@mdsfe/mds-ui 0.2.0 → 0.2.9-rc.1

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