@bigbinary/neetoui 6.6.0 → 6.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/README.md +2 -5
  2. package/dist/Accordion.js +2 -290
  3. package/dist/Accordion.js.map +1 -1
  4. package/dist/ActionDropdown.js +4 -3
  5. package/dist/ActionDropdown.js.map +1 -1
  6. package/dist/Alert.js +5 -4
  7. package/dist/Alert.js.map +1 -1
  8. package/dist/Avatar.js +9 -1128
  9. package/dist/Avatar.js.map +1 -1
  10. package/dist/Button.js +3 -2
  11. package/dist/Button.js.map +1 -1
  12. package/dist/Checkbox.js +3 -2
  13. package/dist/Checkbox.js.map +1 -1
  14. package/dist/ColorPicker.js +8 -8
  15. package/dist/ColorPicker.js.map +1 -1
  16. package/dist/DatePicker.js +3 -2
  17. package/dist/DatePicker.js.map +1 -1
  18. package/dist/DateTimePicker.js +7 -5
  19. package/dist/DateTimePicker.js.map +1 -1
  20. package/dist/Dropdown.js +4 -3
  21. package/dist/Dropdown.js.map +1 -1
  22. package/dist/Input.js +3 -2
  23. package/dist/Input.js.map +1 -1
  24. package/dist/Kbd.js +2 -1
  25. package/dist/Kbd.js.map +1 -1
  26. package/dist/Label.js +2 -1
  27. package/dist/Label.js.map +1 -1
  28. package/dist/Modal.js +5 -4
  29. package/dist/Modal.js.map +1 -1
  30. package/dist/MultiEmailInput.js +6 -4
  31. package/dist/MultiEmailInput.js.map +1 -1
  32. package/dist/NoData.js +3 -2
  33. package/dist/NoData.js.map +1 -1
  34. package/dist/Pagination.js +2 -2
  35. package/dist/Pane.js +5 -4
  36. package/dist/Pane.js.map +1 -1
  37. package/dist/Popover.js +2 -1
  38. package/dist/Popover.js.map +1 -1
  39. package/dist/ProgressBar.js +1 -1
  40. package/dist/Radio.js +3 -2
  41. package/dist/Radio.js.map +1 -1
  42. package/dist/Select.js +30 -182
  43. package/dist/Select.js.map +1 -1
  44. package/dist/Sidebar.js +4 -2
  45. package/dist/Sidebar.js.map +1 -1
  46. package/dist/Slider.js +3 -2
  47. package/dist/Slider.js.map +1 -1
  48. package/dist/Switch.js +3 -2
  49. package/dist/Switch.js.map +1 -1
  50. package/dist/Table.js +405 -4540
  51. package/dist/Table.js.map +1 -1
  52. package/dist/Textarea.js +3 -2
  53. package/dist/Textarea.js.map +1 -1
  54. package/dist/TimePicker.js +3 -2
  55. package/dist/TimePicker.js.map +1 -1
  56. package/dist/TimePickerInput.js +8 -6
  57. package/dist/TimePickerInput.js.map +1 -1
  58. package/dist/Toastr.js +3 -1653
  59. package/dist/Toastr.js.map +1 -1
  60. package/dist/Tooltip.js +2 -1
  61. package/dist/Tooltip.js.map +1 -1
  62. package/dist/Tree.js +1 -1
  63. package/dist/TreeSelect.js +3 -2
  64. package/dist/TreeSelect.js.map +1 -1
  65. package/dist/cjs/Accordion.js +3 -309
  66. package/dist/cjs/Accordion.js.map +1 -1
  67. package/dist/cjs/ActionDropdown.js +4 -3
  68. package/dist/cjs/ActionDropdown.js.map +1 -1
  69. package/dist/cjs/Alert.js +5 -4
  70. package/dist/cjs/Alert.js.map +1 -1
  71. package/dist/cjs/Avatar.js +10 -1128
  72. package/dist/cjs/Avatar.js.map +1 -1
  73. package/dist/cjs/Button.js +6 -5
  74. package/dist/cjs/Button.js.map +1 -1
  75. package/dist/cjs/Checkbox.js +3 -2
  76. package/dist/cjs/Checkbox.js.map +1 -1
  77. package/dist/cjs/ColorPicker.js +7 -7
  78. package/dist/cjs/ColorPicker.js.map +1 -1
  79. package/dist/cjs/DatePicker.js +3 -2
  80. package/dist/cjs/DatePicker.js.map +1 -1
  81. package/dist/cjs/DateTimePicker.js +7 -5
  82. package/dist/cjs/DateTimePicker.js.map +1 -1
  83. package/dist/cjs/Dropdown.js +4 -3
  84. package/dist/cjs/Dropdown.js.map +1 -1
  85. package/dist/cjs/Input.js +3 -2
  86. package/dist/cjs/Input.js.map +1 -1
  87. package/dist/cjs/Kbd.js +2 -1
  88. package/dist/cjs/Kbd.js.map +1 -1
  89. package/dist/cjs/Label.js +2 -1
  90. package/dist/cjs/Label.js.map +1 -1
  91. package/dist/cjs/Modal.js +5 -4
  92. package/dist/cjs/Modal.js.map +1 -1
  93. package/dist/cjs/MultiEmailInput.js +15 -12
  94. package/dist/cjs/MultiEmailInput.js.map +1 -1
  95. package/dist/cjs/NoData.js +3 -2
  96. package/dist/cjs/NoData.js.map +1 -1
  97. package/dist/cjs/Pagination.js +2 -2
  98. package/dist/cjs/Pane.js +5 -4
  99. package/dist/cjs/Pane.js.map +1 -1
  100. package/dist/cjs/Popover.js +2 -1
  101. package/dist/cjs/Popover.js.map +1 -1
  102. package/dist/cjs/ProgressBar.js +2 -2
  103. package/dist/cjs/ProgressBar.js.map +1 -1
  104. package/dist/cjs/Radio.js +3 -2
  105. package/dist/cjs/Radio.js.map +1 -1
  106. package/dist/cjs/Select.js +26 -192
  107. package/dist/cjs/Select.js.map +1 -1
  108. package/dist/cjs/Sidebar.js +4 -2
  109. package/dist/cjs/Sidebar.js.map +1 -1
  110. package/dist/cjs/Slider.js +3 -2
  111. package/dist/cjs/Slider.js.map +1 -1
  112. package/dist/cjs/Switch.js +3 -2
  113. package/dist/cjs/Switch.js.map +1 -1
  114. package/dist/cjs/Table.js +430 -4565
  115. package/dist/cjs/Table.js.map +1 -1
  116. package/dist/cjs/Textarea.js +3 -2
  117. package/dist/cjs/Textarea.js.map +1 -1
  118. package/dist/cjs/TimePicker.js +3 -2
  119. package/dist/cjs/TimePicker.js.map +1 -1
  120. package/dist/cjs/TimePickerInput.js +8 -6
  121. package/dist/cjs/TimePickerInput.js.map +1 -1
  122. package/dist/cjs/Toastr.js +6 -1656
  123. package/dist/cjs/Toastr.js.map +1 -1
  124. package/dist/cjs/Tooltip.js +2 -1
  125. package/dist/cjs/Tooltip.js.map +1 -1
  126. package/dist/cjs/Tree.js +1 -1
  127. package/dist/cjs/TreeSelect.js +3 -2
  128. package/dist/cjs/TreeSelect.js.map +1 -1
  129. package/dist/cjs/formik/ActionBlock.js +3 -2
  130. package/dist/cjs/formik/ActionBlock.js.map +1 -1
  131. package/dist/cjs/formik/BlockNavigation.js +5 -4
  132. package/dist/cjs/formik/BlockNavigation.js.map +1 -1
  133. package/dist/cjs/formik/Button.js +3 -2
  134. package/dist/cjs/formik/Button.js.map +1 -1
  135. package/dist/cjs/formik/Checkbox.js +3 -2
  136. package/dist/cjs/formik/Checkbox.js.map +1 -1
  137. package/dist/cjs/formik/Input.js +3 -2
  138. package/dist/cjs/formik/Input.js.map +1 -1
  139. package/dist/cjs/formik/MultiEmailInput.js +6 -4
  140. package/dist/cjs/formik/MultiEmailInput.js.map +1 -1
  141. package/dist/cjs/formik/Radio.js +3 -2
  142. package/dist/cjs/formik/Radio.js.map +1 -1
  143. package/dist/cjs/formik/Select.js +8 -4
  144. package/dist/cjs/formik/Select.js.map +1 -1
  145. package/dist/cjs/formik/Slider.js +3 -2
  146. package/dist/cjs/formik/Slider.js.map +1 -1
  147. package/dist/cjs/formik/Switch.js +3 -2
  148. package/dist/cjs/formik/Switch.js.map +1 -1
  149. package/dist/cjs/formik/Textarea.js +3 -2
  150. package/dist/cjs/formik/Textarea.js.map +1 -1
  151. package/dist/cjs/formik/TreeSelect.js +3 -2
  152. package/dist/cjs/formik/TreeSelect.js.map +1 -1
  153. package/dist/cjs/formik/index.js +9 -5
  154. package/dist/cjs/formik/index.js.map +1 -1
  155. package/dist/cjs/{index-16ef19ed.js → index-6e09c7bc.js} +1 -23
  156. package/dist/cjs/index-6e09c7bc.js.map +1 -0
  157. package/dist/cjs/index-773961dd.js +453 -0
  158. package/dist/cjs/index-773961dd.js.map +1 -0
  159. package/dist/cjs/index-becc6543.js +262 -0
  160. package/dist/cjs/index-becc6543.js.map +1 -0
  161. package/dist/cjs/index.js +18 -7
  162. package/dist/cjs/index.js.map +1 -1
  163. package/dist/cjs/layouts.js +4 -2
  164. package/dist/cjs/layouts.js.map +1 -1
  165. package/dist/cjs/{useOverlayManager-53380ba5.js → useOverlayManager-359ed795.js} +2 -2
  166. package/dist/cjs/{useOverlayManager-53380ba5.js.map → useOverlayManager-359ed795.js.map} +1 -1
  167. package/dist/cjs/{useQueryParams-3ddcf459.js → useQueryParams-14f054b3.js} +2 -2
  168. package/dist/cjs/{useQueryParams-3ddcf459.js.map → useQueryParams-14f054b3.js.map} +1 -1
  169. package/dist/formik/ActionBlock.js +3 -2
  170. package/dist/formik/ActionBlock.js.map +1 -1
  171. package/dist/formik/BlockNavigation.js +5 -4
  172. package/dist/formik/BlockNavigation.js.map +1 -1
  173. package/dist/formik/Button.js +3 -2
  174. package/dist/formik/Button.js.map +1 -1
  175. package/dist/formik/Checkbox.js +3 -2
  176. package/dist/formik/Checkbox.js.map +1 -1
  177. package/dist/formik/Input.js +3 -2
  178. package/dist/formik/Input.js.map +1 -1
  179. package/dist/formik/MultiEmailInput.js +6 -4
  180. package/dist/formik/MultiEmailInput.js.map +1 -1
  181. package/dist/formik/Radio.js +3 -2
  182. package/dist/formik/Radio.js.map +1 -1
  183. package/dist/formik/Select.js +8 -4
  184. package/dist/formik/Select.js.map +1 -1
  185. package/dist/formik/Slider.js +3 -2
  186. package/dist/formik/Slider.js.map +1 -1
  187. package/dist/formik/Switch.js +3 -2
  188. package/dist/formik/Switch.js.map +1 -1
  189. package/dist/formik/Textarea.js +3 -2
  190. package/dist/formik/Textarea.js.map +1 -1
  191. package/dist/formik/TreeSelect.js +3 -2
  192. package/dist/formik/TreeSelect.js.map +1 -1
  193. package/dist/formik/index.js +9 -5
  194. package/dist/formik/index.js.map +1 -1
  195. package/dist/index-661b9fd6.js +253 -0
  196. package/dist/index-661b9fd6.js.map +1 -0
  197. package/dist/index-c442518b.js +445 -0
  198. package/dist/index-c442518b.js.map +1 -0
  199. package/dist/{index-26f3deee.js → index-c8d9113c.js} +2 -23
  200. package/dist/index-c8d9113c.js.map +1 -0
  201. package/dist/index.js +18 -7
  202. package/dist/index.js.map +1 -1
  203. package/dist/layouts.js +4 -2
  204. package/dist/layouts.js.map +1 -1
  205. package/dist/{useOverlayManager-e76af01f.js → useOverlayManager-95a474d5.js} +2 -2
  206. package/dist/{useOverlayManager-e76af01f.js.map → useOverlayManager-95a474d5.js.map} +1 -1
  207. package/dist/{useQueryParams-4731dc94.js → useQueryParams-4e7ddcf8.js} +2 -2
  208. package/dist/{useQueryParams-4731dc94.js.map → useQueryParams-4e7ddcf8.js.map} +1 -1
  209. package/package.json +13 -2
  210. package/dist/cjs/index-0e68cfff.js +0 -3934
  211. package/dist/cjs/index-0e68cfff.js.map +0 -1
  212. package/dist/cjs/index-16ef19ed.js.map +0 -1
  213. package/dist/cjs/index-e722fedf.js +0 -3844
  214. package/dist/cjs/index-e722fedf.js.map +0 -1
  215. package/dist/cjs/motion-a1906aff.js +0 -8892
  216. package/dist/cjs/motion-a1906aff.js.map +0 -1
  217. package/dist/cjs/react-select-creatable.esm-b39742a3.js +0 -6675
  218. package/dist/cjs/react-select-creatable.esm-b39742a3.js.map +0 -1
  219. package/dist/index-2123b5e9.js +0 -3927
  220. package/dist/index-2123b5e9.js.map +0 -1
  221. package/dist/index-26f3deee.js.map +0 -1
  222. package/dist/index-8ff7d9a1.js +0 -3837
  223. package/dist/index-8ff7d9a1.js.map +0 -1
  224. package/dist/motion-087daf52.js +0 -8862
  225. package/dist/motion-087daf52.js.map +0 -1
  226. package/dist/react-select-creatable.esm-93affeca.js +0 -6644
  227. package/dist/react-select-creatable.esm-93affeca.js.map +0 -1
@@ -1,3927 +0,0 @@
1
- import { _ as _extends } from './extends-093996c9.js';
2
- import { _ as _slicedToArray } from './slicedToArray-45fa766e.js';
3
- import { _ as _objectWithoutProperties } from './objectWithoutProperties-a0edb288.js';
4
- import React__default, { forwardRef as forwardRef$1, cloneElement, useState, useLayoutEffect, useEffect, useRef } from 'react';
5
- import { createPortal } from 'react-dom';
6
-
7
- var top = 'top';
8
- var bottom = 'bottom';
9
- var right = 'right';
10
- var left = 'left';
11
- var auto = 'auto';
12
- var basePlacements = [top, bottom, right, left];
13
- var start = 'start';
14
- var end = 'end';
15
- var clippingParents = 'clippingParents';
16
- var viewport = 'viewport';
17
- var popper = 'popper';
18
- var reference = 'reference';
19
- var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
20
- return acc.concat([placement + "-" + start, placement + "-" + end]);
21
- }, []);
22
- var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
23
- return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
24
- }, []); // modifiers that need to read the DOM
25
-
26
- var beforeRead = 'beforeRead';
27
- var read = 'read';
28
- var afterRead = 'afterRead'; // pure-logic modifiers
29
-
30
- var beforeMain = 'beforeMain';
31
- var main = 'main';
32
- var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
33
-
34
- var beforeWrite = 'beforeWrite';
35
- var write = 'write';
36
- var afterWrite = 'afterWrite';
37
- var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
38
-
39
- function getNodeName(element) {
40
- return element ? (element.nodeName || '').toLowerCase() : null;
41
- }
42
-
43
- function getWindow(node) {
44
- if (node == null) {
45
- return window;
46
- }
47
-
48
- if (node.toString() !== '[object Window]') {
49
- var ownerDocument = node.ownerDocument;
50
- return ownerDocument ? ownerDocument.defaultView || window : window;
51
- }
52
-
53
- return node;
54
- }
55
-
56
- function isElement$1(node) {
57
- var OwnElement = getWindow(node).Element;
58
- return node instanceof OwnElement || node instanceof Element;
59
- }
60
-
61
- function isHTMLElement(node) {
62
- var OwnElement = getWindow(node).HTMLElement;
63
- return node instanceof OwnElement || node instanceof HTMLElement;
64
- }
65
-
66
- function isShadowRoot(node) {
67
- // IE 11 has no ShadowRoot
68
- if (typeof ShadowRoot === 'undefined') {
69
- return false;
70
- }
71
-
72
- var OwnElement = getWindow(node).ShadowRoot;
73
- return node instanceof OwnElement || node instanceof ShadowRoot;
74
- }
75
-
76
- // and applies them to the HTMLElements such as popper and arrow
77
-
78
- function applyStyles(_ref) {
79
- var state = _ref.state;
80
- Object.keys(state.elements).forEach(function (name) {
81
- var style = state.styles[name] || {};
82
- var attributes = state.attributes[name] || {};
83
- var element = state.elements[name]; // arrow is optional + virtual elements
84
-
85
- if (!isHTMLElement(element) || !getNodeName(element)) {
86
- return;
87
- } // Flow doesn't support to extend this property, but it's the most
88
- // effective way to apply styles to an HTMLElement
89
- // $FlowFixMe[cannot-write]
90
-
91
-
92
- Object.assign(element.style, style);
93
- Object.keys(attributes).forEach(function (name) {
94
- var value = attributes[name];
95
-
96
- if (value === false) {
97
- element.removeAttribute(name);
98
- } else {
99
- element.setAttribute(name, value === true ? '' : value);
100
- }
101
- });
102
- });
103
- }
104
-
105
- function effect$2(_ref2) {
106
- var state = _ref2.state;
107
- var initialStyles = {
108
- popper: {
109
- position: state.options.strategy,
110
- left: '0',
111
- top: '0',
112
- margin: '0'
113
- },
114
- arrow: {
115
- position: 'absolute'
116
- },
117
- reference: {}
118
- };
119
- Object.assign(state.elements.popper.style, initialStyles.popper);
120
- state.styles = initialStyles;
121
-
122
- if (state.elements.arrow) {
123
- Object.assign(state.elements.arrow.style, initialStyles.arrow);
124
- }
125
-
126
- return function () {
127
- Object.keys(state.elements).forEach(function (name) {
128
- var element = state.elements[name];
129
- var attributes = state.attributes[name] || {};
130
- var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
131
-
132
- var style = styleProperties.reduce(function (style, property) {
133
- style[property] = '';
134
- return style;
135
- }, {}); // arrow is optional + virtual elements
136
-
137
- if (!isHTMLElement(element) || !getNodeName(element)) {
138
- return;
139
- }
140
-
141
- Object.assign(element.style, style);
142
- Object.keys(attributes).forEach(function (attribute) {
143
- element.removeAttribute(attribute);
144
- });
145
- });
146
- };
147
- } // eslint-disable-next-line import/no-unused-modules
148
-
149
-
150
- var applyStyles$1 = {
151
- name: 'applyStyles',
152
- enabled: true,
153
- phase: 'write',
154
- fn: applyStyles,
155
- effect: effect$2,
156
- requires: ['computeStyles']
157
- };
158
-
159
- function getBasePlacement$1(placement) {
160
- return placement.split('-')[0];
161
- }
162
-
163
- var max = Math.max;
164
- var min = Math.min;
165
- var round = Math.round;
166
-
167
- function getUAString() {
168
- var uaData = navigator.userAgentData;
169
-
170
- if (uaData != null && uaData.brands) {
171
- return uaData.brands.map(function (item) {
172
- return item.brand + "/" + item.version;
173
- }).join(' ');
174
- }
175
-
176
- return navigator.userAgent;
177
- }
178
-
179
- function isLayoutViewport() {
180
- return !/^((?!chrome|android).)*safari/i.test(getUAString());
181
- }
182
-
183
- function getBoundingClientRect(element, includeScale, isFixedStrategy) {
184
- if (includeScale === void 0) {
185
- includeScale = false;
186
- }
187
-
188
- if (isFixedStrategy === void 0) {
189
- isFixedStrategy = false;
190
- }
191
-
192
- var clientRect = element.getBoundingClientRect();
193
- var scaleX = 1;
194
- var scaleY = 1;
195
-
196
- if (includeScale && isHTMLElement(element)) {
197
- scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
198
- scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
199
- }
200
-
201
- var _ref = isElement$1(element) ? getWindow(element) : window,
202
- visualViewport = _ref.visualViewport;
203
-
204
- var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
205
- var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
206
- var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
207
- var width = clientRect.width / scaleX;
208
- var height = clientRect.height / scaleY;
209
- return {
210
- width: width,
211
- height: height,
212
- top: y,
213
- right: x + width,
214
- bottom: y + height,
215
- left: x,
216
- x: x,
217
- y: y
218
- };
219
- }
220
-
221
- // means it doesn't take into account transforms.
222
-
223
- function getLayoutRect(element) {
224
- var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
225
- // Fixes https://github.com/popperjs/popper-core/issues/1223
226
-
227
- var width = element.offsetWidth;
228
- var height = element.offsetHeight;
229
-
230
- if (Math.abs(clientRect.width - width) <= 1) {
231
- width = clientRect.width;
232
- }
233
-
234
- if (Math.abs(clientRect.height - height) <= 1) {
235
- height = clientRect.height;
236
- }
237
-
238
- return {
239
- x: element.offsetLeft,
240
- y: element.offsetTop,
241
- width: width,
242
- height: height
243
- };
244
- }
245
-
246
- function contains(parent, child) {
247
- var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
248
-
249
- if (parent.contains(child)) {
250
- return true;
251
- } // then fallback to custom implementation with Shadow DOM support
252
- else if (rootNode && isShadowRoot(rootNode)) {
253
- var next = child;
254
-
255
- do {
256
- if (next && parent.isSameNode(next)) {
257
- return true;
258
- } // $FlowFixMe[prop-missing]: need a better way to handle this...
259
-
260
-
261
- next = next.parentNode || next.host;
262
- } while (next);
263
- } // Give up, the result is false
264
-
265
-
266
- return false;
267
- }
268
-
269
- function getComputedStyle(element) {
270
- return getWindow(element).getComputedStyle(element);
271
- }
272
-
273
- function isTableElement(element) {
274
- return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
275
- }
276
-
277
- function getDocumentElement(element) {
278
- // $FlowFixMe[incompatible-return]: assume body is always available
279
- return ((isElement$1(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
280
- element.document) || window.document).documentElement;
281
- }
282
-
283
- function getParentNode(element) {
284
- if (getNodeName(element) === 'html') {
285
- return element;
286
- }
287
-
288
- return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
289
- // $FlowFixMe[incompatible-return]
290
- // $FlowFixMe[prop-missing]
291
- element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
292
- element.parentNode || ( // DOM Element detected
293
- isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
294
- // $FlowFixMe[incompatible-call]: HTMLElement is a Node
295
- getDocumentElement(element) // fallback
296
-
297
- );
298
- }
299
-
300
- function getTrueOffsetParent(element) {
301
- if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
302
- getComputedStyle(element).position === 'fixed') {
303
- return null;
304
- }
305
-
306
- return element.offsetParent;
307
- } // `.offsetParent` reports `null` for fixed elements, while absolute elements
308
- // return the containing block
309
-
310
-
311
- function getContainingBlock(element) {
312
- var isFirefox = /firefox/i.test(getUAString());
313
- var isIE = /Trident/i.test(getUAString());
314
-
315
- if (isIE && isHTMLElement(element)) {
316
- // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
317
- var elementCss = getComputedStyle(element);
318
-
319
- if (elementCss.position === 'fixed') {
320
- return null;
321
- }
322
- }
323
-
324
- var currentNode = getParentNode(element);
325
-
326
- if (isShadowRoot(currentNode)) {
327
- currentNode = currentNode.host;
328
- }
329
-
330
- while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
331
- var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
332
- // create a containing block.
333
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
334
-
335
- if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
336
- return currentNode;
337
- } else {
338
- currentNode = currentNode.parentNode;
339
- }
340
- }
341
-
342
- return null;
343
- } // Gets the closest ancestor positioned element. Handles some edge cases,
344
- // such as table ancestors and cross browser bugs.
345
-
346
-
347
- function getOffsetParent(element) {
348
- var window = getWindow(element);
349
- var offsetParent = getTrueOffsetParent(element);
350
-
351
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
352
- offsetParent = getTrueOffsetParent(offsetParent);
353
- }
354
-
355
- if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
356
- return window;
357
- }
358
-
359
- return offsetParent || getContainingBlock(element) || window;
360
- }
361
-
362
- function getMainAxisFromPlacement(placement) {
363
- return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
364
- }
365
-
366
- function within(min$1, value, max$1) {
367
- return max(min$1, min(value, max$1));
368
- }
369
- function withinMaxClamp(min, value, max) {
370
- var v = within(min, value, max);
371
- return v > max ? max : v;
372
- }
373
-
374
- function getFreshSideObject() {
375
- return {
376
- top: 0,
377
- right: 0,
378
- bottom: 0,
379
- left: 0
380
- };
381
- }
382
-
383
- function mergePaddingObject(paddingObject) {
384
- return Object.assign({}, getFreshSideObject(), paddingObject);
385
- }
386
-
387
- function expandToHashMap(value, keys) {
388
- return keys.reduce(function (hashMap, key) {
389
- hashMap[key] = value;
390
- return hashMap;
391
- }, {});
392
- }
393
-
394
- var toPaddingObject = function toPaddingObject(padding, state) {
395
- padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
396
- placement: state.placement
397
- })) : padding;
398
- return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
399
- };
400
-
401
- function arrow(_ref) {
402
- var _state$modifiersData$;
403
-
404
- var state = _ref.state,
405
- name = _ref.name,
406
- options = _ref.options;
407
- var arrowElement = state.elements.arrow;
408
- var popperOffsets = state.modifiersData.popperOffsets;
409
- var basePlacement = getBasePlacement$1(state.placement);
410
- var axis = getMainAxisFromPlacement(basePlacement);
411
- var isVertical = [left, right].indexOf(basePlacement) >= 0;
412
- var len = isVertical ? 'height' : 'width';
413
-
414
- if (!arrowElement || !popperOffsets) {
415
- return;
416
- }
417
-
418
- var paddingObject = toPaddingObject(options.padding, state);
419
- var arrowRect = getLayoutRect(arrowElement);
420
- var minProp = axis === 'y' ? top : left;
421
- var maxProp = axis === 'y' ? bottom : right;
422
- var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
423
- var startDiff = popperOffsets[axis] - state.rects.reference[axis];
424
- var arrowOffsetParent = getOffsetParent(arrowElement);
425
- var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
426
- var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
427
- // outside of the popper bounds
428
-
429
- var min = paddingObject[minProp];
430
- var max = clientSize - arrowRect[len] - paddingObject[maxProp];
431
- var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
432
- var offset = within(min, center, max); // Prevents breaking syntax highlighting...
433
-
434
- var axisProp = axis;
435
- state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
436
- }
437
-
438
- function effect$1(_ref2) {
439
- var state = _ref2.state,
440
- options = _ref2.options;
441
- var _options$element = options.element,
442
- arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
443
-
444
- if (arrowElement == null) {
445
- return;
446
- } // CSS selector
447
-
448
-
449
- if (typeof arrowElement === 'string') {
450
- arrowElement = state.elements.popper.querySelector(arrowElement);
451
-
452
- if (!arrowElement) {
453
- return;
454
- }
455
- }
456
-
457
- if (!contains(state.elements.popper, arrowElement)) {
458
-
459
- return;
460
- }
461
-
462
- state.elements.arrow = arrowElement;
463
- } // eslint-disable-next-line import/no-unused-modules
464
-
465
-
466
- var arrow$1 = {
467
- name: 'arrow',
468
- enabled: true,
469
- phase: 'main',
470
- fn: arrow,
471
- effect: effect$1,
472
- requires: ['popperOffsets'],
473
- requiresIfExists: ['preventOverflow']
474
- };
475
-
476
- function getVariation(placement) {
477
- return placement.split('-')[1];
478
- }
479
-
480
- var unsetSides = {
481
- top: 'auto',
482
- right: 'auto',
483
- bottom: 'auto',
484
- left: 'auto'
485
- }; // Round the offsets to the nearest suitable subpixel based on the DPR.
486
- // Zooming can change the DPR, but it seems to report a value that will
487
- // cleanly divide the values into the appropriate subpixels.
488
-
489
- function roundOffsetsByDPR(_ref) {
490
- var x = _ref.x,
491
- y = _ref.y;
492
- var win = window;
493
- var dpr = win.devicePixelRatio || 1;
494
- return {
495
- x: round(x * dpr) / dpr || 0,
496
- y: round(y * dpr) / dpr || 0
497
- };
498
- }
499
-
500
- function mapToStyles(_ref2) {
501
- var _Object$assign2;
502
-
503
- var popper = _ref2.popper,
504
- popperRect = _ref2.popperRect,
505
- placement = _ref2.placement,
506
- variation = _ref2.variation,
507
- offsets = _ref2.offsets,
508
- position = _ref2.position,
509
- gpuAcceleration = _ref2.gpuAcceleration,
510
- adaptive = _ref2.adaptive,
511
- roundOffsets = _ref2.roundOffsets,
512
- isFixed = _ref2.isFixed;
513
- var _offsets$x = offsets.x,
514
- x = _offsets$x === void 0 ? 0 : _offsets$x,
515
- _offsets$y = offsets.y,
516
- y = _offsets$y === void 0 ? 0 : _offsets$y;
517
-
518
- var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
519
- x: x,
520
- y: y
521
- }) : {
522
- x: x,
523
- y: y
524
- };
525
-
526
- x = _ref3.x;
527
- y = _ref3.y;
528
- var hasX = offsets.hasOwnProperty('x');
529
- var hasY = offsets.hasOwnProperty('y');
530
- var sideX = left;
531
- var sideY = top;
532
- var win = window;
533
-
534
- if (adaptive) {
535
- var offsetParent = getOffsetParent(popper);
536
- var heightProp = 'clientHeight';
537
- var widthProp = 'clientWidth';
538
-
539
- if (offsetParent === getWindow(popper)) {
540
- offsetParent = getDocumentElement(popper);
541
-
542
- if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
543
- heightProp = 'scrollHeight';
544
- widthProp = 'scrollWidth';
545
- }
546
- } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
547
-
548
-
549
- offsetParent = offsetParent;
550
-
551
- if (placement === top || (placement === left || placement === right) && variation === end) {
552
- sideY = bottom;
553
- var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
554
- offsetParent[heightProp];
555
- y -= offsetY - popperRect.height;
556
- y *= gpuAcceleration ? 1 : -1;
557
- }
558
-
559
- if (placement === left || (placement === top || placement === bottom) && variation === end) {
560
- sideX = right;
561
- var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
562
- offsetParent[widthProp];
563
- x -= offsetX - popperRect.width;
564
- x *= gpuAcceleration ? 1 : -1;
565
- }
566
- }
567
-
568
- var commonStyles = Object.assign({
569
- position: position
570
- }, adaptive && unsetSides);
571
-
572
- var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
573
- x: x,
574
- y: y
575
- }) : {
576
- x: x,
577
- y: y
578
- };
579
-
580
- x = _ref4.x;
581
- y = _ref4.y;
582
-
583
- if (gpuAcceleration) {
584
- var _Object$assign;
585
-
586
- return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
587
- }
588
-
589
- return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
590
- }
591
-
592
- function computeStyles(_ref5) {
593
- var state = _ref5.state,
594
- options = _ref5.options;
595
- var _options$gpuAccelerat = options.gpuAcceleration,
596
- gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
597
- _options$adaptive = options.adaptive,
598
- adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
599
- _options$roundOffsets = options.roundOffsets,
600
- roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
601
-
602
- var commonStyles = {
603
- placement: getBasePlacement$1(state.placement),
604
- variation: getVariation(state.placement),
605
- popper: state.elements.popper,
606
- popperRect: state.rects.popper,
607
- gpuAcceleration: gpuAcceleration,
608
- isFixed: state.options.strategy === 'fixed'
609
- };
610
-
611
- if (state.modifiersData.popperOffsets != null) {
612
- state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
613
- offsets: state.modifiersData.popperOffsets,
614
- position: state.options.strategy,
615
- adaptive: adaptive,
616
- roundOffsets: roundOffsets
617
- })));
618
- }
619
-
620
- if (state.modifiersData.arrow != null) {
621
- state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
622
- offsets: state.modifiersData.arrow,
623
- position: 'absolute',
624
- adaptive: false,
625
- roundOffsets: roundOffsets
626
- })));
627
- }
628
-
629
- state.attributes.popper = Object.assign({}, state.attributes.popper, {
630
- 'data-popper-placement': state.placement
631
- });
632
- } // eslint-disable-next-line import/no-unused-modules
633
-
634
-
635
- var computeStyles$1 = {
636
- name: 'computeStyles',
637
- enabled: true,
638
- phase: 'beforeWrite',
639
- fn: computeStyles,
640
- data: {}
641
- };
642
-
643
- var passive = {
644
- passive: true
645
- };
646
-
647
- function effect(_ref) {
648
- var state = _ref.state,
649
- instance = _ref.instance,
650
- options = _ref.options;
651
- var _options$scroll = options.scroll,
652
- scroll = _options$scroll === void 0 ? true : _options$scroll,
653
- _options$resize = options.resize,
654
- resize = _options$resize === void 0 ? true : _options$resize;
655
- var window = getWindow(state.elements.popper);
656
- var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
657
-
658
- if (scroll) {
659
- scrollParents.forEach(function (scrollParent) {
660
- scrollParent.addEventListener('scroll', instance.update, passive);
661
- });
662
- }
663
-
664
- if (resize) {
665
- window.addEventListener('resize', instance.update, passive);
666
- }
667
-
668
- return function () {
669
- if (scroll) {
670
- scrollParents.forEach(function (scrollParent) {
671
- scrollParent.removeEventListener('scroll', instance.update, passive);
672
- });
673
- }
674
-
675
- if (resize) {
676
- window.removeEventListener('resize', instance.update, passive);
677
- }
678
- };
679
- } // eslint-disable-next-line import/no-unused-modules
680
-
681
-
682
- var eventListeners = {
683
- name: 'eventListeners',
684
- enabled: true,
685
- phase: 'write',
686
- fn: function fn() {},
687
- effect: effect,
688
- data: {}
689
- };
690
-
691
- var hash$1 = {
692
- left: 'right',
693
- right: 'left',
694
- bottom: 'top',
695
- top: 'bottom'
696
- };
697
- function getOppositePlacement(placement) {
698
- return placement.replace(/left|right|bottom|top/g, function (matched) {
699
- return hash$1[matched];
700
- });
701
- }
702
-
703
- var hash = {
704
- start: 'end',
705
- end: 'start'
706
- };
707
- function getOppositeVariationPlacement(placement) {
708
- return placement.replace(/start|end/g, function (matched) {
709
- return hash[matched];
710
- });
711
- }
712
-
713
- function getWindowScroll(node) {
714
- var win = getWindow(node);
715
- var scrollLeft = win.pageXOffset;
716
- var scrollTop = win.pageYOffset;
717
- return {
718
- scrollLeft: scrollLeft,
719
- scrollTop: scrollTop
720
- };
721
- }
722
-
723
- function getWindowScrollBarX(element) {
724
- // If <html> has a CSS width greater than the viewport, then this will be
725
- // incorrect for RTL.
726
- // Popper 1 is broken in this case and never had a bug report so let's assume
727
- // it's not an issue. I don't think anyone ever specifies width on <html>
728
- // anyway.
729
- // Browsers where the left scrollbar doesn't cause an issue report `0` for
730
- // this (e.g. Edge 2019, IE11, Safari)
731
- return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
732
- }
733
-
734
- function getViewportRect(element, strategy) {
735
- var win = getWindow(element);
736
- var html = getDocumentElement(element);
737
- var visualViewport = win.visualViewport;
738
- var width = html.clientWidth;
739
- var height = html.clientHeight;
740
- var x = 0;
741
- var y = 0;
742
-
743
- if (visualViewport) {
744
- width = visualViewport.width;
745
- height = visualViewport.height;
746
- var layoutViewport = isLayoutViewport();
747
-
748
- if (layoutViewport || !layoutViewport && strategy === 'fixed') {
749
- x = visualViewport.offsetLeft;
750
- y = visualViewport.offsetTop;
751
- }
752
- }
753
-
754
- return {
755
- width: width,
756
- height: height,
757
- x: x + getWindowScrollBarX(element),
758
- y: y
759
- };
760
- }
761
-
762
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable
763
-
764
- function getDocumentRect(element) {
765
- var _element$ownerDocumen;
766
-
767
- var html = getDocumentElement(element);
768
- var winScroll = getWindowScroll(element);
769
- var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
770
- var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
771
- var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
772
- var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
773
- var y = -winScroll.scrollTop;
774
-
775
- if (getComputedStyle(body || html).direction === 'rtl') {
776
- x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
777
- }
778
-
779
- return {
780
- width: width,
781
- height: height,
782
- x: x,
783
- y: y
784
- };
785
- }
786
-
787
- function isScrollParent(element) {
788
- // Firefox wants us to check `-x` and `-y` variations as well
789
- var _getComputedStyle = getComputedStyle(element),
790
- overflow = _getComputedStyle.overflow,
791
- overflowX = _getComputedStyle.overflowX,
792
- overflowY = _getComputedStyle.overflowY;
793
-
794
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
795
- }
796
-
797
- function getScrollParent(node) {
798
- if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
799
- // $FlowFixMe[incompatible-return]: assume body is always available
800
- return node.ownerDocument.body;
801
- }
802
-
803
- if (isHTMLElement(node) && isScrollParent(node)) {
804
- return node;
805
- }
806
-
807
- return getScrollParent(getParentNode(node));
808
- }
809
-
810
- /*
811
- given a DOM element, return the list of all scroll parents, up the list of ancesors
812
- until we get to the top window object. This list is what we attach scroll listeners
813
- to, because if any of these parent elements scroll, we'll need to re-calculate the
814
- reference element's position.
815
- */
816
-
817
- function listScrollParents(element, list) {
818
- var _element$ownerDocumen;
819
-
820
- if (list === void 0) {
821
- list = [];
822
- }
823
-
824
- var scrollParent = getScrollParent(element);
825
- var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
826
- var win = getWindow(scrollParent);
827
- var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
828
- var updatedList = list.concat(target);
829
- return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
830
- updatedList.concat(listScrollParents(getParentNode(target)));
831
- }
832
-
833
- function rectToClientRect(rect) {
834
- return Object.assign({}, rect, {
835
- left: rect.x,
836
- top: rect.y,
837
- right: rect.x + rect.width,
838
- bottom: rect.y + rect.height
839
- });
840
- }
841
-
842
- function getInnerBoundingClientRect(element, strategy) {
843
- var rect = getBoundingClientRect(element, false, strategy === 'fixed');
844
- rect.top = rect.top + element.clientTop;
845
- rect.left = rect.left + element.clientLeft;
846
- rect.bottom = rect.top + element.clientHeight;
847
- rect.right = rect.left + element.clientWidth;
848
- rect.width = element.clientWidth;
849
- rect.height = element.clientHeight;
850
- rect.x = rect.left;
851
- rect.y = rect.top;
852
- return rect;
853
- }
854
-
855
- function getClientRectFromMixedType(element, clippingParent, strategy) {
856
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement$1(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
857
- } // A "clipping parent" is an overflowable container with the characteristic of
858
- // clipping (or hiding) overflowing elements with a position different from
859
- // `initial`
860
-
861
-
862
- function getClippingParents(element) {
863
- var clippingParents = listScrollParents(getParentNode(element));
864
- var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
865
- var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
866
-
867
- if (!isElement$1(clipperElement)) {
868
- return [];
869
- } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
870
-
871
-
872
- return clippingParents.filter(function (clippingParent) {
873
- return isElement$1(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
874
- });
875
- } // Gets the maximum area that the element is visible in due to any number of
876
- // clipping parents
877
-
878
-
879
- function getClippingRect(element, boundary, rootBoundary, strategy) {
880
- var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
881
- var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
882
- var firstClippingParent = clippingParents[0];
883
- var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
884
- var rect = getClientRectFromMixedType(element, clippingParent, strategy);
885
- accRect.top = max(rect.top, accRect.top);
886
- accRect.right = min(rect.right, accRect.right);
887
- accRect.bottom = min(rect.bottom, accRect.bottom);
888
- accRect.left = max(rect.left, accRect.left);
889
- return accRect;
890
- }, getClientRectFromMixedType(element, firstClippingParent, strategy));
891
- clippingRect.width = clippingRect.right - clippingRect.left;
892
- clippingRect.height = clippingRect.bottom - clippingRect.top;
893
- clippingRect.x = clippingRect.left;
894
- clippingRect.y = clippingRect.top;
895
- return clippingRect;
896
- }
897
-
898
- function computeOffsets(_ref) {
899
- var reference = _ref.reference,
900
- element = _ref.element,
901
- placement = _ref.placement;
902
- var basePlacement = placement ? getBasePlacement$1(placement) : null;
903
- var variation = placement ? getVariation(placement) : null;
904
- var commonX = reference.x + reference.width / 2 - element.width / 2;
905
- var commonY = reference.y + reference.height / 2 - element.height / 2;
906
- var offsets;
907
-
908
- switch (basePlacement) {
909
- case top:
910
- offsets = {
911
- x: commonX,
912
- y: reference.y - element.height
913
- };
914
- break;
915
-
916
- case bottom:
917
- offsets = {
918
- x: commonX,
919
- y: reference.y + reference.height
920
- };
921
- break;
922
-
923
- case right:
924
- offsets = {
925
- x: reference.x + reference.width,
926
- y: commonY
927
- };
928
- break;
929
-
930
- case left:
931
- offsets = {
932
- x: reference.x - element.width,
933
- y: commonY
934
- };
935
- break;
936
-
937
- default:
938
- offsets = {
939
- x: reference.x,
940
- y: reference.y
941
- };
942
- }
943
-
944
- var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
945
-
946
- if (mainAxis != null) {
947
- var len = mainAxis === 'y' ? 'height' : 'width';
948
-
949
- switch (variation) {
950
- case start:
951
- offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
952
- break;
953
-
954
- case end:
955
- offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
956
- break;
957
- }
958
- }
959
-
960
- return offsets;
961
- }
962
-
963
- function detectOverflow(state, options) {
964
- if (options === void 0) {
965
- options = {};
966
- }
967
-
968
- var _options = options,
969
- _options$placement = _options.placement,
970
- placement = _options$placement === void 0 ? state.placement : _options$placement,
971
- _options$strategy = _options.strategy,
972
- strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
973
- _options$boundary = _options.boundary,
974
- boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
975
- _options$rootBoundary = _options.rootBoundary,
976
- rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
977
- _options$elementConte = _options.elementContext,
978
- elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
979
- _options$altBoundary = _options.altBoundary,
980
- altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
981
- _options$padding = _options.padding,
982
- padding = _options$padding === void 0 ? 0 : _options$padding;
983
- var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
984
- var altContext = elementContext === popper ? reference : popper;
985
- var popperRect = state.rects.popper;
986
- var element = state.elements[altBoundary ? altContext : elementContext];
987
- var clippingClientRect = getClippingRect(isElement$1(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
988
- var referenceClientRect = getBoundingClientRect(state.elements.reference);
989
- var popperOffsets = computeOffsets({
990
- reference: referenceClientRect,
991
- element: popperRect,
992
- strategy: 'absolute',
993
- placement: placement
994
- });
995
- var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
996
- var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
997
- // 0 or negative = within the clipping rect
998
-
999
- var overflowOffsets = {
1000
- top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
1001
- bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
1002
- left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
1003
- right: elementClientRect.right - clippingClientRect.right + paddingObject.right
1004
- };
1005
- var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
1006
-
1007
- if (elementContext === popper && offsetData) {
1008
- var offset = offsetData[placement];
1009
- Object.keys(overflowOffsets).forEach(function (key) {
1010
- var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
1011
- var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
1012
- overflowOffsets[key] += offset[axis] * multiply;
1013
- });
1014
- }
1015
-
1016
- return overflowOffsets;
1017
- }
1018
-
1019
- function computeAutoPlacement(state, options) {
1020
- if (options === void 0) {
1021
- options = {};
1022
- }
1023
-
1024
- var _options = options,
1025
- placement = _options.placement,
1026
- boundary = _options.boundary,
1027
- rootBoundary = _options.rootBoundary,
1028
- padding = _options.padding,
1029
- flipVariations = _options.flipVariations,
1030
- _options$allowedAutoP = _options.allowedAutoPlacements,
1031
- allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
1032
- var variation = getVariation(placement);
1033
- var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
1034
- return getVariation(placement) === variation;
1035
- }) : basePlacements;
1036
- var allowedPlacements = placements$1.filter(function (placement) {
1037
- return allowedAutoPlacements.indexOf(placement) >= 0;
1038
- });
1039
-
1040
- if (allowedPlacements.length === 0) {
1041
- allowedPlacements = placements$1;
1042
- } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
1043
-
1044
-
1045
- var overflows = allowedPlacements.reduce(function (acc, placement) {
1046
- acc[placement] = detectOverflow(state, {
1047
- placement: placement,
1048
- boundary: boundary,
1049
- rootBoundary: rootBoundary,
1050
- padding: padding
1051
- })[getBasePlacement$1(placement)];
1052
- return acc;
1053
- }, {});
1054
- return Object.keys(overflows).sort(function (a, b) {
1055
- return overflows[a] - overflows[b];
1056
- });
1057
- }
1058
-
1059
- function getExpandedFallbackPlacements(placement) {
1060
- if (getBasePlacement$1(placement) === auto) {
1061
- return [];
1062
- }
1063
-
1064
- var oppositePlacement = getOppositePlacement(placement);
1065
- return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
1066
- }
1067
-
1068
- function flip(_ref) {
1069
- var state = _ref.state,
1070
- options = _ref.options,
1071
- name = _ref.name;
1072
-
1073
- if (state.modifiersData[name]._skip) {
1074
- return;
1075
- }
1076
-
1077
- var _options$mainAxis = options.mainAxis,
1078
- checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1079
- _options$altAxis = options.altAxis,
1080
- checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
1081
- specifiedFallbackPlacements = options.fallbackPlacements,
1082
- padding = options.padding,
1083
- boundary = options.boundary,
1084
- rootBoundary = options.rootBoundary,
1085
- altBoundary = options.altBoundary,
1086
- _options$flipVariatio = options.flipVariations,
1087
- flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
1088
- allowedAutoPlacements = options.allowedAutoPlacements;
1089
- var preferredPlacement = state.options.placement;
1090
- var basePlacement = getBasePlacement$1(preferredPlacement);
1091
- var isBasePlacement = basePlacement === preferredPlacement;
1092
- var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
1093
- var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
1094
- return acc.concat(getBasePlacement$1(placement) === auto ? computeAutoPlacement(state, {
1095
- placement: placement,
1096
- boundary: boundary,
1097
- rootBoundary: rootBoundary,
1098
- padding: padding,
1099
- flipVariations: flipVariations,
1100
- allowedAutoPlacements: allowedAutoPlacements
1101
- }) : placement);
1102
- }, []);
1103
- var referenceRect = state.rects.reference;
1104
- var popperRect = state.rects.popper;
1105
- var checksMap = new Map();
1106
- var makeFallbackChecks = true;
1107
- var firstFittingPlacement = placements[0];
1108
-
1109
- for (var i = 0; i < placements.length; i++) {
1110
- var placement = placements[i];
1111
-
1112
- var _basePlacement = getBasePlacement$1(placement);
1113
-
1114
- var isStartVariation = getVariation(placement) === start;
1115
- var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
1116
- var len = isVertical ? 'width' : 'height';
1117
- var overflow = detectOverflow(state, {
1118
- placement: placement,
1119
- boundary: boundary,
1120
- rootBoundary: rootBoundary,
1121
- altBoundary: altBoundary,
1122
- padding: padding
1123
- });
1124
- var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
1125
-
1126
- if (referenceRect[len] > popperRect[len]) {
1127
- mainVariationSide = getOppositePlacement(mainVariationSide);
1128
- }
1129
-
1130
- var altVariationSide = getOppositePlacement(mainVariationSide);
1131
- var checks = [];
1132
-
1133
- if (checkMainAxis) {
1134
- checks.push(overflow[_basePlacement] <= 0);
1135
- }
1136
-
1137
- if (checkAltAxis) {
1138
- checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
1139
- }
1140
-
1141
- if (checks.every(function (check) {
1142
- return check;
1143
- })) {
1144
- firstFittingPlacement = placement;
1145
- makeFallbackChecks = false;
1146
- break;
1147
- }
1148
-
1149
- checksMap.set(placement, checks);
1150
- }
1151
-
1152
- if (makeFallbackChecks) {
1153
- // `2` may be desired in some cases – research later
1154
- var numberOfChecks = flipVariations ? 3 : 1;
1155
-
1156
- var _loop = function _loop(_i) {
1157
- var fittingPlacement = placements.find(function (placement) {
1158
- var checks = checksMap.get(placement);
1159
-
1160
- if (checks) {
1161
- return checks.slice(0, _i).every(function (check) {
1162
- return check;
1163
- });
1164
- }
1165
- });
1166
-
1167
- if (fittingPlacement) {
1168
- firstFittingPlacement = fittingPlacement;
1169
- return "break";
1170
- }
1171
- };
1172
-
1173
- for (var _i = numberOfChecks; _i > 0; _i--) {
1174
- var _ret = _loop(_i);
1175
-
1176
- if (_ret === "break") break;
1177
- }
1178
- }
1179
-
1180
- if (state.placement !== firstFittingPlacement) {
1181
- state.modifiersData[name]._skip = true;
1182
- state.placement = firstFittingPlacement;
1183
- state.reset = true;
1184
- }
1185
- } // eslint-disable-next-line import/no-unused-modules
1186
-
1187
-
1188
- var flip$1 = {
1189
- name: 'flip',
1190
- enabled: true,
1191
- phase: 'main',
1192
- fn: flip,
1193
- requiresIfExists: ['offset'],
1194
- data: {
1195
- _skip: false
1196
- }
1197
- };
1198
-
1199
- function getSideOffsets(overflow, rect, preventedOffsets) {
1200
- if (preventedOffsets === void 0) {
1201
- preventedOffsets = {
1202
- x: 0,
1203
- y: 0
1204
- };
1205
- }
1206
-
1207
- return {
1208
- top: overflow.top - rect.height - preventedOffsets.y,
1209
- right: overflow.right - rect.width + preventedOffsets.x,
1210
- bottom: overflow.bottom - rect.height + preventedOffsets.y,
1211
- left: overflow.left - rect.width - preventedOffsets.x
1212
- };
1213
- }
1214
-
1215
- function isAnySideFullyClipped(overflow) {
1216
- return [top, right, bottom, left].some(function (side) {
1217
- return overflow[side] >= 0;
1218
- });
1219
- }
1220
-
1221
- function hide(_ref) {
1222
- var state = _ref.state,
1223
- name = _ref.name;
1224
- var referenceRect = state.rects.reference;
1225
- var popperRect = state.rects.popper;
1226
- var preventedOffsets = state.modifiersData.preventOverflow;
1227
- var referenceOverflow = detectOverflow(state, {
1228
- elementContext: 'reference'
1229
- });
1230
- var popperAltOverflow = detectOverflow(state, {
1231
- altBoundary: true
1232
- });
1233
- var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
1234
- var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
1235
- var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
1236
- var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
1237
- state.modifiersData[name] = {
1238
- referenceClippingOffsets: referenceClippingOffsets,
1239
- popperEscapeOffsets: popperEscapeOffsets,
1240
- isReferenceHidden: isReferenceHidden,
1241
- hasPopperEscaped: hasPopperEscaped
1242
- };
1243
- state.attributes.popper = Object.assign({}, state.attributes.popper, {
1244
- 'data-popper-reference-hidden': isReferenceHidden,
1245
- 'data-popper-escaped': hasPopperEscaped
1246
- });
1247
- } // eslint-disable-next-line import/no-unused-modules
1248
-
1249
-
1250
- var hide$1 = {
1251
- name: 'hide',
1252
- enabled: true,
1253
- phase: 'main',
1254
- requiresIfExists: ['preventOverflow'],
1255
- fn: hide
1256
- };
1257
-
1258
- function distanceAndSkiddingToXY(placement, rects, offset) {
1259
- var basePlacement = getBasePlacement$1(placement);
1260
- var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
1261
-
1262
- var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
1263
- placement: placement
1264
- })) : offset,
1265
- skidding = _ref[0],
1266
- distance = _ref[1];
1267
-
1268
- skidding = skidding || 0;
1269
- distance = (distance || 0) * invertDistance;
1270
- return [left, right].indexOf(basePlacement) >= 0 ? {
1271
- x: distance,
1272
- y: skidding
1273
- } : {
1274
- x: skidding,
1275
- y: distance
1276
- };
1277
- }
1278
-
1279
- function offset(_ref2) {
1280
- var state = _ref2.state,
1281
- options = _ref2.options,
1282
- name = _ref2.name;
1283
- var _options$offset = options.offset,
1284
- offset = _options$offset === void 0 ? [0, 0] : _options$offset;
1285
- var data = placements.reduce(function (acc, placement) {
1286
- acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
1287
- return acc;
1288
- }, {});
1289
- var _data$state$placement = data[state.placement],
1290
- x = _data$state$placement.x,
1291
- y = _data$state$placement.y;
1292
-
1293
- if (state.modifiersData.popperOffsets != null) {
1294
- state.modifiersData.popperOffsets.x += x;
1295
- state.modifiersData.popperOffsets.y += y;
1296
- }
1297
-
1298
- state.modifiersData[name] = data;
1299
- } // eslint-disable-next-line import/no-unused-modules
1300
-
1301
-
1302
- var offset$1 = {
1303
- name: 'offset',
1304
- enabled: true,
1305
- phase: 'main',
1306
- requires: ['popperOffsets'],
1307
- fn: offset
1308
- };
1309
-
1310
- function popperOffsets(_ref) {
1311
- var state = _ref.state,
1312
- name = _ref.name;
1313
- // Offsets are the actual position the popper needs to have to be
1314
- // properly positioned near its reference element
1315
- // This is the most basic placement, and will be adjusted by
1316
- // the modifiers in the next step
1317
- state.modifiersData[name] = computeOffsets({
1318
- reference: state.rects.reference,
1319
- element: state.rects.popper,
1320
- strategy: 'absolute',
1321
- placement: state.placement
1322
- });
1323
- } // eslint-disable-next-line import/no-unused-modules
1324
-
1325
-
1326
- var popperOffsets$1 = {
1327
- name: 'popperOffsets',
1328
- enabled: true,
1329
- phase: 'read',
1330
- fn: popperOffsets,
1331
- data: {}
1332
- };
1333
-
1334
- function getAltAxis(axis) {
1335
- return axis === 'x' ? 'y' : 'x';
1336
- }
1337
-
1338
- function preventOverflow(_ref) {
1339
- var state = _ref.state,
1340
- options = _ref.options,
1341
- name = _ref.name;
1342
- var _options$mainAxis = options.mainAxis,
1343
- checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1344
- _options$altAxis = options.altAxis,
1345
- checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
1346
- boundary = options.boundary,
1347
- rootBoundary = options.rootBoundary,
1348
- altBoundary = options.altBoundary,
1349
- padding = options.padding,
1350
- _options$tether = options.tether,
1351
- tether = _options$tether === void 0 ? true : _options$tether,
1352
- _options$tetherOffset = options.tetherOffset,
1353
- tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
1354
- var overflow = detectOverflow(state, {
1355
- boundary: boundary,
1356
- rootBoundary: rootBoundary,
1357
- padding: padding,
1358
- altBoundary: altBoundary
1359
- });
1360
- var basePlacement = getBasePlacement$1(state.placement);
1361
- var variation = getVariation(state.placement);
1362
- var isBasePlacement = !variation;
1363
- var mainAxis = getMainAxisFromPlacement(basePlacement);
1364
- var altAxis = getAltAxis(mainAxis);
1365
- var popperOffsets = state.modifiersData.popperOffsets;
1366
- var referenceRect = state.rects.reference;
1367
- var popperRect = state.rects.popper;
1368
- var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
1369
- placement: state.placement
1370
- })) : tetherOffset;
1371
- var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
1372
- mainAxis: tetherOffsetValue,
1373
- altAxis: tetherOffsetValue
1374
- } : Object.assign({
1375
- mainAxis: 0,
1376
- altAxis: 0
1377
- }, tetherOffsetValue);
1378
- var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
1379
- var data = {
1380
- x: 0,
1381
- y: 0
1382
- };
1383
-
1384
- if (!popperOffsets) {
1385
- return;
1386
- }
1387
-
1388
- if (checkMainAxis) {
1389
- var _offsetModifierState$;
1390
-
1391
- var mainSide = mainAxis === 'y' ? top : left;
1392
- var altSide = mainAxis === 'y' ? bottom : right;
1393
- var len = mainAxis === 'y' ? 'height' : 'width';
1394
- var offset = popperOffsets[mainAxis];
1395
- var min$1 = offset + overflow[mainSide];
1396
- var max$1 = offset - overflow[altSide];
1397
- var additive = tether ? -popperRect[len] / 2 : 0;
1398
- var minLen = variation === start ? referenceRect[len] : popperRect[len];
1399
- var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
1400
- // outside the reference bounds
1401
-
1402
- var arrowElement = state.elements.arrow;
1403
- var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
1404
- width: 0,
1405
- height: 0
1406
- };
1407
- var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
1408
- var arrowPaddingMin = arrowPaddingObject[mainSide];
1409
- var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
1410
- // to include its full size in the calculation. If the reference is small
1411
- // and near the edge of a boundary, the popper can overflow even if the
1412
- // reference is not overflowing as well (e.g. virtual elements with no
1413
- // width or height)
1414
-
1415
- var arrowLen = within(0, referenceRect[len], arrowRect[len]);
1416
- var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
1417
- var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
1418
- var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
1419
- var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
1420
- var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
1421
- var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
1422
- var tetherMax = offset + maxOffset - offsetModifierValue;
1423
- var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
1424
- popperOffsets[mainAxis] = preventedOffset;
1425
- data[mainAxis] = preventedOffset - offset;
1426
- }
1427
-
1428
- if (checkAltAxis) {
1429
- var _offsetModifierState$2;
1430
-
1431
- var _mainSide = mainAxis === 'x' ? top : left;
1432
-
1433
- var _altSide = mainAxis === 'x' ? bottom : right;
1434
-
1435
- var _offset = popperOffsets[altAxis];
1436
-
1437
- var _len = altAxis === 'y' ? 'height' : 'width';
1438
-
1439
- var _min = _offset + overflow[_mainSide];
1440
-
1441
- var _max = _offset - overflow[_altSide];
1442
-
1443
- var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
1444
-
1445
- var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
1446
-
1447
- var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
1448
-
1449
- var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
1450
-
1451
- var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
1452
-
1453
- popperOffsets[altAxis] = _preventedOffset;
1454
- data[altAxis] = _preventedOffset - _offset;
1455
- }
1456
-
1457
- state.modifiersData[name] = data;
1458
- } // eslint-disable-next-line import/no-unused-modules
1459
-
1460
-
1461
- var preventOverflow$1 = {
1462
- name: 'preventOverflow',
1463
- enabled: true,
1464
- phase: 'main',
1465
- fn: preventOverflow,
1466
- requiresIfExists: ['offset']
1467
- };
1468
-
1469
- function getHTMLElementScroll(element) {
1470
- return {
1471
- scrollLeft: element.scrollLeft,
1472
- scrollTop: element.scrollTop
1473
- };
1474
- }
1475
-
1476
- function getNodeScroll(node) {
1477
- if (node === getWindow(node) || !isHTMLElement(node)) {
1478
- return getWindowScroll(node);
1479
- } else {
1480
- return getHTMLElementScroll(node);
1481
- }
1482
- }
1483
-
1484
- function isElementScaled(element) {
1485
- var rect = element.getBoundingClientRect();
1486
- var scaleX = round(rect.width) / element.offsetWidth || 1;
1487
- var scaleY = round(rect.height) / element.offsetHeight || 1;
1488
- return scaleX !== 1 || scaleY !== 1;
1489
- } // Returns the composite rect of an element relative to its offsetParent.
1490
- // Composite means it takes into account transforms as well as layout.
1491
-
1492
-
1493
- function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
1494
- if (isFixed === void 0) {
1495
- isFixed = false;
1496
- }
1497
-
1498
- var isOffsetParentAnElement = isHTMLElement(offsetParent);
1499
- var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
1500
- var documentElement = getDocumentElement(offsetParent);
1501
- var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
1502
- var scroll = {
1503
- scrollLeft: 0,
1504
- scrollTop: 0
1505
- };
1506
- var offsets = {
1507
- x: 0,
1508
- y: 0
1509
- };
1510
-
1511
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1512
- if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
1513
- isScrollParent(documentElement)) {
1514
- scroll = getNodeScroll(offsetParent);
1515
- }
1516
-
1517
- if (isHTMLElement(offsetParent)) {
1518
- offsets = getBoundingClientRect(offsetParent, true);
1519
- offsets.x += offsetParent.clientLeft;
1520
- offsets.y += offsetParent.clientTop;
1521
- } else if (documentElement) {
1522
- offsets.x = getWindowScrollBarX(documentElement);
1523
- }
1524
- }
1525
-
1526
- return {
1527
- x: rect.left + scroll.scrollLeft - offsets.x,
1528
- y: rect.top + scroll.scrollTop - offsets.y,
1529
- width: rect.width,
1530
- height: rect.height
1531
- };
1532
- }
1533
-
1534
- function order(modifiers) {
1535
- var map = new Map();
1536
- var visited = new Set();
1537
- var result = [];
1538
- modifiers.forEach(function (modifier) {
1539
- map.set(modifier.name, modifier);
1540
- }); // On visiting object, check for its dependencies and visit them recursively
1541
-
1542
- function sort(modifier) {
1543
- visited.add(modifier.name);
1544
- var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
1545
- requires.forEach(function (dep) {
1546
- if (!visited.has(dep)) {
1547
- var depModifier = map.get(dep);
1548
-
1549
- if (depModifier) {
1550
- sort(depModifier);
1551
- }
1552
- }
1553
- });
1554
- result.push(modifier);
1555
- }
1556
-
1557
- modifiers.forEach(function (modifier) {
1558
- if (!visited.has(modifier.name)) {
1559
- // check for visited object
1560
- sort(modifier);
1561
- }
1562
- });
1563
- return result;
1564
- }
1565
-
1566
- function orderModifiers(modifiers) {
1567
- // order based on dependencies
1568
- var orderedModifiers = order(modifiers); // order based on phase
1569
-
1570
- return modifierPhases.reduce(function (acc, phase) {
1571
- return acc.concat(orderedModifiers.filter(function (modifier) {
1572
- return modifier.phase === phase;
1573
- }));
1574
- }, []);
1575
- }
1576
-
1577
- function debounce$1(fn) {
1578
- var pending;
1579
- return function () {
1580
- if (!pending) {
1581
- pending = new Promise(function (resolve) {
1582
- Promise.resolve().then(function () {
1583
- pending = undefined;
1584
- resolve(fn());
1585
- });
1586
- });
1587
- }
1588
-
1589
- return pending;
1590
- };
1591
- }
1592
-
1593
- function mergeByName(modifiers) {
1594
- var merged = modifiers.reduce(function (merged, current) {
1595
- var existing = merged[current.name];
1596
- merged[current.name] = existing ? Object.assign({}, existing, current, {
1597
- options: Object.assign({}, existing.options, current.options),
1598
- data: Object.assign({}, existing.data, current.data)
1599
- }) : current;
1600
- return merged;
1601
- }, {}); // IE11 does not support Object.values
1602
-
1603
- return Object.keys(merged).map(function (key) {
1604
- return merged[key];
1605
- });
1606
- }
1607
-
1608
- var DEFAULT_OPTIONS = {
1609
- placement: 'bottom',
1610
- modifiers: [],
1611
- strategy: 'absolute'
1612
- };
1613
-
1614
- function areValidElements() {
1615
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1616
- args[_key] = arguments[_key];
1617
- }
1618
-
1619
- return !args.some(function (element) {
1620
- return !(element && typeof element.getBoundingClientRect === 'function');
1621
- });
1622
- }
1623
-
1624
- function popperGenerator(generatorOptions) {
1625
- if (generatorOptions === void 0) {
1626
- generatorOptions = {};
1627
- }
1628
-
1629
- var _generatorOptions = generatorOptions,
1630
- _generatorOptions$def = _generatorOptions.defaultModifiers,
1631
- defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
1632
- _generatorOptions$def2 = _generatorOptions.defaultOptions,
1633
- defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
1634
- return function createPopper(reference, popper, options) {
1635
- if (options === void 0) {
1636
- options = defaultOptions;
1637
- }
1638
-
1639
- var state = {
1640
- placement: 'bottom',
1641
- orderedModifiers: [],
1642
- options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
1643
- modifiersData: {},
1644
- elements: {
1645
- reference: reference,
1646
- popper: popper
1647
- },
1648
- attributes: {},
1649
- styles: {}
1650
- };
1651
- var effectCleanupFns = [];
1652
- var isDestroyed = false;
1653
- var instance = {
1654
- state: state,
1655
- setOptions: function setOptions(setOptionsAction) {
1656
- var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
1657
- cleanupModifierEffects();
1658
- state.options = Object.assign({}, defaultOptions, state.options, options);
1659
- state.scrollParents = {
1660
- reference: isElement$1(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
1661
- popper: listScrollParents(popper)
1662
- }; // Orders the modifiers based on their dependencies and `phase`
1663
- // properties
1664
-
1665
- var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
1666
-
1667
- state.orderedModifiers = orderedModifiers.filter(function (m) {
1668
- return m.enabled;
1669
- }); // Validate the provided modifiers so that the consumer will get warned
1670
-
1671
- runModifierEffects();
1672
- return instance.update();
1673
- },
1674
- // Sync update – it will always be executed, even if not necessary. This
1675
- // is useful for low frequency updates where sync behavior simplifies the
1676
- // logic.
1677
- // For high frequency updates (e.g. `resize` and `scroll` events), always
1678
- // prefer the async Popper#update method
1679
- forceUpdate: function forceUpdate() {
1680
- if (isDestroyed) {
1681
- return;
1682
- }
1683
-
1684
- var _state$elements = state.elements,
1685
- reference = _state$elements.reference,
1686
- popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
1687
- // anymore
1688
-
1689
- if (!areValidElements(reference, popper)) {
1690
-
1691
- return;
1692
- } // Store the reference and popper rects to be read by modifiers
1693
-
1694
-
1695
- state.rects = {
1696
- reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
1697
- popper: getLayoutRect(popper)
1698
- }; // Modifiers have the ability to reset the current update cycle. The
1699
- // most common use case for this is the `flip` modifier changing the
1700
- // placement, which then needs to re-run all the modifiers, because the
1701
- // logic was previously ran for the previous placement and is therefore
1702
- // stale/incorrect
1703
-
1704
- state.reset = false;
1705
- state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
1706
- // is filled with the initial data specified by the modifier. This means
1707
- // it doesn't persist and is fresh on each update.
1708
- // To ensure persistent data, use `${name}#persistent`
1709
-
1710
- state.orderedModifiers.forEach(function (modifier) {
1711
- return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
1712
- });
1713
-
1714
- for (var index = 0; index < state.orderedModifiers.length; index++) {
1715
-
1716
- if (state.reset === true) {
1717
- state.reset = false;
1718
- index = -1;
1719
- continue;
1720
- }
1721
-
1722
- var _state$orderedModifie = state.orderedModifiers[index],
1723
- fn = _state$orderedModifie.fn,
1724
- _state$orderedModifie2 = _state$orderedModifie.options,
1725
- _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
1726
- name = _state$orderedModifie.name;
1727
-
1728
- if (typeof fn === 'function') {
1729
- state = fn({
1730
- state: state,
1731
- options: _options,
1732
- name: name,
1733
- instance: instance
1734
- }) || state;
1735
- }
1736
- }
1737
- },
1738
- // Async and optimistically optimized update – it will not be executed if
1739
- // not necessary (debounced to run at most once-per-tick)
1740
- update: debounce$1(function () {
1741
- return new Promise(function (resolve) {
1742
- instance.forceUpdate();
1743
- resolve(state);
1744
- });
1745
- }),
1746
- destroy: function destroy() {
1747
- cleanupModifierEffects();
1748
- isDestroyed = true;
1749
- }
1750
- };
1751
-
1752
- if (!areValidElements(reference, popper)) {
1753
-
1754
- return instance;
1755
- }
1756
-
1757
- instance.setOptions(options).then(function (state) {
1758
- if (!isDestroyed && options.onFirstUpdate) {
1759
- options.onFirstUpdate(state);
1760
- }
1761
- }); // Modifiers have the ability to execute arbitrary code before the first
1762
- // update cycle runs. They will be executed in the same order as the update
1763
- // cycle. This is useful when a modifier adds some persistent data that
1764
- // other modifiers need to use, but the modifier is run after the dependent
1765
- // one.
1766
-
1767
- function runModifierEffects() {
1768
- state.orderedModifiers.forEach(function (_ref3) {
1769
- var name = _ref3.name,
1770
- _ref3$options = _ref3.options,
1771
- options = _ref3$options === void 0 ? {} : _ref3$options,
1772
- effect = _ref3.effect;
1773
-
1774
- if (typeof effect === 'function') {
1775
- var cleanupFn = effect({
1776
- state: state,
1777
- name: name,
1778
- instance: instance,
1779
- options: options
1780
- });
1781
-
1782
- var noopFn = function noopFn() {};
1783
-
1784
- effectCleanupFns.push(cleanupFn || noopFn);
1785
- }
1786
- });
1787
- }
1788
-
1789
- function cleanupModifierEffects() {
1790
- effectCleanupFns.forEach(function (fn) {
1791
- return fn();
1792
- });
1793
- effectCleanupFns = [];
1794
- }
1795
-
1796
- return instance;
1797
- };
1798
- }
1799
-
1800
- var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
1801
- var createPopper = /*#__PURE__*/popperGenerator({
1802
- defaultModifiers: defaultModifiers
1803
- }); // eslint-disable-next-line import/no-unused-modules
1804
-
1805
- /**!
1806
- * tippy.js v6.3.7
1807
- * (c) 2017-2021 atomiks
1808
- * MIT License
1809
- */
1810
- var BOX_CLASS = "tippy-box";
1811
- var CONTENT_CLASS = "tippy-content";
1812
- var BACKDROP_CLASS = "tippy-backdrop";
1813
- var ARROW_CLASS = "tippy-arrow";
1814
- var SVG_ARROW_CLASS = "tippy-svg-arrow";
1815
- var TOUCH_OPTIONS = {
1816
- passive: true,
1817
- capture: true
1818
- };
1819
- var TIPPY_DEFAULT_APPEND_TO = function TIPPY_DEFAULT_APPEND_TO() {
1820
- return document.body;
1821
- };
1822
- function getValueAtIndexOrReturn(value, index, defaultValue) {
1823
- if (Array.isArray(value)) {
1824
- var v = value[index];
1825
- return v == null ? Array.isArray(defaultValue) ? defaultValue[index] : defaultValue : v;
1826
- }
1827
-
1828
- return value;
1829
- }
1830
- function isType(value, type) {
1831
- var str = {}.toString.call(value);
1832
- return str.indexOf('[object') === 0 && str.indexOf(type + "]") > -1;
1833
- }
1834
- function invokeWithArgsOrReturn(value, args) {
1835
- return typeof value === 'function' ? value.apply(void 0, args) : value;
1836
- }
1837
- function debounce(fn, ms) {
1838
- // Avoid wrapping in `setTimeout` if ms is 0 anyway
1839
- if (ms === 0) {
1840
- return fn;
1841
- }
1842
-
1843
- var timeout;
1844
- return function (arg) {
1845
- clearTimeout(timeout);
1846
- timeout = setTimeout(function () {
1847
- fn(arg);
1848
- }, ms);
1849
- };
1850
- }
1851
- function splitBySpaces(value) {
1852
- return value.split(/\s+/).filter(Boolean);
1853
- }
1854
- function normalizeToArray(value) {
1855
- return [].concat(value);
1856
- }
1857
- function pushIfUnique(arr, value) {
1858
- if (arr.indexOf(value) === -1) {
1859
- arr.push(value);
1860
- }
1861
- }
1862
- function unique(arr) {
1863
- return arr.filter(function (item, index) {
1864
- return arr.indexOf(item) === index;
1865
- });
1866
- }
1867
- function getBasePlacement(placement) {
1868
- return placement.split('-')[0];
1869
- }
1870
- function arrayFrom(value) {
1871
- return [].slice.call(value);
1872
- }
1873
- function removeUndefinedProps(obj) {
1874
- return Object.keys(obj).reduce(function (acc, key) {
1875
- if (obj[key] !== undefined) {
1876
- acc[key] = obj[key];
1877
- }
1878
-
1879
- return acc;
1880
- }, {});
1881
- }
1882
-
1883
- function div() {
1884
- return document.createElement('div');
1885
- }
1886
- function isElement(value) {
1887
- return ['Element', 'Fragment'].some(function (type) {
1888
- return isType(value, type);
1889
- });
1890
- }
1891
- function isNodeList(value) {
1892
- return isType(value, 'NodeList');
1893
- }
1894
- function isMouseEvent(value) {
1895
- return isType(value, 'MouseEvent');
1896
- }
1897
- function isReferenceElement(value) {
1898
- return !!(value && value._tippy && value._tippy.reference === value);
1899
- }
1900
- function getArrayOfElements(value) {
1901
- if (isElement(value)) {
1902
- return [value];
1903
- }
1904
-
1905
- if (isNodeList(value)) {
1906
- return arrayFrom(value);
1907
- }
1908
-
1909
- if (Array.isArray(value)) {
1910
- return value;
1911
- }
1912
-
1913
- return arrayFrom(document.querySelectorAll(value));
1914
- }
1915
- function setTransitionDuration(els, value) {
1916
- els.forEach(function (el) {
1917
- if (el) {
1918
- el.style.transitionDuration = value + "ms";
1919
- }
1920
- });
1921
- }
1922
- function setVisibilityState(els, state) {
1923
- els.forEach(function (el) {
1924
- if (el) {
1925
- el.setAttribute('data-state', state);
1926
- }
1927
- });
1928
- }
1929
- function getOwnerDocument(elementOrElements) {
1930
- var _element$ownerDocumen;
1931
-
1932
- var _normalizeToArray = normalizeToArray(elementOrElements),
1933
- element = _normalizeToArray[0]; // Elements created via a <template> have an ownerDocument with no reference to the body
1934
-
1935
-
1936
- return element != null && (_element$ownerDocumen = element.ownerDocument) != null && _element$ownerDocumen.body ? element.ownerDocument : document;
1937
- }
1938
- function isCursorOutsideInteractiveBorder(popperTreeData, event) {
1939
- var clientX = event.clientX,
1940
- clientY = event.clientY;
1941
- return popperTreeData.every(function (_ref) {
1942
- var popperRect = _ref.popperRect,
1943
- popperState = _ref.popperState,
1944
- props = _ref.props;
1945
- var interactiveBorder = props.interactiveBorder;
1946
- var basePlacement = getBasePlacement(popperState.placement);
1947
- var offsetData = popperState.modifiersData.offset;
1948
-
1949
- if (!offsetData) {
1950
- return true;
1951
- }
1952
-
1953
- var topDistance = basePlacement === 'bottom' ? offsetData.top.y : 0;
1954
- var bottomDistance = basePlacement === 'top' ? offsetData.bottom.y : 0;
1955
- var leftDistance = basePlacement === 'right' ? offsetData.left.x : 0;
1956
- var rightDistance = basePlacement === 'left' ? offsetData.right.x : 0;
1957
- var exceedsTop = popperRect.top - clientY + topDistance > interactiveBorder;
1958
- var exceedsBottom = clientY - popperRect.bottom - bottomDistance > interactiveBorder;
1959
- var exceedsLeft = popperRect.left - clientX + leftDistance > interactiveBorder;
1960
- var exceedsRight = clientX - popperRect.right - rightDistance > interactiveBorder;
1961
- return exceedsTop || exceedsBottom || exceedsLeft || exceedsRight;
1962
- });
1963
- }
1964
- function updateTransitionEndListener(box, action, listener) {
1965
- var method = action + "EventListener"; // some browsers apparently support `transition` (unprefixed) but only fire
1966
- // `webkitTransitionEnd`...
1967
-
1968
- ['transitionend', 'webkitTransitionEnd'].forEach(function (event) {
1969
- box[method](event, listener);
1970
- });
1971
- }
1972
- /**
1973
- * Compared to xxx.contains, this function works for dom structures with shadow
1974
- * dom
1975
- */
1976
-
1977
- function actualContains(parent, child) {
1978
- var target = child;
1979
-
1980
- while (target) {
1981
- var _target$getRootNode;
1982
-
1983
- if (parent.contains(target)) {
1984
- return true;
1985
- }
1986
-
1987
- target = target.getRootNode == null ? void 0 : (_target$getRootNode = target.getRootNode()) == null ? void 0 : _target$getRootNode.host;
1988
- }
1989
-
1990
- return false;
1991
- }
1992
-
1993
- var currentInput = {
1994
- isTouch: false
1995
- };
1996
- var lastMouseMoveTime = 0;
1997
- /**
1998
- * When a `touchstart` event is fired, it's assumed the user is using touch
1999
- * input. We'll bind a `mousemove` event listener to listen for mouse input in
2000
- * the future. This way, the `isTouch` property is fully dynamic and will handle
2001
- * hybrid devices that use a mix of touch + mouse input.
2002
- */
2003
-
2004
- function onDocumentTouchStart() {
2005
- if (currentInput.isTouch) {
2006
- return;
2007
- }
2008
-
2009
- currentInput.isTouch = true;
2010
-
2011
- if (window.performance) {
2012
- document.addEventListener('mousemove', onDocumentMouseMove);
2013
- }
2014
- }
2015
- /**
2016
- * When two `mousemove` event are fired consecutively within 20ms, it's assumed
2017
- * the user is using mouse input again. `mousemove` can fire on touch devices as
2018
- * well, but very rarely that quickly.
2019
- */
2020
-
2021
- function onDocumentMouseMove() {
2022
- var now = performance.now();
2023
-
2024
- if (now - lastMouseMoveTime < 20) {
2025
- currentInput.isTouch = false;
2026
- document.removeEventListener('mousemove', onDocumentMouseMove);
2027
- }
2028
-
2029
- lastMouseMoveTime = now;
2030
- }
2031
- /**
2032
- * When an element is in focus and has a tippy, leaving the tab/window and
2033
- * returning causes it to show again. For mouse users this is unexpected, but
2034
- * for keyboard use it makes sense.
2035
- * TODO: find a better technique to solve this problem
2036
- */
2037
-
2038
- function onWindowBlur() {
2039
- var activeElement = document.activeElement;
2040
-
2041
- if (isReferenceElement(activeElement)) {
2042
- var instance = activeElement._tippy;
2043
-
2044
- if (activeElement.blur && !instance.state.isVisible) {
2045
- activeElement.blur();
2046
- }
2047
- }
2048
- }
2049
- function bindGlobalEventListeners() {
2050
- document.addEventListener('touchstart', onDocumentTouchStart, TOUCH_OPTIONS);
2051
- window.addEventListener('blur', onWindowBlur);
2052
- }
2053
-
2054
- var isBrowser$1 = typeof window !== 'undefined' && typeof document !== 'undefined';
2055
- var isIE11 = isBrowser$1 ? // @ts-ignore
2056
- !!window.msCrypto : false;
2057
-
2058
- var pluginProps = {
2059
- animateFill: false,
2060
- followCursor: false,
2061
- inlinePositioning: false,
2062
- sticky: false
2063
- };
2064
- var renderProps = {
2065
- allowHTML: false,
2066
- animation: 'fade',
2067
- arrow: true,
2068
- content: '',
2069
- inertia: false,
2070
- maxWidth: 350,
2071
- role: 'tooltip',
2072
- theme: '',
2073
- zIndex: 9999
2074
- };
2075
- var defaultProps = Object.assign({
2076
- appendTo: TIPPY_DEFAULT_APPEND_TO,
2077
- aria: {
2078
- content: 'auto',
2079
- expanded: 'auto'
2080
- },
2081
- delay: 0,
2082
- duration: [300, 250],
2083
- getReferenceClientRect: null,
2084
- hideOnClick: true,
2085
- ignoreAttributes: false,
2086
- interactive: false,
2087
- interactiveBorder: 2,
2088
- interactiveDebounce: 0,
2089
- moveTransition: '',
2090
- offset: [0, 10],
2091
- onAfterUpdate: function onAfterUpdate() {},
2092
- onBeforeUpdate: function onBeforeUpdate() {},
2093
- onCreate: function onCreate() {},
2094
- onDestroy: function onDestroy() {},
2095
- onHidden: function onHidden() {},
2096
- onHide: function onHide() {},
2097
- onMount: function onMount() {},
2098
- onShow: function onShow() {},
2099
- onShown: function onShown() {},
2100
- onTrigger: function onTrigger() {},
2101
- onUntrigger: function onUntrigger() {},
2102
- onClickOutside: function onClickOutside() {},
2103
- placement: 'top',
2104
- plugins: [],
2105
- popperOptions: {},
2106
- render: null,
2107
- showOnCreate: false,
2108
- touch: true,
2109
- trigger: 'mouseenter focus',
2110
- triggerTarget: null
2111
- }, pluginProps, renderProps);
2112
- var defaultKeys = Object.keys(defaultProps);
2113
- var setDefaultProps = function setDefaultProps(partialProps) {
2114
-
2115
- var keys = Object.keys(partialProps);
2116
- keys.forEach(function (key) {
2117
- defaultProps[key] = partialProps[key];
2118
- });
2119
- };
2120
- function getExtendedPassedProps(passedProps) {
2121
- var plugins = passedProps.plugins || [];
2122
- var pluginProps = plugins.reduce(function (acc, plugin) {
2123
- var name = plugin.name,
2124
- defaultValue = plugin.defaultValue;
2125
-
2126
- if (name) {
2127
- var _name;
2128
-
2129
- acc[name] = passedProps[name] !== undefined ? passedProps[name] : (_name = defaultProps[name]) != null ? _name : defaultValue;
2130
- }
2131
-
2132
- return acc;
2133
- }, {});
2134
- return Object.assign({}, passedProps, pluginProps);
2135
- }
2136
- function getDataAttributeProps(reference, plugins) {
2137
- var propKeys = plugins ? Object.keys(getExtendedPassedProps(Object.assign({}, defaultProps, {
2138
- plugins: plugins
2139
- }))) : defaultKeys;
2140
- var props = propKeys.reduce(function (acc, key) {
2141
- var valueAsString = (reference.getAttribute("data-tippy-" + key) || '').trim();
2142
-
2143
- if (!valueAsString) {
2144
- return acc;
2145
- }
2146
-
2147
- if (key === 'content') {
2148
- acc[key] = valueAsString;
2149
- } else {
2150
- try {
2151
- acc[key] = JSON.parse(valueAsString);
2152
- } catch (e) {
2153
- acc[key] = valueAsString;
2154
- }
2155
- }
2156
-
2157
- return acc;
2158
- }, {});
2159
- return props;
2160
- }
2161
- function evaluateProps(reference, props) {
2162
- var out = Object.assign({}, props, {
2163
- content: invokeWithArgsOrReturn(props.content, [reference])
2164
- }, props.ignoreAttributes ? {} : getDataAttributeProps(reference, props.plugins));
2165
- out.aria = Object.assign({}, defaultProps.aria, out.aria);
2166
- out.aria = {
2167
- expanded: out.aria.expanded === 'auto' ? props.interactive : out.aria.expanded,
2168
- content: out.aria.content === 'auto' ? props.interactive ? null : 'describedby' : out.aria.content
2169
- };
2170
- return out;
2171
- }
2172
-
2173
- var innerHTML = function innerHTML() {
2174
- return 'innerHTML';
2175
- };
2176
-
2177
- function dangerouslySetInnerHTML(element, html) {
2178
- element[innerHTML()] = html;
2179
- }
2180
-
2181
- function createArrowElement(value) {
2182
- var arrow = div();
2183
-
2184
- if (value === true) {
2185
- arrow.className = ARROW_CLASS;
2186
- } else {
2187
- arrow.className = SVG_ARROW_CLASS;
2188
-
2189
- if (isElement(value)) {
2190
- arrow.appendChild(value);
2191
- } else {
2192
- dangerouslySetInnerHTML(arrow, value);
2193
- }
2194
- }
2195
-
2196
- return arrow;
2197
- }
2198
-
2199
- function setContent(content, props) {
2200
- if (isElement(props.content)) {
2201
- dangerouslySetInnerHTML(content, '');
2202
- content.appendChild(props.content);
2203
- } else if (typeof props.content !== 'function') {
2204
- if (props.allowHTML) {
2205
- dangerouslySetInnerHTML(content, props.content);
2206
- } else {
2207
- content.textContent = props.content;
2208
- }
2209
- }
2210
- }
2211
- function getChildren(popper) {
2212
- var box = popper.firstElementChild;
2213
- var boxChildren = arrayFrom(box.children);
2214
- return {
2215
- box: box,
2216
- content: boxChildren.find(function (node) {
2217
- return node.classList.contains(CONTENT_CLASS);
2218
- }),
2219
- arrow: boxChildren.find(function (node) {
2220
- return node.classList.contains(ARROW_CLASS) || node.classList.contains(SVG_ARROW_CLASS);
2221
- }),
2222
- backdrop: boxChildren.find(function (node) {
2223
- return node.classList.contains(BACKDROP_CLASS);
2224
- })
2225
- };
2226
- }
2227
- function render(instance) {
2228
- var popper = div();
2229
- var box = div();
2230
- box.className = BOX_CLASS;
2231
- box.setAttribute('data-state', 'hidden');
2232
- box.setAttribute('tabindex', '-1');
2233
- var content = div();
2234
- content.className = CONTENT_CLASS;
2235
- content.setAttribute('data-state', 'hidden');
2236
- setContent(content, instance.props);
2237
- popper.appendChild(box);
2238
- box.appendChild(content);
2239
- onUpdate(instance.props, instance.props);
2240
-
2241
- function onUpdate(prevProps, nextProps) {
2242
- var _getChildren = getChildren(popper),
2243
- box = _getChildren.box,
2244
- content = _getChildren.content,
2245
- arrow = _getChildren.arrow;
2246
-
2247
- if (nextProps.theme) {
2248
- box.setAttribute('data-theme', nextProps.theme);
2249
- } else {
2250
- box.removeAttribute('data-theme');
2251
- }
2252
-
2253
- if (typeof nextProps.animation === 'string') {
2254
- box.setAttribute('data-animation', nextProps.animation);
2255
- } else {
2256
- box.removeAttribute('data-animation');
2257
- }
2258
-
2259
- if (nextProps.inertia) {
2260
- box.setAttribute('data-inertia', '');
2261
- } else {
2262
- box.removeAttribute('data-inertia');
2263
- }
2264
-
2265
- box.style.maxWidth = typeof nextProps.maxWidth === 'number' ? nextProps.maxWidth + "px" : nextProps.maxWidth;
2266
-
2267
- if (nextProps.role) {
2268
- box.setAttribute('role', nextProps.role);
2269
- } else {
2270
- box.removeAttribute('role');
2271
- }
2272
-
2273
- if (prevProps.content !== nextProps.content || prevProps.allowHTML !== nextProps.allowHTML) {
2274
- setContent(content, instance.props);
2275
- }
2276
-
2277
- if (nextProps.arrow) {
2278
- if (!arrow) {
2279
- box.appendChild(createArrowElement(nextProps.arrow));
2280
- } else if (prevProps.arrow !== nextProps.arrow) {
2281
- box.removeChild(arrow);
2282
- box.appendChild(createArrowElement(nextProps.arrow));
2283
- }
2284
- } else if (arrow) {
2285
- box.removeChild(arrow);
2286
- }
2287
- }
2288
-
2289
- return {
2290
- popper: popper,
2291
- onUpdate: onUpdate
2292
- };
2293
- } // Runtime check to identify if the render function is the default one; this
2294
- // way we can apply default CSS transitions logic and it can be tree-shaken away
2295
-
2296
- render.$$tippy = true;
2297
-
2298
- var idCounter = 1;
2299
- var mouseMoveListeners = []; // Used by `hideAll()`
2300
-
2301
- var mountedInstances = [];
2302
- function createTippy(reference, passedProps) {
2303
- var props = evaluateProps(reference, Object.assign({}, defaultProps, getExtendedPassedProps(removeUndefinedProps(passedProps)))); // ===========================================================================
2304
- // 🔒 Private members
2305
- // ===========================================================================
2306
-
2307
- var showTimeout;
2308
- var hideTimeout;
2309
- var scheduleHideAnimationFrame;
2310
- var isVisibleFromClick = false;
2311
- var didHideDueToDocumentMouseDown = false;
2312
- var didTouchMove = false;
2313
- var ignoreOnFirstUpdate = false;
2314
- var lastTriggerEvent;
2315
- var currentTransitionEndListener;
2316
- var onFirstUpdate;
2317
- var listeners = [];
2318
- var debouncedOnMouseMove = debounce(onMouseMove, props.interactiveDebounce);
2319
- var currentTarget; // ===========================================================================
2320
- // 🔑 Public members
2321
- // ===========================================================================
2322
-
2323
- var id = idCounter++;
2324
- var popperInstance = null;
2325
- var plugins = unique(props.plugins);
2326
- var state = {
2327
- // Is the instance currently enabled?
2328
- isEnabled: true,
2329
- // Is the tippy currently showing and not transitioning out?
2330
- isVisible: false,
2331
- // Has the instance been destroyed?
2332
- isDestroyed: false,
2333
- // Is the tippy currently mounted to the DOM?
2334
- isMounted: false,
2335
- // Has the tippy finished transitioning in?
2336
- isShown: false
2337
- };
2338
- var instance = {
2339
- // properties
2340
- id: id,
2341
- reference: reference,
2342
- popper: div(),
2343
- popperInstance: popperInstance,
2344
- props: props,
2345
- state: state,
2346
- plugins: plugins,
2347
- // methods
2348
- clearDelayTimeouts: clearDelayTimeouts,
2349
- setProps: setProps,
2350
- setContent: setContent,
2351
- show: show,
2352
- hide: hide,
2353
- hideWithInteractivity: hideWithInteractivity,
2354
- enable: enable,
2355
- disable: disable,
2356
- unmount: unmount,
2357
- destroy: destroy
2358
- }; // TODO: Investigate why this early return causes a TDZ error in the tests —
2359
- // it doesn't seem to happen in the browser
2360
-
2361
- /* istanbul ignore if */
2362
-
2363
- if (!props.render) {
2364
-
2365
- return instance;
2366
- } // ===========================================================================
2367
- // Initial mutations
2368
- // ===========================================================================
2369
-
2370
-
2371
- var _props$render = props.render(instance),
2372
- popper = _props$render.popper,
2373
- onUpdate = _props$render.onUpdate;
2374
-
2375
- popper.setAttribute('data-tippy-root', '');
2376
- popper.id = "tippy-" + instance.id;
2377
- instance.popper = popper;
2378
- reference._tippy = instance;
2379
- popper._tippy = instance;
2380
- var pluginsHooks = plugins.map(function (plugin) {
2381
- return plugin.fn(instance);
2382
- });
2383
- var hasAriaExpanded = reference.hasAttribute('aria-expanded');
2384
- addListeners();
2385
- handleAriaExpandedAttribute();
2386
- handleStyles();
2387
- invokeHook('onCreate', [instance]);
2388
-
2389
- if (props.showOnCreate) {
2390
- scheduleShow();
2391
- } // Prevent a tippy with a delay from hiding if the cursor left then returned
2392
- // before it started hiding
2393
-
2394
-
2395
- popper.addEventListener('mouseenter', function () {
2396
- if (instance.props.interactive && instance.state.isVisible) {
2397
- instance.clearDelayTimeouts();
2398
- }
2399
- });
2400
- popper.addEventListener('mouseleave', function () {
2401
- if (instance.props.interactive && instance.props.trigger.indexOf('mouseenter') >= 0) {
2402
- getDocument().addEventListener('mousemove', debouncedOnMouseMove);
2403
- }
2404
- });
2405
- return instance; // ===========================================================================
2406
- // 🔒 Private methods
2407
- // ===========================================================================
2408
-
2409
- function getNormalizedTouchSettings() {
2410
- var touch = instance.props.touch;
2411
- return Array.isArray(touch) ? touch : [touch, 0];
2412
- }
2413
-
2414
- function getIsCustomTouchBehavior() {
2415
- return getNormalizedTouchSettings()[0] === 'hold';
2416
- }
2417
-
2418
- function getIsDefaultRenderFn() {
2419
- var _instance$props$rende;
2420
-
2421
- // @ts-ignore
2422
- return !!((_instance$props$rende = instance.props.render) != null && _instance$props$rende.$$tippy);
2423
- }
2424
-
2425
- function getCurrentTarget() {
2426
- return currentTarget || reference;
2427
- }
2428
-
2429
- function getDocument() {
2430
- var parent = getCurrentTarget().parentNode;
2431
- return parent ? getOwnerDocument(parent) : document;
2432
- }
2433
-
2434
- function getDefaultTemplateChildren() {
2435
- return getChildren(popper);
2436
- }
2437
-
2438
- function getDelay(isShow) {
2439
- // For touch or keyboard input, force `0` delay for UX reasons
2440
- // Also if the instance is mounted but not visible (transitioning out),
2441
- // ignore delay
2442
- if (instance.state.isMounted && !instance.state.isVisible || currentInput.isTouch || lastTriggerEvent && lastTriggerEvent.type === 'focus') {
2443
- return 0;
2444
- }
2445
-
2446
- return getValueAtIndexOrReturn(instance.props.delay, isShow ? 0 : 1, defaultProps.delay);
2447
- }
2448
-
2449
- function handleStyles(fromHide) {
2450
- if (fromHide === void 0) {
2451
- fromHide = false;
2452
- }
2453
-
2454
- popper.style.pointerEvents = instance.props.interactive && !fromHide ? '' : 'none';
2455
- popper.style.zIndex = "" + instance.props.zIndex;
2456
- }
2457
-
2458
- function invokeHook(hook, args, shouldInvokePropsHook) {
2459
- if (shouldInvokePropsHook === void 0) {
2460
- shouldInvokePropsHook = true;
2461
- }
2462
-
2463
- pluginsHooks.forEach(function (pluginHooks) {
2464
- if (pluginHooks[hook]) {
2465
- pluginHooks[hook].apply(pluginHooks, args);
2466
- }
2467
- });
2468
-
2469
- if (shouldInvokePropsHook) {
2470
- var _instance$props;
2471
-
2472
- (_instance$props = instance.props)[hook].apply(_instance$props, args);
2473
- }
2474
- }
2475
-
2476
- function handleAriaContentAttribute() {
2477
- var aria = instance.props.aria;
2478
-
2479
- if (!aria.content) {
2480
- return;
2481
- }
2482
-
2483
- var attr = "aria-" + aria.content;
2484
- var id = popper.id;
2485
- var nodes = normalizeToArray(instance.props.triggerTarget || reference);
2486
- nodes.forEach(function (node) {
2487
- var currentValue = node.getAttribute(attr);
2488
-
2489
- if (instance.state.isVisible) {
2490
- node.setAttribute(attr, currentValue ? currentValue + " " + id : id);
2491
- } else {
2492
- var nextValue = currentValue && currentValue.replace(id, '').trim();
2493
-
2494
- if (nextValue) {
2495
- node.setAttribute(attr, nextValue);
2496
- } else {
2497
- node.removeAttribute(attr);
2498
- }
2499
- }
2500
- });
2501
- }
2502
-
2503
- function handleAriaExpandedAttribute() {
2504
- if (hasAriaExpanded || !instance.props.aria.expanded) {
2505
- return;
2506
- }
2507
-
2508
- var nodes = normalizeToArray(instance.props.triggerTarget || reference);
2509
- nodes.forEach(function (node) {
2510
- if (instance.props.interactive) {
2511
- node.setAttribute('aria-expanded', instance.state.isVisible && node === getCurrentTarget() ? 'true' : 'false');
2512
- } else {
2513
- node.removeAttribute('aria-expanded');
2514
- }
2515
- });
2516
- }
2517
-
2518
- function cleanupInteractiveMouseListeners() {
2519
- getDocument().removeEventListener('mousemove', debouncedOnMouseMove);
2520
- mouseMoveListeners = mouseMoveListeners.filter(function (listener) {
2521
- return listener !== debouncedOnMouseMove;
2522
- });
2523
- }
2524
-
2525
- function onDocumentPress(event) {
2526
- // Moved finger to scroll instead of an intentional tap outside
2527
- if (currentInput.isTouch) {
2528
- if (didTouchMove || event.type === 'mousedown') {
2529
- return;
2530
- }
2531
- }
2532
-
2533
- var actualTarget = event.composedPath && event.composedPath()[0] || event.target; // Clicked on interactive popper
2534
-
2535
- if (instance.props.interactive && actualContains(popper, actualTarget)) {
2536
- return;
2537
- } // Clicked on the event listeners target
2538
-
2539
-
2540
- if (normalizeToArray(instance.props.triggerTarget || reference).some(function (el) {
2541
- return actualContains(el, actualTarget);
2542
- })) {
2543
- if (currentInput.isTouch) {
2544
- return;
2545
- }
2546
-
2547
- if (instance.state.isVisible && instance.props.trigger.indexOf('click') >= 0) {
2548
- return;
2549
- }
2550
- } else {
2551
- invokeHook('onClickOutside', [instance, event]);
2552
- }
2553
-
2554
- if (instance.props.hideOnClick === true) {
2555
- instance.clearDelayTimeouts();
2556
- instance.hide(); // `mousedown` event is fired right before `focus` if pressing the
2557
- // currentTarget. This lets a tippy with `focus` trigger know that it
2558
- // should not show
2559
-
2560
- didHideDueToDocumentMouseDown = true;
2561
- setTimeout(function () {
2562
- didHideDueToDocumentMouseDown = false;
2563
- }); // The listener gets added in `scheduleShow()`, but this may be hiding it
2564
- // before it shows, and hide()'s early bail-out behavior can prevent it
2565
- // from being cleaned up
2566
-
2567
- if (!instance.state.isMounted) {
2568
- removeDocumentPress();
2569
- }
2570
- }
2571
- }
2572
-
2573
- function onTouchMove() {
2574
- didTouchMove = true;
2575
- }
2576
-
2577
- function onTouchStart() {
2578
- didTouchMove = false;
2579
- }
2580
-
2581
- function addDocumentPress() {
2582
- var doc = getDocument();
2583
- doc.addEventListener('mousedown', onDocumentPress, true);
2584
- doc.addEventListener('touchend', onDocumentPress, TOUCH_OPTIONS);
2585
- doc.addEventListener('touchstart', onTouchStart, TOUCH_OPTIONS);
2586
- doc.addEventListener('touchmove', onTouchMove, TOUCH_OPTIONS);
2587
- }
2588
-
2589
- function removeDocumentPress() {
2590
- var doc = getDocument();
2591
- doc.removeEventListener('mousedown', onDocumentPress, true);
2592
- doc.removeEventListener('touchend', onDocumentPress, TOUCH_OPTIONS);
2593
- doc.removeEventListener('touchstart', onTouchStart, TOUCH_OPTIONS);
2594
- doc.removeEventListener('touchmove', onTouchMove, TOUCH_OPTIONS);
2595
- }
2596
-
2597
- function onTransitionedOut(duration, callback) {
2598
- onTransitionEnd(duration, function () {
2599
- if (!instance.state.isVisible && popper.parentNode && popper.parentNode.contains(popper)) {
2600
- callback();
2601
- }
2602
- });
2603
- }
2604
-
2605
- function onTransitionedIn(duration, callback) {
2606
- onTransitionEnd(duration, callback);
2607
- }
2608
-
2609
- function onTransitionEnd(duration, callback) {
2610
- var box = getDefaultTemplateChildren().box;
2611
-
2612
- function listener(event) {
2613
- if (event.target === box) {
2614
- updateTransitionEndListener(box, 'remove', listener);
2615
- callback();
2616
- }
2617
- } // Make callback synchronous if duration is 0
2618
- // `transitionend` won't fire otherwise
2619
-
2620
-
2621
- if (duration === 0) {
2622
- return callback();
2623
- }
2624
-
2625
- updateTransitionEndListener(box, 'remove', currentTransitionEndListener);
2626
- updateTransitionEndListener(box, 'add', listener);
2627
- currentTransitionEndListener = listener;
2628
- }
2629
-
2630
- function on(eventType, handler, options) {
2631
- if (options === void 0) {
2632
- options = false;
2633
- }
2634
-
2635
- var nodes = normalizeToArray(instance.props.triggerTarget || reference);
2636
- nodes.forEach(function (node) {
2637
- node.addEventListener(eventType, handler, options);
2638
- listeners.push({
2639
- node: node,
2640
- eventType: eventType,
2641
- handler: handler,
2642
- options: options
2643
- });
2644
- });
2645
- }
2646
-
2647
- function addListeners() {
2648
- if (getIsCustomTouchBehavior()) {
2649
- on('touchstart', onTrigger, {
2650
- passive: true
2651
- });
2652
- on('touchend', onMouseLeave, {
2653
- passive: true
2654
- });
2655
- }
2656
-
2657
- splitBySpaces(instance.props.trigger).forEach(function (eventType) {
2658
- if (eventType === 'manual') {
2659
- return;
2660
- }
2661
-
2662
- on(eventType, onTrigger);
2663
-
2664
- switch (eventType) {
2665
- case 'mouseenter':
2666
- on('mouseleave', onMouseLeave);
2667
- break;
2668
-
2669
- case 'focus':
2670
- on(isIE11 ? 'focusout' : 'blur', onBlurOrFocusOut);
2671
- break;
2672
-
2673
- case 'focusin':
2674
- on('focusout', onBlurOrFocusOut);
2675
- break;
2676
- }
2677
- });
2678
- }
2679
-
2680
- function removeListeners() {
2681
- listeners.forEach(function (_ref) {
2682
- var node = _ref.node,
2683
- eventType = _ref.eventType,
2684
- handler = _ref.handler,
2685
- options = _ref.options;
2686
- node.removeEventListener(eventType, handler, options);
2687
- });
2688
- listeners = [];
2689
- }
2690
-
2691
- function onTrigger(event) {
2692
- var _lastTriggerEvent;
2693
-
2694
- var shouldScheduleClickHide = false;
2695
-
2696
- if (!instance.state.isEnabled || isEventListenerStopped(event) || didHideDueToDocumentMouseDown) {
2697
- return;
2698
- }
2699
-
2700
- var wasFocused = ((_lastTriggerEvent = lastTriggerEvent) == null ? void 0 : _lastTriggerEvent.type) === 'focus';
2701
- lastTriggerEvent = event;
2702
- currentTarget = event.currentTarget;
2703
- handleAriaExpandedAttribute();
2704
-
2705
- if (!instance.state.isVisible && isMouseEvent(event)) {
2706
- // If scrolling, `mouseenter` events can be fired if the cursor lands
2707
- // over a new target, but `mousemove` events don't get fired. This
2708
- // causes interactive tooltips to get stuck open until the cursor is
2709
- // moved
2710
- mouseMoveListeners.forEach(function (listener) {
2711
- return listener(event);
2712
- });
2713
- } // Toggle show/hide when clicking click-triggered tooltips
2714
-
2715
-
2716
- if (event.type === 'click' && (instance.props.trigger.indexOf('mouseenter') < 0 || isVisibleFromClick) && instance.props.hideOnClick !== false && instance.state.isVisible) {
2717
- shouldScheduleClickHide = true;
2718
- } else {
2719
- scheduleShow(event);
2720
- }
2721
-
2722
- if (event.type === 'click') {
2723
- isVisibleFromClick = !shouldScheduleClickHide;
2724
- }
2725
-
2726
- if (shouldScheduleClickHide && !wasFocused) {
2727
- scheduleHide(event);
2728
- }
2729
- }
2730
-
2731
- function onMouseMove(event) {
2732
- var target = event.target;
2733
- var isCursorOverReferenceOrPopper = getCurrentTarget().contains(target) || popper.contains(target);
2734
-
2735
- if (event.type === 'mousemove' && isCursorOverReferenceOrPopper) {
2736
- return;
2737
- }
2738
-
2739
- var popperTreeData = getNestedPopperTree().concat(popper).map(function (popper) {
2740
- var _instance$popperInsta;
2741
-
2742
- var instance = popper._tippy;
2743
- var state = (_instance$popperInsta = instance.popperInstance) == null ? void 0 : _instance$popperInsta.state;
2744
-
2745
- if (state) {
2746
- return {
2747
- popperRect: popper.getBoundingClientRect(),
2748
- popperState: state,
2749
- props: props
2750
- };
2751
- }
2752
-
2753
- return null;
2754
- }).filter(Boolean);
2755
-
2756
- if (isCursorOutsideInteractiveBorder(popperTreeData, event)) {
2757
- cleanupInteractiveMouseListeners();
2758
- scheduleHide(event);
2759
- }
2760
- }
2761
-
2762
- function onMouseLeave(event) {
2763
- var shouldBail = isEventListenerStopped(event) || instance.props.trigger.indexOf('click') >= 0 && isVisibleFromClick;
2764
-
2765
- if (shouldBail) {
2766
- return;
2767
- }
2768
-
2769
- if (instance.props.interactive) {
2770
- instance.hideWithInteractivity(event);
2771
- return;
2772
- }
2773
-
2774
- scheduleHide(event);
2775
- }
2776
-
2777
- function onBlurOrFocusOut(event) {
2778
- if (instance.props.trigger.indexOf('focusin') < 0 && event.target !== getCurrentTarget()) {
2779
- return;
2780
- } // If focus was moved to within the popper
2781
-
2782
-
2783
- if (instance.props.interactive && event.relatedTarget && popper.contains(event.relatedTarget)) {
2784
- return;
2785
- }
2786
-
2787
- scheduleHide(event);
2788
- }
2789
-
2790
- function isEventListenerStopped(event) {
2791
- return currentInput.isTouch ? getIsCustomTouchBehavior() !== event.type.indexOf('touch') >= 0 : false;
2792
- }
2793
-
2794
- function createPopperInstance() {
2795
- destroyPopperInstance();
2796
- var _instance$props2 = instance.props,
2797
- popperOptions = _instance$props2.popperOptions,
2798
- placement = _instance$props2.placement,
2799
- offset = _instance$props2.offset,
2800
- getReferenceClientRect = _instance$props2.getReferenceClientRect,
2801
- moveTransition = _instance$props2.moveTransition;
2802
- var arrow = getIsDefaultRenderFn() ? getChildren(popper).arrow : null;
2803
- var computedReference = getReferenceClientRect ? {
2804
- getBoundingClientRect: getReferenceClientRect,
2805
- contextElement: getReferenceClientRect.contextElement || getCurrentTarget()
2806
- } : reference;
2807
- var tippyModifier = {
2808
- name: '$$tippy',
2809
- enabled: true,
2810
- phase: 'beforeWrite',
2811
- requires: ['computeStyles'],
2812
- fn: function fn(_ref2) {
2813
- var state = _ref2.state;
2814
-
2815
- if (getIsDefaultRenderFn()) {
2816
- var _getDefaultTemplateCh = getDefaultTemplateChildren(),
2817
- box = _getDefaultTemplateCh.box;
2818
-
2819
- ['placement', 'reference-hidden', 'escaped'].forEach(function (attr) {
2820
- if (attr === 'placement') {
2821
- box.setAttribute('data-placement', state.placement);
2822
- } else {
2823
- if (state.attributes.popper["data-popper-" + attr]) {
2824
- box.setAttribute("data-" + attr, '');
2825
- } else {
2826
- box.removeAttribute("data-" + attr);
2827
- }
2828
- }
2829
- });
2830
- state.attributes.popper = {};
2831
- }
2832
- }
2833
- };
2834
- var modifiers = [{
2835
- name: 'offset',
2836
- options: {
2837
- offset: offset
2838
- }
2839
- }, {
2840
- name: 'preventOverflow',
2841
- options: {
2842
- padding: {
2843
- top: 2,
2844
- bottom: 2,
2845
- left: 5,
2846
- right: 5
2847
- }
2848
- }
2849
- }, {
2850
- name: 'flip',
2851
- options: {
2852
- padding: 5
2853
- }
2854
- }, {
2855
- name: 'computeStyles',
2856
- options: {
2857
- adaptive: !moveTransition
2858
- }
2859
- }, tippyModifier];
2860
-
2861
- if (getIsDefaultRenderFn() && arrow) {
2862
- modifiers.push({
2863
- name: 'arrow',
2864
- options: {
2865
- element: arrow,
2866
- padding: 3
2867
- }
2868
- });
2869
- }
2870
-
2871
- modifiers.push.apply(modifiers, (popperOptions == null ? void 0 : popperOptions.modifiers) || []);
2872
- instance.popperInstance = createPopper(computedReference, popper, Object.assign({}, popperOptions, {
2873
- placement: placement,
2874
- onFirstUpdate: onFirstUpdate,
2875
- modifiers: modifiers
2876
- }));
2877
- }
2878
-
2879
- function destroyPopperInstance() {
2880
- if (instance.popperInstance) {
2881
- instance.popperInstance.destroy();
2882
- instance.popperInstance = null;
2883
- }
2884
- }
2885
-
2886
- function mount() {
2887
- var appendTo = instance.props.appendTo;
2888
- var parentNode; // By default, we'll append the popper to the triggerTargets's parentNode so
2889
- // it's directly after the reference element so the elements inside the
2890
- // tippy can be tabbed to
2891
- // If there are clipping issues, the user can specify a different appendTo
2892
- // and ensure focus management is handled correctly manually
2893
-
2894
- var node = getCurrentTarget();
2895
-
2896
- if (instance.props.interactive && appendTo === TIPPY_DEFAULT_APPEND_TO || appendTo === 'parent') {
2897
- parentNode = node.parentNode;
2898
- } else {
2899
- parentNode = invokeWithArgsOrReturn(appendTo, [node]);
2900
- } // The popper element needs to exist on the DOM before its position can be
2901
- // updated as Popper needs to read its dimensions
2902
-
2903
-
2904
- if (!parentNode.contains(popper)) {
2905
- parentNode.appendChild(popper);
2906
- }
2907
-
2908
- instance.state.isMounted = true;
2909
- createPopperInstance();
2910
- }
2911
-
2912
- function getNestedPopperTree() {
2913
- return arrayFrom(popper.querySelectorAll('[data-tippy-root]'));
2914
- }
2915
-
2916
- function scheduleShow(event) {
2917
- instance.clearDelayTimeouts();
2918
-
2919
- if (event) {
2920
- invokeHook('onTrigger', [instance, event]);
2921
- }
2922
-
2923
- addDocumentPress();
2924
- var delay = getDelay(true);
2925
-
2926
- var _getNormalizedTouchSe = getNormalizedTouchSettings(),
2927
- touchValue = _getNormalizedTouchSe[0],
2928
- touchDelay = _getNormalizedTouchSe[1];
2929
-
2930
- if (currentInput.isTouch && touchValue === 'hold' && touchDelay) {
2931
- delay = touchDelay;
2932
- }
2933
-
2934
- if (delay) {
2935
- showTimeout = setTimeout(function () {
2936
- instance.show();
2937
- }, delay);
2938
- } else {
2939
- instance.show();
2940
- }
2941
- }
2942
-
2943
- function scheduleHide(event) {
2944
- instance.clearDelayTimeouts();
2945
- invokeHook('onUntrigger', [instance, event]);
2946
-
2947
- if (!instance.state.isVisible) {
2948
- removeDocumentPress();
2949
- return;
2950
- } // For interactive tippies, scheduleHide is added to a document.body handler
2951
- // from onMouseLeave so must intercept scheduled hides from mousemove/leave
2952
- // events when trigger contains mouseenter and click, and the tip is
2953
- // currently shown as a result of a click.
2954
-
2955
-
2956
- if (instance.props.trigger.indexOf('mouseenter') >= 0 && instance.props.trigger.indexOf('click') >= 0 && ['mouseleave', 'mousemove'].indexOf(event.type) >= 0 && isVisibleFromClick) {
2957
- return;
2958
- }
2959
-
2960
- var delay = getDelay(false);
2961
-
2962
- if (delay) {
2963
- hideTimeout = setTimeout(function () {
2964
- if (instance.state.isVisible) {
2965
- instance.hide();
2966
- }
2967
- }, delay);
2968
- } else {
2969
- // Fixes a `transitionend` problem when it fires 1 frame too
2970
- // late sometimes, we don't want hide() to be called.
2971
- scheduleHideAnimationFrame = requestAnimationFrame(function () {
2972
- instance.hide();
2973
- });
2974
- }
2975
- } // ===========================================================================
2976
- // 🔑 Public methods
2977
- // ===========================================================================
2978
-
2979
-
2980
- function enable() {
2981
- instance.state.isEnabled = true;
2982
- }
2983
-
2984
- function disable() {
2985
- // Disabling the instance should also hide it
2986
- // https://github.com/atomiks/tippy.js-react/issues/106
2987
- instance.hide();
2988
- instance.state.isEnabled = false;
2989
- }
2990
-
2991
- function clearDelayTimeouts() {
2992
- clearTimeout(showTimeout);
2993
- clearTimeout(hideTimeout);
2994
- cancelAnimationFrame(scheduleHideAnimationFrame);
2995
- }
2996
-
2997
- function setProps(partialProps) {
2998
-
2999
- if (instance.state.isDestroyed) {
3000
- return;
3001
- }
3002
-
3003
- invokeHook('onBeforeUpdate', [instance, partialProps]);
3004
- removeListeners();
3005
- var prevProps = instance.props;
3006
- var nextProps = evaluateProps(reference, Object.assign({}, prevProps, removeUndefinedProps(partialProps), {
3007
- ignoreAttributes: true
3008
- }));
3009
- instance.props = nextProps;
3010
- addListeners();
3011
-
3012
- if (prevProps.interactiveDebounce !== nextProps.interactiveDebounce) {
3013
- cleanupInteractiveMouseListeners();
3014
- debouncedOnMouseMove = debounce(onMouseMove, nextProps.interactiveDebounce);
3015
- } // Ensure stale aria-expanded attributes are removed
3016
-
3017
-
3018
- if (prevProps.triggerTarget && !nextProps.triggerTarget) {
3019
- normalizeToArray(prevProps.triggerTarget).forEach(function (node) {
3020
- node.removeAttribute('aria-expanded');
3021
- });
3022
- } else if (nextProps.triggerTarget) {
3023
- reference.removeAttribute('aria-expanded');
3024
- }
3025
-
3026
- handleAriaExpandedAttribute();
3027
- handleStyles();
3028
-
3029
- if (onUpdate) {
3030
- onUpdate(prevProps, nextProps);
3031
- }
3032
-
3033
- if (instance.popperInstance) {
3034
- createPopperInstance(); // Fixes an issue with nested tippies if they are all getting re-rendered,
3035
- // and the nested ones get re-rendered first.
3036
- // https://github.com/atomiks/tippyjs-react/issues/177
3037
- // TODO: find a cleaner / more efficient solution(!)
3038
-
3039
- getNestedPopperTree().forEach(function (nestedPopper) {
3040
- // React (and other UI libs likely) requires a rAF wrapper as it flushes
3041
- // its work in one
3042
- requestAnimationFrame(nestedPopper._tippy.popperInstance.forceUpdate);
3043
- });
3044
- }
3045
-
3046
- invokeHook('onAfterUpdate', [instance, partialProps]);
3047
- }
3048
-
3049
- function setContent(content) {
3050
- instance.setProps({
3051
- content: content
3052
- });
3053
- }
3054
-
3055
- function show() {
3056
-
3057
-
3058
- var isAlreadyVisible = instance.state.isVisible;
3059
- var isDestroyed = instance.state.isDestroyed;
3060
- var isDisabled = !instance.state.isEnabled;
3061
- var isTouchAndTouchDisabled = currentInput.isTouch && !instance.props.touch;
3062
- var duration = getValueAtIndexOrReturn(instance.props.duration, 0, defaultProps.duration);
3063
-
3064
- if (isAlreadyVisible || isDestroyed || isDisabled || isTouchAndTouchDisabled) {
3065
- return;
3066
- } // Normalize `disabled` behavior across browsers.
3067
- // Firefox allows events on disabled elements, but Chrome doesn't.
3068
- // Using a wrapper element (i.e. <span>) is recommended.
3069
-
3070
-
3071
- if (getCurrentTarget().hasAttribute('disabled')) {
3072
- return;
3073
- }
3074
-
3075
- invokeHook('onShow', [instance], false);
3076
-
3077
- if (instance.props.onShow(instance) === false) {
3078
- return;
3079
- }
3080
-
3081
- instance.state.isVisible = true;
3082
-
3083
- if (getIsDefaultRenderFn()) {
3084
- popper.style.visibility = 'visible';
3085
- }
3086
-
3087
- handleStyles();
3088
- addDocumentPress();
3089
-
3090
- if (!instance.state.isMounted) {
3091
- popper.style.transition = 'none';
3092
- } // If flipping to the opposite side after hiding at least once, the
3093
- // animation will use the wrong placement without resetting the duration
3094
-
3095
-
3096
- if (getIsDefaultRenderFn()) {
3097
- var _getDefaultTemplateCh2 = getDefaultTemplateChildren(),
3098
- box = _getDefaultTemplateCh2.box,
3099
- content = _getDefaultTemplateCh2.content;
3100
-
3101
- setTransitionDuration([box, content], 0);
3102
- }
3103
-
3104
- onFirstUpdate = function onFirstUpdate() {
3105
- var _instance$popperInsta2;
3106
-
3107
- if (!instance.state.isVisible || ignoreOnFirstUpdate) {
3108
- return;
3109
- }
3110
-
3111
- ignoreOnFirstUpdate = true; // reflow
3112
-
3113
- void popper.offsetHeight;
3114
- popper.style.transition = instance.props.moveTransition;
3115
-
3116
- if (getIsDefaultRenderFn() && instance.props.animation) {
3117
- var _getDefaultTemplateCh3 = getDefaultTemplateChildren(),
3118
- _box = _getDefaultTemplateCh3.box,
3119
- _content = _getDefaultTemplateCh3.content;
3120
-
3121
- setTransitionDuration([_box, _content], duration);
3122
- setVisibilityState([_box, _content], 'visible');
3123
- }
3124
-
3125
- handleAriaContentAttribute();
3126
- handleAriaExpandedAttribute();
3127
- pushIfUnique(mountedInstances, instance); // certain modifiers (e.g. `maxSize`) require a second update after the
3128
- // popper has been positioned for the first time
3129
-
3130
- (_instance$popperInsta2 = instance.popperInstance) == null ? void 0 : _instance$popperInsta2.forceUpdate();
3131
- invokeHook('onMount', [instance]);
3132
-
3133
- if (instance.props.animation && getIsDefaultRenderFn()) {
3134
- onTransitionedIn(duration, function () {
3135
- instance.state.isShown = true;
3136
- invokeHook('onShown', [instance]);
3137
- });
3138
- }
3139
- };
3140
-
3141
- mount();
3142
- }
3143
-
3144
- function hide() {
3145
-
3146
-
3147
- var isAlreadyHidden = !instance.state.isVisible;
3148
- var isDestroyed = instance.state.isDestroyed;
3149
- var isDisabled = !instance.state.isEnabled;
3150
- var duration = getValueAtIndexOrReturn(instance.props.duration, 1, defaultProps.duration);
3151
-
3152
- if (isAlreadyHidden || isDestroyed || isDisabled) {
3153
- return;
3154
- }
3155
-
3156
- invokeHook('onHide', [instance], false);
3157
-
3158
- if (instance.props.onHide(instance) === false) {
3159
- return;
3160
- }
3161
-
3162
- instance.state.isVisible = false;
3163
- instance.state.isShown = false;
3164
- ignoreOnFirstUpdate = false;
3165
- isVisibleFromClick = false;
3166
-
3167
- if (getIsDefaultRenderFn()) {
3168
- popper.style.visibility = 'hidden';
3169
- }
3170
-
3171
- cleanupInteractiveMouseListeners();
3172
- removeDocumentPress();
3173
- handleStyles(true);
3174
-
3175
- if (getIsDefaultRenderFn()) {
3176
- var _getDefaultTemplateCh4 = getDefaultTemplateChildren(),
3177
- box = _getDefaultTemplateCh4.box,
3178
- content = _getDefaultTemplateCh4.content;
3179
-
3180
- if (instance.props.animation) {
3181
- setTransitionDuration([box, content], duration);
3182
- setVisibilityState([box, content], 'hidden');
3183
- }
3184
- }
3185
-
3186
- handleAriaContentAttribute();
3187
- handleAriaExpandedAttribute();
3188
-
3189
- if (instance.props.animation) {
3190
- if (getIsDefaultRenderFn()) {
3191
- onTransitionedOut(duration, instance.unmount);
3192
- }
3193
- } else {
3194
- instance.unmount();
3195
- }
3196
- }
3197
-
3198
- function hideWithInteractivity(event) {
3199
-
3200
- getDocument().addEventListener('mousemove', debouncedOnMouseMove);
3201
- pushIfUnique(mouseMoveListeners, debouncedOnMouseMove);
3202
- debouncedOnMouseMove(event);
3203
- }
3204
-
3205
- function unmount() {
3206
-
3207
- if (instance.state.isVisible) {
3208
- instance.hide();
3209
- }
3210
-
3211
- if (!instance.state.isMounted) {
3212
- return;
3213
- }
3214
-
3215
- destroyPopperInstance(); // If a popper is not interactive, it will be appended outside the popper
3216
- // tree by default. This seems mainly for interactive tippies, but we should
3217
- // find a workaround if possible
3218
-
3219
- getNestedPopperTree().forEach(function (nestedPopper) {
3220
- nestedPopper._tippy.unmount();
3221
- });
3222
-
3223
- if (popper.parentNode) {
3224
- popper.parentNode.removeChild(popper);
3225
- }
3226
-
3227
- mountedInstances = mountedInstances.filter(function (i) {
3228
- return i !== instance;
3229
- });
3230
- instance.state.isMounted = false;
3231
- invokeHook('onHidden', [instance]);
3232
- }
3233
-
3234
- function destroy() {
3235
-
3236
- if (instance.state.isDestroyed) {
3237
- return;
3238
- }
3239
-
3240
- instance.clearDelayTimeouts();
3241
- instance.unmount();
3242
- removeListeners();
3243
- delete reference._tippy;
3244
- instance.state.isDestroyed = true;
3245
- invokeHook('onDestroy', [instance]);
3246
- }
3247
- }
3248
-
3249
- function tippy(targets, optionalProps) {
3250
- if (optionalProps === void 0) {
3251
- optionalProps = {};
3252
- }
3253
-
3254
- var plugins = defaultProps.plugins.concat(optionalProps.plugins || []);
3255
-
3256
- bindGlobalEventListeners();
3257
- var passedProps = Object.assign({}, optionalProps, {
3258
- plugins: plugins
3259
- });
3260
- var elements = getArrayOfElements(targets);
3261
-
3262
- var instances = elements.reduce(function (acc, reference) {
3263
- var instance = reference && createTippy(reference, passedProps);
3264
-
3265
- if (instance) {
3266
- acc.push(instance);
3267
- }
3268
-
3269
- return acc;
3270
- }, []);
3271
- return isElement(targets) ? instances[0] : instances;
3272
- }
3273
-
3274
- tippy.defaultProps = defaultProps;
3275
- tippy.setDefaultProps = setDefaultProps;
3276
- tippy.currentInput = currentInput;
3277
-
3278
- // every time the popper is destroyed (i.e. a new target), removing the styles
3279
- // and causing transitions to break for singletons when the console is open, but
3280
- // most notably for non-transform styles being used, `gpuAcceleration: false`.
3281
-
3282
- Object.assign({}, applyStyles$1, {
3283
- effect: function effect(_ref) {
3284
- var state = _ref.state;
3285
- var initialStyles = {
3286
- popper: {
3287
- position: state.options.strategy,
3288
- left: '0',
3289
- top: '0',
3290
- margin: '0'
3291
- },
3292
- arrow: {
3293
- position: 'absolute'
3294
- },
3295
- reference: {}
3296
- };
3297
- Object.assign(state.elements.popper.style, initialStyles.popper);
3298
- state.styles = initialStyles;
3299
-
3300
- if (state.elements.arrow) {
3301
- Object.assign(state.elements.arrow.style, initialStyles.arrow);
3302
- } // intentionally return no cleanup function
3303
- // return () => { ... }
3304
-
3305
- }
3306
- });
3307
-
3308
- var mouseCoords = {
3309
- clientX: 0,
3310
- clientY: 0
3311
- };
3312
- var activeInstances = [];
3313
-
3314
- function storeMouseCoords(_ref) {
3315
- var clientX = _ref.clientX,
3316
- clientY = _ref.clientY;
3317
- mouseCoords = {
3318
- clientX: clientX,
3319
- clientY: clientY
3320
- };
3321
- }
3322
-
3323
- function addMouseCoordsListener(doc) {
3324
- doc.addEventListener('mousemove', storeMouseCoords);
3325
- }
3326
-
3327
- function removeMouseCoordsListener(doc) {
3328
- doc.removeEventListener('mousemove', storeMouseCoords);
3329
- }
3330
-
3331
- var followCursor = {
3332
- name: 'followCursor',
3333
- defaultValue: false,
3334
- fn: function fn(instance) {
3335
- var reference = instance.reference;
3336
- var doc = getOwnerDocument(instance.props.triggerTarget || reference);
3337
- var isInternalUpdate = false;
3338
- var wasFocusEvent = false;
3339
- var isUnmounted = true;
3340
- var prevProps = instance.props;
3341
-
3342
- function getIsInitialBehavior() {
3343
- return instance.props.followCursor === 'initial' && instance.state.isVisible;
3344
- }
3345
-
3346
- function addListener() {
3347
- doc.addEventListener('mousemove', onMouseMove);
3348
- }
3349
-
3350
- function removeListener() {
3351
- doc.removeEventListener('mousemove', onMouseMove);
3352
- }
3353
-
3354
- function unsetGetReferenceClientRect() {
3355
- isInternalUpdate = true;
3356
- instance.setProps({
3357
- getReferenceClientRect: null
3358
- });
3359
- isInternalUpdate = false;
3360
- }
3361
-
3362
- function onMouseMove(event) {
3363
- // If the instance is interactive, avoid updating the position unless it's
3364
- // over the reference element
3365
- var isCursorOverReference = event.target ? reference.contains(event.target) : true;
3366
- var followCursor = instance.props.followCursor;
3367
- var clientX = event.clientX,
3368
- clientY = event.clientY;
3369
- var rect = reference.getBoundingClientRect();
3370
- var relativeX = clientX - rect.left;
3371
- var relativeY = clientY - rect.top;
3372
-
3373
- if (isCursorOverReference || !instance.props.interactive) {
3374
- instance.setProps({
3375
- // @ts-ignore - unneeded DOMRect properties
3376
- getReferenceClientRect: function getReferenceClientRect() {
3377
- var rect = reference.getBoundingClientRect();
3378
- var x = clientX;
3379
- var y = clientY;
3380
-
3381
- if (followCursor === 'initial') {
3382
- x = rect.left + relativeX;
3383
- y = rect.top + relativeY;
3384
- }
3385
-
3386
- var top = followCursor === 'horizontal' ? rect.top : y;
3387
- var right = followCursor === 'vertical' ? rect.right : x;
3388
- var bottom = followCursor === 'horizontal' ? rect.bottom : y;
3389
- var left = followCursor === 'vertical' ? rect.left : x;
3390
- return {
3391
- width: right - left,
3392
- height: bottom - top,
3393
- top: top,
3394
- right: right,
3395
- bottom: bottom,
3396
- left: left
3397
- };
3398
- }
3399
- });
3400
- }
3401
- }
3402
-
3403
- function create() {
3404
- if (instance.props.followCursor) {
3405
- activeInstances.push({
3406
- instance: instance,
3407
- doc: doc
3408
- });
3409
- addMouseCoordsListener(doc);
3410
- }
3411
- }
3412
-
3413
- function destroy() {
3414
- activeInstances = activeInstances.filter(function (data) {
3415
- return data.instance !== instance;
3416
- });
3417
-
3418
- if (activeInstances.filter(function (data) {
3419
- return data.doc === doc;
3420
- }).length === 0) {
3421
- removeMouseCoordsListener(doc);
3422
- }
3423
- }
3424
-
3425
- return {
3426
- onCreate: create,
3427
- onDestroy: destroy,
3428
- onBeforeUpdate: function onBeforeUpdate() {
3429
- prevProps = instance.props;
3430
- },
3431
- onAfterUpdate: function onAfterUpdate(_, _ref2) {
3432
- var followCursor = _ref2.followCursor;
3433
-
3434
- if (isInternalUpdate) {
3435
- return;
3436
- }
3437
-
3438
- if (followCursor !== undefined && prevProps.followCursor !== followCursor) {
3439
- destroy();
3440
-
3441
- if (followCursor) {
3442
- create();
3443
-
3444
- if (instance.state.isMounted && !wasFocusEvent && !getIsInitialBehavior()) {
3445
- addListener();
3446
- }
3447
- } else {
3448
- removeListener();
3449
- unsetGetReferenceClientRect();
3450
- }
3451
- }
3452
- },
3453
- onMount: function onMount() {
3454
- if (instance.props.followCursor && !wasFocusEvent) {
3455
- if (isUnmounted) {
3456
- onMouseMove(mouseCoords);
3457
- isUnmounted = false;
3458
- }
3459
-
3460
- if (!getIsInitialBehavior()) {
3461
- addListener();
3462
- }
3463
- }
3464
- },
3465
- onTrigger: function onTrigger(_, event) {
3466
- if (isMouseEvent(event)) {
3467
- mouseCoords = {
3468
- clientX: event.clientX,
3469
- clientY: event.clientY
3470
- };
3471
- }
3472
-
3473
- wasFocusEvent = event.type === 'focus';
3474
- },
3475
- onHidden: function onHidden() {
3476
- if (instance.props.followCursor) {
3477
- unsetGetReferenceClientRect();
3478
- removeListener();
3479
- isUnmounted = true;
3480
- }
3481
- }
3482
- };
3483
- }
3484
- };
3485
-
3486
- tippy.setDefaultProps({
3487
- render: render
3488
- });
3489
-
3490
- function _objectWithoutPropertiesLoose(source, excluded) {
3491
- if (source == null) return {};
3492
- var target = {};
3493
- var sourceKeys = Object.keys(source);
3494
- var key, i;
3495
-
3496
- for (i = 0; i < sourceKeys.length; i++) {
3497
- key = sourceKeys[i];
3498
- if (excluded.indexOf(key) >= 0) continue;
3499
- target[key] = source[key];
3500
- }
3501
-
3502
- return target;
3503
- }
3504
-
3505
- var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
3506
- function preserveRef(ref, node) {
3507
- if (ref) {
3508
- if (typeof ref === 'function') {
3509
- ref(node);
3510
- }
3511
-
3512
- if ({}.hasOwnProperty.call(ref, 'current')) {
3513
- ref.current = node;
3514
- }
3515
- }
3516
- }
3517
- function ssrSafeCreateDiv() {
3518
- return isBrowser && document.createElement('div');
3519
- }
3520
- function toDataAttributes(attrs) {
3521
- var dataAttrs = {
3522
- 'data-placement': attrs.placement
3523
- };
3524
-
3525
- if (attrs.referenceHidden) {
3526
- dataAttrs['data-reference-hidden'] = '';
3527
- }
3528
-
3529
- if (attrs.escaped) {
3530
- dataAttrs['data-escaped'] = '';
3531
- }
3532
-
3533
- return dataAttrs;
3534
- }
3535
-
3536
- function deepEqual(x, y) {
3537
- if (x === y) {
3538
- return true;
3539
- } else if (typeof x === 'object' && x != null && typeof y === 'object' && y != null) {
3540
- if (Object.keys(x).length !== Object.keys(y).length) {
3541
- return false;
3542
- }
3543
-
3544
- for (var prop in x) {
3545
- if (y.hasOwnProperty(prop)) {
3546
- if (!deepEqual(x[prop], y[prop])) {
3547
- return false;
3548
- }
3549
- } else {
3550
- return false;
3551
- }
3552
- }
3553
-
3554
- return true;
3555
- } else {
3556
- return false;
3557
- }
3558
- }
3559
-
3560
- function uniqueByShape(arr) {
3561
- var output = [];
3562
- arr.forEach(function (item) {
3563
- if (!output.find(function (outputItem) {
3564
- return deepEqual(item, outputItem);
3565
- })) {
3566
- output.push(item);
3567
- }
3568
- });
3569
- return output;
3570
- }
3571
- function deepPreserveProps(instanceProps, componentProps) {
3572
- var _instanceProps$popper, _componentProps$poppe;
3573
-
3574
- return Object.assign({}, componentProps, {
3575
- popperOptions: Object.assign({}, instanceProps.popperOptions, componentProps.popperOptions, {
3576
- modifiers: uniqueByShape([].concat(((_instanceProps$popper = instanceProps.popperOptions) == null ? void 0 : _instanceProps$popper.modifiers) || [], ((_componentProps$poppe = componentProps.popperOptions) == null ? void 0 : _componentProps$poppe.modifiers) || []))
3577
- })
3578
- });
3579
- }
3580
-
3581
- var useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;
3582
- function useMutableBox(initialValue) {
3583
- // Using refs instead of state as it's recommended to not store imperative
3584
- // values in state due to memory problems in React(?)
3585
- var ref = useRef();
3586
-
3587
- if (!ref.current) {
3588
- ref.current = typeof initialValue === 'function' ? initialValue() : initialValue;
3589
- }
3590
-
3591
- return ref.current;
3592
- }
3593
-
3594
- function updateClassName(box, action, classNames) {
3595
- classNames.split(/\s+/).forEach(function (name) {
3596
- if (name) {
3597
- box.classList[action](name);
3598
- }
3599
- });
3600
- }
3601
-
3602
- var classNamePlugin = {
3603
- name: 'className',
3604
- defaultValue: '',
3605
- fn: function fn(instance) {
3606
- var box = instance.popper.firstElementChild;
3607
-
3608
- var isDefaultRenderFn = function isDefaultRenderFn() {
3609
- var _instance$props$rende;
3610
-
3611
- return !!((_instance$props$rende = instance.props.render) == null ? void 0 : _instance$props$rende.$$tippy);
3612
- };
3613
-
3614
- function add() {
3615
- if (instance.props.className && !isDefaultRenderFn()) {
3616
-
3617
- return;
3618
- }
3619
-
3620
- updateClassName(box, 'add', instance.props.className);
3621
- }
3622
-
3623
- function remove() {
3624
- if (isDefaultRenderFn()) {
3625
- updateClassName(box, 'remove', instance.props.className);
3626
- }
3627
- }
3628
-
3629
- return {
3630
- onCreate: add,
3631
- onBeforeUpdate: remove,
3632
- onAfterUpdate: add
3633
- };
3634
- }
3635
- };
3636
-
3637
- function TippyGenerator(tippy) {
3638
- function Tippy(_ref) {
3639
- var children = _ref.children,
3640
- content = _ref.content,
3641
- visible = _ref.visible,
3642
- singleton = _ref.singleton,
3643
- render = _ref.render,
3644
- reference = _ref.reference,
3645
- _ref$disabled = _ref.disabled,
3646
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
3647
- _ref$ignoreAttributes = _ref.ignoreAttributes,
3648
- ignoreAttributes = _ref$ignoreAttributes === void 0 ? true : _ref$ignoreAttributes;
3649
- _ref.__source;
3650
- _ref.__self;
3651
- var restOfNativeProps = _objectWithoutPropertiesLoose(_ref, ["children", "content", "visible", "singleton", "render", "reference", "disabled", "ignoreAttributes", "__source", "__self"]);
3652
-
3653
- var isControlledMode = visible !== undefined;
3654
- var isSingletonMode = singleton !== undefined;
3655
-
3656
- var _useState = useState(false),
3657
- mounted = _useState[0],
3658
- setMounted = _useState[1];
3659
-
3660
- var _useState2 = useState({}),
3661
- attrs = _useState2[0],
3662
- setAttrs = _useState2[1];
3663
-
3664
- var _useState3 = useState(),
3665
- singletonContent = _useState3[0],
3666
- setSingletonContent = _useState3[1];
3667
-
3668
- var mutableBox = useMutableBox(function () {
3669
- return {
3670
- container: ssrSafeCreateDiv(),
3671
- renders: 1
3672
- };
3673
- });
3674
- var props = Object.assign({
3675
- ignoreAttributes: ignoreAttributes
3676
- }, restOfNativeProps, {
3677
- content: mutableBox.container
3678
- });
3679
-
3680
- if (isControlledMode) {
3681
-
3682
- props.trigger = 'manual';
3683
- props.hideOnClick = false;
3684
- }
3685
-
3686
- if (isSingletonMode) {
3687
- disabled = true;
3688
- }
3689
-
3690
- var computedProps = props;
3691
- var plugins = props.plugins || [];
3692
-
3693
- if (render) {
3694
- computedProps = Object.assign({}, props, {
3695
- plugins: isSingletonMode ? [].concat(plugins, [{
3696
- fn: function fn() {
3697
- return {
3698
- onTrigger: function onTrigger(_, event) {
3699
- var _singleton$data$child = singleton.data.children.find(function (_ref2) {
3700
- var instance = _ref2.instance;
3701
- return instance.reference === event.currentTarget;
3702
- }),
3703
- content = _singleton$data$child.content;
3704
-
3705
- setSingletonContent(content);
3706
- }
3707
- };
3708
- }
3709
- }]) : plugins,
3710
- render: function render() {
3711
- return {
3712
- popper: mutableBox.container
3713
- };
3714
- }
3715
- });
3716
- }
3717
-
3718
- var deps = [reference].concat(children ? [children.type] : []); // CREATE
3719
-
3720
- useIsomorphicLayoutEffect(function () {
3721
- var element = reference;
3722
-
3723
- if (reference && reference.hasOwnProperty('current')) {
3724
- element = reference.current;
3725
- }
3726
-
3727
- var instance = tippy(element || mutableBox.ref || ssrSafeCreateDiv(), Object.assign({}, computedProps, {
3728
- plugins: [classNamePlugin].concat(props.plugins || [])
3729
- }));
3730
- mutableBox.instance = instance;
3731
-
3732
- if (disabled) {
3733
- instance.disable();
3734
- }
3735
-
3736
- if (visible) {
3737
- instance.show();
3738
- }
3739
-
3740
- if (isSingletonMode) {
3741
- singleton.hook({
3742
- instance: instance,
3743
- content: content,
3744
- props: computedProps
3745
- });
3746
- }
3747
-
3748
- setMounted(true);
3749
- return function () {
3750
- instance.destroy();
3751
- singleton == null ? void 0 : singleton.cleanup(instance);
3752
- };
3753
- }, deps); // UPDATE
3754
-
3755
- useIsomorphicLayoutEffect(function () {
3756
- var _instance$popperInsta;
3757
-
3758
- // Prevent this effect from running on 1st render
3759
- if (mutableBox.renders === 1) {
3760
- mutableBox.renders++;
3761
- return;
3762
- }
3763
-
3764
- var instance = mutableBox.instance;
3765
- instance.setProps(deepPreserveProps(instance.props, computedProps)); // Fixes #264
3766
-
3767
- (_instance$popperInsta = instance.popperInstance) == null ? void 0 : _instance$popperInsta.forceUpdate();
3768
-
3769
- if (disabled) {
3770
- instance.disable();
3771
- } else {
3772
- instance.enable();
3773
- }
3774
-
3775
- if (isControlledMode) {
3776
- if (visible) {
3777
- instance.show();
3778
- } else {
3779
- instance.hide();
3780
- }
3781
- }
3782
-
3783
- if (isSingletonMode) {
3784
- singleton.hook({
3785
- instance: instance,
3786
- content: content,
3787
- props: computedProps
3788
- });
3789
- }
3790
- });
3791
- useIsomorphicLayoutEffect(function () {
3792
- var _instance$props$poppe;
3793
-
3794
- if (!render) {
3795
- return;
3796
- }
3797
-
3798
- var instance = mutableBox.instance;
3799
- instance.setProps({
3800
- popperOptions: Object.assign({}, instance.props.popperOptions, {
3801
- modifiers: [].concat((((_instance$props$poppe = instance.props.popperOptions) == null ? void 0 : _instance$props$poppe.modifiers) || []).filter(function (_ref3) {
3802
- var name = _ref3.name;
3803
- return name !== '$$tippyReact';
3804
- }), [{
3805
- name: '$$tippyReact',
3806
- enabled: true,
3807
- phase: 'beforeWrite',
3808
- requires: ['computeStyles'],
3809
- fn: function fn(_ref4) {
3810
- var _state$modifiersData;
3811
-
3812
- var state = _ref4.state;
3813
- var hideData = (_state$modifiersData = state.modifiersData) == null ? void 0 : _state$modifiersData.hide; // WARNING: this is a high-risk path that can cause an infinite
3814
- // loop. This expression _must_ evaluate to false when required
3815
-
3816
- if (attrs.placement !== state.placement || attrs.referenceHidden !== (hideData == null ? void 0 : hideData.isReferenceHidden) || attrs.escaped !== (hideData == null ? void 0 : hideData.hasPopperEscaped)) {
3817
- setAttrs({
3818
- placement: state.placement,
3819
- referenceHidden: hideData == null ? void 0 : hideData.isReferenceHidden,
3820
- escaped: hideData == null ? void 0 : hideData.hasPopperEscaped
3821
- });
3822
- }
3823
-
3824
- state.attributes.popper = {};
3825
- }
3826
- }])
3827
- })
3828
- });
3829
- }, [attrs.placement, attrs.referenceHidden, attrs.escaped].concat(deps));
3830
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, children ? /*#__PURE__*/cloneElement(children, {
3831
- ref: function ref(node) {
3832
- mutableBox.ref = node;
3833
- preserveRef(children.ref, node);
3834
- }
3835
- }) : null, mounted && /*#__PURE__*/createPortal(render ? render(toDataAttributes(attrs), singletonContent, mutableBox.instance) : content, mutableBox.container));
3836
- }
3837
-
3838
- return Tippy;
3839
- }
3840
-
3841
- var forwardRef = (function (Tippy, defaultProps) {
3842
- return /*#__PURE__*/forwardRef$1(function TippyWrapper(_ref, _ref2) {
3843
- var children = _ref.children,
3844
- props = _objectWithoutPropertiesLoose(_ref, ["children"]);
3845
-
3846
- return (
3847
- /*#__PURE__*/
3848
- // If I spread them separately here, Babel adds the _extends ponyfill for
3849
- // some reason
3850
- React__default.createElement(Tippy, Object.assign({}, defaultProps, props), children ? /*#__PURE__*/cloneElement(children, {
3851
- ref: function ref(node) {
3852
- preserveRef(_ref2, node);
3853
- preserveRef(children.ref, node);
3854
- }
3855
- }) : null)
3856
- );
3857
- });
3858
- });
3859
- var index = /*#__PURE__*/forwardRef( /*#__PURE__*/TippyGenerator(tippy));
3860
-
3861
- var ARROW = "<svg width='12' height='6' viewBox='0 0 10 5' fill='none' xmlns='http://www.w3.org/2000/svg'><path d='M10 5H0.926697L3.95208 1.63847C4.74227 0.760478 6.11722 0.754951 6.91445 1.62656L10 5Z' /></svg>";
3862
-
3863
- var _excluded = ["content", "children", "theme", "disabled", "position", "interactive", "hideAfter", "hideOnTargetExit"];
3864
- var Tooltip = function Tooltip(_ref) {
3865
- var content = _ref.content,
3866
- children = _ref.children,
3867
- _ref$theme = _ref.theme,
3868
- theme = _ref$theme === void 0 ? "dark" : _ref$theme,
3869
- _ref$disabled = _ref.disabled,
3870
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
3871
- _ref$position = _ref.position,
3872
- position = _ref$position === void 0 ? "auto" : _ref$position,
3873
- _ref$interactive = _ref.interactive,
3874
- interactive = _ref$interactive === void 0 ? false : _ref$interactive,
3875
- _ref$hideAfter = _ref.hideAfter,
3876
- hideAfter = _ref$hideAfter === void 0 ? -1 : _ref$hideAfter,
3877
- _ref$hideOnTargetExit = _ref.hideOnTargetExit,
3878
- hideOnTargetExit = _ref$hideOnTargetExit === void 0 ? false : _ref$hideOnTargetExit,
3879
- otherProps = _objectWithoutProperties(_ref, _excluded);
3880
- var _useState = useState(null),
3881
- _useState2 = _slicedToArray(_useState, 2),
3882
- instance = _useState2[0],
3883
- setInstance = _useState2[1];
3884
- var localProps = {};
3885
- if (hideAfter > 0) {
3886
- localProps["onShow"] = function (instance) {
3887
- return setTimeout(function () {
3888
- return instance.hide();
3889
- }, hideAfter);
3890
- };
3891
- }
3892
- useEffect(function () {
3893
- if (hideOnTargetExit) {
3894
- var intersectionObserver = new IntersectionObserver(function (entries) {
3895
- entries.forEach(function (entry) {
3896
- return !entry.isIntersecting && (instance === null || instance === void 0 ? void 0 : instance.hide());
3897
- });
3898
- });
3899
- (instance === null || instance === void 0 ? void 0 : instance.reference) && intersectionObserver.observe(instance === null || instance === void 0 ? void 0 : instance.reference);
3900
- return function () {
3901
- return intersectionObserver.disconnect();
3902
- };
3903
- }
3904
- return undefined;
3905
- }, [instance, hideOnTargetExit]);
3906
- return /*#__PURE__*/React__default.createElement(index, _extends({
3907
- animation: "scale-subtle",
3908
- arrow: ARROW,
3909
- content: content,
3910
- disabled: disabled,
3911
- duration: [100, 200],
3912
- interactive: interactive,
3913
- placement: position,
3914
- plugins: [followCursor],
3915
- role: "tooltip",
3916
- theme: theme,
3917
- zIndex: 100001,
3918
- onCreate: function onCreate(instance) {
3919
- var _instance$popper$firs;
3920
- setInstance(instance);
3921
- (_instance$popper$firs = instance.popper.firstElementChild) === null || _instance$popper$firs === void 0 || _instance$popper$firs.setAttribute("data-cy", "tooltip-box");
3922
- }
3923
- }, localProps, otherProps), /*#__PURE__*/React__default.isValidElement(children) ? children : /*#__PURE__*/React__default.createElement("span", null, children));
3924
- };
3925
-
3926
- export { Tooltip as T, index as i };
3927
- //# sourceMappingURL=index-2123b5e9.js.map