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