eoss 0.1.0-alpha.39 → 0.1.0-alpha.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/lib/0.js +1 -1
  2. package/lib/1.js +1 -1
  3. package/lib/10.js +1 -1
  4. package/lib/11.js +1 -1
  5. package/lib/12.js +1 -1
  6. package/lib/13.js +1 -1
  7. package/lib/14.js +1 -1
  8. package/lib/15.js +1 -1
  9. package/lib/16.js +1 -1
  10. package/lib/17.js +1 -1
  11. package/lib/18.js +1 -1
  12. package/lib/19.js +1 -1
  13. package/lib/20.js +1 -1
  14. package/lib/21.js +1 -1
  15. package/lib/22.js +1 -1
  16. package/lib/23.js +1 -1
  17. package/lib/24.js +1 -1
  18. package/lib/25.js +1 -1
  19. package/lib/26.js +1 -1
  20. package/lib/27.js +1 -1
  21. package/lib/28.js +1 -1
  22. package/lib/29.js +1 -1
  23. package/lib/3.js +1 -1
  24. package/lib/30.js +1 -1
  25. package/lib/31.js +1 -1
  26. package/lib/32.js +1 -1
  27. package/lib/33.js +1 -1
  28. package/lib/34.js +1 -1
  29. package/lib/35.js +1 -1
  30. package/lib/36.js +1 -1
  31. package/lib/37.js +1 -1
  32. package/lib/38.js +1 -1
  33. package/lib/39.js +1 -1
  34. package/lib/4.js +1 -1
  35. package/lib/40.js +1 -1
  36. package/lib/41.js +1 -1
  37. package/lib/42.js +1 -1
  38. package/lib/43.js +1 -1
  39. package/lib/44.js +1 -1
  40. package/lib/45.js +1 -1
  41. package/lib/46.js +1 -1
  42. package/lib/47.js +1 -1
  43. package/lib/48.js +1 -1
  44. package/lib/49.js +1 -1
  45. package/lib/5.js +1 -1
  46. package/lib/50.js +1 -1
  47. package/lib/51.js +1 -1
  48. package/lib/52.js +1 -1
  49. package/lib/53.js +1 -1
  50. package/lib/54.js +1 -1
  51. package/lib/55.js +1 -1
  52. package/lib/56.js +1 -1
  53. package/lib/57.js +1 -1
  54. package/lib/58.js +1 -1
  55. package/lib/59.js +1 -1
  56. package/lib/6.js +1 -1
  57. package/lib/60.js +1 -1
  58. package/lib/61.js +1 -1
  59. package/lib/62.js +1 -1
  60. package/lib/63.js +1 -1
  61. package/lib/64.js +1 -1
  62. package/lib/65.js +1 -1
  63. package/lib/66.js +1 -1
  64. package/lib/67.js +1 -1
  65. package/lib/68.js +1 -1
  66. package/lib/69.js +1 -1
  67. package/lib/7.js +1 -1
  68. package/lib/70.js +1 -1
  69. package/lib/71.js +1 -1
  70. package/lib/72.js +1 -1
  71. package/lib/73.js +1 -1
  72. package/lib/74.js +1 -1
  73. package/lib/75.js +1 -1
  74. package/lib/76.js +1 -1
  75. package/lib/77.js +1 -1
  76. package/lib/78.js +1 -1
  77. package/lib/79.js +1 -1
  78. package/lib/8.js +1 -1
  79. package/lib/80.js +1 -1
  80. package/lib/81.js +1 -1
  81. package/lib/9.js +1 -1
  82. package/lib/account-login.js +837 -862
  83. package/lib/alert.js +2 -2
  84. package/lib/aside.js +2 -2
  85. package/lib/audit-trajectory.js +4 -4
  86. package/lib/autocomplete.js +1813 -1988
  87. package/lib/avatar.js +2 -2
  88. package/lib/backtop.js +2 -2
  89. package/lib/badge.js +2 -2
  90. package/lib/breadcrumb-item.js +4 -4
  91. package/lib/breadcrumb.js +4 -4
  92. package/lib/button-group.js +4 -4
  93. package/lib/button.js +2 -2
  94. package/lib/ca-login.js +837 -862
  95. package/lib/calendar.js +839 -864
  96. package/lib/card.js +2 -2
  97. package/lib/carousel-item.js +846 -871
  98. package/lib/carousel.js +839 -864
  99. package/lib/cascader-panel.js +852 -877
  100. package/lib/cascader.js +2048 -2223
  101. package/lib/checkbox-button.js +4 -4
  102. package/lib/checkbox-group.js +859 -884
  103. package/lib/checkbox.js +4 -4
  104. package/lib/col.js +2 -2
  105. package/lib/collapse-item.js +1040 -1065
  106. package/lib/collapse.js +1040 -1065
  107. package/lib/color-picker.js +972 -1122
  108. package/lib/container.js +2 -2
  109. package/lib/cron.js +12 -12
  110. package/lib/data-table.js +843 -868
  111. package/lib/date-picker.js +10520 -10695
  112. package/lib/descriptions-item.js +4 -4
  113. package/lib/descriptions.js +4 -4
  114. package/lib/dialog.js +837 -862
  115. package/lib/divider.js +2 -2
  116. package/lib/drawer.js +2 -2
  117. package/lib/dropdown-item.js +4 -4
  118. package/lib/dropdown-menu.js +974 -1124
  119. package/lib/dropdown.js +841 -866
  120. package/lib/email-login.js +837 -862
  121. package/lib/empty.js +2 -2
  122. package/lib/eoss.common.js +4023 -2668
  123. package/lib/flip.js +2 -2
  124. package/lib/flow-group.js +853 -878
  125. package/lib/flow.js +868 -893
  126. package/lib/flows.js +854 -879
  127. package/lib/footer.js +2 -2
  128. package/lib/form-item.js +860 -885
  129. package/lib/form.js +933 -950
  130. package/lib/guide.js +2 -2
  131. package/lib/header.js +2 -2
  132. package/lib/icon.js +837 -862
  133. package/lib/icons.js +2 -2
  134. package/lib/image-viewer.js +837 -862
  135. package/lib/image.js +4 -4
  136. package/lib/index.js +1 -1
  137. package/lib/infinite-scroll.js +2 -2
  138. package/lib/input-number.js +6 -6
  139. package/lib/input.js +839 -864
  140. package/lib/link.js +2 -2
  141. package/lib/loading.js +2 -2
  142. package/lib/login.js +867 -891
  143. package/lib/lowcode-view.js +1843 -1185
  144. package/lib/lowcode.js +3050 -1569
  145. package/lib/main.js +970 -988
  146. package/lib/marquee.js +837 -862
  147. package/lib/menu-item-group.js +15 -15
  148. package/lib/menu-item.js +6 -6
  149. package/lib/menu.js +2227 -2368
  150. package/lib/message-box.js +843 -868
  151. package/lib/message.js +839 -864
  152. package/lib/notification.js +861 -886
  153. package/lib/option-group.js +4 -4
  154. package/lib/option.js +839 -864
  155. package/lib/page-header.js +2 -2
  156. package/lib/pagination.js +839 -864
  157. package/lib/phone-login.js +847 -866
  158. package/lib/popconfirm.js +4 -4
  159. package/lib/popover.js +1831 -2006
  160. package/lib/process-config.js +839 -864
  161. package/lib/process-module.js +846 -871
  162. package/lib/process-rule.js +905 -930
  163. package/lib/progress.js +2 -2
  164. package/lib/qr-code.js +4 -4
  165. package/lib/qrcode-login.js +839 -864
  166. package/lib/radio-button.js +4 -4
  167. package/lib/radio-group.js +850 -875
  168. package/lib/radio.js +4 -4
  169. package/lib/rate.js +837 -862
  170. package/lib/retrial-auth.js +837 -862
  171. package/lib/row.js +2 -2
  172. package/lib/scrollbar.js +839 -864
  173. package/lib/select.js +2139 -2314
  174. package/lib/selector-panel.js +940 -965
  175. package/lib/selector.js +852 -877
  176. package/lib/slider.js +4 -4
  177. package/lib/step.js +32 -32
  178. package/lib/steps.js +874 -899
  179. package/lib/submenu.js +1269 -1385
  180. package/lib/switch.js +839 -864
  181. package/lib/tab-pane.js +4 -4
  182. package/lib/table-column.js +840 -865
  183. package/lib/table.js +1825 -2000
  184. package/lib/tabs.js +846 -871
  185. package/lib/tag.js +2 -2
  186. package/lib/theme-chalk/fonts/iconfont.ttf +0 -0
  187. package/lib/theme-chalk/fonts/iconfont.woff +0 -0
  188. package/lib/theme-chalk/index.css +1 -1
  189. package/lib/theme-chalk/lowcode.css +1 -1
  190. package/lib/time-picker.js +6471 -6646
  191. package/lib/time-select.js +5039 -5214
  192. package/lib/timeline-item.js +2 -2
  193. package/lib/timeline.js +2 -2
  194. package/lib/tips.js +837 -862
  195. package/lib/toolbar.js +4 -4
  196. package/lib/tooltip.js +1813 -1988
  197. package/lib/transfer.js +837 -862
  198. package/lib/tree-group.js +853 -878
  199. package/lib/tree.js +1026 -1051
  200. package/lib/update-history.js +4 -4
  201. package/lib/upload.js +859 -884
  202. package/lib/wujie.js +841 -866
  203. package/package.json +1 -1
  204. package/packages/flow-group/src/main.vue +2 -2
  205. package/packages/form/src/form-item-render.vue +1 -0
  206. package/packages/form/src/form-item.vue +12 -6
  207. package/packages/form/src/form.vue +5 -5
  208. package/packages/login/src/login.vue +1 -0
  209. package/packages/lowcode/src/attribute/function.vue +28 -9
  210. package/packages/lowcode/src/attribute/props.vue +202 -0
  211. package/packages/lowcode/src/attribute/styles.vue +79 -5
  212. package/packages/lowcode/src/attribute.vue +61 -4
  213. package/packages/lowcode/src/canvas.vue +159 -2
  214. package/packages/lowcode/src/form-render.vue +305 -0
  215. package/packages/lowcode/src/lowcode.vue +33 -13
  216. package/packages/lowcode/src/modules.vue +53 -37
  217. package/packages/lowcode/src/render.vue +80 -25
  218. package/packages/lowcode/src/util/components.js +100 -0
  219. package/packages/lowcode/src/util/props-util.js +67 -0
  220. package/packages/lowcode/src/util/source-generator.js +69 -9
  221. package/packages/lowcode/src/util/source-parser.js +64 -10
  222. package/packages/lowcode-view/src/render.vue +48 -18
  223. package/packages/main/src/components/userinfo.vue +0 -1
  224. package/packages/menu/src/menu-item-group.vue +1 -1
  225. package/packages/menu/src/mixins.js +8 -4
  226. package/packages/menu/src/submenu.vue +35 -5
  227. package/packages/phone-login/src/phone-login.vue +5 -2
  228. package/packages/theme-chalk/dist/fonts/iconfont.ttf +0 -0
  229. package/packages/theme-chalk/dist/fonts/iconfont.woff +0 -0
  230. package/packages/theme-chalk/src/fonts/iconfont.ttf +0 -0
  231. package/packages/theme-chalk/src/fonts/iconfont.woff +0 -0
  232. package/packages/theme-chalk/src/lowcode.scss +21 -2
  233. package/src/index.js +336 -336
package/lib/table.js CHANGED
@@ -82,7 +82,7 @@ module.exports =
82
82
  /******/
83
83
  /******/
84
84
  /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 188);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 195);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -4895,7 +4895,7 @@ module.exports = require("eoss/lib/input");
4895
4895
 
4896
4896
  /***/ }),
4897
4897
 
4898
- /***/ 152:
4898
+ /***/ 156:
4899
4899
  /***/ (function(module, exports) {
4900
4900
 
4901
4901
  module.exports = require("normalize-wheel");
@@ -4923,7 +4923,14 @@ module.exports = require("lodash/set");
4923
4923
 
4924
4924
  /***/ }),
4925
4925
 
4926
- /***/ 188:
4926
+ /***/ 19:
4927
+ /***/ (function(module, exports) {
4928
+
4929
+ module.exports = require("lodash/cloneDeep");
4930
+
4931
+ /***/ }),
4932
+
4933
+ /***/ 195:
4927
4934
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4928
4935
 
4929
4936
  "use strict";
@@ -5514,7 +5521,7 @@ var external_throttle_debounce_ = __webpack_require__(24);
5514
5521
  var resize_event = __webpack_require__(38);
5515
5522
 
5516
5523
  // EXTERNAL MODULE: external "normalize-wheel"
5517
- var external_normalize_wheel_ = __webpack_require__(152);
5524
+ var external_normalize_wheel_ = __webpack_require__(156);
5518
5525
  var external_normalize_wheel_default = /*#__PURE__*/__webpack_require__.n(external_normalize_wheel_);
5519
5526
 
5520
5527
  // CONCATENATED MODULE: ./src/directives/mousewheel.js
@@ -6778,7 +6785,7 @@ var doFlattenColumns = function doFlattenColumns(columns) {
6778
6785
  }
6779
6786
  }));
6780
6787
  // EXTERNAL MODULE: ./packages/table/src/config.js
6781
- var src_config = __webpack_require__(87);
6788
+ var src_config = __webpack_require__(89);
6782
6789
 
6783
6790
  // EXTERNAL MODULE: ./src/utils/ajax.js
6784
6791
  var ajax = __webpack_require__(10);
@@ -8431,7 +8438,7 @@ var tooltip_default = /*#__PURE__*/__webpack_require__.n(tooltip_);
8431
8438
  }
8432
8439
  });
8433
8440
  // EXTERNAL MODULE: external "sortablejs"
8434
- var external_sortablejs_ = __webpack_require__(56);
8441
+ var external_sortablejs_ = __webpack_require__(55);
8435
8442
  var external_sortablejs_default = /*#__PURE__*/__webpack_require__.n(external_sortablejs_);
8436
8443
 
8437
8444
  // CONCATENATED MODULE: ./packages/table/src/table-body.js
@@ -11493,7 +11500,7 @@ var table_footer_typeof = typeof Symbol === "function" && typeof Symbol.iterator
11493
11500
  }
11494
11501
  });
11495
11502
  // EXTERNAL MODULE: ./src/components/bar.js
11496
- var bar = __webpack_require__(58);
11503
+ var bar = __webpack_require__(59);
11497
11504
 
11498
11505
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/table/src/table.vue?vue&type=script&lang=js&
11499
11506
  var tablevue_type_script_lang_js_extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
@@ -13241,13 +13248,6 @@ src_table.install = function (Vue) {
13241
13248
 
13242
13249
  /***/ }),
13243
13250
 
13244
- /***/ 19:
13245
- /***/ (function(module, exports) {
13246
-
13247
- module.exports = require("lodash/cloneDeep");
13248
-
13249
- /***/ }),
13250
-
13251
13251
  /***/ 2:
13252
13252
  /***/ (function(module, exports) {
13253
13253
 
@@ -13505,7 +13505,7 @@ module.exports = require("throttle-debounce");
13505
13505
 
13506
13506
 
13507
13507
 
13508
- var PopperJS = vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer ? function () {} : __webpack_require__(52);
13508
+ var PopperJS = vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer ? function () {} : __webpack_require__(53);
13509
13509
  var stopPropagation = function stopPropagation(e) {
13510
13510
  return e.stopPropagation();
13511
13511
  };
@@ -14132,7 +14132,7 @@ var scrollBarWidth = void 0;
14132
14132
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return setColumnRenders; });
14133
14133
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return renderDom; });
14134
14134
  /* harmony import */ var eoss_src_utils_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
14135
- /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(87);
14135
+ /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(89);
14136
14136
  var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
14137
14137
 
14138
14138
  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; };
@@ -16036,10 +16036,12 @@ function insertAfter(newEl, targetEl) {
16036
16036
 
16037
16037
  /***/ }),
16038
16038
 
16039
- /***/ 52:
16039
+ /***/ 53:
16040
16040
  /***/ (function(module, exports, __webpack_require__) {
16041
16041
 
16042
- var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
16042
+ 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; };
16043
+
16044
+ /**
16043
16045
  * @fileOverview Kickass library to create and place poppers near their reference elements.
16044
16046
  * @version {{version}}
16045
16047
  * @license
@@ -16062,68 +16064,60 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
16062
16064
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16063
16065
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16064
16066
  * SOFTWARE.
16065
- */
16066
-
16067
- //
16068
- // Cross module loader
16069
- // Supported: Node, AMD, Browser globals
16070
- //
16071
- (function (root, factory) {
16072
- if (true) {
16073
- // AMD. Register as an anonymous module.
16067
+ */
16068
+
16069
+ //
16070
+ // Cross module loader
16071
+ // Supported: Node, AMD, Browser globals
16072
+ //
16073
+ (function (root, factory) {
16074
+ if (true) {
16075
+ // AMD. Register as an anonymous module.
16074
16076
  !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
16075
16077
  __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
16076
16078
  (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
16077
16079
  __WEBPACK_AMD_DEFINE_FACTORY__),
16078
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
16079
- } else {}
16080
- })(this, function () {
16081
- 'use strict';
16082
-
16083
- var root = window;
16084
- // default options
16085
- var DEFAULTS = {
16086
- // placement of the popper
16087
- placement: 'bottom',
16088
-
16089
- gpuAcceleration: true,
16090
-
16091
- // shift popper from its origin by the given amount of pixels (can be negative)
16092
- offset: 0,
16093
-
16094
- // the element which will act as boundary of the popper
16095
- boundariesElement: 'viewport',
16096
-
16097
- // amount of pixel used to define a minimum distance between the boundaries and the popper
16098
- boundariesPadding: 5,
16099
-
16100
- // popper will try to prevent overflow following this order,
16101
- // by default, then, it could overflow on the left and on top of the boundariesElement
16102
- preventOverflowOrder: ['left', 'right', 'top', 'bottom'],
16103
-
16104
- // the behavior used by flip to change the placement of the popper
16105
- flipBehavior: 'flip',
16106
-
16107
- arrowElement: '[x-arrow]',
16108
-
16109
- arrowOffset: 0,
16110
-
16111
- // list of functions used to modify the offsets before they are applied to the popper
16112
- modifiers: [
16113
- 'shift',
16114
- 'offset',
16115
- 'preventOverflow',
16116
- 'keepTogether',
16117
- 'arrow',
16118
- 'flip',
16119
- 'applyStyle'
16120
- ],
16121
-
16122
- modifiersIgnored: [],
16123
-
16124
- forceAbsolute: false
16125
- };
16126
-
16080
+ __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
16081
+ } else {}
16082
+ })(this, function () {
16083
+ 'use strict';
16084
+
16085
+ var root = window;
16086
+ // default options
16087
+ var DEFAULTS = {
16088
+ // placement of the popper
16089
+ placement: 'bottom',
16090
+
16091
+ gpuAcceleration: true,
16092
+
16093
+ // shift popper from its origin by the given amount of pixels (can be negative)
16094
+ offset: 0,
16095
+
16096
+ // the element which will act as boundary of the popper
16097
+ boundariesElement: 'viewport',
16098
+
16099
+ // amount of pixel used to define a minimum distance between the boundaries and the popper
16100
+ boundariesPadding: 5,
16101
+
16102
+ // popper will try to prevent overflow following this order,
16103
+ // by default, then, it could overflow on the left and on top of the boundariesElement
16104
+ preventOverflowOrder: ['left', 'right', 'top', 'bottom'],
16105
+
16106
+ // the behavior used by flip to change the placement of the popper
16107
+ flipBehavior: 'flip',
16108
+
16109
+ arrowElement: '[x-arrow]',
16110
+
16111
+ arrowOffset: 0,
16112
+
16113
+ // list of functions used to modify the offsets before they are applied to the popper
16114
+ modifiers: ['shift', 'offset', 'preventOverflow', 'keepTogether', 'arrow', 'flip', 'applyStyle'],
16115
+
16116
+ modifiersIgnored: [],
16117
+
16118
+ forceAbsolute: false
16119
+ };
16120
+
16127
16121
  /**
16128
16122
  * Create a new Popper.js instance
16129
16123
  * @constructor Popper
@@ -16188,125 +16182,114 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
16188
16182
  *
16189
16183
  * @param {Boolean} [options.removeOnDestroy=false]
16190
16184
  * Set to true if you want to automatically remove the popper when you call the `destroy` method.
16191
- */
16192
- function Popper(reference, popper, options) {
16193
- this._reference = reference.jquery ? reference[0] : reference;
16194
- this.state = {};
16195
-
16196
- // if the popper variable is a configuration object, parse it to generate an HTMLElement
16197
- // generate a default popper if is not defined
16198
- var isNotDefined = typeof popper === 'undefined' || popper === null;
16199
- var isConfig =
16200
- popper && Object.prototype.toString.call(popper) === '[object Object]';
16201
- if (isNotDefined || isConfig) {
16202
- this._popper = this.parse(isConfig ? popper : {});
16203
- }
16204
- // otherwise, use the given HTMLElement as popper
16205
- else {
16206
- this._popper = popper.jquery ? popper[0] : popper;
16207
- }
16208
-
16209
- // with {} we create a new object with the options inside it
16210
- this._options = Object.assign({}, DEFAULTS, options);
16211
-
16212
- // refactoring modifiers' list
16213
- this._options.modifiers = this._options.modifiers.map(
16214
- function (modifier) {
16215
- // remove ignored modifiers
16216
- if (this._options.modifiersIgnored.indexOf(modifier) !== -1) return;
16217
-
16218
- // set the x-placement attribute before everything else because it could be used to add margins to the popper
16219
- // margins needs to be calculated to get the correct popper offsets
16220
- if (modifier === 'applyStyle') {
16221
- this._popper.setAttribute('x-placement', this._options.placement);
16222
- }
16223
-
16224
- // return predefined modifier identified by string or keep the custom one
16225
- return this.modifiers[modifier] || modifier;
16226
- }.bind(this)
16227
- );
16228
-
16229
- // make sure to apply the popper position before any computation
16230
- this.state.position = this._getPosition(this._popper, this._reference);
16231
- setStyle(this._popper, { position: this.state.position, top: 0 });
16232
-
16233
- // fire the first update to position the popper in the right place
16234
- this.update();
16235
-
16236
- // setup event listeners, they will take care of update the position in specific situations
16237
- this._setupEventListeners();
16238
- return this;
16239
- }
16240
-
16241
- //
16242
- // Methods
16243
- //
16185
+ */
16186
+ function Popper(reference, popper, options) {
16187
+ this._reference = reference.jquery ? reference[0] : reference;
16188
+ this.state = {};
16189
+
16190
+ // if the popper variable is a configuration object, parse it to generate an HTMLElement
16191
+ // generate a default popper if is not defined
16192
+ var isNotDefined = typeof popper === 'undefined' || popper === null;
16193
+ var isConfig = popper && Object.prototype.toString.call(popper) === '[object Object]';
16194
+ if (isNotDefined || isConfig) {
16195
+ this._popper = this.parse(isConfig ? popper : {});
16196
+ }
16197
+ // otherwise, use the given HTMLElement as popper
16198
+ else {
16199
+ this._popper = popper.jquery ? popper[0] : popper;
16200
+ }
16201
+
16202
+ // with {} we create a new object with the options inside it
16203
+ this._options = Object.assign({}, DEFAULTS, options);
16204
+
16205
+ // refactoring modifiers' list
16206
+ this._options.modifiers = this._options.modifiers.map(function (modifier) {
16207
+ // remove ignored modifiers
16208
+ if (this._options.modifiersIgnored.indexOf(modifier) !== -1) return;
16209
+
16210
+ // set the x-placement attribute before everything else because it could be used to add margins to the popper
16211
+ // margins needs to be calculated to get the correct popper offsets
16212
+ if (modifier === 'applyStyle') {
16213
+ this._popper.setAttribute('x-placement', this._options.placement);
16214
+ }
16215
+
16216
+ // return predefined modifier identified by string or keep the custom one
16217
+ return this.modifiers[modifier] || modifier;
16218
+ }.bind(this));
16219
+
16220
+ // make sure to apply the popper position before any computation
16221
+ this.state.position = this._getPosition(this._popper, this._reference);
16222
+ setStyle(this._popper, { position: this.state.position, top: 0 });
16223
+
16224
+ // fire the first update to position the popper in the right place
16225
+ this.update();
16226
+
16227
+ // setup event listeners, they will take care of update the position in specific situations
16228
+ this._setupEventListeners();
16229
+ return this;
16230
+ }
16231
+
16232
+ //
16233
+ // Methods
16234
+ //
16244
16235
  /**
16245
16236
  * Destroy the popper
16246
16237
  * @method
16247
16238
  * @memberof Popper
16248
- */
16249
- Popper.prototype.destroy = function () {
16250
- this._popper.removeAttribute('x-placement');
16251
- this._popper.style.left = '';
16252
- this._popper.style.position = '';
16253
- this._popper.style.top = '';
16254
- this._popper.style[getSupportedPropertyName('transform')] = '';
16255
- this._removeEventListeners();
16256
-
16257
- // remove the popper if user explicity asked for the deletion on destroy
16258
- if (this._options.removeOnDestroy) {
16259
- this._popper.remove();
16260
- }
16261
- return this;
16262
- };
16263
-
16239
+ */
16240
+ Popper.prototype.destroy = function () {
16241
+ this._popper.removeAttribute('x-placement');
16242
+ this._popper.style.left = '';
16243
+ this._popper.style.position = '';
16244
+ this._popper.style.top = '';
16245
+ this._popper.style[getSupportedPropertyName('transform')] = '';
16246
+ this._removeEventListeners();
16247
+
16248
+ // remove the popper if user explicity asked for the deletion on destroy
16249
+ if (this._options.removeOnDestroy) {
16250
+ this._popper.remove();
16251
+ }
16252
+ return this;
16253
+ };
16254
+
16264
16255
  /**
16265
16256
  * Updates the position of the popper, computing the new offsets and applying the new style
16266
16257
  * @method
16267
16258
  * @memberof Popper
16268
- */
16269
- Popper.prototype.update = function () {
16270
- var data = { instance: this, styles: {} };
16271
-
16272
- // store placement inside the data object, modifiers will be able to edit `placement` if needed
16273
- // and refer to _originalPlacement to know the original value
16274
- data.placement = this._options.placement;
16275
- data._originalPlacement = this._options.placement;
16276
-
16277
- // compute the popper and reference offsets and put them inside data.offsets
16278
- data.offsets = this._getOffsets(
16279
- this._popper,
16280
- this._reference,
16281
- data.placement
16282
- );
16283
-
16284
- // get boundaries
16285
- data.boundaries = this._getBoundaries(
16286
- data,
16287
- this._options.boundariesPadding,
16288
- this._options.boundariesElement
16289
- );
16290
-
16291
- data = this.runModifiers(data, this._options.modifiers);
16292
-
16293
- if (typeof this.state.updateCallback === 'function') {
16294
- this.state.updateCallback(data);
16295
- }
16296
- };
16297
-
16259
+ */
16260
+ Popper.prototype.update = function () {
16261
+ var data = { instance: this, styles: {} };
16262
+
16263
+ // store placement inside the data object, modifiers will be able to edit `placement` if needed
16264
+ // and refer to _originalPlacement to know the original value
16265
+ data.placement = this._options.placement;
16266
+ data._originalPlacement = this._options.placement;
16267
+
16268
+ // compute the popper and reference offsets and put them inside data.offsets
16269
+ data.offsets = this._getOffsets(this._popper, this._reference, data.placement);
16270
+
16271
+ // get boundaries
16272
+ data.boundaries = this._getBoundaries(data, this._options.boundariesPadding, this._options.boundariesElement);
16273
+
16274
+ data = this.runModifiers(data, this._options.modifiers);
16275
+
16276
+ if (typeof this.state.updateCallback === 'function') {
16277
+ this.state.updateCallback(data);
16278
+ }
16279
+ };
16280
+
16298
16281
  /**
16299
16282
  * If a function is passed, it will be executed after the initialization of popper with as first argument the Popper instance.
16300
16283
  * @method
16301
16284
  * @memberof Popper
16302
16285
  * @param {Function} callback
16303
- */
16304
- Popper.prototype.onCreate = function (callback) {
16305
- // the createCallbacks return as first argument the popper instance
16306
- callback(this);
16307
- return this;
16308
- };
16309
-
16286
+ */
16287
+ Popper.prototype.onCreate = function (callback) {
16288
+ // the createCallbacks return as first argument the popper instance
16289
+ callback(this);
16290
+ return this;
16291
+ };
16292
+
16310
16293
  /**
16311
16294
  * If a function is passed, it will be executed after each update of popper with as first argument the set of coordinates and informations
16312
16295
  * used to style popper and its arrow.
@@ -16314,101 +16297,93 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
16314
16297
  * @method
16315
16298
  * @memberof Popper
16316
16299
  * @param {Function} callback
16317
- */
16318
- Popper.prototype.onUpdate = function (callback) {
16319
- this.state.updateCallback = callback;
16320
- return this;
16321
- };
16322
-
16300
+ */
16301
+ Popper.prototype.onUpdate = function (callback) {
16302
+ this.state.updateCallback = callback;
16303
+ return this;
16304
+ };
16305
+
16323
16306
  /**
16324
16307
  * Helper used to generate poppers from a configuration file
16325
16308
  * @method
16326
16309
  * @memberof Popper
16327
16310
  * @param config {Object} configuration
16328
16311
  * @returns {HTMLElement} popper
16329
- */
16330
- Popper.prototype.parse = function (config) {
16331
- var defaultConfig = {
16332
- tagName: 'div',
16333
- classNames: ['popper'],
16334
- attributes: [],
16335
- parent: root.document.body,
16336
- content: '',
16337
- contentType: 'text',
16338
- arrowTagName: 'div',
16339
- arrowClassNames: ['popper__arrow'],
16340
- arrowAttributes: ['x-arrow']
16341
- };
16342
- config = Object.assign({}, defaultConfig, config);
16343
-
16344
- var d = root.document;
16345
-
16346
- var popper = d.createElement(config.tagName);
16347
- addClassNames(popper, config.classNames);
16348
- addAttributes(popper, config.attributes);
16349
- if (config.contentType === 'node') {
16350
- popper.appendChild(
16351
- config.content.jquery ? config.content[0] : config.content
16352
- );
16353
- } else if (config.contentType === 'html') {
16354
- popper.innerHTML = config.content;
16355
- } else {
16356
- popper.textContent = config.content;
16357
- }
16358
-
16359
- if (config.arrowTagName) {
16360
- var arrow = d.createElement(config.arrowTagName);
16361
- addClassNames(arrow, config.arrowClassNames);
16362
- addAttributes(arrow, config.arrowAttributes);
16363
- popper.appendChild(arrow);
16364
- }
16365
-
16366
- var parent = config.parent.jquery ? config.parent[0] : config.parent;
16367
-
16368
- // if the given parent is a string, use it to match an element
16369
- // if more than one element is matched, the first one will be used as parent
16370
- // if no elements are matched, the script will throw an error
16371
- if (typeof parent === 'string') {
16372
- parent = d.querySelectorAll(config.parent);
16373
- if (parent.length > 1) {
16374
- console.warn(
16375
- 'WARNING: the given `parent` query(' +
16376
- config.parent +
16377
- ') matched more than one element, the first one will be used'
16378
- );
16379
- }
16380
- if (parent.length === 0) {
16381
- throw "ERROR: the given `parent` doesn't exists!";
16382
- }
16383
- parent = parent[0];
16384
- }
16385
- // if the given parent is a DOM nodes list or an array of nodes with more than one element,
16386
- // the first one will be used as parent
16387
- if (parent.length > 1 && parent instanceof Element === false) {
16388
- console.warn(
16389
- 'WARNING: you have passed as parent a list of elements, the first one will be used'
16390
- );
16391
- parent = parent[0];
16392
- }
16393
-
16394
- // append the generated popper to its parent
16395
- parent.appendChild(popper);
16396
-
16397
- return popper;
16398
-
16312
+ */
16313
+ Popper.prototype.parse = function (config) {
16314
+ var defaultConfig = {
16315
+ tagName: 'div',
16316
+ classNames: ['popper'],
16317
+ attributes: [],
16318
+ parent: root.document.body,
16319
+ content: '',
16320
+ contentType: 'text',
16321
+ arrowTagName: 'div',
16322
+ arrowClassNames: ['popper__arrow'],
16323
+ arrowAttributes: ['x-arrow']
16324
+ };
16325
+ config = Object.assign({}, defaultConfig, config);
16326
+
16327
+ var d = root.document;
16328
+
16329
+ var popper = d.createElement(config.tagName);
16330
+ addClassNames(popper, config.classNames);
16331
+ addAttributes(popper, config.attributes);
16332
+ if (config.contentType === 'node') {
16333
+ popper.appendChild(config.content.jquery ? config.content[0] : config.content);
16334
+ } else if (config.contentType === 'html') {
16335
+ popper.innerHTML = config.content;
16336
+ } else {
16337
+ popper.textContent = config.content;
16338
+ }
16339
+
16340
+ if (config.arrowTagName) {
16341
+ var arrow = d.createElement(config.arrowTagName);
16342
+ addClassNames(arrow, config.arrowClassNames);
16343
+ addAttributes(arrow, config.arrowAttributes);
16344
+ popper.appendChild(arrow);
16345
+ }
16346
+
16347
+ var parent = config.parent.jquery ? config.parent[0] : config.parent;
16348
+
16349
+ // if the given parent is a string, use it to match an element
16350
+ // if more than one element is matched, the first one will be used as parent
16351
+ // if no elements are matched, the script will throw an error
16352
+ if (typeof parent === 'string') {
16353
+ parent = d.querySelectorAll(config.parent);
16354
+ if (parent.length > 1) {
16355
+ console.warn('WARNING: the given `parent` query(' + config.parent + ') matched more than one element, the first one will be used');
16356
+ }
16357
+ if (parent.length === 0) {
16358
+ throw "ERROR: the given `parent` doesn't exists!";
16359
+ }
16360
+ parent = parent[0];
16361
+ }
16362
+ // if the given parent is a DOM nodes list or an array of nodes with more than one element,
16363
+ // the first one will be used as parent
16364
+ if (parent.length > 1 && parent instanceof Element === false) {
16365
+ console.warn('WARNING: you have passed as parent a list of elements, the first one will be used');
16366
+ parent = parent[0];
16367
+ }
16368
+
16369
+ // append the generated popper to its parent
16370
+ parent.appendChild(popper);
16371
+
16372
+ return popper;
16373
+
16399
16374
  /**
16400
16375
  * Adds class names to the given element
16401
16376
  * @function
16402
16377
  * @ignore
16403
16378
  * @param {HTMLElement} target
16404
16379
  * @param {Array} classes
16405
- */
16406
- function addClassNames(element, classNames) {
16407
- classNames.forEach(function (className) {
16408
- element.classList.add(className);
16409
- });
16410
- }
16411
-
16380
+ */
16381
+ function addClassNames(element, classNames) {
16382
+ classNames.forEach(function (className) {
16383
+ element.classList.add(className);
16384
+ });
16385
+ }
16386
+
16412
16387
  /**
16413
16388
  * Adds attributes to the given element
16414
16389
  * @function
@@ -16417,17 +16392,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
16417
16392
  * @param {Array} attributes
16418
16393
  * @example
16419
16394
  * addAttributes(element, [ 'data-info:foobar' ]);
16420
- */
16421
- function addAttributes(element, attributes) {
16422
- attributes.forEach(function (attribute) {
16423
- element.setAttribute(
16424
- attribute.split(':')[0],
16425
- attribute.split(':')[1] || ''
16426
- );
16427
- });
16428
- }
16429
- };
16430
-
16395
+ */
16396
+ function addAttributes(element, attributes) {
16397
+ attributes.forEach(function (attribute) {
16398
+ element.setAttribute(attribute.split(':')[0], attribute.split(':')[1] || '');
16399
+ });
16400
+ }
16401
+ };
16402
+
16431
16403
  /**
16432
16404
  * Helper used to get the position which will be applied to the popper
16433
16405
  * @method
@@ -16435,20 +16407,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
16435
16407
  * @param config {HTMLElement} popper element
16436
16408
  * @param reference {HTMLElement} reference element
16437
16409
  * @returns {String} position
16438
- */
16439
- Popper.prototype._getPosition = function (popper, reference) {
16440
- var container = getOffsetParent(reference);
16441
-
16442
- if (this._options.forceAbsolute) {
16443
- return 'absolute';
16444
- }
16445
-
16446
- // Decide if the popper will be fixed
16447
- // If the reference element is inside a fixed context, the popper will be fixed as well to allow them to scroll together
16448
- var isParentFixed = isFixed(reference, container);
16449
- return isParentFixed ? 'fixed' : 'absolute';
16450
- };
16451
-
16410
+ */
16411
+ Popper.prototype._getPosition = function (popper, reference) {
16412
+ var container = getOffsetParent(reference);
16413
+
16414
+ if (this._options.forceAbsolute) {
16415
+ return 'absolute';
16416
+ }
16417
+
16418
+ // Decide if the popper will be fixed
16419
+ // If the reference element is inside a fixed context, the popper will be fixed as well to allow them to scroll together
16420
+ var isParentFixed = isFixed(reference, container);
16421
+ return isParentFixed ? 'fixed' : 'absolute';
16422
+ };
16423
+
16452
16424
  /**
16453
16425
  * Get offsets to the popper
16454
16426
  * @method
@@ -16457,110 +16429,91 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
16457
16429
  * @param {Element} popper - the popper element
16458
16430
  * @param {Element} reference - the reference element (the popper will be relative to this)
16459
16431
  * @returns {Object} An object containing the offsets which will be applied to the popper
16460
- */
16461
- Popper.prototype._getOffsets = function (popper, reference, placement) {
16462
- placement = placement.split('-')[0];
16463
- var popperOffsets = {};
16464
-
16465
- popperOffsets.position = this.state.position;
16466
- var isParentFixed = popperOffsets.position === 'fixed';
16467
-
16468
- //
16469
- // Get reference element position
16470
- //
16471
- var referenceOffsets = getOffsetRectRelativeToCustomParent(
16472
- reference,
16473
- popper,
16474
- isParentFixed
16475
- );
16476
-
16477
- //
16478
- // Get popper sizes
16479
- //
16480
- var popperRect = getOuterSizes(popper);
16481
-
16482
- //
16483
- // Compute offsets of popper
16484
- //
16485
-
16486
- // depending by the popper placement we have to compute its offsets slightly differently
16487
- if (['right', 'left'].indexOf(placement) !== -1) {
16488
- popperOffsets.top =
16489
- referenceOffsets.top +
16490
- referenceOffsets.height / 2 -
16491
- popperRect.height / 2;
16492
- if (placement === 'left') {
16493
- popperOffsets.left = referenceOffsets.left - popperRect.width;
16494
- } else {
16495
- popperOffsets.left = referenceOffsets.right;
16496
- }
16497
- } else {
16498
- popperOffsets.left =
16499
- referenceOffsets.left +
16500
- referenceOffsets.width / 2 -
16501
- popperRect.width / 2;
16502
- if (placement === 'top') {
16503
- popperOffsets.top = referenceOffsets.top - popperRect.height;
16504
- } else {
16505
- popperOffsets.top = referenceOffsets.bottom;
16506
- }
16507
- }
16508
-
16509
- // Add width and height to our offsets object
16510
- popperOffsets.width = popperRect.width;
16511
- popperOffsets.height = popperRect.height;
16512
-
16513
- return {
16514
- popper: popperOffsets,
16515
- reference: referenceOffsets
16516
- };
16517
- };
16518
-
16432
+ */
16433
+ Popper.prototype._getOffsets = function (popper, reference, placement) {
16434
+ placement = placement.split('-')[0];
16435
+ var popperOffsets = {};
16436
+
16437
+ popperOffsets.position = this.state.position;
16438
+ var isParentFixed = popperOffsets.position === 'fixed';
16439
+
16440
+ //
16441
+ // Get reference element position
16442
+ //
16443
+ var referenceOffsets = getOffsetRectRelativeToCustomParent(reference, popper, isParentFixed);
16444
+
16445
+ //
16446
+ // Get popper sizes
16447
+ //
16448
+ var popperRect = getOuterSizes(popper);
16449
+
16450
+ //
16451
+ // Compute offsets of popper
16452
+ //
16453
+
16454
+ // depending by the popper placement we have to compute its offsets slightly differently
16455
+ if (['right', 'left'].indexOf(placement) !== -1) {
16456
+ popperOffsets.top = referenceOffsets.top + referenceOffsets.height / 2 - popperRect.height / 2;
16457
+ if (placement === 'left') {
16458
+ popperOffsets.left = referenceOffsets.left - popperRect.width;
16459
+ } else {
16460
+ popperOffsets.left = referenceOffsets.right;
16461
+ }
16462
+ } else {
16463
+ popperOffsets.left = referenceOffsets.left + referenceOffsets.width / 2 - popperRect.width / 2;
16464
+ if (placement === 'top') {
16465
+ popperOffsets.top = referenceOffsets.top - popperRect.height;
16466
+ } else {
16467
+ popperOffsets.top = referenceOffsets.bottom;
16468
+ }
16469
+ }
16470
+
16471
+ // Add width and height to our offsets object
16472
+ popperOffsets.width = popperRect.width;
16473
+ popperOffsets.height = popperRect.height;
16474
+
16475
+ return {
16476
+ popper: popperOffsets,
16477
+ reference: referenceOffsets
16478
+ };
16479
+ };
16480
+
16519
16481
  /**
16520
16482
  * Setup needed event listeners used to update the popper position
16521
16483
  * @method
16522
16484
  * @memberof Popper
16523
16485
  * @access private
16524
- */
16525
- Popper.prototype._setupEventListeners = function () {
16526
- // NOTE: 1 DOM access here
16527
- this.state.updateBound = this.update.bind(this);
16528
- // 无界等微前端场景下沙箱 window 不会触发 resize,需监听真实 window
16529
- this.state.realWindow = getRealWindow(this._popper);
16530
- this.state.realWindow.addEventListener('resize', this.state.updateBound);
16531
- // if the boundariesElement is window we don't need to listen for the scroll event
16532
- if (this._options.boundariesElement !== 'window') {
16533
- var target = getScrollParent(this._reference);
16534
- target.addEventListener('scroll', this.state.updateBound);
16535
- this.state.scrollTarget = target;
16536
- }
16537
- };
16538
-
16486
+ */
16487
+ Popper.prototype._setupEventListeners = function () {
16488
+ // NOTE: 1 DOM access here
16489
+ this.state.updateBound = this.update.bind(this);
16490
+ // 无界等微前端场景下沙箱 window 不会触发 resize,需监听真实 window
16491
+ this.state.realWindow = getRealWindow(this._popper);
16492
+ this.state.realWindow.addEventListener('resize', this.state.updateBound);
16493
+ // if the boundariesElement is window we don't need to listen for the scroll event
16494
+ if (this._options.boundariesElement !== 'window') {
16495
+ var target = getScrollParent(this._reference);
16496
+ target.addEventListener('scroll', this.state.updateBound);
16497
+ this.state.scrollTarget = target;
16498
+ }
16499
+ };
16500
+
16539
16501
  /**
16540
16502
  * Remove event listeners used to update the popper position
16541
16503
  * @method
16542
16504
  * @memberof Popper
16543
16505
  * @access private
16544
- */
16545
- Popper.prototype._removeEventListeners = function () {
16546
- // NOTE: 1 DOM access here
16547
- (this.state.realWindow || root).removeEventListener(
16548
- 'resize',
16549
- this.state.updateBound
16550
- );
16551
- if (
16552
- this._options.boundariesElement !== 'window' &&
16553
- this.state.scrollTarget
16554
- ) {
16555
- this.state.scrollTarget.removeEventListener(
16556
- 'scroll',
16557
- this.state.updateBound
16558
- );
16559
- this.state.scrollTarget = null;
16560
- }
16561
- this.state.updateBound = null;
16562
- };
16563
-
16506
+ */
16507
+ Popper.prototype._removeEventListeners = function () {
16508
+ // NOTE: 1 DOM access here
16509
+ (this.state.realWindow || root).removeEventListener('resize', this.state.updateBound);
16510
+ if (this._options.boundariesElement !== 'window' && this.state.scrollTarget) {
16511
+ this.state.scrollTarget.removeEventListener('scroll', this.state.updateBound);
16512
+ this.state.scrollTarget = null;
16513
+ }
16514
+ this.state.updateBound = null;
16515
+ };
16516
+
16564
16517
  /**
16565
16518
  * Computed the boundaries limits and return them
16566
16519
  * @method
@@ -16570,75 +16523,56 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
16570
16523
  * @param {Number} padding - Boundaries padding
16571
16524
  * @param {Element} boundariesElement - Element used to define the boundaries
16572
16525
  * @returns {Object} Coordinates of the boundaries
16573
- */
16574
- Popper.prototype._getBoundaries = function (data, padding, boundariesElement) {
16575
- // NOTE: 1 DOM access here
16576
- var boundaries = {};
16577
- var width, height;
16578
- if (boundariesElement === 'window') {
16579
- var body = root.document.body,
16580
- html = root.document.documentElement;
16581
-
16582
- height = Math.max(
16583
- body.scrollHeight,
16584
- body.offsetHeight,
16585
- html.clientHeight,
16586
- html.scrollHeight,
16587
- html.offsetHeight
16588
- );
16589
- width = Math.max(
16590
- body.scrollWidth,
16591
- body.offsetWidth,
16592
- html.clientWidth,
16593
- html.scrollWidth,
16594
- html.offsetWidth
16595
- );
16596
-
16597
- boundaries = {
16598
- top: 0,
16599
- right: width,
16600
- bottom: height,
16601
- left: 0
16602
- };
16603
- } else if (boundariesElement === 'viewport') {
16604
- // 将真实 window 的视口换算到 popper 所在包含块的坐标系。
16605
- // 无界等场景下沙箱 window 的尺寸、shadowRoot 内元素的 scrollTop 均不可靠,
16606
- // 统一从元素自身的 view 与真实包含块获取
16607
- var realWindow = getRealWindow(this._popper);
16608
- var containingBlockRect = getContainingBlockRect(
16609
- this._popper,
16610
- data.offsets.popper.position === 'fixed'
16611
- );
16612
-
16613
- boundaries = {
16614
- top: 0 - containingBlockRect.top,
16615
- right:
16616
- realWindow.document.documentElement.clientWidth -
16617
- containingBlockRect.left,
16618
- bottom:
16619
- realWindow.document.documentElement.clientHeight -
16620
- containingBlockRect.top,
16621
- left: 0 - containingBlockRect.left
16622
- };
16623
- } else {
16624
- if (getOffsetParent(this._popper) === boundariesElement) {
16625
- boundaries = {
16626
- top: 0,
16627
- left: 0,
16628
- right: boundariesElement.clientWidth,
16629
- bottom: boundariesElement.clientHeight
16630
- };
16631
- } else {
16632
- boundaries = getOffsetRect(boundariesElement);
16633
- }
16634
- }
16635
- boundaries.left += padding;
16636
- boundaries.right -= padding;
16637
- boundaries.top = boundaries.top + padding;
16638
- boundaries.bottom = boundaries.bottom - padding;
16639
- return boundaries;
16640
- };
16641
-
16526
+ */
16527
+ Popper.prototype._getBoundaries = function (data, padding, boundariesElement) {
16528
+ // NOTE: 1 DOM access here
16529
+ var boundaries = {};
16530
+ var width, height;
16531
+ if (boundariesElement === 'window') {
16532
+ var body = root.document.body,
16533
+ html = root.document.documentElement;
16534
+
16535
+ height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
16536
+ width = Math.max(body.scrollWidth, body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth);
16537
+
16538
+ boundaries = {
16539
+ top: 0,
16540
+ right: width,
16541
+ bottom: height,
16542
+ left: 0
16543
+ };
16544
+ } else if (boundariesElement === 'viewport') {
16545
+ // 将真实 window 的视口换算到 popper 所在包含块的坐标系。
16546
+ // 无界等场景下沙箱 window 的尺寸、shadowRoot 内元素的 scrollTop 均不可靠,
16547
+ // 统一从元素自身的 view 与真实包含块获取
16548
+ var realWindow = getRealWindow(this._popper);
16549
+ var containingBlockRect = getContainingBlockRect(this._popper, data.offsets.popper.position === 'fixed');
16550
+
16551
+ boundaries = {
16552
+ top: 0 - containingBlockRect.top,
16553
+ right: realWindow.document.documentElement.clientWidth - containingBlockRect.left,
16554
+ bottom: realWindow.document.documentElement.clientHeight - containingBlockRect.top,
16555
+ left: 0 - containingBlockRect.left
16556
+ };
16557
+ } else {
16558
+ if (getOffsetParent(this._popper) === boundariesElement) {
16559
+ boundaries = {
16560
+ top: 0,
16561
+ left: 0,
16562
+ right: boundariesElement.clientWidth,
16563
+ bottom: boundariesElement.clientHeight
16564
+ };
16565
+ } else {
16566
+ boundaries = getOffsetRect(boundariesElement);
16567
+ }
16568
+ }
16569
+ boundaries.left += padding;
16570
+ boundaries.right -= padding;
16571
+ boundaries.top = boundaries.top + padding;
16572
+ boundaries.bottom = boundaries.bottom - padding;
16573
+ return boundaries;
16574
+ };
16575
+
16642
16576
  /**
16643
16577
  * Loop trough the list of modifiers and run them in order, each of them will then edit the data object
16644
16578
  * @method
@@ -16647,27 +16581,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
16647
16581
  * @param {Object} data
16648
16582
  * @param {Array} modifiers
16649
16583
  * @param {Function} ends
16650
- */
16651
- Popper.prototype.runModifiers = function (data, modifiers, ends) {
16652
- var modifiersToRun = modifiers.slice();
16653
- if (ends !== undefined) {
16654
- modifiersToRun = this._options.modifiers.slice(
16655
- 0,
16656
- getArrayKeyIndex(this._options.modifiers, ends)
16657
- );
16658
- }
16659
-
16660
- modifiersToRun.forEach(
16661
- function (modifier) {
16662
- if (isFunction(modifier)) {
16663
- data = modifier.call(this, data);
16664
- }
16665
- }.bind(this)
16666
- );
16667
-
16668
- return data;
16669
- };
16670
-
16584
+ */
16585
+ Popper.prototype.runModifiers = function (data, modifiers, ends) {
16586
+ var modifiersToRun = modifiers.slice();
16587
+ if (ends !== undefined) {
16588
+ modifiersToRun = this._options.modifiers.slice(0, getArrayKeyIndex(this._options.modifiers, ends));
16589
+ }
16590
+
16591
+ modifiersToRun.forEach(function (modifier) {
16592
+ if (isFunction(modifier)) {
16593
+ data = modifier.call(this, data);
16594
+ }
16595
+ }.bind(this));
16596
+
16597
+ return data;
16598
+ };
16599
+
16671
16600
  /**
16672
16601
  * Helper used to know if the given modifier depends from another one.
16673
16602
  * @method
@@ -16675,204 +16604,191 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
16675
16604
  * @param {String} requesting - name of requesting modifier
16676
16605
  * @param {String} requested - name of requested modifier
16677
16606
  * @returns {Boolean}
16678
- */
16679
- Popper.prototype.isModifierRequired = function (requesting, requested) {
16680
- var index = getArrayKeyIndex(this._options.modifiers, requesting);
16681
- return !!this._options.modifiers.slice(0, index).filter(function (modifier) {
16682
- return modifier === requested;
16683
- }).length;
16684
- };
16685
-
16686
- //
16687
- // Modifiers
16688
- //
16689
-
16607
+ */
16608
+ Popper.prototype.isModifierRequired = function (requesting, requested) {
16609
+ var index = getArrayKeyIndex(this._options.modifiers, requesting);
16610
+ return !!this._options.modifiers.slice(0, index).filter(function (modifier) {
16611
+ return modifier === requested;
16612
+ }).length;
16613
+ };
16614
+
16615
+ //
16616
+ // Modifiers
16617
+ //
16618
+
16690
16619
  /**
16691
16620
  * Modifiers list
16692
16621
  * @namespace Popper.modifiers
16693
16622
  * @memberof Popper
16694
16623
  * @type {Object}
16695
- */
16696
- Popper.prototype.modifiers = {};
16697
-
16624
+ */
16625
+ Popper.prototype.modifiers = {};
16626
+
16698
16627
  /**
16699
16628
  * Apply the computed styles to the popper element
16700
16629
  * @method
16701
16630
  * @memberof Popper.modifiers
16702
16631
  * @argument {Object} data - The data object generated by `update` method
16703
16632
  * @returns {Object} The same data object
16704
- */
16705
- Popper.prototype.modifiers.applyStyle = function (data) {
16706
- // apply the final offsets to the popper
16707
- // NOTE: 1 DOM access here
16708
- var styles = {
16709
- position: data.offsets.popper.position
16710
- };
16711
-
16712
- // round top and left to avoid blurry text
16713
- var left = Math.round(data.offsets.popper.left);
16714
- var top = Math.round(data.offsets.popper.top);
16715
-
16716
- // if gpuAcceleration is set to true and transform is supported, we use `translate3d` to apply the position to the popper
16717
- // we automatically use the supported prefixed version if needed
16718
- var prefixedProperty;
16719
- if (
16720
- this._options.gpuAcceleration &&
16721
- (prefixedProperty = getSupportedPropertyName('transform'))
16722
- ) {
16723
- styles[prefixedProperty] =
16724
- 'translate3d(' + left + 'px, ' + top + 'px, 0)';
16725
- styles.top = 0;
16726
- styles.left = 0;
16727
- }
16728
- // othwerise, we use the standard `left` and `top` properties
16729
- else {
16730
- styles.left = left;
16731
- styles.top = top;
16732
- }
16733
-
16734
- // any property present in `data.styles` will be applied to the popper,
16735
- // in this way we can make the 3rd party modifiers add custom styles to it
16736
- // Be aware, modifiers could override the properties defined in the previous
16737
- // lines of this modifier!
16738
- Object.assign(styles, data.styles);
16739
-
16740
- setStyle(this._popper, styles);
16741
-
16742
- // set an attribute which will be useful to style the tooltip (use it to properly position its arrow)
16743
- // NOTE: 1 DOM access here
16744
- this._popper.setAttribute('x-placement', data.placement);
16745
-
16746
- // if the arrow modifier is required and the arrow style has been computed, apply the arrow style
16747
- if (
16748
- this.isModifierRequired(
16749
- this.modifiers.applyStyle,
16750
- this.modifiers.arrow
16751
- ) &&
16752
- data.offsets.arrow
16753
- ) {
16754
- setStyle(data.arrowElement, data.offsets.arrow);
16755
- }
16756
-
16757
- return data;
16758
- };
16759
-
16633
+ */
16634
+ Popper.prototype.modifiers.applyStyle = function (data) {
16635
+ // apply the final offsets to the popper
16636
+ // NOTE: 1 DOM access here
16637
+ var styles = {
16638
+ position: data.offsets.popper.position
16639
+ };
16640
+
16641
+ // round top and left to avoid blurry text
16642
+ var left = Math.round(data.offsets.popper.left);
16643
+ var top = Math.round(data.offsets.popper.top);
16644
+
16645
+ // if gpuAcceleration is set to true and transform is supported, we use `translate3d` to apply the position to the popper
16646
+ // we automatically use the supported prefixed version if needed
16647
+ var prefixedProperty;
16648
+ if (this._options.gpuAcceleration && (prefixedProperty = getSupportedPropertyName('transform'))) {
16649
+ styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
16650
+ styles.top = 0;
16651
+ styles.left = 0;
16652
+ }
16653
+ // othwerise, we use the standard `left` and `top` properties
16654
+ else {
16655
+ styles.left = left;
16656
+ styles.top = top;
16657
+ }
16658
+
16659
+ // any property present in `data.styles` will be applied to the popper,
16660
+ // in this way we can make the 3rd party modifiers add custom styles to it
16661
+ // Be aware, modifiers could override the properties defined in the previous
16662
+ // lines of this modifier!
16663
+ Object.assign(styles, data.styles);
16664
+
16665
+ setStyle(this._popper, styles);
16666
+
16667
+ // set an attribute which will be useful to style the tooltip (use it to properly position its arrow)
16668
+ // NOTE: 1 DOM access here
16669
+ this._popper.setAttribute('x-placement', data.placement);
16670
+
16671
+ // if the arrow modifier is required and the arrow style has been computed, apply the arrow style
16672
+ if (this.isModifierRequired(this.modifiers.applyStyle, this.modifiers.arrow) && data.offsets.arrow) {
16673
+ setStyle(data.arrowElement, data.offsets.arrow);
16674
+ }
16675
+
16676
+ return data;
16677
+ };
16678
+
16760
16679
  /**
16761
16680
  * Modifier used to shift the popper on the start or end of its reference element side
16762
16681
  * @method
16763
16682
  * @memberof Popper.modifiers
16764
16683
  * @argument {Object} data - The data object generated by `update` method
16765
16684
  * @returns {Object} The data object, properly modified
16766
- */
16767
- Popper.prototype.modifiers.shift = function (data) {
16768
- var placement = data.placement;
16769
- var basePlacement = placement.split('-')[0];
16770
- var shiftVariation = placement.split('-')[1];
16771
-
16772
- // if shift shiftVariation is specified, run the modifier
16773
- if (shiftVariation) {
16774
- var reference = data.offsets.reference;
16775
- var popper = getPopperClientRect(data.offsets.popper);
16776
-
16777
- var shiftOffsets = {
16778
- y: {
16779
- start: { top: reference.top },
16780
- end: { top: reference.top + reference.height - popper.height }
16781
- },
16782
- x: {
16783
- start: { left: reference.left },
16784
- end: { left: reference.left + reference.width - popper.width }
16785
- }
16786
- };
16787
-
16788
- var axis = ['bottom', 'top'].indexOf(basePlacement) !== -1 ? 'x' : 'y';
16789
-
16790
- data.offsets.popper = Object.assign(
16791
- popper,
16792
- shiftOffsets[axis][shiftVariation]
16793
- );
16794
- }
16795
-
16796
- return data;
16797
- };
16798
-
16685
+ */
16686
+ Popper.prototype.modifiers.shift = function (data) {
16687
+ var placement = data.placement;
16688
+ var basePlacement = placement.split('-')[0];
16689
+ var shiftVariation = placement.split('-')[1];
16690
+
16691
+ // if shift shiftVariation is specified, run the modifier
16692
+ if (shiftVariation) {
16693
+ var reference = data.offsets.reference;
16694
+ var popper = getPopperClientRect(data.offsets.popper);
16695
+
16696
+ var shiftOffsets = {
16697
+ y: {
16698
+ start: { top: reference.top },
16699
+ end: { top: reference.top + reference.height - popper.height }
16700
+ },
16701
+ x: {
16702
+ start: { left: reference.left },
16703
+ end: { left: reference.left + reference.width - popper.width }
16704
+ }
16705
+ };
16706
+
16707
+ var axis = ['bottom', 'top'].indexOf(basePlacement) !== -1 ? 'x' : 'y';
16708
+
16709
+ data.offsets.popper = Object.assign(popper, shiftOffsets[axis][shiftVariation]);
16710
+ }
16711
+
16712
+ return data;
16713
+ };
16714
+
16799
16715
  /**
16800
16716
  * Modifier used to make sure the popper does not overflows from it's boundaries
16801
16717
  * @method
16802
16718
  * @memberof Popper.modifiers
16803
16719
  * @argument {Object} data - The data object generated by `update` method
16804
16720
  * @returns {Object} The data object, properly modified
16805
- */
16806
- Popper.prototype.modifiers.preventOverflow = function (data) {
16807
- var order = this._options.preventOverflowOrder;
16808
- var popper = getPopperClientRect(data.offsets.popper);
16809
-
16810
- var check = {
16811
- left: function () {
16812
- var left = popper.left;
16813
- if (popper.left < data.boundaries.left) {
16814
- left = Math.max(popper.left, data.boundaries.left);
16815
- }
16816
- return { left: left };
16817
- },
16818
- right: function () {
16819
- var left = popper.left;
16820
- if (popper.right > data.boundaries.right) {
16821
- left = Math.min(popper.left, data.boundaries.right - popper.width);
16822
- }
16823
- return { left: left };
16824
- },
16825
- top: function () {
16826
- var top = popper.top;
16827
- if (popper.top < data.boundaries.top) {
16828
- top = Math.max(popper.top, data.boundaries.top);
16829
- }
16830
- return { top: top };
16831
- },
16832
- bottom: function () {
16833
- var top = popper.top;
16834
- if (popper.bottom > data.boundaries.bottom) {
16835
- top = Math.min(popper.top, data.boundaries.bottom - popper.height);
16836
- }
16837
- return { top: top };
16838
- }
16839
- };
16840
-
16841
- order.forEach(function (direction) {
16842
- data.offsets.popper = Object.assign(popper, check[direction]());
16843
- });
16844
-
16845
- return data;
16846
- };
16847
-
16721
+ */
16722
+ Popper.prototype.modifiers.preventOverflow = function (data) {
16723
+ var order = this._options.preventOverflowOrder;
16724
+ var popper = getPopperClientRect(data.offsets.popper);
16725
+
16726
+ var check = {
16727
+ left: function left() {
16728
+ var left = popper.left;
16729
+ if (popper.left < data.boundaries.left) {
16730
+ left = Math.max(popper.left, data.boundaries.left);
16731
+ }
16732
+ return { left: left };
16733
+ },
16734
+ right: function right() {
16735
+ var left = popper.left;
16736
+ if (popper.right > data.boundaries.right) {
16737
+ left = Math.min(popper.left, data.boundaries.right - popper.width);
16738
+ }
16739
+ return { left: left };
16740
+ },
16741
+ top: function top() {
16742
+ var top = popper.top;
16743
+ if (popper.top < data.boundaries.top) {
16744
+ top = Math.max(popper.top, data.boundaries.top);
16745
+ }
16746
+ return { top: top };
16747
+ },
16748
+ bottom: function bottom() {
16749
+ var top = popper.top;
16750
+ if (popper.bottom > data.boundaries.bottom) {
16751
+ top = Math.min(popper.top, data.boundaries.bottom - popper.height);
16752
+ }
16753
+ return { top: top };
16754
+ }
16755
+ };
16756
+
16757
+ order.forEach(function (direction) {
16758
+ data.offsets.popper = Object.assign(popper, check[direction]());
16759
+ });
16760
+
16761
+ return data;
16762
+ };
16763
+
16848
16764
  /**
16849
16765
  * Modifier used to make sure the popper is always near its reference
16850
16766
  * @method
16851
16767
  * @memberof Popper.modifiers
16852
16768
  * @argument {Object} data - The data object generated by _update method
16853
16769
  * @returns {Object} The data object, properly modified
16854
- */
16855
- Popper.prototype.modifiers.keepTogether = function (data) {
16856
- var popper = getPopperClientRect(data.offsets.popper);
16857
- var reference = data.offsets.reference;
16858
- var f = Math.floor;
16859
-
16860
- if (popper.right < f(reference.left)) {
16861
- data.offsets.popper.left = f(reference.left) - popper.width;
16862
- }
16863
- if (popper.left > f(reference.right)) {
16864
- data.offsets.popper.left = f(reference.right);
16865
- }
16866
- if (popper.bottom < f(reference.top)) {
16867
- data.offsets.popper.top = f(reference.top) - popper.height;
16868
- }
16869
- if (popper.top > f(reference.bottom)) {
16870
- data.offsets.popper.top = f(reference.bottom);
16871
- }
16872
-
16873
- return data;
16874
- };
16875
-
16770
+ */
16771
+ Popper.prototype.modifiers.keepTogether = function (data) {
16772
+ var popper = getPopperClientRect(data.offsets.popper);
16773
+ var reference = data.offsets.reference;
16774
+ var f = Math.floor;
16775
+
16776
+ if (popper.right < f(reference.left)) {
16777
+ data.offsets.popper.left = f(reference.left) - popper.width;
16778
+ }
16779
+ if (popper.left > f(reference.right)) {
16780
+ data.offsets.popper.left = f(reference.right);
16781
+ }
16782
+ if (popper.bottom < f(reference.top)) {
16783
+ data.offsets.popper.top = f(reference.top) - popper.height;
16784
+ }
16785
+ if (popper.top > f(reference.bottom)) {
16786
+ data.offsets.popper.top = f(reference.bottom);
16787
+ }
16788
+
16789
+ return data;
16790
+ };
16791
+
16876
16792
  /**
16877
16793
  * Modifier used to flip the placement of the popper when the latter is starting overlapping its reference element.
16878
16794
  * Requires the `preventOverflow` modifier before it in order to work.
@@ -16881,81 +16797,61 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
16881
16797
  * @memberof Popper.modifiers
16882
16798
  * @argument {Object} data - The data object generated by _update method
16883
16799
  * @returns {Object} The data object, properly modified
16884
- */
16885
- Popper.prototype.modifiers.flip = function (data) {
16886
- // check if preventOverflow is in the list of modifiers before the flip modifier.
16887
- // otherwise flip would not work as expected.
16888
- if (
16889
- !this.isModifierRequired(
16890
- this.modifiers.flip,
16891
- this.modifiers.preventOverflow
16892
- )
16893
- ) {
16894
- console.warn(
16895
- 'WARNING: preventOverflow modifier is required by flip modifier in order to work, be sure to include it before flip!'
16896
- );
16897
- return data;
16898
- }
16899
-
16900
- if (data.flipped && data.placement === data._originalPlacement) {
16901
- // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
16902
- return data;
16903
- }
16904
-
16905
- var placement = data.placement.split('-')[0];
16906
- var placementOpposite = getOppositePlacement(placement);
16907
- var variation = data.placement.split('-')[1] || '';
16908
-
16909
- var flipOrder = [];
16910
- if (this._options.flipBehavior === 'flip') {
16911
- flipOrder = [placement, placementOpposite];
16912
- } else {
16913
- flipOrder = this._options.flipBehavior;
16914
- }
16915
-
16916
- flipOrder.forEach(
16917
- function (step, index) {
16918
- if (placement !== step || flipOrder.length === index + 1) {
16919
- return;
16920
- }
16921
-
16922
- placement = data.placement.split('-')[0];
16923
- placementOpposite = getOppositePlacement(placement);
16924
-
16925
- var popperOffsets = getPopperClientRect(data.offsets.popper);
16926
-
16927
- // this boolean is used to distinguish right and bottom from top and left
16928
- // they need different computations to get flipped
16929
- var a = ['right', 'bottom'].indexOf(placement) !== -1;
16930
-
16931
- // using Math.floor because the reference offsets may contain decimals we are not going to consider here
16932
- if (
16933
- (a &&
16934
- Math.floor(data.offsets.reference[placement]) >
16935
- Math.floor(popperOffsets[placementOpposite])) ||
16936
- (!a &&
16937
- Math.floor(data.offsets.reference[placement]) <
16938
- Math.floor(popperOffsets[placementOpposite]))
16939
- ) {
16940
- // we'll use this boolean to detect any flip loop
16941
- data.flipped = true;
16942
- data.placement = flipOrder[index + 1];
16943
- if (variation) {
16944
- data.placement += '-' + variation;
16945
- }
16946
- data.offsets.popper = this._getOffsets(
16947
- this._popper,
16948
- this._reference,
16949
- data.placement
16950
- ).popper;
16951
-
16952
- data = this.runModifiers(data, this._options.modifiers, this._flip);
16953
- }
16954
- }.bind(this)
16955
- );
16956
- return data;
16957
- };
16958
-
16800
+ */
16801
+ Popper.prototype.modifiers.flip = function (data) {
16802
+ // check if preventOverflow is in the list of modifiers before the flip modifier.
16803
+ // otherwise flip would not work as expected.
16804
+ if (!this.isModifierRequired(this.modifiers.flip, this.modifiers.preventOverflow)) {
16805
+ console.warn('WARNING: preventOverflow modifier is required by flip modifier in order to work, be sure to include it before flip!');
16806
+ return data;
16807
+ }
16808
+
16809
+ if (data.flipped && data.placement === data._originalPlacement) {
16810
+ // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
16811
+ return data;
16812
+ }
16813
+
16814
+ var placement = data.placement.split('-')[0];
16815
+ var placementOpposite = getOppositePlacement(placement);
16816
+ var variation = data.placement.split('-')[1] || '';
16817
+
16818
+ var flipOrder = [];
16819
+ if (this._options.flipBehavior === 'flip') {
16820
+ flipOrder = [placement, placementOpposite];
16821
+ } else {
16822
+ flipOrder = this._options.flipBehavior;
16823
+ }
16824
+
16825
+ flipOrder.forEach(function (step, index) {
16826
+ if (placement !== step || flipOrder.length === index + 1) {
16827
+ return;
16828
+ }
16829
+
16830
+ placement = data.placement.split('-')[0];
16831
+ placementOpposite = getOppositePlacement(placement);
16832
+
16833
+ var popperOffsets = getPopperClientRect(data.offsets.popper);
16834
+
16835
+ // this boolean is used to distinguish right and bottom from top and left
16836
+ // they need different computations to get flipped
16837
+ var a = ['right', 'bottom'].indexOf(placement) !== -1;
16838
+
16839
+ // using Math.floor because the reference offsets may contain decimals we are not going to consider here
16840
+ if (a && Math.floor(data.offsets.reference[placement]) > Math.floor(popperOffsets[placementOpposite]) || !a && Math.floor(data.offsets.reference[placement]) < Math.floor(popperOffsets[placementOpposite])) {
16841
+ // we'll use this boolean to detect any flip loop
16842
+ data.flipped = true;
16843
+ data.placement = flipOrder[index + 1];
16844
+ if (variation) {
16845
+ data.placement += '-' + variation;
16846
+ }
16847
+ data.offsets.popper = this._getOffsets(this._popper, this._reference, data.placement).popper;
16848
+
16849
+ data = this.runModifiers(data, this._options.modifiers, this._flip);
16850
+ }
16851
+ }.bind(this));
16852
+ return data;
16853
+ };
16854
+
16959
16855
  /**
16960
16856
  * Modifier used to add an offset to the popper, useful if you more granularity positioning your popper.
16961
16857
  * The offsets will shift the popper on the side of its reference element.
@@ -16963,23 +16859,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
16963
16859
  * @memberof Popper.modifiers
16964
16860
  * @argument {Object} data - The data object generated by _update method
16965
16861
  * @returns {Object} The data object, properly modified
16966
- */
16967
- Popper.prototype.modifiers.offset = function (data) {
16968
- var offset = this._options.offset;
16969
- var popper = data.offsets.popper;
16970
-
16971
- if (data.placement.indexOf('left') !== -1) {
16972
- popper.top -= offset;
16973
- } else if (data.placement.indexOf('right') !== -1) {
16974
- popper.top += offset;
16975
- } else if (data.placement.indexOf('top') !== -1) {
16976
- popper.left -= offset;
16977
- } else if (data.placement.indexOf('bottom') !== -1) {
16978
- popper.left += offset;
16979
- }
16980
- return data;
16981
- };
16982
-
16862
+ */
16863
+ Popper.prototype.modifiers.offset = function (data) {
16864
+ var offset = this._options.offset;
16865
+ var popper = data.offsets.popper;
16866
+
16867
+ if (data.placement.indexOf('left') !== -1) {
16868
+ popper.top -= offset;
16869
+ } else if (data.placement.indexOf('right') !== -1) {
16870
+ popper.top += offset;
16871
+ } else if (data.placement.indexOf('top') !== -1) {
16872
+ popper.left -= offset;
16873
+ } else if (data.placement.indexOf('bottom') !== -1) {
16874
+ popper.left += offset;
16875
+ }
16876
+ return data;
16877
+ };
16878
+
16983
16879
  /**
16984
16880
  * 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
16985
16881
  * It will use the CSS outer size of the arrow element to know how many pixels of conjuction are needed
@@ -16987,196 +16883,183 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
16987
16883
  * @memberof Popper.modifiers
16988
16884
  * @argument {Object} data - The data object generated by _update method
16989
16885
  * @returns {Object} The data object, properly modified
16990
- */
16991
- Popper.prototype.modifiers.arrow = function (data) {
16992
- var arrow = this._options.arrowElement;
16993
- var arrowOffset = this._options.arrowOffset;
16994
-
16995
- // if the arrowElement is a string, suppose it's a CSS selector
16996
- if (typeof arrow === 'string') {
16997
- arrow = this._popper.querySelector(arrow);
16998
- }
16999
-
17000
- // if arrow element is not found, don't run the modifier
17001
- if (!arrow) {
17002
- return data;
17003
- }
17004
-
17005
- // the arrow element must be child of its popper
17006
- if (!this._popper.contains(arrow)) {
17007
- console.warn(
17008
- 'WARNING: `arrowElement` must be child of its popper element!'
17009
- );
17010
- return data;
17011
- }
17012
-
17013
- // arrow depends on keepTogether in order to work
17014
- if (
17015
- !this.isModifierRequired(
17016
- this.modifiers.arrow,
17017
- this.modifiers.keepTogether
17018
- )
17019
- ) {
17020
- console.warn(
17021
- 'WARNING: keepTogether modifier is required by arrow modifier in order to work, be sure to include it before arrow!'
17022
- );
17023
- return data;
17024
- }
17025
-
17026
- var arrowStyle = {};
17027
- var placement = data.placement.split('-')[0];
17028
- var popper = getPopperClientRect(data.offsets.popper);
17029
- var reference = data.offsets.reference;
17030
- var isVertical = ['left', 'right'].indexOf(placement) !== -1;
17031
-
17032
- var len = isVertical ? 'height' : 'width';
17033
- var side = isVertical ? 'top' : 'left';
17034
- var translate = isVertical ? 'translateY' : 'translateX';
17035
- var altSide = isVertical ? 'left' : 'top';
17036
- var opSide = isVertical ? 'bottom' : 'right';
17037
- var arrowSize = getOuterSizes(arrow)[len];
17038
-
17039
- //
17040
- // extends keepTogether behavior making sure the popper and its reference have enough pixels in conjuction
17041
- //
17042
-
17043
- // top/left side
17044
- if (reference[opSide] - arrowSize < popper[side]) {
17045
- data.offsets.popper[side] -=
17046
- popper[side] - (reference[opSide] - arrowSize);
17047
- }
17048
- // bottom/right side
17049
- if (reference[side] + arrowSize > popper[opSide]) {
17050
- data.offsets.popper[side] += reference[side] + arrowSize - popper[opSide];
17051
- }
17052
-
17053
- // compute center of the popper
17054
- var center =
17055
- reference[side] + (arrowOffset || reference[len] / 2 - arrowSize / 2);
17056
-
17057
- var sideValue = center - popper[side];
17058
-
17059
- // prevent arrow from being placed not contiguously to its popper
17060
- sideValue = Math.max(Math.min(popper[len] - arrowSize - 8, sideValue), 8);
17061
- arrowStyle[side] = sideValue;
17062
- arrowStyle[altSide] = ''; // make sure to remove any old style from the arrow
17063
-
17064
- data.offsets.arrow = arrowStyle;
17065
- data.arrowElement = arrow;
17066
-
17067
- return data;
17068
- };
17069
-
17070
- //
17071
- // Helpers
17072
- //
17073
-
16886
+ */
16887
+ Popper.prototype.modifiers.arrow = function (data) {
16888
+ var arrow = this._options.arrowElement;
16889
+ var arrowOffset = this._options.arrowOffset;
16890
+
16891
+ // if the arrowElement is a string, suppose it's a CSS selector
16892
+ if (typeof arrow === 'string') {
16893
+ arrow = this._popper.querySelector(arrow);
16894
+ }
16895
+
16896
+ // if arrow element is not found, don't run the modifier
16897
+ if (!arrow) {
16898
+ return data;
16899
+ }
16900
+
16901
+ // the arrow element must be child of its popper
16902
+ if (!this._popper.contains(arrow)) {
16903
+ console.warn('WARNING: `arrowElement` must be child of its popper element!');
16904
+ return data;
16905
+ }
16906
+
16907
+ // arrow depends on keepTogether in order to work
16908
+ if (!this.isModifierRequired(this.modifiers.arrow, this.modifiers.keepTogether)) {
16909
+ console.warn('WARNING: keepTogether modifier is required by arrow modifier in order to work, be sure to include it before arrow!');
16910
+ return data;
16911
+ }
16912
+
16913
+ var arrowStyle = {};
16914
+ var placement = data.placement.split('-')[0];
16915
+ var popper = getPopperClientRect(data.offsets.popper);
16916
+ var reference = data.offsets.reference;
16917
+ var isVertical = ['left', 'right'].indexOf(placement) !== -1;
16918
+
16919
+ var len = isVertical ? 'height' : 'width';
16920
+ var side = isVertical ? 'top' : 'left';
16921
+ var translate = isVertical ? 'translateY' : 'translateX';
16922
+ var altSide = isVertical ? 'left' : 'top';
16923
+ var opSide = isVertical ? 'bottom' : 'right';
16924
+ var arrowSize = getOuterSizes(arrow)[len];
16925
+
16926
+ //
16927
+ // extends keepTogether behavior making sure the popper and its reference have enough pixels in conjuction
16928
+ //
16929
+
16930
+ // top/left side
16931
+ if (reference[opSide] - arrowSize < popper[side]) {
16932
+ data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowSize);
16933
+ }
16934
+ // bottom/right side
16935
+ if (reference[side] + arrowSize > popper[opSide]) {
16936
+ data.offsets.popper[side] += reference[side] + arrowSize - popper[opSide];
16937
+ }
16938
+
16939
+ // compute center of the popper
16940
+ var center = reference[side] + (arrowOffset || reference[len] / 2 - arrowSize / 2);
16941
+
16942
+ var sideValue = center - popper[side];
16943
+
16944
+ // prevent arrow from being placed not contiguously to its popper
16945
+ sideValue = Math.max(Math.min(popper[len] - arrowSize - 8, sideValue), 8);
16946
+ arrowStyle[side] = sideValue;
16947
+ arrowStyle[altSide] = ''; // make sure to remove any old style from the arrow
16948
+
16949
+ data.offsets.arrow = arrowStyle;
16950
+ data.arrowElement = arrow;
16951
+
16952
+ return data;
16953
+ };
16954
+
16955
+ //
16956
+ // Helpers
16957
+ //
16958
+
17074
16959
  /**
17075
16960
  * Get the outer sizes of the given element (offset size + margins)
17076
16961
  * @function
17077
16962
  * @ignore
17078
16963
  * @argument {Element} element
17079
16964
  * @returns {Object} object containing width and height properties
17080
- */
17081
- function getOuterSizes(element) {
17082
- // NOTE: 1 DOM access here
17083
- var _display = element.style.display,
17084
- _visibility = element.style.visibility;
17085
- element.style.display = 'block';
17086
- element.style.visibility = 'hidden';
17087
- var calcWidthToForceRepaint = element.offsetWidth;
17088
- // original method
17089
- var styles = getRealWindow(element).getComputedStyle(element);
17090
- var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
17091
- var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
17092
- var result = {
17093
- width: element.offsetWidth + y,
17094
- height: element.offsetHeight + x
17095
- };
17096
-
17097
- // reset element styles
17098
- element.style.display = _display;
17099
- element.style.visibility = _visibility;
17100
- return result;
17101
- }
17102
-
16965
+ */
16966
+ function getOuterSizes(element) {
16967
+ // NOTE: 1 DOM access here
16968
+ var _display = element.style.display,
16969
+ _visibility = element.style.visibility;
16970
+ element.style.display = 'block';
16971
+ element.style.visibility = 'hidden';
16972
+ var calcWidthToForceRepaint = element.offsetWidth;
16973
+ // original method
16974
+ var styles = getRealWindow(element).getComputedStyle(element);
16975
+ var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
16976
+ var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
16977
+ var result = {
16978
+ width: element.offsetWidth + y,
16979
+ height: element.offsetHeight + x
16980
+ };
16981
+
16982
+ // reset element styles
16983
+ element.style.display = _display;
16984
+ element.style.visibility = _visibility;
16985
+ return result;
16986
+ }
16987
+
17103
16988
  /**
17104
16989
  * Get the opposite placement of the given one/
17105
16990
  * @function
17106
16991
  * @ignore
17107
16992
  * @argument {String} placement
17108
16993
  * @returns {String} flipped placement
17109
- */
17110
- function getOppositePlacement(placement) {
17111
- var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
17112
- return placement.replace(/left|right|bottom|top/g, function (matched) {
17113
- return hash[matched];
17114
- });
17115
- }
17116
-
16994
+ */
16995
+ function getOppositePlacement(placement) {
16996
+ var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
16997
+ return placement.replace(/left|right|bottom|top/g, function (matched) {
16998
+ return hash[matched];
16999
+ });
17000
+ }
17001
+
17117
17002
  /**
17118
17003
  * Given the popper offsets, generate an output similar to getBoundingClientRect
17119
17004
  * @function
17120
17005
  * @ignore
17121
17006
  * @argument {Object} popperOffsets
17122
17007
  * @returns {Object} ClientRect like output
17123
- */
17124
- function getPopperClientRect(popperOffsets) {
17125
- var offsets = Object.assign({}, popperOffsets);
17126
- offsets.right = offsets.left + offsets.width;
17127
- offsets.bottom = offsets.top + offsets.height;
17128
- return offsets;
17129
- }
17130
-
17131
- /**
17132
- * Given an array and the key to find, returns its index
17008
+ */
17009
+ function getPopperClientRect(popperOffsets) {
17010
+ var offsets = Object.assign({}, popperOffsets);
17011
+ offsets.right = offsets.left + offsets.width;
17012
+ offsets.bottom = offsets.top + offsets.height;
17013
+ return offsets;
17014
+ }
17015
+
17016
+ /**
17017
+ * Given an array and the key to find, returns its index
17133
17018
  * @function
17134
17019
  * @ignore
17135
17020
  * @argument {Array} arr
17136
17021
  * @argument keyToFind
17137
17022
  * @returns index or null
17138
- */
17139
- function getArrayKeyIndex(arr, keyToFind) {
17140
- var i = 0,
17141
- key;
17142
- for (key in arr) {
17143
- if (arr[key] === keyToFind) {
17144
- return i;
17145
- }
17146
- i++;
17147
- }
17148
- return null;
17149
- }
17150
-
17023
+ */
17024
+ function getArrayKeyIndex(arr, keyToFind) {
17025
+ var i = 0,
17026
+ key;
17027
+ for (key in arr) {
17028
+ if (arr[key] === keyToFind) {
17029
+ return i;
17030
+ }
17031
+ i++;
17032
+ }
17033
+ return null;
17034
+ }
17035
+
17151
17036
  /**
17152
17037
  * Get CSS computed property of the given element
17153
17038
  * @function
17154
17039
  * @ignore
17155
17040
  * @argument {Eement} element
17156
17041
  * @argument {String} property
17157
- */
17158
- function getStyleComputedProperty(element, property) {
17159
- // NOTE: 1 DOM access here
17160
- // 无界等微前端场景下沙箱 window 与元素实际渲染所在 window 可能不一致,
17161
- // 需使用元素自身的 view 读取计算样式,避免跨 document 读取到空值
17162
- var css = getRealWindow(element).getComputedStyle(element, null);
17163
- return css[property];
17164
- }
17165
-
17042
+ */
17043
+ function getStyleComputedProperty(element, property) {
17044
+ // NOTE: 1 DOM access here
17045
+ // 无界等微前端场景下沙箱 window 与元素实际渲染所在 window 可能不一致,
17046
+ // 需使用元素自身的 view 读取计算样式,避免跨 document 读取到空值
17047
+ var css = getRealWindow(element).getComputedStyle(element, null);
17048
+ return css[property];
17049
+ }
17050
+
17166
17051
  /**
17167
17052
  * Returns the offset parent of the given element
17168
17053
  * @function
17169
17054
  * @ignore
17170
17055
  * @argument {Element} element
17171
17056
  * @returns {Element} offset parent
17172
- */
17173
- function getOffsetParent(element) {
17174
- var offsetParent = element.offsetParent;
17175
- return offsetParent === root.document.body || !offsetParent
17176
- ? root.document.documentElement
17177
- : offsetParent;
17178
- }
17179
-
17057
+ */
17058
+ function getOffsetParent(element) {
17059
+ var offsetParent = element.offsetParent;
17060
+ return offsetParent === root.document.body || !offsetParent ? root.document.documentElement : offsetParent;
17061
+ }
17062
+
17180
17063
  /**
17181
17064
  * Returns the window the given element actually renders in.
17182
17065
  * 无界等微前端场景下组件代码运行在沙箱 window 中,而 DOM 实际渲染在
@@ -17185,16 +17068,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
17185
17068
  * @ignore
17186
17069
  * @argument {Element} element
17187
17070
  * @returns {Window} window
17188
- */
17189
- function getRealWindow(element) {
17190
- return (
17191
- (element &&
17192
- element.ownerDocument &&
17193
- element.ownerDocument.defaultView) ||
17194
- root
17195
- );
17196
- }
17197
-
17071
+ */
17072
+ function getRealWindow(element) {
17073
+ return element && element.ownerDocument && element.ownerDocument.defaultView || root;
17074
+ }
17075
+
17198
17076
  /**
17199
17077
  * Returns the viewport rect of the containing block actually used to position the popper.
17200
17078
  * 无界微前端等场景下 popper 被挂载进子应用的 shadowRoot,offsetParent 的兜底值
@@ -17208,82 +17086,72 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
17208
17086
  * @argument {Element} element - popper element
17209
17087
  * @argument {Boolean} fixed - whether the popper is fixed positioned
17210
17088
  * @returns {Object} rect
17211
- */
17212
- function getContainingBlockRect(element, fixed) {
17213
- if (fixed) {
17214
- return { top: 0, left: 0, right: 0, bottom: 0 };
17215
- }
17216
-
17217
- var node = element.parentNode;
17218
- while (node) {
17219
- if (node.nodeType === 1) {
17220
- if (getStyleComputedProperty(node, 'position') !== 'static') {
17221
- return getBoundingClientRect(node);
17222
- }
17223
- } else if (node.nodeType === 11) {
17224
- // 遇到 shadowRoot,跨边界从宿主元素继续向上查找
17225
- node = node.host;
17226
- continue;
17227
- } else {
17228
- break;
17229
- }
17230
- node = node.parentNode;
17231
- }
17232
-
17233
- var win = getRealWindow(element);
17234
- return {
17235
- top: -(win.pageYOffset || 0),
17236
- left: -(win.pageXOffset || 0),
17237
- right: 0,
17238
- bottom: 0
17239
- };
17240
- }
17241
-
17089
+ */
17090
+ function getContainingBlockRect(element, fixed) {
17091
+ if (fixed) {
17092
+ return { top: 0, left: 0, right: 0, bottom: 0 };
17093
+ }
17094
+
17095
+ var node = element.parentNode;
17096
+ while (node) {
17097
+ if (node.nodeType === 1) {
17098
+ if (getStyleComputedProperty(node, 'position') !== 'static') {
17099
+ return getBoundingClientRect(node);
17100
+ }
17101
+ } else if (node.nodeType === 11) {
17102
+ // 遇到 shadowRoot,跨边界从宿主元素继续向上查找
17103
+ node = node.host;
17104
+ continue;
17105
+ } else {
17106
+ break;
17107
+ }
17108
+ node = node.parentNode;
17109
+ }
17110
+
17111
+ var win = getRealWindow(element);
17112
+ return {
17113
+ top: -(win.pageYOffset || 0),
17114
+ left: -(win.pageXOffset || 0),
17115
+ right: 0,
17116
+ bottom: 0
17117
+ };
17118
+ }
17119
+
17242
17120
  /**
17243
17121
  * Returns the scrolling parent of the given element
17244
17122
  * @function
17245
17123
  * @ignore
17246
17124
  * @argument {Element} element
17247
17125
  * @returns {Element} offset parent
17248
- */
17249
- function getScrollParent(element) {
17250
- var parent = element.parentNode;
17251
- if (!parent) {
17252
- return element;
17253
- }
17254
-
17255
- if (parent.nodeType === 11) {
17256
- // 无界等微前端场景 DOM 位于 shadowRoot 内,需跨边界从宿主元素继续向上查找,
17257
- // 否则查找到 shadowRoot 即终止,滚动事件无法被监听
17258
- return getScrollParent(parent.host);
17259
- }
17260
-
17261
- if (parent.nodeType !== 1) {
17262
- // 到达 document,返回元素实际渲染所在的真实 window,
17263
- // 保证 window 滚动时能触发位置更新
17264
- return getRealWindow(element);
17265
- }
17266
-
17267
- // Firefox want us to check `-x` and `-y` variations as well
17268
- if (
17269
- ['scroll', 'auto'].indexOf(
17270
- getStyleComputedProperty(parent, 'overflow')
17271
- ) !== -1 ||
17272
- ['scroll', 'auto'].indexOf(
17273
- getStyleComputedProperty(parent, 'overflow-x')
17274
- ) !== -1 ||
17275
- ['scroll', 'auto'].indexOf(
17276
- getStyleComputedProperty(parent, 'overflow-y')
17277
- ) !== -1
17278
- ) {
17279
- // If the detected scrollParent is body, we perform an additional check on its parentNode
17280
- // in this way we'll get body if the browser is Chrome-ish, or documentElement otherwise
17281
- // fixes issue #65
17282
- return parent;
17283
- }
17284
- return getScrollParent(parent);
17285
- }
17286
-
17126
+ */
17127
+ function getScrollParent(element) {
17128
+ var parent = element.parentNode;
17129
+ if (!parent) {
17130
+ return element;
17131
+ }
17132
+
17133
+ if (parent.nodeType === 11) {
17134
+ // 无界等微前端场景 DOM 位于 shadowRoot 内,需跨边界从宿主元素继续向上查找,
17135
+ // 否则查找到 shadowRoot 即终止,滚动事件无法被监听
17136
+ return getScrollParent(parent.host);
17137
+ }
17138
+
17139
+ if (parent.nodeType !== 1) {
17140
+ // 到达 document,返回元素实际渲染所在的真实 window,
17141
+ // 保证 window 滚动时能触发位置更新
17142
+ return getRealWindow(element);
17143
+ }
17144
+
17145
+ // Firefox want us to check `-x` and `-y` variations as well
17146
+ if (['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow')) !== -1 || ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-x')) !== -1 || ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-y')) !== -1) {
17147
+ // If the detected scrollParent is body, we perform an additional check on its parentNode
17148
+ // in this way we'll get body if the browser is Chrome-ish, or documentElement otherwise
17149
+ // fixes issue #65
17150
+ return parent;
17151
+ }
17152
+ return getScrollParent(parent);
17153
+ }
17154
+
17287
17155
  /**
17288
17156
  * Check if the given element is fixed or is inside a fixed parent
17289
17157
  * @function
@@ -17291,125 +17159,114 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
17291
17159
  * @argument {Element} element
17292
17160
  * @argument {Element} customContainer
17293
17161
  * @returns {Boolean} answer to "isFixed?"
17294
- */
17295
- function isFixed(element) {
17296
- if (element === root.document.body) {
17297
- return false;
17298
- }
17299
- if (getStyleComputedProperty(element, 'position') === 'fixed') {
17300
- return true;
17301
- }
17302
- var parent = element.parentNode;
17303
- if (parent && parent.nodeType === 11) {
17304
- // 跨 shadowRoot 边界,从宿主元素继续向上判断
17305
- parent = parent.host;
17306
- }
17307
- return parent && parent.nodeType === 1 ? isFixed(parent) : false;
17308
- }
17309
-
17162
+ */
17163
+ function isFixed(element) {
17164
+ if (element === root.document.body) {
17165
+ return false;
17166
+ }
17167
+ if (getStyleComputedProperty(element, 'position') === 'fixed') {
17168
+ return true;
17169
+ }
17170
+ var parent = element.parentNode;
17171
+ if (parent && parent.nodeType === 11) {
17172
+ // 跨 shadowRoot 边界,从宿主元素继续向上判断
17173
+ parent = parent.host;
17174
+ }
17175
+ return parent && parent.nodeType === 1 ? isFixed(parent) : false;
17176
+ }
17177
+
17310
17178
  /**
17311
17179
  * Set the style to the given popper
17312
17180
  * @function
17313
17181
  * @ignore
17314
17182
  * @argument {Element} element - Element to apply the style to
17315
17183
  * @argument {Object} styles - Object with a list of properties and values which will be applied to the element
17316
- */
17317
- function setStyle(element, styles) {
17318
- function is_numeric(n) {
17319
- return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
17320
- }
17321
- Object.keys(styles).forEach(function (prop) {
17322
- var unit = '';
17323
- // add unit if the value is numeric and is one of the following
17324
- if (
17325
- ['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !==
17326
- -1 &&
17327
- is_numeric(styles[prop])
17328
- ) {
17329
- unit = 'px';
17330
- }
17331
- element.style[prop] = styles[prop] + unit;
17332
- });
17333
- }
17334
-
17184
+ */
17185
+ function setStyle(element, styles) {
17186
+ function is_numeric(n) {
17187
+ return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
17188
+ }
17189
+ Object.keys(styles).forEach(function (prop) {
17190
+ var unit = '';
17191
+ // add unit if the value is numeric and is one of the following
17192
+ if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && is_numeric(styles[prop])) {
17193
+ unit = 'px';
17194
+ }
17195
+ element.style[prop] = styles[prop] + unit;
17196
+ });
17197
+ }
17198
+
17335
17199
  /**
17336
17200
  * Check if the given variable is a function
17337
17201
  * @function
17338
17202
  * @ignore
17339
17203
  * @argument {*} functionToCheck - variable to check
17340
17204
  * @returns {Boolean} answer to: is a function?
17341
- */
17342
- function isFunction(functionToCheck) {
17343
- var getType = {};
17344
- return (
17345
- functionToCheck &&
17346
- getType.toString.call(functionToCheck) === '[object Function]'
17347
- );
17348
- }
17349
-
17205
+ */
17206
+ function isFunction(functionToCheck) {
17207
+ var getType = {};
17208
+ return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
17209
+ }
17210
+
17350
17211
  /**
17351
17212
  * Get the position of the given element, relative to its offset parent
17352
17213
  * @function
17353
17214
  * @ignore
17354
17215
  * @param {Element} element
17355
17216
  * @return {Object} position - Coordinates of the element and its `scrollTop`
17356
- */
17357
- function getOffsetRect(element) {
17358
- var transform = getStyle(element, 'transform')
17359
- .replace(/[^0-9\-,]/g, '')
17360
- .split(',');
17361
- var elementRect = {
17362
- width: element.offsetWidth,
17363
- height: element.offsetHeight,
17364
- left:
17365
- element.offsetLeft + (transform[4] ? parseInt(transform[4], 10) : 0),
17366
- top: element.offsetTop + (transform[5] ? parseInt(transform[5], 10) : 0)
17367
- };
17368
-
17369
- elementRect.right = elementRect.left + elementRect.width;
17370
- elementRect.bottom = elementRect.top + elementRect.height;
17371
-
17372
- // position
17373
- return elementRect;
17374
- }
17375
-
17217
+ */
17218
+ function getOffsetRect(element) {
17219
+ var transform = getStyle(element, 'transform').replace(/[^0-9\-,]/g, '').split(',');
17220
+ var elementRect = {
17221
+ width: element.offsetWidth,
17222
+ height: element.offsetHeight,
17223
+ left: element.offsetLeft + (transform[4] ? parseInt(transform[4], 10) : 0),
17224
+ top: element.offsetTop + (transform[5] ? parseInt(transform[5], 10) : 0)
17225
+ };
17226
+
17227
+ elementRect.right = elementRect.left + elementRect.width;
17228
+ elementRect.bottom = elementRect.top + elementRect.height;
17229
+
17230
+ // position
17231
+ return elementRect;
17232
+ }
17233
+
17376
17234
  /**
17377
17235
  * Get bounding client rect of given element
17378
17236
  * @function
17379
17237
  * @ignore
17380
17238
  * @param {HTMLElement} element
17381
17239
  * @return {Object} client rect
17382
- */
17383
- function getBoundingClientRect(element) {
17384
- var rect = element.getBoundingClientRect();
17385
-
17386
- // whether the IE version is lower than 11
17387
- var isIE = /MSIE|Trident/.test(navigator.userAgent);
17388
-
17389
- // fix ie document bounding top always 0 bug
17390
- var rectTop =
17391
- isIE && element.tagName === 'HTML' ? -element.scrollTop : rect.top;
17392
-
17393
- return {
17394
- left: rect.left,
17395
- top: rectTop,
17396
- right: rect.right,
17397
- bottom: rect.bottom,
17398
- width: rect.right - rect.left,
17399
- height: rect.bottom - rectTop
17400
- };
17401
- }
17402
-
17403
- function getStyle(dom, attr) {
17404
- if (dom.style[attr]) {
17405
- return dom.style[attr];
17406
- }
17407
- if (window.getComputedStyle) {
17408
- return getComputedStyle(dom, null)[attr];
17409
- }
17410
- return dom.currentStyle[attr];
17411
- }
17412
-
17240
+ */
17241
+ function getBoundingClientRect(element) {
17242
+ var rect = element.getBoundingClientRect();
17243
+
17244
+ // whether the IE version is lower than 11
17245
+ var isIE = /MSIE|Trident/.test(navigator.userAgent);
17246
+
17247
+ // fix ie document bounding top always 0 bug
17248
+ var rectTop = isIE && element.tagName === 'HTML' ? -element.scrollTop : rect.top;
17249
+
17250
+ return {
17251
+ left: rect.left,
17252
+ top: rectTop,
17253
+ right: rect.right,
17254
+ bottom: rect.bottom,
17255
+ width: rect.right - rect.left,
17256
+ height: rect.bottom - rectTop
17257
+ };
17258
+ }
17259
+
17260
+ function getStyle(dom, attr) {
17261
+ if (dom.style[attr]) {
17262
+ return dom.style[attr];
17263
+ }
17264
+ if (window.getComputedStyle) {
17265
+ return getComputedStyle(dom, null)[attr];
17266
+ }
17267
+ return dom.currentStyle[attr];
17268
+ }
17269
+
17413
17270
  /**
17414
17271
  * Given an element and one of its parents, return the offset
17415
17272
  * @function
@@ -17417,45 +17274,43 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
17417
17274
  * @param {HTMLElement} element
17418
17275
  * @param {HTMLElement} parent
17419
17276
  * @return {Object} rect
17420
- */
17421
- function getOffsetRectRelativeToCustomParent(element, parent, fixed) {
17422
- var elementRect = getBoundingClientRect(element);
17423
- // parent 为 popper 元素:取其真实包含块的视口 rect,
17424
- // 避免无界 shadowRoot 等场景下包含块假设错误导致的整体偏移
17425
- var parentRect = getContainingBlockRect(parent, fixed);
17426
-
17427
- var rect = {
17428
- top: elementRect.top - parentRect.top,
17429
- left: elementRect.left - parentRect.left,
17430
- bottom: elementRect.top - parentRect.top + elementRect.height,
17431
- right: elementRect.left - parentRect.left + elementRect.width,
17432
- width: elementRect.width,
17433
- height: elementRect.height
17434
- };
17435
- return rect;
17436
- }
17437
-
17277
+ */
17278
+ function getOffsetRectRelativeToCustomParent(element, parent, fixed) {
17279
+ var elementRect = getBoundingClientRect(element);
17280
+ // parent 为 popper 元素:取其真实包含块的视口 rect,
17281
+ // 避免无界 shadowRoot 等场景下包含块假设错误导致的整体偏移
17282
+ var parentRect = getContainingBlockRect(parent, fixed);
17283
+
17284
+ var rect = {
17285
+ top: elementRect.top - parentRect.top,
17286
+ left: elementRect.left - parentRect.left,
17287
+ bottom: elementRect.top - parentRect.top + elementRect.height,
17288
+ right: elementRect.left - parentRect.left + elementRect.width,
17289
+ width: elementRect.width,
17290
+ height: elementRect.height
17291
+ };
17292
+ return rect;
17293
+ }
17294
+
17438
17295
  /**
17439
17296
  * Get the prefixed supported property name
17440
17297
  * @function
17441
17298
  * @ignore
17442
17299
  * @argument {String} property (camelCase)
17443
17300
  * @returns {String} prefixed property (camelCase)
17444
- */
17445
- function getSupportedPropertyName(property) {
17446
- var prefixes = ['', 'ms', 'webkit', 'moz', 'o'];
17447
-
17448
- for (var i = 0; i < prefixes.length; i++) {
17449
- var toCheck = prefixes[i]
17450
- ? prefixes[i] + property.charAt(0).toUpperCase() + property.slice(1)
17451
- : property;
17452
- if (typeof root.document.body.style[toCheck] !== 'undefined') {
17453
- return toCheck;
17454
- }
17455
- }
17456
- return null;
17457
- }
17458
-
17301
+ */
17302
+ function getSupportedPropertyName(property) {
17303
+ var prefixes = ['', 'ms', 'webkit', 'moz', 'o'];
17304
+
17305
+ for (var i = 0; i < prefixes.length; i++) {
17306
+ var toCheck = prefixes[i] ? prefixes[i] + property.charAt(0).toUpperCase() + property.slice(1) : property;
17307
+ if (typeof root.document.body.style[toCheck] !== 'undefined') {
17308
+ return toCheck;
17309
+ }
17310
+ }
17311
+ return null;
17312
+ }
17313
+
17459
17314
  /**
17460
17315
  * The Object.assign() method is used to copy the values of all enumerable own properties from one or more source
17461
17316
  * objects to a target object. It will return the target object.
@@ -17463,57 +17318,52 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
17463
17318
  * Source: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
17464
17319
  * @function
17465
17320
  * @ignore
17466
- */
17467
- if (!Object.assign) {
17468
- Object.defineProperty(Object, 'assign', {
17469
- enumerable: false,
17470
- configurable: true,
17471
- writable: true,
17472
- value: function (target) {
17473
- if (target === undefined || target === null) {
17474
- throw new TypeError('Cannot convert first argument to object');
17475
- }
17476
-
17477
- var to = Object(target);
17478
- for (var i = 1; i < arguments.length; i++) {
17479
- var nextSource = arguments[i];
17480
- if (nextSource === undefined || nextSource === null) {
17481
- continue;
17482
- }
17483
- nextSource = Object(nextSource);
17484
-
17485
- var keysArray = Object.keys(nextSource);
17486
- for (
17487
- var nextIndex = 0, len = keysArray.length;
17488
- nextIndex < len;
17489
- nextIndex++
17490
- ) {
17491
- var nextKey = keysArray[nextIndex];
17492
- var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
17493
- if (desc !== undefined && desc.enumerable) {
17494
- to[nextKey] = nextSource[nextKey];
17495
- }
17496
- }
17497
- }
17498
- return to;
17499
- }
17500
- });
17501
- }
17502
-
17503
- return Popper;
17504
- });
17321
+ */
17322
+ if (!Object.assign) {
17323
+ Object.defineProperty(Object, 'assign', {
17324
+ enumerable: false,
17325
+ configurable: true,
17326
+ writable: true,
17327
+ value: function value(target) {
17328
+ if (target === undefined || target === null) {
17329
+ throw new TypeError('Cannot convert first argument to object');
17330
+ }
17505
17331
 
17332
+ var to = Object(target);
17333
+ for (var i = 1; i < arguments.length; i++) {
17334
+ var nextSource = arguments[i];
17335
+ if (nextSource === undefined || nextSource === null) {
17336
+ continue;
17337
+ }
17338
+ nextSource = Object(nextSource);
17339
+
17340
+ var keysArray = Object.keys(nextSource);
17341
+ for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
17342
+ var nextKey = keysArray[nextIndex];
17343
+ var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
17344
+ if (desc !== undefined && desc.enumerable) {
17345
+ to[nextKey] = nextSource[nextKey];
17346
+ }
17347
+ }
17348
+ }
17349
+ return to;
17350
+ }
17351
+ });
17352
+ }
17353
+
17354
+ return Popper;
17355
+ });
17506
17356
 
17507
17357
  /***/ }),
17508
17358
 
17509
- /***/ 56:
17359
+ /***/ 55:
17510
17360
  /***/ (function(module, exports) {
17511
17361
 
17512
17362
  module.exports = require("sortablejs");
17513
17363
 
17514
17364
  /***/ }),
17515
17365
 
17516
- /***/ 58:
17366
+ /***/ 59:
17517
17367
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
17518
17368
 
17519
17369
  "use strict";
@@ -18494,759 +18344,736 @@ var changeInTime = '/baseIssueRules/changeInTime';
18494
18344
  /* unused harmony export getSecond */
18495
18345
  /* unused harmony export getWeekday */
18496
18346
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
18497
- /* Modified from https://github.com/taylorhakes/fecha
18498
- *
18499
- * The MIT License (MIT)
18500
- *
18501
- * Copyright (c) 2015 Taylor Hakes
18502
- *
18503
- * Permission is hereby granted, free of charge, to any person obtaining a copy
18504
- * of this software and associated documentation files (the "Software"), to deal
18505
- * in the Software without restriction, including without limitation the rights
18506
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18507
- * copies of the Software, and to permit persons to whom the Software is
18508
- * furnished to do so, subject to the following conditions:
18509
- *
18510
- * The above copyright notice and this permission notice shall be included in all
18511
- * copies or substantial portions of the Software.
18512
- *
18513
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18514
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18515
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18516
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18517
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18518
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18519
- * SOFTWARE.
18520
- */
18521
-
18522
- /*eslint-disable*/
18523
- // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
18524
-
18525
-
18347
+
18348
+
18526
18349
  /**
18527
18350
  * Parse or format dates
18528
18351
  * @class fecha
18529
- */
18530
- const fecha = {};
18531
- const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
18532
- const twoDigits = '\\d\\d?';
18533
- const threeDigits = '\\d{3}';
18534
- const fourDigits = '\\d{4}';
18535
- const word = '[^\\s]+';
18536
- const literal = /\[([^]*?)\]/gm;
18537
- const noop = function () {};
18538
-
18539
- function regexEscape(str) {
18540
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
18541
- }
18542
-
18543
- function shorten(arr, sLen) {
18544
- const newArr = [];
18545
- for (let i = 0, len = arr.length; i < len; i++) {
18546
- newArr.push(arr[i].substr(0, sLen));
18547
- }
18548
- return newArr;
18549
- }
18550
-
18551
- function monthUpdate() {
18552
- return function (d, v) {
18553
- const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
18554
- if (~index) {
18555
- d.month = index;
18556
- }
18557
- };
18558
- }
18559
-
18560
- function pad(val, len) {
18561
- val = String(val);
18562
- len = len || 2;
18563
- while (val.length < len) {
18564
- val = '0' + val;
18565
- }
18566
- return val;
18567
- }
18568
-
18569
- // 直接使用中文日期名称常量
18570
- const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
18571
- const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
18572
- const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
18573
- const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
18574
- const amPm = ['上午', '下午'];
18575
- const DoFn = function DoFn(D) {
18576
- return D + '日';
18577
- };
18578
-
18579
- const formatFlags = {
18580
- D: function(dateObj) {
18581
- return dateObj.getDay();
18582
- },
18583
- DD: function(dateObj) {
18584
- return pad(dateObj.getDay());
18585
- },
18586
- Do: function(dateObj) {
18587
- return DoFn(dateObj.getDate());
18588
- },
18589
- d: function(dateObj) {
18590
- return dateObj.getDate();
18591
- },
18592
- dd: function(dateObj) {
18593
- return pad(dateObj.getDate());
18594
- },
18595
- ddd: function(dateObj) {
18596
- return dayNamesShort[dateObj.getDay()];
18597
- },
18598
- dddd: function(dateObj) {
18599
- return dayNames[dateObj.getDay()];
18600
- },
18601
- M: function(dateObj) {
18602
- return dateObj.getMonth() + 1;
18603
- },
18604
- MM: function(dateObj) {
18605
- return pad(dateObj.getMonth() + 1);
18606
- },
18607
- MMM: function(dateObj) {
18608
- return monthNamesShort[dateObj.getMonth()];
18609
- },
18610
- MMMM: function(dateObj) {
18611
- return monthNames[dateObj.getMonth()];
18612
- },
18613
- yy: function(dateObj) {
18614
- return pad(String(dateObj.getFullYear()), 4).substr(2);
18615
- },
18616
- yyyy: function(dateObj) {
18617
- return pad(dateObj.getFullYear(), 4);
18618
- },
18619
- h: function(dateObj) {
18620
- return dateObj.getHours() % 12 || 12;
18621
- },
18622
- hh: function(dateObj) {
18623
- return pad(dateObj.getHours() % 12 || 12);
18624
- },
18625
- H: function(dateObj) {
18626
- return dateObj.getHours();
18627
- },
18628
- HH: function(dateObj) {
18629
- return pad(dateObj.getHours());
18630
- },
18631
- m: function(dateObj) {
18632
- return dateObj.getMinutes();
18633
- },
18634
- mm: function(dateObj) {
18635
- return pad(dateObj.getMinutes());
18636
- },
18637
- s: function(dateObj) {
18638
- return dateObj.getSeconds();
18639
- },
18640
- ss: function(dateObj) {
18641
- return pad(dateObj.getSeconds());
18642
- },
18643
- S: function(dateObj) {
18644
- return Math.round(dateObj.getMilliseconds() / 100);
18645
- },
18646
- SS: function(dateObj) {
18647
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
18648
- },
18649
- SSS: function(dateObj) {
18650
- return pad(dateObj.getMilliseconds(), 3);
18651
- },
18652
- a: function(dateObj) {
18653
- return dateObj.getHours() < 12 ? '上午' : '下午';
18654
- },
18655
- A: function(dateObj) {
18656
- return dateObj.getHours() < 12 ? '上午' : '下午';
18657
- },
18658
- ZZ: function(dateObj) {
18659
- const o = dateObj.getTimezoneOffset();
18660
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
18661
- }
18662
- };
18663
-
18664
- const parseFlags = {
18665
- d: [twoDigits, function (d, v) {
18666
- d.day = v;
18667
- }],
18668
- Do: [twoDigits + word, function (d, v) {
18669
- d.day = parseInt(v, 10);
18670
- }],
18671
- M: [twoDigits, function (d, v) {
18672
- d.month = v - 1;
18673
- }],
18674
- yy: [twoDigits, function (d, v) {
18675
- const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
18676
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
18677
- }],
18678
- h: [twoDigits, function (d, v) {
18679
- d.hour = v;
18680
- }],
18681
- m: [twoDigits, function (d, v) {
18682
- d.minute = v;
18683
- }],
18684
- s: [twoDigits, function (d, v) {
18685
- d.second = v;
18686
- }],
18687
- yyyy: [fourDigits, function (d, v) {
18688
- d.year = v;
18689
- }],
18690
- S: ['\\d', function (d, v) {
18691
- d.millisecond = v * 100;
18692
- }],
18693
- SS: ['\\d{2}', function (d, v) {
18694
- d.millisecond = v * 10;
18695
- }],
18696
- SSS: [threeDigits, function (d, v) {
18697
- d.millisecond = v;
18698
- }],
18699
- D: [twoDigits, noop],
18700
- ddd: [word, noop],
18701
- MMM: [word, monthUpdate('monthNamesShort')],
18702
- MMMM: [word, monthUpdate('monthNames')],
18703
- a: [word, function (d, v) {
18704
- const val = v.toLowerCase();
18705
- if (val === '上午') {
18706
- d.isPm = false;
18707
- } else if (val === '下午') {
18708
- d.isPm = true;
18709
- }
18710
- }],
18711
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
18712
- let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
18713
-
18714
- if (parts) {
18715
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
18716
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
18717
- }
18718
- }]
18719
- };
18720
- parseFlags.dd = parseFlags.d;
18721
- parseFlags.dddd = parseFlags.ddd;
18722
- parseFlags.DD = parseFlags.D;
18723
- parseFlags.mm = parseFlags.m;
18724
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
18725
- parseFlags.MM = parseFlags.M;
18726
- parseFlags.ss = parseFlags.s;
18727
- parseFlags.A = parseFlags.a;
18728
-
18729
-
18730
- // Some common format strings
18731
- fecha.masks = {
18732
- default: 'ddd MMM dd yyyy HH:mm:ss',
18733
- shortDate: 'M/D/yy',
18734
- mediumDate: 'MMM d, yyyy',
18735
- longDate: 'MMMM d, yyyy',
18736
- fullDate: 'dddd, MMMM d, yyyy',
18737
- shortTime: 'HH:mm',
18738
- mediumTime: 'HH:mm:ss',
18739
- longTime: 'HH:mm:ss.SSS'
18740
- };
18741
-
18352
+ */
18353
+ var fecha = {};
18354
+ var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
18355
+ var twoDigits = '\\d\\d?';
18356
+ var threeDigits = '\\d{3}';
18357
+ var fourDigits = '\\d{4}';
18358
+ var word = '[^\\s]+';
18359
+ var literal = /\[([^]*?)\]/gm;
18360
+ var noop = function noop() {};
18361
+
18362
+ function regexEscape(str) {
18363
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
18364
+ }
18365
+
18366
+ function shorten(arr, sLen) {
18367
+ var newArr = [];
18368
+ for (var i = 0, len = arr.length; i < len; i++) {
18369
+ newArr.push(arr[i].substr(0, sLen));
18370
+ }
18371
+ return newArr;
18372
+ }
18373
+
18374
+ function monthUpdate() {
18375
+ return function (d, v) {
18376
+ var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
18377
+ if (~index) {
18378
+ d.month = index;
18379
+ }
18380
+ };
18381
+ }
18382
+
18383
+ function pad(val, len) {
18384
+ val = String(val);
18385
+ len = len || 2;
18386
+ while (val.length < len) {
18387
+ val = '0' + val;
18388
+ }
18389
+ return val;
18390
+ }
18391
+
18392
+ // 直接使用中文日期名称常量
18393
+ var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
18394
+ var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
18395
+ var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
18396
+ var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
18397
+ var amPm = ['上午', '下午'];
18398
+ var DoFn = function DoFn(D) {
18399
+ return D + '日';
18400
+ };
18401
+
18402
+ var formatFlags = {
18403
+ D: function D(dateObj) {
18404
+ return dateObj.getDay();
18405
+ },
18406
+ DD: function DD(dateObj) {
18407
+ return pad(dateObj.getDay());
18408
+ },
18409
+ Do: function Do(dateObj) {
18410
+ return DoFn(dateObj.getDate());
18411
+ },
18412
+ d: function d(dateObj) {
18413
+ return dateObj.getDate();
18414
+ },
18415
+ dd: function dd(dateObj) {
18416
+ return pad(dateObj.getDate());
18417
+ },
18418
+ ddd: function ddd(dateObj) {
18419
+ return dayNamesShort[dateObj.getDay()];
18420
+ },
18421
+ dddd: function dddd(dateObj) {
18422
+ return dayNames[dateObj.getDay()];
18423
+ },
18424
+ M: function M(dateObj) {
18425
+ return dateObj.getMonth() + 1;
18426
+ },
18427
+ MM: function MM(dateObj) {
18428
+ return pad(dateObj.getMonth() + 1);
18429
+ },
18430
+ MMM: function MMM(dateObj) {
18431
+ return monthNamesShort[dateObj.getMonth()];
18432
+ },
18433
+ MMMM: function MMMM(dateObj) {
18434
+ return monthNames[dateObj.getMonth()];
18435
+ },
18436
+ yy: function yy(dateObj) {
18437
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
18438
+ },
18439
+ yyyy: function yyyy(dateObj) {
18440
+ return pad(dateObj.getFullYear(), 4);
18441
+ },
18442
+ h: function h(dateObj) {
18443
+ return dateObj.getHours() % 12 || 12;
18444
+ },
18445
+ hh: function hh(dateObj) {
18446
+ return pad(dateObj.getHours() % 12 || 12);
18447
+ },
18448
+ H: function H(dateObj) {
18449
+ return dateObj.getHours();
18450
+ },
18451
+ HH: function HH(dateObj) {
18452
+ return pad(dateObj.getHours());
18453
+ },
18454
+ m: function m(dateObj) {
18455
+ return dateObj.getMinutes();
18456
+ },
18457
+ mm: function mm(dateObj) {
18458
+ return pad(dateObj.getMinutes());
18459
+ },
18460
+ s: function s(dateObj) {
18461
+ return dateObj.getSeconds();
18462
+ },
18463
+ ss: function ss(dateObj) {
18464
+ return pad(dateObj.getSeconds());
18465
+ },
18466
+ S: function S(dateObj) {
18467
+ return Math.round(dateObj.getMilliseconds() / 100);
18468
+ },
18469
+ SS: function SS(dateObj) {
18470
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
18471
+ },
18472
+ SSS: function SSS(dateObj) {
18473
+ return pad(dateObj.getMilliseconds(), 3);
18474
+ },
18475
+ a: function a(dateObj) {
18476
+ return dateObj.getHours() < 12 ? '上午' : '下午';
18477
+ },
18478
+ A: function A(dateObj) {
18479
+ return dateObj.getHours() < 12 ? '上午' : '下午';
18480
+ },
18481
+ ZZ: function ZZ(dateObj) {
18482
+ var o = dateObj.getTimezoneOffset();
18483
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
18484
+ }
18485
+ };
18486
+
18487
+ var parseFlags = {
18488
+ d: [twoDigits, function (d, v) {
18489
+ d.day = v;
18490
+ }],
18491
+ Do: [twoDigits + word, function (d, v) {
18492
+ d.day = parseInt(v, 10);
18493
+ }],
18494
+ M: [twoDigits, function (d, v) {
18495
+ d.month = v - 1;
18496
+ }],
18497
+ yy: [twoDigits, function (d, v) {
18498
+ var da = new Date(),
18499
+ cent = +('' + da.getFullYear()).substr(0, 2);
18500
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
18501
+ }],
18502
+ h: [twoDigits, function (d, v) {
18503
+ d.hour = v;
18504
+ }],
18505
+ m: [twoDigits, function (d, v) {
18506
+ d.minute = v;
18507
+ }],
18508
+ s: [twoDigits, function (d, v) {
18509
+ d.second = v;
18510
+ }],
18511
+ yyyy: [fourDigits, function (d, v) {
18512
+ d.year = v;
18513
+ }],
18514
+ S: ['\\d', function (d, v) {
18515
+ d.millisecond = v * 100;
18516
+ }],
18517
+ SS: ['\\d{2}', function (d, v) {
18518
+ d.millisecond = v * 10;
18519
+ }],
18520
+ SSS: [threeDigits, function (d, v) {
18521
+ d.millisecond = v;
18522
+ }],
18523
+ D: [twoDigits, noop],
18524
+ ddd: [word, noop],
18525
+ MMM: [word, monthUpdate('monthNamesShort')],
18526
+ MMMM: [word, monthUpdate('monthNames')],
18527
+ a: [word, function (d, v) {
18528
+ var val = v.toLowerCase();
18529
+ if (val === '上午') {
18530
+ d.isPm = false;
18531
+ } else if (val === '下午') {
18532
+ d.isPm = true;
18533
+ }
18534
+ }],
18535
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
18536
+ var parts = (v + '').match(/([+-]|\d\d)/gi),
18537
+ minutes = void 0;
18538
+
18539
+ if (parts) {
18540
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
18541
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
18542
+ }
18543
+ }]
18544
+ };
18545
+ parseFlags.dd = parseFlags.d;
18546
+ parseFlags.dddd = parseFlags.ddd;
18547
+ parseFlags.DD = parseFlags.D;
18548
+ parseFlags.mm = parseFlags.m;
18549
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
18550
+ parseFlags.MM = parseFlags.M;
18551
+ parseFlags.ss = parseFlags.s;
18552
+ parseFlags.A = parseFlags.a;
18553
+
18554
+ // Some common format strings
18555
+ fecha.masks = {
18556
+ default: 'ddd MMM dd yyyy HH:mm:ss',
18557
+ shortDate: 'M/D/yy',
18558
+ mediumDate: 'MMM d, yyyy',
18559
+ longDate: 'MMMM d, yyyy',
18560
+ fullDate: 'dddd, MMMM d, yyyy',
18561
+ shortTime: 'HH:mm',
18562
+ mediumTime: 'HH:mm:ss',
18563
+ longTime: 'HH:mm:ss.SSS'
18564
+ };
18565
+
18742
18566
  /***
18743
18567
  * Format a date
18744
18568
  * @method format
18745
18569
  * @param {Date|number} dateObj
18746
18570
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
18747
- */
18748
- fecha.format = function (dateObj, mask) {
18749
- if (typeof dateObj === 'number') {
18750
- dateObj = new Date(dateObj);
18751
- }
18752
-
18753
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
18754
- throw new Error('Invalid Date in fecha.format');
18755
- }
18756
-
18757
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
18758
-
18759
- const literals = [];
18760
-
18761
- // Make literals inactive by replacing them with ??
18762
- mask = mask.replace(literal, function($0, $1) {
18763
- literals.push($1);
18764
- return '@@@';
18765
- });
18766
- // Apply formatting rules
18767
- mask = mask.replace(token, function ($0) {
18768
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
18769
- });
18770
- // Inline literal values back into the formatted value
18771
- return mask.replace(/@@@/g, function() {
18772
- return literals.shift();
18773
- });
18774
- };
18775
-
18571
+ */
18572
+ fecha.format = function (dateObj, mask) {
18573
+ if (typeof dateObj === 'number') {
18574
+ dateObj = new Date(dateObj);
18575
+ }
18576
+
18577
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
18578
+ throw new Error('Invalid Date in fecha.format');
18579
+ }
18580
+
18581
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
18582
+
18583
+ var literals = [];
18584
+
18585
+ // Make literals inactive by replacing them with ??
18586
+ mask = mask.replace(literal, function ($0, $1) {
18587
+ literals.push($1);
18588
+ return '@@@';
18589
+ });
18590
+ // Apply formatting rules
18591
+ mask = mask.replace(token, function ($0) {
18592
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
18593
+ });
18594
+ // Inline literal values back into the formatted value
18595
+ return mask.replace(/@@@/g, function () {
18596
+ return literals.shift();
18597
+ });
18598
+ };
18599
+
18776
18600
  /**
18777
18601
  * Parse a date string into an object, changes - into /
18778
18602
  * @method parse
18779
18603
  * @param {string} dateStr Date string
18780
18604
  * @param {string} format Date parse format
18781
18605
  * @returns {Date|boolean}
18782
- */
18783
- fecha.parse = function (dateStr, format) {
18784
- if (typeof format !== 'string') {
18785
- throw new Error('Invalid format in fecha.parse');
18786
- }
18787
-
18788
- format = fecha.masks[format] || format;
18789
-
18790
- // Avoid regular expression denial of service, fail early for really long strings
18791
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
18792
- if (dateStr.length > 1000) {
18793
- return null;
18794
- }
18795
-
18796
- const dateInfo = {};
18797
- const parseInfo = [];
18798
- const literals = [];
18799
- format = format.replace(literal, function($0, $1) {
18800
- literals.push($1);
18801
- return '@@@';
18802
- });
18803
- let newFormat = regexEscape(format).replace(token, function ($0) {
18804
- if (parseFlags[$0]) {
18805
- const info = parseFlags[$0];
18806
- parseInfo.push(info[1]);
18807
- return '(' + info[0] + ')';
18808
- }
18809
-
18810
- return $0;
18811
- });
18812
- newFormat = newFormat.replace(/@@@/g, function() {
18813
- return literals.shift();
18814
- });
18815
- const matches = dateStr.match(new RegExp(newFormat, 'i'));
18816
- if (!matches) {
18817
- return null;
18818
- }
18819
-
18820
- for (let i = 1; i < matches.length; i++) {
18821
- parseInfo[i - 1](dateInfo, matches[i]);
18822
- }
18823
-
18824
- const today = new Date();
18825
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
18826
- dateInfo.hour = +dateInfo.hour + 12;
18827
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
18828
- dateInfo.hour = 0;
18829
- }
18830
-
18831
- let date;
18832
- if (dateInfo.timezoneOffset != null) {
18833
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
18834
- date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
18835
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
18836
- } else {
18837
- date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
18838
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
18839
- }
18840
- return date;
18841
- };
18842
-
18843
- // 导出fecha对象
18844
-
18845
-
18846
- // 以下是从date-util.js合并的函数
18847
- const newArray = function(start, end) {
18848
- let result = [];
18849
- for (let i = start; i <= end; i++) {
18850
- result.push(i);
18851
- }
18852
- return result;
18853
- };
18854
-
18855
- const getSettings = () => {
18856
- return {
18857
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
18858
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
18859
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
18860
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
18861
- amPm: ['上午', '下午']
18862
- };
18863
- };
18864
-
18865
- const toDate = function(date) {
18866
- return isDate(date) ? new Date(date) : null;
18867
- };
18868
-
18869
- const isDate = function(date) {
18870
- if (date === null || date === undefined) return false;
18871
- if (isNaN(new Date(date).getTime())) return false;
18872
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
18873
- return true;
18874
- };
18875
-
18876
- const isDateObject = function(val) {
18877
- return val instanceof Date;
18878
- };
18879
-
18880
- const formatDate = function (date, format = 'yyyy-MM-dd') {
18881
- // 处理多种输入类型
18882
- if (!date) return '';
18883
-
18884
- // 如果是时间戳,转成日期对象
18885
- if (typeof date === 'number') {
18886
- date = new Date(date);
18887
- }
18888
- // 如果是字符串,转成日期对象
18889
- if (typeof date === 'string') {
18890
- date = new Date(date);
18891
- }
18892
-
18893
- // 调用toDate进一步验证和转换
18894
- date = toDate(date);
18895
- if (!date) return '';
18896
-
18897
- // 兼容大写和小写的格式标记
18898
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
18899
- const lowercaseFormat = format
18900
- .replace(/YYYY/g, 'yyyy')
18901
- .replace(/D/g, 'd')
18902
-
18903
- // 使用fecha库进行格式化,支持中文配置
18904
- const str = fecha.format(date, lowercaseFormat, getSettings());
18905
- return str;
18906
- };
18907
-
18908
- const parseDate = function(string, format) {
18909
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
18910
- };
18911
-
18912
- const getDayCountOfMonth = function(year, month) {
18913
- if (month === 3 || month === 5 || month === 8 || month === 10) {
18914
- return 30;
18915
- }
18916
-
18917
- if (month === 1) {
18918
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
18919
- return 29;
18920
- } else {
18921
- return 28;
18922
- }
18923
- }
18924
-
18925
- return 31;
18926
- };
18927
-
18928
- const getDayCountOfYear = function(year) {
18929
- const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
18930
- return isLeapYear ? 366 : 365;
18931
- };
18932
-
18933
- const getFirstDayOfMonth = function(date) {
18934
- const temp = new Date(date.getTime());
18935
- temp.setDate(1);
18936
- return temp.getDay();
18937
- };
18938
-
18939
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
18940
- // {prev, next} Date should work for Daylight Saving Time
18941
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
18942
- const prevDate = function(date, amount = 1) {
18943
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
18944
- };
18945
-
18946
- const nextDate = function(date, amount = 1) {
18947
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
18948
- };
18949
-
18950
- const getStartDateOfMonth = function(year, month) {
18951
- const result = new Date(year, month, 1);
18952
- const day = result.getDay();
18953
-
18954
- if (day === 0) {
18955
- return prevDate(result, 7);
18956
- } else {
18957
- return prevDate(result, day);
18958
- }
18959
- };
18960
-
18961
- const getWeekNumber = function(date) {
18962
- // 支持多种输入类型
18963
- if (!date||!isDate(date)) {
18964
- date = new Date();
18965
- }
18966
- if (typeof date === 'string') {
18967
- date = new Date(date);
18968
- }
18969
-
18970
- // 验证日期有效性
18971
- if (!isDate(date)) return null;
18972
-
18973
- const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
18974
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
18975
- // 将星期日的星期数设为7
18976
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
18977
- // 获取当年的第一天
18978
- const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
18979
- // 计算到最近的星期四的完整周数
18980
- const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
18981
- // 返回周数
18982
- return weekNo;
18983
- };
18984
-
18985
- const getRangeHours = function(ranges) {
18986
- const hours = [];
18987
- let disabledHours = [];
18988
-
18989
- (ranges || []).forEach(range => {
18990
- const value = range.map(date => date.getHours());
18991
-
18992
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
18993
- });
18994
-
18995
- if (disabledHours.length) {
18996
- for (let i = 0; i < 24; i++) {
18997
- hours[i] = disabledHours.indexOf(i) === -1;
18998
- }
18999
- } else {
19000
- for (let i = 0; i < 24; i++) {
19001
- hours[i] = false;
19002
- }
19003
- }
19004
-
19005
- return hours;
19006
- };
19007
-
19008
- const getPrevMonthLastDays = (date, amount) => {
19009
- if (amount <= 0) return [];
19010
- const temp = new Date(date.getTime());
19011
- temp.setDate(0);
19012
- const lastDay = temp.getDate();
19013
- return range(amount).map((_, index) => lastDay - (amount - index - 1));
19014
- };
19015
-
19016
- const getMonthDays = (date) => {
19017
- const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
19018
- const days = temp.getDate();
19019
- return range(days).map((_, index) => index + 1);
19020
- };
19021
-
19022
- function setRangeData(arr, start, end, value) {
19023
- for (let i = start; i < end; i++) {
19024
- arr[i] = value;
19025
- }
19026
- }
19027
-
19028
- const getRangeMinutes = function(ranges, hour) {
19029
- const minutes = new Array(60);
19030
-
19031
- if (ranges.length > 0) {
19032
- ranges.forEach(range => {
19033
- const start = range[0];
19034
- const end = range[1];
19035
- const startHour = start.getHours();
19036
- const startMinute = start.getMinutes();
19037
- const endHour = end.getHours();
19038
- const endMinute = end.getMinutes();
19039
- if (startHour === hour && endHour !== hour) {
19040
- setRangeData(minutes, startMinute, 60, true);
19041
- } else if (startHour === hour && endHour === hour) {
19042
- setRangeData(minutes, startMinute, endMinute + 1, true);
19043
- } else if (startHour !== hour && endHour === hour) {
19044
- setRangeData(minutes, 0, endMinute + 1, true);
19045
- } else if (startHour < hour && endHour > hour) {
19046
- setRangeData(minutes, 0, 60, true);
19047
- }
19048
- });
19049
- } else {
19050
- setRangeData(minutes, 0, 60, true);
19051
- }
19052
- return minutes;
19053
- };
19054
-
19055
- const range = function(n) {
19056
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
19057
- return Array.apply(null, {length: n}).map((_, n) => n);
19058
- };
19059
-
19060
- const modifyDate = function(date, y, m, d) {
19061
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
19062
- };
19063
-
19064
- const modifyTime = function(date, h, m, s) {
19065
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
19066
- };
19067
-
19068
- const modifyWithTimeString = (date, time) => {
19069
- if (date == null || !time) {
19070
- return date;
19071
- }
19072
- time = parseDate(time, 'HH:mm:ss');
19073
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
19074
- };
19075
-
19076
- const clearTime = function(date) {
19077
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
19078
- };
19079
-
19080
- const clearMilliseconds = function(date) {
19081
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
19082
- };
19083
-
19084
- const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
19085
- // TODO: refactory a more elegant solution
19086
- if (ranges.length === 0) return date;
19087
- const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
19088
- const ndate = normalizeDate(date);
19089
- const nranges = ranges.map(range => range.map(normalizeDate));
19090
- if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
19091
-
19092
- let minDate = nranges[0][0];
19093
- let maxDate = nranges[0][0];
19094
-
19095
- nranges.forEach(nrange => {
19096
- minDate = new Date(Math.min(nrange[0], minDate));
19097
- maxDate = new Date(Math.max(nrange[1], minDate));
19098
- });
19099
-
19100
- const ret = ndate < minDate ? minDate : maxDate;
19101
- // preserve Year/Month/Date
19102
- return modifyDate(
19103
- ret,
19104
- date.getFullYear(),
19105
- date.getMonth(),
19106
- date.getDate()
19107
- );
19108
- };
19109
-
19110
- const timeWithinRange = function(date, selectableRange, format) {
19111
- const limitedDate = limitTimeRange(date, selectableRange, format);
19112
- return limitedDate.getTime() === date.getTime();
19113
- };
19114
-
19115
- const changeYearMonthAndClampDate = function(date, year, month) {
19116
- // clamp date to the number of days in `year`, `month`
19117
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
19118
- const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
19119
- return modifyDate(date, year, month, monthDate);
19120
- };
19121
-
19122
- const prevMonth = function(date) {
19123
- const year = date.getFullYear();
19124
- const month = date.getMonth();
19125
- return month === 0
19126
- ? changeYearMonthAndClampDate(date, year - 1, 11)
19127
- : changeYearMonthAndClampDate(date, year, month - 1);
19128
- };
19129
-
19130
- const nextMonth = function(date) {
19131
- const year = date.getFullYear();
19132
- const month = date.getMonth();
19133
- return month === 11
19134
- ? changeYearMonthAndClampDate(date, year + 1, 0)
19135
- : changeYearMonthAndClampDate(date, year, month + 1);
19136
- };
19137
-
19138
- const prevYear = function(date, amount = 1) {
19139
- const year = date.getFullYear();
19140
- const month = date.getMonth();
19141
- return changeYearMonthAndClampDate(date, year - amount, month);
19142
- };
19143
-
19144
- const nextYear = function(date, amount = 1) {
19145
- const year = date.getFullYear();
19146
- const month = date.getMonth();
19147
- return changeYearMonthAndClampDate(date, year + amount, month);
19148
- };
19149
-
19150
- const extractDateFormat = function(format) {
19151
- return format
19152
- .replace(/\W?m{1,2}|\W?ZZ/g, '')
19153
- .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
19154
- .trim();
19155
- };
19156
-
19157
- const extractTimeFormat = function(format) {
19158
- return format
19159
- .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
19160
- .trim();
19161
- };
19162
-
19163
- const validateRangeInOneMonth = function(start, end) {
19164
- return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
19165
- };
19166
-
18606
+ */
18607
+ fecha.parse = function (dateStr, format) {
18608
+ if (typeof format !== 'string') {
18609
+ throw new Error('Invalid format in fecha.parse');
18610
+ }
18611
+
18612
+ format = fecha.masks[format] || format;
18613
+
18614
+ // Avoid regular expression denial of service, fail early for really long strings
18615
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
18616
+ if (dateStr.length > 1000) {
18617
+ return null;
18618
+ }
18619
+
18620
+ var dateInfo = {};
18621
+ var parseInfo = [];
18622
+ var literals = [];
18623
+ format = format.replace(literal, function ($0, $1) {
18624
+ literals.push($1);
18625
+ return '@@@';
18626
+ });
18627
+ var newFormat = regexEscape(format).replace(token, function ($0) {
18628
+ if (parseFlags[$0]) {
18629
+ var info = parseFlags[$0];
18630
+ parseInfo.push(info[1]);
18631
+ return '(' + info[0] + ')';
18632
+ }
18633
+
18634
+ return $0;
18635
+ });
18636
+ newFormat = newFormat.replace(/@@@/g, function () {
18637
+ return literals.shift();
18638
+ });
18639
+ var matches = dateStr.match(new RegExp(newFormat, 'i'));
18640
+ if (!matches) {
18641
+ return null;
18642
+ }
18643
+
18644
+ for (var i = 1; i < matches.length; i++) {
18645
+ parseInfo[i - 1](dateInfo, matches[i]);
18646
+ }
18647
+
18648
+ var today = new Date();
18649
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
18650
+ dateInfo.hour = +dateInfo.hour + 12;
18651
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
18652
+ dateInfo.hour = 0;
18653
+ }
18654
+
18655
+ var date = void 0;
18656
+ if (dateInfo.timezoneOffset != null) {
18657
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
18658
+ 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));
18659
+ } else {
18660
+ 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);
18661
+ }
18662
+ return date;
18663
+ };
18664
+
18665
+ // 导出fecha对象
18666
+
18667
+
18668
+ // 以下是从date-util.js合并的函数
18669
+ var newArray = function newArray(start, end) {
18670
+ var result = [];
18671
+ for (var i = start; i <= end; i++) {
18672
+ result.push(i);
18673
+ }
18674
+ return result;
18675
+ };
18676
+
18677
+ var getSettings = function getSettings() {
18678
+ return {
18679
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
18680
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
18681
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
18682
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
18683
+ amPm: ['上午', '下午']
18684
+ };
18685
+ };
18686
+
18687
+ var toDate = function toDate(date) {
18688
+ return isDate(date) ? new Date(date) : null;
18689
+ };
18690
+
18691
+ var isDate = function isDate(date) {
18692
+ if (date === null || date === undefined) return false;
18693
+ if (isNaN(new Date(date).getTime())) return false;
18694
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
18695
+ return true;
18696
+ };
18697
+
18698
+ var isDateObject = function isDateObject(val) {
18699
+ return val instanceof Date;
18700
+ };
18701
+
18702
+ var formatDate = function formatDate(date) {
18703
+ var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
18704
+
18705
+ // 处理多种输入类型
18706
+ if (!date) return '';
18707
+
18708
+ // 如果是时间戳,转成日期对象
18709
+ if (typeof date === 'number') {
18710
+ date = new Date(date);
18711
+ }
18712
+ // 如果是字符串,转成日期对象
18713
+ if (typeof date === 'string') {
18714
+ date = new Date(date);
18715
+ }
18716
+
18717
+ // 调用toDate进一步验证和转换
18718
+ date = toDate(date);
18719
+ if (!date) return '';
18720
+
18721
+ // 兼容大写和小写的格式标记
18722
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
18723
+ var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
18724
+
18725
+ // 使用fecha库进行格式化,支持中文配置
18726
+ var str = fecha.format(date, lowercaseFormat, getSettings());
18727
+ return str;
18728
+ };
18729
+
18730
+ var parseDate = function parseDate(string, format) {
18731
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
18732
+ };
18733
+
18734
+ var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
18735
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
18736
+ return 30;
18737
+ }
18738
+
18739
+ if (month === 1) {
18740
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
18741
+ return 29;
18742
+ } else {
18743
+ return 28;
18744
+ }
18745
+ }
18746
+
18747
+ return 31;
18748
+ };
18749
+
18750
+ var getDayCountOfYear = function getDayCountOfYear(year) {
18751
+ var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
18752
+ return isLeapYear ? 366 : 365;
18753
+ };
18754
+
18755
+ var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
18756
+ var temp = new Date(date.getTime());
18757
+ temp.setDate(1);
18758
+ return temp.getDay();
18759
+ };
18760
+
18761
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
18762
+ // {prev, next} Date should work for Daylight Saving Time
18763
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
18764
+ var prevDate = function prevDate(date) {
18765
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
18766
+
18767
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
18768
+ };
18769
+
18770
+ var nextDate = function nextDate(date) {
18771
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
18772
+
18773
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
18774
+ };
18775
+
18776
+ var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
18777
+ var result = new Date(year, month, 1);
18778
+ var day = result.getDay();
18779
+
18780
+ if (day === 0) {
18781
+ return prevDate(result, 7);
18782
+ } else {
18783
+ return prevDate(result, day);
18784
+ }
18785
+ };
18786
+
18787
+ var getWeekNumber = function getWeekNumber(date) {
18788
+ // 支持多种输入类型
18789
+ if (!date || !isDate(date)) {
18790
+ date = new Date();
18791
+ }
18792
+ if (typeof date === 'string') {
18793
+ date = new Date(date);
18794
+ }
18795
+
18796
+ // 验证日期有效性
18797
+ if (!isDate(date)) return null;
18798
+
18799
+ var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
18800
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
18801
+ // 将星期日的星期数设为7
18802
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
18803
+ // 获取当年的第一天
18804
+ var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
18805
+ // 计算到最近的星期四的完整周数
18806
+ var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
18807
+ // 返回周数
18808
+ return weekNo;
18809
+ };
18810
+
18811
+ var getRangeHours = function getRangeHours(ranges) {
18812
+ var hours = [];
18813
+ var disabledHours = [];
18814
+
18815
+ (ranges || []).forEach(function (range) {
18816
+ var value = range.map(function (date) {
18817
+ return date.getHours();
18818
+ });
18819
+
18820
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
18821
+ });
18822
+
18823
+ if (disabledHours.length) {
18824
+ for (var i = 0; i < 24; i++) {
18825
+ hours[i] = disabledHours.indexOf(i) === -1;
18826
+ }
18827
+ } else {
18828
+ for (var _i = 0; _i < 24; _i++) {
18829
+ hours[_i] = false;
18830
+ }
18831
+ }
18832
+
18833
+ return hours;
18834
+ };
18835
+
18836
+ var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
18837
+ if (amount <= 0) return [];
18838
+ var temp = new Date(date.getTime());
18839
+ temp.setDate(0);
18840
+ var lastDay = temp.getDate();
18841
+ return range(amount).map(function (_, index) {
18842
+ return lastDay - (amount - index - 1);
18843
+ });
18844
+ };
18845
+
18846
+ var getMonthDays = function getMonthDays(date) {
18847
+ var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
18848
+ var days = temp.getDate();
18849
+ return range(days).map(function (_, index) {
18850
+ return index + 1;
18851
+ });
18852
+ };
18853
+
18854
+ function setRangeData(arr, start, end, value) {
18855
+ for (var i = start; i < end; i++) {
18856
+ arr[i] = value;
18857
+ }
18858
+ }
18859
+
18860
+ var getRangeMinutes = function getRangeMinutes(ranges, hour) {
18861
+ var minutes = new Array(60);
18862
+
18863
+ if (ranges.length > 0) {
18864
+ ranges.forEach(function (range) {
18865
+ var start = range[0];
18866
+ var end = range[1];
18867
+ var startHour = start.getHours();
18868
+ var startMinute = start.getMinutes();
18869
+ var endHour = end.getHours();
18870
+ var endMinute = end.getMinutes();
18871
+ if (startHour === hour && endHour !== hour) {
18872
+ setRangeData(minutes, startMinute, 60, true);
18873
+ } else if (startHour === hour && endHour === hour) {
18874
+ setRangeData(minutes, startMinute, endMinute + 1, true);
18875
+ } else if (startHour !== hour && endHour === hour) {
18876
+ setRangeData(minutes, 0, endMinute + 1, true);
18877
+ } else if (startHour < hour && endHour > hour) {
18878
+ setRangeData(minutes, 0, 60, true);
18879
+ }
18880
+ });
18881
+ } else {
18882
+ setRangeData(minutes, 0, 60, true);
18883
+ }
18884
+ return minutes;
18885
+ };
18886
+
18887
+ var range = function range(n) {
18888
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
18889
+ return Array.apply(null, { length: n }).map(function (_, n) {
18890
+ return n;
18891
+ });
18892
+ };
18893
+
18894
+ var modifyDate = function modifyDate(date, y, m, d) {
18895
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
18896
+ };
18897
+
18898
+ var modifyTime = function modifyTime(date, h, m, s) {
18899
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
18900
+ };
18901
+
18902
+ var modifyWithTimeString = function modifyWithTimeString(date, time) {
18903
+ if (date == null || !time) {
18904
+ return date;
18905
+ }
18906
+ time = parseDate(time, 'HH:mm:ss');
18907
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
18908
+ };
18909
+
18910
+ var clearTime = function clearTime(date) {
18911
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
18912
+ };
18913
+
18914
+ var clearMilliseconds = function clearMilliseconds(date) {
18915
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
18916
+ };
18917
+
18918
+ var limitTimeRange = function limitTimeRange(date, ranges) {
18919
+ var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
18920
+
18921
+ // TODO: refactory a more elegant solution
18922
+ if (ranges.length === 0) return date;
18923
+ var normalizeDate = function normalizeDate(date) {
18924
+ return fecha.parse(fecha.format(date, format), format);
18925
+ };
18926
+ var ndate = normalizeDate(date);
18927
+ var nranges = ranges.map(function (range) {
18928
+ return range.map(normalizeDate);
18929
+ });
18930
+ if (nranges.some(function (nrange) {
18931
+ return ndate >= nrange[0] && ndate <= nrange[1];
18932
+ })) return date;
18933
+
18934
+ var minDate = nranges[0][0];
18935
+ var maxDate = nranges[0][0];
18936
+
18937
+ nranges.forEach(function (nrange) {
18938
+ minDate = new Date(Math.min(nrange[0], minDate));
18939
+ maxDate = new Date(Math.max(nrange[1], minDate));
18940
+ });
18941
+
18942
+ var ret = ndate < minDate ? minDate : maxDate;
18943
+ // preserve Year/Month/Date
18944
+ return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
18945
+ };
18946
+
18947
+ var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
18948
+ var limitedDate = limitTimeRange(date, selectableRange, format);
18949
+ return limitedDate.getTime() === date.getTime();
18950
+ };
18951
+
18952
+ var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
18953
+ // clamp date to the number of days in `year`, `month`
18954
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
18955
+ var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
18956
+ return modifyDate(date, year, month, monthDate);
18957
+ };
18958
+
18959
+ var prevMonth = function prevMonth(date) {
18960
+ var year = date.getFullYear();
18961
+ var month = date.getMonth();
18962
+ return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
18963
+ };
18964
+
18965
+ var nextMonth = function nextMonth(date) {
18966
+ var year = date.getFullYear();
18967
+ var month = date.getMonth();
18968
+ return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
18969
+ };
18970
+
18971
+ var prevYear = function prevYear(date) {
18972
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
18973
+
18974
+ var year = date.getFullYear();
18975
+ var month = date.getMonth();
18976
+ return changeYearMonthAndClampDate(date, year - amount, month);
18977
+ };
18978
+
18979
+ var nextYear = function nextYear(date) {
18980
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
18981
+
18982
+ var year = date.getFullYear();
18983
+ var month = date.getMonth();
18984
+ return changeYearMonthAndClampDate(date, year + amount, month);
18985
+ };
18986
+
18987
+ var extractDateFormat = function extractDateFormat(format) {
18988
+ return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
18989
+ };
18990
+
18991
+ var extractTimeFormat = function extractTimeFormat(format) {
18992
+ return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
18993
+ };
18994
+
18995
+ var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
18996
+ return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
18997
+ };
18998
+
19167
18999
  /**
19168
19000
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
19169
19001
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
19170
19002
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
19171
19003
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
19172
19004
  * @returns {number} 工作日数量
19173
- */
19174
- const calculateNetworkDays = function (start_date, end_date, holidays = []) {
19175
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
19176
- throw new Error(
19177
- "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
19178
- );
19179
- }
19180
-
19181
- const startDateObj = new Date(start_date);
19182
- const endDateObj = new Date(end_date);
19183
-
19184
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
19185
- throw new Error(
19186
- "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
19187
- );
19188
- }
19189
-
19190
- if (startDateObj > endDateObj) {
19191
- throw new Error('Start date should be earlier than or equal to end date.');
19192
- }
19193
-
19194
- let workdays = 0;
19195
-
19196
- // Iterate through each day in the date range
19197
- for (
19198
- let currentDate = new Date(startDateObj);
19199
- currentDate <= endDateObj;
19200
- currentDate.setDate(currentDate.getDate() + 1)
19201
- ) {
19202
- // Check if the current day is a weekend (Saturday or Sunday)
19203
- const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
19204
-
19205
- // Check if the current day is a holiday
19206
- const isHoliday = holidays.some((holiday) => {
19207
- const holidayDate = new Date(holiday);
19208
- return currentDate.toDateString() === holidayDate.toDateString();
19209
- });
19210
-
19211
- // If it's a workday (not a weekend or holiday), increment the workdays count
19212
- if (!isWeekend && !isHoliday) {
19213
- workdays++;
19214
- }
19215
- }
19216
-
19217
- return workdays;
19218
- };
19219
-
19005
+ */
19006
+ var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
19007
+ var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
19008
+
19009
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
19010
+ throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
19011
+ }
19012
+
19013
+ var startDateObj = new Date(start_date);
19014
+ var endDateObj = new Date(end_date);
19015
+
19016
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
19017
+ throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
19018
+ }
19019
+
19020
+ if (startDateObj > endDateObj) {
19021
+ throw new Error('Start date should be earlier than or equal to end date.');
19022
+ }
19023
+
19024
+ var workdays = 0;
19025
+
19026
+ // Iterate through each day in the date range
19027
+
19028
+ var _loop = function _loop(currentDate) {
19029
+ // Check if the current day is a weekend (Saturday or Sunday)
19030
+ var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
19031
+
19032
+ // Check if the current day is a holiday
19033
+ var isHoliday = holidays.some(function (holiday) {
19034
+ var holidayDate = new Date(holiday);
19035
+ return currentDate.toDateString() === holidayDate.toDateString();
19036
+ });
19037
+
19038
+ // If it's a workday (not a weekend or holiday), increment the workdays count
19039
+ if (!isWeekend && !isHoliday) {
19040
+ workdays++;
19041
+ }
19042
+ };
19043
+
19044
+ for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
19045
+ _loop(currentDate);
19046
+ }
19047
+
19048
+ return workdays;
19049
+ };
19050
+
19220
19051
  /**
19221
19052
  * 日期加减天数
19222
19053
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
19223
19054
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
19224
19055
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
19225
- */
19226
- const dateAddDays = function (start_date, days) {
19227
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
19228
- throw new Error(
19229
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
19230
- );
19231
- }
19232
-
19233
- const startDateObj = new Date(start_date);
19234
- if (isNaN(startDateObj.getTime())) {
19235
- throw new Error(
19236
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
19237
- );
19238
- }
19239
-
19240
- const resultDateObj = new Date(startDateObj);
19241
- resultDateObj.setDate(resultDateObj.getDate() + days);
19242
-
19243
- const resultYear = resultDateObj.getFullYear();
19244
- const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
19245
- const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
19246
-
19247
- return `${resultYear}-${resultMonth}-${resultDay}`;
19248
- };
19249
-
19056
+ */
19057
+ var dateAddDays = function dateAddDays(start_date, days) {
19058
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
19059
+ 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.");
19060
+ }
19061
+
19062
+ var startDateObj = new Date(start_date);
19063
+ if (isNaN(startDateObj.getTime())) {
19064
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
19065
+ }
19066
+
19067
+ var resultDateObj = new Date(startDateObj);
19068
+ resultDateObj.setDate(resultDateObj.getDate() + days);
19069
+
19070
+ var resultYear = resultDateObj.getFullYear();
19071
+ var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
19072
+ var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
19073
+
19074
+ return resultYear + '-' + resultMonth + '-' + resultDay;
19075
+ };
19076
+
19250
19077
  /**
19251
19078
  * 计算两个日期之间的差值
19252
19079
  * @date 2023年12月14日
@@ -19254,182 +19081,180 @@ const dateAddDays = function (start_date, days) {
19254
19081
  * @param {String} end_date - 结束日期字符串
19255
19082
  * @param {String} unit - 单位:year/month/day
19256
19083
  * @returns {Number} 差值
19257
- */
19258
- const dateDiff = function (start_date, end_date, unit = 'day') {
19259
- // Assuming date strings are in "YYYY-MM-DD" format
19260
- var startDate = new Date(start_date);
19261
- var endDate = new Date(end_date);
19262
-
19263
- // If the date is invalid, return 0
19264
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
19265
- return 0;
19266
- }
19267
-
19268
- if (unit === 'year') {
19269
- return endDate.getFullYear() - startDate.getFullYear();
19270
- } else if (unit === 'month') {
19271
- return (
19272
- (endDate.getFullYear() - startDate.getFullYear()) * 12 +
19273
- (endDate.getMonth() - startDate.getMonth())
19274
- );
19275
- } else {
19276
- // Default to day
19277
- var timeDifference = endDate - startDate;
19278
- // Calculate days (86400000 milliseconds per day)
19279
- return Math.floor(timeDifference / 86400000);
19280
- }
19281
- };
19282
-
19084
+ */
19085
+ var dateDiff = function dateDiff(start_date, end_date) {
19086
+ var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
19087
+
19088
+ // Assuming date strings are in "YYYY-MM-DD" format
19089
+ var startDate = new Date(start_date);
19090
+ var endDate = new Date(end_date);
19091
+
19092
+ // If the date is invalid, return 0
19093
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
19094
+ return 0;
19095
+ }
19096
+
19097
+ if (unit === 'year') {
19098
+ return endDate.getFullYear() - startDate.getFullYear();
19099
+ } else if (unit === 'month') {
19100
+ return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
19101
+ } else {
19102
+ // Default to day
19103
+ var timeDifference = endDate - startDate;
19104
+ // Calculate days (86400000 milliseconds per day)
19105
+ return Math.floor(timeDifference / 86400000);
19106
+ }
19107
+ };
19108
+
19283
19109
  /**
19284
19110
  * 获取月份中的日期
19285
19111
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
19286
19112
  * @returns {number} 月份中的日期(1-31)
19287
- */
19288
- const dayOfMonth = function (date) {
19289
- if (typeof date !== 'string') {
19290
- throw new Error(
19291
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
19292
- );
19293
- }
19294
-
19295
- const dateObj = new Date(date);
19296
- if (isNaN(dateObj.getTime())) {
19297
- throw new Error(
19298
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
19299
- );
19300
- }
19301
-
19302
- return dateObj.getDate();
19303
- };
19304
-
19113
+ */
19114
+ var dayOfMonth = function dayOfMonth(date) {
19115
+ if (typeof date !== 'string') {
19116
+ throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
19117
+ }
19118
+
19119
+ var dateObj = new Date(date);
19120
+ if (isNaN(dateObj.getTime())) {
19121
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
19122
+ }
19123
+
19124
+ return dateObj.getDate();
19125
+ };
19126
+
19305
19127
  /**
19306
19128
  * 获取当前日期
19307
19129
  * @date 2022年5月7日
19308
19130
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
19309
19131
  * @returns {string} 当前日期的格式化字符串
19310
- */
19311
- const getCurrentDate = function (format = 'YYYY-MM-DD') {
19312
- return formatDate(new Date(), format);
19313
- };
19314
-
19132
+ */
19133
+ var getCurrentDate = function getCurrentDate() {
19134
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
19135
+
19136
+ return formatDate(new Date(), format);
19137
+ };
19138
+
19315
19139
  /**
19316
19140
  * 获取当前日期时间
19317
19141
  * @date 2022年5月7日
19318
19142
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
19319
19143
  * @returns {string} 当前日期时间的格式化字符串
19320
- */
19321
- const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
19322
- return formatDate(new Date(), format);
19323
- };
19324
-
19144
+ */
19145
+ var getCurrentDateTime = function getCurrentDateTime() {
19146
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
19147
+
19148
+ return formatDate(new Date(), format);
19149
+ };
19150
+
19325
19151
  /**
19326
19152
  * 获取小时
19327
19153
  * @date 2022年5月7日
19328
19154
  * @param {Date|string} [date] - 日期对象或日期字符串
19329
19155
  * @returns {number} 小时数(0-23)
19330
- */
19331
- const getHour = function (date) {
19332
- if (!date) {
19333
- return new Date().getHours();
19334
- }
19335
- if (typeof date === 'string') {
19336
- date = new Date(date);
19337
- }
19338
- return date.getHours();
19339
- };
19340
-
19156
+ */
19157
+ var getHour = function getHour(date) {
19158
+ if (!date) {
19159
+ return new Date().getHours();
19160
+ }
19161
+ if (typeof date === 'string') {
19162
+ date = new Date(date);
19163
+ }
19164
+ return date.getHours();
19165
+ };
19166
+
19341
19167
  /**
19342
19168
  * 获取分钟
19343
19169
  * @date 2022年5月7日
19344
19170
  * @param {Date|string} [date] - 日期对象或日期字符串
19345
19171
  * @returns {number} 分钟数(0-59)
19346
- */
19347
- const getMinute = function (date) {
19348
- if (!date) {
19349
- return new Date().getMinutes();
19350
- }
19351
- if (typeof date === 'string') {
19352
- date = new Date(date);
19353
- }
19354
- return date.getMinutes();
19355
- };
19356
-
19172
+ */
19173
+ var getMinute = function getMinute(date) {
19174
+ if (!date) {
19175
+ return new Date().getMinutes();
19176
+ }
19177
+ if (typeof date === 'string') {
19178
+ date = new Date(date);
19179
+ }
19180
+ return date.getMinutes();
19181
+ };
19182
+
19357
19183
  /**
19358
19184
  * 获取月份
19359
19185
  * @date 2022年5月7日
19360
19186
  * @param {Date|string} [date] - 日期对象或日期字符串
19361
19187
  * @returns {number} 月份数(1-12)
19362
- */
19363
- const getMonth = function (date) {
19364
- if (!date) {
19365
- return new Date().getMonth() + 1;
19366
- }
19367
- if (typeof date === 'string') {
19368
- date = new Date(date);
19369
- }
19370
- return date.getMonth() + 1;
19371
- };
19372
-
19188
+ */
19189
+ var getMonth = function getMonth(date) {
19190
+ if (!date) {
19191
+ return new Date().getMonth() + 1;
19192
+ }
19193
+ if (typeof date === 'string') {
19194
+ date = new Date(date);
19195
+ }
19196
+ return date.getMonth() + 1;
19197
+ };
19198
+
19373
19199
  /**
19374
19200
  * 获取秒
19375
19201
  * @date 2022年5月7日
19376
19202
  * @param {Date|string} [date] - 日期对象或日期字符串
19377
19203
  * @returns {number} 秒数(0-59)
19378
- */
19379
- const getSecond = function (date) {
19380
- if (!date) {
19381
- return new Date().getSeconds();
19382
- }
19383
- if (typeof date === 'string') {
19384
- date = new Date(date);
19385
- }
19386
- return date.getSeconds();
19387
- };
19388
-
19204
+ */
19205
+ var getSecond = function getSecond(date) {
19206
+ if (!date) {
19207
+ return new Date().getSeconds();
19208
+ }
19209
+ if (typeof date === 'string') {
19210
+ date = new Date(date);
19211
+ }
19212
+ return date.getSeconds();
19213
+ };
19214
+
19389
19215
  /**
19390
19216
  * 获取星期几
19391
19217
  * @date 2022年5月7日
19392
19218
  * @param {Date|string} [date] - 日期对象或日期字符串
19393
19219
  * @returns {number} 星期几(0-6,0表示星期日)
19394
- */
19395
- const getWeekday = function (date) {
19396
- if (!date) {
19397
- return new Date().getDay();
19398
- }
19399
- if (typeof date === 'string') {
19400
- date = new Date(date);
19401
- }
19402
- return date.getDay();
19403
- };
19404
-
19405
-
19220
+ */
19221
+ var getWeekday = function getWeekday(date) {
19222
+ if (!date) {
19223
+ return new Date().getDay();
19224
+ }
19225
+ if (typeof date === 'string') {
19226
+ date = new Date(date);
19227
+ }
19228
+ return date.getDay();
19229
+ };
19230
+
19406
19231
  /**
19407
19232
  * @desc 获取上午/下午/晚上
19408
19233
  * @author huangbo
19409
19234
  * @date 2022年5月7日
19410
19235
  * @param {String} [time] - 时间
19411
- **/
19412
- const timeCycle = function (time) {
19413
- let hour = 0;
19414
- if (!time) {
19415
- hour = new Date().getHours();
19416
- } else if (typeof time === 'string') {
19417
- // 从时间字符串中提取小时
19418
- const match = time.match(/^(\d{1,2})/);
19419
- if (match) {
19420
- hour = parseInt(match[1], 10);
19421
- }
19422
- } else if (typeof time === 'number') {
19423
- hour = time;
19424
- }
19425
- // 判断时间段
19426
- if (hour >= 5 && hour < 12) {
19427
- return '上午';
19428
- } else if (hour >= 12 && hour < 18) {
19429
- return '下午';
19430
- } else {
19431
- return '晚上';
19432
- }
19236
+ **/
19237
+ var timeCycle = function timeCycle(time) {
19238
+ var hour = 0;
19239
+ if (!time) {
19240
+ hour = new Date().getHours();
19241
+ } else if (typeof time === 'string') {
19242
+ // 从时间字符串中提取小时
19243
+ var match = time.match(/^(\d{1,2})/);
19244
+ if (match) {
19245
+ hour = parseInt(match[1], 10);
19246
+ }
19247
+ } else if (typeof time === 'number') {
19248
+ hour = time;
19249
+ }
19250
+ // 判断时间段
19251
+ if (hour >= 5 && hour < 12) {
19252
+ return '上午';
19253
+ } else if (hour >= 12 && hour < 18) {
19254
+ return '下午';
19255
+ } else {
19256
+ return '晚上';
19257
+ }
19433
19258
  };
19434
19259
 
19435
19260
  /***/ }),
@@ -19441,7 +19266,7 @@ module.exports = require("eoss/lib/message-box");
19441
19266
 
19442
19267
  /***/ }),
19443
19268
 
19444
- /***/ 87:
19269
+ /***/ 89:
19445
19270
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
19446
19271
 
19447
19272
  "use strict";