@yelon/util 15.2.0 → 15.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +22 -22
  3. package/array/array-type.service.d.ts +68 -68
  4. package/array/array.service.d.ts +78 -78
  5. package/array/index.d.ts +2 -2
  6. package/browser/cookie.service.d.ts +67 -67
  7. package/browser/copy.d.ts +6 -6
  8. package/browser/index.d.ts +5 -5
  9. package/browser/is-empty.d.ts +6 -6
  10. package/browser/scroll.service.d.ts +37 -37
  11. package/browser/style.d.ts +21 -21
  12. package/config/abc/date-picker.type.d.ts +52 -52
  13. package/config/abc/error-collect.type.d.ts +10 -10
  14. package/config/abc/exception.type.d.ts +9 -9
  15. package/config/abc/image.type.d.ts +15 -15
  16. package/config/abc/index.d.ts +17 -17
  17. package/config/abc/loading.type.d.ts +31 -31
  18. package/config/abc/lodop.type.d.ts +33 -33
  19. package/config/abc/media.type.d.ts +11 -11
  20. package/config/abc/onboarding.type.d.ts +4 -4
  21. package/config/abc/page-header.type.d.ts +39 -39
  22. package/config/abc/pdf.type.d.ts +35 -35
  23. package/config/abc/qr.type.d.ts +25 -25
  24. package/config/abc/se.type.d.ts +32 -32
  25. package/config/abc/sg.type.d.ts +10 -10
  26. package/config/abc/st.type.d.ts +465 -465
  27. package/config/abc/sv.type.d.ts +14 -14
  28. package/config/abc/xlsx.type.d.ts +12 -12
  29. package/config/abc/zip.type.d.ts +10 -10
  30. package/config/acl/acl.type.d.ts +32 -32
  31. package/config/auth/auth.type.d.ts +55 -55
  32. package/config/bis/bis.type.d.ts +7 -7
  33. package/config/cache/cache.type.d.ts +40 -40
  34. package/config/chart/chart.type.d.ts +33 -33
  35. package/config/config.service.d.ts +13 -13
  36. package/config/config.types.d.ts +48 -48
  37. package/config/index.d.ts +14 -14
  38. package/config/mock/mock.type.d.ts +18 -18
  39. package/config/sf/sf.type.d.ts +133 -133
  40. package/config/socket/socket.type.d.ts +4 -4
  41. package/config/theme/http.type.d.ts +14 -14
  42. package/config/theme/i18n.type.d.ts +14 -14
  43. package/config/theme/index.d.ts +3 -3
  44. package/config/theme/responsive.type.d.ts +12 -12
  45. package/config/util/array.type.d.ts +22 -22
  46. package/config/util/currency.type.d.ts +39 -39
  47. package/date-time/index.d.ts +2 -2
  48. package/date-time/picker.d.ts +68 -68
  49. package/date-time/time.d.ts +29 -29
  50. package/decorator/convert.d.ts +24 -24
  51. package/decorator/index.d.ts +2 -2
  52. package/decorator/zone-outside.d.ts +35 -35
  53. package/esm2020/array/array-type.service.mjs +1 -1
  54. package/esm2020/array/array.mjs +4 -4
  55. package/esm2020/array/array.service.mjs +276 -276
  56. package/esm2020/array/index.mjs +2 -2
  57. package/esm2020/browser/browser.mjs +4 -4
  58. package/esm2020/browser/cookie.service.mjs +102 -102
  59. package/esm2020/browser/copy.mjs +27 -27
  60. package/esm2020/browser/index.mjs +5 -5
  61. package/esm2020/browser/is-empty.mjs +18 -18
  62. package/esm2020/browser/scroll.service.mjs +87 -87
  63. package/esm2020/browser/style.mjs +37 -37
  64. package/esm2020/config/abc/date-picker.type.mjs +1 -1
  65. package/esm2020/config/abc/error-collect.type.mjs +1 -1
  66. package/esm2020/config/abc/exception.type.mjs +1 -1
  67. package/esm2020/config/abc/image.type.mjs +1 -1
  68. package/esm2020/config/abc/index.mjs +17 -17
  69. package/esm2020/config/abc/loading.type.mjs +1 -1
  70. package/esm2020/config/abc/lodop.type.mjs +1 -1
  71. package/esm2020/config/abc/media.type.mjs +1 -1
  72. package/esm2020/config/abc/onboarding.type.mjs +1 -1
  73. package/esm2020/config/abc/page-header.type.mjs +1 -1
  74. package/esm2020/config/abc/pdf.type.mjs +1 -1
  75. package/esm2020/config/abc/qr.type.mjs +1 -1
  76. package/esm2020/config/abc/se.type.mjs +1 -1
  77. package/esm2020/config/abc/sg.type.mjs +1 -1
  78. package/esm2020/config/abc/st.type.mjs +1 -1
  79. package/esm2020/config/abc/sv.type.mjs +2 -2
  80. package/esm2020/config/abc/xlsx.type.mjs +1 -1
  81. package/esm2020/config/abc/zip.type.mjs +1 -1
  82. package/esm2020/config/acl/acl.type.mjs +1 -1
  83. package/esm2020/config/auth/auth.type.mjs +1 -1
  84. package/esm2020/config/bis/bis.type.mjs +1 -1
  85. package/esm2020/config/cache/cache.type.mjs +1 -1
  86. package/esm2020/config/chart/chart.type.mjs +1 -1
  87. package/esm2020/config/config.mjs +4 -4
  88. package/esm2020/config/config.service.mjs +36 -36
  89. package/esm2020/config/config.types.mjs +8 -8
  90. package/esm2020/config/index.mjs +14 -14
  91. package/esm2020/config/mock/mock.type.mjs +1 -1
  92. package/esm2020/config/sf/sf.type.mjs +1 -1
  93. package/esm2020/config/socket/socket.type.mjs +1 -1
  94. package/esm2020/config/theme/http.type.mjs +1 -1
  95. package/esm2020/config/theme/i18n.type.mjs +1 -1
  96. package/esm2020/config/theme/index.mjs +3 -3
  97. package/esm2020/config/theme/responsive.type.mjs +1 -1
  98. package/esm2020/config/util/array.type.mjs +1 -1
  99. package/esm2020/config/util/currency.type.mjs +1 -1
  100. package/esm2020/date-time/date-time.mjs +4 -4
  101. package/esm2020/date-time/index.mjs +2 -2
  102. package/esm2020/date-time/picker.mjs +115 -115
  103. package/esm2020/date-time/time.mjs +88 -88
  104. package/esm2020/decorator/convert.mjs +57 -57
  105. package/esm2020/decorator/decorator.mjs +4 -4
  106. package/esm2020/decorator/index.mjs +2 -2
  107. package/esm2020/decorator/zone-outside.mjs +56 -56
  108. package/esm2020/form/form.mjs +4 -4
  109. package/esm2020/form/index.mjs +2 -2
  110. package/esm2020/form/match-control.mjs +29 -29
  111. package/esm2020/form/validators.mjs +80 -80
  112. package/esm2020/format/currency.service.mjs +237 -237
  113. package/esm2020/format/currency.types.mjs +7 -7
  114. package/esm2020/format/format.mjs +4 -4
  115. package/esm2020/format/index.mjs +4 -4
  116. package/esm2020/format/string.mjs +84 -84
  117. package/esm2020/format/validate.mjs +93 -93
  118. package/esm2020/index.mjs +11 -11
  119. package/esm2020/math/in-range.mjs +24 -24
  120. package/esm2020/math/index.mjs +2 -2
  121. package/esm2020/math/math.mjs +4 -4
  122. package/esm2020/math/round.mjs +52 -52
  123. package/esm2020/other/assert.mjs +66 -66
  124. package/esm2020/other/deep.mjs +77 -77
  125. package/esm2020/other/favicon.mjs +28 -28
  126. package/esm2020/other/index.mjs +7 -7
  127. package/esm2020/other/lazy.service.mjs +131 -131
  128. package/esm2020/other/logger.mjs +32 -32
  129. package/esm2020/other/other.mjs +4 -4
  130. package/esm2020/other/path-to-regexp.service.mjs +238 -238
  131. package/esm2020/other/resize.mjs +3 -3
  132. package/esm2020/pipes/currency/cny.pipe.mjs +22 -22
  133. package/esm2020/pipes/currency/index.mjs +4 -4
  134. package/esm2020/pipes/currency/mega.pipe.mjs +28 -28
  135. package/esm2020/pipes/currency/module.mjs +18 -18
  136. package/esm2020/pipes/currency/pipe-currency.mjs +4 -4
  137. package/esm2020/pipes/currency/price.pipe.mjs +26 -26
  138. package/esm2020/pipes/filter/filter.pipe.mjs +18 -18
  139. package/esm2020/pipes/filter/index.mjs +2 -2
  140. package/esm2020/pipes/filter/module.mjs +16 -16
  141. package/esm2020/pipes/filter/pipe-filter.mjs +4 -4
  142. package/esm2020/pipes/format/index.mjs +2 -2
  143. package/esm2020/pipes/format/mask.pipe.mjs +33 -33
  144. package/esm2020/pipes/format/module.mjs +16 -16
  145. package/esm2020/pipes/format/pipe-format.mjs +4 -4
  146. package/esm2020/pipes/index.mjs +3 -3
  147. package/esm2020/pipes/pipes.mjs +4 -4
  148. package/esm2020/token/index.mjs +2 -2
  149. package/esm2020/token/page-visibility.mjs +14 -14
  150. package/esm2020/token/token.mjs +4 -4
  151. package/esm2020/token/window.mjs +16 -16
  152. package/esm2020/yelon-util.mjs +4 -4
  153. package/fesm2015/array.mjs +254 -254
  154. package/fesm2015/browser.mjs +283 -283
  155. package/fesm2015/config.mjs +56 -56
  156. package/fesm2015/date-time.mjs +207 -207
  157. package/fesm2015/decorator.mjs +121 -121
  158. package/fesm2015/form.mjs +118 -118
  159. package/fesm2015/format.mjs +413 -413
  160. package/fesm2015/math.mjs +85 -85
  161. package/fesm2015/other.mjs +589 -589
  162. package/fesm2015/pipe-currency.mjs +96 -96
  163. package/fesm2015/pipe-filter.mjs +40 -40
  164. package/fesm2015/pipe-format.mjs +55 -55
  165. package/fesm2015/pipes.mjs +8 -8
  166. package/fesm2015/token.mjs +37 -37
  167. package/fesm2015/yelon-util.mjs +16 -16
  168. package/fesm2020/array.mjs +284 -284
  169. package/fesm2020/browser.mjs +279 -279
  170. package/fesm2020/config.mjs +54 -54
  171. package/fesm2020/date-time.mjs +211 -211
  172. package/fesm2020/decorator.mjs +121 -121
  173. package/fesm2020/form.mjs +118 -118
  174. package/fesm2020/format.mjs +431 -431
  175. package/fesm2020/math.mjs +85 -85
  176. package/fesm2020/other.mjs +586 -586
  177. package/fesm2020/pipe-currency.mjs +94 -94
  178. package/fesm2020/pipe-filter.mjs +40 -40
  179. package/fesm2020/pipe-format.mjs +55 -55
  180. package/fesm2020/pipes.mjs +8 -8
  181. package/fesm2020/token.mjs +37 -37
  182. package/fesm2020/yelon-util.mjs +16 -16
  183. package/form/index.d.ts +2 -2
  184. package/form/match-control.d.ts +15 -15
  185. package/form/validators.d.ts +62 -62
  186. package/format/currency.service.d.ts +37 -37
  187. package/format/currency.types.d.ts +77 -77
  188. package/format/index.d.ts +4 -4
  189. package/format/string.d.ts +44 -44
  190. package/format/validate.d.ts +72 -72
  191. package/index.d.ts +11 -11
  192. package/math/in-range.d.ts +14 -14
  193. package/math/index.d.ts +2 -2
  194. package/math/round.d.ts +33 -33
  195. package/other/assert.d.ts +36 -36
  196. package/other/deep.d.ts +35 -35
  197. package/other/favicon.d.ts +2 -2
  198. package/other/index.d.ts +7 -7
  199. package/other/lazy.service.d.ts +48 -48
  200. package/other/logger.d.ts +5 -5
  201. package/other/path-to-regexp.service.d.ts +26 -26
  202. package/other/resize.d.ts +1 -1
  203. package/package.json +157 -157
  204. package/pipes/currency/cny.pipe.d.ts +15 -15
  205. package/pipes/currency/index.d.ts +4 -4
  206. package/pipes/currency/mega.pipe.d.ts +16 -16
  207. package/pipes/currency/module.d.ts +9 -9
  208. package/pipes/currency/price.pipe.d.ts +19 -19
  209. package/pipes/filter/filter.pipe.d.ts +13 -13
  210. package/pipes/filter/index.d.ts +2 -2
  211. package/pipes/filter/module.d.ts +7 -7
  212. package/pipes/format/index.d.ts +2 -2
  213. package/pipes/format/mask.pipe.d.ts +27 -27
  214. package/pipes/format/module.d.ts +7 -7
  215. package/pipes/index.d.ts +3 -3
  216. package/token/index.d.ts +2 -2
  217. package/token/page-visibility.d.ts +8 -8
  218. package/token/window.d.ts +7 -7
@@ -1,116 +1,116 @@
1
- import { addDays, addSeconds, differenceInCalendarDays, format } from 'date-fns';
2
- // TODO: timezone process
3
- export class DateTimePickerUtil {
4
- /**
5
- * Current local time
6
- *
7
- * 当前本地时间
8
- */
9
- get now() {
10
- return new Date();
11
- }
12
- /**
13
- * Current local date (not including time part)
14
- *
15
- * 当前本地日期(不包含时间部分)
16
- */
17
- get date() {
18
- return this.removeTime(this.now);
19
- }
20
- /**
21
- * Remove the time part of the date
22
- *
23
- * 移除日期的时间部分
24
- */
25
- removeTime(d) {
26
- return new Date(d.toDateString());
27
- }
28
- /**
29
- * Format date-time
30
- *
31
- * 格式化日期
32
- */
33
- format(d, formatString = 'yyyy-MM-dd HH:mm:ss') {
34
- return format(d, formatString);
35
- }
36
- genTick(count) {
37
- return new Array(count).fill(0).map((_, idx) => idx);
38
- }
39
- /**
40
- * Calculate the number of days between two dates, `0` means the same day
41
- *
42
- * 计算两个日期相差天数,`0` 表示同一天
43
- */
44
- getDiffDays(dateLeft, dateRight) {
45
- return differenceInCalendarDays(dateLeft, typeof dateRight === 'number' ? addDays(this.date, dateRight) : dateRight || this.date);
46
- }
47
- /**
48
- * Disabled Before date (Default: today), Generally serves `nzDisabledDate`
49
- *
50
- * 禁用之前日期(默认:今天),一般服务于 `nzDisabledDate`
51
- */
52
- disabledBeforeDate(options) {
53
- return (d) => this.getDiffDays(d, options?.offsetDays) < 0;
54
- }
55
- /**
56
- * Disabled After date (Default: today), Generally serves `nzDisabledDate`
57
- *
58
- * 禁用之后日期(默认:今天),一般服务于 `nzDisabledDate`
59
- */
60
- disabledAfterDate(options) {
61
- return (d) => this.getDiffDays(d, options?.offsetDays) > 0;
62
- }
63
- baseDisabledTime(type, offsetSeconds) {
64
- const tick24 = this.genTick(24);
65
- const tick60 = this.genTick(60);
66
- return (current) => {
67
- const cur = current;
68
- if (cur == null) {
69
- return {};
70
- }
71
- const now = addSeconds(this.now, offsetSeconds || 0);
72
- const nowHours = now.getHours();
73
- const nowMinutes = now.getMinutes();
74
- const curHours = cur.getHours();
75
- const isToday = this.getDiffDays(this.removeTime(cur)) === 0;
76
- return {
77
- nzDisabledHours: () => {
78
- if (!isToday)
79
- return [];
80
- return type === 'before' ? tick24.slice(0, nowHours) : tick24.slice(nowHours + 1);
81
- },
82
- nzDisabledMinutes: () => {
83
- if (isToday && curHours === nowHours) {
84
- return type === 'before' ? tick60.slice(0, nowMinutes) : tick60.slice(nowMinutes + 1);
85
- }
86
- return [];
87
- },
88
- nzDisabledSeconds: () => {
89
- if (isToday && curHours === nowHours && cur.getMinutes() === nowMinutes) {
90
- const nowSeconds = now.getSeconds();
91
- return type === 'before' ? tick60.slice(0, nowSeconds) : tick60.slice(nowSeconds + 1);
92
- }
93
- return [];
94
- }
95
- };
96
- };
97
- }
98
- /**
99
- * Disabled Before time (Default: now), Generally serves `nzDisabledTime`
100
- *
101
- * 禁用之前时间(默认:现在),一般服务于 `nzDisabledTime`
102
- */
103
- disabledBeforeTime(options) {
104
- return this.baseDisabledTime('before', options?.offsetSeconds);
105
- }
106
- /**
107
- * Disabled After time (Default: now), Generally serves `nzDisabledTime`
108
- *
109
- * 禁用之后时间(默认:现在),一般服务于 `nzDisabledTime`
110
- */
111
- disabledAfterTime(options) {
112
- return this.baseDisabledTime('after', options?.offsetSeconds);
113
- }
114
- }
115
- export const dateTimePickerUtil = new DateTimePickerUtil();
1
+ import { addDays, addSeconds, differenceInCalendarDays, format } from 'date-fns';
2
+ // TODO: timezone process
3
+ export class DateTimePickerUtil {
4
+ /**
5
+ * Current local time
6
+ *
7
+ * 当前本地时间
8
+ */
9
+ get now() {
10
+ return new Date();
11
+ }
12
+ /**
13
+ * Current local date (not including time part)
14
+ *
15
+ * 当前本地日期(不包含时间部分)
16
+ */
17
+ get date() {
18
+ return this.removeTime(this.now);
19
+ }
20
+ /**
21
+ * Remove the time part of the date
22
+ *
23
+ * 移除日期的时间部分
24
+ */
25
+ removeTime(d) {
26
+ return new Date(d.toDateString());
27
+ }
28
+ /**
29
+ * Format date-time
30
+ *
31
+ * 格式化日期
32
+ */
33
+ format(d, formatString = 'yyyy-MM-dd HH:mm:ss') {
34
+ return format(d, formatString);
35
+ }
36
+ genTick(count) {
37
+ return new Array(count).fill(0).map((_, idx) => idx);
38
+ }
39
+ /**
40
+ * Calculate the number of days between two dates, `0` means the same day
41
+ *
42
+ * 计算两个日期相差天数,`0` 表示同一天
43
+ */
44
+ getDiffDays(dateLeft, dateRight) {
45
+ return differenceInCalendarDays(dateLeft, typeof dateRight === 'number' ? addDays(this.date, dateRight) : dateRight || this.date);
46
+ }
47
+ /**
48
+ * Disabled Before date (Default: today), Generally serves `nzDisabledDate`
49
+ *
50
+ * 禁用之前日期(默认:今天),一般服务于 `nzDisabledDate`
51
+ */
52
+ disabledBeforeDate(options) {
53
+ return (d) => this.getDiffDays(d, options?.offsetDays) < 0;
54
+ }
55
+ /**
56
+ * Disabled After date (Default: today), Generally serves `nzDisabledDate`
57
+ *
58
+ * 禁用之后日期(默认:今天),一般服务于 `nzDisabledDate`
59
+ */
60
+ disabledAfterDate(options) {
61
+ return (d) => this.getDiffDays(d, options?.offsetDays) > 0;
62
+ }
63
+ baseDisabledTime(type, offsetSeconds) {
64
+ const tick24 = this.genTick(24);
65
+ const tick60 = this.genTick(60);
66
+ return (current) => {
67
+ const cur = current;
68
+ if (cur == null) {
69
+ return {};
70
+ }
71
+ const now = addSeconds(this.now, offsetSeconds || 0);
72
+ const nowHours = now.getHours();
73
+ const nowMinutes = now.getMinutes();
74
+ const curHours = cur.getHours();
75
+ const isToday = this.getDiffDays(this.removeTime(cur)) === 0;
76
+ return {
77
+ nzDisabledHours: () => {
78
+ if (!isToday)
79
+ return [];
80
+ return type === 'before' ? tick24.slice(0, nowHours) : tick24.slice(nowHours + 1);
81
+ },
82
+ nzDisabledMinutes: () => {
83
+ if (isToday && curHours === nowHours) {
84
+ return type === 'before' ? tick60.slice(0, nowMinutes) : tick60.slice(nowMinutes + 1);
85
+ }
86
+ return [];
87
+ },
88
+ nzDisabledSeconds: () => {
89
+ if (isToday && curHours === nowHours && cur.getMinutes() === nowMinutes) {
90
+ const nowSeconds = now.getSeconds();
91
+ return type === 'before' ? tick60.slice(0, nowSeconds) : tick60.slice(nowSeconds + 1);
92
+ }
93
+ return [];
94
+ }
95
+ };
96
+ };
97
+ }
98
+ /**
99
+ * Disabled Before time (Default: now), Generally serves `nzDisabledTime`
100
+ *
101
+ * 禁用之前时间(默认:现在),一般服务于 `nzDisabledTime`
102
+ */
103
+ disabledBeforeTime(options) {
104
+ return this.baseDisabledTime('before', options?.offsetSeconds);
105
+ }
106
+ /**
107
+ * Disabled After time (Default: now), Generally serves `nzDisabledTime`
108
+ *
109
+ * 禁用之后时间(默认:现在),一般服务于 `nzDisabledTime`
110
+ */
111
+ disabledAfterTime(options) {
112
+ return this.baseDisabledTime('after', options?.offsetSeconds);
113
+ }
114
+ }
115
+ export const dateTimePickerUtil = new DateTimePickerUtil();
116
116
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGlja2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvdXRpbC9kYXRlLXRpbWUvcGlja2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOi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Vtb3ZlVGltZShjdXIpKSA9PT0gMDtcbiAgICAgIHJldHVybiB7XG4gICAgICAgIG56RGlzYWJsZWRIb3VyczogKCkgPT4ge1xuICAgICAgICAgIGlmICghaXNUb2RheSkgcmV0dXJuIFtdO1xuICAgICAgICAgIHJldHVybiB0eXBlID09PSAnYmVmb3JlJyA/IHRpY2syNC5zbGljZSgwLCBub3dIb3VycykgOiB0aWNrMjQuc2xpY2Uobm93SG91cnMgKyAxKTtcbiAgICAgICAgfSxcbiAgICAgICAgbnpEaXNhYmxlZE1pbnV0ZXM6ICgpID0+IHtcbiAgICAgICAgICBpZiAoaXNUb2RheSAmJiBjdXJIb3VycyA9PT0gbm93SG91cnMpIHtcbiAgICAgICAgICAgIHJldHVybiB0eXBlID09PSAnYmVmb3JlJyA/IHRpY2s2MC5zbGljZSgwLCBub3dNaW51dGVzKSA6IHRpY2s2MC5zbGljZShub3dNaW51dGVzICsgMSk7XG4gICAgICAgICAgfVxuICAgICAgICAgIHJldHVybiBbXTtcbiAgICAgICAgfSxcbiAgICAgICAgbnpEaXNhYmxlZFNlY29uZHM6ICgpID0+IHtcbiAgICAgICAgICBpZiAoaXNUb2RheSAmJiBjdXJIb3VycyA9PT0gbm93SG91cnMgJiYgY3VyLmdldE1pbnV0ZXMoKSA9PT0gbm93TWludXRlcykge1xuICAgICAgICAgICAgY29uc3Qgbm93U2Vjb25kcyA9IG5vdy5nZXRTZWNvbmRzKCk7XG4gICAgICAgICAgICByZXR1cm4gdHlwZSA9PT0gJ2JlZm9yZScgPyB0aWNrNjAuc2xpY2UoMCwgbm93U2Vjb25kcykgOiB0aWNrNjAuc2xpY2Uobm93U2Vjb25kcyArIDEpO1xuICAgICAgICAgIH1cbiAgICAgICAgICByZXR1cm4gW107XG4gICAgICAgIH1cbiAgICAgIH07XG4gICAgfTtcbiAgfVxuICAvKipcbiAgICogRGlzYWJsZWQgQmVmb3JlIHRpbWUgKERlZmF1bHQ6IG5vdyksIEdlbmVyYWxseSBzZXJ2ZXMgYG56RGlzYWJsZWRUaW1lYFxuICAgKlxuICAgKiDnpoHnlKjkuYvliY3ml7bpl7TvvIjpu5jorqTvvJrnjrDlnKjvvInvvIzkuIDoiKzmnI3liqHkuo4gYG56RGlzYWJsZWRUaW1lYFxuICAgKi9cbiAgZGlzYWJsZWRCZWZvcmVUaW1lKG9wdGlvbnM/OiB7IG9mZnNldFNlY29uZHM/OiBudW1iZXIgfSk6IERpc2FibGVkVGltZUZuIHtcbiAgICByZXR1cm4gdGhpcy5iYXNlRGlzYWJsZWRUaW1lKCdiZWZvcmUnLCBvcHRpb25zPy5vZmZzZXRTZWNvbmRzKTtcbiAgfVxuICAvKipcbiAgICogRGlzYWJsZWQgQWZ0ZXIgdGltZSAoRGVmYXVsdDogbm93KSwgR2VuZXJhbGx5IHNlcnZlcyBgbnpEaXNhYmxlZFRpbWVgXG4gICAqXG4gICAqIOemgeeUqOS5i+WQjuaXtumXtO+8iOm7mOiupO+8mueOsOWcqO+8ie+8jOS4gOiIrOacjeWKoeS6jiBgbnpEaXNhYmxlZFRpbWVgXG4gICAqL1xuICBkaXNhYmxlZEFmdGVyVGltZShvcHRpb25zPzogeyBvZmZzZXRTZWNvbmRzPzogbnVtYmVyIH0pOiBEaXNhYmxlZFRpbWVGbiB7XG4gICAgcmV0dXJuIHRoaXMuYmFzZURpc2FibGVkVGltZSgnYWZ0ZXInLCBvcHRpb25zPy5vZmZzZXRTZWNvbmRzKTtcbiAgfVxufVxuXG5leHBvcnQgY29uc3QgZGF0ZVRpbWVQaWNrZXJVdGlsID0gbmV3IERhdGVUaW1lUGlja2VyVXRpbCgpO1xuIl19
@@ -1,89 +1,89 @@
1
- import { addDays, endOfDay, endOfMonth, endOfWeek, endOfYear, parse, parseISO, startOfDay, startOfMonth, startOfWeek, startOfYear, subMonths, subWeeks, subYears } from 'date-fns';
2
- /**
3
- * Get the time range, return `[ Date, Date]` for the start and end dates
4
- *
5
- * 获取时间范围
6
- *
7
- * @param type 类型,带 `-` 表示过去一个时间,若指定 `number` 表示天数
8
- * @param time 开始时间
9
- * @param ignoreMaxTime 忽略追加结束日期的最大时间值
10
- */
11
- export function getTimeDistance(type, time, options) {
12
- time = time
13
- ? typeof time === 'string'
14
- ? parse(time, 'yyyy-MM-dd HH:mm:ss', new Date())
15
- : new Date(time)
16
- : new Date();
17
- const opt = { weekStartsOn: 1 };
18
- let res;
19
- switch (type) {
20
- case 'today':
21
- res = [time, time];
22
- break;
23
- case '-today':
24
- res = [addDays(time, -1), time];
25
- break;
26
- case 'yesterday':
27
- res = [addDays(time, -1), addDays(time, -1)];
28
- break;
29
- case 'week':
30
- res = [startOfWeek(time, opt), endOfWeek(time, opt)];
31
- break;
32
- case '-week':
33
- res = [startOfWeek(subWeeks(time, 1), opt), endOfWeek(subWeeks(time, 1), opt)];
34
- break;
35
- case 'month':
36
- res = [startOfMonth(time), endOfMonth(time)];
37
- break;
38
- case '-month':
39
- res = [startOfMonth(subMonths(time, 1)), endOfMonth(subMonths(time, 1))];
40
- break;
41
- case 'year':
42
- res = [startOfYear(time), endOfYear(time)];
43
- break;
44
- case '-year':
45
- res = [startOfYear(subYears(time, 1)), endOfYear(subYears(time, 1))];
46
- break;
47
- default:
48
- res = type > 0 ? [time, addDays(time, type)] : [addDays(time, type), time];
49
- break;
50
- }
51
- return options?.ignoreMaxTime ? res : fixEndTimeOfRange(res);
52
- }
53
- /**
54
- * fix time is the most, big value
55
- */
56
- export function fixEndTimeOfRange(dates) {
57
- return [startOfDay(dates[0]), endOfDay(dates[1])];
58
- }
59
- /**
60
- * Return the date parsed from string using the given format string
61
- * - If the argument is a number, it is treated as a timestamp.
62
- *
63
- * @param formatString If parsing fails try to parse the date by pressing `formatString`
64
- * @param defaultValue If parsing fails returned default value, default: `new Date(NaN)`
65
- */
66
- export function toDate(value, options) {
67
- if (typeof options === 'string')
68
- options = { formatString: options };
69
- const { formatString, defaultValue } = {
70
- formatString: 'yyyy-MM-dd HH:mm:ss',
71
- defaultValue: new Date(NaN),
72
- ...options
73
- };
74
- if (value == null) {
75
- return defaultValue;
76
- }
77
- if (value instanceof Date) {
78
- return value;
79
- }
80
- if (typeof value === 'number' || (typeof value === 'string' && /[0-9]{10,13}/.test(value))) {
81
- return new Date(+value);
82
- }
83
- let tryDate = parseISO(value);
84
- if (isNaN(tryDate)) {
85
- tryDate = parse(value, formatString, new Date());
86
- }
87
- return isNaN(tryDate) ? defaultValue : tryDate;
88
- }
1
+ import { addDays, endOfDay, endOfMonth, endOfWeek, endOfYear, parse, parseISO, startOfDay, startOfMonth, startOfWeek, startOfYear, subMonths, subWeeks, subYears } from 'date-fns';
2
+ /**
3
+ * Get the time range, return `[ Date, Date]` for the start and end dates
4
+ *
5
+ * 获取时间范围
6
+ *
7
+ * @param type 类型,带 `-` 表示过去一个时间,若指定 `number` 表示天数
8
+ * @param time 开始时间
9
+ * @param ignoreMaxTime 忽略追加结束日期的最大时间值
10
+ */
11
+ export function getTimeDistance(type, time, options) {
12
+ time = time
13
+ ? typeof time === 'string'
14
+ ? parse(time, 'yyyy-MM-dd HH:mm:ss', new Date())
15
+ : new Date(time)
16
+ : new Date();
17
+ const opt = { weekStartsOn: 1 };
18
+ let res;
19
+ switch (type) {
20
+ case 'today':
21
+ res = [time, time];
22
+ break;
23
+ case '-today':
24
+ res = [addDays(time, -1), time];
25
+ break;
26
+ case 'yesterday':
27
+ res = [addDays(time, -1), addDays(time, -1)];
28
+ break;
29
+ case 'week':
30
+ res = [startOfWeek(time, opt), endOfWeek(time, opt)];
31
+ break;
32
+ case '-week':
33
+ res = [startOfWeek(subWeeks(time, 1), opt), endOfWeek(subWeeks(time, 1), opt)];
34
+ break;
35
+ case 'month':
36
+ res = [startOfMonth(time), endOfMonth(time)];
37
+ break;
38
+ case '-month':
39
+ res = [startOfMonth(subMonths(time, 1)), endOfMonth(subMonths(time, 1))];
40
+ break;
41
+ case 'year':
42
+ res = [startOfYear(time), endOfYear(time)];
43
+ break;
44
+ case '-year':
45
+ res = [startOfYear(subYears(time, 1)), endOfYear(subYears(time, 1))];
46
+ break;
47
+ default:
48
+ res = type > 0 ? [time, addDays(time, type)] : [addDays(time, type), time];
49
+ break;
50
+ }
51
+ return options?.ignoreMaxTime ? res : fixEndTimeOfRange(res);
52
+ }
53
+ /**
54
+ * fix time is the most, big value
55
+ */
56
+ export function fixEndTimeOfRange(dates) {
57
+ return [startOfDay(dates[0]), endOfDay(dates[1])];
58
+ }
59
+ /**
60
+ * Return the date parsed from string using the given format string
61
+ * - If the argument is a number, it is treated as a timestamp.
62
+ *
63
+ * @param formatString If parsing fails try to parse the date by pressing `formatString`
64
+ * @param defaultValue If parsing fails returned default value, default: `new Date(NaN)`
65
+ */
66
+ export function toDate(value, options) {
67
+ if (typeof options === 'string')
68
+ options = { formatString: options };
69
+ const { formatString, defaultValue } = {
70
+ formatString: 'yyyy-MM-dd HH:mm:ss',
71
+ defaultValue: new Date(NaN),
72
+ ...options
73
+ };
74
+ if (value == null) {
75
+ return defaultValue;
76
+ }
77
+ if (value instanceof Date) {
78
+ return value;
79
+ }
80
+ if (typeof value === 'number' || (typeof value === 'string' && /[0-9]{10,13}/.test(value))) {
81
+ return new Date(+value);
82
+ }
83
+ let tryDate = parseISO(value);
84
+ if (isNaN(tryDate)) {
85
+ tryDate = parse(value, formatString, new Date());
86
+ }
87
+ return isNaN(tryDate) ? defaultValue : tryDate;
88
+ }
89
89
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGltZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL3V0aWwvZGF0ZS10aW1lL3RpbWUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUNMLE9BQU8sRUFDUCxRQUFRLEVBQ1IsVUFBVSxFQUNWLFNBQVMsRUFDVCxTQUFTLEVBQ1QsS0FBSyxFQUNMLFFBQVEsRUFDUixVQUFVLEVBQ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B0aW9ucyA9PT0gJ3N0cmluZycpIG9wdGlvbnMgPSB7IGZvcm1hdFN0cmluZzogb3B0aW9ucyB9O1xuICBjb25zdCB7IGZvcm1hdFN0cmluZywgZGVmYXVsdFZhbHVlIH0gPSB7XG4gICAgZm9ybWF0U3RyaW5nOiAneXl5eS1NTS1kZCBISDptbTpzcycsXG4gICAgZGVmYXVsdFZhbHVlOiBuZXcgRGF0ZShOYU4pLFxuICAgIC4uLm9wdGlvbnNcbiAgfTtcbiAgaWYgKHZhbHVlID09IG51bGwpIHtcbiAgICByZXR1cm4gZGVmYXVsdFZhbHVlO1xuICB9XG4gIGlmICh2YWx1ZSBpbnN0YW5jZW9mIERhdGUpIHtcbiAgICByZXR1cm4gdmFsdWU7XG4gIH1cbiAgaWYgKHR5cGVvZiB2YWx1ZSA9PT0gJ251bWJlcicgfHwgKHR5cGVvZiB2YWx1ZSA9PT0gJ3N0cmluZycgJiYgL1swLTldezEwLDEzfS8udGVzdCh2YWx1ZSkpKSB7XG4gICAgcmV0dXJuIG5ldyBEYXRlKCt2YWx1ZSk7XG4gIH1cbiAgbGV0IHRyeURhdGUgPSBwYXJzZUlTTyh2YWx1ZSk7XG4gIGlmIChpc05hTih0cnlEYXRlIGFzIE56U2FmZUFueSkpIHtcbiAgICB0cnlEYXRlID0gcGFyc2UodmFsdWUsIGZvcm1hdFN0cmluZyEsIG5ldyBEYXRlKCkpO1xuICB9XG5cbiAgcmV0dXJuIGlzTmFOKHRyeURhdGUgYXMgTnpTYWZlQW55KSA/IGRlZmF1bHRWYWx1ZSA6IHRyeURhdGU7XG59XG4iXX0=
@@ -1,58 +1,58 @@
1
- import { warn } from '@yelon/util/other';
2
- function propDecoratorFactory(name, fallback, defaultValue) {
3
- function propDecorator(target, propName, originalDescriptor) {
4
- const privatePropName = `$$__${propName}`;
5
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
6
- if (Object.prototype.hasOwnProperty.call(target, privatePropName)) {
7
- warn(`The prop "${privatePropName}" is already exist, it will be overrided by ${name} decorator.`);
8
- }
9
- }
10
- Object.defineProperty(target, privatePropName, {
11
- configurable: true,
12
- writable: true
13
- });
14
- return {
15
- get() {
16
- return originalDescriptor && originalDescriptor.get
17
- ? originalDescriptor.get.bind(this)()
18
- : this[privatePropName];
19
- },
20
- set(value) {
21
- if (originalDescriptor && originalDescriptor.set) {
22
- originalDescriptor.set.bind(this)(fallback(value, defaultValue));
23
- }
24
- this[privatePropName] = fallback(value, defaultValue);
25
- }
26
- };
27
- }
28
- return propDecorator;
29
- }
30
- export function toBoolean(value, defaultValue = false) {
31
- return value == null ? defaultValue : `${value}` !== 'false';
32
- }
33
- /**
34
- * Input decorator that handle a prop to do get/set automatically with toBoolean
35
- *
36
- * ```ts
37
- * {AT}Input() {AT}InputBoolean() visible: boolean = false;
38
- * {AT}Input() {AT}InputBoolean(null) visible: boolean = false;
39
- * ```
40
- */
41
- export function InputBoolean(defaultValue = false) {
42
- return propDecoratorFactory('InputBoolean', toBoolean, defaultValue);
43
- }
44
- export function toNumber(value, fallbackValue = 0) {
45
- return !isNaN(parseFloat(value)) && !isNaN(Number(value)) ? Number(value) : fallbackValue;
46
- }
47
- /**
48
- * Input decorator that handle a prop to do get/set automatically with toNumber
49
- *
50
- * ```ts
51
- * {AT}Input() {AT}InputNumber() visible: number = 1;
52
- * {AT}Input() {AT}InputNumber(null) visible: number = 2;
53
- * ```
54
- */
55
- export function InputNumber(defaultValue = 0) {
56
- return propDecoratorFactory('InputNumber', toNumber, defaultValue);
57
- }
1
+ import { warn } from '@yelon/util/other';
2
+ function propDecoratorFactory(name, fallback, defaultValue) {
3
+ function propDecorator(target, propName, originalDescriptor) {
4
+ const privatePropName = `$$__${propName}`;
5
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
6
+ if (Object.prototype.hasOwnProperty.call(target, privatePropName)) {
7
+ warn(`The prop "${privatePropName}" is already exist, it will be overrided by ${name} decorator.`);
8
+ }
9
+ }
10
+ Object.defineProperty(target, privatePropName, {
11
+ configurable: true,
12
+ writable: true
13
+ });
14
+ return {
15
+ get() {
16
+ return originalDescriptor && originalDescriptor.get
17
+ ? originalDescriptor.get.bind(this)()
18
+ : this[privatePropName];
19
+ },
20
+ set(value) {
21
+ if (originalDescriptor && originalDescriptor.set) {
22
+ originalDescriptor.set.bind(this)(fallback(value, defaultValue));
23
+ }
24
+ this[privatePropName] = fallback(value, defaultValue);
25
+ }
26
+ };
27
+ }
28
+ return propDecorator;
29
+ }
30
+ export function toBoolean(value, defaultValue = false) {
31
+ return value == null ? defaultValue : `${value}` !== 'false';
32
+ }
33
+ /**
34
+ * Input decorator that handle a prop to do get/set automatically with toBoolean
35
+ *
36
+ * ```ts
37
+ * {AT}Input() {AT}InputBoolean() visible: boolean = false;
38
+ * {AT}Input() {AT}InputBoolean(null) visible: boolean = false;
39
+ * ```
40
+ */
41
+ export function InputBoolean(defaultValue = false) {
42
+ return propDecoratorFactory('InputBoolean', toBoolean, defaultValue);
43
+ }
44
+ export function toNumber(value, fallbackValue = 0) {
45
+ return !isNaN(parseFloat(value)) && !isNaN(Number(value)) ? Number(value) : fallbackValue;
46
+ }
47
+ /**
48
+ * Input decorator that handle a prop to do get/set automatically with toNumber
49
+ *
50
+ * ```ts
51
+ * {AT}Input() {AT}InputNumber() visible: number = 1;
52
+ * {AT}Input() {AT}InputNumber(null) visible: number = 2;
53
+ * ```
54
+ */
55
+ export function InputNumber(defaultValue = 0) {
56
+ return propDecoratorFactory('InputNumber', toNumber, defaultValue);
57
+ }
58
58
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udmVydC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL3V0aWwvZGVjb3JhdG9yL2NvbnZlcnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLElBQUksRUFBRSxNQUFNLG1CQUFtQixDQU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lclxuICpcbiAqIGBgYHRzXG4gKiB7QVR9SW5wdXQoKSB7QVR9SW5wdXROdW1iZXIoKSB2aXNpYmxlOiBudW1iZXIgPSAxO1xuICoge0FUfUlucHV0KCkge0FUfUlucHV0TnVtYmVyKG51bGwpIHZpc2libGU6IG51bWJlciA9IDI7XG4gKiBgYGBcbiAqL1xuZXhwb3J0IGZ1bmN0aW9uIElucHV0TnVtYmVyKGRlZmF1bHRWYWx1ZTogbnVtYmVyIHwgbnVsbCA9IDApOiBOelNhZmVBbnkge1xuICByZXR1cm4gcHJvcERlY29yYXRvckZhY3RvcnkoJ0lucHV0TnVtYmVyJywgdG9OdW1iZXIsIGRlZmF1bHRWYWx1ZSk7XG59XG4iXX0=
@@ -1,5 +1,5 @@
1
- /**
2
- * Generated bundle index. Do not edit.
3
- */
4
- export * from './index';
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ export * from './index';
5
5
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVjb3JhdG9yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvdXRpbC9kZWNvcmF0b3IvZGVjb3JhdG9yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBRUgsY0FBYyxTQUFTLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vaW5kZXgnO1xuIl19
@@ -1,3 +1,3 @@
1
- export * from './convert';
2
- export * from './zone-outside';
1
+ export * from './convert';
2
+ export * from './zone-outside';
3
3
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy91dGlsL2RlY29yYXRvci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLFdBQVcsQ0FBQztBQUMxQixjQUFjLGdCQUFnQixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9jb252ZXJ0JztcbmV4cG9ydCAqIGZyb20gJy4vem9uZS1vdXRzaWRlJztcbiJdfQ==