@storybook/components 6.5.9 → 7.0.0-alpha.2

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