@vonage/vivid 4.13.0 → 4.14.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 (512) hide show
  1. package/custom-elements.json +3088 -1610
  2. package/elevation/index.cjs +1 -1
  3. package/elevation/index.js +1 -1
  4. package/index.cjs +70 -136
  5. package/index.d.ts +0 -1
  6. package/index.js +60 -62
  7. package/lib/accordion/accordion.d.ts +2 -2
  8. package/lib/accordion/accordion.template.d.ts +1 -2
  9. package/lib/accordion/definition.d.ts +1 -1
  10. package/lib/accordion-item/accordion-item.d.ts +2 -2
  11. package/lib/accordion-item/accordion-item.template.d.ts +2 -3
  12. package/lib/accordion-item/definition.d.ts +1 -1
  13. package/lib/action-group/action-group.d.ts +2 -2
  14. package/lib/action-group/action-group.template.d.ts +1 -3
  15. package/lib/action-group/definition.d.ts +1 -1
  16. package/lib/alert/alert.d.ts +2 -2
  17. package/lib/alert/alert.template.d.ts +2 -3
  18. package/lib/alert/definition.d.ts +1 -1
  19. package/lib/audio-player/audio-player.d.ts +2 -2
  20. package/lib/audio-player/audio-player.template.d.ts +2 -3
  21. package/lib/audio-player/definition.d.ts +1 -3
  22. package/lib/avatar/avatar.d.ts +2 -2
  23. package/lib/avatar/avatar.template.d.ts +2 -3
  24. package/lib/avatar/definition.d.ts +1 -1
  25. package/lib/badge/badge.d.ts +2 -2
  26. package/lib/badge/badge.template.d.ts +2 -3
  27. package/lib/badge/definition.d.ts +1 -3
  28. package/lib/banner/banner.d.ts +2 -2
  29. package/lib/banner/banner.template.d.ts +2 -3
  30. package/lib/banner/definition.d.ts +1 -1
  31. package/lib/breadcrumb/breadcrumb.d.ts +2 -2
  32. package/lib/breadcrumb/breadcrumb.template.d.ts +3 -4
  33. package/lib/breadcrumb/definition.d.ts +1 -1
  34. package/lib/breadcrumb-item/breadcrumb-item.d.ts +2 -2
  35. package/lib/breadcrumb-item/breadcrumb-item.template.d.ts +2 -3
  36. package/lib/breadcrumb-item/definition.d.ts +1 -1
  37. package/lib/button/button.d.ts +2 -2
  38. package/lib/button/button.template.d.ts +2 -4
  39. package/lib/button/definition.d.ts +1 -1
  40. package/lib/calendar/calendar.d.ts +2 -2
  41. package/lib/calendar/calendar.template.d.ts +1 -3
  42. package/lib/calendar/definition.d.ts +1 -1
  43. package/lib/calendar-event/calendar-event.d.ts +2 -2
  44. package/lib/calendar-event/calendar-event.template.d.ts +1 -3
  45. package/lib/calendar-event/definition.d.ts +1 -1
  46. package/lib/card/card.d.ts +2 -2
  47. package/lib/card/card.template.d.ts +2 -3
  48. package/lib/card/definition.d.ts +1 -1
  49. package/lib/checkbox/checkbox.form-associated.d.ts +3 -2
  50. package/lib/checkbox/checkbox.template.d.ts +2 -3
  51. package/lib/checkbox/definition.d.ts +1 -1
  52. package/lib/combobox/combobox.d.ts +17 -2
  53. package/lib/combobox/combobox.options.d.ts +7 -0
  54. package/lib/combobox/combobox.template.d.ts +2 -3
  55. package/lib/combobox/definition.d.ts +1 -2
  56. package/lib/data-grid/data-grid-cell.d.ts +16 -13
  57. package/lib/data-grid/data-grid-cell.template.d.ts +2 -3
  58. package/lib/data-grid/data-grid-row.d.ts +19 -2
  59. package/lib/data-grid/data-grid-row.template.d.ts +2 -2
  60. package/lib/data-grid/data-grid.d.ts +45 -4
  61. package/lib/data-grid/data-grid.template.d.ts +2 -2
  62. package/lib/data-grid/definition.d.ts +1 -6
  63. package/lib/date-picker/definition.d.ts +1 -3
  64. package/lib/date-range-picker/definition.d.ts +1 -3
  65. package/lib/dial-pad/definition.d.ts +1 -3
  66. package/lib/dial-pad/dial-pad.d.ts +2 -2
  67. package/lib/dial-pad/dial-pad.template.d.ts +2 -3
  68. package/lib/dialog/definition.d.ts +1 -1
  69. package/lib/dialog/dialog.d.ts +2 -2
  70. package/lib/dialog/dialog.template.d.ts +2 -3
  71. package/lib/divider/definition.d.ts +1 -1
  72. package/lib/divider/divider.d.ts +2 -2
  73. package/lib/divider/divider.template.d.ts +1 -3
  74. package/lib/elevation/definition.d.ts +1 -1
  75. package/lib/elevation/elevation.d.ts +3 -2
  76. package/lib/elevation/elevation.template.d.ts +1 -3
  77. package/lib/empty-state/definition.d.ts +1 -3
  78. package/lib/empty-state/empty-state.d.ts +2 -2
  79. package/lib/empty-state/empty-state.template.d.ts +2 -3
  80. package/lib/fab/definition.d.ts +1 -3
  81. package/lib/fab/fab.template.d.ts +2 -3
  82. package/lib/file-picker/definition.d.ts +1 -3
  83. package/lib/file-picker/file-picker.form-associated.d.ts +3 -2
  84. package/lib/file-picker/file-picker.template.d.ts +2 -3
  85. package/lib/header/definition.d.ts +1 -3
  86. package/lib/header/header.d.ts +2 -2
  87. package/lib/header/header.template.d.ts +2 -3
  88. package/lib/icon/definition.d.ts +1 -3
  89. package/lib/icon/icon.d.ts +2 -2
  90. package/lib/icon/icon.template.d.ts +1 -3
  91. package/lib/layout/definition.d.ts +1 -3
  92. package/lib/layout/layout.d.ts +2 -2
  93. package/lib/layout/layout.template.d.ts +1 -3
  94. package/lib/listbox/definition.d.ts +1 -3
  95. package/lib/listbox/listbox.template.d.ts +1 -3
  96. package/lib/menu/definition.d.ts +1 -11
  97. package/lib/menu/menu.d.ts +2 -2
  98. package/lib/menu/menu.template.d.ts +3 -3
  99. package/lib/menu-item/definition.d.ts +1 -3
  100. package/lib/menu-item/menu-item.d.ts +2 -2
  101. package/lib/menu-item/menu-item.template.d.ts +2 -3
  102. package/lib/nav/definition.d.ts +1 -3
  103. package/lib/nav/nav.d.ts +2 -2
  104. package/lib/nav/nav.template.d.ts +1 -3
  105. package/lib/nav-disclosure/definition.d.ts +1 -3
  106. package/lib/nav-disclosure/nav-disclosure.d.ts +2 -2
  107. package/lib/nav-disclosure/nav-disclosure.template.d.ts +2 -3
  108. package/lib/nav-item/definition.d.ts +1 -3
  109. package/lib/nav-item/nav-item.template.d.ts +2 -3
  110. package/lib/note/definition.d.ts +1 -3
  111. package/lib/note/note.d.ts +2 -2
  112. package/lib/note/note.template.d.ts +2 -3
  113. package/lib/number-field/definition.d.ts +1 -4
  114. package/lib/number-field/number-field.form-associated.d.ts +3 -2
  115. package/lib/number-field/number-field.template.d.ts +2 -3
  116. package/lib/option/definition.d.ts +1 -3
  117. package/lib/option/option.d.ts +3 -2
  118. package/lib/option/option.template.d.ts +2 -3
  119. package/lib/pagination/definition.d.ts +1 -3
  120. package/lib/pagination/pagination.d.ts +2 -2
  121. package/lib/pagination/pagination.template.d.ts +2 -3
  122. package/lib/popup/definition.d.ts +1 -3
  123. package/lib/popup/popup.template.d.ts +2 -3
  124. package/lib/progress/definition.d.ts +1 -3
  125. package/lib/progress/progress.d.ts +1 -1
  126. package/lib/progress/progress.template.d.ts +1 -4
  127. package/lib/progress-ring/definition.d.ts +1 -3
  128. package/lib/progress-ring/progress-ring.d.ts +1 -1
  129. package/lib/progress-ring/progress-ring.template.d.ts +1 -3
  130. package/lib/radio/definition.d.ts +1 -3
  131. package/lib/radio/radio.form-associated.d.ts +5 -2
  132. package/lib/radio/radio.template.d.ts +1 -3
  133. package/lib/radio-group/definition.d.ts +1 -11
  134. package/lib/radio-group/radio-group.d.ts +2 -2
  135. package/lib/radio-group/radio-group.template.d.ts +2 -3
  136. package/lib/range-slider/definition.d.ts +1 -3
  137. package/lib/range-slider/range-slider.form-associated.d.ts +3 -2
  138. package/lib/range-slider/range-slider.template.d.ts +2 -3
  139. package/lib/searchable-select/definition.d.ts +1 -4
  140. package/lib/searchable-select/option-tag.template.d.ts +2 -3
  141. package/lib/searchable-select/searchable-select.form-associated.d.ts +3 -2
  142. package/lib/searchable-select/searchable-select.template.d.ts +2 -3
  143. package/lib/select/definition.d.ts +1 -3
  144. package/lib/select/select.d.ts +14 -4
  145. package/lib/select/select.form-associated.d.ts +11 -0
  146. package/lib/select/select.template.d.ts +2 -3
  147. package/lib/selectable-box/definition.d.ts +1 -3
  148. package/lib/selectable-box/selectable-box.d.ts +2 -2
  149. package/lib/selectable-box/selectable-box.template.d.ts +2 -3
  150. package/lib/side-drawer/definition.d.ts +1 -3
  151. package/lib/side-drawer/side-drawer.d.ts +2 -2
  152. package/lib/side-drawer/side-drawer.template.d.ts +1 -3
  153. package/lib/slider/definition.d.ts +1 -3
  154. package/lib/slider/slider.form-associated.d.ts +3 -2
  155. package/lib/slider/slider.template.d.ts +3 -4
  156. package/lib/split-button/definition.d.ts +1 -1
  157. package/lib/split-button/split-button.d.ts +2 -2
  158. package/lib/split-button/split-button.template.d.ts +2 -3
  159. package/lib/switch/definition.d.ts +1 -3
  160. package/lib/switch/switch.form-associated.d.ts +3 -2
  161. package/lib/switch/switch.template.d.ts +1 -3
  162. package/lib/tab/definition.d.ts +1 -3
  163. package/lib/tab/tab.d.ts +2 -2
  164. package/lib/tab/tab.template.d.ts +2 -2
  165. package/lib/tab-panel/definition.d.ts +1 -3
  166. package/lib/tab-panel/tab-panel.d.ts +2 -2
  167. package/lib/tab-panel/tab-panel.template.d.ts +1 -1
  168. package/lib/tabs/definition.d.ts +1 -3
  169. package/lib/tabs/tabs.d.ts +3 -7
  170. package/lib/tabs/tabs.template.d.ts +1 -1
  171. package/lib/tag/definition.d.ts +1 -4
  172. package/lib/tag/tag.d.ts +2 -2
  173. package/lib/tag/tag.template.d.ts +2 -3
  174. package/lib/tag-group/definition.d.ts +1 -3
  175. package/lib/tag-group/tag-group.d.ts +2 -2
  176. package/lib/tag-group/tag-group.template.d.ts +1 -3
  177. package/lib/text-anchor/definition.d.ts +1 -3
  178. package/lib/text-anchor/text-anchor.d.ts +4 -3
  179. package/lib/text-anchor/text-anchor.template.d.ts +2 -3
  180. package/lib/text-area/definition.d.ts +1 -3
  181. package/lib/text-area/text-area.d.ts +1 -1
  182. package/lib/text-area/{text-field.form-associated.d.ts → text-area.form-associated.d.ts} +3 -2
  183. package/lib/text-area/text-area.template.d.ts +2 -3
  184. package/lib/text-field/definition.d.ts +1 -3
  185. package/lib/text-field/text-field.form-associated.d.ts +3 -2
  186. package/lib/text-field/text-field.template.d.ts +2 -3
  187. package/lib/time-picker/definition.d.ts +1 -3
  188. package/lib/time-picker/time-picker.form-associated.d.ts +3 -2
  189. package/lib/time-picker/time-picker.template.d.ts +2 -2
  190. package/lib/toggletip/definition.d.ts +1 -3
  191. package/lib/toggletip/toggletip.d.ts +2 -2
  192. package/lib/toggletip/toggletip.template.d.ts +2 -3
  193. package/lib/tooltip/definition.d.ts +1 -3
  194. package/lib/tooltip/tooltip.d.ts +2 -2
  195. package/lib/tooltip/tooltip.template.d.ts +2 -3
  196. package/lib/tree-item/definition.d.ts +1 -3
  197. package/lib/tree-item/tree-item.d.ts +11 -2
  198. package/lib/tree-item/tree-item.template.d.ts +3 -3
  199. package/lib/tree-view/definition.d.ts +1 -3
  200. package/lib/tree-view/tree-view.d.ts +16 -2
  201. package/lib/tree-view/tree-view.template.d.ts +1 -1
  202. package/lib/video-player/definition.d.ts +1 -3
  203. package/lib/video-player/video-player.d.ts +2 -2
  204. package/lib/video-player/video-player.template.d.ts +1 -3
  205. package/listbox/index.cjs +37 -39
  206. package/listbox/index.js +37 -39
  207. package/menu/index.cjs +1 -1
  208. package/menu/index.js +1 -1
  209. package/nav/index.cjs +1 -1
  210. package/nav/index.js +1 -1
  211. package/nav-disclosure/index.cjs +1 -1
  212. package/nav-disclosure/index.js +1 -1
  213. package/nav-item/index.cjs +1 -1
  214. package/nav-item/index.js +1 -1
  215. package/note/index.cjs +1 -1
  216. package/note/index.js +1 -1
  217. package/number-field/index.cjs +1 -1
  218. package/number-field/index.js +1 -1
  219. package/option/index.cjs +1 -1
  220. package/option/index.js +1 -1
  221. package/package.json +1 -1
  222. package/pagination/index.cjs +1 -1
  223. package/pagination/index.js +1 -1
  224. package/popup/index.cjs +1 -1
  225. package/popup/index.js +1 -1
  226. package/progress/index.cjs +1 -1
  227. package/progress/index.js +1 -1
  228. package/progress-ring/index.cjs +1 -1
  229. package/progress-ring/index.js +1 -1
  230. package/radio/index.cjs +1 -1
  231. package/radio/index.js +1 -1
  232. package/radio-group/index.cjs +1 -1
  233. package/radio-group/index.js +1 -1
  234. package/range-slider/index.cjs +1 -1
  235. package/range-slider/index.js +1 -1
  236. package/searchable-select/index.cjs +1 -1
  237. package/searchable-select/index.js +1 -1
  238. package/select/index.cjs +1 -1
  239. package/select/index.js +1 -1
  240. package/selectable-box/index.cjs +1 -1
  241. package/selectable-box/index.js +1 -1
  242. package/shared/affix.cjs +10 -10
  243. package/shared/affix.js +2 -2
  244. package/shared/anchor.cjs +59 -0
  245. package/shared/anchor.js +57 -0
  246. package/shared/anchored.cjs +6 -6
  247. package/shared/anchored.js +2 -2
  248. package/shared/apply-mixins.cjs +15 -17
  249. package/shared/apply-mixins.js +15 -17
  250. package/shared/apply-mixins2.cjs +25 -0
  251. package/shared/apply-mixins2.js +23 -0
  252. package/shared/applyMixinsWithObservables.cjs +4 -4
  253. package/shared/applyMixinsWithObservables.js +2 -2
  254. package/shared/aria-global.cjs +86 -67
  255. package/shared/aria-global.js +86 -67
  256. package/shared/aria-global2.cjs +68 -86
  257. package/shared/aria-global2.js +68 -86
  258. package/shared/base-progress.cjs +69 -63
  259. package/shared/base-progress.js +69 -63
  260. package/shared/breadcrumb-item.cjs +6 -58
  261. package/shared/breadcrumb-item.js +3 -55
  262. package/shared/button.cjs +177 -0
  263. package/shared/button.js +175 -0
  264. package/shared/calendar-event.cjs +9 -9
  265. package/shared/calendar-event.js +2 -2
  266. package/shared/children.cjs +2 -2
  267. package/shared/children.js +1 -1
  268. package/shared/date-picker/date-picker-base.form-associated.d.ts +3 -2
  269. package/shared/date-picker/date-picker-base.template.d.ts +2 -3
  270. package/shared/definition.cjs +25 -24
  271. package/shared/definition.js +16 -14
  272. package/shared/definition10.cjs +14 -12
  273. package/shared/definition10.js +14 -11
  274. package/shared/definition11.cjs +52 -248
  275. package/shared/definition11.js +24 -218
  276. package/shared/definition12.cjs +18 -14
  277. package/shared/definition12.js +17 -12
  278. package/shared/definition13.cjs +19 -19
  279. package/shared/definition13.js +10 -9
  280. package/shared/definition14.cjs +35 -38
  281. package/shared/definition14.js +15 -17
  282. package/shared/definition15.cjs +27 -26
  283. package/shared/definition15.js +16 -14
  284. package/shared/definition16.cjs +480 -612
  285. package/shared/definition16.js +473 -604
  286. package/shared/definition17.cjs +933 -1113
  287. package/shared/definition17.js +911 -1090
  288. package/shared/definition18.cjs +16 -20
  289. package/shared/definition18.js +19 -22
  290. package/shared/definition19.cjs +26 -30
  291. package/shared/definition19.js +21 -24
  292. package/shared/definition2.cjs +19 -22
  293. package/shared/definition2.js +20 -22
  294. package/shared/definition20.cjs +50 -52
  295. package/shared/definition20.js +34 -35
  296. package/shared/definition21.cjs +43 -47
  297. package/shared/definition21.js +19 -22
  298. package/shared/definition22.cjs +15 -13
  299. package/shared/definition22.js +14 -11
  300. package/shared/definition23.cjs +21 -20
  301. package/shared/definition23.js +14 -12
  302. package/shared/definition24.cjs +21 -173
  303. package/shared/definition24.js +18 -169
  304. package/shared/definition25.cjs +26 -28
  305. package/shared/definition25.js +18 -19
  306. package/shared/definition26.cjs +16 -14
  307. package/shared/definition26.js +14 -11
  308. package/shared/definition27.cjs +264 -12
  309. package/shared/definition27.js +261 -10
  310. package/shared/definition28.cjs +19 -17
  311. package/shared/definition28.js +15 -12
  312. package/shared/definition29.cjs +142 -68
  313. package/shared/definition29.js +101 -29
  314. package/shared/definition3.cjs +20 -16
  315. package/shared/definition3.js +16 -11
  316. package/shared/definition30.cjs +98 -76
  317. package/shared/definition30.js +97 -74
  318. package/shared/definition31.cjs +24 -97
  319. package/shared/definition31.js +25 -97
  320. package/shared/definition32.cjs +9 -25
  321. package/shared/definition32.js +8 -23
  322. package/shared/definition33.cjs +52 -14
  323. package/shared/definition33.js +51 -12
  324. package/shared/definition34.cjs +639 -34
  325. package/shared/definition34.js +636 -30
  326. package/shared/definition35.cjs +203 -596
  327. package/shared/definition35.js +197 -591
  328. package/shared/definition36.cjs +197 -233
  329. package/shared/definition36.js +192 -226
  330. package/shared/definition37.cjs +79 -206
  331. package/shared/definition37.js +75 -202
  332. package/shared/definition38.cjs +50 -56
  333. package/shared/definition38.js +48 -52
  334. package/shared/definition39.cjs +259 -56
  335. package/shared/definition39.js +258 -54
  336. package/shared/definition4.cjs +32 -35
  337. package/shared/definition4.js +19 -21
  338. package/shared/definition40.cjs +156 -225
  339. package/shared/definition40.js +152 -221
  340. package/shared/definition41.cjs +626 -36
  341. package/shared/definition41.js +625 -34
  342. package/shared/definition42.cjs +974 -487
  343. package/shared/definition42.js +971 -482
  344. package/shared/definition43.cjs +725 -932
  345. package/shared/definition43.js +713 -918
  346. package/shared/definition44.cjs +115 -734
  347. package/shared/definition44.js +113 -731
  348. package/shared/definition45.cjs +92 -116
  349. package/shared/definition45.js +92 -115
  350. package/shared/definition46.cjs +468 -89
  351. package/shared/definition46.js +465 -86
  352. package/shared/definition47.cjs +118 -470
  353. package/shared/definition47.js +115 -465
  354. package/shared/definition48.cjs +113 -120
  355. package/shared/definition48.js +111 -117
  356. package/shared/definition49.cjs +16 -134
  357. package/shared/definition49.js +15 -132
  358. package/shared/definition5.cjs +47 -49
  359. package/shared/definition5.js +18 -19
  360. package/shared/definition50.cjs +111 -15
  361. package/shared/definition50.js +109 -12
  362. package/shared/definition51.cjs +862 -84
  363. package/shared/definition51.js +858 -79
  364. package/shared/definition52.cjs +30 -873
  365. package/shared/definition52.js +28 -870
  366. package/shared/definition53.cjs +125 -28
  367. package/shared/definition53.js +123 -25
  368. package/shared/definition54.cjs +267 -107
  369. package/shared/definition54.js +261 -100
  370. package/shared/definition55.cjs +63 -278
  371. package/shared/definition55.js +61 -275
  372. package/shared/definition56.cjs +867 -76
  373. package/shared/definition56.js +866 -74
  374. package/shared/definition57.cjs +107 -826
  375. package/shared/definition57.js +105 -823
  376. package/shared/definition58.cjs +73 -100
  377. package/shared/definition58.js +69 -95
  378. package/shared/definition59.cjs +180 -106
  379. package/shared/definition59.js +174 -101
  380. package/shared/definition6.cjs +22 -21
  381. package/shared/definition6.js +14 -12
  382. package/shared/definition60.cjs +272 -70
  383. package/shared/definition60.js +272 -69
  384. package/shared/definition61.cjs +66154 -271
  385. package/shared/definition61.js +66153 -269
  386. package/shared/definition62.cjs +38 -66173
  387. package/shared/definition62.js +35 -66170
  388. package/shared/definition63.cjs +2153 -27
  389. package/shared/definition63.js +2150 -25
  390. package/shared/definition7.cjs +18 -15
  391. package/shared/definition7.js +13 -10
  392. package/shared/definition8.cjs +25 -27
  393. package/shared/definition8.js +16 -17
  394. package/shared/definition9.cjs +21 -21
  395. package/shared/definition9.js +18 -17
  396. package/shared/design-system/createRegisterFunction.d.ts +2 -0
  397. package/shared/design-system/defineVividComponent.d.ts +15 -0
  398. package/shared/{localization.js → direction.js} +11 -11
  399. package/shared/dom.cjs +0 -13
  400. package/shared/dom.js +1 -13
  401. package/shared/form-associated.cjs +422 -457
  402. package/shared/form-associated.js +422 -457
  403. package/shared/form-associated2.cjs +383 -0
  404. package/shared/form-associated2.js +381 -0
  405. package/shared/form-elements.cjs +15 -42
  406. package/shared/form-elements.js +2 -29
  407. package/shared/foundation/anchor/anchor.d.ts +1 -0
  408. package/shared/foundation/button/button.d.ts +3 -2
  409. package/shared/foundation/button/button.template.d.ts +2 -4
  410. package/shared/foundation/form-associated/form-associated.d.ts +51 -0
  411. package/shared/foundation/listbox/listbox.d.ts +22 -0
  412. package/shared/foundation/progress/base-progress.d.ts +9 -0
  413. package/shared/foundation/utilities/apply-mixins.d.ts +1 -0
  414. package/shared/foundation/vivid-element/vivid-element.d.ts +3 -0
  415. package/shared/index.cjs +7 -5097
  416. package/shared/index.js +7 -5079
  417. package/shared/key-codes.cjs +10 -0
  418. package/shared/key-codes.js +6 -1
  419. package/shared/key-codes2.cjs +1463 -6
  420. package/shared/key-codes2.js +1461 -4
  421. package/shared/listbox.cjs +427 -1195
  422. package/shared/listbox.js +411 -1176
  423. package/shared/listbox2.cjs +1267 -0
  424. package/shared/listbox2.js +1264 -0
  425. package/shared/localized.cjs +2 -2
  426. package/shared/localized.js +1 -1
  427. package/shared/numbers.cjs +12 -0
  428. package/shared/numbers.js +12 -1
  429. package/shared/patterns/affix.d.ts +2 -2
  430. package/shared/patterns/chevron.d.ts +2 -2
  431. package/shared/patterns/form-elements/form-elements.d.ts +2 -2
  432. package/shared/presentationDate.cjs +49 -49
  433. package/shared/presentationDate.js +6 -6
  434. package/shared/ref.cjs +2 -2
  435. package/shared/ref.js +1 -1
  436. package/shared/repeat.cjs +22 -22
  437. package/shared/repeat.js +1 -1
  438. package/shared/slider.template.cjs +5 -5
  439. package/shared/slider.template.js +2 -2
  440. package/shared/slotted.cjs +4 -4
  441. package/shared/slotted.js +1 -1
  442. package/shared/strings.cjs +0 -26
  443. package/shared/strings.js +1 -25
  444. package/shared/strings2.cjs +37 -0
  445. package/shared/strings2.js +33 -0
  446. package/shared/text-anchor.cjs +7 -89
  447. package/shared/text-anchor.js +4 -86
  448. package/shared/text-anchor.template.cjs +2 -2
  449. package/shared/text-anchor.template.js +1 -1
  450. package/shared/text-field2.cjs +28 -28
  451. package/shared/text-field2.js +5 -5
  452. package/shared/vivid-element.cjs +2616 -0
  453. package/shared/vivid-element.js +2595 -0
  454. package/side-drawer/index.cjs +1 -1
  455. package/side-drawer/index.js +1 -1
  456. package/slider/index.cjs +1 -1
  457. package/slider/index.js +1 -1
  458. package/split-button/index.cjs +1 -1
  459. package/split-button/index.js +1 -1
  460. package/styles/core/all.css +40 -1
  461. package/styles/core/theme.css +40 -1
  462. package/styles/core/typography.css +1 -1
  463. package/styles/tokens/theme-dark.css +25 -4
  464. package/styles/tokens/theme-light.css +25 -4
  465. package/styles/tokens/vivid-2-compat.css +1 -1
  466. package/switch/index.cjs +1 -1
  467. package/switch/index.js +1 -1
  468. package/tab/index.cjs +1 -1
  469. package/tab/index.js +1 -1
  470. package/tab-panel/index.cjs +1 -1
  471. package/tab-panel/index.js +1 -1
  472. package/tabs/index.cjs +1 -1
  473. package/tabs/index.js +1 -1
  474. package/tag/index.cjs +1 -1
  475. package/tag/index.js +1 -1
  476. package/tag-group/index.cjs +1 -1
  477. package/tag-group/index.js +1 -1
  478. package/text-anchor/index.cjs +10 -7
  479. package/text-anchor/index.js +10 -7
  480. package/text-area/index.cjs +1 -1
  481. package/text-area/index.js +1 -1
  482. package/text-field/index.cjs +1 -1
  483. package/text-field/index.js +1 -1
  484. package/time-picker/index.cjs +1 -1
  485. package/time-picker/index.js +1 -1
  486. package/toggletip/index.cjs +1 -1
  487. package/toggletip/index.js +1 -1
  488. package/tooltip/index.cjs +1 -1
  489. package/tooltip/index.js +1 -1
  490. package/tree-item/index.cjs +1 -1
  491. package/tree-item/index.js +1 -1
  492. package/tree-view/index.cjs +1 -1
  493. package/tree-view/index.js +1 -1
  494. package/video-player/index.cjs +1 -1
  495. package/video-player/index.js +1 -1
  496. package/vivid.api.json +2846 -7860
  497. package/shared/definition64.cjs +0 -2175
  498. package/shared/definition64.js +0 -2170
  499. package/shared/design-system/index.d.ts +0 -3
  500. package/shared/icon.cjs +0 -261
  501. package/shared/icon.js +0 -258
  502. package/shared/index2.cjs +0 -11
  503. package/shared/index2.js +0 -9
  504. package/shared/radio.cjs +0 -126
  505. package/shared/radio.js +0 -124
  506. package/shared/select.options.cjs +0 -12
  507. package/shared/select.options.js +0 -10
  508. package/shared/start-end.cjs +0 -52
  509. package/shared/start-end.js +0 -50
  510. package/shared/tree-item.cjs +0 -154
  511. package/shared/tree-item.js +0 -151
  512. package/shared/{localization.cjs → direction.cjs} +9 -9
@@ -1,8 +1,1901 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./index.cjs');
3
+ const definition$1 = require('./definition11.cjs');
4
+ const definition = require('./definition62.cjs');
5
+ const vividElement = require('./vivid-element.cjs');
6
+ const ref = require('./ref.cjs');
7
+ const when = require('./when.cjs');
4
8
  const classNames = require('./class-names.cjs');
5
9
 
10
+ /**
11
+ * Custom positioning reference element.
12
+ * @see https://floating-ui.com/docs/virtual-elements
13
+ */
14
+
15
+ const sides = ['top', 'right', 'bottom', 'left'];
16
+ const alignments = ['start', 'end'];
17
+ const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
18
+ const min = Math.min;
19
+ const max = Math.max;
20
+ const round = Math.round;
21
+ const floor = Math.floor;
22
+ const createCoords = v => ({
23
+ x: v,
24
+ y: v
25
+ });
26
+ const oppositeSideMap = {
27
+ left: 'right',
28
+ right: 'left',
29
+ bottom: 'top',
30
+ top: 'bottom'
31
+ };
32
+ const oppositeAlignmentMap = {
33
+ start: 'end',
34
+ end: 'start'
35
+ };
36
+ function clamp(start, value, end) {
37
+ return max(start, min(value, end));
38
+ }
39
+ function evaluate(value, param) {
40
+ return typeof value === 'function' ? value(param) : value;
41
+ }
42
+ function getSide(placement) {
43
+ return placement.split('-')[0];
44
+ }
45
+ function getAlignment(placement) {
46
+ return placement.split('-')[1];
47
+ }
48
+ function getOppositeAxis(axis) {
49
+ return axis === 'x' ? 'y' : 'x';
50
+ }
51
+ function getAxisLength(axis) {
52
+ return axis === 'y' ? 'height' : 'width';
53
+ }
54
+ function getSideAxis(placement) {
55
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
56
+ }
57
+ function getAlignmentAxis(placement) {
58
+ return getOppositeAxis(getSideAxis(placement));
59
+ }
60
+ function getAlignmentSides(placement, rects, rtl) {
61
+ if (rtl === void 0) {
62
+ rtl = false;
63
+ }
64
+ const alignment = getAlignment(placement);
65
+ const alignmentAxis = getAlignmentAxis(placement);
66
+ const length = getAxisLength(alignmentAxis);
67
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
68
+ if (rects.reference[length] > rects.floating[length]) {
69
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
70
+ }
71
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
72
+ }
73
+ function getExpandedPlacements(placement) {
74
+ const oppositePlacement = getOppositePlacement(placement);
75
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
76
+ }
77
+ function getOppositeAlignmentPlacement(placement) {
78
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
79
+ }
80
+ function getSideList(side, isStart, rtl) {
81
+ const lr = ['left', 'right'];
82
+ const rl = ['right', 'left'];
83
+ const tb = ['top', 'bottom'];
84
+ const bt = ['bottom', 'top'];
85
+ switch (side) {
86
+ case 'top':
87
+ case 'bottom':
88
+ if (rtl) return isStart ? rl : lr;
89
+ return isStart ? lr : rl;
90
+ case 'left':
91
+ case 'right':
92
+ return isStart ? tb : bt;
93
+ default:
94
+ return [];
95
+ }
96
+ }
97
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
98
+ const alignment = getAlignment(placement);
99
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
100
+ if (alignment) {
101
+ list = list.map(side => side + "-" + alignment);
102
+ if (flipAlignment) {
103
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
104
+ }
105
+ }
106
+ return list;
107
+ }
108
+ function getOppositePlacement(placement) {
109
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
110
+ }
111
+ function expandPaddingObject(padding) {
112
+ return {
113
+ top: 0,
114
+ right: 0,
115
+ bottom: 0,
116
+ left: 0,
117
+ ...padding
118
+ };
119
+ }
120
+ function getPaddingObject(padding) {
121
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
122
+ top: padding,
123
+ right: padding,
124
+ bottom: padding,
125
+ left: padding
126
+ };
127
+ }
128
+ function rectToClientRect(rect) {
129
+ const {
130
+ x,
131
+ y,
132
+ width,
133
+ height
134
+ } = rect;
135
+ return {
136
+ width,
137
+ height,
138
+ top: y,
139
+ left: x,
140
+ right: x + width,
141
+ bottom: y + height,
142
+ x,
143
+ y
144
+ };
145
+ }
146
+
147
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
148
+ let {
149
+ reference,
150
+ floating
151
+ } = _ref;
152
+ const sideAxis = getSideAxis(placement);
153
+ const alignmentAxis = getAlignmentAxis(placement);
154
+ const alignLength = getAxisLength(alignmentAxis);
155
+ const side = getSide(placement);
156
+ const isVertical = sideAxis === 'y';
157
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
158
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
159
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
160
+ let coords;
161
+ switch (side) {
162
+ case 'top':
163
+ coords = {
164
+ x: commonX,
165
+ y: reference.y - floating.height
166
+ };
167
+ break;
168
+ case 'bottom':
169
+ coords = {
170
+ x: commonX,
171
+ y: reference.y + reference.height
172
+ };
173
+ break;
174
+ case 'right':
175
+ coords = {
176
+ x: reference.x + reference.width,
177
+ y: commonY
178
+ };
179
+ break;
180
+ case 'left':
181
+ coords = {
182
+ x: reference.x - floating.width,
183
+ y: commonY
184
+ };
185
+ break;
186
+ default:
187
+ coords = {
188
+ x: reference.x,
189
+ y: reference.y
190
+ };
191
+ }
192
+ switch (getAlignment(placement)) {
193
+ case 'start':
194
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
195
+ break;
196
+ case 'end':
197
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
198
+ break;
199
+ }
200
+ return coords;
201
+ }
202
+
203
+ /**
204
+ * Computes the `x` and `y` coordinates that will place the floating element
205
+ * next to a given reference element.
206
+ *
207
+ * This export does not have any `platform` interface logic. You will need to
208
+ * write one for the platform you are using Floating UI with.
209
+ */
210
+ const computePosition$1 = async (reference, floating, config) => {
211
+ const {
212
+ placement = 'bottom',
213
+ strategy = 'absolute',
214
+ middleware = [],
215
+ platform
216
+ } = config;
217
+ const validMiddleware = middleware.filter(Boolean);
218
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
219
+ let rects = await platform.getElementRects({
220
+ reference,
221
+ floating,
222
+ strategy
223
+ });
224
+ let {
225
+ x,
226
+ y
227
+ } = computeCoordsFromPlacement(rects, placement, rtl);
228
+ let statefulPlacement = placement;
229
+ let middlewareData = {};
230
+ let resetCount = 0;
231
+ for (let i = 0; i < validMiddleware.length; i++) {
232
+ const {
233
+ name,
234
+ fn
235
+ } = validMiddleware[i];
236
+ const {
237
+ x: nextX,
238
+ y: nextY,
239
+ data,
240
+ reset
241
+ } = await fn({
242
+ x,
243
+ y,
244
+ initialPlacement: placement,
245
+ placement: statefulPlacement,
246
+ strategy,
247
+ middlewareData,
248
+ rects,
249
+ platform,
250
+ elements: {
251
+ reference,
252
+ floating
253
+ }
254
+ });
255
+ x = nextX != null ? nextX : x;
256
+ y = nextY != null ? nextY : y;
257
+ middlewareData = {
258
+ ...middlewareData,
259
+ [name]: {
260
+ ...middlewareData[name],
261
+ ...data
262
+ }
263
+ };
264
+ if (reset && resetCount <= 50) {
265
+ resetCount++;
266
+ if (typeof reset === 'object') {
267
+ if (reset.placement) {
268
+ statefulPlacement = reset.placement;
269
+ }
270
+ if (reset.rects) {
271
+ rects = reset.rects === true ? await platform.getElementRects({
272
+ reference,
273
+ floating,
274
+ strategy
275
+ }) : reset.rects;
276
+ }
277
+ ({
278
+ x,
279
+ y
280
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
281
+ }
282
+ i = -1;
283
+ }
284
+ }
285
+ return {
286
+ x,
287
+ y,
288
+ placement: statefulPlacement,
289
+ strategy,
290
+ middlewareData
291
+ };
292
+ };
293
+
294
+ /**
295
+ * Resolves with an object of overflow side offsets that determine how much the
296
+ * element is overflowing a given clipping boundary on each side.
297
+ * - positive = overflowing the boundary by that number of pixels
298
+ * - negative = how many pixels left before it will overflow
299
+ * - 0 = lies flush with the boundary
300
+ * @see https://floating-ui.com/docs/detectOverflow
301
+ */
302
+ async function detectOverflow(state, options) {
303
+ var _await$platform$isEle;
304
+ if (options === void 0) {
305
+ options = {};
306
+ }
307
+ const {
308
+ x,
309
+ y,
310
+ platform,
311
+ rects,
312
+ elements,
313
+ strategy
314
+ } = state;
315
+ const {
316
+ boundary = 'clippingAncestors',
317
+ rootBoundary = 'viewport',
318
+ elementContext = 'floating',
319
+ altBoundary = false,
320
+ padding = 0
321
+ } = evaluate(options, state);
322
+ const paddingObject = getPaddingObject(padding);
323
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
324
+ const element = elements[altBoundary ? altContext : elementContext];
325
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
326
+ 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))),
327
+ boundary,
328
+ rootBoundary,
329
+ strategy
330
+ }));
331
+ const rect = elementContext === 'floating' ? {
332
+ x,
333
+ y,
334
+ width: rects.floating.width,
335
+ height: rects.floating.height
336
+ } : rects.reference;
337
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
338
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
339
+ x: 1,
340
+ y: 1
341
+ } : {
342
+ x: 1,
343
+ y: 1
344
+ };
345
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
346
+ elements,
347
+ rect,
348
+ offsetParent,
349
+ strategy
350
+ }) : rect);
351
+ return {
352
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
353
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
354
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
355
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
356
+ };
357
+ }
358
+
359
+ /**
360
+ * Provides data to position an inner element of the floating element so that it
361
+ * appears centered to the reference element.
362
+ * @see https://floating-ui.com/docs/arrow
363
+ */
364
+ const arrow$1 = options => ({
365
+ name: 'arrow',
366
+ options,
367
+ async fn(state) {
368
+ const {
369
+ x,
370
+ y,
371
+ placement,
372
+ rects,
373
+ platform,
374
+ elements,
375
+ middlewareData
376
+ } = state;
377
+ // Since `element` is required, we don't Partial<> the type.
378
+ const {
379
+ element,
380
+ padding = 0
381
+ } = evaluate(options, state) || {};
382
+ if (element == null) {
383
+ return {};
384
+ }
385
+ const paddingObject = getPaddingObject(padding);
386
+ const coords = {
387
+ x,
388
+ y
389
+ };
390
+ const axis = getAlignmentAxis(placement);
391
+ const length = getAxisLength(axis);
392
+ const arrowDimensions = await platform.getDimensions(element);
393
+ const isYAxis = axis === 'y';
394
+ const minProp = isYAxis ? 'top' : 'left';
395
+ const maxProp = isYAxis ? 'bottom' : 'right';
396
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
397
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
398
+ const startDiff = coords[axis] - rects.reference[axis];
399
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
400
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
401
+
402
+ // DOM platform can return `window` as the `offsetParent`.
403
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
404
+ clientSize = elements.floating[clientProp] || rects.floating[length];
405
+ }
406
+ const centerToReference = endDiff / 2 - startDiff / 2;
407
+
408
+ // If the padding is large enough that it causes the arrow to no longer be
409
+ // centered, modify the padding so that it is centered.
410
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
411
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
412
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
413
+
414
+ // Make sure the arrow doesn't overflow the floating element if the center
415
+ // point is outside the floating element's bounds.
416
+ const min$1 = minPadding;
417
+ const max = clientSize - arrowDimensions[length] - maxPadding;
418
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
419
+ const offset = clamp(min$1, center, max);
420
+
421
+ // If the reference is small enough that the arrow's padding causes it to
422
+ // to point to nothing for an aligned placement, adjust the offset of the
423
+ // floating element itself. To ensure `shift()` continues to take action,
424
+ // a single reset is performed when this is true.
425
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
426
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
427
+ return {
428
+ [axis]: coords[axis] + alignmentOffset,
429
+ data: {
430
+ [axis]: offset,
431
+ centerOffset: center - offset - alignmentOffset,
432
+ ...(shouldAddOffset && {
433
+ alignmentOffset
434
+ })
435
+ },
436
+ reset: shouldAddOffset
437
+ };
438
+ }
439
+ });
440
+
441
+ function getPlacementList(alignment, autoAlignment, allowedPlacements) {
442
+ const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
443
+ return allowedPlacementsSortedByAlignment.filter(placement => {
444
+ if (alignment) {
445
+ return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
446
+ }
447
+ return true;
448
+ });
449
+ }
450
+ /**
451
+ * Optimizes the visibility of the floating element by choosing the placement
452
+ * that has the most space available automatically, without needing to specify a
453
+ * preferred placement. Alternative to `flip`.
454
+ * @see https://floating-ui.com/docs/autoPlacement
455
+ */
456
+ const autoPlacement$1 = function (options) {
457
+ if (options === void 0) {
458
+ options = {};
459
+ }
460
+ return {
461
+ name: 'autoPlacement',
462
+ options,
463
+ async fn(state) {
464
+ var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
465
+ const {
466
+ rects,
467
+ middlewareData,
468
+ placement,
469
+ platform,
470
+ elements
471
+ } = state;
472
+ const {
473
+ crossAxis = false,
474
+ alignment,
475
+ allowedPlacements = placements,
476
+ autoAlignment = true,
477
+ ...detectOverflowOptions
478
+ } = evaluate(options, state);
479
+ const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
480
+ const overflow = await detectOverflow(state, detectOverflowOptions);
481
+ const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
482
+ const currentPlacement = placements$1[currentIndex];
483
+ if (currentPlacement == null) {
484
+ return {};
485
+ }
486
+ const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
487
+
488
+ // Make `computeCoords` start from the right place.
489
+ if (placement !== currentPlacement) {
490
+ return {
491
+ reset: {
492
+ placement: placements$1[0]
493
+ }
494
+ };
495
+ }
496
+ const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
497
+ const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
498
+ placement: currentPlacement,
499
+ overflows: currentOverflows
500
+ }];
501
+ const nextPlacement = placements$1[currentIndex + 1];
502
+
503
+ // There are more placements to check.
504
+ if (nextPlacement) {
505
+ return {
506
+ data: {
507
+ index: currentIndex + 1,
508
+ overflows: allOverflows
509
+ },
510
+ reset: {
511
+ placement: nextPlacement
512
+ }
513
+ };
514
+ }
515
+ const placementsSortedByMostSpace = allOverflows.map(d => {
516
+ const alignment = getAlignment(d.placement);
517
+ return [d.placement, alignment && crossAxis ?
518
+ // Check along the mainAxis and main crossAxis side.
519
+ d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
520
+ // Check only the mainAxis.
521
+ d.overflows[0], d.overflows];
522
+ }).sort((a, b) => a[1] - b[1]);
523
+ const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
524
+ // Aligned placements should not check their opposite crossAxis
525
+ // side.
526
+ getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
527
+ const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
528
+ if (resetPlacement !== placement) {
529
+ return {
530
+ data: {
531
+ index: currentIndex + 1,
532
+ overflows: allOverflows
533
+ },
534
+ reset: {
535
+ placement: resetPlacement
536
+ }
537
+ };
538
+ }
539
+ return {};
540
+ }
541
+ };
542
+ };
543
+
544
+ /**
545
+ * Optimizes the visibility of the floating element by flipping the `placement`
546
+ * in order to keep it in view when the preferred placement(s) will overflow the
547
+ * clipping boundary. Alternative to `autoPlacement`.
548
+ * @see https://floating-ui.com/docs/flip
549
+ */
550
+ const flip$1 = function (options) {
551
+ if (options === void 0) {
552
+ options = {};
553
+ }
554
+ return {
555
+ name: 'flip',
556
+ options,
557
+ async fn(state) {
558
+ var _middlewareData$arrow, _middlewareData$flip;
559
+ const {
560
+ placement,
561
+ middlewareData,
562
+ rects,
563
+ initialPlacement,
564
+ platform,
565
+ elements
566
+ } = state;
567
+ const {
568
+ mainAxis: checkMainAxis = true,
569
+ crossAxis: checkCrossAxis = true,
570
+ fallbackPlacements: specifiedFallbackPlacements,
571
+ fallbackStrategy = 'bestFit',
572
+ fallbackAxisSideDirection = 'none',
573
+ flipAlignment = true,
574
+ ...detectOverflowOptions
575
+ } = evaluate(options, state);
576
+
577
+ // If a reset by the arrow was caused due to an alignment offset being
578
+ // added, we should skip any logic now since `flip()` has already done its
579
+ // work.
580
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
581
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
582
+ return {};
583
+ }
584
+ const side = getSide(placement);
585
+ const initialSideAxis = getSideAxis(initialPlacement);
586
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
587
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
588
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
589
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
590
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
591
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
592
+ }
593
+ const placements = [initialPlacement, ...fallbackPlacements];
594
+ const overflow = await detectOverflow(state, detectOverflowOptions);
595
+ const overflows = [];
596
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
597
+ if (checkMainAxis) {
598
+ overflows.push(overflow[side]);
599
+ }
600
+ if (checkCrossAxis) {
601
+ const sides = getAlignmentSides(placement, rects, rtl);
602
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
603
+ }
604
+ overflowsData = [...overflowsData, {
605
+ placement,
606
+ overflows
607
+ }];
608
+
609
+ // One or more sides is overflowing.
610
+ if (!overflows.every(side => side <= 0)) {
611
+ var _middlewareData$flip2, _overflowsData$filter;
612
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
613
+ const nextPlacement = placements[nextIndex];
614
+ if (nextPlacement) {
615
+ // Try next placement and re-run the lifecycle.
616
+ return {
617
+ data: {
618
+ index: nextIndex,
619
+ overflows: overflowsData
620
+ },
621
+ reset: {
622
+ placement: nextPlacement
623
+ }
624
+ };
625
+ }
626
+
627
+ // First, find the candidates that fit on the mainAxis side of overflow,
628
+ // then find the placement that fits the best on the main crossAxis side.
629
+ 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;
630
+
631
+ // Otherwise fallback.
632
+ if (!resetPlacement) {
633
+ switch (fallbackStrategy) {
634
+ case 'bestFit':
635
+ {
636
+ var _overflowsData$filter2;
637
+ const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
638
+ if (hasFallbackAxisSideDirection) {
639
+ const currentSideAxis = getSideAxis(d.placement);
640
+ return currentSideAxis === initialSideAxis ||
641
+ // Create a bias to the `y` side axis due to horizontal
642
+ // reading directions favoring greater width.
643
+ currentSideAxis === 'y';
644
+ }
645
+ return true;
646
+ }).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$filter2[0];
647
+ if (placement) {
648
+ resetPlacement = placement;
649
+ }
650
+ break;
651
+ }
652
+ case 'initialPlacement':
653
+ resetPlacement = initialPlacement;
654
+ break;
655
+ }
656
+ }
657
+ if (placement !== resetPlacement) {
658
+ return {
659
+ reset: {
660
+ placement: resetPlacement
661
+ }
662
+ };
663
+ }
664
+ }
665
+ return {};
666
+ }
667
+ };
668
+ };
669
+
670
+ function getSideOffsets(overflow, rect) {
671
+ return {
672
+ top: overflow.top - rect.height,
673
+ right: overflow.right - rect.width,
674
+ bottom: overflow.bottom - rect.height,
675
+ left: overflow.left - rect.width
676
+ };
677
+ }
678
+ function isAnySideFullyClipped(overflow) {
679
+ return sides.some(side => overflow[side] >= 0);
680
+ }
681
+ /**
682
+ * Provides data to hide the floating element in applicable situations, such as
683
+ * when it is not in the same clipping context as the reference element.
684
+ * @see https://floating-ui.com/docs/hide
685
+ */
686
+ const hide$1 = function (options) {
687
+ if (options === void 0) {
688
+ options = {};
689
+ }
690
+ return {
691
+ name: 'hide',
692
+ options,
693
+ async fn(state) {
694
+ const {
695
+ rects
696
+ } = state;
697
+ const {
698
+ strategy = 'referenceHidden',
699
+ ...detectOverflowOptions
700
+ } = evaluate(options, state);
701
+ switch (strategy) {
702
+ case 'referenceHidden':
703
+ {
704
+ const overflow = await detectOverflow(state, {
705
+ ...detectOverflowOptions,
706
+ elementContext: 'reference'
707
+ });
708
+ const offsets = getSideOffsets(overflow, rects.reference);
709
+ return {
710
+ data: {
711
+ referenceHiddenOffsets: offsets,
712
+ referenceHidden: isAnySideFullyClipped(offsets)
713
+ }
714
+ };
715
+ }
716
+ case 'escaped':
717
+ {
718
+ const overflow = await detectOverflow(state, {
719
+ ...detectOverflowOptions,
720
+ altBoundary: true
721
+ });
722
+ const offsets = getSideOffsets(overflow, rects.floating);
723
+ return {
724
+ data: {
725
+ escapedOffsets: offsets,
726
+ escaped: isAnySideFullyClipped(offsets)
727
+ }
728
+ };
729
+ }
730
+ default:
731
+ {
732
+ return {};
733
+ }
734
+ }
735
+ }
736
+ };
737
+ };
738
+
739
+ function getBoundingRect(rects) {
740
+ const minX = min(...rects.map(rect => rect.left));
741
+ const minY = min(...rects.map(rect => rect.top));
742
+ const maxX = max(...rects.map(rect => rect.right));
743
+ const maxY = max(...rects.map(rect => rect.bottom));
744
+ return {
745
+ x: minX,
746
+ y: minY,
747
+ width: maxX - minX,
748
+ height: maxY - minY
749
+ };
750
+ }
751
+ function getRectsByLine(rects) {
752
+ const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
753
+ const groups = [];
754
+ let prevRect = null;
755
+ for (let i = 0; i < sortedRects.length; i++) {
756
+ const rect = sortedRects[i];
757
+ if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
758
+ groups.push([rect]);
759
+ } else {
760
+ groups[groups.length - 1].push(rect);
761
+ }
762
+ prevRect = rect;
763
+ }
764
+ return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
765
+ }
766
+ /**
767
+ * Provides improved positioning for inline reference elements that can span
768
+ * over multiple lines, such as hyperlinks or range selections.
769
+ * @see https://floating-ui.com/docs/inline
770
+ */
771
+ const inline$1 = function (options) {
772
+ if (options === void 0) {
773
+ options = {};
774
+ }
775
+ return {
776
+ name: 'inline',
777
+ options,
778
+ async fn(state) {
779
+ const {
780
+ placement,
781
+ elements,
782
+ rects,
783
+ platform,
784
+ strategy
785
+ } = state;
786
+ // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
787
+ // ClientRect's bounds, despite the event listener being triggered. A
788
+ // padding of 2 seems to handle this issue.
789
+ const {
790
+ padding = 2,
791
+ x,
792
+ y
793
+ } = evaluate(options, state);
794
+ const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
795
+ const clientRects = getRectsByLine(nativeClientRects);
796
+ const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
797
+ const paddingObject = getPaddingObject(padding);
798
+ function getBoundingClientRect() {
799
+ // There are two rects and they are disjoined.
800
+ if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
801
+ // Find the first rect in which the point is fully inside.
802
+ 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;
803
+ }
804
+
805
+ // There are 2 or more connected rects.
806
+ if (clientRects.length >= 2) {
807
+ if (getSideAxis(placement) === 'y') {
808
+ const firstRect = clientRects[0];
809
+ const lastRect = clientRects[clientRects.length - 1];
810
+ const isTop = getSide(placement) === 'top';
811
+ const top = firstRect.top;
812
+ const bottom = lastRect.bottom;
813
+ const left = isTop ? firstRect.left : lastRect.left;
814
+ const right = isTop ? firstRect.right : lastRect.right;
815
+ const width = right - left;
816
+ const height = bottom - top;
817
+ return {
818
+ top,
819
+ bottom,
820
+ left,
821
+ right,
822
+ width,
823
+ height,
824
+ x: left,
825
+ y: top
826
+ };
827
+ }
828
+ const isLeftSide = getSide(placement) === 'left';
829
+ const maxRight = max(...clientRects.map(rect => rect.right));
830
+ const minLeft = min(...clientRects.map(rect => rect.left));
831
+ const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
832
+ const top = measureRects[0].top;
833
+ const bottom = measureRects[measureRects.length - 1].bottom;
834
+ const left = minLeft;
835
+ const right = maxRight;
836
+ const width = right - left;
837
+ const height = bottom - top;
838
+ return {
839
+ top,
840
+ bottom,
841
+ left,
842
+ right,
843
+ width,
844
+ height,
845
+ x: left,
846
+ y: top
847
+ };
848
+ }
849
+ return fallback;
850
+ }
851
+ const resetRects = await platform.getElementRects({
852
+ reference: {
853
+ getBoundingClientRect
854
+ },
855
+ floating: elements.floating,
856
+ strategy
857
+ });
858
+ 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) {
859
+ return {
860
+ reset: {
861
+ rects: resetRects
862
+ }
863
+ };
864
+ }
865
+ return {};
866
+ }
867
+ };
868
+ };
869
+
870
+ // For type backwards-compatibility, the `OffsetOptions` type was also
871
+ // Derivable.
872
+
873
+ async function convertValueToCoords(state, options) {
874
+ const {
875
+ placement,
876
+ platform,
877
+ elements
878
+ } = state;
879
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
880
+ const side = getSide(placement);
881
+ const alignment = getAlignment(placement);
882
+ const isVertical = getSideAxis(placement) === 'y';
883
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
884
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
885
+ const rawValue = evaluate(options, state);
886
+
887
+ // eslint-disable-next-line prefer-const
888
+ let {
889
+ mainAxis,
890
+ crossAxis,
891
+ alignmentAxis
892
+ } = typeof rawValue === 'number' ? {
893
+ mainAxis: rawValue,
894
+ crossAxis: 0,
895
+ alignmentAxis: null
896
+ } : {
897
+ mainAxis: rawValue.mainAxis || 0,
898
+ crossAxis: rawValue.crossAxis || 0,
899
+ alignmentAxis: rawValue.alignmentAxis
900
+ };
901
+ if (alignment && typeof alignmentAxis === 'number') {
902
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
903
+ }
904
+ return isVertical ? {
905
+ x: crossAxis * crossAxisMulti,
906
+ y: mainAxis * mainAxisMulti
907
+ } : {
908
+ x: mainAxis * mainAxisMulti,
909
+ y: crossAxis * crossAxisMulti
910
+ };
911
+ }
912
+
913
+ /**
914
+ * Modifies the placement by translating the floating element along the
915
+ * specified axes.
916
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
917
+ * object may be passed.
918
+ * @see https://floating-ui.com/docs/offset
919
+ */
920
+ const offset$1 = function (options) {
921
+ if (options === void 0) {
922
+ options = 0;
923
+ }
924
+ return {
925
+ name: 'offset',
926
+ options,
927
+ async fn(state) {
928
+ var _middlewareData$offse, _middlewareData$arrow;
929
+ const {
930
+ x,
931
+ y,
932
+ placement,
933
+ middlewareData
934
+ } = state;
935
+ const diffCoords = await convertValueToCoords(state, options);
936
+
937
+ // If the placement is the same and the arrow caused an alignment offset
938
+ // then we don't need to change the positioning coordinates.
939
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
940
+ return {};
941
+ }
942
+ return {
943
+ x: x + diffCoords.x,
944
+ y: y + diffCoords.y,
945
+ data: {
946
+ ...diffCoords,
947
+ placement
948
+ }
949
+ };
950
+ }
951
+ };
952
+ };
953
+
954
+ /**
955
+ * Provides data that allows you to change the size of the floating element —
956
+ * for instance, prevent it from overflowing the clipping boundary or match the
957
+ * width of the reference element.
958
+ * @see https://floating-ui.com/docs/size
959
+ */
960
+ const size$1 = function (options) {
961
+ if (options === void 0) {
962
+ options = {};
963
+ }
964
+ return {
965
+ name: 'size',
966
+ options,
967
+ async fn(state) {
968
+ var _state$middlewareData, _state$middlewareData2;
969
+ const {
970
+ placement,
971
+ rects,
972
+ platform,
973
+ elements
974
+ } = state;
975
+ const {
976
+ apply = () => {},
977
+ ...detectOverflowOptions
978
+ } = evaluate(options, state);
979
+ const overflow = await detectOverflow(state, detectOverflowOptions);
980
+ const side = getSide(placement);
981
+ const alignment = getAlignment(placement);
982
+ const isYAxis = getSideAxis(placement) === 'y';
983
+ const {
984
+ width,
985
+ height
986
+ } = rects.floating;
987
+ let heightSide;
988
+ let widthSide;
989
+ if (side === 'top' || side === 'bottom') {
990
+ heightSide = side;
991
+ widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
992
+ } else {
993
+ widthSide = side;
994
+ heightSide = alignment === 'end' ? 'top' : 'bottom';
995
+ }
996
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
997
+ const maximumClippingWidth = width - overflow.left - overflow.right;
998
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
999
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
1000
+ const noShift = !state.middlewareData.shift;
1001
+ let availableHeight = overflowAvailableHeight;
1002
+ let availableWidth = overflowAvailableWidth;
1003
+ if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
1004
+ availableWidth = maximumClippingWidth;
1005
+ }
1006
+ if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
1007
+ availableHeight = maximumClippingHeight;
1008
+ }
1009
+ if (noShift && !alignment) {
1010
+ const xMin = max(overflow.left, 0);
1011
+ const xMax = max(overflow.right, 0);
1012
+ const yMin = max(overflow.top, 0);
1013
+ const yMax = max(overflow.bottom, 0);
1014
+ if (isYAxis) {
1015
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
1016
+ } else {
1017
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
1018
+ }
1019
+ }
1020
+ await apply({
1021
+ ...state,
1022
+ availableWidth,
1023
+ availableHeight
1024
+ });
1025
+ const nextDimensions = await platform.getDimensions(elements.floating);
1026
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
1027
+ return {
1028
+ reset: {
1029
+ rects: true
1030
+ }
1031
+ };
1032
+ }
1033
+ return {};
1034
+ }
1035
+ };
1036
+ };
1037
+
1038
+ function hasWindow() {
1039
+ return typeof window !== 'undefined';
1040
+ }
1041
+ function getNodeName(node) {
1042
+ if (isNode(node)) {
1043
+ return (node.nodeName || '').toLowerCase();
1044
+ }
1045
+ // Mocked nodes in testing environments may not be instances of Node. By
1046
+ // returning `#document` an infinite loop won't occur.
1047
+ // https://github.com/floating-ui/floating-ui/issues/2317
1048
+ return '#document';
1049
+ }
1050
+ function getWindow(node) {
1051
+ var _node$ownerDocument;
1052
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1053
+ }
1054
+ function getDocumentElement(node) {
1055
+ var _ref;
1056
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1057
+ }
1058
+ function isNode(value) {
1059
+ if (!hasWindow()) {
1060
+ return false;
1061
+ }
1062
+ return value instanceof Node || value instanceof getWindow(value).Node;
1063
+ }
1064
+ function isElement(value) {
1065
+ if (!hasWindow()) {
1066
+ return false;
1067
+ }
1068
+ return value instanceof Element || value instanceof getWindow(value).Element;
1069
+ }
1070
+ function isHTMLElement(value) {
1071
+ if (!hasWindow()) {
1072
+ return false;
1073
+ }
1074
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1075
+ }
1076
+ function isShadowRoot(value) {
1077
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
1078
+ return false;
1079
+ }
1080
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1081
+ }
1082
+ function isOverflowElement(element) {
1083
+ const {
1084
+ overflow,
1085
+ overflowX,
1086
+ overflowY,
1087
+ display
1088
+ } = getComputedStyle(element);
1089
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
1090
+ }
1091
+ function isTableElement(element) {
1092
+ return ['table', 'td', 'th'].includes(getNodeName(element));
1093
+ }
1094
+ function isTopLayer(element) {
1095
+ return [':popover-open', ':modal'].some(selector => {
1096
+ try {
1097
+ return element.matches(selector);
1098
+ } catch (e) {
1099
+ return false;
1100
+ }
1101
+ });
1102
+ }
1103
+ function isContainingBlock(elementOrCss) {
1104
+ const webkit = isWebKit();
1105
+ const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
1106
+
1107
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1108
+ 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));
1109
+ }
1110
+ function getContainingBlock(element) {
1111
+ let currentNode = getParentNode(element);
1112
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1113
+ if (isContainingBlock(currentNode)) {
1114
+ return currentNode;
1115
+ } else if (isTopLayer(currentNode)) {
1116
+ return null;
1117
+ }
1118
+ currentNode = getParentNode(currentNode);
1119
+ }
1120
+ return null;
1121
+ }
1122
+ function isWebKit() {
1123
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
1124
+ return CSS.supports('-webkit-backdrop-filter', 'none');
1125
+ }
1126
+ function isLastTraversableNode(node) {
1127
+ return ['html', 'body', '#document'].includes(getNodeName(node));
1128
+ }
1129
+ function getComputedStyle(element) {
1130
+ return getWindow(element).getComputedStyle(element);
1131
+ }
1132
+ function getNodeScroll(element) {
1133
+ if (isElement(element)) {
1134
+ return {
1135
+ scrollLeft: element.scrollLeft,
1136
+ scrollTop: element.scrollTop
1137
+ };
1138
+ }
1139
+ return {
1140
+ scrollLeft: element.scrollX,
1141
+ scrollTop: element.scrollY
1142
+ };
1143
+ }
1144
+ function getParentNode(node) {
1145
+ if (getNodeName(node) === 'html') {
1146
+ return node;
1147
+ }
1148
+ const result =
1149
+ // Step into the shadow DOM of the parent of a slotted node.
1150
+ node.assignedSlot ||
1151
+ // DOM Element detected.
1152
+ node.parentNode ||
1153
+ // ShadowRoot detected.
1154
+ isShadowRoot(node) && node.host ||
1155
+ // Fallback.
1156
+ getDocumentElement(node);
1157
+ return isShadowRoot(result) ? result.host : result;
1158
+ }
1159
+ function getNearestOverflowAncestor(node) {
1160
+ const parentNode = getParentNode(node);
1161
+ if (isLastTraversableNode(parentNode)) {
1162
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
1163
+ }
1164
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1165
+ return parentNode;
1166
+ }
1167
+ return getNearestOverflowAncestor(parentNode);
1168
+ }
1169
+ function getOverflowAncestors(node, list, traverseIframes) {
1170
+ var _node$ownerDocument2;
1171
+ if (list === void 0) {
1172
+ list = [];
1173
+ }
1174
+ if (traverseIframes === void 0) {
1175
+ traverseIframes = true;
1176
+ }
1177
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1178
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1179
+ const win = getWindow(scrollableAncestor);
1180
+ if (isBody) {
1181
+ const frameElement = getFrameElement(win);
1182
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1183
+ }
1184
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1185
+ }
1186
+ function getFrameElement(win) {
1187
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1188
+ }
1189
+
1190
+ function getCssDimensions(element) {
1191
+ const css = getComputedStyle(element);
1192
+ // In testing environments, the `width` and `height` properties are empty
1193
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
1194
+ let width = parseFloat(css.width) || 0;
1195
+ let height = parseFloat(css.height) || 0;
1196
+ const hasOffset = isHTMLElement(element);
1197
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
1198
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
1199
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1200
+ if (shouldFallback) {
1201
+ width = offsetWidth;
1202
+ height = offsetHeight;
1203
+ }
1204
+ return {
1205
+ width,
1206
+ height,
1207
+ $: shouldFallback
1208
+ };
1209
+ }
1210
+
1211
+ function unwrapElement(element) {
1212
+ return !isElement(element) ? element.contextElement : element;
1213
+ }
1214
+
1215
+ function getScale(element) {
1216
+ const domElement = unwrapElement(element);
1217
+ if (!isHTMLElement(domElement)) {
1218
+ return createCoords(1);
1219
+ }
1220
+ const rect = domElement.getBoundingClientRect();
1221
+ const {
1222
+ width,
1223
+ height,
1224
+ $
1225
+ } = getCssDimensions(domElement);
1226
+ let x = ($ ? round(rect.width) : rect.width) / width;
1227
+ let y = ($ ? round(rect.height) : rect.height) / height;
1228
+
1229
+ // 0, NaN, or Infinity should always fallback to 1.
1230
+
1231
+ if (!x || !Number.isFinite(x)) {
1232
+ x = 1;
1233
+ }
1234
+ if (!y || !Number.isFinite(y)) {
1235
+ y = 1;
1236
+ }
1237
+ return {
1238
+ x,
1239
+ y
1240
+ };
1241
+ }
1242
+
1243
+ const noOffsets = /*#__PURE__*/createCoords(0);
1244
+ function getVisualOffsets(element) {
1245
+ const win = getWindow(element);
1246
+ if (!isWebKit() || !win.visualViewport) {
1247
+ return noOffsets;
1248
+ }
1249
+ return {
1250
+ x: win.visualViewport.offsetLeft,
1251
+ y: win.visualViewport.offsetTop
1252
+ };
1253
+ }
1254
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
1255
+ if (isFixed === void 0) {
1256
+ isFixed = false;
1257
+ }
1258
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
1259
+ return false;
1260
+ }
1261
+ return isFixed;
1262
+ }
1263
+
1264
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1265
+ if (includeScale === void 0) {
1266
+ includeScale = false;
1267
+ }
1268
+ if (isFixedStrategy === void 0) {
1269
+ isFixedStrategy = false;
1270
+ }
1271
+ const clientRect = element.getBoundingClientRect();
1272
+ const domElement = unwrapElement(element);
1273
+ let scale = createCoords(1);
1274
+ if (includeScale) {
1275
+ if (offsetParent) {
1276
+ if (isElement(offsetParent)) {
1277
+ scale = getScale(offsetParent);
1278
+ }
1279
+ } else {
1280
+ scale = getScale(element);
1281
+ }
1282
+ }
1283
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1284
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
1285
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
1286
+ let width = clientRect.width / scale.x;
1287
+ let height = clientRect.height / scale.y;
1288
+ if (domElement) {
1289
+ const win = getWindow(domElement);
1290
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1291
+ let currentWin = win;
1292
+ let currentIFrame = getFrameElement(currentWin);
1293
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
1294
+ const iframeScale = getScale(currentIFrame);
1295
+ const iframeRect = currentIFrame.getBoundingClientRect();
1296
+ const css = getComputedStyle(currentIFrame);
1297
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1298
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1299
+ x *= iframeScale.x;
1300
+ y *= iframeScale.y;
1301
+ width *= iframeScale.x;
1302
+ height *= iframeScale.y;
1303
+ x += left;
1304
+ y += top;
1305
+ currentWin = getWindow(currentIFrame);
1306
+ currentIFrame = getFrameElement(currentWin);
1307
+ }
1308
+ }
1309
+ return rectToClientRect({
1310
+ width,
1311
+ height,
1312
+ x,
1313
+ y
1314
+ });
1315
+ }
1316
+
1317
+ // If <html> has a CSS width greater than the viewport, then this will be
1318
+ // incorrect for RTL.
1319
+ function getWindowScrollBarX(element, rect) {
1320
+ const leftScroll = getNodeScroll(element).scrollLeft;
1321
+ if (!rect) {
1322
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
1323
+ }
1324
+ return rect.left + leftScroll;
1325
+ }
1326
+
1327
+ function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
1328
+ if (ignoreScrollbarX === void 0) {
1329
+ ignoreScrollbarX = false;
1330
+ }
1331
+ const htmlRect = documentElement.getBoundingClientRect();
1332
+ const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
1333
+ // RTL <body> scrollbar.
1334
+ getWindowScrollBarX(documentElement, htmlRect));
1335
+ const y = htmlRect.top + scroll.scrollTop;
1336
+ return {
1337
+ x,
1338
+ y
1339
+ };
1340
+ }
1341
+
1342
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1343
+ let {
1344
+ elements,
1345
+ rect,
1346
+ offsetParent,
1347
+ strategy
1348
+ } = _ref;
1349
+ const isFixed = strategy === 'fixed';
1350
+ const documentElement = getDocumentElement(offsetParent);
1351
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
1352
+ if (offsetParent === documentElement || topLayer && isFixed) {
1353
+ return rect;
1354
+ }
1355
+ let scroll = {
1356
+ scrollLeft: 0,
1357
+ scrollTop: 0
1358
+ };
1359
+ let scale = createCoords(1);
1360
+ const offsets = createCoords(0);
1361
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1362
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1363
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1364
+ scroll = getNodeScroll(offsetParent);
1365
+ }
1366
+ if (isHTMLElement(offsetParent)) {
1367
+ const offsetRect = getBoundingClientRect(offsetParent);
1368
+ scale = getScale(offsetParent);
1369
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1370
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1371
+ }
1372
+ }
1373
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
1374
+ return {
1375
+ width: rect.width * scale.x,
1376
+ height: rect.height * scale.y,
1377
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
1378
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
1379
+ };
1380
+ }
1381
+
1382
+ function getClientRects(element) {
1383
+ return Array.from(element.getClientRects());
1384
+ }
1385
+
1386
+ // Gets the entire size of the scrollable document area, even extending outside
1387
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1388
+ function getDocumentRect(element) {
1389
+ const html = getDocumentElement(element);
1390
+ const scroll = getNodeScroll(element);
1391
+ const body = element.ownerDocument.body;
1392
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1393
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1394
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1395
+ const y = -scroll.scrollTop;
1396
+ if (getComputedStyle(body).direction === 'rtl') {
1397
+ x += max(html.clientWidth, body.clientWidth) - width;
1398
+ }
1399
+ return {
1400
+ width,
1401
+ height,
1402
+ x,
1403
+ y
1404
+ };
1405
+ }
1406
+
1407
+ function getViewportRect(element, strategy) {
1408
+ const win = getWindow(element);
1409
+ const html = getDocumentElement(element);
1410
+ const visualViewport = win.visualViewport;
1411
+ let width = html.clientWidth;
1412
+ let height = html.clientHeight;
1413
+ let x = 0;
1414
+ let y = 0;
1415
+ if (visualViewport) {
1416
+ width = visualViewport.width;
1417
+ height = visualViewport.height;
1418
+ const visualViewportBased = isWebKit();
1419
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1420
+ x = visualViewport.offsetLeft;
1421
+ y = visualViewport.offsetTop;
1422
+ }
1423
+ }
1424
+ return {
1425
+ width,
1426
+ height,
1427
+ x,
1428
+ y
1429
+ };
1430
+ }
1431
+
1432
+ // Returns the inner client rect, subtracting scrollbars if present.
1433
+ function getInnerBoundingClientRect(element, strategy) {
1434
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1435
+ const top = clientRect.top + element.clientTop;
1436
+ const left = clientRect.left + element.clientLeft;
1437
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1438
+ const width = element.clientWidth * scale.x;
1439
+ const height = element.clientHeight * scale.y;
1440
+ const x = left * scale.x;
1441
+ const y = top * scale.y;
1442
+ return {
1443
+ width,
1444
+ height,
1445
+ x,
1446
+ y
1447
+ };
1448
+ }
1449
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1450
+ let rect;
1451
+ if (clippingAncestor === 'viewport') {
1452
+ rect = getViewportRect(element, strategy);
1453
+ } else if (clippingAncestor === 'document') {
1454
+ rect = getDocumentRect(getDocumentElement(element));
1455
+ } else if (isElement(clippingAncestor)) {
1456
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1457
+ } else {
1458
+ const visualOffsets = getVisualOffsets(element);
1459
+ rect = {
1460
+ x: clippingAncestor.x - visualOffsets.x,
1461
+ y: clippingAncestor.y - visualOffsets.y,
1462
+ width: clippingAncestor.width,
1463
+ height: clippingAncestor.height
1464
+ };
1465
+ }
1466
+ return rectToClientRect(rect);
1467
+ }
1468
+ function hasFixedPositionAncestor(element, stopNode) {
1469
+ const parentNode = getParentNode(element);
1470
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1471
+ return false;
1472
+ }
1473
+ return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1474
+ }
1475
+
1476
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
1477
+ // clipping (or hiding) child elements. This returns all clipping ancestors
1478
+ // of the given element up the tree.
1479
+ function getClippingElementAncestors(element, cache) {
1480
+ const cachedResult = cache.get(element);
1481
+ if (cachedResult) {
1482
+ return cachedResult;
1483
+ }
1484
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1485
+ let currentContainingBlockComputedStyle = null;
1486
+ const elementIsFixed = getComputedStyle(element).position === 'fixed';
1487
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1488
+
1489
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1490
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1491
+ const computedStyle = getComputedStyle(currentNode);
1492
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1493
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1494
+ currentContainingBlockComputedStyle = null;
1495
+ }
1496
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1497
+ if (shouldDropCurrentNode) {
1498
+ // Drop non-containing blocks.
1499
+ result = result.filter(ancestor => ancestor !== currentNode);
1500
+ } else {
1501
+ // Record last containing block for next iteration.
1502
+ currentContainingBlockComputedStyle = computedStyle;
1503
+ }
1504
+ currentNode = getParentNode(currentNode);
1505
+ }
1506
+ cache.set(element, result);
1507
+ return result;
1508
+ }
1509
+
1510
+ // Gets the maximum area that the element is visible in due to any number of
1511
+ // clipping ancestors.
1512
+ function getClippingRect(_ref) {
1513
+ let {
1514
+ element,
1515
+ boundary,
1516
+ rootBoundary,
1517
+ strategy
1518
+ } = _ref;
1519
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1520
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1521
+ const firstClippingAncestor = clippingAncestors[0];
1522
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1523
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1524
+ accRect.top = max(rect.top, accRect.top);
1525
+ accRect.right = min(rect.right, accRect.right);
1526
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1527
+ accRect.left = max(rect.left, accRect.left);
1528
+ return accRect;
1529
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1530
+ return {
1531
+ width: clippingRect.right - clippingRect.left,
1532
+ height: clippingRect.bottom - clippingRect.top,
1533
+ x: clippingRect.left,
1534
+ y: clippingRect.top
1535
+ };
1536
+ }
1537
+
1538
+ function getDimensions(element) {
1539
+ const {
1540
+ width,
1541
+ height
1542
+ } = getCssDimensions(element);
1543
+ return {
1544
+ width,
1545
+ height
1546
+ };
1547
+ }
1548
+
1549
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1550
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1551
+ const documentElement = getDocumentElement(offsetParent);
1552
+ const isFixed = strategy === 'fixed';
1553
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1554
+ let scroll = {
1555
+ scrollLeft: 0,
1556
+ scrollTop: 0
1557
+ };
1558
+ const offsets = createCoords(0);
1559
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1560
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1561
+ scroll = getNodeScroll(offsetParent);
1562
+ }
1563
+ if (isOffsetParentAnElement) {
1564
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1565
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1566
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1567
+ } else if (documentElement) {
1568
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
1569
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
1570
+ offsets.x = getWindowScrollBarX(documentElement);
1571
+ }
1572
+ }
1573
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1574
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
1575
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
1576
+ return {
1577
+ x,
1578
+ y,
1579
+ width: rect.width,
1580
+ height: rect.height
1581
+ };
1582
+ }
1583
+
1584
+ function isStaticPositioned(element) {
1585
+ return getComputedStyle(element).position === 'static';
1586
+ }
1587
+
1588
+ function getTrueOffsetParent(element, polyfill) {
1589
+ if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1590
+ return null;
1591
+ }
1592
+ if (polyfill) {
1593
+ return polyfill(element);
1594
+ }
1595
+ let rawOffsetParent = element.offsetParent;
1596
+
1597
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
1598
+ // while Chrome and Safari return the <body> element. The <body> element must
1599
+ // be used to perform the correct calculations even if the <html> element is
1600
+ // non-static.
1601
+ if (getDocumentElement(element) === rawOffsetParent) {
1602
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
1603
+ }
1604
+ return rawOffsetParent;
1605
+ }
1606
+
1607
+ // Gets the closest ancestor positioned element. Handles some edge cases,
1608
+ // such as table ancestors and cross browser bugs.
1609
+ function getOffsetParent(element, polyfill) {
1610
+ const win = getWindow(element);
1611
+ if (isTopLayer(element)) {
1612
+ return win;
1613
+ }
1614
+ if (!isHTMLElement(element)) {
1615
+ let svgOffsetParent = getParentNode(element);
1616
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1617
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1618
+ return svgOffsetParent;
1619
+ }
1620
+ svgOffsetParent = getParentNode(svgOffsetParent);
1621
+ }
1622
+ return win;
1623
+ }
1624
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1625
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1626
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1627
+ }
1628
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1629
+ return win;
1630
+ }
1631
+ return offsetParent || getContainingBlock(element) || win;
1632
+ }
1633
+
1634
+ const getElementRects = async function (data) {
1635
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1636
+ const getDimensionsFn = this.getDimensions;
1637
+ const floatingDimensions = await getDimensionsFn(data.floating);
1638
+ return {
1639
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1640
+ floating: {
1641
+ x: 0,
1642
+ y: 0,
1643
+ width: floatingDimensions.width,
1644
+ height: floatingDimensions.height
1645
+ }
1646
+ };
1647
+ };
1648
+
1649
+ function isRTL(element) {
1650
+ return getComputedStyle(element).direction === 'rtl';
1651
+ }
1652
+
1653
+ const platform = {
1654
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1655
+ getDocumentElement,
1656
+ getClippingRect,
1657
+ getOffsetParent,
1658
+ getElementRects,
1659
+ getClientRects,
1660
+ getDimensions,
1661
+ getScale,
1662
+ isElement,
1663
+ isRTL
1664
+ };
1665
+
1666
+ // https://samthor.au/2021/observing-dom/
1667
+ function observeMove(element, onMove) {
1668
+ let io = null;
1669
+ let timeoutId;
1670
+ const root = getDocumentElement(element);
1671
+ function cleanup() {
1672
+ var _io;
1673
+ clearTimeout(timeoutId);
1674
+ (_io = io) == null || _io.disconnect();
1675
+ io = null;
1676
+ }
1677
+ function refresh(skip, threshold) {
1678
+ if (skip === void 0) {
1679
+ skip = false;
1680
+ }
1681
+ if (threshold === void 0) {
1682
+ threshold = 1;
1683
+ }
1684
+ cleanup();
1685
+ const {
1686
+ left,
1687
+ top,
1688
+ width,
1689
+ height
1690
+ } = element.getBoundingClientRect();
1691
+ if (!skip) {
1692
+ onMove();
1693
+ }
1694
+ if (!width || !height) {
1695
+ return;
1696
+ }
1697
+ const insetTop = floor(top);
1698
+ const insetRight = floor(root.clientWidth - (left + width));
1699
+ const insetBottom = floor(root.clientHeight - (top + height));
1700
+ const insetLeft = floor(left);
1701
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
1702
+ const options = {
1703
+ rootMargin,
1704
+ threshold: max(0, min(1, threshold)) || 1
1705
+ };
1706
+ let isFirstUpdate = true;
1707
+ function handleObserve(entries) {
1708
+ const ratio = entries[0].intersectionRatio;
1709
+ if (ratio !== threshold) {
1710
+ if (!isFirstUpdate) {
1711
+ return refresh();
1712
+ }
1713
+ if (!ratio) {
1714
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
1715
+ // to prevent an infinite loop of updates.
1716
+ timeoutId = setTimeout(() => {
1717
+ refresh(false, 1e-7);
1718
+ }, 1000);
1719
+ } else {
1720
+ refresh(false, ratio);
1721
+ }
1722
+ }
1723
+ isFirstUpdate = false;
1724
+ }
1725
+
1726
+ // Older browsers don't support a `document` as the root and will throw an
1727
+ // error.
1728
+ try {
1729
+ io = new IntersectionObserver(handleObserve, {
1730
+ ...options,
1731
+ // Handle <iframe>s
1732
+ root: root.ownerDocument
1733
+ });
1734
+ } catch (e) {
1735
+ io = new IntersectionObserver(handleObserve, options);
1736
+ }
1737
+ io.observe(element);
1738
+ }
1739
+ refresh(true);
1740
+ return cleanup;
1741
+ }
1742
+
1743
+ /**
1744
+ * Automatically updates the position of the floating element when necessary.
1745
+ * Should only be called when the floating element is mounted on the DOM or
1746
+ * visible on the screen.
1747
+ * @returns cleanup function that should be invoked when the floating element is
1748
+ * removed from the DOM or hidden from the screen.
1749
+ * @see https://floating-ui.com/docs/autoUpdate
1750
+ */
1751
+ function autoUpdate(reference, floating, update, options) {
1752
+ if (options === void 0) {
1753
+ options = {};
1754
+ }
1755
+ const {
1756
+ ancestorScroll = true,
1757
+ ancestorResize = true,
1758
+ elementResize = typeof ResizeObserver === 'function',
1759
+ layoutShift = typeof IntersectionObserver === 'function',
1760
+ animationFrame = false
1761
+ } = options;
1762
+ const referenceEl = unwrapElement(reference);
1763
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
1764
+ ancestors.forEach(ancestor => {
1765
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1766
+ passive: true
1767
+ });
1768
+ ancestorResize && ancestor.addEventListener('resize', update);
1769
+ });
1770
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
1771
+ let reobserveFrame = -1;
1772
+ let resizeObserver = null;
1773
+ if (elementResize) {
1774
+ resizeObserver = new ResizeObserver(_ref => {
1775
+ let [firstEntry] = _ref;
1776
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
1777
+ // Prevent update loops when using the `size` middleware.
1778
+ // https://github.com/floating-ui/floating-ui/issues/1740
1779
+ resizeObserver.unobserve(floating);
1780
+ cancelAnimationFrame(reobserveFrame);
1781
+ reobserveFrame = requestAnimationFrame(() => {
1782
+ var _resizeObserver;
1783
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
1784
+ });
1785
+ }
1786
+ update();
1787
+ });
1788
+ if (referenceEl && !animationFrame) {
1789
+ resizeObserver.observe(referenceEl);
1790
+ }
1791
+ resizeObserver.observe(floating);
1792
+ }
1793
+ let frameId;
1794
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1795
+ if (animationFrame) {
1796
+ frameLoop();
1797
+ }
1798
+ function frameLoop() {
1799
+ const nextRefRect = getBoundingClientRect(reference);
1800
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1801
+ update();
1802
+ }
1803
+ prevRefRect = nextRefRect;
1804
+ frameId = requestAnimationFrame(frameLoop);
1805
+ }
1806
+ update();
1807
+ return () => {
1808
+ var _resizeObserver2;
1809
+ ancestors.forEach(ancestor => {
1810
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1811
+ ancestorResize && ancestor.removeEventListener('resize', update);
1812
+ });
1813
+ cleanupIo == null || cleanupIo();
1814
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
1815
+ resizeObserver = null;
1816
+ if (animationFrame) {
1817
+ cancelAnimationFrame(frameId);
1818
+ }
1819
+ };
1820
+ }
1821
+
1822
+ /**
1823
+ * Modifies the placement by translating the floating element along the
1824
+ * specified axes.
1825
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1826
+ * object may be passed.
1827
+ * @see https://floating-ui.com/docs/offset
1828
+ */
1829
+ const offset = offset$1;
1830
+
1831
+ /**
1832
+ * Optimizes the visibility of the floating element by choosing the placement
1833
+ * that has the most space available automatically, without needing to specify a
1834
+ * preferred placement. Alternative to `flip`.
1835
+ * @see https://floating-ui.com/docs/autoPlacement
1836
+ */
1837
+ const autoPlacement = autoPlacement$1;
1838
+
1839
+ /**
1840
+ * Optimizes the visibility of the floating element by flipping the `placement`
1841
+ * in order to keep it in view when the preferred placement(s) will overflow the
1842
+ * clipping boundary. Alternative to `autoPlacement`.
1843
+ * @see https://floating-ui.com/docs/flip
1844
+ */
1845
+ const flip = flip$1;
1846
+
1847
+ /**
1848
+ * Provides data that allows you to change the size of the floating element —
1849
+ * for instance, prevent it from overflowing the clipping boundary or match the
1850
+ * width of the reference element.
1851
+ * @see https://floating-ui.com/docs/size
1852
+ */
1853
+ const size = size$1;
1854
+
1855
+ /**
1856
+ * Provides data to hide the floating element in applicable situations, such as
1857
+ * when it is not in the same clipping context as the reference element.
1858
+ * @see https://floating-ui.com/docs/hide
1859
+ */
1860
+ const hide = hide$1;
1861
+
1862
+ /**
1863
+ * Provides data to position an inner element of the floating element so that it
1864
+ * appears centered to the reference element.
1865
+ * @see https://floating-ui.com/docs/arrow
1866
+ */
1867
+ const arrow = arrow$1;
1868
+
1869
+ /**
1870
+ * Provides improved positioning for inline reference elements that can span
1871
+ * over multiple lines, such as hyperlinks or range selections.
1872
+ * @see https://floating-ui.com/docs/inline
1873
+ */
1874
+ const inline = inline$1;
1875
+
1876
+ /**
1877
+ * Computes the `x` and `y` coordinates that will place the floating element
1878
+ * next to a given reference element.
1879
+ */
1880
+ const computePosition = (reference, floating, options) => {
1881
+ // This caches the expensive `getClippingElementAncestors` function so that
1882
+ // multiple lifecycle resets re-use the same result. It only lives for a
1883
+ // single call. If other functions become expensive, we can add them as well.
1884
+ const cache = new Map();
1885
+ const mergedOptions = {
1886
+ platform,
1887
+ ...options
1888
+ };
1889
+ const platformWithCache = {
1890
+ ...mergedOptions.platform,
1891
+ _c: cache
1892
+ };
1893
+ return computePosition$1(reference, floating, {
1894
+ ...mergedOptions,
1895
+ platform: platformWithCache
1896
+ });
1897
+ };
1898
+
6
1899
  var __defProp = Object.defineProperty;
7
1900
  var __decorateClass = (decorators, target, key, kind) => {
8
1901
  var result = void 0 ;
@@ -12,37 +1905,270 @@ var __decorateClass = (decorators, target, key, kind) => {
12
1905
  if (result) __defProp(target, key, result);
13
1906
  return result;
14
1907
  };
15
- class Elevation extends index.FoundationElement {
1908
+ const PlacementStrategy = {
1909
+ Flip: "flip",
1910
+ AutoPlacementHorizontal: "auto-placement-horizontal",
1911
+ AutoPlacementVertical: "auto-placement-vertical"
1912
+ };
1913
+ const placementStrategyMiddlewares = {
1914
+ [PlacementStrategy.Flip]: flip(),
1915
+ [PlacementStrategy.AutoPlacementHorizontal]: autoPlacement({
1916
+ allowedPlacements: [
1917
+ "bottom",
1918
+ "top",
1919
+ "bottom-start",
1920
+ "bottom-end",
1921
+ "top-start",
1922
+ "top-end"
1923
+ ]
1924
+ }),
1925
+ [PlacementStrategy.AutoPlacementVertical]: autoPlacement({
1926
+ allowedPlacements: [
1927
+ "left",
1928
+ "right",
1929
+ "left-start",
1930
+ "left-end",
1931
+ "right-start",
1932
+ "right-end"
1933
+ ]
1934
+ })
1935
+ };
1936
+ class Popup extends vividElement.VividElement {
1937
+ constructor() {
1938
+ super(...arguments);
1939
+ this.open = false;
1940
+ this.dismissible = false;
1941
+ this.arrow = false;
1942
+ this.alternate = false;
1943
+ /**
1944
+ * The placement strategy of the popup.
1945
+ *
1946
+ * @public
1947
+ */
1948
+ this.placementStrategy = PlacementStrategy.Flip;
1949
+ this.animationFrame = false;
1950
+ this.strategy = "fixed";
1951
+ }
1952
+ get #middleware() {
1953
+ let middleware = [
1954
+ inline(),
1955
+ placementStrategyMiddlewares[this.placementStrategy],
1956
+ hide(),
1957
+ size({
1958
+ apply({ availableWidth, availableHeight, elements }) {
1959
+ Object.assign(elements.floating.style, {
1960
+ maxWidth: `${availableWidth}px`,
1961
+ maxHeight: `${availableHeight}px`
1962
+ });
1963
+ }
1964
+ })
1965
+ ];
1966
+ if (this.arrow) {
1967
+ middleware = [
1968
+ offset(12),
1969
+ ...middleware,
1970
+ arrow({ element: this.arrowEl, padding: 10 })
1971
+ ];
1972
+ }
1973
+ return middleware;
1974
+ }
1975
+ #cleanup;
1976
+ openChanged(_, newValue) {
1977
+ this.#togglePopover();
1978
+ this.#updateAutoUpdate();
1979
+ this.$emit(newValue ? "vwc-popup:open" : "vwc-popup:close");
1980
+ }
1981
+ /**
1982
+ * @internal
1983
+ */
1984
+ animationFrameChanged() {
1985
+ this.#updateAutoUpdate();
1986
+ }
1987
+ /**
1988
+ * @internal
1989
+ */
1990
+ anchorChanged() {
1991
+ this.#updateAutoUpdate();
1992
+ }
1993
+ /**
1994
+ * @internal
1995
+ */
1996
+ strategyChanged() {
1997
+ this.#togglePopover();
1998
+ }
1999
+ connectedCallback() {
2000
+ super.connectedCallback();
2001
+ this.#togglePopover();
2002
+ this.#updateAutoUpdate();
2003
+ }
2004
+ disconnectedCallback() {
2005
+ super.disconnectedCallback();
2006
+ this.#updateAutoUpdate();
2007
+ }
2008
+ #updateAutoUpdate() {
2009
+ this.#cleanup?.();
2010
+ if (this.open && this.controlEl) {
2011
+ this.controlEl.classList.add("open");
2012
+ }
2013
+ if (this.anchorEl && this.open && this.popupEl) {
2014
+ this.#cleanup = autoUpdate(
2015
+ this.anchorEl,
2016
+ this.popupEl,
2017
+ () => this.updatePosition(),
2018
+ {
2019
+ animationFrame: this.animationFrame
2020
+ }
2021
+ );
2022
+ }
2023
+ }
2024
+ #togglePopover() {
2025
+ if (this.popupEl && this.strategy === "fixed") {
2026
+ if (this.open) {
2027
+ this.popupEl.showPopover();
2028
+ } else {
2029
+ this.popupEl.hidePopover();
2030
+ }
2031
+ }
2032
+ }
2033
+ /**
2034
+ * Updates popup's position
2035
+ *
2036
+ * @public
2037
+ */
2038
+ async updatePosition() {
2039
+ if (!this.open || !this.anchorEl) {
2040
+ return;
2041
+ }
2042
+ const positionData = await computePosition(this.anchorEl, this.popupEl, {
2043
+ placement: this.placement,
2044
+ strategy: this.strategy,
2045
+ middleware: this.#middleware
2046
+ });
2047
+ this.#assignPopupPosition(positionData);
2048
+ if (this.arrow) {
2049
+ this.#assignArrowPosition(positionData);
2050
+ }
2051
+ }
2052
+ #assignPopupPosition(data) {
2053
+ const { x: popupX, y: popupY } = data;
2054
+ const { referenceHidden } = data.middlewareData.hide;
2055
+ Object.assign(this.popupEl.style, {
2056
+ left: `${popupX}px`,
2057
+ top: `${popupY}px`,
2058
+ visibility: referenceHidden ? "hidden" : "visible"
2059
+ });
2060
+ }
2061
+ #assignArrowPosition(data) {
2062
+ const { x: arrowX, y: arrowY } = data.middlewareData.arrow;
2063
+ const styles = {
2064
+ left: "calc(100% - 4px)",
2065
+ right: "-4px",
2066
+ top: "calc(100% - 4px)",
2067
+ bottom: "-4px"
2068
+ };
2069
+ const staticAxis = data.placement.split("-")[0];
2070
+ Object.assign(this.arrowEl.style, {
2071
+ left: arrowX ? `${arrowX}px` : styles[staticAxis],
2072
+ top: arrowY ? `${arrowY}px` : styles[staticAxis]
2073
+ });
2074
+ }
2075
+ get anchorEl() {
2076
+ return this.anchor ?? null;
2077
+ }
2078
+ /**
2079
+ * Shows the popup.
2080
+ * Unlike toggling the `open` attribute, show() will ensure the popup becomes visible synchronously.
2081
+ */
2082
+ show() {
2083
+ this.open = true;
2084
+ this.#togglePopover();
2085
+ this.#updateAutoUpdate();
2086
+ }
2087
+ hide() {
2088
+ this.open = false;
2089
+ }
16
2090
  }
17
2091
  __decorateClass([
18
- index.attr
19
- ], Elevation.prototype, "dp");
2092
+ vividElement.attr({
2093
+ mode: "boolean"
2094
+ })
2095
+ ], Popup.prototype, "open");
2096
+ __decorateClass([
2097
+ vividElement.attr({
2098
+ mode: "boolean"
2099
+ })
2100
+ ], Popup.prototype, "dismissible");
20
2101
  __decorateClass([
21
- index.attr({ attribute: "no-shadow", mode: "boolean" })
22
- ], Elevation.prototype, "noShadow");
2102
+ vividElement.attr({
2103
+ mode: "boolean"
2104
+ })
2105
+ ], Popup.prototype, "arrow");
2106
+ __decorateClass([
2107
+ vividElement.attr({
2108
+ mode: "boolean"
2109
+ })
2110
+ ], Popup.prototype, "alternate");
2111
+ __decorateClass([
2112
+ vividElement.attr({ mode: "fromView" })
2113
+ ], Popup.prototype, "placement");
2114
+ __decorateClass([
2115
+ vividElement.attr({ mode: "boolean", attribute: "animation-frame" })
2116
+ ], Popup.prototype, "animationFrame");
2117
+ __decorateClass([
2118
+ vividElement.attr({ mode: "fromView" })
2119
+ ], Popup.prototype, "strategy");
2120
+ __decorateClass([
2121
+ vividElement.observable
2122
+ ], Popup.prototype, "anchor");
23
2123
 
24
- const styles = ":host{display:contents}.control{display:contents}.control.dp-0{--_elevation-fill: var(--vvd-color-surface-0dp);--_elevation-shadow: var(--vvd-shadow-surface-0dp)}.control.dp-4{--_elevation-fill: var(--vvd-color-surface-4dp);--_elevation-shadow: var(--vvd-shadow-surface-4dp)}.control.dp-8{--_elevation-fill: var(--vvd-color-surface-8dp);--_elevation-shadow: var(--vvd-shadow-surface-8dp)}.control.dp-12{--_elevation-fill: var(--vvd-color-surface-12dp);--_elevation-shadow: var(--vvd-shadow-surface-12dp)}.control.dp-16{--_elevation-fill: var(--vvd-color-surface-16dp);--_elevation-shadow: var(--vvd-shadow-surface-16dp)}.control.dp-24{--_elevation-fill: var(--vvd-color-surface-24dp);--_elevation-shadow: var(--vvd-shadow-surface-24dp)}.control:not(.dp-0,.dp-4,.dp-8,.dp-12,.dp-16,.dp-24){--_elevation-fill: var(--vvd-color-surface-2dp);--_elevation-shadow: var(--vvd-shadow-surface-2dp)}.control ::slotted(*){position:relative;isolation:isolate}.control ::slotted(*):before{position:absolute;z-index:-1;border-radius:inherit;background:var(--_elevation-fill);block-size:100%;content:\"\";filter:var(--_elevation-shadow);inline-size:100%;inset-block-start:0;inset-inline-start:0;transition:background-color .15s linear,filter .15s linear}.control.no-shadow ::slotted(*):before{filter:none}";
2124
+ const styles = ":host{display:var(--_popup-display, inline)}.control{border-radius:inherit;background:var(--vvd-color-surface-4dp);contain:layout}.control:not(.open){display:none}.popup-wrapper{white-space:initial;--scrollbar-track-color: transparent;--scrollbar-thumb-color: color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%)}.popup-wrapper{scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin}.popup-wrapper ::-webkit-scrollbar{width:4px}.popup-wrapper ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.popup-wrapper ::-webkit-scrollbar-thumb{border:0;border-radius:4px;background-color:var(--scrollbar-thumb-color)}.popup-wrapper{z-index:var(--_popup-z-index, 10);overflow:visible;padding:0;border:none;border-radius:8px;margin:0;inline-size:max-content}.popup-wrapper:not(.absolute){position:fixed}.popup-wrapper.absolute{position:absolute;top:0;left:0}.popup-content{display:grid;color:var(--vvd-color-canvas-text)}.dismissible .popup-content{align-content:start;grid-template-columns:1fr auto}.arrow{position:absolute;z-index:-1;width:8px;height:8px;background:var(--vvd-color-surface-4dp);transform:rotate(45deg)}.dismissible-button{align-self:flex-start;margin-block-start:4px;margin-inline-end:4px}";
25
2125
 
26
- const getClasses = ({ dp, noShadow }) => classNames.classNames(
2126
+ const getClasses = ({ open, dismissible, alternate }) => classNames.classNames(
27
2127
  "control",
28
- [`dp-${dp}`, Boolean(dp)],
29
- ["no-shadow", Boolean(noShadow)]
2128
+ ["open", Boolean(open)],
2129
+ ["dismissible", Boolean(dismissible)],
2130
+ ["alternate", Boolean(alternate)]
30
2131
  );
31
- const elevationTemplate = () => index.html` <div
32
- class="${getClasses}"
33
- part="base"
34
- >
35
- <slot></slot>
36
- </div>`;
37
-
38
- const elevationDefinition = Elevation.compose({
39
- baseName: "elevation",
40
- template: elevationTemplate,
41
- styles
42
- });
43
- const elevationRegistries = [elevationDefinition()];
44
- const registerElevation = index.registerFactory(elevationRegistries);
2132
+ function handlePopover(x) {
2133
+ return x.strategy && x.strategy === "fixed" ? "manual" : null;
2134
+ }
2135
+ const popupTemplate = (context) => {
2136
+ const elevationTag = context.tagFor(definition.Elevation);
2137
+ const buttonTag = context.tagFor(definition$1.Button);
2138
+ return vividElement.html`
2139
+ <${elevationTag}>
2140
+ <div popover="${handlePopover}" class="popup-wrapper ${(x) => x.strategy}" ${ref.ref("popupEl")} part="popup-base">
2141
+ <div ${ref.ref("controlEl")} class="${getClasses}" aria-hidden="${(x) => x.open ? "false" : "true"}"
2142
+ part="${(x) => x.alternate ? "vvd-theme-alternate" : ""}">
2143
+ <div class="popup-content">
2144
+ <slot></slot>
2145
+ ${when.when(
2146
+ (x) => x.dismissible,
2147
+ vividElement.html`<${buttonTag} size="condensed" @click="${(x) => x.open = false}"
2148
+ class="dismissible-button" icon="close-small-solid" shape="pill"></${buttonTag}>`
2149
+ )}
2150
+ </div>
2151
+ ${when.when(
2152
+ (x) => x.arrow,
2153
+ vividElement.html`<div class="arrow" ${ref.ref("arrowEl")}></div>`
2154
+ )}
2155
+ </div>
2156
+ </div>
2157
+ </${elevationTag}>`;
2158
+ };
2159
+
2160
+ const popupDefinition = vividElement.defineVividComponent(
2161
+ "popup",
2162
+ Popup,
2163
+ popupTemplate,
2164
+ [definition.elevationDefinition, definition$1.buttonDefinition],
2165
+ {
2166
+ styles
2167
+ }
2168
+ );
2169
+ const registerPopup = vividElement.createRegisterFunction(popupDefinition);
45
2170
 
46
- exports.Elevation = Elevation;
47
- exports.elevationRegistries = elevationRegistries;
48
- exports.registerElevation = registerElevation;
2171
+ exports.PlacementStrategy = PlacementStrategy;
2172
+ exports.Popup = Popup;
2173
+ exports.popupDefinition = popupDefinition;
2174
+ exports.registerPopup = registerPopup;