@vonage/vivid 4.13.0 → 4.14.0

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