@cloudscape-design/components-themeable 3.0.1402 → 3.0.1404

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 (248) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/action-card/mixins.scss +18 -4
  3. package/lib/internal/scss/action-card/styles.scss +63 -13
  4. package/lib/internal/scss/header/styles.scss +2 -2
  5. package/lib/internal/scss/icon/hover-motion.scss +98 -60
  6. package/lib/internal/scss/internal/components/selectable-item/styles.scss +6 -0
  7. package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +1 -1
  8. package/lib/internal/scss/item-card/styles.scss +103 -13
  9. package/lib/internal/scss/option-list/styles.scss +11 -0
  10. package/lib/internal/scss/option-list/test-classes/styles.scss +9 -0
  11. package/lib/internal/scss/table-root/styles.scss +29 -0
  12. package/lib/internal/template/action-card/internal.d.ts +10 -2
  13. package/lib/internal/template/action-card/internal.d.ts.map +1 -1
  14. package/lib/internal/template/action-card/internal.js +5 -5
  15. package/lib/internal/template/action-card/internal.js.map +1 -1
  16. package/lib/internal/template/action-card/styles.css.js +18 -17
  17. package/lib/internal/template/action-card/styles.scoped.css +274 -202
  18. package/lib/internal/template/action-card/styles.selectors.js +18 -17
  19. package/lib/internal/template/app-layout/visual-refresh-toolbar/skeleton/toolbar-container.d.ts.map +1 -1
  20. package/lib/internal/template/app-layout/visual-refresh-toolbar/skeleton/toolbar-container.js +3 -1
  21. package/lib/internal/template/app-layout/visual-refresh-toolbar/skeleton/toolbar-container.js.map +1 -1
  22. package/lib/internal/template/button-dropdown/filter.d.ts +1 -1
  23. package/lib/internal/template/expandable-section/expandable-section-header.js +1 -1
  24. package/lib/internal/template/expandable-section/expandable-section-header.js.map +1 -1
  25. package/lib/internal/template/header/interfaces.d.ts +4 -0
  26. package/lib/internal/template/header/interfaces.d.ts.map +1 -1
  27. package/lib/internal/template/header/interfaces.js.map +1 -1
  28. package/lib/internal/template/header/internal.d.ts +1 -6
  29. package/lib/internal/template/header/internal.d.ts.map +1 -1
  30. package/lib/internal/template/header/internal.js +2 -2
  31. package/lib/internal/template/header/internal.js.map +1 -1
  32. package/lib/internal/template/header/styles.css.js +36 -36
  33. package/lib/internal/template/header/styles.scoped.css +55 -55
  34. package/lib/internal/template/header/styles.selectors.js +36 -36
  35. package/lib/internal/template/i18n/messages/all.all.js +1 -1
  36. package/lib/internal/template/i18n/messages/all.all.json +1 -1
  37. package/lib/internal/template/i18n/messages/all.de.js +1 -1
  38. package/lib/internal/template/i18n/messages/all.de.json +1 -1
  39. package/lib/internal/template/i18n/messages/all.en-GB.js +1 -1
  40. package/lib/internal/template/i18n/messages/all.en-GB.json +1 -1
  41. package/lib/internal/template/i18n/messages/all.en.js +1 -1
  42. package/lib/internal/template/i18n/messages/all.en.json +1 -1
  43. package/lib/internal/template/i18n/messages/all.es.js +1 -1
  44. package/lib/internal/template/i18n/messages/all.es.json +1 -1
  45. package/lib/internal/template/i18n/messages/all.fr.js +1 -1
  46. package/lib/internal/template/i18n/messages/all.fr.json +1 -1
  47. package/lib/internal/template/i18n/messages/all.id.js +1 -1
  48. package/lib/internal/template/i18n/messages/all.id.json +1 -1
  49. package/lib/internal/template/i18n/messages/all.it.js +1 -1
  50. package/lib/internal/template/i18n/messages/all.it.json +1 -1
  51. package/lib/internal/template/i18n/messages/all.ja.js +1 -1
  52. package/lib/internal/template/i18n/messages/all.ja.json +1 -1
  53. package/lib/internal/template/i18n/messages/all.ko.js +1 -1
  54. package/lib/internal/template/i18n/messages/all.ko.json +1 -1
  55. package/lib/internal/template/i18n/messages/all.pt-BR.js +1 -1
  56. package/lib/internal/template/i18n/messages/all.pt-BR.json +1 -1
  57. package/lib/internal/template/i18n/messages/all.tr.js +1 -1
  58. package/lib/internal/template/i18n/messages/all.tr.json +1 -1
  59. package/lib/internal/template/i18n/messages/all.zh-CN.js +1 -1
  60. package/lib/internal/template/i18n/messages/all.zh-CN.json +1 -1
  61. package/lib/internal/template/i18n/messages/all.zh-TW.js +1 -1
  62. package/lib/internal/template/i18n/messages/all.zh-TW.json +1 -1
  63. package/lib/internal/template/i18n/messages-types.d.ts +3 -0
  64. package/lib/internal/template/i18n/messages-types.d.ts.map +1 -1
  65. package/lib/internal/template/i18n/messages-types.js.map +1 -1
  66. package/lib/internal/template/index.d.ts +1 -0
  67. package/lib/internal/template/index.d.ts.map +1 -1
  68. package/lib/internal/template/index.js +1 -0
  69. package/lib/internal/template/index.js.map +1 -1
  70. package/lib/internal/template/internal/base-component/styles.scoped.css +1 -1
  71. package/lib/internal/template/internal/components/focus-lock/utils.d.ts +2 -0
  72. package/lib/internal/template/internal/components/focus-lock/utils.d.ts.map +1 -1
  73. package/lib/internal/template/internal/components/focus-lock/utils.js +5 -1
  74. package/lib/internal/template/internal/components/focus-lock/utils.js.map +1 -1
  75. package/lib/internal/template/internal/components/listbox/interfaces.d.ts +13 -0
  76. package/lib/internal/template/internal/components/listbox/interfaces.d.ts.map +1 -0
  77. package/lib/internal/template/internal/components/listbox/interfaces.js +2 -0
  78. package/lib/internal/template/internal/components/listbox/interfaces.js.map +1 -0
  79. package/lib/internal/template/internal/components/listbox/parts/get-item-props.d.ts +1 -2
  80. package/lib/internal/template/internal/components/listbox/parts/get-item-props.d.ts.map +1 -1
  81. package/lib/internal/template/internal/components/listbox/parts/get-item-props.js +1 -2
  82. package/lib/internal/template/internal/components/listbox/parts/get-item-props.js.map +1 -1
  83. package/lib/internal/template/internal/components/listbox/parts/item.d.ts +46 -0
  84. package/lib/internal/template/internal/components/listbox/parts/item.d.ts.map +1 -0
  85. package/lib/internal/template/internal/components/listbox/parts/item.js +184 -0
  86. package/lib/internal/template/internal/components/listbox/parts/item.js.map +1 -0
  87. package/lib/internal/template/internal/components/listbox/parts/plain-list.d.ts +30 -0
  88. package/lib/internal/template/internal/components/listbox/parts/plain-list.d.ts.map +1 -0
  89. package/lib/internal/template/{select → internal/components/listbox}/parts/plain-list.js +12 -12
  90. package/lib/internal/template/internal/components/listbox/parts/plain-list.js.map +1 -0
  91. package/lib/internal/template/internal/components/listbox/parts/render-options.d.ts +3 -3
  92. package/lib/internal/template/internal/components/listbox/parts/render-options.d.ts.map +1 -1
  93. package/lib/internal/template/internal/components/listbox/parts/render-options.js +3 -6
  94. package/lib/internal/template/internal/components/listbox/parts/render-options.js.map +1 -1
  95. package/lib/internal/template/internal/components/listbox/parts/scroll-to-index.d.ts +8 -0
  96. package/lib/internal/template/internal/components/listbox/parts/scroll-to-index.d.ts.map +1 -1
  97. package/lib/internal/template/internal/components/listbox/parts/scroll-to-index.js +16 -0
  98. package/lib/internal/template/internal/components/listbox/parts/scroll-to-index.js.map +1 -1
  99. package/lib/internal/template/internal/components/listbox/use-listbox.d.ts +85 -0
  100. package/lib/internal/template/internal/components/listbox/use-listbox.d.ts.map +1 -0
  101. package/lib/internal/template/internal/components/listbox/use-listbox.js +117 -0
  102. package/lib/internal/template/internal/components/listbox/use-listbox.js.map +1 -0
  103. package/lib/internal/template/internal/components/listbox/use-type-ahead.d.ts +13 -0
  104. package/lib/internal/template/internal/components/listbox/use-type-ahead.d.ts.map +1 -0
  105. package/lib/internal/template/{select/utils/use-native-search.js → internal/components/listbox/use-type-ahead.js} +8 -8
  106. package/lib/internal/template/internal/components/listbox/use-type-ahead.js.map +1 -0
  107. package/lib/internal/template/internal/components/listbox/utils/navigation.d.ts +20 -0
  108. package/lib/internal/template/internal/components/listbox/utils/navigation.d.ts.map +1 -0
  109. package/lib/internal/template/internal/components/listbox/utils/navigation.js +22 -0
  110. package/lib/internal/template/internal/components/listbox/utils/navigation.js.map +1 -0
  111. package/lib/internal/template/internal/components/listbox/utils/option-props.d.ts +32 -0
  112. package/lib/internal/template/internal/components/listbox/utils/option-props.d.ts.map +1 -0
  113. package/lib/internal/template/internal/components/listbox/utils/option-props.js +51 -0
  114. package/lib/internal/template/internal/components/listbox/utils/option-props.js.map +1 -0
  115. package/lib/internal/template/internal/components/options-list/index.d.ts +4 -1
  116. package/lib/internal/template/internal/components/options-list/index.d.ts.map +1 -1
  117. package/lib/internal/template/internal/components/options-list/index.js +1 -1
  118. package/lib/internal/template/internal/components/options-list/index.js.map +1 -1
  119. package/lib/internal/template/internal/components/options-list/utils/use-keyboard.d.ts +2 -1
  120. package/lib/internal/template/internal/components/options-list/utils/use-keyboard.d.ts.map +1 -1
  121. package/lib/internal/template/internal/components/options-list/utils/use-keyboard.js +5 -3
  122. package/lib/internal/template/internal/components/options-list/utils/use-keyboard.js.map +1 -1
  123. package/lib/internal/template/internal/components/selectable-item/index.d.ts +1 -0
  124. package/lib/internal/template/internal/components/selectable-item/index.d.ts.map +1 -1
  125. package/lib/internal/template/internal/components/selectable-item/index.js +2 -1
  126. package/lib/internal/template/internal/components/selectable-item/index.js.map +1 -1
  127. package/lib/internal/template/internal/components/selectable-item/interfaces.d.ts +1 -0
  128. package/lib/internal/template/internal/components/selectable-item/interfaces.d.ts.map +1 -1
  129. package/lib/internal/template/internal/components/selectable-item/interfaces.js.map +1 -1
  130. package/lib/internal/template/internal/components/selectable-item/styles.css.js +23 -22
  131. package/lib/internal/template/internal/components/selectable-item/styles.scoped.css +52 -49
  132. package/lib/internal/template/internal/components/selectable-item/styles.selectors.js +23 -22
  133. package/lib/internal/template/internal/components/sticky-header/use-untabbable-descendants.d.ts +3 -0
  134. package/lib/internal/template/internal/components/sticky-header/use-untabbable-descendants.d.ts.map +1 -0
  135. package/lib/internal/template/internal/components/sticky-header/use-untabbable-descendants.js +16 -0
  136. package/lib/internal/template/internal/components/sticky-header/use-untabbable-descendants.js.map +1 -0
  137. package/lib/internal/template/internal/environment.js +2 -2
  138. package/lib/internal/template/internal/environment.json +2 -2
  139. package/lib/internal/template/item-card/internal.d.ts +10 -1
  140. package/lib/internal/template/item-card/internal.d.ts.map +1 -1
  141. package/lib/internal/template/item-card/internal.js +4 -4
  142. package/lib/internal/template/item-card/internal.js.map +1 -1
  143. package/lib/internal/template/item-card/style.d.ts.map +1 -1
  144. package/lib/internal/template/item-card/style.js +6 -1
  145. package/lib/internal/template/item-card/style.js.map +1 -1
  146. package/lib/internal/template/item-card/styles.css.js +14 -14
  147. package/lib/internal/template/item-card/styles.scoped.css +125 -63
  148. package/lib/internal/template/item-card/styles.selectors.js +14 -14
  149. package/lib/internal/template/multiselect/embedded.d.ts.map +1 -1
  150. package/lib/internal/template/multiselect/embedded.js +2 -2
  151. package/lib/internal/template/multiselect/embedded.js.map +1 -1
  152. package/lib/internal/template/multiselect/internal.d.ts.map +1 -1
  153. package/lib/internal/template/multiselect/internal.js +2 -2
  154. package/lib/internal/template/multiselect/internal.js.map +1 -1
  155. package/lib/internal/template/multiselect/use-multiselect.d.ts +3 -4
  156. package/lib/internal/template/multiselect/use-multiselect.d.ts.map +1 -1
  157. package/lib/internal/template/multiselect/use-multiselect.js +7 -18
  158. package/lib/internal/template/multiselect/use-multiselect.js.map +1 -1
  159. package/lib/internal/template/option-list/index.d.ts +6 -0
  160. package/lib/internal/template/option-list/index.d.ts.map +1 -0
  161. package/lib/internal/template/option-list/index.js +21 -0
  162. package/lib/internal/template/option-list/index.js.map +1 -0
  163. package/lib/internal/template/option-list/interfaces.d.ts +132 -0
  164. package/lib/internal/template/option-list/interfaces.d.ts.map +1 -0
  165. package/lib/internal/template/option-list/interfaces.js +2 -0
  166. package/lib/internal/template/option-list/interfaces.js.map +1 -0
  167. package/lib/internal/template/option-list/internal.d.ts +6 -0
  168. package/lib/internal/template/option-list/internal.d.ts.map +1 -0
  169. package/lib/internal/template/option-list/internal.js +138 -0
  170. package/lib/internal/template/option-list/internal.js.map +1 -0
  171. package/lib/internal/template/option-list/styles.css.js +6 -0
  172. package/lib/internal/template/option-list/styles.scoped.css +40 -0
  173. package/lib/internal/template/option-list/styles.selectors.js +7 -0
  174. package/lib/internal/template/option-list/test-classes/styles.css.js +8 -0
  175. package/lib/internal/template/option-list/test-classes/styles.scoped.css +9 -0
  176. package/lib/internal/template/option-list/test-classes/styles.selectors.js +9 -0
  177. package/lib/internal/template/option-list/use-option-list.d.ts +30 -0
  178. package/lib/internal/template/option-list/use-option-list.d.ts.map +1 -0
  179. package/lib/internal/template/option-list/use-option-list.js +69 -0
  180. package/lib/internal/template/option-list/use-option-list.js.map +1 -0
  181. package/lib/internal/template/package.json +3 -0
  182. package/lib/internal/template/select/internal.d.ts.map +1 -1
  183. package/lib/internal/template/select/internal.js +9 -19
  184. package/lib/internal/template/select/internal.js.map +1 -1
  185. package/lib/internal/template/select/parts/filter.d.ts +1 -1
  186. package/lib/internal/template/select/parts/virtual-list.d.ts +3 -2
  187. package/lib/internal/template/select/parts/virtual-list.d.ts.map +1 -1
  188. package/lib/internal/template/select/parts/virtual-list.js +7 -8
  189. package/lib/internal/template/select/parts/virtual-list.js.map +1 -1
  190. package/lib/internal/template/select/utils/use-select.d.ts +15 -11
  191. package/lib/internal/template/select/utils/use-select.d.ts.map +1 -1
  192. package/lib/internal/template/select/utils/use-select.js +41 -117
  193. package/lib/internal/template/select/utils/use-select.js.map +1 -1
  194. package/lib/internal/template/styling/action-card.scss +56 -0
  195. package/lib/internal/template/styling/item-card.scss +81 -0
  196. package/lib/internal/template/table-root/index.js +1 -1
  197. package/lib/internal/template/table-root/index.js.map +1 -1
  198. package/lib/internal/template/table-root/interfaces.d.ts +15 -1
  199. package/lib/internal/template/table-root/interfaces.d.ts.map +1 -1
  200. package/lib/internal/template/table-root/interfaces.js.map +1 -1
  201. package/lib/internal/template/table-root/internal.d.ts +1 -1
  202. package/lib/internal/template/table-root/internal.d.ts.map +1 -1
  203. package/lib/internal/template/table-root/internal.js +23 -11
  204. package/lib/internal/template/table-root/internal.js.map +1 -1
  205. package/lib/internal/template/table-root/sticky-header-slot.d.ts +15 -0
  206. package/lib/internal/template/table-root/sticky-header-slot.d.ts.map +1 -0
  207. package/lib/internal/template/table-root/sticky-header-slot.js +13 -0
  208. package/lib/internal/template/table-root/sticky-header-slot.js.map +1 -0
  209. package/lib/internal/template/table-root/styles.css.js +10 -5
  210. package/lib/internal/template/table-root/styles.scoped.css +52 -7
  211. package/lib/internal/template/table-root/styles.selectors.js +10 -5
  212. package/lib/internal/template/table-root/use-sticky-header.d.ts +28 -0
  213. package/lib/internal/template/table-root/use-sticky-header.d.ts.map +1 -0
  214. package/lib/internal/template/table-root/use-sticky-header.js +141 -0
  215. package/lib/internal/template/table-root/use-sticky-header.js.map +1 -0
  216. package/lib/internal/template/test-utils/dom/header/index.d.ts +1 -0
  217. package/lib/internal/template/test-utils/dom/header/index.js +3 -0
  218. package/lib/internal/template/test-utils/dom/header/index.js.map +1 -1
  219. package/lib/internal/template/test-utils/dom/index.d.ts +28 -0
  220. package/lib/internal/template/test-utils/dom/index.js +21 -2
  221. package/lib/internal/template/test-utils/dom/index.js.map +1 -1
  222. package/lib/internal/template/test-utils/dom/option-list/index.d.ts +69 -0
  223. package/lib/internal/template/test-utils/dom/option-list/index.js +132 -0
  224. package/lib/internal/template/test-utils/dom/option-list/index.js.map +1 -0
  225. package/lib/internal/template/test-utils/selectors/header/index.d.ts +1 -0
  226. package/lib/internal/template/test-utils/selectors/header/index.js +3 -0
  227. package/lib/internal/template/test-utils/selectors/header/index.js.map +1 -1
  228. package/lib/internal/template/test-utils/selectors/index.d.ts +18 -0
  229. package/lib/internal/template/test-utils/selectors/index.js +16 -2
  230. package/lib/internal/template/test-utils/selectors/index.js.map +1 -1
  231. package/lib/internal/template/test-utils/selectors/option-list/index.d.ts +66 -0
  232. package/lib/internal/template/test-utils/selectors/option-list/index.js +108 -0
  233. package/lib/internal/template/test-utils/selectors/option-list/index.js.map +1 -0
  234. package/package.json +1 -1
  235. package/lib/internal/template/select/parts/item.d.ts +0 -34
  236. package/lib/internal/template/select/parts/item.d.ts.map +0 -1
  237. package/lib/internal/template/select/parts/item.js +0 -94
  238. package/lib/internal/template/select/parts/item.js.map +0 -1
  239. package/lib/internal/template/select/parts/multiselect-item.d.ts +0 -15
  240. package/lib/internal/template/select/parts/multiselect-item.d.ts.map +0 -1
  241. package/lib/internal/template/select/parts/multiselect-item.js +0 -112
  242. package/lib/internal/template/select/parts/multiselect-item.js.map +0 -1
  243. package/lib/internal/template/select/parts/plain-list.d.ts +0 -27
  244. package/lib/internal/template/select/parts/plain-list.d.ts.map +0 -1
  245. package/lib/internal/template/select/parts/plain-list.js.map +0 -1
  246. package/lib/internal/template/select/utils/use-native-search.d.ts +0 -13
  247. package/lib/internal/template/select/utils/use-native-search.d.ts.map +0 -1
  248. package/lib/internal/template/select/utils/use-native-search.js.map +0 -1
@@ -0,0 +1,138 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import React, { useCallback, useMemo } from 'react';
4
+ import clsx from 'clsx';
5
+ import { warnOnce } from '@cloudscape-design/component-toolkit/internal';
6
+ import { useInternalI18n } from '../i18n/context';
7
+ import { getBaseProps } from '../internal/base-component';
8
+ import PlainList from '../internal/components/listbox/parts/plain-list';
9
+ import { multiSelection } from '../internal/components/listbox/selection/multi-selection';
10
+ import { singleSelection } from '../internal/components/listbox/selection/single-selection';
11
+ import { checkOptionValueField } from '../internal/components/listbox/utils/check-option-value-field';
12
+ import { isGroup } from '../internal/components/option/utils/filter-options';
13
+ import { prepareOptions } from '../internal/components/option/utils/prepare-options';
14
+ import { fireNonCancelableEvent } from '../internal/events';
15
+ import useForwardFocus from '../internal/hooks/forward-focus';
16
+ import { useControllable } from '../internal/hooks/use-controllable';
17
+ import { useOptionList } from './use-option-list';
18
+ import optionStyles from '../internal/components/option/styles.css.js';
19
+ import styles from './styles.css.js';
20
+ import testClasses from './test-classes/styles.css.js';
21
+ const EMPTY_SELECTION = [];
22
+ const isOptionGroup = (option) => isGroup(option);
23
+ /**
24
+ * Converts the public options to the options the shared list renders: the `icon` slot becomes the custom icon of
25
+ * the shared option renderer. `originals` maps each converted option back to the consumer's object, so events and
26
+ * `renderOption` receive the consumer's options.
27
+ */
28
+ function toInternalOptions(options) {
29
+ const originals = new Map();
30
+ const originalGroups = new Map();
31
+ // Options and group headers.
32
+ const convert = ({ icon, ...option }) => {
33
+ // The shared option renders a custom icon as is, so wrap it in the same class as the built-in icon of Select and
34
+ // Multiselect options, for the same spacing and alignment.
35
+ const internal = {
36
+ ...option,
37
+ __customIcon: icon && React.createElement("span", { className: optionStyles.icon }, icon),
38
+ };
39
+ return internal;
40
+ };
41
+ const internalOptions = options.map(option => {
42
+ if (!isOptionGroup(option)) {
43
+ const internal = convert(option);
44
+ originals.set(internal, option);
45
+ return internal;
46
+ }
47
+ const children = option.options.map(child => {
48
+ const internal = convert(child);
49
+ originals.set(internal, child);
50
+ return internal;
51
+ });
52
+ const group = { ...convert(option), options: children };
53
+ originalGroups.set(group, option);
54
+ return group;
55
+ });
56
+ return { internalOptions, originals, originalGroups };
57
+ }
58
+ const InternalOptionList = React.forwardRef(({ options, selectionType, selectedOptions: controlledSelectedOptions, onChange, ariaLabel, ariaLabelledby, ariaDescribedby, renderOption, renderHighlightedAriaLive, i18nStrings, __internalRootRef, ...restProps }, ref) => {
59
+ const baseProps = getBaseProps(restProps);
60
+ const i18n = useInternalI18n('option-list');
61
+ const { listOptions, parentMap, originals, originalGroups, hasDuplicateValues, hasDuplicateGroupValues } = useMemo(() => {
62
+ const { internalOptions, originals, originalGroups } = toInternalOptions(options);
63
+ // Also sets the test indexes that test-utils use to find an option by its position.
64
+ const { flatOptions, parentMap } = prepareOptions(internalOptions, 'none', '');
65
+ const values = flatOptions.filter(option => option.type !== 'parent').map(option => option.option.value);
66
+ // Groups are compared only with groups, so a group may share a value with an option.
67
+ const groupValues = options.filter(isOptionGroup).map(group => group.value);
68
+ return {
69
+ listOptions: flatOptions,
70
+ parentMap,
71
+ originals,
72
+ originalGroups,
73
+ hasDuplicateValues: new Set(values).size !== values.length,
74
+ hasDuplicateGroupValues: new Set(groupValues).size !== groupValues.length,
75
+ };
76
+ }, [options]);
77
+ // Check the options inside groups too, not only the top-level entries.
78
+ checkOptionValueField('OptionList', 'options', listOptions.filter(option => option.type !== 'parent').map(option => option.option));
79
+ if (hasDuplicateValues) {
80
+ warnOnce('OptionList', 'Every option must have a unique `value`. The component may work incorrectly.');
81
+ }
82
+ if (hasDuplicateGroupValues) {
83
+ warnOnce('OptionList', 'Every option group must have a unique `value`. The component may work incorrectly.');
84
+ }
85
+ // Maps an option the list returns back to the consumer's object. Options from `options` map to their originals;
86
+ // anything else already came from the consumer through `selectedOptions`.
87
+ const toPublicOption = useCallback((option) => { var _a; return (_a = originals.get(option)) !== null && _a !== void 0 ? _a : option; }, [originals]);
88
+ const toPublicGroup = useCallback((group) => { var _a; return (_a = originalGroups.get(group)) !== null && _a !== void 0 ? _a : group; }, [originalGroups]);
89
+ const [selectedOptions = EMPTY_SELECTION, setSelectedOptions] = useControllable(controlledSelectedOptions, onChange, EMPTY_SELECTION, { componentName: 'OptionList', controlledProp: 'selectedOptions', changeHandler: 'onChange' });
90
+ const selection = selectionType === 'multi'
91
+ ? multiSelection(selectedOptions, { options: listOptions, interactiveGroups: true })
92
+ : singleSelection(selectedOptions);
93
+ const { listRef, listProps, scrollToIndex, highlightType, announcement, getOptionProps, getRootProps } = useOptionList({
94
+ options: listOptions,
95
+ selection,
96
+ onSelect: option => {
97
+ const nextSelectedOptions = selection.getNextSelection(option).map(toPublicOption);
98
+ setSelectedOptions(nextSelectedOptions);
99
+ fireNonCancelableEvent(onChange, { selectedOptions: nextSelectedOptions });
100
+ },
101
+ getParent: option => { var _a; return (_a = parentMap.get(option)) === null || _a === void 0 ? void 0 : _a.option; },
102
+ selectedAriaLabel: i18n('i18nStrings.selectedAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.selectedAriaLabel),
103
+ // The consumer receives its own option and group objects, as with `renderOption`.
104
+ renderHighlightedAriaLive: renderHighlightedAriaLive &&
105
+ ((option, group) => renderHighlightedAriaLive(isGroup(option) ? toPublicGroup(option) : toPublicOption(option), group && toPublicGroup(group))),
106
+ });
107
+ useForwardFocus(ref, listRef);
108
+ const renderOriginalOption = useMemo(() => {
109
+ if (!renderOption) {
110
+ return undefined;
111
+ }
112
+ const toGroupItem = (item) => ({
113
+ ...item,
114
+ option: toPublicGroup(item.option),
115
+ });
116
+ return ({ item }) => {
117
+ if (item.type === 'item') {
118
+ const parent = item.parent && toGroupItem(item.parent);
119
+ return renderOption({ item: { ...item, option: toPublicOption(item.option), parent } });
120
+ }
121
+ if (item.type === 'group') {
122
+ return renderOption({ item: toGroupItem(item) });
123
+ }
124
+ // The listbox renders only options and group headers; it has no trigger or select-all item.
125
+ return null;
126
+ };
127
+ }, [renderOption, toPublicOption, toPublicGroup]);
128
+ return (React.createElement("div", { ...baseProps, className: clsx(baseProps.className, styles.root, testClasses.root), ref: __internalRootRef, ...getRootProps() },
129
+ React.createElement(PlainList, { ref: scrollToIndex, listProps: { ...listProps, ariaLabel, ariaLabelledby, ariaDescribedby }, filteredOptions: listOptions, filteringValue: "", highlightType: highlightType, selectionType: selection.selectionType, isMultiSelect: listProps.isMultiSelect, screenReaderContent: announcement, renderOption: renderOriginalOption, scrollStrategy: "ancestors", getOptionProps: (option, index) => ({
130
+ ...getOptionProps(option, index),
131
+ // There is no dropdown border above the list, so the first item has no top divider.
132
+ hideTopDivider: index === 0,
133
+ className: option.type === 'parent' ? testClasses['group-header'] : testClasses.option,
134
+ 'data-value': option.option.value,
135
+ }) })));
136
+ });
137
+ export default InternalOptionList;
138
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/option-list/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B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["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useMemo } from 'react';\nimport clsx from 'clsx';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useInternalI18n } from '../i18n/context';\nimport { getBaseProps } from '../internal/base-component';\nimport { ItemProps } from '../internal/components/listbox/parts/item';\nimport PlainList from '../internal/components/listbox/parts/plain-list';\nimport { multiSelection } from '../internal/components/listbox/selection/multi-selection';\nimport { singleSelection } from '../internal/components/listbox/selection/single-selection';\nimport { checkOptionValueField } from '../internal/components/listbox/utils/check-option-value-field';\nimport { isGroup } from '../internal/components/option/utils/filter-options';\nimport { prepareOptions } from '../internal/components/option/utils/prepare-options';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useControllable } from '../internal/hooks/use-controllable';\nimport { OptionDefinition, OptionGroup } from '../types/option';\nimport { OptionListProps } from './interfaces';\nimport { useOptionList } from './use-option-list';\n\nimport optionStyles from '../internal/components/option/styles.css.js';\nimport styles from './styles.css.js';\nimport testClasses from './test-classes/styles.css.js';\n\ntype InternalOptionListProps = OptionListProps & InternalBaseComponentProps;\ntype InternalOption = OptionDefinition | OptionGroup;\n\n// The items the listbox passes to `renderOption`, before they are mapped back to the consumer's options.\ntype ListboxRenderItem = Parameters<NonNullable<ItemProps['renderOption']>>[0]['item'];\ntype ListboxGroupItem = Extract<ListboxRenderItem, { type: 'group' }>;\ntype ListboxRenderOption = (props: { item: ListboxRenderItem }) => React.ReactNode;\n\nconst EMPTY_SELECTION: ReadonlyArray<OptionListProps.Option> = [];\n\nconst isOptionGroup = (\n option: OptionListProps.Option | OptionListProps.OptionGroup\n): option is OptionListProps.OptionGroup => isGroup(option as InternalOption);\n\n/**\n * Converts the public options to the options the shared list renders: the `icon` slot becomes the custom icon of\n * the shared option renderer. `originals` maps each converted option back to the consumer's object, so events and\n * `renderOption` receive the consumer's options.\n */\nfunction toInternalOptions(options: OptionListProps.Options) {\n const originals = new Map<OptionDefinition, OptionListProps.Option>();\n const originalGroups = new Map<OptionGroup, OptionListProps.OptionGroup>();\n // Options and group headers.\n const convert = ({ icon, ...option }: OptionListProps.Option): OptionDefinition => {\n // The shared option renders a custom icon as is, so wrap it in the same class as the built-in icon of Select and\n // Multiselect options, for the same spacing and alignment.\n const internal: OptionDefinition & { __customIcon?: React.ReactNode } = {\n ...option,\n __customIcon: icon && <span className={optionStyles.icon}>{icon}</span>,\n };\n return internal;\n };\n const internalOptions = options.map<InternalOption>(option => {\n if (!isOptionGroup(option)) {\n const internal = convert(option);\n originals.set(internal, option);\n return internal;\n }\n const children = option.options.map(child => {\n const internal = convert(child);\n originals.set(internal, child);\n return internal;\n });\n const group: OptionGroup = { ...convert(option), options: children };\n originalGroups.set(group, option);\n return group;\n });\n return { internalOptions, originals, originalGroups };\n}\n\nconst InternalOptionList = React.forwardRef(\n (\n {\n options,\n selectionType,\n selectedOptions: controlledSelectedOptions,\n onChange,\n ariaLabel,\n ariaLabelledby,\n ariaDescribedby,\n renderOption,\n renderHighlightedAriaLive,\n i18nStrings,\n __internalRootRef,\n ...restProps\n }: InternalOptionListProps,\n ref: React.Ref<OptionListProps.Ref>\n ) => {\n const baseProps = getBaseProps(restProps);\n const i18n = useInternalI18n('option-list');\n\n const { listOptions, parentMap, originals, originalGroups, hasDuplicateValues, hasDuplicateGroupValues } =\n useMemo(() => {\n const { internalOptions, originals, originalGroups } = toInternalOptions(options);\n // Also sets the test indexes that test-utils use to find an option by its position.\n const { flatOptions, parentMap } = prepareOptions(internalOptions, 'none', '');\n const values = flatOptions.filter(option => option.type !== 'parent').map(option => option.option.value);\n // Groups are compared only with groups, so a group may share a value with an option.\n const groupValues = options.filter(isOptionGroup).map(group => group.value);\n return {\n listOptions: flatOptions,\n parentMap,\n originals,\n originalGroups,\n hasDuplicateValues: new Set(values).size !== values.length,\n hasDuplicateGroupValues: new Set(groupValues).size !== groupValues.length,\n };\n }, [options]);\n\n // Check the options inside groups too, not only the top-level entries.\n checkOptionValueField(\n 'OptionList',\n 'options',\n listOptions.filter(option => option.type !== 'parent').map(option => option.option)\n );\n if (hasDuplicateValues) {\n warnOnce('OptionList', 'Every option must have a unique `value`. The component may work incorrectly.');\n }\n if (hasDuplicateGroupValues) {\n warnOnce('OptionList', 'Every option group must have a unique `value`. The component may work incorrectly.');\n }\n\n // Maps an option the list returns back to the consumer's object. Options from `options` map to their originals;\n // anything else already came from the consumer through `selectedOptions`.\n const toPublicOption = useCallback(\n (option: OptionDefinition): OptionListProps.Option => originals.get(option) ?? (option as OptionListProps.Option),\n [originals]\n );\n const toPublicGroup = useCallback(\n (group: OptionGroup): OptionListProps.OptionGroup =>\n originalGroups.get(group) ?? (group as OptionListProps.OptionGroup),\n [originalGroups]\n );\n\n const [selectedOptions = EMPTY_SELECTION, setSelectedOptions] = useControllable(\n controlledSelectedOptions,\n onChange,\n EMPTY_SELECTION,\n { componentName: 'OptionList', controlledProp: 'selectedOptions', changeHandler: 'onChange' }\n );\n\n const selection =\n selectionType === 'multi'\n ? multiSelection(selectedOptions, { options: listOptions, interactiveGroups: true })\n : singleSelection(selectedOptions);\n\n const { listRef, listProps, scrollToIndex, highlightType, announcement, getOptionProps, getRootProps } =\n useOptionList({\n options: listOptions,\n selection,\n onSelect: option => {\n const nextSelectedOptions = selection.getNextSelection(option).map(toPublicOption);\n setSelectedOptions(nextSelectedOptions);\n fireNonCancelableEvent(onChange, { selectedOptions: nextSelectedOptions });\n },\n getParent: option => parentMap.get(option)?.option as OptionGroup | undefined,\n selectedAriaLabel: i18n('i18nStrings.selectedAriaLabel', i18nStrings?.selectedAriaLabel),\n // The consumer receives its own option and group objects, as with `renderOption`.\n renderHighlightedAriaLive:\n renderHighlightedAriaLive &&\n ((option, group) =>\n renderHighlightedAriaLive(\n isGroup(option) ? toPublicGroup(option) : toPublicOption(option),\n group && toPublicGroup(group)\n )),\n });\n useForwardFocus(ref, listRef);\n\n const renderOriginalOption = useMemo<ListboxRenderOption | undefined>(() => {\n if (!renderOption) {\n return undefined;\n }\n const toGroupItem = (item: ListboxGroupItem): OptionListProps.OptionGroupItem => ({\n ...item,\n option: toPublicGroup(item.option),\n });\n return ({ item }) => {\n if (item.type === 'item') {\n const parent = item.parent && toGroupItem(item.parent);\n return renderOption({ item: { ...item, option: toPublicOption(item.option), parent } });\n }\n if (item.type === 'group') {\n return renderOption({ item: toGroupItem(item) });\n }\n // The listbox renders only options and group headers; it has no trigger or select-all item.\n return null;\n };\n }, [renderOption, toPublicOption, toPublicGroup]);\n\n return (\n <div\n {...baseProps}\n className={clsx(baseProps.className, styles.root, testClasses.root)}\n ref={__internalRootRef}\n {...getRootProps()}\n >\n <PlainList\n ref={scrollToIndex}\n listProps={{ ...listProps, ariaLabel, ariaLabelledby, ariaDescribedby }}\n filteredOptions={listOptions}\n filteringValue=\"\"\n highlightType={highlightType}\n selectionType={selection.selectionType}\n isMultiSelect={listProps.isMultiSelect}\n screenReaderContent={announcement}\n renderOption={renderOriginalOption}\n scrollStrategy=\"ancestors\"\n getOptionProps={(option, index) => ({\n ...getOptionProps(option, index),\n // There is no dropdown border above the list, so the first item has no top divider.\n hideTopDivider: index === 0,\n className: option.type === 'parent' ? testClasses['group-header'] : testClasses.option,\n 'data-value': option.option.value,\n })}\n />\n </div>\n );\n }\n);\n\nexport default InternalOptionList;\n"]}
@@ -0,0 +1,6 @@
1
+
2
+ import './styles.scoped.css';
3
+ export default {
4
+ "root": "awsui_root_15gzf_luobi_9"
5
+ };
6
+
@@ -0,0 +1,40 @@
1
+ /*
2
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ /* stylelint-disable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
6
+ /* stylelint-enable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
7
+ /* Style used for links in slots/components that are text heavy, to help links stand out among
8
+ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F73#description */
9
+ .awsui_root_15gzf_luobi_9:not(#\9) {
10
+ border-collapse: separate;
11
+ border-spacing: 0;
12
+ box-sizing: border-box;
13
+ caption-side: top;
14
+ cursor: auto;
15
+ direction: inherit;
16
+ empty-cells: show;
17
+ font-family: serif;
18
+ font-style: normal;
19
+ font-variant: normal;
20
+ font-stretch: normal;
21
+ hyphens: none;
22
+ letter-spacing: normal;
23
+ list-style: disc outside none;
24
+ tab-size: 8;
25
+ text-align: start;
26
+ text-indent: 0;
27
+ text-shadow: none;
28
+ text-transform: none;
29
+ visibility: visible;
30
+ white-space: normal;
31
+ word-spacing: normal;
32
+ font-size: var(--font-size-body-m-tq5a14, 14px);
33
+ line-height: var(--line-height-body-m-5xw6xo, 22px);
34
+ color: var(--color-text-body-default-b2us04, #16191f);
35
+ font-weight: var(--font-weight-normal-fr92v6, 400);
36
+ font-family: var(--font-family-base-c9u5cr, "Noto Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
37
+ -webkit-font-smoothing: auto;
38
+ -moz-osx-font-smoothing: auto;
39
+ display: block;
40
+ }
@@ -0,0 +1,7 @@
1
+
2
+ // es-module interop with Babel and Typescript
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ module.exports.default = {
5
+ "root": "awsui_root_15gzf_luobi_9"
6
+ };
7
+
@@ -0,0 +1,8 @@
1
+
2
+ import './styles.scoped.css';
3
+ export default {
4
+ "root": "awsui_root_1kbcw_1ufe3_5",
5
+ "option": "awsui_option_1kbcw_1ufe3_6",
6
+ "group-header": "awsui_group-header_1kbcw_1ufe3_7"
7
+ };
8
+
@@ -0,0 +1,9 @@
1
+ /*
2
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ .awsui_root_1kbcw_1ufe3_5:not(#\9),
6
+ .awsui_option_1kbcw_1ufe3_6:not(#\9),
7
+ .awsui_group-header_1kbcw_1ufe3_7:not(#\9) {
8
+ /* used in test-utils */
9
+ }
@@ -0,0 +1,9 @@
1
+
2
+ // es-module interop with Babel and Typescript
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ module.exports.default = {
5
+ "root": "awsui_root_1kbcw_1ufe3_5",
6
+ "option": "awsui_option_1kbcw_1ufe3_6",
7
+ "group-header": "awsui_group-header_1kbcw_1ufe3_7"
8
+ };
9
+
@@ -0,0 +1,30 @@
1
+ import { ListElementProps } from '../internal/components/listbox/interfaces';
2
+ import { SelectionModel } from '../internal/components/listbox/selection/interfaces';
3
+ import { UseListboxProps } from '../internal/components/listbox/use-listbox';
4
+ import { DropdownOption } from '../internal/components/option/interfaces';
5
+ interface UseOptionListProps extends Pick<UseListboxProps, 'getParent' | 'selectedAriaLabel' | 'renderHighlightedAriaLive'> {
6
+ /** Flattened options in list order. */
7
+ options: ReadonlyArray<DropdownOption>;
8
+ selection: SelectionModel;
9
+ /** Called with the interactive option the user chose. */
10
+ onSelect: (option: DropdownOption) => void;
11
+ }
12
+ /**
13
+ * The list state of OptionList: the shared `useListbox` with OptionList's settings, plus the parts of a list that is
14
+ * always visible. The list is a tab stop; keyboard, mouse and aria-activedescendant come from `useListbox`.
15
+ * This hook adds focus and blur, the mouse-leave reset and type-ahead.
16
+ */
17
+ export declare function useOptionList({ options, selection, onSelect, getParent, selectedAriaLabel, renderHighlightedAriaLive, }: UseOptionListProps): {
18
+ listRef: import("react").RefObject<HTMLDivElement>;
19
+ listProps: ListElementProps;
20
+ scrollToIndex: import("react").RefObject<import("../internal/components/listbox/interfaces").ScrollToIndexRef>;
21
+ highlightType: import("../internal/components/options-list/utils/use-highlight-option").HighlightType;
22
+ announcement: string;
23
+ getOptionProps: (option: DropdownOption, index: number) => ReturnType<typeof import("../internal/components/listbox/utils/option-props").getListboxOptionProps>;
24
+ getRootProps: () => {
25
+ onKeyDown: (event: React.KeyboardEvent) => void;
26
+ onMouseLeave: () => void;
27
+ };
28
+ };
29
+ export {};
30
+ //# sourceMappingURL=use-option-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-option-list.d.ts","sourceRoot":"","sources":["../../../src/option-list/use-option-list.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,qDAAqD,CAAC;AACrF,OAAO,EAAc,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAEzF,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAE1E,UAAU,kBACR,SAAQ,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,mBAAmB,GAAG,2BAA2B,CAAC;IAC9F,uCAAuC;IACvC,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IACvC,SAAS,EAAE,cAAc,CAAC;IAC1B,yDAAyD;IACzD,QAAQ,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;CAC5C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,SAAS,EACT,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,yBAAyB,GAC1B,EAAE,kBAAkB;;;;;;;;;;;EA0EpB"}
@@ -0,0 +1,69 @@
1
+ import { useListbox } from '../internal/components/listbox/use-listbox';
2
+ import { useTypeAhead } from '../internal/components/listbox/use-type-ahead';
3
+ /**
4
+ * The list state of OptionList: the shared `useListbox` with OptionList's settings, plus the parts of a list that is
5
+ * always visible. The list is a tab stop; keyboard, mouse and aria-activedescendant come from `useListbox`.
6
+ * This hook adds focus and blur, the mouse-leave reset and type-ahead.
7
+ */
8
+ export function useOptionList({ options, selection, onSelect, getParent, selectedAriaLabel, renderHighlightedAriaLive, }) {
9
+ const { listRef, getListProps, scrollToIndex, highlightType, announcement, getOptionProps, highlightedOption, highlight, selectedOptions, } = useListbox({
10
+ options,
11
+ selectedOptions: selection.selectedOptions,
12
+ selection,
13
+ interactiveGroups: selection.interactiveGroups,
14
+ onSelect,
15
+ // When the list has focus, Space always chooses.
16
+ spaceSelects: 'always',
17
+ getParent,
18
+ selectedAriaLabel,
19
+ renderHighlightedAriaLive,
20
+ });
21
+ // Focus entry, like opening Select or Multiselect with the keyboard: highlight the first selected option (in
22
+ // selection order) and scroll it into view, or the first option when nothing in the list is selected.
23
+ // A highlight that is already there, such as a hover highlight, is kept, so a click selects the hovered option.
24
+ const onFocus = () => {
25
+ if (highlightedOption) {
26
+ return;
27
+ }
28
+ const firstSelected = selectedOptions.find(option => options.includes(option));
29
+ if (firstSelected) {
30
+ highlight.highlightOptionWithKeyboard(firstSelected);
31
+ }
32
+ else {
33
+ highlight.goHomeWithKeyboard();
34
+ }
35
+ };
36
+ const listProps = {
37
+ ...getListProps({ withKeyboard: true }),
38
+ onFocus,
39
+ // Like closing Select or Multiselect, leaving the list clears the highlight.
40
+ onBlur: () => highlight.resetHighlightWithKeyboard(),
41
+ open: true,
42
+ // The list element is a tab stop without dropdown corners.
43
+ embedded: true,
44
+ isMultiSelect: selection.selectionType === 'multi' || undefined,
45
+ };
46
+ // Attached to the root, not the list, so leaving the whole component clears a hover highlight.
47
+ const onMouseLeave = () => {
48
+ if (listRef.current !== document.activeElement) {
49
+ highlight.resetHighlightWithKeyboard();
50
+ }
51
+ };
52
+ const onTypeAhead = useTypeAhead({
53
+ isEnabled: true,
54
+ options,
55
+ highlightOption: highlight.highlightOptionWithKeyboard,
56
+ highlightedOption: highlightedOption === null || highlightedOption === void 0 ? void 0 : highlightedOption.option,
57
+ interactiveGroups: selection.interactiveGroups,
58
+ });
59
+ return {
60
+ listRef,
61
+ listProps,
62
+ scrollToIndex,
63
+ highlightType,
64
+ announcement,
65
+ getOptionProps,
66
+ getRootProps: () => ({ onKeyDown: onTypeAhead, onMouseLeave }),
67
+ };
68
+ }
69
+ //# sourceMappingURL=use-option-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-option-list.js","sourceRoot":"","sources":["../../../src/option-list/use-option-list.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAmB,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAY7E;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,OAAO,EACP,SAAS,EACT,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,yBAAyB,GACN;IACnB,MAAM,EACJ,OAAO,EACP,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,SAAS,EACT,eAAe,GAChB,GAAG,UAAU,CAAC;QACb,OAAO;QACP,eAAe,EAAE,SAAS,CAAC,eAAe;QAC1C,SAAS;QACT,iBAAiB,EAAE,SAAS,CAAC,iBAAiB;QAC9C,QAAQ;QACR,iDAAiD;QACjD,YAAY,EAAE,QAAQ;QACtB,SAAS;QACT,iBAAiB;QACjB,yBAAyB;KAC1B,CAAC,CAAC;IAEH,6GAA6G;IAC7G,sGAAsG;IACtG,gHAAgH;IAChH,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,IAAI,iBAAiB,EAAE,CAAC;YACtB,OAAO;QACT,CAAC;QACD,MAAM,aAAa,GAAG,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QAC/E,IAAI,aAAa,EAAE,CAAC;YAClB,SAAS,CAAC,2BAA2B,CAAC,aAAa,CAAC,CAAC;QACvD,CAAC;aAAM,CAAC;YACN,SAAS,CAAC,kBAAkB,EAAE,CAAC;QACjC,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,SAAS,GAAqB;QAClC,GAAG,YAAY,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;QACvC,OAAO;QACP,6EAA6E;QAC7E,MAAM,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,0BAA0B,EAAE;QACpD,IAAI,EAAE,IAAI;QACV,2DAA2D;QAC3D,QAAQ,EAAE,IAAI;QACd,aAAa,EAAE,SAAS,CAAC,aAAa,KAAK,OAAO,IAAI,SAAS;KAChE,CAAC;IAEF,+FAA+F;IAC/F,MAAM,YAAY,GAAG,GAAG,EAAE;QACxB,IAAI,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC,aAAa,EAAE,CAAC;YAC/C,SAAS,CAAC,0BAA0B,EAAE,CAAC;QACzC,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,YAAY,CAAC;QAC/B,SAAS,EAAE,IAAI;QACf,OAAO;QACP,eAAe,EAAE,SAAS,CAAC,2BAA2B;QACtD,iBAAiB,EAAE,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,MAAM;QAC5C,iBAAiB,EAAE,SAAS,CAAC,iBAAiB;KAC/C,CAAC,CAAC;IAEH,OAAO;QACL,OAAO;QACP,SAAS;QACT,aAAa;QACb,aAAa;QACb,YAAY;QACZ,cAAc;QACd,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;KAC/D,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ListElementProps } from '../internal/components/listbox/interfaces';\nimport { SelectionModel } from '../internal/components/listbox/selection/interfaces';\nimport { useListbox, UseListboxProps } from '../internal/components/listbox/use-listbox';\nimport { useTypeAhead } from '../internal/components/listbox/use-type-ahead';\nimport { DropdownOption } from '../internal/components/option/interfaces';\n\ninterface UseOptionListProps\n extends Pick<UseListboxProps, 'getParent' | 'selectedAriaLabel' | 'renderHighlightedAriaLive'> {\n /** Flattened options in list order. */\n options: ReadonlyArray<DropdownOption>;\n selection: SelectionModel;\n /** Called with the interactive option the user chose. */\n onSelect: (option: DropdownOption) => void;\n}\n\n/**\n * The list state of OptionList: the shared `useListbox` with OptionList's settings, plus the parts of a list that is\n * always visible. The list is a tab stop; keyboard, mouse and aria-activedescendant come from `useListbox`.\n * This hook adds focus and blur, the mouse-leave reset and type-ahead.\n */\nexport function useOptionList({\n options,\n selection,\n onSelect,\n getParent,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n}: UseOptionListProps) {\n const {\n listRef,\n getListProps,\n scrollToIndex,\n highlightType,\n announcement,\n getOptionProps,\n highlightedOption,\n highlight,\n selectedOptions,\n } = useListbox({\n options,\n selectedOptions: selection.selectedOptions,\n selection,\n interactiveGroups: selection.interactiveGroups,\n onSelect,\n // When the list has focus, Space always chooses.\n spaceSelects: 'always',\n getParent,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n });\n\n // Focus entry, like opening Select or Multiselect with the keyboard: highlight the first selected option (in\n // selection order) and scroll it into view, or the first option when nothing in the list is selected.\n // A highlight that is already there, such as a hover highlight, is kept, so a click selects the hovered option.\n const onFocus = () => {\n if (highlightedOption) {\n return;\n }\n const firstSelected = selectedOptions.find(option => options.includes(option));\n if (firstSelected) {\n highlight.highlightOptionWithKeyboard(firstSelected);\n } else {\n highlight.goHomeWithKeyboard();\n }\n };\n\n const listProps: ListElementProps = {\n ...getListProps({ withKeyboard: true }),\n onFocus,\n // Like closing Select or Multiselect, leaving the list clears the highlight.\n onBlur: () => highlight.resetHighlightWithKeyboard(),\n open: true,\n // The list element is a tab stop without dropdown corners.\n embedded: true,\n isMultiSelect: selection.selectionType === 'multi' || undefined,\n };\n\n // Attached to the root, not the list, so leaving the whole component clears a hover highlight.\n const onMouseLeave = () => {\n if (listRef.current !== document.activeElement) {\n highlight.resetHighlightWithKeyboard();\n }\n };\n\n const onTypeAhead = useTypeAhead({\n isEnabled: true,\n options,\n highlightOption: highlight.highlightOptionWithKeyboard,\n highlightedOption: highlightedOption?.option,\n interactiveGroups: selection.interactiveGroups,\n });\n\n return {\n listRef,\n listProps,\n scrollToIndex,\n highlightType,\n announcement,\n getOptionProps,\n getRootProps: () => ({ onKeyDown: onTypeAhead, onMouseLeave }),\n };\n}\n"]}
@@ -91,6 +91,7 @@
91
91
  "./modal": "./modal/index.js",
92
92
  "./multiselect": "./multiselect/index.js",
93
93
  "./navigable-group": "./navigable-group/index.js",
94
+ "./option-list": "./option-list/index.js",
94
95
  "./pagination": "./pagination/index.js",
95
96
  "./panel-layout": "./panel-layout/index.js",
96
97
  "./pie-chart": "./pie-chart/index.js",
@@ -251,6 +252,8 @@
251
252
  "./test-utils/selectors/multiselect": "./test-utils/selectors/multiselect/index.js",
252
253
  "./test-utils/dom/navigable-group": "./test-utils/dom/navigable-group/index.js",
253
254
  "./test-utils/selectors/navigable-group": "./test-utils/selectors/navigable-group/index.js",
255
+ "./test-utils/dom/option-list": "./test-utils/dom/option-list/index.js",
256
+ "./test-utils/selectors/option-list": "./test-utils/selectors/option-list/index.js",
254
257
  "./test-utils/dom/pagination": "./test-utils/dom/pagination/index.js",
255
258
  "./test-utils/selectors/pagination": "./test-utils/selectors/pagination/index.js",
256
259
  "./test-utils/dom/panel-layout": "./test-utils/dom/panel-layout/index.js",
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/select/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAO3D,OAAO,EAAE,eAAe,IAAI,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAc5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAElF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAW3C,MAAM,WAAW,mBAAoB,SAAQ,YAAY,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE,0BAA0B;IAC3G,kBAAkB,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IACvC,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAGD,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,QAAA,MAAM,cAAc,6FAoTnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/select/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAOhD,OAAO,EAAE,eAAe,IAAI,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAe5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAElF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAS3C,MAAM,WAAW,mBAAoB,SAAQ,YAAY,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE,0BAA0B;IAC3G,kBAAkB,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IACvC,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAGD,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,QAAA,MAAM,cAAc,6FA0SnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,6 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import React, { useEffect, useRef, useState } from 'react';
3
+ import React, { useRef, useState } from 'react';
4
4
  import clsx from 'clsx';
5
5
  import { useMergeRefs, useResizeObserver, useUniqueId, warnOnce } from '@cloudscape-design/component-toolkit/internal';
6
6
  import Dropdown from '../dropdown/internal';
@@ -9,8 +9,9 @@ import { getBaseProps } from '../internal/base-component';
9
9
  import { getBreakpointValue } from '../internal/breakpoints';
10
10
  import DropdownFooter from '../internal/components/dropdown-footer';
11
11
  import { useDropdownStatus } from '../internal/components/dropdown-status';
12
+ import PlainList from '../internal/components/listbox/parts/plain-list';
12
13
  import { singleSelection } from '../internal/components/listbox/selection/single-selection';
13
- import { useAnnouncement } from '../internal/components/listbox/use-announcement';
14
+ import { useTypeAhead } from '../internal/components/listbox/use-type-ahead';
14
15
  import { checkOptionValueField } from '../internal/components/listbox/utils/check-option-value-field';
15
16
  import { prepareOptions } from '../internal/components/option/utils/prepare-options.js';
16
17
  import { ResetGroupedControlContext, useGroupedControlContext } from '../internal/context/control-group-context';
@@ -22,11 +23,9 @@ import { useLoadItems } from '../internal/hooks/use-load-items';
22
23
  import { getDropdownMinWidth } from '../internal/utils/get-dropdown-min-width';
23
24
  import { joinStrings } from '../internal/utils/strings/join-strings.js';
24
25
  import Filter from './parts/filter';
25
- import PlainList from './parts/plain-list';
26
26
  import Trigger from './parts/trigger';
27
27
  import VirtualList from './parts/virtual-list';
28
28
  import { composeDropdownContent } from './utils/dropdown-customization';
29
- import { useNativeSearch } from './utils/use-native-search';
30
29
  import { useSelect } from './utils/use-select';
31
30
  import styles from './styles.css.js';
32
31
  const InternalSelect = React.forwardRef(({ options, filteringType = 'none', filteringPlaceholder, filteringAriaLabel, filteringClearAriaLabel, filteringResultsText, inlineLabelText, ariaRequired, placeholder, disabled, readOnly, ariaLabel, statusType = 'finished', empty, loadingText, finishedText, errorText, noMatch, triggerVariant = 'label', renderHighlightedAriaLive, selectedOption, onBlur, onFocus, onLoadItems, onChange, virtualScroll, expandToViewport, autoFocus, __inFilteringToken, __internalRootRef, renderOption, renderDropdownHeader, renderDropdownFooter, dropdownRole, dropdownAriaDescribedby, styleClassNames, ...restProps }, externalRef) => {
@@ -68,9 +67,8 @@ const InternalSelect = React.forwardRef(({ options, filteringType = 'none', filt
68
67
  useResizeObserver(() => triggerRef.current, entry => setTriggerWidth(entry.borderBoxWidth));
69
68
  const selfControlId = useUniqueId('trigger');
70
69
  const controlId = (_a = formFieldContext.controlId) !== null && _a !== void 0 ? _a : selfControlId;
71
- const scrollToIndex = useRef(null);
72
70
  const selectedOptions = selectedOption ? [selectedOption] : [];
73
- const { isOpen, highlightType, highlightedOption, highlightedIndex, getTriggerProps, getDropdownProps, getFilterProps, getMenuProps, getOptionProps, highlightOption, selectOption, announceSelected, focusActiveRef, closeDropdown, } = useSelect({
71
+ const { isOpen, highlightType, highlightedOption, getTriggerProps, getDropdownProps, getFilterProps, getMenuProps, getOptionProps, highlightOption, selectOption, announcement, scrollToIndex, focusActiveRef, closeDropdown, } = useSelect({
74
72
  selectedOptions,
75
73
  selection: singleSelection(selectedOptions),
76
74
  updateSelectedOption: option => fireNonCancelableEvent(onChange, { selectedOption: option }),
@@ -83,8 +81,11 @@ const InternalSelect = React.forwardRef(({ options, filteringType = 'none', filt
83
81
  setFilteringValue,
84
82
  statusType,
85
83
  dropdownRole,
84
+ getParent: option => { var _a; return (_a = parentMap.get(option)) === null || _a === void 0 ? void 0 : _a.option; },
85
+ selectedAriaLabel,
86
+ renderHighlightedAriaLive,
86
87
  });
87
- const handleNativeSearch = useNativeSearch({
88
+ const handleNativeSearch = useTypeAhead({
88
89
  isEnabled: filteringType === 'none' && !readOnly,
89
90
  options: filteredOptions,
90
91
  highlightOption: !isOpen ? selectOption : highlightOption,
@@ -92,10 +93,6 @@ const InternalSelect = React.forwardRef(({ options, filteringType = 'none', filt
92
93
  });
93
94
  const selectAriaLabelId = useUniqueId('select-arialabel-');
94
95
  const footerId = useUniqueId('footer');
95
- useEffect(() => {
96
- var _a;
97
- (_a = scrollToIndex.current) === null || _a === void 0 ? void 0 : _a.call(scrollToIndex, highlightedIndex);
98
- }, [highlightedIndex]);
99
96
  const dropdownContentProps = { filterText: filteringValue, closeDropdown };
100
97
  const customDropdownHeader = renderDropdownHeader === null || renderDropdownHeader === void 0 ? void 0 : renderDropdownHeader(dropdownContentProps);
101
98
  const customDropdownFooter = renderDropdownFooter === null || renderDropdownFooter === void 0 ? void 0 : renderDropdownFooter(dropdownContentProps);
@@ -139,13 +136,6 @@ const InternalSelect = React.forwardRef(({ options, filteringType = 'none', filt
139
136
  ariaDescribedby: joinStrings(dropdownStatus.content ? footerId : undefined, dropdownAriaDescribedby),
140
137
  ariaRequired,
141
138
  };
142
- const announcement = useAnnouncement({
143
- announceSelected,
144
- highlightedOption,
145
- getParent: option => { var _a; return (_a = parentMap.get(option)) === null || _a === void 0 ? void 0 : _a.option; },
146
- selectedAriaLabel,
147
- renderHighlightedAriaLive,
148
- });
149
139
  const ListComponent = virtualScroll ? VirtualList : PlainList;
150
140
  const handleMouseDown = (event) => {
151
141
  const target = event.target;
@@ -164,7 +154,7 @@ const InternalSelect = React.forwardRef(({ options, filteringType = 'none', filt
164
154
  ? joinStrings(dropdownStatus.content ? footerId : undefined, dropdownAriaDescribedby)
165
155
  : undefined, open: isOpen, stretchTriggerHeight: !!__inFilteringToken, minWidth: getDropdownMinWidth({ expandToViewport: effectiveExpandToViewport, triggerWidth }), maxWidth: getBreakpointValue('xxs'), trigger: trigger, header: dropdownHeader, onMouseDown: handleMouseDown, footer: dropdownFooter, expandToViewport: effectiveExpandToViewport,
166
156
  // Forces dropdown position recalculation when new options are loaded
167
- contentKey: hasOptions.current.toString(), content: React.createElement(ListComponent, { listBottom: !dropdownStatus.isSticky ? (React.createElement(DropdownFooter, { content: isOpen ? dropdownStatus.content : null, id: footerId })) : null, renderOption: renderOption, menuProps: menuProps, getOptionProps: getOptionProps, filteredOptions: filteredOptions, filteringValue: filteringValue, ref: scrollToIndex, hasDropdownStatus: dropdownStatus.content !== null, screenReaderContent: announcement, highlightType: highlightType }) }),
157
+ contentKey: hasOptions.current.toString(), content: React.createElement(ListComponent, { listBottom: !dropdownStatus.isSticky ? (React.createElement(DropdownFooter, { content: isOpen ? dropdownStatus.content : null, id: footerId })) : null, renderOption: renderOption, listProps: menuProps, getOptionProps: getOptionProps, filteredOptions: filteredOptions, filteringValue: filteringValue, ref: scrollToIndex, hasDropdownStatus: dropdownStatus.content !== null, screenReaderContent: announcement, highlightType: highlightType }) }),
168
158
  React.createElement("div", { hidden: true, id: selectAriaLabelId }, ariaLabel || inlineLabelText))));
169
159
  });
170
160
  export default InternalSelect;
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/select/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEvH,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,cAAc,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,2DAA2D,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,+DAA+D,CAAC;AACtG,OAAO,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAC;AACxF,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACjH,OAAO,EAAE,mBAAmB,EAAE,M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AAC,CAAC,kBAAkB,EAC1C,QAAQ,EAAE,mBAAmB,CAAC,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,YAAY,EAAE,CAAC,EAC5F,QAAQ,EAAE,kBAAkB,CAAC,KAAK,CAAC,EACnC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,cAAc,EACtB,WAAW,EAAE,eAAe,EAC5B,MAAM,EAAE,cAAc,EACtB,gBAAgB,EAAE,yBAAyB;gBAC3C,qEAAqE;gBACrE,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,EACzC,OAAO,EACL,oBAAC,aAAa,IACZ,UAAU,EACR,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CACzB,oBAAC,cAAc,IAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,GAAI,CAClF,CAAC,CAAC,CAAC,IAAI,EAEV,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAC9B,GAAG,EAAE,aAAa,EAClB,iBAAiB,EAAE,cAAc,CAAC,OAAO,KAAK,IAAI,EAClD,mBAAmB,EAAE,YAAY,EACjC,aAAa,EAAE,aAAa,GAC5B,GAEJ;YACF,6BAAK,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,iBAAiB,IACrC,SAAS,IAAI,eAAe,CACzB,CACF,CACqB,CAC9B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useResizeObserver, useUniqueId, warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport Dropdown from '../dropdown/internal';\nimport { useInternalI18n } from '../i18n/context.js';\nimport { StyleClassNames as InputStyleClassNames } from '../input/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { getBreakpointValue } from '../internal/breakpoints';\nimport DropdownFooter from '../internal/components/dropdown-footer';\nimport { useDropdownStatus } from '../internal/components/dropdown-status';\nimport { singleSelection } from '../internal/components/listbox/selection/single-selection';\nimport { useAnnouncement } from '../internal/components/listbox/use-announcement';\nimport { checkOptionValueField } from '../internal/components/listbox/utils/check-option-value-field';\nimport { prepareOptions } from '../internal/components/option/utils/prepare-options.js';\nimport { ResetGroupedControlContext, useGroupedControlContext } from '../internal/context/control-group-context';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { warnOnUnsupportedGroupedControlProps } from '../internal/grouped-control/dev-warnings';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useLoadItems } from '../internal/hooks/use-load-items';\nimport { SomeRequired } from '../internal/types';\nimport { getDropdownMinWidth } from '../internal/utils/get-dropdown-min-width';\nimport { joinStrings } from '../internal/utils/strings/join-strings.js';\nimport { OptionGroup } from '../types/option';\nimport { SelectProps } from './interfaces';\nimport Filter from './parts/filter';\nimport PlainList, { SelectListProps } from './parts/plain-list';\nimport Trigger from './parts/trigger';\nimport VirtualList from './parts/virtual-list';\nimport { composeDropdownContent } from './utils/dropdown-customization';\nimport { useNativeSearch } from './utils/use-native-search';\nimport { useSelect } from './utils/use-select';\n\nimport styles from './styles.css.js';\n\nexport interface InternalSelectProps extends SomeRequired<SelectProps, 'options'>, InternalBaseComponentProps {\n __inFilteringToken?: 'root' | 'nested';\n styleClassNames?: StyleClassNames;\n}\n\n// Style API v2\nexport interface StyleClassNames {\n trigger?: string;\n inlineLabel?: string;\n filter?: InputStyleClassNames;\n dropdown?: string;\n}\n\nconst InternalSelect = React.forwardRef(\n (\n {\n options,\n filteringType = 'none',\n filteringPlaceholder,\n filteringAriaLabel,\n filteringClearAriaLabel,\n filteringResultsText,\n inlineLabelText,\n ariaRequired,\n placeholder,\n disabled,\n readOnly,\n ariaLabel,\n statusType = 'finished',\n empty,\n loadingText,\n finishedText,\n errorText,\n noMatch,\n triggerVariant = 'label',\n renderHighlightedAriaLive,\n selectedOption,\n onBlur,\n onFocus,\n onLoadItems,\n onChange,\n virtualScroll,\n expandToViewport,\n autoFocus,\n __inFilteringToken,\n __internalRootRef,\n renderOption,\n renderDropdownHeader,\n renderDropdownFooter,\n dropdownRole,\n dropdownAriaDescribedby,\n styleClassNames,\n ...restProps\n }: InternalSelectProps,\n externalRef: React.Ref<SelectProps.Ref>\n ) => {\n const baseProps = getBaseProps(restProps);\n const formFieldContext = useFormFieldContext(restProps);\n const groupedControlProps = useGroupedControlContext();\n\n warnOnUnsupportedGroupedControlProps({\n isGrouped: !!groupedControlProps.position,\n componentName: 'Select',\n invalid: formFieldContext.invalid,\n warning: formFieldContext.warning,\n readOnly,\n expandToViewport,\n });\n\n // When grouped, the dropdown is portaled regardless of the public\n // `expandToViewport` prop so it escapes the control slot's stacking context\n // and paints over the group's inline label (which the focus ring stays under).\n const effectiveExpandToViewport = expandToViewport || !!groupedControlProps.position;\n\n const i18n = useInternalI18n('select');\n const errorIconAriaLabel = i18n('errorIconAriaLabel', restProps.errorIconAriaLabel);\n const selectedAriaLabel = i18n('selectedAriaLabel', restProps.selectedAriaLabel);\n const recoveryText = i18n('recoveryText', restProps.recoveryText);\n\n if (restProps.recoveryText && !onLoadItems) {\n warnOnce('Select', '`onLoadItems` must be provided for `recoveryText` to be displayed.');\n }\n\n const { handleLoadMore, handleRecoveryClick, fireLoadItems } = useLoadItems({\n onLoadItems,\n isEmpty: options.length === 0,\n statusType,\n });\n\n checkControlled('Select', 'selectedOption', selectedOption, 'onChange', onChange);\n\n checkOptionValueField('Select', 'options', options);\n\n const [filteringValue, setFilteringValue] = useState('');\n\n const { filteredOptions, parentMap, totalCount, matchesCount } = prepareOptions(\n options,\n filteringType,\n filteringValue\n );\n\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const [triggerWidth, setTriggerWidth] = useState<number | null>(null);\n useResizeObserver(\n () => triggerRef.current,\n entry => setTriggerWidth(entry.borderBoxWidth)\n );\n\n const selfControlId = useUniqueId('trigger');\n const controlId = formFieldContext.controlId ?? selfControlId;\n\n const scrollToIndex = useRef<SelectListProps.SelectListRef>(null);\n const selectedOptions = selectedOption ? [selectedOption] : [];\n const {\n isOpen,\n highlightType,\n highlightedOption,\n highlightedIndex,\n getTriggerProps,\n getDropdownProps,\n getFilterProps,\n getMenuProps,\n getOptionProps,\n highlightOption,\n selectOption,\n announceSelected,\n focusActiveRef,\n closeDropdown,\n } = useSelect({\n selectedOptions,\n selection: singleSelection(selectedOptions),\n updateSelectedOption: option => fireNonCancelableEvent(onChange, { selectedOption: option }),\n options: filteredOptions,\n filteringType,\n onBlur,\n onFocus,\n externalRef,\n fireLoadItems,\n setFilteringValue,\n statusType,\n dropdownRole,\n });\n\n const handleNativeSearch = useNativeSearch({\n isEnabled: filteringType === 'none' && !readOnly,\n options: filteredOptions,\n highlightOption: !isOpen ? selectOption : highlightOption,\n highlightedOption: !isOpen ? selectedOption : highlightedOption?.option,\n });\n\n const selectAriaLabelId = useUniqueId('select-arialabel-');\n const footerId = useUniqueId('footer');\n\n useEffect(() => {\n scrollToIndex.current?.(highlightedIndex);\n }, [highlightedIndex]);\n\n const dropdownContentProps: SelectProps.DropdownContentProps = { filterText: filteringValue, closeDropdown };\n const customDropdownHeader = renderDropdownHeader?.(dropdownContentProps);\n const customDropdownFooter = renderDropdownFooter?.(dropdownContentProps);\n\n const filter = (\n <Filter\n clearAriaLabel={filteringClearAriaLabel}\n filteringType={filteringType}\n placeholder={filteringPlaceholder}\n ariaLabel={filteringAriaLabel}\n ariaRequired={ariaRequired}\n value={filteringValue}\n styleClassNames={styleClassNames?.filter}\n {...getFilterProps()}\n />\n );\n\n const trigger = (\n <Trigger\n renderOption={renderOption}\n ref={triggerRef}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n triggerVariant={triggerVariant}\n triggerProps={getTriggerProps(disabled, autoFocus)}\n selectedOption={selectedOption}\n isOpen={isOpen}\n inFilteringToken={__inFilteringToken}\n groupedControlProps={groupedControlProps}\n inlineLabelText={inlineLabelText}\n styleClassNames={{ trigger: styleClassNames?.trigger, inlineLabel: styleClassNames?.inlineLabel }}\n {...formFieldContext}\n controlId={controlId}\n ariaLabelledby={joinStrings(formFieldContext.ariaLabelledby, selectAriaLabelId)}\n />\n );\n\n const isEmpty = !options || options.length === 0;\n const isNoMatch = filteredOptions && filteredOptions.length === 0;\n const isFiltered =\n filteringType !== 'none' && filteringValue.length > 0 && filteredOptions && filteredOptions.length > 0;\n const filteredText = isFiltered ? filteringResultsText?.(matchesCount, totalCount) : undefined;\n\n const dropdownStatus = useDropdownStatus({\n statusType,\n empty,\n loadingText,\n finishedText,\n errorText,\n recoveryText,\n isEmpty,\n isNoMatch,\n noMatch,\n filteringResultsText: filteredText,\n errorIconAriaLabel,\n onRecoveryClick: () => {\n handleRecoveryClick();\n focusActiveRef();\n },\n hasRecoveryCallback: !!onLoadItems,\n });\n\n const statusFooter = dropdownStatus.isSticky ? (\n <DropdownFooter content={isOpen ? dropdownStatus.content : null} id={footerId} />\n ) : null;\n const { header: dropdownHeader, footer: dropdownFooter } = composeDropdownContent({\n filter,\n customDropdownHeader,\n customDropdownFooter,\n statusFooter,\n dropdownHeaderClass: styles['dropdown-header'],\n dropdownFooterClass: styles['dropdown-footer'],\n });\n\n const menuProps = {\n ...getMenuProps(),\n onLoadMore: handleLoadMore,\n ariaLabelledby: joinStrings(selectAriaLabelId, controlId),\n ariaDescribedby: joinStrings(dropdownStatus.content ? footerId : undefined, dropdownAriaDescribedby),\n ariaRequired,\n };\n\n const announcement = useAnnouncement({\n announceSelected,\n highlightedOption,\n getParent: option => parentMap.get(option)?.option as undefined | OptionGroup,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n });\n\n const ListComponent = virtualScroll ? VirtualList : PlainList;\n\n const handleMouseDown = (event: React.MouseEvent) => {\n const target = event.target as HTMLElement;\n\n if (target !== document.activeElement) {\n // prevent currently focused element from losing it\n event.preventDefault();\n }\n };\n\n const mergedRef = useMergeRefs(rootRef, __internalRootRef);\n\n const dropdownProps = getDropdownProps();\n\n const hasOptions = useRef(options.length > 0);\n hasOptions.current = hasOptions.current || options.length > 0;\n\n return (\n <ResetGroupedControlContext>\n <div\n {...baseProps}\n ref={mergedRef}\n className={clsx(styles.root, baseProps.className)}\n onKeyDown={handleNativeSearch}\n >\n <Dropdown\n {...dropdownProps}\n styleClassNames={{ container: styleClassNames?.dropdown }}\n ariaLabelledby={dropdownProps.ariaRole ? joinStrings(selectAriaLabelId, controlId) : undefined}\n ariaDescribedby={\n dropdownProps.ariaRole\n ? joinStrings(dropdownStatus.content ? footerId : undefined, dropdownAriaDescribedby)\n : undefined\n }\n open={isOpen}\n stretchTriggerHeight={!!__inFilteringToken}\n minWidth={getDropdownMinWidth({ expandToViewport: effectiveExpandToViewport, triggerWidth })}\n maxWidth={getBreakpointValue('xxs')} // AWSUI-19898\n trigger={trigger}\n header={dropdownHeader}\n onMouseDown={handleMouseDown}\n footer={dropdownFooter}\n expandToViewport={effectiveExpandToViewport}\n // Forces dropdown position recalculation when new options are loaded\n contentKey={hasOptions.current.toString()}\n content={\n <ListComponent\n listBottom={\n !dropdownStatus.isSticky ? (\n <DropdownFooter content={isOpen ? dropdownStatus.content : null} id={footerId} />\n ) : null\n }\n renderOption={renderOption}\n menuProps={menuProps}\n getOptionProps={getOptionProps}\n filteredOptions={filteredOptions}\n filteringValue={filteringValue}\n ref={scrollToIndex}\n hasDropdownStatus={dropdownStatus.content !== null}\n screenReaderContent={announcement}\n highlightType={highlightType}\n />\n }\n />\n <div hidden={true} id={selectAriaLabelId}>\n {ariaLabel || inlineLabelText}\n </div>\n </div>\n </ResetGroupedControlContext>\n );\n }\n);\n\nexport default InternalSelect;\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/select/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEvH,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,cAAc,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,SAAS,MAAM,iDAAiD,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,2DAA2D,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+DAA+D,CAAC;AACtG,OAAO,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAC;AACxF,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACjH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,oCAAoC,EAAE,MAAM,0CAA0C,CAAC;AAChG,OAAO,eAAe,MAAM,oCAAoC,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAA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E,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAC9B,GAAG,EAAE,aAAa,EAClB,iBAAiB,EAAE,cAAc,CAAC,OAAO,KAAK,IAAI,EAClD,mBAAmB,EAAE,YAAY,EACjC,aAAa,EAAE,aAAa,GAC5B,GAEJ;YACF,6BAAK,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,iBAAiB,IACrC,SAAS,IAAI,eAAe,CACzB,CACF,CACqB,CAC9B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useResizeObserver, useUniqueId, warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport Dropdown from '../dropdown/internal';\nimport { useInternalI18n } from '../i18n/context.js';\nimport { StyleClassNames as InputStyleClassNames } from '../input/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { getBreakpointValue } from '../internal/breakpoints';\nimport DropdownFooter from '../internal/components/dropdown-footer';\nimport { useDropdownStatus } from '../internal/components/dropdown-status';\nimport PlainList from '../internal/components/listbox/parts/plain-list';\nimport { singleSelection } from '../internal/components/listbox/selection/single-selection';\nimport { useTypeAhead } from '../internal/components/listbox/use-type-ahead';\nimport { checkOptionValueField } from '../internal/components/listbox/utils/check-option-value-field';\nimport { prepareOptions } from '../internal/components/option/utils/prepare-options.js';\nimport { ResetGroupedControlContext, useGroupedControlContext } from '../internal/context/control-group-context';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { warnOnUnsupportedGroupedControlProps } from '../internal/grouped-control/dev-warnings';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useLoadItems } from '../internal/hooks/use-load-items';\nimport { SomeRequired } from '../internal/types';\nimport { getDropdownMinWidth } from '../internal/utils/get-dropdown-min-width';\nimport { joinStrings } from '../internal/utils/strings/join-strings.js';\nimport { OptionGroup } from '../types/option';\nimport { SelectProps } from './interfaces';\nimport Filter from './parts/filter';\nimport Trigger from './parts/trigger';\nimport VirtualList from './parts/virtual-list';\nimport { composeDropdownContent } from './utils/dropdown-customization';\nimport { useSelect } from './utils/use-select';\n\nimport styles from './styles.css.js';\n\nexport interface InternalSelectProps extends SomeRequired<SelectProps, 'options'>, InternalBaseComponentProps {\n __inFilteringToken?: 'root' | 'nested';\n styleClassNames?: StyleClassNames;\n}\n\n// Style API v2\nexport interface StyleClassNames {\n trigger?: string;\n inlineLabel?: string;\n filter?: InputStyleClassNames;\n dropdown?: string;\n}\n\nconst InternalSelect = React.forwardRef(\n (\n {\n options,\n filteringType = 'none',\n filteringPlaceholder,\n filteringAriaLabel,\n filteringClearAriaLabel,\n filteringResultsText,\n inlineLabelText,\n ariaRequired,\n placeholder,\n disabled,\n readOnly,\n ariaLabel,\n statusType = 'finished',\n empty,\n loadingText,\n finishedText,\n errorText,\n noMatch,\n triggerVariant = 'label',\n renderHighlightedAriaLive,\n selectedOption,\n onBlur,\n onFocus,\n onLoadItems,\n onChange,\n virtualScroll,\n expandToViewport,\n autoFocus,\n __inFilteringToken,\n __internalRootRef,\n renderOption,\n renderDropdownHeader,\n renderDropdownFooter,\n dropdownRole,\n dropdownAriaDescribedby,\n styleClassNames,\n ...restProps\n }: InternalSelectProps,\n externalRef: React.Ref<SelectProps.Ref>\n ) => {\n const baseProps = getBaseProps(restProps);\n const formFieldContext = useFormFieldContext(restProps);\n const groupedControlProps = useGroupedControlContext();\n\n warnOnUnsupportedGroupedControlProps({\n isGrouped: !!groupedControlProps.position,\n componentName: 'Select',\n invalid: formFieldContext.invalid,\n warning: formFieldContext.warning,\n readOnly,\n expandToViewport,\n });\n\n // When grouped, the dropdown is portaled regardless of the public\n // `expandToViewport` prop so it escapes the control slot's stacking context\n // and paints over the group's inline label (which the focus ring stays under).\n const effectiveExpandToViewport = expandToViewport || !!groupedControlProps.position;\n\n const i18n = useInternalI18n('select');\n const errorIconAriaLabel = i18n('errorIconAriaLabel', restProps.errorIconAriaLabel);\n const selectedAriaLabel = i18n('selectedAriaLabel', restProps.selectedAriaLabel);\n const recoveryText = i18n('recoveryText', restProps.recoveryText);\n\n if (restProps.recoveryText && !onLoadItems) {\n warnOnce('Select', '`onLoadItems` must be provided for `recoveryText` to be displayed.');\n }\n\n const { handleLoadMore, handleRecoveryClick, fireLoadItems } = useLoadItems({\n onLoadItems,\n isEmpty: options.length === 0,\n statusType,\n });\n\n checkControlled('Select', 'selectedOption', selectedOption, 'onChange', onChange);\n\n checkOptionValueField('Select', 'options', options);\n\n const [filteringValue, setFilteringValue] = useState('');\n\n const { filteredOptions, parentMap, totalCount, matchesCount } = prepareOptions(\n options,\n filteringType,\n filteringValue\n );\n\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const [triggerWidth, setTriggerWidth] = useState<number | null>(null);\n useResizeObserver(\n () => triggerRef.current,\n entry => setTriggerWidth(entry.borderBoxWidth)\n );\n\n const selfControlId = useUniqueId('trigger');\n const controlId = formFieldContext.controlId ?? selfControlId;\n\n const selectedOptions = selectedOption ? [selectedOption] : [];\n const {\n isOpen,\n highlightType,\n highlightedOption,\n getTriggerProps,\n getDropdownProps,\n getFilterProps,\n getMenuProps,\n getOptionProps,\n highlightOption,\n selectOption,\n announcement,\n scrollToIndex,\n focusActiveRef,\n closeDropdown,\n } = useSelect({\n selectedOptions,\n selection: singleSelection(selectedOptions),\n updateSelectedOption: option => fireNonCancelableEvent(onChange, { selectedOption: option }),\n options: filteredOptions,\n filteringType,\n onBlur,\n onFocus,\n externalRef,\n fireLoadItems,\n setFilteringValue,\n statusType,\n dropdownRole,\n getParent: option => parentMap.get(option)?.option as undefined | OptionGroup,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n });\n\n const handleNativeSearch = useTypeAhead({\n isEnabled: filteringType === 'none' && !readOnly,\n options: filteredOptions,\n highlightOption: !isOpen ? selectOption : highlightOption,\n highlightedOption: !isOpen ? selectedOption : highlightedOption?.option,\n });\n\n const selectAriaLabelId = useUniqueId('select-arialabel-');\n const footerId = useUniqueId('footer');\n\n const dropdownContentProps: SelectProps.DropdownContentProps = { filterText: filteringValue, closeDropdown };\n const customDropdownHeader = renderDropdownHeader?.(dropdownContentProps);\n const customDropdownFooter = renderDropdownFooter?.(dropdownContentProps);\n\n const filter = (\n <Filter\n clearAriaLabel={filteringClearAriaLabel}\n filteringType={filteringType}\n placeholder={filteringPlaceholder}\n ariaLabel={filteringAriaLabel}\n ariaRequired={ariaRequired}\n value={filteringValue}\n styleClassNames={styleClassNames?.filter}\n {...getFilterProps()}\n />\n );\n\n const trigger = (\n <Trigger\n renderOption={renderOption}\n ref={triggerRef}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n triggerVariant={triggerVariant}\n triggerProps={getTriggerProps(disabled, autoFocus)}\n selectedOption={selectedOption}\n isOpen={isOpen}\n inFilteringToken={__inFilteringToken}\n groupedControlProps={groupedControlProps}\n inlineLabelText={inlineLabelText}\n styleClassNames={{ trigger: styleClassNames?.trigger, inlineLabel: styleClassNames?.inlineLabel }}\n {...formFieldContext}\n controlId={controlId}\n ariaLabelledby={joinStrings(formFieldContext.ariaLabelledby, selectAriaLabelId)}\n />\n );\n\n const isEmpty = !options || options.length === 0;\n const isNoMatch = filteredOptions && filteredOptions.length === 0;\n const isFiltered =\n filteringType !== 'none' && filteringValue.length > 0 && filteredOptions && filteredOptions.length > 0;\n const filteredText = isFiltered ? filteringResultsText?.(matchesCount, totalCount) : undefined;\n\n const dropdownStatus = useDropdownStatus({\n statusType,\n empty,\n loadingText,\n finishedText,\n errorText,\n recoveryText,\n isEmpty,\n isNoMatch,\n noMatch,\n filteringResultsText: filteredText,\n errorIconAriaLabel,\n onRecoveryClick: () => {\n handleRecoveryClick();\n focusActiveRef();\n },\n hasRecoveryCallback: !!onLoadItems,\n });\n\n const statusFooter = dropdownStatus.isSticky ? (\n <DropdownFooter content={isOpen ? dropdownStatus.content : null} id={footerId} />\n ) : null;\n const { header: dropdownHeader, footer: dropdownFooter } = composeDropdownContent({\n filter,\n customDropdownHeader,\n customDropdownFooter,\n statusFooter,\n dropdownHeaderClass: styles['dropdown-header'],\n dropdownFooterClass: styles['dropdown-footer'],\n });\n\n const menuProps = {\n ...getMenuProps(),\n onLoadMore: handleLoadMore,\n ariaLabelledby: joinStrings(selectAriaLabelId, controlId),\n ariaDescribedby: joinStrings(dropdownStatus.content ? footerId : undefined, dropdownAriaDescribedby),\n ariaRequired,\n };\n\n const ListComponent = virtualScroll ? VirtualList : PlainList;\n\n const handleMouseDown = (event: React.MouseEvent) => {\n const target = event.target as HTMLElement;\n\n if (target !== document.activeElement) {\n // prevent currently focused element from losing it\n event.preventDefault();\n }\n };\n\n const mergedRef = useMergeRefs(rootRef, __internalRootRef);\n\n const dropdownProps = getDropdownProps();\n\n const hasOptions = useRef(options.length > 0);\n hasOptions.current = hasOptions.current || options.length > 0;\n\n return (\n <ResetGroupedControlContext>\n <div\n {...baseProps}\n ref={mergedRef}\n className={clsx(styles.root, baseProps.className)}\n onKeyDown={handleNativeSearch}\n >\n <Dropdown\n {...dropdownProps}\n styleClassNames={{ container: styleClassNames?.dropdown }}\n ariaLabelledby={dropdownProps.ariaRole ? joinStrings(selectAriaLabelId, controlId) : undefined}\n ariaDescribedby={\n dropdownProps.ariaRole\n ? joinStrings(dropdownStatus.content ? footerId : undefined, dropdownAriaDescribedby)\n : undefined\n }\n open={isOpen}\n stretchTriggerHeight={!!__inFilteringToken}\n minWidth={getDropdownMinWidth({ expandToViewport: effectiveExpandToViewport, triggerWidth })}\n maxWidth={getBreakpointValue('xxs')} // AWSUI-19898\n trigger={trigger}\n header={dropdownHeader}\n onMouseDown={handleMouseDown}\n footer={dropdownFooter}\n expandToViewport={effectiveExpandToViewport}\n // Forces dropdown position recalculation when new options are loaded\n contentKey={hasOptions.current.toString()}\n content={\n <ListComponent\n listBottom={\n !dropdownStatus.isSticky ? (\n <DropdownFooter content={isOpen ? dropdownStatus.content : null} id={footerId} />\n ) : null\n }\n renderOption={renderOption}\n listProps={menuProps}\n getOptionProps={getOptionProps}\n filteredOptions={filteredOptions}\n filteringValue={filteringValue}\n ref={scrollToIndex}\n hasDropdownStatus={dropdownStatus.content !== null}\n screenReaderContent={announcement}\n highlightType={highlightType}\n />\n }\n />\n <div hidden={true} id={selectAriaLabelId}>\n {ariaLabel || inlineLabelText}\n </div>\n </div>\n </ResetGroupedControlContext>\n );\n }\n);\n\nexport default InternalSelect;\n"]}