j1-template 2021.3.1 → 2022.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (273) hide show
  1. checksums.yaml +4 -4
  2. data/_includes/themes/j1/blocks/ads/ad.html +14 -14
  3. data/_includes/themes/j1/layouts/content_generator_news_panel_posts.html +4 -4
  4. data/_includes/themes/j1/layouts/content_generator_post.html +4 -4
  5. data/_includes/themes/j1/modules/navigator/generator.html +9 -11
  6. data/_includes/themes/j1/modules/search/docsearch.html +1 -1
  7. data/_includes/themes/j1/procedures/global/create_bs_button.proc +5 -5
  8. data/_includes/themes/j1/procedures/global/create_word_cloud.proc +5 -3
  9. data/_includes/themes/j1/procedures/layouts/module_writer.proc +1 -1
  10. data/_includes/themes/j1/procedures/posts/collate_timeline.proc +3 -3
  11. data/_includes/themes/j1/procedures/posts/create_series_header.proc +1 -1
  12. data/_layouts/default.html +66 -22
  13. data/_layouts/home.html +1 -1
  14. data/_layouts/raw.html +2 -1
  15. data/assets/data/article_navigator/index.html +1 -1
  16. data/assets/data/authclient.html +11 -11
  17. data/assets/data/banner.html +7 -25
  18. data/assets/data/cookieconsent.html +20 -20
  19. data/assets/data/{fam.html → fab.html} +42 -24
  20. data/assets/data/gallery_customizer.html +6 -6
  21. data/assets/data/menu.html +55 -55
  22. data/assets/data/mmenu.html +53 -53
  23. data/assets/data/panel.html +17 -23
  24. data/assets/data/private.json +5 -1
  25. data/assets/data/quicklinks.html +7 -8
  26. data/assets/data/rtext_resizer.html +1 -1
  27. data/assets/data/themes.bootswatch.json +75 -0
  28. data/assets/data/themes.json +6 -6
  29. data/assets/data/translator.html +23 -23
  30. data/assets/error_pages/HTTP445.html +110 -0
  31. data/assets/themes/j1/adapter/js/bmd.js +1 -1
  32. data/assets/themes/j1/adapter/js/clipboard.js +1 -1
  33. data/assets/themes/j1/adapter/js/cookieConsent.js +7 -1
  34. data/assets/themes/j1/adapter/js/{fam.js → fab.js} +121 -116
  35. data/assets/themes/j1/adapter/js/j1.js +242 -174
  36. data/assets/themes/j1/adapter/js/mmenu.js +18 -24
  37. data/assets/themes/j1/adapter/js/navigator.js +6 -4
  38. data/assets/themes/j1/adapter/js/themer.js +13 -4
  39. data/assets/themes/j1/adapter/js/toccer.js +37 -76
  40. data/assets/themes/j1/adapter/js/translator.js +6 -0
  41. data/assets/themes/j1/core/country-flags/css/theme/uno.min.css +15 -0
  42. data/assets/themes/j1/core/css/animate.min.css +1 -1
  43. data/assets/themes/j1/core/css/icon-fonts/fontawesome.min.css +1 -1
  44. data/assets/themes/j1/core/css/icon-fonts/materialdesign-light.min.css +1 -1
  45. data/assets/themes/j1/core/css/icon-fonts/materialdesign.min.css +1 -1
  46. data/assets/themes/j1/core/css/icon-fonts/mdi.css +22307 -0
  47. data/assets/themes/j1/core/css/icon-fonts/mdi.min.css +1 -0
  48. data/assets/themes/j1/core/css/icon-fonts/mdil.css +1222 -0
  49. data/assets/themes/j1/core/css/icon-fonts/mdil.min.css +1 -0
  50. data/assets/themes/j1/core/css/icon-fonts/twemoji.css +4 -0
  51. data/assets/themes/j1/core/css/icon-fonts/twemoji.min.css +1 -1
  52. data/assets/themes/j1/core/css/themes/bootstrap/bootstrap.css +5341 -4730
  53. data/assets/themes/j1/core/css/themes/bootstrap/bootstrap.min.css +3 -1
  54. data/assets/themes/j1/core/css/themes/theme_vapor/bootstrap.css +8301 -0
  55. data/assets/themes/j1/core/css/themes/theme_vapor/bootstrap.min.css +3 -0
  56. data/assets/themes/j1/core/css/themes/{uno-dark → unodark}/bootstrap.css +5284 -4646
  57. data/assets/themes/j1/core/css/themes/unodark/bootstrap.min.css +3 -0
  58. data/assets/themes/j1/core/css/themes/{uno-light → unolight}/bootstrap.css +12188 -12734
  59. data/assets/themes/j1/core/css/themes/unolight/bootstrap.min.css +23 -0
  60. data/assets/themes/j1/core/css/vendor.css +2 -28
  61. data/assets/themes/j1/core/css/vendor.min.css +1 -1
  62. data/assets/themes/j1/core/js/template.js +8201 -10407
  63. data/assets/themes/j1/core/js/template.min.js +20 -30
  64. data/assets/themes/j1/core/js/template.min.js.map +1 -1
  65. data/assets/themes/j1/modules/backstretch/js/backstretch.min.js +1 -1
  66. data/assets/themes/j1/modules/bmd/js/bmd.js +2280 -0
  67. data/assets/themes/j1/modules/bmd/js/bmd.min.js +20 -0
  68. data/assets/themes/j1/modules/bootstrap/js/bootstrap.js +5072 -0
  69. data/assets/themes/j1/modules/bootstrap/js/bootstrap.min.js +7 -0
  70. data/assets/themes/j1/modules/bootstrap/js/bootstrap.min.js.map +1 -0
  71. data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.js +19 -17
  72. data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.min.js +1 -1
  73. data/assets/themes/j1/modules/datatables/js/datatables.js +1 -1
  74. data/assets/themes/j1/modules/datatables/js/datatables.min.js +5 -5
  75. data/assets/themes/j1/modules/{fam/css/theme/uno/fam.css → fab/css/theme/uno/fab.css} +32 -28
  76. data/assets/themes/j1/modules/{fam/css/theme/uno/fam.min.css → fab/css/theme/uno/fab.min.css} +3 -3
  77. data/assets/themes/j1/modules/{materialize → fab}/js/cash.js +20 -2
  78. data/assets/themes/j1/modules/{fam/js/fam.js → fab/js/fab.js} +4 -2
  79. data/assets/themes/j1/modules/{util → gtag-opt-in}/js/gtag-opt-in.js +15 -1
  80. data/assets/themes/j1/modules/gtag-opt-in/js/gtag-opt-in.min.js +15 -0
  81. data/assets/themes/j1/modules/iframeResizer/examples/frame.absolute.html +3 -3
  82. data/assets/themes/j1/modules/iframeResizer/examples/frame.content.html +6 -6
  83. data/assets/themes/j1/modules/iframeResizer/examples/frame.tolerance.html +2 -2
  84. data/assets/themes/j1/modules/iframeResizer/js/client/iframeResizer.contentWindow.js +1 -1
  85. data/assets/themes/j1/modules/iframeResizer/js/client/iframeResizer.contentWindow.min.js +1 -1
  86. data/assets/themes/j1/modules/iframeResizer/js/resizer.min.js +1 -1
  87. data/assets/themes/j1/modules/jquery/js/jquery.js +2 -2
  88. data/assets/themes/j1/modules/jquery/js/jquery.min.js +1 -1
  89. data/assets/themes/j1/modules/jquery/js/jqueryUI.js +7 -7
  90. data/assets/themes/j1/modules/jquery/js/jqueryUI.min.js +3 -3
  91. data/assets/themes/j1/modules/lightGallery/js/core/j1/lightgallery-x.min.js +1 -1
  92. data/assets/themes/j1/modules/lightGallery/js/core/lightgallery.min.js +1 -1
  93. data/assets/themes/j1/modules/lightGallery/js/modules/j1/j1-video.min.js +1 -1
  94. data/assets/themes/j1/modules/lightGallery/js/modules/j1/j1-x-video.min.js +1 -1
  95. data/assets/themes/j1/modules/lightGallery/js/modules/lg-thumbnail.min.js +4 -1
  96. data/assets/themes/j1/modules/lightbox/js/lightbox.js +1 -1
  97. data/assets/themes/j1/modules/lightbox/js/lightbox.min.js +1 -1
  98. data/assets/themes/j1/modules/lunrSearch/js/mustache.js +1 -1
  99. data/assets/themes/j1/modules/lunrSearch/js/mustache.min.js +1 -1
  100. data/assets/themes/j1/modules/lunrSearch/js/uri.js +1 -1
  101. data/assets/themes/j1/modules/lunrSearch/js/uri.min.js +7 -7
  102. data/assets/themes/j1/modules/materialize/js/autocomplete.js +1 -1
  103. data/assets/themes/j1/modules/materialize/js/bin/materialize.js +12374 -0
  104. data/assets/themes/j1/modules/materialize/js/bin/materialize.min.js +6 -0
  105. data/assets/themes/j1/modules/materialize/js/global.js +1 -1
  106. data/assets/themes/j1/modules/materialize/js/select.js +1 -1
  107. data/assets/themes/j1/modules/materialize/js/{tapTarget.js → tapTarget.cash.js} +1 -1
  108. data/assets/themes/j1/modules/materialize/js/tapTarget.jQuery.js +187 -0
  109. data/assets/themes/j1/modules/mdiPreviewer/js/previewer.min.js +1 -1
  110. data/assets/themes/j1/modules/mdilPreviewer/js/previewer.min.js +1 -1
  111. data/assets/themes/j1/modules/msDropdown/css/themes/uno/msDropdown.css +278 -0
  112. data/assets/themes/j1/modules/popper/js/popper.js +1670 -2346
  113. data/assets/themes/j1/modules/popper/js/popper.min.js +6 -4
  114. data/assets/themes/j1/modules/popper/js/popper.min.js.map +1 -1
  115. data/assets/themes/j1/modules/scroller/js/scroller.js +2 -2
  116. data/assets/themes/j1/modules/scroller/js/scroller.min.js +1 -1
  117. data/assets/themes/j1/modules/themeSwitcher/js/switcher.js +8 -8
  118. data/assets/themes/j1/modules/themeSwitcher/js/switcher.min.js +1 -431
  119. data/assets/themes/j1/modules/translator/js/translator.js +6 -2
  120. data/assets/themes/j1/modules/translator/js/translator.min.js +1 -1
  121. data/assets/themes/j1/modules/twemoji/js/picker/twemoji-picker.js +3 -3
  122. data/assets/themes/j1/modules/twemoji/js/picker/twemoji-picker.min.js +1 -1
  123. data/assets/themes/j1/modules/videojs/js/video.min.js +2 -2
  124. data/lib/j1/version.rb +3 -3
  125. data/lib/starter_web/Gemfile +2 -2
  126. data/lib/starter_web/_config.yml +21 -24
  127. data/lib/starter_web/_data/_defaults/j1_config.yml +1 -1
  128. data/lib/starter_web/_data/{private.default.yml → _defaults/private.yml} +2 -0
  129. data/lib/starter_web/_data/_defaults/resources.yml +1 -1
  130. data/lib/starter_web/_data/blocks/banner.yml +71 -68
  131. data/lib/starter_web/_data/blocks/defaults/banner.yml +5 -5
  132. data/lib/starter_web/_data/blocks/defaults/panel.yml +3 -3
  133. data/lib/starter_web/_data/blocks/panel.yml +171 -73
  134. data/lib/starter_web/_data/builder/defaults/blog_navigator.yml +42 -35
  135. data/lib/starter_web/_data/j1_config.yml +3 -3
  136. data/lib/starter_web/_data/layouts/article_navigator.yml +1 -1
  137. data/lib/starter_web/_data/layouts/blog_archive.yml +1 -1
  138. data/lib/starter_web/_data/layouts/collection.yml +1 -1
  139. data/lib/starter_web/_data/layouts/default.yml +1 -1
  140. data/lib/starter_web/_data/layouts/home.yml +6 -26
  141. data/lib/starter_web/_data/layouts/news_panel_posts.yml +1 -1
  142. data/lib/starter_web/_data/layouts/page.yml +1 -1
  143. data/lib/starter_web/_data/layouts/post.yml +1 -1
  144. data/lib/starter_web/_data/modules/defaults/attics.yml +1 -1
  145. data/lib/starter_web/_data/modules/defaults/{fam.yml → fab.yml} +8 -7
  146. data/lib/starter_web/_data/modules/defaults/navigator.yml +3 -0
  147. data/lib/starter_web/_data/modules/defaults/rtable.yml +2 -1
  148. data/lib/starter_web/_data/modules/defaults/scoller.yml +33 -0
  149. data/lib/starter_web/_data/modules/defaults/themer.yml +1 -1
  150. data/lib/starter_web/_data/modules/defaults/toccer.yml +5 -4
  151. data/lib/starter_web/_data/modules/{fam.yml → fab.yml} +31 -31
  152. data/lib/starter_web/_data/modules/scroller.yml +2 -2
  153. data/lib/starter_web/_data/modules/toccer.yml +3 -5
  154. data/lib/starter_web/_data/private.yml +3 -1
  155. data/lib/starter_web/_data/resources.yml +48 -34
  156. data/lib/starter_web/_includes/attributes.asciidoc +121 -122
  157. data/lib/starter_web/_plugins/lunr_index.rb +1 -1
  158. data/lib/starter_web/assets/images/pages/roundtrip/500_themes/themes-menu-1280x800.jpg +0 -0
  159. data/lib/starter_web/collections/posts/public/featured/_posts/0000-00-00-welcome-to-j1.adoc.erb +1 -4
  160. data/lib/starter_web/collections/posts/public/featured/_posts/2021-01-01-about-cookies.adoc +2 -2
  161. data/lib/starter_web/collections/posts/public/featured/_posts/2021-02-01-site-generators.adoc +2 -2
  162. data/lib/starter_web/collections/posts/public/featured/_posts/2021-03-03-about-j1.adoc +2 -2
  163. data/lib/starter_web/collections/posts/public/series/_posts/2020-01-01-post-wiki-series.adoc +1 -1
  164. data/lib/starter_web/collections/posts/public/series/_posts/2020-01-02-post-wiki-series.adoc +1 -1
  165. data/lib/starter_web/collections/posts/public/series/_posts/2020-01-03-post-wiki-series.adoc +2 -2
  166. data/lib/starter_web/index.html +1 -1
  167. data/lib/starter_web/package.json +4 -10
  168. data/lib/starter_web/pages/_test_pages/100_side-bar-tester.adoc +244 -0
  169. data/lib/starter_web/pages/_test_pages/_includes/attributes.asciidoc +110 -0
  170. data/lib/starter_web/pages/_test_pages/_includes/documents/100_gistblock.asciidoc +28 -0
  171. data/lib/starter_web/pages/_test_pages/_includes/documents/410_bottom_info.asciidoc +14 -0
  172. data/lib/starter_web/pages/_test_pages/_includes/documents/410_bottom_left_warning.asciidoc +11 -0
  173. data/lib/starter_web/pages/_test_pages/_includes/documents/410_bottom_right_danger.asciidoc +11 -0
  174. data/lib/starter_web/pages/_test_pages/_includes/documents/410_central_success.asciidoc +11 -0
  175. data/lib/starter_web/pages/_test_pages/_includes/documents/410_full_height_left_info.asciidoc +11 -0
  176. data/lib/starter_web/pages/_test_pages/_includes/documents/410_full_height_right_success.asciidoc +11 -0
  177. data/lib/starter_web/pages/_test_pages/_includes/documents/410_table_bs_modal_examples.asciidoc +47 -0
  178. data/lib/starter_web/pages/_test_pages/_includes/documents/410_top_info.asciidoc +11 -0
  179. data/lib/starter_web/pages/_test_pages/_includes/documents/410_top_left_info.asciidoc +11 -0
  180. data/lib/starter_web/pages/_test_pages/_includes/documents/410_top_right_success.asciidoc +11 -0
  181. data/lib/starter_web/pages/_test_pages/_includes/documents/419_advanced_modals_demo.asciidoc +337 -0
  182. data/lib/starter_web/pages/_test_pages/_includes/documents/tables/bs_modal_examples.asciidoc +47 -0
  183. data/lib/starter_web/pages/_test_pages/accordion-01-tester.adoc +220 -0
  184. data/lib/starter_web/pages/_test_pages/accordion-02-tester.adoc +177 -0
  185. data/lib/starter_web/pages/_test_pages/accordion-03-tester.adoc +148 -0
  186. data/lib/starter_web/pages/_test_pages/attribute-changes-01-tester.adoc +226 -0
  187. data/lib/starter_web/pages/_test_pages/backdrop-tester.adoc +109 -0
  188. data/lib/starter_web/pages/_test_pages/button-tester-1.adoc +127 -0
  189. data/lib/starter_web/pages/_test_pages/card-tester.adoc +128 -0
  190. data/lib/starter_web/pages/_test_pages/cookieConsent.adoc +96 -0
  191. data/lib/starter_web/pages/_test_pages/deepl.0.adoc +258 -0
  192. data/lib/starter_web/pages/_test_pages/deepl.adoc +204 -0
  193. data/lib/starter_web/pages/_test_pages/desandro-button.adoc +171 -0
  194. data/lib/starter_web/pages/_test_pages/desandro.adoc +147 -0
  195. data/lib/starter_web/pages/_test_pages/flipcard-1-tester.adoc +308 -0
  196. data/lib/starter_web/pages/_test_pages/formular-01-tester.adoc +167 -0
  197. data/lib/starter_web/pages/_test_pages/formular-02-tester.adoc +727 -0
  198. data/lib/starter_web/pages/_test_pages/google-translate-tester.0.adoc +113 -0
  199. data/lib/starter_web/pages/_test_pages/google-translate-tester.1.adoc +233 -0
  200. data/lib/starter_web/pages/_test_pages/google-translate-tester.3.adoc +149 -0
  201. data/lib/starter_web/pages/_test_pages/google-translate-tester.4.adoc +239 -0
  202. data/lib/starter_web/pages/_test_pages/infinite-scroll-tester-2.adoc +183 -0
  203. data/lib/starter_web/pages/_test_pages/infinite-scroll-tester-3.adoc +235 -0
  204. data/lib/starter_web/pages/_test_pages/infinite-scroll-tester-4.adoc +222 -0
  205. data/lib/starter_web/pages/_test_pages/infinite-scroll-tester-5.adoc +119 -0
  206. data/lib/starter_web/pages/_test_pages/infinite-scroll-tester.1.adoc +236 -0
  207. data/lib/starter_web/pages/_test_pages/infinite-scroll-tester.adoc +225 -0
  208. data/lib/starter_web/pages/_test_pages/list-group-tester.adoc +265 -0
  209. data/lib/starter_web/pages/_test_pages/tictok.adoc +127 -0
  210. data/lib/starter_web/pages/public/about/about_site.adoc +1 -1
  211. data/lib/starter_web/pages/public/asciidoc_skeletons/documentation/000_intro.adoc +1 -1
  212. data/lib/starter_web/pages/public/asciidoc_skeletons/documentation/100_converter.adoc +1 -1
  213. data/lib/starter_web/pages/public/asciidoc_skeletons/documentation/200_themes.adoc +1 -1
  214. data/lib/starter_web/pages/public/asciidoc_skeletons/documentation/documentation.a2p +1 -1
  215. data/lib/starter_web/pages/public/asciidoc_skeletons/documentation/documentation.adoc +1 -1
  216. data/lib/starter_web/pages/public/asciidoc_skeletons/multi-document/multi.adoc +1 -1
  217. data/lib/starter_web/pages/public/asciidoc_skeletons/simple-document/simple.adoc +1 -1
  218. data/lib/starter_web/pages/public/blog/navigator/archive/categoryview.html +26 -5
  219. data/lib/starter_web/pages/public/blog/navigator/archive/dateview.html +3 -3
  220. data/lib/starter_web/pages/public/blog/navigator/archive/tagview.html +3 -3
  221. data/lib/starter_web/pages/public/blog/navigator/archive.html +3 -3
  222. data/lib/starter_web/pages/public/blog/navigator/index.html +1 -1
  223. data/lib/starter_web/pages/public/learn/quickstart.adoc +2 -2
  224. data/lib/starter_web/pages/public/learn/roundtrip/100_present_images.adoc +2 -2
  225. data/lib/starter_web/pages/public/learn/roundtrip/100_present_videos.adoc +2 -2
  226. data/lib/starter_web/pages/public/learn/roundtrip/200_typography.adoc +6 -7
  227. data/lib/starter_web/pages/public/learn/roundtrip/300_icon_fonts.adoc +2 -2
  228. data/lib/starter_web/pages/public/learn/roundtrip/400_asciidoc_extensions.adoc +2 -2
  229. data/lib/starter_web/pages/public/learn/roundtrip/410_bs_modals_extentions.adoc +3 -3
  230. data/lib/starter_web/pages/public/learn/roundtrip/420_responsive_tables_extensions.adoc +2 -2
  231. data/lib/starter_web/pages/public/learn/roundtrip/500_themes.adoc +4 -4
  232. data/lib/starter_web/pages/public/learn/roundtrip/600_quicksearch.adoc +13 -11
  233. data/lib/starter_web/pages/public/learn/roundtrip/_includes/attributes.asciidoc +1 -1
  234. data/lib/starter_web/pages/public/learn/roundtrip/_includes/documents/410_bottom_info.asciidoc +3 -3
  235. data/lib/starter_web/pages/public/learn/roundtrip/_includes/documents/410_bottom_left_warning.asciidoc +1 -1
  236. data/lib/starter_web/pages/public/learn/roundtrip/_includes/documents/410_bottom_right_danger.asciidoc +1 -1
  237. data/lib/starter_web/pages/public/learn/roundtrip/_includes/documents/410_central_success.asciidoc +1 -1
  238. data/lib/starter_web/pages/public/learn/roundtrip/_includes/documents/410_full_height_left_info.asciidoc +1 -1
  239. data/lib/starter_web/pages/public/learn/roundtrip/_includes/documents/410_full_height_right_success.asciidoc +1 -1
  240. data/lib/starter_web/pages/public/learn/roundtrip/_includes/documents/410_top_info.asciidoc +1 -1
  241. data/lib/starter_web/pages/public/learn/roundtrip/_includes/documents/410_top_left_info.asciidoc +1 -1
  242. data/lib/starter_web/pages/public/learn/roundtrip/_includes/documents/410_top_right_success.asciidoc +1 -1
  243. data/lib/starter_web/pages/public/learn/roundtrip/_includes/documents/419_advanced_modals_demo.asciidoc +51 -51
  244. data/lib/starter_web/pages/public/learn/where_to_go.adoc +2 -2
  245. data/lib/starter_web/pages/public/legal/de/100_copyright.adoc +2 -2
  246. data/lib/starter_web/pages/public/legal/de/100_impress.adoc +2 -2
  247. data/lib/starter_web/pages/public/legal/de/300_privacy.adoc +6 -6
  248. data/lib/starter_web/pages/public/legal/de/400_comment_policy.adoc +2 -2
  249. data/lib/starter_web/pages/public/legal/en/100_copyright.adoc +2 -2
  250. data/lib/starter_web/pages/public/legal/en/200_impress.adoc +2 -2
  251. data/lib/starter_web/pages/public/legal/en/300_privacy.adoc +5 -6
  252. data/lib/starter_web/pages/public/legal/en/400_comment_policy.adoc +2 -2
  253. data/lib/starter_web/pages/public/manuals/dropdown-help.adoc +1 -1
  254. data/lib/starter_web/pages/public/panels/intro_panel/_includes/attributes.asciidoc +55 -0
  255. data/lib/starter_web/pages/public/panels/intro_panel/panel.adoc +53 -5
  256. data/lib/starter_web/pages/public/previewer/preview_bootstrap_theme.adoc +1688 -686
  257. data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
  258. data/lib/starter_web/utilsrv/package.json +2 -1
  259. metadata +80 -29
  260. data/assets/themes/j1/core/css/themes/uno-dark/bootstrap.min.css +0 -1
  261. data/assets/themes/j1/core/css/themes/uno-light/bootstrap.min.css +0 -1
  262. data/assets/themes/j1/modules/bmd/css/bootstrap-material-design.css +0 -12177
  263. data/assets/themes/j1/modules/bmd/css/bootstrap-material-design.min.css +0 -8
  264. data/assets/themes/j1/modules/bmd/js/bootstrap-material-design.full.js +0 -6930
  265. data/assets/themes/j1/modules/bmd/js/bootstrap-material-design.js +0 -6936
  266. data/assets/themes/j1/modules/bmd/js/bootstrap-material-design.js.map +0 -1
  267. data/assets/themes/j1/modules/bmd/js/bootstrap-material-design.min.js +0 -1
  268. data/assets/themes/j1/modules/popper/js/popper.js.map +0 -1
  269. data/assets/themes/j1/modules/util/js/domready.js +0 -146
  270. data/lib/starter_web/_data/_defaults/j1_config.1.yml +0 -478
  271. data/lib/starter_web/_data/_defaults/private.default.yml +0 -119
  272. data/lib/starter_web/_data/blocks/defaults/panel.1.yml +0 -256
  273. data/lib/starter_web/_data/blocks/defaults/panel.2.yml +0 -250
@@ -1,2623 +1,1947 @@
1
- /**!
2
- * @fileOverview Kickass library to create and place poppers near their reference elements.
3
- * @version 1.16.1
4
- * @license
5
- * Copyright (c) 2016 Federico Zivolo and contributors
6
- *
7
- * Permission is hereby granted, free of charge, to any person obtaining a copy
8
- * of this software and associated documentation files (the "Software"), to deal
9
- * in the Software without restriction, including without limitation the rights
10
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- * copies of the Software, and to permit persons to whom the Software is
12
- * furnished to do so, subject to the following conditions:
13
- *
14
- * The above copyright notice and this permission notice shall be included in all
15
- * copies or substantial portions of the Software.
16
- *
17
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- * SOFTWARE.
1
+ /**
2
+ * @popperjs/core v2.10.2 - MIT License
24
3
  */
4
+
25
5
  (function (global, factory) {
26
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
27
- typeof define === 'function' && define.amd ? define(factory) :
28
- (global.Popper = factory());
29
- }(this, (function () { 'use strict';
30
-
31
- var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
32
-
33
- var timeoutDuration = function () {
34
- var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
35
- for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
36
- if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
37
- return 1;
38
- }
6
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
7
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
8
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Popper = {}));
9
+ }(this, (function (exports) { 'use strict';
10
+
11
+ // import { isHTMLElement } from './instanceOf';
12
+ function getBoundingClientRect(element, // eslint-disable-next-line unused-imports/no-unused-vars
13
+ includeScale) {
14
+
15
+ var rect = element.getBoundingClientRect();
16
+ var scaleX = 1;
17
+ var scaleY = 1; // FIXME:
18
+ // `offsetWidth` returns an integer while `getBoundingClientRect`
19
+ // returns a float. This results in `scaleX` or `scaleY` being
20
+ // non-1 when it should be for elements that aren't a full pixel in
21
+ // width or height.
22
+ // if (isHTMLElement(element) && includeScale) {
23
+ // const offsetHeight = element.offsetHeight;
24
+ // const offsetWidth = element.offsetWidth;
25
+ // // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
26
+ // // Fallback to 1 in case both values are `0`
27
+ // if (offsetWidth > 0) {
28
+ // scaleX = rect.width / offsetWidth || 1;
29
+ // }
30
+ // if (offsetHeight > 0) {
31
+ // scaleY = rect.height / offsetHeight || 1;
32
+ // }
33
+ // }
34
+
35
+ return {
36
+ width: rect.width / scaleX,
37
+ height: rect.height / scaleY,
38
+ top: rect.top / scaleY,
39
+ right: rect.right / scaleX,
40
+ bottom: rect.bottom / scaleY,
41
+ left: rect.left / scaleX,
42
+ x: rect.left / scaleX,
43
+ y: rect.top / scaleY
44
+ };
39
45
  }
40
- return 0;
41
- }();
42
46
 
43
- function microtaskDebounce(fn) {
44
- var called = false;
45
- return function () {
46
- if (called) {
47
- return;
48
- }
49
- called = true;
50
- window.Promise.resolve().then(function () {
51
- called = false;
52
- fn();
53
- });
54
- };
55
- }
56
-
57
- function taskDebounce(fn) {
58
- var scheduled = false;
59
- return function () {
60
- if (!scheduled) {
61
- scheduled = true;
62
- setTimeout(function () {
63
- scheduled = false;
64
- fn();
65
- }, timeoutDuration);
47
+ function getWindow(node) {
48
+ if (node == null) {
49
+ return window;
66
50
  }
67
- };
68
- }
69
51
 
70
- var supportsMicroTasks = isBrowser && window.Promise;
71
-
72
- /**
73
- * Create a debounced version of a method, that's asynchronously deferred
74
- * but called in the minimum time possible.
75
- *
76
- * @method
77
- * @memberof Popper.Utils
78
- * @argument {Function} fn
79
- * @returns {Function}
80
- */
81
- var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
82
-
83
- /**
84
- * Check if the given variable is a function
85
- * @method
86
- * @memberof Popper.Utils
87
- * @argument {Any} functionToCheck - variable to check
88
- * @returns {Boolean} answer to: is a function?
89
- */
90
- function isFunction(functionToCheck) {
91
- var getType = {};
92
- return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
93
- }
52
+ if (node.toString() !== '[object Window]') {
53
+ var ownerDocument = node.ownerDocument;
54
+ return ownerDocument ? ownerDocument.defaultView || window : window;
55
+ }
94
56
 
95
- /**
96
- * Get CSS computed property of the given element
97
- * @method
98
- * @memberof Popper.Utils
99
- * @argument {Eement} element
100
- * @argument {String} property
101
- */
102
- function getStyleComputedProperty(element, property) {
103
- if (element.nodeType !== 1) {
104
- return [];
57
+ return node;
105
58
  }
106
- // NOTE: 1 DOM access here
107
- var window = element.ownerDocument.defaultView;
108
- var css = window.getComputedStyle(element, null);
109
- return property ? css[property] : css;
110
- }
111
59
 
112
- /**
113
- * Returns the parentNode or the host of the element
114
- * @method
115
- * @memberof Popper.Utils
116
- * @argument {Element} element
117
- * @returns {Element} parent
118
- */
119
- function getParentNode(element) {
120
- if (element.nodeName === 'HTML') {
121
- return element;
60
+ function getWindowScroll(node) {
61
+ var win = getWindow(node);
62
+ var scrollLeft = win.pageXOffset;
63
+ var scrollTop = win.pageYOffset;
64
+ return {
65
+ scrollLeft: scrollLeft,
66
+ scrollTop: scrollTop
67
+ };
122
68
  }
123
- return element.parentNode || element.host;
124
- }
125
69
 
126
- /**
127
- * Returns the scrolling parent of the given element
128
- * @method
129
- * @memberof Popper.Utils
130
- * @argument {Element} element
131
- * @returns {Element} scroll parent
132
- */
133
- function getScrollParent(element) {
134
- // Return body, `getScroll` will take care to get the correct `scrollTop` from it
135
- if (!element) {
136
- return document.body;
70
+ function isElement(node) {
71
+ var OwnElement = getWindow(node).Element;
72
+ return node instanceof OwnElement || node instanceof Element;
137
73
  }
138
74
 
139
- switch (element.nodeName) {
140
- case 'HTML':
141
- case 'BODY':
142
- return element.ownerDocument.body;
143
- case '#document':
144
- return element.body;
75
+ function isHTMLElement(node) {
76
+ var OwnElement = getWindow(node).HTMLElement;
77
+ return node instanceof OwnElement || node instanceof HTMLElement;
145
78
  }
146
79
 
147
- // Firefox want us to check `-x` and `-y` variations as well
148
-
149
- var _getStyleComputedProp = getStyleComputedProperty(element),
150
- overflow = _getStyleComputedProp.overflow,
151
- overflowX = _getStyleComputedProp.overflowX,
152
- overflowY = _getStyleComputedProp.overflowY;
80
+ function isShadowRoot(node) {
81
+ // IE 11 has no ShadowRoot
82
+ if (typeof ShadowRoot === 'undefined') {
83
+ return false;
84
+ }
153
85
 
154
- if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
155
- return element;
86
+ var OwnElement = getWindow(node).ShadowRoot;
87
+ return node instanceof OwnElement || node instanceof ShadowRoot;
156
88
  }
157
89
 
158
- return getScrollParent(getParentNode(element));
159
- }
160
-
161
- /**
162
- * Returns the reference node of the reference object, or the reference object itself.
163
- * @method
164
- * @memberof Popper.Utils
165
- * @param {Element|Object} reference - the reference element (the popper will be relative to this)
166
- * @returns {Element} parent
167
- */
168
- function getReferenceNode(reference) {
169
- return reference && reference.referenceNode ? reference.referenceNode : reference;
170
- }
171
-
172
- var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
173
- var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
90
+ function getHTMLElementScroll(element) {
91
+ return {
92
+ scrollLeft: element.scrollLeft,
93
+ scrollTop: element.scrollTop
94
+ };
95
+ }
174
96
 
175
- /**
176
- * Determines if the browser is Internet Explorer
177
- * @method
178
- * @memberof Popper.Utils
179
- * @param {Number} version to check
180
- * @returns {Boolean} isIE
181
- */
182
- function isIE(version) {
183
- if (version === 11) {
184
- return isIE11;
97
+ function getNodeScroll(node) {
98
+ if (node === getWindow(node) || !isHTMLElement(node)) {
99
+ return getWindowScroll(node);
100
+ } else {
101
+ return getHTMLElementScroll(node);
102
+ }
185
103
  }
186
- if (version === 10) {
187
- return isIE10;
104
+
105
+ function getNodeName(element) {
106
+ return element ? (element.nodeName || '').toLowerCase() : null;
188
107
  }
189
- return isIE11 || isIE10;
190
- }
191
108
 
192
- /**
193
- * Returns the offset parent of the given element
194
- * @method
195
- * @memberof Popper.Utils
196
- * @argument {Element} element
197
- * @returns {Element} offset parent
198
- */
199
- function getOffsetParent(element) {
200
- if (!element) {
201
- return document.documentElement;
109
+ function getDocumentElement(element) {
110
+ // $FlowFixMe[incompatible-return]: assume body is always available
111
+ return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
112
+ element.document) || window.document).documentElement;
202
113
  }
203
114
 
204
- var noOffsetParent = isIE(10) ? document.body : null;
115
+ function getWindowScrollBarX(element) {
116
+ // If <html> has a CSS width greater than the viewport, then this will be
117
+ // incorrect for RTL.
118
+ // Popper 1 is broken in this case and never had a bug report so let's assume
119
+ // it's not an issue. I don't think anyone ever specifies width on <html>
120
+ // anyway.
121
+ // Browsers where the left scrollbar doesn't cause an issue report `0` for
122
+ // this (e.g. Edge 2019, IE11, Safari)
123
+ return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
124
+ }
205
125
 
206
- // NOTE: 1 DOM access here
207
- var offsetParent = element.offsetParent || null;
208
- // Skip hidden elements which don't have an offsetParent
209
- while (offsetParent === noOffsetParent && element.nextElementSibling) {
210
- offsetParent = (element = element.nextElementSibling).offsetParent;
126
+ function getComputedStyle(element) {
127
+ return getWindow(element).getComputedStyle(element);
211
128
  }
212
129
 
213
- var nodeName = offsetParent && offsetParent.nodeName;
130
+ function isScrollParent(element) {
131
+ // Firefox wants us to check `-x` and `-y` variations as well
132
+ var _getComputedStyle = getComputedStyle(element),
133
+ overflow = _getComputedStyle.overflow,
134
+ overflowX = _getComputedStyle.overflowX,
135
+ overflowY = _getComputedStyle.overflowY;
214
136
 
215
- if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
216
- return element ? element.ownerDocument.documentElement : document.documentElement;
137
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
217
138
  }
218
139
 
219
- // .offsetParent will return the closest TH, TD or TABLE in case
220
- // no offsetParent is present, I hate this job...
221
- if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
222
- return getOffsetParent(offsetParent);
223
- }
140
+ function isElementScaled(element) {
141
+ var rect = element.getBoundingClientRect();
142
+ var scaleX = rect.width / element.offsetWidth || 1;
143
+ var scaleY = rect.height / element.offsetHeight || 1;
144
+ return scaleX !== 1 || scaleY !== 1;
145
+ } // Returns the composite rect of an element relative to its offsetParent.
146
+ // Composite means it takes into account transforms as well as layout.
224
147
 
225
- return offsetParent;
226
- }
227
148
 
228
- function isOffsetContainer(element) {
229
- var nodeName = element.nodeName;
149
+ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
150
+ if (isFixed === void 0) {
151
+ isFixed = false;
152
+ }
230
153
 
231
- if (nodeName === 'BODY') {
232
- return false;
233
- }
234
- return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
235
- }
154
+ var isOffsetParentAnElement = isHTMLElement(offsetParent);
155
+ isHTMLElement(offsetParent) && isElementScaled(offsetParent);
156
+ var documentElement = getDocumentElement(offsetParent);
157
+ var rect = getBoundingClientRect(elementOrVirtualElement);
158
+ var scroll = {
159
+ scrollLeft: 0,
160
+ scrollTop: 0
161
+ };
162
+ var offsets = {
163
+ x: 0,
164
+ y: 0
165
+ };
236
166
 
237
- /**
238
- * Finds the root node (document, shadowDOM root) of the given element
239
- * @method
240
- * @memberof Popper.Utils
241
- * @argument {Element} node
242
- * @returns {Element} root node
243
- */
244
- function getRoot(node) {
245
- if (node.parentNode !== null) {
246
- return getRoot(node.parentNode);
247
- }
167
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
168
+ if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
169
+ isScrollParent(documentElement)) {
170
+ scroll = getNodeScroll(offsetParent);
171
+ }
248
172
 
249
- return node;
250
- }
173
+ if (isHTMLElement(offsetParent)) {
174
+ offsets = getBoundingClientRect(offsetParent);
175
+ offsets.x += offsetParent.clientLeft;
176
+ offsets.y += offsetParent.clientTop;
177
+ } else if (documentElement) {
178
+ offsets.x = getWindowScrollBarX(documentElement);
179
+ }
180
+ }
251
181
 
252
- /**
253
- * Finds the offset parent common to the two provided nodes
254
- * @method
255
- * @memberof Popper.Utils
256
- * @argument {Element} element1
257
- * @argument {Element} element2
258
- * @returns {Element} common offset parent
259
- */
260
- function findCommonOffsetParent(element1, element2) {
261
- // This check is needed to avoid errors in case one of the elements isn't defined for any reason
262
- if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
263
- return document.documentElement;
182
+ return {
183
+ x: rect.left + scroll.scrollLeft - offsets.x,
184
+ y: rect.top + scroll.scrollTop - offsets.y,
185
+ width: rect.width,
186
+ height: rect.height
187
+ };
264
188
  }
265
189
 
266
- // Here we make sure to give as "start" the element that comes first in the DOM
267
- var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
268
- var start = order ? element1 : element2;
269
- var end = order ? element2 : element1;
190
+ // means it doesn't take into account transforms.
270
191
 
271
- // Get common ancestor container
272
- var range = document.createRange();
273
- range.setStart(start, 0);
274
- range.setEnd(end, 0);
275
- var commonAncestorContainer = range.commonAncestorContainer;
192
+ function getLayoutRect(element) {
193
+ var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
194
+ // Fixes https://github.com/popperjs/popper-core/issues/1223
276
195
 
277
- // Both nodes are inside #document
196
+ var width = element.offsetWidth;
197
+ var height = element.offsetHeight;
278
198
 
279
- if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
280
- if (isOffsetContainer(commonAncestorContainer)) {
281
- return commonAncestorContainer;
199
+ if (Math.abs(clientRect.width - width) <= 1) {
200
+ width = clientRect.width;
282
201
  }
283
202
 
284
- return getOffsetParent(commonAncestorContainer);
285
- }
203
+ if (Math.abs(clientRect.height - height) <= 1) {
204
+ height = clientRect.height;
205
+ }
286
206
 
287
- // one of the nodes is inside shadowDOM, find which one
288
- var element1root = getRoot(element1);
289
- if (element1root.host) {
290
- return findCommonOffsetParent(element1root.host, element2);
291
- } else {
292
- return findCommonOffsetParent(element1, getRoot(element2).host);
207
+ return {
208
+ x: element.offsetLeft,
209
+ y: element.offsetTop,
210
+ width: width,
211
+ height: height
212
+ };
293
213
  }
294
- }
295
214
 
296
- /**
297
- * Gets the scroll value of the given element in the given side (top and left)
298
- * @method
299
- * @memberof Popper.Utils
300
- * @argument {Element} element
301
- * @argument {String} side `top` or `left`
302
- * @returns {number} amount of scrolled pixels
303
- */
304
- function getScroll(element) {
305
- var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
215
+ function getParentNode(element) {
216
+ if (getNodeName(element) === 'html') {
217
+ return element;
218
+ }
306
219
 
307
- var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
308
- var nodeName = element.nodeName;
220
+ return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
221
+ // $FlowFixMe[incompatible-return]
222
+ // $FlowFixMe[prop-missing]
223
+ element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
224
+ element.parentNode || ( // DOM Element detected
225
+ isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
226
+ // $FlowFixMe[incompatible-call]: HTMLElement is a Node
227
+ getDocumentElement(element) // fallback
309
228
 
310
- if (nodeName === 'BODY' || nodeName === 'HTML') {
311
- var html = element.ownerDocument.documentElement;
312
- var scrollingElement = element.ownerDocument.scrollingElement || html;
313
- return scrollingElement[upperSide];
229
+ );
314
230
  }
315
231
 
316
- return element[upperSide];
317
- }
318
-
319
- /*
320
- * Sum or subtract the element scroll values (left and top) from a given rect object
321
- * @method
322
- * @memberof Popper.Utils
323
- * @param {Object} rect - Rect object you want to change
324
- * @param {HTMLElement} element - The element from the function reads the scroll values
325
- * @param {Boolean} subtract - set to true if you want to subtract the scroll values
326
- * @return {Object} rect - The modifier rect object
327
- */
328
- function includeScroll(rect, element) {
329
- var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
330
-
331
- var scrollTop = getScroll(element, 'top');
332
- var scrollLeft = getScroll(element, 'left');
333
- var modifier = subtract ? -1 : 1;
334
- rect.top += scrollTop * modifier;
335
- rect.bottom += scrollTop * modifier;
336
- rect.left += scrollLeft * modifier;
337
- rect.right += scrollLeft * modifier;
338
- return rect;
339
- }
340
-
341
- /*
342
- * Helper to detect borders of a given element
343
- * @method
344
- * @memberof Popper.Utils
345
- * @param {CSSStyleDeclaration} styles
346
- * Result of `getStyleComputedProperty` on the given element
347
- * @param {String} axis - `x` or `y`
348
- * @return {number} borders - The borders size of the given axis
349
- */
232
+ function getScrollParent(node) {
233
+ if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
234
+ // $FlowFixMe[incompatible-return]: assume body is always available
235
+ return node.ownerDocument.body;
236
+ }
350
237
 
351
- function getBordersSize(styles, axis) {
352
- var sideA = axis === 'x' ? 'Left' : 'Top';
353
- var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
238
+ if (isHTMLElement(node) && isScrollParent(node)) {
239
+ return node;
240
+ }
354
241
 
355
- return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
356
- }
242
+ return getScrollParent(getParentNode(node));
243
+ }
357
244
 
358
- function getSize(axis, body, html, computedStyle) {
359
- return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE(10) ? parseInt(html['offset' + axis]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')]) : 0);
360
- }
245
+ /*
246
+ given a DOM element, return the list of all scroll parents, up the list of ancesors
247
+ until we get to the top window object. This list is what we attach scroll listeners
248
+ to, because if any of these parent elements scroll, we'll need to re-calculate the
249
+ reference element's position.
250
+ */
361
251
 
362
- function getWindowSizes(document) {
363
- var body = document.body;
364
- var html = document.documentElement;
365
- var computedStyle = isIE(10) && getComputedStyle(html);
252
+ function listScrollParents(element, list) {
253
+ var _element$ownerDocumen;
366
254
 
367
- return {
368
- height: getSize('Height', body, html, computedStyle),
369
- width: getSize('Width', body, html, computedStyle)
370
- };
371
- }
255
+ if (list === void 0) {
256
+ list = [];
257
+ }
372
258
 
373
- var classCallCheck = function (instance, Constructor) {
374
- if (!(instance instanceof Constructor)) {
375
- throw new TypeError("Cannot call a class as a function");
259
+ var scrollParent = getScrollParent(element);
260
+ var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
261
+ var win = getWindow(scrollParent);
262
+ var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
263
+ var updatedList = list.concat(target);
264
+ return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
265
+ updatedList.concat(listScrollParents(getParentNode(target)));
376
266
  }
377
- };
378
-
379
- var createClass = function () {
380
- function defineProperties(target, props) {
381
- for (var i = 0; i < props.length; i++) {
382
- var descriptor = props[i];
383
- descriptor.enumerable = descriptor.enumerable || false;
384
- descriptor.configurable = true;
385
- if ("value" in descriptor) descriptor.writable = true;
386
- Object.defineProperty(target, descriptor.key, descriptor);
387
- }
267
+
268
+ function isTableElement(element) {
269
+ return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
388
270
  }
389
271
 
390
- return function (Constructor, protoProps, staticProps) {
391
- if (protoProps) defineProperties(Constructor.prototype, protoProps);
392
- if (staticProps) defineProperties(Constructor, staticProps);
393
- return Constructor;
394
- };
395
- }();
272
+ function getTrueOffsetParent(element) {
273
+ if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
274
+ getComputedStyle(element).position === 'fixed') {
275
+ return null;
276
+ }
396
277
 
278
+ return element.offsetParent;
279
+ } // `.offsetParent` reports `null` for fixed elements, while absolute elements
280
+ // return the containing block
397
281
 
398
282
 
283
+ function getContainingBlock(element) {
284
+ var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1;
285
+ var isIE = navigator.userAgent.indexOf('Trident') !== -1;
399
286
 
287
+ if (isIE && isHTMLElement(element)) {
288
+ // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
289
+ var elementCss = getComputedStyle(element);
400
290
 
401
- var defineProperty = function (obj, key, value) {
402
- if (key in obj) {
403
- Object.defineProperty(obj, key, {
404
- value: value,
405
- enumerable: true,
406
- configurable: true,
407
- writable: true
408
- });
409
- } else {
410
- obj[key] = value;
411
- }
291
+ if (elementCss.position === 'fixed') {
292
+ return null;
293
+ }
294
+ }
412
295
 
413
- return obj;
414
- };
296
+ var currentNode = getParentNode(element);
415
297
 
416
- var _extends = Object.assign || function (target) {
417
- for (var i = 1; i < arguments.length; i++) {
418
- var source = arguments[i];
298
+ while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
299
+ var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
300
+ // create a containing block.
301
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
419
302
 
420
- for (var key in source) {
421
- if (Object.prototype.hasOwnProperty.call(source, key)) {
422
- target[key] = source[key];
303
+ if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
304
+ return currentNode;
305
+ } else {
306
+ currentNode = currentNode.parentNode;
423
307
  }
424
308
  }
425
- }
426
309
 
427
- return target;
428
- };
310
+ return null;
311
+ } // Gets the closest ancestor positioned element. Handles some edge cases,
312
+ // such as table ancestors and cross browser bugs.
429
313
 
430
- /**
431
- * Given element offsets, generate an output similar to getBoundingClientRect
432
- * @method
433
- * @memberof Popper.Utils
434
- * @argument {Object} offsets
435
- * @returns {Object} ClientRect like output
436
- */
437
- function getClientRect(offsets) {
438
- return _extends({}, offsets, {
439
- right: offsets.left + offsets.width,
440
- bottom: offsets.top + offsets.height
441
- });
442
- }
443
314
 
444
- /**
445
- * Get bounding client rect of given element
446
- * @method
447
- * @memberof Popper.Utils
448
- * @param {HTMLElement} element
449
- * @return {Object} client rect
450
- */
451
- function getBoundingClientRect(element) {
452
- var rect = {};
453
-
454
- // IE10 10 FIX: Please, don't ask, the element isn't
455
- // considered in DOM in some circumstances...
456
- // This isn't reproducible in IE10 compatibility mode of IE11
457
- try {
458
- if (isIE(10)) {
459
- rect = element.getBoundingClientRect();
460
- var scrollTop = getScroll(element, 'top');
461
- var scrollLeft = getScroll(element, 'left');
462
- rect.top += scrollTop;
463
- rect.left += scrollLeft;
464
- rect.bottom += scrollTop;
465
- rect.right += scrollLeft;
466
- } else {
467
- rect = element.getBoundingClientRect();
468
- }
469
- } catch (e) {}
315
+ function getOffsetParent(element) {
316
+ var window = getWindow(element);
317
+ var offsetParent = getTrueOffsetParent(element);
470
318
 
471
- var result = {
472
- left: rect.left,
473
- top: rect.top,
474
- width: rect.right - rect.left,
475
- height: rect.bottom - rect.top
476
- };
319
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
320
+ offsetParent = getTrueOffsetParent(offsetParent);
321
+ }
477
322
 
478
- // subtract scrollbar size from sizes
479
- var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
480
- var width = sizes.width || element.clientWidth || result.width;
481
- var height = sizes.height || element.clientHeight || result.height;
323
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
324
+ return window;
325
+ }
482
326
 
483
- var horizScrollbar = element.offsetWidth - width;
484
- var vertScrollbar = element.offsetHeight - height;
327
+ return offsetParent || getContainingBlock(element) || window;
328
+ }
329
+
330
+ var top = 'top';
331
+ var bottom = 'bottom';
332
+ var right = 'right';
333
+ var left = 'left';
334
+ var auto = 'auto';
335
+ var basePlacements = [top, bottom, right, left];
336
+ var start = 'start';
337
+ var end = 'end';
338
+ var clippingParents = 'clippingParents';
339
+ var viewport = 'viewport';
340
+ var popper = 'popper';
341
+ var reference = 'reference';
342
+ var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
343
+ return acc.concat([placement + "-" + start, placement + "-" + end]);
344
+ }, []);
345
+ var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
346
+ return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
347
+ }, []); // modifiers that need to read the DOM
348
+
349
+ var beforeRead = 'beforeRead';
350
+ var read = 'read';
351
+ var afterRead = 'afterRead'; // pure-logic modifiers
352
+
353
+ var beforeMain = 'beforeMain';
354
+ var main = 'main';
355
+ var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
356
+
357
+ var beforeWrite = 'beforeWrite';
358
+ var write = 'write';
359
+ var afterWrite = 'afterWrite';
360
+ var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
361
+
362
+ function order(modifiers) {
363
+ var map = new Map();
364
+ var visited = new Set();
365
+ var result = [];
366
+ modifiers.forEach(function (modifier) {
367
+ map.set(modifier.name, modifier);
368
+ }); // On visiting object, check for its dependencies and visit them recursively
369
+
370
+ function sort(modifier) {
371
+ visited.add(modifier.name);
372
+ var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
373
+ requires.forEach(function (dep) {
374
+ if (!visited.has(dep)) {
375
+ var depModifier = map.get(dep);
376
+
377
+ if (depModifier) {
378
+ sort(depModifier);
379
+ }
380
+ }
381
+ });
382
+ result.push(modifier);
383
+ }
485
384
 
486
- // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
487
- // we make this check conditional for performance reasons
488
- if (horizScrollbar || vertScrollbar) {
489
- var styles = getStyleComputedProperty(element);
490
- horizScrollbar -= getBordersSize(styles, 'x');
491
- vertScrollbar -= getBordersSize(styles, 'y');
385
+ modifiers.forEach(function (modifier) {
386
+ if (!visited.has(modifier.name)) {
387
+ // check for visited object
388
+ sort(modifier);
389
+ }
390
+ });
391
+ return result;
392
+ }
393
+
394
+ function orderModifiers(modifiers) {
395
+ // order based on dependencies
396
+ var orderedModifiers = order(modifiers); // order based on phase
397
+
398
+ return modifierPhases.reduce(function (acc, phase) {
399
+ return acc.concat(orderedModifiers.filter(function (modifier) {
400
+ return modifier.phase === phase;
401
+ }));
402
+ }, []);
403
+ }
404
+
405
+ function debounce(fn) {
406
+ var pending;
407
+ return function () {
408
+ if (!pending) {
409
+ pending = new Promise(function (resolve) {
410
+ Promise.resolve().then(function () {
411
+ pending = undefined;
412
+ resolve(fn());
413
+ });
414
+ });
415
+ }
492
416
 
493
- result.width -= horizScrollbar;
494
- result.height -= vertScrollbar;
417
+ return pending;
418
+ };
495
419
  }
496
420
 
497
- return getClientRect(result);
498
- }
499
-
500
- function getOffsetRectRelativeToArbitraryNode(children, parent) {
501
- var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
421
+ function format(str) {
422
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
423
+ args[_key - 1] = arguments[_key];
424
+ }
502
425
 
503
- var isIE10 = isIE(10);
504
- var isHTML = parent.nodeName === 'HTML';
505
- var childrenRect = getBoundingClientRect(children);
506
- var parentRect = getBoundingClientRect(parent);
507
- var scrollParent = getScrollParent(children);
426
+ return [].concat(args).reduce(function (p, c) {
427
+ return p.replace(/%s/, c);
428
+ }, str);
429
+ }
430
+
431
+ var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
432
+ var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
433
+ var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options'];
434
+ function validateModifiers(modifiers) {
435
+ modifiers.forEach(function (modifier) {
436
+ [].concat(Object.keys(modifier), VALID_PROPERTIES) // IE11-compatible replacement for `new Set(iterable)`
437
+ .filter(function (value, index, self) {
438
+ return self.indexOf(value) === index;
439
+ }).forEach(function (key) {
440
+ switch (key) {
441
+ case 'name':
442
+ if (typeof modifier.name !== 'string') {
443
+ console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', "\"" + String(modifier.name) + "\""));
444
+ }
445
+
446
+ break;
447
+
448
+ case 'enabled':
449
+ if (typeof modifier.enabled !== 'boolean') {
450
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\""));
451
+ }
452
+
453
+ break;
454
+
455
+ case 'phase':
456
+ if (modifierPhases.indexOf(modifier.phase) < 0) {
457
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
458
+ }
459
+
460
+ break;
461
+
462
+ case 'fn':
463
+ if (typeof modifier.fn !== 'function') {
464
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\""));
465
+ }
466
+
467
+ break;
468
+
469
+ case 'effect':
470
+ if (modifier.effect != null && typeof modifier.effect !== 'function') {
471
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
472
+ }
473
+
474
+ break;
475
+
476
+ case 'requires':
477
+ if (modifier.requires != null && !Array.isArray(modifier.requires)) {
478
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
479
+ }
480
+
481
+ break;
482
+
483
+ case 'requiresIfExists':
484
+ if (!Array.isArray(modifier.requiresIfExists)) {
485
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\""));
486
+ }
487
+
488
+ break;
489
+
490
+ case 'options':
491
+ case 'data':
492
+ break;
493
+
494
+ default:
495
+ console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) {
496
+ return "\"" + s + "\"";
497
+ }).join(', ') + "; but \"" + key + "\" was provided.");
498
+ }
499
+
500
+ modifier.requires && modifier.requires.forEach(function (requirement) {
501
+ if (modifiers.find(function (mod) {
502
+ return mod.name === requirement;
503
+ }) == null) {
504
+ console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
505
+ }
506
+ });
507
+ });
508
+ });
509
+ }
508
510
 
509
- var styles = getStyleComputedProperty(parent);
510
- var borderTopWidth = parseFloat(styles.borderTopWidth);
511
- var borderLeftWidth = parseFloat(styles.borderLeftWidth);
511
+ function uniqueBy(arr, fn) {
512
+ var identifiers = new Set();
513
+ return arr.filter(function (item) {
514
+ var identifier = fn(item);
512
515
 
513
- // In cases where the parent is fixed, we must ignore negative scroll in offset calc
514
- if (fixedPosition && isHTML) {
515
- parentRect.top = Math.max(parentRect.top, 0);
516
- parentRect.left = Math.max(parentRect.left, 0);
517
- }
518
- var offsets = getClientRect({
519
- top: childrenRect.top - parentRect.top - borderTopWidth,
520
- left: childrenRect.left - parentRect.left - borderLeftWidth,
521
- width: childrenRect.width,
522
- height: childrenRect.height
523
- });
524
- offsets.marginTop = 0;
525
- offsets.marginLeft = 0;
526
-
527
- // Subtract margins of documentElement in case it's being used as parent
528
- // we do this only on HTML because it's the only element that behaves
529
- // differently when margins are applied to it. The margins are included in
530
- // the box of the documentElement, in the other cases not.
531
- if (!isIE10 && isHTML) {
532
- var marginTop = parseFloat(styles.marginTop);
533
- var marginLeft = parseFloat(styles.marginLeft);
534
-
535
- offsets.top -= borderTopWidth - marginTop;
536
- offsets.bottom -= borderTopWidth - marginTop;
537
- offsets.left -= borderLeftWidth - marginLeft;
538
- offsets.right -= borderLeftWidth - marginLeft;
539
-
540
- // Attach marginTop and marginLeft because in some circumstances we may need them
541
- offsets.marginTop = marginTop;
542
- offsets.marginLeft = marginLeft;
516
+ if (!identifiers.has(identifier)) {
517
+ identifiers.add(identifier);
518
+ return true;
519
+ }
520
+ });
543
521
  }
544
522
 
545
- if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
546
- offsets = includeScroll(offsets, parent);
523
+ function getBasePlacement(placement) {
524
+ return placement.split('-')[0];
547
525
  }
548
526
 
549
- return offsets;
550
- }
527
+ function mergeByName(modifiers) {
528
+ var merged = modifiers.reduce(function (merged, current) {
529
+ var existing = merged[current.name];
530
+ merged[current.name] = existing ? Object.assign({}, existing, current, {
531
+ options: Object.assign({}, existing.options, current.options),
532
+ data: Object.assign({}, existing.data, current.data)
533
+ }) : current;
534
+ return merged;
535
+ }, {}); // IE11 does not support Object.values
551
536
 
552
- function getViewportOffsetRectRelativeToArtbitraryNode(element) {
553
- var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
554
-
555
- var html = element.ownerDocument.documentElement;
556
- var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
557
- var width = Math.max(html.clientWidth, window.innerWidth || 0);
558
- var height = Math.max(html.clientHeight, window.innerHeight || 0);
537
+ return Object.keys(merged).map(function (key) {
538
+ return merged[key];
539
+ });
540
+ }
559
541
 
560
- var scrollTop = !excludeScroll ? getScroll(html) : 0;
561
- var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
542
+ function getViewportRect(element) {
543
+ var win = getWindow(element);
544
+ var html = getDocumentElement(element);
545
+ var visualViewport = win.visualViewport;
546
+ var width = html.clientWidth;
547
+ var height = html.clientHeight;
548
+ var x = 0;
549
+ var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
550
+ // can be obscured underneath it.
551
+ // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
552
+ // if it isn't open, so if this isn't available, the popper will be detected
553
+ // to overflow the bottom of the screen too early.
554
+
555
+ if (visualViewport) {
556
+ width = visualViewport.width;
557
+ height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
558
+ // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
559
+ // errors due to floating point numbers, so we need to check precision.
560
+ // Safari returns a number <= 0, usually < -1 when pinch-zoomed
561
+ // Feature detection fails in mobile emulation mode in Chrome.
562
+ // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
563
+ // 0.001
564
+ // Fallback here: "Not Safari" userAgent
565
+
566
+ if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
567
+ x = visualViewport.offsetLeft;
568
+ y = visualViewport.offsetTop;
569
+ }
570
+ }
562
571
 
563
- var offset = {
564
- top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
565
- left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
566
- width: width,
567
- height: height
568
- };
572
+ return {
573
+ width: width,
574
+ height: height,
575
+ x: x + getWindowScrollBarX(element),
576
+ y: y
577
+ };
578
+ }
569
579
 
570
- return getClientRect(offset);
571
- }
580
+ var max = Math.max;
581
+ var min = Math.min;
582
+ var round = Math.round;
572
583
 
573
- /**
574
- * Check if the given element is fixed or is inside a fixed parent
575
- * @method
576
- * @memberof Popper.Utils
577
- * @argument {Element} element
578
- * @argument {Element} customContainer
579
- * @returns {Boolean} answer to "isFixed?"
580
- */
581
- function isFixed(element) {
582
- var nodeName = element.nodeName;
583
- if (nodeName === 'BODY' || nodeName === 'HTML') {
584
- return false;
585
- }
586
- if (getStyleComputedProperty(element, 'position') === 'fixed') {
587
- return true;
588
- }
589
- var parentNode = getParentNode(element);
590
- if (!parentNode) {
591
- return false;
592
- }
593
- return isFixed(parentNode);
594
- }
584
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable
595
585
 
596
- /**
597
- * Finds the first parent of an element that has a transformed property defined
598
- * @method
599
- * @memberof Popper.Utils
600
- * @argument {Element} element
601
- * @returns {Element} first transformed parent or documentElement
602
- */
586
+ function getDocumentRect(element) {
587
+ var _element$ownerDocumen;
603
588
 
604
- function getFixedPositionOffsetParent(element) {
605
- // This check is needed to avoid errors in case one of the elements isn't defined for any reason
606
- if (!element || !element.parentElement || isIE()) {
607
- return document.documentElement;
608
- }
609
- var el = element.parentElement;
610
- while (el && getStyleComputedProperty(el, 'transform') === 'none') {
611
- el = el.parentElement;
612
- }
613
- return el || document.documentElement;
614
- }
589
+ var html = getDocumentElement(element);
590
+ var winScroll = getWindowScroll(element);
591
+ var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
592
+ var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
593
+ var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
594
+ var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
595
+ var y = -winScroll.scrollTop;
615
596
 
616
- /**
617
- * Computed the boundaries limits and return them
618
- * @method
619
- * @memberof Popper.Utils
620
- * @param {HTMLElement} popper
621
- * @param {HTMLElement} reference
622
- * @param {number} padding
623
- * @param {HTMLElement} boundariesElement - Element used to define the boundaries
624
- * @param {Boolean} fixedPosition - Is in fixed position mode
625
- * @returns {Object} Coordinates of the boundaries
626
- */
627
- function getBoundaries(popper, reference, padding, boundariesElement) {
628
- var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
629
-
630
- // NOTE: 1 DOM access here
631
-
632
- var boundaries = { top: 0, left: 0 };
633
- var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
634
-
635
- // Handle viewport case
636
- if (boundariesElement === 'viewport') {
637
- boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
638
- } else {
639
- // Handle other cases based on DOM element used as boundaries
640
- var boundariesNode = void 0;
641
- if (boundariesElement === 'scrollParent') {
642
- boundariesNode = getScrollParent(getParentNode(reference));
643
- if (boundariesNode.nodeName === 'BODY') {
644
- boundariesNode = popper.ownerDocument.documentElement;
645
- }
646
- } else if (boundariesElement === 'window') {
647
- boundariesNode = popper.ownerDocument.documentElement;
648
- } else {
649
- boundariesNode = boundariesElement;
597
+ if (getComputedStyle(body || html).direction === 'rtl') {
598
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
650
599
  }
651
600
 
652
- var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
601
+ return {
602
+ width: width,
603
+ height: height,
604
+ x: x,
605
+ y: y
606
+ };
607
+ }
653
608
 
654
- // In case of HTML, we need a different computation
655
- if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
656
- var _getWindowSizes = getWindowSizes(popper.ownerDocument),
657
- height = _getWindowSizes.height,
658
- width = _getWindowSizes.width;
609
+ function contains(parent, child) {
610
+ var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
659
611
 
660
- boundaries.top += offsets.top - offsets.marginTop;
661
- boundaries.bottom = height + offsets.top;
662
- boundaries.left += offsets.left - offsets.marginLeft;
663
- boundaries.right = width + offsets.left;
664
- } else {
665
- // for all the other DOM elements, this one is good
666
- boundaries = offsets;
667
- }
668
- }
612
+ if (parent.contains(child)) {
613
+ return true;
614
+ } // then fallback to custom implementation with Shadow DOM support
615
+ else if (rootNode && isShadowRoot(rootNode)) {
616
+ var next = child;
669
617
 
670
- // Add paddings
671
- padding = padding || 0;
672
- var isPaddingNumber = typeof padding === 'number';
673
- boundaries.left += isPaddingNumber ? padding : padding.left || 0;
674
- boundaries.top += isPaddingNumber ? padding : padding.top || 0;
675
- boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
676
- boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
618
+ do {
619
+ if (next && parent.isSameNode(next)) {
620
+ return true;
621
+ } // $FlowFixMe[prop-missing]: need a better way to handle this...
677
622
 
678
- return boundaries;
679
- }
680
623
 
681
- function getArea(_ref) {
682
- var width = _ref.width,
683
- height = _ref.height;
624
+ next = next.parentNode || next.host;
625
+ } while (next);
626
+ } // Give up, the result is false
684
627
 
685
- return width * height;
686
- }
687
628
 
688
- /**
689
- * Utility used to transform the `auto` placement to the placement with more
690
- * available space.
691
- * @method
692
- * @memberof Popper.Utils
693
- * @argument {Object} data - The data object generated by update method
694
- * @argument {Object} options - Modifiers configuration and options
695
- * @returns {Object} The data object, properly modified
696
- */
697
- function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
698
- var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
629
+ return false;
630
+ }
699
631
 
700
- if (placement.indexOf('auto') === -1) {
701
- return placement;
632
+ function rectToClientRect(rect) {
633
+ return Object.assign({}, rect, {
634
+ left: rect.x,
635
+ top: rect.y,
636
+ right: rect.x + rect.width,
637
+ bottom: rect.y + rect.height
638
+ });
702
639
  }
703
640
 
704
- var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
705
-
706
- var rects = {
707
- top: {
708
- width: boundaries.width,
709
- height: refRect.top - boundaries.top
710
- },
711
- right: {
712
- width: boundaries.right - refRect.right,
713
- height: boundaries.height
714
- },
715
- bottom: {
716
- width: boundaries.width,
717
- height: boundaries.bottom - refRect.bottom
718
- },
719
- left: {
720
- width: refRect.left - boundaries.left,
721
- height: boundaries.height
722
- }
723
- };
641
+ function getInnerBoundingClientRect(element) {
642
+ var rect = getBoundingClientRect(element);
643
+ rect.top = rect.top + element.clientTop;
644
+ rect.left = rect.left + element.clientLeft;
645
+ rect.bottom = rect.top + element.clientHeight;
646
+ rect.right = rect.left + element.clientWidth;
647
+ rect.width = element.clientWidth;
648
+ rect.height = element.clientHeight;
649
+ rect.x = rect.left;
650
+ rect.y = rect.top;
651
+ return rect;
652
+ }
724
653
 
725
- var sortedAreas = Object.keys(rects).map(function (key) {
726
- return _extends({
727
- key: key
728
- }, rects[key], {
729
- area: getArea(rects[key])
730
- });
731
- }).sort(function (a, b) {
732
- return b.area - a.area;
733
- });
654
+ function getClientRectFromMixedType(element, clippingParent) {
655
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
656
+ } // A "clipping parent" is an overflowable container with the characteristic of
657
+ // clipping (or hiding) overflowing elements with a position different from
658
+ // `initial`
734
659
 
735
- var filteredAreas = sortedAreas.filter(function (_ref2) {
736
- var width = _ref2.width,
737
- height = _ref2.height;
738
- return width >= popper.clientWidth && height >= popper.clientHeight;
739
- });
740
660
 
741
- var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
661
+ function getClippingParents(element) {
662
+ var clippingParents = listScrollParents(getParentNode(element));
663
+ var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
664
+ var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
742
665
 
743
- var variation = placement.split('-')[1];
666
+ if (!isElement(clipperElement)) {
667
+ return [];
668
+ } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
744
669
 
745
- return computedPlacement + (variation ? '-' + variation : '');
746
- }
747
670
 
748
- /**
749
- * Get offsets to the reference element
750
- * @method
751
- * @memberof Popper.Utils
752
- * @param {Object} state
753
- * @param {Element} popper - the popper element
754
- * @param {Element} reference - the reference element (the popper will be relative to this)
755
- * @param {Element} fixedPosition - is in fixed position mode
756
- * @returns {Object} An object containing the offsets which will be applied to the popper
757
- */
758
- function getReferenceOffsets(state, popper, reference) {
759
- var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
671
+ return clippingParents.filter(function (clippingParent) {
672
+ return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
673
+ });
674
+ } // Gets the maximum area that the element is visible in due to any number of
675
+ // clipping parents
676
+
677
+
678
+ function getClippingRect(element, boundary, rootBoundary) {
679
+ var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
680
+ var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
681
+ var firstClippingParent = clippingParents[0];
682
+ var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
683
+ var rect = getClientRectFromMixedType(element, clippingParent);
684
+ accRect.top = max(rect.top, accRect.top);
685
+ accRect.right = min(rect.right, accRect.right);
686
+ accRect.bottom = min(rect.bottom, accRect.bottom);
687
+ accRect.left = max(rect.left, accRect.left);
688
+ return accRect;
689
+ }, getClientRectFromMixedType(element, firstClippingParent));
690
+ clippingRect.width = clippingRect.right - clippingRect.left;
691
+ clippingRect.height = clippingRect.bottom - clippingRect.top;
692
+ clippingRect.x = clippingRect.left;
693
+ clippingRect.y = clippingRect.top;
694
+ return clippingRect;
695
+ }
696
+
697
+ function getVariation(placement) {
698
+ return placement.split('-')[1];
699
+ }
700
+
701
+ function getMainAxisFromPlacement(placement) {
702
+ return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
703
+ }
704
+
705
+ function computeOffsets(_ref) {
706
+ var reference = _ref.reference,
707
+ element = _ref.element,
708
+ placement = _ref.placement;
709
+ var basePlacement = placement ? getBasePlacement(placement) : null;
710
+ var variation = placement ? getVariation(placement) : null;
711
+ var commonX = reference.x + reference.width / 2 - element.width / 2;
712
+ var commonY = reference.y + reference.height / 2 - element.height / 2;
713
+ var offsets;
714
+
715
+ switch (basePlacement) {
716
+ case top:
717
+ offsets = {
718
+ x: commonX,
719
+ y: reference.y - element.height
720
+ };
721
+ break;
760
722
 
761
- var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
762
- return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
763
- }
723
+ case bottom:
724
+ offsets = {
725
+ x: commonX,
726
+ y: reference.y + reference.height
727
+ };
728
+ break;
764
729
 
765
- /**
766
- * Get the outer sizes of the given element (offset size + margins)
767
- * @method
768
- * @memberof Popper.Utils
769
- * @argument {Element} element
770
- * @returns {Object} object containing width and height properties
771
- */
772
- function getOuterSizes(element) {
773
- var window = element.ownerDocument.defaultView;
774
- var styles = window.getComputedStyle(element);
775
- var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
776
- var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
777
- var result = {
778
- width: element.offsetWidth + y,
779
- height: element.offsetHeight + x
780
- };
781
- return result;
782
- }
730
+ case right:
731
+ offsets = {
732
+ x: reference.x + reference.width,
733
+ y: commonY
734
+ };
735
+ break;
783
736
 
784
- /**
785
- * Get the opposite placement of the given one
786
- * @method
787
- * @memberof Popper.Utils
788
- * @argument {String} placement
789
- * @returns {String} flipped placement
790
- */
791
- function getOppositePlacement(placement) {
792
- var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
793
- return placement.replace(/left|right|bottom|top/g, function (matched) {
794
- return hash[matched];
795
- });
796
- }
737
+ case left:
738
+ offsets = {
739
+ x: reference.x - element.width,
740
+ y: commonY
741
+ };
742
+ break;
797
743
 
798
- /**
799
- * Get offsets to the popper
800
- * @method
801
- * @memberof Popper.Utils
802
- * @param {Object} position - CSS position the Popper will get applied
803
- * @param {HTMLElement} popper - the popper element
804
- * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
805
- * @param {String} placement - one of the valid placement options
806
- * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
807
- */
808
- function getPopperOffsets(popper, referenceOffsets, placement) {
809
- placement = placement.split('-')[0];
744
+ default:
745
+ offsets = {
746
+ x: reference.x,
747
+ y: reference.y
748
+ };
749
+ }
810
750
 
811
- // Get popper node sizes
812
- var popperRect = getOuterSizes(popper);
751
+ var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
813
752
 
814
- // Add position, width and height to our offsets object
815
- var popperOffsets = {
816
- width: popperRect.width,
817
- height: popperRect.height
818
- };
753
+ if (mainAxis != null) {
754
+ var len = mainAxis === 'y' ? 'height' : 'width';
819
755
 
820
- // depending by the popper placement we have to compute its offsets slightly differently
821
- var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
822
- var mainSide = isHoriz ? 'top' : 'left';
823
- var secondarySide = isHoriz ? 'left' : 'top';
824
- var measurement = isHoriz ? 'height' : 'width';
825
- var secondaryMeasurement = !isHoriz ? 'height' : 'width';
826
-
827
- popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
828
- if (placement === secondarySide) {
829
- popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
830
- } else {
831
- popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
832
- }
756
+ switch (variation) {
757
+ case start:
758
+ offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
759
+ break;
833
760
 
834
- return popperOffsets;
835
- }
761
+ case end:
762
+ offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
763
+ break;
764
+ }
765
+ }
836
766
 
837
- /**
838
- * Mimics the `find` method of Array
839
- * @method
840
- * @memberof Popper.Utils
841
- * @argument {Array} arr
842
- * @argument prop
843
- * @argument value
844
- * @returns index or -1
845
- */
846
- function find(arr, check) {
847
- // use native find if supported
848
- if (Array.prototype.find) {
849
- return arr.find(check);
767
+ return offsets;
850
768
  }
851
769
 
852
- // use `filter` to obtain the same behavior of `find`
853
- return arr.filter(check)[0];
854
- }
855
-
856
- /**
857
- * Return the index of the matching object
858
- * @method
859
- * @memberof Popper.Utils
860
- * @argument {Array} arr
861
- * @argument prop
862
- * @argument value
863
- * @returns index or -1
864
- */
865
- function findIndex(arr, prop, value) {
866
- // use native findIndex if supported
867
- if (Array.prototype.findIndex) {
868
- return arr.findIndex(function (cur) {
869
- return cur[prop] === value;
870
- });
770
+ function getFreshSideObject() {
771
+ return {
772
+ top: 0,
773
+ right: 0,
774
+ bottom: 0,
775
+ left: 0
776
+ };
871
777
  }
872
778
 
873
- // use `find` + `indexOf` if `findIndex` isn't supported
874
- var match = find(arr, function (obj) {
875
- return obj[prop] === value;
876
- });
877
- return arr.indexOf(match);
878
- }
779
+ function mergePaddingObject(paddingObject) {
780
+ return Object.assign({}, getFreshSideObject(), paddingObject);
781
+ }
879
782
 
880
- /**
881
- * Loop trough the list of modifiers and run them in order,
882
- * each of them will then edit the data object.
883
- * @method
884
- * @memberof Popper.Utils
885
- * @param {dataObject} data
886
- * @param {Array} modifiers
887
- * @param {String} ends - Optional modifier name used as stopper
888
- * @returns {dataObject}
889
- */
890
- function runModifiers(modifiers, data, ends) {
891
- var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
783
+ function expandToHashMap(value, keys) {
784
+ return keys.reduce(function (hashMap, key) {
785
+ hashMap[key] = value;
786
+ return hashMap;
787
+ }, {});
788
+ }
892
789
 
893
- modifiersToRun.forEach(function (modifier) {
894
- if (modifier['function']) {
895
- // eslint-disable-line dot-notation
896
- console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
897
- }
898
- var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
899
- if (modifier.enabled && isFunction(fn)) {
900
- // Add properties to offsets to make them a complete clientRect object
901
- // we do this before each modifier to make sure the previous one doesn't
902
- // mess with these values
903
- data.offsets.popper = getClientRect(data.offsets.popper);
904
- data.offsets.reference = getClientRect(data.offsets.reference);
905
-
906
- data = fn(data, modifier);
790
+ function detectOverflow(state, options) {
791
+ if (options === void 0) {
792
+ options = {};
907
793
  }
908
- });
909
794
 
910
- return data;
911
- }
795
+ var _options = options,
796
+ _options$placement = _options.placement,
797
+ placement = _options$placement === void 0 ? state.placement : _options$placement,
798
+ _options$boundary = _options.boundary,
799
+ boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
800
+ _options$rootBoundary = _options.rootBoundary,
801
+ rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
802
+ _options$elementConte = _options.elementContext,
803
+ elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
804
+ _options$altBoundary = _options.altBoundary,
805
+ altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
806
+ _options$padding = _options.padding,
807
+ padding = _options$padding === void 0 ? 0 : _options$padding;
808
+ var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
809
+ var altContext = elementContext === popper ? reference : popper;
810
+ var popperRect = state.rects.popper;
811
+ var element = state.elements[altBoundary ? altContext : elementContext];
812
+ var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
813
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
814
+ var popperOffsets = computeOffsets({
815
+ reference: referenceClientRect,
816
+ element: popperRect,
817
+ strategy: 'absolute',
818
+ placement: placement
819
+ });
820
+ var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
821
+ var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
822
+ // 0 or negative = within the clipping rect
823
+
824
+ var overflowOffsets = {
825
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
826
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
827
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
828
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
829
+ };
830
+ var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
831
+
832
+ if (elementContext === popper && offsetData) {
833
+ var offset = offsetData[placement];
834
+ Object.keys(overflowOffsets).forEach(function (key) {
835
+ var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
836
+ var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
837
+ overflowOffsets[key] += offset[axis] * multiply;
838
+ });
839
+ }
912
840
 
913
- /**
914
- * Updates the position of the popper, computing the new offsets and applying
915
- * the new style.<br />
916
- * Prefer `scheduleUpdate` over `update` because of performance reasons.
917
- * @method
918
- * @memberof Popper
919
- */
920
- function update() {
921
- // if popper is destroyed, don't perform any further update
922
- if (this.state.isDestroyed) {
923
- return;
841
+ return overflowOffsets;
924
842
  }
925
843
 
926
- var data = {
927
- instance: this,
928
- styles: {},
929
- arrowStyles: {},
930
- attributes: {},
931
- flipped: false,
932
- offsets: {}
844
+ var INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';
845
+ var INFINITE_LOOP_ERROR = 'Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.';
846
+ var DEFAULT_OPTIONS = {
847
+ placement: 'bottom',
848
+ modifiers: [],
849
+ strategy: 'absolute'
933
850
  };
934
851
 
935
- // compute reference element offsets
936
- data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
852
+ function areValidElements() {
853
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
854
+ args[_key] = arguments[_key];
855
+ }
937
856
 
938
- // compute auto placement, store placement inside the data object,
939
- // modifiers will be able to edit `placement` if needed
940
- // and refer to originalPlacement to know the original value
941
- data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
857
+ return !args.some(function (element) {
858
+ return !(element && typeof element.getBoundingClientRect === 'function');
859
+ });
860
+ }
942
861
 
943
- // store the computed placement inside `originalPlacement`
944
- data.originalPlacement = data.placement;
862
+ function popperGenerator(generatorOptions) {
863
+ if (generatorOptions === void 0) {
864
+ generatorOptions = {};
865
+ }
945
866
 
946
- data.positionFixed = this.options.positionFixed;
867
+ var _generatorOptions = generatorOptions,
868
+ _generatorOptions$def = _generatorOptions.defaultModifiers,
869
+ defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
870
+ _generatorOptions$def2 = _generatorOptions.defaultOptions,
871
+ defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
872
+ return function createPopper(reference, popper, options) {
873
+ if (options === void 0) {
874
+ options = defaultOptions;
875
+ }
947
876
 
948
- // compute the popper offsets
949
- data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
877
+ var state = {
878
+ placement: 'bottom',
879
+ orderedModifiers: [],
880
+ options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
881
+ modifiersData: {},
882
+ elements: {
883
+ reference: reference,
884
+ popper: popper
885
+ },
886
+ attributes: {},
887
+ styles: {}
888
+ };
889
+ var effectCleanupFns = [];
890
+ var isDestroyed = false;
891
+ var instance = {
892
+ state: state,
893
+ setOptions: function setOptions(setOptionsAction) {
894
+ var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
895
+ cleanupModifierEffects();
896
+ state.options = Object.assign({}, defaultOptions, state.options, options);
897
+ state.scrollParents = {
898
+ reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
899
+ popper: listScrollParents(popper)
900
+ }; // Orders the modifiers based on their dependencies and `phase`
901
+ // properties
902
+
903
+ var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
904
+
905
+ state.orderedModifiers = orderedModifiers.filter(function (m) {
906
+ return m.enabled;
907
+ }); // Validate the provided modifiers so that the consumer will get warned
908
+ // if one of the modifiers is invalid for any reason
909
+
910
+ {
911
+ var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) {
912
+ var name = _ref.name;
913
+ return name;
914
+ });
915
+ validateModifiers(modifiers);
916
+
917
+ if (getBasePlacement(state.options.placement) === auto) {
918
+ var flipModifier = state.orderedModifiers.find(function (_ref2) {
919
+ var name = _ref2.name;
920
+ return name === 'flip';
921
+ });
922
+
923
+ if (!flipModifier) {
924
+ console.error(['Popper: "auto" placements require the "flip" modifier be', 'present and enabled to work.'].join(' '));
925
+ }
926
+ }
927
+
928
+ var _getComputedStyle = getComputedStyle(popper),
929
+ marginTop = _getComputedStyle.marginTop,
930
+ marginRight = _getComputedStyle.marginRight,
931
+ marginBottom = _getComputedStyle.marginBottom,
932
+ marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can
933
+ // cause bugs with positioning, so we'll warn the consumer
934
+
935
+
936
+ if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {
937
+ return parseFloat(margin);
938
+ })) {
939
+ console.warn(['Popper: CSS "margin" styles cannot be used to apply padding', 'between the popper and its reference element or boundary.', 'To replicate margin, use the `offset` modifier, as well as', 'the `padding` option in the `preventOverflow` and `flip`', 'modifiers.'].join(' '));
940
+ }
941
+ }
942
+
943
+ runModifierEffects();
944
+ return instance.update();
945
+ },
946
+ // Sync update – it will always be executed, even if not necessary. This
947
+ // is useful for low frequency updates where sync behavior simplifies the
948
+ // logic.
949
+ // For high frequency updates (e.g. `resize` and `scroll` events), always
950
+ // prefer the async Popper#update method
951
+ forceUpdate: function forceUpdate() {
952
+ if (isDestroyed) {
953
+ return;
954
+ }
955
+
956
+ var _state$elements = state.elements,
957
+ reference = _state$elements.reference,
958
+ popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
959
+ // anymore
960
+
961
+ if (!areValidElements(reference, popper)) {
962
+ {
963
+ console.error(INVALID_ELEMENT_ERROR);
964
+ }
965
+
966
+ return;
967
+ } // Store the reference and popper rects to be read by modifiers
968
+
969
+
970
+ state.rects = {
971
+ reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
972
+ popper: getLayoutRect(popper)
973
+ }; // Modifiers have the ability to reset the current update cycle. The
974
+ // most common use case for this is the `flip` modifier changing the
975
+ // placement, which then needs to re-run all the modifiers, because the
976
+ // logic was previously ran for the previous placement and is therefore
977
+ // stale/incorrect
978
+
979
+ state.reset = false;
980
+ state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
981
+ // is filled with the initial data specified by the modifier. This means
982
+ // it doesn't persist and is fresh on each update.
983
+ // To ensure persistent data, use `${name}#persistent`
984
+
985
+ state.orderedModifiers.forEach(function (modifier) {
986
+ return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
987
+ });
988
+ var __debug_loops__ = 0;
989
+
990
+ for (var index = 0; index < state.orderedModifiers.length; index++) {
991
+ {
992
+ __debug_loops__ += 1;
993
+
994
+ if (__debug_loops__ > 100) {
995
+ console.error(INFINITE_LOOP_ERROR);
996
+ break;
997
+ }
998
+ }
999
+
1000
+ if (state.reset === true) {
1001
+ state.reset = false;
1002
+ index = -1;
1003
+ continue;
1004
+ }
1005
+
1006
+ var _state$orderedModifie = state.orderedModifiers[index],
1007
+ fn = _state$orderedModifie.fn,
1008
+ _state$orderedModifie2 = _state$orderedModifie.options,
1009
+ _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
1010
+ name = _state$orderedModifie.name;
1011
+
1012
+ if (typeof fn === 'function') {
1013
+ state = fn({
1014
+ state: state,
1015
+ options: _options,
1016
+ name: name,
1017
+ instance: instance
1018
+ }) || state;
1019
+ }
1020
+ }
1021
+ },
1022
+ // Async and optimistically optimized update – it will not be executed if
1023
+ // not necessary (debounced to run at most once-per-tick)
1024
+ update: debounce(function () {
1025
+ return new Promise(function (resolve) {
1026
+ instance.forceUpdate();
1027
+ resolve(state);
1028
+ });
1029
+ }),
1030
+ destroy: function destroy() {
1031
+ cleanupModifierEffects();
1032
+ isDestroyed = true;
1033
+ }
1034
+ };
1035
+
1036
+ if (!areValidElements(reference, popper)) {
1037
+ {
1038
+ console.error(INVALID_ELEMENT_ERROR);
1039
+ }
1040
+
1041
+ return instance;
1042
+ }
950
1043
 
951
- data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
1044
+ instance.setOptions(options).then(function (state) {
1045
+ if (!isDestroyed && options.onFirstUpdate) {
1046
+ options.onFirstUpdate(state);
1047
+ }
1048
+ }); // Modifiers have the ability to execute arbitrary code before the first
1049
+ // update cycle runs. They will be executed in the same order as the update
1050
+ // cycle. This is useful when a modifier adds some persistent data that
1051
+ // other modifiers need to use, but the modifier is run after the dependent
1052
+ // one.
1053
+
1054
+ function runModifierEffects() {
1055
+ state.orderedModifiers.forEach(function (_ref3) {
1056
+ var name = _ref3.name,
1057
+ _ref3$options = _ref3.options,
1058
+ options = _ref3$options === void 0 ? {} : _ref3$options,
1059
+ effect = _ref3.effect;
1060
+
1061
+ if (typeof effect === 'function') {
1062
+ var cleanupFn = effect({
1063
+ state: state,
1064
+ name: name,
1065
+ instance: instance,
1066
+ options: options
1067
+ });
1068
+
1069
+ var noopFn = function noopFn() {};
1070
+
1071
+ effectCleanupFns.push(cleanupFn || noopFn);
1072
+ }
1073
+ });
1074
+ }
952
1075
 
953
- // run the modifiers
954
- data = runModifiers(this.modifiers, data);
1076
+ function cleanupModifierEffects() {
1077
+ effectCleanupFns.forEach(function (fn) {
1078
+ return fn();
1079
+ });
1080
+ effectCleanupFns = [];
1081
+ }
955
1082
 
956
- // the first `update` will call `onCreate` callback
957
- // the other ones will call `onUpdate` callback
958
- if (!this.state.isCreated) {
959
- this.state.isCreated = true;
960
- this.options.onCreate(data);
961
- } else {
962
- this.options.onUpdate(data);
1083
+ return instance;
1084
+ };
963
1085
  }
964
- }
965
1086
 
966
- /**
967
- * Helper used to know if the given modifier is enabled.
968
- * @method
969
- * @memberof Popper.Utils
970
- * @returns {Boolean}
971
- */
972
- function isModifierEnabled(modifiers, modifierName) {
973
- return modifiers.some(function (_ref) {
974
- var name = _ref.name,
975
- enabled = _ref.enabled;
976
- return enabled && name === modifierName;
977
- });
978
- }
1087
+ var passive = {
1088
+ passive: true
1089
+ };
979
1090
 
980
- /**
981
- * Get the prefixed supported property name
982
- * @method
983
- * @memberof Popper.Utils
984
- * @argument {String} property (camelCase)
985
- * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
986
- */
987
- function getSupportedPropertyName(property) {
988
- var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
989
- var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
990
-
991
- for (var i = 0; i < prefixes.length; i++) {
992
- var prefix = prefixes[i];
993
- var toCheck = prefix ? '' + prefix + upperProp : property;
994
- if (typeof document.body.style[toCheck] !== 'undefined') {
995
- return toCheck;
1091
+ function effect$2(_ref) {
1092
+ var state = _ref.state,
1093
+ instance = _ref.instance,
1094
+ options = _ref.options;
1095
+ var _options$scroll = options.scroll,
1096
+ scroll = _options$scroll === void 0 ? true : _options$scroll,
1097
+ _options$resize = options.resize,
1098
+ resize = _options$resize === void 0 ? true : _options$resize;
1099
+ var window = getWindow(state.elements.popper);
1100
+ var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
1101
+
1102
+ if (scroll) {
1103
+ scrollParents.forEach(function (scrollParent) {
1104
+ scrollParent.addEventListener('scroll', instance.update, passive);
1105
+ });
996
1106
  }
997
- }
998
- return null;
999
- }
1000
1107
 
1001
- /**
1002
- * Destroys the popper.
1003
- * @method
1004
- * @memberof Popper
1005
- */
1006
- function destroy() {
1007
- this.state.isDestroyed = true;
1008
-
1009
- // touch DOM only if `applyStyle` modifier is enabled
1010
- if (isModifierEnabled(this.modifiers, 'applyStyle')) {
1011
- this.popper.removeAttribute('x-placement');
1012
- this.popper.style.position = '';
1013
- this.popper.style.top = '';
1014
- this.popper.style.left = '';
1015
- this.popper.style.right = '';
1016
- this.popper.style.bottom = '';
1017
- this.popper.style.willChange = '';
1018
- this.popper.style[getSupportedPropertyName('transform')] = '';
1019
- }
1020
-
1021
- this.disableEventListeners();
1108
+ if (resize) {
1109
+ window.addEventListener('resize', instance.update, passive);
1110
+ }
1022
1111
 
1023
- // remove the popper if user explicitly asked for the deletion on destroy
1024
- // do not use `remove` because IE11 doesn't support it
1025
- if (this.options.removeOnDestroy) {
1026
- this.popper.parentNode.removeChild(this.popper);
1027
- }
1028
- return this;
1029
- }
1112
+ return function () {
1113
+ if (scroll) {
1114
+ scrollParents.forEach(function (scrollParent) {
1115
+ scrollParent.removeEventListener('scroll', instance.update, passive);
1116
+ });
1117
+ }
1030
1118
 
1031
- /**
1032
- * Get the window associated with the element
1033
- * @argument {Element} element
1034
- * @returns {browser-window--new}
1035
- */
1036
- function getWindow(element) {
1037
- var ownerDocument = element.ownerDocument;
1038
- return ownerDocument ? ownerDocument.defaultView : window;
1039
- }
1040
-
1041
- function attachToScrollParents(scrollParent, event, callback, scrollParents) {
1042
- var isBody = scrollParent.nodeName === 'BODY';
1043
- var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
1044
- target.addEventListener(event, callback, { passive: true });
1045
-
1046
- if (!isBody) {
1047
- attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
1048
- }
1049
- scrollParents.push(target);
1050
- }
1119
+ if (resize) {
1120
+ window.removeEventListener('resize', instance.update, passive);
1121
+ }
1122
+ };
1123
+ } // eslint-disable-next-line import/no-unused-modules
1051
1124
 
1052
- /**
1053
- * Setup needed event listeners used to update the popper position
1054
- * @method
1055
- * @memberof Popper.Utils
1056
- * @private
1057
- */
1058
- function setupEventListeners(reference, options, state, updateBound) {
1059
- // Resize event listener on window
1060
- state.updateBound = updateBound;
1061
- getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
1062
1125
 
1063
- // Scroll event listener on scroll parents
1064
- var scrollElement = getScrollParent(reference);
1065
- attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
1066
- state.scrollElement = scrollElement;
1067
- state.eventsEnabled = true;
1126
+ var eventListeners = {
1127
+ name: 'eventListeners',
1128
+ enabled: true,
1129
+ phase: 'write',
1130
+ fn: function fn() {},
1131
+ effect: effect$2,
1132
+ data: {}
1133
+ };
1068
1134
 
1069
- return state;
1070
- }
1135
+ function popperOffsets(_ref) {
1136
+ var state = _ref.state,
1137
+ name = _ref.name;
1138
+ // Offsets are the actual position the popper needs to have to be
1139
+ // properly positioned near its reference element
1140
+ // This is the most basic placement, and will be adjusted by
1141
+ // the modifiers in the next step
1142
+ state.modifiersData[name] = computeOffsets({
1143
+ reference: state.rects.reference,
1144
+ element: state.rects.popper,
1145
+ strategy: 'absolute',
1146
+ placement: state.placement
1147
+ });
1148
+ } // eslint-disable-next-line import/no-unused-modules
1071
1149
 
1072
- /**
1073
- * It will add resize/scroll events and start recalculating
1074
- * position of the popper element when they are triggered.
1075
- * @method
1076
- * @memberof Popper
1077
- */
1078
- function enableEventListeners() {
1079
- if (!this.state.eventsEnabled) {
1080
- this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
1081
- }
1082
- }
1083
1150
 
1084
- /**
1085
- * Remove event listeners used to update the popper position
1086
- * @method
1087
- * @memberof Popper.Utils
1088
- * @private
1089
- */
1090
- function removeEventListeners(reference, state) {
1091
- // Remove resize event listener on window
1092
- getWindow(reference).removeEventListener('resize', state.updateBound);
1093
-
1094
- // Remove scroll event listener on scroll parents
1095
- state.scrollParents.forEach(function (target) {
1096
- target.removeEventListener('scroll', state.updateBound);
1097
- });
1098
-
1099
- // Reset state
1100
- state.updateBound = null;
1101
- state.scrollParents = [];
1102
- state.scrollElement = null;
1103
- state.eventsEnabled = false;
1104
- return state;
1105
- }
1151
+ var popperOffsets$1 = {
1152
+ name: 'popperOffsets',
1153
+ enabled: true,
1154
+ phase: 'read',
1155
+ fn: popperOffsets,
1156
+ data: {}
1157
+ };
1106
1158
 
1107
- /**
1108
- * It will remove resize/scroll events and won't recalculate popper position
1109
- * when they are triggered. It also won't trigger `onUpdate` callback anymore,
1110
- * unless you call `update` method manually.
1111
- * @method
1112
- * @memberof Popper
1113
- */
1114
- function disableEventListeners() {
1115
- if (this.state.eventsEnabled) {
1116
- cancelAnimationFrame(this.scheduleUpdate);
1117
- this.state = removeEventListeners(this.reference, this.state);
1159
+ var unsetSides = {
1160
+ top: 'auto',
1161
+ right: 'auto',
1162
+ bottom: 'auto',
1163
+ left: 'auto'
1164
+ }; // Round the offsets to the nearest suitable subpixel based on the DPR.
1165
+ // Zooming can change the DPR, but it seems to report a value that will
1166
+ // cleanly divide the values into the appropriate subpixels.
1167
+
1168
+ function roundOffsetsByDPR(_ref) {
1169
+ var x = _ref.x,
1170
+ y = _ref.y;
1171
+ var win = window;
1172
+ var dpr = win.devicePixelRatio || 1;
1173
+ return {
1174
+ x: round(round(x * dpr) / dpr) || 0,
1175
+ y: round(round(y * dpr) / dpr) || 0
1176
+ };
1118
1177
  }
1119
- }
1120
1178
 
1121
- /**
1122
- * Tells if a given input is a number
1123
- * @method
1124
- * @memberof Popper.Utils
1125
- * @param {*} input to check
1126
- * @return {Boolean}
1127
- */
1128
- function isNumeric(n) {
1129
- return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
1130
- }
1179
+ function mapToStyles(_ref2) {
1180
+ var _Object$assign2;
1131
1181
 
1132
- /**
1133
- * Set the style to the given popper
1134
- * @method
1135
- * @memberof Popper.Utils
1136
- * @argument {Element} element - Element to apply the style to
1137
- * @argument {Object} styles
1138
- * Object with a list of properties and values which will be applied to the element
1139
- */
1140
- function setStyles(element, styles) {
1141
- Object.keys(styles).forEach(function (prop) {
1142
- var unit = '';
1143
- // add unit if the value is numeric and is one of the following
1144
- if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
1145
- unit = 'px';
1146
- }
1147
- element.style[prop] = styles[prop] + unit;
1148
- });
1149
- }
1182
+ var popper = _ref2.popper,
1183
+ popperRect = _ref2.popperRect,
1184
+ placement = _ref2.placement,
1185
+ variation = _ref2.variation,
1186
+ offsets = _ref2.offsets,
1187
+ position = _ref2.position,
1188
+ gpuAcceleration = _ref2.gpuAcceleration,
1189
+ adaptive = _ref2.adaptive,
1190
+ roundOffsets = _ref2.roundOffsets;
1150
1191
 
1151
- /**
1152
- * Set the attributes to the given popper
1153
- * @method
1154
- * @memberof Popper.Utils
1155
- * @argument {Element} element - Element to apply the attributes to
1156
- * @argument {Object} styles
1157
- * Object with a list of properties and values which will be applied to the element
1158
- */
1159
- function setAttributes(element, attributes) {
1160
- Object.keys(attributes).forEach(function (prop) {
1161
- var value = attributes[prop];
1162
- if (value !== false) {
1163
- element.setAttribute(prop, attributes[prop]);
1164
- } else {
1165
- element.removeAttribute(prop);
1166
- }
1167
- });
1168
- }
1192
+ var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === 'function' ? roundOffsets(offsets) : offsets,
1193
+ _ref3$x = _ref3.x,
1194
+ x = _ref3$x === void 0 ? 0 : _ref3$x,
1195
+ _ref3$y = _ref3.y,
1196
+ y = _ref3$y === void 0 ? 0 : _ref3$y;
1169
1197
 
1170
- /**
1171
- * @function
1172
- * @memberof Modifiers
1173
- * @argument {Object} data - The data object generated by `update` method
1174
- * @argument {Object} data.styles - List of style properties - values to apply to popper element
1175
- * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
1176
- * @argument {Object} options - Modifiers configuration and options
1177
- * @returns {Object} The same data object
1178
- */
1179
- function applyStyle(data) {
1180
- // any property present in `data.styles` will be applied to the popper,
1181
- // in this way we can make the 3rd party modifiers add custom styles to it
1182
- // Be aware, modifiers could override the properties defined in the previous
1183
- // lines of this modifier!
1184
- setStyles(data.instance.popper, data.styles);
1185
-
1186
- // any property present in `data.attributes` will be applied to the popper,
1187
- // they will be set as HTML attributes of the element
1188
- setAttributes(data.instance.popper, data.attributes);
1189
-
1190
- // if arrowElement is defined and arrowStyles has some properties
1191
- if (data.arrowElement && Object.keys(data.arrowStyles).length) {
1192
- setStyles(data.arrowElement, data.arrowStyles);
1193
- }
1198
+ var hasX = offsets.hasOwnProperty('x');
1199
+ var hasY = offsets.hasOwnProperty('y');
1200
+ var sideX = left;
1201
+ var sideY = top;
1202
+ var win = window;
1194
1203
 
1195
- return data;
1196
- }
1204
+ if (adaptive) {
1205
+ var offsetParent = getOffsetParent(popper);
1206
+ var heightProp = 'clientHeight';
1207
+ var widthProp = 'clientWidth';
1197
1208
 
1198
- /**
1199
- * Set the x-placement attribute before everything else because it could be used
1200
- * to add margins to the popper margins needs to be calculated to get the
1201
- * correct popper offsets.
1202
- * @method
1203
- * @memberof Popper.modifiers
1204
- * @param {HTMLElement} reference - The reference element used to position the popper
1205
- * @param {HTMLElement} popper - The HTML element used as popper
1206
- * @param {Object} options - Popper.js options
1207
- */
1208
- function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
1209
- // compute reference element offsets
1210
- var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
1209
+ if (offsetParent === getWindow(popper)) {
1210
+ offsetParent = getDocumentElement(popper);
1211
1211
 
1212
- // compute auto placement, store placement inside the data object,
1213
- // modifiers will be able to edit `placement` if needed
1214
- // and refer to originalPlacement to know the original value
1215
- var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
1212
+ if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
1213
+ heightProp = 'scrollHeight';
1214
+ widthProp = 'scrollWidth';
1215
+ }
1216
+ } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
1216
1217
 
1217
- popper.setAttribute('x-placement', placement);
1218
1218
 
1219
- // Apply `position` to popper before anything else because
1220
- // without the position applied we can't guarantee correct computations
1221
- setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
1219
+ offsetParent = offsetParent;
1222
1220
 
1223
- return options;
1224
- }
1221
+ if (placement === top || (placement === left || placement === right) && variation === end) {
1222
+ sideY = bottom; // $FlowFixMe[prop-missing]
1225
1223
 
1226
- /**
1227
- * @function
1228
- * @memberof Popper.Utils
1229
- * @argument {Object} data - The data object generated by `update` method
1230
- * @argument {Boolean} shouldRound - If the offsets should be rounded at all
1231
- * @returns {Object} The popper's position offsets rounded
1232
- *
1233
- * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
1234
- * good as it can be within reason.
1235
- * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
1236
- *
1237
- * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
1238
- * as well on High DPI screens).
1239
- *
1240
- * Firefox prefers no rounding for positioning and does not have blurriness on
1241
- * high DPI screens.
1242
- *
1243
- * Only horizontal placement and left/right values need to be considered.
1244
- */
1245
- function getRoundedOffsets(data, shouldRound) {
1246
- var _data$offsets = data.offsets,
1247
- popper = _data$offsets.popper,
1248
- reference = _data$offsets.reference;
1249
- var round = Math.round,
1250
- floor = Math.floor;
1251
-
1252
- var noRound = function noRound(v) {
1253
- return v;
1254
- };
1224
+ y -= offsetParent[heightProp] - popperRect.height;
1225
+ y *= gpuAcceleration ? 1 : -1;
1226
+ }
1255
1227
 
1256
- var referenceWidth = round(reference.width);
1257
- var popperWidth = round(popper.width);
1228
+ if (placement === left || (placement === top || placement === bottom) && variation === end) {
1229
+ sideX = right; // $FlowFixMe[prop-missing]
1258
1230
 
1259
- var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
1260
- var isVariation = data.placement.indexOf('-') !== -1;
1261
- var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
1262
- var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
1231
+ x -= offsetParent[widthProp] - popperRect.width;
1232
+ x *= gpuAcceleration ? 1 : -1;
1233
+ }
1234
+ }
1263
1235
 
1264
- var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
1265
- var verticalToInteger = !shouldRound ? noRound : round;
1236
+ var commonStyles = Object.assign({
1237
+ position: position
1238
+ }, adaptive && unsetSides);
1266
1239
 
1267
- return {
1268
- left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
1269
- top: verticalToInteger(popper.top),
1270
- bottom: verticalToInteger(popper.bottom),
1271
- right: horizontalToInteger(popper.right)
1272
- };
1273
- }
1240
+ if (gpuAcceleration) {
1241
+ var _Object$assign;
1274
1242
 
1275
- var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
1243
+ return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
1244
+ }
1276
1245
 
1277
- /**
1278
- * @function
1279
- * @memberof Modifiers
1280
- * @argument {Object} data - The data object generated by `update` method
1281
- * @argument {Object} options - Modifiers configuration and options
1282
- * @returns {Object} The data object, properly modified
1283
- */
1284
- function computeStyle(data, options) {
1285
- var x = options.x,
1286
- y = options.y;
1287
- var popper = data.offsets.popper;
1288
-
1289
- // Remove this legacy support in Popper.js v2
1290
-
1291
- var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
1292
- return modifier.name === 'applyStyle';
1293
- }).gpuAcceleration;
1294
- if (legacyGpuAccelerationOption !== undefined) {
1295
- console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
1246
+ return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
1296
1247
  }
1297
- var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
1298
1248
 
1299
- var offsetParent = getOffsetParent(data.instance.popper);
1300
- var offsetParentRect = getBoundingClientRect(offsetParent);
1249
+ function computeStyles(_ref4) {
1250
+ var state = _ref4.state,
1251
+ options = _ref4.options;
1252
+ var _options$gpuAccelerat = options.gpuAcceleration,
1253
+ gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
1254
+ _options$adaptive = options.adaptive,
1255
+ adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
1256
+ _options$roundOffsets = options.roundOffsets,
1257
+ roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
1301
1258
 
1302
- // Styles
1303
- var styles = {
1304
- position: popper.position
1305
- };
1259
+ {
1260
+ var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || '';
1306
1261
 
1307
- var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
1308
-
1309
- var sideA = x === 'bottom' ? 'top' : 'bottom';
1310
- var sideB = y === 'right' ? 'left' : 'right';
1311
-
1312
- // if gpuAcceleration is set to `true` and transform is supported,
1313
- // we use `translate3d` to apply the position to the popper we
1314
- // automatically use the supported prefixed version if needed
1315
- var prefixedProperty = getSupportedPropertyName('transform');
1316
-
1317
- // now, let's make a step back and look at this code closely (wtf?)
1318
- // If the content of the popper grows once it's been positioned, it
1319
- // may happen that the popper gets misplaced because of the new content
1320
- // overflowing its reference element
1321
- // To avoid this problem, we provide two options (x and y), which allow
1322
- // the consumer to define the offset origin.
1323
- // If we position a popper on top of a reference element, we can set
1324
- // `x` to `top` to make the popper grow towards its top instead of
1325
- // its bottom.
1326
- var left = void 0,
1327
- top = void 0;
1328
- if (sideA === 'bottom') {
1329
- // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
1330
- // and not the bottom of the html element
1331
- if (offsetParent.nodeName === 'HTML') {
1332
- top = -offsetParent.clientHeight + offsets.bottom;
1333
- } else {
1334
- top = -offsetParentRect.height + offsets.bottom;
1335
- }
1336
- } else {
1337
- top = offsets.top;
1338
- }
1339
- if (sideB === 'right') {
1340
- if (offsetParent.nodeName === 'HTML') {
1341
- left = -offsetParent.clientWidth + offsets.right;
1342
- } else {
1343
- left = -offsetParentRect.width + offsets.right;
1262
+ if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {
1263
+ return transitionProperty.indexOf(property) >= 0;
1264
+ })) {
1265
+ console.warn(['Popper: Detected CSS transitions on at least one of the following', 'CSS properties: "transform", "top", "right", "bottom", "left".', '\n\n', 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', 'for smooth transitions, or remove these properties from the CSS', 'transition declaration on the popper element if only transitioning', 'opacity or background-color for example.', '\n\n', 'We recommend using the popper element as a wrapper around an inner', 'element that can have any CSS property transitioned for animations.'].join(' '));
1266
+ }
1344
1267
  }
1345
- } else {
1346
- left = offsets.left;
1347
- }
1348
- if (gpuAcceleration && prefixedProperty) {
1349
- styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
1350
- styles[sideA] = 0;
1351
- styles[sideB] = 0;
1352
- styles.willChange = 'transform';
1353
- } else {
1354
- // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
1355
- var invertTop = sideA === 'bottom' ? -1 : 1;
1356
- var invertLeft = sideB === 'right' ? -1 : 1;
1357
- styles[sideA] = top * invertTop;
1358
- styles[sideB] = left * invertLeft;
1359
- styles.willChange = sideA + ', ' + sideB;
1360
- }
1361
1268
 
1362
- // Attributes
1363
- var attributes = {
1364
- 'x-placement': data.placement
1365
- };
1366
-
1367
- // Update `data` attributes, styles and arrowStyles
1368
- data.attributes = _extends({}, attributes, data.attributes);
1369
- data.styles = _extends({}, styles, data.styles);
1370
- data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
1371
-
1372
- return data;
1373
- }
1269
+ var commonStyles = {
1270
+ placement: getBasePlacement(state.placement),
1271
+ variation: getVariation(state.placement),
1272
+ popper: state.elements.popper,
1273
+ popperRect: state.rects.popper,
1274
+ gpuAcceleration: gpuAcceleration
1275
+ };
1374
1276
 
1375
- /**
1376
- * Helper used to know if the given modifier depends from another one.<br />
1377
- * It checks if the needed modifier is listed and enabled.
1378
- * @method
1379
- * @memberof Popper.Utils
1380
- * @param {Array} modifiers - list of modifiers
1381
- * @param {String} requestingName - name of requesting modifier
1382
- * @param {String} requestedName - name of requested modifier
1383
- * @returns {Boolean}
1384
- */
1385
- function isModifierRequired(modifiers, requestingName, requestedName) {
1386
- var requesting = find(modifiers, function (_ref) {
1387
- var name = _ref.name;
1388
- return name === requestingName;
1389
- });
1390
-
1391
- var isRequired = !!requesting && modifiers.some(function (modifier) {
1392
- return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
1393
- });
1394
-
1395
- if (!isRequired) {
1396
- var _requesting = '`' + requestingName + '`';
1397
- var requested = '`' + requestedName + '`';
1398
- console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
1399
- }
1400
- return isRequired;
1401
- }
1277
+ if (state.modifiersData.popperOffsets != null) {
1278
+ state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
1279
+ offsets: state.modifiersData.popperOffsets,
1280
+ position: state.options.strategy,
1281
+ adaptive: adaptive,
1282
+ roundOffsets: roundOffsets
1283
+ })));
1284
+ }
1402
1285
 
1403
- /**
1404
- * @function
1405
- * @memberof Modifiers
1406
- * @argument {Object} data - The data object generated by update method
1407
- * @argument {Object} options - Modifiers configuration and options
1408
- * @returns {Object} The data object, properly modified
1409
- */
1410
- function arrow(data, options) {
1411
- var _data$offsets$arrow;
1286
+ if (state.modifiersData.arrow != null) {
1287
+ state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
1288
+ offsets: state.modifiersData.arrow,
1289
+ position: 'absolute',
1290
+ adaptive: false,
1291
+ roundOffsets: roundOffsets
1292
+ })));
1293
+ }
1412
1294
 
1413
- // arrow depends on keepTogether in order to work
1414
- if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
1415
- return data;
1416
- }
1295
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
1296
+ 'data-popper-placement': state.placement
1297
+ });
1298
+ } // eslint-disable-next-line import/no-unused-modules
1417
1299
 
1418
- var arrowElement = options.element;
1419
1300
 
1420
- // if arrowElement is a string, suppose it's a CSS selector
1421
- if (typeof arrowElement === 'string') {
1422
- arrowElement = data.instance.popper.querySelector(arrowElement);
1301
+ var computeStyles$1 = {
1302
+ name: 'computeStyles',
1303
+ enabled: true,
1304
+ phase: 'beforeWrite',
1305
+ fn: computeStyles,
1306
+ data: {}
1307
+ };
1423
1308
 
1424
- // if arrowElement is not found, don't run the modifier
1425
- if (!arrowElement) {
1426
- return data;
1427
- }
1428
- } else {
1429
- // if the arrowElement isn't a query selector we must check that the
1430
- // provided DOM node is child of its popper node
1431
- if (!data.instance.popper.contains(arrowElement)) {
1432
- console.warn('WARNING: `arrow.element` must be child of its popper element!');
1433
- return data;
1434
- }
1435
- }
1309
+ // and applies them to the HTMLElements such as popper and arrow
1436
1310
 
1437
- var placement = data.placement.split('-')[0];
1438
- var _data$offsets = data.offsets,
1439
- popper = _data$offsets.popper,
1440
- reference = _data$offsets.reference;
1311
+ function applyStyles(_ref) {
1312
+ var state = _ref.state;
1313
+ Object.keys(state.elements).forEach(function (name) {
1314
+ var style = state.styles[name] || {};
1315
+ var attributes = state.attributes[name] || {};
1316
+ var element = state.elements[name]; // arrow is optional + virtual elements
1441
1317
 
1442
- var isVertical = ['left', 'right'].indexOf(placement) !== -1;
1318
+ if (!isHTMLElement(element) || !getNodeName(element)) {
1319
+ return;
1320
+ } // Flow doesn't support to extend this property, but it's the most
1321
+ // effective way to apply styles to an HTMLElement
1322
+ // $FlowFixMe[cannot-write]
1443
1323
 
1444
- var len = isVertical ? 'height' : 'width';
1445
- var sideCapitalized = isVertical ? 'Top' : 'Left';
1446
- var side = sideCapitalized.toLowerCase();
1447
- var altSide = isVertical ? 'left' : 'top';
1448
- var opSide = isVertical ? 'bottom' : 'right';
1449
- var arrowElementSize = getOuterSizes(arrowElement)[len];
1450
1324
 
1451
- //
1452
- // extends keepTogether behavior making sure the popper and its
1453
- // reference have enough pixels in conjunction
1454
- //
1325
+ Object.assign(element.style, style);
1326
+ Object.keys(attributes).forEach(function (name) {
1327
+ var value = attributes[name];
1455
1328
 
1456
- // top/left side
1457
- if (reference[opSide] - arrowElementSize < popper[side]) {
1458
- data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
1459
- }
1460
- // bottom/right side
1461
- if (reference[side] + arrowElementSize > popper[opSide]) {
1462
- data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
1329
+ if (value === false) {
1330
+ element.removeAttribute(name);
1331
+ } else {
1332
+ element.setAttribute(name, value === true ? '' : value);
1333
+ }
1334
+ });
1335
+ });
1463
1336
  }
1464
- data.offsets.popper = getClientRect(data.offsets.popper);
1465
1337
 
1466
- // compute center of the popper
1467
- var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
1338
+ function effect$1(_ref2) {
1339
+ var state = _ref2.state;
1340
+ var initialStyles = {
1341
+ popper: {
1342
+ position: state.options.strategy,
1343
+ left: '0',
1344
+ top: '0',
1345
+ margin: '0'
1346
+ },
1347
+ arrow: {
1348
+ position: 'absolute'
1349
+ },
1350
+ reference: {}
1351
+ };
1352
+ Object.assign(state.elements.popper.style, initialStyles.popper);
1353
+ state.styles = initialStyles;
1468
1354
 
1469
- // Compute the sideValue using the updated popper offsets
1470
- // take popper margin in account because we don't have this info available
1471
- var css = getStyleComputedProperty(data.instance.popper);
1472
- var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
1473
- var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
1474
- var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
1355
+ if (state.elements.arrow) {
1356
+ Object.assign(state.elements.arrow.style, initialStyles.arrow);
1357
+ }
1475
1358
 
1476
- // prevent arrowElement from being placed not contiguously to its popper
1477
- sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
1359
+ return function () {
1360
+ Object.keys(state.elements).forEach(function (name) {
1361
+ var element = state.elements[name];
1362
+ var attributes = state.attributes[name] || {};
1363
+ var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
1364
+
1365
+ var style = styleProperties.reduce(function (style, property) {
1366
+ style[property] = '';
1367
+ return style;
1368
+ }, {}); // arrow is optional + virtual elements
1369
+
1370
+ if (!isHTMLElement(element) || !getNodeName(element)) {
1371
+ return;
1372
+ }
1373
+
1374
+ Object.assign(element.style, style);
1375
+ Object.keys(attributes).forEach(function (attribute) {
1376
+ element.removeAttribute(attribute);
1377
+ });
1378
+ });
1379
+ };
1380
+ } // eslint-disable-next-line import/no-unused-modules
1478
1381
 
1479
- data.arrowElement = arrowElement;
1480
- data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
1481
1382
 
1482
- return data;
1483
- }
1383
+ var applyStyles$1 = {
1384
+ name: 'applyStyles',
1385
+ enabled: true,
1386
+ phase: 'write',
1387
+ fn: applyStyles,
1388
+ effect: effect$1,
1389
+ requires: ['computeStyles']
1390
+ };
1484
1391
 
1485
- /**
1486
- * Get the opposite placement variation of the given one
1487
- * @method
1488
- * @memberof Popper.Utils
1489
- * @argument {String} placement variation
1490
- * @returns {String} flipped placement variation
1491
- */
1492
- function getOppositeVariation(variation) {
1493
- if (variation === 'end') {
1494
- return 'start';
1495
- } else if (variation === 'start') {
1496
- return 'end';
1392
+ function distanceAndSkiddingToXY(placement, rects, offset) {
1393
+ var basePlacement = getBasePlacement(placement);
1394
+ var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
1395
+
1396
+ var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
1397
+ placement: placement
1398
+ })) : offset,
1399
+ skidding = _ref[0],
1400
+ distance = _ref[1];
1401
+
1402
+ skidding = skidding || 0;
1403
+ distance = (distance || 0) * invertDistance;
1404
+ return [left, right].indexOf(basePlacement) >= 0 ? {
1405
+ x: distance,
1406
+ y: skidding
1407
+ } : {
1408
+ x: skidding,
1409
+ y: distance
1410
+ };
1497
1411
  }
1498
- return variation;
1499
- }
1500
-
1501
- /**
1502
- * List of accepted placements to use as values of the `placement` option.<br />
1503
- * Valid placements are:
1504
- * - `auto`
1505
- * - `top`
1506
- * - `right`
1507
- * - `bottom`
1508
- * - `left`
1509
- *
1510
- * Each placement can have a variation from this list:
1511
- * - `-start`
1512
- * - `-end`
1513
- *
1514
- * Variations are interpreted easily if you think of them as the left to right
1515
- * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
1516
- * is right.<br />
1517
- * Vertically (`left` and `right`), `start` is top and `end` is bottom.
1518
- *
1519
- * Some valid examples are:
1520
- * - `top-end` (on top of reference, right aligned)
1521
- * - `right-start` (on right of reference, top aligned)
1522
- * - `bottom` (on bottom, centered)
1523
- * - `auto-end` (on the side with more space available, alignment depends by placement)
1524
- *
1525
- * @static
1526
- * @type {Array}
1527
- * @enum {String}
1528
- * @readonly
1529
- * @method placements
1530
- * @memberof Popper
1531
- */
1532
- var placements = ['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start'];
1533
1412
 
1534
- // Get rid of `auto` `auto-start` and `auto-end`
1535
- var validPlacements = placements.slice(3);
1536
-
1537
- /**
1538
- * Given an initial placement, returns all the subsequent placements
1539
- * clockwise (or counter-clockwise).
1540
- *
1541
- * @method
1542
- * @memberof Popper.Utils
1543
- * @argument {String} placement - A valid placement (it accepts variations)
1544
- * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
1545
- * @returns {Array} placements including their variations
1546
- */
1547
- function clockwise(placement) {
1548
- var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1413
+ function offset(_ref2) {
1414
+ var state = _ref2.state,
1415
+ options = _ref2.options,
1416
+ name = _ref2.name;
1417
+ var _options$offset = options.offset,
1418
+ offset = _options$offset === void 0 ? [0, 0] : _options$offset;
1419
+ var data = placements.reduce(function (acc, placement) {
1420
+ acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
1421
+ return acc;
1422
+ }, {});
1423
+ var _data$state$placement = data[state.placement],
1424
+ x = _data$state$placement.x,
1425
+ y = _data$state$placement.y;
1426
+
1427
+ if (state.modifiersData.popperOffsets != null) {
1428
+ state.modifiersData.popperOffsets.x += x;
1429
+ state.modifiersData.popperOffsets.y += y;
1430
+ }
1549
1431
 
1550
- var index = validPlacements.indexOf(placement);
1551
- var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
1552
- return counter ? arr.reverse() : arr;
1553
- }
1432
+ state.modifiersData[name] = data;
1433
+ } // eslint-disable-next-line import/no-unused-modules
1554
1434
 
1555
- var BEHAVIORS = {
1556
- FLIP: 'flip',
1557
- CLOCKWISE: 'clockwise',
1558
- COUNTERCLOCKWISE: 'counterclockwise'
1559
- };
1560
1435
 
1561
- /**
1562
- * @function
1563
- * @memberof Modifiers
1564
- * @argument {Object} data - The data object generated by update method
1565
- * @argument {Object} options - Modifiers configuration and options
1566
- * @returns {Object} The data object, properly modified
1567
- */
1568
- function flip(data, options) {
1569
- // if `inner` modifier is enabled, we can't use the `flip` modifier
1570
- if (isModifierEnabled(data.instance.modifiers, 'inner')) {
1571
- return data;
1572
- }
1436
+ var offset$1 = {
1437
+ name: 'offset',
1438
+ enabled: true,
1439
+ phase: 'main',
1440
+ requires: ['popperOffsets'],
1441
+ fn: offset
1442
+ };
1573
1443
 
1574
- if (data.flipped && data.placement === data.originalPlacement) {
1575
- // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
1576
- return data;
1444
+ var hash$1 = {
1445
+ left: 'right',
1446
+ right: 'left',
1447
+ bottom: 'top',
1448
+ top: 'bottom'
1449
+ };
1450
+ function getOppositePlacement(placement) {
1451
+ return placement.replace(/left|right|bottom|top/g, function (matched) {
1452
+ return hash$1[matched];
1453
+ });
1577
1454
  }
1578
1455
 
1579
- var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
1580
-
1581
- var placement = data.placement.split('-')[0];
1582
- var placementOpposite = getOppositePlacement(placement);
1583
- var variation = data.placement.split('-')[1] || '';
1584
-
1585
- var flipOrder = [];
1586
-
1587
- switch (options.behavior) {
1588
- case BEHAVIORS.FLIP:
1589
- flipOrder = [placement, placementOpposite];
1590
- break;
1591
- case BEHAVIORS.CLOCKWISE:
1592
- flipOrder = clockwise(placement);
1593
- break;
1594
- case BEHAVIORS.COUNTERCLOCKWISE:
1595
- flipOrder = clockwise(placement, true);
1596
- break;
1597
- default:
1598
- flipOrder = options.behavior;
1456
+ var hash = {
1457
+ start: 'end',
1458
+ end: 'start'
1459
+ };
1460
+ function getOppositeVariationPlacement(placement) {
1461
+ return placement.replace(/start|end/g, function (matched) {
1462
+ return hash[matched];
1463
+ });
1599
1464
  }
1600
1465
 
1601
- flipOrder.forEach(function (step, index) {
1602
- if (placement !== step || flipOrder.length === index + 1) {
1603
- return data;
1466
+ function computeAutoPlacement(state, options) {
1467
+ if (options === void 0) {
1468
+ options = {};
1604
1469
  }
1605
1470
 
1606
- placement = data.placement.split('-')[0];
1607
- placementOpposite = getOppositePlacement(placement);
1608
-
1609
- var popperOffsets = data.offsets.popper;
1610
- var refOffsets = data.offsets.reference;
1471
+ var _options = options,
1472
+ placement = _options.placement,
1473
+ boundary = _options.boundary,
1474
+ rootBoundary = _options.rootBoundary,
1475
+ padding = _options.padding,
1476
+ flipVariations = _options.flipVariations,
1477
+ _options$allowedAutoP = _options.allowedAutoPlacements,
1478
+ allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
1479
+ var variation = getVariation(placement);
1480
+ var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
1481
+ return getVariation(placement) === variation;
1482
+ }) : basePlacements;
1483
+ var allowedPlacements = placements$1.filter(function (placement) {
1484
+ return allowedAutoPlacements.indexOf(placement) >= 0;
1485
+ });
1611
1486
 
1612
- // using floor because the reference offsets may contain decimals we are not going to consider here
1613
- var floor = Math.floor;
1614
- var overlapsRef = placement === 'left' && floor(popperOffsets.right) > floor(refOffsets.left) || placement === 'right' && floor(popperOffsets.left) < floor(refOffsets.right) || placement === 'top' && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === 'bottom' && floor(popperOffsets.top) < floor(refOffsets.bottom);
1487
+ if (allowedPlacements.length === 0) {
1488
+ allowedPlacements = placements$1;
1615
1489
 
1616
- var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
1617
- var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
1618
- var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
1619
- var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
1490
+ {
1491
+ console.error(['Popper: The `allowedAutoPlacements` option did not allow any', 'placements. Ensure the `placement` option matches the variation', 'of the allowed placements.', 'For example, "auto" cannot be used to allow "bottom-start".', 'Use "auto-start" instead.'].join(' '));
1492
+ }
1493
+ } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
1494
+
1495
+
1496
+ var overflows = allowedPlacements.reduce(function (acc, placement) {
1497
+ acc[placement] = detectOverflow(state, {
1498
+ placement: placement,
1499
+ boundary: boundary,
1500
+ rootBoundary: rootBoundary,
1501
+ padding: padding
1502
+ })[getBasePlacement(placement)];
1503
+ return acc;
1504
+ }, {});
1505
+ return Object.keys(overflows).sort(function (a, b) {
1506
+ return overflows[a] - overflows[b];
1507
+ });
1508
+ }
1620
1509
 
1621
- var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
1510
+ function getExpandedFallbackPlacements(placement) {
1511
+ if (getBasePlacement(placement) === auto) {
1512
+ return [];
1513
+ }
1622
1514
 
1623
- // flip the variation if required
1624
- var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
1515
+ var oppositePlacement = getOppositePlacement(placement);
1516
+ return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
1517
+ }
1625
1518
 
1626
- // flips variation if reference element overflows boundaries
1627
- var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
1519
+ function flip(_ref) {
1520
+ var state = _ref.state,
1521
+ options = _ref.options,
1522
+ name = _ref.name;
1628
1523
 
1629
- // flips variation if popper content overflows boundaries
1630
- var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
1524
+ if (state.modifiersData[name]._skip) {
1525
+ return;
1526
+ }
1631
1527
 
1632
- var flippedVariation = flippedVariationByRef || flippedVariationByContent;
1528
+ var _options$mainAxis = options.mainAxis,
1529
+ checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1530
+ _options$altAxis = options.altAxis,
1531
+ checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
1532
+ specifiedFallbackPlacements = options.fallbackPlacements,
1533
+ padding = options.padding,
1534
+ boundary = options.boundary,
1535
+ rootBoundary = options.rootBoundary,
1536
+ altBoundary = options.altBoundary,
1537
+ _options$flipVariatio = options.flipVariations,
1538
+ flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
1539
+ allowedAutoPlacements = options.allowedAutoPlacements;
1540
+ var preferredPlacement = state.options.placement;
1541
+ var basePlacement = getBasePlacement(preferredPlacement);
1542
+ var isBasePlacement = basePlacement === preferredPlacement;
1543
+ var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
1544
+ var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
1545
+ return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
1546
+ placement: placement,
1547
+ boundary: boundary,
1548
+ rootBoundary: rootBoundary,
1549
+ padding: padding,
1550
+ flipVariations: flipVariations,
1551
+ allowedAutoPlacements: allowedAutoPlacements
1552
+ }) : placement);
1553
+ }, []);
1554
+ var referenceRect = state.rects.reference;
1555
+ var popperRect = state.rects.popper;
1556
+ var checksMap = new Map();
1557
+ var makeFallbackChecks = true;
1558
+ var firstFittingPlacement = placements[0];
1559
+
1560
+ for (var i = 0; i < placements.length; i++) {
1561
+ var placement = placements[i];
1562
+
1563
+ var _basePlacement = getBasePlacement(placement);
1564
+
1565
+ var isStartVariation = getVariation(placement) === start;
1566
+ var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
1567
+ var len = isVertical ? 'width' : 'height';
1568
+ var overflow = detectOverflow(state, {
1569
+ placement: placement,
1570
+ boundary: boundary,
1571
+ rootBoundary: rootBoundary,
1572
+ altBoundary: altBoundary,
1573
+ padding: padding
1574
+ });
1575
+ var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
1576
+
1577
+ if (referenceRect[len] > popperRect[len]) {
1578
+ mainVariationSide = getOppositePlacement(mainVariationSide);
1579
+ }
1633
1580
 
1634
- if (overlapsRef || overflowsBoundaries || flippedVariation) {
1635
- // this boolean to detect any flip loop
1636
- data.flipped = true;
1581
+ var altVariationSide = getOppositePlacement(mainVariationSide);
1582
+ var checks = [];
1637
1583
 
1638
- if (overlapsRef || overflowsBoundaries) {
1639
- placement = flipOrder[index + 1];
1584
+ if (checkMainAxis) {
1585
+ checks.push(overflow[_basePlacement] <= 0);
1640
1586
  }
1641
1587
 
1642
- if (flippedVariation) {
1643
- variation = getOppositeVariation(variation);
1588
+ if (checkAltAxis) {
1589
+ checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
1644
1590
  }
1645
1591
 
1646
- data.placement = placement + (variation ? '-' + variation : '');
1647
-
1648
- // this object contains `position`, we want to preserve it along with
1649
- // any additional property we may add in the future
1650
- data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
1651
-
1652
- data = runModifiers(data.instance.modifiers, data, 'flip');
1653
- }
1654
- });
1655
- return data;
1656
- }
1657
-
1658
- /**
1659
- * @function
1660
- * @memberof Modifiers
1661
- * @argument {Object} data - The data object generated by update method
1662
- * @argument {Object} options - Modifiers configuration and options
1663
- * @returns {Object} The data object, properly modified
1664
- */
1665
- function keepTogether(data) {
1666
- var _data$offsets = data.offsets,
1667
- popper = _data$offsets.popper,
1668
- reference = _data$offsets.reference;
1669
-
1670
- var placement = data.placement.split('-')[0];
1671
- var floor = Math.floor;
1672
- var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
1673
- var side = isVertical ? 'right' : 'bottom';
1674
- var opSide = isVertical ? 'left' : 'top';
1675
- var measurement = isVertical ? 'width' : 'height';
1676
-
1677
- if (popper[side] < floor(reference[opSide])) {
1678
- data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
1679
- }
1680
- if (popper[opSide] > floor(reference[side])) {
1681
- data.offsets.popper[opSide] = floor(reference[side]);
1682
- }
1683
-
1684
- return data;
1685
- }
1686
-
1687
- /**
1688
- * Converts a string containing value + unit into a px value number
1689
- * @function
1690
- * @memberof {modifiers~offset}
1691
- * @private
1692
- * @argument {String} str - Value + unit string
1693
- * @argument {String} measurement - `height` or `width`
1694
- * @argument {Object} popperOffsets
1695
- * @argument {Object} referenceOffsets
1696
- * @returns {Number|String}
1697
- * Value in pixels, or original string if no values were extracted
1698
- */
1699
- function toValue(str, measurement, popperOffsets, referenceOffsets) {
1700
- // separate value from unit
1701
- var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
1702
- var value = +split[1];
1703
- var unit = split[2];
1704
-
1705
- // If it's not a number it's an operator, I guess
1706
- if (!value) {
1707
- return str;
1708
- }
1709
-
1710
- if (unit.indexOf('%') === 0) {
1711
- var element = void 0;
1712
- switch (unit) {
1713
- case '%p':
1714
- element = popperOffsets;
1592
+ if (checks.every(function (check) {
1593
+ return check;
1594
+ })) {
1595
+ firstFittingPlacement = placement;
1596
+ makeFallbackChecks = false;
1715
1597
  break;
1716
- case '%':
1717
- case '%r':
1718
- default:
1719
- element = referenceOffsets;
1720
- }
1598
+ }
1721
1599
 
1722
- var rect = getClientRect(element);
1723
- return rect[measurement] / 100 * value;
1724
- } else if (unit === 'vh' || unit === 'vw') {
1725
- // if is a vh or vw, we calculate the size based on the viewport
1726
- var size = void 0;
1727
- if (unit === 'vh') {
1728
- size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
1729
- } else {
1730
- size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
1600
+ checksMap.set(placement, checks);
1731
1601
  }
1732
- return size / 100 * value;
1733
- } else {
1734
- // if is an explicit pixel unit, we get rid of the unit and keep the value
1735
- // if is an implicit unit, it's px, and we return just the value
1736
- return value;
1737
- }
1738
- }
1739
1602
 
1740
- /**
1741
- * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
1742
- * @function
1743
- * @memberof {modifiers~offset}
1744
- * @private
1745
- * @argument {String} offset
1746
- * @argument {Object} popperOffsets
1747
- * @argument {Object} referenceOffsets
1748
- * @argument {String} basePlacement
1749
- * @returns {Array} a two cells array with x and y offsets in numbers
1750
- */
1751
- function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
1752
- var offsets = [0, 0];
1753
-
1754
- // Use height if placement is left or right and index is 0 otherwise use width
1755
- // in this way the first offset will use an axis and the second one
1756
- // will use the other one
1757
- var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
1758
-
1759
- // Split the offset string to obtain a list of values and operands
1760
- // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
1761
- var fragments = offset.split(/(\+|\-)/).map(function (frag) {
1762
- return frag.trim();
1763
- });
1764
-
1765
- // Detect if the offset string contains a pair of values or a single one
1766
- // they could be separated by comma or space
1767
- var divider = fragments.indexOf(find(fragments, function (frag) {
1768
- return frag.search(/,|\s/) !== -1;
1769
- }));
1770
-
1771
- if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
1772
- console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
1773
- }
1774
-
1775
- // If divider is found, we divide the list of values and operands to divide
1776
- // them by ofset X and Y.
1777
- var splitRegex = /\s*,\s*|\s+/;
1778
- var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments];
1779
-
1780
- // Convert the values with units to absolute pixels to allow our computations
1781
- ops = ops.map(function (op, index) {
1782
- // Most of the units rely on the orientation of the popper
1783
- var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
1784
- var mergeWithPrevious = false;
1785
- return op
1786
- // This aggregates any `+` or `-` sign that aren't considered operators
1787
- // e.g.: 10 + +5 => [10, +, +5]
1788
- .reduce(function (a, b) {
1789
- if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
1790
- a[a.length - 1] = b;
1791
- mergeWithPrevious = true;
1792
- return a;
1793
- } else if (mergeWithPrevious) {
1794
- a[a.length - 1] += b;
1795
- mergeWithPrevious = false;
1796
- return a;
1797
- } else {
1798
- return a.concat(b);
1799
- }
1800
- }, [])
1801
- // Here we convert the string values into number values (in px)
1802
- .map(function (str) {
1803
- return toValue(str, measurement, popperOffsets, referenceOffsets);
1804
- });
1805
- });
1603
+ if (makeFallbackChecks) {
1604
+ // `2` may be desired in some cases research later
1605
+ var numberOfChecks = flipVariations ? 3 : 1;
1806
1606
 
1807
- // Loop trough the offsets arrays and execute the operations
1808
- ops.forEach(function (op, index) {
1809
- op.forEach(function (frag, index2) {
1810
- if (isNumeric(frag)) {
1811
- offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
1812
- }
1813
- });
1814
- });
1815
- return offsets;
1816
- }
1607
+ var _loop = function _loop(_i) {
1608
+ var fittingPlacement = placements.find(function (placement) {
1609
+ var checks = checksMap.get(placement);
1817
1610
 
1818
- /**
1819
- * @function
1820
- * @memberof Modifiers
1821
- * @argument {Object} data - The data object generated by update method
1822
- * @argument {Object} options - Modifiers configuration and options
1823
- * @argument {Number|String} options.offset=0
1824
- * The offset value as described in the modifier description
1825
- * @returns {Object} The data object, properly modified
1826
- */
1827
- function offset(data, _ref) {
1828
- var offset = _ref.offset;
1829
- var placement = data.placement,
1830
- _data$offsets = data.offsets,
1831
- popper = _data$offsets.popper,
1832
- reference = _data$offsets.reference;
1833
-
1834
- var basePlacement = placement.split('-')[0];
1835
-
1836
- var offsets = void 0;
1837
- if (isNumeric(+offset)) {
1838
- offsets = [+offset, 0];
1839
- } else {
1840
- offsets = parseOffset(offset, popper, reference, basePlacement);
1841
- }
1611
+ if (checks) {
1612
+ return checks.slice(0, _i).every(function (check) {
1613
+ return check;
1614
+ });
1615
+ }
1616
+ });
1842
1617
 
1843
- if (basePlacement === 'left') {
1844
- popper.top += offsets[0];
1845
- popper.left -= offsets[1];
1846
- } else if (basePlacement === 'right') {
1847
- popper.top += offsets[0];
1848
- popper.left += offsets[1];
1849
- } else if (basePlacement === 'top') {
1850
- popper.left += offsets[0];
1851
- popper.top -= offsets[1];
1852
- } else if (basePlacement === 'bottom') {
1853
- popper.left += offsets[0];
1854
- popper.top += offsets[1];
1855
- }
1618
+ if (fittingPlacement) {
1619
+ firstFittingPlacement = fittingPlacement;
1620
+ return "break";
1621
+ }
1622
+ };
1856
1623
 
1857
- data.popper = popper;
1858
- return data;
1859
- }
1624
+ for (var _i = numberOfChecks; _i > 0; _i--) {
1625
+ var _ret = _loop(_i);
1860
1626
 
1861
- /**
1862
- * @function
1863
- * @memberof Modifiers
1864
- * @argument {Object} data - The data object generated by `update` method
1865
- * @argument {Object} options - Modifiers configuration and options
1866
- * @returns {Object} The data object, properly modified
1867
- */
1868
- function preventOverflow(data, options) {
1869
- var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
1870
-
1871
- // If offsetParent is the reference element, we really want to
1872
- // go one step up and use the next offsetParent as reference to
1873
- // avoid to make this modifier completely useless and look like broken
1874
- if (data.instance.reference === boundariesElement) {
1875
- boundariesElement = getOffsetParent(boundariesElement);
1876
- }
1877
-
1878
- // NOTE: DOM access here
1879
- // resets the popper's position so that the document size can be calculated excluding
1880
- // the size of the popper element itself
1881
- var transformProp = getSupportedPropertyName('transform');
1882
- var popperStyles = data.instance.popper.style; // assignment to help minification
1883
- var top = popperStyles.top,
1884
- left = popperStyles.left,
1885
- transform = popperStyles[transformProp];
1886
-
1887
- popperStyles.top = '';
1888
- popperStyles.left = '';
1889
- popperStyles[transformProp] = '';
1890
-
1891
- var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
1892
-
1893
- // NOTE: DOM access here
1894
- // restores the original style properties after the offsets have been computed
1895
- popperStyles.top = top;
1896
- popperStyles.left = left;
1897
- popperStyles[transformProp] = transform;
1898
-
1899
- options.boundaries = boundaries;
1900
-
1901
- var order = options.priority;
1902
- var popper = data.offsets.popper;
1903
-
1904
- var check = {
1905
- primary: function primary(placement) {
1906
- var value = popper[placement];
1907
- if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
1908
- value = Math.max(popper[placement], boundaries[placement]);
1909
- }
1910
- return defineProperty({}, placement, value);
1911
- },
1912
- secondary: function secondary(placement) {
1913
- var mainSide = placement === 'right' ? 'left' : 'top';
1914
- var value = popper[mainSide];
1915
- if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
1916
- value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
1627
+ if (_ret === "break") break;
1917
1628
  }
1918
- return defineProperty({}, mainSide, value);
1919
1629
  }
1920
- };
1921
1630
 
1922
- order.forEach(function (placement) {
1923
- var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
1924
- popper = _extends({}, popper, check[side](placement));
1925
- });
1631
+ if (state.placement !== firstFittingPlacement) {
1632
+ state.modifiersData[name]._skip = true;
1633
+ state.placement = firstFittingPlacement;
1634
+ state.reset = true;
1635
+ }
1636
+ } // eslint-disable-next-line import/no-unused-modules
1926
1637
 
1927
- data.offsets.popper = popper;
1928
1638
 
1929
- return data;
1930
- }
1639
+ var flip$1 = {
1640
+ name: 'flip',
1641
+ enabled: true,
1642
+ phase: 'main',
1643
+ fn: flip,
1644
+ requiresIfExists: ['offset'],
1645
+ data: {
1646
+ _skip: false
1647
+ }
1648
+ };
1931
1649
 
1932
- /**
1933
- * @function
1934
- * @memberof Modifiers
1935
- * @argument {Object} data - The data object generated by `update` method
1936
- * @argument {Object} options - Modifiers configuration and options
1937
- * @returns {Object} The data object, properly modified
1938
- */
1939
- function shift(data) {
1940
- var placement = data.placement;
1941
- var basePlacement = placement.split('-')[0];
1942
- var shiftvariation = placement.split('-')[1];
1943
-
1944
- // if shift shiftvariation is specified, run the modifier
1945
- if (shiftvariation) {
1946
- var _data$offsets = data.offsets,
1947
- reference = _data$offsets.reference,
1948
- popper = _data$offsets.popper;
1949
-
1950
- var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
1951
- var side = isVertical ? 'left' : 'top';
1952
- var measurement = isVertical ? 'width' : 'height';
1953
-
1954
- var shiftOffsets = {
1955
- start: defineProperty({}, side, reference[side]),
1956
- end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
1650
+ function getAltAxis(axis) {
1651
+ return axis === 'x' ? 'y' : 'x';
1652
+ }
1653
+
1654
+ function within(min$1, value, max$1) {
1655
+ return max(min$1, min(value, max$1));
1656
+ }
1657
+
1658
+ function preventOverflow(_ref) {
1659
+ var state = _ref.state,
1660
+ options = _ref.options,
1661
+ name = _ref.name;
1662
+ var _options$mainAxis = options.mainAxis,
1663
+ checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1664
+ _options$altAxis = options.altAxis,
1665
+ checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
1666
+ boundary = options.boundary,
1667
+ rootBoundary = options.rootBoundary,
1668
+ altBoundary = options.altBoundary,
1669
+ padding = options.padding,
1670
+ _options$tether = options.tether,
1671
+ tether = _options$tether === void 0 ? true : _options$tether,
1672
+ _options$tetherOffset = options.tetherOffset,
1673
+ tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
1674
+ var overflow = detectOverflow(state, {
1675
+ boundary: boundary,
1676
+ rootBoundary: rootBoundary,
1677
+ padding: padding,
1678
+ altBoundary: altBoundary
1679
+ });
1680
+ var basePlacement = getBasePlacement(state.placement);
1681
+ var variation = getVariation(state.placement);
1682
+ var isBasePlacement = !variation;
1683
+ var mainAxis = getMainAxisFromPlacement(basePlacement);
1684
+ var altAxis = getAltAxis(mainAxis);
1685
+ var popperOffsets = state.modifiersData.popperOffsets;
1686
+ var referenceRect = state.rects.reference;
1687
+ var popperRect = state.rects.popper;
1688
+ var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
1689
+ placement: state.placement
1690
+ })) : tetherOffset;
1691
+ var data = {
1692
+ x: 0,
1693
+ y: 0
1957
1694
  };
1958
1695
 
1959
- data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
1960
- }
1961
-
1962
- return data;
1963
- }
1964
-
1965
- /**
1966
- * @function
1967
- * @memberof Modifiers
1968
- * @argument {Object} data - The data object generated by update method
1969
- * @argument {Object} options - Modifiers configuration and options
1970
- * @returns {Object} The data object, properly modified
1971
- */
1972
- function hide(data) {
1973
- if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
1974
- return data;
1975
- }
1976
-
1977
- var refRect = data.offsets.reference;
1978
- var bound = find(data.instance.modifiers, function (modifier) {
1979
- return modifier.name === 'preventOverflow';
1980
- }).boundaries;
1981
-
1982
- if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
1983
- // Avoid unnecessary DOM access if visibility hasn't changed
1984
- if (data.hide === true) {
1985
- return data;
1696
+ if (!popperOffsets) {
1697
+ return;
1986
1698
  }
1987
1699
 
1988
- data.hide = true;
1989
- data.attributes['x-out-of-boundaries'] = '';
1990
- } else {
1991
- // Avoid unnecessary DOM access if visibility hasn't changed
1992
- if (data.hide === false) {
1993
- return data;
1994
- }
1700
+ if (checkMainAxis || checkAltAxis) {
1701
+ var mainSide = mainAxis === 'y' ? top : left;
1702
+ var altSide = mainAxis === 'y' ? bottom : right;
1703
+ var len = mainAxis === 'y' ? 'height' : 'width';
1704
+ var offset = popperOffsets[mainAxis];
1705
+ var min$1 = popperOffsets[mainAxis] + overflow[mainSide];
1706
+ var max$1 = popperOffsets[mainAxis] - overflow[altSide];
1707
+ var additive = tether ? -popperRect[len] / 2 : 0;
1708
+ var minLen = variation === start ? referenceRect[len] : popperRect[len];
1709
+ var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
1710
+ // outside the reference bounds
1711
+
1712
+ var arrowElement = state.elements.arrow;
1713
+ var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
1714
+ width: 0,
1715
+ height: 0
1716
+ };
1717
+ var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
1718
+ var arrowPaddingMin = arrowPaddingObject[mainSide];
1719
+ var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
1720
+ // to include its full size in the calculation. If the reference is small
1721
+ // and near the edge of a boundary, the popper can overflow even if the
1722
+ // reference is not overflowing as well (e.g. virtual elements with no
1723
+ // width or height)
1724
+
1725
+ var arrowLen = within(0, referenceRect[len], arrowRect[len]);
1726
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
1727
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
1728
+ var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
1729
+ var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
1730
+ var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
1731
+ var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
1732
+ var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
1733
+
1734
+ if (checkMainAxis) {
1735
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
1736
+ popperOffsets[mainAxis] = preventedOffset;
1737
+ data[mainAxis] = preventedOffset - offset;
1738
+ }
1995
1739
 
1996
- data.hide = false;
1997
- data.attributes['x-out-of-boundaries'] = false;
1998
- }
1740
+ if (checkAltAxis) {
1741
+ var _mainSide = mainAxis === 'x' ? top : left;
1999
1742
 
2000
- return data;
2001
- }
1743
+ var _altSide = mainAxis === 'x' ? bottom : right;
2002
1744
 
2003
- /**
2004
- * @function
2005
- * @memberof Modifiers
2006
- * @argument {Object} data - The data object generated by `update` method
2007
- * @argument {Object} options - Modifiers configuration and options
2008
- * @returns {Object} The data object, properly modified
2009
- */
2010
- function inner(data) {
2011
- var placement = data.placement;
2012
- var basePlacement = placement.split('-')[0];
2013
- var _data$offsets = data.offsets,
2014
- popper = _data$offsets.popper,
2015
- reference = _data$offsets.reference;
1745
+ var _offset = popperOffsets[altAxis];
2016
1746
 
2017
- var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
1747
+ var _min = _offset + overflow[_mainSide];
2018
1748
 
2019
- var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
1749
+ var _max = _offset - overflow[_altSide];
2020
1750
 
2021
- popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
1751
+ var _preventedOffset = within(tether ? min(_min, tetherMin) : _min, _offset, tether ? max(_max, tetherMax) : _max);
2022
1752
 
2023
- data.placement = getOppositePlacement(placement);
2024
- data.offsets.popper = getClientRect(popper);
1753
+ popperOffsets[altAxis] = _preventedOffset;
1754
+ data[altAxis] = _preventedOffset - _offset;
1755
+ }
1756
+ }
2025
1757
 
2026
- return data;
2027
- }
1758
+ state.modifiersData[name] = data;
1759
+ } // eslint-disable-next-line import/no-unused-modules
2028
1760
 
2029
- /**
2030
- * Modifier function, each modifier can have a function of this type assigned
2031
- * to its `fn` property.<br />
2032
- * These functions will be called on each update, this means that you must
2033
- * make sure they are performant enough to avoid performance bottlenecks.
2034
- *
2035
- * @function ModifierFn
2036
- * @argument {dataObject} data - The data object generated by `update` method
2037
- * @argument {Object} options - Modifiers configuration and options
2038
- * @returns {dataObject} The data object, properly modified
2039
- */
2040
1761
 
2041
- /**
2042
- * Modifiers are plugins used to alter the behavior of your poppers.<br />
2043
- * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
2044
- * needed by the library.
2045
- *
2046
- * Usually you don't want to override the `order`, `fn` and `onLoad` props.
2047
- * All the other properties are configurations that could be tweaked.
2048
- * @namespace modifiers
2049
- */
2050
- var modifiers = {
2051
- /**
2052
- * Modifier used to shift the popper on the start or end of its reference
2053
- * element.<br />
2054
- * It will read the variation of the `placement` property.<br />
2055
- * It can be one either `-end` or `-start`.
2056
- * @memberof modifiers
2057
- * @inner
2058
- */
2059
- shift: {
2060
- /** @prop {number} order=100 - Index used to define the order of execution */
2061
- order: 100,
2062
- /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
1762
+ var preventOverflow$1 = {
1763
+ name: 'preventOverflow',
2063
1764
  enabled: true,
2064
- /** @prop {ModifierFn} */
2065
- fn: shift
2066
- },
2067
-
2068
- /**
2069
- * The `offset` modifier can shift your popper on both its axis.
2070
- *
2071
- * It accepts the following units:
2072
- * - `px` or unit-less, interpreted as pixels
2073
- * - `%` or `%r`, percentage relative to the length of the reference element
2074
- * - `%p`, percentage relative to the length of the popper element
2075
- * - `vw`, CSS viewport width unit
2076
- * - `vh`, CSS viewport height unit
2077
- *
2078
- * For length is intended the main axis relative to the placement of the popper.<br />
2079
- * This means that if the placement is `top` or `bottom`, the length will be the
2080
- * `width`. In case of `left` or `right`, it will be the `height`.
2081
- *
2082
- * You can provide a single value (as `Number` or `String`), or a pair of values
2083
- * as `String` divided by a comma or one (or more) white spaces.<br />
2084
- * The latter is a deprecated method because it leads to confusion and will be
2085
- * removed in v2.<br />
2086
- * Additionally, it accepts additions and subtractions between different units.
2087
- * Note that multiplications and divisions aren't supported.
2088
- *
2089
- * Valid examples are:
2090
- * ```
2091
- * 10
2092
- * '10%'
2093
- * '10, 10'
2094
- * '10%, 10'
2095
- * '10 + 10%'
2096
- * '10 - 5vh + 3%'
2097
- * '-10px + 5vh, 5px - 6%'
2098
- * ```
2099
- * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
2100
- * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
2101
- * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
2102
- *
2103
- * @memberof modifiers
2104
- * @inner
2105
- */
2106
- offset: {
2107
- /** @prop {number} order=200 - Index used to define the order of execution */
2108
- order: 200,
2109
- /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
2110
- enabled: true,
2111
- /** @prop {ModifierFn} */
2112
- fn: offset,
2113
- /** @prop {Number|String} offset=0
2114
- * The offset value as described in the modifier description
2115
- */
2116
- offset: 0
2117
- },
2118
-
2119
- /**
2120
- * Modifier used to prevent the popper from being positioned outside the boundary.
2121
- *
2122
- * A scenario exists where the reference itself is not within the boundaries.<br />
2123
- * We can say it has "escaped the boundaries" — or just "escaped".<br />
2124
- * In this case we need to decide whether the popper should either:
2125
- *
2126
- * - detach from the reference and remain "trapped" in the boundaries, or
2127
- * - if it should ignore the boundary and "escape with its reference"
2128
- *
2129
- * When `escapeWithReference` is set to`true` and reference is completely
2130
- * outside its boundaries, the popper will overflow (or completely leave)
2131
- * the boundaries in order to remain attached to the edge of the reference.
2132
- *
2133
- * @memberof modifiers
2134
- * @inner
2135
- */
2136
- preventOverflow: {
2137
- /** @prop {number} order=300 - Index used to define the order of execution */
2138
- order: 300,
2139
- /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
2140
- enabled: true,
2141
- /** @prop {ModifierFn} */
1765
+ phase: 'main',
2142
1766
  fn: preventOverflow,
2143
- /**
2144
- * @prop {Array} [priority=['left','right','top','bottom']]
2145
- * Popper will try to prevent overflow following these priorities by default,
2146
- * then, it could overflow on the left and on top of the `boundariesElement`
2147
- */
2148
- priority: ['left', 'right', 'top', 'bottom'],
2149
- /**
2150
- * @prop {number} padding=5
2151
- * Amount of pixel used to define a minimum distance between the boundaries
2152
- * and the popper. This makes sure the popper always has a little padding
2153
- * between the edges of its container
2154
- */
2155
- padding: 5,
2156
- /**
2157
- * @prop {String|HTMLElement} boundariesElement='scrollParent'
2158
- * Boundaries used by the modifier. Can be `scrollParent`, `window`,
2159
- * `viewport` or any DOM element.
2160
- */
2161
- boundariesElement: 'scrollParent'
2162
- },
2163
-
2164
- /**
2165
- * Modifier used to make sure the reference and its popper stay near each other
2166
- * without leaving any gap between the two. Especially useful when the arrow is
2167
- * enabled and you want to ensure that it points to its reference element.
2168
- * It cares only about the first axis. You can still have poppers with margin
2169
- * between the popper and its reference element.
2170
- * @memberof modifiers
2171
- * @inner
2172
- */
2173
- keepTogether: {
2174
- /** @prop {number} order=400 - Index used to define the order of execution */
2175
- order: 400,
2176
- /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
2177
- enabled: true,
2178
- /** @prop {ModifierFn} */
2179
- fn: keepTogether
2180
- },
2181
-
2182
- /**
2183
- * This modifier is used to move the `arrowElement` of the popper to make
2184
- * sure it is positioned between the reference element and its popper element.
2185
- * It will read the outer size of the `arrowElement` node to detect how many
2186
- * pixels of conjunction are needed.
2187
- *
2188
- * It has no effect if no `arrowElement` is provided.
2189
- * @memberof modifiers
2190
- * @inner
2191
- */
2192
- arrow: {
2193
- /** @prop {number} order=500 - Index used to define the order of execution */
2194
- order: 500,
2195
- /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
2196
- enabled: true,
2197
- /** @prop {ModifierFn} */
2198
- fn: arrow,
2199
- /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
2200
- element: '[x-arrow]'
2201
- },
2202
-
2203
- /**
2204
- * Modifier used to flip the popper's placement when it starts to overlap its
2205
- * reference element.
2206
- *
2207
- * Requires the `preventOverflow` modifier before it in order to work.
2208
- *
2209
- * **NOTE:** this modifier will interrupt the current update cycle and will
2210
- * restart it if it detects the need to flip the placement.
2211
- * @memberof modifiers
2212
- * @inner
2213
- */
2214
- flip: {
2215
- /** @prop {number} order=600 - Index used to define the order of execution */
2216
- order: 600,
2217
- /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
2218
- enabled: true,
2219
- /** @prop {ModifierFn} */
2220
- fn: flip,
2221
- /**
2222
- * @prop {String|Array} behavior='flip'
2223
- * The behavior used to change the popper's placement. It can be one of
2224
- * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
2225
- * placements (with optional variations)
2226
- */
2227
- behavior: 'flip',
2228
- /**
2229
- * @prop {number} padding=5
2230
- * The popper will flip if it hits the edges of the `boundariesElement`
2231
- */
2232
- padding: 5,
2233
- /**
2234
- * @prop {String|HTMLElement} boundariesElement='viewport'
2235
- * The element which will define the boundaries of the popper position.
2236
- * The popper will never be placed outside of the defined boundaries
2237
- * (except if `keepTogether` is enabled)
2238
- */
2239
- boundariesElement: 'viewport',
2240
- /**
2241
- * @prop {Boolean} flipVariations=false
2242
- * The popper will switch placement variation between `-start` and `-end` when
2243
- * the reference element overlaps its boundaries.
2244
- *
2245
- * The original placement should have a set variation.
2246
- */
2247
- flipVariations: false,
2248
- /**
2249
- * @prop {Boolean} flipVariationsByContent=false
2250
- * The popper will switch placement variation between `-start` and `-end` when
2251
- * the popper element overlaps its reference boundaries.
2252
- *
2253
- * The original placement should have a set variation.
2254
- */
2255
- flipVariationsByContent: false
2256
- },
2257
-
2258
- /**
2259
- * Modifier used to make the popper flow toward the inner of the reference element.
2260
- * By default, when this modifier is disabled, the popper will be placed outside
2261
- * the reference element.
2262
- * @memberof modifiers
2263
- * @inner
2264
- */
2265
- inner: {
2266
- /** @prop {number} order=700 - Index used to define the order of execution */
2267
- order: 700,
2268
- /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
2269
- enabled: false,
2270
- /** @prop {ModifierFn} */
2271
- fn: inner
2272
- },
2273
-
2274
- /**
2275
- * Modifier used to hide the popper when its reference element is outside of the
2276
- * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
2277
- * be used to hide with a CSS selector the popper when its reference is
2278
- * out of boundaries.
2279
- *
2280
- * Requires the `preventOverflow` modifier before it in order to work.
2281
- * @memberof modifiers
2282
- * @inner
2283
- */
2284
- hide: {
2285
- /** @prop {number} order=800 - Index used to define the order of execution */
2286
- order: 800,
2287
- /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
2288
- enabled: true,
2289
- /** @prop {ModifierFn} */
2290
- fn: hide
2291
- },
2292
-
2293
- /**
2294
- * Computes the style that will be applied to the popper element to gets
2295
- * properly positioned.
2296
- *
2297
- * Note that this modifier will not touch the DOM, it just prepares the styles
2298
- * so that `applyStyle` modifier can apply it. This separation is useful
2299
- * in case you need to replace `applyStyle` with a custom implementation.
2300
- *
2301
- * This modifier has `850` as `order` value to maintain backward compatibility
2302
- * with previous versions of Popper.js. Expect the modifiers ordering method
2303
- * to change in future major versions of the library.
2304
- *
2305
- * @memberof modifiers
2306
- * @inner
2307
- */
2308
- computeStyle: {
2309
- /** @prop {number} order=850 - Index used to define the order of execution */
2310
- order: 850,
2311
- /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
2312
- enabled: true,
2313
- /** @prop {ModifierFn} */
2314
- fn: computeStyle,
2315
- /**
2316
- * @prop {Boolean} gpuAcceleration=true
2317
- * If true, it uses the CSS 3D transformation to position the popper.
2318
- * Otherwise, it will use the `top` and `left` properties
2319
- */
2320
- gpuAcceleration: true,
2321
- /**
2322
- * @prop {string} [x='bottom']
2323
- * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
2324
- * Change this if your popper should grow in a direction different from `bottom`
2325
- */
2326
- x: 'bottom',
2327
- /**
2328
- * @prop {string} [x='left']
2329
- * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
2330
- * Change this if your popper should grow in a direction different from `right`
2331
- */
2332
- y: 'right'
2333
- },
2334
-
2335
- /**
2336
- * Applies the computed styles to the popper element.
2337
- *
2338
- * All the DOM manipulations are limited to this modifier. This is useful in case
2339
- * you want to integrate Popper.js inside a framework or view library and you
2340
- * want to delegate all the DOM manipulations to it.
2341
- *
2342
- * Note that if you disable this modifier, you must make sure the popper element
2343
- * has its position set to `absolute` before Popper.js can do its work!
2344
- *
2345
- * Just disable this modifier and define your own to achieve the desired effect.
2346
- *
2347
- * @memberof modifiers
2348
- * @inner
2349
- */
2350
- applyStyle: {
2351
- /** @prop {number} order=900 - Index used to define the order of execution */
2352
- order: 900,
2353
- /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
2354
- enabled: true,
2355
- /** @prop {ModifierFn} */
2356
- fn: applyStyle,
2357
- /** @prop {Function} */
2358
- onLoad: applyStyleOnLoad,
2359
- /**
2360
- * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
2361
- * @prop {Boolean} gpuAcceleration=true
2362
- * If true, it uses the CSS 3D transformation to position the popper.
2363
- * Otherwise, it will use the `top` and `left` properties
2364
- */
2365
- gpuAcceleration: undefined
2366
- }
2367
- };
2368
-
2369
- /**
2370
- * The `dataObject` is an object containing all the information used by Popper.js.
2371
- * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
2372
- * @name dataObject
2373
- * @property {Object} data.instance The Popper.js instance
2374
- * @property {String} data.placement Placement applied to popper
2375
- * @property {String} data.originalPlacement Placement originally defined on init
2376
- * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
2377
- * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
2378
- * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
2379
- * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
2380
- * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
2381
- * @property {Object} data.boundaries Offsets of the popper boundaries
2382
- * @property {Object} data.offsets The measurements of popper, reference and arrow elements
2383
- * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
2384
- * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
2385
- * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
2386
- */
2387
-
2388
- /**
2389
- * Default options provided to Popper.js constructor.<br />
2390
- * These can be overridden using the `options` argument of Popper.js.<br />
2391
- * To override an option, simply pass an object with the same
2392
- * structure of the `options` object, as the 3rd argument. For example:
2393
- * ```
2394
- * new Popper(ref, pop, {
2395
- * modifiers: {
2396
- * preventOverflow: { enabled: false }
2397
- * }
2398
- * })
2399
- * ```
2400
- * @type {Object}
2401
- * @static
2402
- * @memberof Popper
2403
- */
2404
- var Defaults = {
2405
- /**
2406
- * Popper's placement.
2407
- * @prop {Popper.placements} placement='bottom'
2408
- */
2409
- placement: 'bottom',
2410
-
2411
- /**
2412
- * Set this to true if you want popper to position it self in 'fixed' mode
2413
- * @prop {Boolean} positionFixed=false
2414
- */
2415
- positionFixed: false,
2416
-
2417
- /**
2418
- * Whether events (resize, scroll) are initially enabled.
2419
- * @prop {Boolean} eventsEnabled=true
2420
- */
2421
- eventsEnabled: true,
2422
-
2423
- /**
2424
- * Set to true if you want to automatically remove the popper when
2425
- * you call the `destroy` method.
2426
- * @prop {Boolean} removeOnDestroy=false
2427
- */
2428
- removeOnDestroy: false,
2429
-
2430
- /**
2431
- * Callback called when the popper is created.<br />
2432
- * By default, it is set to no-op.<br />
2433
- * Access Popper.js instance with `data.instance`.
2434
- * @prop {onCreate}
2435
- */
2436
- onCreate: function onCreate() {},
2437
-
2438
- /**
2439
- * Callback called when the popper is updated. This callback is not called
2440
- * on the initialization/creation of the popper, but only on subsequent
2441
- * updates.<br />
2442
- * By default, it is set to no-op.<br />
2443
- * Access Popper.js instance with `data.instance`.
2444
- * @prop {onUpdate}
2445
- */
2446
- onUpdate: function onUpdate() {},
2447
-
2448
- /**
2449
- * List of modifiers used to modify the offsets before they are applied to the popper.
2450
- * They provide most of the functionalities of Popper.js.
2451
- * @prop {modifiers}
2452
- */
2453
- modifiers: modifiers
2454
- };
2455
-
2456
- /**
2457
- * @callback onCreate
2458
- * @param {dataObject} data
2459
- */
1767
+ requiresIfExists: ['offset']
1768
+ };
2460
1769
 
2461
- /**
2462
- * @callback onUpdate
2463
- * @param {dataObject} data
2464
- */
1770
+ var toPaddingObject = function toPaddingObject(padding, state) {
1771
+ padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
1772
+ placement: state.placement
1773
+ })) : padding;
1774
+ return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
1775
+ };
2465
1776
 
2466
- // Utils
2467
- // Methods
2468
- var Popper = function () {
2469
- /**
2470
- * Creates a new Popper.js instance.
2471
- * @class Popper
2472
- * @param {Element|referenceObject} reference - The reference element used to position the popper
2473
- * @param {Element} popper - The HTML / XML element used as the popper
2474
- * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
2475
- * @return {Object} instance - The generated Popper.js instance
2476
- */
2477
- function Popper(reference, popper) {
2478
- var _this = this;
2479
-
2480
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2481
- classCallCheck(this, Popper);
2482
-
2483
- this.scheduleUpdate = function () {
2484
- return requestAnimationFrame(_this.update);
2485
- };
1777
+ function arrow(_ref) {
1778
+ var _state$modifiersData$;
2486
1779
 
2487
- // make update() debounced, so that it only runs at most once-per-tick
2488
- this.update = debounce(this.update.bind(this));
1780
+ var state = _ref.state,
1781
+ name = _ref.name,
1782
+ options = _ref.options;
1783
+ var arrowElement = state.elements.arrow;
1784
+ var popperOffsets = state.modifiersData.popperOffsets;
1785
+ var basePlacement = getBasePlacement(state.placement);
1786
+ var axis = getMainAxisFromPlacement(basePlacement);
1787
+ var isVertical = [left, right].indexOf(basePlacement) >= 0;
1788
+ var len = isVertical ? 'height' : 'width';
2489
1789
 
2490
- // with {} we create a new object with the options inside it
2491
- this.options = _extends({}, Popper.Defaults, options);
1790
+ if (!arrowElement || !popperOffsets) {
1791
+ return;
1792
+ }
2492
1793
 
2493
- // init state
2494
- this.state = {
2495
- isDestroyed: false,
2496
- isCreated: false,
2497
- scrollParents: []
2498
- };
1794
+ var paddingObject = toPaddingObject(options.padding, state);
1795
+ var arrowRect = getLayoutRect(arrowElement);
1796
+ var minProp = axis === 'y' ? top : left;
1797
+ var maxProp = axis === 'y' ? bottom : right;
1798
+ var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
1799
+ var startDiff = popperOffsets[axis] - state.rects.reference[axis];
1800
+ var arrowOffsetParent = getOffsetParent(arrowElement);
1801
+ var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
1802
+ var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
1803
+ // outside of the popper bounds
1804
+
1805
+ var min = paddingObject[minProp];
1806
+ var max = clientSize - arrowRect[len] - paddingObject[maxProp];
1807
+ var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
1808
+ var offset = within(min, center, max); // Prevents breaking syntax highlighting...
1809
+
1810
+ var axisProp = axis;
1811
+ state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
1812
+ }
1813
+
1814
+ function effect(_ref2) {
1815
+ var state = _ref2.state,
1816
+ options = _ref2.options;
1817
+ var _options$element = options.element,
1818
+ arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
1819
+
1820
+ if (arrowElement == null) {
1821
+ return;
1822
+ } // CSS selector
2499
1823
 
2500
- // get reference and popper elements (allow jQuery wrappers)
2501
- this.reference = reference && reference.jquery ? reference[0] : reference;
2502
- this.popper = popper && popper.jquery ? popper[0] : popper;
2503
1824
 
2504
- // Deep merge modifiers options
2505
- this.options.modifiers = {};
2506
- Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
2507
- _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
2508
- });
1825
+ if (typeof arrowElement === 'string') {
1826
+ arrowElement = state.elements.popper.querySelector(arrowElement);
2509
1827
 
2510
- // Refactoring modifiers' list (Object => Array)
2511
- this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
2512
- return _extends({
2513
- name: name
2514
- }, _this.options.modifiers[name]);
2515
- })
2516
- // sort the modifiers by order
2517
- .sort(function (a, b) {
2518
- return a.order - b.order;
2519
- });
1828
+ if (!arrowElement) {
1829
+ return;
1830
+ }
1831
+ }
2520
1832
 
2521
- // modifiers have the ability to execute arbitrary code when Popper.js get inited
2522
- // such code is executed in the same order of its modifier
2523
- // they could add new properties to their options configuration
2524
- // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
2525
- this.modifiers.forEach(function (modifierOptions) {
2526
- if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
2527
- modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
1833
+ {
1834
+ if (!isHTMLElement(arrowElement)) {
1835
+ console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).', 'To use an SVG arrow, wrap it in an HTMLElement that will be used as', 'the arrow.'].join(' '));
2528
1836
  }
2529
- });
1837
+ }
2530
1838
 
2531
- // fire the first update to position the popper in the right place
2532
- this.update();
1839
+ if (!contains(state.elements.popper, arrowElement)) {
1840
+ {
1841
+ console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', 'element.'].join(' '));
1842
+ }
2533
1843
 
2534
- var eventsEnabled = this.options.eventsEnabled;
2535
- if (eventsEnabled) {
2536
- // setup event listeners, they will take care of update the position in specific situations
2537
- this.enableEventListeners();
1844
+ return;
2538
1845
  }
2539
1846
 
2540
- this.state.eventsEnabled = eventsEnabled;
2541
- }
1847
+ state.elements.arrow = arrowElement;
1848
+ } // eslint-disable-next-line import/no-unused-modules
2542
1849
 
2543
- // We can't use class properties because they don't get listed in the
2544
- // class prototype and break stuff like Sinon stubs
2545
1850
 
1851
+ var arrow$1 = {
1852
+ name: 'arrow',
1853
+ enabled: true,
1854
+ phase: 'main',
1855
+ fn: arrow,
1856
+ effect: effect,
1857
+ requires: ['popperOffsets'],
1858
+ requiresIfExists: ['preventOverflow']
1859
+ };
2546
1860
 
2547
- createClass(Popper, [{
2548
- key: 'update',
2549
- value: function update$$1() {
2550
- return update.call(this);
2551
- }
2552
- }, {
2553
- key: 'destroy',
2554
- value: function destroy$$1() {
2555
- return destroy.call(this);
2556
- }
2557
- }, {
2558
- key: 'enableEventListeners',
2559
- value: function enableEventListeners$$1() {
2560
- return enableEventListeners.call(this);
2561
- }
2562
- }, {
2563
- key: 'disableEventListeners',
2564
- value: function disableEventListeners$$1() {
2565
- return disableEventListeners.call(this);
1861
+ function getSideOffsets(overflow, rect, preventedOffsets) {
1862
+ if (preventedOffsets === void 0) {
1863
+ preventedOffsets = {
1864
+ x: 0,
1865
+ y: 0
1866
+ };
2566
1867
  }
2567
1868
 
2568
- /**
2569
- * Schedules an update. It will run on the next UI update available.
2570
- * @method scheduleUpdate
2571
- * @memberof Popper
2572
- */
2573
-
2574
-
2575
- /**
2576
- * Collection of utilities useful when writing custom modifiers.
2577
- * Starting from version 1.7, this method is available only if you
2578
- * include `popper-utils.js` before `popper.js`.
2579
- *
2580
- * **DEPRECATION**: This way to access PopperUtils is deprecated
2581
- * and will be removed in v2! Use the PopperUtils module directly instead.
2582
- * Due to the high instability of the methods contained in Utils, we can't
2583
- * guarantee them to follow semver. Use them at your own risk!
2584
- * @static
2585
- * @private
2586
- * @type {Object}
2587
- * @deprecated since version 1.8
2588
- * @member Utils
2589
- * @memberof Popper
2590
- */
2591
-
2592
- }]);
2593
- return Popper;
2594
- }();
1869
+ return {
1870
+ top: overflow.top - rect.height - preventedOffsets.y,
1871
+ right: overflow.right - rect.width + preventedOffsets.x,
1872
+ bottom: overflow.bottom - rect.height + preventedOffsets.y,
1873
+ left: overflow.left - rect.width - preventedOffsets.x
1874
+ };
1875
+ }
1876
+
1877
+ function isAnySideFullyClipped(overflow) {
1878
+ return [top, right, bottom, left].some(function (side) {
1879
+ return overflow[side] >= 0;
1880
+ });
1881
+ }
2595
1882
 
2596
- /**
2597
- * The `referenceObject` is an object that provides an interface compatible with Popper.js
2598
- * and lets you use it as replacement of a real DOM node.<br />
2599
- * You can use this method to position a popper relatively to a set of coordinates
2600
- * in case you don't have a DOM node to use as reference.
2601
- *
2602
- * ```
2603
- * new Popper(referenceObject, popperNode);
2604
- * ```
2605
- *
2606
- * NB: This feature isn't supported in Internet Explorer 10.
2607
- * @name referenceObject
2608
- * @property {Function} data.getBoundingClientRect
2609
- * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
2610
- * @property {number} data.clientWidth
2611
- * An ES6 getter that will return the width of the virtual reference element.
2612
- * @property {number} data.clientHeight
2613
- * An ES6 getter that will return the height of the virtual reference element.
2614
- */
1883
+ function hide(_ref) {
1884
+ var state = _ref.state,
1885
+ name = _ref.name;
1886
+ var referenceRect = state.rects.reference;
1887
+ var popperRect = state.rects.popper;
1888
+ var preventedOffsets = state.modifiersData.preventOverflow;
1889
+ var referenceOverflow = detectOverflow(state, {
1890
+ elementContext: 'reference'
1891
+ });
1892
+ var popperAltOverflow = detectOverflow(state, {
1893
+ altBoundary: true
1894
+ });
1895
+ var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
1896
+ var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
1897
+ var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
1898
+ var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
1899
+ state.modifiersData[name] = {
1900
+ referenceClippingOffsets: referenceClippingOffsets,
1901
+ popperEscapeOffsets: popperEscapeOffsets,
1902
+ isReferenceHidden: isReferenceHidden,
1903
+ hasPopperEscaped: hasPopperEscaped
1904
+ };
1905
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
1906
+ 'data-popper-reference-hidden': isReferenceHidden,
1907
+ 'data-popper-escaped': hasPopperEscaped
1908
+ });
1909
+ } // eslint-disable-next-line import/no-unused-modules
2615
1910
 
2616
1911
 
2617
- Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
2618
- Popper.placements = placements;
2619
- Popper.Defaults = Defaults;
1912
+ var hide$1 = {
1913
+ name: 'hide',
1914
+ enabled: true,
1915
+ phase: 'main',
1916
+ requiresIfExists: ['preventOverflow'],
1917
+ fn: hide
1918
+ };
2620
1919
 
2621
- return Popper;
1920
+ var defaultModifiers$1 = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1];
1921
+ var createPopper$1 = /*#__PURE__*/popperGenerator({
1922
+ defaultModifiers: defaultModifiers$1
1923
+ }); // eslint-disable-next-line import/no-unused-modules
1924
+
1925
+ var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
1926
+ var createPopper = /*#__PURE__*/popperGenerator({
1927
+ defaultModifiers: defaultModifiers
1928
+ }); // eslint-disable-next-line import/no-unused-modules
1929
+
1930
+ exports.applyStyles = applyStyles$1;
1931
+ exports.arrow = arrow$1;
1932
+ exports.computeStyles = computeStyles$1;
1933
+ exports.createPopper = createPopper;
1934
+ exports.createPopperLite = createPopper$1;
1935
+ exports.defaultModifiers = defaultModifiers;
1936
+ exports.detectOverflow = detectOverflow;
1937
+ exports.eventListeners = eventListeners;
1938
+ exports.flip = flip$1;
1939
+ exports.hide = hide$1;
1940
+ exports.offset = offset$1;
1941
+ exports.popperGenerator = popperGenerator;
1942
+ exports.popperOffsets = popperOffsets$1;
1943
+ exports.preventOverflow = preventOverflow$1;
1944
+
1945
+ Object.defineProperty(exports, '__esModule', { value: true });
2622
1946
 
2623
1947
  })));