@primer/components 0.0.0-202111023618 → 0.0.0-2021111114654

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 (737) hide show
  1. package/CHANGELOG.md +946 -39
  2. package/README.md +16 -16
  3. package/codemods/__tests__/deprecateUtilityComponents.js +200 -0
  4. package/codemods/__tests__/removeSystemProps.js +225 -0
  5. package/codemods/deprecateUtilityComponents.js +111 -0
  6. package/codemods/lib/modifyProps.js +9 -7
  7. package/codemods/lib/prettify.js +1 -1
  8. package/codemods/lib/replaceImportSource.js +5 -5
  9. package/codemods/removeSystemProps.js +312 -0
  10. package/dist/browser.esm.js +1267 -853
  11. package/dist/browser.esm.js.map +1 -1
  12. package/dist/browser.umd.js +1304 -890
  13. package/dist/browser.umd.js.map +1 -1
  14. package/lib/ActionList/Divider.d.ts +9 -0
  15. package/lib/ActionList/Divider.js +40 -0
  16. package/lib/ActionList/Group.d.ts +28 -0
  17. package/lib/ActionList/Group.js +35 -0
  18. package/lib/ActionList/Header.d.ts +29 -0
  19. package/lib/ActionList/Header.js +51 -0
  20. package/lib/ActionList/Item.d.ts +98 -0
  21. package/lib/ActionList/Item.js +276 -0
  22. package/lib/ActionList/List.d.ts +88 -0
  23. package/lib/ActionList/List.js +199 -0
  24. package/lib/ActionList/index.d.ts +17 -0
  25. package/lib/ActionList/index.js +29 -0
  26. package/lib/ActionList2/Description.d.ts +12 -0
  27. package/lib/ActionList2/Description.js +57 -0
  28. package/lib/ActionList2/Divider.d.ts +6 -0
  29. package/lib/ActionList2/Divider.js +40 -0
  30. package/lib/ActionList2/Group.d.ts +37 -0
  31. package/lib/ActionList2/Group.js +106 -0
  32. package/lib/ActionList2/Item.d.ts +63 -0
  33. package/lib/ActionList2/Item.js +260 -0
  34. package/lib/ActionList2/LinkItem.d.ts +17 -0
  35. package/lib/ActionList2/LinkItem.js +57 -0
  36. package/lib/ActionList2/List.d.ts +26 -0
  37. package/lib/ActionList2/List.js +68 -0
  38. package/lib/ActionList2/MenuContext.d.ts +10 -0
  39. package/lib/ActionList2/MenuContext.js +15 -0
  40. package/lib/ActionList2/Selection.d.ts +5 -0
  41. package/lib/ActionList2/Selection.js +97 -0
  42. package/lib/ActionList2/Visuals.d.ts +9 -0
  43. package/lib/ActionList2/Visuals.js +90 -0
  44. package/lib/ActionList2/index.d.ts +35 -0
  45. package/lib/ActionList2/index.js +47 -0
  46. package/lib/ActionMenu.d.ts +40 -0
  47. package/lib/ActionMenu.js +103 -0
  48. package/lib/ActionMenu2.d.ts +310 -0
  49. package/lib/ActionMenu2.js +91 -0
  50. package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +62 -0
  51. package/lib/AnchoredOverlay/AnchoredOverlay.js +124 -0
  52. package/lib/AnchoredOverlay/index.d.ts +2 -0
  53. package/lib/AnchoredOverlay/index.js +13 -0
  54. package/lib/Autocomplete/Autocomplete.d.ts +305 -0
  55. package/lib/Autocomplete/Autocomplete.js +145 -0
  56. package/lib/Autocomplete/AutocompleteContext.d.ts +17 -0
  57. package/lib/Autocomplete/AutocompleteContext.js +11 -0
  58. package/lib/Autocomplete/AutocompleteInput.d.ts +293 -0
  59. package/lib/Autocomplete/AutocompleteInput.js +157 -0
  60. package/lib/Autocomplete/AutocompleteMenu.d.ts +72 -0
  61. package/lib/Autocomplete/AutocompleteMenu.js +224 -0
  62. package/lib/Autocomplete/AutocompleteOverlay.d.ts +20 -0
  63. package/lib/Autocomplete/AutocompleteOverlay.js +80 -0
  64. package/lib/Autocomplete/index.d.ts +2 -0
  65. package/lib/Autocomplete/index.js +15 -0
  66. package/lib/Avatar.d.ts +14 -0
  67. package/lib/Avatar.js +1 -12
  68. package/lib/AvatarPair.d.ts +8 -0
  69. package/lib/AvatarPair.js +9 -16
  70. package/lib/AvatarStack.d.ts +8 -0
  71. package/lib/AvatarStack.js +12 -23
  72. package/lib/BaseStyles.d.ts +14 -0
  73. package/lib/BaseStyles.js +25 -31
  74. package/lib/BorderBox.d.ts +7 -0
  75. package/lib/BorderBox.js +5 -16
  76. package/lib/Box.d.ts +6 -0
  77. package/lib/Box.js +2 -15
  78. package/lib/BranchName.d.ts +5 -0
  79. package/lib/BranchName.js +1 -14
  80. package/lib/Breadcrumbs.d.ts +41 -0
  81. package/lib/Breadcrumbs.js +82 -0
  82. package/lib/Button/Button.d.ts +284 -0
  83. package/lib/Button/Button.js +3 -15
  84. package/lib/Button/ButtonBase.d.ts +9 -0
  85. package/lib/Button/ButtonBase.js +2 -25
  86. package/lib/Button/ButtonClose.d.ts +279 -0
  87. package/lib/Button/ButtonClose.js +9 -26
  88. package/lib/Button/ButtonDanger.d.ts +284 -0
  89. package/lib/Button/ButtonDanger.js +2 -14
  90. package/lib/Button/ButtonGroup.d.ts +4 -0
  91. package/lib/Button/ButtonGroup.js +2 -8
  92. package/lib/Button/ButtonInvisible.d.ts +284 -0
  93. package/lib/Button/ButtonInvisible.js +3 -15
  94. package/lib/Button/ButtonOutline.d.ts +284 -0
  95. package/lib/Button/ButtonOutline.js +2 -14
  96. package/lib/Button/ButtonPrimary.d.ts +284 -0
  97. package/lib/Button/ButtonPrimary.js +2 -14
  98. package/lib/Button/ButtonStyles.d.ts +2 -0
  99. package/lib/Button/ButtonTableList.d.ts +5 -0
  100. package/lib/Button/ButtonTableList.js +1 -15
  101. package/lib/Button/index.d.ts +16 -0
  102. package/lib/Button/index.js +9 -59
  103. package/lib/Caret.d.ts +21 -0
  104. package/lib/Caret.js +14 -17
  105. package/lib/Checkbox.d.ts +29 -0
  106. package/lib/Checkbox.js +64 -0
  107. package/lib/CircleBadge.d.ts +24 -0
  108. package/lib/CircleBadge.js +2 -20
  109. package/lib/CircleOcticon.d.ts +392 -0
  110. package/lib/CircleOcticon.js +9 -18
  111. package/lib/CounterLabel.d.ts +7 -0
  112. package/lib/CounterLabel.js +3 -17
  113. package/lib/Details.d.ts +5 -0
  114. package/lib/Details.js +2 -12
  115. package/lib/Dialog/ConfirmationDialog.d.ts +44 -0
  116. package/lib/Dialog/ConfirmationDialog.js +191 -0
  117. package/lib/Dialog/Dialog.d.ts +163 -0
  118. package/lib/Dialog/Dialog.js +311 -0
  119. package/lib/Dialog.d.ts +406 -0
  120. package/lib/Dialog.js +34 -49
  121. package/lib/Dropdown.d.ts +1113 -0
  122. package/lib/Dropdown.js +45 -60
  123. package/lib/DropdownMenu/DropdownButton.d.ts +280 -0
  124. package/lib/DropdownMenu/DropdownButton.js +33 -0
  125. package/lib/DropdownMenu/DropdownMenu.d.ts +43 -0
  126. package/lib/DropdownMenu/DropdownMenu.js +94 -0
  127. package/lib/DropdownMenu/index.d.ts +4 -0
  128. package/lib/DropdownMenu/index.js +21 -0
  129. package/lib/DropdownStyles.d.ts +3 -0
  130. package/lib/DropdownStyles.js +6 -6
  131. package/lib/FilterList.d.ts +283 -0
  132. package/lib/FilterList.js +2 -30
  133. package/lib/FilteredActionList/FilteredActionList.d.ts +16 -0
  134. package/lib/FilteredActionList/FilteredActionList.js +137 -0
  135. package/lib/FilteredActionList/index.d.ts +2 -0
  136. package/lib/FilteredActionList/index.js +13 -0
  137. package/lib/FilteredSearch.d.ts +5 -0
  138. package/lib/FilteredSearch.js +1 -12
  139. package/lib/Flash.d.ts +8 -0
  140. package/lib/Flash.js +35 -14
  141. package/lib/Flex.d.ts +7 -0
  142. package/lib/Flex.js +3 -5
  143. package/lib/FormGroup.d.ts +11 -0
  144. package/lib/FormGroup.js +2 -22
  145. package/lib/Grid.d.ts +7 -0
  146. package/lib/Grid.js +4 -9
  147. package/lib/Header.d.ts +23 -0
  148. package/lib/Header.js +7 -37
  149. package/lib/Heading.d.ts +5 -0
  150. package/lib/Heading.js +1 -13
  151. package/lib/Label.d.ts +10 -0
  152. package/lib/Label.js +5 -19
  153. package/lib/LabelGroup.d.ts +5 -0
  154. package/lib/LabelGroup.js +1 -9
  155. package/lib/Link.d.ts +9 -0
  156. package/lib/Link.js +2 -30
  157. package/lib/NewButton/button-base.d.ts +6 -0
  158. package/lib/NewButton/button-base.js +75 -0
  159. package/lib/NewButton/button-counter.d.ts +6 -0
  160. package/lib/NewButton/button-counter.js +31 -0
  161. package/lib/NewButton/button-link.d.ts +23 -0
  162. package/lib/NewButton/button-link.js +37 -0
  163. package/lib/NewButton/button.d.ts +12 -0
  164. package/lib/NewButton/button.js +31 -0
  165. package/lib/NewButton/icon-button.d.ts +11 -0
  166. package/lib/NewButton/icon-button.js +57 -0
  167. package/lib/NewButton/index.d.ts +18 -0
  168. package/lib/NewButton/index.js +33 -0
  169. package/lib/NewButton/styles.d.ts +202 -0
  170. package/lib/NewButton/styles.js +248 -0
  171. package/lib/NewButton/types.d.ts +50 -0
  172. package/lib/{utils → NewButton}/types.js +0 -0
  173. package/lib/Overlay.d.ts +66 -0
  174. package/lib/Overlay.js +184 -0
  175. package/lib/Pagehead.d.ts +5 -0
  176. package/lib/Pagehead.js +1 -13
  177. package/lib/Pagination/Pagination.d.ts +24 -0
  178. package/lib/Pagination/Pagination.js +14 -29
  179. package/lib/Pagination/index.d.ts +3 -0
  180. package/lib/Pagination/model.d.ts +26 -0
  181. package/lib/Pagination/model.js +1 -1
  182. package/lib/PointerBox.d.ts +11 -0
  183. package/lib/PointerBox.js +4 -13
  184. package/lib/Popover.d.ts +20 -0
  185. package/lib/Popover.js +15 -38
  186. package/lib/Portal/Portal.d.ts +25 -0
  187. package/lib/Portal/Portal.js +101 -0
  188. package/lib/Portal/index.d.ts +4 -0
  189. package/lib/Portal/index.js +17 -0
  190. package/lib/Position.d.ts +34 -0
  191. package/lib/Position.js +46 -46
  192. package/lib/ProgressBar.d.ts +26 -0
  193. package/lib/ProgressBar.js +8 -27
  194. package/lib/SelectMenu/SelectMenu.d.ts +1670 -0
  195. package/lib/SelectMenu/SelectMenu.js +32 -44
  196. package/lib/SelectMenu/SelectMenuContext.d.ts +8 -0
  197. package/lib/SelectMenu/SelectMenuContext.js +1 -1
  198. package/lib/SelectMenu/SelectMenuDivider.d.ts +5 -0
  199. package/lib/SelectMenu/SelectMenuDivider.js +6 -14
  200. package/lib/SelectMenu/SelectMenuFilter.d.ts +9 -0
  201. package/lib/SelectMenu/SelectMenuFilter.js +13 -21
  202. package/lib/SelectMenu/SelectMenuFooter.d.ts +5 -0
  203. package/lib/SelectMenu/SelectMenuFooter.js +6 -14
  204. package/lib/SelectMenu/SelectMenuHeader.d.ts +10 -0
  205. package/lib/SelectMenu/SelectMenuHeader.js +4 -17
  206. package/lib/SelectMenu/SelectMenuItem.d.ts +14 -0
  207. package/lib/SelectMenu/SelectMenuItem.js +13 -21
  208. package/lib/SelectMenu/SelectMenuList.d.ts +5 -0
  209. package/lib/SelectMenu/SelectMenuList.js +6 -14
  210. package/lib/SelectMenu/SelectMenuLoadingAnimation.d.ts +7 -0
  211. package/lib/SelectMenu/SelectMenuLoadingAnimation.js +6 -17
  212. package/lib/SelectMenu/SelectMenuModal.d.ts +14 -0
  213. package/lib/SelectMenu/SelectMenuModal.js +11 -23
  214. package/lib/SelectMenu/SelectMenuTab.d.ts +13 -0
  215. package/lib/SelectMenu/SelectMenuTab.js +16 -26
  216. package/lib/SelectMenu/SelectMenuTabPanel.d.ts +12 -0
  217. package/lib/SelectMenu/SelectMenuTabPanel.js +14 -25
  218. package/lib/SelectMenu/SelectMenuTabs.d.ts +10 -0
  219. package/lib/SelectMenu/SelectMenuTabs.js +10 -17
  220. package/lib/SelectMenu/hooks/useKeyboardNav.d.ts +2 -0
  221. package/lib/SelectMenu/hooks/useKeyboardNav.js +2 -0
  222. package/lib/SelectMenu/index.d.ts +2 -0
  223. package/lib/SelectMenu/index.js +7 -5
  224. package/lib/SelectPanel/SelectPanel.d.ts +25 -0
  225. package/lib/SelectPanel/SelectPanel.js +147 -0
  226. package/lib/SelectPanel/index.d.ts +2 -0
  227. package/lib/SelectPanel/index.js +13 -0
  228. package/lib/SideNav.d.ts +34 -0
  229. package/lib/SideNav.js +35 -51
  230. package/lib/Spinner.d.ts +16 -0
  231. package/lib/Spinner.js +58 -0
  232. package/lib/StateLabel.d.ts +15 -0
  233. package/lib/StateLabel.js +53 -23
  234. package/lib/StyledOcticon.d.ts +11 -0
  235. package/lib/StyledOcticon.js +1 -15
  236. package/lib/SubNav.d.ts +26 -0
  237. package/lib/SubNav.js +27 -49
  238. package/lib/TabNav.d.ts +19 -0
  239. package/lib/TabNav.js +15 -37
  240. package/lib/Text.d.ts +6 -0
  241. package/lib/Text.js +0 -12
  242. package/lib/TextInput.d.ts +14 -0
  243. package/lib/TextInput.js +25 -76
  244. package/lib/TextInputWithTokens.d.ts +328 -0
  245. package/lib/TextInputWithTokens.js +318 -0
  246. package/lib/ThemeProvider.d.ts +26 -0
  247. package/lib/ThemeProvider.js +193 -0
  248. package/lib/Timeline.d.ts +33 -0
  249. package/lib/Timeline.js +34 -87
  250. package/lib/Token/AvatarToken.d.ts +7 -0
  251. package/lib/Token/AvatarToken.js +64 -0
  252. package/lib/Token/IssueLabelToken.d.ts +14 -0
  253. package/lib/Token/IssueLabelToken.js +144 -0
  254. package/lib/Token/Token.d.ts +15 -0
  255. package/lib/Token/Token.js +105 -0
  256. package/lib/Token/TokenBase.d.ts +31 -0
  257. package/lib/Token/TokenBase.js +104 -0
  258. package/lib/Token/_RemoveTokenButton.d.ts +12 -0
  259. package/lib/Token/_RemoveTokenButton.js +90 -0
  260. package/lib/Token/_TokenTextContainer.d.ts +3 -0
  261. package/lib/Token/_TokenTextContainer.js +17 -0
  262. package/lib/Token/index.d.ts +3 -0
  263. package/lib/Token/index.js +31 -0
  264. package/lib/Tooltip.d.ts +17 -0
  265. package/lib/Tooltip.js +4 -21
  266. package/lib/Truncate.d.ts +10 -0
  267. package/lib/Truncate.js +2 -18
  268. package/lib/UnderlineNav.d.ts +24 -0
  269. package/lib/UnderlineNav.js +3 -29
  270. package/lib/_TextInputWrapper.d.ts +10 -0
  271. package/lib/_TextInputWrapper.js +51 -0
  272. package/lib/_UnstyledTextInput.d.ts +2 -0
  273. package/lib/_UnstyledTextInput.js +20 -0
  274. package/lib/behaviors/anchoredPosition.d.ts +89 -0
  275. package/lib/behaviors/anchoredPosition.js +316 -0
  276. package/lib/behaviors/focusTrap.d.ts +12 -0
  277. package/lib/behaviors/focusTrap.js +179 -0
  278. package/lib/behaviors/focusZone.d.ts +137 -0
  279. package/lib/behaviors/focusZone.js +578 -0
  280. package/lib/behaviors/scrollIntoViewingArea.d.ts +1 -0
  281. package/lib/behaviors/scrollIntoViewingArea.js +39 -0
  282. package/lib/constants.d.ts +20 -0
  283. package/lib/constants.js +11 -27
  284. package/lib/drafts.d.ts +9 -0
  285. package/lib/drafts.js +44 -0
  286. package/lib/hooks/index.d.ts +11 -0
  287. package/lib/hooks/index.js +61 -0
  288. package/lib/hooks/useAnchoredPosition.d.ts +20 -0
  289. package/lib/hooks/useAnchoredPosition.js +51 -0
  290. package/lib/hooks/useCombinedRefs.d.ts +10 -0
  291. package/lib/hooks/useCombinedRefs.js +47 -0
  292. package/lib/hooks/useDetails.d.ts +17 -0
  293. package/lib/hooks/useDetails.js +10 -3
  294. package/lib/hooks/useDialog.d.ts +16 -0
  295. package/lib/hooks/useDialog.js +21 -6
  296. package/lib/hooks/useFocusTrap.d.ts +32 -0
  297. package/lib/hooks/useFocusTrap.js +69 -0
  298. package/lib/hooks/useFocusZone.d.ts +23 -0
  299. package/lib/hooks/useFocusZone.js +53 -0
  300. package/lib/hooks/useOnEscapePress.d.ts +23 -0
  301. package/lib/hooks/useOnEscapePress.js +69 -0
  302. package/lib/hooks/useOnOutsideClick.d.ts +8 -0
  303. package/lib/hooks/useOnOutsideClick.js +90 -0
  304. package/lib/hooks/useOpenAndCloseFocus.d.ts +8 -0
  305. package/lib/hooks/useOpenAndCloseFocus.js +36 -0
  306. package/lib/hooks/useOverlay.d.ts +15 -0
  307. package/lib/hooks/useOverlay.js +43 -0
  308. package/lib/hooks/useProvidedRefOrCreate.d.ts +10 -0
  309. package/lib/hooks/useProvidedRefOrCreate.js +24 -0
  310. package/lib/hooks/useProvidedStateOrCreate.d.ts +10 -0
  311. package/lib/hooks/useProvidedStateOrCreate.js +27 -0
  312. package/lib/hooks/useRenderForcingRef.d.ts +8 -0
  313. package/lib/hooks/useRenderForcingRef.js +25 -0
  314. package/lib/hooks/useResizeObserver.d.ts +1 -0
  315. package/lib/hooks/useResizeObserver.js +20 -0
  316. package/lib/hooks/useSafeTimeout.d.ts +12 -0
  317. package/lib/hooks/useSafeTimeout.js +38 -0
  318. package/lib/hooks/useScrollFlash.d.ts +6 -0
  319. package/lib/hooks/useScrollFlash.js +29 -0
  320. package/lib/index.d.ts +120 -0
  321. package/lib/index.js +191 -7
  322. package/lib/polyfills/eventListenerSignal.d.ts +6 -0
  323. package/lib/polyfills/eventListenerSignal.js +64 -0
  324. package/lib/sx.d.ts +14 -0
  325. package/lib/sx.js +8 -5
  326. package/lib/theme-preval.d.ts +49 -0
  327. package/lib/theme-preval.js +3119 -357
  328. package/lib/theme.d.ts +80 -0
  329. package/lib/theme.js +5 -8
  330. package/lib/utils/create-slots.d.ts +17 -0
  331. package/lib/utils/create-slots.js +105 -0
  332. package/lib/utils/deprecate.d.ts +18 -0
  333. package/lib/utils/deprecate.js +6 -5
  334. package/lib/utils/isNumeric.d.ts +1 -0
  335. package/lib/utils/isNumeric.js +1 -0
  336. package/lib/utils/iterateFocusableElements.d.ts +42 -0
  337. package/lib/utils/iterateFocusableElements.js +113 -0
  338. package/lib/utils/ssr.d.ts +1 -0
  339. package/lib/utils/ssr.js +19 -0
  340. package/lib/utils/test-deprecations.d.ts +1 -0
  341. package/lib/utils/test-deprecations.js +2 -1
  342. package/lib/utils/test-helpers.d.ts +0 -0
  343. package/lib/utils/test-helpers.js +9 -0
  344. package/lib/utils/test-matchers.d.ts +1 -0
  345. package/lib/utils/test-matchers.js +6 -50
  346. package/lib/utils/testing.d.ts +545 -0
  347. package/lib/utils/testing.js +65 -49
  348. package/lib/utils/theme.d.ts +9 -0
  349. package/lib/utils/theme.js +68 -0
  350. package/lib/utils/types/AriaRole.d.ts +1 -0
  351. package/lib/utils/types/AriaRole.js +1 -0
  352. package/lib/utils/types/ComponentProps.d.ts +9 -0
  353. package/lib/utils/types/ComponentProps.js +1 -0
  354. package/lib/utils/types/Flatten.d.ts +4 -0
  355. package/lib/utils/types/Flatten.js +1 -0
  356. package/lib/utils/types/KeyPaths.d.ts +3 -0
  357. package/lib/utils/types/KeyPaths.js +1 -0
  358. package/lib/utils/types/MandateProps.d.ts +3 -0
  359. package/lib/utils/types/MandateProps.js +1 -0
  360. package/lib/utils/types/Merge.d.ts +19 -0
  361. package/lib/utils/types/Merge.js +1 -0
  362. package/lib/utils/types/index.d.ts +5 -0
  363. package/lib/utils/types/index.js +70 -0
  364. package/lib/utils/uniqueId.d.ts +1 -0
  365. package/lib/utils/uniqueId.js +12 -0
  366. package/lib/utils/use-force-update.d.ts +1 -0
  367. package/lib/utils/use-force-update.js +19 -0
  368. package/lib/utils/useIsomorphicLayoutEffect.d.ts +3 -0
  369. package/lib/utils/useIsomorphicLayoutEffect.js +12 -0
  370. package/lib/utils/userAgent.d.ts +1 -0
  371. package/lib/utils/userAgent.js +15 -0
  372. package/lib-esm/ActionList/Divider.d.ts +9 -0
  373. package/lib-esm/ActionList/Divider.js +23 -0
  374. package/lib-esm/ActionList/Group.d.ts +28 -0
  375. package/lib-esm/ActionList/Group.js +24 -0
  376. package/lib-esm/ActionList/Header.d.ts +29 -0
  377. package/lib-esm/ActionList/Header.js +33 -0
  378. package/lib-esm/ActionList/Item.d.ts +98 -0
  379. package/lib-esm/ActionList/Item.js +241 -0
  380. package/lib-esm/ActionList/List.d.ts +88 -0
  381. package/lib-esm/ActionList/List.js +181 -0
  382. package/lib-esm/ActionList/index.d.ts +17 -0
  383. package/lib-esm/ActionList/index.js +18 -0
  384. package/lib-esm/ActionList2/Description.d.ts +12 -0
  385. package/lib-esm/ActionList2/Description.js +41 -0
  386. package/lib-esm/ActionList2/Divider.d.ts +6 -0
  387. package/lib-esm/ActionList2/Divider.js +26 -0
  388. package/lib-esm/ActionList2/Group.d.ts +37 -0
  389. package/lib-esm/ActionList2/Group.js +87 -0
  390. package/lib-esm/ActionList2/Item.d.ts +63 -0
  391. package/lib-esm/ActionList2/Item.js +224 -0
  392. package/lib-esm/ActionList2/LinkItem.d.ts +17 -0
  393. package/lib-esm/ActionList2/LinkItem.js +43 -0
  394. package/lib-esm/ActionList2/List.d.ts +26 -0
  395. package/lib-esm/ActionList2/List.js +44 -0
  396. package/lib-esm/ActionList2/MenuContext.d.ts +10 -0
  397. package/lib-esm/ActionList2/MenuContext.js +3 -0
  398. package/lib-esm/ActionList2/Selection.d.ts +5 -0
  399. package/lib-esm/ActionList2/Selection.js +77 -0
  400. package/lib-esm/ActionList2/Visuals.d.ts +9 -0
  401. package/lib-esm/ActionList2/Visuals.js +68 -0
  402. package/lib-esm/ActionList2/index.d.ts +35 -0
  403. package/lib-esm/ActionList2/index.js +33 -0
  404. package/lib-esm/ActionMenu.d.ts +40 -0
  405. package/lib-esm/ActionMenu.js +82 -0
  406. package/lib-esm/ActionMenu2.d.ts +310 -0
  407. package/lib-esm/ActionMenu2.js +67 -0
  408. package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +62 -0
  409. package/lib-esm/AnchoredOverlay/AnchoredOverlay.js +104 -0
  410. package/lib-esm/AnchoredOverlay/index.d.ts +2 -0
  411. package/lib-esm/AnchoredOverlay/index.js +1 -0
  412. package/lib-esm/Autocomplete/Autocomplete.d.ts +305 -0
  413. package/lib-esm/Autocomplete/Autocomplete.js +123 -0
  414. package/lib-esm/Autocomplete/AutocompleteContext.d.ts +17 -0
  415. package/lib-esm/Autocomplete/AutocompleteContext.js +2 -0
  416. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +293 -0
  417. package/lib-esm/Autocomplete/AutocompleteInput.js +138 -0
  418. package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +72 -0
  419. package/lib-esm/Autocomplete/AutocompleteMenu.js +205 -0
  420. package/lib-esm/Autocomplete/AutocompleteOverlay.d.ts +20 -0
  421. package/lib-esm/Autocomplete/AutocompleteOverlay.js +62 -0
  422. package/lib-esm/Autocomplete/index.d.ts +2 -0
  423. package/lib-esm/Autocomplete/index.js +1 -0
  424. package/lib-esm/Avatar.d.ts +14 -0
  425. package/lib-esm/Avatar.js +2 -11
  426. package/lib-esm/AvatarPair.d.ts +8 -0
  427. package/lib-esm/AvatarPair.js +8 -14
  428. package/lib-esm/AvatarStack.d.ts +8 -0
  429. package/lib-esm/AvatarStack.js +12 -21
  430. package/lib-esm/BaseStyles.d.ts +14 -0
  431. package/lib-esm/BaseStyles.js +23 -26
  432. package/lib-esm/BorderBox.d.ts +7 -0
  433. package/lib-esm/BorderBox.js +6 -12
  434. package/lib-esm/Box.d.ts +6 -0
  435. package/lib-esm/Box.js +2 -13
  436. package/lib-esm/BranchName.d.ts +5 -0
  437. package/lib-esm/BranchName.js +2 -13
  438. package/lib-esm/Breadcrumbs.d.ts +41 -0
  439. package/lib-esm/Breadcrumbs.js +58 -0
  440. package/lib-esm/Button/Button.d.ts +284 -0
  441. package/lib-esm/Button/Button.js +3 -10
  442. package/lib-esm/Button/ButtonBase.d.ts +9 -0
  443. package/lib-esm/Button/ButtonBase.js +1 -19
  444. package/lib-esm/Button/ButtonClose.d.ts +279 -0
  445. package/lib-esm/Button/ButtonClose.js +5 -20
  446. package/lib-esm/Button/ButtonDanger.d.ts +284 -0
  447. package/lib-esm/Button/ButtonDanger.js +2 -9
  448. package/lib-esm/Button/ButtonGroup.d.ts +4 -0
  449. package/lib-esm/Button/ButtonGroup.js +2 -7
  450. package/lib-esm/Button/ButtonInvisible.d.ts +284 -0
  451. package/lib-esm/Button/ButtonInvisible.js +3 -10
  452. package/lib-esm/Button/ButtonOutline.d.ts +284 -0
  453. package/lib-esm/Button/ButtonOutline.js +2 -9
  454. package/lib-esm/Button/ButtonPrimary.d.ts +284 -0
  455. package/lib-esm/Button/ButtonPrimary.js +2 -9
  456. package/lib-esm/Button/ButtonStyles.d.ts +2 -0
  457. package/lib-esm/Button/ButtonTableList.d.ts +5 -0
  458. package/lib-esm/Button/ButtonTableList.js +2 -14
  459. package/lib-esm/Button/index.d.ts +16 -0
  460. package/lib-esm/Button/index.js +8 -8
  461. package/lib-esm/Caret.d.ts +21 -0
  462. package/lib-esm/Caret.js +13 -16
  463. package/lib-esm/Checkbox.d.ts +29 -0
  464. package/lib-esm/Checkbox.js +44 -0
  465. package/lib-esm/CircleBadge.d.ts +24 -0
  466. package/lib-esm/CircleBadge.js +3 -19
  467. package/lib-esm/CircleOcticon.d.ts +392 -0
  468. package/lib-esm/CircleOcticon.js +9 -15
  469. package/lib-esm/CounterLabel.d.ts +7 -0
  470. package/lib-esm/CounterLabel.js +4 -16
  471. package/lib-esm/Details.d.ts +5 -0
  472. package/lib-esm/Details.js +2 -10
  473. package/lib-esm/Dialog/ConfirmationDialog.d.ts +44 -0
  474. package/lib-esm/Dialog/ConfirmationDialog.js +169 -0
  475. package/lib-esm/Dialog/Dialog.d.ts +163 -0
  476. package/lib-esm/Dialog/Dialog.js +275 -0
  477. package/lib-esm/Dialog.d.ts +406 -0
  478. package/lib-esm/Dialog.js +31 -46
  479. package/lib-esm/Dropdown.d.ts +1113 -0
  480. package/lib-esm/Dropdown.js +38 -58
  481. package/lib-esm/DropdownMenu/DropdownButton.d.ts +280 -0
  482. package/lib-esm/DropdownMenu/DropdownButton.js +18 -0
  483. package/lib-esm/DropdownMenu/DropdownMenu.d.ts +43 -0
  484. package/lib-esm/DropdownMenu/DropdownMenu.js +77 -0
  485. package/lib-esm/DropdownMenu/index.d.ts +4 -0
  486. package/lib-esm/DropdownMenu/index.js +2 -0
  487. package/lib-esm/DropdownStyles.d.ts +3 -0
  488. package/lib-esm/DropdownStyles.js +6 -6
  489. package/lib-esm/FilterList.d.ts +283 -0
  490. package/lib-esm/FilterList.js +3 -29
  491. package/lib-esm/FilteredActionList/FilteredActionList.d.ts +16 -0
  492. package/lib-esm/FilteredActionList/FilteredActionList.js +109 -0
  493. package/lib-esm/FilteredActionList/index.d.ts +2 -0
  494. package/lib-esm/FilteredActionList/index.js +1 -0
  495. package/lib-esm/FilteredSearch.d.ts +5 -0
  496. package/lib-esm/FilteredSearch.js +2 -11
  497. package/lib-esm/Flash.d.ts +8 -0
  498. package/lib-esm/Flash.js +36 -13
  499. package/lib-esm/Flex.d.ts +7 -0
  500. package/lib-esm/Flex.js +4 -4
  501. package/lib-esm/FormGroup.d.ts +11 -0
  502. package/lib-esm/FormGroup.js +3 -20
  503. package/lib-esm/Grid.d.ts +7 -0
  504. package/lib-esm/Grid.js +5 -7
  505. package/lib-esm/Header.d.ts +23 -0
  506. package/lib-esm/Header.js +6 -34
  507. package/lib-esm/Heading.d.ts +5 -0
  508. package/lib-esm/Heading.js +2 -12
  509. package/lib-esm/Label.d.ts +10 -0
  510. package/lib-esm/Label.js +3 -15
  511. package/lib-esm/LabelGroup.d.ts +5 -0
  512. package/lib-esm/LabelGroup.js +2 -9
  513. package/lib-esm/Link.d.ts +9 -0
  514. package/lib-esm/Link.js +2 -28
  515. package/lib-esm/NewButton/button-base.d.ts +6 -0
  516. package/lib-esm/NewButton/button-base.js +51 -0
  517. package/lib-esm/NewButton/button-counter.d.ts +6 -0
  518. package/lib-esm/NewButton/button-counter.js +18 -0
  519. package/lib-esm/NewButton/button-link.d.ts +23 -0
  520. package/lib-esm/NewButton/button-link.js +21 -0
  521. package/lib-esm/NewButton/button.d.ts +12 -0
  522. package/lib-esm/NewButton/button.js +16 -0
  523. package/lib-esm/NewButton/icon-button.d.ts +11 -0
  524. package/lib-esm/NewButton/icon-button.js +35 -0
  525. package/lib-esm/NewButton/index.d.ts +18 -0
  526. package/lib-esm/NewButton/index.js +8 -0
  527. package/lib-esm/NewButton/styles.d.ts +202 -0
  528. package/lib-esm/NewButton/styles.js +229 -0
  529. package/lib-esm/NewButton/types.d.ts +50 -0
  530. package/lib-esm/NewButton/types.js +1 -0
  531. package/lib-esm/Overlay.d.ts +66 -0
  532. package/lib-esm/Overlay.js +160 -0
  533. package/lib-esm/Pagehead.d.ts +5 -0
  534. package/lib-esm/Pagehead.js +2 -12
  535. package/lib-esm/Pagination/Pagination.d.ts +24 -0
  536. package/lib-esm/Pagination/Pagination.js +15 -28
  537. package/lib-esm/Pagination/index.d.ts +3 -0
  538. package/lib-esm/Pagination/model.d.ts +26 -0
  539. package/lib-esm/Pagination/model.js +1 -1
  540. package/lib-esm/PointerBox.d.ts +11 -0
  541. package/lib-esm/PointerBox.js +4 -11
  542. package/lib-esm/Popover.d.ts +20 -0
  543. package/lib-esm/Popover.js +13 -36
  544. package/lib-esm/Portal/Portal.d.ts +25 -0
  545. package/lib-esm/Portal/Portal.js +83 -0
  546. package/lib-esm/Portal/index.d.ts +4 -0
  547. package/lib-esm/Portal/index.js +3 -0
  548. package/lib-esm/Position.d.ts +34 -0
  549. package/lib-esm/Position.js +42 -37
  550. package/lib-esm/ProgressBar.d.ts +26 -0
  551. package/lib-esm/ProgressBar.js +9 -25
  552. package/lib-esm/SelectMenu/SelectMenu.d.ts +1670 -0
  553. package/lib-esm/SelectMenu/SelectMenu.js +27 -38
  554. package/lib-esm/SelectMenu/SelectMenuContext.d.ts +8 -0
  555. package/lib-esm/SelectMenu/SelectMenuContext.js +1 -1
  556. package/lib-esm/SelectMenu/SelectMenuDivider.d.ts +5 -0
  557. package/lib-esm/SelectMenu/SelectMenuDivider.js +4 -11
  558. package/lib-esm/SelectMenu/SelectMenuFilter.d.ts +9 -0
  559. package/lib-esm/SelectMenu/SelectMenuFilter.js +13 -19
  560. package/lib-esm/SelectMenu/SelectMenuFooter.d.ts +5 -0
  561. package/lib-esm/SelectMenu/SelectMenuFooter.js +4 -11
  562. package/lib-esm/SelectMenu/SelectMenuHeader.d.ts +10 -0
  563. package/lib-esm/SelectMenu/SelectMenuHeader.js +7 -18
  564. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +14 -0
  565. package/lib-esm/SelectMenu/SelectMenuItem.js +11 -17
  566. package/lib-esm/SelectMenu/SelectMenuList.d.ts +5 -0
  567. package/lib-esm/SelectMenu/SelectMenuList.js +4 -11
  568. package/lib-esm/SelectMenu/SelectMenuLoadingAnimation.d.ts +7 -0
  569. package/lib-esm/SelectMenu/SelectMenuLoadingAnimation.js +7 -13
  570. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +14 -0
  571. package/lib-esm/SelectMenu/SelectMenuModal.js +10 -20
  572. package/lib-esm/SelectMenu/SelectMenuTab.d.ts +13 -0
  573. package/lib-esm/SelectMenu/SelectMenuTab.js +13 -21
  574. package/lib-esm/SelectMenu/SelectMenuTabPanel.d.ts +12 -0
  575. package/lib-esm/SelectMenu/SelectMenuTabPanel.js +9 -19
  576. package/lib-esm/SelectMenu/SelectMenuTabs.d.ts +10 -0
  577. package/lib-esm/SelectMenu/SelectMenuTabs.js +8 -15
  578. package/lib-esm/SelectMenu/hooks/useKeyboardNav.d.ts +2 -0
  579. package/lib-esm/SelectMenu/hooks/useKeyboardNav.js +2 -0
  580. package/lib-esm/SelectMenu/index.d.ts +2 -0
  581. package/lib-esm/SelectMenu/index.js +1 -2
  582. package/lib-esm/SelectPanel/SelectPanel.d.ts +25 -0
  583. package/lib-esm/SelectPanel/SelectPanel.js +127 -0
  584. package/lib-esm/SelectPanel/index.d.ts +2 -0
  585. package/lib-esm/SelectPanel/index.js +1 -0
  586. package/lib-esm/SideNav.d.ts +34 -0
  587. package/lib-esm/SideNav.js +29 -45
  588. package/lib-esm/Spinner.d.ts +16 -0
  589. package/lib-esm/Spinner.js +45 -0
  590. package/lib-esm/StateLabel.d.ts +15 -0
  591. package/lib-esm/StateLabel.js +55 -23
  592. package/lib-esm/StyledOcticon.d.ts +11 -0
  593. package/lib-esm/StyledOcticon.js +1 -12
  594. package/lib-esm/SubNav.d.ts +26 -0
  595. package/lib-esm/SubNav.js +24 -48
  596. package/lib-esm/TabNav.d.ts +19 -0
  597. package/lib-esm/TabNav.js +13 -33
  598. package/lib-esm/Text.d.ts +6 -0
  599. package/lib-esm/Text.js +0 -10
  600. package/lib-esm/TextInput.d.ts +14 -0
  601. package/lib-esm/TextInput.js +24 -62
  602. package/lib-esm/TextInputWithTokens.d.ts +328 -0
  603. package/lib-esm/TextInputWithTokens.js +291 -0
  604. package/lib-esm/ThemeProvider.d.ts +26 -0
  605. package/lib-esm/ThemeProvider.js +161 -0
  606. package/lib-esm/Timeline.d.ts +33 -0
  607. package/lib-esm/Timeline.js +26 -81
  608. package/lib-esm/Token/AvatarToken.d.ts +7 -0
  609. package/lib-esm/Token/AvatarToken.js +43 -0
  610. package/lib-esm/Token/IssueLabelToken.d.ts +14 -0
  611. package/lib-esm/Token/IssueLabelToken.js +124 -0
  612. package/lib-esm/Token/Token.d.ts +15 -0
  613. package/lib-esm/Token/Token.js +84 -0
  614. package/lib-esm/Token/TokenBase.d.ts +31 -0
  615. package/lib-esm/Token/TokenBase.js +83 -0
  616. package/lib-esm/Token/_RemoveTokenButton.d.ts +12 -0
  617. package/lib-esm/Token/_RemoveTokenButton.js +69 -0
  618. package/lib-esm/Token/_TokenTextContainer.d.ts +3 -0
  619. package/lib-esm/Token/_TokenTextContainer.js +6 -0
  620. package/lib-esm/Token/index.d.ts +3 -0
  621. package/lib-esm/Token/index.js +3 -0
  622. package/lib-esm/Tooltip.d.ts +17 -0
  623. package/lib-esm/Tooltip.js +4 -19
  624. package/lib-esm/Truncate.d.ts +10 -0
  625. package/lib-esm/Truncate.js +2 -15
  626. package/lib-esm/UnderlineNav.d.ts +24 -0
  627. package/lib-esm/UnderlineNav.js +5 -28
  628. package/lib-esm/_TextInputWrapper.d.ts +10 -0
  629. package/lib-esm/_TextInputWrapper.js +31 -0
  630. package/lib-esm/_UnstyledTextInput.d.ts +2 -0
  631. package/lib-esm/_UnstyledTextInput.js +7 -0
  632. package/lib-esm/behaviors/anchoredPosition.d.ts +89 -0
  633. package/lib-esm/behaviors/anchoredPosition.js +309 -0
  634. package/lib-esm/behaviors/focusTrap.d.ts +12 -0
  635. package/lib-esm/behaviors/focusTrap.js +170 -0
  636. package/lib-esm/behaviors/focusZone.d.ts +137 -0
  637. package/lib-esm/behaviors/focusZone.js +560 -0
  638. package/lib-esm/behaviors/scrollIntoViewingArea.d.ts +1 -0
  639. package/lib-esm/behaviors/scrollIntoViewingArea.js +30 -0
  640. package/lib-esm/constants.d.ts +20 -0
  641. package/lib-esm/constants.js +9 -23
  642. package/lib-esm/drafts.d.ts +9 -0
  643. package/lib-esm/drafts.js +10 -0
  644. package/lib-esm/hooks/index.d.ts +11 -0
  645. package/lib-esm/hooks/index.js +7 -0
  646. package/lib-esm/hooks/useAnchoredPosition.d.ts +20 -0
  647. package/lib-esm/hooks/useAnchoredPosition.js +35 -0
  648. package/lib-esm/hooks/useCombinedRefs.d.ts +10 -0
  649. package/lib-esm/hooks/useCombinedRefs.js +37 -0
  650. package/lib-esm/hooks/useDetails.d.ts +17 -0
  651. package/lib-esm/hooks/useDetails.js +10 -3
  652. package/lib-esm/hooks/useDialog.d.ts +16 -0
  653. package/lib-esm/hooks/useDialog.js +21 -6
  654. package/lib-esm/hooks/useFocusTrap.d.ts +32 -0
  655. package/lib-esm/hooks/useFocusTrap.js +54 -0
  656. package/lib-esm/hooks/useFocusZone.d.ts +23 -0
  657. package/lib-esm/hooks/useFocusZone.js +37 -0
  658. package/lib-esm/hooks/useOnEscapePress.d.ts +23 -0
  659. package/lib-esm/hooks/useOnEscapePress.js +59 -0
  660. package/lib-esm/hooks/useOnOutsideClick.d.ts +8 -0
  661. package/lib-esm/hooks/useOnOutsideClick.js +79 -0
  662. package/lib-esm/hooks/useOpenAndCloseFocus.d.ts +8 -0
  663. package/lib-esm/hooks/useOpenAndCloseFocus.js +27 -0
  664. package/lib-esm/hooks/useOverlay.d.ts +15 -0
  665. package/lib-esm/hooks/useOverlay.js +30 -0
  666. package/lib-esm/hooks/useProvidedRefOrCreate.d.ts +10 -0
  667. package/lib-esm/hooks/useProvidedRefOrCreate.js +14 -0
  668. package/lib-esm/hooks/useProvidedStateOrCreate.d.ts +10 -0
  669. package/lib-esm/hooks/useProvidedStateOrCreate.js +20 -0
  670. package/lib-esm/hooks/useRenderForcingRef.d.ts +8 -0
  671. package/lib-esm/hooks/useRenderForcingRef.js +18 -0
  672. package/lib-esm/hooks/useResizeObserver.d.ts +1 -0
  673. package/lib-esm/hooks/useResizeObserver.js +10 -0
  674. package/lib-esm/hooks/useSafeTimeout.d.ts +12 -0
  675. package/lib-esm/hooks/useSafeTimeout.js +31 -0
  676. package/lib-esm/hooks/useScrollFlash.d.ts +6 -0
  677. package/lib-esm/hooks/useScrollFlash.js +22 -0
  678. package/lib-esm/index.d.ts +120 -0
  679. package/lib-esm/index.js +29 -7
  680. package/lib-esm/polyfills/eventListenerSignal.d.ts +6 -0
  681. package/lib-esm/polyfills/eventListenerSignal.js +57 -0
  682. package/lib-esm/sx.d.ts +14 -0
  683. package/lib-esm/sx.js +3 -5
  684. package/lib-esm/theme-preval.d.ts +49 -0
  685. package/lib-esm/theme-preval.js +3119 -357
  686. package/lib-esm/theme.d.ts +80 -0
  687. package/lib-esm/theme.js +3 -8
  688. package/lib-esm/utils/create-slots.d.ts +17 -0
  689. package/lib-esm/utils/create-slots.js +84 -0
  690. package/lib-esm/utils/deprecate.d.ts +18 -0
  691. package/lib-esm/utils/deprecate.js +6 -5
  692. package/lib-esm/utils/isNumeric.d.ts +1 -0
  693. package/lib-esm/utils/isNumeric.js +1 -0
  694. package/lib-esm/utils/iterateFocusableElements.d.ts +42 -0
  695. package/lib-esm/utils/iterateFocusableElements.js +102 -0
  696. package/lib-esm/utils/ssr.d.ts +1 -0
  697. package/lib-esm/utils/ssr.js +1 -0
  698. package/lib-esm/utils/test-deprecations.d.ts +1 -0
  699. package/lib-esm/utils/test-deprecations.js +1 -1
  700. package/lib-esm/utils/{types.js → test-helpers.d.ts} +0 -0
  701. package/lib-esm/utils/test-helpers.js +7 -0
  702. package/lib-esm/utils/test-matchers.d.ts +1 -0
  703. package/lib-esm/utils/test-matchers.js +7 -49
  704. package/lib-esm/utils/testing.d.ts +545 -0
  705. package/lib-esm/utils/testing.js +60 -46
  706. package/lib-esm/utils/theme.d.ts +9 -0
  707. package/lib-esm/utils/theme.js +66 -0
  708. package/lib-esm/utils/types/AriaRole.d.ts +1 -0
  709. package/lib-esm/utils/types/AriaRole.js +1 -0
  710. package/lib-esm/utils/types/ComponentProps.d.ts +9 -0
  711. package/lib-esm/utils/types/ComponentProps.js +1 -0
  712. package/lib-esm/utils/types/Flatten.d.ts +4 -0
  713. package/lib-esm/utils/types/Flatten.js +1 -0
  714. package/lib-esm/utils/types/KeyPaths.d.ts +3 -0
  715. package/lib-esm/utils/types/KeyPaths.js +1 -0
  716. package/lib-esm/utils/types/MandateProps.d.ts +3 -0
  717. package/lib-esm/utils/types/MandateProps.js +1 -0
  718. package/lib-esm/utils/types/Merge.d.ts +19 -0
  719. package/lib-esm/utils/types/Merge.js +1 -0
  720. package/lib-esm/utils/types/index.d.ts +5 -0
  721. package/lib-esm/utils/types/index.js +5 -0
  722. package/lib-esm/utils/uniqueId.d.ts +1 -0
  723. package/lib-esm/utils/uniqueId.js +5 -0
  724. package/lib-esm/utils/use-force-update.d.ts +1 -0
  725. package/lib-esm/utils/use-force-update.js +6 -0
  726. package/lib-esm/utils/useIsomorphicLayoutEffect.d.ts +3 -0
  727. package/lib-esm/utils/useIsomorphicLayoutEffect.js +3 -0
  728. package/lib-esm/utils/userAgent.d.ts +1 -0
  729. package/lib-esm/utils/userAgent.js +8 -0
  730. package/package.json +114 -93
  731. package/index.d.ts +0 -828
  732. package/lib/Breadcrumb.js +0 -96
  733. package/lib/hooks/useMouseIntent.js +0 -58
  734. package/lib/stories/Button.stories.js +0 -100
  735. package/lib-esm/Breadcrumb.js +0 -70
  736. package/lib-esm/hooks/useMouseIntent.js +0 -50
  737. package/lib-esm/stories/Button.stories.js +0 -65
@@ -0,0 +1,560 @@
1
+ import { iterateFocusableElements } from '../utils/iterateFocusableElements';
2
+ import { polyfill as eventListenerSignalPolyfill } from '../polyfills/eventListenerSignal';
3
+ import { isMacOS } from '../utils/userAgent';
4
+ import { uniqueId } from '../utils/uniqueId';
5
+ eventListenerSignalPolyfill();
6
+ // eslint-disable-next-line no-shadow
7
+ export let FocusKeys;
8
+
9
+ (function (FocusKeys) {
10
+ FocusKeys[FocusKeys["ArrowHorizontal"] = 1] = "ArrowHorizontal";
11
+ FocusKeys[FocusKeys["ArrowVertical"] = 2] = "ArrowVertical";
12
+ FocusKeys[FocusKeys["JK"] = 4] = "JK";
13
+ FocusKeys[FocusKeys["HL"] = 8] = "HL";
14
+ FocusKeys[FocusKeys["HomeAndEnd"] = 16] = "HomeAndEnd";
15
+ FocusKeys[FocusKeys["PageUpDown"] = 256] = "PageUpDown";
16
+ FocusKeys[FocusKeys["WS"] = 32] = "WS";
17
+ FocusKeys[FocusKeys["AD"] = 64] = "AD";
18
+ FocusKeys[FocusKeys["Tab"] = 128] = "Tab";
19
+ FocusKeys[FocusKeys["ArrowAll"] = FocusKeys.ArrowHorizontal | FocusKeys.ArrowVertical] = "ArrowAll";
20
+ FocusKeys[FocusKeys["HJKL"] = FocusKeys.HL | FocusKeys.JK] = "HJKL";
21
+ FocusKeys[FocusKeys["WASD"] = FocusKeys.WS | FocusKeys.AD] = "WASD";
22
+ FocusKeys[FocusKeys["All"] = FocusKeys.ArrowAll | FocusKeys.HJKL | FocusKeys.HomeAndEnd | FocusKeys.PageUpDown | FocusKeys.WASD | FocusKeys.Tab] = "All";
23
+ })(FocusKeys || (FocusKeys = {}));
24
+
25
+ const KEY_TO_BIT = {
26
+ ArrowLeft: FocusKeys.ArrowHorizontal,
27
+ ArrowDown: FocusKeys.ArrowVertical,
28
+ ArrowUp: FocusKeys.ArrowVertical,
29
+ ArrowRight: FocusKeys.ArrowHorizontal,
30
+ h: FocusKeys.HL,
31
+ j: FocusKeys.JK,
32
+ k: FocusKeys.JK,
33
+ l: FocusKeys.HL,
34
+ a: FocusKeys.AD,
35
+ s: FocusKeys.WS,
36
+ w: FocusKeys.WS,
37
+ d: FocusKeys.AD,
38
+ Tab: FocusKeys.Tab,
39
+ Home: FocusKeys.HomeAndEnd,
40
+ End: FocusKeys.HomeAndEnd,
41
+ PageUp: FocusKeys.PageUpDown,
42
+ PageDown: FocusKeys.PageUpDown
43
+ };
44
+ const KEY_TO_DIRECTION = {
45
+ ArrowLeft: 'previous',
46
+ ArrowDown: 'next',
47
+ ArrowUp: 'previous',
48
+ ArrowRight: 'next',
49
+ h: 'previous',
50
+ j: 'next',
51
+ k: 'previous',
52
+ l: 'next',
53
+ a: 'previous',
54
+ s: 'next',
55
+ w: 'previous',
56
+ d: 'next',
57
+ Tab: 'next',
58
+ Home: 'start',
59
+ End: 'end',
60
+ PageUp: 'start',
61
+ PageDown: 'end'
62
+ };
63
+ /**
64
+ * Options that control the behavior of the arrow focus behavior.
65
+ */
66
+
67
+ function getDirection(keyboardEvent) {
68
+ const direction = KEY_TO_DIRECTION[keyboardEvent.key];
69
+
70
+ if (keyboardEvent.key === 'Tab' && keyboardEvent.shiftKey) {
71
+ return 'previous';
72
+ }
73
+
74
+ const isMac = isMacOS();
75
+
76
+ if (isMac && keyboardEvent.metaKey || !isMac && keyboardEvent.ctrlKey) {
77
+ if (keyboardEvent.key === 'ArrowLeft' || keyboardEvent.key === 'ArrowUp') {
78
+ return 'start';
79
+ } else if (keyboardEvent.key === 'ArrowRight' || keyboardEvent.key === 'ArrowDown') {
80
+ return 'end';
81
+ }
82
+ }
83
+
84
+ return direction;
85
+ }
86
+ /**
87
+ * There are some situations where we do not want various keys to affect focus. This function
88
+ * checks for those situations.
89
+ * 1. Home and End should not move focus when a text input or textarea is active
90
+ * 2. Keys that would normally type characters into an input or navigate a select element should be ignored
91
+ * 3. The down arrow sometimes should not move focus when a select is active since that sometimes invokes the dropdown
92
+ * 4. Page Up and Page Down within a textarea should not have any effect
93
+ * 5. When in a text input or textarea, left should only move focus if the cursor is at the beginning of the input
94
+ * 6. When in a text input or textarea, right should only move focus if the cursor is at the end of the input
95
+ * 7. When in a textarea, up and down should only move focus if cursor is at the beginning or end, respectively.
96
+ * @param keyboardEvent
97
+ * @param activeElement
98
+ */
99
+
100
+
101
+ function shouldIgnoreFocusHandling(keyboardEvent, activeElement) {
102
+ const key = keyboardEvent.key; // Get the number of characters in `key`, accounting for double-wide UTF-16 chars. If keyLength
103
+ // is 1, we can assume it's a "printable" character. Otherwise it's likely a control character.
104
+ // One exception is the Tab key, which is technically printable, but browsers generally assign
105
+ // its function to move focus rather than type a <TAB> character.
106
+
107
+ const keyLength = [...key].length;
108
+ const isTextInput = activeElement instanceof HTMLInputElement && activeElement.type === 'text' || activeElement instanceof HTMLTextAreaElement; // If we would normally type a character into an input, ignore
109
+ // Also, Home and End keys should never affect focus when in a text input
110
+
111
+ if (isTextInput && (keyLength === 1 || key === 'Home' || key === 'End')) {
112
+ return true;
113
+ } // Some situations we want to ignore with <select> elements
114
+
115
+
116
+ if (activeElement instanceof HTMLSelectElement) {
117
+ // Regular typeable characters change the selection, so ignore those
118
+ if (keyLength === 1) {
119
+ return true;
120
+ } // On macOS, bare ArrowDown opens the select, so ignore that
121
+
122
+
123
+ if (key === 'ArrowDown' && isMacOS() && !keyboardEvent.metaKey) {
124
+ return true;
125
+ } // On other platforms, Alt+ArrowDown opens the select, so ignore that
126
+
127
+
128
+ if (key === 'ArrowDown' && !isMacOS() && keyboardEvent.altKey) {
129
+ return true;
130
+ }
131
+ } // Ignore page up and page down for textareas
132
+
133
+
134
+ if (activeElement instanceof HTMLTextAreaElement && (key === 'PageUp' || key === 'PageDown')) {
135
+ return true;
136
+ }
137
+
138
+ if (isTextInput) {
139
+ const textInput = activeElement;
140
+ const cursorAtStart = textInput.selectionStart === 0 && textInput.selectionEnd === 0;
141
+ const cursorAtEnd = textInput.selectionStart === textInput.value.length && textInput.selectionEnd === textInput.value.length; // When in a text area or text input, only move focus left/right if at beginning/end of the field
142
+
143
+ if (key === 'ArrowLeft' && !cursorAtStart) {
144
+ return true;
145
+ }
146
+
147
+ if (key === 'ArrowRight' && !cursorAtEnd) {
148
+ return true;
149
+ } // When in a text area, only move focus up/down if at beginning/end of the field
150
+
151
+
152
+ if (textInput instanceof HTMLTextAreaElement) {
153
+ if (key === 'ArrowUp' && !cursorAtStart) {
154
+ return true;
155
+ }
156
+
157
+ if (key === 'ArrowDown' && !cursorAtEnd) {
158
+ return true;
159
+ }
160
+ }
161
+ }
162
+
163
+ return false;
164
+ }
165
+
166
+ export const isActiveDescendantAttribute = 'data-is-active-descendant';
167
+ /**
168
+ * A value of activated-directly for data-is-active-descendant indicates the descendant was activated
169
+ * by a manual user interaction with intent to move active descendant. This usually translates to the
170
+ * user pressing one of the bound keys (up/down arrow, etc) to move through the focus zone. This is
171
+ * intended to be roughly equivalent to the :focus-visible pseudo-class
172
+ **/
173
+
174
+ export const activeDescendantActivatedDirectly = 'activated-directly';
175
+ /**
176
+ * A value of activated-indirectly for data-is-active-descendant indicates the descendant was activated
177
+ * implicitly, and not by a direct key press. This includes focus zone being created from scratch, focusable
178
+ * elements being added/removed, and mouseover events. This is intended to be roughly equivalent
179
+ * to :focus:not(:focus-visible)
180
+ **/
181
+
182
+ export const activeDescendantActivatedIndirectly = 'activated-indirectly';
183
+ export const hasActiveDescendantAttribute = 'data-has-active-descendant';
184
+ /**
185
+ * Sets up the arrow key focus behavior for all focusable elements in the given `container`.
186
+ * @param container
187
+ * @param settings
188
+ * @returns
189
+ */
190
+
191
+ export function focusZone(container, settings) {
192
+ var _settings$bindKeys, _settings$focusOutBeh, _settings$focusInStra, _settings$abortSignal;
193
+
194
+ const focusableElements = [];
195
+ const savedTabIndex = new WeakMap();
196
+ const bindKeys = (_settings$bindKeys = settings === null || settings === void 0 ? void 0 : settings.bindKeys) !== null && _settings$bindKeys !== void 0 ? _settings$bindKeys : (settings !== null && settings !== void 0 && settings.getNextFocusable ? FocusKeys.ArrowAll : FocusKeys.ArrowVertical) | FocusKeys.HomeAndEnd;
197
+ const focusOutBehavior = (_settings$focusOutBeh = settings === null || settings === void 0 ? void 0 : settings.focusOutBehavior) !== null && _settings$focusOutBeh !== void 0 ? _settings$focusOutBeh : 'stop';
198
+ const focusInStrategy = (_settings$focusInStra = settings === null || settings === void 0 ? void 0 : settings.focusInStrategy) !== null && _settings$focusInStra !== void 0 ? _settings$focusInStra : 'previous';
199
+ const activeDescendantControl = settings === null || settings === void 0 ? void 0 : settings.activeDescendantControl;
200
+ const activeDescendantCallback = settings === null || settings === void 0 ? void 0 : settings.onActiveDescendantChanged;
201
+ let currentFocusedElement;
202
+
203
+ function getFirstFocusableElement() {
204
+ return focusableElements[0];
205
+ }
206
+
207
+ function isActiveDescendantInputFocused() {
208
+ return document.activeElement === activeDescendantControl;
209
+ }
210
+
211
+ function updateFocusedElement(to, directlyActivated = false) {
212
+ const from = currentFocusedElement;
213
+ currentFocusedElement = to;
214
+
215
+ if (activeDescendantControl) {
216
+ if (to && isActiveDescendantInputFocused()) {
217
+ setActiveDescendant(from, to, directlyActivated);
218
+ } else {
219
+ clearActiveDescendant();
220
+ }
221
+
222
+ return;
223
+ }
224
+
225
+ if (from && from !== to && savedTabIndex.has(from)) {
226
+ from.setAttribute('tabindex', '-1');
227
+ }
228
+
229
+ to === null || to === void 0 ? void 0 : to.setAttribute('tabindex', '0');
230
+ }
231
+
232
+ function setActiveDescendant(from, to, directlyActivated = false) {
233
+ if (!to.id) {
234
+ to.setAttribute('id', uniqueId());
235
+ }
236
+
237
+ if (from && from !== to) {
238
+ from.removeAttribute(isActiveDescendantAttribute);
239
+ }
240
+
241
+ if (!activeDescendantControl || !directlyActivated && activeDescendantControl.getAttribute('aria-activedescendant') === to.id) {
242
+ // prevent active descendant callback from being called repeatedly if the same element is activated (e.g. via mousemove)
243
+ return;
244
+ }
245
+
246
+ activeDescendantControl.setAttribute('aria-activedescendant', to.id);
247
+ container.setAttribute(hasActiveDescendantAttribute, to.id);
248
+ to.setAttribute(isActiveDescendantAttribute, directlyActivated ? activeDescendantActivatedDirectly : activeDescendantActivatedIndirectly);
249
+ activeDescendantCallback === null || activeDescendantCallback === void 0 ? void 0 : activeDescendantCallback(to, from, directlyActivated);
250
+ }
251
+
252
+ function clearActiveDescendant(previouslyActiveElement = currentFocusedElement) {
253
+ if (focusInStrategy === 'first') {
254
+ currentFocusedElement = undefined;
255
+ }
256
+
257
+ activeDescendantControl === null || activeDescendantControl === void 0 ? void 0 : activeDescendantControl.removeAttribute('aria-activedescendant');
258
+ container.removeAttribute(hasActiveDescendantAttribute);
259
+ previouslyActiveElement === null || previouslyActiveElement === void 0 ? void 0 : previouslyActiveElement.removeAttribute(isActiveDescendantAttribute);
260
+ activeDescendantCallback === null || activeDescendantCallback === void 0 ? void 0 : activeDescendantCallback(undefined, previouslyActiveElement, false);
261
+ }
262
+
263
+ function beginFocusManagement(...elements) {
264
+ const filteredElements = elements.filter(e => {
265
+ var _settings$focusableEl, _settings$focusableEl2;
266
+
267
+ return (_settings$focusableEl = settings === null || settings === void 0 ? void 0 : (_settings$focusableEl2 = settings.focusableElementFilter) === null || _settings$focusableEl2 === void 0 ? void 0 : _settings$focusableEl2.call(settings, e)) !== null && _settings$focusableEl !== void 0 ? _settings$focusableEl : true;
268
+ });
269
+
270
+ if (filteredElements.length === 0) {
271
+ return;
272
+ } // Insert all elements atomically. Assume that all passed elements are well-ordered.
273
+
274
+
275
+ const insertIndex = focusableElements.findIndex(e => (e.compareDocumentPosition(filteredElements[0]) & Node.DOCUMENT_POSITION_PRECEDING) > 0);
276
+ focusableElements.splice(insertIndex === -1 ? focusableElements.length : insertIndex, 0, ...filteredElements);
277
+
278
+ for (const element of filteredElements) {
279
+ // Set tabindex="-1" on all tabbable elements, but save the original
280
+ // value in case we need to disable the behavior
281
+ if (!savedTabIndex.has(element)) {
282
+ savedTabIndex.set(element, element.getAttribute('tabindex'));
283
+ }
284
+
285
+ element.setAttribute('tabindex', '-1');
286
+ }
287
+
288
+ if (!currentFocusedElement) {
289
+ updateFocusedElement(getFirstFocusableElement());
290
+ }
291
+ }
292
+
293
+ function endFocusManagement(...elements) {
294
+ for (const element of elements) {
295
+ const focusableElementIndex = focusableElements.indexOf(element);
296
+
297
+ if (focusableElementIndex >= 0) {
298
+ focusableElements.splice(focusableElementIndex, 1);
299
+ }
300
+
301
+ const savedIndex = savedTabIndex.get(element);
302
+
303
+ if (savedIndex !== undefined) {
304
+ if (savedIndex === null) {
305
+ element.removeAttribute('tabindex');
306
+ } else {
307
+ element.setAttribute('tabindex', savedIndex);
308
+ }
309
+
310
+ savedTabIndex.delete(element);
311
+ } // If removing the last-focused element, move focus to the first element in the list.
312
+
313
+
314
+ if (element === currentFocusedElement) {
315
+ const nextElementToFocus = getFirstFocusableElement();
316
+ updateFocusedElement(nextElementToFocus);
317
+ }
318
+ }
319
+ } // Take all tabbable elements within container under management
320
+
321
+
322
+ beginFocusManagement(...iterateFocusableElements(container)); // Open the first tabbable element for tabbing
323
+
324
+ updateFocusedElement(getFirstFocusableElement()); // If the DOM structure of the container changes, make sure we keep our state up-to-date
325
+ // with respect to the focusable elements cache and its order
326
+
327
+ const observer = new MutationObserver(mutations => {
328
+ // Perform all removals first, in case element order has simply changed
329
+ for (const mutation of mutations) {
330
+ for (const removedNode of mutation.removedNodes) {
331
+ if (removedNode instanceof HTMLElement) {
332
+ endFocusManagement(...iterateFocusableElements(removedNode));
333
+ }
334
+ }
335
+ }
336
+
337
+ for (const mutation of mutations) {
338
+ for (const addedNode of mutation.addedNodes) {
339
+ if (addedNode instanceof HTMLElement) {
340
+ beginFocusManagement(...iterateFocusableElements(addedNode));
341
+ }
342
+ }
343
+ }
344
+ });
345
+ observer.observe(container, {
346
+ subtree: true,
347
+ childList: true
348
+ });
349
+ const controller = new AbortController();
350
+ const signal = (_settings$abortSignal = settings === null || settings === void 0 ? void 0 : settings.abortSignal) !== null && _settings$abortSignal !== void 0 ? _settings$abortSignal : controller.signal;
351
+ signal.addEventListener('abort', () => {
352
+ // Clean up any modifications
353
+ endFocusManagement(...focusableElements);
354
+ });
355
+ let elementIndexFocusedByClick = undefined;
356
+ container.addEventListener('mousedown', event => {
357
+ // Since focusin is only called when focus changes, we need to make sure the clicked
358
+ // element isn't already focused.
359
+ if (event.target instanceof HTMLElement && event.target !== document.activeElement) {
360
+ elementIndexFocusedByClick = focusableElements.indexOf(event.target);
361
+ }
362
+ }, {
363
+ signal
364
+ });
365
+
366
+ if (activeDescendantControl) {
367
+ container.addEventListener('focusin', event => {
368
+ if (event.target instanceof HTMLElement && focusableElements.includes(event.target)) {
369
+ // Move focus to the activeDescendantControl if one of the descendants is focused
370
+ activeDescendantControl.focus();
371
+ updateFocusedElement(event.target);
372
+ }
373
+ });
374
+ container.addEventListener('mousemove', ({
375
+ target
376
+ }) => {
377
+ if (!(target instanceof Node)) {
378
+ return;
379
+ }
380
+
381
+ const focusableElement = focusableElements.find(element => element.contains(target));
382
+
383
+ if (focusableElement) {
384
+ updateFocusedElement(focusableElement);
385
+ }
386
+ }, {
387
+ signal,
388
+ capture: true
389
+ }); // Listeners specifically on the controlling element
390
+
391
+ activeDescendantControl.addEventListener('focusin', () => {
392
+ // Focus moved into the active descendant input. Activate current or first descendant.
393
+ if (!currentFocusedElement) {
394
+ updateFocusedElement(getFirstFocusableElement());
395
+ } else {
396
+ setActiveDescendant(undefined, currentFocusedElement);
397
+ }
398
+ });
399
+ activeDescendantControl.addEventListener('focusout', () => {
400
+ clearActiveDescendant();
401
+ });
402
+ } else {
403
+ // This is called whenever focus enters an element in the container
404
+ container.addEventListener('focusin', event => {
405
+ if (event.target instanceof HTMLElement) {
406
+ // If a click initiated the focus movement, we always want to set our internal state
407
+ // to reflect the clicked element as the currently focused one.
408
+ if (elementIndexFocusedByClick !== undefined) {
409
+ if (elementIndexFocusedByClick >= 0) {
410
+ if (focusableElements[elementIndexFocusedByClick] !== currentFocusedElement) {
411
+ updateFocusedElement(focusableElements[elementIndexFocusedByClick]);
412
+ }
413
+ }
414
+
415
+ elementIndexFocusedByClick = undefined;
416
+ } else {
417
+ // Set tab indexes and internal state based on the focus handling strategy
418
+ if (focusInStrategy === 'previous') {
419
+ updateFocusedElement(event.target);
420
+ } else if (focusInStrategy === 'closest' || focusInStrategy === 'first') {
421
+ if (event.relatedTarget instanceof Element && !container.contains(event.relatedTarget)) {
422
+ // Regardless of the previously focused element, if we're coming from outside the
423
+ // container, put focus onto the first encountered element (from above, it's The
424
+ // first element of the container; from below, it's the last). If the
425
+ // focusInStrategy is set to "first", lastKeyboardFocusDirection will always
426
+ // be undefined.
427
+ const targetElementIndex = lastKeyboardFocusDirection === 'previous' ? focusableElements.length - 1 : 0;
428
+ const targetElement = focusableElements[targetElementIndex];
429
+ targetElement === null || targetElement === void 0 ? void 0 : targetElement.focus();
430
+ return;
431
+ } else {
432
+ updateFocusedElement(event.target);
433
+ }
434
+ } else if (typeof focusInStrategy === 'function') {
435
+ if (event.relatedTarget instanceof Element && !container.contains(event.relatedTarget)) {
436
+ const elementToFocus = focusInStrategy(event.relatedTarget);
437
+ const requestedFocusElementIndex = elementToFocus ? focusableElements.indexOf(elementToFocus) : -1;
438
+
439
+ if (requestedFocusElementIndex >= 0 && elementToFocus instanceof HTMLElement) {
440
+ // Since we are calling focus() this handler will run again synchronously. Therefore,
441
+ // we don't want to let this invocation finish since it will clobber the value of
442
+ // currentFocusedElement.
443
+ elementToFocus.focus();
444
+ return;
445
+ } else {
446
+ // eslint-disable-next-line no-console
447
+ console.warn('Element requested is not a known focusable element.');
448
+ }
449
+ } else {
450
+ updateFocusedElement(event.target);
451
+ }
452
+ }
453
+ }
454
+ }
455
+
456
+ lastKeyboardFocusDirection = undefined;
457
+ }, {
458
+ signal
459
+ });
460
+ }
461
+
462
+ const keyboardEventRecipient = activeDescendantControl !== null && activeDescendantControl !== void 0 ? activeDescendantControl : container; // If the strategy is "closest", we need to capture the direction that the user
463
+ // is trying to move focus before our focusin handler is executed.
464
+
465
+ let lastKeyboardFocusDirection = undefined;
466
+
467
+ if (focusInStrategy === 'closest') {
468
+ document.addEventListener('keydown', event => {
469
+ if (event.key === 'Tab') {
470
+ lastKeyboardFocusDirection = getDirection(event);
471
+ }
472
+ }, {
473
+ signal,
474
+ capture: true
475
+ });
476
+ }
477
+
478
+ function getCurrentFocusedIndex() {
479
+ if (!currentFocusedElement) {
480
+ return 0;
481
+ }
482
+
483
+ const focusedIndex = focusableElements.indexOf(currentFocusedElement);
484
+ const fallbackIndex = currentFocusedElement === container ? -1 : 0;
485
+ return focusedIndex !== -1 ? focusedIndex : fallbackIndex;
486
+ } // "keydown" is the event that triggers DOM focus change, so that is what we use here
487
+
488
+
489
+ keyboardEventRecipient.addEventListener('keydown', event => {
490
+ if (event.key in KEY_TO_DIRECTION) {
491
+ const keyBit = KEY_TO_BIT[event.key]; // Check if the pressed key (keyBit) is one that is being used for focus (bindKeys)
492
+
493
+ if (!event.defaultPrevented && (keyBit & bindKeys) > 0 && !shouldIgnoreFocusHandling(event, document.activeElement)) {
494
+ // Moving forward or backward?
495
+ const direction = getDirection(event);
496
+ let nextElementToFocus = undefined; // If there is a custom function that retrieves the next focusable element, try calling that first.
497
+
498
+ if (settings !== null && settings !== void 0 && settings.getNextFocusable) {
499
+ var _document$activeEleme;
500
+
501
+ nextElementToFocus = settings.getNextFocusable(direction, (_document$activeEleme = document.activeElement) !== null && _document$activeEleme !== void 0 ? _document$activeEleme : undefined, event);
502
+ }
503
+
504
+ if (!nextElementToFocus) {
505
+ const lastFocusedIndex = getCurrentFocusedIndex();
506
+ let nextFocusedIndex = lastFocusedIndex;
507
+
508
+ if (direction === 'previous') {
509
+ nextFocusedIndex -= 1;
510
+ } else if (direction === 'start') {
511
+ nextFocusedIndex = 0;
512
+ } else if (direction === 'next') {
513
+ nextFocusedIndex += 1;
514
+ } else {
515
+ // end
516
+ nextFocusedIndex = focusableElements.length - 1;
517
+ }
518
+
519
+ if (nextFocusedIndex < 0) {
520
+ // Tab should never cause focus to wrap. Use focusTrap for that behavior.
521
+ if (focusOutBehavior === 'wrap' && event.key !== 'Tab') {
522
+ nextFocusedIndex = focusableElements.length - 1;
523
+ } else {
524
+ nextFocusedIndex = 0;
525
+ }
526
+ }
527
+
528
+ if (nextFocusedIndex >= focusableElements.length) {
529
+ if (focusOutBehavior === 'wrap' && event.key !== 'Tab') {
530
+ nextFocusedIndex = 0;
531
+ } else {
532
+ nextFocusedIndex = focusableElements.length - 1;
533
+ }
534
+ }
535
+
536
+ if (lastFocusedIndex !== nextFocusedIndex) {
537
+ nextElementToFocus = focusableElements[nextFocusedIndex];
538
+ }
539
+ }
540
+
541
+ if (activeDescendantControl) {
542
+ updateFocusedElement(nextElementToFocus || currentFocusedElement, true);
543
+ } else if (nextElementToFocus) {
544
+ lastKeyboardFocusDirection = direction; // updateFocusedElement will be called implicitly when focus moves, as long as the event isn't prevented somehow
545
+
546
+ nextElementToFocus.focus();
547
+ } // Tab should always allow escaping from this container, so only
548
+ // preventDefault if tab key press already resulted in a focus movement
549
+
550
+
551
+ if (event.key !== 'Tab' || nextElementToFocus) {
552
+ event.preventDefault();
553
+ }
554
+ }
555
+ }
556
+ }, {
557
+ signal
558
+ });
559
+ return controller;
560
+ }
@@ -0,0 +1 @@
1
+ export declare const scrollIntoViewingArea: (child: HTMLElement, viewingArea: HTMLElement, direction?: 'horizontal' | 'vertical', startMargin?: number, endMargin?: number, behavior?: ScrollBehavior) => void;
@@ -0,0 +1,30 @@
1
+ export const scrollIntoViewingArea = (child, viewingArea, direction = 'vertical', startMargin = 8, endMargin = 0, behavior = 'smooth') => {
2
+ const startSide = direction === 'vertical' ? 'top' : 'left';
3
+ const endSide = direction === 'vertical' ? 'bottom' : 'right';
4
+ const scrollSide = direction === 'vertical' ? 'scrollTop' : 'scrollLeft';
5
+ const {
6
+ [startSide]: childStart,
7
+ [endSide]: childEnd
8
+ } = child.getBoundingClientRect();
9
+ const {
10
+ [startSide]: viewingAreaStart,
11
+ [endSide]: viewingAreaEnd
12
+ } = viewingArea.getBoundingClientRect();
13
+ const isChildStartAboveViewingArea = childStart < viewingAreaStart + endMargin;
14
+ const isChildBottomBelowViewingArea = childEnd > viewingAreaEnd - startMargin;
15
+
16
+ if (isChildStartAboveViewingArea) {
17
+ const scrollHeightToChildStart = childStart - viewingAreaStart + viewingArea[scrollSide];
18
+ viewingArea.scrollTo({
19
+ behavior,
20
+ [startSide]: scrollHeightToChildStart - endMargin
21
+ });
22
+ } else if (isChildBottomBelowViewingArea) {
23
+ const scrollHeightToChildBottom = childEnd - viewingAreaEnd + viewingArea[scrollSide];
24
+ viewingArea.scrollTo({
25
+ behavior,
26
+ [startSide]: scrollHeightToChildBottom + startMargin
27
+ });
28
+ } // either completely in view or outside viewing area on both ends, don't scroll
29
+
30
+ };
@@ -0,0 +1,20 @@
1
+ import * as styledSystem from 'styled-system';
2
+ export declare const get: (key: string) => (props: any) => any;
3
+ export declare const COMMON: styledSystem.styleFn;
4
+ export interface SystemCommonProps extends styledSystem.ColorProps, styledSystem.SpaceProps, styledSystem.DisplayProps {
5
+ }
6
+ export declare const TYPOGRAPHY: styledSystem.styleFn;
7
+ export interface SystemTypographyProps extends styledSystem.TypographyProps {
8
+ whiteSpace?: 'normal' | 'nowrap' | 'pre' | 'pre-wrap' | 'pre-line';
9
+ }
10
+ export declare const BORDER: styledSystem.styleFn;
11
+ export interface SystemBorderProps extends styledSystem.BorderProps, styledSystem.ShadowProps {
12
+ }
13
+ export declare const LAYOUT: styledSystem.styleFn;
14
+ export declare type SystemLayoutProps = styledSystem.LayoutProps;
15
+ export declare const POSITION: styledSystem.styleFn;
16
+ export declare type SystemPositionProps = styledSystem.PositionProps;
17
+ export declare const FLEX: styledSystem.styleFn;
18
+ export declare type SystemFlexProps = styledSystem.FlexboxProps;
19
+ export declare const GRID: styledSystem.styleFn;
20
+ export declare type SystemGridProps = styledSystem.GridProps;
@@ -1,6 +1,5 @@
1
- import systemPropTypes from '@styled-system/prop-types';
2
- import { themeGet } from '@styled-system/theme-get';
3
- import PropTypes from 'prop-types';
1
+ import { themeGet } from '@styled-system/theme-get'; // eslint-disable-next-line import/no-namespace
2
+
4
3
  import * as styledSystem from 'styled-system';
5
4
  import theme from './theme';
6
5
  const {
@@ -11,10 +10,7 @@ const {
11
10
  export const get = key => themeGet(key, getKey(theme, key)); // Common props
12
11
 
13
12
  export const COMMON = compose(styledSystem.space, styledSystem.color, styledSystem.display);
14
- COMMON.propTypes = { ...systemPropTypes.space,
15
- ...systemPropTypes.color
16
- }; // Typography props
17
-
13
+ // Typography props
18
14
  const whiteSpace = system({
19
15
  whiteSpace: {
20
16
  property: 'whiteSpace' // cssProperty: 'whiteSpace',
@@ -22,23 +18,13 @@ const whiteSpace = system({
22
18
  }
23
19
  });
24
20
  export const TYPOGRAPHY = compose(styledSystem.typography, whiteSpace);
25
- TYPOGRAPHY.propTypes = { ...systemPropTypes.typography,
26
- whiteSpace: PropTypes.oneOf(['normal', 'nowrap', 'pre-wrap', 'pre', 'pre-line'])
27
- }; // Border props
28
-
21
+ // Border props
29
22
  export const BORDER = compose(styledSystem.border, styledSystem.shadow);
30
- BORDER.propTypes = { ...systemPropTypes.border,
31
- ...systemPropTypes.shadow
32
- }; // Layout props
33
-
23
+ // Layout props
34
24
  export const LAYOUT = styledSystem.layout;
35
- LAYOUT.propTypes = systemPropTypes.layout; // Position props
36
-
25
+ // Position props
37
26
  export const POSITION = styledSystem.position;
38
- POSITION.propTypes = systemPropTypes.position; // Flex props
39
-
27
+ // Flex props
40
28
  export const FLEX = styledSystem.flexbox;
41
- FLEX.propTypes = systemPropTypes.flexbox; // Grid props
42
-
43
- export const GRID = styledSystem.grid;
44
- GRID.propTypes = systemPropTypes.grid;
29
+ // Grid props
30
+ export const GRID = styledSystem.grid;
@@ -0,0 +1,9 @@
1
+ /** This is the place where we keep components that are not part of the public
2
+ * api yet (not in main bundle). We don't recommend using it in production.
3
+ *
4
+ * But, they are published on npm and you can import them for experimentation/feedback.
5
+ * example: import {ActionList} from '@primer/components/drafts
6
+ */
7
+ export * from './ActionList2';
8
+ export * from './NewButton';
9
+ export * from './ActionMenu2';