@atlaskit/select 17.3.3 → 17.4.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 +12 -0
- package/dist/cjs/Select.js +1 -1
- package/dist/cjs/components/input-aria-describedby.js +3 -3
- package/dist/cjs/createSelect.js +62 -113
- package/dist/es2019/Select.js +1 -1
- package/dist/es2019/components/input-aria-describedby.js +2 -2
- package/dist/es2019/createSelect.js +56 -88
- package/dist/esm/Select.js +1 -1
- package/dist/esm/components/input-aria-describedby.js +2 -2
- package/dist/esm/createSelect.js +63 -114
- package/dist/types/AsyncCreatableSelect.d.ts +3 -44
- package/dist/types/AsyncSelect.d.ts +3 -44
- package/dist/types/CreatableSelect.d.ts +3 -44
- package/dist/types/Select.d.ts +6 -88
- package/dist/types/components/indicators.d.ts +5 -4
- package/dist/types/components/input-aria-describedby.d.ts +2 -1
- package/dist/types/createSelect.d.ts +6 -46
- package/dist/types/utils/grouped-options-announcement.d.ts +1 -1
- package/dist/types-ts4.5/AsyncCreatableSelect.d.ts +3 -44
- package/dist/types-ts4.5/AsyncSelect.d.ts +3 -44
- package/dist/types-ts4.5/CreatableSelect.d.ts +3 -44
- package/dist/types-ts4.5/Select.d.ts +6 -88
- package/dist/types-ts4.5/components/indicators.d.ts +5 -4
- package/dist/types-ts4.5/components/input-aria-describedby.d.ts +2 -1
- package/dist/types-ts4.5/createSelect.d.ts +6 -46
- package/dist/types-ts4.5/utils/grouped-options-announcement.d.ts +1 -1
- package/package.json +4 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/select
|
|
2
2
|
|
|
3
|
+
## 17.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#86848](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/86848) [`fa9de32b502e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fa9de32b502e) - Convert AtlaskitSelect from react class component to function component
|
|
8
|
+
|
|
9
|
+
## 17.3.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#83706](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83706) [`2c6f01982c94`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2c6f01982c94) - Fixed aria-describedby attribute being incorrect when components prop is passed
|
|
14
|
+
|
|
3
15
|
## 17.3.3
|
|
4
16
|
|
|
5
17
|
### Patch 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.4.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)({
|
|
@@ -4,11 +4,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.Input =
|
|
7
|
+
exports.Input = Input;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _reactSelect = require("react-select");
|
|
11
|
-
|
|
11
|
+
function Input(props) {
|
|
12
12
|
var ariaDescribedByAttribute;
|
|
13
13
|
var passed_describedby = props.selectProps['aria-describedby'];
|
|
14
14
|
if (props['aria-describedby'] && passed_describedby) {
|
|
@@ -19,4 +19,4 @@ var Input = exports.Input = function Input(props) {
|
|
|
19
19
|
return /*#__PURE__*/_react.default.createElement(_reactSelect.components.Input, (0, _extends2.default)({}, props, {
|
|
20
20
|
"aria-describedby": ariaDescribedByAttribute
|
|
21
21
|
}));
|
|
22
|
-
}
|
|
22
|
+
}
|
package/dist/cjs/createSelect.js
CHANGED
|
@@ -7,131 +7,80 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = createSelect;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
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
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
18
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
19
13
|
var _reactSelect = require("react-select");
|
|
20
|
-
var
|
|
21
|
-
var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));
|
|
14
|
+
var _mergeRefs = _interopRequireDefault(require("@atlaskit/ds-lib/merge-refs"));
|
|
22
15
|
var _inputAriaDescribedby = require("./components/input-aria-describedby");
|
|
23
16
|
var _components = require("./components");
|
|
24
17
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
25
18
|
var _groupedOptionsAnnouncement = require("./utils/grouped-options-announcement");
|
|
26
|
-
var _excluded = ["
|
|
19
|
+
var _excluded = ["appearance", "ariaLiveMessages", "components", "isInvalid", "onClickPreventDefault", "spacing", "styles", "tabSelectsValue", "validationState"];
|
|
27
20
|
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); }
|
|
28
21
|
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; }
|
|
29
22
|
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; }
|
|
30
23
|
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; })(); }
|
|
33
24
|
function createSelect(WrappedComponent) {
|
|
34
|
-
var
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}, {
|
|
73
|
-
key: "blur",
|
|
74
|
-
value: function blur() {
|
|
75
|
-
if (this.select) {
|
|
76
|
-
this.select.blur();
|
|
25
|
+
var AtlaskitSelect = /*#__PURE__*/(0, _react.forwardRef)(function AtlaskitSelect(props, forwardedRef) {
|
|
26
|
+
var appearance = props.appearance,
|
|
27
|
+
ariaLiveMessages = props.ariaLiveMessages,
|
|
28
|
+
componentsProp = props.components,
|
|
29
|
+
isInvalid = props.isInvalid,
|
|
30
|
+
_props$onClickPrevent = props.onClickPreventDefault,
|
|
31
|
+
onClickPreventDefault = _props$onClickPrevent === void 0 ? true : _props$onClickPrevent,
|
|
32
|
+
_props$spacing = props.spacing,
|
|
33
|
+
spacing = _props$spacing === void 0 ? 'default' : _props$spacing,
|
|
34
|
+
_props$styles = props.styles,
|
|
35
|
+
styles = _props$styles === void 0 ? {} : _props$styles,
|
|
36
|
+
_props$tabSelectsValu = props.tabSelectsValue,
|
|
37
|
+
tabSelectsValue = _props$tabSelectsValu === void 0 ? false : _props$tabSelectsValu,
|
|
38
|
+
_props$validationStat = props.validationState,
|
|
39
|
+
validationState = _props$validationStat === void 0 ? 'default' : _props$validationStat,
|
|
40
|
+
restProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
41
|
+
var internalSelectRef = (0, _react.useRef)(null);
|
|
42
|
+
var components = (0, _react.useMemo)(function () {
|
|
43
|
+
return _objectSpread({
|
|
44
|
+
ClearIndicator: _components.ClearIndicator,
|
|
45
|
+
DropdownIndicator: _components.DropdownIndicator,
|
|
46
|
+
LoadingIndicator: _components.LoadingIndicator,
|
|
47
|
+
MultiValueRemove: _components.MultiValueRemove,
|
|
48
|
+
IndicatorSeparator: _components.IndicatorSeparator,
|
|
49
|
+
Input: _inputAriaDescribedby.Input
|
|
50
|
+
}, componentsProp);
|
|
51
|
+
}, [componentsProp]);
|
|
52
|
+
var descriptionId = props['aria-describedby'];
|
|
53
|
+
var isSearchable = props.isSearchable;
|
|
54
|
+
(0, _react.useEffect)(function () {
|
|
55
|
+
if (!isSearchable && descriptionId) {
|
|
56
|
+
var _internalSelectRef$cu;
|
|
57
|
+
// when isSearchable is false, react-select will create its own dummy input instead of using ours,
|
|
58
|
+
// so we need to manually add the additional aria-describedby using ref.
|
|
59
|
+
var input = (_internalSelectRef$cu = internalSelectRef.current) === null || _internalSelectRef$cu === void 0 ? void 0 : _internalSelectRef$cu.inputRef;
|
|
60
|
+
var ariaDescribedby = input === null || input === void 0 ? void 0 : input.getAttribute('aria-describedby');
|
|
61
|
+
if (!(ariaDescribedby !== null && ariaDescribedby !== void 0 && ariaDescribedby.includes(descriptionId))) {
|
|
62
|
+
input === null || input === void 0 || input.setAttribute('aria-describedby', "".concat(ariaDescribedby, " ").concat(descriptionId));
|
|
77
63
|
}
|
|
78
64
|
}
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
isInvalid = _this$props.isInvalid,
|
|
101
|
-
spacing = _this$props.spacing,
|
|
102
|
-
isMulti = _this$props.isMulti,
|
|
103
|
-
appearance = _this$props.appearance,
|
|
104
|
-
ariaLiveMessages = _this$props.ariaLiveMessages,
|
|
105
|
-
props = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
|
|
106
|
-
var isCompact = spacing === 'compact';
|
|
107
|
-
|
|
108
|
-
// props must be spread first to stop `components` being overridden
|
|
109
|
-
return /*#__PURE__*/_react.default.createElement(WrappedComponent, (0, _extends2.default)({
|
|
110
|
-
ref: this.onSelectRef,
|
|
111
|
-
isMulti: isMulti,
|
|
112
|
-
"aria-live": "assertive",
|
|
113
|
-
ariaLiveMessages: (0, _groupedOptionsAnnouncement.isOptionsGrouped)(this.props.options) ? _objectSpread({
|
|
114
|
-
onFocus: _groupedOptionsAnnouncement.onFocus
|
|
115
|
-
}, ariaLiveMessages) : _objectSpread({}, ariaLiveMessages)
|
|
116
|
-
}, props, {
|
|
117
|
-
components: this.components,
|
|
118
|
-
styles: (0, _reactSelect.mergeStyles)((0, _styles.default)(
|
|
119
|
-
// This will cover both props for invalid state while giving priority to isInvalid. When cleaning up validationState, we can just keep the inner condition.
|
|
120
|
-
typeof isInvalid !== 'undefined' ? isInvalid ? 'error' : 'default' : validationState, isCompact, this.props.appearance || 'default'), styles)
|
|
121
|
-
}));
|
|
122
|
-
}
|
|
123
|
-
}]);
|
|
124
|
-
return AtlaskitSelect;
|
|
125
|
-
}(_react.Component), (0, _defineProperty2.default)(_class, "defaultProps", {
|
|
126
|
-
validationState: 'default',
|
|
127
|
-
// TODO: uncomment the next line when cleaning up validationState prop so it has a default value
|
|
128
|
-
// isInvalid: false,
|
|
129
|
-
spacing: 'default',
|
|
130
|
-
onClickPreventDefault: true,
|
|
131
|
-
tabSelectsValue: false,
|
|
132
|
-
components: {
|
|
133
|
-
Input: _inputAriaDescribedby.Input
|
|
134
|
-
},
|
|
135
|
-
styles: {}
|
|
136
|
-
}), _class;
|
|
65
|
+
}, [descriptionId, isSearchable]);
|
|
66
|
+
var isCompact = spacing === 'compact';
|
|
67
|
+
return /*#__PURE__*/_react.default.createElement(WrappedComponent
|
|
68
|
+
// @ts-ignore - mergeRefs only supports HTMLElement
|
|
69
|
+
, (0, _extends2.default)({
|
|
70
|
+
ref: (0, _mergeRefs.default)([forwardedRef, internalSelectRef]),
|
|
71
|
+
"aria-live": "assertive",
|
|
72
|
+
ariaLiveMessages: (0, _groupedOptionsAnnouncement.isOptionsGrouped)(props.options) ? _objectSpread({
|
|
73
|
+
onFocus: _groupedOptionsAnnouncement.onFocus
|
|
74
|
+
}, ariaLiveMessages) : _objectSpread({}, ariaLiveMessages),
|
|
75
|
+
tabSelectsValue: tabSelectsValue,
|
|
76
|
+
onClickPreventDefault: onClickPreventDefault
|
|
77
|
+
}, restProps, {
|
|
78
|
+
components: components,
|
|
79
|
+
styles: (0, _reactSelect.mergeStyles)((0, _styles.default)(
|
|
80
|
+
// This will cover both props for invalid state while giving priority to isInvalid. When cleaning up validationState, we can just keep the inner condition.
|
|
81
|
+
typeof isInvalid !== 'undefined' ? isInvalid ? 'error' : 'default' : validationState, isCompact, appearance || 'default'), styles)
|
|
82
|
+
}));
|
|
83
|
+
});
|
|
84
|
+
AtlaskitSelect.displayName = 'AtlaskitSelect';
|
|
85
|
+
return AtlaskitSelect;
|
|
137
86
|
}
|
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.4.0";
|
|
6
6
|
export const SelectWithoutAnalytics = createSelect(ReactSelect);
|
|
7
7
|
const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
8
8
|
const Select = withAnalyticsContext({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { components } from 'react-select';
|
|
4
|
-
export
|
|
4
|
+
export function Input(props) {
|
|
5
5
|
let ariaDescribedByAttribute;
|
|
6
6
|
const passed_describedby = props.selectProps['aria-describedby'];
|
|
7
7
|
if (props['aria-describedby'] && passed_describedby) {
|
|
@@ -12,4 +12,4 @@ export const Input = props => {
|
|
|
12
12
|
return /*#__PURE__*/React.createElement(components.Input, _extends({}, props, {
|
|
13
13
|
"aria-describedby": ariaDescribedByAttribute
|
|
14
14
|
}));
|
|
15
|
-
}
|
|
15
|
+
}
|
|
@@ -1,103 +1,71 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import
|
|
3
|
-
import React, { Component } from 'react';
|
|
2
|
+
import React, { useRef, useEffect, useMemo, forwardRef } from 'react';
|
|
4
3
|
import { mergeStyles } from 'react-select';
|
|
5
|
-
import
|
|
6
|
-
import isEqual from 'react-fast-compare';
|
|
4
|
+
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
7
5
|
import { Input } from './components/input-aria-describedby';
|
|
8
6
|
import { ClearIndicator, DropdownIndicator, LoadingIndicator, MultiValueRemove, IndicatorSeparator } from './components';
|
|
9
7
|
import baseStyles from './styles';
|
|
10
8
|
import { onFocus, isOptionsGrouped } from './utils/grouped-options-announcement';
|
|
11
9
|
export default function createSelect(WrappedComponent) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
blur() {
|
|
43
|
-
if (this.select) {
|
|
44
|
-
this.select.blur();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
componentDidMount() {
|
|
48
|
-
const descriptionId = this.props['aria-describedby'];
|
|
49
|
-
if (!this.props.isSearchable && descriptionId) {
|
|
50
|
-
var _this$select;
|
|
10
|
+
const AtlaskitSelect = /*#__PURE__*/forwardRef(function AtlaskitSelect(props, forwardedRef) {
|
|
11
|
+
const {
|
|
12
|
+
appearance,
|
|
13
|
+
ariaLiveMessages,
|
|
14
|
+
components: componentsProp,
|
|
15
|
+
isInvalid,
|
|
16
|
+
// TODO: set to true when cleaning up validationState prop so it has a default value
|
|
17
|
+
onClickPreventDefault = true,
|
|
18
|
+
spacing = 'default',
|
|
19
|
+
styles = {},
|
|
20
|
+
tabSelectsValue = false,
|
|
21
|
+
validationState = 'default',
|
|
22
|
+
...restProps
|
|
23
|
+
} = props;
|
|
24
|
+
const internalSelectRef = useRef(null);
|
|
25
|
+
const components = useMemo(() => ({
|
|
26
|
+
ClearIndicator,
|
|
27
|
+
DropdownIndicator,
|
|
28
|
+
LoadingIndicator,
|
|
29
|
+
MultiValueRemove,
|
|
30
|
+
IndicatorSeparator,
|
|
31
|
+
Input,
|
|
32
|
+
...componentsProp
|
|
33
|
+
}), [componentsProp]);
|
|
34
|
+
const descriptionId = props['aria-describedby'];
|
|
35
|
+
const isSearchable = props.isSearchable;
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!isSearchable && descriptionId) {
|
|
38
|
+
var _internalSelectRef$cu;
|
|
51
39
|
// when isSearchable is false, react-select will create its own dummy input instead of using ours,
|
|
52
40
|
// so we need to manually add the additional aria-describedby using ref.
|
|
53
|
-
const input = (
|
|
41
|
+
const input = (_internalSelectRef$cu = internalSelectRef.current) === null || _internalSelectRef$cu === void 0 ? void 0 : _internalSelectRef$cu.inputRef;
|
|
54
42
|
const ariaDescribedby = input === null || input === void 0 ? void 0 : input.getAttribute('aria-describedby');
|
|
55
43
|
if (!(ariaDescribedby !== null && ariaDescribedby !== void 0 && ariaDescribedby.includes(descriptionId))) {
|
|
56
44
|
input === null || input === void 0 ? void 0 : input.setAttribute('aria-describedby', `${ariaDescribedby} ${descriptionId}`);
|
|
57
45
|
}
|
|
58
46
|
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
ariaLiveMessages
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
}, props, {
|
|
85
|
-
components: this.components,
|
|
86
|
-
styles: mergeStyles(baseStyles(
|
|
87
|
-
// This will cover both props for invalid state while giving priority to isInvalid. When cleaning up validationState, we can just keep the inner condition.
|
|
88
|
-
typeof isInvalid !== 'undefined' ? isInvalid ? 'error' : 'default' : validationState, isCompact, this.props.appearance || 'default'), styles)
|
|
89
|
-
}));
|
|
90
|
-
}
|
|
91
|
-
}, _defineProperty(_class, "defaultProps", {
|
|
92
|
-
validationState: 'default',
|
|
93
|
-
// TODO: uncomment the next line when cleaning up validationState prop so it has a default value
|
|
94
|
-
// isInvalid: false,
|
|
95
|
-
spacing: 'default',
|
|
96
|
-
onClickPreventDefault: true,
|
|
97
|
-
tabSelectsValue: false,
|
|
98
|
-
components: {
|
|
99
|
-
Input
|
|
100
|
-
},
|
|
101
|
-
styles: {}
|
|
102
|
-
}), _class;
|
|
47
|
+
}, [descriptionId, isSearchable]);
|
|
48
|
+
const isCompact = spacing === 'compact';
|
|
49
|
+
return /*#__PURE__*/React.createElement(WrappedComponent
|
|
50
|
+
// @ts-ignore - mergeRefs only supports HTMLElement
|
|
51
|
+
, _extends({
|
|
52
|
+
ref: mergeRefs([forwardedRef, internalSelectRef]),
|
|
53
|
+
"aria-live": "assertive",
|
|
54
|
+
ariaLiveMessages: isOptionsGrouped(props.options) ? {
|
|
55
|
+
onFocus,
|
|
56
|
+
...ariaLiveMessages
|
|
57
|
+
} : {
|
|
58
|
+
...ariaLiveMessages
|
|
59
|
+
},
|
|
60
|
+
tabSelectsValue: tabSelectsValue,
|
|
61
|
+
onClickPreventDefault: onClickPreventDefault
|
|
62
|
+
}, restProps, {
|
|
63
|
+
components: components,
|
|
64
|
+
styles: mergeStyles(baseStyles(
|
|
65
|
+
// This will cover both props for invalid state while giving priority to isInvalid. When cleaning up validationState, we can just keep the inner condition.
|
|
66
|
+
typeof isInvalid !== 'undefined' ? isInvalid ? 'error' : 'default' : validationState, isCompact, appearance || 'default'), styles)
|
|
67
|
+
}));
|
|
68
|
+
});
|
|
69
|
+
AtlaskitSelect.displayName = 'AtlaskitSelect';
|
|
70
|
+
return AtlaskitSelect;
|
|
103
71
|
}
|
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.4.0";
|
|
6
6
|
export var SelectWithoutAnalytics = createSelect(ReactSelect);
|
|
7
7
|
var createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
8
8
|
var Select = withAnalyticsContext({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { components } from 'react-select';
|
|
4
|
-
export
|
|
4
|
+
export function Input(props) {
|
|
5
5
|
var ariaDescribedByAttribute;
|
|
6
6
|
var passed_describedby = props.selectProps['aria-describedby'];
|
|
7
7
|
if (props['aria-describedby'] && passed_describedby) {
|
|
@@ -12,4 +12,4 @@ export var Input = function Input(props) {
|
|
|
12
12
|
return /*#__PURE__*/React.createElement(components.Input, _extends({}, props, {
|
|
13
13
|
"aria-describedby": ariaDescribedByAttribute
|
|
14
14
|
}));
|
|
15
|
-
}
|
|
15
|
+
}
|