@atlaskit/react-select 1.3.0 → 1.3.2

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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/react-select
2
2
 
3
+ ## 1.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#163217](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/163217)
8
+ [`560d23ab4dfbe`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/560d23ab4dfbe) -
9
+ Add null check on safari for SSR
10
+
11
+ ## 1.3.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [#162105](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/162105)
16
+ [`4edf9a851c491`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4edf9a851c491) -
17
+ Improve the aria live for searching and reduce the live message when menu is open
18
+
3
19
  ## 1.3.0
4
20
 
5
21
  ### Minor Changes
@@ -19,8 +19,12 @@ function isIPhone() {
19
19
  return testPlatform(/^iPhone/i);
20
20
  }
21
21
  function isSafari() {
22
- var ua = navigator.userAgent.toLowerCase();
23
- return ua.includes('safari') && !ua.includes('chrome');
22
+ if (typeof window !== 'undefined' && window.navigator != null) {
23
+ var _window$navigator$use2;
24
+ var ua = (_window$navigator$use2 = window.navigator.userAgent) === null || _window$navigator$use2 === void 0 ? void 0 : _window$navigator$use2.toLowerCase();
25
+ return ua ? ua.includes('safari') && !ua.includes('chrome') : false;
26
+ }
27
+ return false;
24
28
  }
25
29
  function isMac() {
26
30
  return testPlatform(/^Mac/i);
@@ -53,15 +53,14 @@ var defaultAriaLiveMessages = exports.defaultAriaLiveMessages = {
53
53
  selectValue = props.selectValue,
54
54
  isMulti = props.isMulti,
55
55
  isDisabled = props.isDisabled,
56
- isSelected = props.isSelected,
57
- isAppleDevice = props.isAppleDevice;
56
+ isSelected = props.isSelected;
58
57
  var getArrayIndex = function getArrayIndex(arr, item) {
59
58
  return arr && arr.length ? "(".concat(arr.indexOf(item) + 1, " of ").concat(arr.length, ")") : '';
60
59
  };
61
60
  if (context === 'value' && selectValue) {
62
61
  return "value ".concat(label, " focused, ").concat(getArrayIndex(selectValue, focused), ".");
63
62
  }
64
- if (context === 'menu' && isAppleDevice) {
63
+ if (context === 'menu') {
65
64
  var disabled = isDisabled ? ' disabled' : '';
66
65
  // don't announce not selected for single selection
67
66
  var notSelectedStatus = !isMulti && (0, _platformFeatureFlags.fg)('design_system_select-a11y-improvement') ? '' : ' not selected';
@@ -57,6 +57,10 @@ var LiveRegion = function LiveRegion(props) {
57
57
  // Update aria live selected option when prop changes
58
58
  var ariaSelected = (0, _react.useMemo)(function () {
59
59
  var message = '';
60
+ if (isA11yImprovementEnabled && menuIsOpen) {
61
+ // we don't need to have selected message when the menu is open
62
+ return '';
63
+ }
60
64
  if (ariaSelection && messages.onChange) {
61
65
  var option = ariaSelection.option,
62
66
  selectedOptions = ariaSelection.options,
@@ -75,6 +79,10 @@ var LiveRegion = function LiveRegion(props) {
75
79
  // If there are multiple items from the action then return an array of labels
76
80
  var multiSelected = selectedOptions || removedValues || undefined;
77
81
  var labels = multiSelected ? multiSelected.map(getOptionLabel) : [];
82
+ if (isA11yImprovementEnabled && !_label && !labels.length) {
83
+ // return empty string if no labels provided
84
+ return '';
85
+ }
78
86
  var onChangeProps = _objectSpread({
79
87
  // multiSelected items are usually items that have already been selected
80
88
  // or set by the user as a default value so we assume they are not disabled
@@ -85,18 +93,17 @@ var LiveRegion = function LiveRegion(props) {
85
93
  message = messages.onChange(onChangeProps);
86
94
  }
87
95
  return message;
88
- }, [ariaSelection, messages, isOptionDisabled, selectValue, getOptionLabel]);
96
+ }, [ariaSelection, messages, isOptionDisabled, selectValue, getOptionLabel, isA11yImprovementEnabled, menuIsOpen]);
89
97
  var prevInputValue = (0, _react.useRef)('');
90
98
  var ariaFocused = (0, _react.useMemo)(function () {
91
99
  var focusMsg = '';
92
100
  var focused = focusedOption || focusedValue;
93
101
  var isSelected = !!(focusedOption && selectValue && selectValue.includes(focusedOption));
94
- if ((!inputValue || inputValue === prevInputValue.current) && isA11yImprovementEnabled) {
95
- // only announce focus option when searching when ff is on,
102
+ if (inputValue === prevInputValue.current && isA11yImprovementEnabled) {
103
+ // only announce focus option when searching when ff is on and the input value changed
96
104
  // for safari, we will announce for all
97
105
  return '';
98
106
  }
99
- prevInputValue.current = inputValue;
100
107
  if (focused && messages.onFocus) {
101
108
  var onFocusProps = {
102
109
  focused: focused,
@@ -106,13 +113,13 @@ var LiveRegion = function LiveRegion(props) {
106
113
  options: focusableOptions,
107
114
  context: focused === focusedOption ? 'menu' : 'value',
108
115
  selectValue: selectValue,
109
- isAppleDevice: isAppleDevice,
110
116
  isMulti: isMulti
111
117
  };
112
118
  focusMsg = messages.onFocus(onFocusProps);
113
119
  }
120
+ prevInputValue.current = inputValue;
114
121
  return focusMsg;
115
- }, [inputValue, focusedOption, focusedValue, getOptionLabel, isOptionDisabled, messages, focusableOptions, selectValue, isAppleDevice, isA11yImprovementEnabled, isMulti]);
122
+ }, [inputValue, focusedOption, focusedValue, getOptionLabel, isOptionDisabled, messages, focusableOptions, selectValue, isA11yImprovementEnabled, isMulti]);
116
123
  var ariaResults = (0, _react.useMemo)(function () {
117
124
  var resultsMsg = '';
118
125
  if (menuIsOpen && options.length && !isLoading && messages.onFilter) {
@@ -8,8 +8,12 @@ export function isIPhone() {
8
8
  return testPlatform(/^iPhone/i);
9
9
  }
10
10
  export function isSafari() {
11
- const ua = navigator.userAgent.toLowerCase();
12
- return ua.includes('safari') && !ua.includes('chrome');
11
+ if (typeof window !== 'undefined' && window.navigator != null) {
12
+ var _window$navigator$use2;
13
+ const ua = (_window$navigator$use2 = window.navigator.userAgent) === null || _window$navigator$use2 === void 0 ? void 0 : _window$navigator$use2.toLowerCase();
14
+ return ua ? ua.includes('safari') && !ua.includes('chrome') : false;
15
+ }
16
+ return false;
13
17
  }
14
18
  export function isMac() {
15
19
  return testPlatform(/^Mac/i);
@@ -50,14 +50,13 @@ export const defaultAriaLiveMessages = {
50
50
  selectValue,
51
51
  isMulti,
52
52
  isDisabled,
53
- isSelected,
54
- isAppleDevice
53
+ isSelected
55
54
  } = props;
56
55
  const getArrayIndex = (arr, item) => arr && arr.length ? `(${arr.indexOf(item) + 1} of ${arr.length})` : '';
57
56
  if (context === 'value' && selectValue) {
58
57
  return `value ${label} focused, ${getArrayIndex(selectValue, focused)}.`;
59
58
  }
60
- if (context === 'menu' && isAppleDevice) {
59
+ if (context === 'menu') {
61
60
  const disabled = isDisabled ? ' disabled' : '';
62
61
  // don't announce not selected for single selection
63
62
  const notSelectedStatus = !isMulti && fg('design_system_select-a11y-improvement') ? '' : ' not selected';
@@ -54,6 +54,10 @@ const LiveRegion = props => {
54
54
  // Update aria live selected option when prop changes
55
55
  const ariaSelected = useMemo(() => {
56
56
  let message = '';
57
+ if (isA11yImprovementEnabled && menuIsOpen) {
58
+ // we don't need to have selected message when the menu is open
59
+ return '';
60
+ }
57
61
  if (ariaSelection && messages.onChange) {
58
62
  const {
59
63
  option,
@@ -72,6 +76,10 @@ const LiveRegion = props => {
72
76
  // If there are multiple items from the action then return an array of labels
73
77
  const multiSelected = selectedOptions || removedValues || undefined;
74
78
  const labels = multiSelected ? multiSelected.map(getOptionLabel) : [];
79
+ if (isA11yImprovementEnabled && !label && !labels.length) {
80
+ // return empty string if no labels provided
81
+ return '';
82
+ }
75
83
  const onChangeProps = {
76
84
  // multiSelected items are usually items that have already been selected
77
85
  // or set by the user as a default value so we assume they are not disabled
@@ -83,18 +91,17 @@ const LiveRegion = props => {
83
91
  message = messages.onChange(onChangeProps);
84
92
  }
85
93
  return message;
86
- }, [ariaSelection, messages, isOptionDisabled, selectValue, getOptionLabel]);
94
+ }, [ariaSelection, messages, isOptionDisabled, selectValue, getOptionLabel, isA11yImprovementEnabled, menuIsOpen]);
87
95
  const prevInputValue = useRef('');
88
96
  const ariaFocused = useMemo(() => {
89
97
  let focusMsg = '';
90
98
  const focused = focusedOption || focusedValue;
91
99
  const isSelected = !!(focusedOption && selectValue && selectValue.includes(focusedOption));
92
- if ((!inputValue || inputValue === prevInputValue.current) && isA11yImprovementEnabled) {
93
- // only announce focus option when searching when ff is on,
100
+ if (inputValue === prevInputValue.current && isA11yImprovementEnabled) {
101
+ // only announce focus option when searching when ff is on and the input value changed
94
102
  // for safari, we will announce for all
95
103
  return '';
96
104
  }
97
- prevInputValue.current = inputValue;
98
105
  if (focused && messages.onFocus) {
99
106
  const onFocusProps = {
100
107
  focused,
@@ -104,13 +111,13 @@ const LiveRegion = props => {
104
111
  options: focusableOptions,
105
112
  context: focused === focusedOption ? 'menu' : 'value',
106
113
  selectValue,
107
- isAppleDevice,
108
114
  isMulti
109
115
  };
110
116
  focusMsg = messages.onFocus(onFocusProps);
111
117
  }
118
+ prevInputValue.current = inputValue;
112
119
  return focusMsg;
113
- }, [inputValue, focusedOption, focusedValue, getOptionLabel, isOptionDisabled, messages, focusableOptions, selectValue, isAppleDevice, isA11yImprovementEnabled, isMulti]);
120
+ }, [inputValue, focusedOption, focusedValue, getOptionLabel, isOptionDisabled, messages, focusableOptions, selectValue, isA11yImprovementEnabled, isMulti]);
114
121
  const ariaResults = useMemo(() => {
115
122
  let resultsMsg = '';
116
123
  if (menuIsOpen && options.length && !isLoading && messages.onFilter) {
@@ -8,8 +8,12 @@ export function isIPhone() {
8
8
  return testPlatform(/^iPhone/i);
9
9
  }
10
10
  export function isSafari() {
11
- var ua = navigator.userAgent.toLowerCase();
12
- return ua.includes('safari') && !ua.includes('chrome');
11
+ if (typeof window !== 'undefined' && window.navigator != null) {
12
+ var _window$navigator$use2;
13
+ var ua = (_window$navigator$use2 = window.navigator.userAgent) === null || _window$navigator$use2 === void 0 ? void 0 : _window$navigator$use2.toLowerCase();
14
+ return ua ? ua.includes('safari') && !ua.includes('chrome') : false;
15
+ }
16
+ return false;
13
17
  }
14
18
  export function isMac() {
15
19
  return testPlatform(/^Mac/i);
@@ -47,15 +47,14 @@ export var defaultAriaLiveMessages = {
47
47
  selectValue = props.selectValue,
48
48
  isMulti = props.isMulti,
49
49
  isDisabled = props.isDisabled,
50
- isSelected = props.isSelected,
51
- isAppleDevice = props.isAppleDevice;
50
+ isSelected = props.isSelected;
52
51
  var getArrayIndex = function getArrayIndex(arr, item) {
53
52
  return arr && arr.length ? "(".concat(arr.indexOf(item) + 1, " of ").concat(arr.length, ")") : '';
54
53
  };
55
54
  if (context === 'value' && selectValue) {
56
55
  return "value ".concat(label, " focused, ").concat(getArrayIndex(selectValue, focused), ".");
57
56
  }
58
- if (context === 'menu' && isAppleDevice) {
57
+ if (context === 'menu') {
59
58
  var disabled = isDisabled ? ' disabled' : '';
60
59
  // don't announce not selected for single selection
61
60
  var notSelectedStatus = !isMulti && fg('design_system_select-a11y-improvement') ? '' : ' not selected';
@@ -52,6 +52,10 @@ var LiveRegion = function LiveRegion(props) {
52
52
  // Update aria live selected option when prop changes
53
53
  var ariaSelected = useMemo(function () {
54
54
  var message = '';
55
+ if (isA11yImprovementEnabled && menuIsOpen) {
56
+ // we don't need to have selected message when the menu is open
57
+ return '';
58
+ }
55
59
  if (ariaSelection && messages.onChange) {
56
60
  var option = ariaSelection.option,
57
61
  selectedOptions = ariaSelection.options,
@@ -70,6 +74,10 @@ var LiveRegion = function LiveRegion(props) {
70
74
  // If there are multiple items from the action then return an array of labels
71
75
  var multiSelected = selectedOptions || removedValues || undefined;
72
76
  var labels = multiSelected ? multiSelected.map(getOptionLabel) : [];
77
+ if (isA11yImprovementEnabled && !_label && !labels.length) {
78
+ // return empty string if no labels provided
79
+ return '';
80
+ }
73
81
  var onChangeProps = _objectSpread({
74
82
  // multiSelected items are usually items that have already been selected
75
83
  // or set by the user as a default value so we assume they are not disabled
@@ -80,18 +88,17 @@ var LiveRegion = function LiveRegion(props) {
80
88
  message = messages.onChange(onChangeProps);
81
89
  }
82
90
  return message;
83
- }, [ariaSelection, messages, isOptionDisabled, selectValue, getOptionLabel]);
91
+ }, [ariaSelection, messages, isOptionDisabled, selectValue, getOptionLabel, isA11yImprovementEnabled, menuIsOpen]);
84
92
  var prevInputValue = useRef('');
85
93
  var ariaFocused = useMemo(function () {
86
94
  var focusMsg = '';
87
95
  var focused = focusedOption || focusedValue;
88
96
  var isSelected = !!(focusedOption && selectValue && selectValue.includes(focusedOption));
89
- if ((!inputValue || inputValue === prevInputValue.current) && isA11yImprovementEnabled) {
90
- // only announce focus option when searching when ff is on,
97
+ if (inputValue === prevInputValue.current && isA11yImprovementEnabled) {
98
+ // only announce focus option when searching when ff is on and the input value changed
91
99
  // for safari, we will announce for all
92
100
  return '';
93
101
  }
94
- prevInputValue.current = inputValue;
95
102
  if (focused && messages.onFocus) {
96
103
  var onFocusProps = {
97
104
  focused: focused,
@@ -101,13 +108,13 @@ var LiveRegion = function LiveRegion(props) {
101
108
  options: focusableOptions,
102
109
  context: focused === focusedOption ? 'menu' : 'value',
103
110
  selectValue: selectValue,
104
- isAppleDevice: isAppleDevice,
105
111
  isMulti: isMulti
106
112
  };
107
113
  focusMsg = messages.onFocus(onFocusProps);
108
114
  }
115
+ prevInputValue.current = inputValue;
109
116
  return focusMsg;
110
- }, [inputValue, focusedOption, focusedValue, getOptionLabel, isOptionDisabled, messages, focusableOptions, selectValue, isAppleDevice, isA11yImprovementEnabled, isMulti]);
117
+ }, [inputValue, focusedOption, focusedValue, getOptionLabel, isOptionDisabled, messages, focusableOptions, selectValue, isA11yImprovementEnabled, isMulti]);
111
118
  var ariaResults = useMemo(function () {
112
119
  var resultsMsg = '';
113
120
  if (menuIsOpen && options.length && !isLoading && messages.onFilter) {
@@ -90,10 +90,6 @@ export interface AriaOnFocusProps<Option, Group extends GroupBase<Option>> {
90
90
  * selected option(s) of the Select
91
91
  */
92
92
  selectValue: Options<Option>;
93
- /**
94
- * Boolean indicating whether user uses Apple device
95
- */
96
- isAppleDevice: boolean;
97
93
  /**
98
94
  * Boolean value of selectProp isMulti
99
95
  */
@@ -4,7 +4,7 @@ import useStateManager from './use-state-manager';
4
4
  export { default } from './state-manager';
5
5
  export { mergeStyles } from './styles';
6
6
  export { defaultTheme } from './theme';
7
- export { createFilter } from './filters';
7
+ export { createFilter, type FilterOptionOption } from './filters';
8
8
  export { components } from './components';
9
9
  export type SelectInstance<Option = unknown, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>> = Select<Option, IsMulti, Group>;
10
10
  export type { StateManagerProps as Props } from './use-state-manager';
@@ -90,10 +90,6 @@ export interface AriaOnFocusProps<Option, Group extends GroupBase<Option>> {
90
90
  * selected option(s) of the Select
91
91
  */
92
92
  selectValue: Options<Option>;
93
- /**
94
- * Boolean indicating whether user uses Apple device
95
- */
96
- isAppleDevice: boolean;
97
93
  /**
98
94
  * Boolean value of selectProp isMulti
99
95
  */
@@ -4,7 +4,7 @@ import useStateManager from './use-state-manager';
4
4
  export { default } from './state-manager';
5
5
  export { mergeStyles } from './styles';
6
6
  export { defaultTheme } from './theme';
7
- export { createFilter } from './filters';
7
+ export { createFilter, type FilterOptionOption } from './filters';
8
8
  export { components } from './components';
9
9
  export type SelectInstance<Option = unknown, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>> = Select<Option, IsMulti, Group>;
10
10
  export type { StateManagerProps as Props } from './use-state-manager';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-select",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "A forked version of react-select to only be used in atlaskit/select",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -26,7 +26,7 @@
26
26
  "./async-creatable": "./src/async-creatable.tsx"
27
27
  },
28
28
  "dependencies": {
29
- "@atlaskit/ds-lib": "^3.1.0",
29
+ "@atlaskit/ds-lib": "^3.2.0",
30
30
  "@atlaskit/platform-feature-flags": "^0.3.0",
31
31
  "@babel/runtime": "^7.0.0",
32
32
  "@emotion/react": "^11.7.1",