@dhis2-ui/select 10.16.3-alpha.1 → 10.16.4

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 (168) hide show
  1. package/build/cjs/locales/index.js +94 -57
  2. package/build/cjs/multi-select/features/menu_width_matches_input/index.js +2 -4
  3. package/build/cjs/multi-select/features/position/index.js +6 -12
  4. package/build/cjs/multi-select/filterable-menu.js +22 -25
  5. package/build/cjs/multi-select/input.js +14 -15
  6. package/build/cjs/multi-select/menu.js +24 -28
  7. package/build/cjs/multi-select/multi-select.e2e.stories.js +21 -32
  8. package/build/cjs/multi-select/multi-select.js +30 -31
  9. package/build/cjs/multi-select/multi-select.prod.stories.js +13 -21
  10. package/build/cjs/multi-select/selection-list.js +51 -57
  11. package/build/cjs/multi-select-option/multi-select-option.js +27 -30
  12. package/build/cjs/select/debounce/debounce.js +2 -6
  13. package/build/cjs/select/empty.js +11 -14
  14. package/build/cjs/select/filter-input.js +21 -24
  15. package/build/cjs/select/filterable-menu.js +6 -8
  16. package/build/cjs/select/input-clear-button.js +28 -31
  17. package/build/cjs/select/input-placeholder.js +5 -6
  18. package/build/cjs/select/input-prefix.js +5 -6
  19. package/build/cjs/select/input-wrapper.js +13 -14
  20. package/build/cjs/select/loading.js +15 -18
  21. package/build/cjs/select/menu-wrapper.js +8 -9
  22. package/build/cjs/select/no-match.js +9 -12
  23. package/build/cjs/select/select.js +3 -4
  24. package/build/cjs/simple-single-select/__stories__/DefaultPosition.js +1 -2
  25. package/build/cjs/simple-single-select/__stories__/Dense.js +1 -2
  26. package/build/cjs/simple-single-select/__stories__/Empty.js +1 -2
  27. package/build/cjs/simple-single-select/__stories__/EmptyWithEmptyNode.js +1 -2
  28. package/build/cjs/simple-single-select/__stories__/EmptyWithEmptyText.js +1 -2
  29. package/build/cjs/simple-single-select/__stories__/FlippedPosition.js +1 -2
  30. package/build/cjs/simple-single-select/__stories__/InfiniteLoading.js +1 -2
  31. package/build/cjs/simple-single-select/__stories__/ShiftedIntoView.js +1 -2
  32. package/build/cjs/simple-single-select/__stories__/WithClearButton.js +1 -2
  33. package/build/cjs/simple-single-select/__stories__/WithCustomLowMaxHeight.js +1 -2
  34. package/build/cjs/simple-single-select/__stories__/WithCustomOptions.js +17 -21
  35. package/build/cjs/simple-single-select/__stories__/WithDisabledOption.js +1 -2
  36. package/build/cjs/simple-single-select/__stories__/WithFilterField.js +5 -9
  37. package/build/cjs/simple-single-select/__stories__/WithInitialFocus.js +1 -2
  38. package/build/cjs/simple-single-select/__stories__/WithManyOptions.js +1 -2
  39. package/build/cjs/simple-single-select/__stories__/WithMultipleSelectsAndScrollableParent.js +1 -2
  40. package/build/cjs/simple-single-select/__stories__/WithNoMatchText.js +1 -2
  41. package/build/cjs/simple-single-select/__stories__/WithOnBlur.js +1 -2
  42. package/build/cjs/simple-single-select/__stories__/WithOnFocus.js +1 -2
  43. package/build/cjs/simple-single-select/__stories__/WithOptionsAndDisabled.js +1 -2
  44. package/build/cjs/simple-single-select/__stories__/WithOptionsAndLoading.js +1 -2
  45. package/build/cjs/simple-single-select/__stories__/WithOptionsAndLoadingText.js +1 -2
  46. package/build/cjs/simple-single-select/__stories__/WithPlaceholder.js +1 -2
  47. package/build/cjs/simple-single-select/__stories__/WithPlaceholderAndSelection.js +1 -2
  48. package/build/cjs/simple-single-select/__stories__/WithPrefix.js +1 -2
  49. package/build/cjs/simple-single-select/__stories__/WithPrefixAndSelection.js +1 -2
  50. package/build/cjs/simple-single-select/__stories__/WithRTL.js +1 -2
  51. package/build/cjs/simple-single-select/__stories__/WithScrollingParent.js +1 -2
  52. package/build/cjs/simple-single-select/__stories__/WithSelection.js +1 -2
  53. package/build/cjs/simple-single-select/__stories__/WithSelectionAndDisabled.js +1 -2
  54. package/build/cjs/simple-single-select/__stories__/WithServerSideFilteringDemo.js +25 -36
  55. package/build/cjs/simple-single-select/__stories__/WithSimpleFilteringDemo.js +4 -6
  56. package/build/cjs/simple-single-select/__stories__/WithoutOptionsAndLoading.js +1 -2
  57. package/build/cjs/simple-single-select/__stories__/WithoutSelection.js +1 -2
  58. package/build/cjs/simple-single-select/__stories__/simple-single-select-server-side-filtering/CustomDataProvider.js +19 -26
  59. package/build/cjs/simple-single-select/features/keyboard-interactions.test.e2e.js +9 -18
  60. package/build/cjs/simple-single-select/features/menu-positioning.test.e2e.js +8 -16
  61. package/build/cjs/simple-single-select/menu/empty.js +8 -11
  62. package/build/cjs/simple-single-select/menu/filter.js +11 -12
  63. package/build/cjs/simple-single-select/menu/loading.js +3 -4
  64. package/build/cjs/simple-single-select/menu/menu.js +26 -28
  65. package/build/cjs/simple-single-select/menu/no-match.js +9 -12
  66. package/build/cjs/simple-single-select/menu/option.js +20 -23
  67. package/build/cjs/simple-single-select/menu/options-list.js +23 -26
  68. package/build/cjs/simple-single-select/selected-value/clear-button.js +5 -6
  69. package/build/cjs/simple-single-select/selected-value/container.js +23 -25
  70. package/build/cjs/simple-single-select/selected-value/placeholder.js +5 -6
  71. package/build/cjs/simple-single-select/selected-value/prefix.js +5 -6
  72. package/build/cjs/simple-single-select/selected-value/selected-value.js +34 -35
  73. package/build/cjs/simple-single-select/simple-single-select.e2e.stories.js +1 -2
  74. package/build/cjs/simple-single-select/simple-single-select.js +47 -50
  75. package/build/cjs/simple-single-select/simple-single-select.test.js +14 -24
  76. package/build/cjs/simple-single-select/use-handle-key-press/use-focus-option.js +5 -6
  77. package/build/cjs/simple-single-select/use-handle-key-press/use-handle-key-press-on-combobox.js +31 -34
  78. package/build/cjs/simple-single-select/use-handle-key-press/use-handle-key-press-on-filter-input.js +11 -12
  79. package/build/cjs/simple-single-select/use-handle-key-press/use-handle-typing.js +10 -14
  80. package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-first-option-on-previous-page.js +6 -7
  81. package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-first-visible-option.js +5 -6
  82. package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-last-option-on-next-page.js +6 -7
  83. package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-last-visible-option.js +5 -6
  84. package/build/cjs/simple-single-select/use-handle-key-press/use-page-down.js +6 -7
  85. package/build/cjs/simple-single-select/use-handle-key-press/use-page-up.js +6 -7
  86. package/build/cjs/simple-single-select/use-handle-key-press/utils.js +17 -22
  87. package/build/cjs/simple-single-select-field/simple-single-select-field.js +3 -6
  88. package/build/cjs/simple-single-select-field/simple-single-select-field.prod.stories.js +1 -2
  89. package/build/cjs/simple-single-select-field/simple-single-select-field.test.js +3 -6
  90. package/build/cjs/single-select/features/menu_width_matches_input/index.js +2 -4
  91. package/build/cjs/single-select/features/position/index.js +4 -8
  92. package/build/cjs/single-select/filterable-menu.js +22 -25
  93. package/build/cjs/single-select/input.js +13 -14
  94. package/build/cjs/single-select/menu.js +9 -10
  95. package/build/cjs/single-select/selection.js +5 -6
  96. package/build/cjs/single-select/single-select.e2e.stories.js +18 -28
  97. package/build/cjs/single-select/single-select.js +29 -30
  98. package/build/cjs/single-select/single-select.prod.stories.js +7 -11
  99. package/build/cjs/single-select-option/single-select-option.js +25 -28
  100. package/build/es/locales/index.js +70 -33
  101. package/build/es/multi-select/features/menu_width_matches_input/index.js +2 -4
  102. package/build/es/multi-select/features/position/index.js +6 -12
  103. package/build/es/multi-select/filterable-menu.js +22 -25
  104. package/build/es/multi-select/input.js +14 -15
  105. package/build/es/multi-select/menu.js +24 -28
  106. package/build/es/multi-select/multi-select.e2e.stories.js +20 -30
  107. package/build/es/multi-select/multi-select.js +30 -31
  108. package/build/es/multi-select/multi-select.prod.stories.js +12 -19
  109. package/build/es/multi-select/selection-list.js +51 -57
  110. package/build/es/multi-select-option/multi-select-option.js +27 -30
  111. package/build/es/select/debounce/debounce.js +2 -6
  112. package/build/es/select/empty.js +11 -14
  113. package/build/es/select/filter-input.js +21 -24
  114. package/build/es/select/filterable-menu.js +5 -6
  115. package/build/es/select/input-clear-button.js +28 -31
  116. package/build/es/select/input-placeholder.js +5 -6
  117. package/build/es/select/input-prefix.js +5 -6
  118. package/build/es/select/input-wrapper.js +13 -14
  119. package/build/es/select/loading.js +15 -18
  120. package/build/es/select/menu-wrapper.js +8 -9
  121. package/build/es/select/no-match.js +9 -12
  122. package/build/es/select/select.js +2 -2
  123. package/build/es/simple-single-select/__stories__/WithCustomOptions.js +16 -19
  124. package/build/es/simple-single-select/__stories__/WithFilterField.js +4 -7
  125. package/build/es/simple-single-select/__stories__/WithServerSideFilteringDemo.js +24 -34
  126. package/build/es/simple-single-select/__stories__/WithSimpleFilteringDemo.js +3 -4
  127. package/build/es/simple-single-select/__stories__/simple-single-select-server-side-filtering/CustomDataProvider.js +19 -26
  128. package/build/es/simple-single-select/features/keyboard-interactions.test.e2e.js +9 -18
  129. package/build/es/simple-single-select/features/menu-positioning.test.e2e.js +8 -16
  130. package/build/es/simple-single-select/menu/empty.js +8 -11
  131. package/build/es/simple-single-select/menu/filter.js +11 -12
  132. package/build/es/simple-single-select/menu/loading.js +3 -4
  133. package/build/es/simple-single-select/menu/menu.js +25 -26
  134. package/build/es/simple-single-select/menu/no-match.js +9 -12
  135. package/build/es/simple-single-select/menu/option.js +19 -21
  136. package/build/es/simple-single-select/menu/options-list.js +22 -24
  137. package/build/es/simple-single-select/selected-value/clear-button.js +5 -6
  138. package/build/es/simple-single-select/selected-value/container.js +22 -23
  139. package/build/es/simple-single-select/selected-value/placeholder.js +5 -6
  140. package/build/es/simple-single-select/selected-value/prefix.js +5 -6
  141. package/build/es/simple-single-select/selected-value/selected-value.js +34 -35
  142. package/build/es/simple-single-select/simple-single-select.js +46 -48
  143. package/build/es/simple-single-select/simple-single-select.test.js +13 -22
  144. package/build/es/simple-single-select/use-handle-key-press/use-focus-option.js +5 -6
  145. package/build/es/simple-single-select/use-handle-key-press/use-handle-key-press-on-combobox.js +31 -34
  146. package/build/es/simple-single-select/use-handle-key-press/use-handle-key-press-on-filter-input.js +11 -12
  147. package/build/es/simple-single-select/use-handle-key-press/use-handle-typing.js +10 -14
  148. package/build/es/simple-single-select/use-handle-key-press/use-highlight-first-option-on-previous-page.js +6 -7
  149. package/build/es/simple-single-select/use-handle-key-press/use-highlight-first-visible-option.js +5 -6
  150. package/build/es/simple-single-select/use-handle-key-press/use-highlight-last-option-on-next-page.js +6 -7
  151. package/build/es/simple-single-select/use-handle-key-press/use-highlight-last-visible-option.js +5 -6
  152. package/build/es/simple-single-select/use-handle-key-press/use-page-down.js +6 -7
  153. package/build/es/simple-single-select/use-handle-key-press/use-page-up.js +6 -7
  154. package/build/es/simple-single-select/use-handle-key-press/utils.js +17 -22
  155. package/build/es/simple-single-select-field/simple-single-select-field.js +3 -6
  156. package/build/es/simple-single-select-field/simple-single-select-field.test.js +3 -6
  157. package/build/es/single-select/features/menu_width_matches_input/index.js +2 -4
  158. package/build/es/single-select/features/position/index.js +4 -8
  159. package/build/es/single-select/filterable-menu.js +22 -25
  160. package/build/es/single-select/input.js +13 -14
  161. package/build/es/single-select/menu.js +9 -10
  162. package/build/es/single-select/selection.js +5 -6
  163. package/build/es/single-select/single-select.e2e.stories.js +17 -26
  164. package/build/es/single-select/single-select.js +29 -30
  165. package/build/es/single-select/single-select.prod.stories.js +6 -9
  166. package/build/es/single-select-option/single-select-option.js +25 -28
  167. package/package.json +15 -15
  168. package/src/locales/index.js +102 -33
@@ -3,27 +3,26 @@ import { colors, theme } from '@dhis2/ui-constants';
3
3
  import cx from 'classnames';
4
4
  import PropTypes from 'prop-types';
5
5
  import React, { forwardRef, useCallback, useEffect } from 'react';
6
- export const Container = /*#__PURE__*/forwardRef(function Container(_ref, ref) {
7
- let {
8
- children,
9
- comboBoxId,
10
- autoFocus,
11
- dataTest,
12
- dense,
13
- disabled,
14
- error,
15
- expanded,
16
- labelledBy,
17
- name,
18
- placeholder,
19
- tabIndex,
20
- valid,
21
- warning,
22
- onBlur,
23
- onClick: _onClick,
24
- onFocus,
25
- onKeyDown
26
- } = _ref;
6
+ export const Container = /*#__PURE__*/forwardRef(function Container({
7
+ children,
8
+ comboBoxId,
9
+ autoFocus,
10
+ dataTest,
11
+ dense,
12
+ disabled,
13
+ error,
14
+ expanded,
15
+ labelledBy,
16
+ name,
17
+ placeholder,
18
+ tabIndex,
19
+ valid,
20
+ warning,
21
+ onBlur,
22
+ onClick: _onClick,
23
+ onFocus,
24
+ onKeyDown
25
+ }, ref) {
27
26
  // Using useEffect so we have access to the ref, which will be set before
28
27
  // the first call to the useEffect's callback
29
28
  useEffect(() => {
@@ -34,9 +33,9 @@ export const Container = /*#__PURE__*/forwardRef(function Container(_ref, ref) {
34
33
  // We want to run this only once:
35
34
  // eslint-disable-next-line react-hooks/exhaustive-deps
36
35
  []);
37
- const onClick = useCallback(function () {
36
+ const onClick = useCallback((...args) => {
38
37
  if (!disabled) {
39
- _onClick(...arguments);
38
+ _onClick(...args);
40
39
  }
41
40
  }, [disabled, _onClick]);
42
41
  return /*#__PURE__*/React.createElement("div", {
@@ -2,12 +2,11 @@ import _JSXStyle from "styled-jsx/style";
2
2
  import { colors } from '@dhis2/ui-constants';
3
3
  import PropTypes from 'prop-types';
4
4
  import React from 'react';
5
- export function Placeholder(_ref) {
6
- let {
7
- placeholder,
8
- className,
9
- dataTest
10
- } = _ref;
5
+ export function Placeholder({
6
+ placeholder,
7
+ className,
8
+ dataTest
9
+ }) {
11
10
  return /*#__PURE__*/React.createElement("div", {
12
11
  "data-test": dataTest,
13
12
  className: _JSXStyle.dynamic([["1027033961", [colors.grey600]]]) + " " + (className || "")
@@ -2,12 +2,11 @@ import _JSXStyle from "styled-jsx/style";
2
2
  import { colors, spacers } from '@dhis2/ui-constants';
3
3
  import PropTypes from 'prop-types';
4
4
  import React from 'react';
5
- export function Prefix(_ref) {
6
- let {
7
- prefix,
8
- className,
9
- dataTest
10
- } = _ref;
5
+ export function Prefix({
6
+ prefix,
7
+ className,
8
+ dataTest
9
+ }) {
11
10
  return /*#__PURE__*/React.createElement("div", {
12
11
  "data-test": dataTest,
13
12
  className: _JSXStyle.dynamic([["1343055987", [colors.grey600, spacers.dp12]]]) + " " + (className || "")
@@ -7,41 +7,40 @@ import { ClearButton } from './clear-button.js';
7
7
  import { Container } from './container.js';
8
8
  import { Placeholder } from './placeholder.js';
9
9
  import { Prefix } from './prefix.js';
10
- export function SelectedValue(_ref) {
11
- let {
12
- clearText,
13
- comboBoxId,
14
- name,
15
- selectedLabel,
16
- onKeyDown,
17
- autoFocus,
18
- clearable,
19
- comboBoxRef,
20
- dataTest,
21
- dense,
22
- disabled,
23
- error,
24
- expanded,
25
- filterLabel,
26
- filterPlaceholder,
27
- filterRef,
28
- filterable,
29
- filterValue,
30
- hasSelection,
31
- inputMaxHeight,
32
- labelledBy,
33
- placeholder,
34
- prefix,
35
- tabIndex,
36
- valid,
37
- warning,
38
- onBlur,
39
- onClear,
40
- onClick,
41
- onFilterChange,
42
- onFilterInputKeyDown,
43
- onFocus
44
- } = _ref;
10
+ export function SelectedValue({
11
+ clearText,
12
+ comboBoxId,
13
+ name,
14
+ selectedLabel,
15
+ onKeyDown,
16
+ autoFocus,
17
+ clearable,
18
+ comboBoxRef,
19
+ dataTest,
20
+ dense,
21
+ disabled,
22
+ error,
23
+ expanded,
24
+ filterLabel,
25
+ filterPlaceholder,
26
+ filterRef,
27
+ filterable,
28
+ filterValue,
29
+ hasSelection,
30
+ inputMaxHeight,
31
+ labelledBy,
32
+ placeholder,
33
+ prefix,
34
+ tabIndex,
35
+ valid,
36
+ warning,
37
+ onBlur,
38
+ onClear,
39
+ onClick,
40
+ onFilterChange,
41
+ onFilterInputKeyDown,
42
+ onFocus
43
+ }) {
45
44
  const dataTestPrefix = `${dataTest}-selectedvalue`;
46
45
  const showFilter = filterable && expanded;
47
46
  return /*#__PURE__*/React.createElement(Container, {
@@ -8,12 +8,11 @@ import { Menu } from './menu/index.js';
8
8
  import { SelectedValue } from './selected-value/index.js';
9
9
  import { optionProp } from './shared-prop-types.js';
10
10
  import { useHandleKeyPressOnCombobox, useHandleKeyPressOnFilterInput } from './use-handle-key-press/index.js';
11
- function useFocussedOptionIndex(_ref) {
12
- let {
13
- filterable,
14
- filterValue,
15
- options
16
- } = _ref;
11
+ function useFocussedOptionIndex({
12
+ filterable,
13
+ filterValue,
14
+ options
15
+ }) {
17
16
  const [defaultFocussedOptionIndex, setDefaultFocussedOptionIndex] = useState(0);
18
17
  const [searchFocussedOptionIndex, setSearchFocussedOptionIndex] = useState(0);
19
18
 
@@ -43,47 +42,46 @@ function useFocussedOptionIndex(_ref) {
43
42
  }, [filterValue]);
44
43
  return [focussedOptionIndex, setFocussedOptionIndex];
45
44
  }
46
- export function SimpleSingleSelect(_ref2) {
47
- let {
48
- name,
49
- options,
50
- onChange,
51
- autoFocus = false,
52
- className = '',
53
- clearText: _clearText = '',
54
- clearable = false,
55
- optionComponent = undefined,
56
- dataTest = 'dhis2-simplesingleselect',
57
- dense = false,
58
- disabled = false,
59
- empty: _empty = false,
60
- error = false,
61
- filterLabel = '',
62
- filterPlaceholder: _filterPlaceholder = '',
63
- filterValue = '',
64
- filterable = false,
65
- inputMaxHeight = '',
66
- labelledBy = '',
67
- loading = false,
68
- menuLoadingText: _menuLoadingText = '',
69
- menuMaxHeight = '288px',
70
- noMatchText: _noMatchText = '',
71
- optionUpdateStrategy = 'polite',
72
- placeholder = '',
73
- prefix = '',
74
- selected = {
75
- label: '',
76
- value: ''
77
- },
78
- tabIndex = '0',
79
- valid = false,
80
- warning = false,
81
- onBlur = () => undefined,
82
- onClear = () => undefined,
83
- onEndReached = () => undefined,
84
- onFilterChange = () => undefined,
85
- onFocus = () => undefined
86
- } = _ref2;
45
+ export function SimpleSingleSelect({
46
+ name,
47
+ options,
48
+ onChange,
49
+ autoFocus = false,
50
+ className = '',
51
+ clearText: _clearText = '',
52
+ clearable = false,
53
+ optionComponent = undefined,
54
+ dataTest = 'dhis2-simplesingleselect',
55
+ dense = false,
56
+ disabled = false,
57
+ empty: _empty = false,
58
+ error = false,
59
+ filterLabel = '',
60
+ filterPlaceholder: _filterPlaceholder = '',
61
+ filterValue = '',
62
+ filterable = false,
63
+ inputMaxHeight = '',
64
+ labelledBy = '',
65
+ loading = false,
66
+ menuLoadingText: _menuLoadingText = '',
67
+ menuMaxHeight = '288px',
68
+ noMatchText: _noMatchText = '',
69
+ optionUpdateStrategy = 'polite',
70
+ placeholder = '',
71
+ prefix = '',
72
+ selected = {
73
+ label: '',
74
+ value: ''
75
+ },
76
+ tabIndex = '0',
77
+ valid = false,
78
+ warning = false,
79
+ onBlur = () => undefined,
80
+ onClear = () => undefined,
81
+ onEndReached = () => undefined,
82
+ onFilterChange = () => undefined,
83
+ onFocus = () => undefined
84
+ }) {
87
85
  // We can't translate with default props as the translation function would
88
86
  // be called before we get any translations from the consuming app/lib
89
87
  const clearText = _clearText || i18n.t('Clear');
@@ -106,7 +104,7 @@ export function SimpleSingleSelect(_ref2) {
106
104
  if (expanded && filterable) {
107
105
  requestAnimationFrame(() => {
108
106
  var _filterInputRef$curre;
109
- (_filterInputRef$curre = filterInputRef.current) === null || _filterInputRef$curre === void 0 ? void 0 : _filterInputRef$curre.focus();
107
+ (_filterInputRef$curre = filterInputRef.current) === null || _filterInputRef$curre === void 0 || _filterInputRef$curre.focus();
110
108
  });
111
109
  }
112
110
  }, [expanded, filterable]);
@@ -5,10 +5,7 @@ import { SimpleSingleSelect } from './simple-single-select.js';
5
5
  describe('<SimpleSingleSelect />', () => {
6
6
  beforeAll(() => {
7
7
  const consoleError = console.error;
8
- jest.spyOn(console, 'error').mockImplementation(function () {
9
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
10
- args[_key] = arguments[_key];
11
- }
8
+ jest.spyOn(console, 'error').mockImplementation((...args) => {
12
9
  const [message, dynamicContent] = args;
13
10
  if (message.startsWith('Warning: An update to %s inside a test was not wrapped in act(...)') && dynamicContent === 'Popper') {
14
11
  return;
@@ -209,15 +206,12 @@ describe('<SimpleSingleSelect />', () => {
209
206
  const onChange = jest.fn();
210
207
 
211
208
  // eslint-disable-next-line react/prop-types
212
- const CustomOption = _ref => {
213
- let {
214
- value,
215
- label
216
- } = _ref;
217
- return /*#__PURE__*/React.createElement("span", {
218
- "data-test": `custom-option-${value}`
219
- }, label);
220
- };
209
+ const CustomOption = ({
210
+ value,
211
+ label
212
+ }) => /*#__PURE__*/React.createElement("span", {
213
+ "data-test": `custom-option-${value}`
214
+ }, label);
221
215
  render(/*#__PURE__*/React.createElement(SimpleSingleSelect, {
222
216
  name: "simple",
223
217
  selected: null,
@@ -247,15 +241,12 @@ describe('<SimpleSingleSelect />', () => {
247
241
  const onChange = jest.fn();
248
242
 
249
243
  // eslint-disable-next-line react/prop-types
250
- const CustomOption = _ref2 => {
251
- let {
252
- value,
253
- label
254
- } = _ref2;
255
- return /*#__PURE__*/React.createElement("span", {
256
- "data-test": `custom-option-${value}`
257
- }, label);
258
- };
244
+ const CustomOption = ({
245
+ value,
246
+ label
247
+ }) => /*#__PURE__*/React.createElement("span", {
248
+ "data-test": `custom-option-${value}`
249
+ }, label);
259
250
  render(/*#__PURE__*/React.createElement(SimpleSingleSelect, {
260
251
  name: "simple",
261
252
  selected: null,
@@ -1,10 +1,9 @@
1
1
  import { useCallback } from 'react';
2
- export function useFocusOption(findIndexCallback, _ref) {
3
- let {
4
- options,
5
- focussedOptionIndex,
6
- setFocussedOptionIndex
7
- } = _ref;
2
+ export function useFocusOption(findIndexCallback, {
3
+ options,
4
+ focussedOptionIndex,
5
+ setFocussedOptionIndex
6
+ }) {
8
7
  return useCallback(() => {
9
8
  const nextFocussedIndex = findIndexCallback({
10
9
  options,
@@ -4,21 +4,19 @@ import { useHandleTyping } from './use-handle-typing.js';
4
4
  import { usePageDown } from './use-page-down.js';
5
5
  import { usePageUp } from './use-page-up.js';
6
6
  import { findNextOptionIndex, findPrevOptionIndex, findFirstOptionIndex, findLastOptionIndex } from './utils.js';
7
- function isUnmodifiedCharacterKey(_ref) {
8
- let {
9
- key,
10
- altKey,
11
- ctrlKey,
12
- metaKey
13
- } = _ref;
7
+ function isUnmodifiedCharacterKey({
8
+ key,
9
+ altKey,
10
+ ctrlKey,
11
+ metaKey
12
+ }) {
14
13
  return key.length === 1 && key !== ' ' && !altKey && !ctrlKey && !metaKey;
15
14
  }
16
- function useSelectOption(findIndexCallback, _ref2) {
17
- let {
18
- options,
19
- onChange,
20
- value
21
- } = _ref2;
15
+ function useSelectOption(findIndexCallback, {
16
+ options,
17
+ onChange,
18
+ value
19
+ }) {
22
20
  return useCallback(() => {
23
21
  const currentOptionIndex = options.findIndex(option => option.value === value);
24
22
  const nextSelectedOptionIndex = findIndexCallback({
@@ -35,25 +33,24 @@ function useSelectOption(findIndexCallback, _ref2) {
35
33
  });
36
34
  }, [findIndexCallback, options, onChange, value]);
37
35
  }
38
- export function useHandleKeyPressOnCombobox(_ref3) {
39
- let {
40
- value,
41
- disabled,
42
- expanded,
43
- loading,
44
- options,
45
- openMenu,
46
- closeMenu,
47
- listBoxRef,
48
- focussedOptionIndex,
49
- setFocussedOptionIndex,
50
- selectFocussedOption,
51
- onChange,
52
- clearable,
53
- onClear,
54
- filterable,
55
- onFilterChange
56
- } = _ref3;
36
+ export function useHandleKeyPressOnCombobox({
37
+ value,
38
+ disabled,
39
+ expanded,
40
+ loading,
41
+ options,
42
+ openMenu,
43
+ closeMenu,
44
+ listBoxRef,
45
+ focussedOptionIndex,
46
+ setFocussedOptionIndex,
47
+ selectFocussedOption,
48
+ onChange,
49
+ clearable,
50
+ onClear,
51
+ filterable,
52
+ onFilterChange
53
+ }) {
57
54
  const {
58
55
  onTyping,
59
56
  typing
@@ -142,7 +139,7 @@ export function useHandleKeyPressOnCombobox(_ref3) {
142
139
  return;
143
140
  }
144
141
  if (!expanded && clearable && key === 'Escape') {
145
- onClear === null || onClear === void 0 ? void 0 : onClear();
142
+ onClear === null || onClear === void 0 || onClear();
146
143
  return;
147
144
  }
148
145
  if (!expanded && (key === ' ' && !typing || key === 'Enter' || key === 'ArrowUp' && altKey || key === 'ArrowDown' && altKey)) {
@@ -175,7 +172,7 @@ export function useHandleKeyPressOnCombobox(_ref3) {
175
172
  }
176
173
  if (filterable && !expanded && isUnmodifiedCharacterKey(event)) {
177
174
  openMenu();
178
- onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange(key);
175
+ onFilterChange === null || onFilterChange === void 0 || onFilterChange(key);
179
176
  return;
180
177
  }
181
178
  if (key === 'Backspace' || key === 'Clear' || isUnmodifiedCharacterKey(event) || key === ' ' && typing) {
@@ -3,18 +3,17 @@ import { useFocusOption } from './use-focus-option.js';
3
3
  import { usePageDown } from './use-page-down.js';
4
4
  import { usePageUp } from './use-page-up.js';
5
5
  import { findNextOptionIndex, findPrevOptionIndex, findFirstOptionIndex, findLastOptionIndex } from './utils.js';
6
- export function useHandleKeyPressOnFilterInput(_ref) {
7
- let {
8
- value,
9
- options,
10
- loading,
11
- closeMenu,
12
- listBoxRef,
13
- focusComboBox,
14
- focussedOptionIndex,
15
- setFocussedOptionIndex,
16
- selectFocussedOption
17
- } = _ref;
6
+ export function useHandleKeyPressOnFilterInput({
7
+ value,
8
+ options,
9
+ loading,
10
+ closeMenu,
11
+ listBoxRef,
12
+ focusComboBox,
13
+ focussedOptionIndex,
14
+ setFocussedOptionIndex,
15
+ selectFocussedOption
16
+ }) {
18
17
  const pageDown = usePageDown({
19
18
  options,
20
19
  focussedOptionIndex,
@@ -1,13 +1,12 @@
1
1
  import { useCallback, useEffect, useRef, useState } from 'react';
2
2
  const TYPING_DEBOUNCE_TIME = 300; // ms
3
3
 
4
- export function useHandleTyping(_ref) {
5
- let {
6
- expanded,
7
- options,
8
- setFocussedOptionIndex,
9
- onChange
10
- } = _ref;
4
+ export function useHandleTyping({
5
+ expanded,
6
+ options,
7
+ setFocussedOptionIndex,
8
+ onChange
9
+ }) {
11
10
  const [value, setValue] = useState('');
12
11
  const [typing, setTyping] = useState(false);
13
12
 
@@ -36,13 +35,10 @@ export function useHandleTyping(_ref) {
36
35
  if (value && value !== prevValueRef.current) {
37
36
  // We only want to do this when the value changed
38
37
  prevValueRef.current = value;
39
- const optionIndex = options.findIndex(_ref2 => {
40
- let {
41
- disabled,
42
- label
43
- } = _ref2;
44
- return !disabled && label.toLowerCase().startsWith(value.toLowerCase());
45
- });
38
+ const optionIndex = options.findIndex(({
39
+ disabled,
40
+ label
41
+ }) => !disabled && label.toLowerCase().startsWith(value.toLowerCase()));
46
42
  if (optionIndex !== -1) {
47
43
  if (expanded) {
48
44
  setFocussedOptionIndex(optionIndex);
@@ -1,11 +1,10 @@
1
1
  import { useCallback } from 'react';
2
- export function useHighlightFirstOptionOnPreviousPage(_ref) {
3
- let {
4
- options,
5
- focussedOptionIndex,
6
- setFocussedOptionIndex,
7
- listBoxRef
8
- } = _ref;
2
+ export function useHighlightFirstOptionOnPreviousPage({
3
+ options,
4
+ focussedOptionIndex,
5
+ setFocussedOptionIndex,
6
+ listBoxRef
7
+ }) {
9
8
  return useCallback(() => {
10
9
  const listBoxParent = listBoxRef.current.parentNode;
11
10
  const optionElements = Array.from(listBoxRef.current.childNodes);
@@ -1,10 +1,9 @@
1
1
  import { useCallback } from 'react';
2
- export function useHighlightFirstVisibleOption(_ref) {
3
- let {
4
- options,
5
- focussedOptionIndex,
6
- setFocussedOptionIndex
7
- } = _ref;
2
+ export function useHighlightFirstVisibleOption({
3
+ options,
4
+ focussedOptionIndex,
5
+ setFocussedOptionIndex
6
+ }) {
8
7
  return useCallback(lowestVisibleIndex => {
9
8
  if (!options[lowestVisibleIndex].disabled) {
10
9
  setFocussedOptionIndex(lowestVisibleIndex);
@@ -1,11 +1,10 @@
1
1
  import { useCallback } from 'react';
2
- export function useHighlightLastOptionOnNextPage(_ref) {
3
- let {
4
- options,
5
- focussedOptionIndex,
6
- setFocussedOptionIndex,
7
- listBoxRef
8
- } = _ref;
2
+ export function useHighlightLastOptionOnNextPage({
3
+ options,
4
+ focussedOptionIndex,
5
+ setFocussedOptionIndex,
6
+ listBoxRef
7
+ }) {
9
8
  return useCallback(() => {
10
9
  const listBoxParent = listBoxRef.current.parentNode;
11
10
  const optionElements = Array.from(listBoxRef.current.childNodes);
@@ -1,10 +1,9 @@
1
1
  import { useCallback } from 'react';
2
- export function useHighlightLastVisibleOption(_ref) {
3
- let {
4
- options,
5
- focussedOptionIndex,
6
- setFocussedOptionIndex
7
- } = _ref;
2
+ export function useHighlightLastVisibleOption({
3
+ options,
4
+ focussedOptionIndex,
5
+ setFocussedOptionIndex
6
+ }) {
8
7
  return useCallback(highestVisibleIndex => {
9
8
  if (!options[highestVisibleIndex].disabled) {
10
9
  setFocussedOptionIndex(highestVisibleIndex);
@@ -2,13 +2,12 @@ import { useCallback } from 'react';
2
2
  import { isOptionHidden } from '../is-option-hidden.js';
3
3
  import { useHighlightLastOptionOnNextPage } from './use-highlight-last-option-on-next-page.js';
4
4
  import { useHighlightLastVisibleOption } from './use-highlight-last-visible-option.js';
5
- export function usePageDown(_ref) {
6
- let {
7
- options,
8
- focussedOptionIndex,
9
- setFocussedOptionIndex,
10
- listBoxRef
11
- } = _ref;
5
+ export function usePageDown({
6
+ options,
7
+ focussedOptionIndex,
8
+ setFocussedOptionIndex,
9
+ listBoxRef
10
+ }) {
12
11
  const highlightLastVisibleOption = useHighlightLastVisibleOption({
13
12
  options,
14
13
  focussedOptionIndex,
@@ -2,13 +2,12 @@ import { useCallback } from 'react';
2
2
  import { isOptionHidden } from '../is-option-hidden.js';
3
3
  import { useHighlightFirstOptionOnPreviousPage } from './use-highlight-first-option-on-previous-page.js';
4
4
  import { useHighlightFirstVisibleOption } from './use-highlight-first-visible-option.js';
5
- export function usePageUp(_ref) {
6
- let {
7
- options,
8
- listBoxRef,
9
- focussedOptionIndex,
10
- setFocussedOptionIndex
11
- } = _ref;
5
+ export function usePageUp({
6
+ options,
7
+ listBoxRef,
8
+ focussedOptionIndex,
9
+ setFocussedOptionIndex
10
+ }) {
12
11
  const highlightFirstVisibleOption = useHighlightFirstVisibleOption({
13
12
  options,
14
13
  focussedOptionIndex,