@storybook/components 6.5.6 → 7.0.0-alpha.0

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