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
@@ -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 = 197);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 199);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -3781,7 +3781,7 @@ module.exports = require("lodash/cloneDeep");
3781
3781
 
3782
3782
  /***/ }),
3783
3783
 
3784
- /***/ 197:
3784
+ /***/ 199:
3785
3785
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3786
3786
 
3787
3787
  "use strict";
@@ -5857,9 +5857,7 @@ function insertAfter(newEl, targetEl) {
5857
5857
  /***/ 51:
5858
5858
  /***/ (function(module, exports, __webpack_require__) {
5859
5859
 
5860
- 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; };
5861
-
5862
- /**
5860
+ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
5863
5861
  * @fileOverview Kickass library to create and place poppers near their reference elements.
5864
5862
  * @version {{version}}
5865
5863
  * @license
@@ -5882,60 +5880,68 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
5882
5880
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5883
5881
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5884
5882
  * SOFTWARE.
5885
- */
5886
-
5887
- //
5888
- // Cross module loader
5889
- // Supported: Node, AMD, Browser globals
5890
- //
5891
- (function (root, factory) {
5892
- if (true) {
5893
- // AMD. Register as an anonymous module.
5883
+ */
5884
+
5885
+ //
5886
+ // Cross module loader
5887
+ // Supported: Node, AMD, Browser globals
5888
+ //
5889
+ (function (root, factory) {
5890
+ if (true) {
5891
+ // AMD. Register as an anonymous module.
5894
5892
  !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
5895
5893
  __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
5896
5894
  (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
5897
5895
  __WEBPACK_AMD_DEFINE_FACTORY__),
5898
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
5899
- } else {}
5900
- })(this, function () {
5901
- 'use strict';
5902
-
5903
- var root = window;
5904
- // default options
5905
- var DEFAULTS = {
5906
- // placement of the popper
5907
- placement: 'bottom',
5908
-
5909
- gpuAcceleration: true,
5910
-
5911
- // shift popper from its origin by the given amount of pixels (can be negative)
5912
- offset: 0,
5913
-
5914
- // the element which will act as boundary of the popper
5915
- boundariesElement: 'viewport',
5916
-
5917
- // amount of pixel used to define a minimum distance between the boundaries and the popper
5918
- boundariesPadding: 5,
5919
-
5920
- // popper will try to prevent overflow following this order,
5921
- // by default, then, it could overflow on the left and on top of the boundariesElement
5922
- preventOverflowOrder: ['left', 'right', 'top', 'bottom'],
5923
-
5924
- // the behavior used by flip to change the placement of the popper
5925
- flipBehavior: 'flip',
5926
-
5927
- arrowElement: '[x-arrow]',
5928
-
5929
- arrowOffset: 0,
5930
-
5931
- // list of functions used to modify the offsets before they are applied to the popper
5932
- modifiers: ['shift', 'offset', 'preventOverflow', 'keepTogether', 'arrow', 'flip', 'applyStyle'],
5933
-
5934
- modifiersIgnored: [],
5935
-
5936
- forceAbsolute: false
5937
- };
5938
-
5896
+ __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
5897
+ } else {}
5898
+ })(this, function () {
5899
+ 'use strict';
5900
+
5901
+ var root = window;
5902
+ // default options
5903
+ var DEFAULTS = {
5904
+ // placement of the popper
5905
+ placement: 'bottom',
5906
+
5907
+ gpuAcceleration: true,
5908
+
5909
+ // shift popper from its origin by the given amount of pixels (can be negative)
5910
+ offset: 0,
5911
+
5912
+ // the element which will act as boundary of the popper
5913
+ boundariesElement: 'viewport',
5914
+
5915
+ // amount of pixel used to define a minimum distance between the boundaries and the popper
5916
+ boundariesPadding: 5,
5917
+
5918
+ // popper will try to prevent overflow following this order,
5919
+ // by default, then, it could overflow on the left and on top of the boundariesElement
5920
+ preventOverflowOrder: ['left', 'right', 'top', 'bottom'],
5921
+
5922
+ // the behavior used by flip to change the placement of the popper
5923
+ flipBehavior: 'flip',
5924
+
5925
+ arrowElement: '[x-arrow]',
5926
+
5927
+ arrowOffset: 0,
5928
+
5929
+ // list of functions used to modify the offsets before they are applied to the popper
5930
+ modifiers: [
5931
+ 'shift',
5932
+ 'offset',
5933
+ 'preventOverflow',
5934
+ 'keepTogether',
5935
+ 'arrow',
5936
+ 'flip',
5937
+ 'applyStyle'
5938
+ ],
5939
+
5940
+ modifiersIgnored: [],
5941
+
5942
+ forceAbsolute: false
5943
+ };
5944
+
5939
5945
  /**
5940
5946
  * Create a new Popper.js instance
5941
5947
  * @constructor Popper
@@ -6000,114 +6006,125 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
6000
6006
  *
6001
6007
  * @param {Boolean} [options.removeOnDestroy=false]
6002
6008
  * Set to true if you want to automatically remove the popper when you call the `destroy` method.
6003
- */
6004
- function Popper(reference, popper, options) {
6005
- this._reference = reference.jquery ? reference[0] : reference;
6006
- this.state = {};
6007
-
6008
- // if the popper variable is a configuration object, parse it to generate an HTMLElement
6009
- // generate a default popper if is not defined
6010
- var isNotDefined = typeof popper === 'undefined' || popper === null;
6011
- var isConfig = popper && Object.prototype.toString.call(popper) === '[object Object]';
6012
- if (isNotDefined || isConfig) {
6013
- this._popper = this.parse(isConfig ? popper : {});
6014
- }
6015
- // otherwise, use the given HTMLElement as popper
6016
- else {
6017
- this._popper = popper.jquery ? popper[0] : popper;
6018
- }
6019
-
6020
- // with {} we create a new object with the options inside it
6021
- this._options = Object.assign({}, DEFAULTS, options);
6022
-
6023
- // refactoring modifiers' list
6024
- this._options.modifiers = this._options.modifiers.map(function (modifier) {
6025
- // remove ignored modifiers
6026
- if (this._options.modifiersIgnored.indexOf(modifier) !== -1) return;
6027
-
6028
- // set the x-placement attribute before everything else because it could be used to add margins to the popper
6029
- // margins needs to be calculated to get the correct popper offsets
6030
- if (modifier === 'applyStyle') {
6031
- this._popper.setAttribute('x-placement', this._options.placement);
6032
- }
6033
-
6034
- // return predefined modifier identified by string or keep the custom one
6035
- return this.modifiers[modifier] || modifier;
6036
- }.bind(this));
6037
-
6038
- // make sure to apply the popper position before any computation
6039
- this.state.position = this._getPosition(this._popper, this._reference);
6040
- setStyle(this._popper, { position: this.state.position, top: 0 });
6041
-
6042
- // fire the first update to position the popper in the right place
6043
- this.update();
6044
-
6045
- // setup event listeners, they will take care of update the position in specific situations
6046
- this._setupEventListeners();
6047
- return this;
6048
- }
6049
-
6050
- //
6051
- // Methods
6052
- //
6009
+ */
6010
+ function Popper(reference, popper, options) {
6011
+ this._reference = reference.jquery ? reference[0] : reference;
6012
+ this.state = {};
6013
+
6014
+ // if the popper variable is a configuration object, parse it to generate an HTMLElement
6015
+ // generate a default popper if is not defined
6016
+ var isNotDefined = typeof popper === 'undefined' || popper === null;
6017
+ var isConfig =
6018
+ popper && Object.prototype.toString.call(popper) === '[object Object]';
6019
+ if (isNotDefined || isConfig) {
6020
+ this._popper = this.parse(isConfig ? popper : {});
6021
+ }
6022
+ // otherwise, use the given HTMLElement as popper
6023
+ else {
6024
+ this._popper = popper.jquery ? popper[0] : popper;
6025
+ }
6026
+
6027
+ // with {} we create a new object with the options inside it
6028
+ this._options = Object.assign({}, DEFAULTS, options);
6029
+
6030
+ // refactoring modifiers' list
6031
+ this._options.modifiers = this._options.modifiers.map(
6032
+ function (modifier) {
6033
+ // remove ignored modifiers
6034
+ if (this._options.modifiersIgnored.indexOf(modifier) !== -1) return;
6035
+
6036
+ // set the x-placement attribute before everything else because it could be used to add margins to the popper
6037
+ // margins needs to be calculated to get the correct popper offsets
6038
+ if (modifier === 'applyStyle') {
6039
+ this._popper.setAttribute('x-placement', this._options.placement);
6040
+ }
6041
+
6042
+ // return predefined modifier identified by string or keep the custom one
6043
+ return this.modifiers[modifier] || modifier;
6044
+ }.bind(this)
6045
+ );
6046
+
6047
+ // make sure to apply the popper position before any computation
6048
+ this.state.position = this._getPosition(this._popper, this._reference);
6049
+ setStyle(this._popper, { position: this.state.position, top: 0 });
6050
+
6051
+ // fire the first update to position the popper in the right place
6052
+ this.update();
6053
+
6054
+ // setup event listeners, they will take care of update the position in specific situations
6055
+ this._setupEventListeners();
6056
+ return this;
6057
+ }
6058
+
6059
+ //
6060
+ // Methods
6061
+ //
6053
6062
  /**
6054
6063
  * Destroy the popper
6055
6064
  * @method
6056
6065
  * @memberof Popper
6057
- */
6058
- Popper.prototype.destroy = function () {
6059
- this._popper.removeAttribute('x-placement');
6060
- this._popper.style.left = '';
6061
- this._popper.style.position = '';
6062
- this._popper.style.top = '';
6063
- this._popper.style[getSupportedPropertyName('transform')] = '';
6064
- this._removeEventListeners();
6065
-
6066
- // remove the popper if user explicity asked for the deletion on destroy
6067
- if (this._options.removeOnDestroy) {
6068
- this._popper.remove();
6069
- }
6070
- return this;
6071
- };
6072
-
6066
+ */
6067
+ Popper.prototype.destroy = function () {
6068
+ this._popper.removeAttribute('x-placement');
6069
+ this._popper.style.left = '';
6070
+ this._popper.style.position = '';
6071
+ this._popper.style.top = '';
6072
+ this._popper.style[getSupportedPropertyName('transform')] = '';
6073
+ this._removeEventListeners();
6074
+
6075
+ // remove the popper if user explicity asked for the deletion on destroy
6076
+ if (this._options.removeOnDestroy) {
6077
+ this._popper.remove();
6078
+ }
6079
+ return this;
6080
+ };
6081
+
6073
6082
  /**
6074
6083
  * Updates the position of the popper, computing the new offsets and applying the new style
6075
6084
  * @method
6076
6085
  * @memberof Popper
6077
- */
6078
- Popper.prototype.update = function () {
6079
- var data = { instance: this, styles: {} };
6080
-
6081
- // store placement inside the data object, modifiers will be able to edit `placement` if needed
6082
- // and refer to _originalPlacement to know the original value
6083
- data.placement = this._options.placement;
6084
- data._originalPlacement = this._options.placement;
6085
-
6086
- // compute the popper and reference offsets and put them inside data.offsets
6087
- data.offsets = this._getOffsets(this._popper, this._reference, data.placement);
6088
-
6089
- // get boundaries
6090
- data.boundaries = this._getBoundaries(data, this._options.boundariesPadding, this._options.boundariesElement);
6091
-
6092
- data = this.runModifiers(data, this._options.modifiers);
6093
-
6094
- if (typeof this.state.updateCallback === 'function') {
6095
- this.state.updateCallback(data);
6096
- }
6097
- };
6098
-
6086
+ */
6087
+ Popper.prototype.update = function () {
6088
+ var data = { instance: this, styles: {} };
6089
+
6090
+ // store placement inside the data object, modifiers will be able to edit `placement` if needed
6091
+ // and refer to _originalPlacement to know the original value
6092
+ data.placement = this._options.placement;
6093
+ data._originalPlacement = this._options.placement;
6094
+
6095
+ // compute the popper and reference offsets and put them inside data.offsets
6096
+ data.offsets = this._getOffsets(
6097
+ this._popper,
6098
+ this._reference,
6099
+ data.placement
6100
+ );
6101
+
6102
+ // get boundaries
6103
+ data.boundaries = this._getBoundaries(
6104
+ data,
6105
+ this._options.boundariesPadding,
6106
+ this._options.boundariesElement
6107
+ );
6108
+
6109
+ data = this.runModifiers(data, this._options.modifiers);
6110
+
6111
+ if (typeof this.state.updateCallback === 'function') {
6112
+ this.state.updateCallback(data);
6113
+ }
6114
+ };
6115
+
6099
6116
  /**
6100
6117
  * If a function is passed, it will be executed after the initialization of popper with as first argument the Popper instance.
6101
6118
  * @method
6102
6119
  * @memberof Popper
6103
6120
  * @param {Function} callback
6104
- */
6105
- Popper.prototype.onCreate = function (callback) {
6106
- // the createCallbacks return as first argument the popper instance
6107
- callback(this);
6108
- return this;
6109
- };
6110
-
6121
+ */
6122
+ Popper.prototype.onCreate = function (callback) {
6123
+ // the createCallbacks return as first argument the popper instance
6124
+ callback(this);
6125
+ return this;
6126
+ };
6127
+
6111
6128
  /**
6112
6129
  * If a function is passed, it will be executed after each update of popper with as first argument the set of coordinates and informations
6113
6130
  * used to style popper and its arrow.
@@ -6115,93 +6132,101 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
6115
6132
  * @method
6116
6133
  * @memberof Popper
6117
6134
  * @param {Function} callback
6118
- */
6119
- Popper.prototype.onUpdate = function (callback) {
6120
- this.state.updateCallback = callback;
6121
- return this;
6122
- };
6123
-
6135
+ */
6136
+ Popper.prototype.onUpdate = function (callback) {
6137
+ this.state.updateCallback = callback;
6138
+ return this;
6139
+ };
6140
+
6124
6141
  /**
6125
6142
  * Helper used to generate poppers from a configuration file
6126
6143
  * @method
6127
6144
  * @memberof Popper
6128
6145
  * @param config {Object} configuration
6129
6146
  * @returns {HTMLElement} popper
6130
- */
6131
- Popper.prototype.parse = function (config) {
6132
- var defaultConfig = {
6133
- tagName: 'div',
6134
- classNames: ['popper'],
6135
- attributes: [],
6136
- parent: root.document.body,
6137
- content: '',
6138
- contentType: 'text',
6139
- arrowTagName: 'div',
6140
- arrowClassNames: ['popper__arrow'],
6141
- arrowAttributes: ['x-arrow']
6142
- };
6143
- config = Object.assign({}, defaultConfig, config);
6144
-
6145
- var d = root.document;
6146
-
6147
- var popper = d.createElement(config.tagName);
6148
- addClassNames(popper, config.classNames);
6149
- addAttributes(popper, config.attributes);
6150
- if (config.contentType === 'node') {
6151
- popper.appendChild(config.content.jquery ? config.content[0] : config.content);
6152
- } else if (config.contentType === 'html') {
6153
- popper.innerHTML = config.content;
6154
- } else {
6155
- popper.textContent = config.content;
6156
- }
6157
-
6158
- if (config.arrowTagName) {
6159
- var arrow = d.createElement(config.arrowTagName);
6160
- addClassNames(arrow, config.arrowClassNames);
6161
- addAttributes(arrow, config.arrowAttributes);
6162
- popper.appendChild(arrow);
6163
- }
6164
-
6165
- var parent = config.parent.jquery ? config.parent[0] : config.parent;
6166
-
6167
- // if the given parent is a string, use it to match an element
6168
- // if more than one element is matched, the first one will be used as parent
6169
- // if no elements are matched, the script will throw an error
6170
- if (typeof parent === 'string') {
6171
- parent = d.querySelectorAll(config.parent);
6172
- if (parent.length > 1) {
6173
- console.warn('WARNING: the given `parent` query(' + config.parent + ') matched more than one element, the first one will be used');
6174
- }
6175
- if (parent.length === 0) {
6176
- throw "ERROR: the given `parent` doesn't exists!";
6177
- }
6178
- parent = parent[0];
6179
- }
6180
- // if the given parent is a DOM nodes list or an array of nodes with more than one element,
6181
- // the first one will be used as parent
6182
- if (parent.length > 1 && parent instanceof Element === false) {
6183
- console.warn('WARNING: you have passed as parent a list of elements, the first one will be used');
6184
- parent = parent[0];
6185
- }
6186
-
6187
- // append the generated popper to its parent
6188
- parent.appendChild(popper);
6189
-
6190
- return popper;
6191
-
6147
+ */
6148
+ Popper.prototype.parse = function (config) {
6149
+ var defaultConfig = {
6150
+ tagName: 'div',
6151
+ classNames: ['popper'],
6152
+ attributes: [],
6153
+ parent: root.document.body,
6154
+ content: '',
6155
+ contentType: 'text',
6156
+ arrowTagName: 'div',
6157
+ arrowClassNames: ['popper__arrow'],
6158
+ arrowAttributes: ['x-arrow']
6159
+ };
6160
+ config = Object.assign({}, defaultConfig, config);
6161
+
6162
+ var d = root.document;
6163
+
6164
+ var popper = d.createElement(config.tagName);
6165
+ addClassNames(popper, config.classNames);
6166
+ addAttributes(popper, config.attributes);
6167
+ if (config.contentType === 'node') {
6168
+ popper.appendChild(
6169
+ config.content.jquery ? config.content[0] : config.content
6170
+ );
6171
+ } else if (config.contentType === 'html') {
6172
+ popper.innerHTML = config.content;
6173
+ } else {
6174
+ popper.textContent = config.content;
6175
+ }
6176
+
6177
+ if (config.arrowTagName) {
6178
+ var arrow = d.createElement(config.arrowTagName);
6179
+ addClassNames(arrow, config.arrowClassNames);
6180
+ addAttributes(arrow, config.arrowAttributes);
6181
+ popper.appendChild(arrow);
6182
+ }
6183
+
6184
+ var parent = config.parent.jquery ? config.parent[0] : config.parent;
6185
+
6186
+ // if the given parent is a string, use it to match an element
6187
+ // if more than one element is matched, the first one will be used as parent
6188
+ // if no elements are matched, the script will throw an error
6189
+ if (typeof parent === 'string') {
6190
+ parent = d.querySelectorAll(config.parent);
6191
+ if (parent.length > 1) {
6192
+ console.warn(
6193
+ 'WARNING: the given `parent` query(' +
6194
+ config.parent +
6195
+ ') matched more than one element, the first one will be used'
6196
+ );
6197
+ }
6198
+ if (parent.length === 0) {
6199
+ throw "ERROR: the given `parent` doesn't exists!";
6200
+ }
6201
+ parent = parent[0];
6202
+ }
6203
+ // if the given parent is a DOM nodes list or an array of nodes with more than one element,
6204
+ // the first one will be used as parent
6205
+ if (parent.length > 1 && parent instanceof Element === false) {
6206
+ console.warn(
6207
+ 'WARNING: you have passed as parent a list of elements, the first one will be used'
6208
+ );
6209
+ parent = parent[0];
6210
+ }
6211
+
6212
+ // append the generated popper to its parent
6213
+ parent.appendChild(popper);
6214
+
6215
+ return popper;
6216
+
6192
6217
  /**
6193
6218
  * Adds class names to the given element
6194
6219
  * @function
6195
6220
  * @ignore
6196
6221
  * @param {HTMLElement} target
6197
6222
  * @param {Array} classes
6198
- */
6199
- function addClassNames(element, classNames) {
6200
- classNames.forEach(function (className) {
6201
- element.classList.add(className);
6202
- });
6203
- }
6204
-
6223
+ */
6224
+ function addClassNames(element, classNames) {
6225
+ classNames.forEach(function (className) {
6226
+ element.classList.add(className);
6227
+ });
6228
+ }
6229
+
6205
6230
  /**
6206
6231
  * Adds attributes to the given element
6207
6232
  * @function
@@ -6210,14 +6235,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
6210
6235
  * @param {Array} attributes
6211
6236
  * @example
6212
6237
  * addAttributes(element, [ 'data-info:foobar' ]);
6213
- */
6214
- function addAttributes(element, attributes) {
6215
- attributes.forEach(function (attribute) {
6216
- element.setAttribute(attribute.split(':')[0], attribute.split(':')[1] || '');
6217
- });
6218
- }
6219
- };
6220
-
6238
+ */
6239
+ function addAttributes(element, attributes) {
6240
+ attributes.forEach(function (attribute) {
6241
+ element.setAttribute(
6242
+ attribute.split(':')[0],
6243
+ attribute.split(':')[1] || ''
6244
+ );
6245
+ });
6246
+ }
6247
+ };
6248
+
6221
6249
  /**
6222
6250
  * Helper used to get the position which will be applied to the popper
6223
6251
  * @method
@@ -6225,20 +6253,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
6225
6253
  * @param config {HTMLElement} popper element
6226
6254
  * @param reference {HTMLElement} reference element
6227
6255
  * @returns {String} position
6228
- */
6229
- Popper.prototype._getPosition = function (popper, reference) {
6230
- var container = getOffsetParent(reference);
6231
-
6232
- if (this._options.forceAbsolute) {
6233
- return 'absolute';
6234
- }
6235
-
6236
- // Decide if the popper will be fixed
6237
- // If the reference element is inside a fixed context, the popper will be fixed as well to allow them to scroll together
6238
- var isParentFixed = isFixed(reference, container);
6239
- return isParentFixed ? 'fixed' : 'absolute';
6240
- };
6241
-
6256
+ */
6257
+ Popper.prototype._getPosition = function (popper, reference) {
6258
+ var container = getOffsetParent(reference);
6259
+
6260
+ if (this._options.forceAbsolute) {
6261
+ return 'absolute';
6262
+ }
6263
+
6264
+ // Decide if the popper will be fixed
6265
+ // If the reference element is inside a fixed context, the popper will be fixed as well to allow them to scroll together
6266
+ var isParentFixed = isFixed(reference, container);
6267
+ return isParentFixed ? 'fixed' : 'absolute';
6268
+ };
6269
+
6242
6270
  /**
6243
6271
  * Get offsets to the popper
6244
6272
  * @method
@@ -6247,93 +6275,110 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
6247
6275
  * @param {Element} popper - the popper element
6248
6276
  * @param {Element} reference - the reference element (the popper will be relative to this)
6249
6277
  * @returns {Object} An object containing the offsets which will be applied to the popper
6250
- */
6251
- Popper.prototype._getOffsets = function (popper, reference, placement) {
6252
- placement = placement.split('-')[0];
6253
- var popperOffsets = {};
6254
-
6255
- popperOffsets.position = this.state.position;
6256
- var isParentFixed = popperOffsets.position === 'fixed';
6257
-
6258
- //
6259
- // Get reference element position
6260
- //
6261
- var referenceOffsets = getOffsetRectRelativeToCustomParent(reference, getOffsetParent(popper), isParentFixed);
6262
-
6263
- //
6264
- // Get popper sizes
6265
- //
6266
- var popperRect = getOuterSizes(popper);
6267
-
6268
- //
6269
- // Compute offsets of popper
6270
- //
6271
-
6272
- // depending by the popper placement we have to compute its offsets slightly differently
6273
- if (['right', 'left'].indexOf(placement) !== -1) {
6274
- popperOffsets.top = referenceOffsets.top + referenceOffsets.height / 2 - popperRect.height / 2;
6275
- if (placement === 'left') {
6276
- popperOffsets.left = referenceOffsets.left - popperRect.width;
6277
- } else {
6278
- popperOffsets.left = referenceOffsets.right;
6279
- }
6280
- } else {
6281
- popperOffsets.left = referenceOffsets.left + referenceOffsets.width / 2 - popperRect.width / 2;
6282
- if (placement === 'top') {
6283
- popperOffsets.top = referenceOffsets.top - popperRect.height;
6284
- } else {
6285
- popperOffsets.top = referenceOffsets.bottom;
6286
- }
6287
- }
6288
-
6289
- // Add width and height to our offsets object
6290
- popperOffsets.width = popperRect.width;
6291
- popperOffsets.height = popperRect.height;
6292
-
6293
- return {
6294
- popper: popperOffsets,
6295
- reference: referenceOffsets
6296
- };
6297
- };
6298
-
6278
+ */
6279
+ Popper.prototype._getOffsets = function (popper, reference, placement) {
6280
+ placement = placement.split('-')[0];
6281
+ var popperOffsets = {};
6282
+
6283
+ popperOffsets.position = this.state.position;
6284
+ var isParentFixed = popperOffsets.position === 'fixed';
6285
+
6286
+ //
6287
+ // Get reference element position
6288
+ //
6289
+ var referenceOffsets = getOffsetRectRelativeToCustomParent(
6290
+ reference,
6291
+ popper,
6292
+ isParentFixed
6293
+ );
6294
+
6295
+ //
6296
+ // Get popper sizes
6297
+ //
6298
+ var popperRect = getOuterSizes(popper);
6299
+
6300
+ //
6301
+ // Compute offsets of popper
6302
+ //
6303
+
6304
+ // depending by the popper placement we have to compute its offsets slightly differently
6305
+ if (['right', 'left'].indexOf(placement) !== -1) {
6306
+ popperOffsets.top =
6307
+ referenceOffsets.top +
6308
+ referenceOffsets.height / 2 -
6309
+ popperRect.height / 2;
6310
+ if (placement === 'left') {
6311
+ popperOffsets.left = referenceOffsets.left - popperRect.width;
6312
+ } else {
6313
+ popperOffsets.left = referenceOffsets.right;
6314
+ }
6315
+ } else {
6316
+ popperOffsets.left =
6317
+ referenceOffsets.left +
6318
+ referenceOffsets.width / 2 -
6319
+ popperRect.width / 2;
6320
+ if (placement === 'top') {
6321
+ popperOffsets.top = referenceOffsets.top - popperRect.height;
6322
+ } else {
6323
+ popperOffsets.top = referenceOffsets.bottom;
6324
+ }
6325
+ }
6326
+
6327
+ // Add width and height to our offsets object
6328
+ popperOffsets.width = popperRect.width;
6329
+ popperOffsets.height = popperRect.height;
6330
+
6331
+ return {
6332
+ popper: popperOffsets,
6333
+ reference: referenceOffsets
6334
+ };
6335
+ };
6336
+
6299
6337
  /**
6300
6338
  * Setup needed event listeners used to update the popper position
6301
6339
  * @method
6302
6340
  * @memberof Popper
6303
6341
  * @access private
6304
- */
6305
- Popper.prototype._setupEventListeners = function () {
6306
- // NOTE: 1 DOM access here
6307
- this.state.updateBound = this.update.bind(this);
6308
- root.addEventListener('resize', this.state.updateBound);
6309
- // if the boundariesElement is window we don't need to listen for the scroll event
6310
- if (this._options.boundariesElement !== 'window') {
6311
- var target = getScrollParent(this._reference);
6312
- // here it could be both `body` or `documentElement` thanks to Firefox, we then check both
6313
- if (target === root.document.body || target === root.document.documentElement) {
6314
- target = root;
6315
- }
6316
- target.addEventListener('scroll', this.state.updateBound);
6317
- this.state.scrollTarget = target;
6318
- }
6319
- };
6320
-
6342
+ */
6343
+ Popper.prototype._setupEventListeners = function () {
6344
+ // NOTE: 1 DOM access here
6345
+ this.state.updateBound = this.update.bind(this);
6346
+ // 无界等微前端场景下沙箱 window 不会触发 resize,需监听真实 window
6347
+ this.state.realWindow = getRealWindow(this._popper);
6348
+ this.state.realWindow.addEventListener('resize', this.state.updateBound);
6349
+ // if the boundariesElement is window we don't need to listen for the scroll event
6350
+ if (this._options.boundariesElement !== 'window') {
6351
+ var target = getScrollParent(this._reference);
6352
+ target.addEventListener('scroll', this.state.updateBound);
6353
+ this.state.scrollTarget = target;
6354
+ }
6355
+ };
6356
+
6321
6357
  /**
6322
6358
  * Remove event listeners used to update the popper position
6323
6359
  * @method
6324
6360
  * @memberof Popper
6325
6361
  * @access private
6326
- */
6327
- Popper.prototype._removeEventListeners = function () {
6328
- // NOTE: 1 DOM access here
6329
- root.removeEventListener('resize', this.state.updateBound);
6330
- if (this._options.boundariesElement !== 'window' && this.state.scrollTarget) {
6331
- this.state.scrollTarget.removeEventListener('scroll', this.state.updateBound);
6332
- this.state.scrollTarget = null;
6333
- }
6334
- this.state.updateBound = null;
6335
- };
6336
-
6362
+ */
6363
+ Popper.prototype._removeEventListeners = function () {
6364
+ // NOTE: 1 DOM access here
6365
+ (this.state.realWindow || root).removeEventListener(
6366
+ 'resize',
6367
+ this.state.updateBound
6368
+ );
6369
+ if (
6370
+ this._options.boundariesElement !== 'window' &&
6371
+ this.state.scrollTarget
6372
+ ) {
6373
+ this.state.scrollTarget.removeEventListener(
6374
+ 'scroll',
6375
+ this.state.updateBound
6376
+ );
6377
+ this.state.scrollTarget = null;
6378
+ }
6379
+ this.state.updateBound = null;
6380
+ };
6381
+
6337
6382
  /**
6338
6383
  * Computed the boundaries limits and return them
6339
6384
  * @method
@@ -6343,66 +6388,75 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
6343
6388
  * @param {Number} padding - Boundaries padding
6344
6389
  * @param {Element} boundariesElement - Element used to define the boundaries
6345
6390
  * @returns {Object} Coordinates of the boundaries
6346
- */
6347
- Popper.prototype._getBoundaries = function (data, padding, boundariesElement) {
6348
- // NOTE: 1 DOM access here
6349
- var boundaries = {};
6350
- var width, height;
6351
- if (boundariesElement === 'window') {
6352
- var body = root.document.body,
6353
- html = root.document.documentElement;
6354
-
6355
- height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
6356
- width = Math.max(body.scrollWidth, body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth);
6357
-
6358
- boundaries = {
6359
- top: 0,
6360
- right: width,
6361
- bottom: height,
6362
- left: 0
6363
- };
6364
- } else if (boundariesElement === 'viewport') {
6365
- var offsetParent = getOffsetParent(this._popper);
6366
- var scrollParent = getScrollParent(this._popper);
6367
- var offsetParentRect = getOffsetRect(offsetParent);
6368
-
6369
- // Thanks the fucking native API, `document.body.scrollTop` & `document.documentElement.scrollTop`
6370
- var getScrollTopValue = function getScrollTopValue(element) {
6371
- return element == document.body ? Math.max(document.documentElement.scrollTop, document.body.scrollTop) : element.scrollTop;
6372
- };
6373
- var getScrollLeftValue = function getScrollLeftValue(element) {
6374
- return element == document.body ? Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) : element.scrollLeft;
6375
- };
6376
-
6377
- // if the popper is fixed we don't have to substract scrolling from the boundaries
6378
- var scrollTop = data.offsets.popper.position === 'fixed' ? 0 : getScrollTopValue(scrollParent);
6379
- var scrollLeft = data.offsets.popper.position === 'fixed' ? 0 : getScrollLeftValue(scrollParent);
6380
-
6381
- boundaries = {
6382
- top: 0 - (offsetParentRect.top - scrollTop),
6383
- right: root.document.documentElement.clientWidth - (offsetParentRect.left - scrollLeft),
6384
- bottom: root.document.documentElement.clientHeight - (offsetParentRect.top - scrollTop),
6385
- left: 0 - (offsetParentRect.left - scrollLeft)
6386
- };
6387
- } else {
6388
- if (getOffsetParent(this._popper) === boundariesElement) {
6389
- boundaries = {
6390
- top: 0,
6391
- left: 0,
6392
- right: boundariesElement.clientWidth,
6393
- bottom: boundariesElement.clientHeight
6394
- };
6395
- } else {
6396
- boundaries = getOffsetRect(boundariesElement);
6397
- }
6398
- }
6399
- boundaries.left += padding;
6400
- boundaries.right -= padding;
6401
- boundaries.top = boundaries.top + padding;
6402
- boundaries.bottom = boundaries.bottom - padding;
6403
- return boundaries;
6404
- };
6405
-
6391
+ */
6392
+ Popper.prototype._getBoundaries = function (data, padding, boundariesElement) {
6393
+ // NOTE: 1 DOM access here
6394
+ var boundaries = {};
6395
+ var width, height;
6396
+ if (boundariesElement === 'window') {
6397
+ var body = root.document.body,
6398
+ html = root.document.documentElement;
6399
+
6400
+ height = Math.max(
6401
+ body.scrollHeight,
6402
+ body.offsetHeight,
6403
+ html.clientHeight,
6404
+ html.scrollHeight,
6405
+ html.offsetHeight
6406
+ );
6407
+ width = Math.max(
6408
+ body.scrollWidth,
6409
+ body.offsetWidth,
6410
+ html.clientWidth,
6411
+ html.scrollWidth,
6412
+ html.offsetWidth
6413
+ );
6414
+
6415
+ boundaries = {
6416
+ top: 0,
6417
+ right: width,
6418
+ bottom: height,
6419
+ left: 0
6420
+ };
6421
+ } else if (boundariesElement === 'viewport') {
6422
+ // 将真实 window 的视口换算到 popper 所在包含块的坐标系。
6423
+ // 无界等场景下沙箱 window 的尺寸、shadowRoot 内元素的 scrollTop 均不可靠,
6424
+ // 统一从元素自身的 view 与真实包含块获取
6425
+ var realWindow = getRealWindow(this._popper);
6426
+ var containingBlockRect = getContainingBlockRect(
6427
+ this._popper,
6428
+ data.offsets.popper.position === 'fixed'
6429
+ );
6430
+
6431
+ boundaries = {
6432
+ top: 0 - containingBlockRect.top,
6433
+ right:
6434
+ realWindow.document.documentElement.clientWidth -
6435
+ containingBlockRect.left,
6436
+ bottom:
6437
+ realWindow.document.documentElement.clientHeight -
6438
+ containingBlockRect.top,
6439
+ left: 0 - containingBlockRect.left
6440
+ };
6441
+ } else {
6442
+ if (getOffsetParent(this._popper) === boundariesElement) {
6443
+ boundaries = {
6444
+ top: 0,
6445
+ left: 0,
6446
+ right: boundariesElement.clientWidth,
6447
+ bottom: boundariesElement.clientHeight
6448
+ };
6449
+ } else {
6450
+ boundaries = getOffsetRect(boundariesElement);
6451
+ }
6452
+ }
6453
+ boundaries.left += padding;
6454
+ boundaries.right -= padding;
6455
+ boundaries.top = boundaries.top + padding;
6456
+ boundaries.bottom = boundaries.bottom - padding;
6457
+ return boundaries;
6458
+ };
6459
+
6406
6460
  /**
6407
6461
  * Loop trough the list of modifiers and run them in order, each of them will then edit the data object
6408
6462
  * @method
@@ -6411,22 +6465,27 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
6411
6465
  * @param {Object} data
6412
6466
  * @param {Array} modifiers
6413
6467
  * @param {Function} ends
6414
- */
6415
- Popper.prototype.runModifiers = function (data, modifiers, ends) {
6416
- var modifiersToRun = modifiers.slice();
6417
- if (ends !== undefined) {
6418
- modifiersToRun = this._options.modifiers.slice(0, getArrayKeyIndex(this._options.modifiers, ends));
6419
- }
6420
-
6421
- modifiersToRun.forEach(function (modifier) {
6422
- if (isFunction(modifier)) {
6423
- data = modifier.call(this, data);
6424
- }
6425
- }.bind(this));
6426
-
6427
- return data;
6428
- };
6429
-
6468
+ */
6469
+ Popper.prototype.runModifiers = function (data, modifiers, ends) {
6470
+ var modifiersToRun = modifiers.slice();
6471
+ if (ends !== undefined) {
6472
+ modifiersToRun = this._options.modifiers.slice(
6473
+ 0,
6474
+ getArrayKeyIndex(this._options.modifiers, ends)
6475
+ );
6476
+ }
6477
+
6478
+ modifiersToRun.forEach(
6479
+ function (modifier) {
6480
+ if (isFunction(modifier)) {
6481
+ data = modifier.call(this, data);
6482
+ }
6483
+ }.bind(this)
6484
+ );
6485
+
6486
+ return data;
6487
+ };
6488
+
6430
6489
  /**
6431
6490
  * Helper used to know if the given modifier depends from another one.
6432
6491
  * @method
@@ -6434,191 +6493,204 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
6434
6493
  * @param {String} requesting - name of requesting modifier
6435
6494
  * @param {String} requested - name of requested modifier
6436
6495
  * @returns {Boolean}
6437
- */
6438
- Popper.prototype.isModifierRequired = function (requesting, requested) {
6439
- var index = getArrayKeyIndex(this._options.modifiers, requesting);
6440
- return !!this._options.modifiers.slice(0, index).filter(function (modifier) {
6441
- return modifier === requested;
6442
- }).length;
6443
- };
6444
-
6445
- //
6446
- // Modifiers
6447
- //
6448
-
6496
+ */
6497
+ Popper.prototype.isModifierRequired = function (requesting, requested) {
6498
+ var index = getArrayKeyIndex(this._options.modifiers, requesting);
6499
+ return !!this._options.modifiers.slice(0, index).filter(function (modifier) {
6500
+ return modifier === requested;
6501
+ }).length;
6502
+ };
6503
+
6504
+ //
6505
+ // Modifiers
6506
+ //
6507
+
6449
6508
  /**
6450
6509
  * Modifiers list
6451
6510
  * @namespace Popper.modifiers
6452
6511
  * @memberof Popper
6453
6512
  * @type {Object}
6454
- */
6455
- Popper.prototype.modifiers = {};
6456
-
6513
+ */
6514
+ Popper.prototype.modifiers = {};
6515
+
6457
6516
  /**
6458
6517
  * Apply the computed styles to the popper element
6459
6518
  * @method
6460
6519
  * @memberof Popper.modifiers
6461
6520
  * @argument {Object} data - The data object generated by `update` method
6462
6521
  * @returns {Object} The same data object
6463
- */
6464
- Popper.prototype.modifiers.applyStyle = function (data) {
6465
- // apply the final offsets to the popper
6466
- // NOTE: 1 DOM access here
6467
- var styles = {
6468
- position: data.offsets.popper.position
6469
- };
6470
-
6471
- // round top and left to avoid blurry text
6472
- var left = Math.round(data.offsets.popper.left);
6473
- var top = Math.round(data.offsets.popper.top);
6474
-
6475
- // if gpuAcceleration is set to true and transform is supported, we use `translate3d` to apply the position to the popper
6476
- // we automatically use the supported prefixed version if needed
6477
- var prefixedProperty;
6478
- if (this._options.gpuAcceleration && (prefixedProperty = getSupportedPropertyName('transform'))) {
6479
- styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
6480
- styles.top = 0;
6481
- styles.left = 0;
6482
- }
6483
- // othwerise, we use the standard `left` and `top` properties
6484
- else {
6485
- styles.left = left;
6486
- styles.top = top;
6487
- }
6488
-
6489
- // any property present in `data.styles` will be applied to the popper,
6490
- // in this way we can make the 3rd party modifiers add custom styles to it
6491
- // Be aware, modifiers could override the properties defined in the previous
6492
- // lines of this modifier!
6493
- Object.assign(styles, data.styles);
6494
-
6495
- setStyle(this._popper, styles);
6496
-
6497
- // set an attribute which will be useful to style the tooltip (use it to properly position its arrow)
6498
- // NOTE: 1 DOM access here
6499
- this._popper.setAttribute('x-placement', data.placement);
6500
-
6501
- // if the arrow modifier is required and the arrow style has been computed, apply the arrow style
6502
- if (this.isModifierRequired(this.modifiers.applyStyle, this.modifiers.arrow) && data.offsets.arrow) {
6503
- setStyle(data.arrowElement, data.offsets.arrow);
6504
- }
6505
-
6506
- return data;
6507
- };
6508
-
6522
+ */
6523
+ Popper.prototype.modifiers.applyStyle = function (data) {
6524
+ // apply the final offsets to the popper
6525
+ // NOTE: 1 DOM access here
6526
+ var styles = {
6527
+ position: data.offsets.popper.position
6528
+ };
6529
+
6530
+ // round top and left to avoid blurry text
6531
+ var left = Math.round(data.offsets.popper.left);
6532
+ var top = Math.round(data.offsets.popper.top);
6533
+
6534
+ // if gpuAcceleration is set to true and transform is supported, we use `translate3d` to apply the position to the popper
6535
+ // we automatically use the supported prefixed version if needed
6536
+ var prefixedProperty;
6537
+ if (
6538
+ this._options.gpuAcceleration &&
6539
+ (prefixedProperty = getSupportedPropertyName('transform'))
6540
+ ) {
6541
+ styles[prefixedProperty] =
6542
+ 'translate3d(' + left + 'px, ' + top + 'px, 0)';
6543
+ styles.top = 0;
6544
+ styles.left = 0;
6545
+ }
6546
+ // othwerise, we use the standard `left` and `top` properties
6547
+ else {
6548
+ styles.left = left;
6549
+ styles.top = top;
6550
+ }
6551
+
6552
+ // any property present in `data.styles` will be applied to the popper,
6553
+ // in this way we can make the 3rd party modifiers add custom styles to it
6554
+ // Be aware, modifiers could override the properties defined in the previous
6555
+ // lines of this modifier!
6556
+ Object.assign(styles, data.styles);
6557
+
6558
+ setStyle(this._popper, styles);
6559
+
6560
+ // set an attribute which will be useful to style the tooltip (use it to properly position its arrow)
6561
+ // NOTE: 1 DOM access here
6562
+ this._popper.setAttribute('x-placement', data.placement);
6563
+
6564
+ // if the arrow modifier is required and the arrow style has been computed, apply the arrow style
6565
+ if (
6566
+ this.isModifierRequired(
6567
+ this.modifiers.applyStyle,
6568
+ this.modifiers.arrow
6569
+ ) &&
6570
+ data.offsets.arrow
6571
+ ) {
6572
+ setStyle(data.arrowElement, data.offsets.arrow);
6573
+ }
6574
+
6575
+ return data;
6576
+ };
6577
+
6509
6578
  /**
6510
6579
  * Modifier used to shift the popper on the start or end of its reference element side
6511
6580
  * @method
6512
6581
  * @memberof Popper.modifiers
6513
6582
  * @argument {Object} data - The data object generated by `update` method
6514
6583
  * @returns {Object} The data object, properly modified
6515
- */
6516
- Popper.prototype.modifiers.shift = function (data) {
6517
- var placement = data.placement;
6518
- var basePlacement = placement.split('-')[0];
6519
- var shiftVariation = placement.split('-')[1];
6520
-
6521
- // if shift shiftVariation is specified, run the modifier
6522
- if (shiftVariation) {
6523
- var reference = data.offsets.reference;
6524
- var popper = getPopperClientRect(data.offsets.popper);
6525
-
6526
- var shiftOffsets = {
6527
- y: {
6528
- start: { top: reference.top },
6529
- end: { top: reference.top + reference.height - popper.height }
6530
- },
6531
- x: {
6532
- start: { left: reference.left },
6533
- end: { left: reference.left + reference.width - popper.width }
6534
- }
6535
- };
6536
-
6537
- var axis = ['bottom', 'top'].indexOf(basePlacement) !== -1 ? 'x' : 'y';
6538
-
6539
- data.offsets.popper = Object.assign(popper, shiftOffsets[axis][shiftVariation]);
6540
- }
6541
-
6542
- return data;
6543
- };
6544
-
6584
+ */
6585
+ Popper.prototype.modifiers.shift = function (data) {
6586
+ var placement = data.placement;
6587
+ var basePlacement = placement.split('-')[0];
6588
+ var shiftVariation = placement.split('-')[1];
6589
+
6590
+ // if shift shiftVariation is specified, run the modifier
6591
+ if (shiftVariation) {
6592
+ var reference = data.offsets.reference;
6593
+ var popper = getPopperClientRect(data.offsets.popper);
6594
+
6595
+ var shiftOffsets = {
6596
+ y: {
6597
+ start: { top: reference.top },
6598
+ end: { top: reference.top + reference.height - popper.height }
6599
+ },
6600
+ x: {
6601
+ start: { left: reference.left },
6602
+ end: { left: reference.left + reference.width - popper.width }
6603
+ }
6604
+ };
6605
+
6606
+ var axis = ['bottom', 'top'].indexOf(basePlacement) !== -1 ? 'x' : 'y';
6607
+
6608
+ data.offsets.popper = Object.assign(
6609
+ popper,
6610
+ shiftOffsets[axis][shiftVariation]
6611
+ );
6612
+ }
6613
+
6614
+ return data;
6615
+ };
6616
+
6545
6617
  /**
6546
6618
  * Modifier used to make sure the popper does not overflows from it's boundaries
6547
6619
  * @method
6548
6620
  * @memberof Popper.modifiers
6549
6621
  * @argument {Object} data - The data object generated by `update` method
6550
6622
  * @returns {Object} The data object, properly modified
6551
- */
6552
- Popper.prototype.modifiers.preventOverflow = function (data) {
6553
- var order = this._options.preventOverflowOrder;
6554
- var popper = getPopperClientRect(data.offsets.popper);
6555
-
6556
- var check = {
6557
- left: function left() {
6558
- var left = popper.left;
6559
- if (popper.left < data.boundaries.left) {
6560
- left = Math.max(popper.left, data.boundaries.left);
6561
- }
6562
- return { left: left };
6563
- },
6564
- right: function right() {
6565
- var left = popper.left;
6566
- if (popper.right > data.boundaries.right) {
6567
- left = Math.min(popper.left, data.boundaries.right - popper.width);
6568
- }
6569
- return { left: left };
6570
- },
6571
- top: function top() {
6572
- var top = popper.top;
6573
- if (popper.top < data.boundaries.top) {
6574
- top = Math.max(popper.top, data.boundaries.top);
6575
- }
6576
- return { top: top };
6577
- },
6578
- bottom: function bottom() {
6579
- var top = popper.top;
6580
- if (popper.bottom > data.boundaries.bottom) {
6581
- top = Math.min(popper.top, data.boundaries.bottom - popper.height);
6582
- }
6583
- return { top: top };
6584
- }
6585
- };
6586
-
6587
- order.forEach(function (direction) {
6588
- data.offsets.popper = Object.assign(popper, check[direction]());
6589
- });
6590
-
6591
- return data;
6592
- };
6593
-
6623
+ */
6624
+ Popper.prototype.modifiers.preventOverflow = function (data) {
6625
+ var order = this._options.preventOverflowOrder;
6626
+ var popper = getPopperClientRect(data.offsets.popper);
6627
+
6628
+ var check = {
6629
+ left: function () {
6630
+ var left = popper.left;
6631
+ if (popper.left < data.boundaries.left) {
6632
+ left = Math.max(popper.left, data.boundaries.left);
6633
+ }
6634
+ return { left: left };
6635
+ },
6636
+ right: function () {
6637
+ var left = popper.left;
6638
+ if (popper.right > data.boundaries.right) {
6639
+ left = Math.min(popper.left, data.boundaries.right - popper.width);
6640
+ }
6641
+ return { left: left };
6642
+ },
6643
+ top: function () {
6644
+ var top = popper.top;
6645
+ if (popper.top < data.boundaries.top) {
6646
+ top = Math.max(popper.top, data.boundaries.top);
6647
+ }
6648
+ return { top: top };
6649
+ },
6650
+ bottom: function () {
6651
+ var top = popper.top;
6652
+ if (popper.bottom > data.boundaries.bottom) {
6653
+ top = Math.min(popper.top, data.boundaries.bottom - popper.height);
6654
+ }
6655
+ return { top: top };
6656
+ }
6657
+ };
6658
+
6659
+ order.forEach(function (direction) {
6660
+ data.offsets.popper = Object.assign(popper, check[direction]());
6661
+ });
6662
+
6663
+ return data;
6664
+ };
6665
+
6594
6666
  /**
6595
6667
  * Modifier used to make sure the popper is always near its reference
6596
6668
  * @method
6597
6669
  * @memberof Popper.modifiers
6598
6670
  * @argument {Object} data - The data object generated by _update method
6599
6671
  * @returns {Object} The data object, properly modified
6600
- */
6601
- Popper.prototype.modifiers.keepTogether = function (data) {
6602
- var popper = getPopperClientRect(data.offsets.popper);
6603
- var reference = data.offsets.reference;
6604
- var f = Math.floor;
6605
-
6606
- if (popper.right < f(reference.left)) {
6607
- data.offsets.popper.left = f(reference.left) - popper.width;
6608
- }
6609
- if (popper.left > f(reference.right)) {
6610
- data.offsets.popper.left = f(reference.right);
6611
- }
6612
- if (popper.bottom < f(reference.top)) {
6613
- data.offsets.popper.top = f(reference.top) - popper.height;
6614
- }
6615
- if (popper.top > f(reference.bottom)) {
6616
- data.offsets.popper.top = f(reference.bottom);
6617
- }
6618
-
6619
- return data;
6620
- };
6621
-
6672
+ */
6673
+ Popper.prototype.modifiers.keepTogether = function (data) {
6674
+ var popper = getPopperClientRect(data.offsets.popper);
6675
+ var reference = data.offsets.reference;
6676
+ var f = Math.floor;
6677
+
6678
+ if (popper.right < f(reference.left)) {
6679
+ data.offsets.popper.left = f(reference.left) - popper.width;
6680
+ }
6681
+ if (popper.left > f(reference.right)) {
6682
+ data.offsets.popper.left = f(reference.right);
6683
+ }
6684
+ if (popper.bottom < f(reference.top)) {
6685
+ data.offsets.popper.top = f(reference.top) - popper.height;
6686
+ }
6687
+ if (popper.top > f(reference.bottom)) {
6688
+ data.offsets.popper.top = f(reference.bottom);
6689
+ }
6690
+
6691
+ return data;
6692
+ };
6693
+
6622
6694
  /**
6623
6695
  * Modifier used to flip the placement of the popper when the latter is starting overlapping its reference element.
6624
6696
  * Requires the `preventOverflow` modifier before it in order to work.
@@ -6627,61 +6699,81 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
6627
6699
  * @memberof Popper.modifiers
6628
6700
  * @argument {Object} data - The data object generated by _update method
6629
6701
  * @returns {Object} The data object, properly modified
6630
- */
6631
- Popper.prototype.modifiers.flip = function (data) {
6632
- // check if preventOverflow is in the list of modifiers before the flip modifier.
6633
- // otherwise flip would not work as expected.
6634
- if (!this.isModifierRequired(this.modifiers.flip, this.modifiers.preventOverflow)) {
6635
- console.warn('WARNING: preventOverflow modifier is required by flip modifier in order to work, be sure to include it before flip!');
6636
- return data;
6637
- }
6638
-
6639
- if (data.flipped && data.placement === data._originalPlacement) {
6640
- // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
6641
- return data;
6642
- }
6643
-
6644
- var placement = data.placement.split('-')[0];
6645
- var placementOpposite = getOppositePlacement(placement);
6646
- var variation = data.placement.split('-')[1] || '';
6647
-
6648
- var flipOrder = [];
6649
- if (this._options.flipBehavior === 'flip') {
6650
- flipOrder = [placement, placementOpposite];
6651
- } else {
6652
- flipOrder = this._options.flipBehavior;
6653
- }
6654
-
6655
- flipOrder.forEach(function (step, index) {
6656
- if (placement !== step || flipOrder.length === index + 1) {
6657
- return;
6658
- }
6659
-
6660
- placement = data.placement.split('-')[0];
6661
- placementOpposite = getOppositePlacement(placement);
6662
-
6663
- var popperOffsets = getPopperClientRect(data.offsets.popper);
6664
-
6665
- // this boolean is used to distinguish right and bottom from top and left
6666
- // they need different computations to get flipped
6667
- var a = ['right', 'bottom'].indexOf(placement) !== -1;
6668
-
6669
- // using Math.floor because the reference offsets may contain decimals we are not going to consider here
6670
- if (a && Math.floor(data.offsets.reference[placement]) > Math.floor(popperOffsets[placementOpposite]) || !a && Math.floor(data.offsets.reference[placement]) < Math.floor(popperOffsets[placementOpposite])) {
6671
- // we'll use this boolean to detect any flip loop
6672
- data.flipped = true;
6673
- data.placement = flipOrder[index + 1];
6674
- if (variation) {
6675
- data.placement += '-' + variation;
6676
- }
6677
- data.offsets.popper = this._getOffsets(this._popper, this._reference, data.placement).popper;
6678
-
6679
- data = this.runModifiers(data, this._options.modifiers, this._flip);
6680
- }
6681
- }.bind(this));
6682
- return data;
6683
- };
6684
-
6702
+ */
6703
+ Popper.prototype.modifiers.flip = function (data) {
6704
+ // check if preventOverflow is in the list of modifiers before the flip modifier.
6705
+ // otherwise flip would not work as expected.
6706
+ if (
6707
+ !this.isModifierRequired(
6708
+ this.modifiers.flip,
6709
+ this.modifiers.preventOverflow
6710
+ )
6711
+ ) {
6712
+ console.warn(
6713
+ 'WARNING: preventOverflow modifier is required by flip modifier in order to work, be sure to include it before flip!'
6714
+ );
6715
+ return data;
6716
+ }
6717
+
6718
+ if (data.flipped && data.placement === data._originalPlacement) {
6719
+ // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
6720
+ return data;
6721
+ }
6722
+
6723
+ var placement = data.placement.split('-')[0];
6724
+ var placementOpposite = getOppositePlacement(placement);
6725
+ var variation = data.placement.split('-')[1] || '';
6726
+
6727
+ var flipOrder = [];
6728
+ if (this._options.flipBehavior === 'flip') {
6729
+ flipOrder = [placement, placementOpposite];
6730
+ } else {
6731
+ flipOrder = this._options.flipBehavior;
6732
+ }
6733
+
6734
+ flipOrder.forEach(
6735
+ function (step, index) {
6736
+ if (placement !== step || flipOrder.length === index + 1) {
6737
+ return;
6738
+ }
6739
+
6740
+ placement = data.placement.split('-')[0];
6741
+ placementOpposite = getOppositePlacement(placement);
6742
+
6743
+ var popperOffsets = getPopperClientRect(data.offsets.popper);
6744
+
6745
+ // this boolean is used to distinguish right and bottom from top and left
6746
+ // they need different computations to get flipped
6747
+ var a = ['right', 'bottom'].indexOf(placement) !== -1;
6748
+
6749
+ // using Math.floor because the reference offsets may contain decimals we are not going to consider here
6750
+ if (
6751
+ (a &&
6752
+ Math.floor(data.offsets.reference[placement]) >
6753
+ Math.floor(popperOffsets[placementOpposite])) ||
6754
+ (!a &&
6755
+ Math.floor(data.offsets.reference[placement]) <
6756
+ Math.floor(popperOffsets[placementOpposite]))
6757
+ ) {
6758
+ // we'll use this boolean to detect any flip loop
6759
+ data.flipped = true;
6760
+ data.placement = flipOrder[index + 1];
6761
+ if (variation) {
6762
+ data.placement += '-' + variation;
6763
+ }
6764
+ data.offsets.popper = this._getOffsets(
6765
+ this._popper,
6766
+ this._reference,
6767
+ data.placement
6768
+ ).popper;
6769
+
6770
+ data = this.runModifiers(data, this._options.modifiers, this._flip);
6771
+ }
6772
+ }.bind(this)
6773
+ );
6774
+ return data;
6775
+ };
6776
+
6685
6777
  /**
6686
6778
  * Modifier used to add an offset to the popper, useful if you more granularity positioning your popper.
6687
6779
  * The offsets will shift the popper on the side of its reference element.
@@ -6689,23 +6781,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
6689
6781
  * @memberof Popper.modifiers
6690
6782
  * @argument {Object} data - The data object generated by _update method
6691
6783
  * @returns {Object} The data object, properly modified
6692
- */
6693
- Popper.prototype.modifiers.offset = function (data) {
6694
- var offset = this._options.offset;
6695
- var popper = data.offsets.popper;
6696
-
6697
- if (data.placement.indexOf('left') !== -1) {
6698
- popper.top -= offset;
6699
- } else if (data.placement.indexOf('right') !== -1) {
6700
- popper.top += offset;
6701
- } else if (data.placement.indexOf('top') !== -1) {
6702
- popper.left -= offset;
6703
- } else if (data.placement.indexOf('bottom') !== -1) {
6704
- popper.left += offset;
6705
- }
6706
- return data;
6707
- };
6708
-
6784
+ */
6785
+ Popper.prototype.modifiers.offset = function (data) {
6786
+ var offset = this._options.offset;
6787
+ var popper = data.offsets.popper;
6788
+
6789
+ if (data.placement.indexOf('left') !== -1) {
6790
+ popper.top -= offset;
6791
+ } else if (data.placement.indexOf('right') !== -1) {
6792
+ popper.top += offset;
6793
+ } else if (data.placement.indexOf('top') !== -1) {
6794
+ popper.left -= offset;
6795
+ } else if (data.placement.indexOf('bottom') !== -1) {
6796
+ popper.left += offset;
6797
+ }
6798
+ return data;
6799
+ };
6800
+
6709
6801
  /**
6710
6802
  * 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
6711
6803
  * It will use the CSS outer size of the arrow element to know how many pixels of conjuction are needed
@@ -6713,136 +6805,147 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
6713
6805
  * @memberof Popper.modifiers
6714
6806
  * @argument {Object} data - The data object generated by _update method
6715
6807
  * @returns {Object} The data object, properly modified
6716
- */
6717
- Popper.prototype.modifiers.arrow = function (data) {
6718
- var arrow = this._options.arrowElement;
6719
- var arrowOffset = this._options.arrowOffset;
6720
-
6721
- // if the arrowElement is a string, suppose it's a CSS selector
6722
- if (typeof arrow === 'string') {
6723
- arrow = this._popper.querySelector(arrow);
6724
- }
6725
-
6726
- // if arrow element is not found, don't run the modifier
6727
- if (!arrow) {
6728
- return data;
6729
- }
6730
-
6731
- // the arrow element must be child of its popper
6732
- if (!this._popper.contains(arrow)) {
6733
- console.warn('WARNING: `arrowElement` must be child of its popper element!');
6734
- return data;
6735
- }
6736
-
6737
- // arrow depends on keepTogether in order to work
6738
- if (!this.isModifierRequired(this.modifiers.arrow, this.modifiers.keepTogether)) {
6739
- console.warn('WARNING: keepTogether modifier is required by arrow modifier in order to work, be sure to include it before arrow!');
6740
- return data;
6741
- }
6742
-
6743
- var arrowStyle = {};
6744
- var placement = data.placement.split('-')[0];
6745
- var popper = getPopperClientRect(data.offsets.popper);
6746
- var reference = data.offsets.reference;
6747
- var isVertical = ['left', 'right'].indexOf(placement) !== -1;
6748
-
6749
- var len = isVertical ? 'height' : 'width';
6750
- var side = isVertical ? 'top' : 'left';
6751
- var translate = isVertical ? 'translateY' : 'translateX';
6752
- var altSide = isVertical ? 'left' : 'top';
6753
- var opSide = isVertical ? 'bottom' : 'right';
6754
- var arrowSize = getOuterSizes(arrow)[len];
6755
-
6756
- //
6757
- // extends keepTogether behavior making sure the popper and its reference have enough pixels in conjuction
6758
- //
6759
-
6760
- // top/left side
6761
- if (reference[opSide] - arrowSize < popper[side]) {
6762
- data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowSize);
6763
- }
6764
- // bottom/right side
6765
- if (reference[side] + arrowSize > popper[opSide]) {
6766
- data.offsets.popper[side] += reference[side] + arrowSize - popper[opSide];
6767
- }
6768
-
6769
- // compute center of the popper
6770
- var center = reference[side] + (arrowOffset || reference[len] / 2 - arrowSize / 2);
6771
-
6772
- var sideValue = center - popper[side];
6773
-
6774
- // prevent arrow from being placed not contiguously to its popper
6775
- sideValue = Math.max(Math.min(popper[len] - arrowSize - 8, sideValue), 8);
6776
- arrowStyle[side] = sideValue;
6777
- arrowStyle[altSide] = ''; // make sure to remove any old style from the arrow
6778
-
6779
- data.offsets.arrow = arrowStyle;
6780
- data.arrowElement = arrow;
6781
-
6782
- return data;
6783
- };
6784
-
6785
- //
6786
- // Helpers
6787
- //
6788
-
6808
+ */
6809
+ Popper.prototype.modifiers.arrow = function (data) {
6810
+ var arrow = this._options.arrowElement;
6811
+ var arrowOffset = this._options.arrowOffset;
6812
+
6813
+ // if the arrowElement is a string, suppose it's a CSS selector
6814
+ if (typeof arrow === 'string') {
6815
+ arrow = this._popper.querySelector(arrow);
6816
+ }
6817
+
6818
+ // if arrow element is not found, don't run the modifier
6819
+ if (!arrow) {
6820
+ return data;
6821
+ }
6822
+
6823
+ // the arrow element must be child of its popper
6824
+ if (!this._popper.contains(arrow)) {
6825
+ console.warn(
6826
+ 'WARNING: `arrowElement` must be child of its popper element!'
6827
+ );
6828
+ return data;
6829
+ }
6830
+
6831
+ // arrow depends on keepTogether in order to work
6832
+ if (
6833
+ !this.isModifierRequired(
6834
+ this.modifiers.arrow,
6835
+ this.modifiers.keepTogether
6836
+ )
6837
+ ) {
6838
+ console.warn(
6839
+ 'WARNING: keepTogether modifier is required by arrow modifier in order to work, be sure to include it before arrow!'
6840
+ );
6841
+ return data;
6842
+ }
6843
+
6844
+ var arrowStyle = {};
6845
+ var placement = data.placement.split('-')[0];
6846
+ var popper = getPopperClientRect(data.offsets.popper);
6847
+ var reference = data.offsets.reference;
6848
+ var isVertical = ['left', 'right'].indexOf(placement) !== -1;
6849
+
6850
+ var len = isVertical ? 'height' : 'width';
6851
+ var side = isVertical ? 'top' : 'left';
6852
+ var translate = isVertical ? 'translateY' : 'translateX';
6853
+ var altSide = isVertical ? 'left' : 'top';
6854
+ var opSide = isVertical ? 'bottom' : 'right';
6855
+ var arrowSize = getOuterSizes(arrow)[len];
6856
+
6857
+ //
6858
+ // extends keepTogether behavior making sure the popper and its reference have enough pixels in conjuction
6859
+ //
6860
+
6861
+ // top/left side
6862
+ if (reference[opSide] - arrowSize < popper[side]) {
6863
+ data.offsets.popper[side] -=
6864
+ popper[side] - (reference[opSide] - arrowSize);
6865
+ }
6866
+ // bottom/right side
6867
+ if (reference[side] + arrowSize > popper[opSide]) {
6868
+ data.offsets.popper[side] += reference[side] + arrowSize - popper[opSide];
6869
+ }
6870
+
6871
+ // compute center of the popper
6872
+ var center =
6873
+ reference[side] + (arrowOffset || reference[len] / 2 - arrowSize / 2);
6874
+
6875
+ var sideValue = center - popper[side];
6876
+
6877
+ // prevent arrow from being placed not contiguously to its popper
6878
+ sideValue = Math.max(Math.min(popper[len] - arrowSize - 8, sideValue), 8);
6879
+ arrowStyle[side] = sideValue;
6880
+ arrowStyle[altSide] = ''; // make sure to remove any old style from the arrow
6881
+
6882
+ data.offsets.arrow = arrowStyle;
6883
+ data.arrowElement = arrow;
6884
+
6885
+ return data;
6886
+ };
6887
+
6888
+ //
6889
+ // Helpers
6890
+ //
6891
+
6789
6892
  /**
6790
6893
  * Get the outer sizes of the given element (offset size + margins)
6791
6894
  * @function
6792
6895
  * @ignore
6793
6896
  * @argument {Element} element
6794
6897
  * @returns {Object} object containing width and height properties
6795
- */
6796
- function getOuterSizes(element) {
6797
- // NOTE: 1 DOM access here
6798
- var _display = element.style.display,
6799
- _visibility = element.style.visibility;
6800
- element.style.display = 'block';
6801
- element.style.visibility = 'hidden';
6802
- var calcWidthToForceRepaint = element.offsetWidth;
6803
- // original method
6804
- var styles = root.getComputedStyle(element);
6805
- var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
6806
- var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
6807
- var result = {
6808
- width: element.offsetWidth + y,
6809
- height: element.offsetHeight + x
6810
- };
6811
-
6812
- // reset element styles
6813
- element.style.display = _display;
6814
- element.style.visibility = _visibility;
6815
- return result;
6816
- }
6817
-
6898
+ */
6899
+ function getOuterSizes(element) {
6900
+ // NOTE: 1 DOM access here
6901
+ var _display = element.style.display,
6902
+ _visibility = element.style.visibility;
6903
+ element.style.display = 'block';
6904
+ element.style.visibility = 'hidden';
6905
+ var calcWidthToForceRepaint = element.offsetWidth;
6906
+ // original method
6907
+ var styles = getRealWindow(element).getComputedStyle(element);
6908
+ var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
6909
+ var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
6910
+ var result = {
6911
+ width: element.offsetWidth + y,
6912
+ height: element.offsetHeight + x
6913
+ };
6914
+
6915
+ // reset element styles
6916
+ element.style.display = _display;
6917
+ element.style.visibility = _visibility;
6918
+ return result;
6919
+ }
6920
+
6818
6921
  /**
6819
6922
  * Get the opposite placement of the given one/
6820
6923
  * @function
6821
6924
  * @ignore
6822
6925
  * @argument {String} placement
6823
6926
  * @returns {String} flipped placement
6824
- */
6825
- function getOppositePlacement(placement) {
6826
- var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
6827
- return placement.replace(/left|right|bottom|top/g, function (matched) {
6828
- return hash[matched];
6829
- });
6830
- }
6831
-
6927
+ */
6928
+ function getOppositePlacement(placement) {
6929
+ var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
6930
+ return placement.replace(/left|right|bottom|top/g, function (matched) {
6931
+ return hash[matched];
6932
+ });
6933
+ }
6934
+
6832
6935
  /**
6833
6936
  * Given the popper offsets, generate an output similar to getBoundingClientRect
6834
6937
  * @function
6835
6938
  * @ignore
6836
6939
  * @argument {Object} popperOffsets
6837
6940
  * @returns {Object} ClientRect like output
6838
- */
6839
- function getPopperClientRect(popperOffsets) {
6840
- var offsets = Object.assign({}, popperOffsets);
6841
- offsets.right = offsets.left + offsets.width;
6842
- offsets.bottom = offsets.top + offsets.height;
6843
- return offsets;
6844
- }
6845
-
6941
+ */
6942
+ function getPopperClientRect(popperOffsets) {
6943
+ var offsets = Object.assign({}, popperOffsets);
6944
+ offsets.right = offsets.left + offsets.width;
6945
+ offsets.bottom = offsets.top + offsets.height;
6946
+ return offsets;
6947
+ }
6948
+
6846
6949
  /**
6847
6950
  * Given an array and the key to find, returns its index
6848
6951
  * @function
@@ -6850,76 +6953,155 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
6850
6953
  * @argument {Array} arr
6851
6954
  * @argument keyToFind
6852
6955
  * @returns index or null
6853
- */
6854
- function getArrayKeyIndex(arr, keyToFind) {
6855
- var i = 0,
6856
- key;
6857
- for (key in arr) {
6858
- if (arr[key] === keyToFind) {
6859
- return i;
6860
- }
6861
- i++;
6862
- }
6863
- return null;
6864
- }
6865
-
6956
+ */
6957
+ function getArrayKeyIndex(arr, keyToFind) {
6958
+ var i = 0,
6959
+ key;
6960
+ for (key in arr) {
6961
+ if (arr[key] === keyToFind) {
6962
+ return i;
6963
+ }
6964
+ i++;
6965
+ }
6966
+ return null;
6967
+ }
6968
+
6866
6969
  /**
6867
6970
  * Get CSS computed property of the given element
6868
6971
  * @function
6869
6972
  * @ignore
6870
6973
  * @argument {Eement} element
6871
6974
  * @argument {String} property
6872
- */
6873
- function getStyleComputedProperty(element, property) {
6874
- // NOTE: 1 DOM access here
6875
- var css = root.getComputedStyle(element, null);
6876
- return css[property];
6877
- }
6975
+ */
6976
+ function getStyleComputedProperty(element, property) {
6977
+ // NOTE: 1 DOM access here
6978
+ // 无界等微前端场景下沙箱 window 与元素实际渲染所在 window 可能不一致,
6979
+ // 需使用元素自身的 view 读取计算样式,避免跨 document 读取到空值
6980
+ var css = getRealWindow(element).getComputedStyle(element, null);
6981
+ return css[property];
6982
+ }
6983
+
6878
6984
  /**
6879
6985
  * Returns the offset parent of the given element
6880
6986
  * @function
6881
6987
  * @ignore
6882
6988
  * @argument {Element} element
6883
6989
  * @returns {Element} offset parent
6884
- */
6885
- function getOffsetParent(element) {
6886
- var offsetParent = element.offsetParent;
6887
- return offsetParent === root.document.body || !offsetParent ? root.document.documentElement : offsetParent;
6888
- }
6889
-
6990
+ */
6991
+ function getOffsetParent(element) {
6992
+ var offsetParent = element.offsetParent;
6993
+ return offsetParent === root.document.body || !offsetParent
6994
+ ? root.document.documentElement
6995
+ : offsetParent;
6996
+ }
6997
+
6998
+ /**
6999
+ * Returns the window the given element actually renders in.
7000
+ * 无界等微前端场景下组件代码运行在沙箱 window 中,而 DOM 实际渲染在
7001
+ * 主应用的 window(shadowRoot 内),滚动量、视口尺寸等必须取自元素自身的 view
7002
+ * @function
7003
+ * @ignore
7004
+ * @argument {Element} element
7005
+ * @returns {Window} window
7006
+ */
7007
+ function getRealWindow(element) {
7008
+ return (
7009
+ (element &&
7010
+ element.ownerDocument &&
7011
+ element.ownerDocument.defaultView) ||
7012
+ root
7013
+ );
7014
+ }
7015
+
7016
+ /**
7017
+ * Returns the viewport rect of the containing block actually used to position the popper.
7018
+ * 无界微前端等场景下 popper 被挂载进子应用的 shadowRoot,offsetParent 的兜底值
7019
+ * (documentElement)与浏览器真实的包含块不再重合,导致下拉框/提示框整体偏移
7020
+ * (偏移量恰为子应用容器在主应用中的位置),因此需要沿 composed tree 查找:
7021
+ * - fixed 定位:包含块为视口;
7022
+ * - absolute 定位:最近的 positioned 祖先元素(跨 shadowRoot 边界查找);
7023
+ * - 无 positioned 祖先:初始包含块,其视口原点为真实 window 滚动量的负值。
7024
+ * @function
7025
+ * @ignore
7026
+ * @argument {Element} element - popper element
7027
+ * @argument {Boolean} fixed - whether the popper is fixed positioned
7028
+ * @returns {Object} rect
7029
+ */
7030
+ function getContainingBlockRect(element, fixed) {
7031
+ if (fixed) {
7032
+ return { top: 0, left: 0, right: 0, bottom: 0 };
7033
+ }
7034
+
7035
+ var node = element.parentNode;
7036
+ while (node) {
7037
+ if (node.nodeType === 1) {
7038
+ if (getStyleComputedProperty(node, 'position') !== 'static') {
7039
+ return getBoundingClientRect(node);
7040
+ }
7041
+ } else if (node.nodeType === 11) {
7042
+ // 遇到 shadowRoot,跨边界从宿主元素继续向上查找
7043
+ node = node.host;
7044
+ continue;
7045
+ } else {
7046
+ break;
7047
+ }
7048
+ node = node.parentNode;
7049
+ }
7050
+
7051
+ var win = getRealWindow(element);
7052
+ return {
7053
+ top: -(win.pageYOffset || 0),
7054
+ left: -(win.pageXOffset || 0),
7055
+ right: 0,
7056
+ bottom: 0
7057
+ };
7058
+ }
7059
+
6890
7060
  /**
6891
7061
  * Returns the scrolling parent of the given element
6892
7062
  * @function
6893
7063
  * @ignore
6894
7064
  * @argument {Element} element
6895
7065
  * @returns {Element} offset parent
6896
- */
6897
- function getScrollParent(element) {
6898
- var parent = element.parentNode;
6899
- if (!parent || parent.nodeType !== 1) {
6900
- return element;
6901
- }
6902
-
6903
- if (parent === root.document) {
6904
- // Firefox puts the scrollTOp value on `documentElement` instead of `body`, we then check which of them is
6905
- // greater than 0 and return the proper element
6906
- if (root.document.body.scrollTop || root.document.body.scrollLeft) {
6907
- return root.document.body;
6908
- } else {
6909
- return root.document.documentElement;
6910
- }
6911
- }
6912
-
6913
- // Firefox want us to check `-x` and `-y` variations as well
6914
- if (['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow')) !== -1 || ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-x')) !== -1 || ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-y')) !== -1) {
6915
- // If the detected scrollParent is body, we perform an additional check on its parentNode
6916
- // in this way we'll get body if the browser is Chrome-ish, or documentElement otherwise
6917
- // fixes issue #65
6918
- return parent;
6919
- }
6920
- return getScrollParent(element.parentNode);
6921
- }
6922
-
7066
+ */
7067
+ function getScrollParent(element) {
7068
+ var parent = element.parentNode;
7069
+ if (!parent) {
7070
+ return element;
7071
+ }
7072
+
7073
+ if (parent.nodeType === 11) {
7074
+ // 无界等微前端场景 DOM 位于 shadowRoot 内,需跨边界从宿主元素继续向上查找,
7075
+ // 否则查找到 shadowRoot 即终止,滚动事件无法被监听
7076
+ return getScrollParent(parent.host);
7077
+ }
7078
+
7079
+ if (parent.nodeType !== 1) {
7080
+ // 到达 document,返回元素实际渲染所在的真实 window,
7081
+ // 保证 window 滚动时能触发位置更新
7082
+ return getRealWindow(element);
7083
+ }
7084
+
7085
+ // Firefox want us to check `-x` and `-y` variations as well
7086
+ if (
7087
+ ['scroll', 'auto'].indexOf(
7088
+ getStyleComputedProperty(parent, 'overflow')
7089
+ ) !== -1 ||
7090
+ ['scroll', 'auto'].indexOf(
7091
+ getStyleComputedProperty(parent, 'overflow-x')
7092
+ ) !== -1 ||
7093
+ ['scroll', 'auto'].indexOf(
7094
+ getStyleComputedProperty(parent, 'overflow-y')
7095
+ ) !== -1
7096
+ ) {
7097
+ // If the detected scrollParent is body, we perform an additional check on its parentNode
7098
+ // in this way we'll get body if the browser is Chrome-ish, or documentElement otherwise
7099
+ // fixes issue #65
7100
+ return parent;
7101
+ }
7102
+ return getScrollParent(parent);
7103
+ }
7104
+
6923
7105
  /**
6924
7106
  * Check if the given element is fixed or is inside a fixed parent
6925
7107
  * @function
@@ -6927,109 +7109,125 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
6927
7109
  * @argument {Element} element
6928
7110
  * @argument {Element} customContainer
6929
7111
  * @returns {Boolean} answer to "isFixed?"
6930
- */
6931
- function isFixed(element) {
6932
- if (element === root.document.body) {
6933
- return false;
6934
- }
6935
- if (getStyleComputedProperty(element, 'position') === 'fixed') {
6936
- return true;
6937
- }
6938
- return element.parentNode && element.parentNode.nodeType === 1 ? isFixed(element.parentNode) : element;
6939
- }
6940
-
7112
+ */
7113
+ function isFixed(element) {
7114
+ if (element === root.document.body) {
7115
+ return false;
7116
+ }
7117
+ if (getStyleComputedProperty(element, 'position') === 'fixed') {
7118
+ return true;
7119
+ }
7120
+ var parent = element.parentNode;
7121
+ if (parent && parent.nodeType === 11) {
7122
+ // 跨 shadowRoot 边界,从宿主元素继续向上判断
7123
+ parent = parent.host;
7124
+ }
7125
+ return parent && parent.nodeType === 1 ? isFixed(parent) : false;
7126
+ }
7127
+
6941
7128
  /**
6942
7129
  * Set the style to the given popper
6943
7130
  * @function
6944
7131
  * @ignore
6945
7132
  * @argument {Element} element - Element to apply the style to
6946
7133
  * @argument {Object} styles - Object with a list of properties and values which will be applied to the element
6947
- */
6948
- function setStyle(element, styles) {
6949
- function is_numeric(n) {
6950
- return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
6951
- }
6952
- Object.keys(styles).forEach(function (prop) {
6953
- var unit = '';
6954
- // add unit if the value is numeric and is one of the following
6955
- if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && is_numeric(styles[prop])) {
6956
- unit = 'px';
6957
- }
6958
- element.style[prop] = styles[prop] + unit;
6959
- });
6960
- }
6961
-
7134
+ */
7135
+ function setStyle(element, styles) {
7136
+ function is_numeric(n) {
7137
+ return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
7138
+ }
7139
+ Object.keys(styles).forEach(function (prop) {
7140
+ var unit = '';
7141
+ // add unit if the value is numeric and is one of the following
7142
+ if (
7143
+ ['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !==
7144
+ -1 &&
7145
+ is_numeric(styles[prop])
7146
+ ) {
7147
+ unit = 'px';
7148
+ }
7149
+ element.style[prop] = styles[prop] + unit;
7150
+ });
7151
+ }
7152
+
6962
7153
  /**
6963
7154
  * Check if the given variable is a function
6964
7155
  * @function
6965
7156
  * @ignore
6966
7157
  * @argument {*} functionToCheck - variable to check
6967
7158
  * @returns {Boolean} answer to: is a function?
6968
- */
6969
- function isFunction(functionToCheck) {
6970
- var getType = {};
6971
- return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
6972
- }
6973
-
7159
+ */
7160
+ function isFunction(functionToCheck) {
7161
+ var getType = {};
7162
+ return (
7163
+ functionToCheck &&
7164
+ getType.toString.call(functionToCheck) === '[object Function]'
7165
+ );
7166
+ }
7167
+
6974
7168
  /**
6975
7169
  * Get the position of the given element, relative to its offset parent
6976
7170
  * @function
6977
7171
  * @ignore
6978
7172
  * @param {Element} element
6979
7173
  * @return {Object} position - Coordinates of the element and its `scrollTop`
6980
- */
6981
- function getOffsetRect(element) {
6982
- var transform = getStyle(element, 'transform').replace(/[^0-9\-,]/g, '').split(',');
6983
- var elementRect = {
6984
- width: element.offsetWidth,
6985
- height: element.offsetHeight,
6986
- left: element.offsetLeft + (transform[4] ? parseInt(transform[4], 10) : 0),
6987
- top: element.offsetTop + (transform[5] ? parseInt(transform[5], 10) : 0)
6988
- };
6989
-
6990
- elementRect.right = elementRect.left + elementRect.width;
6991
- elementRect.bottom = elementRect.top + elementRect.height;
6992
-
6993
- // position
6994
- return elementRect;
6995
- }
6996
-
7174
+ */
7175
+ function getOffsetRect(element) {
7176
+ var transform = getStyle(element, 'transform')
7177
+ .replace(/[^0-9\-,]/g, '')
7178
+ .split(',');
7179
+ var elementRect = {
7180
+ width: element.offsetWidth,
7181
+ height: element.offsetHeight,
7182
+ left:
7183
+ element.offsetLeft + (transform[4] ? parseInt(transform[4], 10) : 0),
7184
+ top: element.offsetTop + (transform[5] ? parseInt(transform[5], 10) : 0)
7185
+ };
7186
+
7187
+ elementRect.right = elementRect.left + elementRect.width;
7188
+ elementRect.bottom = elementRect.top + elementRect.height;
7189
+
7190
+ // position
7191
+ return elementRect;
7192
+ }
7193
+
6997
7194
  /**
6998
7195
  * Get bounding client rect of given element
6999
7196
  * @function
7000
7197
  * @ignore
7001
7198
  * @param {HTMLElement} element
7002
7199
  * @return {Object} client rect
7003
- */
7004
- function getBoundingClientRect(element) {
7005
- var rect = element.getBoundingClientRect();
7006
-
7007
- // whether the IE version is lower than 11
7008
- var isIE = /MSIE|Trident/.test(navigator.userAgent);
7009
-
7010
- // fix ie document bounding top always 0 bug
7011
- var rectTop = isIE && element.tagName === 'HTML' ? -element.scrollTop : rect.top;
7012
-
7013
- return {
7014
- left: rect.left,
7015
- top: rectTop,
7016
- right: rect.right,
7017
- bottom: rect.bottom,
7018
- width: rect.right - rect.left,
7019
- height: rect.bottom - rectTop
7020
- };
7021
- }
7022
-
7023
- function getStyle(dom, attr) {
7024
- if (dom.style[attr]) {
7025
- return dom.style[attr];
7026
- }
7027
- if (window.getComputedStyle) {
7028
- return getComputedStyle(dom, null)[attr];
7029
- }
7030
- return dom.currentStyle[attr];
7031
- }
7032
-
7200
+ */
7201
+ function getBoundingClientRect(element) {
7202
+ var rect = element.getBoundingClientRect();
7203
+
7204
+ // whether the IE version is lower than 11
7205
+ var isIE = /MSIE|Trident/.test(navigator.userAgent);
7206
+
7207
+ // fix ie document bounding top always 0 bug
7208
+ var rectTop =
7209
+ isIE && element.tagName === 'HTML' ? -element.scrollTop : rect.top;
7210
+
7211
+ return {
7212
+ left: rect.left,
7213
+ top: rectTop,
7214
+ right: rect.right,
7215
+ bottom: rect.bottom,
7216
+ width: rect.right - rect.left,
7217
+ height: rect.bottom - rectTop
7218
+ };
7219
+ }
7220
+
7221
+ function getStyle(dom, attr) {
7222
+ if (dom.style[attr]) {
7223
+ return dom.style[attr];
7224
+ }
7225
+ if (window.getComputedStyle) {
7226
+ return getComputedStyle(dom, null)[attr];
7227
+ }
7228
+ return dom.currentStyle[attr];
7229
+ }
7230
+
7033
7231
  /**
7034
7232
  * Given an element and one of its parents, return the offset
7035
7233
  * @function
@@ -7037,49 +7235,45 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
7037
7235
  * @param {HTMLElement} element
7038
7236
  * @param {HTMLElement} parent
7039
7237
  * @return {Object} rect
7040
- */
7041
- function getOffsetRectRelativeToCustomParent(element, parent, fixed) {
7042
- var elementRect = getBoundingClientRect(element);
7043
- var parentRect = getBoundingClientRect(parent);
7044
-
7045
- if (fixed) {
7046
- var scrollParent = getScrollParent(parent);
7047
- parentRect.top += scrollParent.scrollTop;
7048
- parentRect.bottom += scrollParent.scrollTop;
7049
- parentRect.left += scrollParent.scrollLeft;
7050
- parentRect.right += scrollParent.scrollLeft;
7051
- }
7052
-
7053
- var rect = {
7054
- top: elementRect.top - parentRect.top,
7055
- left: elementRect.left - parentRect.left,
7056
- bottom: elementRect.top - parentRect.top + elementRect.height,
7057
- right: elementRect.left - parentRect.left + elementRect.width,
7058
- width: elementRect.width,
7059
- height: elementRect.height
7060
- };
7061
- return rect;
7062
- }
7063
-
7238
+ */
7239
+ function getOffsetRectRelativeToCustomParent(element, parent, fixed) {
7240
+ var elementRect = getBoundingClientRect(element);
7241
+ // parent 为 popper 元素:取其真实包含块的视口 rect,
7242
+ // 避免无界 shadowRoot 等场景下包含块假设错误导致的整体偏移
7243
+ var parentRect = getContainingBlockRect(parent, fixed);
7244
+
7245
+ var rect = {
7246
+ top: elementRect.top - parentRect.top,
7247
+ left: elementRect.left - parentRect.left,
7248
+ bottom: elementRect.top - parentRect.top + elementRect.height,
7249
+ right: elementRect.left - parentRect.left + elementRect.width,
7250
+ width: elementRect.width,
7251
+ height: elementRect.height
7252
+ };
7253
+ return rect;
7254
+ }
7255
+
7064
7256
  /**
7065
7257
  * Get the prefixed supported property name
7066
7258
  * @function
7067
7259
  * @ignore
7068
7260
  * @argument {String} property (camelCase)
7069
7261
  * @returns {String} prefixed property (camelCase)
7070
- */
7071
- function getSupportedPropertyName(property) {
7072
- var prefixes = ['', 'ms', 'webkit', 'moz', 'o'];
7073
-
7074
- for (var i = 0; i < prefixes.length; i++) {
7075
- var toCheck = prefixes[i] ? prefixes[i] + property.charAt(0).toUpperCase() + property.slice(1) : property;
7076
- if (typeof root.document.body.style[toCheck] !== 'undefined') {
7077
- return toCheck;
7078
- }
7079
- }
7080
- return null;
7081
- }
7082
-
7262
+ */
7263
+ function getSupportedPropertyName(property) {
7264
+ var prefixes = ['', 'ms', 'webkit', 'moz', 'o'];
7265
+
7266
+ for (var i = 0; i < prefixes.length; i++) {
7267
+ var toCheck = prefixes[i]
7268
+ ? prefixes[i] + property.charAt(0).toUpperCase() + property.slice(1)
7269
+ : property;
7270
+ if (typeof root.document.body.style[toCheck] !== 'undefined') {
7271
+ return toCheck;
7272
+ }
7273
+ }
7274
+ return null;
7275
+ }
7276
+
7083
7277
  /**
7084
7278
  * The Object.assign() method is used to copy the values of all enumerable own properties from one or more source
7085
7279
  * objects to a target object. It will return the target object.
@@ -7087,41 +7281,46 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
7087
7281
  * Source: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
7088
7282
  * @function
7089
7283
  * @ignore
7090
- */
7091
- if (!Object.assign) {
7092
- Object.defineProperty(Object, 'assign', {
7093
- enumerable: false,
7094
- configurable: true,
7095
- writable: true,
7096
- value: function value(target) {
7097
- if (target === undefined || target === null) {
7098
- throw new TypeError('Cannot convert first argument to object');
7099
- }
7100
-
7101
- var to = Object(target);
7102
- for (var i = 1; i < arguments.length; i++) {
7103
- var nextSource = arguments[i];
7104
- if (nextSource === undefined || nextSource === null) {
7105
- continue;
7106
- }
7107
- nextSource = Object(nextSource);
7108
-
7109
- var keysArray = Object.keys(nextSource);
7110
- for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
7111
- var nextKey = keysArray[nextIndex];
7112
- var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
7113
- if (desc !== undefined && desc.enumerable) {
7114
- to[nextKey] = nextSource[nextKey];
7115
- }
7116
- }
7117
- }
7118
- return to;
7119
- }
7120
- });
7121
- }
7284
+ */
7285
+ if (!Object.assign) {
7286
+ Object.defineProperty(Object, 'assign', {
7287
+ enumerable: false,
7288
+ configurable: true,
7289
+ writable: true,
7290
+ value: function (target) {
7291
+ if (target === undefined || target === null) {
7292
+ throw new TypeError('Cannot convert first argument to object');
7293
+ }
7294
+
7295
+ var to = Object(target);
7296
+ for (var i = 1; i < arguments.length; i++) {
7297
+ var nextSource = arguments[i];
7298
+ if (nextSource === undefined || nextSource === null) {
7299
+ continue;
7300
+ }
7301
+ nextSource = Object(nextSource);
7302
+
7303
+ var keysArray = Object.keys(nextSource);
7304
+ for (
7305
+ var nextIndex = 0, len = keysArray.length;
7306
+ nextIndex < len;
7307
+ nextIndex++
7308
+ ) {
7309
+ var nextKey = keysArray[nextIndex];
7310
+ var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
7311
+ if (desc !== undefined && desc.enumerable) {
7312
+ to[nextKey] = nextSource[nextKey];
7313
+ }
7314
+ }
7315
+ }
7316
+ return to;
7317
+ }
7318
+ });
7319
+ }
7320
+
7321
+ return Popper;
7322
+ });
7122
7323
 
7123
- return Popper;
7124
- });
7125
7324
 
7126
7325
  /***/ }),
7127
7326
 
@@ -7175,736 +7374,759 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
7175
7374
  /* unused harmony export getSecond */
7176
7375
  /* unused harmony export getWeekday */
7177
7376
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
7178
-
7179
-
7377
+ /* Modified from https://github.com/taylorhakes/fecha
7378
+ *
7379
+ * The MIT License (MIT)
7380
+ *
7381
+ * Copyright (c) 2015 Taylor Hakes
7382
+ *
7383
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7384
+ * of this software and associated documentation files (the "Software"), to deal
7385
+ * in the Software without restriction, including without limitation the rights
7386
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7387
+ * copies of the Software, and to permit persons to whom the Software is
7388
+ * furnished to do so, subject to the following conditions:
7389
+ *
7390
+ * The above copyright notice and this permission notice shall be included in all
7391
+ * copies or substantial portions of the Software.
7392
+ *
7393
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
7394
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7395
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
7396
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
7397
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
7398
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
7399
+ * SOFTWARE.
7400
+ */
7401
+
7402
+ /*eslint-disable*/
7403
+ // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
7404
+
7405
+
7180
7406
  /**
7181
7407
  * Parse or format dates
7182
7408
  * @class fecha
7183
- */
7184
- var fecha = {};
7185
- var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
7186
- var twoDigits = '\\d\\d?';
7187
- var threeDigits = '\\d{3}';
7188
- var fourDigits = '\\d{4}';
7189
- var word = '[^\\s]+';
7190
- var literal = /\[([^]*?)\]/gm;
7191
- var noop = function noop() {};
7192
-
7193
- function regexEscape(str) {
7194
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
7195
- }
7196
-
7197
- function shorten(arr, sLen) {
7198
- var newArr = [];
7199
- for (var i = 0, len = arr.length; i < len; i++) {
7200
- newArr.push(arr[i].substr(0, sLen));
7201
- }
7202
- return newArr;
7203
- }
7204
-
7205
- function monthUpdate() {
7206
- return function (d, v) {
7207
- var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
7208
- if (~index) {
7209
- d.month = index;
7210
- }
7211
- };
7212
- }
7213
-
7214
- function pad(val, len) {
7215
- val = String(val);
7216
- len = len || 2;
7217
- while (val.length < len) {
7218
- val = '0' + val;
7219
- }
7220
- return val;
7221
- }
7222
-
7223
- // 直接使用中文日期名称常量
7224
- var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
7225
- var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
7226
- var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
7227
- var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
7228
- var amPm = ['上午', '下午'];
7229
- var DoFn = function DoFn(D) {
7230
- return D + '日';
7231
- };
7232
-
7233
- var formatFlags = {
7234
- D: function D(dateObj) {
7235
- return dateObj.getDay();
7236
- },
7237
- DD: function DD(dateObj) {
7238
- return pad(dateObj.getDay());
7239
- },
7240
- Do: function Do(dateObj) {
7241
- return DoFn(dateObj.getDate());
7242
- },
7243
- d: function d(dateObj) {
7244
- return dateObj.getDate();
7245
- },
7246
- dd: function dd(dateObj) {
7247
- return pad(dateObj.getDate());
7248
- },
7249
- ddd: function ddd(dateObj) {
7250
- return dayNamesShort[dateObj.getDay()];
7251
- },
7252
- dddd: function dddd(dateObj) {
7253
- return dayNames[dateObj.getDay()];
7254
- },
7255
- M: function M(dateObj) {
7256
- return dateObj.getMonth() + 1;
7257
- },
7258
- MM: function MM(dateObj) {
7259
- return pad(dateObj.getMonth() + 1);
7260
- },
7261
- MMM: function MMM(dateObj) {
7262
- return monthNamesShort[dateObj.getMonth()];
7263
- },
7264
- MMMM: function MMMM(dateObj) {
7265
- return monthNames[dateObj.getMonth()];
7266
- },
7267
- yy: function yy(dateObj) {
7268
- return pad(String(dateObj.getFullYear()), 4).substr(2);
7269
- },
7270
- yyyy: function yyyy(dateObj) {
7271
- return pad(dateObj.getFullYear(), 4);
7272
- },
7273
- h: function h(dateObj) {
7274
- return dateObj.getHours() % 12 || 12;
7275
- },
7276
- hh: function hh(dateObj) {
7277
- return pad(dateObj.getHours() % 12 || 12);
7278
- },
7279
- H: function H(dateObj) {
7280
- return dateObj.getHours();
7281
- },
7282
- HH: function HH(dateObj) {
7283
- return pad(dateObj.getHours());
7284
- },
7285
- m: function m(dateObj) {
7286
- return dateObj.getMinutes();
7287
- },
7288
- mm: function mm(dateObj) {
7289
- return pad(dateObj.getMinutes());
7290
- },
7291
- s: function s(dateObj) {
7292
- return dateObj.getSeconds();
7293
- },
7294
- ss: function ss(dateObj) {
7295
- return pad(dateObj.getSeconds());
7296
- },
7297
- S: function S(dateObj) {
7298
- return Math.round(dateObj.getMilliseconds() / 100);
7299
- },
7300
- SS: function SS(dateObj) {
7301
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
7302
- },
7303
- SSS: function SSS(dateObj) {
7304
- return pad(dateObj.getMilliseconds(), 3);
7305
- },
7306
- a: function a(dateObj) {
7307
- return dateObj.getHours() < 12 ? '上午' : '下午';
7308
- },
7309
- A: function A(dateObj) {
7310
- return dateObj.getHours() < 12 ? '上午' : '下午';
7311
- },
7312
- ZZ: function ZZ(dateObj) {
7313
- var o = dateObj.getTimezoneOffset();
7314
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
7315
- }
7316
- };
7317
-
7318
- var parseFlags = {
7319
- d: [twoDigits, function (d, v) {
7320
- d.day = v;
7321
- }],
7322
- Do: [twoDigits + word, function (d, v) {
7323
- d.day = parseInt(v, 10);
7324
- }],
7325
- M: [twoDigits, function (d, v) {
7326
- d.month = v - 1;
7327
- }],
7328
- yy: [twoDigits, function (d, v) {
7329
- var da = new Date(),
7330
- cent = +('' + da.getFullYear()).substr(0, 2);
7331
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
7332
- }],
7333
- h: [twoDigits, function (d, v) {
7334
- d.hour = v;
7335
- }],
7336
- m: [twoDigits, function (d, v) {
7337
- d.minute = v;
7338
- }],
7339
- s: [twoDigits, function (d, v) {
7340
- d.second = v;
7341
- }],
7342
- yyyy: [fourDigits, function (d, v) {
7343
- d.year = v;
7344
- }],
7345
- S: ['\\d', function (d, v) {
7346
- d.millisecond = v * 100;
7347
- }],
7348
- SS: ['\\d{2}', function (d, v) {
7349
- d.millisecond = v * 10;
7350
- }],
7351
- SSS: [threeDigits, function (d, v) {
7352
- d.millisecond = v;
7353
- }],
7354
- D: [twoDigits, noop],
7355
- ddd: [word, noop],
7356
- MMM: [word, monthUpdate('monthNamesShort')],
7357
- MMMM: [word, monthUpdate('monthNames')],
7358
- a: [word, function (d, v) {
7359
- var val = v.toLowerCase();
7360
- if (val === '上午') {
7361
- d.isPm = false;
7362
- } else if (val === '下午') {
7363
- d.isPm = true;
7364
- }
7365
- }],
7366
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
7367
- var parts = (v + '').match(/([+-]|\d\d)/gi),
7368
- minutes = void 0;
7369
-
7370
- if (parts) {
7371
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
7372
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
7373
- }
7374
- }]
7375
- };
7376
- parseFlags.dd = parseFlags.d;
7377
- parseFlags.dddd = parseFlags.ddd;
7378
- parseFlags.DD = parseFlags.D;
7379
- parseFlags.mm = parseFlags.m;
7380
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
7381
- parseFlags.MM = parseFlags.M;
7382
- parseFlags.ss = parseFlags.s;
7383
- parseFlags.A = parseFlags.a;
7384
-
7385
- // Some common format strings
7386
- fecha.masks = {
7387
- default: 'ddd MMM dd yyyy HH:mm:ss',
7388
- shortDate: 'M/D/yy',
7389
- mediumDate: 'MMM d, yyyy',
7390
- longDate: 'MMMM d, yyyy',
7391
- fullDate: 'dddd, MMMM d, yyyy',
7392
- shortTime: 'HH:mm',
7393
- mediumTime: 'HH:mm:ss',
7394
- longTime: 'HH:mm:ss.SSS'
7395
- };
7396
-
7409
+ */
7410
+ const fecha = {};
7411
+ const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
7412
+ const twoDigits = '\\d\\d?';
7413
+ const threeDigits = '\\d{3}';
7414
+ const fourDigits = '\\d{4}';
7415
+ const word = '[^\\s]+';
7416
+ const literal = /\[([^]*?)\]/gm;
7417
+ const noop = function () {};
7418
+
7419
+ function regexEscape(str) {
7420
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
7421
+ }
7422
+
7423
+ function shorten(arr, sLen) {
7424
+ const newArr = [];
7425
+ for (let i = 0, len = arr.length; i < len; i++) {
7426
+ newArr.push(arr[i].substr(0, sLen));
7427
+ }
7428
+ return newArr;
7429
+ }
7430
+
7431
+ function monthUpdate() {
7432
+ return function (d, v) {
7433
+ const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
7434
+ if (~index) {
7435
+ d.month = index;
7436
+ }
7437
+ };
7438
+ }
7439
+
7440
+ function pad(val, len) {
7441
+ val = String(val);
7442
+ len = len || 2;
7443
+ while (val.length < len) {
7444
+ val = '0' + val;
7445
+ }
7446
+ return val;
7447
+ }
7448
+
7449
+ // 直接使用中文日期名称常量
7450
+ const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
7451
+ const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
7452
+ const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
7453
+ const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
7454
+ const amPm = ['上午', '下午'];
7455
+ const DoFn = function DoFn(D) {
7456
+ return D + '日';
7457
+ };
7458
+
7459
+ const formatFlags = {
7460
+ D: function(dateObj) {
7461
+ return dateObj.getDay();
7462
+ },
7463
+ DD: function(dateObj) {
7464
+ return pad(dateObj.getDay());
7465
+ },
7466
+ Do: function(dateObj) {
7467
+ return DoFn(dateObj.getDate());
7468
+ },
7469
+ d: function(dateObj) {
7470
+ return dateObj.getDate();
7471
+ },
7472
+ dd: function(dateObj) {
7473
+ return pad(dateObj.getDate());
7474
+ },
7475
+ ddd: function(dateObj) {
7476
+ return dayNamesShort[dateObj.getDay()];
7477
+ },
7478
+ dddd: function(dateObj) {
7479
+ return dayNames[dateObj.getDay()];
7480
+ },
7481
+ M: function(dateObj) {
7482
+ return dateObj.getMonth() + 1;
7483
+ },
7484
+ MM: function(dateObj) {
7485
+ return pad(dateObj.getMonth() + 1);
7486
+ },
7487
+ MMM: function(dateObj) {
7488
+ return monthNamesShort[dateObj.getMonth()];
7489
+ },
7490
+ MMMM: function(dateObj) {
7491
+ return monthNames[dateObj.getMonth()];
7492
+ },
7493
+ yy: function(dateObj) {
7494
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
7495
+ },
7496
+ yyyy: function(dateObj) {
7497
+ return pad(dateObj.getFullYear(), 4);
7498
+ },
7499
+ h: function(dateObj) {
7500
+ return dateObj.getHours() % 12 || 12;
7501
+ },
7502
+ hh: function(dateObj) {
7503
+ return pad(dateObj.getHours() % 12 || 12);
7504
+ },
7505
+ H: function(dateObj) {
7506
+ return dateObj.getHours();
7507
+ },
7508
+ HH: function(dateObj) {
7509
+ return pad(dateObj.getHours());
7510
+ },
7511
+ m: function(dateObj) {
7512
+ return dateObj.getMinutes();
7513
+ },
7514
+ mm: function(dateObj) {
7515
+ return pad(dateObj.getMinutes());
7516
+ },
7517
+ s: function(dateObj) {
7518
+ return dateObj.getSeconds();
7519
+ },
7520
+ ss: function(dateObj) {
7521
+ return pad(dateObj.getSeconds());
7522
+ },
7523
+ S: function(dateObj) {
7524
+ return Math.round(dateObj.getMilliseconds() / 100);
7525
+ },
7526
+ SS: function(dateObj) {
7527
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
7528
+ },
7529
+ SSS: function(dateObj) {
7530
+ return pad(dateObj.getMilliseconds(), 3);
7531
+ },
7532
+ a: function(dateObj) {
7533
+ return dateObj.getHours() < 12 ? '上午' : '下午';
7534
+ },
7535
+ A: function(dateObj) {
7536
+ return dateObj.getHours() < 12 ? '上午' : '下午';
7537
+ },
7538
+ ZZ: function(dateObj) {
7539
+ const o = dateObj.getTimezoneOffset();
7540
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
7541
+ }
7542
+ };
7543
+
7544
+ const parseFlags = {
7545
+ d: [twoDigits, function (d, v) {
7546
+ d.day = v;
7547
+ }],
7548
+ Do: [twoDigits + word, function (d, v) {
7549
+ d.day = parseInt(v, 10);
7550
+ }],
7551
+ M: [twoDigits, function (d, v) {
7552
+ d.month = v - 1;
7553
+ }],
7554
+ yy: [twoDigits, function (d, v) {
7555
+ const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
7556
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
7557
+ }],
7558
+ h: [twoDigits, function (d, v) {
7559
+ d.hour = v;
7560
+ }],
7561
+ m: [twoDigits, function (d, v) {
7562
+ d.minute = v;
7563
+ }],
7564
+ s: [twoDigits, function (d, v) {
7565
+ d.second = v;
7566
+ }],
7567
+ yyyy: [fourDigits, function (d, v) {
7568
+ d.year = v;
7569
+ }],
7570
+ S: ['\\d', function (d, v) {
7571
+ d.millisecond = v * 100;
7572
+ }],
7573
+ SS: ['\\d{2}', function (d, v) {
7574
+ d.millisecond = v * 10;
7575
+ }],
7576
+ SSS: [threeDigits, function (d, v) {
7577
+ d.millisecond = v;
7578
+ }],
7579
+ D: [twoDigits, noop],
7580
+ ddd: [word, noop],
7581
+ MMM: [word, monthUpdate('monthNamesShort')],
7582
+ MMMM: [word, monthUpdate('monthNames')],
7583
+ a: [word, function (d, v) {
7584
+ const val = v.toLowerCase();
7585
+ if (val === '上午') {
7586
+ d.isPm = false;
7587
+ } else if (val === '下午') {
7588
+ d.isPm = true;
7589
+ }
7590
+ }],
7591
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
7592
+ let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
7593
+
7594
+ if (parts) {
7595
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
7596
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
7597
+ }
7598
+ }]
7599
+ };
7600
+ parseFlags.dd = parseFlags.d;
7601
+ parseFlags.dddd = parseFlags.ddd;
7602
+ parseFlags.DD = parseFlags.D;
7603
+ parseFlags.mm = parseFlags.m;
7604
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
7605
+ parseFlags.MM = parseFlags.M;
7606
+ parseFlags.ss = parseFlags.s;
7607
+ parseFlags.A = parseFlags.a;
7608
+
7609
+
7610
+ // Some common format strings
7611
+ fecha.masks = {
7612
+ default: 'ddd MMM dd yyyy HH:mm:ss',
7613
+ shortDate: 'M/D/yy',
7614
+ mediumDate: 'MMM d, yyyy',
7615
+ longDate: 'MMMM d, yyyy',
7616
+ fullDate: 'dddd, MMMM d, yyyy',
7617
+ shortTime: 'HH:mm',
7618
+ mediumTime: 'HH:mm:ss',
7619
+ longTime: 'HH:mm:ss.SSS'
7620
+ };
7621
+
7397
7622
  /***
7398
7623
  * Format a date
7399
7624
  * @method format
7400
7625
  * @param {Date|number} dateObj
7401
7626
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
7402
- */
7403
- fecha.format = function (dateObj, mask) {
7404
- if (typeof dateObj === 'number') {
7405
- dateObj = new Date(dateObj);
7406
- }
7407
-
7408
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
7409
- throw new Error('Invalid Date in fecha.format');
7410
- }
7411
-
7412
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
7413
-
7414
- var literals = [];
7415
-
7416
- // Make literals inactive by replacing them with ??
7417
- mask = mask.replace(literal, function ($0, $1) {
7418
- literals.push($1);
7419
- return '@@@';
7420
- });
7421
- // Apply formatting rules
7422
- mask = mask.replace(token, function ($0) {
7423
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
7424
- });
7425
- // Inline literal values back into the formatted value
7426
- return mask.replace(/@@@/g, function () {
7427
- return literals.shift();
7428
- });
7429
- };
7430
-
7627
+ */
7628
+ fecha.format = function (dateObj, mask) {
7629
+ if (typeof dateObj === 'number') {
7630
+ dateObj = new Date(dateObj);
7631
+ }
7632
+
7633
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
7634
+ throw new Error('Invalid Date in fecha.format');
7635
+ }
7636
+
7637
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
7638
+
7639
+ const literals = [];
7640
+
7641
+ // Make literals inactive by replacing them with ??
7642
+ mask = mask.replace(literal, function($0, $1) {
7643
+ literals.push($1);
7644
+ return '@@@';
7645
+ });
7646
+ // Apply formatting rules
7647
+ mask = mask.replace(token, function ($0) {
7648
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
7649
+ });
7650
+ // Inline literal values back into the formatted value
7651
+ return mask.replace(/@@@/g, function() {
7652
+ return literals.shift();
7653
+ });
7654
+ };
7655
+
7431
7656
  /**
7432
7657
  * Parse a date string into an object, changes - into /
7433
7658
  * @method parse
7434
7659
  * @param {string} dateStr Date string
7435
7660
  * @param {string} format Date parse format
7436
7661
  * @returns {Date|boolean}
7437
- */
7438
- fecha.parse = function (dateStr, format) {
7439
- if (typeof format !== 'string') {
7440
- throw new Error('Invalid format in fecha.parse');
7441
- }
7442
-
7443
- format = fecha.masks[format] || format;
7444
-
7445
- // Avoid regular expression denial of service, fail early for really long strings
7446
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
7447
- if (dateStr.length > 1000) {
7448
- return null;
7449
- }
7450
-
7451
- var dateInfo = {};
7452
- var parseInfo = [];
7453
- var literals = [];
7454
- format = format.replace(literal, function ($0, $1) {
7455
- literals.push($1);
7456
- return '@@@';
7457
- });
7458
- var newFormat = regexEscape(format).replace(token, function ($0) {
7459
- if (parseFlags[$0]) {
7460
- var info = parseFlags[$0];
7461
- parseInfo.push(info[1]);
7462
- return '(' + info[0] + ')';
7463
- }
7464
-
7465
- return $0;
7466
- });
7467
- newFormat = newFormat.replace(/@@@/g, function () {
7468
- return literals.shift();
7469
- });
7470
- var matches = dateStr.match(new RegExp(newFormat, 'i'));
7471
- if (!matches) {
7472
- return null;
7473
- }
7474
-
7475
- for (var i = 1; i < matches.length; i++) {
7476
- parseInfo[i - 1](dateInfo, matches[i]);
7477
- }
7478
-
7479
- var today = new Date();
7480
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
7481
- dateInfo.hour = +dateInfo.hour + 12;
7482
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
7483
- dateInfo.hour = 0;
7484
- }
7485
-
7486
- var date = void 0;
7487
- if (dateInfo.timezoneOffset != null) {
7488
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
7489
- 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));
7490
- } else {
7491
- 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);
7492
- }
7493
- return date;
7494
- };
7495
-
7496
- // 导出fecha对象
7497
-
7498
-
7499
- // 以下是从date-util.js合并的函数
7500
- var newArray = function newArray(start, end) {
7501
- var result = [];
7502
- for (var i = start; i <= end; i++) {
7503
- result.push(i);
7504
- }
7505
- return result;
7506
- };
7507
-
7508
- var getSettings = function getSettings() {
7509
- return {
7510
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
7511
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
7512
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
7513
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
7514
- amPm: ['上午', '下午']
7515
- };
7516
- };
7517
-
7518
- var toDate = function toDate(date) {
7519
- return isDate(date) ? new Date(date) : null;
7520
- };
7521
-
7522
- var isDate = function isDate(date) {
7523
- if (date === null || date === undefined) return false;
7524
- if (isNaN(new Date(date).getTime())) return false;
7525
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
7526
- return true;
7527
- };
7528
-
7529
- var isDateObject = function isDateObject(val) {
7530
- return val instanceof Date;
7531
- };
7532
-
7533
- var formatDate = function formatDate(date) {
7534
- var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
7535
-
7536
- // 处理多种输入类型
7537
- if (!date) return '';
7538
-
7539
- // 如果是时间戳,转成日期对象
7540
- if (typeof date === 'number') {
7541
- date = new Date(date);
7542
- }
7543
- // 如果是字符串,转成日期对象
7544
- if (typeof date === 'string') {
7545
- date = new Date(date);
7546
- }
7547
-
7548
- // 调用toDate进一步验证和转换
7549
- date = toDate(date);
7550
- if (!date) return '';
7551
-
7552
- // 兼容大写和小写的格式标记
7553
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
7554
- var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
7555
-
7556
- // 使用fecha库进行格式化,支持中文配置
7557
- var str = fecha.format(date, lowercaseFormat, getSettings());
7558
- return str;
7559
- };
7560
-
7561
- var parseDate = function parseDate(string, format) {
7562
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
7563
- };
7564
-
7565
- var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
7566
- if (month === 3 || month === 5 || month === 8 || month === 10) {
7567
- return 30;
7568
- }
7569
-
7570
- if (month === 1) {
7571
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
7572
- return 29;
7573
- } else {
7574
- return 28;
7575
- }
7576
- }
7577
-
7578
- return 31;
7579
- };
7580
-
7581
- var getDayCountOfYear = function getDayCountOfYear(year) {
7582
- var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
7583
- return isLeapYear ? 366 : 365;
7584
- };
7585
-
7586
- var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
7587
- var temp = new Date(date.getTime());
7588
- temp.setDate(1);
7589
- return temp.getDay();
7590
- };
7591
-
7592
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
7593
- // {prev, next} Date should work for Daylight Saving Time
7594
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
7595
- var prevDate = function prevDate(date) {
7596
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
7597
-
7598
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
7599
- };
7600
-
7601
- var nextDate = function nextDate(date) {
7602
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
7603
-
7604
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
7605
- };
7606
-
7607
- var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
7608
- var result = new Date(year, month, 1);
7609
- var day = result.getDay();
7610
-
7611
- if (day === 0) {
7612
- return prevDate(result, 7);
7613
- } else {
7614
- return prevDate(result, day);
7615
- }
7616
- };
7617
-
7618
- var getWeekNumber = function getWeekNumber(date) {
7619
- // 支持多种输入类型
7620
- if (!date || !isDate(date)) {
7621
- date = new Date();
7622
- }
7623
- if (typeof date === 'string') {
7624
- date = new Date(date);
7625
- }
7626
-
7627
- // 验证日期有效性
7628
- if (!isDate(date)) return null;
7629
-
7630
- var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
7631
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
7632
- // 将星期日的星期数设为7
7633
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
7634
- // 获取当年的第一天
7635
- var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
7636
- // 计算到最近的星期四的完整周数
7637
- var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
7638
- // 返回周数
7639
- return weekNo;
7640
- };
7641
-
7642
- var getRangeHours = function getRangeHours(ranges) {
7643
- var hours = [];
7644
- var disabledHours = [];
7645
-
7646
- (ranges || []).forEach(function (range) {
7647
- var value = range.map(function (date) {
7648
- return date.getHours();
7649
- });
7650
-
7651
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
7652
- });
7653
-
7654
- if (disabledHours.length) {
7655
- for (var i = 0; i < 24; i++) {
7656
- hours[i] = disabledHours.indexOf(i) === -1;
7657
- }
7658
- } else {
7659
- for (var _i = 0; _i < 24; _i++) {
7660
- hours[_i] = false;
7661
- }
7662
- }
7663
-
7664
- return hours;
7665
- };
7666
-
7667
- var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
7668
- if (amount <= 0) return [];
7669
- var temp = new Date(date.getTime());
7670
- temp.setDate(0);
7671
- var lastDay = temp.getDate();
7672
- return range(amount).map(function (_, index) {
7673
- return lastDay - (amount - index - 1);
7674
- });
7675
- };
7676
-
7677
- var getMonthDays = function getMonthDays(date) {
7678
- var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
7679
- var days = temp.getDate();
7680
- return range(days).map(function (_, index) {
7681
- return index + 1;
7682
- });
7683
- };
7684
-
7685
- function setRangeData(arr, start, end, value) {
7686
- for (var i = start; i < end; i++) {
7687
- arr[i] = value;
7688
- }
7689
- }
7690
-
7691
- var getRangeMinutes = function getRangeMinutes(ranges, hour) {
7692
- var minutes = new Array(60);
7693
-
7694
- if (ranges.length > 0) {
7695
- ranges.forEach(function (range) {
7696
- var start = range[0];
7697
- var end = range[1];
7698
- var startHour = start.getHours();
7699
- var startMinute = start.getMinutes();
7700
- var endHour = end.getHours();
7701
- var endMinute = end.getMinutes();
7702
- if (startHour === hour && endHour !== hour) {
7703
- setRangeData(minutes, startMinute, 60, true);
7704
- } else if (startHour === hour && endHour === hour) {
7705
- setRangeData(minutes, startMinute, endMinute + 1, true);
7706
- } else if (startHour !== hour && endHour === hour) {
7707
- setRangeData(minutes, 0, endMinute + 1, true);
7708
- } else if (startHour < hour && endHour > hour) {
7709
- setRangeData(minutes, 0, 60, true);
7710
- }
7711
- });
7712
- } else {
7713
- setRangeData(minutes, 0, 60, true);
7714
- }
7715
- return minutes;
7716
- };
7717
-
7718
- var range = function range(n) {
7719
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
7720
- return Array.apply(null, { length: n }).map(function (_, n) {
7721
- return n;
7722
- });
7723
- };
7724
-
7725
- var modifyDate = function modifyDate(date, y, m, d) {
7726
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
7727
- };
7728
-
7729
- var modifyTime = function modifyTime(date, h, m, s) {
7730
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
7731
- };
7732
-
7733
- var modifyWithTimeString = function modifyWithTimeString(date, time) {
7734
- if (date == null || !time) {
7735
- return date;
7736
- }
7737
- time = parseDate(time, 'HH:mm:ss');
7738
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
7739
- };
7740
-
7741
- var clearTime = function clearTime(date) {
7742
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
7743
- };
7744
-
7745
- var clearMilliseconds = function clearMilliseconds(date) {
7746
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
7747
- };
7748
-
7749
- var limitTimeRange = function limitTimeRange(date, ranges) {
7750
- var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
7751
-
7752
- // TODO: refactory a more elegant solution
7753
- if (ranges.length === 0) return date;
7754
- var normalizeDate = function normalizeDate(date) {
7755
- return fecha.parse(fecha.format(date, format), format);
7756
- };
7757
- var ndate = normalizeDate(date);
7758
- var nranges = ranges.map(function (range) {
7759
- return range.map(normalizeDate);
7760
- });
7761
- if (nranges.some(function (nrange) {
7762
- return ndate >= nrange[0] && ndate <= nrange[1];
7763
- })) return date;
7764
-
7765
- var minDate = nranges[0][0];
7766
- var maxDate = nranges[0][0];
7767
-
7768
- nranges.forEach(function (nrange) {
7769
- minDate = new Date(Math.min(nrange[0], minDate));
7770
- maxDate = new Date(Math.max(nrange[1], minDate));
7771
- });
7772
-
7773
- var ret = ndate < minDate ? minDate : maxDate;
7774
- // preserve Year/Month/Date
7775
- return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
7776
- };
7777
-
7778
- var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
7779
- var limitedDate = limitTimeRange(date, selectableRange, format);
7780
- return limitedDate.getTime() === date.getTime();
7781
- };
7782
-
7783
- var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
7784
- // clamp date to the number of days in `year`, `month`
7785
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
7786
- var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
7787
- return modifyDate(date, year, month, monthDate);
7788
- };
7789
-
7790
- var prevMonth = function prevMonth(date) {
7791
- var year = date.getFullYear();
7792
- var month = date.getMonth();
7793
- return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
7794
- };
7795
-
7796
- var nextMonth = function nextMonth(date) {
7797
- var year = date.getFullYear();
7798
- var month = date.getMonth();
7799
- return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
7800
- };
7801
-
7802
- var prevYear = function prevYear(date) {
7803
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
7804
-
7805
- var year = date.getFullYear();
7806
- var month = date.getMonth();
7807
- return changeYearMonthAndClampDate(date, year - amount, month);
7808
- };
7809
-
7810
- var nextYear = function nextYear(date) {
7811
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
7812
-
7813
- var year = date.getFullYear();
7814
- var month = date.getMonth();
7815
- return changeYearMonthAndClampDate(date, year + amount, month);
7816
- };
7817
-
7818
- var extractDateFormat = function extractDateFormat(format) {
7819
- return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
7820
- };
7821
-
7822
- var extractTimeFormat = function extractTimeFormat(format) {
7823
- return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
7824
- };
7825
-
7826
- var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
7827
- return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
7828
- };
7829
-
7662
+ */
7663
+ fecha.parse = function (dateStr, format) {
7664
+ if (typeof format !== 'string') {
7665
+ throw new Error('Invalid format in fecha.parse');
7666
+ }
7667
+
7668
+ format = fecha.masks[format] || format;
7669
+
7670
+ // Avoid regular expression denial of service, fail early for really long strings
7671
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
7672
+ if (dateStr.length > 1000) {
7673
+ return null;
7674
+ }
7675
+
7676
+ const dateInfo = {};
7677
+ const parseInfo = [];
7678
+ const literals = [];
7679
+ format = format.replace(literal, function($0, $1) {
7680
+ literals.push($1);
7681
+ return '@@@';
7682
+ });
7683
+ let newFormat = regexEscape(format).replace(token, function ($0) {
7684
+ if (parseFlags[$0]) {
7685
+ const info = parseFlags[$0];
7686
+ parseInfo.push(info[1]);
7687
+ return '(' + info[0] + ')';
7688
+ }
7689
+
7690
+ return $0;
7691
+ });
7692
+ newFormat = newFormat.replace(/@@@/g, function() {
7693
+ return literals.shift();
7694
+ });
7695
+ const matches = dateStr.match(new RegExp(newFormat, 'i'));
7696
+ if (!matches) {
7697
+ return null;
7698
+ }
7699
+
7700
+ for (let i = 1; i < matches.length; i++) {
7701
+ parseInfo[i - 1](dateInfo, matches[i]);
7702
+ }
7703
+
7704
+ const today = new Date();
7705
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
7706
+ dateInfo.hour = +dateInfo.hour + 12;
7707
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
7708
+ dateInfo.hour = 0;
7709
+ }
7710
+
7711
+ let date;
7712
+ if (dateInfo.timezoneOffset != null) {
7713
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
7714
+ date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
7715
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
7716
+ } else {
7717
+ date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
7718
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
7719
+ }
7720
+ return date;
7721
+ };
7722
+
7723
+ // 导出fecha对象
7724
+
7725
+
7726
+ // 以下是从date-util.js合并的函数
7727
+ const newArray = function(start, end) {
7728
+ let result = [];
7729
+ for (let i = start; i <= end; i++) {
7730
+ result.push(i);
7731
+ }
7732
+ return result;
7733
+ };
7734
+
7735
+ const getSettings = () => {
7736
+ return {
7737
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
7738
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
7739
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
7740
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
7741
+ amPm: ['上午', '下午']
7742
+ };
7743
+ };
7744
+
7745
+ const toDate = function(date) {
7746
+ return isDate(date) ? new Date(date) : null;
7747
+ };
7748
+
7749
+ const isDate = function(date) {
7750
+ if (date === null || date === undefined) return false;
7751
+ if (isNaN(new Date(date).getTime())) return false;
7752
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
7753
+ return true;
7754
+ };
7755
+
7756
+ const isDateObject = function(val) {
7757
+ return val instanceof Date;
7758
+ };
7759
+
7760
+ const formatDate = function (date, format = 'yyyy-MM-dd') {
7761
+ // 处理多种输入类型
7762
+ if (!date) return '';
7763
+
7764
+ // 如果是时间戳,转成日期对象
7765
+ if (typeof date === 'number') {
7766
+ date = new Date(date);
7767
+ }
7768
+ // 如果是字符串,转成日期对象
7769
+ if (typeof date === 'string') {
7770
+ date = new Date(date);
7771
+ }
7772
+
7773
+ // 调用toDate进一步验证和转换
7774
+ date = toDate(date);
7775
+ if (!date) return '';
7776
+
7777
+ // 兼容大写和小写的格式标记
7778
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
7779
+ const lowercaseFormat = format
7780
+ .replace(/YYYY/g, 'yyyy')
7781
+ .replace(/D/g, 'd')
7782
+
7783
+ // 使用fecha库进行格式化,支持中文配置
7784
+ const str = fecha.format(date, lowercaseFormat, getSettings());
7785
+ return str;
7786
+ };
7787
+
7788
+ const parseDate = function(string, format) {
7789
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
7790
+ };
7791
+
7792
+ const getDayCountOfMonth = function(year, month) {
7793
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
7794
+ return 30;
7795
+ }
7796
+
7797
+ if (month === 1) {
7798
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
7799
+ return 29;
7800
+ } else {
7801
+ return 28;
7802
+ }
7803
+ }
7804
+
7805
+ return 31;
7806
+ };
7807
+
7808
+ const getDayCountOfYear = function(year) {
7809
+ const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
7810
+ return isLeapYear ? 366 : 365;
7811
+ };
7812
+
7813
+ const getFirstDayOfMonth = function(date) {
7814
+ const temp = new Date(date.getTime());
7815
+ temp.setDate(1);
7816
+ return temp.getDay();
7817
+ };
7818
+
7819
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
7820
+ // {prev, next} Date should work for Daylight Saving Time
7821
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
7822
+ const prevDate = function(date, amount = 1) {
7823
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
7824
+ };
7825
+
7826
+ const nextDate = function(date, amount = 1) {
7827
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
7828
+ };
7829
+
7830
+ const getStartDateOfMonth = function(year, month) {
7831
+ const result = new Date(year, month, 1);
7832
+ const day = result.getDay();
7833
+
7834
+ if (day === 0) {
7835
+ return prevDate(result, 7);
7836
+ } else {
7837
+ return prevDate(result, day);
7838
+ }
7839
+ };
7840
+
7841
+ const getWeekNumber = function(date) {
7842
+ // 支持多种输入类型
7843
+ if (!date||!isDate(date)) {
7844
+ date = new Date();
7845
+ }
7846
+ if (typeof date === 'string') {
7847
+ date = new Date(date);
7848
+ }
7849
+
7850
+ // 验证日期有效性
7851
+ if (!isDate(date)) return null;
7852
+
7853
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
7854
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
7855
+ // 将星期日的星期数设为7
7856
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
7857
+ // 获取当年的第一天
7858
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
7859
+ // 计算到最近的星期四的完整周数
7860
+ const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
7861
+ // 返回周数
7862
+ return weekNo;
7863
+ };
7864
+
7865
+ const getRangeHours = function(ranges) {
7866
+ const hours = [];
7867
+ let disabledHours = [];
7868
+
7869
+ (ranges || []).forEach(range => {
7870
+ const value = range.map(date => date.getHours());
7871
+
7872
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
7873
+ });
7874
+
7875
+ if (disabledHours.length) {
7876
+ for (let i = 0; i < 24; i++) {
7877
+ hours[i] = disabledHours.indexOf(i) === -1;
7878
+ }
7879
+ } else {
7880
+ for (let i = 0; i < 24; i++) {
7881
+ hours[i] = false;
7882
+ }
7883
+ }
7884
+
7885
+ return hours;
7886
+ };
7887
+
7888
+ const getPrevMonthLastDays = (date, amount) => {
7889
+ if (amount <= 0) return [];
7890
+ const temp = new Date(date.getTime());
7891
+ temp.setDate(0);
7892
+ const lastDay = temp.getDate();
7893
+ return range(amount).map((_, index) => lastDay - (amount - index - 1));
7894
+ };
7895
+
7896
+ const getMonthDays = (date) => {
7897
+ const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
7898
+ const days = temp.getDate();
7899
+ return range(days).map((_, index) => index + 1);
7900
+ };
7901
+
7902
+ function setRangeData(arr, start, end, value) {
7903
+ for (let i = start; i < end; i++) {
7904
+ arr[i] = value;
7905
+ }
7906
+ }
7907
+
7908
+ const getRangeMinutes = function(ranges, hour) {
7909
+ const minutes = new Array(60);
7910
+
7911
+ if (ranges.length > 0) {
7912
+ ranges.forEach(range => {
7913
+ const start = range[0];
7914
+ const end = range[1];
7915
+ const startHour = start.getHours();
7916
+ const startMinute = start.getMinutes();
7917
+ const endHour = end.getHours();
7918
+ const endMinute = end.getMinutes();
7919
+ if (startHour === hour && endHour !== hour) {
7920
+ setRangeData(minutes, startMinute, 60, true);
7921
+ } else if (startHour === hour && endHour === hour) {
7922
+ setRangeData(minutes, startMinute, endMinute + 1, true);
7923
+ } else if (startHour !== hour && endHour === hour) {
7924
+ setRangeData(minutes, 0, endMinute + 1, true);
7925
+ } else if (startHour < hour && endHour > hour) {
7926
+ setRangeData(minutes, 0, 60, true);
7927
+ }
7928
+ });
7929
+ } else {
7930
+ setRangeData(minutes, 0, 60, true);
7931
+ }
7932
+ return minutes;
7933
+ };
7934
+
7935
+ const range = function(n) {
7936
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
7937
+ return Array.apply(null, {length: n}).map((_, n) => n);
7938
+ };
7939
+
7940
+ const modifyDate = function(date, y, m, d) {
7941
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
7942
+ };
7943
+
7944
+ const modifyTime = function(date, h, m, s) {
7945
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
7946
+ };
7947
+
7948
+ const modifyWithTimeString = (date, time) => {
7949
+ if (date == null || !time) {
7950
+ return date;
7951
+ }
7952
+ time = parseDate(time, 'HH:mm:ss');
7953
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
7954
+ };
7955
+
7956
+ const clearTime = function(date) {
7957
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
7958
+ };
7959
+
7960
+ const clearMilliseconds = function(date) {
7961
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
7962
+ };
7963
+
7964
+ const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
7965
+ // TODO: refactory a more elegant solution
7966
+ if (ranges.length === 0) return date;
7967
+ const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
7968
+ const ndate = normalizeDate(date);
7969
+ const nranges = ranges.map(range => range.map(normalizeDate));
7970
+ if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
7971
+
7972
+ let minDate = nranges[0][0];
7973
+ let maxDate = nranges[0][0];
7974
+
7975
+ nranges.forEach(nrange => {
7976
+ minDate = new Date(Math.min(nrange[0], minDate));
7977
+ maxDate = new Date(Math.max(nrange[1], minDate));
7978
+ });
7979
+
7980
+ const ret = ndate < minDate ? minDate : maxDate;
7981
+ // preserve Year/Month/Date
7982
+ return modifyDate(
7983
+ ret,
7984
+ date.getFullYear(),
7985
+ date.getMonth(),
7986
+ date.getDate()
7987
+ );
7988
+ };
7989
+
7990
+ const timeWithinRange = function(date, selectableRange, format) {
7991
+ const limitedDate = limitTimeRange(date, selectableRange, format);
7992
+ return limitedDate.getTime() === date.getTime();
7993
+ };
7994
+
7995
+ const changeYearMonthAndClampDate = function(date, year, month) {
7996
+ // clamp date to the number of days in `year`, `month`
7997
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
7998
+ const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
7999
+ return modifyDate(date, year, month, monthDate);
8000
+ };
8001
+
8002
+ const prevMonth = function(date) {
8003
+ const year = date.getFullYear();
8004
+ const month = date.getMonth();
8005
+ return month === 0
8006
+ ? changeYearMonthAndClampDate(date, year - 1, 11)
8007
+ : changeYearMonthAndClampDate(date, year, month - 1);
8008
+ };
8009
+
8010
+ const nextMonth = function(date) {
8011
+ const year = date.getFullYear();
8012
+ const month = date.getMonth();
8013
+ return month === 11
8014
+ ? changeYearMonthAndClampDate(date, year + 1, 0)
8015
+ : changeYearMonthAndClampDate(date, year, month + 1);
8016
+ };
8017
+
8018
+ const prevYear = function(date, amount = 1) {
8019
+ const year = date.getFullYear();
8020
+ const month = date.getMonth();
8021
+ return changeYearMonthAndClampDate(date, year - amount, month);
8022
+ };
8023
+
8024
+ const nextYear = function(date, amount = 1) {
8025
+ const year = date.getFullYear();
8026
+ const month = date.getMonth();
8027
+ return changeYearMonthAndClampDate(date, year + amount, month);
8028
+ };
8029
+
8030
+ const extractDateFormat = function(format) {
8031
+ return format
8032
+ .replace(/\W?m{1,2}|\W?ZZ/g, '')
8033
+ .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
8034
+ .trim();
8035
+ };
8036
+
8037
+ const extractTimeFormat = function(format) {
8038
+ return format
8039
+ .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
8040
+ .trim();
8041
+ };
8042
+
8043
+ const validateRangeInOneMonth = function(start, end) {
8044
+ return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
8045
+ };
8046
+
7830
8047
  /**
7831
8048
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
7832
8049
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
7833
8050
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
7834
8051
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
7835
8052
  * @returns {number} 工作日数量
7836
- */
7837
- var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
7838
- var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
7839
-
7840
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
7841
- throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
7842
- }
7843
-
7844
- var startDateObj = new Date(start_date);
7845
- var endDateObj = new Date(end_date);
7846
-
7847
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
7848
- throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
7849
- }
7850
-
7851
- if (startDateObj > endDateObj) {
7852
- throw new Error('Start date should be earlier than or equal to end date.');
7853
- }
7854
-
7855
- var workdays = 0;
7856
-
7857
- // Iterate through each day in the date range
7858
-
7859
- var _loop = function _loop(currentDate) {
7860
- // Check if the current day is a weekend (Saturday or Sunday)
7861
- var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
7862
-
7863
- // Check if the current day is a holiday
7864
- var isHoliday = holidays.some(function (holiday) {
7865
- var holidayDate = new Date(holiday);
7866
- return currentDate.toDateString() === holidayDate.toDateString();
7867
- });
7868
-
7869
- // If it's a workday (not a weekend or holiday), increment the workdays count
7870
- if (!isWeekend && !isHoliday) {
7871
- workdays++;
7872
- }
7873
- };
7874
-
7875
- for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
7876
- _loop(currentDate);
7877
- }
7878
-
7879
- return workdays;
7880
- };
7881
-
8053
+ */
8054
+ const calculateNetworkDays = function (start_date, end_date, holidays = []) {
8055
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
8056
+ throw new Error(
8057
+ "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
8058
+ );
8059
+ }
8060
+
8061
+ const startDateObj = new Date(start_date);
8062
+ const endDateObj = new Date(end_date);
8063
+
8064
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
8065
+ throw new Error(
8066
+ "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
8067
+ );
8068
+ }
8069
+
8070
+ if (startDateObj > endDateObj) {
8071
+ throw new Error('Start date should be earlier than or equal to end date.');
8072
+ }
8073
+
8074
+ let workdays = 0;
8075
+
8076
+ // Iterate through each day in the date range
8077
+ for (
8078
+ let currentDate = new Date(startDateObj);
8079
+ currentDate <= endDateObj;
8080
+ currentDate.setDate(currentDate.getDate() + 1)
8081
+ ) {
8082
+ // Check if the current day is a weekend (Saturday or Sunday)
8083
+ const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
8084
+
8085
+ // Check if the current day is a holiday
8086
+ const isHoliday = holidays.some((holiday) => {
8087
+ const holidayDate = new Date(holiday);
8088
+ return currentDate.toDateString() === holidayDate.toDateString();
8089
+ });
8090
+
8091
+ // If it's a workday (not a weekend or holiday), increment the workdays count
8092
+ if (!isWeekend && !isHoliday) {
8093
+ workdays++;
8094
+ }
8095
+ }
8096
+
8097
+ return workdays;
8098
+ };
8099
+
7882
8100
  /**
7883
8101
  * 日期加减天数
7884
8102
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
7885
8103
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
7886
8104
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
7887
- */
7888
- var dateAddDays = function dateAddDays(start_date, days) {
7889
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
7890
- 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.");
7891
- }
7892
-
7893
- var startDateObj = new Date(start_date);
7894
- if (isNaN(startDateObj.getTime())) {
7895
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
7896
- }
7897
-
7898
- var resultDateObj = new Date(startDateObj);
7899
- resultDateObj.setDate(resultDateObj.getDate() + days);
7900
-
7901
- var resultYear = resultDateObj.getFullYear();
7902
- var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
7903
- var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
7904
-
7905
- return resultYear + '-' + resultMonth + '-' + resultDay;
7906
- };
7907
-
8105
+ */
8106
+ const dateAddDays = function (start_date, days) {
8107
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
8108
+ throw new Error(
8109
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
8110
+ );
8111
+ }
8112
+
8113
+ const startDateObj = new Date(start_date);
8114
+ if (isNaN(startDateObj.getTime())) {
8115
+ throw new Error(
8116
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
8117
+ );
8118
+ }
8119
+
8120
+ const resultDateObj = new Date(startDateObj);
8121
+ resultDateObj.setDate(resultDateObj.getDate() + days);
8122
+
8123
+ const resultYear = resultDateObj.getFullYear();
8124
+ const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
8125
+ const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
8126
+
8127
+ return `${resultYear}-${resultMonth}-${resultDay}`;
8128
+ };
8129
+
7908
8130
  /**
7909
8131
  * 计算两个日期之间的差值
7910
8132
  * @date 2023年12月14日
@@ -7912,180 +8134,182 @@ var dateAddDays = function dateAddDays(start_date, days) {
7912
8134
  * @param {String} end_date - 结束日期字符串
7913
8135
  * @param {String} unit - 单位:year/month/day
7914
8136
  * @returns {Number} 差值
7915
- */
7916
- var dateDiff = function dateDiff(start_date, end_date) {
7917
- var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
7918
-
7919
- // Assuming date strings are in "YYYY-MM-DD" format
7920
- var startDate = new Date(start_date);
7921
- var endDate = new Date(end_date);
7922
-
7923
- // If the date is invalid, return 0
7924
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
7925
- return 0;
7926
- }
7927
-
7928
- if (unit === 'year') {
7929
- return endDate.getFullYear() - startDate.getFullYear();
7930
- } else if (unit === 'month') {
7931
- return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
7932
- } else {
7933
- // Default to day
7934
- var timeDifference = endDate - startDate;
7935
- // Calculate days (86400000 milliseconds per day)
7936
- return Math.floor(timeDifference / 86400000);
7937
- }
7938
- };
7939
-
8137
+ */
8138
+ const dateDiff = function (start_date, end_date, unit = 'day') {
8139
+ // Assuming date strings are in "YYYY-MM-DD" format
8140
+ var startDate = new Date(start_date);
8141
+ var endDate = new Date(end_date);
8142
+
8143
+ // If the date is invalid, return 0
8144
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
8145
+ return 0;
8146
+ }
8147
+
8148
+ if (unit === 'year') {
8149
+ return endDate.getFullYear() - startDate.getFullYear();
8150
+ } else if (unit === 'month') {
8151
+ return (
8152
+ (endDate.getFullYear() - startDate.getFullYear()) * 12 +
8153
+ (endDate.getMonth() - startDate.getMonth())
8154
+ );
8155
+ } else {
8156
+ // Default to day
8157
+ var timeDifference = endDate - startDate;
8158
+ // Calculate days (86400000 milliseconds per day)
8159
+ return Math.floor(timeDifference / 86400000);
8160
+ }
8161
+ };
8162
+
7940
8163
  /**
7941
8164
  * 获取月份中的日期
7942
8165
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
7943
8166
  * @returns {number} 月份中的日期(1-31)
7944
- */
7945
- var dayOfMonth = function dayOfMonth(date) {
7946
- if (typeof date !== 'string') {
7947
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
7948
- }
7949
-
7950
- var dateObj = new Date(date);
7951
- if (isNaN(dateObj.getTime())) {
7952
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
7953
- }
7954
-
7955
- return dateObj.getDate();
7956
- };
7957
-
8167
+ */
8168
+ const dayOfMonth = function (date) {
8169
+ if (typeof date !== 'string') {
8170
+ throw new Error(
8171
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
8172
+ );
8173
+ }
8174
+
8175
+ const dateObj = new Date(date);
8176
+ if (isNaN(dateObj.getTime())) {
8177
+ throw new Error(
8178
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
8179
+ );
8180
+ }
8181
+
8182
+ return dateObj.getDate();
8183
+ };
8184
+
7958
8185
  /**
7959
8186
  * 获取当前日期
7960
8187
  * @date 2022年5月7日
7961
8188
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
7962
8189
  * @returns {string} 当前日期的格式化字符串
7963
- */
7964
- var getCurrentDate = function getCurrentDate() {
7965
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
7966
-
7967
- return formatDate(new Date(), format);
7968
- };
7969
-
8190
+ */
8191
+ const getCurrentDate = function (format = 'YYYY-MM-DD') {
8192
+ return formatDate(new Date(), format);
8193
+ };
8194
+
7970
8195
  /**
7971
8196
  * 获取当前日期时间
7972
8197
  * @date 2022年5月7日
7973
8198
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
7974
8199
  * @returns {string} 当前日期时间的格式化字符串
7975
- */
7976
- var getCurrentDateTime = function getCurrentDateTime() {
7977
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
7978
-
7979
- return formatDate(new Date(), format);
7980
- };
7981
-
8200
+ */
8201
+ const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
8202
+ return formatDate(new Date(), format);
8203
+ };
8204
+
7982
8205
  /**
7983
8206
  * 获取小时
7984
8207
  * @date 2022年5月7日
7985
8208
  * @param {Date|string} [date] - 日期对象或日期字符串
7986
8209
  * @returns {number} 小时数(0-23)
7987
- */
7988
- var getHour = function getHour(date) {
7989
- if (!date) {
7990
- return new Date().getHours();
7991
- }
7992
- if (typeof date === 'string') {
7993
- date = new Date(date);
7994
- }
7995
- return date.getHours();
7996
- };
7997
-
8210
+ */
8211
+ const getHour = function (date) {
8212
+ if (!date) {
8213
+ return new Date().getHours();
8214
+ }
8215
+ if (typeof date === 'string') {
8216
+ date = new Date(date);
8217
+ }
8218
+ return date.getHours();
8219
+ };
8220
+
7998
8221
  /**
7999
8222
  * 获取分钟
8000
8223
  * @date 2022年5月7日
8001
8224
  * @param {Date|string} [date] - 日期对象或日期字符串
8002
8225
  * @returns {number} 分钟数(0-59)
8003
- */
8004
- var getMinute = function getMinute(date) {
8005
- if (!date) {
8006
- return new Date().getMinutes();
8007
- }
8008
- if (typeof date === 'string') {
8009
- date = new Date(date);
8010
- }
8011
- return date.getMinutes();
8012
- };
8013
-
8226
+ */
8227
+ const getMinute = function (date) {
8228
+ if (!date) {
8229
+ return new Date().getMinutes();
8230
+ }
8231
+ if (typeof date === 'string') {
8232
+ date = new Date(date);
8233
+ }
8234
+ return date.getMinutes();
8235
+ };
8236
+
8014
8237
  /**
8015
8238
  * 获取月份
8016
8239
  * @date 2022年5月7日
8017
8240
  * @param {Date|string} [date] - 日期对象或日期字符串
8018
8241
  * @returns {number} 月份数(1-12)
8019
- */
8020
- var getMonth = function getMonth(date) {
8021
- if (!date) {
8022
- return new Date().getMonth() + 1;
8023
- }
8024
- if (typeof date === 'string') {
8025
- date = new Date(date);
8026
- }
8027
- return date.getMonth() + 1;
8028
- };
8029
-
8242
+ */
8243
+ const getMonth = function (date) {
8244
+ if (!date) {
8245
+ return new Date().getMonth() + 1;
8246
+ }
8247
+ if (typeof date === 'string') {
8248
+ date = new Date(date);
8249
+ }
8250
+ return date.getMonth() + 1;
8251
+ };
8252
+
8030
8253
  /**
8031
8254
  * 获取秒
8032
8255
  * @date 2022年5月7日
8033
8256
  * @param {Date|string} [date] - 日期对象或日期字符串
8034
8257
  * @returns {number} 秒数(0-59)
8035
- */
8036
- var getSecond = function getSecond(date) {
8037
- if (!date) {
8038
- return new Date().getSeconds();
8039
- }
8040
- if (typeof date === 'string') {
8041
- date = new Date(date);
8042
- }
8043
- return date.getSeconds();
8044
- };
8045
-
8258
+ */
8259
+ const getSecond = function (date) {
8260
+ if (!date) {
8261
+ return new Date().getSeconds();
8262
+ }
8263
+ if (typeof date === 'string') {
8264
+ date = new Date(date);
8265
+ }
8266
+ return date.getSeconds();
8267
+ };
8268
+
8046
8269
  /**
8047
8270
  * 获取星期几
8048
8271
  * @date 2022年5月7日
8049
8272
  * @param {Date|string} [date] - 日期对象或日期字符串
8050
8273
  * @returns {number} 星期几(0-6,0表示星期日)
8051
- */
8052
- var getWeekday = function getWeekday(date) {
8053
- if (!date) {
8054
- return new Date().getDay();
8055
- }
8056
- if (typeof date === 'string') {
8057
- date = new Date(date);
8058
- }
8059
- return date.getDay();
8060
- };
8061
-
8274
+ */
8275
+ const getWeekday = function (date) {
8276
+ if (!date) {
8277
+ return new Date().getDay();
8278
+ }
8279
+ if (typeof date === 'string') {
8280
+ date = new Date(date);
8281
+ }
8282
+ return date.getDay();
8283
+ };
8284
+
8285
+
8062
8286
  /**
8063
8287
  * @desc 获取上午/下午/晚上
8064
8288
  * @author huangbo
8065
8289
  * @date 2022年5月7日
8066
8290
  * @param {String} [time] - 时间
8067
- **/
8068
- var timeCycle = function timeCycle(time) {
8069
- var hour = 0;
8070
- if (!time) {
8071
- hour = new Date().getHours();
8072
- } else if (typeof time === 'string') {
8073
- // 从时间字符串中提取小时
8074
- var match = time.match(/^(\d{1,2})/);
8075
- if (match) {
8076
- hour = parseInt(match[1], 10);
8077
- }
8078
- } else if (typeof time === 'number') {
8079
- hour = time;
8080
- }
8081
- // 判断时间段
8082
- if (hour >= 5 && hour < 12) {
8083
- return '上午';
8084
- } else if (hour >= 12 && hour < 18) {
8085
- return '下午';
8086
- } else {
8087
- return '晚上';
8088
- }
8291
+ **/
8292
+ const timeCycle = function (time) {
8293
+ let hour = 0;
8294
+ if (!time) {
8295
+ hour = new Date().getHours();
8296
+ } else if (typeof time === 'string') {
8297
+ // 从时间字符串中提取小时
8298
+ const match = time.match(/^(\d{1,2})/);
8299
+ if (match) {
8300
+ hour = parseInt(match[1], 10);
8301
+ }
8302
+ } else if (typeof time === 'number') {
8303
+ hour = time;
8304
+ }
8305
+ // 判断时间段
8306
+ if (hour >= 5 && hour < 12) {
8307
+ return '上午';
8308
+ } else if (hour >= 12 && hour < 18) {
8309
+ return '下午';
8310
+ } else {
8311
+ return '晚上';
8312
+ }
8089
8313
  };
8090
8314
 
8091
8315
  /***/ }),