@primer/components 29.1.0 → 29.1.1-rc.cea79543

Sign up to get free protection for your applications and to get access to all the features.
Files changed (753) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/config.json +10 -0
  3. package/.devcontainer/devcontainer.json +8 -0
  4. package/.eslintrc.json +106 -0
  5. package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
  6. package/.github/ISSUE_TEMPLATE/new_component_proposal_template.md +41 -0
  7. package/.github/dependabot.yml +18 -0
  8. package/.github/pull_request_template.md +18 -0
  9. package/.github/workflows/ci.yml +31 -0
  10. package/.github/workflows/deploy_preview.yml +47 -0
  11. package/.github/workflows/deploy_production.yml +70 -0
  12. package/.github/workflows/release.yml +35 -0
  13. package/.github/workflows/release_canary.yml +70 -0
  14. package/.github/workflows/release_candidate.yml +60 -0
  15. package/.github/workflows/size.yml +13 -0
  16. package/.github/workflows/stale.yml +26 -0
  17. package/.gitignore +10 -0
  18. package/.npmrc +4 -0
  19. package/.nvmrc +1 -0
  20. package/.storybook/main.js +11 -0
  21. package/.storybook/preview.js +69 -0
  22. package/.vscode/launch.json +21 -0
  23. package/.vscode/settings.json +13 -0
  24. package/@types/@styled-system/index.d.ts +0 -0
  25. package/@types/@styled-system/prop-types/index.d.ts +1 -0
  26. package/@types/@styled-system/props/index.d.ts +1 -0
  27. package/@types/jest-styled-components/index.d.ts +1 -0
  28. package/CHANGELOG.md +6 -0
  29. package/CODEOWNERS +2 -0
  30. package/babel-defines.js +13 -0
  31. package/babel.config.js +39 -0
  32. package/contributor-docs/CODE_OF_CONDUCT.md +76 -0
  33. package/contributor-docs/CONTRIBUTING.md +274 -0
  34. package/contributor-docs/adrs/adr-001-typescript.md +23 -0
  35. package/contributor-docs/adrs/adr-002-behavior-isolation.md +106 -0
  36. package/contributor-docs/behaviors.md +132 -0
  37. package/contributor-docs/component-contents-api-patterns.md +315 -0
  38. package/contributor-docs/principles.md +39 -0
  39. package/docs/.eslintrc +0 -0
  40. package/docs/.gitignore +91 -0
  41. package/docs/components/PropsList.js +5 -0
  42. package/docs/components/State.js +9 -0
  43. package/docs/components/constants.js +34 -0
  44. package/docs/components/index.js +2 -0
  45. package/docs/content/ActionList.mdx +72 -0
  46. package/docs/content/ActionMenu.mdx +80 -0
  47. package/docs/content/AnchoredOverlay.mdx +37 -0
  48. package/docs/content/Avatar.mdx +33 -0
  49. package/docs/content/AvatarStack.mdx +43 -0
  50. package/docs/content/BorderBox.md +46 -0
  51. package/docs/content/Box.md +74 -0
  52. package/docs/content/BranchName.md +18 -0
  53. package/docs/content/Breadcrumbs.md +52 -0
  54. package/docs/content/Buttons.md +54 -0
  55. package/docs/content/CircleBadge.md +45 -0
  56. package/docs/content/CircleOcticon.md +18 -0
  57. package/docs/content/CounterLabel.md +30 -0
  58. package/docs/content/Details.md +105 -0
  59. package/docs/content/Dialog.md +108 -0
  60. package/docs/content/Dialog2.mdx +179 -0
  61. package/docs/content/Dropdown.md +72 -0
  62. package/docs/content/DropdownMenu.mdx +49 -0
  63. package/docs/content/FilterList.md +44 -0
  64. package/docs/content/FilteredSearch.md +39 -0
  65. package/docs/content/Flash.md +42 -0
  66. package/docs/content/Flex.md +58 -0
  67. package/docs/content/FormGroup.md +44 -0
  68. package/docs/content/Grid.md +59 -0
  69. package/docs/content/Header.md +79 -0
  70. package/docs/content/Heading.md +22 -0
  71. package/docs/content/Label.md +40 -0
  72. package/docs/content/LabelGroup.md +31 -0
  73. package/docs/content/Link.md +37 -0
  74. package/docs/content/Overlay.mdx +94 -0
  75. package/docs/content/Pagehead.md +27 -0
  76. package/docs/content/Pagination.md +187 -0
  77. package/docs/content/PointerBox.md +81 -0
  78. package/docs/content/Popover.md +137 -0
  79. package/docs/content/Portal.mdx +73 -0
  80. package/docs/content/Position.md +97 -0
  81. package/docs/content/ProgressBar.mdx +29 -0
  82. package/docs/content/SelectMenu.md +433 -0
  83. package/docs/content/SelectPanel.mdx +67 -0
  84. package/docs/content/SideNav.md +179 -0
  85. package/docs/content/Spinner.mdx +32 -0
  86. package/docs/content/StateLabel.md +33 -0
  87. package/docs/content/StyledOcticon.md +34 -0
  88. package/docs/content/SubNav.md +102 -0
  89. package/docs/content/TabNav.md +50 -0
  90. package/docs/content/Text.md +29 -0
  91. package/docs/content/TextInput.md +32 -0
  92. package/docs/content/Timeline.md +138 -0
  93. package/docs/content/Tooltip.md +41 -0
  94. package/docs/content/Truncate.md +65 -0
  95. package/docs/content/UnderlineNav.md +53 -0
  96. package/docs/content/anchoredPosition.mdx +163 -0
  97. package/docs/content/core-concepts.md +70 -0
  98. package/docs/content/focusTrap.mdx +103 -0
  99. package/docs/content/focusZone.mdx +145 -0
  100. package/docs/content/getting-started.md +134 -0
  101. package/docs/content/index.md +33 -0
  102. package/docs/content/linting.md +35 -0
  103. package/docs/content/overriding-styles.mdx +79 -0
  104. package/docs/content/philosophy.md +23 -0
  105. package/docs/content/primer-theme.md +89 -0
  106. package/docs/content/ssr.mdx +43 -0
  107. package/docs/content/system-props.mdx +37 -0
  108. package/docs/content/theme-reference.md +16 -0
  109. package/docs/content/theming.md +249 -0
  110. package/docs/content/useOnEscapePress.mdx +56 -0
  111. package/docs/content/useOnOutsideClick.mdx +57 -0
  112. package/docs/content/useOpenAndCloseFocus.mdx +49 -0
  113. package/docs/content/useOverlay.mdx +62 -0
  114. package/docs/content/useSafeTimeout.mdx +32 -0
  115. package/docs/gatsby-config.js +30 -0
  116. package/docs/gatsby-node.js +101 -0
  117. package/docs/package-lock.json +20979 -0
  118. package/docs/package.json +35 -0
  119. package/docs/src/@primer/gatsby-theme-doctocat/components/hero.js +21 -0
  120. package/docs/src/@primer/gatsby-theme-doctocat/components/live-code.js +84 -0
  121. package/docs/src/@primer/gatsby-theme-doctocat/components/live-preview-wrapper.js +39 -0
  122. package/docs/src/@primer/gatsby-theme-doctocat/components/nav-dropdown.js +48 -0
  123. package/docs/src/@primer/gatsby-theme-doctocat/components/wrap-page-element.js +25 -0
  124. package/docs/src/@primer/gatsby-theme-doctocat/live-code-scope.js +54 -0
  125. package/docs/src/@primer/gatsby-theme-doctocat/nav.yml +127 -0
  126. package/docs/src/@primer/gatsby-theme-doctocat/primer-components-hero.svg +1411 -0
  127. package/docs/src/props.js +77 -0
  128. package/jest.config.js +13 -0
  129. package/lib/Button/Button.d.ts +0 -1
  130. package/lib/Button/ButtonClose.d.ts +1 -2
  131. package/lib/Button/ButtonDanger.d.ts +0 -1
  132. package/lib/Button/ButtonInvisible.d.ts +0 -1
  133. package/lib/Button/ButtonOutline.d.ts +0 -1
  134. package/lib/Button/ButtonPrimary.d.ts +0 -1
  135. package/lib/CircleOcticon.d.ts +0 -1
  136. package/lib/Dialog.d.ts +2 -3
  137. package/lib/Dropdown.d.ts +0 -4
  138. package/lib/DropdownMenu/DropdownButton.d.ts +1 -2
  139. package/lib/FilterList.d.ts +0 -1
  140. package/lib/Position.d.ts +4 -4
  141. package/lib/SelectMenu/SelectMenu.d.ts +4 -10
  142. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  143. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  144. package/lib/Timeline.d.ts +0 -1
  145. package/lib/__tests__/ActionList.d.ts +1 -0
  146. package/lib/__tests__/ActionList.js +67 -0
  147. package/lib/__tests__/ActionMenu.d.ts +1 -0
  148. package/lib/__tests__/ActionMenu.js +154 -0
  149. package/lib/__tests__/AnchoredOverlay.d.ts +1 -0
  150. package/lib/__tests__/AnchoredOverlay.js +161 -0
  151. package/lib/__tests__/Avatar.d.ts +1 -0
  152. package/lib/__tests__/Avatar.js +70 -0
  153. package/lib/__tests__/AvatarStack.d.ts +1 -0
  154. package/lib/__tests__/AvatarStack.js +71 -0
  155. package/lib/__tests__/BorderBox.d.ts +1 -0
  156. package/lib/__tests__/BorderBox.js +61 -0
  157. package/lib/__tests__/Box.d.ts +1 -0
  158. package/lib/__tests__/Box.js +81 -0
  159. package/lib/__tests__/BranchName.d.ts +1 -0
  160. package/lib/__tests__/BranchName.js +39 -0
  161. package/lib/__tests__/Breadcrumb.d.ts +1 -0
  162. package/lib/__tests__/Breadcrumb.js +42 -0
  163. package/lib/__tests__/BreadcrumbItem.d.ts +1 -0
  164. package/lib/__tests__/BreadcrumbItem.js +52 -0
  165. package/lib/__tests__/Button.d.ts +1 -0
  166. package/lib/__tests__/Button.js +152 -0
  167. package/lib/__tests__/Caret.d.ts +1 -0
  168. package/lib/__tests__/Caret.js +52 -0
  169. package/lib/__tests__/CircleBadge.d.ts +1 -0
  170. package/lib/__tests__/CircleBadge.js +87 -0
  171. package/lib/__tests__/CircleOcticon.d.ts +1 -0
  172. package/lib/__tests__/CircleOcticon.js +74 -0
  173. package/lib/__tests__/CounterLabel.d.ts +1 -0
  174. package/lib/__tests__/CounterLabel.js +61 -0
  175. package/lib/__tests__/Details.d.ts +1 -0
  176. package/lib/__tests__/Details.js +120 -0
  177. package/lib/__tests__/Dialog.d.ts +1 -0
  178. package/lib/__tests__/Dialog.js +188 -0
  179. package/lib/__tests__/Dropdown.d.ts +1 -0
  180. package/lib/__tests__/Dropdown.js +70 -0
  181. package/lib/__tests__/DropdownMenu.d.ts +1 -0
  182. package/lib/__tests__/DropdownMenu.js +153 -0
  183. package/lib/__tests__/FilterList.d.ts +1 -0
  184. package/lib/__tests__/FilterList.js +39 -0
  185. package/lib/__tests__/FilterListItem.d.ts +1 -0
  186. package/lib/__tests__/FilterListItem.js +49 -0
  187. package/lib/__tests__/FilteredSearch.d.ts +1 -0
  188. package/lib/__tests__/FilteredSearch.js +39 -0
  189. package/lib/__tests__/Flash.d.ts +1 -0
  190. package/lib/__tests__/Flash.js +65 -0
  191. package/lib/__tests__/Flex.d.ts +1 -0
  192. package/lib/__tests__/Flex.js +77 -0
  193. package/lib/__tests__/FormGroup.d.ts +1 -0
  194. package/lib/__tests__/FormGroup.js +58 -0
  195. package/lib/__tests__/Grid.d.ts +1 -0
  196. package/lib/__tests__/Grid.js +107 -0
  197. package/lib/__tests__/Header.d.ts +1 -0
  198. package/lib/__tests__/Header.js +63 -0
  199. package/lib/__tests__/Heading.d.ts +1 -0
  200. package/lib/__tests__/Heading.js +112 -0
  201. package/lib/__tests__/Label.d.ts +1 -0
  202. package/lib/__tests__/Label.js +49 -0
  203. package/lib/__tests__/LabelGroup.d.ts +1 -0
  204. package/lib/__tests__/LabelGroup.js +41 -0
  205. package/lib/__tests__/Link.d.ts +1 -0
  206. package/lib/__tests__/Link.js +73 -0
  207. package/lib/__tests__/Overlay.d.ts +1 -0
  208. package/lib/__tests__/Overlay.js +145 -0
  209. package/lib/__tests__/Pagehead.d.ts +1 -0
  210. package/lib/__tests__/Pagehead.js +40 -0
  211. package/lib/__tests__/Pagination/Pagination.d.ts +1 -0
  212. package/lib/__tests__/Pagination/Pagination.js +50 -0
  213. package/lib/__tests__/Pagination/PaginationModel.d.ts +1 -0
  214. package/lib/__tests__/Pagination/PaginationModel.js +186 -0
  215. package/lib/__tests__/PointerBox.d.ts +1 -0
  216. package/lib/__tests__/PointerBox.js +49 -0
  217. package/lib/__tests__/Popover.d.ts +1 -0
  218. package/lib/__tests__/Popover.js +70 -0
  219. package/lib/__tests__/Portal.d.ts +1 -0
  220. package/lib/__tests__/Portal.js +124 -0
  221. package/lib/__tests__/Position.d.ts +1 -0
  222. package/lib/__tests__/Position.js +149 -0
  223. package/lib/__tests__/ProgressBar.d.ts +1 -0
  224. package/lib/__tests__/ProgressBar.js +71 -0
  225. package/lib/__tests__/SelectMenu.d.ts +1 -0
  226. package/lib/__tests__/SelectMenu.js +155 -0
  227. package/lib/__tests__/SelectPanel.d.ts +1 -0
  228. package/lib/__tests__/SelectPanel.js +83 -0
  229. package/lib/__tests__/SideNav.d.ts +1 -0
  230. package/lib/__tests__/SideNav.js +75 -0
  231. package/lib/__tests__/Spinner.d.ts +1 -0
  232. package/lib/__tests__/Spinner.js +56 -0
  233. package/lib/__tests__/StateLabel.d.ts +1 -0
  234. package/lib/__tests__/StateLabel.js +74 -0
  235. package/lib/__tests__/StyledOcticon.d.ts +1 -0
  236. package/lib/__tests__/StyledOcticon.js +43 -0
  237. package/lib/__tests__/SubNav.d.ts +1 -0
  238. package/lib/__tests__/SubNav.js +65 -0
  239. package/lib/__tests__/SubNavLink.d.ts +1 -0
  240. package/lib/__tests__/SubNavLink.js +52 -0
  241. package/lib/__tests__/TabNav.d.ts +1 -0
  242. package/lib/__tests__/TabNav.js +53 -0
  243. package/lib/__tests__/Text.d.ts +1 -0
  244. package/lib/__tests__/Text.js +108 -0
  245. package/lib/__tests__/TextInput.d.ts +1 -0
  246. package/lib/__tests__/TextInput.js +81 -0
  247. package/lib/__tests__/ThemeProvider.d.ts +1 -0
  248. package/lib/__tests__/ThemeProvider.js +444 -0
  249. package/lib/__tests__/Timeline.d.ts +1 -0
  250. package/lib/__tests__/Timeline.js +80 -0
  251. package/lib/__tests__/Tooltip.d.ts +1 -0
  252. package/lib/__tests__/Tooltip.js +72 -0
  253. package/lib/__tests__/Truncate.d.ts +1 -0
  254. package/lib/__tests__/Truncate.js +66 -0
  255. package/lib/__tests__/UnderlineNav.d.ts +1 -0
  256. package/lib/__tests__/UnderlineNav.js +75 -0
  257. package/lib/__tests__/UnderlineNavLink.d.ts +1 -0
  258. package/lib/__tests__/UnderlineNavLink.js +54 -0
  259. package/lib/__tests__/behaviors/anchoredPosition.d.ts +1 -0
  260. package/lib/__tests__/behaviors/anchoredPosition.js +390 -0
  261. package/lib/__tests__/behaviors/focusTrap.d.ts +1 -0
  262. package/lib/__tests__/behaviors/focusTrap.js +234 -0
  263. package/lib/__tests__/behaviors/focusZone.d.ts +1 -0
  264. package/lib/__tests__/behaviors/focusZone.js +570 -0
  265. package/lib/__tests__/behaviors/iterateFocusableElements.d.ts +1 -0
  266. package/lib/__tests__/behaviors/iterateFocusableElements.js +55 -0
  267. package/lib/__tests__/filterObject.d.ts +1 -0
  268. package/lib/__tests__/filterObject.js +30 -0
  269. package/lib/__tests__/hooks/useAnchoredPosition.d.ts +1 -0
  270. package/lib/__tests__/hooks/useAnchoredPosition.js +54 -0
  271. package/lib/__tests__/hooks/useOnEscapePress.d.ts +1 -0
  272. package/lib/__tests__/hooks/useOnEscapePress.js +32 -0
  273. package/lib/__tests__/hooks/useOnOutsideClick.d.ts +1 -0
  274. package/lib/__tests__/hooks/useOnOutsideClick.js +87 -0
  275. package/lib/__tests__/hooks/useOpenAndCloseFocus.d.ts +1 -0
  276. package/lib/__tests__/hooks/useOpenAndCloseFocus.js +60 -0
  277. package/lib/__tests__/hooks/useProvidedStateOrCreate.d.ts +1 -0
  278. package/lib/__tests__/hooks/useProvidedStateOrCreate.js +45 -0
  279. package/lib/__tests__/theme.d.ts +1 -0
  280. package/lib/__tests__/theme.js +36 -0
  281. package/lib/__tests__/themeGet.d.ts +1 -0
  282. package/lib/__tests__/themeGet.js +25 -0
  283. package/lib/__tests__/useSafeTimeout.d.ts +1 -0
  284. package/lib/__tests__/useSafeTimeout.js +45 -0
  285. package/lib/stories/ActionList.stories.js +382 -0
  286. package/lib/stories/ActionMenu.stories.js +338 -0
  287. package/lib/stories/AnchoredOverlay.stories.js +127 -0
  288. package/lib/stories/AvatarStack.stories.js +49 -0
  289. package/lib/stories/Button.stories.js +114 -0
  290. package/lib/stories/ConfirmationDialog.stories.js +111 -0
  291. package/lib/stories/Dialog.stories.js +265 -0
  292. package/lib/stories/DropdownMenu.stories.js +122 -0
  293. package/lib/stories/Overlay.stories.js +185 -0
  294. package/lib/stories/Portal.stories.js +104 -0
  295. package/lib/stories/SelectPanel.stories.js +342 -0
  296. package/lib/stories/ThemeProvider.stories.js +102 -0
  297. package/lib/stories/useAnchoredPosition.stories.js +351 -0
  298. package/lib/stories/useFocusTrap.stories.js +356 -0
  299. package/lib/stories/useFocusZone.stories.js +599 -0
  300. package/lib-esm/Button/Button.d.ts +0 -1
  301. package/lib-esm/Button/ButtonClose.d.ts +1 -2
  302. package/lib-esm/Button/ButtonDanger.d.ts +0 -1
  303. package/lib-esm/Button/ButtonInvisible.d.ts +0 -1
  304. package/lib-esm/Button/ButtonOutline.d.ts +0 -1
  305. package/lib-esm/Button/ButtonPrimary.d.ts +0 -1
  306. package/lib-esm/CircleOcticon.d.ts +0 -1
  307. package/lib-esm/Dialog.d.ts +2 -3
  308. package/lib-esm/Dropdown.d.ts +0 -4
  309. package/lib-esm/DropdownMenu/DropdownButton.d.ts +1 -2
  310. package/lib-esm/FilterList.d.ts +0 -1
  311. package/lib-esm/Position.d.ts +4 -4
  312. package/lib-esm/SelectMenu/SelectMenu.d.ts +4 -10
  313. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  314. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  315. package/lib-esm/Timeline.d.ts +0 -1
  316. package/lib-esm/__tests__/ActionList.d.ts +1 -0
  317. package/lib-esm/__tests__/ActionList.js +54 -0
  318. package/lib-esm/__tests__/ActionMenu.d.ts +1 -0
  319. package/lib-esm/__tests__/ActionMenu.js +141 -0
  320. package/lib-esm/__tests__/AnchoredOverlay.d.ts +1 -0
  321. package/lib-esm/__tests__/AnchoredOverlay.js +135 -0
  322. package/lib-esm/__tests__/Avatar.d.ts +1 -0
  323. package/lib-esm/__tests__/Avatar.js +58 -0
  324. package/lib-esm/__tests__/AvatarStack.d.ts +1 -0
  325. package/lib-esm/__tests__/AvatarStack.js +57 -0
  326. package/lib-esm/__tests__/BorderBox.d.ts +1 -0
  327. package/lib-esm/__tests__/BorderBox.js +49 -0
  328. package/lib-esm/__tests__/Box.d.ts +1 -0
  329. package/lib-esm/__tests__/Box.js +69 -0
  330. package/lib-esm/__tests__/BranchName.d.ts +1 -0
  331. package/lib-esm/__tests__/BranchName.js +28 -0
  332. package/lib-esm/__tests__/Breadcrumb.d.ts +1 -0
  333. package/lib-esm/__tests__/Breadcrumb.js +31 -0
  334. package/lib-esm/__tests__/BreadcrumbItem.d.ts +1 -0
  335. package/lib-esm/__tests__/BreadcrumbItem.js +41 -0
  336. package/lib-esm/__tests__/Button.d.ts +1 -0
  337. package/lib-esm/__tests__/Button.js +141 -0
  338. package/lib-esm/__tests__/Caret.d.ts +1 -0
  339. package/lib-esm/__tests__/Caret.js +42 -0
  340. package/lib-esm/__tests__/CircleBadge.d.ts +1 -0
  341. package/lib-esm/__tests__/CircleBadge.js +73 -0
  342. package/lib-esm/__tests__/CircleOcticon.d.ts +1 -0
  343. package/lib-esm/__tests__/CircleOcticon.js +61 -0
  344. package/lib-esm/__tests__/CounterLabel.d.ts +1 -0
  345. package/lib-esm/__tests__/CounterLabel.js +49 -0
  346. package/lib-esm/__tests__/Details.d.ts +1 -0
  347. package/lib-esm/__tests__/Details.js +109 -0
  348. package/lib-esm/__tests__/Dialog.d.ts +1 -0
  349. package/lib-esm/__tests__/Dialog.js +174 -0
  350. package/lib-esm/__tests__/Dropdown.d.ts +1 -0
  351. package/lib-esm/__tests__/Dropdown.js +59 -0
  352. package/lib-esm/__tests__/DropdownMenu.d.ts +1 -0
  353. package/lib-esm/__tests__/DropdownMenu.js +139 -0
  354. package/lib-esm/__tests__/FilterList.d.ts +1 -0
  355. package/lib-esm/__tests__/FilterList.js +28 -0
  356. package/lib-esm/__tests__/FilterListItem.d.ts +1 -0
  357. package/lib-esm/__tests__/FilterListItem.js +38 -0
  358. package/lib-esm/__tests__/FilteredSearch.d.ts +1 -0
  359. package/lib-esm/__tests__/FilteredSearch.js +28 -0
  360. package/lib-esm/__tests__/Flash.d.ts +1 -0
  361. package/lib-esm/__tests__/Flash.js +53 -0
  362. package/lib-esm/__tests__/Flex.d.ts +1 -0
  363. package/lib-esm/__tests__/Flex.js +66 -0
  364. package/lib-esm/__tests__/FormGroup.d.ts +1 -0
  365. package/lib-esm/__tests__/FormGroup.js +47 -0
  366. package/lib-esm/__tests__/Grid.d.ts +1 -0
  367. package/lib-esm/__tests__/Grid.js +96 -0
  368. package/lib-esm/__tests__/Header.d.ts +1 -0
  369. package/lib-esm/__tests__/Header.js +52 -0
  370. package/lib-esm/__tests__/Heading.d.ts +1 -0
  371. package/lib-esm/__tests__/Heading.js +101 -0
  372. package/lib-esm/__tests__/Label.d.ts +1 -0
  373. package/lib-esm/__tests__/Label.js +38 -0
  374. package/lib-esm/__tests__/LabelGroup.d.ts +1 -0
  375. package/lib-esm/__tests__/LabelGroup.js +28 -0
  376. package/lib-esm/__tests__/Link.d.ts +1 -0
  377. package/lib-esm/__tests__/Link.js +62 -0
  378. package/lib-esm/__tests__/Overlay.d.ts +1 -0
  379. package/lib-esm/__tests__/Overlay.js +123 -0
  380. package/lib-esm/__tests__/Pagehead.d.ts +1 -0
  381. package/lib-esm/__tests__/Pagehead.js +28 -0
  382. package/lib-esm/__tests__/Pagination/Pagination.d.ts +1 -0
  383. package/lib-esm/__tests__/Pagination/Pagination.js +37 -0
  384. package/lib-esm/__tests__/Pagination/PaginationModel.d.ts +1 -0
  385. package/lib-esm/__tests__/Pagination/PaginationModel.js +182 -0
  386. package/lib-esm/__tests__/PointerBox.d.ts +1 -0
  387. package/lib-esm/__tests__/PointerBox.js +38 -0
  388. package/lib-esm/__tests__/Popover.d.ts +1 -0
  389. package/lib-esm/__tests__/Popover.js +56 -0
  390. package/lib-esm/__tests__/Portal.d.ts +1 -0
  391. package/lib-esm/__tests__/Portal.js +104 -0
  392. package/lib-esm/__tests__/Position.d.ts +1 -0
  393. package/lib-esm/__tests__/Position.js +138 -0
  394. package/lib-esm/__tests__/ProgressBar.d.ts +1 -0
  395. package/lib-esm/__tests__/ProgressBar.js +60 -0
  396. package/lib-esm/__tests__/SelectMenu.d.ts +1 -0
  397. package/lib-esm/__tests__/SelectMenu.js +145 -0
  398. package/lib-esm/__tests__/SelectPanel.d.ts +1 -0
  399. package/lib-esm/__tests__/SelectPanel.js +67 -0
  400. package/lib-esm/__tests__/SideNav.d.ts +1 -0
  401. package/lib-esm/__tests__/SideNav.js +63 -0
  402. package/lib-esm/__tests__/Spinner.d.ts +1 -0
  403. package/lib-esm/__tests__/Spinner.js +45 -0
  404. package/lib-esm/__tests__/StateLabel.d.ts +1 -0
  405. package/lib-esm/__tests__/StateLabel.js +63 -0
  406. package/lib-esm/__tests__/StyledOcticon.d.ts +1 -0
  407. package/lib-esm/__tests__/StyledOcticon.js +31 -0
  408. package/lib-esm/__tests__/SubNav.d.ts +1 -0
  409. package/lib-esm/__tests__/SubNav.js +52 -0
  410. package/lib-esm/__tests__/SubNavLink.d.ts +1 -0
  411. package/lib-esm/__tests__/SubNavLink.js +41 -0
  412. package/lib-esm/__tests__/TabNav.d.ts +1 -0
  413. package/lib-esm/__tests__/TabNav.js +42 -0
  414. package/lib-esm/__tests__/Text.d.ts +1 -0
  415. package/lib-esm/__tests__/Text.js +95 -0
  416. package/lib-esm/__tests__/TextInput.d.ts +1 -0
  417. package/lib-esm/__tests__/TextInput.js +70 -0
  418. package/lib-esm/__tests__/ThemeProvider.d.ts +1 -0
  419. package/lib-esm/__tests__/ThemeProvider.js +408 -0
  420. package/lib-esm/__tests__/Timeline.d.ts +1 -0
  421. package/lib-esm/__tests__/Timeline.js +69 -0
  422. package/lib-esm/__tests__/Tooltip.d.ts +1 -0
  423. package/lib-esm/__tests__/Tooltip.js +61 -0
  424. package/lib-esm/__tests__/Truncate.d.ts +1 -0
  425. package/lib-esm/__tests__/Truncate.js +55 -0
  426. package/lib-esm/__tests__/UnderlineNav.d.ts +1 -0
  427. package/lib-esm/__tests__/UnderlineNav.js +62 -0
  428. package/lib-esm/__tests__/UnderlineNavLink.d.ts +1 -0
  429. package/lib-esm/__tests__/UnderlineNavLink.js +43 -0
  430. package/lib-esm/__tests__/behaviors/anchoredPosition.d.ts +1 -0
  431. package/lib-esm/__tests__/behaviors/anchoredPosition.js +388 -0
  432. package/lib-esm/__tests__/behaviors/focusTrap.d.ts +1 -0
  433. package/lib-esm/__tests__/behaviors/focusTrap.js +227 -0
  434. package/lib-esm/__tests__/behaviors/focusZone.d.ts +1 -0
  435. package/lib-esm/__tests__/behaviors/focusZone.js +487 -0
  436. package/lib-esm/__tests__/behaviors/iterateFocusableElements.d.ts +1 -0
  437. package/lib-esm/__tests__/behaviors/iterateFocusableElements.js +48 -0
  438. package/lib-esm/__tests__/filterObject.d.ts +1 -0
  439. package/lib-esm/__tests__/filterObject.js +27 -0
  440. package/lib-esm/__tests__/hooks/useAnchoredPosition.d.ts +1 -0
  441. package/lib-esm/__tests__/hooks/useAnchoredPosition.js +46 -0
  442. package/lib-esm/__tests__/hooks/useOnEscapePress.d.ts +1 -0
  443. package/lib-esm/__tests__/hooks/useOnEscapePress.js +23 -0
  444. package/lib-esm/__tests__/hooks/useOnOutsideClick.d.ts +1 -0
  445. package/lib-esm/__tests__/hooks/useOnOutsideClick.js +68 -0
  446. package/lib-esm/__tests__/hooks/useOpenAndCloseFocus.d.ts +1 -0
  447. package/lib-esm/__tests__/hooks/useOpenAndCloseFocus.js +52 -0
  448. package/lib-esm/__tests__/hooks/useProvidedStateOrCreate.d.ts +1 -0
  449. package/lib-esm/__tests__/hooks/useProvidedStateOrCreate.js +36 -0
  450. package/lib-esm/__tests__/theme.d.ts +1 -0
  451. package/lib-esm/__tests__/theme.js +33 -0
  452. package/lib-esm/__tests__/themeGet.d.ts +1 -0
  453. package/lib-esm/__tests__/themeGet.js +22 -0
  454. package/lib-esm/__tests__/useSafeTimeout.d.ts +1 -0
  455. package/lib-esm/__tests__/useSafeTimeout.js +39 -0
  456. package/lib-esm/stories/ActionList.stories.js +334 -0
  457. package/lib-esm/stories/ActionMenu.stories.js +293 -0
  458. package/lib-esm/stories/AnchoredOverlay.stories.js +101 -0
  459. package/lib-esm/stories/AvatarStack.stories.js +32 -0
  460. package/lib-esm/stories/Button.stories.js +78 -0
  461. package/lib-esm/stories/ConfirmationDialog.stories.js +86 -0
  462. package/lib-esm/stories/Dialog.stories.js +240 -0
  463. package/lib-esm/stories/DropdownMenu.stories.js +94 -0
  464. package/lib-esm/stories/Overlay.stories.js +154 -0
  465. package/lib-esm/stories/Portal.stories.js +68 -0
  466. package/lib-esm/stories/SelectPanel.stories.js +284 -0
  467. package/lib-esm/stories/ThemeProvider.stories.js +83 -0
  468. package/lib-esm/stories/useAnchoredPosition.stories.js +313 -0
  469. package/lib-esm/stories/useFocusTrap.stories.js +309 -0
  470. package/lib-esm/stories/useFocusZone.stories.js +554 -0
  471. package/migrating.md +250 -0
  472. package/now.json +17 -0
  473. package/package-lock.json +28661 -0
  474. package/package.json +2 -2
  475. package/rollup.config.js +36 -0
  476. package/script/build +19 -0
  477. package/script/setup +12 -0
  478. package/src/ActionList/Divider.tsx +25 -0
  479. package/src/ActionList/Group.tsx +45 -0
  480. package/src/ActionList/Header.tsx +74 -0
  481. package/src/ActionList/Item.tsx +460 -0
  482. package/src/ActionList/List.tsx +253 -0
  483. package/src/ActionList/index.ts +21 -0
  484. package/src/ActionMenu.tsx +106 -0
  485. package/src/AnchoredOverlay/AnchoredOverlay.tsx +180 -0
  486. package/src/AnchoredOverlay/index.ts +2 -0
  487. package/src/Avatar.tsx +46 -0
  488. package/src/AvatarPair.tsx +35 -0
  489. package/src/AvatarStack.tsx +161 -0
  490. package/src/BaseStyles.tsx +53 -0
  491. package/src/BorderBox.tsx +18 -0
  492. package/src/Box.tsx +54 -0
  493. package/src/BranchName.tsx +19 -0
  494. package/src/Breadcrumb.tsx +87 -0
  495. package/src/Button/Button.tsx +40 -0
  496. package/src/Button/ButtonBase.tsx +43 -0
  497. package/src/Button/ButtonClose.tsx +40 -0
  498. package/src/Button/ButtonDanger.tsx +43 -0
  499. package/src/Button/ButtonGroup.tsx +55 -0
  500. package/src/Button/ButtonInvisible.tsx +27 -0
  501. package/src/Button/ButtonOutline.tsx +43 -0
  502. package/src/Button/ButtonPrimary.tsx +41 -0
  503. package/src/Button/ButtonStyles.tsx +36 -0
  504. package/src/Button/ButtonTableList.tsx +58 -0
  505. package/src/Button/index.ts +16 -0
  506. package/src/Caret.tsx +133 -0
  507. package/src/CircleBadge.tsx +55 -0
  508. package/src/CircleOcticon.tsx +37 -0
  509. package/src/CounterLabel.tsx +52 -0
  510. package/src/Details.tsx +23 -0
  511. package/src/Dialog/ConfirmationDialog.tsx +184 -0
  512. package/src/Dialog/Dialog.tsx +419 -0
  513. package/src/Dialog.tsx +149 -0
  514. package/src/Dropdown.tsx +158 -0
  515. package/src/DropdownMenu/DropdownButton.tsx +15 -0
  516. package/src/DropdownMenu/DropdownMenu.tsx +115 -0
  517. package/src/DropdownMenu/index.ts +4 -0
  518. package/src/DropdownStyles.ts +128 -0
  519. package/src/FilterList.tsx +81 -0
  520. package/src/FilteredActionList/FilteredActionList.tsx +152 -0
  521. package/src/FilteredActionList/index.ts +2 -0
  522. package/src/FilteredSearch.tsx +28 -0
  523. package/src/Flash.tsx +77 -0
  524. package/src/Flex.tsx +15 -0
  525. package/src/FormGroup.tsx +27 -0
  526. package/src/Grid.tsx +15 -0
  527. package/src/Header.tsx +84 -0
  528. package/src/Heading.tsx +21 -0
  529. package/src/Label.tsx +75 -0
  530. package/src/LabelGroup.tsx +18 -0
  531. package/src/Link.tsx +46 -0
  532. package/src/Overlay.tsx +194 -0
  533. package/src/Pagehead.tsx +17 -0
  534. package/src/Pagination/Pagination.tsx +214 -0
  535. package/src/Pagination/index.ts +4 -0
  536. package/src/Pagination/model.tsx +187 -0
  537. package/src/PointerBox.tsx +31 -0
  538. package/src/Popover.tsx +236 -0
  539. package/src/Portal/Portal.tsx +96 -0
  540. package/src/Portal/index.ts +5 -0
  541. package/src/Position.tsx +63 -0
  542. package/src/ProgressBar.tsx +52 -0
  543. package/src/SelectMenu/SelectMenu.tsx +125 -0
  544. package/src/SelectMenu/SelectMenuContext.tsx +9 -0
  545. package/src/SelectMenu/SelectMenuDivider.tsx +25 -0
  546. package/src/SelectMenu/SelectMenuFilter.tsx +51 -0
  547. package/src/SelectMenu/SelectMenuFooter.tsx +28 -0
  548. package/src/SelectMenu/SelectMenuHeader.tsx +50 -0
  549. package/src/SelectMenu/SelectMenuItem.tsx +137 -0
  550. package/src/SelectMenu/SelectMenuList.tsx +42 -0
  551. package/src/SelectMenu/SelectMenuLoadingAnimation.tsx +24 -0
  552. package/src/SelectMenu/SelectMenuModal.tsx +121 -0
  553. package/src/SelectMenu/SelectMenuTab.tsx +88 -0
  554. package/src/SelectMenu/SelectMenuTabPanel.tsx +30 -0
  555. package/src/SelectMenu/SelectMenuTabs.tsx +44 -0
  556. package/src/SelectMenu/hooks/useKeyboardNav.js +90 -0
  557. package/src/SelectMenu/index.ts +15 -0
  558. package/src/SelectPanel/SelectPanel.tsx +173 -0
  559. package/src/SelectPanel/index.ts +2 -0
  560. package/src/SideNav.tsx +193 -0
  561. package/src/Spinner.tsx +59 -0
  562. package/src/StateLabel.tsx +110 -0
  563. package/src/StyledOcticon.tsx +24 -0
  564. package/src/SubNav.tsx +129 -0
  565. package/src/TabNav.tsx +77 -0
  566. package/src/Text.tsx +13 -0
  567. package/src/TextInput.tsx +183 -0
  568. package/src/ThemeProvider.tsx +176 -0
  569. package/src/Timeline.tsx +141 -0
  570. package/src/Tooltip.tsx +263 -0
  571. package/src/Truncate.tsx +36 -0
  572. package/src/UnderlineNav.tsx +110 -0
  573. package/src/__tests__/.eslintrc.json +11 -0
  574. package/src/__tests__/ActionList.tsx +49 -0
  575. package/src/__tests__/ActionMenu.tsx +138 -0
  576. package/src/__tests__/AnchoredOverlay.tsx +151 -0
  577. package/src/__tests__/Avatar.tsx +45 -0
  578. package/src/__tests__/AvatarStack.tsx +45 -0
  579. package/src/__tests__/BorderBox.tsx +44 -0
  580. package/src/__tests__/Box.tsx +43 -0
  581. package/src/__tests__/BranchName.tsx +27 -0
  582. package/src/__tests__/Breadcrumb.tsx +31 -0
  583. package/src/__tests__/BreadcrumbItem.tsx +32 -0
  584. package/src/__tests__/Button.tsx +129 -0
  585. package/src/__tests__/Caret.tsx +36 -0
  586. package/src/__tests__/CircleBadge.tsx +69 -0
  587. package/src/__tests__/CircleOcticon.tsx +52 -0
  588. package/src/__tests__/CounterLabel.tsx +51 -0
  589. package/src/__tests__/Details.tsx +116 -0
  590. package/src/__tests__/Dialog.tsx +157 -0
  591. package/src/__tests__/Dropdown.tsx +57 -0
  592. package/src/__tests__/DropdownMenu.tsx +138 -0
  593. package/src/__tests__/FilterList.tsx +27 -0
  594. package/src/__tests__/FilterListItem.tsx +32 -0
  595. package/src/__tests__/FilteredSearch.tsx +27 -0
  596. package/src/__tests__/Flash.tsx +46 -0
  597. package/src/__tests__/Flex.tsx +59 -0
  598. package/src/__tests__/FormGroup.tsx +39 -0
  599. package/src/__tests__/Grid.tsx +83 -0
  600. package/src/__tests__/Header.tsx +50 -0
  601. package/src/__tests__/Heading.tsx +92 -0
  602. package/src/__tests__/Label.tsx +35 -0
  603. package/src/__tests__/LabelGroup.tsx +31 -0
  604. package/src/__tests__/Link.tsx +48 -0
  605. package/src/__tests__/Overlay.tsx +103 -0
  606. package/src/__tests__/Pagehead.tsx +24 -0
  607. package/src/__tests__/Pagination/Pagination.tsx +31 -0
  608. package/src/__tests__/Pagination/PaginationModel.tsx +133 -0
  609. package/src/__tests__/Pagination/__snapshots__/Pagination.tsx.snap +184 -0
  610. package/src/__tests__/PointerBox.tsx +35 -0
  611. package/src/__tests__/Popover.tsx +69 -0
  612. package/src/__tests__/Portal.tsx +103 -0
  613. package/src/__tests__/Position.tsx +118 -0
  614. package/src/__tests__/ProgressBar.tsx +41 -0
  615. package/src/__tests__/SelectMenu.tsx +142 -0
  616. package/src/__tests__/SelectPanel.tsx +65 -0
  617. package/src/__tests__/SideNav.tsx +63 -0
  618. package/src/__tests__/Spinner.tsx +44 -0
  619. package/src/__tests__/StateLabel.tsx +50 -0
  620. package/src/__tests__/StyledOcticon.tsx +28 -0
  621. package/src/__tests__/SubNav.tsx +51 -0
  622. package/src/__tests__/SubNavLink.tsx +32 -0
  623. package/src/__tests__/TabNav.tsx +33 -0
  624. package/src/__tests__/Text.tsx +79 -0
  625. package/src/__tests__/TextInput.tsx +50 -0
  626. package/src/__tests__/ThemeProvider.tsx +441 -0
  627. package/src/__tests__/Timeline.tsx +59 -0
  628. package/src/__tests__/Tooltip.tsx +53 -0
  629. package/src/__tests__/Truncate.tsx +45 -0
  630. package/src/__tests__/UnderlineNav.tsx +59 -0
  631. package/src/__tests__/UnderlineNavLink.tsx +32 -0
  632. package/src/__tests__/__snapshots__/ActionList.tsx.snap +27 -0
  633. package/src/__tests__/__snapshots__/ActionMenu.tsx.snap +80 -0
  634. package/src/__tests__/__snapshots__/AnchoredOverlay.tsx.snap +332 -0
  635. package/src/__tests__/__snapshots__/Avatar.tsx.snap +19 -0
  636. package/src/__tests__/__snapshots__/AvatarStack.tsx.snap +377 -0
  637. package/src/__tests__/__snapshots__/BorderBox.tsx.snap +14 -0
  638. package/src/__tests__/__snapshots__/Box.tsx.snap +201 -0
  639. package/src/__tests__/__snapshots__/BranchName.tsx.snap +17 -0
  640. package/src/__tests__/__snapshots__/Breadcrumb.tsx.snap +29 -0
  641. package/src/__tests__/__snapshots__/BreadcrumbItem.tsx.snap +79 -0
  642. package/src/__tests__/__snapshots__/Button.tsx.snap +832 -0
  643. package/src/__tests__/__snapshots__/Caret.tsx.snap +373 -0
  644. package/src/__tests__/__snapshots__/CircleBadge.tsx.snap +141 -0
  645. package/src/__tests__/__snapshots__/CircleOcticon.tsx.snap +64 -0
  646. package/src/__tests__/__snapshots__/CounterLabel.tsx.snap +22 -0
  647. package/src/__tests__/__snapshots__/Details.tsx.snap +15 -0
  648. package/src/__tests__/__snapshots__/Dialog.tsx.snap +200 -0
  649. package/src/__tests__/__snapshots__/Dropdown.tsx.snap +249 -0
  650. package/src/__tests__/__snapshots__/DropdownMenu.tsx.snap +106 -0
  651. package/src/__tests__/__snapshots__/FilterList.tsx.snap +13 -0
  652. package/src/__tests__/__snapshots__/FilterListItem.tsx.snap +80 -0
  653. package/src/__tests__/__snapshots__/FilteredSearch.tsx.snap +32 -0
  654. package/src/__tests__/__snapshots__/Flash.tsx.snap +32 -0
  655. package/src/__tests__/__snapshots__/Flex.tsx.snap +130 -0
  656. package/src/__tests__/__snapshots__/FormGroup.tsx.snap +25 -0
  657. package/src/__tests__/__snapshots__/Grid.tsx.snap +178 -0
  658. package/src/__tests__/__snapshots__/Header.tsx.snap +79 -0
  659. package/src/__tests__/__snapshots__/Heading.tsx.snap +13 -0
  660. package/src/__tests__/__snapshots__/Label.tsx.snap +74 -0
  661. package/src/__tests__/__snapshots__/LabelGroup.tsx.snap +15 -0
  662. package/src/__tests__/__snapshots__/Link.tsx.snap +213 -0
  663. package/src/__tests__/__snapshots__/Pagehead.tsx.snap +15 -0
  664. package/src/__tests__/__snapshots__/PointerBox.tsx.snap +174 -0
  665. package/src/__tests__/__snapshots__/Popover.tsx.snap +4687 -0
  666. package/src/__tests__/__snapshots__/Position.tsx.snap +44 -0
  667. package/src/__tests__/__snapshots__/ProgressBar.tsx.snap +53 -0
  668. package/src/__tests__/__snapshots__/SelectMenu.tsx.snap +469 -0
  669. package/src/__tests__/__snapshots__/SelectPanel.tsx.snap +123 -0
  670. package/src/__tests__/__snapshots__/SideNav.tsx.snap +143 -0
  671. package/src/__tests__/__snapshots__/Spinner.tsx.snap +33 -0
  672. package/src/__tests__/__snapshots__/StateLabel.tsx.snap +409 -0
  673. package/src/__tests__/__snapshots__/StyledOcticon.tsx.snap +25 -0
  674. package/src/__tests__/__snapshots__/SubNav.tsx.snap +44 -0
  675. package/src/__tests__/__snapshots__/SubNavLink.tsx.snap +199 -0
  676. package/src/__tests__/__snapshots__/TabNav.tsx.snap +58 -0
  677. package/src/__tests__/__snapshots__/Text.tsx.snap +7 -0
  678. package/src/__tests__/__snapshots__/TextInput.tsx.snap +440 -0
  679. package/src/__tests__/__snapshots__/ThemeProvider.tsx.snap +15 -0
  680. package/src/__tests__/__snapshots__/Timeline.tsx.snap +159 -0
  681. package/src/__tests__/__snapshots__/Tooltip.tsx.snap +227 -0
  682. package/src/__tests__/__snapshots__/Truncate.tsx.snap +17 -0
  683. package/src/__tests__/__snapshots__/UnderlineNav.tsx.snap +59 -0
  684. package/src/__tests__/__snapshots__/UnderlineNavLink.tsx.snap +130 -0
  685. package/src/__tests__/behaviors/anchoredPosition.ts +295 -0
  686. package/src/__tests__/behaviors/focusTrap.tsx +236 -0
  687. package/src/__tests__/behaviors/focusZone.tsx +549 -0
  688. package/src/__tests__/behaviors/iterateFocusableElements.tsx +61 -0
  689. package/src/__tests__/filterObject.ts +54 -0
  690. package/src/__tests__/hooks/useAnchoredPosition.tsx +31 -0
  691. package/src/__tests__/hooks/useOnEscapePress.tsx +16 -0
  692. package/src/__tests__/hooks/useOnOutsideClick.tsx +48 -0
  693. package/src/__tests__/hooks/useOpenAndCloseFocus.tsx +48 -0
  694. package/src/__tests__/hooks/useProvidedStateOrCreate.tsx +39 -0
  695. package/src/__tests__/theme.ts +41 -0
  696. package/src/__tests__/themeGet.ts +15 -0
  697. package/src/__tests__/useSafeTimeout.tsx +36 -0
  698. package/src/behaviors/anchoredPosition.ts +442 -0
  699. package/src/behaviors/focusTrap.ts +184 -0
  700. package/src/behaviors/focusZone.ts +713 -0
  701. package/src/constants.ts +62 -0
  702. package/src/hooks/index.ts +11 -0
  703. package/src/hooks/useAnchoredPosition.ts +53 -0
  704. package/src/hooks/useCombinedRefs.ts +40 -0
  705. package/src/hooks/useDetails.tsx +54 -0
  706. package/src/hooks/useDialog.ts +121 -0
  707. package/src/hooks/useFocusTrap.ts +80 -0
  708. package/src/hooks/useFocusZone.ts +64 -0
  709. package/src/hooks/useOnEscapePress.ts +63 -0
  710. package/src/hooks/useOnOutsideClick.tsx +82 -0
  711. package/src/hooks/useOpenAndCloseFocus.ts +27 -0
  712. package/src/hooks/useOverlay.tsx +32 -0
  713. package/src/hooks/useProvidedRefOrCreate.ts +14 -0
  714. package/src/hooks/useProvidedStateOrCreate.ts +27 -0
  715. package/src/hooks/useRenderForcingRef.ts +22 -0
  716. package/src/hooks/useResizeObserver.ts +11 -0
  717. package/src/hooks/useSafeTimeout.ts +38 -0
  718. package/src/hooks/useScrollFlash.ts +21 -0
  719. package/src/index.ts +165 -0
  720. package/src/polyfills/eventListenerSignal.ts +66 -0
  721. package/src/stories/ActionList.stories.tsx +364 -0
  722. package/src/stories/ActionMenu.stories.tsx +322 -0
  723. package/src/stories/AnchoredOverlay.stories.tsx +117 -0
  724. package/src/stories/AvatarStack.stories.tsx +37 -0
  725. package/src/stories/Button.stories.tsx +88 -0
  726. package/src/stories/ConfirmationDialog.stories.tsx +105 -0
  727. package/src/stories/Dialog.stories.tsx +240 -0
  728. package/src/stories/DropdownMenu.stories.tsx +84 -0
  729. package/src/stories/Overlay.stories.tsx +186 -0
  730. package/src/stories/Portal.stories.tsx +109 -0
  731. package/src/stories/SelectPanel.stories.tsx +300 -0
  732. package/src/stories/ThemeProvider.stories.tsx +104 -0
  733. package/src/stories/useAnchoredPosition.stories.tsx +320 -0
  734. package/src/stories/useFocusTrap.stories.tsx +400 -0
  735. package/src/stories/useFocusZone.stories.tsx +663 -0
  736. package/src/sx.ts +9 -0
  737. package/src/theme-preval.js +136 -0
  738. package/src/theme.ts +3 -0
  739. package/src/utils/deprecate.tsx +73 -0
  740. package/src/utils/isNumeric.tsx +4 -0
  741. package/src/utils/iterateFocusableElements.ts +121 -0
  742. package/src/utils/ssr.tsx +1 -0
  743. package/src/utils/test-deprecations.tsx +19 -0
  744. package/src/utils/test-helpers.tsx +7 -0
  745. package/src/utils/test-matchers.tsx +109 -0
  746. package/src/utils/testing.tsx +243 -0
  747. package/src/utils/theme.js +64 -0
  748. package/src/utils/types.ts +90 -0
  749. package/src/utils/uniqueId.ts +6 -0
  750. package/src/utils/userAgent.ts +7 -0
  751. package/stats.html +3279 -0
  752. package/tsconfig.build.json +7 -0
  753. package/tsconfig.json +20 -0
@@ -0,0 +1,45 @@
1
+ ---
2
+ title: CircleBadge
3
+ ---
4
+
5
+ Use CircleBadge to visually connect logos of third party services like in marketplace. Use CircleBadge.Icon to add an Octicon to the CircleBadge.
6
+
7
+ ## Default example
8
+
9
+ ```jsx live
10
+ <CircleBadge>
11
+ <CircleBadge.Icon icon={ZapIcon} />
12
+ </CircleBadge>
13
+ ```
14
+
15
+ ## System props
16
+
17
+ <Note variant="warning">
18
+
19
+ System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead.
20
+
21
+ </Note>
22
+
23
+ CircleBadge and CircleBadge.Icon components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props.
24
+
25
+ ## Component props
26
+
27
+ ### CircleBadge
28
+
29
+ | Name | Type | Default | Description |
30
+ | :------ | :------ | :------: | :---------------------------------------------------------------------------------------------------------- |
31
+ | as | String | `div` | sets the HTML tag for the component |
32
+ | inline | Boolean | false | Styles the badge to display inline |
33
+ | size | Number | | sets the size of the badge in pixels; overrides any value for `variant` prop when set |
34
+ | variant | String | 'medium' | a value of `small`, `medium`, or `large` creates a smaller or larger badge; no effect if `size` prop is set |
35
+
36
+ ### CircleBadge.Icon
37
+
38
+ CircleBadge.Icon components receive all the same props at [StyledOcticon]. They are listed below for convenience:
39
+
40
+ | Name | Type | Default | Description |
41
+ | :------------ | :-------- | :-----------: | :----------------------------------------------------------------------------------------------------------- |
42
+ | ariaLabel | String | | Specifies the `aria-label` attribute, which is read verbatim by screen readers |
43
+ | icon | Component | | [Octicon component](https://github.com/primer/octicons/tree/master/lib/octicons_react) used in the component |
44
+ | size | Number | 16 | Sets the uniform `width` and `height` of the SVG element |
45
+ | verticalAlign | String | `text-bottom` | Sets the `vertical-align` CSS property |
@@ -0,0 +1,18 @@
1
+ ---
2
+ title: CircleOcticon
3
+ ---
4
+
5
+ CircleOcticon renders any Octicon with a circle background. CircleOcticons are most commonly used to represent the status of a pull request in the comment timeline.
6
+
7
+ ## Default example
8
+
9
+ ```jsx live
10
+ <CircleOcticon icon={CheckIcon} size={32} sx={{bg: 'icon.success', color: 'text.inverse'}} />
11
+ ```
12
+
13
+ ## Component props
14
+
15
+ | Name | Type | Default | Description |
16
+ | :--- | :------ | :-----: | :------------------------------------------------ |
17
+ | icon | Octicon | | Octicon component used in the component |
18
+ | size | Number | 32 | used to set the width and height of the component |
@@ -0,0 +1,30 @@
1
+ ---
2
+ title: CounterLabel
3
+ tags: pill
4
+ ---
5
+
6
+ Use the CounterLabel component to add a count to navigational elements and buttons.
7
+
8
+ ## Default example
9
+
10
+ ```jsx live
11
+ <CounterLabel>12</CounterLabel>
12
+ <CounterLabel scheme="primary">13</CounterLabel>
13
+ <CounterLabel scheme="secondary">13</CounterLabel>
14
+ ```
15
+
16
+ ## System props
17
+
18
+ <Note variant="warning">
19
+
20
+ System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead.
21
+
22
+ </Note>
23
+
24
+ CounterLabel components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props.
25
+
26
+ ## Component props
27
+
28
+ | Name | Type | Default | Description |
29
+ | :----- | :----- | :-----: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
30
+ | scheme | String | | Pass in 'primary' for a darker background and inverse text, or 'gray-light' for a lighter background and primary text. Omitting the scheme prop renders the default counter scheme |
@@ -0,0 +1,105 @@
1
+ ---
2
+ title: Details & useDetails hook
3
+ ---
4
+
5
+ `Details` is a styled `details` element for use with the `useDetails` hook. The `useDetails` hook returns the `open` state, a `setOpen` function to manually change the open state, and **`getDetailsProps` which must be spread onto your `Details` element in order for `Details` to get receive the proper behaviors provided by the hook**. See Kent Dodd's article on this pattern [here](https://kentcdodds.com/blog/how-to-give-rendering-control-to-users-with-prop-getters).
6
+
7
+ The `useDetails` hook also takes a few configuration options as parameters which are noted in the table below.
8
+
9
+ You must use a `summary` element as your `Details` trigger button. To style your summary element like a [Button](./Button), you can use the `as` prop (see example below).
10
+
11
+ It's also possible to use the `useDetails` hook with components other than the Primer `Details`, such as a custom `Details` or `Modal` wrapper in your consuming application. All that matters is that the outer element is a `details` and it contains a `summary` for the button that opens and closes the component, and that `getDetailsProps` is properly spread onto the component rendering your `details` element.
12
+
13
+ ```jsx live
14
+ <State>
15
+ {([]) => {
16
+ const {getDetailsProps} = useDetails({closeOnOutsideClick: true})
17
+ return (
18
+ <Details {...getDetailsProps()}>
19
+ <Button as="summary">Hello</Button>
20
+ This is some content
21
+ </Details>
22
+ )
23
+ }}
24
+ </State>
25
+ ```
26
+
27
+ You can use the `open` state returned from the hook to conditionally render content:
28
+
29
+ ```jsx live
30
+ <State>
31
+ {([]) => {
32
+ const {getDetailsProps, open} = useDetails({closeOnOutsideClick: true})
33
+ return (
34
+ <Details {...getDetailsProps()}>
35
+ <Button as="summary">{open ? 'open' : 'close'}</Button>
36
+ This is some content
37
+ </Details>
38
+ )
39
+ }}
40
+ </State>
41
+ ```
42
+
43
+ You can also manually show/hide the content using the `setOpen` function returned from the hook. This can be useful if you have action items in the content of the component such as confirmation buttons:
44
+
45
+ ```jsx live
46
+ <State>
47
+ {([]) => {
48
+ const {getDetailsProps, setOpen} = useDetails({closeOnOutsideClick: true})
49
+ return (
50
+ <Details {...getDetailsProps()}>
51
+ <Button as="summary">Delete item</Button>
52
+ Are you sure?
53
+ <ButtonDanger onClick={() => setOpen(false)}>Yes I'm sure</ButtonDanger>
54
+ </Details>
55
+ )
56
+ }}
57
+ </State>
58
+ ```
59
+
60
+ In previous versions of Primer React Components, we allowed users to pass in a custom `onToggle` function. You can do this now by overriding the `onToggle` function returned in `getDetailsProps`. Please note that in most cases, you'll want the hook's handling of `onToggle` to be run as well, so that the internal state is properly updated. To do this, manually call the `onToggle` handler returned from `useDetails` before executing your custom `onToggle` code.
61
+
62
+ ```jsx live
63
+ <State>
64
+ {([]) => {
65
+ const {getDetailsProps, open, setOpen} = useDetails({closeOnOutsideClick: true})
66
+ const {onToggle, ...detailsProps} = getDetailsProps()
67
+ const customToggle = e => {
68
+ onToggle(e)
69
+ window.alert('hi')
70
+ }
71
+ return (
72
+ <Details {...detailsProps} onToggle={customToggle}>
73
+ <Button as="summary">{open ? 'Open' : 'Closed'}</Button>
74
+ Hello World
75
+ </Details>
76
+ )
77
+ }}
78
+ </State>
79
+ ```
80
+
81
+ ## `Details` System props
82
+
83
+ <Note variant="warning">
84
+
85
+ System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead.
86
+
87
+ </Note>
88
+
89
+ Details components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props.
90
+
91
+ ## `useDetails` hook configuration options
92
+
93
+ | Name | Type | Default | Description |
94
+ | :------------------ | :-------- | :-----: | :------------------------------------------------------------------------ |
95
+ | defaultOpen | Boolean | | Sets the initial open/closed state |
96
+ | closeOnOutsideClick | Boolean | false | Sets whether or not element will close when the user clicks outside of it |
97
+ | ref | React ref | | optional ref to pass down to Details component |
98
+
99
+ ### Values returned by the `useDetails` hook
100
+
101
+ | Name | Type | Description |
102
+ | :-------------- | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
103
+ | open | string | Whether or not Details is currently open |
104
+ | setOpen | function | Used to manually change the open state of the Details component |
105
+ | getDetailsProps | Object | Contains an `onToggle` function, the `ref` to pass down to `Details` and the `open` attribute. In most cases, you won't need to interact with any of these values directly, but if you'd like to override any of these yourself you may. |
@@ -0,0 +1,108 @@
1
+ ---
2
+ title: Dialog
3
+ ---
4
+
5
+ import State from '../components/State'
6
+
7
+ The dialog component is used for all modals. It renders on top of the rest of the app with an overlay.
8
+
9
+ You'll need to manage the `isOpen` state in a wrapper component of your own and pass in a function to be used to close the Dialog. For documentation purposes only we've created a mock `State` to handle this, but you should handle the state in the component you consume `Dialog` in or in a wrapper component.
10
+
11
+ ### Accessibility
12
+
13
+ A few considerations must be made to ensure your use of the `Dialog` component is accessible:
14
+
15
+ - Always be sure to provide either `aria-labelledby` or `aria-label` to your `Dialog` component. In most cases you should use `aria-labelledby` and pass it the `id` of your `Dialog.Header`. If there is no text in your header, or you chose not to use a header, you can use `aria-label` to describe the purpose of the `Dialog`.
16
+
17
+ - Be sure to pass a ref to return the focus back to once the `Dialog` closes via the `returnFocusRef` prop. In most cases this should be the element that opened the Dialog. If you decide to manage focus within your application and want to bypass Primer React Components from doing so when the `Dialog` closes, you can omit the `returnFocusProp`.
18
+
19
+ ### Z-index
20
+
21
+ If you're running into z-index issues or are rendering the component inside of an absolutely positioned element, you can wrap your `Dialog` in a [React Portal](https://reactjs.org/docs/portals.html).
22
+
23
+ ### Examples
24
+
25
+ ```jsx live
26
+ <State default={false}>
27
+ {([isOpen, setIsOpen]) => {
28
+ const returnFocusRef = React.useRef(null)
29
+ return (
30
+ <>
31
+ <Button ref={returnFocusRef} onClick={() => setIsOpen(true)}>
32
+ Open
33
+ </Button>
34
+ <Dialog
35
+ returnFocusRef={returnFocusRef}
36
+ isOpen={isOpen}
37
+ onDismiss={() => setIsOpen(false)}
38
+ aria-labelledby="header-id"
39
+ >
40
+ <Dialog.Header id="header-id">Title</Dialog.Header>
41
+ <Box p={3}>
42
+ <Text fontFamily="sans-serif">Some content</Text>
43
+ </Box>
44
+ </Dialog>
45
+ </>
46
+ )
47
+ }}
48
+ </State>
49
+ ```
50
+
51
+ You can also pass any non-text content into the header:
52
+
53
+ ```jsx live
54
+ <State default={false}>
55
+ {([isOpen, setIsOpen]) => {
56
+ const returnFocusRef = React.useRef(null)
57
+ return (
58
+ <>
59
+ <Button ref={returnFocusRef} onClick={() => setIsOpen(true)}>
60
+ Open
61
+ </Button>
62
+ <Dialog
63
+ isOpen={isOpen}
64
+ returnFocusRef={returnFocusRef}
65
+ onDismiss={() => setIsOpen(false)}
66
+ aria-labelledby="label"
67
+ >
68
+ <Dialog.Header>
69
+ <ZapIcon />
70
+ </Dialog.Header>
71
+ <Box p={3}>
72
+ <Text id="label" fontFamily="sans-serif">
73
+ Are you sure you'd like to delete this issue?
74
+ </Text>
75
+ <Box display="flex" mt={3} justifyContent="flex-end">
76
+ <Button sx={{mr: 1}}>Cancel</Button>
77
+ <ButtonDanger>Delete</ButtonDanger>
78
+ </Box>
79
+ </Box>
80
+ </Dialog>
81
+ </>
82
+ )
83
+ }}
84
+ </State>
85
+ ```
86
+
87
+ ## System props
88
+
89
+ <Note variant="warning">
90
+
91
+ System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead.
92
+
93
+ </Note>
94
+
95
+ `Dialog` components get the `COMMON` and `LAYOUT` categories of system props. `Dialog.Header` components get `COMMON`, `LAYOUT`, and `FLEX` system props. Read our [System Props](/system-props) doc page for a full list of available props.
96
+
97
+ ## Component props
98
+
99
+ | Prop name | Type | Description |
100
+ | :-------------- | :-------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------- |
101
+ | isOpen | Boolean | Set whether or not the dialog is shown |
102
+ | onDismiss | Function | A user-provided function that should close the dialog |
103
+ | returnFocusRef | React ref | The element to restore focus back to after the `Dialog` is closed |
104
+ | initialFocusRef | React ref | Element inside of the `Dialog` you'd like to be focused when the Dialog is opened. If nothing is passed to `initialFocusRef` the close button is focused. |
105
+ | aria-labelledby | string | Pass an id to use for the aria-label. Use either a `aria-label` or an `aria-labelledby` but not both. |
106
+ | aria-label | string | Pass a label to be used to describe the Dialog. Use either a `aria-label` or an `aria-labelledby` but not both. |
107
+
108
+ `Dialog.Header` does not take any non-system props.
@@ -0,0 +1,179 @@
1
+ ---
2
+ title: Dialog v2
3
+ ---
4
+
5
+ import State from '../components/State'
6
+
7
+ The dialog component the Primer implementation of the ARIA design pattern [Dialog](https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal). A dialog is a type of overlay that can be used for confirming actions, asking for disambiguation, and presenting small forms. They generally allow the user to focus on a quick task without having to navigate to a different page.
8
+
9
+ **Dialogs appear in the page after a direct user interaction**. Don't show dialogs on page load or as system alerts.
10
+
11
+ **Dialogs appear centered in the page**, with a visible backdrop that dims the rest of the window for focus.
12
+
13
+ **All dialogs should have a title and a close button**. Use the `title` prop to set the title. The close button is created automatically, but must be handled with an `onClose` prop.
14
+
15
+ **Dialogs are modal**. Dialogs can be dismissed by clicking on the close button, or by interacting with another button in the overlay. To avoid losing information and missing important messages, clicking outside of the dialog will not close it.
16
+
17
+ **(Coming soon) Make sure larger dialogs remain mobile-friendly**. Even large dialogs need to be responsive. A dialog's width and height will be readjusted depending on the screen size and should never exceed the available space. Use responsive solutions to adjust the UI so they behave well on smaller screens.
18
+
19
+ **(Coming soon) Simple and small dialogs can remain as-is on mobile**. As more elements are added to it, mobile-specific style variations such as **Bottom sheet** and **Full-screen** should be considered.
20
+
21
+ ### State
22
+
23
+ The dialog component is completely stateless. The parent component must conditionally render a dialog based on the necessary criteria. The parent component can be notified by a gesture to close the dialog (e.g. by clicking the "X" button or by pressing the Escape key) by passing in the `onClose` prop.
24
+
25
+ ### Accessibility
26
+
27
+ The dialog component is fully accessible out-of-the-box. The dialog's title is used for `aria-labelledby`, and the dialog's description is used for `aria-describedby`. The `aria-modal="true"` attribute is used to inform screen readers that the rest of the content on the page is inert.
28
+
29
+ #### Keyboard
30
+
31
+ The default keyboard API for a dialog employs three mechanisms:
32
+
33
+ 1. The Escape key can be pressed to close the dialog.
34
+ 2. Focus is trapped within the top-most dialog. When a dialog is opened, the close button receives initial focus by default, or on a button defined with `autoFocus: true`.
35
+ 3. If there are buttons in the dialog footer, focus can be moved between them with left and right arrow keys or tab/shift+tab.
36
+ 4. When a dialog is closed, it can optionally handle returning focus to the element that was focused immediately before the dialog was opened. Otherwise, it is the consumer's responsibility to move focus to a suitable element.
37
+
38
+ ### Custom rendering
39
+
40
+ **Note: using custom rendering allows breaking out of the defined design, UX, and accessibility patterns of the dialog. Use only as a last resort.**
41
+
42
+ By default, the Dialog component implements the design and interactions defined by the Primer design system. If necessary, you can provide custom renderers for the header, body, or footer using the `renderHeader`, `renderBody`, and `renderFooter` props, respectively. The JSX produced by these render props will render full-bleed into their respective areas of the dialog. If you are using the custom renderers, you should use the provided sub-components `Dialog.Header`, `Dialog.Title`, `Dialog.Subtitle`, `Dialog.CloseButton`, `Dialog.Body`, `Dialog.Footer`, and `Dialog.Buttons` to the extent possible.
43
+
44
+ ### Example
45
+
46
+ ```jsx live
47
+ <State default={false}>
48
+ {([isOpen, setIsOpen]) => {
49
+ const openDialog = React.useCallback(() => setIsOpen(true), [setIsOpen])
50
+ const closeDialog = React.useCallback(() => setIsOpen(false), [setIsOpen])
51
+ return (
52
+ <>
53
+ <Button onClick={openDialog}>Open</Button>
54
+ {isOpen && (
55
+ <Dialog2
56
+ title="Dialog example"
57
+ subtitle={
58
+ <>
59
+ This is a <b>description</b> of the dialog.
60
+ </>
61
+ }
62
+ footerButtons={[{content: 'Ok', onClick: closeDialog}]}
63
+ onClose={closeDialog}
64
+ >
65
+ <Text fontFamily="sans-serif">Some content</Text>
66
+ </Dialog2>
67
+ )}
68
+ </>
69
+ )
70
+ }}
71
+ </State>
72
+ ```
73
+
74
+ ## Component props
75
+
76
+ ### DialogProps
77
+
78
+ | Prop name | Type | Default | Description |
79
+ | :------------ | :--------------------------------------------- | :--------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
80
+ | title | `React.ReactNode` | `"Dialog"` | Sets the title of the dialog, which by default is also used as the `aria-labelledby` attribute. |
81
+ | subtitle | `React.ReactNode` | | Optional. Sets the subtitle of the dialog, which by default is also used as the `aria-describedby` attribute. |
82
+ | renderHeader | `(props: DialogHeaderProps) => JSX.Element` | | Optional. Custom render the dialog header. See "Custom rendering" above for more info. |
83
+ | renderBody | `(props: DialogProps) => JSX.Element` | | Optional. Custom render the dialog body. See "Custom rendering" above for more info. |
84
+ | renderFooter | `(props: DialogProps) => JSX.Element` | | Optional. Custom render the dialog footer. See "Custom rendering" above for more info. |
85
+ | footerButtons | `DialogButtonProps[]` | | Optional. Specify buttons that will be rendered in the footer of the dialog. |
86
+ | onClose | `(gesture: 'close-button' │ 'escape') => void` | | Required. This method is invoked when a gesture to close the dialog is used (either an Escape key press or clicking the "X" in the top-right corner). The gesture argument indicates the gesture that was used to close the dialog (either 'close-button' or 'escape'). |
87
+ | role | `"dialog" │ "alertdialog"` | `"dialog"` | The ARIA role given to the dialog element. More info: [dialog](https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal), [alertdialog](https://www.w3.org/TR/wai-aria-practices-1.1/#alertdialog) |
88
+ | width | `"small" │ "medium" │ "large" │ "xlarge"` | `"xlarge"` | The fixed width of the dialog. |
89
+ | height | `"small" │ "large" │ "auto"` | `"auto"` | The fixed height of the dialog, or, auto to adjust the height based on its contents. |
90
+
91
+ ### DialogHeaderProps
92
+
93
+ The `DialogHeaderProps` interface extends `DialogProps` and adds these additional properties:
94
+
95
+ | Prop name | Type | Description |
96
+ | :------------------ | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------- |
97
+ | dialogLabelId | `string` | ID of the element that will be used as the `aria-labelledby` attribute on the dialog. This ID should be set to the element that renders the dialog's title. |
98
+ | dialogDescriptionId | `string` | ID of the element that will be used as the `aria-describedby` attribute on the dialog. This ID should be set to the element that renders the dialog's subtitle. |
99
+
100
+ ### DialogButtonProps
101
+
102
+ The `DialogButtonProps` interface extends `ButtonProps` (see Button) and adds these additional properties:
103
+
104
+ | Prop name | Type | Default | Description |
105
+ | :--------- | :-------------------------------- | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
106
+ | buttonType | `"normal" │ "primary" │ "danger"` | `Button` | The type of button to render |
107
+ | content | `React.ReactNode` | | Required. The button's inner content. |
108
+ | autoFocus | `boolean` | false | If true, this button will be automatically focused when the dialog is first rendered. If `autoFocus` is true on subsequent button definitions, it will be ignored. |
109
+
110
+ ## ConfirmationDialog
111
+
112
+ A `ConfirmationDialog` is a special kind of dialog with more rigid behavior. It is used to confirm a user action. `ConfirmationDialog`s always have exactly two buttons: one to cancel the action and one to confirm it. No custom rendering capabilities are provided for ConfirmationDialog.
113
+
114
+ ### useConfirm hook
115
+
116
+ An alternate way to use `ConfirmationDialog` is with the `useConfirm()` hook. It takes no parameters and returns an `async` function, `confirm`. When `confirm` is called (see ConfirmOptions below for its argument), it shows the confirmation dialog. When the dialog is dismissed, a promise is resolved with `true` or `false` depending on whether or not the confirm button was used.
117
+
118
+ ### Example (with `useConfirm` hook)
119
+
120
+ ```javascript live noinline
121
+ function ShorthandExample2() {
122
+ const confirm = useConfirm()
123
+ const buttonClick = React.useCallback(
124
+ async function (e) {
125
+ if (await confirm({title: 'Are you sure?', content: 'You must confirm this action to continue.'})) {
126
+ e.target.textContent = 'Confirmed!'
127
+ }
128
+ },
129
+ [confirm]
130
+ )
131
+ return (
132
+ <>
133
+ <Button onClick={buttonClick}>Confirmable action</Button>
134
+ </>
135
+ )
136
+ }
137
+ render(<ShorthandExample2 />)
138
+ ```
139
+
140
+ ### Example (using the full `ConfirmationDialog` component)
141
+
142
+ ```jsx live
143
+ <State default={false}>
144
+ {([isOpen, setIsOpen]) => {
145
+ const openDialog = React.useCallback(() => setIsOpen(true), [setIsOpen])
146
+ const closeDialog = React.useCallback(() => setIsOpen(false), [setIsOpen])
147
+ return (
148
+ <>
149
+ <Button onClick={openDialog}>Open</Button>
150
+ {isOpen && (
151
+ <ConfirmationDialog title="Confirm action?" onClose={closeDialog}>
152
+ Are you sure you want to confirm this action?
153
+ </ConfirmationDialog>
154
+ )}
155
+ </>
156
+ )
157
+ }}
158
+ </State>
159
+ ```
160
+
161
+ ### ConfirmationDialogProps
162
+
163
+ | Prop name | Type | Default | Description |
164
+ | :------------------- | :-------------------------------------------------------------------- | :--------- | :---------------------------------------------------------------------------------------------------------------------------- |
165
+ | title | `React.ReactNode` | | Required. Sets the title of the dialog, which by default is also used as the `aria-labelledby` attribute. |
166
+ | onClose | `(gesture: 'confirm' │ 'cancel' │ 'close-button' │ 'escape') => void` | | Required. This callback is invoked when a gesture to close the dialog is performed. The first argument indicates the gesture. |
167
+ | cancelButtonContent | `React.ReactNode` | `"Cancel"` | The content to use for the cancel button. |
168
+ | confirmButtonContent | `React.ReactNode` | `"OK"` | The content to use for the confirm button. |
169
+ | confirmButtonType | `"normal" │ "primary" │ "danger"` | `Button` | The type of button to use for the confirm button. |
170
+
171
+ ### ConfirmOptions
172
+
173
+ | Prop name | Type | Default | Description |
174
+ | :------------------- | :-------------------------------- | :--------- | :-------------------------------------------------------------------------------------------------------- |
175
+ | title | `React.ReactNode` | | Required. Sets the title of the dialog, which by default is also used as the `aria-labelledby` attribute. |
176
+ | content | `React.ReactNode` | | Required. Used as the body of the ConfirmationDialog that is displayed. |
177
+ | cancelButtonContent | `React.ReactNode` | `"Cancel"` | The content to use for the cancel button. |
178
+ | confirmButtonContent | `React.ReactNode` | `"OK"` | The content to use for the confirm button. |
179
+ | confirmButtonType | `"normal" │ "primary" │ "danger"` | `Button` | The type of button to use for the confirm button. |
@@ -0,0 +1,72 @@
1
+ ---
2
+ title: Dropdown
3
+ ---
4
+
5
+ The Dropdown component is a lightweight context menu for housing navigation and actions.
6
+
7
+ Use `Dropdown.Button` as the trigger for the dropdown, or use a custom `summary` element if you would like. **You must use a `summary` tag in order for the dropdown to behave properly!**. You should also add `aria-haspopup="true"` to custom dropdown triggers for accessibility purposes. You can use the `Dropdown.Caret` component to add a caret to a custom dropdown trigger.
8
+
9
+ Dropdown.Menu wraps your menu content. Be sure to pass a `direction` prop to this component to position the menu in relation to the Dropdown.Button.
10
+
11
+ ## Default example
12
+
13
+ ```jsx live
14
+ <Dropdown>
15
+ <Dropdown.Button>Dropdown</Dropdown.Button>
16
+ <Dropdown.Menu direction="sw">
17
+ <Dropdown.Item>Item 1</Dropdown.Item>
18
+ <Dropdown.Item>Item 2</Dropdown.Item>
19
+ <Dropdown.Item>Item 3</Dropdown.Item>
20
+ </Dropdown.Menu>
21
+ </Dropdown>
22
+ ```
23
+
24
+ ## With custom button
25
+
26
+ ```jsx live
27
+ <Dropdown>
28
+ <summary>
29
+ Dropdown
30
+ <Dropdown.Caret />
31
+ </summary>
32
+ <Dropdown.Menu direction="sw">
33
+ <Dropdown.Item>Item 1</Dropdown.Item>
34
+ <Dropdown.Item>Item 2</Dropdown.Item>
35
+ <Dropdown.Item>Item 3</Dropdown.Item>
36
+ </Dropdown.Menu>
37
+ </Dropdown>
38
+ ```
39
+
40
+ ## System props
41
+
42
+ <Note variant="warning">
43
+
44
+ System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead.
45
+
46
+ </Note>
47
+
48
+ Dropdown, Dropdown.Menu, Dropdown.Button, Dropdown.Caret, and Dropdown.Item all get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props.
49
+
50
+ ## Component props
51
+
52
+ The Dropdown component is extended from the [`Details`](/Details) component and gets all props that the [`Details`](/Details) component gets.
53
+
54
+ #### Dropdown.Menu
55
+
56
+ | Name | Type | Default | Description |
57
+ | :-------- | :----- | :-----: | :------------------------------------------------------------------------------------ |
58
+ | direction | String | 'sw' | Sets the direction of the dropdown menu. Pick from 'ne', 'e', 'se', 's', 'sw', or 'w' |
59
+
60
+ #### Dropdown.Button
61
+
62
+ | Name | Type | Default | Description |
63
+ | :------ | :------- | :-----: | :----------------------------------------------------------------------------------------------------------- |
64
+ | onClick | Function | none | Use the `onClick` handler to add additional functionality when the button is clicked, such as fetching data. |
65
+
66
+ #### Dropdown.Caret
67
+
68
+ No additional props.
69
+
70
+ #### Dropdown.Item
71
+
72
+ No additional props.
@@ -0,0 +1,49 @@
1
+ ---
2
+ title: DropdownMenu
3
+ ---
4
+
5
+ A `DropdownMenu` provides an anchor (button by default) that will open a floating menu of selectable items. The menu can be opened and navigated using keyboard or mouse. When an item is selected, the menu will close and the `onChange` callback will be called. If the default anchor button is used, the anchor contents will be updated with the selection.
6
+
7
+ ## Example
8
+
9
+ ```javascript live noinline
10
+ function DemoComponent() {
11
+ const items = React.useMemo(
12
+ () => [
13
+ {text: '🔵 Cyan', id: 5, key: 'cyan'},
14
+ {text: '🔴 Magenta', key: 'magenta'},
15
+ {text: '🟡 Yellow', key: 'yellow'}
16
+ ],
17
+ []
18
+ )
19
+ const [selectedItem, setSelectedItem] = React.useState()
20
+
21
+ return (
22
+ <DropdownMenu
23
+ renderAnchor={({children, 'aria-labelledby': ariaLabelledBy, ...anchorProps}) => (
24
+ <DropdownButton aria-labelledby={`favorite-color-label ${ariaLabelledBy}`} {...anchorProps}>
25
+ {children}
26
+ </DropdownButton>
27
+ )}
28
+ placeholder="🎨"
29
+ items={items}
30
+ selectedItem={selectedItem}
31
+ onChange={setSelectedItem}
32
+ />
33
+ )
34
+ }
35
+
36
+ render(<DemoComponent />)
37
+ ```
38
+
39
+ ## Component props
40
+
41
+ | Name | Type | Default | Description |
42
+ | :------------ | :-------------------------------------------- | :---------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
43
+ | items | `ItemProps[]` | `undefined` | Required. A list of item objects to display in the menu |
44
+ | selectedItem | `ItemInput` | `undefined` | An `ItemProps` item from the list of `items` which is currently selected. This item will receive a checkmark next to it in the menu. |
45
+ | onChange? | (item?: ItemInput) => unknown | `undefined` | A callback which receives the selected item or `undefined` when an item is activated in the menu. If the activated item is the same as the current `selectedItem`, `undefined` will be passed. |
46
+ | placeholder | `string` | `undefined` | Optional. A placeholder value to display when there is no current selection. |
47
+ | renderAnchor | `(props: DropdownButtonProps) => JSX.Element` | `DropdownButton` | Optional. If defined, provided component will be used to render the menu anchor. Will receive the selected `Item` text as `children` prop when an item is activated. |
48
+ | renderItem | `(props: ItemProps) => JSX.Element` | `ActionList.Item` | Optional. If defined, each item in `items` will be passed to this function, allowing for custom item rendering. |
49
+ | groupMetadata | `GroupProps[]` | `undefined` | Optional. If defined, `DropdownMenu` will group `items` into `ActionList.Group`s separated by `ActionList.Divider` according to their `groupId` property. |