eoss 0.1.0-alpha.35 → 0.1.0-alpha.36

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 (136) hide show
  1. package/lib/account-login.js +912 -856
  2. package/lib/alert.js +2 -2
  3. package/lib/aside.js +2 -2
  4. package/lib/audit-trajectory.js +2 -2
  5. package/lib/autocomplete.js +2001 -1777
  6. package/lib/avatar.js +2 -2
  7. package/lib/backtop.js +2 -2
  8. package/lib/badge.js +2 -2
  9. package/lib/breadcrumb-item.js +4 -4
  10. package/lib/breadcrumb.js +4 -4
  11. package/lib/button-group.js +2 -2
  12. package/lib/button.js +2 -2
  13. package/lib/ca-login.js +862 -837
  14. package/lib/calendar.js +862 -837
  15. package/lib/card.js +2 -2
  16. package/lib/carousel-item.js +864 -839
  17. package/lib/carousel.js +864 -839
  18. package/lib/cascader-panel.js +864 -839
  19. package/lib/cascader.js +2003 -1779
  20. package/lib/checkbox-button.js +2 -2
  21. package/lib/checkbox-group.js +864 -839
  22. package/lib/checkbox.js +2 -2
  23. package/lib/col.js +2 -2
  24. package/lib/collapse-item.js +864 -839
  25. package/lib/collapse.js +864 -839
  26. package/lib/color-picker.js +1141 -942
  27. package/lib/container.js +2 -2
  28. package/lib/cron.js +2 -2
  29. package/lib/data-table.js +871 -846
  30. package/lib/date-picker.js +2003 -1779
  31. package/lib/descriptions-item.js +144 -0
  32. package/lib/descriptions.js +561 -0
  33. package/lib/dialog.js +862 -837
  34. package/lib/divider.js +2 -2
  35. package/lib/drawer.js +2 -2
  36. package/lib/dropdown-item.js +4 -4
  37. package/lib/dropdown-menu.js +1141 -942
  38. package/lib/dropdown.js +862 -837
  39. package/lib/email-login.js +862 -837
  40. package/lib/empty.js +2 -2
  41. package/lib/eoss.common.js +2485 -1819
  42. package/lib/flip.js +2 -2
  43. package/lib/flow-group.js +866 -841
  44. package/lib/flow.js +871 -846
  45. package/lib/flows.js +862 -837
  46. package/lib/footer.js +2 -2
  47. package/lib/form-item.js +875 -850
  48. package/lib/form.js +876 -849
  49. package/lib/guide.js +2 -2
  50. package/lib/header.js +2 -2
  51. package/lib/icon.js +862 -837
  52. package/lib/icons.js +2 -2
  53. package/lib/image-viewer.js +862 -837
  54. package/lib/image.js +4 -4
  55. package/lib/index.js +1 -1
  56. package/lib/infinite-scroll.js +2 -2
  57. package/lib/input-number.js +2 -2
  58. package/lib/input.js +884 -859
  59. package/lib/link.js +2 -2
  60. package/lib/loading.js +2 -2
  61. package/lib/login.js +913 -873
  62. package/lib/lowcode-view.js +862 -837
  63. package/lib/lowcode.js +901 -876
  64. package/lib/main.js +908 -880
  65. package/lib/marquee.js +862 -837
  66. package/lib/menu-item-group.js +2 -2
  67. package/lib/menu-item.js +2 -2
  68. package/lib/menu.js +2003 -1779
  69. package/lib/message-box.js +862 -837
  70. package/lib/message.js +884 -859
  71. package/lib/notification.js +862 -837
  72. package/lib/option-group.js +4 -4
  73. package/lib/option.js +871 -846
  74. package/lib/page-header.js +2 -2
  75. package/lib/pagination.js +862 -837
  76. package/lib/phone-login.js +862 -837
  77. package/lib/popconfirm.js +4 -4
  78. package/lib/popover.js +2001 -1777
  79. package/lib/process-config.js +869 -844
  80. package/lib/process-module.js +862 -837
  81. package/lib/process-rule.js +862 -837
  82. package/lib/progress.js +2 -2
  83. package/lib/qr-code.js +4 -4
  84. package/lib/qrcode-login.js +870 -845
  85. package/lib/radio-button.js +2 -2
  86. package/lib/radio-group.js +871 -846
  87. package/lib/radio.js +2 -2
  88. package/lib/rate.js +862 -837
  89. package/lib/row.js +2 -2
  90. package/lib/scrollbar.js +862 -837
  91. package/lib/select.js +2005 -1781
  92. package/lib/selector-panel.js +873 -848
  93. package/lib/selector.js +866 -841
  94. package/lib/slider.js +2 -2
  95. package/lib/step.js +5 -5
  96. package/lib/steps.js +865 -840
  97. package/lib/submenu.js +1143 -944
  98. package/lib/switch.js +862 -837
  99. package/lib/tab-pane.js +4 -4
  100. package/lib/table-column.js +862 -837
  101. package/lib/table.js +2003 -1779
  102. package/lib/tabs.js +864 -839
  103. package/lib/tag.js +2 -2
  104. package/lib/theme-chalk/base.css +1 -1
  105. package/lib/theme-chalk/descriptions.css +1 -1
  106. package/lib/theme-chalk/index.css +1 -1
  107. package/lib/theme-chalk/main.css +1 -1
  108. package/lib/time-picker.js +2004 -1780
  109. package/lib/time-select.js +2001 -1777
  110. package/lib/timeline-item.js +2 -2
  111. package/lib/timeline.js +2 -2
  112. package/lib/tips.js +862 -837
  113. package/lib/toolbar.js +2 -2
  114. package/lib/tooltip.js +2003 -1779
  115. package/lib/transfer.js +869 -844
  116. package/lib/tree-group.js +862 -837
  117. package/lib/tree.js +862 -837
  118. package/lib/update-history.js +2 -2
  119. package/lib/upload.js +868 -843
  120. package/lib/utils/popper.js +97 -48
  121. package/lib/wujie.js +866 -841
  122. package/package.json +1 -1
  123. package/packages/account-login/src/account-login.vue +29 -0
  124. package/packages/descriptions/index.js +8 -0
  125. package/packages/descriptions/src/index.js +181 -0
  126. package/packages/descriptions/src/item.js +30 -0
  127. package/packages/descriptions/src/row.js +120 -0
  128. package/packages/descriptions-item/index.js +8 -0
  129. package/packages/login/src/login.vue +8 -0
  130. package/packages/login/src/mixins.js +3 -1
  131. package/packages/main/src/minxs.js +1 -0
  132. package/packages/theme-chalk/src/base.scss +2 -1
  133. package/packages/theme-chalk/src/descriptions.scss +0 -1
  134. package/packages/theme-chalk/src/index.scss +2 -0
  135. package/src/index.js +333 -327
  136. package/src/utils/popper.js +109 -70
package/lib/select.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 = 190);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 192);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -3505,7 +3505,7 @@ if (!vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer) {
3505
3505
 
3506
3506
  /***/ }),
3507
3507
 
3508
- /***/ 107:
3508
+ /***/ 108:
3509
3509
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3510
3510
 
3511
3511
  "use strict";
@@ -3842,7 +3842,7 @@ var component = Object(componentNormalizer["a" /* default */])(
3842
3842
 
3843
3843
  /***/ }),
3844
3844
 
3845
- /***/ 108:
3845
+ /***/ 109:
3846
3846
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3847
3847
 
3848
3848
  "use strict";
@@ -4262,7 +4262,7 @@ module.exports = require("lodash/cloneDeep");
4262
4262
 
4263
4263
  /***/ }),
4264
4264
 
4265
- /***/ 190:
4265
+ /***/ 192:
4266
4266
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4267
4267
 
4268
4268
  "use strict";
@@ -5055,7 +5055,7 @@ var component = Object(componentNormalizer["a" /* default */])(
5055
5055
 
5056
5056
  /* harmony default export */ var select_dropdown = (component.exports);
5057
5057
  // EXTERNAL MODULE: ./packages/select/src/option.vue + 4 modules
5058
- var src_option = __webpack_require__(107);
5058
+ var src_option = __webpack_require__(108);
5059
5059
 
5060
5060
  // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/select/src/option-tree.vue?vue&type=template&id=9f3104b4&
5061
5061
  var option_treevue_type_template_id_9f3104b4_render = function () {
@@ -5463,7 +5463,7 @@ var button_ = __webpack_require__(13);
5463
5463
  var button_default = /*#__PURE__*/__webpack_require__.n(button_);
5464
5464
 
5465
5465
  // EXTERNAL MODULE: ./packages/select/src/option-group.vue + 4 modules
5466
- var option_group = __webpack_require__(108);
5466
+ var option_group = __webpack_require__(109);
5467
5467
 
5468
5468
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/select/src/select.vue?vue&type=script&lang=js&
5469
5469
  var selectvue_type_script_lang_js_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; };
@@ -8723,9 +8723,7 @@ function insertAfter(newEl, targetEl) {
8723
8723
  /***/ 51:
8724
8724
  /***/ (function(module, exports, __webpack_require__) {
8725
8725
 
8726
- 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; };
8727
-
8728
- /**
8726
+ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
8729
8727
  * @fileOverview Kickass library to create and place poppers near their reference elements.
8730
8728
  * @version {{version}}
8731
8729
  * @license
@@ -8748,60 +8746,68 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
8748
8746
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
8749
8747
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
8750
8748
  * SOFTWARE.
8751
- */
8752
-
8753
- //
8754
- // Cross module loader
8755
- // Supported: Node, AMD, Browser globals
8756
- //
8757
- (function (root, factory) {
8758
- if (true) {
8759
- // AMD. Register as an anonymous module.
8749
+ */
8750
+
8751
+ //
8752
+ // Cross module loader
8753
+ // Supported: Node, AMD, Browser globals
8754
+ //
8755
+ (function (root, factory) {
8756
+ if (true) {
8757
+ // AMD. Register as an anonymous module.
8760
8758
  !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
8761
8759
  __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
8762
8760
  (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
8763
8761
  __WEBPACK_AMD_DEFINE_FACTORY__),
8764
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
8765
- } else {}
8766
- })(this, function () {
8767
- 'use strict';
8768
-
8769
- var root = window;
8770
- // default options
8771
- var DEFAULTS = {
8772
- // placement of the popper
8773
- placement: 'bottom',
8774
-
8775
- gpuAcceleration: true,
8776
-
8777
- // shift popper from its origin by the given amount of pixels (can be negative)
8778
- offset: 0,
8779
-
8780
- // the element which will act as boundary of the popper
8781
- boundariesElement: 'viewport',
8782
-
8783
- // amount of pixel used to define a minimum distance between the boundaries and the popper
8784
- boundariesPadding: 5,
8785
-
8786
- // popper will try to prevent overflow following this order,
8787
- // by default, then, it could overflow on the left and on top of the boundariesElement
8788
- preventOverflowOrder: ['left', 'right', 'top', 'bottom'],
8789
-
8790
- // the behavior used by flip to change the placement of the popper
8791
- flipBehavior: 'flip',
8792
-
8793
- arrowElement: '[x-arrow]',
8794
-
8795
- arrowOffset: 0,
8796
-
8797
- // list of functions used to modify the offsets before they are applied to the popper
8798
- modifiers: ['shift', 'offset', 'preventOverflow', 'keepTogether', 'arrow', 'flip', 'applyStyle'],
8799
-
8800
- modifiersIgnored: [],
8801
-
8802
- forceAbsolute: false
8803
- };
8804
-
8762
+ __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
8763
+ } else {}
8764
+ })(this, function () {
8765
+ 'use strict';
8766
+
8767
+ var root = window;
8768
+ // default options
8769
+ var DEFAULTS = {
8770
+ // placement of the popper
8771
+ placement: 'bottom',
8772
+
8773
+ gpuAcceleration: true,
8774
+
8775
+ // shift popper from its origin by the given amount of pixels (can be negative)
8776
+ offset: 0,
8777
+
8778
+ // the element which will act as boundary of the popper
8779
+ boundariesElement: 'viewport',
8780
+
8781
+ // amount of pixel used to define a minimum distance between the boundaries and the popper
8782
+ boundariesPadding: 5,
8783
+
8784
+ // popper will try to prevent overflow following this order,
8785
+ // by default, then, it could overflow on the left and on top of the boundariesElement
8786
+ preventOverflowOrder: ['left', 'right', 'top', 'bottom'],
8787
+
8788
+ // the behavior used by flip to change the placement of the popper
8789
+ flipBehavior: 'flip',
8790
+
8791
+ arrowElement: '[x-arrow]',
8792
+
8793
+ arrowOffset: 0,
8794
+
8795
+ // list of functions used to modify the offsets before they are applied to the popper
8796
+ modifiers: [
8797
+ 'shift',
8798
+ 'offset',
8799
+ 'preventOverflow',
8800
+ 'keepTogether',
8801
+ 'arrow',
8802
+ 'flip',
8803
+ 'applyStyle'
8804
+ ],
8805
+
8806
+ modifiersIgnored: [],
8807
+
8808
+ forceAbsolute: false
8809
+ };
8810
+
8805
8811
  /**
8806
8812
  * Create a new Popper.js instance
8807
8813
  * @constructor Popper
@@ -8866,114 +8872,125 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
8866
8872
  *
8867
8873
  * @param {Boolean} [options.removeOnDestroy=false]
8868
8874
  * Set to true if you want to automatically remove the popper when you call the `destroy` method.
8869
- */
8870
- function Popper(reference, popper, options) {
8871
- this._reference = reference.jquery ? reference[0] : reference;
8872
- this.state = {};
8873
-
8874
- // if the popper variable is a configuration object, parse it to generate an HTMLElement
8875
- // generate a default popper if is not defined
8876
- var isNotDefined = typeof popper === 'undefined' || popper === null;
8877
- var isConfig = popper && Object.prototype.toString.call(popper) === '[object Object]';
8878
- if (isNotDefined || isConfig) {
8879
- this._popper = this.parse(isConfig ? popper : {});
8880
- }
8881
- // otherwise, use the given HTMLElement as popper
8882
- else {
8883
- this._popper = popper.jquery ? popper[0] : popper;
8884
- }
8885
-
8886
- // with {} we create a new object with the options inside it
8887
- this._options = Object.assign({}, DEFAULTS, options);
8888
-
8889
- // refactoring modifiers' list
8890
- this._options.modifiers = this._options.modifiers.map(function (modifier) {
8891
- // remove ignored modifiers
8892
- if (this._options.modifiersIgnored.indexOf(modifier) !== -1) return;
8893
-
8894
- // set the x-placement attribute before everything else because it could be used to add margins to the popper
8895
- // margins needs to be calculated to get the correct popper offsets
8896
- if (modifier === 'applyStyle') {
8897
- this._popper.setAttribute('x-placement', this._options.placement);
8898
- }
8899
-
8900
- // return predefined modifier identified by string or keep the custom one
8901
- return this.modifiers[modifier] || modifier;
8902
- }.bind(this));
8903
-
8904
- // make sure to apply the popper position before any computation
8905
- this.state.position = this._getPosition(this._popper, this._reference);
8906
- setStyle(this._popper, { position: this.state.position, top: 0 });
8907
-
8908
- // fire the first update to position the popper in the right place
8909
- this.update();
8910
-
8911
- // setup event listeners, they will take care of update the position in specific situations
8912
- this._setupEventListeners();
8913
- return this;
8914
- }
8915
-
8916
- //
8917
- // Methods
8918
- //
8875
+ */
8876
+ function Popper(reference, popper, options) {
8877
+ this._reference = reference.jquery ? reference[0] : reference;
8878
+ this.state = {};
8879
+
8880
+ // if the popper variable is a configuration object, parse it to generate an HTMLElement
8881
+ // generate a default popper if is not defined
8882
+ var isNotDefined = typeof popper === 'undefined' || popper === null;
8883
+ var isConfig =
8884
+ popper && Object.prototype.toString.call(popper) === '[object Object]';
8885
+ if (isNotDefined || isConfig) {
8886
+ this._popper = this.parse(isConfig ? popper : {});
8887
+ }
8888
+ // otherwise, use the given HTMLElement as popper
8889
+ else {
8890
+ this._popper = popper.jquery ? popper[0] : popper;
8891
+ }
8892
+
8893
+ // with {} we create a new object with the options inside it
8894
+ this._options = Object.assign({}, DEFAULTS, options);
8895
+
8896
+ // refactoring modifiers' list
8897
+ this._options.modifiers = this._options.modifiers.map(
8898
+ function (modifier) {
8899
+ // remove ignored modifiers
8900
+ if (this._options.modifiersIgnored.indexOf(modifier) !== -1) return;
8901
+
8902
+ // set the x-placement attribute before everything else because it could be used to add margins to the popper
8903
+ // margins needs to be calculated to get the correct popper offsets
8904
+ if (modifier === 'applyStyle') {
8905
+ this._popper.setAttribute('x-placement', this._options.placement);
8906
+ }
8907
+
8908
+ // return predefined modifier identified by string or keep the custom one
8909
+ return this.modifiers[modifier] || modifier;
8910
+ }.bind(this)
8911
+ );
8912
+
8913
+ // make sure to apply the popper position before any computation
8914
+ this.state.position = this._getPosition(this._popper, this._reference);
8915
+ setStyle(this._popper, { position: this.state.position, top: 0 });
8916
+
8917
+ // fire the first update to position the popper in the right place
8918
+ this.update();
8919
+
8920
+ // setup event listeners, they will take care of update the position in specific situations
8921
+ this._setupEventListeners();
8922
+ return this;
8923
+ }
8924
+
8925
+ //
8926
+ // Methods
8927
+ //
8919
8928
  /**
8920
8929
  * Destroy the popper
8921
8930
  * @method
8922
8931
  * @memberof Popper
8923
- */
8924
- Popper.prototype.destroy = function () {
8925
- this._popper.removeAttribute('x-placement');
8926
- this._popper.style.left = '';
8927
- this._popper.style.position = '';
8928
- this._popper.style.top = '';
8929
- this._popper.style[getSupportedPropertyName('transform')] = '';
8930
- this._removeEventListeners();
8931
-
8932
- // remove the popper if user explicity asked for the deletion on destroy
8933
- if (this._options.removeOnDestroy) {
8934
- this._popper.remove();
8935
- }
8936
- return this;
8937
- };
8938
-
8932
+ */
8933
+ Popper.prototype.destroy = function () {
8934
+ this._popper.removeAttribute('x-placement');
8935
+ this._popper.style.left = '';
8936
+ this._popper.style.position = '';
8937
+ this._popper.style.top = '';
8938
+ this._popper.style[getSupportedPropertyName('transform')] = '';
8939
+ this._removeEventListeners();
8940
+
8941
+ // remove the popper if user explicity asked for the deletion on destroy
8942
+ if (this._options.removeOnDestroy) {
8943
+ this._popper.remove();
8944
+ }
8945
+ return this;
8946
+ };
8947
+
8939
8948
  /**
8940
8949
  * Updates the position of the popper, computing the new offsets and applying the new style
8941
8950
  * @method
8942
8951
  * @memberof Popper
8943
- */
8944
- Popper.prototype.update = function () {
8945
- var data = { instance: this, styles: {} };
8946
-
8947
- // store placement inside the data object, modifiers will be able to edit `placement` if needed
8948
- // and refer to _originalPlacement to know the original value
8949
- data.placement = this._options.placement;
8950
- data._originalPlacement = this._options.placement;
8951
-
8952
- // compute the popper and reference offsets and put them inside data.offsets
8953
- data.offsets = this._getOffsets(this._popper, this._reference, data.placement);
8954
-
8955
- // get boundaries
8956
- data.boundaries = this._getBoundaries(data, this._options.boundariesPadding, this._options.boundariesElement);
8957
-
8958
- data = this.runModifiers(data, this._options.modifiers);
8959
-
8960
- if (typeof this.state.updateCallback === 'function') {
8961
- this.state.updateCallback(data);
8962
- }
8963
- };
8964
-
8952
+ */
8953
+ Popper.prototype.update = function () {
8954
+ var data = { instance: this, styles: {} };
8955
+
8956
+ // store placement inside the data object, modifiers will be able to edit `placement` if needed
8957
+ // and refer to _originalPlacement to know the original value
8958
+ data.placement = this._options.placement;
8959
+ data._originalPlacement = this._options.placement;
8960
+
8961
+ // compute the popper and reference offsets and put them inside data.offsets
8962
+ data.offsets = this._getOffsets(
8963
+ this._popper,
8964
+ this._reference,
8965
+ data.placement
8966
+ );
8967
+
8968
+ // get boundaries
8969
+ data.boundaries = this._getBoundaries(
8970
+ data,
8971
+ this._options.boundariesPadding,
8972
+ this._options.boundariesElement
8973
+ );
8974
+
8975
+ data = this.runModifiers(data, this._options.modifiers);
8976
+
8977
+ if (typeof this.state.updateCallback === 'function') {
8978
+ this.state.updateCallback(data);
8979
+ }
8980
+ };
8981
+
8965
8982
  /**
8966
8983
  * If a function is passed, it will be executed after the initialization of popper with as first argument the Popper instance.
8967
8984
  * @method
8968
8985
  * @memberof Popper
8969
8986
  * @param {Function} callback
8970
- */
8971
- Popper.prototype.onCreate = function (callback) {
8972
- // the createCallbacks return as first argument the popper instance
8973
- callback(this);
8974
- return this;
8975
- };
8976
-
8987
+ */
8988
+ Popper.prototype.onCreate = function (callback) {
8989
+ // the createCallbacks return as first argument the popper instance
8990
+ callback(this);
8991
+ return this;
8992
+ };
8993
+
8977
8994
  /**
8978
8995
  * If a function is passed, it will be executed after each update of popper with as first argument the set of coordinates and informations
8979
8996
  * used to style popper and its arrow.
@@ -8981,93 +8998,101 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
8981
8998
  * @method
8982
8999
  * @memberof Popper
8983
9000
  * @param {Function} callback
8984
- */
8985
- Popper.prototype.onUpdate = function (callback) {
8986
- this.state.updateCallback = callback;
8987
- return this;
8988
- };
8989
-
9001
+ */
9002
+ Popper.prototype.onUpdate = function (callback) {
9003
+ this.state.updateCallback = callback;
9004
+ return this;
9005
+ };
9006
+
8990
9007
  /**
8991
9008
  * Helper used to generate poppers from a configuration file
8992
9009
  * @method
8993
9010
  * @memberof Popper
8994
9011
  * @param config {Object} configuration
8995
9012
  * @returns {HTMLElement} popper
8996
- */
8997
- Popper.prototype.parse = function (config) {
8998
- var defaultConfig = {
8999
- tagName: 'div',
9000
- classNames: ['popper'],
9001
- attributes: [],
9002
- parent: root.document.body,
9003
- content: '',
9004
- contentType: 'text',
9005
- arrowTagName: 'div',
9006
- arrowClassNames: ['popper__arrow'],
9007
- arrowAttributes: ['x-arrow']
9008
- };
9009
- config = Object.assign({}, defaultConfig, config);
9010
-
9011
- var d = root.document;
9012
-
9013
- var popper = d.createElement(config.tagName);
9014
- addClassNames(popper, config.classNames);
9015
- addAttributes(popper, config.attributes);
9016
- if (config.contentType === 'node') {
9017
- popper.appendChild(config.content.jquery ? config.content[0] : config.content);
9018
- } else if (config.contentType === 'html') {
9019
- popper.innerHTML = config.content;
9020
- } else {
9021
- popper.textContent = config.content;
9022
- }
9023
-
9024
- if (config.arrowTagName) {
9025
- var arrow = d.createElement(config.arrowTagName);
9026
- addClassNames(arrow, config.arrowClassNames);
9027
- addAttributes(arrow, config.arrowAttributes);
9028
- popper.appendChild(arrow);
9029
- }
9030
-
9031
- var parent = config.parent.jquery ? config.parent[0] : config.parent;
9032
-
9033
- // if the given parent is a string, use it to match an element
9034
- // if more than one element is matched, the first one will be used as parent
9035
- // if no elements are matched, the script will throw an error
9036
- if (typeof parent === 'string') {
9037
- parent = d.querySelectorAll(config.parent);
9038
- if (parent.length > 1) {
9039
- console.warn('WARNING: the given `parent` query(' + config.parent + ') matched more than one element, the first one will be used');
9040
- }
9041
- if (parent.length === 0) {
9042
- throw "ERROR: the given `parent` doesn't exists!";
9043
- }
9044
- parent = parent[0];
9045
- }
9046
- // if the given parent is a DOM nodes list or an array of nodes with more than one element,
9047
- // the first one will be used as parent
9048
- if (parent.length > 1 && parent instanceof Element === false) {
9049
- console.warn('WARNING: you have passed as parent a list of elements, the first one will be used');
9050
- parent = parent[0];
9051
- }
9052
-
9053
- // append the generated popper to its parent
9054
- parent.appendChild(popper);
9055
-
9056
- return popper;
9057
-
9013
+ */
9014
+ Popper.prototype.parse = function (config) {
9015
+ var defaultConfig = {
9016
+ tagName: 'div',
9017
+ classNames: ['popper'],
9018
+ attributes: [],
9019
+ parent: root.document.body,
9020
+ content: '',
9021
+ contentType: 'text',
9022
+ arrowTagName: 'div',
9023
+ arrowClassNames: ['popper__arrow'],
9024
+ arrowAttributes: ['x-arrow']
9025
+ };
9026
+ config = Object.assign({}, defaultConfig, config);
9027
+
9028
+ var d = root.document;
9029
+
9030
+ var popper = d.createElement(config.tagName);
9031
+ addClassNames(popper, config.classNames);
9032
+ addAttributes(popper, config.attributes);
9033
+ if (config.contentType === 'node') {
9034
+ popper.appendChild(
9035
+ config.content.jquery ? config.content[0] : config.content
9036
+ );
9037
+ } else if (config.contentType === 'html') {
9038
+ popper.innerHTML = config.content;
9039
+ } else {
9040
+ popper.textContent = config.content;
9041
+ }
9042
+
9043
+ if (config.arrowTagName) {
9044
+ var arrow = d.createElement(config.arrowTagName);
9045
+ addClassNames(arrow, config.arrowClassNames);
9046
+ addAttributes(arrow, config.arrowAttributes);
9047
+ popper.appendChild(arrow);
9048
+ }
9049
+
9050
+ var parent = config.parent.jquery ? config.parent[0] : config.parent;
9051
+
9052
+ // if the given parent is a string, use it to match an element
9053
+ // if more than one element is matched, the first one will be used as parent
9054
+ // if no elements are matched, the script will throw an error
9055
+ if (typeof parent === 'string') {
9056
+ parent = d.querySelectorAll(config.parent);
9057
+ if (parent.length > 1) {
9058
+ console.warn(
9059
+ 'WARNING: the given `parent` query(' +
9060
+ config.parent +
9061
+ ') matched more than one element, the first one will be used'
9062
+ );
9063
+ }
9064
+ if (parent.length === 0) {
9065
+ throw "ERROR: the given `parent` doesn't exists!";
9066
+ }
9067
+ parent = parent[0];
9068
+ }
9069
+ // if the given parent is a DOM nodes list or an array of nodes with more than one element,
9070
+ // the first one will be used as parent
9071
+ if (parent.length > 1 && parent instanceof Element === false) {
9072
+ console.warn(
9073
+ 'WARNING: you have passed as parent a list of elements, the first one will be used'
9074
+ );
9075
+ parent = parent[0];
9076
+ }
9077
+
9078
+ // append the generated popper to its parent
9079
+ parent.appendChild(popper);
9080
+
9081
+ return popper;
9082
+
9058
9083
  /**
9059
9084
  * Adds class names to the given element
9060
9085
  * @function
9061
9086
  * @ignore
9062
9087
  * @param {HTMLElement} target
9063
9088
  * @param {Array} classes
9064
- */
9065
- function addClassNames(element, classNames) {
9066
- classNames.forEach(function (className) {
9067
- element.classList.add(className);
9068
- });
9069
- }
9070
-
9089
+ */
9090
+ function addClassNames(element, classNames) {
9091
+ classNames.forEach(function (className) {
9092
+ element.classList.add(className);
9093
+ });
9094
+ }
9095
+
9071
9096
  /**
9072
9097
  * Adds attributes to the given element
9073
9098
  * @function
@@ -9076,14 +9101,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
9076
9101
  * @param {Array} attributes
9077
9102
  * @example
9078
9103
  * addAttributes(element, [ 'data-info:foobar' ]);
9079
- */
9080
- function addAttributes(element, attributes) {
9081
- attributes.forEach(function (attribute) {
9082
- element.setAttribute(attribute.split(':')[0], attribute.split(':')[1] || '');
9083
- });
9084
- }
9085
- };
9086
-
9104
+ */
9105
+ function addAttributes(element, attributes) {
9106
+ attributes.forEach(function (attribute) {
9107
+ element.setAttribute(
9108
+ attribute.split(':')[0],
9109
+ attribute.split(':')[1] || ''
9110
+ );
9111
+ });
9112
+ }
9113
+ };
9114
+
9087
9115
  /**
9088
9116
  * Helper used to get the position which will be applied to the popper
9089
9117
  * @method
@@ -9091,20 +9119,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
9091
9119
  * @param config {HTMLElement} popper element
9092
9120
  * @param reference {HTMLElement} reference element
9093
9121
  * @returns {String} position
9094
- */
9095
- Popper.prototype._getPosition = function (popper, reference) {
9096
- var container = getOffsetParent(reference);
9097
-
9098
- if (this._options.forceAbsolute) {
9099
- return 'absolute';
9100
- }
9101
-
9102
- // Decide if the popper will be fixed
9103
- // If the reference element is inside a fixed context, the popper will be fixed as well to allow them to scroll together
9104
- var isParentFixed = isFixed(reference, container);
9105
- return isParentFixed ? 'fixed' : 'absolute';
9106
- };
9107
-
9122
+ */
9123
+ Popper.prototype._getPosition = function (popper, reference) {
9124
+ var container = getOffsetParent(reference);
9125
+
9126
+ if (this._options.forceAbsolute) {
9127
+ return 'absolute';
9128
+ }
9129
+
9130
+ // Decide if the popper will be fixed
9131
+ // If the reference element is inside a fixed context, the popper will be fixed as well to allow them to scroll together
9132
+ var isParentFixed = isFixed(reference, container);
9133
+ return isParentFixed ? 'fixed' : 'absolute';
9134
+ };
9135
+
9108
9136
  /**
9109
9137
  * Get offsets to the popper
9110
9138
  * @method
@@ -9113,93 +9141,110 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
9113
9141
  * @param {Element} popper - the popper element
9114
9142
  * @param {Element} reference - the reference element (the popper will be relative to this)
9115
9143
  * @returns {Object} An object containing the offsets which will be applied to the popper
9116
- */
9117
- Popper.prototype._getOffsets = function (popper, reference, placement) {
9118
- placement = placement.split('-')[0];
9119
- var popperOffsets = {};
9120
-
9121
- popperOffsets.position = this.state.position;
9122
- var isParentFixed = popperOffsets.position === 'fixed';
9123
-
9124
- //
9125
- // Get reference element position
9126
- //
9127
- var referenceOffsets = getOffsetRectRelativeToCustomParent(reference, getOffsetParent(popper), isParentFixed);
9128
-
9129
- //
9130
- // Get popper sizes
9131
- //
9132
- var popperRect = getOuterSizes(popper);
9133
-
9134
- //
9135
- // Compute offsets of popper
9136
- //
9137
-
9138
- // depending by the popper placement we have to compute its offsets slightly differently
9139
- if (['right', 'left'].indexOf(placement) !== -1) {
9140
- popperOffsets.top = referenceOffsets.top + referenceOffsets.height / 2 - popperRect.height / 2;
9141
- if (placement === 'left') {
9142
- popperOffsets.left = referenceOffsets.left - popperRect.width;
9143
- } else {
9144
- popperOffsets.left = referenceOffsets.right;
9145
- }
9146
- } else {
9147
- popperOffsets.left = referenceOffsets.left + referenceOffsets.width / 2 - popperRect.width / 2;
9148
- if (placement === 'top') {
9149
- popperOffsets.top = referenceOffsets.top - popperRect.height;
9150
- } else {
9151
- popperOffsets.top = referenceOffsets.bottom;
9152
- }
9153
- }
9154
-
9155
- // Add width and height to our offsets object
9156
- popperOffsets.width = popperRect.width;
9157
- popperOffsets.height = popperRect.height;
9158
-
9159
- return {
9160
- popper: popperOffsets,
9161
- reference: referenceOffsets
9162
- };
9163
- };
9164
-
9144
+ */
9145
+ Popper.prototype._getOffsets = function (popper, reference, placement) {
9146
+ placement = placement.split('-')[0];
9147
+ var popperOffsets = {};
9148
+
9149
+ popperOffsets.position = this.state.position;
9150
+ var isParentFixed = popperOffsets.position === 'fixed';
9151
+
9152
+ //
9153
+ // Get reference element position
9154
+ //
9155
+ var referenceOffsets = getOffsetRectRelativeToCustomParent(
9156
+ reference,
9157
+ popper,
9158
+ isParentFixed
9159
+ );
9160
+
9161
+ //
9162
+ // Get popper sizes
9163
+ //
9164
+ var popperRect = getOuterSizes(popper);
9165
+
9166
+ //
9167
+ // Compute offsets of popper
9168
+ //
9169
+
9170
+ // depending by the popper placement we have to compute its offsets slightly differently
9171
+ if (['right', 'left'].indexOf(placement) !== -1) {
9172
+ popperOffsets.top =
9173
+ referenceOffsets.top +
9174
+ referenceOffsets.height / 2 -
9175
+ popperRect.height / 2;
9176
+ if (placement === 'left') {
9177
+ popperOffsets.left = referenceOffsets.left - popperRect.width;
9178
+ } else {
9179
+ popperOffsets.left = referenceOffsets.right;
9180
+ }
9181
+ } else {
9182
+ popperOffsets.left =
9183
+ referenceOffsets.left +
9184
+ referenceOffsets.width / 2 -
9185
+ popperRect.width / 2;
9186
+ if (placement === 'top') {
9187
+ popperOffsets.top = referenceOffsets.top - popperRect.height;
9188
+ } else {
9189
+ popperOffsets.top = referenceOffsets.bottom;
9190
+ }
9191
+ }
9192
+
9193
+ // Add width and height to our offsets object
9194
+ popperOffsets.width = popperRect.width;
9195
+ popperOffsets.height = popperRect.height;
9196
+
9197
+ return {
9198
+ popper: popperOffsets,
9199
+ reference: referenceOffsets
9200
+ };
9201
+ };
9202
+
9165
9203
  /**
9166
9204
  * Setup needed event listeners used to update the popper position
9167
9205
  * @method
9168
9206
  * @memberof Popper
9169
9207
  * @access private
9170
- */
9171
- Popper.prototype._setupEventListeners = function () {
9172
- // NOTE: 1 DOM access here
9173
- this.state.updateBound = this.update.bind(this);
9174
- root.addEventListener('resize', this.state.updateBound);
9175
- // if the boundariesElement is window we don't need to listen for the scroll event
9176
- if (this._options.boundariesElement !== 'window') {
9177
- var target = getScrollParent(this._reference);
9178
- // here it could be both `body` or `documentElement` thanks to Firefox, we then check both
9179
- if (target === root.document.body || target === root.document.documentElement) {
9180
- target = root;
9181
- }
9182
- target.addEventListener('scroll', this.state.updateBound);
9183
- this.state.scrollTarget = target;
9184
- }
9185
- };
9186
-
9208
+ */
9209
+ Popper.prototype._setupEventListeners = function () {
9210
+ // NOTE: 1 DOM access here
9211
+ this.state.updateBound = this.update.bind(this);
9212
+ // 无界等微前端场景下沙箱 window 不会触发 resize,需监听真实 window
9213
+ this.state.realWindow = getRealWindow(this._popper);
9214
+ this.state.realWindow.addEventListener('resize', this.state.updateBound);
9215
+ // if the boundariesElement is window we don't need to listen for the scroll event
9216
+ if (this._options.boundariesElement !== 'window') {
9217
+ var target = getScrollParent(this._reference);
9218
+ target.addEventListener('scroll', this.state.updateBound);
9219
+ this.state.scrollTarget = target;
9220
+ }
9221
+ };
9222
+
9187
9223
  /**
9188
9224
  * Remove event listeners used to update the popper position
9189
9225
  * @method
9190
9226
  * @memberof Popper
9191
9227
  * @access private
9192
- */
9193
- Popper.prototype._removeEventListeners = function () {
9194
- // NOTE: 1 DOM access here
9195
- root.removeEventListener('resize', this.state.updateBound);
9196
- if (this._options.boundariesElement !== 'window' && this.state.scrollTarget) {
9197
- this.state.scrollTarget.removeEventListener('scroll', this.state.updateBound);
9198
- this.state.scrollTarget = null;
9199
- }
9200
- this.state.updateBound = null;
9201
- };
9202
-
9228
+ */
9229
+ Popper.prototype._removeEventListeners = function () {
9230
+ // NOTE: 1 DOM access here
9231
+ (this.state.realWindow || root).removeEventListener(
9232
+ 'resize',
9233
+ this.state.updateBound
9234
+ );
9235
+ if (
9236
+ this._options.boundariesElement !== 'window' &&
9237
+ this.state.scrollTarget
9238
+ ) {
9239
+ this.state.scrollTarget.removeEventListener(
9240
+ 'scroll',
9241
+ this.state.updateBound
9242
+ );
9243
+ this.state.scrollTarget = null;
9244
+ }
9245
+ this.state.updateBound = null;
9246
+ };
9247
+
9203
9248
  /**
9204
9249
  * Computed the boundaries limits and return them
9205
9250
  * @method
@@ -9209,66 +9254,75 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
9209
9254
  * @param {Number} padding - Boundaries padding
9210
9255
  * @param {Element} boundariesElement - Element used to define the boundaries
9211
9256
  * @returns {Object} Coordinates of the boundaries
9212
- */
9213
- Popper.prototype._getBoundaries = function (data, padding, boundariesElement) {
9214
- // NOTE: 1 DOM access here
9215
- var boundaries = {};
9216
- var width, height;
9217
- if (boundariesElement === 'window') {
9218
- var body = root.document.body,
9219
- html = root.document.documentElement;
9220
-
9221
- height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
9222
- width = Math.max(body.scrollWidth, body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth);
9223
-
9224
- boundaries = {
9225
- top: 0,
9226
- right: width,
9227
- bottom: height,
9228
- left: 0
9229
- };
9230
- } else if (boundariesElement === 'viewport') {
9231
- var offsetParent = getOffsetParent(this._popper);
9232
- var scrollParent = getScrollParent(this._popper);
9233
- var offsetParentRect = getOffsetRect(offsetParent);
9234
-
9235
- // Thanks the fucking native API, `document.body.scrollTop` & `document.documentElement.scrollTop`
9236
- var getScrollTopValue = function getScrollTopValue(element) {
9237
- return element == document.body ? Math.max(document.documentElement.scrollTop, document.body.scrollTop) : element.scrollTop;
9238
- };
9239
- var getScrollLeftValue = function getScrollLeftValue(element) {
9240
- return element == document.body ? Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) : element.scrollLeft;
9241
- };
9242
-
9243
- // if the popper is fixed we don't have to substract scrolling from the boundaries
9244
- var scrollTop = data.offsets.popper.position === 'fixed' ? 0 : getScrollTopValue(scrollParent);
9245
- var scrollLeft = data.offsets.popper.position === 'fixed' ? 0 : getScrollLeftValue(scrollParent);
9246
-
9247
- boundaries = {
9248
- top: 0 - (offsetParentRect.top - scrollTop),
9249
- right: root.document.documentElement.clientWidth - (offsetParentRect.left - scrollLeft),
9250
- bottom: root.document.documentElement.clientHeight - (offsetParentRect.top - scrollTop),
9251
- left: 0 - (offsetParentRect.left - scrollLeft)
9252
- };
9253
- } else {
9254
- if (getOffsetParent(this._popper) === boundariesElement) {
9255
- boundaries = {
9256
- top: 0,
9257
- left: 0,
9258
- right: boundariesElement.clientWidth,
9259
- bottom: boundariesElement.clientHeight
9260
- };
9261
- } else {
9262
- boundaries = getOffsetRect(boundariesElement);
9263
- }
9264
- }
9265
- boundaries.left += padding;
9266
- boundaries.right -= padding;
9267
- boundaries.top = boundaries.top + padding;
9268
- boundaries.bottom = boundaries.bottom - padding;
9269
- return boundaries;
9270
- };
9271
-
9257
+ */
9258
+ Popper.prototype._getBoundaries = function (data, padding, boundariesElement) {
9259
+ // NOTE: 1 DOM access here
9260
+ var boundaries = {};
9261
+ var width, height;
9262
+ if (boundariesElement === 'window') {
9263
+ var body = root.document.body,
9264
+ html = root.document.documentElement;
9265
+
9266
+ height = Math.max(
9267
+ body.scrollHeight,
9268
+ body.offsetHeight,
9269
+ html.clientHeight,
9270
+ html.scrollHeight,
9271
+ html.offsetHeight
9272
+ );
9273
+ width = Math.max(
9274
+ body.scrollWidth,
9275
+ body.offsetWidth,
9276
+ html.clientWidth,
9277
+ html.scrollWidth,
9278
+ html.offsetWidth
9279
+ );
9280
+
9281
+ boundaries = {
9282
+ top: 0,
9283
+ right: width,
9284
+ bottom: height,
9285
+ left: 0
9286
+ };
9287
+ } else if (boundariesElement === 'viewport') {
9288
+ // 将真实 window 的视口换算到 popper 所在包含块的坐标系。
9289
+ // 无界等场景下沙箱 window 的尺寸、shadowRoot 内元素的 scrollTop 均不可靠,
9290
+ // 统一从元素自身的 view 与真实包含块获取
9291
+ var realWindow = getRealWindow(this._popper);
9292
+ var containingBlockRect = getContainingBlockRect(
9293
+ this._popper,
9294
+ data.offsets.popper.position === 'fixed'
9295
+ );
9296
+
9297
+ boundaries = {
9298
+ top: 0 - containingBlockRect.top,
9299
+ right:
9300
+ realWindow.document.documentElement.clientWidth -
9301
+ containingBlockRect.left,
9302
+ bottom:
9303
+ realWindow.document.documentElement.clientHeight -
9304
+ containingBlockRect.top,
9305
+ left: 0 - containingBlockRect.left
9306
+ };
9307
+ } else {
9308
+ if (getOffsetParent(this._popper) === boundariesElement) {
9309
+ boundaries = {
9310
+ top: 0,
9311
+ left: 0,
9312
+ right: boundariesElement.clientWidth,
9313
+ bottom: boundariesElement.clientHeight
9314
+ };
9315
+ } else {
9316
+ boundaries = getOffsetRect(boundariesElement);
9317
+ }
9318
+ }
9319
+ boundaries.left += padding;
9320
+ boundaries.right -= padding;
9321
+ boundaries.top = boundaries.top + padding;
9322
+ boundaries.bottom = boundaries.bottom - padding;
9323
+ return boundaries;
9324
+ };
9325
+
9272
9326
  /**
9273
9327
  * Loop trough the list of modifiers and run them in order, each of them will then edit the data object
9274
9328
  * @method
@@ -9277,22 +9331,27 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
9277
9331
  * @param {Object} data
9278
9332
  * @param {Array} modifiers
9279
9333
  * @param {Function} ends
9280
- */
9281
- Popper.prototype.runModifiers = function (data, modifiers, ends) {
9282
- var modifiersToRun = modifiers.slice();
9283
- if (ends !== undefined) {
9284
- modifiersToRun = this._options.modifiers.slice(0, getArrayKeyIndex(this._options.modifiers, ends));
9285
- }
9286
-
9287
- modifiersToRun.forEach(function (modifier) {
9288
- if (isFunction(modifier)) {
9289
- data = modifier.call(this, data);
9290
- }
9291
- }.bind(this));
9292
-
9293
- return data;
9294
- };
9295
-
9334
+ */
9335
+ Popper.prototype.runModifiers = function (data, modifiers, ends) {
9336
+ var modifiersToRun = modifiers.slice();
9337
+ if (ends !== undefined) {
9338
+ modifiersToRun = this._options.modifiers.slice(
9339
+ 0,
9340
+ getArrayKeyIndex(this._options.modifiers, ends)
9341
+ );
9342
+ }
9343
+
9344
+ modifiersToRun.forEach(
9345
+ function (modifier) {
9346
+ if (isFunction(modifier)) {
9347
+ data = modifier.call(this, data);
9348
+ }
9349
+ }.bind(this)
9350
+ );
9351
+
9352
+ return data;
9353
+ };
9354
+
9296
9355
  /**
9297
9356
  * Helper used to know if the given modifier depends from another one.
9298
9357
  * @method
@@ -9300,191 +9359,204 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
9300
9359
  * @param {String} requesting - name of requesting modifier
9301
9360
  * @param {String} requested - name of requested modifier
9302
9361
  * @returns {Boolean}
9303
- */
9304
- Popper.prototype.isModifierRequired = function (requesting, requested) {
9305
- var index = getArrayKeyIndex(this._options.modifiers, requesting);
9306
- return !!this._options.modifiers.slice(0, index).filter(function (modifier) {
9307
- return modifier === requested;
9308
- }).length;
9309
- };
9310
-
9311
- //
9312
- // Modifiers
9313
- //
9314
-
9362
+ */
9363
+ Popper.prototype.isModifierRequired = function (requesting, requested) {
9364
+ var index = getArrayKeyIndex(this._options.modifiers, requesting);
9365
+ return !!this._options.modifiers.slice(0, index).filter(function (modifier) {
9366
+ return modifier === requested;
9367
+ }).length;
9368
+ };
9369
+
9370
+ //
9371
+ // Modifiers
9372
+ //
9373
+
9315
9374
  /**
9316
9375
  * Modifiers list
9317
9376
  * @namespace Popper.modifiers
9318
9377
  * @memberof Popper
9319
9378
  * @type {Object}
9320
- */
9321
- Popper.prototype.modifiers = {};
9322
-
9379
+ */
9380
+ Popper.prototype.modifiers = {};
9381
+
9323
9382
  /**
9324
9383
  * Apply the computed styles to the popper element
9325
9384
  * @method
9326
9385
  * @memberof Popper.modifiers
9327
9386
  * @argument {Object} data - The data object generated by `update` method
9328
9387
  * @returns {Object} The same data object
9329
- */
9330
- Popper.prototype.modifiers.applyStyle = function (data) {
9331
- // apply the final offsets to the popper
9332
- // NOTE: 1 DOM access here
9333
- var styles = {
9334
- position: data.offsets.popper.position
9335
- };
9336
-
9337
- // round top and left to avoid blurry text
9338
- var left = Math.round(data.offsets.popper.left);
9339
- var top = Math.round(data.offsets.popper.top);
9340
-
9341
- // if gpuAcceleration is set to true and transform is supported, we use `translate3d` to apply the position to the popper
9342
- // we automatically use the supported prefixed version if needed
9343
- var prefixedProperty;
9344
- if (this._options.gpuAcceleration && (prefixedProperty = getSupportedPropertyName('transform'))) {
9345
- styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
9346
- styles.top = 0;
9347
- styles.left = 0;
9348
- }
9349
- // othwerise, we use the standard `left` and `top` properties
9350
- else {
9351
- styles.left = left;
9352
- styles.top = top;
9353
- }
9354
-
9355
- // any property present in `data.styles` will be applied to the popper,
9356
- // in this way we can make the 3rd party modifiers add custom styles to it
9357
- // Be aware, modifiers could override the properties defined in the previous
9358
- // lines of this modifier!
9359
- Object.assign(styles, data.styles);
9360
-
9361
- setStyle(this._popper, styles);
9362
-
9363
- // set an attribute which will be useful to style the tooltip (use it to properly position its arrow)
9364
- // NOTE: 1 DOM access here
9365
- this._popper.setAttribute('x-placement', data.placement);
9366
-
9367
- // if the arrow modifier is required and the arrow style has been computed, apply the arrow style
9368
- if (this.isModifierRequired(this.modifiers.applyStyle, this.modifiers.arrow) && data.offsets.arrow) {
9369
- setStyle(data.arrowElement, data.offsets.arrow);
9370
- }
9371
-
9372
- return data;
9373
- };
9374
-
9388
+ */
9389
+ Popper.prototype.modifiers.applyStyle = function (data) {
9390
+ // apply the final offsets to the popper
9391
+ // NOTE: 1 DOM access here
9392
+ var styles = {
9393
+ position: data.offsets.popper.position
9394
+ };
9395
+
9396
+ // round top and left to avoid blurry text
9397
+ var left = Math.round(data.offsets.popper.left);
9398
+ var top = Math.round(data.offsets.popper.top);
9399
+
9400
+ // if gpuAcceleration is set to true and transform is supported, we use `translate3d` to apply the position to the popper
9401
+ // we automatically use the supported prefixed version if needed
9402
+ var prefixedProperty;
9403
+ if (
9404
+ this._options.gpuAcceleration &&
9405
+ (prefixedProperty = getSupportedPropertyName('transform'))
9406
+ ) {
9407
+ styles[prefixedProperty] =
9408
+ 'translate3d(' + left + 'px, ' + top + 'px, 0)';
9409
+ styles.top = 0;
9410
+ styles.left = 0;
9411
+ }
9412
+ // othwerise, we use the standard `left` and `top` properties
9413
+ else {
9414
+ styles.left = left;
9415
+ styles.top = top;
9416
+ }
9417
+
9418
+ // any property present in `data.styles` will be applied to the popper,
9419
+ // in this way we can make the 3rd party modifiers add custom styles to it
9420
+ // Be aware, modifiers could override the properties defined in the previous
9421
+ // lines of this modifier!
9422
+ Object.assign(styles, data.styles);
9423
+
9424
+ setStyle(this._popper, styles);
9425
+
9426
+ // set an attribute which will be useful to style the tooltip (use it to properly position its arrow)
9427
+ // NOTE: 1 DOM access here
9428
+ this._popper.setAttribute('x-placement', data.placement);
9429
+
9430
+ // if the arrow modifier is required and the arrow style has been computed, apply the arrow style
9431
+ if (
9432
+ this.isModifierRequired(
9433
+ this.modifiers.applyStyle,
9434
+ this.modifiers.arrow
9435
+ ) &&
9436
+ data.offsets.arrow
9437
+ ) {
9438
+ setStyle(data.arrowElement, data.offsets.arrow);
9439
+ }
9440
+
9441
+ return data;
9442
+ };
9443
+
9375
9444
  /**
9376
9445
  * Modifier used to shift the popper on the start or end of its reference element side
9377
9446
  * @method
9378
9447
  * @memberof Popper.modifiers
9379
9448
  * @argument {Object} data - The data object generated by `update` method
9380
9449
  * @returns {Object} The data object, properly modified
9381
- */
9382
- Popper.prototype.modifiers.shift = function (data) {
9383
- var placement = data.placement;
9384
- var basePlacement = placement.split('-')[0];
9385
- var shiftVariation = placement.split('-')[1];
9386
-
9387
- // if shift shiftVariation is specified, run the modifier
9388
- if (shiftVariation) {
9389
- var reference = data.offsets.reference;
9390
- var popper = getPopperClientRect(data.offsets.popper);
9391
-
9392
- var shiftOffsets = {
9393
- y: {
9394
- start: { top: reference.top },
9395
- end: { top: reference.top + reference.height - popper.height }
9396
- },
9397
- x: {
9398
- start: { left: reference.left },
9399
- end: { left: reference.left + reference.width - popper.width }
9400
- }
9401
- };
9402
-
9403
- var axis = ['bottom', 'top'].indexOf(basePlacement) !== -1 ? 'x' : 'y';
9404
-
9405
- data.offsets.popper = Object.assign(popper, shiftOffsets[axis][shiftVariation]);
9406
- }
9407
-
9408
- return data;
9409
- };
9410
-
9450
+ */
9451
+ Popper.prototype.modifiers.shift = function (data) {
9452
+ var placement = data.placement;
9453
+ var basePlacement = placement.split('-')[0];
9454
+ var shiftVariation = placement.split('-')[1];
9455
+
9456
+ // if shift shiftVariation is specified, run the modifier
9457
+ if (shiftVariation) {
9458
+ var reference = data.offsets.reference;
9459
+ var popper = getPopperClientRect(data.offsets.popper);
9460
+
9461
+ var shiftOffsets = {
9462
+ y: {
9463
+ start: { top: reference.top },
9464
+ end: { top: reference.top + reference.height - popper.height }
9465
+ },
9466
+ x: {
9467
+ start: { left: reference.left },
9468
+ end: { left: reference.left + reference.width - popper.width }
9469
+ }
9470
+ };
9471
+
9472
+ var axis = ['bottom', 'top'].indexOf(basePlacement) !== -1 ? 'x' : 'y';
9473
+
9474
+ data.offsets.popper = Object.assign(
9475
+ popper,
9476
+ shiftOffsets[axis][shiftVariation]
9477
+ );
9478
+ }
9479
+
9480
+ return data;
9481
+ };
9482
+
9411
9483
  /**
9412
9484
  * Modifier used to make sure the popper does not overflows from it's boundaries
9413
9485
  * @method
9414
9486
  * @memberof Popper.modifiers
9415
9487
  * @argument {Object} data - The data object generated by `update` method
9416
9488
  * @returns {Object} The data object, properly modified
9417
- */
9418
- Popper.prototype.modifiers.preventOverflow = function (data) {
9419
- var order = this._options.preventOverflowOrder;
9420
- var popper = getPopperClientRect(data.offsets.popper);
9421
-
9422
- var check = {
9423
- left: function left() {
9424
- var left = popper.left;
9425
- if (popper.left < data.boundaries.left) {
9426
- left = Math.max(popper.left, data.boundaries.left);
9427
- }
9428
- return { left: left };
9429
- },
9430
- right: function right() {
9431
- var left = popper.left;
9432
- if (popper.right > data.boundaries.right) {
9433
- left = Math.min(popper.left, data.boundaries.right - popper.width);
9434
- }
9435
- return { left: left };
9436
- },
9437
- top: function top() {
9438
- var top = popper.top;
9439
- if (popper.top < data.boundaries.top) {
9440
- top = Math.max(popper.top, data.boundaries.top);
9441
- }
9442
- return { top: top };
9443
- },
9444
- bottom: function bottom() {
9445
- var top = popper.top;
9446
- if (popper.bottom > data.boundaries.bottom) {
9447
- top = Math.min(popper.top, data.boundaries.bottom - popper.height);
9448
- }
9449
- return { top: top };
9450
- }
9451
- };
9452
-
9453
- order.forEach(function (direction) {
9454
- data.offsets.popper = Object.assign(popper, check[direction]());
9455
- });
9456
-
9457
- return data;
9458
- };
9459
-
9489
+ */
9490
+ Popper.prototype.modifiers.preventOverflow = function (data) {
9491
+ var order = this._options.preventOverflowOrder;
9492
+ var popper = getPopperClientRect(data.offsets.popper);
9493
+
9494
+ var check = {
9495
+ left: function () {
9496
+ var left = popper.left;
9497
+ if (popper.left < data.boundaries.left) {
9498
+ left = Math.max(popper.left, data.boundaries.left);
9499
+ }
9500
+ return { left: left };
9501
+ },
9502
+ right: function () {
9503
+ var left = popper.left;
9504
+ if (popper.right > data.boundaries.right) {
9505
+ left = Math.min(popper.left, data.boundaries.right - popper.width);
9506
+ }
9507
+ return { left: left };
9508
+ },
9509
+ top: function () {
9510
+ var top = popper.top;
9511
+ if (popper.top < data.boundaries.top) {
9512
+ top = Math.max(popper.top, data.boundaries.top);
9513
+ }
9514
+ return { top: top };
9515
+ },
9516
+ bottom: function () {
9517
+ var top = popper.top;
9518
+ if (popper.bottom > data.boundaries.bottom) {
9519
+ top = Math.min(popper.top, data.boundaries.bottom - popper.height);
9520
+ }
9521
+ return { top: top };
9522
+ }
9523
+ };
9524
+
9525
+ order.forEach(function (direction) {
9526
+ data.offsets.popper = Object.assign(popper, check[direction]());
9527
+ });
9528
+
9529
+ return data;
9530
+ };
9531
+
9460
9532
  /**
9461
9533
  * Modifier used to make sure the popper is always near its reference
9462
9534
  * @method
9463
9535
  * @memberof Popper.modifiers
9464
9536
  * @argument {Object} data - The data object generated by _update method
9465
9537
  * @returns {Object} The data object, properly modified
9466
- */
9467
- Popper.prototype.modifiers.keepTogether = function (data) {
9468
- var popper = getPopperClientRect(data.offsets.popper);
9469
- var reference = data.offsets.reference;
9470
- var f = Math.floor;
9471
-
9472
- if (popper.right < f(reference.left)) {
9473
- data.offsets.popper.left = f(reference.left) - popper.width;
9474
- }
9475
- if (popper.left > f(reference.right)) {
9476
- data.offsets.popper.left = f(reference.right);
9477
- }
9478
- if (popper.bottom < f(reference.top)) {
9479
- data.offsets.popper.top = f(reference.top) - popper.height;
9480
- }
9481
- if (popper.top > f(reference.bottom)) {
9482
- data.offsets.popper.top = f(reference.bottom);
9483
- }
9484
-
9485
- return data;
9486
- };
9487
-
9538
+ */
9539
+ Popper.prototype.modifiers.keepTogether = function (data) {
9540
+ var popper = getPopperClientRect(data.offsets.popper);
9541
+ var reference = data.offsets.reference;
9542
+ var f = Math.floor;
9543
+
9544
+ if (popper.right < f(reference.left)) {
9545
+ data.offsets.popper.left = f(reference.left) - popper.width;
9546
+ }
9547
+ if (popper.left > f(reference.right)) {
9548
+ data.offsets.popper.left = f(reference.right);
9549
+ }
9550
+ if (popper.bottom < f(reference.top)) {
9551
+ data.offsets.popper.top = f(reference.top) - popper.height;
9552
+ }
9553
+ if (popper.top > f(reference.bottom)) {
9554
+ data.offsets.popper.top = f(reference.bottom);
9555
+ }
9556
+
9557
+ return data;
9558
+ };
9559
+
9488
9560
  /**
9489
9561
  * Modifier used to flip the placement of the popper when the latter is starting overlapping its reference element.
9490
9562
  * Requires the `preventOverflow` modifier before it in order to work.
@@ -9493,61 +9565,81 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
9493
9565
  * @memberof Popper.modifiers
9494
9566
  * @argument {Object} data - The data object generated by _update method
9495
9567
  * @returns {Object} The data object, properly modified
9496
- */
9497
- Popper.prototype.modifiers.flip = function (data) {
9498
- // check if preventOverflow is in the list of modifiers before the flip modifier.
9499
- // otherwise flip would not work as expected.
9500
- if (!this.isModifierRequired(this.modifiers.flip, this.modifiers.preventOverflow)) {
9501
- console.warn('WARNING: preventOverflow modifier is required by flip modifier in order to work, be sure to include it before flip!');
9502
- return data;
9503
- }
9504
-
9505
- if (data.flipped && data.placement === data._originalPlacement) {
9506
- // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
9507
- return data;
9508
- }
9509
-
9510
- var placement = data.placement.split('-')[0];
9511
- var placementOpposite = getOppositePlacement(placement);
9512
- var variation = data.placement.split('-')[1] || '';
9513
-
9514
- var flipOrder = [];
9515
- if (this._options.flipBehavior === 'flip') {
9516
- flipOrder = [placement, placementOpposite];
9517
- } else {
9518
- flipOrder = this._options.flipBehavior;
9519
- }
9520
-
9521
- flipOrder.forEach(function (step, index) {
9522
- if (placement !== step || flipOrder.length === index + 1) {
9523
- return;
9524
- }
9525
-
9526
- placement = data.placement.split('-')[0];
9527
- placementOpposite = getOppositePlacement(placement);
9528
-
9529
- var popperOffsets = getPopperClientRect(data.offsets.popper);
9530
-
9531
- // this boolean is used to distinguish right and bottom from top and left
9532
- // they need different computations to get flipped
9533
- var a = ['right', 'bottom'].indexOf(placement) !== -1;
9534
-
9535
- // using Math.floor because the reference offsets may contain decimals we are not going to consider here
9536
- if (a && Math.floor(data.offsets.reference[placement]) > Math.floor(popperOffsets[placementOpposite]) || !a && Math.floor(data.offsets.reference[placement]) < Math.floor(popperOffsets[placementOpposite])) {
9537
- // we'll use this boolean to detect any flip loop
9538
- data.flipped = true;
9539
- data.placement = flipOrder[index + 1];
9540
- if (variation) {
9541
- data.placement += '-' + variation;
9542
- }
9543
- data.offsets.popper = this._getOffsets(this._popper, this._reference, data.placement).popper;
9544
-
9545
- data = this.runModifiers(data, this._options.modifiers, this._flip);
9546
- }
9547
- }.bind(this));
9548
- return data;
9549
- };
9550
-
9568
+ */
9569
+ Popper.prototype.modifiers.flip = function (data) {
9570
+ // check if preventOverflow is in the list of modifiers before the flip modifier.
9571
+ // otherwise flip would not work as expected.
9572
+ if (
9573
+ !this.isModifierRequired(
9574
+ this.modifiers.flip,
9575
+ this.modifiers.preventOverflow
9576
+ )
9577
+ ) {
9578
+ console.warn(
9579
+ 'WARNING: preventOverflow modifier is required by flip modifier in order to work, be sure to include it before flip!'
9580
+ );
9581
+ return data;
9582
+ }
9583
+
9584
+ if (data.flipped && data.placement === data._originalPlacement) {
9585
+ // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
9586
+ return data;
9587
+ }
9588
+
9589
+ var placement = data.placement.split('-')[0];
9590
+ var placementOpposite = getOppositePlacement(placement);
9591
+ var variation = data.placement.split('-')[1] || '';
9592
+
9593
+ var flipOrder = [];
9594
+ if (this._options.flipBehavior === 'flip') {
9595
+ flipOrder = [placement, placementOpposite];
9596
+ } else {
9597
+ flipOrder = this._options.flipBehavior;
9598
+ }
9599
+
9600
+ flipOrder.forEach(
9601
+ function (step, index) {
9602
+ if (placement !== step || flipOrder.length === index + 1) {
9603
+ return;
9604
+ }
9605
+
9606
+ placement = data.placement.split('-')[0];
9607
+ placementOpposite = getOppositePlacement(placement);
9608
+
9609
+ var popperOffsets = getPopperClientRect(data.offsets.popper);
9610
+
9611
+ // this boolean is used to distinguish right and bottom from top and left
9612
+ // they need different computations to get flipped
9613
+ var a = ['right', 'bottom'].indexOf(placement) !== -1;
9614
+
9615
+ // using Math.floor because the reference offsets may contain decimals we are not going to consider here
9616
+ if (
9617
+ (a &&
9618
+ Math.floor(data.offsets.reference[placement]) >
9619
+ Math.floor(popperOffsets[placementOpposite])) ||
9620
+ (!a &&
9621
+ Math.floor(data.offsets.reference[placement]) <
9622
+ Math.floor(popperOffsets[placementOpposite]))
9623
+ ) {
9624
+ // we'll use this boolean to detect any flip loop
9625
+ data.flipped = true;
9626
+ data.placement = flipOrder[index + 1];
9627
+ if (variation) {
9628
+ data.placement += '-' + variation;
9629
+ }
9630
+ data.offsets.popper = this._getOffsets(
9631
+ this._popper,
9632
+ this._reference,
9633
+ data.placement
9634
+ ).popper;
9635
+
9636
+ data = this.runModifiers(data, this._options.modifiers, this._flip);
9637
+ }
9638
+ }.bind(this)
9639
+ );
9640
+ return data;
9641
+ };
9642
+
9551
9643
  /**
9552
9644
  * Modifier used to add an offset to the popper, useful if you more granularity positioning your popper.
9553
9645
  * The offsets will shift the popper on the side of its reference element.
@@ -9555,23 +9647,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
9555
9647
  * @memberof Popper.modifiers
9556
9648
  * @argument {Object} data - The data object generated by _update method
9557
9649
  * @returns {Object} The data object, properly modified
9558
- */
9559
- Popper.prototype.modifiers.offset = function (data) {
9560
- var offset = this._options.offset;
9561
- var popper = data.offsets.popper;
9562
-
9563
- if (data.placement.indexOf('left') !== -1) {
9564
- popper.top -= offset;
9565
- } else if (data.placement.indexOf('right') !== -1) {
9566
- popper.top += offset;
9567
- } else if (data.placement.indexOf('top') !== -1) {
9568
- popper.left -= offset;
9569
- } else if (data.placement.indexOf('bottom') !== -1) {
9570
- popper.left += offset;
9571
- }
9572
- return data;
9573
- };
9574
-
9650
+ */
9651
+ Popper.prototype.modifiers.offset = function (data) {
9652
+ var offset = this._options.offset;
9653
+ var popper = data.offsets.popper;
9654
+
9655
+ if (data.placement.indexOf('left') !== -1) {
9656
+ popper.top -= offset;
9657
+ } else if (data.placement.indexOf('right') !== -1) {
9658
+ popper.top += offset;
9659
+ } else if (data.placement.indexOf('top') !== -1) {
9660
+ popper.left -= offset;
9661
+ } else if (data.placement.indexOf('bottom') !== -1) {
9662
+ popper.left += offset;
9663
+ }
9664
+ return data;
9665
+ };
9666
+
9575
9667
  /**
9576
9668
  * 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
9577
9669
  * It will use the CSS outer size of the arrow element to know how many pixels of conjuction are needed
@@ -9579,136 +9671,147 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
9579
9671
  * @memberof Popper.modifiers
9580
9672
  * @argument {Object} data - The data object generated by _update method
9581
9673
  * @returns {Object} The data object, properly modified
9582
- */
9583
- Popper.prototype.modifiers.arrow = function (data) {
9584
- var arrow = this._options.arrowElement;
9585
- var arrowOffset = this._options.arrowOffset;
9586
-
9587
- // if the arrowElement is a string, suppose it's a CSS selector
9588
- if (typeof arrow === 'string') {
9589
- arrow = this._popper.querySelector(arrow);
9590
- }
9591
-
9592
- // if arrow element is not found, don't run the modifier
9593
- if (!arrow) {
9594
- return data;
9595
- }
9596
-
9597
- // the arrow element must be child of its popper
9598
- if (!this._popper.contains(arrow)) {
9599
- console.warn('WARNING: `arrowElement` must be child of its popper element!');
9600
- return data;
9601
- }
9602
-
9603
- // arrow depends on keepTogether in order to work
9604
- if (!this.isModifierRequired(this.modifiers.arrow, this.modifiers.keepTogether)) {
9605
- console.warn('WARNING: keepTogether modifier is required by arrow modifier in order to work, be sure to include it before arrow!');
9606
- return data;
9607
- }
9608
-
9609
- var arrowStyle = {};
9610
- var placement = data.placement.split('-')[0];
9611
- var popper = getPopperClientRect(data.offsets.popper);
9612
- var reference = data.offsets.reference;
9613
- var isVertical = ['left', 'right'].indexOf(placement) !== -1;
9614
-
9615
- var len = isVertical ? 'height' : 'width';
9616
- var side = isVertical ? 'top' : 'left';
9617
- var translate = isVertical ? 'translateY' : 'translateX';
9618
- var altSide = isVertical ? 'left' : 'top';
9619
- var opSide = isVertical ? 'bottom' : 'right';
9620
- var arrowSize = getOuterSizes(arrow)[len];
9621
-
9622
- //
9623
- // extends keepTogether behavior making sure the popper and its reference have enough pixels in conjuction
9624
- //
9625
-
9626
- // top/left side
9627
- if (reference[opSide] - arrowSize < popper[side]) {
9628
- data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowSize);
9629
- }
9630
- // bottom/right side
9631
- if (reference[side] + arrowSize > popper[opSide]) {
9632
- data.offsets.popper[side] += reference[side] + arrowSize - popper[opSide];
9633
- }
9634
-
9635
- // compute center of the popper
9636
- var center = reference[side] + (arrowOffset || reference[len] / 2 - arrowSize / 2);
9637
-
9638
- var sideValue = center - popper[side];
9639
-
9640
- // prevent arrow from being placed not contiguously to its popper
9641
- sideValue = Math.max(Math.min(popper[len] - arrowSize - 8, sideValue), 8);
9642
- arrowStyle[side] = sideValue;
9643
- arrowStyle[altSide] = ''; // make sure to remove any old style from the arrow
9644
-
9645
- data.offsets.arrow = arrowStyle;
9646
- data.arrowElement = arrow;
9647
-
9648
- return data;
9649
- };
9650
-
9651
- //
9652
- // Helpers
9653
- //
9654
-
9674
+ */
9675
+ Popper.prototype.modifiers.arrow = function (data) {
9676
+ var arrow = this._options.arrowElement;
9677
+ var arrowOffset = this._options.arrowOffset;
9678
+
9679
+ // if the arrowElement is a string, suppose it's a CSS selector
9680
+ if (typeof arrow === 'string') {
9681
+ arrow = this._popper.querySelector(arrow);
9682
+ }
9683
+
9684
+ // if arrow element is not found, don't run the modifier
9685
+ if (!arrow) {
9686
+ return data;
9687
+ }
9688
+
9689
+ // the arrow element must be child of its popper
9690
+ if (!this._popper.contains(arrow)) {
9691
+ console.warn(
9692
+ 'WARNING: `arrowElement` must be child of its popper element!'
9693
+ );
9694
+ return data;
9695
+ }
9696
+
9697
+ // arrow depends on keepTogether in order to work
9698
+ if (
9699
+ !this.isModifierRequired(
9700
+ this.modifiers.arrow,
9701
+ this.modifiers.keepTogether
9702
+ )
9703
+ ) {
9704
+ console.warn(
9705
+ 'WARNING: keepTogether modifier is required by arrow modifier in order to work, be sure to include it before arrow!'
9706
+ );
9707
+ return data;
9708
+ }
9709
+
9710
+ var arrowStyle = {};
9711
+ var placement = data.placement.split('-')[0];
9712
+ var popper = getPopperClientRect(data.offsets.popper);
9713
+ var reference = data.offsets.reference;
9714
+ var isVertical = ['left', 'right'].indexOf(placement) !== -1;
9715
+
9716
+ var len = isVertical ? 'height' : 'width';
9717
+ var side = isVertical ? 'top' : 'left';
9718
+ var translate = isVertical ? 'translateY' : 'translateX';
9719
+ var altSide = isVertical ? 'left' : 'top';
9720
+ var opSide = isVertical ? 'bottom' : 'right';
9721
+ var arrowSize = getOuterSizes(arrow)[len];
9722
+
9723
+ //
9724
+ // extends keepTogether behavior making sure the popper and its reference have enough pixels in conjuction
9725
+ //
9726
+
9727
+ // top/left side
9728
+ if (reference[opSide] - arrowSize < popper[side]) {
9729
+ data.offsets.popper[side] -=
9730
+ popper[side] - (reference[opSide] - arrowSize);
9731
+ }
9732
+ // bottom/right side
9733
+ if (reference[side] + arrowSize > popper[opSide]) {
9734
+ data.offsets.popper[side] += reference[side] + arrowSize - popper[opSide];
9735
+ }
9736
+
9737
+ // compute center of the popper
9738
+ var center =
9739
+ reference[side] + (arrowOffset || reference[len] / 2 - arrowSize / 2);
9740
+
9741
+ var sideValue = center - popper[side];
9742
+
9743
+ // prevent arrow from being placed not contiguously to its popper
9744
+ sideValue = Math.max(Math.min(popper[len] - arrowSize - 8, sideValue), 8);
9745
+ arrowStyle[side] = sideValue;
9746
+ arrowStyle[altSide] = ''; // make sure to remove any old style from the arrow
9747
+
9748
+ data.offsets.arrow = arrowStyle;
9749
+ data.arrowElement = arrow;
9750
+
9751
+ return data;
9752
+ };
9753
+
9754
+ //
9755
+ // Helpers
9756
+ //
9757
+
9655
9758
  /**
9656
9759
  * Get the outer sizes of the given element (offset size + margins)
9657
9760
  * @function
9658
9761
  * @ignore
9659
9762
  * @argument {Element} element
9660
9763
  * @returns {Object} object containing width and height properties
9661
- */
9662
- function getOuterSizes(element) {
9663
- // NOTE: 1 DOM access here
9664
- var _display = element.style.display,
9665
- _visibility = element.style.visibility;
9666
- element.style.display = 'block';
9667
- element.style.visibility = 'hidden';
9668
- var calcWidthToForceRepaint = element.offsetWidth;
9669
- // original method
9670
- var styles = root.getComputedStyle(element);
9671
- var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
9672
- var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
9673
- var result = {
9674
- width: element.offsetWidth + y,
9675
- height: element.offsetHeight + x
9676
- };
9677
-
9678
- // reset element styles
9679
- element.style.display = _display;
9680
- element.style.visibility = _visibility;
9681
- return result;
9682
- }
9683
-
9764
+ */
9765
+ function getOuterSizes(element) {
9766
+ // NOTE: 1 DOM access here
9767
+ var _display = element.style.display,
9768
+ _visibility = element.style.visibility;
9769
+ element.style.display = 'block';
9770
+ element.style.visibility = 'hidden';
9771
+ var calcWidthToForceRepaint = element.offsetWidth;
9772
+ // original method
9773
+ var styles = getRealWindow(element).getComputedStyle(element);
9774
+ var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
9775
+ var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
9776
+ var result = {
9777
+ width: element.offsetWidth + y,
9778
+ height: element.offsetHeight + x
9779
+ };
9780
+
9781
+ // reset element styles
9782
+ element.style.display = _display;
9783
+ element.style.visibility = _visibility;
9784
+ return result;
9785
+ }
9786
+
9684
9787
  /**
9685
9788
  * Get the opposite placement of the given one/
9686
9789
  * @function
9687
9790
  * @ignore
9688
9791
  * @argument {String} placement
9689
9792
  * @returns {String} flipped placement
9690
- */
9691
- function getOppositePlacement(placement) {
9692
- var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
9693
- return placement.replace(/left|right|bottom|top/g, function (matched) {
9694
- return hash[matched];
9695
- });
9696
- }
9697
-
9793
+ */
9794
+ function getOppositePlacement(placement) {
9795
+ var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
9796
+ return placement.replace(/left|right|bottom|top/g, function (matched) {
9797
+ return hash[matched];
9798
+ });
9799
+ }
9800
+
9698
9801
  /**
9699
9802
  * Given the popper offsets, generate an output similar to getBoundingClientRect
9700
9803
  * @function
9701
9804
  * @ignore
9702
9805
  * @argument {Object} popperOffsets
9703
9806
  * @returns {Object} ClientRect like output
9704
- */
9705
- function getPopperClientRect(popperOffsets) {
9706
- var offsets = Object.assign({}, popperOffsets);
9707
- offsets.right = offsets.left + offsets.width;
9708
- offsets.bottom = offsets.top + offsets.height;
9709
- return offsets;
9710
- }
9711
-
9807
+ */
9808
+ function getPopperClientRect(popperOffsets) {
9809
+ var offsets = Object.assign({}, popperOffsets);
9810
+ offsets.right = offsets.left + offsets.width;
9811
+ offsets.bottom = offsets.top + offsets.height;
9812
+ return offsets;
9813
+ }
9814
+
9712
9815
  /**
9713
9816
  * Given an array and the key to find, returns its index
9714
9817
  * @function
@@ -9716,76 +9819,155 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
9716
9819
  * @argument {Array} arr
9717
9820
  * @argument keyToFind
9718
9821
  * @returns index or null
9719
- */
9720
- function getArrayKeyIndex(arr, keyToFind) {
9721
- var i = 0,
9722
- key;
9723
- for (key in arr) {
9724
- if (arr[key] === keyToFind) {
9725
- return i;
9726
- }
9727
- i++;
9728
- }
9729
- return null;
9730
- }
9731
-
9822
+ */
9823
+ function getArrayKeyIndex(arr, keyToFind) {
9824
+ var i = 0,
9825
+ key;
9826
+ for (key in arr) {
9827
+ if (arr[key] === keyToFind) {
9828
+ return i;
9829
+ }
9830
+ i++;
9831
+ }
9832
+ return null;
9833
+ }
9834
+
9732
9835
  /**
9733
9836
  * Get CSS computed property of the given element
9734
9837
  * @function
9735
9838
  * @ignore
9736
9839
  * @argument {Eement} element
9737
9840
  * @argument {String} property
9738
- */
9739
- function getStyleComputedProperty(element, property) {
9740
- // NOTE: 1 DOM access here
9741
- var css = root.getComputedStyle(element, null);
9742
- return css[property];
9743
- }
9841
+ */
9842
+ function getStyleComputedProperty(element, property) {
9843
+ // NOTE: 1 DOM access here
9844
+ // 无界等微前端场景下沙箱 window 与元素实际渲染所在 window 可能不一致,
9845
+ // 需使用元素自身的 view 读取计算样式,避免跨 document 读取到空值
9846
+ var css = getRealWindow(element).getComputedStyle(element, null);
9847
+ return css[property];
9848
+ }
9849
+
9744
9850
  /**
9745
9851
  * Returns the offset parent of the given element
9746
9852
  * @function
9747
9853
  * @ignore
9748
9854
  * @argument {Element} element
9749
9855
  * @returns {Element} offset parent
9750
- */
9751
- function getOffsetParent(element) {
9752
- var offsetParent = element.offsetParent;
9753
- return offsetParent === root.document.body || !offsetParent ? root.document.documentElement : offsetParent;
9754
- }
9755
-
9856
+ */
9857
+ function getOffsetParent(element) {
9858
+ var offsetParent = element.offsetParent;
9859
+ return offsetParent === root.document.body || !offsetParent
9860
+ ? root.document.documentElement
9861
+ : offsetParent;
9862
+ }
9863
+
9864
+ /**
9865
+ * Returns the window the given element actually renders in.
9866
+ * 无界等微前端场景下组件代码运行在沙箱 window 中,而 DOM 实际渲染在
9867
+ * 主应用的 window(shadowRoot 内),滚动量、视口尺寸等必须取自元素自身的 view
9868
+ * @function
9869
+ * @ignore
9870
+ * @argument {Element} element
9871
+ * @returns {Window} window
9872
+ */
9873
+ function getRealWindow(element) {
9874
+ return (
9875
+ (element &&
9876
+ element.ownerDocument &&
9877
+ element.ownerDocument.defaultView) ||
9878
+ root
9879
+ );
9880
+ }
9881
+
9882
+ /**
9883
+ * Returns the viewport rect of the containing block actually used to position the popper.
9884
+ * 无界微前端等场景下 popper 被挂载进子应用的 shadowRoot,offsetParent 的兜底值
9885
+ * (documentElement)与浏览器真实的包含块不再重合,导致下拉框/提示框整体偏移
9886
+ * (偏移量恰为子应用容器在主应用中的位置),因此需要沿 composed tree 查找:
9887
+ * - fixed 定位:包含块为视口;
9888
+ * - absolute 定位:最近的 positioned 祖先元素(跨 shadowRoot 边界查找);
9889
+ * - 无 positioned 祖先:初始包含块,其视口原点为真实 window 滚动量的负值。
9890
+ * @function
9891
+ * @ignore
9892
+ * @argument {Element} element - popper element
9893
+ * @argument {Boolean} fixed - whether the popper is fixed positioned
9894
+ * @returns {Object} rect
9895
+ */
9896
+ function getContainingBlockRect(element, fixed) {
9897
+ if (fixed) {
9898
+ return { top: 0, left: 0, right: 0, bottom: 0 };
9899
+ }
9900
+
9901
+ var node = element.parentNode;
9902
+ while (node) {
9903
+ if (node.nodeType === 1) {
9904
+ if (getStyleComputedProperty(node, 'position') !== 'static') {
9905
+ return getBoundingClientRect(node);
9906
+ }
9907
+ } else if (node.nodeType === 11) {
9908
+ // 遇到 shadowRoot,跨边界从宿主元素继续向上查找
9909
+ node = node.host;
9910
+ continue;
9911
+ } else {
9912
+ break;
9913
+ }
9914
+ node = node.parentNode;
9915
+ }
9916
+
9917
+ var win = getRealWindow(element);
9918
+ return {
9919
+ top: -(win.pageYOffset || 0),
9920
+ left: -(win.pageXOffset || 0),
9921
+ right: 0,
9922
+ bottom: 0
9923
+ };
9924
+ }
9925
+
9756
9926
  /**
9757
9927
  * Returns the scrolling parent of the given element
9758
9928
  * @function
9759
9929
  * @ignore
9760
9930
  * @argument {Element} element
9761
9931
  * @returns {Element} offset parent
9762
- */
9763
- function getScrollParent(element) {
9764
- var parent = element.parentNode;
9765
- if (!parent || parent.nodeType !== 1) {
9766
- return element;
9767
- }
9768
-
9769
- if (parent === root.document) {
9770
- // Firefox puts the scrollTOp value on `documentElement` instead of `body`, we then check which of them is
9771
- // greater than 0 and return the proper element
9772
- if (root.document.body.scrollTop || root.document.body.scrollLeft) {
9773
- return root.document.body;
9774
- } else {
9775
- return root.document.documentElement;
9776
- }
9777
- }
9778
-
9779
- // Firefox want us to check `-x` and `-y` variations as well
9780
- if (['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow')) !== -1 || ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-x')) !== -1 || ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-y')) !== -1) {
9781
- // If the detected scrollParent is body, we perform an additional check on its parentNode
9782
- // in this way we'll get body if the browser is Chrome-ish, or documentElement otherwise
9783
- // fixes issue #65
9784
- return parent;
9785
- }
9786
- return getScrollParent(element.parentNode);
9787
- }
9788
-
9932
+ */
9933
+ function getScrollParent(element) {
9934
+ var parent = element.parentNode;
9935
+ if (!parent) {
9936
+ return element;
9937
+ }
9938
+
9939
+ if (parent.nodeType === 11) {
9940
+ // 无界等微前端场景 DOM 位于 shadowRoot 内,需跨边界从宿主元素继续向上查找,
9941
+ // 否则查找到 shadowRoot 即终止,滚动事件无法被监听
9942
+ return getScrollParent(parent.host);
9943
+ }
9944
+
9945
+ if (parent.nodeType !== 1) {
9946
+ // 到达 document,返回元素实际渲染所在的真实 window,
9947
+ // 保证 window 滚动时能触发位置更新
9948
+ return getRealWindow(element);
9949
+ }
9950
+
9951
+ // Firefox want us to check `-x` and `-y` variations as well
9952
+ if (
9953
+ ['scroll', 'auto'].indexOf(
9954
+ getStyleComputedProperty(parent, 'overflow')
9955
+ ) !== -1 ||
9956
+ ['scroll', 'auto'].indexOf(
9957
+ getStyleComputedProperty(parent, 'overflow-x')
9958
+ ) !== -1 ||
9959
+ ['scroll', 'auto'].indexOf(
9960
+ getStyleComputedProperty(parent, 'overflow-y')
9961
+ ) !== -1
9962
+ ) {
9963
+ // If the detected scrollParent is body, we perform an additional check on its parentNode
9964
+ // in this way we'll get body if the browser is Chrome-ish, or documentElement otherwise
9965
+ // fixes issue #65
9966
+ return parent;
9967
+ }
9968
+ return getScrollParent(parent);
9969
+ }
9970
+
9789
9971
  /**
9790
9972
  * Check if the given element is fixed or is inside a fixed parent
9791
9973
  * @function
@@ -9793,109 +9975,125 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
9793
9975
  * @argument {Element} element
9794
9976
  * @argument {Element} customContainer
9795
9977
  * @returns {Boolean} answer to "isFixed?"
9796
- */
9797
- function isFixed(element) {
9798
- if (element === root.document.body) {
9799
- return false;
9800
- }
9801
- if (getStyleComputedProperty(element, 'position') === 'fixed') {
9802
- return true;
9803
- }
9804
- return element.parentNode && element.parentNode.nodeType === 1 ? isFixed(element.parentNode) : element;
9805
- }
9806
-
9978
+ */
9979
+ function isFixed(element) {
9980
+ if (element === root.document.body) {
9981
+ return false;
9982
+ }
9983
+ if (getStyleComputedProperty(element, 'position') === 'fixed') {
9984
+ return true;
9985
+ }
9986
+ var parent = element.parentNode;
9987
+ if (parent && parent.nodeType === 11) {
9988
+ // 跨 shadowRoot 边界,从宿主元素继续向上判断
9989
+ parent = parent.host;
9990
+ }
9991
+ return parent && parent.nodeType === 1 ? isFixed(parent) : false;
9992
+ }
9993
+
9807
9994
  /**
9808
9995
  * Set the style to the given popper
9809
9996
  * @function
9810
9997
  * @ignore
9811
9998
  * @argument {Element} element - Element to apply the style to
9812
9999
  * @argument {Object} styles - Object with a list of properties and values which will be applied to the element
9813
- */
9814
- function setStyle(element, styles) {
9815
- function is_numeric(n) {
9816
- return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
9817
- }
9818
- Object.keys(styles).forEach(function (prop) {
9819
- var unit = '';
9820
- // add unit if the value is numeric and is one of the following
9821
- if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && is_numeric(styles[prop])) {
9822
- unit = 'px';
9823
- }
9824
- element.style[prop] = styles[prop] + unit;
9825
- });
9826
- }
9827
-
10000
+ */
10001
+ function setStyle(element, styles) {
10002
+ function is_numeric(n) {
10003
+ return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
10004
+ }
10005
+ Object.keys(styles).forEach(function (prop) {
10006
+ var unit = '';
10007
+ // add unit if the value is numeric and is one of the following
10008
+ if (
10009
+ ['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !==
10010
+ -1 &&
10011
+ is_numeric(styles[prop])
10012
+ ) {
10013
+ unit = 'px';
10014
+ }
10015
+ element.style[prop] = styles[prop] + unit;
10016
+ });
10017
+ }
10018
+
9828
10019
  /**
9829
10020
  * Check if the given variable is a function
9830
10021
  * @function
9831
10022
  * @ignore
9832
10023
  * @argument {*} functionToCheck - variable to check
9833
10024
  * @returns {Boolean} answer to: is a function?
9834
- */
9835
- function isFunction(functionToCheck) {
9836
- var getType = {};
9837
- return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
9838
- }
9839
-
10025
+ */
10026
+ function isFunction(functionToCheck) {
10027
+ var getType = {};
10028
+ return (
10029
+ functionToCheck &&
10030
+ getType.toString.call(functionToCheck) === '[object Function]'
10031
+ );
10032
+ }
10033
+
9840
10034
  /**
9841
10035
  * Get the position of the given element, relative to its offset parent
9842
10036
  * @function
9843
10037
  * @ignore
9844
10038
  * @param {Element} element
9845
10039
  * @return {Object} position - Coordinates of the element and its `scrollTop`
9846
- */
9847
- function getOffsetRect(element) {
9848
- var transform = getStyle(element, 'transform').replace(/[^0-9\-,]/g, '').split(',');
9849
- var elementRect = {
9850
- width: element.offsetWidth,
9851
- height: element.offsetHeight,
9852
- left: element.offsetLeft + (transform[4] ? parseInt(transform[4], 10) : 0),
9853
- top: element.offsetTop + (transform[5] ? parseInt(transform[5], 10) : 0)
9854
- };
9855
-
9856
- elementRect.right = elementRect.left + elementRect.width;
9857
- elementRect.bottom = elementRect.top + elementRect.height;
9858
-
9859
- // position
9860
- return elementRect;
9861
- }
9862
-
10040
+ */
10041
+ function getOffsetRect(element) {
10042
+ var transform = getStyle(element, 'transform')
10043
+ .replace(/[^0-9\-,]/g, '')
10044
+ .split(',');
10045
+ var elementRect = {
10046
+ width: element.offsetWidth,
10047
+ height: element.offsetHeight,
10048
+ left:
10049
+ element.offsetLeft + (transform[4] ? parseInt(transform[4], 10) : 0),
10050
+ top: element.offsetTop + (transform[5] ? parseInt(transform[5], 10) : 0)
10051
+ };
10052
+
10053
+ elementRect.right = elementRect.left + elementRect.width;
10054
+ elementRect.bottom = elementRect.top + elementRect.height;
10055
+
10056
+ // position
10057
+ return elementRect;
10058
+ }
10059
+
9863
10060
  /**
9864
10061
  * Get bounding client rect of given element
9865
10062
  * @function
9866
10063
  * @ignore
9867
10064
  * @param {HTMLElement} element
9868
10065
  * @return {Object} client rect
9869
- */
9870
- function getBoundingClientRect(element) {
9871
- var rect = element.getBoundingClientRect();
9872
-
9873
- // whether the IE version is lower than 11
9874
- var isIE = /MSIE|Trident/.test(navigator.userAgent);
9875
-
9876
- // fix ie document bounding top always 0 bug
9877
- var rectTop = isIE && element.tagName === 'HTML' ? -element.scrollTop : rect.top;
9878
-
9879
- return {
9880
- left: rect.left,
9881
- top: rectTop,
9882
- right: rect.right,
9883
- bottom: rect.bottom,
9884
- width: rect.right - rect.left,
9885
- height: rect.bottom - rectTop
9886
- };
9887
- }
9888
-
9889
- function getStyle(dom, attr) {
9890
- if (dom.style[attr]) {
9891
- return dom.style[attr];
9892
- }
9893
- if (window.getComputedStyle) {
9894
- return getComputedStyle(dom, null)[attr];
9895
- }
9896
- return dom.currentStyle[attr];
9897
- }
9898
-
10066
+ */
10067
+ function getBoundingClientRect(element) {
10068
+ var rect = element.getBoundingClientRect();
10069
+
10070
+ // whether the IE version is lower than 11
10071
+ var isIE = /MSIE|Trident/.test(navigator.userAgent);
10072
+
10073
+ // fix ie document bounding top always 0 bug
10074
+ var rectTop =
10075
+ isIE && element.tagName === 'HTML' ? -element.scrollTop : rect.top;
10076
+
10077
+ return {
10078
+ left: rect.left,
10079
+ top: rectTop,
10080
+ right: rect.right,
10081
+ bottom: rect.bottom,
10082
+ width: rect.right - rect.left,
10083
+ height: rect.bottom - rectTop
10084
+ };
10085
+ }
10086
+
10087
+ function getStyle(dom, attr) {
10088
+ if (dom.style[attr]) {
10089
+ return dom.style[attr];
10090
+ }
10091
+ if (window.getComputedStyle) {
10092
+ return getComputedStyle(dom, null)[attr];
10093
+ }
10094
+ return dom.currentStyle[attr];
10095
+ }
10096
+
9899
10097
  /**
9900
10098
  * Given an element and one of its parents, return the offset
9901
10099
  * @function
@@ -9903,49 +10101,45 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
9903
10101
  * @param {HTMLElement} element
9904
10102
  * @param {HTMLElement} parent
9905
10103
  * @return {Object} rect
9906
- */
9907
- function getOffsetRectRelativeToCustomParent(element, parent, fixed) {
9908
- var elementRect = getBoundingClientRect(element);
9909
- var parentRect = getBoundingClientRect(parent);
9910
-
9911
- if (fixed) {
9912
- var scrollParent = getScrollParent(parent);
9913
- parentRect.top += scrollParent.scrollTop;
9914
- parentRect.bottom += scrollParent.scrollTop;
9915
- parentRect.left += scrollParent.scrollLeft;
9916
- parentRect.right += scrollParent.scrollLeft;
9917
- }
9918
-
9919
- var rect = {
9920
- top: elementRect.top - parentRect.top,
9921
- left: elementRect.left - parentRect.left,
9922
- bottom: elementRect.top - parentRect.top + elementRect.height,
9923
- right: elementRect.left - parentRect.left + elementRect.width,
9924
- width: elementRect.width,
9925
- height: elementRect.height
9926
- };
9927
- return rect;
9928
- }
9929
-
10104
+ */
10105
+ function getOffsetRectRelativeToCustomParent(element, parent, fixed) {
10106
+ var elementRect = getBoundingClientRect(element);
10107
+ // parent 为 popper 元素:取其真实包含块的视口 rect,
10108
+ // 避免无界 shadowRoot 等场景下包含块假设错误导致的整体偏移
10109
+ var parentRect = getContainingBlockRect(parent, fixed);
10110
+
10111
+ var rect = {
10112
+ top: elementRect.top - parentRect.top,
10113
+ left: elementRect.left - parentRect.left,
10114
+ bottom: elementRect.top - parentRect.top + elementRect.height,
10115
+ right: elementRect.left - parentRect.left + elementRect.width,
10116
+ width: elementRect.width,
10117
+ height: elementRect.height
10118
+ };
10119
+ return rect;
10120
+ }
10121
+
9930
10122
  /**
9931
10123
  * Get the prefixed supported property name
9932
10124
  * @function
9933
10125
  * @ignore
9934
10126
  * @argument {String} property (camelCase)
9935
10127
  * @returns {String} prefixed property (camelCase)
9936
- */
9937
- function getSupportedPropertyName(property) {
9938
- var prefixes = ['', 'ms', 'webkit', 'moz', 'o'];
9939
-
9940
- for (var i = 0; i < prefixes.length; i++) {
9941
- var toCheck = prefixes[i] ? prefixes[i] + property.charAt(0).toUpperCase() + property.slice(1) : property;
9942
- if (typeof root.document.body.style[toCheck] !== 'undefined') {
9943
- return toCheck;
9944
- }
9945
- }
9946
- return null;
9947
- }
9948
-
10128
+ */
10129
+ function getSupportedPropertyName(property) {
10130
+ var prefixes = ['', 'ms', 'webkit', 'moz', 'o'];
10131
+
10132
+ for (var i = 0; i < prefixes.length; i++) {
10133
+ var toCheck = prefixes[i]
10134
+ ? prefixes[i] + property.charAt(0).toUpperCase() + property.slice(1)
10135
+ : property;
10136
+ if (typeof root.document.body.style[toCheck] !== 'undefined') {
10137
+ return toCheck;
10138
+ }
10139
+ }
10140
+ return null;
10141
+ }
10142
+
9949
10143
  /**
9950
10144
  * The Object.assign() method is used to copy the values of all enumerable own properties from one or more source
9951
10145
  * objects to a target object. It will return the target object.
@@ -9953,41 +10147,46 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
9953
10147
  * Source: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
9954
10148
  * @function
9955
10149
  * @ignore
9956
- */
9957
- if (!Object.assign) {
9958
- Object.defineProperty(Object, 'assign', {
9959
- enumerable: false,
9960
- configurable: true,
9961
- writable: true,
9962
- value: function value(target) {
9963
- if (target === undefined || target === null) {
9964
- throw new TypeError('Cannot convert first argument to object');
9965
- }
9966
-
9967
- var to = Object(target);
9968
- for (var i = 1; i < arguments.length; i++) {
9969
- var nextSource = arguments[i];
9970
- if (nextSource === undefined || nextSource === null) {
9971
- continue;
9972
- }
9973
- nextSource = Object(nextSource);
9974
-
9975
- var keysArray = Object.keys(nextSource);
9976
- for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
9977
- var nextKey = keysArray[nextIndex];
9978
- var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
9979
- if (desc !== undefined && desc.enumerable) {
9980
- to[nextKey] = nextSource[nextKey];
9981
- }
9982
- }
9983
- }
9984
- return to;
9985
- }
9986
- });
9987
- }
10150
+ */
10151
+ if (!Object.assign) {
10152
+ Object.defineProperty(Object, 'assign', {
10153
+ enumerable: false,
10154
+ configurable: true,
10155
+ writable: true,
10156
+ value: function (target) {
10157
+ if (target === undefined || target === null) {
10158
+ throw new TypeError('Cannot convert first argument to object');
10159
+ }
10160
+
10161
+ var to = Object(target);
10162
+ for (var i = 1; i < arguments.length; i++) {
10163
+ var nextSource = arguments[i];
10164
+ if (nextSource === undefined || nextSource === null) {
10165
+ continue;
10166
+ }
10167
+ nextSource = Object(nextSource);
10168
+
10169
+ var keysArray = Object.keys(nextSource);
10170
+ for (
10171
+ var nextIndex = 0, len = keysArray.length;
10172
+ nextIndex < len;
10173
+ nextIndex++
10174
+ ) {
10175
+ var nextKey = keysArray[nextIndex];
10176
+ var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
10177
+ if (desc !== undefined && desc.enumerable) {
10178
+ to[nextKey] = nextSource[nextKey];
10179
+ }
10180
+ }
10181
+ }
10182
+ return to;
10183
+ }
10184
+ });
10185
+ }
10186
+
10187
+ return Popper;
10188
+ });
9988
10189
 
9989
- return Popper;
9990
- });
9991
10190
 
9992
10191
  /***/ }),
9993
10192
 
@@ -10621,736 +10820,759 @@ module.exports = require("eoss/lib/tag");
10621
10820
  /* unused harmony export getSecond */
10622
10821
  /* unused harmony export getWeekday */
10623
10822
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
10624
-
10625
-
10823
+ /* Modified from https://github.com/taylorhakes/fecha
10824
+ *
10825
+ * The MIT License (MIT)
10826
+ *
10827
+ * Copyright (c) 2015 Taylor Hakes
10828
+ *
10829
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10830
+ * of this software and associated documentation files (the "Software"), to deal
10831
+ * in the Software without restriction, including without limitation the rights
10832
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10833
+ * copies of the Software, and to permit persons to whom the Software is
10834
+ * furnished to do so, subject to the following conditions:
10835
+ *
10836
+ * The above copyright notice and this permission notice shall be included in all
10837
+ * copies or substantial portions of the Software.
10838
+ *
10839
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10840
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
10841
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
10842
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10843
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
10844
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
10845
+ * SOFTWARE.
10846
+ */
10847
+
10848
+ /*eslint-disable*/
10849
+ // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
10850
+
10851
+
10626
10852
  /**
10627
10853
  * Parse or format dates
10628
10854
  * @class fecha
10629
- */
10630
- var fecha = {};
10631
- var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
10632
- var twoDigits = '\\d\\d?';
10633
- var threeDigits = '\\d{3}';
10634
- var fourDigits = '\\d{4}';
10635
- var word = '[^\\s]+';
10636
- var literal = /\[([^]*?)\]/gm;
10637
- var noop = function noop() {};
10638
-
10639
- function regexEscape(str) {
10640
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
10641
- }
10642
-
10643
- function shorten(arr, sLen) {
10644
- var newArr = [];
10645
- for (var i = 0, len = arr.length; i < len; i++) {
10646
- newArr.push(arr[i].substr(0, sLen));
10647
- }
10648
- return newArr;
10649
- }
10650
-
10651
- function monthUpdate() {
10652
- return function (d, v) {
10653
- var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
10654
- if (~index) {
10655
- d.month = index;
10656
- }
10657
- };
10658
- }
10659
-
10660
- function pad(val, len) {
10661
- val = String(val);
10662
- len = len || 2;
10663
- while (val.length < len) {
10664
- val = '0' + val;
10665
- }
10666
- return val;
10667
- }
10668
-
10669
- // 直接使用中文日期名称常量
10670
- var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
10671
- var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
10672
- var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
10673
- var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
10674
- var amPm = ['上午', '下午'];
10675
- var DoFn = function DoFn(D) {
10676
- return D + '日';
10677
- };
10678
-
10679
- var formatFlags = {
10680
- D: function D(dateObj) {
10681
- return dateObj.getDay();
10682
- },
10683
- DD: function DD(dateObj) {
10684
- return pad(dateObj.getDay());
10685
- },
10686
- Do: function Do(dateObj) {
10687
- return DoFn(dateObj.getDate());
10688
- },
10689
- d: function d(dateObj) {
10690
- return dateObj.getDate();
10691
- },
10692
- dd: function dd(dateObj) {
10693
- return pad(dateObj.getDate());
10694
- },
10695
- ddd: function ddd(dateObj) {
10696
- return dayNamesShort[dateObj.getDay()];
10697
- },
10698
- dddd: function dddd(dateObj) {
10699
- return dayNames[dateObj.getDay()];
10700
- },
10701
- M: function M(dateObj) {
10702
- return dateObj.getMonth() + 1;
10703
- },
10704
- MM: function MM(dateObj) {
10705
- return pad(dateObj.getMonth() + 1);
10706
- },
10707
- MMM: function MMM(dateObj) {
10708
- return monthNamesShort[dateObj.getMonth()];
10709
- },
10710
- MMMM: function MMMM(dateObj) {
10711
- return monthNames[dateObj.getMonth()];
10712
- },
10713
- yy: function yy(dateObj) {
10714
- return pad(String(dateObj.getFullYear()), 4).substr(2);
10715
- },
10716
- yyyy: function yyyy(dateObj) {
10717
- return pad(dateObj.getFullYear(), 4);
10718
- },
10719
- h: function h(dateObj) {
10720
- return dateObj.getHours() % 12 || 12;
10721
- },
10722
- hh: function hh(dateObj) {
10723
- return pad(dateObj.getHours() % 12 || 12);
10724
- },
10725
- H: function H(dateObj) {
10726
- return dateObj.getHours();
10727
- },
10728
- HH: function HH(dateObj) {
10729
- return pad(dateObj.getHours());
10730
- },
10731
- m: function m(dateObj) {
10732
- return dateObj.getMinutes();
10733
- },
10734
- mm: function mm(dateObj) {
10735
- return pad(dateObj.getMinutes());
10736
- },
10737
- s: function s(dateObj) {
10738
- return dateObj.getSeconds();
10739
- },
10740
- ss: function ss(dateObj) {
10741
- return pad(dateObj.getSeconds());
10742
- },
10743
- S: function S(dateObj) {
10744
- return Math.round(dateObj.getMilliseconds() / 100);
10745
- },
10746
- SS: function SS(dateObj) {
10747
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
10748
- },
10749
- SSS: function SSS(dateObj) {
10750
- return pad(dateObj.getMilliseconds(), 3);
10751
- },
10752
- a: function a(dateObj) {
10753
- return dateObj.getHours() < 12 ? '上午' : '下午';
10754
- },
10755
- A: function A(dateObj) {
10756
- return dateObj.getHours() < 12 ? '上午' : '下午';
10757
- },
10758
- ZZ: function ZZ(dateObj) {
10759
- var o = dateObj.getTimezoneOffset();
10760
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
10761
- }
10762
- };
10763
-
10764
- var parseFlags = {
10765
- d: [twoDigits, function (d, v) {
10766
- d.day = v;
10767
- }],
10768
- Do: [twoDigits + word, function (d, v) {
10769
- d.day = parseInt(v, 10);
10770
- }],
10771
- M: [twoDigits, function (d, v) {
10772
- d.month = v - 1;
10773
- }],
10774
- yy: [twoDigits, function (d, v) {
10775
- var da = new Date(),
10776
- cent = +('' + da.getFullYear()).substr(0, 2);
10777
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
10778
- }],
10779
- h: [twoDigits, function (d, v) {
10780
- d.hour = v;
10781
- }],
10782
- m: [twoDigits, function (d, v) {
10783
- d.minute = v;
10784
- }],
10785
- s: [twoDigits, function (d, v) {
10786
- d.second = v;
10787
- }],
10788
- yyyy: [fourDigits, function (d, v) {
10789
- d.year = v;
10790
- }],
10791
- S: ['\\d', function (d, v) {
10792
- d.millisecond = v * 100;
10793
- }],
10794
- SS: ['\\d{2}', function (d, v) {
10795
- d.millisecond = v * 10;
10796
- }],
10797
- SSS: [threeDigits, function (d, v) {
10798
- d.millisecond = v;
10799
- }],
10800
- D: [twoDigits, noop],
10801
- ddd: [word, noop],
10802
- MMM: [word, monthUpdate('monthNamesShort')],
10803
- MMMM: [word, monthUpdate('monthNames')],
10804
- a: [word, function (d, v) {
10805
- var val = v.toLowerCase();
10806
- if (val === '上午') {
10807
- d.isPm = false;
10808
- } else if (val === '下午') {
10809
- d.isPm = true;
10810
- }
10811
- }],
10812
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
10813
- var parts = (v + '').match(/([+-]|\d\d)/gi),
10814
- minutes = void 0;
10815
-
10816
- if (parts) {
10817
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
10818
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
10819
- }
10820
- }]
10821
- };
10822
- parseFlags.dd = parseFlags.d;
10823
- parseFlags.dddd = parseFlags.ddd;
10824
- parseFlags.DD = parseFlags.D;
10825
- parseFlags.mm = parseFlags.m;
10826
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
10827
- parseFlags.MM = parseFlags.M;
10828
- parseFlags.ss = parseFlags.s;
10829
- parseFlags.A = parseFlags.a;
10830
-
10831
- // Some common format strings
10832
- fecha.masks = {
10833
- default: 'ddd MMM dd yyyy HH:mm:ss',
10834
- shortDate: 'M/D/yy',
10835
- mediumDate: 'MMM d, yyyy',
10836
- longDate: 'MMMM d, yyyy',
10837
- fullDate: 'dddd, MMMM d, yyyy',
10838
- shortTime: 'HH:mm',
10839
- mediumTime: 'HH:mm:ss',
10840
- longTime: 'HH:mm:ss.SSS'
10841
- };
10842
-
10855
+ */
10856
+ const fecha = {};
10857
+ const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
10858
+ const twoDigits = '\\d\\d?';
10859
+ const threeDigits = '\\d{3}';
10860
+ const fourDigits = '\\d{4}';
10861
+ const word = '[^\\s]+';
10862
+ const literal = /\[([^]*?)\]/gm;
10863
+ const noop = function () {};
10864
+
10865
+ function regexEscape(str) {
10866
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
10867
+ }
10868
+
10869
+ function shorten(arr, sLen) {
10870
+ const newArr = [];
10871
+ for (let i = 0, len = arr.length; i < len; i++) {
10872
+ newArr.push(arr[i].substr(0, sLen));
10873
+ }
10874
+ return newArr;
10875
+ }
10876
+
10877
+ function monthUpdate() {
10878
+ return function (d, v) {
10879
+ const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
10880
+ if (~index) {
10881
+ d.month = index;
10882
+ }
10883
+ };
10884
+ }
10885
+
10886
+ function pad(val, len) {
10887
+ val = String(val);
10888
+ len = len || 2;
10889
+ while (val.length < len) {
10890
+ val = '0' + val;
10891
+ }
10892
+ return val;
10893
+ }
10894
+
10895
+ // 直接使用中文日期名称常量
10896
+ const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
10897
+ const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
10898
+ const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
10899
+ const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
10900
+ const amPm = ['上午', '下午'];
10901
+ const DoFn = function DoFn(D) {
10902
+ return D + '日';
10903
+ };
10904
+
10905
+ const formatFlags = {
10906
+ D: function(dateObj) {
10907
+ return dateObj.getDay();
10908
+ },
10909
+ DD: function(dateObj) {
10910
+ return pad(dateObj.getDay());
10911
+ },
10912
+ Do: function(dateObj) {
10913
+ return DoFn(dateObj.getDate());
10914
+ },
10915
+ d: function(dateObj) {
10916
+ return dateObj.getDate();
10917
+ },
10918
+ dd: function(dateObj) {
10919
+ return pad(dateObj.getDate());
10920
+ },
10921
+ ddd: function(dateObj) {
10922
+ return dayNamesShort[dateObj.getDay()];
10923
+ },
10924
+ dddd: function(dateObj) {
10925
+ return dayNames[dateObj.getDay()];
10926
+ },
10927
+ M: function(dateObj) {
10928
+ return dateObj.getMonth() + 1;
10929
+ },
10930
+ MM: function(dateObj) {
10931
+ return pad(dateObj.getMonth() + 1);
10932
+ },
10933
+ MMM: function(dateObj) {
10934
+ return monthNamesShort[dateObj.getMonth()];
10935
+ },
10936
+ MMMM: function(dateObj) {
10937
+ return monthNames[dateObj.getMonth()];
10938
+ },
10939
+ yy: function(dateObj) {
10940
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
10941
+ },
10942
+ yyyy: function(dateObj) {
10943
+ return pad(dateObj.getFullYear(), 4);
10944
+ },
10945
+ h: function(dateObj) {
10946
+ return dateObj.getHours() % 12 || 12;
10947
+ },
10948
+ hh: function(dateObj) {
10949
+ return pad(dateObj.getHours() % 12 || 12);
10950
+ },
10951
+ H: function(dateObj) {
10952
+ return dateObj.getHours();
10953
+ },
10954
+ HH: function(dateObj) {
10955
+ return pad(dateObj.getHours());
10956
+ },
10957
+ m: function(dateObj) {
10958
+ return dateObj.getMinutes();
10959
+ },
10960
+ mm: function(dateObj) {
10961
+ return pad(dateObj.getMinutes());
10962
+ },
10963
+ s: function(dateObj) {
10964
+ return dateObj.getSeconds();
10965
+ },
10966
+ ss: function(dateObj) {
10967
+ return pad(dateObj.getSeconds());
10968
+ },
10969
+ S: function(dateObj) {
10970
+ return Math.round(dateObj.getMilliseconds() / 100);
10971
+ },
10972
+ SS: function(dateObj) {
10973
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
10974
+ },
10975
+ SSS: function(dateObj) {
10976
+ return pad(dateObj.getMilliseconds(), 3);
10977
+ },
10978
+ a: function(dateObj) {
10979
+ return dateObj.getHours() < 12 ? '上午' : '下午';
10980
+ },
10981
+ A: function(dateObj) {
10982
+ return dateObj.getHours() < 12 ? '上午' : '下午';
10983
+ },
10984
+ ZZ: function(dateObj) {
10985
+ const o = dateObj.getTimezoneOffset();
10986
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
10987
+ }
10988
+ };
10989
+
10990
+ const parseFlags = {
10991
+ d: [twoDigits, function (d, v) {
10992
+ d.day = v;
10993
+ }],
10994
+ Do: [twoDigits + word, function (d, v) {
10995
+ d.day = parseInt(v, 10);
10996
+ }],
10997
+ M: [twoDigits, function (d, v) {
10998
+ d.month = v - 1;
10999
+ }],
11000
+ yy: [twoDigits, function (d, v) {
11001
+ const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
11002
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
11003
+ }],
11004
+ h: [twoDigits, function (d, v) {
11005
+ d.hour = v;
11006
+ }],
11007
+ m: [twoDigits, function (d, v) {
11008
+ d.minute = v;
11009
+ }],
11010
+ s: [twoDigits, function (d, v) {
11011
+ d.second = v;
11012
+ }],
11013
+ yyyy: [fourDigits, function (d, v) {
11014
+ d.year = v;
11015
+ }],
11016
+ S: ['\\d', function (d, v) {
11017
+ d.millisecond = v * 100;
11018
+ }],
11019
+ SS: ['\\d{2}', function (d, v) {
11020
+ d.millisecond = v * 10;
11021
+ }],
11022
+ SSS: [threeDigits, function (d, v) {
11023
+ d.millisecond = v;
11024
+ }],
11025
+ D: [twoDigits, noop],
11026
+ ddd: [word, noop],
11027
+ MMM: [word, monthUpdate('monthNamesShort')],
11028
+ MMMM: [word, monthUpdate('monthNames')],
11029
+ a: [word, function (d, v) {
11030
+ const val = v.toLowerCase();
11031
+ if (val === '上午') {
11032
+ d.isPm = false;
11033
+ } else if (val === '下午') {
11034
+ d.isPm = true;
11035
+ }
11036
+ }],
11037
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
11038
+ let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
11039
+
11040
+ if (parts) {
11041
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
11042
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
11043
+ }
11044
+ }]
11045
+ };
11046
+ parseFlags.dd = parseFlags.d;
11047
+ parseFlags.dddd = parseFlags.ddd;
11048
+ parseFlags.DD = parseFlags.D;
11049
+ parseFlags.mm = parseFlags.m;
11050
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
11051
+ parseFlags.MM = parseFlags.M;
11052
+ parseFlags.ss = parseFlags.s;
11053
+ parseFlags.A = parseFlags.a;
11054
+
11055
+
11056
+ // Some common format strings
11057
+ fecha.masks = {
11058
+ default: 'ddd MMM dd yyyy HH:mm:ss',
11059
+ shortDate: 'M/D/yy',
11060
+ mediumDate: 'MMM d, yyyy',
11061
+ longDate: 'MMMM d, yyyy',
11062
+ fullDate: 'dddd, MMMM d, yyyy',
11063
+ shortTime: 'HH:mm',
11064
+ mediumTime: 'HH:mm:ss',
11065
+ longTime: 'HH:mm:ss.SSS'
11066
+ };
11067
+
10843
11068
  /***
10844
11069
  * Format a date
10845
11070
  * @method format
10846
11071
  * @param {Date|number} dateObj
10847
11072
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
10848
- */
10849
- fecha.format = function (dateObj, mask) {
10850
- if (typeof dateObj === 'number') {
10851
- dateObj = new Date(dateObj);
10852
- }
10853
-
10854
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
10855
- throw new Error('Invalid Date in fecha.format');
10856
- }
10857
-
10858
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
10859
-
10860
- var literals = [];
10861
-
10862
- // Make literals inactive by replacing them with ??
10863
- mask = mask.replace(literal, function ($0, $1) {
10864
- literals.push($1);
10865
- return '@@@';
10866
- });
10867
- // Apply formatting rules
10868
- mask = mask.replace(token, function ($0) {
10869
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
10870
- });
10871
- // Inline literal values back into the formatted value
10872
- return mask.replace(/@@@/g, function () {
10873
- return literals.shift();
10874
- });
10875
- };
10876
-
11073
+ */
11074
+ fecha.format = function (dateObj, mask) {
11075
+ if (typeof dateObj === 'number') {
11076
+ dateObj = new Date(dateObj);
11077
+ }
11078
+
11079
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
11080
+ throw new Error('Invalid Date in fecha.format');
11081
+ }
11082
+
11083
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
11084
+
11085
+ const literals = [];
11086
+
11087
+ // Make literals inactive by replacing them with ??
11088
+ mask = mask.replace(literal, function($0, $1) {
11089
+ literals.push($1);
11090
+ return '@@@';
11091
+ });
11092
+ // Apply formatting rules
11093
+ mask = mask.replace(token, function ($0) {
11094
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
11095
+ });
11096
+ // Inline literal values back into the formatted value
11097
+ return mask.replace(/@@@/g, function() {
11098
+ return literals.shift();
11099
+ });
11100
+ };
11101
+
10877
11102
  /**
10878
11103
  * Parse a date string into an object, changes - into /
10879
11104
  * @method parse
10880
11105
  * @param {string} dateStr Date string
10881
11106
  * @param {string} format Date parse format
10882
11107
  * @returns {Date|boolean}
10883
- */
10884
- fecha.parse = function (dateStr, format) {
10885
- if (typeof format !== 'string') {
10886
- throw new Error('Invalid format in fecha.parse');
10887
- }
10888
-
10889
- format = fecha.masks[format] || format;
10890
-
10891
- // Avoid regular expression denial of service, fail early for really long strings
10892
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
10893
- if (dateStr.length > 1000) {
10894
- return null;
10895
- }
10896
-
10897
- var dateInfo = {};
10898
- var parseInfo = [];
10899
- var literals = [];
10900
- format = format.replace(literal, function ($0, $1) {
10901
- literals.push($1);
10902
- return '@@@';
10903
- });
10904
- var newFormat = regexEscape(format).replace(token, function ($0) {
10905
- if (parseFlags[$0]) {
10906
- var info = parseFlags[$0];
10907
- parseInfo.push(info[1]);
10908
- return '(' + info[0] + ')';
10909
- }
10910
-
10911
- return $0;
10912
- });
10913
- newFormat = newFormat.replace(/@@@/g, function () {
10914
- return literals.shift();
10915
- });
10916
- var matches = dateStr.match(new RegExp(newFormat, 'i'));
10917
- if (!matches) {
10918
- return null;
10919
- }
10920
-
10921
- for (var i = 1; i < matches.length; i++) {
10922
- parseInfo[i - 1](dateInfo, matches[i]);
10923
- }
10924
-
10925
- var today = new Date();
10926
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
10927
- dateInfo.hour = +dateInfo.hour + 12;
10928
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
10929
- dateInfo.hour = 0;
10930
- }
10931
-
10932
- var date = void 0;
10933
- if (dateInfo.timezoneOffset != null) {
10934
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
10935
- 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));
10936
- } else {
10937
- 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);
10938
- }
10939
- return date;
10940
- };
10941
-
10942
- // 导出fecha对象
10943
-
10944
-
10945
- // 以下是从date-util.js合并的函数
10946
- var newArray = function newArray(start, end) {
10947
- var result = [];
10948
- for (var i = start; i <= end; i++) {
10949
- result.push(i);
10950
- }
10951
- return result;
10952
- };
10953
-
10954
- var getSettings = function getSettings() {
10955
- return {
10956
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
10957
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
10958
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
10959
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
10960
- amPm: ['上午', '下午']
10961
- };
10962
- };
10963
-
10964
- var toDate = function toDate(date) {
10965
- return isDate(date) ? new Date(date) : null;
10966
- };
10967
-
10968
- var isDate = function isDate(date) {
10969
- if (date === null || date === undefined) return false;
10970
- if (isNaN(new Date(date).getTime())) return false;
10971
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
10972
- return true;
10973
- };
10974
-
10975
- var isDateObject = function isDateObject(val) {
10976
- return val instanceof Date;
10977
- };
10978
-
10979
- var formatDate = function formatDate(date) {
10980
- var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
10981
-
10982
- // 处理多种输入类型
10983
- if (!date) return '';
10984
-
10985
- // 如果是时间戳,转成日期对象
10986
- if (typeof date === 'number') {
10987
- date = new Date(date);
10988
- }
10989
- // 如果是字符串,转成日期对象
10990
- if (typeof date === 'string') {
10991
- date = new Date(date);
10992
- }
10993
-
10994
- // 调用toDate进一步验证和转换
10995
- date = toDate(date);
10996
- if (!date) return '';
10997
-
10998
- // 兼容大写和小写的格式标记
10999
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
11000
- var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
11001
-
11002
- // 使用fecha库进行格式化,支持中文配置
11003
- var str = fecha.format(date, lowercaseFormat, getSettings());
11004
- return str;
11005
- };
11006
-
11007
- var parseDate = function parseDate(string, format) {
11008
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
11009
- };
11010
-
11011
- var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
11012
- if (month === 3 || month === 5 || month === 8 || month === 10) {
11013
- return 30;
11014
- }
11015
-
11016
- if (month === 1) {
11017
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
11018
- return 29;
11019
- } else {
11020
- return 28;
11021
- }
11022
- }
11023
-
11024
- return 31;
11025
- };
11026
-
11027
- var getDayCountOfYear = function getDayCountOfYear(year) {
11028
- var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
11029
- return isLeapYear ? 366 : 365;
11030
- };
11031
-
11032
- var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
11033
- var temp = new Date(date.getTime());
11034
- temp.setDate(1);
11035
- return temp.getDay();
11036
- };
11037
-
11038
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
11039
- // {prev, next} Date should work for Daylight Saving Time
11040
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
11041
- var prevDate = function prevDate(date) {
11042
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
11043
-
11044
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
11045
- };
11046
-
11047
- var nextDate = function nextDate(date) {
11048
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
11049
-
11050
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
11051
- };
11052
-
11053
- var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
11054
- var result = new Date(year, month, 1);
11055
- var day = result.getDay();
11056
-
11057
- if (day === 0) {
11058
- return prevDate(result, 7);
11059
- } else {
11060
- return prevDate(result, day);
11061
- }
11062
- };
11063
-
11064
- var getWeekNumber = function getWeekNumber(date) {
11065
- // 支持多种输入类型
11066
- if (!date || !isDate(date)) {
11067
- date = new Date();
11068
- }
11069
- if (typeof date === 'string') {
11070
- date = new Date(date);
11071
- }
11072
-
11073
- // 验证日期有效性
11074
- if (!isDate(date)) return null;
11075
-
11076
- var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
11077
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
11078
- // 将星期日的星期数设为7
11079
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
11080
- // 获取当年的第一天
11081
- var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
11082
- // 计算到最近的星期四的完整周数
11083
- var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
11084
- // 返回周数
11085
- return weekNo;
11086
- };
11087
-
11088
- var getRangeHours = function getRangeHours(ranges) {
11089
- var hours = [];
11090
- var disabledHours = [];
11091
-
11092
- (ranges || []).forEach(function (range) {
11093
- var value = range.map(function (date) {
11094
- return date.getHours();
11095
- });
11096
-
11097
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
11098
- });
11099
-
11100
- if (disabledHours.length) {
11101
- for (var i = 0; i < 24; i++) {
11102
- hours[i] = disabledHours.indexOf(i) === -1;
11103
- }
11104
- } else {
11105
- for (var _i = 0; _i < 24; _i++) {
11106
- hours[_i] = false;
11107
- }
11108
- }
11109
-
11110
- return hours;
11111
- };
11112
-
11113
- var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
11114
- if (amount <= 0) return [];
11115
- var temp = new Date(date.getTime());
11116
- temp.setDate(0);
11117
- var lastDay = temp.getDate();
11118
- return range(amount).map(function (_, index) {
11119
- return lastDay - (amount - index - 1);
11120
- });
11121
- };
11122
-
11123
- var getMonthDays = function getMonthDays(date) {
11124
- var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
11125
- var days = temp.getDate();
11126
- return range(days).map(function (_, index) {
11127
- return index + 1;
11128
- });
11129
- };
11130
-
11131
- function setRangeData(arr, start, end, value) {
11132
- for (var i = start; i < end; i++) {
11133
- arr[i] = value;
11134
- }
11135
- }
11136
-
11137
- var getRangeMinutes = function getRangeMinutes(ranges, hour) {
11138
- var minutes = new Array(60);
11139
-
11140
- if (ranges.length > 0) {
11141
- ranges.forEach(function (range) {
11142
- var start = range[0];
11143
- var end = range[1];
11144
- var startHour = start.getHours();
11145
- var startMinute = start.getMinutes();
11146
- var endHour = end.getHours();
11147
- var endMinute = end.getMinutes();
11148
- if (startHour === hour && endHour !== hour) {
11149
- setRangeData(minutes, startMinute, 60, true);
11150
- } else if (startHour === hour && endHour === hour) {
11151
- setRangeData(minutes, startMinute, endMinute + 1, true);
11152
- } else if (startHour !== hour && endHour === hour) {
11153
- setRangeData(minutes, 0, endMinute + 1, true);
11154
- } else if (startHour < hour && endHour > hour) {
11155
- setRangeData(minutes, 0, 60, true);
11156
- }
11157
- });
11158
- } else {
11159
- setRangeData(minutes, 0, 60, true);
11160
- }
11161
- return minutes;
11162
- };
11163
-
11164
- var range = function range(n) {
11165
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
11166
- return Array.apply(null, { length: n }).map(function (_, n) {
11167
- return n;
11168
- });
11169
- };
11170
-
11171
- var modifyDate = function modifyDate(date, y, m, d) {
11172
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
11173
- };
11174
-
11175
- var modifyTime = function modifyTime(date, h, m, s) {
11176
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
11177
- };
11178
-
11179
- var modifyWithTimeString = function modifyWithTimeString(date, time) {
11180
- if (date == null || !time) {
11181
- return date;
11182
- }
11183
- time = parseDate(time, 'HH:mm:ss');
11184
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
11185
- };
11186
-
11187
- var clearTime = function clearTime(date) {
11188
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
11189
- };
11190
-
11191
- var clearMilliseconds = function clearMilliseconds(date) {
11192
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
11193
- };
11194
-
11195
- var limitTimeRange = function limitTimeRange(date, ranges) {
11196
- var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
11197
-
11198
- // TODO: refactory a more elegant solution
11199
- if (ranges.length === 0) return date;
11200
- var normalizeDate = function normalizeDate(date) {
11201
- return fecha.parse(fecha.format(date, format), format);
11202
- };
11203
- var ndate = normalizeDate(date);
11204
- var nranges = ranges.map(function (range) {
11205
- return range.map(normalizeDate);
11206
- });
11207
- if (nranges.some(function (nrange) {
11208
- return ndate >= nrange[0] && ndate <= nrange[1];
11209
- })) return date;
11210
-
11211
- var minDate = nranges[0][0];
11212
- var maxDate = nranges[0][0];
11213
-
11214
- nranges.forEach(function (nrange) {
11215
- minDate = new Date(Math.min(nrange[0], minDate));
11216
- maxDate = new Date(Math.max(nrange[1], minDate));
11217
- });
11218
-
11219
- var ret = ndate < minDate ? minDate : maxDate;
11220
- // preserve Year/Month/Date
11221
- return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
11222
- };
11223
-
11224
- var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
11225
- var limitedDate = limitTimeRange(date, selectableRange, format);
11226
- return limitedDate.getTime() === date.getTime();
11227
- };
11228
-
11229
- var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
11230
- // clamp date to the number of days in `year`, `month`
11231
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
11232
- var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
11233
- return modifyDate(date, year, month, monthDate);
11234
- };
11235
-
11236
- var prevMonth = function prevMonth(date) {
11237
- var year = date.getFullYear();
11238
- var month = date.getMonth();
11239
- return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
11240
- };
11241
-
11242
- var nextMonth = function nextMonth(date) {
11243
- var year = date.getFullYear();
11244
- var month = date.getMonth();
11245
- return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
11246
- };
11247
-
11248
- var prevYear = function prevYear(date) {
11249
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
11250
-
11251
- var year = date.getFullYear();
11252
- var month = date.getMonth();
11253
- return changeYearMonthAndClampDate(date, year - amount, month);
11254
- };
11255
-
11256
- var nextYear = function nextYear(date) {
11257
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
11258
-
11259
- var year = date.getFullYear();
11260
- var month = date.getMonth();
11261
- return changeYearMonthAndClampDate(date, year + amount, month);
11262
- };
11263
-
11264
- var extractDateFormat = function extractDateFormat(format) {
11265
- return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
11266
- };
11267
-
11268
- var extractTimeFormat = function extractTimeFormat(format) {
11269
- return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
11270
- };
11271
-
11272
- var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
11273
- return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
11274
- };
11275
-
11108
+ */
11109
+ fecha.parse = function (dateStr, format) {
11110
+ if (typeof format !== 'string') {
11111
+ throw new Error('Invalid format in fecha.parse');
11112
+ }
11113
+
11114
+ format = fecha.masks[format] || format;
11115
+
11116
+ // Avoid regular expression denial of service, fail early for really long strings
11117
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
11118
+ if (dateStr.length > 1000) {
11119
+ return null;
11120
+ }
11121
+
11122
+ const dateInfo = {};
11123
+ const parseInfo = [];
11124
+ const literals = [];
11125
+ format = format.replace(literal, function($0, $1) {
11126
+ literals.push($1);
11127
+ return '@@@';
11128
+ });
11129
+ let newFormat = regexEscape(format).replace(token, function ($0) {
11130
+ if (parseFlags[$0]) {
11131
+ const info = parseFlags[$0];
11132
+ parseInfo.push(info[1]);
11133
+ return '(' + info[0] + ')';
11134
+ }
11135
+
11136
+ return $0;
11137
+ });
11138
+ newFormat = newFormat.replace(/@@@/g, function() {
11139
+ return literals.shift();
11140
+ });
11141
+ const matches = dateStr.match(new RegExp(newFormat, 'i'));
11142
+ if (!matches) {
11143
+ return null;
11144
+ }
11145
+
11146
+ for (let i = 1; i < matches.length; i++) {
11147
+ parseInfo[i - 1](dateInfo, matches[i]);
11148
+ }
11149
+
11150
+ const today = new Date();
11151
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
11152
+ dateInfo.hour = +dateInfo.hour + 12;
11153
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
11154
+ dateInfo.hour = 0;
11155
+ }
11156
+
11157
+ let date;
11158
+ if (dateInfo.timezoneOffset != null) {
11159
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
11160
+ date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
11161
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
11162
+ } else {
11163
+ date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
11164
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
11165
+ }
11166
+ return date;
11167
+ };
11168
+
11169
+ // 导出fecha对象
11170
+
11171
+
11172
+ // 以下是从date-util.js合并的函数
11173
+ const newArray = function(start, end) {
11174
+ let result = [];
11175
+ for (let i = start; i <= end; i++) {
11176
+ result.push(i);
11177
+ }
11178
+ return result;
11179
+ };
11180
+
11181
+ const getSettings = () => {
11182
+ return {
11183
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
11184
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
11185
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
11186
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
11187
+ amPm: ['上午', '下午']
11188
+ };
11189
+ };
11190
+
11191
+ const toDate = function(date) {
11192
+ return isDate(date) ? new Date(date) : null;
11193
+ };
11194
+
11195
+ const isDate = function(date) {
11196
+ if (date === null || date === undefined) return false;
11197
+ if (isNaN(new Date(date).getTime())) return false;
11198
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
11199
+ return true;
11200
+ };
11201
+
11202
+ const isDateObject = function(val) {
11203
+ return val instanceof Date;
11204
+ };
11205
+
11206
+ const formatDate = function (date, format = 'yyyy-MM-dd') {
11207
+ // 处理多种输入类型
11208
+ if (!date) return '';
11209
+
11210
+ // 如果是时间戳,转成日期对象
11211
+ if (typeof date === 'number') {
11212
+ date = new Date(date);
11213
+ }
11214
+ // 如果是字符串,转成日期对象
11215
+ if (typeof date === 'string') {
11216
+ date = new Date(date);
11217
+ }
11218
+
11219
+ // 调用toDate进一步验证和转换
11220
+ date = toDate(date);
11221
+ if (!date) return '';
11222
+
11223
+ // 兼容大写和小写的格式标记
11224
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
11225
+ const lowercaseFormat = format
11226
+ .replace(/YYYY/g, 'yyyy')
11227
+ .replace(/D/g, 'd')
11228
+
11229
+ // 使用fecha库进行格式化,支持中文配置
11230
+ const str = fecha.format(date, lowercaseFormat, getSettings());
11231
+ return str;
11232
+ };
11233
+
11234
+ const parseDate = function(string, format) {
11235
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
11236
+ };
11237
+
11238
+ const getDayCountOfMonth = function(year, month) {
11239
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
11240
+ return 30;
11241
+ }
11242
+
11243
+ if (month === 1) {
11244
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
11245
+ return 29;
11246
+ } else {
11247
+ return 28;
11248
+ }
11249
+ }
11250
+
11251
+ return 31;
11252
+ };
11253
+
11254
+ const getDayCountOfYear = function(year) {
11255
+ const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
11256
+ return isLeapYear ? 366 : 365;
11257
+ };
11258
+
11259
+ const getFirstDayOfMonth = function(date) {
11260
+ const temp = new Date(date.getTime());
11261
+ temp.setDate(1);
11262
+ return temp.getDay();
11263
+ };
11264
+
11265
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
11266
+ // {prev, next} Date should work for Daylight Saving Time
11267
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
11268
+ const prevDate = function(date, amount = 1) {
11269
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
11270
+ };
11271
+
11272
+ const nextDate = function(date, amount = 1) {
11273
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
11274
+ };
11275
+
11276
+ const getStartDateOfMonth = function(year, month) {
11277
+ const result = new Date(year, month, 1);
11278
+ const day = result.getDay();
11279
+
11280
+ if (day === 0) {
11281
+ return prevDate(result, 7);
11282
+ } else {
11283
+ return prevDate(result, day);
11284
+ }
11285
+ };
11286
+
11287
+ const getWeekNumber = function(date) {
11288
+ // 支持多种输入类型
11289
+ if (!date||!isDate(date)) {
11290
+ date = new Date();
11291
+ }
11292
+ if (typeof date === 'string') {
11293
+ date = new Date(date);
11294
+ }
11295
+
11296
+ // 验证日期有效性
11297
+ if (!isDate(date)) return null;
11298
+
11299
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
11300
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
11301
+ // 将星期日的星期数设为7
11302
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
11303
+ // 获取当年的第一天
11304
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
11305
+ // 计算到最近的星期四的完整周数
11306
+ const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
11307
+ // 返回周数
11308
+ return weekNo;
11309
+ };
11310
+
11311
+ const getRangeHours = function(ranges) {
11312
+ const hours = [];
11313
+ let disabledHours = [];
11314
+
11315
+ (ranges || []).forEach(range => {
11316
+ const value = range.map(date => date.getHours());
11317
+
11318
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
11319
+ });
11320
+
11321
+ if (disabledHours.length) {
11322
+ for (let i = 0; i < 24; i++) {
11323
+ hours[i] = disabledHours.indexOf(i) === -1;
11324
+ }
11325
+ } else {
11326
+ for (let i = 0; i < 24; i++) {
11327
+ hours[i] = false;
11328
+ }
11329
+ }
11330
+
11331
+ return hours;
11332
+ };
11333
+
11334
+ const getPrevMonthLastDays = (date, amount) => {
11335
+ if (amount <= 0) return [];
11336
+ const temp = new Date(date.getTime());
11337
+ temp.setDate(0);
11338
+ const lastDay = temp.getDate();
11339
+ return range(amount).map((_, index) => lastDay - (amount - index - 1));
11340
+ };
11341
+
11342
+ const getMonthDays = (date) => {
11343
+ const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
11344
+ const days = temp.getDate();
11345
+ return range(days).map((_, index) => index + 1);
11346
+ };
11347
+
11348
+ function setRangeData(arr, start, end, value) {
11349
+ for (let i = start; i < end; i++) {
11350
+ arr[i] = value;
11351
+ }
11352
+ }
11353
+
11354
+ const getRangeMinutes = function(ranges, hour) {
11355
+ const minutes = new Array(60);
11356
+
11357
+ if (ranges.length > 0) {
11358
+ ranges.forEach(range => {
11359
+ const start = range[0];
11360
+ const end = range[1];
11361
+ const startHour = start.getHours();
11362
+ const startMinute = start.getMinutes();
11363
+ const endHour = end.getHours();
11364
+ const endMinute = end.getMinutes();
11365
+ if (startHour === hour && endHour !== hour) {
11366
+ setRangeData(minutes, startMinute, 60, true);
11367
+ } else if (startHour === hour && endHour === hour) {
11368
+ setRangeData(minutes, startMinute, endMinute + 1, true);
11369
+ } else if (startHour !== hour && endHour === hour) {
11370
+ setRangeData(minutes, 0, endMinute + 1, true);
11371
+ } else if (startHour < hour && endHour > hour) {
11372
+ setRangeData(minutes, 0, 60, true);
11373
+ }
11374
+ });
11375
+ } else {
11376
+ setRangeData(minutes, 0, 60, true);
11377
+ }
11378
+ return minutes;
11379
+ };
11380
+
11381
+ const range = function(n) {
11382
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
11383
+ return Array.apply(null, {length: n}).map((_, n) => n);
11384
+ };
11385
+
11386
+ const modifyDate = function(date, y, m, d) {
11387
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
11388
+ };
11389
+
11390
+ const modifyTime = function(date, h, m, s) {
11391
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
11392
+ };
11393
+
11394
+ const modifyWithTimeString = (date, time) => {
11395
+ if (date == null || !time) {
11396
+ return date;
11397
+ }
11398
+ time = parseDate(time, 'HH:mm:ss');
11399
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
11400
+ };
11401
+
11402
+ const clearTime = function(date) {
11403
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
11404
+ };
11405
+
11406
+ const clearMilliseconds = function(date) {
11407
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
11408
+ };
11409
+
11410
+ const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
11411
+ // TODO: refactory a more elegant solution
11412
+ if (ranges.length === 0) return date;
11413
+ const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
11414
+ const ndate = normalizeDate(date);
11415
+ const nranges = ranges.map(range => range.map(normalizeDate));
11416
+ if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
11417
+
11418
+ let minDate = nranges[0][0];
11419
+ let maxDate = nranges[0][0];
11420
+
11421
+ nranges.forEach(nrange => {
11422
+ minDate = new Date(Math.min(nrange[0], minDate));
11423
+ maxDate = new Date(Math.max(nrange[1], minDate));
11424
+ });
11425
+
11426
+ const ret = ndate < minDate ? minDate : maxDate;
11427
+ // preserve Year/Month/Date
11428
+ return modifyDate(
11429
+ ret,
11430
+ date.getFullYear(),
11431
+ date.getMonth(),
11432
+ date.getDate()
11433
+ );
11434
+ };
11435
+
11436
+ const timeWithinRange = function(date, selectableRange, format) {
11437
+ const limitedDate = limitTimeRange(date, selectableRange, format);
11438
+ return limitedDate.getTime() === date.getTime();
11439
+ };
11440
+
11441
+ const changeYearMonthAndClampDate = function(date, year, month) {
11442
+ // clamp date to the number of days in `year`, `month`
11443
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
11444
+ const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
11445
+ return modifyDate(date, year, month, monthDate);
11446
+ };
11447
+
11448
+ const prevMonth = function(date) {
11449
+ const year = date.getFullYear();
11450
+ const month = date.getMonth();
11451
+ return month === 0
11452
+ ? changeYearMonthAndClampDate(date, year - 1, 11)
11453
+ : changeYearMonthAndClampDate(date, year, month - 1);
11454
+ };
11455
+
11456
+ const nextMonth = function(date) {
11457
+ const year = date.getFullYear();
11458
+ const month = date.getMonth();
11459
+ return month === 11
11460
+ ? changeYearMonthAndClampDate(date, year + 1, 0)
11461
+ : changeYearMonthAndClampDate(date, year, month + 1);
11462
+ };
11463
+
11464
+ const prevYear = function(date, amount = 1) {
11465
+ const year = date.getFullYear();
11466
+ const month = date.getMonth();
11467
+ return changeYearMonthAndClampDate(date, year - amount, month);
11468
+ };
11469
+
11470
+ const nextYear = function(date, amount = 1) {
11471
+ const year = date.getFullYear();
11472
+ const month = date.getMonth();
11473
+ return changeYearMonthAndClampDate(date, year + amount, month);
11474
+ };
11475
+
11476
+ const extractDateFormat = function(format) {
11477
+ return format
11478
+ .replace(/\W?m{1,2}|\W?ZZ/g, '')
11479
+ .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
11480
+ .trim();
11481
+ };
11482
+
11483
+ const extractTimeFormat = function(format) {
11484
+ return format
11485
+ .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
11486
+ .trim();
11487
+ };
11488
+
11489
+ const validateRangeInOneMonth = function(start, end) {
11490
+ return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
11491
+ };
11492
+
11276
11493
  /**
11277
11494
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
11278
11495
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
11279
11496
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
11280
11497
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
11281
11498
  * @returns {number} 工作日数量
11282
- */
11283
- var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
11284
- var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
11285
-
11286
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
11287
- throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
11288
- }
11289
-
11290
- var startDateObj = new Date(start_date);
11291
- var endDateObj = new Date(end_date);
11292
-
11293
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
11294
- throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
11295
- }
11296
-
11297
- if (startDateObj > endDateObj) {
11298
- throw new Error('Start date should be earlier than or equal to end date.');
11299
- }
11300
-
11301
- var workdays = 0;
11302
-
11303
- // Iterate through each day in the date range
11304
-
11305
- var _loop = function _loop(currentDate) {
11306
- // Check if the current day is a weekend (Saturday or Sunday)
11307
- var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
11308
-
11309
- // Check if the current day is a holiday
11310
- var isHoliday = holidays.some(function (holiday) {
11311
- var holidayDate = new Date(holiday);
11312
- return currentDate.toDateString() === holidayDate.toDateString();
11313
- });
11314
-
11315
- // If it's a workday (not a weekend or holiday), increment the workdays count
11316
- if (!isWeekend && !isHoliday) {
11317
- workdays++;
11318
- }
11319
- };
11320
-
11321
- for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
11322
- _loop(currentDate);
11323
- }
11324
-
11325
- return workdays;
11326
- };
11327
-
11499
+ */
11500
+ const calculateNetworkDays = function (start_date, end_date, holidays = []) {
11501
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
11502
+ throw new Error(
11503
+ "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
11504
+ );
11505
+ }
11506
+
11507
+ const startDateObj = new Date(start_date);
11508
+ const endDateObj = new Date(end_date);
11509
+
11510
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
11511
+ throw new Error(
11512
+ "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
11513
+ );
11514
+ }
11515
+
11516
+ if (startDateObj > endDateObj) {
11517
+ throw new Error('Start date should be earlier than or equal to end date.');
11518
+ }
11519
+
11520
+ let workdays = 0;
11521
+
11522
+ // Iterate through each day in the date range
11523
+ for (
11524
+ let currentDate = new Date(startDateObj);
11525
+ currentDate <= endDateObj;
11526
+ currentDate.setDate(currentDate.getDate() + 1)
11527
+ ) {
11528
+ // Check if the current day is a weekend (Saturday or Sunday)
11529
+ const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
11530
+
11531
+ // Check if the current day is a holiday
11532
+ const isHoliday = holidays.some((holiday) => {
11533
+ const holidayDate = new Date(holiday);
11534
+ return currentDate.toDateString() === holidayDate.toDateString();
11535
+ });
11536
+
11537
+ // If it's a workday (not a weekend or holiday), increment the workdays count
11538
+ if (!isWeekend && !isHoliday) {
11539
+ workdays++;
11540
+ }
11541
+ }
11542
+
11543
+ return workdays;
11544
+ };
11545
+
11328
11546
  /**
11329
11547
  * 日期加减天数
11330
11548
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
11331
11549
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
11332
11550
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
11333
- */
11334
- var dateAddDays = function dateAddDays(start_date, days) {
11335
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
11336
- 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.");
11337
- }
11338
-
11339
- var startDateObj = new Date(start_date);
11340
- if (isNaN(startDateObj.getTime())) {
11341
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
11342
- }
11343
-
11344
- var resultDateObj = new Date(startDateObj);
11345
- resultDateObj.setDate(resultDateObj.getDate() + days);
11346
-
11347
- var resultYear = resultDateObj.getFullYear();
11348
- var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
11349
- var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
11350
-
11351
- return resultYear + '-' + resultMonth + '-' + resultDay;
11352
- };
11353
-
11551
+ */
11552
+ const dateAddDays = function (start_date, days) {
11553
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
11554
+ throw new Error(
11555
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
11556
+ );
11557
+ }
11558
+
11559
+ const startDateObj = new Date(start_date);
11560
+ if (isNaN(startDateObj.getTime())) {
11561
+ throw new Error(
11562
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
11563
+ );
11564
+ }
11565
+
11566
+ const resultDateObj = new Date(startDateObj);
11567
+ resultDateObj.setDate(resultDateObj.getDate() + days);
11568
+
11569
+ const resultYear = resultDateObj.getFullYear();
11570
+ const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
11571
+ const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
11572
+
11573
+ return `${resultYear}-${resultMonth}-${resultDay}`;
11574
+ };
11575
+
11354
11576
  /**
11355
11577
  * 计算两个日期之间的差值
11356
11578
  * @date 2023年12月14日
@@ -11358,180 +11580,182 @@ var dateAddDays = function dateAddDays(start_date, days) {
11358
11580
  * @param {String} end_date - 结束日期字符串
11359
11581
  * @param {String} unit - 单位:year/month/day
11360
11582
  * @returns {Number} 差值
11361
- */
11362
- var dateDiff = function dateDiff(start_date, end_date) {
11363
- var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
11364
-
11365
- // Assuming date strings are in "YYYY-MM-DD" format
11366
- var startDate = new Date(start_date);
11367
- var endDate = new Date(end_date);
11368
-
11369
- // If the date is invalid, return 0
11370
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
11371
- return 0;
11372
- }
11373
-
11374
- if (unit === 'year') {
11375
- return endDate.getFullYear() - startDate.getFullYear();
11376
- } else if (unit === 'month') {
11377
- return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
11378
- } else {
11379
- // Default to day
11380
- var timeDifference = endDate - startDate;
11381
- // Calculate days (86400000 milliseconds per day)
11382
- return Math.floor(timeDifference / 86400000);
11383
- }
11384
- };
11385
-
11583
+ */
11584
+ const dateDiff = function (start_date, end_date, unit = 'day') {
11585
+ // Assuming date strings are in "YYYY-MM-DD" format
11586
+ var startDate = new Date(start_date);
11587
+ var endDate = new Date(end_date);
11588
+
11589
+ // If the date is invalid, return 0
11590
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
11591
+ return 0;
11592
+ }
11593
+
11594
+ if (unit === 'year') {
11595
+ return endDate.getFullYear() - startDate.getFullYear();
11596
+ } else if (unit === 'month') {
11597
+ return (
11598
+ (endDate.getFullYear() - startDate.getFullYear()) * 12 +
11599
+ (endDate.getMonth() - startDate.getMonth())
11600
+ );
11601
+ } else {
11602
+ // Default to day
11603
+ var timeDifference = endDate - startDate;
11604
+ // Calculate days (86400000 milliseconds per day)
11605
+ return Math.floor(timeDifference / 86400000);
11606
+ }
11607
+ };
11608
+
11386
11609
  /**
11387
11610
  * 获取月份中的日期
11388
11611
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
11389
11612
  * @returns {number} 月份中的日期(1-31)
11390
- */
11391
- var dayOfMonth = function dayOfMonth(date) {
11392
- if (typeof date !== 'string') {
11393
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
11394
- }
11395
-
11396
- var dateObj = new Date(date);
11397
- if (isNaN(dateObj.getTime())) {
11398
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
11399
- }
11400
-
11401
- return dateObj.getDate();
11402
- };
11403
-
11613
+ */
11614
+ const dayOfMonth = function (date) {
11615
+ if (typeof date !== 'string') {
11616
+ throw new Error(
11617
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
11618
+ );
11619
+ }
11620
+
11621
+ const dateObj = new Date(date);
11622
+ if (isNaN(dateObj.getTime())) {
11623
+ throw new Error(
11624
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
11625
+ );
11626
+ }
11627
+
11628
+ return dateObj.getDate();
11629
+ };
11630
+
11404
11631
  /**
11405
11632
  * 获取当前日期
11406
11633
  * @date 2022年5月7日
11407
11634
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
11408
11635
  * @returns {string} 当前日期的格式化字符串
11409
- */
11410
- var getCurrentDate = function getCurrentDate() {
11411
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
11412
-
11413
- return formatDate(new Date(), format);
11414
- };
11415
-
11636
+ */
11637
+ const getCurrentDate = function (format = 'YYYY-MM-DD') {
11638
+ return formatDate(new Date(), format);
11639
+ };
11640
+
11416
11641
  /**
11417
11642
  * 获取当前日期时间
11418
11643
  * @date 2022年5月7日
11419
11644
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
11420
11645
  * @returns {string} 当前日期时间的格式化字符串
11421
- */
11422
- var getCurrentDateTime = function getCurrentDateTime() {
11423
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
11424
-
11425
- return formatDate(new Date(), format);
11426
- };
11427
-
11646
+ */
11647
+ const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
11648
+ return formatDate(new Date(), format);
11649
+ };
11650
+
11428
11651
  /**
11429
11652
  * 获取小时
11430
11653
  * @date 2022年5月7日
11431
11654
  * @param {Date|string} [date] - 日期对象或日期字符串
11432
11655
  * @returns {number} 小时数(0-23)
11433
- */
11434
- var getHour = function getHour(date) {
11435
- if (!date) {
11436
- return new Date().getHours();
11437
- }
11438
- if (typeof date === 'string') {
11439
- date = new Date(date);
11440
- }
11441
- return date.getHours();
11442
- };
11443
-
11656
+ */
11657
+ const getHour = function (date) {
11658
+ if (!date) {
11659
+ return new Date().getHours();
11660
+ }
11661
+ if (typeof date === 'string') {
11662
+ date = new Date(date);
11663
+ }
11664
+ return date.getHours();
11665
+ };
11666
+
11444
11667
  /**
11445
11668
  * 获取分钟
11446
11669
  * @date 2022年5月7日
11447
11670
  * @param {Date|string} [date] - 日期对象或日期字符串
11448
11671
  * @returns {number} 分钟数(0-59)
11449
- */
11450
- var getMinute = function getMinute(date) {
11451
- if (!date) {
11452
- return new Date().getMinutes();
11453
- }
11454
- if (typeof date === 'string') {
11455
- date = new Date(date);
11456
- }
11457
- return date.getMinutes();
11458
- };
11459
-
11672
+ */
11673
+ const getMinute = function (date) {
11674
+ if (!date) {
11675
+ return new Date().getMinutes();
11676
+ }
11677
+ if (typeof date === 'string') {
11678
+ date = new Date(date);
11679
+ }
11680
+ return date.getMinutes();
11681
+ };
11682
+
11460
11683
  /**
11461
11684
  * 获取月份
11462
11685
  * @date 2022年5月7日
11463
11686
  * @param {Date|string} [date] - 日期对象或日期字符串
11464
11687
  * @returns {number} 月份数(1-12)
11465
- */
11466
- var getMonth = function getMonth(date) {
11467
- if (!date) {
11468
- return new Date().getMonth() + 1;
11469
- }
11470
- if (typeof date === 'string') {
11471
- date = new Date(date);
11472
- }
11473
- return date.getMonth() + 1;
11474
- };
11475
-
11688
+ */
11689
+ const getMonth = function (date) {
11690
+ if (!date) {
11691
+ return new Date().getMonth() + 1;
11692
+ }
11693
+ if (typeof date === 'string') {
11694
+ date = new Date(date);
11695
+ }
11696
+ return date.getMonth() + 1;
11697
+ };
11698
+
11476
11699
  /**
11477
11700
  * 获取秒
11478
11701
  * @date 2022年5月7日
11479
11702
  * @param {Date|string} [date] - 日期对象或日期字符串
11480
11703
  * @returns {number} 秒数(0-59)
11481
- */
11482
- var getSecond = function getSecond(date) {
11483
- if (!date) {
11484
- return new Date().getSeconds();
11485
- }
11486
- if (typeof date === 'string') {
11487
- date = new Date(date);
11488
- }
11489
- return date.getSeconds();
11490
- };
11491
-
11704
+ */
11705
+ const getSecond = function (date) {
11706
+ if (!date) {
11707
+ return new Date().getSeconds();
11708
+ }
11709
+ if (typeof date === 'string') {
11710
+ date = new Date(date);
11711
+ }
11712
+ return date.getSeconds();
11713
+ };
11714
+
11492
11715
  /**
11493
11716
  * 获取星期几
11494
11717
  * @date 2022年5月7日
11495
11718
  * @param {Date|string} [date] - 日期对象或日期字符串
11496
11719
  * @returns {number} 星期几(0-6,0表示星期日)
11497
- */
11498
- var getWeekday = function getWeekday(date) {
11499
- if (!date) {
11500
- return new Date().getDay();
11501
- }
11502
- if (typeof date === 'string') {
11503
- date = new Date(date);
11504
- }
11505
- return date.getDay();
11506
- };
11507
-
11720
+ */
11721
+ const getWeekday = function (date) {
11722
+ if (!date) {
11723
+ return new Date().getDay();
11724
+ }
11725
+ if (typeof date === 'string') {
11726
+ date = new Date(date);
11727
+ }
11728
+ return date.getDay();
11729
+ };
11730
+
11731
+
11508
11732
  /**
11509
11733
  * @desc 获取上午/下午/晚上
11510
11734
  * @author huangbo
11511
11735
  * @date 2022年5月7日
11512
11736
  * @param {String} [time] - 时间
11513
- **/
11514
- var timeCycle = function timeCycle(time) {
11515
- var hour = 0;
11516
- if (!time) {
11517
- hour = new Date().getHours();
11518
- } else if (typeof time === 'string') {
11519
- // 从时间字符串中提取小时
11520
- var match = time.match(/^(\d{1,2})/);
11521
- if (match) {
11522
- hour = parseInt(match[1], 10);
11523
- }
11524
- } else if (typeof time === 'number') {
11525
- hour = time;
11526
- }
11527
- // 判断时间段
11528
- if (hour >= 5 && hour < 12) {
11529
- return '上午';
11530
- } else if (hour >= 12 && hour < 18) {
11531
- return '下午';
11532
- } else {
11533
- return '晚上';
11534
- }
11737
+ **/
11738
+ const timeCycle = function (time) {
11739
+ let hour = 0;
11740
+ if (!time) {
11741
+ hour = new Date().getHours();
11742
+ } else if (typeof time === 'string') {
11743
+ // 从时间字符串中提取小时
11744
+ const match = time.match(/^(\d{1,2})/);
11745
+ if (match) {
11746
+ hour = parseInt(match[1], 10);
11747
+ }
11748
+ } else if (typeof time === 'number') {
11749
+ hour = time;
11750
+ }
11751
+ // 判断时间段
11752
+ if (hour >= 5 && hour < 12) {
11753
+ return '上午';
11754
+ } else if (hour >= 12 && hour < 18) {
11755
+ return '下午';
11756
+ } else {
11757
+ return '晚上';
11758
+ }
11535
11759
  };
11536
11760
 
11537
11761
  /***/ }),