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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/lib/0.js +1 -1
  2. package/lib/1.js +1 -1
  3. package/lib/10.js +1 -1
  4. package/lib/11.js +1 -1
  5. package/lib/12.js +1 -1
  6. package/lib/13.js +1 -1
  7. package/lib/14.js +1 -1
  8. package/lib/15.js +1 -1
  9. package/lib/16.js +1 -1
  10. package/lib/17.js +1 -1
  11. package/lib/18.js +1 -1
  12. package/lib/19.js +1 -1
  13. package/lib/20.js +1 -1
  14. package/lib/21.js +1 -1
  15. package/lib/22.js +1 -1
  16. package/lib/23.js +1 -1
  17. package/lib/24.js +1 -1
  18. package/lib/25.js +1 -1
  19. package/lib/26.js +1 -1
  20. package/lib/27.js +1 -1
  21. package/lib/28.js +1 -1
  22. package/lib/29.js +1 -1
  23. package/lib/3.js +1 -1
  24. package/lib/30.js +1 -1
  25. package/lib/31.js +1 -1
  26. package/lib/32.js +1 -1
  27. package/lib/33.js +1 -1
  28. package/lib/34.js +1 -1
  29. package/lib/35.js +1 -1
  30. package/lib/36.js +1 -1
  31. package/lib/37.js +1 -1
  32. package/lib/38.js +1 -1
  33. package/lib/39.js +1 -1
  34. package/lib/4.js +1 -1
  35. package/lib/40.js +1 -1
  36. package/lib/41.js +1 -1
  37. package/lib/42.js +1 -1
  38. package/lib/43.js +1 -1
  39. package/lib/44.js +1 -1
  40. package/lib/45.js +1 -1
  41. package/lib/46.js +1 -1
  42. package/lib/47.js +1 -1
  43. package/lib/48.js +1 -1
  44. package/lib/49.js +1 -1
  45. package/lib/5.js +1 -1
  46. package/lib/50.js +1 -1
  47. package/lib/51.js +1 -1
  48. package/lib/52.js +1 -1
  49. package/lib/53.js +1 -1
  50. package/lib/54.js +1 -1
  51. package/lib/55.js +1 -1
  52. package/lib/56.js +1 -1
  53. package/lib/57.js +1 -1
  54. package/lib/58.js +1 -1
  55. package/lib/59.js +1 -1
  56. package/lib/6.js +1 -1
  57. package/lib/60.js +1 -1
  58. package/lib/61.js +1 -1
  59. package/lib/62.js +1 -1
  60. package/lib/63.js +1 -1
  61. package/lib/64.js +1 -1
  62. package/lib/65.js +1 -1
  63. package/lib/66.js +1 -1
  64. package/lib/67.js +1 -1
  65. package/lib/68.js +1 -1
  66. package/lib/69.js +1 -1
  67. package/lib/7.js +1 -1
  68. package/lib/70.js +1 -1
  69. package/lib/71.js +1 -1
  70. package/lib/72.js +1 -1
  71. package/lib/73.js +1 -1
  72. package/lib/74.js +1 -1
  73. package/lib/75.js +1 -1
  74. package/lib/76.js +1 -1
  75. package/lib/77.js +1 -1
  76. package/lib/78.js +1 -1
  77. package/lib/79.js +1 -1
  78. package/lib/8.js +1 -1
  79. package/lib/80.js +1 -1
  80. package/lib/81.js +1 -1
  81. package/lib/9.js +1 -1
  82. package/lib/account-login.js +837 -862
  83. package/lib/alert.js +2 -2
  84. package/lib/aside.js +2 -2
  85. package/lib/audit-trajectory.js +4 -4
  86. package/lib/autocomplete.js +1813 -1988
  87. package/lib/avatar.js +2 -2
  88. package/lib/backtop.js +2 -2
  89. package/lib/badge.js +2 -2
  90. package/lib/breadcrumb-item.js +4 -4
  91. package/lib/breadcrumb.js +4 -4
  92. package/lib/button-group.js +4 -4
  93. package/lib/button.js +2 -2
  94. package/lib/ca-login.js +837 -862
  95. package/lib/calendar.js +839 -864
  96. package/lib/card.js +2 -2
  97. package/lib/carousel-item.js +846 -871
  98. package/lib/carousel.js +839 -864
  99. package/lib/cascader-panel.js +852 -877
  100. package/lib/cascader.js +2048 -2223
  101. package/lib/checkbox-button.js +4 -4
  102. package/lib/checkbox-group.js +859 -884
  103. package/lib/checkbox.js +4 -4
  104. package/lib/col.js +2 -2
  105. package/lib/collapse-item.js +1040 -1065
  106. package/lib/collapse.js +1040 -1065
  107. package/lib/color-picker.js +972 -1122
  108. package/lib/container.js +2 -2
  109. package/lib/cron.js +12 -12
  110. package/lib/data-table.js +843 -868
  111. package/lib/date-picker.js +10520 -10695
  112. package/lib/descriptions-item.js +4 -4
  113. package/lib/descriptions.js +4 -4
  114. package/lib/dialog.js +837 -862
  115. package/lib/divider.js +2 -2
  116. package/lib/drawer.js +2 -2
  117. package/lib/dropdown-item.js +4 -4
  118. package/lib/dropdown-menu.js +974 -1124
  119. package/lib/dropdown.js +841 -866
  120. package/lib/email-login.js +837 -862
  121. package/lib/empty.js +2 -2
  122. package/lib/eoss.common.js +4023 -2668
  123. package/lib/flip.js +2 -2
  124. package/lib/flow-group.js +853 -878
  125. package/lib/flow.js +868 -893
  126. package/lib/flows.js +854 -879
  127. package/lib/footer.js +2 -2
  128. package/lib/form-item.js +860 -885
  129. package/lib/form.js +933 -950
  130. package/lib/guide.js +2 -2
  131. package/lib/header.js +2 -2
  132. package/lib/icon.js +837 -862
  133. package/lib/icons.js +2 -2
  134. package/lib/image-viewer.js +837 -862
  135. package/lib/image.js +4 -4
  136. package/lib/index.js +1 -1
  137. package/lib/infinite-scroll.js +2 -2
  138. package/lib/input-number.js +6 -6
  139. package/lib/input.js +839 -864
  140. package/lib/link.js +2 -2
  141. package/lib/loading.js +2 -2
  142. package/lib/login.js +867 -891
  143. package/lib/lowcode-view.js +1843 -1185
  144. package/lib/lowcode.js +3050 -1569
  145. package/lib/main.js +970 -988
  146. package/lib/marquee.js +837 -862
  147. package/lib/menu-item-group.js +15 -15
  148. package/lib/menu-item.js +6 -6
  149. package/lib/menu.js +2227 -2368
  150. package/lib/message-box.js +843 -868
  151. package/lib/message.js +839 -864
  152. package/lib/notification.js +861 -886
  153. package/lib/option-group.js +4 -4
  154. package/lib/option.js +839 -864
  155. package/lib/page-header.js +2 -2
  156. package/lib/pagination.js +839 -864
  157. package/lib/phone-login.js +847 -866
  158. package/lib/popconfirm.js +4 -4
  159. package/lib/popover.js +1831 -2006
  160. package/lib/process-config.js +839 -864
  161. package/lib/process-module.js +846 -871
  162. package/lib/process-rule.js +905 -930
  163. package/lib/progress.js +2 -2
  164. package/lib/qr-code.js +4 -4
  165. package/lib/qrcode-login.js +839 -864
  166. package/lib/radio-button.js +4 -4
  167. package/lib/radio-group.js +850 -875
  168. package/lib/radio.js +4 -4
  169. package/lib/rate.js +837 -862
  170. package/lib/retrial-auth.js +837 -862
  171. package/lib/row.js +2 -2
  172. package/lib/scrollbar.js +839 -864
  173. package/lib/select.js +2139 -2314
  174. package/lib/selector-panel.js +940 -965
  175. package/lib/selector.js +852 -877
  176. package/lib/slider.js +4 -4
  177. package/lib/step.js +32 -32
  178. package/lib/steps.js +874 -899
  179. package/lib/submenu.js +1269 -1385
  180. package/lib/switch.js +839 -864
  181. package/lib/tab-pane.js +4 -4
  182. package/lib/table-column.js +840 -865
  183. package/lib/table.js +1825 -2000
  184. package/lib/tabs.js +846 -871
  185. package/lib/tag.js +2 -2
  186. package/lib/theme-chalk/fonts/iconfont.ttf +0 -0
  187. package/lib/theme-chalk/fonts/iconfont.woff +0 -0
  188. package/lib/theme-chalk/index.css +1 -1
  189. package/lib/theme-chalk/lowcode.css +1 -1
  190. package/lib/time-picker.js +6471 -6646
  191. package/lib/time-select.js +5039 -5214
  192. package/lib/timeline-item.js +2 -2
  193. package/lib/timeline.js +2 -2
  194. package/lib/tips.js +837 -862
  195. package/lib/toolbar.js +4 -4
  196. package/lib/tooltip.js +1813 -1988
  197. package/lib/transfer.js +837 -862
  198. package/lib/tree-group.js +853 -878
  199. package/lib/tree.js +1026 -1051
  200. package/lib/update-history.js +4 -4
  201. package/lib/upload.js +859 -884
  202. package/lib/wujie.js +841 -866
  203. package/package.json +1 -1
  204. package/packages/flow-group/src/main.vue +2 -2
  205. package/packages/form/src/form-item-render.vue +1 -0
  206. package/packages/form/src/form-item.vue +12 -6
  207. package/packages/form/src/form.vue +5 -5
  208. package/packages/login/src/login.vue +1 -0
  209. package/packages/lowcode/src/attribute/function.vue +28 -9
  210. package/packages/lowcode/src/attribute/props.vue +202 -0
  211. package/packages/lowcode/src/attribute/styles.vue +79 -5
  212. package/packages/lowcode/src/attribute.vue +61 -4
  213. package/packages/lowcode/src/canvas.vue +159 -2
  214. package/packages/lowcode/src/form-render.vue +305 -0
  215. package/packages/lowcode/src/lowcode.vue +33 -13
  216. package/packages/lowcode/src/modules.vue +53 -37
  217. package/packages/lowcode/src/render.vue +80 -25
  218. package/packages/lowcode/src/util/components.js +100 -0
  219. package/packages/lowcode/src/util/props-util.js +67 -0
  220. package/packages/lowcode/src/util/source-generator.js +69 -9
  221. package/packages/lowcode/src/util/source-parser.js +64 -10
  222. package/packages/lowcode-view/src/render.vue +48 -18
  223. package/packages/main/src/components/userinfo.vue +0 -1
  224. package/packages/menu/src/menu-item-group.vue +1 -1
  225. package/packages/menu/src/mixins.js +8 -4
  226. package/packages/menu/src/submenu.vue +35 -5
  227. package/packages/phone-login/src/phone-login.vue +5 -2
  228. package/packages/theme-chalk/dist/fonts/iconfont.ttf +0 -0
  229. package/packages/theme-chalk/dist/fonts/iconfont.woff +0 -0
  230. package/packages/theme-chalk/src/fonts/iconfont.ttf +0 -0
  231. package/packages/theme-chalk/src/fonts/iconfont.woff +0 -0
  232. package/packages/theme-chalk/src/lowcode.scss +21 -2
  233. package/src/index.js +336 -336
package/lib/tree.js CHANGED
@@ -82,7 +82,7 @@ module.exports =
82
82
  /******/
83
83
  /******/
84
84
  /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 197);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 204);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -4743,7 +4743,73 @@ module.exports = require("lodash/cloneDeep");
4743
4743
 
4744
4744
  /***/ }),
4745
4745
 
4746
- /***/ 197:
4746
+ /***/ 2:
4747
+ /***/ (function(module, exports) {
4748
+
4749
+ module.exports = require("vue");
4750
+
4751
+ /***/ }),
4752
+
4753
+ /***/ 20:
4754
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
4755
+
4756
+ "use strict";
4757
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return doEncrypt; });
4758
+ /* unused harmony export doDecrypt */
4759
+ /* harmony import */ var _storage__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
4760
+ var sm2 = __webpack_require__(42).sm2;
4761
+
4762
+
4763
+ /**
4764
+ * doEncrypt
4765
+ * @desc:sm2加密
4766
+ * @author huangbo
4767
+ * @date 2022年5月7日
4768
+ * @param {string} [data] - 被加密的字符串
4769
+ * @param {string} [key] - 公钥
4770
+ **/
4771
+ var doEncrypt = function doEncrypt(_ref) {
4772
+ var data = _ref.data,
4773
+ key = _ref.key,
4774
+ mode = _ref.mode;
4775
+
4776
+ if (!key) {
4777
+ key = Object(_storage__WEBPACK_IMPORTED_MODULE_0__[/* getStorage */ "a"])('secretKey');
4778
+ }
4779
+ if (!mode) {
4780
+ mode = 1;
4781
+ }
4782
+ if (!new RegExp('^04').test(key)) {
4783
+ key = '04' + key;
4784
+ }
4785
+ var result = sm2.doEncrypt(data, key, mode);
4786
+ return result;
4787
+ };
4788
+
4789
+ /**
4790
+ * doDecrypt
4791
+ * @desc:sm2解密
4792
+ * @author huangbo
4793
+ * @date 2022年5月7日
4794
+ * @param {string} [data] - 被解密的加密字符串
4795
+ * @param {string} [key] - 私钥
4796
+ **/
4797
+ var doDecrypt = function doDecrypt(_ref2) {
4798
+ var data = _ref2.data,
4799
+ key = _ref2.key,
4800
+ mode = _ref2.mode;
4801
+
4802
+ var cipherMode = mode ? mode : 1;
4803
+ if (new RegExp('^04').test(key)) {
4804
+ key = key.slice(2);
4805
+ }
4806
+ var result = sm2.doDecrypt(data, key, cipherMode);
4807
+ return result;
4808
+ };
4809
+
4810
+ /***/ }),
4811
+
4812
+ /***/ 204:
4747
4813
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4748
4814
 
4749
4815
  "use strict";
@@ -6194,10 +6260,10 @@ tree_nodevue_type_template_id_5439f49a_render._withStripped = true
6194
6260
  // CONCATENATED MODULE: ./packages/tree/src/tree-node.vue?vue&type=template&id=5439f49a&
6195
6261
 
6196
6262
  // EXTERNAL MODULE: ./src/transitions/collapse-transition.js
6197
- var collapse_transition = __webpack_require__(69);
6263
+ var collapse_transition = __webpack_require__(70);
6198
6264
 
6199
6265
  // EXTERNAL MODULE: external "eoss/lib/radio"
6200
- var radio_ = __webpack_require__(48);
6266
+ var radio_ = __webpack_require__(49);
6201
6267
  var radio_default = /*#__PURE__*/__webpack_require__.n(radio_);
6202
6268
 
6203
6269
  // EXTERNAL MODULE: external "eoss/lib/checkbox"
@@ -6625,7 +6691,7 @@ var component = Object(componentNormalizer["a" /* default */])(
6625
6691
  var dom = __webpack_require__(5);
6626
6692
 
6627
6693
  // EXTERNAL MODULE: ./src/components/bar.js
6628
- var bar = __webpack_require__(58);
6694
+ var bar = __webpack_require__(59);
6629
6695
 
6630
6696
  // EXTERNAL MODULE: ./src/utils/scrollbar.js
6631
6697
  var scrollbar = __webpack_require__(23);
@@ -7964,72 +8030,6 @@ tree.install = function (Vue) {
7964
8030
 
7965
8031
  /***/ }),
7966
8032
 
7967
- /***/ 2:
7968
- /***/ (function(module, exports) {
7969
-
7970
- module.exports = require("vue");
7971
-
7972
- /***/ }),
7973
-
7974
- /***/ 20:
7975
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
7976
-
7977
- "use strict";
7978
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return doEncrypt; });
7979
- /* unused harmony export doDecrypt */
7980
- /* harmony import */ var _storage__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
7981
- var sm2 = __webpack_require__(42).sm2;
7982
-
7983
-
7984
- /**
7985
- * doEncrypt
7986
- * @desc:sm2加密
7987
- * @author huangbo
7988
- * @date 2022年5月7日
7989
- * @param {string} [data] - 被加密的字符串
7990
- * @param {string} [key] - 公钥
7991
- **/
7992
- var doEncrypt = function doEncrypt(_ref) {
7993
- var data = _ref.data,
7994
- key = _ref.key,
7995
- mode = _ref.mode;
7996
-
7997
- if (!key) {
7998
- key = Object(_storage__WEBPACK_IMPORTED_MODULE_0__[/* getStorage */ "a"])('secretKey');
7999
- }
8000
- if (!mode) {
8001
- mode = 1;
8002
- }
8003
- if (!new RegExp('^04').test(key)) {
8004
- key = '04' + key;
8005
- }
8006
- var result = sm2.doEncrypt(data, key, mode);
8007
- return result;
8008
- };
8009
-
8010
- /**
8011
- * doDecrypt
8012
- * @desc:sm2解密
8013
- * @author huangbo
8014
- * @date 2022年5月7日
8015
- * @param {string} [data] - 被解密的加密字符串
8016
- * @param {string} [key] - 私钥
8017
- **/
8018
- var doDecrypt = function doDecrypt(_ref2) {
8019
- var data = _ref2.data,
8020
- key = _ref2.key,
8021
- mode = _ref2.mode;
8022
-
8023
- var cipherMode = mode ? mode : 1;
8024
- if (new RegExp('^04').test(key)) {
8025
- key = key.slice(2);
8026
- }
8027
- var result = sm2.doDecrypt(data, key, cipherMode);
8028
- return result;
8029
- };
8030
-
8031
- /***/ }),
8032
-
8033
8033
  /***/ 21:
8034
8034
  /***/ (function(module, exports) {
8035
8035
 
@@ -8439,7 +8439,7 @@ module.exports = require("sm-crypto");
8439
8439
 
8440
8440
  /***/ }),
8441
8441
 
8442
- /***/ 48:
8442
+ /***/ 49:
8443
8443
  /***/ (function(module, exports) {
8444
8444
 
8445
8445
  module.exports = require("eoss/lib/radio");
@@ -8705,7 +8705,7 @@ function insertAfter(newEl, targetEl) {
8705
8705
 
8706
8706
  /***/ }),
8707
8707
 
8708
- /***/ 58:
8708
+ /***/ 59:
8709
8709
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
8710
8710
 
8711
8711
  "use strict";
@@ -9636,108 +9636,6 @@ var changeInTime = '/baseIssueRules/changeInTime';
9636
9636
 
9637
9637
  /***/ }),
9638
9638
 
9639
- /***/ 69:
9640
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
9641
-
9642
- "use strict";
9643
- /* harmony import */ var eoss_src_utils_dom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
9644
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9645
-
9646
-
9647
-
9648
- var Transition = function () {
9649
- function Transition() {
9650
- _classCallCheck(this, Transition);
9651
- }
9652
-
9653
- Transition.prototype.beforeEnter = function beforeEnter(el) {
9654
- Object(eoss_src_utils_dom__WEBPACK_IMPORTED_MODULE_0__[/* addClass */ "a"])(el, 'collapse-transition');
9655
- if (!el.dataset) el.dataset = {};
9656
- if (el.dataset.state === 6 || !el.dataset.state) {
9657
- el.dataset.oldPaddingTop = el.style.paddingTop;
9658
- el.dataset.oldPaddingBottom = el.style.paddingBottom;
9659
- }
9660
- el.dataset.state = 1;
9661
-
9662
- el.style.height = '0';
9663
- el.style.paddingTop = 0;
9664
- el.style.paddingBottom = 0;
9665
- };
9666
-
9667
- Transition.prototype.enter = function enter(el) {
9668
- el.dataset.oldOverflow = el.style.overflow;
9669
- if (el.scrollHeight !== 0) {
9670
- el.style.height = el.scrollHeight + 'px';
9671
- el.style.paddingTop = el.dataset.oldPaddingTop;
9672
- el.style.paddingBottom = el.dataset.oldPaddingBottom;
9673
- } else {
9674
- el.style.height = '';
9675
- el.style.paddingTop = el.dataset.oldPaddingTop;
9676
- el.style.paddingBottom = el.dataset.oldPaddingBottom;
9677
- }
9678
-
9679
- el.dataset.state = 2;
9680
- el.style.overflow = 'hidden';
9681
- };
9682
-
9683
- Transition.prototype.afterEnter = function afterEnter(el) {
9684
- // for safari: remove class then reset height is necessary
9685
- Object(eoss_src_utils_dom__WEBPACK_IMPORTED_MODULE_0__[/* removeClass */ "i"])(el, 'collapse-transition');
9686
- el.style.height = '';
9687
- el.style.overflow = el.dataset.oldOverflow;
9688
- el.dataset.state = 3;
9689
- };
9690
-
9691
- Transition.prototype.beforeLeave = function beforeLeave(el) {
9692
- if (!el.dataset) el.dataset = {};
9693
- el.dataset.oldPaddingTop = el.style.paddingTop;
9694
- el.dataset.oldPaddingBottom = el.style.paddingBottom;
9695
- el.dataset.oldOverflow = el.style.overflow;
9696
- el.dataset.state = 4;
9697
-
9698
- el.style.height = el.scrollHeight + 'px';
9699
- el.style.overflow = 'hidden';
9700
- };
9701
-
9702
- Transition.prototype.leave = function leave(el) {
9703
- if (el.scrollHeight !== 0) {
9704
- // for safari: add class after set height, or it will jump to zero height suddenly, weired
9705
- Object(eoss_src_utils_dom__WEBPACK_IMPORTED_MODULE_0__[/* addClass */ "a"])(el, 'collapse-transition');
9706
- el.style.height = 0;
9707
- el.style.paddingTop = 0;
9708
- el.style.paddingBottom = 0;
9709
- el.dataset.state = 5;
9710
- }
9711
- };
9712
-
9713
- Transition.prototype.afterLeave = function afterLeave(el) {
9714
- Object(eoss_src_utils_dom__WEBPACK_IMPORTED_MODULE_0__[/* removeClass */ "i"])(el, 'collapse-transition');
9715
- el.style.height = '';
9716
- el.style.overflow = el.dataset.oldOverflow;
9717
- el.style.paddingTop = el.dataset.oldPaddingTop;
9718
- el.style.paddingBottom = el.dataset.oldPaddingBottom;
9719
- el.dataset.state = 6;
9720
- };
9721
-
9722
- return Transition;
9723
- }();
9724
-
9725
- /* harmony default export */ __webpack_exports__["a"] = ({
9726
- name: 'EsCollapseTransition',
9727
- functional: true,
9728
- render: function render(h, _ref) {
9729
- var children = _ref.children;
9730
-
9731
- var data = {
9732
- on: new Transition()
9733
- };
9734
-
9735
- return h('transition', data, children);
9736
- }
9737
- });
9738
-
9739
- /***/ }),
9740
-
9741
9639
  /***/ 7:
9742
9640
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
9743
9641
 
@@ -9788,759 +9686,736 @@ var Transition = function () {
9788
9686
  /* unused harmony export getSecond */
9789
9687
  /* unused harmony export getWeekday */
9790
9688
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
9791
- /* Modified from https://github.com/taylorhakes/fecha
9792
- *
9793
- * The MIT License (MIT)
9794
- *
9795
- * Copyright (c) 2015 Taylor Hakes
9796
- *
9797
- * Permission is hereby granted, free of charge, to any person obtaining a copy
9798
- * of this software and associated documentation files (the "Software"), to deal
9799
- * in the Software without restriction, including without limitation the rights
9800
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9801
- * copies of the Software, and to permit persons to whom the Software is
9802
- * furnished to do so, subject to the following conditions:
9803
- *
9804
- * The above copyright notice and this permission notice shall be included in all
9805
- * copies or substantial portions of the Software.
9806
- *
9807
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
9808
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9809
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
9810
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
9811
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
9812
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
9813
- * SOFTWARE.
9814
- */
9815
-
9816
- /*eslint-disable*/
9817
- // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
9818
-
9819
-
9689
+
9690
+
9820
9691
  /**
9821
9692
  * Parse or format dates
9822
9693
  * @class fecha
9823
- */
9824
- const fecha = {};
9825
- const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
9826
- const twoDigits = '\\d\\d?';
9827
- const threeDigits = '\\d{3}';
9828
- const fourDigits = '\\d{4}';
9829
- const word = '[^\\s]+';
9830
- const literal = /\[([^]*?)\]/gm;
9831
- const noop = function () {};
9832
-
9833
- function regexEscape(str) {
9834
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
9835
- }
9836
-
9837
- function shorten(arr, sLen) {
9838
- const newArr = [];
9839
- for (let i = 0, len = arr.length; i < len; i++) {
9840
- newArr.push(arr[i].substr(0, sLen));
9841
- }
9842
- return newArr;
9843
- }
9844
-
9845
- function monthUpdate() {
9846
- return function (d, v) {
9847
- const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
9848
- if (~index) {
9849
- d.month = index;
9850
- }
9851
- };
9852
- }
9853
-
9854
- function pad(val, len) {
9855
- val = String(val);
9856
- len = len || 2;
9857
- while (val.length < len) {
9858
- val = '0' + val;
9859
- }
9860
- return val;
9861
- }
9862
-
9863
- // 直接使用中文日期名称常量
9864
- const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
9865
- const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
9866
- const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
9867
- const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
9868
- const amPm = ['上午', '下午'];
9869
- const DoFn = function DoFn(D) {
9870
- return D + '日';
9871
- };
9872
-
9873
- const formatFlags = {
9874
- D: function(dateObj) {
9875
- return dateObj.getDay();
9876
- },
9877
- DD: function(dateObj) {
9878
- return pad(dateObj.getDay());
9879
- },
9880
- Do: function(dateObj) {
9881
- return DoFn(dateObj.getDate());
9882
- },
9883
- d: function(dateObj) {
9884
- return dateObj.getDate();
9885
- },
9886
- dd: function(dateObj) {
9887
- return pad(dateObj.getDate());
9888
- },
9889
- ddd: function(dateObj) {
9890
- return dayNamesShort[dateObj.getDay()];
9891
- },
9892
- dddd: function(dateObj) {
9893
- return dayNames[dateObj.getDay()];
9894
- },
9895
- M: function(dateObj) {
9896
- return dateObj.getMonth() + 1;
9897
- },
9898
- MM: function(dateObj) {
9899
- return pad(dateObj.getMonth() + 1);
9900
- },
9901
- MMM: function(dateObj) {
9902
- return monthNamesShort[dateObj.getMonth()];
9903
- },
9904
- MMMM: function(dateObj) {
9905
- return monthNames[dateObj.getMonth()];
9906
- },
9907
- yy: function(dateObj) {
9908
- return pad(String(dateObj.getFullYear()), 4).substr(2);
9909
- },
9910
- yyyy: function(dateObj) {
9911
- return pad(dateObj.getFullYear(), 4);
9912
- },
9913
- h: function(dateObj) {
9914
- return dateObj.getHours() % 12 || 12;
9915
- },
9916
- hh: function(dateObj) {
9917
- return pad(dateObj.getHours() % 12 || 12);
9918
- },
9919
- H: function(dateObj) {
9920
- return dateObj.getHours();
9921
- },
9922
- HH: function(dateObj) {
9923
- return pad(dateObj.getHours());
9924
- },
9925
- m: function(dateObj) {
9926
- return dateObj.getMinutes();
9927
- },
9928
- mm: function(dateObj) {
9929
- return pad(dateObj.getMinutes());
9930
- },
9931
- s: function(dateObj) {
9932
- return dateObj.getSeconds();
9933
- },
9934
- ss: function(dateObj) {
9935
- return pad(dateObj.getSeconds());
9936
- },
9937
- S: function(dateObj) {
9938
- return Math.round(dateObj.getMilliseconds() / 100);
9939
- },
9940
- SS: function(dateObj) {
9941
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
9942
- },
9943
- SSS: function(dateObj) {
9944
- return pad(dateObj.getMilliseconds(), 3);
9945
- },
9946
- a: function(dateObj) {
9947
- return dateObj.getHours() < 12 ? '上午' : '下午';
9948
- },
9949
- A: function(dateObj) {
9950
- return dateObj.getHours() < 12 ? '上午' : '下午';
9951
- },
9952
- ZZ: function(dateObj) {
9953
- const o = dateObj.getTimezoneOffset();
9954
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
9955
- }
9956
- };
9957
-
9958
- const parseFlags = {
9959
- d: [twoDigits, function (d, v) {
9960
- d.day = v;
9961
- }],
9962
- Do: [twoDigits + word, function (d, v) {
9963
- d.day = parseInt(v, 10);
9964
- }],
9965
- M: [twoDigits, function (d, v) {
9966
- d.month = v - 1;
9967
- }],
9968
- yy: [twoDigits, function (d, v) {
9969
- const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
9970
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
9971
- }],
9972
- h: [twoDigits, function (d, v) {
9973
- d.hour = v;
9974
- }],
9975
- m: [twoDigits, function (d, v) {
9976
- d.minute = v;
9977
- }],
9978
- s: [twoDigits, function (d, v) {
9979
- d.second = v;
9980
- }],
9981
- yyyy: [fourDigits, function (d, v) {
9982
- d.year = v;
9983
- }],
9984
- S: ['\\d', function (d, v) {
9985
- d.millisecond = v * 100;
9986
- }],
9987
- SS: ['\\d{2}', function (d, v) {
9988
- d.millisecond = v * 10;
9989
- }],
9990
- SSS: [threeDigits, function (d, v) {
9991
- d.millisecond = v;
9992
- }],
9993
- D: [twoDigits, noop],
9994
- ddd: [word, noop],
9995
- MMM: [word, monthUpdate('monthNamesShort')],
9996
- MMMM: [word, monthUpdate('monthNames')],
9997
- a: [word, function (d, v) {
9998
- const val = v.toLowerCase();
9999
- if (val === '上午') {
10000
- d.isPm = false;
10001
- } else if (val === '下午') {
10002
- d.isPm = true;
10003
- }
10004
- }],
10005
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
10006
- let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
10007
-
10008
- if (parts) {
10009
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
10010
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
10011
- }
10012
- }]
10013
- };
10014
- parseFlags.dd = parseFlags.d;
10015
- parseFlags.dddd = parseFlags.ddd;
10016
- parseFlags.DD = parseFlags.D;
10017
- parseFlags.mm = parseFlags.m;
10018
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
10019
- parseFlags.MM = parseFlags.M;
10020
- parseFlags.ss = parseFlags.s;
10021
- parseFlags.A = parseFlags.a;
10022
-
10023
-
10024
- // Some common format strings
10025
- fecha.masks = {
10026
- default: 'ddd MMM dd yyyy HH:mm:ss',
10027
- shortDate: 'M/D/yy',
10028
- mediumDate: 'MMM d, yyyy',
10029
- longDate: 'MMMM d, yyyy',
10030
- fullDate: 'dddd, MMMM d, yyyy',
10031
- shortTime: 'HH:mm',
10032
- mediumTime: 'HH:mm:ss',
10033
- longTime: 'HH:mm:ss.SSS'
10034
- };
10035
-
10036
- /***
10037
- * Format a date
10038
- * @method format
10039
- * @param {Date|number} dateObj
10040
- * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
10041
- */
10042
- fecha.format = function (dateObj, mask) {
10043
- if (typeof dateObj === 'number') {
10044
- dateObj = new Date(dateObj);
10045
- }
10046
-
10047
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
10048
- throw new Error('Invalid Date in fecha.format');
10049
- }
10050
-
10051
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
10052
-
10053
- const literals = [];
10054
-
10055
- // Make literals inactive by replacing them with ??
10056
- mask = mask.replace(literal, function($0, $1) {
10057
- literals.push($1);
10058
- return '@@@';
10059
- });
10060
- // Apply formatting rules
10061
- mask = mask.replace(token, function ($0) {
10062
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
10063
- });
10064
- // Inline literal values back into the formatted value
10065
- return mask.replace(/@@@/g, function() {
10066
- return literals.shift();
10067
- });
10068
- };
10069
-
10070
- /**
10071
- * Parse a date string into an object, changes - into /
10072
- * @method parse
10073
- * @param {string} dateStr Date string
10074
- * @param {string} format Date parse format
10075
- * @returns {Date|boolean}
10076
- */
10077
- fecha.parse = function (dateStr, format) {
10078
- if (typeof format !== 'string') {
10079
- throw new Error('Invalid format in fecha.parse');
10080
- }
10081
-
10082
- format = fecha.masks[format] || format;
10083
-
10084
- // Avoid regular expression denial of service, fail early for really long strings
10085
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
10086
- if (dateStr.length > 1000) {
10087
- return null;
10088
- }
10089
-
10090
- const dateInfo = {};
10091
- const parseInfo = [];
10092
- const literals = [];
10093
- format = format.replace(literal, function($0, $1) {
10094
- literals.push($1);
10095
- return '@@@';
10096
- });
10097
- let newFormat = regexEscape(format).replace(token, function ($0) {
10098
- if (parseFlags[$0]) {
10099
- const info = parseFlags[$0];
10100
- parseInfo.push(info[1]);
10101
- return '(' + info[0] + ')';
10102
- }
10103
-
10104
- return $0;
10105
- });
10106
- newFormat = newFormat.replace(/@@@/g, function() {
10107
- return literals.shift();
10108
- });
10109
- const matches = dateStr.match(new RegExp(newFormat, 'i'));
10110
- if (!matches) {
10111
- return null;
10112
- }
10113
-
10114
- for (let i = 1; i < matches.length; i++) {
10115
- parseInfo[i - 1](dateInfo, matches[i]);
10116
- }
10117
-
10118
- const today = new Date();
10119
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
10120
- dateInfo.hour = +dateInfo.hour + 12;
10121
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
10122
- dateInfo.hour = 0;
10123
- }
10124
-
10125
- let date;
10126
- if (dateInfo.timezoneOffset != null) {
10127
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
10128
- date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
10129
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
10130
- } else {
10131
- date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
10132
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
10133
- }
10134
- return date;
10135
- };
10136
-
10137
- // 导出fecha对象
10138
-
10139
-
10140
- // 以下是从date-util.js合并的函数
10141
- const newArray = function(start, end) {
10142
- let result = [];
10143
- for (let i = start; i <= end; i++) {
10144
- result.push(i);
10145
- }
10146
- return result;
10147
- };
10148
-
10149
- const getSettings = () => {
10150
- return {
10151
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
10152
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
10153
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
10154
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
10155
- amPm: ['上午', '下午']
10156
- };
10157
- };
10158
-
10159
- const toDate = function(date) {
10160
- return isDate(date) ? new Date(date) : null;
10161
- };
10162
-
10163
- const isDate = function(date) {
10164
- if (date === null || date === undefined) return false;
10165
- if (isNaN(new Date(date).getTime())) return false;
10166
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
10167
- return true;
10168
- };
10169
-
10170
- const isDateObject = function(val) {
10171
- return val instanceof Date;
10172
- };
10173
-
10174
- const formatDate = function (date, format = 'yyyy-MM-dd') {
10175
- // 处理多种输入类型
10176
- if (!date) return '';
10177
-
10178
- // 如果是时间戳,转成日期对象
10179
- if (typeof date === 'number') {
10180
- date = new Date(date);
10181
- }
10182
- // 如果是字符串,转成日期对象
10183
- if (typeof date === 'string') {
10184
- date = new Date(date);
10185
- }
10186
-
10187
- // 调用toDate进一步验证和转换
10188
- date = toDate(date);
10189
- if (!date) return '';
10190
-
10191
- // 兼容大写和小写的格式标记
10192
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
10193
- const lowercaseFormat = format
10194
- .replace(/YYYY/g, 'yyyy')
10195
- .replace(/D/g, 'd')
10196
-
10197
- // 使用fecha库进行格式化,支持中文配置
10198
- const str = fecha.format(date, lowercaseFormat, getSettings());
10199
- return str;
10200
- };
10201
-
10202
- const parseDate = function(string, format) {
10203
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
10204
- };
10205
-
10206
- const getDayCountOfMonth = function(year, month) {
10207
- if (month === 3 || month === 5 || month === 8 || month === 10) {
10208
- return 30;
10209
- }
10210
-
10211
- if (month === 1) {
10212
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
10213
- return 29;
10214
- } else {
10215
- return 28;
10216
- }
10217
- }
10218
-
10219
- return 31;
10220
- };
10221
-
10222
- const getDayCountOfYear = function(year) {
10223
- const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
10224
- return isLeapYear ? 366 : 365;
10225
- };
10226
-
10227
- const getFirstDayOfMonth = function(date) {
10228
- const temp = new Date(date.getTime());
10229
- temp.setDate(1);
10230
- return temp.getDay();
10231
- };
10232
-
10233
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
10234
- // {prev, next} Date should work for Daylight Saving Time
10235
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
10236
- const prevDate = function(date, amount = 1) {
10237
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
10238
- };
10239
-
10240
- const nextDate = function(date, amount = 1) {
10241
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
10242
- };
10243
-
10244
- const getStartDateOfMonth = function(year, month) {
10245
- const result = new Date(year, month, 1);
10246
- const day = result.getDay();
10247
-
10248
- if (day === 0) {
10249
- return prevDate(result, 7);
10250
- } else {
10251
- return prevDate(result, day);
10252
- }
10253
- };
10254
-
10255
- const getWeekNumber = function(date) {
10256
- // 支持多种输入类型
10257
- if (!date||!isDate(date)) {
10258
- date = new Date();
10259
- }
10260
- if (typeof date === 'string') {
10261
- date = new Date(date);
10262
- }
10263
-
10264
- // 验证日期有效性
10265
- if (!isDate(date)) return null;
10266
-
10267
- const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
10268
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
10269
- // 将星期日的星期数设为7
10270
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
10271
- // 获取当年的第一天
10272
- const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
10273
- // 计算到最近的星期四的完整周数
10274
- const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
10275
- // 返回周数
10276
- return weekNo;
10277
- };
10278
-
10279
- const getRangeHours = function(ranges) {
10280
- const hours = [];
10281
- let disabledHours = [];
10282
-
10283
- (ranges || []).forEach(range => {
10284
- const value = range.map(date => date.getHours());
10285
-
10286
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
10287
- });
10288
-
10289
- if (disabledHours.length) {
10290
- for (let i = 0; i < 24; i++) {
10291
- hours[i] = disabledHours.indexOf(i) === -1;
10292
- }
10293
- } else {
10294
- for (let i = 0; i < 24; i++) {
10295
- hours[i] = false;
10296
- }
10297
- }
10298
-
10299
- return hours;
10300
- };
10301
-
10302
- const getPrevMonthLastDays = (date, amount) => {
10303
- if (amount <= 0) return [];
10304
- const temp = new Date(date.getTime());
10305
- temp.setDate(0);
10306
- const lastDay = temp.getDate();
10307
- return range(amount).map((_, index) => lastDay - (amount - index - 1));
10308
- };
10309
-
10310
- const getMonthDays = (date) => {
10311
- const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
10312
- const days = temp.getDate();
10313
- return range(days).map((_, index) => index + 1);
10314
- };
10315
-
10316
- function setRangeData(arr, start, end, value) {
10317
- for (let i = start; i < end; i++) {
10318
- arr[i] = value;
10319
- }
10320
- }
10321
-
10322
- const getRangeMinutes = function(ranges, hour) {
10323
- const minutes = new Array(60);
10324
-
10325
- if (ranges.length > 0) {
10326
- ranges.forEach(range => {
10327
- const start = range[0];
10328
- const end = range[1];
10329
- const startHour = start.getHours();
10330
- const startMinute = start.getMinutes();
10331
- const endHour = end.getHours();
10332
- const endMinute = end.getMinutes();
10333
- if (startHour === hour && endHour !== hour) {
10334
- setRangeData(minutes, startMinute, 60, true);
10335
- } else if (startHour === hour && endHour === hour) {
10336
- setRangeData(minutes, startMinute, endMinute + 1, true);
10337
- } else if (startHour !== hour && endHour === hour) {
10338
- setRangeData(minutes, 0, endMinute + 1, true);
10339
- } else if (startHour < hour && endHour > hour) {
10340
- setRangeData(minutes, 0, 60, true);
10341
- }
10342
- });
10343
- } else {
10344
- setRangeData(minutes, 0, 60, true);
10345
- }
10346
- return minutes;
10347
- };
10348
-
10349
- const range = function(n) {
10350
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
10351
- return Array.apply(null, {length: n}).map((_, n) => n);
10352
- };
10353
-
10354
- const modifyDate = function(date, y, m, d) {
10355
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
10356
- };
10357
-
10358
- const modifyTime = function(date, h, m, s) {
10359
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
10360
- };
10361
-
10362
- const modifyWithTimeString = (date, time) => {
10363
- if (date == null || !time) {
10364
- return date;
10365
- }
10366
- time = parseDate(time, 'HH:mm:ss');
10367
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
10368
- };
10369
-
10370
- const clearTime = function(date) {
10371
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
10372
- };
10373
-
10374
- const clearMilliseconds = function(date) {
10375
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
10376
- };
10377
-
10378
- const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
10379
- // TODO: refactory a more elegant solution
10380
- if (ranges.length === 0) return date;
10381
- const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
10382
- const ndate = normalizeDate(date);
10383
- const nranges = ranges.map(range => range.map(normalizeDate));
10384
- if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
10385
-
10386
- let minDate = nranges[0][0];
10387
- let maxDate = nranges[0][0];
10388
-
10389
- nranges.forEach(nrange => {
10390
- minDate = new Date(Math.min(nrange[0], minDate));
10391
- maxDate = new Date(Math.max(nrange[1], minDate));
10392
- });
10393
-
10394
- const ret = ndate < minDate ? minDate : maxDate;
10395
- // preserve Year/Month/Date
10396
- return modifyDate(
10397
- ret,
10398
- date.getFullYear(),
10399
- date.getMonth(),
10400
- date.getDate()
10401
- );
10402
- };
10403
-
10404
- const timeWithinRange = function(date, selectableRange, format) {
10405
- const limitedDate = limitTimeRange(date, selectableRange, format);
10406
- return limitedDate.getTime() === date.getTime();
10407
- };
10408
-
10409
- const changeYearMonthAndClampDate = function(date, year, month) {
10410
- // clamp date to the number of days in `year`, `month`
10411
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
10412
- const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
10413
- return modifyDate(date, year, month, monthDate);
10414
- };
10415
-
10416
- const prevMonth = function(date) {
10417
- const year = date.getFullYear();
10418
- const month = date.getMonth();
10419
- return month === 0
10420
- ? changeYearMonthAndClampDate(date, year - 1, 11)
10421
- : changeYearMonthAndClampDate(date, year, month - 1);
10422
- };
10423
-
10424
- const nextMonth = function(date) {
10425
- const year = date.getFullYear();
10426
- const month = date.getMonth();
10427
- return month === 11
10428
- ? changeYearMonthAndClampDate(date, year + 1, 0)
10429
- : changeYearMonthAndClampDate(date, year, month + 1);
10430
- };
10431
-
10432
- const prevYear = function(date, amount = 1) {
10433
- const year = date.getFullYear();
10434
- const month = date.getMonth();
10435
- return changeYearMonthAndClampDate(date, year - amount, month);
10436
- };
10437
-
10438
- const nextYear = function(date, amount = 1) {
10439
- const year = date.getFullYear();
10440
- const month = date.getMonth();
10441
- return changeYearMonthAndClampDate(date, year + amount, month);
10442
- };
10443
-
10444
- const extractDateFormat = function(format) {
10445
- return format
10446
- .replace(/\W?m{1,2}|\W?ZZ/g, '')
10447
- .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
10448
- .trim();
10449
- };
10450
-
10451
- const extractTimeFormat = function(format) {
10452
- return format
10453
- .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
10454
- .trim();
10455
- };
10456
-
10457
- const validateRangeInOneMonth = function(start, end) {
10458
- return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
10459
- };
10460
-
10461
- /**
10462
- * 计算两个日期之间的工作日数量(不包括周末和节假日)
10463
- * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
10464
- * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
10465
- * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
9694
+ */
9695
+ var fecha = {};
9696
+ var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
9697
+ var twoDigits = '\\d\\d?';
9698
+ var threeDigits = '\\d{3}';
9699
+ var fourDigits = '\\d{4}';
9700
+ var word = '[^\\s]+';
9701
+ var literal = /\[([^]*?)\]/gm;
9702
+ var noop = function noop() {};
9703
+
9704
+ function regexEscape(str) {
9705
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
9706
+ }
9707
+
9708
+ function shorten(arr, sLen) {
9709
+ var newArr = [];
9710
+ for (var i = 0, len = arr.length; i < len; i++) {
9711
+ newArr.push(arr[i].substr(0, sLen));
9712
+ }
9713
+ return newArr;
9714
+ }
9715
+
9716
+ function monthUpdate() {
9717
+ return function (d, v) {
9718
+ var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
9719
+ if (~index) {
9720
+ d.month = index;
9721
+ }
9722
+ };
9723
+ }
9724
+
9725
+ function pad(val, len) {
9726
+ val = String(val);
9727
+ len = len || 2;
9728
+ while (val.length < len) {
9729
+ val = '0' + val;
9730
+ }
9731
+ return val;
9732
+ }
9733
+
9734
+ // 直接使用中文日期名称常量
9735
+ var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
9736
+ var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
9737
+ var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
9738
+ var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
9739
+ var amPm = ['上午', '下午'];
9740
+ var DoFn = function DoFn(D) {
9741
+ return D + '日';
9742
+ };
9743
+
9744
+ var formatFlags = {
9745
+ D: function D(dateObj) {
9746
+ return dateObj.getDay();
9747
+ },
9748
+ DD: function DD(dateObj) {
9749
+ return pad(dateObj.getDay());
9750
+ },
9751
+ Do: function Do(dateObj) {
9752
+ return DoFn(dateObj.getDate());
9753
+ },
9754
+ d: function d(dateObj) {
9755
+ return dateObj.getDate();
9756
+ },
9757
+ dd: function dd(dateObj) {
9758
+ return pad(dateObj.getDate());
9759
+ },
9760
+ ddd: function ddd(dateObj) {
9761
+ return dayNamesShort[dateObj.getDay()];
9762
+ },
9763
+ dddd: function dddd(dateObj) {
9764
+ return dayNames[dateObj.getDay()];
9765
+ },
9766
+ M: function M(dateObj) {
9767
+ return dateObj.getMonth() + 1;
9768
+ },
9769
+ MM: function MM(dateObj) {
9770
+ return pad(dateObj.getMonth() + 1);
9771
+ },
9772
+ MMM: function MMM(dateObj) {
9773
+ return monthNamesShort[dateObj.getMonth()];
9774
+ },
9775
+ MMMM: function MMMM(dateObj) {
9776
+ return monthNames[dateObj.getMonth()];
9777
+ },
9778
+ yy: function yy(dateObj) {
9779
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
9780
+ },
9781
+ yyyy: function yyyy(dateObj) {
9782
+ return pad(dateObj.getFullYear(), 4);
9783
+ },
9784
+ h: function h(dateObj) {
9785
+ return dateObj.getHours() % 12 || 12;
9786
+ },
9787
+ hh: function hh(dateObj) {
9788
+ return pad(dateObj.getHours() % 12 || 12);
9789
+ },
9790
+ H: function H(dateObj) {
9791
+ return dateObj.getHours();
9792
+ },
9793
+ HH: function HH(dateObj) {
9794
+ return pad(dateObj.getHours());
9795
+ },
9796
+ m: function m(dateObj) {
9797
+ return dateObj.getMinutes();
9798
+ },
9799
+ mm: function mm(dateObj) {
9800
+ return pad(dateObj.getMinutes());
9801
+ },
9802
+ s: function s(dateObj) {
9803
+ return dateObj.getSeconds();
9804
+ },
9805
+ ss: function ss(dateObj) {
9806
+ return pad(dateObj.getSeconds());
9807
+ },
9808
+ S: function S(dateObj) {
9809
+ return Math.round(dateObj.getMilliseconds() / 100);
9810
+ },
9811
+ SS: function SS(dateObj) {
9812
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
9813
+ },
9814
+ SSS: function SSS(dateObj) {
9815
+ return pad(dateObj.getMilliseconds(), 3);
9816
+ },
9817
+ a: function a(dateObj) {
9818
+ return dateObj.getHours() < 12 ? '上午' : '下午';
9819
+ },
9820
+ A: function A(dateObj) {
9821
+ return dateObj.getHours() < 12 ? '上午' : '下午';
9822
+ },
9823
+ ZZ: function ZZ(dateObj) {
9824
+ var o = dateObj.getTimezoneOffset();
9825
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
9826
+ }
9827
+ };
9828
+
9829
+ var parseFlags = {
9830
+ d: [twoDigits, function (d, v) {
9831
+ d.day = v;
9832
+ }],
9833
+ Do: [twoDigits + word, function (d, v) {
9834
+ d.day = parseInt(v, 10);
9835
+ }],
9836
+ M: [twoDigits, function (d, v) {
9837
+ d.month = v - 1;
9838
+ }],
9839
+ yy: [twoDigits, function (d, v) {
9840
+ var da = new Date(),
9841
+ cent = +('' + da.getFullYear()).substr(0, 2);
9842
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
9843
+ }],
9844
+ h: [twoDigits, function (d, v) {
9845
+ d.hour = v;
9846
+ }],
9847
+ m: [twoDigits, function (d, v) {
9848
+ d.minute = v;
9849
+ }],
9850
+ s: [twoDigits, function (d, v) {
9851
+ d.second = v;
9852
+ }],
9853
+ yyyy: [fourDigits, function (d, v) {
9854
+ d.year = v;
9855
+ }],
9856
+ S: ['\\d', function (d, v) {
9857
+ d.millisecond = v * 100;
9858
+ }],
9859
+ SS: ['\\d{2}', function (d, v) {
9860
+ d.millisecond = v * 10;
9861
+ }],
9862
+ SSS: [threeDigits, function (d, v) {
9863
+ d.millisecond = v;
9864
+ }],
9865
+ D: [twoDigits, noop],
9866
+ ddd: [word, noop],
9867
+ MMM: [word, monthUpdate('monthNamesShort')],
9868
+ MMMM: [word, monthUpdate('monthNames')],
9869
+ a: [word, function (d, v) {
9870
+ var val = v.toLowerCase();
9871
+ if (val === '上午') {
9872
+ d.isPm = false;
9873
+ } else if (val === '下午') {
9874
+ d.isPm = true;
9875
+ }
9876
+ }],
9877
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
9878
+ var parts = (v + '').match(/([+-]|\d\d)/gi),
9879
+ minutes = void 0;
9880
+
9881
+ if (parts) {
9882
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
9883
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
9884
+ }
9885
+ }]
9886
+ };
9887
+ parseFlags.dd = parseFlags.d;
9888
+ parseFlags.dddd = parseFlags.ddd;
9889
+ parseFlags.DD = parseFlags.D;
9890
+ parseFlags.mm = parseFlags.m;
9891
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
9892
+ parseFlags.MM = parseFlags.M;
9893
+ parseFlags.ss = parseFlags.s;
9894
+ parseFlags.A = parseFlags.a;
9895
+
9896
+ // Some common format strings
9897
+ fecha.masks = {
9898
+ default: 'ddd MMM dd yyyy HH:mm:ss',
9899
+ shortDate: 'M/D/yy',
9900
+ mediumDate: 'MMM d, yyyy',
9901
+ longDate: 'MMMM d, yyyy',
9902
+ fullDate: 'dddd, MMMM d, yyyy',
9903
+ shortTime: 'HH:mm',
9904
+ mediumTime: 'HH:mm:ss',
9905
+ longTime: 'HH:mm:ss.SSS'
9906
+ };
9907
+
9908
+ /***
9909
+ * Format a date
9910
+ * @method format
9911
+ * @param {Date|number} dateObj
9912
+ * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
9913
+ */
9914
+ fecha.format = function (dateObj, mask) {
9915
+ if (typeof dateObj === 'number') {
9916
+ dateObj = new Date(dateObj);
9917
+ }
9918
+
9919
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
9920
+ throw new Error('Invalid Date in fecha.format');
9921
+ }
9922
+
9923
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
9924
+
9925
+ var literals = [];
9926
+
9927
+ // Make literals inactive by replacing them with ??
9928
+ mask = mask.replace(literal, function ($0, $1) {
9929
+ literals.push($1);
9930
+ return '@@@';
9931
+ });
9932
+ // Apply formatting rules
9933
+ mask = mask.replace(token, function ($0) {
9934
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
9935
+ });
9936
+ // Inline literal values back into the formatted value
9937
+ return mask.replace(/@@@/g, function () {
9938
+ return literals.shift();
9939
+ });
9940
+ };
9941
+
9942
+ /**
9943
+ * Parse a date string into an object, changes - into /
9944
+ * @method parse
9945
+ * @param {string} dateStr Date string
9946
+ * @param {string} format Date parse format
9947
+ * @returns {Date|boolean}
9948
+ */
9949
+ fecha.parse = function (dateStr, format) {
9950
+ if (typeof format !== 'string') {
9951
+ throw new Error('Invalid format in fecha.parse');
9952
+ }
9953
+
9954
+ format = fecha.masks[format] || format;
9955
+
9956
+ // Avoid regular expression denial of service, fail early for really long strings
9957
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
9958
+ if (dateStr.length > 1000) {
9959
+ return null;
9960
+ }
9961
+
9962
+ var dateInfo = {};
9963
+ var parseInfo = [];
9964
+ var literals = [];
9965
+ format = format.replace(literal, function ($0, $1) {
9966
+ literals.push($1);
9967
+ return '@@@';
9968
+ });
9969
+ var newFormat = regexEscape(format).replace(token, function ($0) {
9970
+ if (parseFlags[$0]) {
9971
+ var info = parseFlags[$0];
9972
+ parseInfo.push(info[1]);
9973
+ return '(' + info[0] + ')';
9974
+ }
9975
+
9976
+ return $0;
9977
+ });
9978
+ newFormat = newFormat.replace(/@@@/g, function () {
9979
+ return literals.shift();
9980
+ });
9981
+ var matches = dateStr.match(new RegExp(newFormat, 'i'));
9982
+ if (!matches) {
9983
+ return null;
9984
+ }
9985
+
9986
+ for (var i = 1; i < matches.length; i++) {
9987
+ parseInfo[i - 1](dateInfo, matches[i]);
9988
+ }
9989
+
9990
+ var today = new Date();
9991
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
9992
+ dateInfo.hour = +dateInfo.hour + 12;
9993
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
9994
+ dateInfo.hour = 0;
9995
+ }
9996
+
9997
+ var date = void 0;
9998
+ if (dateInfo.timezoneOffset != null) {
9999
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
10000
+ 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));
10001
+ } else {
10002
+ 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);
10003
+ }
10004
+ return date;
10005
+ };
10006
+
10007
+ // 导出fecha对象
10008
+
10009
+
10010
+ // 以下是从date-util.js合并的函数
10011
+ var newArray = function newArray(start, end) {
10012
+ var result = [];
10013
+ for (var i = start; i <= end; i++) {
10014
+ result.push(i);
10015
+ }
10016
+ return result;
10017
+ };
10018
+
10019
+ var getSettings = function getSettings() {
10020
+ return {
10021
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
10022
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
10023
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
10024
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
10025
+ amPm: ['上午', '下午']
10026
+ };
10027
+ };
10028
+
10029
+ var toDate = function toDate(date) {
10030
+ return isDate(date) ? new Date(date) : null;
10031
+ };
10032
+
10033
+ var isDate = function isDate(date) {
10034
+ if (date === null || date === undefined) return false;
10035
+ if (isNaN(new Date(date).getTime())) return false;
10036
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
10037
+ return true;
10038
+ };
10039
+
10040
+ var isDateObject = function isDateObject(val) {
10041
+ return val instanceof Date;
10042
+ };
10043
+
10044
+ var formatDate = function formatDate(date) {
10045
+ var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
10046
+
10047
+ // 处理多种输入类型
10048
+ if (!date) return '';
10049
+
10050
+ // 如果是时间戳,转成日期对象
10051
+ if (typeof date === 'number') {
10052
+ date = new Date(date);
10053
+ }
10054
+ // 如果是字符串,转成日期对象
10055
+ if (typeof date === 'string') {
10056
+ date = new Date(date);
10057
+ }
10058
+
10059
+ // 调用toDate进一步验证和转换
10060
+ date = toDate(date);
10061
+ if (!date) return '';
10062
+
10063
+ // 兼容大写和小写的格式标记
10064
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
10065
+ var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
10066
+
10067
+ // 使用fecha库进行格式化,支持中文配置
10068
+ var str = fecha.format(date, lowercaseFormat, getSettings());
10069
+ return str;
10070
+ };
10071
+
10072
+ var parseDate = function parseDate(string, format) {
10073
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
10074
+ };
10075
+
10076
+ var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
10077
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
10078
+ return 30;
10079
+ }
10080
+
10081
+ if (month === 1) {
10082
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
10083
+ return 29;
10084
+ } else {
10085
+ return 28;
10086
+ }
10087
+ }
10088
+
10089
+ return 31;
10090
+ };
10091
+
10092
+ var getDayCountOfYear = function getDayCountOfYear(year) {
10093
+ var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
10094
+ return isLeapYear ? 366 : 365;
10095
+ };
10096
+
10097
+ var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
10098
+ var temp = new Date(date.getTime());
10099
+ temp.setDate(1);
10100
+ return temp.getDay();
10101
+ };
10102
+
10103
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
10104
+ // {prev, next} Date should work for Daylight Saving Time
10105
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
10106
+ var prevDate = function prevDate(date) {
10107
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
10108
+
10109
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
10110
+ };
10111
+
10112
+ var nextDate = function nextDate(date) {
10113
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
10114
+
10115
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
10116
+ };
10117
+
10118
+ var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
10119
+ var result = new Date(year, month, 1);
10120
+ var day = result.getDay();
10121
+
10122
+ if (day === 0) {
10123
+ return prevDate(result, 7);
10124
+ } else {
10125
+ return prevDate(result, day);
10126
+ }
10127
+ };
10128
+
10129
+ var getWeekNumber = function getWeekNumber(date) {
10130
+ // 支持多种输入类型
10131
+ if (!date || !isDate(date)) {
10132
+ date = new Date();
10133
+ }
10134
+ if (typeof date === 'string') {
10135
+ date = new Date(date);
10136
+ }
10137
+
10138
+ // 验证日期有效性
10139
+ if (!isDate(date)) return null;
10140
+
10141
+ var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
10142
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
10143
+ // 将星期日的星期数设为7
10144
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
10145
+ // 获取当年的第一天
10146
+ var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
10147
+ // 计算到最近的星期四的完整周数
10148
+ var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
10149
+ // 返回周数
10150
+ return weekNo;
10151
+ };
10152
+
10153
+ var getRangeHours = function getRangeHours(ranges) {
10154
+ var hours = [];
10155
+ var disabledHours = [];
10156
+
10157
+ (ranges || []).forEach(function (range) {
10158
+ var value = range.map(function (date) {
10159
+ return date.getHours();
10160
+ });
10161
+
10162
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
10163
+ });
10164
+
10165
+ if (disabledHours.length) {
10166
+ for (var i = 0; i < 24; i++) {
10167
+ hours[i] = disabledHours.indexOf(i) === -1;
10168
+ }
10169
+ } else {
10170
+ for (var _i = 0; _i < 24; _i++) {
10171
+ hours[_i] = false;
10172
+ }
10173
+ }
10174
+
10175
+ return hours;
10176
+ };
10177
+
10178
+ var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
10179
+ if (amount <= 0) return [];
10180
+ var temp = new Date(date.getTime());
10181
+ temp.setDate(0);
10182
+ var lastDay = temp.getDate();
10183
+ return range(amount).map(function (_, index) {
10184
+ return lastDay - (amount - index - 1);
10185
+ });
10186
+ };
10187
+
10188
+ var getMonthDays = function getMonthDays(date) {
10189
+ var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
10190
+ var days = temp.getDate();
10191
+ return range(days).map(function (_, index) {
10192
+ return index + 1;
10193
+ });
10194
+ };
10195
+
10196
+ function setRangeData(arr, start, end, value) {
10197
+ for (var i = start; i < end; i++) {
10198
+ arr[i] = value;
10199
+ }
10200
+ }
10201
+
10202
+ var getRangeMinutes = function getRangeMinutes(ranges, hour) {
10203
+ var minutes = new Array(60);
10204
+
10205
+ if (ranges.length > 0) {
10206
+ ranges.forEach(function (range) {
10207
+ var start = range[0];
10208
+ var end = range[1];
10209
+ var startHour = start.getHours();
10210
+ var startMinute = start.getMinutes();
10211
+ var endHour = end.getHours();
10212
+ var endMinute = end.getMinutes();
10213
+ if (startHour === hour && endHour !== hour) {
10214
+ setRangeData(minutes, startMinute, 60, true);
10215
+ } else if (startHour === hour && endHour === hour) {
10216
+ setRangeData(minutes, startMinute, endMinute + 1, true);
10217
+ } else if (startHour !== hour && endHour === hour) {
10218
+ setRangeData(minutes, 0, endMinute + 1, true);
10219
+ } else if (startHour < hour && endHour > hour) {
10220
+ setRangeData(minutes, 0, 60, true);
10221
+ }
10222
+ });
10223
+ } else {
10224
+ setRangeData(minutes, 0, 60, true);
10225
+ }
10226
+ return minutes;
10227
+ };
10228
+
10229
+ var range = function range(n) {
10230
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
10231
+ return Array.apply(null, { length: n }).map(function (_, n) {
10232
+ return n;
10233
+ });
10234
+ };
10235
+
10236
+ var modifyDate = function modifyDate(date, y, m, d) {
10237
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
10238
+ };
10239
+
10240
+ var modifyTime = function modifyTime(date, h, m, s) {
10241
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
10242
+ };
10243
+
10244
+ var modifyWithTimeString = function modifyWithTimeString(date, time) {
10245
+ if (date == null || !time) {
10246
+ return date;
10247
+ }
10248
+ time = parseDate(time, 'HH:mm:ss');
10249
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
10250
+ };
10251
+
10252
+ var clearTime = function clearTime(date) {
10253
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
10254
+ };
10255
+
10256
+ var clearMilliseconds = function clearMilliseconds(date) {
10257
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
10258
+ };
10259
+
10260
+ var limitTimeRange = function limitTimeRange(date, ranges) {
10261
+ var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
10262
+
10263
+ // TODO: refactory a more elegant solution
10264
+ if (ranges.length === 0) return date;
10265
+ var normalizeDate = function normalizeDate(date) {
10266
+ return fecha.parse(fecha.format(date, format), format);
10267
+ };
10268
+ var ndate = normalizeDate(date);
10269
+ var nranges = ranges.map(function (range) {
10270
+ return range.map(normalizeDate);
10271
+ });
10272
+ if (nranges.some(function (nrange) {
10273
+ return ndate >= nrange[0] && ndate <= nrange[1];
10274
+ })) return date;
10275
+
10276
+ var minDate = nranges[0][0];
10277
+ var maxDate = nranges[0][0];
10278
+
10279
+ nranges.forEach(function (nrange) {
10280
+ minDate = new Date(Math.min(nrange[0], minDate));
10281
+ maxDate = new Date(Math.max(nrange[1], minDate));
10282
+ });
10283
+
10284
+ var ret = ndate < minDate ? minDate : maxDate;
10285
+ // preserve Year/Month/Date
10286
+ return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
10287
+ };
10288
+
10289
+ var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
10290
+ var limitedDate = limitTimeRange(date, selectableRange, format);
10291
+ return limitedDate.getTime() === date.getTime();
10292
+ };
10293
+
10294
+ var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
10295
+ // clamp date to the number of days in `year`, `month`
10296
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
10297
+ var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
10298
+ return modifyDate(date, year, month, monthDate);
10299
+ };
10300
+
10301
+ var prevMonth = function prevMonth(date) {
10302
+ var year = date.getFullYear();
10303
+ var month = date.getMonth();
10304
+ return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
10305
+ };
10306
+
10307
+ var nextMonth = function nextMonth(date) {
10308
+ var year = date.getFullYear();
10309
+ var month = date.getMonth();
10310
+ return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
10311
+ };
10312
+
10313
+ var prevYear = function prevYear(date) {
10314
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
10315
+
10316
+ var year = date.getFullYear();
10317
+ var month = date.getMonth();
10318
+ return changeYearMonthAndClampDate(date, year - amount, month);
10319
+ };
10320
+
10321
+ var nextYear = function nextYear(date) {
10322
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
10323
+
10324
+ var year = date.getFullYear();
10325
+ var month = date.getMonth();
10326
+ return changeYearMonthAndClampDate(date, year + amount, month);
10327
+ };
10328
+
10329
+ var extractDateFormat = function extractDateFormat(format) {
10330
+ return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
10331
+ };
10332
+
10333
+ var extractTimeFormat = function extractTimeFormat(format) {
10334
+ return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
10335
+ };
10336
+
10337
+ var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
10338
+ return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
10339
+ };
10340
+
10341
+ /**
10342
+ * 计算两个日期之间的工作日数量(不包括周末和节假日)
10343
+ * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
10344
+ * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
10345
+ * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
10466
10346
  * @returns {number} 工作日数量
10467
- */
10468
- const calculateNetworkDays = function (start_date, end_date, holidays = []) {
10469
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
10470
- throw new Error(
10471
- "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
10472
- );
10473
- }
10474
-
10475
- const startDateObj = new Date(start_date);
10476
- const endDateObj = new Date(end_date);
10477
-
10478
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
10479
- throw new Error(
10480
- "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
10481
- );
10482
- }
10483
-
10484
- if (startDateObj > endDateObj) {
10485
- throw new Error('Start date should be earlier than or equal to end date.');
10486
- }
10487
-
10488
- let workdays = 0;
10489
-
10490
- // Iterate through each day in the date range
10491
- for (
10492
- let currentDate = new Date(startDateObj);
10493
- currentDate <= endDateObj;
10494
- currentDate.setDate(currentDate.getDate() + 1)
10495
- ) {
10496
- // Check if the current day is a weekend (Saturday or Sunday)
10497
- const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
10498
-
10499
- // Check if the current day is a holiday
10500
- const isHoliday = holidays.some((holiday) => {
10501
- const holidayDate = new Date(holiday);
10502
- return currentDate.toDateString() === holidayDate.toDateString();
10503
- });
10504
-
10505
- // If it's a workday (not a weekend or holiday), increment the workdays count
10506
- if (!isWeekend && !isHoliday) {
10507
- workdays++;
10508
- }
10509
- }
10510
-
10511
- return workdays;
10512
- };
10513
-
10347
+ */
10348
+ var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
10349
+ var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
10350
+
10351
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
10352
+ throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
10353
+ }
10354
+
10355
+ var startDateObj = new Date(start_date);
10356
+ var endDateObj = new Date(end_date);
10357
+
10358
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
10359
+ throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
10360
+ }
10361
+
10362
+ if (startDateObj > endDateObj) {
10363
+ throw new Error('Start date should be earlier than or equal to end date.');
10364
+ }
10365
+
10366
+ var workdays = 0;
10367
+
10368
+ // Iterate through each day in the date range
10369
+
10370
+ var _loop = function _loop(currentDate) {
10371
+ // Check if the current day is a weekend (Saturday or Sunday)
10372
+ var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
10373
+
10374
+ // Check if the current day is a holiday
10375
+ var isHoliday = holidays.some(function (holiday) {
10376
+ var holidayDate = new Date(holiday);
10377
+ return currentDate.toDateString() === holidayDate.toDateString();
10378
+ });
10379
+
10380
+ // If it's a workday (not a weekend or holiday), increment the workdays count
10381
+ if (!isWeekend && !isHoliday) {
10382
+ workdays++;
10383
+ }
10384
+ };
10385
+
10386
+ for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
10387
+ _loop(currentDate);
10388
+ }
10389
+
10390
+ return workdays;
10391
+ };
10392
+
10514
10393
  /**
10515
10394
  * 日期加减天数
10516
10395
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
10517
10396
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
10518
10397
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
10519
- */
10520
- const dateAddDays = function (start_date, days) {
10521
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
10522
- throw new Error(
10523
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
10524
- );
10525
- }
10526
-
10527
- const startDateObj = new Date(start_date);
10528
- if (isNaN(startDateObj.getTime())) {
10529
- throw new Error(
10530
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
10531
- );
10532
- }
10533
-
10534
- const resultDateObj = new Date(startDateObj);
10535
- resultDateObj.setDate(resultDateObj.getDate() + days);
10536
-
10537
- const resultYear = resultDateObj.getFullYear();
10538
- const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
10539
- const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
10540
-
10541
- return `${resultYear}-${resultMonth}-${resultDay}`;
10542
- };
10543
-
10398
+ */
10399
+ var dateAddDays = function dateAddDays(start_date, days) {
10400
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
10401
+ 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.");
10402
+ }
10403
+
10404
+ var startDateObj = new Date(start_date);
10405
+ if (isNaN(startDateObj.getTime())) {
10406
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
10407
+ }
10408
+
10409
+ var resultDateObj = new Date(startDateObj);
10410
+ resultDateObj.setDate(resultDateObj.getDate() + days);
10411
+
10412
+ var resultYear = resultDateObj.getFullYear();
10413
+ var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
10414
+ var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
10415
+
10416
+ return resultYear + '-' + resultMonth + '-' + resultDay;
10417
+ };
10418
+
10544
10419
  /**
10545
10420
  * 计算两个日期之间的差值
10546
10421
  * @date 2023年12月14日
@@ -10548,186 +10423,286 @@ const dateAddDays = function (start_date, days) {
10548
10423
  * @param {String} end_date - 结束日期字符串
10549
10424
  * @param {String} unit - 单位:year/month/day
10550
10425
  * @returns {Number} 差值
10551
- */
10552
- const dateDiff = function (start_date, end_date, unit = 'day') {
10553
- // Assuming date strings are in "YYYY-MM-DD" format
10554
- var startDate = new Date(start_date);
10555
- var endDate = new Date(end_date);
10556
-
10557
- // If the date is invalid, return 0
10558
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
10559
- return 0;
10560
- }
10561
-
10562
- if (unit === 'year') {
10563
- return endDate.getFullYear() - startDate.getFullYear();
10564
- } else if (unit === 'month') {
10565
- return (
10566
- (endDate.getFullYear() - startDate.getFullYear()) * 12 +
10567
- (endDate.getMonth() - startDate.getMonth())
10568
- );
10569
- } else {
10570
- // Default to day
10571
- var timeDifference = endDate - startDate;
10572
- // Calculate days (86400000 milliseconds per day)
10573
- return Math.floor(timeDifference / 86400000);
10574
- }
10575
- };
10576
-
10426
+ */
10427
+ var dateDiff = function dateDiff(start_date, end_date) {
10428
+ var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
10429
+
10430
+ // Assuming date strings are in "YYYY-MM-DD" format
10431
+ var startDate = new Date(start_date);
10432
+ var endDate = new Date(end_date);
10433
+
10434
+ // If the date is invalid, return 0
10435
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
10436
+ return 0;
10437
+ }
10438
+
10439
+ if (unit === 'year') {
10440
+ return endDate.getFullYear() - startDate.getFullYear();
10441
+ } else if (unit === 'month') {
10442
+ return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
10443
+ } else {
10444
+ // Default to day
10445
+ var timeDifference = endDate - startDate;
10446
+ // Calculate days (86400000 milliseconds per day)
10447
+ return Math.floor(timeDifference / 86400000);
10448
+ }
10449
+ };
10450
+
10577
10451
  /**
10578
10452
  * 获取月份中的日期
10579
10453
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
10580
10454
  * @returns {number} 月份中的日期(1-31)
10581
- */
10582
- const dayOfMonth = function (date) {
10583
- if (typeof date !== 'string') {
10584
- throw new Error(
10585
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
10586
- );
10587
- }
10588
-
10589
- const dateObj = new Date(date);
10590
- if (isNaN(dateObj.getTime())) {
10591
- throw new Error(
10592
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
10593
- );
10594
- }
10595
-
10596
- return dateObj.getDate();
10597
- };
10598
-
10455
+ */
10456
+ var dayOfMonth = function dayOfMonth(date) {
10457
+ if (typeof date !== 'string') {
10458
+ throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
10459
+ }
10460
+
10461
+ var dateObj = new Date(date);
10462
+ if (isNaN(dateObj.getTime())) {
10463
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
10464
+ }
10465
+
10466
+ return dateObj.getDate();
10467
+ };
10468
+
10599
10469
  /**
10600
10470
  * 获取当前日期
10601
10471
  * @date 2022年5月7日
10602
10472
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
10603
10473
  * @returns {string} 当前日期的格式化字符串
10604
- */
10605
- const getCurrentDate = function (format = 'YYYY-MM-DD') {
10606
- return formatDate(new Date(), format);
10607
- };
10608
-
10474
+ */
10475
+ var getCurrentDate = function getCurrentDate() {
10476
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
10477
+
10478
+ return formatDate(new Date(), format);
10479
+ };
10480
+
10609
10481
  /**
10610
10482
  * 获取当前日期时间
10611
10483
  * @date 2022年5月7日
10612
10484
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
10613
10485
  * @returns {string} 当前日期时间的格式化字符串
10614
- */
10615
- const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
10616
- return formatDate(new Date(), format);
10617
- };
10618
-
10486
+ */
10487
+ var getCurrentDateTime = function getCurrentDateTime() {
10488
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
10489
+
10490
+ return formatDate(new Date(), format);
10491
+ };
10492
+
10619
10493
  /**
10620
10494
  * 获取小时
10621
10495
  * @date 2022年5月7日
10622
10496
  * @param {Date|string} [date] - 日期对象或日期字符串
10623
10497
  * @returns {number} 小时数(0-23)
10624
- */
10625
- const getHour = function (date) {
10626
- if (!date) {
10627
- return new Date().getHours();
10628
- }
10629
- if (typeof date === 'string') {
10630
- date = new Date(date);
10631
- }
10632
- return date.getHours();
10633
- };
10634
-
10498
+ */
10499
+ var getHour = function getHour(date) {
10500
+ if (!date) {
10501
+ return new Date().getHours();
10502
+ }
10503
+ if (typeof date === 'string') {
10504
+ date = new Date(date);
10505
+ }
10506
+ return date.getHours();
10507
+ };
10508
+
10635
10509
  /**
10636
10510
  * 获取分钟
10637
10511
  * @date 2022年5月7日
10638
10512
  * @param {Date|string} [date] - 日期对象或日期字符串
10639
10513
  * @returns {number} 分钟数(0-59)
10640
- */
10641
- const getMinute = function (date) {
10642
- if (!date) {
10643
- return new Date().getMinutes();
10644
- }
10645
- if (typeof date === 'string') {
10646
- date = new Date(date);
10647
- }
10648
- return date.getMinutes();
10649
- };
10650
-
10514
+ */
10515
+ var getMinute = function getMinute(date) {
10516
+ if (!date) {
10517
+ return new Date().getMinutes();
10518
+ }
10519
+ if (typeof date === 'string') {
10520
+ date = new Date(date);
10521
+ }
10522
+ return date.getMinutes();
10523
+ };
10524
+
10651
10525
  /**
10652
10526
  * 获取月份
10653
10527
  * @date 2022年5月7日
10654
10528
  * @param {Date|string} [date] - 日期对象或日期字符串
10655
10529
  * @returns {number} 月份数(1-12)
10656
- */
10657
- const getMonth = function (date) {
10658
- if (!date) {
10659
- return new Date().getMonth() + 1;
10660
- }
10661
- if (typeof date === 'string') {
10662
- date = new Date(date);
10663
- }
10664
- return date.getMonth() + 1;
10665
- };
10666
-
10530
+ */
10531
+ var getMonth = function getMonth(date) {
10532
+ if (!date) {
10533
+ return new Date().getMonth() + 1;
10534
+ }
10535
+ if (typeof date === 'string') {
10536
+ date = new Date(date);
10537
+ }
10538
+ return date.getMonth() + 1;
10539
+ };
10540
+
10667
10541
  /**
10668
10542
  * 获取秒
10669
10543
  * @date 2022年5月7日
10670
10544
  * @param {Date|string} [date] - 日期对象或日期字符串
10671
10545
  * @returns {number} 秒数(0-59)
10672
- */
10673
- const getSecond = function (date) {
10674
- if (!date) {
10675
- return new Date().getSeconds();
10676
- }
10677
- if (typeof date === 'string') {
10678
- date = new Date(date);
10679
- }
10680
- return date.getSeconds();
10681
- };
10682
-
10546
+ */
10547
+ var getSecond = function getSecond(date) {
10548
+ if (!date) {
10549
+ return new Date().getSeconds();
10550
+ }
10551
+ if (typeof date === 'string') {
10552
+ date = new Date(date);
10553
+ }
10554
+ return date.getSeconds();
10555
+ };
10556
+
10683
10557
  /**
10684
10558
  * 获取星期几
10685
10559
  * @date 2022年5月7日
10686
10560
  * @param {Date|string} [date] - 日期对象或日期字符串
10687
10561
  * @returns {number} 星期几(0-6,0表示星期日)
10688
- */
10689
- const getWeekday = function (date) {
10690
- if (!date) {
10691
- return new Date().getDay();
10692
- }
10693
- if (typeof date === 'string') {
10694
- date = new Date(date);
10695
- }
10696
- return date.getDay();
10697
- };
10698
-
10699
-
10562
+ */
10563
+ var getWeekday = function getWeekday(date) {
10564
+ if (!date) {
10565
+ return new Date().getDay();
10566
+ }
10567
+ if (typeof date === 'string') {
10568
+ date = new Date(date);
10569
+ }
10570
+ return date.getDay();
10571
+ };
10572
+
10700
10573
  /**
10701
10574
  * @desc 获取上午/下午/晚上
10702
10575
  * @author huangbo
10703
10576
  * @date 2022年5月7日
10704
10577
  * @param {String} [time] - 时间
10705
- **/
10706
- const timeCycle = function (time) {
10707
- let hour = 0;
10708
- if (!time) {
10709
- hour = new Date().getHours();
10710
- } else if (typeof time === 'string') {
10711
- // 从时间字符串中提取小时
10712
- const match = time.match(/^(\d{1,2})/);
10713
- if (match) {
10714
- hour = parseInt(match[1], 10);
10715
- }
10716
- } else if (typeof time === 'number') {
10717
- hour = time;
10718
- }
10719
- // 判断时间段
10720
- if (hour >= 5 && hour < 12) {
10721
- return '上午';
10722
- } else if (hour >= 12 && hour < 18) {
10723
- return '下午';
10724
- } else {
10725
- return '晚上';
10726
- }
10578
+ **/
10579
+ var timeCycle = function timeCycle(time) {
10580
+ var hour = 0;
10581
+ if (!time) {
10582
+ hour = new Date().getHours();
10583
+ } else if (typeof time === 'string') {
10584
+ // 从时间字符串中提取小时
10585
+ var match = time.match(/^(\d{1,2})/);
10586
+ if (match) {
10587
+ hour = parseInt(match[1], 10);
10588
+ }
10589
+ } else if (typeof time === 'number') {
10590
+ hour = time;
10591
+ }
10592
+ // 判断时间段
10593
+ if (hour >= 5 && hour < 12) {
10594
+ return '上午';
10595
+ } else if (hour >= 12 && hour < 18) {
10596
+ return '下午';
10597
+ } else {
10598
+ return '晚上';
10599
+ }
10727
10600
  };
10728
10601
 
10729
10602
  /***/ }),
10730
10603
 
10604
+ /***/ 70:
10605
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
10606
+
10607
+ "use strict";
10608
+ /* harmony import */ var eoss_src_utils_dom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
10609
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10610
+
10611
+
10612
+
10613
+ var Transition = function () {
10614
+ function Transition() {
10615
+ _classCallCheck(this, Transition);
10616
+ }
10617
+
10618
+ Transition.prototype.beforeEnter = function beforeEnter(el) {
10619
+ Object(eoss_src_utils_dom__WEBPACK_IMPORTED_MODULE_0__[/* addClass */ "a"])(el, 'collapse-transition');
10620
+ if (!el.dataset) el.dataset = {};
10621
+ if (el.dataset.state === 6 || !el.dataset.state) {
10622
+ el.dataset.oldPaddingTop = el.style.paddingTop;
10623
+ el.dataset.oldPaddingBottom = el.style.paddingBottom;
10624
+ }
10625
+ el.dataset.state = 1;
10626
+
10627
+ el.style.height = '0';
10628
+ el.style.paddingTop = 0;
10629
+ el.style.paddingBottom = 0;
10630
+ };
10631
+
10632
+ Transition.prototype.enter = function enter(el) {
10633
+ el.dataset.oldOverflow = el.style.overflow;
10634
+ if (el.scrollHeight !== 0) {
10635
+ el.style.height = el.scrollHeight + 'px';
10636
+ el.style.paddingTop = el.dataset.oldPaddingTop;
10637
+ el.style.paddingBottom = el.dataset.oldPaddingBottom;
10638
+ } else {
10639
+ el.style.height = '';
10640
+ el.style.paddingTop = el.dataset.oldPaddingTop;
10641
+ el.style.paddingBottom = el.dataset.oldPaddingBottom;
10642
+ }
10643
+
10644
+ el.dataset.state = 2;
10645
+ el.style.overflow = 'hidden';
10646
+ };
10647
+
10648
+ Transition.prototype.afterEnter = function afterEnter(el) {
10649
+ // for safari: remove class then reset height is necessary
10650
+ Object(eoss_src_utils_dom__WEBPACK_IMPORTED_MODULE_0__[/* removeClass */ "i"])(el, 'collapse-transition');
10651
+ el.style.height = '';
10652
+ el.style.overflow = el.dataset.oldOverflow;
10653
+ el.dataset.state = 3;
10654
+ };
10655
+
10656
+ Transition.prototype.beforeLeave = function beforeLeave(el) {
10657
+ if (!el.dataset) el.dataset = {};
10658
+ el.dataset.oldPaddingTop = el.style.paddingTop;
10659
+ el.dataset.oldPaddingBottom = el.style.paddingBottom;
10660
+ el.dataset.oldOverflow = el.style.overflow;
10661
+ el.dataset.state = 4;
10662
+
10663
+ el.style.height = el.scrollHeight + 'px';
10664
+ el.style.overflow = 'hidden';
10665
+ };
10666
+
10667
+ Transition.prototype.leave = function leave(el) {
10668
+ if (el.scrollHeight !== 0) {
10669
+ // for safari: add class after set height, or it will jump to zero height suddenly, weired
10670
+ Object(eoss_src_utils_dom__WEBPACK_IMPORTED_MODULE_0__[/* addClass */ "a"])(el, 'collapse-transition');
10671
+ el.style.height = 0;
10672
+ el.style.paddingTop = 0;
10673
+ el.style.paddingBottom = 0;
10674
+ el.dataset.state = 5;
10675
+ }
10676
+ };
10677
+
10678
+ Transition.prototype.afterLeave = function afterLeave(el) {
10679
+ Object(eoss_src_utils_dom__WEBPACK_IMPORTED_MODULE_0__[/* removeClass */ "i"])(el, 'collapse-transition');
10680
+ el.style.height = '';
10681
+ el.style.overflow = el.dataset.oldOverflow;
10682
+ el.style.paddingTop = el.dataset.oldPaddingTop;
10683
+ el.style.paddingBottom = el.dataset.oldPaddingBottom;
10684
+ el.dataset.state = 6;
10685
+ };
10686
+
10687
+ return Transition;
10688
+ }();
10689
+
10690
+ /* harmony default export */ __webpack_exports__["a"] = ({
10691
+ name: 'EsCollapseTransition',
10692
+ functional: true,
10693
+ render: function render(h, _ref) {
10694
+ var children = _ref.children;
10695
+
10696
+ var data = {
10697
+ on: new Transition()
10698
+ };
10699
+
10700
+ return h('transition', data, children);
10701
+ }
10702
+ });
10703
+
10704
+ /***/ }),
10705
+
10731
10706
  /***/ 8:
10732
10707
  /***/ (function(module, exports) {
10733
10708