@storybook/components 6.5.9 → 7.0.0-alpha.2

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