@lumx/react 3.0.2-alpha-react-utils.2 → 3.0.2-alpha-react-utils.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (357) hide show
  1. package/_internal/{6340c129.js → ClickAwayProvider.js} +107 -2
  2. package/_internal/ClickAwayProvider.js.map +1 -0
  3. package/_internal/{eca6d4dc.d.ts → types.d.ts} +1 -1
  4. package/index.d.ts +2627 -56
  5. package/index.js +12438 -56
  6. package/index.js.map +1 -1
  7. package/package.json +4 -4
  8. package/utils/index.d.ts +1 -1
  9. package/utils/index.js +1 -1
  10. package/_internal/0062d1bc.js +0 -220
  11. package/_internal/0062d1bc.js.map +0 -1
  12. package/_internal/03e8323d.d.ts +0 -118
  13. package/_internal/0402f9bc.d.ts +0 -183
  14. package/_internal/0b370acc.js +0 -796
  15. package/_internal/0b370acc.js.map +0 -1
  16. package/_internal/0d154d73.d.ts +0 -67
  17. package/_internal/113e3b40.d.ts +0 -31
  18. package/_internal/12ab39e4.js +0 -58
  19. package/_internal/12ab39e4.js.map +0 -1
  20. package/_internal/13e759f3.js +0 -343
  21. package/_internal/13e759f3.js.map +0 -1
  22. package/_internal/158b46d5.js +0 -151
  23. package/_internal/158b46d5.js.map +0 -1
  24. package/_internal/17b74e16.d.ts +0 -31
  25. package/_internal/1b1530a4.d.ts +0 -43
  26. package/_internal/20976405.js +0 -87
  27. package/_internal/20976405.js.map +0 -1
  28. package/_internal/20b0e9a5.d.ts +0 -77
  29. package/_internal/26cd9c63.js +0 -118
  30. package/_internal/26cd9c63.js.map +0 -1
  31. package/_internal/27f21164.js +0 -79
  32. package/_internal/27f21164.js.map +0 -1
  33. package/_internal/288dfd0f.js +0 -13
  34. package/_internal/288dfd0f.js.map +0 -1
  35. package/_internal/28aaf23a.d.ts +0 -41
  36. package/_internal/2c829c0b.d.ts +0 -57
  37. package/_internal/2cc0aec5.js +0 -86
  38. package/_internal/2cc0aec5.js.map +0 -1
  39. package/_internal/2d0a5b28.js +0 -23
  40. package/_internal/2d0a5b28.js.map +0 -1
  41. package/_internal/2d4b5a5e.d.ts +0 -92
  42. package/_internal/2d770113.d.ts +0 -38
  43. package/_internal/2fe97f00.js +0 -291
  44. package/_internal/2fe97f00.js.map +0 -1
  45. package/_internal/31c16fa0.d.ts +0 -37
  46. package/_internal/329a01d3.js +0 -25
  47. package/_internal/329a01d3.js.map +0 -1
  48. package/_internal/3326e990.js +0 -168
  49. package/_internal/3326e990.js.map +0 -1
  50. package/_internal/377b2f44.js +0 -70
  51. package/_internal/377b2f44.js.map +0 -1
  52. package/_internal/3b8d2a6e.js +0 -124
  53. package/_internal/3b8d2a6e.js.map +0 -1
  54. package/_internal/3bd3186e.d.ts +0 -57
  55. package/_internal/48e40868.js +0 -101
  56. package/_internal/48e40868.js.map +0 -1
  57. package/_internal/490ec1da.js +0 -322
  58. package/_internal/490ec1da.js.map +0 -1
  59. package/_internal/49127d69.d.ts +0 -52
  60. package/_internal/4dcd87cb.js +0 -78
  61. package/_internal/4dcd87cb.js.map +0 -1
  62. package/_internal/4f44d848.js +0 -157
  63. package/_internal/4f44d848.js.map +0 -1
  64. package/_internal/4fc64a2e.js +0 -27
  65. package/_internal/4fc64a2e.js.map +0 -1
  66. package/_internal/53a831be.js +0 -108
  67. package/_internal/53a831be.js.map +0 -1
  68. package/_internal/55271fa1.d.ts +0 -34
  69. package/_internal/55d30377.d.ts +0 -22
  70. package/_internal/56385b04.js +0 -116
  71. package/_internal/56385b04.js.map +0 -1
  72. package/_internal/599e250a.d.ts +0 -88
  73. package/_internal/5a054691.d.ts +0 -33
  74. package/_internal/5a127b58.js +0 -82
  75. package/_internal/5a127b58.js.map +0 -1
  76. package/_internal/5a1c0db4.js +0 -156
  77. package/_internal/5a1c0db4.js.map +0 -1
  78. package/_internal/5babcc39.js +0 -147
  79. package/_internal/5babcc39.js.map +0 -1
  80. package/_internal/5c1bf4d4.d.ts +0 -81
  81. package/_internal/5d8ed4ee.js +0 -113
  82. package/_internal/5d8ed4ee.js.map +0 -1
  83. package/_internal/616f2912.js +0 -301
  84. package/_internal/616f2912.js.map +0 -1
  85. package/_internal/61f915de.d.ts +0 -49
  86. package/_internal/620081fa.js +0 -122
  87. package/_internal/620081fa.js.map +0 -1
  88. package/_internal/6340c129.js.map +0 -1
  89. package/_internal/6581c863.d.ts +0 -34
  90. package/_internal/66de4d45.d.ts +0 -32
  91. package/_internal/6735c5c8.d.ts +0 -62
  92. package/_internal/69dd1472.js +0 -112
  93. package/_internal/69dd1472.js.map +0 -1
  94. package/_internal/6a0e1c77.js +0 -327
  95. package/_internal/6a0e1c77.js.map +0 -1
  96. package/_internal/701c20b0.d.ts +0 -24
  97. package/_internal/7391188a.js +0 -81
  98. package/_internal/7391188a.js.map +0 -1
  99. package/_internal/74cb6c26.js +0 -136
  100. package/_internal/74cb6c26.js.map +0 -1
  101. package/_internal/761031bf.js +0 -314
  102. package/_internal/761031bf.js.map +0 -1
  103. package/_internal/76fed69d.js +0 -50
  104. package/_internal/76fed69d.js.map +0 -1
  105. package/_internal/78ef8e34.js +0 -40
  106. package/_internal/78ef8e34.js.map +0 -1
  107. package/_internal/7b906e16.d.ts +0 -17
  108. package/_internal/7be11ddc.d.ts +0 -35
  109. package/_internal/7d39705e.d.ts +0 -20
  110. package/_internal/7e03266f.js +0 -47
  111. package/_internal/7e03266f.js.map +0 -1
  112. package/_internal/7e8d0ac5.js +0 -84
  113. package/_internal/7e8d0ac5.js.map +0 -1
  114. package/_internal/7ffa45f6.js +0 -48
  115. package/_internal/7ffa45f6.js.map +0 -1
  116. package/_internal/84c1ec44.js +0 -257
  117. package/_internal/84c1ec44.js.map +0 -1
  118. package/_internal/8518279f.js +0 -96
  119. package/_internal/8518279f.js.map +0 -1
  120. package/_internal/853713cd.js +0 -25
  121. package/_internal/853713cd.js.map +0 -1
  122. package/_internal/86566d75.d.ts +0 -27
  123. package/_internal/86d22dde.d.ts +0 -57
  124. package/_internal/8e755ded.d.ts +0 -101
  125. package/_internal/901471f5.d.ts +0 -37
  126. package/_internal/935ce959.d.ts +0 -49
  127. package/_internal/97089888.d.ts +0 -16
  128. package/_internal/97cc728c.d.ts +0 -26
  129. package/_internal/9ab3c637.js +0 -2474
  130. package/_internal/9ab3c637.js.map +0 -1
  131. package/_internal/9ca3f59c.js +0 -60
  132. package/_internal/9ca3f59c.js.map +0 -1
  133. package/_internal/9e95ea38.d.ts +0 -43
  134. package/_internal/a0108f92.js +0 -84
  135. package/_internal/a0108f92.js.map +0 -1
  136. package/_internal/a493a193.d.ts +0 -65
  137. package/_internal/a521723d.js +0 -120
  138. package/_internal/a521723d.js.map +0 -1
  139. package/_internal/a6fad025.d.ts +0 -107
  140. package/_internal/a8fa525f.js +0 -124
  141. package/_internal/a8fa525f.js.map +0 -1
  142. package/_internal/aca2ecf5.js +0 -141
  143. package/_internal/aca2ecf5.js.map +0 -1
  144. package/_internal/aef2ef1c.js +0 -53
  145. package/_internal/aef2ef1c.js.map +0 -1
  146. package/_internal/af048b0c.js +0 -89
  147. package/_internal/af048b0c.js.map +0 -1
  148. package/_internal/af2cd0cd.d.ts +0 -17
  149. package/_internal/afec6b62.js +0 -864
  150. package/_internal/afec6b62.js.map +0 -1
  151. package/_internal/b0eb3a30.js +0 -72
  152. package/_internal/b0eb3a30.js.map +0 -1
  153. package/_internal/b89517ea.js +0 -275
  154. package/_internal/b89517ea.js.map +0 -1
  155. package/_internal/bafa6fcc.js +0 -116
  156. package/_internal/bafa6fcc.js.map +0 -1
  157. package/_internal/bbbeb49e.js +0 -47
  158. package/_internal/bbbeb49e.js.map +0 -1
  159. package/_internal/c11f6162.d.ts +0 -52
  160. package/_internal/c723dab4.js +0 -133
  161. package/_internal/c723dab4.js.map +0 -1
  162. package/_internal/c87cc857.d.ts +0 -42
  163. package/_internal/c97f8d04.js +0 -424
  164. package/_internal/c97f8d04.js.map +0 -1
  165. package/_internal/cbb373ea.d.ts +0 -6
  166. package/_internal/cbef23b6.d.ts +0 -104
  167. package/_internal/cdf77f06.d.ts +0 -88
  168. package/_internal/d350f2ff.js +0 -105
  169. package/_internal/d350f2ff.js.map +0 -1
  170. package/_internal/d71a8cf7.js +0 -54
  171. package/_internal/d71a8cf7.js.map +0 -1
  172. package/_internal/d9337952.js +0 -96
  173. package/_internal/d9337952.js.map +0 -1
  174. package/_internal/def14e1a.d.ts +0 -24
  175. package/_internal/e0cd29c7.d.ts +0 -35
  176. package/_internal/e354228f.js +0 -145
  177. package/_internal/e354228f.js.map +0 -1
  178. package/_internal/e3922a05.d.ts +0 -22
  179. package/_internal/e3cb6177.d.ts +0 -75
  180. package/_internal/e810c841.d.ts +0 -182
  181. package/_internal/ea700b01.d.ts +0 -43
  182. package/_internal/eed07003.js +0 -122
  183. package/_internal/eed07003.js.map +0 -1
  184. package/_internal/f1c9b334.d.ts +0 -22
  185. package/_internal/f3c3a674.js +0 -281
  186. package/_internal/f3c3a674.js.map +0 -1
  187. package/_internal/f571cdcd.js +0 -132
  188. package/_internal/f571cdcd.js.map +0 -1
  189. package/_internal/f5bdff7e.js +0 -282
  190. package/_internal/f5bdff7e.js.map +0 -1
  191. package/_internal/f851fc00.d.ts +0 -34
  192. package/_internal/f859b007.d.ts +0 -49
  193. package/_internal/fb384b79.d.ts +0 -38
  194. package/_internal/fc4c034b.js +0 -63
  195. package/_internal/fc4c034b.js.map +0 -1
  196. package/_internal/fc608bd9.js +0 -16
  197. package/_internal/fc608bd9.js.map +0 -1
  198. package/_internal/fd1f4d68.d.ts +0 -36
  199. package/_internal/fd867c9d.js +0 -346
  200. package/_internal/fd867c9d.js.map +0 -1
  201. package/_internal/ff8081e5.js +0 -57
  202. package/_internal/ff8081e5.js.map +0 -1
  203. package/_internal/ffd1bfe3.js +0 -123
  204. package/_internal/ffd1bfe3.js.map +0 -1
  205. package/components/alert-dialog.d.ts +0 -6
  206. package/components/alert-dialog.js +0 -2
  207. package/components/alert-dialog.js.map +0 -1
  208. package/components/autocomplete.d.ts +0 -8
  209. package/components/autocomplete.js +0 -2
  210. package/components/autocomplete.js.map +0 -1
  211. package/components/avatar.d.ts +0 -4
  212. package/components/avatar.js +0 -2
  213. package/components/avatar.js.map +0 -1
  214. package/components/badge.d.ts +0 -3
  215. package/components/badge.js +0 -2
  216. package/components/badge.js.map +0 -1
  217. package/components/button.d.ts +0 -8
  218. package/components/button.js +0 -4
  219. package/components/button.js.map +0 -1
  220. package/components/checkbox.d.ts +0 -3
  221. package/components/checkbox.js +0 -2
  222. package/components/checkbox.js.map +0 -1
  223. package/components/chip.d.ts +0 -3
  224. package/components/chip.js +0 -3
  225. package/components/chip.js.map +0 -1
  226. package/components/comment-block.d.ts +0 -5
  227. package/components/comment-block.js +0 -2
  228. package/components/comment-block.js.map +0 -1
  229. package/components/date-picker.d.ts +0 -7
  230. package/components/date-picker.js +0 -2
  231. package/components/date-picker.js.map +0 -1
  232. package/components/dialog.d.ts +0 -3
  233. package/components/dialog.js +0 -2
  234. package/components/dialog.js.map +0 -1
  235. package/components/divider.d.ts +0 -3
  236. package/components/divider.js +0 -2
  237. package/components/divider.js.map +0 -1
  238. package/components/drag-handle.d.ts +0 -3
  239. package/components/drag-handle.js +0 -2
  240. package/components/drag-handle.js.map +0 -1
  241. package/components/dropdown.d.ts +0 -4
  242. package/components/dropdown.js +0 -2
  243. package/components/dropdown.js.map +0 -1
  244. package/components/expansion-panel.d.ts +0 -7
  245. package/components/expansion-panel.js +0 -2
  246. package/components/expansion-panel.js.map +0 -1
  247. package/components/flag.d.ts +0 -3
  248. package/components/flag.js +0 -2
  249. package/components/flag.js.map +0 -1
  250. package/components/flex-box.d.ts +0 -3
  251. package/components/flex-box.js +0 -2
  252. package/components/flex-box.js.map +0 -1
  253. package/components/generic-block.d.ts +0 -4
  254. package/components/generic-block.js +0 -2
  255. package/components/generic-block.js.map +0 -1
  256. package/components/grid.d.ts +0 -3
  257. package/components/grid.js +0 -2
  258. package/components/grid.js.map +0 -1
  259. package/components/heading.d.ts +0 -4
  260. package/components/heading.js +0 -2
  261. package/components/heading.js.map +0 -1
  262. package/components/icon.d.ts +0 -3
  263. package/components/icon.js +0 -2
  264. package/components/icon.js.map +0 -1
  265. package/components/image-block.d.ts +0 -4
  266. package/components/image-block.js +0 -2
  267. package/components/image-block.js.map +0 -1
  268. package/components/input-helper.d.ts +0 -3
  269. package/components/input-helper.js +0 -2
  270. package/components/input-helper.js.map +0 -1
  271. package/components/input-label.d.ts +0 -3
  272. package/components/input-label.js +0 -2
  273. package/components/input-label.js.map +0 -1
  274. package/components/lightbox.d.ts +0 -7
  275. package/components/lightbox.js +0 -2
  276. package/components/lightbox.js.map +0 -1
  277. package/components/link-preview.d.ts +0 -5
  278. package/components/link-preview.js +0 -2
  279. package/components/link-preview.js.map +0 -1
  280. package/components/link.d.ts +0 -3
  281. package/components/link.js +0 -2
  282. package/components/link.js.map +0 -1
  283. package/components/list.d.ts +0 -3
  284. package/components/list.js +0 -3
  285. package/components/list.js.map +0 -1
  286. package/components/message.d.ts +0 -3
  287. package/components/message.js +0 -2
  288. package/components/message.js.map +0 -1
  289. package/components/mosaic.d.ts +0 -4
  290. package/components/mosaic.js +0 -2
  291. package/components/mosaic.js.map +0 -1
  292. package/components/notification.d.ts +0 -3
  293. package/components/notification.js +0 -2
  294. package/components/notification.js.map +0 -1
  295. package/components/popover.d.ts +0 -3
  296. package/components/popover.js +0 -2
  297. package/components/popover.js.map +0 -1
  298. package/components/post-block.d.ts +0 -4
  299. package/components/post-block.js +0 -2
  300. package/components/post-block.js.map +0 -1
  301. package/components/progress-tracker.d.ts +0 -3
  302. package/components/progress-tracker.js +0 -2
  303. package/components/progress-tracker.js.map +0 -1
  304. package/components/progress.d.ts +0 -3
  305. package/components/progress.js +0 -2
  306. package/components/progress.js.map +0 -1
  307. package/components/radio-button.d.ts +0 -3
  308. package/components/radio-button.js +0 -2
  309. package/components/radio-button.js.map +0 -1
  310. package/components/select.d.ts +0 -7
  311. package/components/select.js +0 -2
  312. package/components/select.js.map +0 -1
  313. package/components/side-navigation.d.ts +0 -7
  314. package/components/side-navigation.js +0 -2
  315. package/components/side-navigation.js.map +0 -1
  316. package/components/skeleton.d.ts +0 -3
  317. package/components/skeleton.js +0 -2
  318. package/components/skeleton.js.map +0 -1
  319. package/components/slider.d.ts +0 -3
  320. package/components/slider.js +0 -2
  321. package/components/slider.js.map +0 -1
  322. package/components/slideshow.d.ts +0 -7
  323. package/components/slideshow.js +0 -2
  324. package/components/slideshow.js.map +0 -1
  325. package/components/switch.d.ts +0 -3
  326. package/components/switch.js +0 -2
  327. package/components/switch.js.map +0 -1
  328. package/components/table.d.ts +0 -3
  329. package/components/table.js +0 -2
  330. package/components/table.js.map +0 -1
  331. package/components/tabs.d.ts +0 -4
  332. package/components/tabs.js +0 -2
  333. package/components/tabs.js.map +0 -1
  334. package/components/text-field.d.ts +0 -7
  335. package/components/text-field.js +0 -2
  336. package/components/text-field.js.map +0 -1
  337. package/components/text.d.ts +0 -3
  338. package/components/text.js +0 -2
  339. package/components/text.js.map +0 -1
  340. package/components/thumbnail.d.ts +0 -4
  341. package/components/thumbnail.js +0 -3
  342. package/components/thumbnail.js.map +0 -1
  343. package/components/toolbar.d.ts +0 -3
  344. package/components/toolbar.js +0 -2
  345. package/components/toolbar.js.map +0 -1
  346. package/components/tooltip.d.ts +0 -4
  347. package/components/tooltip.js +0 -2
  348. package/components/tooltip.js.map +0 -1
  349. package/components/uploader.d.ts +0 -3
  350. package/components/uploader.js +0 -2
  351. package/components/uploader.js.map +0 -1
  352. package/components/user-block.d.ts +0 -5
  353. package/components/user-block.js +0 -2
  354. package/components/user-block.js.map +0 -1
  355. package/components.d.ts +0 -2
  356. package/components.js +0 -156
  357. package/components.js.map +0 -1
@@ -1,2474 +0,0 @@
1
- import { d as _slicedToArray, b as _objectWithoutProperties, _ as _objectSpread2, c as _extends } from './6340c129.js';
2
- import React, { useState, useEffect, useLayoutEffect, useRef, useMemo, forwardRef, useCallback } from 'react';
3
- import { g as getRootClassName, c as classnames, h as handleBasicClasses } from './fd867c9d.js';
4
- import { D as DOCUMENT, W as WINDOW } from './288dfd0f.js';
5
- import { m as mergeRefs } from './853713cd.js';
6
- import { g as getFirstAndLastFocusable, u as useCallbackOnEscape } from './5d8ed4ee.js';
7
- import { createPortal } from 'react-dom';
8
- import { C as ClickAwayProvider } from './53a831be.js';
9
-
10
- /**
11
- * Hook focusing an element when defined and `focus` boolean `true`.
12
- *
13
- * @param element Element to focus.
14
- * @param shouldFocus Boolean flag to trigger the focus
15
- */
16
-
17
- function useFocus(element) {
18
- var shouldFocus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
19
-
20
- var _useState = useState(false),
21
- _useState2 = _slicedToArray(_useState, 2),
22
- wasFocus = _useState2[0],
23
- setWasFocus = _useState2[1];
24
-
25
- useEffect(function () {
26
- if (shouldFocus && wasFocus !== shouldFocus && element) {
27
- element.focus();
28
- setWasFocus(shouldFocus);
29
- }
30
- }, // eslint-disable-next-line react-hooks/exhaustive-deps
31
- [element, shouldFocus]);
32
- }
33
-
34
- var top = 'top';
35
- var bottom = 'bottom';
36
- var right = 'right';
37
- var left = 'left';
38
- var auto = 'auto';
39
- var basePlacements = [top, bottom, right, left];
40
- var start = 'start';
41
- var end = 'end';
42
- var clippingParents = 'clippingParents';
43
- var viewport = 'viewport';
44
- var popper = 'popper';
45
- var reference = 'reference';
46
- var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
47
- return acc.concat([placement + "-" + start, placement + "-" + end]);
48
- }, []);
49
- var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
50
- return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
51
- }, []); // modifiers that need to read the DOM
52
-
53
- var beforeRead = 'beforeRead';
54
- var read = 'read';
55
- var afterRead = 'afterRead'; // pure-logic modifiers
56
-
57
- var beforeMain = 'beforeMain';
58
- var main = 'main';
59
- var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
60
-
61
- var beforeWrite = 'beforeWrite';
62
- var write = 'write';
63
- var afterWrite = 'afterWrite';
64
- var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
65
-
66
- function getNodeName(element) {
67
- return element ? (element.nodeName || '').toLowerCase() : null;
68
- }
69
-
70
- /*:: import type { Window } from '../types'; */
71
-
72
- /*:: declare function getWindow(node: Node | Window): Window; */
73
- function getWindow(node) {
74
- if (node.toString() !== '[object Window]') {
75
- var ownerDocument = node.ownerDocument;
76
- return ownerDocument ? ownerDocument.defaultView || window : window;
77
- }
78
-
79
- return node;
80
- }
81
-
82
- /*:: declare function isElement(node: mixed): boolean %checks(node instanceof
83
- Element); */
84
-
85
- function isElement(node) {
86
- var OwnElement = getWindow(node).Element;
87
- return node instanceof OwnElement || node instanceof Element;
88
- }
89
- /*:: declare function isHTMLElement(node: mixed): boolean %checks(node instanceof
90
- HTMLElement); */
91
-
92
-
93
- function isHTMLElement(node) {
94
- var OwnElement = getWindow(node).HTMLElement;
95
- return node instanceof OwnElement || node instanceof HTMLElement;
96
- }
97
- /*:: declare function isShadowRoot(node: mixed): boolean %checks(node instanceof
98
- ShadowRoot); */
99
-
100
-
101
- function isShadowRoot(node) {
102
- var OwnElement = getWindow(node).ShadowRoot;
103
- return node instanceof OwnElement || node instanceof ShadowRoot;
104
- }
105
-
106
- // and applies them to the HTMLElements such as popper and arrow
107
-
108
- function applyStyles(_ref) {
109
- var state = _ref.state;
110
- Object.keys(state.elements).forEach(function (name) {
111
- var style = state.styles[name] || {};
112
- var attributes = state.attributes[name] || {};
113
- var element = state.elements[name]; // arrow is optional + virtual elements
114
-
115
- if (!isHTMLElement(element) || !getNodeName(element)) {
116
- return;
117
- } // Flow doesn't support to extend this property, but it's the most
118
- // effective way to apply styles to an HTMLElement
119
- // $FlowFixMe
120
-
121
-
122
- Object.assign(element.style, style);
123
- Object.keys(attributes).forEach(function (name) {
124
- var value = attributes[name];
125
-
126
- if (value === false) {
127
- element.removeAttribute(name);
128
- } else {
129
- element.setAttribute(name, value === true ? '' : value);
130
- }
131
- });
132
- });
133
- }
134
-
135
- function effect(_ref2) {
136
- var state = _ref2.state;
137
- var initialStyles = {
138
- popper: {
139
- position: state.options.strategy,
140
- left: '0',
141
- top: '0',
142
- margin: '0'
143
- },
144
- arrow: {
145
- position: 'absolute'
146
- },
147
- reference: {}
148
- };
149
- Object.assign(state.elements.popper.style, initialStyles.popper);
150
-
151
- if (state.elements.arrow) {
152
- Object.assign(state.elements.arrow.style, initialStyles.arrow);
153
- }
154
-
155
- return function () {
156
- Object.keys(state.elements).forEach(function (name) {
157
- var element = state.elements[name];
158
- var attributes = state.attributes[name] || {};
159
- var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
160
-
161
- var style = styleProperties.reduce(function (style, property) {
162
- style[property] = '';
163
- return style;
164
- }, {}); // arrow is optional + virtual elements
165
-
166
- if (!isHTMLElement(element) || !getNodeName(element)) {
167
- return;
168
- } // Flow doesn't support to extend this property, but it's the most
169
- // effective way to apply styles to an HTMLElement
170
- // $FlowFixMe
171
-
172
-
173
- Object.assign(element.style, style);
174
- Object.keys(attributes).forEach(function (attribute) {
175
- element.removeAttribute(attribute);
176
- });
177
- });
178
- };
179
- } // eslint-disable-next-line import/no-unused-modules
180
-
181
-
182
- var applyStyles$1 = {
183
- name: 'applyStyles',
184
- enabled: true,
185
- phase: 'write',
186
- fn: applyStyles,
187
- effect: effect,
188
- requires: ['computeStyles']
189
- };
190
-
191
- function getBasePlacement(placement) {
192
- return placement.split('-')[0];
193
- }
194
-
195
- // Returns the layout rect of an element relative to its offsetParent. Layout
196
- // means it doesn't take into account transforms.
197
- function getLayoutRect(element) {
198
- return {
199
- x: element.offsetLeft,
200
- y: element.offsetTop,
201
- width: element.offsetWidth,
202
- height: element.offsetHeight
203
- };
204
- }
205
-
206
- function contains(parent, child) {
207
- var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
208
-
209
- if (parent.contains(child)) {
210
- return true;
211
- } // then fallback to custom implementation with Shadow DOM support
212
- else if (rootNode && isShadowRoot(rootNode)) {
213
- var next = child;
214
-
215
- do {
216
- if (next && parent.isSameNode(next)) {
217
- return true;
218
- } // $FlowFixMe: need a better way to handle this...
219
-
220
-
221
- next = next.parentNode || next.host;
222
- } while (next);
223
- } // Give up, the result is false
224
-
225
-
226
- return false;
227
- }
228
-
229
- function getComputedStyle(element) {
230
- return getWindow(element).getComputedStyle(element);
231
- }
232
-
233
- function isTableElement(element) {
234
- return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
235
- }
236
-
237
- function getDocumentElement(element) {
238
- // $FlowFixMe: assume body is always available
239
- return ((isElement(element) ? element.ownerDocument : element.document) || window.document).documentElement;
240
- }
241
-
242
- function getParentNode(element) {
243
- if (getNodeName(element) === 'html') {
244
- return element;
245
- }
246
-
247
- return (// $FlowFixMe: this is a quicker (but less type safe) way to save quite some bytes from the bundle
248
- element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
249
- element.parentNode || // DOM Element detected
250
- // $FlowFixMe: need a better way to handle this...
251
- element.host || // ShadowRoot detected
252
- // $FlowFixMe: HTMLElement is a Node
253
- getDocumentElement(element) // fallback
254
-
255
- );
256
- }
257
-
258
- function getTrueOffsetParent(element) {
259
- if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
260
- getComputedStyle(element).position === 'fixed') {
261
- return null;
262
- }
263
-
264
- var offsetParent = element.offsetParent;
265
-
266
- if (offsetParent) {
267
- var html = getDocumentElement(offsetParent);
268
-
269
- if (getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && getComputedStyle(html).position !== 'static') {
270
- return html;
271
- }
272
- }
273
-
274
- return offsetParent;
275
- } // `.offsetParent` reports `null` for fixed elements, while absolute elements
276
- // return the containing block
277
-
278
-
279
- function getContainingBlock(element) {
280
- var currentNode = getParentNode(element);
281
-
282
- while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
283
- var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
284
- // create a containing block.
285
-
286
- if (css.transform !== 'none' || css.perspective !== 'none' || css.willChange && css.willChange !== 'auto') {
287
- return currentNode;
288
- } else {
289
- currentNode = currentNode.parentNode;
290
- }
291
- }
292
-
293
- return null;
294
- } // Gets the closest ancestor positioned element. Handles some edge cases,
295
- // such as table ancestors and cross browser bugs.
296
-
297
-
298
- function getOffsetParent(element) {
299
- var window = getWindow(element);
300
- var offsetParent = getTrueOffsetParent(element);
301
-
302
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
303
- offsetParent = getTrueOffsetParent(offsetParent);
304
- }
305
-
306
- if (offsetParent && getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static') {
307
- return window;
308
- }
309
-
310
- return offsetParent || getContainingBlock(element) || window;
311
- }
312
-
313
- function getMainAxisFromPlacement(placement) {
314
- return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
315
- }
316
-
317
- function within(min, value, max) {
318
- return Math.max(min, Math.min(value, max));
319
- }
320
-
321
- function getFreshSideObject() {
322
- return {
323
- top: 0,
324
- right: 0,
325
- bottom: 0,
326
- left: 0
327
- };
328
- }
329
-
330
- function mergePaddingObject(paddingObject) {
331
- return Object.assign(Object.assign({}, getFreshSideObject()), paddingObject);
332
- }
333
-
334
- function expandToHashMap(value, keys) {
335
- return keys.reduce(function (hashMap, key) {
336
- hashMap[key] = value;
337
- return hashMap;
338
- }, {});
339
- }
340
-
341
- function arrow(_ref) {
342
- var _state$modifiersData$;
343
-
344
- var state = _ref.state,
345
- name = _ref.name;
346
- var arrowElement = state.elements.arrow;
347
- var popperOffsets = state.modifiersData.popperOffsets;
348
- var basePlacement = getBasePlacement(state.placement);
349
- var axis = getMainAxisFromPlacement(basePlacement);
350
- var isVertical = [left, right].indexOf(basePlacement) >= 0;
351
- var len = isVertical ? 'height' : 'width';
352
-
353
- if (!arrowElement || !popperOffsets) {
354
- return;
355
- }
356
-
357
- var paddingObject = state.modifiersData[name + "#persistent"].padding;
358
- var arrowRect = getLayoutRect(arrowElement);
359
- var minProp = axis === 'y' ? top : left;
360
- var maxProp = axis === 'y' ? bottom : right;
361
- var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
362
- var startDiff = popperOffsets[axis] - state.rects.reference[axis];
363
- var arrowOffsetParent = getOffsetParent(arrowElement);
364
- var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
365
- var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
366
- // outside of the popper bounds
367
-
368
- var min = paddingObject[minProp];
369
- var max = clientSize - arrowRect[len] - paddingObject[maxProp];
370
- var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
371
- var offset = within(min, center, max); // Prevents breaking syntax highlighting...
372
-
373
- var axisProp = axis;
374
- state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
375
- }
376
-
377
- function effect$1(_ref2) {
378
- var state = _ref2.state,
379
- options = _ref2.options,
380
- name = _ref2.name;
381
- var _options$element = options.element,
382
- arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element,
383
- _options$padding = options.padding,
384
- padding = _options$padding === void 0 ? 0 : _options$padding;
385
-
386
- if (arrowElement == null) {
387
- return;
388
- } // CSS selector
389
-
390
-
391
- if (typeof arrowElement === 'string') {
392
- arrowElement = state.elements.popper.querySelector(arrowElement);
393
-
394
- if (!arrowElement) {
395
- return;
396
- }
397
- }
398
-
399
- if (process.env.NODE_ENV !== "production") {
400
- if (!isHTMLElement(arrowElement)) {
401
- 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(' '));
402
- }
403
- }
404
-
405
- if (!contains(state.elements.popper, arrowElement)) {
406
- if (process.env.NODE_ENV !== "production") {
407
- console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', 'element.'].join(' '));
408
- }
409
-
410
- return;
411
- }
412
-
413
- state.elements.arrow = arrowElement;
414
- state.modifiersData[name + "#persistent"] = {
415
- padding: mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements))
416
- };
417
- } // eslint-disable-next-line import/no-unused-modules
418
-
419
-
420
- var arrow$1 = {
421
- name: 'arrow',
422
- enabled: true,
423
- phase: 'main',
424
- fn: arrow,
425
- effect: effect$1,
426
- requires: ['popperOffsets'],
427
- requiresIfExists: ['preventOverflow']
428
- };
429
-
430
- var unsetSides = {
431
- top: 'auto',
432
- right: 'auto',
433
- bottom: 'auto',
434
- left: 'auto'
435
- }; // Round the offsets to the nearest suitable subpixel based on the DPR.
436
- // Zooming can change the DPR, but it seems to report a value that will
437
- // cleanly divide the values into the appropriate subpixels.
438
-
439
- function roundOffsets(_ref) {
440
- var x = _ref.x,
441
- y = _ref.y;
442
- var win = window;
443
- var dpr = win.devicePixelRatio || 1;
444
- return {
445
- x: Math.round(x * dpr) / dpr || 0,
446
- y: Math.round(y * dpr) / dpr || 0
447
- };
448
- }
449
-
450
- function mapToStyles(_ref2) {
451
- var _Object$assign2;
452
-
453
- var popper = _ref2.popper,
454
- popperRect = _ref2.popperRect,
455
- placement = _ref2.placement,
456
- offsets = _ref2.offsets,
457
- position = _ref2.position,
458
- gpuAcceleration = _ref2.gpuAcceleration,
459
- adaptive = _ref2.adaptive;
460
-
461
- var _roundOffsets = roundOffsets(offsets),
462
- x = _roundOffsets.x,
463
- y = _roundOffsets.y;
464
-
465
- var hasX = offsets.hasOwnProperty('x');
466
- var hasY = offsets.hasOwnProperty('y');
467
- var sideX = left;
468
- var sideY = top;
469
- var win = window;
470
-
471
- if (adaptive) {
472
- var offsetParent = getOffsetParent(popper);
473
-
474
- if (offsetParent === getWindow(popper)) {
475
- offsetParent = getDocumentElement(popper);
476
- } // $FlowFixMe: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
477
-
478
- /*:: offsetParent = (offsetParent: Element); */
479
-
480
-
481
- if (placement === top) {
482
- sideY = bottom;
483
- y -= offsetParent.clientHeight - popperRect.height;
484
- y *= gpuAcceleration ? 1 : -1;
485
- }
486
-
487
- if (placement === left) {
488
- sideX = right;
489
- x -= offsetParent.clientWidth - popperRect.width;
490
- x *= gpuAcceleration ? 1 : -1;
491
- }
492
- }
493
-
494
- var commonStyles = Object.assign({
495
- position: position
496
- }, adaptive && unsetSides);
497
-
498
- if (gpuAcceleration) {
499
- var _Object$assign;
500
-
501
- return Object.assign(Object.assign({}, commonStyles), {}, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) < 2 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
502
- }
503
-
504
- return Object.assign(Object.assign({}, commonStyles), {}, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
505
- }
506
-
507
- function computeStyles(_ref3) {
508
- var state = _ref3.state,
509
- options = _ref3.options;
510
- var _options$gpuAccelerat = options.gpuAcceleration,
511
- gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
512
- _options$adaptive = options.adaptive,
513
- adaptive = _options$adaptive === void 0 ? true : _options$adaptive;
514
-
515
- if (process.env.NODE_ENV !== "production") {
516
- var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || '';
517
-
518
- if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {
519
- return transitionProperty.indexOf(property) >= 0;
520
- })) {
521
- 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(' '));
522
- }
523
- }
524
-
525
- var commonStyles = {
526
- placement: getBasePlacement(state.placement),
527
- popper: state.elements.popper,
528
- popperRect: state.rects.popper,
529
- gpuAcceleration: gpuAcceleration
530
- };
531
-
532
- if (state.modifiersData.popperOffsets != null) {
533
- state.styles.popper = Object.assign(Object.assign({}, state.styles.popper), mapToStyles(Object.assign(Object.assign({}, commonStyles), {}, {
534
- offsets: state.modifiersData.popperOffsets,
535
- position: state.options.strategy,
536
- adaptive: adaptive
537
- })));
538
- }
539
-
540
- if (state.modifiersData.arrow != null) {
541
- state.styles.arrow = Object.assign(Object.assign({}, state.styles.arrow), mapToStyles(Object.assign(Object.assign({}, commonStyles), {}, {
542
- offsets: state.modifiersData.arrow,
543
- position: 'absolute',
544
- adaptive: false
545
- })));
546
- }
547
-
548
- state.attributes.popper = Object.assign(Object.assign({}, state.attributes.popper), {}, {
549
- 'data-popper-placement': state.placement
550
- });
551
- } // eslint-disable-next-line import/no-unused-modules
552
-
553
-
554
- var computeStyles$1 = {
555
- name: 'computeStyles',
556
- enabled: true,
557
- phase: 'beforeWrite',
558
- fn: computeStyles,
559
- data: {}
560
- };
561
-
562
- var passive = {
563
- passive: true
564
- };
565
-
566
- function effect$2(_ref) {
567
- var state = _ref.state,
568
- instance = _ref.instance,
569
- options = _ref.options;
570
- var _options$scroll = options.scroll,
571
- scroll = _options$scroll === void 0 ? true : _options$scroll,
572
- _options$resize = options.resize,
573
- resize = _options$resize === void 0 ? true : _options$resize;
574
- var window = getWindow(state.elements.popper);
575
- var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
576
-
577
- if (scroll) {
578
- scrollParents.forEach(function (scrollParent) {
579
- scrollParent.addEventListener('scroll', instance.update, passive);
580
- });
581
- }
582
-
583
- if (resize) {
584
- window.addEventListener('resize', instance.update, passive);
585
- }
586
-
587
- return function () {
588
- if (scroll) {
589
- scrollParents.forEach(function (scrollParent) {
590
- scrollParent.removeEventListener('scroll', instance.update, passive);
591
- });
592
- }
593
-
594
- if (resize) {
595
- window.removeEventListener('resize', instance.update, passive);
596
- }
597
- };
598
- } // eslint-disable-next-line import/no-unused-modules
599
-
600
-
601
- var eventListeners = {
602
- name: 'eventListeners',
603
- enabled: true,
604
- phase: 'write',
605
- fn: function fn() {},
606
- effect: effect$2,
607
- data: {}
608
- };
609
-
610
- var hash = {
611
- left: 'right',
612
- right: 'left',
613
- bottom: 'top',
614
- top: 'bottom'
615
- };
616
- function getOppositePlacement(placement) {
617
- return placement.replace(/left|right|bottom|top/g, function (matched) {
618
- return hash[matched];
619
- });
620
- }
621
-
622
- var hash$1 = {
623
- start: 'end',
624
- end: 'start'
625
- };
626
- function getOppositeVariationPlacement(placement) {
627
- return placement.replace(/start|end/g, function (matched) {
628
- return hash$1[matched];
629
- });
630
- }
631
-
632
- function getBoundingClientRect(element) {
633
- var rect = element.getBoundingClientRect();
634
- return {
635
- width: rect.width,
636
- height: rect.height,
637
- top: rect.top,
638
- right: rect.right,
639
- bottom: rect.bottom,
640
- left: rect.left,
641
- x: rect.left,
642
- y: rect.top
643
- };
644
- }
645
-
646
- function getWindowScroll(node) {
647
- var win = getWindow(node);
648
- var scrollLeft = win.pageXOffset;
649
- var scrollTop = win.pageYOffset;
650
- return {
651
- scrollLeft: scrollLeft,
652
- scrollTop: scrollTop
653
- };
654
- }
655
-
656
- function getWindowScrollBarX(element) {
657
- // If <html> has a CSS width greater than the viewport, then this will be
658
- // incorrect for RTL.
659
- // Popper 1 is broken in this case and never had a bug report so let's assume
660
- // it's not an issue. I don't think anyone ever specifies width on <html>
661
- // anyway.
662
- // Browsers where the left scrollbar doesn't cause an issue report `0` for
663
- // this (e.g. Edge 2019, IE11, Safari)
664
- return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
665
- }
666
-
667
- function getViewportRect(element) {
668
- var win = getWindow(element);
669
- var html = getDocumentElement(element);
670
- var visualViewport = win.visualViewport;
671
- var width = html.clientWidth;
672
- var height = html.clientHeight;
673
- var x = 0;
674
- var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
675
- // can be obscured underneath it.
676
- // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
677
- // if it isn't open, so if this isn't available, the popper will be detected
678
- // to overflow the bottom of the screen too early.
679
-
680
- if (visualViewport) {
681
- width = visualViewport.width;
682
- height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
683
- // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
684
- // errors due to floating point numbers, so we need to check precision.
685
- // Safari returns a number <= 0, usually < -1 when pinch-zoomed
686
- // Feature detection fails in mobile emulation mode in Chrome.
687
- // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
688
- // 0.001
689
- // Fallback here: "Not Safari" userAgent
690
-
691
- if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
692
- x = visualViewport.offsetLeft;
693
- y = visualViewport.offsetTop;
694
- }
695
- }
696
-
697
- return {
698
- width: width,
699
- height: height,
700
- x: x + getWindowScrollBarX(element),
701
- y: y
702
- };
703
- }
704
-
705
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable
706
-
707
- function getDocumentRect(element) {
708
- var html = getDocumentElement(element);
709
- var winScroll = getWindowScroll(element);
710
- var body = element.ownerDocument.body;
711
- var width = Math.max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
712
- var height = Math.max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
713
- var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
714
- var y = -winScroll.scrollTop;
715
-
716
- if (getComputedStyle(body || html).direction === 'rtl') {
717
- x += Math.max(html.clientWidth, body ? body.clientWidth : 0) - width;
718
- }
719
-
720
- return {
721
- width: width,
722
- height: height,
723
- x: x,
724
- y: y
725
- };
726
- }
727
-
728
- function isScrollParent(element) {
729
- // Firefox wants us to check `-x` and `-y` variations as well
730
- var _getComputedStyle = getComputedStyle(element),
731
- overflow = _getComputedStyle.overflow,
732
- overflowX = _getComputedStyle.overflowX,
733
- overflowY = _getComputedStyle.overflowY;
734
-
735
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
736
- }
737
-
738
- function getScrollParent(node) {
739
- if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
740
- // $FlowFixMe: assume body is always available
741
- return node.ownerDocument.body;
742
- }
743
-
744
- if (isHTMLElement(node) && isScrollParent(node)) {
745
- return node;
746
- }
747
-
748
- return getScrollParent(getParentNode(node));
749
- }
750
-
751
- /*
752
- given a DOM element, return the list of all scroll parents, up the list of ancesors
753
- until we get to the top window object. This list is what we attach scroll listeners
754
- to, because if any of these parent elements scroll, we'll need to re-calculate the
755
- reference element's position.
756
- */
757
-
758
- function listScrollParents(element, list) {
759
- if (list === void 0) {
760
- list = [];
761
- }
762
-
763
- var scrollParent = getScrollParent(element);
764
- var isBody = getNodeName(scrollParent) === 'body';
765
- var win = getWindow(scrollParent);
766
- var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
767
- var updatedList = list.concat(target);
768
- return isBody ? updatedList : // $FlowFixMe: isBody tells us target will be an HTMLElement here
769
- updatedList.concat(listScrollParents(getParentNode(target)));
770
- }
771
-
772
- function rectToClientRect(rect) {
773
- return Object.assign(Object.assign({}, rect), {}, {
774
- left: rect.x,
775
- top: rect.y,
776
- right: rect.x + rect.width,
777
- bottom: rect.y + rect.height
778
- });
779
- }
780
-
781
- function getInnerBoundingClientRect(element) {
782
- var rect = getBoundingClientRect(element);
783
- rect.top = rect.top + element.clientTop;
784
- rect.left = rect.left + element.clientLeft;
785
- rect.bottom = rect.top + element.clientHeight;
786
- rect.right = rect.left + element.clientWidth;
787
- rect.width = element.clientWidth;
788
- rect.height = element.clientHeight;
789
- rect.x = rect.left;
790
- rect.y = rect.top;
791
- return rect;
792
- }
793
-
794
- function getClientRectFromMixedType(element, clippingParent) {
795
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
796
- } // A "clipping parent" is an overflowable container with the characteristic of
797
- // clipping (or hiding) overflowing elements with a position different from
798
- // `initial`
799
-
800
-
801
- function getClippingParents(element) {
802
- var clippingParents = listScrollParents(getParentNode(element));
803
- var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
804
- var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
805
-
806
- if (!isElement(clipperElement)) {
807
- return [];
808
- } // $FlowFixMe: https://github.com/facebook/flow/issues/1414
809
-
810
-
811
- return clippingParents.filter(function (clippingParent) {
812
- return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
813
- });
814
- } // Gets the maximum area that the element is visible in due to any number of
815
- // clipping parents
816
-
817
-
818
- function getClippingRect(element, boundary, rootBoundary) {
819
- var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
820
- var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
821
- var firstClippingParent = clippingParents[0];
822
- var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
823
- var rect = getClientRectFromMixedType(element, clippingParent);
824
- accRect.top = Math.max(rect.top, accRect.top);
825
- accRect.right = Math.min(rect.right, accRect.right);
826
- accRect.bottom = Math.min(rect.bottom, accRect.bottom);
827
- accRect.left = Math.max(rect.left, accRect.left);
828
- return accRect;
829
- }, getClientRectFromMixedType(element, firstClippingParent));
830
- clippingRect.width = clippingRect.right - clippingRect.left;
831
- clippingRect.height = clippingRect.bottom - clippingRect.top;
832
- clippingRect.x = clippingRect.left;
833
- clippingRect.y = clippingRect.top;
834
- return clippingRect;
835
- }
836
-
837
- function getVariation(placement) {
838
- return placement.split('-')[1];
839
- }
840
-
841
- function computeOffsets(_ref) {
842
- var reference = _ref.reference,
843
- element = _ref.element,
844
- placement = _ref.placement;
845
- var basePlacement = placement ? getBasePlacement(placement) : null;
846
- var variation = placement ? getVariation(placement) : null;
847
- var commonX = reference.x + reference.width / 2 - element.width / 2;
848
- var commonY = reference.y + reference.height / 2 - element.height / 2;
849
- var offsets;
850
-
851
- switch (basePlacement) {
852
- case top:
853
- offsets = {
854
- x: commonX,
855
- y: reference.y - element.height
856
- };
857
- break;
858
-
859
- case bottom:
860
- offsets = {
861
- x: commonX,
862
- y: reference.y + reference.height
863
- };
864
- break;
865
-
866
- case right:
867
- offsets = {
868
- x: reference.x + reference.width,
869
- y: commonY
870
- };
871
- break;
872
-
873
- case left:
874
- offsets = {
875
- x: reference.x - element.width,
876
- y: commonY
877
- };
878
- break;
879
-
880
- default:
881
- offsets = {
882
- x: reference.x,
883
- y: reference.y
884
- };
885
- }
886
-
887
- var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
888
-
889
- if (mainAxis != null) {
890
- var len = mainAxis === 'y' ? 'height' : 'width';
891
-
892
- switch (variation) {
893
- case start:
894
- offsets[mainAxis] = Math.floor(offsets[mainAxis]) - Math.floor(reference[len] / 2 - element[len] / 2);
895
- break;
896
-
897
- case end:
898
- offsets[mainAxis] = Math.floor(offsets[mainAxis]) + Math.ceil(reference[len] / 2 - element[len] / 2);
899
- break;
900
- }
901
- }
902
-
903
- return offsets;
904
- }
905
-
906
- function detectOverflow(state, options) {
907
- if (options === void 0) {
908
- options = {};
909
- }
910
-
911
- var _options = options,
912
- _options$placement = _options.placement,
913
- placement = _options$placement === void 0 ? state.placement : _options$placement,
914
- _options$boundary = _options.boundary,
915
- boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
916
- _options$rootBoundary = _options.rootBoundary,
917
- rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
918
- _options$elementConte = _options.elementContext,
919
- elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
920
- _options$altBoundary = _options.altBoundary,
921
- altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
922
- _options$padding = _options.padding,
923
- padding = _options$padding === void 0 ? 0 : _options$padding;
924
- var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
925
- var altContext = elementContext === popper ? reference : popper;
926
- var referenceElement = state.elements.reference;
927
- var popperRect = state.rects.popper;
928
- var element = state.elements[altBoundary ? altContext : elementContext];
929
- var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
930
- var referenceClientRect = getBoundingClientRect(referenceElement);
931
- var popperOffsets = computeOffsets({
932
- reference: referenceClientRect,
933
- element: popperRect,
934
- strategy: 'absolute',
935
- placement: placement
936
- });
937
- var popperClientRect = rectToClientRect(Object.assign(Object.assign({}, popperRect), popperOffsets));
938
- var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
939
- // 0 or negative = within the clipping rect
940
-
941
- var overflowOffsets = {
942
- top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
943
- bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
944
- left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
945
- right: elementClientRect.right - clippingClientRect.right + paddingObject.right
946
- };
947
- var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
948
-
949
- if (elementContext === popper && offsetData) {
950
- var offset = offsetData[placement];
951
- Object.keys(overflowOffsets).forEach(function (key) {
952
- var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
953
- var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
954
- overflowOffsets[key] += offset[axis] * multiply;
955
- });
956
- }
957
-
958
- return overflowOffsets;
959
- }
960
-
961
- /*:: type OverflowsMap = { [ComputedPlacement]: number }; */
962
-
963
- /*;; type OverflowsMap = { [key in ComputedPlacement]: number }; */
964
- function computeAutoPlacement(state, options) {
965
- if (options === void 0) {
966
- options = {};
967
- }
968
-
969
- var _options = options,
970
- placement = _options.placement,
971
- boundary = _options.boundary,
972
- rootBoundary = _options.rootBoundary,
973
- padding = _options.padding,
974
- flipVariations = _options.flipVariations,
975
- _options$allowedAutoP = _options.allowedAutoPlacements,
976
- allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
977
- var variation = getVariation(placement);
978
- var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
979
- return getVariation(placement) === variation;
980
- }) : basePlacements; // $FlowFixMe
981
-
982
- var allowedPlacements = placements$1.filter(function (placement) {
983
- return allowedAutoPlacements.indexOf(placement) >= 0;
984
- });
985
-
986
- if (allowedPlacements.length === 0) {
987
- allowedPlacements = placements$1;
988
-
989
- if (process.env.NODE_ENV !== "production") {
990
- 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(' '));
991
- }
992
- } // $FlowFixMe: Flow seems to have problems with two array unions...
993
-
994
-
995
- var overflows = allowedPlacements.reduce(function (acc, placement) {
996
- acc[placement] = detectOverflow(state, {
997
- placement: placement,
998
- boundary: boundary,
999
- rootBoundary: rootBoundary,
1000
- padding: padding
1001
- })[getBasePlacement(placement)];
1002
- return acc;
1003
- }, {});
1004
- return Object.keys(overflows).sort(function (a, b) {
1005
- return overflows[a] - overflows[b];
1006
- });
1007
- }
1008
-
1009
- function getExpandedFallbackPlacements(placement) {
1010
- if (getBasePlacement(placement) === auto) {
1011
- return [];
1012
- }
1013
-
1014
- var oppositePlacement = getOppositePlacement(placement);
1015
- return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
1016
- }
1017
-
1018
- function flip(_ref) {
1019
- var state = _ref.state,
1020
- options = _ref.options,
1021
- name = _ref.name;
1022
-
1023
- if (state.modifiersData[name]._skip) {
1024
- return;
1025
- }
1026
-
1027
- var _options$mainAxis = options.mainAxis,
1028
- checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1029
- _options$altAxis = options.altAxis,
1030
- checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
1031
- specifiedFallbackPlacements = options.fallbackPlacements,
1032
- padding = options.padding,
1033
- boundary = options.boundary,
1034
- rootBoundary = options.rootBoundary,
1035
- altBoundary = options.altBoundary,
1036
- _options$flipVariatio = options.flipVariations,
1037
- flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
1038
- allowedAutoPlacements = options.allowedAutoPlacements;
1039
- var preferredPlacement = state.options.placement;
1040
- var basePlacement = getBasePlacement(preferredPlacement);
1041
- var isBasePlacement = basePlacement === preferredPlacement;
1042
- var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
1043
- var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
1044
- return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
1045
- placement: placement,
1046
- boundary: boundary,
1047
- rootBoundary: rootBoundary,
1048
- padding: padding,
1049
- flipVariations: flipVariations,
1050
- allowedAutoPlacements: allowedAutoPlacements
1051
- }) : placement);
1052
- }, []);
1053
- var referenceRect = state.rects.reference;
1054
- var popperRect = state.rects.popper;
1055
- var checksMap = new Map();
1056
- var makeFallbackChecks = true;
1057
- var firstFittingPlacement = placements[0];
1058
-
1059
- for (var i = 0; i < placements.length; i++) {
1060
- var placement = placements[i];
1061
-
1062
- var _basePlacement = getBasePlacement(placement);
1063
-
1064
- var isStartVariation = getVariation(placement) === start;
1065
- var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
1066
- var len = isVertical ? 'width' : 'height';
1067
- var overflow = detectOverflow(state, {
1068
- placement: placement,
1069
- boundary: boundary,
1070
- rootBoundary: rootBoundary,
1071
- altBoundary: altBoundary,
1072
- padding: padding
1073
- });
1074
- var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
1075
-
1076
- if (referenceRect[len] > popperRect[len]) {
1077
- mainVariationSide = getOppositePlacement(mainVariationSide);
1078
- }
1079
-
1080
- var altVariationSide = getOppositePlacement(mainVariationSide);
1081
- var checks = [];
1082
-
1083
- if (checkMainAxis) {
1084
- checks.push(overflow[_basePlacement] <= 0);
1085
- }
1086
-
1087
- if (checkAltAxis) {
1088
- checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
1089
- }
1090
-
1091
- if (checks.every(function (check) {
1092
- return check;
1093
- })) {
1094
- firstFittingPlacement = placement;
1095
- makeFallbackChecks = false;
1096
- break;
1097
- }
1098
-
1099
- checksMap.set(placement, checks);
1100
- }
1101
-
1102
- if (makeFallbackChecks) {
1103
- // `2` may be desired in some cases – research later
1104
- var numberOfChecks = flipVariations ? 3 : 1;
1105
-
1106
- var _loop = function _loop(_i) {
1107
- var fittingPlacement = placements.find(function (placement) {
1108
- var checks = checksMap.get(placement);
1109
-
1110
- if (checks) {
1111
- return checks.slice(0, _i).every(function (check) {
1112
- return check;
1113
- });
1114
- }
1115
- });
1116
-
1117
- if (fittingPlacement) {
1118
- firstFittingPlacement = fittingPlacement;
1119
- return "break";
1120
- }
1121
- };
1122
-
1123
- for (var _i = numberOfChecks; _i > 0; _i--) {
1124
- var _ret = _loop(_i);
1125
-
1126
- if (_ret === "break") break;
1127
- }
1128
- }
1129
-
1130
- if (state.placement !== firstFittingPlacement) {
1131
- state.modifiersData[name]._skip = true;
1132
- state.placement = firstFittingPlacement;
1133
- state.reset = true;
1134
- }
1135
- } // eslint-disable-next-line import/no-unused-modules
1136
-
1137
-
1138
- var flip$1 = {
1139
- name: 'flip',
1140
- enabled: true,
1141
- phase: 'main',
1142
- fn: flip,
1143
- requiresIfExists: ['offset'],
1144
- data: {
1145
- _skip: false
1146
- }
1147
- };
1148
-
1149
- function getSideOffsets(overflow, rect, preventedOffsets) {
1150
- if (preventedOffsets === void 0) {
1151
- preventedOffsets = {
1152
- x: 0,
1153
- y: 0
1154
- };
1155
- }
1156
-
1157
- return {
1158
- top: overflow.top - rect.height - preventedOffsets.y,
1159
- right: overflow.right - rect.width + preventedOffsets.x,
1160
- bottom: overflow.bottom - rect.height + preventedOffsets.y,
1161
- left: overflow.left - rect.width - preventedOffsets.x
1162
- };
1163
- }
1164
-
1165
- function isAnySideFullyClipped(overflow) {
1166
- return [top, right, bottom, left].some(function (side) {
1167
- return overflow[side] >= 0;
1168
- });
1169
- }
1170
-
1171
- function hide(_ref) {
1172
- var state = _ref.state,
1173
- name = _ref.name;
1174
- var referenceRect = state.rects.reference;
1175
- var popperRect = state.rects.popper;
1176
- var preventedOffsets = state.modifiersData.preventOverflow;
1177
- var referenceOverflow = detectOverflow(state, {
1178
- elementContext: 'reference'
1179
- });
1180
- var popperAltOverflow = detectOverflow(state, {
1181
- altBoundary: true
1182
- });
1183
- var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
1184
- var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
1185
- var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
1186
- var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
1187
- state.modifiersData[name] = {
1188
- referenceClippingOffsets: referenceClippingOffsets,
1189
- popperEscapeOffsets: popperEscapeOffsets,
1190
- isReferenceHidden: isReferenceHidden,
1191
- hasPopperEscaped: hasPopperEscaped
1192
- };
1193
- state.attributes.popper = Object.assign(Object.assign({}, state.attributes.popper), {}, {
1194
- 'data-popper-reference-hidden': isReferenceHidden,
1195
- 'data-popper-escaped': hasPopperEscaped
1196
- });
1197
- } // eslint-disable-next-line import/no-unused-modules
1198
-
1199
-
1200
- var hide$1 = {
1201
- name: 'hide',
1202
- enabled: true,
1203
- phase: 'main',
1204
- requiresIfExists: ['preventOverflow'],
1205
- fn: hide
1206
- };
1207
-
1208
- function distanceAndSkiddingToXY(placement, rects, offset) {
1209
- var basePlacement = getBasePlacement(placement);
1210
- var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
1211
-
1212
- var _ref = typeof offset === 'function' ? offset(Object.assign(Object.assign({}, rects), {}, {
1213
- placement: placement
1214
- })) : offset,
1215
- skidding = _ref[0],
1216
- distance = _ref[1];
1217
-
1218
- skidding = skidding || 0;
1219
- distance = (distance || 0) * invertDistance;
1220
- return [left, right].indexOf(basePlacement) >= 0 ? {
1221
- x: distance,
1222
- y: skidding
1223
- } : {
1224
- x: skidding,
1225
- y: distance
1226
- };
1227
- }
1228
-
1229
- function offset(_ref2) {
1230
- var state = _ref2.state,
1231
- options = _ref2.options,
1232
- name = _ref2.name;
1233
- var _options$offset = options.offset,
1234
- offset = _options$offset === void 0 ? [0, 0] : _options$offset;
1235
- var data = placements.reduce(function (acc, placement) {
1236
- acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
1237
- return acc;
1238
- }, {});
1239
- var _data$state$placement = data[state.placement],
1240
- x = _data$state$placement.x,
1241
- y = _data$state$placement.y;
1242
-
1243
- if (state.modifiersData.popperOffsets != null) {
1244
- state.modifiersData.popperOffsets.x += x;
1245
- state.modifiersData.popperOffsets.y += y;
1246
- }
1247
-
1248
- state.modifiersData[name] = data;
1249
- } // eslint-disable-next-line import/no-unused-modules
1250
-
1251
-
1252
- var offset$1 = {
1253
- name: 'offset',
1254
- enabled: true,
1255
- phase: 'main',
1256
- requires: ['popperOffsets'],
1257
- fn: offset
1258
- };
1259
-
1260
- function popperOffsets(_ref) {
1261
- var state = _ref.state,
1262
- name = _ref.name;
1263
- // Offsets are the actual position the popper needs to have to be
1264
- // properly positioned near its reference element
1265
- // This is the most basic placement, and will be adjusted by
1266
- // the modifiers in the next step
1267
- state.modifiersData[name] = computeOffsets({
1268
- reference: state.rects.reference,
1269
- element: state.rects.popper,
1270
- strategy: 'absolute',
1271
- placement: state.placement
1272
- });
1273
- } // eslint-disable-next-line import/no-unused-modules
1274
-
1275
-
1276
- var popperOffsets$1 = {
1277
- name: 'popperOffsets',
1278
- enabled: true,
1279
- phase: 'read',
1280
- fn: popperOffsets,
1281
- data: {}
1282
- };
1283
-
1284
- function getAltAxis(axis) {
1285
- return axis === 'x' ? 'y' : 'x';
1286
- }
1287
-
1288
- function preventOverflow(_ref) {
1289
- var state = _ref.state,
1290
- options = _ref.options,
1291
- name = _ref.name;
1292
- var _options$mainAxis = options.mainAxis,
1293
- checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1294
- _options$altAxis = options.altAxis,
1295
- checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
1296
- boundary = options.boundary,
1297
- rootBoundary = options.rootBoundary,
1298
- altBoundary = options.altBoundary,
1299
- padding = options.padding,
1300
- _options$tether = options.tether,
1301
- tether = _options$tether === void 0 ? true : _options$tether,
1302
- _options$tetherOffset = options.tetherOffset,
1303
- tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
1304
- var overflow = detectOverflow(state, {
1305
- boundary: boundary,
1306
- rootBoundary: rootBoundary,
1307
- padding: padding,
1308
- altBoundary: altBoundary
1309
- });
1310
- var basePlacement = getBasePlacement(state.placement);
1311
- var variation = getVariation(state.placement);
1312
- var isBasePlacement = !variation;
1313
- var mainAxis = getMainAxisFromPlacement(basePlacement);
1314
- var altAxis = getAltAxis(mainAxis);
1315
- var popperOffsets = state.modifiersData.popperOffsets;
1316
- var referenceRect = state.rects.reference;
1317
- var popperRect = state.rects.popper;
1318
- var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign(Object.assign({}, state.rects), {}, {
1319
- placement: state.placement
1320
- })) : tetherOffset;
1321
- var data = {
1322
- x: 0,
1323
- y: 0
1324
- };
1325
-
1326
- if (!popperOffsets) {
1327
- return;
1328
- }
1329
-
1330
- if (checkMainAxis) {
1331
- var mainSide = mainAxis === 'y' ? top : left;
1332
- var altSide = mainAxis === 'y' ? bottom : right;
1333
- var len = mainAxis === 'y' ? 'height' : 'width';
1334
- var offset = popperOffsets[mainAxis];
1335
- var min = popperOffsets[mainAxis] + overflow[mainSide];
1336
- var max = popperOffsets[mainAxis] - overflow[altSide];
1337
- var additive = tether ? -popperRect[len] / 2 : 0;
1338
- var minLen = variation === start ? referenceRect[len] : popperRect[len];
1339
- var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
1340
- // outside the reference bounds
1341
-
1342
- var arrowElement = state.elements.arrow;
1343
- var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
1344
- width: 0,
1345
- height: 0
1346
- };
1347
- var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
1348
- var arrowPaddingMin = arrowPaddingObject[mainSide];
1349
- var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
1350
- // to include its full size in the calculation. If the reference is small
1351
- // and near the edge of a boundary, the popper can overflow even if the
1352
- // reference is not overflowing as well (e.g. virtual elements with no
1353
- // width or height)
1354
-
1355
- var arrowLen = within(0, referenceRect[len], arrowRect[len]);
1356
- var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
1357
- var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
1358
- var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
1359
- var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
1360
- var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
1361
- var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
1362
- var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
1363
- var preventedOffset = within(tether ? Math.min(min, tetherMin) : min, offset, tether ? Math.max(max, tetherMax) : max);
1364
- popperOffsets[mainAxis] = preventedOffset;
1365
- data[mainAxis] = preventedOffset - offset;
1366
- }
1367
-
1368
- if (checkAltAxis) {
1369
- var _mainSide = mainAxis === 'x' ? top : left;
1370
-
1371
- var _altSide = mainAxis === 'x' ? bottom : right;
1372
-
1373
- var _offset = popperOffsets[altAxis];
1374
-
1375
- var _min = _offset + overflow[_mainSide];
1376
-
1377
- var _max = _offset - overflow[_altSide];
1378
-
1379
- var _preventedOffset = within(_min, _offset, _max);
1380
-
1381
- popperOffsets[altAxis] = _preventedOffset;
1382
- data[altAxis] = _preventedOffset - _offset;
1383
- }
1384
-
1385
- state.modifiersData[name] = data;
1386
- } // eslint-disable-next-line import/no-unused-modules
1387
-
1388
-
1389
- var preventOverflow$1 = {
1390
- name: 'preventOverflow',
1391
- enabled: true,
1392
- phase: 'main',
1393
- fn: preventOverflow,
1394
- requiresIfExists: ['offset']
1395
- };
1396
-
1397
- function getHTMLElementScroll(element) {
1398
- return {
1399
- scrollLeft: element.scrollLeft,
1400
- scrollTop: element.scrollTop
1401
- };
1402
- }
1403
-
1404
- function getNodeScroll(node) {
1405
- if (node === getWindow(node) || !isHTMLElement(node)) {
1406
- return getWindowScroll(node);
1407
- } else {
1408
- return getHTMLElementScroll(node);
1409
- }
1410
- }
1411
-
1412
- // Composite means it takes into account transforms as well as layout.
1413
-
1414
- function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
1415
- if (isFixed === void 0) {
1416
- isFixed = false;
1417
- }
1418
-
1419
- var documentElement = getDocumentElement(offsetParent);
1420
- var rect = getBoundingClientRect(elementOrVirtualElement);
1421
- var isOffsetParentAnElement = isHTMLElement(offsetParent);
1422
- var scroll = {
1423
- scrollLeft: 0,
1424
- scrollTop: 0
1425
- };
1426
- var offsets = {
1427
- x: 0,
1428
- y: 0
1429
- };
1430
-
1431
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1432
- if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
1433
- isScrollParent(documentElement)) {
1434
- scroll = getNodeScroll(offsetParent);
1435
- }
1436
-
1437
- if (isHTMLElement(offsetParent)) {
1438
- offsets = getBoundingClientRect(offsetParent);
1439
- offsets.x += offsetParent.clientLeft;
1440
- offsets.y += offsetParent.clientTop;
1441
- } else if (documentElement) {
1442
- offsets.x = getWindowScrollBarX(documentElement);
1443
- }
1444
- }
1445
-
1446
- return {
1447
- x: rect.left + scroll.scrollLeft - offsets.x,
1448
- y: rect.top + scroll.scrollTop - offsets.y,
1449
- width: rect.width,
1450
- height: rect.height
1451
- };
1452
- }
1453
-
1454
- function order(modifiers) {
1455
- var map = new Map();
1456
- var visited = new Set();
1457
- var result = [];
1458
- modifiers.forEach(function (modifier) {
1459
- map.set(modifier.name, modifier);
1460
- }); // On visiting object, check for its dependencies and visit them recursively
1461
-
1462
- function sort(modifier) {
1463
- visited.add(modifier.name);
1464
- var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
1465
- requires.forEach(function (dep) {
1466
- if (!visited.has(dep)) {
1467
- var depModifier = map.get(dep);
1468
-
1469
- if (depModifier) {
1470
- sort(depModifier);
1471
- }
1472
- }
1473
- });
1474
- result.push(modifier);
1475
- }
1476
-
1477
- modifiers.forEach(function (modifier) {
1478
- if (!visited.has(modifier.name)) {
1479
- // check for visited object
1480
- sort(modifier);
1481
- }
1482
- });
1483
- return result;
1484
- }
1485
-
1486
- function orderModifiers(modifiers) {
1487
- // order based on dependencies
1488
- var orderedModifiers = order(modifiers); // order based on phase
1489
-
1490
- return modifierPhases.reduce(function (acc, phase) {
1491
- return acc.concat(orderedModifiers.filter(function (modifier) {
1492
- return modifier.phase === phase;
1493
- }));
1494
- }, []);
1495
- }
1496
-
1497
- function debounce(fn) {
1498
- var pending;
1499
- return function () {
1500
- if (!pending) {
1501
- pending = new Promise(function (resolve) {
1502
- Promise.resolve().then(function () {
1503
- pending = undefined;
1504
- resolve(fn());
1505
- });
1506
- });
1507
- }
1508
-
1509
- return pending;
1510
- };
1511
- }
1512
-
1513
- function format(str) {
1514
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1515
- args[_key - 1] = arguments[_key];
1516
- }
1517
-
1518
- return [].concat(args).reduce(function (p, c) {
1519
- return p.replace(/%s/, c);
1520
- }, str);
1521
- }
1522
-
1523
- var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
1524
- var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
1525
- var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options'];
1526
- function validateModifiers(modifiers) {
1527
- modifiers.forEach(function (modifier) {
1528
- Object.keys(modifier).forEach(function (key) {
1529
- switch (key) {
1530
- case 'name':
1531
- if (typeof modifier.name !== 'string') {
1532
- console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', "\"" + String(modifier.name) + "\""));
1533
- }
1534
-
1535
- break;
1536
-
1537
- case 'enabled':
1538
- if (typeof modifier.enabled !== 'boolean') {
1539
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\""));
1540
- }
1541
-
1542
- case 'phase':
1543
- if (modifierPhases.indexOf(modifier.phase) < 0) {
1544
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
1545
- }
1546
-
1547
- break;
1548
-
1549
- case 'fn':
1550
- if (typeof modifier.fn !== 'function') {
1551
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\""));
1552
- }
1553
-
1554
- break;
1555
-
1556
- case 'effect':
1557
- if (typeof modifier.effect !== 'function') {
1558
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
1559
- }
1560
-
1561
- break;
1562
-
1563
- case 'requires':
1564
- if (!Array.isArray(modifier.requires)) {
1565
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
1566
- }
1567
-
1568
- break;
1569
-
1570
- case 'requiresIfExists':
1571
- if (!Array.isArray(modifier.requiresIfExists)) {
1572
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\""));
1573
- }
1574
-
1575
- break;
1576
-
1577
- case 'options':
1578
- case 'data':
1579
- break;
1580
-
1581
- default:
1582
- console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) {
1583
- return "\"" + s + "\"";
1584
- }).join(', ') + "; but \"" + key + "\" was provided.");
1585
- }
1586
-
1587
- modifier.requires && modifier.requires.forEach(function (requirement) {
1588
- if (modifiers.find(function (mod) {
1589
- return mod.name === requirement;
1590
- }) == null) {
1591
- console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
1592
- }
1593
- });
1594
- });
1595
- });
1596
- }
1597
-
1598
- function uniqueBy(arr, fn) {
1599
- var identifiers = new Set();
1600
- return arr.filter(function (item) {
1601
- var identifier = fn(item);
1602
-
1603
- if (!identifiers.has(identifier)) {
1604
- identifiers.add(identifier);
1605
- return true;
1606
- }
1607
- });
1608
- }
1609
-
1610
- function mergeByName(modifiers) {
1611
- var merged = modifiers.reduce(function (merged, current) {
1612
- var existing = merged[current.name];
1613
- merged[current.name] = existing ? Object.assign(Object.assign(Object.assign({}, existing), current), {}, {
1614
- options: Object.assign(Object.assign({}, existing.options), current.options),
1615
- data: Object.assign(Object.assign({}, existing.data), current.data)
1616
- }) : current;
1617
- return merged;
1618
- }, {}); // IE11 does not support Object.values
1619
-
1620
- return Object.keys(merged).map(function (key) {
1621
- return merged[key];
1622
- });
1623
- }
1624
-
1625
- var INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';
1626
- 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.';
1627
- var DEFAULT_OPTIONS = {
1628
- placement: 'bottom',
1629
- modifiers: [],
1630
- strategy: 'absolute'
1631
- };
1632
-
1633
- function areValidElements() {
1634
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1635
- args[_key] = arguments[_key];
1636
- }
1637
-
1638
- return !args.some(function (element) {
1639
- return !(element && typeof element.getBoundingClientRect === 'function');
1640
- });
1641
- }
1642
-
1643
- function popperGenerator(generatorOptions) {
1644
- if (generatorOptions === void 0) {
1645
- generatorOptions = {};
1646
- }
1647
-
1648
- var _generatorOptions = generatorOptions,
1649
- _generatorOptions$def = _generatorOptions.defaultModifiers,
1650
- defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
1651
- _generatorOptions$def2 = _generatorOptions.defaultOptions,
1652
- defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
1653
- return function createPopper(reference, popper, options) {
1654
- if (options === void 0) {
1655
- options = defaultOptions;
1656
- }
1657
-
1658
- var state = {
1659
- placement: 'bottom',
1660
- orderedModifiers: [],
1661
- options: Object.assign(Object.assign({}, DEFAULT_OPTIONS), defaultOptions),
1662
- modifiersData: {},
1663
- elements: {
1664
- reference: reference,
1665
- popper: popper
1666
- },
1667
- attributes: {},
1668
- styles: {}
1669
- };
1670
- var effectCleanupFns = [];
1671
- var isDestroyed = false;
1672
- var instance = {
1673
- state: state,
1674
- setOptions: function setOptions(options) {
1675
- cleanupModifierEffects();
1676
- state.options = Object.assign(Object.assign(Object.assign({}, defaultOptions), state.options), options);
1677
- state.scrollParents = {
1678
- reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
1679
- popper: listScrollParents(popper)
1680
- }; // Orders the modifiers based on their dependencies and `phase`
1681
- // properties
1682
-
1683
- var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
1684
-
1685
- state.orderedModifiers = orderedModifiers.filter(function (m) {
1686
- return m.enabled;
1687
- }); // Validate the provided modifiers so that the consumer will get warned
1688
- // if one of the modifiers is invalid for any reason
1689
-
1690
- if (process.env.NODE_ENV !== "production") {
1691
- var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) {
1692
- var name = _ref.name;
1693
- return name;
1694
- });
1695
- validateModifiers(modifiers);
1696
-
1697
- if (getBasePlacement(state.options.placement) === auto) {
1698
- var flipModifier = state.orderedModifiers.find(function (_ref2) {
1699
- var name = _ref2.name;
1700
- return name === 'flip';
1701
- });
1702
-
1703
- if (!flipModifier) {
1704
- console.error(['Popper: "auto" placements require the "flip" modifier be', 'present and enabled to work.'].join(' '));
1705
- }
1706
- }
1707
-
1708
- var _getComputedStyle = getComputedStyle(popper),
1709
- marginTop = _getComputedStyle.marginTop,
1710
- marginRight = _getComputedStyle.marginRight,
1711
- marginBottom = _getComputedStyle.marginBottom,
1712
- marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can
1713
- // cause bugs with positioning, so we'll warn the consumer
1714
-
1715
-
1716
- if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {
1717
- return parseFloat(margin);
1718
- })) {
1719
- 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(' '));
1720
- }
1721
- }
1722
-
1723
- runModifierEffects();
1724
- return instance.update();
1725
- },
1726
- // Sync update – it will always be executed, even if not necessary. This
1727
- // is useful for low frequency updates where sync behavior simplifies the
1728
- // logic.
1729
- // For high frequency updates (e.g. `resize` and `scroll` events), always
1730
- // prefer the async Popper#update method
1731
- forceUpdate: function forceUpdate() {
1732
- if (isDestroyed) {
1733
- return;
1734
- }
1735
-
1736
- var _state$elements = state.elements,
1737
- reference = _state$elements.reference,
1738
- popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
1739
- // anymore
1740
-
1741
- if (!areValidElements(reference, popper)) {
1742
- if (process.env.NODE_ENV !== "production") {
1743
- console.error(INVALID_ELEMENT_ERROR);
1744
- }
1745
-
1746
- return;
1747
- } // Store the reference and popper rects to be read by modifiers
1748
-
1749
-
1750
- state.rects = {
1751
- reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
1752
- popper: getLayoutRect(popper)
1753
- }; // Modifiers have the ability to reset the current update cycle. The
1754
- // most common use case for this is the `flip` modifier changing the
1755
- // placement, which then needs to re-run all the modifiers, because the
1756
- // logic was previously ran for the previous placement and is therefore
1757
- // stale/incorrect
1758
-
1759
- state.reset = false;
1760
- state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
1761
- // is filled with the initial data specified by the modifier. This means
1762
- // it doesn't persist and is fresh on each update.
1763
- // To ensure persistent data, use `${name}#persistent`
1764
-
1765
- state.orderedModifiers.forEach(function (modifier) {
1766
- return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
1767
- });
1768
- var __debug_loops__ = 0;
1769
-
1770
- for (var index = 0; index < state.orderedModifiers.length; index++) {
1771
- if (process.env.NODE_ENV !== "production") {
1772
- __debug_loops__ += 1;
1773
-
1774
- if (__debug_loops__ > 100) {
1775
- console.error(INFINITE_LOOP_ERROR);
1776
- break;
1777
- }
1778
- }
1779
-
1780
- if (state.reset === true) {
1781
- state.reset = false;
1782
- index = -1;
1783
- continue;
1784
- }
1785
-
1786
- var _state$orderedModifie = state.orderedModifiers[index],
1787
- fn = _state$orderedModifie.fn,
1788
- _state$orderedModifie2 = _state$orderedModifie.options,
1789
- _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
1790
- name = _state$orderedModifie.name;
1791
-
1792
- if (typeof fn === 'function') {
1793
- state = fn({
1794
- state: state,
1795
- options: _options,
1796
- name: name,
1797
- instance: instance
1798
- }) || state;
1799
- }
1800
- }
1801
- },
1802
- // Async and optimistically optimized update – it will not be executed if
1803
- // not necessary (debounced to run at most once-per-tick)
1804
- update: debounce(function () {
1805
- return new Promise(function (resolve) {
1806
- instance.forceUpdate();
1807
- resolve(state);
1808
- });
1809
- }),
1810
- destroy: function destroy() {
1811
- cleanupModifierEffects();
1812
- isDestroyed = true;
1813
- }
1814
- };
1815
-
1816
- if (!areValidElements(reference, popper)) {
1817
- if (process.env.NODE_ENV !== "production") {
1818
- console.error(INVALID_ELEMENT_ERROR);
1819
- }
1820
-
1821
- return instance;
1822
- }
1823
-
1824
- instance.setOptions(options).then(function (state) {
1825
- if (!isDestroyed && options.onFirstUpdate) {
1826
- options.onFirstUpdate(state);
1827
- }
1828
- }); // Modifiers have the ability to execute arbitrary code before the first
1829
- // update cycle runs. They will be executed in the same order as the update
1830
- // cycle. This is useful when a modifier adds some persistent data that
1831
- // other modifiers need to use, but the modifier is run after the dependent
1832
- // one.
1833
-
1834
- function runModifierEffects() {
1835
- state.orderedModifiers.forEach(function (_ref3) {
1836
- var name = _ref3.name,
1837
- _ref3$options = _ref3.options,
1838
- options = _ref3$options === void 0 ? {} : _ref3$options,
1839
- effect = _ref3.effect;
1840
-
1841
- if (typeof effect === 'function') {
1842
- var cleanupFn = effect({
1843
- state: state,
1844
- name: name,
1845
- instance: instance,
1846
- options: options
1847
- });
1848
-
1849
- var noopFn = function noopFn() {};
1850
-
1851
- effectCleanupFns.push(cleanupFn || noopFn);
1852
- }
1853
- });
1854
- }
1855
-
1856
- function cleanupModifierEffects() {
1857
- effectCleanupFns.forEach(function (fn) {
1858
- return fn();
1859
- });
1860
- effectCleanupFns = [];
1861
- }
1862
-
1863
- return instance;
1864
- };
1865
- }
1866
-
1867
- var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
1868
- var createPopper = /*#__PURE__*/popperGenerator({
1869
- defaultModifiers: defaultModifiers
1870
- }); // eslint-disable-next-line import/no-unused-modules
1871
-
1872
- /**
1873
- * Simple ponyfill for Object.fromEntries
1874
- */
1875
-
1876
- var fromEntries = function fromEntries(entries) {
1877
- return entries.reduce(function (acc, _ref) {
1878
- var key = _ref[0],
1879
- value = _ref[1];
1880
- acc[key] = value;
1881
- return acc;
1882
- }, {});
1883
- };
1884
- /**
1885
- * Small wrapper around `useLayoutEffect` to get rid of the warning on SSR envs
1886
- */
1887
-
1888
- var useIsomorphicLayoutEffect = typeof window !== 'undefined' && window.document && window.document.createElement ? useLayoutEffect : useEffect;
1889
-
1890
- /* global Map:readonly, Set:readonly, ArrayBuffer:readonly */
1891
-
1892
- var hasElementType = typeof Element !== 'undefined';
1893
- var hasMap = typeof Map === 'function';
1894
- var hasSet = typeof Set === 'function';
1895
- var hasArrayBuffer = typeof ArrayBuffer === 'function' && !!ArrayBuffer.isView;
1896
-
1897
- // Note: We **don't** need `envHasBigInt64Array` in fde es6/index.js
1898
-
1899
- function equal(a, b) {
1900
- // START: fast-deep-equal es6/index.js 3.1.1
1901
- if (a === b) return true;
1902
-
1903
- if (a && b && typeof a == 'object' && typeof b == 'object') {
1904
- if (a.constructor !== b.constructor) return false;
1905
-
1906
- var length, i, keys;
1907
- if (Array.isArray(a)) {
1908
- length = a.length;
1909
- if (length != b.length) return false;
1910
- for (i = length; i-- !== 0;)
1911
- if (!equal(a[i], b[i])) return false;
1912
- return true;
1913
- }
1914
-
1915
- // START: Modifications:
1916
- // 1. Extra `has<Type> &&` helpers in initial condition allow es6 code
1917
- // to co-exist with es5.
1918
- // 2. Replace `for of` with es5 compliant iteration using `for`.
1919
- // Basically, take:
1920
- //
1921
- // ```js
1922
- // for (i of a.entries())
1923
- // if (!b.has(i[0])) return false;
1924
- // ```
1925
- //
1926
- // ... and convert to:
1927
- //
1928
- // ```js
1929
- // it = a.entries();
1930
- // while (!(i = it.next()).done)
1931
- // if (!b.has(i.value[0])) return false;
1932
- // ```
1933
- //
1934
- // **Note**: `i` access switches to `i.value`.
1935
- var it;
1936
- if (hasMap && (a instanceof Map) && (b instanceof Map)) {
1937
- if (a.size !== b.size) return false;
1938
- it = a.entries();
1939
- while (!(i = it.next()).done)
1940
- if (!b.has(i.value[0])) return false;
1941
- it = a.entries();
1942
- while (!(i = it.next()).done)
1943
- if (!equal(i.value[1], b.get(i.value[0]))) return false;
1944
- return true;
1945
- }
1946
-
1947
- if (hasSet && (a instanceof Set) && (b instanceof Set)) {
1948
- if (a.size !== b.size) return false;
1949
- it = a.entries();
1950
- while (!(i = it.next()).done)
1951
- if (!b.has(i.value[0])) return false;
1952
- return true;
1953
- }
1954
- // END: Modifications
1955
-
1956
- if (hasArrayBuffer && ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
1957
- length = a.length;
1958
- if (length != b.length) return false;
1959
- for (i = length; i-- !== 0;)
1960
- if (a[i] !== b[i]) return false;
1961
- return true;
1962
- }
1963
-
1964
- if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
1965
- if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
1966
- if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
1967
-
1968
- keys = Object.keys(a);
1969
- length = keys.length;
1970
- if (length !== Object.keys(b).length) return false;
1971
-
1972
- for (i = length; i-- !== 0;)
1973
- if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
1974
- // END: fast-deep-equal
1975
-
1976
- // START: react-fast-compare
1977
- // custom handling for DOM elements
1978
- if (hasElementType && a instanceof Element) return false;
1979
-
1980
- // custom handling for React/Preact
1981
- for (i = length; i-- !== 0;) {
1982
- if ((keys[i] === '_owner' || keys[i] === '__v' || keys[i] === '__o') && a.$$typeof) {
1983
- // React-specific: avoid traversing React elements' _owner
1984
- // Preact-specific: avoid traversing Preact elements' __v and __o
1985
- // __v = $_original / $_vnode
1986
- // __o = $_owner
1987
- // These properties contain circular references and are not needed when
1988
- // comparing the actual elements (and not their owners)
1989
- // .$$typeof and ._store on just reasonable markers of elements
1990
-
1991
- continue;
1992
- }
1993
-
1994
- // all other properties should be traversed as usual
1995
- if (!equal(a[keys[i]], b[keys[i]])) return false;
1996
- }
1997
- // END: react-fast-compare
1998
-
1999
- // START: fast-deep-equal
2000
- return true;
2001
- }
2002
-
2003
- return a !== a && b !== b;
2004
- }
2005
- // end fast-deep-equal
2006
-
2007
- var reactFastCompare = function isEqual(a, b) {
2008
- try {
2009
- return equal(a, b);
2010
- } catch (error) {
2011
- if (((error.message || '').match(/stack|recursion/i))) {
2012
- // warn on circular references, don't crash
2013
- // browsers give this different errors name and messages:
2014
- // chrome/safari: "RangeError", "Maximum call stack size exceeded"
2015
- // firefox: "InternalError", too much recursion"
2016
- // edge: "Error", "Out of stack space"
2017
- console.warn('react-fast-compare cannot handle circular refs');
2018
- return false;
2019
- }
2020
- // some other error. we should definitely know about these
2021
- throw error;
2022
- }
2023
- };
2024
-
2025
- var EMPTY_MODIFIERS = [];
2026
- var usePopper = function usePopper(referenceElement, popperElement, options) {
2027
- if (options === void 0) {
2028
- options = {};
2029
- }
2030
-
2031
- var prevOptions = useRef(null);
2032
- var optionsWithDefaults = {
2033
- onFirstUpdate: options.onFirstUpdate,
2034
- placement: options.placement || 'bottom',
2035
- strategy: options.strategy || 'absolute',
2036
- modifiers: options.modifiers || EMPTY_MODIFIERS
2037
- };
2038
-
2039
- var _React$useState = useState({
2040
- styles: {
2041
- popper: {
2042
- position: optionsWithDefaults.strategy,
2043
- left: '0',
2044
- top: '0'
2045
- }
2046
- },
2047
- attributes: {}
2048
- }),
2049
- state = _React$useState[0],
2050
- setState = _React$useState[1];
2051
-
2052
- var updateStateModifier = useMemo(function () {
2053
- return {
2054
- name: 'updateState',
2055
- enabled: true,
2056
- phase: 'write',
2057
- fn: function fn(_ref) {
2058
- var state = _ref.state;
2059
- var elements = Object.keys(state.elements);
2060
- setState({
2061
- styles: fromEntries(elements.map(function (element) {
2062
- return [element, state.styles[element] || {}];
2063
- })),
2064
- attributes: fromEntries(elements.map(function (element) {
2065
- return [element, state.attributes[element]];
2066
- }))
2067
- });
2068
- },
2069
- requires: ['computeStyles']
2070
- };
2071
- }, []);
2072
- var popperOptions = useMemo(function () {
2073
- var newOptions = {
2074
- onFirstUpdate: optionsWithDefaults.onFirstUpdate,
2075
- placement: optionsWithDefaults.placement,
2076
- strategy: optionsWithDefaults.strategy,
2077
- modifiers: [].concat(optionsWithDefaults.modifiers, [updateStateModifier, {
2078
- name: 'applyStyles',
2079
- enabled: false
2080
- }])
2081
- };
2082
-
2083
- if (reactFastCompare(prevOptions.current, newOptions)) {
2084
- return prevOptions.current || newOptions;
2085
- } else {
2086
- prevOptions.current = newOptions;
2087
- return newOptions;
2088
- }
2089
- }, [optionsWithDefaults.onFirstUpdate, optionsWithDefaults.placement, optionsWithDefaults.strategy, optionsWithDefaults.modifiers, updateStateModifier]);
2090
- var popperInstanceRef = useRef();
2091
- useIsomorphicLayoutEffect(function () {
2092
- if (popperInstanceRef.current) {
2093
- popperInstanceRef.current.setOptions(popperOptions);
2094
- }
2095
- }, [popperOptions]);
2096
- useIsomorphicLayoutEffect(function () {
2097
- if (referenceElement == null || popperElement == null) {
2098
- return;
2099
- }
2100
-
2101
- var createPopper$1 = options.createPopper || createPopper;
2102
- var popperInstance = createPopper$1(referenceElement, popperElement, popperOptions);
2103
- popperInstanceRef.current = popperInstance;
2104
- return function () {
2105
- popperInstance.destroy();
2106
- popperInstanceRef.current = null;
2107
- };
2108
- }, [referenceElement, popperElement, options.createPopper]);
2109
- return {
2110
- state: popperInstanceRef.current ? popperInstanceRef.current.state : null,
2111
- styles: state.styles,
2112
- attributes: state.attributes,
2113
- update: popperInstanceRef.current ? popperInstanceRef.current.update : null,
2114
- forceUpdate: popperInstanceRef.current ? popperInstanceRef.current.forceUpdate : null
2115
- };
2116
- };
2117
-
2118
- /**
2119
- * Hook that allows to control when there is a focus event within a given element, meaning
2120
- * that any element within the given target will trigger the focus in and focus out events.
2121
- * @param options - UseFocusWithinOptions
2122
- */
2123
- var useFocusWithin = function useFocusWithin(_ref) {
2124
- var element = _ref.element,
2125
- onFocusIn = _ref.onFocusIn,
2126
- onFocusOut = _ref.onFocusOut;
2127
- useEffect(function () {
2128
- if (element) {
2129
- element.addEventListener('focusin', onFocusIn);
2130
- element.addEventListener('focusout', onFocusOut);
2131
- }
2132
-
2133
- return function () {
2134
- if (element) {
2135
- element.removeEventListener('focusin', onFocusIn);
2136
- element.removeEventListener('focusout', onFocusOut);
2137
- }
2138
- };
2139
- }, [onFocusIn, element, onFocusOut]);
2140
- };
2141
-
2142
- /**
2143
- * Different possible placements for the popover.
2144
- */
2145
-
2146
- var Placement = {
2147
- AUTO: 'auto',
2148
- AUTO_END: 'auto-end',
2149
- AUTO_START: 'auto-start',
2150
- TOP: 'top',
2151
- TOP_END: 'top-end',
2152
- TOP_START: 'top-start',
2153
- RIGHT: 'right',
2154
- RIGHT_END: 'right-end',
2155
- RIGHT_START: 'right-start',
2156
- BOTTOM: 'bottom',
2157
- BOTTOM_END: 'bottom-end',
2158
- BOTTOM_START: 'bottom-start',
2159
- LEFT: 'left',
2160
- LEFT_END: 'left-end',
2161
- LEFT_START: 'left-start'
2162
- };
2163
-
2164
- /**
2165
- * Arrow size (in pixel).
2166
- */
2167
- var ARROW_SIZE = 8;
2168
- /**
2169
- * Defines the props of the component.
2170
- */
2171
-
2172
- /**
2173
- * Component display name.
2174
- */
2175
- var COMPONENT_NAME = 'Popover';
2176
- /**
2177
- * Component default class name and class prefix.
2178
- */
2179
-
2180
- var CLASSNAME = getRootClassName(COMPONENT_NAME);
2181
- /**
2182
- * Component default props.
2183
- */
2184
-
2185
- var DEFAULT_PROPS = {
2186
- elevation: 3,
2187
- placement: Placement.AUTO,
2188
- usePortal: true,
2189
- zIndex: 9999
2190
- };
2191
- /**
2192
- * Popper js modifier to fit popover min width to the anchor width.
2193
- */
2194
-
2195
- var sameWidth = {
2196
- name: 'sameWidth',
2197
- enabled: true,
2198
- phase: 'beforeWrite',
2199
- requires: ['computeStyles'],
2200
- fn: function fn(_ref) {
2201
- var state = _ref.state;
2202
- // eslint-disable-next-line no-param-reassign
2203
- state.styles.popper.minWidth = "".concat(state.rects.reference.width, "px");
2204
- },
2205
- effect: function effect(_ref2) {
2206
- var state = _ref2.state;
2207
- // eslint-disable-next-line no-param-reassign
2208
- state.elements.popper.style.minWidth = "".concat(state.elements.reference.offsetWidth, "px");
2209
- }
2210
- };
2211
- /**
2212
- * Popper js modifier to compute max size of the popover.
2213
- */
2214
-
2215
- var maxSize = {
2216
- name: 'maxSize',
2217
- enabled: true,
2218
- phase: 'main',
2219
- requiresIfExists: ['offset', 'preventOverflow', 'flip'],
2220
- fn: function fn(_ref3) {
2221
- var state = _ref3.state,
2222
- name = _ref3.name,
2223
- options = _ref3.options;
2224
- var overflow = detectOverflow(state, options);
2225
- var _state$modifiersData$ = state.modifiersData.preventOverflow,
2226
- _state$modifiersData$2 = _state$modifiersData$.y,
2227
- y = _state$modifiersData$2 === void 0 ? 0 : _state$modifiersData$2,
2228
- _state$modifiersData$3 = _state$modifiersData$.x,
2229
- x = _state$modifiersData$3 === void 0 ? 0 : _state$modifiersData$3;
2230
- var _state$rects$popper = state.rects.popper,
2231
- width = _state$rects$popper.width,
2232
- height = _state$rects$popper.height;
2233
-
2234
- var _state$placement$spli = state.placement.split('-'),
2235
- _state$placement$spli2 = _slicedToArray(_state$placement$spli, 1),
2236
- basePlacement = _state$placement$spli2[0];
2237
-
2238
- var widthProp = basePlacement === 'left' ? 'left' : 'right';
2239
- var heightProp = basePlacement === 'top' ? 'top' : 'bottom'; // eslint-disable-next-line no-param-reassign
2240
-
2241
- state.modifiersData[name] = {
2242
- width: width - overflow[widthProp] - x,
2243
- height: height - overflow[heightProp] - y
2244
- };
2245
- }
2246
- };
2247
- /**
2248
- * Popper js modifier to apply the max height.
2249
- */
2250
-
2251
- var applyMaxHeight = {
2252
- name: 'applyMaxHeight',
2253
- enabled: true,
2254
- phase: 'beforeWrite',
2255
- requires: ['maxSize'],
2256
- fn: function fn(_ref4) {
2257
- var state = _ref4.state;
2258
- var height = state.modifiersData.maxSize.height; // eslint-disable-next-line no-param-reassign
2259
-
2260
- state.elements.popper.style.maxHeight = "".concat(height - ARROW_SIZE, "px");
2261
- }
2262
- };
2263
- /** Method to render the popover inside a portal if usePortal is true */
2264
-
2265
- var renderPopover = function renderPopover(children, usePortal) {
2266
- return usePortal ? createPortal(children, document.body) : children;
2267
- };
2268
- /**
2269
- * Popover component.
2270
- *
2271
- * @param props Component props.
2272
- * @param ref Component ref.
2273
- * @return React element.
2274
- */
2275
-
2276
-
2277
- var Popover = forwardRef(function (props, ref) {
2278
- var _ref5, _ref6, _ref7, _ref8, _state$rects, _state$rects$popper2;
2279
-
2280
- if (!DOCUMENT) {
2281
- // Can't render in SSR.
2282
- return null;
2283
- }
2284
-
2285
- var anchorRef = props.anchorRef,
2286
- boundaryRef = props.boundaryRef,
2287
- children = props.children,
2288
- className = props.className,
2289
- closeOnClickAway = props.closeOnClickAway,
2290
- closeOnEscape = props.closeOnEscape,
2291
- elevation = props.elevation,
2292
- fitToAnchorWidth = props.fitToAnchorWidth,
2293
- fitWithinViewportHeight = props.fitWithinViewportHeight,
2294
- focusElement = props.focusElement,
2295
- hasArrow = props.hasArrow,
2296
- isOpen = props.isOpen,
2297
- offset = props.offset,
2298
- onClose = props.onClose,
2299
- parentElement = props.parentElement,
2300
- placement = props.placement,
2301
- style = props.style,
2302
- usePortal = props.usePortal,
2303
- zIndex = props.zIndex,
2304
- _props$focusAnchorOnC = props.focusAnchorOnClose,
2305
- focusAnchorOnClose = _props$focusAnchorOnC === void 0 ? true : _props$focusAnchorOnC,
2306
- forwardedProps = _objectWithoutProperties(props, ["anchorRef", "boundaryRef", "children", "className", "closeOnClickAway", "closeOnEscape", "elevation", "fitToAnchorWidth", "fitWithinViewportHeight", "focusElement", "hasArrow", "isOpen", "offset", "onClose", "parentElement", "placement", "style", "usePortal", "zIndex", "focusAnchorOnClose"]); // eslint-disable-next-line react-hooks/rules-of-hooks
2307
-
2308
-
2309
- var _useState = useState(),
2310
- _useState2 = _slicedToArray(_useState, 2),
2311
- popperElement = _useState2[0],
2312
- setPopperElement = _useState2[1]; // eslint-disable-next-line react-hooks/rules-of-hooks
2313
-
2314
-
2315
- var _useState3 = useState(null),
2316
- _useState4 = _slicedToArray(_useState3, 2),
2317
- arrowElement = _useState4[0],
2318
- setArrowElement = _useState4[1]; // eslint-disable-next-line react-hooks/rules-of-hooks
2319
-
2320
-
2321
- var clickAwayRef = useRef(null);
2322
- /**
2323
- * Track whether the focus is currently set in the
2324
- * popover.
2325
- * */
2326
- // eslint-disable-next-line react-hooks/rules-of-hooks
2327
-
2328
- var isFocusedWithin = useRef(false); // eslint-disable-next-line react-hooks/rules-of-hooks
2329
-
2330
- useFocusWithin({
2331
- element: popperElement || null,
2332
- onFocusIn: function onFocusIn() {
2333
- isFocusedWithin.current = true;
2334
- },
2335
- onFocusOut: function onFocusOut() {
2336
- isFocusedWithin.current = false;
2337
- }
2338
- });
2339
- /** Action on close */
2340
- // eslint-disable-next-line react-hooks/rules-of-hooks
2341
-
2342
- var handleClose = useCallback(function () {
2343
- if (!onClose) {
2344
- return;
2345
- }
2346
- /**
2347
- * If the focus is currently within the popover
2348
- * when the popover closes, reset the focus back to the anchor element
2349
- * unless specifically requested not to.
2350
- */
2351
-
2352
-
2353
- if (isFocusedWithin.current && focusAnchorOnClose) {
2354
- if (parentElement === null || parentElement === void 0 ? void 0 : parentElement.current) {
2355
- parentElement === null || parentElement === void 0 ? void 0 : parentElement.current.focus();
2356
- }
2357
-
2358
- var firstFocusable = (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) && getFirstAndLastFocusable(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current).first;
2359
-
2360
- if (firstFocusable) {
2361
- // Focus the first focusable element in anchor.
2362
- firstFocusable.focus();
2363
- } else {
2364
- var _anchorRef$current;
2365
-
2366
- // Fallback on the anchor element.
2367
- anchorRef === null || anchorRef === void 0 ? void 0 : (_anchorRef$current = anchorRef.current) === null || _anchorRef$current === void 0 ? void 0 : _anchorRef$current.focus();
2368
- }
2369
- }
2370
-
2371
- onClose();
2372
- }, [anchorRef, focusAnchorOnClose, onClose, parentElement]);
2373
- var modifiers = [];
2374
- var actualOffset = [(_ref5 = offset === null || offset === void 0 ? void 0 : offset.along) !== null && _ref5 !== void 0 ? _ref5 : 0, ((_ref6 = offset === null || offset === void 0 ? void 0 : offset.away) !== null && _ref6 !== void 0 ? _ref6 : 0) + (hasArrow ? ARROW_SIZE : 0)];
2375
- modifiers.push({
2376
- name: 'offset',
2377
- options: {
2378
- offset: actualOffset
2379
- }
2380
- });
2381
-
2382
- if (hasArrow && arrowElement) {
2383
- modifiers.push({
2384
- name: 'arrow',
2385
- options: {
2386
- element: arrowElement,
2387
- padding: ARROW_SIZE
2388
- }
2389
- });
2390
- }
2391
-
2392
- if (fitToAnchorWidth) {
2393
- modifiers.push(sameWidth);
2394
- }
2395
-
2396
- if (fitWithinViewportHeight) {
2397
- modifiers.push(_objectSpread2({}, maxSize, {
2398
- options: {
2399
- boundary: boundaryRef === null || boundaryRef === void 0 ? void 0 : boundaryRef.current
2400
- }
2401
- }), applyMaxHeight);
2402
- }
2403
-
2404
- if (boundaryRef) {
2405
- modifiers.push({
2406
- name: 'flip',
2407
- options: {
2408
- boundary: boundaryRef.current
2409
- }
2410
- });
2411
- modifiers.push({
2412
- name: 'preventOverflow',
2413
- options: {
2414
- boundary: boundaryRef.current
2415
- }
2416
- });
2417
- } // eslint-disable-next-line react-hooks/rules-of-hooks
2418
-
2419
-
2420
- var _usePopper = usePopper(anchorRef.current, popperElement, {
2421
- placement: placement,
2422
- modifiers: modifiers
2423
- }),
2424
- styles = _usePopper.styles,
2425
- attributes = _usePopper.attributes,
2426
- state = _usePopper.state,
2427
- update = _usePopper.update; // eslint-disable-next-line react-hooks/rules-of-hooks
2428
-
2429
-
2430
- useEffect(function () {
2431
- update === null || update === void 0 ? void 0 : update();
2432
- }, [children, update]);
2433
- var position = (_ref7 = state === null || state === void 0 ? void 0 : state.placement) !== null && _ref7 !== void 0 ? _ref7 : placement; // eslint-disable-next-line react-hooks/rules-of-hooks
2434
-
2435
- var popoverStyle = useMemo(function () {
2436
- var newStyles = _objectSpread2({}, style, {}, styles.popper, {
2437
- zIndex: zIndex
2438
- });
2439
-
2440
- if (fitWithinViewportHeight && !newStyles.maxHeight) {
2441
- newStyles.maxHeight = (WINDOW === null || WINDOW === void 0 ? void 0 : WINDOW.innerHeight) || (DOCUMENT === null || DOCUMENT === void 0 ? void 0 : DOCUMENT.documentElement.clientHeight);
2442
- }
2443
-
2444
- return newStyles;
2445
- }, [style, styles.popper, zIndex, fitWithinViewportHeight]); // eslint-disable-next-line react-hooks/rules-of-hooks
2446
-
2447
- useCallbackOnEscape(handleClose, isOpen && closeOnEscape); // eslint-disable-next-line react-hooks/rules-of-hooks
2448
-
2449
- useFocus(focusElement === null || focusElement === void 0 ? void 0 : focusElement.current, isOpen && ((_ref8 = state === null || state === void 0 ? void 0 : (_state$rects = state.rects) === null || _state$rects === void 0 ? void 0 : (_state$rects$popper2 = _state$rects.popper) === null || _state$rects$popper2 === void 0 ? void 0 : _state$rects$popper2.y) !== null && _ref8 !== void 0 ? _ref8 : -1) >= 0); // eslint-disable-next-line react-hooks/rules-of-hooks
2450
-
2451
- var clickAwayRefs = useRef([clickAwayRef, anchorRef]);
2452
- return isOpen ? renderPopover(React.createElement("div", _extends({}, forwardedProps, {
2453
- ref: mergeRefs(setPopperElement, ref, clickAwayRef),
2454
- className: classnames(className, handleBasicClasses({
2455
- prefix: CLASSNAME,
2456
- elevation: Math.min(elevation || 0, 5),
2457
- position: position
2458
- })),
2459
- style: popoverStyle
2460
- }, attributes.popper), React.createElement(ClickAwayProvider, {
2461
- callback: closeOnClickAway && handleClose,
2462
- childrenRefs: clickAwayRefs
2463
- }, hasArrow && React.createElement("div", {
2464
- ref: setArrowElement,
2465
- className: "".concat(CLASSNAME, "__arrow"),
2466
- style: styles.arrow
2467
- }), children)), usePortal) : null;
2468
- });
2469
- Popover.displayName = COMPONENT_NAME;
2470
- Popover.className = CLASSNAME;
2471
- Popover.defaultProps = DEFAULT_PROPS;
2472
-
2473
- export { Placement as P, Popover as a, useFocusWithin as b, usePopper as c, useFocus as u };
2474
- //# sourceMappingURL=9ab3c637.js.map