eoss 0.1.0-alpha.35 → 0.1.0-alpha.37

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 (228) 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 +1101 -1035
  83. package/lib/alert.js +2 -2
  84. package/lib/aside.js +2 -2
  85. package/lib/audit-trajectory.js +150 -150
  86. package/lib/autocomplete.js +2095 -1871
  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 +862 -837
  95. package/lib/calendar.js +864 -839
  96. package/lib/card.js +2 -2
  97. package/lib/carousel-item.js +864 -839
  98. package/lib/carousel.js +866 -841
  99. package/lib/cascader-panel.js +878 -853
  100. package/lib/cascader.js +2325 -2101
  101. package/lib/checkbox-button.js +4 -4
  102. package/lib/checkbox-group.js +1060 -1025
  103. package/lib/checkbox.js +6 -6
  104. package/lib/col.js +2 -2
  105. package/lib/collapse-item.js +920 -895
  106. package/lib/collapse.js +913 -888
  107. package/lib/color-picker.js +1155 -956
  108. package/lib/container.js +2 -2
  109. package/lib/cron.js +18 -18
  110. package/lib/data-table.js +1053 -1018
  111. package/lib/date-picker.js +2094 -1870
  112. package/lib/descriptions-item.js +144 -0
  113. package/lib/descriptions.js +561 -0
  114. package/lib/dialog.js +943 -918
  115. package/lib/divider.js +2 -2
  116. package/lib/drawer.js +12 -12
  117. package/lib/dropdown-item.js +6 -6
  118. package/lib/dropdown-menu.js +1157 -958
  119. package/lib/dropdown.js +870 -845
  120. package/lib/email-login.js +1047 -1012
  121. package/lib/empty.js +2 -2
  122. package/lib/eoss.common.js +3493 -2313
  123. package/lib/flip.js +2 -2
  124. package/lib/flow-group.js +876 -851
  125. package/lib/flow.js +1184 -1149
  126. package/lib/flows.js +1080 -1045
  127. package/lib/footer.js +2 -2
  128. package/lib/form-item.js +877 -852
  129. package/lib/form.js +1123 -1087
  130. package/lib/guide.js +2 -2
  131. package/lib/header.js +2 -2
  132. package/lib/icon.js +1009 -984
  133. package/lib/icons.js +6 -6
  134. package/lib/image-viewer.js +862 -837
  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 +870 -845
  140. package/lib/link.js +2 -2
  141. package/lib/loading.js +13 -13
  142. package/lib/login.js +1116 -1066
  143. package/lib/lowcode-view.js +1078 -1043
  144. package/lib/lowcode.js +1131 -1096
  145. package/lib/main.js +1185 -1148
  146. package/lib/marquee.js +862 -837
  147. package/lib/menu-item-group.js +20 -17
  148. package/lib/menu-item.js +8 -8
  149. package/lib/menu.js +2390 -2164
  150. package/lib/message-box.js +950 -925
  151. package/lib/message.js +941 -916
  152. package/lib/notification.js +962 -937
  153. package/lib/option-group.js +4 -4
  154. package/lib/option.js +871 -846
  155. package/lib/page-header.js +2 -2
  156. package/lib/pagination.js +866 -841
  157. package/lib/phone-login.js +1049 -1014
  158. package/lib/popconfirm.js +4 -4
  159. package/lib/popover.js +2100 -1876
  160. package/lib/process-config.js +1065 -1030
  161. package/lib/process-module.js +1053 -1018
  162. package/lib/process-rule.js +1062 -1027
  163. package/lib/progress.js +2 -2
  164. package/lib/qr-code.js +4 -4
  165. package/lib/qrcode-login.js +1052 -1017
  166. package/lib/radio-button.js +4 -4
  167. package/lib/radio-group.js +2608 -2573
  168. package/lib/radio.js +6 -6
  169. package/lib/rate.js +864 -839
  170. package/lib/retrial-auth.js +7063 -0
  171. package/lib/row.js +2 -2
  172. package/lib/scrollbar.js +868 -843
  173. package/lib/select.js +2591 -2357
  174. package/lib/selector-panel.js +2659 -2624
  175. package/lib/selector.js +1068 -1033
  176. package/lib/slider.js +6 -6
  177. package/lib/step.js +44 -44
  178. package/lib/steps.js +911 -886
  179. package/lib/submenu.js +1439 -1236
  180. package/lib/switch.js +866 -841
  181. package/lib/tab-pane.js +4 -4
  182. package/lib/table-column.js +936 -911
  183. package/lib/table.js +2318 -2084
  184. package/lib/tabs.js +866 -841
  185. package/lib/tag.js +2 -2
  186. package/lib/theme-chalk/base.css +1 -1
  187. package/lib/theme-chalk/descriptions.css +1 -1
  188. package/lib/theme-chalk/index.css +1 -1
  189. package/lib/theme-chalk/main.css +1 -1
  190. package/lib/theme-chalk/retrial-auth.css +1 -0
  191. package/lib/time-picker.js +2047 -1823
  192. package/lib/time-select.js +2041 -1817
  193. package/lib/timeline-item.js +2 -2
  194. package/lib/timeline.js +2 -2
  195. package/lib/tips.js +1047 -1012
  196. package/lib/toolbar.js +36 -17
  197. package/lib/tooltip.js +2080 -1856
  198. package/lib/transfer.js +881 -856
  199. package/lib/tree-group.js +1020 -995
  200. package/lib/tree.js +1062 -1027
  201. package/lib/update-history.js +151 -151
  202. package/lib/upload.js +1082 -1047
  203. package/lib/utils/ajax.js +5 -1
  204. package/lib/utils/popper.js +97 -48
  205. package/lib/wujie.js +866 -841
  206. package/package.json +1 -1
  207. package/packages/account-login/src/account-login.vue +29 -0
  208. package/packages/descriptions/index.js +8 -0
  209. package/packages/descriptions/src/index.js +181 -0
  210. package/packages/descriptions/src/item.js +30 -0
  211. package/packages/descriptions/src/row.js +120 -0
  212. package/packages/descriptions-item/index.js +8 -0
  213. package/packages/login/src/login.vue +8 -0
  214. package/packages/login/src/mixins.js +3 -1
  215. package/packages/main/src/minxs.js +1 -0
  216. package/packages/menu/src/menu.vue +0 -1
  217. package/packages/menu/src/mixins.js +4 -3
  218. package/packages/menu/src/submenu.vue +4 -4
  219. package/packages/retrial-auth/index.js +5 -0
  220. package/packages/retrial-auth/src/main.vue +300 -0
  221. package/packages/theme-chalk/src/base.scss +2 -1
  222. package/packages/theme-chalk/src/descriptions.scss +0 -1
  223. package/packages/theme-chalk/src/index.scss +3 -0
  224. package/packages/theme-chalk/src/retrial-auth.scss +38 -0
  225. package/packages/toolbar/src/toolbar.vue +5 -0
  226. package/src/index.js +336 -327
  227. package/src/utils/ajax.js +2 -1
  228. package/src/utils/popper.js +109 -70
@@ -82,12 +82,12 @@ module.exports =
82
82
  /******/
83
83
  /******/
84
84
  /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 213);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 216);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
89
89
 
90
- /***/ 10:
90
+ /***/ 11:
91
91
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
92
92
 
93
93
  "use strict";
@@ -303,11 +303,11 @@ if (!vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer) {
303
303
  }
304
304
 
305
305
  /* harmony default export */ __webpack_exports__["a"] = (PopupManager);
306
- /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(44)))
306
+ /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(45)))
307
307
 
308
308
  /***/ }),
309
309
 
310
- /***/ 113:
310
+ /***/ 115:
311
311
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
312
312
 
313
313
  "use strict";
@@ -687,11 +687,11 @@ render._withStripped = true
687
687
  var date = __webpack_require__(7);
688
688
 
689
689
  // EXTERNAL MODULE: external "eoss/lib/scrollbar"
690
- var scrollbar_ = __webpack_require__(30);
690
+ var scrollbar_ = __webpack_require__(34);
691
691
  var scrollbar_default = /*#__PURE__*/__webpack_require__.n(scrollbar_);
692
692
 
693
693
  // EXTERNAL MODULE: ./src/directives/repeat-click.js
694
- var repeat_click = __webpack_require__(96);
694
+ var repeat_click = __webpack_require__(97);
695
695
 
696
696
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/date-picker/src/basic/time-spinner.vue?vue&type=script&lang=js&
697
697
  //
@@ -1120,29 +1120,7 @@ module.exports = require("vue");
1120
1120
 
1121
1121
  /***/ }),
1122
1122
 
1123
- /***/ 21:
1124
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
1125
-
1126
- "use strict";
1127
- /* harmony default export */ __webpack_exports__["a"] = (function (target) {
1128
- for (var i = 1, j = arguments.length; i < j; i++) {
1129
- var source = arguments[i] || {};
1130
- for (var prop in source) {
1131
- if (source.hasOwnProperty(prop)) {
1132
- var value = source[prop];
1133
- if (value !== undefined) {
1134
- target[prop] = value;
1135
- }
1136
- }
1137
- }
1138
- }
1139
-
1140
- return target;
1141
- });;
1142
-
1143
- /***/ }),
1144
-
1145
- /***/ 213:
1123
+ /***/ 216:
1146
1124
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1147
1125
 
1148
1126
  "use strict";
@@ -1150,10 +1128,10 @@ module.exports = require("vue");
1150
1128
  __webpack_require__.r(__webpack_exports__);
1151
1129
 
1152
1130
  // EXTERNAL MODULE: ./packages/date-picker/src/picker.vue + 4 modules
1153
- var picker = __webpack_require__(98);
1131
+ var picker = __webpack_require__(99);
1154
1132
 
1155
1133
  // EXTERNAL MODULE: ./packages/date-picker/src/panel/time.vue + 4 modules
1156
- var time = __webpack_require__(95);
1134
+ var time = __webpack_require__(96);
1157
1135
 
1158
1136
  // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/date-picker/src/panel/time-range.vue?vue&type=template&id=77b22d27&
1159
1137
  var render = function () {
@@ -1295,7 +1273,7 @@ render._withStripped = true
1295
1273
  var utils_date = __webpack_require__(7);
1296
1274
 
1297
1275
  // EXTERNAL MODULE: ./packages/date-picker/src/basic/time-spinner.vue + 4 modules
1298
- var time_spinner = __webpack_require__(113);
1276
+ var time_spinner = __webpack_require__(115);
1299
1277
 
1300
1278
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/date-picker/src/panel/time-range.vue?vue&type=script&lang=js&
1301
1279
  //
@@ -1638,6 +1616,28 @@ time_picker.install = function (Vue) {
1638
1616
  /***/ 22:
1639
1617
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1640
1618
 
1619
+ "use strict";
1620
+ /* harmony default export */ __webpack_exports__["a"] = (function (target) {
1621
+ for (var i = 1, j = arguments.length; i < j; i++) {
1622
+ var source = arguments[i] || {};
1623
+ for (var prop in source) {
1624
+ if (source.hasOwnProperty(prop)) {
1625
+ var value = source[prop];
1626
+ if (value !== undefined) {
1627
+ target[prop] = value;
1628
+ }
1629
+ }
1630
+ }
1631
+ }
1632
+
1633
+ return target;
1634
+ });;
1635
+
1636
+ /***/ }),
1637
+
1638
+ /***/ 23:
1639
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1640
+
1641
1641
  "use strict";
1642
1642
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return getScrollbarWidth; });
1643
1643
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return scrollIntoView; });
@@ -1786,11 +1786,11 @@ function scrollMove(wrap) {
1786
1786
  "use strict";
1787
1787
  /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
1788
1788
  /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(vue__WEBPACK_IMPORTED_MODULE_0__);
1789
- /* harmony import */ var eoss_src_utils_popup__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(28);
1789
+ /* harmony import */ var eoss_src_utils_popup__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(32);
1790
1790
 
1791
1791
 
1792
1792
 
1793
- var PopperJS = vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer ? function () {} : __webpack_require__(51);
1793
+ var PopperJS = vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer ? function () {} : __webpack_require__(52);
1794
1794
  var stopPropagation = function stopPropagation(e) {
1795
1795
  return e.stopPropagation();
1796
1796
  };
@@ -2051,17 +2051,17 @@ var stopPropagation = function stopPropagation(e) {
2051
2051
 
2052
2052
  /***/ }),
2053
2053
 
2054
- /***/ 28:
2054
+ /***/ 32:
2055
2055
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
2056
2056
 
2057
2057
  "use strict";
2058
2058
  /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
2059
2059
  /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(vue__WEBPACK_IMPORTED_MODULE_0__);
2060
- /* harmony import */ var eoss_src_utils_merge__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(21);
2061
- /* harmony import */ var eoss_src_utils_popup_popup_manager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(10);
2060
+ /* harmony import */ var eoss_src_utils_merge__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(22);
2061
+ /* harmony import */ var eoss_src_utils_popup_popup_manager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(11);
2062
2062
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "a", function() { return eoss_src_utils_popup_popup_manager__WEBPACK_IMPORTED_MODULE_2__["a"]; });
2063
2063
 
2064
- /* harmony import */ var _scrollbar__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(22);
2064
+ /* harmony import */ var _scrollbar__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(23);
2065
2065
  /* harmony import */ var _dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5);
2066
2066
 
2067
2067
 
@@ -2292,7 +2292,7 @@ var scrollBarWidth = void 0;
2292
2292
 
2293
2293
  /***/ }),
2294
2294
 
2295
- /***/ 30:
2295
+ /***/ 34:
2296
2296
  /***/ (function(module, exports) {
2297
2297
 
2298
2298
  module.exports = require("eoss/lib/scrollbar");
@@ -2404,7 +2404,7 @@ function normalizeComponent(
2404
2404
 
2405
2405
  /***/ }),
2406
2406
 
2407
- /***/ 42:
2407
+ /***/ 43:
2408
2408
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
2409
2409
 
2410
2410
  "use strict";
@@ -2525,7 +2525,7 @@ function createDocumentHandler(el, binding, vnode) {
2525
2525
 
2526
2526
  /***/ }),
2527
2527
 
2528
- /***/ 44:
2528
+ /***/ 45:
2529
2529
  /***/ (function(module, exports) {
2530
2530
 
2531
2531
  var g;
@@ -2811,12 +2811,10 @@ function insertAfter(newEl, targetEl) {
2811
2811
 
2812
2812
  /***/ }),
2813
2813
 
2814
- /***/ 51:
2814
+ /***/ 52:
2815
2815
  /***/ (function(module, exports, __webpack_require__) {
2816
2816
 
2817
- 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; };
2818
-
2819
- /**
2817
+ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
2820
2818
  * @fileOverview Kickass library to create and place poppers near their reference elements.
2821
2819
  * @version {{version}}
2822
2820
  * @license
@@ -2839,60 +2837,68 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
2839
2837
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2840
2838
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2841
2839
  * SOFTWARE.
2842
- */
2843
-
2844
- //
2845
- // Cross module loader
2846
- // Supported: Node, AMD, Browser globals
2847
- //
2848
- (function (root, factory) {
2849
- if (true) {
2850
- // AMD. Register as an anonymous module.
2840
+ */
2841
+
2842
+ //
2843
+ // Cross module loader
2844
+ // Supported: Node, AMD, Browser globals
2845
+ //
2846
+ (function (root, factory) {
2847
+ if (true) {
2848
+ // AMD. Register as an anonymous module.
2851
2849
  !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
2852
2850
  __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
2853
2851
  (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
2854
2852
  __WEBPACK_AMD_DEFINE_FACTORY__),
2855
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
2856
- } else {}
2857
- })(this, function () {
2858
- 'use strict';
2859
-
2860
- var root = window;
2861
- // default options
2862
- var DEFAULTS = {
2863
- // placement of the popper
2864
- placement: 'bottom',
2865
-
2866
- gpuAcceleration: true,
2867
-
2868
- // shift popper from its origin by the given amount of pixels (can be negative)
2869
- offset: 0,
2870
-
2871
- // the element which will act as boundary of the popper
2872
- boundariesElement: 'viewport',
2873
-
2874
- // amount of pixel used to define a minimum distance between the boundaries and the popper
2875
- boundariesPadding: 5,
2876
-
2877
- // popper will try to prevent overflow following this order,
2878
- // by default, then, it could overflow on the left and on top of the boundariesElement
2879
- preventOverflowOrder: ['left', 'right', 'top', 'bottom'],
2880
-
2881
- // the behavior used by flip to change the placement of the popper
2882
- flipBehavior: 'flip',
2883
-
2884
- arrowElement: '[x-arrow]',
2885
-
2886
- arrowOffset: 0,
2887
-
2888
- // list of functions used to modify the offsets before they are applied to the popper
2889
- modifiers: ['shift', 'offset', 'preventOverflow', 'keepTogether', 'arrow', 'flip', 'applyStyle'],
2890
-
2891
- modifiersIgnored: [],
2892
-
2893
- forceAbsolute: false
2894
- };
2895
-
2853
+ __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
2854
+ } else {}
2855
+ })(this, function () {
2856
+ 'use strict';
2857
+
2858
+ var root = window;
2859
+ // default options
2860
+ var DEFAULTS = {
2861
+ // placement of the popper
2862
+ placement: 'bottom',
2863
+
2864
+ gpuAcceleration: true,
2865
+
2866
+ // shift popper from its origin by the given amount of pixels (can be negative)
2867
+ offset: 0,
2868
+
2869
+ // the element which will act as boundary of the popper
2870
+ boundariesElement: 'viewport',
2871
+
2872
+ // amount of pixel used to define a minimum distance between the boundaries and the popper
2873
+ boundariesPadding: 5,
2874
+
2875
+ // popper will try to prevent overflow following this order,
2876
+ // by default, then, it could overflow on the left and on top of the boundariesElement
2877
+ preventOverflowOrder: ['left', 'right', 'top', 'bottom'],
2878
+
2879
+ // the behavior used by flip to change the placement of the popper
2880
+ flipBehavior: 'flip',
2881
+
2882
+ arrowElement: '[x-arrow]',
2883
+
2884
+ arrowOffset: 0,
2885
+
2886
+ // list of functions used to modify the offsets before they are applied to the popper
2887
+ modifiers: [
2888
+ 'shift',
2889
+ 'offset',
2890
+ 'preventOverflow',
2891
+ 'keepTogether',
2892
+ 'arrow',
2893
+ 'flip',
2894
+ 'applyStyle'
2895
+ ],
2896
+
2897
+ modifiersIgnored: [],
2898
+
2899
+ forceAbsolute: false
2900
+ };
2901
+
2896
2902
  /**
2897
2903
  * Create a new Popper.js instance
2898
2904
  * @constructor Popper
@@ -2957,114 +2963,125 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
2957
2963
  *
2958
2964
  * @param {Boolean} [options.removeOnDestroy=false]
2959
2965
  * Set to true if you want to automatically remove the popper when you call the `destroy` method.
2960
- */
2961
- function Popper(reference, popper, options) {
2962
- this._reference = reference.jquery ? reference[0] : reference;
2963
- this.state = {};
2964
-
2965
- // if the popper variable is a configuration object, parse it to generate an HTMLElement
2966
- // generate a default popper if is not defined
2967
- var isNotDefined = typeof popper === 'undefined' || popper === null;
2968
- var isConfig = popper && Object.prototype.toString.call(popper) === '[object Object]';
2969
- if (isNotDefined || isConfig) {
2970
- this._popper = this.parse(isConfig ? popper : {});
2971
- }
2972
- // otherwise, use the given HTMLElement as popper
2973
- else {
2974
- this._popper = popper.jquery ? popper[0] : popper;
2975
- }
2976
-
2977
- // with {} we create a new object with the options inside it
2978
- this._options = Object.assign({}, DEFAULTS, options);
2979
-
2980
- // refactoring modifiers' list
2981
- this._options.modifiers = this._options.modifiers.map(function (modifier) {
2982
- // remove ignored modifiers
2983
- if (this._options.modifiersIgnored.indexOf(modifier) !== -1) return;
2984
-
2985
- // set the x-placement attribute before everything else because it could be used to add margins to the popper
2986
- // margins needs to be calculated to get the correct popper offsets
2987
- if (modifier === 'applyStyle') {
2988
- this._popper.setAttribute('x-placement', this._options.placement);
2989
- }
2990
-
2991
- // return predefined modifier identified by string or keep the custom one
2992
- return this.modifiers[modifier] || modifier;
2993
- }.bind(this));
2994
-
2995
- // make sure to apply the popper position before any computation
2996
- this.state.position = this._getPosition(this._popper, this._reference);
2997
- setStyle(this._popper, { position: this.state.position, top: 0 });
2998
-
2999
- // fire the first update to position the popper in the right place
3000
- this.update();
3001
-
3002
- // setup event listeners, they will take care of update the position in specific situations
3003
- this._setupEventListeners();
3004
- return this;
3005
- }
3006
-
3007
- //
3008
- // Methods
3009
- //
2966
+ */
2967
+ function Popper(reference, popper, options) {
2968
+ this._reference = reference.jquery ? reference[0] : reference;
2969
+ this.state = {};
2970
+
2971
+ // if the popper variable is a configuration object, parse it to generate an HTMLElement
2972
+ // generate a default popper if is not defined
2973
+ var isNotDefined = typeof popper === 'undefined' || popper === null;
2974
+ var isConfig =
2975
+ popper && Object.prototype.toString.call(popper) === '[object Object]';
2976
+ if (isNotDefined || isConfig) {
2977
+ this._popper = this.parse(isConfig ? popper : {});
2978
+ }
2979
+ // otherwise, use the given HTMLElement as popper
2980
+ else {
2981
+ this._popper = popper.jquery ? popper[0] : popper;
2982
+ }
2983
+
2984
+ // with {} we create a new object with the options inside it
2985
+ this._options = Object.assign({}, DEFAULTS, options);
2986
+
2987
+ // refactoring modifiers' list
2988
+ this._options.modifiers = this._options.modifiers.map(
2989
+ function (modifier) {
2990
+ // remove ignored modifiers
2991
+ if (this._options.modifiersIgnored.indexOf(modifier) !== -1) return;
2992
+
2993
+ // set the x-placement attribute before everything else because it could be used to add margins to the popper
2994
+ // margins needs to be calculated to get the correct popper offsets
2995
+ if (modifier === 'applyStyle') {
2996
+ this._popper.setAttribute('x-placement', this._options.placement);
2997
+ }
2998
+
2999
+ // return predefined modifier identified by string or keep the custom one
3000
+ return this.modifiers[modifier] || modifier;
3001
+ }.bind(this)
3002
+ );
3003
+
3004
+ // make sure to apply the popper position before any computation
3005
+ this.state.position = this._getPosition(this._popper, this._reference);
3006
+ setStyle(this._popper, { position: this.state.position, top: 0 });
3007
+
3008
+ // fire the first update to position the popper in the right place
3009
+ this.update();
3010
+
3011
+ // setup event listeners, they will take care of update the position in specific situations
3012
+ this._setupEventListeners();
3013
+ return this;
3014
+ }
3015
+
3016
+ //
3017
+ // Methods
3018
+ //
3010
3019
  /**
3011
3020
  * Destroy the popper
3012
3021
  * @method
3013
3022
  * @memberof Popper
3014
- */
3015
- Popper.prototype.destroy = function () {
3016
- this._popper.removeAttribute('x-placement');
3017
- this._popper.style.left = '';
3018
- this._popper.style.position = '';
3019
- this._popper.style.top = '';
3020
- this._popper.style[getSupportedPropertyName('transform')] = '';
3021
- this._removeEventListeners();
3022
-
3023
- // remove the popper if user explicity asked for the deletion on destroy
3024
- if (this._options.removeOnDestroy) {
3025
- this._popper.remove();
3026
- }
3027
- return this;
3028
- };
3029
-
3023
+ */
3024
+ Popper.prototype.destroy = function () {
3025
+ this._popper.removeAttribute('x-placement');
3026
+ this._popper.style.left = '';
3027
+ this._popper.style.position = '';
3028
+ this._popper.style.top = '';
3029
+ this._popper.style[getSupportedPropertyName('transform')] = '';
3030
+ this._removeEventListeners();
3031
+
3032
+ // remove the popper if user explicity asked for the deletion on destroy
3033
+ if (this._options.removeOnDestroy) {
3034
+ this._popper.remove();
3035
+ }
3036
+ return this;
3037
+ };
3038
+
3030
3039
  /**
3031
3040
  * Updates the position of the popper, computing the new offsets and applying the new style
3032
3041
  * @method
3033
3042
  * @memberof Popper
3034
- */
3035
- Popper.prototype.update = function () {
3036
- var data = { instance: this, styles: {} };
3037
-
3038
- // store placement inside the data object, modifiers will be able to edit `placement` if needed
3039
- // and refer to _originalPlacement to know the original value
3040
- data.placement = this._options.placement;
3041
- data._originalPlacement = this._options.placement;
3042
-
3043
- // compute the popper and reference offsets and put them inside data.offsets
3044
- data.offsets = this._getOffsets(this._popper, this._reference, data.placement);
3045
-
3046
- // get boundaries
3047
- data.boundaries = this._getBoundaries(data, this._options.boundariesPadding, this._options.boundariesElement);
3048
-
3049
- data = this.runModifiers(data, this._options.modifiers);
3050
-
3051
- if (typeof this.state.updateCallback === 'function') {
3052
- this.state.updateCallback(data);
3053
- }
3054
- };
3055
-
3043
+ */
3044
+ Popper.prototype.update = function () {
3045
+ var data = { instance: this, styles: {} };
3046
+
3047
+ // store placement inside the data object, modifiers will be able to edit `placement` if needed
3048
+ // and refer to _originalPlacement to know the original value
3049
+ data.placement = this._options.placement;
3050
+ data._originalPlacement = this._options.placement;
3051
+
3052
+ // compute the popper and reference offsets and put them inside data.offsets
3053
+ data.offsets = this._getOffsets(
3054
+ this._popper,
3055
+ this._reference,
3056
+ data.placement
3057
+ );
3058
+
3059
+ // get boundaries
3060
+ data.boundaries = this._getBoundaries(
3061
+ data,
3062
+ this._options.boundariesPadding,
3063
+ this._options.boundariesElement
3064
+ );
3065
+
3066
+ data = this.runModifiers(data, this._options.modifiers);
3067
+
3068
+ if (typeof this.state.updateCallback === 'function') {
3069
+ this.state.updateCallback(data);
3070
+ }
3071
+ };
3072
+
3056
3073
  /**
3057
3074
  * If a function is passed, it will be executed after the initialization of popper with as first argument the Popper instance.
3058
3075
  * @method
3059
3076
  * @memberof Popper
3060
3077
  * @param {Function} callback
3061
- */
3062
- Popper.prototype.onCreate = function (callback) {
3063
- // the createCallbacks return as first argument the popper instance
3064
- callback(this);
3065
- return this;
3066
- };
3067
-
3078
+ */
3079
+ Popper.prototype.onCreate = function (callback) {
3080
+ // the createCallbacks return as first argument the popper instance
3081
+ callback(this);
3082
+ return this;
3083
+ };
3084
+
3068
3085
  /**
3069
3086
  * If a function is passed, it will be executed after each update of popper with as first argument the set of coordinates and informations
3070
3087
  * used to style popper and its arrow.
@@ -3072,93 +3089,101 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
3072
3089
  * @method
3073
3090
  * @memberof Popper
3074
3091
  * @param {Function} callback
3075
- */
3076
- Popper.prototype.onUpdate = function (callback) {
3077
- this.state.updateCallback = callback;
3078
- return this;
3079
- };
3080
-
3092
+ */
3093
+ Popper.prototype.onUpdate = function (callback) {
3094
+ this.state.updateCallback = callback;
3095
+ return this;
3096
+ };
3097
+
3081
3098
  /**
3082
3099
  * Helper used to generate poppers from a configuration file
3083
3100
  * @method
3084
3101
  * @memberof Popper
3085
3102
  * @param config {Object} configuration
3086
3103
  * @returns {HTMLElement} popper
3087
- */
3088
- Popper.prototype.parse = function (config) {
3089
- var defaultConfig = {
3090
- tagName: 'div',
3091
- classNames: ['popper'],
3092
- attributes: [],
3093
- parent: root.document.body,
3094
- content: '',
3095
- contentType: 'text',
3096
- arrowTagName: 'div',
3097
- arrowClassNames: ['popper__arrow'],
3098
- arrowAttributes: ['x-arrow']
3099
- };
3100
- config = Object.assign({}, defaultConfig, config);
3101
-
3102
- var d = root.document;
3103
-
3104
- var popper = d.createElement(config.tagName);
3105
- addClassNames(popper, config.classNames);
3106
- addAttributes(popper, config.attributes);
3107
- if (config.contentType === 'node') {
3108
- popper.appendChild(config.content.jquery ? config.content[0] : config.content);
3109
- } else if (config.contentType === 'html') {
3110
- popper.innerHTML = config.content;
3111
- } else {
3112
- popper.textContent = config.content;
3113
- }
3114
-
3115
- if (config.arrowTagName) {
3116
- var arrow = d.createElement(config.arrowTagName);
3117
- addClassNames(arrow, config.arrowClassNames);
3118
- addAttributes(arrow, config.arrowAttributes);
3119
- popper.appendChild(arrow);
3120
- }
3121
-
3122
- var parent = config.parent.jquery ? config.parent[0] : config.parent;
3123
-
3124
- // if the given parent is a string, use it to match an element
3125
- // if more than one element is matched, the first one will be used as parent
3126
- // if no elements are matched, the script will throw an error
3127
- if (typeof parent === 'string') {
3128
- parent = d.querySelectorAll(config.parent);
3129
- if (parent.length > 1) {
3130
- console.warn('WARNING: the given `parent` query(' + config.parent + ') matched more than one element, the first one will be used');
3131
- }
3132
- if (parent.length === 0) {
3133
- throw "ERROR: the given `parent` doesn't exists!";
3134
- }
3135
- parent = parent[0];
3136
- }
3137
- // if the given parent is a DOM nodes list or an array of nodes with more than one element,
3138
- // the first one will be used as parent
3139
- if (parent.length > 1 && parent instanceof Element === false) {
3140
- console.warn('WARNING: you have passed as parent a list of elements, the first one will be used');
3141
- parent = parent[0];
3142
- }
3143
-
3144
- // append the generated popper to its parent
3145
- parent.appendChild(popper);
3146
-
3147
- return popper;
3148
-
3104
+ */
3105
+ Popper.prototype.parse = function (config) {
3106
+ var defaultConfig = {
3107
+ tagName: 'div',
3108
+ classNames: ['popper'],
3109
+ attributes: [],
3110
+ parent: root.document.body,
3111
+ content: '',
3112
+ contentType: 'text',
3113
+ arrowTagName: 'div',
3114
+ arrowClassNames: ['popper__arrow'],
3115
+ arrowAttributes: ['x-arrow']
3116
+ };
3117
+ config = Object.assign({}, defaultConfig, config);
3118
+
3119
+ var d = root.document;
3120
+
3121
+ var popper = d.createElement(config.tagName);
3122
+ addClassNames(popper, config.classNames);
3123
+ addAttributes(popper, config.attributes);
3124
+ if (config.contentType === 'node') {
3125
+ popper.appendChild(
3126
+ config.content.jquery ? config.content[0] : config.content
3127
+ );
3128
+ } else if (config.contentType === 'html') {
3129
+ popper.innerHTML = config.content;
3130
+ } else {
3131
+ popper.textContent = config.content;
3132
+ }
3133
+
3134
+ if (config.arrowTagName) {
3135
+ var arrow = d.createElement(config.arrowTagName);
3136
+ addClassNames(arrow, config.arrowClassNames);
3137
+ addAttributes(arrow, config.arrowAttributes);
3138
+ popper.appendChild(arrow);
3139
+ }
3140
+
3141
+ var parent = config.parent.jquery ? config.parent[0] : config.parent;
3142
+
3143
+ // if the given parent is a string, use it to match an element
3144
+ // if more than one element is matched, the first one will be used as parent
3145
+ // if no elements are matched, the script will throw an error
3146
+ if (typeof parent === 'string') {
3147
+ parent = d.querySelectorAll(config.parent);
3148
+ if (parent.length > 1) {
3149
+ console.warn(
3150
+ 'WARNING: the given `parent` query(' +
3151
+ config.parent +
3152
+ ') matched more than one element, the first one will be used'
3153
+ );
3154
+ }
3155
+ if (parent.length === 0) {
3156
+ throw "ERROR: the given `parent` doesn't exists!";
3157
+ }
3158
+ parent = parent[0];
3159
+ }
3160
+ // if the given parent is a DOM nodes list or an array of nodes with more than one element,
3161
+ // the first one will be used as parent
3162
+ if (parent.length > 1 && parent instanceof Element === false) {
3163
+ console.warn(
3164
+ 'WARNING: you have passed as parent a list of elements, the first one will be used'
3165
+ );
3166
+ parent = parent[0];
3167
+ }
3168
+
3169
+ // append the generated popper to its parent
3170
+ parent.appendChild(popper);
3171
+
3172
+ return popper;
3173
+
3149
3174
  /**
3150
3175
  * Adds class names to the given element
3151
3176
  * @function
3152
3177
  * @ignore
3153
3178
  * @param {HTMLElement} target
3154
3179
  * @param {Array} classes
3155
- */
3156
- function addClassNames(element, classNames) {
3157
- classNames.forEach(function (className) {
3158
- element.classList.add(className);
3159
- });
3160
- }
3161
-
3180
+ */
3181
+ function addClassNames(element, classNames) {
3182
+ classNames.forEach(function (className) {
3183
+ element.classList.add(className);
3184
+ });
3185
+ }
3186
+
3162
3187
  /**
3163
3188
  * Adds attributes to the given element
3164
3189
  * @function
@@ -3167,14 +3192,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
3167
3192
  * @param {Array} attributes
3168
3193
  * @example
3169
3194
  * addAttributes(element, [ 'data-info:foobar' ]);
3170
- */
3171
- function addAttributes(element, attributes) {
3172
- attributes.forEach(function (attribute) {
3173
- element.setAttribute(attribute.split(':')[0], attribute.split(':')[1] || '');
3174
- });
3175
- }
3176
- };
3177
-
3195
+ */
3196
+ function addAttributes(element, attributes) {
3197
+ attributes.forEach(function (attribute) {
3198
+ element.setAttribute(
3199
+ attribute.split(':')[0],
3200
+ attribute.split(':')[1] || ''
3201
+ );
3202
+ });
3203
+ }
3204
+ };
3205
+
3178
3206
  /**
3179
3207
  * Helper used to get the position which will be applied to the popper
3180
3208
  * @method
@@ -3182,20 +3210,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
3182
3210
  * @param config {HTMLElement} popper element
3183
3211
  * @param reference {HTMLElement} reference element
3184
3212
  * @returns {String} position
3185
- */
3186
- Popper.prototype._getPosition = function (popper, reference) {
3187
- var container = getOffsetParent(reference);
3188
-
3189
- if (this._options.forceAbsolute) {
3190
- return 'absolute';
3191
- }
3192
-
3193
- // Decide if the popper will be fixed
3194
- // If the reference element is inside a fixed context, the popper will be fixed as well to allow them to scroll together
3195
- var isParentFixed = isFixed(reference, container);
3196
- return isParentFixed ? 'fixed' : 'absolute';
3197
- };
3198
-
3213
+ */
3214
+ Popper.prototype._getPosition = function (popper, reference) {
3215
+ var container = getOffsetParent(reference);
3216
+
3217
+ if (this._options.forceAbsolute) {
3218
+ return 'absolute';
3219
+ }
3220
+
3221
+ // Decide if the popper will be fixed
3222
+ // If the reference element is inside a fixed context, the popper will be fixed as well to allow them to scroll together
3223
+ var isParentFixed = isFixed(reference, container);
3224
+ return isParentFixed ? 'fixed' : 'absolute';
3225
+ };
3226
+
3199
3227
  /**
3200
3228
  * Get offsets to the popper
3201
3229
  * @method
@@ -3204,93 +3232,110 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
3204
3232
  * @param {Element} popper - the popper element
3205
3233
  * @param {Element} reference - the reference element (the popper will be relative to this)
3206
3234
  * @returns {Object} An object containing the offsets which will be applied to the popper
3207
- */
3208
- Popper.prototype._getOffsets = function (popper, reference, placement) {
3209
- placement = placement.split('-')[0];
3210
- var popperOffsets = {};
3211
-
3212
- popperOffsets.position = this.state.position;
3213
- var isParentFixed = popperOffsets.position === 'fixed';
3214
-
3215
- //
3216
- // Get reference element position
3217
- //
3218
- var referenceOffsets = getOffsetRectRelativeToCustomParent(reference, getOffsetParent(popper), isParentFixed);
3219
-
3220
- //
3221
- // Get popper sizes
3222
- //
3223
- var popperRect = getOuterSizes(popper);
3224
-
3225
- //
3226
- // Compute offsets of popper
3227
- //
3228
-
3229
- // depending by the popper placement we have to compute its offsets slightly differently
3230
- if (['right', 'left'].indexOf(placement) !== -1) {
3231
- popperOffsets.top = referenceOffsets.top + referenceOffsets.height / 2 - popperRect.height / 2;
3232
- if (placement === 'left') {
3233
- popperOffsets.left = referenceOffsets.left - popperRect.width;
3234
- } else {
3235
- popperOffsets.left = referenceOffsets.right;
3236
- }
3237
- } else {
3238
- popperOffsets.left = referenceOffsets.left + referenceOffsets.width / 2 - popperRect.width / 2;
3239
- if (placement === 'top') {
3240
- popperOffsets.top = referenceOffsets.top - popperRect.height;
3241
- } else {
3242
- popperOffsets.top = referenceOffsets.bottom;
3243
- }
3244
- }
3245
-
3246
- // Add width and height to our offsets object
3247
- popperOffsets.width = popperRect.width;
3248
- popperOffsets.height = popperRect.height;
3249
-
3250
- return {
3251
- popper: popperOffsets,
3252
- reference: referenceOffsets
3253
- };
3254
- };
3255
-
3235
+ */
3236
+ Popper.prototype._getOffsets = function (popper, reference, placement) {
3237
+ placement = placement.split('-')[0];
3238
+ var popperOffsets = {};
3239
+
3240
+ popperOffsets.position = this.state.position;
3241
+ var isParentFixed = popperOffsets.position === 'fixed';
3242
+
3243
+ //
3244
+ // Get reference element position
3245
+ //
3246
+ var referenceOffsets = getOffsetRectRelativeToCustomParent(
3247
+ reference,
3248
+ popper,
3249
+ isParentFixed
3250
+ );
3251
+
3252
+ //
3253
+ // Get popper sizes
3254
+ //
3255
+ var popperRect = getOuterSizes(popper);
3256
+
3257
+ //
3258
+ // Compute offsets of popper
3259
+ //
3260
+
3261
+ // depending by the popper placement we have to compute its offsets slightly differently
3262
+ if (['right', 'left'].indexOf(placement) !== -1) {
3263
+ popperOffsets.top =
3264
+ referenceOffsets.top +
3265
+ referenceOffsets.height / 2 -
3266
+ popperRect.height / 2;
3267
+ if (placement === 'left') {
3268
+ popperOffsets.left = referenceOffsets.left - popperRect.width;
3269
+ } else {
3270
+ popperOffsets.left = referenceOffsets.right;
3271
+ }
3272
+ } else {
3273
+ popperOffsets.left =
3274
+ referenceOffsets.left +
3275
+ referenceOffsets.width / 2 -
3276
+ popperRect.width / 2;
3277
+ if (placement === 'top') {
3278
+ popperOffsets.top = referenceOffsets.top - popperRect.height;
3279
+ } else {
3280
+ popperOffsets.top = referenceOffsets.bottom;
3281
+ }
3282
+ }
3283
+
3284
+ // Add width and height to our offsets object
3285
+ popperOffsets.width = popperRect.width;
3286
+ popperOffsets.height = popperRect.height;
3287
+
3288
+ return {
3289
+ popper: popperOffsets,
3290
+ reference: referenceOffsets
3291
+ };
3292
+ };
3293
+
3256
3294
  /**
3257
3295
  * Setup needed event listeners used to update the popper position
3258
3296
  * @method
3259
3297
  * @memberof Popper
3260
3298
  * @access private
3261
- */
3262
- Popper.prototype._setupEventListeners = function () {
3263
- // NOTE: 1 DOM access here
3264
- this.state.updateBound = this.update.bind(this);
3265
- root.addEventListener('resize', this.state.updateBound);
3266
- // if the boundariesElement is window we don't need to listen for the scroll event
3267
- if (this._options.boundariesElement !== 'window') {
3268
- var target = getScrollParent(this._reference);
3269
- // here it could be both `body` or `documentElement` thanks to Firefox, we then check both
3270
- if (target === root.document.body || target === root.document.documentElement) {
3271
- target = root;
3272
- }
3273
- target.addEventListener('scroll', this.state.updateBound);
3274
- this.state.scrollTarget = target;
3275
- }
3276
- };
3277
-
3299
+ */
3300
+ Popper.prototype._setupEventListeners = function () {
3301
+ // NOTE: 1 DOM access here
3302
+ this.state.updateBound = this.update.bind(this);
3303
+ // 无界等微前端场景下沙箱 window 不会触发 resize,需监听真实 window
3304
+ this.state.realWindow = getRealWindow(this._popper);
3305
+ this.state.realWindow.addEventListener('resize', this.state.updateBound);
3306
+ // if the boundariesElement is window we don't need to listen for the scroll event
3307
+ if (this._options.boundariesElement !== 'window') {
3308
+ var target = getScrollParent(this._reference);
3309
+ target.addEventListener('scroll', this.state.updateBound);
3310
+ this.state.scrollTarget = target;
3311
+ }
3312
+ };
3313
+
3278
3314
  /**
3279
3315
  * Remove event listeners used to update the popper position
3280
3316
  * @method
3281
3317
  * @memberof Popper
3282
3318
  * @access private
3283
- */
3284
- Popper.prototype._removeEventListeners = function () {
3285
- // NOTE: 1 DOM access here
3286
- root.removeEventListener('resize', this.state.updateBound);
3287
- if (this._options.boundariesElement !== 'window' && this.state.scrollTarget) {
3288
- this.state.scrollTarget.removeEventListener('scroll', this.state.updateBound);
3289
- this.state.scrollTarget = null;
3290
- }
3291
- this.state.updateBound = null;
3292
- };
3293
-
3319
+ */
3320
+ Popper.prototype._removeEventListeners = function () {
3321
+ // NOTE: 1 DOM access here
3322
+ (this.state.realWindow || root).removeEventListener(
3323
+ 'resize',
3324
+ this.state.updateBound
3325
+ );
3326
+ if (
3327
+ this._options.boundariesElement !== 'window' &&
3328
+ this.state.scrollTarget
3329
+ ) {
3330
+ this.state.scrollTarget.removeEventListener(
3331
+ 'scroll',
3332
+ this.state.updateBound
3333
+ );
3334
+ this.state.scrollTarget = null;
3335
+ }
3336
+ this.state.updateBound = null;
3337
+ };
3338
+
3294
3339
  /**
3295
3340
  * Computed the boundaries limits and return them
3296
3341
  * @method
@@ -3300,66 +3345,75 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
3300
3345
  * @param {Number} padding - Boundaries padding
3301
3346
  * @param {Element} boundariesElement - Element used to define the boundaries
3302
3347
  * @returns {Object} Coordinates of the boundaries
3303
- */
3304
- Popper.prototype._getBoundaries = function (data, padding, boundariesElement) {
3305
- // NOTE: 1 DOM access here
3306
- var boundaries = {};
3307
- var width, height;
3308
- if (boundariesElement === 'window') {
3309
- var body = root.document.body,
3310
- html = root.document.documentElement;
3311
-
3312
- height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
3313
- width = Math.max(body.scrollWidth, body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth);
3314
-
3315
- boundaries = {
3316
- top: 0,
3317
- right: width,
3318
- bottom: height,
3319
- left: 0
3320
- };
3321
- } else if (boundariesElement === 'viewport') {
3322
- var offsetParent = getOffsetParent(this._popper);
3323
- var scrollParent = getScrollParent(this._popper);
3324
- var offsetParentRect = getOffsetRect(offsetParent);
3325
-
3326
- // Thanks the fucking native API, `document.body.scrollTop` & `document.documentElement.scrollTop`
3327
- var getScrollTopValue = function getScrollTopValue(element) {
3328
- return element == document.body ? Math.max(document.documentElement.scrollTop, document.body.scrollTop) : element.scrollTop;
3329
- };
3330
- var getScrollLeftValue = function getScrollLeftValue(element) {
3331
- return element == document.body ? Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) : element.scrollLeft;
3332
- };
3333
-
3334
- // if the popper is fixed we don't have to substract scrolling from the boundaries
3335
- var scrollTop = data.offsets.popper.position === 'fixed' ? 0 : getScrollTopValue(scrollParent);
3336
- var scrollLeft = data.offsets.popper.position === 'fixed' ? 0 : getScrollLeftValue(scrollParent);
3337
-
3338
- boundaries = {
3339
- top: 0 - (offsetParentRect.top - scrollTop),
3340
- right: root.document.documentElement.clientWidth - (offsetParentRect.left - scrollLeft),
3341
- bottom: root.document.documentElement.clientHeight - (offsetParentRect.top - scrollTop),
3342
- left: 0 - (offsetParentRect.left - scrollLeft)
3343
- };
3344
- } else {
3345
- if (getOffsetParent(this._popper) === boundariesElement) {
3346
- boundaries = {
3347
- top: 0,
3348
- left: 0,
3349
- right: boundariesElement.clientWidth,
3350
- bottom: boundariesElement.clientHeight
3351
- };
3352
- } else {
3353
- boundaries = getOffsetRect(boundariesElement);
3354
- }
3355
- }
3356
- boundaries.left += padding;
3357
- boundaries.right -= padding;
3358
- boundaries.top = boundaries.top + padding;
3359
- boundaries.bottom = boundaries.bottom - padding;
3360
- return boundaries;
3361
- };
3362
-
3348
+ */
3349
+ Popper.prototype._getBoundaries = function (data, padding, boundariesElement) {
3350
+ // NOTE: 1 DOM access here
3351
+ var boundaries = {};
3352
+ var width, height;
3353
+ if (boundariesElement === 'window') {
3354
+ var body = root.document.body,
3355
+ html = root.document.documentElement;
3356
+
3357
+ height = Math.max(
3358
+ body.scrollHeight,
3359
+ body.offsetHeight,
3360
+ html.clientHeight,
3361
+ html.scrollHeight,
3362
+ html.offsetHeight
3363
+ );
3364
+ width = Math.max(
3365
+ body.scrollWidth,
3366
+ body.offsetWidth,
3367
+ html.clientWidth,
3368
+ html.scrollWidth,
3369
+ html.offsetWidth
3370
+ );
3371
+
3372
+ boundaries = {
3373
+ top: 0,
3374
+ right: width,
3375
+ bottom: height,
3376
+ left: 0
3377
+ };
3378
+ } else if (boundariesElement === 'viewport') {
3379
+ // 将真实 window 的视口换算到 popper 所在包含块的坐标系。
3380
+ // 无界等场景下沙箱 window 的尺寸、shadowRoot 内元素的 scrollTop 均不可靠,
3381
+ // 统一从元素自身的 view 与真实包含块获取
3382
+ var realWindow = getRealWindow(this._popper);
3383
+ var containingBlockRect = getContainingBlockRect(
3384
+ this._popper,
3385
+ data.offsets.popper.position === 'fixed'
3386
+ );
3387
+
3388
+ boundaries = {
3389
+ top: 0 - containingBlockRect.top,
3390
+ right:
3391
+ realWindow.document.documentElement.clientWidth -
3392
+ containingBlockRect.left,
3393
+ bottom:
3394
+ realWindow.document.documentElement.clientHeight -
3395
+ containingBlockRect.top,
3396
+ left: 0 - containingBlockRect.left
3397
+ };
3398
+ } else {
3399
+ if (getOffsetParent(this._popper) === boundariesElement) {
3400
+ boundaries = {
3401
+ top: 0,
3402
+ left: 0,
3403
+ right: boundariesElement.clientWidth,
3404
+ bottom: boundariesElement.clientHeight
3405
+ };
3406
+ } else {
3407
+ boundaries = getOffsetRect(boundariesElement);
3408
+ }
3409
+ }
3410
+ boundaries.left += padding;
3411
+ boundaries.right -= padding;
3412
+ boundaries.top = boundaries.top + padding;
3413
+ boundaries.bottom = boundaries.bottom - padding;
3414
+ return boundaries;
3415
+ };
3416
+
3363
3417
  /**
3364
3418
  * Loop trough the list of modifiers and run them in order, each of them will then edit the data object
3365
3419
  * @method
@@ -3368,22 +3422,27 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
3368
3422
  * @param {Object} data
3369
3423
  * @param {Array} modifiers
3370
3424
  * @param {Function} ends
3371
- */
3372
- Popper.prototype.runModifiers = function (data, modifiers, ends) {
3373
- var modifiersToRun = modifiers.slice();
3374
- if (ends !== undefined) {
3375
- modifiersToRun = this._options.modifiers.slice(0, getArrayKeyIndex(this._options.modifiers, ends));
3376
- }
3377
-
3378
- modifiersToRun.forEach(function (modifier) {
3379
- if (isFunction(modifier)) {
3380
- data = modifier.call(this, data);
3381
- }
3382
- }.bind(this));
3383
-
3384
- return data;
3385
- };
3386
-
3425
+ */
3426
+ Popper.prototype.runModifiers = function (data, modifiers, ends) {
3427
+ var modifiersToRun = modifiers.slice();
3428
+ if (ends !== undefined) {
3429
+ modifiersToRun = this._options.modifiers.slice(
3430
+ 0,
3431
+ getArrayKeyIndex(this._options.modifiers, ends)
3432
+ );
3433
+ }
3434
+
3435
+ modifiersToRun.forEach(
3436
+ function (modifier) {
3437
+ if (isFunction(modifier)) {
3438
+ data = modifier.call(this, data);
3439
+ }
3440
+ }.bind(this)
3441
+ );
3442
+
3443
+ return data;
3444
+ };
3445
+
3387
3446
  /**
3388
3447
  * Helper used to know if the given modifier depends from another one.
3389
3448
  * @method
@@ -3391,191 +3450,204 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
3391
3450
  * @param {String} requesting - name of requesting modifier
3392
3451
  * @param {String} requested - name of requested modifier
3393
3452
  * @returns {Boolean}
3394
- */
3395
- Popper.prototype.isModifierRequired = function (requesting, requested) {
3396
- var index = getArrayKeyIndex(this._options.modifiers, requesting);
3397
- return !!this._options.modifiers.slice(0, index).filter(function (modifier) {
3398
- return modifier === requested;
3399
- }).length;
3400
- };
3401
-
3402
- //
3403
- // Modifiers
3404
- //
3405
-
3453
+ */
3454
+ Popper.prototype.isModifierRequired = function (requesting, requested) {
3455
+ var index = getArrayKeyIndex(this._options.modifiers, requesting);
3456
+ return !!this._options.modifiers.slice(0, index).filter(function (modifier) {
3457
+ return modifier === requested;
3458
+ }).length;
3459
+ };
3460
+
3461
+ //
3462
+ // Modifiers
3463
+ //
3464
+
3406
3465
  /**
3407
3466
  * Modifiers list
3408
3467
  * @namespace Popper.modifiers
3409
3468
  * @memberof Popper
3410
3469
  * @type {Object}
3411
- */
3412
- Popper.prototype.modifiers = {};
3413
-
3470
+ */
3471
+ Popper.prototype.modifiers = {};
3472
+
3414
3473
  /**
3415
3474
  * Apply the computed styles to the popper element
3416
3475
  * @method
3417
3476
  * @memberof Popper.modifiers
3418
3477
  * @argument {Object} data - The data object generated by `update` method
3419
3478
  * @returns {Object} The same data object
3420
- */
3421
- Popper.prototype.modifiers.applyStyle = function (data) {
3422
- // apply the final offsets to the popper
3423
- // NOTE: 1 DOM access here
3424
- var styles = {
3425
- position: data.offsets.popper.position
3426
- };
3427
-
3428
- // round top and left to avoid blurry text
3429
- var left = Math.round(data.offsets.popper.left);
3430
- var top = Math.round(data.offsets.popper.top);
3431
-
3432
- // if gpuAcceleration is set to true and transform is supported, we use `translate3d` to apply the position to the popper
3433
- // we automatically use the supported prefixed version if needed
3434
- var prefixedProperty;
3435
- if (this._options.gpuAcceleration && (prefixedProperty = getSupportedPropertyName('transform'))) {
3436
- styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
3437
- styles.top = 0;
3438
- styles.left = 0;
3439
- }
3440
- // othwerise, we use the standard `left` and `top` properties
3441
- else {
3442
- styles.left = left;
3443
- styles.top = top;
3444
- }
3445
-
3446
- // any property present in `data.styles` will be applied to the popper,
3447
- // in this way we can make the 3rd party modifiers add custom styles to it
3448
- // Be aware, modifiers could override the properties defined in the previous
3449
- // lines of this modifier!
3450
- Object.assign(styles, data.styles);
3451
-
3452
- setStyle(this._popper, styles);
3453
-
3454
- // set an attribute which will be useful to style the tooltip (use it to properly position its arrow)
3455
- // NOTE: 1 DOM access here
3456
- this._popper.setAttribute('x-placement', data.placement);
3457
-
3458
- // if the arrow modifier is required and the arrow style has been computed, apply the arrow style
3459
- if (this.isModifierRequired(this.modifiers.applyStyle, this.modifiers.arrow) && data.offsets.arrow) {
3460
- setStyle(data.arrowElement, data.offsets.arrow);
3461
- }
3462
-
3463
- return data;
3464
- };
3465
-
3479
+ */
3480
+ Popper.prototype.modifiers.applyStyle = function (data) {
3481
+ // apply the final offsets to the popper
3482
+ // NOTE: 1 DOM access here
3483
+ var styles = {
3484
+ position: data.offsets.popper.position
3485
+ };
3486
+
3487
+ // round top and left to avoid blurry text
3488
+ var left = Math.round(data.offsets.popper.left);
3489
+ var top = Math.round(data.offsets.popper.top);
3490
+
3491
+ // if gpuAcceleration is set to true and transform is supported, we use `translate3d` to apply the position to the popper
3492
+ // we automatically use the supported prefixed version if needed
3493
+ var prefixedProperty;
3494
+ if (
3495
+ this._options.gpuAcceleration &&
3496
+ (prefixedProperty = getSupportedPropertyName('transform'))
3497
+ ) {
3498
+ styles[prefixedProperty] =
3499
+ 'translate3d(' + left + 'px, ' + top + 'px, 0)';
3500
+ styles.top = 0;
3501
+ styles.left = 0;
3502
+ }
3503
+ // othwerise, we use the standard `left` and `top` properties
3504
+ else {
3505
+ styles.left = left;
3506
+ styles.top = top;
3507
+ }
3508
+
3509
+ // any property present in `data.styles` will be applied to the popper,
3510
+ // in this way we can make the 3rd party modifiers add custom styles to it
3511
+ // Be aware, modifiers could override the properties defined in the previous
3512
+ // lines of this modifier!
3513
+ Object.assign(styles, data.styles);
3514
+
3515
+ setStyle(this._popper, styles);
3516
+
3517
+ // set an attribute which will be useful to style the tooltip (use it to properly position its arrow)
3518
+ // NOTE: 1 DOM access here
3519
+ this._popper.setAttribute('x-placement', data.placement);
3520
+
3521
+ // if the arrow modifier is required and the arrow style has been computed, apply the arrow style
3522
+ if (
3523
+ this.isModifierRequired(
3524
+ this.modifiers.applyStyle,
3525
+ this.modifiers.arrow
3526
+ ) &&
3527
+ data.offsets.arrow
3528
+ ) {
3529
+ setStyle(data.arrowElement, data.offsets.arrow);
3530
+ }
3531
+
3532
+ return data;
3533
+ };
3534
+
3466
3535
  /**
3467
3536
  * Modifier used to shift the popper on the start or end of its reference element side
3468
3537
  * @method
3469
3538
  * @memberof Popper.modifiers
3470
3539
  * @argument {Object} data - The data object generated by `update` method
3471
3540
  * @returns {Object} The data object, properly modified
3472
- */
3473
- Popper.prototype.modifiers.shift = function (data) {
3474
- var placement = data.placement;
3475
- var basePlacement = placement.split('-')[0];
3476
- var shiftVariation = placement.split('-')[1];
3477
-
3478
- // if shift shiftVariation is specified, run the modifier
3479
- if (shiftVariation) {
3480
- var reference = data.offsets.reference;
3481
- var popper = getPopperClientRect(data.offsets.popper);
3482
-
3483
- var shiftOffsets = {
3484
- y: {
3485
- start: { top: reference.top },
3486
- end: { top: reference.top + reference.height - popper.height }
3487
- },
3488
- x: {
3489
- start: { left: reference.left },
3490
- end: { left: reference.left + reference.width - popper.width }
3491
- }
3492
- };
3493
-
3494
- var axis = ['bottom', 'top'].indexOf(basePlacement) !== -1 ? 'x' : 'y';
3495
-
3496
- data.offsets.popper = Object.assign(popper, shiftOffsets[axis][shiftVariation]);
3497
- }
3498
-
3499
- return data;
3500
- };
3501
-
3541
+ */
3542
+ Popper.prototype.modifiers.shift = function (data) {
3543
+ var placement = data.placement;
3544
+ var basePlacement = placement.split('-')[0];
3545
+ var shiftVariation = placement.split('-')[1];
3546
+
3547
+ // if shift shiftVariation is specified, run the modifier
3548
+ if (shiftVariation) {
3549
+ var reference = data.offsets.reference;
3550
+ var popper = getPopperClientRect(data.offsets.popper);
3551
+
3552
+ var shiftOffsets = {
3553
+ y: {
3554
+ start: { top: reference.top },
3555
+ end: { top: reference.top + reference.height - popper.height }
3556
+ },
3557
+ x: {
3558
+ start: { left: reference.left },
3559
+ end: { left: reference.left + reference.width - popper.width }
3560
+ }
3561
+ };
3562
+
3563
+ var axis = ['bottom', 'top'].indexOf(basePlacement) !== -1 ? 'x' : 'y';
3564
+
3565
+ data.offsets.popper = Object.assign(
3566
+ popper,
3567
+ shiftOffsets[axis][shiftVariation]
3568
+ );
3569
+ }
3570
+
3571
+ return data;
3572
+ };
3573
+
3502
3574
  /**
3503
3575
  * Modifier used to make sure the popper does not overflows from it's boundaries
3504
3576
  * @method
3505
3577
  * @memberof Popper.modifiers
3506
3578
  * @argument {Object} data - The data object generated by `update` method
3507
3579
  * @returns {Object} The data object, properly modified
3508
- */
3509
- Popper.prototype.modifiers.preventOverflow = function (data) {
3510
- var order = this._options.preventOverflowOrder;
3511
- var popper = getPopperClientRect(data.offsets.popper);
3512
-
3513
- var check = {
3514
- left: function left() {
3515
- var left = popper.left;
3516
- if (popper.left < data.boundaries.left) {
3517
- left = Math.max(popper.left, data.boundaries.left);
3518
- }
3519
- return { left: left };
3520
- },
3521
- right: function right() {
3522
- var left = popper.left;
3523
- if (popper.right > data.boundaries.right) {
3524
- left = Math.min(popper.left, data.boundaries.right - popper.width);
3525
- }
3526
- return { left: left };
3527
- },
3528
- top: function top() {
3529
- var top = popper.top;
3530
- if (popper.top < data.boundaries.top) {
3531
- top = Math.max(popper.top, data.boundaries.top);
3532
- }
3533
- return { top: top };
3534
- },
3535
- bottom: function bottom() {
3536
- var top = popper.top;
3537
- if (popper.bottom > data.boundaries.bottom) {
3538
- top = Math.min(popper.top, data.boundaries.bottom - popper.height);
3539
- }
3540
- return { top: top };
3541
- }
3542
- };
3543
-
3544
- order.forEach(function (direction) {
3545
- data.offsets.popper = Object.assign(popper, check[direction]());
3546
- });
3547
-
3548
- return data;
3549
- };
3550
-
3580
+ */
3581
+ Popper.prototype.modifiers.preventOverflow = function (data) {
3582
+ var order = this._options.preventOverflowOrder;
3583
+ var popper = getPopperClientRect(data.offsets.popper);
3584
+
3585
+ var check = {
3586
+ left: function () {
3587
+ var left = popper.left;
3588
+ if (popper.left < data.boundaries.left) {
3589
+ left = Math.max(popper.left, data.boundaries.left);
3590
+ }
3591
+ return { left: left };
3592
+ },
3593
+ right: function () {
3594
+ var left = popper.left;
3595
+ if (popper.right > data.boundaries.right) {
3596
+ left = Math.min(popper.left, data.boundaries.right - popper.width);
3597
+ }
3598
+ return { left: left };
3599
+ },
3600
+ top: function () {
3601
+ var top = popper.top;
3602
+ if (popper.top < data.boundaries.top) {
3603
+ top = Math.max(popper.top, data.boundaries.top);
3604
+ }
3605
+ return { top: top };
3606
+ },
3607
+ bottom: function () {
3608
+ var top = popper.top;
3609
+ if (popper.bottom > data.boundaries.bottom) {
3610
+ top = Math.min(popper.top, data.boundaries.bottom - popper.height);
3611
+ }
3612
+ return { top: top };
3613
+ }
3614
+ };
3615
+
3616
+ order.forEach(function (direction) {
3617
+ data.offsets.popper = Object.assign(popper, check[direction]());
3618
+ });
3619
+
3620
+ return data;
3621
+ };
3622
+
3551
3623
  /**
3552
3624
  * Modifier used to make sure the popper is always near its reference
3553
3625
  * @method
3554
3626
  * @memberof Popper.modifiers
3555
3627
  * @argument {Object} data - The data object generated by _update method
3556
3628
  * @returns {Object} The data object, properly modified
3557
- */
3558
- Popper.prototype.modifiers.keepTogether = function (data) {
3559
- var popper = getPopperClientRect(data.offsets.popper);
3560
- var reference = data.offsets.reference;
3561
- var f = Math.floor;
3562
-
3563
- if (popper.right < f(reference.left)) {
3564
- data.offsets.popper.left = f(reference.left) - popper.width;
3565
- }
3566
- if (popper.left > f(reference.right)) {
3567
- data.offsets.popper.left = f(reference.right);
3568
- }
3569
- if (popper.bottom < f(reference.top)) {
3570
- data.offsets.popper.top = f(reference.top) - popper.height;
3571
- }
3572
- if (popper.top > f(reference.bottom)) {
3573
- data.offsets.popper.top = f(reference.bottom);
3574
- }
3575
-
3576
- return data;
3577
- };
3578
-
3629
+ */
3630
+ Popper.prototype.modifiers.keepTogether = function (data) {
3631
+ var popper = getPopperClientRect(data.offsets.popper);
3632
+ var reference = data.offsets.reference;
3633
+ var f = Math.floor;
3634
+
3635
+ if (popper.right < f(reference.left)) {
3636
+ data.offsets.popper.left = f(reference.left) - popper.width;
3637
+ }
3638
+ if (popper.left > f(reference.right)) {
3639
+ data.offsets.popper.left = f(reference.right);
3640
+ }
3641
+ if (popper.bottom < f(reference.top)) {
3642
+ data.offsets.popper.top = f(reference.top) - popper.height;
3643
+ }
3644
+ if (popper.top > f(reference.bottom)) {
3645
+ data.offsets.popper.top = f(reference.bottom);
3646
+ }
3647
+
3648
+ return data;
3649
+ };
3650
+
3579
3651
  /**
3580
3652
  * Modifier used to flip the placement of the popper when the latter is starting overlapping its reference element.
3581
3653
  * Requires the `preventOverflow` modifier before it in order to work.
@@ -3584,61 +3656,81 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
3584
3656
  * @memberof Popper.modifiers
3585
3657
  * @argument {Object} data - The data object generated by _update method
3586
3658
  * @returns {Object} The data object, properly modified
3587
- */
3588
- Popper.prototype.modifiers.flip = function (data) {
3589
- // check if preventOverflow is in the list of modifiers before the flip modifier.
3590
- // otherwise flip would not work as expected.
3591
- if (!this.isModifierRequired(this.modifiers.flip, this.modifiers.preventOverflow)) {
3592
- console.warn('WARNING: preventOverflow modifier is required by flip modifier in order to work, be sure to include it before flip!');
3593
- return data;
3594
- }
3595
-
3596
- if (data.flipped && data.placement === data._originalPlacement) {
3597
- // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
3598
- return data;
3599
- }
3600
-
3601
- var placement = data.placement.split('-')[0];
3602
- var placementOpposite = getOppositePlacement(placement);
3603
- var variation = data.placement.split('-')[1] || '';
3604
-
3605
- var flipOrder = [];
3606
- if (this._options.flipBehavior === 'flip') {
3607
- flipOrder = [placement, placementOpposite];
3608
- } else {
3609
- flipOrder = this._options.flipBehavior;
3610
- }
3611
-
3612
- flipOrder.forEach(function (step, index) {
3613
- if (placement !== step || flipOrder.length === index + 1) {
3614
- return;
3615
- }
3616
-
3617
- placement = data.placement.split('-')[0];
3618
- placementOpposite = getOppositePlacement(placement);
3619
-
3620
- var popperOffsets = getPopperClientRect(data.offsets.popper);
3621
-
3622
- // this boolean is used to distinguish right and bottom from top and left
3623
- // they need different computations to get flipped
3624
- var a = ['right', 'bottom'].indexOf(placement) !== -1;
3625
-
3626
- // using Math.floor because the reference offsets may contain decimals we are not going to consider here
3627
- if (a && Math.floor(data.offsets.reference[placement]) > Math.floor(popperOffsets[placementOpposite]) || !a && Math.floor(data.offsets.reference[placement]) < Math.floor(popperOffsets[placementOpposite])) {
3628
- // we'll use this boolean to detect any flip loop
3629
- data.flipped = true;
3630
- data.placement = flipOrder[index + 1];
3631
- if (variation) {
3632
- data.placement += '-' + variation;
3633
- }
3634
- data.offsets.popper = this._getOffsets(this._popper, this._reference, data.placement).popper;
3635
-
3636
- data = this.runModifiers(data, this._options.modifiers, this._flip);
3637
- }
3638
- }.bind(this));
3639
- return data;
3640
- };
3641
-
3659
+ */
3660
+ Popper.prototype.modifiers.flip = function (data) {
3661
+ // check if preventOverflow is in the list of modifiers before the flip modifier.
3662
+ // otherwise flip would not work as expected.
3663
+ if (
3664
+ !this.isModifierRequired(
3665
+ this.modifiers.flip,
3666
+ this.modifiers.preventOverflow
3667
+ )
3668
+ ) {
3669
+ console.warn(
3670
+ 'WARNING: preventOverflow modifier is required by flip modifier in order to work, be sure to include it before flip!'
3671
+ );
3672
+ return data;
3673
+ }
3674
+
3675
+ if (data.flipped && data.placement === data._originalPlacement) {
3676
+ // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
3677
+ return data;
3678
+ }
3679
+
3680
+ var placement = data.placement.split('-')[0];
3681
+ var placementOpposite = getOppositePlacement(placement);
3682
+ var variation = data.placement.split('-')[1] || '';
3683
+
3684
+ var flipOrder = [];
3685
+ if (this._options.flipBehavior === 'flip') {
3686
+ flipOrder = [placement, placementOpposite];
3687
+ } else {
3688
+ flipOrder = this._options.flipBehavior;
3689
+ }
3690
+
3691
+ flipOrder.forEach(
3692
+ function (step, index) {
3693
+ if (placement !== step || flipOrder.length === index + 1) {
3694
+ return;
3695
+ }
3696
+
3697
+ placement = data.placement.split('-')[0];
3698
+ placementOpposite = getOppositePlacement(placement);
3699
+
3700
+ var popperOffsets = getPopperClientRect(data.offsets.popper);
3701
+
3702
+ // this boolean is used to distinguish right and bottom from top and left
3703
+ // they need different computations to get flipped
3704
+ var a = ['right', 'bottom'].indexOf(placement) !== -1;
3705
+
3706
+ // using Math.floor because the reference offsets may contain decimals we are not going to consider here
3707
+ if (
3708
+ (a &&
3709
+ Math.floor(data.offsets.reference[placement]) >
3710
+ Math.floor(popperOffsets[placementOpposite])) ||
3711
+ (!a &&
3712
+ Math.floor(data.offsets.reference[placement]) <
3713
+ Math.floor(popperOffsets[placementOpposite]))
3714
+ ) {
3715
+ // we'll use this boolean to detect any flip loop
3716
+ data.flipped = true;
3717
+ data.placement = flipOrder[index + 1];
3718
+ if (variation) {
3719
+ data.placement += '-' + variation;
3720
+ }
3721
+ data.offsets.popper = this._getOffsets(
3722
+ this._popper,
3723
+ this._reference,
3724
+ data.placement
3725
+ ).popper;
3726
+
3727
+ data = this.runModifiers(data, this._options.modifiers, this._flip);
3728
+ }
3729
+ }.bind(this)
3730
+ );
3731
+ return data;
3732
+ };
3733
+
3642
3734
  /**
3643
3735
  * Modifier used to add an offset to the popper, useful if you more granularity positioning your popper.
3644
3736
  * The offsets will shift the popper on the side of its reference element.
@@ -3646,23 +3738,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
3646
3738
  * @memberof Popper.modifiers
3647
3739
  * @argument {Object} data - The data object generated by _update method
3648
3740
  * @returns {Object} The data object, properly modified
3649
- */
3650
- Popper.prototype.modifiers.offset = function (data) {
3651
- var offset = this._options.offset;
3652
- var popper = data.offsets.popper;
3653
-
3654
- if (data.placement.indexOf('left') !== -1) {
3655
- popper.top -= offset;
3656
- } else if (data.placement.indexOf('right') !== -1) {
3657
- popper.top += offset;
3658
- } else if (data.placement.indexOf('top') !== -1) {
3659
- popper.left -= offset;
3660
- } else if (data.placement.indexOf('bottom') !== -1) {
3661
- popper.left += offset;
3662
- }
3663
- return data;
3664
- };
3665
-
3741
+ */
3742
+ Popper.prototype.modifiers.offset = function (data) {
3743
+ var offset = this._options.offset;
3744
+ var popper = data.offsets.popper;
3745
+
3746
+ if (data.placement.indexOf('left') !== -1) {
3747
+ popper.top -= offset;
3748
+ } else if (data.placement.indexOf('right') !== -1) {
3749
+ popper.top += offset;
3750
+ } else if (data.placement.indexOf('top') !== -1) {
3751
+ popper.left -= offset;
3752
+ } else if (data.placement.indexOf('bottom') !== -1) {
3753
+ popper.left += offset;
3754
+ }
3755
+ return data;
3756
+ };
3757
+
3666
3758
  /**
3667
3759
  * 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
3668
3760
  * It will use the CSS outer size of the arrow element to know how many pixels of conjuction are needed
@@ -3670,136 +3762,147 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
3670
3762
  * @memberof Popper.modifiers
3671
3763
  * @argument {Object} data - The data object generated by _update method
3672
3764
  * @returns {Object} The data object, properly modified
3673
- */
3674
- Popper.prototype.modifiers.arrow = function (data) {
3675
- var arrow = this._options.arrowElement;
3676
- var arrowOffset = this._options.arrowOffset;
3677
-
3678
- // if the arrowElement is a string, suppose it's a CSS selector
3679
- if (typeof arrow === 'string') {
3680
- arrow = this._popper.querySelector(arrow);
3681
- }
3682
-
3683
- // if arrow element is not found, don't run the modifier
3684
- if (!arrow) {
3685
- return data;
3686
- }
3687
-
3688
- // the arrow element must be child of its popper
3689
- if (!this._popper.contains(arrow)) {
3690
- console.warn('WARNING: `arrowElement` must be child of its popper element!');
3691
- return data;
3692
- }
3693
-
3694
- // arrow depends on keepTogether in order to work
3695
- if (!this.isModifierRequired(this.modifiers.arrow, this.modifiers.keepTogether)) {
3696
- console.warn('WARNING: keepTogether modifier is required by arrow modifier in order to work, be sure to include it before arrow!');
3697
- return data;
3698
- }
3699
-
3700
- var arrowStyle = {};
3701
- var placement = data.placement.split('-')[0];
3702
- var popper = getPopperClientRect(data.offsets.popper);
3703
- var reference = data.offsets.reference;
3704
- var isVertical = ['left', 'right'].indexOf(placement) !== -1;
3705
-
3706
- var len = isVertical ? 'height' : 'width';
3707
- var side = isVertical ? 'top' : 'left';
3708
- var translate = isVertical ? 'translateY' : 'translateX';
3709
- var altSide = isVertical ? 'left' : 'top';
3710
- var opSide = isVertical ? 'bottom' : 'right';
3711
- var arrowSize = getOuterSizes(arrow)[len];
3712
-
3713
- //
3714
- // extends keepTogether behavior making sure the popper and its reference have enough pixels in conjuction
3715
- //
3716
-
3717
- // top/left side
3718
- if (reference[opSide] - arrowSize < popper[side]) {
3719
- data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowSize);
3720
- }
3721
- // bottom/right side
3722
- if (reference[side] + arrowSize > popper[opSide]) {
3723
- data.offsets.popper[side] += reference[side] + arrowSize - popper[opSide];
3724
- }
3725
-
3726
- // compute center of the popper
3727
- var center = reference[side] + (arrowOffset || reference[len] / 2 - arrowSize / 2);
3728
-
3729
- var sideValue = center - popper[side];
3730
-
3731
- // prevent arrow from being placed not contiguously to its popper
3732
- sideValue = Math.max(Math.min(popper[len] - arrowSize - 8, sideValue), 8);
3733
- arrowStyle[side] = sideValue;
3734
- arrowStyle[altSide] = ''; // make sure to remove any old style from the arrow
3735
-
3736
- data.offsets.arrow = arrowStyle;
3737
- data.arrowElement = arrow;
3738
-
3739
- return data;
3740
- };
3741
-
3742
- //
3743
- // Helpers
3744
- //
3745
-
3765
+ */
3766
+ Popper.prototype.modifiers.arrow = function (data) {
3767
+ var arrow = this._options.arrowElement;
3768
+ var arrowOffset = this._options.arrowOffset;
3769
+
3770
+ // if the arrowElement is a string, suppose it's a CSS selector
3771
+ if (typeof arrow === 'string') {
3772
+ arrow = this._popper.querySelector(arrow);
3773
+ }
3774
+
3775
+ // if arrow element is not found, don't run the modifier
3776
+ if (!arrow) {
3777
+ return data;
3778
+ }
3779
+
3780
+ // the arrow element must be child of its popper
3781
+ if (!this._popper.contains(arrow)) {
3782
+ console.warn(
3783
+ 'WARNING: `arrowElement` must be child of its popper element!'
3784
+ );
3785
+ return data;
3786
+ }
3787
+
3788
+ // arrow depends on keepTogether in order to work
3789
+ if (
3790
+ !this.isModifierRequired(
3791
+ this.modifiers.arrow,
3792
+ this.modifiers.keepTogether
3793
+ )
3794
+ ) {
3795
+ console.warn(
3796
+ 'WARNING: keepTogether modifier is required by arrow modifier in order to work, be sure to include it before arrow!'
3797
+ );
3798
+ return data;
3799
+ }
3800
+
3801
+ var arrowStyle = {};
3802
+ var placement = data.placement.split('-')[0];
3803
+ var popper = getPopperClientRect(data.offsets.popper);
3804
+ var reference = data.offsets.reference;
3805
+ var isVertical = ['left', 'right'].indexOf(placement) !== -1;
3806
+
3807
+ var len = isVertical ? 'height' : 'width';
3808
+ var side = isVertical ? 'top' : 'left';
3809
+ var translate = isVertical ? 'translateY' : 'translateX';
3810
+ var altSide = isVertical ? 'left' : 'top';
3811
+ var opSide = isVertical ? 'bottom' : 'right';
3812
+ var arrowSize = getOuterSizes(arrow)[len];
3813
+
3814
+ //
3815
+ // extends keepTogether behavior making sure the popper and its reference have enough pixels in conjuction
3816
+ //
3817
+
3818
+ // top/left side
3819
+ if (reference[opSide] - arrowSize < popper[side]) {
3820
+ data.offsets.popper[side] -=
3821
+ popper[side] - (reference[opSide] - arrowSize);
3822
+ }
3823
+ // bottom/right side
3824
+ if (reference[side] + arrowSize > popper[opSide]) {
3825
+ data.offsets.popper[side] += reference[side] + arrowSize - popper[opSide];
3826
+ }
3827
+
3828
+ // compute center of the popper
3829
+ var center =
3830
+ reference[side] + (arrowOffset || reference[len] / 2 - arrowSize / 2);
3831
+
3832
+ var sideValue = center - popper[side];
3833
+
3834
+ // prevent arrow from being placed not contiguously to its popper
3835
+ sideValue = Math.max(Math.min(popper[len] - arrowSize - 8, sideValue), 8);
3836
+ arrowStyle[side] = sideValue;
3837
+ arrowStyle[altSide] = ''; // make sure to remove any old style from the arrow
3838
+
3839
+ data.offsets.arrow = arrowStyle;
3840
+ data.arrowElement = arrow;
3841
+
3842
+ return data;
3843
+ };
3844
+
3845
+ //
3846
+ // Helpers
3847
+ //
3848
+
3746
3849
  /**
3747
3850
  * Get the outer sizes of the given element (offset size + margins)
3748
3851
  * @function
3749
3852
  * @ignore
3750
3853
  * @argument {Element} element
3751
3854
  * @returns {Object} object containing width and height properties
3752
- */
3753
- function getOuterSizes(element) {
3754
- // NOTE: 1 DOM access here
3755
- var _display = element.style.display,
3756
- _visibility = element.style.visibility;
3757
- element.style.display = 'block';
3758
- element.style.visibility = 'hidden';
3759
- var calcWidthToForceRepaint = element.offsetWidth;
3760
- // original method
3761
- var styles = root.getComputedStyle(element);
3762
- var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
3763
- var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
3764
- var result = {
3765
- width: element.offsetWidth + y,
3766
- height: element.offsetHeight + x
3767
- };
3768
-
3769
- // reset element styles
3770
- element.style.display = _display;
3771
- element.style.visibility = _visibility;
3772
- return result;
3773
- }
3774
-
3855
+ */
3856
+ function getOuterSizes(element) {
3857
+ // NOTE: 1 DOM access here
3858
+ var _display = element.style.display,
3859
+ _visibility = element.style.visibility;
3860
+ element.style.display = 'block';
3861
+ element.style.visibility = 'hidden';
3862
+ var calcWidthToForceRepaint = element.offsetWidth;
3863
+ // original method
3864
+ var styles = getRealWindow(element).getComputedStyle(element);
3865
+ var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
3866
+ var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
3867
+ var result = {
3868
+ width: element.offsetWidth + y,
3869
+ height: element.offsetHeight + x
3870
+ };
3871
+
3872
+ // reset element styles
3873
+ element.style.display = _display;
3874
+ element.style.visibility = _visibility;
3875
+ return result;
3876
+ }
3877
+
3775
3878
  /**
3776
3879
  * Get the opposite placement of the given one/
3777
3880
  * @function
3778
3881
  * @ignore
3779
3882
  * @argument {String} placement
3780
3883
  * @returns {String} flipped placement
3781
- */
3782
- function getOppositePlacement(placement) {
3783
- var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
3784
- return placement.replace(/left|right|bottom|top/g, function (matched) {
3785
- return hash[matched];
3786
- });
3787
- }
3788
-
3884
+ */
3885
+ function getOppositePlacement(placement) {
3886
+ var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
3887
+ return placement.replace(/left|right|bottom|top/g, function (matched) {
3888
+ return hash[matched];
3889
+ });
3890
+ }
3891
+
3789
3892
  /**
3790
3893
  * Given the popper offsets, generate an output similar to getBoundingClientRect
3791
3894
  * @function
3792
3895
  * @ignore
3793
3896
  * @argument {Object} popperOffsets
3794
3897
  * @returns {Object} ClientRect like output
3795
- */
3796
- function getPopperClientRect(popperOffsets) {
3797
- var offsets = Object.assign({}, popperOffsets);
3798
- offsets.right = offsets.left + offsets.width;
3799
- offsets.bottom = offsets.top + offsets.height;
3800
- return offsets;
3801
- }
3802
-
3898
+ */
3899
+ function getPopperClientRect(popperOffsets) {
3900
+ var offsets = Object.assign({}, popperOffsets);
3901
+ offsets.right = offsets.left + offsets.width;
3902
+ offsets.bottom = offsets.top + offsets.height;
3903
+ return offsets;
3904
+ }
3905
+
3803
3906
  /**
3804
3907
  * Given an array and the key to find, returns its index
3805
3908
  * @function
@@ -3807,76 +3910,155 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
3807
3910
  * @argument {Array} arr
3808
3911
  * @argument keyToFind
3809
3912
  * @returns index or null
3810
- */
3811
- function getArrayKeyIndex(arr, keyToFind) {
3812
- var i = 0,
3813
- key;
3814
- for (key in arr) {
3815
- if (arr[key] === keyToFind) {
3816
- return i;
3817
- }
3818
- i++;
3819
- }
3820
- return null;
3821
- }
3822
-
3913
+ */
3914
+ function getArrayKeyIndex(arr, keyToFind) {
3915
+ var i = 0,
3916
+ key;
3917
+ for (key in arr) {
3918
+ if (arr[key] === keyToFind) {
3919
+ return i;
3920
+ }
3921
+ i++;
3922
+ }
3923
+ return null;
3924
+ }
3925
+
3823
3926
  /**
3824
3927
  * Get CSS computed property of the given element
3825
3928
  * @function
3826
3929
  * @ignore
3827
3930
  * @argument {Eement} element
3828
3931
  * @argument {String} property
3829
- */
3830
- function getStyleComputedProperty(element, property) {
3831
- // NOTE: 1 DOM access here
3832
- var css = root.getComputedStyle(element, null);
3833
- return css[property];
3834
- }
3932
+ */
3933
+ function getStyleComputedProperty(element, property) {
3934
+ // NOTE: 1 DOM access here
3935
+ // 无界等微前端场景下沙箱 window 与元素实际渲染所在 window 可能不一致,
3936
+ // 需使用元素自身的 view 读取计算样式,避免跨 document 读取到空值
3937
+ var css = getRealWindow(element).getComputedStyle(element, null);
3938
+ return css[property];
3939
+ }
3940
+
3835
3941
  /**
3836
3942
  * Returns the offset parent of the given element
3837
3943
  * @function
3838
3944
  * @ignore
3839
3945
  * @argument {Element} element
3840
3946
  * @returns {Element} offset parent
3841
- */
3842
- function getOffsetParent(element) {
3843
- var offsetParent = element.offsetParent;
3844
- return offsetParent === root.document.body || !offsetParent ? root.document.documentElement : offsetParent;
3845
- }
3846
-
3947
+ */
3948
+ function getOffsetParent(element) {
3949
+ var offsetParent = element.offsetParent;
3950
+ return offsetParent === root.document.body || !offsetParent
3951
+ ? root.document.documentElement
3952
+ : offsetParent;
3953
+ }
3954
+
3955
+ /**
3956
+ * Returns the window the given element actually renders in.
3957
+ * 无界等微前端场景下组件代码运行在沙箱 window 中,而 DOM 实际渲染在
3958
+ * 主应用的 window(shadowRoot 内),滚动量、视口尺寸等必须取自元素自身的 view
3959
+ * @function
3960
+ * @ignore
3961
+ * @argument {Element} element
3962
+ * @returns {Window} window
3963
+ */
3964
+ function getRealWindow(element) {
3965
+ return (
3966
+ (element &&
3967
+ element.ownerDocument &&
3968
+ element.ownerDocument.defaultView) ||
3969
+ root
3970
+ );
3971
+ }
3972
+
3973
+ /**
3974
+ * Returns the viewport rect of the containing block actually used to position the popper.
3975
+ * 无界微前端等场景下 popper 被挂载进子应用的 shadowRoot,offsetParent 的兜底值
3976
+ * (documentElement)与浏览器真实的包含块不再重合,导致下拉框/提示框整体偏移
3977
+ * (偏移量恰为子应用容器在主应用中的位置),因此需要沿 composed tree 查找:
3978
+ * - fixed 定位:包含块为视口;
3979
+ * - absolute 定位:最近的 positioned 祖先元素(跨 shadowRoot 边界查找);
3980
+ * - 无 positioned 祖先:初始包含块,其视口原点为真实 window 滚动量的负值。
3981
+ * @function
3982
+ * @ignore
3983
+ * @argument {Element} element - popper element
3984
+ * @argument {Boolean} fixed - whether the popper is fixed positioned
3985
+ * @returns {Object} rect
3986
+ */
3987
+ function getContainingBlockRect(element, fixed) {
3988
+ if (fixed) {
3989
+ return { top: 0, left: 0, right: 0, bottom: 0 };
3990
+ }
3991
+
3992
+ var node = element.parentNode;
3993
+ while (node) {
3994
+ if (node.nodeType === 1) {
3995
+ if (getStyleComputedProperty(node, 'position') !== 'static') {
3996
+ return getBoundingClientRect(node);
3997
+ }
3998
+ } else if (node.nodeType === 11) {
3999
+ // 遇到 shadowRoot,跨边界从宿主元素继续向上查找
4000
+ node = node.host;
4001
+ continue;
4002
+ } else {
4003
+ break;
4004
+ }
4005
+ node = node.parentNode;
4006
+ }
4007
+
4008
+ var win = getRealWindow(element);
4009
+ return {
4010
+ top: -(win.pageYOffset || 0),
4011
+ left: -(win.pageXOffset || 0),
4012
+ right: 0,
4013
+ bottom: 0
4014
+ };
4015
+ }
4016
+
3847
4017
  /**
3848
4018
  * Returns the scrolling parent of the given element
3849
4019
  * @function
3850
4020
  * @ignore
3851
4021
  * @argument {Element} element
3852
4022
  * @returns {Element} offset parent
3853
- */
3854
- function getScrollParent(element) {
3855
- var parent = element.parentNode;
3856
- if (!parent || parent.nodeType !== 1) {
3857
- return element;
3858
- }
3859
-
3860
- if (parent === root.document) {
3861
- // Firefox puts the scrollTOp value on `documentElement` instead of `body`, we then check which of them is
3862
- // greater than 0 and return the proper element
3863
- if (root.document.body.scrollTop || root.document.body.scrollLeft) {
3864
- return root.document.body;
3865
- } else {
3866
- return root.document.documentElement;
3867
- }
3868
- }
3869
-
3870
- // Firefox want us to check `-x` and `-y` variations as well
3871
- if (['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow')) !== -1 || ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-x')) !== -1 || ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-y')) !== -1) {
3872
- // If the detected scrollParent is body, we perform an additional check on its parentNode
3873
- // in this way we'll get body if the browser is Chrome-ish, or documentElement otherwise
3874
- // fixes issue #65
3875
- return parent;
3876
- }
3877
- return getScrollParent(element.parentNode);
3878
- }
3879
-
4023
+ */
4024
+ function getScrollParent(element) {
4025
+ var parent = element.parentNode;
4026
+ if (!parent) {
4027
+ return element;
4028
+ }
4029
+
4030
+ if (parent.nodeType === 11) {
4031
+ // 无界等微前端场景 DOM 位于 shadowRoot 内,需跨边界从宿主元素继续向上查找,
4032
+ // 否则查找到 shadowRoot 即终止,滚动事件无法被监听
4033
+ return getScrollParent(parent.host);
4034
+ }
4035
+
4036
+ if (parent.nodeType !== 1) {
4037
+ // 到达 document,返回元素实际渲染所在的真实 window,
4038
+ // 保证 window 滚动时能触发位置更新
4039
+ return getRealWindow(element);
4040
+ }
4041
+
4042
+ // Firefox want us to check `-x` and `-y` variations as well
4043
+ if (
4044
+ ['scroll', 'auto'].indexOf(
4045
+ getStyleComputedProperty(parent, 'overflow')
4046
+ ) !== -1 ||
4047
+ ['scroll', 'auto'].indexOf(
4048
+ getStyleComputedProperty(parent, 'overflow-x')
4049
+ ) !== -1 ||
4050
+ ['scroll', 'auto'].indexOf(
4051
+ getStyleComputedProperty(parent, 'overflow-y')
4052
+ ) !== -1
4053
+ ) {
4054
+ // If the detected scrollParent is body, we perform an additional check on its parentNode
4055
+ // in this way we'll get body if the browser is Chrome-ish, or documentElement otherwise
4056
+ // fixes issue #65
4057
+ return parent;
4058
+ }
4059
+ return getScrollParent(parent);
4060
+ }
4061
+
3880
4062
  /**
3881
4063
  * Check if the given element is fixed or is inside a fixed parent
3882
4064
  * @function
@@ -3884,109 +4066,125 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
3884
4066
  * @argument {Element} element
3885
4067
  * @argument {Element} customContainer
3886
4068
  * @returns {Boolean} answer to "isFixed?"
3887
- */
3888
- function isFixed(element) {
3889
- if (element === root.document.body) {
3890
- return false;
3891
- }
3892
- if (getStyleComputedProperty(element, 'position') === 'fixed') {
3893
- return true;
3894
- }
3895
- return element.parentNode && element.parentNode.nodeType === 1 ? isFixed(element.parentNode) : element;
3896
- }
3897
-
4069
+ */
4070
+ function isFixed(element) {
4071
+ if (element === root.document.body) {
4072
+ return false;
4073
+ }
4074
+ if (getStyleComputedProperty(element, 'position') === 'fixed') {
4075
+ return true;
4076
+ }
4077
+ var parent = element.parentNode;
4078
+ if (parent && parent.nodeType === 11) {
4079
+ // 跨 shadowRoot 边界,从宿主元素继续向上判断
4080
+ parent = parent.host;
4081
+ }
4082
+ return parent && parent.nodeType === 1 ? isFixed(parent) : false;
4083
+ }
4084
+
3898
4085
  /**
3899
4086
  * Set the style to the given popper
3900
4087
  * @function
3901
4088
  * @ignore
3902
4089
  * @argument {Element} element - Element to apply the style to
3903
4090
  * @argument {Object} styles - Object with a list of properties and values which will be applied to the element
3904
- */
3905
- function setStyle(element, styles) {
3906
- function is_numeric(n) {
3907
- return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
3908
- }
3909
- Object.keys(styles).forEach(function (prop) {
3910
- var unit = '';
3911
- // add unit if the value is numeric and is one of the following
3912
- if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && is_numeric(styles[prop])) {
3913
- unit = 'px';
3914
- }
3915
- element.style[prop] = styles[prop] + unit;
3916
- });
3917
- }
3918
-
4091
+ */
4092
+ function setStyle(element, styles) {
4093
+ function is_numeric(n) {
4094
+ return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
4095
+ }
4096
+ Object.keys(styles).forEach(function (prop) {
4097
+ var unit = '';
4098
+ // add unit if the value is numeric and is one of the following
4099
+ if (
4100
+ ['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !==
4101
+ -1 &&
4102
+ is_numeric(styles[prop])
4103
+ ) {
4104
+ unit = 'px';
4105
+ }
4106
+ element.style[prop] = styles[prop] + unit;
4107
+ });
4108
+ }
4109
+
3919
4110
  /**
3920
4111
  * Check if the given variable is a function
3921
4112
  * @function
3922
4113
  * @ignore
3923
4114
  * @argument {*} functionToCheck - variable to check
3924
4115
  * @returns {Boolean} answer to: is a function?
3925
- */
3926
- function isFunction(functionToCheck) {
3927
- var getType = {};
3928
- return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
3929
- }
3930
-
4116
+ */
4117
+ function isFunction(functionToCheck) {
4118
+ var getType = {};
4119
+ return (
4120
+ functionToCheck &&
4121
+ getType.toString.call(functionToCheck) === '[object Function]'
4122
+ );
4123
+ }
4124
+
3931
4125
  /**
3932
4126
  * Get the position of the given element, relative to its offset parent
3933
4127
  * @function
3934
4128
  * @ignore
3935
4129
  * @param {Element} element
3936
4130
  * @return {Object} position - Coordinates of the element and its `scrollTop`
3937
- */
3938
- function getOffsetRect(element) {
3939
- var transform = getStyle(element, 'transform').replace(/[^0-9\-,]/g, '').split(',');
3940
- var elementRect = {
3941
- width: element.offsetWidth,
3942
- height: element.offsetHeight,
3943
- left: element.offsetLeft + (transform[4] ? parseInt(transform[4], 10) : 0),
3944
- top: element.offsetTop + (transform[5] ? parseInt(transform[5], 10) : 0)
3945
- };
3946
-
3947
- elementRect.right = elementRect.left + elementRect.width;
3948
- elementRect.bottom = elementRect.top + elementRect.height;
3949
-
3950
- // position
3951
- return elementRect;
3952
- }
3953
-
4131
+ */
4132
+ function getOffsetRect(element) {
4133
+ var transform = getStyle(element, 'transform')
4134
+ .replace(/[^0-9\-,]/g, '')
4135
+ .split(',');
4136
+ var elementRect = {
4137
+ width: element.offsetWidth,
4138
+ height: element.offsetHeight,
4139
+ left:
4140
+ element.offsetLeft + (transform[4] ? parseInt(transform[4], 10) : 0),
4141
+ top: element.offsetTop + (transform[5] ? parseInt(transform[5], 10) : 0)
4142
+ };
4143
+
4144
+ elementRect.right = elementRect.left + elementRect.width;
4145
+ elementRect.bottom = elementRect.top + elementRect.height;
4146
+
4147
+ // position
4148
+ return elementRect;
4149
+ }
4150
+
3954
4151
  /**
3955
4152
  * Get bounding client rect of given element
3956
4153
  * @function
3957
4154
  * @ignore
3958
4155
  * @param {HTMLElement} element
3959
4156
  * @return {Object} client rect
3960
- */
3961
- function getBoundingClientRect(element) {
3962
- var rect = element.getBoundingClientRect();
3963
-
3964
- // whether the IE version is lower than 11
3965
- var isIE = /MSIE|Trident/.test(navigator.userAgent);
3966
-
3967
- // fix ie document bounding top always 0 bug
3968
- var rectTop = isIE && element.tagName === 'HTML' ? -element.scrollTop : rect.top;
3969
-
3970
- return {
3971
- left: rect.left,
3972
- top: rectTop,
3973
- right: rect.right,
3974
- bottom: rect.bottom,
3975
- width: rect.right - rect.left,
3976
- height: rect.bottom - rectTop
3977
- };
3978
- }
3979
-
3980
- function getStyle(dom, attr) {
3981
- if (dom.style[attr]) {
3982
- return dom.style[attr];
3983
- }
3984
- if (window.getComputedStyle) {
3985
- return getComputedStyle(dom, null)[attr];
3986
- }
3987
- return dom.currentStyle[attr];
3988
- }
3989
-
4157
+ */
4158
+ function getBoundingClientRect(element) {
4159
+ var rect = element.getBoundingClientRect();
4160
+
4161
+ // whether the IE version is lower than 11
4162
+ var isIE = /MSIE|Trident/.test(navigator.userAgent);
4163
+
4164
+ // fix ie document bounding top always 0 bug
4165
+ var rectTop =
4166
+ isIE && element.tagName === 'HTML' ? -element.scrollTop : rect.top;
4167
+
4168
+ return {
4169
+ left: rect.left,
4170
+ top: rectTop,
4171
+ right: rect.right,
4172
+ bottom: rect.bottom,
4173
+ width: rect.right - rect.left,
4174
+ height: rect.bottom - rectTop
4175
+ };
4176
+ }
4177
+
4178
+ function getStyle(dom, attr) {
4179
+ if (dom.style[attr]) {
4180
+ return dom.style[attr];
4181
+ }
4182
+ if (window.getComputedStyle) {
4183
+ return getComputedStyle(dom, null)[attr];
4184
+ }
4185
+ return dom.currentStyle[attr];
4186
+ }
4187
+
3990
4188
  /**
3991
4189
  * Given an element and one of its parents, return the offset
3992
4190
  * @function
@@ -3994,49 +4192,45 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
3994
4192
  * @param {HTMLElement} element
3995
4193
  * @param {HTMLElement} parent
3996
4194
  * @return {Object} rect
3997
- */
3998
- function getOffsetRectRelativeToCustomParent(element, parent, fixed) {
3999
- var elementRect = getBoundingClientRect(element);
4000
- var parentRect = getBoundingClientRect(parent);
4001
-
4002
- if (fixed) {
4003
- var scrollParent = getScrollParent(parent);
4004
- parentRect.top += scrollParent.scrollTop;
4005
- parentRect.bottom += scrollParent.scrollTop;
4006
- parentRect.left += scrollParent.scrollLeft;
4007
- parentRect.right += scrollParent.scrollLeft;
4008
- }
4009
-
4010
- var rect = {
4011
- top: elementRect.top - parentRect.top,
4012
- left: elementRect.left - parentRect.left,
4013
- bottom: elementRect.top - parentRect.top + elementRect.height,
4014
- right: elementRect.left - parentRect.left + elementRect.width,
4015
- width: elementRect.width,
4016
- height: elementRect.height
4017
- };
4018
- return rect;
4019
- }
4020
-
4195
+ */
4196
+ function getOffsetRectRelativeToCustomParent(element, parent, fixed) {
4197
+ var elementRect = getBoundingClientRect(element);
4198
+ // parent 为 popper 元素:取其真实包含块的视口 rect,
4199
+ // 避免无界 shadowRoot 等场景下包含块假设错误导致的整体偏移
4200
+ var parentRect = getContainingBlockRect(parent, fixed);
4201
+
4202
+ var rect = {
4203
+ top: elementRect.top - parentRect.top,
4204
+ left: elementRect.left - parentRect.left,
4205
+ bottom: elementRect.top - parentRect.top + elementRect.height,
4206
+ right: elementRect.left - parentRect.left + elementRect.width,
4207
+ width: elementRect.width,
4208
+ height: elementRect.height
4209
+ };
4210
+ return rect;
4211
+ }
4212
+
4021
4213
  /**
4022
4214
  * Get the prefixed supported property name
4023
4215
  * @function
4024
4216
  * @ignore
4025
4217
  * @argument {String} property (camelCase)
4026
4218
  * @returns {String} prefixed property (camelCase)
4027
- */
4028
- function getSupportedPropertyName(property) {
4029
- var prefixes = ['', 'ms', 'webkit', 'moz', 'o'];
4030
-
4031
- for (var i = 0; i < prefixes.length; i++) {
4032
- var toCheck = prefixes[i] ? prefixes[i] + property.charAt(0).toUpperCase() + property.slice(1) : property;
4033
- if (typeof root.document.body.style[toCheck] !== 'undefined') {
4034
- return toCheck;
4035
- }
4036
- }
4037
- return null;
4038
- }
4039
-
4219
+ */
4220
+ function getSupportedPropertyName(property) {
4221
+ var prefixes = ['', 'ms', 'webkit', 'moz', 'o'];
4222
+
4223
+ for (var i = 0; i < prefixes.length; i++) {
4224
+ var toCheck = prefixes[i]
4225
+ ? prefixes[i] + property.charAt(0).toUpperCase() + property.slice(1)
4226
+ : property;
4227
+ if (typeof root.document.body.style[toCheck] !== 'undefined') {
4228
+ return toCheck;
4229
+ }
4230
+ }
4231
+ return null;
4232
+ }
4233
+
4040
4234
  /**
4041
4235
  * The Object.assign() method is used to copy the values of all enumerable own properties from one or more source
4042
4236
  * objects to a target object. It will return the target object.
@@ -4044,41 +4238,46 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
4044
4238
  * Source: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
4045
4239
  * @function
4046
4240
  * @ignore
4047
- */
4048
- if (!Object.assign) {
4049
- Object.defineProperty(Object, 'assign', {
4050
- enumerable: false,
4051
- configurable: true,
4052
- writable: true,
4053
- value: function value(target) {
4054
- if (target === undefined || target === null) {
4055
- throw new TypeError('Cannot convert first argument to object');
4056
- }
4241
+ */
4242
+ if (!Object.assign) {
4243
+ Object.defineProperty(Object, 'assign', {
4244
+ enumerable: false,
4245
+ configurable: true,
4246
+ writable: true,
4247
+ value: function (target) {
4248
+ if (target === undefined || target === null) {
4249
+ throw new TypeError('Cannot convert first argument to object');
4250
+ }
4251
+
4252
+ var to = Object(target);
4253
+ for (var i = 1; i < arguments.length; i++) {
4254
+ var nextSource = arguments[i];
4255
+ if (nextSource === undefined || nextSource === null) {
4256
+ continue;
4257
+ }
4258
+ nextSource = Object(nextSource);
4259
+
4260
+ var keysArray = Object.keys(nextSource);
4261
+ for (
4262
+ var nextIndex = 0, len = keysArray.length;
4263
+ nextIndex < len;
4264
+ nextIndex++
4265
+ ) {
4266
+ var nextKey = keysArray[nextIndex];
4267
+ var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
4268
+ if (desc !== undefined && desc.enumerable) {
4269
+ to[nextKey] = nextSource[nextKey];
4270
+ }
4271
+ }
4272
+ }
4273
+ return to;
4274
+ }
4275
+ });
4276
+ }
4277
+
4278
+ return Popper;
4279
+ });
4057
4280
 
4058
- var to = Object(target);
4059
- for (var i = 1; i < arguments.length; i++) {
4060
- var nextSource = arguments[i];
4061
- if (nextSource === undefined || nextSource === null) {
4062
- continue;
4063
- }
4064
- nextSource = Object(nextSource);
4065
-
4066
- var keysArray = Object.keys(nextSource);
4067
- for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
4068
- var nextKey = keysArray[nextIndex];
4069
- var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
4070
- if (desc !== undefined && desc.enumerable) {
4071
- to[nextKey] = nextSource[nextKey];
4072
- }
4073
- }
4074
- }
4075
- return to;
4076
- }
4077
- });
4078
- }
4079
-
4080
- return Popper;
4081
- });
4082
4281
 
4083
4282
  /***/ }),
4084
4283
 
@@ -4132,736 +4331,759 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof =
4132
4331
  /* unused harmony export getSecond */
4133
4332
  /* unused harmony export getWeekday */
4134
4333
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
4135
-
4136
-
4334
+ /* Modified from https://github.com/taylorhakes/fecha
4335
+ *
4336
+ * The MIT License (MIT)
4337
+ *
4338
+ * Copyright (c) 2015 Taylor Hakes
4339
+ *
4340
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
4341
+ * of this software and associated documentation files (the "Software"), to deal
4342
+ * in the Software without restriction, including without limitation the rights
4343
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4344
+ * copies of the Software, and to permit persons to whom the Software is
4345
+ * furnished to do so, subject to the following conditions:
4346
+ *
4347
+ * The above copyright notice and this permission notice shall be included in all
4348
+ * copies or substantial portions of the Software.
4349
+ *
4350
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4351
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4352
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4353
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4354
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4355
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4356
+ * SOFTWARE.
4357
+ */
4358
+
4359
+ /*eslint-disable*/
4360
+ // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
4361
+
4362
+
4137
4363
  /**
4138
4364
  * Parse or format dates
4139
4365
  * @class fecha
4140
- */
4141
- var fecha = {};
4142
- var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
4143
- var twoDigits = '\\d\\d?';
4144
- var threeDigits = '\\d{3}';
4145
- var fourDigits = '\\d{4}';
4146
- var word = '[^\\s]+';
4147
- var literal = /\[([^]*?)\]/gm;
4148
- var noop = function noop() {};
4149
-
4150
- function regexEscape(str) {
4151
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
4152
- }
4153
-
4154
- function shorten(arr, sLen) {
4155
- var newArr = [];
4156
- for (var i = 0, len = arr.length; i < len; i++) {
4157
- newArr.push(arr[i].substr(0, sLen));
4158
- }
4159
- return newArr;
4160
- }
4161
-
4162
- function monthUpdate() {
4163
- return function (d, v) {
4164
- var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
4165
- if (~index) {
4166
- d.month = index;
4167
- }
4168
- };
4169
- }
4170
-
4171
- function pad(val, len) {
4172
- val = String(val);
4173
- len = len || 2;
4174
- while (val.length < len) {
4175
- val = '0' + val;
4176
- }
4177
- return val;
4178
- }
4179
-
4180
- // 直接使用中文日期名称常量
4181
- var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
4182
- var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
4183
- var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
4184
- var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
4185
- var amPm = ['上午', '下午'];
4186
- var DoFn = function DoFn(D) {
4187
- return D + '日';
4188
- };
4189
-
4190
- var formatFlags = {
4191
- D: function D(dateObj) {
4192
- return dateObj.getDay();
4193
- },
4194
- DD: function DD(dateObj) {
4195
- return pad(dateObj.getDay());
4196
- },
4197
- Do: function Do(dateObj) {
4198
- return DoFn(dateObj.getDate());
4199
- },
4200
- d: function d(dateObj) {
4201
- return dateObj.getDate();
4202
- },
4203
- dd: function dd(dateObj) {
4204
- return pad(dateObj.getDate());
4205
- },
4206
- ddd: function ddd(dateObj) {
4207
- return dayNamesShort[dateObj.getDay()];
4208
- },
4209
- dddd: function dddd(dateObj) {
4210
- return dayNames[dateObj.getDay()];
4211
- },
4212
- M: function M(dateObj) {
4213
- return dateObj.getMonth() + 1;
4214
- },
4215
- MM: function MM(dateObj) {
4216
- return pad(dateObj.getMonth() + 1);
4217
- },
4218
- MMM: function MMM(dateObj) {
4219
- return monthNamesShort[dateObj.getMonth()];
4220
- },
4221
- MMMM: function MMMM(dateObj) {
4222
- return monthNames[dateObj.getMonth()];
4223
- },
4224
- yy: function yy(dateObj) {
4225
- return pad(String(dateObj.getFullYear()), 4).substr(2);
4226
- },
4227
- yyyy: function yyyy(dateObj) {
4228
- return pad(dateObj.getFullYear(), 4);
4229
- },
4230
- h: function h(dateObj) {
4231
- return dateObj.getHours() % 12 || 12;
4232
- },
4233
- hh: function hh(dateObj) {
4234
- return pad(dateObj.getHours() % 12 || 12);
4235
- },
4236
- H: function H(dateObj) {
4237
- return dateObj.getHours();
4238
- },
4239
- HH: function HH(dateObj) {
4240
- return pad(dateObj.getHours());
4241
- },
4242
- m: function m(dateObj) {
4243
- return dateObj.getMinutes();
4244
- },
4245
- mm: function mm(dateObj) {
4246
- return pad(dateObj.getMinutes());
4247
- },
4248
- s: function s(dateObj) {
4249
- return dateObj.getSeconds();
4250
- },
4251
- ss: function ss(dateObj) {
4252
- return pad(dateObj.getSeconds());
4253
- },
4254
- S: function S(dateObj) {
4255
- return Math.round(dateObj.getMilliseconds() / 100);
4256
- },
4257
- SS: function SS(dateObj) {
4258
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
4259
- },
4260
- SSS: function SSS(dateObj) {
4261
- return pad(dateObj.getMilliseconds(), 3);
4262
- },
4263
- a: function a(dateObj) {
4264
- return dateObj.getHours() < 12 ? '上午' : '下午';
4265
- },
4266
- A: function A(dateObj) {
4267
- return dateObj.getHours() < 12 ? '上午' : '下午';
4268
- },
4269
- ZZ: function ZZ(dateObj) {
4270
- var o = dateObj.getTimezoneOffset();
4271
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
4272
- }
4273
- };
4274
-
4275
- var parseFlags = {
4276
- d: [twoDigits, function (d, v) {
4277
- d.day = v;
4278
- }],
4279
- Do: [twoDigits + word, function (d, v) {
4280
- d.day = parseInt(v, 10);
4281
- }],
4282
- M: [twoDigits, function (d, v) {
4283
- d.month = v - 1;
4284
- }],
4285
- yy: [twoDigits, function (d, v) {
4286
- var da = new Date(),
4287
- cent = +('' + da.getFullYear()).substr(0, 2);
4288
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
4289
- }],
4290
- h: [twoDigits, function (d, v) {
4291
- d.hour = v;
4292
- }],
4293
- m: [twoDigits, function (d, v) {
4294
- d.minute = v;
4295
- }],
4296
- s: [twoDigits, function (d, v) {
4297
- d.second = v;
4298
- }],
4299
- yyyy: [fourDigits, function (d, v) {
4300
- d.year = v;
4301
- }],
4302
- S: ['\\d', function (d, v) {
4303
- d.millisecond = v * 100;
4304
- }],
4305
- SS: ['\\d{2}', function (d, v) {
4306
- d.millisecond = v * 10;
4307
- }],
4308
- SSS: [threeDigits, function (d, v) {
4309
- d.millisecond = v;
4310
- }],
4311
- D: [twoDigits, noop],
4312
- ddd: [word, noop],
4313
- MMM: [word, monthUpdate('monthNamesShort')],
4314
- MMMM: [word, monthUpdate('monthNames')],
4315
- a: [word, function (d, v) {
4316
- var val = v.toLowerCase();
4317
- if (val === '上午') {
4318
- d.isPm = false;
4319
- } else if (val === '下午') {
4320
- d.isPm = true;
4321
- }
4322
- }],
4323
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
4324
- var parts = (v + '').match(/([+-]|\d\d)/gi),
4325
- minutes = void 0;
4326
-
4327
- if (parts) {
4328
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
4329
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
4330
- }
4331
- }]
4332
- };
4333
- parseFlags.dd = parseFlags.d;
4334
- parseFlags.dddd = parseFlags.ddd;
4335
- parseFlags.DD = parseFlags.D;
4336
- parseFlags.mm = parseFlags.m;
4337
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
4338
- parseFlags.MM = parseFlags.M;
4339
- parseFlags.ss = parseFlags.s;
4340
- parseFlags.A = parseFlags.a;
4341
-
4342
- // Some common format strings
4343
- fecha.masks = {
4344
- default: 'ddd MMM dd yyyy HH:mm:ss',
4345
- shortDate: 'M/D/yy',
4346
- mediumDate: 'MMM d, yyyy',
4347
- longDate: 'MMMM d, yyyy',
4348
- fullDate: 'dddd, MMMM d, yyyy',
4349
- shortTime: 'HH:mm',
4350
- mediumTime: 'HH:mm:ss',
4351
- longTime: 'HH:mm:ss.SSS'
4352
- };
4353
-
4366
+ */
4367
+ const fecha = {};
4368
+ const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
4369
+ const twoDigits = '\\d\\d?';
4370
+ const threeDigits = '\\d{3}';
4371
+ const fourDigits = '\\d{4}';
4372
+ const word = '[^\\s]+';
4373
+ const literal = /\[([^]*?)\]/gm;
4374
+ const noop = function () {};
4375
+
4376
+ function regexEscape(str) {
4377
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
4378
+ }
4379
+
4380
+ function shorten(arr, sLen) {
4381
+ const newArr = [];
4382
+ for (let i = 0, len = arr.length; i < len; i++) {
4383
+ newArr.push(arr[i].substr(0, sLen));
4384
+ }
4385
+ return newArr;
4386
+ }
4387
+
4388
+ function monthUpdate() {
4389
+ return function (d, v) {
4390
+ const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
4391
+ if (~index) {
4392
+ d.month = index;
4393
+ }
4394
+ };
4395
+ }
4396
+
4397
+ function pad(val, len) {
4398
+ val = String(val);
4399
+ len = len || 2;
4400
+ while (val.length < len) {
4401
+ val = '0' + val;
4402
+ }
4403
+ return val;
4404
+ }
4405
+
4406
+ // 直接使用中文日期名称常量
4407
+ const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
4408
+ const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
4409
+ const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
4410
+ const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
4411
+ const amPm = ['上午', '下午'];
4412
+ const DoFn = function DoFn(D) {
4413
+ return D + '日';
4414
+ };
4415
+
4416
+ const formatFlags = {
4417
+ D: function(dateObj) {
4418
+ return dateObj.getDay();
4419
+ },
4420
+ DD: function(dateObj) {
4421
+ return pad(dateObj.getDay());
4422
+ },
4423
+ Do: function(dateObj) {
4424
+ return DoFn(dateObj.getDate());
4425
+ },
4426
+ d: function(dateObj) {
4427
+ return dateObj.getDate();
4428
+ },
4429
+ dd: function(dateObj) {
4430
+ return pad(dateObj.getDate());
4431
+ },
4432
+ ddd: function(dateObj) {
4433
+ return dayNamesShort[dateObj.getDay()];
4434
+ },
4435
+ dddd: function(dateObj) {
4436
+ return dayNames[dateObj.getDay()];
4437
+ },
4438
+ M: function(dateObj) {
4439
+ return dateObj.getMonth() + 1;
4440
+ },
4441
+ MM: function(dateObj) {
4442
+ return pad(dateObj.getMonth() + 1);
4443
+ },
4444
+ MMM: function(dateObj) {
4445
+ return monthNamesShort[dateObj.getMonth()];
4446
+ },
4447
+ MMMM: function(dateObj) {
4448
+ return monthNames[dateObj.getMonth()];
4449
+ },
4450
+ yy: function(dateObj) {
4451
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
4452
+ },
4453
+ yyyy: function(dateObj) {
4454
+ return pad(dateObj.getFullYear(), 4);
4455
+ },
4456
+ h: function(dateObj) {
4457
+ return dateObj.getHours() % 12 || 12;
4458
+ },
4459
+ hh: function(dateObj) {
4460
+ return pad(dateObj.getHours() % 12 || 12);
4461
+ },
4462
+ H: function(dateObj) {
4463
+ return dateObj.getHours();
4464
+ },
4465
+ HH: function(dateObj) {
4466
+ return pad(dateObj.getHours());
4467
+ },
4468
+ m: function(dateObj) {
4469
+ return dateObj.getMinutes();
4470
+ },
4471
+ mm: function(dateObj) {
4472
+ return pad(dateObj.getMinutes());
4473
+ },
4474
+ s: function(dateObj) {
4475
+ return dateObj.getSeconds();
4476
+ },
4477
+ ss: function(dateObj) {
4478
+ return pad(dateObj.getSeconds());
4479
+ },
4480
+ S: function(dateObj) {
4481
+ return Math.round(dateObj.getMilliseconds() / 100);
4482
+ },
4483
+ SS: function(dateObj) {
4484
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
4485
+ },
4486
+ SSS: function(dateObj) {
4487
+ return pad(dateObj.getMilliseconds(), 3);
4488
+ },
4489
+ a: function(dateObj) {
4490
+ return dateObj.getHours() < 12 ? '上午' : '下午';
4491
+ },
4492
+ A: function(dateObj) {
4493
+ return dateObj.getHours() < 12 ? '上午' : '下午';
4494
+ },
4495
+ ZZ: function(dateObj) {
4496
+ const o = dateObj.getTimezoneOffset();
4497
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
4498
+ }
4499
+ };
4500
+
4501
+ const parseFlags = {
4502
+ d: [twoDigits, function (d, v) {
4503
+ d.day = v;
4504
+ }],
4505
+ Do: [twoDigits + word, function (d, v) {
4506
+ d.day = parseInt(v, 10);
4507
+ }],
4508
+ M: [twoDigits, function (d, v) {
4509
+ d.month = v - 1;
4510
+ }],
4511
+ yy: [twoDigits, function (d, v) {
4512
+ const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
4513
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
4514
+ }],
4515
+ h: [twoDigits, function (d, v) {
4516
+ d.hour = v;
4517
+ }],
4518
+ m: [twoDigits, function (d, v) {
4519
+ d.minute = v;
4520
+ }],
4521
+ s: [twoDigits, function (d, v) {
4522
+ d.second = v;
4523
+ }],
4524
+ yyyy: [fourDigits, function (d, v) {
4525
+ d.year = v;
4526
+ }],
4527
+ S: ['\\d', function (d, v) {
4528
+ d.millisecond = v * 100;
4529
+ }],
4530
+ SS: ['\\d{2}', function (d, v) {
4531
+ d.millisecond = v * 10;
4532
+ }],
4533
+ SSS: [threeDigits, function (d, v) {
4534
+ d.millisecond = v;
4535
+ }],
4536
+ D: [twoDigits, noop],
4537
+ ddd: [word, noop],
4538
+ MMM: [word, monthUpdate('monthNamesShort')],
4539
+ MMMM: [word, monthUpdate('monthNames')],
4540
+ a: [word, function (d, v) {
4541
+ const val = v.toLowerCase();
4542
+ if (val === '上午') {
4543
+ d.isPm = false;
4544
+ } else if (val === '下午') {
4545
+ d.isPm = true;
4546
+ }
4547
+ }],
4548
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
4549
+ let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
4550
+
4551
+ if (parts) {
4552
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
4553
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
4554
+ }
4555
+ }]
4556
+ };
4557
+ parseFlags.dd = parseFlags.d;
4558
+ parseFlags.dddd = parseFlags.ddd;
4559
+ parseFlags.DD = parseFlags.D;
4560
+ parseFlags.mm = parseFlags.m;
4561
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
4562
+ parseFlags.MM = parseFlags.M;
4563
+ parseFlags.ss = parseFlags.s;
4564
+ parseFlags.A = parseFlags.a;
4565
+
4566
+
4567
+ // Some common format strings
4568
+ fecha.masks = {
4569
+ default: 'ddd MMM dd yyyy HH:mm:ss',
4570
+ shortDate: 'M/D/yy',
4571
+ mediumDate: 'MMM d, yyyy',
4572
+ longDate: 'MMMM d, yyyy',
4573
+ fullDate: 'dddd, MMMM d, yyyy',
4574
+ shortTime: 'HH:mm',
4575
+ mediumTime: 'HH:mm:ss',
4576
+ longTime: 'HH:mm:ss.SSS'
4577
+ };
4578
+
4354
4579
  /***
4355
4580
  * Format a date
4356
4581
  * @method format
4357
4582
  * @param {Date|number} dateObj
4358
4583
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
4359
- */
4360
- fecha.format = function (dateObj, mask) {
4361
- if (typeof dateObj === 'number') {
4362
- dateObj = new Date(dateObj);
4363
- }
4364
-
4365
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
4366
- throw new Error('Invalid Date in fecha.format');
4367
- }
4368
-
4369
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
4370
-
4371
- var literals = [];
4372
-
4373
- // Make literals inactive by replacing them with ??
4374
- mask = mask.replace(literal, function ($0, $1) {
4375
- literals.push($1);
4376
- return '@@@';
4377
- });
4378
- // Apply formatting rules
4379
- mask = mask.replace(token, function ($0) {
4380
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
4381
- });
4382
- // Inline literal values back into the formatted value
4383
- return mask.replace(/@@@/g, function () {
4384
- return literals.shift();
4385
- });
4386
- };
4387
-
4584
+ */
4585
+ fecha.format = function (dateObj, mask) {
4586
+ if (typeof dateObj === 'number') {
4587
+ dateObj = new Date(dateObj);
4588
+ }
4589
+
4590
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
4591
+ throw new Error('Invalid Date in fecha.format');
4592
+ }
4593
+
4594
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
4595
+
4596
+ const literals = [];
4597
+
4598
+ // Make literals inactive by replacing them with ??
4599
+ mask = mask.replace(literal, function($0, $1) {
4600
+ literals.push($1);
4601
+ return '@@@';
4602
+ });
4603
+ // Apply formatting rules
4604
+ mask = mask.replace(token, function ($0) {
4605
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
4606
+ });
4607
+ // Inline literal values back into the formatted value
4608
+ return mask.replace(/@@@/g, function() {
4609
+ return literals.shift();
4610
+ });
4611
+ };
4612
+
4388
4613
  /**
4389
4614
  * Parse a date string into an object, changes - into /
4390
4615
  * @method parse
4391
4616
  * @param {string} dateStr Date string
4392
4617
  * @param {string} format Date parse format
4393
4618
  * @returns {Date|boolean}
4394
- */
4395
- fecha.parse = function (dateStr, format) {
4396
- if (typeof format !== 'string') {
4397
- throw new Error('Invalid format in fecha.parse');
4398
- }
4399
-
4400
- format = fecha.masks[format] || format;
4401
-
4402
- // Avoid regular expression denial of service, fail early for really long strings
4403
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
4404
- if (dateStr.length > 1000) {
4405
- return null;
4406
- }
4407
-
4408
- var dateInfo = {};
4409
- var parseInfo = [];
4410
- var literals = [];
4411
- format = format.replace(literal, function ($0, $1) {
4412
- literals.push($1);
4413
- return '@@@';
4414
- });
4415
- var newFormat = regexEscape(format).replace(token, function ($0) {
4416
- if (parseFlags[$0]) {
4417
- var info = parseFlags[$0];
4418
- parseInfo.push(info[1]);
4419
- return '(' + info[0] + ')';
4420
- }
4421
-
4422
- return $0;
4423
- });
4424
- newFormat = newFormat.replace(/@@@/g, function () {
4425
- return literals.shift();
4426
- });
4427
- var matches = dateStr.match(new RegExp(newFormat, 'i'));
4428
- if (!matches) {
4429
- return null;
4430
- }
4431
-
4432
- for (var i = 1; i < matches.length; i++) {
4433
- parseInfo[i - 1](dateInfo, matches[i]);
4434
- }
4435
-
4436
- var today = new Date();
4437
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
4438
- dateInfo.hour = +dateInfo.hour + 12;
4439
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
4440
- dateInfo.hour = 0;
4441
- }
4442
-
4443
- var date = void 0;
4444
- if (dateInfo.timezoneOffset != null) {
4445
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
4446
- 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));
4447
- } else {
4448
- 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);
4449
- }
4450
- return date;
4451
- };
4452
-
4453
- // 导出fecha对象
4454
-
4455
-
4456
- // 以下是从date-util.js合并的函数
4457
- var newArray = function newArray(start, end) {
4458
- var result = [];
4459
- for (var i = start; i <= end; i++) {
4460
- result.push(i);
4461
- }
4462
- return result;
4463
- };
4464
-
4465
- var getSettings = function getSettings() {
4466
- return {
4467
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
4468
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
4469
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
4470
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
4471
- amPm: ['上午', '下午']
4472
- };
4473
- };
4474
-
4475
- var toDate = function toDate(date) {
4476
- return isDate(date) ? new Date(date) : null;
4477
- };
4478
-
4479
- var isDate = function isDate(date) {
4480
- if (date === null || date === undefined) return false;
4481
- if (isNaN(new Date(date).getTime())) return false;
4482
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
4483
- return true;
4484
- };
4485
-
4486
- var isDateObject = function isDateObject(val) {
4487
- return val instanceof Date;
4488
- };
4489
-
4490
- var formatDate = function formatDate(date) {
4491
- var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
4492
-
4493
- // 处理多种输入类型
4494
- if (!date) return '';
4495
-
4496
- // 如果是时间戳,转成日期对象
4497
- if (typeof date === 'number') {
4498
- date = new Date(date);
4499
- }
4500
- // 如果是字符串,转成日期对象
4501
- if (typeof date === 'string') {
4502
- date = new Date(date);
4503
- }
4504
-
4505
- // 调用toDate进一步验证和转换
4506
- date = toDate(date);
4507
- if (!date) return '';
4508
-
4509
- // 兼容大写和小写的格式标记
4510
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
4511
- var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
4512
-
4513
- // 使用fecha库进行格式化,支持中文配置
4514
- var str = fecha.format(date, lowercaseFormat, getSettings());
4515
- return str;
4516
- };
4517
-
4518
- var parseDate = function parseDate(string, format) {
4519
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
4520
- };
4521
-
4522
- var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
4523
- if (month === 3 || month === 5 || month === 8 || month === 10) {
4524
- return 30;
4525
- }
4526
-
4527
- if (month === 1) {
4528
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
4529
- return 29;
4530
- } else {
4531
- return 28;
4532
- }
4533
- }
4534
-
4535
- return 31;
4536
- };
4537
-
4538
- var getDayCountOfYear = function getDayCountOfYear(year) {
4539
- var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
4540
- return isLeapYear ? 366 : 365;
4541
- };
4542
-
4543
- var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
4544
- var temp = new Date(date.getTime());
4545
- temp.setDate(1);
4546
- return temp.getDay();
4547
- };
4548
-
4549
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
4550
- // {prev, next} Date should work for Daylight Saving Time
4551
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
4552
- var prevDate = function prevDate(date) {
4553
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4554
-
4555
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
4556
- };
4557
-
4558
- var nextDate = function nextDate(date) {
4559
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4560
-
4561
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
4562
- };
4563
-
4564
- var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
4565
- var result = new Date(year, month, 1);
4566
- var day = result.getDay();
4567
-
4568
- if (day === 0) {
4569
- return prevDate(result, 7);
4570
- } else {
4571
- return prevDate(result, day);
4572
- }
4573
- };
4574
-
4575
- var getWeekNumber = function getWeekNumber(date) {
4576
- // 支持多种输入类型
4577
- if (!date || !isDate(date)) {
4578
- date = new Date();
4579
- }
4580
- if (typeof date === 'string') {
4581
- date = new Date(date);
4582
- }
4583
-
4584
- // 验证日期有效性
4585
- if (!isDate(date)) return null;
4586
-
4587
- var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
4588
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
4589
- // 将星期日的星期数设为7
4590
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
4591
- // 获取当年的第一天
4592
- var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
4593
- // 计算到最近的星期四的完整周数
4594
- var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
4595
- // 返回周数
4596
- return weekNo;
4597
- };
4598
-
4599
- var getRangeHours = function getRangeHours(ranges) {
4600
- var hours = [];
4601
- var disabledHours = [];
4602
-
4603
- (ranges || []).forEach(function (range) {
4604
- var value = range.map(function (date) {
4605
- return date.getHours();
4606
- });
4607
-
4608
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
4609
- });
4610
-
4611
- if (disabledHours.length) {
4612
- for (var i = 0; i < 24; i++) {
4613
- hours[i] = disabledHours.indexOf(i) === -1;
4614
- }
4615
- } else {
4616
- for (var _i = 0; _i < 24; _i++) {
4617
- hours[_i] = false;
4618
- }
4619
- }
4620
-
4621
- return hours;
4622
- };
4623
-
4624
- var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
4625
- if (amount <= 0) return [];
4626
- var temp = new Date(date.getTime());
4627
- temp.setDate(0);
4628
- var lastDay = temp.getDate();
4629
- return range(amount).map(function (_, index) {
4630
- return lastDay - (amount - index - 1);
4631
- });
4632
- };
4633
-
4634
- var getMonthDays = function getMonthDays(date) {
4635
- var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
4636
- var days = temp.getDate();
4637
- return range(days).map(function (_, index) {
4638
- return index + 1;
4639
- });
4640
- };
4641
-
4642
- function setRangeData(arr, start, end, value) {
4643
- for (var i = start; i < end; i++) {
4644
- arr[i] = value;
4645
- }
4646
- }
4647
-
4648
- var getRangeMinutes = function getRangeMinutes(ranges, hour) {
4649
- var minutes = new Array(60);
4650
-
4651
- if (ranges.length > 0) {
4652
- ranges.forEach(function (range) {
4653
- var start = range[0];
4654
- var end = range[1];
4655
- var startHour = start.getHours();
4656
- var startMinute = start.getMinutes();
4657
- var endHour = end.getHours();
4658
- var endMinute = end.getMinutes();
4659
- if (startHour === hour && endHour !== hour) {
4660
- setRangeData(minutes, startMinute, 60, true);
4661
- } else if (startHour === hour && endHour === hour) {
4662
- setRangeData(minutes, startMinute, endMinute + 1, true);
4663
- } else if (startHour !== hour && endHour === hour) {
4664
- setRangeData(minutes, 0, endMinute + 1, true);
4665
- } else if (startHour < hour && endHour > hour) {
4666
- setRangeData(minutes, 0, 60, true);
4667
- }
4668
- });
4669
- } else {
4670
- setRangeData(minutes, 0, 60, true);
4671
- }
4672
- return minutes;
4673
- };
4674
-
4675
- var range = function range(n) {
4676
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
4677
- return Array.apply(null, { length: n }).map(function (_, n) {
4678
- return n;
4679
- });
4680
- };
4681
-
4682
- var modifyDate = function modifyDate(date, y, m, d) {
4683
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
4684
- };
4685
-
4686
- var modifyTime = function modifyTime(date, h, m, s) {
4687
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
4688
- };
4689
-
4690
- var modifyWithTimeString = function modifyWithTimeString(date, time) {
4691
- if (date == null || !time) {
4692
- return date;
4693
- }
4694
- time = parseDate(time, 'HH:mm:ss');
4695
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
4696
- };
4697
-
4698
- var clearTime = function clearTime(date) {
4699
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
4700
- };
4701
-
4702
- var clearMilliseconds = function clearMilliseconds(date) {
4703
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
4704
- };
4705
-
4706
- var limitTimeRange = function limitTimeRange(date, ranges) {
4707
- var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
4708
-
4709
- // TODO: refactory a more elegant solution
4710
- if (ranges.length === 0) return date;
4711
- var normalizeDate = function normalizeDate(date) {
4712
- return fecha.parse(fecha.format(date, format), format);
4713
- };
4714
- var ndate = normalizeDate(date);
4715
- var nranges = ranges.map(function (range) {
4716
- return range.map(normalizeDate);
4717
- });
4718
- if (nranges.some(function (nrange) {
4719
- return ndate >= nrange[0] && ndate <= nrange[1];
4720
- })) return date;
4721
-
4722
- var minDate = nranges[0][0];
4723
- var maxDate = nranges[0][0];
4724
-
4725
- nranges.forEach(function (nrange) {
4726
- minDate = new Date(Math.min(nrange[0], minDate));
4727
- maxDate = new Date(Math.max(nrange[1], minDate));
4728
- });
4729
-
4730
- var ret = ndate < minDate ? minDate : maxDate;
4731
- // preserve Year/Month/Date
4732
- return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
4733
- };
4734
-
4735
- var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
4736
- var limitedDate = limitTimeRange(date, selectableRange, format);
4737
- return limitedDate.getTime() === date.getTime();
4738
- };
4739
-
4740
- var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
4741
- // clamp date to the number of days in `year`, `month`
4742
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
4743
- var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
4744
- return modifyDate(date, year, month, monthDate);
4745
- };
4746
-
4747
- var prevMonth = function prevMonth(date) {
4748
- var year = date.getFullYear();
4749
- var month = date.getMonth();
4750
- return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
4751
- };
4752
-
4753
- var nextMonth = function nextMonth(date) {
4754
- var year = date.getFullYear();
4755
- var month = date.getMonth();
4756
- return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
4757
- };
4758
-
4759
- var prevYear = function prevYear(date) {
4760
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4761
-
4762
- var year = date.getFullYear();
4763
- var month = date.getMonth();
4764
- return changeYearMonthAndClampDate(date, year - amount, month);
4765
- };
4766
-
4767
- var nextYear = function nextYear(date) {
4768
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4769
-
4770
- var year = date.getFullYear();
4771
- var month = date.getMonth();
4772
- return changeYearMonthAndClampDate(date, year + amount, month);
4773
- };
4774
-
4775
- var extractDateFormat = function extractDateFormat(format) {
4776
- return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
4777
- };
4778
-
4779
- var extractTimeFormat = function extractTimeFormat(format) {
4780
- return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
4781
- };
4782
-
4783
- var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
4784
- return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
4785
- };
4786
-
4619
+ */
4620
+ fecha.parse = function (dateStr, format) {
4621
+ if (typeof format !== 'string') {
4622
+ throw new Error('Invalid format in fecha.parse');
4623
+ }
4624
+
4625
+ format = fecha.masks[format] || format;
4626
+
4627
+ // Avoid regular expression denial of service, fail early for really long strings
4628
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
4629
+ if (dateStr.length > 1000) {
4630
+ return null;
4631
+ }
4632
+
4633
+ const dateInfo = {};
4634
+ const parseInfo = [];
4635
+ const literals = [];
4636
+ format = format.replace(literal, function($0, $1) {
4637
+ literals.push($1);
4638
+ return '@@@';
4639
+ });
4640
+ let newFormat = regexEscape(format).replace(token, function ($0) {
4641
+ if (parseFlags[$0]) {
4642
+ const info = parseFlags[$0];
4643
+ parseInfo.push(info[1]);
4644
+ return '(' + info[0] + ')';
4645
+ }
4646
+
4647
+ return $0;
4648
+ });
4649
+ newFormat = newFormat.replace(/@@@/g, function() {
4650
+ return literals.shift();
4651
+ });
4652
+ const matches = dateStr.match(new RegExp(newFormat, 'i'));
4653
+ if (!matches) {
4654
+ return null;
4655
+ }
4656
+
4657
+ for (let i = 1; i < matches.length; i++) {
4658
+ parseInfo[i - 1](dateInfo, matches[i]);
4659
+ }
4660
+
4661
+ const today = new Date();
4662
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
4663
+ dateInfo.hour = +dateInfo.hour + 12;
4664
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
4665
+ dateInfo.hour = 0;
4666
+ }
4667
+
4668
+ let date;
4669
+ if (dateInfo.timezoneOffset != null) {
4670
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
4671
+ date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
4672
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
4673
+ } else {
4674
+ date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
4675
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
4676
+ }
4677
+ return date;
4678
+ };
4679
+
4680
+ // 导出fecha对象
4681
+
4682
+
4683
+ // 以下是从date-util.js合并的函数
4684
+ const newArray = function(start, end) {
4685
+ let result = [];
4686
+ for (let i = start; i <= end; i++) {
4687
+ result.push(i);
4688
+ }
4689
+ return result;
4690
+ };
4691
+
4692
+ const getSettings = () => {
4693
+ return {
4694
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
4695
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
4696
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
4697
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
4698
+ amPm: ['上午', '下午']
4699
+ };
4700
+ };
4701
+
4702
+ const toDate = function(date) {
4703
+ return isDate(date) ? new Date(date) : null;
4704
+ };
4705
+
4706
+ const isDate = function(date) {
4707
+ if (date === null || date === undefined) return false;
4708
+ if (isNaN(new Date(date).getTime())) return false;
4709
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
4710
+ return true;
4711
+ };
4712
+
4713
+ const isDateObject = function(val) {
4714
+ return val instanceof Date;
4715
+ };
4716
+
4717
+ const formatDate = function (date, format = 'yyyy-MM-dd') {
4718
+ // 处理多种输入类型
4719
+ if (!date) return '';
4720
+
4721
+ // 如果是时间戳,转成日期对象
4722
+ if (typeof date === 'number') {
4723
+ date = new Date(date);
4724
+ }
4725
+ // 如果是字符串,转成日期对象
4726
+ if (typeof date === 'string') {
4727
+ date = new Date(date);
4728
+ }
4729
+
4730
+ // 调用toDate进一步验证和转换
4731
+ date = toDate(date);
4732
+ if (!date) return '';
4733
+
4734
+ // 兼容大写和小写的格式标记
4735
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
4736
+ const lowercaseFormat = format
4737
+ .replace(/YYYY/g, 'yyyy')
4738
+ .replace(/D/g, 'd')
4739
+
4740
+ // 使用fecha库进行格式化,支持中文配置
4741
+ const str = fecha.format(date, lowercaseFormat, getSettings());
4742
+ return str;
4743
+ };
4744
+
4745
+ const parseDate = function(string, format) {
4746
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
4747
+ };
4748
+
4749
+ const getDayCountOfMonth = function(year, month) {
4750
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
4751
+ return 30;
4752
+ }
4753
+
4754
+ if (month === 1) {
4755
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
4756
+ return 29;
4757
+ } else {
4758
+ return 28;
4759
+ }
4760
+ }
4761
+
4762
+ return 31;
4763
+ };
4764
+
4765
+ const getDayCountOfYear = function(year) {
4766
+ const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
4767
+ return isLeapYear ? 366 : 365;
4768
+ };
4769
+
4770
+ const getFirstDayOfMonth = function(date) {
4771
+ const temp = new Date(date.getTime());
4772
+ temp.setDate(1);
4773
+ return temp.getDay();
4774
+ };
4775
+
4776
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
4777
+ // {prev, next} Date should work for Daylight Saving Time
4778
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
4779
+ const prevDate = function(date, amount = 1) {
4780
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
4781
+ };
4782
+
4783
+ const nextDate = function(date, amount = 1) {
4784
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
4785
+ };
4786
+
4787
+ const getStartDateOfMonth = function(year, month) {
4788
+ const result = new Date(year, month, 1);
4789
+ const day = result.getDay();
4790
+
4791
+ if (day === 0) {
4792
+ return prevDate(result, 7);
4793
+ } else {
4794
+ return prevDate(result, day);
4795
+ }
4796
+ };
4797
+
4798
+ const getWeekNumber = function(date) {
4799
+ // 支持多种输入类型
4800
+ if (!date||!isDate(date)) {
4801
+ date = new Date();
4802
+ }
4803
+ if (typeof date === 'string') {
4804
+ date = new Date(date);
4805
+ }
4806
+
4807
+ // 验证日期有效性
4808
+ if (!isDate(date)) return null;
4809
+
4810
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
4811
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
4812
+ // 将星期日的星期数设为7
4813
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
4814
+ // 获取当年的第一天
4815
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
4816
+ // 计算到最近的星期四的完整周数
4817
+ const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
4818
+ // 返回周数
4819
+ return weekNo;
4820
+ };
4821
+
4822
+ const getRangeHours = function(ranges) {
4823
+ const hours = [];
4824
+ let disabledHours = [];
4825
+
4826
+ (ranges || []).forEach(range => {
4827
+ const value = range.map(date => date.getHours());
4828
+
4829
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
4830
+ });
4831
+
4832
+ if (disabledHours.length) {
4833
+ for (let i = 0; i < 24; i++) {
4834
+ hours[i] = disabledHours.indexOf(i) === -1;
4835
+ }
4836
+ } else {
4837
+ for (let i = 0; i < 24; i++) {
4838
+ hours[i] = false;
4839
+ }
4840
+ }
4841
+
4842
+ return hours;
4843
+ };
4844
+
4845
+ const getPrevMonthLastDays = (date, amount) => {
4846
+ if (amount <= 0) return [];
4847
+ const temp = new Date(date.getTime());
4848
+ temp.setDate(0);
4849
+ const lastDay = temp.getDate();
4850
+ return range(amount).map((_, index) => lastDay - (amount - index - 1));
4851
+ };
4852
+
4853
+ const getMonthDays = (date) => {
4854
+ const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
4855
+ const days = temp.getDate();
4856
+ return range(days).map((_, index) => index + 1);
4857
+ };
4858
+
4859
+ function setRangeData(arr, start, end, value) {
4860
+ for (let i = start; i < end; i++) {
4861
+ arr[i] = value;
4862
+ }
4863
+ }
4864
+
4865
+ const getRangeMinutes = function(ranges, hour) {
4866
+ const minutes = new Array(60);
4867
+
4868
+ if (ranges.length > 0) {
4869
+ ranges.forEach(range => {
4870
+ const start = range[0];
4871
+ const end = range[1];
4872
+ const startHour = start.getHours();
4873
+ const startMinute = start.getMinutes();
4874
+ const endHour = end.getHours();
4875
+ const endMinute = end.getMinutes();
4876
+ if (startHour === hour && endHour !== hour) {
4877
+ setRangeData(minutes, startMinute, 60, true);
4878
+ } else if (startHour === hour && endHour === hour) {
4879
+ setRangeData(minutes, startMinute, endMinute + 1, true);
4880
+ } else if (startHour !== hour && endHour === hour) {
4881
+ setRangeData(minutes, 0, endMinute + 1, true);
4882
+ } else if (startHour < hour && endHour > hour) {
4883
+ setRangeData(minutes, 0, 60, true);
4884
+ }
4885
+ });
4886
+ } else {
4887
+ setRangeData(minutes, 0, 60, true);
4888
+ }
4889
+ return minutes;
4890
+ };
4891
+
4892
+ const range = function(n) {
4893
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
4894
+ return Array.apply(null, {length: n}).map((_, n) => n);
4895
+ };
4896
+
4897
+ const modifyDate = function(date, y, m, d) {
4898
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
4899
+ };
4900
+
4901
+ const modifyTime = function(date, h, m, s) {
4902
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
4903
+ };
4904
+
4905
+ const modifyWithTimeString = (date, time) => {
4906
+ if (date == null || !time) {
4907
+ return date;
4908
+ }
4909
+ time = parseDate(time, 'HH:mm:ss');
4910
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
4911
+ };
4912
+
4913
+ const clearTime = function(date) {
4914
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
4915
+ };
4916
+
4917
+ const clearMilliseconds = function(date) {
4918
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
4919
+ };
4920
+
4921
+ const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
4922
+ // TODO: refactory a more elegant solution
4923
+ if (ranges.length === 0) return date;
4924
+ const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
4925
+ const ndate = normalizeDate(date);
4926
+ const nranges = ranges.map(range => range.map(normalizeDate));
4927
+ if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
4928
+
4929
+ let minDate = nranges[0][0];
4930
+ let maxDate = nranges[0][0];
4931
+
4932
+ nranges.forEach(nrange => {
4933
+ minDate = new Date(Math.min(nrange[0], minDate));
4934
+ maxDate = new Date(Math.max(nrange[1], minDate));
4935
+ });
4936
+
4937
+ const ret = ndate < minDate ? minDate : maxDate;
4938
+ // preserve Year/Month/Date
4939
+ return modifyDate(
4940
+ ret,
4941
+ date.getFullYear(),
4942
+ date.getMonth(),
4943
+ date.getDate()
4944
+ );
4945
+ };
4946
+
4947
+ const timeWithinRange = function(date, selectableRange, format) {
4948
+ const limitedDate = limitTimeRange(date, selectableRange, format);
4949
+ return limitedDate.getTime() === date.getTime();
4950
+ };
4951
+
4952
+ const changeYearMonthAndClampDate = function(date, year, month) {
4953
+ // clamp date to the number of days in `year`, `month`
4954
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
4955
+ const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
4956
+ return modifyDate(date, year, month, monthDate);
4957
+ };
4958
+
4959
+ const prevMonth = function(date) {
4960
+ const year = date.getFullYear();
4961
+ const month = date.getMonth();
4962
+ return month === 0
4963
+ ? changeYearMonthAndClampDate(date, year - 1, 11)
4964
+ : changeYearMonthAndClampDate(date, year, month - 1);
4965
+ };
4966
+
4967
+ const nextMonth = function(date) {
4968
+ const year = date.getFullYear();
4969
+ const month = date.getMonth();
4970
+ return month === 11
4971
+ ? changeYearMonthAndClampDate(date, year + 1, 0)
4972
+ : changeYearMonthAndClampDate(date, year, month + 1);
4973
+ };
4974
+
4975
+ const prevYear = function(date, amount = 1) {
4976
+ const year = date.getFullYear();
4977
+ const month = date.getMonth();
4978
+ return changeYearMonthAndClampDate(date, year - amount, month);
4979
+ };
4980
+
4981
+ const nextYear = function(date, amount = 1) {
4982
+ const year = date.getFullYear();
4983
+ const month = date.getMonth();
4984
+ return changeYearMonthAndClampDate(date, year + amount, month);
4985
+ };
4986
+
4987
+ const extractDateFormat = function(format) {
4988
+ return format
4989
+ .replace(/\W?m{1,2}|\W?ZZ/g, '')
4990
+ .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
4991
+ .trim();
4992
+ };
4993
+
4994
+ const extractTimeFormat = function(format) {
4995
+ return format
4996
+ .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
4997
+ .trim();
4998
+ };
4999
+
5000
+ const validateRangeInOneMonth = function(start, end) {
5001
+ return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
5002
+ };
5003
+
4787
5004
  /**
4788
5005
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
4789
5006
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
4790
5007
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
4791
5008
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
4792
5009
  * @returns {number} 工作日数量
4793
- */
4794
- var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
4795
- var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
4796
-
4797
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
4798
- throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
4799
- }
4800
-
4801
- var startDateObj = new Date(start_date);
4802
- var endDateObj = new Date(end_date);
4803
-
4804
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
4805
- throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
4806
- }
4807
-
4808
- if (startDateObj > endDateObj) {
4809
- throw new Error('Start date should be earlier than or equal to end date.');
4810
- }
4811
-
4812
- var workdays = 0;
4813
-
4814
- // Iterate through each day in the date range
4815
-
4816
- var _loop = function _loop(currentDate) {
4817
- // Check if the current day is a weekend (Saturday or Sunday)
4818
- var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
4819
-
4820
- // Check if the current day is a holiday
4821
- var isHoliday = holidays.some(function (holiday) {
4822
- var holidayDate = new Date(holiday);
4823
- return currentDate.toDateString() === holidayDate.toDateString();
4824
- });
4825
-
4826
- // If it's a workday (not a weekend or holiday), increment the workdays count
4827
- if (!isWeekend && !isHoliday) {
4828
- workdays++;
4829
- }
4830
- };
4831
-
4832
- for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
4833
- _loop(currentDate);
4834
- }
4835
-
4836
- return workdays;
4837
- };
4838
-
5010
+ */
5011
+ const calculateNetworkDays = function (start_date, end_date, holidays = []) {
5012
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5013
+ throw new Error(
5014
+ "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
5015
+ );
5016
+ }
5017
+
5018
+ const startDateObj = new Date(start_date);
5019
+ const endDateObj = new Date(end_date);
5020
+
5021
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5022
+ throw new Error(
5023
+ "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
5024
+ );
5025
+ }
5026
+
5027
+ if (startDateObj > endDateObj) {
5028
+ throw new Error('Start date should be earlier than or equal to end date.');
5029
+ }
5030
+
5031
+ let workdays = 0;
5032
+
5033
+ // Iterate through each day in the date range
5034
+ for (
5035
+ let currentDate = new Date(startDateObj);
5036
+ currentDate <= endDateObj;
5037
+ currentDate.setDate(currentDate.getDate() + 1)
5038
+ ) {
5039
+ // Check if the current day is a weekend (Saturday or Sunday)
5040
+ const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
5041
+
5042
+ // Check if the current day is a holiday
5043
+ const isHoliday = holidays.some((holiday) => {
5044
+ const holidayDate = new Date(holiday);
5045
+ return currentDate.toDateString() === holidayDate.toDateString();
5046
+ });
5047
+
5048
+ // If it's a workday (not a weekend or holiday), increment the workdays count
5049
+ if (!isWeekend && !isHoliday) {
5050
+ workdays++;
5051
+ }
5052
+ }
5053
+
5054
+ return workdays;
5055
+ };
5056
+
4839
5057
  /**
4840
5058
  * 日期加减天数
4841
5059
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
4842
5060
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
4843
5061
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
4844
- */
4845
- var dateAddDays = function dateAddDays(start_date, days) {
4846
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
4847
- 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.");
4848
- }
4849
-
4850
- var startDateObj = new Date(start_date);
4851
- if (isNaN(startDateObj.getTime())) {
4852
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
4853
- }
4854
-
4855
- var resultDateObj = new Date(startDateObj);
4856
- resultDateObj.setDate(resultDateObj.getDate() + days);
4857
-
4858
- var resultYear = resultDateObj.getFullYear();
4859
- var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
4860
- var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
4861
-
4862
- return resultYear + '-' + resultMonth + '-' + resultDay;
4863
- };
4864
-
5062
+ */
5063
+ const dateAddDays = function (start_date, days) {
5064
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
5065
+ throw new Error(
5066
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
5067
+ );
5068
+ }
5069
+
5070
+ const startDateObj = new Date(start_date);
5071
+ if (isNaN(startDateObj.getTime())) {
5072
+ throw new Error(
5073
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
5074
+ );
5075
+ }
5076
+
5077
+ const resultDateObj = new Date(startDateObj);
5078
+ resultDateObj.setDate(resultDateObj.getDate() + days);
5079
+
5080
+ const resultYear = resultDateObj.getFullYear();
5081
+ const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
5082
+ const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
5083
+
5084
+ return `${resultYear}-${resultMonth}-${resultDay}`;
5085
+ };
5086
+
4865
5087
  /**
4866
5088
  * 计算两个日期之间的差值
4867
5089
  * @date 2023年12月14日
@@ -4869,185 +5091,187 @@ var dateAddDays = function dateAddDays(start_date, days) {
4869
5091
  * @param {String} end_date - 结束日期字符串
4870
5092
  * @param {String} unit - 单位:year/month/day
4871
5093
  * @returns {Number} 差值
4872
- */
4873
- var dateDiff = function dateDiff(start_date, end_date) {
4874
- var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
4875
-
4876
- // Assuming date strings are in "YYYY-MM-DD" format
4877
- var startDate = new Date(start_date);
4878
- var endDate = new Date(end_date);
4879
-
4880
- // If the date is invalid, return 0
4881
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
4882
- return 0;
4883
- }
4884
-
4885
- if (unit === 'year') {
4886
- return endDate.getFullYear() - startDate.getFullYear();
4887
- } else if (unit === 'month') {
4888
- return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
4889
- } else {
4890
- // Default to day
4891
- var timeDifference = endDate - startDate;
4892
- // Calculate days (86400000 milliseconds per day)
4893
- return Math.floor(timeDifference / 86400000);
4894
- }
4895
- };
4896
-
5094
+ */
5095
+ const dateDiff = function (start_date, end_date, unit = 'day') {
5096
+ // Assuming date strings are in "YYYY-MM-DD" format
5097
+ var startDate = new Date(start_date);
5098
+ var endDate = new Date(end_date);
5099
+
5100
+ // If the date is invalid, return 0
5101
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
5102
+ return 0;
5103
+ }
5104
+
5105
+ if (unit === 'year') {
5106
+ return endDate.getFullYear() - startDate.getFullYear();
5107
+ } else if (unit === 'month') {
5108
+ return (
5109
+ (endDate.getFullYear() - startDate.getFullYear()) * 12 +
5110
+ (endDate.getMonth() - startDate.getMonth())
5111
+ );
5112
+ } else {
5113
+ // Default to day
5114
+ var timeDifference = endDate - startDate;
5115
+ // Calculate days (86400000 milliseconds per day)
5116
+ return Math.floor(timeDifference / 86400000);
5117
+ }
5118
+ };
5119
+
4897
5120
  /**
4898
5121
  * 获取月份中的日期
4899
5122
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
4900
5123
  * @returns {number} 月份中的日期(1-31)
4901
- */
4902
- var dayOfMonth = function dayOfMonth(date) {
4903
- if (typeof date !== 'string') {
4904
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
4905
- }
4906
-
4907
- var dateObj = new Date(date);
4908
- if (isNaN(dateObj.getTime())) {
4909
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
4910
- }
4911
-
4912
- return dateObj.getDate();
4913
- };
4914
-
5124
+ */
5125
+ const dayOfMonth = function (date) {
5126
+ if (typeof date !== 'string') {
5127
+ throw new Error(
5128
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
5129
+ );
5130
+ }
5131
+
5132
+ const dateObj = new Date(date);
5133
+ if (isNaN(dateObj.getTime())) {
5134
+ throw new Error(
5135
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
5136
+ );
5137
+ }
5138
+
5139
+ return dateObj.getDate();
5140
+ };
5141
+
4915
5142
  /**
4916
5143
  * 获取当前日期
4917
5144
  * @date 2022年5月7日
4918
5145
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
4919
5146
  * @returns {string} 当前日期的格式化字符串
4920
- */
4921
- var getCurrentDate = function getCurrentDate() {
4922
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
4923
-
4924
- return formatDate(new Date(), format);
4925
- };
4926
-
5147
+ */
5148
+ const getCurrentDate = function (format = 'YYYY-MM-DD') {
5149
+ return formatDate(new Date(), format);
5150
+ };
5151
+
4927
5152
  /**
4928
5153
  * 获取当前日期时间
4929
5154
  * @date 2022年5月7日
4930
5155
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
4931
5156
  * @returns {string} 当前日期时间的格式化字符串
4932
- */
4933
- var getCurrentDateTime = function getCurrentDateTime() {
4934
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
4935
-
4936
- return formatDate(new Date(), format);
4937
- };
4938
-
5157
+ */
5158
+ const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
5159
+ return formatDate(new Date(), format);
5160
+ };
5161
+
4939
5162
  /**
4940
5163
  * 获取小时
4941
5164
  * @date 2022年5月7日
4942
5165
  * @param {Date|string} [date] - 日期对象或日期字符串
4943
5166
  * @returns {number} 小时数(0-23)
4944
- */
4945
- var getHour = function getHour(date) {
4946
- if (!date) {
4947
- return new Date().getHours();
4948
- }
4949
- if (typeof date === 'string') {
4950
- date = new Date(date);
4951
- }
4952
- return date.getHours();
4953
- };
4954
-
5167
+ */
5168
+ const getHour = function (date) {
5169
+ if (!date) {
5170
+ return new Date().getHours();
5171
+ }
5172
+ if (typeof date === 'string') {
5173
+ date = new Date(date);
5174
+ }
5175
+ return date.getHours();
5176
+ };
5177
+
4955
5178
  /**
4956
5179
  * 获取分钟
4957
5180
  * @date 2022年5月7日
4958
5181
  * @param {Date|string} [date] - 日期对象或日期字符串
4959
5182
  * @returns {number} 分钟数(0-59)
4960
- */
4961
- var getMinute = function getMinute(date) {
4962
- if (!date) {
4963
- return new Date().getMinutes();
4964
- }
4965
- if (typeof date === 'string') {
4966
- date = new Date(date);
4967
- }
4968
- return date.getMinutes();
4969
- };
4970
-
5183
+ */
5184
+ const getMinute = function (date) {
5185
+ if (!date) {
5186
+ return new Date().getMinutes();
5187
+ }
5188
+ if (typeof date === 'string') {
5189
+ date = new Date(date);
5190
+ }
5191
+ return date.getMinutes();
5192
+ };
5193
+
4971
5194
  /**
4972
5195
  * 获取月份
4973
5196
  * @date 2022年5月7日
4974
5197
  * @param {Date|string} [date] - 日期对象或日期字符串
4975
5198
  * @returns {number} 月份数(1-12)
4976
- */
4977
- var getMonth = function getMonth(date) {
4978
- if (!date) {
4979
- return new Date().getMonth() + 1;
4980
- }
4981
- if (typeof date === 'string') {
4982
- date = new Date(date);
4983
- }
4984
- return date.getMonth() + 1;
4985
- };
4986
-
5199
+ */
5200
+ const getMonth = function (date) {
5201
+ if (!date) {
5202
+ return new Date().getMonth() + 1;
5203
+ }
5204
+ if (typeof date === 'string') {
5205
+ date = new Date(date);
5206
+ }
5207
+ return date.getMonth() + 1;
5208
+ };
5209
+
4987
5210
  /**
4988
5211
  * 获取秒
4989
5212
  * @date 2022年5月7日
4990
5213
  * @param {Date|string} [date] - 日期对象或日期字符串
4991
5214
  * @returns {number} 秒数(0-59)
4992
- */
4993
- var getSecond = function getSecond(date) {
4994
- if (!date) {
4995
- return new Date().getSeconds();
4996
- }
4997
- if (typeof date === 'string') {
4998
- date = new Date(date);
4999
- }
5000
- return date.getSeconds();
5001
- };
5002
-
5215
+ */
5216
+ const getSecond = function (date) {
5217
+ if (!date) {
5218
+ return new Date().getSeconds();
5219
+ }
5220
+ if (typeof date === 'string') {
5221
+ date = new Date(date);
5222
+ }
5223
+ return date.getSeconds();
5224
+ };
5225
+
5003
5226
  /**
5004
5227
  * 获取星期几
5005
5228
  * @date 2022年5月7日
5006
5229
  * @param {Date|string} [date] - 日期对象或日期字符串
5007
5230
  * @returns {number} 星期几(0-6,0表示星期日)
5008
- */
5009
- var getWeekday = function getWeekday(date) {
5010
- if (!date) {
5011
- return new Date().getDay();
5012
- }
5013
- if (typeof date === 'string') {
5014
- date = new Date(date);
5015
- }
5016
- return date.getDay();
5017
- };
5018
-
5231
+ */
5232
+ const getWeekday = function (date) {
5233
+ if (!date) {
5234
+ return new Date().getDay();
5235
+ }
5236
+ if (typeof date === 'string') {
5237
+ date = new Date(date);
5238
+ }
5239
+ return date.getDay();
5240
+ };
5241
+
5242
+
5019
5243
  /**
5020
5244
  * @desc 获取上午/下午/晚上
5021
5245
  * @author huangbo
5022
5246
  * @date 2022年5月7日
5023
5247
  * @param {String} [time] - 时间
5024
- **/
5025
- var timeCycle = function timeCycle(time) {
5026
- var hour = 0;
5027
- if (!time) {
5028
- hour = new Date().getHours();
5029
- } else if (typeof time === 'string') {
5030
- // 从时间字符串中提取小时
5031
- var match = time.match(/^(\d{1,2})/);
5032
- if (match) {
5033
- hour = parseInt(match[1], 10);
5034
- }
5035
- } else if (typeof time === 'number') {
5036
- hour = time;
5037
- }
5038
- // 判断时间段
5039
- if (hour >= 5 && hour < 12) {
5040
- return '上午';
5041
- } else if (hour >= 12 && hour < 18) {
5042
- return '下午';
5043
- } else {
5044
- return '晚上';
5045
- }
5248
+ **/
5249
+ const timeCycle = function (time) {
5250
+ let hour = 0;
5251
+ if (!time) {
5252
+ hour = new Date().getHours();
5253
+ } else if (typeof time === 'string') {
5254
+ // 从时间字符串中提取小时
5255
+ const match = time.match(/^(\d{1,2})/);
5256
+ if (match) {
5257
+ hour = parseInt(match[1], 10);
5258
+ }
5259
+ } else if (typeof time === 'number') {
5260
+ hour = time;
5261
+ }
5262
+ // 判断时间段
5263
+ if (hour >= 5 && hour < 12) {
5264
+ return '上午';
5265
+ } else if (hour >= 12 && hour < 18) {
5266
+ return '下午';
5267
+ } else {
5268
+ return '晚上';
5269
+ }
5046
5270
  };
5047
5271
 
5048
5272
  /***/ }),
5049
5273
 
5050
- /***/ 95:
5274
+ /***/ 96:
5051
5275
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
5052
5276
 
5053
5277
  "use strict";
@@ -5150,7 +5374,7 @@ render._withStripped = true
5150
5374
  var utils_date = __webpack_require__(7);
5151
5375
 
5152
5376
  // EXTERNAL MODULE: ./packages/date-picker/src/basic/time-spinner.vue + 4 modules
5153
- var time_spinner = __webpack_require__(113);
5377
+ var time_spinner = __webpack_require__(115);
5154
5378
 
5155
5379
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/date-picker/src/panel/time.vue?vue&type=script&lang=js&
5156
5380
  //
@@ -5376,7 +5600,7 @@ var component = Object(componentNormalizer["a" /* default */])(
5376
5600
 
5377
5601
  /***/ }),
5378
5602
 
5379
- /***/ 96:
5603
+ /***/ 97:
5380
5604
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
5381
5605
 
5382
5606
  "use strict";
@@ -5410,7 +5634,7 @@ var component = Object(componentNormalizer["a" /* default */])(
5410
5634
 
5411
5635
  /***/ }),
5412
5636
 
5413
- /***/ 98:
5637
+ /***/ 99:
5414
5638
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
5415
5639
 
5416
5640
  "use strict";
@@ -5602,7 +5826,7 @@ var external_vue_ = __webpack_require__(2);
5602
5826
  var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
5603
5827
 
5604
5828
  // EXTERNAL MODULE: ./src/utils/clickoutside.js
5605
- var clickoutside = __webpack_require__(42);
5829
+ var clickoutside = __webpack_require__(43);
5606
5830
 
5607
5831
  // EXTERNAL MODULE: ./src/utils/date.js
5608
5832
  var utils_date = __webpack_require__(7);
@@ -5618,7 +5842,7 @@ var input_ = __webpack_require__(14);
5618
5842
  var input_default = /*#__PURE__*/__webpack_require__.n(input_);
5619
5843
 
5620
5844
  // EXTERNAL MODULE: ./src/utils/merge.js
5621
- var merge = __webpack_require__(21);
5845
+ var merge = __webpack_require__(22);
5622
5846
 
5623
5847
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/date-picker/src/picker.vue?vue&type=script&lang=js&
5624
5848
  //