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