@opentiny/vue-renderless 3.1.0-alpha.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.
- package/action-sheet/index.js +28 -0
- package/action-sheet/vue.js +29 -0
- package/alert/index.js +23 -0
- package/alert/vue.js +37 -0
- package/autocomplete/index.js +175 -0
- package/autocomplete/vue.js +171 -0
- package/avatar/index.js +29 -0
- package/avatar/vue.js +24 -0
- package/badge/index.js +16 -0
- package/badge/vue.js +30 -0
- package/breadcrumb/vue.js +4 -0
- package/breadcrumb-item/vue.js +24 -0
- package/bulletin-board/index.js +21 -0
- package/bulletin-board/vue.js +36 -0
- package/button/index.js +19 -0
- package/button/vue.js +43 -0
- package/button-group/index.js +25 -0
- package/button-group/vue.js +51 -0
- package/calendar/index.js +279 -0
- package/calendar/vue.js +124 -0
- package/card-template/index.js +39 -0
- package/card-template/vue.js +34 -0
- package/carousel/index.js +206 -0
- package/carousel/vue.js +222 -0
- package/carousel-item/index.js +93 -0
- package/carousel-item/vue.js +57 -0
- package/cascader/index.js +511 -0
- package/cascader/vue.js +342 -0
- package/cascader-menu/index.js +41 -0
- package/cascader-menu/vue.js +36 -0
- package/cascader-node/index.js +63 -0
- package/cascader-node/vue.js +62 -0
- package/cascader-panel/index.js +359 -0
- package/cascader-panel/node.js +199 -0
- package/cascader-panel/store.js +80 -0
- package/cascader-panel/vue.js +217 -0
- package/checkbox/index.js +145 -0
- package/checkbox/vue.js +139 -0
- package/checkbox-button/index.js +102 -0
- package/checkbox-button/vue.js +150 -0
- package/checkbox-group/index.js +12 -0
- package/checkbox-group/vue.js +33 -0
- package/col/index.js +132 -0
- package/col/vue.js +34 -0
- package/collapse/index.js +45 -0
- package/collapse/vue.js +35 -0
- package/collapse-item/index.js +38 -0
- package/collapse-item/vue.js +48 -0
- package/common/array.js +120 -0
- package/common/bigInt.js +352 -0
- package/common/browser.js +69 -0
- package/common/dataset/index.js +135 -0
- package/common/date.js +352 -0
- package/common/decimal.js +203 -0
- package/common/deps/ResizeObserver.js +474 -0
- package/common/deps/after-leave.js +25 -0
- package/common/deps/clickoutside.js +61 -0
- package/common/deps/date-util.js +262 -0
- package/common/deps/date.js +308 -0
- package/common/deps/debounce.js +4 -0
- package/common/deps/dom.js +190 -0
- package/common/deps/fullscreen/apis.js +157 -0
- package/common/deps/fullscreen/screenfull.js +106 -0
- package/common/deps/letter-only.js +15 -0
- package/common/deps/memorize.js +149 -0
- package/common/deps/number-only.js +16 -0
- package/common/deps/popper.js +713 -0
- package/common/deps/popup-manager.js +179 -0
- package/common/deps/repeat-click.js +24 -0
- package/common/deps/requestAnimationFrame.js +25 -0
- package/common/deps/resize-event.js +29 -0
- package/common/deps/scroll-into-view.js +29 -0
- package/common/deps/scrollbar-width.js +25 -0
- package/common/deps/throttle.js +34 -0
- package/common/deps/touch.js +33 -0
- package/common/deps/tree-model/node.js +586 -0
- package/common/deps/tree-model/tree-store.js +377 -0
- package/common/deps/tree-model/util.js +14 -0
- package/common/deps/upload-ajax.js +71 -0
- package/common/deps/vue-emitter.js +30 -0
- package/common/deps/vue-popper.js +291 -0
- package/common/deps/vue-popup.js +211 -0
- package/common/event.js +17 -0
- package/common/index.js +288 -0
- package/common/object.js +228 -0
- package/common/runtime.js +52 -0
- package/common/string.js +446 -0
- package/common/type.js +65 -0
- package/common/validate/index.js +6 -0
- package/common/validate/messages.js +68 -0
- package/common/validate/rules/enum.js +8 -0
- package/common/validate/rules/index.js +14 -0
- package/common/validate/rules/pattern.js +16 -0
- package/common/validate/rules/range.js +62 -0
- package/common/validate/rules/required.js +13 -0
- package/common/validate/rules/type.js +110 -0
- package/common/validate/rules/whitespace.js +6 -0
- package/common/validate/schema.js +323 -0
- package/common/validate/util.js +198 -0
- package/common/validate/validations/array.js +25 -0
- package/common/validate/validations/date.js +35 -0
- package/common/validate/validations/enum.js +24 -0
- package/common/validate/validations/float.js +24 -0
- package/common/validate/validations/index.js +42 -0
- package/common/validate/validations/integer.js +24 -0
- package/common/validate/validations/method.js +23 -0
- package/common/validate/validations/number.js +27 -0
- package/common/validate/validations/pattern.js +23 -0
- package/common/validate/validations/required.js +15 -0
- package/common/validate/validations/string.js +29 -0
- package/common/validate/validations/type.js +25 -0
- package/common/xss.js +325 -0
- package/container/index.js +110 -0
- package/container/vue.js +63 -0
- package/credit-card/index.js +107 -0
- package/credit-card/vue.js +117 -0
- package/credit-card-form/index.js +143 -0
- package/credit-card-form/vue.js +150 -0
- package/crop/index.js +297 -0
- package/crop/vue.js +191 -0
- package/date-panel/index.js +584 -0
- package/date-panel/vue.js +319 -0
- package/date-picker/index.js +301 -0
- package/date-picker/vue.js +169 -0
- package/date-range/index.js +463 -0
- package/date-range/vue.js +297 -0
- package/date-table/index.js +457 -0
- package/date-table/vue.js +151 -0
- package/detail-page/index.js +135 -0
- package/detail-page/vue.js +145 -0
- package/dialog-box/index.js +268 -0
- package/dialog-box/vue.js +226 -0
- package/drop-times/index.js +23 -0
- package/drop-times/vue.js +28 -0
- package/dropdown/index.js +259 -0
- package/dropdown/vue.js +107 -0
- package/dropdown-item/index.js +155 -0
- package/dropdown-item/vue.js +124 -0
- package/dropdown-menu/index.js +148 -0
- package/dropdown-menu/vue.js +44 -0
- package/exception/index.js +13 -0
- package/exception/vue.js +25 -0
- package/fall-menu/index.js +121 -0
- package/fall-menu/vue.js +90 -0
- package/file-upload/index.js +1940 -0
- package/file-upload/vue.js +458 -0
- package/floatbar/index.js +10 -0
- package/floatbar/vue.js +17 -0
- package/form/index.js +186 -0
- package/form/vue.js +69 -0
- package/form-item/index.js +364 -0
- package/form-item/vue.js +210 -0
- package/fullscreen/index.js +138 -0
- package/fullscreen/vue.js +77 -0
- package/grid/core/index.js +3 -0
- package/grid/core/interceptor.js +38 -0
- package/grid/core/storeMap.js +19 -0
- package/grid/plugins/export.js +169 -0
- package/grid/plugins/exportExcel.js +749 -0
- package/grid/plugins/header.js +58 -0
- package/grid/plugins/resize.js +82 -0
- package/grid/static/array/arrayEach.js +12 -0
- package/grid/static/array/arrayIndexOf.js +11 -0
- package/grid/static/array/eachTree.js +32 -0
- package/grid/static/array/every.js +2 -0
- package/grid/static/array/filterTree.js +16 -0
- package/grid/static/array/find.js +3 -0
- package/grid/static/array/findTree.js +46 -0
- package/grid/static/array/helperCreateIterateHandle.js +59 -0
- package/grid/static/array/helperCreateTreeFunc.js +18 -0
- package/grid/static/array/includes.js +5 -0
- package/grid/static/array/lastArrayEach.js +6 -0
- package/grid/static/array/map.js +23 -0
- package/grid/static/array/mapTree.js +33 -0
- package/grid/static/array/slice.js +10 -0
- package/grid/static/array/sortBy.js +69 -0
- package/grid/static/array/sum.js +28 -0
- package/grid/static/array/toArray.js +7 -0
- package/grid/static/array/toTreeArray.js +24 -0
- package/grid/static/base/clear.js +44 -0
- package/grid/static/base/clone.js +18 -0
- package/grid/static/base/destructuring.js +18 -0
- package/grid/static/base/each.js +9 -0
- package/grid/static/base/eqNull.js +6 -0
- package/grid/static/base/findIndexOf.js +10 -0
- package/grid/static/base/get.js +42 -0
- package/grid/static/base/has.js +60 -0
- package/grid/static/base/hasOwnProp.js +4 -0
- package/grid/static/base/helperCreateGetObjects.js +26 -0
- package/grid/static/base/helperCreateInInObjectString.js +7 -0
- package/grid/static/base/helperCreateInTypeof.js +6 -0
- package/grid/static/base/helperCreateIndexOf.js +21 -0
- package/grid/static/base/helperCreateiterateIndexOf.js +21 -0
- package/grid/static/base/helperDefaultCompare.js +4 -0
- package/grid/static/base/helperDeleteProperty.js +8 -0
- package/grid/static/base/helperEqualCompare.js +60 -0
- package/grid/static/base/helperGetHGSKeys.js +4 -0
- package/grid/static/base/indexOf.js +3 -0
- package/grid/static/base/isArray.js +3 -0
- package/grid/static/base/isBoolean.js +4 -0
- package/grid/static/base/isDate.js +3 -0
- package/grid/static/base/isEmpty.js +8 -0
- package/grid/static/base/isEqual.js +11 -0
- package/grid/static/base/isFunction.js +4 -0
- package/grid/static/base/isNaN.js +5 -0
- package/grid/static/base/isNull.js +4 -0
- package/grid/static/base/isNumber.js +4 -0
- package/grid/static/base/isObject.js +5 -0
- package/grid/static/base/isPlainObject.js +2 -0
- package/grid/static/base/isRegExp.js +3 -0
- package/grid/static/base/isSet.js +5 -0
- package/grid/static/base/isString.js +4 -0
- package/grid/static/base/isUndefined.js +4 -0
- package/grid/static/base/keys.js +3 -0
- package/grid/static/base/lastEach.js +9 -0
- package/grid/static/base/remove.js +44 -0
- package/grid/static/base/set.js +43 -0
- package/grid/static/base/toJSONString.js +4 -0
- package/grid/static/base/toStringJSON.js +13 -0
- package/grid/static/base/uniqueId.js +5 -0
- package/grid/static/browse/browse.js +54 -0
- package/grid/static/function/property.js +7 -0
- package/grid/static/function/throttle.js +43 -0
- package/grid/static/index.js +55 -0
- package/grid/static/number/helperCreateToNumber.js +12 -0
- package/grid/static/number/toNumber.js +3 -0
- package/grid/static/object/assign.js +41 -0
- package/grid/static/object/extend.js +3 -0
- package/grid/static/object/lastObjectEach.js +8 -0
- package/grid/static/object/objectEach.js +11 -0
- package/grid/static/object/objectMap.js +20 -0
- package/grid/static/object/values.js +9 -0
- package/grid/static/static/staticDocument.js +4 -0
- package/grid/static/static/staticHGKeyRE.js +2 -0
- package/grid/static/static/staticParseInt.js +2 -0
- package/grid/static/static/staticStrUndefined.js +2 -0
- package/grid/static/static/staticWindow.js +4 -0
- package/grid/static/string/template.js +12 -0
- package/grid/static/string/toString.js +12 -0
- package/grid/utils/column.js +72 -0
- package/grid/utils/common.js +155 -0
- package/grid/utils/dom.js +213 -0
- package/grid/utils/event.js +40 -0
- package/grid/utils/index.js +5 -0
- package/image/index.js +187 -0
- package/image/vue.js +142 -0
- package/image-viewer/index.js +469 -0
- package/image-viewer/vue.js +243 -0
- package/input/index.js +319 -0
- package/input/vue.js +319 -0
- package/ip-address/index.js +370 -0
- package/ip-address/vue.js +185 -0
- package/layout/vue.js +4 -0
- package/link/index.js +10 -0
- package/link/vue.js +26 -0
- package/link-menu/index.js +146 -0
- package/link-menu/vue.js +138 -0
- package/list/index.js +13 -0
- package/list/vue.js +17 -0
- package/loading/index.js +29 -0
- package/loading/vue.js +28 -0
- package/milestone/index.js +92 -0
- package/milestone/vue.js +31 -0
- package/mini-picker/index.js +227 -0
- package/mini-picker/vue.js +142 -0
- package/modal/index.js +866 -0
- package/modal/vue.js +130 -0
- package/month-range/index.js +169 -0
- package/month-range/vue.js +104 -0
- package/month-table/index.js +232 -0
- package/month-table/vue.js +72 -0
- package/nav-menu/index.js +457 -0
- package/nav-menu/vue.js +187 -0
- package/notify/index.js +91 -0
- package/notify/vue.js +67 -0
- package/numeric/index.js +419 -0
- package/numeric/vue.js +218 -0
- package/option/index.js +79 -0
- package/option/vue.js +219 -0
- package/option-group/index.js +18 -0
- package/option-group/vue.js +37 -0
- package/package.json +179 -0
- package/pager-item/index.js +122 -0
- package/pager-item/vue.js +52 -0
- package/panel/index.js +30 -0
- package/panel/vue.js +26 -0
- package/picker/index.js +1039 -0
- package/picker/timezone.js +974 -0
- package/picker/vue.js +415 -0
- package/picker-column/index.js +261 -0
- package/picker-column/vue.js +163 -0
- package/pop-upload/index.js +324 -0
- package/pop-upload/vue.js +292 -0
- package/popeditor/index.js +884 -0
- package/popeditor/vue.js +368 -0
- package/popover/index.js +203 -0
- package/popover/vue.js +174 -0
- package/popup/index.js +139 -0
- package/popup/vue.js +129 -0
- package/progress/index.js +174 -0
- package/progress/vue.js +118 -0
- package/pull-refresh/index.js +104 -0
- package/pull-refresh/vue.js +64 -0
- package/radio/index.js +83 -0
- package/radio/vue.js +99 -0
- package/radio-button/index.js +58 -0
- package/radio-button/vue.js +70 -0
- package/radio-group/index.js +51 -0
- package/radio-group/vue.js +34 -0
- package/rate/index.js +254 -0
- package/rate/vue.js +158 -0
- package/row/index.js +19 -0
- package/row/vue.js +24 -0
- package/scroll-text/index.js +24 -0
- package/scroll-text/vue.js +31 -0
- package/scrollbar/index.js +127 -0
- package/scrollbar/vue-bar.js +49 -0
- package/scrollbar/vue.js +43 -0
- package/search/index.js +110 -0
- package/search/vue.js +110 -0
- package/select/index.js +1766 -0
- package/select/vue.js +693 -0
- package/select-dropdown/index.js +23 -0
- package/select-dropdown/vue.js +122 -0
- package/slide-bar/index.js +94 -0
- package/slide-bar/vue.js +58 -0
- package/slider/index.js +434 -0
- package/slider/vue.js +172 -0
- package/split/index.js +122 -0
- package/split/vue.js +131 -0
- package/steps/vue.js +4 -0
- package/switch/index.js +45 -0
- package/switch/vue.js +62 -0
- package/tab-bar/index.js +51 -0
- package/tab-bar/vue.js +16 -0
- package/tab-dropdown/index.js +11 -0
- package/tab-dropdown/vue.js +17 -0
- package/tab-item/index.js +37 -0
- package/tab-item/vue.js +49 -0
- package/tab-nav/index.js +247 -0
- package/tab-nav/vue.js +106 -0
- package/tabbar/index.js +32 -0
- package/tabbar/vue.js +54 -0
- package/tabbar-item/index.js +55 -0
- package/tabbar-item/vue.js +53 -0
- package/table/index.js +111 -0
- package/table/vue.js +66 -0
- package/tabs/index.js +174 -0
- package/tabs/vue.js +141 -0
- package/tag/index.js +14 -0
- package/tag/vue.js +13 -0
- package/tall-storage/index.js +161 -0
- package/tall-storage/vue-storage-box.js +25 -0
- package/tall-storage/vue.js +38 -0
- package/text-popup/index.js +75 -0
- package/text-popup/vue.js +64 -0
- package/time/index.js +121 -0
- package/time/vue.js +124 -0
- package/time-line/index.js +60 -0
- package/time-line/vue.js +49 -0
- package/time-panel/index.js +189 -0
- package/time-panel/scrollIntoView.js +23 -0
- package/time-panel/vue.js +110 -0
- package/time-range/index.js +199 -0
- package/time-range/vue.js +129 -0
- package/time-spinner/index.js +175 -0
- package/time-spinner/vue.js +122 -0
- package/toggle-menu/index.js +104 -0
- package/toggle-menu/vue.js +74 -0
- package/tooltip/index.js +171 -0
- package/tooltip/vue.js +133 -0
- package/top-box/index.js +81 -0
- package/top-box/vue.js +77 -0
- package/transfer/index.js +296 -0
- package/transfer/vue.js +138 -0
- package/transfer-panel/index.js +364 -0
- package/transfer-panel/vue.js +258 -0
- package/tree/index.js +642 -0
- package/tree/vue.js +268 -0
- package/tree-menu/index.js +124 -0
- package/tree-menu/vue.js +60 -0
- package/tree-node/index.js +271 -0
- package/tree-node/vue.js +211 -0
- package/upload/index.js +324 -0
- package/upload/vue.js +93 -0
- package/upload-dragger/index.js +50 -0
- package/upload-dragger/vue.js +27 -0
- package/upload-list/index.js +55 -0
- package/upload-list/vue.js +48 -0
- package/user-contact/index.js +13 -0
- package/user-contact/vue.js +20 -0
- package/user-head/index.js +71 -0
- package/user-head/vue.js +47 -0
- package/wizard/index.js +123 -0
- package/wizard/vue.js +45 -0
- package/year-table/index.js +40 -0
- package/year-table/vue.js +23 -0
|
@@ -0,0 +1,713 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
+
import { on, off } from '@opentiny/vue-renderless/common/deps/dom';
|
|
8
|
+
import { typeOf } from '@opentiny/vue-renderless/common/type';
|
|
9
|
+
import { xss } from '@opentiny/vue-renderless/common/xss.js';
|
|
10
|
+
var win = window;
|
|
11
|
+
var positions = ['left', 'right', 'top', 'bottom'];
|
|
12
|
+
var modifiers = ['shift', 'offset', 'preventOverflow', 'keepTogether', 'arrow', 'flip', 'applyStyle'];
|
|
13
|
+
var DEFAULTS = {
|
|
14
|
+
arrowOffset: 0,
|
|
15
|
+
arrowElement: '[x-arrow]',
|
|
16
|
+
boundariesElement: 'viewport',
|
|
17
|
+
boundariesPadding: 5,
|
|
18
|
+
flipBehavior: 'flip',
|
|
19
|
+
forceAbsolute: false,
|
|
20
|
+
gpuAcceleration: true,
|
|
21
|
+
offset: 0,
|
|
22
|
+
placement: 'bottom',
|
|
23
|
+
preventOverflowOrder: positions,
|
|
24
|
+
modifiers: modifiers,
|
|
25
|
+
modifiersIgnored: []
|
|
26
|
+
};
|
|
27
|
+
var getRealElement = function getRealElement(el) {
|
|
28
|
+
return el.jquery ? el[0] : el;
|
|
29
|
+
};
|
|
30
|
+
var setStyle = function setStyle(el, styles) {
|
|
31
|
+
var isNumeric = function isNumeric(n) {
|
|
32
|
+
return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
|
|
33
|
+
};
|
|
34
|
+
Object.keys(styles).forEach(function (prop) {
|
|
35
|
+
var unit = '';
|
|
36
|
+
if (~['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) && isNumeric(styles[prop])) {
|
|
37
|
+
unit = 'px';
|
|
38
|
+
}
|
|
39
|
+
el.style[prop] = styles[prop] + unit;
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
var getSupportedPropertyName = function getSupportedPropertyName(property) {
|
|
43
|
+
var prefixes = ['', 'ms', 'webkit', 'moz', 'o'];
|
|
44
|
+
var bodyEl = win.document.body;
|
|
45
|
+
for (var i = 0; i < prefixes.length; i++) {
|
|
46
|
+
var toCheck = prefixes[i] ? prefixes[i] + property.charAt(0).toUpperCase() + property.slice(1) : property;
|
|
47
|
+
if (typeof bodyEl.style[toCheck] !== 'undefined') {
|
|
48
|
+
return toCheck;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
};
|
|
53
|
+
var addClassNames = function addClassNames(el, classNames) {
|
|
54
|
+
classNames.forEach(function (className) {
|
|
55
|
+
el.classList.add(className);
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
var addAttributes = function addAttributes(el, attributes) {
|
|
59
|
+
attributes.forEach(function (attribute) {
|
|
60
|
+
var attrs = attribute.split(':');
|
|
61
|
+
el.setAttribute(attrs[0], attrs[1] || '');
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
var getOffsetParent = function getOffsetParent(el) {
|
|
65
|
+
var offsetParent = el.offsetParent;
|
|
66
|
+
return offsetParent === win.document.body || !offsetParent ? win.document.documentElement : offsetParent;
|
|
67
|
+
};
|
|
68
|
+
var getStyleComputedProperty = function getStyleComputedProperty(el, property) {
|
|
69
|
+
if (!el || el.nodeType !== 1) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
var css = win.getComputedStyle(el, null);
|
|
73
|
+
return css[property];
|
|
74
|
+
};
|
|
75
|
+
var isFixed = function isFixed(el) {
|
|
76
|
+
if (el === win.document.body) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (getStyleComputedProperty(el, 'position') === 'fixed') {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
return el.parentNode ? isFixed(el.parentNode) : el;
|
|
83
|
+
};
|
|
84
|
+
var getBoundingClientRect = function getBoundingClientRect(el) {
|
|
85
|
+
var rectObj = el.getBoundingClientRect();
|
|
86
|
+
var isIE = navigator.userAgent.indexOf('MSIE') != -1;
|
|
87
|
+
var rectTop = isIE && el.tagName === 'HTML' ? -el.scrollTop : rectObj.top;
|
|
88
|
+
return {
|
|
89
|
+
left: rectObj.left,
|
|
90
|
+
top: rectTop,
|
|
91
|
+
right: rectObj.right,
|
|
92
|
+
bottom: rectObj.bottom,
|
|
93
|
+
width: rectObj.right - rectObj.left,
|
|
94
|
+
height: rectObj.bottom - rectTop
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
var isScrollElement = function isScrollElement(parent) {
|
|
98
|
+
var scrollTypes = ['scroll', 'auto'];
|
|
99
|
+
return ~scrollTypes.indexOf(getStyleComputedProperty(parent, 'overflow')) || ~scrollTypes.indexOf(getStyleComputedProperty(parent, 'overflow-x')) || ~scrollTypes.indexOf(getStyleComputedProperty(parent, 'overflow-y'));
|
|
100
|
+
};
|
|
101
|
+
export var getScrollParent = function getScrollParent(el) {
|
|
102
|
+
var parent = el.parentNode;
|
|
103
|
+
if (!parent) {
|
|
104
|
+
return el;
|
|
105
|
+
}
|
|
106
|
+
if (parent === win.document) {
|
|
107
|
+
if (win.document.body.scrollTop || win.document.body.scrollLeft) {
|
|
108
|
+
return win.document.body;
|
|
109
|
+
}
|
|
110
|
+
return win.document.documentElement;
|
|
111
|
+
}
|
|
112
|
+
if (isScrollElement(parent)) {
|
|
113
|
+
return parent;
|
|
114
|
+
}
|
|
115
|
+
return getScrollParent(el.parentNode);
|
|
116
|
+
};
|
|
117
|
+
var getOffsetRectRelativeToCustomParent = function getOffsetRectRelativeToCustomParent(el, parent, fixed) {
|
|
118
|
+
var _getBoundingClientRec = getBoundingClientRect(el),
|
|
119
|
+
top = _getBoundingClientRec.top,
|
|
120
|
+
left = _getBoundingClientRec.left,
|
|
121
|
+
width = _getBoundingClientRec.width,
|
|
122
|
+
height = _getBoundingClientRec.height;
|
|
123
|
+
var parentRect = getBoundingClientRect(parent);
|
|
124
|
+
if (fixed) {
|
|
125
|
+
var _getScrollParent = getScrollParent(parent),
|
|
126
|
+
scrollTop = _getScrollParent.scrollTop,
|
|
127
|
+
scrollLeft = _getScrollParent.scrollLeft;
|
|
128
|
+
parentRect.top += scrollTop;
|
|
129
|
+
parentRect.bottom += scrollTop;
|
|
130
|
+
parentRect.left += scrollLeft;
|
|
131
|
+
parentRect.right += scrollLeft;
|
|
132
|
+
}
|
|
133
|
+
var rect = {
|
|
134
|
+
top: top - parentRect.top,
|
|
135
|
+
left: left - parentRect.left,
|
|
136
|
+
bottom: top - parentRect.top + height,
|
|
137
|
+
right: left - parentRect.left + width,
|
|
138
|
+
width: width,
|
|
139
|
+
height: height
|
|
140
|
+
};
|
|
141
|
+
return rect;
|
|
142
|
+
};
|
|
143
|
+
var getScrollTopValue = function getScrollTopValue(el) {
|
|
144
|
+
return el == document.body ? Math.max(document.documentElement.scrollTop, document.body.scrollTop) : el.scrollTop;
|
|
145
|
+
};
|
|
146
|
+
var getScrollLeftValue = function getScrollLeftValue(el) {
|
|
147
|
+
return el == document.body ? Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) : el.scrollLeft;
|
|
148
|
+
};
|
|
149
|
+
var getMaxWH = function getMaxWH(body, html) {
|
|
150
|
+
var height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
|
|
151
|
+
var width = Math.max(body.scrollWidth, body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth);
|
|
152
|
+
return {
|
|
153
|
+
width: width,
|
|
154
|
+
height: height
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
var adjustArrowStyle = function adjustArrowStyle(arrowStyle, side, arrowRect, popperRect, popperOptions) {
|
|
158
|
+
var params = popperOptions.placement.split('-');
|
|
159
|
+
if (popperOptions.adjustArrow && ~['top', 'bottom'].indexOf(params[0]) && side === 'left') {
|
|
160
|
+
if (params[1] === 'start') {
|
|
161
|
+
arrowStyle.left = 8;
|
|
162
|
+
} else if (!params[1]) {
|
|
163
|
+
arrowStyle.left = (popperRect.width - arrowRect.width) / 2;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return arrowStyle;
|
|
167
|
+
};
|
|
168
|
+
var getOuterSizes = function getOuterSizes(el) {
|
|
169
|
+
var _display = el.style.display,
|
|
170
|
+
_visibility = el.style.visibility;
|
|
171
|
+
el.style.display = 'block';
|
|
172
|
+
el.style.visibility = 'hidden';
|
|
173
|
+
var styles = win.getComputedStyle(el);
|
|
174
|
+
var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
|
|
175
|
+
var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
|
|
176
|
+
var result = {
|
|
177
|
+
width: el.offsetWidth + y,
|
|
178
|
+
height: el.offsetHeight + x
|
|
179
|
+
};
|
|
180
|
+
el.style.display = _display;
|
|
181
|
+
el.style.visibility = _visibility;
|
|
182
|
+
return result;
|
|
183
|
+
};
|
|
184
|
+
var getOppositePlacement = function getOppositePlacement(placement) {
|
|
185
|
+
var hash = {
|
|
186
|
+
left: 'right',
|
|
187
|
+
right: 'left',
|
|
188
|
+
bottom: 'top',
|
|
189
|
+
top: 'bottom'
|
|
190
|
+
};
|
|
191
|
+
return placement.replace(/left|right|bottom|top/g, function (matched) {
|
|
192
|
+
return hash[matched];
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
var getPopperClientRect = function getPopperClientRect(popperOffsets) {
|
|
196
|
+
var offsets = _objectSpread({}, popperOffsets);
|
|
197
|
+
offsets.right = offsets.left + offsets.width;
|
|
198
|
+
offsets.bottom = offsets.top + offsets.height;
|
|
199
|
+
return offsets;
|
|
200
|
+
};
|
|
201
|
+
var getArrayKeyIndex = function getArrayKeyIndex(arr, keyToFind) {
|
|
202
|
+
var i = 0;
|
|
203
|
+
var _iterator = _createForOfIteratorHelper(arr),
|
|
204
|
+
_step;
|
|
205
|
+
try {
|
|
206
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
207
|
+
var value = _step.value;
|
|
208
|
+
if (value === keyToFind) {
|
|
209
|
+
return i;
|
|
210
|
+
}
|
|
211
|
+
i++;
|
|
212
|
+
}
|
|
213
|
+
} catch (err) {
|
|
214
|
+
_iterator.e(err);
|
|
215
|
+
} finally {
|
|
216
|
+
_iterator.f();
|
|
217
|
+
}
|
|
218
|
+
return null;
|
|
219
|
+
};
|
|
220
|
+
export var getAllScrollParents = function getAllScrollParents(el) {
|
|
221
|
+
var parents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
222
|
+
var parent = el.parentNode;
|
|
223
|
+
if (parent) {
|
|
224
|
+
isScrollElement(parent) && parents.push(parent);
|
|
225
|
+
return getAllScrollParents(parent, parents);
|
|
226
|
+
}
|
|
227
|
+
return parents;
|
|
228
|
+
};
|
|
229
|
+
var getOffsetRect = function getOffsetRect(el) {
|
|
230
|
+
var elementRect = {
|
|
231
|
+
width: el.offsetWidth,
|
|
232
|
+
height: el.offsetHeight,
|
|
233
|
+
left: el.offsetLeft,
|
|
234
|
+
top: el.offsetTop
|
|
235
|
+
};
|
|
236
|
+
elementRect.right = elementRect.left + elementRect.width;
|
|
237
|
+
elementRect.bottom = elementRect.top + elementRect.height;
|
|
238
|
+
return elementRect;
|
|
239
|
+
};
|
|
240
|
+
function Popper(reference, popper, options) {
|
|
241
|
+
var _this = this;
|
|
242
|
+
this._reference = getRealElement(reference);
|
|
243
|
+
this.state = {};
|
|
244
|
+
var isNotDefined = typeof popper === 'undefined' || popper === null;
|
|
245
|
+
var isConfig = popper && Object.prototype.toString.call(popper) === '[object Object]';
|
|
246
|
+
if (isNotDefined || isConfig) {
|
|
247
|
+
this._popper = this.parse(isConfig ? popper : {});
|
|
248
|
+
} else {
|
|
249
|
+
this._popper = getRealElement(popper);
|
|
250
|
+
}
|
|
251
|
+
this._options = _objectSpread(_objectSpread({}, DEFAULTS), options);
|
|
252
|
+
this._options.modifiers = this._options.modifiers.map(function (modifier) {
|
|
253
|
+
if (~_this._options.modifiersIgnored.indexOf(modifier)) {
|
|
254
|
+
return undefined;
|
|
255
|
+
}
|
|
256
|
+
if (modifier === 'applyStyle') {
|
|
257
|
+
_this._popper.setAttribute('x-placement', _this._options.placement);
|
|
258
|
+
}
|
|
259
|
+
return _this.modifiers[modifier] || modifier;
|
|
260
|
+
});
|
|
261
|
+
this.state.position = this._getPosition(this._popper, this._reference);
|
|
262
|
+
setStyle(this._popper, {
|
|
263
|
+
position: this.state.position,
|
|
264
|
+
top: 0
|
|
265
|
+
});
|
|
266
|
+
this.update();
|
|
267
|
+
this._setupEventListeners();
|
|
268
|
+
this._oldreference = this._reference;
|
|
269
|
+
this._oldreference._popper = this._popper.style || {};
|
|
270
|
+
return this;
|
|
271
|
+
}
|
|
272
|
+
Popper.prototype.destroy = function () {
|
|
273
|
+
this._popper.removeAttribute('x-placement');
|
|
274
|
+
var popperStyle = this._reference === this._oldreference && this._oldreference._popper || {};
|
|
275
|
+
this._popper.style.position = '';
|
|
276
|
+
this._popper.style.top = popperStyle.top || '';
|
|
277
|
+
this._popper.style.left = popperStyle.left || '';
|
|
278
|
+
this._popper.style[getSupportedPropertyName('transform')] = '';
|
|
279
|
+
this._removeEventListeners();
|
|
280
|
+
this._options.removeOnDestroy && this._popper.remove();
|
|
281
|
+
return this;
|
|
282
|
+
};
|
|
283
|
+
Popper.prototype.onCreate = function (callback) {
|
|
284
|
+
callback(this);
|
|
285
|
+
return this;
|
|
286
|
+
};
|
|
287
|
+
Popper.prototype.onUpdate = function (callback) {
|
|
288
|
+
this.state.updateCallback = callback;
|
|
289
|
+
return this;
|
|
290
|
+
};
|
|
291
|
+
Popper.prototype.update = function () {
|
|
292
|
+
var data = {
|
|
293
|
+
instance: this,
|
|
294
|
+
styles: {}
|
|
295
|
+
};
|
|
296
|
+
data.placement = data._originalPlacement = this._options.placement;
|
|
297
|
+
data.offsets = this._getOffsets(this._popper, this._reference, data.placement);
|
|
298
|
+
data.boundaries = this._getBoundaries(data, this._options.boundariesPadding, this._options.boundariesElement);
|
|
299
|
+
data = this.runModifiers(data, this._options.modifiers);
|
|
300
|
+
typeof this.state.updateCallback === 'function' && this.state.updateCallback(data);
|
|
301
|
+
};
|
|
302
|
+
Popper.prototype.parse = function (config) {
|
|
303
|
+
var defaultConfig = {
|
|
304
|
+
attributes: [],
|
|
305
|
+
arrowTagName: 'div',
|
|
306
|
+
arrowClassNames: ['popper__arrow'],
|
|
307
|
+
arrowAttributes: ['x-arrow'],
|
|
308
|
+
classNames: ['popper'],
|
|
309
|
+
content: '',
|
|
310
|
+
contentType: 'text',
|
|
311
|
+
parent: win.document.body,
|
|
312
|
+
tagName: 'div'
|
|
313
|
+
};
|
|
314
|
+
config = _objectSpread(_objectSpread({}, defaultConfig), config);
|
|
315
|
+
var _config = config,
|
|
316
|
+
tagName = _config.tagName,
|
|
317
|
+
classNames = _config.classNames,
|
|
318
|
+
attributes = _config.attributes,
|
|
319
|
+
contentType = _config.contentType,
|
|
320
|
+
content = _config.content,
|
|
321
|
+
arrowTagName = _config.arrowTagName;
|
|
322
|
+
var docEl = win.document;
|
|
323
|
+
var popper = docEl.createElement(tagName);
|
|
324
|
+
addClassNames(popper, classNames);
|
|
325
|
+
addAttributes(popper, attributes);
|
|
326
|
+
if (contentType === 'node') {
|
|
327
|
+
popper.appendChild(getRealElement(content));
|
|
328
|
+
} else if (contentType === 'html') {
|
|
329
|
+
popper.innerHTML = xss.filterHtml(content);
|
|
330
|
+
} else {
|
|
331
|
+
popper.textContent = content;
|
|
332
|
+
}
|
|
333
|
+
if (arrowTagName) {
|
|
334
|
+
var arrow = docEl.createElement(arrowTagName);
|
|
335
|
+
addClassNames(arrow, config.arrowClassNames);
|
|
336
|
+
addAttributes(arrow, config.arrowAttributes);
|
|
337
|
+
popper.appendChild(arrow);
|
|
338
|
+
}
|
|
339
|
+
var parent = getRealElement(config.parent);
|
|
340
|
+
if (typeof parent === 'string') {
|
|
341
|
+
parent = docEl.querySelectorAll(config.parent);
|
|
342
|
+
if (parent && parent.length) {
|
|
343
|
+
parent = parent[0];
|
|
344
|
+
} else {
|
|
345
|
+
throw new Error('ERROR: the given `parent` does not exists!');
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
if (parent.length > 1 && parent instanceof Element === false) {
|
|
349
|
+
parent = parent[0];
|
|
350
|
+
}
|
|
351
|
+
parent.appendChild(popper);
|
|
352
|
+
return popper;
|
|
353
|
+
};
|
|
354
|
+
Popper.prototype._getPosition = function (popper, reference) {
|
|
355
|
+
var container = getOffsetParent(reference);
|
|
356
|
+
if (this._options.forceAbsolute) {
|
|
357
|
+
return 'absolute';
|
|
358
|
+
}
|
|
359
|
+
var isParentFixed = isFixed(reference, container);
|
|
360
|
+
return isParentFixed ? 'fixed' : 'absolute';
|
|
361
|
+
};
|
|
362
|
+
Popper.prototype._getOffsets = function (popper, reference, placement) {
|
|
363
|
+
placement = placement.split('-')[0];
|
|
364
|
+
var popperOffsets = {};
|
|
365
|
+
popperOffsets.position = this.state.position;
|
|
366
|
+
var isParentFixed = popperOffsets.position === 'fixed';
|
|
367
|
+
var referenceOffsets = getOffsetRectRelativeToCustomParent(reference, getOffsetParent(popper), isParentFixed);
|
|
368
|
+
var _getOuterSizes = getOuterSizes(popper),
|
|
369
|
+
width = _getOuterSizes.width,
|
|
370
|
+
height = _getOuterSizes.height;
|
|
371
|
+
if (~['right', 'left'].indexOf(placement)) {
|
|
372
|
+
popperOffsets.top = referenceOffsets.top + referenceOffsets.height / 2 - height / 2;
|
|
373
|
+
if (placement === 'left') {
|
|
374
|
+
popperOffsets.left = referenceOffsets.left - width;
|
|
375
|
+
} else {
|
|
376
|
+
popperOffsets.left = referenceOffsets.right;
|
|
377
|
+
}
|
|
378
|
+
} else {
|
|
379
|
+
popperOffsets.left = referenceOffsets.left + referenceOffsets.width / 2 - width / 2;
|
|
380
|
+
if (placement === 'top') {
|
|
381
|
+
popperOffsets.top = referenceOffsets.top - height;
|
|
382
|
+
} else {
|
|
383
|
+
popperOffsets.top = referenceOffsets.bottom;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
popperOffsets.width = width;
|
|
387
|
+
popperOffsets.height = height;
|
|
388
|
+
return {
|
|
389
|
+
popper: popperOffsets,
|
|
390
|
+
reference: referenceOffsets
|
|
391
|
+
};
|
|
392
|
+
};
|
|
393
|
+
Popper.prototype._setupEventListeners = function () {
|
|
394
|
+
var _this2 = this;
|
|
395
|
+
this.state.updateBound = this.update.bind(this);
|
|
396
|
+
on(win, 'resize', this.state.updateBound);
|
|
397
|
+
if (this._options.boundariesElement !== 'window') {
|
|
398
|
+
var target = getScrollParent(this._reference);
|
|
399
|
+
if (target === win.document.body || target === win.document.documentElement) {
|
|
400
|
+
target = win;
|
|
401
|
+
}
|
|
402
|
+
if (this._options.bubbling) {
|
|
403
|
+
var targets = getAllScrollParents(this._reference);
|
|
404
|
+
this.state.scrollTargets = targets || [];
|
|
405
|
+
targets.forEach(function (target) {
|
|
406
|
+
on(target, 'scroll', _this2.state.updateBound);
|
|
407
|
+
});
|
|
408
|
+
} else {
|
|
409
|
+
on(target, 'scroll', this.state.updateBound);
|
|
410
|
+
}
|
|
411
|
+
this.state.scrollTarget = target;
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
Popper.prototype._removeEventListeners = function () {
|
|
415
|
+
var _this3 = this;
|
|
416
|
+
off(win, 'resize', this.state.updateBound);
|
|
417
|
+
if (this._options.boundariesElement !== 'window' && this.state.scrollTarget) {
|
|
418
|
+
off(this.state.scrollTarget, 'scroll', this.state.updateBound);
|
|
419
|
+
this.state.scrollTarget = null;
|
|
420
|
+
if (this._options.bubbling) {
|
|
421
|
+
var targets = this.state.scrollTargets || [];
|
|
422
|
+
targets.forEach(function (target) {
|
|
423
|
+
off(target, 'scroll', _this3.state.updateBound);
|
|
424
|
+
});
|
|
425
|
+
this.state.scrollTargets = null;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
this.state.updateBound = null;
|
|
429
|
+
};
|
|
430
|
+
Popper.prototype._getBoundaries = function (data, padding, boundariesElement) {
|
|
431
|
+
var boundaries = {};
|
|
432
|
+
if (boundariesElement === 'window') {
|
|
433
|
+
var body = win.document.body;
|
|
434
|
+
var html = win.document.documentElement;
|
|
435
|
+
var _getMaxWH = getMaxWH(body, html),
|
|
436
|
+
width = _getMaxWH.width,
|
|
437
|
+
height = _getMaxWH.height;
|
|
438
|
+
boundaries = {
|
|
439
|
+
top: 0,
|
|
440
|
+
right: width,
|
|
441
|
+
bottom: height,
|
|
442
|
+
left: 0
|
|
443
|
+
};
|
|
444
|
+
} else if (boundariesElement === 'viewport') {
|
|
445
|
+
var offsetParent = getOffsetParent(this._popper);
|
|
446
|
+
var scrollParent = getScrollParent(this._popper);
|
|
447
|
+
var offsetParentRect = getOffsetRect(offsetParent);
|
|
448
|
+
var _isFixed = data.offsets.popper.position === 'fixed';
|
|
449
|
+
var scrollTop = _isFixed ? 0 : getScrollTopValue(scrollParent);
|
|
450
|
+
var scrollLeft = _isFixed ? 0 : getScrollLeftValue(scrollParent);
|
|
451
|
+
boundaries = {
|
|
452
|
+
top: 0 - (offsetParentRect.top - scrollTop),
|
|
453
|
+
right: win.document.documentElement.clientWidth - (offsetParentRect.left - scrollLeft),
|
|
454
|
+
bottom: win.document.documentElement.clientHeight - (offsetParentRect.top - scrollTop),
|
|
455
|
+
left: 0 - (offsetParentRect.left - scrollLeft)
|
|
456
|
+
};
|
|
457
|
+
} else {
|
|
458
|
+
if (getOffsetParent(this._popper) === boundariesElement) {
|
|
459
|
+
var clientWidth = boundariesElement.clientWidth,
|
|
460
|
+
clientHeight = boundariesElement.clientHeight;
|
|
461
|
+
boundaries = {
|
|
462
|
+
right: clientWidth,
|
|
463
|
+
bottom: clientHeight,
|
|
464
|
+
top: 0,
|
|
465
|
+
left: 0
|
|
466
|
+
};
|
|
467
|
+
} else {
|
|
468
|
+
boundaries = getOffsetRect(boundariesElement);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
boundaries.right -= padding;
|
|
472
|
+
boundaries.left += padding;
|
|
473
|
+
boundaries.bottom = boundaries.bottom - padding;
|
|
474
|
+
boundaries.top = boundaries.top + padding;
|
|
475
|
+
return boundaries;
|
|
476
|
+
};
|
|
477
|
+
Popper.prototype.isModifierRequired = function (requesting, requested) {
|
|
478
|
+
var index = getArrayKeyIndex(this._options.modifiers, requesting);
|
|
479
|
+
return !!this._options.modifiers.slice(0, index).filter(function (modifier) {
|
|
480
|
+
return modifier === requested;
|
|
481
|
+
}).length;
|
|
482
|
+
};
|
|
483
|
+
Popper.prototype.runModifiers = function (data, modifiers, ends) {
|
|
484
|
+
var _this4 = this;
|
|
485
|
+
var modifiersToRun = modifiers.slice();
|
|
486
|
+
var _options = this._options;
|
|
487
|
+
if (ends !== undefined) {
|
|
488
|
+
modifiersToRun = _options.modifiers.slice(0, getArrayKeyIndex(_options.modifiers, ends));
|
|
489
|
+
}
|
|
490
|
+
modifiersToRun.forEach(function (modifier) {
|
|
491
|
+
if (typeOf(modifier) === 'function') {
|
|
492
|
+
data = modifier.call(_this4, data);
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
return data;
|
|
496
|
+
};
|
|
497
|
+
Popper.prototype.modifiers = {};
|
|
498
|
+
Popper.prototype.modifiers.applyStyle = function (data) {
|
|
499
|
+
var styles = {
|
|
500
|
+
position: data.offsets.popper.position
|
|
501
|
+
};
|
|
502
|
+
var left = Math.round(data.offsets.popper.left);
|
|
503
|
+
var top = Math.round(data.offsets.popper.top);
|
|
504
|
+
var prefixedProperty;
|
|
505
|
+
if (this._options.gpuAcceleration && (prefixedProperty = getSupportedPropertyName('transform'))) {
|
|
506
|
+
styles[prefixedProperty] = "translate3d(".concat(left, "px, ").concat(top, "px, 0)");
|
|
507
|
+
Object.assign(styles, {
|
|
508
|
+
top: 0,
|
|
509
|
+
left: 0
|
|
510
|
+
});
|
|
511
|
+
} else {
|
|
512
|
+
Object.assign(styles, {
|
|
513
|
+
top: top,
|
|
514
|
+
left: left
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
Object.assign(styles, data.styles);
|
|
518
|
+
setStyle(this._popper, styles);
|
|
519
|
+
this._popper.setAttribute('x-placement', data.placement);
|
|
520
|
+
var modifiers = this.modifiers;
|
|
521
|
+
if (this.isModifierRequired(modifiers.applyStyle, modifiers.arrow) && data.offsets.arrow) {
|
|
522
|
+
setStyle(data.arrowElement, data.offsets.arrow);
|
|
523
|
+
}
|
|
524
|
+
return data;
|
|
525
|
+
};
|
|
526
|
+
Popper.prototype.modifiers.shift = function (data) {
|
|
527
|
+
var placement = data.placement;
|
|
528
|
+
var basePlacement = placement.split('-')[0];
|
|
529
|
+
var shiftVariation = placement.split('-')[1];
|
|
530
|
+
if (shiftVariation) {
|
|
531
|
+
var _data$offsets$referen = data.offsets.reference,
|
|
532
|
+
top = _data$offsets$referen.top,
|
|
533
|
+
left = _data$offsets$referen.left,
|
|
534
|
+
height = _data$offsets$referen.height,
|
|
535
|
+
width = _data$offsets$referen.width;
|
|
536
|
+
var popper = getPopperClientRect(data.offsets.popper);
|
|
537
|
+
var shiftOffsets = {
|
|
538
|
+
y: {
|
|
539
|
+
start: {
|
|
540
|
+
top: top
|
|
541
|
+
},
|
|
542
|
+
end: {
|
|
543
|
+
top: top + height - popper.height
|
|
544
|
+
}
|
|
545
|
+
},
|
|
546
|
+
x: {
|
|
547
|
+
start: {
|
|
548
|
+
left: left
|
|
549
|
+
},
|
|
550
|
+
end: {
|
|
551
|
+
left: left + width - popper.width
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
var axis = ~['bottom', 'top'].indexOf(basePlacement) ? 'x' : 'y';
|
|
556
|
+
data.offsets.popper = Object.assign(popper, shiftOffsets[axis][shiftVariation]);
|
|
557
|
+
}
|
|
558
|
+
return data;
|
|
559
|
+
};
|
|
560
|
+
Popper.prototype.modifiers.preventOverflow = function (data) {
|
|
561
|
+
var order = this._options.preventOverflowOrder;
|
|
562
|
+
var popper = getPopperClientRect(data.offsets.popper);
|
|
563
|
+
var check = {
|
|
564
|
+
top: function top() {
|
|
565
|
+
var top = popper.top;
|
|
566
|
+
if (top < data.boundaries.top) {
|
|
567
|
+
top = Math.max(top, data.boundaries.top);
|
|
568
|
+
}
|
|
569
|
+
return {
|
|
570
|
+
top: top
|
|
571
|
+
};
|
|
572
|
+
},
|
|
573
|
+
right: function right() {
|
|
574
|
+
var left = popper.left;
|
|
575
|
+
if (popper.right > data.boundaries.right) {
|
|
576
|
+
left = Math.min(left, data.boundaries.right - popper.width);
|
|
577
|
+
}
|
|
578
|
+
return {
|
|
579
|
+
left: left
|
|
580
|
+
};
|
|
581
|
+
},
|
|
582
|
+
bottom: function bottom() {
|
|
583
|
+
var top = popper.top;
|
|
584
|
+
if (popper.bottom > data.boundaries.bottom) {
|
|
585
|
+
top = Math.min(top, data.boundaries.bottom - popper.height);
|
|
586
|
+
}
|
|
587
|
+
return {
|
|
588
|
+
top: top
|
|
589
|
+
};
|
|
590
|
+
},
|
|
591
|
+
left: function left() {
|
|
592
|
+
var left = popper.left;
|
|
593
|
+
if (popper.left < data.boundaries.left) {
|
|
594
|
+
left = Math.max(left, data.boundaries.left);
|
|
595
|
+
}
|
|
596
|
+
return {
|
|
597
|
+
left: left
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
order.forEach(function (direction) {
|
|
602
|
+
data.offsets.popper = Object.assign(popper, check[direction]());
|
|
603
|
+
});
|
|
604
|
+
return data;
|
|
605
|
+
};
|
|
606
|
+
Popper.prototype.modifiers.keepTogether = function (data) {
|
|
607
|
+
var popper = getPopperClientRect(data.offsets.popper);
|
|
608
|
+
var reference = data.offsets.reference;
|
|
609
|
+
if (popper.right < Math.floor(reference.left)) {
|
|
610
|
+
data.offsets.popper.left = Math.floor(reference.left) - popper.width;
|
|
611
|
+
}
|
|
612
|
+
if (popper.left > Math.floor(reference.right)) {
|
|
613
|
+
data.offsets.popper.left = Math.floor(reference.right);
|
|
614
|
+
}
|
|
615
|
+
if (popper.bottom < Math.floor(reference.top)) {
|
|
616
|
+
data.offsets.popper.top = Math.floor(reference.top) - popper.height;
|
|
617
|
+
}
|
|
618
|
+
if (popper.top > Math.floor(reference.bottom)) {
|
|
619
|
+
data.offsets.popper.top = Math.floor(reference.bottom);
|
|
620
|
+
}
|
|
621
|
+
return data;
|
|
622
|
+
};
|
|
623
|
+
Popper.prototype.modifiers.flip = function (data) {
|
|
624
|
+
var _this5 = this;
|
|
625
|
+
if (!this.isModifierRequired(this.modifiers.flip, this.modifiers.preventOverflow)) {
|
|
626
|
+
return data;
|
|
627
|
+
}
|
|
628
|
+
if (data.flipped && data.placement === data._originalPlacement) {
|
|
629
|
+
return data;
|
|
630
|
+
}
|
|
631
|
+
var placements = data.placement.split('-');
|
|
632
|
+
var placement = placements[0];
|
|
633
|
+
var placementOpposite = getOppositePlacement(placement);
|
|
634
|
+
var variation = placements[1] || '';
|
|
635
|
+
var flipOrderArr = [];
|
|
636
|
+
if (this._options.flipBehavior === 'flip') {
|
|
637
|
+
flipOrderArr = [placement, placementOpposite];
|
|
638
|
+
} else {
|
|
639
|
+
flipOrderArr = this._options.flipBehavior;
|
|
640
|
+
}
|
|
641
|
+
flipOrderArr.forEach(function (step, index) {
|
|
642
|
+
if (placement !== step || flipOrderArr.length === index + 1) {
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
placement = data.placement.split('-')[0];
|
|
646
|
+
placementOpposite = getOppositePlacement(placement);
|
|
647
|
+
var popperOffsets = getPopperClientRect(data.offsets.popper);
|
|
648
|
+
var a = ~['right', 'bottom'].indexOf(placement);
|
|
649
|
+
var p = Math.floor(data.offsets.reference[placement]);
|
|
650
|
+
var po = Math.floor(popperOffsets[placementOpposite]);
|
|
651
|
+
if (a && p > po || !a && p < po) {
|
|
652
|
+
data.flipped = true;
|
|
653
|
+
data.placement = flipOrderArr[index + 1];
|
|
654
|
+
if (variation) {
|
|
655
|
+
data.placement += "-".concat(variation);
|
|
656
|
+
}
|
|
657
|
+
data.offsets.popper = _this5._getOffsets(_this5._popper, _this5._reference, data.placement).popper;
|
|
658
|
+
data = _this5.runModifiers(data, _this5._options.modifiers, _this5._flip);
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
return data;
|
|
662
|
+
};
|
|
663
|
+
Popper.prototype.modifiers.offset = function (data) {
|
|
664
|
+
var offset = this._options.offset;
|
|
665
|
+
var popper = data.offsets.popper;
|
|
666
|
+
if (~data.placement.indexOf('left')) {
|
|
667
|
+
popper.top -= offset;
|
|
668
|
+
} else if (~data.placement.indexOf('right')) {
|
|
669
|
+
popper.top += offset;
|
|
670
|
+
} else if (~data.placement.indexOf('top')) {
|
|
671
|
+
popper.left -= offset;
|
|
672
|
+
} else if (~data.placement.indexOf('bottom')) {
|
|
673
|
+
popper.left += offset;
|
|
674
|
+
}
|
|
675
|
+
return data;
|
|
676
|
+
};
|
|
677
|
+
Popper.prototype.modifiers.arrow = function (data) {
|
|
678
|
+
var arrow = this._options.arrowElement;
|
|
679
|
+
var arrowOffset = this._options.arrowOffset;
|
|
680
|
+
if (typeof arrow === 'string') {
|
|
681
|
+
arrow = this._popper.querySelector(arrow);
|
|
682
|
+
}
|
|
683
|
+
if (!arrow || !this._popper.contains(arrow) || !this.isModifierRequired(this.modifiers.arrow, this.modifiers.keepTogether)) {
|
|
684
|
+
return data;
|
|
685
|
+
}
|
|
686
|
+
var arrowStyle = {};
|
|
687
|
+
var placement = data.placement.split('-')[0];
|
|
688
|
+
var popper = getPopperClientRect(data.offsets.popper);
|
|
689
|
+
var reference = data.offsets.reference;
|
|
690
|
+
var isVertical = ~['left', 'right'].indexOf(placement);
|
|
691
|
+
var len = isVertical ? 'height' : 'width';
|
|
692
|
+
var opSide = isVertical ? 'bottom' : 'right';
|
|
693
|
+
var altSide = isVertical ? 'left' : 'top';
|
|
694
|
+
var side = isVertical ? 'top' : 'left';
|
|
695
|
+
var popperRect = getOuterSizes(this._popper);
|
|
696
|
+
var arrowRect = getOuterSizes(arrow);
|
|
697
|
+
var arrowSize = arrowRect[len];
|
|
698
|
+
if (reference[opSide] - arrowSize < popper[side]) {
|
|
699
|
+
data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowSize);
|
|
700
|
+
}
|
|
701
|
+
if (reference[side] + arrowSize > popper[opSide]) {
|
|
702
|
+
data.offsets.popper[side] += reference[side] + arrowSize - popper[opSide];
|
|
703
|
+
}
|
|
704
|
+
var center = reference[side] + (arrowOffset || reference[len] / 2 - arrowSize / 2);
|
|
705
|
+
var sideValue = center - popper[side];
|
|
706
|
+
sideValue = Math.max(Math.min(popper[len] - arrowSize - 8, sideValue), 8);
|
|
707
|
+
arrowStyle[side] = sideValue;
|
|
708
|
+
arrowStyle[altSide] = '';
|
|
709
|
+
data.offsets.arrow = adjustArrowStyle(arrowStyle, side, arrowRect, popperRect, this._options);
|
|
710
|
+
data.arrowElement = arrow;
|
|
711
|
+
return data;
|
|
712
|
+
};
|
|
713
|
+
export default Popper;
|