@atlaskit/react-select 2.6.6 → 2.7.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 +9 -0
- package/dist/cjs/accessibility/index.js +3 -49
- package/dist/cjs/compiled/components/live-region.js +8 -72
- package/dist/cjs/emotion/components/live-region.js +10 -76
- package/dist/cjs/select.js +141 -99
- package/dist/es2019/accessibility/index.js +3 -50
- package/dist/es2019/compiled/components/live-region.js +7 -71
- package/dist/es2019/emotion/components/live-region.js +7 -72
- package/dist/es2019/select.js +117 -82
- package/dist/esm/accessibility/index.js +3 -49
- package/dist/esm/compiled/components/live-region.js +9 -73
- package/dist/esm/emotion/components/live-region.js +9 -74
- package/dist/esm/select.js +139 -98
- package/dist/types/accessibility/index.d.ts +0 -2
- package/dist/types/compiled/components/live-region.d.ts +0 -2
- package/dist/types/emotion/components/live-region.d.ts +0 -2
- package/dist/types/select.d.ts +5 -6
- package/dist/types-ts4.5/accessibility/index.d.ts +0 -2
- package/dist/types-ts4.5/compiled/components/live-region.d.ts +0 -2
- package/dist/types-ts4.5/emotion/components/live-region.d.ts +0 -2
- package/dist/types-ts4.5/select.d.ts +5 -6
- package/package.json +1 -4
|
@@ -1,73 +1,27 @@
|
|
|
1
1
|
/* eslint-disable @atlaskit/platform/ensure-feature-flag-prefix */
|
|
2
2
|
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
export var defaultAriaLiveMessages = {
|
|
5
|
-
guidance: function guidance(props) {
|
|
6
|
-
var isSearchable = props.isSearchable,
|
|
7
|
-
isMulti = props.isMulti,
|
|
8
|
-
tabSelectsValue = props.tabSelectsValue,
|
|
9
|
-
context = props.context,
|
|
10
|
-
isInitialFocus = props.isInitialFocus;
|
|
11
|
-
switch (context) {
|
|
12
|
-
case 'menu':
|
|
13
|
-
return "Use Up and Down to choose options, press Enter to select the currently focused option, press Escape to exit the menu".concat(tabSelectsValue ? ', press Tab to select the option and exit the menu' : '', ".");
|
|
14
|
-
case 'input':
|
|
15
|
-
return isInitialFocus ? "".concat(props['aria-label'] || 'Select', " is focused ").concat(isSearchable ? ',type to refine list' : '', ", press Down to open the menu, ").concat(isMulti ? ' press left to focus selected values' : '') : '';
|
|
16
|
-
case 'value':
|
|
17
|
-
return 'Use left and right to toggle between focused values, press Backspace to remove the currently focused value';
|
|
18
|
-
default:
|
|
19
|
-
return '';
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
4
|
onChange: function onChange(props) {
|
|
23
5
|
var action = props.action,
|
|
24
6
|
_props$label = props.label,
|
|
25
7
|
label = _props$label === void 0 ? '' : _props$label,
|
|
26
|
-
labels = props.labels,
|
|
27
8
|
isDisabled = props.isDisabled;
|
|
28
9
|
switch (action) {
|
|
29
10
|
case 'deselect-option':
|
|
30
11
|
case 'pop-value':
|
|
31
12
|
case 'remove-value':
|
|
32
|
-
return label.length
|
|
33
|
-
// TODO: this should be handled on backspace|delete if no value, but doing it here first
|
|
13
|
+
return label.length ? "option ".concat(label, ", deselected") : '';
|
|
34
14
|
case 'clear':
|
|
35
15
|
return 'All selected options have been cleared.';
|
|
36
|
-
case 'initial-input-focus':
|
|
37
|
-
return label.length && fg('design_system_select-a11y-improvement') || !fg('design_system_select-a11y-improvement') ? "option".concat(labels.length > 1 ? 's' : '', " ").concat(labels.join(','), ", selected.") : '';
|
|
38
16
|
case 'select-option':
|
|
39
|
-
return
|
|
17
|
+
return label.length && !isDisabled ? "option ".concat(label, ", selected.") : '';
|
|
40
18
|
default:
|
|
41
19
|
return '';
|
|
42
20
|
}
|
|
43
21
|
},
|
|
44
|
-
onFocus: function onFocus(props) {
|
|
45
|
-
var context = props.context,
|
|
46
|
-
focused = props.focused,
|
|
47
|
-
options = props.options,
|
|
48
|
-
_props$label2 = props.label,
|
|
49
|
-
label = _props$label2 === void 0 ? '' : _props$label2,
|
|
50
|
-
selectValue = props.selectValue,
|
|
51
|
-
isDisabled = props.isDisabled,
|
|
52
|
-
isSelected = props.isSelected;
|
|
53
|
-
var getArrayIndex = function getArrayIndex(arr, item) {
|
|
54
|
-
return arr && arr.length ? "(".concat(arr.indexOf(item) + 1, " of ").concat(arr.length, ")") : '';
|
|
55
|
-
};
|
|
56
|
-
if (context === 'value' && selectValue) {
|
|
57
|
-
return "value ".concat(label, " focused, ").concat(getArrayIndex(selectValue, focused), ".");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// No longer needed after fg('design_system_select-a11y-improvement') is cleaned up
|
|
61
|
-
if (context === 'menu' && !fg('design_system_select-a11y-improvement')) {
|
|
62
|
-
var disabled = isDisabled ? ' disabled' : '';
|
|
63
|
-
var status = "".concat(isSelected ? ' selected' : ' not selected').concat(disabled);
|
|
64
|
-
return "".concat(label).concat(status, ", ").concat(getArrayIndex(options, focused), ", completion selected");
|
|
65
|
-
}
|
|
66
|
-
return '';
|
|
67
|
-
},
|
|
68
22
|
onFilter: function onFilter(props) {
|
|
69
23
|
var inputValue = props.inputValue,
|
|
70
24
|
resultsMessage = props.resultsMessage;
|
|
71
|
-
return "".concat(resultsMessage
|
|
25
|
+
return inputValue ? "".concat(resultsMessage, " for search term ").concat(inputValue, ".") : '';
|
|
72
26
|
}
|
|
73
27
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
|
-
import React, { Fragment, useMemo
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import React, { Fragment, useMemo } from 'react';
|
|
6
5
|
import { defaultAriaLiveMessages } from '../../accessibility';
|
|
7
6
|
import A11yText from './internal/a11y-text';
|
|
8
7
|
|
|
@@ -12,32 +11,21 @@ import A11yText from './internal/a11y-text';
|
|
|
12
11
|
|
|
13
12
|
var LiveRegion = function LiveRegion(props) {
|
|
14
13
|
var ariaSelection = props.ariaSelection,
|
|
15
|
-
focusedOption = props.focusedOption,
|
|
16
|
-
focusedValue = props.focusedValue,
|
|
17
14
|
focusableOptions = props.focusableOptions,
|
|
18
15
|
isFocused = props.isFocused,
|
|
19
16
|
selectValue = props.selectValue,
|
|
20
17
|
selectProps = props.selectProps,
|
|
21
|
-
id = props.id
|
|
22
|
-
isAppleDevice = props.isAppleDevice;
|
|
18
|
+
id = props.id;
|
|
23
19
|
var ariaLiveMessages = selectProps.ariaLiveMessages,
|
|
24
20
|
getOptionLabel = selectProps.getOptionLabel,
|
|
25
21
|
inputValue = selectProps.inputValue,
|
|
26
|
-
isMulti = selectProps.isMulti,
|
|
27
22
|
isOptionDisabled = selectProps.isOptionDisabled,
|
|
28
|
-
isSearchable = selectProps.isSearchable,
|
|
29
|
-
label = selectProps.label,
|
|
30
23
|
menuIsOpen = selectProps.menuIsOpen,
|
|
31
24
|
options = selectProps.options,
|
|
32
25
|
screenReaderStatus = selectProps.screenReaderStatus,
|
|
33
|
-
tabSelectsValue = selectProps.tabSelectsValue,
|
|
34
26
|
isLoading = selectProps.isLoading;
|
|
35
|
-
var ariaLabel = selectProps['aria-label'] || label;
|
|
36
27
|
var ariaLive = selectProps['aria-live'];
|
|
37
28
|
|
|
38
|
-
// for safari, we will use minimum support from aria-live region
|
|
39
|
-
var isA11yImprovementEnabled = fg('design_system_select-a11y-improvement') && !isAppleDevice;
|
|
40
|
-
|
|
41
29
|
// Update aria live message configuration when prop changes
|
|
42
30
|
var messages = useMemo(function () {
|
|
43
31
|
return _objectSpread(_objectSpread({}, defaultAriaLiveMessages), ariaLiveMessages || {});
|
|
@@ -46,7 +34,7 @@ var LiveRegion = function LiveRegion(props) {
|
|
|
46
34
|
// Update aria live selected option when prop changes
|
|
47
35
|
var ariaSelected = useMemo(function () {
|
|
48
36
|
var message = '';
|
|
49
|
-
if (
|
|
37
|
+
if (menuIsOpen) {
|
|
50
38
|
// we don't need to have selected message when the menu is open
|
|
51
39
|
return '';
|
|
52
40
|
}
|
|
@@ -63,12 +51,12 @@ var LiveRegion = function LiveRegion(props) {
|
|
|
63
51
|
|
|
64
52
|
// If there is just one item from the action then get its label
|
|
65
53
|
var selected = removedValue || option || asOption(value);
|
|
66
|
-
var
|
|
54
|
+
var label = selected ? getOptionLabel(selected) : '';
|
|
67
55
|
|
|
68
56
|
// If there are multiple items from the action then return an array of labels
|
|
69
57
|
var multiSelected = selectedOptions || removedValues || undefined;
|
|
70
58
|
var labels = multiSelected ? multiSelected.map(getOptionLabel) : [];
|
|
71
|
-
if (
|
|
59
|
+
if (!label && !labels.length) {
|
|
72
60
|
// return empty string if no labels provided
|
|
73
61
|
return '';
|
|
74
62
|
}
|
|
@@ -76,39 +64,13 @@ var LiveRegion = function LiveRegion(props) {
|
|
|
76
64
|
// multiSelected items are usually items that have already been selected
|
|
77
65
|
// or set by the user as a default value so we assume they are not disabled
|
|
78
66
|
isDisabled: selected && isOptionDisabled(selected, selectValue),
|
|
79
|
-
label:
|
|
67
|
+
label: label,
|
|
80
68
|
labels: labels
|
|
81
69
|
}, ariaSelection);
|
|
82
70
|
message = messages.onChange(onChangeProps);
|
|
83
71
|
}
|
|
84
72
|
return message;
|
|
85
|
-
}, [ariaSelection, messages, isOptionDisabled, selectValue, getOptionLabel,
|
|
86
|
-
var prevInputValue = useRef('');
|
|
87
|
-
var ariaFocused = useMemo(function () {
|
|
88
|
-
var focusMsg = '';
|
|
89
|
-
var focused = focusedOption || focusedValue;
|
|
90
|
-
var isSelected = !!(focusedOption && selectValue && selectValue.includes(focusedOption));
|
|
91
|
-
if (inputValue === prevInputValue.current && isA11yImprovementEnabled) {
|
|
92
|
-
// only announce focus option when searching when ff is on and the input value changed
|
|
93
|
-
// for safari, we will announce for all
|
|
94
|
-
return '';
|
|
95
|
-
}
|
|
96
|
-
if (focused && messages.onFocus) {
|
|
97
|
-
var onFocusProps = {
|
|
98
|
-
focused: focused,
|
|
99
|
-
label: getOptionLabel(focused),
|
|
100
|
-
isDisabled: isOptionDisabled(focused, selectValue),
|
|
101
|
-
isSelected: isSelected,
|
|
102
|
-
options: focusableOptions,
|
|
103
|
-
context: focused === focusedOption ? 'menu' : 'value',
|
|
104
|
-
selectValue: selectValue,
|
|
105
|
-
isMulti: isMulti
|
|
106
|
-
};
|
|
107
|
-
focusMsg = messages.onFocus(onFocusProps);
|
|
108
|
-
}
|
|
109
|
-
prevInputValue.current = inputValue;
|
|
110
|
-
return focusMsg;
|
|
111
|
-
}, [inputValue, focusedOption, focusedValue, getOptionLabel, isOptionDisabled, messages, focusableOptions, selectValue, isA11yImprovementEnabled, isMulti]);
|
|
73
|
+
}, [ariaSelection, messages, isOptionDisabled, selectValue, getOptionLabel, menuIsOpen]);
|
|
112
74
|
var ariaResults = useMemo(function () {
|
|
113
75
|
var resultsMsg = '';
|
|
114
76
|
if (isLoading) {
|
|
@@ -129,43 +91,17 @@ var LiveRegion = function LiveRegion(props) {
|
|
|
129
91
|
return resultsMsg;
|
|
130
92
|
}, [focusableOptions, inputValue, menuIsOpen, messages, options, screenReaderStatus, isLoading]);
|
|
131
93
|
var isInitialFocus = (ariaSelection === null || ariaSelection === void 0 ? void 0 : ariaSelection.action) === 'initial-input-focus';
|
|
132
|
-
var ariaGuidance = useMemo(function () {
|
|
133
|
-
if (fg('design_system_select-a11y-improvement')) {
|
|
134
|
-
// don't announce guidance at all when ff is on
|
|
135
|
-
return '';
|
|
136
|
-
}
|
|
137
|
-
var guidanceMsg = '';
|
|
138
|
-
if (messages.guidance) {
|
|
139
|
-
var context = focusedValue ? 'value' : menuIsOpen ? 'menu' : 'input';
|
|
140
|
-
guidanceMsg = messages.guidance({
|
|
141
|
-
'aria-label': ariaLabel,
|
|
142
|
-
context: context,
|
|
143
|
-
isDisabled: focusedOption && isOptionDisabled(focusedOption, selectValue),
|
|
144
|
-
isMulti: isMulti,
|
|
145
|
-
isSearchable: isSearchable,
|
|
146
|
-
tabSelectsValue: tabSelectsValue,
|
|
147
|
-
isInitialFocus: isInitialFocus
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
return guidanceMsg;
|
|
151
|
-
}, [ariaLabel, focusedOption, focusedValue, isMulti, isOptionDisabled, isSearchable, menuIsOpen, messages, selectValue, tabSelectsValue, isInitialFocus]);
|
|
152
94
|
var ScreenReaderText = /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
153
95
|
id: "aria-selection"
|
|
154
96
|
}, ariaSelected), /*#__PURE__*/React.createElement("span", {
|
|
155
97
|
id: "aria-results"
|
|
156
|
-
}, ariaResults)
|
|
157
|
-
id: "aria-focused"
|
|
158
|
-
}, ariaFocused), /*#__PURE__*/React.createElement("span", {
|
|
159
|
-
id: "aria-guidance"
|
|
160
|
-
}, ariaGuidance)));
|
|
98
|
+
}, ariaResults));
|
|
161
99
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(A11yText, {
|
|
162
100
|
id: id
|
|
163
101
|
}, isInitialFocus && ScreenReaderText), /*#__PURE__*/React.createElement(A11yText, {
|
|
164
102
|
"aria-live": ariaLive // Should be undefined by default unless a specific use case requires it
|
|
165
103
|
,
|
|
166
|
-
"
|
|
167
|
-
"aria-relevant": fg('design_system_select-a11y-improvement') ? undefined : 'additions text',
|
|
168
|
-
role: fg('design_system_select-a11y-improvement') ? 'status' : 'log'
|
|
104
|
+
role: "status"
|
|
169
105
|
}, isFocused && !isInitialFocus && ScreenReaderText));
|
|
170
106
|
};
|
|
171
107
|
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
|
-
/* eslint-disable @atlaskit/platform/ensure-feature-flag-prefix */
|
|
5
4
|
/**
|
|
6
5
|
* @jsxRuntime classic
|
|
7
6
|
* @jsx jsx
|
|
8
7
|
* @jsxFrag React.Fragment
|
|
9
8
|
*/
|
|
10
|
-
import
|
|
9
|
+
import { Fragment, useMemo } from 'react';
|
|
11
10
|
|
|
12
11
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
|
|
13
12
|
import { jsx } from '@emotion/react';
|
|
14
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
13
|
import { defaultAriaLiveMessages } from '../../accessibility';
|
|
16
14
|
import A11yText from './internal/a11y-text';
|
|
17
15
|
|
|
@@ -21,32 +19,21 @@ import A11yText from './internal/a11y-text';
|
|
|
21
19
|
|
|
22
20
|
var LiveRegion = function LiveRegion(props) {
|
|
23
21
|
var ariaSelection = props.ariaSelection,
|
|
24
|
-
focusedOption = props.focusedOption,
|
|
25
|
-
focusedValue = props.focusedValue,
|
|
26
22
|
focusableOptions = props.focusableOptions,
|
|
27
23
|
isFocused = props.isFocused,
|
|
28
24
|
selectValue = props.selectValue,
|
|
29
25
|
selectProps = props.selectProps,
|
|
30
|
-
id = props.id
|
|
31
|
-
isAppleDevice = props.isAppleDevice;
|
|
26
|
+
id = props.id;
|
|
32
27
|
var ariaLiveMessages = selectProps.ariaLiveMessages,
|
|
33
28
|
getOptionLabel = selectProps.getOptionLabel,
|
|
34
29
|
inputValue = selectProps.inputValue,
|
|
35
|
-
isMulti = selectProps.isMulti,
|
|
36
30
|
isOptionDisabled = selectProps.isOptionDisabled,
|
|
37
|
-
isSearchable = selectProps.isSearchable,
|
|
38
|
-
label = selectProps.label,
|
|
39
31
|
menuIsOpen = selectProps.menuIsOpen,
|
|
40
32
|
options = selectProps.options,
|
|
41
33
|
screenReaderStatus = selectProps.screenReaderStatus,
|
|
42
|
-
tabSelectsValue = selectProps.tabSelectsValue,
|
|
43
34
|
isLoading = selectProps.isLoading;
|
|
44
|
-
var ariaLabel = selectProps['aria-label'] || label;
|
|
45
35
|
var ariaLive = selectProps['aria-live'];
|
|
46
36
|
|
|
47
|
-
// for safari, we will use minimum support from aria-live region
|
|
48
|
-
var isA11yImprovementEnabled = fg('design_system_select-a11y-improvement') && !isAppleDevice;
|
|
49
|
-
|
|
50
37
|
// Update aria live message configuration when prop changes
|
|
51
38
|
var messages = useMemo(function () {
|
|
52
39
|
return _objectSpread(_objectSpread({}, defaultAriaLiveMessages), ariaLiveMessages || {});
|
|
@@ -55,7 +42,7 @@ var LiveRegion = function LiveRegion(props) {
|
|
|
55
42
|
// Update aria live selected option when prop changes
|
|
56
43
|
var ariaSelected = useMemo(function () {
|
|
57
44
|
var message = '';
|
|
58
|
-
if (
|
|
45
|
+
if (menuIsOpen) {
|
|
59
46
|
// we don't need to have selected message when the menu is open
|
|
60
47
|
return '';
|
|
61
48
|
}
|
|
@@ -72,12 +59,12 @@ var LiveRegion = function LiveRegion(props) {
|
|
|
72
59
|
|
|
73
60
|
// If there is just one item from the action then get its label
|
|
74
61
|
var selected = removedValue || option || asOption(value);
|
|
75
|
-
var
|
|
62
|
+
var label = selected ? getOptionLabel(selected) : '';
|
|
76
63
|
|
|
77
64
|
// If there are multiple items from the action then return an array of labels
|
|
78
65
|
var multiSelected = selectedOptions || removedValues || undefined;
|
|
79
66
|
var labels = multiSelected ? multiSelected.map(getOptionLabel) : [];
|
|
80
|
-
if (
|
|
67
|
+
if (!label && !labels.length) {
|
|
81
68
|
// return empty string if no labels provided
|
|
82
69
|
return '';
|
|
83
70
|
}
|
|
@@ -85,39 +72,13 @@ var LiveRegion = function LiveRegion(props) {
|
|
|
85
72
|
// multiSelected items are usually items that have already been selected
|
|
86
73
|
// or set by the user as a default value so we assume they are not disabled
|
|
87
74
|
isDisabled: selected && isOptionDisabled(selected, selectValue),
|
|
88
|
-
label:
|
|
75
|
+
label: label,
|
|
89
76
|
labels: labels
|
|
90
77
|
}, ariaSelection);
|
|
91
78
|
message = messages.onChange(onChangeProps);
|
|
92
79
|
}
|
|
93
80
|
return message;
|
|
94
|
-
}, [ariaSelection, messages, isOptionDisabled, selectValue, getOptionLabel,
|
|
95
|
-
var prevInputValue = useRef('');
|
|
96
|
-
var ariaFocused = useMemo(function () {
|
|
97
|
-
var focusMsg = '';
|
|
98
|
-
var focused = focusedOption || focusedValue;
|
|
99
|
-
var isSelected = !!(focusedOption && selectValue && selectValue.includes(focusedOption));
|
|
100
|
-
if (inputValue === prevInputValue.current && isA11yImprovementEnabled) {
|
|
101
|
-
// only announce focus option when searching when ff is on and the input value changed
|
|
102
|
-
// for safari, we will announce for all
|
|
103
|
-
return '';
|
|
104
|
-
}
|
|
105
|
-
if (focused && messages.onFocus) {
|
|
106
|
-
var onFocusProps = {
|
|
107
|
-
focused: focused,
|
|
108
|
-
label: getOptionLabel(focused),
|
|
109
|
-
isDisabled: isOptionDisabled(focused, selectValue),
|
|
110
|
-
isSelected: isSelected,
|
|
111
|
-
options: focusableOptions,
|
|
112
|
-
context: focused === focusedOption ? 'menu' : 'value',
|
|
113
|
-
selectValue: selectValue,
|
|
114
|
-
isMulti: isMulti
|
|
115
|
-
};
|
|
116
|
-
focusMsg = messages.onFocus(onFocusProps);
|
|
117
|
-
}
|
|
118
|
-
prevInputValue.current = inputValue;
|
|
119
|
-
return focusMsg;
|
|
120
|
-
}, [inputValue, focusedOption, focusedValue, getOptionLabel, isOptionDisabled, messages, focusableOptions, selectValue, isA11yImprovementEnabled, isMulti]);
|
|
81
|
+
}, [ariaSelection, messages, isOptionDisabled, selectValue, getOptionLabel, menuIsOpen]);
|
|
121
82
|
var ariaResults = useMemo(function () {
|
|
122
83
|
var resultsMsg = '';
|
|
123
84
|
if (isLoading) {
|
|
@@ -138,43 +99,17 @@ var LiveRegion = function LiveRegion(props) {
|
|
|
138
99
|
return resultsMsg;
|
|
139
100
|
}, [focusableOptions, inputValue, menuIsOpen, messages, options, screenReaderStatus, isLoading]);
|
|
140
101
|
var isInitialFocus = (ariaSelection === null || ariaSelection === void 0 ? void 0 : ariaSelection.action) === 'initial-input-focus';
|
|
141
|
-
var ariaGuidance = useMemo(function () {
|
|
142
|
-
if (fg('design_system_select-a11y-improvement')) {
|
|
143
|
-
// don't announce guidance at all when ff is on
|
|
144
|
-
return '';
|
|
145
|
-
}
|
|
146
|
-
var guidanceMsg = '';
|
|
147
|
-
if (messages.guidance) {
|
|
148
|
-
var context = focusedValue ? 'value' : menuIsOpen ? 'menu' : 'input';
|
|
149
|
-
guidanceMsg = messages.guidance({
|
|
150
|
-
'aria-label': ariaLabel,
|
|
151
|
-
context: context,
|
|
152
|
-
isDisabled: focusedOption && isOptionDisabled(focusedOption, selectValue),
|
|
153
|
-
isMulti: isMulti,
|
|
154
|
-
isSearchable: isSearchable,
|
|
155
|
-
tabSelectsValue: tabSelectsValue,
|
|
156
|
-
isInitialFocus: isInitialFocus
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
return guidanceMsg;
|
|
160
|
-
}, [ariaLabel, focusedOption, focusedValue, isMulti, isOptionDisabled, isSearchable, menuIsOpen, messages, selectValue, tabSelectsValue, isInitialFocus]);
|
|
161
102
|
var ScreenReaderText = jsx(Fragment, null, jsx("span", {
|
|
162
103
|
id: "aria-selection"
|
|
163
104
|
}, ariaSelected), jsx("span", {
|
|
164
105
|
id: "aria-results"
|
|
165
|
-
}, ariaResults)
|
|
166
|
-
id: "aria-focused"
|
|
167
|
-
}, ariaFocused), jsx("span", {
|
|
168
|
-
id: "aria-guidance"
|
|
169
|
-
}, ariaGuidance)));
|
|
106
|
+
}, ariaResults));
|
|
170
107
|
return jsx(Fragment, null, jsx(A11yText, {
|
|
171
108
|
id: id
|
|
172
109
|
}, isInitialFocus && ScreenReaderText), jsx(A11yText, {
|
|
173
110
|
"aria-live": ariaLive // Should be undefined by default unless a specific use case requires it
|
|
174
111
|
,
|
|
175
|
-
"
|
|
176
|
-
"aria-relevant": fg('design_system_select-a11y-improvement') ? undefined : 'additions text',
|
|
177
|
-
role: fg('design_system_select-a11y-improvement') ? 'status' : 'log'
|
|
112
|
+
role: "status"
|
|
178
113
|
}, isFocused && !isInitialFocus && ScreenReaderText));
|
|
179
114
|
};
|
|
180
115
|
|