@atlaskit/select 17.4.0 → 17.5.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 +6 -0
- package/dist/cjs/Select.js +1 -1
- package/dist/cjs/createSelect.js +114 -62
- package/dist/es2019/Select.js +1 -1
- package/dist/es2019/createSelect.js +89 -56
- package/dist/esm/Select.js +1 -1
- package/dist/esm/createSelect.js +115 -63
- package/dist/types/AsyncCreatableSelect.d.ts +44 -3
- package/dist/types/AsyncSelect.d.ts +44 -3
- package/dist/types/CreatableSelect.d.ts +44 -3
- package/dist/types/Select.d.ts +88 -6
- package/dist/types/components/indicators.d.ts +4 -5
- package/dist/types/createSelect.d.ts +47 -6
- package/dist/types/utils/grouped-options-announcement.d.ts +1 -1
- package/dist/types-ts4.5/AsyncCreatableSelect.d.ts +44 -3
- package/dist/types-ts4.5/AsyncSelect.d.ts +44 -3
- package/dist/types-ts4.5/CreatableSelect.d.ts +44 -3
- package/dist/types-ts4.5/Select.d.ts +88 -6
- package/dist/types-ts4.5/components/indicators.d.ts +4 -5
- package/dist/types-ts4.5/createSelect.d.ts +47 -6
- package/dist/types-ts4.5/utils/grouped-options-announcement.d.ts +1 -1
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/select
|
|
2
2
|
|
|
3
|
+
## 17.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#87916](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/87916) [`373dc429147d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/373dc429147d) - Reverted "Convert AtlaskitSelect from react class component to function component"
|
|
8
|
+
|
|
3
9
|
## 17.4.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/cjs/Select.js
CHANGED
|
@@ -9,7 +9,7 @@ var _reactSelect = _interopRequireDefault(require("react-select"));
|
|
|
9
9
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
10
10
|
var _createSelect = _interopRequireDefault(require("./createSelect"));
|
|
11
11
|
var packageName = "@atlaskit/select";
|
|
12
|
-
var packageVersion = "17.
|
|
12
|
+
var packageVersion = "17.5.0";
|
|
13
13
|
var SelectWithoutAnalytics = exports.SelectWithoutAnalytics = (0, _createSelect.default)(_reactSelect.default);
|
|
14
14
|
var createAndFireEventOnAtlaskit = (0, _analyticsNext.createAndFireEvent)('atlaskit');
|
|
15
15
|
var Select = (0, _analyticsNext.withAnalyticsContext)({
|
package/dist/cjs/createSelect.js
CHANGED
|
@@ -7,80 +7,132 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = createSelect;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
14
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
16
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
17
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
18
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
19
|
var _reactSelect = require("react-select");
|
|
14
|
-
var
|
|
20
|
+
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
21
|
+
var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));
|
|
15
22
|
var _inputAriaDescribedby = require("./components/input-aria-describedby");
|
|
16
23
|
var _components = require("./components");
|
|
17
24
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
18
25
|
var _groupedOptionsAnnouncement = require("./utils/grouped-options-announcement");
|
|
19
|
-
var _excluded = ["
|
|
26
|
+
var _excluded = ["styles", "validationState", "isInvalid", "spacing", "isMulti", "appearance", "ariaLiveMessages"];
|
|
20
27
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
21
28
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
29
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
30
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
31
|
+
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); }; }
|
|
32
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
24
33
|
function createSelect(WrappedComponent) {
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
34
|
+
var _class;
|
|
35
|
+
return _class = /*#__PURE__*/function (_Component) {
|
|
36
|
+
(0, _inherits2.default)(AtlaskitSelect, _Component);
|
|
37
|
+
var _super = _createSuper(AtlaskitSelect);
|
|
38
|
+
function AtlaskitSelect(props) {
|
|
39
|
+
var _this;
|
|
40
|
+
(0, _classCallCheck2.default)(this, AtlaskitSelect);
|
|
41
|
+
_this = _super.call(this, props);
|
|
42
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "components", {});
|
|
43
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "select", null);
|
|
44
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "cacheComponents", function (components) {
|
|
45
|
+
_this.components = _objectSpread({
|
|
46
|
+
ClearIndicator: _components.ClearIndicator ? _components.ClearIndicator : undefined,
|
|
47
|
+
DropdownIndicator: _components.DropdownIndicator,
|
|
48
|
+
LoadingIndicator: _components.LoadingIndicator,
|
|
49
|
+
MultiValueRemove: _components.MultiValueRemove,
|
|
50
|
+
IndicatorSeparator: _components.IndicatorSeparator,
|
|
51
|
+
Input: _inputAriaDescribedby.Input
|
|
52
|
+
}, components);
|
|
53
|
+
});
|
|
54
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onSelectRef", function (ref) {
|
|
55
|
+
_this.select = ref;
|
|
56
|
+
});
|
|
57
|
+
_this.cacheComponents = (0, _memoizeOne.default)(_this.cacheComponents, _reactFastCompare.default).bind((0, _assertThisInitialized2.default)(_this));
|
|
58
|
+
_this.cacheComponents(props.components || {});
|
|
59
|
+
return _this;
|
|
60
|
+
}
|
|
61
|
+
(0, _createClass2.default)(AtlaskitSelect, [{
|
|
62
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
63
|
+
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
64
|
+
this.cacheComponents(nextProps.components);
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
key: "focus",
|
|
68
|
+
value: function focus() {
|
|
69
|
+
if (this.select) {
|
|
70
|
+
this.select.focus();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
key: "blur",
|
|
75
|
+
value: function blur() {
|
|
76
|
+
if (this.select) {
|
|
77
|
+
this.select.blur();
|
|
63
78
|
}
|
|
64
79
|
}
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
}, {
|
|
81
|
+
key: "componentDidMount",
|
|
82
|
+
value: function componentDidMount() {
|
|
83
|
+
var descriptionId = this.props['aria-describedby'];
|
|
84
|
+
if (!this.props.isSearchable && descriptionId) {
|
|
85
|
+
var _this$select;
|
|
86
|
+
// when isSearchable is false, react-select will create its own dummy input instead of using ours,
|
|
87
|
+
// so we need to manually add the additional aria-describedby using ref.
|
|
88
|
+
var input = (_this$select = this.select) === null || _this$select === void 0 ? void 0 : _this$select.inputRef;
|
|
89
|
+
var ariaDescribedby = input === null || input === void 0 ? void 0 : input.getAttribute('aria-describedby');
|
|
90
|
+
if (!(ariaDescribedby !== null && ariaDescribedby !== void 0 && ariaDescribedby.includes(descriptionId))) {
|
|
91
|
+
input === null || input === void 0 || input.setAttribute('aria-describedby', "".concat(ariaDescribedby, " ").concat(descriptionId));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}, {
|
|
96
|
+
key: "render",
|
|
97
|
+
value: function render() {
|
|
98
|
+
var _this$props = this.props,
|
|
99
|
+
styles = _this$props.styles,
|
|
100
|
+
validationState = _this$props.validationState,
|
|
101
|
+
isInvalid = _this$props.isInvalid,
|
|
102
|
+
spacing = _this$props.spacing,
|
|
103
|
+
isMulti = _this$props.isMulti,
|
|
104
|
+
appearance = _this$props.appearance,
|
|
105
|
+
ariaLiveMessages = _this$props.ariaLiveMessages,
|
|
106
|
+
props = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
|
|
107
|
+
var isCompact = spacing === 'compact';
|
|
108
|
+
|
|
109
|
+
// props must be spread first to stop `components` being overridden
|
|
110
|
+
return /*#__PURE__*/_react.default.createElement(WrappedComponent, (0, _extends2.default)({
|
|
111
|
+
ref: this.onSelectRef,
|
|
112
|
+
isMulti: isMulti,
|
|
113
|
+
"aria-live": "assertive",
|
|
114
|
+
ariaLiveMessages: (0, _groupedOptionsAnnouncement.isOptionsGrouped)(this.props.options) ? _objectSpread({
|
|
115
|
+
onFocus: _groupedOptionsAnnouncement.onFocus
|
|
116
|
+
}, ariaLiveMessages) : _objectSpread({}, ariaLiveMessages)
|
|
117
|
+
}, props, {
|
|
118
|
+
components: this.components,
|
|
119
|
+
styles: (0, _reactSelect.mergeStyles)((0, _styles.default)(
|
|
120
|
+
// This will cover both props for invalid state while giving priority to isInvalid. When cleaning up validationState, we can just keep the inner condition.
|
|
121
|
+
typeof isInvalid !== 'undefined' ? isInvalid ? 'error' : 'default' : validationState, isCompact, this.props.appearance || 'default'), styles)
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
}]);
|
|
125
|
+
return AtlaskitSelect;
|
|
126
|
+
}(_react.Component), (0, _defineProperty2.default)(_class, "defaultProps", {
|
|
127
|
+
validationState: 'default',
|
|
128
|
+
// TODO: uncomment the next line when cleaning up validationState prop so it has a default value
|
|
129
|
+
// isInvalid: false,
|
|
130
|
+
spacing: 'default',
|
|
131
|
+
onClickPreventDefault: true,
|
|
132
|
+
tabSelectsValue: false,
|
|
133
|
+
components: {
|
|
134
|
+
Input: _inputAriaDescribedby.Input
|
|
135
|
+
},
|
|
136
|
+
styles: {}
|
|
137
|
+
}), _class;
|
|
86
138
|
}
|
package/dist/es2019/Select.js
CHANGED
|
@@ -2,7 +2,7 @@ import ReactSelect from 'react-select';
|
|
|
2
2
|
import { withAnalyticsEvents, withAnalyticsContext, createAndFireEvent } from '@atlaskit/analytics-next';
|
|
3
3
|
import createSelect from './createSelect';
|
|
4
4
|
const packageName = "@atlaskit/select";
|
|
5
|
-
const packageVersion = "17.
|
|
5
|
+
const packageVersion = "17.5.0";
|
|
6
6
|
export const SelectWithoutAnalytics = createSelect(ReactSelect);
|
|
7
7
|
const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
8
8
|
const Select = withAnalyticsContext({
|
|
@@ -1,71 +1,104 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import React, { Component } from 'react';
|
|
3
4
|
import { mergeStyles } from 'react-select';
|
|
4
|
-
import
|
|
5
|
+
import memoizeOne from 'memoize-one';
|
|
6
|
+
import isEqual from 'react-fast-compare';
|
|
5
7
|
import { Input } from './components/input-aria-describedby';
|
|
6
8
|
import { ClearIndicator, DropdownIndicator, LoadingIndicator, MultiValueRemove, IndicatorSeparator } from './components';
|
|
7
9
|
import baseStyles from './styles';
|
|
8
10
|
import { onFocus, isOptionsGrouped } from './utils/grouped-options-announcement';
|
|
9
11
|
export default function createSelect(WrappedComponent) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
components
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
|
|
12
|
+
var _class;
|
|
13
|
+
return _class = class AtlaskitSelect extends Component {
|
|
14
|
+
constructor(props) {
|
|
15
|
+
super(props);
|
|
16
|
+
_defineProperty(this, "components", {});
|
|
17
|
+
_defineProperty(this, "select", null);
|
|
18
|
+
_defineProperty(this, "cacheComponents", components => {
|
|
19
|
+
this.components = {
|
|
20
|
+
ClearIndicator: ClearIndicator ? ClearIndicator : undefined,
|
|
21
|
+
DropdownIndicator,
|
|
22
|
+
LoadingIndicator,
|
|
23
|
+
MultiValueRemove,
|
|
24
|
+
IndicatorSeparator,
|
|
25
|
+
Input: Input,
|
|
26
|
+
...components
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
_defineProperty(this, "onSelectRef", ref => {
|
|
30
|
+
this.select = ref;
|
|
31
|
+
});
|
|
32
|
+
this.cacheComponents = memoizeOne(this.cacheComponents, isEqual).bind(this);
|
|
33
|
+
this.cacheComponents(props.components || {});
|
|
34
|
+
}
|
|
35
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
36
|
+
this.cacheComponents(nextProps.components);
|
|
37
|
+
}
|
|
38
|
+
focus() {
|
|
39
|
+
if (this.select) {
|
|
40
|
+
this.select.focus();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
blur() {
|
|
44
|
+
if (this.select) {
|
|
45
|
+
this.select.blur();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
componentDidMount() {
|
|
49
|
+
const descriptionId = this.props['aria-describedby'];
|
|
50
|
+
if (!this.props.isSearchable && descriptionId) {
|
|
51
|
+
var _this$select;
|
|
39
52
|
// when isSearchable is false, react-select will create its own dummy input instead of using ours,
|
|
40
53
|
// so we need to manually add the additional aria-describedby using ref.
|
|
41
|
-
const input = (
|
|
54
|
+
const input = (_this$select = this.select) === null || _this$select === void 0 ? void 0 : _this$select.inputRef;
|
|
42
55
|
const ariaDescribedby = input === null || input === void 0 ? void 0 : input.getAttribute('aria-describedby');
|
|
43
56
|
if (!(ariaDescribedby !== null && ariaDescribedby !== void 0 && ariaDescribedby.includes(descriptionId))) {
|
|
44
57
|
input === null || input === void 0 ? void 0 : input.setAttribute('aria-describedby', `${ariaDescribedby} ${descriptionId}`);
|
|
45
58
|
}
|
|
46
59
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
}
|
|
61
|
+
render() {
|
|
62
|
+
const {
|
|
63
|
+
styles,
|
|
64
|
+
validationState,
|
|
65
|
+
isInvalid,
|
|
66
|
+
spacing,
|
|
67
|
+
isMulti,
|
|
68
|
+
appearance,
|
|
69
|
+
ariaLiveMessages,
|
|
70
|
+
...props
|
|
71
|
+
} = this.props;
|
|
72
|
+
const isCompact = spacing === 'compact';
|
|
73
|
+
|
|
74
|
+
// props must be spread first to stop `components` being overridden
|
|
75
|
+
return /*#__PURE__*/React.createElement(WrappedComponent, _extends({
|
|
76
|
+
ref: this.onSelectRef,
|
|
77
|
+
isMulti: isMulti,
|
|
78
|
+
"aria-live": "assertive",
|
|
79
|
+
ariaLiveMessages: isOptionsGrouped(this.props.options) ? {
|
|
80
|
+
onFocus,
|
|
81
|
+
...ariaLiveMessages
|
|
82
|
+
} : {
|
|
83
|
+
...ariaLiveMessages
|
|
84
|
+
}
|
|
85
|
+
}, props, {
|
|
86
|
+
components: this.components,
|
|
87
|
+
styles: mergeStyles(baseStyles(
|
|
88
|
+
// This will cover both props for invalid state while giving priority to isInvalid. When cleaning up validationState, we can just keep the inner condition.
|
|
89
|
+
typeof isInvalid !== 'undefined' ? isInvalid ? 'error' : 'default' : validationState, isCompact, this.props.appearance || 'default'), styles)
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
}, _defineProperty(_class, "defaultProps", {
|
|
93
|
+
validationState: 'default',
|
|
94
|
+
// TODO: uncomment the next line when cleaning up validationState prop so it has a default value
|
|
95
|
+
// isInvalid: false,
|
|
96
|
+
spacing: 'default',
|
|
97
|
+
onClickPreventDefault: true,
|
|
98
|
+
tabSelectsValue: false,
|
|
99
|
+
components: {
|
|
100
|
+
Input
|
|
101
|
+
},
|
|
102
|
+
styles: {}
|
|
103
|
+
}), _class;
|
|
71
104
|
}
|
package/dist/esm/Select.js
CHANGED
|
@@ -2,7 +2,7 @@ import ReactSelect from 'react-select';
|
|
|
2
2
|
import { withAnalyticsEvents, withAnalyticsContext, createAndFireEvent } from '@atlaskit/analytics-next';
|
|
3
3
|
import createSelect from './createSelect';
|
|
4
4
|
var packageName = "@atlaskit/select";
|
|
5
|
-
var packageVersion = "17.
|
|
5
|
+
var packageVersion = "17.5.0";
|
|
6
6
|
export var SelectWithoutAnalytics = createSelect(ReactSelect);
|
|
7
7
|
var createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
8
8
|
var Select = withAnalyticsContext({
|
package/dist/esm/createSelect.js
CHANGED
|
@@ -1,76 +1,128 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
8
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
|
+
var _excluded = ["styles", "validationState", "isInvalid", "spacing", "isMulti", "appearance", "ariaLiveMessages"];
|
|
5
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
-
|
|
13
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
15
|
+
import React, { Component } from 'react';
|
|
8
16
|
import { mergeStyles } from 'react-select';
|
|
9
|
-
import
|
|
17
|
+
import memoizeOne from 'memoize-one';
|
|
18
|
+
import isEqual from 'react-fast-compare';
|
|
10
19
|
import { Input } from './components/input-aria-describedby';
|
|
11
20
|
import { ClearIndicator, DropdownIndicator, LoadingIndicator, MultiValueRemove, IndicatorSeparator } from './components';
|
|
12
21
|
import baseStyles from './styles';
|
|
13
22
|
import { onFocus, isOptionsGrouped } from './utils/grouped-options-announcement';
|
|
14
23
|
export default function createSelect(WrappedComponent) {
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
24
|
+
var _class;
|
|
25
|
+
return _class = /*#__PURE__*/function (_Component) {
|
|
26
|
+
_inherits(AtlaskitSelect, _Component);
|
|
27
|
+
var _super = _createSuper(AtlaskitSelect);
|
|
28
|
+
function AtlaskitSelect(props) {
|
|
29
|
+
var _this;
|
|
30
|
+
_classCallCheck(this, AtlaskitSelect);
|
|
31
|
+
_this = _super.call(this, props);
|
|
32
|
+
_defineProperty(_assertThisInitialized(_this), "components", {});
|
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "select", null);
|
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "cacheComponents", function (components) {
|
|
35
|
+
_this.components = _objectSpread({
|
|
36
|
+
ClearIndicator: ClearIndicator ? ClearIndicator : undefined,
|
|
37
|
+
DropdownIndicator: DropdownIndicator,
|
|
38
|
+
LoadingIndicator: LoadingIndicator,
|
|
39
|
+
MultiValueRemove: MultiValueRemove,
|
|
40
|
+
IndicatorSeparator: IndicatorSeparator,
|
|
41
|
+
Input: Input
|
|
42
|
+
}, components);
|
|
43
|
+
});
|
|
44
|
+
_defineProperty(_assertThisInitialized(_this), "onSelectRef", function (ref) {
|
|
45
|
+
_this.select = ref;
|
|
46
|
+
});
|
|
47
|
+
_this.cacheComponents = memoizeOne(_this.cacheComponents, isEqual).bind(_assertThisInitialized(_this));
|
|
48
|
+
_this.cacheComponents(props.components || {});
|
|
49
|
+
return _this;
|
|
50
|
+
}
|
|
51
|
+
_createClass(AtlaskitSelect, [{
|
|
52
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
53
|
+
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
54
|
+
this.cacheComponents(nextProps.components);
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
key: "focus",
|
|
58
|
+
value: function focus() {
|
|
59
|
+
if (this.select) {
|
|
60
|
+
this.select.focus();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
key: "blur",
|
|
65
|
+
value: function blur() {
|
|
66
|
+
if (this.select) {
|
|
67
|
+
this.select.blur();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
key: "componentDidMount",
|
|
72
|
+
value: function componentDidMount() {
|
|
73
|
+
var descriptionId = this.props['aria-describedby'];
|
|
74
|
+
if (!this.props.isSearchable && descriptionId) {
|
|
75
|
+
var _this$select;
|
|
76
|
+
// when isSearchable is false, react-select will create its own dummy input instead of using ours,
|
|
77
|
+
// so we need to manually add the additional aria-describedby using ref.
|
|
78
|
+
var input = (_this$select = this.select) === null || _this$select === void 0 ? void 0 : _this$select.inputRef;
|
|
79
|
+
var ariaDescribedby = input === null || input === void 0 ? void 0 : input.getAttribute('aria-describedby');
|
|
80
|
+
if (!(ariaDescribedby !== null && ariaDescribedby !== void 0 && ariaDescribedby.includes(descriptionId))) {
|
|
81
|
+
input === null || input === void 0 || input.setAttribute('aria-describedby', "".concat(ariaDescribedby, " ").concat(descriptionId));
|
|
82
|
+
}
|
|
53
83
|
}
|
|
54
84
|
}
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
85
|
+
}, {
|
|
86
|
+
key: "render",
|
|
87
|
+
value: function render() {
|
|
88
|
+
var _this$props = this.props,
|
|
89
|
+
styles = _this$props.styles,
|
|
90
|
+
validationState = _this$props.validationState,
|
|
91
|
+
isInvalid = _this$props.isInvalid,
|
|
92
|
+
spacing = _this$props.spacing,
|
|
93
|
+
isMulti = _this$props.isMulti,
|
|
94
|
+
appearance = _this$props.appearance,
|
|
95
|
+
ariaLiveMessages = _this$props.ariaLiveMessages,
|
|
96
|
+
props = _objectWithoutProperties(_this$props, _excluded);
|
|
97
|
+
var isCompact = spacing === 'compact';
|
|
98
|
+
|
|
99
|
+
// props must be spread first to stop `components` being overridden
|
|
100
|
+
return /*#__PURE__*/React.createElement(WrappedComponent, _extends({
|
|
101
|
+
ref: this.onSelectRef,
|
|
102
|
+
isMulti: isMulti,
|
|
103
|
+
"aria-live": "assertive",
|
|
104
|
+
ariaLiveMessages: isOptionsGrouped(this.props.options) ? _objectSpread({
|
|
105
|
+
onFocus: onFocus
|
|
106
|
+
}, ariaLiveMessages) : _objectSpread({}, ariaLiveMessages)
|
|
107
|
+
}, props, {
|
|
108
|
+
components: this.components,
|
|
109
|
+
styles: mergeStyles(baseStyles(
|
|
110
|
+
// This will cover both props for invalid state while giving priority to isInvalid. When cleaning up validationState, we can just keep the inner condition.
|
|
111
|
+
typeof isInvalid !== 'undefined' ? isInvalid ? 'error' : 'default' : validationState, isCompact, this.props.appearance || 'default'), styles)
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
}]);
|
|
115
|
+
return AtlaskitSelect;
|
|
116
|
+
}(Component), _defineProperty(_class, "defaultProps", {
|
|
117
|
+
validationState: 'default',
|
|
118
|
+
// TODO: uncomment the next line when cleaning up validationState prop so it has a default value
|
|
119
|
+
// isInvalid: false,
|
|
120
|
+
spacing: 'default',
|
|
121
|
+
onClickPreventDefault: true,
|
|
122
|
+
tabSelectsValue: false,
|
|
123
|
+
components: {
|
|
124
|
+
Input: Input
|
|
125
|
+
},
|
|
126
|
+
styles: {}
|
|
127
|
+
}), _class;
|
|
76
128
|
}
|