@siemens/ix 2.0.0 → 2.0.1

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 (404) hide show
  1. package/components/_commonjsHelpers.js +21 -0
  2. package/components/_commonjsHelpers.js.map +1 -0
  3. package/components/a11y.js +79 -0
  4. package/components/a11y.js.map +1 -0
  5. package/components/animation.js +19 -0
  6. package/components/animation.js.map +1 -0
  7. package/components/anime.es.js +1311 -0
  8. package/components/anime.es.js.map +1 -0
  9. package/components/application-header.js +95 -0
  10. package/components/application-header.js.map +1 -0
  11. package/components/avatar.js +53 -0
  12. package/components/avatar.js.map +1 -0
  13. package/components/base-button.js +47 -0
  14. package/components/base-button.js.map +1 -0
  15. package/components/base-icon-button.js +18 -0
  16. package/components/base-icon-button.js.map +1 -0
  17. package/components/breadcrumb-item.js +92 -0
  18. package/components/breadcrumb-item.js.map +1 -0
  19. package/components/breakpoints.js +25 -0
  20. package/components/breakpoints.js.map +1 -0
  21. package/components/burger-menu.js +55 -0
  22. package/components/burger-menu.js.map +1 -0
  23. package/components/button.js +91 -0
  24. package/components/button.js.map +1 -0
  25. package/components/card-accordion.js +72 -0
  26. package/components/card-accordion.js.map +1 -0
  27. package/components/card-content.js +32 -0
  28. package/components/card-content.js.map +1 -0
  29. package/components/card-title.js +32 -0
  30. package/components/card-title.js.map +1 -0
  31. package/components/card.js +36 -0
  32. package/components/card.js.map +1 -0
  33. package/components/context.js +101 -0
  34. package/components/context.js.map +1 -0
  35. package/components/custom-elements.d.ts +10 -0
  36. package/components/date-picker.js +372 -0
  37. package/components/date-picker.js.map +1 -0
  38. package/components/date-time-card.js +45 -0
  39. package/components/date-time-card.js.map +1 -0
  40. package/components/default-tree-item.js +22 -0
  41. package/components/default-tree-item.js.map +1 -0
  42. package/components/divider.js +32 -0
  43. package/components/divider.js.map +1 -0
  44. package/components/dropdown-item.js +69 -0
  45. package/components/dropdown-item.js.map +1 -0
  46. package/components/dropdown.js +346 -0
  47. package/components/dropdown.js.map +1 -0
  48. package/components/filter-chip.js +56 -0
  49. package/components/filter-chip.js.map +1 -0
  50. package/components/flip-tile-state.js +20 -0
  51. package/components/flip-tile-state.js.map +1 -0
  52. package/components/floating-ui.dom.esm.js +1512 -0
  53. package/components/floating-ui.dom.esm.js.map +1 -0
  54. package/components/group-context-menu.js +73 -0
  55. package/components/group-context-menu.js.map +1 -0
  56. package/components/group-item.js +58 -0
  57. package/components/group-item.js.map +1 -0
  58. package/components/icon-button.js +99 -0
  59. package/components/icon-button.js.map +1 -0
  60. package/components/index.d.ts +27 -0
  61. package/components/index.js +101 -0
  62. package/components/index.js.map +1 -0
  63. package/components/ix-action-card.d.ts +11 -0
  64. package/components/ix-action-card.js +66 -0
  65. package/components/ix-action-card.js.map +1 -0
  66. package/components/ix-application-header.d.ts +11 -0
  67. package/components/ix-application-header.js +8 -0
  68. package/components/ix-application-header.js.map +1 -0
  69. package/components/ix-application-sidebar.d.ts +11 -0
  70. package/components/ix-application-sidebar.js +63 -0
  71. package/components/ix-application-sidebar.js.map +1 -0
  72. package/components/ix-application.d.ts +11 -0
  73. package/components/ix-application.js +128 -0
  74. package/components/ix-application.js.map +1 -0
  75. package/components/ix-avatar.d.ts +11 -0
  76. package/components/ix-avatar.js +8 -0
  77. package/components/ix-avatar.js.map +1 -0
  78. package/components/ix-basic-navigation.d.ts +11 -0
  79. package/components/ix-basic-navigation.js +132 -0
  80. package/components/ix-basic-navigation.js.map +1 -0
  81. package/components/ix-blind.d.ts +11 -0
  82. package/components/ix-blind.js +128 -0
  83. package/components/ix-blind.js.map +1 -0
  84. package/components/ix-breadcrumb-item.d.ts +11 -0
  85. package/components/ix-breadcrumb-item.js +8 -0
  86. package/components/ix-breadcrumb-item.js.map +1 -0
  87. package/components/ix-breadcrumb.d.ts +11 -0
  88. package/components/ix-breadcrumb.js +151 -0
  89. package/components/ix-breadcrumb.js.map +1 -0
  90. package/components/ix-burger-menu.d.ts +11 -0
  91. package/components/ix-burger-menu.js +8 -0
  92. package/components/ix-burger-menu.js.map +1 -0
  93. package/components/ix-button.d.ts +11 -0
  94. package/components/ix-button.js +8 -0
  95. package/components/ix-button.js.map +1 -0
  96. package/components/ix-card-accordion.d.ts +11 -0
  97. package/components/ix-card-accordion.js +8 -0
  98. package/components/ix-card-accordion.js.map +1 -0
  99. package/components/ix-card-content.d.ts +11 -0
  100. package/components/ix-card-content.js +8 -0
  101. package/components/ix-card-content.js.map +1 -0
  102. package/components/ix-card-list.d.ts +11 -0
  103. package/components/ix-card-list.js +228 -0
  104. package/components/ix-card-list.js.map +1 -0
  105. package/components/ix-card-title.d.ts +11 -0
  106. package/components/ix-card-title.js +8 -0
  107. package/components/ix-card-title.js.map +1 -0
  108. package/components/ix-card.d.ts +11 -0
  109. package/components/ix-card.js +8 -0
  110. package/components/ix-card.js.map +1 -0
  111. package/components/ix-category-filter.d.ts +11 -0
  112. package/components/ix-category-filter.js +464 -0
  113. package/components/ix-category-filter.js.map +1 -0
  114. package/components/ix-chip.d.ts +11 -0
  115. package/components/ix-chip.js +98 -0
  116. package/components/ix-chip.js.map +1 -0
  117. package/components/ix-col.d.ts +11 -0
  118. package/components/ix-col.js +96 -0
  119. package/components/ix-col.js.map +1 -0
  120. package/components/ix-content-header.d.ts +11 -0
  121. package/components/ix-content-header.js +63 -0
  122. package/components/ix-content-header.js.map +1 -0
  123. package/components/ix-content.d.ts +11 -0
  124. package/components/ix-content.js +48 -0
  125. package/components/ix-content.js.map +1 -0
  126. package/components/ix-css-grid-item.d.ts +11 -0
  127. package/components/ix-css-grid-item.js +40 -0
  128. package/components/ix-css-grid-item.js.map +1 -0
  129. package/components/ix-css-grid.d.ts +11 -0
  130. package/components/ix-css-grid.js +113 -0
  131. package/components/ix-css-grid.js.map +1 -0
  132. package/components/ix-date-picker.d.ts +11 -0
  133. package/components/ix-date-picker.js +8 -0
  134. package/components/ix-date-picker.js.map +1 -0
  135. package/components/ix-date-time-card.d.ts +11 -0
  136. package/components/ix-date-time-card.js +8 -0
  137. package/components/ix-date-time-card.js.map +1 -0
  138. package/components/ix-datetime-picker.d.ts +11 -0
  139. package/components/ix-datetime-picker.js +149 -0
  140. package/components/ix-datetime-picker.js.map +1 -0
  141. package/components/ix-divider.d.ts +11 -0
  142. package/components/ix-divider.js +8 -0
  143. package/components/ix-divider.js.map +1 -0
  144. package/components/ix-drawer.d.ts +11 -0
  145. package/components/ix-drawer.js +145 -0
  146. package/components/ix-drawer.js.map +1 -0
  147. package/components/ix-dropdown-button.d.ts +11 -0
  148. package/components/ix-dropdown-button.js +92 -0
  149. package/components/ix-dropdown-button.js.map +1 -0
  150. package/components/ix-dropdown-header.d.ts +11 -0
  151. package/components/ix-dropdown-header.js +44 -0
  152. package/components/ix-dropdown-header.js.map +1 -0
  153. package/components/ix-dropdown-item.d.ts +11 -0
  154. package/components/ix-dropdown-item.js +8 -0
  155. package/components/ix-dropdown-item.js.map +1 -0
  156. package/components/ix-dropdown-quick-actions.d.ts +11 -0
  157. package/components/ix-dropdown-quick-actions.js +35 -0
  158. package/components/ix-dropdown-quick-actions.js.map +1 -0
  159. package/components/ix-dropdown.d.ts +11 -0
  160. package/components/ix-dropdown.js +8 -0
  161. package/components/ix-dropdown.js.map +1 -0
  162. package/components/ix-empty-state.d.ts +11 -0
  163. package/components/ix-empty-state.js +65 -0
  164. package/components/ix-empty-state.js.map +1 -0
  165. package/components/ix-event-list-item.d.ts +11 -0
  166. package/components/ix-event-list-item.js +61 -0
  167. package/components/ix-event-list-item.js.map +1 -0
  168. package/components/ix-event-list.d.ts +11 -0
  169. package/components/ix-event-list.js +143 -0
  170. package/components/ix-event-list.js.map +1 -0
  171. package/components/ix-expanding-search.d.ts +11 -0
  172. package/components/ix-expanding-search.js +119 -0
  173. package/components/ix-expanding-search.js.map +1 -0
  174. package/components/ix-filter-chip.d.ts +11 -0
  175. package/components/ix-filter-chip.js +8 -0
  176. package/components/ix-filter-chip.js.map +1 -0
  177. package/components/ix-flip-tile-content.d.ts +11 -0
  178. package/components/ix-flip-tile-content.js +38 -0
  179. package/components/ix-flip-tile-content.js.map +1 -0
  180. package/components/ix-flip-tile.d.ts +11 -0
  181. package/components/ix-flip-tile.js +121 -0
  182. package/components/ix-flip-tile.js.map +1 -0
  183. package/components/ix-form-field.d.ts +11 -0
  184. package/components/ix-form-field.js +43 -0
  185. package/components/ix-form-field.js.map +1 -0
  186. package/components/ix-group-context-menu.d.ts +11 -0
  187. package/components/ix-group-context-menu.js +8 -0
  188. package/components/ix-group-context-menu.js.map +1 -0
  189. package/components/ix-group-item.d.ts +11 -0
  190. package/components/ix-group-item.js +8 -0
  191. package/components/ix-group-item.js.map +1 -0
  192. package/components/ix-group.d.ts +11 -0
  193. package/components/ix-group.js +178 -0
  194. package/components/ix-group.js.map +1 -0
  195. package/components/ix-icon-button.d.ts +11 -0
  196. package/components/ix-icon-button.js +8 -0
  197. package/components/ix-icon-button.js.map +1 -0
  198. package/components/ix-icon-toggle-button.d.ts +11 -0
  199. package/components/ix-icon-toggle-button.js +116 -0
  200. package/components/ix-icon-toggle-button.js.map +1 -0
  201. package/components/ix-input-group.d.ts +11 -0
  202. package/components/ix-input-group.js +130 -0
  203. package/components/ix-input-group.js.map +1 -0
  204. package/components/ix-key-value-list.d.ts +11 -0
  205. package/components/ix-key-value-list.js +38 -0
  206. package/components/ix-key-value-list.js.map +1 -0
  207. package/components/ix-key-value.d.ts +11 -0
  208. package/components/ix-key-value.js +47 -0
  209. package/components/ix-key-value.js.map +1 -0
  210. package/components/ix-kpi.d.ts +11 -0
  211. package/components/ix-kpi.js +69 -0
  212. package/components/ix-kpi.js.map +1 -0
  213. package/components/ix-layout-grid.d.ts +11 -0
  214. package/components/ix-layout-grid.js +47 -0
  215. package/components/ix-layout-grid.js.map +1 -0
  216. package/components/ix-link-button.d.ts +11 -0
  217. package/components/ix-link-button.js +48 -0
  218. package/components/ix-link-button.js.map +1 -0
  219. package/components/ix-map-navigation-overlay.d.ts +11 -0
  220. package/components/ix-map-navigation-overlay.js +8 -0
  221. package/components/ix-map-navigation-overlay.js.map +1 -0
  222. package/components/ix-map-navigation.d.ts +11 -0
  223. package/components/ix-map-navigation.js +226 -0
  224. package/components/ix-map-navigation.js.map +1 -0
  225. package/components/ix-menu-about-item.d.ts +11 -0
  226. package/components/ix-menu-about-item.js +38 -0
  227. package/components/ix-menu-about-item.js.map +1 -0
  228. package/components/ix-menu-about-news.d.ts +11 -0
  229. package/components/ix-menu-about-news.js +83 -0
  230. package/components/ix-menu-about-news.js.map +1 -0
  231. package/components/ix-menu-about.d.ts +11 -0
  232. package/components/ix-menu-about.js +119 -0
  233. package/components/ix-menu-about.js.map +1 -0
  234. package/components/ix-menu-avatar-item.d.ts +11 -0
  235. package/components/ix-menu-avatar-item.js +8 -0
  236. package/components/ix-menu-avatar-item.js.map +1 -0
  237. package/components/ix-menu-avatar.d.ts +11 -0
  238. package/components/ix-menu-avatar.js +77 -0
  239. package/components/ix-menu-avatar.js.map +1 -0
  240. package/components/ix-menu-category.d.ts +11 -0
  241. package/components/ix-menu-category.js +190 -0
  242. package/components/ix-menu-category.js.map +1 -0
  243. package/components/ix-menu-item.d.ts +11 -0
  244. package/components/ix-menu-item.js +8 -0
  245. package/components/ix-menu-item.js.map +1 -0
  246. package/components/ix-menu-settings-item.d.ts +11 -0
  247. package/components/ix-menu-settings-item.js +38 -0
  248. package/components/ix-menu-settings-item.js.map +1 -0
  249. package/components/ix-menu-settings.d.ts +11 -0
  250. package/components/ix-menu-settings.js +106 -0
  251. package/components/ix-menu-settings.js.map +1 -0
  252. package/components/ix-menu.d.ts +11 -0
  253. package/components/ix-menu.js +508 -0
  254. package/components/ix-menu.js.map +1 -0
  255. package/components/ix-message-bar.d.ts +11 -0
  256. package/components/ix-message-bar.js +87 -0
  257. package/components/ix-message-bar.js.map +1 -0
  258. package/components/ix-modal-content.d.ts +11 -0
  259. package/components/ix-modal-content.js +35 -0
  260. package/components/ix-modal-content.js.map +1 -0
  261. package/components/ix-modal-example.d.ts +11 -0
  262. package/components/ix-modal-example.js +58 -0
  263. package/components/ix-modal-example.js.map +1 -0
  264. package/components/ix-modal-footer.d.ts +11 -0
  265. package/components/ix-modal-footer.js +35 -0
  266. package/components/ix-modal-footer.js.map +1 -0
  267. package/components/ix-modal-header.d.ts +11 -0
  268. package/components/ix-modal-header.js +84 -0
  269. package/components/ix-modal-header.js.map +1 -0
  270. package/components/ix-modal-loading.d.ts +11 -0
  271. package/components/ix-modal-loading.js +41 -0
  272. package/components/ix-modal-loading.js.map +1 -0
  273. package/components/ix-modal.d.ts +11 -0
  274. package/components/ix-modal.js +156 -0
  275. package/components/ix-modal.js.map +1 -0
  276. package/components/ix-pagination.d.ts +11 -0
  277. package/components/ix-pagination.js +211 -0
  278. package/components/ix-pagination.js.map +1 -0
  279. package/components/ix-pill.d.ts +11 -0
  280. package/components/ix-pill.js +78 -0
  281. package/components/ix-pill.js.map +1 -0
  282. package/components/ix-push-card.d.ts +11 -0
  283. package/components/ix-push-card.js +80 -0
  284. package/components/ix-push-card.js.map +1 -0
  285. package/components/ix-row.d.ts +11 -0
  286. package/components/ix-row.js +35 -0
  287. package/components/ix-row.js.map +1 -0
  288. package/components/ix-select-item.d.ts +11 -0
  289. package/components/ix-select-item.js +8 -0
  290. package/components/ix-select-item.js.map +1 -0
  291. package/components/ix-select.d.ts +11 -0
  292. package/components/ix-select.js +8 -0
  293. package/components/ix-select.js.map +1 -0
  294. package/components/ix-slider.d.ts +11 -0
  295. package/components/ix-slider.js +192 -0
  296. package/components/ix-slider.js.map +1 -0
  297. package/components/ix-spinner.d.ts +11 -0
  298. package/components/ix-spinner.js +8 -0
  299. package/components/ix-spinner.js.map +1 -0
  300. package/components/ix-split-button-item.d.ts +11 -0
  301. package/components/ix-split-button-item.js +51 -0
  302. package/components/ix-split-button-item.js.map +1 -0
  303. package/components/ix-split-button.d.ts +11 -0
  304. package/components/ix-split-button.js +97 -0
  305. package/components/ix-split-button.js.map +1 -0
  306. package/components/ix-tab-item.d.ts +11 -0
  307. package/components/ix-tab-item.js +8 -0
  308. package/components/ix-tab-item.js.map +1 -0
  309. package/components/ix-tabs.d.ts +11 -0
  310. package/components/ix-tabs.js +8 -0
  311. package/components/ix-tabs.js.map +1 -0
  312. package/components/ix-tile.d.ts +11 -0
  313. package/components/ix-tile.js +59 -0
  314. package/components/ix-tile.js.map +1 -0
  315. package/components/ix-time-picker.d.ts +11 -0
  316. package/components/ix-time-picker.js +8 -0
  317. package/components/ix-time-picker.js.map +1 -0
  318. package/components/ix-toast-container.d.ts +11 -0
  319. package/components/ix-toast-container.js +124 -0
  320. package/components/ix-toast-container.js.map +1 -0
  321. package/components/ix-toast.d.ts +11 -0
  322. package/components/ix-toast.js +8 -0
  323. package/components/ix-toast.js.map +1 -0
  324. package/components/ix-toggle-button.d.ts +11 -0
  325. package/components/ix-toggle-button.js +105 -0
  326. package/components/ix-toggle-button.js.map +1 -0
  327. package/components/ix-toggle.d.ts +11 -0
  328. package/components/ix-toggle.js +62 -0
  329. package/components/ix-toggle.js.map +1 -0
  330. package/components/ix-tooltip.d.ts +11 -0
  331. package/components/ix-tooltip.js +8 -0
  332. package/components/ix-tooltip.js.map +1 -0
  333. package/components/ix-tree-item.d.ts +11 -0
  334. package/components/ix-tree-item.js +8 -0
  335. package/components/ix-tree-item.js.map +1 -0
  336. package/components/ix-tree.d.ts +11 -0
  337. package/components/ix-tree.js +727 -0
  338. package/components/ix-tree.js.map +1 -0
  339. package/components/ix-typography.d.ts +11 -0
  340. package/components/ix-typography.js +8 -0
  341. package/components/ix-typography.js.map +1 -0
  342. package/components/ix-upload.d.ts +11 -0
  343. package/components/ix-upload.js +147 -0
  344. package/components/ix-upload.js.map +1 -0
  345. package/components/ix-validation-tooltip.d.ts +11 -0
  346. package/components/ix-validation-tooltip.js +170 -0
  347. package/components/ix-validation-tooltip.js.map +1 -0
  348. package/components/ix-workflow-step.d.ts +11 -0
  349. package/components/ix-workflow-step.js +120 -0
  350. package/components/ix-workflow-step.js.map +1 -0
  351. package/components/ix-workflow-steps.d.ts +11 -0
  352. package/components/ix-workflow-steps.js +99 -0
  353. package/components/ix-workflow-steps.js.map +1 -0
  354. package/components/logical-filter-operator.js +35 -0
  355. package/components/logical-filter-operator.js.map +1 -0
  356. package/components/luxon.js +7828 -0
  357. package/components/luxon.js.map +1 -0
  358. package/components/map-navigation-overlay.js +89 -0
  359. package/components/map-navigation-overlay.js.map +1 -0
  360. package/components/menu-avatar-item.js +45 -0
  361. package/components/menu-avatar-item.js.map +1 -0
  362. package/components/menu-item.js +92 -0
  363. package/components/menu-item.js.map +1 -0
  364. package/components/menu-service.js +156 -0
  365. package/components/menu-service.js.map +1 -0
  366. package/components/modal.js +245 -0
  367. package/components/modal.js.map +1 -0
  368. package/components/mutation-observer.js +13 -0
  369. package/components/mutation-observer.js.map +1 -0
  370. package/components/my-component.d.ts +11 -0
  371. package/components/my-component.js +34 -0
  372. package/components/my-component.js.map +1 -0
  373. package/components/package.json +8 -0
  374. package/components/rwd.util.js +41 -0
  375. package/components/rwd.util.js.map +1 -0
  376. package/components/select-item.js +92 -0
  377. package/components/select-item.js.map +1 -0
  378. package/components/select.js +410 -0
  379. package/components/select.js.map +1 -0
  380. package/components/shadow-dom.js +21 -0
  381. package/components/shadow-dom.js.map +1 -0
  382. package/components/spinner.js +48 -0
  383. package/components/spinner.js.map +1 -0
  384. package/components/tab-item.js +87 -0
  385. package/components/tab-item.js.map +1 -0
  386. package/components/tabs.js +227 -0
  387. package/components/tabs.js.map +1 -0
  388. package/components/theme-switcher.js +123 -0
  389. package/components/theme-switcher.js.map +1 -0
  390. package/components/time-picker.js +252 -0
  391. package/components/time-picker.js.map +1 -0
  392. package/components/toast.js +105 -0
  393. package/components/toast.js.map +1 -0
  394. package/components/tooltip.js +197 -0
  395. package/components/tooltip.js.map +1 -0
  396. package/components/tree-item.js +51 -0
  397. package/components/tree-item.js.map +1 -0
  398. package/components/typed-event.js +46 -0
  399. package/components/typed-event.js.map +1 -0
  400. package/components/typography.js +76 -0
  401. package/components/typography.js.map +1 -0
  402. package/components/upload-file-state.js +19 -0
  403. package/components/upload-file-state.js.map +1 -0
  404. package/package.json +1 -1
@@ -0,0 +1,1512 @@
1
+ const min = Math.min;
2
+ const max = Math.max;
3
+ const round = Math.round;
4
+ const floor = Math.floor;
5
+ const createCoords = v => ({
6
+ x: v,
7
+ y: v
8
+ });
9
+ const oppositeSideMap = {
10
+ left: 'right',
11
+ right: 'left',
12
+ bottom: 'top',
13
+ top: 'bottom'
14
+ };
15
+ const oppositeAlignmentMap = {
16
+ start: 'end',
17
+ end: 'start'
18
+ };
19
+ function clamp(start, value, end) {
20
+ return max(start, min(value, end));
21
+ }
22
+ function evaluate(value, param) {
23
+ return typeof value === 'function' ? value(param) : value;
24
+ }
25
+ function getSide(placement) {
26
+ return placement.split('-')[0];
27
+ }
28
+ function getAlignment(placement) {
29
+ return placement.split('-')[1];
30
+ }
31
+ function getOppositeAxis(axis) {
32
+ return axis === 'x' ? 'y' : 'x';
33
+ }
34
+ function getAxisLength(axis) {
35
+ return axis === 'y' ? 'height' : 'width';
36
+ }
37
+ function getSideAxis(placement) {
38
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
39
+ }
40
+ function getAlignmentAxis(placement) {
41
+ return getOppositeAxis(getSideAxis(placement));
42
+ }
43
+ function getAlignmentSides(placement, rects, rtl) {
44
+ if (rtl === void 0) {
45
+ rtl = false;
46
+ }
47
+ const alignment = getAlignment(placement);
48
+ const alignmentAxis = getAlignmentAxis(placement);
49
+ const length = getAxisLength(alignmentAxis);
50
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
51
+ if (rects.reference[length] > rects.floating[length]) {
52
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
53
+ }
54
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
55
+ }
56
+ function getExpandedPlacements(placement) {
57
+ const oppositePlacement = getOppositePlacement(placement);
58
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
59
+ }
60
+ function getOppositeAlignmentPlacement(placement) {
61
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
62
+ }
63
+ function getSideList(side, isStart, rtl) {
64
+ const lr = ['left', 'right'];
65
+ const rl = ['right', 'left'];
66
+ const tb = ['top', 'bottom'];
67
+ const bt = ['bottom', 'top'];
68
+ switch (side) {
69
+ case 'top':
70
+ case 'bottom':
71
+ if (rtl) return isStart ? rl : lr;
72
+ return isStart ? lr : rl;
73
+ case 'left':
74
+ case 'right':
75
+ return isStart ? tb : bt;
76
+ default:
77
+ return [];
78
+ }
79
+ }
80
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
81
+ const alignment = getAlignment(placement);
82
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
83
+ if (alignment) {
84
+ list = list.map(side => side + "-" + alignment);
85
+ if (flipAlignment) {
86
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
87
+ }
88
+ }
89
+ return list;
90
+ }
91
+ function getOppositePlacement(placement) {
92
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
93
+ }
94
+ function expandPaddingObject(padding) {
95
+ return {
96
+ top: 0,
97
+ right: 0,
98
+ bottom: 0,
99
+ left: 0,
100
+ ...padding
101
+ };
102
+ }
103
+ function getPaddingObject(padding) {
104
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
105
+ top: padding,
106
+ right: padding,
107
+ bottom: padding,
108
+ left: padding
109
+ };
110
+ }
111
+ function rectToClientRect(rect) {
112
+ return {
113
+ ...rect,
114
+ top: rect.y,
115
+ left: rect.x,
116
+ right: rect.x + rect.width,
117
+ bottom: rect.y + rect.height
118
+ };
119
+ }
120
+
121
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
122
+ let {
123
+ reference,
124
+ floating
125
+ } = _ref;
126
+ const sideAxis = getSideAxis(placement);
127
+ const alignmentAxis = getAlignmentAxis(placement);
128
+ const alignLength = getAxisLength(alignmentAxis);
129
+ const side = getSide(placement);
130
+ const isVertical = sideAxis === 'y';
131
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
132
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
133
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
134
+ let coords;
135
+ switch (side) {
136
+ case 'top':
137
+ coords = {
138
+ x: commonX,
139
+ y: reference.y - floating.height
140
+ };
141
+ break;
142
+ case 'bottom':
143
+ coords = {
144
+ x: commonX,
145
+ y: reference.y + reference.height
146
+ };
147
+ break;
148
+ case 'right':
149
+ coords = {
150
+ x: reference.x + reference.width,
151
+ y: commonY
152
+ };
153
+ break;
154
+ case 'left':
155
+ coords = {
156
+ x: reference.x - floating.width,
157
+ y: commonY
158
+ };
159
+ break;
160
+ default:
161
+ coords = {
162
+ x: reference.x,
163
+ y: reference.y
164
+ };
165
+ }
166
+ switch (getAlignment(placement)) {
167
+ case 'start':
168
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
169
+ break;
170
+ case 'end':
171
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
172
+ break;
173
+ }
174
+ return coords;
175
+ }
176
+
177
+ /**
178
+ * Computes the `x` and `y` coordinates that will place the floating element
179
+ * next to a reference element when it is given a certain positioning strategy.
180
+ *
181
+ * This export does not have any `platform` interface logic. You will need to
182
+ * write one for the platform you are using Floating UI with.
183
+ */
184
+ const computePosition$1 = async (reference, floating, config) => {
185
+ const {
186
+ placement = 'bottom',
187
+ strategy = 'absolute',
188
+ middleware = [],
189
+ platform
190
+ } = config;
191
+ const validMiddleware = middleware.filter(Boolean);
192
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
193
+ let rects = await platform.getElementRects({
194
+ reference,
195
+ floating,
196
+ strategy
197
+ });
198
+ let {
199
+ x,
200
+ y
201
+ } = computeCoordsFromPlacement(rects, placement, rtl);
202
+ let statefulPlacement = placement;
203
+ let middlewareData = {};
204
+ let resetCount = 0;
205
+ for (let i = 0; i < validMiddleware.length; i++) {
206
+ const {
207
+ name,
208
+ fn
209
+ } = validMiddleware[i];
210
+ const {
211
+ x: nextX,
212
+ y: nextY,
213
+ data,
214
+ reset
215
+ } = await fn({
216
+ x,
217
+ y,
218
+ initialPlacement: placement,
219
+ placement: statefulPlacement,
220
+ strategy,
221
+ middlewareData,
222
+ rects,
223
+ platform,
224
+ elements: {
225
+ reference,
226
+ floating
227
+ }
228
+ });
229
+ x = nextX != null ? nextX : x;
230
+ y = nextY != null ? nextY : y;
231
+ middlewareData = {
232
+ ...middlewareData,
233
+ [name]: {
234
+ ...middlewareData[name],
235
+ ...data
236
+ }
237
+ };
238
+ if (reset && resetCount <= 50) {
239
+ resetCount++;
240
+ if (typeof reset === 'object') {
241
+ if (reset.placement) {
242
+ statefulPlacement = reset.placement;
243
+ }
244
+ if (reset.rects) {
245
+ rects = reset.rects === true ? await platform.getElementRects({
246
+ reference,
247
+ floating,
248
+ strategy
249
+ }) : reset.rects;
250
+ }
251
+ ({
252
+ x,
253
+ y
254
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
255
+ }
256
+ i = -1;
257
+ continue;
258
+ }
259
+ }
260
+ return {
261
+ x,
262
+ y,
263
+ placement: statefulPlacement,
264
+ strategy,
265
+ middlewareData
266
+ };
267
+ };
268
+
269
+ /**
270
+ * Resolves with an object of overflow side offsets that determine how much the
271
+ * element is overflowing a given clipping boundary on each side.
272
+ * - positive = overflowing the boundary by that number of pixels
273
+ * - negative = how many pixels left before it will overflow
274
+ * - 0 = lies flush with the boundary
275
+ * @see https://floating-ui.com/docs/detectOverflow
276
+ */
277
+ async function detectOverflow(state, options) {
278
+ var _await$platform$isEle;
279
+ if (options === void 0) {
280
+ options = {};
281
+ }
282
+ const {
283
+ x,
284
+ y,
285
+ platform,
286
+ rects,
287
+ elements,
288
+ strategy
289
+ } = state;
290
+ const {
291
+ boundary = 'clippingAncestors',
292
+ rootBoundary = 'viewport',
293
+ elementContext = 'floating',
294
+ altBoundary = false,
295
+ padding = 0
296
+ } = evaluate(options, state);
297
+ const paddingObject = getPaddingObject(padding);
298
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
299
+ const element = elements[altBoundary ? altContext : elementContext];
300
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
301
+ 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))),
302
+ boundary,
303
+ rootBoundary,
304
+ strategy
305
+ }));
306
+ const rect = elementContext === 'floating' ? {
307
+ ...rects.floating,
308
+ x,
309
+ y
310
+ } : rects.reference;
311
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
312
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
313
+ x: 1,
314
+ y: 1
315
+ } : {
316
+ x: 1,
317
+ y: 1
318
+ };
319
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
320
+ rect,
321
+ offsetParent,
322
+ strategy
323
+ }) : rect);
324
+ return {
325
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
326
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
327
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
328
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
329
+ };
330
+ }
331
+
332
+ /**
333
+ * Provides data to position an inner element of the floating element so that it
334
+ * appears centered to the reference element.
335
+ * @see https://floating-ui.com/docs/arrow
336
+ */
337
+ const arrow = options => ({
338
+ name: 'arrow',
339
+ options,
340
+ async fn(state) {
341
+ const {
342
+ x,
343
+ y,
344
+ placement,
345
+ rects,
346
+ platform,
347
+ elements
348
+ } = state;
349
+ // Since `element` is required, we don't Partial<> the type.
350
+ const {
351
+ element,
352
+ padding = 0
353
+ } = evaluate(options, state) || {};
354
+ if (element == null) {
355
+ return {};
356
+ }
357
+ const paddingObject = getPaddingObject(padding);
358
+ const coords = {
359
+ x,
360
+ y
361
+ };
362
+ const axis = getAlignmentAxis(placement);
363
+ const length = getAxisLength(axis);
364
+ const arrowDimensions = await platform.getDimensions(element);
365
+ const isYAxis = axis === 'y';
366
+ const minProp = isYAxis ? 'top' : 'left';
367
+ const maxProp = isYAxis ? 'bottom' : 'right';
368
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
369
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
370
+ const startDiff = coords[axis] - rects.reference[axis];
371
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
372
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
373
+
374
+ // DOM platform can return `window` as the `offsetParent`.
375
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
376
+ clientSize = elements.floating[clientProp] || rects.floating[length];
377
+ }
378
+ const centerToReference = endDiff / 2 - startDiff / 2;
379
+
380
+ // If the padding is large enough that it causes the arrow to no longer be
381
+ // centered, modify the padding so that it is centered.
382
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
383
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
384
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
385
+
386
+ // Make sure the arrow doesn't overflow the floating element if the center
387
+ // point is outside the floating element's bounds.
388
+ const min$1 = minPadding;
389
+ const max = clientSize - arrowDimensions[length] - maxPadding;
390
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
391
+ const offset = clamp(min$1, center, max);
392
+
393
+ // If the reference is small enough that the arrow's padding causes it to
394
+ // to point to nothing for an aligned placement, adjust the offset of the
395
+ // floating element itself. This stops `shift()` from taking action, but can
396
+ // be worked around by calling it again after the `arrow()` if desired.
397
+ const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
398
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? min$1 - center : max - center : 0;
399
+ return {
400
+ [axis]: coords[axis] - alignmentOffset,
401
+ data: {
402
+ [axis]: offset,
403
+ centerOffset: center - offset + alignmentOffset
404
+ }
405
+ };
406
+ }
407
+ });
408
+
409
+ /**
410
+ * Optimizes the visibility of the floating element by flipping the `placement`
411
+ * in order to keep it in view when the preferred placement(s) will overflow the
412
+ * clipping boundary. Alternative to `autoPlacement`.
413
+ * @see https://floating-ui.com/docs/flip
414
+ */
415
+ const flip = function (options) {
416
+ if (options === void 0) {
417
+ options = {};
418
+ }
419
+ return {
420
+ name: 'flip',
421
+ options,
422
+ async fn(state) {
423
+ var _middlewareData$flip;
424
+ const {
425
+ placement,
426
+ middlewareData,
427
+ rects,
428
+ initialPlacement,
429
+ platform,
430
+ elements
431
+ } = state;
432
+ const {
433
+ mainAxis: checkMainAxis = true,
434
+ crossAxis: checkCrossAxis = true,
435
+ fallbackPlacements: specifiedFallbackPlacements,
436
+ fallbackStrategy = 'bestFit',
437
+ fallbackAxisSideDirection = 'none',
438
+ flipAlignment = true,
439
+ ...detectOverflowOptions
440
+ } = evaluate(options, state);
441
+ const side = getSide(placement);
442
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
443
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
444
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
445
+ if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
446
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
447
+ }
448
+ const placements = [initialPlacement, ...fallbackPlacements];
449
+ const overflow = await detectOverflow(state, detectOverflowOptions);
450
+ const overflows = [];
451
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
452
+ if (checkMainAxis) {
453
+ overflows.push(overflow[side]);
454
+ }
455
+ if (checkCrossAxis) {
456
+ const sides = getAlignmentSides(placement, rects, rtl);
457
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
458
+ }
459
+ overflowsData = [...overflowsData, {
460
+ placement,
461
+ overflows
462
+ }];
463
+
464
+ // One or more sides is overflowing.
465
+ if (!overflows.every(side => side <= 0)) {
466
+ var _middlewareData$flip2, _overflowsData$filter;
467
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
468
+ const nextPlacement = placements[nextIndex];
469
+ if (nextPlacement) {
470
+ // Try next placement and re-run the lifecycle.
471
+ return {
472
+ data: {
473
+ index: nextIndex,
474
+ overflows: overflowsData
475
+ },
476
+ reset: {
477
+ placement: nextPlacement
478
+ }
479
+ };
480
+ }
481
+
482
+ // First, find the candidates that fit on the mainAxis side of overflow,
483
+ // then find the placement that fits the best on the main crossAxis side.
484
+ 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;
485
+
486
+ // Otherwise fallback.
487
+ if (!resetPlacement) {
488
+ switch (fallbackStrategy) {
489
+ case 'bestFit':
490
+ {
491
+ var _overflowsData$map$so;
492
+ 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];
493
+ if (placement) {
494
+ resetPlacement = placement;
495
+ }
496
+ break;
497
+ }
498
+ case 'initialPlacement':
499
+ resetPlacement = initialPlacement;
500
+ break;
501
+ }
502
+ }
503
+ if (placement !== resetPlacement) {
504
+ return {
505
+ reset: {
506
+ placement: resetPlacement
507
+ }
508
+ };
509
+ }
510
+ }
511
+ return {};
512
+ }
513
+ };
514
+ };
515
+
516
+ function getBoundingRect(rects) {
517
+ const minX = min(...rects.map(rect => rect.left));
518
+ const minY = min(...rects.map(rect => rect.top));
519
+ const maxX = max(...rects.map(rect => rect.right));
520
+ const maxY = max(...rects.map(rect => rect.bottom));
521
+ return {
522
+ x: minX,
523
+ y: minY,
524
+ width: maxX - minX,
525
+ height: maxY - minY
526
+ };
527
+ }
528
+ function getRectsByLine(rects) {
529
+ const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
530
+ const groups = [];
531
+ let prevRect = null;
532
+ for (let i = 0; i < sortedRects.length; i++) {
533
+ const rect = sortedRects[i];
534
+ if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
535
+ groups.push([rect]);
536
+ } else {
537
+ groups[groups.length - 1].push(rect);
538
+ }
539
+ prevRect = rect;
540
+ }
541
+ return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
542
+ }
543
+ /**
544
+ * Provides improved positioning for inline reference elements that can span
545
+ * over multiple lines, such as hyperlinks or range selections.
546
+ * @see https://floating-ui.com/docs/inline
547
+ */
548
+ const inline = function (options) {
549
+ if (options === void 0) {
550
+ options = {};
551
+ }
552
+ return {
553
+ name: 'inline',
554
+ options,
555
+ async fn(state) {
556
+ const {
557
+ placement,
558
+ elements,
559
+ rects,
560
+ platform,
561
+ strategy
562
+ } = state;
563
+ // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
564
+ // ClientRect's bounds, despite the event listener being triggered. A
565
+ // padding of 2 seems to handle this issue.
566
+ const {
567
+ padding = 2,
568
+ x,
569
+ y
570
+ } = evaluate(options, state);
571
+ const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
572
+ const clientRects = getRectsByLine(nativeClientRects);
573
+ const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
574
+ const paddingObject = getPaddingObject(padding);
575
+ function getBoundingClientRect() {
576
+ // There are two rects and they are disjoined.
577
+ if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
578
+ // Find the first rect in which the point is fully inside.
579
+ return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
580
+ }
581
+
582
+ // There are 2 or more connected rects.
583
+ if (clientRects.length >= 2) {
584
+ if (getSideAxis(placement) === 'y') {
585
+ const firstRect = clientRects[0];
586
+ const lastRect = clientRects[clientRects.length - 1];
587
+ const isTop = getSide(placement) === 'top';
588
+ const top = firstRect.top;
589
+ const bottom = lastRect.bottom;
590
+ const left = isTop ? firstRect.left : lastRect.left;
591
+ const right = isTop ? firstRect.right : lastRect.right;
592
+ const width = right - left;
593
+ const height = bottom - top;
594
+ return {
595
+ top,
596
+ bottom,
597
+ left,
598
+ right,
599
+ width,
600
+ height,
601
+ x: left,
602
+ y: top
603
+ };
604
+ }
605
+ const isLeftSide = getSide(placement) === 'left';
606
+ const maxRight = max(...clientRects.map(rect => rect.right));
607
+ const minLeft = min(...clientRects.map(rect => rect.left));
608
+ const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
609
+ const top = measureRects[0].top;
610
+ const bottom = measureRects[measureRects.length - 1].bottom;
611
+ const left = minLeft;
612
+ const right = maxRight;
613
+ const width = right - left;
614
+ const height = bottom - top;
615
+ return {
616
+ top,
617
+ bottom,
618
+ left,
619
+ right,
620
+ width,
621
+ height,
622
+ x: left,
623
+ y: top
624
+ };
625
+ }
626
+ return fallback;
627
+ }
628
+ const resetRects = await platform.getElementRects({
629
+ reference: {
630
+ getBoundingClientRect
631
+ },
632
+ floating: elements.floating,
633
+ strategy
634
+ });
635
+ if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
636
+ return {
637
+ reset: {
638
+ rects: resetRects
639
+ }
640
+ };
641
+ }
642
+ return {};
643
+ }
644
+ };
645
+ };
646
+
647
+ // For type backwards-compatibility, the `OffsetOptions` type was also
648
+ // Derivable.
649
+ async function convertValueToCoords(state, options) {
650
+ const {
651
+ placement,
652
+ platform,
653
+ elements
654
+ } = state;
655
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
656
+ const side = getSide(placement);
657
+ const alignment = getAlignment(placement);
658
+ const isVertical = getSideAxis(placement) === 'y';
659
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
660
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
661
+ const rawValue = evaluate(options, state);
662
+
663
+ // eslint-disable-next-line prefer-const
664
+ let {
665
+ mainAxis,
666
+ crossAxis,
667
+ alignmentAxis
668
+ } = typeof rawValue === 'number' ? {
669
+ mainAxis: rawValue,
670
+ crossAxis: 0,
671
+ alignmentAxis: null
672
+ } : {
673
+ mainAxis: 0,
674
+ crossAxis: 0,
675
+ alignmentAxis: null,
676
+ ...rawValue
677
+ };
678
+ if (alignment && typeof alignmentAxis === 'number') {
679
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
680
+ }
681
+ return isVertical ? {
682
+ x: crossAxis * crossAxisMulti,
683
+ y: mainAxis * mainAxisMulti
684
+ } : {
685
+ x: mainAxis * mainAxisMulti,
686
+ y: crossAxis * crossAxisMulti
687
+ };
688
+ }
689
+
690
+ /**
691
+ * Modifies the placement by translating the floating element along the
692
+ * specified axes.
693
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
694
+ * object may be passed.
695
+ * @see https://floating-ui.com/docs/offset
696
+ */
697
+ const offset = function (options) {
698
+ if (options === void 0) {
699
+ options = 0;
700
+ }
701
+ return {
702
+ name: 'offset',
703
+ options,
704
+ async fn(state) {
705
+ const {
706
+ x,
707
+ y
708
+ } = state;
709
+ const diffCoords = await convertValueToCoords(state, options);
710
+ return {
711
+ x: x + diffCoords.x,
712
+ y: y + diffCoords.y,
713
+ data: diffCoords
714
+ };
715
+ }
716
+ };
717
+ };
718
+
719
+ /**
720
+ * Optimizes the visibility of the floating element by shifting it in order to
721
+ * keep it in view when it will overflow the clipping boundary.
722
+ * @see https://floating-ui.com/docs/shift
723
+ */
724
+ const shift = function (options) {
725
+ if (options === void 0) {
726
+ options = {};
727
+ }
728
+ return {
729
+ name: 'shift',
730
+ options,
731
+ async fn(state) {
732
+ const {
733
+ x,
734
+ y,
735
+ placement
736
+ } = state;
737
+ const {
738
+ mainAxis: checkMainAxis = true,
739
+ crossAxis: checkCrossAxis = false,
740
+ limiter = {
741
+ fn: _ref => {
742
+ let {
743
+ x,
744
+ y
745
+ } = _ref;
746
+ return {
747
+ x,
748
+ y
749
+ };
750
+ }
751
+ },
752
+ ...detectOverflowOptions
753
+ } = evaluate(options, state);
754
+ const coords = {
755
+ x,
756
+ y
757
+ };
758
+ const overflow = await detectOverflow(state, detectOverflowOptions);
759
+ const crossAxis = getSideAxis(getSide(placement));
760
+ const mainAxis = getOppositeAxis(crossAxis);
761
+ let mainAxisCoord = coords[mainAxis];
762
+ let crossAxisCoord = coords[crossAxis];
763
+ if (checkMainAxis) {
764
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
765
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
766
+ const min = mainAxisCoord + overflow[minSide];
767
+ const max = mainAxisCoord - overflow[maxSide];
768
+ mainAxisCoord = clamp(min, mainAxisCoord, max);
769
+ }
770
+ if (checkCrossAxis) {
771
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
772
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
773
+ const min = crossAxisCoord + overflow[minSide];
774
+ const max = crossAxisCoord - overflow[maxSide];
775
+ crossAxisCoord = clamp(min, crossAxisCoord, max);
776
+ }
777
+ const limitedCoords = limiter.fn({
778
+ ...state,
779
+ [mainAxis]: mainAxisCoord,
780
+ [crossAxis]: crossAxisCoord
781
+ });
782
+ return {
783
+ ...limitedCoords,
784
+ data: {
785
+ x: limitedCoords.x - x,
786
+ y: limitedCoords.y - y
787
+ }
788
+ };
789
+ }
790
+ };
791
+ };
792
+
793
+ function getNodeName(node) {
794
+ if (isNode(node)) {
795
+ return (node.nodeName || '').toLowerCase();
796
+ }
797
+ // Mocked nodes in testing environments may not be instances of Node. By
798
+ // returning `#document` an infinite loop won't occur.
799
+ // https://github.com/floating-ui/floating-ui/issues/2317
800
+ return '#document';
801
+ }
802
+ function getWindow(node) {
803
+ var _node$ownerDocument;
804
+ return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
805
+ }
806
+ function getDocumentElement(node) {
807
+ var _ref;
808
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
809
+ }
810
+ function isNode(value) {
811
+ return value instanceof Node || value instanceof getWindow(value).Node;
812
+ }
813
+ function isElement(value) {
814
+ return value instanceof Element || value instanceof getWindow(value).Element;
815
+ }
816
+ function isHTMLElement(value) {
817
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
818
+ }
819
+ function isShadowRoot(value) {
820
+ // Browsers without `ShadowRoot` support.
821
+ if (typeof ShadowRoot === 'undefined') {
822
+ return false;
823
+ }
824
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
825
+ }
826
+ function isOverflowElement(element) {
827
+ const {
828
+ overflow,
829
+ overflowX,
830
+ overflowY,
831
+ display
832
+ } = getComputedStyle(element);
833
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
834
+ }
835
+ function isTableElement(element) {
836
+ return ['table', 'td', 'th'].includes(getNodeName(element));
837
+ }
838
+ function isContainingBlock(element) {
839
+ const webkit = isWebKit();
840
+ const css = getComputedStyle(element);
841
+
842
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
843
+ 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));
844
+ }
845
+ function getContainingBlock(element) {
846
+ let currentNode = getParentNode(element);
847
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
848
+ if (isContainingBlock(currentNode)) {
849
+ return currentNode;
850
+ } else {
851
+ currentNode = getParentNode(currentNode);
852
+ }
853
+ }
854
+ return null;
855
+ }
856
+ function isWebKit() {
857
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
858
+ return CSS.supports('-webkit-backdrop-filter', 'none');
859
+ }
860
+ function isLastTraversableNode(node) {
861
+ return ['html', 'body', '#document'].includes(getNodeName(node));
862
+ }
863
+ function getComputedStyle(element) {
864
+ return getWindow(element).getComputedStyle(element);
865
+ }
866
+ function getNodeScroll(element) {
867
+ if (isElement(element)) {
868
+ return {
869
+ scrollLeft: element.scrollLeft,
870
+ scrollTop: element.scrollTop
871
+ };
872
+ }
873
+ return {
874
+ scrollLeft: element.pageXOffset,
875
+ scrollTop: element.pageYOffset
876
+ };
877
+ }
878
+ function getParentNode(node) {
879
+ if (getNodeName(node) === 'html') {
880
+ return node;
881
+ }
882
+ const result =
883
+ // Step into the shadow DOM of the parent of a slotted node.
884
+ node.assignedSlot ||
885
+ // DOM Element detected.
886
+ node.parentNode ||
887
+ // ShadowRoot detected.
888
+ isShadowRoot(node) && node.host ||
889
+ // Fallback.
890
+ getDocumentElement(node);
891
+ return isShadowRoot(result) ? result.host : result;
892
+ }
893
+ function getNearestOverflowAncestor(node) {
894
+ const parentNode = getParentNode(node);
895
+ if (isLastTraversableNode(parentNode)) {
896
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
897
+ }
898
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
899
+ return parentNode;
900
+ }
901
+ return getNearestOverflowAncestor(parentNode);
902
+ }
903
+ function getOverflowAncestors(node, list) {
904
+ var _node$ownerDocument2;
905
+ if (list === void 0) {
906
+ list = [];
907
+ }
908
+ const scrollableAncestor = getNearestOverflowAncestor(node);
909
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
910
+ const win = getWindow(scrollableAncestor);
911
+ if (isBody) {
912
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
913
+ }
914
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
915
+ }
916
+
917
+ function getCssDimensions(element) {
918
+ const css = getComputedStyle(element);
919
+ // In testing environments, the `width` and `height` properties are empty
920
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
921
+ let width = parseFloat(css.width) || 0;
922
+ let height = parseFloat(css.height) || 0;
923
+ const hasOffset = isHTMLElement(element);
924
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
925
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
926
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
927
+ if (shouldFallback) {
928
+ width = offsetWidth;
929
+ height = offsetHeight;
930
+ }
931
+ return {
932
+ width,
933
+ height,
934
+ $: shouldFallback
935
+ };
936
+ }
937
+
938
+ function unwrapElement(element) {
939
+ return !isElement(element) ? element.contextElement : element;
940
+ }
941
+
942
+ function getScale(element) {
943
+ const domElement = unwrapElement(element);
944
+ if (!isHTMLElement(domElement)) {
945
+ return createCoords(1);
946
+ }
947
+ const rect = domElement.getBoundingClientRect();
948
+ const {
949
+ width,
950
+ height,
951
+ $
952
+ } = getCssDimensions(domElement);
953
+ let x = ($ ? round(rect.width) : rect.width) / width;
954
+ let y = ($ ? round(rect.height) : rect.height) / height;
955
+
956
+ // 0, NaN, or Infinity should always fallback to 1.
957
+
958
+ if (!x || !Number.isFinite(x)) {
959
+ x = 1;
960
+ }
961
+ if (!y || !Number.isFinite(y)) {
962
+ y = 1;
963
+ }
964
+ return {
965
+ x,
966
+ y
967
+ };
968
+ }
969
+
970
+ const noOffsets = /*#__PURE__*/createCoords(0);
971
+ function getVisualOffsets(element) {
972
+ const win = getWindow(element);
973
+ if (!isWebKit() || !win.visualViewport) {
974
+ return noOffsets;
975
+ }
976
+ return {
977
+ x: win.visualViewport.offsetLeft,
978
+ y: win.visualViewport.offsetTop
979
+ };
980
+ }
981
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
982
+ if (isFixed === void 0) {
983
+ isFixed = false;
984
+ }
985
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
986
+ return false;
987
+ }
988
+ return isFixed;
989
+ }
990
+
991
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
992
+ if (includeScale === void 0) {
993
+ includeScale = false;
994
+ }
995
+ if (isFixedStrategy === void 0) {
996
+ isFixedStrategy = false;
997
+ }
998
+ const clientRect = element.getBoundingClientRect();
999
+ const domElement = unwrapElement(element);
1000
+ let scale = createCoords(1);
1001
+ if (includeScale) {
1002
+ if (offsetParent) {
1003
+ if (isElement(offsetParent)) {
1004
+ scale = getScale(offsetParent);
1005
+ }
1006
+ } else {
1007
+ scale = getScale(element);
1008
+ }
1009
+ }
1010
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1011
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
1012
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
1013
+ let width = clientRect.width / scale.x;
1014
+ let height = clientRect.height / scale.y;
1015
+ if (domElement) {
1016
+ const win = getWindow(domElement);
1017
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1018
+ let currentIFrame = win.frameElement;
1019
+ while (currentIFrame && offsetParent && offsetWin !== win) {
1020
+ const iframeScale = getScale(currentIFrame);
1021
+ const iframeRect = currentIFrame.getBoundingClientRect();
1022
+ const css = getComputedStyle(currentIFrame);
1023
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1024
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1025
+ x *= iframeScale.x;
1026
+ y *= iframeScale.y;
1027
+ width *= iframeScale.x;
1028
+ height *= iframeScale.y;
1029
+ x += left;
1030
+ y += top;
1031
+ currentIFrame = getWindow(currentIFrame).frameElement;
1032
+ }
1033
+ }
1034
+ return rectToClientRect({
1035
+ width,
1036
+ height,
1037
+ x,
1038
+ y
1039
+ });
1040
+ }
1041
+
1042
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1043
+ let {
1044
+ rect,
1045
+ offsetParent,
1046
+ strategy
1047
+ } = _ref;
1048
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1049
+ const documentElement = getDocumentElement(offsetParent);
1050
+ if (offsetParent === documentElement) {
1051
+ return rect;
1052
+ }
1053
+ let scroll = {
1054
+ scrollLeft: 0,
1055
+ scrollTop: 0
1056
+ };
1057
+ let scale = createCoords(1);
1058
+ const offsets = createCoords(0);
1059
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1060
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1061
+ scroll = getNodeScroll(offsetParent);
1062
+ }
1063
+ if (isHTMLElement(offsetParent)) {
1064
+ const offsetRect = getBoundingClientRect(offsetParent);
1065
+ scale = getScale(offsetParent);
1066
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1067
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1068
+ }
1069
+ }
1070
+ return {
1071
+ width: rect.width * scale.x,
1072
+ height: rect.height * scale.y,
1073
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
1074
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
1075
+ };
1076
+ }
1077
+
1078
+ function getClientRects(element) {
1079
+ return Array.from(element.getClientRects());
1080
+ }
1081
+
1082
+ function getWindowScrollBarX(element) {
1083
+ // If <html> has a CSS width greater than the viewport, then this will be
1084
+ // incorrect for RTL.
1085
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
1086
+ }
1087
+
1088
+ // Gets the entire size of the scrollable document area, even extending outside
1089
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1090
+ function getDocumentRect(element) {
1091
+ const html = getDocumentElement(element);
1092
+ const scroll = getNodeScroll(element);
1093
+ const body = element.ownerDocument.body;
1094
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1095
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1096
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1097
+ const y = -scroll.scrollTop;
1098
+ if (getComputedStyle(body).direction === 'rtl') {
1099
+ x += max(html.clientWidth, body.clientWidth) - width;
1100
+ }
1101
+ return {
1102
+ width,
1103
+ height,
1104
+ x,
1105
+ y
1106
+ };
1107
+ }
1108
+
1109
+ function getViewportRect(element, strategy) {
1110
+ const win = getWindow(element);
1111
+ const html = getDocumentElement(element);
1112
+ const visualViewport = win.visualViewport;
1113
+ let width = html.clientWidth;
1114
+ let height = html.clientHeight;
1115
+ let x = 0;
1116
+ let y = 0;
1117
+ if (visualViewport) {
1118
+ width = visualViewport.width;
1119
+ height = visualViewport.height;
1120
+ const visualViewportBased = isWebKit();
1121
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1122
+ x = visualViewport.offsetLeft;
1123
+ y = visualViewport.offsetTop;
1124
+ }
1125
+ }
1126
+ return {
1127
+ width,
1128
+ height,
1129
+ x,
1130
+ y
1131
+ };
1132
+ }
1133
+
1134
+ // Returns the inner client rect, subtracting scrollbars if present.
1135
+ function getInnerBoundingClientRect(element, strategy) {
1136
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1137
+ const top = clientRect.top + element.clientTop;
1138
+ const left = clientRect.left + element.clientLeft;
1139
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1140
+ const width = element.clientWidth * scale.x;
1141
+ const height = element.clientHeight * scale.y;
1142
+ const x = left * scale.x;
1143
+ const y = top * scale.y;
1144
+ return {
1145
+ width,
1146
+ height,
1147
+ x,
1148
+ y
1149
+ };
1150
+ }
1151
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1152
+ let rect;
1153
+ if (clippingAncestor === 'viewport') {
1154
+ rect = getViewportRect(element, strategy);
1155
+ } else if (clippingAncestor === 'document') {
1156
+ rect = getDocumentRect(getDocumentElement(element));
1157
+ } else if (isElement(clippingAncestor)) {
1158
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1159
+ } else {
1160
+ const visualOffsets = getVisualOffsets(element);
1161
+ rect = {
1162
+ ...clippingAncestor,
1163
+ x: clippingAncestor.x - visualOffsets.x,
1164
+ y: clippingAncestor.y - visualOffsets.y
1165
+ };
1166
+ }
1167
+ return rectToClientRect(rect);
1168
+ }
1169
+ function hasFixedPositionAncestor(element, stopNode) {
1170
+ const parentNode = getParentNode(element);
1171
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1172
+ return false;
1173
+ }
1174
+ return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1175
+ }
1176
+
1177
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
1178
+ // clipping (or hiding) child elements. This returns all clipping ancestors
1179
+ // of the given element up the tree.
1180
+ function getClippingElementAncestors(element, cache) {
1181
+ const cachedResult = cache.get(element);
1182
+ if (cachedResult) {
1183
+ return cachedResult;
1184
+ }
1185
+ let result = getOverflowAncestors(element).filter(el => isElement(el) && getNodeName(el) !== 'body');
1186
+ let currentContainingBlockComputedStyle = null;
1187
+ const elementIsFixed = getComputedStyle(element).position === 'fixed';
1188
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1189
+
1190
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1191
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1192
+ const computedStyle = getComputedStyle(currentNode);
1193
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1194
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1195
+ currentContainingBlockComputedStyle = null;
1196
+ }
1197
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1198
+ if (shouldDropCurrentNode) {
1199
+ // Drop non-containing blocks.
1200
+ result = result.filter(ancestor => ancestor !== currentNode);
1201
+ } else {
1202
+ // Record last containing block for next iteration.
1203
+ currentContainingBlockComputedStyle = computedStyle;
1204
+ }
1205
+ currentNode = getParentNode(currentNode);
1206
+ }
1207
+ cache.set(element, result);
1208
+ return result;
1209
+ }
1210
+
1211
+ // Gets the maximum area that the element is visible in due to any number of
1212
+ // clipping ancestors.
1213
+ function getClippingRect(_ref) {
1214
+ let {
1215
+ element,
1216
+ boundary,
1217
+ rootBoundary,
1218
+ strategy
1219
+ } = _ref;
1220
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
1221
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1222
+ const firstClippingAncestor = clippingAncestors[0];
1223
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1224
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1225
+ accRect.top = max(rect.top, accRect.top);
1226
+ accRect.right = min(rect.right, accRect.right);
1227
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1228
+ accRect.left = max(rect.left, accRect.left);
1229
+ return accRect;
1230
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1231
+ return {
1232
+ width: clippingRect.right - clippingRect.left,
1233
+ height: clippingRect.bottom - clippingRect.top,
1234
+ x: clippingRect.left,
1235
+ y: clippingRect.top
1236
+ };
1237
+ }
1238
+
1239
+ function getDimensions(element) {
1240
+ return getCssDimensions(element);
1241
+ }
1242
+
1243
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1244
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1245
+ const documentElement = getDocumentElement(offsetParent);
1246
+ const isFixed = strategy === 'fixed';
1247
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1248
+ let scroll = {
1249
+ scrollLeft: 0,
1250
+ scrollTop: 0
1251
+ };
1252
+ const offsets = createCoords(0);
1253
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1254
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1255
+ scroll = getNodeScroll(offsetParent);
1256
+ }
1257
+ if (isOffsetParentAnElement) {
1258
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1259
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1260
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1261
+ } else if (documentElement) {
1262
+ offsets.x = getWindowScrollBarX(documentElement);
1263
+ }
1264
+ }
1265
+ return {
1266
+ x: rect.left + scroll.scrollLeft - offsets.x,
1267
+ y: rect.top + scroll.scrollTop - offsets.y,
1268
+ width: rect.width,
1269
+ height: rect.height
1270
+ };
1271
+ }
1272
+
1273
+ function getTrueOffsetParent(element, polyfill) {
1274
+ if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1275
+ return null;
1276
+ }
1277
+ if (polyfill) {
1278
+ return polyfill(element);
1279
+ }
1280
+ return element.offsetParent;
1281
+ }
1282
+
1283
+ // Gets the closest ancestor positioned element. Handles some edge cases,
1284
+ // such as table ancestors and cross browser bugs.
1285
+ function getOffsetParent(element, polyfill) {
1286
+ const window = getWindow(element);
1287
+ if (!isHTMLElement(element)) {
1288
+ return window;
1289
+ }
1290
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1291
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
1292
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1293
+ }
1294
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1295
+ return window;
1296
+ }
1297
+ return offsetParent || getContainingBlock(element) || window;
1298
+ }
1299
+
1300
+ const getElementRects = async function (_ref) {
1301
+ let {
1302
+ reference,
1303
+ floating,
1304
+ strategy
1305
+ } = _ref;
1306
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1307
+ const getDimensionsFn = this.getDimensions;
1308
+ return {
1309
+ reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
1310
+ floating: {
1311
+ x: 0,
1312
+ y: 0,
1313
+ ...(await getDimensionsFn(floating))
1314
+ }
1315
+ };
1316
+ };
1317
+
1318
+ function isRTL(element) {
1319
+ return getComputedStyle(element).direction === 'rtl';
1320
+ }
1321
+
1322
+ const platform = {
1323
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1324
+ getDocumentElement,
1325
+ getClippingRect,
1326
+ getOffsetParent,
1327
+ getElementRects,
1328
+ getClientRects,
1329
+ getDimensions,
1330
+ getScale,
1331
+ isElement,
1332
+ isRTL
1333
+ };
1334
+
1335
+ // https://samthor.au/2021/observing-dom/
1336
+ function observeMove(element, onMove) {
1337
+ let io = null;
1338
+ let timeoutId;
1339
+ const root = getDocumentElement(element);
1340
+ function cleanup() {
1341
+ clearTimeout(timeoutId);
1342
+ io && io.disconnect();
1343
+ io = null;
1344
+ }
1345
+ function refresh(skip, threshold) {
1346
+ if (skip === void 0) {
1347
+ skip = false;
1348
+ }
1349
+ if (threshold === void 0) {
1350
+ threshold = 1;
1351
+ }
1352
+ cleanup();
1353
+ const {
1354
+ left,
1355
+ top,
1356
+ width,
1357
+ height
1358
+ } = element.getBoundingClientRect();
1359
+ if (!skip) {
1360
+ onMove();
1361
+ }
1362
+ if (!width || !height) {
1363
+ return;
1364
+ }
1365
+ const insetTop = floor(top);
1366
+ const insetRight = floor(root.clientWidth - (left + width));
1367
+ const insetBottom = floor(root.clientHeight - (top + height));
1368
+ const insetLeft = floor(left);
1369
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
1370
+ const options = {
1371
+ rootMargin,
1372
+ threshold: max(0, min(1, threshold)) || 1
1373
+ };
1374
+ let isFirstUpdate = true;
1375
+ function handleObserve(entries) {
1376
+ const ratio = entries[0].intersectionRatio;
1377
+ if (ratio !== threshold) {
1378
+ if (!isFirstUpdate) {
1379
+ return refresh();
1380
+ }
1381
+ if (!ratio) {
1382
+ timeoutId = setTimeout(() => {
1383
+ refresh(false, 1e-7);
1384
+ }, 100);
1385
+ } else {
1386
+ refresh(false, ratio);
1387
+ }
1388
+ }
1389
+ isFirstUpdate = false;
1390
+ }
1391
+
1392
+ // Older browsers don't support a `document` as the root and will throw an
1393
+ // error.
1394
+ try {
1395
+ io = new IntersectionObserver(handleObserve, {
1396
+ ...options,
1397
+ // Handle <iframe>s
1398
+ root: root.ownerDocument
1399
+ });
1400
+ } catch (e) {
1401
+ io = new IntersectionObserver(handleObserve, options);
1402
+ }
1403
+ io.observe(element);
1404
+ }
1405
+ refresh(true);
1406
+ return cleanup;
1407
+ }
1408
+
1409
+ /**
1410
+ * Automatically updates the position of the floating element when necessary.
1411
+ * Should only be called when the floating element is mounted on the DOM or
1412
+ * visible on the screen.
1413
+ * @returns cleanup function that should be invoked when the floating element is
1414
+ * removed from the DOM or hidden from the screen.
1415
+ * @see https://floating-ui.com/docs/autoUpdate
1416
+ */
1417
+ function autoUpdate(reference, floating, update, options) {
1418
+ if (options === void 0) {
1419
+ options = {};
1420
+ }
1421
+ const {
1422
+ ancestorScroll = true,
1423
+ ancestorResize = true,
1424
+ elementResize = typeof ResizeObserver === 'function',
1425
+ layoutShift = typeof IntersectionObserver === 'function',
1426
+ animationFrame = false
1427
+ } = options;
1428
+ const referenceEl = unwrapElement(reference);
1429
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
1430
+ ancestors.forEach(ancestor => {
1431
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1432
+ passive: true
1433
+ });
1434
+ ancestorResize && ancestor.addEventListener('resize', update);
1435
+ });
1436
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
1437
+ let reobserveFrame = -1;
1438
+ let resizeObserver = null;
1439
+ if (elementResize) {
1440
+ resizeObserver = new ResizeObserver(_ref => {
1441
+ let [firstEntry] = _ref;
1442
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
1443
+ // Prevent update loops when using the `size` middleware.
1444
+ // https://github.com/floating-ui/floating-ui/issues/1740
1445
+ resizeObserver.unobserve(floating);
1446
+ cancelAnimationFrame(reobserveFrame);
1447
+ reobserveFrame = requestAnimationFrame(() => {
1448
+ resizeObserver && resizeObserver.observe(floating);
1449
+ });
1450
+ }
1451
+ update();
1452
+ });
1453
+ if (referenceEl && !animationFrame) {
1454
+ resizeObserver.observe(referenceEl);
1455
+ }
1456
+ resizeObserver.observe(floating);
1457
+ }
1458
+ let frameId;
1459
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1460
+ if (animationFrame) {
1461
+ frameLoop();
1462
+ }
1463
+ function frameLoop() {
1464
+ const nextRefRect = getBoundingClientRect(reference);
1465
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1466
+ update();
1467
+ }
1468
+ prevRefRect = nextRefRect;
1469
+ frameId = requestAnimationFrame(frameLoop);
1470
+ }
1471
+ update();
1472
+ return () => {
1473
+ ancestors.forEach(ancestor => {
1474
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1475
+ ancestorResize && ancestor.removeEventListener('resize', update);
1476
+ });
1477
+ cleanupIo && cleanupIo();
1478
+ resizeObserver && resizeObserver.disconnect();
1479
+ resizeObserver = null;
1480
+ if (animationFrame) {
1481
+ cancelAnimationFrame(frameId);
1482
+ }
1483
+ };
1484
+ }
1485
+
1486
+ /**
1487
+ * Computes the `x` and `y` coordinates that will place the floating element
1488
+ * next to a reference element when it is given a certain CSS positioning
1489
+ * strategy.
1490
+ */
1491
+ const computePosition = (reference, floating, options) => {
1492
+ // This caches the expensive `getClippingElementAncestors` function so that
1493
+ // multiple lifecycle resets re-use the same result. It only lives for a
1494
+ // single call. If other functions become expensive, we can add them as well.
1495
+ const cache = new Map();
1496
+ const mergedOptions = {
1497
+ platform,
1498
+ ...options
1499
+ };
1500
+ const platformWithCache = {
1501
+ ...mergedOptions.platform,
1502
+ _c: cache
1503
+ };
1504
+ return computePosition$1(reference, floating, {
1505
+ ...mergedOptions,
1506
+ platform: platformWithCache
1507
+ });
1508
+ };
1509
+
1510
+ export { autoUpdate as a, arrow as b, computePosition as c, flip as f, inline as i, offset as o, shift as s };
1511
+
1512
+ //# sourceMappingURL=floating-ui.dom.esm.js.map