zhxg-element-ui-v3 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +70 -0
  2. package/lib/zhxg-element-ui.css +1 -0
  3. package/lib/zhxg-element-ui.es.js +23680 -0
  4. package/lib/zhxg-element-ui.umd.js +73 -0
  5. package/package.json +59 -0
  6. package/src/App.vue +12 -0
  7. package/src/assets/logo.png +0 -0
  8. package/src/components/HelloWorld.vue +132 -0
  9. package/src/directives/mousewheel.js +23 -0
  10. package/src/directives/repeat-click.js +24 -0
  11. package/src/locale/format.js +45 -0
  12. package/src/locale/index.js +43 -0
  13. package/src/locale/lang/af-ZA.js +116 -0
  14. package/src/locale/lang/ar.js +115 -0
  15. package/src/locale/lang/bg.js +116 -0
  16. package/src/locale/lang/ca.js +115 -0
  17. package/src/locale/lang/cs-CZ.js +118 -0
  18. package/src/locale/lang/da.js +115 -0
  19. package/src/locale/lang/de.js +117 -0
  20. package/src/locale/lang/ee.js +116 -0
  21. package/src/locale/lang/el.js +116 -0
  22. package/src/locale/lang/en.js +116 -0
  23. package/src/locale/lang/eo.js +116 -0
  24. package/src/locale/lang/es.js +115 -0
  25. package/src/locale/lang/eu.js +116 -0
  26. package/src/locale/lang/fa.js +116 -0
  27. package/src/locale/lang/fi.js +116 -0
  28. package/src/locale/lang/fr.js +115 -0
  29. package/src/locale/lang/he.js +116 -0
  30. package/src/locale/lang/hr.js +116 -0
  31. package/src/locale/lang/hu.js +115 -0
  32. package/src/locale/lang/hy-AM.js +116 -0
  33. package/src/locale/lang/id.js +116 -0
  34. package/src/locale/lang/it.js +115 -0
  35. package/src/locale/lang/ja.js +116 -0
  36. package/src/locale/lang/kg.js +116 -0
  37. package/src/locale/lang/km.js +116 -0
  38. package/src/locale/lang/ko.js +116 -0
  39. package/src/locale/lang/ku.js +116 -0
  40. package/src/locale/lang/kz.js +116 -0
  41. package/src/locale/lang/lt.js +116 -0
  42. package/src/locale/lang/lv.js +116 -0
  43. package/src/locale/lang/mn.js +116 -0
  44. package/src/locale/lang/nb-NO.js +115 -0
  45. package/src/locale/lang/nl.js +116 -0
  46. package/src/locale/lang/pl.js +116 -0
  47. package/src/locale/lang/pt-br.js +116 -0
  48. package/src/locale/lang/pt.js +116 -0
  49. package/src/locale/lang/ro.js +116 -0
  50. package/src/locale/lang/ru-RU.js +116 -0
  51. package/src/locale/lang/sk.js +118 -0
  52. package/src/locale/lang/sl.js +116 -0
  53. package/src/locale/lang/sr.js +116 -0
  54. package/src/locale/lang/sv-SE.js +116 -0
  55. package/src/locale/lang/ta.js +115 -0
  56. package/src/locale/lang/th.js +116 -0
  57. package/src/locale/lang/tk.js +116 -0
  58. package/src/locale/lang/tr-TR.js +116 -0
  59. package/src/locale/lang/ua.js +116 -0
  60. package/src/locale/lang/ug-CN.js +116 -0
  61. package/src/locale/lang/uz-UZ.js +116 -0
  62. package/src/locale/lang/vi.js +116 -0
  63. package/src/locale/lang/zh-CN.js +116 -0
  64. package/src/locale/lang/zh-TW.js +116 -0
  65. package/src/main.js +20 -0
  66. package/src/mixins/emitter-bus.js +92 -0
  67. package/src/mixins/emitter.js +68 -0
  68. package/src/mixins/focus.js +9 -0
  69. package/src/mixins/locale.js +9 -0
  70. package/src/mixins/migrating.js +58 -0
  71. package/src/router.js +40 -0
  72. package/src/store.js +7 -0
  73. package/src/theme-chalk/common/var.scss +2 -0
  74. package/src/theme-chalk/fonts/element-icons.ttf +0 -0
  75. package/src/theme-chalk/fonts/element-icons.woff +0 -0
  76. package/src/theme-chalk/fonts/iconfont.eot +0 -0
  77. package/src/theme-chalk/fonts/iconfont.svg +470 -0
  78. package/src/theme-chalk/fonts/iconfont.ttf +0 -0
  79. package/src/theme-chalk/fonts/iconfont.woff +0 -0
  80. package/src/theme-chalk/fonts/iconfont.woff2 +0 -0
  81. package/src/theme-chalk/index.css +16740 -0
  82. package/src/transitions/collapse-transition.js +83 -0
  83. package/src/utils/Blob.js +210 -0
  84. package/src/utils/Export2Excel.js +144 -0
  85. package/src/utils/after-leave.js +27 -0
  86. package/src/utils/aria-dialog.js +95 -0
  87. package/src/utils/aria-utils.js +129 -0
  88. package/src/utils/clickoutside.js +75 -0
  89. package/src/utils/date-util.js +342 -0
  90. package/src/utils/date.js +375 -0
  91. package/src/utils/dom.js +247 -0
  92. package/src/utils/event-bus.js +43 -0
  93. package/src/utils/menu/aria-menubar.js +16 -0
  94. package/src/utils/menu/aria-menuitem.js +50 -0
  95. package/src/utils/menu/aria-submenu.js +59 -0
  96. package/src/utils/merge.js +15 -0
  97. package/src/utils/popper.js +1420 -0
  98. package/src/utils/popup/index.js +234 -0
  99. package/src/utils/popup/popup-manager.js +199 -0
  100. package/src/utils/resize-event.js +38 -0
  101. package/src/utils/scroll-into-view.js +29 -0
  102. package/src/utils/scrollbar-width.js +30 -0
  103. package/src/utils/shared.js +7 -0
  104. package/src/utils/types.js +27 -0
  105. package/src/utils/util.js +246 -0
  106. package/src/utils/vdom.js +9 -0
  107. package/src/utils/vue-popper.js +217 -0
  108. package/src/views/CascaderInfo.vue +71 -0
  109. package/src/views/ComponentTest.vue +361 -0
  110. package/src/views/DarkTheme.vue +209 -0
  111. package/src/views/Home.vue +454 -0
  112. package/src/views/NavTreeDemo.vue +161 -0
  113. package/src/views/SubjectTrees.vue +1498 -0
@@ -0,0 +1,1420 @@
1
+ /**
2
+ * @fileOverview Kickass library to create and place poppers near their reference elements.
3
+ * @version {{version}}
4
+ * @license
5
+ * Copyright (c) 2016 Federico Zivolo and contributors
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ //
27
+ // Cross module loader
28
+ // Supported: Node, AMD, Browser globals
29
+ //
30
+ /* eslint-disable */
31
+ (function(root, factory) {
32
+ if (typeof define === "function" && define.amd) {
33
+ // AMD. Register as an anonymous module.
34
+ define(factory);
35
+ } else if (typeof module === "object" && module.exports) {
36
+ // Node. Does not work with strict CommonJS, but
37
+ // only CommonJS-like environments that support module.exports,
38
+ // like Node.
39
+ module.exports = factory();
40
+ } else {
41
+ // Browser globals (root is window)
42
+ root.Popper = factory();
43
+ }
44
+ })(typeof window !== 'undefined' ? window : {}, function() {
45
+ "use strict";
46
+
47
+ var root = typeof window !== 'undefined' ? window : {};
48
+
49
+ // default options
50
+ var DEFAULTS = {
51
+ // placement of the popper
52
+ placement: "bottom",
53
+
54
+ gpuAcceleration: true,
55
+
56
+ // shift popper from its origin by the given amount of pixels (can be negative)
57
+ offset: 0,
58
+
59
+ // the element which will act as boundary of the popper
60
+ boundariesElement: "viewport",
61
+
62
+ // amount of pixel used to define a minimum distance between the boundaries and the popper
63
+ boundariesPadding: 5,
64
+
65
+ // popper will try to prevent overflow following this order,
66
+ // by default, then, it could overflow on the left and on top of the boundariesElement
67
+ preventOverflowOrder: ["left", "right", "top", "bottom"],
68
+
69
+ // the behavior used by flip to change the placement of the popper
70
+ flipBehavior: "flip",
71
+
72
+ arrowElement: "[x-arrow]",
73
+
74
+ arrowOffset: 0,
75
+
76
+ // list of functions used to modify the offsets before they are applied to the popper
77
+ modifiers: [
78
+ "shift",
79
+ "offset",
80
+ "preventOverflow",
81
+ "keepTogether",
82
+ "arrow",
83
+ "flip",
84
+ "applyStyle"
85
+ ],
86
+
87
+ modifiersIgnored: [],
88
+
89
+ forceAbsolute: false
90
+ };
91
+
92
+ /**
93
+ * Create a new Popper.js instance
94
+ * @constructor Popper
95
+ * @param {HTMLElement} reference - The reference element used to position the popper
96
+ * @param {HTMLElement|Object} popper
97
+ * The HTML element used as popper, or a configuration used to generate the popper.
98
+ * @param {String} [popper.tagName='div'] The tag name of the generated popper.
99
+ * @param {Array} [popper.classNames=['popper']] Array of classes to apply to the generated popper.
100
+ * @param {Array} [popper.attributes] Array of attributes to apply, specify `attr:value` to assign a value to it.
101
+ * @param {HTMLElement|String} [popper.parent=window.document.body] The parent element, given as HTMLElement or as query string.
102
+ * @param {String} [popper.content=''] The content of the popper, it can be text, html, or node; if it is not text, set `contentType` to `html` or `node`.
103
+ * @param {String} [popper.contentType='text'] If `html`, the `content` will be parsed as HTML. If `node`, it will be appended as-is.
104
+ * @param {String} [popper.arrowTagName='div'] Same as `popper.tagName` but for the arrow element.
105
+ * @param {Array} [popper.arrowClassNames='popper__arrow'] Same as `popper.classNames` but for the arrow element.
106
+ * @param {String} [popper.arrowAttributes=['x-arrow']] Same as `popper.attributes` but for the arrow element.
107
+ * @param {Object} options
108
+ * @param {String} [options.placement=bottom]
109
+ * Placement of the popper accepted values: `top(-start, -end), right(-start, -end), bottom(-start, -right),
110
+ * left(-start, -end)`
111
+ *
112
+ * @param {HTMLElement|String} [options.arrowElement='[x-arrow]']
113
+ * The DOM Node used as arrow for the popper, or a CSS selector used to get the DOM node. It must be child of
114
+ * its parent Popper. Popper.js will apply to the given element the style required to align the arrow with its
115
+ * reference element.
116
+ * By default, it will look for a child node of the popper with the `x-arrow` attribute.
117
+ *
118
+ * @param {Boolean} [options.gpuAcceleration=true]
119
+ * When this property is set to true, the popper position will be applied using CSS3 translate3d, allowing the
120
+ * browser to use the GPU to accelerate the rendering.
121
+ * If set to false, the popper will be placed using `top` and `left` properties, not using the GPU.
122
+ *
123
+ * @param {Number} [options.offset=0]
124
+ * Amount of pixels the popper will be shifted (can be negative).
125
+ *
126
+ * @param {String|Element} [options.boundariesElement='viewport']
127
+ * The element which will define the boundaries of the popper position, the popper will never be placed outside
128
+ * of the defined boundaries (except if `keepTogether` is enabled)
129
+ *
130
+ * @param {Number} [options.boundariesPadding=5]
131
+ * Additional padding for the boundaries
132
+ *
133
+ * @param {Array} [options.preventOverflowOrder=['left', 'right', 'top', 'bottom']]
134
+ * Order used when Popper.js tries to avoid overflows from the boundaries, they will be checked in order,
135
+ * this means that the last ones will never overflow
136
+ *
137
+ * @param {String|Array} [options.flipBehavior='flip']
138
+ * The behavior used by the `flip` modifier to change the placement of the popper when the latter is trying to
139
+ * overlap its reference element. Defining `flip` as value, the placement will be flipped on
140
+ * its axis (`right - left`, `top - bottom`).
141
+ * You can even pass an array of placements (eg: `['right', 'left', 'top']` ) to manually specify
142
+ * how alter the placement when a flip is needed. (eg. in the above example, it would first flip from right to left,
143
+ * then, if even in its new placement, the popper is overlapping its reference element, it will be moved to top)
144
+ *
145
+ * @param {Array} [options.modifiers=[ 'shift', 'offset', 'preventOverflow', 'keepTogether', 'arrow', 'flip', 'applyStyle']]
146
+ * List of functions used to modify the data before they are applied to the popper, add your custom functions
147
+ * to this array to edit the offsets and placement.
148
+ * The function should reflect the @params and @returns of preventOverflow
149
+ *
150
+ * @param {Array} [options.modifiersIgnored=[]]
151
+ * Put here any built-in modifier name you want to exclude from the modifiers list
152
+ * The function should reflect the @params and @returns of preventOverflow
153
+ *
154
+ * @param {Boolean} [options.removeOnDestroy=false]
155
+ * Set to true if you want to automatically remove the popper when you call the `destroy` method.
156
+ */
157
+ function Popper(reference, popper, options) {
158
+ this._reference = reference.jquery ? reference[0] : reference;
159
+ this.state = {};
160
+
161
+ // if the popper variable is a configuration object, parse it to generate an HTMLElement
162
+ // generate a default popper if is not defined
163
+ var isNotDefined = typeof popper === "undefined" || popper === null;
164
+ var isConfig =
165
+ popper && Object.prototype.toString.call(popper) === "[object Object]";
166
+ if (isNotDefined || isConfig) {
167
+ this._popper = this.parse(isConfig ? popper : {});
168
+ }
169
+ // otherwise, use the given HTMLElement as popper
170
+ else {
171
+ this._popper = popper.jquery ? popper[0] : popper;
172
+ }
173
+
174
+ // with {} we create a new object with the options inside it
175
+ this._options = Object.assign({}, DEFAULTS, options);
176
+
177
+ // refactoring modifiers' list
178
+ this._options.modifiers = this._options.modifiers.map(
179
+ function(modifier) {
180
+ // remove ignored modifiers
181
+ if (this._options.modifiersIgnored.indexOf(modifier) !== -1) return;
182
+
183
+ // set the x-placement attribute before everything else because it could be used to add margins to the popper
184
+ // margins needs to be calculated to get the correct popper offsets
185
+ if (modifier === "applyStyle") {
186
+ this._popper.setAttribute("x-placement", this._options.placement);
187
+ }
188
+
189
+ // return predefined modifier identified by string or keep the custom one
190
+ return this.modifiers[modifier] || modifier;
191
+ }.bind(this)
192
+ );
193
+
194
+ // make sure to apply the popper position before any computation
195
+ this.state.position = this._getPosition(this._popper, this._reference);
196
+ setStyle(this._popper, { position: this.state.position, top: 0 });
197
+
198
+ // fire the first update to position the popper in the right place
199
+ this.update();
200
+
201
+ // setup event listeners, they will take care of update the position in specific situations
202
+ this._setupEventListeners();
203
+ return this;
204
+ }
205
+
206
+ //
207
+ // Methods
208
+ //
209
+ /**
210
+ * Destroy the popper
211
+ * @method
212
+ * @memberof Popper
213
+ */
214
+ Popper.prototype.destroy = function() {
215
+ this._popper.removeAttribute("x-placement");
216
+ this._popper.style.left = "";
217
+ this._popper.style.position = "";
218
+ this._popper.style.top = "";
219
+ this._popper.style[getSupportedPropertyName("transform")] = "";
220
+ this._removeEventListeners();
221
+
222
+ // remove the popper if user explicity asked for the deletion on destroy
223
+ if (this._options.removeOnDestroy) {
224
+ this._popper.remove();
225
+ }
226
+ return this;
227
+ };
228
+
229
+ /**
230
+ * Updates the position of the popper, computing the new offsets and applying the new style
231
+ * @method
232
+ * @memberof Popper
233
+ */
234
+ Popper.prototype.update = function() {
235
+ var data = { instance: this, styles: {} };
236
+
237
+ // store placement inside the data object, modifiers will be able to edit `placement` if needed
238
+ // and refer to _originalPlacement to know the original value
239
+ data.placement = this._options.placement;
240
+ data._originalPlacement = this._options.placement;
241
+
242
+ // compute the popper and reference offsets and put them inside data.offsets
243
+ data.offsets = this._getOffsets(
244
+ this._popper,
245
+ this._reference,
246
+ data.placement
247
+ );
248
+
249
+ // get boundaries
250
+ data.boundaries = this._getBoundaries(
251
+ data,
252
+ this._options.boundariesPadding,
253
+ this._options.boundariesElement
254
+ );
255
+
256
+ data = this.runModifiers(data, this._options.modifiers);
257
+
258
+ if (typeof this.state.updateCallback === "function") {
259
+ this.state.updateCallback(data);
260
+ }
261
+ };
262
+
263
+ /**
264
+ * If a function is passed, it will be executed after the initialization of popper with as first argument the Popper instance.
265
+ * @method
266
+ * @memberof Popper
267
+ * @param {Function} callback
268
+ */
269
+ Popper.prototype.onCreate = function(callback) {
270
+ // the createCallbacks return as first argument the popper instance
271
+ callback(this);
272
+ return this;
273
+ };
274
+
275
+ /**
276
+ * If a function is passed, it will be executed after each update of popper with as first argument the set of coordinates and informations
277
+ * used to style popper and its arrow.
278
+ * NOTE: it doesn't get fired on the first call of the `Popper.update()` method inside the `Popper` constructor!
279
+ * @method
280
+ * @memberof Popper
281
+ * @param {Function} callback
282
+ */
283
+ Popper.prototype.onUpdate = function(callback) {
284
+ this.state.updateCallback = callback;
285
+ return this;
286
+ };
287
+
288
+ /**
289
+ * Helper used to generate poppers from a configuration file
290
+ * @method
291
+ * @memberof Popper
292
+ * @param config {Object} configuration
293
+ * @returns {HTMLElement} popper
294
+ */
295
+ Popper.prototype.parse = function(config) {
296
+ var defaultConfig = {
297
+ tagName: "div",
298
+ classNames: ["popper"],
299
+ attributes: [],
300
+ parent: root.document.body,
301
+ content: "",
302
+ contentType: "text",
303
+ arrowTagName: "div",
304
+ arrowClassNames: ["popper__arrow"],
305
+ arrowAttributes: ["x-arrow"]
306
+ };
307
+ config = Object.assign({}, defaultConfig, config);
308
+
309
+ var d = root.document;
310
+
311
+ var popper = d.createElement(config.tagName);
312
+ addClassNames(popper, config.classNames);
313
+ addAttributes(popper, config.attributes);
314
+ if (config.contentType === "node") {
315
+ popper.appendChild(
316
+ config.content.jquery ? config.content[0] : config.content
317
+ );
318
+ } else if (config.contentType === "html") {
319
+ popper.innerHTML = config.content;
320
+ } else {
321
+ popper.textContent = config.content;
322
+ }
323
+
324
+ if (config.arrowTagName) {
325
+ var arrow = d.createElement(config.arrowTagName);
326
+ addClassNames(arrow, config.arrowClassNames);
327
+ addAttributes(arrow, config.arrowAttributes);
328
+ popper.appendChild(arrow);
329
+ }
330
+
331
+ var parent = config.parent.jquery ? config.parent[0] : config.parent;
332
+
333
+ // if the given parent is a string, use it to match an element
334
+ // if more than one element is matched, the first one will be used as parent
335
+ // if no elements are matched, the script will throw an error
336
+ if (typeof parent === "string") {
337
+ parent = d.querySelectorAll(config.parent);
338
+ if (parent.length > 1) {
339
+ console.warn(
340
+ "WARNING: the given `parent` query(" +
341
+ config.parent +
342
+ ") matched more than one element, the first one will be used"
343
+ );
344
+ }
345
+ if (parent.length === 0) {
346
+ throw "ERROR: the given `parent` doesn't exists!";
347
+ }
348
+ parent = parent[0];
349
+ }
350
+ // if the given parent is a DOM nodes list or an array of nodes with more than one element,
351
+ // the first one will be used as parent
352
+ if (parent.length > 1 && parent instanceof Element === false) {
353
+ console.warn(
354
+ "WARNING: you have passed as parent a list of elements, the first one will be used"
355
+ );
356
+ parent = parent[0];
357
+ }
358
+
359
+ // append the generated popper to its parent
360
+ parent.appendChild(popper);
361
+
362
+ return popper;
363
+
364
+ /**
365
+ * Adds class names to the given element
366
+ * @function
367
+ * @ignore
368
+ * @param {HTMLElement} target
369
+ * @param {Array} classes
370
+ */
371
+ function addClassNames(element, classNames) {
372
+ classNames.forEach(function(className) {
373
+ element.classList.add(className);
374
+ });
375
+ }
376
+
377
+ /**
378
+ * Adds attributes to the given element
379
+ * @function
380
+ * @ignore
381
+ * @param {HTMLElement} target
382
+ * @param {Array} attributes
383
+ * @example
384
+ * addAttributes(element, [ 'data-info:foobar' ]);
385
+ */
386
+ function addAttributes(element, attributes) {
387
+ attributes.forEach(function(attribute) {
388
+ element.setAttribute(
389
+ attribute.split(":")[0],
390
+ attribute.split(":")[1] || ""
391
+ );
392
+ });
393
+ }
394
+ };
395
+
396
+ /**
397
+ * Helper used to get the position which will be applied to the popper
398
+ * @method
399
+ * @memberof Popper
400
+ * @param config {HTMLElement} popper element
401
+ * @param reference {HTMLElement} reference element
402
+ * @returns {String} position
403
+ */
404
+ Popper.prototype._getPosition = function(popper, reference) {
405
+ var container = getOffsetParent(reference);
406
+
407
+ if (this._options.forceAbsolute) {
408
+ return "absolute";
409
+ }
410
+
411
+ // Decide if the popper will be fixed
412
+ // If the reference element is inside a fixed context, the popper will be fixed as well to allow them to scroll together
413
+ var isParentFixed = isFixed(reference, container);
414
+ return isParentFixed ? "fixed" : "absolute";
415
+ };
416
+
417
+ /**
418
+ * Get offsets to the popper
419
+ * @method
420
+ * @memberof Popper
421
+ * @access private
422
+ * @param {Element} popper - the popper element
423
+ * @param {Element} reference - the reference element (the popper will be relative to this)
424
+ * @returns {Object} An object containing the offsets which will be applied to the popper
425
+ */
426
+ Popper.prototype._getOffsets = function(popper, reference, placement) {
427
+ placement = placement.split("-")[0];
428
+ var popperOffsets = {};
429
+
430
+ popperOffsets.position = this.state.position;
431
+ var isParentFixed = popperOffsets.position === "fixed";
432
+
433
+ //
434
+ // Get reference element position
435
+ //
436
+ var referenceOffsets = getOffsetRectRelativeToCustomParent(
437
+ reference,
438
+ getOffsetParent(popper),
439
+ isParentFixed
440
+ );
441
+
442
+ //
443
+ // Get popper sizes
444
+ //
445
+ var popperRect = getOuterSizes(popper);
446
+
447
+ //
448
+ // Compute offsets of popper
449
+ //
450
+
451
+ // depending by the popper placement we have to compute its offsets slightly differently
452
+ if (["right", "left"].indexOf(placement) !== -1) {
453
+ popperOffsets.top =
454
+ referenceOffsets.top +
455
+ referenceOffsets.height / 2 -
456
+ popperRect.height / 2;
457
+ if (placement === "left") {
458
+ popperOffsets.left = referenceOffsets.left - popperRect.width;
459
+ } else {
460
+ popperOffsets.left = referenceOffsets.right;
461
+ }
462
+ } else {
463
+ popperOffsets.left =
464
+ referenceOffsets.left +
465
+ referenceOffsets.width / 2 -
466
+ popperRect.width / 2;
467
+ if (placement === "top") {
468
+ popperOffsets.top = referenceOffsets.top - popperRect.height;
469
+ } else {
470
+ popperOffsets.top = referenceOffsets.bottom;
471
+ }
472
+ }
473
+
474
+ // Add width and height to our offsets object
475
+ popperOffsets.width = popperRect.width;
476
+ popperOffsets.height = popperRect.height;
477
+
478
+ return {
479
+ popper: popperOffsets,
480
+ reference: referenceOffsets
481
+ };
482
+ };
483
+
484
+ /**
485
+ * Setup needed event listeners used to update the popper position
486
+ * @method
487
+ * @memberof Popper
488
+ * @access private
489
+ */
490
+ Popper.prototype._setupEventListeners = function() {
491
+ // NOTE: 1 DOM access here
492
+ this.state.updateBound = this.update.bind(this);
493
+ root.addEventListener("resize", this.state.updateBound);
494
+ // if the boundariesElement is window we don't need to listen for the scroll event
495
+ if (this._options.boundariesElement !== "window") {
496
+ var target = getScrollParent(this._reference);
497
+ // here it could be both `body` or `documentElement` thanks to Firefox, we then check both
498
+ if (
499
+ target === root.document.body ||
500
+ target === root.document.documentElement
501
+ ) {
502
+ target = root;
503
+ }
504
+ target.addEventListener("scroll", this.state.updateBound);
505
+ this.state.scrollTarget = target;
506
+ }
507
+ };
508
+
509
+ /**
510
+ * Remove event listeners used to update the popper position
511
+ * @method
512
+ * @memberof Popper
513
+ * @access private
514
+ */
515
+ Popper.prototype._removeEventListeners = function() {
516
+ // NOTE: 1 DOM access here
517
+ root.removeEventListener("resize", this.state.updateBound);
518
+ if (
519
+ this._options.boundariesElement !== "window" &&
520
+ this.state.scrollTarget
521
+ ) {
522
+ this.state.scrollTarget.removeEventListener(
523
+ "scroll",
524
+ this.state.updateBound
525
+ );
526
+ this.state.scrollTarget = null;
527
+ }
528
+ this.state.updateBound = null;
529
+ };
530
+
531
+ /**
532
+ * Computed the boundaries limits and return them
533
+ * @method
534
+ * @memberof Popper
535
+ * @access private
536
+ * @param {Object} data - Object containing the property "offsets" generated by `_getOffsets`
537
+ * @param {Number} padding - Boundaries padding
538
+ * @param {Element} boundariesElement - Element used to define the boundaries
539
+ * @returns {Object} Coordinates of the boundaries
540
+ */
541
+ Popper.prototype._getBoundaries = function(data, padding, boundariesElement) {
542
+ // NOTE: 1 DOM access here
543
+ var boundaries = {};
544
+ var width, height;
545
+ if (boundariesElement === "window") {
546
+ var body = root.document.body,
547
+ html = root.document.documentElement;
548
+
549
+ height = Math.max(
550
+ body.scrollHeight,
551
+ body.offsetHeight,
552
+ html.clientHeight,
553
+ html.scrollHeight,
554
+ html.offsetHeight
555
+ );
556
+ width = Math.max(
557
+ body.scrollWidth,
558
+ body.offsetWidth,
559
+ html.clientWidth,
560
+ html.scrollWidth,
561
+ html.offsetWidth
562
+ );
563
+
564
+ boundaries = {
565
+ top: 0,
566
+ right: width,
567
+ bottom: height,
568
+ left: 0
569
+ };
570
+ } else if (boundariesElement === "viewport") {
571
+ var offsetParent = getOffsetParent(this._popper);
572
+ var scrollParent = getScrollParent(this._popper);
573
+ var offsetParentRect = getOffsetRect(offsetParent);
574
+
575
+ // Thanks the fucking native API, `document.body.scrollTop` & `document.documentElement.scrollTop`
576
+ var getScrollTopValue = function(element) {
577
+ return element == document.body
578
+ ? Math.max(
579
+ document.documentElement.scrollTop,
580
+ document.body.scrollTop
581
+ )
582
+ : element.scrollTop;
583
+ };
584
+ var getScrollLeftValue = function(element) {
585
+ return element == document.body
586
+ ? Math.max(
587
+ document.documentElement.scrollLeft,
588
+ document.body.scrollLeft
589
+ )
590
+ : element.scrollLeft;
591
+ };
592
+
593
+ // if the popper is fixed we don't have to substract scrolling from the boundaries
594
+ var scrollTop =
595
+ data.offsets.popper.position === "fixed"
596
+ ? 0
597
+ : getScrollTopValue(scrollParent);
598
+ var scrollLeft =
599
+ data.offsets.popper.position === "fixed"
600
+ ? 0
601
+ : getScrollLeftValue(scrollParent);
602
+
603
+ boundaries = {
604
+ top: 0 - (offsetParentRect.top - scrollTop),
605
+ right:
606
+ root.document.documentElement.clientWidth -
607
+ (offsetParentRect.left - scrollLeft),
608
+ bottom:
609
+ root.document.documentElement.clientHeight -
610
+ (offsetParentRect.top - scrollTop),
611
+ left: 0 - (offsetParentRect.left - scrollLeft)
612
+ };
613
+ } else {
614
+ if (getOffsetParent(this._popper) === boundariesElement) {
615
+ boundaries = {
616
+ top: 0,
617
+ left: 0,
618
+ right: boundariesElement.clientWidth,
619
+ bottom: boundariesElement.clientHeight
620
+ };
621
+ } else {
622
+ boundaries = getOffsetRect(boundariesElement);
623
+ }
624
+ }
625
+ boundaries.left += padding;
626
+ boundaries.right -= padding;
627
+ boundaries.top = boundaries.top + padding;
628
+ boundaries.bottom = boundaries.bottom - padding;
629
+ return boundaries;
630
+ };
631
+
632
+ /**
633
+ * Loop trough the list of modifiers and run them in order, each of them will then edit the data object
634
+ * @method
635
+ * @memberof Popper
636
+ * @access public
637
+ * @param {Object} data
638
+ * @param {Array} modifiers
639
+ * @param {Function} ends
640
+ */
641
+ Popper.prototype.runModifiers = function(data, modifiers, ends) {
642
+ var modifiersToRun = modifiers.slice();
643
+ if (ends !== undefined) {
644
+ modifiersToRun = this._options.modifiers.slice(
645
+ 0,
646
+ getArrayKeyIndex(this._options.modifiers, ends)
647
+ );
648
+ }
649
+
650
+ modifiersToRun.forEach(
651
+ function(modifier) {
652
+ if (isFunction(modifier)) {
653
+ data = modifier.call(this, data);
654
+ }
655
+ }.bind(this)
656
+ );
657
+
658
+ return data;
659
+ };
660
+
661
+ /**
662
+ * Helper used to know if the given modifier depends from another one.
663
+ * @method
664
+ * @memberof Popper
665
+ * @param {String} requesting - name of requesting modifier
666
+ * @param {String} requested - name of requested modifier
667
+ * @returns {Boolean}
668
+ */
669
+ Popper.prototype.isModifierRequired = function(requesting, requested) {
670
+ var index = getArrayKeyIndex(this._options.modifiers, requesting);
671
+ return !!this._options.modifiers.slice(0, index).filter(function(modifier) {
672
+ return modifier === requested;
673
+ }).length;
674
+ };
675
+
676
+ //
677
+ // Modifiers
678
+ //
679
+
680
+ /**
681
+ * Modifiers list
682
+ * @namespace Popper.modifiers
683
+ * @memberof Popper
684
+ * @type {Object}
685
+ */
686
+ Popper.prototype.modifiers = {};
687
+
688
+ /**
689
+ * Apply the computed styles to the popper element
690
+ * @method
691
+ * @memberof Popper.modifiers
692
+ * @argument {Object} data - The data object generated by `update` method
693
+ * @returns {Object} The same data object
694
+ */
695
+ Popper.prototype.modifiers.applyStyle = function(data) {
696
+ // apply the final offsets to the popper
697
+ // NOTE: 1 DOM access here
698
+ var styles = {
699
+ position: data.offsets.popper.position
700
+ };
701
+
702
+ // round top and left to avoid blurry text
703
+ var left = Math.round(data.offsets.popper.left);
704
+ var top = Math.round(data.offsets.popper.top);
705
+
706
+ // if gpuAcceleration is set to true and transform is supported, we use `translate3d` to apply the position to the popper
707
+ // we automatically use the supported prefixed version if needed
708
+ var prefixedProperty;
709
+ if (
710
+ this._options.gpuAcceleration &&
711
+ (prefixedProperty = getSupportedPropertyName("transform"))
712
+ ) {
713
+ styles[prefixedProperty] =
714
+ "translate3d(" + left + "px, " + top + "px, 0)";
715
+ styles.top = 0;
716
+ styles.left = 0;
717
+ }
718
+ // othwerise, we use the standard `left` and `top` properties
719
+ else {
720
+ styles.left = left;
721
+ styles.top = top;
722
+ }
723
+
724
+ // any property present in `data.styles` will be applied to the popper,
725
+ // in this way we can make the 3rd party modifiers add custom styles to it
726
+ // Be aware, modifiers could override the properties defined in the previous
727
+ // lines of this modifier!
728
+ Object.assign(styles, data.styles);
729
+
730
+ setStyle(this._popper, styles);
731
+
732
+ // set an attribute which will be useful to style the tooltip (use it to properly position its arrow)
733
+ // NOTE: 1 DOM access here
734
+ this._popper.setAttribute("x-placement", data.placement);
735
+
736
+ // if the arrow modifier is required and the arrow style has been computed, apply the arrow style
737
+ if (
738
+ this.isModifierRequired(
739
+ this.modifiers.applyStyle,
740
+ this.modifiers.arrow
741
+ ) &&
742
+ data.offsets.arrow
743
+ ) {
744
+ setStyle(data.arrowElement, data.offsets.arrow);
745
+ }
746
+
747
+ return data;
748
+ };
749
+
750
+ /**
751
+ * Modifier used to shift the popper on the start or end of its reference element side
752
+ * @method
753
+ * @memberof Popper.modifiers
754
+ * @argument {Object} data - The data object generated by `update` method
755
+ * @returns {Object} The data object, properly modified
756
+ */
757
+ Popper.prototype.modifiers.shift = function(data) {
758
+ var placement = data.placement;
759
+ var basePlacement = placement.split("-")[0];
760
+ var shiftVariation = placement.split("-")[1];
761
+
762
+ // if shift shiftVariation is specified, run the modifier
763
+ if (shiftVariation) {
764
+ var reference = data.offsets.reference;
765
+ var popper = getPopperClientRect(data.offsets.popper);
766
+
767
+ var shiftOffsets = {
768
+ y: {
769
+ start: { top: reference.top },
770
+ end: { top: reference.top + reference.height - popper.height }
771
+ },
772
+ x: {
773
+ start: { left: reference.left },
774
+ end: { left: reference.left + reference.width - popper.width }
775
+ }
776
+ };
777
+
778
+ var axis = ["bottom", "top"].indexOf(basePlacement) !== -1 ? "x" : "y";
779
+
780
+ data.offsets.popper = Object.assign(
781
+ popper,
782
+ shiftOffsets[axis][shiftVariation]
783
+ );
784
+ }
785
+
786
+ return data;
787
+ };
788
+
789
+ /**
790
+ * Modifier used to make sure the popper does not overflows from it's boundaries
791
+ * @method
792
+ * @memberof Popper.modifiers
793
+ * @argument {Object} data - The data object generated by `update` method
794
+ * @returns {Object} The data object, properly modified
795
+ */
796
+ Popper.prototype.modifiers.preventOverflow = function(data) {
797
+ var order = this._options.preventOverflowOrder;
798
+ var popper = getPopperClientRect(data.offsets.popper);
799
+
800
+ var check = {
801
+ left: function() {
802
+ var left = popper.left;
803
+ if (popper.left < data.boundaries.left) {
804
+ left = Math.max(popper.left, data.boundaries.left);
805
+ }
806
+ return { left: left };
807
+ },
808
+ right: function() {
809
+ var left = popper.left;
810
+ if (popper.right > data.boundaries.right) {
811
+ left = Math.min(popper.left, data.boundaries.right - popper.width);
812
+ }
813
+ return { left: left };
814
+ },
815
+ top: function() {
816
+ var top = popper.top;
817
+ if (popper.top < data.boundaries.top) {
818
+ top = Math.max(popper.top, data.boundaries.top);
819
+ }
820
+ return { top: top };
821
+ },
822
+ bottom: function() {
823
+ var top = popper.top;
824
+ if (popper.bottom > data.boundaries.bottom) {
825
+ top = Math.min(popper.top, data.boundaries.bottom - popper.height);
826
+ }
827
+ return { top: top };
828
+ }
829
+ };
830
+
831
+ order.forEach(function(direction) {
832
+ data.offsets.popper = Object.assign(popper, check[direction]());
833
+ });
834
+
835
+ return data;
836
+ };
837
+
838
+ /**
839
+ * Modifier used to make sure the popper is always near its reference
840
+ * @method
841
+ * @memberof Popper.modifiers
842
+ * @argument {Object} data - The data object generated by _update method
843
+ * @returns {Object} The data object, properly modified
844
+ */
845
+ Popper.prototype.modifiers.keepTogether = function(data) {
846
+ var popper = getPopperClientRect(data.offsets.popper);
847
+ var reference = data.offsets.reference;
848
+ var f = Math.floor;
849
+
850
+ if (popper.right < f(reference.left)) {
851
+ data.offsets.popper.left = f(reference.left) - popper.width;
852
+ }
853
+ if (popper.left > f(reference.right)) {
854
+ data.offsets.popper.left = f(reference.right);
855
+ }
856
+ if (popper.bottom < f(reference.top)) {
857
+ data.offsets.popper.top = f(reference.top) - popper.height;
858
+ }
859
+ if (popper.top > f(reference.bottom)) {
860
+ data.offsets.popper.top = f(reference.bottom);
861
+ }
862
+
863
+ return data;
864
+ };
865
+
866
+ /**
867
+ * Modifier used to flip the placement of the popper when the latter is starting overlapping its reference element.
868
+ * Requires the `preventOverflow` modifier before it in order to work.
869
+ * **NOTE:** This modifier will run all its previous modifiers everytime it tries to flip the popper!
870
+ * @method
871
+ * @memberof Popper.modifiers
872
+ * @argument {Object} data - The data object generated by _update method
873
+ * @returns {Object} The data object, properly modified
874
+ */
875
+ Popper.prototype.modifiers.flip = function(data) {
876
+ // check if preventOverflow is in the list of modifiers before the flip modifier.
877
+ // otherwise flip would not work as expected.
878
+ if (
879
+ !this.isModifierRequired(
880
+ this.modifiers.flip,
881
+ this.modifiers.preventOverflow
882
+ )
883
+ ) {
884
+ console.warn(
885
+ "WARNING: preventOverflow modifier is required by flip modifier in order to work, be sure to include it before flip!"
886
+ );
887
+ return data;
888
+ }
889
+
890
+ if (data.flipped && data.placement === data._originalPlacement) {
891
+ // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
892
+ return data;
893
+ }
894
+
895
+ var placement = data.placement.split("-")[0];
896
+ var placementOpposite = getOppositePlacement(placement);
897
+ var variation = data.placement.split("-")[1] || "";
898
+
899
+ var flipOrder = [];
900
+ if (this._options.flipBehavior === "flip") {
901
+ flipOrder = [placement, placementOpposite];
902
+ } else {
903
+ flipOrder = this._options.flipBehavior;
904
+ }
905
+
906
+ flipOrder.forEach(
907
+ function(step, index) {
908
+ if (placement !== step || flipOrder.length === index + 1) {
909
+ return;
910
+ }
911
+
912
+ placement = data.placement.split("-")[0];
913
+ placementOpposite = getOppositePlacement(placement);
914
+
915
+ var popperOffsets = getPopperClientRect(data.offsets.popper);
916
+
917
+ // this boolean is used to distinguish right and bottom from top and left
918
+ // they need different computations to get flipped
919
+ var a = ["right", "bottom"].indexOf(placement) !== -1;
920
+
921
+ // using Math.floor because the reference offsets may contain decimals we are not going to consider here
922
+ if (
923
+ (a &&
924
+ Math.floor(data.offsets.reference[placement]) >
925
+ Math.floor(popperOffsets[placementOpposite])) ||
926
+ (!a &&
927
+ Math.floor(data.offsets.reference[placement]) <
928
+ Math.floor(popperOffsets[placementOpposite]))
929
+ ) {
930
+ // we'll use this boolean to detect any flip loop
931
+ data.flipped = true;
932
+ data.placement = flipOrder[index + 1];
933
+ if (variation) {
934
+ data.placement += "-" + variation;
935
+ }
936
+ data.offsets.popper = this._getOffsets(
937
+ this._popper,
938
+ this._reference,
939
+ data.placement
940
+ ).popper;
941
+
942
+ data = this.runModifiers(data, this._options.modifiers, this._flip);
943
+ }
944
+ }.bind(this)
945
+ );
946
+ return data;
947
+ };
948
+
949
+ /**
950
+ * Modifier used to add an offset to the popper, useful if you more granularity positioning your popper.
951
+ * The offsets will shift the popper on the side of its reference element.
952
+ * @method
953
+ * @memberof Popper.modifiers
954
+ * @argument {Object} data - The data object generated by _update method
955
+ * @returns {Object} The data object, properly modified
956
+ */
957
+ Popper.prototype.modifiers.offset = function(data) {
958
+ var offset = this._options.offset;
959
+ var popper = data.offsets.popper;
960
+
961
+ if (data.placement.indexOf("left") !== -1) {
962
+ popper.top -= offset;
963
+ } else if (data.placement.indexOf("right") !== -1) {
964
+ popper.top += offset;
965
+ } else if (data.placement.indexOf("top") !== -1) {
966
+ popper.left -= offset;
967
+ } else if (data.placement.indexOf("bottom") !== -1) {
968
+ popper.left += offset;
969
+ }
970
+ return data;
971
+ };
972
+
973
+ /**
974
+ * Modifier used to move the arrows on the edge of the popper to make sure them are always between the popper and the reference element
975
+ * It will use the CSS outer size of the arrow element to know how many pixels of conjuction are needed
976
+ * @method
977
+ * @memberof Popper.modifiers
978
+ * @argument {Object} data - The data object generated by _update method
979
+ * @returns {Object} The data object, properly modified
980
+ */
981
+ Popper.prototype.modifiers.arrow = function(data) {
982
+ var arrow = this._options.arrowElement;
983
+ var arrowOffset = this._options.arrowOffset;
984
+
985
+ // if the arrowElement is a string, suppose it's a CSS selector
986
+ if (typeof arrow === "string") {
987
+ arrow = this._popper.querySelector(arrow);
988
+ }
989
+
990
+ // if arrow element is not found, don't run the modifier
991
+ if (!arrow) {
992
+ return data;
993
+ }
994
+
995
+ // the arrow element must be child of its popper
996
+ if (!this._popper.contains(arrow)) {
997
+ console.warn(
998
+ "WARNING: `arrowElement` must be child of its popper element!"
999
+ );
1000
+ return data;
1001
+ }
1002
+
1003
+ // arrow depends on keepTogether in order to work
1004
+ if (
1005
+ !this.isModifierRequired(
1006
+ this.modifiers.arrow,
1007
+ this.modifiers.keepTogether
1008
+ )
1009
+ ) {
1010
+ console.warn(
1011
+ "WARNING: keepTogether modifier is required by arrow modifier in order to work, be sure to include it before arrow!"
1012
+ );
1013
+ return data;
1014
+ }
1015
+
1016
+ var arrowStyle = {};
1017
+ var placement = data.placement.split("-")[0];
1018
+ var popper = getPopperClientRect(data.offsets.popper);
1019
+ var reference = data.offsets.reference;
1020
+ var isVertical = ["left", "right"].indexOf(placement) !== -1;
1021
+
1022
+ var len = isVertical ? "height" : "width";
1023
+ var side = isVertical ? "top" : "left";
1024
+ var translate = isVertical ? "translateY" : "translateX";
1025
+ var altSide = isVertical ? "left" : "top";
1026
+ var opSide = isVertical ? "bottom" : "right";
1027
+ var arrowSize = getOuterSizes(arrow)[len];
1028
+
1029
+ //
1030
+ // extends keepTogether behavior making sure the popper and its reference have enough pixels in conjuction
1031
+ //
1032
+
1033
+ // top/left side
1034
+ if (reference[opSide] - arrowSize < popper[side]) {
1035
+ data.offsets.popper[side] -=
1036
+ popper[side] - (reference[opSide] - arrowSize);
1037
+ }
1038
+ // bottom/right side
1039
+ if (reference[side] + arrowSize > popper[opSide]) {
1040
+ data.offsets.popper[side] += reference[side] + arrowSize - popper[opSide];
1041
+ }
1042
+
1043
+ // compute center of the popper
1044
+ var center =
1045
+ reference[side] + (arrowOffset || reference[len] / 2 - arrowSize / 2);
1046
+
1047
+ var sideValue = center - popper[side];
1048
+
1049
+ // prevent arrow from being placed not contiguously to its popper
1050
+ sideValue = Math.max(Math.min(popper[len] - arrowSize - 8, sideValue), 8);
1051
+ arrowStyle[side] = sideValue;
1052
+ arrowStyle[altSide] = ""; // make sure to remove any old style from the arrow
1053
+
1054
+ data.offsets.arrow = arrowStyle;
1055
+ data.arrowElement = arrow;
1056
+
1057
+ return data;
1058
+ };
1059
+
1060
+ //
1061
+ // Helpers
1062
+ //
1063
+
1064
+ /**
1065
+ * Get the outer sizes of the given element (offset size + margins)
1066
+ * @function
1067
+ * @ignore
1068
+ * @argument {Element} element
1069
+ * @returns {Object} object containing width and height properties
1070
+ */
1071
+ function getOuterSizes(element) {
1072
+ // NOTE: 1 DOM access here
1073
+ var _display = element.style.display,
1074
+ _visibility = element.style.visibility;
1075
+ element.style.display = "block";
1076
+ element.style.visibility = "hidden";
1077
+ var calcWidthToForceRepaint = element.offsetWidth;
1078
+
1079
+ // original method
1080
+ var styles = root.getComputedStyle(element);
1081
+ var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
1082
+ var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
1083
+ var result = {
1084
+ width: element.offsetWidth + y,
1085
+ height: element.offsetHeight + x
1086
+ };
1087
+
1088
+ // reset element styles
1089
+ element.style.display = _display;
1090
+ element.style.visibility = _visibility;
1091
+ return result;
1092
+ }
1093
+
1094
+ /**
1095
+ * Get the opposite placement of the given one/
1096
+ * @function
1097
+ * @ignore
1098
+ * @argument {String} placement
1099
+ * @returns {String} flipped placement
1100
+ */
1101
+ function getOppositePlacement(placement) {
1102
+ var hash = { left: "right", right: "left", bottom: "top", top: "bottom" };
1103
+ return placement.replace(/left|right|bottom|top/g, function(matched) {
1104
+ return hash[matched];
1105
+ });
1106
+ }
1107
+
1108
+ /**
1109
+ * Given the popper offsets, generate an output similar to getBoundingClientRect
1110
+ * @function
1111
+ * @ignore
1112
+ * @argument {Object} popperOffsets
1113
+ * @returns {Object} ClientRect like output
1114
+ */
1115
+ function getPopperClientRect(popperOffsets) {
1116
+ var offsets = Object.assign({}, popperOffsets);
1117
+ offsets.right = offsets.left + offsets.width;
1118
+ offsets.bottom = offsets.top + offsets.height;
1119
+ return offsets;
1120
+ }
1121
+
1122
+ /**
1123
+ * Given an array and the key to find, returns its index
1124
+ * @function
1125
+ * @ignore
1126
+ * @argument {Array} arr
1127
+ * @argument keyToFind
1128
+ * @returns index or null
1129
+ */
1130
+ function getArrayKeyIndex(arr, keyToFind) {
1131
+ var i = 0,
1132
+ key;
1133
+ for (key in arr) {
1134
+ if (arr[key] === keyToFind) {
1135
+ return i;
1136
+ }
1137
+ i++;
1138
+ }
1139
+ return null;
1140
+ }
1141
+
1142
+ /**
1143
+ * Get CSS computed property of the given element
1144
+ * @function
1145
+ * @ignore
1146
+ * @argument {Eement} element
1147
+ * @argument {String} property
1148
+ */
1149
+ function getStyleComputedProperty(element, property) {
1150
+ // NOTE: 1 DOM access here
1151
+ var css = root.getComputedStyle(element, null);
1152
+ return css[property];
1153
+ }
1154
+
1155
+ /**
1156
+ * Returns the offset parent of the given element
1157
+ * @function
1158
+ * @ignore
1159
+ * @argument {Element} element
1160
+ * @returns {Element} offset parent
1161
+ */
1162
+ function getOffsetParent(element) {
1163
+ // NOTE: 1 DOM access here
1164
+ var offsetParent = element.offsetParent;
1165
+ return offsetParent === root.document.body || !offsetParent
1166
+ ? root.document.documentElement
1167
+ : offsetParent;
1168
+ }
1169
+
1170
+ /**
1171
+ * Returns the scrolling parent of the given element
1172
+ * @function
1173
+ * @ignore
1174
+ * @argument {Element} element
1175
+ * @returns {Element} offset parent
1176
+ */
1177
+ function getScrollParent(element) {
1178
+ var parent = element.parentNode;
1179
+
1180
+ if (!parent) {
1181
+ return element;
1182
+ }
1183
+
1184
+ if (parent === root.document) {
1185
+ // Firefox puts the scrollTOp value on `documentElement` instead of `body`, we then check which of them is
1186
+ // greater than 0 and return the proper element
1187
+ if (root.document.body.scrollTop || root.document.body.scrollLeft) {
1188
+ return root.document.body;
1189
+ } else {
1190
+ return root.document.documentElement;
1191
+ }
1192
+ }
1193
+
1194
+ // Firefox want us to check `-x` and `-y` variations as well
1195
+ if (
1196
+ ["scroll", "auto"].indexOf(
1197
+ getStyleComputedProperty(parent, "overflow")
1198
+ ) !== -1 ||
1199
+ ["scroll", "auto"].indexOf(
1200
+ getStyleComputedProperty(parent, "overflow-x")
1201
+ ) !== -1 ||
1202
+ ["scroll", "auto"].indexOf(
1203
+ getStyleComputedProperty(parent, "overflow-y")
1204
+ ) !== -1
1205
+ ) {
1206
+ // If the detected scrollParent is body, we perform an additional check on its parentNode
1207
+ // in this way we'll get body if the browser is Chrome-ish, or documentElement otherwise
1208
+ // fixes issue #65
1209
+ return parent;
1210
+ }
1211
+ return getScrollParent(element.parentNode);
1212
+ }
1213
+
1214
+ /**
1215
+ * Check if the given element is fixed or is inside a fixed parent
1216
+ * @function
1217
+ * @ignore
1218
+ * @argument {Element} element
1219
+ * @argument {Element} customContainer
1220
+ * @returns {Boolean} answer to "isFixed?"
1221
+ */
1222
+ function isFixed(element) {
1223
+ if (element === root.document.body) {
1224
+ return false;
1225
+ }
1226
+ if (getStyleComputedProperty(element, "position") === "fixed") {
1227
+ return true;
1228
+ }
1229
+ return element.parentNode ? isFixed(element.parentNode) : element;
1230
+ }
1231
+
1232
+ /**
1233
+ * Set the style to the given popper
1234
+ * @function
1235
+ * @ignore
1236
+ * @argument {Element} element - Element to apply the style to
1237
+ * @argument {Object} styles - Object with a list of properties and values which will be applied to the element
1238
+ */
1239
+ function setStyle(element, styles) {
1240
+ function is_numeric(n) {
1241
+ return n !== "" && !isNaN(parseFloat(n)) && isFinite(n);
1242
+ }
1243
+ Object.keys(styles).forEach(function(prop) {
1244
+ var unit = "";
1245
+ // add unit if the value is numeric and is one of the following
1246
+ if (
1247
+ ["width", "height", "top", "right", "bottom", "left"].indexOf(prop) !==
1248
+ -1 &&
1249
+ is_numeric(styles[prop])
1250
+ ) {
1251
+ unit = "px";
1252
+ }
1253
+ element.style[prop] = styles[prop] + unit;
1254
+ });
1255
+ }
1256
+
1257
+ /**
1258
+ * Check if the given variable is a function
1259
+ * @function
1260
+ * @ignore
1261
+ * @argument {*} functionToCheck - variable to check
1262
+ * @returns {Boolean} answer to: is a function?
1263
+ */
1264
+ function isFunction(functionToCheck) {
1265
+ var getType = {};
1266
+ return (
1267
+ functionToCheck &&
1268
+ getType.toString.call(functionToCheck) === "[object Function]"
1269
+ );
1270
+ }
1271
+
1272
+ /**
1273
+ * Get the position of the given element, relative to its offset parent
1274
+ * @function
1275
+ * @ignore
1276
+ * @param {Element} element
1277
+ * @return {Object} position - Coordinates of the element and its `scrollTop`
1278
+ */
1279
+ function getOffsetRect(element) {
1280
+ var elementRect = {
1281
+ width: element.offsetWidth,
1282
+ height: element.offsetHeight,
1283
+ left: element.offsetLeft,
1284
+ top: element.offsetTop
1285
+ };
1286
+
1287
+ elementRect.right = elementRect.left + elementRect.width;
1288
+ elementRect.bottom = elementRect.top + elementRect.height;
1289
+
1290
+ // position
1291
+ return elementRect;
1292
+ }
1293
+
1294
+ /**
1295
+ * Get bounding client rect of given element
1296
+ * @function
1297
+ * @ignore
1298
+ * @param {HTMLElement} element
1299
+ * @return {Object} client rect
1300
+ */
1301
+ function getBoundingClientRect(element) {
1302
+ var rect = element.getBoundingClientRect();
1303
+
1304
+ // whether the IE version is lower than 11
1305
+ var isIE = navigator.userAgent.indexOf("MSIE") != -1;
1306
+
1307
+ // fix ie document bounding top always 0 bug
1308
+ var rectTop =
1309
+ isIE && element.tagName === "HTML" ? -element.scrollTop : rect.top;
1310
+
1311
+ return {
1312
+ left: rect.left,
1313
+ top: rectTop,
1314
+ right: rect.right,
1315
+ bottom: rect.bottom,
1316
+ width: rect.right - rect.left,
1317
+ height: rect.bottom - rectTop
1318
+ };
1319
+ }
1320
+
1321
+ /**
1322
+ * Given an element and one of its parents, return the offset
1323
+ * @function
1324
+ * @ignore
1325
+ * @param {HTMLElement} element
1326
+ * @param {HTMLElement} parent
1327
+ * @return {Object} rect
1328
+ */
1329
+ function getOffsetRectRelativeToCustomParent(element, parent, fixed) {
1330
+ var elementRect = getBoundingClientRect(element);
1331
+ var parentRect = getBoundingClientRect(parent);
1332
+
1333
+ if (fixed) {
1334
+ var scrollParent = getScrollParent(parent);
1335
+ parentRect.top += scrollParent.scrollTop;
1336
+ parentRect.bottom += scrollParent.scrollTop;
1337
+ parentRect.left += scrollParent.scrollLeft;
1338
+ parentRect.right += scrollParent.scrollLeft;
1339
+ }
1340
+
1341
+ var rect = {
1342
+ top: elementRect.top - parentRect.top,
1343
+ left: elementRect.left - parentRect.left,
1344
+ bottom: elementRect.top - parentRect.top + elementRect.height,
1345
+ right: elementRect.left - parentRect.left + elementRect.width,
1346
+ width: elementRect.width,
1347
+ height: elementRect.height
1348
+ };
1349
+ return rect;
1350
+ }
1351
+
1352
+ /**
1353
+ * Get the prefixed supported property name
1354
+ * @function
1355
+ * @ignore
1356
+ * @argument {String} property (camelCase)
1357
+ * @returns {String} prefixed property (camelCase)
1358
+ */
1359
+ function getSupportedPropertyName(property) {
1360
+ var prefixes = ["", "ms", "webkit", "moz", "o"];
1361
+
1362
+ for (var i = 0; i < prefixes.length; i++) {
1363
+ var toCheck = prefixes[i]
1364
+ ? prefixes[i] + property.charAt(0).toUpperCase() + property.slice(1)
1365
+ : property;
1366
+ if (typeof root.document.body.style[toCheck] !== "undefined") {
1367
+ return toCheck;
1368
+ }
1369
+ }
1370
+ return null;
1371
+ }
1372
+
1373
+ /**
1374
+ * The Object.assign() method is used to copy the values of all enumerable own properties from one or more source
1375
+ * objects to a target object. It will return the target object.
1376
+ * This polyfill doesn't support symbol properties, since ES5 doesn't have symbols anyway
1377
+ * Source: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
1378
+ * @function
1379
+ * @ignore
1380
+ */
1381
+ if (!Object.assign) {
1382
+ Object.defineProperty(Object, "assign", {
1383
+ enumerable: false,
1384
+ configurable: true,
1385
+ writable: true,
1386
+ value: function(target) {
1387
+ if (target === undefined || target === null) {
1388
+ throw new TypeError("Cannot convert first argument to object");
1389
+ }
1390
+
1391
+ var to = Object(target);
1392
+ for (var i = 1; i < arguments.length; i++) {
1393
+ var nextSource = arguments[i];
1394
+ if (nextSource === undefined || nextSource === null) {
1395
+ continue;
1396
+ }
1397
+ nextSource = Object(nextSource);
1398
+
1399
+ var keysArray = Object.keys(nextSource);
1400
+ for (
1401
+ var nextIndex = 0, len = keysArray.length;
1402
+ nextIndex < len;
1403
+ nextIndex++
1404
+ ) {
1405
+ var nextKey = keysArray[nextIndex];
1406
+ var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
1407
+ if (desc !== undefined && desc.enumerable) {
1408
+ to[nextKey] = nextSource[nextKey];
1409
+ }
1410
+ }
1411
+ }
1412
+ return to;
1413
+ }
1414
+ });
1415
+ }
1416
+
1417
+ return Popper;
1418
+ });
1419
+
1420
+ export default (typeof module !== 'undefined' && module.exports) || window.Popper;