@primer/components 0.0.0-2021983515 → 0.0.0-2022530194733

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 (596) hide show
  1. package/CHANGELOG.md +105 -492
  2. package/README.md +16 -16
  3. package/codemods/lib/modifyProps.js +7 -9
  4. package/codemods/lib/prettify.js +1 -1
  5. package/codemods/lib/replaceImportSource.js +5 -5
  6. package/dist/browser.esm.js +889 -1279
  7. package/dist/browser.esm.js.map +1 -1
  8. package/dist/browser.umd.js +839 -1234
  9. package/dist/browser.umd.js.map +1 -1
  10. package/index.d.ts +940 -0
  11. package/lib/AvatarPair.js +5 -6
  12. package/lib/AvatarStack.js +10 -10
  13. package/lib/BaseStyles.js +19 -18
  14. package/lib/BorderBox.js +5 -4
  15. package/lib/Box.js +2 -2
  16. package/lib/BranchName.js +1 -1
  17. package/lib/{Breadcrumbs.js → Breadcrumb.js} +23 -33
  18. package/lib/Button/Button.js +3 -3
  19. package/lib/Button/ButtonClose.js +4 -4
  20. package/lib/Button/ButtonDanger.js +2 -2
  21. package/lib/Button/ButtonInvisible.js +3 -3
  22. package/lib/Button/ButtonOutline.js +2 -2
  23. package/lib/Button/ButtonPrimary.js +2 -2
  24. package/lib/Button/ButtonTableList.js +1 -1
  25. package/lib/CircleBadge.js +1 -1
  26. package/lib/CircleOcticon.js +7 -9
  27. package/lib/CounterLabel.js +2 -2
  28. package/lib/Dialog.js +14 -13
  29. package/lib/Dropdown.js +2 -2
  30. package/lib/DropdownStyles.js +6 -6
  31. package/lib/FilterList.js +1 -1
  32. package/lib/Flash.js +1 -1
  33. package/lib/Flex.js +0 -3
  34. package/lib/Grid.js +3 -4
  35. package/lib/Header.js +2 -3
  36. package/lib/Label.js +4 -4
  37. package/lib/Link.js +12 -1
  38. package/lib/Overlay.js +36 -126
  39. package/lib/Pagehead.js +1 -1
  40. package/lib/Pagination/Pagination.js +2 -3
  41. package/lib/Popover.js +3 -3
  42. package/lib/Portal/Portal.js +12 -20
  43. package/lib/Position.js +27 -46
  44. package/lib/ProgressBar.js +1 -1
  45. package/lib/SelectMenu/SelectMenu.js +4 -4
  46. package/lib/SelectMenu/SelectMenuContext.js +1 -1
  47. package/lib/SelectMenu/SelectMenuDivider.js +3 -3
  48. package/lib/SelectMenu/SelectMenuFilter.js +6 -6
  49. package/lib/SelectMenu/SelectMenuFooter.js +3 -3
  50. package/lib/SelectMenu/SelectMenuHeader.js +2 -2
  51. package/lib/SelectMenu/SelectMenuItem.js +4 -4
  52. package/lib/SelectMenu/SelectMenuList.js +3 -3
  53. package/lib/SelectMenu/SelectMenuLoadingAnimation.js +15 -4
  54. package/lib/SelectMenu/SelectMenuModal.js +7 -7
  55. package/lib/SelectMenu/SelectMenuTab.js +3 -3
  56. package/lib/SelectMenu/SelectMenuTabPanel.js +3 -3
  57. package/lib/SelectMenu/SelectMenuTabs.js +2 -2
  58. package/lib/SelectMenu/hooks/useKeyboardNav.js +0 -2
  59. package/lib/SideNav.js +12 -20
  60. package/lib/StateLabel.js +4 -4
  61. package/lib/SubNav.js +3 -5
  62. package/lib/TabNav.js +3 -3
  63. package/lib/TextInput.js +59 -22
  64. package/lib/ThemeProvider.js +15 -32
  65. package/lib/Timeline.js +29 -24
  66. package/lib/Tooltip.js +1 -2
  67. package/lib/UnderlineNav.js +2 -2
  68. package/lib/behaviors/anchoredPosition.js +9 -17
  69. package/lib/behaviors/focusTrap.js +14 -32
  70. package/lib/behaviors/focusZone.js +148 -218
  71. package/lib/constants.js +2 -3
  72. package/lib/hooks/index.js +1 -9
  73. package/lib/hooks/useAnchoredPosition.js +4 -11
  74. package/lib/hooks/useDialog.js +1 -1
  75. package/lib/hooks/useFocusTrap.js +8 -26
  76. package/lib/hooks/useFocusZone.js +7 -7
  77. package/lib/hooks/useMouseIntent.js +58 -0
  78. package/lib/hooks/useOnEscapePress.js +10 -53
  79. package/lib/hooks/useOnOutsideClick.js +35 -62
  80. package/lib/hooks/useOpenAndCloseFocus.js +3 -8
  81. package/lib/hooks/useOverlay.js +19 -9
  82. package/lib/hooks/useSafeTimeout.js +0 -1
  83. package/lib/index.js +12 -112
  84. package/lib/polyfills/eventListenerSignal.js +1 -6
  85. package/lib/stories/Button.stories.js +114 -0
  86. package/lib/stories/Overlay.stories.js +102 -0
  87. package/lib/stories/Portal.stories.js +108 -0
  88. package/lib/stories/ThemeProvider.stories.js +95 -0
  89. package/lib/stories/useAnchoredPosition.stories.js +349 -0
  90. package/lib/stories/useFocusTrap.stories.js +278 -0
  91. package/lib/stories/useFocusZone.stories.js +490 -0
  92. package/lib/theme-preval.js +2057 -5148
  93. package/lib/utils/deprecate.js +2 -3
  94. package/lib/utils/isNumeric.js +0 -1
  95. package/lib/utils/iterateFocusableElements.js +1 -1
  96. package/lib/utils/test-deprecations.js +0 -1
  97. package/lib/utils/test-matchers.js +12 -3
  98. package/lib/utils/testing.js +4 -4
  99. package/lib/utils/theme.js +1 -1
  100. package/lib/utils/{types/AriaRole.js → types.js} +0 -0
  101. package/lib/utils/uniqueId.js +0 -1
  102. package/lib-esm/AvatarPair.js +5 -6
  103. package/lib-esm/AvatarStack.js +11 -11
  104. package/lib-esm/BaseStyles.js +16 -16
  105. package/lib-esm/BorderBox.js +3 -5
  106. package/lib-esm/Box.js +2 -2
  107. package/lib-esm/BranchName.js +1 -1
  108. package/lib-esm/{Breadcrumbs.js → Breadcrumb.js} +22 -32
  109. package/lib-esm/Button/Button.js +1 -1
  110. package/lib-esm/Button/ButtonClose.js +2 -2
  111. package/lib-esm/Button/ButtonInvisible.js +1 -1
  112. package/lib-esm/Button/ButtonTableList.js +1 -1
  113. package/lib-esm/CircleBadge.js +1 -1
  114. package/lib-esm/CircleOcticon.js +6 -9
  115. package/lib-esm/CounterLabel.js +2 -2
  116. package/lib-esm/Dialog.js +12 -10
  117. package/lib-esm/Dropdown.js +2 -2
  118. package/lib-esm/DropdownStyles.js +6 -6
  119. package/lib-esm/FilterList.js +1 -1
  120. package/lib-esm/Flash.js +1 -1
  121. package/lib-esm/Flex.js +0 -4
  122. package/lib-esm/Grid.js +2 -5
  123. package/lib-esm/Header.js +0 -1
  124. package/lib-esm/Label.js +2 -2
  125. package/lib-esm/Link.js +12 -1
  126. package/lib-esm/Overlay.js +38 -119
  127. package/lib-esm/Pagehead.js +1 -1
  128. package/lib-esm/Pagination/Pagination.js +2 -3
  129. package/lib-esm/Popover.js +3 -3
  130. package/lib-esm/Portal/Portal.js +12 -19
  131. package/lib-esm/Portal/index.js +1 -1
  132. package/lib-esm/Position.js +20 -45
  133. package/lib-esm/ProgressBar.js +1 -1
  134. package/lib-esm/SelectMenu/SelectMenu.js +3 -3
  135. package/lib-esm/SelectMenu/SelectMenuContext.js +1 -1
  136. package/lib-esm/SelectMenu/SelectMenuDivider.js +1 -1
  137. package/lib-esm/SelectMenu/SelectMenuFilter.js +4 -4
  138. package/lib-esm/SelectMenu/SelectMenuFooter.js +1 -1
  139. package/lib-esm/SelectMenu/SelectMenuHeader.js +2 -2
  140. package/lib-esm/SelectMenu/SelectMenuItem.js +2 -2
  141. package/lib-esm/SelectMenu/SelectMenuList.js +1 -1
  142. package/lib-esm/SelectMenu/SelectMenuLoadingAnimation.js +10 -5
  143. package/lib-esm/SelectMenu/SelectMenuModal.js +5 -5
  144. package/lib-esm/SelectMenu/SelectMenuTab.js +1 -1
  145. package/lib-esm/SelectMenu/SelectMenuTabPanel.js +1 -1
  146. package/lib-esm/SelectMenu/hooks/useKeyboardNav.js +0 -2
  147. package/lib-esm/SideNav.js +7 -16
  148. package/lib-esm/StateLabel.js +4 -4
  149. package/lib-esm/SubNav.js +4 -7
  150. package/lib-esm/TabNav.js +4 -5
  151. package/lib-esm/TextInput.js +49 -22
  152. package/lib-esm/ThemeProvider.js +16 -31
  153. package/lib-esm/Timeline.js +24 -19
  154. package/lib-esm/Tooltip.js +1 -2
  155. package/lib-esm/UnderlineNav.js +3 -4
  156. package/lib-esm/behaviors/anchoredPosition.js +9 -17
  157. package/lib-esm/behaviors/focusTrap.js +14 -32
  158. package/lib-esm/behaviors/focusZone.js +148 -213
  159. package/lib-esm/constants.js +1 -2
  160. package/lib-esm/hooks/index.js +1 -2
  161. package/lib-esm/hooks/useAnchoredPosition.js +5 -10
  162. package/lib-esm/hooks/useDialog.js +1 -1
  163. package/lib-esm/hooks/useFocusTrap.js +8 -25
  164. package/lib-esm/hooks/useFocusZone.js +5 -5
  165. package/lib-esm/hooks/useMouseIntent.js +50 -0
  166. package/lib-esm/hooks/useOnEscapePress.js +10 -53
  167. package/lib-esm/hooks/useOnOutsideClick.js +37 -62
  168. package/lib-esm/hooks/useOpenAndCloseFocus.js +3 -8
  169. package/lib-esm/hooks/useOverlay.js +18 -9
  170. package/lib-esm/hooks/useSafeTimeout.js +0 -1
  171. package/lib-esm/index.js +10 -22
  172. package/lib-esm/polyfills/eventListenerSignal.js +1 -6
  173. package/lib-esm/stories/Button.stories.js +79 -0
  174. package/lib-esm/stories/Overlay.stories.js +80 -0
  175. package/lib-esm/stories/Portal.stories.js +72 -0
  176. package/lib-esm/stories/ThemeProvider.stories.js +76 -0
  177. package/lib-esm/stories/useAnchoredPosition.stories.js +311 -0
  178. package/lib-esm/stories/useFocusTrap.stories.js +234 -0
  179. package/lib-esm/stories/useFocusZone.stories.js +445 -0
  180. package/lib-esm/theme-preval.js +2057 -5148
  181. package/lib-esm/utils/deprecate.js +2 -3
  182. package/lib-esm/utils/isNumeric.js +0 -1
  183. package/lib-esm/utils/iterateFocusableElements.js +1 -1
  184. package/lib-esm/utils/test-deprecations.js +1 -1
  185. package/lib-esm/utils/test-matchers.js +11 -3
  186. package/lib-esm/utils/testing.js +6 -6
  187. package/lib-esm/utils/theme.js +1 -1
  188. package/lib-esm/utils/{test-helpers.d.ts → types.js} +0 -0
  189. package/lib-esm/utils/uniqueId.js +0 -1
  190. package/package.json +95 -103
  191. package/codemods/__tests__/deprecateUtilityComponents.js +0 -200
  192. package/codemods/__tests__/removeSystemProps.js +0 -225
  193. package/codemods/deprecateUtilityComponents.js +0 -111
  194. package/codemods/removeSystemProps.js +0 -312
  195. package/lib/ActionList/Divider.d.ts +0 -9
  196. package/lib/ActionList/Divider.js +0 -40
  197. package/lib/ActionList/Group.d.ts +0 -28
  198. package/lib/ActionList/Group.js +0 -35
  199. package/lib/ActionList/Header.d.ts +0 -29
  200. package/lib/ActionList/Header.js +0 -51
  201. package/lib/ActionList/Item.d.ts +0 -92
  202. package/lib/ActionList/Item.js +0 -288
  203. package/lib/ActionList/List.d.ts +0 -88
  204. package/lib/ActionList/List.js +0 -199
  205. package/lib/ActionList/index.d.ts +0 -17
  206. package/lib/ActionList/index.js +0 -29
  207. package/lib/ActionMenu.d.ts +0 -40
  208. package/lib/ActionMenu.js +0 -103
  209. package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +0 -62
  210. package/lib/AnchoredOverlay/AnchoredOverlay.js +0 -124
  211. package/lib/AnchoredOverlay/index.d.ts +0 -2
  212. package/lib/AnchoredOverlay/index.js +0 -13
  213. package/lib/Autocomplete/Autocomplete.d.ts +0 -40
  214. package/lib/Autocomplete/Autocomplete.js +0 -68
  215. package/lib/Autocomplete/AutocompleteContext.d.ts +0 -17
  216. package/lib/Autocomplete/AutocompleteContext.js +0 -11
  217. package/lib/Autocomplete/AutocompleteInput.d.ts +0 -9
  218. package/lib/Autocomplete/AutocompleteInput.js +0 -150
  219. package/lib/Autocomplete/AutocompleteMenu.d.ts +0 -71
  220. package/lib/Autocomplete/AutocompleteMenu.js +0 -223
  221. package/lib/Autocomplete/AutocompleteOverlay.d.ts +0 -17
  222. package/lib/Autocomplete/AutocompleteOverlay.js +0 -69
  223. package/lib/Autocomplete/index.d.ts +0 -2
  224. package/lib/Autocomplete/index.js +0 -15
  225. package/lib/Avatar.d.ts +0 -15
  226. package/lib/AvatarPair.d.ts +0 -8
  227. package/lib/AvatarStack.d.ts +0 -8
  228. package/lib/BaseStyles.d.ts +0 -14
  229. package/lib/BorderBox.d.ts +0 -7
  230. package/lib/Box.d.ts +0 -6
  231. package/lib/BranchName.d.ts +0 -6
  232. package/lib/Breadcrumbs.d.ts +0 -40
  233. package/lib/Button/Button.d.ts +0 -284
  234. package/lib/Button/ButtonBase.d.ts +0 -12
  235. package/lib/Button/ButtonClose.d.ts +0 -321
  236. package/lib/Button/ButtonDanger.d.ts +0 -284
  237. package/lib/Button/ButtonGroup.d.ts +0 -4
  238. package/lib/Button/ButtonInvisible.d.ts +0 -284
  239. package/lib/Button/ButtonOutline.d.ts +0 -284
  240. package/lib/Button/ButtonPrimary.d.ts +0 -284
  241. package/lib/Button/ButtonStyles.d.ts +0 -2
  242. package/lib/Button/ButtonTableList.d.ts +0 -6
  243. package/lib/Button/index.d.ts +0 -16
  244. package/lib/Caret.d.ts +0 -21
  245. package/lib/CircleBadge.d.ts +0 -25
  246. package/lib/CircleOcticon.d.ts +0 -391
  247. package/lib/CounterLabel.d.ts +0 -8
  248. package/lib/Details.d.ts +0 -6
  249. package/lib/Dialog/ConfirmationDialog.d.ts +0 -44
  250. package/lib/Dialog/ConfirmationDialog.js +0 -191
  251. package/lib/Dialog/Dialog.d.ts +0 -167
  252. package/lib/Dialog/Dialog.js +0 -304
  253. package/lib/Dialog.d.ts +0 -406
  254. package/lib/Dropdown.d.ts +0 -1262
  255. package/lib/DropdownMenu/DropdownButton.d.ts +0 -323
  256. package/lib/DropdownMenu/DropdownButton.js +0 -31
  257. package/lib/DropdownMenu/DropdownMenu.d.ts +0 -43
  258. package/lib/DropdownMenu/DropdownMenu.js +0 -94
  259. package/lib/DropdownMenu/index.d.ts +0 -4
  260. package/lib/DropdownMenu/index.js +0 -21
  261. package/lib/DropdownStyles.d.ts +0 -3
  262. package/lib/FilterList.d.ts +0 -321
  263. package/lib/FilteredActionList/FilteredActionList.d.ts +0 -16
  264. package/lib/FilteredActionList/FilteredActionList.js +0 -137
  265. package/lib/FilteredActionList/index.d.ts +0 -2
  266. package/lib/FilteredActionList/index.js +0 -13
  267. package/lib/FilteredSearch.d.ts +0 -6
  268. package/lib/Flash.d.ts +0 -9
  269. package/lib/Flex.d.ts +0 -7
  270. package/lib/FormGroup.d.ts +0 -12
  271. package/lib/Grid.d.ts +0 -7
  272. package/lib/Header.d.ts +0 -24
  273. package/lib/Heading.d.ts +0 -6
  274. package/lib/Label.d.ts +0 -11
  275. package/lib/LabelGroup.d.ts +0 -6
  276. package/lib/Link.d.ts +0 -10
  277. package/lib/Overlay.d.ts +0 -63
  278. package/lib/Pagehead.d.ts +0 -6
  279. package/lib/Pagination/Pagination.d.ts +0 -24
  280. package/lib/Pagination/index.d.ts +0 -3
  281. package/lib/Pagination/model.d.ts +0 -26
  282. package/lib/PointerBox.d.ts +0 -11
  283. package/lib/Popover.d.ts +0 -21
  284. package/lib/Portal/Portal.d.ts +0 -25
  285. package/lib/Portal/index.d.ts +0 -4
  286. package/lib/Position.d.ts +0 -34
  287. package/lib/ProgressBar.d.ts +0 -21
  288. package/lib/SelectMenu/SelectMenu.d.ts +0 -1832
  289. package/lib/SelectMenu/SelectMenuContext.d.ts +0 -8
  290. package/lib/SelectMenu/SelectMenuDivider.d.ts +0 -6
  291. package/lib/SelectMenu/SelectMenuFilter.d.ts +0 -9
  292. package/lib/SelectMenu/SelectMenuFooter.d.ts +0 -6
  293. package/lib/SelectMenu/SelectMenuHeader.d.ts +0 -11
  294. package/lib/SelectMenu/SelectMenuItem.d.ts +0 -15
  295. package/lib/SelectMenu/SelectMenuList.d.ts +0 -6
  296. package/lib/SelectMenu/SelectMenuLoadingAnimation.d.ts +0 -7
  297. package/lib/SelectMenu/SelectMenuModal.d.ts +0 -15
  298. package/lib/SelectMenu/SelectMenuTab.d.ts +0 -14
  299. package/lib/SelectMenu/SelectMenuTabPanel.d.ts +0 -13
  300. package/lib/SelectMenu/SelectMenuTabs.d.ts +0 -11
  301. package/lib/SelectMenu/hooks/useKeyboardNav.d.ts +0 -2
  302. package/lib/SelectMenu/index.d.ts +0 -2
  303. package/lib/SelectPanel/SelectPanel.d.ts +0 -25
  304. package/lib/SelectPanel/SelectPanel.js +0 -147
  305. package/lib/SelectPanel/index.d.ts +0 -2
  306. package/lib/SelectPanel/index.js +0 -13
  307. package/lib/SideNav.d.ts +0 -31
  308. package/lib/Spinner.d.ts +0 -17
  309. package/lib/Spinner.js +0 -60
  310. package/lib/StateLabel.d.ts +0 -16
  311. package/lib/StyledOcticon.d.ts +0 -12
  312. package/lib/SubNav.d.ts +0 -32
  313. package/lib/TabNav.d.ts +0 -20
  314. package/lib/Text.d.ts +0 -6
  315. package/lib/TextInput.d.ts +0 -14
  316. package/lib/TextInputWithTokens.d.ts +0 -323
  317. package/lib/TextInputWithTokens.js +0 -244
  318. package/lib/ThemeProvider.d.ts +0 -26
  319. package/lib/Timeline.d.ts +0 -407
  320. package/lib/Token/IssueLabelToken.d.ts +0 -14
  321. package/lib/Token/IssueLabelToken.js +0 -144
  322. package/lib/Token/ProfileToken.d.ts +0 -7
  323. package/lib/Token/ProfileToken.js +0 -53
  324. package/lib/Token/Token.d.ts +0 -15
  325. package/lib/Token/Token.js +0 -94
  326. package/lib/Token/TokenBase.d.ts +0 -17
  327. package/lib/Token/TokenBase.js +0 -108
  328. package/lib/Token/_RemoveTokenButton.d.ts +0 -12
  329. package/lib/Token/_RemoveTokenButton.js +0 -77
  330. package/lib/Token/_TokenTextContainer.d.ts +0 -3
  331. package/lib/Token/_TokenTextContainer.js +0 -28
  332. package/lib/Token/index.d.ts +0 -3
  333. package/lib/Token/index.js +0 -31
  334. package/lib/Tooltip.d.ts +0 -18
  335. package/lib/Truncate.d.ts +0 -11
  336. package/lib/UnderlineNav.d.ts +0 -25
  337. package/lib/_TextInputWrapper.d.ts +0 -10
  338. package/lib/_TextInputWrapper.js +0 -51
  339. package/lib/_UnstyledTextInput.d.ts +0 -2
  340. package/lib/_UnstyledTextInput.js +0 -20
  341. package/lib/behaviors/anchoredPosition.d.ts +0 -89
  342. package/lib/behaviors/focusTrap.d.ts +0 -12
  343. package/lib/behaviors/focusZone.d.ts +0 -137
  344. package/lib/constants.d.ts +0 -20
  345. package/lib/hooks/index.d.ts +0 -11
  346. package/lib/hooks/useAnchoredPosition.d.ts +0 -20
  347. package/lib/hooks/useCombinedRefs.d.ts +0 -10
  348. package/lib/hooks/useCombinedRefs.js +0 -49
  349. package/lib/hooks/useDetails.d.ts +0 -17
  350. package/lib/hooks/useDialog.d.ts +0 -16
  351. package/lib/hooks/useFocusTrap.d.ts +0 -32
  352. package/lib/hooks/useFocusZone.d.ts +0 -23
  353. package/lib/hooks/useOnEscapePress.d.ts +0 -23
  354. package/lib/hooks/useOnOutsideClick.d.ts +0 -8
  355. package/lib/hooks/useOpenAndCloseFocus.d.ts +0 -8
  356. package/lib/hooks/useOverlay.d.ts +0 -15
  357. package/lib/hooks/useProvidedRefOrCreate.d.ts +0 -10
  358. package/lib/hooks/useProvidedStateOrCreate.d.ts +0 -10
  359. package/lib/hooks/useProvidedStateOrCreate.js +0 -27
  360. package/lib/hooks/useRenderForcingRef.d.ts +0 -8
  361. package/lib/hooks/useRenderForcingRef.js +0 -25
  362. package/lib/hooks/useResizeObserver.d.ts +0 -1
  363. package/lib/hooks/useResizeObserver.js +0 -20
  364. package/lib/hooks/useSafeTimeout.d.ts +0 -12
  365. package/lib/hooks/useScrollFlash.d.ts +0 -6
  366. package/lib/hooks/useScrollFlash.js +0 -29
  367. package/lib/index.d.ts +0 -114
  368. package/lib/polyfills/eventListenerSignal.d.ts +0 -6
  369. package/lib/sx.d.ts +0 -6
  370. package/lib/theme-preval.d.ts +0 -49
  371. package/lib/theme.d.ts +0 -2
  372. package/lib/utils/deprecate.d.ts +0 -18
  373. package/lib/utils/isNumeric.d.ts +0 -1
  374. package/lib/utils/iterateFocusableElements.d.ts +0 -42
  375. package/lib/utils/scrollIntoViewingArea.d.ts +0 -1
  376. package/lib/utils/scrollIntoViewingArea.js +0 -39
  377. package/lib/utils/ssr.d.ts +0 -1
  378. package/lib/utils/ssr.js +0 -19
  379. package/lib/utils/test-deprecations.d.ts +0 -1
  380. package/lib/utils/test-helpers.d.ts +0 -0
  381. package/lib/utils/test-helpers.js +0 -9
  382. package/lib/utils/test-matchers.d.ts +0 -1
  383. package/lib/utils/testing.d.ts +0 -1028
  384. package/lib/utils/theme.d.ts +0 -9
  385. package/lib/utils/types/AriaRole.d.ts +0 -4
  386. package/lib/utils/types/ComponentProps.d.ts +0 -9
  387. package/lib/utils/types/ComponentProps.js +0 -1
  388. package/lib/utils/types/Flatten.d.ts +0 -4
  389. package/lib/utils/types/Flatten.js +0 -1
  390. package/lib/utils/types/Merge.d.ts +0 -19
  391. package/lib/utils/types/Merge.js +0 -1
  392. package/lib/utils/types/index.d.ts +0 -4
  393. package/lib/utils/types/index.js +0 -57
  394. package/lib/utils/uniqueId.d.ts +0 -1
  395. package/lib/utils/userAgent.d.ts +0 -1
  396. package/lib-esm/ActionList/Divider.d.ts +0 -9
  397. package/lib-esm/ActionList/Divider.js +0 -23
  398. package/lib-esm/ActionList/Group.d.ts +0 -28
  399. package/lib-esm/ActionList/Group.js +0 -24
  400. package/lib-esm/ActionList/Header.d.ts +0 -29
  401. package/lib-esm/ActionList/Header.js +0 -33
  402. package/lib-esm/ActionList/Item.d.ts +0 -92
  403. package/lib-esm/ActionList/Item.js +0 -253
  404. package/lib-esm/ActionList/List.d.ts +0 -88
  405. package/lib-esm/ActionList/List.js +0 -181
  406. package/lib-esm/ActionList/index.d.ts +0 -17
  407. package/lib-esm/ActionList/index.js +0 -18
  408. package/lib-esm/ActionMenu.d.ts +0 -40
  409. package/lib-esm/ActionMenu.js +0 -82
  410. package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +0 -62
  411. package/lib-esm/AnchoredOverlay/AnchoredOverlay.js +0 -104
  412. package/lib-esm/AnchoredOverlay/index.d.ts +0 -2
  413. package/lib-esm/AnchoredOverlay/index.js +0 -1
  414. package/lib-esm/Autocomplete/Autocomplete.d.ts +0 -40
  415. package/lib-esm/Autocomplete/Autocomplete.js +0 -47
  416. package/lib-esm/Autocomplete/AutocompleteContext.d.ts +0 -17
  417. package/lib-esm/Autocomplete/AutocompleteContext.js +0 -2
  418. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +0 -9
  419. package/lib-esm/Autocomplete/AutocompleteInput.js +0 -131
  420. package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +0 -71
  421. package/lib-esm/Autocomplete/AutocompleteMenu.js +0 -204
  422. package/lib-esm/Autocomplete/AutocompleteOverlay.d.ts +0 -17
  423. package/lib-esm/Autocomplete/AutocompleteOverlay.js +0 -51
  424. package/lib-esm/Autocomplete/index.d.ts +0 -2
  425. package/lib-esm/Autocomplete/index.js +0 -1
  426. package/lib-esm/Avatar.d.ts +0 -15
  427. package/lib-esm/AvatarPair.d.ts +0 -8
  428. package/lib-esm/AvatarStack.d.ts +0 -8
  429. package/lib-esm/BaseStyles.d.ts +0 -14
  430. package/lib-esm/BorderBox.d.ts +0 -7
  431. package/lib-esm/Box.d.ts +0 -6
  432. package/lib-esm/BranchName.d.ts +0 -6
  433. package/lib-esm/Breadcrumbs.d.ts +0 -40
  434. package/lib-esm/Button/Button.d.ts +0 -284
  435. package/lib-esm/Button/ButtonBase.d.ts +0 -12
  436. package/lib-esm/Button/ButtonClose.d.ts +0 -321
  437. package/lib-esm/Button/ButtonDanger.d.ts +0 -284
  438. package/lib-esm/Button/ButtonGroup.d.ts +0 -4
  439. package/lib-esm/Button/ButtonInvisible.d.ts +0 -284
  440. package/lib-esm/Button/ButtonOutline.d.ts +0 -284
  441. package/lib-esm/Button/ButtonPrimary.d.ts +0 -284
  442. package/lib-esm/Button/ButtonStyles.d.ts +0 -2
  443. package/lib-esm/Button/ButtonTableList.d.ts +0 -6
  444. package/lib-esm/Button/index.d.ts +0 -16
  445. package/lib-esm/Caret.d.ts +0 -21
  446. package/lib-esm/CircleBadge.d.ts +0 -25
  447. package/lib-esm/CircleOcticon.d.ts +0 -391
  448. package/lib-esm/CounterLabel.d.ts +0 -8
  449. package/lib-esm/Details.d.ts +0 -6
  450. package/lib-esm/Dialog/ConfirmationDialog.d.ts +0 -44
  451. package/lib-esm/Dialog/ConfirmationDialog.js +0 -169
  452. package/lib-esm/Dialog/Dialog.d.ts +0 -167
  453. package/lib-esm/Dialog/Dialog.js +0 -274
  454. package/lib-esm/Dialog.d.ts +0 -406
  455. package/lib-esm/Dropdown.d.ts +0 -1262
  456. package/lib-esm/DropdownMenu/DropdownButton.d.ts +0 -323
  457. package/lib-esm/DropdownMenu/DropdownButton.js +0 -16
  458. package/lib-esm/DropdownMenu/DropdownMenu.d.ts +0 -43
  459. package/lib-esm/DropdownMenu/DropdownMenu.js +0 -77
  460. package/lib-esm/DropdownMenu/index.d.ts +0 -4
  461. package/lib-esm/DropdownMenu/index.js +0 -2
  462. package/lib-esm/DropdownStyles.d.ts +0 -3
  463. package/lib-esm/FilterList.d.ts +0 -321
  464. package/lib-esm/FilteredActionList/FilteredActionList.d.ts +0 -16
  465. package/lib-esm/FilteredActionList/FilteredActionList.js +0 -109
  466. package/lib-esm/FilteredActionList/index.d.ts +0 -2
  467. package/lib-esm/FilteredActionList/index.js +0 -1
  468. package/lib-esm/FilteredSearch.d.ts +0 -6
  469. package/lib-esm/Flash.d.ts +0 -9
  470. package/lib-esm/Flex.d.ts +0 -7
  471. package/lib-esm/FormGroup.d.ts +0 -12
  472. package/lib-esm/Grid.d.ts +0 -7
  473. package/lib-esm/Header.d.ts +0 -24
  474. package/lib-esm/Heading.d.ts +0 -6
  475. package/lib-esm/Label.d.ts +0 -11
  476. package/lib-esm/LabelGroup.d.ts +0 -6
  477. package/lib-esm/Link.d.ts +0 -10
  478. package/lib-esm/Overlay.d.ts +0 -63
  479. package/lib-esm/Pagehead.d.ts +0 -6
  480. package/lib-esm/Pagination/Pagination.d.ts +0 -24
  481. package/lib-esm/Pagination/index.d.ts +0 -3
  482. package/lib-esm/Pagination/model.d.ts +0 -26
  483. package/lib-esm/PointerBox.d.ts +0 -11
  484. package/lib-esm/Popover.d.ts +0 -21
  485. package/lib-esm/Portal/Portal.d.ts +0 -25
  486. package/lib-esm/Portal/index.d.ts +0 -4
  487. package/lib-esm/Position.d.ts +0 -34
  488. package/lib-esm/ProgressBar.d.ts +0 -21
  489. package/lib-esm/SelectMenu/SelectMenu.d.ts +0 -1832
  490. package/lib-esm/SelectMenu/SelectMenuContext.d.ts +0 -8
  491. package/lib-esm/SelectMenu/SelectMenuDivider.d.ts +0 -6
  492. package/lib-esm/SelectMenu/SelectMenuFilter.d.ts +0 -9
  493. package/lib-esm/SelectMenu/SelectMenuFooter.d.ts +0 -6
  494. package/lib-esm/SelectMenu/SelectMenuHeader.d.ts +0 -11
  495. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +0 -15
  496. package/lib-esm/SelectMenu/SelectMenuList.d.ts +0 -6
  497. package/lib-esm/SelectMenu/SelectMenuLoadingAnimation.d.ts +0 -7
  498. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +0 -15
  499. package/lib-esm/SelectMenu/SelectMenuTab.d.ts +0 -14
  500. package/lib-esm/SelectMenu/SelectMenuTabPanel.d.ts +0 -13
  501. package/lib-esm/SelectMenu/SelectMenuTabs.d.ts +0 -11
  502. package/lib-esm/SelectMenu/hooks/useKeyboardNav.d.ts +0 -2
  503. package/lib-esm/SelectMenu/index.d.ts +0 -2
  504. package/lib-esm/SelectPanel/SelectPanel.d.ts +0 -25
  505. package/lib-esm/SelectPanel/SelectPanel.js +0 -127
  506. package/lib-esm/SelectPanel/index.d.ts +0 -2
  507. package/lib-esm/SelectPanel/index.js +0 -1
  508. package/lib-esm/SideNav.d.ts +0 -31
  509. package/lib-esm/Spinner.d.ts +0 -17
  510. package/lib-esm/Spinner.js +0 -46
  511. package/lib-esm/StateLabel.d.ts +0 -16
  512. package/lib-esm/StyledOcticon.d.ts +0 -12
  513. package/lib-esm/SubNav.d.ts +0 -32
  514. package/lib-esm/TabNav.d.ts +0 -20
  515. package/lib-esm/Text.d.ts +0 -6
  516. package/lib-esm/TextInput.d.ts +0 -14
  517. package/lib-esm/TextInputWithTokens.d.ts +0 -323
  518. package/lib-esm/TextInputWithTokens.js +0 -219
  519. package/lib-esm/ThemeProvider.d.ts +0 -26
  520. package/lib-esm/Timeline.d.ts +0 -407
  521. package/lib-esm/Token/IssueLabelToken.d.ts +0 -14
  522. package/lib-esm/Token/IssueLabelToken.js +0 -124
  523. package/lib-esm/Token/ProfileToken.d.ts +0 -7
  524. package/lib-esm/Token/ProfileToken.js +0 -33
  525. package/lib-esm/Token/Token.d.ts +0 -15
  526. package/lib-esm/Token/Token.js +0 -73
  527. package/lib-esm/Token/TokenBase.d.ts +0 -17
  528. package/lib-esm/Token/TokenBase.js +0 -87
  529. package/lib-esm/Token/_RemoveTokenButton.d.ts +0 -12
  530. package/lib-esm/Token/_RemoveTokenButton.js +0 -60
  531. package/lib-esm/Token/_TokenTextContainer.d.ts +0 -3
  532. package/lib-esm/Token/_TokenTextContainer.js +0 -15
  533. package/lib-esm/Token/index.d.ts +0 -3
  534. package/lib-esm/Token/index.js +0 -3
  535. package/lib-esm/Tooltip.d.ts +0 -18
  536. package/lib-esm/Truncate.d.ts +0 -11
  537. package/lib-esm/UnderlineNav.d.ts +0 -25
  538. package/lib-esm/_TextInputWrapper.d.ts +0 -10
  539. package/lib-esm/_TextInputWrapper.js +0 -31
  540. package/lib-esm/_UnstyledTextInput.d.ts +0 -2
  541. package/lib-esm/_UnstyledTextInput.js +0 -7
  542. package/lib-esm/behaviors/anchoredPosition.d.ts +0 -89
  543. package/lib-esm/behaviors/focusTrap.d.ts +0 -12
  544. package/lib-esm/behaviors/focusZone.d.ts +0 -137
  545. package/lib-esm/constants.d.ts +0 -20
  546. package/lib-esm/hooks/index.d.ts +0 -11
  547. package/lib-esm/hooks/useAnchoredPosition.d.ts +0 -20
  548. package/lib-esm/hooks/useCombinedRefs.d.ts +0 -10
  549. package/lib-esm/hooks/useCombinedRefs.js +0 -36
  550. package/lib-esm/hooks/useDetails.d.ts +0 -17
  551. package/lib-esm/hooks/useDialog.d.ts +0 -16
  552. package/lib-esm/hooks/useFocusTrap.d.ts +0 -32
  553. package/lib-esm/hooks/useFocusZone.d.ts +0 -23
  554. package/lib-esm/hooks/useOnEscapePress.d.ts +0 -23
  555. package/lib-esm/hooks/useOnOutsideClick.d.ts +0 -8
  556. package/lib-esm/hooks/useOpenAndCloseFocus.d.ts +0 -8
  557. package/lib-esm/hooks/useOverlay.d.ts +0 -15
  558. package/lib-esm/hooks/useProvidedRefOrCreate.d.ts +0 -10
  559. package/lib-esm/hooks/useProvidedStateOrCreate.d.ts +0 -10
  560. package/lib-esm/hooks/useProvidedStateOrCreate.js +0 -20
  561. package/lib-esm/hooks/useRenderForcingRef.d.ts +0 -8
  562. package/lib-esm/hooks/useRenderForcingRef.js +0 -18
  563. package/lib-esm/hooks/useResizeObserver.d.ts +0 -1
  564. package/lib-esm/hooks/useResizeObserver.js +0 -10
  565. package/lib-esm/hooks/useSafeTimeout.d.ts +0 -12
  566. package/lib-esm/hooks/useScrollFlash.d.ts +0 -6
  567. package/lib-esm/hooks/useScrollFlash.js +0 -22
  568. package/lib-esm/index.d.ts +0 -114
  569. package/lib-esm/polyfills/eventListenerSignal.d.ts +0 -6
  570. package/lib-esm/sx.d.ts +0 -6
  571. package/lib-esm/theme-preval.d.ts +0 -49
  572. package/lib-esm/theme.d.ts +0 -2
  573. package/lib-esm/utils/deprecate.d.ts +0 -18
  574. package/lib-esm/utils/isNumeric.d.ts +0 -1
  575. package/lib-esm/utils/iterateFocusableElements.d.ts +0 -42
  576. package/lib-esm/utils/scrollIntoViewingArea.d.ts +0 -1
  577. package/lib-esm/utils/scrollIntoViewingArea.js +0 -30
  578. package/lib-esm/utils/ssr.d.ts +0 -1
  579. package/lib-esm/utils/ssr.js +0 -1
  580. package/lib-esm/utils/test-deprecations.d.ts +0 -1
  581. package/lib-esm/utils/test-helpers.js +0 -7
  582. package/lib-esm/utils/test-matchers.d.ts +0 -1
  583. package/lib-esm/utils/testing.d.ts +0 -1028
  584. package/lib-esm/utils/theme.d.ts +0 -9
  585. package/lib-esm/utils/types/AriaRole.d.ts +0 -4
  586. package/lib-esm/utils/types/AriaRole.js +0 -1
  587. package/lib-esm/utils/types/ComponentProps.d.ts +0 -9
  588. package/lib-esm/utils/types/ComponentProps.js +0 -1
  589. package/lib-esm/utils/types/Flatten.d.ts +0 -4
  590. package/lib-esm/utils/types/Flatten.js +0 -1
  591. package/lib-esm/utils/types/Merge.d.ts +0 -19
  592. package/lib-esm/utils/types/Merge.js +0 -1
  593. package/lib-esm/utils/types/index.d.ts +0 -4
  594. package/lib-esm/utils/types/index.js +0 -4
  595. package/lib-esm/utils/uniqueId.d.ts +0 -1
  596. package/lib-esm/utils/userAgent.d.ts +0 -1
@@ -1,191 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useConfirm = useConfirm;
7
- exports.ConfirmationDialog = void 0;
8
-
9
- var _react = _interopRequireWildcard(require("react"));
10
-
11
- var _reactDom = _interopRequireDefault(require("react-dom"));
12
-
13
- var _styledComponents = _interopRequireDefault(require("styled-components"));
14
-
15
- var _Box = _interopRequireDefault(require("../Box"));
16
-
17
- var _ThemeProvider = require("../ThemeProvider");
18
-
19
- var _focusZone = require("../behaviors/focusZone");
20
-
21
- var _constants = require("../constants");
22
-
23
- var _Dialog = require("../Dialog/Dialog");
24
-
25
- var _useFocusZone = require("../hooks/useFocusZone");
26
-
27
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
-
29
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
30
-
31
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
32
-
33
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
34
-
35
- const StyledConfirmationHeader = _styledComponents.default.header.withConfig({
36
- displayName: "ConfirmationDialog__StyledConfirmationHeader",
37
- componentId: "sc-1ub32x2-0"
38
- })(["padding:", ";display:flex;flex-direction:row;"], (0, _constants.get)('space.2'));
39
-
40
- const StyledTitle = (0, _styledComponents.default)(_Box.default).withConfig({
41
- displayName: "ConfirmationDialog__StyledTitle",
42
- componentId: "sc-1ub32x2-1"
43
- })(["font-size:", ";font-weight:", ";padding:6px ", ";flex-grow:1;"], (0, _constants.get)('fontSizes.3'), (0, _constants.get)('fontWeights.bold'), (0, _constants.get)('space.2'));
44
-
45
- const ConfirmationHeader = ({
46
- title,
47
- onClose,
48
- dialogLabelId
49
- }) => {
50
- const onCloseClick = (0, _react.useCallback)(() => {
51
- onClose('close-button');
52
- }, [onClose]);
53
- return /*#__PURE__*/_react.default.createElement(StyledConfirmationHeader, null, /*#__PURE__*/_react.default.createElement(StyledTitle, {
54
- id: dialogLabelId
55
- }, title), /*#__PURE__*/_react.default.createElement(_Dialog.Dialog.CloseButton, {
56
- onClose: onCloseClick
57
- }));
58
- };
59
-
60
- ConfirmationHeader.displayName = "ConfirmationHeader";
61
- const StyledConfirmationBody = (0, _styledComponents.default)(_Box.default).withConfig({
62
- displayName: "ConfirmationDialog__StyledConfirmationBody",
63
- componentId: "sc-1ub32x2-2"
64
- })(["font-size:", ";padding:0 ", " ", " ", ";color:", ";flex-grow:1;"], (0, _constants.get)('fontSizes.1'), (0, _constants.get)('space.3'), (0, _constants.get)('space.3'), (0, _constants.get)('space.3'), (0, _constants.get)('colors.fg.muted'));
65
-
66
- const ConfirmationBody = ({
67
- children
68
- }) => {
69
- return /*#__PURE__*/_react.default.createElement(StyledConfirmationBody, null, children);
70
- };
71
-
72
- ConfirmationBody.displayName = "ConfirmationBody";
73
- const StyledConfirmationFooter = (0, _styledComponents.default)(_Box.default).withConfig({
74
- displayName: "ConfirmationDialog__StyledConfirmationFooter",
75
- componentId: "sc-1ub32x2-3"
76
- })(["display:grid;grid-auto-flow:column;grid-auto-columns:max-content;grid-gap:", ";align-items:end;justify-content:end;padding:", " ", " ", ";"], (0, _constants.get)('space.2'), (0, _constants.get)('space.1'), (0, _constants.get)('space.3'), (0, _constants.get)('space.3'));
77
-
78
- const ConfirmationFooter = ({
79
- footerButtons
80
- }) => {
81
- const {
82
- containerRef: footerRef
83
- } = (0, _useFocusZone.useFocusZone)({
84
- bindKeys: _focusZone.FocusKeys.ArrowHorizontal | _focusZone.FocusKeys.Tab,
85
- focusInStrategy: 'closest'
86
- }); // Must have exactly 2 buttons!
87
-
88
- return /*#__PURE__*/_react.default.createElement(StyledConfirmationFooter, {
89
- ref: footerRef
90
- }, /*#__PURE__*/_react.default.createElement(_Dialog.Dialog.Buttons, {
91
- buttons: footerButtons !== null && footerButtons !== void 0 ? footerButtons : []
92
- }));
93
- };
94
-
95
- ConfirmationFooter.displayName = "ConfirmationFooter";
96
-
97
- /**
98
- * A ConfirmationDialog is a special kind of dialog with more rigid behavior. It
99
- * is used to confirm a user action. ConfirmationDialogs always have exactly
100
- * two buttons: one to cancel the action and one to confirm it. No custom
101
- * rendering capabilities are provided for ConfirmationDialog.
102
- */
103
- const ConfirmationDialog = props => {
104
- const {
105
- onClose,
106
- title,
107
- cancelButtonContent = 'Cancel',
108
- confirmButtonContent = 'OK',
109
- confirmButtonType = 'normal',
110
- children
111
- } = props;
112
- const onCancelButtonClick = (0, _react.useCallback)(() => {
113
- onClose('cancel');
114
- }, [onClose]);
115
- const onConfirmButtonClick = (0, _react.useCallback)(() => {
116
- onClose('confirm');
117
- }, [onClose]);
118
- const cancelButton = {
119
- content: cancelButtonContent,
120
- onClick: onCancelButtonClick
121
- };
122
- const confirmButton = {
123
- content: confirmButtonContent,
124
- buttonType: confirmButtonType,
125
- onClick: onConfirmButtonClick,
126
- autoFocus: true
127
- };
128
- const footerButtons = [cancelButton, confirmButton];
129
- return /*#__PURE__*/_react.default.createElement(_Dialog.Dialog, {
130
- onClose: onClose,
131
- title: title,
132
- footerButtons: footerButtons,
133
- role: "alertdialog",
134
- width: "medium",
135
- renderHeader: ConfirmationHeader,
136
- renderBody: ConfirmationBody,
137
- renderFooter: ConfirmationFooter
138
- }, children);
139
- };
140
-
141
- exports.ConfirmationDialog = ConfirmationDialog;
142
- ConfirmationDialog.displayName = "ConfirmationDialog";
143
-
144
- async function confirm(themeProps, options) {
145
- const {
146
- content,
147
- ...confirmationDialogProps
148
- } = options;
149
- return new Promise(resolve => {
150
- const hostElement = document.createElement('div');
151
-
152
- const onClose = gesture => {
153
- _reactDom.default.unmountComponentAtNode(hostElement);
154
-
155
- if (gesture === 'confirm') {
156
- resolve(true);
157
- } else {
158
- resolve(false);
159
- }
160
- };
161
-
162
- _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_ThemeProvider.ThemeProvider, themeProps, /*#__PURE__*/_react.default.createElement(ConfirmationDialog, _extends({}, confirmationDialogProps, {
163
- onClose: onClose
164
- }), content)), hostElement);
165
- });
166
- }
167
- /**
168
- * This hook takes no parameters and returns an `async` function, `confirm`. When `confirm`
169
- * is called, it shows the confirmation dialog. When the dialog is dismissed, a promise is
170
- * resolved with `true` or `false` depending on whether or not the confirm button was used.
171
- */
172
-
173
-
174
- function useConfirm() {
175
- const {
176
- theme,
177
- colorMode,
178
- dayScheme,
179
- nightScheme
180
- } = (0, _ThemeProvider.useTheme)();
181
- const result = (0, _react.useCallback)(options => {
182
- const themeProps = {
183
- theme,
184
- colorMode,
185
- dayScheme,
186
- nightScheme
187
- };
188
- return confirm(themeProps, options);
189
- }, [theme, colorMode, dayScheme, nightScheme]);
190
- return result;
191
- }
@@ -1,167 +0,0 @@
1
- import React from 'react';
2
- import { ButtonProps } from '../Button';
3
- import { SxProp } from '../sx';
4
- /**
5
- * Props that characterize a button to be rendered into the footer of
6
- * a Dialog.
7
- */
8
- export declare type DialogButtonProps = ButtonProps & {
9
- /**
10
- * The type of Button element to use
11
- */
12
- buttonType?: 'normal' | 'primary' | 'danger';
13
- /**
14
- * The Button's inner text
15
- */
16
- content: React.ReactNode;
17
- /**
18
- * If true, and if this is the only button with autoFocus set to true,
19
- * focus this button automatically when the dialog appears.
20
- */
21
- autoFocus?: boolean;
22
- /**
23
- * A reference to the rendered Button’s DOM node, used together with
24
- * `autoFocus` for `focusTrap`’s `initialFocus`.
25
- */
26
- ref?: React.RefObject<HTMLButtonElement>;
27
- };
28
- /**
29
- * Props to customize the rendering of the Dialog.
30
- */
31
- export interface DialogProps {
32
- /**
33
- * Title of the Dialog. Also serves as the aria-label for this Dialog.
34
- */
35
- title?: React.ReactNode;
36
- /**
37
- * The Dialog's subtitle. Optional. Rendered below the title in smaller
38
- * type with less contrast. Also serves as the aria-describedby for this
39
- * Dialog.
40
- */
41
- subtitle?: React.ReactNode;
42
- /**
43
- * Provide a custom renderer for the dialog header. This content is
44
- * rendered directly into the dialog body area, full bleed from edge
45
- * to edge, top to the start of the body element.
46
- *
47
- * Warning: using a custom renderer may violate Primer UX principles.
48
- */
49
- renderHeader?: React.FunctionComponent<DialogHeaderProps>;
50
- /**
51
- * Provide a custom render function for the dialog body. This content is
52
- * rendered directly into the dialog body area, full bleed from edge to
53
- * edge, header to footer.
54
- *
55
- * Warning: using a custom renderer may violate Primer UX principles.
56
- */
57
- renderBody?: React.FunctionComponent<DialogProps>;
58
- /**
59
- * Provide a custom render function for the dialog footer. This content is
60
- * rendered directly into the dialog footer area, full bleed from edge to
61
- * edge, end of the body element to bottom.
62
- *
63
- * Warning: using a custom renderer may violate Primer UX principles.
64
- */
65
- renderFooter?: React.FunctionComponent<DialogProps>;
66
- /**
67
- * Specifies the buttons to be rendered in the Dialog footer.
68
- */
69
- footerButtons?: DialogButtonProps[];
70
- /**
71
- * This method is invoked when a gesture to close the dialog is used (either
72
- * an Escape key press or clicking the "X" in the top-right corner). The
73
- * gesture argument indicates the gesture that was used to close the dialog
74
- * (either 'close-button' or 'escape').
75
- */
76
- onClose: (gesture: 'close-button' | 'escape') => void;
77
- /**
78
- * Default: "dialog". The ARIA role to assign to this dialog.
79
- * @see https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal
80
- * @see https://www.w3.org/TR/wai-aria-practices-1.1/#alertdialog
81
- */
82
- role?: 'dialog' | 'alertdialog';
83
- /**
84
- * The width of the dialog.
85
- * small: 296px
86
- * medium: 320px
87
- * large: 480px
88
- * xlarge: 640px
89
- */
90
- width?: DialogWidth;
91
- /**
92
- * The height of the dialog.
93
- * small: 296x480
94
- * large: 480x640
95
- * auto: variable based on contents
96
- */
97
- height?: DialogHeight;
98
- }
99
- /**
100
- * Props that are passed to a component that serves as a dialog header
101
- */
102
- export interface DialogHeaderProps extends DialogProps {
103
- /**
104
- * ID of the element that will be used as the `aria-labelledby` attribute on the
105
- * dialog. This ID should be set to the element that renders the dialog's title.
106
- */
107
- dialogLabelId: string;
108
- /**
109
- * ID of the element that will be used as the `aria-describedby` attribute on the
110
- * dialog. This ID should be set to the element that renders the dialog's subtitle.
111
- */
112
- dialogDescriptionId: string;
113
- }
114
- declare const heightMap: {
115
- readonly small: "480px";
116
- readonly large: "640px";
117
- readonly auto: "auto";
118
- };
119
- declare const widthMap: {
120
- readonly small: "296px";
121
- readonly medium: "320px";
122
- readonly large: "480px";
123
- readonly xlarge: "640px";
124
- };
125
- export declare type DialogWidth = keyof typeof widthMap;
126
- export declare type DialogHeight = keyof typeof heightMap;
127
- /**
128
- * A dialog is a type of overlay that can be used for confirming actions, asking
129
- * for disambiguation, and presenting small forms. They generally allow the user
130
- * to focus on a quick task without having to navigate to a different page.
131
- *
132
- * Dialogs appear in the page after a direct user interaction. Don't show dialogs
133
- * on page load or as system alerts.
134
- *
135
- * Dialogs appear centered in the page, with a visible backdrop that dims the rest
136
- * of the window for focus.
137
- *
138
- * All dialogs have a title and a close button.
139
- *
140
- * Dialogs are modal. Dialogs can be dismissed by clicking on the close button,
141
- * pressing the escape key, or by interacting with another button in the dialog.
142
- * To avoid losing information and missing important messages, clicking outside
143
- * of the dialog will not close it.
144
- *
145
- * The sub components provided (e.g. Header, Title, etc.) are available for custom
146
- * renderers only. They are not intended to be used otherwise.
147
- */
148
- export declare const Dialog: React.ForwardRefExoticComponent<DialogProps & {
149
- children?: React.ReactNode;
150
- } & React.RefAttributes<HTMLDivElement>> & {
151
- Header: import("styled-components").StyledComponent<"div", any, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").TypographyProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").GridProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> & import("styled-system").BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ShadowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & SxProp & {
152
- as: string;
153
- }, "as">;
154
- Title: import("styled-components").StyledComponent<"div", any, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").TypographyProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").GridProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> & import("styled-system").BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ShadowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & SxProp, never>;
155
- Subtitle: import("styled-components").StyledComponent<"div", any, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").TypographyProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").GridProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> & import("styled-system").BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ShadowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & SxProp, never>;
156
- Body: import("styled-components").StyledComponent<"div", any, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").TypographyProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").GridProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> & import("styled-system").BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ShadowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & SxProp, never>;
157
- Footer: import("styled-components").StyledComponent<"div", any, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").TypographyProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").GridProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> & import("styled-system").BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ShadowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & SxProp & {
158
- as: string;
159
- }, "as">;
160
- Buttons: React.FC<{
161
- buttons: DialogButtonProps[];
162
- }>;
163
- CloseButton: React.FC<{
164
- onClose: () => void;
165
- }>;
166
- };
167
- export {};
@@ -1,304 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Dialog = void 0;
7
-
8
- var _react = _interopRequireWildcard(require("react"));
9
-
10
- var _styledComponents = _interopRequireDefault(require("styled-components"));
11
-
12
- var _Button = _interopRequireWildcard(require("../Button"));
13
-
14
- var _Box = _interopRequireDefault(require("../Box"));
15
-
16
- var _constants = require("../constants");
17
-
18
- var _hooks = require("../hooks");
19
-
20
- var _useFocusTrap = require("../hooks/useFocusTrap");
21
-
22
- var _sx = _interopRequireDefault(require("../sx"));
23
-
24
- var _StyledOcticon = _interopRequireDefault(require("../StyledOcticon"));
25
-
26
- var _octiconsReact = require("@primer/octicons-react");
27
-
28
- var _useFocusZone = require("../hooks/useFocusZone");
29
-
30
- var _focusZone = require("../behaviors/focusZone");
31
-
32
- var _Portal = _interopRequireDefault(require("../Portal"));
33
-
34
- var _useCombinedRefs = require("../hooks/useCombinedRefs");
35
-
36
- var _ssr = require("@react-aria/ssr");
37
-
38
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
-
40
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
41
-
42
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
43
-
44
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
45
-
46
- const ANIMATION_DURATION = '200ms';
47
- /**
48
- * Props that characterize a button to be rendered into the footer of
49
- * a Dialog.
50
- */
51
-
52
- const Backdrop = (0, _styledComponents.default)('div').withConfig({
53
- displayName: "Dialog__Backdrop",
54
- componentId: "sc-11pkgky-0"
55
- })(["position:fixed;top:0;left:0;bottom:0;right:0;display:flex;align-items:center;justify-content:center;background-color:rgba(0,0,0,0.4);animation:dialog-backdrop-appear ", " ", ";@keyframes dialog-backdrop-appear{0%{opacity:0;}100%{opacity:1;}}"], ANIMATION_DURATION, (0, _constants.get)('animation.easeOutCubic'));
56
- const heightMap = {
57
- small: '480px',
58
- large: '640px',
59
- auto: 'auto'
60
- };
61
- const widthMap = {
62
- small: '296px',
63
- medium: '320px',
64
- large: '480px',
65
- xlarge: '640px'
66
- };
67
-
68
- const StyledDialog = _styledComponents.default.div.withConfig({
69
- displayName: "Dialog__StyledDialog",
70
- componentId: "sc-11pkgky-1"
71
- })(["display:flex;flex-direction:column;background-color:", ";box-shadow:", ";min-width:296px;max-width:calc(100vw - 64px);max-height:calc(100vh - 64px);width:", ";height:", ";border-radius:12px;opacity:1;animation:overlay--dialog-appear ", " ", ";@keyframes overlay--dialog-appear{0%{opacity:0;transform:scale(0.5);}100%{opacity:1;transform:scale(1);}}", ";", ";", ";"], (0, _constants.get)('colors.canvas.overlay'), (0, _constants.get)('shadows.overlay.shadow'), props => {
72
- var _props$width;
73
-
74
- return widthMap[(_props$width = props.width) !== null && _props$width !== void 0 ? _props$width : 'xlarge'];
75
- }, props => {
76
- var _props$height;
77
-
78
- return heightMap[(_props$height = props.height) !== null && _props$height !== void 0 ? _props$height : 'auto'];
79
- }, ANIMATION_DURATION, (0, _constants.get)('animation.easeOutCubic'), _constants.COMMON, _constants.POSITION, _sx.default);
80
-
81
- const DefaultHeader = ({
82
- dialogLabelId,
83
- title,
84
- subtitle,
85
- dialogDescriptionId,
86
- onClose
87
- }) => {
88
- const onCloseClick = (0, _react.useCallback)(() => {
89
- onClose('close-button');
90
- }, [onClose]);
91
- return /*#__PURE__*/_react.default.createElement(Dialog.Header, null, /*#__PURE__*/_react.default.createElement(_Box.default, {
92
- display: "flex"
93
- }, /*#__PURE__*/_react.default.createElement(_Box.default, {
94
- display: "flex",
95
- px: 2,
96
- py: "6px",
97
- flexDirection: "column",
98
- flexGrow: 1
99
- }, /*#__PURE__*/_react.default.createElement(Dialog.Title, {
100
- id: dialogLabelId
101
- }, title !== null && title !== void 0 ? title : 'Dialog'), subtitle && /*#__PURE__*/_react.default.createElement(Dialog.Subtitle, {
102
- id: dialogDescriptionId
103
- }, subtitle)), /*#__PURE__*/_react.default.createElement(Dialog.CloseButton, {
104
- onClose: onCloseClick
105
- })));
106
- };
107
-
108
- DefaultHeader.displayName = "DefaultHeader";
109
-
110
- const DefaultBody = ({
111
- children
112
- }) => {
113
- return /*#__PURE__*/_react.default.createElement(Dialog.Body, null, children);
114
- };
115
-
116
- DefaultBody.displayName = "DefaultBody";
117
-
118
- const DefaultFooter = ({
119
- footerButtons
120
- }) => {
121
- const {
122
- containerRef: footerRef
123
- } = (0, _useFocusZone.useFocusZone)({
124
- bindKeys: _focusZone.FocusKeys.ArrowHorizontal | _focusZone.FocusKeys.Tab,
125
- focusInStrategy: 'closest'
126
- });
127
- return footerButtons ? /*#__PURE__*/_react.default.createElement(Dialog.Footer, {
128
- ref: footerRef
129
- }, /*#__PURE__*/_react.default.createElement(Dialog.Buttons, {
130
- buttons: footerButtons
131
- })) : null;
132
- };
133
-
134
- const _Dialog = /*#__PURE__*/_react.default.forwardRef((props, forwardedRef) => {
135
- const {
136
- title = 'Dialog',
137
- subtitle = '',
138
- renderHeader,
139
- renderBody,
140
- renderFooter,
141
- onClose,
142
- role = 'dialog',
143
- width = 'xlarge',
144
- height = 'auto',
145
- footerButtons = []
146
- } = props;
147
- const dialogLabelId = (0, _ssr.useSSRSafeId)();
148
- const dialogDescriptionId = (0, _ssr.useSSRSafeId)();
149
- const autoFocusedFooterButtonRef = (0, _react.useRef)(null);
150
-
151
- for (const footerButton of footerButtons) {
152
- if (footerButton.autoFocus) {
153
- footerButton.ref = autoFocusedFooterButtonRef;
154
- }
155
- }
156
-
157
- const defaultedProps = { ...props,
158
- title,
159
- subtitle,
160
- role,
161
- dialogLabelId,
162
- dialogDescriptionId
163
- };
164
- const dialogRef = (0, _react.useRef)(null);
165
- const combinedRef = (0, _useCombinedRefs.useCombinedRefs)(dialogRef, forwardedRef);
166
- const backdropRef = (0, _react.useRef)(null);
167
- (0, _useFocusTrap.useFocusTrap)({
168
- containerRef: dialogRef,
169
- restoreFocusOnCleanUp: true,
170
- initialFocusRef: autoFocusedFooterButtonRef
171
- });
172
- (0, _hooks.useOnEscapePress)(event => {
173
- onClose('escape');
174
- event.preventDefault();
175
- }, [onClose]);
176
- const header = (renderHeader !== null && renderHeader !== void 0 ? renderHeader : DefaultHeader)(defaultedProps);
177
- const body = (renderBody !== null && renderBody !== void 0 ? renderBody : DefaultBody)(defaultedProps);
178
- const footer = (renderFooter !== null && renderFooter !== void 0 ? renderFooter : DefaultFooter)(defaultedProps);
179
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Portal.default, null, /*#__PURE__*/_react.default.createElement(Backdrop, {
180
- ref: backdropRef
181
- }, /*#__PURE__*/_react.default.createElement(StyledDialog, {
182
- width: width,
183
- height: height,
184
- ref: combinedRef,
185
- role: role,
186
- "aria-labelledby": dialogLabelId,
187
- "aria-describedby": dialogDescriptionId
188
- }, header, body, footer))));
189
- });
190
-
191
- _Dialog.displayName = 'Dialog';
192
- const Header = (0, _styledComponents.default)(_Box.default).attrs({
193
- as: 'header'
194
- }).withConfig({
195
- displayName: "Dialog__Header",
196
- componentId: "sc-11pkgky-2"
197
- })(["box-shadow:0 1px 0 ", ";padding:", ";z-index:1;flex-shrink:0;"], (0, _constants.get)('colors.border.default'), (0, _constants.get)('space.2'));
198
- const Title = (0, _styledComponents.default)(_Box.default).withConfig({
199
- displayName: "Dialog__Title",
200
- componentId: "sc-11pkgky-3"
201
- })(["font-size:", ";font-weight:", ";"], (0, _constants.get)('fontSizes.1'), (0, _constants.get)('fontWeights.bold'));
202
- const Subtitle = (0, _styledComponents.default)(_Box.default).withConfig({
203
- displayName: "Dialog__Subtitle",
204
- componentId: "sc-11pkgky-4"
205
- })(["font-size:", ";margin-top:", ";color:", ";"], (0, _constants.get)('fontSizes.0'), (0, _constants.get)('space.1'), (0, _constants.get)('colors.fg.muted'));
206
- const Body = (0, _styledComponents.default)(_Box.default).withConfig({
207
- displayName: "Dialog__Body",
208
- componentId: "sc-11pkgky-5"
209
- })(["flex-grow:1;overflow:auto;padding:", ";"], (0, _constants.get)('space.3'));
210
- const Footer = (0, _styledComponents.default)(_Box.default).attrs({
211
- as: 'footer'
212
- }).withConfig({
213
- displayName: "Dialog__Footer",
214
- componentId: "sc-11pkgky-6"
215
- })(["box-shadow:0 -1px 0 ", ";padding:", ";display:flex;flex-flow:wrap;justify-content:flex-end;z-index:1;flex-shrink:0;button{margin-left:", ";&:first-child{margin-left:0;}}"], (0, _constants.get)('colors.border.default'), (0, _constants.get)('space.3'), (0, _constants.get)('space.1'));
216
- const buttonTypes = {
217
- normal: _Button.default,
218
- primary: _Button.ButtonPrimary,
219
- danger: _Button.ButtonDanger
220
- };
221
-
222
- const Buttons = ({
223
- buttons
224
- }) => {
225
- var _buttons$find;
226
-
227
- const autoFocusRef = (0, _hooks.useProvidedRefOrCreate)((_buttons$find = buttons.find(button => button.autoFocus)) === null || _buttons$find === void 0 ? void 0 : _buttons$find.ref);
228
- let autoFocusCount = 0;
229
- const [hasRendered, setHasRendered] = (0, _react.useState)(0);
230
- (0, _react.useEffect)(() => {
231
- // hack to work around dialogs originating from other focus traps.
232
- if (hasRendered === 1) {
233
- var _autoFocusRef$current;
234
-
235
- (_autoFocusRef$current = autoFocusRef.current) === null || _autoFocusRef$current === void 0 ? void 0 : _autoFocusRef$current.focus();
236
- } else {
237
- setHasRendered(hasRendered + 1);
238
- }
239
- }, [autoFocusRef, hasRendered]);
240
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, buttons.map((dialogButtonProps, index) => {
241
- const {
242
- content,
243
- buttonType = 'normal',
244
- autoFocus = false,
245
- ...buttonProps
246
- } = dialogButtonProps;
247
- const ButtonElement = buttonTypes[buttonType];
248
- return /*#__PURE__*/_react.default.createElement(ButtonElement, _extends({
249
- key: index
250
- }, buttonProps, {
251
- ref: autoFocus && autoFocusCount === 0 ? (autoFocusCount++, autoFocusRef) : null
252
- }), content);
253
- }));
254
- };
255
-
256
- const DialogCloseButton = (0, _styledComponents.default)(_Button.default).withConfig({
257
- displayName: "Dialog__DialogCloseButton",
258
- componentId: "sc-11pkgky-7"
259
- })(["border-radius:4px;background:transparent;border:0;vertical-align:middle;color:", ";padding:", ";align-self:flex-start;line-height:normal;box-shadow:none;"], (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('space.2'));
260
-
261
- const CloseButton = ({
262
- onClose
263
- }) => {
264
- return /*#__PURE__*/_react.default.createElement(DialogCloseButton, {
265
- "aria-label": "Close",
266
- onClick: onClose
267
- }, /*#__PURE__*/_react.default.createElement(_StyledOcticon.default, {
268
- icon: _octiconsReact.XIcon
269
- }));
270
- };
271
-
272
- CloseButton.displayName = "CloseButton";
273
-
274
- /**
275
- * A dialog is a type of overlay that can be used for confirming actions, asking
276
- * for disambiguation, and presenting small forms. They generally allow the user
277
- * to focus on a quick task without having to navigate to a different page.
278
- *
279
- * Dialogs appear in the page after a direct user interaction. Don't show dialogs
280
- * on page load or as system alerts.
281
- *
282
- * Dialogs appear centered in the page, with a visible backdrop that dims the rest
283
- * of the window for focus.
284
- *
285
- * All dialogs have a title and a close button.
286
- *
287
- * Dialogs are modal. Dialogs can be dismissed by clicking on the close button,
288
- * pressing the escape key, or by interacting with another button in the dialog.
289
- * To avoid losing information and missing important messages, clicking outside
290
- * of the dialog will not close it.
291
- *
292
- * The sub components provided (e.g. Header, Title, etc.) are available for custom
293
- * renderers only. They are not intended to be used otherwise.
294
- */
295
- const Dialog = Object.assign(_Dialog, {
296
- Header,
297
- Title,
298
- Subtitle,
299
- Body,
300
- Footer,
301
- Buttons,
302
- CloseButton
303
- });
304
- exports.Dialog = Dialog;