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