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