@vc-shell/framework 1.1.2 → 1.1.4

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 (271) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/apl-B2DGVGxc.js +76 -0
  3. package/dist/asciiarmor-2LVJmxlE.js +34 -0
  4. package/dist/asn1-jKiBa2Ya.js +95 -0
  5. package/dist/asterisk-DS281yxp.js +271 -0
  6. package/dist/brainfuck-C_p9pTT8.js +34 -0
  7. package/dist/clike-BUuHEmgZ.js +620 -0
  8. package/dist/clojure-CCKyeQKf.js +800 -0
  9. package/dist/cmake-CuaCgAKt.js +28 -0
  10. package/dist/cobol-BlTKFDRj.js +72 -0
  11. package/dist/coffeescript-BVCvwO8I.js +179 -0
  12. package/dist/commonlisp-D_kxz07b.js +75 -0
  13. package/dist/crystal-D309uH6_.js +217 -0
  14. package/dist/css-bIlmDBTK.js +1560 -0
  15. package/dist/cypher-BMq4Fwjl.js +68 -0
  16. package/dist/d-BZcgY6La.js +127 -0
  17. package/dist/diff-Cg9d_RX2.js +18 -0
  18. package/dist/{assets/dockerfile-D0MivFIF.js → dockerfile-DIy8NleC.js} +36 -41
  19. package/dist/dtd-CtLokQ-U.js +84 -0
  20. package/dist/dylan-QYeExnWK.js +234 -0
  21. package/dist/ebnf-DUPDuY4r.js +78 -0
  22. package/dist/ecl-CiXN-g_D.js +121 -0
  23. package/dist/eiffel-yQhjl4T1.js +110 -0
  24. package/dist/elm-CNT9vbN0.js +108 -0
  25. package/dist/erlang-CFOYdy9e.js +487 -0
  26. package/dist/factor-DDOC7X6P.js +65 -0
  27. package/dist/fcl-CPC2WYrI.js +103 -0
  28. package/dist/forth-BmxRyE9S.js +60 -0
  29. package/dist/fortran-9bvPyrOW.js +442 -0
  30. package/dist/framework.js +288 -29
  31. package/dist/gas-BdfkXJT_.js +183 -0
  32. package/dist/gherkin-CJuwpceU.js +34 -0
  33. package/dist/groovy-DZeT_VM-.js +146 -0
  34. package/dist/haskell-Bvt3Qq1t.js +375 -0
  35. package/dist/haxe-70NVW1pR.js +359 -0
  36. package/dist/http-D9LttvKF.js +44 -0
  37. package/dist/idl-B6TRFYjl.js +947 -0
  38. package/dist/{assets/index-BKF-A58l.js → index-BBYKbiRX.js} +79 -92
  39. package/dist/index-BDm0tcWn.js +145680 -0
  40. package/dist/{assets/index-CeeaNa4F.js → index-BDqUaIyQ.js} +136 -167
  41. package/dist/index-BdflTsg6.js +308 -0
  42. package/dist/{assets/index-CtmpJVwa.js → index-BpBTtmQ6.js} +270 -312
  43. package/dist/index-Br0y2YMn.js +58 -0
  44. package/dist/index-CIcET-ZI.js +71 -0
  45. package/dist/index-CYAMpxnu.js +341 -0
  46. package/dist/index-Cf2H7YZ1.js +98 -0
  47. package/dist/{assets/index-Bv_z_qRq.js → index-Ck055pN8.js} +121 -124
  48. package/dist/index-D-fPN3yf.js +75 -0
  49. package/dist/{assets/index-BT8o9-M5.js → index-DJOis7Nc.js} +267 -386
  50. package/dist/index-DKtQMsy4.js +538 -0
  51. package/dist/{assets/index-DMTL7O1s.js → index-DWTsz5bC.js} +570 -586
  52. package/dist/{assets/index-C7zlEJy8.js → index-DuY7BIGm.js} +229 -302
  53. package/dist/{assets/index-B1srGfDb.js → index-o6aSdNED.js} +119 -165
  54. package/dist/index-wfv8ehcx.js +249 -0
  55. package/dist/index.css +9 -18
  56. package/dist/javascript-WMWNx-Vj.js +690 -0
  57. package/dist/jinja2-DnB6dQmV.js +154 -0
  58. package/dist/julia-DpvXAuO6.js +241 -0
  59. package/dist/livescript-CanGTf8u.js +272 -0
  60. package/dist/lua-XplVlWi_.js +217 -0
  61. package/dist/mathematica-jaRHnSxC.js +35 -0
  62. package/dist/mbox-BctzC1hL.js +76 -0
  63. package/dist/mirc-CFBPAOaF.js +72 -0
  64. package/dist/mllike-BSnXJBGA.js +272 -0
  65. package/dist/modelica-vUgVs--1.js +93 -0
  66. package/dist/mscgen-Cpl0NYLN.js +104 -0
  67. package/dist/mumps-CQoS1kWX.js +25 -0
  68. package/dist/nginx-zDPm3Z74.js +89 -0
  69. package/dist/nsis-fePjrhq7.js +62 -0
  70. package/dist/ntriples-CsNjv2QF.js +79 -0
  71. package/dist/octave-C8PmmSRH.js +143 -0
  72. package/dist/oz-Ce8aN8oE.js +151 -0
  73. package/dist/pascal-De0D6mP7.js +77 -0
  74. package/dist/perl-B4bSCe1C.js +915 -0
  75. package/dist/pig-D24Z8EXi.js +54 -0
  76. package/dist/powershell-DkYVfTzP.js +249 -0
  77. package/dist/properties-Dn9wna3M.js +26 -0
  78. package/dist/protobuf-BPIjwpzm.js +49 -0
  79. package/dist/pug-BqUR2bBq.js +248 -0
  80. package/dist/puppet-nyd4dhjf.js +45 -0
  81. package/dist/python-B5QdSKoL.js +313 -0
  82. package/dist/q-DXjKs-tC.js +83 -0
  83. package/dist/r-LKEuhEGI.js +104 -0
  84. package/dist/rpm-IznJm2Xc.js +57 -0
  85. package/dist/ruby-CcYfvIk6.js +228 -0
  86. package/dist/sas-7E8yHoCW.js +105 -0
  87. package/dist/scheme-DjibxsNh.js +124 -0
  88. package/dist/shell-C0C2sNA_.js +182 -0
  89. package/dist/sieve-Bwz7vjP5.js +72 -0
  90. package/dist/simple-mode-B0dvCdAA.js +89 -0
  91. package/dist/smalltalk-Bhddl2pB.js +48 -0
  92. package/dist/solr-BNlsLglM.js +41 -0
  93. package/dist/sparql-FarWu_Gb.js +197 -0
  94. package/dist/spreadsheet-C-cy4P5N.js +49 -0
  95. package/dist/sql-mMre1Bo3.js +282 -0
  96. package/dist/stex-92raWT1r.js +129 -0
  97. package/dist/stylus-CAdqWld3.js +250 -0
  98. package/dist/swift-DSxqR9R6.js +230 -0
  99. package/dist/tcl-xfoLljhY.js +81 -0
  100. package/dist/textile-D1AWE-pc.js +295 -0
  101. package/dist/tiddlywiki-5wqsXtSk.js +155 -0
  102. package/dist/tiki-__Kn3CeS.js +181 -0
  103. package/dist/toml-BHiuTcfn.js +49 -0
  104. package/dist/troff-D2UO-fKf.js +35 -0
  105. package/dist/tsconfig.tsbuildinfo +1 -1
  106. package/dist/ttcn-Bsa4sfRm.js +123 -0
  107. package/dist/ttcn-cfg-Bac_acMi.js +88 -0
  108. package/dist/turtle-xwJUxoPV.js +80 -0
  109. package/dist/ui/components/atoms/vc-widget/vc-widget.vue.d.ts.map +1 -1
  110. package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/vc-blade-toolbar.vue.d.ts.map +1 -1
  111. package/dist/vb-c2kQGd6-.js +74 -0
  112. package/dist/vbscript-Dz1TtKsy.js +324 -0
  113. package/dist/velocity-DJd0pTTC.js +96 -0
  114. package/dist/verilog-C4VGD9n1.js +263 -0
  115. package/dist/vhdl-T9HkrbI2.js +106 -0
  116. package/dist/webidl-CjfDENEo.js +155 -0
  117. package/dist/xquery-BUQdORAS.js +422 -0
  118. package/dist/yacas-C0absKBh.js +73 -0
  119. package/dist/z80-C8rPtw-0.js +61 -0
  120. package/package.json +4 -4
  121. package/ui/components/atoms/vc-widget/vc-widget.vue +2 -0
  122. package/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/vc-blade-toolbar.vue +65 -32
  123. package/dist/assets/apl-NdZ6-T1z.js +0 -142
  124. package/dist/assets/asciiarmor-CmJEbAuq.js +0 -56
  125. package/dist/assets/asn1-Ctc8K72v.js +0 -192
  126. package/dist/assets/asterisk-D6r__RMF.js +0 -187
  127. package/dist/assets/brainfuck-COwWCBpq.js +0 -70
  128. package/dist/assets/clike-C-PtfL50.js +0 -1019
  129. package/dist/assets/clojure-C2XPrGCa.js +0 -274
  130. package/dist/assets/cmake-BGrEgXCL.js +0 -81
  131. package/dist/assets/cobol-DShPmpZe.js +0 -234
  132. package/dist/assets/coffeescript-BG8vTfSz.js +0 -329
  133. package/dist/assets/commonlisp-8oE2EpEe.js +0 -108
  134. package/dist/assets/core-api-BMLS9FrT.js +0 -8288
  135. package/dist/assets/core-composables-DYxpIWyY.js +0 -1799
  136. package/dist/assets/core-constants-DiKDBbnD.js +0 -83
  137. package/dist/assets/core-directives-QhJx9kWh.js +0 -41
  138. package/dist/assets/core-interceptors-CSjUvxQ0.js +0 -78
  139. package/dist/assets/core-plugins-wv2bDZ0l.js +0 -4919
  140. package/dist/assets/core-services-CAfJRsjs.js +0 -4
  141. package/dist/assets/core-utilities-BTktq_a-.js +0 -33
  142. package/dist/assets/crystal--rIRMl16.js +0 -419
  143. package/dist/assets/css/core-directives-FL4vIIkN.css +0 -73
  144. package/dist/assets/css/fonts-M1mtyV8L.css +0 -305
  145. package/dist/assets/css/icons-css-DbCVsovz.css +0 -41
  146. package/dist/assets/css/shared-components-bnLHdCtf.css +0 -429
  147. package/dist/assets/css/shared-modules-CNOICmYQ.css +0 -45
  148. package/dist/assets/css/styles-C62nDZwV.css +0 -4096
  149. package/dist/assets/css/ui-app-Bh9hmlIB.css +0 -1287
  150. package/dist/assets/css/ui-content-B29jsmK7.css +0 -1187
  151. package/dist/assets/css/ui-controls-CRtfFczw.css +0 -387
  152. package/dist/assets/css/ui-data-CYLxfdUa.css +0 -1555
  153. package/dist/assets/css/ui-form-C3WrWfVl.css +0 -71
  154. package/dist/assets/css/ui-form-fields-DOtHhDeM.css +0 -1360
  155. package/dist/assets/css/ui-helpers-bOoNv5dS.css +0 -37
  156. package/dist/assets/css/ui-indicators-CybQnCoU.css +0 -628
  157. package/dist/assets/css/ui-layout-DyGKgizy.css +0 -251
  158. package/dist/assets/css/ui-media-TWYep8js.css +0 -298
  159. package/dist/assets/css/ui-media-advanced-BGxy3VSB.css +0 -183
  160. package/dist/assets/css/ui-navigation-DcPRn8SB.css +0 -1693
  161. package/dist/assets/css-C_ZeEwz2.js +0 -847
  162. package/dist/assets/cypher-Bayei42D.js +0 -122
  163. package/dist/assets/d-B0hhz6be.js +0 -205
  164. package/dist/assets/diff-DQutOIXs.js +0 -30
  165. package/dist/assets/dtd-C1CeYVnM.js +0 -121
  166. package/dist/assets/dylan-Dm9-uD-A.js +0 -337
  167. package/dist/assets/ebnf-jWG_1Yly.js +0 -151
  168. package/dist/assets/ecl-CgJPA6z9.js +0 -190
  169. package/dist/assets/eiffel-lj7uLahq.js +0 -146
  170. package/dist/assets/elm-Cz7o1ijk.js +0 -230
  171. package/dist/assets/erlang-CyL5QOyR.js +0 -581
  172. package/dist/assets/factor-BVWHwYpu.js +0 -65
  173. package/dist/assets/fcl-DiozYjc8.js +0 -154
  174. package/dist/assets/forth-B7vn5ze0.js +0 -164
  175. package/dist/assets/fortran-D2XNEnBT.js +0 -172
  176. package/dist/assets/gas-B_Tj57Ve.js +0 -343
  177. package/dist/assets/gherkin-CJ6Qk4EZ.js +0 -147
  178. package/dist/assets/groovy-ioGz2WSV.js +0 -228
  179. package/dist/assets/haskell-BHnm1B83.js +0 -239
  180. package/dist/assets/haxe-Bn6Yo6N3.js +0 -490
  181. package/dist/assets/http-BOd5SYCT.js +0 -89
  182. package/dist/assets/idl-FSFk8_xX.js +0 -274
  183. package/dist/assets/index--5fKpGeN.js +0 -792
  184. package/dist/assets/index-0lME64YH.js +0 -342
  185. package/dist/assets/index-B6Ip0FgO.js +0 -437
  186. package/dist/assets/index-BmV05E5M.js +0 -479
  187. package/dist/assets/index-C6MavZDA.js +0 -131
  188. package/dist/assets/index-CwKpgcYl.js +0 -85
  189. package/dist/assets/index-DRUmDL0J.js +0 -59
  190. package/dist/assets/index-DgFC-M9G.js +0 -96
  191. package/dist/assets/javascript-DGrAs70C.js +0 -922
  192. package/dist/assets/jinja2-D9k5QrXv.js +0 -171
  193. package/dist/assets/julia-DM42tOPB.js +0 -369
  194. package/dist/assets/livescript-Dci8HnOi.js +0 -259
  195. package/dist/assets/lua-CByQu4v6.js +0 -137
  196. package/dist/assets/lucide-icons-af0BY3bi.js +0 -34555
  197. package/dist/assets/mathematica-Dkv0uCYF.js +0 -153
  198. package/dist/assets/mbox-CYTvs5kC.js +0 -114
  199. package/dist/assets/mirc-DpgP3GCo.js +0 -176
  200. package/dist/assets/mllike-C6tNn2Yt.js +0 -343
  201. package/dist/assets/modelica-CR6hTSce.js +0 -192
  202. package/dist/assets/mscgen-D0GXtzMS.js +0 -149
  203. package/dist/assets/mumps-Bf1EyDa6.js +0 -129
  204. package/dist/assets/nginx-By9Phklj.js +0 -163
  205. package/dist/assets/nsis-B5ggMLQ9.js +0 -80
  206. package/dist/assets/ntriples-C7VJ7pnm.js +0 -141
  207. package/dist/assets/octave-6yR_ix15.js +0 -112
  208. package/dist/assets/oz-CEUnktiQ.js +0 -235
  209. package/dist/assets/pascal-Dksf1EyF.js +0 -124
  210. package/dist/assets/perl-B99DUQQt.js +0 -819
  211. package/dist/assets/pig-DFeDRta6.js +0 -149
  212. package/dist/assets/powershell-DhwsNWMx.js +0 -381
  213. package/dist/assets/properties-o21uErwC.js +0 -62
  214. package/dist/assets/protobuf-YxlANsmD.js +0 -54
  215. package/dist/assets/pug-bUgjeODZ.js +0 -504
  216. package/dist/assets/puppet-B8WICGYE.js +0 -205
  217. package/dist/assets/python-D3FFx1Id.js +0 -389
  218. package/dist/assets/q-D2Hjhl2C.js +0 -123
  219. package/dist/assets/r-D73k5lac.js +0 -174
  220. package/dist/assets/rpm-Duv_WH0z.js +0 -89
  221. package/dist/assets/ruby-DGCVqZDt.js +0 -287
  222. package/dist/assets/sas-XjPv1Vy5.js +0 -268
  223. package/dist/assets/scheme-DeaA28vt.js +0 -263
  224. package/dist/assets/shared-components-CfAt2hC6.js +0 -1501
  225. package/dist/assets/shared-composables-v9NkNuAe.js +0 -35
  226. package/dist/assets/shared-modules-CDP-H5ZB.js +0 -3588
  227. package/dist/assets/shared-pages-BGRRA5WB.js +0 -20
  228. package/dist/assets/shell-Bx6QZTgx.js +0 -145
  229. package/dist/assets/sieve-CWCD62sW.js +0 -178
  230. package/dist/assets/simple-mode-BAO9cD7H.js +0 -136
  231. package/dist/assets/smalltalk-DSQbF4MF.js +0 -153
  232. package/dist/assets/solr-v_XRf31C.js +0 -80
  233. package/dist/assets/sparql-BrfDqf0-.js +0 -170
  234. package/dist/assets/spreadsheet-Csn84Pef.js +0 -98
  235. package/dist/assets/sql-D4utlq1l.js +0 -480
  236. package/dist/assets/stex-DBkktma-.js +0 -246
  237. package/dist/assets/stylus-ByG-Fd6f.js +0 -750
  238. package/dist/assets/swift-CHbTprt3.js +0 -202
  239. package/dist/assets/tcl-BRlMUELr.js +0 -125
  240. package/dist/assets/textile-CqfTUjd4.js +0 -441
  241. package/dist/assets/tiddlywiki-BrsoM8KB.js +0 -278
  242. package/dist/assets/tiki-D-ivWPkc.js +0 -289
  243. package/dist/assets/toml-t_IhJu83.js +0 -75
  244. package/dist/assets/troff-DckGF2AE.js +0 -64
  245. package/dist/assets/ttcn-B8TAFbRR.js +0 -253
  246. package/dist/assets/ttcn-cfg-NHh25oCM.js +0 -197
  247. package/dist/assets/turtle-D9Js0BlL.js +0 -141
  248. package/dist/assets/ui-app-D31Pr1WY.js +0 -1993
  249. package/dist/assets/ui-content-B7SxH8y9.js +0 -52887
  250. package/dist/assets/ui-controls-nmDJYLmC.js +0 -348
  251. package/dist/assets/ui-data-Ci3b1ye0.js +0 -22901
  252. package/dist/assets/ui-form-Cs5ooOo7.js +0 -159
  253. package/dist/assets/ui-form-fields-DFQi31jT.js +0 -40575
  254. package/dist/assets/ui-helpers-CF-EUlOg.js +0 -1736
  255. package/dist/assets/ui-indicators-mIQeEqha.js +0 -199
  256. package/dist/assets/ui-layout-v2XBQky3.js +0 -320
  257. package/dist/assets/ui-media-WWYrwmZw.js +0 -1259
  258. package/dist/assets/ui-media-advanced-T8ibi153.js +0 -492
  259. package/dist/assets/ui-modals-BdZXzI85.js +0 -2
  260. package/dist/assets/ui-navigation-BtHa6ovW.js +0 -24269
  261. package/dist/assets/utils-DZK5fu48.js +0 -17216
  262. package/dist/assets/vb-CbIGLrpY.js +0 -249
  263. package/dist/assets/vbscript-8ANWle9n.js +0 -320
  264. package/dist/assets/velocity-D6hz3Hzw.js +0 -186
  265. package/dist/assets/verilog-DIV442at.js +0 -565
  266. package/dist/assets/vhdl-BlTiZo_v.js +0 -174
  267. package/dist/assets/vueuse-CTQm4Zh0.js +0 -9308
  268. package/dist/assets/webidl-Cp3tcqdk.js +0 -179
  269. package/dist/assets/xquery-Dd4TBzXv.js +0 -411
  270. package/dist/assets/yacas-DQ1WucF0.js +0 -182
  271. package/dist/assets/z80-P1j44jDI.js +0 -102
@@ -1,1736 +0,0 @@
1
- import { createElementBlock, openBlock, renderSlot, computed, ref, shallowRef, watch, getCurrentScope, onScopeDispose, shallowReadonly, unref, defineComponent, getCurrentInstance, createElementVNode, createBlock, Teleport, createCommentVNode, normalizeStyle } from 'vue';
2
-
3
- const _export_sfc = (sfc, props) => {
4
- const target = sfc.__vccOpts || sfc;
5
- for (const [key, val] of props) {
6
- target[key] = val;
7
- }
8
- return target;
9
- };
10
-
11
- const _sfc_main$1 = { };
12
-
13
- const _hoisted_1 = { class: "vc-hint" };
14
-
15
- function _sfc_render(_ctx, _cache) {
16
- return (openBlock(), createElementBlock("div", _hoisted_1, [
17
- renderSlot(_ctx.$slots, "default")
18
- ]))
19
- }
20
- const _Hint = /*#__PURE__*/_export_sfc(_sfc_main$1, [['render',_sfc_render]]);
21
-
22
- const VcHint = _Hint;
23
-
24
- /**
25
- * Custom positioning reference element.
26
- * @see https://floating-ui.com/docs/virtual-elements
27
- */
28
-
29
- const min = Math.min;
30
- const max = Math.max;
31
- const round = Math.round;
32
- const floor = Math.floor;
33
- const createCoords = v => ({
34
- x: v,
35
- y: v
36
- });
37
- const oppositeSideMap = {
38
- left: 'right',
39
- right: 'left',
40
- bottom: 'top',
41
- top: 'bottom'
42
- };
43
- const oppositeAlignmentMap = {
44
- start: 'end',
45
- end: 'start'
46
- };
47
- function clamp(start, value, end) {
48
- return max(start, min(value, end));
49
- }
50
- function evaluate(value, param) {
51
- return typeof value === 'function' ? value(param) : value;
52
- }
53
- function getSide(placement) {
54
- return placement.split('-')[0];
55
- }
56
- function getAlignment(placement) {
57
- return placement.split('-')[1];
58
- }
59
- function getOppositeAxis(axis) {
60
- return axis === 'x' ? 'y' : 'x';
61
- }
62
- function getAxisLength(axis) {
63
- return axis === 'y' ? 'height' : 'width';
64
- }
65
- function getSideAxis(placement) {
66
- return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
67
- }
68
- function getAlignmentAxis(placement) {
69
- return getOppositeAxis(getSideAxis(placement));
70
- }
71
- function getAlignmentSides(placement, rects, rtl) {
72
- if (rtl === void 0) {
73
- rtl = false;
74
- }
75
- const alignment = getAlignment(placement);
76
- const alignmentAxis = getAlignmentAxis(placement);
77
- const length = getAxisLength(alignmentAxis);
78
- let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
79
- if (rects.reference[length] > rects.floating[length]) {
80
- mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
81
- }
82
- return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
83
- }
84
- function getExpandedPlacements(placement) {
85
- const oppositePlacement = getOppositePlacement(placement);
86
- return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
87
- }
88
- function getOppositeAlignmentPlacement(placement) {
89
- return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
90
- }
91
- function getSideList(side, isStart, rtl) {
92
- const lr = ['left', 'right'];
93
- const rl = ['right', 'left'];
94
- const tb = ['top', 'bottom'];
95
- const bt = ['bottom', 'top'];
96
- switch (side) {
97
- case 'top':
98
- case 'bottom':
99
- if (rtl) return isStart ? rl : lr;
100
- return isStart ? lr : rl;
101
- case 'left':
102
- case 'right':
103
- return isStart ? tb : bt;
104
- default:
105
- return [];
106
- }
107
- }
108
- function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
109
- const alignment = getAlignment(placement);
110
- let list = getSideList(getSide(placement), direction === 'start', rtl);
111
- if (alignment) {
112
- list = list.map(side => side + "-" + alignment);
113
- if (flipAlignment) {
114
- list = list.concat(list.map(getOppositeAlignmentPlacement));
115
- }
116
- }
117
- return list;
118
- }
119
- function getOppositePlacement(placement) {
120
- return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
121
- }
122
- function expandPaddingObject(padding) {
123
- return {
124
- top: 0,
125
- right: 0,
126
- bottom: 0,
127
- left: 0,
128
- ...padding
129
- };
130
- }
131
- function getPaddingObject(padding) {
132
- return typeof padding !== 'number' ? expandPaddingObject(padding) : {
133
- top: padding,
134
- right: padding,
135
- bottom: padding,
136
- left: padding
137
- };
138
- }
139
- function rectToClientRect(rect) {
140
- const {
141
- x,
142
- y,
143
- width,
144
- height
145
- } = rect;
146
- return {
147
- width,
148
- height,
149
- top: y,
150
- left: x,
151
- right: x + width,
152
- bottom: y + height,
153
- x,
154
- y
155
- };
156
- }
157
-
158
- function computeCoordsFromPlacement(_ref, placement, rtl) {
159
- let {
160
- reference,
161
- floating
162
- } = _ref;
163
- const sideAxis = getSideAxis(placement);
164
- const alignmentAxis = getAlignmentAxis(placement);
165
- const alignLength = getAxisLength(alignmentAxis);
166
- const side = getSide(placement);
167
- const isVertical = sideAxis === 'y';
168
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
169
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
170
- const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
171
- let coords;
172
- switch (side) {
173
- case 'top':
174
- coords = {
175
- x: commonX,
176
- y: reference.y - floating.height
177
- };
178
- break;
179
- case 'bottom':
180
- coords = {
181
- x: commonX,
182
- y: reference.y + reference.height
183
- };
184
- break;
185
- case 'right':
186
- coords = {
187
- x: reference.x + reference.width,
188
- y: commonY
189
- };
190
- break;
191
- case 'left':
192
- coords = {
193
- x: reference.x - floating.width,
194
- y: commonY
195
- };
196
- break;
197
- default:
198
- coords = {
199
- x: reference.x,
200
- y: reference.y
201
- };
202
- }
203
- switch (getAlignment(placement)) {
204
- case 'start':
205
- coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
206
- break;
207
- case 'end':
208
- coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
209
- break;
210
- }
211
- return coords;
212
- }
213
-
214
- /**
215
- * Computes the `x` and `y` coordinates that will place the floating element
216
- * next to a given reference element.
217
- *
218
- * This export does not have any `platform` interface logic. You will need to
219
- * write one for the platform you are using Floating UI with.
220
- */
221
- const computePosition$1 = async (reference, floating, config) => {
222
- const {
223
- placement = 'bottom',
224
- strategy = 'absolute',
225
- middleware = [],
226
- platform
227
- } = config;
228
- const validMiddleware = middleware.filter(Boolean);
229
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
230
- let rects = await platform.getElementRects({
231
- reference,
232
- floating,
233
- strategy
234
- });
235
- let {
236
- x,
237
- y
238
- } = computeCoordsFromPlacement(rects, placement, rtl);
239
- let statefulPlacement = placement;
240
- let middlewareData = {};
241
- let resetCount = 0;
242
- for (let i = 0; i < validMiddleware.length; i++) {
243
- const {
244
- name,
245
- fn
246
- } = validMiddleware[i];
247
- const {
248
- x: nextX,
249
- y: nextY,
250
- data,
251
- reset
252
- } = await fn({
253
- x,
254
- y,
255
- initialPlacement: placement,
256
- placement: statefulPlacement,
257
- strategy,
258
- middlewareData,
259
- rects,
260
- platform,
261
- elements: {
262
- reference,
263
- floating
264
- }
265
- });
266
- x = nextX != null ? nextX : x;
267
- y = nextY != null ? nextY : y;
268
- middlewareData = {
269
- ...middlewareData,
270
- [name]: {
271
- ...middlewareData[name],
272
- ...data
273
- }
274
- };
275
- if (reset && resetCount <= 50) {
276
- resetCount++;
277
- if (typeof reset === 'object') {
278
- if (reset.placement) {
279
- statefulPlacement = reset.placement;
280
- }
281
- if (reset.rects) {
282
- rects = reset.rects === true ? await platform.getElementRects({
283
- reference,
284
- floating,
285
- strategy
286
- }) : reset.rects;
287
- }
288
- ({
289
- x,
290
- y
291
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
292
- }
293
- i = -1;
294
- }
295
- }
296
- return {
297
- x,
298
- y,
299
- placement: statefulPlacement,
300
- strategy,
301
- middlewareData
302
- };
303
- };
304
-
305
- /**
306
- * Resolves with an object of overflow side offsets that determine how much the
307
- * element is overflowing a given clipping boundary on each side.
308
- * - positive = overflowing the boundary by that number of pixels
309
- * - negative = how many pixels left before it will overflow
310
- * - 0 = lies flush with the boundary
311
- * @see https://floating-ui.com/docs/detectOverflow
312
- */
313
- async function detectOverflow(state, options) {
314
- var _await$platform$isEle;
315
- if (options === void 0) {
316
- options = {};
317
- }
318
- const {
319
- x,
320
- y,
321
- platform,
322
- rects,
323
- elements,
324
- strategy
325
- } = state;
326
- const {
327
- boundary = 'clippingAncestors',
328
- rootBoundary = 'viewport',
329
- elementContext = 'floating',
330
- altBoundary = false,
331
- padding = 0
332
- } = evaluate(options, state);
333
- const paddingObject = getPaddingObject(padding);
334
- const altContext = elementContext === 'floating' ? 'reference' : 'floating';
335
- const element = elements[altBoundary ? altContext : elementContext];
336
- const clippingClientRect = rectToClientRect(await platform.getClippingRect({
337
- 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))),
338
- boundary,
339
- rootBoundary,
340
- strategy
341
- }));
342
- const rect = elementContext === 'floating' ? {
343
- x,
344
- y,
345
- width: rects.floating.width,
346
- height: rects.floating.height
347
- } : rects.reference;
348
- const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
349
- const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
350
- x: 1,
351
- y: 1
352
- } : {
353
- x: 1,
354
- y: 1
355
- };
356
- const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
357
- elements,
358
- rect,
359
- offsetParent,
360
- strategy
361
- }) : rect);
362
- return {
363
- top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
364
- bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
365
- left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
366
- right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
367
- };
368
- }
369
-
370
- /**
371
- * Optimizes the visibility of the floating element by flipping the `placement`
372
- * in order to keep it in view when the preferred placement(s) will overflow the
373
- * clipping boundary. Alternative to `autoPlacement`.
374
- * @see https://floating-ui.com/docs/flip
375
- */
376
- const flip$1 = function (options) {
377
- if (options === void 0) {
378
- options = {};
379
- }
380
- return {
381
- name: 'flip',
382
- options,
383
- async fn(state) {
384
- var _middlewareData$arrow, _middlewareData$flip;
385
- const {
386
- placement,
387
- middlewareData,
388
- rects,
389
- initialPlacement,
390
- platform,
391
- elements
392
- } = state;
393
- const {
394
- mainAxis: checkMainAxis = true,
395
- crossAxis: checkCrossAxis = true,
396
- fallbackPlacements: specifiedFallbackPlacements,
397
- fallbackStrategy = 'bestFit',
398
- fallbackAxisSideDirection = 'none',
399
- flipAlignment = true,
400
- ...detectOverflowOptions
401
- } = evaluate(options, state);
402
-
403
- // If a reset by the arrow was caused due to an alignment offset being
404
- // added, we should skip any logic now since `flip()` has already done its
405
- // work.
406
- // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
407
- if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
408
- return {};
409
- }
410
- const side = getSide(placement);
411
- const initialSideAxis = getSideAxis(initialPlacement);
412
- const isBasePlacement = getSide(initialPlacement) === initialPlacement;
413
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
414
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
415
- const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
416
- if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
417
- fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
418
- }
419
- const placements = [initialPlacement, ...fallbackPlacements];
420
- const overflow = await detectOverflow(state, detectOverflowOptions);
421
- const overflows = [];
422
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
423
- if (checkMainAxis) {
424
- overflows.push(overflow[side]);
425
- }
426
- if (checkCrossAxis) {
427
- const sides = getAlignmentSides(placement, rects, rtl);
428
- overflows.push(overflow[sides[0]], overflow[sides[1]]);
429
- }
430
- overflowsData = [...overflowsData, {
431
- placement,
432
- overflows
433
- }];
434
-
435
- // One or more sides is overflowing.
436
- if (!overflows.every(side => side <= 0)) {
437
- var _middlewareData$flip2, _overflowsData$filter;
438
- const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
439
- const nextPlacement = placements[nextIndex];
440
- if (nextPlacement) {
441
- // Try next placement and re-run the lifecycle.
442
- return {
443
- data: {
444
- index: nextIndex,
445
- overflows: overflowsData
446
- },
447
- reset: {
448
- placement: nextPlacement
449
- }
450
- };
451
- }
452
-
453
- // First, find the candidates that fit on the mainAxis side of overflow,
454
- // then find the placement that fits the best on the main crossAxis side.
455
- 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;
456
-
457
- // Otherwise fallback.
458
- if (!resetPlacement) {
459
- switch (fallbackStrategy) {
460
- case 'bestFit':
461
- {
462
- var _overflowsData$filter2;
463
- const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
464
- if (hasFallbackAxisSideDirection) {
465
- const currentSideAxis = getSideAxis(d.placement);
466
- return currentSideAxis === initialSideAxis ||
467
- // Create a bias to the `y` side axis due to horizontal
468
- // reading directions favoring greater width.
469
- currentSideAxis === 'y';
470
- }
471
- return true;
472
- }).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];
473
- if (placement) {
474
- resetPlacement = placement;
475
- }
476
- break;
477
- }
478
- case 'initialPlacement':
479
- resetPlacement = initialPlacement;
480
- break;
481
- }
482
- }
483
- if (placement !== resetPlacement) {
484
- return {
485
- reset: {
486
- placement: resetPlacement
487
- }
488
- };
489
- }
490
- }
491
- return {};
492
- }
493
- };
494
- };
495
-
496
- // For type backwards-compatibility, the `OffsetOptions` type was also
497
- // Derivable.
498
-
499
- async function convertValueToCoords(state, options) {
500
- const {
501
- placement,
502
- platform,
503
- elements
504
- } = state;
505
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
506
- const side = getSide(placement);
507
- const alignment = getAlignment(placement);
508
- const isVertical = getSideAxis(placement) === 'y';
509
- const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
510
- const crossAxisMulti = rtl && isVertical ? -1 : 1;
511
- const rawValue = evaluate(options, state);
512
-
513
- // eslint-disable-next-line prefer-const
514
- let {
515
- mainAxis,
516
- crossAxis,
517
- alignmentAxis
518
- } = typeof rawValue === 'number' ? {
519
- mainAxis: rawValue,
520
- crossAxis: 0,
521
- alignmentAxis: null
522
- } : {
523
- mainAxis: rawValue.mainAxis || 0,
524
- crossAxis: rawValue.crossAxis || 0,
525
- alignmentAxis: rawValue.alignmentAxis
526
- };
527
- if (alignment && typeof alignmentAxis === 'number') {
528
- crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
529
- }
530
- return isVertical ? {
531
- x: crossAxis * crossAxisMulti,
532
- y: mainAxis * mainAxisMulti
533
- } : {
534
- x: mainAxis * mainAxisMulti,
535
- y: crossAxis * crossAxisMulti
536
- };
537
- }
538
-
539
- /**
540
- * Modifies the placement by translating the floating element along the
541
- * specified axes.
542
- * A number (shorthand for `mainAxis` or distance), or an axes configuration
543
- * object may be passed.
544
- * @see https://floating-ui.com/docs/offset
545
- */
546
- const offset$1 = function (options) {
547
- if (options === void 0) {
548
- options = 0;
549
- }
550
- return {
551
- name: 'offset',
552
- options,
553
- async fn(state) {
554
- var _middlewareData$offse, _middlewareData$arrow;
555
- const {
556
- x,
557
- y,
558
- placement,
559
- middlewareData
560
- } = state;
561
- const diffCoords = await convertValueToCoords(state, options);
562
-
563
- // If the placement is the same and the arrow caused an alignment offset
564
- // then we don't need to change the positioning coordinates.
565
- if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
566
- return {};
567
- }
568
- return {
569
- x: x + diffCoords.x,
570
- y: y + diffCoords.y,
571
- data: {
572
- ...diffCoords,
573
- placement
574
- }
575
- };
576
- }
577
- };
578
- };
579
-
580
- /**
581
- * Optimizes the visibility of the floating element by shifting it in order to
582
- * keep it in view when it will overflow the clipping boundary.
583
- * @see https://floating-ui.com/docs/shift
584
- */
585
- const shift$1 = function (options) {
586
- if (options === void 0) {
587
- options = {};
588
- }
589
- return {
590
- name: 'shift',
591
- options,
592
- async fn(state) {
593
- const {
594
- x,
595
- y,
596
- placement
597
- } = state;
598
- const {
599
- mainAxis: checkMainAxis = true,
600
- crossAxis: checkCrossAxis = false,
601
- limiter = {
602
- fn: _ref => {
603
- let {
604
- x,
605
- y
606
- } = _ref;
607
- return {
608
- x,
609
- y
610
- };
611
- }
612
- },
613
- ...detectOverflowOptions
614
- } = evaluate(options, state);
615
- const coords = {
616
- x,
617
- y
618
- };
619
- const overflow = await detectOverflow(state, detectOverflowOptions);
620
- const crossAxis = getSideAxis(getSide(placement));
621
- const mainAxis = getOppositeAxis(crossAxis);
622
- let mainAxisCoord = coords[mainAxis];
623
- let crossAxisCoord = coords[crossAxis];
624
- if (checkMainAxis) {
625
- const minSide = mainAxis === 'y' ? 'top' : 'left';
626
- const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
627
- const min = mainAxisCoord + overflow[minSide];
628
- const max = mainAxisCoord - overflow[maxSide];
629
- mainAxisCoord = clamp(min, mainAxisCoord, max);
630
- }
631
- if (checkCrossAxis) {
632
- const minSide = crossAxis === 'y' ? 'top' : 'left';
633
- const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
634
- const min = crossAxisCoord + overflow[minSide];
635
- const max = crossAxisCoord - overflow[maxSide];
636
- crossAxisCoord = clamp(min, crossAxisCoord, max);
637
- }
638
- const limitedCoords = limiter.fn({
639
- ...state,
640
- [mainAxis]: mainAxisCoord,
641
- [crossAxis]: crossAxisCoord
642
- });
643
- return {
644
- ...limitedCoords,
645
- data: {
646
- x: limitedCoords.x - x,
647
- y: limitedCoords.y - y,
648
- enabled: {
649
- [mainAxis]: checkMainAxis,
650
- [crossAxis]: checkCrossAxis
651
- }
652
- }
653
- };
654
- }
655
- };
656
- };
657
-
658
- function hasWindow() {
659
- return typeof window !== 'undefined';
660
- }
661
- function getNodeName(node) {
662
- if (isNode(node)) {
663
- return (node.nodeName || '').toLowerCase();
664
- }
665
- // Mocked nodes in testing environments may not be instances of Node. By
666
- // returning `#document` an infinite loop won't occur.
667
- // https://github.com/floating-ui/floating-ui/issues/2317
668
- return '#document';
669
- }
670
- function getWindow(node) {
671
- var _node$ownerDocument;
672
- return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
673
- }
674
- function getDocumentElement(node) {
675
- var _ref;
676
- return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
677
- }
678
- function isNode(value) {
679
- if (!hasWindow()) {
680
- return false;
681
- }
682
- return value instanceof Node || value instanceof getWindow(value).Node;
683
- }
684
- function isElement(value) {
685
- if (!hasWindow()) {
686
- return false;
687
- }
688
- return value instanceof Element || value instanceof getWindow(value).Element;
689
- }
690
- function isHTMLElement(value) {
691
- if (!hasWindow()) {
692
- return false;
693
- }
694
- return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
695
- }
696
- function isShadowRoot(value) {
697
- if (!hasWindow() || typeof ShadowRoot === 'undefined') {
698
- return false;
699
- }
700
- return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
701
- }
702
- function isOverflowElement(element) {
703
- const {
704
- overflow,
705
- overflowX,
706
- overflowY,
707
- display
708
- } = getComputedStyle(element);
709
- return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
710
- }
711
- function isTableElement(element) {
712
- return ['table', 'td', 'th'].includes(getNodeName(element));
713
- }
714
- function isTopLayer(element) {
715
- return [':popover-open', ':modal'].some(selector => {
716
- try {
717
- return element.matches(selector);
718
- } catch (e) {
719
- return false;
720
- }
721
- });
722
- }
723
- function isContainingBlock(elementOrCss) {
724
- const webkit = isWebKit();
725
- const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
726
-
727
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
728
- // https://drafts.csswg.org/css-transforms-2/#individual-transforms
729
- return ['transform', 'translate', 'scale', 'rotate', 'perspective'].some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
730
- }
731
- function getContainingBlock(element) {
732
- let currentNode = getParentNode(element);
733
- while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
734
- if (isContainingBlock(currentNode)) {
735
- return currentNode;
736
- } else if (isTopLayer(currentNode)) {
737
- return null;
738
- }
739
- currentNode = getParentNode(currentNode);
740
- }
741
- return null;
742
- }
743
- function isWebKit() {
744
- if (typeof CSS === 'undefined' || !CSS.supports) return false;
745
- return CSS.supports('-webkit-backdrop-filter', 'none');
746
- }
747
- function isLastTraversableNode(node) {
748
- return ['html', 'body', '#document'].includes(getNodeName(node));
749
- }
750
- function getComputedStyle(element) {
751
- return getWindow(element).getComputedStyle(element);
752
- }
753
- function getNodeScroll(element) {
754
- if (isElement(element)) {
755
- return {
756
- scrollLeft: element.scrollLeft,
757
- scrollTop: element.scrollTop
758
- };
759
- }
760
- return {
761
- scrollLeft: element.scrollX,
762
- scrollTop: element.scrollY
763
- };
764
- }
765
- function getParentNode(node) {
766
- if (getNodeName(node) === 'html') {
767
- return node;
768
- }
769
- const result =
770
- // Step into the shadow DOM of the parent of a slotted node.
771
- node.assignedSlot ||
772
- // DOM Element detected.
773
- node.parentNode ||
774
- // ShadowRoot detected.
775
- isShadowRoot(node) && node.host ||
776
- // Fallback.
777
- getDocumentElement(node);
778
- return isShadowRoot(result) ? result.host : result;
779
- }
780
- function getNearestOverflowAncestor(node) {
781
- const parentNode = getParentNode(node);
782
- if (isLastTraversableNode(parentNode)) {
783
- return node.ownerDocument ? node.ownerDocument.body : node.body;
784
- }
785
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
786
- return parentNode;
787
- }
788
- return getNearestOverflowAncestor(parentNode);
789
- }
790
- function getOverflowAncestors(node, list, traverseIframes) {
791
- var _node$ownerDocument2;
792
- if (list === void 0) {
793
- list = [];
794
- }
795
- if (traverseIframes === void 0) {
796
- traverseIframes = true;
797
- }
798
- const scrollableAncestor = getNearestOverflowAncestor(node);
799
- const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
800
- const win = getWindow(scrollableAncestor);
801
- if (isBody) {
802
- const frameElement = getFrameElement(win);
803
- return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
804
- }
805
- return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
806
- }
807
- function getFrameElement(win) {
808
- return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
809
- }
810
-
811
- function getCssDimensions(element) {
812
- const css = getComputedStyle(element);
813
- // In testing environments, the `width` and `height` properties are empty
814
- // strings for SVG elements, returning NaN. Fallback to `0` in this case.
815
- let width = parseFloat(css.width) || 0;
816
- let height = parseFloat(css.height) || 0;
817
- const hasOffset = isHTMLElement(element);
818
- const offsetWidth = hasOffset ? element.offsetWidth : width;
819
- const offsetHeight = hasOffset ? element.offsetHeight : height;
820
- const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
821
- if (shouldFallback) {
822
- width = offsetWidth;
823
- height = offsetHeight;
824
- }
825
- return {
826
- width,
827
- height,
828
- $: shouldFallback
829
- };
830
- }
831
-
832
- function unwrapElement$1(element) {
833
- return !isElement(element) ? element.contextElement : element;
834
- }
835
-
836
- function getScale(element) {
837
- const domElement = unwrapElement$1(element);
838
- if (!isHTMLElement(domElement)) {
839
- return createCoords(1);
840
- }
841
- const rect = domElement.getBoundingClientRect();
842
- const {
843
- width,
844
- height,
845
- $
846
- } = getCssDimensions(domElement);
847
- let x = ($ ? round(rect.width) : rect.width) / width;
848
- let y = ($ ? round(rect.height) : rect.height) / height;
849
-
850
- // 0, NaN, or Infinity should always fallback to 1.
851
-
852
- if (!x || !Number.isFinite(x)) {
853
- x = 1;
854
- }
855
- if (!y || !Number.isFinite(y)) {
856
- y = 1;
857
- }
858
- return {
859
- x,
860
- y
861
- };
862
- }
863
-
864
- const noOffsets = /*#__PURE__*/createCoords(0);
865
- function getVisualOffsets(element) {
866
- const win = getWindow(element);
867
- if (!isWebKit() || !win.visualViewport) {
868
- return noOffsets;
869
- }
870
- return {
871
- x: win.visualViewport.offsetLeft,
872
- y: win.visualViewport.offsetTop
873
- };
874
- }
875
- function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
876
- if (isFixed === void 0) {
877
- isFixed = false;
878
- }
879
- if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
880
- return false;
881
- }
882
- return isFixed;
883
- }
884
-
885
- function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
886
- if (includeScale === void 0) {
887
- includeScale = false;
888
- }
889
- if (isFixedStrategy === void 0) {
890
- isFixedStrategy = false;
891
- }
892
- const clientRect = element.getBoundingClientRect();
893
- const domElement = unwrapElement$1(element);
894
- let scale = createCoords(1);
895
- if (includeScale) {
896
- if (offsetParent) {
897
- if (isElement(offsetParent)) {
898
- scale = getScale(offsetParent);
899
- }
900
- } else {
901
- scale = getScale(element);
902
- }
903
- }
904
- const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
905
- let x = (clientRect.left + visualOffsets.x) / scale.x;
906
- let y = (clientRect.top + visualOffsets.y) / scale.y;
907
- let width = clientRect.width / scale.x;
908
- let height = clientRect.height / scale.y;
909
- if (domElement) {
910
- const win = getWindow(domElement);
911
- const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
912
- let currentWin = win;
913
- let currentIFrame = getFrameElement(currentWin);
914
- while (currentIFrame && offsetParent && offsetWin !== currentWin) {
915
- const iframeScale = getScale(currentIFrame);
916
- const iframeRect = currentIFrame.getBoundingClientRect();
917
- const css = getComputedStyle(currentIFrame);
918
- const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
919
- const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
920
- x *= iframeScale.x;
921
- y *= iframeScale.y;
922
- width *= iframeScale.x;
923
- height *= iframeScale.y;
924
- x += left;
925
- y += top;
926
- currentWin = getWindow(currentIFrame);
927
- currentIFrame = getFrameElement(currentWin);
928
- }
929
- }
930
- return rectToClientRect({
931
- width,
932
- height,
933
- x,
934
- y
935
- });
936
- }
937
-
938
- // If <html> has a CSS width greater than the viewport, then this will be
939
- // incorrect for RTL.
940
- function getWindowScrollBarX(element, rect) {
941
- const leftScroll = getNodeScroll(element).scrollLeft;
942
- if (!rect) {
943
- return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
944
- }
945
- return rect.left + leftScroll;
946
- }
947
-
948
- function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
949
- if (ignoreScrollbarX === void 0) {
950
- ignoreScrollbarX = false;
951
- }
952
- const htmlRect = documentElement.getBoundingClientRect();
953
- const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
954
- // RTL <body> scrollbar.
955
- getWindowScrollBarX(documentElement, htmlRect));
956
- const y = htmlRect.top + scroll.scrollTop;
957
- return {
958
- x,
959
- y
960
- };
961
- }
962
-
963
- function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
964
- let {
965
- elements,
966
- rect,
967
- offsetParent,
968
- strategy
969
- } = _ref;
970
- const isFixed = strategy === 'fixed';
971
- const documentElement = getDocumentElement(offsetParent);
972
- const topLayer = elements ? isTopLayer(elements.floating) : false;
973
- if (offsetParent === documentElement || topLayer && isFixed) {
974
- return rect;
975
- }
976
- let scroll = {
977
- scrollLeft: 0,
978
- scrollTop: 0
979
- };
980
- let scale = createCoords(1);
981
- const offsets = createCoords(0);
982
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
983
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
984
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
985
- scroll = getNodeScroll(offsetParent);
986
- }
987
- if (isHTMLElement(offsetParent)) {
988
- const offsetRect = getBoundingClientRect(offsetParent);
989
- scale = getScale(offsetParent);
990
- offsets.x = offsetRect.x + offsetParent.clientLeft;
991
- offsets.y = offsetRect.y + offsetParent.clientTop;
992
- }
993
- }
994
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
995
- return {
996
- width: rect.width * scale.x,
997
- height: rect.height * scale.y,
998
- x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
999
- y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
1000
- };
1001
- }
1002
-
1003
- function getClientRects(element) {
1004
- return Array.from(element.getClientRects());
1005
- }
1006
-
1007
- // Gets the entire size of the scrollable document area, even extending outside
1008
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1009
- function getDocumentRect(element) {
1010
- const html = getDocumentElement(element);
1011
- const scroll = getNodeScroll(element);
1012
- const body = element.ownerDocument.body;
1013
- const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1014
- const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1015
- let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1016
- const y = -scroll.scrollTop;
1017
- if (getComputedStyle(body).direction === 'rtl') {
1018
- x += max(html.clientWidth, body.clientWidth) - width;
1019
- }
1020
- return {
1021
- width,
1022
- height,
1023
- x,
1024
- y
1025
- };
1026
- }
1027
-
1028
- function getViewportRect(element, strategy) {
1029
- const win = getWindow(element);
1030
- const html = getDocumentElement(element);
1031
- const visualViewport = win.visualViewport;
1032
- let width = html.clientWidth;
1033
- let height = html.clientHeight;
1034
- let x = 0;
1035
- let y = 0;
1036
- if (visualViewport) {
1037
- width = visualViewport.width;
1038
- height = visualViewport.height;
1039
- const visualViewportBased = isWebKit();
1040
- if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1041
- x = visualViewport.offsetLeft;
1042
- y = visualViewport.offsetTop;
1043
- }
1044
- }
1045
- return {
1046
- width,
1047
- height,
1048
- x,
1049
- y
1050
- };
1051
- }
1052
-
1053
- // Returns the inner client rect, subtracting scrollbars if present.
1054
- function getInnerBoundingClientRect(element, strategy) {
1055
- const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1056
- const top = clientRect.top + element.clientTop;
1057
- const left = clientRect.left + element.clientLeft;
1058
- const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1059
- const width = element.clientWidth * scale.x;
1060
- const height = element.clientHeight * scale.y;
1061
- const x = left * scale.x;
1062
- const y = top * scale.y;
1063
- return {
1064
- width,
1065
- height,
1066
- x,
1067
- y
1068
- };
1069
- }
1070
- function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1071
- let rect;
1072
- if (clippingAncestor === 'viewport') {
1073
- rect = getViewportRect(element, strategy);
1074
- } else if (clippingAncestor === 'document') {
1075
- rect = getDocumentRect(getDocumentElement(element));
1076
- } else if (isElement(clippingAncestor)) {
1077
- rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1078
- } else {
1079
- const visualOffsets = getVisualOffsets(element);
1080
- rect = {
1081
- x: clippingAncestor.x - visualOffsets.x,
1082
- y: clippingAncestor.y - visualOffsets.y,
1083
- width: clippingAncestor.width,
1084
- height: clippingAncestor.height
1085
- };
1086
- }
1087
- return rectToClientRect(rect);
1088
- }
1089
- function hasFixedPositionAncestor(element, stopNode) {
1090
- const parentNode = getParentNode(element);
1091
- if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1092
- return false;
1093
- }
1094
- return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1095
- }
1096
-
1097
- // A "clipping ancestor" is an `overflow` element with the characteristic of
1098
- // clipping (or hiding) child elements. This returns all clipping ancestors
1099
- // of the given element up the tree.
1100
- function getClippingElementAncestors(element, cache) {
1101
- const cachedResult = cache.get(element);
1102
- if (cachedResult) {
1103
- return cachedResult;
1104
- }
1105
- let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1106
- let currentContainingBlockComputedStyle = null;
1107
- const elementIsFixed = getComputedStyle(element).position === 'fixed';
1108
- let currentNode = elementIsFixed ? getParentNode(element) : element;
1109
-
1110
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1111
- while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1112
- const computedStyle = getComputedStyle(currentNode);
1113
- const currentNodeIsContaining = isContainingBlock(currentNode);
1114
- if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1115
- currentContainingBlockComputedStyle = null;
1116
- }
1117
- const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1118
- if (shouldDropCurrentNode) {
1119
- // Drop non-containing blocks.
1120
- result = result.filter(ancestor => ancestor !== currentNode);
1121
- } else {
1122
- // Record last containing block for next iteration.
1123
- currentContainingBlockComputedStyle = computedStyle;
1124
- }
1125
- currentNode = getParentNode(currentNode);
1126
- }
1127
- cache.set(element, result);
1128
- return result;
1129
- }
1130
-
1131
- // Gets the maximum area that the element is visible in due to any number of
1132
- // clipping ancestors.
1133
- function getClippingRect(_ref) {
1134
- let {
1135
- element,
1136
- boundary,
1137
- rootBoundary,
1138
- strategy
1139
- } = _ref;
1140
- const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1141
- const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1142
- const firstClippingAncestor = clippingAncestors[0];
1143
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1144
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1145
- accRect.top = max(rect.top, accRect.top);
1146
- accRect.right = min(rect.right, accRect.right);
1147
- accRect.bottom = min(rect.bottom, accRect.bottom);
1148
- accRect.left = max(rect.left, accRect.left);
1149
- return accRect;
1150
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1151
- return {
1152
- width: clippingRect.right - clippingRect.left,
1153
- height: clippingRect.bottom - clippingRect.top,
1154
- x: clippingRect.left,
1155
- y: clippingRect.top
1156
- };
1157
- }
1158
-
1159
- function getDimensions(element) {
1160
- const {
1161
- width,
1162
- height
1163
- } = getCssDimensions(element);
1164
- return {
1165
- width,
1166
- height
1167
- };
1168
- }
1169
-
1170
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1171
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
1172
- const documentElement = getDocumentElement(offsetParent);
1173
- const isFixed = strategy === 'fixed';
1174
- const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1175
- let scroll = {
1176
- scrollLeft: 0,
1177
- scrollTop: 0
1178
- };
1179
- const offsets = createCoords(0);
1180
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1181
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1182
- scroll = getNodeScroll(offsetParent);
1183
- }
1184
- if (isOffsetParentAnElement) {
1185
- const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1186
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1187
- offsets.y = offsetRect.y + offsetParent.clientTop;
1188
- } else if (documentElement) {
1189
- // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
1190
- // Firefox with layout.scrollbar.side = 3 in about:config to test this.
1191
- offsets.x = getWindowScrollBarX(documentElement);
1192
- }
1193
- }
1194
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1195
- const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
1196
- const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
1197
- return {
1198
- x,
1199
- y,
1200
- width: rect.width,
1201
- height: rect.height
1202
- };
1203
- }
1204
-
1205
- function isStaticPositioned(element) {
1206
- return getComputedStyle(element).position === 'static';
1207
- }
1208
-
1209
- function getTrueOffsetParent(element, polyfill) {
1210
- if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1211
- return null;
1212
- }
1213
- if (polyfill) {
1214
- return polyfill(element);
1215
- }
1216
- let rawOffsetParent = element.offsetParent;
1217
-
1218
- // Firefox returns the <html> element as the offsetParent if it's non-static,
1219
- // while Chrome and Safari return the <body> element. The <body> element must
1220
- // be used to perform the correct calculations even if the <html> element is
1221
- // non-static.
1222
- if (getDocumentElement(element) === rawOffsetParent) {
1223
- rawOffsetParent = rawOffsetParent.ownerDocument.body;
1224
- }
1225
- return rawOffsetParent;
1226
- }
1227
-
1228
- // Gets the closest ancestor positioned element. Handles some edge cases,
1229
- // such as table ancestors and cross browser bugs.
1230
- function getOffsetParent(element, polyfill) {
1231
- const win = getWindow(element);
1232
- if (isTopLayer(element)) {
1233
- return win;
1234
- }
1235
- if (!isHTMLElement(element)) {
1236
- let svgOffsetParent = getParentNode(element);
1237
- while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1238
- if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1239
- return svgOffsetParent;
1240
- }
1241
- svgOffsetParent = getParentNode(svgOffsetParent);
1242
- }
1243
- return win;
1244
- }
1245
- let offsetParent = getTrueOffsetParent(element, polyfill);
1246
- while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1247
- offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1248
- }
1249
- if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1250
- return win;
1251
- }
1252
- return offsetParent || getContainingBlock(element) || win;
1253
- }
1254
-
1255
- const getElementRects = async function (data) {
1256
- const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1257
- const getDimensionsFn = this.getDimensions;
1258
- const floatingDimensions = await getDimensionsFn(data.floating);
1259
- return {
1260
- reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1261
- floating: {
1262
- x: 0,
1263
- y: 0,
1264
- width: floatingDimensions.width,
1265
- height: floatingDimensions.height
1266
- }
1267
- };
1268
- };
1269
-
1270
- function isRTL(element) {
1271
- return getComputedStyle(element).direction === 'rtl';
1272
- }
1273
-
1274
- const platform = {
1275
- convertOffsetParentRelativeRectToViewportRelativeRect,
1276
- getDocumentElement,
1277
- getClippingRect,
1278
- getOffsetParent,
1279
- getElementRects,
1280
- getClientRects,
1281
- getDimensions,
1282
- getScale,
1283
- isElement,
1284
- isRTL
1285
- };
1286
-
1287
- function rectsAreEqual(a, b) {
1288
- return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
1289
- }
1290
-
1291
- // https://samthor.au/2021/observing-dom/
1292
- function observeMove(element, onMove) {
1293
- let io = null;
1294
- let timeoutId;
1295
- const root = getDocumentElement(element);
1296
- function cleanup() {
1297
- var _io;
1298
- clearTimeout(timeoutId);
1299
- (_io = io) == null || _io.disconnect();
1300
- io = null;
1301
- }
1302
- function refresh(skip, threshold) {
1303
- if (skip === void 0) {
1304
- skip = false;
1305
- }
1306
- if (threshold === void 0) {
1307
- threshold = 1;
1308
- }
1309
- cleanup();
1310
- const elementRectForRootMargin = element.getBoundingClientRect();
1311
- const {
1312
- left,
1313
- top,
1314
- width,
1315
- height
1316
- } = elementRectForRootMargin;
1317
- if (!skip) {
1318
- onMove();
1319
- }
1320
- if (!width || !height) {
1321
- return;
1322
- }
1323
- const insetTop = floor(top);
1324
- const insetRight = floor(root.clientWidth - (left + width));
1325
- const insetBottom = floor(root.clientHeight - (top + height));
1326
- const insetLeft = floor(left);
1327
- const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
1328
- const options = {
1329
- rootMargin,
1330
- threshold: max(0, min(1, threshold)) || 1
1331
- };
1332
- let isFirstUpdate = true;
1333
- function handleObserve(entries) {
1334
- const ratio = entries[0].intersectionRatio;
1335
- if (ratio !== threshold) {
1336
- if (!isFirstUpdate) {
1337
- return refresh();
1338
- }
1339
- if (!ratio) {
1340
- // If the reference is clipped, the ratio is 0. Throttle the refresh
1341
- // to prevent an infinite loop of updates.
1342
- timeoutId = setTimeout(() => {
1343
- refresh(false, 1e-7);
1344
- }, 1000);
1345
- } else {
1346
- refresh(false, ratio);
1347
- }
1348
- }
1349
- if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
1350
- // It's possible that even though the ratio is reported as 1, the
1351
- // element is not actually fully within the IntersectionObserver's root
1352
- // area anymore. This can happen under performance constraints. This may
1353
- // be a bug in the browser's IntersectionObserver implementation. To
1354
- // work around this, we compare the element's bounding rect now with
1355
- // what it was at the time we created the IntersectionObserver. If they
1356
- // are not equal then the element moved, so we refresh.
1357
- refresh();
1358
- }
1359
- isFirstUpdate = false;
1360
- }
1361
-
1362
- // Older browsers don't support a `document` as the root and will throw an
1363
- // error.
1364
- try {
1365
- io = new IntersectionObserver(handleObserve, {
1366
- ...options,
1367
- // Handle <iframe>s
1368
- root: root.ownerDocument
1369
- });
1370
- } catch (e) {
1371
- io = new IntersectionObserver(handleObserve, options);
1372
- }
1373
- io.observe(element);
1374
- }
1375
- refresh(true);
1376
- return cleanup;
1377
- }
1378
-
1379
- /**
1380
- * Automatically updates the position of the floating element when necessary.
1381
- * Should only be called when the floating element is mounted on the DOM or
1382
- * visible on the screen.
1383
- * @returns cleanup function that should be invoked when the floating element is
1384
- * removed from the DOM or hidden from the screen.
1385
- * @see https://floating-ui.com/docs/autoUpdate
1386
- */
1387
- function autoUpdate(reference, floating, update, options) {
1388
- if (options === void 0) {
1389
- options = {};
1390
- }
1391
- const {
1392
- ancestorScroll = true,
1393
- ancestorResize = true,
1394
- elementResize = typeof ResizeObserver === 'function',
1395
- layoutShift = typeof IntersectionObserver === 'function',
1396
- animationFrame = false
1397
- } = options;
1398
- const referenceEl = unwrapElement$1(reference);
1399
- const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
1400
- ancestors.forEach(ancestor => {
1401
- ancestorScroll && ancestor.addEventListener('scroll', update, {
1402
- passive: true
1403
- });
1404
- ancestorResize && ancestor.addEventListener('resize', update);
1405
- });
1406
- const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
1407
- let reobserveFrame = -1;
1408
- let resizeObserver = null;
1409
- if (elementResize) {
1410
- resizeObserver = new ResizeObserver(_ref => {
1411
- let [firstEntry] = _ref;
1412
- if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
1413
- // Prevent update loops when using the `size` middleware.
1414
- // https://github.com/floating-ui/floating-ui/issues/1740
1415
- resizeObserver.unobserve(floating);
1416
- cancelAnimationFrame(reobserveFrame);
1417
- reobserveFrame = requestAnimationFrame(() => {
1418
- var _resizeObserver;
1419
- (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
1420
- });
1421
- }
1422
- update();
1423
- });
1424
- if (referenceEl && !animationFrame) {
1425
- resizeObserver.observe(referenceEl);
1426
- }
1427
- resizeObserver.observe(floating);
1428
- }
1429
- let frameId;
1430
- let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1431
- if (animationFrame) {
1432
- frameLoop();
1433
- }
1434
- function frameLoop() {
1435
- const nextRefRect = getBoundingClientRect(reference);
1436
- if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
1437
- update();
1438
- }
1439
- prevRefRect = nextRefRect;
1440
- frameId = requestAnimationFrame(frameLoop);
1441
- }
1442
- update();
1443
- return () => {
1444
- var _resizeObserver2;
1445
- ancestors.forEach(ancestor => {
1446
- ancestorScroll && ancestor.removeEventListener('scroll', update);
1447
- ancestorResize && ancestor.removeEventListener('resize', update);
1448
- });
1449
- cleanupIo == null || cleanupIo();
1450
- (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
1451
- resizeObserver = null;
1452
- if (animationFrame) {
1453
- cancelAnimationFrame(frameId);
1454
- }
1455
- };
1456
- }
1457
-
1458
- /**
1459
- * Modifies the placement by translating the floating element along the
1460
- * specified axes.
1461
- * A number (shorthand for `mainAxis` or distance), or an axes configuration
1462
- * object may be passed.
1463
- * @see https://floating-ui.com/docs/offset
1464
- */
1465
- const offset = offset$1;
1466
-
1467
- /**
1468
- * Optimizes the visibility of the floating element by shifting it in order to
1469
- * keep it in view when it will overflow the clipping boundary.
1470
- * @see https://floating-ui.com/docs/shift
1471
- */
1472
- const shift = shift$1;
1473
-
1474
- /**
1475
- * Optimizes the visibility of the floating element by flipping the `placement`
1476
- * in order to keep it in view when the preferred placement(s) will overflow the
1477
- * clipping boundary. Alternative to `autoPlacement`.
1478
- * @see https://floating-ui.com/docs/flip
1479
- */
1480
- const flip = flip$1;
1481
-
1482
- /**
1483
- * Computes the `x` and `y` coordinates that will place the floating element
1484
- * next to a given reference element.
1485
- */
1486
- const computePosition = (reference, floating, options) => {
1487
- // This caches the expensive `getClippingElementAncestors` function so that
1488
- // multiple lifecycle resets re-use the same result. It only lives for a
1489
- // single call. If other functions become expensive, we can add them as well.
1490
- const cache = new Map();
1491
- const mergedOptions = {
1492
- platform,
1493
- ...options
1494
- };
1495
- const platformWithCache = {
1496
- ...mergedOptions.platform,
1497
- _c: cache
1498
- };
1499
- return computePosition$1(reference, floating, {
1500
- ...mergedOptions,
1501
- platform: platformWithCache
1502
- });
1503
- };
1504
-
1505
- function isComponentPublicInstance(target) {
1506
- return target != null && typeof target === 'object' && '$el' in target;
1507
- }
1508
- function unwrapElement(target) {
1509
- if (isComponentPublicInstance(target)) {
1510
- const element = target.$el;
1511
- return isNode(element) && getNodeName(element) === '#comment' ? null : element;
1512
- }
1513
- return target;
1514
- }
1515
-
1516
- function toValue(source) {
1517
- return typeof source === 'function' ? source() : unref(source);
1518
- }
1519
-
1520
- function getDPR(element) {
1521
- if (typeof window === 'undefined') {
1522
- return 1;
1523
- }
1524
- const win = element.ownerDocument.defaultView || window;
1525
- return win.devicePixelRatio || 1;
1526
- }
1527
-
1528
- function roundByDPR(element, value) {
1529
- const dpr = getDPR(element);
1530
- return Math.round(value * dpr) / dpr;
1531
- }
1532
-
1533
- /**
1534
- * Computes the `x` and `y` coordinates that will place the floating element next to a reference element when it is given a certain CSS positioning strategy.
1535
- * @param reference The reference template ref.
1536
- * @param floating The floating template ref.
1537
- * @param options The floating options.
1538
- * @see https://floating-ui.com/docs/vue
1539
- */
1540
- function useFloating(reference, floating, options) {
1541
- if (options === void 0) {
1542
- options = {};
1543
- }
1544
- const whileElementsMountedOption = options.whileElementsMounted;
1545
- const openOption = computed(() => {
1546
- var _toValue;
1547
- return (_toValue = toValue(options.open)) != null ? _toValue : true;
1548
- });
1549
- const middlewareOption = computed(() => toValue(options.middleware));
1550
- const placementOption = computed(() => {
1551
- var _toValue2;
1552
- return (_toValue2 = toValue(options.placement)) != null ? _toValue2 : 'bottom';
1553
- });
1554
- const strategyOption = computed(() => {
1555
- var _toValue3;
1556
- return (_toValue3 = toValue(options.strategy)) != null ? _toValue3 : 'absolute';
1557
- });
1558
- const transformOption = computed(() => {
1559
- var _toValue4;
1560
- return (_toValue4 = toValue(options.transform)) != null ? _toValue4 : true;
1561
- });
1562
- const referenceElement = computed(() => unwrapElement(reference.value));
1563
- const floatingElement = computed(() => unwrapElement(floating.value));
1564
- const x = ref(0);
1565
- const y = ref(0);
1566
- const strategy = ref(strategyOption.value);
1567
- const placement = ref(placementOption.value);
1568
- const middlewareData = shallowRef({});
1569
- const isPositioned = ref(false);
1570
- const floatingStyles = computed(() => {
1571
- const initialStyles = {
1572
- position: strategy.value,
1573
- left: '0',
1574
- top: '0'
1575
- };
1576
- if (!floatingElement.value) {
1577
- return initialStyles;
1578
- }
1579
- const xVal = roundByDPR(floatingElement.value, x.value);
1580
- const yVal = roundByDPR(floatingElement.value, y.value);
1581
- if (transformOption.value) {
1582
- return {
1583
- ...initialStyles,
1584
- transform: "translate(" + xVal + "px, " + yVal + "px)",
1585
- ...(getDPR(floatingElement.value) >= 1.5 && {
1586
- willChange: 'transform'
1587
- })
1588
- };
1589
- }
1590
- return {
1591
- position: strategy.value,
1592
- left: xVal + "px",
1593
- top: yVal + "px"
1594
- };
1595
- });
1596
- let whileElementsMountedCleanup;
1597
- function update() {
1598
- if (referenceElement.value == null || floatingElement.value == null) {
1599
- return;
1600
- }
1601
- const open = openOption.value;
1602
- computePosition(referenceElement.value, floatingElement.value, {
1603
- middleware: middlewareOption.value,
1604
- placement: placementOption.value,
1605
- strategy: strategyOption.value
1606
- }).then(position => {
1607
- x.value = position.x;
1608
- y.value = position.y;
1609
- strategy.value = position.strategy;
1610
- placement.value = position.placement;
1611
- middlewareData.value = position.middlewareData;
1612
- /**
1613
- * The floating element's position may be recomputed while it's closed
1614
- * but still mounted (such as when transitioning out). To ensure
1615
- * `isPositioned` will be `false` initially on the next open, avoid
1616
- * setting it to `true` when `open === false` (must be specified).
1617
- */
1618
- isPositioned.value = open !== false;
1619
- });
1620
- }
1621
- function cleanup() {
1622
- if (typeof whileElementsMountedCleanup === 'function') {
1623
- whileElementsMountedCleanup();
1624
- whileElementsMountedCleanup = undefined;
1625
- }
1626
- }
1627
- function attach() {
1628
- cleanup();
1629
- if (whileElementsMountedOption === undefined) {
1630
- update();
1631
- return;
1632
- }
1633
- if (referenceElement.value != null && floatingElement.value != null) {
1634
- whileElementsMountedCleanup = whileElementsMountedOption(referenceElement.value, floatingElement.value, update);
1635
- return;
1636
- }
1637
- }
1638
- function reset() {
1639
- if (!openOption.value) {
1640
- isPositioned.value = false;
1641
- }
1642
- }
1643
- watch([middlewareOption, placementOption, strategyOption, openOption], update, {
1644
- flush: 'sync'
1645
- });
1646
- watch([referenceElement, floatingElement], attach, {
1647
- flush: 'sync'
1648
- });
1649
- watch(openOption, reset, {
1650
- flush: 'sync'
1651
- });
1652
- if (getCurrentScope()) {
1653
- onScopeDispose(cleanup);
1654
- }
1655
- return {
1656
- x: shallowReadonly(x),
1657
- y: shallowReadonly(y),
1658
- strategy: shallowReadonly(strategy),
1659
- placement: shallowReadonly(placement),
1660
- middlewareData: shallowReadonly(middlewareData),
1661
- isPositioned: shallowReadonly(isPositioned),
1662
- floatingStyles,
1663
- update
1664
- };
1665
- }
1666
-
1667
- const _sfc_main = /* @__PURE__ */ defineComponent({
1668
- __name: "vc-tooltip",
1669
- props: {
1670
- placement: { default: "bottom" },
1671
- offset: { default: () => ({
1672
- crossAxis: 0,
1673
- mainAxis: 0
1674
- }) },
1675
- delay: { default: 0 }
1676
- },
1677
- setup(__props) {
1678
- const props = __props;
1679
- const tooltipVisible = ref(false);
1680
- const tooltipCompRef = ref(null);
1681
- const tooltipRef = ref(null);
1682
- const target = ref(null);
1683
- let showTimeout = null;
1684
- getCurrentInstance();
1685
- const { floatingStyles } = useFloating(tooltipCompRef, tooltipRef, {
1686
- placement: props.placement,
1687
- middleware: [offset(props.offset), shift()]
1688
- });
1689
- const showTooltip = () => {
1690
- if (props.delay > 0) {
1691
- showTimeout = setTimeout(() => {
1692
- tooltipVisible.value = true;
1693
- }, props.delay);
1694
- } else {
1695
- tooltipVisible.value = true;
1696
- }
1697
- };
1698
- const hideTooltip = () => {
1699
- if (showTimeout) {
1700
- clearTimeout(showTimeout);
1701
- showTimeout = null;
1702
- }
1703
- tooltipVisible.value = false;
1704
- };
1705
- return (_ctx, _cache) => {
1706
- return openBlock(), createElementBlock("div", {
1707
- ref_key: "target",
1708
- ref: target,
1709
- class: "vc-tooltip",
1710
- onMouseenter: showTooltip,
1711
- onMouseleave: hideTooltip
1712
- }, [
1713
- createElementVNode("div", {
1714
- ref_key: "tooltipCompRef",
1715
- ref: tooltipCompRef,
1716
- class: "vc-tooltip__trigger"
1717
- }, [
1718
- renderSlot(_ctx.$slots, "default")
1719
- ], 512),
1720
- (openBlock(), createBlock(Teleport, { to: "body" }, [
1721
- tooltipVisible.value && _ctx.$slots["tooltip"] ? (openBlock(), createElementBlock("span", {
1722
- key: 0,
1723
- ref_key: "tooltipRef",
1724
- ref: tooltipRef,
1725
- style: normalizeStyle(unref(floatingStyles)),
1726
- class: "vc-tooltip__content"
1727
- }, [
1728
- renderSlot(_ctx.$slots, "tooltip")
1729
- ], 4)) : createCommentVNode("", true)
1730
- ]))
1731
- ], 544);
1732
- };
1733
- }
1734
- });
1735
-
1736
- export { VcHint as V, _sfc_main as _, autoUpdate as a, _export_sfc as b, flip as f, offset as o, shift as s, useFloating as u };