eoss 0.1.0-alpha.39 → 0.1.0-alpha.40
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/lib/0.js +1 -1
- package/lib/1.js +1 -1
- package/lib/10.js +1 -1
- package/lib/11.js +1 -1
- package/lib/12.js +1 -1
- package/lib/13.js +1 -1
- package/lib/14.js +1 -1
- package/lib/15.js +1 -1
- package/lib/16.js +1 -1
- package/lib/17.js +1 -1
- package/lib/18.js +1 -1
- package/lib/19.js +1 -1
- package/lib/20.js +1 -1
- package/lib/21.js +1 -1
- package/lib/22.js +1 -1
- package/lib/23.js +1 -1
- package/lib/24.js +1 -1
- package/lib/25.js +1 -1
- package/lib/26.js +1 -1
- package/lib/27.js +1 -1
- package/lib/28.js +1 -1
- package/lib/29.js +1 -1
- package/lib/3.js +1 -1
- package/lib/30.js +1 -1
- package/lib/31.js +1 -1
- package/lib/32.js +1 -1
- package/lib/33.js +1 -1
- package/lib/34.js +1 -1
- package/lib/35.js +1 -1
- package/lib/36.js +1 -1
- package/lib/37.js +1 -1
- package/lib/38.js +1 -1
- package/lib/39.js +1 -1
- package/lib/4.js +1 -1
- package/lib/40.js +1 -1
- package/lib/41.js +1 -1
- package/lib/42.js +1 -1
- package/lib/43.js +1 -1
- package/lib/44.js +1 -1
- package/lib/45.js +1 -1
- package/lib/46.js +1 -1
- package/lib/47.js +1 -1
- package/lib/48.js +1 -1
- package/lib/49.js +1 -1
- package/lib/5.js +1 -1
- package/lib/50.js +1 -1
- package/lib/51.js +1 -1
- package/lib/52.js +1 -1
- package/lib/53.js +1 -1
- package/lib/54.js +1 -1
- package/lib/55.js +1 -1
- package/lib/56.js +1 -1
- package/lib/57.js +1 -1
- package/lib/58.js +1 -1
- package/lib/59.js +1 -1
- package/lib/6.js +1 -1
- package/lib/60.js +1 -1
- package/lib/61.js +1 -1
- package/lib/62.js +1 -1
- package/lib/63.js +1 -1
- package/lib/64.js +1 -1
- package/lib/65.js +1 -1
- package/lib/66.js +1 -1
- package/lib/67.js +1 -1
- package/lib/68.js +1 -1
- package/lib/69.js +1 -1
- package/lib/7.js +1 -1
- package/lib/70.js +1 -1
- package/lib/71.js +1 -1
- package/lib/72.js +1 -1
- package/lib/73.js +1 -1
- package/lib/74.js +1 -1
- package/lib/75.js +1 -1
- package/lib/76.js +1 -1
- package/lib/77.js +1 -1
- package/lib/78.js +1 -1
- package/lib/79.js +1 -1
- package/lib/8.js +1 -1
- package/lib/80.js +1 -1
- package/lib/81.js +1 -1
- package/lib/9.js +1 -1
- package/lib/account-login.js +837 -862
- package/lib/alert.js +2 -2
- package/lib/aside.js +2 -2
- package/lib/audit-trajectory.js +4 -4
- package/lib/autocomplete.js +1813 -1988
- package/lib/avatar.js +2 -2
- package/lib/backtop.js +2 -2
- package/lib/badge.js +2 -2
- package/lib/breadcrumb-item.js +4 -4
- package/lib/breadcrumb.js +4 -4
- package/lib/button-group.js +4 -4
- package/lib/button.js +2 -2
- package/lib/ca-login.js +837 -862
- package/lib/calendar.js +839 -864
- package/lib/card.js +2 -2
- package/lib/carousel-item.js +846 -871
- package/lib/carousel.js +839 -864
- package/lib/cascader-panel.js +852 -877
- package/lib/cascader.js +2048 -2223
- package/lib/checkbox-button.js +4 -4
- package/lib/checkbox-group.js +859 -884
- package/lib/checkbox.js +4 -4
- package/lib/col.js +2 -2
- package/lib/collapse-item.js +1040 -1065
- package/lib/collapse.js +1040 -1065
- package/lib/color-picker.js +972 -1122
- package/lib/container.js +2 -2
- package/lib/cron.js +12 -12
- package/lib/data-table.js +843 -868
- package/lib/date-picker.js +10520 -10695
- package/lib/descriptions-item.js +4 -4
- package/lib/descriptions.js +4 -4
- package/lib/dialog.js +837 -862
- package/lib/divider.js +2 -2
- package/lib/drawer.js +2 -2
- package/lib/dropdown-item.js +4 -4
- package/lib/dropdown-menu.js +974 -1124
- package/lib/dropdown.js +841 -866
- package/lib/email-login.js +837 -862
- package/lib/empty.js +2 -2
- package/lib/eoss.common.js +4023 -2668
- package/lib/flip.js +2 -2
- package/lib/flow-group.js +853 -878
- package/lib/flow.js +868 -893
- package/lib/flows.js +854 -879
- package/lib/footer.js +2 -2
- package/lib/form-item.js +860 -885
- package/lib/form.js +933 -950
- package/lib/guide.js +2 -2
- package/lib/header.js +2 -2
- package/lib/icon.js +837 -862
- package/lib/icons.js +2 -2
- package/lib/image-viewer.js +837 -862
- package/lib/image.js +4 -4
- package/lib/index.js +1 -1
- package/lib/infinite-scroll.js +2 -2
- package/lib/input-number.js +6 -6
- package/lib/input.js +839 -864
- package/lib/link.js +2 -2
- package/lib/loading.js +2 -2
- package/lib/login.js +867 -891
- package/lib/lowcode-view.js +1843 -1185
- package/lib/lowcode.js +3050 -1569
- package/lib/main.js +970 -988
- package/lib/marquee.js +837 -862
- package/lib/menu-item-group.js +15 -15
- package/lib/menu-item.js +6 -6
- package/lib/menu.js +2227 -2368
- package/lib/message-box.js +843 -868
- package/lib/message.js +839 -864
- package/lib/notification.js +861 -886
- package/lib/option-group.js +4 -4
- package/lib/option.js +839 -864
- package/lib/page-header.js +2 -2
- package/lib/pagination.js +839 -864
- package/lib/phone-login.js +847 -866
- package/lib/popconfirm.js +4 -4
- package/lib/popover.js +1831 -2006
- package/lib/process-config.js +839 -864
- package/lib/process-module.js +846 -871
- package/lib/process-rule.js +905 -930
- package/lib/progress.js +2 -2
- package/lib/qr-code.js +4 -4
- package/lib/qrcode-login.js +839 -864
- package/lib/radio-button.js +4 -4
- package/lib/radio-group.js +850 -875
- package/lib/radio.js +4 -4
- package/lib/rate.js +837 -862
- package/lib/retrial-auth.js +837 -862
- package/lib/row.js +2 -2
- package/lib/scrollbar.js +839 -864
- package/lib/select.js +2139 -2314
- package/lib/selector-panel.js +940 -965
- package/lib/selector.js +852 -877
- package/lib/slider.js +4 -4
- package/lib/step.js +32 -32
- package/lib/steps.js +874 -899
- package/lib/submenu.js +1269 -1385
- package/lib/switch.js +839 -864
- package/lib/tab-pane.js +4 -4
- package/lib/table-column.js +840 -865
- package/lib/table.js +1825 -2000
- package/lib/tabs.js +846 -871
- package/lib/tag.js +2 -2
- package/lib/theme-chalk/fonts/iconfont.ttf +0 -0
- package/lib/theme-chalk/fonts/iconfont.woff +0 -0
- package/lib/theme-chalk/index.css +1 -1
- package/lib/theme-chalk/lowcode.css +1 -1
- package/lib/time-picker.js +6471 -6646
- package/lib/time-select.js +5039 -5214
- package/lib/timeline-item.js +2 -2
- package/lib/timeline.js +2 -2
- package/lib/tips.js +837 -862
- package/lib/toolbar.js +4 -4
- package/lib/tooltip.js +1813 -1988
- package/lib/transfer.js +837 -862
- package/lib/tree-group.js +853 -878
- package/lib/tree.js +1026 -1051
- package/lib/update-history.js +4 -4
- package/lib/upload.js +859 -884
- package/lib/wujie.js +841 -866
- package/package.json +1 -1
- package/packages/flow-group/src/main.vue +2 -2
- package/packages/form/src/form-item-render.vue +1 -0
- package/packages/form/src/form-item.vue +12 -6
- package/packages/form/src/form.vue +5 -5
- package/packages/login/src/login.vue +1 -0
- package/packages/lowcode/src/attribute/function.vue +28 -9
- package/packages/lowcode/src/attribute/props.vue +202 -0
- package/packages/lowcode/src/attribute/styles.vue +79 -5
- package/packages/lowcode/src/attribute.vue +61 -4
- package/packages/lowcode/src/canvas.vue +159 -2
- package/packages/lowcode/src/form-render.vue +305 -0
- package/packages/lowcode/src/lowcode.vue +33 -13
- package/packages/lowcode/src/modules.vue +53 -37
- package/packages/lowcode/src/render.vue +80 -25
- package/packages/lowcode/src/util/components.js +100 -0
- package/packages/lowcode/src/util/props-util.js +67 -0
- package/packages/lowcode/src/util/source-generator.js +69 -9
- package/packages/lowcode/src/util/source-parser.js +64 -10
- package/packages/lowcode-view/src/render.vue +48 -18
- package/packages/main/src/components/userinfo.vue +0 -1
- package/packages/menu/src/menu-item-group.vue +1 -1
- package/packages/menu/src/mixins.js +8 -4
- package/packages/menu/src/submenu.vue +35 -5
- package/packages/phone-login/src/phone-login.vue +5 -2
- package/packages/theme-chalk/dist/fonts/iconfont.ttf +0 -0
- package/packages/theme-chalk/dist/fonts/iconfont.woff +0 -0
- package/packages/theme-chalk/src/fonts/iconfont.ttf +0 -0
- package/packages/theme-chalk/src/fonts/iconfont.woff +0 -0
- package/packages/theme-chalk/src/lowcode.scss +21 -2
- package/src/index.js +336 -336
package/lib/popover.js
CHANGED
|
@@ -82,7 +82,7 @@ module.exports =
|
|
|
82
82
|
/******/
|
|
83
83
|
/******/
|
|
84
84
|
/******/ // Load entry module and return exports
|
|
85
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
|
85
|
+
/******/ return __webpack_require__(__webpack_require__.s = 222);
|
|
86
86
|
/******/ })
|
|
87
87
|
/************************************************************************/
|
|
88
88
|
/******/ ({
|
|
@@ -3741,7 +3741,29 @@ module.exports = require("vue");
|
|
|
3741
3741
|
|
|
3742
3742
|
/***/ }),
|
|
3743
3743
|
|
|
3744
|
-
/***/
|
|
3744
|
+
/***/ 22:
|
|
3745
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
3746
|
+
|
|
3747
|
+
"use strict";
|
|
3748
|
+
/* harmony default export */ __webpack_exports__["a"] = (function (target) {
|
|
3749
|
+
for (var i = 1, j = arguments.length; i < j; i++) {
|
|
3750
|
+
var source = arguments[i] || {};
|
|
3751
|
+
for (var prop in source) {
|
|
3752
|
+
if (source.hasOwnProperty(prop)) {
|
|
3753
|
+
var value = source[prop];
|
|
3754
|
+
if (value !== undefined) {
|
|
3755
|
+
target[prop] = value;
|
|
3756
|
+
}
|
|
3757
|
+
}
|
|
3758
|
+
}
|
|
3759
|
+
}
|
|
3760
|
+
|
|
3761
|
+
return target;
|
|
3762
|
+
});;
|
|
3763
|
+
|
|
3764
|
+
/***/ }),
|
|
3765
|
+
|
|
3766
|
+
/***/ 222:
|
|
3745
3767
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
3746
3768
|
|
|
3747
3769
|
"use strict";
|
|
@@ -4344,28 +4366,6 @@ main.directive = directive;
|
|
|
4344
4366
|
|
|
4345
4367
|
/***/ }),
|
|
4346
4368
|
|
|
4347
|
-
/***/ 22:
|
|
4348
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
4349
|
-
|
|
4350
|
-
"use strict";
|
|
4351
|
-
/* harmony default export */ __webpack_exports__["a"] = (function (target) {
|
|
4352
|
-
for (var i = 1, j = arguments.length; i < j; i++) {
|
|
4353
|
-
var source = arguments[i] || {};
|
|
4354
|
-
for (var prop in source) {
|
|
4355
|
-
if (source.hasOwnProperty(prop)) {
|
|
4356
|
-
var value = source[prop];
|
|
4357
|
-
if (value !== undefined) {
|
|
4358
|
-
target[prop] = value;
|
|
4359
|
-
}
|
|
4360
|
-
}
|
|
4361
|
-
}
|
|
4362
|
-
}
|
|
4363
|
-
|
|
4364
|
-
return target;
|
|
4365
|
-
});;
|
|
4366
|
-
|
|
4367
|
-
/***/ }),
|
|
4368
|
-
|
|
4369
4369
|
/***/ 23:
|
|
4370
4370
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
4371
4371
|
|
|
@@ -4521,7 +4521,7 @@ function scrollMove(wrap) {
|
|
|
4521
4521
|
|
|
4522
4522
|
|
|
4523
4523
|
|
|
4524
|
-
var PopperJS = vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer ? function () {} : __webpack_require__(
|
|
4524
|
+
var PopperJS = vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer ? function () {} : __webpack_require__(53);
|
|
4525
4525
|
var stopPropagation = function stopPropagation(e) {
|
|
4526
4526
|
return e.stopPropagation();
|
|
4527
4527
|
};
|
|
@@ -5481,10 +5481,12 @@ function insertAfter(newEl, targetEl) {
|
|
|
5481
5481
|
|
|
5482
5482
|
/***/ }),
|
|
5483
5483
|
|
|
5484
|
-
/***/
|
|
5484
|
+
/***/ 53:
|
|
5485
5485
|
/***/ (function(module, exports, __webpack_require__) {
|
|
5486
5486
|
|
|
5487
|
-
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__
|
|
5487
|
+
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
5488
|
+
|
|
5489
|
+
/**
|
|
5488
5490
|
* @fileOverview Kickass library to create and place poppers near their reference elements.
|
|
5489
5491
|
* @version {{version}}
|
|
5490
5492
|
* @license
|
|
@@ -5507,68 +5509,60 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
5507
5509
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
5508
5510
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
5509
5511
|
* SOFTWARE.
|
|
5510
|
-
*/
|
|
5511
|
-
|
|
5512
|
-
//
|
|
5513
|
-
// Cross module loader
|
|
5514
|
-
// Supported: Node, AMD, Browser globals
|
|
5515
|
-
//
|
|
5516
|
-
(function (root, factory) {
|
|
5517
|
-
if (true) {
|
|
5518
|
-
// AMD. Register as an anonymous module.
|
|
5512
|
+
*/
|
|
5513
|
+
|
|
5514
|
+
//
|
|
5515
|
+
// Cross module loader
|
|
5516
|
+
// Supported: Node, AMD, Browser globals
|
|
5517
|
+
//
|
|
5518
|
+
(function (root, factory) {
|
|
5519
|
+
if (true) {
|
|
5520
|
+
// AMD. Register as an anonymous module.
|
|
5519
5521
|
!(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
|
|
5520
5522
|
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
|
|
5521
5523
|
(__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
|
|
5522
5524
|
__WEBPACK_AMD_DEFINE_FACTORY__),
|
|
5523
|
-
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
|
5524
|
-
} else {}
|
|
5525
|
-
})(this, function () {
|
|
5526
|
-
'use strict';
|
|
5527
|
-
|
|
5528
|
-
var root =
|
|
5529
|
-
// default options
|
|
5530
|
-
var DEFAULTS = {
|
|
5531
|
-
// placement of the popper
|
|
5532
|
-
placement: 'bottom',
|
|
5533
|
-
|
|
5534
|
-
gpuAcceleration: true,
|
|
5535
|
-
|
|
5536
|
-
// shift popper from its origin by the given amount of pixels (can be negative)
|
|
5537
|
-
offset: 0,
|
|
5538
|
-
|
|
5539
|
-
// the element which will act as boundary of the popper
|
|
5540
|
-
boundariesElement: 'viewport',
|
|
5541
|
-
|
|
5542
|
-
// amount of pixel used to define a minimum distance between the boundaries and the popper
|
|
5543
|
-
boundariesPadding: 5,
|
|
5544
|
-
|
|
5545
|
-
// popper will try to prevent overflow following this order,
|
|
5546
|
-
// by default, then, it could overflow on the left and on top of the boundariesElement
|
|
5547
|
-
preventOverflowOrder: ['left', 'right', 'top', 'bottom'],
|
|
5548
|
-
|
|
5549
|
-
// the behavior used by flip to change the placement of the popper
|
|
5550
|
-
flipBehavior: 'flip',
|
|
5551
|
-
|
|
5552
|
-
arrowElement: '[x-arrow]',
|
|
5553
|
-
|
|
5554
|
-
arrowOffset: 0,
|
|
5555
|
-
|
|
5556
|
-
// list of functions used to modify the offsets before they are applied to the popper
|
|
5557
|
-
modifiers: [
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
'applyStyle'
|
|
5565
|
-
],
|
|
5566
|
-
|
|
5567
|
-
modifiersIgnored: [],
|
|
5568
|
-
|
|
5569
|
-
forceAbsolute: false
|
|
5570
|
-
};
|
|
5571
|
-
|
|
5525
|
+
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
|
5526
|
+
} else {}
|
|
5527
|
+
})(this, function () {
|
|
5528
|
+
'use strict';
|
|
5529
|
+
|
|
5530
|
+
var root = window;
|
|
5531
|
+
// default options
|
|
5532
|
+
var DEFAULTS = {
|
|
5533
|
+
// placement of the popper
|
|
5534
|
+
placement: 'bottom',
|
|
5535
|
+
|
|
5536
|
+
gpuAcceleration: true,
|
|
5537
|
+
|
|
5538
|
+
// shift popper from its origin by the given amount of pixels (can be negative)
|
|
5539
|
+
offset: 0,
|
|
5540
|
+
|
|
5541
|
+
// the element which will act as boundary of the popper
|
|
5542
|
+
boundariesElement: 'viewport',
|
|
5543
|
+
|
|
5544
|
+
// amount of pixel used to define a minimum distance between the boundaries and the popper
|
|
5545
|
+
boundariesPadding: 5,
|
|
5546
|
+
|
|
5547
|
+
// popper will try to prevent overflow following this order,
|
|
5548
|
+
// by default, then, it could overflow on the left and on top of the boundariesElement
|
|
5549
|
+
preventOverflowOrder: ['left', 'right', 'top', 'bottom'],
|
|
5550
|
+
|
|
5551
|
+
// the behavior used by flip to change the placement of the popper
|
|
5552
|
+
flipBehavior: 'flip',
|
|
5553
|
+
|
|
5554
|
+
arrowElement: '[x-arrow]',
|
|
5555
|
+
|
|
5556
|
+
arrowOffset: 0,
|
|
5557
|
+
|
|
5558
|
+
// list of functions used to modify the offsets before they are applied to the popper
|
|
5559
|
+
modifiers: ['shift', 'offset', 'preventOverflow', 'keepTogether', 'arrow', 'flip', 'applyStyle'],
|
|
5560
|
+
|
|
5561
|
+
modifiersIgnored: [],
|
|
5562
|
+
|
|
5563
|
+
forceAbsolute: false
|
|
5564
|
+
};
|
|
5565
|
+
|
|
5572
5566
|
/**
|
|
5573
5567
|
* Create a new Popper.js instance
|
|
5574
5568
|
* @constructor Popper
|
|
@@ -5633,125 +5627,114 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
5633
5627
|
*
|
|
5634
5628
|
* @param {Boolean} [options.removeOnDestroy=false]
|
|
5635
5629
|
* Set to true if you want to automatically remove the popper when you call the `destroy` method.
|
|
5636
|
-
*/
|
|
5637
|
-
function Popper(reference, popper, options) {
|
|
5638
|
-
this._reference = reference.jquery ? reference[0] : reference;
|
|
5639
|
-
this.state = {};
|
|
5640
|
-
|
|
5641
|
-
// if the popper variable is a configuration object, parse it to generate an HTMLElement
|
|
5642
|
-
// generate a default popper if is not defined
|
|
5643
|
-
var isNotDefined = typeof popper === 'undefined' || popper === null;
|
|
5644
|
-
var isConfig =
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
);
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
//
|
|
5679
|
-
this.
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
//
|
|
5687
|
-
// Methods
|
|
5688
|
-
//
|
|
5630
|
+
*/
|
|
5631
|
+
function Popper(reference, popper, options) {
|
|
5632
|
+
this._reference = reference.jquery ? reference[0] : reference;
|
|
5633
|
+
this.state = {};
|
|
5634
|
+
|
|
5635
|
+
// if the popper variable is a configuration object, parse it to generate an HTMLElement
|
|
5636
|
+
// generate a default popper if is not defined
|
|
5637
|
+
var isNotDefined = typeof popper === 'undefined' || popper === null;
|
|
5638
|
+
var isConfig = popper && Object.prototype.toString.call(popper) === '[object Object]';
|
|
5639
|
+
if (isNotDefined || isConfig) {
|
|
5640
|
+
this._popper = this.parse(isConfig ? popper : {});
|
|
5641
|
+
}
|
|
5642
|
+
// otherwise, use the given HTMLElement as popper
|
|
5643
|
+
else {
|
|
5644
|
+
this._popper = popper.jquery ? popper[0] : popper;
|
|
5645
|
+
}
|
|
5646
|
+
|
|
5647
|
+
// with {} we create a new object with the options inside it
|
|
5648
|
+
this._options = Object.assign({}, DEFAULTS, options);
|
|
5649
|
+
|
|
5650
|
+
// refactoring modifiers' list
|
|
5651
|
+
this._options.modifiers = this._options.modifiers.map(function (modifier) {
|
|
5652
|
+
// remove ignored modifiers
|
|
5653
|
+
if (this._options.modifiersIgnored.indexOf(modifier) !== -1) return;
|
|
5654
|
+
|
|
5655
|
+
// set the x-placement attribute before everything else because it could be used to add margins to the popper
|
|
5656
|
+
// margins needs to be calculated to get the correct popper offsets
|
|
5657
|
+
if (modifier === 'applyStyle') {
|
|
5658
|
+
this._popper.setAttribute('x-placement', this._options.placement);
|
|
5659
|
+
}
|
|
5660
|
+
|
|
5661
|
+
// return predefined modifier identified by string or keep the custom one
|
|
5662
|
+
return this.modifiers[modifier] || modifier;
|
|
5663
|
+
}.bind(this));
|
|
5664
|
+
|
|
5665
|
+
// make sure to apply the popper position before any computation
|
|
5666
|
+
this.state.position = this._getPosition(this._popper, this._reference);
|
|
5667
|
+
setStyle(this._popper, { position: this.state.position, top: 0 });
|
|
5668
|
+
|
|
5669
|
+
// fire the first update to position the popper in the right place
|
|
5670
|
+
this.update();
|
|
5671
|
+
|
|
5672
|
+
// setup event listeners, they will take care of update the position in specific situations
|
|
5673
|
+
this._setupEventListeners();
|
|
5674
|
+
return this;
|
|
5675
|
+
}
|
|
5676
|
+
|
|
5677
|
+
//
|
|
5678
|
+
// Methods
|
|
5679
|
+
//
|
|
5689
5680
|
/**
|
|
5690
5681
|
* Destroy the popper
|
|
5691
5682
|
* @method
|
|
5692
5683
|
* @memberof Popper
|
|
5693
|
-
*/
|
|
5694
|
-
Popper.prototype.destroy = function () {
|
|
5695
|
-
this._popper.removeAttribute('x-placement');
|
|
5696
|
-
this._popper.style.left = '';
|
|
5697
|
-
this._popper.style.position = '';
|
|
5698
|
-
this._popper.style.top = '';
|
|
5699
|
-
this._popper.style[getSupportedPropertyName('transform')] = '';
|
|
5700
|
-
this._removeEventListeners();
|
|
5701
|
-
|
|
5702
|
-
// remove the popper if user explicity asked for the deletion on destroy
|
|
5703
|
-
if (this._options.removeOnDestroy) {
|
|
5704
|
-
this._popper.remove();
|
|
5705
|
-
}
|
|
5706
|
-
return this;
|
|
5707
|
-
};
|
|
5708
|
-
|
|
5684
|
+
*/
|
|
5685
|
+
Popper.prototype.destroy = function () {
|
|
5686
|
+
this._popper.removeAttribute('x-placement');
|
|
5687
|
+
this._popper.style.left = '';
|
|
5688
|
+
this._popper.style.position = '';
|
|
5689
|
+
this._popper.style.top = '';
|
|
5690
|
+
this._popper.style[getSupportedPropertyName('transform')] = '';
|
|
5691
|
+
this._removeEventListeners();
|
|
5692
|
+
|
|
5693
|
+
// remove the popper if user explicity asked for the deletion on destroy
|
|
5694
|
+
if (this._options.removeOnDestroy) {
|
|
5695
|
+
this._popper.remove();
|
|
5696
|
+
}
|
|
5697
|
+
return this;
|
|
5698
|
+
};
|
|
5699
|
+
|
|
5709
5700
|
/**
|
|
5710
5701
|
* Updates the position of the popper, computing the new offsets and applying the new style
|
|
5711
5702
|
* @method
|
|
5712
5703
|
* @memberof Popper
|
|
5713
|
-
*/
|
|
5714
|
-
Popper.prototype.update = function () {
|
|
5715
|
-
var data = { instance: this, styles: {} };
|
|
5716
|
-
|
|
5717
|
-
// store placement inside the data object, modifiers will be able to edit `placement` if needed
|
|
5718
|
-
// and refer to _originalPlacement to know the original value
|
|
5719
|
-
data.placement = this._options.placement;
|
|
5720
|
-
data._originalPlacement = this._options.placement;
|
|
5721
|
-
|
|
5722
|
-
// compute the popper and reference offsets and put them inside data.offsets
|
|
5723
|
-
data.offsets = this._getOffsets(
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
data
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
data = this.runModifiers(data, this._options.modifiers);
|
|
5737
|
-
|
|
5738
|
-
if (typeof this.state.updateCallback === 'function') {
|
|
5739
|
-
this.state.updateCallback(data);
|
|
5740
|
-
}
|
|
5741
|
-
};
|
|
5742
|
-
|
|
5704
|
+
*/
|
|
5705
|
+
Popper.prototype.update = function () {
|
|
5706
|
+
var data = { instance: this, styles: {} };
|
|
5707
|
+
|
|
5708
|
+
// store placement inside the data object, modifiers will be able to edit `placement` if needed
|
|
5709
|
+
// and refer to _originalPlacement to know the original value
|
|
5710
|
+
data.placement = this._options.placement;
|
|
5711
|
+
data._originalPlacement = this._options.placement;
|
|
5712
|
+
|
|
5713
|
+
// compute the popper and reference offsets and put them inside data.offsets
|
|
5714
|
+
data.offsets = this._getOffsets(this._popper, this._reference, data.placement);
|
|
5715
|
+
|
|
5716
|
+
// get boundaries
|
|
5717
|
+
data.boundaries = this._getBoundaries(data, this._options.boundariesPadding, this._options.boundariesElement);
|
|
5718
|
+
|
|
5719
|
+
data = this.runModifiers(data, this._options.modifiers);
|
|
5720
|
+
|
|
5721
|
+
if (typeof this.state.updateCallback === 'function') {
|
|
5722
|
+
this.state.updateCallback(data);
|
|
5723
|
+
}
|
|
5724
|
+
};
|
|
5725
|
+
|
|
5743
5726
|
/**
|
|
5744
5727
|
* If a function is passed, it will be executed after the initialization of popper with as first argument the Popper instance.
|
|
5745
5728
|
* @method
|
|
5746
5729
|
* @memberof Popper
|
|
5747
5730
|
* @param {Function} callback
|
|
5748
|
-
*/
|
|
5749
|
-
Popper.prototype.onCreate = function (callback) {
|
|
5750
|
-
// the createCallbacks return as first argument the popper instance
|
|
5751
|
-
callback(this);
|
|
5752
|
-
return this;
|
|
5753
|
-
};
|
|
5754
|
-
|
|
5731
|
+
*/
|
|
5732
|
+
Popper.prototype.onCreate = function (callback) {
|
|
5733
|
+
// the createCallbacks return as first argument the popper instance
|
|
5734
|
+
callback(this);
|
|
5735
|
+
return this;
|
|
5736
|
+
};
|
|
5737
|
+
|
|
5755
5738
|
/**
|
|
5756
5739
|
* If a function is passed, it will be executed after each update of popper with as first argument the set of coordinates and informations
|
|
5757
5740
|
* used to style popper and its arrow.
|
|
@@ -5759,101 +5742,93 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
5759
5742
|
* @method
|
|
5760
5743
|
* @memberof Popper
|
|
5761
5744
|
* @param {Function} callback
|
|
5762
|
-
*/
|
|
5763
|
-
Popper.prototype.onUpdate = function (callback) {
|
|
5764
|
-
this.state.updateCallback = callback;
|
|
5765
|
-
return this;
|
|
5766
|
-
};
|
|
5767
|
-
|
|
5745
|
+
*/
|
|
5746
|
+
Popper.prototype.onUpdate = function (callback) {
|
|
5747
|
+
this.state.updateCallback = callback;
|
|
5748
|
+
return this;
|
|
5749
|
+
};
|
|
5750
|
+
|
|
5768
5751
|
/**
|
|
5769
5752
|
* Helper used to generate poppers from a configuration file
|
|
5770
5753
|
* @method
|
|
5771
5754
|
* @memberof Popper
|
|
5772
5755
|
* @param config {Object} configuration
|
|
5773
5756
|
* @returns {HTMLElement} popper
|
|
5774
|
-
*/
|
|
5775
|
-
Popper.prototype.parse = function (config) {
|
|
5776
|
-
var defaultConfig = {
|
|
5777
|
-
tagName: 'div',
|
|
5778
|
-
classNames: ['popper'],
|
|
5779
|
-
attributes: [],
|
|
5780
|
-
parent: root.document.body,
|
|
5781
|
-
content: '',
|
|
5782
|
-
contentType: 'text',
|
|
5783
|
-
arrowTagName: 'div',
|
|
5784
|
-
arrowClassNames: ['popper__arrow'],
|
|
5785
|
-
arrowAttributes: ['x-arrow']
|
|
5786
|
-
};
|
|
5787
|
-
config = Object.assign({}, defaultConfig, config);
|
|
5788
|
-
|
|
5789
|
-
var d = root.document;
|
|
5790
|
-
|
|
5791
|
-
var popper = d.createElement(config.tagName);
|
|
5792
|
-
addClassNames(popper, config.classNames);
|
|
5793
|
-
addAttributes(popper, config.attributes);
|
|
5794
|
-
if (config.contentType === 'node') {
|
|
5795
|
-
popper.appendChild(
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
} else
|
|
5799
|
-
popper.
|
|
5800
|
-
}
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
// if
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
parent = parent[0];
|
|
5829
|
-
}
|
|
5830
|
-
|
|
5831
|
-
// the
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
parent = parent[0];
|
|
5837
|
-
}
|
|
5838
|
-
|
|
5839
|
-
// append the generated popper to its parent
|
|
5840
|
-
parent.appendChild(popper);
|
|
5841
|
-
|
|
5842
|
-
return popper;
|
|
5843
|
-
|
|
5757
|
+
*/
|
|
5758
|
+
Popper.prototype.parse = function (config) {
|
|
5759
|
+
var defaultConfig = {
|
|
5760
|
+
tagName: 'div',
|
|
5761
|
+
classNames: ['popper'],
|
|
5762
|
+
attributes: [],
|
|
5763
|
+
parent: root.document.body,
|
|
5764
|
+
content: '',
|
|
5765
|
+
contentType: 'text',
|
|
5766
|
+
arrowTagName: 'div',
|
|
5767
|
+
arrowClassNames: ['popper__arrow'],
|
|
5768
|
+
arrowAttributes: ['x-arrow']
|
|
5769
|
+
};
|
|
5770
|
+
config = Object.assign({}, defaultConfig, config);
|
|
5771
|
+
|
|
5772
|
+
var d = root.document;
|
|
5773
|
+
|
|
5774
|
+
var popper = d.createElement(config.tagName);
|
|
5775
|
+
addClassNames(popper, config.classNames);
|
|
5776
|
+
addAttributes(popper, config.attributes);
|
|
5777
|
+
if (config.contentType === 'node') {
|
|
5778
|
+
popper.appendChild(config.content.jquery ? config.content[0] : config.content);
|
|
5779
|
+
} else if (config.contentType === 'html') {
|
|
5780
|
+
popper.innerHTML = config.content;
|
|
5781
|
+
} else {
|
|
5782
|
+
popper.textContent = config.content;
|
|
5783
|
+
}
|
|
5784
|
+
|
|
5785
|
+
if (config.arrowTagName) {
|
|
5786
|
+
var arrow = d.createElement(config.arrowTagName);
|
|
5787
|
+
addClassNames(arrow, config.arrowClassNames);
|
|
5788
|
+
addAttributes(arrow, config.arrowAttributes);
|
|
5789
|
+
popper.appendChild(arrow);
|
|
5790
|
+
}
|
|
5791
|
+
|
|
5792
|
+
var parent = config.parent.jquery ? config.parent[0] : config.parent;
|
|
5793
|
+
|
|
5794
|
+
// if the given parent is a string, use it to match an element
|
|
5795
|
+
// if more than one element is matched, the first one will be used as parent
|
|
5796
|
+
// if no elements are matched, the script will throw an error
|
|
5797
|
+
if (typeof parent === 'string') {
|
|
5798
|
+
parent = d.querySelectorAll(config.parent);
|
|
5799
|
+
if (parent.length > 1) {
|
|
5800
|
+
console.warn('WARNING: the given `parent` query(' + config.parent + ') matched more than one element, the first one will be used');
|
|
5801
|
+
}
|
|
5802
|
+
if (parent.length === 0) {
|
|
5803
|
+
throw "ERROR: the given `parent` doesn't exists!";
|
|
5804
|
+
}
|
|
5805
|
+
parent = parent[0];
|
|
5806
|
+
}
|
|
5807
|
+
// if the given parent is a DOM nodes list or an array of nodes with more than one element,
|
|
5808
|
+
// the first one will be used as parent
|
|
5809
|
+
if (parent.length > 1 && parent instanceof Element === false) {
|
|
5810
|
+
console.warn('WARNING: you have passed as parent a list of elements, the first one will be used');
|
|
5811
|
+
parent = parent[0];
|
|
5812
|
+
}
|
|
5813
|
+
|
|
5814
|
+
// append the generated popper to its parent
|
|
5815
|
+
parent.appendChild(popper);
|
|
5816
|
+
|
|
5817
|
+
return popper;
|
|
5818
|
+
|
|
5844
5819
|
/**
|
|
5845
5820
|
* Adds class names to the given element
|
|
5846
5821
|
* @function
|
|
5847
5822
|
* @ignore
|
|
5848
5823
|
* @param {HTMLElement} target
|
|
5849
5824
|
* @param {Array} classes
|
|
5850
|
-
*/
|
|
5851
|
-
function addClassNames(element, classNames) {
|
|
5852
|
-
classNames.forEach(function (className) {
|
|
5853
|
-
element.classList.add(className);
|
|
5854
|
-
});
|
|
5855
|
-
}
|
|
5856
|
-
|
|
5825
|
+
*/
|
|
5826
|
+
function addClassNames(element, classNames) {
|
|
5827
|
+
classNames.forEach(function (className) {
|
|
5828
|
+
element.classList.add(className);
|
|
5829
|
+
});
|
|
5830
|
+
}
|
|
5831
|
+
|
|
5857
5832
|
/**
|
|
5858
5833
|
* Adds attributes to the given element
|
|
5859
5834
|
* @function
|
|
@@ -5862,17 +5837,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
5862
5837
|
* @param {Array} attributes
|
|
5863
5838
|
* @example
|
|
5864
5839
|
* addAttributes(element, [ 'data-info:foobar' ]);
|
|
5865
|
-
*/
|
|
5866
|
-
function addAttributes(element, attributes) {
|
|
5867
|
-
attributes.forEach(function (attribute) {
|
|
5868
|
-
element.setAttribute(
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
}
|
|
5874
|
-
};
|
|
5875
|
-
|
|
5840
|
+
*/
|
|
5841
|
+
function addAttributes(element, attributes) {
|
|
5842
|
+
attributes.forEach(function (attribute) {
|
|
5843
|
+
element.setAttribute(attribute.split(':')[0], attribute.split(':')[1] || '');
|
|
5844
|
+
});
|
|
5845
|
+
}
|
|
5846
|
+
};
|
|
5847
|
+
|
|
5876
5848
|
/**
|
|
5877
5849
|
* Helper used to get the position which will be applied to the popper
|
|
5878
5850
|
* @method
|
|
@@ -5880,20 +5852,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
5880
5852
|
* @param config {HTMLElement} popper element
|
|
5881
5853
|
* @param reference {HTMLElement} reference element
|
|
5882
5854
|
* @returns {String} position
|
|
5883
|
-
*/
|
|
5884
|
-
Popper.prototype._getPosition = function (popper, reference) {
|
|
5885
|
-
var container = getOffsetParent(reference);
|
|
5886
|
-
|
|
5887
|
-
if (this._options.forceAbsolute) {
|
|
5888
|
-
return 'absolute';
|
|
5889
|
-
}
|
|
5890
|
-
|
|
5891
|
-
// Decide if the popper will be fixed
|
|
5892
|
-
// If the reference element is inside a fixed context, the popper will be fixed as well to allow them to scroll together
|
|
5893
|
-
var isParentFixed = isFixed(reference, container);
|
|
5894
|
-
return isParentFixed ? 'fixed' : 'absolute';
|
|
5895
|
-
};
|
|
5896
|
-
|
|
5855
|
+
*/
|
|
5856
|
+
Popper.prototype._getPosition = function (popper, reference) {
|
|
5857
|
+
var container = getOffsetParent(reference);
|
|
5858
|
+
|
|
5859
|
+
if (this._options.forceAbsolute) {
|
|
5860
|
+
return 'absolute';
|
|
5861
|
+
}
|
|
5862
|
+
|
|
5863
|
+
// Decide if the popper will be fixed
|
|
5864
|
+
// If the reference element is inside a fixed context, the popper will be fixed as well to allow them to scroll together
|
|
5865
|
+
var isParentFixed = isFixed(reference, container);
|
|
5866
|
+
return isParentFixed ? 'fixed' : 'absolute';
|
|
5867
|
+
};
|
|
5868
|
+
|
|
5897
5869
|
/**
|
|
5898
5870
|
* Get offsets to the popper
|
|
5899
5871
|
* @method
|
|
@@ -5902,110 +5874,91 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
5902
5874
|
* @param {Element} popper - the popper element
|
|
5903
5875
|
* @param {Element} reference - the reference element (the popper will be relative to this)
|
|
5904
5876
|
* @returns {Object} An object containing the offsets which will be applied to the popper
|
|
5905
|
-
*/
|
|
5906
|
-
Popper.prototype._getOffsets = function (popper, reference, placement) {
|
|
5907
|
-
placement = placement.split('-')[0];
|
|
5908
|
-
var popperOffsets = {};
|
|
5909
|
-
|
|
5910
|
-
popperOffsets.position = this.state.position;
|
|
5911
|
-
var isParentFixed = popperOffsets.position === 'fixed';
|
|
5912
|
-
|
|
5913
|
-
//
|
|
5914
|
-
// Get reference element position
|
|
5915
|
-
//
|
|
5916
|
-
var referenceOffsets = getOffsetRectRelativeToCustomParent(
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
//
|
|
5924
|
-
//
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
//
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
if (placement === '
|
|
5938
|
-
popperOffsets.
|
|
5939
|
-
} else {
|
|
5940
|
-
popperOffsets.
|
|
5941
|
-
}
|
|
5942
|
-
}
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
// Add width and height to our offsets object
|
|
5955
|
-
popperOffsets.width = popperRect.width;
|
|
5956
|
-
popperOffsets.height = popperRect.height;
|
|
5957
|
-
|
|
5958
|
-
return {
|
|
5959
|
-
popper: popperOffsets,
|
|
5960
|
-
reference: referenceOffsets
|
|
5961
|
-
};
|
|
5962
|
-
};
|
|
5963
|
-
|
|
5877
|
+
*/
|
|
5878
|
+
Popper.prototype._getOffsets = function (popper, reference, placement) {
|
|
5879
|
+
placement = placement.split('-')[0];
|
|
5880
|
+
var popperOffsets = {};
|
|
5881
|
+
|
|
5882
|
+
popperOffsets.position = this.state.position;
|
|
5883
|
+
var isParentFixed = popperOffsets.position === 'fixed';
|
|
5884
|
+
|
|
5885
|
+
//
|
|
5886
|
+
// Get reference element position
|
|
5887
|
+
//
|
|
5888
|
+
var referenceOffsets = getOffsetRectRelativeToCustomParent(reference, popper, isParentFixed);
|
|
5889
|
+
|
|
5890
|
+
//
|
|
5891
|
+
// Get popper sizes
|
|
5892
|
+
//
|
|
5893
|
+
var popperRect = getOuterSizes(popper);
|
|
5894
|
+
|
|
5895
|
+
//
|
|
5896
|
+
// Compute offsets of popper
|
|
5897
|
+
//
|
|
5898
|
+
|
|
5899
|
+
// depending by the popper placement we have to compute its offsets slightly differently
|
|
5900
|
+
if (['right', 'left'].indexOf(placement) !== -1) {
|
|
5901
|
+
popperOffsets.top = referenceOffsets.top + referenceOffsets.height / 2 - popperRect.height / 2;
|
|
5902
|
+
if (placement === 'left') {
|
|
5903
|
+
popperOffsets.left = referenceOffsets.left - popperRect.width;
|
|
5904
|
+
} else {
|
|
5905
|
+
popperOffsets.left = referenceOffsets.right;
|
|
5906
|
+
}
|
|
5907
|
+
} else {
|
|
5908
|
+
popperOffsets.left = referenceOffsets.left + referenceOffsets.width / 2 - popperRect.width / 2;
|
|
5909
|
+
if (placement === 'top') {
|
|
5910
|
+
popperOffsets.top = referenceOffsets.top - popperRect.height;
|
|
5911
|
+
} else {
|
|
5912
|
+
popperOffsets.top = referenceOffsets.bottom;
|
|
5913
|
+
}
|
|
5914
|
+
}
|
|
5915
|
+
|
|
5916
|
+
// Add width and height to our offsets object
|
|
5917
|
+
popperOffsets.width = popperRect.width;
|
|
5918
|
+
popperOffsets.height = popperRect.height;
|
|
5919
|
+
|
|
5920
|
+
return {
|
|
5921
|
+
popper: popperOffsets,
|
|
5922
|
+
reference: referenceOffsets
|
|
5923
|
+
};
|
|
5924
|
+
};
|
|
5925
|
+
|
|
5964
5926
|
/**
|
|
5965
5927
|
* Setup needed event listeners used to update the popper position
|
|
5966
5928
|
* @method
|
|
5967
5929
|
* @memberof Popper
|
|
5968
5930
|
* @access private
|
|
5969
|
-
*/
|
|
5970
|
-
Popper.prototype._setupEventListeners = function () {
|
|
5971
|
-
// NOTE: 1 DOM access here
|
|
5972
|
-
this.state.updateBound = this.update.bind(this);
|
|
5973
|
-
// 无界等微前端场景下沙箱 window 不会触发 resize,需监听真实 window
|
|
5974
|
-
this.state.realWindow = getRealWindow(this._popper);
|
|
5975
|
-
this.state.realWindow.addEventListener('resize', this.state.updateBound);
|
|
5976
|
-
// if the boundariesElement is window we don't need to listen for the scroll event
|
|
5977
|
-
if (this._options.boundariesElement !== 'window') {
|
|
5978
|
-
var target = getScrollParent(this._reference);
|
|
5979
|
-
target.addEventListener('scroll', this.state.updateBound);
|
|
5980
|
-
this.state.scrollTarget = target;
|
|
5981
|
-
}
|
|
5982
|
-
};
|
|
5983
|
-
|
|
5931
|
+
*/
|
|
5932
|
+
Popper.prototype._setupEventListeners = function () {
|
|
5933
|
+
// NOTE: 1 DOM access here
|
|
5934
|
+
this.state.updateBound = this.update.bind(this);
|
|
5935
|
+
// 无界等微前端场景下沙箱 window 不会触发 resize,需监听真实 window
|
|
5936
|
+
this.state.realWindow = getRealWindow(this._popper);
|
|
5937
|
+
this.state.realWindow.addEventListener('resize', this.state.updateBound);
|
|
5938
|
+
// if the boundariesElement is window we don't need to listen for the scroll event
|
|
5939
|
+
if (this._options.boundariesElement !== 'window') {
|
|
5940
|
+
var target = getScrollParent(this._reference);
|
|
5941
|
+
target.addEventListener('scroll', this.state.updateBound);
|
|
5942
|
+
this.state.scrollTarget = target;
|
|
5943
|
+
}
|
|
5944
|
+
};
|
|
5945
|
+
|
|
5984
5946
|
/**
|
|
5985
5947
|
* Remove event listeners used to update the popper position
|
|
5986
5948
|
* @method
|
|
5987
5949
|
* @memberof Popper
|
|
5988
5950
|
* @access private
|
|
5989
|
-
*/
|
|
5990
|
-
Popper.prototype._removeEventListeners = function () {
|
|
5991
|
-
// NOTE: 1 DOM access here
|
|
5992
|
-
(this.state.realWindow || root).removeEventListener(
|
|
5993
|
-
|
|
5994
|
-
this.state.updateBound
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
this.state.scrollTarget.removeEventListener(
|
|
6001
|
-
'scroll',
|
|
6002
|
-
this.state.updateBound
|
|
6003
|
-
);
|
|
6004
|
-
this.state.scrollTarget = null;
|
|
6005
|
-
}
|
|
6006
|
-
this.state.updateBound = null;
|
|
6007
|
-
};
|
|
6008
|
-
|
|
5951
|
+
*/
|
|
5952
|
+
Popper.prototype._removeEventListeners = function () {
|
|
5953
|
+
// NOTE: 1 DOM access here
|
|
5954
|
+
(this.state.realWindow || root).removeEventListener('resize', this.state.updateBound);
|
|
5955
|
+
if (this._options.boundariesElement !== 'window' && this.state.scrollTarget) {
|
|
5956
|
+
this.state.scrollTarget.removeEventListener('scroll', this.state.updateBound);
|
|
5957
|
+
this.state.scrollTarget = null;
|
|
5958
|
+
}
|
|
5959
|
+
this.state.updateBound = null;
|
|
5960
|
+
};
|
|
5961
|
+
|
|
6009
5962
|
/**
|
|
6010
5963
|
* Computed the boundaries limits and return them
|
|
6011
5964
|
* @method
|
|
@@ -6015,75 +5968,56 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6015
5968
|
* @param {Number} padding - Boundaries padding
|
|
6016
5969
|
* @param {Element} boundariesElement - Element used to define the boundaries
|
|
6017
5970
|
* @returns {Object} Coordinates of the boundaries
|
|
6018
|
-
*/
|
|
6019
|
-
Popper.prototype._getBoundaries = function (data, padding, boundariesElement) {
|
|
6020
|
-
// NOTE: 1 DOM access here
|
|
6021
|
-
var boundaries = {};
|
|
6022
|
-
var width, height;
|
|
6023
|
-
if (boundariesElement === 'window') {
|
|
6024
|
-
var body = root.document.body,
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
height = Math.max(
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
);
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
} else {
|
|
6069
|
-
if (getOffsetParent(this._popper) === boundariesElement) {
|
|
6070
|
-
boundaries = {
|
|
6071
|
-
top: 0,
|
|
6072
|
-
left: 0,
|
|
6073
|
-
right: boundariesElement.clientWidth,
|
|
6074
|
-
bottom: boundariesElement.clientHeight
|
|
6075
|
-
};
|
|
6076
|
-
} else {
|
|
6077
|
-
boundaries = getOffsetRect(boundariesElement);
|
|
6078
|
-
}
|
|
6079
|
-
}
|
|
6080
|
-
boundaries.left += padding;
|
|
6081
|
-
boundaries.right -= padding;
|
|
6082
|
-
boundaries.top = boundaries.top + padding;
|
|
6083
|
-
boundaries.bottom = boundaries.bottom - padding;
|
|
6084
|
-
return boundaries;
|
|
6085
|
-
};
|
|
6086
|
-
|
|
5971
|
+
*/
|
|
5972
|
+
Popper.prototype._getBoundaries = function (data, padding, boundariesElement) {
|
|
5973
|
+
// NOTE: 1 DOM access here
|
|
5974
|
+
var boundaries = {};
|
|
5975
|
+
var width, height;
|
|
5976
|
+
if (boundariesElement === 'window') {
|
|
5977
|
+
var body = root.document.body,
|
|
5978
|
+
html = root.document.documentElement;
|
|
5979
|
+
|
|
5980
|
+
height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
|
|
5981
|
+
width = Math.max(body.scrollWidth, body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth);
|
|
5982
|
+
|
|
5983
|
+
boundaries = {
|
|
5984
|
+
top: 0,
|
|
5985
|
+
right: width,
|
|
5986
|
+
bottom: height,
|
|
5987
|
+
left: 0
|
|
5988
|
+
};
|
|
5989
|
+
} else if (boundariesElement === 'viewport') {
|
|
5990
|
+
// 将真实 window 的视口换算到 popper 所在包含块的坐标系。
|
|
5991
|
+
// 无界等场景下沙箱 window 的尺寸、shadowRoot 内元素的 scrollTop 均不可靠,
|
|
5992
|
+
// 统一从元素自身的 view 与真实包含块获取
|
|
5993
|
+
var realWindow = getRealWindow(this._popper);
|
|
5994
|
+
var containingBlockRect = getContainingBlockRect(this._popper, data.offsets.popper.position === 'fixed');
|
|
5995
|
+
|
|
5996
|
+
boundaries = {
|
|
5997
|
+
top: 0 - containingBlockRect.top,
|
|
5998
|
+
right: realWindow.document.documentElement.clientWidth - containingBlockRect.left,
|
|
5999
|
+
bottom: realWindow.document.documentElement.clientHeight - containingBlockRect.top,
|
|
6000
|
+
left: 0 - containingBlockRect.left
|
|
6001
|
+
};
|
|
6002
|
+
} else {
|
|
6003
|
+
if (getOffsetParent(this._popper) === boundariesElement) {
|
|
6004
|
+
boundaries = {
|
|
6005
|
+
top: 0,
|
|
6006
|
+
left: 0,
|
|
6007
|
+
right: boundariesElement.clientWidth,
|
|
6008
|
+
bottom: boundariesElement.clientHeight
|
|
6009
|
+
};
|
|
6010
|
+
} else {
|
|
6011
|
+
boundaries = getOffsetRect(boundariesElement);
|
|
6012
|
+
}
|
|
6013
|
+
}
|
|
6014
|
+
boundaries.left += padding;
|
|
6015
|
+
boundaries.right -= padding;
|
|
6016
|
+
boundaries.top = boundaries.top + padding;
|
|
6017
|
+
boundaries.bottom = boundaries.bottom - padding;
|
|
6018
|
+
return boundaries;
|
|
6019
|
+
};
|
|
6020
|
+
|
|
6087
6021
|
/**
|
|
6088
6022
|
* Loop trough the list of modifiers and run them in order, each of them will then edit the data object
|
|
6089
6023
|
* @method
|
|
@@ -6092,27 +6026,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6092
6026
|
* @param {Object} data
|
|
6093
6027
|
* @param {Array} modifiers
|
|
6094
6028
|
* @param {Function} ends
|
|
6095
|
-
*/
|
|
6096
|
-
Popper.prototype.runModifiers = function (data, modifiers, ends) {
|
|
6097
|
-
var modifiersToRun = modifiers.slice();
|
|
6098
|
-
if (ends !== undefined) {
|
|
6099
|
-
modifiersToRun = this._options.modifiers.slice(
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
);
|
|
6112
|
-
|
|
6113
|
-
return data;
|
|
6114
|
-
};
|
|
6115
|
-
|
|
6029
|
+
*/
|
|
6030
|
+
Popper.prototype.runModifiers = function (data, modifiers, ends) {
|
|
6031
|
+
var modifiersToRun = modifiers.slice();
|
|
6032
|
+
if (ends !== undefined) {
|
|
6033
|
+
modifiersToRun = this._options.modifiers.slice(0, getArrayKeyIndex(this._options.modifiers, ends));
|
|
6034
|
+
}
|
|
6035
|
+
|
|
6036
|
+
modifiersToRun.forEach(function (modifier) {
|
|
6037
|
+
if (isFunction(modifier)) {
|
|
6038
|
+
data = modifier.call(this, data);
|
|
6039
|
+
}
|
|
6040
|
+
}.bind(this));
|
|
6041
|
+
|
|
6042
|
+
return data;
|
|
6043
|
+
};
|
|
6044
|
+
|
|
6116
6045
|
/**
|
|
6117
6046
|
* Helper used to know if the given modifier depends from another one.
|
|
6118
6047
|
* @method
|
|
@@ -6120,204 +6049,191 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6120
6049
|
* @param {String} requesting - name of requesting modifier
|
|
6121
6050
|
* @param {String} requested - name of requested modifier
|
|
6122
6051
|
* @returns {Boolean}
|
|
6123
|
-
*/
|
|
6124
|
-
Popper.prototype.isModifierRequired = function (requesting, requested) {
|
|
6125
|
-
var index = getArrayKeyIndex(this._options.modifiers, requesting);
|
|
6126
|
-
return !!this._options.modifiers.slice(0, index).filter(function (modifier) {
|
|
6127
|
-
return modifier === requested;
|
|
6128
|
-
}).length;
|
|
6129
|
-
};
|
|
6130
|
-
|
|
6131
|
-
//
|
|
6132
|
-
// Modifiers
|
|
6133
|
-
//
|
|
6134
|
-
|
|
6052
|
+
*/
|
|
6053
|
+
Popper.prototype.isModifierRequired = function (requesting, requested) {
|
|
6054
|
+
var index = getArrayKeyIndex(this._options.modifiers, requesting);
|
|
6055
|
+
return !!this._options.modifiers.slice(0, index).filter(function (modifier) {
|
|
6056
|
+
return modifier === requested;
|
|
6057
|
+
}).length;
|
|
6058
|
+
};
|
|
6059
|
+
|
|
6060
|
+
//
|
|
6061
|
+
// Modifiers
|
|
6062
|
+
//
|
|
6063
|
+
|
|
6135
6064
|
/**
|
|
6136
6065
|
* Modifiers list
|
|
6137
6066
|
* @namespace Popper.modifiers
|
|
6138
6067
|
* @memberof Popper
|
|
6139
6068
|
* @type {Object}
|
|
6140
|
-
*/
|
|
6141
|
-
Popper.prototype.modifiers = {};
|
|
6142
|
-
|
|
6069
|
+
*/
|
|
6070
|
+
Popper.prototype.modifiers = {};
|
|
6071
|
+
|
|
6143
6072
|
/**
|
|
6144
6073
|
* Apply the computed styles to the popper element
|
|
6145
6074
|
* @method
|
|
6146
6075
|
* @memberof Popper.modifiers
|
|
6147
6076
|
* @argument {Object} data - The data object generated by `update` method
|
|
6148
6077
|
* @returns {Object} The same data object
|
|
6149
|
-
*/
|
|
6150
|
-
Popper.prototype.modifiers.applyStyle = function (data) {
|
|
6151
|
-
// apply the final offsets to the popper
|
|
6152
|
-
// NOTE: 1 DOM access here
|
|
6153
|
-
var styles = {
|
|
6154
|
-
position: data.offsets.popper.position
|
|
6155
|
-
};
|
|
6156
|
-
|
|
6157
|
-
// round top and left to avoid blurry text
|
|
6158
|
-
var left = Math.round(data.offsets.popper.left);
|
|
6159
|
-
var top = Math.round(data.offsets.popper.top);
|
|
6160
|
-
|
|
6161
|
-
// if gpuAcceleration is set to true and transform is supported, we use `translate3d` to apply the position to the popper
|
|
6162
|
-
// we automatically use the supported prefixed version if needed
|
|
6163
|
-
var prefixedProperty;
|
|
6164
|
-
if (
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
//
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
this.modifiers.arrow
|
|
6196
|
-
) &&
|
|
6197
|
-
data.offsets.arrow
|
|
6198
|
-
) {
|
|
6199
|
-
setStyle(data.arrowElement, data.offsets.arrow);
|
|
6200
|
-
}
|
|
6201
|
-
|
|
6202
|
-
return data;
|
|
6203
|
-
};
|
|
6204
|
-
|
|
6078
|
+
*/
|
|
6079
|
+
Popper.prototype.modifiers.applyStyle = function (data) {
|
|
6080
|
+
// apply the final offsets to the popper
|
|
6081
|
+
// NOTE: 1 DOM access here
|
|
6082
|
+
var styles = {
|
|
6083
|
+
position: data.offsets.popper.position
|
|
6084
|
+
};
|
|
6085
|
+
|
|
6086
|
+
// round top and left to avoid blurry text
|
|
6087
|
+
var left = Math.round(data.offsets.popper.left);
|
|
6088
|
+
var top = Math.round(data.offsets.popper.top);
|
|
6089
|
+
|
|
6090
|
+
// if gpuAcceleration is set to true and transform is supported, we use `translate3d` to apply the position to the popper
|
|
6091
|
+
// we automatically use the supported prefixed version if needed
|
|
6092
|
+
var prefixedProperty;
|
|
6093
|
+
if (this._options.gpuAcceleration && (prefixedProperty = getSupportedPropertyName('transform'))) {
|
|
6094
|
+
styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
|
|
6095
|
+
styles.top = 0;
|
|
6096
|
+
styles.left = 0;
|
|
6097
|
+
}
|
|
6098
|
+
// othwerise, we use the standard `left` and `top` properties
|
|
6099
|
+
else {
|
|
6100
|
+
styles.left = left;
|
|
6101
|
+
styles.top = top;
|
|
6102
|
+
}
|
|
6103
|
+
|
|
6104
|
+
// any property present in `data.styles` will be applied to the popper,
|
|
6105
|
+
// in this way we can make the 3rd party modifiers add custom styles to it
|
|
6106
|
+
// Be aware, modifiers could override the properties defined in the previous
|
|
6107
|
+
// lines of this modifier!
|
|
6108
|
+
Object.assign(styles, data.styles);
|
|
6109
|
+
|
|
6110
|
+
setStyle(this._popper, styles);
|
|
6111
|
+
|
|
6112
|
+
// set an attribute which will be useful to style the tooltip (use it to properly position its arrow)
|
|
6113
|
+
// NOTE: 1 DOM access here
|
|
6114
|
+
this._popper.setAttribute('x-placement', data.placement);
|
|
6115
|
+
|
|
6116
|
+
// if the arrow modifier is required and the arrow style has been computed, apply the arrow style
|
|
6117
|
+
if (this.isModifierRequired(this.modifiers.applyStyle, this.modifiers.arrow) && data.offsets.arrow) {
|
|
6118
|
+
setStyle(data.arrowElement, data.offsets.arrow);
|
|
6119
|
+
}
|
|
6120
|
+
|
|
6121
|
+
return data;
|
|
6122
|
+
};
|
|
6123
|
+
|
|
6205
6124
|
/**
|
|
6206
6125
|
* Modifier used to shift the popper on the start or end of its reference element side
|
|
6207
6126
|
* @method
|
|
6208
6127
|
* @memberof Popper.modifiers
|
|
6209
6128
|
* @argument {Object} data - The data object generated by `update` method
|
|
6210
6129
|
* @returns {Object} The data object, properly modified
|
|
6211
|
-
*/
|
|
6212
|
-
Popper.prototype.modifiers.shift = function (data) {
|
|
6213
|
-
var placement = data.placement;
|
|
6214
|
-
var basePlacement = placement.split('-')[0];
|
|
6215
|
-
var shiftVariation = placement.split('-')[1];
|
|
6216
|
-
|
|
6217
|
-
// if shift shiftVariation is specified, run the modifier
|
|
6218
|
-
if (shiftVariation) {
|
|
6219
|
-
var reference = data.offsets.reference;
|
|
6220
|
-
var popper = getPopperClientRect(data.offsets.popper);
|
|
6221
|
-
|
|
6222
|
-
var shiftOffsets = {
|
|
6223
|
-
y: {
|
|
6224
|
-
start: { top: reference.top },
|
|
6225
|
-
end: { top: reference.top + reference.height - popper.height }
|
|
6226
|
-
},
|
|
6227
|
-
x: {
|
|
6228
|
-
start: { left: reference.left },
|
|
6229
|
-
end: { left: reference.left + reference.width - popper.width }
|
|
6230
|
-
}
|
|
6231
|
-
};
|
|
6232
|
-
|
|
6233
|
-
var axis = ['bottom', 'top'].indexOf(basePlacement) !== -1 ? 'x' : 'y';
|
|
6234
|
-
|
|
6235
|
-
data.offsets.popper = Object.assign(
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
return data;
|
|
6242
|
-
};
|
|
6243
|
-
|
|
6130
|
+
*/
|
|
6131
|
+
Popper.prototype.modifiers.shift = function (data) {
|
|
6132
|
+
var placement = data.placement;
|
|
6133
|
+
var basePlacement = placement.split('-')[0];
|
|
6134
|
+
var shiftVariation = placement.split('-')[1];
|
|
6135
|
+
|
|
6136
|
+
// if shift shiftVariation is specified, run the modifier
|
|
6137
|
+
if (shiftVariation) {
|
|
6138
|
+
var reference = data.offsets.reference;
|
|
6139
|
+
var popper = getPopperClientRect(data.offsets.popper);
|
|
6140
|
+
|
|
6141
|
+
var shiftOffsets = {
|
|
6142
|
+
y: {
|
|
6143
|
+
start: { top: reference.top },
|
|
6144
|
+
end: { top: reference.top + reference.height - popper.height }
|
|
6145
|
+
},
|
|
6146
|
+
x: {
|
|
6147
|
+
start: { left: reference.left },
|
|
6148
|
+
end: { left: reference.left + reference.width - popper.width }
|
|
6149
|
+
}
|
|
6150
|
+
};
|
|
6151
|
+
|
|
6152
|
+
var axis = ['bottom', 'top'].indexOf(basePlacement) !== -1 ? 'x' : 'y';
|
|
6153
|
+
|
|
6154
|
+
data.offsets.popper = Object.assign(popper, shiftOffsets[axis][shiftVariation]);
|
|
6155
|
+
}
|
|
6156
|
+
|
|
6157
|
+
return data;
|
|
6158
|
+
};
|
|
6159
|
+
|
|
6244
6160
|
/**
|
|
6245
6161
|
* Modifier used to make sure the popper does not overflows from it's boundaries
|
|
6246
6162
|
* @method
|
|
6247
6163
|
* @memberof Popper.modifiers
|
|
6248
6164
|
* @argument {Object} data - The data object generated by `update` method
|
|
6249
6165
|
* @returns {Object} The data object, properly modified
|
|
6250
|
-
*/
|
|
6251
|
-
Popper.prototype.modifiers.preventOverflow = function (data) {
|
|
6252
|
-
var order = this._options.preventOverflowOrder;
|
|
6253
|
-
var popper = getPopperClientRect(data.offsets.popper);
|
|
6254
|
-
|
|
6255
|
-
var check = {
|
|
6256
|
-
left: function () {
|
|
6257
|
-
var left = popper.left;
|
|
6258
|
-
if (popper.left < data.boundaries.left) {
|
|
6259
|
-
left = Math.max(popper.left, data.boundaries.left);
|
|
6260
|
-
}
|
|
6261
|
-
return { left: left };
|
|
6262
|
-
},
|
|
6263
|
-
right: function () {
|
|
6264
|
-
var left = popper.left;
|
|
6265
|
-
if (popper.right > data.boundaries.right) {
|
|
6266
|
-
left = Math.min(popper.left, data.boundaries.right - popper.width);
|
|
6267
|
-
}
|
|
6268
|
-
return { left: left };
|
|
6269
|
-
},
|
|
6270
|
-
top: function () {
|
|
6271
|
-
var top = popper.top;
|
|
6272
|
-
if (popper.top < data.boundaries.top) {
|
|
6273
|
-
top = Math.max(popper.top, data.boundaries.top);
|
|
6274
|
-
}
|
|
6275
|
-
return { top: top };
|
|
6276
|
-
},
|
|
6277
|
-
bottom: function () {
|
|
6278
|
-
var top = popper.top;
|
|
6279
|
-
if (popper.bottom > data.boundaries.bottom) {
|
|
6280
|
-
top = Math.min(popper.top, data.boundaries.bottom - popper.height);
|
|
6281
|
-
}
|
|
6282
|
-
return { top: top };
|
|
6283
|
-
}
|
|
6284
|
-
};
|
|
6285
|
-
|
|
6286
|
-
order.forEach(function (direction) {
|
|
6287
|
-
data.offsets.popper = Object.assign(popper, check[direction]());
|
|
6288
|
-
});
|
|
6289
|
-
|
|
6290
|
-
return data;
|
|
6291
|
-
};
|
|
6292
|
-
|
|
6166
|
+
*/
|
|
6167
|
+
Popper.prototype.modifiers.preventOverflow = function (data) {
|
|
6168
|
+
var order = this._options.preventOverflowOrder;
|
|
6169
|
+
var popper = getPopperClientRect(data.offsets.popper);
|
|
6170
|
+
|
|
6171
|
+
var check = {
|
|
6172
|
+
left: function left() {
|
|
6173
|
+
var left = popper.left;
|
|
6174
|
+
if (popper.left < data.boundaries.left) {
|
|
6175
|
+
left = Math.max(popper.left, data.boundaries.left);
|
|
6176
|
+
}
|
|
6177
|
+
return { left: left };
|
|
6178
|
+
},
|
|
6179
|
+
right: function right() {
|
|
6180
|
+
var left = popper.left;
|
|
6181
|
+
if (popper.right > data.boundaries.right) {
|
|
6182
|
+
left = Math.min(popper.left, data.boundaries.right - popper.width);
|
|
6183
|
+
}
|
|
6184
|
+
return { left: left };
|
|
6185
|
+
},
|
|
6186
|
+
top: function top() {
|
|
6187
|
+
var top = popper.top;
|
|
6188
|
+
if (popper.top < data.boundaries.top) {
|
|
6189
|
+
top = Math.max(popper.top, data.boundaries.top);
|
|
6190
|
+
}
|
|
6191
|
+
return { top: top };
|
|
6192
|
+
},
|
|
6193
|
+
bottom: function bottom() {
|
|
6194
|
+
var top = popper.top;
|
|
6195
|
+
if (popper.bottom > data.boundaries.bottom) {
|
|
6196
|
+
top = Math.min(popper.top, data.boundaries.bottom - popper.height);
|
|
6197
|
+
}
|
|
6198
|
+
return { top: top };
|
|
6199
|
+
}
|
|
6200
|
+
};
|
|
6201
|
+
|
|
6202
|
+
order.forEach(function (direction) {
|
|
6203
|
+
data.offsets.popper = Object.assign(popper, check[direction]());
|
|
6204
|
+
});
|
|
6205
|
+
|
|
6206
|
+
return data;
|
|
6207
|
+
};
|
|
6208
|
+
|
|
6293
6209
|
/**
|
|
6294
6210
|
* Modifier used to make sure the popper is always near its reference
|
|
6295
6211
|
* @method
|
|
6296
6212
|
* @memberof Popper.modifiers
|
|
6297
6213
|
* @argument {Object} data - The data object generated by _update method
|
|
6298
6214
|
* @returns {Object} The data object, properly modified
|
|
6299
|
-
*/
|
|
6300
|
-
Popper.prototype.modifiers.keepTogether = function (data) {
|
|
6301
|
-
var popper = getPopperClientRect(data.offsets.popper);
|
|
6302
|
-
var reference = data.offsets.reference;
|
|
6303
|
-
var f = Math.floor;
|
|
6304
|
-
|
|
6305
|
-
if (popper.right < f(reference.left)) {
|
|
6306
|
-
data.offsets.popper.left = f(reference.left) - popper.width;
|
|
6307
|
-
}
|
|
6308
|
-
if (popper.left > f(reference.right)) {
|
|
6309
|
-
data.offsets.popper.left = f(reference.right);
|
|
6310
|
-
}
|
|
6311
|
-
if (popper.bottom < f(reference.top)) {
|
|
6312
|
-
data.offsets.popper.top = f(reference.top) - popper.height;
|
|
6313
|
-
}
|
|
6314
|
-
if (popper.top > f(reference.bottom)) {
|
|
6315
|
-
data.offsets.popper.top = f(reference.bottom);
|
|
6316
|
-
}
|
|
6317
|
-
|
|
6318
|
-
return data;
|
|
6319
|
-
};
|
|
6320
|
-
|
|
6215
|
+
*/
|
|
6216
|
+
Popper.prototype.modifiers.keepTogether = function (data) {
|
|
6217
|
+
var popper = getPopperClientRect(data.offsets.popper);
|
|
6218
|
+
var reference = data.offsets.reference;
|
|
6219
|
+
var f = Math.floor;
|
|
6220
|
+
|
|
6221
|
+
if (popper.right < f(reference.left)) {
|
|
6222
|
+
data.offsets.popper.left = f(reference.left) - popper.width;
|
|
6223
|
+
}
|
|
6224
|
+
if (popper.left > f(reference.right)) {
|
|
6225
|
+
data.offsets.popper.left = f(reference.right);
|
|
6226
|
+
}
|
|
6227
|
+
if (popper.bottom < f(reference.top)) {
|
|
6228
|
+
data.offsets.popper.top = f(reference.top) - popper.height;
|
|
6229
|
+
}
|
|
6230
|
+
if (popper.top > f(reference.bottom)) {
|
|
6231
|
+
data.offsets.popper.top = f(reference.bottom);
|
|
6232
|
+
}
|
|
6233
|
+
|
|
6234
|
+
return data;
|
|
6235
|
+
};
|
|
6236
|
+
|
|
6321
6237
|
/**
|
|
6322
6238
|
* Modifier used to flip the placement of the popper when the latter is starting overlapping its reference element.
|
|
6323
6239
|
* Requires the `preventOverflow` modifier before it in order to work.
|
|
@@ -6326,81 +6242,61 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6326
6242
|
* @memberof Popper.modifiers
|
|
6327
6243
|
* @argument {Object} data - The data object generated by _update method
|
|
6328
6244
|
* @returns {Object} The data object, properly modified
|
|
6329
|
-
*/
|
|
6330
|
-
Popper.prototype.modifiers.flip = function (data) {
|
|
6331
|
-
// check if preventOverflow is in the list of modifiers before the flip modifier.
|
|
6332
|
-
// otherwise flip would not work as expected.
|
|
6333
|
-
if (
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
) {
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
) {
|
|
6385
|
-
// we'll use this boolean to detect any flip loop
|
|
6386
|
-
data.flipped = true;
|
|
6387
|
-
data.placement = flipOrder[index + 1];
|
|
6388
|
-
if (variation) {
|
|
6389
|
-
data.placement += '-' + variation;
|
|
6390
|
-
}
|
|
6391
|
-
data.offsets.popper = this._getOffsets(
|
|
6392
|
-
this._popper,
|
|
6393
|
-
this._reference,
|
|
6394
|
-
data.placement
|
|
6395
|
-
).popper;
|
|
6396
|
-
|
|
6397
|
-
data = this.runModifiers(data, this._options.modifiers, this._flip);
|
|
6398
|
-
}
|
|
6399
|
-
}.bind(this)
|
|
6400
|
-
);
|
|
6401
|
-
return data;
|
|
6402
|
-
};
|
|
6403
|
-
|
|
6245
|
+
*/
|
|
6246
|
+
Popper.prototype.modifiers.flip = function (data) {
|
|
6247
|
+
// check if preventOverflow is in the list of modifiers before the flip modifier.
|
|
6248
|
+
// otherwise flip would not work as expected.
|
|
6249
|
+
if (!this.isModifierRequired(this.modifiers.flip, this.modifiers.preventOverflow)) {
|
|
6250
|
+
console.warn('WARNING: preventOverflow modifier is required by flip modifier in order to work, be sure to include it before flip!');
|
|
6251
|
+
return data;
|
|
6252
|
+
}
|
|
6253
|
+
|
|
6254
|
+
if (data.flipped && data.placement === data._originalPlacement) {
|
|
6255
|
+
// seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
|
|
6256
|
+
return data;
|
|
6257
|
+
}
|
|
6258
|
+
|
|
6259
|
+
var placement = data.placement.split('-')[0];
|
|
6260
|
+
var placementOpposite = getOppositePlacement(placement);
|
|
6261
|
+
var variation = data.placement.split('-')[1] || '';
|
|
6262
|
+
|
|
6263
|
+
var flipOrder = [];
|
|
6264
|
+
if (this._options.flipBehavior === 'flip') {
|
|
6265
|
+
flipOrder = [placement, placementOpposite];
|
|
6266
|
+
} else {
|
|
6267
|
+
flipOrder = this._options.flipBehavior;
|
|
6268
|
+
}
|
|
6269
|
+
|
|
6270
|
+
flipOrder.forEach(function (step, index) {
|
|
6271
|
+
if (placement !== step || flipOrder.length === index + 1) {
|
|
6272
|
+
return;
|
|
6273
|
+
}
|
|
6274
|
+
|
|
6275
|
+
placement = data.placement.split('-')[0];
|
|
6276
|
+
placementOpposite = getOppositePlacement(placement);
|
|
6277
|
+
|
|
6278
|
+
var popperOffsets = getPopperClientRect(data.offsets.popper);
|
|
6279
|
+
|
|
6280
|
+
// this boolean is used to distinguish right and bottom from top and left
|
|
6281
|
+
// they need different computations to get flipped
|
|
6282
|
+
var a = ['right', 'bottom'].indexOf(placement) !== -1;
|
|
6283
|
+
|
|
6284
|
+
// using Math.floor because the reference offsets may contain decimals we are not going to consider here
|
|
6285
|
+
if (a && Math.floor(data.offsets.reference[placement]) > Math.floor(popperOffsets[placementOpposite]) || !a && Math.floor(data.offsets.reference[placement]) < Math.floor(popperOffsets[placementOpposite])) {
|
|
6286
|
+
// we'll use this boolean to detect any flip loop
|
|
6287
|
+
data.flipped = true;
|
|
6288
|
+
data.placement = flipOrder[index + 1];
|
|
6289
|
+
if (variation) {
|
|
6290
|
+
data.placement += '-' + variation;
|
|
6291
|
+
}
|
|
6292
|
+
data.offsets.popper = this._getOffsets(this._popper, this._reference, data.placement).popper;
|
|
6293
|
+
|
|
6294
|
+
data = this.runModifiers(data, this._options.modifiers, this._flip);
|
|
6295
|
+
}
|
|
6296
|
+
}.bind(this));
|
|
6297
|
+
return data;
|
|
6298
|
+
};
|
|
6299
|
+
|
|
6404
6300
|
/**
|
|
6405
6301
|
* Modifier used to add an offset to the popper, useful if you more granularity positioning your popper.
|
|
6406
6302
|
* The offsets will shift the popper on the side of its reference element.
|
|
@@ -6408,23 +6304,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6408
6304
|
* @memberof Popper.modifiers
|
|
6409
6305
|
* @argument {Object} data - The data object generated by _update method
|
|
6410
6306
|
* @returns {Object} The data object, properly modified
|
|
6411
|
-
*/
|
|
6412
|
-
Popper.prototype.modifiers.offset = function (data) {
|
|
6413
|
-
var offset = this._options.offset;
|
|
6414
|
-
var popper = data.offsets.popper;
|
|
6415
|
-
|
|
6416
|
-
if (data.placement.indexOf('left') !== -1) {
|
|
6417
|
-
popper.top -= offset;
|
|
6418
|
-
} else if (data.placement.indexOf('right') !== -1) {
|
|
6419
|
-
popper.top += offset;
|
|
6420
|
-
} else if (data.placement.indexOf('top') !== -1) {
|
|
6421
|
-
popper.left -= offset;
|
|
6422
|
-
} else if (data.placement.indexOf('bottom') !== -1) {
|
|
6423
|
-
popper.left += offset;
|
|
6424
|
-
}
|
|
6425
|
-
return data;
|
|
6426
|
-
};
|
|
6427
|
-
|
|
6307
|
+
*/
|
|
6308
|
+
Popper.prototype.modifiers.offset = function (data) {
|
|
6309
|
+
var offset = this._options.offset;
|
|
6310
|
+
var popper = data.offsets.popper;
|
|
6311
|
+
|
|
6312
|
+
if (data.placement.indexOf('left') !== -1) {
|
|
6313
|
+
popper.top -= offset;
|
|
6314
|
+
} else if (data.placement.indexOf('right') !== -1) {
|
|
6315
|
+
popper.top += offset;
|
|
6316
|
+
} else if (data.placement.indexOf('top') !== -1) {
|
|
6317
|
+
popper.left -= offset;
|
|
6318
|
+
} else if (data.placement.indexOf('bottom') !== -1) {
|
|
6319
|
+
popper.left += offset;
|
|
6320
|
+
}
|
|
6321
|
+
return data;
|
|
6322
|
+
};
|
|
6323
|
+
|
|
6428
6324
|
/**
|
|
6429
6325
|
* 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
|
|
6430
6326
|
* It will use the CSS outer size of the arrow element to know how many pixels of conjuction are needed
|
|
@@ -6432,147 +6328,136 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6432
6328
|
* @memberof Popper.modifiers
|
|
6433
6329
|
* @argument {Object} data - The data object generated by _update method
|
|
6434
6330
|
* @returns {Object} The data object, properly modified
|
|
6435
|
-
*/
|
|
6436
|
-
Popper.prototype.modifiers.arrow = function (data) {
|
|
6437
|
-
var arrow = this._options.arrowElement;
|
|
6438
|
-
var arrowOffset = this._options.arrowOffset;
|
|
6439
|
-
|
|
6440
|
-
// if the arrowElement is a string, suppose it's a CSS selector
|
|
6441
|
-
if (typeof arrow === 'string') {
|
|
6442
|
-
arrow = this._popper.querySelector(arrow);
|
|
6443
|
-
}
|
|
6444
|
-
|
|
6445
|
-
// if arrow element is not found, don't run the modifier
|
|
6446
|
-
if (!arrow) {
|
|
6447
|
-
return data;
|
|
6448
|
-
}
|
|
6449
|
-
|
|
6450
|
-
// the arrow element must be child of its popper
|
|
6451
|
-
if (!this._popper.contains(arrow)) {
|
|
6452
|
-
console.warn(
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
)
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
var
|
|
6472
|
-
var
|
|
6473
|
-
var
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
//
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
//
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
data.offsets.arrow = arrowStyle;
|
|
6510
|
-
data.arrowElement = arrow;
|
|
6511
|
-
|
|
6512
|
-
return data;
|
|
6513
|
-
};
|
|
6514
|
-
|
|
6515
|
-
//
|
|
6516
|
-
// Helpers
|
|
6517
|
-
//
|
|
6518
|
-
|
|
6331
|
+
*/
|
|
6332
|
+
Popper.prototype.modifiers.arrow = function (data) {
|
|
6333
|
+
var arrow = this._options.arrowElement;
|
|
6334
|
+
var arrowOffset = this._options.arrowOffset;
|
|
6335
|
+
|
|
6336
|
+
// if the arrowElement is a string, suppose it's a CSS selector
|
|
6337
|
+
if (typeof arrow === 'string') {
|
|
6338
|
+
arrow = this._popper.querySelector(arrow);
|
|
6339
|
+
}
|
|
6340
|
+
|
|
6341
|
+
// if arrow element is not found, don't run the modifier
|
|
6342
|
+
if (!arrow) {
|
|
6343
|
+
return data;
|
|
6344
|
+
}
|
|
6345
|
+
|
|
6346
|
+
// the arrow element must be child of its popper
|
|
6347
|
+
if (!this._popper.contains(arrow)) {
|
|
6348
|
+
console.warn('WARNING: `arrowElement` must be child of its popper element!');
|
|
6349
|
+
return data;
|
|
6350
|
+
}
|
|
6351
|
+
|
|
6352
|
+
// arrow depends on keepTogether in order to work
|
|
6353
|
+
if (!this.isModifierRequired(this.modifiers.arrow, this.modifiers.keepTogether)) {
|
|
6354
|
+
console.warn('WARNING: keepTogether modifier is required by arrow modifier in order to work, be sure to include it before arrow!');
|
|
6355
|
+
return data;
|
|
6356
|
+
}
|
|
6357
|
+
|
|
6358
|
+
var arrowStyle = {};
|
|
6359
|
+
var placement = data.placement.split('-')[0];
|
|
6360
|
+
var popper = getPopperClientRect(data.offsets.popper);
|
|
6361
|
+
var reference = data.offsets.reference;
|
|
6362
|
+
var isVertical = ['left', 'right'].indexOf(placement) !== -1;
|
|
6363
|
+
|
|
6364
|
+
var len = isVertical ? 'height' : 'width';
|
|
6365
|
+
var side = isVertical ? 'top' : 'left';
|
|
6366
|
+
var translate = isVertical ? 'translateY' : 'translateX';
|
|
6367
|
+
var altSide = isVertical ? 'left' : 'top';
|
|
6368
|
+
var opSide = isVertical ? 'bottom' : 'right';
|
|
6369
|
+
var arrowSize = getOuterSizes(arrow)[len];
|
|
6370
|
+
|
|
6371
|
+
//
|
|
6372
|
+
// extends keepTogether behavior making sure the popper and its reference have enough pixels in conjuction
|
|
6373
|
+
//
|
|
6374
|
+
|
|
6375
|
+
// top/left side
|
|
6376
|
+
if (reference[opSide] - arrowSize < popper[side]) {
|
|
6377
|
+
data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowSize);
|
|
6378
|
+
}
|
|
6379
|
+
// bottom/right side
|
|
6380
|
+
if (reference[side] + arrowSize > popper[opSide]) {
|
|
6381
|
+
data.offsets.popper[side] += reference[side] + arrowSize - popper[opSide];
|
|
6382
|
+
}
|
|
6383
|
+
|
|
6384
|
+
// compute center of the popper
|
|
6385
|
+
var center = reference[side] + (arrowOffset || reference[len] / 2 - arrowSize / 2);
|
|
6386
|
+
|
|
6387
|
+
var sideValue = center - popper[side];
|
|
6388
|
+
|
|
6389
|
+
// prevent arrow from being placed not contiguously to its popper
|
|
6390
|
+
sideValue = Math.max(Math.min(popper[len] - arrowSize - 8, sideValue), 8);
|
|
6391
|
+
arrowStyle[side] = sideValue;
|
|
6392
|
+
arrowStyle[altSide] = ''; // make sure to remove any old style from the arrow
|
|
6393
|
+
|
|
6394
|
+
data.offsets.arrow = arrowStyle;
|
|
6395
|
+
data.arrowElement = arrow;
|
|
6396
|
+
|
|
6397
|
+
return data;
|
|
6398
|
+
};
|
|
6399
|
+
|
|
6400
|
+
//
|
|
6401
|
+
// Helpers
|
|
6402
|
+
//
|
|
6403
|
+
|
|
6519
6404
|
/**
|
|
6520
6405
|
* Get the outer sizes of the given element (offset size + margins)
|
|
6521
6406
|
* @function
|
|
6522
6407
|
* @ignore
|
|
6523
6408
|
* @argument {Element} element
|
|
6524
6409
|
* @returns {Object} object containing width and height properties
|
|
6525
|
-
*/
|
|
6526
|
-
function getOuterSizes(element) {
|
|
6527
|
-
// NOTE: 1 DOM access here
|
|
6528
|
-
var _display = element.style.display,
|
|
6529
|
-
|
|
6530
|
-
element.style.display = 'block';
|
|
6531
|
-
element.style.visibility = 'hidden';
|
|
6532
|
-
var calcWidthToForceRepaint = element.offsetWidth;
|
|
6533
|
-
// original method
|
|
6534
|
-
var styles = getRealWindow(element).getComputedStyle(element);
|
|
6535
|
-
var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
|
|
6536
|
-
var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
|
|
6537
|
-
var result = {
|
|
6538
|
-
width: element.offsetWidth + y,
|
|
6539
|
-
height: element.offsetHeight + x
|
|
6540
|
-
};
|
|
6541
|
-
|
|
6542
|
-
// reset element styles
|
|
6543
|
-
element.style.display = _display;
|
|
6544
|
-
element.style.visibility = _visibility;
|
|
6545
|
-
return result;
|
|
6546
|
-
}
|
|
6547
|
-
|
|
6410
|
+
*/
|
|
6411
|
+
function getOuterSizes(element) {
|
|
6412
|
+
// NOTE: 1 DOM access here
|
|
6413
|
+
var _display = element.style.display,
|
|
6414
|
+
_visibility = element.style.visibility;
|
|
6415
|
+
element.style.display = 'block';
|
|
6416
|
+
element.style.visibility = 'hidden';
|
|
6417
|
+
var calcWidthToForceRepaint = element.offsetWidth;
|
|
6418
|
+
// original method
|
|
6419
|
+
var styles = getRealWindow(element).getComputedStyle(element);
|
|
6420
|
+
var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
|
|
6421
|
+
var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
|
|
6422
|
+
var result = {
|
|
6423
|
+
width: element.offsetWidth + y,
|
|
6424
|
+
height: element.offsetHeight + x
|
|
6425
|
+
};
|
|
6426
|
+
|
|
6427
|
+
// reset element styles
|
|
6428
|
+
element.style.display = _display;
|
|
6429
|
+
element.style.visibility = _visibility;
|
|
6430
|
+
return result;
|
|
6431
|
+
}
|
|
6432
|
+
|
|
6548
6433
|
/**
|
|
6549
6434
|
* Get the opposite placement of the given one/
|
|
6550
6435
|
* @function
|
|
6551
6436
|
* @ignore
|
|
6552
6437
|
* @argument {String} placement
|
|
6553
6438
|
* @returns {String} flipped placement
|
|
6554
|
-
*/
|
|
6555
|
-
function getOppositePlacement(placement) {
|
|
6556
|
-
var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
|
|
6557
|
-
return placement.replace(/left|right|bottom|top/g, function (matched) {
|
|
6558
|
-
return hash[matched];
|
|
6559
|
-
});
|
|
6560
|
-
}
|
|
6561
|
-
|
|
6439
|
+
*/
|
|
6440
|
+
function getOppositePlacement(placement) {
|
|
6441
|
+
var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
|
|
6442
|
+
return placement.replace(/left|right|bottom|top/g, function (matched) {
|
|
6443
|
+
return hash[matched];
|
|
6444
|
+
});
|
|
6445
|
+
}
|
|
6446
|
+
|
|
6562
6447
|
/**
|
|
6563
6448
|
* Given the popper offsets, generate an output similar to getBoundingClientRect
|
|
6564
6449
|
* @function
|
|
6565
6450
|
* @ignore
|
|
6566
6451
|
* @argument {Object} popperOffsets
|
|
6567
6452
|
* @returns {Object} ClientRect like output
|
|
6568
|
-
*/
|
|
6569
|
-
function getPopperClientRect(popperOffsets) {
|
|
6570
|
-
var offsets = Object.assign({}, popperOffsets);
|
|
6571
|
-
offsets.right = offsets.left + offsets.width;
|
|
6572
|
-
offsets.bottom = offsets.top + offsets.height;
|
|
6573
|
-
return offsets;
|
|
6574
|
-
}
|
|
6575
|
-
|
|
6453
|
+
*/
|
|
6454
|
+
function getPopperClientRect(popperOffsets) {
|
|
6455
|
+
var offsets = Object.assign({}, popperOffsets);
|
|
6456
|
+
offsets.right = offsets.left + offsets.width;
|
|
6457
|
+
offsets.bottom = offsets.top + offsets.height;
|
|
6458
|
+
return offsets;
|
|
6459
|
+
}
|
|
6460
|
+
|
|
6576
6461
|
/**
|
|
6577
6462
|
* Given an array and the key to find, returns its index
|
|
6578
6463
|
* @function
|
|
@@ -6580,48 +6465,46 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6580
6465
|
* @argument {Array} arr
|
|
6581
6466
|
* @argument keyToFind
|
|
6582
6467
|
* @returns index or null
|
|
6583
|
-
*/
|
|
6584
|
-
function getArrayKeyIndex(arr, keyToFind) {
|
|
6585
|
-
var i = 0,
|
|
6586
|
-
|
|
6587
|
-
for (key in arr) {
|
|
6588
|
-
if (arr[key] === keyToFind) {
|
|
6589
|
-
return i;
|
|
6590
|
-
}
|
|
6591
|
-
i++;
|
|
6592
|
-
}
|
|
6593
|
-
return null;
|
|
6594
|
-
}
|
|
6595
|
-
|
|
6596
|
-
/**
|
|
6597
|
-
* Get CSS computed property of the given element
|
|
6468
|
+
*/
|
|
6469
|
+
function getArrayKeyIndex(arr, keyToFind) {
|
|
6470
|
+
var i = 0,
|
|
6471
|
+
key;
|
|
6472
|
+
for (key in arr) {
|
|
6473
|
+
if (arr[key] === keyToFind) {
|
|
6474
|
+
return i;
|
|
6475
|
+
}
|
|
6476
|
+
i++;
|
|
6477
|
+
}
|
|
6478
|
+
return null;
|
|
6479
|
+
}
|
|
6480
|
+
|
|
6481
|
+
/**
|
|
6482
|
+
* Get CSS computed property of the given element
|
|
6598
6483
|
* @function
|
|
6599
6484
|
* @ignore
|
|
6600
6485
|
* @argument {Eement} element
|
|
6601
6486
|
* @argument {String} property
|
|
6602
|
-
*/
|
|
6603
|
-
function getStyleComputedProperty(element, property) {
|
|
6604
|
-
// NOTE: 1 DOM access here
|
|
6605
|
-
// 无界等微前端场景下沙箱 window 与元素实际渲染所在 window 可能不一致,
|
|
6606
|
-
// 需使用元素自身的 view 读取计算样式,避免跨 document 读取到空值
|
|
6607
|
-
var css = getRealWindow(element).getComputedStyle(element, null);
|
|
6608
|
-
return css[property];
|
|
6609
|
-
}
|
|
6610
|
-
|
|
6487
|
+
*/
|
|
6488
|
+
function getStyleComputedProperty(element, property) {
|
|
6489
|
+
// NOTE: 1 DOM access here
|
|
6490
|
+
// 无界等微前端场景下沙箱 window 与元素实际渲染所在 window 可能不一致,
|
|
6491
|
+
// 需使用元素自身的 view 读取计算样式,避免跨 document 读取到空值
|
|
6492
|
+
var css = getRealWindow(element).getComputedStyle(element, null);
|
|
6493
|
+
return css[property];
|
|
6494
|
+
}
|
|
6495
|
+
|
|
6611
6496
|
/**
|
|
6612
6497
|
* Returns the offset parent of the given element
|
|
6613
6498
|
* @function
|
|
6614
6499
|
* @ignore
|
|
6615
6500
|
* @argument {Element} element
|
|
6616
6501
|
* @returns {Element} offset parent
|
|
6617
|
-
*/
|
|
6618
|
-
function getOffsetParent(element) {
|
|
6619
|
-
var offsetParent = element.offsetParent;
|
|
6620
|
-
return offsetParent === root.document.body || !offsetParent
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
}
|
|
6624
|
-
|
|
6502
|
+
*/
|
|
6503
|
+
function getOffsetParent(element) {
|
|
6504
|
+
var offsetParent = element.offsetParent;
|
|
6505
|
+
return offsetParent === root.document.body || !offsetParent ? root.document.documentElement : offsetParent;
|
|
6506
|
+
}
|
|
6507
|
+
|
|
6625
6508
|
/**
|
|
6626
6509
|
* Returns the window the given element actually renders in.
|
|
6627
6510
|
* 无界等微前端场景下组件代码运行在沙箱 window 中,而 DOM 实际渲染在
|
|
@@ -6630,16 +6513,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6630
6513
|
* @ignore
|
|
6631
6514
|
* @argument {Element} element
|
|
6632
6515
|
* @returns {Window} window
|
|
6633
|
-
*/
|
|
6634
|
-
function getRealWindow(element) {
|
|
6635
|
-
return
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
element.ownerDocument.defaultView) ||
|
|
6639
|
-
root
|
|
6640
|
-
);
|
|
6641
|
-
}
|
|
6642
|
-
|
|
6516
|
+
*/
|
|
6517
|
+
function getRealWindow(element) {
|
|
6518
|
+
return element && element.ownerDocument && element.ownerDocument.defaultView || root;
|
|
6519
|
+
}
|
|
6520
|
+
|
|
6643
6521
|
/**
|
|
6644
6522
|
* Returns the viewport rect of the containing block actually used to position the popper.
|
|
6645
6523
|
* 无界微前端等场景下 popper 被挂载进子应用的 shadowRoot,offsetParent 的兜底值
|
|
@@ -6653,82 +6531,72 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6653
6531
|
* @argument {Element} element - popper element
|
|
6654
6532
|
* @argument {Boolean} fixed - whether the popper is fixed positioned
|
|
6655
6533
|
* @returns {Object} rect
|
|
6656
|
-
*/
|
|
6657
|
-
function getContainingBlockRect(element, fixed) {
|
|
6658
|
-
if (fixed) {
|
|
6659
|
-
return { top: 0, left: 0, right: 0, bottom: 0 };
|
|
6660
|
-
}
|
|
6661
|
-
|
|
6662
|
-
var node = element.parentNode;
|
|
6663
|
-
while (node) {
|
|
6664
|
-
if (node.nodeType === 1) {
|
|
6665
|
-
if (getStyleComputedProperty(node, 'position') !== 'static') {
|
|
6666
|
-
return getBoundingClientRect(node);
|
|
6667
|
-
}
|
|
6668
|
-
} else if (node.nodeType === 11) {
|
|
6669
|
-
// 遇到 shadowRoot,跨边界从宿主元素继续向上查找
|
|
6670
|
-
node = node.host;
|
|
6671
|
-
continue;
|
|
6672
|
-
} else {
|
|
6673
|
-
break;
|
|
6674
|
-
}
|
|
6675
|
-
node = node.parentNode;
|
|
6676
|
-
}
|
|
6677
|
-
|
|
6678
|
-
var win = getRealWindow(element);
|
|
6679
|
-
return {
|
|
6680
|
-
top: -(win.pageYOffset || 0),
|
|
6681
|
-
left: -(win.pageXOffset || 0),
|
|
6682
|
-
right: 0,
|
|
6683
|
-
bottom: 0
|
|
6684
|
-
};
|
|
6685
|
-
}
|
|
6686
|
-
|
|
6534
|
+
*/
|
|
6535
|
+
function getContainingBlockRect(element, fixed) {
|
|
6536
|
+
if (fixed) {
|
|
6537
|
+
return { top: 0, left: 0, right: 0, bottom: 0 };
|
|
6538
|
+
}
|
|
6539
|
+
|
|
6540
|
+
var node = element.parentNode;
|
|
6541
|
+
while (node) {
|
|
6542
|
+
if (node.nodeType === 1) {
|
|
6543
|
+
if (getStyleComputedProperty(node, 'position') !== 'static') {
|
|
6544
|
+
return getBoundingClientRect(node);
|
|
6545
|
+
}
|
|
6546
|
+
} else if (node.nodeType === 11) {
|
|
6547
|
+
// 遇到 shadowRoot,跨边界从宿主元素继续向上查找
|
|
6548
|
+
node = node.host;
|
|
6549
|
+
continue;
|
|
6550
|
+
} else {
|
|
6551
|
+
break;
|
|
6552
|
+
}
|
|
6553
|
+
node = node.parentNode;
|
|
6554
|
+
}
|
|
6555
|
+
|
|
6556
|
+
var win = getRealWindow(element);
|
|
6557
|
+
return {
|
|
6558
|
+
top: -(win.pageYOffset || 0),
|
|
6559
|
+
left: -(win.pageXOffset || 0),
|
|
6560
|
+
right: 0,
|
|
6561
|
+
bottom: 0
|
|
6562
|
+
};
|
|
6563
|
+
}
|
|
6564
|
+
|
|
6687
6565
|
/**
|
|
6688
6566
|
* Returns the scrolling parent of the given element
|
|
6689
6567
|
* @function
|
|
6690
6568
|
* @ignore
|
|
6691
6569
|
* @argument {Element} element
|
|
6692
6570
|
* @returns {Element} offset parent
|
|
6693
|
-
*/
|
|
6694
|
-
function getScrollParent(element) {
|
|
6695
|
-
var parent = element.parentNode;
|
|
6696
|
-
if (!parent) {
|
|
6697
|
-
return element;
|
|
6698
|
-
}
|
|
6699
|
-
|
|
6700
|
-
if (parent.nodeType === 11) {
|
|
6701
|
-
// 无界等微前端场景 DOM 位于 shadowRoot 内,需跨边界从宿主元素继续向上查找,
|
|
6702
|
-
// 否则查找到 shadowRoot 即终止,滚动事件无法被监听
|
|
6703
|
-
return getScrollParent(parent.host);
|
|
6704
|
-
}
|
|
6705
|
-
|
|
6706
|
-
if (parent.nodeType !== 1) {
|
|
6707
|
-
// 到达 document,返回元素实际渲染所在的真实 window,
|
|
6708
|
-
// 保证 window 滚动时能触发位置更新
|
|
6709
|
-
return getRealWindow(element);
|
|
6710
|
-
}
|
|
6711
|
-
|
|
6712
|
-
// Firefox want us to check `-x` and `-y` variations as well
|
|
6713
|
-
if (
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
) !== -1
|
|
6723
|
-
) {
|
|
6724
|
-
// If the detected scrollParent is body, we perform an additional check on its parentNode
|
|
6725
|
-
// in this way we'll get body if the browser is Chrome-ish, or documentElement otherwise
|
|
6726
|
-
// fixes issue #65
|
|
6727
|
-
return parent;
|
|
6728
|
-
}
|
|
6729
|
-
return getScrollParent(parent);
|
|
6730
|
-
}
|
|
6731
|
-
|
|
6571
|
+
*/
|
|
6572
|
+
function getScrollParent(element) {
|
|
6573
|
+
var parent = element.parentNode;
|
|
6574
|
+
if (!parent) {
|
|
6575
|
+
return element;
|
|
6576
|
+
}
|
|
6577
|
+
|
|
6578
|
+
if (parent.nodeType === 11) {
|
|
6579
|
+
// 无界等微前端场景 DOM 位于 shadowRoot 内,需跨边界从宿主元素继续向上查找,
|
|
6580
|
+
// 否则查找到 shadowRoot 即终止,滚动事件无法被监听
|
|
6581
|
+
return getScrollParent(parent.host);
|
|
6582
|
+
}
|
|
6583
|
+
|
|
6584
|
+
if (parent.nodeType !== 1) {
|
|
6585
|
+
// 到达 document,返回元素实际渲染所在的真实 window,
|
|
6586
|
+
// 保证 window 滚动时能触发位置更新
|
|
6587
|
+
return getRealWindow(element);
|
|
6588
|
+
}
|
|
6589
|
+
|
|
6590
|
+
// Firefox want us to check `-x` and `-y` variations as well
|
|
6591
|
+
if (['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow')) !== -1 || ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-x')) !== -1 || ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-y')) !== -1) {
|
|
6592
|
+
// If the detected scrollParent is body, we perform an additional check on its parentNode
|
|
6593
|
+
// in this way we'll get body if the browser is Chrome-ish, or documentElement otherwise
|
|
6594
|
+
// fixes issue #65
|
|
6595
|
+
return parent;
|
|
6596
|
+
}
|
|
6597
|
+
return getScrollParent(parent);
|
|
6598
|
+
}
|
|
6599
|
+
|
|
6732
6600
|
/**
|
|
6733
6601
|
* Check if the given element is fixed or is inside a fixed parent
|
|
6734
6602
|
* @function
|
|
@@ -6736,125 +6604,114 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6736
6604
|
* @argument {Element} element
|
|
6737
6605
|
* @argument {Element} customContainer
|
|
6738
6606
|
* @returns {Boolean} answer to "isFixed?"
|
|
6739
|
-
*/
|
|
6740
|
-
function isFixed(element) {
|
|
6741
|
-
if (element === root.document.body) {
|
|
6742
|
-
return false;
|
|
6743
|
-
}
|
|
6744
|
-
if (getStyleComputedProperty(element, 'position') === 'fixed') {
|
|
6745
|
-
return true;
|
|
6746
|
-
}
|
|
6747
|
-
var parent = element.parentNode;
|
|
6748
|
-
if (parent && parent.nodeType === 11) {
|
|
6749
|
-
// 跨 shadowRoot 边界,从宿主元素继续向上判断
|
|
6750
|
-
parent = parent.host;
|
|
6751
|
-
}
|
|
6752
|
-
return parent && parent.nodeType === 1 ? isFixed(parent) : false;
|
|
6753
|
-
}
|
|
6754
|
-
|
|
6607
|
+
*/
|
|
6608
|
+
function isFixed(element) {
|
|
6609
|
+
if (element === root.document.body) {
|
|
6610
|
+
return false;
|
|
6611
|
+
}
|
|
6612
|
+
if (getStyleComputedProperty(element, 'position') === 'fixed') {
|
|
6613
|
+
return true;
|
|
6614
|
+
}
|
|
6615
|
+
var parent = element.parentNode;
|
|
6616
|
+
if (parent && parent.nodeType === 11) {
|
|
6617
|
+
// 跨 shadowRoot 边界,从宿主元素继续向上判断
|
|
6618
|
+
parent = parent.host;
|
|
6619
|
+
}
|
|
6620
|
+
return parent && parent.nodeType === 1 ? isFixed(parent) : false;
|
|
6621
|
+
}
|
|
6622
|
+
|
|
6755
6623
|
/**
|
|
6756
6624
|
* Set the style to the given popper
|
|
6757
6625
|
* @function
|
|
6758
6626
|
* @ignore
|
|
6759
6627
|
* @argument {Element} element - Element to apply the style to
|
|
6760
6628
|
* @argument {Object} styles - Object with a list of properties and values which will be applied to the element
|
|
6761
|
-
*/
|
|
6762
|
-
function setStyle(element, styles) {
|
|
6763
|
-
function is_numeric(n) {
|
|
6764
|
-
return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
|
|
6765
|
-
}
|
|
6766
|
-
Object.keys(styles).forEach(function (prop) {
|
|
6767
|
-
var unit = '';
|
|
6768
|
-
// add unit if the value is numeric and is one of the following
|
|
6769
|
-
if (
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
element.style[prop] = styles[prop] + unit;
|
|
6777
|
-
});
|
|
6778
|
-
}
|
|
6779
|
-
|
|
6629
|
+
*/
|
|
6630
|
+
function setStyle(element, styles) {
|
|
6631
|
+
function is_numeric(n) {
|
|
6632
|
+
return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
|
|
6633
|
+
}
|
|
6634
|
+
Object.keys(styles).forEach(function (prop) {
|
|
6635
|
+
var unit = '';
|
|
6636
|
+
// add unit if the value is numeric and is one of the following
|
|
6637
|
+
if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && is_numeric(styles[prop])) {
|
|
6638
|
+
unit = 'px';
|
|
6639
|
+
}
|
|
6640
|
+
element.style[prop] = styles[prop] + unit;
|
|
6641
|
+
});
|
|
6642
|
+
}
|
|
6643
|
+
|
|
6780
6644
|
/**
|
|
6781
6645
|
* Check if the given variable is a function
|
|
6782
6646
|
* @function
|
|
6783
6647
|
* @ignore
|
|
6784
6648
|
* @argument {*} functionToCheck - variable to check
|
|
6785
6649
|
* @returns {Boolean} answer to: is a function?
|
|
6786
|
-
*/
|
|
6787
|
-
function isFunction(functionToCheck) {
|
|
6788
|
-
var getType = {};
|
|
6789
|
-
return (
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
);
|
|
6793
|
-
}
|
|
6794
|
-
|
|
6650
|
+
*/
|
|
6651
|
+
function isFunction(functionToCheck) {
|
|
6652
|
+
var getType = {};
|
|
6653
|
+
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
|
|
6654
|
+
}
|
|
6655
|
+
|
|
6795
6656
|
/**
|
|
6796
6657
|
* Get the position of the given element, relative to its offset parent
|
|
6797
6658
|
* @function
|
|
6798
6659
|
* @ignore
|
|
6799
6660
|
* @param {Element} element
|
|
6800
6661
|
* @return {Object} position - Coordinates of the element and its `scrollTop`
|
|
6801
|
-
*/
|
|
6802
|
-
function getOffsetRect(element) {
|
|
6803
|
-
var transform = getStyle(element, 'transform')
|
|
6804
|
-
|
|
6805
|
-
.
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
return elementRect;
|
|
6819
|
-
}
|
|
6820
|
-
|
|
6662
|
+
*/
|
|
6663
|
+
function getOffsetRect(element) {
|
|
6664
|
+
var transform = getStyle(element, 'transform').replace(/[^0-9\-,]/g, '').split(',');
|
|
6665
|
+
var elementRect = {
|
|
6666
|
+
width: element.offsetWidth,
|
|
6667
|
+
height: element.offsetHeight,
|
|
6668
|
+
left: element.offsetLeft + (transform[4] ? parseInt(transform[4], 10) : 0),
|
|
6669
|
+
top: element.offsetTop + (transform[5] ? parseInt(transform[5], 10) : 0)
|
|
6670
|
+
};
|
|
6671
|
+
|
|
6672
|
+
elementRect.right = elementRect.left + elementRect.width;
|
|
6673
|
+
elementRect.bottom = elementRect.top + elementRect.height;
|
|
6674
|
+
|
|
6675
|
+
// position
|
|
6676
|
+
return elementRect;
|
|
6677
|
+
}
|
|
6678
|
+
|
|
6821
6679
|
/**
|
|
6822
6680
|
* Get bounding client rect of given element
|
|
6823
6681
|
* @function
|
|
6824
6682
|
* @ignore
|
|
6825
6683
|
* @param {HTMLElement} element
|
|
6826
6684
|
* @return {Object} client rect
|
|
6827
|
-
*/
|
|
6828
|
-
function getBoundingClientRect(element) {
|
|
6829
|
-
var rect = element.getBoundingClientRect();
|
|
6830
|
-
|
|
6831
|
-
// whether the IE version is lower than 11
|
|
6832
|
-
var isIE = /MSIE|Trident/.test(navigator.userAgent);
|
|
6833
|
-
|
|
6834
|
-
// fix ie document bounding top always 0 bug
|
|
6835
|
-
var rectTop =
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6685
|
+
*/
|
|
6686
|
+
function getBoundingClientRect(element) {
|
|
6687
|
+
var rect = element.getBoundingClientRect();
|
|
6688
|
+
|
|
6689
|
+
// whether the IE version is lower than 11
|
|
6690
|
+
var isIE = /MSIE|Trident/.test(navigator.userAgent);
|
|
6691
|
+
|
|
6692
|
+
// fix ie document bounding top always 0 bug
|
|
6693
|
+
var rectTop = isIE && element.tagName === 'HTML' ? -element.scrollTop : rect.top;
|
|
6694
|
+
|
|
6695
|
+
return {
|
|
6696
|
+
left: rect.left,
|
|
6697
|
+
top: rectTop,
|
|
6698
|
+
right: rect.right,
|
|
6699
|
+
bottom: rect.bottom,
|
|
6700
|
+
width: rect.right - rect.left,
|
|
6701
|
+
height: rect.bottom - rectTop
|
|
6702
|
+
};
|
|
6703
|
+
}
|
|
6704
|
+
|
|
6705
|
+
function getStyle(dom, attr) {
|
|
6706
|
+
if (dom.style[attr]) {
|
|
6707
|
+
return dom.style[attr];
|
|
6708
|
+
}
|
|
6709
|
+
if (window.getComputedStyle) {
|
|
6710
|
+
return getComputedStyle(dom, null)[attr];
|
|
6711
|
+
}
|
|
6712
|
+
return dom.currentStyle[attr];
|
|
6713
|
+
}
|
|
6714
|
+
|
|
6858
6715
|
/**
|
|
6859
6716
|
* Given an element and one of its parents, return the offset
|
|
6860
6717
|
* @function
|
|
@@ -6862,45 +6719,43 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6862
6719
|
* @param {HTMLElement} element
|
|
6863
6720
|
* @param {HTMLElement} parent
|
|
6864
6721
|
* @return {Object} rect
|
|
6865
|
-
*/
|
|
6866
|
-
function getOffsetRectRelativeToCustomParent(element, parent, fixed) {
|
|
6867
|
-
var elementRect = getBoundingClientRect(element);
|
|
6868
|
-
// parent 为 popper 元素:取其真实包含块的视口 rect,
|
|
6869
|
-
// 避免无界 shadowRoot 等场景下包含块假设错误导致的整体偏移
|
|
6870
|
-
var parentRect = getContainingBlockRect(parent, fixed);
|
|
6871
|
-
|
|
6872
|
-
var rect = {
|
|
6873
|
-
top: elementRect.top - parentRect.top,
|
|
6874
|
-
left: elementRect.left - parentRect.left,
|
|
6875
|
-
bottom: elementRect.top - parentRect.top + elementRect.height,
|
|
6876
|
-
right: elementRect.left - parentRect.left + elementRect.width,
|
|
6877
|
-
width: elementRect.width,
|
|
6878
|
-
height: elementRect.height
|
|
6879
|
-
};
|
|
6880
|
-
return rect;
|
|
6881
|
-
}
|
|
6882
|
-
|
|
6722
|
+
*/
|
|
6723
|
+
function getOffsetRectRelativeToCustomParent(element, parent, fixed) {
|
|
6724
|
+
var elementRect = getBoundingClientRect(element);
|
|
6725
|
+
// parent 为 popper 元素:取其真实包含块的视口 rect,
|
|
6726
|
+
// 避免无界 shadowRoot 等场景下包含块假设错误导致的整体偏移
|
|
6727
|
+
var parentRect = getContainingBlockRect(parent, fixed);
|
|
6728
|
+
|
|
6729
|
+
var rect = {
|
|
6730
|
+
top: elementRect.top - parentRect.top,
|
|
6731
|
+
left: elementRect.left - parentRect.left,
|
|
6732
|
+
bottom: elementRect.top - parentRect.top + elementRect.height,
|
|
6733
|
+
right: elementRect.left - parentRect.left + elementRect.width,
|
|
6734
|
+
width: elementRect.width,
|
|
6735
|
+
height: elementRect.height
|
|
6736
|
+
};
|
|
6737
|
+
return rect;
|
|
6738
|
+
}
|
|
6739
|
+
|
|
6883
6740
|
/**
|
|
6884
6741
|
* Get the prefixed supported property name
|
|
6885
6742
|
* @function
|
|
6886
6743
|
* @ignore
|
|
6887
6744
|
* @argument {String} property (camelCase)
|
|
6888
6745
|
* @returns {String} prefixed property (camelCase)
|
|
6889
|
-
*/
|
|
6890
|
-
function getSupportedPropertyName(property) {
|
|
6891
|
-
var prefixes = ['', 'ms', 'webkit', 'moz', 'o'];
|
|
6892
|
-
|
|
6893
|
-
for (var i = 0; i < prefixes.length; i++) {
|
|
6894
|
-
var toCheck = prefixes[i]
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
|
|
6901
|
-
|
|
6902
|
-
}
|
|
6903
|
-
|
|
6746
|
+
*/
|
|
6747
|
+
function getSupportedPropertyName(property) {
|
|
6748
|
+
var prefixes = ['', 'ms', 'webkit', 'moz', 'o'];
|
|
6749
|
+
|
|
6750
|
+
for (var i = 0; i < prefixes.length; i++) {
|
|
6751
|
+
var toCheck = prefixes[i] ? prefixes[i] + property.charAt(0).toUpperCase() + property.slice(1) : property;
|
|
6752
|
+
if (typeof root.document.body.style[toCheck] !== 'undefined') {
|
|
6753
|
+
return toCheck;
|
|
6754
|
+
}
|
|
6755
|
+
}
|
|
6756
|
+
return null;
|
|
6757
|
+
}
|
|
6758
|
+
|
|
6904
6759
|
/**
|
|
6905
6760
|
* The Object.assign() method is used to copy the values of all enumerable own properties from one or more source
|
|
6906
6761
|
* objects to a target object. It will return the target object.
|
|
@@ -6908,46 +6763,41 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
6908
6763
|
* Source: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
6909
6764
|
* @function
|
|
6910
6765
|
* @ignore
|
|
6911
|
-
*/
|
|
6912
|
-
if (!Object.assign) {
|
|
6913
|
-
Object.defineProperty(Object, 'assign', {
|
|
6914
|
-
enumerable: false,
|
|
6915
|
-
configurable: true,
|
|
6916
|
-
writable: true,
|
|
6917
|
-
value: function (target) {
|
|
6918
|
-
if (target === undefined || target === null) {
|
|
6919
|
-
throw new TypeError('Cannot convert first argument to object');
|
|
6920
|
-
}
|
|
6921
|
-
|
|
6922
|
-
var to = Object(target);
|
|
6923
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
6924
|
-
var nextSource = arguments[i];
|
|
6925
|
-
if (nextSource === undefined || nextSource === null) {
|
|
6926
|
-
continue;
|
|
6927
|
-
}
|
|
6928
|
-
nextSource = Object(nextSource);
|
|
6929
|
-
|
|
6930
|
-
var keysArray = Object.keys(nextSource);
|
|
6931
|
-
for (
|
|
6932
|
-
var
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
return to;
|
|
6944
|
-
}
|
|
6945
|
-
});
|
|
6946
|
-
}
|
|
6947
|
-
|
|
6948
|
-
return Popper;
|
|
6949
|
-
});
|
|
6766
|
+
*/
|
|
6767
|
+
if (!Object.assign) {
|
|
6768
|
+
Object.defineProperty(Object, 'assign', {
|
|
6769
|
+
enumerable: false,
|
|
6770
|
+
configurable: true,
|
|
6771
|
+
writable: true,
|
|
6772
|
+
value: function value(target) {
|
|
6773
|
+
if (target === undefined || target === null) {
|
|
6774
|
+
throw new TypeError('Cannot convert first argument to object');
|
|
6775
|
+
}
|
|
6776
|
+
|
|
6777
|
+
var to = Object(target);
|
|
6778
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
6779
|
+
var nextSource = arguments[i];
|
|
6780
|
+
if (nextSource === undefined || nextSource === null) {
|
|
6781
|
+
continue;
|
|
6782
|
+
}
|
|
6783
|
+
nextSource = Object(nextSource);
|
|
6784
|
+
|
|
6785
|
+
var keysArray = Object.keys(nextSource);
|
|
6786
|
+
for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
|
|
6787
|
+
var nextKey = keysArray[nextIndex];
|
|
6788
|
+
var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
|
|
6789
|
+
if (desc !== undefined && desc.enumerable) {
|
|
6790
|
+
to[nextKey] = nextSource[nextKey];
|
|
6791
|
+
}
|
|
6792
|
+
}
|
|
6793
|
+
}
|
|
6794
|
+
return to;
|
|
6795
|
+
}
|
|
6796
|
+
});
|
|
6797
|
+
}
|
|
6950
6798
|
|
|
6799
|
+
return Popper;
|
|
6800
|
+
});
|
|
6951
6801
|
|
|
6952
6802
|
/***/ }),
|
|
6953
6803
|
|
|
@@ -7001,759 +6851,736 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
|
7001
6851
|
/* unused harmony export getSecond */
|
|
7002
6852
|
/* unused harmony export getWeekday */
|
|
7003
6853
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
* The MIT License (MIT)
|
|
7007
|
-
*
|
|
7008
|
-
* Copyright (c) 2015 Taylor Hakes
|
|
7009
|
-
*
|
|
7010
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7011
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
7012
|
-
* in the Software without restriction, including without limitation the rights
|
|
7013
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7014
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
7015
|
-
* furnished to do so, subject to the following conditions:
|
|
7016
|
-
*
|
|
7017
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
7018
|
-
* copies or substantial portions of the Software.
|
|
7019
|
-
*
|
|
7020
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
7021
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
7022
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
7023
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
7024
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
7025
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
7026
|
-
* SOFTWARE.
|
|
7027
|
-
*/
|
|
7028
|
-
|
|
7029
|
-
/*eslint-disable*/
|
|
7030
|
-
// 把 YYYY-MM-DD 改成了 yyyy-MM-dd
|
|
7031
|
-
|
|
7032
|
-
|
|
6854
|
+
|
|
6855
|
+
|
|
7033
6856
|
/**
|
|
7034
6857
|
* Parse or format dates
|
|
7035
6858
|
* @class fecha
|
|
7036
|
-
*/
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
-
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
|
|
7045
|
-
|
|
7046
|
-
function regexEscape(str) {
|
|
7047
|
-
return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
|
|
7048
|
-
}
|
|
7049
|
-
|
|
7050
|
-
function shorten(arr, sLen) {
|
|
7051
|
-
|
|
7052
|
-
for (
|
|
7053
|
-
newArr.push(arr[i].substr(0, sLen));
|
|
7054
|
-
}
|
|
7055
|
-
return newArr;
|
|
7056
|
-
}
|
|
7057
|
-
|
|
7058
|
-
function monthUpdate() {
|
|
7059
|
-
return function (d, v) {
|
|
7060
|
-
|
|
7061
|
-
if (~index) {
|
|
7062
|
-
d.month = index;
|
|
7063
|
-
}
|
|
7064
|
-
};
|
|
7065
|
-
}
|
|
7066
|
-
|
|
7067
|
-
function pad(val, len) {
|
|
7068
|
-
val = String(val);
|
|
7069
|
-
len = len || 2;
|
|
7070
|
-
while (val.length < len) {
|
|
7071
|
-
val = '0' + val;
|
|
7072
|
-
}
|
|
7073
|
-
return val;
|
|
7074
|
-
}
|
|
7075
|
-
|
|
7076
|
-
// 直接使用中文日期名称常量
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
return D + '日';
|
|
7084
|
-
};
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
D: function(dateObj) {
|
|
7088
|
-
return dateObj.getDay();
|
|
7089
|
-
},
|
|
7090
|
-
DD: function(dateObj) {
|
|
7091
|
-
return pad(dateObj.getDay());
|
|
7092
|
-
},
|
|
7093
|
-
Do: function(dateObj) {
|
|
7094
|
-
return DoFn(dateObj.getDate());
|
|
7095
|
-
},
|
|
7096
|
-
d: function(dateObj) {
|
|
7097
|
-
return dateObj.getDate();
|
|
7098
|
-
},
|
|
7099
|
-
dd: function(dateObj) {
|
|
7100
|
-
return pad(dateObj.getDate());
|
|
7101
|
-
},
|
|
7102
|
-
ddd: function(dateObj) {
|
|
7103
|
-
return dayNamesShort[dateObj.getDay()];
|
|
7104
|
-
},
|
|
7105
|
-
dddd: function(dateObj) {
|
|
7106
|
-
return dayNames[dateObj.getDay()];
|
|
7107
|
-
},
|
|
7108
|
-
M: function(dateObj) {
|
|
7109
|
-
return dateObj.getMonth() + 1;
|
|
7110
|
-
},
|
|
7111
|
-
MM: function(dateObj) {
|
|
7112
|
-
return pad(dateObj.getMonth() + 1);
|
|
7113
|
-
},
|
|
7114
|
-
MMM: function(dateObj) {
|
|
7115
|
-
return monthNamesShort[dateObj.getMonth()];
|
|
7116
|
-
},
|
|
7117
|
-
MMMM: function(dateObj) {
|
|
7118
|
-
return monthNames[dateObj.getMonth()];
|
|
7119
|
-
},
|
|
7120
|
-
yy: function(dateObj) {
|
|
7121
|
-
return pad(String(dateObj.getFullYear()), 4).substr(2);
|
|
7122
|
-
},
|
|
7123
|
-
yyyy: function(dateObj) {
|
|
7124
|
-
return pad(dateObj.getFullYear(), 4);
|
|
7125
|
-
},
|
|
7126
|
-
h: function(dateObj) {
|
|
7127
|
-
return dateObj.getHours() % 12 || 12;
|
|
7128
|
-
},
|
|
7129
|
-
hh: function(dateObj) {
|
|
7130
|
-
return pad(dateObj.getHours() % 12 || 12);
|
|
7131
|
-
},
|
|
7132
|
-
H: function(dateObj) {
|
|
7133
|
-
return dateObj.getHours();
|
|
7134
|
-
},
|
|
7135
|
-
HH: function(dateObj) {
|
|
7136
|
-
return pad(dateObj.getHours());
|
|
7137
|
-
},
|
|
7138
|
-
m: function(dateObj) {
|
|
7139
|
-
return dateObj.getMinutes();
|
|
7140
|
-
},
|
|
7141
|
-
mm: function(dateObj) {
|
|
7142
|
-
return pad(dateObj.getMinutes());
|
|
7143
|
-
},
|
|
7144
|
-
s: function(dateObj) {
|
|
7145
|
-
return dateObj.getSeconds();
|
|
7146
|
-
},
|
|
7147
|
-
ss: function(dateObj) {
|
|
7148
|
-
return pad(dateObj.getSeconds());
|
|
7149
|
-
},
|
|
7150
|
-
S: function(dateObj) {
|
|
7151
|
-
return Math.round(dateObj.getMilliseconds() / 100);
|
|
7152
|
-
},
|
|
7153
|
-
SS: function(dateObj) {
|
|
7154
|
-
return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
|
|
7155
|
-
},
|
|
7156
|
-
SSS: function(dateObj) {
|
|
7157
|
-
return pad(dateObj.getMilliseconds(), 3);
|
|
7158
|
-
},
|
|
7159
|
-
a: function(dateObj) {
|
|
7160
|
-
return dateObj.getHours() < 12 ? '上午' : '下午';
|
|
7161
|
-
},
|
|
7162
|
-
A: function(dateObj) {
|
|
7163
|
-
return dateObj.getHours() < 12 ? '上午' : '下午';
|
|
7164
|
-
},
|
|
7165
|
-
ZZ: function(dateObj) {
|
|
7166
|
-
|
|
7167
|
-
return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
|
|
7168
|
-
}
|
|
7169
|
-
};
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
d: [twoDigits, function (d, v) {
|
|
7173
|
-
d.day = v;
|
|
7174
|
-
}],
|
|
7175
|
-
Do: [twoDigits + word, function (d, v) {
|
|
7176
|
-
d.day = parseInt(v, 10);
|
|
7177
|
-
}],
|
|
7178
|
-
M: [twoDigits, function (d, v) {
|
|
7179
|
-
d.month = v - 1;
|
|
7180
|
-
}],
|
|
7181
|
-
yy: [twoDigits, function (d, v) {
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
}
|
|
7227
|
-
|
|
7228
|
-
|
|
7229
|
-
parseFlags.
|
|
7230
|
-
parseFlags.
|
|
7231
|
-
parseFlags.
|
|
7232
|
-
parseFlags.
|
|
7233
|
-
parseFlags.
|
|
7234
|
-
parseFlags.
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
6859
|
+
*/
|
|
6860
|
+
var fecha = {};
|
|
6861
|
+
var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
|
|
6862
|
+
var twoDigits = '\\d\\d?';
|
|
6863
|
+
var threeDigits = '\\d{3}';
|
|
6864
|
+
var fourDigits = '\\d{4}';
|
|
6865
|
+
var word = '[^\\s]+';
|
|
6866
|
+
var literal = /\[([^]*?)\]/gm;
|
|
6867
|
+
var noop = function noop() {};
|
|
6868
|
+
|
|
6869
|
+
function regexEscape(str) {
|
|
6870
|
+
return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
|
|
6871
|
+
}
|
|
6872
|
+
|
|
6873
|
+
function shorten(arr, sLen) {
|
|
6874
|
+
var newArr = [];
|
|
6875
|
+
for (var i = 0, len = arr.length; i < len; i++) {
|
|
6876
|
+
newArr.push(arr[i].substr(0, sLen));
|
|
6877
|
+
}
|
|
6878
|
+
return newArr;
|
|
6879
|
+
}
|
|
6880
|
+
|
|
6881
|
+
function monthUpdate() {
|
|
6882
|
+
return function (d, v) {
|
|
6883
|
+
var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
|
|
6884
|
+
if (~index) {
|
|
6885
|
+
d.month = index;
|
|
6886
|
+
}
|
|
6887
|
+
};
|
|
6888
|
+
}
|
|
6889
|
+
|
|
6890
|
+
function pad(val, len) {
|
|
6891
|
+
val = String(val);
|
|
6892
|
+
len = len || 2;
|
|
6893
|
+
while (val.length < len) {
|
|
6894
|
+
val = '0' + val;
|
|
6895
|
+
}
|
|
6896
|
+
return val;
|
|
6897
|
+
}
|
|
6898
|
+
|
|
6899
|
+
// 直接使用中文日期名称常量
|
|
6900
|
+
var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
|
|
6901
|
+
var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
|
|
6902
|
+
var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
|
|
6903
|
+
var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
|
|
6904
|
+
var amPm = ['上午', '下午'];
|
|
6905
|
+
var DoFn = function DoFn(D) {
|
|
6906
|
+
return D + '日';
|
|
6907
|
+
};
|
|
6908
|
+
|
|
6909
|
+
var formatFlags = {
|
|
6910
|
+
D: function D(dateObj) {
|
|
6911
|
+
return dateObj.getDay();
|
|
6912
|
+
},
|
|
6913
|
+
DD: function DD(dateObj) {
|
|
6914
|
+
return pad(dateObj.getDay());
|
|
6915
|
+
},
|
|
6916
|
+
Do: function Do(dateObj) {
|
|
6917
|
+
return DoFn(dateObj.getDate());
|
|
6918
|
+
},
|
|
6919
|
+
d: function d(dateObj) {
|
|
6920
|
+
return dateObj.getDate();
|
|
6921
|
+
},
|
|
6922
|
+
dd: function dd(dateObj) {
|
|
6923
|
+
return pad(dateObj.getDate());
|
|
6924
|
+
},
|
|
6925
|
+
ddd: function ddd(dateObj) {
|
|
6926
|
+
return dayNamesShort[dateObj.getDay()];
|
|
6927
|
+
},
|
|
6928
|
+
dddd: function dddd(dateObj) {
|
|
6929
|
+
return dayNames[dateObj.getDay()];
|
|
6930
|
+
},
|
|
6931
|
+
M: function M(dateObj) {
|
|
6932
|
+
return dateObj.getMonth() + 1;
|
|
6933
|
+
},
|
|
6934
|
+
MM: function MM(dateObj) {
|
|
6935
|
+
return pad(dateObj.getMonth() + 1);
|
|
6936
|
+
},
|
|
6937
|
+
MMM: function MMM(dateObj) {
|
|
6938
|
+
return monthNamesShort[dateObj.getMonth()];
|
|
6939
|
+
},
|
|
6940
|
+
MMMM: function MMMM(dateObj) {
|
|
6941
|
+
return monthNames[dateObj.getMonth()];
|
|
6942
|
+
},
|
|
6943
|
+
yy: function yy(dateObj) {
|
|
6944
|
+
return pad(String(dateObj.getFullYear()), 4).substr(2);
|
|
6945
|
+
},
|
|
6946
|
+
yyyy: function yyyy(dateObj) {
|
|
6947
|
+
return pad(dateObj.getFullYear(), 4);
|
|
6948
|
+
},
|
|
6949
|
+
h: function h(dateObj) {
|
|
6950
|
+
return dateObj.getHours() % 12 || 12;
|
|
6951
|
+
},
|
|
6952
|
+
hh: function hh(dateObj) {
|
|
6953
|
+
return pad(dateObj.getHours() % 12 || 12);
|
|
6954
|
+
},
|
|
6955
|
+
H: function H(dateObj) {
|
|
6956
|
+
return dateObj.getHours();
|
|
6957
|
+
},
|
|
6958
|
+
HH: function HH(dateObj) {
|
|
6959
|
+
return pad(dateObj.getHours());
|
|
6960
|
+
},
|
|
6961
|
+
m: function m(dateObj) {
|
|
6962
|
+
return dateObj.getMinutes();
|
|
6963
|
+
},
|
|
6964
|
+
mm: function mm(dateObj) {
|
|
6965
|
+
return pad(dateObj.getMinutes());
|
|
6966
|
+
},
|
|
6967
|
+
s: function s(dateObj) {
|
|
6968
|
+
return dateObj.getSeconds();
|
|
6969
|
+
},
|
|
6970
|
+
ss: function ss(dateObj) {
|
|
6971
|
+
return pad(dateObj.getSeconds());
|
|
6972
|
+
},
|
|
6973
|
+
S: function S(dateObj) {
|
|
6974
|
+
return Math.round(dateObj.getMilliseconds() / 100);
|
|
6975
|
+
},
|
|
6976
|
+
SS: function SS(dateObj) {
|
|
6977
|
+
return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
|
|
6978
|
+
},
|
|
6979
|
+
SSS: function SSS(dateObj) {
|
|
6980
|
+
return pad(dateObj.getMilliseconds(), 3);
|
|
6981
|
+
},
|
|
6982
|
+
a: function a(dateObj) {
|
|
6983
|
+
return dateObj.getHours() < 12 ? '上午' : '下午';
|
|
6984
|
+
},
|
|
6985
|
+
A: function A(dateObj) {
|
|
6986
|
+
return dateObj.getHours() < 12 ? '上午' : '下午';
|
|
6987
|
+
},
|
|
6988
|
+
ZZ: function ZZ(dateObj) {
|
|
6989
|
+
var o = dateObj.getTimezoneOffset();
|
|
6990
|
+
return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
|
|
6991
|
+
}
|
|
6992
|
+
};
|
|
6993
|
+
|
|
6994
|
+
var parseFlags = {
|
|
6995
|
+
d: [twoDigits, function (d, v) {
|
|
6996
|
+
d.day = v;
|
|
6997
|
+
}],
|
|
6998
|
+
Do: [twoDigits + word, function (d, v) {
|
|
6999
|
+
d.day = parseInt(v, 10);
|
|
7000
|
+
}],
|
|
7001
|
+
M: [twoDigits, function (d, v) {
|
|
7002
|
+
d.month = v - 1;
|
|
7003
|
+
}],
|
|
7004
|
+
yy: [twoDigits, function (d, v) {
|
|
7005
|
+
var da = new Date(),
|
|
7006
|
+
cent = +('' + da.getFullYear()).substr(0, 2);
|
|
7007
|
+
d.year = '' + (v > 68 ? cent - 1 : cent) + v;
|
|
7008
|
+
}],
|
|
7009
|
+
h: [twoDigits, function (d, v) {
|
|
7010
|
+
d.hour = v;
|
|
7011
|
+
}],
|
|
7012
|
+
m: [twoDigits, function (d, v) {
|
|
7013
|
+
d.minute = v;
|
|
7014
|
+
}],
|
|
7015
|
+
s: [twoDigits, function (d, v) {
|
|
7016
|
+
d.second = v;
|
|
7017
|
+
}],
|
|
7018
|
+
yyyy: [fourDigits, function (d, v) {
|
|
7019
|
+
d.year = v;
|
|
7020
|
+
}],
|
|
7021
|
+
S: ['\\d', function (d, v) {
|
|
7022
|
+
d.millisecond = v * 100;
|
|
7023
|
+
}],
|
|
7024
|
+
SS: ['\\d{2}', function (d, v) {
|
|
7025
|
+
d.millisecond = v * 10;
|
|
7026
|
+
}],
|
|
7027
|
+
SSS: [threeDigits, function (d, v) {
|
|
7028
|
+
d.millisecond = v;
|
|
7029
|
+
}],
|
|
7030
|
+
D: [twoDigits, noop],
|
|
7031
|
+
ddd: [word, noop],
|
|
7032
|
+
MMM: [word, monthUpdate('monthNamesShort')],
|
|
7033
|
+
MMMM: [word, monthUpdate('monthNames')],
|
|
7034
|
+
a: [word, function (d, v) {
|
|
7035
|
+
var val = v.toLowerCase();
|
|
7036
|
+
if (val === '上午') {
|
|
7037
|
+
d.isPm = false;
|
|
7038
|
+
} else if (val === '下午') {
|
|
7039
|
+
d.isPm = true;
|
|
7040
|
+
}
|
|
7041
|
+
}],
|
|
7042
|
+
ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
|
|
7043
|
+
var parts = (v + '').match(/([+-]|\d\d)/gi),
|
|
7044
|
+
minutes = void 0;
|
|
7045
|
+
|
|
7046
|
+
if (parts) {
|
|
7047
|
+
minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
|
|
7048
|
+
d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
|
|
7049
|
+
}
|
|
7050
|
+
}]
|
|
7051
|
+
};
|
|
7052
|
+
parseFlags.dd = parseFlags.d;
|
|
7053
|
+
parseFlags.dddd = parseFlags.ddd;
|
|
7054
|
+
parseFlags.DD = parseFlags.D;
|
|
7055
|
+
parseFlags.mm = parseFlags.m;
|
|
7056
|
+
parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
|
|
7057
|
+
parseFlags.MM = parseFlags.M;
|
|
7058
|
+
parseFlags.ss = parseFlags.s;
|
|
7059
|
+
parseFlags.A = parseFlags.a;
|
|
7060
|
+
|
|
7061
|
+
// Some common format strings
|
|
7062
|
+
fecha.masks = {
|
|
7063
|
+
default: 'ddd MMM dd yyyy HH:mm:ss',
|
|
7064
|
+
shortDate: 'M/D/yy',
|
|
7065
|
+
mediumDate: 'MMM d, yyyy',
|
|
7066
|
+
longDate: 'MMMM d, yyyy',
|
|
7067
|
+
fullDate: 'dddd, MMMM d, yyyy',
|
|
7068
|
+
shortTime: 'HH:mm',
|
|
7069
|
+
mediumTime: 'HH:mm:ss',
|
|
7070
|
+
longTime: 'HH:mm:ss.SSS'
|
|
7071
|
+
};
|
|
7072
|
+
|
|
7249
7073
|
/***
|
|
7250
7074
|
* Format a date
|
|
7251
7075
|
* @method format
|
|
7252
7076
|
* @param {Date|number} dateObj
|
|
7253
7077
|
* @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
|
|
7254
|
-
*/
|
|
7255
|
-
fecha.format = function (dateObj, mask) {
|
|
7256
|
-
if (typeof dateObj === 'number') {
|
|
7257
|
-
dateObj = new Date(dateObj);
|
|
7258
|
-
}
|
|
7259
|
-
|
|
7260
|
-
if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
|
|
7261
|
-
throw new Error('Invalid Date in fecha.format');
|
|
7262
|
-
}
|
|
7263
|
-
|
|
7264
|
-
mask = fecha.masks[mask] || mask || fecha.masks['default'];
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
// Make literals inactive by replacing them with ??
|
|
7269
|
-
mask = mask.replace(literal, function($0, $1) {
|
|
7270
|
-
literals.push($1);
|
|
7271
|
-
return '@@@';
|
|
7272
|
-
});
|
|
7273
|
-
// Apply formatting rules
|
|
7274
|
-
mask = mask.replace(token, function ($0) {
|
|
7275
|
-
return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
|
|
7276
|
-
});
|
|
7277
|
-
// Inline literal values back into the formatted value
|
|
7278
|
-
return mask.replace(/@@@/g, function() {
|
|
7279
|
-
return literals.shift();
|
|
7280
|
-
});
|
|
7281
|
-
};
|
|
7282
|
-
|
|
7078
|
+
*/
|
|
7079
|
+
fecha.format = function (dateObj, mask) {
|
|
7080
|
+
if (typeof dateObj === 'number') {
|
|
7081
|
+
dateObj = new Date(dateObj);
|
|
7082
|
+
}
|
|
7083
|
+
|
|
7084
|
+
if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
|
|
7085
|
+
throw new Error('Invalid Date in fecha.format');
|
|
7086
|
+
}
|
|
7087
|
+
|
|
7088
|
+
mask = fecha.masks[mask] || mask || fecha.masks['default'];
|
|
7089
|
+
|
|
7090
|
+
var literals = [];
|
|
7091
|
+
|
|
7092
|
+
// Make literals inactive by replacing them with ??
|
|
7093
|
+
mask = mask.replace(literal, function ($0, $1) {
|
|
7094
|
+
literals.push($1);
|
|
7095
|
+
return '@@@';
|
|
7096
|
+
});
|
|
7097
|
+
// Apply formatting rules
|
|
7098
|
+
mask = mask.replace(token, function ($0) {
|
|
7099
|
+
return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
|
|
7100
|
+
});
|
|
7101
|
+
// Inline literal values back into the formatted value
|
|
7102
|
+
return mask.replace(/@@@/g, function () {
|
|
7103
|
+
return literals.shift();
|
|
7104
|
+
});
|
|
7105
|
+
};
|
|
7106
|
+
|
|
7283
7107
|
/**
|
|
7284
7108
|
* Parse a date string into an object, changes - into /
|
|
7285
7109
|
* @method parse
|
|
7286
7110
|
* @param {string} dateStr Date string
|
|
7287
7111
|
* @param {string} format Date parse format
|
|
7288
7112
|
* @returns {Date|boolean}
|
|
7289
|
-
*/
|
|
7290
|
-
fecha.parse = function (dateStr, format) {
|
|
7291
|
-
if (typeof format !== 'string') {
|
|
7292
|
-
throw new Error('Invalid format in fecha.parse');
|
|
7293
|
-
}
|
|
7294
|
-
|
|
7295
|
-
format = fecha.masks[format] || format;
|
|
7296
|
-
|
|
7297
|
-
// Avoid regular expression denial of service, fail early for really long strings
|
|
7298
|
-
// https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
|
|
7299
|
-
if (dateStr.length > 1000) {
|
|
7300
|
-
return null;
|
|
7301
|
-
}
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
format = format.replace(literal, function($0, $1) {
|
|
7307
|
-
literals.push($1);
|
|
7308
|
-
return '@@@';
|
|
7309
|
-
});
|
|
7310
|
-
|
|
7311
|
-
if (parseFlags[$0]) {
|
|
7312
|
-
|
|
7313
|
-
parseInfo.push(info[1]);
|
|
7314
|
-
return '(' + info[0] + ')';
|
|
7315
|
-
}
|
|
7316
|
-
|
|
7317
|
-
return $0;
|
|
7318
|
-
});
|
|
7319
|
-
newFormat = newFormat.replace(/@@@/g, function() {
|
|
7320
|
-
return literals.shift();
|
|
7321
|
-
});
|
|
7322
|
-
|
|
7323
|
-
if (!matches) {
|
|
7324
|
-
return null;
|
|
7325
|
-
}
|
|
7326
|
-
|
|
7327
|
-
for (
|
|
7328
|
-
parseInfo[i - 1](dateInfo, matches[i]);
|
|
7329
|
-
}
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
|
|
7333
|
-
dateInfo.hour = +dateInfo.hour + 12;
|
|
7334
|
-
} else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
|
|
7335
|
-
dateInfo.hour = 0;
|
|
7336
|
-
}
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
if (dateInfo.timezoneOffset != null) {
|
|
7340
|
-
dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
|
|
7341
|
-
date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
if (date
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
// 处理多种输入类型
|
|
7389
|
-
if (!date) return '';
|
|
7390
|
-
|
|
7391
|
-
// 如果是时间戳,转成日期对象
|
|
7392
|
-
if (typeof date === 'number') {
|
|
7393
|
-
date = new Date(date);
|
|
7394
|
-
}
|
|
7395
|
-
// 如果是字符串,转成日期对象
|
|
7396
|
-
if (typeof date === 'string') {
|
|
7397
|
-
date = new Date(date);
|
|
7398
|
-
}
|
|
7399
|
-
|
|
7400
|
-
// 调用toDate进一步验证和转换
|
|
7401
|
-
date = toDate(date);
|
|
7402
|
-
if (!date) return '';
|
|
7403
|
-
|
|
7404
|
-
// 兼容大写和小写的格式标记
|
|
7405
|
-
// 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
return
|
|
7427
|
-
}
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
//
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
|
|
7451
|
-
};
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
return prevDate(result,
|
|
7465
|
-
}
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
//
|
|
7485
|
-
|
|
7486
|
-
//
|
|
7487
|
-
|
|
7488
|
-
//
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
for (
|
|
7508
|
-
hours[i] =
|
|
7509
|
-
}
|
|
7510
|
-
}
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
}
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
};
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
}
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
return
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
};
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
return
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
|
|
7652
|
-
|
|
7653
|
-
|
|
7654
|
-
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
};
|
|
7669
|
-
|
|
7670
|
-
|
|
7671
|
-
return
|
|
7672
|
-
};
|
|
7673
|
-
|
|
7113
|
+
*/
|
|
7114
|
+
fecha.parse = function (dateStr, format) {
|
|
7115
|
+
if (typeof format !== 'string') {
|
|
7116
|
+
throw new Error('Invalid format in fecha.parse');
|
|
7117
|
+
}
|
|
7118
|
+
|
|
7119
|
+
format = fecha.masks[format] || format;
|
|
7120
|
+
|
|
7121
|
+
// Avoid regular expression denial of service, fail early for really long strings
|
|
7122
|
+
// https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
|
|
7123
|
+
if (dateStr.length > 1000) {
|
|
7124
|
+
return null;
|
|
7125
|
+
}
|
|
7126
|
+
|
|
7127
|
+
var dateInfo = {};
|
|
7128
|
+
var parseInfo = [];
|
|
7129
|
+
var literals = [];
|
|
7130
|
+
format = format.replace(literal, function ($0, $1) {
|
|
7131
|
+
literals.push($1);
|
|
7132
|
+
return '@@@';
|
|
7133
|
+
});
|
|
7134
|
+
var newFormat = regexEscape(format).replace(token, function ($0) {
|
|
7135
|
+
if (parseFlags[$0]) {
|
|
7136
|
+
var info = parseFlags[$0];
|
|
7137
|
+
parseInfo.push(info[1]);
|
|
7138
|
+
return '(' + info[0] + ')';
|
|
7139
|
+
}
|
|
7140
|
+
|
|
7141
|
+
return $0;
|
|
7142
|
+
});
|
|
7143
|
+
newFormat = newFormat.replace(/@@@/g, function () {
|
|
7144
|
+
return literals.shift();
|
|
7145
|
+
});
|
|
7146
|
+
var matches = dateStr.match(new RegExp(newFormat, 'i'));
|
|
7147
|
+
if (!matches) {
|
|
7148
|
+
return null;
|
|
7149
|
+
}
|
|
7150
|
+
|
|
7151
|
+
for (var i = 1; i < matches.length; i++) {
|
|
7152
|
+
parseInfo[i - 1](dateInfo, matches[i]);
|
|
7153
|
+
}
|
|
7154
|
+
|
|
7155
|
+
var today = new Date();
|
|
7156
|
+
if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
|
|
7157
|
+
dateInfo.hour = +dateInfo.hour + 12;
|
|
7158
|
+
} else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
|
|
7159
|
+
dateInfo.hour = 0;
|
|
7160
|
+
}
|
|
7161
|
+
|
|
7162
|
+
var date = void 0;
|
|
7163
|
+
if (dateInfo.timezoneOffset != null) {
|
|
7164
|
+
dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
|
|
7165
|
+
date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
|
|
7166
|
+
} else {
|
|
7167
|
+
date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
|
|
7168
|
+
}
|
|
7169
|
+
return date;
|
|
7170
|
+
};
|
|
7171
|
+
|
|
7172
|
+
// 导出fecha对象
|
|
7173
|
+
|
|
7174
|
+
|
|
7175
|
+
// 以下是从date-util.js合并的函数
|
|
7176
|
+
var newArray = function newArray(start, end) {
|
|
7177
|
+
var result = [];
|
|
7178
|
+
for (var i = start; i <= end; i++) {
|
|
7179
|
+
result.push(i);
|
|
7180
|
+
}
|
|
7181
|
+
return result;
|
|
7182
|
+
};
|
|
7183
|
+
|
|
7184
|
+
var getSettings = function getSettings() {
|
|
7185
|
+
return {
|
|
7186
|
+
dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
|
|
7187
|
+
dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
|
|
7188
|
+
monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
|
|
7189
|
+
monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
|
|
7190
|
+
amPm: ['上午', '下午']
|
|
7191
|
+
};
|
|
7192
|
+
};
|
|
7193
|
+
|
|
7194
|
+
var toDate = function toDate(date) {
|
|
7195
|
+
return isDate(date) ? new Date(date) : null;
|
|
7196
|
+
};
|
|
7197
|
+
|
|
7198
|
+
var isDate = function isDate(date) {
|
|
7199
|
+
if (date === null || date === undefined) return false;
|
|
7200
|
+
if (isNaN(new Date(date).getTime())) return false;
|
|
7201
|
+
if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
|
|
7202
|
+
return true;
|
|
7203
|
+
};
|
|
7204
|
+
|
|
7205
|
+
var isDateObject = function isDateObject(val) {
|
|
7206
|
+
return val instanceof Date;
|
|
7207
|
+
};
|
|
7208
|
+
|
|
7209
|
+
var formatDate = function formatDate(date) {
|
|
7210
|
+
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
|
|
7211
|
+
|
|
7212
|
+
// 处理多种输入类型
|
|
7213
|
+
if (!date) return '';
|
|
7214
|
+
|
|
7215
|
+
// 如果是时间戳,转成日期对象
|
|
7216
|
+
if (typeof date === 'number') {
|
|
7217
|
+
date = new Date(date);
|
|
7218
|
+
}
|
|
7219
|
+
// 如果是字符串,转成日期对象
|
|
7220
|
+
if (typeof date === 'string') {
|
|
7221
|
+
date = new Date(date);
|
|
7222
|
+
}
|
|
7223
|
+
|
|
7224
|
+
// 调用toDate进一步验证和转换
|
|
7225
|
+
date = toDate(date);
|
|
7226
|
+
if (!date) return '';
|
|
7227
|
+
|
|
7228
|
+
// 兼容大写和小写的格式标记
|
|
7229
|
+
// 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
|
|
7230
|
+
var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
|
|
7231
|
+
|
|
7232
|
+
// 使用fecha库进行格式化,支持中文配置
|
|
7233
|
+
var str = fecha.format(date, lowercaseFormat, getSettings());
|
|
7234
|
+
return str;
|
|
7235
|
+
};
|
|
7236
|
+
|
|
7237
|
+
var parseDate = function parseDate(string, format) {
|
|
7238
|
+
return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
|
|
7239
|
+
};
|
|
7240
|
+
|
|
7241
|
+
var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
|
|
7242
|
+
if (month === 3 || month === 5 || month === 8 || month === 10) {
|
|
7243
|
+
return 30;
|
|
7244
|
+
}
|
|
7245
|
+
|
|
7246
|
+
if (month === 1) {
|
|
7247
|
+
if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
|
|
7248
|
+
return 29;
|
|
7249
|
+
} else {
|
|
7250
|
+
return 28;
|
|
7251
|
+
}
|
|
7252
|
+
}
|
|
7253
|
+
|
|
7254
|
+
return 31;
|
|
7255
|
+
};
|
|
7256
|
+
|
|
7257
|
+
var getDayCountOfYear = function getDayCountOfYear(year) {
|
|
7258
|
+
var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
|
|
7259
|
+
return isLeapYear ? 366 : 365;
|
|
7260
|
+
};
|
|
7261
|
+
|
|
7262
|
+
var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
|
|
7263
|
+
var temp = new Date(date.getTime());
|
|
7264
|
+
temp.setDate(1);
|
|
7265
|
+
return temp.getDay();
|
|
7266
|
+
};
|
|
7267
|
+
|
|
7268
|
+
// see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
|
|
7269
|
+
// {prev, next} Date should work for Daylight Saving Time
|
|
7270
|
+
// Adding 24 * 60 * 60 * 1000 does not work in the above scenario
|
|
7271
|
+
var prevDate = function prevDate(date) {
|
|
7272
|
+
var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
7273
|
+
|
|
7274
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
|
|
7275
|
+
};
|
|
7276
|
+
|
|
7277
|
+
var nextDate = function nextDate(date) {
|
|
7278
|
+
var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
7279
|
+
|
|
7280
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
|
|
7281
|
+
};
|
|
7282
|
+
|
|
7283
|
+
var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
|
|
7284
|
+
var result = new Date(year, month, 1);
|
|
7285
|
+
var day = result.getDay();
|
|
7286
|
+
|
|
7287
|
+
if (day === 0) {
|
|
7288
|
+
return prevDate(result, 7);
|
|
7289
|
+
} else {
|
|
7290
|
+
return prevDate(result, day);
|
|
7291
|
+
}
|
|
7292
|
+
};
|
|
7293
|
+
|
|
7294
|
+
var getWeekNumber = function getWeekNumber(date) {
|
|
7295
|
+
// 支持多种输入类型
|
|
7296
|
+
if (!date || !isDate(date)) {
|
|
7297
|
+
date = new Date();
|
|
7298
|
+
}
|
|
7299
|
+
if (typeof date === 'string') {
|
|
7300
|
+
date = new Date(date);
|
|
7301
|
+
}
|
|
7302
|
+
|
|
7303
|
+
// 验证日期有效性
|
|
7304
|
+
if (!isDate(date)) return null;
|
|
7305
|
+
|
|
7306
|
+
var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
7307
|
+
// 设置为最近的星期四:当前日期 + 4 - 当前星期数
|
|
7308
|
+
// 将星期日的星期数设为7
|
|
7309
|
+
d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
|
|
7310
|
+
// 获取当年的第一天
|
|
7311
|
+
var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
|
|
7312
|
+
// 计算到最近的星期四的完整周数
|
|
7313
|
+
var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
|
|
7314
|
+
// 返回周数
|
|
7315
|
+
return weekNo;
|
|
7316
|
+
};
|
|
7317
|
+
|
|
7318
|
+
var getRangeHours = function getRangeHours(ranges) {
|
|
7319
|
+
var hours = [];
|
|
7320
|
+
var disabledHours = [];
|
|
7321
|
+
|
|
7322
|
+
(ranges || []).forEach(function (range) {
|
|
7323
|
+
var value = range.map(function (date) {
|
|
7324
|
+
return date.getHours();
|
|
7325
|
+
});
|
|
7326
|
+
|
|
7327
|
+
disabledHours = disabledHours.concat(newArray(value[0], value[1]));
|
|
7328
|
+
});
|
|
7329
|
+
|
|
7330
|
+
if (disabledHours.length) {
|
|
7331
|
+
for (var i = 0; i < 24; i++) {
|
|
7332
|
+
hours[i] = disabledHours.indexOf(i) === -1;
|
|
7333
|
+
}
|
|
7334
|
+
} else {
|
|
7335
|
+
for (var _i = 0; _i < 24; _i++) {
|
|
7336
|
+
hours[_i] = false;
|
|
7337
|
+
}
|
|
7338
|
+
}
|
|
7339
|
+
|
|
7340
|
+
return hours;
|
|
7341
|
+
};
|
|
7342
|
+
|
|
7343
|
+
var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
|
|
7344
|
+
if (amount <= 0) return [];
|
|
7345
|
+
var temp = new Date(date.getTime());
|
|
7346
|
+
temp.setDate(0);
|
|
7347
|
+
var lastDay = temp.getDate();
|
|
7348
|
+
return range(amount).map(function (_, index) {
|
|
7349
|
+
return lastDay - (amount - index - 1);
|
|
7350
|
+
});
|
|
7351
|
+
};
|
|
7352
|
+
|
|
7353
|
+
var getMonthDays = function getMonthDays(date) {
|
|
7354
|
+
var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
|
7355
|
+
var days = temp.getDate();
|
|
7356
|
+
return range(days).map(function (_, index) {
|
|
7357
|
+
return index + 1;
|
|
7358
|
+
});
|
|
7359
|
+
};
|
|
7360
|
+
|
|
7361
|
+
function setRangeData(arr, start, end, value) {
|
|
7362
|
+
for (var i = start; i < end; i++) {
|
|
7363
|
+
arr[i] = value;
|
|
7364
|
+
}
|
|
7365
|
+
}
|
|
7366
|
+
|
|
7367
|
+
var getRangeMinutes = function getRangeMinutes(ranges, hour) {
|
|
7368
|
+
var minutes = new Array(60);
|
|
7369
|
+
|
|
7370
|
+
if (ranges.length > 0) {
|
|
7371
|
+
ranges.forEach(function (range) {
|
|
7372
|
+
var start = range[0];
|
|
7373
|
+
var end = range[1];
|
|
7374
|
+
var startHour = start.getHours();
|
|
7375
|
+
var startMinute = start.getMinutes();
|
|
7376
|
+
var endHour = end.getHours();
|
|
7377
|
+
var endMinute = end.getMinutes();
|
|
7378
|
+
if (startHour === hour && endHour !== hour) {
|
|
7379
|
+
setRangeData(minutes, startMinute, 60, true);
|
|
7380
|
+
} else if (startHour === hour && endHour === hour) {
|
|
7381
|
+
setRangeData(minutes, startMinute, endMinute + 1, true);
|
|
7382
|
+
} else if (startHour !== hour && endHour === hour) {
|
|
7383
|
+
setRangeData(minutes, 0, endMinute + 1, true);
|
|
7384
|
+
} else if (startHour < hour && endHour > hour) {
|
|
7385
|
+
setRangeData(minutes, 0, 60, true);
|
|
7386
|
+
}
|
|
7387
|
+
});
|
|
7388
|
+
} else {
|
|
7389
|
+
setRangeData(minutes, 0, 60, true);
|
|
7390
|
+
}
|
|
7391
|
+
return minutes;
|
|
7392
|
+
};
|
|
7393
|
+
|
|
7394
|
+
var range = function range(n) {
|
|
7395
|
+
// see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
|
|
7396
|
+
return Array.apply(null, { length: n }).map(function (_, n) {
|
|
7397
|
+
return n;
|
|
7398
|
+
});
|
|
7399
|
+
};
|
|
7400
|
+
|
|
7401
|
+
var modifyDate = function modifyDate(date, y, m, d) {
|
|
7402
|
+
return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
|
|
7403
|
+
};
|
|
7404
|
+
|
|
7405
|
+
var modifyTime = function modifyTime(date, h, m, s) {
|
|
7406
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
|
|
7407
|
+
};
|
|
7408
|
+
|
|
7409
|
+
var modifyWithTimeString = function modifyWithTimeString(date, time) {
|
|
7410
|
+
if (date == null || !time) {
|
|
7411
|
+
return date;
|
|
7412
|
+
}
|
|
7413
|
+
time = parseDate(time, 'HH:mm:ss');
|
|
7414
|
+
return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
|
|
7415
|
+
};
|
|
7416
|
+
|
|
7417
|
+
var clearTime = function clearTime(date) {
|
|
7418
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
7419
|
+
};
|
|
7420
|
+
|
|
7421
|
+
var clearMilliseconds = function clearMilliseconds(date) {
|
|
7422
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
|
|
7423
|
+
};
|
|
7424
|
+
|
|
7425
|
+
var limitTimeRange = function limitTimeRange(date, ranges) {
|
|
7426
|
+
var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
|
|
7427
|
+
|
|
7428
|
+
// TODO: refactory a more elegant solution
|
|
7429
|
+
if (ranges.length === 0) return date;
|
|
7430
|
+
var normalizeDate = function normalizeDate(date) {
|
|
7431
|
+
return fecha.parse(fecha.format(date, format), format);
|
|
7432
|
+
};
|
|
7433
|
+
var ndate = normalizeDate(date);
|
|
7434
|
+
var nranges = ranges.map(function (range) {
|
|
7435
|
+
return range.map(normalizeDate);
|
|
7436
|
+
});
|
|
7437
|
+
if (nranges.some(function (nrange) {
|
|
7438
|
+
return ndate >= nrange[0] && ndate <= nrange[1];
|
|
7439
|
+
})) return date;
|
|
7440
|
+
|
|
7441
|
+
var minDate = nranges[0][0];
|
|
7442
|
+
var maxDate = nranges[0][0];
|
|
7443
|
+
|
|
7444
|
+
nranges.forEach(function (nrange) {
|
|
7445
|
+
minDate = new Date(Math.min(nrange[0], minDate));
|
|
7446
|
+
maxDate = new Date(Math.max(nrange[1], minDate));
|
|
7447
|
+
});
|
|
7448
|
+
|
|
7449
|
+
var ret = ndate < minDate ? minDate : maxDate;
|
|
7450
|
+
// preserve Year/Month/Date
|
|
7451
|
+
return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
|
|
7452
|
+
};
|
|
7453
|
+
|
|
7454
|
+
var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
|
|
7455
|
+
var limitedDate = limitTimeRange(date, selectableRange, format);
|
|
7456
|
+
return limitedDate.getTime() === date.getTime();
|
|
7457
|
+
};
|
|
7458
|
+
|
|
7459
|
+
var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
|
|
7460
|
+
// clamp date to the number of days in `year`, `month`
|
|
7461
|
+
// eg: (2010-1-31, 2010, 2) => 2010-2-28
|
|
7462
|
+
var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
|
|
7463
|
+
return modifyDate(date, year, month, monthDate);
|
|
7464
|
+
};
|
|
7465
|
+
|
|
7466
|
+
var prevMonth = function prevMonth(date) {
|
|
7467
|
+
var year = date.getFullYear();
|
|
7468
|
+
var month = date.getMonth();
|
|
7469
|
+
return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
|
|
7470
|
+
};
|
|
7471
|
+
|
|
7472
|
+
var nextMonth = function nextMonth(date) {
|
|
7473
|
+
var year = date.getFullYear();
|
|
7474
|
+
var month = date.getMonth();
|
|
7475
|
+
return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
|
|
7476
|
+
};
|
|
7477
|
+
|
|
7478
|
+
var prevYear = function prevYear(date) {
|
|
7479
|
+
var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
7480
|
+
|
|
7481
|
+
var year = date.getFullYear();
|
|
7482
|
+
var month = date.getMonth();
|
|
7483
|
+
return changeYearMonthAndClampDate(date, year - amount, month);
|
|
7484
|
+
};
|
|
7485
|
+
|
|
7486
|
+
var nextYear = function nextYear(date) {
|
|
7487
|
+
var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
7488
|
+
|
|
7489
|
+
var year = date.getFullYear();
|
|
7490
|
+
var month = date.getMonth();
|
|
7491
|
+
return changeYearMonthAndClampDate(date, year + amount, month);
|
|
7492
|
+
};
|
|
7493
|
+
|
|
7494
|
+
var extractDateFormat = function extractDateFormat(format) {
|
|
7495
|
+
return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
|
|
7496
|
+
};
|
|
7497
|
+
|
|
7498
|
+
var extractTimeFormat = function extractTimeFormat(format) {
|
|
7499
|
+
return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
|
|
7500
|
+
};
|
|
7501
|
+
|
|
7502
|
+
var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
|
|
7503
|
+
return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
|
|
7504
|
+
};
|
|
7505
|
+
|
|
7674
7506
|
/**
|
|
7675
7507
|
* 计算两个日期之间的工作日数量(不包括周末和节假日)
|
|
7676
7508
|
* @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
|
|
7677
7509
|
* @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
|
|
7678
7510
|
* @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
|
|
7679
7511
|
* @returns {number} 工作日数量
|
|
7680
|
-
*/
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
);
|
|
7686
|
-
}
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
|
|
7692
|
-
throw new Error(
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
}
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7512
|
+
*/
|
|
7513
|
+
var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
|
|
7514
|
+
var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
7515
|
+
|
|
7516
|
+
if (typeof start_date !== 'string' || typeof end_date !== 'string') {
|
|
7517
|
+
throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
|
|
7518
|
+
}
|
|
7519
|
+
|
|
7520
|
+
var startDateObj = new Date(start_date);
|
|
7521
|
+
var endDateObj = new Date(end_date);
|
|
7522
|
+
|
|
7523
|
+
if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
|
|
7524
|
+
throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
|
|
7525
|
+
}
|
|
7526
|
+
|
|
7527
|
+
if (startDateObj > endDateObj) {
|
|
7528
|
+
throw new Error('Start date should be earlier than or equal to end date.');
|
|
7529
|
+
}
|
|
7530
|
+
|
|
7531
|
+
var workdays = 0;
|
|
7532
|
+
|
|
7533
|
+
// Iterate through each day in the date range
|
|
7534
|
+
|
|
7535
|
+
var _loop = function _loop(currentDate) {
|
|
7536
|
+
// Check if the current day is a weekend (Saturday or Sunday)
|
|
7537
|
+
var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
|
|
7538
|
+
|
|
7539
|
+
// Check if the current day is a holiday
|
|
7540
|
+
var isHoliday = holidays.some(function (holiday) {
|
|
7541
|
+
var holidayDate = new Date(holiday);
|
|
7542
|
+
return currentDate.toDateString() === holidayDate.toDateString();
|
|
7543
|
+
});
|
|
7544
|
+
|
|
7545
|
+
// If it's a workday (not a weekend or holiday), increment the workdays count
|
|
7546
|
+
if (!isWeekend && !isHoliday) {
|
|
7547
|
+
workdays++;
|
|
7548
|
+
}
|
|
7549
|
+
};
|
|
7550
|
+
|
|
7551
|
+
for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
|
|
7552
|
+
_loop(currentDate);
|
|
7553
|
+
}
|
|
7554
|
+
|
|
7555
|
+
return workdays;
|
|
7556
|
+
};
|
|
7557
|
+
|
|
7727
7558
|
/**
|
|
7728
7559
|
* 日期加减天数
|
|
7729
7560
|
* @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
|
|
7730
7561
|
* @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
|
|
7731
7562
|
* @returns {string} 结果日期,格式为 "YYYY-MM-DD"
|
|
7732
|
-
*/
|
|
7733
|
-
|
|
7734
|
-
if (typeof start_date !== 'string' || !Number.isInteger(days)) {
|
|
7735
|
-
throw new Error(
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
return `${resultYear}-${resultMonth}-${resultDay}`;
|
|
7755
|
-
};
|
|
7756
|
-
|
|
7563
|
+
*/
|
|
7564
|
+
var dateAddDays = function dateAddDays(start_date, days) {
|
|
7565
|
+
if (typeof start_date !== 'string' || !Number.isInteger(days)) {
|
|
7566
|
+
throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days.");
|
|
7567
|
+
}
|
|
7568
|
+
|
|
7569
|
+
var startDateObj = new Date(start_date);
|
|
7570
|
+
if (isNaN(startDateObj.getTime())) {
|
|
7571
|
+
throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
|
|
7572
|
+
}
|
|
7573
|
+
|
|
7574
|
+
var resultDateObj = new Date(startDateObj);
|
|
7575
|
+
resultDateObj.setDate(resultDateObj.getDate() + days);
|
|
7576
|
+
|
|
7577
|
+
var resultYear = resultDateObj.getFullYear();
|
|
7578
|
+
var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
|
|
7579
|
+
var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
|
|
7580
|
+
|
|
7581
|
+
return resultYear + '-' + resultMonth + '-' + resultDay;
|
|
7582
|
+
};
|
|
7583
|
+
|
|
7757
7584
|
/**
|
|
7758
7585
|
* 计算两个日期之间的差值
|
|
7759
7586
|
* @date 2023年12月14日
|
|
@@ -7761,182 +7588,180 @@ const dateAddDays = function (start_date, days) {
|
|
|
7761
7588
|
* @param {String} end_date - 结束日期字符串
|
|
7762
7589
|
* @param {String} unit - 单位:year/month/day
|
|
7763
7590
|
* @returns {Number} 差值
|
|
7764
|
-
*/
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
return (
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
7591
|
+
*/
|
|
7592
|
+
var dateDiff = function dateDiff(start_date, end_date) {
|
|
7593
|
+
var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
|
|
7594
|
+
|
|
7595
|
+
// Assuming date strings are in "YYYY-MM-DD" format
|
|
7596
|
+
var startDate = new Date(start_date);
|
|
7597
|
+
var endDate = new Date(end_date);
|
|
7598
|
+
|
|
7599
|
+
// If the date is invalid, return 0
|
|
7600
|
+
if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
|
|
7601
|
+
return 0;
|
|
7602
|
+
}
|
|
7603
|
+
|
|
7604
|
+
if (unit === 'year') {
|
|
7605
|
+
return endDate.getFullYear() - startDate.getFullYear();
|
|
7606
|
+
} else if (unit === 'month') {
|
|
7607
|
+
return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
|
|
7608
|
+
} else {
|
|
7609
|
+
// Default to day
|
|
7610
|
+
var timeDifference = endDate - startDate;
|
|
7611
|
+
// Calculate days (86400000 milliseconds per day)
|
|
7612
|
+
return Math.floor(timeDifference / 86400000);
|
|
7613
|
+
}
|
|
7614
|
+
};
|
|
7615
|
+
|
|
7790
7616
|
/**
|
|
7791
7617
|
* 获取月份中的日期
|
|
7792
7618
|
* @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
|
|
7793
7619
|
* @returns {number} 月份中的日期(1-31)
|
|
7794
|
-
*/
|
|
7795
|
-
|
|
7796
|
-
if (typeof date !== 'string') {
|
|
7797
|
-
throw new Error(
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
return dateObj.getDate();
|
|
7810
|
-
};
|
|
7811
|
-
|
|
7620
|
+
*/
|
|
7621
|
+
var dayOfMonth = function dayOfMonth(date) {
|
|
7622
|
+
if (typeof date !== 'string') {
|
|
7623
|
+
throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
|
|
7624
|
+
}
|
|
7625
|
+
|
|
7626
|
+
var dateObj = new Date(date);
|
|
7627
|
+
if (isNaN(dateObj.getTime())) {
|
|
7628
|
+
throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
|
|
7629
|
+
}
|
|
7630
|
+
|
|
7631
|
+
return dateObj.getDate();
|
|
7632
|
+
};
|
|
7633
|
+
|
|
7812
7634
|
/**
|
|
7813
7635
|
* 获取当前日期
|
|
7814
7636
|
* @date 2022年5月7日
|
|
7815
7637
|
* @param {string} format - 日期格式,默认为'YYYY-MM-DD'
|
|
7816
7638
|
* @returns {string} 当前日期的格式化字符串
|
|
7817
|
-
*/
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7639
|
+
*/
|
|
7640
|
+
var getCurrentDate = function getCurrentDate() {
|
|
7641
|
+
var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
|
|
7642
|
+
|
|
7643
|
+
return formatDate(new Date(), format);
|
|
7644
|
+
};
|
|
7645
|
+
|
|
7822
7646
|
/**
|
|
7823
7647
|
* 获取当前日期时间
|
|
7824
7648
|
* @date 2022年5月7日
|
|
7825
7649
|
* @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
|
|
7826
7650
|
* @returns {string} 当前日期时间的格式化字符串
|
|
7827
|
-
*/
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7651
|
+
*/
|
|
7652
|
+
var getCurrentDateTime = function getCurrentDateTime() {
|
|
7653
|
+
var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
|
|
7654
|
+
|
|
7655
|
+
return formatDate(new Date(), format);
|
|
7656
|
+
};
|
|
7657
|
+
|
|
7832
7658
|
/**
|
|
7833
7659
|
* 获取小时
|
|
7834
7660
|
* @date 2022年5月7日
|
|
7835
7661
|
* @param {Date|string} [date] - 日期对象或日期字符串
|
|
7836
7662
|
* @returns {number} 小时数(0-23)
|
|
7837
|
-
*/
|
|
7838
|
-
|
|
7839
|
-
if (!date) {
|
|
7840
|
-
return new Date().getHours();
|
|
7841
|
-
}
|
|
7842
|
-
if (typeof date === 'string') {
|
|
7843
|
-
date = new Date(date);
|
|
7844
|
-
}
|
|
7845
|
-
return date.getHours();
|
|
7846
|
-
};
|
|
7847
|
-
|
|
7663
|
+
*/
|
|
7664
|
+
var getHour = function getHour(date) {
|
|
7665
|
+
if (!date) {
|
|
7666
|
+
return new Date().getHours();
|
|
7667
|
+
}
|
|
7668
|
+
if (typeof date === 'string') {
|
|
7669
|
+
date = new Date(date);
|
|
7670
|
+
}
|
|
7671
|
+
return date.getHours();
|
|
7672
|
+
};
|
|
7673
|
+
|
|
7848
7674
|
/**
|
|
7849
7675
|
* 获取分钟
|
|
7850
7676
|
* @date 2022年5月7日
|
|
7851
7677
|
* @param {Date|string} [date] - 日期对象或日期字符串
|
|
7852
7678
|
* @returns {number} 分钟数(0-59)
|
|
7853
|
-
*/
|
|
7854
|
-
|
|
7855
|
-
if (!date) {
|
|
7856
|
-
return new Date().getMinutes();
|
|
7857
|
-
}
|
|
7858
|
-
if (typeof date === 'string') {
|
|
7859
|
-
date = new Date(date);
|
|
7860
|
-
}
|
|
7861
|
-
return date.getMinutes();
|
|
7862
|
-
};
|
|
7863
|
-
|
|
7679
|
+
*/
|
|
7680
|
+
var getMinute = function getMinute(date) {
|
|
7681
|
+
if (!date) {
|
|
7682
|
+
return new Date().getMinutes();
|
|
7683
|
+
}
|
|
7684
|
+
if (typeof date === 'string') {
|
|
7685
|
+
date = new Date(date);
|
|
7686
|
+
}
|
|
7687
|
+
return date.getMinutes();
|
|
7688
|
+
};
|
|
7689
|
+
|
|
7864
7690
|
/**
|
|
7865
7691
|
* 获取月份
|
|
7866
7692
|
* @date 2022年5月7日
|
|
7867
7693
|
* @param {Date|string} [date] - 日期对象或日期字符串
|
|
7868
7694
|
* @returns {number} 月份数(1-12)
|
|
7869
|
-
*/
|
|
7870
|
-
|
|
7871
|
-
if (!date) {
|
|
7872
|
-
return new Date().getMonth() + 1;
|
|
7873
|
-
}
|
|
7874
|
-
if (typeof date === 'string') {
|
|
7875
|
-
date = new Date(date);
|
|
7876
|
-
}
|
|
7877
|
-
return date.getMonth() + 1;
|
|
7878
|
-
};
|
|
7879
|
-
|
|
7695
|
+
*/
|
|
7696
|
+
var getMonth = function getMonth(date) {
|
|
7697
|
+
if (!date) {
|
|
7698
|
+
return new Date().getMonth() + 1;
|
|
7699
|
+
}
|
|
7700
|
+
if (typeof date === 'string') {
|
|
7701
|
+
date = new Date(date);
|
|
7702
|
+
}
|
|
7703
|
+
return date.getMonth() + 1;
|
|
7704
|
+
};
|
|
7705
|
+
|
|
7880
7706
|
/**
|
|
7881
7707
|
* 获取秒
|
|
7882
7708
|
* @date 2022年5月7日
|
|
7883
7709
|
* @param {Date|string} [date] - 日期对象或日期字符串
|
|
7884
7710
|
* @returns {number} 秒数(0-59)
|
|
7885
|
-
*/
|
|
7886
|
-
|
|
7887
|
-
if (!date) {
|
|
7888
|
-
return new Date().getSeconds();
|
|
7889
|
-
}
|
|
7890
|
-
if (typeof date === 'string') {
|
|
7891
|
-
date = new Date(date);
|
|
7892
|
-
}
|
|
7893
|
-
return date.getSeconds();
|
|
7894
|
-
};
|
|
7895
|
-
|
|
7711
|
+
*/
|
|
7712
|
+
var getSecond = function getSecond(date) {
|
|
7713
|
+
if (!date) {
|
|
7714
|
+
return new Date().getSeconds();
|
|
7715
|
+
}
|
|
7716
|
+
if (typeof date === 'string') {
|
|
7717
|
+
date = new Date(date);
|
|
7718
|
+
}
|
|
7719
|
+
return date.getSeconds();
|
|
7720
|
+
};
|
|
7721
|
+
|
|
7896
7722
|
/**
|
|
7897
7723
|
* 获取星期几
|
|
7898
7724
|
* @date 2022年5月7日
|
|
7899
7725
|
* @param {Date|string} [date] - 日期对象或日期字符串
|
|
7900
7726
|
* @returns {number} 星期几(0-6,0表示星期日)
|
|
7901
|
-
*/
|
|
7902
|
-
|
|
7903
|
-
if (!date) {
|
|
7904
|
-
return new Date().getDay();
|
|
7905
|
-
}
|
|
7906
|
-
if (typeof date === 'string') {
|
|
7907
|
-
date = new Date(date);
|
|
7908
|
-
}
|
|
7909
|
-
return date.getDay();
|
|
7910
|
-
};
|
|
7911
|
-
|
|
7912
|
-
|
|
7727
|
+
*/
|
|
7728
|
+
var getWeekday = function getWeekday(date) {
|
|
7729
|
+
if (!date) {
|
|
7730
|
+
return new Date().getDay();
|
|
7731
|
+
}
|
|
7732
|
+
if (typeof date === 'string') {
|
|
7733
|
+
date = new Date(date);
|
|
7734
|
+
}
|
|
7735
|
+
return date.getDay();
|
|
7736
|
+
};
|
|
7737
|
+
|
|
7913
7738
|
/**
|
|
7914
7739
|
* @desc 获取上午/下午/晚上
|
|
7915
7740
|
* @author huangbo
|
|
7916
7741
|
* @date 2022年5月7日
|
|
7917
7742
|
* @param {String} [time] - 时间
|
|
7918
|
-
**/
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
if (!time) {
|
|
7922
|
-
hour = new Date().getHours();
|
|
7923
|
-
} else if (typeof time === 'string') {
|
|
7924
|
-
// 从时间字符串中提取小时
|
|
7925
|
-
|
|
7926
|
-
if (match) {
|
|
7927
|
-
hour = parseInt(match[1], 10);
|
|
7928
|
-
}
|
|
7929
|
-
} else if (typeof time === 'number') {
|
|
7930
|
-
hour = time;
|
|
7931
|
-
}
|
|
7932
|
-
// 判断时间段
|
|
7933
|
-
if (hour >= 5 && hour < 12) {
|
|
7934
|
-
return '上午';
|
|
7935
|
-
} else if (hour >= 12 && hour < 18) {
|
|
7936
|
-
return '下午';
|
|
7937
|
-
} else {
|
|
7938
|
-
return '晚上';
|
|
7939
|
-
}
|
|
7743
|
+
**/
|
|
7744
|
+
var timeCycle = function timeCycle(time) {
|
|
7745
|
+
var hour = 0;
|
|
7746
|
+
if (!time) {
|
|
7747
|
+
hour = new Date().getHours();
|
|
7748
|
+
} else if (typeof time === 'string') {
|
|
7749
|
+
// 从时间字符串中提取小时
|
|
7750
|
+
var match = time.match(/^(\d{1,2})/);
|
|
7751
|
+
if (match) {
|
|
7752
|
+
hour = parseInt(match[1], 10);
|
|
7753
|
+
}
|
|
7754
|
+
} else if (typeof time === 'number') {
|
|
7755
|
+
hour = time;
|
|
7756
|
+
}
|
|
7757
|
+
// 判断时间段
|
|
7758
|
+
if (hour >= 5 && hour < 12) {
|
|
7759
|
+
return '上午';
|
|
7760
|
+
} else if (hour >= 12 && hour < 18) {
|
|
7761
|
+
return '下午';
|
|
7762
|
+
} else {
|
|
7763
|
+
return '晚上';
|
|
7764
|
+
}
|
|
7940
7765
|
};
|
|
7941
7766
|
|
|
7942
7767
|
/***/ }),
|