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