@digdir/designsystemet-react 1.0.0-next.32 → 1.0.0-next.34

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 (660) hide show
  1. package/dist/cjs/components/Accordion/Accordion.js +15 -0
  2. package/dist/cjs/components/Accordion/AccordionContent.js +3 -12
  3. package/dist/cjs/components/Accordion/AccordionHeading.js +7 -19
  4. package/dist/cjs/components/Accordion/AccordionItem.js +63 -18
  5. package/dist/cjs/components/Accordion/index.js +4 -7
  6. package/dist/cjs/components/Alert/Alert.js +5 -20
  7. package/dist/cjs/components/Avatar/Avatar.js +36 -0
  8. package/dist/cjs/components/Badge/Badge.js +4 -5
  9. package/dist/cjs/components/Breadcrumbs/Breadcrumbs.js +11 -0
  10. package/dist/cjs/components/Breadcrumbs/BreadcrumbsItem.js +4 -4
  11. package/dist/cjs/components/Breadcrumbs/BreadcrumbsLink.js +4 -4
  12. package/dist/cjs/components/Breadcrumbs/BreadcrumbsList.js +8 -10
  13. package/dist/cjs/components/Breadcrumbs/index.js +11 -20
  14. package/dist/cjs/components/Button/Button.js +10 -7
  15. package/dist/cjs/components/Card/Card.js +6 -6
  16. package/dist/cjs/components/Card/CardContent.js +6 -6
  17. package/dist/cjs/components/Card/CardFooter.js +6 -6
  18. package/dist/cjs/components/Card/CardHeader.js +6 -6
  19. package/dist/cjs/components/Card/CardMedia.js +6 -6
  20. package/dist/cjs/components/Chip/Group/Group.js +5 -5
  21. package/dist/cjs/components/Chip/Removable/Removable.js +5 -5
  22. package/dist/cjs/components/Chip/Toggle/Toggle.js +5 -5
  23. package/dist/cjs/components/Divider/Divider.js +7 -6
  24. package/dist/cjs/components/Dropdown/Dropdown.js +23 -0
  25. package/dist/cjs/components/Dropdown/DropdownContext.js +26 -0
  26. package/dist/cjs/components/Dropdown/DropdownHeading.js +15 -0
  27. package/dist/cjs/components/Dropdown/DropdownItem.js +14 -0
  28. package/dist/cjs/components/Dropdown/DropdownList.js +12 -0
  29. package/dist/cjs/components/Dropdown/DropdownTrigger.js +13 -0
  30. package/dist/cjs/components/Dropdown/index.js +41 -0
  31. package/dist/cjs/components/ErrorSummary/ErrorSummary.js +20 -0
  32. package/dist/cjs/components/ErrorSummary/ErrorSummaryHeading.js +14 -11
  33. package/dist/cjs/components/ErrorSummary/ErrorSummaryItem.js +4 -4
  34. package/dist/cjs/components/ErrorSummary/ErrorSummaryList.js +7 -5
  35. package/dist/cjs/components/ErrorSummary/index.js +9 -11
  36. package/dist/cjs/components/HelpText/HelpText.js +5 -9
  37. package/dist/cjs/components/Link/Link.js +6 -6
  38. package/dist/cjs/components/List/ListItem.js +5 -7
  39. package/dist/cjs/components/List/Lists.js +13 -16
  40. package/dist/cjs/components/List/index.js +7 -14
  41. package/dist/cjs/components/Modal/ModaContent.js +6 -6
  42. package/dist/cjs/components/Modal/ModalDialog.js +14 -14
  43. package/dist/cjs/components/Modal/ModalFooter.js +6 -6
  44. package/dist/cjs/components/Modal/ModalHeader.js +9 -10
  45. package/dist/cjs/components/Modal/ModalRoot.js +6 -6
  46. package/dist/cjs/components/Modal/ModalTrigger.js +6 -6
  47. package/dist/cjs/components/Modal/useModalState.js +3 -3
  48. package/dist/cjs/components/Modal/useScrollLock.js +2 -2
  49. package/dist/cjs/components/Pagination/Pagination.js +4 -18
  50. package/dist/cjs/components/Pagination/PaginationButton.js +5 -6
  51. package/dist/cjs/components/Pagination/PaginationEllipsis.js +5 -6
  52. package/dist/cjs/components/Pagination/PaginationItem.js +7 -8
  53. package/dist/cjs/components/Pagination/PaginationList.js +16 -0
  54. package/dist/cjs/components/Pagination/PaginationNextPrev.js +5 -7
  55. package/dist/cjs/components/Pagination/PaginationRoot.js +6 -7
  56. package/dist/cjs/components/Pagination/index.js +4 -4
  57. package/dist/cjs/components/Pagination/usePagination.js +3 -3
  58. package/dist/cjs/components/Popover/Popover.js +96 -0
  59. package/dist/cjs/components/Popover/PopoverContext.js +16 -0
  60. package/dist/cjs/components/Popover/PopoverTrigger.js +7 -16
  61. package/dist/cjs/components/Popover/index.js +6 -9
  62. package/dist/cjs/components/SkipLink/SkipLink.js +2 -2
  63. package/dist/cjs/components/Table/Table.js +4 -24
  64. package/dist/cjs/components/Table/TableBody.js +3 -23
  65. package/dist/cjs/components/Table/TableCell.js +3 -24
  66. package/dist/cjs/components/Table/TableHead.js +3 -24
  67. package/dist/cjs/components/Table/TableHeaderCell.js +3 -30
  68. package/dist/cjs/components/Table/TableRow.js +3 -24
  69. package/dist/cjs/components/Tabs/Tabs.js +45 -0
  70. package/dist/cjs/components/Tabs/TabsList.js +25 -0
  71. package/dist/cjs/components/Tabs/TabsPanel.js +23 -0
  72. package/dist/cjs/components/Tabs/TabsTab.js +22 -0
  73. package/dist/cjs/components/Tabs/index.js +18 -20
  74. package/dist/cjs/components/Tag/Tag.js +4 -5
  75. package/dist/cjs/components/ToggleGroup/ToggleGroup.js +41 -0
  76. package/dist/cjs/components/ToggleGroup/ToggleGroupItem.js +20 -0
  77. package/dist/cjs/components/ToggleGroup/index.js +5 -8
  78. package/dist/cjs/components/ToggleGroup/{ToggleGroupItem/useToggleGroupitem.js → useToggleGroupitem.js} +5 -5
  79. package/dist/cjs/components/Tooltip/Tooltip.js +27 -48
  80. package/dist/cjs/components/Typography/Heading/Heading.js +6 -6
  81. package/dist/cjs/components/Typography/Ingress/Ingress.js +6 -6
  82. package/dist/cjs/components/Typography/Label/Label.js +6 -6
  83. package/dist/cjs/components/Typography/Paragraph/Paragraph.js +6 -6
  84. package/dist/cjs/components/Typography/ValidationMessage/ValidationMessage.js +15 -0
  85. package/dist/cjs/components/form/CharacterCounter.js +2 -2
  86. package/dist/cjs/components/form/Checkbox/Checkbox.js +6 -6
  87. package/dist/cjs/components/form/Checkbox/CheckboxGroup.js +6 -6
  88. package/dist/cjs/components/form/Checkbox/useCheckbox.js +2 -2
  89. package/dist/cjs/components/form/Combobox/Combobox.js +18 -19
  90. package/dist/cjs/components/form/Combobox/ComboboxContext.js +2 -2
  91. package/dist/cjs/components/form/Combobox/ComboboxIdContext.js +6 -6
  92. package/dist/cjs/components/form/Combobox/Custom.js +12 -12
  93. package/dist/cjs/components/form/Combobox/Empty.js +5 -5
  94. package/dist/cjs/components/form/Combobox/Option/Description.js +4 -4
  95. package/dist/cjs/components/form/Combobox/Option/Option.js +11 -7
  96. package/dist/cjs/components/form/Combobox/Option/SelectedIcon.js +2 -2
  97. package/dist/cjs/components/form/Combobox/Option/useComboboxOption.js +8 -8
  98. package/dist/cjs/components/form/Combobox/internal/ComboboxChips.js +2 -2
  99. package/dist/cjs/components/form/Combobox/internal/ComboboxClearButton.js +5 -5
  100. package/dist/cjs/components/form/Combobox/internal/ComboboxError.js +2 -2
  101. package/dist/cjs/components/form/Combobox/internal/ComboboxInput.js +7 -8
  102. package/dist/cjs/components/form/Combobox/internal/ComboboxLabel.js +2 -2
  103. package/dist/cjs/components/form/Combobox/useCombobox.js +11 -10
  104. package/dist/cjs/components/form/Combobox/useFloatingCombobox.js +14 -16
  105. package/dist/cjs/components/form/Combobox/utilities.js +2 -7
  106. package/dist/cjs/components/form/Fieldset/Fieldset.js +10 -12
  107. package/dist/cjs/components/form/Fieldset/FieldsetContext.js +2 -2
  108. package/dist/cjs/components/form/Radio/Radio.js +4 -4
  109. package/dist/cjs/components/form/Radio/RadioGroup.js +6 -6
  110. package/dist/cjs/components/form/Radio/useRadio.js +2 -2
  111. package/dist/cjs/components/form/Search/Search.js +11 -11
  112. package/dist/cjs/components/form/Search/useSearch.js +2 -2
  113. package/dist/cjs/components/form/Select/Select.js +20 -0
  114. package/dist/cjs/components/form/Select/SelectOptgroup.js +13 -0
  115. package/dist/cjs/components/form/Select/SelectOption.js +13 -0
  116. package/dist/cjs/components/form/Select/index.js +16 -0
  117. package/dist/cjs/components/form/Select/useSelect.js +49 -0
  118. package/dist/cjs/components/form/Switch/Switch.js +4 -4
  119. package/dist/cjs/components/form/Switch/useSwitch.js +2 -2
  120. package/dist/cjs/components/form/Textarea/Textarea.js +8 -8
  121. package/dist/cjs/components/form/Textarea/useTextarea.js +2 -2
  122. package/dist/cjs/components/form/Textfield/Textfield.js +9 -9
  123. package/dist/cjs/components/form/Textfield/useTextfield.js +2 -2
  124. package/dist/cjs/components/form/useFormField.js +5 -5
  125. package/dist/cjs/components/loaders/Skeleton/Skeleton.js +18 -0
  126. package/dist/cjs/components/loaders/Spinner/Spinner.js +16 -0
  127. package/dist/cjs/index.js +57 -77
  128. package/dist/cjs/utilities/RovingFocus/RovingFocusItem.js +6 -6
  129. package/dist/cjs/utilities/RovingFocus/RovingFocusRoot.js +12 -12
  130. package/dist/cjs/utilities/RovingFocus/useRovingFocus.js +2 -2
  131. package/dist/cjs/utilities/hooks/useDebounceCallback/useDebounceCallback.js +3 -3
  132. package/dist/cjs/utilities/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +2 -2
  133. package/dist/cjs/utilities/hooks/useSynchronizedAnimation/useSynchronizedAnimation.js +6 -4
  134. package/dist/esm/components/Accordion/Accordion.js +13 -0
  135. package/dist/esm/components/Accordion/AccordionContent.js +3 -12
  136. package/dist/esm/components/Accordion/AccordionHeading.js +8 -20
  137. package/dist/esm/components/Accordion/AccordionItem.js +64 -18
  138. package/dist/esm/components/Accordion/index.js +5 -7
  139. package/dist/esm/components/Alert/Alert.js +5 -20
  140. package/dist/esm/components/Avatar/Avatar.js +34 -0
  141. package/dist/esm/components/Badge/Badge.js +4 -5
  142. package/dist/esm/components/Breadcrumbs/Breadcrumbs.js +9 -0
  143. package/dist/esm/components/Breadcrumbs/BreadcrumbsItem.js +3 -3
  144. package/dist/esm/components/Breadcrumbs/BreadcrumbsLink.js +3 -3
  145. package/dist/esm/components/Breadcrumbs/BreadcrumbsList.js +4 -6
  146. package/dist/esm/components/Breadcrumbs/index.js +12 -19
  147. package/dist/esm/components/Button/Button.js +9 -6
  148. package/dist/esm/components/Card/Card.js +3 -3
  149. package/dist/esm/components/Card/CardContent.js +3 -3
  150. package/dist/esm/components/Card/CardFooter.js +3 -3
  151. package/dist/esm/components/Card/CardHeader.js +3 -3
  152. package/dist/esm/components/Card/CardMedia.js +3 -3
  153. package/dist/esm/components/Chip/Group/Group.js +2 -2
  154. package/dist/esm/components/Chip/Removable/Removable.js +2 -2
  155. package/dist/esm/components/Chip/Toggle/Toggle.js +2 -2
  156. package/dist/esm/components/Divider/Divider.js +6 -5
  157. package/dist/esm/components/Dropdown/Dropdown.js +20 -0
  158. package/dist/esm/components/Dropdown/DropdownContext.js +24 -0
  159. package/dist/esm/components/Dropdown/DropdownHeading.js +13 -0
  160. package/dist/esm/components/Dropdown/DropdownItem.js +12 -0
  161. package/dist/esm/components/Dropdown/DropdownList.js +10 -0
  162. package/dist/esm/components/Dropdown/DropdownTrigger.js +11 -0
  163. package/dist/esm/components/Dropdown/index.js +34 -0
  164. package/dist/esm/components/ErrorSummary/ErrorSummary.js +17 -0
  165. package/dist/esm/components/ErrorSummary/ErrorSummaryHeading.js +13 -10
  166. package/dist/esm/components/ErrorSummary/ErrorSummaryItem.js +4 -4
  167. package/dist/esm/components/ErrorSummary/ErrorSummaryList.js +7 -5
  168. package/dist/esm/components/ErrorSummary/index.js +10 -11
  169. package/dist/esm/components/HelpText/HelpText.js +6 -10
  170. package/dist/esm/components/Link/Link.js +4 -4
  171. package/dist/esm/components/List/ListItem.js +3 -5
  172. package/dist/esm/components/List/Lists.js +12 -15
  173. package/dist/esm/components/List/index.js +7 -12
  174. package/dist/esm/components/Modal/ModaContent.js +3 -3
  175. package/dist/esm/components/Modal/ModalDialog.js +4 -4
  176. package/dist/esm/components/Modal/ModalFooter.js +3 -3
  177. package/dist/esm/components/Modal/ModalHeader.js +5 -6
  178. package/dist/esm/components/Modal/ModalTrigger.js +2 -2
  179. package/dist/esm/components/Pagination/Pagination.js +3 -17
  180. package/dist/esm/components/Pagination/PaginationButton.js +3 -4
  181. package/dist/esm/components/Pagination/PaginationEllipsis.js +3 -4
  182. package/dist/esm/components/Pagination/PaginationItem.js +4 -5
  183. package/dist/esm/components/Pagination/PaginationList.js +14 -0
  184. package/dist/esm/components/Pagination/PaginationNextPrev.js +4 -6
  185. package/dist/esm/components/Pagination/PaginationRoot.js +3 -4
  186. package/dist/esm/components/Pagination/index.js +4 -4
  187. package/dist/esm/components/Popover/Popover.js +94 -0
  188. package/dist/esm/components/Popover/PopoverContext.js +13 -0
  189. package/dist/esm/components/Popover/PopoverTrigger.js +6 -15
  190. package/dist/esm/components/Popover/index.js +6 -8
  191. package/dist/esm/components/SkipLink/SkipLink.js +2 -2
  192. package/dist/esm/components/Table/Table.js +4 -5
  193. package/dist/esm/components/Table/TableBody.js +3 -4
  194. package/dist/esm/components/Table/TableCell.js +3 -5
  195. package/dist/esm/components/Table/TableHead.js +3 -5
  196. package/dist/esm/components/Table/TableHeaderCell.js +4 -12
  197. package/dist/esm/components/Table/TableRow.js +3 -5
  198. package/dist/esm/components/Tabs/{TabsRoot.js → Tabs.js} +11 -12
  199. package/dist/esm/components/Tabs/{TabList.js → TabsList.js} +6 -7
  200. package/dist/esm/components/Tabs/TabsPanel.js +21 -0
  201. package/dist/esm/components/Tabs/TabsTab.js +20 -0
  202. package/dist/esm/components/Tabs/index.js +16 -17
  203. package/dist/esm/components/Tag/Tag.js +3 -4
  204. package/dist/esm/components/ToggleGroup/ToggleGroup.js +38 -0
  205. package/dist/esm/components/ToggleGroup/ToggleGroupItem.js +18 -0
  206. package/dist/esm/components/ToggleGroup/index.js +6 -8
  207. package/dist/esm/components/ToggleGroup/{ToggleGroupItem/useToggleGroupitem.js → useToggleGroupitem.js} +1 -1
  208. package/dist/esm/components/Tooltip/Tooltip.js +11 -14
  209. package/dist/esm/components/Typography/Heading/Heading.js +5 -5
  210. package/dist/esm/components/Typography/Ingress/Ingress.js +3 -3
  211. package/dist/esm/components/Typography/Label/Label.js +3 -3
  212. package/dist/esm/components/Typography/Paragraph/Paragraph.js +3 -3
  213. package/dist/esm/components/Typography/ValidationMessage/ValidationMessage.js +13 -0
  214. package/dist/esm/components/form/CharacterCounter.js +2 -2
  215. package/dist/esm/components/form/Checkbox/Checkbox.js +3 -3
  216. package/dist/esm/components/form/Checkbox/CheckboxGroup.js +2 -2
  217. package/dist/esm/components/form/Combobox/Combobox.js +6 -7
  218. package/dist/esm/components/form/Combobox/Custom.js +4 -4
  219. package/dist/esm/components/form/Combobox/Empty.js +2 -2
  220. package/dist/esm/components/form/Combobox/Option/Description.js +2 -2
  221. package/dist/esm/components/form/Combobox/Option/Option.js +8 -5
  222. package/dist/esm/components/form/Combobox/Option/SelectedIcon.js +2 -2
  223. package/dist/esm/components/form/Combobox/Option/useComboboxOption.js +2 -2
  224. package/dist/esm/components/form/Combobox/internal/ComboboxClearButton.js +2 -2
  225. package/dist/esm/components/form/Combobox/internal/ComboboxError.js +2 -2
  226. package/dist/esm/components/form/Combobox/internal/ComboboxInput.js +3 -4
  227. package/dist/esm/components/form/Combobox/internal/ComboboxLabel.js +2 -2
  228. package/dist/esm/components/form/Combobox/useCombobox.js +2 -1
  229. package/dist/esm/components/form/Combobox/useFloatingCombobox.js +1 -3
  230. package/dist/esm/components/form/Combobox/utilities.js +1 -5
  231. package/dist/esm/components/form/Fieldset/Fieldset.js +8 -10
  232. package/dist/esm/components/form/Radio/Radio.js +2 -2
  233. package/dist/esm/components/form/Radio/RadioGroup.js +2 -2
  234. package/dist/esm/components/form/Search/Search.js +5 -5
  235. package/dist/esm/components/form/Select/Select.js +18 -0
  236. package/dist/esm/components/form/Select/SelectOptgroup.js +11 -0
  237. package/dist/esm/components/form/Select/SelectOption.js +11 -0
  238. package/dist/esm/components/form/Select/index.js +12 -0
  239. package/dist/esm/components/form/Select/useSelect.js +47 -0
  240. package/dist/esm/components/form/Switch/Switch.js +2 -2
  241. package/dist/esm/components/form/Textarea/Textarea.js +5 -5
  242. package/dist/esm/components/form/Textfield/Textfield.js +5 -5
  243. package/dist/esm/components/form/useFormField.js +2 -2
  244. package/dist/esm/components/loaders/Skeleton/Skeleton.js +16 -0
  245. package/dist/esm/components/loaders/Spinner/Spinner.js +14 -0
  246. package/dist/esm/index.js +21 -31
  247. package/dist/esm/utilities/RovingFocus/RovingFocusItem.js +2 -2
  248. package/dist/esm/utilities/RovingFocus/RovingFocusRoot.js +2 -2
  249. package/dist/esm/utilities/hooks/useSynchronizedAnimation/useSynchronizedAnimation.js +4 -2
  250. package/dist/types/components/Accordion/{AccordionRoot.d.ts → Accordion.d.ts} +5 -5
  251. package/dist/types/components/Accordion/Accordion.d.ts.map +1 -0
  252. package/dist/types/components/Accordion/AccordionContent.d.ts +1 -1
  253. package/dist/types/components/Accordion/AccordionContent.d.ts.map +1 -1
  254. package/dist/types/components/Accordion/AccordionHeading.d.ts +6 -20
  255. package/dist/types/components/Accordion/AccordionHeading.d.ts.map +1 -1
  256. package/dist/types/components/Accordion/AccordionItem.d.ts +12 -26
  257. package/dist/types/components/Accordion/AccordionItem.d.ts.map +1 -1
  258. package/dist/types/components/Accordion/index.d.ts +9 -11
  259. package/dist/types/components/Accordion/index.d.ts.map +1 -1
  260. package/dist/types/components/Alert/Alert.d.ts +7 -23
  261. package/dist/types/components/Alert/Alert.d.ts.map +1 -1
  262. package/dist/types/components/Avatar/Avatar.d.ts +78 -0
  263. package/dist/types/components/Avatar/Avatar.d.ts.map +1 -0
  264. package/dist/types/components/Avatar/index.d.ts +3 -0
  265. package/dist/types/components/Avatar/index.d.ts.map +1 -0
  266. package/dist/types/components/Badge/Badge.d.ts +2 -2
  267. package/dist/types/components/Badge/Badge.d.ts.map +1 -1
  268. package/dist/types/components/Breadcrumbs/Breadcrumbs.d.ts +26 -0
  269. package/dist/types/components/Breadcrumbs/Breadcrumbs.d.ts.map +1 -0
  270. package/dist/types/components/Breadcrumbs/BreadcrumbsItem.d.ts +1 -1
  271. package/dist/types/components/Breadcrumbs/BreadcrumbsItem.d.ts.map +1 -1
  272. package/dist/types/components/Breadcrumbs/BreadcrumbsLink.d.ts +3 -3
  273. package/dist/types/components/Breadcrumbs/BreadcrumbsLink.d.ts.map +1 -1
  274. package/dist/types/components/Breadcrumbs/BreadcrumbsList.d.ts +1 -1
  275. package/dist/types/components/Breadcrumbs/BreadcrumbsList.d.ts.map +1 -1
  276. package/dist/types/components/Breadcrumbs/index.d.ts +22 -30
  277. package/dist/types/components/Breadcrumbs/index.d.ts.map +1 -1
  278. package/dist/types/components/Button/Button.d.ts +21 -13
  279. package/dist/types/components/Button/Button.d.ts.map +1 -1
  280. package/dist/types/components/Card/Card.d.ts +2 -2
  281. package/dist/types/components/Card/Card.d.ts.map +1 -1
  282. package/dist/types/components/Card/CardContent.d.ts +2 -2
  283. package/dist/types/components/Card/CardContent.d.ts.map +1 -1
  284. package/dist/types/components/Card/CardFooter.d.ts +2 -2
  285. package/dist/types/components/Card/CardFooter.d.ts.map +1 -1
  286. package/dist/types/components/Card/CardHeader.d.ts +2 -2
  287. package/dist/types/components/Card/CardHeader.d.ts.map +1 -1
  288. package/dist/types/components/Card/CardMedia.d.ts +2 -2
  289. package/dist/types/components/Card/CardMedia.d.ts.map +1 -1
  290. package/dist/types/components/Chip/Group/Group.d.ts +3 -3
  291. package/dist/types/components/Chip/Group/Group.d.ts.map +1 -1
  292. package/dist/types/components/Chip/Removable/Removable.d.ts +2 -2
  293. package/dist/types/components/Chip/Removable/Removable.d.ts.map +1 -1
  294. package/dist/types/components/Chip/Toggle/Toggle.d.ts +2 -2
  295. package/dist/types/components/Chip/Toggle/Toggle.d.ts.map +1 -1
  296. package/dist/types/components/Divider/Divider.d.ts +3 -15
  297. package/dist/types/components/Divider/Divider.d.ts.map +1 -1
  298. package/dist/types/components/Dropdown/Dropdown.d.ts +23 -0
  299. package/dist/types/components/Dropdown/Dropdown.d.ts.map +1 -0
  300. package/dist/types/components/Dropdown/DropdownContext.d.ts +22 -0
  301. package/dist/types/components/Dropdown/DropdownContext.d.ts.map +1 -0
  302. package/dist/types/components/Dropdown/DropdownHeading.d.ts +4 -0
  303. package/dist/types/components/Dropdown/DropdownHeading.d.ts.map +1 -0
  304. package/dist/types/components/Dropdown/DropdownItem.d.ts +4 -0
  305. package/dist/types/components/Dropdown/DropdownItem.d.ts.map +1 -0
  306. package/dist/types/components/Dropdown/DropdownList.d.ts +4 -0
  307. package/dist/types/components/Dropdown/DropdownList.d.ts.map +1 -0
  308. package/dist/types/components/Dropdown/DropdownTrigger.d.ts +17 -0
  309. package/dist/types/components/Dropdown/DropdownTrigger.d.ts.map +1 -0
  310. package/dist/types/components/Dropdown/index.d.ts +49 -0
  311. package/dist/types/components/Dropdown/index.d.ts.map +1 -0
  312. package/dist/types/components/ErrorSummary/ErrorSummary.d.ts +16 -0
  313. package/dist/types/components/ErrorSummary/ErrorSummary.d.ts.map +1 -0
  314. package/dist/types/components/ErrorSummary/ErrorSummaryHeading.d.ts +8 -6
  315. package/dist/types/components/ErrorSummary/ErrorSummaryHeading.d.ts.map +1 -1
  316. package/dist/types/components/ErrorSummary/ErrorSummaryItem.d.ts +2 -5
  317. package/dist/types/components/ErrorSummary/ErrorSummaryItem.d.ts.map +1 -1
  318. package/dist/types/components/ErrorSummary/ErrorSummaryList.d.ts +6 -7
  319. package/dist/types/components/ErrorSummary/ErrorSummaryList.d.ts.map +1 -1
  320. package/dist/types/components/ErrorSummary/index.d.ts +20 -13
  321. package/dist/types/components/ErrorSummary/index.d.ts.map +1 -1
  322. package/dist/types/components/HelpText/HelpText.d.ts +21 -10
  323. package/dist/types/components/HelpText/HelpText.d.ts.map +1 -1
  324. package/dist/types/components/Link/Link.d.ts +2 -2
  325. package/dist/types/components/Link/Link.d.ts.map +1 -1
  326. package/dist/types/components/List/ListItem.d.ts +2 -2
  327. package/dist/types/components/List/ListItem.d.ts.map +1 -1
  328. package/dist/types/components/List/Lists.d.ts +11 -21
  329. package/dist/types/components/List/Lists.d.ts.map +1 -1
  330. package/dist/types/components/List/index.d.ts +15 -14
  331. package/dist/types/components/List/index.d.ts.map +1 -1
  332. package/dist/types/components/Modal/ModaContent.d.ts +2 -2
  333. package/dist/types/components/Modal/ModaContent.d.ts.map +1 -1
  334. package/dist/types/components/Modal/ModalDialog.d.ts +2 -2
  335. package/dist/types/components/Modal/ModalDialog.d.ts.map +1 -1
  336. package/dist/types/components/Modal/ModalFooter.d.ts +2 -2
  337. package/dist/types/components/Modal/ModalFooter.d.ts.map +1 -1
  338. package/dist/types/components/Modal/ModalHeader.d.ts +2 -2
  339. package/dist/types/components/Modal/ModalHeader.d.ts.map +1 -1
  340. package/dist/types/components/Modal/ModalRoot.d.ts +4 -3
  341. package/dist/types/components/Modal/ModalRoot.d.ts.map +1 -1
  342. package/dist/types/components/Modal/ModalTrigger.d.ts +6 -5
  343. package/dist/types/components/Modal/ModalTrigger.d.ts.map +1 -1
  344. package/dist/types/components/Pagination/Pagination.d.ts +4 -5
  345. package/dist/types/components/Pagination/Pagination.d.ts.map +1 -1
  346. package/dist/types/components/Pagination/PaginationButton.d.ts +3 -3
  347. package/dist/types/components/Pagination/PaginationButton.d.ts.map +1 -1
  348. package/dist/types/components/Pagination/PaginationEllipsis.d.ts +1 -2
  349. package/dist/types/components/Pagination/PaginationEllipsis.d.ts.map +1 -1
  350. package/dist/types/components/Pagination/PaginationItem.d.ts +2 -3
  351. package/dist/types/components/Pagination/PaginationItem.d.ts.map +1 -1
  352. package/dist/types/components/Pagination/{PaginationContent.d.ts → PaginationList.d.ts} +4 -4
  353. package/dist/types/components/Pagination/PaginationList.d.ts.map +1 -0
  354. package/dist/types/components/Pagination/PaginationNextPrev.d.ts +4 -5
  355. package/dist/types/components/Pagination/PaginationNextPrev.d.ts.map +1 -1
  356. package/dist/types/components/Pagination/PaginationRoot.d.ts +14 -4
  357. package/dist/types/components/Pagination/PaginationRoot.d.ts.map +1 -1
  358. package/dist/types/components/Pagination/index.d.ts +9 -10
  359. package/dist/types/components/Pagination/index.d.ts.map +1 -1
  360. package/dist/types/components/Pagination/usePagination.d.ts +1 -1
  361. package/dist/types/components/Popover/Popover.d.ts +85 -0
  362. package/dist/types/components/Popover/Popover.d.ts.map +1 -0
  363. package/dist/types/components/Popover/PopoverContext.d.ts +13 -0
  364. package/dist/types/components/Popover/PopoverContext.d.ts.map +1 -0
  365. package/dist/types/components/Popover/PopoverTrigger.d.ts +6 -5
  366. package/dist/types/components/Popover/PopoverTrigger.d.ts.map +1 -1
  367. package/dist/types/components/Popover/index.d.ts +8 -10
  368. package/dist/types/components/Popover/index.d.ts.map +1 -1
  369. package/dist/types/components/Table/Table.d.ts +3 -3
  370. package/dist/types/components/Table/Table.d.ts.map +1 -1
  371. package/dist/types/components/Table/TableBody.d.ts +2 -2
  372. package/dist/types/components/Table/TableBody.d.ts.map +1 -1
  373. package/dist/types/components/Table/TableCell.d.ts +2 -2
  374. package/dist/types/components/Table/TableCell.d.ts.map +1 -1
  375. package/dist/types/components/Table/TableHead.d.ts +2 -2
  376. package/dist/types/components/Table/TableHead.d.ts.map +1 -1
  377. package/dist/types/components/Table/TableHeaderCell.d.ts +5 -25
  378. package/dist/types/components/Table/TableHeaderCell.d.ts.map +1 -1
  379. package/dist/types/components/Table/TableRow.d.ts +2 -2
  380. package/dist/types/components/Table/TableRow.d.ts.map +1 -1
  381. package/dist/types/components/Tabs/{TabsRoot.d.ts → Tabs.d.ts} +10 -10
  382. package/dist/types/components/Tabs/Tabs.d.ts.map +1 -0
  383. package/dist/types/components/Tabs/{TabList.d.ts → TabsList.d.ts} +3 -2
  384. package/dist/types/components/Tabs/TabsList.d.ts.map +1 -0
  385. package/dist/types/components/Tabs/TabsPanel.d.ts +17 -0
  386. package/dist/types/components/Tabs/TabsPanel.d.ts.map +1 -0
  387. package/dist/types/components/Tabs/{Tab.d.ts → TabsTab.d.ts} +4 -4
  388. package/dist/types/components/Tabs/TabsTab.d.ts.map +1 -0
  389. package/dist/types/components/Tabs/index.d.ts +27 -20
  390. package/dist/types/components/Tabs/index.d.ts.map +1 -1
  391. package/dist/types/components/Tag/Tag.d.ts +2 -2
  392. package/dist/types/components/Tag/Tag.d.ts.map +1 -1
  393. package/dist/types/components/ToggleGroup/{ToggleGroupRoot.d.ts → ToggleGroup.d.ts} +6 -6
  394. package/dist/types/components/ToggleGroup/ToggleGroup.d.ts.map +1 -0
  395. package/dist/types/components/ToggleGroup/{ToggleGroupItem/ToggleGroupItem.d.ts → ToggleGroupItem.d.ts} +4 -4
  396. package/dist/types/components/ToggleGroup/ToggleGroupItem.d.ts.map +1 -0
  397. package/dist/types/components/ToggleGroup/index.d.ts +8 -9
  398. package/dist/types/components/ToggleGroup/index.d.ts.map +1 -1
  399. package/dist/types/components/ToggleGroup/{ToggleGroupItem/useToggleGroupitem.d.ts → useToggleGroupitem.d.ts} +2 -2
  400. package/dist/types/components/ToggleGroup/useToggleGroupitem.d.ts.map +1 -0
  401. package/dist/types/components/Tooltip/Tooltip.d.ts +6 -7
  402. package/dist/types/components/Tooltip/Tooltip.d.ts.map +1 -1
  403. package/dist/types/components/Typography/Heading/Heading.d.ts +4 -4
  404. package/dist/types/components/Typography/Heading/Heading.d.ts.map +1 -1
  405. package/dist/types/components/Typography/Ingress/Ingress.d.ts +2 -2
  406. package/dist/types/components/Typography/Ingress/Ingress.d.ts.map +1 -1
  407. package/dist/types/components/Typography/Label/Label.d.ts +2 -2
  408. package/dist/types/components/Typography/Label/Label.d.ts.map +1 -1
  409. package/dist/types/components/Typography/Paragraph/Paragraph.d.ts +2 -2
  410. package/dist/types/components/Typography/Paragraph/Paragraph.d.ts.map +1 -1
  411. package/dist/types/components/Typography/{ErrorMessage/ErrorMessage.d.ts → ValidationMessage/ValidationMessage.d.ts} +5 -5
  412. package/dist/types/components/Typography/ValidationMessage/ValidationMessage.d.ts.map +1 -0
  413. package/dist/types/components/Typography/ValidationMessage/index.d.ts +2 -0
  414. package/dist/types/components/Typography/ValidationMessage/index.d.ts.map +1 -0
  415. package/dist/types/components/Typography/index.d.ts +1 -1
  416. package/dist/types/components/Typography/index.d.ts.map +1 -1
  417. package/dist/types/components/form/Checkbox/Checkbox.d.ts +2 -2
  418. package/dist/types/components/form/Checkbox/Checkbox.d.ts.map +1 -1
  419. package/dist/types/components/form/Checkbox/CheckboxGroup.d.ts +3 -3
  420. package/dist/types/components/form/Checkbox/CheckboxGroup.d.ts.map +1 -1
  421. package/dist/types/components/form/Combobox/Combobox.d.ts +4 -4
  422. package/dist/types/components/form/Combobox/Combobox.d.ts.map +1 -1
  423. package/dist/types/components/form/Combobox/ComboboxContext.d.ts +5 -4
  424. package/dist/types/components/form/Combobox/ComboboxContext.d.ts.map +1 -1
  425. package/dist/types/components/form/Combobox/ComboboxIdContext.d.ts +4 -4
  426. package/dist/types/components/form/Combobox/ComboboxIdContext.d.ts.map +1 -1
  427. package/dist/types/components/form/Combobox/Custom.d.ts +2 -2
  428. package/dist/types/components/form/Combobox/Custom.d.ts.map +1 -1
  429. package/dist/types/components/form/Combobox/Empty.d.ts +2 -2
  430. package/dist/types/components/form/Combobox/Empty.d.ts.map +1 -1
  431. package/dist/types/components/form/Combobox/Option/Description.d.ts +2 -2
  432. package/dist/types/components/form/Combobox/Option/Description.d.ts.map +1 -1
  433. package/dist/types/components/form/Combobox/Option/Option.d.ts +4 -3
  434. package/dist/types/components/form/Combobox/Option/Option.d.ts.map +1 -1
  435. package/dist/types/components/form/Combobox/Option/useComboboxOption.d.ts +1 -1
  436. package/dist/types/components/form/Combobox/internal/ComboboxClearButton.d.ts +2 -1
  437. package/dist/types/components/form/Combobox/internal/ComboboxClearButton.d.ts.map +1 -1
  438. package/dist/types/components/form/Combobox/internal/ComboboxInput.d.ts +3 -2
  439. package/dist/types/components/form/Combobox/internal/ComboboxInput.d.ts.map +1 -1
  440. package/dist/types/components/form/Combobox/useCombobox.d.ts +4 -4
  441. package/dist/types/components/form/Combobox/useCombobox.d.ts.map +1 -1
  442. package/dist/types/components/form/Combobox/useComboboxKeyboard.d.ts +2 -1
  443. package/dist/types/components/form/Combobox/useComboboxKeyboard.d.ts.map +1 -1
  444. package/dist/types/components/form/Combobox/useFloatingCombobox.d.ts +13 -12
  445. package/dist/types/components/form/Combobox/useFloatingCombobox.d.ts.map +1 -1
  446. package/dist/types/components/form/Combobox/utilities.d.ts +0 -2
  447. package/dist/types/components/form/Combobox/utilities.d.ts.map +1 -1
  448. package/dist/types/components/form/Fieldset/Fieldset.d.ts +3 -3
  449. package/dist/types/components/form/Fieldset/Fieldset.d.ts.map +1 -1
  450. package/dist/types/components/form/Fieldset/FieldsetContext.d.ts +1 -1
  451. package/dist/types/components/form/Fieldset/FieldsetContext.d.ts.map +1 -1
  452. package/dist/types/components/form/Radio/Radio.d.ts +2 -2
  453. package/dist/types/components/form/Radio/Radio.d.ts.map +1 -1
  454. package/dist/types/components/form/Radio/RadioGroup.d.ts +3 -3
  455. package/dist/types/components/form/Radio/RadioGroup.d.ts.map +1 -1
  456. package/dist/types/components/form/Search/Search.d.ts +2 -2
  457. package/dist/types/components/form/Search/Search.d.ts.map +1 -1
  458. package/dist/types/components/form/{NativeSelect/NativeSelect.d.ts → Select/Select.d.ts} +5 -5
  459. package/dist/types/components/form/Select/Select.d.ts.map +1 -0
  460. package/dist/types/components/form/Select/SelectOptgroup.d.ts +16 -0
  461. package/dist/types/components/form/Select/SelectOptgroup.d.ts.map +1 -0
  462. package/dist/types/components/form/Select/SelectOption.d.ts +16 -0
  463. package/dist/types/components/form/Select/SelectOption.d.ts.map +1 -0
  464. package/dist/types/components/form/Select/index.d.ts +13 -0
  465. package/dist/types/components/form/Select/index.d.ts.map +1 -0
  466. package/dist/types/components/form/Select/useSelect.d.ts +10 -0
  467. package/dist/types/components/form/Select/useSelect.d.ts.map +1 -0
  468. package/dist/types/components/form/Switch/Switch.d.ts +2 -2
  469. package/dist/types/components/form/Switch/Switch.d.ts.map +1 -1
  470. package/dist/types/components/form/Textarea/Textarea.d.ts +2 -2
  471. package/dist/types/components/form/Textarea/Textarea.d.ts.map +1 -1
  472. package/dist/types/components/form/Textfield/Textfield.d.ts +2 -2
  473. package/dist/types/components/form/Textfield/Textfield.d.ts.map +1 -1
  474. package/dist/types/components/index.d.ts +5 -5
  475. package/dist/types/components/index.d.ts.map +1 -1
  476. package/dist/types/components/loaders/Skeleton/Skeleton.d.ts +34 -0
  477. package/dist/types/components/loaders/Skeleton/Skeleton.d.ts.map +1 -0
  478. package/dist/types/components/loaders/Skeleton/index.d.ts +12 -0
  479. package/dist/types/components/loaders/Skeleton/index.d.ts.map +1 -0
  480. package/dist/types/components/{Spinner → loaders/Spinner}/Spinner.d.ts +3 -3
  481. package/dist/types/components/loaders/Spinner/Spinner.d.ts.map +1 -0
  482. package/dist/types/components/loaders/Spinner/index.d.ts.map +1 -0
  483. package/dist/types/utilities/AnimateHeight/AnimateHeight.d.ts +2 -2
  484. package/dist/types/utilities/AnimateHeight/AnimateHeight.d.ts.map +1 -1
  485. package/dist/types/utilities/RovingFocus/RovingFocusItem.d.ts +2 -2
  486. package/dist/types/utilities/RovingFocus/RovingFocusItem.d.ts.map +1 -1
  487. package/dist/types/utilities/RovingFocus/RovingFocusRoot.d.ts +3 -3
  488. package/dist/types/utilities/RovingFocus/RovingFocusRoot.d.ts.map +1 -1
  489. package/dist/types/utilities/RovingFocus/useRovingFocus.d.ts +163 -162
  490. package/dist/types/utilities/RovingFocus/useRovingFocus.d.ts.map +1 -1
  491. package/dist/types/utilities/hooks/useSynchronizedAnimation/useSynchronizedAnimation.d.ts +1 -1
  492. package/dist/types/utilities/hooks/useSynchronizedAnimation/useSynchronizedAnimation.d.ts.map +1 -1
  493. package/package.json +6 -4
  494. package/dist/cjs/components/Accordion/AccordionRoot.js +0 -16
  495. package/dist/cjs/components/Box/Box.js +0 -15
  496. package/dist/cjs/components/Breadcrumbs/BreadcrumbsNav.js +0 -11
  497. package/dist/cjs/components/Breadcrumbs/BreadcrumbsRoot.js +0 -11
  498. package/dist/cjs/components/DropdownMenu/DropdownMenuContent.js +0 -74
  499. package/dist/cjs/components/DropdownMenu/DropdownMenuGroup.js +0 -16
  500. package/dist/cjs/components/DropdownMenu/DropdownMenuItem.js +0 -15
  501. package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.js +0 -49
  502. package/dist/cjs/components/DropdownMenu/DropdownMenuTrigger.js +0 -22
  503. package/dist/cjs/components/DropdownMenu/index.js +0 -38
  504. package/dist/cjs/components/ErrorSummary/ErrorSummaryRoot.js +0 -21
  505. package/dist/cjs/components/HelpText/HelpTextIcon.js +0 -14
  506. package/dist/cjs/components/List/ListHeading.js +0 -28
  507. package/dist/cjs/components/List/ListRoot.js +0 -21
  508. package/dist/cjs/components/Pagination/PaginationContent.js +0 -17
  509. package/dist/cjs/components/Popover/PopoverContent.js +0 -105
  510. package/dist/cjs/components/Popover/PopoverRoot.js +0 -68
  511. package/dist/cjs/components/Skeleton/Circle/Circle.js +0 -15
  512. package/dist/cjs/components/Skeleton/Rectangle/Rectangle.js +0 -15
  513. package/dist/cjs/components/Skeleton/Text/Text.js +0 -15
  514. package/dist/cjs/components/Skeleton/index.js +0 -20
  515. package/dist/cjs/components/Spinner/Spinner.js +0 -24
  516. package/dist/cjs/components/Tabs/Tab.js +0 -23
  517. package/dist/cjs/components/Tabs/TabContent.js +0 -24
  518. package/dist/cjs/components/Tabs/TabList.js +0 -26
  519. package/dist/cjs/components/Tabs/TabsRoot.js +0 -46
  520. package/dist/cjs/components/Tabs/useTab.js +0 -24
  521. package/dist/cjs/components/ToggleGroup/ToggleGroupItem/ToggleGroupItem.js +0 -23
  522. package/dist/cjs/components/ToggleGroup/ToggleGroupRoot.js +0 -42
  523. package/dist/cjs/components/Typography/ErrorMessage/ErrorMessage.js +0 -16
  524. package/dist/cjs/components/form/Fieldset/useFieldset.js +0 -19
  525. package/dist/cjs/components/form/NativeSelect/NativeSelect.js +0 -21
  526. package/dist/cjs/components/form/NativeSelect/useNativeSelect.js +0 -55
  527. package/dist/cjs/node_modules/@floating-ui/core/dist/floating-ui.core.js +0 -674
  528. package/dist/cjs/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +0 -677
  529. package/dist/cjs/node_modules/@floating-ui/react/dist/floating-ui.react.js +0 -3273
  530. package/dist/cjs/node_modules/@floating-ui/react/dist/floating-ui.react.utils.js +0 -165
  531. package/dist/cjs/node_modules/@floating-ui/react/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +0 -68
  532. package/dist/cjs/node_modules/@floating-ui/react/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +0 -11
  533. package/dist/cjs/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +0 -353
  534. package/dist/cjs/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +0 -159
  535. package/dist/cjs/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +0 -158
  536. package/dist/cjs/node_modules/@radix-ui/react-compose-refs/dist/index.js +0 -18
  537. package/dist/cjs/node_modules/@radix-ui/react-slot/dist/index.js +0 -104
  538. package/dist/cjs/node_modules/@tanstack/react-virtual/dist/esm/index.js +0 -70
  539. package/dist/cjs/node_modules/@tanstack/virtual-core/dist/esm/index.js +0 -684
  540. package/dist/cjs/node_modules/@tanstack/virtual-core/dist/esm/utils.js +0 -66
  541. package/dist/cjs/node_modules/clsx/dist/lite.js +0 -9
  542. package/dist/cjs/node_modules/tabbable/dist/index.esm.js +0 -550
  543. package/dist/cjs/utilities/AnimateHeight/AnimateHeight.js +0 -46
  544. package/dist/cjs/utilities/hooks/useMediaQuery/useMediaQuery.js +0 -49
  545. package/dist/cjs/utilities/hooks/usePrevious.js +0 -14
  546. package/dist/esm/components/Accordion/AccordionRoot.js +0 -14
  547. package/dist/esm/components/Box/Box.js +0 -13
  548. package/dist/esm/components/Breadcrumbs/BreadcrumbsNav.js +0 -9
  549. package/dist/esm/components/Breadcrumbs/BreadcrumbsRoot.js +0 -9
  550. package/dist/esm/components/DropdownMenu/DropdownMenuContent.js +0 -54
  551. package/dist/esm/components/DropdownMenu/DropdownMenuGroup.js +0 -14
  552. package/dist/esm/components/DropdownMenu/DropdownMenuItem.js +0 -13
  553. package/dist/esm/components/DropdownMenu/DropdownMenuRoot.js +0 -46
  554. package/dist/esm/components/DropdownMenu/DropdownMenuTrigger.js +0 -20
  555. package/dist/esm/components/DropdownMenu/index.js +0 -31
  556. package/dist/esm/components/ErrorSummary/ErrorSummaryRoot.js +0 -18
  557. package/dist/esm/components/HelpText/HelpTextIcon.js +0 -12
  558. package/dist/esm/components/List/ListHeading.js +0 -26
  559. package/dist/esm/components/List/ListRoot.js +0 -18
  560. package/dist/esm/components/Pagination/PaginationContent.js +0 -15
  561. package/dist/esm/components/Popover/PopoverContent.js +0 -85
  562. package/dist/esm/components/Popover/PopoverRoot.js +0 -47
  563. package/dist/esm/components/Skeleton/Circle/Circle.js +0 -13
  564. package/dist/esm/components/Skeleton/Rectangle/Rectangle.js +0 -13
  565. package/dist/esm/components/Skeleton/Text/Text.js +0 -13
  566. package/dist/esm/components/Skeleton/index.js +0 -15
  567. package/dist/esm/components/Spinner/Spinner.js +0 -22
  568. package/dist/esm/components/Tabs/Tab.js +0 -21
  569. package/dist/esm/components/Tabs/TabContent.js +0 -22
  570. package/dist/esm/components/Tabs/useTab.js +0 -22
  571. package/dist/esm/components/ToggleGroup/ToggleGroupItem/ToggleGroupItem.js +0 -21
  572. package/dist/esm/components/ToggleGroup/ToggleGroupRoot.js +0 -39
  573. package/dist/esm/components/Typography/ErrorMessage/ErrorMessage.js +0 -14
  574. package/dist/esm/components/form/Fieldset/useFieldset.js +0 -17
  575. package/dist/esm/components/form/NativeSelect/NativeSelect.js +0 -19
  576. package/dist/esm/components/form/NativeSelect/useNativeSelect.js +0 -53
  577. package/dist/esm/node_modules/@floating-ui/core/dist/floating-ui.core.js +0 -665
  578. package/dist/esm/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +0 -667
  579. package/dist/esm/node_modules/@floating-ui/react/dist/floating-ui.react.js +0 -3229
  580. package/dist/esm/node_modules/@floating-ui/react/dist/floating-ui.react.utils.js +0 -144
  581. package/dist/esm/node_modules/@floating-ui/react/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +0 -57
  582. package/dist/esm/node_modules/@floating-ui/react/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +0 -9
  583. package/dist/esm/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +0 -325
  584. package/dist/esm/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +0 -139
  585. package/dist/esm/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +0 -136
  586. package/dist/esm/node_modules/@radix-ui/react-compose-refs/dist/index.js +0 -16
  587. package/dist/esm/node_modules/@radix-ui/react-slot/dist/index.js +0 -82
  588. package/dist/esm/node_modules/@tanstack/react-virtual/dist/esm/index.js +0 -43
  589. package/dist/esm/node_modules/@tanstack/virtual-core/dist/esm/index.js +0 -672
  590. package/dist/esm/node_modules/@tanstack/virtual-core/dist/esm/utils.js +0 -61
  591. package/dist/esm/node_modules/clsx/dist/lite.js +0 -4
  592. package/dist/esm/node_modules/tabbable/dist/index.esm.js +0 -546
  593. package/dist/esm/utilities/AnimateHeight/AnimateHeight.js +0 -44
  594. package/dist/esm/utilities/hooks/useMediaQuery/useMediaQuery.js +0 -47
  595. package/dist/esm/utilities/hooks/usePrevious.js +0 -12
  596. package/dist/types/components/Accordion/AccordionRoot.d.ts.map +0 -1
  597. package/dist/types/components/Box/Box.d.ts +0 -56
  598. package/dist/types/components/Box/Box.d.ts.map +0 -1
  599. package/dist/types/components/Box/index.d.ts +0 -3
  600. package/dist/types/components/Box/index.d.ts.map +0 -1
  601. package/dist/types/components/Breadcrumbs/BreadcrumbsNav.d.ts +0 -14
  602. package/dist/types/components/Breadcrumbs/BreadcrumbsNav.d.ts.map +0 -1
  603. package/dist/types/components/Breadcrumbs/BreadcrumbsRoot.d.ts +0 -16
  604. package/dist/types/components/Breadcrumbs/BreadcrumbsRoot.d.ts.map +0 -1
  605. package/dist/types/components/DropdownMenu/DropdownMenuContent.d.ts +0 -8
  606. package/dist/types/components/DropdownMenu/DropdownMenuContent.d.ts.map +0 -1
  607. package/dist/types/components/DropdownMenu/DropdownMenuGroup.d.ts +0 -14
  608. package/dist/types/components/DropdownMenu/DropdownMenuGroup.d.ts.map +0 -1
  609. package/dist/types/components/DropdownMenu/DropdownMenuItem.d.ts +0 -4
  610. package/dist/types/components/DropdownMenu/DropdownMenuItem.d.ts.map +0 -1
  611. package/dist/types/components/DropdownMenu/DropdownMenuRoot.d.ts +0 -51
  612. package/dist/types/components/DropdownMenu/DropdownMenuRoot.d.ts.map +0 -1
  613. package/dist/types/components/DropdownMenu/DropdownMenuTrigger.d.ts +0 -14
  614. package/dist/types/components/DropdownMenu/DropdownMenuTrigger.d.ts.map +0 -1
  615. package/dist/types/components/DropdownMenu/index.d.ts +0 -30
  616. package/dist/types/components/DropdownMenu/index.d.ts.map +0 -1
  617. package/dist/types/components/ErrorSummary/ErrorSummaryRoot.d.ts +0 -15
  618. package/dist/types/components/ErrorSummary/ErrorSummaryRoot.d.ts.map +0 -1
  619. package/dist/types/components/HelpText/HelpTextIcon.d.ts +0 -10
  620. package/dist/types/components/HelpText/HelpTextIcon.d.ts.map +0 -1
  621. package/dist/types/components/List/ListHeading.d.ts +0 -9
  622. package/dist/types/components/List/ListHeading.d.ts.map +0 -1
  623. package/dist/types/components/List/ListRoot.d.ts +0 -34
  624. package/dist/types/components/List/ListRoot.d.ts.map +0 -1
  625. package/dist/types/components/Pagination/PaginationContent.d.ts.map +0 -1
  626. package/dist/types/components/Popover/PopoverContent.d.ts +0 -8
  627. package/dist/types/components/Popover/PopoverContent.d.ts.map +0 -1
  628. package/dist/types/components/Popover/PopoverRoot.d.ts +0 -54
  629. package/dist/types/components/Popover/PopoverRoot.d.ts.map +0 -1
  630. package/dist/types/components/Skeleton/Circle/Circle.d.ts +0 -13
  631. package/dist/types/components/Skeleton/Circle/Circle.d.ts.map +0 -1
  632. package/dist/types/components/Skeleton/Rectangle/Rectangle.d.ts +0 -13
  633. package/dist/types/components/Skeleton/Rectangle/Rectangle.d.ts.map +0 -1
  634. package/dist/types/components/Skeleton/Text/Text.d.ts +0 -13
  635. package/dist/types/components/Skeleton/Text/Text.d.ts.map +0 -1
  636. package/dist/types/components/Skeleton/index.d.ts +0 -24
  637. package/dist/types/components/Skeleton/index.d.ts.map +0 -1
  638. package/dist/types/components/Spinner/Spinner.d.ts.map +0 -1
  639. package/dist/types/components/Spinner/index.d.ts.map +0 -1
  640. package/dist/types/components/Tabs/Tab.d.ts.map +0 -1
  641. package/dist/types/components/Tabs/TabContent.d.ts +0 -17
  642. package/dist/types/components/Tabs/TabContent.d.ts.map +0 -1
  643. package/dist/types/components/Tabs/TabList.d.ts.map +0 -1
  644. package/dist/types/components/Tabs/TabsRoot.d.ts.map +0 -1
  645. package/dist/types/components/Tabs/useTab.d.ts +0 -10
  646. package/dist/types/components/Tabs/useTab.d.ts.map +0 -1
  647. package/dist/types/components/ToggleGroup/ToggleGroupItem/ToggleGroupItem.d.ts.map +0 -1
  648. package/dist/types/components/ToggleGroup/ToggleGroupItem/useToggleGroupitem.d.ts.map +0 -1
  649. package/dist/types/components/ToggleGroup/ToggleGroupRoot.d.ts.map +0 -1
  650. package/dist/types/components/Typography/ErrorMessage/ErrorMessage.d.ts.map +0 -1
  651. package/dist/types/components/Typography/ErrorMessage/index.d.ts +0 -2
  652. package/dist/types/components/Typography/ErrorMessage/index.d.ts.map +0 -1
  653. package/dist/types/components/form/Fieldset/useFieldset.d.ts +0 -17
  654. package/dist/types/components/form/Fieldset/useFieldset.d.ts.map +0 -1
  655. package/dist/types/components/form/NativeSelect/NativeSelect.d.ts.map +0 -1
  656. package/dist/types/components/form/NativeSelect/index.d.ts +0 -3
  657. package/dist/types/components/form/NativeSelect/index.d.ts.map +0 -1
  658. package/dist/types/components/form/NativeSelect/useNativeSelect.d.ts +0 -10
  659. package/dist/types/components/form/NativeSelect/useNativeSelect.d.ts.map +0 -1
  660. /package/dist/types/components/{Spinner → loaders/Spinner}/index.d.ts +0 -0
@@ -1,3273 +0,0 @@
1
- 'use client';
2
- 'use strict';
3
-
4
- var React = require('react');
5
- var floatingUi_react_utils = require('./floating-ui.react.utils.js');
6
- var floatingUi_utils = require('../node_modules/@floating-ui/utils/dist/floating-ui.utils.js');
7
- var floatingUi_utils_dom$1 = require('../node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js');
8
- var index_esm = require('../../../tabbable/dist/index.esm.js');
9
- var ReactDOM = require('react-dom');
10
- var floatingUi_reactDom = require('../../react-dom/dist/floating-ui.react-dom.js');
11
- var floatingUi_utils_dom = require('../../utils/dist/floating-ui.utils.dom.js');
12
-
13
- function _interopNamespaceDefault(e) {
14
- var n = Object.create(null);
15
- if (e) {
16
- Object.keys(e).forEach(function (k) {
17
- if (k !== 'default') {
18
- var d = Object.getOwnPropertyDescriptor(e, k);
19
- Object.defineProperty(n, k, d.get ? d : {
20
- enumerable: true,
21
- get: function () { return e[k]; }
22
- });
23
- }
24
- });
25
- }
26
- n.default = e;
27
- return Object.freeze(n);
28
- }
29
-
30
- var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
31
- var ReactDOM__namespace = /*#__PURE__*/_interopNamespaceDefault(ReactDOM);
32
-
33
- /**
34
- * Merges an array of refs into a single memoized callback ref or `null`.
35
- * @see https://floating-ui.com/docs/react-utils#usemergerefs
36
- */
37
- function useMergeRefs(refs) {
38
- return React__namespace.useMemo(() => {
39
- if (refs.every(ref => ref == null)) {
40
- return null;
41
- }
42
- return value => {
43
- refs.forEach(ref => {
44
- if (typeof ref === 'function') {
45
- ref(value);
46
- } else if (ref != null) {
47
- ref.current = value;
48
- }
49
- });
50
- };
51
- // eslint-disable-next-line react-hooks/exhaustive-deps
52
- }, refs);
53
- }
54
-
55
- // https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379
56
- const SafeReact = {
57
- ...React__namespace
58
- };
59
-
60
- const useInsertionEffect = SafeReact.useInsertionEffect;
61
- const useSafeInsertionEffect = useInsertionEffect || (fn => fn());
62
- function useEffectEvent(callback) {
63
- const ref = React__namespace.useRef(() => {
64
- if (process.env.NODE_ENV !== "production") {
65
- throw new Error('Cannot call an event handler while rendering.');
66
- }
67
- });
68
- useSafeInsertionEffect(() => {
69
- ref.current = callback;
70
- });
71
- return React__namespace.useCallback(function () {
72
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
73
- args[_key] = arguments[_key];
74
- }
75
- return ref.current == null ? void 0 : ref.current(...args);
76
- }, []);
77
- }
78
-
79
- const ARROW_UP = 'ArrowUp';
80
- const ARROW_DOWN = 'ArrowDown';
81
- const ARROW_LEFT = 'ArrowLeft';
82
- const ARROW_RIGHT = 'ArrowRight';
83
- function isDifferentRow(index, cols, prevRow) {
84
- return Math.floor(index / cols) !== prevRow;
85
- }
86
- function isIndexOutOfBounds(listRef, index) {
87
- return index < 0 || index >= listRef.current.length;
88
- }
89
- function getMinIndex(listRef, disabledIndices) {
90
- return findNonDisabledIndex(listRef, {
91
- disabledIndices
92
- });
93
- }
94
- function getMaxIndex(listRef, disabledIndices) {
95
- return findNonDisabledIndex(listRef, {
96
- decrement: true,
97
- startingIndex: listRef.current.length,
98
- disabledIndices
99
- });
100
- }
101
- function findNonDisabledIndex(listRef, _temp) {
102
- let {
103
- startingIndex = -1,
104
- decrement = false,
105
- disabledIndices,
106
- amount = 1
107
- } = _temp === void 0 ? {} : _temp;
108
- const list = listRef.current;
109
- let index = startingIndex;
110
- do {
111
- index += decrement ? -amount : amount;
112
- } while (index >= 0 && index <= list.length - 1 && isDisabled(list, index, disabledIndices));
113
- return index;
114
- }
115
- function getGridNavigatedIndex(elementsRef, _ref) {
116
- let {
117
- event,
118
- orientation,
119
- loop,
120
- cols,
121
- disabledIndices,
122
- minIndex,
123
- maxIndex,
124
- prevIndex,
125
- stopEvent: stop = false
126
- } = _ref;
127
- let nextIndex = prevIndex;
128
- if (event.key === ARROW_UP) {
129
- stop && floatingUi_react_utils.stopEvent(event);
130
- if (prevIndex === -1) {
131
- nextIndex = maxIndex;
132
- } else {
133
- nextIndex = findNonDisabledIndex(elementsRef, {
134
- startingIndex: nextIndex,
135
- amount: cols,
136
- decrement: true,
137
- disabledIndices
138
- });
139
- if (loop && (prevIndex - cols < minIndex || nextIndex < 0)) {
140
- const col = prevIndex % cols;
141
- const maxCol = maxIndex % cols;
142
- const offset = maxIndex - (maxCol - col);
143
- if (maxCol === col) {
144
- nextIndex = maxIndex;
145
- } else {
146
- nextIndex = maxCol > col ? offset : offset - cols;
147
- }
148
- }
149
- }
150
- if (isIndexOutOfBounds(elementsRef, nextIndex)) {
151
- nextIndex = prevIndex;
152
- }
153
- }
154
- if (event.key === ARROW_DOWN) {
155
- stop && floatingUi_react_utils.stopEvent(event);
156
- if (prevIndex === -1) {
157
- nextIndex = minIndex;
158
- } else {
159
- nextIndex = findNonDisabledIndex(elementsRef, {
160
- startingIndex: prevIndex,
161
- amount: cols,
162
- disabledIndices
163
- });
164
- if (loop && prevIndex + cols > maxIndex) {
165
- nextIndex = findNonDisabledIndex(elementsRef, {
166
- startingIndex: prevIndex % cols - cols,
167
- amount: cols,
168
- disabledIndices
169
- });
170
- }
171
- }
172
- if (isIndexOutOfBounds(elementsRef, nextIndex)) {
173
- nextIndex = prevIndex;
174
- }
175
- }
176
-
177
- // Remains on the same row/column.
178
- if (orientation === 'both') {
179
- const prevRow = floatingUi_utils.floor(prevIndex / cols);
180
- if (event.key === ARROW_RIGHT) {
181
- stop && floatingUi_react_utils.stopEvent(event);
182
- if (prevIndex % cols !== cols - 1) {
183
- nextIndex = findNonDisabledIndex(elementsRef, {
184
- startingIndex: prevIndex,
185
- disabledIndices
186
- });
187
- if (loop && isDifferentRow(nextIndex, cols, prevRow)) {
188
- nextIndex = findNonDisabledIndex(elementsRef, {
189
- startingIndex: prevIndex - prevIndex % cols - 1,
190
- disabledIndices
191
- });
192
- }
193
- } else if (loop) {
194
- nextIndex = findNonDisabledIndex(elementsRef, {
195
- startingIndex: prevIndex - prevIndex % cols - 1,
196
- disabledIndices
197
- });
198
- }
199
- if (isDifferentRow(nextIndex, cols, prevRow)) {
200
- nextIndex = prevIndex;
201
- }
202
- }
203
- if (event.key === ARROW_LEFT) {
204
- stop && floatingUi_react_utils.stopEvent(event);
205
- if (prevIndex % cols !== 0) {
206
- nextIndex = findNonDisabledIndex(elementsRef, {
207
- startingIndex: prevIndex,
208
- decrement: true,
209
- disabledIndices
210
- });
211
- if (loop && isDifferentRow(nextIndex, cols, prevRow)) {
212
- nextIndex = findNonDisabledIndex(elementsRef, {
213
- startingIndex: prevIndex + (cols - prevIndex % cols),
214
- decrement: true,
215
- disabledIndices
216
- });
217
- }
218
- } else if (loop) {
219
- nextIndex = findNonDisabledIndex(elementsRef, {
220
- startingIndex: prevIndex + (cols - prevIndex % cols),
221
- decrement: true,
222
- disabledIndices
223
- });
224
- }
225
- if (isDifferentRow(nextIndex, cols, prevRow)) {
226
- nextIndex = prevIndex;
227
- }
228
- }
229
- const lastRow = floatingUi_utils.floor(maxIndex / cols) === prevRow;
230
- if (isIndexOutOfBounds(elementsRef, nextIndex)) {
231
- if (loop && lastRow) {
232
- nextIndex = event.key === ARROW_LEFT ? maxIndex : findNonDisabledIndex(elementsRef, {
233
- startingIndex: prevIndex - prevIndex % cols - 1,
234
- disabledIndices
235
- });
236
- } else {
237
- nextIndex = prevIndex;
238
- }
239
- }
240
- }
241
- return nextIndex;
242
- }
243
-
244
- /** For each cell index, gets the item index that occupies that cell */
245
- function buildCellMap(sizes, cols, dense) {
246
- const cellMap = [];
247
- let startIndex = 0;
248
- sizes.forEach((_ref2, index) => {
249
- let {
250
- width,
251
- height
252
- } = _ref2;
253
- if (width > cols) {
254
- if (process.env.NODE_ENV !== "production") {
255
- throw new Error("[Floating UI]: Invalid grid - item width at index " + index + " is greater than grid columns");
256
- }
257
- }
258
- let itemPlaced = false;
259
- if (dense) {
260
- startIndex = 0;
261
- }
262
- while (!itemPlaced) {
263
- const targetCells = [];
264
- for (let i = 0; i < width; i++) {
265
- for (let j = 0; j < height; j++) {
266
- targetCells.push(startIndex + i + j * cols);
267
- }
268
- }
269
- if (startIndex % cols + width <= cols && targetCells.every(cell => cellMap[cell] == null)) {
270
- targetCells.forEach(cell => {
271
- cellMap[cell] = index;
272
- });
273
- itemPlaced = true;
274
- } else {
275
- startIndex++;
276
- }
277
- }
278
- });
279
-
280
- // convert into a non-sparse array
281
- return [...cellMap];
282
- }
283
-
284
- /** Gets cell index of an item's corner or -1 when index is -1. */
285
- function getCellIndexOfCorner(index, sizes, cellMap, cols, corner) {
286
- if (index === -1) return -1;
287
- const firstCellIndex = cellMap.indexOf(index);
288
- const sizeItem = sizes[index];
289
- switch (corner) {
290
- case 'tl':
291
- return firstCellIndex;
292
- case 'tr':
293
- if (!sizeItem) {
294
- return firstCellIndex;
295
- }
296
- return firstCellIndex + sizeItem.width - 1;
297
- case 'bl':
298
- if (!sizeItem) {
299
- return firstCellIndex;
300
- }
301
- return firstCellIndex + (sizeItem.height - 1) * cols;
302
- case 'br':
303
- return cellMap.lastIndexOf(index);
304
- }
305
- }
306
-
307
- /** Gets all cell indices that correspond to the specified indices */
308
- function getCellIndices(indices, cellMap) {
309
- return cellMap.flatMap((index, cellIndex) => indices.includes(index) ? [cellIndex] : []);
310
- }
311
- function isDisabled(list, index, disabledIndices) {
312
- if (disabledIndices) {
313
- return disabledIndices.includes(index);
314
- }
315
- const element = list[index];
316
- return element == null || element.hasAttribute('disabled') || element.getAttribute('aria-disabled') === 'true';
317
- }
318
-
319
- let rafId = 0;
320
- function enqueueFocus(el, options) {
321
- if (options === void 0) {
322
- options = {};
323
- }
324
- const {
325
- preventScroll = false,
326
- cancelPrevious = true,
327
- sync = false
328
- } = options;
329
- cancelPrevious && cancelAnimationFrame(rafId);
330
- const exec = () => el == null ? void 0 : el.focus({
331
- preventScroll
332
- });
333
- if (sync) {
334
- exec();
335
- } else {
336
- rafId = requestAnimationFrame(exec);
337
- }
338
- }
339
-
340
- var index = typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect;
341
-
342
- function _extends() {
343
- _extends = Object.assign ? Object.assign.bind() : function (target) {
344
- for (var i = 1; i < arguments.length; i++) {
345
- var source = arguments[i];
346
- for (var key in source) {
347
- if (Object.prototype.hasOwnProperty.call(source, key)) {
348
- target[key] = source[key];
349
- }
350
- }
351
- }
352
- return target;
353
- };
354
- return _extends.apply(this, arguments);
355
- }
356
-
357
- let serverHandoffComplete = false;
358
- let count = 0;
359
- const genId = () => // Ensure the id is unique with multiple independent versions of Floating UI
360
- // on <React 18
361
- "floating-ui-" + Math.random().toString(36).slice(2, 6) + count++;
362
- function useFloatingId() {
363
- const [id, setId] = React__namespace.useState(() => serverHandoffComplete ? genId() : undefined);
364
- index(() => {
365
- if (id == null) {
366
- setId(genId());
367
- }
368
- // eslint-disable-next-line react-hooks/exhaustive-deps
369
- }, []);
370
- React__namespace.useEffect(() => {
371
- serverHandoffComplete = true;
372
- }, []);
373
- return id;
374
- }
375
- const useReactId = SafeReact.useId;
376
-
377
- /**
378
- * Uses React 18's built-in `useId()` when available, or falls back to a
379
- * slightly less performant (requiring a double render) implementation for
380
- * earlier React versions.
381
- * @see https://floating-ui.com/docs/react-utils#useid
382
- */
383
- const useId = useReactId || useFloatingId;
384
-
385
- let devMessageSet;
386
- if (process.env.NODE_ENV !== "production") {
387
- devMessageSet = /*#__PURE__*/new Set();
388
- }
389
- function warn() {
390
- var _devMessageSet;
391
- for (var _len = arguments.length, messages = new Array(_len), _key = 0; _key < _len; _key++) {
392
- messages[_key] = arguments[_key];
393
- }
394
- const message = "Floating UI: " + messages.join(' ');
395
- if (!((_devMessageSet = devMessageSet) != null && _devMessageSet.has(message))) {
396
- var _devMessageSet2;
397
- (_devMessageSet2 = devMessageSet) == null || _devMessageSet2.add(message);
398
- console.warn(message);
399
- }
400
- }
401
- function error() {
402
- var _devMessageSet3;
403
- for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
404
- messages[_key2] = arguments[_key2];
405
- }
406
- const message = "Floating UI: " + messages.join(' ');
407
- if (!((_devMessageSet3 = devMessageSet) != null && _devMessageSet3.has(message))) {
408
- var _devMessageSet4;
409
- (_devMessageSet4 = devMessageSet) == null || _devMessageSet4.add(message);
410
- console.error(message);
411
- }
412
- }
413
-
414
- /**
415
- * Renders a pointing arrow triangle.
416
- * @see https://floating-ui.com/docs/FloatingArrow
417
- */
418
- const FloatingArrow = /*#__PURE__*/React__namespace.forwardRef(function FloatingArrow(props, ref) {
419
- const {
420
- context: {
421
- placement,
422
- elements: {
423
- floating
424
- },
425
- middlewareData: {
426
- arrow
427
- }
428
- },
429
- width = 14,
430
- height = 7,
431
- tipRadius = 0,
432
- strokeWidth = 0,
433
- staticOffset,
434
- stroke,
435
- d,
436
- style: {
437
- transform,
438
- ...restStyle
439
- } = {},
440
- ...rest
441
- } = props;
442
- if (process.env.NODE_ENV !== "production") {
443
- if (!ref) {
444
- warn('The `ref` prop is required for `FloatingArrow`.');
445
- }
446
- }
447
- const clipPathId = useId();
448
- const [isRTL, setIsRTL] = React__namespace.useState(false);
449
-
450
- // https://github.com/floating-ui/floating-ui/issues/2932
451
- index(() => {
452
- if (!floating) return;
453
- const isRTL = floatingUi_utils_dom$1.getComputedStyle(floating).direction === 'rtl';
454
- if (isRTL) {
455
- setIsRTL(true);
456
- }
457
- }, [floating]);
458
- if (!floating) {
459
- return null;
460
- }
461
-
462
- // Strokes must be double the border width, this ensures the stroke's width
463
- // works as you'd expect.
464
- const computedStrokeWidth = strokeWidth * 2;
465
- const halfStrokeWidth = computedStrokeWidth / 2;
466
- const svgX = width / 2 * (tipRadius / -8 + 1);
467
- const svgY = height / 2 * tipRadius / 4;
468
- const [side, alignment] = placement.split('-');
469
- const isCustomShape = !!d;
470
- const isVerticalSide = side === 'top' || side === 'bottom';
471
- const yOffsetProp = staticOffset && alignment === 'end' ? 'bottom' : 'top';
472
- let xOffsetProp = staticOffset && alignment === 'end' ? 'right' : 'left';
473
- if (staticOffset && isRTL) {
474
- xOffsetProp = alignment === 'end' ? 'left' : 'right';
475
- }
476
- const arrowX = (arrow == null ? void 0 : arrow.x) != null ? staticOffset || arrow.x : '';
477
- const arrowY = (arrow == null ? void 0 : arrow.y) != null ? staticOffset || arrow.y : '';
478
- const dValue = d || 'M0,0' + (" H" + width) + (" L" + (width - svgX) + "," + (height - svgY)) + (" Q" + width / 2 + "," + height + " " + svgX + "," + (height - svgY)) + ' Z';
479
- const rotation = {
480
- top: isCustomShape ? 'rotate(180deg)' : '',
481
- left: isCustomShape ? 'rotate(90deg)' : 'rotate(-90deg)',
482
- bottom: isCustomShape ? '' : 'rotate(180deg)',
483
- right: isCustomShape ? 'rotate(-90deg)' : 'rotate(90deg)'
484
- }[side];
485
- return /*#__PURE__*/React__namespace.createElement("svg", _extends({}, rest, {
486
- "aria-hidden": true,
487
- ref: ref,
488
- width: isCustomShape ? width : width + computedStrokeWidth,
489
- height: width,
490
- viewBox: "0 0 " + width + " " + (height > width ? height : width),
491
- style: {
492
- position: 'absolute',
493
- pointerEvents: 'none',
494
- [xOffsetProp]: arrowX,
495
- [yOffsetProp]: arrowY,
496
- [side]: isVerticalSide || isCustomShape ? '100%' : "calc(100% - " + computedStrokeWidth / 2 + "px)",
497
- transform: "" + rotation + (transform != null ? transform : ''),
498
- ...restStyle
499
- }
500
- }), computedStrokeWidth > 0 && /*#__PURE__*/React__namespace.createElement("path", {
501
- clipPath: "url(#" + clipPathId + ")",
502
- fill: "none",
503
- stroke: stroke
504
- // Account for the stroke on the fill path rendered below.
505
- ,
506
- strokeWidth: computedStrokeWidth + (d ? 0 : 1),
507
- d: dValue
508
- }), /*#__PURE__*/React__namespace.createElement("path", {
509
- stroke: computedStrokeWidth && !d ? rest.fill : 'none',
510
- d: dValue
511
- }), /*#__PURE__*/React__namespace.createElement("clipPath", {
512
- id: clipPathId
513
- }, /*#__PURE__*/React__namespace.createElement("rect", {
514
- x: -halfStrokeWidth,
515
- y: halfStrokeWidth * (isCustomShape ? -1 : 1),
516
- width: width + computedStrokeWidth,
517
- height: width
518
- })));
519
- });
520
-
521
- function createPubSub() {
522
- const map = new Map();
523
- return {
524
- emit(event, data) {
525
- var _map$get;
526
- (_map$get = map.get(event)) == null || _map$get.forEach(handler => handler(data));
527
- },
528
- on(event, listener) {
529
- map.set(event, [...(map.get(event) || []), listener]);
530
- },
531
- off(event, listener) {
532
- var _map$get2;
533
- map.set(event, ((_map$get2 = map.get(event)) == null ? void 0 : _map$get2.filter(l => l !== listener)) || []);
534
- }
535
- };
536
- }
537
-
538
- const FloatingNodeContext = /*#__PURE__*/React__namespace.createContext(null);
539
- const FloatingTreeContext = /*#__PURE__*/React__namespace.createContext(null);
540
-
541
- /**
542
- * Returns the parent node id for nested floating elements, if available.
543
- * Returns `null` for top-level floating elements.
544
- */
545
- const useFloatingParentNodeId = () => {
546
- var _React$useContext;
547
- return ((_React$useContext = React__namespace.useContext(FloatingNodeContext)) == null ? void 0 : _React$useContext.id) || null;
548
- };
549
-
550
- /**
551
- * Returns the nearest floating tree context, if available.
552
- */
553
- const useFloatingTree = () => React__namespace.useContext(FloatingTreeContext);
554
-
555
- function createAttribute(name) {
556
- return "data-floating-ui-" + name;
557
- }
558
-
559
- function useLatestRef(value) {
560
- const ref = React.useRef(value);
561
- index(() => {
562
- ref.current = value;
563
- });
564
- return ref;
565
- }
566
-
567
- const safePolygonIdentifier = /*#__PURE__*/createAttribute('safe-polygon');
568
- function getDelay(value, prop, pointerType) {
569
- if (pointerType && !floatingUi_react_utils.isMouseLikePointerType(pointerType)) {
570
- return 0;
571
- }
572
- if (typeof value === 'number') {
573
- return value;
574
- }
575
- return value == null ? void 0 : value[prop];
576
- }
577
- /**
578
- * Opens the floating element while hovering over the reference element, like
579
- * CSS `:hover`.
580
- * @see https://floating-ui.com/docs/useHover
581
- */
582
- function useHover(context, props) {
583
- if (props === void 0) {
584
- props = {};
585
- }
586
- const {
587
- open,
588
- onOpenChange,
589
- dataRef,
590
- events,
591
- elements
592
- } = context;
593
- const {
594
- enabled = true,
595
- delay = 0,
596
- handleClose = null,
597
- mouseOnly = false,
598
- restMs = 0,
599
- move = true
600
- } = props;
601
- const tree = useFloatingTree();
602
- const parentId = useFloatingParentNodeId();
603
- const handleCloseRef = useLatestRef(handleClose);
604
- const delayRef = useLatestRef(delay);
605
- const openRef = useLatestRef(open);
606
- const pointerTypeRef = React__namespace.useRef();
607
- const timeoutRef = React__namespace.useRef(-1);
608
- const handlerRef = React__namespace.useRef();
609
- const restTimeoutRef = React__namespace.useRef(-1);
610
- const blockMouseMoveRef = React__namespace.useRef(true);
611
- const performedPointerEventsMutationRef = React__namespace.useRef(false);
612
- const unbindMouseMoveRef = React__namespace.useRef(() => {});
613
- const isHoverOpen = React__namespace.useCallback(() => {
614
- var _dataRef$current$open;
615
- const type = (_dataRef$current$open = dataRef.current.openEvent) == null ? void 0 : _dataRef$current$open.type;
616
- return (type == null ? void 0 : type.includes('mouse')) && type !== 'mousedown';
617
- }, [dataRef]);
618
-
619
- // When closing before opening, clear the delay timeouts to cancel it
620
- // from showing.
621
- React__namespace.useEffect(() => {
622
- if (!enabled) return;
623
- function onOpenChange(_ref) {
624
- let {
625
- open
626
- } = _ref;
627
- if (!open) {
628
- clearTimeout(timeoutRef.current);
629
- clearTimeout(restTimeoutRef.current);
630
- blockMouseMoveRef.current = true;
631
- }
632
- }
633
- events.on('openchange', onOpenChange);
634
- return () => {
635
- events.off('openchange', onOpenChange);
636
- };
637
- }, [enabled, events]);
638
- React__namespace.useEffect(() => {
639
- if (!enabled) return;
640
- if (!handleCloseRef.current) return;
641
- if (!open) return;
642
- function onLeave(event) {
643
- if (isHoverOpen()) {
644
- onOpenChange(false, event, 'hover');
645
- }
646
- }
647
- const html = floatingUi_react_utils.getDocument(elements.floating).documentElement;
648
- html.addEventListener('mouseleave', onLeave);
649
- return () => {
650
- html.removeEventListener('mouseleave', onLeave);
651
- };
652
- }, [elements.floating, open, onOpenChange, enabled, handleCloseRef, isHoverOpen]);
653
- const closeWithDelay = React__namespace.useCallback(function (event, runElseBranch, reason) {
654
- if (runElseBranch === void 0) {
655
- runElseBranch = true;
656
- }
657
- if (reason === void 0) {
658
- reason = 'hover';
659
- }
660
- const closeDelay = getDelay(delayRef.current, 'close', pointerTypeRef.current);
661
- if (closeDelay && !handlerRef.current) {
662
- clearTimeout(timeoutRef.current);
663
- timeoutRef.current = window.setTimeout(() => onOpenChange(false, event, reason), closeDelay);
664
- } else if (runElseBranch) {
665
- clearTimeout(timeoutRef.current);
666
- onOpenChange(false, event, reason);
667
- }
668
- }, [delayRef, onOpenChange]);
669
- const cleanupMouseMoveHandler = useEffectEvent(() => {
670
- unbindMouseMoveRef.current();
671
- handlerRef.current = undefined;
672
- });
673
- const clearPointerEvents = useEffectEvent(() => {
674
- if (performedPointerEventsMutationRef.current) {
675
- const body = floatingUi_react_utils.getDocument(elements.floating).body;
676
- body.style.pointerEvents = '';
677
- body.removeAttribute(safePolygonIdentifier);
678
- performedPointerEventsMutationRef.current = false;
679
- }
680
- });
681
-
682
- // Registering the mouse events on the reference directly to bypass React's
683
- // delegation system. If the cursor was on a disabled element and then entered
684
- // the reference (no gap), `mouseenter` doesn't fire in the delegation system.
685
- React__namespace.useEffect(() => {
686
- if (!enabled) return;
687
- function isClickLikeOpenEvent() {
688
- return dataRef.current.openEvent ? ['click', 'mousedown'].includes(dataRef.current.openEvent.type) : false;
689
- }
690
- function onMouseEnter(event) {
691
- clearTimeout(timeoutRef.current);
692
- blockMouseMoveRef.current = false;
693
- if (mouseOnly && !floatingUi_react_utils.isMouseLikePointerType(pointerTypeRef.current) || restMs > 0 && !getDelay(delayRef.current, 'open')) {
694
- return;
695
- }
696
- const openDelay = getDelay(delayRef.current, 'open', pointerTypeRef.current);
697
- if (openDelay) {
698
- timeoutRef.current = window.setTimeout(() => {
699
- if (!openRef.current) {
700
- onOpenChange(true, event, 'hover');
701
- }
702
- }, openDelay);
703
- } else {
704
- onOpenChange(true, event, 'hover');
705
- }
706
- }
707
- function onMouseLeave(event) {
708
- if (isClickLikeOpenEvent()) return;
709
- unbindMouseMoveRef.current();
710
- const doc = floatingUi_react_utils.getDocument(elements.floating);
711
- clearTimeout(restTimeoutRef.current);
712
- if (handleCloseRef.current && dataRef.current.floatingContext) {
713
- // Prevent clearing `onScrollMouseLeave` timeout.
714
- if (!open) {
715
- clearTimeout(timeoutRef.current);
716
- }
717
- handlerRef.current = handleCloseRef.current({
718
- ...dataRef.current.floatingContext,
719
- tree,
720
- x: event.clientX,
721
- y: event.clientY,
722
- onClose() {
723
- clearPointerEvents();
724
- cleanupMouseMoveHandler();
725
- closeWithDelay(event, true, 'safe-polygon');
726
- }
727
- });
728
- const handler = handlerRef.current;
729
- doc.addEventListener('mousemove', handler);
730
- unbindMouseMoveRef.current = () => {
731
- doc.removeEventListener('mousemove', handler);
732
- };
733
- return;
734
- }
735
-
736
- // Allow interactivity without `safePolygon` on touch devices. With a
737
- // pointer, a short close delay is an alternative, so it should work
738
- // consistently.
739
- const shouldClose = pointerTypeRef.current === 'touch' ? !floatingUi_react_utils.contains(elements.floating, event.relatedTarget) : true;
740
- if (shouldClose) {
741
- closeWithDelay(event);
742
- }
743
- }
744
-
745
- // Ensure the floating element closes after scrolling even if the pointer
746
- // did not move.
747
- // https://github.com/floating-ui/floating-ui/discussions/1692
748
- function onScrollMouseLeave(event) {
749
- if (isClickLikeOpenEvent()) return;
750
- if (!dataRef.current.floatingContext) return;
751
- handleCloseRef.current == null || handleCloseRef.current({
752
- ...dataRef.current.floatingContext,
753
- tree,
754
- x: event.clientX,
755
- y: event.clientY,
756
- onClose() {
757
- clearPointerEvents();
758
- cleanupMouseMoveHandler();
759
- closeWithDelay(event);
760
- }
761
- })(event);
762
- }
763
- if (floatingUi_utils_dom$1.isElement(elements.domReference)) {
764
- var _elements$floating;
765
- const ref = elements.domReference;
766
- open && ref.addEventListener('mouseleave', onScrollMouseLeave);
767
- (_elements$floating = elements.floating) == null || _elements$floating.addEventListener('mouseleave', onScrollMouseLeave);
768
- move && ref.addEventListener('mousemove', onMouseEnter, {
769
- once: true
770
- });
771
- ref.addEventListener('mouseenter', onMouseEnter);
772
- ref.addEventListener('mouseleave', onMouseLeave);
773
- return () => {
774
- var _elements$floating2;
775
- open && ref.removeEventListener('mouseleave', onScrollMouseLeave);
776
- (_elements$floating2 = elements.floating) == null || _elements$floating2.removeEventListener('mouseleave', onScrollMouseLeave);
777
- move && ref.removeEventListener('mousemove', onMouseEnter);
778
- ref.removeEventListener('mouseenter', onMouseEnter);
779
- ref.removeEventListener('mouseleave', onMouseLeave);
780
- };
781
- }
782
- }, [elements, enabled, context, mouseOnly, restMs, move, closeWithDelay, cleanupMouseMoveHandler, clearPointerEvents, onOpenChange, open, openRef, tree, delayRef, handleCloseRef, dataRef]);
783
-
784
- // Block pointer-events of every element other than the reference and floating
785
- // while the floating element is open and has a `handleClose` handler. Also
786
- // handles nested floating elements.
787
- // https://github.com/floating-ui/floating-ui/issues/1722
788
- index(() => {
789
- var _handleCloseRef$curre;
790
- if (!enabled) return;
791
- if (open && (_handleCloseRef$curre = handleCloseRef.current) != null && _handleCloseRef$curre.__options.blockPointerEvents && isHoverOpen()) {
792
- const body = floatingUi_react_utils.getDocument(elements.floating).body;
793
- body.setAttribute(safePolygonIdentifier, '');
794
- body.style.pointerEvents = 'none';
795
- performedPointerEventsMutationRef.current = true;
796
- const floatingEl = elements.floating;
797
- if (floatingUi_utils_dom$1.isElement(elements.domReference) && floatingEl) {
798
- var _tree$nodesRef$curren;
799
- const ref = elements.domReference;
800
- const parentFloating = tree == null || (_tree$nodesRef$curren = tree.nodesRef.current.find(node => node.id === parentId)) == null || (_tree$nodesRef$curren = _tree$nodesRef$curren.context) == null ? void 0 : _tree$nodesRef$curren.elements.floating;
801
- if (parentFloating) {
802
- parentFloating.style.pointerEvents = '';
803
- }
804
- ref.style.pointerEvents = 'auto';
805
- floatingEl.style.pointerEvents = 'auto';
806
- return () => {
807
- ref.style.pointerEvents = '';
808
- floatingEl.style.pointerEvents = '';
809
- };
810
- }
811
- }
812
- }, [enabled, open, parentId, elements, tree, handleCloseRef, isHoverOpen]);
813
- index(() => {
814
- if (!open) {
815
- pointerTypeRef.current = undefined;
816
- cleanupMouseMoveHandler();
817
- clearPointerEvents();
818
- }
819
- }, [open, cleanupMouseMoveHandler, clearPointerEvents]);
820
- React__namespace.useEffect(() => {
821
- return () => {
822
- cleanupMouseMoveHandler();
823
- clearTimeout(timeoutRef.current);
824
- clearTimeout(restTimeoutRef.current);
825
- clearPointerEvents();
826
- };
827
- }, [enabled, elements.domReference, cleanupMouseMoveHandler, clearPointerEvents]);
828
- const reference = React__namespace.useMemo(() => {
829
- function setPointerRef(event) {
830
- pointerTypeRef.current = event.pointerType;
831
- }
832
- return {
833
- onPointerDown: setPointerRef,
834
- onPointerEnter: setPointerRef,
835
- onMouseMove(event) {
836
- const {
837
- nativeEvent
838
- } = event;
839
- function handleMouseMove() {
840
- if (!blockMouseMoveRef.current && !openRef.current) {
841
- onOpenChange(true, nativeEvent, 'hover');
842
- }
843
- }
844
- if (mouseOnly && !floatingUi_react_utils.isMouseLikePointerType(pointerTypeRef.current)) {
845
- return;
846
- }
847
- if (open || restMs === 0) {
848
- return;
849
- }
850
- clearTimeout(restTimeoutRef.current);
851
- if (pointerTypeRef.current === 'touch') {
852
- handleMouseMove();
853
- } else {
854
- restTimeoutRef.current = window.setTimeout(handleMouseMove, restMs);
855
- }
856
- }
857
- };
858
- }, [mouseOnly, onOpenChange, open, openRef, restMs]);
859
- const floating = React__namespace.useMemo(() => ({
860
- onMouseEnter() {
861
- clearTimeout(timeoutRef.current);
862
- },
863
- onMouseLeave(event) {
864
- closeWithDelay(event.nativeEvent, false);
865
- }
866
- }), [closeWithDelay]);
867
- return React__namespace.useMemo(() => enabled ? {
868
- reference,
869
- floating
870
- } : {}, [enabled, reference, floating]);
871
- }
872
-
873
- function getAncestors(nodes, id) {
874
- var _nodes$find;
875
- let allAncestors = [];
876
- let currentParentId = (_nodes$find = nodes.find(node => node.id === id)) == null ? void 0 : _nodes$find.parentId;
877
- while (currentParentId) {
878
- const currentNode = nodes.find(node => node.id === currentParentId);
879
- currentParentId = currentNode == null ? void 0 : currentNode.parentId;
880
- if (currentNode) {
881
- allAncestors = allAncestors.concat(currentNode);
882
- }
883
- }
884
- return allAncestors;
885
- }
886
-
887
- function getChildren(nodes, id) {
888
- let allChildren = nodes.filter(node => {
889
- var _node$context;
890
- return node.parentId === id && ((_node$context = node.context) == null ? void 0 : _node$context.open);
891
- });
892
- let currentChildren = allChildren;
893
- while (currentChildren.length) {
894
- currentChildren = nodes.filter(node => {
895
- var _currentChildren;
896
- return (_currentChildren = currentChildren) == null ? void 0 : _currentChildren.some(n => {
897
- var _node$context2;
898
- return node.parentId === n.id && ((_node$context2 = node.context) == null ? void 0 : _node$context2.open);
899
- });
900
- });
901
- allChildren = allChildren.concat(currentChildren);
902
- }
903
- return allChildren;
904
- }
905
- function getDeepestNode(nodes, id) {
906
- let deepestNodeId;
907
- let maxDepth = -1;
908
- function findDeepest(nodeId, depth) {
909
- if (depth > maxDepth) {
910
- deepestNodeId = nodeId;
911
- maxDepth = depth;
912
- }
913
- const children = getChildren(nodes, nodeId);
914
- children.forEach(child => {
915
- findDeepest(child.id, depth + 1);
916
- });
917
- }
918
- findDeepest(id, 0);
919
- return nodes.find(node => node.id === deepestNodeId);
920
- }
921
-
922
- // Modified to add conditional `aria-hidden` support:
923
- // https://github.com/theKashey/aria-hidden/blob/9220c8f4a4fd35f63bee5510a9f41a37264382d4/src/index.ts
924
- let counterMap = /*#__PURE__*/new WeakMap();
925
- let uncontrolledElementsSet = /*#__PURE__*/new WeakSet();
926
- let markerMap = {};
927
- let lockCount = 0;
928
- const supportsInert = () => typeof HTMLElement !== 'undefined' && 'inert' in HTMLElement.prototype;
929
- const unwrapHost = node => node && (node.host || unwrapHost(node.parentNode));
930
- const correctElements = (parent, targets) => targets.map(target => {
931
- if (parent.contains(target)) {
932
- return target;
933
- }
934
- const correctedTarget = unwrapHost(target);
935
- if (parent.contains(correctedTarget)) {
936
- return correctedTarget;
937
- }
938
- return null;
939
- }).filter(x => x != null);
940
- function applyAttributeToOthers(uncorrectedAvoidElements, body, ariaHidden, inert) {
941
- const markerName = 'data-floating-ui-inert';
942
- const controlAttribute = inert ? 'inert' : ariaHidden ? 'aria-hidden' : null;
943
- const avoidElements = correctElements(body, uncorrectedAvoidElements);
944
- const elementsToKeep = new Set();
945
- const elementsToStop = new Set(avoidElements);
946
- const hiddenElements = [];
947
- if (!markerMap[markerName]) {
948
- markerMap[markerName] = new WeakMap();
949
- }
950
- const markerCounter = markerMap[markerName];
951
- avoidElements.forEach(keep);
952
- deep(body);
953
- elementsToKeep.clear();
954
- function keep(el) {
955
- if (!el || elementsToKeep.has(el)) {
956
- return;
957
- }
958
- elementsToKeep.add(el);
959
- el.parentNode && keep(el.parentNode);
960
- }
961
- function deep(parent) {
962
- if (!parent || elementsToStop.has(parent)) {
963
- return;
964
- }
965
- [].forEach.call(parent.children, node => {
966
- if (floatingUi_utils_dom$1.getNodeName(node) === 'script') return;
967
- if (elementsToKeep.has(node)) {
968
- deep(node);
969
- } else {
970
- const attr = controlAttribute ? node.getAttribute(controlAttribute) : null;
971
- const alreadyHidden = attr !== null && attr !== 'false';
972
- const counterValue = (counterMap.get(node) || 0) + 1;
973
- const markerValue = (markerCounter.get(node) || 0) + 1;
974
- counterMap.set(node, counterValue);
975
- markerCounter.set(node, markerValue);
976
- hiddenElements.push(node);
977
- if (counterValue === 1 && alreadyHidden) {
978
- uncontrolledElementsSet.add(node);
979
- }
980
- if (markerValue === 1) {
981
- node.setAttribute(markerName, '');
982
- }
983
- if (!alreadyHidden && controlAttribute) {
984
- node.setAttribute(controlAttribute, 'true');
985
- }
986
- }
987
- });
988
- }
989
- lockCount++;
990
- return () => {
991
- hiddenElements.forEach(element => {
992
- const counterValue = (counterMap.get(element) || 0) - 1;
993
- const markerValue = (markerCounter.get(element) || 0) - 1;
994
- counterMap.set(element, counterValue);
995
- markerCounter.set(element, markerValue);
996
- if (!counterValue) {
997
- if (!uncontrolledElementsSet.has(element) && controlAttribute) {
998
- element.removeAttribute(controlAttribute);
999
- }
1000
- uncontrolledElementsSet.delete(element);
1001
- }
1002
- if (!markerValue) {
1003
- element.removeAttribute(markerName);
1004
- }
1005
- });
1006
- lockCount--;
1007
- if (!lockCount) {
1008
- counterMap = new WeakMap();
1009
- counterMap = new WeakMap();
1010
- uncontrolledElementsSet = new WeakSet();
1011
- markerMap = {};
1012
- }
1013
- };
1014
- }
1015
- function markOthers(avoidElements, ariaHidden, inert) {
1016
- if (ariaHidden === void 0) {
1017
- ariaHidden = false;
1018
- }
1019
- if (inert === void 0) {
1020
- inert = false;
1021
- }
1022
- const body = floatingUi_react_utils.getDocument(avoidElements[0]).body;
1023
- return applyAttributeToOthers(avoidElements.concat(Array.from(body.querySelectorAll('[aria-live]'))), body, ariaHidden, inert);
1024
- }
1025
-
1026
- const getTabbableOptions = () => ({
1027
- getShadowRoot: true,
1028
- displayCheck:
1029
- // JSDOM does not support the `tabbable` library. To solve this we can
1030
- // check if `ResizeObserver` is a real function (not polyfilled), which
1031
- // determines if the current environment is JSDOM-like.
1032
- typeof ResizeObserver === 'function' && ResizeObserver.toString().includes('[native code]') ? 'full' : 'none'
1033
- });
1034
- function getTabbableIn(container, direction) {
1035
- const allTabbable = index_esm.tabbable(container, getTabbableOptions());
1036
- if (direction === 'prev') {
1037
- allTabbable.reverse();
1038
- }
1039
- const activeIndex = allTabbable.indexOf(floatingUi_react_utils.activeElement(floatingUi_react_utils.getDocument(container)));
1040
- const nextTabbableElements = allTabbable.slice(activeIndex + 1);
1041
- return nextTabbableElements[0];
1042
- }
1043
- function getNextTabbable() {
1044
- return getTabbableIn(document.body, 'next');
1045
- }
1046
- function getPreviousTabbable() {
1047
- return getTabbableIn(document.body, 'prev');
1048
- }
1049
- function isOutsideEvent(event, container) {
1050
- const containerElement = container || event.currentTarget;
1051
- const relatedTarget = event.relatedTarget;
1052
- return !relatedTarget || !floatingUi_react_utils.contains(containerElement, relatedTarget);
1053
- }
1054
- function disableFocusInside(container) {
1055
- const tabbableElements = index_esm.tabbable(container, getTabbableOptions());
1056
- tabbableElements.forEach(element => {
1057
- element.dataset.tabindex = element.getAttribute('tabindex') || '';
1058
- element.setAttribute('tabindex', '-1');
1059
- });
1060
- }
1061
- function enableFocusInside(container) {
1062
- const elements = container.querySelectorAll('[data-tabindex]');
1063
- elements.forEach(element => {
1064
- const tabindex = element.dataset.tabindex;
1065
- delete element.dataset.tabindex;
1066
- if (tabindex) {
1067
- element.setAttribute('tabindex', tabindex);
1068
- } else {
1069
- element.removeAttribute('tabindex');
1070
- }
1071
- });
1072
- }
1073
- function getClosestTabbableElement(tabbableElements, element, floating) {
1074
- const elementIndex = tabbableElements.indexOf(element);
1075
- function traverseTabbableElements(next) {
1076
- const attr = createAttribute('focus-guard');
1077
- let index = elementIndex + (next ? 1 : 0);
1078
- let currentElement = tabbableElements[index];
1079
- while (currentElement && (!currentElement.isConnected || currentElement.hasAttribute(attr) || floatingUi_react_utils.contains(floating, currentElement))) {
1080
- if (next) {
1081
- index++;
1082
- } else {
1083
- index--;
1084
- }
1085
- currentElement = tabbableElements[index];
1086
- }
1087
- return currentElement;
1088
- }
1089
-
1090
- // First, try to find the next tabbable element
1091
- const next = traverseTabbableElements(true);
1092
- if (next) {
1093
- return next;
1094
- }
1095
-
1096
- // If we can't find a next tabbable element, try to find the previous one
1097
- return traverseTabbableElements(false);
1098
- }
1099
-
1100
- // See Diego Haz's Sandbox for making this logic work well on Safari/iOS:
1101
- // https://codesandbox.io/s/tabbable-portal-f4tng?file=/src/FocusTrap.tsx
1102
-
1103
- const HIDDEN_STYLES = {
1104
- border: 0,
1105
- clip: 'rect(0 0 0 0)',
1106
- height: '1px',
1107
- margin: '-1px',
1108
- overflow: 'hidden',
1109
- padding: 0,
1110
- position: 'fixed',
1111
- whiteSpace: 'nowrap',
1112
- width: '1px',
1113
- top: 0,
1114
- left: 0
1115
- };
1116
- let timeoutId;
1117
- function setActiveElementOnTab(event) {
1118
- if (event.key === 'Tab') {
1119
- event.target;
1120
- clearTimeout(timeoutId);
1121
- }
1122
- }
1123
- const FocusGuard = /*#__PURE__*/React__namespace.forwardRef(function FocusGuard(props, ref) {
1124
- const [role, setRole] = React__namespace.useState();
1125
- index(() => {
1126
- if (floatingUi_react_utils.isSafari()) {
1127
- // Unlike other screen readers such as NVDA and JAWS, the virtual cursor
1128
- // on VoiceOver does trigger the onFocus event, so we can use the focus
1129
- // trap element. On Safari, only buttons trigger the onFocus event.
1130
- // NB: "group" role in the Sandbox no longer appears to work, must be a
1131
- // button role.
1132
- setRole('button');
1133
- }
1134
- document.addEventListener('keydown', setActiveElementOnTab);
1135
- return () => {
1136
- document.removeEventListener('keydown', setActiveElementOnTab);
1137
- };
1138
- }, []);
1139
- const restProps = {
1140
- ref,
1141
- tabIndex: 0,
1142
- // Role is only for VoiceOver
1143
- role,
1144
- 'aria-hidden': role ? undefined : true,
1145
- [createAttribute('focus-guard')]: '',
1146
- style: HIDDEN_STYLES
1147
- };
1148
- return /*#__PURE__*/React__namespace.createElement("span", _extends({}, props, restProps));
1149
- });
1150
-
1151
- const PortalContext = /*#__PURE__*/React__namespace.createContext(null);
1152
- const attr = /*#__PURE__*/createAttribute('portal');
1153
- /**
1154
- * @see https://floating-ui.com/docs/FloatingPortal#usefloatingportalnode
1155
- */
1156
- function useFloatingPortalNode(props) {
1157
- if (props === void 0) {
1158
- props = {};
1159
- }
1160
- const {
1161
- id,
1162
- root
1163
- } = props;
1164
- const uniqueId = useId();
1165
- const portalContext = usePortalContext();
1166
- const [portalNode, setPortalNode] = React__namespace.useState(null);
1167
- const portalNodeRef = React__namespace.useRef(null);
1168
- index(() => {
1169
- return () => {
1170
- portalNode == null || portalNode.remove();
1171
- // Allow the subsequent layout effects to create a new node on updates.
1172
- // The portal node will still be cleaned up on unmount.
1173
- // https://github.com/floating-ui/floating-ui/issues/2454
1174
- queueMicrotask(() => {
1175
- portalNodeRef.current = null;
1176
- });
1177
- };
1178
- }, [portalNode]);
1179
- index(() => {
1180
- // Wait for the uniqueId to be generated before creating the portal node in
1181
- // React <18 (using `useFloatingId` instead of the native `useId`).
1182
- // https://github.com/floating-ui/floating-ui/issues/2778
1183
- if (!uniqueId) return;
1184
- if (portalNodeRef.current) return;
1185
- const existingIdRoot = id ? document.getElementById(id) : null;
1186
- if (!existingIdRoot) return;
1187
- const subRoot = document.createElement('div');
1188
- subRoot.id = uniqueId;
1189
- subRoot.setAttribute(attr, '');
1190
- existingIdRoot.appendChild(subRoot);
1191
- portalNodeRef.current = subRoot;
1192
- setPortalNode(subRoot);
1193
- }, [id, uniqueId]);
1194
- index(() => {
1195
- if (!uniqueId) return;
1196
- if (portalNodeRef.current) return;
1197
- let container = root || (portalContext == null ? void 0 : portalContext.portalNode);
1198
- if (container && !floatingUi_utils_dom$1.isElement(container)) container = container.current;
1199
- container = container || document.body;
1200
- let idWrapper = null;
1201
- if (id) {
1202
- idWrapper = document.createElement('div');
1203
- idWrapper.id = id;
1204
- container.appendChild(idWrapper);
1205
- }
1206
- const subRoot = document.createElement('div');
1207
- subRoot.id = uniqueId;
1208
- subRoot.setAttribute(attr, '');
1209
- container = idWrapper || container;
1210
- container.appendChild(subRoot);
1211
- portalNodeRef.current = subRoot;
1212
- setPortalNode(subRoot);
1213
- }, [id, root, uniqueId, portalContext]);
1214
- return portalNode;
1215
- }
1216
- /**
1217
- * Portals the floating element into a given container element — by default,
1218
- * outside of the app root and into the body.
1219
- * This is necessary to ensure the floating element can appear outside any
1220
- * potential parent containers that cause clipping (such as `overflow: hidden`),
1221
- * while retaining its location in the React tree.
1222
- * @see https://floating-ui.com/docs/FloatingPortal
1223
- */
1224
- function FloatingPortal(props) {
1225
- const {
1226
- children,
1227
- id,
1228
- root = null,
1229
- preserveTabOrder = true
1230
- } = props;
1231
- const portalNode = useFloatingPortalNode({
1232
- id,
1233
- root
1234
- });
1235
- const [focusManagerState, setFocusManagerState] = React__namespace.useState(null);
1236
- const beforeOutsideRef = React__namespace.useRef(null);
1237
- const afterOutsideRef = React__namespace.useRef(null);
1238
- const beforeInsideRef = React__namespace.useRef(null);
1239
- const afterInsideRef = React__namespace.useRef(null);
1240
- const shouldRenderGuards =
1241
- // The FocusManager and therefore floating element are currently open/
1242
- // rendered.
1243
- !!focusManagerState &&
1244
- // Guards are only for non-modal focus management.
1245
- !focusManagerState.modal &&
1246
- // Don't render if unmount is transitioning.
1247
- focusManagerState.open && preserveTabOrder && !!(root || portalNode);
1248
-
1249
- // https://codesandbox.io/s/tabbable-portal-f4tng?file=/src/TabbablePortal.tsx
1250
- React__namespace.useEffect(() => {
1251
- if (!portalNode || !preserveTabOrder || focusManagerState != null && focusManagerState.modal) {
1252
- return;
1253
- }
1254
-
1255
- // Make sure elements inside the portal element are tabbable only when the
1256
- // portal has already been focused, either by tabbing into a focus trap
1257
- // element outside or using the mouse.
1258
- function onFocus(event) {
1259
- if (portalNode && isOutsideEvent(event)) {
1260
- const focusing = event.type === 'focusin';
1261
- const manageFocus = focusing ? enableFocusInside : disableFocusInside;
1262
- manageFocus(portalNode);
1263
- }
1264
- }
1265
- // Listen to the event on the capture phase so they run before the focus
1266
- // trap elements onFocus prop is called.
1267
- portalNode.addEventListener('focusin', onFocus, true);
1268
- portalNode.addEventListener('focusout', onFocus, true);
1269
- return () => {
1270
- portalNode.removeEventListener('focusin', onFocus, true);
1271
- portalNode.removeEventListener('focusout', onFocus, true);
1272
- };
1273
- }, [portalNode, preserveTabOrder, focusManagerState == null ? void 0 : focusManagerState.modal]);
1274
- return /*#__PURE__*/React__namespace.createElement(PortalContext.Provider, {
1275
- value: React__namespace.useMemo(() => ({
1276
- preserveTabOrder,
1277
- beforeOutsideRef,
1278
- afterOutsideRef,
1279
- beforeInsideRef,
1280
- afterInsideRef,
1281
- portalNode,
1282
- setFocusManagerState
1283
- }), [preserveTabOrder, portalNode])
1284
- }, shouldRenderGuards && portalNode && /*#__PURE__*/React__namespace.createElement(FocusGuard, {
1285
- "data-type": "outside",
1286
- ref: beforeOutsideRef,
1287
- onFocus: event => {
1288
- if (isOutsideEvent(event, portalNode)) {
1289
- var _beforeInsideRef$curr;
1290
- (_beforeInsideRef$curr = beforeInsideRef.current) == null || _beforeInsideRef$curr.focus();
1291
- } else {
1292
- const prevTabbable = getPreviousTabbable() || (focusManagerState == null ? void 0 : focusManagerState.refs.domReference.current);
1293
- prevTabbable == null || prevTabbable.focus();
1294
- }
1295
- }
1296
- }), shouldRenderGuards && portalNode && /*#__PURE__*/React__namespace.createElement("span", {
1297
- "aria-owns": portalNode.id,
1298
- style: HIDDEN_STYLES
1299
- }), portalNode && /*#__PURE__*/ReactDOM__namespace.createPortal(children, portalNode), shouldRenderGuards && portalNode && /*#__PURE__*/React__namespace.createElement(FocusGuard, {
1300
- "data-type": "outside",
1301
- ref: afterOutsideRef,
1302
- onFocus: event => {
1303
- if (isOutsideEvent(event, portalNode)) {
1304
- var _afterInsideRef$curre;
1305
- (_afterInsideRef$curre = afterInsideRef.current) == null || _afterInsideRef$curre.focus();
1306
- } else {
1307
- const nextTabbable = getNextTabbable() || (focusManagerState == null ? void 0 : focusManagerState.refs.domReference.current);
1308
- nextTabbable == null || nextTabbable.focus();
1309
- (focusManagerState == null ? void 0 : focusManagerState.closeOnFocusOut) && (focusManagerState == null ? void 0 : focusManagerState.onOpenChange(false, event.nativeEvent));
1310
- }
1311
- }
1312
- }));
1313
- }
1314
- const usePortalContext = () => React__namespace.useContext(PortalContext);
1315
-
1316
- const LIST_LIMIT = 20;
1317
- let previouslyFocusedElements = [];
1318
- function addPreviouslyFocusedElement(element) {
1319
- previouslyFocusedElements = previouslyFocusedElements.filter(el => el.isConnected);
1320
- let tabbableEl = element;
1321
- if (!tabbableEl || floatingUi_utils_dom$1.getNodeName(tabbableEl) === 'body') return;
1322
- if (!index_esm.isTabbable(tabbableEl, getTabbableOptions())) {
1323
- const tabbableChild = index_esm.tabbable(tabbableEl, getTabbableOptions())[0];
1324
- if (tabbableChild) {
1325
- tabbableEl = tabbableChild;
1326
- }
1327
- }
1328
- previouslyFocusedElements.push(tabbableEl);
1329
- if (previouslyFocusedElements.length > LIST_LIMIT) {
1330
- previouslyFocusedElements = previouslyFocusedElements.slice(-LIST_LIMIT);
1331
- }
1332
- }
1333
- function getPreviouslyFocusedElement() {
1334
- return previouslyFocusedElements.slice().reverse().find(el => el.isConnected);
1335
- }
1336
- const VisuallyHiddenDismiss = /*#__PURE__*/React__namespace.forwardRef(function VisuallyHiddenDismiss(props, ref) {
1337
- return /*#__PURE__*/React__namespace.createElement("button", _extends({}, props, {
1338
- type: "button",
1339
- ref: ref,
1340
- tabIndex: -1,
1341
- style: HIDDEN_STYLES
1342
- }));
1343
- });
1344
- /**
1345
- * Provides focus management for the floating element.
1346
- * @see https://floating-ui.com/docs/FloatingFocusManager
1347
- */
1348
- function FloatingFocusManager(props) {
1349
- const {
1350
- context,
1351
- children,
1352
- disabled = false,
1353
- order = ['content'],
1354
- guards: _guards = true,
1355
- initialFocus = 0,
1356
- returnFocus = true,
1357
- restoreFocus = false,
1358
- modal = true,
1359
- visuallyHiddenDismiss = false,
1360
- closeOnFocusOut = true
1361
- } = props;
1362
- const {
1363
- open,
1364
- refs,
1365
- nodeId,
1366
- onOpenChange,
1367
- events,
1368
- dataRef,
1369
- floatingId,
1370
- elements: {
1371
- domReference,
1372
- floating
1373
- }
1374
- } = context;
1375
- const ignoreInitialFocus = typeof initialFocus === 'number' && initialFocus < 0;
1376
- // If the reference is a combobox and is typeable (e.g. input/textarea),
1377
- // there are different focus semantics. The guards should not be rendered, but
1378
- // aria-hidden should be applied to all nodes still. Further, the visually
1379
- // hidden dismiss button should only appear at the end of the list, not the
1380
- // start.
1381
- const isUntrappedTypeableCombobox = floatingUi_react_utils.isTypeableCombobox(domReference) && ignoreInitialFocus;
1382
-
1383
- // Force the guards to be rendered if the `inert` attribute is not supported.
1384
- const guards = supportsInert() ? _guards : true;
1385
- const orderRef = useLatestRef(order);
1386
- const initialFocusRef = useLatestRef(initialFocus);
1387
- const returnFocusRef = useLatestRef(returnFocus);
1388
- const tree = useFloatingTree();
1389
- const portalContext = usePortalContext();
1390
- const startDismissButtonRef = React__namespace.useRef(null);
1391
- const endDismissButtonRef = React__namespace.useRef(null);
1392
- const preventReturnFocusRef = React__namespace.useRef(false);
1393
- const isPointerDownRef = React__namespace.useRef(false);
1394
- const tabbableIndexRef = React__namespace.useRef(-1);
1395
- const isInsidePortal = portalContext != null;
1396
- const firstElementChild = floating == null ? void 0 : floating.firstElementChild;
1397
- // If the floating element is acting as a positioning wrapper rather than the
1398
- // element that receives aria props, use it as the focus root instead.
1399
- const floatingFocusNode = (firstElementChild == null ? void 0 : firstElementChild.id) === floatingId ? firstElementChild : floating;
1400
- const getTabbableContent = useEffectEvent(function (container) {
1401
- if (container === void 0) {
1402
- container = floatingFocusNode;
1403
- }
1404
- return container ? index_esm.tabbable(container, getTabbableOptions()) : [];
1405
- });
1406
- const getTabbableElements = useEffectEvent(container => {
1407
- const content = getTabbableContent(container);
1408
- return orderRef.current.map(type => {
1409
- if (domReference && type === 'reference') {
1410
- return domReference;
1411
- }
1412
- if (floatingFocusNode && type === 'floating') {
1413
- return floatingFocusNode;
1414
- }
1415
- return content;
1416
- }).filter(Boolean).flat();
1417
- });
1418
- React__namespace.useEffect(() => {
1419
- if (disabled) return;
1420
- if (!modal) return;
1421
- function onKeyDown(event) {
1422
- if (event.key === 'Tab') {
1423
- // The focus guards have nothing to focus, so we need to stop the event.
1424
- if (floatingUi_react_utils.contains(floatingFocusNode, floatingUi_react_utils.activeElement(floatingUi_react_utils.getDocument(floatingFocusNode))) && getTabbableContent().length === 0 && !isUntrappedTypeableCombobox) {
1425
- floatingUi_react_utils.stopEvent(event);
1426
- }
1427
- const els = getTabbableElements();
1428
- const target = floatingUi_react_utils.getTarget(event);
1429
- if (orderRef.current[0] === 'reference' && target === domReference) {
1430
- floatingUi_react_utils.stopEvent(event);
1431
- if (event.shiftKey) {
1432
- enqueueFocus(els[els.length - 1]);
1433
- } else {
1434
- enqueueFocus(els[1]);
1435
- }
1436
- }
1437
- if (orderRef.current[1] === 'floating' && target === floatingFocusNode && event.shiftKey) {
1438
- floatingUi_react_utils.stopEvent(event);
1439
- enqueueFocus(els[0]);
1440
- }
1441
- }
1442
- }
1443
- const doc = floatingUi_react_utils.getDocument(floatingFocusNode);
1444
- doc.addEventListener('keydown', onKeyDown);
1445
- return () => {
1446
- doc.removeEventListener('keydown', onKeyDown);
1447
- };
1448
- }, [disabled, domReference, floatingFocusNode, modal, orderRef, isUntrappedTypeableCombobox, getTabbableContent, getTabbableElements]);
1449
- React__namespace.useEffect(() => {
1450
- if (disabled) return;
1451
- if (!floating) return;
1452
- function handleFocusIn(event) {
1453
- const target = floatingUi_react_utils.getTarget(event);
1454
- const tabbableContent = getTabbableContent();
1455
- const tabbableIndex = tabbableContent.indexOf(target);
1456
- if (tabbableIndex !== -1) {
1457
- tabbableIndexRef.current = tabbableIndex;
1458
- }
1459
- }
1460
- floating.addEventListener('focusin', handleFocusIn);
1461
- return () => {
1462
- floating.removeEventListener('focusin', handleFocusIn);
1463
- };
1464
- }, [disabled, floating, getTabbableContent]);
1465
- React__namespace.useEffect(() => {
1466
- if (disabled) return;
1467
- if (!closeOnFocusOut) return;
1468
-
1469
- // In Safari, buttons lose focus when pressing them.
1470
- function handlePointerDown() {
1471
- isPointerDownRef.current = true;
1472
- setTimeout(() => {
1473
- isPointerDownRef.current = false;
1474
- });
1475
- }
1476
- function handleFocusOutside(event) {
1477
- const relatedTarget = event.relatedTarget;
1478
- queueMicrotask(() => {
1479
- const movedToUnrelatedNode = !(floatingUi_react_utils.contains(domReference, relatedTarget) || floatingUi_react_utils.contains(floating, relatedTarget) || floatingUi_react_utils.contains(relatedTarget, floating) || floatingUi_react_utils.contains(portalContext == null ? void 0 : portalContext.portalNode, relatedTarget) || relatedTarget != null && relatedTarget.hasAttribute(createAttribute('focus-guard')) || tree && (getChildren(tree.nodesRef.current, nodeId).find(node => {
1480
- var _node$context, _node$context2;
1481
- return floatingUi_react_utils.contains((_node$context = node.context) == null ? void 0 : _node$context.elements.floating, relatedTarget) || floatingUi_react_utils.contains((_node$context2 = node.context) == null ? void 0 : _node$context2.elements.domReference, relatedTarget);
1482
- }) || getAncestors(tree.nodesRef.current, nodeId).find(node => {
1483
- var _node$context3, _node$context4;
1484
- return ((_node$context3 = node.context) == null ? void 0 : _node$context3.elements.floating) === relatedTarget || ((_node$context4 = node.context) == null ? void 0 : _node$context4.elements.domReference) === relatedTarget;
1485
- })));
1486
-
1487
- // Restore focus to the previous tabbable element index to prevent
1488
- // focus from being lost outside the floating tree.
1489
- if (restoreFocus && movedToUnrelatedNode && floatingUi_react_utils.activeElement(floatingUi_react_utils.getDocument(floatingFocusNode)) === floatingUi_react_utils.getDocument(floatingFocusNode).body) {
1490
- // Let `FloatingPortal` effect knows that focus is still inside the
1491
- // floating tree.
1492
- if (floatingUi_utils_dom$1.isHTMLElement(floatingFocusNode)) {
1493
- floatingFocusNode == null || floatingFocusNode.focus();
1494
- }
1495
- const prevTabbableIndex = tabbableIndexRef.current;
1496
- const tabbableContent = getTabbableContent();
1497
- const nodeToFocus = tabbableContent[prevTabbableIndex] || tabbableContent[tabbableContent.length - 1] || floatingFocusNode;
1498
- if (floatingUi_utils_dom$1.isHTMLElement(nodeToFocus)) {
1499
- nodeToFocus.focus();
1500
- }
1501
- }
1502
-
1503
- // Focus did not move inside the floating tree, and there are no tabbable
1504
- // portal guards to handle closing.
1505
- if ((isUntrappedTypeableCombobox ? true : !modal) && relatedTarget && movedToUnrelatedNode && !isPointerDownRef.current &&
1506
- // Fix React 18 Strict Mode returnFocus due to double rendering.
1507
- relatedTarget !== getPreviouslyFocusedElement()) {
1508
- preventReturnFocusRef.current = true;
1509
- onOpenChange(false, event);
1510
- }
1511
- });
1512
- }
1513
- if (floating && floatingUi_utils_dom$1.isHTMLElement(domReference)) {
1514
- domReference.addEventListener('focusout', handleFocusOutside);
1515
- domReference.addEventListener('pointerdown', handlePointerDown);
1516
- floating.addEventListener('focusout', handleFocusOutside);
1517
- return () => {
1518
- domReference.removeEventListener('focusout', handleFocusOutside);
1519
- domReference.removeEventListener('pointerdown', handlePointerDown);
1520
- floating.removeEventListener('focusout', handleFocusOutside);
1521
- };
1522
- }
1523
- }, [disabled, domReference, floating, floatingFocusNode, modal, nodeId, tree, portalContext, onOpenChange, closeOnFocusOut, restoreFocus, getTabbableContent, isUntrappedTypeableCombobox]);
1524
- React__namespace.useEffect(() => {
1525
- var _portalContext$portal;
1526
- if (disabled) return;
1527
-
1528
- // Don't hide portals nested within the parent portal.
1529
- const portalNodes = Array.from((portalContext == null || (_portalContext$portal = portalContext.portalNode) == null ? void 0 : _portalContext$portal.querySelectorAll("[" + createAttribute('portal') + "]")) || []);
1530
- if (floating) {
1531
- const insideElements = [floating, ...portalNodes, startDismissButtonRef.current, endDismissButtonRef.current, orderRef.current.includes('reference') || isUntrappedTypeableCombobox ? domReference : null].filter(x => x != null);
1532
- const cleanup = modal || isUntrappedTypeableCombobox ? markOthers(insideElements, guards, !guards) : markOthers(insideElements);
1533
- return () => {
1534
- cleanup();
1535
- };
1536
- }
1537
- }, [disabled, domReference, floating, modal, orderRef, portalContext, isUntrappedTypeableCombobox, guards]);
1538
- index(() => {
1539
- if (disabled || !floatingUi_utils_dom$1.isHTMLElement(floatingFocusNode)) return;
1540
- const doc = floatingUi_react_utils.getDocument(floatingFocusNode);
1541
- const previouslyFocusedElement = floatingUi_react_utils.activeElement(doc);
1542
-
1543
- // Wait for any layout effect state setters to execute to set `tabIndex`.
1544
- queueMicrotask(() => {
1545
- const focusableElements = getTabbableElements(floatingFocusNode);
1546
- const initialFocusValue = initialFocusRef.current;
1547
- const elToFocus = (typeof initialFocusValue === 'number' ? focusableElements[initialFocusValue] : initialFocusValue.current) || floatingFocusNode;
1548
- const focusAlreadyInsideFloatingEl = floatingUi_react_utils.contains(floatingFocusNode, previouslyFocusedElement);
1549
- if (!ignoreInitialFocus && !focusAlreadyInsideFloatingEl && open) {
1550
- enqueueFocus(elToFocus, {
1551
- preventScroll: elToFocus === floatingFocusNode
1552
- });
1553
- }
1554
- });
1555
- }, [disabled, open, floatingFocusNode, ignoreInitialFocus, getTabbableElements, initialFocusRef]);
1556
- index(() => {
1557
- if (disabled || !floatingFocusNode) return;
1558
- let preventReturnFocusScroll = false;
1559
- const doc = floatingUi_react_utils.getDocument(floatingFocusNode);
1560
- const previouslyFocusedElement = floatingUi_react_utils.activeElement(doc);
1561
- const contextData = dataRef.current;
1562
- let openEvent = contextData.openEvent;
1563
- const domReference = refs.domReference.current;
1564
- addPreviouslyFocusedElement(previouslyFocusedElement);
1565
-
1566
- // Dismissing via outside press should always ignore `returnFocus` to
1567
- // prevent unwanted scrolling.
1568
- function onOpenChange(_ref) {
1569
- let {
1570
- open,
1571
- reason,
1572
- event,
1573
- nested
1574
- } = _ref;
1575
- if (open) {
1576
- openEvent = event;
1577
- }
1578
- if (reason === 'escape-key' && refs.domReference.current) {
1579
- addPreviouslyFocusedElement(refs.domReference.current);
1580
- }
1581
- if (reason === 'hover' && event.type === 'mouseleave') {
1582
- preventReturnFocusRef.current = true;
1583
- }
1584
- if (reason !== 'outside-press') return;
1585
- if (nested) {
1586
- preventReturnFocusRef.current = false;
1587
- preventReturnFocusScroll = true;
1588
- } else {
1589
- preventReturnFocusRef.current = !(floatingUi_react_utils.isVirtualClick(event) || floatingUi_react_utils.isVirtualPointerEvent(event));
1590
- }
1591
- }
1592
- events.on('openchange', onOpenChange);
1593
- return () => {
1594
- events.off('openchange', onOpenChange);
1595
- const activeEl = floatingUi_react_utils.activeElement(doc);
1596
- const isFocusInsideFloatingTree = floatingUi_react_utils.contains(floating, activeEl) || tree && getChildren(tree.nodesRef.current, nodeId).some(node => {
1597
- var _node$context5;
1598
- return floatingUi_react_utils.contains((_node$context5 = node.context) == null ? void 0 : _node$context5.elements.floating, activeEl);
1599
- });
1600
- const shouldFocusReference = isFocusInsideFloatingTree || openEvent && ['click', 'mousedown'].includes(openEvent.type);
1601
- if (shouldFocusReference && refs.domReference.current) {
1602
- addPreviouslyFocusedElement(refs.domReference.current);
1603
- }
1604
- const returnContextElement = domReference || previouslyFocusedElement;
1605
- const tabbableElements = index_esm.tabbable(floatingUi_react_utils.getDocument(returnContextElement).body, getTabbableOptions());
1606
-
1607
- // Wait for the return element to get potentially disconnected before
1608
- // checking.
1609
- queueMicrotask(() => {
1610
- let returnElement = getPreviouslyFocusedElement();
1611
- if (!returnElement && floatingUi_utils_dom$1.isHTMLElement(returnContextElement) && floating) {
1612
- returnElement = getClosestTabbableElement(tabbableElements, returnContextElement, floating);
1613
- }
1614
- if (
1615
- // eslint-disable-next-line react-hooks/exhaustive-deps
1616
- returnFocusRef.current && !preventReturnFocusRef.current && floatingUi_utils_dom$1.isHTMLElement(returnElement) && (
1617
- // If the focus moved somewhere else after mount, avoid returning focus
1618
- // since it likely entered a different element which should be
1619
- // respected: https://github.com/floating-ui/floating-ui/issues/2607
1620
- returnElement !== activeEl && activeEl !== doc.body ? isFocusInsideFloatingTree : true)) {
1621
- returnElement.focus({
1622
- preventScroll: preventReturnFocusScroll
1623
- });
1624
- }
1625
- });
1626
- };
1627
- }, [disabled, floating, floatingFocusNode, returnFocusRef, dataRef, refs, events, tree, nodeId]);
1628
-
1629
- // Synchronize the `context` & `modal` value to the FloatingPortal context.
1630
- // It will decide whether or not it needs to render its own guards.
1631
- index(() => {
1632
- if (disabled) return;
1633
- if (!portalContext) return;
1634
- portalContext.setFocusManagerState({
1635
- modal,
1636
- closeOnFocusOut,
1637
- open,
1638
- onOpenChange,
1639
- refs
1640
- });
1641
- return () => {
1642
- portalContext.setFocusManagerState(null);
1643
- };
1644
- }, [disabled, portalContext, modal, open, onOpenChange, refs, closeOnFocusOut]);
1645
- index(() => {
1646
- if (disabled) return;
1647
- if (!floatingFocusNode) return;
1648
- if (typeof MutationObserver !== 'function') return;
1649
- if (ignoreInitialFocus) return;
1650
- const handleMutation = () => {
1651
- const tabIndex = floatingFocusNode.getAttribute('tabindex');
1652
- const tabbableContent = getTabbableContent();
1653
- const activeEl = floatingUi_react_utils.activeElement(floatingUi_react_utils.getDocument(floating));
1654
- const tabbableIndex = tabbableContent.indexOf(activeEl);
1655
- if (tabbableIndex !== -1) {
1656
- tabbableIndexRef.current = tabbableIndex;
1657
- }
1658
- if (orderRef.current.includes('floating') || activeEl !== refs.domReference.current && tabbableContent.length === 0) {
1659
- if (tabIndex !== '0') {
1660
- floatingFocusNode.setAttribute('tabindex', '0');
1661
- }
1662
- } else if (tabIndex !== '-1') {
1663
- floatingFocusNode.setAttribute('tabindex', '-1');
1664
- }
1665
- };
1666
- handleMutation();
1667
- const observer = new MutationObserver(handleMutation);
1668
- observer.observe(floatingFocusNode, {
1669
- childList: true,
1670
- subtree: true,
1671
- attributes: true
1672
- });
1673
- return () => {
1674
- observer.disconnect();
1675
- };
1676
- }, [disabled, floating, floatingFocusNode, refs, orderRef, getTabbableContent, ignoreInitialFocus]);
1677
- function renderDismissButton(location) {
1678
- if (disabled || !visuallyHiddenDismiss || !modal) {
1679
- return null;
1680
- }
1681
- return /*#__PURE__*/React__namespace.createElement(VisuallyHiddenDismiss, {
1682
- ref: location === 'start' ? startDismissButtonRef : endDismissButtonRef,
1683
- onClick: event => onOpenChange(false, event.nativeEvent)
1684
- }, typeof visuallyHiddenDismiss === 'string' ? visuallyHiddenDismiss : 'Dismiss');
1685
- }
1686
- const shouldRenderGuards = !disabled && guards && (modal ? !isUntrappedTypeableCombobox : true) && (isInsidePortal || modal);
1687
- return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, shouldRenderGuards && /*#__PURE__*/React__namespace.createElement(FocusGuard, {
1688
- "data-type": "inside",
1689
- ref: portalContext == null ? void 0 : portalContext.beforeInsideRef,
1690
- onFocus: event => {
1691
- if (modal) {
1692
- const els = getTabbableElements();
1693
- enqueueFocus(order[0] === 'reference' ? els[0] : els[els.length - 1]);
1694
- } else if (portalContext != null && portalContext.preserveTabOrder && portalContext.portalNode) {
1695
- preventReturnFocusRef.current = false;
1696
- if (isOutsideEvent(event, portalContext.portalNode)) {
1697
- const nextTabbable = getNextTabbable() || domReference;
1698
- nextTabbable == null || nextTabbable.focus();
1699
- } else {
1700
- var _portalContext$before;
1701
- (_portalContext$before = portalContext.beforeOutsideRef.current) == null || _portalContext$before.focus();
1702
- }
1703
- }
1704
- }
1705
- }), !isUntrappedTypeableCombobox && renderDismissButton('start'), children, renderDismissButton('end'), shouldRenderGuards && /*#__PURE__*/React__namespace.createElement(FocusGuard, {
1706
- "data-type": "inside",
1707
- ref: portalContext == null ? void 0 : portalContext.afterInsideRef,
1708
- onFocus: event => {
1709
- if (modal) {
1710
- enqueueFocus(getTabbableElements()[0]);
1711
- } else if (portalContext != null && portalContext.preserveTabOrder && portalContext.portalNode) {
1712
- if (closeOnFocusOut) {
1713
- preventReturnFocusRef.current = true;
1714
- }
1715
- if (isOutsideEvent(event, portalContext.portalNode)) {
1716
- const prevTabbable = getPreviousTabbable() || domReference;
1717
- prevTabbable == null || prevTabbable.focus();
1718
- } else {
1719
- var _portalContext$afterO;
1720
- (_portalContext$afterO = portalContext.afterOutsideRef.current) == null || _portalContext$afterO.focus();
1721
- }
1722
- }
1723
- }
1724
- }));
1725
- }
1726
-
1727
- function isButtonTarget(event) {
1728
- return floatingUi_utils_dom$1.isHTMLElement(event.target) && event.target.tagName === 'BUTTON';
1729
- }
1730
- function isSpaceIgnored(element) {
1731
- return floatingUi_react_utils.isTypeableElement(element);
1732
- }
1733
- /**
1734
- * Opens or closes the floating element when clicking the reference element.
1735
- * @see https://floating-ui.com/docs/useClick
1736
- */
1737
- function useClick(context, props) {
1738
- if (props === void 0) {
1739
- props = {};
1740
- }
1741
- const {
1742
- open,
1743
- onOpenChange,
1744
- dataRef,
1745
- elements: {
1746
- domReference
1747
- }
1748
- } = context;
1749
- const {
1750
- enabled = true,
1751
- event: eventOption = 'click',
1752
- toggle = true,
1753
- ignoreMouse = false,
1754
- keyboardHandlers = true
1755
- } = props;
1756
- const pointerTypeRef = React__namespace.useRef();
1757
- const didKeyDownRef = React__namespace.useRef(false);
1758
- const reference = React__namespace.useMemo(() => ({
1759
- onPointerDown(event) {
1760
- pointerTypeRef.current = event.pointerType;
1761
- },
1762
- onMouseDown(event) {
1763
- const pointerType = pointerTypeRef.current;
1764
-
1765
- // Ignore all buttons except for the "main" button.
1766
- // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
1767
- if (event.button !== 0) return;
1768
- if (eventOption === 'click') return;
1769
- if (floatingUi_react_utils.isMouseLikePointerType(pointerType, true) && ignoreMouse) return;
1770
- if (open && toggle && (dataRef.current.openEvent ? dataRef.current.openEvent.type === 'mousedown' : true)) {
1771
- onOpenChange(false, event.nativeEvent, 'click');
1772
- } else {
1773
- // Prevent stealing focus from the floating element
1774
- event.preventDefault();
1775
- onOpenChange(true, event.nativeEvent, 'click');
1776
- }
1777
- },
1778
- onClick(event) {
1779
- const pointerType = pointerTypeRef.current;
1780
- if (eventOption === 'mousedown' && pointerTypeRef.current) {
1781
- pointerTypeRef.current = undefined;
1782
- return;
1783
- }
1784
- if (floatingUi_react_utils.isMouseLikePointerType(pointerType, true) && ignoreMouse) return;
1785
- if (open && toggle && (dataRef.current.openEvent ? dataRef.current.openEvent.type === 'click' : true)) {
1786
- onOpenChange(false, event.nativeEvent, 'click');
1787
- } else {
1788
- onOpenChange(true, event.nativeEvent, 'click');
1789
- }
1790
- },
1791
- onKeyDown(event) {
1792
- pointerTypeRef.current = undefined;
1793
- if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event)) {
1794
- return;
1795
- }
1796
- if (event.key === ' ' && !isSpaceIgnored(domReference)) {
1797
- // Prevent scrolling
1798
- event.preventDefault();
1799
- didKeyDownRef.current = true;
1800
- }
1801
- if (event.key === 'Enter') {
1802
- if (open && toggle) {
1803
- onOpenChange(false, event.nativeEvent, 'click');
1804
- } else {
1805
- onOpenChange(true, event.nativeEvent, 'click');
1806
- }
1807
- }
1808
- },
1809
- onKeyUp(event) {
1810
- if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event) || isSpaceIgnored(domReference)) {
1811
- return;
1812
- }
1813
- if (event.key === ' ' && didKeyDownRef.current) {
1814
- didKeyDownRef.current = false;
1815
- if (open && toggle) {
1816
- onOpenChange(false, event.nativeEvent, 'click');
1817
- } else {
1818
- onOpenChange(true, event.nativeEvent, 'click');
1819
- }
1820
- }
1821
- }
1822
- }), [dataRef, domReference, eventOption, ignoreMouse, keyboardHandlers, onOpenChange, open, toggle]);
1823
- return React__namespace.useMemo(() => enabled ? {
1824
- reference
1825
- } : {}, [enabled, reference]);
1826
- }
1827
-
1828
- const bubbleHandlerKeys = {
1829
- pointerdown: 'onPointerDown',
1830
- mousedown: 'onMouseDown',
1831
- click: 'onClick'
1832
- };
1833
- const captureHandlerKeys = {
1834
- pointerdown: 'onPointerDownCapture',
1835
- mousedown: 'onMouseDownCapture',
1836
- click: 'onClickCapture'
1837
- };
1838
- const normalizeProp = normalizable => {
1839
- var _normalizable$escapeK, _normalizable$outside;
1840
- return {
1841
- escapeKey: typeof normalizable === 'boolean' ? normalizable : (_normalizable$escapeK = normalizable == null ? void 0 : normalizable.escapeKey) != null ? _normalizable$escapeK : false,
1842
- outsidePress: typeof normalizable === 'boolean' ? normalizable : (_normalizable$outside = normalizable == null ? void 0 : normalizable.outsidePress) != null ? _normalizable$outside : true
1843
- };
1844
- };
1845
- /**
1846
- * Closes the floating element when a dismissal is requested — by default, when
1847
- * the user presses the `escape` key or outside of the floating element.
1848
- * @see https://floating-ui.com/docs/useDismiss
1849
- */
1850
- function useDismiss(context, props) {
1851
- if (props === void 0) {
1852
- props = {};
1853
- }
1854
- const {
1855
- open,
1856
- onOpenChange,
1857
- elements,
1858
- dataRef
1859
- } = context;
1860
- const {
1861
- enabled = true,
1862
- escapeKey = true,
1863
- outsidePress: unstable_outsidePress = true,
1864
- outsidePressEvent = 'pointerdown',
1865
- referencePress = false,
1866
- referencePressEvent = 'pointerdown',
1867
- ancestorScroll = false,
1868
- bubbles,
1869
- capture
1870
- } = props;
1871
- const tree = useFloatingTree();
1872
- const outsidePressFn = useEffectEvent(typeof unstable_outsidePress === 'function' ? unstable_outsidePress : () => false);
1873
- const outsidePress = typeof unstable_outsidePress === 'function' ? outsidePressFn : unstable_outsidePress;
1874
- const insideReactTreeRef = React__namespace.useRef(false);
1875
- const endedOrStartedInsideRef = React__namespace.useRef(false);
1876
- const {
1877
- escapeKey: escapeKeyBubbles,
1878
- outsidePress: outsidePressBubbles
1879
- } = normalizeProp(bubbles);
1880
- const {
1881
- escapeKey: escapeKeyCapture,
1882
- outsidePress: outsidePressCapture
1883
- } = normalizeProp(capture);
1884
- const closeOnEscapeKeyDown = useEffectEvent(event => {
1885
- var _dataRef$current$floa;
1886
- if (!open || !enabled || !escapeKey || event.key !== 'Escape') {
1887
- return;
1888
- }
1889
- const nodeId = (_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.nodeId;
1890
- const children = tree ? getChildren(tree.nodesRef.current, nodeId) : [];
1891
- if (!escapeKeyBubbles) {
1892
- event.stopPropagation();
1893
- if (children.length > 0) {
1894
- let shouldDismiss = true;
1895
- children.forEach(child => {
1896
- var _child$context;
1897
- if ((_child$context = child.context) != null && _child$context.open && !child.context.dataRef.current.__escapeKeyBubbles) {
1898
- shouldDismiss = false;
1899
- return;
1900
- }
1901
- });
1902
- if (!shouldDismiss) {
1903
- return;
1904
- }
1905
- }
1906
- }
1907
- onOpenChange(false, floatingUi_react_utils.isReactEvent(event) ? event.nativeEvent : event, 'escape-key');
1908
- });
1909
- const closeOnEscapeKeyDownCapture = useEffectEvent(event => {
1910
- var _getTarget2;
1911
- const callback = () => {
1912
- var _getTarget;
1913
- closeOnEscapeKeyDown(event);
1914
- (_getTarget = floatingUi_react_utils.getTarget(event)) == null || _getTarget.removeEventListener('keydown', callback);
1915
- };
1916
- (_getTarget2 = floatingUi_react_utils.getTarget(event)) == null || _getTarget2.addEventListener('keydown', callback);
1917
- });
1918
- const closeOnPressOutside = useEffectEvent(event => {
1919
- var _dataRef$current$floa2;
1920
- // Given developers can stop the propagation of the synthetic event,
1921
- // we can only be confident with a positive value.
1922
- const insideReactTree = insideReactTreeRef.current;
1923
- insideReactTreeRef.current = false;
1924
-
1925
- // When click outside is lazy (`click` event), handle dragging.
1926
- // Don't close if:
1927
- // - The click started inside the floating element.
1928
- // - The click ended inside the floating element.
1929
- const endedOrStartedInside = endedOrStartedInsideRef.current;
1930
- endedOrStartedInsideRef.current = false;
1931
- if (outsidePressEvent === 'click' && endedOrStartedInside) {
1932
- return;
1933
- }
1934
- if (insideReactTree) {
1935
- return;
1936
- }
1937
- if (typeof outsidePress === 'function' && !outsidePress(event)) {
1938
- return;
1939
- }
1940
- const target = floatingUi_react_utils.getTarget(event);
1941
- const inertSelector = "[" + createAttribute('inert') + "]";
1942
- const markers = floatingUi_react_utils.getDocument(elements.floating).querySelectorAll(inertSelector);
1943
- let targetRootAncestor = floatingUi_utils_dom$1.isElement(target) ? target : null;
1944
- while (targetRootAncestor && !floatingUi_utils_dom$1.isLastTraversableNode(targetRootAncestor)) {
1945
- const nextParent = floatingUi_utils_dom$1.getParentNode(targetRootAncestor);
1946
- if (floatingUi_utils_dom$1.isLastTraversableNode(nextParent) || !floatingUi_utils_dom$1.isElement(nextParent)) {
1947
- break;
1948
- }
1949
- targetRootAncestor = nextParent;
1950
- }
1951
-
1952
- // Check if the click occurred on a third-party element injected after the
1953
- // floating element rendered.
1954
- if (markers.length && floatingUi_utils_dom$1.isElement(target) && !floatingUi_react_utils.isRootElement(target) &&
1955
- // Clicked on a direct ancestor (e.g. FloatingOverlay).
1956
- !floatingUi_react_utils.contains(target, elements.floating) &&
1957
- // If the target root element contains none of the markers, then the
1958
- // element was injected after the floating element rendered.
1959
- Array.from(markers).every(marker => !floatingUi_react_utils.contains(targetRootAncestor, marker))) {
1960
- return;
1961
- }
1962
-
1963
- // Check if the click occurred on the scrollbar
1964
- if (floatingUi_utils_dom$1.isHTMLElement(target) && floating) {
1965
- // In Firefox, `target.scrollWidth > target.clientWidth` for inline
1966
- // elements.
1967
- const canScrollX = target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
1968
- const canScrollY = target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
1969
- let xCond = canScrollY && event.offsetX > target.clientWidth;
1970
-
1971
- // In some browsers it is possible to change the <body> (or window)
1972
- // scrollbar to the left side, but is very rare and is difficult to
1973
- // check for. Plus, for modal dialogs with backdrops, it is more
1974
- // important that the backdrop is checked but not so much the window.
1975
- if (canScrollY) {
1976
- const isRTL = floatingUi_utils_dom$1.getComputedStyle(target).direction === 'rtl';
1977
- if (isRTL) {
1978
- xCond = event.offsetX <= target.offsetWidth - target.clientWidth;
1979
- }
1980
- }
1981
- if (xCond || canScrollX && event.offsetY > target.clientHeight) {
1982
- return;
1983
- }
1984
- }
1985
- const nodeId = (_dataRef$current$floa2 = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa2.nodeId;
1986
- const targetIsInsideChildren = tree && getChildren(tree.nodesRef.current, nodeId).some(node => {
1987
- var _node$context;
1988
- return floatingUi_react_utils.isEventTargetWithin(event, (_node$context = node.context) == null ? void 0 : _node$context.elements.floating);
1989
- });
1990
- if (floatingUi_react_utils.isEventTargetWithin(event, elements.floating) || floatingUi_react_utils.isEventTargetWithin(event, elements.domReference) || targetIsInsideChildren) {
1991
- return;
1992
- }
1993
- const children = tree ? getChildren(tree.nodesRef.current, nodeId) : [];
1994
- if (children.length > 0) {
1995
- let shouldDismiss = true;
1996
- children.forEach(child => {
1997
- var _child$context2;
1998
- if ((_child$context2 = child.context) != null && _child$context2.open && !child.context.dataRef.current.__outsidePressBubbles) {
1999
- shouldDismiss = false;
2000
- return;
2001
- }
2002
- });
2003
- if (!shouldDismiss) {
2004
- return;
2005
- }
2006
- }
2007
- onOpenChange(false, event, 'outside-press');
2008
- });
2009
- const closeOnPressOutsideCapture = useEffectEvent(event => {
2010
- var _getTarget4;
2011
- const callback = () => {
2012
- var _getTarget3;
2013
- closeOnPressOutside(event);
2014
- (_getTarget3 = floatingUi_react_utils.getTarget(event)) == null || _getTarget3.removeEventListener(outsidePressEvent, callback);
2015
- };
2016
- (_getTarget4 = floatingUi_react_utils.getTarget(event)) == null || _getTarget4.addEventListener(outsidePressEvent, callback);
2017
- });
2018
- React__namespace.useEffect(() => {
2019
- if (!open || !enabled) {
2020
- return;
2021
- }
2022
- dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
2023
- dataRef.current.__outsidePressBubbles = outsidePressBubbles;
2024
- function onScroll(event) {
2025
- onOpenChange(false, event, 'ancestor-scroll');
2026
- }
2027
- const doc = floatingUi_react_utils.getDocument(elements.floating);
2028
- escapeKey && doc.addEventListener('keydown', escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
2029
- outsidePress && doc.addEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
2030
- let ancestors = [];
2031
- if (ancestorScroll) {
2032
- if (floatingUi_utils_dom$1.isElement(elements.domReference)) {
2033
- ancestors = floatingUi_utils_dom.getOverflowAncestors(elements.domReference);
2034
- }
2035
- if (floatingUi_utils_dom$1.isElement(elements.floating)) {
2036
- ancestors = ancestors.concat(floatingUi_utils_dom.getOverflowAncestors(elements.floating));
2037
- }
2038
- if (!floatingUi_utils_dom$1.isElement(elements.reference) && elements.reference && elements.reference.contextElement) {
2039
- ancestors = ancestors.concat(floatingUi_utils_dom.getOverflowAncestors(elements.reference.contextElement));
2040
- }
2041
- }
2042
-
2043
- // Ignore the visual viewport for scrolling dismissal (allow pinch-zoom)
2044
- ancestors = ancestors.filter(ancestor => {
2045
- var _doc$defaultView;
2046
- return ancestor !== ((_doc$defaultView = doc.defaultView) == null ? void 0 : _doc$defaultView.visualViewport);
2047
- });
2048
- ancestors.forEach(ancestor => {
2049
- ancestor.addEventListener('scroll', onScroll, {
2050
- passive: true
2051
- });
2052
- });
2053
- return () => {
2054
- escapeKey && doc.removeEventListener('keydown', escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
2055
- outsidePress && doc.removeEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
2056
- ancestors.forEach(ancestor => {
2057
- ancestor.removeEventListener('scroll', onScroll);
2058
- });
2059
- };
2060
- }, [dataRef, elements, escapeKey, outsidePress, outsidePressEvent, open, onOpenChange, ancestorScroll, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, escapeKeyCapture, closeOnEscapeKeyDownCapture, closeOnPressOutside, outsidePressCapture, closeOnPressOutsideCapture]);
2061
- React__namespace.useEffect(() => {
2062
- insideReactTreeRef.current = false;
2063
- }, [outsidePress, outsidePressEvent]);
2064
- const reference = React__namespace.useMemo(() => ({
2065
- onKeyDown: closeOnEscapeKeyDown,
2066
- [bubbleHandlerKeys[referencePressEvent]]: event => {
2067
- if (referencePress) {
2068
- onOpenChange(false, event.nativeEvent, 'reference-press');
2069
- }
2070
- }
2071
- }), [closeOnEscapeKeyDown, onOpenChange, referencePress, referencePressEvent]);
2072
- const floating = React__namespace.useMemo(() => ({
2073
- onKeyDown: closeOnEscapeKeyDown,
2074
- onMouseDown() {
2075
- endedOrStartedInsideRef.current = true;
2076
- },
2077
- onMouseUp() {
2078
- endedOrStartedInsideRef.current = true;
2079
- },
2080
- [captureHandlerKeys[outsidePressEvent]]: () => {
2081
- insideReactTreeRef.current = true;
2082
- }
2083
- }), [closeOnEscapeKeyDown, outsidePressEvent]);
2084
- return React__namespace.useMemo(() => enabled ? {
2085
- reference,
2086
- floating
2087
- } : {}, [enabled, reference, floating]);
2088
- }
2089
-
2090
- function useFloatingRootContext(options) {
2091
- const {
2092
- open = false,
2093
- onOpenChange: onOpenChangeProp,
2094
- elements: elementsProp
2095
- } = options;
2096
- const floatingId = useId();
2097
- const dataRef = React__namespace.useRef({});
2098
- const [events] = React__namespace.useState(() => createPubSub());
2099
- const nested = useFloatingParentNodeId() != null;
2100
- if (process.env.NODE_ENV !== "production") {
2101
- const optionDomReference = elementsProp.reference;
2102
- if (optionDomReference && !floatingUi_utils_dom$1.isElement(optionDomReference)) {
2103
- error('Cannot pass a virtual element to the `elements.reference` option,', 'as it must be a real DOM element. Use `refs.setPositionReference()`', 'instead.');
2104
- }
2105
- }
2106
- const [positionReference, setPositionReference] = React__namespace.useState(elementsProp.reference);
2107
- const onOpenChange = useEffectEvent((open, event, reason) => {
2108
- dataRef.current.openEvent = open ? event : undefined;
2109
- events.emit('openchange', {
2110
- open,
2111
- event,
2112
- reason,
2113
- nested
2114
- });
2115
- onOpenChangeProp == null || onOpenChangeProp(open, event, reason);
2116
- });
2117
- const refs = React__namespace.useMemo(() => ({
2118
- setPositionReference
2119
- }), []);
2120
- const elements = React__namespace.useMemo(() => ({
2121
- reference: positionReference || elementsProp.reference || null,
2122
- floating: elementsProp.floating || null,
2123
- domReference: elementsProp.reference
2124
- }), [positionReference, elementsProp.reference, elementsProp.floating]);
2125
- return React__namespace.useMemo(() => ({
2126
- dataRef,
2127
- open,
2128
- onOpenChange,
2129
- elements,
2130
- events,
2131
- floatingId,
2132
- refs
2133
- }), [open, onOpenChange, elements, events, floatingId, refs]);
2134
- }
2135
-
2136
- /**
2137
- * Provides data to position a floating element and context to add interactions.
2138
- * @see https://floating-ui.com/docs/useFloating
2139
- */
2140
- function useFloating(options) {
2141
- if (options === void 0) {
2142
- options = {};
2143
- }
2144
- const {
2145
- nodeId
2146
- } = options;
2147
- const internalRootContext = useFloatingRootContext({
2148
- ...options,
2149
- elements: {
2150
- reference: null,
2151
- floating: null,
2152
- ...options.elements
2153
- }
2154
- });
2155
- const rootContext = options.rootContext || internalRootContext;
2156
- const computedElements = rootContext.elements;
2157
- const [_domReference, setDomReference] = React__namespace.useState(null);
2158
- const [positionReference, _setPositionReference] = React__namespace.useState(null);
2159
- const optionDomReference = computedElements == null ? void 0 : computedElements.reference;
2160
- const domReference = optionDomReference || _domReference;
2161
- const domReferenceRef = React__namespace.useRef(null);
2162
- const tree = useFloatingTree();
2163
- index(() => {
2164
- if (domReference) {
2165
- domReferenceRef.current = domReference;
2166
- }
2167
- }, [domReference]);
2168
- const position = floatingUi_reactDom.useFloating({
2169
- ...options,
2170
- elements: {
2171
- ...computedElements,
2172
- ...(positionReference && {
2173
- reference: positionReference
2174
- })
2175
- }
2176
- });
2177
- const setPositionReference = React__namespace.useCallback(node => {
2178
- const computedPositionReference = floatingUi_utils_dom$1.isElement(node) ? {
2179
- getBoundingClientRect: () => node.getBoundingClientRect(),
2180
- contextElement: node
2181
- } : node;
2182
- // Store the positionReference in state if the DOM reference is specified externally via the
2183
- // `elements.reference` option. This ensures that it won't be overridden on future renders.
2184
- _setPositionReference(computedPositionReference);
2185
- position.refs.setReference(computedPositionReference);
2186
- }, [position.refs]);
2187
- const setReference = React__namespace.useCallback(node => {
2188
- if (floatingUi_utils_dom$1.isElement(node) || node === null) {
2189
- domReferenceRef.current = node;
2190
- setDomReference(node);
2191
- }
2192
-
2193
- // Backwards-compatibility for passing a virtual element to `reference`
2194
- // after it has set the DOM reference.
2195
- if (floatingUi_utils_dom$1.isElement(position.refs.reference.current) || position.refs.reference.current === null ||
2196
- // Don't allow setting virtual elements using the old technique back to
2197
- // `null` to support `positionReference` + an unstable `reference`
2198
- // callback ref.
2199
- node !== null && !floatingUi_utils_dom$1.isElement(node)) {
2200
- position.refs.setReference(node);
2201
- }
2202
- }, [position.refs]);
2203
- const refs = React__namespace.useMemo(() => ({
2204
- ...position.refs,
2205
- setReference,
2206
- setPositionReference,
2207
- domReference: domReferenceRef
2208
- }), [position.refs, setReference, setPositionReference]);
2209
- const elements = React__namespace.useMemo(() => ({
2210
- ...position.elements,
2211
- domReference: domReference
2212
- }), [position.elements, domReference]);
2213
- const context = React__namespace.useMemo(() => ({
2214
- ...position,
2215
- ...rootContext,
2216
- refs,
2217
- elements,
2218
- nodeId
2219
- }), [position, refs, elements, nodeId, rootContext]);
2220
- index(() => {
2221
- rootContext.dataRef.current.floatingContext = context;
2222
- const node = tree == null ? void 0 : tree.nodesRef.current.find(node => node.id === nodeId);
2223
- if (node) {
2224
- node.context = context;
2225
- }
2226
- });
2227
- return React__namespace.useMemo(() => ({
2228
- ...position,
2229
- context,
2230
- refs,
2231
- elements
2232
- }), [position, refs, elements, context]);
2233
- }
2234
-
2235
- /**
2236
- * Opens the floating element while the reference element has focus, like CSS
2237
- * `:focus`.
2238
- * @see https://floating-ui.com/docs/useFocus
2239
- */
2240
- function useFocus(context, props) {
2241
- if (props === void 0) {
2242
- props = {};
2243
- }
2244
- const {
2245
- open,
2246
- onOpenChange,
2247
- events,
2248
- dataRef,
2249
- elements
2250
- } = context;
2251
- const {
2252
- enabled = true,
2253
- visibleOnly = true
2254
- } = props;
2255
- const blockFocusRef = React__namespace.useRef(false);
2256
- const timeoutRef = React__namespace.useRef();
2257
- const keyboardModalityRef = React__namespace.useRef(true);
2258
- React__namespace.useEffect(() => {
2259
- if (!enabled) return;
2260
- const win = floatingUi_utils_dom$1.getWindow(elements.domReference);
2261
-
2262
- // If the reference was focused and the user left the tab/window, and the
2263
- // floating element was not open, the focus should be blocked when they
2264
- // return to the tab/window.
2265
- function onBlur() {
2266
- if (!open && floatingUi_utils_dom$1.isHTMLElement(elements.domReference) && elements.domReference === floatingUi_react_utils.activeElement(floatingUi_react_utils.getDocument(elements.domReference))) {
2267
- blockFocusRef.current = true;
2268
- }
2269
- }
2270
- function onKeyDown() {
2271
- keyboardModalityRef.current = true;
2272
- }
2273
- win.addEventListener('blur', onBlur);
2274
- win.addEventListener('keydown', onKeyDown, true);
2275
- return () => {
2276
- win.removeEventListener('blur', onBlur);
2277
- win.removeEventListener('keydown', onKeyDown, true);
2278
- };
2279
- }, [elements.domReference, open, enabled]);
2280
- React__namespace.useEffect(() => {
2281
- if (!enabled) return;
2282
- function onOpenChange(_ref) {
2283
- let {
2284
- reason
2285
- } = _ref;
2286
- if (reason === 'reference-press' || reason === 'escape-key') {
2287
- blockFocusRef.current = true;
2288
- }
2289
- }
2290
- events.on('openchange', onOpenChange);
2291
- return () => {
2292
- events.off('openchange', onOpenChange);
2293
- };
2294
- }, [events, enabled]);
2295
- React__namespace.useEffect(() => {
2296
- return () => {
2297
- clearTimeout(timeoutRef.current);
2298
- };
2299
- }, []);
2300
- const reference = React__namespace.useMemo(() => ({
2301
- onPointerDown(event) {
2302
- if (floatingUi_react_utils.isVirtualPointerEvent(event.nativeEvent)) return;
2303
- keyboardModalityRef.current = false;
2304
- },
2305
- onMouseLeave() {
2306
- blockFocusRef.current = false;
2307
- },
2308
- onFocus(event) {
2309
- if (blockFocusRef.current) return;
2310
- const target = floatingUi_react_utils.getTarget(event.nativeEvent);
2311
- if (visibleOnly && floatingUi_utils_dom$1.isElement(target)) {
2312
- try {
2313
- // Mac Safari unreliably matches `:focus-visible` on the reference
2314
- // if focus was outside the page initially - use the fallback
2315
- // instead.
2316
- if (floatingUi_react_utils.isSafari() && floatingUi_react_utils.isMac()) throw Error();
2317
- if (!target.matches(':focus-visible')) return;
2318
- } catch (e) {
2319
- // Old browsers will throw an error when using `:focus-visible`.
2320
- if (!keyboardModalityRef.current && !floatingUi_react_utils.isTypeableElement(target)) {
2321
- return;
2322
- }
2323
- }
2324
- }
2325
- onOpenChange(true, event.nativeEvent, 'focus');
2326
- },
2327
- onBlur(event) {
2328
- blockFocusRef.current = false;
2329
- const relatedTarget = event.relatedTarget;
2330
- const nativeEvent = event.nativeEvent;
2331
-
2332
- // Hit the non-modal focus management portal guard. Focus will be
2333
- // moved into the floating element immediately after.
2334
- const movedToFocusGuard = floatingUi_utils_dom$1.isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute('focus-guard')) && relatedTarget.getAttribute('data-type') === 'outside';
2335
-
2336
- // Wait for the window blur listener to fire.
2337
- timeoutRef.current = window.setTimeout(() => {
2338
- var _dataRef$current$floa;
2339
- const activeEl = floatingUi_react_utils.activeElement(elements.domReference ? elements.domReference.ownerDocument : document);
2340
-
2341
- // Focus left the page, keep it open.
2342
- if (!relatedTarget && activeEl === elements.domReference) return;
2343
-
2344
- // When focusing the reference element (e.g. regular click), then
2345
- // clicking into the floating element, prevent it from hiding.
2346
- // Note: it must be focusable, e.g. `tabindex="-1"`.
2347
- // We can not rely on relatedTarget to point to the correct element
2348
- // as it will only point to the shadow host of the newly focused element
2349
- // and not the element that actually has received focus if it is located
2350
- // inside a shadow root.
2351
- if (floatingUi_react_utils.contains((_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.refs.floating.current, activeEl) || floatingUi_react_utils.contains(elements.domReference, activeEl) || movedToFocusGuard) {
2352
- return;
2353
- }
2354
- onOpenChange(false, nativeEvent, 'focus');
2355
- });
2356
- }
2357
- }), [dataRef, elements.domReference, onOpenChange, visibleOnly]);
2358
- return React__namespace.useMemo(() => enabled ? {
2359
- reference
2360
- } : {}, [enabled, reference]);
2361
- }
2362
-
2363
- const ACTIVE_KEY = 'active';
2364
- const SELECTED_KEY = 'selected';
2365
- function mergeProps(userProps, propsList, elementKey) {
2366
- const map = new Map();
2367
- const isItem = elementKey === 'item';
2368
- let domUserProps = userProps;
2369
- if (isItem && userProps) {
2370
- const {
2371
- [ACTIVE_KEY]: _,
2372
- [SELECTED_KEY]: __,
2373
- ...validProps
2374
- } = userProps;
2375
- domUserProps = validProps;
2376
- }
2377
- return {
2378
- ...(elementKey === 'floating' && {
2379
- tabIndex: -1
2380
- }),
2381
- ...domUserProps,
2382
- ...propsList.map(value => {
2383
- const propsOrGetProps = value ? value[elementKey] : null;
2384
- if (typeof propsOrGetProps === 'function') {
2385
- return userProps ? propsOrGetProps(userProps) : null;
2386
- }
2387
- return propsOrGetProps;
2388
- }).concat(userProps).reduce((acc, props) => {
2389
- if (!props) {
2390
- return acc;
2391
- }
2392
- Object.entries(props).forEach(_ref => {
2393
- let [key, value] = _ref;
2394
- if (isItem && [ACTIVE_KEY, SELECTED_KEY].includes(key)) {
2395
- return;
2396
- }
2397
- if (key.indexOf('on') === 0) {
2398
- if (!map.has(key)) {
2399
- map.set(key, []);
2400
- }
2401
- if (typeof value === 'function') {
2402
- var _map$get;
2403
- (_map$get = map.get(key)) == null || _map$get.push(value);
2404
- acc[key] = function () {
2405
- var _map$get2;
2406
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2407
- args[_key] = arguments[_key];
2408
- }
2409
- return (_map$get2 = map.get(key)) == null ? void 0 : _map$get2.map(fn => fn(...args)).find(val => val !== undefined);
2410
- };
2411
- }
2412
- } else {
2413
- acc[key] = value;
2414
- }
2415
- });
2416
- return acc;
2417
- }, {})
2418
- };
2419
- }
2420
- /**
2421
- * Merges an array of interaction hooks' props into prop getters, allowing
2422
- * event handler functions to be composed together without overwriting one
2423
- * another.
2424
- * @see https://floating-ui.com/docs/useInteractions
2425
- */
2426
- function useInteractions(propsList) {
2427
- if (propsList === void 0) {
2428
- propsList = [];
2429
- }
2430
- const referenceDeps = propsList.map(key => key == null ? void 0 : key.reference);
2431
- const floatingDeps = propsList.map(key => key == null ? void 0 : key.floating);
2432
- const itemDeps = propsList.map(key => key == null ? void 0 : key.item);
2433
- const getReferenceProps = React__namespace.useCallback(userProps => mergeProps(userProps, propsList, 'reference'),
2434
- // eslint-disable-next-line react-hooks/exhaustive-deps
2435
- referenceDeps);
2436
- const getFloatingProps = React__namespace.useCallback(userProps => mergeProps(userProps, propsList, 'floating'),
2437
- // eslint-disable-next-line react-hooks/exhaustive-deps
2438
- floatingDeps);
2439
- const getItemProps = React__namespace.useCallback(userProps => mergeProps(userProps, propsList, 'item'),
2440
- // eslint-disable-next-line react-hooks/exhaustive-deps
2441
- itemDeps);
2442
- return React__namespace.useMemo(() => ({
2443
- getReferenceProps,
2444
- getFloatingProps,
2445
- getItemProps
2446
- }), [getReferenceProps, getFloatingProps, getItemProps]);
2447
- }
2448
-
2449
- let isPreventScrollSupported = false;
2450
- function doSwitch(orientation, vertical, horizontal) {
2451
- switch (orientation) {
2452
- case 'vertical':
2453
- return vertical;
2454
- case 'horizontal':
2455
- return horizontal;
2456
- default:
2457
- return vertical || horizontal;
2458
- }
2459
- }
2460
- function isMainOrientationKey(key, orientation) {
2461
- const vertical = key === ARROW_UP || key === ARROW_DOWN;
2462
- const horizontal = key === ARROW_LEFT || key === ARROW_RIGHT;
2463
- return doSwitch(orientation, vertical, horizontal);
2464
- }
2465
- function isMainOrientationToEndKey(key, orientation, rtl) {
2466
- const vertical = key === ARROW_DOWN;
2467
- const horizontal = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;
2468
- return doSwitch(orientation, vertical, horizontal) || key === 'Enter' || key === ' ' || key === '';
2469
- }
2470
- function isCrossOrientationOpenKey(key, orientation, rtl) {
2471
- const vertical = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;
2472
- const horizontal = key === ARROW_DOWN;
2473
- return doSwitch(orientation, vertical, horizontal);
2474
- }
2475
- function isCrossOrientationCloseKey(key, orientation, rtl) {
2476
- const vertical = rtl ? key === ARROW_RIGHT : key === ARROW_LEFT;
2477
- const horizontal = key === ARROW_UP;
2478
- return doSwitch(orientation, vertical, horizontal);
2479
- }
2480
- /**
2481
- * Adds arrow key-based navigation of a list of items, either using real DOM
2482
- * focus or virtual focus.
2483
- * @see https://floating-ui.com/docs/useListNavigation
2484
- */
2485
- function useListNavigation(context, props) {
2486
- const {
2487
- open,
2488
- onOpenChange,
2489
- elements
2490
- } = context;
2491
- const {
2492
- listRef,
2493
- activeIndex,
2494
- onNavigate: unstable_onNavigate = () => {},
2495
- enabled = true,
2496
- selectedIndex = null,
2497
- allowEscape = false,
2498
- loop = false,
2499
- nested = false,
2500
- rtl = false,
2501
- virtual = false,
2502
- focusItemOnOpen = 'auto',
2503
- focusItemOnHover = true,
2504
- openOnArrowKeyDown = true,
2505
- disabledIndices = undefined,
2506
- orientation = 'vertical',
2507
- cols = 1,
2508
- scrollItemIntoView = true,
2509
- virtualItemRef,
2510
- itemSizes,
2511
- dense = false
2512
- } = props;
2513
- if (process.env.NODE_ENV !== "production") {
2514
- if (allowEscape) {
2515
- if (!loop) {
2516
- warn('`useListNavigation` looping must be enabled to allow escaping.');
2517
- }
2518
- if (!virtual) {
2519
- warn('`useListNavigation` must be virtual to allow escaping.');
2520
- }
2521
- }
2522
- if (orientation === 'vertical' && cols > 1) {
2523
- warn('In grid list navigation mode (`cols` > 1), the `orientation` should', 'be either "horizontal" or "both".');
2524
- }
2525
- }
2526
- const parentId = useFloatingParentNodeId();
2527
- const tree = useFloatingTree();
2528
- const onNavigate = useEffectEvent(unstable_onNavigate);
2529
- const focusItemOnOpenRef = React__namespace.useRef(focusItemOnOpen);
2530
- const indexRef = React__namespace.useRef(selectedIndex != null ? selectedIndex : -1);
2531
- const keyRef = React__namespace.useRef(null);
2532
- const isPointerModalityRef = React__namespace.useRef(true);
2533
- const previousOnNavigateRef = React__namespace.useRef(onNavigate);
2534
- const previousMountedRef = React__namespace.useRef(!!elements.floating);
2535
- const previousOpenRef = React__namespace.useRef(open);
2536
- const forceSyncFocus = React__namespace.useRef(false);
2537
- const forceScrollIntoViewRef = React__namespace.useRef(false);
2538
- const disabledIndicesRef = useLatestRef(disabledIndices);
2539
- const latestOpenRef = useLatestRef(open);
2540
- const scrollItemIntoViewRef = useLatestRef(scrollItemIntoView);
2541
- const floatingRef = useLatestRef(elements.floating);
2542
- const selectedIndexRef = useLatestRef(selectedIndex);
2543
- const [activeId, setActiveId] = React__namespace.useState();
2544
- const [virtualId, setVirtualId] = React__namespace.useState();
2545
- const focusItem = useEffectEvent(function (listRef, indexRef, forceScrollIntoView) {
2546
- if (forceScrollIntoView === void 0) {
2547
- forceScrollIntoView = false;
2548
- }
2549
- function runFocus(item) {
2550
- if (virtual) {
2551
- setActiveId(item.id);
2552
- tree == null || tree.events.emit('virtualfocus', item);
2553
- if (virtualItemRef) {
2554
- virtualItemRef.current = item;
2555
- }
2556
- } else {
2557
- enqueueFocus(item, {
2558
- preventScroll: true,
2559
- // Mac Safari does not move the virtual cursor unless the focus call
2560
- // is sync. However, for the very first focus call, we need to wait
2561
- // for the position to be ready in order to prevent unwanted
2562
- // scrolling. This means the virtual cursor will not move to the first
2563
- // item when first opening the floating element, but will on
2564
- // subsequent calls. `preventScroll` is supported in modern Safari,
2565
- // so we can use that instead.
2566
- // iOS Safari must be async or the first item will not be focused.
2567
- sync: floatingUi_react_utils.isMac() && floatingUi_react_utils.isSafari() ? isPreventScrollSupported || forceSyncFocus.current : false
2568
- });
2569
- }
2570
- }
2571
- const initialItem = listRef.current[indexRef.current];
2572
- if (initialItem) {
2573
- runFocus(initialItem);
2574
- }
2575
- requestAnimationFrame(() => {
2576
- const waitedItem = listRef.current[indexRef.current] || initialItem;
2577
- if (!waitedItem) return;
2578
- if (!initialItem) {
2579
- runFocus(waitedItem);
2580
- }
2581
- const scrollIntoViewOptions = scrollItemIntoViewRef.current;
2582
- const shouldScrollIntoView = scrollIntoViewOptions && item && (forceScrollIntoView || !isPointerModalityRef.current);
2583
- if (shouldScrollIntoView) {
2584
- // JSDOM doesn't support `.scrollIntoView()` but it's widely supported
2585
- // by all browsers.
2586
- waitedItem.scrollIntoView == null || waitedItem.scrollIntoView(typeof scrollIntoViewOptions === 'boolean' ? {
2587
- block: 'nearest',
2588
- inline: 'nearest'
2589
- } : scrollIntoViewOptions);
2590
- }
2591
- });
2592
- });
2593
- index(() => {
2594
- document.createElement('div').focus({
2595
- get preventScroll() {
2596
- isPreventScrollSupported = true;
2597
- return false;
2598
- }
2599
- });
2600
- }, []);
2601
-
2602
- // Sync `selectedIndex` to be the `activeIndex` upon opening the floating
2603
- // element. Also, reset `activeIndex` upon closing the floating element.
2604
- index(() => {
2605
- if (!enabled) return;
2606
- if (open && elements.floating) {
2607
- if (focusItemOnOpenRef.current && selectedIndex != null) {
2608
- // Regardless of the pointer modality, we want to ensure the selected
2609
- // item comes into view when the floating element is opened.
2610
- forceScrollIntoViewRef.current = true;
2611
- indexRef.current = selectedIndex;
2612
- onNavigate(selectedIndex);
2613
- }
2614
- } else if (previousMountedRef.current) {
2615
- // Since the user can specify `onNavigate` conditionally
2616
- // (onNavigate: open ? setActiveIndex : setSelectedIndex),
2617
- // we store and call the previous function.
2618
- indexRef.current = -1;
2619
- previousOnNavigateRef.current(null);
2620
- }
2621
- }, [enabled, open, elements.floating, selectedIndex, onNavigate]);
2622
-
2623
- // Sync `activeIndex` to be the focused item while the floating element is
2624
- // open.
2625
- index(() => {
2626
- if (!enabled) return;
2627
- if (open && elements.floating) {
2628
- if (activeIndex == null) {
2629
- forceSyncFocus.current = false;
2630
- if (selectedIndexRef.current != null) {
2631
- return;
2632
- }
2633
-
2634
- // Reset while the floating element was open (e.g. the list changed).
2635
- if (previousMountedRef.current) {
2636
- indexRef.current = -1;
2637
- focusItem(listRef, indexRef);
2638
- }
2639
-
2640
- // Initial sync.
2641
- if ((!previousOpenRef.current || !previousMountedRef.current) && focusItemOnOpenRef.current && (keyRef.current != null || focusItemOnOpenRef.current === true && keyRef.current == null)) {
2642
- let runs = 0;
2643
- const waitForListPopulated = () => {
2644
- if (listRef.current[0] == null) {
2645
- // Avoid letting the browser paint if possible on the first try,
2646
- // otherwise use rAF. Don't try more than twice, since something
2647
- // is wrong otherwise.
2648
- if (runs < 2) {
2649
- const scheduler = runs ? requestAnimationFrame : queueMicrotask;
2650
- scheduler(waitForListPopulated);
2651
- }
2652
- runs++;
2653
- } else {
2654
- indexRef.current = keyRef.current == null || isMainOrientationToEndKey(keyRef.current, orientation, rtl) || nested ? getMinIndex(listRef, disabledIndicesRef.current) : getMaxIndex(listRef, disabledIndicesRef.current);
2655
- keyRef.current = null;
2656
- onNavigate(indexRef.current);
2657
- }
2658
- };
2659
- waitForListPopulated();
2660
- }
2661
- } else if (!isIndexOutOfBounds(listRef, activeIndex)) {
2662
- indexRef.current = activeIndex;
2663
- focusItem(listRef, indexRef, forceScrollIntoViewRef.current);
2664
- forceScrollIntoViewRef.current = false;
2665
- }
2666
- }
2667
- }, [enabled, open, elements.floating, activeIndex, selectedIndexRef, nested, listRef, orientation, rtl, onNavigate, focusItem, disabledIndicesRef]);
2668
-
2669
- // Ensure the parent floating element has focus when a nested child closes
2670
- // to allow arrow key navigation to work after the pointer leaves the child.
2671
- index(() => {
2672
- var _nodes$find;
2673
- if (!enabled || elements.floating || !tree || virtual || !previousMountedRef.current) {
2674
- return;
2675
- }
2676
- const nodes = tree.nodesRef.current;
2677
- const parent = (_nodes$find = nodes.find(node => node.id === parentId)) == null || (_nodes$find = _nodes$find.context) == null ? void 0 : _nodes$find.elements.floating;
2678
- const activeEl = floatingUi_react_utils.activeElement(floatingUi_react_utils.getDocument(elements.floating));
2679
- const treeContainsActiveEl = nodes.some(node => node.context && floatingUi_react_utils.contains(node.context.elements.floating, activeEl));
2680
- if (parent && !treeContainsActiveEl && isPointerModalityRef.current) {
2681
- parent.focus({
2682
- preventScroll: true
2683
- });
2684
- }
2685
- }, [enabled, elements.floating, tree, parentId, virtual]);
2686
- index(() => {
2687
- if (!enabled) return;
2688
- if (!tree) return;
2689
- if (!virtual) return;
2690
- if (parentId) return;
2691
- function handleVirtualFocus(item) {
2692
- setVirtualId(item.id);
2693
- if (virtualItemRef) {
2694
- virtualItemRef.current = item;
2695
- }
2696
- }
2697
- tree.events.on('virtualfocus', handleVirtualFocus);
2698
- return () => {
2699
- tree.events.off('virtualfocus', handleVirtualFocus);
2700
- };
2701
- }, [enabled, tree, virtual, parentId, virtualItemRef]);
2702
- index(() => {
2703
- previousOnNavigateRef.current = onNavigate;
2704
- previousMountedRef.current = !!elements.floating;
2705
- });
2706
- index(() => {
2707
- if (!open) {
2708
- keyRef.current = null;
2709
- }
2710
- }, [open]);
2711
- index(() => {
2712
- previousOpenRef.current = open;
2713
- }, [open]);
2714
- const hasActiveIndex = activeIndex != null;
2715
- const item = React__namespace.useMemo(() => {
2716
- function syncCurrentTarget(currentTarget) {
2717
- if (!open) return;
2718
- const index = listRef.current.indexOf(currentTarget);
2719
- if (index !== -1) {
2720
- onNavigate(index);
2721
- }
2722
- }
2723
- const props = {
2724
- onFocus(_ref) {
2725
- let {
2726
- currentTarget
2727
- } = _ref;
2728
- syncCurrentTarget(currentTarget);
2729
- },
2730
- onClick: _ref2 => {
2731
- let {
2732
- currentTarget
2733
- } = _ref2;
2734
- return currentTarget.focus({
2735
- preventScroll: true
2736
- });
2737
- },
2738
- // Safari
2739
- ...(focusItemOnHover && {
2740
- onMouseMove(_ref3) {
2741
- let {
2742
- currentTarget
2743
- } = _ref3;
2744
- syncCurrentTarget(currentTarget);
2745
- },
2746
- onPointerLeave(_ref4) {
2747
- let {
2748
- pointerType
2749
- } = _ref4;
2750
- if (!isPointerModalityRef.current || pointerType === 'touch') {
2751
- return;
2752
- }
2753
- indexRef.current = -1;
2754
- focusItem(listRef, indexRef);
2755
- onNavigate(null);
2756
- if (!virtual) {
2757
- enqueueFocus(floatingRef.current, {
2758
- preventScroll: true
2759
- });
2760
- }
2761
- }
2762
- })
2763
- };
2764
- return props;
2765
- }, [open, floatingRef, focusItem, focusItemOnHover, listRef, onNavigate, virtual]);
2766
- const commonOnKeyDown = useEffectEvent(event => {
2767
- isPointerModalityRef.current = false;
2768
- forceSyncFocus.current = true;
2769
-
2770
- // If the floating element is animating out, ignore navigation. Otherwise,
2771
- // the `activeIndex` gets set to 0 despite not being open so the next time
2772
- // the user ArrowDowns, the first item won't be focused.
2773
- if (!latestOpenRef.current && event.currentTarget === floatingRef.current) {
2774
- return;
2775
- }
2776
- if (nested && isCrossOrientationCloseKey(event.key, orientation, rtl)) {
2777
- floatingUi_react_utils.stopEvent(event);
2778
- onOpenChange(false, event.nativeEvent, 'list-navigation');
2779
- if (floatingUi_utils_dom$1.isHTMLElement(elements.domReference) && !virtual) {
2780
- elements.domReference.focus();
2781
- }
2782
- return;
2783
- }
2784
- const currentIndex = indexRef.current;
2785
- const minIndex = getMinIndex(listRef, disabledIndices);
2786
- const maxIndex = getMaxIndex(listRef, disabledIndices);
2787
- if (event.key === 'Home') {
2788
- floatingUi_react_utils.stopEvent(event);
2789
- indexRef.current = minIndex;
2790
- onNavigate(indexRef.current);
2791
- }
2792
- if (event.key === 'End') {
2793
- floatingUi_react_utils.stopEvent(event);
2794
- indexRef.current = maxIndex;
2795
- onNavigate(indexRef.current);
2796
- }
2797
-
2798
- // Grid navigation.
2799
- if (cols > 1) {
2800
- const sizes = itemSizes || Array.from({
2801
- length: listRef.current.length
2802
- }, () => ({
2803
- width: 1,
2804
- height: 1
2805
- }));
2806
- // To calculate movements on the grid, we use hypothetical cell indices
2807
- // as if every item was 1x1, then convert back to real indices.
2808
- const cellMap = buildCellMap(sizes, cols, dense);
2809
- const minGridIndex = cellMap.findIndex(index => index != null && !isDisabled(listRef.current, index, disabledIndices));
2810
- // last enabled index
2811
- const maxGridIndex = cellMap.reduce((foundIndex, index, cellIndex) => index != null && !isDisabled(listRef.current, index, disabledIndices) ? cellIndex : foundIndex, -1);
2812
- indexRef.current = cellMap[getGridNavigatedIndex({
2813
- current: cellMap.map(itemIndex => itemIndex != null ? listRef.current[itemIndex] : null)
2814
- }, {
2815
- event,
2816
- orientation,
2817
- loop,
2818
- cols,
2819
- // treat undefined (empty grid spaces) as disabled indices so we
2820
- // don't end up in them
2821
- disabledIndices: getCellIndices([...(disabledIndices || listRef.current.map((_, index) => isDisabled(listRef.current, index) ? index : undefined)), undefined], cellMap),
2822
- minIndex: minGridIndex,
2823
- maxIndex: maxGridIndex,
2824
- prevIndex: getCellIndexOfCorner(indexRef.current > maxIndex ? minIndex : indexRef.current, sizes, cellMap, cols,
2825
- // use a corner matching the edge closest to the direction
2826
- // we're moving in so we don't end up in the same item. Prefer
2827
- // top/left over bottom/right.
2828
- event.key === ARROW_DOWN ? 'bl' : event.key === ARROW_RIGHT ? 'tr' : 'tl'),
2829
- stopEvent: true
2830
- })]; // navigated cell will never be nullish
2831
-
2832
- onNavigate(indexRef.current);
2833
- if (orientation === 'both') {
2834
- return;
2835
- }
2836
- }
2837
- if (isMainOrientationKey(event.key, orientation)) {
2838
- floatingUi_react_utils.stopEvent(event);
2839
-
2840
- // Reset the index if no item is focused.
2841
- if (open && !virtual && floatingUi_react_utils.activeElement(event.currentTarget.ownerDocument) === event.currentTarget) {
2842
- indexRef.current = isMainOrientationToEndKey(event.key, orientation, rtl) ? minIndex : maxIndex;
2843
- onNavigate(indexRef.current);
2844
- return;
2845
- }
2846
- if (isMainOrientationToEndKey(event.key, orientation, rtl)) {
2847
- if (loop) {
2848
- indexRef.current = currentIndex >= maxIndex ? allowEscape && currentIndex !== listRef.current.length ? -1 : minIndex : findNonDisabledIndex(listRef, {
2849
- startingIndex: currentIndex,
2850
- disabledIndices
2851
- });
2852
- } else {
2853
- indexRef.current = Math.min(maxIndex, findNonDisabledIndex(listRef, {
2854
- startingIndex: currentIndex,
2855
- disabledIndices
2856
- }));
2857
- }
2858
- } else {
2859
- if (loop) {
2860
- indexRef.current = currentIndex <= minIndex ? allowEscape && currentIndex !== -1 ? listRef.current.length : maxIndex : findNonDisabledIndex(listRef, {
2861
- startingIndex: currentIndex,
2862
- decrement: true,
2863
- disabledIndices
2864
- });
2865
- } else {
2866
- indexRef.current = Math.max(minIndex, findNonDisabledIndex(listRef, {
2867
- startingIndex: currentIndex,
2868
- decrement: true,
2869
- disabledIndices
2870
- }));
2871
- }
2872
- }
2873
- if (isIndexOutOfBounds(listRef, indexRef.current)) {
2874
- onNavigate(null);
2875
- } else {
2876
- onNavigate(indexRef.current);
2877
- }
2878
- }
2879
- });
2880
- const ariaActiveDescendantProp = React__namespace.useMemo(() => {
2881
- return virtual && open && hasActiveIndex && {
2882
- 'aria-activedescendant': virtualId || activeId
2883
- };
2884
- }, [virtual, open, hasActiveIndex, virtualId, activeId]);
2885
- const floating = React__namespace.useMemo(() => {
2886
- return {
2887
- 'aria-orientation': orientation === 'both' ? undefined : orientation,
2888
- ...(!floatingUi_react_utils.isTypeableCombobox(elements.domReference) && ariaActiveDescendantProp),
2889
- onKeyDown: commonOnKeyDown,
2890
- onPointerMove() {
2891
- isPointerModalityRef.current = true;
2892
- }
2893
- };
2894
- }, [ariaActiveDescendantProp, commonOnKeyDown, elements.domReference, orientation]);
2895
- const reference = React__namespace.useMemo(() => {
2896
- function checkVirtualMouse(event) {
2897
- if (focusItemOnOpen === 'auto' && floatingUi_react_utils.isVirtualClick(event.nativeEvent)) {
2898
- focusItemOnOpenRef.current = true;
2899
- }
2900
- }
2901
- function checkVirtualPointer(event) {
2902
- // `pointerdown` fires first, reset the state then perform the checks.
2903
- focusItemOnOpenRef.current = focusItemOnOpen;
2904
- if (focusItemOnOpen === 'auto' && floatingUi_react_utils.isVirtualPointerEvent(event.nativeEvent)) {
2905
- focusItemOnOpenRef.current = true;
2906
- }
2907
- }
2908
- return {
2909
- ...ariaActiveDescendantProp,
2910
- onKeyDown(event) {
2911
- isPointerModalityRef.current = false;
2912
- const isArrowKey = event.key.indexOf('Arrow') === 0;
2913
- const isCrossOpenKey = isCrossOrientationOpenKey(event.key, orientation, rtl);
2914
- const isCrossCloseKey = isCrossOrientationCloseKey(event.key, orientation, rtl);
2915
- const isMainKey = isMainOrientationKey(event.key, orientation);
2916
- const isNavigationKey = (nested ? isCrossOpenKey : isMainKey) || event.key === 'Enter' || event.key.trim() === '';
2917
- if (virtual && open) {
2918
- const rootNode = tree == null ? void 0 : tree.nodesRef.current.find(node => node.parentId == null);
2919
- const deepestNode = tree && rootNode ? getDeepestNode(tree.nodesRef.current, rootNode.id) : null;
2920
- if (isArrowKey && deepestNode && virtualItemRef) {
2921
- const eventObject = new KeyboardEvent('keydown', {
2922
- key: event.key,
2923
- bubbles: true
2924
- });
2925
- if (isCrossOpenKey || isCrossCloseKey) {
2926
- var _deepestNode$context, _deepestNode$context2;
2927
- const isCurrentTarget = ((_deepestNode$context = deepestNode.context) == null ? void 0 : _deepestNode$context.elements.domReference) === event.currentTarget;
2928
- const dispatchItem = isCrossCloseKey && !isCurrentTarget ? (_deepestNode$context2 = deepestNode.context) == null ? void 0 : _deepestNode$context2.elements.domReference : isCrossOpenKey ? listRef.current.find(item => (item == null ? void 0 : item.id) === activeId) : null;
2929
- if (dispatchItem) {
2930
- floatingUi_react_utils.stopEvent(event);
2931
- dispatchItem.dispatchEvent(eventObject);
2932
- setVirtualId(undefined);
2933
- }
2934
- }
2935
- if (isMainKey && deepestNode.context) {
2936
- if (deepestNode.context.open && deepestNode.parentId && event.currentTarget !== deepestNode.context.elements.domReference) {
2937
- var _deepestNode$context$;
2938
- floatingUi_react_utils.stopEvent(event);
2939
- (_deepestNode$context$ = deepestNode.context.elements.domReference) == null || _deepestNode$context$.dispatchEvent(eventObject);
2940
- return;
2941
- }
2942
- }
2943
- }
2944
- return commonOnKeyDown(event);
2945
- }
2946
-
2947
- // If a floating element should not open on arrow key down, avoid
2948
- // setting `activeIndex` while it's closed.
2949
- if (!open && !openOnArrowKeyDown && isArrowKey) {
2950
- return;
2951
- }
2952
- if (isNavigationKey) {
2953
- keyRef.current = nested && isMainKey ? null : event.key;
2954
- }
2955
- if (nested) {
2956
- if (isCrossOpenKey) {
2957
- floatingUi_react_utils.stopEvent(event);
2958
- if (open) {
2959
- indexRef.current = getMinIndex(listRef, disabledIndicesRef.current);
2960
- onNavigate(indexRef.current);
2961
- } else {
2962
- onOpenChange(true, event.nativeEvent, 'list-navigation');
2963
- }
2964
- }
2965
- return;
2966
- }
2967
- if (isMainKey) {
2968
- if (selectedIndex != null) {
2969
- indexRef.current = selectedIndex;
2970
- }
2971
- floatingUi_react_utils.stopEvent(event);
2972
- if (!open && openOnArrowKeyDown) {
2973
- onOpenChange(true, event.nativeEvent, 'list-navigation');
2974
- } else {
2975
- commonOnKeyDown(event);
2976
- }
2977
- if (open) {
2978
- onNavigate(indexRef.current);
2979
- }
2980
- }
2981
- },
2982
- onFocus() {
2983
- if (open && !virtual) {
2984
- onNavigate(null);
2985
- }
2986
- },
2987
- onPointerDown: checkVirtualPointer,
2988
- onMouseDown: checkVirtualMouse,
2989
- onClick: checkVirtualMouse
2990
- };
2991
- }, [activeId, ariaActiveDescendantProp, commonOnKeyDown, disabledIndicesRef, focusItemOnOpen, listRef, nested, onNavigate, onOpenChange, open, openOnArrowKeyDown, orientation, rtl, selectedIndex, tree, virtual, virtualItemRef]);
2992
- return React__namespace.useMemo(() => enabled ? {
2993
- reference,
2994
- floating,
2995
- item
2996
- } : {}, [enabled, reference, floating, item]);
2997
- }
2998
-
2999
- const componentRoleToAriaRoleMap = /*#__PURE__*/new Map([['select', 'listbox'], ['combobox', 'listbox'], ['label', false]]);
3000
-
3001
- /**
3002
- * Adds base screen reader props to the reference and floating elements for a
3003
- * given floating element `role`.
3004
- * @see https://floating-ui.com/docs/useRole
3005
- */
3006
- function useRole(context, props) {
3007
- var _componentRoleToAriaR;
3008
- if (props === void 0) {
3009
- props = {};
3010
- }
3011
- const {
3012
- open,
3013
- floatingId
3014
- } = context;
3015
- const {
3016
- enabled = true,
3017
- role = 'dialog'
3018
- } = props;
3019
- const ariaRole = (_componentRoleToAriaR = componentRoleToAriaRoleMap.get(role)) != null ? _componentRoleToAriaR : role;
3020
- const referenceId = useId();
3021
- const parentId = useFloatingParentNodeId();
3022
- const isNested = parentId != null;
3023
- const reference = React__namespace.useMemo(() => {
3024
- if (ariaRole === 'tooltip' || role === 'label') {
3025
- return {
3026
- ["aria-" + (role === 'label' ? 'labelledby' : 'describedby')]: open ? floatingId : undefined
3027
- };
3028
- }
3029
- return {
3030
- 'aria-expanded': open ? 'true' : 'false',
3031
- 'aria-haspopup': ariaRole === 'alertdialog' ? 'dialog' : ariaRole,
3032
- 'aria-controls': open ? floatingId : undefined,
3033
- ...(ariaRole === 'listbox' && {
3034
- role: 'combobox'
3035
- }),
3036
- ...(ariaRole === 'menu' && {
3037
- id: referenceId
3038
- }),
3039
- ...(ariaRole === 'menu' && isNested && {
3040
- role: 'menuitem'
3041
- }),
3042
- ...(role === 'select' && {
3043
- 'aria-autocomplete': 'none'
3044
- }),
3045
- ...(role === 'combobox' && {
3046
- 'aria-autocomplete': 'list'
3047
- })
3048
- };
3049
- }, [ariaRole, floatingId, isNested, open, referenceId, role]);
3050
- const floating = React__namespace.useMemo(() => {
3051
- const floatingProps = {
3052
- id: floatingId,
3053
- ...(ariaRole && {
3054
- role: ariaRole
3055
- })
3056
- };
3057
- if (ariaRole === 'tooltip' || role === 'label') {
3058
- return floatingProps;
3059
- }
3060
- return {
3061
- ...floatingProps,
3062
- ...(ariaRole === 'menu' && {
3063
- 'aria-labelledby': referenceId
3064
- })
3065
- };
3066
- }, [ariaRole, floatingId, referenceId, role]);
3067
- const item = React__namespace.useCallback(_ref => {
3068
- let {
3069
- active,
3070
- selected
3071
- } = _ref;
3072
- const commonProps = {
3073
- role: 'option',
3074
- ...(active && {
3075
- id: floatingId + "-option"
3076
- })
3077
- };
3078
-
3079
- // For `menu`, we are unable to tell if the item is a `menuitemradio`
3080
- // or `menuitemcheckbox`. For backwards-compatibility reasons, also
3081
- // avoid defaulting to `menuitem` as it may overwrite custom role props.
3082
- switch (role) {
3083
- case 'select':
3084
- return {
3085
- ...commonProps,
3086
- 'aria-selected': active && selected
3087
- };
3088
- case 'combobox':
3089
- {
3090
- return {
3091
- ...commonProps,
3092
- ...(active && {
3093
- 'aria-selected': true
3094
- })
3095
- };
3096
- }
3097
- }
3098
- return {};
3099
- }, [floatingId, role]);
3100
- return React__namespace.useMemo(() => enabled ? {
3101
- reference,
3102
- floating,
3103
- item
3104
- } : {}, [enabled, reference, floating, item]);
3105
- }
3106
-
3107
- // Converts a JS style key like `backgroundColor` to a CSS transition-property
3108
- // like `background-color`.
3109
- const camelCaseToKebabCase = str => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? '-' : '') + $.toLowerCase());
3110
- function execWithArgsOrReturn(valueOrFn, args) {
3111
- return typeof valueOrFn === 'function' ? valueOrFn(args) : valueOrFn;
3112
- }
3113
- function useDelayUnmount(open, durationMs) {
3114
- const [isMounted, setIsMounted] = React__namespace.useState(open);
3115
- if (open && !isMounted) {
3116
- setIsMounted(true);
3117
- }
3118
- React__namespace.useEffect(() => {
3119
- if (!open && isMounted) {
3120
- const timeout = setTimeout(() => setIsMounted(false), durationMs);
3121
- return () => clearTimeout(timeout);
3122
- }
3123
- }, [open, isMounted, durationMs]);
3124
- return isMounted;
3125
- }
3126
- /**
3127
- * Provides a status string to apply CSS transitions to a floating element,
3128
- * correctly handling placement-aware transitions.
3129
- * @see https://floating-ui.com/docs/useTransition#usetransitionstatus
3130
- */
3131
- function useTransitionStatus(context, props) {
3132
- if (props === void 0) {
3133
- props = {};
3134
- }
3135
- const {
3136
- open,
3137
- elements: {
3138
- floating
3139
- }
3140
- } = context;
3141
- const {
3142
- duration = 250
3143
- } = props;
3144
- const isNumberDuration = typeof duration === 'number';
3145
- const closeDuration = (isNumberDuration ? duration : duration.close) || 0;
3146
- const [status, setStatus] = React__namespace.useState('unmounted');
3147
- const isMounted = useDelayUnmount(open, closeDuration);
3148
- if (!isMounted && status === 'close') {
3149
- setStatus('unmounted');
3150
- }
3151
- index(() => {
3152
- if (!floating) return;
3153
- if (open) {
3154
- setStatus('initial');
3155
- const frame = requestAnimationFrame(() => {
3156
- setStatus('open');
3157
- });
3158
- return () => {
3159
- cancelAnimationFrame(frame);
3160
- };
3161
- }
3162
- setStatus('close');
3163
- }, [open, floating]);
3164
- return {
3165
- isMounted,
3166
- status
3167
- };
3168
- }
3169
- /**
3170
- * Provides styles to apply CSS transitions to a floating element, correctly
3171
- * handling placement-aware transitions. Wrapper around `useTransitionStatus`.
3172
- * @see https://floating-ui.com/docs/useTransition#usetransitionstyles
3173
- */
3174
- function useTransitionStyles(context, props) {
3175
- if (props === void 0) {
3176
- props = {};
3177
- }
3178
- const {
3179
- initial: unstable_initial = {
3180
- opacity: 0
3181
- },
3182
- open: unstable_open,
3183
- close: unstable_close,
3184
- common: unstable_common,
3185
- duration = 250
3186
- } = props;
3187
- const placement = context.placement;
3188
- const side = placement.split('-')[0];
3189
- const fnArgs = React__namespace.useMemo(() => ({
3190
- side,
3191
- placement
3192
- }), [side, placement]);
3193
- const isNumberDuration = typeof duration === 'number';
3194
- const openDuration = (isNumberDuration ? duration : duration.open) || 0;
3195
- const closeDuration = (isNumberDuration ? duration : duration.close) || 0;
3196
- const [styles, setStyles] = React__namespace.useState(() => ({
3197
- ...execWithArgsOrReturn(unstable_common, fnArgs),
3198
- ...execWithArgsOrReturn(unstable_initial, fnArgs)
3199
- }));
3200
- const {
3201
- isMounted,
3202
- status
3203
- } = useTransitionStatus(context, {
3204
- duration
3205
- });
3206
- const initialRef = useLatestRef(unstable_initial);
3207
- const openRef = useLatestRef(unstable_open);
3208
- const closeRef = useLatestRef(unstable_close);
3209
- const commonRef = useLatestRef(unstable_common);
3210
- index(() => {
3211
- const initialStyles = execWithArgsOrReturn(initialRef.current, fnArgs);
3212
- const closeStyles = execWithArgsOrReturn(closeRef.current, fnArgs);
3213
- const commonStyles = execWithArgsOrReturn(commonRef.current, fnArgs);
3214
- const openStyles = execWithArgsOrReturn(openRef.current, fnArgs) || Object.keys(initialStyles).reduce((acc, key) => {
3215
- acc[key] = '';
3216
- return acc;
3217
- }, {});
3218
- if (status === 'initial') {
3219
- setStyles(styles => ({
3220
- transitionProperty: styles.transitionProperty,
3221
- ...commonStyles,
3222
- ...initialStyles
3223
- }));
3224
- }
3225
- if (status === 'open') {
3226
- setStyles({
3227
- transitionProperty: Object.keys(openStyles).map(camelCaseToKebabCase).join(','),
3228
- transitionDuration: openDuration + "ms",
3229
- ...commonStyles,
3230
- ...openStyles
3231
- });
3232
- }
3233
- if (status === 'close') {
3234
- const styles = closeStyles || initialStyles;
3235
- setStyles({
3236
- transitionProperty: Object.keys(styles).map(camelCaseToKebabCase).join(','),
3237
- transitionDuration: closeDuration + "ms",
3238
- ...commonStyles,
3239
- ...styles
3240
- });
3241
- }
3242
- }, [closeDuration, closeRef, initialRef, openRef, commonRef, openDuration, status, fnArgs]);
3243
- return {
3244
- isMounted,
3245
- styles
3246
- };
3247
- }
3248
-
3249
- exports.arrow = floatingUi_reactDom.arrow;
3250
- exports.flip = floatingUi_reactDom.flip;
3251
- exports.offset = floatingUi_reactDom.offset;
3252
- exports.shift = floatingUi_reactDom.shift;
3253
- exports.size = floatingUi_reactDom.size;
3254
- exports.getOverflowAncestors = floatingUi_utils_dom.getOverflowAncestors;
3255
- exports.FloatingArrow = FloatingArrow;
3256
- exports.FloatingFocusManager = FloatingFocusManager;
3257
- exports.FloatingPortal = FloatingPortal;
3258
- exports.useClick = useClick;
3259
- exports.useDismiss = useDismiss;
3260
- exports.useFloating = useFloating;
3261
- exports.useFloatingParentNodeId = useFloatingParentNodeId;
3262
- exports.useFloatingPortalNode = useFloatingPortalNode;
3263
- exports.useFloatingRootContext = useFloatingRootContext;
3264
- exports.useFloatingTree = useFloatingTree;
3265
- exports.useFocus = useFocus;
3266
- exports.useHover = useHover;
3267
- exports.useId = useId;
3268
- exports.useInteractions = useInteractions;
3269
- exports.useListNavigation = useListNavigation;
3270
- exports.useMergeRefs = useMergeRefs;
3271
- exports.useRole = useRole;
3272
- exports.useTransitionStatus = useTransitionStatus;
3273
- exports.useTransitionStyles = useTransitionStyles;