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

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