@cloudscape-design/components 3.0.1412 → 3.0.1414

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 (383) hide show
  1. package/alert/styles.css.js +27 -27
  2. package/alert/styles.scoped.css +49 -49
  3. package/alert/styles.selectors.js +27 -27
  4. package/annotation-context/annotation/styles.css.js +13 -13
  5. package/annotation-context/annotation/styles.scoped.css +21 -21
  6. package/annotation-context/annotation/styles.selectors.js +13 -13
  7. package/app-layout/notifications/styles.css.js +3 -3
  8. package/app-layout/notifications/styles.scoped.css +7 -7
  9. package/app-layout/notifications/styles.selectors.js +3 -3
  10. package/app-layout/visual-refresh/mobile-toolbar.d.ts.map +1 -1
  11. package/app-layout/visual-refresh/mobile-toolbar.js +1 -1
  12. package/app-layout/visual-refresh/mobile-toolbar.js.map +1 -1
  13. package/app-layout/visual-refresh/styles.css.js +86 -86
  14. package/app-layout/visual-refresh/styles.scoped.css +258 -258
  15. package/app-layout/visual-refresh/styles.selectors.js +86 -86
  16. package/app-layout/visual-refresh-toolbar/drawer/styles.css.js +32 -32
  17. package/app-layout/visual-refresh-toolbar/drawer/styles.scoped.css +89 -89
  18. package/app-layout/visual-refresh-toolbar/drawer/styles.selectors.js +32 -32
  19. package/app-layout/visual-refresh-toolbar/navigation/styles.css.js +6 -6
  20. package/app-layout/visual-refresh-toolbar/navigation/styles.scoped.css +13 -13
  21. package/app-layout/visual-refresh-toolbar/navigation/styles.selectors.js +6 -6
  22. package/app-layout/visual-refresh-toolbar/skeleton/styles.css.js +30 -30
  23. package/app-layout/visual-refresh-toolbar/skeleton/styles.scoped.css +68 -68
  24. package/app-layout/visual-refresh-toolbar/skeleton/styles.selectors.js +30 -30
  25. package/attribute-editor/styles.css.js +15 -15
  26. package/attribute-editor/styles.scoped.css +28 -28
  27. package/attribute-editor/styles.selectors.js +15 -15
  28. package/breadcrumb-group/item/styles.css.js +7 -7
  29. package/breadcrumb-group/item/styles.scoped.css +28 -28
  30. package/breadcrumb-group/item/styles.selectors.js +7 -7
  31. package/button/styles.css.js +24 -24
  32. package/button/styles.scoped.css +328 -328
  33. package/button/styles.selectors.js +24 -24
  34. package/button-dropdown/item-element/styles.css.js +21 -21
  35. package/button-dropdown/item-element/styles.scoped.css +37 -37
  36. package/button-dropdown/item-element/styles.selectors.js +21 -21
  37. package/cards/styles.css.js +39 -39
  38. package/cards/styles.scoped.css +41 -41
  39. package/cards/styles.selectors.js +39 -39
  40. package/checkbox/internal.d.ts +1 -1
  41. package/checkbox/internal.d.ts.map +1 -1
  42. package/checkbox/internal.js.map +1 -1
  43. package/checkbox/styles.css.js +3 -3
  44. package/checkbox/styles.scoped.css +10 -10
  45. package/checkbox/styles.selectors.js +3 -3
  46. package/container/styles.css.js +33 -33
  47. package/container/styles.scoped.css +106 -106
  48. package/container/styles.selectors.js +33 -33
  49. package/content-layout/interfaces.d.ts +4 -2
  50. package/content-layout/interfaces.d.ts.map +1 -1
  51. package/content-layout/interfaces.js.map +1 -1
  52. package/content-layout/styles.css.js +14 -14
  53. package/content-layout/styles.scoped.css +27 -27
  54. package/content-layout/styles.selectors.js +14 -14
  55. package/control-group/styles.css.js +27 -27
  56. package/control-group/styles.scoped.css +28 -28
  57. package/control-group/styles.selectors.js +27 -27
  58. package/dropdown/styles.css.js +20 -20
  59. package/dropdown/styles.scoped.css +45 -45
  60. package/dropdown/styles.selectors.js +20 -20
  61. package/expandable-section/expandable-section-header.js +1 -1
  62. package/expandable-section/expandable-section-header.js.map +1 -1
  63. package/file-token-group/styles.css.js +23 -23
  64. package/file-token-group/styles.scoped.css +36 -36
  65. package/file-token-group/styles.selectors.js +23 -23
  66. package/flashbar/styles.css.js +50 -50
  67. package/flashbar/styles.scoped.css +182 -182
  68. package/flashbar/styles.selectors.js +50 -50
  69. package/header/interfaces.d.ts +4 -0
  70. package/header/interfaces.d.ts.map +1 -1
  71. package/header/interfaces.js.map +1 -1
  72. package/header/internal.d.ts +1 -6
  73. package/header/internal.d.ts.map +1 -1
  74. package/header/internal.js +2 -2
  75. package/header/internal.js.map +1 -1
  76. package/header/styles.css.js +36 -36
  77. package/header/styles.scoped.css +55 -55
  78. package/header/styles.selectors.js +36 -36
  79. package/help-panel/styles.css.js +6 -6
  80. package/help-panel/styles.scoped.css +72 -72
  81. package/help-panel/styles.selectors.js +6 -6
  82. package/i18n/messages/all.all.js +1 -1
  83. package/i18n/messages/all.all.json +1 -1
  84. package/i18n/messages/all.de.js +1 -1
  85. package/i18n/messages/all.de.json +1 -1
  86. package/i18n/messages/all.en-GB.js +1 -1
  87. package/i18n/messages/all.en-GB.json +1 -1
  88. package/i18n/messages/all.en.js +1 -1
  89. package/i18n/messages/all.en.json +1 -1
  90. package/i18n/messages/all.es.js +1 -1
  91. package/i18n/messages/all.es.json +1 -1
  92. package/i18n/messages/all.fr.js +1 -1
  93. package/i18n/messages/all.fr.json +1 -1
  94. package/i18n/messages/all.id.js +1 -1
  95. package/i18n/messages/all.id.json +1 -1
  96. package/i18n/messages/all.it.js +1 -1
  97. package/i18n/messages/all.it.json +1 -1
  98. package/i18n/messages/all.ja.js +1 -1
  99. package/i18n/messages/all.ja.json +1 -1
  100. package/i18n/messages/all.ko.js +1 -1
  101. package/i18n/messages/all.ko.json +1 -1
  102. package/i18n/messages/all.pt-BR.js +1 -1
  103. package/i18n/messages/all.pt-BR.json +1 -1
  104. package/i18n/messages/all.tr.js +1 -1
  105. package/i18n/messages/all.tr.json +1 -1
  106. package/i18n/messages/all.zh-CN.js +1 -1
  107. package/i18n/messages/all.zh-CN.json +1 -1
  108. package/i18n/messages/all.zh-TW.js +1 -1
  109. package/i18n/messages/all.zh-TW.json +1 -1
  110. package/i18n/messages-types.d.ts +3 -0
  111. package/i18n/messages-types.d.ts.map +1 -1
  112. package/i18n/messages-types.js.map +1 -1
  113. package/index.d.ts +1 -0
  114. package/index.d.ts.map +1 -1
  115. package/index.js +1 -0
  116. package/index.js.map +1 -1
  117. package/input/styles.css.js +45 -45
  118. package/input/styles.scoped.css +145 -145
  119. package/input/styles.selectors.js +45 -45
  120. package/internal/base-component/styles.scoped.css +1 -1
  121. package/internal/components/drag-handle-wrapper/styles.css.js +30 -30
  122. package/internal/components/drag-handle-wrapper/styles.scoped.css +58 -58
  123. package/internal/components/drag-handle-wrapper/styles.selectors.js +30 -30
  124. package/internal/components/focus-lock/utils.d.ts +2 -0
  125. package/internal/components/focus-lock/utils.d.ts.map +1 -1
  126. package/internal/components/focus-lock/utils.js +5 -1
  127. package/internal/components/focus-lock/utils.js.map +1 -1
  128. package/internal/components/listbox/parts/item.d.ts +2 -0
  129. package/internal/components/listbox/parts/item.d.ts.map +1 -1
  130. package/internal/components/listbox/parts/item.js +3 -3
  131. package/internal/components/listbox/parts/item.js.map +1 -1
  132. package/internal/components/listbox/parts/plain-list.d.ts +6 -0
  133. package/internal/components/listbox/parts/plain-list.d.ts.map +1 -1
  134. package/internal/components/listbox/parts/plain-list.js +5 -4
  135. package/internal/components/listbox/parts/plain-list.js.map +1 -1
  136. package/internal/components/listbox/parts/scroll-to-index.d.ts +11 -0
  137. package/internal/components/listbox/parts/scroll-to-index.d.ts.map +1 -1
  138. package/internal/components/listbox/parts/scroll-to-index.js +16 -0
  139. package/internal/components/listbox/parts/scroll-to-index.js.map +1 -1
  140. package/internal/components/listbox/use-listbox.d.ts +2 -2
  141. package/internal/components/listbox/use-listbox.d.ts.map +1 -1
  142. package/internal/components/listbox/use-listbox.js.map +1 -1
  143. package/internal/components/option/styles.css.js +19 -19
  144. package/internal/components/option/styles.scoped.css +36 -36
  145. package/internal/components/option/styles.selectors.js +19 -19
  146. package/internal/components/options-list/index.d.ts +4 -1
  147. package/internal/components/options-list/index.d.ts.map +1 -1
  148. package/internal/components/options-list/index.js +1 -1
  149. package/internal/components/options-list/index.js.map +1 -1
  150. package/internal/components/options-list/utils/use-keyboard.d.ts +2 -1
  151. package/internal/components/options-list/utils/use-keyboard.d.ts.map +1 -1
  152. package/internal/components/options-list/utils/use-keyboard.js +4 -2
  153. package/internal/components/options-list/utils/use-keyboard.js.map +1 -1
  154. package/internal/components/radio-button/styles.css.js +7 -7
  155. package/internal/components/radio-button/styles.scoped.css +17 -17
  156. package/internal/components/radio-button/styles.selectors.js +7 -7
  157. package/internal/components/selectable-item/index.d.ts +1 -0
  158. package/internal/components/selectable-item/index.d.ts.map +1 -1
  159. package/internal/components/selectable-item/index.js +2 -1
  160. package/internal/components/selectable-item/index.js.map +1 -1
  161. package/internal/components/selectable-item/interfaces.d.ts +1 -0
  162. package/internal/components/selectable-item/interfaces.d.ts.map +1 -1
  163. package/internal/components/selectable-item/interfaces.js.map +1 -1
  164. package/internal/components/selectable-item/styles.css.js +23 -22
  165. package/internal/components/selectable-item/styles.scoped.css +60 -57
  166. package/internal/components/selectable-item/styles.selectors.js +23 -22
  167. package/internal/components/sticky-header/use-untabbable-descendants.d.ts +2 -0
  168. package/internal/components/sticky-header/use-untabbable-descendants.d.ts.map +1 -0
  169. package/internal/components/sticky-header/use-untabbable-descendants.js +16 -0
  170. package/internal/components/sticky-header/use-untabbable-descendants.js.map +1 -0
  171. package/internal/components/token-list/styles.css.js +10 -10
  172. package/internal/components/token-list/styles.scoped.css +25 -25
  173. package/internal/components/token-list/styles.selectors.js +10 -10
  174. package/internal/environment.js +2 -2
  175. package/internal/environment.json +2 -2
  176. package/internal/generated/custom-css-properties/index.d.ts +1 -0
  177. package/internal/generated/custom-css-properties/index.d.ts.map +1 -1
  178. package/internal/generated/custom-css-properties/index.js +178 -177
  179. package/internal/generated/custom-css-properties/index.js.map +1 -1
  180. package/internal/manifest.json +1 -1
  181. package/item-card/styles.css.js +14 -14
  182. package/item-card/styles.scoped.css +73 -73
  183. package/item-card/styles.selectors.js +14 -14
  184. package/link/styles.css.js +21 -21
  185. package/link/styles.scoped.css +104 -104
  186. package/link/styles.selectors.js +21 -21
  187. package/manifest.json +2 -2
  188. package/modal/styles.css.js +32 -32
  189. package/modal/styles.scoped.css +49 -49
  190. package/modal/styles.selectors.js +32 -32
  191. package/multiselect/use-multiselect.d.ts +1 -1
  192. package/option-list/index.d.ts +5 -0
  193. package/option-list/index.d.ts.map +1 -0
  194. package/option-list/index.js +21 -0
  195. package/option-list/index.js.map +1 -0
  196. package/option-list/interfaces.d.ts +131 -0
  197. package/option-list/interfaces.d.ts.map +1 -0
  198. package/option-list/interfaces.js +2 -0
  199. package/option-list/interfaces.js.map +1 -0
  200. package/option-list/internal.d.ts +5 -0
  201. package/option-list/internal.d.ts.map +1 -0
  202. package/option-list/internal.js +138 -0
  203. package/option-list/internal.js.map +1 -0
  204. package/option-list/styles.css.js +6 -0
  205. package/option-list/styles.scoped.css +40 -0
  206. package/option-list/styles.selectors.js +7 -0
  207. package/option-list/test-classes/styles.css.js +8 -0
  208. package/option-list/test-classes/styles.scoped.css +9 -0
  209. package/option-list/test-classes/styles.selectors.js +9 -0
  210. package/option-list/use-option-list.d.ts +36 -0
  211. package/option-list/use-option-list.d.ts.map +1 -0
  212. package/option-list/use-option-list.js +69 -0
  213. package/option-list/use-option-list.js.map +1 -0
  214. package/package.json +4 -1
  215. package/popover/styles.css.js +58 -58
  216. package/popover/styles.scoped.css +94 -94
  217. package/popover/styles.selectors.js +58 -58
  218. package/progress-bar/styles.css.js +20 -20
  219. package/progress-bar/styles.scoped.css +59 -59
  220. package/progress-bar/styles.selectors.js +20 -20
  221. package/prompt-input/components/token-mode.d.ts +4 -0
  222. package/prompt-input/components/token-mode.d.ts.map +1 -1
  223. package/prompt-input/components/token-mode.js +2 -2
  224. package/prompt-input/components/token-mode.js.map +1 -1
  225. package/prompt-input/internal.d.ts +10 -1
  226. package/prompt-input/internal.d.ts.map +1 -1
  227. package/prompt-input/internal.js +35 -26
  228. package/prompt-input/internal.js.map +1 -1
  229. package/prompt-input/styles.css.js +26 -26
  230. package/prompt-input/styles.scoped.css +136 -107
  231. package/prompt-input/styles.selectors.js +26 -26
  232. package/prompt-input/tokens/use-token-mode.d.ts +4 -0
  233. package/prompt-input/tokens/use-token-mode.d.ts.map +1 -1
  234. package/prompt-input/tokens/use-token-mode.js +3 -3
  235. package/prompt-input/tokens/use-token-mode.js.map +1 -1
  236. package/property-filter/interfaces.d.ts +2 -0
  237. package/property-filter/interfaces.d.ts.map +1 -1
  238. package/property-filter/interfaces.js.map +1 -1
  239. package/property-filter/token-editor-inputs.d.ts.map +1 -1
  240. package/property-filter/token-editor-inputs.js +3 -3
  241. package/property-filter/token-editor-inputs.js.map +1 -1
  242. package/segmented-control/styles.css.js +31 -31
  243. package/segmented-control/styles.scoped.css +81 -81
  244. package/segmented-control/styles.selectors.js +31 -31
  245. package/select/parts/styles.css.js +22 -22
  246. package/select/parts/styles.scoped.css +25 -25
  247. package/select/parts/styles.selectors.js +22 -22
  248. package/side-navigation/styles.css.js +65 -65
  249. package/side-navigation/styles.scoped.css +114 -114
  250. package/side-navigation/styles.selectors.js +65 -65
  251. package/slider/styles.css.js +26 -26
  252. package/slider/styles.scoped.css +167 -167
  253. package/slider/styles.selectors.js +26 -26
  254. package/spinner/styles.css.js +14 -14
  255. package/spinner/styles.scoped.css +40 -40
  256. package/spinner/styles.selectors.js +14 -14
  257. package/styling/prompt-input.scss +76 -0
  258. package/styling/table.scss +102 -0
  259. package/styling/tabs.scss +128 -0
  260. package/table/body-cell/styles.css.js +47 -47
  261. package/table/body-cell/styles.scoped.css +426 -418
  262. package/table/body-cell/styles.selectors.js +47 -47
  263. package/table/body-cell/td-element.d.ts +1 -0
  264. package/table/body-cell/td-element.d.ts.map +1 -1
  265. package/table/body-cell/td-element.js +2 -2
  266. package/table/body-cell/td-element.js.map +1 -1
  267. package/table/clear-sort.d.ts +3 -1
  268. package/table/clear-sort.d.ts.map +1 -1
  269. package/table/clear-sort.js +2 -2
  270. package/table/clear-sort.js.map +1 -1
  271. package/table/header-cell/common-props.d.ts +2 -0
  272. package/table/header-cell/common-props.d.ts.map +1 -1
  273. package/table/header-cell/common-props.js.map +1 -1
  274. package/table/header-cell/group-header-cell.d.ts +2 -1
  275. package/table/header-cell/group-header-cell.d.ts.map +1 -1
  276. package/table/header-cell/group-header-cell.js +3 -2
  277. package/table/header-cell/group-header-cell.js.map +1 -1
  278. package/table/header-cell/index.d.ts +2 -1
  279. package/table/header-cell/index.d.ts.map +1 -1
  280. package/table/header-cell/index.js +12 -5
  281. package/table/header-cell/index.js.map +1 -1
  282. package/table/header-cell/sort-menu.d.ts +4 -1
  283. package/table/header-cell/sort-menu.d.ts.map +1 -1
  284. package/table/header-cell/sort-menu.js +2 -2
  285. package/table/header-cell/sort-menu.js.map +1 -1
  286. package/table/header-cell/styles.css.js +39 -39
  287. package/table/header-cell/styles.scoped.css +140 -125
  288. package/table/header-cell/styles.selectors.js +39 -39
  289. package/table/header-cell/th-element.d.ts +2 -0
  290. package/table/header-cell/th-element.d.ts.map +1 -1
  291. package/table/header-cell/th-element.js +2 -2
  292. package/table/header-cell/th-element.js.map +1 -1
  293. package/table/internal.d.ts.map +1 -1
  294. package/table/internal.js +20 -7
  295. package/table/internal.js.map +1 -1
  296. package/table/resizer/index.d.ts.map +1 -1
  297. package/table/resizer/index.js +1 -1
  298. package/table/resizer/index.js.map +1 -1
  299. package/table/resizer/styles.css.js +17 -17
  300. package/table/resizer/styles.scoped.css +39 -35
  301. package/table/resizer/styles.selectors.js +17 -17
  302. package/table/selection/selection-cell.d.ts +5 -0
  303. package/table/selection/selection-cell.d.ts.map +1 -1
  304. package/table/selection/selection-cell.js +6 -5
  305. package/table/selection/selection-cell.js.map +1 -1
  306. package/table/selection/selection-control.d.ts +3 -0
  307. package/table/selection/selection-control.d.ts.map +1 -1
  308. package/table/selection/selection-control.js +2 -2
  309. package/table/selection/selection-control.js.map +1 -1
  310. package/table/style-api.d.ts +41 -0
  311. package/table/style-api.d.ts.map +1 -0
  312. package/table/style-api.js +4 -0
  313. package/table/style-api.js.map +1 -0
  314. package/table/styles.css.js +37 -37
  315. package/table/styles.scoped.css +119 -46
  316. package/table/styles.selectors.js +37 -37
  317. package/table/thead.d.ts +2 -0
  318. package/table/thead.d.ts.map +1 -1
  319. package/table/thead.js +2 -1
  320. package/table/thead.js.map +1 -1
  321. package/table-root/index.js +1 -1
  322. package/table-root/index.js.map +1 -1
  323. package/table-root/interfaces.d.ts +15 -1
  324. package/table-root/interfaces.d.ts.map +1 -1
  325. package/table-root/interfaces.js.map +1 -1
  326. package/table-root/internal.d.ts +2 -0
  327. package/table-root/internal.d.ts.map +1 -1
  328. package/table-root/internal.js +23 -11
  329. package/table-root/internal.js.map +1 -1
  330. package/table-root/sticky-header-slot.d.ts +24 -0
  331. package/table-root/sticky-header-slot.d.ts.map +1 -0
  332. package/table-root/sticky-header-slot.js +13 -0
  333. package/table-root/sticky-header-slot.js.map +1 -0
  334. package/table-root/styles.css.js +10 -5
  335. package/table-root/styles.scoped.css +52 -7
  336. package/table-root/styles.selectors.js +10 -5
  337. package/table-root/use-sticky-header.d.ts +33 -0
  338. package/table-root/use-sticky-header.d.ts.map +1 -0
  339. package/table-root/use-sticky-header.js +141 -0
  340. package/table-root/use-sticky-header.js.map +1 -0
  341. package/tabs/index.d.ts.map +1 -1
  342. package/tabs/index.js +3 -2
  343. package/tabs/index.js.map +1 -1
  344. package/tabs/styles.css.js +30 -30
  345. package/tabs/styles.scoped.css +137 -81
  346. package/tabs/styles.selectors.js +30 -30
  347. package/tabs/tab-header-bar.d.ts +12 -1
  348. package/tabs/tab-header-bar.d.ts.map +1 -1
  349. package/tabs/tab-header-bar.js +14 -7
  350. package/tabs/tab-header-bar.js.map +1 -1
  351. package/tag-editor/styles.css.js +3 -3
  352. package/tag-editor/styles.scoped.css +13 -13
  353. package/tag-editor/styles.selectors.js +3 -3
  354. package/test-utils/dom/header/index.d.ts +1 -0
  355. package/test-utils/dom/header/index.js +3 -0
  356. package/test-utils/dom/header/index.js.map +1 -1
  357. package/test-utils/dom/index.d.ts +28 -0
  358. package/test-utils/dom/index.js +21 -2
  359. package/test-utils/dom/index.js.map +1 -1
  360. package/test-utils/dom/option-list/index.d.ts +69 -0
  361. package/test-utils/dom/option-list/index.js +132 -0
  362. package/test-utils/dom/option-list/index.js.map +1 -0
  363. package/test-utils/selectors/header/index.d.ts +1 -0
  364. package/test-utils/selectors/header/index.js +3 -0
  365. package/test-utils/selectors/header/index.js.map +1 -1
  366. package/test-utils/selectors/index.d.ts +18 -0
  367. package/test-utils/selectors/index.js +16 -2
  368. package/test-utils/selectors/index.js.map +1 -1
  369. package/test-utils/selectors/option-list/index.d.ts +66 -0
  370. package/test-utils/selectors/option-list/index.js +108 -0
  371. package/test-utils/selectors/option-list/index.js.map +1 -0
  372. package/text-content/styles.css.js +1 -1
  373. package/text-content/styles.scoped.css +66 -66
  374. package/text-content/styles.selectors.js +1 -1
  375. package/textarea/styles.css.js +9 -9
  376. package/textarea/styles.scoped.css +51 -51
  377. package/textarea/styles.selectors.js +9 -9
  378. package/toggle/styles.css.js +10 -10
  379. package/toggle/styles.scoped.css +25 -25
  380. package/toggle/styles.selectors.js +10 -10
  381. package/token/styles.css.js +14 -14
  382. package/token/styles.scoped.css +57 -57
  383. package/token/styles.selectors.js +14 -14
@@ -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
@@ -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ClC,GAAG,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC;gBAChC,oFAAoF;gBACpF,cAAc,EAAE,KAAK,KAAK,CAAC;gBAC3B,SAAS,EAAE,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM;gBACtF,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK;aAClC,CAAC,GACF,CACE,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,kBAAkB,CAAC","sourcesContent":["// 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_1ozs6_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_1ozs6_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-diae7s, 14px);
33
+ line-height: var(--line-height-body-m-18p63n, 20px);
34
+ color: var(--color-text-body-default-9im48h, #0f141a);
35
+ font-weight: var(--font-weight-normal-jditlz, 400);
36
+ font-family: var(--font-family-base-khplu5, "Open 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_1ozs6_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,36 @@
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({
18
+ options,
19
+ selection,
20
+ onSelect,
21
+ getParent,
22
+ selectedAriaLabel,
23
+ renderHighlightedAriaLive
24
+ }: UseOptionListProps): {
25
+ listRef: import("react").RefObject<HTMLDivElement>;
26
+ listProps: ListElementProps;
27
+ scrollToIndex: import("react").RefObject<import("../internal/components/listbox/interfaces").ScrollToIndexRef>;
28
+ highlightType: import("../internal/components/options-list/utils/use-highlight-option").HighlightType;
29
+ announcement: string;
30
+ getOptionProps: (option: DropdownOption, index: number) => ReturnType<typeof import("../internal/components/listbox/utils/option-props").getListboxOptionProps>;
31
+ getRootProps: () => {
32
+ onKeyDown: (event: React.KeyboardEvent) => void;
33
+ onMouseLeave: () => void;
34
+ };
35
+ };
36
+ export {};
@@ -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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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"]}
package/package.json CHANGED
@@ -92,6 +92,7 @@
92
92
  "./modal": "./modal/index.js",
93
93
  "./multiselect": "./multiselect/index.js",
94
94
  "./navigable-group": "./navigable-group/index.js",
95
+ "./option-list": "./option-list/index.js",
95
96
  "./pagination": "./pagination/index.js",
96
97
  "./panel-layout": "./panel-layout/index.js",
97
98
  "./pie-chart": "./pie-chart/index.js",
@@ -252,6 +253,8 @@
252
253
  "./test-utils/selectors/multiselect": "./test-utils/selectors/multiselect/index.js",
253
254
  "./test-utils/dom/navigable-group": "./test-utils/dom/navigable-group/index.js",
254
255
  "./test-utils/selectors/navigable-group": "./test-utils/selectors/navigable-group/index.js",
256
+ "./test-utils/dom/option-list": "./test-utils/dom/option-list/index.js",
257
+ "./test-utils/selectors/option-list": "./test-utils/selectors/option-list/index.js",
255
258
  "./test-utils/dom/pagination": "./test-utils/dom/pagination/index.js",
256
259
  "./test-utils/selectors/pagination": "./test-utils/selectors/pagination/index.js",
257
260
  "./test-utils/dom/panel-layout": "./test-utils/dom/panel-layout/index.js",
@@ -380,7 +383,7 @@
380
383
  "./internal/base-theme/styles.css.js",
381
384
  "./internal/base-component/styles.css.js"
382
385
  ],
383
- "version": "3.0.1412",
386
+ "version": "3.0.1414",
384
387
  "repository": {
385
388
  "type": "git",
386
389
  "url": "https://github.com/cloudscape-design/components.git"
@@ -1,63 +1,63 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "arrow": "awsui_arrow_xjuzf_85n7e_13",
5
- "arrow-outer": "awsui_arrow-outer_xjuzf_85n7e_20",
6
- "arrow-inner": "awsui_arrow-inner_xjuzf_85n7e_20",
7
- "arrow-position-right-top": "awsui_arrow-position-right-top_xjuzf_85n7e_63",
8
- "arrow-position-right-bottom": "awsui_arrow-position-right-bottom_xjuzf_85n7e_63",
9
- "arrow-position-left-top": "awsui_arrow-position-left-top_xjuzf_85n7e_66",
10
- "arrow-position-left-bottom": "awsui_arrow-position-left-bottom_xjuzf_85n7e_66",
11
- "arrow-position-top-center": "awsui_arrow-position-top-center_xjuzf_85n7e_69",
12
- "arrow-position-top-right": "awsui_arrow-position-top-right_xjuzf_85n7e_69",
13
- "arrow-position-top-left": "awsui_arrow-position-top-left_xjuzf_85n7e_69",
14
- "arrow-position-top-responsive": "awsui_arrow-position-top-responsive_xjuzf_85n7e_69",
15
- "arrow-position-bottom-center": "awsui_arrow-position-bottom-center_xjuzf_85n7e_72",
16
- "arrow-position-bottom-right": "awsui_arrow-position-bottom-right_xjuzf_85n7e_72",
17
- "arrow-position-bottom-left": "awsui_arrow-position-bottom-left_xjuzf_85n7e_72",
18
- "arrow-position-bottom-responsive": "awsui_arrow-position-bottom-responsive_xjuzf_85n7e_72",
19
- "arrow-variant-info": "awsui_arrow-variant-info_xjuzf_85n7e_76",
20
- "body": "awsui_body_xjuzf_85n7e_87",
21
- "body-overflow-visible": "awsui_body-overflow-visible_xjuzf_85n7e_123",
22
- "body-variant-chart": "awsui_body-variant-chart_xjuzf_85n7e_126",
23
- "has-dismiss": "awsui_has-dismiss_xjuzf_85n7e_131",
24
- "dismiss": "awsui_dismiss_xjuzf_85n7e_136",
25
- "dismiss-control": "awsui_dismiss-control_xjuzf_85n7e_144",
26
- "header-row": "awsui_header-row_xjuzf_85n7e_148",
27
- "header": "awsui_header_xjuzf_85n7e_148",
28
- "content": "awsui_content_xjuzf_85n7e_177",
29
- "content-overflow-visible": "awsui_content-overflow-visible_xjuzf_85n7e_186",
30
- "container": "awsui_container_xjuzf_85n7e_194",
31
- "container-arrow-position-bottom-left": "awsui_container-arrow-position-bottom-left_xjuzf_85n7e_205",
32
- "container-arrow-position-bottom-center": "awsui_container-arrow-position-bottom-center_xjuzf_85n7e_205",
33
- "container-arrow-position-bottom-right": "awsui_container-arrow-position-bottom-right_xjuzf_85n7e_205",
34
- "container-arrow-position-top-left": "awsui_container-arrow-position-top-left_xjuzf_85n7e_210",
35
- "container-arrow-position-top-center": "awsui_container-arrow-position-top-center_xjuzf_85n7e_210",
36
- "container-arrow-position-top-right": "awsui_container-arrow-position-top-right_xjuzf_85n7e_210",
37
- "container-arrow-position-right-top": "awsui_container-arrow-position-right-top_xjuzf_85n7e_215",
38
- "container-arrow-position-right-bottom": "awsui_container-arrow-position-right-bottom_xjuzf_85n7e_215",
39
- "container-arrow-position-left-top": "awsui_container-arrow-position-left-top_xjuzf_85n7e_220",
40
- "container-arrow-position-left-bottom": "awsui_container-arrow-position-left-bottom_xjuzf_85n7e_220",
41
- "container-body": "awsui_container-body_xjuzf_85n7e_226",
42
- "container-body-variant-annotation": "awsui_container-body-variant-annotation_xjuzf_85n7e_266",
43
- "container-body-size-small": "awsui_container-body-size-small_xjuzf_85n7e_271",
44
- "fixed-width": "awsui_fixed-width_xjuzf_85n7e_274",
45
- "container-body-size-medium": "awsui_container-body-size-medium_xjuzf_85n7e_278",
46
- "container-body-size-large": "awsui_container-body-size-large_xjuzf_85n7e_285",
47
- "container-arrow": "awsui_container-arrow_xjuzf_85n7e_205",
48
- "container-arrow-position-top-responsive": "awsui_container-arrow-position-top-responsive_xjuzf_85n7e_335",
49
- "awsui-motion-fade-in": "awsui_awsui-motion-fade-in_xjuzf_85n7e_1",
50
- "refresh": "awsui_refresh_xjuzf_85n7e_389",
51
- "root": "awsui_root_xjuzf_85n7e_431",
52
- "no-wrap": "awsui_no-wrap_xjuzf_85n7e_463",
53
- "trigger-type-text-inline": "awsui_trigger-type-text-inline_xjuzf_85n7e_466",
54
- "overflow-ellipsis": "awsui_overflow-ellipsis_xjuzf_85n7e_466",
55
- "trigger-type-text": "awsui_trigger-type-text_xjuzf_85n7e_466",
56
- "root-filtering-token": "awsui_root-filtering-token_xjuzf_85n7e_488",
57
- "trigger": "awsui_trigger_xjuzf_85n7e_466",
58
- "in-inline-token": "awsui_in-inline-token_xjuzf_85n7e_530",
59
- "trigger-type-filtering-token": "awsui_trigger-type-filtering-token_xjuzf_85n7e_578",
60
- "popover-inline-content": "awsui_popover-inline-content_xjuzf_85n7e_582",
61
- "hover-area": "awsui_hover-area_xjuzf_85n7e_586"
4
+ "arrow": "awsui_arrow_xjuzf_uj4t0_13",
5
+ "arrow-outer": "awsui_arrow-outer_xjuzf_uj4t0_20",
6
+ "arrow-inner": "awsui_arrow-inner_xjuzf_uj4t0_20",
7
+ "arrow-position-right-top": "awsui_arrow-position-right-top_xjuzf_uj4t0_63",
8
+ "arrow-position-right-bottom": "awsui_arrow-position-right-bottom_xjuzf_uj4t0_63",
9
+ "arrow-position-left-top": "awsui_arrow-position-left-top_xjuzf_uj4t0_66",
10
+ "arrow-position-left-bottom": "awsui_arrow-position-left-bottom_xjuzf_uj4t0_66",
11
+ "arrow-position-top-center": "awsui_arrow-position-top-center_xjuzf_uj4t0_69",
12
+ "arrow-position-top-right": "awsui_arrow-position-top-right_xjuzf_uj4t0_69",
13
+ "arrow-position-top-left": "awsui_arrow-position-top-left_xjuzf_uj4t0_69",
14
+ "arrow-position-top-responsive": "awsui_arrow-position-top-responsive_xjuzf_uj4t0_69",
15
+ "arrow-position-bottom-center": "awsui_arrow-position-bottom-center_xjuzf_uj4t0_72",
16
+ "arrow-position-bottom-right": "awsui_arrow-position-bottom-right_xjuzf_uj4t0_72",
17
+ "arrow-position-bottom-left": "awsui_arrow-position-bottom-left_xjuzf_uj4t0_72",
18
+ "arrow-position-bottom-responsive": "awsui_arrow-position-bottom-responsive_xjuzf_uj4t0_72",
19
+ "arrow-variant-info": "awsui_arrow-variant-info_xjuzf_uj4t0_76",
20
+ "body": "awsui_body_xjuzf_uj4t0_87",
21
+ "body-overflow-visible": "awsui_body-overflow-visible_xjuzf_uj4t0_123",
22
+ "body-variant-chart": "awsui_body-variant-chart_xjuzf_uj4t0_126",
23
+ "has-dismiss": "awsui_has-dismiss_xjuzf_uj4t0_131",
24
+ "dismiss": "awsui_dismiss_xjuzf_uj4t0_136",
25
+ "dismiss-control": "awsui_dismiss-control_xjuzf_uj4t0_144",
26
+ "header-row": "awsui_header-row_xjuzf_uj4t0_148",
27
+ "header": "awsui_header_xjuzf_uj4t0_148",
28
+ "content": "awsui_content_xjuzf_uj4t0_177",
29
+ "content-overflow-visible": "awsui_content-overflow-visible_xjuzf_uj4t0_186",
30
+ "container": "awsui_container_xjuzf_uj4t0_194",
31
+ "container-arrow-position-bottom-left": "awsui_container-arrow-position-bottom-left_xjuzf_uj4t0_205",
32
+ "container-arrow-position-bottom-center": "awsui_container-arrow-position-bottom-center_xjuzf_uj4t0_205",
33
+ "container-arrow-position-bottom-right": "awsui_container-arrow-position-bottom-right_xjuzf_uj4t0_205",
34
+ "container-arrow-position-top-left": "awsui_container-arrow-position-top-left_xjuzf_uj4t0_210",
35
+ "container-arrow-position-top-center": "awsui_container-arrow-position-top-center_xjuzf_uj4t0_210",
36
+ "container-arrow-position-top-right": "awsui_container-arrow-position-top-right_xjuzf_uj4t0_210",
37
+ "container-arrow-position-right-top": "awsui_container-arrow-position-right-top_xjuzf_uj4t0_215",
38
+ "container-arrow-position-right-bottom": "awsui_container-arrow-position-right-bottom_xjuzf_uj4t0_215",
39
+ "container-arrow-position-left-top": "awsui_container-arrow-position-left-top_xjuzf_uj4t0_220",
40
+ "container-arrow-position-left-bottom": "awsui_container-arrow-position-left-bottom_xjuzf_uj4t0_220",
41
+ "container-body": "awsui_container-body_xjuzf_uj4t0_226",
42
+ "container-body-variant-annotation": "awsui_container-body-variant-annotation_xjuzf_uj4t0_266",
43
+ "container-body-size-small": "awsui_container-body-size-small_xjuzf_uj4t0_271",
44
+ "fixed-width": "awsui_fixed-width_xjuzf_uj4t0_274",
45
+ "container-body-size-medium": "awsui_container-body-size-medium_xjuzf_uj4t0_278",
46
+ "container-body-size-large": "awsui_container-body-size-large_xjuzf_uj4t0_285",
47
+ "container-arrow": "awsui_container-arrow_xjuzf_uj4t0_205",
48
+ "container-arrow-position-top-responsive": "awsui_container-arrow-position-top-responsive_xjuzf_uj4t0_335",
49
+ "awsui-motion-fade-in": "awsui_awsui-motion-fade-in_xjuzf_uj4t0_1",
50
+ "refresh": "awsui_refresh_xjuzf_uj4t0_389",
51
+ "root": "awsui_root_xjuzf_uj4t0_431",
52
+ "no-wrap": "awsui_no-wrap_xjuzf_uj4t0_463",
53
+ "trigger-type-text-inline": "awsui_trigger-type-text-inline_xjuzf_uj4t0_466",
54
+ "overflow-ellipsis": "awsui_overflow-ellipsis_xjuzf_uj4t0_466",
55
+ "trigger-type-text": "awsui_trigger-type-text_xjuzf_uj4t0_466",
56
+ "root-filtering-token": "awsui_root-filtering-token_xjuzf_uj4t0_488",
57
+ "trigger": "awsui_trigger_xjuzf_uj4t0_466",
58
+ "in-inline-token": "awsui_in-inline-token_xjuzf_uj4t0_530",
59
+ "trigger-type-filtering-token": "awsui_trigger-type-filtering-token_xjuzf_uj4t0_578",
60
+ "popover-inline-content": "awsui_popover-inline-content_xjuzf_uj4t0_582",
61
+ "hover-area": "awsui_hover-area_xjuzf_uj4t0_586"
62
62
  };
63
63