@atlaskit/react-select 2.6.6 → 2.7.1

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/accessibility/index.js +3 -49
  3. package/dist/cjs/compiled/components/indicators.js +6 -4
  4. package/dist/cjs/compiled/components/live-region.js +8 -72
  5. package/dist/cjs/compiled/components/multi-value.js +4 -3
  6. package/dist/cjs/emotion/components/indicators.js +6 -4
  7. package/dist/cjs/emotion/components/live-region.js +10 -76
  8. package/dist/cjs/emotion/components/multi-value.js +4 -3
  9. package/dist/cjs/select.js +141 -99
  10. package/dist/es2019/accessibility/index.js +3 -50
  11. package/dist/es2019/compiled/components/indicators.js +6 -4
  12. package/dist/es2019/compiled/components/live-region.js +7 -71
  13. package/dist/es2019/compiled/components/multi-value.js +3 -2
  14. package/dist/es2019/emotion/components/indicators.js +6 -4
  15. package/dist/es2019/emotion/components/live-region.js +7 -72
  16. package/dist/es2019/emotion/components/multi-value.js +3 -2
  17. package/dist/es2019/select.js +117 -82
  18. package/dist/esm/accessibility/index.js +3 -49
  19. package/dist/esm/compiled/components/indicators.js +6 -4
  20. package/dist/esm/compiled/components/live-region.js +9 -73
  21. package/dist/esm/compiled/components/multi-value.js +3 -2
  22. package/dist/esm/emotion/components/indicators.js +6 -4
  23. package/dist/esm/emotion/components/live-region.js +9 -74
  24. package/dist/esm/emotion/components/multi-value.js +3 -2
  25. package/dist/esm/select.js +139 -98
  26. package/dist/types/accessibility/index.d.ts +0 -2
  27. package/dist/types/compiled/components/live-region.d.ts +0 -2
  28. package/dist/types/emotion/components/live-region.d.ts +0 -2
  29. package/dist/types/select.d.ts +5 -6
  30. package/dist/types-ts4.5/accessibility/index.d.ts +0 -2
  31. package/dist/types-ts4.5/compiled/components/live-region.d.ts +0 -2
  32. package/dist/types-ts4.5/emotion/components/live-region.d.ts +0 -2
  33. package/dist/types-ts4.5/select.d.ts +5 -6
  34. package/package.json +2 -5
@@ -1,5 +1,4 @@
1
- import React, { Fragment, useMemo, useRef } from 'react';
2
- import { fg } from '@atlaskit/platform-feature-flags';
1
+ import React, { Fragment, useMemo } from 'react';
3
2
  import { defaultAriaLiveMessages } from '../../accessibility';
4
3
  import A11yText from './internal/a11y-text';
5
4
 
@@ -10,35 +9,24 @@ import A11yText from './internal/a11y-text';
10
9
  const LiveRegion = props => {
11
10
  const {
12
11
  ariaSelection,
13
- focusedOption,
14
- focusedValue,
15
12
  focusableOptions,
16
13
  isFocused,
17
14
  selectValue,
18
15
  selectProps,
19
- id,
20
- isAppleDevice
16
+ id
21
17
  } = props;
22
18
  const {
23
19
  ariaLiveMessages,
24
20
  getOptionLabel,
25
21
  inputValue,
26
- isMulti,
27
22
  isOptionDisabled,
28
- isSearchable,
29
- label,
30
23
  menuIsOpen,
31
24
  options,
32
25
  screenReaderStatus,
33
- tabSelectsValue,
34
26
  isLoading
35
27
  } = selectProps;
36
- const ariaLabel = selectProps['aria-label'] || label;
37
28
  const ariaLive = selectProps['aria-live'];
38
29
 
39
- // for safari, we will use minimum support from aria-live region
40
- const isA11yImprovementEnabled = fg('design_system_select-a11y-improvement') && !isAppleDevice;
41
-
42
30
  // Update aria live message configuration when prop changes
43
31
  const messages = useMemo(() => ({
44
32
  ...defaultAriaLiveMessages,
@@ -48,7 +36,7 @@ const LiveRegion = props => {
48
36
  // Update aria live selected option when prop changes
49
37
  const ariaSelected = useMemo(() => {
50
38
  let message = '';
51
- if (isA11yImprovementEnabled && menuIsOpen) {
39
+ if (menuIsOpen) {
52
40
  // we don't need to have selected message when the menu is open
53
41
  return '';
54
42
  }
@@ -70,7 +58,7 @@ const LiveRegion = props => {
70
58
  // If there are multiple items from the action then return an array of labels
71
59
  const multiSelected = selectedOptions || removedValues || undefined;
72
60
  const labels = multiSelected ? multiSelected.map(getOptionLabel) : [];
73
- if (isA11yImprovementEnabled && !label && !labels.length) {
61
+ if (!label && !labels.length) {
74
62
  // return empty string if no labels provided
75
63
  return '';
76
64
  }
@@ -85,33 +73,7 @@ const LiveRegion = props => {
85
73
  message = messages.onChange(onChangeProps);
86
74
  }
87
75
  return message;
88
- }, [ariaSelection, messages, isOptionDisabled, selectValue, getOptionLabel, isA11yImprovementEnabled, menuIsOpen]);
89
- const prevInputValue = useRef('');
90
- const ariaFocused = useMemo(() => {
91
- let focusMsg = '';
92
- const focused = focusedOption || focusedValue;
93
- const isSelected = !!(focusedOption && selectValue && selectValue.includes(focusedOption));
94
- if (inputValue === prevInputValue.current && isA11yImprovementEnabled) {
95
- // only announce focus option when searching when ff is on and the input value changed
96
- // for safari, we will announce for all
97
- return '';
98
- }
99
- if (focused && messages.onFocus) {
100
- const onFocusProps = {
101
- focused,
102
- label: getOptionLabel(focused),
103
- isDisabled: isOptionDisabled(focused, selectValue),
104
- isSelected,
105
- options: focusableOptions,
106
- context: focused === focusedOption ? 'menu' : 'value',
107
- selectValue,
108
- isMulti
109
- };
110
- focusMsg = messages.onFocus(onFocusProps);
111
- }
112
- prevInputValue.current = inputValue;
113
- return focusMsg;
114
- }, [inputValue, focusedOption, focusedValue, getOptionLabel, isOptionDisabled, messages, focusableOptions, selectValue, isA11yImprovementEnabled, isMulti]);
76
+ }, [ariaSelection, messages, isOptionDisabled, selectValue, getOptionLabel, menuIsOpen]);
115
77
  const ariaResults = useMemo(() => {
116
78
  let resultsMsg = '';
117
79
  if (isLoading) {
@@ -132,43 +94,17 @@ const LiveRegion = props => {
132
94
  return resultsMsg;
133
95
  }, [focusableOptions, inputValue, menuIsOpen, messages, options, screenReaderStatus, isLoading]);
134
96
  const isInitialFocus = (ariaSelection === null || ariaSelection === void 0 ? void 0 : ariaSelection.action) === 'initial-input-focus';
135
- const ariaGuidance = useMemo(() => {
136
- if (fg('design_system_select-a11y-improvement')) {
137
- // don't announce guidance at all when ff is on
138
- return '';
139
- }
140
- let guidanceMsg = '';
141
- if (messages.guidance) {
142
- const context = focusedValue ? 'value' : menuIsOpen ? 'menu' : 'input';
143
- guidanceMsg = messages.guidance({
144
- 'aria-label': ariaLabel,
145
- context,
146
- isDisabled: focusedOption && isOptionDisabled(focusedOption, selectValue),
147
- isMulti,
148
- isSearchable,
149
- tabSelectsValue,
150
- isInitialFocus
151
- });
152
- }
153
- return guidanceMsg;
154
- }, [ariaLabel, focusedOption, focusedValue, isMulti, isOptionDisabled, isSearchable, menuIsOpen, messages, selectValue, tabSelectsValue, isInitialFocus]);
155
97
  const ScreenReaderText = /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("span", {
156
98
  id: "aria-selection"
157
99
  }, ariaSelected), /*#__PURE__*/React.createElement("span", {
158
100
  id: "aria-results"
159
- }, ariaResults), !fg('design_system_select-a11y-improvement') && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
160
- id: "aria-focused"
161
- }, ariaFocused), /*#__PURE__*/React.createElement("span", {
162
- id: "aria-guidance"
163
- }, ariaGuidance)));
101
+ }, ariaResults));
164
102
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(A11yText, {
165
103
  id: id
166
104
  }, isInitialFocus && ScreenReaderText), /*#__PURE__*/React.createElement(A11yText, {
167
105
  "aria-live": ariaLive // Should be undefined by default unless a specific use case requires it
168
106
  ,
169
- "aria-atomic": fg('design_system_select-a11y-improvement') ? undefined : 'false',
170
- "aria-relevant": fg('design_system_select-a11y-improvement') ? undefined : 'additions text',
171
- role: fg('design_system_select-a11y-improvement') ? 'status' : 'log'
107
+ role: "status"
172
108
  }, isFocused && !isInitialFocus && ScreenReaderText));
173
109
  };
174
110
 
@@ -4,8 +4,8 @@ import "./multi-value.compiled.css";
4
4
  import * as React from 'react';
5
5
  import { ax, ix } from "@compiled/react/runtime";
6
6
  import { cx } from '@compiled/react';
7
+ import CrossIcon from '@atlaskit/icon/core/close';
7
8
  import LegacySelectClearIcon from '@atlaskit/icon/glyph/select-clear';
8
- import CrossIcon from '@atlaskit/icon/utility/cross';
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
10
  import { getStyleProps } from '../../utils';
11
11
  const multiValueStyles = {
@@ -78,7 +78,8 @@ export function MultiValueRemove({
78
78
  LEGACY_fallbackIcon: LegacySelectClearIcon,
79
79
  LEGACY_primaryColor: "transparent",
80
80
  LEGACY_secondaryColor: "inherit",
81
- LEGACY_size: "small"
81
+ LEGACY_size: "small",
82
+ size: "small"
82
83
  })));
83
84
  }
84
85
  const MultiValue = props => {
@@ -6,8 +6,8 @@ import _extends from "@babel/runtime/helpers/extends";
6
6
 
7
7
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
8
8
  import { jsx } from '@emotion/react';
9
- import DownIcon from '@atlaskit/icon/utility/migration/chevron-down';
10
- import CrossIcon from '@atlaskit/icon/utility/migration/cross-circle--select-clear';
9
+ import DownIcon from '@atlaskit/icon/core/migration/chevron-down';
10
+ import CrossIcon from '@atlaskit/icon/core/migration/cross-circle--select-clear';
11
11
  import { Inline, Pressable, xcss } from '@atlaskit/primitives';
12
12
  import Spinner from '@atlaskit/spinner';
13
13
  import { getStyleProps } from '../../utils';
@@ -61,7 +61,8 @@ export const DropdownIndicator = props => {
61
61
  }, jsx(DownIcon, {
62
62
  color: "currentColor",
63
63
  label: "open",
64
- LEGACY_margin: "var(--ds-space-negative-075, -0.375rem)"
64
+ LEGACY_margin: "var(--ds-space-negative-075, -0.375rem)",
65
+ size: "small"
65
66
  })));
66
67
  };
67
68
  export const clearIndicatorCSS = ({
@@ -94,7 +95,8 @@ export const ClearIndicator = props => {
94
95
  label: "",
95
96
  color: "currentColor",
96
97
  LEGACY_size: "small",
97
- LEGACY_margin: "var(--ds-space-negative-025, -0.125rem)"
98
+ LEGACY_margin: "var(--ds-space-negative-025, -0.125rem)",
99
+ size: "small"
98
100
  })));
99
101
  };
100
102
 
@@ -1,14 +1,12 @@
1
- /* eslint-disable @atlaskit/platform/ensure-feature-flag-prefix */
2
1
  /**
3
2
  * @jsxRuntime classic
4
3
  * @jsx jsx
5
4
  * @jsxFrag React.Fragment
6
5
  */
7
- import React, { Fragment, useMemo, useRef } from 'react';
6
+ import { Fragment, useMemo } from 'react';
8
7
 
9
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
10
9
  import { jsx } from '@emotion/react';
11
- import { fg } from '@atlaskit/platform-feature-flags';
12
10
  import { defaultAriaLiveMessages } from '../../accessibility';
13
11
  import A11yText from './internal/a11y-text';
14
12
 
@@ -19,35 +17,24 @@ import A11yText from './internal/a11y-text';
19
17
  const LiveRegion = props => {
20
18
  const {
21
19
  ariaSelection,
22
- focusedOption,
23
- focusedValue,
24
20
  focusableOptions,
25
21
  isFocused,
26
22
  selectValue,
27
23
  selectProps,
28
- id,
29
- isAppleDevice
24
+ id
30
25
  } = props;
31
26
  const {
32
27
  ariaLiveMessages,
33
28
  getOptionLabel,
34
29
  inputValue,
35
- isMulti,
36
30
  isOptionDisabled,
37
- isSearchable,
38
- label,
39
31
  menuIsOpen,
40
32
  options,
41
33
  screenReaderStatus,
42
- tabSelectsValue,
43
34
  isLoading
44
35
  } = selectProps;
45
- const ariaLabel = selectProps['aria-label'] || label;
46
36
  const ariaLive = selectProps['aria-live'];
47
37
 
48
- // for safari, we will use minimum support from aria-live region
49
- const isA11yImprovementEnabled = fg('design_system_select-a11y-improvement') && !isAppleDevice;
50
-
51
38
  // Update aria live message configuration when prop changes
52
39
  const messages = useMemo(() => ({
53
40
  ...defaultAriaLiveMessages,
@@ -57,7 +44,7 @@ const LiveRegion = props => {
57
44
  // Update aria live selected option when prop changes
58
45
  const ariaSelected = useMemo(() => {
59
46
  let message = '';
60
- if (isA11yImprovementEnabled && menuIsOpen) {
47
+ if (menuIsOpen) {
61
48
  // we don't need to have selected message when the menu is open
62
49
  return '';
63
50
  }
@@ -79,7 +66,7 @@ const LiveRegion = props => {
79
66
  // If there are multiple items from the action then return an array of labels
80
67
  const multiSelected = selectedOptions || removedValues || undefined;
81
68
  const labels = multiSelected ? multiSelected.map(getOptionLabel) : [];
82
- if (isA11yImprovementEnabled && !label && !labels.length) {
69
+ if (!label && !labels.length) {
83
70
  // return empty string if no labels provided
84
71
  return '';
85
72
  }
@@ -94,33 +81,7 @@ const LiveRegion = props => {
94
81
  message = messages.onChange(onChangeProps);
95
82
  }
96
83
  return message;
97
- }, [ariaSelection, messages, isOptionDisabled, selectValue, getOptionLabel, isA11yImprovementEnabled, menuIsOpen]);
98
- const prevInputValue = useRef('');
99
- const ariaFocused = useMemo(() => {
100
- let focusMsg = '';
101
- const focused = focusedOption || focusedValue;
102
- const isSelected = !!(focusedOption && selectValue && selectValue.includes(focusedOption));
103
- if (inputValue === prevInputValue.current && isA11yImprovementEnabled) {
104
- // only announce focus option when searching when ff is on and the input value changed
105
- // for safari, we will announce for all
106
- return '';
107
- }
108
- if (focused && messages.onFocus) {
109
- const onFocusProps = {
110
- focused,
111
- label: getOptionLabel(focused),
112
- isDisabled: isOptionDisabled(focused, selectValue),
113
- isSelected,
114
- options: focusableOptions,
115
- context: focused === focusedOption ? 'menu' : 'value',
116
- selectValue,
117
- isMulti
118
- };
119
- focusMsg = messages.onFocus(onFocusProps);
120
- }
121
- prevInputValue.current = inputValue;
122
- return focusMsg;
123
- }, [inputValue, focusedOption, focusedValue, getOptionLabel, isOptionDisabled, messages, focusableOptions, selectValue, isA11yImprovementEnabled, isMulti]);
84
+ }, [ariaSelection, messages, isOptionDisabled, selectValue, getOptionLabel, menuIsOpen]);
124
85
  const ariaResults = useMemo(() => {
125
86
  let resultsMsg = '';
126
87
  if (isLoading) {
@@ -141,43 +102,17 @@ const LiveRegion = props => {
141
102
  return resultsMsg;
142
103
  }, [focusableOptions, inputValue, menuIsOpen, messages, options, screenReaderStatus, isLoading]);
143
104
  const isInitialFocus = (ariaSelection === null || ariaSelection === void 0 ? void 0 : ariaSelection.action) === 'initial-input-focus';
144
- const ariaGuidance = useMemo(() => {
145
- if (fg('design_system_select-a11y-improvement')) {
146
- // don't announce guidance at all when ff is on
147
- return '';
148
- }
149
- let guidanceMsg = '';
150
- if (messages.guidance) {
151
- const context = focusedValue ? 'value' : menuIsOpen ? 'menu' : 'input';
152
- guidanceMsg = messages.guidance({
153
- 'aria-label': ariaLabel,
154
- context,
155
- isDisabled: focusedOption && isOptionDisabled(focusedOption, selectValue),
156
- isMulti,
157
- isSearchable,
158
- tabSelectsValue,
159
- isInitialFocus
160
- });
161
- }
162
- return guidanceMsg;
163
- }, [ariaLabel, focusedOption, focusedValue, isMulti, isOptionDisabled, isSearchable, menuIsOpen, messages, selectValue, tabSelectsValue, isInitialFocus]);
164
105
  const ScreenReaderText = jsx(Fragment, null, jsx("span", {
165
106
  id: "aria-selection"
166
107
  }, ariaSelected), jsx("span", {
167
108
  id: "aria-results"
168
- }, ariaResults), !fg('design_system_select-a11y-improvement') && jsx(React.Fragment, null, jsx("span", {
169
- id: "aria-focused"
170
- }, ariaFocused), jsx("span", {
171
- id: "aria-guidance"
172
- }, ariaGuidance)));
109
+ }, ariaResults));
173
110
  return jsx(Fragment, null, jsx(A11yText, {
174
111
  id: id
175
112
  }, isInitialFocus && ScreenReaderText), jsx(A11yText, {
176
113
  "aria-live": ariaLive // Should be undefined by default unless a specific use case requires it
177
114
  ,
178
- "aria-atomic": fg('design_system_select-a11y-improvement') ? undefined : 'false',
179
- "aria-relevant": fg('design_system_select-a11y-improvement') ? undefined : 'additions text',
180
- role: fg('design_system_select-a11y-improvement') ? 'status' : 'log'
115
+ role: "status"
181
116
  }, isFocused && !isInitialFocus && ScreenReaderText));
182
117
  };
183
118
 
@@ -5,8 +5,8 @@
5
5
 
6
6
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
7
7
  import { css, jsx } from '@emotion/react';
8
+ import CrossIcon from '@atlaskit/icon/core/close';
8
9
  import LegacySelectClearIcon from '@atlaskit/icon/glyph/select-clear';
9
- import CrossIcon from '@atlaskit/icon/utility/cross';
10
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
11
  import { getStyleProps } from '../../utils';
12
12
  export const multiValueCSS = ({
@@ -144,7 +144,8 @@ export function MultiValueRemove({
144
144
  LEGACY_fallbackIcon: LegacySelectClearIcon,
145
145
  LEGACY_primaryColor: "transparent",
146
146
  LEGACY_secondaryColor: "inherit",
147
- LEGACY_size: "small"
147
+ LEGACY_size: "small",
148
+ size: "small"
148
149
  })))
149
150
  );
150
151
  }