@preply/ds-web-lib 11.0.0 → 11.1.0

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 (303) hide show
  1. package/dist/Accordion-B0hR-tcI.js +96 -0
  2. package/dist/AlertBannerProvider-Cf7w9AOq.js +76 -0
  3. package/dist/AlertDialog-BG-diKBi.js +475 -0
  4. package/dist/Avatar-B-JdqVyg.js +66 -0
  5. package/dist/AvatarWithStatus-CD9jEqEB.js +36 -0
  6. package/dist/Badge-Dd-CLBoW.js +50 -0
  7. package/dist/Box-BJBE9KNm.js +91 -0
  8. package/dist/BubbleCounter.module-BU2S0euA.js +16 -0
  9. package/dist/Button-C35BZJZT.js +91 -0
  10. package/dist/ButtonBase-8eUyTWxX.js +215 -0
  11. package/dist/Checkbox-CtolNbxI.js +108 -0
  12. package/dist/Chips-BRGw7Uup.js +99 -0
  13. package/dist/ChipsPrimitive-Bezq7ptE.js +1179 -0
  14. package/dist/CountryFlag-DVDKHmQH.js +43 -0
  15. package/dist/Dialog.module-Db2BJAn4.js +21 -0
  16. package/dist/DialogCloseButton-DjDd9Mid.js +98 -0
  17. package/dist/DialogDescription-8zw9t6pm.js +44 -0
  18. package/dist/DialogRoot-B67oJduC.js +335 -0
  19. package/dist/DialogRootContext-Bz8RW-Mq.js +12 -0
  20. package/dist/DialogTitle-C2Nn2ys-.js +43 -0
  21. package/dist/Divider-DvwDWB9_.js +17 -0
  22. package/dist/DropdownMenu.primitives-BrsTBvMk.js +4007 -0
  23. package/dist/FieldButton-B2slox8P.js +32 -0
  24. package/dist/FormControl-qnbQL1iF.js +128 -0
  25. package/dist/Heading-DA9gHfsx.js +71 -0
  26. package/dist/Icon-CixAeOSd.js +48 -0
  27. package/dist/IconButton-BPKpgfep.js +31 -0
  28. package/dist/InputContainer-CzzuOe_p.js +38 -0
  29. package/dist/LayoutFlex-e9auDvWD.js +86 -0
  30. package/dist/LayoutFlexItem-D9ziMmHe.js +48 -0
  31. package/dist/LayoutGridItem-Q8Lnvrri.js +34 -0
  32. package/dist/Link-CdoJVeER.js +66 -0
  33. package/dist/Loader-BMOxdJce.js +26 -0
  34. package/dist/OnboardingTooltip-B47_Yrsj.js +165 -0
  35. package/dist/OnboardingTour-DUUoI5WE.js +131 -0
  36. package/dist/PasswordField-Bx5YG62t.js +93 -0
  37. package/dist/PreplyLogo-abgOre30.js +112 -0
  38. package/dist/ProgressBar-CEU4GyHn.js +31 -0
  39. package/dist/ProgressSteps-BSqopxqv.js +45 -0
  40. package/dist/Select-Bo7PX_8V.js +124 -0
  41. package/dist/Slider-Crg4DEn_.js +64 -0
  42. package/dist/Spinner-Ck8KQA22.js +86 -0
  43. package/dist/Stars-D5QspUBE.js +72 -0
  44. package/dist/Steps-DbN5vFrP.js +173 -0
  45. package/dist/Switch-Ck_xB0ID.js +49 -0
  46. package/dist/Text-CaOF75Z-.js +121 -0
  47. package/dist/TextHighlighted-Dwq9Clgn.js +34 -0
  48. package/dist/TextInline-BcA4H2Tk.js +34 -0
  49. package/dist/Toast-wJAjSLfo.js +1019 -0
  50. package/dist/TokyoUIChevronDown-DGcVqR1z.js +14 -0
  51. package/dist/Tooltip-grvKQxTN.js +84 -0
  52. package/dist/VisuallyHidden-CtcHcZCK.js +29 -0
  53. package/dist/align-self-VrZUceie.js +42 -0
  54. package/dist/assets/Accordion.css +2 -2
  55. package/dist/assets/AlertBannerProvider.css +2 -2
  56. package/dist/assets/AlertDialog.css +2 -2
  57. package/dist/assets/Avatar.css +3 -3
  58. package/dist/assets/AvatarWithStatus.css +2 -2
  59. package/dist/assets/Badge.css +1 -1
  60. package/dist/assets/Box.css +3 -3
  61. package/dist/assets/BubbleCounter.css +1 -1
  62. package/dist/assets/Button.css +4 -4
  63. package/dist/assets/ButtonBase.css +40 -46
  64. package/dist/assets/Checkbox.css +1 -1
  65. package/dist/assets/Chips.css +2 -2
  66. package/dist/assets/ChipsPrimitive.css +2 -2
  67. package/dist/assets/CountryFlag.css +1 -1
  68. package/dist/assets/Dialog.css +13 -4
  69. package/dist/assets/Divider.css +1 -1
  70. package/dist/assets/DropdownMenu.css +2 -2
  71. package/dist/assets/FieldButton.css +3 -3
  72. package/dist/assets/FormControl.css +1 -1
  73. package/dist/assets/Heading.css +3 -3
  74. package/dist/assets/Icon.css +3 -3
  75. package/dist/assets/InputContainer.css +2 -2
  76. package/dist/assets/LayoutFlex.css +1 -1
  77. package/dist/assets/LayoutFlexItem.css +1 -1
  78. package/dist/assets/Link.css +3 -3
  79. package/dist/assets/Loader.css +1 -1
  80. package/dist/assets/OnboardingTooltip.css +1 -1
  81. package/dist/assets/OnboardingTour.css +1 -1
  82. package/dist/assets/PreplyLogo.css +1 -1
  83. package/dist/assets/ProgressBar.css +1 -1
  84. package/dist/assets/ProgressSteps.css +1 -1
  85. package/dist/assets/Select.css +2 -2
  86. package/dist/assets/Slider.css +1 -1
  87. package/dist/assets/Spinner.css +3 -3
  88. package/dist/assets/Stars.css +3 -3
  89. package/dist/assets/Steps.css +2 -2
  90. package/dist/assets/Switch.css +1 -1
  91. package/dist/assets/Text.css +3 -3
  92. package/dist/assets/TextHighlighted.css +3 -3
  93. package/dist/assets/TextInline.css +3 -3
  94. package/dist/assets/Toast.css +2 -2
  95. package/dist/assets/Tooltip.css +1 -1
  96. package/dist/assets/align-self.css +1 -1
  97. package/dist/assets/{IconTile.css → components.css} +1 -1
  98. package/dist/assets/exp-color.css +2 -2
  99. package/dist/assets/index.css +1 -1
  100. package/dist/assets/layout-gap.css +3 -3
  101. package/dist/assets/layout-grid.css +3 -3
  102. package/dist/assets/layout-hide.css +1 -1
  103. package/dist/assets/layout-padding.css +3 -3
  104. package/dist/assets/layout-relative.css +1 -1
  105. package/dist/assets/text-accent.css +2 -2
  106. package/dist/assets/text-centered.css +1 -1
  107. package/dist/assets/text-weight.css +2 -2
  108. package/dist/chunk-BVTlhY3a.js +24 -0
  109. package/dist/components/Accordion/Accordion.js +4 -60
  110. package/dist/components/Accordion/hooks/useOnOpenChange.js +19 -28
  111. package/dist/components/AlertBanner/AlertBanner.js +11 -26
  112. package/dist/components/AlertBanner/AlertBannerProvider.js +3 -8
  113. package/dist/components/AlertBanner/primitives/AlertBannerAction.js +11 -69
  114. package/dist/components/AlertBanner/primitives/AlertBannerIcon.js +77 -39
  115. package/dist/components/AlertBanner/primitives/AlertBannerRoot.js +26 -22
  116. package/dist/components/AlertBanner/primitives/AlertBannerText.js +11 -70
  117. package/dist/components/AlertDialog/AlertDialog.js +5 -430
  118. package/dist/components/Avatar/Avatar.js +3 -71
  119. package/dist/components/AvatarWithStatus/AvatarWithStatus.js +3 -43
  120. package/dist/components/Badge/Badge.js +4 -62
  121. package/dist/components/Box/Box.js +3 -95
  122. package/dist/components/BubbleCounter/BubbleCounter.js +23 -28
  123. package/dist/components/Button/Button.js +4 -80
  124. package/dist/components/CalloutBanner/CalloutBanner.js +61 -12
  125. package/dist/components/CalloutBanner/primitives/CalloutBannerDismissButton.js +50 -22
  126. package/dist/components/CalloutBanner/primitives/CalloutBannerIcon.js +86 -45
  127. package/dist/components/CalloutBanner/primitives/CalloutBannerRoot.js +50 -24
  128. package/dist/components/CalloutBanner/primitives/CalloutBannerText.js +41 -11
  129. package/dist/components/Checkbox/Checkbox.js +4 -78
  130. package/dist/components/Checkbox/hooks/useIndeterminate.js +24 -30
  131. package/dist/components/Chips/Chips.types.js +0 -1
  132. package/dist/components/Chips/DismissibleChips.js +117 -86
  133. package/dist/components/Chips/MultiSelectChips.js +98 -64
  134. package/dist/components/Chips/SingleSelectChips.js +94 -57
  135. package/dist/components/Chips/private/ChipsPrimitive.js +4 -17
  136. package/dist/components/CountryFlag/CountryFlag.js +3 -44
  137. package/dist/components/Dialog/Dialog.js +56 -31
  138. package/dist/components/Dialog/DialogSteps.js +40 -29
  139. package/dist/components/Dialog/primitives/DialogActions.js +26 -19
  140. package/dist/components/Dialog/primitives/DialogButtonStack.d.ts.map +1 -1
  141. package/dist/components/Dialog/primitives/DialogButtonStack.js +22 -15
  142. package/dist/components/Dialog/primitives/DialogCloseButton.d.ts +1 -1
  143. package/dist/components/Dialog/primitives/DialogCloseButton.d.ts.map +1 -1
  144. package/dist/components/Dialog/primitives/DialogCloseButton.js +4 -67
  145. package/dist/components/Dialog/primitives/DialogDescription.js +3 -43
  146. package/dist/components/Dialog/primitives/DialogFooter.js +37 -34
  147. package/dist/components/Dialog/primitives/DialogRoot.js +4 -315
  148. package/dist/components/Dialog/primitives/DialogTitle.js +3 -42
  149. package/dist/components/Divider/Divider.js +3 -14
  150. package/dist/components/DropdownMenu/DropdownMenu.js +253 -188
  151. package/dist/components/DropdownMenu/primitives/DropdownMenu.primitives.js +5 -34
  152. package/dist/components/DropdownMenu/primitives/DropdownMenuSelectItem.primitives.js +121 -71
  153. package/dist/components/FieldButton/FieldButton.js +3 -37
  154. package/dist/components/FormControl/FormControl.js +3 -105
  155. package/dist/components/Heading/Heading.js +3 -78
  156. package/dist/components/Icon/Icon.js +4 -49
  157. package/dist/components/IconButton/IconButton.d.ts +5 -1
  158. package/dist/components/IconButton/IconButton.d.ts.map +1 -1
  159. package/dist/components/IconButton/IconButton.js +4 -28
  160. package/dist/components/IconTile/IconTile.js +11 -69
  161. package/dist/components/IntlFormatted/IntlFormattedAggregatedDateTime.js +16 -32
  162. package/dist/components/IntlFormatted/IntlFormattedCurrency.js +20 -42
  163. package/dist/components/IntlFormatted/IntlFormattedDate.js +73 -195
  164. package/dist/components/IntlFormatted/IntlFormattedTime.js +14 -24
  165. package/dist/components/IntlFormatted/Wrapper.js +14 -8
  166. package/dist/components/LayoutFlex/LayoutFlex.js +3 -100
  167. package/dist/components/LayoutFlex/style/getStyleAttrs.js +71 -143
  168. package/dist/components/LayoutFlex/tests/AlignItems.js +67 -97
  169. package/dist/components/LayoutFlex/tests/ColumnReverse.js +63 -100
  170. package/dist/components/LayoutFlex/tests/DataOverride.js +1498 -1093
  171. package/dist/components/LayoutFlex/tests/Default.js +19 -20
  172. package/dist/components/LayoutFlex/tests/Direction.js +65 -88
  173. package/dist/components/LayoutFlex/tests/Gap.js +115 -197
  174. package/dist/components/LayoutFlex/tests/HideInline.js +95 -136
  175. package/dist/components/LayoutFlex/tests/JustifyContent.js +75 -108
  176. package/dist/components/LayoutFlex/tests/Nowrap.js +35 -42
  177. package/dist/components/LayoutFlex/tests/Padding.js +207 -263
  178. package/dist/components/LayoutFlex/tests/Relative.js +49 -64
  179. package/dist/components/LayoutFlexItem/LayoutFlexItem.js +3 -54
  180. package/dist/components/LayoutGrid/LayoutGrid.js +26 -34
  181. package/dist/components/LayoutGridItem/LayoutGridItem.js +3 -41
  182. package/dist/components/Link/Link.js +3 -72
  183. package/dist/components/Loader/Loader.js +3 -32
  184. package/dist/components/NumberField/NumberField.js +33 -35
  185. package/dist/components/ObserveIntersection/ObserveIntersection.js +41 -42
  186. package/dist/components/OnboardingTooltip/OnboardingTooltip.js +4 -115
  187. package/dist/components/OnboardingTour/OnboardingTour.js +4 -114
  188. package/dist/components/PasswordField/PasswordField.js +3 -78
  189. package/dist/components/PreplyLogo/PreplyLogo.js +3 -81
  190. package/dist/components/ProgressBar/ProgressBar.js +3 -27
  191. package/dist/components/ProgressSteps/ProgressSteps.js +3 -48
  192. package/dist/components/Rating/Rating.js +29 -20
  193. package/dist/components/Rating/RatingInput.js +57 -59
  194. package/dist/components/Rating/Stars.js +4 -8
  195. package/dist/components/Rating/hooks/useHasError.js +11 -15
  196. package/dist/components/Rating/hooks/useHoverPercentage.js +37 -45
  197. package/dist/components/Rating/hooks/useInputState.js +18 -24
  198. package/dist/components/Rating/hooks/useLocalizations.js +12 -24
  199. package/dist/components/Rating/utils/roundToHalfDecimal.js +4 -4
  200. package/dist/components/SelectField/Select.js +5 -112
  201. package/dist/components/SelectField/SelectField.js +29 -24
  202. package/dist/components/SelectField/hooks/useBreakpointMatch.js +18 -19
  203. package/dist/components/ShowOnIntersection/ShowOnIntersection.js +32 -21
  204. package/dist/components/Slider/RangeSlider.js +62 -52
  205. package/dist/components/Slider/Slider.js +3 -10
  206. package/dist/components/Steps/Steps.js +4 -210
  207. package/dist/components/Switch/Switch.js +3 -51
  208. package/dist/components/Text/Text.js +3 -128
  209. package/dist/components/TextField/TextField.js +27 -29
  210. package/dist/components/TextHighlighted/TextHighlighted.js +3 -41
  211. package/dist/components/TextInline/TextInline.js +3 -40
  212. package/dist/components/TextareaField/TextareaField.js +26 -28
  213. package/dist/components/Toast/Toast.js +4 -1168
  214. package/dist/components/Tooltip/Tooltip.js +3 -66
  215. package/dist/components/deprecated/Chips/Chips.js +4 -76
  216. package/dist/components/deprecated/NativeSelectField/NativeSelect.js +40 -32
  217. package/dist/components/deprecated/NativeSelectField/NativeSelectField.js +34 -33
  218. package/dist/components/deprecated/index.js +5 -6
  219. package/dist/components/index.js +50 -150
  220. package/dist/components/private/ButtonBase/ButtonBase.d.ts +7 -11
  221. package/dist/components/private/ButtonBase/ButtonBase.d.ts.map +1 -1
  222. package/dist/components/private/ButtonBase/ButtonBase.js +3 -247
  223. package/dist/components/private/Input/Input.js +27 -19
  224. package/dist/components/private/Input/InputContainer.js +3 -5
  225. package/dist/components/private/Input/Textarea.js +24 -20
  226. package/dist/components/private/Input/index.js +2 -4
  227. package/dist/components/private/Spinner/Spinner.js +3 -52
  228. package/dist/components/private/VisuallyHidden/VisuallyHidden.js +3 -15
  229. package/dist/components-BIYP8wHJ.js +200 -0
  230. package/dist/exp-color-C5mKAN91.js +74 -0
  231. package/dist/floating-ui.utils.dom-CoeTbDZx.js +215 -0
  232. package/dist/index.js +50 -150
  233. package/dist/index.module-1c7ENvxc.js +7 -0
  234. package/dist/jsx-runtime-i4KUlhDu.js +743 -0
  235. package/dist/layout-gap.module-DLD8bcR4.js +95 -0
  236. package/dist/layout-grid.module-CZfhrKrB.js +101 -0
  237. package/dist/layout-hide.module-B1P0N4i3.js +53 -0
  238. package/dist/layout-padding-ugY-yd2q.js +389 -0
  239. package/dist/layout-relative.module-B5xrFD9j.js +6 -0
  240. package/dist/render-icon-Ch3b2dE0.js +290 -0
  241. package/dist/shared-styles/align-self/align-self.js +2 -36
  242. package/dist/shared-styles/exp-color/exp-color.js +2 -68
  243. package/dist/shared-styles/layout-gap/layout-gap.js +13 -7
  244. package/dist/shared-styles/layout-grid/layout-grid.js +28 -28
  245. package/dist/shared-styles/layout-grid-responsive-columns/layout-grid-responsive-columns.js +29 -43
  246. package/dist/shared-styles/layout-hide/layout-hide.js +8 -8
  247. package/dist/shared-styles/layout-padding/layout-padding.js +2 -5
  248. package/dist/shared-styles/layout-relative/layout-relative.js +14 -8
  249. package/dist/shared-styles/text-accent/text-accent.js +2 -25
  250. package/dist/shared-styles/text-centered/text-centered.js +2 -24
  251. package/dist/shared-styles/text-weight/text-weight.js +2 -15
  252. package/dist/store-sN_eYeZT.js +1064 -0
  253. package/dist/storybook-utils/consts.js +6 -8
  254. package/dist/storybook-utils/index.js +1 -5
  255. package/dist/text-accent-CfUFx-1K.js +30 -0
  256. package/dist/text-centered-Dwp2_-Yp.js +30 -0
  257. package/dist/text-weight-CwoqmM4o.js +21 -0
  258. package/dist/useBaseUiId-CWAD_PSs.js +13 -0
  259. package/dist/useBreakpointMatch-D9a3CTNK.js +338 -0
  260. package/dist/useButton-DHTh3Hm7.js +148 -0
  261. package/dist/useDialogClose-BzFIyWco.js +22 -0
  262. package/dist/useId-CJsH-2wV.js +34 -0
  263. package/dist/useOpenInteractionType-D8vA_ZKI.js +4104 -0
  264. package/dist/useRenderElement-ZBds6eRN.js +341 -0
  265. package/dist/utils/Orientation/OrientationProvider.js +54 -23
  266. package/dist/utils/Orientation/index.js +2 -4
  267. package/dist/utils/RovingTabIndex/RovingTabIndexProvider.js +70 -44
  268. package/dist/utils/RovingTabIndex/index.js +2 -4
  269. package/dist/utils/createRequiredContext.js +23 -13
  270. package/dist/utils/filterAttributesPassedByRadixUIAtRuntime.js +28 -25
  271. package/dist/utils/render-icon.js +3 -320
  272. package/dist/utils/shared-strings.js +24 -32
  273. package/dist/utils/useBreakpointMatch.d.ts.map +1 -1
  274. package/dist/utils/useBreakpointMatch.js +2 -183
  275. package/dist/utils/useControllableState/useControllableState.js +31 -25
  276. package/dist/utils/useMergeRefs.js +29 -14
  277. package/dist/utils/useStableCallback/useStableCallback.js +28 -13
  278. package/package.json +17 -22
  279. package/dist/AlertBannerProvider-DTx2Xp3V.js +0 -50
  280. package/dist/BubbleCounter.module-QMwXWFIS.js +0 -16
  281. package/dist/ChipsPrimitive-DzsaOWgY.js +0 -1244
  282. package/dist/Dialog.module-Ba1X7b3N.js +0 -29
  283. package/dist/DialogRootContext-BCXmmJAw.js +0 -15
  284. package/dist/DropdownMenu.primitives-B3WK71bR.js +0 -5871
  285. package/dist/IconTile-D1G7MljH.js +0 -172
  286. package/dist/InputContainer-oHJlLWIi.js +0 -30
  287. package/dist/Slider-DB4Maswa.js +0 -55
  288. package/dist/Stars-C_mHop2H.js +0 -67
  289. package/dist/TokyoUIChevronDown-D_tD1yU8.js +0 -11
  290. package/dist/floating-ui.utils.dom-3OgjGonN.js +0 -234
  291. package/dist/index.module-Q9TzIR6B.js +0 -11
  292. package/dist/layout-gap.module-MKn_un_k.js +0 -97
  293. package/dist/layout-grid.module-P4B4WVUy.js +0 -103
  294. package/dist/layout-hide.module-Bpl3Pl-a.js +0 -55
  295. package/dist/layout-padding-D5I6rRlL.js +0 -373
  296. package/dist/layout-relative.module-1z75aSwo.js +0 -8
  297. package/dist/store-BUKWfVf3.js +0 -1155
  298. package/dist/useBaseUiId-DavsGYu9.js +0 -8
  299. package/dist/useButton-CFPpP0o5.js +0 -193
  300. package/dist/useDialogClose-C9x1leGd.js +0 -34
  301. package/dist/useId-BhIOp2JG.js +0 -28
  302. package/dist/useOpenInteractionType-Cj41-8Yk.js +0 -2880
  303. package/dist/useRenderElement-DtYPTE_y.js +0 -350
@@ -1,2880 +0,0 @@
1
- "use client";
2
- var __defProp = Object.defineProperty;
3
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- import * as React from "react";
6
- import * as ReactDOM from "react-dom";
7
- import { u as useEventCallback, a as useIsoLayoutEffect, b as isShadowRoot, i as isHTMLElement, g as getNodeName, c as createChangeEventDetails, d as isNode, e as getWindow, f as isElement, h as isLastTraversableNode, j as getParentNode, k as getComputedStyle$1, l as getOverflowAncestors, m as isWebKit$1 } from "./floating-ui.utils.dom-3OgjGonN.js";
8
- import { b as useRefWithInit, i as isReactVersionAtLeast, c as useMergedRefs, E as EMPTY_OBJECT, N as NOOP } from "./useRenderElement-DtYPTE_y.js";
9
- import { jsx, jsxs } from "react/jsx-runtime";
10
- import { u as useId } from "./useId-BhIOp2JG.js";
11
- const TYPEAHEAD_RESET_MS = 500;
12
- const PATIENT_CLICK_THRESHOLD = 500;
13
- const DISABLED_TRANSITIONS_STYLE = {
14
- style: {
15
- transition: "none"
16
- }
17
- };
18
- const CLICK_TRIGGER_IDENTIFIER = "data-base-ui-click-trigger";
19
- const DROPDOWN_COLLISION_AVOIDANCE = {
20
- fallbackAxisSide: "none"
21
- };
22
- const EMPTY$2 = [];
23
- function useOnMount(fn) {
24
- React.useEffect(fn, EMPTY$2);
25
- }
26
- const EMPTY$1 = null;
27
- let LAST_RAF = globalThis.requestAnimationFrame;
28
- class Scheduler {
29
- constructor() {
30
- /* This implementation uses an array as a backing data-structure for frame callbacks.
31
- * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
32
- * never calls the native `cancelAnimationFrame` if there are no frames left. This can
33
- * be much more efficient if there is a call pattern that alterns as
34
- * "request-cancel-request-cancel-…".
35
- * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
36
- * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
37
- __publicField(this, "callbacks", /* @__PURE__ */ (() => [])());
38
- __publicField(this, "callbacksCount", 0);
39
- __publicField(this, "nextId", 1);
40
- __publicField(this, "startId", 1);
41
- __publicField(this, "isScheduled", false);
42
- __publicField(this, "tick", (timestamp) => {
43
- var _a;
44
- this.isScheduled = false;
45
- const currentCallbacks = this.callbacks;
46
- const currentCallbacksCount = this.callbacksCount;
47
- this.callbacks = [];
48
- this.callbacksCount = 0;
49
- this.startId = this.nextId;
50
- if (currentCallbacksCount > 0) {
51
- for (let i = 0; i < currentCallbacks.length; i += 1) {
52
- (_a = currentCallbacks[i]) == null ? void 0 : _a.call(currentCallbacks, timestamp);
53
- }
54
- }
55
- });
56
- }
57
- request(fn) {
58
- const id = this.nextId;
59
- this.nextId += 1;
60
- this.callbacks.push(fn);
61
- this.callbacksCount += 1;
62
- const didRAFChange = process.env.NODE_ENV === "test" && LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
63
- if (!this.isScheduled || didRAFChange) {
64
- requestAnimationFrame(this.tick);
65
- this.isScheduled = true;
66
- }
67
- return id;
68
- }
69
- cancel(id) {
70
- const index = id - this.startId;
71
- if (index < 0 || index >= this.callbacks.length) {
72
- return;
73
- }
74
- this.callbacks[index] = null;
75
- this.callbacksCount -= 1;
76
- }
77
- }
78
- const scheduler = new Scheduler();
79
- class AnimationFrame {
80
- constructor() {
81
- __publicField(this, "currentId", /* @__PURE__ */ (() => EMPTY$1)());
82
- __publicField(this, "cancel", () => {
83
- if (this.currentId !== EMPTY$1) {
84
- scheduler.cancel(this.currentId);
85
- this.currentId = EMPTY$1;
86
- }
87
- });
88
- __publicField(this, "disposeEffect", () => {
89
- return this.cancel;
90
- });
91
- }
92
- static create() {
93
- return new AnimationFrame();
94
- }
95
- static request(fn) {
96
- return scheduler.request(fn);
97
- }
98
- static cancel(id) {
99
- return scheduler.cancel(id);
100
- }
101
- /**
102
- * Executes `fn` after `delay`, clearing any previously scheduled call.
103
- */
104
- request(fn) {
105
- this.cancel();
106
- this.currentId = scheduler.request(() => {
107
- this.currentId = EMPTY$1;
108
- fn();
109
- });
110
- }
111
- }
112
- function useAnimationFrame() {
113
- const timeout = useRefWithInit(AnimationFrame.create).current;
114
- useOnMount(timeout.disposeEffect);
115
- return timeout;
116
- }
117
- function useAnimationsFinished(elementOrRef, waitForNextTick = false) {
118
- const frame = useAnimationFrame();
119
- return useEventCallback((fnToExecute, signal = null) => {
120
- frame.cancel();
121
- if (elementOrRef == null) {
122
- return;
123
- }
124
- let element;
125
- if ("current" in elementOrRef) {
126
- if (elementOrRef.current == null) {
127
- return;
128
- }
129
- element = elementOrRef.current;
130
- } else {
131
- element = elementOrRef;
132
- }
133
- if (typeof element.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
134
- fnToExecute();
135
- } else {
136
- frame.request(() => {
137
- function exec() {
138
- if (!element) {
139
- return;
140
- }
141
- Promise.allSettled(element.getAnimations().map((anim) => anim.finished)).then(() => {
142
- if (signal != null && signal.aborted) {
143
- return;
144
- }
145
- ReactDOM.flushSync(fnToExecute);
146
- });
147
- }
148
- if (waitForNextTick) {
149
- frame.request(exec);
150
- } else {
151
- exec();
152
- }
153
- });
154
- }
155
- });
156
- }
157
- function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
158
- const [transitionStatus, setTransitionStatus] = React.useState(open && enableIdleState ? "idle" : void 0);
159
- const [mounted, setMounted] = React.useState(open);
160
- if (open && !mounted) {
161
- setMounted(true);
162
- setTransitionStatus("starting");
163
- }
164
- if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
165
- setTransitionStatus("ending");
166
- }
167
- if (!open && !mounted && transitionStatus === "ending") {
168
- setTransitionStatus(void 0);
169
- }
170
- useIsoLayoutEffect(() => {
171
- if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
172
- const frame = AnimationFrame.request(() => {
173
- setTransitionStatus("ending");
174
- });
175
- return () => {
176
- AnimationFrame.cancel(frame);
177
- };
178
- }
179
- return void 0;
180
- }, [open, mounted, transitionStatus, deferEndingState]);
181
- useIsoLayoutEffect(() => {
182
- if (!open || enableIdleState) {
183
- return void 0;
184
- }
185
- const frame = AnimationFrame.request(() => {
186
- ReactDOM.flushSync(() => {
187
- setTransitionStatus(void 0);
188
- });
189
- });
190
- return () => {
191
- AnimationFrame.cancel(frame);
192
- };
193
- }, [enableIdleState, open]);
194
- useIsoLayoutEffect(() => {
195
- if (!open || !enableIdleState) {
196
- return void 0;
197
- }
198
- if (open && mounted && transitionStatus !== "idle") {
199
- setTransitionStatus("starting");
200
- }
201
- const frame = AnimationFrame.request(() => {
202
- setTransitionStatus("idle");
203
- });
204
- return () => {
205
- AnimationFrame.cancel(frame);
206
- };
207
- }, [enableIdleState, open, mounted, setTransitionStatus, transitionStatus]);
208
- return React.useMemo(() => ({
209
- mounted,
210
- setMounted,
211
- transitionStatus
212
- }), [mounted, transitionStatus]);
213
- }
214
- let TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
215
- TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
216
- TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
217
- return TransitionStatusDataAttributes2;
218
- })({});
219
- const STARTING_HOOK = {
220
- [TransitionStatusDataAttributes.startingStyle]: ""
221
- };
222
- const ENDING_HOOK = {
223
- [TransitionStatusDataAttributes.endingStyle]: ""
224
- };
225
- const transitionStatusMapping = {
226
- transitionStatus(value) {
227
- if (value === "starting") {
228
- return STARTING_HOOK;
229
- }
230
- if (value === "ending") {
231
- return ENDING_HOOK;
232
- }
233
- return null;
234
- }
235
- };
236
- const hasNavigator = typeof navigator !== "undefined";
237
- const nav = getNavigatorData();
238
- const platform = getPlatform();
239
- const userAgent = getUserAgent();
240
- const isWebKit = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
241
- const isIOS = (
242
- // iPads can claim to be MacIntel
243
- nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
244
- );
245
- const isSafari = hasNavigator && /apple/i.test(navigator.vendor);
246
- const isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
247
- const isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
248
- const isJSDOM = userAgent.includes("jsdom/");
249
- function getNavigatorData() {
250
- var _a, _b;
251
- if (!hasNavigator) {
252
- return {
253
- platform: "",
254
- maxTouchPoints: -1
255
- };
256
- }
257
- const uaData = navigator.userAgentData;
258
- if (uaData == null ? void 0 : uaData.platform) {
259
- return {
260
- platform: uaData.platform,
261
- maxTouchPoints: navigator.maxTouchPoints
262
- };
263
- }
264
- return {
265
- platform: (_a = navigator.platform) != null ? _a : "",
266
- maxTouchPoints: (_b = navigator.maxTouchPoints) != null ? _b : -1
267
- };
268
- }
269
- function getUserAgent() {
270
- if (!hasNavigator) {
271
- return "";
272
- }
273
- const uaData = navigator.userAgentData;
274
- if (uaData && Array.isArray(uaData.brands)) {
275
- return uaData.brands.map(({
276
- brand,
277
- version
278
- }) => `${brand}/${version}`).join(" ");
279
- }
280
- return navigator.userAgent;
281
- }
282
- function getPlatform() {
283
- var _a;
284
- if (!hasNavigator) {
285
- return "";
286
- }
287
- const uaData = navigator.userAgentData;
288
- if (uaData == null ? void 0 : uaData.platform) {
289
- return uaData.platform;
290
- }
291
- return (_a = navigator.platform) != null ? _a : "";
292
- }
293
- const FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
294
- const ACTIVE_KEY = "active";
295
- const SELECTED_KEY = "selected";
296
- const TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
297
- const ARROW_LEFT$1 = "ArrowLeft";
298
- const ARROW_RIGHT$1 = "ArrowRight";
299
- const ARROW_UP$1 = "ArrowUp";
300
- const ARROW_DOWN$1 = "ArrowDown";
301
- function activeElement(doc) {
302
- var _a;
303
- let element = doc.activeElement;
304
- while (((_a = element == null ? void 0 : element.shadowRoot) == null ? void 0 : _a.activeElement) != null) {
305
- element = element.shadowRoot.activeElement;
306
- }
307
- return element;
308
- }
309
- function contains(parent, child) {
310
- var _a;
311
- if (!parent || !child) {
312
- return false;
313
- }
314
- const rootNode = (_a = child.getRootNode) == null ? void 0 : _a.call(child);
315
- if (parent.contains(child)) {
316
- return true;
317
- }
318
- if (rootNode && isShadowRoot(rootNode)) {
319
- let next = child;
320
- while (next) {
321
- if (parent === next) {
322
- return true;
323
- }
324
- next = next.parentNode || next.host;
325
- }
326
- }
327
- return false;
328
- }
329
- function getTarget(event) {
330
- if ("composedPath" in event) {
331
- return event.composedPath()[0];
332
- }
333
- return event.target;
334
- }
335
- function isEventTargetWithin(event, node) {
336
- if (node == null) {
337
- return false;
338
- }
339
- if ("composedPath" in event) {
340
- return event.composedPath().includes(node);
341
- }
342
- const eventAgain = event;
343
- return eventAgain.target != null && node.contains(eventAgain.target);
344
- }
345
- function isRootElement(element) {
346
- return element.matches("html,body");
347
- }
348
- function getDocument(node) {
349
- return (node == null ? void 0 : node.ownerDocument) || document;
350
- }
351
- function isTypeableElement(element) {
352
- return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
353
- }
354
- function isTypeableCombobox(element) {
355
- if (!element) {
356
- return false;
357
- }
358
- return element.getAttribute("role") === "combobox" && isTypeableElement(element);
359
- }
360
- function matchesFocusVisible(element) {
361
- if (!element || isJSDOM) {
362
- return true;
363
- }
364
- try {
365
- return element.matches(":focus-visible");
366
- } catch (_e) {
367
- return true;
368
- }
369
- }
370
- function getFloatingFocusElement(floatingElement) {
371
- if (!floatingElement) {
372
- return null;
373
- }
374
- return floatingElement.hasAttribute(FOCUSABLE_ATTRIBUTE) ? floatingElement : floatingElement.querySelector(`[${FOCUSABLE_ATTRIBUTE}]`) || floatingElement;
375
- }
376
- function getNodeChildren(nodes, id, onlyOpenChildren = true) {
377
- const directChildren = nodes.filter((node) => {
378
- var _a;
379
- return node.parentId === id && (!onlyOpenChildren || ((_a = node.context) == null ? void 0 : _a.open));
380
- });
381
- return directChildren.flatMap((child) => [child, ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
382
- }
383
- function getNodeAncestors(nodes, id) {
384
- var _a;
385
- let allAncestors = [];
386
- let currentParentId = (_a = nodes.find((node) => node.id === id)) == null ? void 0 : _a.parentId;
387
- while (currentParentId) {
388
- const currentNode = nodes.find((node) => node.id === currentParentId);
389
- currentParentId = currentNode == null ? void 0 : currentNode.parentId;
390
- if (currentNode) {
391
- allAncestors = allAncestors.concat(currentNode);
392
- }
393
- }
394
- return allAncestors;
395
- }
396
- function stopEvent(event) {
397
- event.preventDefault();
398
- event.stopPropagation();
399
- }
400
- function isReactEvent(event) {
401
- return "nativeEvent" in event;
402
- }
403
- function isVirtualClick(event) {
404
- if (event.mozInputSource === 0 && event.isTrusted) {
405
- return true;
406
- }
407
- if (isAndroid && event.pointerType) {
408
- return event.type === "click" && event.buttons === 1;
409
- }
410
- return event.detail === 0 && !event.pointerType;
411
- }
412
- function isVirtualPointerEvent(event) {
413
- if (isJSDOM) {
414
- return false;
415
- }
416
- return !isAndroid && event.width === 0 && event.height === 0 || isAndroid && event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "mouse" || // iOS VoiceOver returns 0.333• for width/height.
417
- event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "touch";
418
- }
419
- function isMouseLikePointerType(pointerType, strict) {
420
- const values = ["mouse", "pen"];
421
- if (!strict) {
422
- values.push("", void 0);
423
- }
424
- return values.includes(pointerType);
425
- }
426
- /*!
427
- * tabbable 6.2.0
428
- * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
429
- */
430
- var candidateSelectors = ["input:not([inert])", "select:not([inert])", "textarea:not([inert])", "a[href]:not([inert])", "button:not([inert])", "[tabindex]:not(slot):not([inert])", "audio[controls]:not([inert])", "video[controls]:not([inert])", '[contenteditable]:not([contenteditable="false"]):not([inert])', "details>summary:first-of-type:not([inert])", "details:not([inert])"];
431
- var candidateSelector = /* @__PURE__ */ candidateSelectors.join(",");
432
- var NoElement = typeof Element === "undefined";
433
- var matches = NoElement ? function() {
434
- } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
435
- var getRootNode = !NoElement && Element.prototype.getRootNode ? function(element) {
436
- var _element$getRootNode;
437
- return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
438
- } : function(element) {
439
- return element === null || element === void 0 ? void 0 : element.ownerDocument;
440
- };
441
- var isInert = function isInert2(node, lookUp) {
442
- var _node$getAttribute;
443
- if (lookUp === void 0) {
444
- lookUp = true;
445
- }
446
- var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, "inert");
447
- var inert = inertAtt === "" || inertAtt === "true";
448
- var result = inert || lookUp && node && isInert2(node.parentNode);
449
- return result;
450
- };
451
- var isContentEditable = function isContentEditable2(node) {
452
- var _node$getAttribute2;
453
- var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, "contenteditable");
454
- return attValue === "" || attValue === "true";
455
- };
456
- var getCandidates = function getCandidates2(el, includeContainer, filter) {
457
- if (isInert(el)) {
458
- return [];
459
- }
460
- var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
461
- if (includeContainer && matches.call(el, candidateSelector)) {
462
- candidates.unshift(el);
463
- }
464
- candidates = candidates.filter(filter);
465
- return candidates;
466
- };
467
- var getCandidatesIteratively = function getCandidatesIteratively2(elements, includeContainer, options) {
468
- var candidates = [];
469
- var elementsToCheck = Array.from(elements);
470
- while (elementsToCheck.length) {
471
- var element = elementsToCheck.shift();
472
- if (isInert(element, false)) {
473
- continue;
474
- }
475
- if (element.tagName === "SLOT") {
476
- var assigned = element.assignedElements();
477
- var content = assigned.length ? assigned : element.children;
478
- var nestedCandidates = getCandidatesIteratively2(content, true, options);
479
- if (options.flatten) {
480
- candidates.push.apply(candidates, nestedCandidates);
481
- } else {
482
- candidates.push({
483
- scopeParent: element,
484
- candidates: nestedCandidates
485
- });
486
- }
487
- } else {
488
- var validCandidate = matches.call(element, candidateSelector);
489
- if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
490
- candidates.push(element);
491
- }
492
- var shadowRoot = element.shadowRoot || // check for an undisclosed shadow
493
- typeof options.getShadowRoot === "function" && options.getShadowRoot(element);
494
- var validShadowRoot = !isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
495
- if (shadowRoot && validShadowRoot) {
496
- var _nestedCandidates = getCandidatesIteratively2(shadowRoot === true ? element.children : shadowRoot.children, true, options);
497
- if (options.flatten) {
498
- candidates.push.apply(candidates, _nestedCandidates);
499
- } else {
500
- candidates.push({
501
- scopeParent: element,
502
- candidates: _nestedCandidates
503
- });
504
- }
505
- } else {
506
- elementsToCheck.unshift.apply(elementsToCheck, element.children);
507
- }
508
- }
509
- }
510
- return candidates;
511
- };
512
- var hasTabIndex = function hasTabIndex2(node) {
513
- return !isNaN(parseInt(node.getAttribute("tabindex"), 10));
514
- };
515
- var getTabIndex = function getTabIndex2(node) {
516
- if (!node) {
517
- throw new Error("No node provided");
518
- }
519
- if (node.tabIndex < 0) {
520
- if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
521
- return 0;
522
- }
523
- }
524
- return node.tabIndex;
525
- };
526
- var getSortOrderTabIndex = function getSortOrderTabIndex2(node, isScope) {
527
- var tabIndex = getTabIndex(node);
528
- if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
529
- return 0;
530
- }
531
- return tabIndex;
532
- };
533
- var sortOrderedTabbables = function sortOrderedTabbables2(a, b) {
534
- return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
535
- };
536
- var isInput = function isInput2(node) {
537
- return node.tagName === "INPUT";
538
- };
539
- var isHiddenInput = function isHiddenInput2(node) {
540
- return isInput(node) && node.type === "hidden";
541
- };
542
- var isDetailsWithSummary = function isDetailsWithSummary2(node) {
543
- var r = node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) {
544
- return child.tagName === "SUMMARY";
545
- });
546
- return r;
547
- };
548
- var getCheckedRadio = function getCheckedRadio2(nodes, form) {
549
- for (var i = 0; i < nodes.length; i++) {
550
- if (nodes[i].checked && nodes[i].form === form) {
551
- return nodes[i];
552
- }
553
- }
554
- };
555
- var isTabbableRadio = function isTabbableRadio2(node) {
556
- if (!node.name) {
557
- return true;
558
- }
559
- var radioScope = node.form || getRootNode(node);
560
- var queryRadios = function queryRadios2(name) {
561
- return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
562
- };
563
- var radioSet;
564
- if (typeof window !== "undefined" && typeof window.CSS !== "undefined" && typeof window.CSS.escape === "function") {
565
- radioSet = queryRadios(window.CSS.escape(node.name));
566
- } else {
567
- try {
568
- radioSet = queryRadios(node.name);
569
- } catch (err) {
570
- console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", err.message);
571
- return false;
572
- }
573
- }
574
- var checked = getCheckedRadio(radioSet, node.form);
575
- return !checked || checked === node;
576
- };
577
- var isRadio = function isRadio2(node) {
578
- return isInput(node) && node.type === "radio";
579
- };
580
- var isNonTabbableRadio = function isNonTabbableRadio2(node) {
581
- return isRadio(node) && !isTabbableRadio(node);
582
- };
583
- var isNodeAttached = function isNodeAttached2(node) {
584
- var _nodeRoot;
585
- var nodeRoot = node && getRootNode(node);
586
- var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
587
- var attached = false;
588
- if (nodeRoot && nodeRoot !== node) {
589
- var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
590
- attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node));
591
- while (!attached && nodeRootHost) {
592
- var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
593
- nodeRoot = getRootNode(nodeRootHost);
594
- nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
595
- attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
596
- }
597
- }
598
- return attached;
599
- };
600
- var isZeroArea = function isZeroArea2(node) {
601
- var _node$getBoundingClie = node.getBoundingClientRect(), width = _node$getBoundingClie.width, height = _node$getBoundingClie.height;
602
- return width === 0 && height === 0;
603
- };
604
- var isHidden = function isHidden2(node, _ref) {
605
- var displayCheck = _ref.displayCheck, getShadowRoot = _ref.getShadowRoot;
606
- if (getComputedStyle(node).visibility === "hidden") {
607
- return true;
608
- }
609
- var isDirectSummary = matches.call(node, "details>summary:first-of-type");
610
- var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
611
- if (matches.call(nodeUnderDetails, "details:not([open]) *")) {
612
- return true;
613
- }
614
- if (!displayCheck || displayCheck === "full" || displayCheck === "legacy-full") {
615
- if (typeof getShadowRoot === "function") {
616
- var originalNode = node;
617
- while (node) {
618
- var parentElement = node.parentElement;
619
- var rootNode = getRootNode(node);
620
- if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true) {
621
- return isZeroArea(node);
622
- } else if (node.assignedSlot) {
623
- node = node.assignedSlot;
624
- } else if (!parentElement && rootNode !== node.ownerDocument) {
625
- node = rootNode.host;
626
- } else {
627
- node = parentElement;
628
- }
629
- }
630
- node = originalNode;
631
- }
632
- if (isNodeAttached(node)) {
633
- return !node.getClientRects().length;
634
- }
635
- if (displayCheck !== "legacy-full") {
636
- return true;
637
- }
638
- } else if (displayCheck === "non-zero-area") {
639
- return isZeroArea(node);
640
- }
641
- return false;
642
- };
643
- var isDisabledFromFieldset = function isDisabledFromFieldset2(node) {
644
- if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
645
- var parentNode = node.parentElement;
646
- while (parentNode) {
647
- if (parentNode.tagName === "FIELDSET" && parentNode.disabled) {
648
- for (var i = 0; i < parentNode.children.length; i++) {
649
- var child = parentNode.children.item(i);
650
- if (child.tagName === "LEGEND") {
651
- return matches.call(parentNode, "fieldset[disabled] *") ? true : !child.contains(node);
652
- }
653
- }
654
- return true;
655
- }
656
- parentNode = parentNode.parentElement;
657
- }
658
- }
659
- return false;
660
- };
661
- var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable2(options, node) {
662
- if (node.disabled || // we must do an inert look up to filter out any elements inside an inert ancestor
663
- // because we're limited in the type of selectors we can use in JSDom (see related
664
- // note related to `candidateSelectors`)
665
- isInert(node) || isHiddenInput(node) || isHidden(node, options) || // For a details element with a summary, the summary element gets the focus
666
- isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
667
- return false;
668
- }
669
- return true;
670
- };
671
- var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable2(options, node) {
672
- if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
673
- return false;
674
- }
675
- return true;
676
- };
677
- var isValidShadowRootTabbable = function isValidShadowRootTabbable2(shadowHostNode) {
678
- var tabIndex = parseInt(shadowHostNode.getAttribute("tabindex"), 10);
679
- if (isNaN(tabIndex) || tabIndex >= 0) {
680
- return true;
681
- }
682
- return false;
683
- };
684
- var sortByOrder = function sortByOrder2(candidates) {
685
- var regularTabbables = [];
686
- var orderedTabbables = [];
687
- candidates.forEach(function(item, i) {
688
- var isScope = !!item.scopeParent;
689
- var element = isScope ? item.scopeParent : item;
690
- var candidateTabindex = getSortOrderTabIndex(element, isScope);
691
- var elements = isScope ? sortByOrder2(item.candidates) : element;
692
- if (candidateTabindex === 0) {
693
- isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
694
- } else {
695
- orderedTabbables.push({
696
- documentOrder: i,
697
- tabIndex: candidateTabindex,
698
- item,
699
- isScope,
700
- content: elements
701
- });
702
- }
703
- });
704
- return orderedTabbables.sort(sortOrderedTabbables).reduce(function(acc, sortable) {
705
- sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
706
- return acc;
707
- }, []).concat(regularTabbables);
708
- };
709
- var tabbable = function tabbable2(container, options) {
710
- options = options || {};
711
- var candidates;
712
- if (options.getShadowRoot) {
713
- candidates = getCandidatesIteratively([container], options.includeContainer, {
714
- filter: isNodeMatchingSelectorTabbable.bind(null, options),
715
- flatten: false,
716
- getShadowRoot: options.getShadowRoot,
717
- shadowRootFilter: isValidShadowRootTabbable
718
- });
719
- } else {
720
- candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
721
- }
722
- return sortByOrder(candidates);
723
- };
724
- var focusable = function focusable2(container, options) {
725
- options = options || {};
726
- var candidates;
727
- if (options.getShadowRoot) {
728
- candidates = getCandidatesIteratively([container], options.includeContainer, {
729
- filter: isNodeMatchingSelectorFocusable.bind(null, options),
730
- flatten: true,
731
- getShadowRoot: options.getShadowRoot
732
- });
733
- } else {
734
- candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
735
- }
736
- return candidates;
737
- };
738
- var isTabbable = function isTabbable2(node, options) {
739
- options = options || {};
740
- if (!node) {
741
- throw new Error("No node provided");
742
- }
743
- if (matches.call(node, candidateSelector) === false) {
744
- return false;
745
- }
746
- return isNodeMatchingSelectorTabbable(options, node);
747
- };
748
- const getTabbableOptions = () => ({
749
- getShadowRoot: true,
750
- displayCheck: (
751
- // JSDOM does not support the `tabbable` library. To solve this we can
752
- // check if `ResizeObserver` is a real function (not polyfilled), which
753
- // determines if the current environment is JSDOM-like.
754
- typeof ResizeObserver === "function" && ResizeObserver.toString().includes("[native code]") ? "full" : "none"
755
- )
756
- });
757
- function getTabbableIn(container, dir) {
758
- const list = tabbable(container, getTabbableOptions());
759
- const len = list.length;
760
- if (len === 0) {
761
- return void 0;
762
- }
763
- const active = activeElement(getDocument(container));
764
- const index = list.indexOf(active);
765
- const nextIndex = index === -1 ? dir === 1 ? 0 : len - 1 : index + dir;
766
- return list[nextIndex];
767
- }
768
- function getNextTabbable(referenceElement) {
769
- return getTabbableIn(getDocument(referenceElement).body, 1) || referenceElement;
770
- }
771
- function getPreviousTabbable(referenceElement) {
772
- return getTabbableIn(getDocument(referenceElement).body, -1) || referenceElement;
773
- }
774
- function isOutsideEvent(event, container) {
775
- const containerElement = container || event.currentTarget;
776
- const relatedTarget = event.relatedTarget;
777
- return !relatedTarget || !contains(containerElement, relatedTarget);
778
- }
779
- function disableFocusInside(container) {
780
- const tabbableElements = tabbable(container, getTabbableOptions());
781
- tabbableElements.forEach((element) => {
782
- element.dataset.tabindex = element.getAttribute("tabindex") || "";
783
- element.setAttribute("tabindex", "-1");
784
- });
785
- }
786
- function enableFocusInside(container) {
787
- const elements = container.querySelectorAll("[data-tabindex]");
788
- elements.forEach((element) => {
789
- const tabindex = element.dataset.tabindex;
790
- delete element.dataset.tabindex;
791
- if (tabindex) {
792
- element.setAttribute("tabindex", tabindex);
793
- } else {
794
- element.removeAttribute("tabindex");
795
- }
796
- });
797
- }
798
- const ARROW_UP = "ArrowUp";
799
- const ARROW_DOWN = "ArrowDown";
800
- const ARROW_LEFT = "ArrowLeft";
801
- const ARROW_RIGHT = "ArrowRight";
802
- const HOME = "Home";
803
- const END = "End";
804
- const HORIZONTAL_KEYS = /* @__PURE__ */ new Set([ARROW_LEFT, ARROW_RIGHT]);
805
- const VERTICAL_KEYS = /* @__PURE__ */ new Set([ARROW_UP, ARROW_DOWN]);
806
- const ARROW_KEYS = /* @__PURE__ */ new Set([...HORIZONTAL_KEYS, ...VERTICAL_KEYS]);
807
- /* @__PURE__ */ new Set([...ARROW_KEYS, HOME, END]);
808
- const COMPOSITE_KEYS = /* @__PURE__ */ new Set([ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, HOME, END]);
809
- function useLatestRef(value) {
810
- const latest = useRefWithInit(createLatestRef, value).current;
811
- latest.next = value;
812
- useIsoLayoutEffect(latest.effect);
813
- return latest;
814
- }
815
- function createLatestRef(value) {
816
- const latest = {
817
- current: value,
818
- next: value,
819
- effect: () => {
820
- latest.current = latest.next;
821
- }
822
- };
823
- return latest;
824
- }
825
- function useOpenChangeComplete(parameters) {
826
- const {
827
- enabled = true,
828
- open,
829
- ref,
830
- onComplete: onCompleteParam
831
- } = parameters;
832
- const openRef = useLatestRef(open);
833
- const onComplete = useEventCallback(onCompleteParam);
834
- const runOnceAnimationsFinish = useAnimationsFinished(ref, open);
835
- React.useEffect(() => {
836
- if (!enabled) {
837
- return;
838
- }
839
- runOnceAnimationsFinish(() => {
840
- if (open === openRef.current) {
841
- onComplete();
842
- }
843
- });
844
- }, [enabled, open, onComplete, runOnceAnimationsFinish, openRef]);
845
- }
846
- let CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
847
- CommonPopupDataAttributes2["open"] = "data-open";
848
- CommonPopupDataAttributes2["closed"] = "data-closed";
849
- CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
850
- CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
851
- CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
852
- return CommonPopupDataAttributes2;
853
- })({});
854
- let CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
855
- CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
856
- CommonTriggerDataAttributes2["pressed"] = "data-pressed";
857
- return CommonTriggerDataAttributes2;
858
- })({});
859
- const TRIGGER_HOOK = {
860
- [CommonTriggerDataAttributes.popupOpen]: ""
861
- };
862
- const PRESSABLE_TRIGGER_HOOK = {
863
- [CommonTriggerDataAttributes.popupOpen]: "",
864
- [CommonTriggerDataAttributes.pressed]: ""
865
- };
866
- const POPUP_OPEN_HOOK = {
867
- [CommonPopupDataAttributes.open]: ""
868
- };
869
- const POPUP_CLOSED_HOOK = {
870
- [CommonPopupDataAttributes.closed]: ""
871
- };
872
- const ANCHOR_HIDDEN_HOOK = {
873
- [CommonPopupDataAttributes.anchorHidden]: ""
874
- };
875
- const triggerOpenStateMapping = {
876
- open(value) {
877
- if (value) {
878
- return TRIGGER_HOOK;
879
- }
880
- return null;
881
- }
882
- };
883
- const pressableTriggerOpenStateMapping = {
884
- open(value) {
885
- if (value) {
886
- return PRESSABLE_TRIGGER_HOOK;
887
- }
888
- return null;
889
- }
890
- };
891
- const popupStateMapping = {
892
- open(value) {
893
- if (value) {
894
- return POPUP_OPEN_HOOK;
895
- }
896
- return POPUP_CLOSED_HOOK;
897
- },
898
- anchorHidden(value) {
899
- if (value) {
900
- return ANCHOR_HIDDEN_HOOK;
901
- }
902
- return null;
903
- }
904
- };
905
- function inertValue(value) {
906
- if (isReactVersionAtLeast(19)) {
907
- return value;
908
- }
909
- return value ? "true" : void 0;
910
- }
911
- const EMPTY = 0;
912
- class Timeout {
913
- constructor() {
914
- __publicField(this, "currentId", /* @__PURE__ */ (() => EMPTY)());
915
- __publicField(this, "clear", () => {
916
- if (this.currentId !== EMPTY) {
917
- clearTimeout(this.currentId);
918
- this.currentId = EMPTY;
919
- }
920
- });
921
- __publicField(this, "disposeEffect", () => {
922
- return this.clear;
923
- });
924
- }
925
- static create() {
926
- return new Timeout();
927
- }
928
- /**
929
- * Executes `fn` after `delay`, clearing any previously scheduled call.
930
- */
931
- start(delay, fn) {
932
- this.clear();
933
- this.currentId = setTimeout(() => {
934
- this.currentId = EMPTY;
935
- fn();
936
- }, delay);
937
- }
938
- isStarted() {
939
- return this.currentId !== EMPTY;
940
- }
941
- }
942
- function useTimeout() {
943
- const timeout = useRefWithInit(Timeout.create).current;
944
- useOnMount(timeout.disposeEffect);
945
- return timeout;
946
- }
947
- function createEventEmitter() {
948
- const map = /* @__PURE__ */ new Map();
949
- return {
950
- emit(event, data) {
951
- var _a;
952
- (_a = map.get(event)) == null ? void 0 : _a.forEach((listener) => listener(data));
953
- },
954
- on(event, listener) {
955
- if (!map.has(event)) {
956
- map.set(event, /* @__PURE__ */ new Set());
957
- }
958
- map.get(event).add(listener);
959
- },
960
- off(event, listener) {
961
- var _a;
962
- (_a = map.get(event)) == null ? void 0 : _a.delete(listener);
963
- }
964
- };
965
- }
966
- const FloatingNodeContext = /* @__PURE__ */ React.createContext(null);
967
- if (process.env.NODE_ENV !== "production") FloatingNodeContext.displayName = "FloatingNodeContext";
968
- const FloatingTreeContext = /* @__PURE__ */ React.createContext(null);
969
- if (process.env.NODE_ENV !== "production") FloatingTreeContext.displayName = "FloatingTreeContext";
970
- const useFloatingParentNodeId = () => {
971
- var _a;
972
- return ((_a = React.useContext(FloatingNodeContext)) == null ? void 0 : _a.id) || null;
973
- };
974
- const useFloatingTree = () => React.useContext(FloatingTreeContext);
975
- function useFloatingNodeId(customParentId) {
976
- const id = useId();
977
- const tree = useFloatingTree();
978
- const reactParentId = useFloatingParentNodeId();
979
- const parentId = reactParentId;
980
- useIsoLayoutEffect(() => {
981
- if (!id) {
982
- return void 0;
983
- }
984
- const node = {
985
- id,
986
- parentId
987
- };
988
- tree == null ? void 0 : tree.addNode(node);
989
- return () => {
990
- tree == null ? void 0 : tree.removeNode(node);
991
- };
992
- }, [tree, id, parentId]);
993
- return id;
994
- }
995
- function FloatingNode(props) {
996
- const {
997
- children,
998
- id
999
- } = props;
1000
- const parentId = useFloatingParentNodeId();
1001
- return /* @__PURE__ */ jsx(FloatingNodeContext.Provider, {
1002
- value: React.useMemo(() => ({
1003
- id,
1004
- parentId
1005
- }), [id, parentId]),
1006
- children
1007
- });
1008
- }
1009
- function FloatingTree(props) {
1010
- const {
1011
- children
1012
- } = props;
1013
- const nodesRef = React.useRef([]);
1014
- const addNode = React.useCallback((node) => {
1015
- nodesRef.current = [...nodesRef.current, node];
1016
- }, []);
1017
- const removeNode = React.useCallback((node) => {
1018
- nodesRef.current = nodesRef.current.filter((n) => n !== node);
1019
- }, []);
1020
- const [events] = React.useState(() => createEventEmitter());
1021
- return /* @__PURE__ */ jsx(FloatingTreeContext.Provider, {
1022
- value: React.useMemo(() => ({
1023
- nodesRef,
1024
- addNode,
1025
- removeNode,
1026
- events
1027
- }), [addNode, removeNode, events]),
1028
- children
1029
- });
1030
- }
1031
- function createAttribute(name) {
1032
- return `data-base-ui-${name}`;
1033
- }
1034
- const visuallyHidden = {
1035
- clip: "rect(0 0 0 0)",
1036
- overflow: "hidden",
1037
- whiteSpace: "nowrap",
1038
- position: "fixed",
1039
- top: 0,
1040
- left: 0,
1041
- border: 0,
1042
- padding: 0,
1043
- width: 1,
1044
- height: 1,
1045
- margin: -1
1046
- };
1047
- function ownerDocument(node) {
1048
- return (node == null ? void 0 : node.ownerDocument) || document;
1049
- }
1050
- const FocusGuard = /* @__PURE__ */ React.forwardRef(function FocusGuard2(props, ref) {
1051
- const [role, setRole] = React.useState();
1052
- useIsoLayoutEffect(() => {
1053
- if (isSafari) {
1054
- setRole("button");
1055
- }
1056
- }, []);
1057
- const restProps = {
1058
- tabIndex: 0,
1059
- // Role is only for VoiceOver
1060
- role
1061
- };
1062
- return /* @__PURE__ */ jsx("span", {
1063
- ...props,
1064
- ref,
1065
- style: visuallyHidden,
1066
- "aria-hidden": role ? void 0 : true,
1067
- ...restProps,
1068
- "data-base-ui-focus-guard": ""
1069
- });
1070
- });
1071
- if (process.env.NODE_ENV !== "production") FocusGuard.displayName = "FocusGuard";
1072
- let rafId = 0;
1073
- function enqueueFocus(el, options = {}) {
1074
- const {
1075
- preventScroll = false,
1076
- cancelPrevious = true,
1077
- sync = false
1078
- } = options;
1079
- if (cancelPrevious) {
1080
- cancelAnimationFrame(rafId);
1081
- }
1082
- const exec = () => el == null ? void 0 : el.focus({
1083
- preventScroll
1084
- });
1085
- if (sync) {
1086
- exec();
1087
- } else {
1088
- rafId = requestAnimationFrame(exec);
1089
- }
1090
- }
1091
- const counters = {
1092
- inert: /* @__PURE__ */ new WeakMap(),
1093
- "aria-hidden": /* @__PURE__ */ new WeakMap(),
1094
- none: /* @__PURE__ */ new WeakMap()
1095
- };
1096
- function getCounterMap(control) {
1097
- if (control === "inert") {
1098
- return counters.inert;
1099
- }
1100
- if (control === "aria-hidden") {
1101
- return counters["aria-hidden"];
1102
- }
1103
- return counters.none;
1104
- }
1105
- let uncontrolledElementsSet = /* @__PURE__ */ new WeakSet();
1106
- let markerMap = {};
1107
- let lockCount = 0;
1108
- const unwrapHost = (node) => node && (node.host || unwrapHost(node.parentNode));
1109
- const correctElements = (parent, targets) => targets.map((target) => {
1110
- if (parent.contains(target)) {
1111
- return target;
1112
- }
1113
- const correctedTarget = unwrapHost(target);
1114
- if (parent.contains(correctedTarget)) {
1115
- return correctedTarget;
1116
- }
1117
- return null;
1118
- }).filter((x) => x != null);
1119
- function applyAttributeToOthers(uncorrectedAvoidElements, body, ariaHidden, inert) {
1120
- const markerName = "data-base-ui-inert";
1121
- const controlAttribute = inert ? "inert" : ariaHidden ? "aria-hidden" : null;
1122
- const avoidElements = correctElements(body, uncorrectedAvoidElements);
1123
- const elementsToKeep = /* @__PURE__ */ new Set();
1124
- const elementsToStop = new Set(avoidElements);
1125
- const hiddenElements = [];
1126
- if (!markerMap[markerName]) {
1127
- markerMap[markerName] = /* @__PURE__ */ new WeakMap();
1128
- }
1129
- const markerCounter = markerMap[markerName];
1130
- avoidElements.forEach(keep);
1131
- deep(body);
1132
- elementsToKeep.clear();
1133
- function keep(el) {
1134
- if (!el || elementsToKeep.has(el)) {
1135
- return;
1136
- }
1137
- elementsToKeep.add(el);
1138
- if (el.parentNode) {
1139
- keep(el.parentNode);
1140
- }
1141
- }
1142
- function deep(parent) {
1143
- if (!parent || elementsToStop.has(parent)) {
1144
- return;
1145
- }
1146
- [].forEach.call(parent.children, (node) => {
1147
- if (getNodeName(node) === "script") {
1148
- return;
1149
- }
1150
- if (elementsToKeep.has(node)) {
1151
- deep(node);
1152
- } else {
1153
- const attr2 = controlAttribute ? node.getAttribute(controlAttribute) : null;
1154
- const alreadyHidden = attr2 !== null && attr2 !== "false";
1155
- const counterMap = getCounterMap(controlAttribute);
1156
- const counterValue = (counterMap.get(node) || 0) + 1;
1157
- const markerValue = (markerCounter.get(node) || 0) + 1;
1158
- counterMap.set(node, counterValue);
1159
- markerCounter.set(node, markerValue);
1160
- hiddenElements.push(node);
1161
- if (counterValue === 1 && alreadyHidden) {
1162
- uncontrolledElementsSet.add(node);
1163
- }
1164
- if (markerValue === 1) {
1165
- node.setAttribute(markerName, "");
1166
- }
1167
- if (!alreadyHidden && controlAttribute) {
1168
- node.setAttribute(controlAttribute, controlAttribute === "inert" ? "" : "true");
1169
- }
1170
- }
1171
- });
1172
- }
1173
- lockCount += 1;
1174
- return () => {
1175
- hiddenElements.forEach((element) => {
1176
- const counterMap = getCounterMap(controlAttribute);
1177
- const currentCounterValue = counterMap.get(element) || 0;
1178
- const counterValue = currentCounterValue - 1;
1179
- const markerValue = (markerCounter.get(element) || 0) - 1;
1180
- counterMap.set(element, counterValue);
1181
- markerCounter.set(element, markerValue);
1182
- if (!counterValue) {
1183
- if (!uncontrolledElementsSet.has(element) && controlAttribute) {
1184
- element.removeAttribute(controlAttribute);
1185
- }
1186
- uncontrolledElementsSet.delete(element);
1187
- }
1188
- if (!markerValue) {
1189
- element.removeAttribute(markerName);
1190
- }
1191
- });
1192
- lockCount -= 1;
1193
- if (!lockCount) {
1194
- counters.inert = /* @__PURE__ */ new WeakMap();
1195
- counters["aria-hidden"] = /* @__PURE__ */ new WeakMap();
1196
- counters.none = /* @__PURE__ */ new WeakMap();
1197
- uncontrolledElementsSet = /* @__PURE__ */ new WeakSet();
1198
- markerMap = {};
1199
- }
1200
- };
1201
- }
1202
- function markOthers(avoidElements, ariaHidden = false, inert = false) {
1203
- const body = getDocument(avoidElements[0]).body;
1204
- return applyAttributeToOthers(avoidElements.concat(Array.from(body.querySelectorAll("[aria-live]"))), body, ariaHidden, inert);
1205
- }
1206
- const PortalContext = /* @__PURE__ */ React.createContext(null);
1207
- if (process.env.NODE_ENV !== "production") PortalContext.displayName = "PortalContext";
1208
- const usePortalContext = () => React.useContext(PortalContext);
1209
- const attr = createAttribute("portal");
1210
- function useFloatingPortalNode(props = {}) {
1211
- const {
1212
- id,
1213
- root
1214
- } = props;
1215
- const uniqueId = useId();
1216
- const portalContext = usePortalContext();
1217
- const [portalNode, setPortalNode] = React.useState(null);
1218
- const portalNodeRef = React.useRef(null);
1219
- useIsoLayoutEffect(() => {
1220
- return () => {
1221
- portalNode == null ? void 0 : portalNode.remove();
1222
- queueMicrotask(() => {
1223
- portalNodeRef.current = null;
1224
- });
1225
- };
1226
- }, [portalNode]);
1227
- useIsoLayoutEffect(() => {
1228
- if (!uniqueId) {
1229
- return;
1230
- }
1231
- if (portalNodeRef.current) {
1232
- return;
1233
- }
1234
- const existingIdRoot = id ? document.getElementById(id) : null;
1235
- if (!existingIdRoot) {
1236
- return;
1237
- }
1238
- const subRoot = document.createElement("div");
1239
- subRoot.id = uniqueId;
1240
- subRoot.setAttribute(attr, "");
1241
- existingIdRoot.appendChild(subRoot);
1242
- portalNodeRef.current = subRoot;
1243
- setPortalNode(subRoot);
1244
- }, [id, uniqueId]);
1245
- useIsoLayoutEffect(() => {
1246
- if (root === null) {
1247
- return;
1248
- }
1249
- if (!uniqueId) {
1250
- return;
1251
- }
1252
- if (portalNodeRef.current) {
1253
- return;
1254
- }
1255
- let container = root || (portalContext == null ? void 0 : portalContext.portalNode);
1256
- if (container && !isNode(container)) {
1257
- container = container.current;
1258
- }
1259
- container = container || document.body;
1260
- let idWrapper = null;
1261
- if (id) {
1262
- idWrapper = document.createElement("div");
1263
- idWrapper.id = id;
1264
- container.appendChild(idWrapper);
1265
- }
1266
- const subRoot = document.createElement("div");
1267
- subRoot.id = uniqueId;
1268
- subRoot.setAttribute(attr, "");
1269
- container = idWrapper || container;
1270
- container.appendChild(subRoot);
1271
- portalNodeRef.current = subRoot;
1272
- setPortalNode(subRoot);
1273
- }, [id, root, uniqueId, portalContext]);
1274
- return portalNode;
1275
- }
1276
- function FloatingPortal(props) {
1277
- const {
1278
- children,
1279
- id,
1280
- root,
1281
- preserveTabOrder = true
1282
- } = props;
1283
- const portalNode = useFloatingPortalNode({
1284
- id,
1285
- root
1286
- });
1287
- const [focusManagerState, setFocusManagerState] = React.useState(null);
1288
- const beforeOutsideRef = React.useRef(null);
1289
- const afterOutsideRef = React.useRef(null);
1290
- const beforeInsideRef = React.useRef(null);
1291
- const afterInsideRef = React.useRef(null);
1292
- const modal = focusManagerState == null ? void 0 : focusManagerState.modal;
1293
- const open = focusManagerState == null ? void 0 : focusManagerState.open;
1294
- const shouldRenderGuards = (
1295
- // The FocusManager and therefore floating element are currently open/
1296
- // rendered.
1297
- !!focusManagerState && // Guards are only for non-modal focus management.
1298
- !focusManagerState.modal && // Don't render if unmount is transitioning.
1299
- focusManagerState.open && preserveTabOrder && !!(root || portalNode)
1300
- );
1301
- React.useEffect(() => {
1302
- if (!portalNode || !preserveTabOrder || modal) {
1303
- return void 0;
1304
- }
1305
- function onFocus(event) {
1306
- if (portalNode && isOutsideEvent(event)) {
1307
- const focusing = event.type === "focusin";
1308
- const manageFocus = focusing ? enableFocusInside : disableFocusInside;
1309
- manageFocus(portalNode);
1310
- }
1311
- }
1312
- portalNode.addEventListener("focusin", onFocus, true);
1313
- portalNode.addEventListener("focusout", onFocus, true);
1314
- return () => {
1315
- portalNode.removeEventListener("focusin", onFocus, true);
1316
- portalNode.removeEventListener("focusout", onFocus, true);
1317
- };
1318
- }, [portalNode, preserveTabOrder, modal]);
1319
- React.useEffect(() => {
1320
- if (!portalNode) {
1321
- return;
1322
- }
1323
- if (open) {
1324
- return;
1325
- }
1326
- enableFocusInside(portalNode);
1327
- }, [open, portalNode]);
1328
- return /* @__PURE__ */ jsxs(PortalContext.Provider, {
1329
- value: React.useMemo(() => ({
1330
- preserveTabOrder,
1331
- beforeOutsideRef,
1332
- afterOutsideRef,
1333
- beforeInsideRef,
1334
- afterInsideRef,
1335
- portalNode,
1336
- setFocusManagerState
1337
- }), [preserveTabOrder, portalNode]),
1338
- children: [shouldRenderGuards && portalNode && /* @__PURE__ */ jsx(FocusGuard, {
1339
- "data-type": "outside",
1340
- ref: beforeOutsideRef,
1341
- onFocus: (event) => {
1342
- var _a;
1343
- if (isOutsideEvent(event, portalNode)) {
1344
- (_a = beforeInsideRef.current) == null ? void 0 : _a.focus();
1345
- } else {
1346
- const domReference = focusManagerState ? focusManagerState.domReference : null;
1347
- const prevTabbable = getPreviousTabbable(domReference);
1348
- prevTabbable == null ? void 0 : prevTabbable.focus();
1349
- }
1350
- }
1351
- }), shouldRenderGuards && portalNode && /* @__PURE__ */ jsx("span", {
1352
- "aria-owns": portalNode.id,
1353
- style: visuallyHidden
1354
- }), portalNode && /* @__PURE__ */ ReactDOM.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ jsx(FocusGuard, {
1355
- "data-type": "outside",
1356
- ref: afterOutsideRef,
1357
- onFocus: (event) => {
1358
- var _a;
1359
- if (isOutsideEvent(event, portalNode)) {
1360
- (_a = afterInsideRef.current) == null ? void 0 : _a.focus();
1361
- } else {
1362
- const domReference = focusManagerState ? focusManagerState.domReference : null;
1363
- const nextTabbable = getNextTabbable(domReference);
1364
- nextTabbable == null ? void 0 : nextTabbable.focus();
1365
- if (focusManagerState == null ? void 0 : focusManagerState.closeOnFocusOut) {
1366
- focusManagerState == null ? void 0 : focusManagerState.onOpenChange(false, createChangeEventDetails("focus-out", event.nativeEvent));
1367
- }
1368
- }
1369
- }
1370
- })]
1371
- });
1372
- }
1373
- function getEventType(event, lastInteractionType) {
1374
- const win = getWindow(event.target);
1375
- if (event instanceof win.KeyboardEvent) {
1376
- return "keyboard";
1377
- }
1378
- if (event instanceof win.FocusEvent) {
1379
- return lastInteractionType || "keyboard";
1380
- }
1381
- if ("pointerType" in event) {
1382
- return event.pointerType || "keyboard";
1383
- }
1384
- if ("touches" in event) {
1385
- return "touch";
1386
- }
1387
- if (event instanceof win.MouseEvent) {
1388
- return lastInteractionType || (event.detail === 0 ? "keyboard" : "mouse");
1389
- }
1390
- return "";
1391
- }
1392
- const LIST_LIMIT = 20;
1393
- let previouslyFocusedElements = [];
1394
- function clearDisconnectedPreviouslyFocusedElements() {
1395
- previouslyFocusedElements = previouslyFocusedElements.filter((el) => el.isConnected);
1396
- }
1397
- function addPreviouslyFocusedElement(element) {
1398
- clearDisconnectedPreviouslyFocusedElements();
1399
- if (element && getNodeName(element) !== "body") {
1400
- previouslyFocusedElements.push(element);
1401
- if (previouslyFocusedElements.length > LIST_LIMIT) {
1402
- previouslyFocusedElements = previouslyFocusedElements.slice(-LIST_LIMIT);
1403
- }
1404
- }
1405
- }
1406
- function getPreviouslyFocusedElement() {
1407
- clearDisconnectedPreviouslyFocusedElements();
1408
- return previouslyFocusedElements[previouslyFocusedElements.length - 1];
1409
- }
1410
- function getFirstTabbableElement(container) {
1411
- if (!container) {
1412
- return null;
1413
- }
1414
- const tabbableOptions = getTabbableOptions();
1415
- if (isTabbable(container, tabbableOptions)) {
1416
- return container;
1417
- }
1418
- return tabbable(container, tabbableOptions)[0] || container;
1419
- }
1420
- function handleTabIndex(floatingFocusElement, orderRef) {
1421
- var _a;
1422
- if (!orderRef.current.includes("floating") && !((_a = floatingFocusElement.getAttribute("role")) == null ? void 0 : _a.includes("dialog"))) {
1423
- return;
1424
- }
1425
- const options = getTabbableOptions();
1426
- const focusableElements = focusable(floatingFocusElement, options);
1427
- const tabbableContent = focusableElements.filter((element) => {
1428
- const dataTabIndex = element.getAttribute("data-tabindex") || "";
1429
- return isTabbable(element, options) || element.hasAttribute("data-tabindex") && !dataTabIndex.startsWith("-");
1430
- });
1431
- const tabIndex = floatingFocusElement.getAttribute("tabindex");
1432
- if (orderRef.current.includes("floating") || tabbableContent.length === 0) {
1433
- if (tabIndex !== "0") {
1434
- floatingFocusElement.setAttribute("tabindex", "0");
1435
- }
1436
- } else if (tabIndex !== "-1" || floatingFocusElement.hasAttribute("data-tabindex") && floatingFocusElement.getAttribute("data-tabindex") !== "-1") {
1437
- floatingFocusElement.setAttribute("tabindex", "-1");
1438
- floatingFocusElement.setAttribute("data-tabindex", "-1");
1439
- }
1440
- }
1441
- function FloatingFocusManager(props) {
1442
- const {
1443
- context,
1444
- children,
1445
- disabled = false,
1446
- order = ["content"],
1447
- initialFocus = true,
1448
- returnFocus = true,
1449
- restoreFocus = false,
1450
- modal = true,
1451
- closeOnFocusOut = true,
1452
- openInteractionType = "",
1453
- getInsideElements: getInsideElementsProp = () => []
1454
- } = props;
1455
- const {
1456
- open,
1457
- onOpenChange,
1458
- events,
1459
- dataRef,
1460
- elements: {
1461
- domReference,
1462
- floating
1463
- }
1464
- } = context;
1465
- const getNodeId = useEventCallback(() => {
1466
- var _a;
1467
- return (_a = dataRef.current.floatingContext) == null ? void 0 : _a.nodeId;
1468
- });
1469
- const getInsideElements = useEventCallback(getInsideElementsProp);
1470
- const ignoreInitialFocus = initialFocus === false;
1471
- const isUntrappedTypeableCombobox = isTypeableCombobox(domReference) && ignoreInitialFocus;
1472
- const orderRef = useLatestRef(order);
1473
- const initialFocusRef = useLatestRef(initialFocus);
1474
- const returnFocusRef = useLatestRef(returnFocus);
1475
- const openInteractionTypeRef = useLatestRef(openInteractionType);
1476
- const tree = useFloatingTree();
1477
- const portalContext = usePortalContext();
1478
- const startDismissButtonRef = React.useRef(null);
1479
- const endDismissButtonRef = React.useRef(null);
1480
- const preventReturnFocusRef = React.useRef(false);
1481
- const isPointerDownRef = React.useRef(false);
1482
- const tabbableIndexRef = React.useRef(-1);
1483
- const closeTypeRef = React.useRef("");
1484
- const lastInteractionTypeRef = React.useRef("");
1485
- const blurTimeout = useTimeout();
1486
- const pointerDownTimeout = useTimeout();
1487
- const restoreFocusFrame = useAnimationFrame();
1488
- const isInsidePortal = portalContext != null;
1489
- const floatingFocusElement = getFloatingFocusElement(floating);
1490
- const getTabbableContent = useEventCallback((container = floatingFocusElement) => {
1491
- return container ? tabbable(container, getTabbableOptions()) : [];
1492
- });
1493
- const getTabbableElements = useEventCallback((container) => {
1494
- const content = getTabbableContent(container);
1495
- return orderRef.current.map(() => content).filter(Boolean).flat();
1496
- });
1497
- React.useEffect(() => {
1498
- if (disabled) {
1499
- return void 0;
1500
- }
1501
- if (!modal) {
1502
- return void 0;
1503
- }
1504
- function onKeyDown(event) {
1505
- if (event.key === "Tab") {
1506
- if (contains(floatingFocusElement, activeElement(getDocument(floatingFocusElement))) && getTabbableContent().length === 0 && !isUntrappedTypeableCombobox) {
1507
- stopEvent(event);
1508
- }
1509
- }
1510
- }
1511
- const doc = getDocument(floatingFocusElement);
1512
- doc.addEventListener("keydown", onKeyDown);
1513
- return () => {
1514
- doc.removeEventListener("keydown", onKeyDown);
1515
- };
1516
- }, [disabled, domReference, floatingFocusElement, modal, orderRef, isUntrappedTypeableCombobox, getTabbableContent, getTabbableElements]);
1517
- React.useEffect(() => {
1518
- if (disabled) {
1519
- return void 0;
1520
- }
1521
- if (!floating) {
1522
- return void 0;
1523
- }
1524
- function handleFocusIn(event) {
1525
- const target = getTarget(event);
1526
- const tabbableContent = getTabbableContent();
1527
- const tabbableIndex = tabbableContent.indexOf(target);
1528
- if (tabbableIndex !== -1) {
1529
- tabbableIndexRef.current = tabbableIndex;
1530
- }
1531
- }
1532
- floating.addEventListener("focusin", handleFocusIn);
1533
- return () => {
1534
- floating.removeEventListener("focusin", handleFocusIn);
1535
- };
1536
- }, [disabled, floating, getTabbableContent]);
1537
- React.useEffect(() => {
1538
- if (disabled || !open) {
1539
- return void 0;
1540
- }
1541
- const doc = getDocument(floatingFocusElement);
1542
- function onPointerDown(event) {
1543
- lastInteractionTypeRef.current = event.pointerType || "keyboard";
1544
- }
1545
- function onKeyDown() {
1546
- lastInteractionTypeRef.current = "keyboard";
1547
- }
1548
- doc.addEventListener("pointerdown", onPointerDown, true);
1549
- doc.addEventListener("keydown", onKeyDown, true);
1550
- return () => {
1551
- doc.removeEventListener("pointerdown", onPointerDown, true);
1552
- doc.removeEventListener("keydown", onKeyDown, true);
1553
- };
1554
- }, [disabled, floating, domReference, floatingFocusElement, open]);
1555
- React.useEffect(() => {
1556
- if (disabled) {
1557
- return void 0;
1558
- }
1559
- if (!closeOnFocusOut) {
1560
- return void 0;
1561
- }
1562
- function handlePointerDown() {
1563
- isPointerDownRef.current = true;
1564
- pointerDownTimeout.start(0, () => {
1565
- isPointerDownRef.current = false;
1566
- });
1567
- }
1568
- function handleFocusOutside(event) {
1569
- const relatedTarget = event.relatedTarget;
1570
- const currentTarget = event.currentTarget;
1571
- const target = getTarget(event);
1572
- queueMicrotask(() => {
1573
- const nodeId = getNodeId();
1574
- const movedToUnrelatedNode = !(contains(domReference, relatedTarget) || contains(floating, relatedTarget) || contains(relatedTarget, floating) || contains(portalContext == null ? void 0 : portalContext.portalNode, relatedTarget) || (relatedTarget == null ? void 0 : relatedTarget.hasAttribute(createAttribute("focus-guard"))) || tree && (getNodeChildren(tree.nodesRef.current, nodeId).find((node) => {
1575
- var _a, _b;
1576
- return contains((_a = node.context) == null ? void 0 : _a.elements.floating, relatedTarget) || contains((_b = node.context) == null ? void 0 : _b.elements.domReference, relatedTarget);
1577
- }) || getNodeAncestors(tree.nodesRef.current, nodeId).find((node) => {
1578
- var _a, _b, _c;
1579
- return [(_a = node.context) == null ? void 0 : _a.elements.floating, getFloatingFocusElement((_b = node.context) == null ? void 0 : _b.elements.floating)].includes(relatedTarget) || ((_c = node.context) == null ? void 0 : _c.elements.domReference) === relatedTarget;
1580
- })));
1581
- if (currentTarget === domReference && floatingFocusElement) {
1582
- handleTabIndex(floatingFocusElement, orderRef);
1583
- }
1584
- if (restoreFocus && currentTarget !== domReference && !(target == null ? void 0 : target.isConnected) && activeElement(getDocument(floatingFocusElement)) === getDocument(floatingFocusElement).body) {
1585
- if (isHTMLElement(floatingFocusElement)) {
1586
- floatingFocusElement.focus();
1587
- if (restoreFocus === "popup") {
1588
- restoreFocusFrame.request(() => {
1589
- floatingFocusElement.focus();
1590
- });
1591
- return;
1592
- }
1593
- }
1594
- const prevTabbableIndex = tabbableIndexRef.current;
1595
- const tabbableContent = getTabbableContent();
1596
- const nodeToFocus = tabbableContent[prevTabbableIndex] || tabbableContent[tabbableContent.length - 1] || floatingFocusElement;
1597
- if (isHTMLElement(nodeToFocus)) {
1598
- nodeToFocus.focus();
1599
- }
1600
- }
1601
- if (dataRef.current.insideReactTree) {
1602
- dataRef.current.insideReactTree = false;
1603
- return;
1604
- }
1605
- if ((isUntrappedTypeableCombobox ? true : !modal) && relatedTarget && movedToUnrelatedNode && // Fix React 18 Strict Mode returnFocus due to double rendering.
1606
- // For an "untrapped" typeable combobox (input role=combobox with
1607
- // initialFocus=false), re-opening the popup and tabbing out should still close it even
1608
- // when the previously focused element (e.g. the next tabbable outside the popup) is
1609
- // focused again. Otherwise, the popup remains open on the second Tab sequence:
1610
- // click input -> Tab (closes) -> click input -> Tab.
1611
- // Allow closing when `isUntrappedTypeableCombobox` regardless of the previously focused element.
1612
- (isUntrappedTypeableCombobox || relatedTarget !== getPreviouslyFocusedElement())) {
1613
- preventReturnFocusRef.current = true;
1614
- onOpenChange(false, createChangeEventDetails("focus-out", event));
1615
- }
1616
- });
1617
- }
1618
- function markInsideReactTree() {
1619
- dataRef.current.insideReactTree = true;
1620
- blurTimeout.start(0, () => {
1621
- dataRef.current.insideReactTree = false;
1622
- });
1623
- }
1624
- if (floating && isHTMLElement(domReference)) {
1625
- domReference.addEventListener("focusout", handleFocusOutside);
1626
- domReference.addEventListener("pointerdown", handlePointerDown);
1627
- floating.addEventListener("focusout", handleFocusOutside);
1628
- if (portalContext) {
1629
- floating.addEventListener("focusout", markInsideReactTree, true);
1630
- }
1631
- return () => {
1632
- domReference.removeEventListener("focusout", handleFocusOutside);
1633
- domReference.removeEventListener("pointerdown", handlePointerDown);
1634
- floating.removeEventListener("focusout", handleFocusOutside);
1635
- if (portalContext) {
1636
- floating.removeEventListener("focusout", markInsideReactTree, true);
1637
- }
1638
- };
1639
- }
1640
- return void 0;
1641
- }, [disabled, domReference, floating, floatingFocusElement, modal, tree, portalContext, onOpenChange, closeOnFocusOut, restoreFocus, getTabbableContent, isUntrappedTypeableCombobox, getNodeId, orderRef, dataRef, blurTimeout, pointerDownTimeout, restoreFocusFrame]);
1642
- const beforeGuardRef = React.useRef(null);
1643
- const afterGuardRef = React.useRef(null);
1644
- const mergedBeforeGuardRef = useMergedRefs(beforeGuardRef, portalContext == null ? void 0 : portalContext.beforeInsideRef);
1645
- const mergedAfterGuardRef = useMergedRefs(afterGuardRef, portalContext == null ? void 0 : portalContext.afterInsideRef);
1646
- React.useEffect(() => {
1647
- var _a, _b, _c;
1648
- if (disabled || !floating || !open) {
1649
- return void 0;
1650
- }
1651
- const portalNodes = Array.from(((_a = portalContext == null ? void 0 : portalContext.portalNode) == null ? void 0 : _a.querySelectorAll(`[${createAttribute("portal")}]`)) || []);
1652
- const ancestors = tree ? getNodeAncestors(tree.nodesRef.current, getNodeId()) : [];
1653
- const rootAncestorComboboxDomReference = (_c = (_b = ancestors.find((node) => {
1654
- var _a2;
1655
- return isTypeableCombobox(((_a2 = node.context) == null ? void 0 : _a2.elements.domReference) || null);
1656
- })) == null ? void 0 : _b.context) == null ? void 0 : _c.elements.domReference;
1657
- const insideElements = [floating, rootAncestorComboboxDomReference, ...portalNodes, ...getInsideElements(), startDismissButtonRef.current, endDismissButtonRef.current, beforeGuardRef.current, afterGuardRef.current, portalContext == null ? void 0 : portalContext.beforeOutsideRef.current, portalContext == null ? void 0 : portalContext.afterOutsideRef.current, isUntrappedTypeableCombobox ? domReference : null].filter((x) => x != null);
1658
- const cleanup = markOthers(insideElements, modal || isUntrappedTypeableCombobox);
1659
- return () => {
1660
- cleanup();
1661
- };
1662
- }, [open, disabled, domReference, floating, modal, orderRef, portalContext, isUntrappedTypeableCombobox, tree, getNodeId, getInsideElements]);
1663
- useIsoLayoutEffect(() => {
1664
- if (disabled || !isHTMLElement(floatingFocusElement)) {
1665
- return;
1666
- }
1667
- const doc = getDocument(floatingFocusElement);
1668
- const previouslyFocusedElement = activeElement(doc);
1669
- queueMicrotask(() => {
1670
- const focusableElements = getTabbableElements(floatingFocusElement);
1671
- const initialFocusValueOrFn = initialFocusRef.current;
1672
- const resolvedInitialFocus = typeof initialFocusValueOrFn === "function" ? initialFocusValueOrFn(openInteractionTypeRef.current || "") : initialFocusValueOrFn;
1673
- if (resolvedInitialFocus === void 0 || resolvedInitialFocus === false) {
1674
- return;
1675
- }
1676
- let elToFocus;
1677
- if (resolvedInitialFocus === true || resolvedInitialFocus === null) {
1678
- elToFocus = focusableElements[0] || floatingFocusElement;
1679
- } else if ("current" in resolvedInitialFocus) {
1680
- elToFocus = resolvedInitialFocus.current;
1681
- } else {
1682
- elToFocus = resolvedInitialFocus;
1683
- }
1684
- elToFocus = elToFocus || focusableElements[0] || floatingFocusElement;
1685
- const focusAlreadyInsideFloatingEl = contains(floatingFocusElement, previouslyFocusedElement);
1686
- if (!focusAlreadyInsideFloatingEl && open) {
1687
- enqueueFocus(elToFocus, {
1688
- preventScroll: elToFocus === floatingFocusElement
1689
- });
1690
- }
1691
- });
1692
- }, [disabled, open, floatingFocusElement, ignoreInitialFocus, getTabbableElements, initialFocusRef, openInteractionTypeRef]);
1693
- useIsoLayoutEffect(() => {
1694
- if (disabled || !floatingFocusElement) {
1695
- return void 0;
1696
- }
1697
- const doc = getDocument(floatingFocusElement);
1698
- const previouslyFocusedElement = activeElement(doc);
1699
- addPreviouslyFocusedElement(previouslyFocusedElement);
1700
- function onOpenChangeLocal(details) {
1701
- if (!details.open) {
1702
- closeTypeRef.current = getEventType(details.nativeEvent, lastInteractionTypeRef.current);
1703
- }
1704
- if (details.reason === "trigger-hover" && details.nativeEvent.type === "mouseleave") {
1705
- preventReturnFocusRef.current = true;
1706
- }
1707
- if (details.reason !== "outside-press") {
1708
- return;
1709
- }
1710
- if (details.nested) {
1711
- preventReturnFocusRef.current = false;
1712
- } else if (isVirtualClick(details.nativeEvent) || isVirtualPointerEvent(details.nativeEvent)) {
1713
- preventReturnFocusRef.current = false;
1714
- } else {
1715
- let isPreventScrollSupported = false;
1716
- document.createElement("div").focus({
1717
- get preventScroll() {
1718
- isPreventScrollSupported = true;
1719
- return false;
1720
- }
1721
- });
1722
- if (isPreventScrollSupported) {
1723
- preventReturnFocusRef.current = false;
1724
- } else {
1725
- preventReturnFocusRef.current = true;
1726
- }
1727
- }
1728
- }
1729
- events.on("openchange", onOpenChangeLocal);
1730
- const fallbackEl = doc.createElement("span");
1731
- fallbackEl.setAttribute("tabindex", "-1");
1732
- fallbackEl.setAttribute("aria-hidden", "true");
1733
- Object.assign(fallbackEl.style, visuallyHidden);
1734
- if (isInsidePortal && domReference) {
1735
- domReference.insertAdjacentElement("afterend", fallbackEl);
1736
- }
1737
- function getReturnElement() {
1738
- const returnFocusValueOrFn = returnFocusRef.current;
1739
- let resolvedReturnFocusValue = typeof returnFocusValueOrFn === "function" ? returnFocusValueOrFn(closeTypeRef.current) : returnFocusValueOrFn;
1740
- if (resolvedReturnFocusValue === void 0 || resolvedReturnFocusValue === false) {
1741
- return null;
1742
- }
1743
- if (resolvedReturnFocusValue === null) {
1744
- resolvedReturnFocusValue = true;
1745
- }
1746
- if (typeof resolvedReturnFocusValue === "boolean") {
1747
- const el = domReference || getPreviouslyFocusedElement();
1748
- return el && el.isConnected ? el : fallbackEl;
1749
- }
1750
- const fallback = domReference || getPreviouslyFocusedElement() || fallbackEl;
1751
- if ("current" in resolvedReturnFocusValue) {
1752
- return resolvedReturnFocusValue.current || fallback;
1753
- }
1754
- return resolvedReturnFocusValue || fallback;
1755
- }
1756
- return () => {
1757
- events.off("openchange", onOpenChangeLocal);
1758
- const activeEl = activeElement(doc);
1759
- const isFocusInsideFloatingTree = contains(floating, activeEl) || tree && getNodeChildren(tree.nodesRef.current, getNodeId(), false).some((node) => {
1760
- var _a;
1761
- return contains((_a = node.context) == null ? void 0 : _a.elements.floating, activeEl);
1762
- });
1763
- const returnElement = getReturnElement();
1764
- queueMicrotask(() => {
1765
- const tabbableReturnElement = getFirstTabbableElement(returnElement);
1766
- const hasExplicitReturnFocus = typeof returnFocusRef.current !== "boolean";
1767
- if (
1768
- // eslint-disable-next-line react-hooks/exhaustive-deps
1769
- returnFocusRef.current && !preventReturnFocusRef.current && isHTMLElement(tabbableReturnElement) && // If the focus moved somewhere else after mount, avoid returning focus
1770
- // since it likely entered a different element which should be
1771
- // respected: https://github.com/floating-ui/floating-ui/issues/2607
1772
- (!hasExplicitReturnFocus && tabbableReturnElement !== activeEl && activeEl !== doc.body ? isFocusInsideFloatingTree : true)
1773
- ) {
1774
- tabbableReturnElement.focus({
1775
- preventScroll: true
1776
- });
1777
- }
1778
- fallbackEl.remove();
1779
- });
1780
- };
1781
- }, [disabled, floating, floatingFocusElement, returnFocusRef, dataRef, events, tree, isInsidePortal, domReference, getNodeId]);
1782
- React.useEffect(() => {
1783
- queueMicrotask(() => {
1784
- preventReturnFocusRef.current = false;
1785
- });
1786
- }, [disabled]);
1787
- React.useEffect(() => {
1788
- if (disabled || !open) {
1789
- return void 0;
1790
- }
1791
- function handlePointerDown(event) {
1792
- const target = getTarget(event);
1793
- if (target == null ? void 0 : target.closest(`[${CLICK_TRIGGER_IDENTIFIER}]`)) {
1794
- isPointerDownRef.current = true;
1795
- }
1796
- }
1797
- const doc = getDocument(floatingFocusElement);
1798
- doc.addEventListener("pointerdown", handlePointerDown, true);
1799
- return () => {
1800
- doc.removeEventListener("pointerdown", handlePointerDown, true);
1801
- };
1802
- }, [disabled, open, floatingFocusElement]);
1803
- useIsoLayoutEffect(() => {
1804
- if (disabled) {
1805
- return void 0;
1806
- }
1807
- if (!portalContext) {
1808
- return void 0;
1809
- }
1810
- portalContext.setFocusManagerState({
1811
- modal,
1812
- closeOnFocusOut,
1813
- open,
1814
- onOpenChange,
1815
- domReference
1816
- });
1817
- return () => {
1818
- portalContext.setFocusManagerState(null);
1819
- };
1820
- }, [disabled, portalContext, modal, open, onOpenChange, closeOnFocusOut, domReference]);
1821
- useIsoLayoutEffect(() => {
1822
- if (disabled || !floatingFocusElement) {
1823
- return void 0;
1824
- }
1825
- handleTabIndex(floatingFocusElement, orderRef);
1826
- return () => {
1827
- queueMicrotask(clearDisconnectedPreviouslyFocusedElements);
1828
- };
1829
- }, [disabled, floatingFocusElement, orderRef]);
1830
- const shouldRenderGuards = !disabled && (modal ? !isUntrappedTypeableCombobox : true) && (isInsidePortal || modal);
1831
- return /* @__PURE__ */ jsxs(React.Fragment, {
1832
- children: [shouldRenderGuards && /* @__PURE__ */ jsx(FocusGuard, {
1833
- "data-type": "inside",
1834
- ref: mergedBeforeGuardRef,
1835
- onFocus: (event) => {
1836
- var _a;
1837
- if (modal) {
1838
- const els = getTabbableElements();
1839
- enqueueFocus(els[els.length - 1]);
1840
- } else if ((portalContext == null ? void 0 : portalContext.preserveTabOrder) && portalContext.portalNode) {
1841
- preventReturnFocusRef.current = false;
1842
- if (isOutsideEvent(event, portalContext.portalNode)) {
1843
- const nextTabbable = getNextTabbable(domReference);
1844
- nextTabbable == null ? void 0 : nextTabbable.focus();
1845
- } else {
1846
- (_a = portalContext.beforeOutsideRef.current) == null ? void 0 : _a.focus();
1847
- }
1848
- }
1849
- }
1850
- }), children, shouldRenderGuards && /* @__PURE__ */ jsx(FocusGuard, {
1851
- "data-type": "inside",
1852
- ref: mergedAfterGuardRef,
1853
- onFocus: (event) => {
1854
- var _a;
1855
- if (modal) {
1856
- enqueueFocus(getTabbableElements()[0]);
1857
- } else if ((portalContext == null ? void 0 : portalContext.preserveTabOrder) && portalContext.portalNode) {
1858
- if (closeOnFocusOut) {
1859
- preventReturnFocusRef.current = true;
1860
- }
1861
- if (isOutsideEvent(event, portalContext.portalNode)) {
1862
- const prevTabbable = getPreviousTabbable(domReference);
1863
- prevTabbable == null ? void 0 : prevTabbable.focus();
1864
- } else {
1865
- (_a = portalContext.afterOutsideRef.current) == null ? void 0 : _a.focus();
1866
- }
1867
- }
1868
- }
1869
- })]
1870
- });
1871
- }
1872
- function useClick(context, props = {}) {
1873
- const {
1874
- open,
1875
- onOpenChange,
1876
- dataRef
1877
- } = context;
1878
- const {
1879
- enabled = true,
1880
- event: eventOption = "click",
1881
- toggle = true,
1882
- ignoreMouse = false,
1883
- stickIfOpen = true,
1884
- touchOpenDelay = 0
1885
- } = props;
1886
- const pointerTypeRef = React.useRef(void 0);
1887
- const frame = useAnimationFrame();
1888
- const touchOpenTimeout = useTimeout();
1889
- const reference = React.useMemo(() => ({
1890
- onPointerDown(event) {
1891
- pointerTypeRef.current = event.pointerType;
1892
- },
1893
- onMouseDown(event) {
1894
- const pointerType = pointerTypeRef.current;
1895
- const nativeEvent = event.nativeEvent;
1896
- if (event.button !== 0 || eventOption === "click" || isMouseLikePointerType(pointerType, true) && ignoreMouse) {
1897
- return;
1898
- }
1899
- const openEvent = dataRef.current.openEvent;
1900
- const openEventType = openEvent == null ? void 0 : openEvent.type;
1901
- const nextOpen = !(open && toggle && (openEvent && stickIfOpen ? openEventType === "click" || openEventType === "mousedown" : true));
1902
- if (isTypeableElement(nativeEvent.target)) {
1903
- const details = createChangeEventDetails("trigger-press", nativeEvent);
1904
- if (nextOpen && pointerType === "touch" && touchOpenDelay > 0) {
1905
- touchOpenTimeout.start(touchOpenDelay, () => {
1906
- onOpenChange(true, details);
1907
- });
1908
- } else {
1909
- onOpenChange(nextOpen, details);
1910
- }
1911
- return;
1912
- }
1913
- frame.request(() => {
1914
- const details = createChangeEventDetails("trigger-press", nativeEvent);
1915
- if (nextOpen && pointerType === "touch" && touchOpenDelay > 0) {
1916
- touchOpenTimeout.start(touchOpenDelay, () => {
1917
- onOpenChange(true, details);
1918
- });
1919
- } else {
1920
- onOpenChange(nextOpen, details);
1921
- }
1922
- });
1923
- },
1924
- onClick(event) {
1925
- if (eventOption === "mousedown-only") {
1926
- return;
1927
- }
1928
- const pointerType = pointerTypeRef.current;
1929
- if (eventOption === "mousedown" && pointerType) {
1930
- pointerTypeRef.current = void 0;
1931
- return;
1932
- }
1933
- if (isMouseLikePointerType(pointerType, true) && ignoreMouse) {
1934
- return;
1935
- }
1936
- const openEvent = dataRef.current.openEvent;
1937
- const openEventType = openEvent == null ? void 0 : openEvent.type;
1938
- const nextOpen = !(open && toggle && (openEvent && stickIfOpen ? openEventType === "click" || openEventType === "mousedown" || openEventType === "keydown" || openEventType === "keyup" : true));
1939
- const details = createChangeEventDetails("trigger-press", event.nativeEvent);
1940
- if (nextOpen && pointerType === "touch" && touchOpenDelay > 0) {
1941
- touchOpenTimeout.start(touchOpenDelay, () => {
1942
- onOpenChange(true, details);
1943
- });
1944
- } else {
1945
- onOpenChange(nextOpen, details);
1946
- }
1947
- },
1948
- onKeyDown() {
1949
- pointerTypeRef.current = void 0;
1950
- }
1951
- }), [dataRef, eventOption, ignoreMouse, onOpenChange, open, stickIfOpen, toggle, frame, touchOpenTimeout, touchOpenDelay]);
1952
- return React.useMemo(() => enabled ? {
1953
- reference
1954
- } : EMPTY_OBJECT, [enabled, reference]);
1955
- }
1956
- const bubbleHandlerKeys = {
1957
- intentional: "onClick",
1958
- sloppy: "onPointerDown"
1959
- };
1960
- function normalizeProp(normalizable) {
1961
- var _a, _b;
1962
- return {
1963
- escapeKey: typeof normalizable === "boolean" ? normalizable : (_a = normalizable == null ? void 0 : normalizable.escapeKey) != null ? _a : false,
1964
- outsidePress: typeof normalizable === "boolean" ? normalizable : (_b = normalizable == null ? void 0 : normalizable.outsidePress) != null ? _b : true
1965
- };
1966
- }
1967
- function useDismiss(context, props = {}) {
1968
- const {
1969
- open,
1970
- onOpenChange,
1971
- elements,
1972
- dataRef
1973
- } = context;
1974
- const {
1975
- enabled = true,
1976
- escapeKey = true,
1977
- outsidePress: outsidePressProp = true,
1978
- outsidePressEvent = "sloppy",
1979
- referencePress = false,
1980
- referencePressEvent = "sloppy",
1981
- ancestorScroll = false,
1982
- bubbles,
1983
- capture
1984
- } = props;
1985
- const tree = useFloatingTree();
1986
- const outsidePressFn = useEventCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
1987
- const outsidePress = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
1988
- const endedOrStartedInsideRef = React.useRef(false);
1989
- const {
1990
- escapeKey: escapeKeyBubbles,
1991
- outsidePress: outsidePressBubbles
1992
- } = normalizeProp(bubbles);
1993
- const {
1994
- escapeKey: escapeKeyCapture,
1995
- outsidePress: outsidePressCapture
1996
- } = normalizeProp(capture);
1997
- const touchStateRef = React.useRef(null);
1998
- const cancelDismissOnEndTimeout = useTimeout();
1999
- const insideReactTreeTimeout = useTimeout();
2000
- const isComposingRef = React.useRef(false);
2001
- const currentPointerTypeRef = React.useRef("");
2002
- const trackPointerType = useEventCallback((event) => {
2003
- currentPointerTypeRef.current = event.pointerType;
2004
- });
2005
- const getOutsidePressEvent = useEventCallback(() => {
2006
- const type = currentPointerTypeRef.current;
2007
- const computedType = type === "pen" || !type ? "mouse" : type;
2008
- const resolved = typeof outsidePressEvent === "function" ? outsidePressEvent() : outsidePressEvent;
2009
- if (typeof resolved === "string") {
2010
- return resolved;
2011
- }
2012
- return resolved[computedType];
2013
- });
2014
- const closeOnEscapeKeyDown = useEventCallback((event) => {
2015
- var _a;
2016
- if (!open || !enabled || !escapeKey || event.key !== "Escape") {
2017
- return;
2018
- }
2019
- if (isComposingRef.current) {
2020
- return;
2021
- }
2022
- const nodeId = (_a = dataRef.current.floatingContext) == null ? void 0 : _a.nodeId;
2023
- const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
2024
- if (!escapeKeyBubbles) {
2025
- if (children.length > 0) {
2026
- let shouldDismiss = true;
2027
- children.forEach((child) => {
2028
- var _a2;
2029
- if (((_a2 = child.context) == null ? void 0 : _a2.open) && !child.context.dataRef.current.__escapeKeyBubbles) {
2030
- shouldDismiss = false;
2031
- }
2032
- });
2033
- if (!shouldDismiss) {
2034
- return;
2035
- }
2036
- }
2037
- }
2038
- const native = isReactEvent(event) ? event.nativeEvent : event;
2039
- const eventDetails = createChangeEventDetails("escape-key", native);
2040
- onOpenChange(false, eventDetails);
2041
- if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
2042
- event.stopPropagation();
2043
- }
2044
- });
2045
- const shouldIgnoreEvent = useEventCallback((event) => {
2046
- const computedOutsidePressEvent = getOutsidePressEvent();
2047
- return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
2048
- });
2049
- const closeOnEscapeKeyDownCapture = useEventCallback((event) => {
2050
- var _a;
2051
- const callback = () => {
2052
- var _a2;
2053
- closeOnEscapeKeyDown(event);
2054
- (_a2 = getTarget(event)) == null ? void 0 : _a2.removeEventListener("keydown", callback);
2055
- };
2056
- (_a = getTarget(event)) == null ? void 0 : _a.addEventListener("keydown", callback);
2057
- });
2058
- const closeOnPressOutside = useEventCallback((event, endedOrStartedInside = false) => {
2059
- var _a;
2060
- if (shouldIgnoreEvent(event)) {
2061
- return;
2062
- }
2063
- const insideReactTree = dataRef.current.insideReactTree;
2064
- dataRef.current.insideReactTree = false;
2065
- if (getOutsidePressEvent() === "intentional" && endedOrStartedInside) {
2066
- return;
2067
- }
2068
- if (insideReactTree) {
2069
- return;
2070
- }
2071
- if (typeof outsidePress === "function" && !outsidePress(event)) {
2072
- return;
2073
- }
2074
- const target = getTarget(event);
2075
- const inertSelector = `[${createAttribute("inert")}]`;
2076
- const markers = getDocument(elements.floating).querySelectorAll(inertSelector);
2077
- let targetRootAncestor = isElement(target) ? target : null;
2078
- while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
2079
- const nextParent = getParentNode(targetRootAncestor);
2080
- if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
2081
- break;
2082
- }
2083
- targetRootAncestor = nextParent;
2084
- }
2085
- if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
2086
- !contains(target, elements.floating) && // If the target root element contains none of the markers, then the
2087
- // element was injected after the floating element rendered.
2088
- Array.from(markers).every((marker) => !contains(targetRootAncestor, marker))) {
2089
- return;
2090
- }
2091
- if (isHTMLElement(target)) {
2092
- const lastTraversableNode = isLastTraversableNode(target);
2093
- const style = getComputedStyle$1(target);
2094
- const scrollRe = /auto|scroll/;
2095
- const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
2096
- const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
2097
- const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
2098
- const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
2099
- const isRTL = style.direction === "rtl";
2100
- const pressedVerticalScrollbar = canScrollY && (isRTL ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
2101
- const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
2102
- if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
2103
- return;
2104
- }
2105
- }
2106
- const nodeId = (_a = dataRef.current.floatingContext) == null ? void 0 : _a.nodeId;
2107
- const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => {
2108
- var _a2;
2109
- return isEventTargetWithin(event, (_a2 = node.context) == null ? void 0 : _a2.elements.floating);
2110
- });
2111
- if (isEventTargetWithin(event, elements.floating) || isEventTargetWithin(event, elements.domReference) || targetIsInsideChildren) {
2112
- return;
2113
- }
2114
- const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
2115
- if (children.length > 0) {
2116
- let shouldDismiss = true;
2117
- children.forEach((child) => {
2118
- var _a2;
2119
- if (((_a2 = child.context) == null ? void 0 : _a2.open) && !child.context.dataRef.current.__outsidePressBubbles) {
2120
- shouldDismiss = false;
2121
- }
2122
- });
2123
- if (!shouldDismiss) {
2124
- return;
2125
- }
2126
- }
2127
- onOpenChange(false, createChangeEventDetails("outside-press", event));
2128
- });
2129
- const handlePointerDown = useEventCallback((event) => {
2130
- if (getOutsidePressEvent() !== "sloppy" || !open || !enabled || isEventTargetWithin(event, elements.floating) || isEventTargetWithin(event, elements.domReference)) {
2131
- return;
2132
- }
2133
- if (event.pointerType === "touch") {
2134
- touchStateRef.current = {
2135
- startTime: Date.now(),
2136
- startX: event.clientX,
2137
- startY: event.clientY,
2138
- dismissOnPointerUp: false,
2139
- dismissOnMouseDown: true
2140
- };
2141
- cancelDismissOnEndTimeout.start(1e3, () => {
2142
- if (touchStateRef.current) {
2143
- touchStateRef.current.dismissOnPointerUp = false;
2144
- touchStateRef.current.dismissOnMouseDown = false;
2145
- }
2146
- });
2147
- return;
2148
- }
2149
- closeOnPressOutside(event);
2150
- });
2151
- const closeOnPressOutsideCapture = useEventCallback((event) => {
2152
- var _a;
2153
- const endedOrStartedInside = endedOrStartedInsideRef.current;
2154
- endedOrStartedInsideRef.current = false;
2155
- if (shouldIgnoreEvent(event)) {
2156
- return;
2157
- }
2158
- cancelDismissOnEndTimeout.clear();
2159
- if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
2160
- return;
2161
- }
2162
- const callback = () => {
2163
- var _a2;
2164
- if (event.type === "pointerdown") {
2165
- handlePointerDown(event);
2166
- } else {
2167
- closeOnPressOutside(event, endedOrStartedInside);
2168
- }
2169
- (_a2 = getTarget(event)) == null ? void 0 : _a2.removeEventListener(event.type, callback);
2170
- };
2171
- (_a = getTarget(event)) == null ? void 0 : _a.addEventListener(event.type, callback);
2172
- });
2173
- const handlePointerMove = useEventCallback((event) => {
2174
- if (getOutsidePressEvent() !== "sloppy" || event.pointerType !== "touch" || !touchStateRef.current || isEventTargetWithin(event, elements.floating) || isEventTargetWithin(event, elements.domReference)) {
2175
- return;
2176
- }
2177
- const deltaX = Math.abs(event.clientX - touchStateRef.current.startX);
2178
- const deltaY = Math.abs(event.clientY - touchStateRef.current.startY);
2179
- const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
2180
- if (distance > 5) {
2181
- touchStateRef.current.dismissOnPointerUp = true;
2182
- }
2183
- if (distance > 10) {
2184
- closeOnPressOutside(event);
2185
- cancelDismissOnEndTimeout.clear();
2186
- touchStateRef.current = null;
2187
- }
2188
- });
2189
- const handlePointerUp = useEventCallback((event) => {
2190
- if (getOutsidePressEvent() !== "sloppy" || event.pointerType !== "touch" || !touchStateRef.current || isEventTargetWithin(event, elements.floating) || isEventTargetWithin(event, elements.domReference)) {
2191
- return;
2192
- }
2193
- if (touchStateRef.current.dismissOnPointerUp) {
2194
- closeOnPressOutside(event);
2195
- }
2196
- cancelDismissOnEndTimeout.clear();
2197
- touchStateRef.current = null;
2198
- });
2199
- React.useEffect(() => {
2200
- if (!open || !enabled) {
2201
- return void 0;
2202
- }
2203
- dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
2204
- dataRef.current.__outsidePressBubbles = outsidePressBubbles;
2205
- const compositionTimeout = new Timeout();
2206
- function onScroll(event) {
2207
- onOpenChange(false, createChangeEventDetails("none", event));
2208
- }
2209
- function handleCompositionStart() {
2210
- compositionTimeout.clear();
2211
- isComposingRef.current = true;
2212
- }
2213
- function handleCompositionEnd() {
2214
- compositionTimeout.start(
2215
- // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
2216
- // Only apply to WebKit for the test to remain 0ms.
2217
- isWebKit$1() ? 5 : 0,
2218
- () => {
2219
- isComposingRef.current = false;
2220
- }
2221
- );
2222
- }
2223
- const doc = getDocument(elements.floating);
2224
- doc.addEventListener("pointerdown", trackPointerType, true);
2225
- if (escapeKey) {
2226
- doc.addEventListener("keydown", escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
2227
- doc.addEventListener("compositionstart", handleCompositionStart);
2228
- doc.addEventListener("compositionend", handleCompositionEnd);
2229
- }
2230
- if (outsidePress) {
2231
- doc.addEventListener("click", outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
2232
- doc.addEventListener("pointerdown", outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
2233
- doc.addEventListener("pointermove", handlePointerMove, outsidePressCapture);
2234
- doc.addEventListener("pointerup", handlePointerUp, outsidePressCapture);
2235
- doc.addEventListener("mousedown", closeOnPressOutsideCapture, outsidePressCapture);
2236
- }
2237
- let ancestors = [];
2238
- if (ancestorScroll) {
2239
- if (isElement(elements.domReference)) {
2240
- ancestors = getOverflowAncestors(elements.domReference);
2241
- }
2242
- if (isElement(elements.floating)) {
2243
- ancestors = ancestors.concat(getOverflowAncestors(elements.floating));
2244
- }
2245
- if (!isElement(elements.reference) && elements.reference && elements.reference.contextElement) {
2246
- ancestors = ancestors.concat(getOverflowAncestors(elements.reference.contextElement));
2247
- }
2248
- }
2249
- ancestors = ancestors.filter((ancestor) => {
2250
- var _a;
2251
- return ancestor !== ((_a = doc.defaultView) == null ? void 0 : _a.visualViewport);
2252
- });
2253
- ancestors.forEach((ancestor) => {
2254
- ancestor.addEventListener("scroll", onScroll, {
2255
- passive: true
2256
- });
2257
- });
2258
- return () => {
2259
- doc.removeEventListener("pointerdown", trackPointerType, true);
2260
- if (escapeKey) {
2261
- doc.removeEventListener("keydown", escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
2262
- doc.removeEventListener("compositionstart", handleCompositionStart);
2263
- doc.removeEventListener("compositionend", handleCompositionEnd);
2264
- }
2265
- if (outsidePress) {
2266
- doc.removeEventListener("click", outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
2267
- doc.removeEventListener("pointerdown", outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
2268
- doc.removeEventListener("pointermove", handlePointerMove, outsidePressCapture);
2269
- doc.removeEventListener("pointerup", handlePointerUp, outsidePressCapture);
2270
- doc.removeEventListener("mousedown", closeOnPressOutsideCapture, outsidePressCapture);
2271
- }
2272
- ancestors.forEach((ancestor) => {
2273
- ancestor.removeEventListener("scroll", onScroll);
2274
- });
2275
- compositionTimeout.clear();
2276
- };
2277
- }, [dataRef, elements, escapeKey, outsidePress, open, onOpenChange, ancestorScroll, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, escapeKeyCapture, closeOnEscapeKeyDownCapture, closeOnPressOutside, outsidePressCapture, closeOnPressOutsideCapture, handlePointerDown, handlePointerMove, handlePointerUp, trackPointerType]);
2278
- React.useEffect(() => {
2279
- dataRef.current.insideReactTree = false;
2280
- }, [dataRef, outsidePress]);
2281
- const reference = React.useMemo(() => ({
2282
- onKeyDown: closeOnEscapeKeyDown,
2283
- ...referencePress && {
2284
- [bubbleHandlerKeys[referencePressEvent]]: (event) => {
2285
- onOpenChange(false, createChangeEventDetails("trigger-press", event.nativeEvent));
2286
- },
2287
- ...referencePressEvent !== "intentional" && {
2288
- onClick(event) {
2289
- onOpenChange(false, createChangeEventDetails("trigger-press", event.nativeEvent));
2290
- }
2291
- }
2292
- }
2293
- }), [closeOnEscapeKeyDown, onOpenChange, referencePress, referencePressEvent]);
2294
- const handlePressedInside = useEventCallback((event) => {
2295
- const target = getTarget(event.nativeEvent);
2296
- if (!contains(elements.floating, target) || event.button !== 0) {
2297
- return;
2298
- }
2299
- endedOrStartedInsideRef.current = true;
2300
- });
2301
- const handleCaptureInside = useEventCallback(() => {
2302
- dataRef.current.insideReactTree = true;
2303
- insideReactTreeTimeout.start(0, () => {
2304
- dataRef.current.insideReactTree = false;
2305
- });
2306
- });
2307
- const floating = React.useMemo(() => ({
2308
- onKeyDown: closeOnEscapeKeyDown,
2309
- onMouseDown: handlePressedInside,
2310
- onMouseUp: handlePressedInside,
2311
- onPointerDownCapture: handleCaptureInside,
2312
- onMouseDownCapture: handleCaptureInside,
2313
- onClickCapture: handleCaptureInside,
2314
- onMouseUpCapture: handleCaptureInside
2315
- }), [closeOnEscapeKeyDown, handlePressedInside, handleCaptureInside]);
2316
- return React.useMemo(() => enabled ? {
2317
- reference,
2318
- floating
2319
- } : {}, [enabled, reference, floating]);
2320
- }
2321
- function useFloatingRootContext(options) {
2322
- const {
2323
- open = false,
2324
- onOpenChange: onOpenChangeProp,
2325
- elements: elementsProp
2326
- } = options;
2327
- const floatingId = useId();
2328
- const dataRef = React.useRef({});
2329
- const [events] = React.useState(() => createEventEmitter());
2330
- const nested = useFloatingParentNodeId() != null;
2331
- if (process.env.NODE_ENV !== "production") {
2332
- const optionDomReference = elementsProp.reference;
2333
- if (optionDomReference && !isElement(optionDomReference)) {
2334
- console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
2335
- }
2336
- }
2337
- const [positionReference, setPositionReference] = React.useState(elementsProp.reference);
2338
- const onOpenChange = useEventCallback((newOpen, eventDetails) => {
2339
- dataRef.current.openEvent = newOpen ? eventDetails.event : void 0;
2340
- if (!options.noEmit) {
2341
- const details = {
2342
- open: newOpen,
2343
- reason: eventDetails.reason,
2344
- nativeEvent: eventDetails.event,
2345
- nested
2346
- };
2347
- events.emit("openchange", details);
2348
- }
2349
- onOpenChangeProp == null ? void 0 : onOpenChangeProp(newOpen, eventDetails);
2350
- });
2351
- const refs = React.useMemo(() => ({
2352
- setPositionReference
2353
- }), []);
2354
- const elements = React.useMemo(() => ({
2355
- reference: positionReference || elementsProp.reference || null,
2356
- floating: elementsProp.floating || null,
2357
- domReference: elementsProp.reference
2358
- }), [positionReference, elementsProp.reference, elementsProp.floating]);
2359
- return React.useMemo(() => ({
2360
- dataRef,
2361
- open,
2362
- onOpenChange,
2363
- elements,
2364
- events,
2365
- floatingId,
2366
- refs
2367
- }), [open, onOpenChange, elements, events, floatingId, refs]);
2368
- }
2369
- function getEmptyContext() {
2370
- return {
2371
- open: false,
2372
- onOpenChange: () => {
2373
- },
2374
- dataRef: {
2375
- current: {}
2376
- },
2377
- elements: {
2378
- floating: null,
2379
- reference: null,
2380
- domReference: null
2381
- },
2382
- events: {
2383
- on: () => {
2384
- },
2385
- off: () => {
2386
- },
2387
- emit: () => {
2388
- }
2389
- },
2390
- floatingId: "",
2391
- refs: {
2392
- setPositionReference: () => {
2393
- }
2394
- }
2395
- };
2396
- }
2397
- function useInteractions(propsList = []) {
2398
- const referenceDeps = propsList.map((key) => key == null ? void 0 : key.reference);
2399
- const floatingDeps = propsList.map((key) => key == null ? void 0 : key.floating);
2400
- const itemDeps = propsList.map((key) => key == null ? void 0 : key.item);
2401
- const getReferenceProps = React.useCallback(
2402
- (userProps) => mergeProps(userProps, propsList, "reference"),
2403
- // eslint-disable-next-line react-hooks/exhaustive-deps
2404
- referenceDeps
2405
- );
2406
- const getFloatingProps = React.useCallback(
2407
- (userProps) => mergeProps(userProps, propsList, "floating"),
2408
- // eslint-disable-next-line react-hooks/exhaustive-deps
2409
- floatingDeps
2410
- );
2411
- const getItemProps = React.useCallback(
2412
- (userProps) => mergeProps(userProps, propsList, "item"),
2413
- // eslint-disable-next-line react-hooks/exhaustive-deps
2414
- itemDeps
2415
- );
2416
- return React.useMemo(() => ({
2417
- getReferenceProps,
2418
- getFloatingProps,
2419
- getItemProps
2420
- }), [getReferenceProps, getFloatingProps, getItemProps]);
2421
- }
2422
- function mergeProps(userProps, propsList, elementKey) {
2423
- var _a;
2424
- const eventHandlers = /* @__PURE__ */ new Map();
2425
- const isItem = elementKey === "item";
2426
- const outputProps = {};
2427
- if (elementKey === "floating") {
2428
- outputProps.tabIndex = -1;
2429
- outputProps[FOCUSABLE_ATTRIBUTE] = "";
2430
- }
2431
- for (const key in userProps) {
2432
- if (isItem && userProps) {
2433
- if (key === ACTIVE_KEY || key === SELECTED_KEY) {
2434
- continue;
2435
- }
2436
- }
2437
- outputProps[key] = userProps[key];
2438
- }
2439
- for (let i = 0; i < propsList.length; i += 1) {
2440
- let props;
2441
- const propsOrGetProps = (_a = propsList[i]) == null ? void 0 : _a[elementKey];
2442
- if (typeof propsOrGetProps === "function") {
2443
- props = userProps ? propsOrGetProps(userProps) : null;
2444
- } else {
2445
- props = propsOrGetProps;
2446
- }
2447
- if (!props) {
2448
- continue;
2449
- }
2450
- mutablyMergeProps(outputProps, props, isItem, eventHandlers);
2451
- }
2452
- mutablyMergeProps(outputProps, userProps, isItem, eventHandlers);
2453
- return outputProps;
2454
- }
2455
- function mutablyMergeProps(outputProps, props, isItem, eventHandlers) {
2456
- var _a;
2457
- for (const key in props) {
2458
- const value = props[key];
2459
- if (isItem && (key === ACTIVE_KEY || key === SELECTED_KEY)) {
2460
- continue;
2461
- }
2462
- if (!key.startsWith("on")) {
2463
- outputProps[key] = value;
2464
- } else {
2465
- if (!eventHandlers.has(key)) {
2466
- eventHandlers.set(key, []);
2467
- }
2468
- if (typeof value === "function") {
2469
- (_a = eventHandlers.get(key)) == null ? void 0 : _a.push(value);
2470
- outputProps[key] = (...args) => {
2471
- var _a2;
2472
- return (_a2 = eventHandlers.get(key)) == null ? void 0 : _a2.map((fn) => fn(...args)).find((val) => val !== void 0);
2473
- };
2474
- }
2475
- }
2476
- }
2477
- }
2478
- const componentRoleToAriaRoleMap = /* @__PURE__ */ new Map([["select", "listbox"], ["combobox", "listbox"], ["label", false]]);
2479
- function useRole(context, props = {}) {
2480
- var _a, _b;
2481
- const {
2482
- open,
2483
- elements,
2484
- floatingId: defaultFloatingId
2485
- } = context;
2486
- const {
2487
- enabled = true,
2488
- role = "dialog"
2489
- } = props;
2490
- const defaultReferenceId = useId();
2491
- const referenceId = ((_a = elements.domReference) == null ? void 0 : _a.id) || defaultReferenceId;
2492
- const floatingId = React.useMemo(() => {
2493
- var _a2;
2494
- return ((_a2 = getFloatingFocusElement(elements.floating)) == null ? void 0 : _a2.id) || defaultFloatingId;
2495
- }, [elements.floating, defaultFloatingId]);
2496
- const ariaRole = (_b = componentRoleToAriaRoleMap.get(role)) != null ? _b : role;
2497
- const parentId = useFloatingParentNodeId();
2498
- const isNested = parentId != null;
2499
- const reference = React.useMemo(() => {
2500
- if (ariaRole === "tooltip" || role === "label") {
2501
- return {
2502
- [`aria-${role === "label" ? "labelledby" : "describedby"}`]: open ? floatingId : void 0
2503
- };
2504
- }
2505
- return {
2506
- "aria-expanded": open ? "true" : "false",
2507
- "aria-haspopup": ariaRole === "alertdialog" ? "dialog" : ariaRole,
2508
- "aria-controls": open ? floatingId : void 0,
2509
- ...ariaRole === "listbox" && {
2510
- role: "combobox"
2511
- },
2512
- ...ariaRole === "menu" && {
2513
- id: referenceId
2514
- },
2515
- ...ariaRole === "menu" && isNested && {
2516
- role: "menuitem"
2517
- },
2518
- ...role === "select" && {
2519
- "aria-autocomplete": "none"
2520
- },
2521
- ...role === "combobox" && {
2522
- "aria-autocomplete": "list"
2523
- }
2524
- };
2525
- }, [ariaRole, floatingId, isNested, open, referenceId, role]);
2526
- const floating = React.useMemo(() => {
2527
- const floatingProps = {
2528
- id: floatingId,
2529
- ...ariaRole && {
2530
- role: ariaRole
2531
- }
2532
- };
2533
- if (ariaRole === "tooltip" || role === "label") {
2534
- return floatingProps;
2535
- }
2536
- return {
2537
- ...floatingProps,
2538
- ...ariaRole === "menu" && {
2539
- "aria-labelledby": referenceId
2540
- }
2541
- };
2542
- }, [ariaRole, floatingId, referenceId, role]);
2543
- const item = React.useCallback(({
2544
- active,
2545
- selected
2546
- }) => {
2547
- const commonProps = {
2548
- role: "option",
2549
- ...active && {
2550
- id: `${floatingId}-fui-option`
2551
- }
2552
- };
2553
- switch (role) {
2554
- case "select":
2555
- case "combobox":
2556
- return {
2557
- ...commonProps,
2558
- "aria-selected": selected
2559
- };
2560
- }
2561
- return {};
2562
- }, [floatingId, role]);
2563
- return React.useMemo(() => enabled ? {
2564
- reference,
2565
- floating,
2566
- item
2567
- } : {}, [enabled, reference, floating, item]);
2568
- }
2569
- const InternalBackdrop = /* @__PURE__ */ React.forwardRef(function InternalBackdrop2(props, ref) {
2570
- const {
2571
- cutout,
2572
- ...otherProps
2573
- } = props;
2574
- let clipPath;
2575
- if (cutout) {
2576
- const rect = cutout == null ? void 0 : cutout.getBoundingClientRect();
2577
- clipPath = `polygon(
2578
- 0% 0%,
2579
- 100% 0%,
2580
- 100% 100%,
2581
- 0% 100%,
2582
- 0% 0%,
2583
- ${rect.left}px ${rect.top}px,
2584
- ${rect.left}px ${rect.bottom}px,
2585
- ${rect.right}px ${rect.bottom}px,
2586
- ${rect.right}px ${rect.top}px,
2587
- ${rect.left}px ${rect.top}px
2588
- )`;
2589
- }
2590
- return /* @__PURE__ */ jsx("div", {
2591
- ref,
2592
- role: "presentation",
2593
- "data-base-ui-inert": "",
2594
- ...otherProps,
2595
- style: {
2596
- position: "fixed",
2597
- inset: 0,
2598
- userSelect: "none",
2599
- WebkitUserSelect: "none",
2600
- clipPath
2601
- }
2602
- });
2603
- });
2604
- if (process.env.NODE_ENV !== "production") InternalBackdrop.displayName = "InternalBackdrop";
2605
- let originalHtmlStyles = {};
2606
- let originalBodyStyles = {};
2607
- let originalHtmlScrollBehavior = "";
2608
- function hasInsetScrollbars(referenceElement) {
2609
- if (typeof document === "undefined") {
2610
- return false;
2611
- }
2612
- const doc = ownerDocument(referenceElement);
2613
- const win = getWindow(doc);
2614
- return win.innerWidth - doc.documentElement.clientWidth > 0;
2615
- }
2616
- function preventScrollBasic(referenceElement) {
2617
- const doc = ownerDocument(referenceElement);
2618
- const html = doc.documentElement;
2619
- const originalOverflow = html.style.overflow;
2620
- html.style.overflow = "hidden";
2621
- return () => {
2622
- html.style.overflow = originalOverflow;
2623
- };
2624
- }
2625
- function preventScrollStandard(referenceElement) {
2626
- var _a, _b;
2627
- const doc = ownerDocument(referenceElement);
2628
- const html = doc.documentElement;
2629
- const body = doc.body;
2630
- const win = getWindow(html);
2631
- let scrollTop = 0;
2632
- let scrollLeft = 0;
2633
- const resizeFrame = AnimationFrame.create();
2634
- if (isWebKit && ((_b = (_a = win.visualViewport) == null ? void 0 : _a.scale) != null ? _b : 1) !== 1) {
2635
- return () => {
2636
- };
2637
- }
2638
- function lockScroll() {
2639
- var _a2;
2640
- const htmlStyles = win.getComputedStyle(html);
2641
- const bodyStyles = win.getComputedStyle(body);
2642
- scrollTop = html.scrollTop;
2643
- scrollLeft = html.scrollLeft;
2644
- originalHtmlStyles = {
2645
- scrollbarGutter: html.style.scrollbarGutter,
2646
- overflowY: html.style.overflowY,
2647
- overflowX: html.style.overflowX
2648
- };
2649
- originalHtmlScrollBehavior = html.style.scrollBehavior;
2650
- originalBodyStyles = {
2651
- position: body.style.position,
2652
- height: body.style.height,
2653
- width: body.style.width,
2654
- boxSizing: body.style.boxSizing,
2655
- overflowY: body.style.overflowY,
2656
- overflowX: body.style.overflowX,
2657
- scrollBehavior: body.style.scrollBehavior
2658
- };
2659
- const supportsStableScrollbarGutter = typeof CSS !== "undefined" && ((_a2 = CSS.supports) == null ? void 0 : _a2.call(CSS, "scrollbar-gutter", "stable"));
2660
- const isScrollableY = html.scrollHeight > html.clientHeight;
2661
- const isScrollableX = html.scrollWidth > html.clientWidth;
2662
- const hasConstantOverflowY = htmlStyles.overflowY === "scroll" || bodyStyles.overflowY === "scroll";
2663
- const hasConstantOverflowX = htmlStyles.overflowX === "scroll" || bodyStyles.overflowX === "scroll";
2664
- const scrollbarWidth = Math.max(0, win.innerWidth - html.clientWidth);
2665
- const scrollbarHeight = Math.max(0, win.innerHeight - html.clientHeight);
2666
- const marginY = parseFloat(bodyStyles.marginTop) + parseFloat(bodyStyles.marginBottom);
2667
- const marginX = parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight);
2668
- Object.assign(html.style, {
2669
- scrollbarGutter: "stable",
2670
- overflowY: !supportsStableScrollbarGutter && (isScrollableY || hasConstantOverflowY) ? "scroll" : "hidden",
2671
- overflowX: !supportsStableScrollbarGutter && (isScrollableX || hasConstantOverflowX) ? "scroll" : "hidden"
2672
- });
2673
- Object.assign(body.style, {
2674
- position: "relative",
2675
- height: marginY || scrollbarHeight ? `calc(100dvh - ${marginY + scrollbarHeight}px)` : "100dvh",
2676
- width: marginX || scrollbarWidth ? `calc(100vw - ${marginX + scrollbarWidth}px)` : "100vw",
2677
- boxSizing: "border-box",
2678
- overflow: "hidden",
2679
- scrollBehavior: "unset"
2680
- });
2681
- body.scrollTop = scrollTop;
2682
- body.scrollLeft = scrollLeft;
2683
- html.setAttribute("data-base-ui-scroll-locked", "");
2684
- html.style.scrollBehavior = "unset";
2685
- }
2686
- function cleanup() {
2687
- Object.assign(html.style, originalHtmlStyles);
2688
- Object.assign(body.style, originalBodyStyles);
2689
- html.scrollTop = scrollTop;
2690
- html.scrollLeft = scrollLeft;
2691
- html.removeAttribute("data-base-ui-scroll-locked");
2692
- html.style.scrollBehavior = originalHtmlScrollBehavior;
2693
- }
2694
- function handleResize() {
2695
- cleanup();
2696
- resizeFrame.request(lockScroll);
2697
- }
2698
- lockScroll();
2699
- win.addEventListener("resize", handleResize);
2700
- return () => {
2701
- resizeFrame.cancel();
2702
- cleanup();
2703
- win.removeEventListener("resize", handleResize);
2704
- };
2705
- }
2706
- class ScrollLocker {
2707
- constructor() {
2708
- __publicField(this, "lockCount", 0);
2709
- __publicField(this, "restore", /* @__PURE__ */ (() => null)());
2710
- __publicField(this, "timeoutLock", (() => Timeout.create())());
2711
- __publicField(this, "timeoutUnlock", (() => Timeout.create())());
2712
- __publicField(this, "release", () => {
2713
- this.lockCount -= 1;
2714
- if (this.lockCount === 0 && this.restore) {
2715
- this.timeoutUnlock.start(0, this.unlock);
2716
- }
2717
- });
2718
- __publicField(this, "unlock", () => {
2719
- var _a;
2720
- if (this.lockCount === 0 && this.restore) {
2721
- (_a = this.restore) == null ? void 0 : _a.call(this);
2722
- this.restore = null;
2723
- }
2724
- });
2725
- }
2726
- acquire(referenceElement) {
2727
- this.lockCount += 1;
2728
- if (this.lockCount === 1 && this.restore === null) {
2729
- this.timeoutLock.start(0, () => this.lock(referenceElement));
2730
- }
2731
- return this.release;
2732
- }
2733
- lock(referenceElement) {
2734
- if (this.lockCount === 0 || this.restore !== null) {
2735
- return;
2736
- }
2737
- const doc = ownerDocument(referenceElement);
2738
- const html = doc.documentElement;
2739
- const htmlOverflowY = getWindow(html).getComputedStyle(html).overflowY;
2740
- if (htmlOverflowY === "hidden" || htmlOverflowY === "clip") {
2741
- this.restore = NOOP;
2742
- return;
2743
- }
2744
- const isOverflowHiddenLock = isIOS || !hasInsetScrollbars(referenceElement);
2745
- this.restore = isOverflowHiddenLock ? preventScrollBasic(referenceElement) : preventScrollStandard(referenceElement);
2746
- }
2747
- }
2748
- const SCROLL_LOCKER = new ScrollLocker();
2749
- function useScrollLock(params) {
2750
- const {
2751
- enabled = true,
2752
- mounted,
2753
- open,
2754
- referenceElement = null
2755
- } = params;
2756
- useIsoLayoutEffect(() => {
2757
- if (enabled && isWebKit && mounted && !open) {
2758
- const doc = ownerDocument(referenceElement);
2759
- const originalUserSelect = doc.body.style.userSelect;
2760
- const originalWebkitUserSelect = doc.body.style.webkitUserSelect;
2761
- doc.body.style.userSelect = "none";
2762
- doc.body.style.webkitUserSelect = "none";
2763
- return () => {
2764
- doc.body.style.userSelect = originalUserSelect;
2765
- doc.body.style.webkitUserSelect = originalWebkitUserSelect;
2766
- };
2767
- }
2768
- return void 0;
2769
- }, [enabled, mounted, open, referenceElement]);
2770
- useIsoLayoutEffect(() => {
2771
- if (!enabled) {
2772
- return void 0;
2773
- }
2774
- return SCROLL_LOCKER.acquire(referenceElement);
2775
- }, [enabled, referenceElement]);
2776
- }
2777
- function useEnhancedClickHandler(handler) {
2778
- const lastClickInteractionTypeRef = React.useRef("");
2779
- const handlePointerDown = React.useCallback((event) => {
2780
- if (event.defaultPrevented) {
2781
- return;
2782
- }
2783
- lastClickInteractionTypeRef.current = event.pointerType;
2784
- handler(event, event.pointerType);
2785
- }, [handler]);
2786
- const handleClick = React.useCallback((event) => {
2787
- if (event.detail === 0) {
2788
- handler(event, "keyboard");
2789
- return;
2790
- }
2791
- if ("pointerType" in event) {
2792
- handler(event, event.pointerType);
2793
- }
2794
- handler(event, lastClickInteractionTypeRef.current);
2795
- lastClickInteractionTypeRef.current = "";
2796
- }, [handler]);
2797
- return {
2798
- onClick: handleClick,
2799
- onPointerDown: handlePointerDown
2800
- };
2801
- }
2802
- function useOpenInteractionType(open) {
2803
- const [openMethod, setOpenMethod] = React.useState(null);
2804
- const handleTriggerClick = useEventCallback((_, interactionType) => {
2805
- if (!open) {
2806
- setOpenMethod(interactionType);
2807
- }
2808
- });
2809
- const reset = useEventCallback(() => {
2810
- setOpenMethod(null);
2811
- });
2812
- const {
2813
- onClick,
2814
- onPointerDown
2815
- } = useEnhancedClickHandler(handleTriggerClick);
2816
- return React.useMemo(() => ({
2817
- openMethod,
2818
- reset,
2819
- triggerProps: {
2820
- onClick,
2821
- onPointerDown
2822
- }
2823
- }), [openMethod, reset, onClick, onPointerDown]);
2824
- }
2825
- export {
2826
- pressableTriggerOpenStateMapping as $,
2827
- ARROW_UP$1 as A,
2828
- createAttribute as B,
2829
- CommonPopupDataAttributes as C,
2830
- isMouseLikePointerType as D,
2831
- contains as E,
2832
- FloatingFocusManager as F,
2833
- activeElement as G,
2834
- isTypeableElement as H,
2835
- InternalBackdrop as I,
2836
- matchesFocusVisible as J,
2837
- isMac as K,
2838
- isSafari as L,
2839
- getFloatingFocusElement as M,
2840
- isTypeableCombobox as N,
2841
- enqueueFocus as O,
2842
- isVirtualClick as P,
2843
- isVirtualPointerEvent as Q,
2844
- getNodeChildren as R,
2845
- ownerDocument as S,
2846
- Timeout as T,
2847
- DISABLED_TRANSITIONS_STYLE as U,
2848
- DROPDOWN_COLLISION_AVOIDANCE as V,
2849
- useFloatingNodeId as W,
2850
- FloatingNode as X,
2851
- PATIENT_CLICK_THRESHOLD as Y,
2852
- FloatingTree as Z,
2853
- TYPEAHEAD_RESET_MS as _,
2854
- COMPOSITE_KEYS as a,
2855
- FloatingPortal as b,
2856
- triggerOpenStateMapping as c,
2857
- useTransitionStatus as d,
2858
- useOpenInteractionType as e,
2859
- useFloatingRootContext as f,
2860
- getEmptyContext as g,
2861
- useRole as h,
2862
- inertValue as i,
2863
- useClick as j,
2864
- useDismiss as k,
2865
- useScrollLock as l,
2866
- useInteractions as m,
2867
- getTarget as n,
2868
- ARROW_DOWN$1 as o,
2869
- popupStateMapping as p,
2870
- ARROW_LEFT$1 as q,
2871
- ARROW_RIGHT$1 as r,
2872
- stopEvent as s,
2873
- transitionStatusMapping as t,
2874
- useOpenChangeComplete as u,
2875
- useFloatingTree as v,
2876
- useFloatingParentNodeId as w,
2877
- useLatestRef as x,
2878
- useTimeout as y,
2879
- getDocument as z
2880
- };