UNPKG

226 kBJavaScriptView Raw
1import React, { Fragment, PureComponent } from 'react';
2export { default as React } from 'react';
3import ReactDOM from 'react-dom';
4
5var styleElement = document.createElement('style');
6styleElement.setAttribute('data-reactlite', '');
7styleElement.type = 'text/css';
8document.head.appendChild(styleElement);
9
10function addStyleToHead(rule) {
11 if (styleElement) {
12 var sheet = styleElement.sheet;
13 try {
14 sheet.insertRule(rule, sheet.cssRules.length);
15 } catch (error) {
16 // insertRule will fail for rules with pseudoelements the browser doesn't support.
17 // see: https://github.com/jsxstyle/jsxstyle/issues/75
18 if (process.env.NODE_ENV !== 'production') {
19 console.error('Could not insert rule at position ' + sheet.cssRules.length + ': `' + rule + '`');
20 }
21 }
22 }
23}
24
25/**
26 * Copyright 2013-present, Facebook, Inc.
27 * All rights reserved.
28 *
29 * This source code is licensed under the BSD-style license found in the
30 * LICENSE file in the root directory of this source tree. An additional grant
31 * of patent rights can be found in the PATENTS file in the same directory.
32 *
33 */
34
35// A hearty blend of the following two files:
36// https://github.com/facebook/react/blob/master/src/renderers/dom/shared/CSSProperty.js
37// https://github.com/facebook/react/blob/master/src/renderers/dom/shared/dangerousStyleValue.js
38
39var isUnitlessNumber = {
40 animationIterationCount: true,
41 borderImageOutset: true,
42 borderImageSlice: true,
43 borderImageWidth: true,
44 boxFlex: true,
45 boxFlexGroup: true,
46 boxOrdinalGroup: true,
47 columnCount: true,
48 columns: true,
49 flex: true,
50 flexGrow: true,
51 flexNegative: true,
52 flexOrder: true,
53 flexPositive: true,
54 flexShrink: true,
55 fontWeight: true,
56 gridColumn: true,
57 gridColumnEnd: true,
58 gridColumnSpan: true,
59 gridColumnStart: true,
60 gridRow: true,
61 gridRowEnd: true,
62 gridRowSpan: true,
63 gridRowStart: true,
64 lineClamp: true,
65 lineHeight: true,
66 opacity: true,
67 order: true,
68 orphans: true,
69 tabSize: true,
70 widows: true,
71 zIndex: true,
72 zoom: true,
73
74 // SVG-related properties
75 fillOpacity: true,
76 floodOpacity: true,
77 stopOpacity: true,
78 strokeDasharray: true,
79 strokeDashoffset: true,
80 strokeMiterlimit: true,
81 strokeOpacity: true,
82 strokeWidth: true
83};
84
85function prefixKey(prefix, key) {
86 return prefix + key.charAt(0).toUpperCase() + key.substring(1);
87}
88
89var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
90
91Object.keys(isUnitlessNumber).forEach(function (prop) {
92 prefixes.forEach(function (prefix) {
93 isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
94 });
95});
96
97function dangerousStyleValue(name, value) {
98 var isEmpty = value == null || typeof value === 'boolean' || value === '';
99 if (isEmpty) {
100 return '';
101 }
102
103 if (typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) {
104 if (value > -1 && value < 1) {
105 return Math.round(value * 1e6) / 1e4 + '%';
106 }
107 return value + 'px';
108 }
109
110 if (!value.toString) {
111 if (process.env.NODE_ENV === 'development') {
112 console.error('Value for prop `%s` (`%o`) cannot be stringified.', name, value);
113 }
114 return '';
115 }
116
117 return ('' + value).trim();
118}
119
120var roundedBorderRadius = '0.25em';
121var shapeTypes = {
122 square: { borderRadius: 0 },
123 circle: { borderRadius: '50%' },
124 pill: { borderRadius: '999px' },
125 rounded: { borderRadius: '' + roundedBorderRadius },
126 roundedTop: {
127 borderRadius: roundedBorderRadius + ' ' + roundedBorderRadius + ' 0 0'
128 },
129 roundedRight: {
130 borderRadius: '0 ' + roundedBorderRadius + ' ' + roundedBorderRadius + ' 0'
131 },
132 roundedBottom: {
133 borderRadius: '0 0 ' + roundedBorderRadius + ' ' + roundedBorderRadius
134 },
135 roundedLeft: {
136 borderRadius: roundedBorderRadius + ' 0 0 ' + roundedBorderRadius
137 }
138};
139var enhanceStyles = {
140 top: function top(value) {
141 return { top: value === true ? 0 : value };
142 },
143 right: function right(value) {
144 return { right: value === true ? 0 : value };
145 },
146 bottom: function bottom(value) {
147 return { bottom: value === true ? 0 : value };
148 },
149 left: function left(value) {
150 return { left: value === true ? 0 : value };
151 },
152 paddingX: function paddingX(value) {
153 return {
154 paddingLeft: value,
155 paddingRight: value
156 };
157 },
158 paddingY: function paddingY(value) {
159 return {
160 paddingTop: value,
161 paddingBottom: value
162 };
163 },
164 widthRatio: function widthRatio(value) {
165 return { width: value * 100 + '%' };
166 },
167 heightRatio: function heightRatio(value) {
168 return { height: value * 100 + '%' };
169 },
170 aspectRatio: function aspectRatio(value) {
171 return {
172 paddingBottom: 1 / value * 100 + '%',
173 height: 0
174 };
175 },
176 shape: function shape(value) {
177 return shapeTypes[value];
178 }
179};
180
181var uppercasePattern = /([A-Z])/g;
182var msPattern = /^ms-/;
183var hyphenateCache = {};
184
185function hyphenateStyleName(styleName) {
186 if (hyphenateCache.hasOwnProperty(styleName)) {
187 return hyphenateCache[styleName];
188 }
189 var hyphenatedString = styleName.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern, '-ms-');
190
191 hyphenateCache[styleName] = hyphenatedString;
192 return hyphenateCache[styleName];
193}
194
195var formatStyle = function formatStyle(styleName, styleValue) {
196 return hyphenateStyleName(styleName) + ':' + styleValue + ';';
197};
198var formatStylePretty = function formatStylePretty(styleName, styleValue) {
199 return ' ' + hyphenateStyleName(styleName) + ': ' + styleValue + ';\n';
200};
201
202var getEnhanceStyles = function getEnhanceStyles(propName, propValue) {
203 var pretty = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
204
205 var formatString = pretty ? formatStylePretty : formatStyle;
206 if (!enhanceStyles.hasOwnProperty(propName)) {
207 return formatString(propName, propValue);
208 }
209 var styleStr = '';
210 var styleObj = enhanceStyles[propName](propValue);
211 if (styleObj) {
212 for (var styleName in styleObj) {
213 if (styleObj.hasOwnProperty(styleName)) {
214 var styleValue = styleObj[styleName];
215 styleStr += formatString(styleName, styleValue);
216 }
217 }
218 }
219
220 return styleStr;
221};
222
223var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
224 return typeof obj;
225} : function (obj) {
226 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
227};
228
229var classCallCheck = function (instance, Constructor) {
230 if (!(instance instanceof Constructor)) {
231 throw new TypeError("Cannot call a class as a function");
232 }
233};
234
235var createClass = function () {
236 function defineProperties(target, props) {
237 for (var i = 0; i < props.length; i++) {
238 var descriptor = props[i];
239 descriptor.enumerable = descriptor.enumerable || false;
240 descriptor.configurable = true;
241 if ("value" in descriptor) descriptor.writable = true;
242 Object.defineProperty(target, descriptor.key, descriptor);
243 }
244 }
245
246 return function (Constructor, protoProps, staticProps) {
247 if (protoProps) defineProperties(Constructor.prototype, protoProps);
248 if (staticProps) defineProperties(Constructor, staticProps);
249 return Constructor;
250 };
251}();
252
253var _extends = Object.assign || function (target) {
254 for (var i = 1; i < arguments.length; i++) {
255 var source = arguments[i];
256
257 for (var key in source) {
258 if (Object.prototype.hasOwnProperty.call(source, key)) {
259 target[key] = source[key];
260 }
261 }
262 }
263
264 return target;
265};
266
267var inherits = function (subClass, superClass) {
268 if (typeof superClass !== "function" && superClass !== null) {
269 throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
270 }
271
272 subClass.prototype = Object.create(superClass && superClass.prototype, {
273 constructor: {
274 value: subClass,
275 enumerable: false,
276 writable: true,
277 configurable: true
278 }
279 });
280 if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
281};
282
283var objectWithoutProperties = function (obj, keys) {
284 var target = {};
285
286 for (var i in obj) {
287 if (keys.indexOf(i) >= 0) continue;
288 if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
289 target[i] = obj[i];
290 }
291
292 return target;
293};
294
295var possibleConstructorReturn = function (self, call) {
296 if (!self) {
297 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
298 }
299
300 return call && (typeof call === "object" || typeof call === "function") ? call : self;
301};
302
303// global flag makes subsequent calls of capRegex.test advance to the next match
304var capRegex = /[A-Z]/g;
305
306var pseudoelements = {
307 after: true,
308 before: true,
309 placeholder: true,
310 selection: true
311};
312
313var pseudoclasses = {
314 active: true,
315 checked: true,
316 disabled: true,
317 empty: true,
318 enabled: true,
319 focus: true,
320 hover: true,
321 invalid: true,
322 required: true,
323 target: true,
324 valid: true
325};
326
327var specialCaseProps = {
328 children: true,
329 class: true,
330 className: true,
331 is: true,
332 mediaQueries: true,
333 props: true,
334 style: true
335};
336
337function getStyleKeysForProps(props) {
338 var pretty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
339
340 if ((typeof props === 'undefined' ? 'undefined' : _typeof(props)) !== 'object' || props === null) {
341 return null;
342 }
343
344 var propKeys = Object.keys(props).sort();
345 var keyCount = propKeys.length;
346
347 if (keyCount === 0) {
348 return null;
349 }
350
351 var mediaQueries = props.mediaQueries;
352 var hasMediaQueries = mediaQueries && (typeof mediaQueries === 'undefined' ? 'undefined' : _typeof(mediaQueries)) === 'object';
353 var usesMediaQueries = false;
354
355 var styleKeyObj = {};
356
357 var classNameKey = '';
358 var seenMQs = {};
359
360 var mqSortKeys = {};
361 if (hasMediaQueries) {
362 var idx = -1;
363 for (var k in mediaQueries) {
364 mqSortKeys[k] = '@' + (1000 + ++idx);
365 }
366 }
367
368 for (var _idx = -1; ++_idx < keyCount;) {
369 var originalPropName = propKeys[_idx];
370 if (specialCaseProps.hasOwnProperty(originalPropName) || !props.hasOwnProperty(originalPropName)) {
371 continue;
372 }
373
374 var propName = originalPropName;
375 var propSansMQ = void 0;
376 var pseudoelement = void 0;
377 var pseudoclass = void 0;
378 var mqKey = void 0;
379
380 capRegex.lastIndex = 0;
381 var splitIndex = 0;
382
383 var prefix = capRegex.test(originalPropName) && capRegex.lastIndex > 1 && originalPropName.slice(0, capRegex.lastIndex - 1);
384
385 // check for media query prefix
386 if (prefix && hasMediaQueries && mediaQueries.hasOwnProperty(prefix)) {
387 usesMediaQueries = true;
388 mqKey = prefix;
389 splitIndex = capRegex.lastIndex - 1;
390
391 propSansMQ = originalPropName[splitIndex].toLowerCase() + originalPropName.slice(splitIndex + 1);
392
393 prefix = capRegex.test(originalPropName) && propSansMQ.slice(0, capRegex.lastIndex - splitIndex - 1);
394 }
395
396 // check for pseudoelement prefix
397 if (prefix && pseudoelements.hasOwnProperty(prefix)) {
398 pseudoelement = prefix;
399 splitIndex = capRegex.lastIndex - 1;
400 prefix = capRegex.test(originalPropName) && originalPropName[splitIndex].toLowerCase() + originalPropName.slice(splitIndex + 1, capRegex.lastIndex - 1);
401 }
402
403 // check for pseudoclass prefix
404 if (prefix && pseudoclasses.hasOwnProperty(prefix)) {
405 pseudoclass = prefix;
406 splitIndex = capRegex.lastIndex - 1;
407 }
408
409 // trim prefixes off propName
410 if (splitIndex > 0) {
411 propName = originalPropName[splitIndex].toLowerCase() + originalPropName.slice(splitIndex + 1);
412 }
413
414 var styleValue = dangerousStyleValue(propName, props[originalPropName]);
415 if (styleValue === '') {
416 continue;
417 }
418
419 var mediaQuery = mqKey && mediaQueries[mqKey];
420 var mqSortKey = mqKey && mqSortKeys[mqKey];
421
422 var key = '.' + (mqSortKey || '') + (pseudoclass ? ':' + pseudoclass : '') + (pseudoelement ? '::' + pseudoelement : '');
423
424 if (!styleKeyObj.hasOwnProperty(key)) {
425 styleKeyObj[key] = { styles: pretty ? '\n' : '' };
426 if (mediaQuery) {
427 styleKeyObj[key].mediaQuery = mediaQuery;
428 }
429 if (pseudoclass) {
430 styleKeyObj[key].pseudoclass = pseudoclass;
431 }
432 if (pseudoelement) {
433 styleKeyObj[key].pseudoelement = pseudoelement;
434 }
435 }
436
437 if (mediaQuery) {
438 seenMQs[mediaQuery] = seenMQs[mediaQuery] || '';
439 // seenMQs[mediaQuery] += getEnhanceStyles(propSansMQ, styleValue);
440 seenMQs[mediaQuery] += propSansMQ + ':' + styleValue + ';';
441 } else {
442 // classNameKey += getEnhanceStyles(originalPropName, styleValue);
443 classNameKey += originalPropName + ':' + styleValue + ';';
444 }
445 if (props.shape == 'circle') {
446 console.log(propName, styleValue);
447 }
448 styleKeyObj[key].styles += getEnhanceStyles(propName, styleValue, pretty);
449 // (pretty ? ' ' : '') +
450 // hyphenateStyleName(propName) +
451 // (pretty ? ': ' : ':') +
452 // styleValue +
453 // (pretty ? ';\n' : ';');
454 // styleKeyObj[key].styles +=
455 // (pretty ? ' ' : '') +
456 // hyphenateStyleName(propName) +
457 // (pretty ? ': ' : ':') +
458 // styleValue +
459 // (pretty ? ';\n' : ';');
460 }
461
462 // append media query key
463 if (usesMediaQueries) {
464 var mqKeys = Object.keys(seenMQs).sort();
465 for (var _idx2 = -1, len = mqKeys.length; ++_idx2 < len;) {
466 var _mediaQuery = mqKeys[_idx2];
467 classNameKey += '@' + _mediaQuery + '~' + seenMQs[_mediaQuery];
468 }
469 }
470 if (props.shape == 'circle') {
471 console.log(props.shape, props, classNameKey, styleKeyObj);
472 }
473 if (classNameKey === '') {
474 return null;
475 }
476
477 styleKeyObj.classNameKey = classNameKey;
478
479 return styleKeyObj;
480}
481
482// darksky: https://git.io/v9kWO
483function stringHash(str) {
484 var hash = 5381;
485 var i = str.length;
486
487 while (i) {
488 hash = hash * 33 ^ str.charCodeAt(--i);
489 }
490
491 /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
492 * integers. Since we want the results to be always positive, convert the
493 * signed int to an unsigned by doing an unsigned bitshift. */
494 return hash >>> 0;
495}
496
497function cannotInject() {
498 throw new Error('error: `injectOptions` must be called before any components mount.');
499}
500
501function alreadyInjected() {
502 throw new Error('error: `injectOptions` should be called once and only once.');
503}
504
505function getStringHash(key, props) {
506 return '_' + stringHash(key).toString(36);
507}
508
509function getStyleCache() {
510 var _classNameCache = {};
511 var getClassNameForKey = getStringHash;
512 var onInsertRule = void 0;
513 var pretty = false;
514
515 var styleCache = {
516 reset: function reset() {
517 _classNameCache = {};
518 },
519 injectOptions: function injectOptions(options) {
520 if (options) {
521 if (options.getClassName) {
522 getClassNameForKey = options.getClassName;
523 }
524 if (options.onInsertRule) {
525 onInsertRule = options.onInsertRule;
526 }
527 if (options.pretty) {
528 pretty = options.pretty;
529 }
530 }
531 styleCache.injectOptions = alreadyInjected;
532 },
533 getClassName: function getClassName(props, classNameProp) {
534 styleCache.injectOptions = cannotInject;
535
536 var styleObj = getStyleKeysForProps(props, pretty);
537 if ((typeof styleObj === 'undefined' ? 'undefined' : _typeof(styleObj)) !== 'object' || styleObj === null) {
538 return classNameProp || null;
539 }
540
541 var key = styleObj.classNameKey;
542 if (key && !_classNameCache.hasOwnProperty(key)) {
543 _classNameCache[key] = getClassNameForKey(key, props);
544 delete styleObj.classNameKey;
545 Object.keys(styleObj).sort().forEach(function (k) {
546 var selector = '.' + _classNameCache[key];
547 // prettier-ignore
548 var _styleObj$k = styleObj[k],
549 pseudoclass = _styleObj$k.pseudoclass,
550 pseudoelement = _styleObj$k.pseudoelement,
551 mediaQuery = _styleObj$k.mediaQuery,
552 styles = _styleObj$k.styles;
553
554
555 var rule = selector + (pseudoclass ? ':' + pseudoclass : '') + (pseudoelement ? '::' + pseudoelement : '') + (' {' + styles + '}');
556
557 if (mediaQuery) {
558 rule = '@media ' + mediaQuery + ' { ' + rule + ' }';
559 }
560
561 if (onInsertRule &&
562 // if the function returns false, bail.
563 onInsertRule(rule, props) === false) {
564 return;
565 }
566 addStyleToHead(rule);
567 });
568 }
569
570 return _classNameCache[key] && classNameProp ? classNameProp + ' ' + _classNameCache[key] : _classNameCache[key] || classNameProp || null;
571 }
572 };
573
574 return styleCache;
575}
576
577/** Shared instance of a style cache object. */
578var cache = getStyleCache();
579
580var getDerivedStateFromProps = function getDerivedStateFromProps(props) {
581 return {
582 className: cache.getClassName(props, props.className)
583 };
584};
585
586function factory(displayName, defaultProps) {
587 var _class, _temp;
588
589 return _temp = _class = function (_React$Component) {
590 inherits(_class, _React$Component);
591
592 function _class(props) {
593 classCallCheck(this, _class);
594
595 // className will be set before initial render with either getDerivedStateFromProps or componentWillMount
596 var _this = possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).call(this, props));
597
598 _this.state = { className: null };
599
600 var componentWillMount = function componentWillMount() {
601 _this.setState(getDerivedStateFromProps(_this.props));
602 };
603
604 var componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
605 _this.setState(getDerivedStateFromProps(nextProps));
606 };
607
608 // In React 16.3+, deprecated lifecycles will not be called if getDerivedStateFromProps is defined.
609 // This boolean prevents React from logging the presence of these functions as an error in strict mode.
610 // See https://github.com/reactjs/react-lifecycles-compat/blob/0a02b80/index.js#L47
611 componentWillReceiveProps.__suppressDeprecationWarning = true;
612 componentWillMount.__suppressDeprecationWarning = true;
613
614 _this.componentDidMount = componentWillMount;
615 _this.componentWillReceiveProps = componentWillReceiveProps;
616 return _this;
617 }
618
619 createClass(_class, [{
620 key: 'render',
621 value: function render() {
622 var _props = this.props,
623 props = _props.props,
624 style = _props.style,
625 children = _props.children,
626 is = _props.is;
627
628 var Component = is || 'div';
629
630 return React.createElement(
631 Component,
632 _extends({}, props, {
633 className: this.state.className || undefined,
634 style: style || undefined
635 }),
636 children
637 );
638 }
639 }]);
640 return _class;
641 }(React.Component), _class.defaultProps = defaultProps, _class.displayName = displayName, _class.getDerivedStateFromProps = getDerivedStateFromProps, _temp;
642}
643
644var Box = factory('Box', null);
645var Block = factory('Block', { display: 'block' });
646var Flex = factory('Flex', { display: 'flex' });
647var Grid = factory('Grid', { display: 'grid' });
648var Inline = factory('Inline', { display: 'inline' });
649var InlineBlock = factory('InlineBlock', { display: 'inline-block' });
650var InlineFlex = factory('InlineFlex', { display: 'inline-flex' });
651
652var Button = function (_React$Component) {
653 inherits(Button, _React$Component);
654
655 function Button() {
656 classCallCheck(this, Button);
657 return possibleConstructorReturn(this, (Button.__proto__ || Object.getPrototypeOf(Button)).apply(this, arguments));
658 }
659
660 createClass(Button, [{
661 key: 'render',
662 value: function render() {
663 return React.createElement(Box, _extends({ is: 'button' }, this.props));
664 }
665 }]);
666 return Button;
667}(React.Component);
668
669var Divider = function Divider(props) {
670 var _props$vertical = props.vertical,
671 vertical = _props$vertical === undefined ? false : _props$vertical,
672 others = objectWithoutProperties(props, ['vertical']);
673
674
675 var dividerStyle = vertical ? {
676 marginTop: '0 1em',
677 minHeight: '100%',
678 width: 0,
679 borderWidth: '0 0 0 1px'
680 } : {
681 margin: '1em 0',
682 height: 0,
683 borderWidth: '1px 0 0 0'
684 };
685 return React.createElement(Box, _extends({
686 is: 'hr',
687 borderColor: 'currentColor',
688 borderStyle: 'solid',
689 opacity: '0.2',
690 role: 'divider'
691 }, dividerStyle, others));
692};
693
694/**
695 * 图标组件
696 */
697var Icon = function Icon(_ref) {
698 var src = _ref.src,
699 width = _ref.width,
700 height = _ref.height,
701 path = _ref.path,
702 sourceWidth = _ref.sourceWidth,
703 sourceHeight = _ref.sourceHeight,
704 props = objectWithoutProperties(_ref, ['src', 'width', 'height', 'path', 'sourceWidth', 'sourceHeight']);
705
706 var iconWidth = width || height || 16;
707 var iconHeight = height || width || 16;
708
709 var iconSourceWidth = sourceWidth || sourceHeight || 1024;
710 var iconSourceHeight = sourceHeight || sourceWidth || 1024;
711
712 return React.createElement(
713 Box,
714 _extends({
715 tag: 'svg',
716 role: 'img',
717 width: iconWidth,
718 height: iconHeight,
719 viewBox: '0 0 ' + iconSourceWidth + ' ' + iconSourceHeight,
720 fill: 'currentColor',
721 strokeWidth: 0,
722 verticalAlign: 'middle'
723 }, props),
724 React.createElement('path', { d: path })
725 );
726};
727Icon.defaultProps = {
728 path: 'M0 0L1024 0L1024 1024L0 1024z'
729};
730
731var Image = function Image(props) {
732 var src = props.src,
733 _props$contain = props.contain,
734 contain = _props$contain === undefined ? false : _props$contain,
735 _props$cover = props.cover,
736 cover = _props$cover === undefined ? false : _props$cover,
737 _props$fit = props.fit,
738 fit = _props$fit === undefined ? false : _props$fit,
739 _props$repeat = props.repeat,
740 repeat = _props$repeat === undefined ? false : _props$repeat,
741 others = objectWithoutProperties(props, ['src', 'contain', 'cover', 'fit', 'repeat']);
742
743 return React.createElement(Box, _extends({
744 role: 'img',
745 width: '100%',
746 height: '100%',
747 backgroundPosition: 'center'
748 }, others, {
749 backgroundRepeat: repeat ? 'repeat' : 'no-repeat',
750 backgroundSize: contain ? 'contain' : cover ? 'cover' : fit ? '100% 100%' : 'unset',
751 backgroundImage: 'url(\'' + src + '\')'
752 }));
753};
754
755/**
756 * 层组件
757 *
758 * 方式 1
759 * showLayer && <Layer><div>Layer Content</div></Layer>
760 *
761 * 方式 2
762 * <Layer.Placeholder/>
763 * let element = <Tooltip/>;
764 * Layer.mount(element);
765 * Layer.unmount(element);
766 *
767 */
768var __layerMap = new Map();
769var __defaultName = 'default';
770function getLayer(name) {
771 return __layerMap.get(name);
772}
773function addLayer(name, layer) {
774 if (__layerMap.has(name)) {
775 console.warn('[Layer] \u91CD\u590D\u7684 name: ' + name);
776 }
777 __layerMap.set(name, layer);
778}
779function removeLayer(name) {
780 __layerMap.delete(name);
781}
782var __elementMap = new Map();
783var __elementKey = 0;
784function isMounted(name, element) {
785 if (typeof name === 'string') {
786 return __elementMap.has(element);
787 } else {
788 return isMounted.apply(undefined, [__defaultName].concat(Array.prototype.slice.call(arguments)));
789 }
790}
791function mount(name, element, onMountCallback, onUnmountCallback) {
792 if (typeof name === 'string') {
793 var unmountSelf = function unmountSelf() {
794 return unmount(name, element);
795 };
796 if (!__layerMap.has(name)) {
797 console.error('[Layer] \u9700\u8981\u5148\u6DFB\u52A0 <Layer.Placeholder/>');
798 }
799 if (__elementMap.has(element)) {
800 console.warn('[Layer] \u91CD\u590D\u7684 element: ', element);
801 }
802 var ref = React.createRef();
803 __elementMap.set(element, { ref: ref, onUnmountCallback: onUnmountCallback });
804 var layer = getLayer(name);
805
806 var props = {
807 ref: ref,
808 unmount: unmountSelf
809 };
810 if (element.key == null) {
811 props.key = 'layer' + __elementKey++;
812 }
813 layer.setState(function (_ref) {
814 var children = _ref.children;
815 return {
816 children: children.filter(function (element) {
817 return element.ref !== ref;
818 }).concat([React.cloneElement(element, props)])
819 };
820 }, onMountCallback);
821 return unmountSelf;
822 } else {
823 return mount.apply(undefined, [__defaultName].concat(Array.prototype.slice.call(arguments)));
824 }
825}
826function unmount(name, element) {
827 if (typeof name === 'string') {
828 if (__elementMap.has(element)) {
829 var _elementMap$get = __elementMap.get(element),
830 ref = _elementMap$get.ref,
831 onUnmountCallback = _elementMap$get.onUnmountCallback;
832
833 __elementMap.delete(element);
834 var layer = getLayer(name);
835 layer.setState(function (_ref2) {
836 var children = _ref2.children;
837 return {
838 children: children.filter(function (element) {
839 return element.ref !== ref;
840 })
841 };
842 }, onUnmountCallback);
843 }
844 } else {
845 unmount.apply(undefined, [__defaultName].concat(Array.prototype.slice.call(arguments)));
846 }
847}
848
849var Layer = function (_React$Component) {
850 inherits(Layer, _React$Component);
851
852 function Layer(props) {
853 classCallCheck(this, Layer);
854
855 var _this = possibleConstructorReturn(this, (Layer.__proto__ || Object.getPrototypeOf(Layer)).call(this, props));
856
857 _this.el = document.createElement('div');
858 return _this;
859 }
860
861 createClass(Layer, [{
862 key: 'componentDidMount',
863 value: function componentDidMount() {
864 if (document.body) {
865 document.body.appendChild(this.el);
866 }
867 }
868 }, {
869 key: 'componentWillUnmount',
870 value: function componentWillUnmount() {
871 if (document.body) {
872 document.body.removeChild(this.el);
873 }
874 }
875 }, {
876 key: 'render',
877 value: function render() {
878 var children = this.props.children;
879
880 return ReactDOM.createPortal(children, this.el);
881 }
882 }]);
883 return Layer;
884}(React.Component);
885
886var Placeholder = function (_React$Component2) {
887 inherits(Placeholder, _React$Component2);
888
889 function Placeholder(props) {
890 classCallCheck(this, Placeholder);
891
892 var _this2 = possibleConstructorReturn(this, (Placeholder.__proto__ || Object.getPrototypeOf(Placeholder)).call(this, props));
893
894 _this2.state = { children: [] };
895 return _this2;
896 }
897
898 createClass(Placeholder, [{
899 key: 'componentDidMount',
900 value: function componentDidMount() {
901 var name = this.props.name;
902
903 addLayer(name, this);
904 }
905 }, {
906 key: 'componentWillUnmount',
907 value: function componentWillUnmount() {
908 var name = this.props.name;
909
910 removeLayer(name);
911 }
912 }, {
913 key: 'render',
914 value: function render() {
915 var children = this.state.children;
916
917 return React.createElement(Layer, { children: children });
918 }
919 }]);
920 return Placeholder;
921}(React.Component);
922
923Placeholder.defaultProps = {
924 name: __defaultName
925};
926
927Layer.show = mount;
928Layer.mount = mount;
929Layer.hide = unmount;
930Layer.unmount = unmount;
931Layer.isMounted = isMounted;
932Layer.Placeholder = Placeholder;
933
934/**!
935 * @fileOverview Kickass library to create and place poppers near their reference elements.
936 * @version 1.14.4
937 * @license
938 * Copyright (c) 2016 Federico Zivolo and contributors
939 *
940 * Permission is hereby granted, free of charge, to any person obtaining a copy
941 * of this software and associated documentation files (the "Software"), to deal
942 * in the Software without restriction, including without limitation the rights
943 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
944 * copies of the Software, and to permit persons to whom the Software is
945 * furnished to do so, subject to the following conditions:
946 *
947 * The above copyright notice and this permission notice shall be included in all
948 * copies or substantial portions of the Software.
949 *
950 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
951 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
952 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
953 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
954 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
955 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
956 * SOFTWARE.
957 */
958var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
959
960var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
961var timeoutDuration = 0;
962for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
963 if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
964 timeoutDuration = 1;
965 break;
966 }
967}
968
969function microtaskDebounce(fn) {
970 var called = false;
971 return function () {
972 if (called) {
973 return;
974 }
975 called = true;
976 window.Promise.resolve().then(function () {
977 called = false;
978 fn();
979 });
980 };
981}
982
983function taskDebounce(fn) {
984 var scheduled = false;
985 return function () {
986 if (!scheduled) {
987 scheduled = true;
988 setTimeout(function () {
989 scheduled = false;
990 fn();
991 }, timeoutDuration);
992 }
993 };
994}
995
996var supportsMicroTasks = isBrowser && window.Promise;
997
998/**
999* Create a debounced version of a method, that's asynchronously deferred
1000* but called in the minimum time possible.
1001*
1002* @method
1003* @memberof Popper.Utils
1004* @argument {Function} fn
1005* @returns {Function}
1006*/
1007var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
1008
1009/**
1010 * Check if the given variable is a function
1011 * @method
1012 * @memberof Popper.Utils
1013 * @argument {Any} functionToCheck - variable to check
1014 * @returns {Boolean} answer to: is a function?
1015 */
1016function isFunction(functionToCheck) {
1017 var getType = {};
1018 return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
1019}
1020
1021/**
1022 * Get CSS computed property of the given element
1023 * @method
1024 * @memberof Popper.Utils
1025 * @argument {Eement} element
1026 * @argument {String} property
1027 */
1028function getStyleComputedProperty(element, property) {
1029 if (element.nodeType !== 1) {
1030 return [];
1031 }
1032 // NOTE: 1 DOM access here
1033 var css = getComputedStyle(element, null);
1034 return property ? css[property] : css;
1035}
1036
1037/**
1038 * Returns the parentNode or the host of the element
1039 * @method
1040 * @memberof Popper.Utils
1041 * @argument {Element} element
1042 * @returns {Element} parent
1043 */
1044function getParentNode(element) {
1045 if (element.nodeName === 'HTML') {
1046 return element;
1047 }
1048 return element.parentNode || element.host;
1049}
1050
1051/**
1052 * Returns the scrolling parent of the given element
1053 * @method
1054 * @memberof Popper.Utils
1055 * @argument {Element} element
1056 * @returns {Element} scroll parent
1057 */
1058function getScrollParent(element) {
1059 // Return body, `getScroll` will take care to get the correct `scrollTop` from it
1060 if (!element) {
1061 return document.body;
1062 }
1063
1064 switch (element.nodeName) {
1065 case 'HTML':
1066 case 'BODY':
1067 return element.ownerDocument.body;
1068 case '#document':
1069 return element.body;
1070 }
1071
1072 // Firefox want us to check `-x` and `-y` variations as well
1073
1074 var _getStyleComputedProp = getStyleComputedProperty(element),
1075 overflow = _getStyleComputedProp.overflow,
1076 overflowX = _getStyleComputedProp.overflowX,
1077 overflowY = _getStyleComputedProp.overflowY;
1078
1079 if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
1080 return element;
1081 }
1082
1083 return getScrollParent(getParentNode(element));
1084}
1085
1086var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
1087var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
1088
1089/**
1090 * Determines if the browser is Internet Explorer
1091 * @method
1092 * @memberof Popper.Utils
1093 * @param {Number} version to check
1094 * @returns {Boolean} isIE
1095 */
1096function isIE(version) {
1097 if (version === 11) {
1098 return isIE11;
1099 }
1100 if (version === 10) {
1101 return isIE10;
1102 }
1103 return isIE11 || isIE10;
1104}
1105
1106/**
1107 * Returns the offset parent of the given element
1108 * @method
1109 * @memberof Popper.Utils
1110 * @argument {Element} element
1111 * @returns {Element} offset parent
1112 */
1113function getOffsetParent(element) {
1114 if (!element) {
1115 return document.documentElement;
1116 }
1117
1118 var noOffsetParent = isIE(10) ? document.body : null;
1119
1120 // NOTE: 1 DOM access here
1121 var offsetParent = element.offsetParent;
1122 // Skip hidden elements which don't have an offsetParent
1123 while (offsetParent === noOffsetParent && element.nextElementSibling) {
1124 offsetParent = (element = element.nextElementSibling).offsetParent;
1125 }
1126
1127 var nodeName = offsetParent && offsetParent.nodeName;
1128
1129 if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
1130 return element ? element.ownerDocument.documentElement : document.documentElement;
1131 }
1132
1133 // .offsetParent will return the closest TD or TABLE in case
1134 // no offsetParent is present, I hate this job...
1135 if (['TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
1136 return getOffsetParent(offsetParent);
1137 }
1138
1139 return offsetParent;
1140}
1141
1142function isOffsetContainer(element) {
1143 var nodeName = element.nodeName;
1144
1145 if (nodeName === 'BODY') {
1146 return false;
1147 }
1148 return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
1149}
1150
1151/**
1152 * Finds the root node (document, shadowDOM root) of the given element
1153 * @method
1154 * @memberof Popper.Utils
1155 * @argument {Element} node
1156 * @returns {Element} root node
1157 */
1158function getRoot(node) {
1159 if (node.parentNode !== null) {
1160 return getRoot(node.parentNode);
1161 }
1162
1163 return node;
1164}
1165
1166/**
1167 * Finds the offset parent common to the two provided nodes
1168 * @method
1169 * @memberof Popper.Utils
1170 * @argument {Element} element1
1171 * @argument {Element} element2
1172 * @returns {Element} common offset parent
1173 */
1174function findCommonOffsetParent(element1, element2) {
1175 // This check is needed to avoid errors in case one of the elements isn't defined for any reason
1176 if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
1177 return document.documentElement;
1178 }
1179
1180 // Here we make sure to give as "start" the element that comes first in the DOM
1181 var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
1182 var start = order ? element1 : element2;
1183 var end = order ? element2 : element1;
1184
1185 // Get common ancestor container
1186 var range = document.createRange();
1187 range.setStart(start, 0);
1188 range.setEnd(end, 0);
1189 var commonAncestorContainer = range.commonAncestorContainer;
1190
1191 // Both nodes are inside #document
1192
1193 if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
1194 if (isOffsetContainer(commonAncestorContainer)) {
1195 return commonAncestorContainer;
1196 }
1197
1198 return getOffsetParent(commonAncestorContainer);
1199 }
1200
1201 // one of the nodes is inside shadowDOM, find which one
1202 var element1root = getRoot(element1);
1203 if (element1root.host) {
1204 return findCommonOffsetParent(element1root.host, element2);
1205 } else {
1206 return findCommonOffsetParent(element1, getRoot(element2).host);
1207 }
1208}
1209
1210/**
1211 * Gets the scroll value of the given element in the given side (top and left)
1212 * @method
1213 * @memberof Popper.Utils
1214 * @argument {Element} element
1215 * @argument {String} side `top` or `left`
1216 * @returns {number} amount of scrolled pixels
1217 */
1218function getScroll(element) {
1219 var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
1220
1221 var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
1222 var nodeName = element.nodeName;
1223
1224 if (nodeName === 'BODY' || nodeName === 'HTML') {
1225 var html = element.ownerDocument.documentElement;
1226 var scrollingElement = element.ownerDocument.scrollingElement || html;
1227 return scrollingElement[upperSide];
1228 }
1229
1230 return element[upperSide];
1231}
1232
1233/*
1234 * Sum or subtract the element scroll values (left and top) from a given rect object
1235 * @method
1236 * @memberof Popper.Utils
1237 * @param {Object} rect - Rect object you want to change
1238 * @param {HTMLElement} element - The element from the function reads the scroll values
1239 * @param {Boolean} subtract - set to true if you want to subtract the scroll values
1240 * @return {Object} rect - The modifier rect object
1241 */
1242function includeScroll(rect, element) {
1243 var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1244
1245 var scrollTop = getScroll(element, 'top');
1246 var scrollLeft = getScroll(element, 'left');
1247 var modifier = subtract ? -1 : 1;
1248 rect.top += scrollTop * modifier;
1249 rect.bottom += scrollTop * modifier;
1250 rect.left += scrollLeft * modifier;
1251 rect.right += scrollLeft * modifier;
1252 return rect;
1253}
1254
1255/*
1256 * Helper to detect borders of a given element
1257 * @method
1258 * @memberof Popper.Utils
1259 * @param {CSSStyleDeclaration} styles
1260 * Result of `getStyleComputedProperty` on the given element
1261 * @param {String} axis - `x` or `y`
1262 * @return {number} borders - The borders size of the given axis
1263 */
1264
1265function getBordersSize(styles, axis) {
1266 var sideA = axis === 'x' ? 'Left' : 'Top';
1267 var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
1268
1269 return parseFloat(styles['border' + sideA + 'Width'], 10) + parseFloat(styles['border' + sideB + 'Width'], 10);
1270}
1271
1272function getSize(axis, body, html, computedStyle) {
1273 return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE(10) ? parseInt(html['offset' + axis]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')]) : 0);
1274}
1275
1276function getWindowSizes(document) {
1277 var body = document.body;
1278 var html = document.documentElement;
1279 var computedStyle = isIE(10) && getComputedStyle(html);
1280
1281 return {
1282 height: getSize('Height', body, html, computedStyle),
1283 width: getSize('Width', body, html, computedStyle)
1284 };
1285}
1286
1287var classCallCheck$1 = function (instance, Constructor) {
1288 if (!(instance instanceof Constructor)) {
1289 throw new TypeError("Cannot call a class as a function");
1290 }
1291};
1292
1293var createClass$1 = function () {
1294 function defineProperties(target, props) {
1295 for (var i = 0; i < props.length; i++) {
1296 var descriptor = props[i];
1297 descriptor.enumerable = descriptor.enumerable || false;
1298 descriptor.configurable = true;
1299 if ("value" in descriptor) descriptor.writable = true;
1300 Object.defineProperty(target, descriptor.key, descriptor);
1301 }
1302 }
1303
1304 return function (Constructor, protoProps, staticProps) {
1305 if (protoProps) defineProperties(Constructor.prototype, protoProps);
1306 if (staticProps) defineProperties(Constructor, staticProps);
1307 return Constructor;
1308 };
1309}();
1310
1311
1312
1313
1314
1315var defineProperty$1 = function (obj, key, value) {
1316 if (key in obj) {
1317 Object.defineProperty(obj, key, {
1318 value: value,
1319 enumerable: true,
1320 configurable: true,
1321 writable: true
1322 });
1323 } else {
1324 obj[key] = value;
1325 }
1326
1327 return obj;
1328};
1329
1330var _extends$1 = Object.assign || function (target) {
1331 for (var i = 1; i < arguments.length; i++) {
1332 var source = arguments[i];
1333
1334 for (var key in source) {
1335 if (Object.prototype.hasOwnProperty.call(source, key)) {
1336 target[key] = source[key];
1337 }
1338 }
1339 }
1340
1341 return target;
1342};
1343
1344/**
1345 * Given element offsets, generate an output similar to getBoundingClientRect
1346 * @method
1347 * @memberof Popper.Utils
1348 * @argument {Object} offsets
1349 * @returns {Object} ClientRect like output
1350 */
1351function getClientRect(offsets) {
1352 return _extends$1({}, offsets, {
1353 right: offsets.left + offsets.width,
1354 bottom: offsets.top + offsets.height
1355 });
1356}
1357
1358/**
1359 * Get bounding client rect of given element
1360 * @method
1361 * @memberof Popper.Utils
1362 * @param {HTMLElement} element
1363 * @return {Object} client rect
1364 */
1365function getBoundingClientRect(element) {
1366 var rect = {};
1367
1368 // IE10 10 FIX: Please, don't ask, the element isn't
1369 // considered in DOM in some circumstances...
1370 // This isn't reproducible in IE10 compatibility mode of IE11
1371 try {
1372 if (isIE(10)) {
1373 rect = element.getBoundingClientRect();
1374 var scrollTop = getScroll(element, 'top');
1375 var scrollLeft = getScroll(element, 'left');
1376 rect.top += scrollTop;
1377 rect.left += scrollLeft;
1378 rect.bottom += scrollTop;
1379 rect.right += scrollLeft;
1380 } else {
1381 rect = element.getBoundingClientRect();
1382 }
1383 } catch (e) {}
1384
1385 var result = {
1386 left: rect.left,
1387 top: rect.top,
1388 width: rect.right - rect.left,
1389 height: rect.bottom - rect.top
1390 };
1391
1392 // subtract scrollbar size from sizes
1393 var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
1394 var width = sizes.width || element.clientWidth || result.right - result.left;
1395 var height = sizes.height || element.clientHeight || result.bottom - result.top;
1396
1397 var horizScrollbar = element.offsetWidth - width;
1398 var vertScrollbar = element.offsetHeight - height;
1399
1400 // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
1401 // we make this check conditional for performance reasons
1402 if (horizScrollbar || vertScrollbar) {
1403 var styles = getStyleComputedProperty(element);
1404 horizScrollbar -= getBordersSize(styles, 'x');
1405 vertScrollbar -= getBordersSize(styles, 'y');
1406
1407 result.width -= horizScrollbar;
1408 result.height -= vertScrollbar;
1409 }
1410
1411 return getClientRect(result);
1412}
1413
1414function getOffsetRectRelativeToArbitraryNode(children, parent) {
1415 var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1416
1417 var isIE10 = isIE(10);
1418 var isHTML = parent.nodeName === 'HTML';
1419 var childrenRect = getBoundingClientRect(children);
1420 var parentRect = getBoundingClientRect(parent);
1421 var scrollParent = getScrollParent(children);
1422
1423 var styles = getStyleComputedProperty(parent);
1424 var borderTopWidth = parseFloat(styles.borderTopWidth, 10);
1425 var borderLeftWidth = parseFloat(styles.borderLeftWidth, 10);
1426
1427 // In cases where the parent is fixed, we must ignore negative scroll in offset calc
1428 if (fixedPosition && isHTML) {
1429 parentRect.top = Math.max(parentRect.top, 0);
1430 parentRect.left = Math.max(parentRect.left, 0);
1431 }
1432 var offsets = getClientRect({
1433 top: childrenRect.top - parentRect.top - borderTopWidth,
1434 left: childrenRect.left - parentRect.left - borderLeftWidth,
1435 width: childrenRect.width,
1436 height: childrenRect.height
1437 });
1438 offsets.marginTop = 0;
1439 offsets.marginLeft = 0;
1440
1441 // Subtract margins of documentElement in case it's being used as parent
1442 // we do this only on HTML because it's the only element that behaves
1443 // differently when margins are applied to it. The margins are included in
1444 // the box of the documentElement, in the other cases not.
1445 if (!isIE10 && isHTML) {
1446 var marginTop = parseFloat(styles.marginTop, 10);
1447 var marginLeft = parseFloat(styles.marginLeft, 10);
1448
1449 offsets.top -= borderTopWidth - marginTop;
1450 offsets.bottom -= borderTopWidth - marginTop;
1451 offsets.left -= borderLeftWidth - marginLeft;
1452 offsets.right -= borderLeftWidth - marginLeft;
1453
1454 // Attach marginTop and marginLeft because in some circumstances we may need them
1455 offsets.marginTop = marginTop;
1456 offsets.marginLeft = marginLeft;
1457 }
1458
1459 if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
1460 offsets = includeScroll(offsets, parent);
1461 }
1462
1463 return offsets;
1464}
1465
1466function getViewportOffsetRectRelativeToArtbitraryNode(element) {
1467 var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1468
1469 var html = element.ownerDocument.documentElement;
1470 var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
1471 var width = Math.max(html.clientWidth, window.innerWidth || 0);
1472 var height = Math.max(html.clientHeight, window.innerHeight || 0);
1473
1474 var scrollTop = !excludeScroll ? getScroll(html) : 0;
1475 var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
1476
1477 var offset = {
1478 top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
1479 left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
1480 width: width,
1481 height: height
1482 };
1483
1484 return getClientRect(offset);
1485}
1486
1487/**
1488 * Check if the given element is fixed or is inside a fixed parent
1489 * @method
1490 * @memberof Popper.Utils
1491 * @argument {Element} element
1492 * @argument {Element} customContainer
1493 * @returns {Boolean} answer to "isFixed?"
1494 */
1495function isFixed(element) {
1496 var nodeName = element.nodeName;
1497 if (nodeName === 'BODY' || nodeName === 'HTML') {
1498 return false;
1499 }
1500 if (getStyleComputedProperty(element, 'position') === 'fixed') {
1501 return true;
1502 }
1503 return isFixed(getParentNode(element));
1504}
1505
1506/**
1507 * Finds the first parent of an element that has a transformed property defined
1508 * @method
1509 * @memberof Popper.Utils
1510 * @argument {Element} element
1511 * @returns {Element} first transformed parent or documentElement
1512 */
1513
1514function getFixedPositionOffsetParent(element) {
1515 // This check is needed to avoid errors in case one of the elements isn't defined for any reason
1516 if (!element || !element.parentElement || isIE()) {
1517 return document.documentElement;
1518 }
1519 var el = element.parentElement;
1520 while (el && getStyleComputedProperty(el, 'transform') === 'none') {
1521 el = el.parentElement;
1522 }
1523 return el || document.documentElement;
1524}
1525
1526/**
1527 * Computed the boundaries limits and return them
1528 * @method
1529 * @memberof Popper.Utils
1530 * @param {HTMLElement} popper
1531 * @param {HTMLElement} reference
1532 * @param {number} padding
1533 * @param {HTMLElement} boundariesElement - Element used to define the boundaries
1534 * @param {Boolean} fixedPosition - Is in fixed position mode
1535 * @returns {Object} Coordinates of the boundaries
1536 */
1537function getBoundaries(popper, reference, padding, boundariesElement) {
1538 var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
1539
1540 // NOTE: 1 DOM access here
1541
1542 var boundaries = { top: 0, left: 0 };
1543 var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, reference);
1544
1545 // Handle viewport case
1546 if (boundariesElement === 'viewport') {
1547 boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
1548 } else {
1549 // Handle other cases based on DOM element used as boundaries
1550 var boundariesNode = void 0;
1551 if (boundariesElement === 'scrollParent') {
1552 boundariesNode = getScrollParent(getParentNode(reference));
1553 if (boundariesNode.nodeName === 'BODY') {
1554 boundariesNode = popper.ownerDocument.documentElement;
1555 }
1556 } else if (boundariesElement === 'window') {
1557 boundariesNode = popper.ownerDocument.documentElement;
1558 } else {
1559 boundariesNode = boundariesElement;
1560 }
1561
1562 var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
1563
1564 // In case of HTML, we need a different computation
1565 if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
1566 var _getWindowSizes = getWindowSizes(popper.ownerDocument),
1567 height = _getWindowSizes.height,
1568 width = _getWindowSizes.width;
1569
1570 boundaries.top += offsets.top - offsets.marginTop;
1571 boundaries.bottom = height + offsets.top;
1572 boundaries.left += offsets.left - offsets.marginLeft;
1573 boundaries.right = width + offsets.left;
1574 } else {
1575 // for all the other DOM elements, this one is good
1576 boundaries = offsets;
1577 }
1578 }
1579
1580 // Add paddings
1581 padding = padding || 0;
1582 var isPaddingNumber = typeof padding === 'number';
1583 boundaries.left += isPaddingNumber ? padding : padding.left || 0;
1584 boundaries.top += isPaddingNumber ? padding : padding.top || 0;
1585 boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
1586 boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
1587
1588 return boundaries;
1589}
1590
1591function getArea(_ref) {
1592 var width = _ref.width,
1593 height = _ref.height;
1594
1595 return width * height;
1596}
1597
1598/**
1599 * Utility used to transform the `auto` placement to the placement with more
1600 * available space.
1601 * @method
1602 * @memberof Popper.Utils
1603 * @argument {Object} data - The data object generated by update method
1604 * @argument {Object} options - Modifiers configuration and options
1605 * @returns {Object} The data object, properly modified
1606 */
1607function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
1608 var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
1609
1610 if (placement.indexOf('auto') === -1) {
1611 return placement;
1612 }
1613
1614 var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
1615
1616 var rects = {
1617 top: {
1618 width: boundaries.width,
1619 height: refRect.top - boundaries.top
1620 },
1621 right: {
1622 width: boundaries.right - refRect.right,
1623 height: boundaries.height
1624 },
1625 bottom: {
1626 width: boundaries.width,
1627 height: boundaries.bottom - refRect.bottom
1628 },
1629 left: {
1630 width: refRect.left - boundaries.left,
1631 height: boundaries.height
1632 }
1633 };
1634
1635 var sortedAreas = Object.keys(rects).map(function (key) {
1636 return _extends$1({
1637 key: key
1638 }, rects[key], {
1639 area: getArea(rects[key])
1640 });
1641 }).sort(function (a, b) {
1642 return b.area - a.area;
1643 });
1644
1645 var filteredAreas = sortedAreas.filter(function (_ref2) {
1646 var width = _ref2.width,
1647 height = _ref2.height;
1648 return width >= popper.clientWidth && height >= popper.clientHeight;
1649 });
1650
1651 var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
1652
1653 var variation = placement.split('-')[1];
1654
1655 return computedPlacement + (variation ? '-' + variation : '');
1656}
1657
1658/**
1659 * Get offsets to the reference element
1660 * @method
1661 * @memberof Popper.Utils
1662 * @param {Object} state
1663 * @param {Element} popper - the popper element
1664 * @param {Element} reference - the reference element (the popper will be relative to this)
1665 * @param {Element} fixedPosition - is in fixed position mode
1666 * @returns {Object} An object containing the offsets which will be applied to the popper
1667 */
1668function getReferenceOffsets(state, popper, reference) {
1669 var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
1670
1671 var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, reference);
1672 return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
1673}
1674
1675/**
1676 * Get the outer sizes of the given element (offset size + margins)
1677 * @method
1678 * @memberof Popper.Utils
1679 * @argument {Element} element
1680 * @returns {Object} object containing width and height properties
1681 */
1682function getOuterSizes(element) {
1683 var styles = getComputedStyle(element);
1684 var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
1685 var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
1686 var result = {
1687 width: element.offsetWidth + y,
1688 height: element.offsetHeight + x
1689 };
1690 return result;
1691}
1692
1693/**
1694 * Get the opposite placement of the given one
1695 * @method
1696 * @memberof Popper.Utils
1697 * @argument {String} placement
1698 * @returns {String} flipped placement
1699 */
1700function getOppositePlacement(placement) {
1701 var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
1702 return placement.replace(/left|right|bottom|top/g, function (matched) {
1703 return hash[matched];
1704 });
1705}
1706
1707/**
1708 * Get offsets to the popper
1709 * @method
1710 * @memberof Popper.Utils
1711 * @param {Object} position - CSS position the Popper will get applied
1712 * @param {HTMLElement} popper - the popper element
1713 * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
1714 * @param {String} placement - one of the valid placement options
1715 * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
1716 */
1717function getPopperOffsets(popper, referenceOffsets, placement) {
1718 placement = placement.split('-')[0];
1719
1720 // Get popper node sizes
1721 var popperRect = getOuterSizes(popper);
1722
1723 // Add position, width and height to our offsets object
1724 var popperOffsets = {
1725 width: popperRect.width,
1726 height: popperRect.height
1727 };
1728
1729 // depending by the popper placement we have to compute its offsets slightly differently
1730 var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
1731 var mainSide = isHoriz ? 'top' : 'left';
1732 var secondarySide = isHoriz ? 'left' : 'top';
1733 var measurement = isHoriz ? 'height' : 'width';
1734 var secondaryMeasurement = !isHoriz ? 'height' : 'width';
1735
1736 popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
1737 if (placement === secondarySide) {
1738 popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
1739 } else {
1740 popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
1741 }
1742
1743 return popperOffsets;
1744}
1745
1746/**
1747 * Mimics the `find` method of Array
1748 * @method
1749 * @memberof Popper.Utils
1750 * @argument {Array} arr
1751 * @argument prop
1752 * @argument value
1753 * @returns index or -1
1754 */
1755function find(arr, check) {
1756 // use native find if supported
1757 if (Array.prototype.find) {
1758 return arr.find(check);
1759 }
1760
1761 // use `filter` to obtain the same behavior of `find`
1762 return arr.filter(check)[0];
1763}
1764
1765/**
1766 * Return the index of the matching object
1767 * @method
1768 * @memberof Popper.Utils
1769 * @argument {Array} arr
1770 * @argument prop
1771 * @argument value
1772 * @returns index or -1
1773 */
1774function findIndex(arr, prop, value) {
1775 // use native findIndex if supported
1776 if (Array.prototype.findIndex) {
1777 return arr.findIndex(function (cur) {
1778 return cur[prop] === value;
1779 });
1780 }
1781
1782 // use `find` + `indexOf` if `findIndex` isn't supported
1783 var match = find(arr, function (obj) {
1784 return obj[prop] === value;
1785 });
1786 return arr.indexOf(match);
1787}
1788
1789/**
1790 * Loop trough the list of modifiers and run them in order,
1791 * each of them will then edit the data object.
1792 * @method
1793 * @memberof Popper.Utils
1794 * @param {dataObject} data
1795 * @param {Array} modifiers
1796 * @param {String} ends - Optional modifier name used as stopper
1797 * @returns {dataObject}
1798 */
1799function runModifiers(modifiers, data, ends) {
1800 var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
1801
1802 modifiersToRun.forEach(function (modifier) {
1803 if (modifier['function']) {
1804 // eslint-disable-line dot-notation
1805 console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
1806 }
1807 var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
1808 if (modifier.enabled && isFunction(fn)) {
1809 // Add properties to offsets to make them a complete clientRect object
1810 // we do this before each modifier to make sure the previous one doesn't
1811 // mess with these values
1812 data.offsets.popper = getClientRect(data.offsets.popper);
1813 data.offsets.reference = getClientRect(data.offsets.reference);
1814
1815 data = fn(data, modifier);
1816 }
1817 });
1818
1819 return data;
1820}
1821
1822/**
1823 * Updates the position of the popper, computing the new offsets and applying
1824 * the new style.<br />
1825 * Prefer `scheduleUpdate` over `update` because of performance reasons.
1826 * @method
1827 * @memberof Popper
1828 */
1829function update() {
1830 // if popper is destroyed, don't perform any further update
1831 if (this.state.isDestroyed) {
1832 return;
1833 }
1834
1835 var data = {
1836 instance: this,
1837 styles: {},
1838 arrowStyles: {},
1839 attributes: {},
1840 flipped: false,
1841 offsets: {}
1842 };
1843
1844 // compute reference element offsets
1845 data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
1846
1847 // compute auto placement, store placement inside the data object,
1848 // modifiers will be able to edit `placement` if needed
1849 // and refer to originalPlacement to know the original value
1850 data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
1851
1852 // store the computed placement inside `originalPlacement`
1853 data.originalPlacement = data.placement;
1854
1855 data.positionFixed = this.options.positionFixed;
1856
1857 // compute the popper offsets
1858 data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
1859
1860 data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
1861
1862 // run the modifiers
1863 data = runModifiers(this.modifiers, data);
1864
1865 // the first `update` will call `onCreate` callback
1866 // the other ones will call `onUpdate` callback
1867 if (!this.state.isCreated) {
1868 this.state.isCreated = true;
1869 this.options.onCreate(data);
1870 } else {
1871 this.options.onUpdate(data);
1872 }
1873}
1874
1875/**
1876 * Helper used to know if the given modifier is enabled.
1877 * @method
1878 * @memberof Popper.Utils
1879 * @returns {Boolean}
1880 */
1881function isModifierEnabled(modifiers, modifierName) {
1882 return modifiers.some(function (_ref) {
1883 var name = _ref.name,
1884 enabled = _ref.enabled;
1885 return enabled && name === modifierName;
1886 });
1887}
1888
1889/**
1890 * Get the prefixed supported property name
1891 * @method
1892 * @memberof Popper.Utils
1893 * @argument {String} property (camelCase)
1894 * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
1895 */
1896function getSupportedPropertyName(property) {
1897 var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
1898 var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
1899
1900 for (var i = 0; i < prefixes.length; i++) {
1901 var prefix = prefixes[i];
1902 var toCheck = prefix ? '' + prefix + upperProp : property;
1903 if (typeof document.body.style[toCheck] !== 'undefined') {
1904 return toCheck;
1905 }
1906 }
1907 return null;
1908}
1909
1910/**
1911 * Destroys the popper.
1912 * @method
1913 * @memberof Popper
1914 */
1915function destroy() {
1916 this.state.isDestroyed = true;
1917
1918 // touch DOM only if `applyStyle` modifier is enabled
1919 if (isModifierEnabled(this.modifiers, 'applyStyle')) {
1920 this.popper.removeAttribute('x-placement');
1921 this.popper.style.position = '';
1922 this.popper.style.top = '';
1923 this.popper.style.left = '';
1924 this.popper.style.right = '';
1925 this.popper.style.bottom = '';
1926 this.popper.style.willChange = '';
1927 this.popper.style[getSupportedPropertyName('transform')] = '';
1928 }
1929
1930 this.disableEventListeners();
1931
1932 // remove the popper if user explicity asked for the deletion on destroy
1933 // do not use `remove` because IE11 doesn't support it
1934 if (this.options.removeOnDestroy) {
1935 this.popper.parentNode.removeChild(this.popper);
1936 }
1937 return this;
1938}
1939
1940/**
1941 * Get the window associated with the element
1942 * @argument {Element} element
1943 * @returns {Window}
1944 */
1945function getWindow(element) {
1946 var ownerDocument = element.ownerDocument;
1947 return ownerDocument ? ownerDocument.defaultView : window;
1948}
1949
1950function attachToScrollParents(scrollParent, event, callback, scrollParents) {
1951 var isBody = scrollParent.nodeName === 'BODY';
1952 var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
1953 target.addEventListener(event, callback, { passive: true });
1954
1955 if (!isBody) {
1956 attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
1957 }
1958 scrollParents.push(target);
1959}
1960
1961/**
1962 * Setup needed event listeners used to update the popper position
1963 * @method
1964 * @memberof Popper.Utils
1965 * @private
1966 */
1967function setupEventListeners(reference, options, state, updateBound) {
1968 // Resize event listener on window
1969 state.updateBound = updateBound;
1970 getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
1971
1972 // Scroll event listener on scroll parents
1973 var scrollElement = getScrollParent(reference);
1974 attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
1975 state.scrollElement = scrollElement;
1976 state.eventsEnabled = true;
1977
1978 return state;
1979}
1980
1981/**
1982 * It will add resize/scroll events and start recalculating
1983 * position of the popper element when they are triggered.
1984 * @method
1985 * @memberof Popper
1986 */
1987function enableEventListeners() {
1988 if (!this.state.eventsEnabled) {
1989 this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
1990 }
1991}
1992
1993/**
1994 * Remove event listeners used to update the popper position
1995 * @method
1996 * @memberof Popper.Utils
1997 * @private
1998 */
1999function removeEventListeners(reference, state) {
2000 // Remove resize event listener on window
2001 getWindow(reference).removeEventListener('resize', state.updateBound);
2002
2003 // Remove scroll event listener on scroll parents
2004 state.scrollParents.forEach(function (target) {
2005 target.removeEventListener('scroll', state.updateBound);
2006 });
2007
2008 // Reset state
2009 state.updateBound = null;
2010 state.scrollParents = [];
2011 state.scrollElement = null;
2012 state.eventsEnabled = false;
2013 return state;
2014}
2015
2016/**
2017 * It will remove resize/scroll events and won't recalculate popper position
2018 * when they are triggered. It also won't trigger `onUpdate` callback anymore,
2019 * unless you call `update` method manually.
2020 * @method
2021 * @memberof Popper
2022 */
2023function disableEventListeners() {
2024 if (this.state.eventsEnabled) {
2025 cancelAnimationFrame(this.scheduleUpdate);
2026 this.state = removeEventListeners(this.reference, this.state);
2027 }
2028}
2029
2030/**
2031 * Tells if a given input is a number
2032 * @method
2033 * @memberof Popper.Utils
2034 * @param {*} input to check
2035 * @return {Boolean}
2036 */
2037function isNumeric(n) {
2038 return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
2039}
2040
2041/**
2042 * Set the style to the given popper
2043 * @method
2044 * @memberof Popper.Utils
2045 * @argument {Element} element - Element to apply the style to
2046 * @argument {Object} styles
2047 * Object with a list of properties and values which will be applied to the element
2048 */
2049function setStyles(element, styles) {
2050 Object.keys(styles).forEach(function (prop) {
2051 var unit = '';
2052 // add unit if the value is numeric and is one of the following
2053 if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
2054 unit = 'px';
2055 }
2056 element.style[prop] = styles[prop] + unit;
2057 });
2058}
2059
2060/**
2061 * Set the attributes to the given popper
2062 * @method
2063 * @memberof Popper.Utils
2064 * @argument {Element} element - Element to apply the attributes to
2065 * @argument {Object} styles
2066 * Object with a list of properties and values which will be applied to the element
2067 */
2068function setAttributes(element, attributes) {
2069 Object.keys(attributes).forEach(function (prop) {
2070 var value = attributes[prop];
2071 if (value !== false) {
2072 element.setAttribute(prop, attributes[prop]);
2073 } else {
2074 element.removeAttribute(prop);
2075 }
2076 });
2077}
2078
2079/**
2080 * @function
2081 * @memberof Modifiers
2082 * @argument {Object} data - The data object generated by `update` method
2083 * @argument {Object} data.styles - List of style properties - values to apply to popper element
2084 * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
2085 * @argument {Object} options - Modifiers configuration and options
2086 * @returns {Object} The same data object
2087 */
2088function applyStyle(data) {
2089 // any property present in `data.styles` will be applied to the popper,
2090 // in this way we can make the 3rd party modifiers add custom styles to it
2091 // Be aware, modifiers could override the properties defined in the previous
2092 // lines of this modifier!
2093 setStyles(data.instance.popper, data.styles);
2094
2095 // any property present in `data.attributes` will be applied to the popper,
2096 // they will be set as HTML attributes of the element
2097 setAttributes(data.instance.popper, data.attributes);
2098
2099 // if arrowElement is defined and arrowStyles has some properties
2100 if (data.arrowElement && Object.keys(data.arrowStyles).length) {
2101 setStyles(data.arrowElement, data.arrowStyles);
2102 }
2103
2104 return data;
2105}
2106
2107/**
2108 * Set the x-placement attribute before everything else because it could be used
2109 * to add margins to the popper margins needs to be calculated to get the
2110 * correct popper offsets.
2111 * @method
2112 * @memberof Popper.modifiers
2113 * @param {HTMLElement} reference - The reference element used to position the popper
2114 * @param {HTMLElement} popper - The HTML element used as popper
2115 * @param {Object} options - Popper.js options
2116 */
2117function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
2118 // compute reference element offsets
2119 var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
2120
2121 // compute auto placement, store placement inside the data object,
2122 // modifiers will be able to edit `placement` if needed
2123 // and refer to originalPlacement to know the original value
2124 var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
2125
2126 popper.setAttribute('x-placement', placement);
2127
2128 // Apply `position` to popper before anything else because
2129 // without the position applied we can't guarantee correct computations
2130 setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
2131
2132 return options;
2133}
2134
2135/**
2136 * @function
2137 * @memberof Modifiers
2138 * @argument {Object} data - The data object generated by `update` method
2139 * @argument {Object} options - Modifiers configuration and options
2140 * @returns {Object} The data object, properly modified
2141 */
2142function computeStyle(data, options) {
2143 var x = options.x,
2144 y = options.y;
2145 var popper = data.offsets.popper;
2146
2147 // Remove this legacy support in Popper.js v2
2148
2149 var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
2150 return modifier.name === 'applyStyle';
2151 }).gpuAcceleration;
2152 if (legacyGpuAccelerationOption !== undefined) {
2153 console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
2154 }
2155 var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
2156
2157 var offsetParent = getOffsetParent(data.instance.popper);
2158 var offsetParentRect = getBoundingClientRect(offsetParent);
2159
2160 // Styles
2161 var styles = {
2162 position: popper.position
2163 };
2164
2165 // Avoid blurry text by using full pixel integers.
2166 // For pixel-perfect positioning, top/bottom prefers rounded
2167 // values, while left/right prefers floored values.
2168 var offsets = {
2169 left: Math.floor(popper.left),
2170 top: Math.round(popper.top),
2171 bottom: Math.round(popper.bottom),
2172 right: Math.floor(popper.right)
2173 };
2174
2175 var sideA = x === 'bottom' ? 'top' : 'bottom';
2176 var sideB = y === 'right' ? 'left' : 'right';
2177
2178 // if gpuAcceleration is set to `true` and transform is supported,
2179 // we use `translate3d` to apply the position to the popper we
2180 // automatically use the supported prefixed version if needed
2181 var prefixedProperty = getSupportedPropertyName('transform');
2182
2183 // now, let's make a step back and look at this code closely (wtf?)
2184 // If the content of the popper grows once it's been positioned, it
2185 // may happen that the popper gets misplaced because of the new content
2186 // overflowing its reference element
2187 // To avoid this problem, we provide two options (x and y), which allow
2188 // the consumer to define the offset origin.
2189 // If we position a popper on top of a reference element, we can set
2190 // `x` to `top` to make the popper grow towards its top instead of
2191 // its bottom.
2192 var left = void 0,
2193 top = void 0;
2194 if (sideA === 'bottom') {
2195 // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
2196 // and not the bottom of the html element
2197 if (offsetParent.nodeName === 'HTML') {
2198 top = -offsetParent.clientHeight + offsets.bottom;
2199 } else {
2200 top = -offsetParentRect.height + offsets.bottom;
2201 }
2202 } else {
2203 top = offsets.top;
2204 }
2205 if (sideB === 'right') {
2206 if (offsetParent.nodeName === 'HTML') {
2207 left = -offsetParent.clientWidth + offsets.right;
2208 } else {
2209 left = -offsetParentRect.width + offsets.right;
2210 }
2211 } else {
2212 left = offsets.left;
2213 }
2214 if (gpuAcceleration && prefixedProperty) {
2215 styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
2216 styles[sideA] = 0;
2217 styles[sideB] = 0;
2218 styles.willChange = 'transform';
2219 } else {
2220 // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
2221 var invertTop = sideA === 'bottom' ? -1 : 1;
2222 var invertLeft = sideB === 'right' ? -1 : 1;
2223 styles[sideA] = top * invertTop;
2224 styles[sideB] = left * invertLeft;
2225 styles.willChange = sideA + ', ' + sideB;
2226 }
2227
2228 // Attributes
2229 var attributes = {
2230 'x-placement': data.placement
2231 };
2232
2233 // Update `data` attributes, styles and arrowStyles
2234 data.attributes = _extends$1({}, attributes, data.attributes);
2235 data.styles = _extends$1({}, styles, data.styles);
2236 data.arrowStyles = _extends$1({}, data.offsets.arrow, data.arrowStyles);
2237
2238 return data;
2239}
2240
2241/**
2242 * Helper used to know if the given modifier depends from another one.<br />
2243 * It checks if the needed modifier is listed and enabled.
2244 * @method
2245 * @memberof Popper.Utils
2246 * @param {Array} modifiers - list of modifiers
2247 * @param {String} requestingName - name of requesting modifier
2248 * @param {String} requestedName - name of requested modifier
2249 * @returns {Boolean}
2250 */
2251function isModifierRequired(modifiers, requestingName, requestedName) {
2252 var requesting = find(modifiers, function (_ref) {
2253 var name = _ref.name;
2254 return name === requestingName;
2255 });
2256
2257 var isRequired = !!requesting && modifiers.some(function (modifier) {
2258 return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
2259 });
2260
2261 if (!isRequired) {
2262 var _requesting = '`' + requestingName + '`';
2263 var requested = '`' + requestedName + '`';
2264 console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
2265 }
2266 return isRequired;
2267}
2268
2269/**
2270 * @function
2271 * @memberof Modifiers
2272 * @argument {Object} data - The data object generated by update method
2273 * @argument {Object} options - Modifiers configuration and options
2274 * @returns {Object} The data object, properly modified
2275 */
2276function arrow(data, options) {
2277 var _data$offsets$arrow;
2278
2279 // arrow depends on keepTogether in order to work
2280 if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
2281 return data;
2282 }
2283
2284 var arrowElement = options.element;
2285
2286 // if arrowElement is a string, suppose it's a CSS selector
2287 if (typeof arrowElement === 'string') {
2288 arrowElement = data.instance.popper.querySelector(arrowElement);
2289
2290 // if arrowElement is not found, don't run the modifier
2291 if (!arrowElement) {
2292 return data;
2293 }
2294 } else {
2295 // if the arrowElement isn't a query selector we must check that the
2296 // provided DOM node is child of its popper node
2297 if (!data.instance.popper.contains(arrowElement)) {
2298 console.warn('WARNING: `arrow.element` must be child of its popper element!');
2299 return data;
2300 }
2301 }
2302
2303 var placement = data.placement.split('-')[0];
2304 var _data$offsets = data.offsets,
2305 popper = _data$offsets.popper,
2306 reference = _data$offsets.reference;
2307
2308 var isVertical = ['left', 'right'].indexOf(placement) !== -1;
2309
2310 var len = isVertical ? 'height' : 'width';
2311 var sideCapitalized = isVertical ? 'Top' : 'Left';
2312 var side = sideCapitalized.toLowerCase();
2313 var altSide = isVertical ? 'left' : 'top';
2314 var opSide = isVertical ? 'bottom' : 'right';
2315 var arrowElementSize = getOuterSizes(arrowElement)[len];
2316
2317 //
2318 // extends keepTogether behavior making sure the popper and its
2319 // reference have enough pixels in conjunction
2320 //
2321
2322 // top/left side
2323 if (reference[opSide] - arrowElementSize < popper[side]) {
2324 data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
2325 }
2326 // bottom/right side
2327 if (reference[side] + arrowElementSize > popper[opSide]) {
2328 data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
2329 }
2330 data.offsets.popper = getClientRect(data.offsets.popper);
2331
2332 // compute center of the popper
2333 var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
2334
2335 // Compute the sideValue using the updated popper offsets
2336 // take popper margin in account because we don't have this info available
2337 var css = getStyleComputedProperty(data.instance.popper);
2338 var popperMarginSide = parseFloat(css['margin' + sideCapitalized], 10);
2339 var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width'], 10);
2340 var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
2341
2342 // prevent arrowElement from being placed not contiguously to its popper
2343 sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
2344
2345 data.arrowElement = arrowElement;
2346 data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty$1(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty$1(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
2347
2348 return data;
2349}
2350
2351/**
2352 * Get the opposite placement variation of the given one
2353 * @method
2354 * @memberof Popper.Utils
2355 * @argument {String} placement variation
2356 * @returns {String} flipped placement variation
2357 */
2358function getOppositeVariation(variation) {
2359 if (variation === 'end') {
2360 return 'start';
2361 } else if (variation === 'start') {
2362 return 'end';
2363 }
2364 return variation;
2365}
2366
2367/**
2368 * List of accepted placements to use as values of the `placement` option.<br />
2369 * Valid placements are:
2370 * - `auto`
2371 * - `top`
2372 * - `right`
2373 * - `bottom`
2374 * - `left`
2375 *
2376 * Each placement can have a variation from this list:
2377 * - `-start`
2378 * - `-end`
2379 *
2380 * Variations are interpreted easily if you think of them as the left to right
2381 * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
2382 * is right.<br />
2383 * Vertically (`left` and `right`), `start` is top and `end` is bottom.
2384 *
2385 * Some valid examples are:
2386 * - `top-end` (on top of reference, right aligned)
2387 * - `right-start` (on right of reference, top aligned)
2388 * - `bottom` (on bottom, centered)
2389 * - `auto-end` (on the side with more space available, alignment depends by placement)
2390 *
2391 * @static
2392 * @type {Array}
2393 * @enum {String}
2394 * @readonly
2395 * @method placements
2396 * @memberof Popper
2397 */
2398var placements = ['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start'];
2399
2400// Get rid of `auto` `auto-start` and `auto-end`
2401var validPlacements = placements.slice(3);
2402
2403/**
2404 * Given an initial placement, returns all the subsequent placements
2405 * clockwise (or counter-clockwise).
2406 *
2407 * @method
2408 * @memberof Popper.Utils
2409 * @argument {String} placement - A valid placement (it accepts variations)
2410 * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
2411 * @returns {Array} placements including their variations
2412 */
2413function clockwise(placement) {
2414 var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2415
2416 var index = validPlacements.indexOf(placement);
2417 var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
2418 return counter ? arr.reverse() : arr;
2419}
2420
2421var BEHAVIORS = {
2422 FLIP: 'flip',
2423 CLOCKWISE: 'clockwise',
2424 COUNTERCLOCKWISE: 'counterclockwise'
2425};
2426
2427/**
2428 * @function
2429 * @memberof Modifiers
2430 * @argument {Object} data - The data object generated by update method
2431 * @argument {Object} options - Modifiers configuration and options
2432 * @returns {Object} The data object, properly modified
2433 */
2434function flip(data, options) {
2435 // if `inner` modifier is enabled, we can't use the `flip` modifier
2436 if (isModifierEnabled(data.instance.modifiers, 'inner')) {
2437 return data;
2438 }
2439
2440 if (data.flipped && data.placement === data.originalPlacement) {
2441 // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
2442 return data;
2443 }
2444
2445 var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
2446
2447 var placement = data.placement.split('-')[0];
2448 var placementOpposite = getOppositePlacement(placement);
2449 var variation = data.placement.split('-')[1] || '';
2450
2451 var flipOrder = [];
2452
2453 switch (options.behavior) {
2454 case BEHAVIORS.FLIP:
2455 flipOrder = [placement, placementOpposite];
2456 break;
2457 case BEHAVIORS.CLOCKWISE:
2458 flipOrder = clockwise(placement);
2459 break;
2460 case BEHAVIORS.COUNTERCLOCKWISE:
2461 flipOrder = clockwise(placement, true);
2462 break;
2463 default:
2464 flipOrder = options.behavior;
2465 }
2466
2467 flipOrder.forEach(function (step, index) {
2468 if (placement !== step || flipOrder.length === index + 1) {
2469 return data;
2470 }
2471
2472 placement = data.placement.split('-')[0];
2473 placementOpposite = getOppositePlacement(placement);
2474
2475 var popperOffsets = data.offsets.popper;
2476 var refOffsets = data.offsets.reference;
2477
2478 // using floor because the reference offsets may contain decimals we are not going to consider here
2479 var floor = Math.floor;
2480 var overlapsRef = placement === 'left' && floor(popperOffsets.right) > floor(refOffsets.left) || placement === 'right' && floor(popperOffsets.left) < floor(refOffsets.right) || placement === 'top' && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === 'bottom' && floor(popperOffsets.top) < floor(refOffsets.bottom);
2481
2482 var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
2483 var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
2484 var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
2485 var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
2486
2487 var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
2488
2489 // flip the variation if required
2490 var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
2491 var flippedVariation = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
2492
2493 if (overlapsRef || overflowsBoundaries || flippedVariation) {
2494 // this boolean to detect any flip loop
2495 data.flipped = true;
2496
2497 if (overlapsRef || overflowsBoundaries) {
2498 placement = flipOrder[index + 1];
2499 }
2500
2501 if (flippedVariation) {
2502 variation = getOppositeVariation(variation);
2503 }
2504
2505 data.placement = placement + (variation ? '-' + variation : '');
2506
2507 // this object contains `position`, we want to preserve it along with
2508 // any additional property we may add in the future
2509 data.offsets.popper = _extends$1({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
2510
2511 data = runModifiers(data.instance.modifiers, data, 'flip');
2512 }
2513 });
2514 return data;
2515}
2516
2517/**
2518 * @function
2519 * @memberof Modifiers
2520 * @argument {Object} data - The data object generated by update method
2521 * @argument {Object} options - Modifiers configuration and options
2522 * @returns {Object} The data object, properly modified
2523 */
2524function keepTogether(data) {
2525 var _data$offsets = data.offsets,
2526 popper = _data$offsets.popper,
2527 reference = _data$offsets.reference;
2528
2529 var placement = data.placement.split('-')[0];
2530 var floor = Math.floor;
2531 var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
2532 var side = isVertical ? 'right' : 'bottom';
2533 var opSide = isVertical ? 'left' : 'top';
2534 var measurement = isVertical ? 'width' : 'height';
2535
2536 if (popper[side] < floor(reference[opSide])) {
2537 data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
2538 }
2539 if (popper[opSide] > floor(reference[side])) {
2540 data.offsets.popper[opSide] = floor(reference[side]);
2541 }
2542
2543 return data;
2544}
2545
2546/**
2547 * Converts a string containing value + unit into a px value number
2548 * @function
2549 * @memberof {modifiers~offset}
2550 * @private
2551 * @argument {String} str - Value + unit string
2552 * @argument {String} measurement - `height` or `width`
2553 * @argument {Object} popperOffsets
2554 * @argument {Object} referenceOffsets
2555 * @returns {Number|String}
2556 * Value in pixels, or original string if no values were extracted
2557 */
2558function toValue(str, measurement, popperOffsets, referenceOffsets) {
2559 // separate value from unit
2560 var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
2561 var value = +split[1];
2562 var unit = split[2];
2563
2564 // If it's not a number it's an operator, I guess
2565 if (!value) {
2566 return str;
2567 }
2568
2569 if (unit.indexOf('%') === 0) {
2570 var element = void 0;
2571 switch (unit) {
2572 case '%p':
2573 element = popperOffsets;
2574 break;
2575 case '%':
2576 case '%r':
2577 default:
2578 element = referenceOffsets;
2579 }
2580
2581 var rect = getClientRect(element);
2582 return rect[measurement] / 100 * value;
2583 } else if (unit === 'vh' || unit === 'vw') {
2584 // if is a vh or vw, we calculate the size based on the viewport
2585 var size = void 0;
2586 if (unit === 'vh') {
2587 size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
2588 } else {
2589 size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
2590 }
2591 return size / 100 * value;
2592 } else {
2593 // if is an explicit pixel unit, we get rid of the unit and keep the value
2594 // if is an implicit unit, it's px, and we return just the value
2595 return value;
2596 }
2597}
2598
2599/**
2600 * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
2601 * @function
2602 * @memberof {modifiers~offset}
2603 * @private
2604 * @argument {String} offset
2605 * @argument {Object} popperOffsets
2606 * @argument {Object} referenceOffsets
2607 * @argument {String} basePlacement
2608 * @returns {Array} a two cells array with x and y offsets in numbers
2609 */
2610function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
2611 var offsets = [0, 0];
2612
2613 // Use height if placement is left or right and index is 0 otherwise use width
2614 // in this way the first offset will use an axis and the second one
2615 // will use the other one
2616 var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
2617
2618 // Split the offset string to obtain a list of values and operands
2619 // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
2620 var fragments = offset.split(/(\+|\-)/).map(function (frag) {
2621 return frag.trim();
2622 });
2623
2624 // Detect if the offset string contains a pair of values or a single one
2625 // they could be separated by comma or space
2626 var divider = fragments.indexOf(find(fragments, function (frag) {
2627 return frag.search(/,|\s/) !== -1;
2628 }));
2629
2630 if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
2631 console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
2632 }
2633
2634 // If divider is found, we divide the list of values and operands to divide
2635 // them by ofset X and Y.
2636 var splitRegex = /\s*,\s*|\s+/;
2637 var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments];
2638
2639 // Convert the values with units to absolute pixels to allow our computations
2640 ops = ops.map(function (op, index) {
2641 // Most of the units rely on the orientation of the popper
2642 var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
2643 var mergeWithPrevious = false;
2644 return op
2645 // This aggregates any `+` or `-` sign that aren't considered operators
2646 // e.g.: 10 + +5 => [10, +, +5]
2647 .reduce(function (a, b) {
2648 if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
2649 a[a.length - 1] = b;
2650 mergeWithPrevious = true;
2651 return a;
2652 } else if (mergeWithPrevious) {
2653 a[a.length - 1] += b;
2654 mergeWithPrevious = false;
2655 return a;
2656 } else {
2657 return a.concat(b);
2658 }
2659 }, [])
2660 // Here we convert the string values into number values (in px)
2661 .map(function (str) {
2662 return toValue(str, measurement, popperOffsets, referenceOffsets);
2663 });
2664 });
2665
2666 // Loop trough the offsets arrays and execute the operations
2667 ops.forEach(function (op, index) {
2668 op.forEach(function (frag, index2) {
2669 if (isNumeric(frag)) {
2670 offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
2671 }
2672 });
2673 });
2674 return offsets;
2675}
2676
2677/**
2678 * @function
2679 * @memberof Modifiers
2680 * @argument {Object} data - The data object generated by update method
2681 * @argument {Object} options - Modifiers configuration and options
2682 * @argument {Number|String} options.offset=0
2683 * The offset value as described in the modifier description
2684 * @returns {Object} The data object, properly modified
2685 */
2686function offset(data, _ref) {
2687 var offset = _ref.offset;
2688 var placement = data.placement,
2689 _data$offsets = data.offsets,
2690 popper = _data$offsets.popper,
2691 reference = _data$offsets.reference;
2692
2693 var basePlacement = placement.split('-')[0];
2694
2695 var offsets = void 0;
2696 if (isNumeric(+offset)) {
2697 offsets = [+offset, 0];
2698 } else {
2699 offsets = parseOffset(offset, popper, reference, basePlacement);
2700 }
2701
2702 if (basePlacement === 'left') {
2703 popper.top += offsets[0];
2704 popper.left -= offsets[1];
2705 } else if (basePlacement === 'right') {
2706 popper.top += offsets[0];
2707 popper.left += offsets[1];
2708 } else if (basePlacement === 'top') {
2709 popper.left += offsets[0];
2710 popper.top -= offsets[1];
2711 } else if (basePlacement === 'bottom') {
2712 popper.left += offsets[0];
2713 popper.top += offsets[1];
2714 }
2715
2716 data.popper = popper;
2717 return data;
2718}
2719
2720/**
2721 * @function
2722 * @memberof Modifiers
2723 * @argument {Object} data - The data object generated by `update` method
2724 * @argument {Object} options - Modifiers configuration and options
2725 * @returns {Object} The data object, properly modified
2726 */
2727function preventOverflow(data, options) {
2728 var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
2729
2730 // If offsetParent is the reference element, we really want to
2731 // go one step up and use the next offsetParent as reference to
2732 // avoid to make this modifier completely useless and look like broken
2733 if (data.instance.reference === boundariesElement) {
2734 boundariesElement = getOffsetParent(boundariesElement);
2735 }
2736
2737 // NOTE: DOM access here
2738 // resets the popper's position so that the document size can be calculated excluding
2739 // the size of the popper element itself
2740 var transformProp = getSupportedPropertyName('transform');
2741 var popperStyles = data.instance.popper.style; // assignment to help minification
2742 var top = popperStyles.top,
2743 left = popperStyles.left,
2744 transform = popperStyles[transformProp];
2745
2746 popperStyles.top = '';
2747 popperStyles.left = '';
2748 popperStyles[transformProp] = '';
2749
2750 var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
2751
2752 // NOTE: DOM access here
2753 // restores the original style properties after the offsets have been computed
2754 popperStyles.top = top;
2755 popperStyles.left = left;
2756 popperStyles[transformProp] = transform;
2757
2758 options.boundaries = boundaries;
2759
2760 var order = options.priority;
2761 var popper = data.offsets.popper;
2762
2763 var check = {
2764 primary: function primary(placement) {
2765 var value = popper[placement];
2766 if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
2767 value = Math.max(popper[placement], boundaries[placement]);
2768 }
2769 return defineProperty$1({}, placement, value);
2770 },
2771 secondary: function secondary(placement) {
2772 var mainSide = placement === 'right' ? 'left' : 'top';
2773 var value = popper[mainSide];
2774 if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
2775 value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
2776 }
2777 return defineProperty$1({}, mainSide, value);
2778 }
2779 };
2780
2781 order.forEach(function (placement) {
2782 var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
2783 popper = _extends$1({}, popper, check[side](placement));
2784 });
2785
2786 data.offsets.popper = popper;
2787
2788 return data;
2789}
2790
2791/**
2792 * @function
2793 * @memberof Modifiers
2794 * @argument {Object} data - The data object generated by `update` method
2795 * @argument {Object} options - Modifiers configuration and options
2796 * @returns {Object} The data object, properly modified
2797 */
2798function shift(data) {
2799 var placement = data.placement;
2800 var basePlacement = placement.split('-')[0];
2801 var shiftvariation = placement.split('-')[1];
2802
2803 // if shift shiftvariation is specified, run the modifier
2804 if (shiftvariation) {
2805 var _data$offsets = data.offsets,
2806 reference = _data$offsets.reference,
2807 popper = _data$offsets.popper;
2808
2809 var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
2810 var side = isVertical ? 'left' : 'top';
2811 var measurement = isVertical ? 'width' : 'height';
2812
2813 var shiftOffsets = {
2814 start: defineProperty$1({}, side, reference[side]),
2815 end: defineProperty$1({}, side, reference[side] + reference[measurement] - popper[measurement])
2816 };
2817
2818 data.offsets.popper = _extends$1({}, popper, shiftOffsets[shiftvariation]);
2819 }
2820
2821 return data;
2822}
2823
2824/**
2825 * @function
2826 * @memberof Modifiers
2827 * @argument {Object} data - The data object generated by update method
2828 * @argument {Object} options - Modifiers configuration and options
2829 * @returns {Object} The data object, properly modified
2830 */
2831function hide(data) {
2832 if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
2833 return data;
2834 }
2835
2836 var refRect = data.offsets.reference;
2837 var bound = find(data.instance.modifiers, function (modifier) {
2838 return modifier.name === 'preventOverflow';
2839 }).boundaries;
2840
2841 if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
2842 // Avoid unnecessary DOM access if visibility hasn't changed
2843 if (data.hide === true) {
2844 return data;
2845 }
2846
2847 data.hide = true;
2848 data.attributes['x-out-of-boundaries'] = '';
2849 } else {
2850 // Avoid unnecessary DOM access if visibility hasn't changed
2851 if (data.hide === false) {
2852 return data;
2853 }
2854
2855 data.hide = false;
2856 data.attributes['x-out-of-boundaries'] = false;
2857 }
2858
2859 return data;
2860}
2861
2862/**
2863 * @function
2864 * @memberof Modifiers
2865 * @argument {Object} data - The data object generated by `update` method
2866 * @argument {Object} options - Modifiers configuration and options
2867 * @returns {Object} The data object, properly modified
2868 */
2869function inner(data) {
2870 var placement = data.placement;
2871 var basePlacement = placement.split('-')[0];
2872 var _data$offsets = data.offsets,
2873 popper = _data$offsets.popper,
2874 reference = _data$offsets.reference;
2875
2876 var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
2877
2878 var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
2879
2880 popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
2881
2882 data.placement = getOppositePlacement(placement);
2883 data.offsets.popper = getClientRect(popper);
2884
2885 return data;
2886}
2887
2888/**
2889 * Modifier function, each modifier can have a function of this type assigned
2890 * to its `fn` property.<br />
2891 * These functions will be called on each update, this means that you must
2892 * make sure they are performant enough to avoid performance bottlenecks.
2893 *
2894 * @function ModifierFn
2895 * @argument {dataObject} data - The data object generated by `update` method
2896 * @argument {Object} options - Modifiers configuration and options
2897 * @returns {dataObject} The data object, properly modified
2898 */
2899
2900/**
2901 * Modifiers are plugins used to alter the behavior of your poppers.<br />
2902 * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
2903 * needed by the library.
2904 *
2905 * Usually you don't want to override the `order`, `fn` and `onLoad` props.
2906 * All the other properties are configurations that could be tweaked.
2907 * @namespace modifiers
2908 */
2909var modifiers = {
2910 /**
2911 * Modifier used to shift the popper on the start or end of its reference
2912 * element.<br />
2913 * It will read the variation of the `placement` property.<br />
2914 * It can be one either `-end` or `-start`.
2915 * @memberof modifiers
2916 * @inner
2917 */
2918 shift: {
2919 /** @prop {number} order=100 - Index used to define the order of execution */
2920 order: 100,
2921 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
2922 enabled: true,
2923 /** @prop {ModifierFn} */
2924 fn: shift
2925 },
2926
2927 /**
2928 * The `offset` modifier can shift your popper on both its axis.
2929 *
2930 * It accepts the following units:
2931 * - `px` or unit-less, interpreted as pixels
2932 * - `%` or `%r`, percentage relative to the length of the reference element
2933 * - `%p`, percentage relative to the length of the popper element
2934 * - `vw`, CSS viewport width unit
2935 * - `vh`, CSS viewport height unit
2936 *
2937 * For length is intended the main axis relative to the placement of the popper.<br />
2938 * This means that if the placement is `top` or `bottom`, the length will be the
2939 * `width`. In case of `left` or `right`, it will be the `height`.
2940 *
2941 * You can provide a single value (as `Number` or `String`), or a pair of values
2942 * as `String` divided by a comma or one (or more) white spaces.<br />
2943 * The latter is a deprecated method because it leads to confusion and will be
2944 * removed in v2.<br />
2945 * Additionally, it accepts additions and subtractions between different units.
2946 * Note that multiplications and divisions aren't supported.
2947 *
2948 * Valid examples are:
2949 * ```
2950 * 10
2951 * '10%'
2952 * '10, 10'
2953 * '10%, 10'
2954 * '10 + 10%'
2955 * '10 - 5vh + 3%'
2956 * '-10px + 5vh, 5px - 6%'
2957 * ```
2958 * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
2959 * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
2960 * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
2961 *
2962 * @memberof modifiers
2963 * @inner
2964 */
2965 offset: {
2966 /** @prop {number} order=200 - Index used to define the order of execution */
2967 order: 200,
2968 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
2969 enabled: true,
2970 /** @prop {ModifierFn} */
2971 fn: offset,
2972 /** @prop {Number|String} offset=0
2973 * The offset value as described in the modifier description
2974 */
2975 offset: 0
2976 },
2977
2978 /**
2979 * Modifier used to prevent the popper from being positioned outside the boundary.
2980 *
2981 * A scenario exists where the reference itself is not within the boundaries.<br />
2982 * We can say it has "escaped the boundaries" — or just "escaped".<br />
2983 * In this case we need to decide whether the popper should either:
2984 *
2985 * - detach from the reference and remain "trapped" in the boundaries, or
2986 * - if it should ignore the boundary and "escape with its reference"
2987 *
2988 * When `escapeWithReference` is set to`true` and reference is completely
2989 * outside its boundaries, the popper will overflow (or completely leave)
2990 * the boundaries in order to remain attached to the edge of the reference.
2991 *
2992 * @memberof modifiers
2993 * @inner
2994 */
2995 preventOverflow: {
2996 /** @prop {number} order=300 - Index used to define the order of execution */
2997 order: 300,
2998 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
2999 enabled: true,
3000 /** @prop {ModifierFn} */
3001 fn: preventOverflow,
3002 /**
3003 * @prop {Array} [priority=['left','right','top','bottom']]
3004 * Popper will try to prevent overflow following these priorities by default,
3005 * then, it could overflow on the left and on top of the `boundariesElement`
3006 */
3007 priority: ['left', 'right', 'top', 'bottom'],
3008 /**
3009 * @prop {number} padding=5
3010 * Amount of pixel used to define a minimum distance between the boundaries
3011 * and the popper. This makes sure the popper always has a little padding
3012 * between the edges of its container
3013 */
3014 padding: 5,
3015 /**
3016 * @prop {String|HTMLElement} boundariesElement='scrollParent'
3017 * Boundaries used by the modifier. Can be `scrollParent`, `window`,
3018 * `viewport` or any DOM element.
3019 */
3020 boundariesElement: 'scrollParent'
3021 },
3022
3023 /**
3024 * Modifier used to make sure the reference and its popper stay near each other
3025 * without leaving any gap between the two. Especially useful when the arrow is
3026 * enabled and you want to ensure that it points to its reference element.
3027 * It cares only about the first axis. You can still have poppers with margin
3028 * between the popper and its reference element.
3029 * @memberof modifiers
3030 * @inner
3031 */
3032 keepTogether: {
3033 /** @prop {number} order=400 - Index used to define the order of execution */
3034 order: 400,
3035 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
3036 enabled: true,
3037 /** @prop {ModifierFn} */
3038 fn: keepTogether
3039 },
3040
3041 /**
3042 * This modifier is used to move the `arrowElement` of the popper to make
3043 * sure it is positioned between the reference element and its popper element.
3044 * It will read the outer size of the `arrowElement` node to detect how many
3045 * pixels of conjunction are needed.
3046 *
3047 * It has no effect if no `arrowElement` is provided.
3048 * @memberof modifiers
3049 * @inner
3050 */
3051 arrow: {
3052 /** @prop {number} order=500 - Index used to define the order of execution */
3053 order: 500,
3054 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
3055 enabled: true,
3056 /** @prop {ModifierFn} */
3057 fn: arrow,
3058 /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
3059 element: '[x-arrow]'
3060 },
3061
3062 /**
3063 * Modifier used to flip the popper's placement when it starts to overlap its
3064 * reference element.
3065 *
3066 * Requires the `preventOverflow` modifier before it in order to work.
3067 *
3068 * **NOTE:** this modifier will interrupt the current update cycle and will
3069 * restart it if it detects the need to flip the placement.
3070 * @memberof modifiers
3071 * @inner
3072 */
3073 flip: {
3074 /** @prop {number} order=600 - Index used to define the order of execution */
3075 order: 600,
3076 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
3077 enabled: true,
3078 /** @prop {ModifierFn} */
3079 fn: flip,
3080 /**
3081 * @prop {String|Array} behavior='flip'
3082 * The behavior used to change the popper's placement. It can be one of
3083 * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
3084 * placements (with optional variations)
3085 */
3086 behavior: 'flip',
3087 /**
3088 * @prop {number} padding=5
3089 * The popper will flip if it hits the edges of the `boundariesElement`
3090 */
3091 padding: 5,
3092 /**
3093 * @prop {String|HTMLElement} boundariesElement='viewport'
3094 * The element which will define the boundaries of the popper position.
3095 * The popper will never be placed outside of the defined boundaries
3096 * (except if `keepTogether` is enabled)
3097 */
3098 boundariesElement: 'viewport'
3099 },
3100
3101 /**
3102 * Modifier used to make the popper flow toward the inner of the reference element.
3103 * By default, when this modifier is disabled, the popper will be placed outside
3104 * the reference element.
3105 * @memberof modifiers
3106 * @inner
3107 */
3108 inner: {
3109 /** @prop {number} order=700 - Index used to define the order of execution */
3110 order: 700,
3111 /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
3112 enabled: false,
3113 /** @prop {ModifierFn} */
3114 fn: inner
3115 },
3116
3117 /**
3118 * Modifier used to hide the popper when its reference element is outside of the
3119 * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
3120 * be used to hide with a CSS selector the popper when its reference is
3121 * out of boundaries.
3122 *
3123 * Requires the `preventOverflow` modifier before it in order to work.
3124 * @memberof modifiers
3125 * @inner
3126 */
3127 hide: {
3128 /** @prop {number} order=800 - Index used to define the order of execution */
3129 order: 800,
3130 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
3131 enabled: true,
3132 /** @prop {ModifierFn} */
3133 fn: hide
3134 },
3135
3136 /**
3137 * Computes the style that will be applied to the popper element to gets
3138 * properly positioned.
3139 *
3140 * Note that this modifier will not touch the DOM, it just prepares the styles
3141 * so that `applyStyle` modifier can apply it. This separation is useful
3142 * in case you need to replace `applyStyle` with a custom implementation.
3143 *
3144 * This modifier has `850` as `order` value to maintain backward compatibility
3145 * with previous versions of Popper.js. Expect the modifiers ordering method
3146 * to change in future major versions of the library.
3147 *
3148 * @memberof modifiers
3149 * @inner
3150 */
3151 computeStyle: {
3152 /** @prop {number} order=850 - Index used to define the order of execution */
3153 order: 850,
3154 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
3155 enabled: true,
3156 /** @prop {ModifierFn} */
3157 fn: computeStyle,
3158 /**
3159 * @prop {Boolean} gpuAcceleration=true
3160 * If true, it uses the CSS 3D transformation to position the popper.
3161 * Otherwise, it will use the `top` and `left` properties
3162 */
3163 gpuAcceleration: true,
3164 /**
3165 * @prop {string} [x='bottom']
3166 * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
3167 * Change this if your popper should grow in a direction different from `bottom`
3168 */
3169 x: 'bottom',
3170 /**
3171 * @prop {string} [x='left']
3172 * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
3173 * Change this if your popper should grow in a direction different from `right`
3174 */
3175 y: 'right'
3176 },
3177
3178 /**
3179 * Applies the computed styles to the popper element.
3180 *
3181 * All the DOM manipulations are limited to this modifier. This is useful in case
3182 * you want to integrate Popper.js inside a framework or view library and you
3183 * want to delegate all the DOM manipulations to it.
3184 *
3185 * Note that if you disable this modifier, you must make sure the popper element
3186 * has its position set to `absolute` before Popper.js can do its work!
3187 *
3188 * Just disable this modifier and define your own to achieve the desired effect.
3189 *
3190 * @memberof modifiers
3191 * @inner
3192 */
3193 applyStyle: {
3194 /** @prop {number} order=900 - Index used to define the order of execution */
3195 order: 900,
3196 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
3197 enabled: true,
3198 /** @prop {ModifierFn} */
3199 fn: applyStyle,
3200 /** @prop {Function} */
3201 onLoad: applyStyleOnLoad,
3202 /**
3203 * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
3204 * @prop {Boolean} gpuAcceleration=true
3205 * If true, it uses the CSS 3D transformation to position the popper.
3206 * Otherwise, it will use the `top` and `left` properties
3207 */
3208 gpuAcceleration: undefined
3209 }
3210};
3211
3212/**
3213 * The `dataObject` is an object containing all the information used by Popper.js.
3214 * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
3215 * @name dataObject
3216 * @property {Object} data.instance The Popper.js instance
3217 * @property {String} data.placement Placement applied to popper
3218 * @property {String} data.originalPlacement Placement originally defined on init
3219 * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
3220 * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
3221 * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
3222 * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
3223 * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
3224 * @property {Object} data.boundaries Offsets of the popper boundaries
3225 * @property {Object} data.offsets The measurements of popper, reference and arrow elements
3226 * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
3227 * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
3228 * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
3229 */
3230
3231/**
3232 * Default options provided to Popper.js constructor.<br />
3233 * These can be overridden using the `options` argument of Popper.js.<br />
3234 * To override an option, simply pass an object with the same
3235 * structure of the `options` object, as the 3rd argument. For example:
3236 * ```
3237 * new Popper(ref, pop, {
3238 * modifiers: {
3239 * preventOverflow: { enabled: false }
3240 * }
3241 * })
3242 * ```
3243 * @type {Object}
3244 * @static
3245 * @memberof Popper
3246 */
3247var Defaults = {
3248 /**
3249 * Popper's placement.
3250 * @prop {Popper.placements} placement='bottom'
3251 */
3252 placement: 'bottom',
3253
3254 /**
3255 * Set this to true if you want popper to position it self in 'fixed' mode
3256 * @prop {Boolean} positionFixed=false
3257 */
3258 positionFixed: false,
3259
3260 /**
3261 * Whether events (resize, scroll) are initially enabled.
3262 * @prop {Boolean} eventsEnabled=true
3263 */
3264 eventsEnabled: true,
3265
3266 /**
3267 * Set to true if you want to automatically remove the popper when
3268 * you call the `destroy` method.
3269 * @prop {Boolean} removeOnDestroy=false
3270 */
3271 removeOnDestroy: false,
3272
3273 /**
3274 * Callback called when the popper is created.<br />
3275 * By default, it is set to no-op.<br />
3276 * Access Popper.js instance with `data.instance`.
3277 * @prop {onCreate}
3278 */
3279 onCreate: function onCreate() {},
3280
3281 /**
3282 * Callback called when the popper is updated. This callback is not called
3283 * on the initialization/creation of the popper, but only on subsequent
3284 * updates.<br />
3285 * By default, it is set to no-op.<br />
3286 * Access Popper.js instance with `data.instance`.
3287 * @prop {onUpdate}
3288 */
3289 onUpdate: function onUpdate() {},
3290
3291 /**
3292 * List of modifiers used to modify the offsets before they are applied to the popper.
3293 * They provide most of the functionalities of Popper.js.
3294 * @prop {modifiers}
3295 */
3296 modifiers: modifiers
3297};
3298
3299/**
3300 * @callback onCreate
3301 * @param {dataObject} data
3302 */
3303
3304/**
3305 * @callback onUpdate
3306 * @param {dataObject} data
3307 */
3308
3309// Utils
3310// Methods
3311var Popper = function () {
3312 /**
3313 * Creates a new Popper.js instance.
3314 * @class Popper
3315 * @param {HTMLElement|referenceObject} reference - The reference element used to position the popper
3316 * @param {HTMLElement} popper - The HTML element used as the popper
3317 * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
3318 * @return {Object} instance - The generated Popper.js instance
3319 */
3320 function Popper(reference, popper) {
3321 var _this = this;
3322
3323 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3324 classCallCheck$1(this, Popper);
3325
3326 this.scheduleUpdate = function () {
3327 return requestAnimationFrame(_this.update);
3328 };
3329
3330 // make update() debounced, so that it only runs at most once-per-tick
3331 this.update = debounce(this.update.bind(this));
3332
3333 // with {} we create a new object with the options inside it
3334 this.options = _extends$1({}, Popper.Defaults, options);
3335
3336 // init state
3337 this.state = {
3338 isDestroyed: false,
3339 isCreated: false,
3340 scrollParents: []
3341 };
3342
3343 // get reference and popper elements (allow jQuery wrappers)
3344 this.reference = reference && reference.jquery ? reference[0] : reference;
3345 this.popper = popper && popper.jquery ? popper[0] : popper;
3346
3347 // Deep merge modifiers options
3348 this.options.modifiers = {};
3349 Object.keys(_extends$1({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
3350 _this.options.modifiers[name] = _extends$1({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
3351 });
3352
3353 // Refactoring modifiers' list (Object => Array)
3354 this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
3355 return _extends$1({
3356 name: name
3357 }, _this.options.modifiers[name]);
3358 })
3359 // sort the modifiers by order
3360 .sort(function (a, b) {
3361 return a.order - b.order;
3362 });
3363
3364 // modifiers have the ability to execute arbitrary code when Popper.js get inited
3365 // such code is executed in the same order of its modifier
3366 // they could add new properties to their options configuration
3367 // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
3368 this.modifiers.forEach(function (modifierOptions) {
3369 if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
3370 modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
3371 }
3372 });
3373
3374 // fire the first update to position the popper in the right place
3375 this.update();
3376
3377 var eventsEnabled = this.options.eventsEnabled;
3378 if (eventsEnabled) {
3379 // setup event listeners, they will take care of update the position in specific situations
3380 this.enableEventListeners();
3381 }
3382
3383 this.state.eventsEnabled = eventsEnabled;
3384 }
3385
3386 // We can't use class properties because they don't get listed in the
3387 // class prototype and break stuff like Sinon stubs
3388
3389
3390 createClass$1(Popper, [{
3391 key: 'update',
3392 value: function update$$1() {
3393 return update.call(this);
3394 }
3395 }, {
3396 key: 'destroy',
3397 value: function destroy$$1() {
3398 return destroy.call(this);
3399 }
3400 }, {
3401 key: 'enableEventListeners',
3402 value: function enableEventListeners$$1() {
3403 return enableEventListeners.call(this);
3404 }
3405 }, {
3406 key: 'disableEventListeners',
3407 value: function disableEventListeners$$1() {
3408 return disableEventListeners.call(this);
3409 }
3410
3411 /**
3412 * Schedules an update. It will run on the next UI update available.
3413 * @method scheduleUpdate
3414 * @memberof Popper
3415 */
3416
3417
3418 /**
3419 * Collection of utilities useful when writing custom modifiers.
3420 * Starting from version 1.7, this method is available only if you
3421 * include `popper-utils.js` before `popper.js`.
3422 *
3423 * **DEPRECATION**: This way to access PopperUtils is deprecated
3424 * and will be removed in v2! Use the PopperUtils module directly instead.
3425 * Due to the high instability of the methods contained in Utils, we can't
3426 * guarantee them to follow semver. Use them at your own risk!
3427 * @static
3428 * @private
3429 * @type {Object}
3430 * @deprecated since version 1.8
3431 * @member Utils
3432 * @memberof Popper
3433 */
3434
3435 }]);
3436 return Popper;
3437}();
3438
3439/**
3440 * The `referenceObject` is an object that provides an interface compatible with Popper.js
3441 * and lets you use it as replacement of a real DOM node.<br />
3442 * You can use this method to position a popper relatively to a set of coordinates
3443 * in case you don't have a DOM node to use as reference.
3444 *
3445 * ```
3446 * new Popper(referenceObject, popperNode);
3447 * ```
3448 *
3449 * NB: This feature isn't supported in Internet Explorer 10.
3450 * @name referenceObject
3451 * @property {Function} data.getBoundingClientRect
3452 * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
3453 * @property {number} data.clientWidth
3454 * An ES6 getter that will return the width of the virtual reference element.
3455 * @property {number} data.clientHeight
3456 * An ES6 getter that will return the height of the virtual reference element.
3457 */
3458
3459
3460Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
3461Popper.placements = placements;
3462Popper.Defaults = Defaults;
3463
3464var State = function (_React$Component) {
3465 inherits(State, _React$Component);
3466
3467 function State(props) {
3468 classCallCheck(this, State);
3469
3470 var _this = possibleConstructorReturn(this, (State.__proto__ || Object.getPrototypeOf(State)).call(this, props));
3471
3472 _this.state = props.state || {};
3473
3474 _this.setStateBond = function (_, cb) {
3475 _this.setState(_, cb);
3476 };
3477
3478 var _this$props = _this.props,
3479 constructor = _this$props.constructor,
3480 componentDidMount = _this$props.componentDidMount,
3481 componentDidUpdate = _this$props.componentDidUpdate,
3482 componentWillUnmount = _this$props.componentWillUnmount;
3483
3484
3485 if (componentDidMount) {
3486 _this.componentDidMount = function () {
3487 return componentDidMount({
3488 state: _this.state,
3489 setState: _this.setStateBond
3490 });
3491 };
3492 }
3493 if (componentDidUpdate) {
3494 _this.componentDidUpdate = function (prevProps, prevState) {
3495 return componentDidUpdate({
3496 prevState: prevState,
3497 state: _this.state,
3498 setState: _this.setStateBond
3499 });
3500 };
3501 }
3502
3503 if (componentWillUnmount) {
3504 _this.componentWillUnmount = function () {
3505 return componentWillUnmount({
3506 state: _this.state,
3507 setState: _this.setStateBond
3508 });
3509 };
3510 }
3511 constructor && constructor({
3512 state: _this.state,
3513 setState: _this.setStateBond
3514 });
3515 return _this;
3516 }
3517
3518 createClass(State, [{
3519 key: 'render',
3520 value: function render() {
3521 var children = this.props.children;
3522
3523 return children({ state: this.state, setState: this.setStateBond }) || null;
3524 }
3525 }]);
3526 return State;
3527}(React.Component);
3528
3529var _class = function (_PureComponent) {
3530 inherits(_class, _PureComponent);
3531
3532 function _class(props) {
3533 classCallCheck(this, _class);
3534
3535 var _this = possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).call(this, props));
3536
3537 _this.state = {
3538 visible: false
3539 };
3540
3541 _this.updatePopper = function () {
3542 var visible = _this.state.visible;
3543 var placement = _this.props.placement;
3544
3545 if (visible) {
3546 document.body.appendChild(_this.el);
3547 var reference = ReactDOM.findDOMNode(_this.triggerRef.current);
3548 _this.popper = new Popper(reference, _this.el, {
3549 placement: placement,
3550 modifiers: {
3551 applyStyle: { enabled: true },
3552 arrow: { enabled: true, element: '[data-x-arrow]' }
3553 }
3554 });
3555 } else {
3556 _this.destroyPopper();
3557 }
3558 };
3559
3560 _this.destroyPopper = function () {
3561 if (_this.popper) {
3562 _this.popper.destroy();
3563 _this.popper = undefined;
3564 document.body.removeChild(_this.el);
3565 }
3566 };
3567
3568 _this.el = document.createElement('div');
3569 _this.el.className = 'popover';
3570 _this.triggerRef = React.createRef();
3571 return _this;
3572 }
3573
3574 createClass(_class, [{
3575 key: 'componentDidMount',
3576 value: function componentDidMount() {
3577 this.updatePopper();
3578 }
3579 }, {
3580 key: 'componentDidUpdate',
3581 value: function componentDidUpdate(prevProps, prevState) {
3582 if (prevState.visible !== this.state.visible) {
3583 this.updatePopper();
3584 }
3585 }
3586 }, {
3587 key: 'componentWillUnmount',
3588 value: function componentWillUnmount() {
3589 this.destroyPopper();
3590 }
3591 }, {
3592 key: 'render',
3593 value: function render() {
3594 var _this2 = this;
3595
3596 var _props = this.props,
3597 children = _props.children,
3598 content = _props.content,
3599 stateToProps = _props.stateToProps;
3600
3601
3602 return React.createElement(
3603 State,
3604 {
3605 state: { visible: false },
3606 componentDidUpdate: function componentDidUpdate(_ref) {
3607 var prevState = _ref.prevState,
3608 state = _ref.state,
3609 setState = _ref.setState;
3610
3611 if (prevState.visible !== state.visible) {
3612 _this2.updatePopper(state.visible);
3613 }
3614 }
3615 },
3616 function (_ref2) {
3617 var state = _ref2.state,
3618 setState = _ref2.setState;
3619 return React.createElement(
3620 Fragment,
3621 null,
3622 React.cloneElement(children, _extends({
3623 ref: _this2.triggerRef
3624 }, stateToProps({ state: state, setState: setState }, children.props))),
3625 state.visible && ReactDOM.createPortal(React.createElement(
3626 Fragment,
3627 null,
3628 content,
3629 React.createElement(Box, { 'data-x-arrow': true, className: 'popover-arrow' })
3630 ), _this2.el)
3631 );
3632 }
3633 );
3634 }
3635 }]);
3636 return _class;
3637}(PureComponent);
3638
3639_class.defaultProps = {
3640 placement: 'auto',
3641 stateToProps: function stateToProps(_ref3, targetProps) {
3642 var state = _ref3.state,
3643 setState = _ref3.setState;
3644 return {
3645 onClick: function onClick(event) {
3646 console.log('onClick');
3647 targetProps.onClick && targetProps.onClick(event);
3648 setState(function (state) {
3649 return {
3650 visible: !state.visible
3651 };
3652 });
3653 }
3654 };
3655 }
3656};
3657
3658/**!
3659 * @fileOverview Kickass library to create and place poppers near their reference elements.
3660 * @version 1.14.5
3661 * @license
3662 * Copyright (c) 2016 Federico Zivolo and contributors
3663 *
3664 * Permission is hereby granted, free of charge, to any person obtaining a copy
3665 * of this software and associated documentation files (the "Software"), to deal
3666 * in the Software without restriction, including without limitation the rights
3667 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3668 * copies of the Software, and to permit persons to whom the Software is
3669 * furnished to do so, subject to the following conditions:
3670 *
3671 * The above copyright notice and this permission notice shall be included in all
3672 * copies or substantial portions of the Software.
3673 *
3674 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3675 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3676 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3677 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3678 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3679 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3680 * SOFTWARE.
3681 */
3682var isBrowser$1 = typeof window !== 'undefined' && typeof document !== 'undefined';
3683
3684var longerTimeoutBrowsers$1 = ['Edge', 'Trident', 'Firefox'];
3685var timeoutDuration$1 = 0;
3686for (var i$1 = 0; i$1 < longerTimeoutBrowsers$1.length; i$1 += 1) {
3687 if (isBrowser$1 && navigator.userAgent.indexOf(longerTimeoutBrowsers$1[i$1]) >= 0) {
3688 timeoutDuration$1 = 1;
3689 break;
3690 }
3691}
3692
3693function microtaskDebounce$1(fn) {
3694 var called = false;
3695 return function () {
3696 if (called) {
3697 return;
3698 }
3699 called = true;
3700 window.Promise.resolve().then(function () {
3701 called = false;
3702 fn();
3703 });
3704 };
3705}
3706
3707function taskDebounce$1(fn) {
3708 var scheduled = false;
3709 return function () {
3710 if (!scheduled) {
3711 scheduled = true;
3712 setTimeout(function () {
3713 scheduled = false;
3714 fn();
3715 }, timeoutDuration$1);
3716 }
3717 };
3718}
3719
3720var supportsMicroTasks$1 = isBrowser$1 && window.Promise;
3721
3722/**
3723* Create a debounced version of a method, that's asynchronously deferred
3724* but called in the minimum time possible.
3725*
3726* @method
3727* @memberof Popper.Utils
3728* @argument {Function} fn
3729* @returns {Function}
3730*/
3731var debounce$1 = supportsMicroTasks$1 ? microtaskDebounce$1 : taskDebounce$1;
3732
3733/**
3734 * Check if the given variable is a function
3735 * @method
3736 * @memberof Popper.Utils
3737 * @argument {Any} functionToCheck - variable to check
3738 * @returns {Boolean} answer to: is a function?
3739 */
3740function isFunction$1(functionToCheck) {
3741 var getType = {};
3742 return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
3743}
3744
3745/**
3746 * Get CSS computed property of the given element
3747 * @method
3748 * @memberof Popper.Utils
3749 * @argument {Eement} element
3750 * @argument {String} property
3751 */
3752function getStyleComputedProperty$1(element, property) {
3753 if (element.nodeType !== 1) {
3754 return [];
3755 }
3756 // NOTE: 1 DOM access here
3757 var window = element.ownerDocument.defaultView;
3758 var css = window.getComputedStyle(element, null);
3759 return property ? css[property] : css;
3760}
3761
3762/**
3763 * Returns the parentNode or the host of the element
3764 * @method
3765 * @memberof Popper.Utils
3766 * @argument {Element} element
3767 * @returns {Element} parent
3768 */
3769function getParentNode$1(element) {
3770 if (element.nodeName === 'HTML') {
3771 return element;
3772 }
3773 return element.parentNode || element.host;
3774}
3775
3776/**
3777 * Returns the scrolling parent of the given element
3778 * @method
3779 * @memberof Popper.Utils
3780 * @argument {Element} element
3781 * @returns {Element} scroll parent
3782 */
3783function getScrollParent$1(element) {
3784 // Return body, `getScroll` will take care to get the correct `scrollTop` from it
3785 if (!element) {
3786 return document.body;
3787 }
3788
3789 switch (element.nodeName) {
3790 case 'HTML':
3791 case 'BODY':
3792 return element.ownerDocument.body;
3793 case '#document':
3794 return element.body;
3795 }
3796
3797 // Firefox want us to check `-x` and `-y` variations as well
3798
3799 var _getStyleComputedProp = getStyleComputedProperty$1(element),
3800 overflow = _getStyleComputedProp.overflow,
3801 overflowX = _getStyleComputedProp.overflowX,
3802 overflowY = _getStyleComputedProp.overflowY;
3803
3804 if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
3805 return element;
3806 }
3807
3808 return getScrollParent$1(getParentNode$1(element));
3809}
3810
3811var isIE11$1 = isBrowser$1 && !!(window.MSInputMethodContext && document.documentMode);
3812var isIE10$1 = isBrowser$1 && /MSIE 10/.test(navigator.userAgent);
3813
3814/**
3815 * Determines if the browser is Internet Explorer
3816 * @method
3817 * @memberof Popper.Utils
3818 * @param {Number} version to check
3819 * @returns {Boolean} isIE
3820 */
3821function isIE$1(version) {
3822 if (version === 11) {
3823 return isIE11$1;
3824 }
3825 if (version === 10) {
3826 return isIE10$1;
3827 }
3828 return isIE11$1 || isIE10$1;
3829}
3830
3831/**
3832 * Returns the offset parent of the given element
3833 * @method
3834 * @memberof Popper.Utils
3835 * @argument {Element} element
3836 * @returns {Element} offset parent
3837 */
3838function getOffsetParent$1(element) {
3839 if (!element) {
3840 return document.documentElement;
3841 }
3842
3843 var noOffsetParent = isIE$1(10) ? document.body : null;
3844
3845 // NOTE: 1 DOM access here
3846 var offsetParent = element.offsetParent || null;
3847 // Skip hidden elements which don't have an offsetParent
3848 while (offsetParent === noOffsetParent && element.nextElementSibling) {
3849 offsetParent = (element = element.nextElementSibling).offsetParent;
3850 }
3851
3852 var nodeName = offsetParent && offsetParent.nodeName;
3853
3854 if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
3855 return element ? element.ownerDocument.documentElement : document.documentElement;
3856 }
3857
3858 // .offsetParent will return the closest TH, TD or TABLE in case
3859 // no offsetParent is present, I hate this job...
3860 if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty$1(offsetParent, 'position') === 'static') {
3861 return getOffsetParent$1(offsetParent);
3862 }
3863
3864 return offsetParent;
3865}
3866
3867function isOffsetContainer$1(element) {
3868 var nodeName = element.nodeName;
3869
3870 if (nodeName === 'BODY') {
3871 return false;
3872 }
3873 return nodeName === 'HTML' || getOffsetParent$1(element.firstElementChild) === element;
3874}
3875
3876/**
3877 * Finds the root node (document, shadowDOM root) of the given element
3878 * @method
3879 * @memberof Popper.Utils
3880 * @argument {Element} node
3881 * @returns {Element} root node
3882 */
3883function getRoot$1(node) {
3884 if (node.parentNode !== null) {
3885 return getRoot$1(node.parentNode);
3886 }
3887
3888 return node;
3889}
3890
3891/**
3892 * Finds the offset parent common to the two provided nodes
3893 * @method
3894 * @memberof Popper.Utils
3895 * @argument {Element} element1
3896 * @argument {Element} element2
3897 * @returns {Element} common offset parent
3898 */
3899function findCommonOffsetParent$1(element1, element2) {
3900 // This check is needed to avoid errors in case one of the elements isn't defined for any reason
3901 if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
3902 return document.documentElement;
3903 }
3904
3905 // Here we make sure to give as "start" the element that comes first in the DOM
3906 var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
3907 var start = order ? element1 : element2;
3908 var end = order ? element2 : element1;
3909
3910 // Get common ancestor container
3911 var range = document.createRange();
3912 range.setStart(start, 0);
3913 range.setEnd(end, 0);
3914 var commonAncestorContainer = range.commonAncestorContainer;
3915
3916 // Both nodes are inside #document
3917
3918 if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
3919 if (isOffsetContainer$1(commonAncestorContainer)) {
3920 return commonAncestorContainer;
3921 }
3922
3923 return getOffsetParent$1(commonAncestorContainer);
3924 }
3925
3926 // one of the nodes is inside shadowDOM, find which one
3927 var element1root = getRoot$1(element1);
3928 if (element1root.host) {
3929 return findCommonOffsetParent$1(element1root.host, element2);
3930 } else {
3931 return findCommonOffsetParent$1(element1, getRoot$1(element2).host);
3932 }
3933}
3934
3935/**
3936 * Gets the scroll value of the given element in the given side (top and left)
3937 * @method
3938 * @memberof Popper.Utils
3939 * @argument {Element} element
3940 * @argument {String} side `top` or `left`
3941 * @returns {number} amount of scrolled pixels
3942 */
3943function getScroll$1(element) {
3944 var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
3945
3946 var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
3947 var nodeName = element.nodeName;
3948
3949 if (nodeName === 'BODY' || nodeName === 'HTML') {
3950 var html = element.ownerDocument.documentElement;
3951 var scrollingElement = element.ownerDocument.scrollingElement || html;
3952 return scrollingElement[upperSide];
3953 }
3954
3955 return element[upperSide];
3956}
3957
3958/*
3959 * Sum or subtract the element scroll values (left and top) from a given rect object
3960 * @method
3961 * @memberof Popper.Utils
3962 * @param {Object} rect - Rect object you want to change
3963 * @param {HTMLElement} element - The element from the function reads the scroll values
3964 * @param {Boolean} subtract - set to true if you want to subtract the scroll values
3965 * @return {Object} rect - The modifier rect object
3966 */
3967function includeScroll$1(rect, element) {
3968 var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3969
3970 var scrollTop = getScroll$1(element, 'top');
3971 var scrollLeft = getScroll$1(element, 'left');
3972 var modifier = subtract ? -1 : 1;
3973 rect.top += scrollTop * modifier;
3974 rect.bottom += scrollTop * modifier;
3975 rect.left += scrollLeft * modifier;
3976 rect.right += scrollLeft * modifier;
3977 return rect;
3978}
3979
3980/*
3981 * Helper to detect borders of a given element
3982 * @method
3983 * @memberof Popper.Utils
3984 * @param {CSSStyleDeclaration} styles
3985 * Result of `getStyleComputedProperty` on the given element
3986 * @param {String} axis - `x` or `y`
3987 * @return {number} borders - The borders size of the given axis
3988 */
3989
3990function getBordersSize$1(styles, axis) {
3991 var sideA = axis === 'x' ? 'Left' : 'Top';
3992 var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
3993
3994 return parseFloat(styles['border' + sideA + 'Width'], 10) + parseFloat(styles['border' + sideB + 'Width'], 10);
3995}
3996
3997function getSize$1(axis, body, html, computedStyle) {
3998 return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE$1(10) ? parseInt(html['offset' + axis]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')]) : 0);
3999}
4000
4001function getWindowSizes$1(document) {
4002 var body = document.body;
4003 var html = document.documentElement;
4004 var computedStyle = isIE$1(10) && getComputedStyle(html);
4005
4006 return {
4007 height: getSize$1('Height', body, html, computedStyle),
4008 width: getSize$1('Width', body, html, computedStyle)
4009 };
4010}
4011
4012var classCallCheck$2 = function (instance, Constructor) {
4013 if (!(instance instanceof Constructor)) {
4014 throw new TypeError("Cannot call a class as a function");
4015 }
4016};
4017
4018var createClass$2 = function () {
4019 function defineProperties(target, props) {
4020 for (var i = 0; i < props.length; i++) {
4021 var descriptor = props[i];
4022 descriptor.enumerable = descriptor.enumerable || false;
4023 descriptor.configurable = true;
4024 if ("value" in descriptor) descriptor.writable = true;
4025 Object.defineProperty(target, descriptor.key, descriptor);
4026 }
4027 }
4028
4029 return function (Constructor, protoProps, staticProps) {
4030 if (protoProps) defineProperties(Constructor.prototype, protoProps);
4031 if (staticProps) defineProperties(Constructor, staticProps);
4032 return Constructor;
4033 };
4034}();
4035
4036
4037
4038
4039
4040var defineProperty$2 = function (obj, key, value) {
4041 if (key in obj) {
4042 Object.defineProperty(obj, key, {
4043 value: value,
4044 enumerable: true,
4045 configurable: true,
4046 writable: true
4047 });
4048 } else {
4049 obj[key] = value;
4050 }
4051
4052 return obj;
4053};
4054
4055var _extends$2 = Object.assign || function (target) {
4056 for (var i = 1; i < arguments.length; i++) {
4057 var source = arguments[i];
4058
4059 for (var key in source) {
4060 if (Object.prototype.hasOwnProperty.call(source, key)) {
4061 target[key] = source[key];
4062 }
4063 }
4064 }
4065
4066 return target;
4067};
4068
4069/**
4070 * Given element offsets, generate an output similar to getBoundingClientRect
4071 * @method
4072 * @memberof Popper.Utils
4073 * @argument {Object} offsets
4074 * @returns {Object} ClientRect like output
4075 */
4076function getClientRect$1(offsets) {
4077 return _extends$2({}, offsets, {
4078 right: offsets.left + offsets.width,
4079 bottom: offsets.top + offsets.height
4080 });
4081}
4082
4083/**
4084 * Get bounding client rect of given element
4085 * @method
4086 * @memberof Popper.Utils
4087 * @param {HTMLElement} element
4088 * @return {Object} client rect
4089 */
4090function getBoundingClientRect$1(element) {
4091 var rect = {};
4092
4093 // IE10 10 FIX: Please, don't ask, the element isn't
4094 // considered in DOM in some circumstances...
4095 // This isn't reproducible in IE10 compatibility mode of IE11
4096 try {
4097 if (isIE$1(10)) {
4098 rect = element.getBoundingClientRect();
4099 var scrollTop = getScroll$1(element, 'top');
4100 var scrollLeft = getScroll$1(element, 'left');
4101 rect.top += scrollTop;
4102 rect.left += scrollLeft;
4103 rect.bottom += scrollTop;
4104 rect.right += scrollLeft;
4105 } else {
4106 rect = element.getBoundingClientRect();
4107 }
4108 } catch (e) {}
4109
4110 var result = {
4111 left: rect.left,
4112 top: rect.top,
4113 width: rect.right - rect.left,
4114 height: rect.bottom - rect.top
4115 };
4116
4117 // subtract scrollbar size from sizes
4118 var sizes = element.nodeName === 'HTML' ? getWindowSizes$1(element.ownerDocument) : {};
4119 var width = sizes.width || element.clientWidth || result.right - result.left;
4120 var height = sizes.height || element.clientHeight || result.bottom - result.top;
4121
4122 var horizScrollbar = element.offsetWidth - width;
4123 var vertScrollbar = element.offsetHeight - height;
4124
4125 // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
4126 // we make this check conditional for performance reasons
4127 if (horizScrollbar || vertScrollbar) {
4128 var styles = getStyleComputedProperty$1(element);
4129 horizScrollbar -= getBordersSize$1(styles, 'x');
4130 vertScrollbar -= getBordersSize$1(styles, 'y');
4131
4132 result.width -= horizScrollbar;
4133 result.height -= vertScrollbar;
4134 }
4135
4136 return getClientRect$1(result);
4137}
4138
4139function getOffsetRectRelativeToArbitraryNode$1(children, parent) {
4140 var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
4141
4142 var isIE10 = isIE$1(10);
4143 var isHTML = parent.nodeName === 'HTML';
4144 var childrenRect = getBoundingClientRect$1(children);
4145 var parentRect = getBoundingClientRect$1(parent);
4146 var scrollParent = getScrollParent$1(children);
4147
4148 var styles = getStyleComputedProperty$1(parent);
4149 var borderTopWidth = parseFloat(styles.borderTopWidth, 10);
4150 var borderLeftWidth = parseFloat(styles.borderLeftWidth, 10);
4151
4152 // In cases where the parent is fixed, we must ignore negative scroll in offset calc
4153 if (fixedPosition && isHTML) {
4154 parentRect.top = Math.max(parentRect.top, 0);
4155 parentRect.left = Math.max(parentRect.left, 0);
4156 }
4157 var offsets = getClientRect$1({
4158 top: childrenRect.top - parentRect.top - borderTopWidth,
4159 left: childrenRect.left - parentRect.left - borderLeftWidth,
4160 width: childrenRect.width,
4161 height: childrenRect.height
4162 });
4163 offsets.marginTop = 0;
4164 offsets.marginLeft = 0;
4165
4166 // Subtract margins of documentElement in case it's being used as parent
4167 // we do this only on HTML because it's the only element that behaves
4168 // differently when margins are applied to it. The margins are included in
4169 // the box of the documentElement, in the other cases not.
4170 if (!isIE10 && isHTML) {
4171 var marginTop = parseFloat(styles.marginTop, 10);
4172 var marginLeft = parseFloat(styles.marginLeft, 10);
4173
4174 offsets.top -= borderTopWidth - marginTop;
4175 offsets.bottom -= borderTopWidth - marginTop;
4176 offsets.left -= borderLeftWidth - marginLeft;
4177 offsets.right -= borderLeftWidth - marginLeft;
4178
4179 // Attach marginTop and marginLeft because in some circumstances we may need them
4180 offsets.marginTop = marginTop;
4181 offsets.marginLeft = marginLeft;
4182 }
4183
4184 if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
4185 offsets = includeScroll$1(offsets, parent);
4186 }
4187
4188 return offsets;
4189}
4190
4191function getViewportOffsetRectRelativeToArtbitraryNode$1(element) {
4192 var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
4193
4194 var html = element.ownerDocument.documentElement;
4195 var relativeOffset = getOffsetRectRelativeToArbitraryNode$1(element, html);
4196 var width = Math.max(html.clientWidth, window.innerWidth || 0);
4197 var height = Math.max(html.clientHeight, window.innerHeight || 0);
4198
4199 var scrollTop = !excludeScroll ? getScroll$1(html) : 0;
4200 var scrollLeft = !excludeScroll ? getScroll$1(html, 'left') : 0;
4201
4202 var offset = {
4203 top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
4204 left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
4205 width: width,
4206 height: height
4207 };
4208
4209 return getClientRect$1(offset);
4210}
4211
4212/**
4213 * Check if the given element is fixed or is inside a fixed parent
4214 * @method
4215 * @memberof Popper.Utils
4216 * @argument {Element} element
4217 * @argument {Element} customContainer
4218 * @returns {Boolean} answer to "isFixed?"
4219 */
4220function isFixed$1(element) {
4221 var nodeName = element.nodeName;
4222 if (nodeName === 'BODY' || nodeName === 'HTML') {
4223 return false;
4224 }
4225 if (getStyleComputedProperty$1(element, 'position') === 'fixed') {
4226 return true;
4227 }
4228 return isFixed$1(getParentNode$1(element));
4229}
4230
4231/**
4232 * Finds the first parent of an element that has a transformed property defined
4233 * @method
4234 * @memberof Popper.Utils
4235 * @argument {Element} element
4236 * @returns {Element} first transformed parent or documentElement
4237 */
4238
4239function getFixedPositionOffsetParent$1(element) {
4240 // This check is needed to avoid errors in case one of the elements isn't defined for any reason
4241 if (!element || !element.parentElement || isIE$1()) {
4242 return document.documentElement;
4243 }
4244 var el = element.parentElement;
4245 while (el && getStyleComputedProperty$1(el, 'transform') === 'none') {
4246 el = el.parentElement;
4247 }
4248 return el || document.documentElement;
4249}
4250
4251/**
4252 * Computed the boundaries limits and return them
4253 * @method
4254 * @memberof Popper.Utils
4255 * @param {HTMLElement} popper
4256 * @param {HTMLElement} reference
4257 * @param {number} padding
4258 * @param {HTMLElement} boundariesElement - Element used to define the boundaries
4259 * @param {Boolean} fixedPosition - Is in fixed position mode
4260 * @returns {Object} Coordinates of the boundaries
4261 */
4262function getBoundaries$1(popper, reference, padding, boundariesElement) {
4263 var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
4264
4265 // NOTE: 1 DOM access here
4266
4267 var boundaries = { top: 0, left: 0 };
4268 var offsetParent = fixedPosition ? getFixedPositionOffsetParent$1(popper) : findCommonOffsetParent$1(popper, reference);
4269
4270 // Handle viewport case
4271 if (boundariesElement === 'viewport') {
4272 boundaries = getViewportOffsetRectRelativeToArtbitraryNode$1(offsetParent, fixedPosition);
4273 } else {
4274 // Handle other cases based on DOM element used as boundaries
4275 var boundariesNode = void 0;
4276 if (boundariesElement === 'scrollParent') {
4277 boundariesNode = getScrollParent$1(getParentNode$1(reference));
4278 if (boundariesNode.nodeName === 'BODY') {
4279 boundariesNode = popper.ownerDocument.documentElement;
4280 }
4281 } else if (boundariesElement === 'window') {
4282 boundariesNode = popper.ownerDocument.documentElement;
4283 } else {
4284 boundariesNode = boundariesElement;
4285 }
4286
4287 var offsets = getOffsetRectRelativeToArbitraryNode$1(boundariesNode, offsetParent, fixedPosition);
4288
4289 // In case of HTML, we need a different computation
4290 if (boundariesNode.nodeName === 'HTML' && !isFixed$1(offsetParent)) {
4291 var _getWindowSizes = getWindowSizes$1(popper.ownerDocument),
4292 height = _getWindowSizes.height,
4293 width = _getWindowSizes.width;
4294
4295 boundaries.top += offsets.top - offsets.marginTop;
4296 boundaries.bottom = height + offsets.top;
4297 boundaries.left += offsets.left - offsets.marginLeft;
4298 boundaries.right = width + offsets.left;
4299 } else {
4300 // for all the other DOM elements, this one is good
4301 boundaries = offsets;
4302 }
4303 }
4304
4305 // Add paddings
4306 padding = padding || 0;
4307 var isPaddingNumber = typeof padding === 'number';
4308 boundaries.left += isPaddingNumber ? padding : padding.left || 0;
4309 boundaries.top += isPaddingNumber ? padding : padding.top || 0;
4310 boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
4311 boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
4312
4313 return boundaries;
4314}
4315
4316function getArea$1(_ref) {
4317 var width = _ref.width,
4318 height = _ref.height;
4319
4320 return width * height;
4321}
4322
4323/**
4324 * Utility used to transform the `auto` placement to the placement with more
4325 * available space.
4326 * @method
4327 * @memberof Popper.Utils
4328 * @argument {Object} data - The data object generated by update method
4329 * @argument {Object} options - Modifiers configuration and options
4330 * @returns {Object} The data object, properly modified
4331 */
4332function computeAutoPlacement$1(placement, refRect, popper, reference, boundariesElement) {
4333 var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
4334
4335 if (placement.indexOf('auto') === -1) {
4336 return placement;
4337 }
4338
4339 var boundaries = getBoundaries$1(popper, reference, padding, boundariesElement);
4340
4341 var rects = {
4342 top: {
4343 width: boundaries.width,
4344 height: refRect.top - boundaries.top
4345 },
4346 right: {
4347 width: boundaries.right - refRect.right,
4348 height: boundaries.height
4349 },
4350 bottom: {
4351 width: boundaries.width,
4352 height: boundaries.bottom - refRect.bottom
4353 },
4354 left: {
4355 width: refRect.left - boundaries.left,
4356 height: boundaries.height
4357 }
4358 };
4359
4360 var sortedAreas = Object.keys(rects).map(function (key) {
4361 return _extends$2({
4362 key: key
4363 }, rects[key], {
4364 area: getArea$1(rects[key])
4365 });
4366 }).sort(function (a, b) {
4367 return b.area - a.area;
4368 });
4369
4370 var filteredAreas = sortedAreas.filter(function (_ref2) {
4371 var width = _ref2.width,
4372 height = _ref2.height;
4373 return width >= popper.clientWidth && height >= popper.clientHeight;
4374 });
4375
4376 var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
4377
4378 var variation = placement.split('-')[1];
4379
4380 return computedPlacement + (variation ? '-' + variation : '');
4381}
4382
4383/**
4384 * Get offsets to the reference element
4385 * @method
4386 * @memberof Popper.Utils
4387 * @param {Object} state
4388 * @param {Element} popper - the popper element
4389 * @param {Element} reference - the reference element (the popper will be relative to this)
4390 * @param {Element} fixedPosition - is in fixed position mode
4391 * @returns {Object} An object containing the offsets which will be applied to the popper
4392 */
4393function getReferenceOffsets$1(state, popper, reference) {
4394 var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
4395
4396 var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent$1(popper) : findCommonOffsetParent$1(popper, reference);
4397 return getOffsetRectRelativeToArbitraryNode$1(reference, commonOffsetParent, fixedPosition);
4398}
4399
4400/**
4401 * Get the outer sizes of the given element (offset size + margins)
4402 * @method
4403 * @memberof Popper.Utils
4404 * @argument {Element} element
4405 * @returns {Object} object containing width and height properties
4406 */
4407function getOuterSizes$1(element) {
4408 var window = element.ownerDocument.defaultView;
4409 var styles = window.getComputedStyle(element);
4410 var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
4411 var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
4412 var result = {
4413 width: element.offsetWidth + y,
4414 height: element.offsetHeight + x
4415 };
4416 return result;
4417}
4418
4419/**
4420 * Get the opposite placement of the given one
4421 * @method
4422 * @memberof Popper.Utils
4423 * @argument {String} placement
4424 * @returns {String} flipped placement
4425 */
4426function getOppositePlacement$1(placement) {
4427 var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
4428 return placement.replace(/left|right|bottom|top/g, function (matched) {
4429 return hash[matched];
4430 });
4431}
4432
4433/**
4434 * Get offsets to the popper
4435 * @method
4436 * @memberof Popper.Utils
4437 * @param {Object} position - CSS position the Popper will get applied
4438 * @param {HTMLElement} popper - the popper element
4439 * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
4440 * @param {String} placement - one of the valid placement options
4441 * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
4442 */
4443function getPopperOffsets$1(popper, referenceOffsets, placement) {
4444 placement = placement.split('-')[0];
4445
4446 // Get popper node sizes
4447 var popperRect = getOuterSizes$1(popper);
4448
4449 // Add position, width and height to our offsets object
4450 var popperOffsets = {
4451 width: popperRect.width,
4452 height: popperRect.height
4453 };
4454
4455 // depending by the popper placement we have to compute its offsets slightly differently
4456 var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
4457 var mainSide = isHoriz ? 'top' : 'left';
4458 var secondarySide = isHoriz ? 'left' : 'top';
4459 var measurement = isHoriz ? 'height' : 'width';
4460 var secondaryMeasurement = !isHoriz ? 'height' : 'width';
4461
4462 popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
4463 if (placement === secondarySide) {
4464 popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
4465 } else {
4466 popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement$1(secondarySide)];
4467 }
4468
4469 return popperOffsets;
4470}
4471
4472/**
4473 * Mimics the `find` method of Array
4474 * @method
4475 * @memberof Popper.Utils
4476 * @argument {Array} arr
4477 * @argument prop
4478 * @argument value
4479 * @returns index or -1
4480 */
4481function find$1(arr, check) {
4482 // use native find if supported
4483 if (Array.prototype.find) {
4484 return arr.find(check);
4485 }
4486
4487 // use `filter` to obtain the same behavior of `find`
4488 return arr.filter(check)[0];
4489}
4490
4491/**
4492 * Return the index of the matching object
4493 * @method
4494 * @memberof Popper.Utils
4495 * @argument {Array} arr
4496 * @argument prop
4497 * @argument value
4498 * @returns index or -1
4499 */
4500function findIndex$1(arr, prop, value) {
4501 // use native findIndex if supported
4502 if (Array.prototype.findIndex) {
4503 return arr.findIndex(function (cur) {
4504 return cur[prop] === value;
4505 });
4506 }
4507
4508 // use `find` + `indexOf` if `findIndex` isn't supported
4509 var match = find$1(arr, function (obj) {
4510 return obj[prop] === value;
4511 });
4512 return arr.indexOf(match);
4513}
4514
4515/**
4516 * Loop trough the list of modifiers and run them in order,
4517 * each of them will then edit the data object.
4518 * @method
4519 * @memberof Popper.Utils
4520 * @param {dataObject} data
4521 * @param {Array} modifiers
4522 * @param {String} ends - Optional modifier name used as stopper
4523 * @returns {dataObject}
4524 */
4525function runModifiers$1(modifiers, data, ends) {
4526 var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex$1(modifiers, 'name', ends));
4527
4528 modifiersToRun.forEach(function (modifier) {
4529 if (modifier['function']) {
4530 // eslint-disable-line dot-notation
4531 console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
4532 }
4533 var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
4534 if (modifier.enabled && isFunction$1(fn)) {
4535 // Add properties to offsets to make them a complete clientRect object
4536 // we do this before each modifier to make sure the previous one doesn't
4537 // mess with these values
4538 data.offsets.popper = getClientRect$1(data.offsets.popper);
4539 data.offsets.reference = getClientRect$1(data.offsets.reference);
4540
4541 data = fn(data, modifier);
4542 }
4543 });
4544
4545 return data;
4546}
4547
4548/**
4549 * Updates the position of the popper, computing the new offsets and applying
4550 * the new style.<br />
4551 * Prefer `scheduleUpdate` over `update` because of performance reasons.
4552 * @method
4553 * @memberof Popper
4554 */
4555function update$1() {
4556 // if popper is destroyed, don't perform any further update
4557 if (this.state.isDestroyed) {
4558 return;
4559 }
4560
4561 var data = {
4562 instance: this,
4563 styles: {},
4564 arrowStyles: {},
4565 attributes: {},
4566 flipped: false,
4567 offsets: {}
4568 };
4569
4570 // compute reference element offsets
4571 data.offsets.reference = getReferenceOffsets$1(this.state, this.popper, this.reference, this.options.positionFixed);
4572
4573 // compute auto placement, store placement inside the data object,
4574 // modifiers will be able to edit `placement` if needed
4575 // and refer to originalPlacement to know the original value
4576 data.placement = computeAutoPlacement$1(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
4577
4578 // store the computed placement inside `originalPlacement`
4579 data.originalPlacement = data.placement;
4580
4581 data.positionFixed = this.options.positionFixed;
4582
4583 // compute the popper offsets
4584 data.offsets.popper = getPopperOffsets$1(this.popper, data.offsets.reference, data.placement);
4585
4586 data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
4587
4588 // run the modifiers
4589 data = runModifiers$1(this.modifiers, data);
4590
4591 // the first `update` will call `onCreate` callback
4592 // the other ones will call `onUpdate` callback
4593 if (!this.state.isCreated) {
4594 this.state.isCreated = true;
4595 this.options.onCreate(data);
4596 } else {
4597 this.options.onUpdate(data);
4598 }
4599}
4600
4601/**
4602 * Helper used to know if the given modifier is enabled.
4603 * @method
4604 * @memberof Popper.Utils
4605 * @returns {Boolean}
4606 */
4607function isModifierEnabled$1(modifiers, modifierName) {
4608 return modifiers.some(function (_ref) {
4609 var name = _ref.name,
4610 enabled = _ref.enabled;
4611 return enabled && name === modifierName;
4612 });
4613}
4614
4615/**
4616 * Get the prefixed supported property name
4617 * @method
4618 * @memberof Popper.Utils
4619 * @argument {String} property (camelCase)
4620 * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
4621 */
4622function getSupportedPropertyName$1(property) {
4623 var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
4624 var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
4625
4626 for (var i = 0; i < prefixes.length; i++) {
4627 var prefix = prefixes[i];
4628 var toCheck = prefix ? '' + prefix + upperProp : property;
4629 if (typeof document.body.style[toCheck] !== 'undefined') {
4630 return toCheck;
4631 }
4632 }
4633 return null;
4634}
4635
4636/**
4637 * Destroys the popper.
4638 * @method
4639 * @memberof Popper
4640 */
4641function destroy$1() {
4642 this.state.isDestroyed = true;
4643
4644 // touch DOM only if `applyStyle` modifier is enabled
4645 if (isModifierEnabled$1(this.modifiers, 'applyStyle')) {
4646 this.popper.removeAttribute('x-placement');
4647 this.popper.style.position = '';
4648 this.popper.style.top = '';
4649 this.popper.style.left = '';
4650 this.popper.style.right = '';
4651 this.popper.style.bottom = '';
4652 this.popper.style.willChange = '';
4653 this.popper.style[getSupportedPropertyName$1('transform')] = '';
4654 }
4655
4656 this.disableEventListeners();
4657
4658 // remove the popper if user explicity asked for the deletion on destroy
4659 // do not use `remove` because IE11 doesn't support it
4660 if (this.options.removeOnDestroy) {
4661 this.popper.parentNode.removeChild(this.popper);
4662 }
4663 return this;
4664}
4665
4666/**
4667 * Get the window associated with the element
4668 * @argument {Element} element
4669 * @returns {Window}
4670 */
4671function getWindow$1(element) {
4672 var ownerDocument = element.ownerDocument;
4673 return ownerDocument ? ownerDocument.defaultView : window;
4674}
4675
4676function attachToScrollParents$1(scrollParent, event, callback, scrollParents) {
4677 var isBody = scrollParent.nodeName === 'BODY';
4678 var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
4679 target.addEventListener(event, callback, { passive: true });
4680
4681 if (!isBody) {
4682 attachToScrollParents$1(getScrollParent$1(target.parentNode), event, callback, scrollParents);
4683 }
4684 scrollParents.push(target);
4685}
4686
4687/**
4688 * Setup needed event listeners used to update the popper position
4689 * @method
4690 * @memberof Popper.Utils
4691 * @private
4692 */
4693function setupEventListeners$1(reference, options, state, updateBound) {
4694 // Resize event listener on window
4695 state.updateBound = updateBound;
4696 getWindow$1(reference).addEventListener('resize', state.updateBound, { passive: true });
4697
4698 // Scroll event listener on scroll parents
4699 var scrollElement = getScrollParent$1(reference);
4700 attachToScrollParents$1(scrollElement, 'scroll', state.updateBound, state.scrollParents);
4701 state.scrollElement = scrollElement;
4702 state.eventsEnabled = true;
4703
4704 return state;
4705}
4706
4707/**
4708 * It will add resize/scroll events and start recalculating
4709 * position of the popper element when they are triggered.
4710 * @method
4711 * @memberof Popper
4712 */
4713function enableEventListeners$1() {
4714 if (!this.state.eventsEnabled) {
4715 this.state = setupEventListeners$1(this.reference, this.options, this.state, this.scheduleUpdate);
4716 }
4717}
4718
4719/**
4720 * Remove event listeners used to update the popper position
4721 * @method
4722 * @memberof Popper.Utils
4723 * @private
4724 */
4725function removeEventListeners$1(reference, state) {
4726 // Remove resize event listener on window
4727 getWindow$1(reference).removeEventListener('resize', state.updateBound);
4728
4729 // Remove scroll event listener on scroll parents
4730 state.scrollParents.forEach(function (target) {
4731 target.removeEventListener('scroll', state.updateBound);
4732 });
4733
4734 // Reset state
4735 state.updateBound = null;
4736 state.scrollParents = [];
4737 state.scrollElement = null;
4738 state.eventsEnabled = false;
4739 return state;
4740}
4741
4742/**
4743 * It will remove resize/scroll events and won't recalculate popper position
4744 * when they are triggered. It also won't trigger `onUpdate` callback anymore,
4745 * unless you call `update` method manually.
4746 * @method
4747 * @memberof Popper
4748 */
4749function disableEventListeners$1() {
4750 if (this.state.eventsEnabled) {
4751 cancelAnimationFrame(this.scheduleUpdate);
4752 this.state = removeEventListeners$1(this.reference, this.state);
4753 }
4754}
4755
4756/**
4757 * Tells if a given input is a number
4758 * @method
4759 * @memberof Popper.Utils
4760 * @param {*} input to check
4761 * @return {Boolean}
4762 */
4763function isNumeric$1(n) {
4764 return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
4765}
4766
4767/**
4768 * Set the style to the given popper
4769 * @method
4770 * @memberof Popper.Utils
4771 * @argument {Element} element - Element to apply the style to
4772 * @argument {Object} styles
4773 * Object with a list of properties and values which will be applied to the element
4774 */
4775function setStyles$1(element, styles) {
4776 Object.keys(styles).forEach(function (prop) {
4777 var unit = '';
4778 // add unit if the value is numeric and is one of the following
4779 if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric$1(styles[prop])) {
4780 unit = 'px';
4781 }
4782 element.style[prop] = styles[prop] + unit;
4783 });
4784}
4785
4786/**
4787 * Set the attributes to the given popper
4788 * @method
4789 * @memberof Popper.Utils
4790 * @argument {Element} element - Element to apply the attributes to
4791 * @argument {Object} styles
4792 * Object with a list of properties and values which will be applied to the element
4793 */
4794function setAttributes$1(element, attributes) {
4795 Object.keys(attributes).forEach(function (prop) {
4796 var value = attributes[prop];
4797 if (value !== false) {
4798 element.setAttribute(prop, attributes[prop]);
4799 } else {
4800 element.removeAttribute(prop);
4801 }
4802 });
4803}
4804
4805/**
4806 * @function
4807 * @memberof Modifiers
4808 * @argument {Object} data - The data object generated by `update` method
4809 * @argument {Object} data.styles - List of style properties - values to apply to popper element
4810 * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
4811 * @argument {Object} options - Modifiers configuration and options
4812 * @returns {Object} The same data object
4813 */
4814function applyStyle$1(data) {
4815 // any property present in `data.styles` will be applied to the popper,
4816 // in this way we can make the 3rd party modifiers add custom styles to it
4817 // Be aware, modifiers could override the properties defined in the previous
4818 // lines of this modifier!
4819 setStyles$1(data.instance.popper, data.styles);
4820
4821 // any property present in `data.attributes` will be applied to the popper,
4822 // they will be set as HTML attributes of the element
4823 setAttributes$1(data.instance.popper, data.attributes);
4824
4825 // if arrowElement is defined and arrowStyles has some properties
4826 if (data.arrowElement && Object.keys(data.arrowStyles).length) {
4827 setStyles$1(data.arrowElement, data.arrowStyles);
4828 }
4829
4830 return data;
4831}
4832
4833/**
4834 * Set the x-placement attribute before everything else because it could be used
4835 * to add margins to the popper margins needs to be calculated to get the
4836 * correct popper offsets.
4837 * @method
4838 * @memberof Popper.modifiers
4839 * @param {HTMLElement} reference - The reference element used to position the popper
4840 * @param {HTMLElement} popper - The HTML element used as popper
4841 * @param {Object} options - Popper.js options
4842 */
4843function applyStyleOnLoad$1(reference, popper, options, modifierOptions, state) {
4844 // compute reference element offsets
4845 var referenceOffsets = getReferenceOffsets$1(state, popper, reference, options.positionFixed);
4846
4847 // compute auto placement, store placement inside the data object,
4848 // modifiers will be able to edit `placement` if needed
4849 // and refer to originalPlacement to know the original value
4850 var placement = computeAutoPlacement$1(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
4851
4852 popper.setAttribute('x-placement', placement);
4853
4854 // Apply `position` to popper before anything else because
4855 // without the position applied we can't guarantee correct computations
4856 setStyles$1(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
4857
4858 return options;
4859}
4860
4861/**
4862 * @function
4863 * @memberof Modifiers
4864 * @argument {Object} data - The data object generated by `update` method
4865 * @argument {Object} options - Modifiers configuration and options
4866 * @returns {Object} The data object, properly modified
4867 */
4868function computeStyle$1(data, options) {
4869 var x = options.x,
4870 y = options.y;
4871 var popper = data.offsets.popper;
4872
4873 // Remove this legacy support in Popper.js v2
4874
4875 var legacyGpuAccelerationOption = find$1(data.instance.modifiers, function (modifier) {
4876 return modifier.name === 'applyStyle';
4877 }).gpuAcceleration;
4878 if (legacyGpuAccelerationOption !== undefined) {
4879 console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
4880 }
4881 var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
4882
4883 var offsetParent = getOffsetParent$1(data.instance.popper);
4884 var offsetParentRect = getBoundingClientRect$1(offsetParent);
4885
4886 // Styles
4887 var styles = {
4888 position: popper.position
4889 };
4890
4891 // Avoid blurry text by using full pixel integers.
4892 // For pixel-perfect positioning, top/bottom prefers rounded
4893 // values, while left/right prefers floored values.
4894 var offsets = {
4895 left: Math.floor(popper.left),
4896 top: Math.round(popper.top),
4897 bottom: Math.round(popper.bottom),
4898 right: Math.floor(popper.right)
4899 };
4900
4901 var sideA = x === 'bottom' ? 'top' : 'bottom';
4902 var sideB = y === 'right' ? 'left' : 'right';
4903
4904 // if gpuAcceleration is set to `true` and transform is supported,
4905 // we use `translate3d` to apply the position to the popper we
4906 // automatically use the supported prefixed version if needed
4907 var prefixedProperty = getSupportedPropertyName$1('transform');
4908
4909 // now, let's make a step back and look at this code closely (wtf?)
4910 // If the content of the popper grows once it's been positioned, it
4911 // may happen that the popper gets misplaced because of the new content
4912 // overflowing its reference element
4913 // To avoid this problem, we provide two options (x and y), which allow
4914 // the consumer to define the offset origin.
4915 // If we position a popper on top of a reference element, we can set
4916 // `x` to `top` to make the popper grow towards its top instead of
4917 // its bottom.
4918 var left = void 0,
4919 top = void 0;
4920 if (sideA === 'bottom') {
4921 // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
4922 // and not the bottom of the html element
4923 if (offsetParent.nodeName === 'HTML') {
4924 top = -offsetParent.clientHeight + offsets.bottom;
4925 } else {
4926 top = -offsetParentRect.height + offsets.bottom;
4927 }
4928 } else {
4929 top = offsets.top;
4930 }
4931 if (sideB === 'right') {
4932 if (offsetParent.nodeName === 'HTML') {
4933 left = -offsetParent.clientWidth + offsets.right;
4934 } else {
4935 left = -offsetParentRect.width + offsets.right;
4936 }
4937 } else {
4938 left = offsets.left;
4939 }
4940 if (gpuAcceleration && prefixedProperty) {
4941 styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
4942 styles[sideA] = 0;
4943 styles[sideB] = 0;
4944 styles.willChange = 'transform';
4945 } else {
4946 // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
4947 var invertTop = sideA === 'bottom' ? -1 : 1;
4948 var invertLeft = sideB === 'right' ? -1 : 1;
4949 styles[sideA] = top * invertTop;
4950 styles[sideB] = left * invertLeft;
4951 styles.willChange = sideA + ', ' + sideB;
4952 }
4953
4954 // Attributes
4955 var attributes = {
4956 'x-placement': data.placement
4957 };
4958
4959 // Update `data` attributes, styles and arrowStyles
4960 data.attributes = _extends$2({}, attributes, data.attributes);
4961 data.styles = _extends$2({}, styles, data.styles);
4962 data.arrowStyles = _extends$2({}, data.offsets.arrow, data.arrowStyles);
4963
4964 return data;
4965}
4966
4967/**
4968 * Helper used to know if the given modifier depends from another one.<br />
4969 * It checks if the needed modifier is listed and enabled.
4970 * @method
4971 * @memberof Popper.Utils
4972 * @param {Array} modifiers - list of modifiers
4973 * @param {String} requestingName - name of requesting modifier
4974 * @param {String} requestedName - name of requested modifier
4975 * @returns {Boolean}
4976 */
4977function isModifierRequired$1(modifiers, requestingName, requestedName) {
4978 var requesting = find$1(modifiers, function (_ref) {
4979 var name = _ref.name;
4980 return name === requestingName;
4981 });
4982
4983 var isRequired = !!requesting && modifiers.some(function (modifier) {
4984 return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
4985 });
4986
4987 if (!isRequired) {
4988 var _requesting = '`' + requestingName + '`';
4989 var requested = '`' + requestedName + '`';
4990 console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
4991 }
4992 return isRequired;
4993}
4994
4995/**
4996 * @function
4997 * @memberof Modifiers
4998 * @argument {Object} data - The data object generated by update method
4999 * @argument {Object} options - Modifiers configuration and options
5000 * @returns {Object} The data object, properly modified
5001 */
5002function arrow$1(data, options) {
5003 var _data$offsets$arrow;
5004
5005 // arrow depends on keepTogether in order to work
5006 if (!isModifierRequired$1(data.instance.modifiers, 'arrow', 'keepTogether')) {
5007 return data;
5008 }
5009
5010 var arrowElement = options.element;
5011
5012 // if arrowElement is a string, suppose it's a CSS selector
5013 if (typeof arrowElement === 'string') {
5014 arrowElement = data.instance.popper.querySelector(arrowElement);
5015
5016 // if arrowElement is not found, don't run the modifier
5017 if (!arrowElement) {
5018 return data;
5019 }
5020 } else {
5021 // if the arrowElement isn't a query selector we must check that the
5022 // provided DOM node is child of its popper node
5023 if (!data.instance.popper.contains(arrowElement)) {
5024 console.warn('WARNING: `arrow.element` must be child of its popper element!');
5025 return data;
5026 }
5027 }
5028
5029 var placement = data.placement.split('-')[0];
5030 var _data$offsets = data.offsets,
5031 popper = _data$offsets.popper,
5032 reference = _data$offsets.reference;
5033
5034 var isVertical = ['left', 'right'].indexOf(placement) !== -1;
5035
5036 var len = isVertical ? 'height' : 'width';
5037 var sideCapitalized = isVertical ? 'Top' : 'Left';
5038 var side = sideCapitalized.toLowerCase();
5039 var altSide = isVertical ? 'left' : 'top';
5040 var opSide = isVertical ? 'bottom' : 'right';
5041 var arrowElementSize = getOuterSizes$1(arrowElement)[len];
5042
5043 //
5044 // extends keepTogether behavior making sure the popper and its
5045 // reference have enough pixels in conjunction
5046 //
5047
5048 // top/left side
5049 if (reference[opSide] - arrowElementSize < popper[side]) {
5050 data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
5051 }
5052 // bottom/right side
5053 if (reference[side] + arrowElementSize > popper[opSide]) {
5054 data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
5055 }
5056 data.offsets.popper = getClientRect$1(data.offsets.popper);
5057
5058 // compute center of the popper
5059 var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
5060
5061 // Compute the sideValue using the updated popper offsets
5062 // take popper margin in account because we don't have this info available
5063 var css = getStyleComputedProperty$1(data.instance.popper);
5064 var popperMarginSide = parseFloat(css['margin' + sideCapitalized], 10);
5065 var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width'], 10);
5066 var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
5067
5068 // prevent arrowElement from being placed not contiguously to its popper
5069 sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
5070
5071 data.arrowElement = arrowElement;
5072 data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty$2(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty$2(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
5073
5074 return data;
5075}
5076
5077/**
5078 * Get the opposite placement variation of the given one
5079 * @method
5080 * @memberof Popper.Utils
5081 * @argument {String} placement variation
5082 * @returns {String} flipped placement variation
5083 */
5084function getOppositeVariation$1(variation) {
5085 if (variation === 'end') {
5086 return 'start';
5087 } else if (variation === 'start') {
5088 return 'end';
5089 }
5090 return variation;
5091}
5092
5093/**
5094 * List of accepted placements to use as values of the `placement` option.<br />
5095 * Valid placements are:
5096 * - `auto`
5097 * - `top`
5098 * - `right`
5099 * - `bottom`
5100 * - `left`
5101 *
5102 * Each placement can have a variation from this list:
5103 * - `-start`
5104 * - `-end`
5105 *
5106 * Variations are interpreted easily if you think of them as the left to right
5107 * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
5108 * is right.<br />
5109 * Vertically (`left` and `right`), `start` is top and `end` is bottom.
5110 *
5111 * Some valid examples are:
5112 * - `top-end` (on top of reference, right aligned)
5113 * - `right-start` (on right of reference, top aligned)
5114 * - `bottom` (on bottom, centered)
5115 * - `auto-end` (on the side with more space available, alignment depends by placement)
5116 *
5117 * @static
5118 * @type {Array}
5119 * @enum {String}
5120 * @readonly
5121 * @method placements
5122 * @memberof Popper
5123 */
5124var placements$1 = ['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start'];
5125
5126// Get rid of `auto` `auto-start` and `auto-end`
5127var validPlacements$1 = placements$1.slice(3);
5128
5129/**
5130 * Given an initial placement, returns all the subsequent placements
5131 * clockwise (or counter-clockwise).
5132 *
5133 * @method
5134 * @memberof Popper.Utils
5135 * @argument {String} placement - A valid placement (it accepts variations)
5136 * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
5137 * @returns {Array} placements including their variations
5138 */
5139function clockwise$1(placement) {
5140 var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
5141
5142 var index = validPlacements$1.indexOf(placement);
5143 var arr = validPlacements$1.slice(index + 1).concat(validPlacements$1.slice(0, index));
5144 return counter ? arr.reverse() : arr;
5145}
5146
5147var BEHAVIORS$1 = {
5148 FLIP: 'flip',
5149 CLOCKWISE: 'clockwise',
5150 COUNTERCLOCKWISE: 'counterclockwise'
5151};
5152
5153/**
5154 * @function
5155 * @memberof Modifiers
5156 * @argument {Object} data - The data object generated by update method
5157 * @argument {Object} options - Modifiers configuration and options
5158 * @returns {Object} The data object, properly modified
5159 */
5160function flip$1(data, options) {
5161 // if `inner` modifier is enabled, we can't use the `flip` modifier
5162 if (isModifierEnabled$1(data.instance.modifiers, 'inner')) {
5163 return data;
5164 }
5165
5166 if (data.flipped && data.placement === data.originalPlacement) {
5167 // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
5168 return data;
5169 }
5170
5171 var boundaries = getBoundaries$1(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
5172
5173 var placement = data.placement.split('-')[0];
5174 var placementOpposite = getOppositePlacement$1(placement);
5175 var variation = data.placement.split('-')[1] || '';
5176
5177 var flipOrder = [];
5178
5179 switch (options.behavior) {
5180 case BEHAVIORS$1.FLIP:
5181 flipOrder = [placement, placementOpposite];
5182 break;
5183 case BEHAVIORS$1.CLOCKWISE:
5184 flipOrder = clockwise$1(placement);
5185 break;
5186 case BEHAVIORS$1.COUNTERCLOCKWISE:
5187 flipOrder = clockwise$1(placement, true);
5188 break;
5189 default:
5190 flipOrder = options.behavior;
5191 }
5192
5193 flipOrder.forEach(function (step, index) {
5194 if (placement !== step || flipOrder.length === index + 1) {
5195 return data;
5196 }
5197
5198 placement = data.placement.split('-')[0];
5199 placementOpposite = getOppositePlacement$1(placement);
5200
5201 var popperOffsets = data.offsets.popper;
5202 var refOffsets = data.offsets.reference;
5203
5204 // using floor because the reference offsets may contain decimals we are not going to consider here
5205 var floor = Math.floor;
5206 var overlapsRef = placement === 'left' && floor(popperOffsets.right) > floor(refOffsets.left) || placement === 'right' && floor(popperOffsets.left) < floor(refOffsets.right) || placement === 'top' && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === 'bottom' && floor(popperOffsets.top) < floor(refOffsets.bottom);
5207
5208 var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
5209 var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
5210 var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
5211 var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
5212
5213 var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
5214
5215 // flip the variation if required
5216 var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
5217 var flippedVariation = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
5218
5219 if (overlapsRef || overflowsBoundaries || flippedVariation) {
5220 // this boolean to detect any flip loop
5221 data.flipped = true;
5222
5223 if (overlapsRef || overflowsBoundaries) {
5224 placement = flipOrder[index + 1];
5225 }
5226
5227 if (flippedVariation) {
5228 variation = getOppositeVariation$1(variation);
5229 }
5230
5231 data.placement = placement + (variation ? '-' + variation : '');
5232
5233 // this object contains `position`, we want to preserve it along with
5234 // any additional property we may add in the future
5235 data.offsets.popper = _extends$2({}, data.offsets.popper, getPopperOffsets$1(data.instance.popper, data.offsets.reference, data.placement));
5236
5237 data = runModifiers$1(data.instance.modifiers, data, 'flip');
5238 }
5239 });
5240 return data;
5241}
5242
5243/**
5244 * @function
5245 * @memberof Modifiers
5246 * @argument {Object} data - The data object generated by update method
5247 * @argument {Object} options - Modifiers configuration and options
5248 * @returns {Object} The data object, properly modified
5249 */
5250function keepTogether$1(data) {
5251 var _data$offsets = data.offsets,
5252 popper = _data$offsets.popper,
5253 reference = _data$offsets.reference;
5254
5255 var placement = data.placement.split('-')[0];
5256 var floor = Math.floor;
5257 var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
5258 var side = isVertical ? 'right' : 'bottom';
5259 var opSide = isVertical ? 'left' : 'top';
5260 var measurement = isVertical ? 'width' : 'height';
5261
5262 if (popper[side] < floor(reference[opSide])) {
5263 data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
5264 }
5265 if (popper[opSide] > floor(reference[side])) {
5266 data.offsets.popper[opSide] = floor(reference[side]);
5267 }
5268
5269 return data;
5270}
5271
5272/**
5273 * Converts a string containing value + unit into a px value number
5274 * @function
5275 * @memberof {modifiers~offset}
5276 * @private
5277 * @argument {String} str - Value + unit string
5278 * @argument {String} measurement - `height` or `width`
5279 * @argument {Object} popperOffsets
5280 * @argument {Object} referenceOffsets
5281 * @returns {Number|String}
5282 * Value in pixels, or original string if no values were extracted
5283 */
5284function toValue$1(str, measurement, popperOffsets, referenceOffsets) {
5285 // separate value from unit
5286 var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
5287 var value = +split[1];
5288 var unit = split[2];
5289
5290 // If it's not a number it's an operator, I guess
5291 if (!value) {
5292 return str;
5293 }
5294
5295 if (unit.indexOf('%') === 0) {
5296 var element = void 0;
5297 switch (unit) {
5298 case '%p':
5299 element = popperOffsets;
5300 break;
5301 case '%':
5302 case '%r':
5303 default:
5304 element = referenceOffsets;
5305 }
5306
5307 var rect = getClientRect$1(element);
5308 return rect[measurement] / 100 * value;
5309 } else if (unit === 'vh' || unit === 'vw') {
5310 // if is a vh or vw, we calculate the size based on the viewport
5311 var size = void 0;
5312 if (unit === 'vh') {
5313 size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
5314 } else {
5315 size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
5316 }
5317 return size / 100 * value;
5318 } else {
5319 // if is an explicit pixel unit, we get rid of the unit and keep the value
5320 // if is an implicit unit, it's px, and we return just the value
5321 return value;
5322 }
5323}
5324
5325/**
5326 * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
5327 * @function
5328 * @memberof {modifiers~offset}
5329 * @private
5330 * @argument {String} offset
5331 * @argument {Object} popperOffsets
5332 * @argument {Object} referenceOffsets
5333 * @argument {String} basePlacement
5334 * @returns {Array} a two cells array with x and y offsets in numbers
5335 */
5336function parseOffset$1(offset, popperOffsets, referenceOffsets, basePlacement) {
5337 var offsets = [0, 0];
5338
5339 // Use height if placement is left or right and index is 0 otherwise use width
5340 // in this way the first offset will use an axis and the second one
5341 // will use the other one
5342 var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
5343
5344 // Split the offset string to obtain a list of values and operands
5345 // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
5346 var fragments = offset.split(/(\+|\-)/).map(function (frag) {
5347 return frag.trim();
5348 });
5349
5350 // Detect if the offset string contains a pair of values or a single one
5351 // they could be separated by comma or space
5352 var divider = fragments.indexOf(find$1(fragments, function (frag) {
5353 return frag.search(/,|\s/) !== -1;
5354 }));
5355
5356 if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
5357 console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
5358 }
5359
5360 // If divider is found, we divide the list of values and operands to divide
5361 // them by ofset X and Y.
5362 var splitRegex = /\s*,\s*|\s+/;
5363 var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments];
5364
5365 // Convert the values with units to absolute pixels to allow our computations
5366 ops = ops.map(function (op, index) {
5367 // Most of the units rely on the orientation of the popper
5368 var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
5369 var mergeWithPrevious = false;
5370 return op
5371 // This aggregates any `+` or `-` sign that aren't considered operators
5372 // e.g.: 10 + +5 => [10, +, +5]
5373 .reduce(function (a, b) {
5374 if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
5375 a[a.length - 1] = b;
5376 mergeWithPrevious = true;
5377 return a;
5378 } else if (mergeWithPrevious) {
5379 a[a.length - 1] += b;
5380 mergeWithPrevious = false;
5381 return a;
5382 } else {
5383 return a.concat(b);
5384 }
5385 }, [])
5386 // Here we convert the string values into number values (in px)
5387 .map(function (str) {
5388 return toValue$1(str, measurement, popperOffsets, referenceOffsets);
5389 });
5390 });
5391
5392 // Loop trough the offsets arrays and execute the operations
5393 ops.forEach(function (op, index) {
5394 op.forEach(function (frag, index2) {
5395 if (isNumeric$1(frag)) {
5396 offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
5397 }
5398 });
5399 });
5400 return offsets;
5401}
5402
5403/**
5404 * @function
5405 * @memberof Modifiers
5406 * @argument {Object} data - The data object generated by update method
5407 * @argument {Object} options - Modifiers configuration and options
5408 * @argument {Number|String} options.offset=0
5409 * The offset value as described in the modifier description
5410 * @returns {Object} The data object, properly modified
5411 */
5412function offset$1(data, _ref) {
5413 var offset = _ref.offset;
5414 var placement = data.placement,
5415 _data$offsets = data.offsets,
5416 popper = _data$offsets.popper,
5417 reference = _data$offsets.reference;
5418
5419 var basePlacement = placement.split('-')[0];
5420
5421 var offsets = void 0;
5422 if (isNumeric$1(+offset)) {
5423 offsets = [+offset, 0];
5424 } else {
5425 offsets = parseOffset$1(offset, popper, reference, basePlacement);
5426 }
5427
5428 if (basePlacement === 'left') {
5429 popper.top += offsets[0];
5430 popper.left -= offsets[1];
5431 } else if (basePlacement === 'right') {
5432 popper.top += offsets[0];
5433 popper.left += offsets[1];
5434 } else if (basePlacement === 'top') {
5435 popper.left += offsets[0];
5436 popper.top -= offsets[1];
5437 } else if (basePlacement === 'bottom') {
5438 popper.left += offsets[0];
5439 popper.top += offsets[1];
5440 }
5441
5442 data.popper = popper;
5443 return data;
5444}
5445
5446/**
5447 * @function
5448 * @memberof Modifiers
5449 * @argument {Object} data - The data object generated by `update` method
5450 * @argument {Object} options - Modifiers configuration and options
5451 * @returns {Object} The data object, properly modified
5452 */
5453function preventOverflow$1(data, options) {
5454 var boundariesElement = options.boundariesElement || getOffsetParent$1(data.instance.popper);
5455
5456 // If offsetParent is the reference element, we really want to
5457 // go one step up and use the next offsetParent as reference to
5458 // avoid to make this modifier completely useless and look like broken
5459 if (data.instance.reference === boundariesElement) {
5460 boundariesElement = getOffsetParent$1(boundariesElement);
5461 }
5462
5463 // NOTE: DOM access here
5464 // resets the popper's position so that the document size can be calculated excluding
5465 // the size of the popper element itself
5466 var transformProp = getSupportedPropertyName$1('transform');
5467 var popperStyles = data.instance.popper.style; // assignment to help minification
5468 var top = popperStyles.top,
5469 left = popperStyles.left,
5470 transform = popperStyles[transformProp];
5471
5472 popperStyles.top = '';
5473 popperStyles.left = '';
5474 popperStyles[transformProp] = '';
5475
5476 var boundaries = getBoundaries$1(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
5477
5478 // NOTE: DOM access here
5479 // restores the original style properties after the offsets have been computed
5480 popperStyles.top = top;
5481 popperStyles.left = left;
5482 popperStyles[transformProp] = transform;
5483
5484 options.boundaries = boundaries;
5485
5486 var order = options.priority;
5487 var popper = data.offsets.popper;
5488
5489 var check = {
5490 primary: function primary(placement) {
5491 var value = popper[placement];
5492 if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
5493 value = Math.max(popper[placement], boundaries[placement]);
5494 }
5495 return defineProperty$2({}, placement, value);
5496 },
5497 secondary: function secondary(placement) {
5498 var mainSide = placement === 'right' ? 'left' : 'top';
5499 var value = popper[mainSide];
5500 if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
5501 value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
5502 }
5503 return defineProperty$2({}, mainSide, value);
5504 }
5505 };
5506
5507 order.forEach(function (placement) {
5508 var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
5509 popper = _extends$2({}, popper, check[side](placement));
5510 });
5511
5512 data.offsets.popper = popper;
5513
5514 return data;
5515}
5516
5517/**
5518 * @function
5519 * @memberof Modifiers
5520 * @argument {Object} data - The data object generated by `update` method
5521 * @argument {Object} options - Modifiers configuration and options
5522 * @returns {Object} The data object, properly modified
5523 */
5524function shift$1(data) {
5525 var placement = data.placement;
5526 var basePlacement = placement.split('-')[0];
5527 var shiftvariation = placement.split('-')[1];
5528
5529 // if shift shiftvariation is specified, run the modifier
5530 if (shiftvariation) {
5531 var _data$offsets = data.offsets,
5532 reference = _data$offsets.reference,
5533 popper = _data$offsets.popper;
5534
5535 var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
5536 var side = isVertical ? 'left' : 'top';
5537 var measurement = isVertical ? 'width' : 'height';
5538
5539 var shiftOffsets = {
5540 start: defineProperty$2({}, side, reference[side]),
5541 end: defineProperty$2({}, side, reference[side] + reference[measurement] - popper[measurement])
5542 };
5543
5544 data.offsets.popper = _extends$2({}, popper, shiftOffsets[shiftvariation]);
5545 }
5546
5547 return data;
5548}
5549
5550/**
5551 * @function
5552 * @memberof Modifiers
5553 * @argument {Object} data - The data object generated by update method
5554 * @argument {Object} options - Modifiers configuration and options
5555 * @returns {Object} The data object, properly modified
5556 */
5557function hide$1(data) {
5558 if (!isModifierRequired$1(data.instance.modifiers, 'hide', 'preventOverflow')) {
5559 return data;
5560 }
5561
5562 var refRect = data.offsets.reference;
5563 var bound = find$1(data.instance.modifiers, function (modifier) {
5564 return modifier.name === 'preventOverflow';
5565 }).boundaries;
5566
5567 if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
5568 // Avoid unnecessary DOM access if visibility hasn't changed
5569 if (data.hide === true) {
5570 return data;
5571 }
5572
5573 data.hide = true;
5574 data.attributes['x-out-of-boundaries'] = '';
5575 } else {
5576 // Avoid unnecessary DOM access if visibility hasn't changed
5577 if (data.hide === false) {
5578 return data;
5579 }
5580
5581 data.hide = false;
5582 data.attributes['x-out-of-boundaries'] = false;
5583 }
5584
5585 return data;
5586}
5587
5588/**
5589 * @function
5590 * @memberof Modifiers
5591 * @argument {Object} data - The data object generated by `update` method
5592 * @argument {Object} options - Modifiers configuration and options
5593 * @returns {Object} The data object, properly modified
5594 */
5595function inner$1(data) {
5596 var placement = data.placement;
5597 var basePlacement = placement.split('-')[0];
5598 var _data$offsets = data.offsets,
5599 popper = _data$offsets.popper,
5600 reference = _data$offsets.reference;
5601
5602 var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
5603
5604 var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
5605
5606 popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
5607
5608 data.placement = getOppositePlacement$1(placement);
5609 data.offsets.popper = getClientRect$1(popper);
5610
5611 return data;
5612}
5613
5614/**
5615 * Modifier function, each modifier can have a function of this type assigned
5616 * to its `fn` property.<br />
5617 * These functions will be called on each update, this means that you must
5618 * make sure they are performant enough to avoid performance bottlenecks.
5619 *
5620 * @function ModifierFn
5621 * @argument {dataObject} data - The data object generated by `update` method
5622 * @argument {Object} options - Modifiers configuration and options
5623 * @returns {dataObject} The data object, properly modified
5624 */
5625
5626/**
5627 * Modifiers are plugins used to alter the behavior of your poppers.<br />
5628 * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
5629 * needed by the library.
5630 *
5631 * Usually you don't want to override the `order`, `fn` and `onLoad` props.
5632 * All the other properties are configurations that could be tweaked.
5633 * @namespace modifiers
5634 */
5635var modifiers$1 = {
5636 /**
5637 * Modifier used to shift the popper on the start or end of its reference
5638 * element.<br />
5639 * It will read the variation of the `placement` property.<br />
5640 * It can be one either `-end` or `-start`.
5641 * @memberof modifiers
5642 * @inner
5643 */
5644 shift: {
5645 /** @prop {number} order=100 - Index used to define the order of execution */
5646 order: 100,
5647 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
5648 enabled: true,
5649 /** @prop {ModifierFn} */
5650 fn: shift$1
5651 },
5652
5653 /**
5654 * The `offset` modifier can shift your popper on both its axis.
5655 *
5656 * It accepts the following units:
5657 * - `px` or unit-less, interpreted as pixels
5658 * - `%` or `%r`, percentage relative to the length of the reference element
5659 * - `%p`, percentage relative to the length of the popper element
5660 * - `vw`, CSS viewport width unit
5661 * - `vh`, CSS viewport height unit
5662 *
5663 * For length is intended the main axis relative to the placement of the popper.<br />
5664 * This means that if the placement is `top` or `bottom`, the length will be the
5665 * `width`. In case of `left` or `right`, it will be the `height`.
5666 *
5667 * You can provide a single value (as `Number` or `String`), or a pair of values
5668 * as `String` divided by a comma or one (or more) white spaces.<br />
5669 * The latter is a deprecated method because it leads to confusion and will be
5670 * removed in v2.<br />
5671 * Additionally, it accepts additions and subtractions between different units.
5672 * Note that multiplications and divisions aren't supported.
5673 *
5674 * Valid examples are:
5675 * ```
5676 * 10
5677 * '10%'
5678 * '10, 10'
5679 * '10%, 10'
5680 * '10 + 10%'
5681 * '10 - 5vh + 3%'
5682 * '-10px + 5vh, 5px - 6%'
5683 * ```
5684 * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
5685 * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
5686 * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
5687 *
5688 * @memberof modifiers
5689 * @inner
5690 */
5691 offset: {
5692 /** @prop {number} order=200 - Index used to define the order of execution */
5693 order: 200,
5694 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
5695 enabled: true,
5696 /** @prop {ModifierFn} */
5697 fn: offset$1,
5698 /** @prop {Number|String} offset=0
5699 * The offset value as described in the modifier description
5700 */
5701 offset: 0
5702 },
5703
5704 /**
5705 * Modifier used to prevent the popper from being positioned outside the boundary.
5706 *
5707 * A scenario exists where the reference itself is not within the boundaries.<br />
5708 * We can say it has "escaped the boundaries" — or just "escaped".<br />
5709 * In this case we need to decide whether the popper should either:
5710 *
5711 * - detach from the reference and remain "trapped" in the boundaries, or
5712 * - if it should ignore the boundary and "escape with its reference"
5713 *
5714 * When `escapeWithReference` is set to`true` and reference is completely
5715 * outside its boundaries, the popper will overflow (or completely leave)
5716 * the boundaries in order to remain attached to the edge of the reference.
5717 *
5718 * @memberof modifiers
5719 * @inner
5720 */
5721 preventOverflow: {
5722 /** @prop {number} order=300 - Index used to define the order of execution */
5723 order: 300,
5724 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
5725 enabled: true,
5726 /** @prop {ModifierFn} */
5727 fn: preventOverflow$1,
5728 /**
5729 * @prop {Array} [priority=['left','right','top','bottom']]
5730 * Popper will try to prevent overflow following these priorities by default,
5731 * then, it could overflow on the left and on top of the `boundariesElement`
5732 */
5733 priority: ['left', 'right', 'top', 'bottom'],
5734 /**
5735 * @prop {number} padding=5
5736 * Amount of pixel used to define a minimum distance between the boundaries
5737 * and the popper. This makes sure the popper always has a little padding
5738 * between the edges of its container
5739 */
5740 padding: 5,
5741 /**
5742 * @prop {String|HTMLElement} boundariesElement='scrollParent'
5743 * Boundaries used by the modifier. Can be `scrollParent`, `window`,
5744 * `viewport` or any DOM element.
5745 */
5746 boundariesElement: 'scrollParent'
5747 },
5748
5749 /**
5750 * Modifier used to make sure the reference and its popper stay near each other
5751 * without leaving any gap between the two. Especially useful when the arrow is
5752 * enabled and you want to ensure that it points to its reference element.
5753 * It cares only about the first axis. You can still have poppers with margin
5754 * between the popper and its reference element.
5755 * @memberof modifiers
5756 * @inner
5757 */
5758 keepTogether: {
5759 /** @prop {number} order=400 - Index used to define the order of execution */
5760 order: 400,
5761 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
5762 enabled: true,
5763 /** @prop {ModifierFn} */
5764 fn: keepTogether$1
5765 },
5766
5767 /**
5768 * This modifier is used to move the `arrowElement` of the popper to make
5769 * sure it is positioned between the reference element and its popper element.
5770 * It will read the outer size of the `arrowElement` node to detect how many
5771 * pixels of conjunction are needed.
5772 *
5773 * It has no effect if no `arrowElement` is provided.
5774 * @memberof modifiers
5775 * @inner
5776 */
5777 arrow: {
5778 /** @prop {number} order=500 - Index used to define the order of execution */
5779 order: 500,
5780 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
5781 enabled: true,
5782 /** @prop {ModifierFn} */
5783 fn: arrow$1,
5784 /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
5785 element: '[x-arrow]'
5786 },
5787
5788 /**
5789 * Modifier used to flip the popper's placement when it starts to overlap its
5790 * reference element.
5791 *
5792 * Requires the `preventOverflow` modifier before it in order to work.
5793 *
5794 * **NOTE:** this modifier will interrupt the current update cycle and will
5795 * restart it if it detects the need to flip the placement.
5796 * @memberof modifiers
5797 * @inner
5798 */
5799 flip: {
5800 /** @prop {number} order=600 - Index used to define the order of execution */
5801 order: 600,
5802 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
5803 enabled: true,
5804 /** @prop {ModifierFn} */
5805 fn: flip$1,
5806 /**
5807 * @prop {String|Array} behavior='flip'
5808 * The behavior used to change the popper's placement. It can be one of
5809 * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
5810 * placements (with optional variations)
5811 */
5812 behavior: 'flip',
5813 /**
5814 * @prop {number} padding=5
5815 * The popper will flip if it hits the edges of the `boundariesElement`
5816 */
5817 padding: 5,
5818 /**
5819 * @prop {String|HTMLElement} boundariesElement='viewport'
5820 * The element which will define the boundaries of the popper position.
5821 * The popper will never be placed outside of the defined boundaries
5822 * (except if `keepTogether` is enabled)
5823 */
5824 boundariesElement: 'viewport'
5825 },
5826
5827 /**
5828 * Modifier used to make the popper flow toward the inner of the reference element.
5829 * By default, when this modifier is disabled, the popper will be placed outside
5830 * the reference element.
5831 * @memberof modifiers
5832 * @inner
5833 */
5834 inner: {
5835 /** @prop {number} order=700 - Index used to define the order of execution */
5836 order: 700,
5837 /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
5838 enabled: false,
5839 /** @prop {ModifierFn} */
5840 fn: inner$1
5841 },
5842
5843 /**
5844 * Modifier used to hide the popper when its reference element is outside of the
5845 * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
5846 * be used to hide with a CSS selector the popper when its reference is
5847 * out of boundaries.
5848 *
5849 * Requires the `preventOverflow` modifier before it in order to work.
5850 * @memberof modifiers
5851 * @inner
5852 */
5853 hide: {
5854 /** @prop {number} order=800 - Index used to define the order of execution */
5855 order: 800,
5856 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
5857 enabled: true,
5858 /** @prop {ModifierFn} */
5859 fn: hide$1
5860 },
5861
5862 /**
5863 * Computes the style that will be applied to the popper element to gets
5864 * properly positioned.
5865 *
5866 * Note that this modifier will not touch the DOM, it just prepares the styles
5867 * so that `applyStyle` modifier can apply it. This separation is useful
5868 * in case you need to replace `applyStyle` with a custom implementation.
5869 *
5870 * This modifier has `850` as `order` value to maintain backward compatibility
5871 * with previous versions of Popper.js. Expect the modifiers ordering method
5872 * to change in future major versions of the library.
5873 *
5874 * @memberof modifiers
5875 * @inner
5876 */
5877 computeStyle: {
5878 /** @prop {number} order=850 - Index used to define the order of execution */
5879 order: 850,
5880 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
5881 enabled: true,
5882 /** @prop {ModifierFn} */
5883 fn: computeStyle$1,
5884 /**
5885 * @prop {Boolean} gpuAcceleration=true
5886 * If true, it uses the CSS 3D transformation to position the popper.
5887 * Otherwise, it will use the `top` and `left` properties
5888 */
5889 gpuAcceleration: true,
5890 /**
5891 * @prop {string} [x='bottom']
5892 * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
5893 * Change this if your popper should grow in a direction different from `bottom`
5894 */
5895 x: 'bottom',
5896 /**
5897 * @prop {string} [x='left']
5898 * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
5899 * Change this if your popper should grow in a direction different from `right`
5900 */
5901 y: 'right'
5902 },
5903
5904 /**
5905 * Applies the computed styles to the popper element.
5906 *
5907 * All the DOM manipulations are limited to this modifier. This is useful in case
5908 * you want to integrate Popper.js inside a framework or view library and you
5909 * want to delegate all the DOM manipulations to it.
5910 *
5911 * Note that if you disable this modifier, you must make sure the popper element
5912 * has its position set to `absolute` before Popper.js can do its work!
5913 *
5914 * Just disable this modifier and define your own to achieve the desired effect.
5915 *
5916 * @memberof modifiers
5917 * @inner
5918 */
5919 applyStyle: {
5920 /** @prop {number} order=900 - Index used to define the order of execution */
5921 order: 900,
5922 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
5923 enabled: true,
5924 /** @prop {ModifierFn} */
5925 fn: applyStyle$1,
5926 /** @prop {Function} */
5927 onLoad: applyStyleOnLoad$1,
5928 /**
5929 * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
5930 * @prop {Boolean} gpuAcceleration=true
5931 * If true, it uses the CSS 3D transformation to position the popper.
5932 * Otherwise, it will use the `top` and `left` properties
5933 */
5934 gpuAcceleration: undefined
5935 }
5936};
5937
5938/**
5939 * The `dataObject` is an object containing all the information used by Popper.js.
5940 * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
5941 * @name dataObject
5942 * @property {Object} data.instance The Popper.js instance
5943 * @property {String} data.placement Placement applied to popper
5944 * @property {String} data.originalPlacement Placement originally defined on init
5945 * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
5946 * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
5947 * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
5948 * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
5949 * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
5950 * @property {Object} data.boundaries Offsets of the popper boundaries
5951 * @property {Object} data.offsets The measurements of popper, reference and arrow elements
5952 * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
5953 * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
5954 * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
5955 */
5956
5957/**
5958 * Default options provided to Popper.js constructor.<br />
5959 * These can be overridden using the `options` argument of Popper.js.<br />
5960 * To override an option, simply pass an object with the same
5961 * structure of the `options` object, as the 3rd argument. For example:
5962 * ```
5963 * new Popper(ref, pop, {
5964 * modifiers: {
5965 * preventOverflow: { enabled: false }
5966 * }
5967 * })
5968 * ```
5969 * @type {Object}
5970 * @static
5971 * @memberof Popper
5972 */
5973var Defaults$1 = {
5974 /**
5975 * Popper's placement.
5976 * @prop {Popper.placements} placement='bottom'
5977 */
5978 placement: 'bottom',
5979
5980 /**
5981 * Set this to true if you want popper to position it self in 'fixed' mode
5982 * @prop {Boolean} positionFixed=false
5983 */
5984 positionFixed: false,
5985
5986 /**
5987 * Whether events (resize, scroll) are initially enabled.
5988 * @prop {Boolean} eventsEnabled=true
5989 */
5990 eventsEnabled: true,
5991
5992 /**
5993 * Set to true if you want to automatically remove the popper when
5994 * you call the `destroy` method.
5995 * @prop {Boolean} removeOnDestroy=false
5996 */
5997 removeOnDestroy: false,
5998
5999 /**
6000 * Callback called when the popper is created.<br />
6001 * By default, it is set to no-op.<br />
6002 * Access Popper.js instance with `data.instance`.
6003 * @prop {onCreate}
6004 */
6005 onCreate: function onCreate() {},
6006
6007 /**
6008 * Callback called when the popper is updated. This callback is not called
6009 * on the initialization/creation of the popper, but only on subsequent
6010 * updates.<br />
6011 * By default, it is set to no-op.<br />
6012 * Access Popper.js instance with `data.instance`.
6013 * @prop {onUpdate}
6014 */
6015 onUpdate: function onUpdate() {},
6016
6017 /**
6018 * List of modifiers used to modify the offsets before they are applied to the popper.
6019 * They provide most of the functionalities of Popper.js.
6020 * @prop {modifiers}
6021 */
6022 modifiers: modifiers$1
6023};
6024
6025/**
6026 * @callback onCreate
6027 * @param {dataObject} data
6028 */
6029
6030/**
6031 * @callback onUpdate
6032 * @param {dataObject} data
6033 */
6034
6035// Utils
6036// Methods
6037var Popper$1 = function () {
6038 /**
6039 * Creates a new Popper.js instance.
6040 * @class Popper
6041 * @param {HTMLElement|referenceObject} reference - The reference element used to position the popper
6042 * @param {HTMLElement} popper - The HTML element used as the popper
6043 * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
6044 * @return {Object} instance - The generated Popper.js instance
6045 */
6046 function Popper(reference, popper) {
6047 var _this = this;
6048
6049 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
6050 classCallCheck$2(this, Popper);
6051
6052 this.scheduleUpdate = function () {
6053 return requestAnimationFrame(_this.update);
6054 };
6055
6056 // make update() debounced, so that it only runs at most once-per-tick
6057 this.update = debounce$1(this.update.bind(this));
6058
6059 // with {} we create a new object with the options inside it
6060 this.options = _extends$2({}, Popper.Defaults, options);
6061
6062 // init state
6063 this.state = {
6064 isDestroyed: false,
6065 isCreated: false,
6066 scrollParents: []
6067 };
6068
6069 // get reference and popper elements (allow jQuery wrappers)
6070 this.reference = reference && reference.jquery ? reference[0] : reference;
6071 this.popper = popper && popper.jquery ? popper[0] : popper;
6072
6073 // Deep merge modifiers options
6074 this.options.modifiers = {};
6075 Object.keys(_extends$2({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
6076 _this.options.modifiers[name] = _extends$2({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
6077 });
6078
6079 // Refactoring modifiers' list (Object => Array)
6080 this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
6081 return _extends$2({
6082 name: name
6083 }, _this.options.modifiers[name]);
6084 })
6085 // sort the modifiers by order
6086 .sort(function (a, b) {
6087 return a.order - b.order;
6088 });
6089
6090 // modifiers have the ability to execute arbitrary code when Popper.js get inited
6091 // such code is executed in the same order of its modifier
6092 // they could add new properties to their options configuration
6093 // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
6094 this.modifiers.forEach(function (modifierOptions) {
6095 if (modifierOptions.enabled && isFunction$1(modifierOptions.onLoad)) {
6096 modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
6097 }
6098 });
6099
6100 // fire the first update to position the popper in the right place
6101 this.update();
6102
6103 var eventsEnabled = this.options.eventsEnabled;
6104 if (eventsEnabled) {
6105 // setup event listeners, they will take care of update the position in specific situations
6106 this.enableEventListeners();
6107 }
6108
6109 this.state.eventsEnabled = eventsEnabled;
6110 }
6111
6112 // We can't use class properties because they don't get listed in the
6113 // class prototype and break stuff like Sinon stubs
6114
6115
6116 createClass$2(Popper, [{
6117 key: 'update',
6118 value: function update$$1() {
6119 return update$1.call(this);
6120 }
6121 }, {
6122 key: 'destroy',
6123 value: function destroy$$1() {
6124 return destroy$1.call(this);
6125 }
6126 }, {
6127 key: 'enableEventListeners',
6128 value: function enableEventListeners$$1() {
6129 return enableEventListeners$1.call(this);
6130 }
6131 }, {
6132 key: 'disableEventListeners',
6133 value: function disableEventListeners$$1() {
6134 return disableEventListeners$1.call(this);
6135 }
6136
6137 /**
6138 * Schedules an update. It will run on the next UI update available.
6139 * @method scheduleUpdate
6140 * @memberof Popper
6141 */
6142
6143
6144 /**
6145 * Collection of utilities useful when writing custom modifiers.
6146 * Starting from version 1.7, this method is available only if you
6147 * include `popper-utils.js` before `popper.js`.
6148 *
6149 * **DEPRECATION**: This way to access PopperUtils is deprecated
6150 * and will be removed in v2! Use the PopperUtils module directly instead.
6151 * Due to the high instability of the methods contained in Utils, we can't
6152 * guarantee them to follow semver. Use them at your own risk!
6153 * @static
6154 * @private
6155 * @type {Object}
6156 * @deprecated since version 1.8
6157 * @member Utils
6158 * @memberof Popper
6159 */
6160
6161 }]);
6162 return Popper;
6163}();
6164
6165/**
6166 * The `referenceObject` is an object that provides an interface compatible with Popper.js
6167 * and lets you use it as replacement of a real DOM node.<br />
6168 * You can use this method to position a popper relatively to a set of coordinates
6169 * in case you don't have a DOM node to use as reference.
6170 *
6171 * ```
6172 * new Popper(referenceObject, popperNode);
6173 * ```
6174 *
6175 * NB: This feature isn't supported in Internet Explorer 10.
6176 * @name referenceObject
6177 * @property {Function} data.getBoundingClientRect
6178 * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
6179 * @property {number} data.clientWidth
6180 * An ES6 getter that will return the width of the virtual reference element.
6181 * @property {number} data.clientHeight
6182 * An ES6 getter that will return the height of the virtual reference element.
6183 */
6184
6185
6186Popper$1.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
6187Popper$1.placements = placements$1;
6188Popper$1.Defaults = Defaults$1;
6189
6190/**!
6191 * @fileOverview Kickass library to create and place poppers near their reference elements.
6192 * @version 1.3.1
6193 * @license
6194 * Copyright (c) 2016 Federico Zivolo and contributors
6195 *
6196 * Permission is hereby granted, free of charge, to any person obtaining a copy
6197 * of this software and associated documentation files (the "Software"), to deal
6198 * in the Software without restriction, including without limitation the rights
6199 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6200 * copies of the Software, and to permit persons to whom the Software is
6201 * furnished to do so, subject to the following conditions:
6202 *
6203 * The above copyright notice and this permission notice shall be included in all
6204 * copies or substantial portions of the Software.
6205 *
6206 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6207 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6208 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6209 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6210 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6211 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
6212 * SOFTWARE.
6213 */
6214
6215/**
6216 * Check if the given variable is a function
6217 * @method
6218 * @memberof Popper.Utils
6219 * @argument {Any} functionToCheck - variable to check
6220 * @returns {Boolean} answer to: is a function?
6221 */
6222function isFunction$2(functionToCheck) {
6223 var getType = {};
6224 return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
6225}
6226
6227var classCallCheck$3 = function (instance, Constructor) {
6228 if (!(instance instanceof Constructor)) {
6229 throw new TypeError("Cannot call a class as a function");
6230 }
6231};
6232
6233var createClass$3 = function () {
6234 function defineProperties(target, props) {
6235 for (var i = 0; i < props.length; i++) {
6236 var descriptor = props[i];
6237 descriptor.enumerable = descriptor.enumerable || false;
6238 descriptor.configurable = true;
6239 if ("value" in descriptor) descriptor.writable = true;
6240 Object.defineProperty(target, descriptor.key, descriptor);
6241 }
6242 }
6243
6244 return function (Constructor, protoProps, staticProps) {
6245 if (protoProps) defineProperties(Constructor.prototype, protoProps);
6246 if (staticProps) defineProperties(Constructor, staticProps);
6247 return Constructor;
6248 };
6249}();
6250
6251
6252
6253
6254
6255
6256
6257var _extends$3 = Object.assign || function (target) {
6258 for (var i = 1; i < arguments.length; i++) {
6259 var source = arguments[i];
6260
6261 for (var key in source) {
6262 if (Object.prototype.hasOwnProperty.call(source, key)) {
6263 target[key] = source[key];
6264 }
6265 }
6266 }
6267
6268 return target;
6269};
6270
6271var DEFAULT_OPTIONS = {
6272 container: false,
6273 delay: 0,
6274 html: false,
6275 placement: 'top',
6276 title: '',
6277 template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
6278 trigger: 'hover focus',
6279 offset: 0,
6280 arrowSelector: '.tooltip-arrow, .tooltip__arrow',
6281 innerSelector: '.tooltip-inner, .tooltip__inner'
6282};
6283
6284var Tooltip = function () {
6285 /**
6286 * Create a new Tooltip.js instance
6287 * @class Tooltip
6288 * @param {HTMLElement} reference - The DOM node used as reference of the tooltip (it can be a jQuery element).
6289 * @param {Object} options
6290 * @param {String} options.placement='top'
6291 * Placement of the popper accepted values: `top(-start, -end), right(-start, -end), bottom(-start, -end),
6292 * left(-start, -end)`
6293 * @param {String} options.arrowSelector='.tooltip-arrow, .tooltip__arrow' - className used to locate the DOM arrow element in the tooltip.
6294 * @param {String} options.innerSelector='.tooltip-inner, .tooltip__inner' - className used to locate the DOM inner element in the tooltip.
6295 * @param {HTMLElement|String|false} options.container=false - Append the tooltip to a specific element.
6296 * @param {Number|Object} options.delay=0
6297 * Delay showing and hiding the tooltip (ms) - does not apply to manual trigger type.
6298 * If a number is supplied, delay is applied to both hide/show.
6299 * Object structure is: `{ show: 500, hide: 100 }`
6300 * @param {Boolean} options.html=false - Insert HTML into the tooltip. If false, the content will inserted with `textContent`.
6301 * @param {String} [options.template='<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>']
6302 * Base HTML to used when creating the tooltip.
6303 * The tooltip's `title` will be injected into the `.tooltip-inner` or `.tooltip__inner`.
6304 * `.tooltip-arrow` or `.tooltip__arrow` will become the tooltip's arrow.
6305 * The outermost wrapper element should have the `.tooltip` class.
6306 * @param {String|HTMLElement|TitleFunction} options.title='' - Default title value if `title` attribute isn't present.
6307 * @param {String} [options.trigger='hover focus']
6308 * How tooltip is triggered - click, hover, focus, manual.
6309 * You may pass multiple triggers; separate them with a space. `manual` cannot be combined with any other trigger.
6310 * @param {Boolean} options.closeOnClickOutside=false - Close a popper on click outside of the popper and reference element. This has effect only when options.trigger is 'click'.
6311 * @param {String|HTMLElement} options.boundariesElement
6312 * The element used as boundaries for the tooltip. For more information refer to Popper.js'
6313 * [boundariesElement docs](https://popper.js.org/popper-documentation.html)
6314 * @param {Number|String} options.offset=0 - Offset of the tooltip relative to its reference. For more information refer to Popper.js'
6315 * [offset docs](https://popper.js.org/popper-documentation.html)
6316 * @param {Object} options.popperOptions={} - Popper options, will be passed directly to popper instance. For more information refer to Popper.js'
6317 * [options docs](https://popper.js.org/popper-documentation.html)
6318 * @return {Object} instance - The generated tooltip instance
6319 */
6320 function Tooltip(reference, options) {
6321 classCallCheck$3(this, Tooltip);
6322
6323 _initialiseProps.call(this);
6324
6325 // apply user options over default ones
6326 options = _extends$3({}, DEFAULT_OPTIONS, options);
6327
6328 reference.jquery && (reference = reference[0]);
6329
6330 // cache reference and options
6331 this.reference = reference;
6332 this.options = options;
6333
6334 // get events list
6335 var events = typeof options.trigger === 'string' ? options.trigger.split(' ').filter(function (trigger) {
6336 return ['click', 'hover', 'focus'].indexOf(trigger) !== -1;
6337 }) : [];
6338
6339 // set initial state
6340 this._isOpen = false;
6341 this._popperOptions = {};
6342
6343 // set event listeners
6344 this._setEventListeners(reference, events, options);
6345 }
6346
6347 //
6348 // Public methods
6349 //
6350
6351 /**
6352 * Reveals an element's tooltip. This is considered a "manual" triggering of the tooltip.
6353 * Tooltips with zero-length titles are never displayed.
6354 * @method Tooltip#show
6355 * @memberof Tooltip
6356 */
6357
6358
6359 /**
6360 * Hides an element’s tooltip. This is considered a “manual” triggering of the tooltip.
6361 * @method Tooltip#hide
6362 * @memberof Tooltip
6363 */
6364
6365
6366 /**
6367 * Hides and destroys an element’s tooltip.
6368 * @method Tooltip#dispose
6369 * @memberof Tooltip
6370 */
6371
6372
6373 /**
6374 * Toggles an element’s tooltip. This is considered a “manual” triggering of the tooltip.
6375 * @method Tooltip#toggle
6376 * @memberof Tooltip
6377 */
6378
6379
6380 /**
6381 * Updates the tooltip's title content
6382 * @method Tooltip#updateTitleContent
6383 * @memberof Tooltip
6384 * @param {String|HTMLElement} title - The new content to use for the title
6385 */
6386
6387
6388 //
6389 // Private methods
6390 //
6391
6392 createClass$3(Tooltip, [{
6393 key: '_create',
6394
6395
6396 /**
6397 * Creates a new tooltip node
6398 * @memberof Tooltip
6399 * @private
6400 * @param {HTMLElement} reference
6401 * @param {String} template
6402 * @param {String|HTMLElement|TitleFunction} title
6403 * @param {Boolean} allowHtml
6404 * @return {HTMLElement} tooltipNode
6405 */
6406 value: function _create(reference, template, title, allowHtml) {
6407 // create tooltip element
6408 var tooltipGenerator = window.document.createElement('div');
6409 tooltipGenerator.innerHTML = template.trim();
6410 var tooltipNode = tooltipGenerator.childNodes[0];
6411
6412 // add unique ID to our tooltip (needed for accessibility reasons)
6413 tooltipNode.id = 'tooltip_' + Math.random().toString(36).substr(2, 10);
6414
6415 // set initial `aria-hidden` state to `false` (it's visible!)
6416 tooltipNode.setAttribute('aria-hidden', 'false');
6417
6418 // add title to tooltip
6419 var titleNode = tooltipGenerator.querySelector(this.options.innerSelector);
6420 this._addTitleContent(reference, title, allowHtml, titleNode);
6421
6422 // return the generated tooltip node
6423 return tooltipNode;
6424 }
6425 }, {
6426 key: '_addTitleContent',
6427 value: function _addTitleContent(reference, title, allowHtml, titleNode) {
6428 if (title.nodeType === 1 || title.nodeType === 11) {
6429 // if title is a element node or document fragment, append it only if allowHtml is true
6430 allowHtml && titleNode.appendChild(title);
6431 } else if (isFunction$2(title)) {
6432 // if title is a function, call it and set textContent or innerHtml depending by `allowHtml` value
6433 var titleText = title.call(reference);
6434 allowHtml ? titleNode.innerHTML = titleText : titleNode.textContent = titleText;
6435 } else {
6436 // if it's just a simple text, set textContent or innerHtml depending by `allowHtml` value
6437 allowHtml ? titleNode.innerHTML = title : titleNode.textContent = title;
6438 }
6439 }
6440 }, {
6441 key: '_show',
6442 value: function _show(reference, options) {
6443 // don't show if it's already visible
6444 // or if it's not being showed
6445 if (this._isOpen && !this._isOpening) {
6446 return this;
6447 }
6448 this._isOpen = true;
6449
6450 // if the tooltipNode already exists, just show it
6451 if (this._tooltipNode) {
6452 this._tooltipNode.style.visibility = 'visible';
6453 this._tooltipNode.setAttribute('aria-hidden', 'false');
6454 this.popperInstance.update();
6455 return this;
6456 }
6457
6458 // get title
6459 var title = reference.getAttribute('title') || options.title;
6460
6461 // don't show tooltip if no title is defined
6462 if (!title) {
6463 return this;
6464 }
6465
6466 // create tooltip node
6467 var tooltipNode = this._create(reference, options.template, title, options.html);
6468
6469 // Add `aria-describedby` to our reference element for accessibility reasons
6470 reference.setAttribute('aria-describedby', tooltipNode.id);
6471
6472 // append tooltip to container
6473 var container = this._findContainer(options.container, reference);
6474
6475 this._append(tooltipNode, container);
6476
6477 this._popperOptions = _extends$3({}, options.popperOptions, {
6478 placement: options.placement
6479 });
6480
6481 this._popperOptions.modifiers = _extends$3({}, this._popperOptions.modifiers, {
6482 arrow: {
6483 element: this.options.arrowSelector
6484 },
6485 offset: {
6486 offset: options.offset
6487 }
6488 });
6489
6490 if (options.boundariesElement) {
6491 this._popperOptions.modifiers.preventOverflow = {
6492 boundariesElement: options.boundariesElement
6493 };
6494 }
6495
6496 this.popperInstance = new Popper$1(reference, tooltipNode, this._popperOptions);
6497
6498 this._tooltipNode = tooltipNode;
6499
6500 return this;
6501 }
6502 }, {
6503 key: '_hide',
6504 value: function _hide() /*reference, options*/{
6505 // don't hide if it's already hidden
6506 if (!this._isOpen) {
6507 return this;
6508 }
6509
6510 this._isOpen = false;
6511
6512 // hide tooltipNode
6513 this._tooltipNode.style.visibility = 'hidden';
6514 this._tooltipNode.setAttribute('aria-hidden', 'true');
6515
6516 return this;
6517 }
6518 }, {
6519 key: '_dispose',
6520 value: function _dispose() {
6521 var _this = this;
6522
6523 // remove event listeners first to prevent any unexpected behaviour
6524 this._events.forEach(function (_ref) {
6525 var func = _ref.func,
6526 event = _ref.event;
6527
6528 _this.reference.removeEventListener(event, func);
6529 });
6530 this._events = [];
6531
6532 if (this._tooltipNode) {
6533 this._hide();
6534
6535 // destroy instance
6536 this.popperInstance.destroy();
6537
6538 // destroy tooltipNode if removeOnDestroy is not set, as popperInstance.destroy() already removes the element
6539 if (!this.popperInstance.options.removeOnDestroy) {
6540 this._tooltipNode.parentNode.removeChild(this._tooltipNode);
6541 this._tooltipNode = null;
6542 }
6543 }
6544 return this;
6545 }
6546 }, {
6547 key: '_findContainer',
6548 value: function _findContainer(container, reference) {
6549 // if container is a query, get the relative element
6550 if (typeof container === 'string') {
6551 container = window.document.querySelector(container);
6552 } else if (container === false) {
6553 // if container is `false`, set it to reference parent
6554 container = reference.parentNode;
6555 }
6556 return container;
6557 }
6558
6559 /**
6560 * Append tooltip to container
6561 * @memberof Tooltip
6562 * @private
6563 * @param {HTMLElement} tooltipNode
6564 * @param {HTMLElement|String|false} container
6565 */
6566
6567 }, {
6568 key: '_append',
6569 value: function _append(tooltipNode, container) {
6570 container.appendChild(tooltipNode);
6571 }
6572 }, {
6573 key: '_setEventListeners',
6574 value: function _setEventListeners(reference, events, options) {
6575 var _this2 = this;
6576
6577 var directEvents = [];
6578 var oppositeEvents = [];
6579
6580 events.forEach(function (event) {
6581 switch (event) {
6582 case 'hover':
6583 directEvents.push('mouseenter');
6584 oppositeEvents.push('mouseleave');
6585 break;
6586 case 'focus':
6587 directEvents.push('focus');
6588 oppositeEvents.push('blur');
6589 break;
6590 case 'click':
6591 directEvents.push('click');
6592 oppositeEvents.push('click');
6593 break;
6594 }
6595 });
6596
6597 // schedule show tooltip
6598 directEvents.forEach(function (event) {
6599 var func = function func(evt) {
6600 if (_this2._isOpening === true) {
6601 return;
6602 }
6603 evt.usedByTooltip = true;
6604 _this2._scheduleShow(reference, options.delay, options, evt);
6605 };
6606 _this2._events.push({ event: event, func: func });
6607 reference.addEventListener(event, func);
6608 });
6609
6610 // schedule hide tooltip
6611 oppositeEvents.forEach(function (event) {
6612 var func = function func(evt) {
6613 if (evt.usedByTooltip === true) {
6614 return;
6615 }
6616 _this2._scheduleHide(reference, options.delay, options, evt);
6617 };
6618 _this2._events.push({ event: event, func: func });
6619 reference.addEventListener(event, func);
6620 if (event === 'click' && options.closeOnClickOutside) {
6621 document.addEventListener('mousedown', function (e) {
6622 if (!_this2._isOpening) {
6623 return;
6624 }
6625 var popper = _this2.popperInstance.popper;
6626 if (reference.contains(e.target) || popper.contains(e.target)) {
6627 return;
6628 }
6629 func(e);
6630 }, true);
6631 }
6632 });
6633 }
6634 }, {
6635 key: '_scheduleShow',
6636 value: function _scheduleShow(reference, delay, options /*, evt */) {
6637 var _this3 = this;
6638
6639 this._isOpening = true;
6640 // defaults to 0
6641 var computedDelay = delay && delay.show || delay || 0;
6642 this._showTimeout = window.setTimeout(function () {
6643 return _this3._show(reference, options);
6644 }, computedDelay);
6645 }
6646 }, {
6647 key: '_scheduleHide',
6648 value: function _scheduleHide(reference, delay, options, evt) {
6649 var _this4 = this;
6650
6651 this._isOpening = false;
6652 // defaults to 0
6653 var computedDelay = delay && delay.hide || delay || 0;
6654 window.setTimeout(function () {
6655 window.clearTimeout(_this4._showTimeout);
6656 if (_this4._isOpen === false) {
6657 return;
6658 }
6659 if (!document.body.contains(_this4._tooltipNode)) {
6660 return;
6661 }
6662
6663 // if we are hiding because of a mouseleave, we must check that the new
6664 // reference isn't the tooltip, because in this case we don't want to hide it
6665 if (evt.type === 'mouseleave') {
6666 var isSet = _this4._setTooltipNodeEvent(evt, reference, delay, options);
6667
6668 // if we set the new event, don't hide the tooltip yet
6669 // the new event will take care to hide it if necessary
6670 if (isSet) {
6671 return;
6672 }
6673 }
6674
6675 _this4._hide(reference, options);
6676 }, computedDelay);
6677 }
6678 }, {
6679 key: '_updateTitleContent',
6680 value: function _updateTitleContent(title) {
6681 if (typeof this._tooltipNode === 'undefined') {
6682 if (typeof this.options.title !== 'undefined') {
6683 this.options.title = title;
6684 }
6685 return;
6686 }
6687 var titleNode = this._tooltipNode.parentNode.querySelector(this.options.innerSelector);
6688 this._clearTitleContent(titleNode, this.options.html, this.reference.getAttribute('title') || this.options.title);
6689 this._addTitleContent(this.reference, title, this.options.html, titleNode);
6690 this.options.title = title;
6691 this.popperInstance.update();
6692 }
6693 }, {
6694 key: '_clearTitleContent',
6695 value: function _clearTitleContent(titleNode, allowHtml, lastTitle) {
6696 if (lastTitle.nodeType === 1 || lastTitle.nodeType === 11) {
6697 allowHtml && titleNode.removeChild(lastTitle);
6698 } else {
6699 allowHtml ? titleNode.innerHTML = '' : titleNode.textContent = '';
6700 }
6701 }
6702 }]);
6703 return Tooltip;
6704}();
6705
6706/**
6707 * Title function, its context is the Tooltip instance.
6708 * @memberof Tooltip
6709 * @callback TitleFunction
6710 * @return {String} placement - The desired title.
6711 */
6712
6713
6714var _initialiseProps = function _initialiseProps() {
6715 var _this5 = this;
6716
6717 this.show = function () {
6718 return _this5._show(_this5.reference, _this5.options);
6719 };
6720
6721 this.hide = function () {
6722 return _this5._hide();
6723 };
6724
6725 this.dispose = function () {
6726 return _this5._dispose();
6727 };
6728
6729 this.toggle = function () {
6730 if (_this5._isOpen) {
6731 return _this5.hide();
6732 } else {
6733 return _this5.show();
6734 }
6735 };
6736
6737 this.updateTitleContent = function (title) {
6738 return _this5._updateTitleContent(title);
6739 };
6740
6741 this._events = [];
6742
6743 this._setTooltipNodeEvent = function (evt, reference, delay, options) {
6744 var relatedreference = evt.relatedreference || evt.toElement || evt.relatedTarget;
6745
6746 var callback = function callback(evt2) {
6747 var relatedreference2 = evt2.relatedreference || evt2.toElement || evt2.relatedTarget;
6748
6749 // Remove event listener after call
6750 _this5._tooltipNode.removeEventListener(evt.type, callback);
6751
6752 // If the new reference is not the reference element
6753 if (!reference.contains(relatedreference2)) {
6754 // Schedule to hide tooltip
6755 _this5._scheduleHide(reference, options.delay, options, evt2);
6756 }
6757 };
6758
6759 if (_this5._tooltipNode.contains(relatedreference)) {
6760 // listen to mouseleave on the tooltip element to be able to hide the tooltip
6761 _this5._tooltipNode.addEventListener(evt.type, callback);
6762 return true;
6763 }
6764
6765 return false;
6766 };
6767};
6768
6769var Container = function (_React$Component) {
6770 inherits(Container, _React$Component);
6771
6772 function Container() {
6773 var _ref;
6774
6775 var _temp, _this, _ret;
6776
6777 classCallCheck(this, Container);
6778
6779 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
6780 args[_key] = arguments[_key];
6781 }
6782
6783 return _ret = (_temp = (_this = possibleConstructorReturn(this, (_ref = Container.__proto__ || Object.getPrototypeOf(Container)).call.apply(_ref, [this].concat(args))), _this), _this.boxRef = React.createRef(), _temp), possibleConstructorReturn(_this, _ret);
6784 }
6785
6786 createClass(Container, [{
6787 key: 'componentDidMount',
6788 value: function componentDidMount() {
6789 var dom = ReactDOM.findDOMNode(this.boxRef.current);
6790 console.log('Container findDOMNode Ref', dom);
6791 }
6792 }, {
6793 key: 'render',
6794 value: function render() {
6795 var children = this.props.children;
6796
6797 return React.cloneElement(children, {
6798 ref: this.boxRef
6799 });
6800 }
6801 }]);
6802 return Container;
6803}(React.Component);
6804
6805var Tooltip2 = function (_React$Component2) {
6806 inherits(Tooltip2, _React$Component2);
6807
6808 function Tooltip2() {
6809 var _ref2;
6810
6811 var _temp2, _this2, _ret2;
6812
6813 classCallCheck(this, Tooltip2);
6814
6815 for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
6816 args[_key2] = arguments[_key2];
6817 }
6818
6819 return _ret2 = (_temp2 = (_this2 = possibleConstructorReturn(this, (_ref2 = Tooltip2.__proto__ || Object.getPrototypeOf(Tooltip2)).call.apply(_ref2, [this].concat(args))), _this2), _this2.targetRef = React.createRef(), _temp2), possibleConstructorReturn(_this2, _ret2);
6820 }
6821
6822 createClass(Tooltip2, [{
6823 key: 'componentDidMount',
6824 value: function componentDidMount() {
6825 var _props = this.props,
6826 placement = _props.placement,
6827 trigger = _props.trigger,
6828 content = _props.content;
6829
6830
6831 var target = ReactDOM.findDOMNode(this.targetRef.current);
6832 console.log('componentDidMount', this.targetRef.current, target);
6833 // this.tooltip = new Tooltip(target, {
6834 // placement,
6835 // trigger,
6836 // title: content
6837 // });
6838 }
6839 }, {
6840 key: 'componentDidMount2',
6841 value: function componentDidMount2() {
6842 var _props2 = this.props,
6843 placement = _props2.placement,
6844 trigger = _props2.trigger,
6845 content = _props2.content;
6846
6847
6848 var target = ReactDOM.findDOMNode(this.targetRef);
6849 console.log('componentDidMount', this, target);
6850 this.tooltip = new Tooltip(target, {
6851 placement: placement,
6852 trigger: trigger,
6853 title: content
6854 });
6855 }
6856 }, {
6857 key: 'componentWillUnmount',
6858 value: function componentWillUnmount() {
6859 if (this.tooltip) {
6860 this.tooltip.dispose();
6861 this.tooltip = null;
6862 }
6863 }
6864 }, {
6865 key: 'render',
6866 value: function render() {
6867 var children = this.props.children;
6868
6869 return React.cloneElement(children, {
6870 ref: this.targetRef
6871 });
6872 }
6873 }]);
6874 return Tooltip2;
6875}(React.Component);
6876
6877Tooltip2.defaultProps = {
6878 placement: 'auto',
6879 trigger: 'hover'
6880};
6881
6882export { Box as Button, Image, Divider, Layer, Icon, State, _class as Popover, Container as Tooltip, enhanceStyles, Box, Block, Flex, Grid, Inline, InlineBlock, InlineFlex };
6883//# sourceMappingURL=reactlite.es.js.map