@arc-ui/components 11.16.0 → 11.17.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 (230) hide show
  1. package/dist/Calendar/Calendar.cjs.js +21 -0
  2. package/dist/Calendar/Calendar.esm.js +13 -0
  3. package/dist/Calendar/package.json +7 -0
  4. package/dist/Checkbox/Checkbox.cjs.js +3 -2
  5. package/dist/Checkbox/Checkbox.esm.js +3 -2
  6. package/dist/DatePicker/DatePicker.cjs.js +565 -0
  7. package/dist/DatePicker/DatePicker.esm.js +552 -0
  8. package/dist/DatePicker/package.json +7 -0
  9. package/dist/FormControl/FormControl.cjs.js +2 -1
  10. package/dist/FormControl/FormControl.esm.js +2 -1
  11. package/dist/InformationCard/InformationCard.cjs.js +10 -9
  12. package/dist/InformationCard/InformationCard.esm.js +8 -7
  13. package/dist/MediaCard/MediaCard.cjs.js +56 -0
  14. package/dist/MediaCard/MediaCard.esm.js +48 -0
  15. package/dist/MediaCard/package.json +7 -0
  16. package/dist/Modal/Modal.cjs.js +13 -286
  17. package/dist/Modal/Modal.esm.js +6 -279
  18. package/dist/RadioGroup/RadioGroup.cjs.js +3 -2
  19. package/dist/RadioGroup/RadioGroup.esm.js +3 -2
  20. package/dist/Select/Select.cjs.js +31 -2705
  21. package/dist/Select/Select.esm.js +13 -2668
  22. package/dist/SiteFooter/SiteFooter.cjs.js +2 -2
  23. package/dist/SiteFooter/SiteFooter.esm.js +3 -3
  24. package/dist/SiteHeader/SiteHeader.cjs.js +2 -2
  25. package/dist/SiteHeader/SiteHeader.esm.js +2 -2
  26. package/dist/SiteHeaderV2/SiteHeaderV2.cjs.js +23 -0
  27. package/dist/SiteHeaderV2/SiteHeaderV2.esm.js +15 -0
  28. package/dist/SiteHeaderV2/package.json +7 -0
  29. package/dist/Switch/Switch.cjs.js +4 -3
  30. package/dist/Switch/Switch.esm.js +4 -3
  31. package/dist/Tabs/Tabs.cjs.js +5 -5
  32. package/dist/Tabs/Tabs.esm.js +5 -5
  33. package/dist/TextArea/TextArea.cjs.js +20 -20
  34. package/dist/TextArea/TextArea.esm.js +20 -20
  35. package/dist/TextInput/TextInput.cjs.js +3 -2
  36. package/dist/TextInput/TextInput.esm.js +3 -2
  37. package/dist/Toast/Toast.cjs.js +6 -7
  38. package/dist/Toast/Toast.esm.js +6 -7
  39. package/dist/TypographyCard/TypographyCard.cjs.js +13 -70
  40. package/dist/TypographyCard/TypographyCard.esm.js +14 -71
  41. package/dist/_shared/cjs/Calendar-18e255f8.js +4106 -0
  42. package/dist/_shared/cjs/CardFooter-43c32239.js +80 -0
  43. package/dist/_shared/cjs/CardLabel-768abf20.js +54 -0
  44. package/dist/_shared/cjs/{Checkbox-904ad028.js → Checkbox-4d4b432f.js} +1 -1
  45. package/dist/_shared/cjs/{index-3d69ea00.js → Combination-9974f2e2.js} +662 -145
  46. package/dist/_shared/cjs/{FormControl-166e0957.js → FormControl-b26ad353.js} +8 -5
  47. package/dist/_shared/cjs/{RadioGroup-1eddf86f.js → RadioGroup-23c964ae.js} +1 -1
  48. package/dist/_shared/cjs/{SiteFooter-97c27b29.js → SiteFooter-65b6360c.js} +2 -2
  49. package/dist/_shared/cjs/{SiteHeader.rehydrator-af3dddef.js → SiteHeader.rehydrator-df053a52.js} +8 -8
  50. package/dist/_shared/cjs/SiteHeaderV2-8ce6d4fc.js +610 -0
  51. package/dist/_shared/cjs/{Tabs-cc77dabb.js → Tabs-34db6bc1.js} +4 -4
  52. package/dist/_shared/cjs/{TextInput-fd9c756f.js → TextInput-d0370fa8.js} +19 -6
  53. package/dist/_shared/cjs/{Toast-91e96744.js → Toast-392b1d60.js} +292 -34
  54. package/dist/_shared/cjs/{index-84e6a68f.js → index-6eb396a3.js} +1 -1
  55. package/dist/_shared/cjs/{index-6542b467.js → index-74004a9c.js} +1 -1
  56. package/dist/_shared/cjs/index-77ab5c6a.js +2180 -0
  57. package/dist/_shared/cjs/{index-d31f2b65.js → index-9f99d686.js} +1 -1
  58. package/dist/_shared/cjs/{index-1641d0b4.js → index-a31e64a9.js} +1 -1
  59. package/dist/_shared/cjs/{index-49c72a87.js → index-d38f1bd0.js} +1 -1
  60. package/dist/_shared/esm/Calendar-4033fa48.js +4093 -0
  61. package/dist/_shared/esm/CardFooter-dd8d4000.js +74 -0
  62. package/dist/_shared/esm/CardLabel-d6d71407.js +46 -0
  63. package/dist/_shared/esm/{Checkbox-8a5bb9a1.js → Checkbox-720b074d.js} +1 -1
  64. package/dist/_shared/esm/{index-3e2bc99d.js → Combination-e9f7e64e.js} +643 -132
  65. package/dist/_shared/esm/{FormControl-9d4ddfec.js → FormControl-f0b8fe91.js} +8 -5
  66. package/dist/_shared/esm/{RadioGroup-238db88d.js → RadioGroup-37fdb06b.js} +1 -1
  67. package/dist/_shared/esm/{SiteFooter-94316b8b.js → SiteFooter-38ee1536.js} +1 -1
  68. package/dist/_shared/esm/{SiteHeader.rehydrator-1b507253.js → SiteHeader.rehydrator-32bdcd88.js} +2 -2
  69. package/dist/_shared/esm/SiteHeaderV2-f8377627.js +604 -0
  70. package/dist/_shared/esm/{Tabs-8719d952.js → Tabs-df9965dd.js} +4 -4
  71. package/dist/_shared/esm/{TextInput-c1e2a1dd.js → TextInput-abbab56b.js} +19 -6
  72. package/dist/_shared/esm/{Toast-7cb1e544.js → Toast-5d66e13f.js} +264 -7
  73. package/dist/_shared/esm/{index-39019a9b.js → index-044da8d0.js} +1 -1
  74. package/dist/_shared/esm/{index-6b7b075c.js → index-25a5b393.js} +1 -1
  75. package/dist/_shared/esm/{index-246b4f18.js → index-2cfab9f2.js} +1 -1
  76. package/dist/_shared/esm/{index-12f3a407.js → index-7b531fa7.js} +68 -68
  77. package/dist/_shared/esm/index-b84a20c6.js +2155 -0
  78. package/dist/_shared/esm/{index-db47e95a.js → index-ca72c9d5.js} +1 -1
  79. package/dist/_shared/esm/{index-936b5179.js → index-efa9be1a.js} +1 -1
  80. package/dist/_shared/esm/{index.es-c552c0ea.js → use-media-query-4c807227.js} +9 -9
  81. package/dist/index.es.js +1135 -791
  82. package/dist/index.es.js.map +1 -1
  83. package/dist/index.js +1136 -791
  84. package/dist/index.js.map +1 -1
  85. package/dist/styles.css +4 -4
  86. package/dist/types/components/Calendar/Calendar.d.ts +49 -0
  87. package/dist/types/components/Calendar/Calendar.provider.d.ts +21 -0
  88. package/dist/types/components/Calendar/components/CalendarDateSelect/CalendarDateSelect.d.ts +15 -0
  89. package/dist/types/components/Calendar/components/CalendarDateSelect/index.d.ts +1 -0
  90. package/dist/types/components/Calendar/components/CalendarDayGrid/CalendarDayGrid.d.ts +6 -0
  91. package/dist/types/components/Calendar/components/CalendarDayGrid/index.d.ts +1 -0
  92. package/dist/types/components/Calendar/components/CalendarDayNumber/CalendarDayNumber.d.ts +8 -0
  93. package/dist/types/components/Calendar/components/CalendarDayNumber/index.d.ts +1 -0
  94. package/dist/types/components/Calendar/components/CalendarDoubleMonthView/CalendarDoubleMonthView.d.ts +9 -0
  95. package/dist/types/components/Calendar/components/CalendarDoubleMonthView/index.d.ts +1 -0
  96. package/dist/types/components/Calendar/components/CalendarFooter/CalendarFooter.d.ts +6 -0
  97. package/dist/types/components/Calendar/components/CalendarFooter/index.d.ts +1 -0
  98. package/dist/types/components/Calendar/components/CalendarMonthView/CalendarMonthView.d.ts +9 -0
  99. package/dist/types/components/Calendar/components/CalendarMonthView/index.d.ts +1 -0
  100. package/dist/types/components/Calendar/components/CalendarMonthYearView/CalendarMonthYearView.d.ts +11 -0
  101. package/dist/types/components/Calendar/components/CalendarMonthYearView/index.d.ts +1 -0
  102. package/dist/types/components/Calendar/components/CalendarNavButton/CalendarNavButton.d.ts +10 -0
  103. package/dist/types/components/Calendar/components/CalendarNavButton/index.d.ts +1 -0
  104. package/dist/types/components/Calendar/components/CalendarWrapper/CalendarWrapper.d.ts +5 -0
  105. package/dist/types/components/Calendar/components/CalendarWrapper/index.d.ts +1 -0
  106. package/dist/types/components/Calendar/components/index.d.ts +6 -0
  107. package/dist/types/components/Calendar/constants/day-names.d.ts +5 -0
  108. package/dist/types/components/Calendar/constants/index.d.ts +1 -0
  109. package/dist/types/components/Calendar/helpers/contains-date.d.ts +1 -0
  110. package/dist/types/components/Calendar/helpers/contains-date.test.d.ts +1 -0
  111. package/dist/types/components/Calendar/helpers/date-without-time.d.ts +1 -0
  112. package/dist/types/components/Calendar/helpers/date-without-time.test.d.ts +1 -0
  113. package/dist/types/components/Calendar/helpers/get-calendar-type.d.ts +2 -0
  114. package/dist/types/components/Calendar/helpers/get-calendar-type.test.d.ts +1 -0
  115. package/dist/types/components/Calendar/helpers/get-dates-in-month.d.ts +1 -0
  116. package/dist/types/components/Calendar/helpers/get-dates-in-month.test.d.ts +1 -0
  117. package/dist/types/components/Calendar/helpers/get-double-month-display-range.d.ts +1 -0
  118. package/dist/types/components/Calendar/helpers/get-double-month-display-range.test.d.ts +1 -0
  119. package/dist/types/components/Calendar/helpers/get-focus-date.d.ts +5 -0
  120. package/dist/types/components/Calendar/helpers/get-focus-date.test.d.ts +1 -0
  121. package/dist/types/components/Calendar/helpers/get-highlighted-range.d.ts +6 -0
  122. package/dist/types/components/Calendar/helpers/get-highlighted-range.test.d.ts +1 -0
  123. package/dist/types/components/Calendar/helpers/get-keydown-date.d.ts +6 -0
  124. package/dist/types/components/Calendar/helpers/get-keydown-date.test.d.ts +1 -0
  125. package/dist/types/components/Calendar/helpers/index.d.ts +13 -0
  126. package/dist/types/components/Calendar/helpers/is-day.d.ts +2 -0
  127. package/dist/types/components/Calendar/helpers/is-day.test.d.ts +1 -0
  128. package/dist/types/components/Calendar/helpers/is-disabled-date.d.ts +1 -0
  129. package/dist/types/components/Calendar/helpers/is-disabled-date.test.d.ts +1 -0
  130. package/dist/types/components/Calendar/helpers/is-month-after-max-date.d.ts +1 -0
  131. package/dist/types/components/Calendar/helpers/is-month-after-max-date.test.d.ts +1 -0
  132. package/dist/types/components/Calendar/helpers/is-month-before-min-date.d.ts +1 -0
  133. package/dist/types/components/Calendar/helpers/is-month-before-min-date.test.d.ts +1 -0
  134. package/dist/types/components/Calendar/helpers/process-selected-range.d.ts +9 -0
  135. package/dist/types/components/Calendar/helpers/process-selected-range.test.d.ts +1 -0
  136. package/dist/types/components/Calendar/index.d.ts +2 -0
  137. package/dist/types/components/Calendar/state/handlers/calendar-keydown-handler.d.ts +3 -0
  138. package/dist/types/components/Calendar/state/handlers/day-grid-leave-handler.d.ts +3 -0
  139. package/dist/types/components/Calendar/state/handlers/day-number-select-handler.d.ts +3 -0
  140. package/dist/types/components/Calendar/state/handlers/default-handler.d.ts +2 -0
  141. package/dist/types/components/Calendar/state/handlers/dropdown-change-month-handler.d.ts +3 -0
  142. package/dist/types/components/Calendar/state/handlers/dropdown-change-year-handler.d.ts +3 -0
  143. package/dist/types/components/Calendar/state/handlers/highlight-range-handler.d.ts +3 -0
  144. package/dist/types/components/Calendar/state/handlers/index.d.ts +12 -0
  145. package/dist/types/components/Calendar/state/handlers/range-select-handler.d.ts +3 -0
  146. package/dist/types/components/Calendar/state/handlers/show-next-double-month-handler.d.ts +3 -0
  147. package/dist/types/components/Calendar/state/handlers/show-next-month-handler.d.ts +3 -0
  148. package/dist/types/components/Calendar/state/handlers/show-previous-double-month-handler.d.ts +3 -0
  149. package/dist/types/components/Calendar/state/handlers/show-previous-month-handler.d.ts +3 -0
  150. package/dist/types/components/Calendar/state/index.d.ts +2 -0
  151. package/dist/types/components/Calendar/state/reducer.d.ts +3 -0
  152. package/dist/types/components/Calendar/state/reducer.test.d.ts +1 -0
  153. package/dist/types/components/Calendar/state/types/actions.d.ts +81 -0
  154. package/dist/types/components/Calendar/state/types/state-handler.d.ts +3 -0
  155. package/dist/types/components/Calendar/state/types/state.d.ts +5 -0
  156. package/dist/types/components/Calendar/types/calendar-type.d.ts +1 -0
  157. package/dist/types/components/Calendar/types/date-select-value.d.ts +2 -0
  158. package/dist/types/components/Calendar/types/index.d.ts +6 -0
  159. package/dist/types/components/Calendar/types/key-names.d.ts +13 -0
  160. package/dist/types/components/Calendar/types/range-selection.d.ts +10 -0
  161. package/dist/types/components/Calendar/types/selection-type.d.ts +1 -0
  162. package/dist/types/components/Calendar/types/week-days.d.ts +18 -0
  163. package/dist/types/components/DatePicker/DatePicker.d.ts +17 -0
  164. package/dist/types/components/DatePicker/constants/date-format.d.ts +1 -0
  165. package/dist/types/components/DatePicker/constants/index.d.ts +1 -0
  166. package/dist/types/components/DatePicker/helpers/convert-date-string-to-date.d.ts +1 -0
  167. package/dist/types/components/DatePicker/helpers/convert-date-string-to-date.test.d.ts +1 -0
  168. package/dist/types/components/DatePicker/helpers/convert-range-string-to-dates.d.ts +1 -0
  169. package/dist/types/components/DatePicker/helpers/convert-range-string-to-dates.test.d.ts +1 -0
  170. package/dist/types/components/DatePicker/helpers/format-date.d.ts +1 -0
  171. package/dist/types/components/DatePicker/helpers/format-date.test.d.ts +1 -0
  172. package/dist/types/components/DatePicker/helpers/index.d.ts +8 -0
  173. package/dist/types/components/DatePicker/helpers/is-date-valid.d.ts +1 -0
  174. package/dist/types/components/DatePicker/helpers/is-date-valid.test.d.ts +1 -0
  175. package/dist/types/components/DatePicker/helpers/is-disabled-date.d.ts +1 -0
  176. package/dist/types/components/DatePicker/helpers/is-disabled-date.test.d.ts +1 -0
  177. package/dist/types/components/DatePicker/helpers/is-range-valid.d.ts +1 -0
  178. package/dist/types/components/DatePicker/helpers/is-range-valid.test.d.ts +1 -0
  179. package/dist/types/components/DatePicker/helpers/parse-date-string.d.ts +5 -0
  180. package/dist/types/components/DatePicker/helpers/parse-date-string.test.d.ts +1 -0
  181. package/dist/types/components/DatePicker/helpers/parse-range-string.d.ts +14 -0
  182. package/dist/types/components/DatePicker/helpers/parse-range-string.test.d.ts +1 -0
  183. package/dist/types/components/DatePicker/index.d.ts +6 -0
  184. package/dist/types/components/FormControl/FormControl.d.ts +4 -0
  185. package/dist/types/components/RadioGroup/RadioGroup.d.ts +1 -1
  186. package/dist/types/components/SiteHeaderV2/SiteHeaderV2.d.ts +77 -0
  187. package/dist/types/components/SiteHeaderV2/components/BackButton/BackButton.d.ts +5 -0
  188. package/dist/types/components/SiteHeaderV2/components/BackButton/index.d.ts +1 -0
  189. package/dist/types/components/SiteHeaderV2/components/Column/Column.d.ts +8 -0
  190. package/dist/types/components/SiteHeaderV2/components/Column/index.d.ts +1 -0
  191. package/dist/types/components/SiteHeaderV2/components/HorizontalPanel/HorizontalPanel.d.ts +13 -0
  192. package/dist/types/components/SiteHeaderV2/components/HorizontalPanel/index.d.ts +1 -0
  193. package/dist/types/components/SiteHeaderV2/components/Item/Item.d.ts +20 -0
  194. package/dist/types/components/SiteHeaderV2/components/Item/index.d.ts +1 -0
  195. package/dist/types/components/SiteHeaderV2/components/ItemGroup/ItemGroup.d.ts +27 -0
  196. package/dist/types/components/SiteHeaderV2/components/ItemGroup/index.d.ts +1 -0
  197. package/dist/types/components/SiteHeaderV2/components/MenuButton/MenuButton.d.ts +6 -0
  198. package/dist/types/components/SiteHeaderV2/components/MenuButton/index.d.ts +1 -0
  199. package/dist/types/components/SiteHeaderV2/components/NavItem/NavItem.d.ts +40 -0
  200. package/dist/types/components/SiteHeaderV2/components/NavItem/NavItemWithSubNav.d.ts +55 -0
  201. package/dist/types/components/SiteHeaderV2/components/NavItem/index.d.ts +2 -0
  202. package/dist/types/components/SiteHeaderV2/components/NodeItem/NodeItem.d.ts +8 -0
  203. package/dist/types/components/SiteHeaderV2/components/Panel/Panel.d.ts +26 -0
  204. package/dist/types/components/SiteHeaderV2/components/Panel/index.d.ts +1 -0
  205. package/dist/types/components/SiteHeaderV2/components/SubNavItem/SubNavItem.d.ts +45 -0
  206. package/dist/types/components/SiteHeaderV2/components/SubNavItem/index.d.ts +1 -0
  207. package/dist/types/components/SiteHeaderV2/components/VerticalDivider/VerticalDivider.d.ts +1 -0
  208. package/dist/types/components/SiteHeaderV2/components/VerticalDivider/index.d.ts +1 -0
  209. package/dist/types/components/SiteHeaderV2/index.d.ts +1 -0
  210. package/dist/types/components/TextArea/TextArea.d.ts +4 -0
  211. package/dist/types/components/TextInput/TextInput.d.ts +22 -3
  212. package/dist/types/components/index.d.ts +1 -0
  213. package/dist/types/private-components/CardFooter/CardFooter.d.ts +11 -0
  214. package/dist/types/private-components/CardFooter/index.d.ts +1 -0
  215. package/dist/types/private-components/CardHeading/CardHeading.d.ts +19 -0
  216. package/dist/types/private-components/CardHeading/index.d.ts +1 -0
  217. package/dist/types/private-components/CardLabel/CardLabel.d.ts +10 -0
  218. package/dist/types/private-components/CardLabel/index.d.ts +1 -0
  219. package/dist/types/private-components/index.d.ts +4 -0
  220. package/dist/types/styles.d.ts +6 -0
  221. package/package.json +4 -2
  222. package/dist/_shared/cjs/BtIconArrowRight.esm-8e8ac316.js +0 -30
  223. package/dist/_shared/cjs/index-4ecad2dd.js +0 -273
  224. package/dist/_shared/esm/BtIconArrowRight.esm-267916a4.js +0 -24
  225. package/dist/_shared/esm/index-d0307140.js +0 -264
  226. package/dist/types/internal-components/index.d.ts +0 -1
  227. package/dist/_shared/cjs/{index-56a040f4.js → index-dd1d18ea.js} +66 -66
  228. package/dist/_shared/cjs/{index.es-26dd8c5d.js → use-media-query-e61881d8.js} +8 -8
  229. /package/dist/types/{internal-components → private-components}/ConditionalWrapper/ConditionalWrapper.d.ts +0 -0
  230. /package/dist/types/{internal-components → private-components}/ConditionalWrapper/index.d.ts +0 -0
@@ -1,2687 +1,32 @@
1
1
  import { _ as __rest, a as __assign, f as filterDataAttrs } from '../_shared/esm/filter-data-attrs-ea8f4ed4.js';
2
2
  import { c as classNames } from '../_shared/esm/index-2e73c2e9.js';
3
- import * as React from 'react';
4
- import React__default, { forwardRef, useContext, useState, useEffect, createElement, useRef, createContext, useCallback, useLayoutEffect, useMemo, Fragment, useId } from 'react';
3
+ import React__default, { useRef, useMemo, useState, createElement, useCallback, forwardRef, Fragment, useEffect, useId, useContext } from 'react';
5
4
  import { _ as _extends } from '../_shared/esm/extends-8cc61aad.js';
6
- import * as $7SXl2$reactdom from 'react-dom';
7
- import $7SXl2$reactdom__default, { createPortal } from 'react-dom';
8
- import { a as $6ed0406888f73fc4$export$c7b2cbe3552a0d05, b as $8927f6f2acc4f386$export$250ffa63cdc0d034, f as $e42e1063c40fb3ef$export$b9ecd428b558ff10, $ as $b1b2314f5f9a1d84$export$25bec8c6f54ee79a, h as $8927f6f2acc4f386$export$6d1a0317bde7de7f, g as $9f79659886946c16$export$e5c5a5f917a5871c, c as $c512c27ab02ef895$export$50c7b4e9d9f19c1, d as $71cd76cc60e0454e$export$6f32135080cb4c3, e as $5e63c961fc1ce211$export$8c6ed5c666ac1360 } from '../_shared/esm/index-12f3a407.js';
9
- import { $ as $e02a7d9cb1dc128c$export$c74125a8e3af6bb2 } from '../_shared/esm/index-39019a9b.js';
5
+ import { createPortal } from 'react-dom';
6
+ import { $ as $c512c27ab02ef895$export$50c7b4e9d9f19c1, a as $71cd76cc60e0454e$export$6f32135080cb4c3, b as $6ed0406888f73fc4$export$c7b2cbe3552a0d05, e as $8927f6f2acc4f386$export$250ffa63cdc0d034, d as $e42e1063c40fb3ef$export$b9ecd428b558ff10, h as $9f79659886946c16$export$e5c5a5f917a5871c, c as $5e63c961fc1ce211$export$8c6ed5c666ac1360, f as $b1b2314f5f9a1d84$export$25bec8c6f54ee79a } from '../_shared/esm/index-7b531fa7.js';
7
+ import { $ as $e02a7d9cb1dc128c$export$c74125a8e3af6bb2 } from '../_shared/esm/index-044da8d0.js';
10
8
  import { $ as $f631663db3294ace$export$b39126d51d94e6f3 } from '../_shared/esm/index-a624de47.js';
11
- import { $ as $addc16e1bbe58fd0$export$3a72a57244d6e765 } from '../_shared/esm/index-246b4f18.js';
12
- import { h as hideOthers, a as $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c, $ as $01b9c$RemoveScroll } from '../_shared/esm/index-3e2bc99d.js';
13
- import { $ as $1746a345f3d73bb7$export$f680877a34711e37 } from '../_shared/esm/index-936b5179.js';
14
- import { $ as $ea1ef594cf570d83$export$439d29a4e110a164 } from '../_shared/esm/index-6b7b075c.js';
9
+ import { $ as $f1701beae083dbae$export$602eac185826482c, h as hideOthers, b as $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c, a as $01b9c$RemoveScroll, c as $d3863c46a17e8a28$export$20e40289641fbbb6, d as $5cb92bef7577960e$export$177fb62ff3ec1f22 } from '../_shared/esm/Combination-e9f7e64e.js';
10
+ import { $ as $1746a345f3d73bb7$export$f680877a34711e37 } from '../_shared/esm/index-efa9be1a.js';
11
+ import { $ as $cf1ac5d9fe0e8206$export$722aac194ae923, a as $cf1ac5d9fe0e8206$export$be92b6f5f03c0fe9, b as $cf1ac5d9fe0e8206$export$b688253958b8dfe7, c as $cf1ac5d9fe0e8206$export$7c6e2c02157bb7d2 } from '../_shared/esm/index-b84a20c6.js';
12
+ import { $ as $ea1ef594cf570d83$export$439d29a4e110a164 } from '../_shared/esm/index-25a5b393.js';
15
13
  import { B as BtIconChevronDown2Px } from '../_shared/esm/BtIconChevronDown2Px.esm-217276c2.js';
16
14
  import { B as BtIconTickAlt2Px } from '../_shared/esm/BtIconTickAlt2Px.esm-0bc2ded0.js';
17
15
  import { I as Icon } from '../_shared/esm/Icon-abd0d990.js';
18
- import { F as FormControl } from '../_shared/esm/FormControl-9d4ddfec.js';
16
+ import { F as FormControl } from '../_shared/esm/FormControl-f0b8fe91.js';
19
17
  import { C as Context } from '../_shared/esm/Surface-0ca6817d.js';
20
18
  import { A as ArcRootElementContext } from '../_shared/esm/Base-f200653c.js';
19
+ import '../_shared/esm/index-2cfab9f2.js';
21
20
  import '../_shared/esm/suffix-modifier-3d548e45.js';
22
21
  import '../_shared/esm/BtIconAlert.esm-a4608d47.js';
23
22
  import '../_shared/esm/DisclosureMini-ec17b008.js';
24
23
  import '../_shared/esm/Text-14f586ac.js';
24
+ import '../_shared/esm/VisuallyHidden-b9eebf71.js';
25
25
 
26
26
  function $ae6933e535247d3d$export$7d15b64cf5a3a4c4(value, [min, max]) {
27
27
  return Math.min(max, Math.max(min, value));
28
28
  }
29
29
 
30
- const $5cb92bef7577960e$var$CONTEXT_UPDATE = 'dismissableLayer.update';
31
- const $5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE = 'dismissableLayer.pointerDownOutside';
32
- const $5cb92bef7577960e$var$FOCUS_OUTSIDE = 'dismissableLayer.focusOutside';
33
- let $5cb92bef7577960e$var$originalBodyPointerEvents;
34
- const $5cb92bef7577960e$var$DismissableLayerContext = /*#__PURE__*/ createContext({
35
- layers: new Set(),
36
- layersWithOutsidePointerEventsDisabled: new Set(),
37
- branches: new Set()
38
- });
39
- const $5cb92bef7577960e$export$177fb62ff3ec1f22 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
40
- var _node$ownerDocument;
41
- const { disableOutsidePointerEvents: disableOutsidePointerEvents = false , onEscapeKeyDown: onEscapeKeyDown , onPointerDownOutside: onPointerDownOutside , onFocusOutside: onFocusOutside , onInteractOutside: onInteractOutside , onDismiss: onDismiss , ...layerProps } = props;
42
- const context = useContext($5cb92bef7577960e$var$DismissableLayerContext);
43
- const [node1, setNode] = useState(null);
44
- const ownerDocument = (_node$ownerDocument = node1 === null || node1 === void 0 ? void 0 : node1.ownerDocument) !== null && _node$ownerDocument !== void 0 ? _node$ownerDocument : globalThis === null || globalThis === void 0 ? void 0 : globalThis.document;
45
- const [, force] = useState({});
46
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setNode(node)
47
- );
48
- const layers = Array.from(context.layers);
49
- const [highestLayerWithOutsidePointerEventsDisabled] = [
50
- ...context.layersWithOutsidePointerEventsDisabled
51
- ].slice(-1); // prettier-ignore
52
- const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled); // prettier-ignore
53
- const index = node1 ? layers.indexOf(node1) : -1;
54
- const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
55
- const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
56
- const pointerDownOutside = $5cb92bef7577960e$var$usePointerDownOutside((event)=>{
57
- const target = event.target;
58
- const isPointerDownOnBranch = [
59
- ...context.branches
60
- ].some((branch)=>branch.contains(target)
61
- );
62
- if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
63
- onPointerDownOutside === null || onPointerDownOutside === void 0 || onPointerDownOutside(event);
64
- onInteractOutside === null || onInteractOutside === void 0 || onInteractOutside(event);
65
- if (!event.defaultPrevented) onDismiss === null || onDismiss === void 0 || onDismiss();
66
- }, ownerDocument);
67
- const focusOutside = $5cb92bef7577960e$var$useFocusOutside((event)=>{
68
- const target = event.target;
69
- const isFocusInBranch = [
70
- ...context.branches
71
- ].some((branch)=>branch.contains(target)
72
- );
73
- if (isFocusInBranch) return;
74
- onFocusOutside === null || onFocusOutside === void 0 || onFocusOutside(event);
75
- onInteractOutside === null || onInteractOutside === void 0 || onInteractOutside(event);
76
- if (!event.defaultPrevented) onDismiss === null || onDismiss === void 0 || onDismiss();
77
- }, ownerDocument);
78
- $addc16e1bbe58fd0$export$3a72a57244d6e765((event)=>{
79
- const isHighestLayer = index === context.layers.size - 1;
80
- if (!isHighestLayer) return;
81
- onEscapeKeyDown === null || onEscapeKeyDown === void 0 || onEscapeKeyDown(event);
82
- if (!event.defaultPrevented && onDismiss) {
83
- event.preventDefault();
84
- onDismiss();
85
- }
86
- }, ownerDocument);
87
- useEffect(()=>{
88
- if (!node1) return;
89
- if (disableOutsidePointerEvents) {
90
- if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
91
- $5cb92bef7577960e$var$originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
92
- ownerDocument.body.style.pointerEvents = 'none';
93
- }
94
- context.layersWithOutsidePointerEventsDisabled.add(node1);
95
- }
96
- context.layers.add(node1);
97
- $5cb92bef7577960e$var$dispatchUpdate();
98
- return ()=>{
99
- if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) ownerDocument.body.style.pointerEvents = $5cb92bef7577960e$var$originalBodyPointerEvents;
100
- };
101
- }, [
102
- node1,
103
- ownerDocument,
104
- disableOutsidePointerEvents,
105
- context
106
- ]);
107
- /**
108
- * We purposefully prevent combining this effect with the `disableOutsidePointerEvents` effect
109
- * because a change to `disableOutsidePointerEvents` would remove this layer from the stack
110
- * and add it to the end again so the layering order wouldn't be _creation order_.
111
- * We only want them to be removed from context stacks when unmounted.
112
- */ useEffect(()=>{
113
- return ()=>{
114
- if (!node1) return;
115
- context.layers.delete(node1);
116
- context.layersWithOutsidePointerEventsDisabled.delete(node1);
117
- $5cb92bef7577960e$var$dispatchUpdate();
118
- };
119
- }, [
120
- node1,
121
- context
122
- ]);
123
- useEffect(()=>{
124
- const handleUpdate = ()=>force({})
125
- ;
126
- document.addEventListener($5cb92bef7577960e$var$CONTEXT_UPDATE, handleUpdate);
127
- return ()=>document.removeEventListener($5cb92bef7577960e$var$CONTEXT_UPDATE, handleUpdate)
128
- ;
129
- }, []);
130
- return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, layerProps, {
131
- ref: composedRefs,
132
- style: {
133
- pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? 'auto' : 'none' : undefined,
134
- ...props.style
135
- },
136
- onFocusCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocusCapture, focusOutside.onFocusCapture),
137
- onBlurCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onBlurCapture, focusOutside.onBlurCapture),
138
- onPointerDownCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerDownCapture, pointerDownOutside.onPointerDownCapture)
139
- }));
140
- });
141
- /* -----------------------------------------------------------------------------------------------*/ /**
142
- * Listens for `pointerdown` outside a react subtree. We use `pointerdown` rather than `pointerup`
143
- * to mimic layer dismissing behaviour present in OS.
144
- * Returns props to pass to the node we want to check for outside events.
145
- */ function $5cb92bef7577960e$var$usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
146
- const handlePointerDownOutside = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onPointerDownOutside);
147
- const isPointerInsideReactTreeRef = useRef(false);
148
- const handleClickRef = useRef(()=>{});
149
- useEffect(()=>{
150
- const handlePointerDown = (event)=>{
151
- if (event.target && !isPointerInsideReactTreeRef.current) {
152
- const eventDetail = {
153
- originalEvent: event
154
- };
155
- function handleAndDispatchPointerDownOutsideEvent() {
156
- $5cb92bef7577960e$var$handleAndDispatchCustomEvent($5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE, handlePointerDownOutside, eventDetail, {
157
- discrete: true
158
- });
159
- }
160
- /**
161
- * On touch devices, we need to wait for a click event because browsers implement
162
- * a ~350ms delay between the time the user stops touching the display and when the
163
- * browser executres events. We need to ensure we don't reactivate pointer-events within
164
- * this timeframe otherwise the browser may execute events that should have been prevented.
165
- *
166
- * Additionally, this also lets us deal automatically with cancellations when a click event
167
- * isn't raised because the page was considered scrolled/drag-scrolled, long-pressed, etc.
168
- *
169
- * This is why we also continuously remove the previous listener, because we cannot be
170
- * certain that it was raised, and therefore cleaned-up.
171
- */ if (event.pointerType === 'touch') {
172
- ownerDocument.removeEventListener('click', handleClickRef.current);
173
- handleClickRef.current = handleAndDispatchPointerDownOutsideEvent;
174
- ownerDocument.addEventListener('click', handleClickRef.current, {
175
- once: true
176
- });
177
- } else handleAndDispatchPointerDownOutsideEvent();
178
- } else // We need to remove the event listener in case the outside click has been canceled.
179
- // See: https://github.com/radix-ui/primitives/issues/2171
180
- ownerDocument.removeEventListener('click', handleClickRef.current);
181
- isPointerInsideReactTreeRef.current = false;
182
- };
183
- /**
184
- * if this hook executes in a component that mounts via a `pointerdown` event, the event
185
- * would bubble up to the document and trigger a `pointerDownOutside` event. We avoid
186
- * this by delaying the event listener registration on the document.
187
- * This is not React specific, but rather how the DOM works, ie:
188
- * ```
189
- * button.addEventListener('pointerdown', () => {
190
- * console.log('I will log');
191
- * document.addEventListener('pointerdown', () => {
192
- * console.log('I will also log');
193
- * })
194
- * });
195
- */ const timerId = window.setTimeout(()=>{
196
- ownerDocument.addEventListener('pointerdown', handlePointerDown);
197
- }, 0);
198
- return ()=>{
199
- window.clearTimeout(timerId);
200
- ownerDocument.removeEventListener('pointerdown', handlePointerDown);
201
- ownerDocument.removeEventListener('click', handleClickRef.current);
202
- };
203
- }, [
204
- ownerDocument,
205
- handlePointerDownOutside
206
- ]);
207
- return {
208
- // ensures we check React component tree (not just DOM tree)
209
- onPointerDownCapture: ()=>isPointerInsideReactTreeRef.current = true
210
- };
211
- }
212
- /**
213
- * Listens for when focus happens outside a react subtree.
214
- * Returns props to pass to the root (node) of the subtree we want to check.
215
- */ function $5cb92bef7577960e$var$useFocusOutside(onFocusOutside, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
216
- const handleFocusOutside = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onFocusOutside);
217
- const isFocusInsideReactTreeRef = useRef(false);
218
- useEffect(()=>{
219
- const handleFocus = (event)=>{
220
- if (event.target && !isFocusInsideReactTreeRef.current) {
221
- const eventDetail = {
222
- originalEvent: event
223
- };
224
- $5cb92bef7577960e$var$handleAndDispatchCustomEvent($5cb92bef7577960e$var$FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
225
- discrete: false
226
- });
227
- }
228
- };
229
- ownerDocument.addEventListener('focusin', handleFocus);
230
- return ()=>ownerDocument.removeEventListener('focusin', handleFocus)
231
- ;
232
- }, [
233
- ownerDocument,
234
- handleFocusOutside
235
- ]);
236
- return {
237
- onFocusCapture: ()=>isFocusInsideReactTreeRef.current = true
238
- ,
239
- onBlurCapture: ()=>isFocusInsideReactTreeRef.current = false
240
- };
241
- }
242
- function $5cb92bef7577960e$var$dispatchUpdate() {
243
- const event = new CustomEvent($5cb92bef7577960e$var$CONTEXT_UPDATE);
244
- document.dispatchEvent(event);
245
- }
246
- function $5cb92bef7577960e$var$handleAndDispatchCustomEvent(name, handler, detail, { discrete: discrete }) {
247
- const target = detail.originalEvent.target;
248
- const event = new CustomEvent(name, {
249
- bubbles: false,
250
- cancelable: true,
251
- detail: detail
252
- });
253
- if (handler) target.addEventListener(name, handler, {
254
- once: true
255
- });
256
- if (discrete) $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event);
257
- else target.dispatchEvent(event);
258
- }
259
-
260
- const $d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT = 'focusScope.autoFocusOnMount';
261
- const $d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT = 'focusScope.autoFocusOnUnmount';
262
- const $d3863c46a17e8a28$var$EVENT_OPTIONS = {
263
- bubbles: false,
264
- cancelable: true
265
- };
266
- const $d3863c46a17e8a28$export$20e40289641fbbb6 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
267
- const { loop: loop = false , trapped: trapped = false , onMountAutoFocus: onMountAutoFocusProp , onUnmountAutoFocus: onUnmountAutoFocusProp , ...scopeProps } = props;
268
- const [container1, setContainer] = useState(null);
269
- const onMountAutoFocus = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onMountAutoFocusProp);
270
- const onUnmountAutoFocus = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onUnmountAutoFocusProp);
271
- const lastFocusedElementRef = useRef(null);
272
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setContainer(node)
273
- );
274
- const focusScope = useRef({
275
- paused: false,
276
- pause () {
277
- this.paused = true;
278
- },
279
- resume () {
280
- this.paused = false;
281
- }
282
- }).current; // Takes care of trapping focus if focus is moved outside programmatically for example
283
- useEffect(()=>{
284
- if (trapped) {
285
- function handleFocusIn(event) {
286
- if (focusScope.paused || !container1) return;
287
- const target = event.target;
288
- if (container1.contains(target)) lastFocusedElementRef.current = target;
289
- else $d3863c46a17e8a28$var$focus(lastFocusedElementRef.current, {
290
- select: true
291
- });
292
- }
293
- function handleFocusOut(event) {
294
- if (focusScope.paused || !container1) return;
295
- const relatedTarget = event.relatedTarget; // A `focusout` event with a `null` `relatedTarget` will happen in at least two cases:
296
- //
297
- // 1. When the user switches app/tabs/windows/the browser itself loses focus.
298
- // 2. In Google Chrome, when the focused element is removed from the DOM.
299
- //
300
- // We let the browser do its thing here because:
301
- //
302
- // 1. The browser already keeps a memory of what's focused for when the page gets refocused.
303
- // 2. In Google Chrome, if we try to focus the deleted focused element (as per below), it
304
- // throws the CPU to 100%, so we avoid doing anything for this reason here too.
305
- if (relatedTarget === null) return; // If the focus has moved to an actual legitimate element (`relatedTarget !== null`)
306
- // that is outside the container, we move focus to the last valid focused element inside.
307
- if (!container1.contains(relatedTarget)) $d3863c46a17e8a28$var$focus(lastFocusedElementRef.current, {
308
- select: true
309
- });
310
- } // When the focused element gets removed from the DOM, browsers move focus
311
- // back to the document.body. In this case, we move focus to the container
312
- // to keep focus trapped correctly.
313
- function handleMutations(mutations) {
314
- const focusedElement = document.activeElement;
315
- if (focusedElement !== document.body) return;
316
- for (const mutation of mutations)if (mutation.removedNodes.length > 0) $d3863c46a17e8a28$var$focus(container1);
317
- }
318
- document.addEventListener('focusin', handleFocusIn);
319
- document.addEventListener('focusout', handleFocusOut);
320
- const mutationObserver = new MutationObserver(handleMutations);
321
- if (container1) mutationObserver.observe(container1, {
322
- childList: true,
323
- subtree: true
324
- });
325
- return ()=>{
326
- document.removeEventListener('focusin', handleFocusIn);
327
- document.removeEventListener('focusout', handleFocusOut);
328
- mutationObserver.disconnect();
329
- };
330
- }
331
- }, [
332
- trapped,
333
- container1,
334
- focusScope.paused
335
- ]);
336
- useEffect(()=>{
337
- if (container1) {
338
- $d3863c46a17e8a28$var$focusScopesStack.add(focusScope);
339
- const previouslyFocusedElement = document.activeElement;
340
- const hasFocusedCandidate = container1.contains(previouslyFocusedElement);
341
- if (!hasFocusedCandidate) {
342
- const mountEvent = new CustomEvent($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, $d3863c46a17e8a28$var$EVENT_OPTIONS);
343
- container1.addEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
344
- container1.dispatchEvent(mountEvent);
345
- if (!mountEvent.defaultPrevented) {
346
- $d3863c46a17e8a28$var$focusFirst($d3863c46a17e8a28$var$removeLinks($d3863c46a17e8a28$var$getTabbableCandidates(container1)), {
347
- select: true
348
- });
349
- if (document.activeElement === previouslyFocusedElement) $d3863c46a17e8a28$var$focus(container1);
350
- }
351
- }
352
- return ()=>{
353
- container1.removeEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, onMountAutoFocus); // We hit a react bug (fixed in v17) with focusing in unmount.
354
- // We need to delay the focus a little to get around it for now.
355
- // See: https://github.com/facebook/react/issues/17894
356
- setTimeout(()=>{
357
- const unmountEvent = new CustomEvent($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, $d3863c46a17e8a28$var$EVENT_OPTIONS);
358
- container1.addEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
359
- container1.dispatchEvent(unmountEvent);
360
- if (!unmountEvent.defaultPrevented) $d3863c46a17e8a28$var$focus(previouslyFocusedElement !== null && previouslyFocusedElement !== void 0 ? previouslyFocusedElement : document.body, {
361
- select: true
362
- });
363
- // we need to remove the listener after we `dispatchEvent`
364
- container1.removeEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
365
- $d3863c46a17e8a28$var$focusScopesStack.remove(focusScope);
366
- }, 0);
367
- };
368
- }
369
- }, [
370
- container1,
371
- onMountAutoFocus,
372
- onUnmountAutoFocus,
373
- focusScope
374
- ]); // Takes care of looping focus (when tabbing whilst at the edges)
375
- const handleKeyDown = useCallback((event)=>{
376
- if (!loop && !trapped) return;
377
- if (focusScope.paused) return;
378
- const isTabKey = event.key === 'Tab' && !event.altKey && !event.ctrlKey && !event.metaKey;
379
- const focusedElement = document.activeElement;
380
- if (isTabKey && focusedElement) {
381
- const container = event.currentTarget;
382
- const [first, last] = $d3863c46a17e8a28$var$getTabbableEdges(container);
383
- const hasTabbableElementsInside = first && last; // we can only wrap focus if we have tabbable edges
384
- if (!hasTabbableElementsInside) {
385
- if (focusedElement === container) event.preventDefault();
386
- } else {
387
- if (!event.shiftKey && focusedElement === last) {
388
- event.preventDefault();
389
- if (loop) $d3863c46a17e8a28$var$focus(first, {
390
- select: true
391
- });
392
- } else if (event.shiftKey && focusedElement === first) {
393
- event.preventDefault();
394
- if (loop) $d3863c46a17e8a28$var$focus(last, {
395
- select: true
396
- });
397
- }
398
- }
399
- }
400
- }, [
401
- loop,
402
- trapped,
403
- focusScope.paused
404
- ]);
405
- return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
406
- tabIndex: -1
407
- }, scopeProps, {
408
- ref: composedRefs,
409
- onKeyDown: handleKeyDown
410
- }));
411
- });
412
- /* -------------------------------------------------------------------------------------------------
413
- * Utils
414
- * -----------------------------------------------------------------------------------------------*/ /**
415
- * Attempts focusing the first element in a list of candidates.
416
- * Stops when focus has actually moved.
417
- */ function $d3863c46a17e8a28$var$focusFirst(candidates, { select: select = false } = {}) {
418
- const previouslyFocusedElement = document.activeElement;
419
- for (const candidate of candidates){
420
- $d3863c46a17e8a28$var$focus(candidate, {
421
- select: select
422
- });
423
- if (document.activeElement !== previouslyFocusedElement) return;
424
- }
425
- }
426
- /**
427
- * Returns the first and last tabbable elements inside a container.
428
- */ function $d3863c46a17e8a28$var$getTabbableEdges(container) {
429
- const candidates = $d3863c46a17e8a28$var$getTabbableCandidates(container);
430
- const first = $d3863c46a17e8a28$var$findVisible(candidates, container);
431
- const last = $d3863c46a17e8a28$var$findVisible(candidates.reverse(), container);
432
- return [
433
- first,
434
- last
435
- ];
436
- }
437
- /**
438
- * Returns a list of potential tabbable candidates.
439
- *
440
- * NOTE: This is only a close approximation. For example it doesn't take into account cases like when
441
- * elements are not visible. This cannot be worked out easily by just reading a property, but rather
442
- * necessitate runtime knowledge (computed styles, etc). We deal with these cases separately.
443
- *
444
- * See: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker
445
- * Credit: https://github.com/discord/focus-layers/blob/master/src/util/wrapFocus.tsx#L1
446
- */ function $d3863c46a17e8a28$var$getTabbableCandidates(container) {
447
- const nodes = [];
448
- const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
449
- acceptNode: (node)=>{
450
- const isHiddenInput = node.tagName === 'INPUT' && node.type === 'hidden';
451
- if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP; // `.tabIndex` is not the same as the `tabindex` attribute. It works on the
452
- // runtime's understanding of tabbability, so this automatically accounts
453
- // for any kind of element that could be tabbed to.
454
- return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
455
- }
456
- });
457
- while(walker.nextNode())nodes.push(walker.currentNode); // we do not take into account the order of nodes with positive `tabIndex` as it
458
- // hinders accessibility to have tab order different from visual order.
459
- return nodes;
460
- }
461
- /**
462
- * Returns the first visible element in a list.
463
- * NOTE: Only checks visibility up to the `container`.
464
- */ function $d3863c46a17e8a28$var$findVisible(elements, container) {
465
- for (const element of elements){
466
- // we stop checking if it's hidden at the `container` level (excluding)
467
- if (!$d3863c46a17e8a28$var$isHidden(element, {
468
- upTo: container
469
- })) return element;
470
- }
471
- }
472
- function $d3863c46a17e8a28$var$isHidden(node, { upTo: upTo }) {
473
- if (getComputedStyle(node).visibility === 'hidden') return true;
474
- while(node){
475
- // we stop at `upTo` (excluding it)
476
- if (upTo !== undefined && node === upTo) return false;
477
- if (getComputedStyle(node).display === 'none') return true;
478
- node = node.parentElement;
479
- }
480
- return false;
481
- }
482
- function $d3863c46a17e8a28$var$isSelectableInput(element) {
483
- return element instanceof HTMLInputElement && 'select' in element;
484
- }
485
- function $d3863c46a17e8a28$var$focus(element, { select: select = false } = {}) {
486
- // only focus if that element is focusable
487
- if (element && element.focus) {
488
- const previouslyFocusedElement = document.activeElement; // NOTE: we prevent scrolling on focus, to minimize jarring transitions for users
489
- element.focus({
490
- preventScroll: true
491
- }); // only select if its not the same element, it supports selection and we need to select
492
- if (element !== previouslyFocusedElement && $d3863c46a17e8a28$var$isSelectableInput(element) && select) element.select();
493
- }
494
- }
495
- /* -------------------------------------------------------------------------------------------------
496
- * FocusScope stack
497
- * -----------------------------------------------------------------------------------------------*/ const $d3863c46a17e8a28$var$focusScopesStack = $d3863c46a17e8a28$var$createFocusScopesStack();
498
- function $d3863c46a17e8a28$var$createFocusScopesStack() {
499
- /** A stack of focus scopes, with the active one at the top */ let stack = [];
500
- return {
501
- add (focusScope) {
502
- // pause the currently active focus scope (at the top of the stack)
503
- const activeFocusScope = stack[0];
504
- if (focusScope !== activeFocusScope) activeFocusScope === null || activeFocusScope === void 0 || activeFocusScope.pause();
505
- // remove in case it already exists (because we'll re-add it at the top of the stack)
506
- stack = $d3863c46a17e8a28$var$arrayRemove(stack, focusScope);
507
- stack.unshift(focusScope);
508
- },
509
- remove (focusScope) {
510
- var _stack$;
511
- stack = $d3863c46a17e8a28$var$arrayRemove(stack, focusScope);
512
- (_stack$ = stack[0]) === null || _stack$ === void 0 || _stack$.resume();
513
- }
514
- };
515
- }
516
- function $d3863c46a17e8a28$var$arrayRemove(array, item) {
517
- const updatedArray = [
518
- ...array
519
- ];
520
- const index = updatedArray.indexOf(item);
521
- if (index !== -1) updatedArray.splice(index, 1);
522
- return updatedArray;
523
- }
524
- function $d3863c46a17e8a28$var$removeLinks(items) {
525
- return items.filter((item)=>item.tagName !== 'A'
526
- );
527
- }
528
-
529
- const sides = ['top', 'right', 'bottom', 'left'];
530
- const min = Math.min;
531
- const max = Math.max;
532
- const round = Math.round;
533
- const floor = Math.floor;
534
- const createCoords = v => ({
535
- x: v,
536
- y: v
537
- });
538
- const oppositeSideMap = {
539
- left: 'right',
540
- right: 'left',
541
- bottom: 'top',
542
- top: 'bottom'
543
- };
544
- const oppositeAlignmentMap = {
545
- start: 'end',
546
- end: 'start'
547
- };
548
- function clamp(start, value, end) {
549
- return max(start, min(value, end));
550
- }
551
- function evaluate(value, param) {
552
- return typeof value === 'function' ? value(param) : value;
553
- }
554
- function getSide(placement) {
555
- return placement.split('-')[0];
556
- }
557
- function getAlignment(placement) {
558
- return placement.split('-')[1];
559
- }
560
- function getOppositeAxis(axis) {
561
- return axis === 'x' ? 'y' : 'x';
562
- }
563
- function getAxisLength(axis) {
564
- return axis === 'y' ? 'height' : 'width';
565
- }
566
- function getSideAxis(placement) {
567
- return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
568
- }
569
- function getAlignmentAxis(placement) {
570
- return getOppositeAxis(getSideAxis(placement));
571
- }
572
- function getAlignmentSides(placement, rects, rtl) {
573
- if (rtl === void 0) {
574
- rtl = false;
575
- }
576
- const alignment = getAlignment(placement);
577
- const alignmentAxis = getAlignmentAxis(placement);
578
- const length = getAxisLength(alignmentAxis);
579
- let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
580
- if (rects.reference[length] > rects.floating[length]) {
581
- mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
582
- }
583
- return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
584
- }
585
- function getExpandedPlacements(placement) {
586
- const oppositePlacement = getOppositePlacement(placement);
587
- return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
588
- }
589
- function getOppositeAlignmentPlacement(placement) {
590
- return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
591
- }
592
- function getSideList(side, isStart, rtl) {
593
- const lr = ['left', 'right'];
594
- const rl = ['right', 'left'];
595
- const tb = ['top', 'bottom'];
596
- const bt = ['bottom', 'top'];
597
- switch (side) {
598
- case 'top':
599
- case 'bottom':
600
- if (rtl) return isStart ? rl : lr;
601
- return isStart ? lr : rl;
602
- case 'left':
603
- case 'right':
604
- return isStart ? tb : bt;
605
- default:
606
- return [];
607
- }
608
- }
609
- function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
610
- const alignment = getAlignment(placement);
611
- let list = getSideList(getSide(placement), direction === 'start', rtl);
612
- if (alignment) {
613
- list = list.map(side => side + "-" + alignment);
614
- if (flipAlignment) {
615
- list = list.concat(list.map(getOppositeAlignmentPlacement));
616
- }
617
- }
618
- return list;
619
- }
620
- function getOppositePlacement(placement) {
621
- return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
622
- }
623
- function expandPaddingObject(padding) {
624
- return {
625
- top: 0,
626
- right: 0,
627
- bottom: 0,
628
- left: 0,
629
- ...padding
630
- };
631
- }
632
- function getPaddingObject(padding) {
633
- return typeof padding !== 'number' ? expandPaddingObject(padding) : {
634
- top: padding,
635
- right: padding,
636
- bottom: padding,
637
- left: padding
638
- };
639
- }
640
- function rectToClientRect(rect) {
641
- return {
642
- ...rect,
643
- top: rect.y,
644
- left: rect.x,
645
- right: rect.x + rect.width,
646
- bottom: rect.y + rect.height
647
- };
648
- }
649
-
650
- function computeCoordsFromPlacement(_ref, placement, rtl) {
651
- let {
652
- reference,
653
- floating
654
- } = _ref;
655
- const sideAxis = getSideAxis(placement);
656
- const alignmentAxis = getAlignmentAxis(placement);
657
- const alignLength = getAxisLength(alignmentAxis);
658
- const side = getSide(placement);
659
- const isVertical = sideAxis === 'y';
660
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
661
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
662
- const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
663
- let coords;
664
- switch (side) {
665
- case 'top':
666
- coords = {
667
- x: commonX,
668
- y: reference.y - floating.height
669
- };
670
- break;
671
- case 'bottom':
672
- coords = {
673
- x: commonX,
674
- y: reference.y + reference.height
675
- };
676
- break;
677
- case 'right':
678
- coords = {
679
- x: reference.x + reference.width,
680
- y: commonY
681
- };
682
- break;
683
- case 'left':
684
- coords = {
685
- x: reference.x - floating.width,
686
- y: commonY
687
- };
688
- break;
689
- default:
690
- coords = {
691
- x: reference.x,
692
- y: reference.y
693
- };
694
- }
695
- switch (getAlignment(placement)) {
696
- case 'start':
697
- coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
698
- break;
699
- case 'end':
700
- coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
701
- break;
702
- }
703
- return coords;
704
- }
705
-
706
- /**
707
- * Computes the `x` and `y` coordinates that will place the floating element
708
- * next to a reference element when it is given a certain positioning strategy.
709
- *
710
- * This export does not have any `platform` interface logic. You will need to
711
- * write one for the platform you are using Floating UI with.
712
- */
713
- const computePosition$1 = async (reference, floating, config) => {
714
- const {
715
- placement = 'bottom',
716
- strategy = 'absolute',
717
- middleware = [],
718
- platform
719
- } = config;
720
- const validMiddleware = middleware.filter(Boolean);
721
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
722
- let rects = await platform.getElementRects({
723
- reference,
724
- floating,
725
- strategy
726
- });
727
- let {
728
- x,
729
- y
730
- } = computeCoordsFromPlacement(rects, placement, rtl);
731
- let statefulPlacement = placement;
732
- let middlewareData = {};
733
- let resetCount = 0;
734
- for (let i = 0; i < validMiddleware.length; i++) {
735
- const {
736
- name,
737
- fn
738
- } = validMiddleware[i];
739
- const {
740
- x: nextX,
741
- y: nextY,
742
- data,
743
- reset
744
- } = await fn({
745
- x,
746
- y,
747
- initialPlacement: placement,
748
- placement: statefulPlacement,
749
- strategy,
750
- middlewareData,
751
- rects,
752
- platform,
753
- elements: {
754
- reference,
755
- floating
756
- }
757
- });
758
- x = nextX != null ? nextX : x;
759
- y = nextY != null ? nextY : y;
760
- middlewareData = {
761
- ...middlewareData,
762
- [name]: {
763
- ...middlewareData[name],
764
- ...data
765
- }
766
- };
767
- if (reset && resetCount <= 50) {
768
- resetCount++;
769
- if (typeof reset === 'object') {
770
- if (reset.placement) {
771
- statefulPlacement = reset.placement;
772
- }
773
- if (reset.rects) {
774
- rects = reset.rects === true ? await platform.getElementRects({
775
- reference,
776
- floating,
777
- strategy
778
- }) : reset.rects;
779
- }
780
- ({
781
- x,
782
- y
783
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
784
- }
785
- i = -1;
786
- continue;
787
- }
788
- }
789
- return {
790
- x,
791
- y,
792
- placement: statefulPlacement,
793
- strategy,
794
- middlewareData
795
- };
796
- };
797
-
798
- /**
799
- * Resolves with an object of overflow side offsets that determine how much the
800
- * element is overflowing a given clipping boundary on each side.
801
- * - positive = overflowing the boundary by that number of pixels
802
- * - negative = how many pixels left before it will overflow
803
- * - 0 = lies flush with the boundary
804
- * @see https://floating-ui.com/docs/detectOverflow
805
- */
806
- async function detectOverflow(state, options) {
807
- var _await$platform$isEle;
808
- if (options === void 0) {
809
- options = {};
810
- }
811
- const {
812
- x,
813
- y,
814
- platform,
815
- rects,
816
- elements,
817
- strategy
818
- } = state;
819
- const {
820
- boundary = 'clippingAncestors',
821
- rootBoundary = 'viewport',
822
- elementContext = 'floating',
823
- altBoundary = false,
824
- padding = 0
825
- } = evaluate(options, state);
826
- const paddingObject = getPaddingObject(padding);
827
- const altContext = elementContext === 'floating' ? 'reference' : 'floating';
828
- const element = elements[altBoundary ? altContext : elementContext];
829
- const clippingClientRect = rectToClientRect(await platform.getClippingRect({
830
- element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
831
- boundary,
832
- rootBoundary,
833
- strategy
834
- }));
835
- const rect = elementContext === 'floating' ? {
836
- ...rects.floating,
837
- x,
838
- y
839
- } : rects.reference;
840
- const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
841
- const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
842
- x: 1,
843
- y: 1
844
- } : {
845
- x: 1,
846
- y: 1
847
- };
848
- const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
849
- rect,
850
- offsetParent,
851
- strategy
852
- }) : rect);
853
- return {
854
- top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
855
- bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
856
- left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
857
- right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
858
- };
859
- }
860
-
861
- /**
862
- * Provides data to position an inner element of the floating element so that it
863
- * appears centered to the reference element.
864
- * @see https://floating-ui.com/docs/arrow
865
- */
866
- const arrow$1 = options => ({
867
- name: 'arrow',
868
- options,
869
- async fn(state) {
870
- const {
871
- x,
872
- y,
873
- placement,
874
- rects,
875
- platform,
876
- elements,
877
- middlewareData
878
- } = state;
879
- // Since `element` is required, we don't Partial<> the type.
880
- const {
881
- element,
882
- padding = 0
883
- } = evaluate(options, state) || {};
884
- if (element == null) {
885
- return {};
886
- }
887
- const paddingObject = getPaddingObject(padding);
888
- const coords = {
889
- x,
890
- y
891
- };
892
- const axis = getAlignmentAxis(placement);
893
- const length = getAxisLength(axis);
894
- const arrowDimensions = await platform.getDimensions(element);
895
- const isYAxis = axis === 'y';
896
- const minProp = isYAxis ? 'top' : 'left';
897
- const maxProp = isYAxis ? 'bottom' : 'right';
898
- const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
899
- const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
900
- const startDiff = coords[axis] - rects.reference[axis];
901
- const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
902
- let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
903
-
904
- // DOM platform can return `window` as the `offsetParent`.
905
- if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
906
- clientSize = elements.floating[clientProp] || rects.floating[length];
907
- }
908
- const centerToReference = endDiff / 2 - startDiff / 2;
909
-
910
- // If the padding is large enough that it causes the arrow to no longer be
911
- // centered, modify the padding so that it is centered.
912
- const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
913
- const minPadding = min(paddingObject[minProp], largestPossiblePadding);
914
- const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
915
-
916
- // Make sure the arrow doesn't overflow the floating element if the center
917
- // point is outside the floating element's bounds.
918
- const min$1 = minPadding;
919
- const max = clientSize - arrowDimensions[length] - maxPadding;
920
- const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
921
- const offset = clamp(min$1, center, max);
922
-
923
- // If the reference is small enough that the arrow's padding causes it to
924
- // to point to nothing for an aligned placement, adjust the offset of the
925
- // floating element itself. To ensure `shift()` continues to take action,
926
- // a single reset is performed when this is true.
927
- const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
928
- const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
929
- return {
930
- [axis]: coords[axis] + alignmentOffset,
931
- data: {
932
- [axis]: offset,
933
- centerOffset: center - offset - alignmentOffset,
934
- ...(shouldAddOffset && {
935
- alignmentOffset
936
- })
937
- },
938
- reset: shouldAddOffset
939
- };
940
- }
941
- });
942
-
943
- /**
944
- * Optimizes the visibility of the floating element by flipping the `placement`
945
- * in order to keep it in view when the preferred placement(s) will overflow the
946
- * clipping boundary. Alternative to `autoPlacement`.
947
- * @see https://floating-ui.com/docs/flip
948
- */
949
- const flip = function (options) {
950
- if (options === void 0) {
951
- options = {};
952
- }
953
- return {
954
- name: 'flip',
955
- options,
956
- async fn(state) {
957
- var _middlewareData$arrow, _middlewareData$flip;
958
- const {
959
- placement,
960
- middlewareData,
961
- rects,
962
- initialPlacement,
963
- platform,
964
- elements
965
- } = state;
966
- const {
967
- mainAxis: checkMainAxis = true,
968
- crossAxis: checkCrossAxis = true,
969
- fallbackPlacements: specifiedFallbackPlacements,
970
- fallbackStrategy = 'bestFit',
971
- fallbackAxisSideDirection = 'none',
972
- flipAlignment = true,
973
- ...detectOverflowOptions
974
- } = evaluate(options, state);
975
-
976
- // If a reset by the arrow was caused due to an alignment offset being
977
- // added, we should skip any logic now since `flip()` has already done its
978
- // work.
979
- // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
980
- if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
981
- return {};
982
- }
983
- const side = getSide(placement);
984
- const isBasePlacement = getSide(initialPlacement) === initialPlacement;
985
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
986
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
987
- if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
988
- fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
989
- }
990
- const placements = [initialPlacement, ...fallbackPlacements];
991
- const overflow = await detectOverflow(state, detectOverflowOptions);
992
- const overflows = [];
993
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
994
- if (checkMainAxis) {
995
- overflows.push(overflow[side]);
996
- }
997
- if (checkCrossAxis) {
998
- const sides = getAlignmentSides(placement, rects, rtl);
999
- overflows.push(overflow[sides[0]], overflow[sides[1]]);
1000
- }
1001
- overflowsData = [...overflowsData, {
1002
- placement,
1003
- overflows
1004
- }];
1005
-
1006
- // One or more sides is overflowing.
1007
- if (!overflows.every(side => side <= 0)) {
1008
- var _middlewareData$flip2, _overflowsData$filter;
1009
- const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
1010
- const nextPlacement = placements[nextIndex];
1011
- if (nextPlacement) {
1012
- // Try next placement and re-run the lifecycle.
1013
- return {
1014
- data: {
1015
- index: nextIndex,
1016
- overflows: overflowsData
1017
- },
1018
- reset: {
1019
- placement: nextPlacement
1020
- }
1021
- };
1022
- }
1023
-
1024
- // First, find the candidates that fit on the mainAxis side of overflow,
1025
- // then find the placement that fits the best on the main crossAxis side.
1026
- let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
1027
-
1028
- // Otherwise fallback.
1029
- if (!resetPlacement) {
1030
- switch (fallbackStrategy) {
1031
- case 'bestFit':
1032
- {
1033
- var _overflowsData$map$so;
1034
- const placement = (_overflowsData$map$so = overflowsData.map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
1035
- if (placement) {
1036
- resetPlacement = placement;
1037
- }
1038
- break;
1039
- }
1040
- case 'initialPlacement':
1041
- resetPlacement = initialPlacement;
1042
- break;
1043
- }
1044
- }
1045
- if (placement !== resetPlacement) {
1046
- return {
1047
- reset: {
1048
- placement: resetPlacement
1049
- }
1050
- };
1051
- }
1052
- }
1053
- return {};
1054
- }
1055
- };
1056
- };
1057
-
1058
- function getSideOffsets(overflow, rect) {
1059
- return {
1060
- top: overflow.top - rect.height,
1061
- right: overflow.right - rect.width,
1062
- bottom: overflow.bottom - rect.height,
1063
- left: overflow.left - rect.width
1064
- };
1065
- }
1066
- function isAnySideFullyClipped(overflow) {
1067
- return sides.some(side => overflow[side] >= 0);
1068
- }
1069
- /**
1070
- * Provides data to hide the floating element in applicable situations, such as
1071
- * when it is not in the same clipping context as the reference element.
1072
- * @see https://floating-ui.com/docs/hide
1073
- */
1074
- const hide = function (options) {
1075
- if (options === void 0) {
1076
- options = {};
1077
- }
1078
- return {
1079
- name: 'hide',
1080
- options,
1081
- async fn(state) {
1082
- const {
1083
- rects
1084
- } = state;
1085
- const {
1086
- strategy = 'referenceHidden',
1087
- ...detectOverflowOptions
1088
- } = evaluate(options, state);
1089
- switch (strategy) {
1090
- case 'referenceHidden':
1091
- {
1092
- const overflow = await detectOverflow(state, {
1093
- ...detectOverflowOptions,
1094
- elementContext: 'reference'
1095
- });
1096
- const offsets = getSideOffsets(overflow, rects.reference);
1097
- return {
1098
- data: {
1099
- referenceHiddenOffsets: offsets,
1100
- referenceHidden: isAnySideFullyClipped(offsets)
1101
- }
1102
- };
1103
- }
1104
- case 'escaped':
1105
- {
1106
- const overflow = await detectOverflow(state, {
1107
- ...detectOverflowOptions,
1108
- altBoundary: true
1109
- });
1110
- const offsets = getSideOffsets(overflow, rects.floating);
1111
- return {
1112
- data: {
1113
- escapedOffsets: offsets,
1114
- escaped: isAnySideFullyClipped(offsets)
1115
- }
1116
- };
1117
- }
1118
- default:
1119
- {
1120
- return {};
1121
- }
1122
- }
1123
- }
1124
- };
1125
- };
1126
-
1127
- // For type backwards-compatibility, the `OffsetOptions` type was also
1128
- // Derivable.
1129
- async function convertValueToCoords(state, options) {
1130
- const {
1131
- placement,
1132
- platform,
1133
- elements
1134
- } = state;
1135
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1136
- const side = getSide(placement);
1137
- const alignment = getAlignment(placement);
1138
- const isVertical = getSideAxis(placement) === 'y';
1139
- const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
1140
- const crossAxisMulti = rtl && isVertical ? -1 : 1;
1141
- const rawValue = evaluate(options, state);
1142
-
1143
- // eslint-disable-next-line prefer-const
1144
- let {
1145
- mainAxis,
1146
- crossAxis,
1147
- alignmentAxis
1148
- } = typeof rawValue === 'number' ? {
1149
- mainAxis: rawValue,
1150
- crossAxis: 0,
1151
- alignmentAxis: null
1152
- } : {
1153
- mainAxis: 0,
1154
- crossAxis: 0,
1155
- alignmentAxis: null,
1156
- ...rawValue
1157
- };
1158
- if (alignment && typeof alignmentAxis === 'number') {
1159
- crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
1160
- }
1161
- return isVertical ? {
1162
- x: crossAxis * crossAxisMulti,
1163
- y: mainAxis * mainAxisMulti
1164
- } : {
1165
- x: mainAxis * mainAxisMulti,
1166
- y: crossAxis * crossAxisMulti
1167
- };
1168
- }
1169
-
1170
- /**
1171
- * Modifies the placement by translating the floating element along the
1172
- * specified axes.
1173
- * A number (shorthand for `mainAxis` or distance), or an axes configuration
1174
- * object may be passed.
1175
- * @see https://floating-ui.com/docs/offset
1176
- */
1177
- const offset = function (options) {
1178
- if (options === void 0) {
1179
- options = 0;
1180
- }
1181
- return {
1182
- name: 'offset',
1183
- options,
1184
- async fn(state) {
1185
- const {
1186
- x,
1187
- y
1188
- } = state;
1189
- const diffCoords = await convertValueToCoords(state, options);
1190
- return {
1191
- x: x + diffCoords.x,
1192
- y: y + diffCoords.y,
1193
- data: diffCoords
1194
- };
1195
- }
1196
- };
1197
- };
1198
-
1199
- /**
1200
- * Optimizes the visibility of the floating element by shifting it in order to
1201
- * keep it in view when it will overflow the clipping boundary.
1202
- * @see https://floating-ui.com/docs/shift
1203
- */
1204
- const shift = function (options) {
1205
- if (options === void 0) {
1206
- options = {};
1207
- }
1208
- return {
1209
- name: 'shift',
1210
- options,
1211
- async fn(state) {
1212
- const {
1213
- x,
1214
- y,
1215
- placement
1216
- } = state;
1217
- const {
1218
- mainAxis: checkMainAxis = true,
1219
- crossAxis: checkCrossAxis = false,
1220
- limiter = {
1221
- fn: _ref => {
1222
- let {
1223
- x,
1224
- y
1225
- } = _ref;
1226
- return {
1227
- x,
1228
- y
1229
- };
1230
- }
1231
- },
1232
- ...detectOverflowOptions
1233
- } = evaluate(options, state);
1234
- const coords = {
1235
- x,
1236
- y
1237
- };
1238
- const overflow = await detectOverflow(state, detectOverflowOptions);
1239
- const crossAxis = getSideAxis(getSide(placement));
1240
- const mainAxis = getOppositeAxis(crossAxis);
1241
- let mainAxisCoord = coords[mainAxis];
1242
- let crossAxisCoord = coords[crossAxis];
1243
- if (checkMainAxis) {
1244
- const minSide = mainAxis === 'y' ? 'top' : 'left';
1245
- const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
1246
- const min = mainAxisCoord + overflow[minSide];
1247
- const max = mainAxisCoord - overflow[maxSide];
1248
- mainAxisCoord = clamp(min, mainAxisCoord, max);
1249
- }
1250
- if (checkCrossAxis) {
1251
- const minSide = crossAxis === 'y' ? 'top' : 'left';
1252
- const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
1253
- const min = crossAxisCoord + overflow[minSide];
1254
- const max = crossAxisCoord - overflow[maxSide];
1255
- crossAxisCoord = clamp(min, crossAxisCoord, max);
1256
- }
1257
- const limitedCoords = limiter.fn({
1258
- ...state,
1259
- [mainAxis]: mainAxisCoord,
1260
- [crossAxis]: crossAxisCoord
1261
- });
1262
- return {
1263
- ...limitedCoords,
1264
- data: {
1265
- x: limitedCoords.x - x,
1266
- y: limitedCoords.y - y
1267
- }
1268
- };
1269
- }
1270
- };
1271
- };
1272
- /**
1273
- * Built-in `limiter` that will stop `shift()` at a certain point.
1274
- */
1275
- const limitShift = function (options) {
1276
- if (options === void 0) {
1277
- options = {};
1278
- }
1279
- return {
1280
- options,
1281
- fn(state) {
1282
- const {
1283
- x,
1284
- y,
1285
- placement,
1286
- rects,
1287
- middlewareData
1288
- } = state;
1289
- const {
1290
- offset = 0,
1291
- mainAxis: checkMainAxis = true,
1292
- crossAxis: checkCrossAxis = true
1293
- } = evaluate(options, state);
1294
- const coords = {
1295
- x,
1296
- y
1297
- };
1298
- const crossAxis = getSideAxis(placement);
1299
- const mainAxis = getOppositeAxis(crossAxis);
1300
- let mainAxisCoord = coords[mainAxis];
1301
- let crossAxisCoord = coords[crossAxis];
1302
- const rawOffset = evaluate(offset, state);
1303
- const computedOffset = typeof rawOffset === 'number' ? {
1304
- mainAxis: rawOffset,
1305
- crossAxis: 0
1306
- } : {
1307
- mainAxis: 0,
1308
- crossAxis: 0,
1309
- ...rawOffset
1310
- };
1311
- if (checkMainAxis) {
1312
- const len = mainAxis === 'y' ? 'height' : 'width';
1313
- const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
1314
- const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
1315
- if (mainAxisCoord < limitMin) {
1316
- mainAxisCoord = limitMin;
1317
- } else if (mainAxisCoord > limitMax) {
1318
- mainAxisCoord = limitMax;
1319
- }
1320
- }
1321
- if (checkCrossAxis) {
1322
- var _middlewareData$offse, _middlewareData$offse2;
1323
- const len = mainAxis === 'y' ? 'width' : 'height';
1324
- const isOriginSide = ['top', 'left'].includes(getSide(placement));
1325
- const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
1326
- const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
1327
- if (crossAxisCoord < limitMin) {
1328
- crossAxisCoord = limitMin;
1329
- } else if (crossAxisCoord > limitMax) {
1330
- crossAxisCoord = limitMax;
1331
- }
1332
- }
1333
- return {
1334
- [mainAxis]: mainAxisCoord,
1335
- [crossAxis]: crossAxisCoord
1336
- };
1337
- }
1338
- };
1339
- };
1340
-
1341
- /**
1342
- * Provides data that allows you to change the size of the floating element —
1343
- * for instance, prevent it from overflowing the clipping boundary or match the
1344
- * width of the reference element.
1345
- * @see https://floating-ui.com/docs/size
1346
- */
1347
- const size = function (options) {
1348
- if (options === void 0) {
1349
- options = {};
1350
- }
1351
- return {
1352
- name: 'size',
1353
- options,
1354
- async fn(state) {
1355
- const {
1356
- placement,
1357
- rects,
1358
- platform,
1359
- elements
1360
- } = state;
1361
- const {
1362
- apply = () => {},
1363
- ...detectOverflowOptions
1364
- } = evaluate(options, state);
1365
- const overflow = await detectOverflow(state, detectOverflowOptions);
1366
- const side = getSide(placement);
1367
- const alignment = getAlignment(placement);
1368
- const isYAxis = getSideAxis(placement) === 'y';
1369
- const {
1370
- width,
1371
- height
1372
- } = rects.floating;
1373
- let heightSide;
1374
- let widthSide;
1375
- if (side === 'top' || side === 'bottom') {
1376
- heightSide = side;
1377
- widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
1378
- } else {
1379
- widthSide = side;
1380
- heightSide = alignment === 'end' ? 'top' : 'bottom';
1381
- }
1382
- const overflowAvailableHeight = height - overflow[heightSide];
1383
- const overflowAvailableWidth = width - overflow[widthSide];
1384
- const noShift = !state.middlewareData.shift;
1385
- let availableHeight = overflowAvailableHeight;
1386
- let availableWidth = overflowAvailableWidth;
1387
- if (isYAxis) {
1388
- const maximumClippingWidth = width - overflow.left - overflow.right;
1389
- availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
1390
- } else {
1391
- const maximumClippingHeight = height - overflow.top - overflow.bottom;
1392
- availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
1393
- }
1394
- if (noShift && !alignment) {
1395
- const xMin = max(overflow.left, 0);
1396
- const xMax = max(overflow.right, 0);
1397
- const yMin = max(overflow.top, 0);
1398
- const yMax = max(overflow.bottom, 0);
1399
- if (isYAxis) {
1400
- availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
1401
- } else {
1402
- availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
1403
- }
1404
- }
1405
- await apply({
1406
- ...state,
1407
- availableWidth,
1408
- availableHeight
1409
- });
1410
- const nextDimensions = await platform.getDimensions(elements.floating);
1411
- if (width !== nextDimensions.width || height !== nextDimensions.height) {
1412
- return {
1413
- reset: {
1414
- rects: true
1415
- }
1416
- };
1417
- }
1418
- return {};
1419
- }
1420
- };
1421
- };
1422
-
1423
- function getNodeName(node) {
1424
- if (isNode(node)) {
1425
- return (node.nodeName || '').toLowerCase();
1426
- }
1427
- // Mocked nodes in testing environments may not be instances of Node. By
1428
- // returning `#document` an infinite loop won't occur.
1429
- // https://github.com/floating-ui/floating-ui/issues/2317
1430
- return '#document';
1431
- }
1432
- function getWindow(node) {
1433
- var _node$ownerDocument;
1434
- return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1435
- }
1436
- function getDocumentElement(node) {
1437
- var _ref;
1438
- return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1439
- }
1440
- function isNode(value) {
1441
- return value instanceof Node || value instanceof getWindow(value).Node;
1442
- }
1443
- function isElement(value) {
1444
- return value instanceof Element || value instanceof getWindow(value).Element;
1445
- }
1446
- function isHTMLElement(value) {
1447
- return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1448
- }
1449
- function isShadowRoot(value) {
1450
- // Browsers without `ShadowRoot` support.
1451
- if (typeof ShadowRoot === 'undefined') {
1452
- return false;
1453
- }
1454
- return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1455
- }
1456
- function isOverflowElement(element) {
1457
- const {
1458
- overflow,
1459
- overflowX,
1460
- overflowY,
1461
- display
1462
- } = getComputedStyle$1(element);
1463
- return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
1464
- }
1465
- function isTableElement(element) {
1466
- return ['table', 'td', 'th'].includes(getNodeName(element));
1467
- }
1468
- function isContainingBlock(element) {
1469
- const webkit = isWebKit();
1470
- const css = getComputedStyle$1(element);
1471
-
1472
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1473
- return css.transform !== 'none' || css.perspective !== 'none' || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
1474
- }
1475
- function getContainingBlock(element) {
1476
- let currentNode = getParentNode(element);
1477
- while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1478
- if (isContainingBlock(currentNode)) {
1479
- return currentNode;
1480
- } else {
1481
- currentNode = getParentNode(currentNode);
1482
- }
1483
- }
1484
- return null;
1485
- }
1486
- function isWebKit() {
1487
- if (typeof CSS === 'undefined' || !CSS.supports) return false;
1488
- return CSS.supports('-webkit-backdrop-filter', 'none');
1489
- }
1490
- function isLastTraversableNode(node) {
1491
- return ['html', 'body', '#document'].includes(getNodeName(node));
1492
- }
1493
- function getComputedStyle$1(element) {
1494
- return getWindow(element).getComputedStyle(element);
1495
- }
1496
- function getNodeScroll(element) {
1497
- if (isElement(element)) {
1498
- return {
1499
- scrollLeft: element.scrollLeft,
1500
- scrollTop: element.scrollTop
1501
- };
1502
- }
1503
- return {
1504
- scrollLeft: element.pageXOffset,
1505
- scrollTop: element.pageYOffset
1506
- };
1507
- }
1508
- function getParentNode(node) {
1509
- if (getNodeName(node) === 'html') {
1510
- return node;
1511
- }
1512
- const result =
1513
- // Step into the shadow DOM of the parent of a slotted node.
1514
- node.assignedSlot ||
1515
- // DOM Element detected.
1516
- node.parentNode ||
1517
- // ShadowRoot detected.
1518
- isShadowRoot(node) && node.host ||
1519
- // Fallback.
1520
- getDocumentElement(node);
1521
- return isShadowRoot(result) ? result.host : result;
1522
- }
1523
- function getNearestOverflowAncestor(node) {
1524
- const parentNode = getParentNode(node);
1525
- if (isLastTraversableNode(parentNode)) {
1526
- return node.ownerDocument ? node.ownerDocument.body : node.body;
1527
- }
1528
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1529
- return parentNode;
1530
- }
1531
- return getNearestOverflowAncestor(parentNode);
1532
- }
1533
- function getOverflowAncestors(node, list, traverseIframes) {
1534
- var _node$ownerDocument2;
1535
- if (list === void 0) {
1536
- list = [];
1537
- }
1538
- if (traverseIframes === void 0) {
1539
- traverseIframes = true;
1540
- }
1541
- const scrollableAncestor = getNearestOverflowAncestor(node);
1542
- const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1543
- const win = getWindow(scrollableAncestor);
1544
- if (isBody) {
1545
- return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
1546
- }
1547
- return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1548
- }
1549
-
1550
- function getCssDimensions(element) {
1551
- const css = getComputedStyle$1(element);
1552
- // In testing environments, the `width` and `height` properties are empty
1553
- // strings for SVG elements, returning NaN. Fallback to `0` in this case.
1554
- let width = parseFloat(css.width) || 0;
1555
- let height = parseFloat(css.height) || 0;
1556
- const hasOffset = isHTMLElement(element);
1557
- const offsetWidth = hasOffset ? element.offsetWidth : width;
1558
- const offsetHeight = hasOffset ? element.offsetHeight : height;
1559
- const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1560
- if (shouldFallback) {
1561
- width = offsetWidth;
1562
- height = offsetHeight;
1563
- }
1564
- return {
1565
- width,
1566
- height,
1567
- $: shouldFallback
1568
- };
1569
- }
1570
-
1571
- function unwrapElement(element) {
1572
- return !isElement(element) ? element.contextElement : element;
1573
- }
1574
-
1575
- function getScale(element) {
1576
- const domElement = unwrapElement(element);
1577
- if (!isHTMLElement(domElement)) {
1578
- return createCoords(1);
1579
- }
1580
- const rect = domElement.getBoundingClientRect();
1581
- const {
1582
- width,
1583
- height,
1584
- $
1585
- } = getCssDimensions(domElement);
1586
- let x = ($ ? round(rect.width) : rect.width) / width;
1587
- let y = ($ ? round(rect.height) : rect.height) / height;
1588
-
1589
- // 0, NaN, or Infinity should always fallback to 1.
1590
-
1591
- if (!x || !Number.isFinite(x)) {
1592
- x = 1;
1593
- }
1594
- if (!y || !Number.isFinite(y)) {
1595
- y = 1;
1596
- }
1597
- return {
1598
- x,
1599
- y
1600
- };
1601
- }
1602
-
1603
- const noOffsets = /*#__PURE__*/createCoords(0);
1604
- function getVisualOffsets(element) {
1605
- const win = getWindow(element);
1606
- if (!isWebKit() || !win.visualViewport) {
1607
- return noOffsets;
1608
- }
1609
- return {
1610
- x: win.visualViewport.offsetLeft,
1611
- y: win.visualViewport.offsetTop
1612
- };
1613
- }
1614
- function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
1615
- if (isFixed === void 0) {
1616
- isFixed = false;
1617
- }
1618
- if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
1619
- return false;
1620
- }
1621
- return isFixed;
1622
- }
1623
-
1624
- function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1625
- if (includeScale === void 0) {
1626
- includeScale = false;
1627
- }
1628
- if (isFixedStrategy === void 0) {
1629
- isFixedStrategy = false;
1630
- }
1631
- const clientRect = element.getBoundingClientRect();
1632
- const domElement = unwrapElement(element);
1633
- let scale = createCoords(1);
1634
- if (includeScale) {
1635
- if (offsetParent) {
1636
- if (isElement(offsetParent)) {
1637
- scale = getScale(offsetParent);
1638
- }
1639
- } else {
1640
- scale = getScale(element);
1641
- }
1642
- }
1643
- const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1644
- let x = (clientRect.left + visualOffsets.x) / scale.x;
1645
- let y = (clientRect.top + visualOffsets.y) / scale.y;
1646
- let width = clientRect.width / scale.x;
1647
- let height = clientRect.height / scale.y;
1648
- if (domElement) {
1649
- const win = getWindow(domElement);
1650
- const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1651
- let currentIFrame = win.frameElement;
1652
- while (currentIFrame && offsetParent && offsetWin !== win) {
1653
- const iframeScale = getScale(currentIFrame);
1654
- const iframeRect = currentIFrame.getBoundingClientRect();
1655
- const css = getComputedStyle$1(currentIFrame);
1656
- const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1657
- const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1658
- x *= iframeScale.x;
1659
- y *= iframeScale.y;
1660
- width *= iframeScale.x;
1661
- height *= iframeScale.y;
1662
- x += left;
1663
- y += top;
1664
- currentIFrame = getWindow(currentIFrame).frameElement;
1665
- }
1666
- }
1667
- return rectToClientRect({
1668
- width,
1669
- height,
1670
- x,
1671
- y
1672
- });
1673
- }
1674
-
1675
- function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1676
- let {
1677
- rect,
1678
- offsetParent,
1679
- strategy
1680
- } = _ref;
1681
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
1682
- const documentElement = getDocumentElement(offsetParent);
1683
- if (offsetParent === documentElement) {
1684
- return rect;
1685
- }
1686
- let scroll = {
1687
- scrollLeft: 0,
1688
- scrollTop: 0
1689
- };
1690
- let scale = createCoords(1);
1691
- const offsets = createCoords(0);
1692
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1693
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1694
- scroll = getNodeScroll(offsetParent);
1695
- }
1696
- if (isHTMLElement(offsetParent)) {
1697
- const offsetRect = getBoundingClientRect(offsetParent);
1698
- scale = getScale(offsetParent);
1699
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1700
- offsets.y = offsetRect.y + offsetParent.clientTop;
1701
- }
1702
- }
1703
- return {
1704
- width: rect.width * scale.x,
1705
- height: rect.height * scale.y,
1706
- x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
1707
- y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
1708
- };
1709
- }
1710
-
1711
- function getClientRects(element) {
1712
- return Array.from(element.getClientRects());
1713
- }
1714
-
1715
- function getWindowScrollBarX(element) {
1716
- // If <html> has a CSS width greater than the viewport, then this will be
1717
- // incorrect for RTL.
1718
- return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
1719
- }
1720
-
1721
- // Gets the entire size of the scrollable document area, even extending outside
1722
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1723
- function getDocumentRect(element) {
1724
- const html = getDocumentElement(element);
1725
- const scroll = getNodeScroll(element);
1726
- const body = element.ownerDocument.body;
1727
- const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1728
- const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1729
- let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1730
- const y = -scroll.scrollTop;
1731
- if (getComputedStyle$1(body).direction === 'rtl') {
1732
- x += max(html.clientWidth, body.clientWidth) - width;
1733
- }
1734
- return {
1735
- width,
1736
- height,
1737
- x,
1738
- y
1739
- };
1740
- }
1741
-
1742
- function getViewportRect(element, strategy) {
1743
- const win = getWindow(element);
1744
- const html = getDocumentElement(element);
1745
- const visualViewport = win.visualViewport;
1746
- let width = html.clientWidth;
1747
- let height = html.clientHeight;
1748
- let x = 0;
1749
- let y = 0;
1750
- if (visualViewport) {
1751
- width = visualViewport.width;
1752
- height = visualViewport.height;
1753
- const visualViewportBased = isWebKit();
1754
- if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1755
- x = visualViewport.offsetLeft;
1756
- y = visualViewport.offsetTop;
1757
- }
1758
- }
1759
- return {
1760
- width,
1761
- height,
1762
- x,
1763
- y
1764
- };
1765
- }
1766
-
1767
- // Returns the inner client rect, subtracting scrollbars if present.
1768
- function getInnerBoundingClientRect(element, strategy) {
1769
- const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1770
- const top = clientRect.top + element.clientTop;
1771
- const left = clientRect.left + element.clientLeft;
1772
- const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1773
- const width = element.clientWidth * scale.x;
1774
- const height = element.clientHeight * scale.y;
1775
- const x = left * scale.x;
1776
- const y = top * scale.y;
1777
- return {
1778
- width,
1779
- height,
1780
- x,
1781
- y
1782
- };
1783
- }
1784
- function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1785
- let rect;
1786
- if (clippingAncestor === 'viewport') {
1787
- rect = getViewportRect(element, strategy);
1788
- } else if (clippingAncestor === 'document') {
1789
- rect = getDocumentRect(getDocumentElement(element));
1790
- } else if (isElement(clippingAncestor)) {
1791
- rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1792
- } else {
1793
- const visualOffsets = getVisualOffsets(element);
1794
- rect = {
1795
- ...clippingAncestor,
1796
- x: clippingAncestor.x - visualOffsets.x,
1797
- y: clippingAncestor.y - visualOffsets.y
1798
- };
1799
- }
1800
- return rectToClientRect(rect);
1801
- }
1802
- function hasFixedPositionAncestor(element, stopNode) {
1803
- const parentNode = getParentNode(element);
1804
- if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1805
- return false;
1806
- }
1807
- return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1808
- }
1809
-
1810
- // A "clipping ancestor" is an `overflow` element with the characteristic of
1811
- // clipping (or hiding) child elements. This returns all clipping ancestors
1812
- // of the given element up the tree.
1813
- function getClippingElementAncestors(element, cache) {
1814
- const cachedResult = cache.get(element);
1815
- if (cachedResult) {
1816
- return cachedResult;
1817
- }
1818
- let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1819
- let currentContainingBlockComputedStyle = null;
1820
- const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
1821
- let currentNode = elementIsFixed ? getParentNode(element) : element;
1822
-
1823
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1824
- while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1825
- const computedStyle = getComputedStyle$1(currentNode);
1826
- const currentNodeIsContaining = isContainingBlock(currentNode);
1827
- if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1828
- currentContainingBlockComputedStyle = null;
1829
- }
1830
- const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1831
- if (shouldDropCurrentNode) {
1832
- // Drop non-containing blocks.
1833
- result = result.filter(ancestor => ancestor !== currentNode);
1834
- } else {
1835
- // Record last containing block for next iteration.
1836
- currentContainingBlockComputedStyle = computedStyle;
1837
- }
1838
- currentNode = getParentNode(currentNode);
1839
- }
1840
- cache.set(element, result);
1841
- return result;
1842
- }
1843
-
1844
- // Gets the maximum area that the element is visible in due to any number of
1845
- // clipping ancestors.
1846
- function getClippingRect(_ref) {
1847
- let {
1848
- element,
1849
- boundary,
1850
- rootBoundary,
1851
- strategy
1852
- } = _ref;
1853
- const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
1854
- const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1855
- const firstClippingAncestor = clippingAncestors[0];
1856
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1857
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1858
- accRect.top = max(rect.top, accRect.top);
1859
- accRect.right = min(rect.right, accRect.right);
1860
- accRect.bottom = min(rect.bottom, accRect.bottom);
1861
- accRect.left = max(rect.left, accRect.left);
1862
- return accRect;
1863
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1864
- return {
1865
- width: clippingRect.right - clippingRect.left,
1866
- height: clippingRect.bottom - clippingRect.top,
1867
- x: clippingRect.left,
1868
- y: clippingRect.top
1869
- };
1870
- }
1871
-
1872
- function getDimensions(element) {
1873
- return getCssDimensions(element);
1874
- }
1875
-
1876
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1877
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
1878
- const documentElement = getDocumentElement(offsetParent);
1879
- const isFixed = strategy === 'fixed';
1880
- const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1881
- let scroll = {
1882
- scrollLeft: 0,
1883
- scrollTop: 0
1884
- };
1885
- const offsets = createCoords(0);
1886
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1887
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1888
- scroll = getNodeScroll(offsetParent);
1889
- }
1890
- if (isOffsetParentAnElement) {
1891
- const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1892
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1893
- offsets.y = offsetRect.y + offsetParent.clientTop;
1894
- } else if (documentElement) {
1895
- offsets.x = getWindowScrollBarX(documentElement);
1896
- }
1897
- }
1898
- return {
1899
- x: rect.left + scroll.scrollLeft - offsets.x,
1900
- y: rect.top + scroll.scrollTop - offsets.y,
1901
- width: rect.width,
1902
- height: rect.height
1903
- };
1904
- }
1905
-
1906
- function getTrueOffsetParent(element, polyfill) {
1907
- if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
1908
- return null;
1909
- }
1910
- if (polyfill) {
1911
- return polyfill(element);
1912
- }
1913
- return element.offsetParent;
1914
- }
1915
-
1916
- // Gets the closest ancestor positioned element. Handles some edge cases,
1917
- // such as table ancestors and cross browser bugs.
1918
- function getOffsetParent(element, polyfill) {
1919
- const window = getWindow(element);
1920
- if (!isHTMLElement(element)) {
1921
- return window;
1922
- }
1923
- let offsetParent = getTrueOffsetParent(element, polyfill);
1924
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
1925
- offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1926
- }
1927
- if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1928
- return window;
1929
- }
1930
- return offsetParent || getContainingBlock(element) || window;
1931
- }
1932
-
1933
- const getElementRects = async function (_ref) {
1934
- let {
1935
- reference,
1936
- floating,
1937
- strategy
1938
- } = _ref;
1939
- const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1940
- const getDimensionsFn = this.getDimensions;
1941
- return {
1942
- reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
1943
- floating: {
1944
- x: 0,
1945
- y: 0,
1946
- ...(await getDimensionsFn(floating))
1947
- }
1948
- };
1949
- };
1950
-
1951
- function isRTL(element) {
1952
- return getComputedStyle$1(element).direction === 'rtl';
1953
- }
1954
-
1955
- const platform = {
1956
- convertOffsetParentRelativeRectToViewportRelativeRect,
1957
- getDocumentElement,
1958
- getClippingRect,
1959
- getOffsetParent,
1960
- getElementRects,
1961
- getClientRects,
1962
- getDimensions,
1963
- getScale,
1964
- isElement,
1965
- isRTL
1966
- };
1967
-
1968
- // https://samthor.au/2021/observing-dom/
1969
- function observeMove(element, onMove) {
1970
- let io = null;
1971
- let timeoutId;
1972
- const root = getDocumentElement(element);
1973
- function cleanup() {
1974
- clearTimeout(timeoutId);
1975
- io && io.disconnect();
1976
- io = null;
1977
- }
1978
- function refresh(skip, threshold) {
1979
- if (skip === void 0) {
1980
- skip = false;
1981
- }
1982
- if (threshold === void 0) {
1983
- threshold = 1;
1984
- }
1985
- cleanup();
1986
- const {
1987
- left,
1988
- top,
1989
- width,
1990
- height
1991
- } = element.getBoundingClientRect();
1992
- if (!skip) {
1993
- onMove();
1994
- }
1995
- if (!width || !height) {
1996
- return;
1997
- }
1998
- const insetTop = floor(top);
1999
- const insetRight = floor(root.clientWidth - (left + width));
2000
- const insetBottom = floor(root.clientHeight - (top + height));
2001
- const insetLeft = floor(left);
2002
- const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
2003
- const options = {
2004
- rootMargin,
2005
- threshold: max(0, min(1, threshold)) || 1
2006
- };
2007
- let isFirstUpdate = true;
2008
- function handleObserve(entries) {
2009
- const ratio = entries[0].intersectionRatio;
2010
- if (ratio !== threshold) {
2011
- if (!isFirstUpdate) {
2012
- return refresh();
2013
- }
2014
- if (!ratio) {
2015
- timeoutId = setTimeout(() => {
2016
- refresh(false, 1e-7);
2017
- }, 100);
2018
- } else {
2019
- refresh(false, ratio);
2020
- }
2021
- }
2022
- isFirstUpdate = false;
2023
- }
2024
-
2025
- // Older browsers don't support a `document` as the root and will throw an
2026
- // error.
2027
- try {
2028
- io = new IntersectionObserver(handleObserve, {
2029
- ...options,
2030
- // Handle <iframe>s
2031
- root: root.ownerDocument
2032
- });
2033
- } catch (e) {
2034
- io = new IntersectionObserver(handleObserve, options);
2035
- }
2036
- io.observe(element);
2037
- }
2038
- refresh(true);
2039
- return cleanup;
2040
- }
2041
-
2042
- /**
2043
- * Automatically updates the position of the floating element when necessary.
2044
- * Should only be called when the floating element is mounted on the DOM or
2045
- * visible on the screen.
2046
- * @returns cleanup function that should be invoked when the floating element is
2047
- * removed from the DOM or hidden from the screen.
2048
- * @see https://floating-ui.com/docs/autoUpdate
2049
- */
2050
- function autoUpdate(reference, floating, update, options) {
2051
- if (options === void 0) {
2052
- options = {};
2053
- }
2054
- const {
2055
- ancestorScroll = true,
2056
- ancestorResize = true,
2057
- elementResize = typeof ResizeObserver === 'function',
2058
- layoutShift = typeof IntersectionObserver === 'function',
2059
- animationFrame = false
2060
- } = options;
2061
- const referenceEl = unwrapElement(reference);
2062
- const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
2063
- ancestors.forEach(ancestor => {
2064
- ancestorScroll && ancestor.addEventListener('scroll', update, {
2065
- passive: true
2066
- });
2067
- ancestorResize && ancestor.addEventListener('resize', update);
2068
- });
2069
- const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
2070
- let reobserveFrame = -1;
2071
- let resizeObserver = null;
2072
- if (elementResize) {
2073
- resizeObserver = new ResizeObserver(_ref => {
2074
- let [firstEntry] = _ref;
2075
- if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
2076
- // Prevent update loops when using the `size` middleware.
2077
- // https://github.com/floating-ui/floating-ui/issues/1740
2078
- resizeObserver.unobserve(floating);
2079
- cancelAnimationFrame(reobserveFrame);
2080
- reobserveFrame = requestAnimationFrame(() => {
2081
- resizeObserver && resizeObserver.observe(floating);
2082
- });
2083
- }
2084
- update();
2085
- });
2086
- if (referenceEl && !animationFrame) {
2087
- resizeObserver.observe(referenceEl);
2088
- }
2089
- resizeObserver.observe(floating);
2090
- }
2091
- let frameId;
2092
- let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
2093
- if (animationFrame) {
2094
- frameLoop();
2095
- }
2096
- function frameLoop() {
2097
- const nextRefRect = getBoundingClientRect(reference);
2098
- if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
2099
- update();
2100
- }
2101
- prevRefRect = nextRefRect;
2102
- frameId = requestAnimationFrame(frameLoop);
2103
- }
2104
- update();
2105
- return () => {
2106
- ancestors.forEach(ancestor => {
2107
- ancestorScroll && ancestor.removeEventListener('scroll', update);
2108
- ancestorResize && ancestor.removeEventListener('resize', update);
2109
- });
2110
- cleanupIo && cleanupIo();
2111
- resizeObserver && resizeObserver.disconnect();
2112
- resizeObserver = null;
2113
- if (animationFrame) {
2114
- cancelAnimationFrame(frameId);
2115
- }
2116
- };
2117
- }
2118
-
2119
- /**
2120
- * Computes the `x` and `y` coordinates that will place the floating element
2121
- * next to a reference element when it is given a certain CSS positioning
2122
- * strategy.
2123
- */
2124
- const computePosition = (reference, floating, options) => {
2125
- // This caches the expensive `getClippingElementAncestors` function so that
2126
- // multiple lifecycle resets re-use the same result. It only lives for a
2127
- // single call. If other functions become expensive, we can add them as well.
2128
- const cache = new Map();
2129
- const mergedOptions = {
2130
- platform,
2131
- ...options
2132
- };
2133
- const platformWithCache = {
2134
- ...mergedOptions.platform,
2135
- _c: cache
2136
- };
2137
- return computePosition$1(reference, floating, {
2138
- ...mergedOptions,
2139
- platform: platformWithCache
2140
- });
2141
- };
2142
-
2143
- /**
2144
- * Provides data to position an inner element of the floating element so that it
2145
- * appears centered to the reference element.
2146
- * This wraps the core `arrow` middleware to allow React refs as the element.
2147
- * @see https://floating-ui.com/docs/arrow
2148
- */
2149
- const arrow = options => {
2150
- function isRef(value) {
2151
- return {}.hasOwnProperty.call(value, 'current');
2152
- }
2153
- return {
2154
- name: 'arrow',
2155
- options,
2156
- fn(state) {
2157
- const {
2158
- element,
2159
- padding
2160
- } = typeof options === 'function' ? options(state) : options;
2161
- if (element && isRef(element)) {
2162
- if (element.current != null) {
2163
- return arrow$1({
2164
- element: element.current,
2165
- padding
2166
- }).fn(state);
2167
- }
2168
- return {};
2169
- } else if (element) {
2170
- return arrow$1({
2171
- element,
2172
- padding
2173
- }).fn(state);
2174
- }
2175
- return {};
2176
- }
2177
- };
2178
- };
2179
-
2180
- var index = typeof document !== 'undefined' ? useLayoutEffect : useEffect;
2181
-
2182
- // Fork of `fast-deep-equal` that only does the comparisons we need and compares
2183
- // functions
2184
- function deepEqual(a, b) {
2185
- if (a === b) {
2186
- return true;
2187
- }
2188
- if (typeof a !== typeof b) {
2189
- return false;
2190
- }
2191
- if (typeof a === 'function' && a.toString() === b.toString()) {
2192
- return true;
2193
- }
2194
- let length, i, keys;
2195
- if (a && b && typeof a == 'object') {
2196
- if (Array.isArray(a)) {
2197
- length = a.length;
2198
- if (length != b.length) return false;
2199
- for (i = length; i-- !== 0;) {
2200
- if (!deepEqual(a[i], b[i])) {
2201
- return false;
2202
- }
2203
- }
2204
- return true;
2205
- }
2206
- keys = Object.keys(a);
2207
- length = keys.length;
2208
- if (length !== Object.keys(b).length) {
2209
- return false;
2210
- }
2211
- for (i = length; i-- !== 0;) {
2212
- if (!{}.hasOwnProperty.call(b, keys[i])) {
2213
- return false;
2214
- }
2215
- }
2216
- for (i = length; i-- !== 0;) {
2217
- const key = keys[i];
2218
- if (key === '_owner' && a.$$typeof) {
2219
- continue;
2220
- }
2221
- if (!deepEqual(a[key], b[key])) {
2222
- return false;
2223
- }
2224
- }
2225
- return true;
2226
- }
2227
- return a !== a && b !== b;
2228
- }
2229
-
2230
- function getDPR(element) {
2231
- if (typeof window === 'undefined') {
2232
- return 1;
2233
- }
2234
- const win = element.ownerDocument.defaultView || window;
2235
- return win.devicePixelRatio || 1;
2236
- }
2237
-
2238
- function roundByDPR(element, value) {
2239
- const dpr = getDPR(element);
2240
- return Math.round(value * dpr) / dpr;
2241
- }
2242
-
2243
- function useLatestRef(value) {
2244
- const ref = React.useRef(value);
2245
- index(() => {
2246
- ref.current = value;
2247
- });
2248
- return ref;
2249
- }
2250
-
2251
- /**
2252
- * Provides data to position a floating element.
2253
- * @see https://floating-ui.com/docs/react
2254
- */
2255
- function useFloating(options) {
2256
- if (options === void 0) {
2257
- options = {};
2258
- }
2259
- const {
2260
- placement = 'bottom',
2261
- strategy = 'absolute',
2262
- middleware = [],
2263
- platform,
2264
- elements: {
2265
- reference: externalReference,
2266
- floating: externalFloating
2267
- } = {},
2268
- transform = true,
2269
- whileElementsMounted,
2270
- open
2271
- } = options;
2272
- const [data, setData] = React.useState({
2273
- x: 0,
2274
- y: 0,
2275
- strategy,
2276
- placement,
2277
- middlewareData: {},
2278
- isPositioned: false
2279
- });
2280
- const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
2281
- if (!deepEqual(latestMiddleware, middleware)) {
2282
- setLatestMiddleware(middleware);
2283
- }
2284
- const [_reference, _setReference] = React.useState(null);
2285
- const [_floating, _setFloating] = React.useState(null);
2286
- const setReference = React.useCallback(node => {
2287
- if (node != referenceRef.current) {
2288
- referenceRef.current = node;
2289
- _setReference(node);
2290
- }
2291
- }, [_setReference]);
2292
- const setFloating = React.useCallback(node => {
2293
- if (node !== floatingRef.current) {
2294
- floatingRef.current = node;
2295
- _setFloating(node);
2296
- }
2297
- }, [_setFloating]);
2298
- const referenceEl = externalReference || _reference;
2299
- const floatingEl = externalFloating || _floating;
2300
- const referenceRef = React.useRef(null);
2301
- const floatingRef = React.useRef(null);
2302
- const dataRef = React.useRef(data);
2303
- const whileElementsMountedRef = useLatestRef(whileElementsMounted);
2304
- const platformRef = useLatestRef(platform);
2305
- const update = React.useCallback(() => {
2306
- if (!referenceRef.current || !floatingRef.current) {
2307
- return;
2308
- }
2309
- const config = {
2310
- placement,
2311
- strategy,
2312
- middleware: latestMiddleware
2313
- };
2314
- if (platformRef.current) {
2315
- config.platform = platformRef.current;
2316
- }
2317
- computePosition(referenceRef.current, floatingRef.current, config).then(data => {
2318
- const fullData = {
2319
- ...data,
2320
- isPositioned: true
2321
- };
2322
- if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
2323
- dataRef.current = fullData;
2324
- $7SXl2$reactdom.flushSync(() => {
2325
- setData(fullData);
2326
- });
2327
- }
2328
- });
2329
- }, [latestMiddleware, placement, strategy, platformRef]);
2330
- index(() => {
2331
- if (open === false && dataRef.current.isPositioned) {
2332
- dataRef.current.isPositioned = false;
2333
- setData(data => ({
2334
- ...data,
2335
- isPositioned: false
2336
- }));
2337
- }
2338
- }, [open]);
2339
- const isMountedRef = React.useRef(false);
2340
- index(() => {
2341
- isMountedRef.current = true;
2342
- return () => {
2343
- isMountedRef.current = false;
2344
- };
2345
- }, []);
2346
- index(() => {
2347
- if (referenceEl) referenceRef.current = referenceEl;
2348
- if (floatingEl) floatingRef.current = floatingEl;
2349
- if (referenceEl && floatingEl) {
2350
- if (whileElementsMountedRef.current) {
2351
- return whileElementsMountedRef.current(referenceEl, floatingEl, update);
2352
- } else {
2353
- update();
2354
- }
2355
- }
2356
- }, [referenceEl, floatingEl, update, whileElementsMountedRef]);
2357
- const refs = React.useMemo(() => ({
2358
- reference: referenceRef,
2359
- floating: floatingRef,
2360
- setReference,
2361
- setFloating
2362
- }), [setReference, setFloating]);
2363
- const elements = React.useMemo(() => ({
2364
- reference: referenceEl,
2365
- floating: floatingEl
2366
- }), [referenceEl, floatingEl]);
2367
- const floatingStyles = React.useMemo(() => {
2368
- const initialStyles = {
2369
- position: strategy,
2370
- left: 0,
2371
- top: 0
2372
- };
2373
- if (!elements.floating) {
2374
- return initialStyles;
2375
- }
2376
- const x = roundByDPR(elements.floating, data.x);
2377
- const y = roundByDPR(elements.floating, data.y);
2378
- if (transform) {
2379
- return {
2380
- ...initialStyles,
2381
- transform: "translate(" + x + "px, " + y + "px)",
2382
- ...(getDPR(elements.floating) >= 1.5 && {
2383
- willChange: 'transform'
2384
- })
2385
- };
2386
- }
2387
- return {
2388
- position: strategy,
2389
- left: x,
2390
- top: y
2391
- };
2392
- }, [strategy, transform, elements.floating, data.x, data.y]);
2393
- return React.useMemo(() => ({
2394
- ...data,
2395
- update,
2396
- refs,
2397
- elements,
2398
- floatingStyles
2399
- }), [data, update, refs, elements, floatingStyles]);
2400
- }
2401
-
2402
- function $db6c3485150b8e66$export$1ab7ae714698c4b8(element) {
2403
- const [size, setSize] = useState(undefined);
2404
- $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2405
- if (element) {
2406
- // provide size as early as possible
2407
- setSize({
2408
- width: element.offsetWidth,
2409
- height: element.offsetHeight
2410
- });
2411
- const resizeObserver = new ResizeObserver((entries)=>{
2412
- if (!Array.isArray(entries)) return;
2413
- // Since we only observe the one element, we don't need to loop over the
2414
- // array
2415
- if (!entries.length) return;
2416
- const entry = entries[0];
2417
- let width;
2418
- let height;
2419
- if ('borderBoxSize' in entry) {
2420
- const borderSizeEntry = entry['borderBoxSize']; // iron out differences between browsers
2421
- const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
2422
- width = borderSize['inlineSize'];
2423
- height = borderSize['blockSize'];
2424
- } else {
2425
- // for browsers that don't support `borderBoxSize`
2426
- // we calculate it ourselves to get the correct border box.
2427
- width = element.offsetWidth;
2428
- height = element.offsetHeight;
2429
- }
2430
- setSize({
2431
- width: width,
2432
- height: height
2433
- });
2434
- });
2435
- resizeObserver.observe(element, {
2436
- box: 'border-box'
2437
- });
2438
- return ()=>resizeObserver.unobserve(element)
2439
- ;
2440
- } else // We only want to reset to `undefined` when the element becomes `null`,
2441
- // not if it changes to another element.
2442
- setSize(undefined);
2443
- }, [
2444
- element
2445
- ]);
2446
- return size;
2447
- }
2448
-
2449
- /* -------------------------------------------------------------------------------------------------
2450
- * Popper
2451
- * -----------------------------------------------------------------------------------------------*/ const $cf1ac5d9fe0e8206$var$POPPER_NAME = 'Popper';
2452
- const [$cf1ac5d9fe0e8206$var$createPopperContext, $cf1ac5d9fe0e8206$export$722aac194ae923] = $c512c27ab02ef895$export$50c7b4e9d9f19c1($cf1ac5d9fe0e8206$var$POPPER_NAME);
2453
- const [$cf1ac5d9fe0e8206$var$PopperProvider, $cf1ac5d9fe0e8206$var$usePopperContext] = $cf1ac5d9fe0e8206$var$createPopperContext($cf1ac5d9fe0e8206$var$POPPER_NAME);
2454
- const $cf1ac5d9fe0e8206$export$badac9ada3a0bdf9 = (props)=>{
2455
- const { __scopePopper: __scopePopper , children: children } = props;
2456
- const [anchor, setAnchor] = useState(null);
2457
- return /*#__PURE__*/ createElement($cf1ac5d9fe0e8206$var$PopperProvider, {
2458
- scope: __scopePopper,
2459
- anchor: anchor,
2460
- onAnchorChange: setAnchor
2461
- }, children);
2462
- };
2463
- /* -------------------------------------------------------------------------------------------------
2464
- * PopperAnchor
2465
- * -----------------------------------------------------------------------------------------------*/ const $cf1ac5d9fe0e8206$var$ANCHOR_NAME = 'PopperAnchor';
2466
- const $cf1ac5d9fe0e8206$export$ecd4e1ccab6ed6d = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
2467
- const { __scopePopper: __scopePopper , virtualRef: virtualRef , ...anchorProps } = props;
2468
- const context = $cf1ac5d9fe0e8206$var$usePopperContext($cf1ac5d9fe0e8206$var$ANCHOR_NAME, __scopePopper);
2469
- const ref = useRef(null);
2470
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
2471
- useEffect(()=>{
2472
- // Consumer can anchor the popper to something that isn't
2473
- // a DOM node e.g. pointer position, so we override the
2474
- // `anchorRef` with their virtual ref in this case.
2475
- context.onAnchorChange((virtualRef === null || virtualRef === void 0 ? void 0 : virtualRef.current) || ref.current);
2476
- });
2477
- return virtualRef ? null : /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, anchorProps, {
2478
- ref: composedRefs
2479
- }));
2480
- });
2481
- /* -------------------------------------------------------------------------------------------------
2482
- * PopperContent
2483
- * -----------------------------------------------------------------------------------------------*/ const $cf1ac5d9fe0e8206$var$CONTENT_NAME = 'PopperContent';
2484
- const [$cf1ac5d9fe0e8206$var$PopperContentProvider, $cf1ac5d9fe0e8206$var$useContentContext] = $cf1ac5d9fe0e8206$var$createPopperContext($cf1ac5d9fe0e8206$var$CONTENT_NAME);
2485
- const $cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
2486
- var _arrowSize$width, _arrowSize$height, _middlewareData$arrow, _middlewareData$arrow2, _middlewareData$arrow3, _middlewareData$trans, _middlewareData$trans2, _middlewareData$hide;
2487
- const { __scopePopper: __scopePopper , side: side = 'bottom' , sideOffset: sideOffset = 0 , align: align = 'center' , alignOffset: alignOffset = 0 , arrowPadding: arrowPadding = 0 , avoidCollisions: avoidCollisions = true , collisionBoundary: collisionBoundary = [] , collisionPadding: collisionPaddingProp = 0 , sticky: sticky = 'partial' , hideWhenDetached: hideWhenDetached = false , updatePositionStrategy: updatePositionStrategy = 'optimized' , onPlaced: onPlaced , ...contentProps } = props;
2488
- const context = $cf1ac5d9fe0e8206$var$usePopperContext($cf1ac5d9fe0e8206$var$CONTENT_NAME, __scopePopper);
2489
- const [content, setContent] = useState(null);
2490
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setContent(node)
2491
- );
2492
- const [arrow$1, setArrow] = useState(null);
2493
- const arrowSize = $db6c3485150b8e66$export$1ab7ae714698c4b8(arrow$1);
2494
- const arrowWidth = (_arrowSize$width = arrowSize === null || arrowSize === void 0 ? void 0 : arrowSize.width) !== null && _arrowSize$width !== void 0 ? _arrowSize$width : 0;
2495
- const arrowHeight = (_arrowSize$height = arrowSize === null || arrowSize === void 0 ? void 0 : arrowSize.height) !== null && _arrowSize$height !== void 0 ? _arrowSize$height : 0;
2496
- const desiredPlacement = side + (align !== 'center' ? '-' + align : '');
2497
- const collisionPadding = typeof collisionPaddingProp === 'number' ? collisionPaddingProp : {
2498
- top: 0,
2499
- right: 0,
2500
- bottom: 0,
2501
- left: 0,
2502
- ...collisionPaddingProp
2503
- };
2504
- const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [
2505
- collisionBoundary
2506
- ];
2507
- const hasExplicitBoundaries = boundary.length > 0;
2508
- const detectOverflowOptions = {
2509
- padding: collisionPadding,
2510
- boundary: boundary.filter($cf1ac5d9fe0e8206$var$isNotNull),
2511
- // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
2512
- altBoundary: hasExplicitBoundaries
2513
- };
2514
- const { refs: refs , floatingStyles: floatingStyles , placement: placement , isPositioned: isPositioned , middlewareData: middlewareData } = useFloating({
2515
- // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
2516
- strategy: 'fixed',
2517
- placement: desiredPlacement,
2518
- whileElementsMounted: (...args)=>{
2519
- const cleanup = autoUpdate(...args, {
2520
- animationFrame: updatePositionStrategy === 'always'
2521
- });
2522
- return cleanup;
2523
- },
2524
- elements: {
2525
- reference: context.anchor
2526
- },
2527
- middleware: [
2528
- offset({
2529
- mainAxis: sideOffset + arrowHeight,
2530
- alignmentAxis: alignOffset
2531
- }),
2532
- avoidCollisions && shift({
2533
- mainAxis: true,
2534
- crossAxis: false,
2535
- limiter: sticky === 'partial' ? limitShift() : undefined,
2536
- ...detectOverflowOptions
2537
- }),
2538
- avoidCollisions && flip({
2539
- ...detectOverflowOptions
2540
- }),
2541
- size({
2542
- ...detectOverflowOptions,
2543
- apply: ({ elements: elements , rects: rects , availableWidth: availableWidth , availableHeight: availableHeight })=>{
2544
- const { width: anchorWidth , height: anchorHeight } = rects.reference;
2545
- const contentStyle = elements.floating.style;
2546
- contentStyle.setProperty('--radix-popper-available-width', `${availableWidth}px`);
2547
- contentStyle.setProperty('--radix-popper-available-height', `${availableHeight}px`);
2548
- contentStyle.setProperty('--radix-popper-anchor-width', `${anchorWidth}px`);
2549
- contentStyle.setProperty('--radix-popper-anchor-height', `${anchorHeight}px`);
2550
- }
2551
- }),
2552
- arrow$1 && arrow({
2553
- element: arrow$1,
2554
- padding: arrowPadding
2555
- }),
2556
- $cf1ac5d9fe0e8206$var$transformOrigin({
2557
- arrowWidth: arrowWidth,
2558
- arrowHeight: arrowHeight
2559
- }),
2560
- hideWhenDetached && hide({
2561
- strategy: 'referenceHidden',
2562
- ...detectOverflowOptions
2563
- })
2564
- ]
2565
- });
2566
- const [placedSide, placedAlign] = $cf1ac5d9fe0e8206$var$getSideAndAlignFromPlacement(placement);
2567
- const handlePlaced = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onPlaced);
2568
- $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2569
- if (isPositioned) handlePlaced === null || handlePlaced === void 0 || handlePlaced();
2570
- }, [
2571
- isPositioned,
2572
- handlePlaced
2573
- ]);
2574
- const arrowX = (_middlewareData$arrow = middlewareData.arrow) === null || _middlewareData$arrow === void 0 ? void 0 : _middlewareData$arrow.x;
2575
- const arrowY = (_middlewareData$arrow2 = middlewareData.arrow) === null || _middlewareData$arrow2 === void 0 ? void 0 : _middlewareData$arrow2.y;
2576
- const cannotCenterArrow = ((_middlewareData$arrow3 = middlewareData.arrow) === null || _middlewareData$arrow3 === void 0 ? void 0 : _middlewareData$arrow3.centerOffset) !== 0;
2577
- const [contentZIndex, setContentZIndex] = useState();
2578
- $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2579
- if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
2580
- }, [
2581
- content
2582
- ]);
2583
- return /*#__PURE__*/ createElement("div", {
2584
- ref: refs.setFloating,
2585
- "data-radix-popper-content-wrapper": "",
2586
- style: {
2587
- ...floatingStyles,
2588
- transform: isPositioned ? floatingStyles.transform : 'translate(0, -200%)',
2589
- // keep off the page when measuring
2590
- minWidth: 'max-content',
2591
- zIndex: contentZIndex,
2592
- ['--radix-popper-transform-origin']: [
2593
- (_middlewareData$trans = middlewareData.transformOrigin) === null || _middlewareData$trans === void 0 ? void 0 : _middlewareData$trans.x,
2594
- (_middlewareData$trans2 = middlewareData.transformOrigin) === null || _middlewareData$trans2 === void 0 ? void 0 : _middlewareData$trans2.y
2595
- ].join(' ')
2596
- } // Floating UI interally calculates logical alignment based the `dir` attribute on
2597
- ,
2598
- dir: props.dir
2599
- }, /*#__PURE__*/ createElement($cf1ac5d9fe0e8206$var$PopperContentProvider, {
2600
- scope: __scopePopper,
2601
- placedSide: placedSide,
2602
- onArrowChange: setArrow,
2603
- arrowX: arrowX,
2604
- arrowY: arrowY,
2605
- shouldHideArrow: cannotCenterArrow
2606
- }, /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
2607
- "data-side": placedSide,
2608
- "data-align": placedAlign
2609
- }, contentProps, {
2610
- ref: composedRefs,
2611
- style: {
2612
- ...contentProps.style,
2613
- // if the PopperContent hasn't been placed yet (not all measurements done)
2614
- // we prevent animations so that users's animation don't kick in too early referring wrong sides
2615
- animation: !isPositioned ? 'none' : undefined,
2616
- // hide the content if using the hide middleware and should be hidden
2617
- opacity: (_middlewareData$hide = middlewareData.hide) !== null && _middlewareData$hide !== void 0 && _middlewareData$hide.referenceHidden ? 0 : undefined
2618
- }
2619
- }))));
2620
- });
2621
- /* -----------------------------------------------------------------------------------------------*/ function $cf1ac5d9fe0e8206$var$isNotNull(value) {
2622
- return value !== null;
2623
- }
2624
- const $cf1ac5d9fe0e8206$var$transformOrigin = (options)=>({
2625
- name: 'transformOrigin',
2626
- options: options,
2627
- fn (data) {
2628
- var _middlewareData$arrow4, _middlewareData$arrow5, _middlewareData$arrow6, _middlewareData$arrow7, _middlewareData$arrow8;
2629
- const { placement: placement , rects: rects , middlewareData: middlewareData } = data;
2630
- const cannotCenterArrow = ((_middlewareData$arrow4 = middlewareData.arrow) === null || _middlewareData$arrow4 === void 0 ? void 0 : _middlewareData$arrow4.centerOffset) !== 0;
2631
- const isArrowHidden = cannotCenterArrow;
2632
- const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
2633
- const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
2634
- const [placedSide, placedAlign] = $cf1ac5d9fe0e8206$var$getSideAndAlignFromPlacement(placement);
2635
- const noArrowAlign = {
2636
- start: '0%',
2637
- center: '50%',
2638
- end: '100%'
2639
- }[placedAlign];
2640
- const arrowXCenter = ((_middlewareData$arrow5 = (_middlewareData$arrow6 = middlewareData.arrow) === null || _middlewareData$arrow6 === void 0 ? void 0 : _middlewareData$arrow6.x) !== null && _middlewareData$arrow5 !== void 0 ? _middlewareData$arrow5 : 0) + arrowWidth / 2;
2641
- const arrowYCenter = ((_middlewareData$arrow7 = (_middlewareData$arrow8 = middlewareData.arrow) === null || _middlewareData$arrow8 === void 0 ? void 0 : _middlewareData$arrow8.y) !== null && _middlewareData$arrow7 !== void 0 ? _middlewareData$arrow7 : 0) + arrowHeight / 2;
2642
- let x = '';
2643
- let y = '';
2644
- if (placedSide === 'bottom') {
2645
- x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
2646
- y = `${-arrowHeight}px`;
2647
- } else if (placedSide === 'top') {
2648
- x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
2649
- y = `${rects.floating.height + arrowHeight}px`;
2650
- } else if (placedSide === 'right') {
2651
- x = `${-arrowHeight}px`;
2652
- y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
2653
- } else if (placedSide === 'left') {
2654
- x = `${rects.floating.width + arrowHeight}px`;
2655
- y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
2656
- }
2657
- return {
2658
- data: {
2659
- x: x,
2660
- y: y
2661
- }
2662
- };
2663
- }
2664
- })
2665
- ;
2666
- function $cf1ac5d9fe0e8206$var$getSideAndAlignFromPlacement(placement) {
2667
- const [side, align = 'center'] = placement.split('-');
2668
- return [
2669
- side,
2670
- align
2671
- ];
2672
- }
2673
- const $cf1ac5d9fe0e8206$export$be92b6f5f03c0fe9 = $cf1ac5d9fe0e8206$export$badac9ada3a0bdf9;
2674
- const $cf1ac5d9fe0e8206$export$b688253958b8dfe7 = $cf1ac5d9fe0e8206$export$ecd4e1ccab6ed6d;
2675
- const $cf1ac5d9fe0e8206$export$7c6e2c02157bb7d2 = $cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc;
2676
-
2677
- const $f1701beae083dbae$export$602eac185826482c = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
2678
- var _globalThis$document;
2679
- const { container: container = globalThis === null || globalThis === void 0 ? void 0 : (_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.body , ...portalProps } = props;
2680
- return container ? /*#__PURE__*/ $7SXl2$reactdom__default.createPortal(/*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, portalProps, {
2681
- ref: forwardedRef
2682
- })), container) : null;
2683
- });
2684
-
2685
30
  function $010c2913dbd2fe3d$export$5cae361ad82dce8b(value) {
2686
31
  const ref = useRef({
2687
32
  value: value,
@@ -3814,7 +1159,7 @@ const BtIconChevronUp2Px = (props) =>
3814
1159
  /** Use `Select` to choose from a dropdown list of options. */
3815
1160
  var Select = function (_a) {
3816
1161
  var _b;
3817
- var isRequired = _a.isRequired, isDisabled = _a.isDisabled, placeholder = _a.placeholder, label = _a.label, _c = _a.ariaLabel, ariaLabel = _c === void 0 ? label : _c, options = _a.options, onOpenChange = _a.onOpenChange, isDefaultOpen = _a.isDefaultOpen, defaultValue = _a.defaultValue, errorMessage = _a.errorMessage, labelSize = _a.labelSize, helper = _a.helper, name = _a.name, width = _a.width, isFluid = _a.isFluid, onBlur = _a.onBlur, onChange = _a.onChange, disclosureTitle = _a.disclosureTitle, disclosureText = _a.disclosureText, onClickDisclosure = _a.onClickDisclosure, _d = _a.selectSize, selectSize = _d === void 0 ? "m" : _d, props = __rest(_a, ["isRequired", "isDisabled", "placeholder", "label", "ariaLabel", "options", "onOpenChange", "isDefaultOpen", "defaultValue", "errorMessage", "labelSize", "helper", "name", "width", "isFluid", "onBlur", "onChange", "disclosureTitle", "disclosureText", "onClickDisclosure", "selectSize"]);
1162
+ var isRequired = _a.isRequired, isDisabled = _a.isDisabled, placeholder = _a.placeholder, label = _a.label, _c = _a.ariaLabel, ariaLabel = _c === void 0 ? label : _c, options = _a.options, onOpenChange = _a.onOpenChange, isDefaultOpen = _a.isDefaultOpen, defaultValue = _a.defaultValue, errorMessage = _a.errorMessage, labelSize = _a.labelSize, helper = _a.helper, hideLabel = _a.hideLabel, name = _a.name, width = _a.width, isFluid = _a.isFluid, onBlur = _a.onBlur, onChange = _a.onChange, disclosureTitle = _a.disclosureTitle, disclosureText = _a.disclosureText, onClickDisclosure = _a.onClickDisclosure, _d = _a.selectSize, selectSize = _d === void 0 ? "m" : _d, props = __rest(_a, ["isRequired", "isDisabled", "placeholder", "label", "ariaLabel", "options", "onOpenChange", "isDefaultOpen", "defaultValue", "errorMessage", "labelSize", "helper", "hideLabel", "name", "width", "isFluid", "onBlur", "onChange", "disclosureTitle", "disclosureText", "onClickDisclosure", "selectSize"]);
3818
1163
  var id = useId();
3819
1164
  var arcRootElement = useContext(ArcRootElementContext);
3820
1165
  var surface = useContext(Context).surface;
@@ -3837,7 +1182,7 @@ var Select = function (_a) {
3837
1182
  return 20;
3838
1183
  }
3839
1184
  };
3840
- return (React__default.createElement(FormControl, { errorMessage: errorMessage, helper: helper, htmlFor: id, label: label, labelSize: labelSize, requirementStatus: isRequired ? "required" : "optional", isDisabled: isDisabled, disclosureText: disclosureText, disclosureTitle: disclosureTitle, onClickDisclosure: onClickDisclosure },
1185
+ return (React__default.createElement(FormControl, { errorMessage: errorMessage, helper: helper, htmlFor: id, label: label, hideLabel: hideLabel, labelSize: labelSize, requirementStatus: isRequired ? "required" : "optional", isDisabled: isDisabled, disclosureText: disclosureText, disclosureTitle: disclosureTitle, onClickDisclosure: onClickDisclosure },
3841
1186
  React__default.createElement($cc7e05a45900e73f$export$be92b6f5f03c0fe9, { name: name, required: isRequired, disabled: isDisabled, defaultOpen: isDefaultOpen, value: selectedValue, onOpenChange: onOpenChange, onValueChange: function (value) { return onValueChange(value); } },
3842
1187
  React__default.createElement("div", { className: "arc-Select-wrapper" },
3843
1188
  React__default.createElement($cc7e05a45900e73f$export$41fb9f06171c75f4, __assign({ id: id, name: name, onBlur: onBlur, "aria-label": ariaLabel, style: { width: width }, className: classNames("arc-Select-trigger", (_b = {