@storybook/components 6.5.7-alpha.0 → 7.0.0-alpha.1

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 (93) hide show
  1. package/dist/Color-GC2EERLU.mjs +1 -0
  2. package/dist/GlobalScrollAreaStyles-SBQA32UJ.mjs +1 -0
  3. package/dist/OverlayScrollbars-XXHHIFRP.mjs +6 -0
  4. package/dist/WithTooltip-2JKU54KI.mjs +9 -0
  5. package/dist/chunk-4HFE7HIP.mjs +6 -0
  6. package/dist/chunk-B5E6VV27.mjs +1 -0
  7. package/dist/chunk-HK5F4PFQ.mjs +1 -0
  8. package/dist/chunk-IE3SZHMD.mjs +1 -0
  9. package/dist/chunk-MGIUKE7Y.mjs +149 -0
  10. package/dist/chunk-SEEBCDLS.mjs +5 -0
  11. package/dist/chunk-X32VMURG.mjs +73 -0
  12. package/dist/chunk-XFP3TTPB.mjs +1 -0
  13. package/dist/chunk-YLDU3KBJ.mjs +1 -0
  14. package/dist/formatter-5ZDRIBVE.mjs +184 -0
  15. package/dist/html.d.ts +6 -0
  16. package/dist/html.js +352 -0
  17. package/dist/html.mjs +5 -0
  18. package/dist/index.d.ts +1144 -0
  19. package/dist/index.js +432 -0
  20. package/dist/index.mjs +1 -0
  21. package/dist/syntaxhighlighter-RDO7V73N.mjs +7 -0
  22. package/html.d.ts +1 -1
  23. package/html.js +1 -2
  24. package/package.json +31 -22
  25. package/dist/cjs/Color-90d9da2c.js +0 -2459
  26. package/dist/cjs/GlobalScrollAreaStyles-ff4bd929.js +0 -463
  27. package/dist/cjs/OverlayScrollbars-82979310.js +0 -6620
  28. package/dist/cjs/WithTooltip-60d59c62.js +0 -3166
  29. package/dist/cjs/formatter-adb74648.js +0 -128
  30. package/dist/cjs/index-97a2a5a9.js +0 -2060
  31. package/dist/cjs/index.js +0 -131
  32. package/dist/cjs/syntaxhighlighter-bc65a250.js +0 -211
  33. package/dist/esm/Color-01c31ae2.js +0 -2575
  34. package/dist/esm/GlobalScrollAreaStyles-8793ce4a.js +0 -461
  35. package/dist/esm/OverlayScrollbars-9b821cbe.js +0 -6709
  36. package/dist/esm/WithTooltip-2fc4c925.js +0 -3194
  37. package/dist/esm/formatter-9bb0ae57.js +0 -128
  38. package/dist/esm/index-3ae04fda.js +0 -2003
  39. package/dist/esm/index.js +0 -6
  40. package/dist/esm/syntaxhighlighter-b09267a2.js +0 -229
  41. package/dist/modern/Color-adcd690c.js +0 -2443
  42. package/dist/modern/GlobalScrollAreaStyles-8793ce4a.js +0 -450
  43. package/dist/modern/OverlayScrollbars-2dbee1e7.js +0 -6603
  44. package/dist/modern/WithTooltip-e676f2b3.js +0 -3125
  45. package/dist/modern/formatter-409edac5.js +0 -128
  46. package/dist/modern/index-377367fa.js +0 -2060
  47. package/dist/modern/index.js +0 -6
  48. package/dist/modern/syntaxhighlighter-a425409f.js +0 -157
  49. package/dist/ts-tmp/index.d.ts +0 -928
  50. package/dist/ts3.4/_modules/@popperjs-core-index.d.ts +0 -1
  51. package/dist/ts3.4/_modules/@popperjs-core-lib-createPopper.d.ts +0 -9
  52. package/dist/ts3.4/_modules/@popperjs-core-lib-enums.d.ts +0 -34
  53. package/dist/ts3.4/_modules/@popperjs-core-lib-index.d.ts +0 -6
  54. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-applyStyles.d.ts +0 -4
  55. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-arrow.d.ts +0 -13
  56. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-computeStyles.d.ts +0 -38
  57. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-eventListeners.d.ts +0 -8
  58. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-flip.d.ts +0 -16
  59. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-hide.d.ts +0 -4
  60. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-index.d.ts +0 -9
  61. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-offset.d.ts +0 -24
  62. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-popperOffsets.d.ts +0 -4
  63. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-preventOverflow.d.ts +0 -30
  64. package/dist/ts3.4/_modules/@popperjs-core-lib-popper-lite.d.ts +0 -5
  65. package/dist/ts3.4/_modules/@popperjs-core-lib-popper.d.ts +0 -7
  66. package/dist/ts3.4/_modules/@popperjs-core-lib-types.d.ts +0 -167
  67. package/dist/ts3.4/_modules/@popperjs-core-lib-utils-detectOverflow.d.ts +0 -11
  68. package/dist/ts3.4/_modules/@types-prettier-index.d.ts +0 -641
  69. package/dist/ts3.4/_modules/react-textarea-autosize-dist-declarations-src-index.d.ts +0 -17
  70. package/dist/ts3.4/_modules/react-textarea-autosize-dist-react-textarea-autosize.cjs.d.ts +0 -2
  71. package/dist/ts3.4/index.d.ts +0 -926
  72. package/dist/ts3.9/_modules/@popperjs-core-index.d.ts +0 -1
  73. package/dist/ts3.9/_modules/@popperjs-core-lib-createPopper.d.ts +0 -9
  74. package/dist/ts3.9/_modules/@popperjs-core-lib-enums.d.ts +0 -34
  75. package/dist/ts3.9/_modules/@popperjs-core-lib-index.d.ts +0 -6
  76. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-applyStyles.d.ts +0 -4
  77. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-arrow.d.ts +0 -13
  78. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-computeStyles.d.ts +0 -38
  79. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-eventListeners.d.ts +0 -8
  80. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-flip.d.ts +0 -16
  81. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-hide.d.ts +0 -4
  82. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-index.d.ts +0 -9
  83. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-offset.d.ts +0 -18
  84. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-popperOffsets.d.ts +0 -4
  85. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-preventOverflow.d.ts +0 -30
  86. package/dist/ts3.9/_modules/@popperjs-core-lib-popper-lite.d.ts +0 -5
  87. package/dist/ts3.9/_modules/@popperjs-core-lib-popper.d.ts +0 -7
  88. package/dist/ts3.9/_modules/@popperjs-core-lib-types.d.ts +0 -167
  89. package/dist/ts3.9/_modules/@popperjs-core-lib-utils-detectOverflow.d.ts +0 -11
  90. package/dist/ts3.9/_modules/@types-prettier-index.d.ts +0 -641
  91. package/dist/ts3.9/_modules/react-textarea-autosize-dist-declarations-src-index.d.ts +0 -17
  92. package/dist/ts3.9/_modules/react-textarea-autosize-dist-react-textarea-autosize.cjs.d.ts +0 -2
  93. package/dist/ts3.9/index.d.ts +0 -926
@@ -1,3194 +0,0 @@
1
- import "core-js/modules/es.symbol.js";
2
- import "core-js/modules/es.symbol.description.js";
3
- import "core-js/modules/es.symbol.iterator.js";
4
- import "core-js/modules/es.object.freeze.js";
5
-
6
- var _templateObject, _templateObject2;
7
-
8
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
-
10
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
-
12
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
-
14
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
15
-
16
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
17
-
18
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
-
20
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
21
-
22
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
23
-
24
- import "core-js/modules/es.object.to-string.js";
25
- import "core-js/modules/es.regexp.to-string.js";
26
- import "core-js/modules/web.dom-collections.for-each.js";
27
- import "core-js/modules/es.object.keys.js";
28
- import "core-js/modules/es.object.assign.js";
29
- import "core-js/modules/es.regexp.exec.js";
30
- import "core-js/modules/es.string.split.js";
31
- import "core-js/modules/es.array.filter.js";
32
- import "core-js/modules/es.function.name.js";
33
- import "core-js/modules/es.array.join.js";
34
- import "core-js/modules/es.array.concat.js";
35
- import "core-js/modules/es.string.replace.js";
36
- import "core-js/modules/es.array.sort.js";
37
- import "core-js/modules/es.array.iterator.js";
38
- import "core-js/modules/es.map.js";
39
- import "core-js/modules/es.string.iterator.js";
40
- import "core-js/modules/web.dom-collections.iterator.js";
41
- import "core-js/modules/es.array.find.js";
42
- import "core-js/modules/es.array.slice.js";
43
- import "core-js/modules/es.set.js";
44
- import "core-js/modules/es.promise.js";
45
- import "core-js/modules/es.array.map.js";
46
- import "core-js/modules/es.array-buffer.constructor.js";
47
- import "core-js/modules/es.regexp.constructor.js";
48
- import "core-js/modules/es.regexp.flags.js";
49
- import "core-js/modules/es.string.match.js";
50
- import "core-js/modules/es.array.includes.js";
51
- import "core-js/modules/es.string.includes.js";
52
- import "core-js/modules/es.string.starts-with.js";
53
- import "core-js/modules/es.array.from.js";
54
- import { b as basePlacements, t as top, l as left, e as bottom, r as right, f as end, v as viewport, s as start, p as popper, h as clippingParents, i as reference, j as variationPlacements, k as placements, n as auto, o as modifierPhases, q as _extends, u as _objectWithoutPropertiesLoose, m as memoizerific, a as __rest, w as window_1 } from './index-3ae04fda.js';
55
- import * as React from 'react';
56
- import React__default, { Component, useState, useCallback, useEffect } from 'react';
57
- import { styled, lighten, darken } from '@storybook/theming';
58
- import { createPortal } from 'react-dom';
59
- import '@storybook/csf';
60
- import 'qs';
61
- import '@storybook/client-logger';
62
-
63
- function getNodeName(element) {
64
- return element ? (element.nodeName || '').toLowerCase() : null;
65
- }
66
-
67
- function getWindow(node) {
68
- if (node == null) {
69
- return window;
70
- }
71
-
72
- if (node.toString() !== '[object Window]') {
73
- var ownerDocument = node.ownerDocument;
74
- return ownerDocument ? ownerDocument.defaultView || window : window;
75
- }
76
-
77
- return node;
78
- }
79
-
80
- function isElement(node) {
81
- var OwnElement = getWindow(node).Element;
82
- return node instanceof OwnElement || node instanceof Element;
83
- }
84
-
85
- function isHTMLElement(node) {
86
- var OwnElement = getWindow(node).HTMLElement;
87
- return node instanceof OwnElement || node instanceof HTMLElement;
88
- }
89
-
90
- function isShadowRoot(node) {
91
- // IE 11 has no ShadowRoot
92
- if (typeof ShadowRoot === 'undefined') {
93
- return false;
94
- }
95
-
96
- var OwnElement = getWindow(node).ShadowRoot;
97
- return node instanceof OwnElement || node instanceof ShadowRoot;
98
- } // and applies them to the HTMLElements such as popper and arrow
99
-
100
-
101
- function applyStyles(_ref) {
102
- var state = _ref.state;
103
- Object.keys(state.elements).forEach(function (name) {
104
- var style = state.styles[name] || {};
105
- var attributes = state.attributes[name] || {};
106
- var element = state.elements[name]; // arrow is optional + virtual elements
107
-
108
- if (!isHTMLElement(element) || !getNodeName(element)) {
109
- return;
110
- } // Flow doesn't support to extend this property, but it's the most
111
- // effective way to apply styles to an HTMLElement
112
- // $FlowFixMe[cannot-write]
113
-
114
-
115
- Object.assign(element.style, style);
116
- Object.keys(attributes).forEach(function (name) {
117
- var value = attributes[name];
118
-
119
- if (value === false) {
120
- element.removeAttribute(name);
121
- } else {
122
- element.setAttribute(name, value === true ? '' : value);
123
- }
124
- });
125
- });
126
- }
127
-
128
- function effect$2(_ref2) {
129
- var state = _ref2.state;
130
- var initialStyles = {
131
- popper: {
132
- position: state.options.strategy,
133
- left: '0',
134
- top: '0',
135
- margin: '0'
136
- },
137
- arrow: {
138
- position: 'absolute'
139
- },
140
- reference: {}
141
- };
142
- Object.assign(state.elements.popper.style, initialStyles.popper);
143
- state.styles = initialStyles;
144
-
145
- if (state.elements.arrow) {
146
- Object.assign(state.elements.arrow.style, initialStyles.arrow);
147
- }
148
-
149
- return function () {
150
- Object.keys(state.elements).forEach(function (name) {
151
- var element = state.elements[name];
152
- var attributes = state.attributes[name] || {};
153
- var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
154
-
155
- var style = styleProperties.reduce(function (style, property) {
156
- style[property] = '';
157
- return style;
158
- }, {}); // arrow is optional + virtual elements
159
-
160
- if (!isHTMLElement(element) || !getNodeName(element)) {
161
- return;
162
- }
163
-
164
- Object.assign(element.style, style);
165
- Object.keys(attributes).forEach(function (attribute) {
166
- element.removeAttribute(attribute);
167
- });
168
- });
169
- };
170
- } // eslint-disable-next-line import/no-unused-modules
171
-
172
-
173
- var applyStyles$1 = {
174
- name: 'applyStyles',
175
- enabled: true,
176
- phase: 'write',
177
- fn: applyStyles,
178
- effect: effect$2,
179
- requires: ['computeStyles']
180
- };
181
-
182
- function getBasePlacement(placement) {
183
- return placement.split('-')[0];
184
- }
185
-
186
- var max = Math.max;
187
- var min = Math.min;
188
- var round = Math.round;
189
-
190
- function getBoundingClientRect(element, includeScale) {
191
- if (includeScale === void 0) {
192
- includeScale = false;
193
- }
194
-
195
- var rect = element.getBoundingClientRect();
196
- var scaleX = 1;
197
- var scaleY = 1;
198
-
199
- if (isHTMLElement(element) && includeScale) {
200
- var offsetHeight = element.offsetHeight;
201
- var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
202
- // Fallback to 1 in case both values are `0`
203
-
204
- if (offsetWidth > 0) {
205
- scaleX = round(rect.width) / offsetWidth || 1;
206
- }
207
-
208
- if (offsetHeight > 0) {
209
- scaleY = round(rect.height) / offsetHeight || 1;
210
- }
211
- }
212
-
213
- return {
214
- width: rect.width / scaleX,
215
- height: rect.height / scaleY,
216
- top: rect.top / scaleY,
217
- right: rect.right / scaleX,
218
- bottom: rect.bottom / scaleY,
219
- left: rect.left / scaleX,
220
- x: rect.left / scaleX,
221
- y: rect.top / scaleY
222
- };
223
- } // means it doesn't take into account transforms.
224
-
225
-
226
- function getLayoutRect(element) {
227
- var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
228
- // Fixes https://github.com/popperjs/popper-core/issues/1223
229
-
230
- var width = element.offsetWidth;
231
- var height = element.offsetHeight;
232
-
233
- if (Math.abs(clientRect.width - width) <= 1) {
234
- width = clientRect.width;
235
- }
236
-
237
- if (Math.abs(clientRect.height - height) <= 1) {
238
- height = clientRect.height;
239
- }
240
-
241
- return {
242
- x: element.offsetLeft,
243
- y: element.offsetTop,
244
- width: width,
245
- height: height
246
- };
247
- }
248
-
249
- function contains(parent, child) {
250
- var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
251
-
252
- if (parent.contains(child)) {
253
- return true;
254
- } // then fallback to custom implementation with Shadow DOM support
255
- else if (rootNode && isShadowRoot(rootNode)) {
256
- var next = child;
257
-
258
- do {
259
- if (next && parent.isSameNode(next)) {
260
- return true;
261
- } // $FlowFixMe[prop-missing]: need a better way to handle this...
262
-
263
-
264
- next = next.parentNode || next.host;
265
- } while (next);
266
- } // Give up, the result is false
267
-
268
-
269
- return false;
270
- }
271
-
272
- function getComputedStyle(element) {
273
- return getWindow(element).getComputedStyle(element);
274
- }
275
-
276
- function isTableElement(element) {
277
- return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
278
- }
279
-
280
- function getDocumentElement(element) {
281
- // $FlowFixMe[incompatible-return]: assume body is always available
282
- return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
283
- element.document) || window.document).documentElement;
284
- }
285
-
286
- function getParentNode(element) {
287
- if (getNodeName(element) === 'html') {
288
- return element;
289
- }
290
-
291
- return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
292
- // $FlowFixMe[incompatible-return]
293
- // $FlowFixMe[prop-missing]
294
- element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
295
- element.parentNode || ( // DOM Element detected
296
- isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
297
- // $FlowFixMe[incompatible-call]: HTMLElement is a Node
298
- getDocumentElement(element) // fallback
299
-
300
- );
301
- }
302
-
303
- function getTrueOffsetParent(element) {
304
- if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
305
- getComputedStyle(element).position === 'fixed') {
306
- return null;
307
- }
308
-
309
- return element.offsetParent;
310
- } // `.offsetParent` reports `null` for fixed elements, while absolute elements
311
- // return the containing block
312
-
313
-
314
- function getContainingBlock(element) {
315
- var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1;
316
- var isIE = navigator.userAgent.indexOf('Trident') !== -1;
317
-
318
- if (isIE && isHTMLElement(element)) {
319
- // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
320
- var elementCss = getComputedStyle(element);
321
-
322
- if (elementCss.position === 'fixed') {
323
- return null;
324
- }
325
- }
326
-
327
- var currentNode = getParentNode(element);
328
-
329
- while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
330
- var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
331
- // create a containing block.
332
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
333
-
334
- 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') {
335
- return currentNode;
336
- } else {
337
- currentNode = currentNode.parentNode;
338
- }
339
- }
340
-
341
- return null;
342
- } // Gets the closest ancestor positioned element. Handles some edge cases,
343
- // such as table ancestors and cross browser bugs.
344
-
345
-
346
- function getOffsetParent(element) {
347
- var window = getWindow(element);
348
- var offsetParent = getTrueOffsetParent(element);
349
-
350
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
351
- offsetParent = getTrueOffsetParent(offsetParent);
352
- }
353
-
354
- if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
355
- return window;
356
- }
357
-
358
- return offsetParent || getContainingBlock(element) || window;
359
- }
360
-
361
- function getMainAxisFromPlacement(placement) {
362
- return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
363
- }
364
-
365
- function within(min$1, value, max$1) {
366
- return max(min$1, min(value, max$1));
367
- }
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(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 (process.env.NODE_ENV !== "production") {
458
- if (!isHTMLElement(arrowElement)) {
459
- console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).', 'To use an SVG arrow, wrap it in an HTMLElement that will be used as', 'the arrow.'].join(' '));
460
- }
461
- }
462
-
463
- if (!contains(state.elements.popper, arrowElement)) {
464
- if (process.env.NODE_ENV !== "production") {
465
- console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', 'element.'].join(' '));
466
- }
467
-
468
- return;
469
- }
470
-
471
- state.elements.arrow = arrowElement;
472
- } // eslint-disable-next-line import/no-unused-modules
473
-
474
-
475
- var arrow$1 = {
476
- name: 'arrow',
477
- enabled: true,
478
- phase: 'main',
479
- fn: arrow,
480
- effect: effect$1,
481
- requires: ['popperOffsets'],
482
- requiresIfExists: ['preventOverflow']
483
- };
484
-
485
- function getVariation(placement) {
486
- return placement.split('-')[1];
487
- }
488
-
489
- var unsetSides = {
490
- top: 'auto',
491
- right: 'auto',
492
- bottom: 'auto',
493
- left: 'auto'
494
- }; // Round the offsets to the nearest suitable subpixel based on the DPR.
495
- // Zooming can change the DPR, but it seems to report a value that will
496
- // cleanly divide the values into the appropriate subpixels.
497
-
498
- function roundOffsetsByDPR(_ref) {
499
- var x = _ref.x,
500
- y = _ref.y;
501
- var win = window;
502
- var dpr = win.devicePixelRatio || 1;
503
- return {
504
- x: round(x * dpr) / dpr || 0,
505
- y: round(y * dpr) / dpr || 0
506
- };
507
- }
508
-
509
- function mapToStyles(_ref2) {
510
- var _Object$assign2;
511
-
512
- var popper = _ref2.popper,
513
- popperRect = _ref2.popperRect,
514
- placement = _ref2.placement,
515
- variation = _ref2.variation,
516
- offsets = _ref2.offsets,
517
- position = _ref2.position,
518
- gpuAcceleration = _ref2.gpuAcceleration,
519
- adaptive = _ref2.adaptive,
520
- roundOffsets = _ref2.roundOffsets,
521
- isFixed = _ref2.isFixed;
522
- var _offsets$x = offsets.x,
523
- x = _offsets$x === void 0 ? 0 : _offsets$x,
524
- _offsets$y = offsets.y,
525
- y = _offsets$y === void 0 ? 0 : _offsets$y;
526
-
527
- var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
528
- x: x,
529
- y: y
530
- }) : {
531
- x: x,
532
- y: y
533
- };
534
-
535
- x = _ref3.x;
536
- y = _ref3.y;
537
- var hasX = offsets.hasOwnProperty('x');
538
- var hasY = offsets.hasOwnProperty('y');
539
- var sideX = left;
540
- var sideY = top;
541
- var win = window;
542
-
543
- if (adaptive) {
544
- var offsetParent = getOffsetParent(popper);
545
- var heightProp = 'clientHeight';
546
- var widthProp = 'clientWidth';
547
-
548
- if (offsetParent === getWindow(popper)) {
549
- offsetParent = getDocumentElement(popper);
550
-
551
- if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
552
- heightProp = 'scrollHeight';
553
- widthProp = 'scrollWidth';
554
- }
555
- } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
556
-
557
-
558
- offsetParent = offsetParent;
559
-
560
- if (placement === top || (placement === left || placement === right) && variation === end) {
561
- sideY = bottom;
562
- var offsetY = isFixed && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
563
- offsetParent[heightProp];
564
- y -= offsetY - popperRect.height;
565
- y *= gpuAcceleration ? 1 : -1;
566
- }
567
-
568
- if (placement === left || (placement === top || placement === bottom) && variation === end) {
569
- sideX = right;
570
- var offsetX = isFixed && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
571
- offsetParent[widthProp];
572
- x -= offsetX - popperRect.width;
573
- x *= gpuAcceleration ? 1 : -1;
574
- }
575
- }
576
-
577
- var commonStyles = Object.assign({
578
- position: position
579
- }, adaptive && unsetSides);
580
-
581
- var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
582
- x: x,
583
- y: y
584
- }) : {
585
- x: x,
586
- y: y
587
- };
588
-
589
- x = _ref4.x;
590
- y = _ref4.y;
591
-
592
- if (gpuAcceleration) {
593
- var _Object$assign;
594
-
595
- 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));
596
- }
597
-
598
- return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
599
- }
600
-
601
- function computeStyles(_ref5) {
602
- var state = _ref5.state,
603
- options = _ref5.options;
604
- var _options$gpuAccelerat = options.gpuAcceleration,
605
- gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
606
- _options$adaptive = options.adaptive,
607
- adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
608
- _options$roundOffsets = options.roundOffsets,
609
- roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
610
-
611
- if (process.env.NODE_ENV !== "production") {
612
- var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || '';
613
-
614
- if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {
615
- return transitionProperty.indexOf(property) >= 0;
616
- })) {
617
- console.warn(['Popper: Detected CSS transitions on at least one of the following', 'CSS properties: "transform", "top", "right", "bottom", "left".', '\n\n', 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', 'for smooth transitions, or remove these properties from the CSS', 'transition declaration on the popper element if only transitioning', 'opacity or background-color for example.', '\n\n', 'We recommend using the popper element as a wrapper around an inner', 'element that can have any CSS property transitioned for animations.'].join(' '));
618
- }
619
- }
620
-
621
- var commonStyles = {
622
- placement: getBasePlacement(state.placement),
623
- variation: getVariation(state.placement),
624
- popper: state.elements.popper,
625
- popperRect: state.rects.popper,
626
- gpuAcceleration: gpuAcceleration,
627
- isFixed: state.options.strategy === 'fixed'
628
- };
629
-
630
- if (state.modifiersData.popperOffsets != null) {
631
- state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
632
- offsets: state.modifiersData.popperOffsets,
633
- position: state.options.strategy,
634
- adaptive: adaptive,
635
- roundOffsets: roundOffsets
636
- })));
637
- }
638
-
639
- if (state.modifiersData.arrow != null) {
640
- state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
641
- offsets: state.modifiersData.arrow,
642
- position: 'absolute',
643
- adaptive: false,
644
- roundOffsets: roundOffsets
645
- })));
646
- }
647
-
648
- state.attributes.popper = Object.assign({}, state.attributes.popper, {
649
- 'data-popper-placement': state.placement
650
- });
651
- } // eslint-disable-next-line import/no-unused-modules
652
-
653
-
654
- var computeStyles$1 = {
655
- name: 'computeStyles',
656
- enabled: true,
657
- phase: 'beforeWrite',
658
- fn: computeStyles,
659
- data: {}
660
- };
661
- var passive = {
662
- passive: true
663
- };
664
-
665
- function effect(_ref) {
666
- var state = _ref.state,
667
- instance = _ref.instance,
668
- options = _ref.options;
669
- var _options$scroll = options.scroll,
670
- scroll = _options$scroll === void 0 ? true : _options$scroll,
671
- _options$resize = options.resize,
672
- resize = _options$resize === void 0 ? true : _options$resize;
673
- var window = getWindow(state.elements.popper);
674
- var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
675
-
676
- if (scroll) {
677
- scrollParents.forEach(function (scrollParent) {
678
- scrollParent.addEventListener('scroll', instance.update, passive);
679
- });
680
- }
681
-
682
- if (resize) {
683
- window.addEventListener('resize', instance.update, passive);
684
- }
685
-
686
- return function () {
687
- if (scroll) {
688
- scrollParents.forEach(function (scrollParent) {
689
- scrollParent.removeEventListener('scroll', instance.update, passive);
690
- });
691
- }
692
-
693
- if (resize) {
694
- window.removeEventListener('resize', instance.update, passive);
695
- }
696
- };
697
- } // eslint-disable-next-line import/no-unused-modules
698
-
699
-
700
- var eventListeners = {
701
- name: 'eventListeners',
702
- enabled: true,
703
- phase: 'write',
704
- fn: function fn() {},
705
- effect: effect,
706
- data: {}
707
- };
708
- var hash$1 = {
709
- left: 'right',
710
- right: 'left',
711
- bottom: 'top',
712
- top: 'bottom'
713
- };
714
-
715
- function getOppositePlacement(placement) {
716
- return placement.replace(/left|right|bottom|top/g, function (matched) {
717
- return hash$1[matched];
718
- });
719
- }
720
-
721
- var hash = {
722
- start: 'end',
723
- end: 'start'
724
- };
725
-
726
- function getOppositeVariationPlacement(placement) {
727
- return placement.replace(/start|end/g, function (matched) {
728
- return hash[matched];
729
- });
730
- }
731
-
732
- function getWindowScroll(node) {
733
- var win = getWindow(node);
734
- var scrollLeft = win.pageXOffset;
735
- var scrollTop = win.pageYOffset;
736
- return {
737
- scrollLeft: scrollLeft,
738
- scrollTop: scrollTop
739
- };
740
- }
741
-
742
- function getWindowScrollBarX(element) {
743
- // If <html> has a CSS width greater than the viewport, then this will be
744
- // incorrect for RTL.
745
- // Popper 1 is broken in this case and never had a bug report so let's assume
746
- // it's not an issue. I don't think anyone ever specifies width on <html>
747
- // anyway.
748
- // Browsers where the left scrollbar doesn't cause an issue report `0` for
749
- // this (e.g. Edge 2019, IE11, Safari)
750
- return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
751
- }
752
-
753
- function getViewportRect(element) {
754
- var win = getWindow(element);
755
- var html = getDocumentElement(element);
756
- var visualViewport = win.visualViewport;
757
- var width = html.clientWidth;
758
- var height = html.clientHeight;
759
- var x = 0;
760
- var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
761
- // can be obscured underneath it.
762
- // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
763
- // if it isn't open, so if this isn't available, the popper will be detected
764
- // to overflow the bottom of the screen too early.
765
-
766
- if (visualViewport) {
767
- width = visualViewport.width;
768
- height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
769
- // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
770
- // errors due to floating point numbers, so we need to check precision.
771
- // Safari returns a number <= 0, usually < -1 when pinch-zoomed
772
- // Feature detection fails in mobile emulation mode in Chrome.
773
- // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
774
- // 0.001
775
- // Fallback here: "Not Safari" userAgent
776
-
777
- if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
778
- x = visualViewport.offsetLeft;
779
- y = visualViewport.offsetTop;
780
- }
781
- }
782
-
783
- return {
784
- width: width,
785
- height: height,
786
- x: x + getWindowScrollBarX(element),
787
- y: y
788
- };
789
- } // of the `<html>` and `<body>` rect bounds if horizontally scrollable
790
-
791
-
792
- function getDocumentRect(element) {
793
- var _element$ownerDocumen;
794
-
795
- var html = getDocumentElement(element);
796
- var winScroll = getWindowScroll(element);
797
- var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
798
- var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
799
- var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
800
- var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
801
- var y = -winScroll.scrollTop;
802
-
803
- if (getComputedStyle(body || html).direction === 'rtl') {
804
- x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
805
- }
806
-
807
- return {
808
- width: width,
809
- height: height,
810
- x: x,
811
- y: y
812
- };
813
- }
814
-
815
- function isScrollParent(element) {
816
- // Firefox wants us to check `-x` and `-y` variations as well
817
- var _getComputedStyle = getComputedStyle(element),
818
- overflow = _getComputedStyle.overflow,
819
- overflowX = _getComputedStyle.overflowX,
820
- overflowY = _getComputedStyle.overflowY;
821
-
822
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
823
- }
824
-
825
- function getScrollParent(node) {
826
- if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
827
- // $FlowFixMe[incompatible-return]: assume body is always available
828
- return node.ownerDocument.body;
829
- }
830
-
831
- if (isHTMLElement(node) && isScrollParent(node)) {
832
- return node;
833
- }
834
-
835
- return getScrollParent(getParentNode(node));
836
- }
837
- /*
838
- given a DOM element, return the list of all scroll parents, up the list of ancesors
839
- until we get to the top window object. This list is what we attach scroll listeners
840
- to, because if any of these parent elements scroll, we'll need to re-calculate the
841
- reference element's position.
842
- */
843
-
844
-
845
- function listScrollParents(element, list) {
846
- var _element$ownerDocumen;
847
-
848
- if (list === void 0) {
849
- list = [];
850
- }
851
-
852
- var scrollParent = getScrollParent(element);
853
- var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
854
- var win = getWindow(scrollParent);
855
- var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
856
- var updatedList = list.concat(target);
857
- return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
858
- updatedList.concat(listScrollParents(getParentNode(target)));
859
- }
860
-
861
- function rectToClientRect(rect) {
862
- return Object.assign({}, rect, {
863
- left: rect.x,
864
- top: rect.y,
865
- right: rect.x + rect.width,
866
- bottom: rect.y + rect.height
867
- });
868
- }
869
-
870
- function getInnerBoundingClientRect(element) {
871
- var rect = getBoundingClientRect(element);
872
- rect.top = rect.top + element.clientTop;
873
- rect.left = rect.left + element.clientLeft;
874
- rect.bottom = rect.top + element.clientHeight;
875
- rect.right = rect.left + element.clientWidth;
876
- rect.width = element.clientWidth;
877
- rect.height = element.clientHeight;
878
- rect.x = rect.left;
879
- rect.y = rect.top;
880
- return rect;
881
- }
882
-
883
- function getClientRectFromMixedType(element, clippingParent) {
884
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
885
- } // A "clipping parent" is an overflowable container with the characteristic of
886
- // clipping (or hiding) overflowing elements with a position different from
887
- // `initial`
888
-
889
-
890
- function getClippingParents(element) {
891
- var clippingParents = listScrollParents(getParentNode(element));
892
- var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
893
- var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
894
-
895
- if (!isElement(clipperElement)) {
896
- return [];
897
- } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
898
-
899
-
900
- return clippingParents.filter(function (clippingParent) {
901
- return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
902
- });
903
- } // Gets the maximum area that the element is visible in due to any number of
904
- // clipping parents
905
-
906
-
907
- function getClippingRect(element, boundary, rootBoundary) {
908
- var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
909
- var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
910
- var firstClippingParent = clippingParents[0];
911
- var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
912
- var rect = getClientRectFromMixedType(element, clippingParent);
913
- accRect.top = max(rect.top, accRect.top);
914
- accRect.right = min(rect.right, accRect.right);
915
- accRect.bottom = min(rect.bottom, accRect.bottom);
916
- accRect.left = max(rect.left, accRect.left);
917
- return accRect;
918
- }, getClientRectFromMixedType(element, firstClippingParent));
919
- clippingRect.width = clippingRect.right - clippingRect.left;
920
- clippingRect.height = clippingRect.bottom - clippingRect.top;
921
- clippingRect.x = clippingRect.left;
922
- clippingRect.y = clippingRect.top;
923
- return clippingRect;
924
- }
925
-
926
- function computeOffsets(_ref) {
927
- var reference = _ref.reference,
928
- element = _ref.element,
929
- placement = _ref.placement;
930
- var basePlacement = placement ? getBasePlacement(placement) : null;
931
- var variation = placement ? getVariation(placement) : null;
932
- var commonX = reference.x + reference.width / 2 - element.width / 2;
933
- var commonY = reference.y + reference.height / 2 - element.height / 2;
934
- var offsets;
935
-
936
- switch (basePlacement) {
937
- case top:
938
- offsets = {
939
- x: commonX,
940
- y: reference.y - element.height
941
- };
942
- break;
943
-
944
- case bottom:
945
- offsets = {
946
- x: commonX,
947
- y: reference.y + reference.height
948
- };
949
- break;
950
-
951
- case right:
952
- offsets = {
953
- x: reference.x + reference.width,
954
- y: commonY
955
- };
956
- break;
957
-
958
- case left:
959
- offsets = {
960
- x: reference.x - element.width,
961
- y: commonY
962
- };
963
- break;
964
-
965
- default:
966
- offsets = {
967
- x: reference.x,
968
- y: reference.y
969
- };
970
- }
971
-
972
- var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
973
-
974
- if (mainAxis != null) {
975
- var len = mainAxis === 'y' ? 'height' : 'width';
976
-
977
- switch (variation) {
978
- case start:
979
- offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
980
- break;
981
-
982
- case end:
983
- offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
984
- break;
985
- }
986
- }
987
-
988
- return offsets;
989
- }
990
-
991
- function detectOverflow(state, options) {
992
- if (options === void 0) {
993
- options = {};
994
- }
995
-
996
- var _options = options,
997
- _options$placement = _options.placement,
998
- placement = _options$placement === void 0 ? state.placement : _options$placement,
999
- _options$boundary = _options.boundary,
1000
- boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
1001
- _options$rootBoundary = _options.rootBoundary,
1002
- rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
1003
- _options$elementConte = _options.elementContext,
1004
- elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
1005
- _options$altBoundary = _options.altBoundary,
1006
- altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
1007
- _options$padding = _options.padding,
1008
- padding = _options$padding === void 0 ? 0 : _options$padding;
1009
- var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
1010
- var altContext = elementContext === popper ? reference : popper;
1011
- var popperRect = state.rects.popper;
1012
- var element = state.elements[altBoundary ? altContext : elementContext];
1013
- var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
1014
- var referenceClientRect = getBoundingClientRect(state.elements.reference);
1015
- var popperOffsets = computeOffsets({
1016
- reference: referenceClientRect,
1017
- element: popperRect,
1018
- strategy: 'absolute',
1019
- placement: placement
1020
- });
1021
- var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
1022
- var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
1023
- // 0 or negative = within the clipping rect
1024
-
1025
- var overflowOffsets = {
1026
- top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
1027
- bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
1028
- left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
1029
- right: elementClientRect.right - clippingClientRect.right + paddingObject.right
1030
- };
1031
- var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
1032
-
1033
- if (elementContext === popper && offsetData) {
1034
- var offset = offsetData[placement];
1035
- Object.keys(overflowOffsets).forEach(function (key) {
1036
- var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
1037
- var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
1038
- overflowOffsets[key] += offset[axis] * multiply;
1039
- });
1040
- }
1041
-
1042
- return overflowOffsets;
1043
- }
1044
-
1045
- function computeAutoPlacement(state, options) {
1046
- if (options === void 0) {
1047
- options = {};
1048
- }
1049
-
1050
- var _options = options,
1051
- placement = _options.placement,
1052
- boundary = _options.boundary,
1053
- rootBoundary = _options.rootBoundary,
1054
- padding = _options.padding,
1055
- flipVariations = _options.flipVariations,
1056
- _options$allowedAutoP = _options.allowedAutoPlacements,
1057
- allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
1058
- var variation = getVariation(placement);
1059
- var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
1060
- return getVariation(placement) === variation;
1061
- }) : basePlacements;
1062
- var allowedPlacements = placements$1.filter(function (placement) {
1063
- return allowedAutoPlacements.indexOf(placement) >= 0;
1064
- });
1065
-
1066
- if (allowedPlacements.length === 0) {
1067
- allowedPlacements = placements$1;
1068
-
1069
- if (process.env.NODE_ENV !== "production") {
1070
- console.error(['Popper: The `allowedAutoPlacements` option did not allow any', 'placements. Ensure the `placement` option matches the variation', 'of the allowed placements.', 'For example, "auto" cannot be used to allow "bottom-start".', 'Use "auto-start" instead.'].join(' '));
1071
- }
1072
- } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
1073
-
1074
-
1075
- var overflows = allowedPlacements.reduce(function (acc, placement) {
1076
- acc[placement] = detectOverflow(state, {
1077
- placement: placement,
1078
- boundary: boundary,
1079
- rootBoundary: rootBoundary,
1080
- padding: padding
1081
- })[getBasePlacement(placement)];
1082
- return acc;
1083
- }, {});
1084
- return Object.keys(overflows).sort(function (a, b) {
1085
- return overflows[a] - overflows[b];
1086
- });
1087
- }
1088
-
1089
- function getExpandedFallbackPlacements(placement) {
1090
- if (getBasePlacement(placement) === auto) {
1091
- return [];
1092
- }
1093
-
1094
- var oppositePlacement = getOppositePlacement(placement);
1095
- return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
1096
- }
1097
-
1098
- function flip(_ref) {
1099
- var state = _ref.state,
1100
- options = _ref.options,
1101
- name = _ref.name;
1102
-
1103
- if (state.modifiersData[name]._skip) {
1104
- return;
1105
- }
1106
-
1107
- var _options$mainAxis = options.mainAxis,
1108
- checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1109
- _options$altAxis = options.altAxis,
1110
- checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
1111
- specifiedFallbackPlacements = options.fallbackPlacements,
1112
- padding = options.padding,
1113
- boundary = options.boundary,
1114
- rootBoundary = options.rootBoundary,
1115
- altBoundary = options.altBoundary,
1116
- _options$flipVariatio = options.flipVariations,
1117
- flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
1118
- allowedAutoPlacements = options.allowedAutoPlacements;
1119
- var preferredPlacement = state.options.placement;
1120
- var basePlacement = getBasePlacement(preferredPlacement);
1121
- var isBasePlacement = basePlacement === preferredPlacement;
1122
- var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
1123
- var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
1124
- return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
1125
- placement: placement,
1126
- boundary: boundary,
1127
- rootBoundary: rootBoundary,
1128
- padding: padding,
1129
- flipVariations: flipVariations,
1130
- allowedAutoPlacements: allowedAutoPlacements
1131
- }) : placement);
1132
- }, []);
1133
- var referenceRect = state.rects.reference;
1134
- var popperRect = state.rects.popper;
1135
- var checksMap = new Map();
1136
- var makeFallbackChecks = true;
1137
- var firstFittingPlacement = placements[0];
1138
-
1139
- for (var i = 0; i < placements.length; i++) {
1140
- var placement = placements[i];
1141
-
1142
- var _basePlacement = getBasePlacement(placement);
1143
-
1144
- var isStartVariation = getVariation(placement) === start;
1145
- var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
1146
- var len = isVertical ? 'width' : 'height';
1147
- var overflow = detectOverflow(state, {
1148
- placement: placement,
1149
- boundary: boundary,
1150
- rootBoundary: rootBoundary,
1151
- altBoundary: altBoundary,
1152
- padding: padding
1153
- });
1154
- var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
1155
-
1156
- if (referenceRect[len] > popperRect[len]) {
1157
- mainVariationSide = getOppositePlacement(mainVariationSide);
1158
- }
1159
-
1160
- var altVariationSide = getOppositePlacement(mainVariationSide);
1161
- var checks = [];
1162
-
1163
- if (checkMainAxis) {
1164
- checks.push(overflow[_basePlacement] <= 0);
1165
- }
1166
-
1167
- if (checkAltAxis) {
1168
- checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
1169
- }
1170
-
1171
- if (checks.every(function (check) {
1172
- return check;
1173
- })) {
1174
- firstFittingPlacement = placement;
1175
- makeFallbackChecks = false;
1176
- break;
1177
- }
1178
-
1179
- checksMap.set(placement, checks);
1180
- }
1181
-
1182
- if (makeFallbackChecks) {
1183
- // `2` may be desired in some cases – research later
1184
- var numberOfChecks = flipVariations ? 3 : 1;
1185
-
1186
- var _loop = function _loop(_i) {
1187
- var fittingPlacement = placements.find(function (placement) {
1188
- var checks = checksMap.get(placement);
1189
-
1190
- if (checks) {
1191
- return checks.slice(0, _i).every(function (check) {
1192
- return check;
1193
- });
1194
- }
1195
- });
1196
-
1197
- if (fittingPlacement) {
1198
- firstFittingPlacement = fittingPlacement;
1199
- return "break";
1200
- }
1201
- };
1202
-
1203
- for (var _i = numberOfChecks; _i > 0; _i--) {
1204
- var _ret = _loop(_i);
1205
-
1206
- if (_ret === "break") break;
1207
- }
1208
- }
1209
-
1210
- if (state.placement !== firstFittingPlacement) {
1211
- state.modifiersData[name]._skip = true;
1212
- state.placement = firstFittingPlacement;
1213
- state.reset = true;
1214
- }
1215
- } // eslint-disable-next-line import/no-unused-modules
1216
-
1217
-
1218
- var flip$1 = {
1219
- name: 'flip',
1220
- enabled: true,
1221
- phase: 'main',
1222
- fn: flip,
1223
- requiresIfExists: ['offset'],
1224
- data: {
1225
- _skip: false
1226
- }
1227
- };
1228
-
1229
- function getSideOffsets(overflow, rect, preventedOffsets) {
1230
- if (preventedOffsets === void 0) {
1231
- preventedOffsets = {
1232
- x: 0,
1233
- y: 0
1234
- };
1235
- }
1236
-
1237
- return {
1238
- top: overflow.top - rect.height - preventedOffsets.y,
1239
- right: overflow.right - rect.width + preventedOffsets.x,
1240
- bottom: overflow.bottom - rect.height + preventedOffsets.y,
1241
- left: overflow.left - rect.width - preventedOffsets.x
1242
- };
1243
- }
1244
-
1245
- function isAnySideFullyClipped(overflow) {
1246
- return [top, right, bottom, left].some(function (side) {
1247
- return overflow[side] >= 0;
1248
- });
1249
- }
1250
-
1251
- function hide(_ref) {
1252
- var state = _ref.state,
1253
- name = _ref.name;
1254
- var referenceRect = state.rects.reference;
1255
- var popperRect = state.rects.popper;
1256
- var preventedOffsets = state.modifiersData.preventOverflow;
1257
- var referenceOverflow = detectOverflow(state, {
1258
- elementContext: 'reference'
1259
- });
1260
- var popperAltOverflow = detectOverflow(state, {
1261
- altBoundary: true
1262
- });
1263
- var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
1264
- var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
1265
- var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
1266
- var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
1267
- state.modifiersData[name] = {
1268
- referenceClippingOffsets: referenceClippingOffsets,
1269
- popperEscapeOffsets: popperEscapeOffsets,
1270
- isReferenceHidden: isReferenceHidden,
1271
- hasPopperEscaped: hasPopperEscaped
1272
- };
1273
- state.attributes.popper = Object.assign({}, state.attributes.popper, {
1274
- 'data-popper-reference-hidden': isReferenceHidden,
1275
- 'data-popper-escaped': hasPopperEscaped
1276
- });
1277
- } // eslint-disable-next-line import/no-unused-modules
1278
-
1279
-
1280
- var hide$1 = {
1281
- name: 'hide',
1282
- enabled: true,
1283
- phase: 'main',
1284
- requiresIfExists: ['preventOverflow'],
1285
- fn: hide
1286
- };
1287
-
1288
- function distanceAndSkiddingToXY(placement, rects, offset) {
1289
- var basePlacement = getBasePlacement(placement);
1290
- var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
1291
-
1292
- var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
1293
- placement: placement
1294
- })) : offset,
1295
- skidding = _ref[0],
1296
- distance = _ref[1];
1297
-
1298
- skidding = skidding || 0;
1299
- distance = (distance || 0) * invertDistance;
1300
- return [left, right].indexOf(basePlacement) >= 0 ? {
1301
- x: distance,
1302
- y: skidding
1303
- } : {
1304
- x: skidding,
1305
- y: distance
1306
- };
1307
- }
1308
-
1309
- function offset(_ref2) {
1310
- var state = _ref2.state,
1311
- options = _ref2.options,
1312
- name = _ref2.name;
1313
- var _options$offset = options.offset,
1314
- offset = _options$offset === void 0 ? [0, 0] : _options$offset;
1315
- var data = placements.reduce(function (acc, placement) {
1316
- acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
1317
- return acc;
1318
- }, {});
1319
- var _data$state$placement = data[state.placement],
1320
- x = _data$state$placement.x,
1321
- y = _data$state$placement.y;
1322
-
1323
- if (state.modifiersData.popperOffsets != null) {
1324
- state.modifiersData.popperOffsets.x += x;
1325
- state.modifiersData.popperOffsets.y += y;
1326
- }
1327
-
1328
- state.modifiersData[name] = data;
1329
- } // eslint-disable-next-line import/no-unused-modules
1330
-
1331
-
1332
- var offset$1 = {
1333
- name: 'offset',
1334
- enabled: true,
1335
- phase: 'main',
1336
- requires: ['popperOffsets'],
1337
- fn: offset
1338
- };
1339
-
1340
- function popperOffsets(_ref) {
1341
- var state = _ref.state,
1342
- name = _ref.name; // Offsets are the actual position the popper needs to have to be
1343
- // properly positioned near its reference element
1344
- // This is the most basic placement, and will be adjusted by
1345
- // the modifiers in the next step
1346
-
1347
- state.modifiersData[name] = computeOffsets({
1348
- reference: state.rects.reference,
1349
- element: state.rects.popper,
1350
- strategy: 'absolute',
1351
- placement: state.placement
1352
- });
1353
- } // eslint-disable-next-line import/no-unused-modules
1354
-
1355
-
1356
- var popperOffsets$1 = {
1357
- name: 'popperOffsets',
1358
- enabled: true,
1359
- phase: 'read',
1360
- fn: popperOffsets,
1361
- data: {}
1362
- };
1363
-
1364
- function getAltAxis(axis) {
1365
- return axis === 'x' ? 'y' : 'x';
1366
- }
1367
-
1368
- function preventOverflow(_ref) {
1369
- var state = _ref.state,
1370
- options = _ref.options,
1371
- name = _ref.name;
1372
- var _options$mainAxis = options.mainAxis,
1373
- checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1374
- _options$altAxis = options.altAxis,
1375
- checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
1376
- boundary = options.boundary,
1377
- rootBoundary = options.rootBoundary,
1378
- altBoundary = options.altBoundary,
1379
- padding = options.padding,
1380
- _options$tether = options.tether,
1381
- tether = _options$tether === void 0 ? true : _options$tether,
1382
- _options$tetherOffset = options.tetherOffset,
1383
- tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
1384
- var overflow = detectOverflow(state, {
1385
- boundary: boundary,
1386
- rootBoundary: rootBoundary,
1387
- padding: padding,
1388
- altBoundary: altBoundary
1389
- });
1390
- var basePlacement = getBasePlacement(state.placement);
1391
- var variation = getVariation(state.placement);
1392
- var isBasePlacement = !variation;
1393
- var mainAxis = getMainAxisFromPlacement(basePlacement);
1394
- var altAxis = getAltAxis(mainAxis);
1395
- var popperOffsets = state.modifiersData.popperOffsets;
1396
- var referenceRect = state.rects.reference;
1397
- var popperRect = state.rects.popper;
1398
- var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
1399
- placement: state.placement
1400
- })) : tetherOffset;
1401
- var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
1402
- mainAxis: tetherOffsetValue,
1403
- altAxis: tetherOffsetValue
1404
- } : Object.assign({
1405
- mainAxis: 0,
1406
- altAxis: 0
1407
- }, tetherOffsetValue);
1408
- var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
1409
- var data = {
1410
- x: 0,
1411
- y: 0
1412
- };
1413
-
1414
- if (!popperOffsets) {
1415
- return;
1416
- }
1417
-
1418
- if (checkMainAxis) {
1419
- var _offsetModifierState$;
1420
-
1421
- var mainSide = mainAxis === 'y' ? top : left;
1422
- var altSide = mainAxis === 'y' ? bottom : right;
1423
- var len = mainAxis === 'y' ? 'height' : 'width';
1424
- var offset = popperOffsets[mainAxis];
1425
- var min$1 = offset + overflow[mainSide];
1426
- var max$1 = offset - overflow[altSide];
1427
- var additive = tether ? -popperRect[len] / 2 : 0;
1428
- var minLen = variation === start ? referenceRect[len] : popperRect[len];
1429
- var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
1430
- // outside the reference bounds
1431
-
1432
- var arrowElement = state.elements.arrow;
1433
- var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
1434
- width: 0,
1435
- height: 0
1436
- };
1437
- var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
1438
- var arrowPaddingMin = arrowPaddingObject[mainSide];
1439
- var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
1440
- // to include its full size in the calculation. If the reference is small
1441
- // and near the edge of a boundary, the popper can overflow even if the
1442
- // reference is not overflowing as well (e.g. virtual elements with no
1443
- // width or height)
1444
-
1445
- var arrowLen = within(0, referenceRect[len], arrowRect[len]);
1446
- var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
1447
- var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
1448
- var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
1449
- var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
1450
- var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
1451
- var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
1452
- var tetherMax = offset + maxOffset - offsetModifierValue;
1453
- var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
1454
- popperOffsets[mainAxis] = preventedOffset;
1455
- data[mainAxis] = preventedOffset - offset;
1456
- }
1457
-
1458
- if (checkAltAxis) {
1459
- var _offsetModifierState$2;
1460
-
1461
- var _mainSide = mainAxis === 'x' ? top : left;
1462
-
1463
- var _altSide = mainAxis === 'x' ? bottom : right;
1464
-
1465
- var _offset = popperOffsets[altAxis];
1466
-
1467
- var _len = altAxis === 'y' ? 'height' : 'width';
1468
-
1469
- var _min = _offset + overflow[_mainSide];
1470
-
1471
- var _max = _offset - overflow[_altSide];
1472
-
1473
- var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
1474
-
1475
- var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
1476
-
1477
- var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
1478
-
1479
- var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
1480
-
1481
- var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
1482
-
1483
- popperOffsets[altAxis] = _preventedOffset;
1484
- data[altAxis] = _preventedOffset - _offset;
1485
- }
1486
-
1487
- state.modifiersData[name] = data;
1488
- } // eslint-disable-next-line import/no-unused-modules
1489
-
1490
-
1491
- var preventOverflow$1 = {
1492
- name: 'preventOverflow',
1493
- enabled: true,
1494
- phase: 'main',
1495
- fn: preventOverflow,
1496
- requiresIfExists: ['offset']
1497
- };
1498
-
1499
- function getHTMLElementScroll(element) {
1500
- return {
1501
- scrollLeft: element.scrollLeft,
1502
- scrollTop: element.scrollTop
1503
- };
1504
- }
1505
-
1506
- function getNodeScroll(node) {
1507
- if (node === getWindow(node) || !isHTMLElement(node)) {
1508
- return getWindowScroll(node);
1509
- } else {
1510
- return getHTMLElementScroll(node);
1511
- }
1512
- }
1513
-
1514
- function isElementScaled(element) {
1515
- var rect = element.getBoundingClientRect();
1516
- var scaleX = round(rect.width) / element.offsetWidth || 1;
1517
- var scaleY = round(rect.height) / element.offsetHeight || 1;
1518
- return scaleX !== 1 || scaleY !== 1;
1519
- } // Returns the composite rect of an element relative to its offsetParent.
1520
- // Composite means it takes into account transforms as well as layout.
1521
-
1522
-
1523
- function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
1524
- if (isFixed === void 0) {
1525
- isFixed = false;
1526
- }
1527
-
1528
- var isOffsetParentAnElement = isHTMLElement(offsetParent);
1529
- var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
1530
- var documentElement = getDocumentElement(offsetParent);
1531
- var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
1532
- var scroll = {
1533
- scrollLeft: 0,
1534
- scrollTop: 0
1535
- };
1536
- var offsets = {
1537
- x: 0,
1538
- y: 0
1539
- };
1540
-
1541
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1542
- if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
1543
- isScrollParent(documentElement)) {
1544
- scroll = getNodeScroll(offsetParent);
1545
- }
1546
-
1547
- if (isHTMLElement(offsetParent)) {
1548
- offsets = getBoundingClientRect(offsetParent, true);
1549
- offsets.x += offsetParent.clientLeft;
1550
- offsets.y += offsetParent.clientTop;
1551
- } else if (documentElement) {
1552
- offsets.x = getWindowScrollBarX(documentElement);
1553
- }
1554
- }
1555
-
1556
- return {
1557
- x: rect.left + scroll.scrollLeft - offsets.x,
1558
- y: rect.top + scroll.scrollTop - offsets.y,
1559
- width: rect.width,
1560
- height: rect.height
1561
- };
1562
- }
1563
-
1564
- function order(modifiers) {
1565
- var map = new Map();
1566
- var visited = new Set();
1567
- var result = [];
1568
- modifiers.forEach(function (modifier) {
1569
- map.set(modifier.name, modifier);
1570
- }); // On visiting object, check for its dependencies and visit them recursively
1571
-
1572
- function sort(modifier) {
1573
- visited.add(modifier.name);
1574
- var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
1575
- requires.forEach(function (dep) {
1576
- if (!visited.has(dep)) {
1577
- var depModifier = map.get(dep);
1578
-
1579
- if (depModifier) {
1580
- sort(depModifier);
1581
- }
1582
- }
1583
- });
1584
- result.push(modifier);
1585
- }
1586
-
1587
- modifiers.forEach(function (modifier) {
1588
- if (!visited.has(modifier.name)) {
1589
- // check for visited object
1590
- sort(modifier);
1591
- }
1592
- });
1593
- return result;
1594
- }
1595
-
1596
- function orderModifiers(modifiers) {
1597
- // order based on dependencies
1598
- var orderedModifiers = order(modifiers); // order based on phase
1599
-
1600
- return modifierPhases.reduce(function (acc, phase) {
1601
- return acc.concat(orderedModifiers.filter(function (modifier) {
1602
- return modifier.phase === phase;
1603
- }));
1604
- }, []);
1605
- }
1606
-
1607
- function debounce(fn) {
1608
- var pending;
1609
- return function () {
1610
- if (!pending) {
1611
- pending = new Promise(function (resolve) {
1612
- Promise.resolve().then(function () {
1613
- pending = undefined;
1614
- resolve(fn());
1615
- });
1616
- });
1617
- }
1618
-
1619
- return pending;
1620
- };
1621
- }
1622
-
1623
- function format(str) {
1624
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1625
- args[_key - 1] = arguments[_key];
1626
- }
1627
-
1628
- return [].concat(args).reduce(function (p, c) {
1629
- return p.replace(/%s/, c);
1630
- }, str);
1631
- }
1632
-
1633
- var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
1634
- var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
1635
- var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options'];
1636
-
1637
- function validateModifiers(modifiers) {
1638
- modifiers.forEach(function (modifier) {
1639
- [].concat(Object.keys(modifier), VALID_PROPERTIES) // IE11-compatible replacement for `new Set(iterable)`
1640
- .filter(function (value, index, self) {
1641
- return self.indexOf(value) === index;
1642
- }).forEach(function (key) {
1643
- switch (key) {
1644
- case 'name':
1645
- if (typeof modifier.name !== 'string') {
1646
- console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', "\"" + String(modifier.name) + "\""));
1647
- }
1648
-
1649
- break;
1650
-
1651
- case 'enabled':
1652
- if (typeof modifier.enabled !== 'boolean') {
1653
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\""));
1654
- }
1655
-
1656
- break;
1657
-
1658
- case 'phase':
1659
- if (modifierPhases.indexOf(modifier.phase) < 0) {
1660
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
1661
- }
1662
-
1663
- break;
1664
-
1665
- case 'fn':
1666
- if (typeof modifier.fn !== 'function') {
1667
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\""));
1668
- }
1669
-
1670
- break;
1671
-
1672
- case 'effect':
1673
- if (modifier.effect != null && typeof modifier.effect !== 'function') {
1674
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
1675
- }
1676
-
1677
- break;
1678
-
1679
- case 'requires':
1680
- if (modifier.requires != null && !Array.isArray(modifier.requires)) {
1681
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
1682
- }
1683
-
1684
- break;
1685
-
1686
- case 'requiresIfExists':
1687
- if (!Array.isArray(modifier.requiresIfExists)) {
1688
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\""));
1689
- }
1690
-
1691
- break;
1692
-
1693
- case 'options':
1694
- case 'data':
1695
- break;
1696
-
1697
- default:
1698
- console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) {
1699
- return "\"" + s + "\"";
1700
- }).join(', ') + "; but \"" + key + "\" was provided.");
1701
- }
1702
-
1703
- modifier.requires && modifier.requires.forEach(function (requirement) {
1704
- if (modifiers.find(function (mod) {
1705
- return mod.name === requirement;
1706
- }) == null) {
1707
- console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
1708
- }
1709
- });
1710
- });
1711
- });
1712
- }
1713
-
1714
- function uniqueBy(arr, fn) {
1715
- var identifiers = new Set();
1716
- return arr.filter(function (item) {
1717
- var identifier = fn(item);
1718
-
1719
- if (!identifiers.has(identifier)) {
1720
- identifiers.add(identifier);
1721
- return true;
1722
- }
1723
- });
1724
- }
1725
-
1726
- function mergeByName(modifiers) {
1727
- var merged = modifiers.reduce(function (merged, current) {
1728
- var existing = merged[current.name];
1729
- merged[current.name] = existing ? Object.assign({}, existing, current, {
1730
- options: Object.assign({}, existing.options, current.options),
1731
- data: Object.assign({}, existing.data, current.data)
1732
- }) : current;
1733
- return merged;
1734
- }, {}); // IE11 does not support Object.values
1735
-
1736
- return Object.keys(merged).map(function (key) {
1737
- return merged[key];
1738
- });
1739
- }
1740
-
1741
- var INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';
1742
- var INFINITE_LOOP_ERROR = 'Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.';
1743
- var DEFAULT_OPTIONS = {
1744
- placement: 'bottom',
1745
- modifiers: [],
1746
- strategy: 'absolute'
1747
- };
1748
-
1749
- function areValidElements() {
1750
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1751
- args[_key] = arguments[_key];
1752
- }
1753
-
1754
- return !args.some(function (element) {
1755
- return !(element && typeof element.getBoundingClientRect === 'function');
1756
- });
1757
- }
1758
-
1759
- function popperGenerator(generatorOptions) {
1760
- if (generatorOptions === void 0) {
1761
- generatorOptions = {};
1762
- }
1763
-
1764
- var _generatorOptions = generatorOptions,
1765
- _generatorOptions$def = _generatorOptions.defaultModifiers,
1766
- defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
1767
- _generatorOptions$def2 = _generatorOptions.defaultOptions,
1768
- defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
1769
- return function createPopper(reference, popper, options) {
1770
- if (options === void 0) {
1771
- options = defaultOptions;
1772
- }
1773
-
1774
- var state = {
1775
- placement: 'bottom',
1776
- orderedModifiers: [],
1777
- options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
1778
- modifiersData: {},
1779
- elements: {
1780
- reference: reference,
1781
- popper: popper
1782
- },
1783
- attributes: {},
1784
- styles: {}
1785
- };
1786
- var effectCleanupFns = [];
1787
- var isDestroyed = false;
1788
- var instance = {
1789
- state: state,
1790
- setOptions: function setOptions(setOptionsAction) {
1791
- var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
1792
- cleanupModifierEffects();
1793
- state.options = Object.assign({}, defaultOptions, state.options, options);
1794
- state.scrollParents = {
1795
- reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
1796
- popper: listScrollParents(popper)
1797
- }; // Orders the modifiers based on their dependencies and `phase`
1798
- // properties
1799
-
1800
- var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
1801
-
1802
- state.orderedModifiers = orderedModifiers.filter(function (m) {
1803
- return m.enabled;
1804
- }); // Validate the provided modifiers so that the consumer will get warned
1805
- // if one of the modifiers is invalid for any reason
1806
-
1807
- if (process.env.NODE_ENV !== "production") {
1808
- var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) {
1809
- var name = _ref.name;
1810
- return name;
1811
- });
1812
- validateModifiers(modifiers);
1813
-
1814
- if (getBasePlacement(state.options.placement) === auto) {
1815
- var flipModifier = state.orderedModifiers.find(function (_ref2) {
1816
- var name = _ref2.name;
1817
- return name === 'flip';
1818
- });
1819
-
1820
- if (!flipModifier) {
1821
- console.error(['Popper: "auto" placements require the "flip" modifier be', 'present and enabled to work.'].join(' '));
1822
- }
1823
- }
1824
-
1825
- var _getComputedStyle = getComputedStyle(popper),
1826
- marginTop = _getComputedStyle.marginTop,
1827
- marginRight = _getComputedStyle.marginRight,
1828
- marginBottom = _getComputedStyle.marginBottom,
1829
- marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can
1830
- // cause bugs with positioning, so we'll warn the consumer
1831
-
1832
-
1833
- if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {
1834
- return parseFloat(margin);
1835
- })) {
1836
- console.warn(['Popper: CSS "margin" styles cannot be used to apply padding', 'between the popper and its reference element or boundary.', 'To replicate margin, use the `offset` modifier, as well as', 'the `padding` option in the `preventOverflow` and `flip`', 'modifiers.'].join(' '));
1837
- }
1838
- }
1839
-
1840
- runModifierEffects();
1841
- return instance.update();
1842
- },
1843
- // Sync update – it will always be executed, even if not necessary. This
1844
- // is useful for low frequency updates where sync behavior simplifies the
1845
- // logic.
1846
- // For high frequency updates (e.g. `resize` and `scroll` events), always
1847
- // prefer the async Popper#update method
1848
- forceUpdate: function forceUpdate() {
1849
- if (isDestroyed) {
1850
- return;
1851
- }
1852
-
1853
- var _state$elements = state.elements,
1854
- reference = _state$elements.reference,
1855
- popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
1856
- // anymore
1857
-
1858
- if (!areValidElements(reference, popper)) {
1859
- if (process.env.NODE_ENV !== "production") {
1860
- console.error(INVALID_ELEMENT_ERROR);
1861
- }
1862
-
1863
- return;
1864
- } // Store the reference and popper rects to be read by modifiers
1865
-
1866
-
1867
- state.rects = {
1868
- reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
1869
- popper: getLayoutRect(popper)
1870
- }; // Modifiers have the ability to reset the current update cycle. The
1871
- // most common use case for this is the `flip` modifier changing the
1872
- // placement, which then needs to re-run all the modifiers, because the
1873
- // logic was previously ran for the previous placement and is therefore
1874
- // stale/incorrect
1875
-
1876
- state.reset = false;
1877
- state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
1878
- // is filled with the initial data specified by the modifier. This means
1879
- // it doesn't persist and is fresh on each update.
1880
- // To ensure persistent data, use `${name}#persistent`
1881
-
1882
- state.orderedModifiers.forEach(function (modifier) {
1883
- return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
1884
- });
1885
- var __debug_loops__ = 0;
1886
-
1887
- for (var index = 0; index < state.orderedModifiers.length; index++) {
1888
- if (process.env.NODE_ENV !== "production") {
1889
- __debug_loops__ += 1;
1890
-
1891
- if (__debug_loops__ > 100) {
1892
- console.error(INFINITE_LOOP_ERROR);
1893
- break;
1894
- }
1895
- }
1896
-
1897
- if (state.reset === true) {
1898
- state.reset = false;
1899
- index = -1;
1900
- continue;
1901
- }
1902
-
1903
- var _state$orderedModifie = state.orderedModifiers[index],
1904
- fn = _state$orderedModifie.fn,
1905
- _state$orderedModifie2 = _state$orderedModifie.options,
1906
- _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
1907
- name = _state$orderedModifie.name;
1908
-
1909
- if (typeof fn === 'function') {
1910
- state = fn({
1911
- state: state,
1912
- options: _options,
1913
- name: name,
1914
- instance: instance
1915
- }) || state;
1916
- }
1917
- }
1918
- },
1919
- // Async and optimistically optimized update – it will not be executed if
1920
- // not necessary (debounced to run at most once-per-tick)
1921
- update: debounce(function () {
1922
- return new Promise(function (resolve) {
1923
- instance.forceUpdate();
1924
- resolve(state);
1925
- });
1926
- }),
1927
- destroy: function destroy() {
1928
- cleanupModifierEffects();
1929
- isDestroyed = true;
1930
- }
1931
- };
1932
-
1933
- if (!areValidElements(reference, popper)) {
1934
- if (process.env.NODE_ENV !== "production") {
1935
- console.error(INVALID_ELEMENT_ERROR);
1936
- }
1937
-
1938
- return instance;
1939
- }
1940
-
1941
- instance.setOptions(options).then(function (state) {
1942
- if (!isDestroyed && options.onFirstUpdate) {
1943
- options.onFirstUpdate(state);
1944
- }
1945
- }); // Modifiers have the ability to execute arbitrary code before the first
1946
- // update cycle runs. They will be executed in the same order as the update
1947
- // cycle. This is useful when a modifier adds some persistent data that
1948
- // other modifiers need to use, but the modifier is run after the dependent
1949
- // one.
1950
-
1951
- function runModifierEffects() {
1952
- state.orderedModifiers.forEach(function (_ref3) {
1953
- var name = _ref3.name,
1954
- _ref3$options = _ref3.options,
1955
- options = _ref3$options === void 0 ? {} : _ref3$options,
1956
- effect = _ref3.effect;
1957
-
1958
- if (typeof effect === 'function') {
1959
- var cleanupFn = effect({
1960
- state: state,
1961
- name: name,
1962
- instance: instance,
1963
- options: options
1964
- });
1965
-
1966
- var noopFn = function noopFn() {};
1967
-
1968
- effectCleanupFns.push(cleanupFn || noopFn);
1969
- }
1970
- });
1971
- }
1972
-
1973
- function cleanupModifierEffects() {
1974
- effectCleanupFns.forEach(function (fn) {
1975
- return fn();
1976
- });
1977
- effectCleanupFns = [];
1978
- }
1979
-
1980
- return instance;
1981
- };
1982
- }
1983
-
1984
- var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
1985
- var createPopper = /*#__PURE__*/popperGenerator({
1986
- defaultModifiers: defaultModifiers
1987
- }); // eslint-disable-next-line import/no-unused-modules
1988
-
1989
- function _setPrototypeOf(o, p) {
1990
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
1991
- o.__proto__ = p;
1992
- return o;
1993
- };
1994
-
1995
- return _setPrototypeOf(o, p);
1996
- }
1997
-
1998
- function _inheritsLoose(subClass, superClass) {
1999
- subClass.prototype = Object.create(superClass.prototype);
2000
- subClass.prototype.constructor = subClass;
2001
-
2002
- _setPrototypeOf(subClass, superClass);
2003
- }
2004
-
2005
- var ManagerReferenceNodeContext = React.createContext();
2006
- var ManagerReferenceNodeSetterContext = React.createContext();
2007
-
2008
- function Manager(_ref) {
2009
- var children = _ref.children;
2010
-
2011
- var _React$useState = React.useState(null),
2012
- referenceNode = _React$useState[0],
2013
- setReferenceNode = _React$useState[1];
2014
-
2015
- var hasUnmounted = React.useRef(false);
2016
- React.useEffect(function () {
2017
- return function () {
2018
- hasUnmounted.current = true;
2019
- };
2020
- }, []);
2021
- var handleSetReferenceNode = React.useCallback(function (node) {
2022
- if (!hasUnmounted.current) {
2023
- setReferenceNode(node);
2024
- }
2025
- }, []);
2026
- return /*#__PURE__*/React.createElement(ManagerReferenceNodeContext.Provider, {
2027
- value: referenceNode
2028
- }, /*#__PURE__*/React.createElement(ManagerReferenceNodeSetterContext.Provider, {
2029
- value: handleSetReferenceNode
2030
- }, children));
2031
- }
2032
- /**
2033
- * Takes an argument and if it's an array, returns the first item in the array,
2034
- * otherwise returns the argument. Used for Preact compatibility.
2035
- */
2036
-
2037
-
2038
- var unwrapArray = function unwrapArray(arg) {
2039
- return Array.isArray(arg) ? arg[0] : arg;
2040
- };
2041
- /**
2042
- * Takes a maybe-undefined function and arbitrary args and invokes the function
2043
- * only if it is defined.
2044
- */
2045
-
2046
-
2047
- var safeInvoke = function safeInvoke(fn) {
2048
- if (typeof fn === 'function') {
2049
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2050
- args[_key - 1] = arguments[_key];
2051
- }
2052
-
2053
- return fn.apply(void 0, args);
2054
- }
2055
- };
2056
- /**
2057
- * Sets a ref using either a ref callback or a ref object
2058
- */
2059
-
2060
-
2061
- var setRef$1 = function setRef(ref, node) {
2062
- // if its a function call it
2063
- if (typeof ref === 'function') {
2064
- return safeInvoke(ref, node);
2065
- } // otherwise we should treat it as a ref object
2066
- else if (ref != null) {
2067
- ref.current = node;
2068
- }
2069
- };
2070
- /**
2071
- * Simple ponyfill for Object.fromEntries
2072
- */
2073
-
2074
-
2075
- var fromEntries = function fromEntries(entries) {
2076
- return entries.reduce(function (acc, _ref) {
2077
- var key = _ref[0],
2078
- value = _ref[1];
2079
- acc[key] = value;
2080
- return acc;
2081
- }, {});
2082
- };
2083
- /**
2084
- * Small wrapper around `useLayoutEffect` to get rid of the warning on SSR envs
2085
- */
2086
-
2087
-
2088
- var useIsomorphicLayoutEffect = typeof window !== 'undefined' && window.document && window.document.createElement ? React.useLayoutEffect : React.useEffect;
2089
- /* global Map:readonly, Set:readonly, ArrayBuffer:readonly */
2090
-
2091
- var hasElementType = typeof Element !== 'undefined';
2092
- var hasMap = typeof Map === 'function';
2093
- var hasSet = typeof Set === 'function';
2094
- var hasArrayBuffer = typeof ArrayBuffer === 'function' && !!ArrayBuffer.isView; // Note: We **don't** need `envHasBigInt64Array` in fde es6/index.js
2095
-
2096
- function equal(a, b) {
2097
- // START: fast-deep-equal es6/index.js 3.1.1
2098
- if (a === b) return true;
2099
-
2100
- if (a && b && _typeof(a) == 'object' && _typeof(b) == 'object') {
2101
- if (a.constructor !== b.constructor) return false;
2102
- var length, i, keys;
2103
-
2104
- if (Array.isArray(a)) {
2105
- length = a.length;
2106
- if (length != b.length) return false;
2107
-
2108
- for (i = length; i-- !== 0;) {
2109
- if (!equal(a[i], b[i])) return false;
2110
- }
2111
-
2112
- return true;
2113
- } // START: Modifications:
2114
- // 1. Extra `has<Type> &&` helpers in initial condition allow es6 code
2115
- // to co-exist with es5.
2116
- // 2. Replace `for of` with es5 compliant iteration using `for`.
2117
- // Basically, take:
2118
- //
2119
- // ```js
2120
- // for (i of a.entries())
2121
- // if (!b.has(i[0])) return false;
2122
- // ```
2123
- //
2124
- // ... and convert to:
2125
- //
2126
- // ```js
2127
- // it = a.entries();
2128
- // while (!(i = it.next()).done)
2129
- // if (!b.has(i.value[0])) return false;
2130
- // ```
2131
- //
2132
- // **Note**: `i` access switches to `i.value`.
2133
-
2134
-
2135
- var it;
2136
-
2137
- if (hasMap && a instanceof Map && b instanceof Map) {
2138
- if (a.size !== b.size) return false;
2139
- it = a.entries();
2140
-
2141
- while (!(i = it.next()).done) {
2142
- if (!b.has(i.value[0])) return false;
2143
- }
2144
-
2145
- it = a.entries();
2146
-
2147
- while (!(i = it.next()).done) {
2148
- if (!equal(i.value[1], b.get(i.value[0]))) return false;
2149
- }
2150
-
2151
- return true;
2152
- }
2153
-
2154
- if (hasSet && a instanceof Set && b instanceof Set) {
2155
- if (a.size !== b.size) return false;
2156
- it = a.entries();
2157
-
2158
- while (!(i = it.next()).done) {
2159
- if (!b.has(i.value[0])) return false;
2160
- }
2161
-
2162
- return true;
2163
- } // END: Modifications
2164
-
2165
-
2166
- if (hasArrayBuffer && ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
2167
- length = a.length;
2168
- if (length != b.length) return false;
2169
-
2170
- for (i = length; i-- !== 0;) {
2171
- if (a[i] !== b[i]) return false;
2172
- }
2173
-
2174
- return true;
2175
- }
2176
-
2177
- if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
2178
- if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
2179
- if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
2180
- keys = Object.keys(a);
2181
- length = keys.length;
2182
- if (length !== Object.keys(b).length) return false;
2183
-
2184
- for (i = length; i-- !== 0;) {
2185
- if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
2186
- } // END: fast-deep-equal
2187
- // START: react-fast-compare
2188
- // custom handling for DOM elements
2189
-
2190
-
2191
- if (hasElementType && a instanceof Element) return false; // custom handling for React/Preact
2192
-
2193
- for (i = length; i-- !== 0;) {
2194
- if ((keys[i] === '_owner' || keys[i] === '__v' || keys[i] === '__o') && a.$$typeof) {
2195
- // React-specific: avoid traversing React elements' _owner
2196
- // Preact-specific: avoid traversing Preact elements' __v and __o
2197
- // __v = $_original / $_vnode
2198
- // __o = $_owner
2199
- // These properties contain circular references and are not needed when
2200
- // comparing the actual elements (and not their owners)
2201
- // .$$typeof and ._store on just reasonable markers of elements
2202
- continue;
2203
- } // all other properties should be traversed as usual
2204
-
2205
-
2206
- if (!equal(a[keys[i]], b[keys[i]])) return false;
2207
- } // END: react-fast-compare
2208
- // START: fast-deep-equal
2209
-
2210
-
2211
- return true;
2212
- }
2213
-
2214
- return a !== a && b !== b;
2215
- } // end fast-deep-equal
2216
-
2217
-
2218
- var reactFastCompare = function isEqual(a, b) {
2219
- try {
2220
- return equal(a, b);
2221
- } catch (error) {
2222
- if ((error.message || '').match(/stack|recursion/i)) {
2223
- // warn on circular references, don't crash
2224
- // browsers give this different errors name and messages:
2225
- // chrome/safari: "RangeError", "Maximum call stack size exceeded"
2226
- // firefox: "InternalError", too much recursion"
2227
- // edge: "Error", "Out of stack space"
2228
- console.warn('react-fast-compare cannot handle circular refs');
2229
- return false;
2230
- } // some other error. we should definitely know about these
2231
-
2232
-
2233
- throw error;
2234
- }
2235
- };
2236
-
2237
- var EMPTY_MODIFIERS$1 = [];
2238
-
2239
- var usePopper = function usePopper(referenceElement, popperElement, options) {
2240
- if (options === void 0) {
2241
- options = {};
2242
- }
2243
-
2244
- var prevOptions = React.useRef(null);
2245
- var optionsWithDefaults = {
2246
- onFirstUpdate: options.onFirstUpdate,
2247
- placement: options.placement || 'bottom',
2248
- strategy: options.strategy || 'absolute',
2249
- modifiers: options.modifiers || EMPTY_MODIFIERS$1
2250
- };
2251
-
2252
- var _React$useState = React.useState({
2253
- styles: {
2254
- popper: {
2255
- position: optionsWithDefaults.strategy,
2256
- left: '0',
2257
- top: '0'
2258
- },
2259
- arrow: {
2260
- position: 'absolute'
2261
- }
2262
- },
2263
- attributes: {}
2264
- }),
2265
- state = _React$useState[0],
2266
- setState = _React$useState[1];
2267
-
2268
- var updateStateModifier = React.useMemo(function () {
2269
- return {
2270
- name: 'updateState',
2271
- enabled: true,
2272
- phase: 'write',
2273
- fn: function fn(_ref) {
2274
- var state = _ref.state;
2275
- var elements = Object.keys(state.elements);
2276
- setState({
2277
- styles: fromEntries(elements.map(function (element) {
2278
- return [element, state.styles[element] || {}];
2279
- })),
2280
- attributes: fromEntries(elements.map(function (element) {
2281
- return [element, state.attributes[element]];
2282
- }))
2283
- });
2284
- },
2285
- requires: ['computeStyles']
2286
- };
2287
- }, []);
2288
- var popperOptions = React.useMemo(function () {
2289
- var newOptions = {
2290
- onFirstUpdate: optionsWithDefaults.onFirstUpdate,
2291
- placement: optionsWithDefaults.placement,
2292
- strategy: optionsWithDefaults.strategy,
2293
- modifiers: [].concat(optionsWithDefaults.modifiers, [updateStateModifier, {
2294
- name: 'applyStyles',
2295
- enabled: false
2296
- }])
2297
- };
2298
-
2299
- if (reactFastCompare(prevOptions.current, newOptions)) {
2300
- return prevOptions.current || newOptions;
2301
- } else {
2302
- prevOptions.current = newOptions;
2303
- return newOptions;
2304
- }
2305
- }, [optionsWithDefaults.onFirstUpdate, optionsWithDefaults.placement, optionsWithDefaults.strategy, optionsWithDefaults.modifiers, updateStateModifier]);
2306
- var popperInstanceRef = React.useRef();
2307
- useIsomorphicLayoutEffect(function () {
2308
- if (popperInstanceRef.current) {
2309
- popperInstanceRef.current.setOptions(popperOptions);
2310
- }
2311
- }, [popperOptions]);
2312
- useIsomorphicLayoutEffect(function () {
2313
- if (referenceElement == null || popperElement == null) {
2314
- return;
2315
- }
2316
-
2317
- var createPopper$1 = options.createPopper || createPopper;
2318
- var popperInstance = createPopper$1(referenceElement, popperElement, popperOptions);
2319
- popperInstanceRef.current = popperInstance;
2320
- return function () {
2321
- popperInstance.destroy();
2322
- popperInstanceRef.current = null;
2323
- };
2324
- }, [referenceElement, popperElement, options.createPopper]);
2325
- return {
2326
- state: popperInstanceRef.current ? popperInstanceRef.current.state : null,
2327
- styles: state.styles,
2328
- attributes: state.attributes,
2329
- update: popperInstanceRef.current ? popperInstanceRef.current.update : null,
2330
- forceUpdate: popperInstanceRef.current ? popperInstanceRef.current.forceUpdate : null
2331
- };
2332
- };
2333
-
2334
- var NOOP = function NOOP() {
2335
- return void 0;
2336
- };
2337
-
2338
- var NOOP_PROMISE = function NOOP_PROMISE() {
2339
- return Promise.resolve(null);
2340
- };
2341
-
2342
- var EMPTY_MODIFIERS = [];
2343
-
2344
- function Popper(_ref) {
2345
- var _ref$placement = _ref.placement,
2346
- placement = _ref$placement === void 0 ? 'bottom' : _ref$placement,
2347
- _ref$strategy = _ref.strategy,
2348
- strategy = _ref$strategy === void 0 ? 'absolute' : _ref$strategy,
2349
- _ref$modifiers = _ref.modifiers,
2350
- modifiers = _ref$modifiers === void 0 ? EMPTY_MODIFIERS : _ref$modifiers,
2351
- referenceElement = _ref.referenceElement,
2352
- onFirstUpdate = _ref.onFirstUpdate,
2353
- innerRef = _ref.innerRef,
2354
- children = _ref.children;
2355
- var referenceNode = React.useContext(ManagerReferenceNodeContext);
2356
-
2357
- var _React$useState = React.useState(null),
2358
- popperElement = _React$useState[0],
2359
- setPopperElement = _React$useState[1];
2360
-
2361
- var _React$useState2 = React.useState(null),
2362
- arrowElement = _React$useState2[0],
2363
- setArrowElement = _React$useState2[1];
2364
-
2365
- React.useEffect(function () {
2366
- setRef$1(innerRef, popperElement);
2367
- }, [innerRef, popperElement]);
2368
- var options = React.useMemo(function () {
2369
- return {
2370
- placement: placement,
2371
- strategy: strategy,
2372
- onFirstUpdate: onFirstUpdate,
2373
- modifiers: [].concat(modifiers, [{
2374
- name: 'arrow',
2375
- enabled: arrowElement != null,
2376
- options: {
2377
- element: arrowElement
2378
- }
2379
- }])
2380
- };
2381
- }, [placement, strategy, onFirstUpdate, modifiers, arrowElement]);
2382
-
2383
- var _usePopper = usePopper(referenceElement || referenceNode, popperElement, options),
2384
- state = _usePopper.state,
2385
- styles = _usePopper.styles,
2386
- forceUpdate = _usePopper.forceUpdate,
2387
- update = _usePopper.update;
2388
-
2389
- var childrenProps = React.useMemo(function () {
2390
- return {
2391
- ref: setPopperElement,
2392
- style: styles.popper,
2393
- placement: state ? state.placement : placement,
2394
- hasPopperEscaped: state && state.modifiersData.hide ? state.modifiersData.hide.hasPopperEscaped : null,
2395
- isReferenceHidden: state && state.modifiersData.hide ? state.modifiersData.hide.isReferenceHidden : null,
2396
- arrowProps: {
2397
- style: styles.arrow,
2398
- ref: setArrowElement
2399
- },
2400
- forceUpdate: forceUpdate || NOOP,
2401
- update: update || NOOP_PROMISE
2402
- };
2403
- }, [setPopperElement, setArrowElement, placement, state, styles, update, forceUpdate]);
2404
- return unwrapArray(children)(childrenProps);
2405
- }
2406
- /**
2407
- * Copyright (c) 2014-present, Facebook, Inc.
2408
- *
2409
- * This source code is licensed under the MIT license found in the
2410
- * LICENSE file in the root directory of this source tree.
2411
- */
2412
-
2413
- /**
2414
- * Similar to invariant but only logs a warning if the condition is not met.
2415
- * This can be used to log issues in development environments in critical
2416
- * paths. Removing the logging code for production environments will keep the
2417
- * same logic and follow the same code paths.
2418
- */
2419
-
2420
-
2421
- var __DEV__ = process.env.NODE_ENV !== 'production';
2422
-
2423
- var warning = function warning() {};
2424
-
2425
- if (__DEV__) {
2426
- var printWarning = function printWarning(format, args) {
2427
- var len = arguments.length;
2428
- args = new Array(len > 1 ? len - 1 : 0);
2429
-
2430
- for (var key = 1; key < len; key++) {
2431
- args[key - 1] = arguments[key];
2432
- }
2433
-
2434
- var argIndex = 0;
2435
- var message = 'Warning: ' + format.replace(/%s/g, function () {
2436
- return args[argIndex++];
2437
- });
2438
-
2439
- if (typeof console !== 'undefined') {
2440
- console.error(message);
2441
- }
2442
-
2443
- try {
2444
- // --- Welcome to debugging React ---
2445
- // This error was thrown as a convenience so that you can use this stack
2446
- // to find the callsite that caused this warning to fire.
2447
- throw new Error(message);
2448
- } catch (x) {}
2449
- };
2450
-
2451
- warning = function warning(condition, format, args) {
2452
- var len = arguments.length;
2453
- args = new Array(len > 2 ? len - 2 : 0);
2454
-
2455
- for (var key = 2; key < len; key++) {
2456
- args[key - 2] = arguments[key];
2457
- }
2458
-
2459
- if (format === undefined) {
2460
- throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
2461
- }
2462
-
2463
- if (!condition) {
2464
- printWarning.apply(null, [format].concat(args));
2465
- }
2466
- };
2467
- }
2468
-
2469
- var warning_1 = warning;
2470
-
2471
- function Reference(_ref) {
2472
- var children = _ref.children,
2473
- innerRef = _ref.innerRef;
2474
- var setReferenceNode = React.useContext(ManagerReferenceNodeSetterContext);
2475
- var refHandler = React.useCallback(function (node) {
2476
- setRef$1(innerRef, node);
2477
- safeInvoke(setReferenceNode, node);
2478
- }, [innerRef, setReferenceNode]); // ran on unmount
2479
-
2480
- React.useEffect(function () {
2481
- return function () {
2482
- return setRef$1(innerRef, null);
2483
- };
2484
- });
2485
- React.useEffect(function () {
2486
- warning_1(Boolean(setReferenceNode), '`Reference` should not be used outside of a `Manager` component.');
2487
- }, [setReferenceNode]);
2488
- return unwrapArray(children)({
2489
- ref: refHandler
2490
- });
2491
- }
2492
-
2493
- var TooltipContext = /*#__PURE__*/React__default.createContext({}); // eslint-disable-next-line @typescript-eslint/no-explicit-any
2494
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2495
-
2496
- var callAll = function callAll() {
2497
- for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
2498
- fns[_key] = arguments[_key];
2499
- }
2500
-
2501
- return function () {
2502
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2503
- args[_key2] = arguments[_key2];
2504
- }
2505
-
2506
- return fns.forEach(function (fn) {
2507
- return fn && fn.apply(void 0, args);
2508
- });
2509
- };
2510
- };
2511
-
2512
- var noop = function noop() {// do nothing
2513
- };
2514
-
2515
- var canUseDOM = function canUseDOM() {
2516
- return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
2517
- };
2518
-
2519
- var setRef = function setRef(ref, node) {
2520
- if (typeof ref === 'function') {
2521
- return ref(node);
2522
- } else if (ref != null) {
2523
- ref.current = node;
2524
- }
2525
- };
2526
-
2527
- var Tooltip$1 = /*#__PURE__*/function (_Component) {
2528
- _inheritsLoose(Tooltip, _Component);
2529
-
2530
- function Tooltip() {
2531
- var _this;
2532
-
2533
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2534
- args[_key] = arguments[_key];
2535
- }
2536
-
2537
- _this = _Component.call.apply(_Component, [this].concat(args)) || this;
2538
- _this.observer = void 0;
2539
- _this.tooltipRef = void 0;
2540
-
2541
- _this.handleOutsideClick = function (event) {
2542
- if (_this.tooltipRef && !_this.tooltipRef.contains(event.target)) {
2543
- var parentOutsideClickHandler = _this.context.parentOutsideClickHandler;
2544
- var _this$props = _this.props,
2545
- hideTooltip = _this$props.hideTooltip,
2546
- clearScheduled = _this$props.clearScheduled;
2547
- clearScheduled();
2548
- hideTooltip();
2549
-
2550
- if (parentOutsideClickHandler) {
2551
- parentOutsideClickHandler(event);
2552
- }
2553
- }
2554
- };
2555
-
2556
- _this.handleOutsideRightClick = function (event) {
2557
- if (_this.tooltipRef && !_this.tooltipRef.contains(event.target)) {
2558
- var parentOutsideRightClickHandler = _this.context.parentOutsideRightClickHandler;
2559
- var _this$props2 = _this.props,
2560
- hideTooltip = _this$props2.hideTooltip,
2561
- clearScheduled = _this$props2.clearScheduled;
2562
- clearScheduled();
2563
- hideTooltip();
2564
-
2565
- if (parentOutsideRightClickHandler) {
2566
- parentOutsideRightClickHandler(event);
2567
- }
2568
- }
2569
- };
2570
-
2571
- _this.addOutsideClickHandler = function () {
2572
- document.body.addEventListener('touchend', _this.handleOutsideClick);
2573
- document.body.addEventListener('click', _this.handleOutsideClick);
2574
- };
2575
-
2576
- _this.removeOutsideClickHandler = function () {
2577
- document.body.removeEventListener('touchend', _this.handleOutsideClick);
2578
- document.body.removeEventListener('click', _this.handleOutsideClick);
2579
- };
2580
-
2581
- _this.addOutsideRightClickHandler = function () {
2582
- return document.body.addEventListener('contextmenu', _this.handleOutsideRightClick);
2583
- };
2584
-
2585
- _this.removeOutsideRightClickHandler = function () {
2586
- return document.body.removeEventListener('contextmenu', _this.handleOutsideRightClick);
2587
- };
2588
-
2589
- _this.getTooltipRef = function (node) {
2590
- _this.tooltipRef = node;
2591
- setRef(_this.props.innerRef, node);
2592
- };
2593
-
2594
- _this.getArrowProps = function (props) {
2595
- if (props === void 0) {
2596
- props = {};
2597
- }
2598
-
2599
- return _extends({}, props, {
2600
- style: _extends({}, props.style, _this.props.arrowProps.style)
2601
- });
2602
- };
2603
-
2604
- _this.getTooltipProps = function (props) {
2605
- if (props === void 0) {
2606
- props = {};
2607
- }
2608
-
2609
- return _extends({}, props, _this.isTriggeredBy('hover') && {
2610
- onMouseEnter: callAll(_this.props.clearScheduled, props.onMouseEnter),
2611
- onMouseLeave: callAll(_this.props.hideTooltip, props.onMouseLeave)
2612
- }, {
2613
- style: _extends({}, props.style, _this.props.style)
2614
- });
2615
- };
2616
-
2617
- _this.contextValue = {
2618
- isParentNoneTriggered: _this.props.trigger === 'none',
2619
- addParentOutsideClickHandler: _this.addOutsideClickHandler,
2620
- addParentOutsideRightClickHandler: _this.addOutsideRightClickHandler,
2621
- parentOutsideClickHandler: _this.handleOutsideClick,
2622
- parentOutsideRightClickHandler: _this.handleOutsideRightClick,
2623
- removeParentOutsideClickHandler: _this.removeOutsideClickHandler,
2624
- removeParentOutsideRightClickHandler: _this.removeOutsideRightClickHandler
2625
- };
2626
- return _this;
2627
- }
2628
-
2629
- var _proto = Tooltip.prototype;
2630
-
2631
- _proto.componentDidMount = function componentDidMount() {
2632
- var _this2 = this;
2633
-
2634
- var observer = this.observer = new MutationObserver(function () {
2635
- _this2.props.update();
2636
- });
2637
- observer.observe(this.tooltipRef, this.props.mutationObserverOptions);
2638
-
2639
- if (this.isTriggeredBy('hover') || this.isTriggeredBy('click') || this.isTriggeredBy('right-click')) {
2640
- var _this$context = this.context,
2641
- removeParentOutsideClickHandler = _this$context.removeParentOutsideClickHandler,
2642
- removeParentOutsideRightClickHandler = _this$context.removeParentOutsideRightClickHandler;
2643
- this.addOutsideClickHandler();
2644
- this.addOutsideRightClickHandler();
2645
-
2646
- if (removeParentOutsideClickHandler) {
2647
- removeParentOutsideClickHandler();
2648
- }
2649
-
2650
- if (removeParentOutsideRightClickHandler) {
2651
- removeParentOutsideRightClickHandler();
2652
- }
2653
- }
2654
- };
2655
-
2656
- _proto.componentDidUpdate = function componentDidUpdate() {
2657
- if (this.props.closeOnReferenceHidden && this.props.isReferenceHidden) {
2658
- this.props.hideTooltip();
2659
- }
2660
- };
2661
-
2662
- _proto.componentWillUnmount = function componentWillUnmount() {
2663
- if (this.observer) {
2664
- this.observer.disconnect();
2665
- }
2666
-
2667
- if (this.isTriggeredBy('hover') || this.isTriggeredBy('click') || this.isTriggeredBy('right-click')) {
2668
- var _this$context2 = this.context,
2669
- isParentNoneTriggered = _this$context2.isParentNoneTriggered,
2670
- addParentOutsideClickHandler = _this$context2.addParentOutsideClickHandler,
2671
- addParentOutsideRightClickHandler = _this$context2.addParentOutsideRightClickHandler;
2672
- this.removeOutsideClickHandler();
2673
- this.removeOutsideRightClickHandler();
2674
- this.handleOutsideClick = undefined;
2675
- this.handleOutsideRightClick = undefined;
2676
-
2677
- if (!isParentNoneTriggered && addParentOutsideClickHandler) {
2678
- addParentOutsideClickHandler();
2679
- }
2680
-
2681
- if (!isParentNoneTriggered && addParentOutsideRightClickHandler) {
2682
- addParentOutsideRightClickHandler();
2683
- }
2684
- }
2685
- };
2686
-
2687
- _proto.render = function render() {
2688
- var _this$props3 = this.props,
2689
- arrowProps = _this$props3.arrowProps,
2690
- placement = _this$props3.placement,
2691
- tooltip = _this$props3.tooltip;
2692
- return /*#__PURE__*/React__default.createElement(TooltipContext.Provider, {
2693
- value: this.contextValue
2694
- }, tooltip({
2695
- arrowRef: arrowProps.ref,
2696
- getArrowProps: this.getArrowProps,
2697
- getTooltipProps: this.getTooltipProps,
2698
- placement: placement,
2699
- tooltipRef: this.getTooltipRef
2700
- }));
2701
- };
2702
-
2703
- _proto.isTriggeredBy = function isTriggeredBy(event) {
2704
- var trigger = this.props.trigger;
2705
- return trigger === event || Array.isArray(trigger) && trigger.includes(event);
2706
- };
2707
-
2708
- return Tooltip;
2709
- }(Component);
2710
-
2711
- Tooltip$1.contextType = TooltipContext;
2712
- var DEFAULT_MUTATION_OBSERVER_CONFIG = {
2713
- childList: true,
2714
- subtree: true
2715
- };
2716
-
2717
- var TooltipTrigger = /*#__PURE__*/function (_Component) {
2718
- _inheritsLoose(TooltipTrigger, _Component);
2719
-
2720
- function TooltipTrigger() {
2721
- var _this;
2722
-
2723
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2724
- args[_key] = arguments[_key];
2725
- }
2726
-
2727
- _this = _Component.call.apply(_Component, [this].concat(args)) || this;
2728
- _this.state = {
2729
- tooltipShown: _this.props.defaultTooltipShown
2730
- };
2731
- _this.hideTimeout = void 0;
2732
- _this.showTimeout = void 0;
2733
- _this.popperOffset = void 0;
2734
-
2735
- _this.setTooltipState = function (state) {
2736
- var cb = function cb() {
2737
- return _this.props.onVisibilityChange(state.tooltipShown);
2738
- };
2739
-
2740
- _this.isControlled() ? cb() : _this.setState(state, cb);
2741
- };
2742
-
2743
- _this.clearScheduled = function () {
2744
- clearTimeout(_this.hideTimeout);
2745
- clearTimeout(_this.showTimeout);
2746
- };
2747
-
2748
- _this.showTooltip = function (_ref) {
2749
- var pageX = _ref.pageX,
2750
- pageY = _ref.pageY;
2751
-
2752
- _this.clearScheduled();
2753
-
2754
- var state = {
2755
- tooltipShown: true
2756
- };
2757
-
2758
- if (_this.props.followCursor) {
2759
- state = _extends({}, state, {
2760
- pageX: pageX,
2761
- pageY: pageY
2762
- });
2763
- }
2764
-
2765
- _this.showTimeout = window.setTimeout(function () {
2766
- return _this.setTooltipState(state);
2767
- }, _this.props.delayShow);
2768
- };
2769
-
2770
- _this.hideTooltip = function () {
2771
- _this.clearScheduled();
2772
-
2773
- _this.hideTimeout = window.setTimeout(function () {
2774
- return _this.setTooltipState({
2775
- tooltipShown: false
2776
- });
2777
- }, _this.props.delayHide);
2778
- };
2779
-
2780
- _this.toggleTooltip = function (_ref2) {
2781
- var pageX = _ref2.pageX,
2782
- pageY = _ref2.pageY;
2783
- var action = _this.getState() ? 'hideTooltip' : 'showTooltip';
2784
-
2785
- _this[action]({
2786
- pageX: pageX,
2787
- pageY: pageY
2788
- });
2789
- };
2790
-
2791
- _this.clickToggle = function (event) {
2792
- event.preventDefault();
2793
- var pageX = event.pageX,
2794
- pageY = event.pageY;
2795
- var action = _this.props.followCursor ? 'showTooltip' : 'toggleTooltip';
2796
-
2797
- _this[action]({
2798
- pageX: pageX,
2799
- pageY: pageY
2800
- });
2801
- };
2802
-
2803
- _this.contextMenuToggle = function (event) {
2804
- event.preventDefault();
2805
- var pageX = event.pageX,
2806
- pageY = event.pageY;
2807
- var action = _this.props.followCursor ? 'showTooltip' : 'toggleTooltip';
2808
-
2809
- _this[action]({
2810
- pageX: pageX,
2811
- pageY: pageY
2812
- });
2813
- };
2814
-
2815
- _this.getTriggerProps = function (props) {
2816
- if (props === void 0) {
2817
- props = {};
2818
- }
2819
-
2820
- return _extends({}, props, _this.isTriggeredBy('click') && {
2821
- onClick: callAll(_this.clickToggle, props.onClick),
2822
- onTouchEnd: callAll(_this.clickToggle, props.onTouchEnd)
2823
- }, _this.isTriggeredBy('right-click') && {
2824
- onContextMenu: callAll(_this.contextMenuToggle, props.onContextMenu)
2825
- }, _this.isTriggeredBy('hover') && _extends({
2826
- onMouseEnter: callAll(_this.showTooltip, props.onMouseEnter),
2827
- onMouseLeave: callAll(_this.hideTooltip, props.onMouseLeave)
2828
- }, _this.props.followCursor && {
2829
- onMouseMove: callAll(_this.showTooltip, props.onMouseMove)
2830
- }), _this.isTriggeredBy('focus') && {
2831
- onFocus: callAll(_this.showTooltip, props.onFocus),
2832
- onBlur: callAll(_this.hideTooltip, props.onBlur)
2833
- });
2834
- };
2835
-
2836
- return _this;
2837
- }
2838
-
2839
- var _proto = TooltipTrigger.prototype;
2840
-
2841
- _proto.componentWillUnmount = function componentWillUnmount() {
2842
- this.clearScheduled();
2843
- };
2844
-
2845
- _proto.render = function render() {
2846
- var _this2 = this;
2847
-
2848
- var _this$props = this.props,
2849
- children = _this$props.children,
2850
- tooltip = _this$props.tooltip,
2851
- placement = _this$props.placement,
2852
- trigger = _this$props.trigger,
2853
- getTriggerRef = _this$props.getTriggerRef,
2854
- modifiers = _this$props.modifiers,
2855
- closeOnReferenceHidden = _this$props.closeOnReferenceHidden,
2856
- usePortal = _this$props.usePortal,
2857
- portalContainer = _this$props.portalContainer,
2858
- followCursor = _this$props.followCursor,
2859
- getTooltipRef = _this$props.getTooltipRef,
2860
- mutationObserverOptions = _this$props.mutationObserverOptions,
2861
- restProps = _objectWithoutPropertiesLoose(_this$props, ["children", "tooltip", "placement", "trigger", "getTriggerRef", "modifiers", "closeOnReferenceHidden", "usePortal", "portalContainer", "followCursor", "getTooltipRef", "mutationObserverOptions"]);
2862
-
2863
- var popper = /*#__PURE__*/React__default.createElement(Popper, _extends({
2864
- innerRef: getTooltipRef,
2865
- placement: placement,
2866
- modifiers: [{
2867
- name: 'followCursor',
2868
- enabled: followCursor,
2869
- phase: 'main',
2870
- fn: function fn(data) {
2871
- _this2.popperOffset = data.state.rects.popper;
2872
- }
2873
- }].concat(modifiers)
2874
- }, restProps), function (_ref3) {
2875
- var ref = _ref3.ref,
2876
- style = _ref3.style,
2877
- placement = _ref3.placement,
2878
- arrowProps = _ref3.arrowProps,
2879
- isReferenceHidden = _ref3.isReferenceHidden,
2880
- update = _ref3.update;
2881
-
2882
- if (followCursor && _this2.popperOffset) {
2883
- var _this2$state = _this2.state,
2884
- pageX = _this2$state.pageX,
2885
- pageY = _this2$state.pageY;
2886
- var _this2$popperOffset = _this2.popperOffset,
2887
- width = _this2$popperOffset.width,
2888
- height = _this2$popperOffset.height;
2889
- var x = pageX + width > window.pageXOffset + document.body.offsetWidth ? pageX - width : pageX;
2890
- var y = pageY + height > window.pageYOffset + document.body.offsetHeight ? pageY - height : pageY;
2891
- style.transform = "translate3d(" + x + "px, " + y + "px, 0";
2892
- }
2893
-
2894
- return /*#__PURE__*/React__default.createElement(Tooltip$1, _extends({
2895
- arrowProps: arrowProps,
2896
- closeOnReferenceHidden: closeOnReferenceHidden,
2897
- isReferenceHidden: isReferenceHidden,
2898
- placement: placement,
2899
- update: update,
2900
- style: style,
2901
- tooltip: tooltip,
2902
- trigger: trigger,
2903
- mutationObserverOptions: mutationObserverOptions
2904
- }, {
2905
- clearScheduled: _this2.clearScheduled,
2906
- hideTooltip: _this2.hideTooltip,
2907
- innerRef: ref
2908
- }));
2909
- });
2910
- return /*#__PURE__*/React__default.createElement(Manager, null, /*#__PURE__*/React__default.createElement(Reference, {
2911
- innerRef: getTriggerRef
2912
- }, function (_ref4) {
2913
- var ref = _ref4.ref;
2914
- return children({
2915
- getTriggerProps: _this2.getTriggerProps,
2916
- triggerRef: ref
2917
- });
2918
- }), this.getState() && (usePortal ? /*#__PURE__*/createPortal(popper, portalContainer) : popper));
2919
- };
2920
-
2921
- _proto.isControlled = function isControlled() {
2922
- return this.props.tooltipShown !== undefined;
2923
- };
2924
-
2925
- _proto.getState = function getState() {
2926
- return this.isControlled() ? this.props.tooltipShown : this.state.tooltipShown;
2927
- };
2928
-
2929
- _proto.isTriggeredBy = function isTriggeredBy(event) {
2930
- var trigger = this.props.trigger;
2931
- return trigger === event || Array.isArray(trigger) && trigger.includes(event);
2932
- };
2933
-
2934
- return TooltipTrigger;
2935
- }(Component);
2936
-
2937
- TooltipTrigger.defaultProps = {
2938
- closeOnReferenceHidden: true,
2939
- defaultTooltipShown: false,
2940
- delayHide: 0,
2941
- delayShow: 0,
2942
- followCursor: false,
2943
- onVisibilityChange: noop,
2944
- placement: 'right',
2945
- portalContainer: canUseDOM() ? document.body : null,
2946
- trigger: 'hover',
2947
- usePortal: canUseDOM(),
2948
- mutationObserverOptions: DEFAULT_MUTATION_OBSERVER_CONFIG,
2949
- modifiers: []
2950
- };
2951
- var TooltipTrigger$1 = TooltipTrigger;
2952
- var match = memoizerific(1000)(function (requests, actual, value) {
2953
- var fallback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
2954
- return actual.split('-')[0] === requests ? value : fallback;
2955
- });
2956
- var ArrowSpacing = 8;
2957
- var Arrow = styled.div({
2958
- position: 'absolute',
2959
- borderStyle: 'solid'
2960
- }, function (_ref6) {
2961
- var placement = _ref6.placement;
2962
- var x = 0;
2963
- var y = 0;
2964
-
2965
- switch (true) {
2966
- case placement.startsWith('left') || placement.startsWith('right'):
2967
- {
2968
- y = 8;
2969
- break;
2970
- }
2971
-
2972
- case placement.startsWith('top') || placement.startsWith('bottom'):
2973
- {
2974
- x = 8;
2975
- break;
2976
- }
2977
- }
2978
-
2979
- var transform = "translate3d(".concat(x, "px, ").concat(y, "px, 0px)");
2980
- return {
2981
- transform: transform
2982
- };
2983
- }, function (_ref7) {
2984
- var theme = _ref7.theme,
2985
- color = _ref7.color,
2986
- placement = _ref7.placement;
2987
- return {
2988
- bottom: "".concat(match('top', placement, ArrowSpacing * -1, 'auto'), "px"),
2989
- top: "".concat(match('bottom', placement, ArrowSpacing * -1, 'auto'), "px"),
2990
- right: "".concat(match('left', placement, ArrowSpacing * -1, 'auto'), "px"),
2991
- left: "".concat(match('right', placement, ArrowSpacing * -1, 'auto'), "px"),
2992
- borderBottomWidth: "".concat(match('top', placement, '0', ArrowSpacing), "px"),
2993
- borderTopWidth: "".concat(match('bottom', placement, '0', ArrowSpacing), "px"),
2994
- borderRightWidth: "".concat(match('left', placement, '0', ArrowSpacing), "px"),
2995
- borderLeftWidth: "".concat(match('right', placement, '0', ArrowSpacing), "px"),
2996
- borderTopColor: match('top', placement, theme.color[color] || color || theme.base === 'light' ? lighten(theme.background.app) : darken(theme.background.app), 'transparent'),
2997
- borderBottomColor: match('bottom', placement, theme.color[color] || color || theme.base === 'light' ? lighten(theme.background.app) : darken(theme.background.app), 'transparent'),
2998
- borderLeftColor: match('left', placement, theme.color[color] || color || theme.base === 'light' ? lighten(theme.background.app) : darken(theme.background.app), 'transparent'),
2999
- borderRightColor: match('right', placement, theme.color[color] || color || theme.base === 'light' ? lighten(theme.background.app) : darken(theme.background.app), 'transparent')
3000
- };
3001
- });
3002
- var Wrapper = styled.div(function (_ref8) {
3003
- var hidden = _ref8.hidden;
3004
- return {
3005
- display: hidden ? 'none' : 'inline-block',
3006
- zIndex: 2147483647
3007
- };
3008
- }, function (_ref9) {
3009
- var theme = _ref9.theme,
3010
- color = _ref9.color,
3011
- hasChrome = _ref9.hasChrome;
3012
- return hasChrome ? {
3013
- background: theme.color[color] || color || theme.base === 'light' ? lighten(theme.background.app) : darken(theme.background.app),
3014
- filter: "\n drop-shadow(0px 5px 5px rgba(0,0,0,0.05))\n drop-shadow(0 1px 3px rgba(0,0,0,0.1))\n ",
3015
- borderRadius: theme.appBorderRadius * 2,
3016
- fontSize: theme.typography.size.s1
3017
- } : {};
3018
- });
3019
-
3020
- var Tooltip = function Tooltip(_a) {
3021
- var placement = _a.placement,
3022
- hasChrome = _a.hasChrome,
3023
- children = _a.children,
3024
- arrowProps = _a.arrowProps,
3025
- tooltipRef = _a.tooltipRef,
3026
- arrowRef = _a.arrowRef,
3027
- color = _a.color,
3028
- props = __rest(_a, ["placement", "hasChrome", "children", "arrowProps", "tooltipRef", "arrowRef", "color"]);
3029
-
3030
- return React__default.createElement(Wrapper, Object.assign({
3031
- hasChrome: hasChrome,
3032
- placement: placement,
3033
- ref: tooltipRef
3034
- }, props, {
3035
- color: color
3036
- }), hasChrome && React__default.createElement(Arrow, Object.assign({
3037
- placement: placement,
3038
- ref: arrowRef
3039
- }, arrowProps, {
3040
- color: color
3041
- })), children);
3042
- };
3043
-
3044
- Tooltip.defaultProps = {
3045
- color: undefined,
3046
- arrowRef: undefined,
3047
- tooltipRef: undefined,
3048
- hasChrome: true,
3049
- placement: 'top',
3050
- arrowProps: {}
3051
- };
3052
- var document$1 = window_1.document; // A target that doesn't speak popper
3053
-
3054
- var TargetContainer = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-block;\n cursor: ", ";\n"])), function (props) {
3055
- return props.mode === 'hover' ? 'default' : 'pointer';
3056
- });
3057
- var TargetSvgContainer = styled.g(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n cursor: ", ";\n"])), function (props) {
3058
- return props.mode === 'hover' ? 'default' : 'pointer';
3059
- }); // Pure, does not bind to the body
3060
-
3061
- var WithTooltipPure = function WithTooltipPure(_a) {
3062
- var svg = _a.svg,
3063
- trigger = _a.trigger,
3064
- closeOnClick = _a.closeOnClick,
3065
- placement = _a.placement,
3066
- modifiers = _a.modifiers,
3067
- hasChrome = _a.hasChrome,
3068
- _tooltip = _a.tooltip,
3069
- children = _a.children,
3070
- tooltipShown = _a.tooltipShown,
3071
- onVisibilityChange = _a.onVisibilityChange,
3072
- props = __rest(_a, ["svg", "trigger", "closeOnClick", "placement", "modifiers", "hasChrome", "tooltip", "children", "tooltipShown", "onVisibilityChange"]);
3073
-
3074
- var Container = svg ? TargetSvgContainer : TargetContainer;
3075
- return React__default.createElement(TooltipTrigger$1, {
3076
- placement: placement,
3077
- trigger: trigger,
3078
- modifiers: modifiers,
3079
- tooltipShown: tooltipShown,
3080
- onVisibilityChange: onVisibilityChange,
3081
- tooltip: function tooltip(_ref10) {
3082
- var getTooltipProps = _ref10.getTooltipProps,
3083
- getArrowProps = _ref10.getArrowProps,
3084
- tooltipRef = _ref10.tooltipRef,
3085
- arrowRef = _ref10.arrowRef,
3086
- tooltipPlacement = _ref10.placement;
3087
- return React__default.createElement(Tooltip, Object.assign({
3088
- hasChrome: hasChrome,
3089
- placement: tooltipPlacement,
3090
- tooltipRef: tooltipRef,
3091
- arrowRef: arrowRef,
3092
- arrowProps: getArrowProps()
3093
- }, getTooltipProps()), typeof _tooltip === 'function' ? _tooltip({
3094
- onHide: function onHide() {
3095
- return onVisibilityChange(false);
3096
- }
3097
- }) : _tooltip);
3098
- }
3099
- }, function (_ref11) {
3100
- var getTriggerProps = _ref11.getTriggerProps,
3101
- triggerRef = _ref11.triggerRef;
3102
- return (// @ts-ignore
3103
- React__default.createElement(Container, Object.assign({
3104
- ref: triggerRef
3105
- }, getTriggerProps(), props), children)
3106
- );
3107
- });
3108
- };
3109
-
3110
- WithTooltipPure.defaultProps = {
3111
- svg: false,
3112
- trigger: 'hover',
3113
- closeOnClick: false,
3114
- placement: 'top',
3115
- modifiers: [{
3116
- name: 'preventOverflow',
3117
- options: {
3118
- padding: 8
3119
- }
3120
- }, {
3121
- name: 'offset',
3122
- options: {
3123
- offset: [8, 8]
3124
- }
3125
- }, {
3126
- name: 'arrow',
3127
- options: {
3128
- padding: 8
3129
- }
3130
- }],
3131
- hasChrome: true,
3132
- tooltipShown: false
3133
- };
3134
-
3135
- var WithToolTipState = function WithToolTipState(_a) {
3136
- var startOpen = _a.startOpen,
3137
- onChange = _a.onVisibilityChange,
3138
- rest = __rest(_a, ["startOpen", "onVisibilityChange"]);
3139
-
3140
- var _useState = useState(startOpen || false),
3141
- _useState2 = _slicedToArray(_useState, 2),
3142
- tooltipShown = _useState2[0],
3143
- setTooltipShown = _useState2[1];
3144
-
3145
- var onVisibilityChange = useCallback(function (visibility) {
3146
- if (onChange && onChange(visibility) === false) return;
3147
- setTooltipShown(visibility);
3148
- }, [onChange]);
3149
- useEffect(function () {
3150
- var hide = function hide() {
3151
- return onVisibilityChange(false);
3152
- };
3153
-
3154
- document$1.addEventListener('keydown', hide, false); // Find all iframes on the screen and bind to clicks inside them (waiting until the iframe is ready)
3155
-
3156
- var iframes = Array.from(document$1.getElementsByTagName('iframe'));
3157
- var unbinders = [];
3158
- iframes.forEach(function (iframe) {
3159
- var bind = function bind() {
3160
- try {
3161
- if (iframe.contentWindow.document) {
3162
- iframe.contentWindow.document.addEventListener('click', hide);
3163
- unbinders.push(function () {
3164
- try {
3165
- iframe.contentWindow.document.removeEventListener('click', hide);
3166
- } catch (e) {// logger.debug('Removing a click listener from iframe failed: ', e);
3167
- }
3168
- });
3169
- }
3170
- } catch (e) {// logger.debug('Adding a click listener to iframe failed: ', e);
3171
- }
3172
- };
3173
-
3174
- bind(); // I don't know how to find out if it's already loaded so I potentially will bind twice
3175
-
3176
- iframe.addEventListener('load', bind);
3177
- unbinders.push(function () {
3178
- iframe.removeEventListener('load', bind);
3179
- });
3180
- });
3181
- return function () {
3182
- document$1.removeEventListener('keydown', hide);
3183
- unbinders.forEach(function (unbind) {
3184
- unbind();
3185
- });
3186
- };
3187
- });
3188
- return React__default.createElement(WithTooltipPure, Object.assign({}, rest, {
3189
- tooltipShown: tooltipShown,
3190
- onVisibilityChange: onVisibilityChange
3191
- }));
3192
- };
3193
-
3194
- export { WithToolTipState, WithToolTipState as WithTooltip, WithTooltipPure };