UNPKG

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