@yelon/util 12.0.19 → 13.0.0-beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (306) hide show
  1. package/{date-time/yelon-util-date-time.d.ts → array/array.d.ts} +1 -0
  2. package/array/array.service.d.ts +3 -0
  3. package/array/package.json +6 -7
  4. package/browser/browser.d.ts +1 -0
  5. package/browser/cookie.service.d.ts +3 -0
  6. package/browser/copy.d.ts +1 -1
  7. package/browser/package.json +5 -6
  8. package/browser/scroll.service.d.ts +3 -0
  9. package/config/config.d.ts +5 -0
  10. package/config/config.service.d.ts +3 -0
  11. package/config/package.json +6 -7
  12. package/date-time/date-time.d.ts +5 -0
  13. package/date-time/package.json +6 -7
  14. package/decorator/decorator.d.ts +5 -0
  15. package/decorator/package.json +6 -7
  16. package/{esm2015/array/array-type.service.js → esm2020/array/array-type.service.mjs} +0 -0
  17. package/esm2020/array/array.mjs +5 -0
  18. package/esm2020/array/array.service.mjs +278 -0
  19. package/{esm2015/array/index.js → esm2020/array/index.mjs} +0 -0
  20. package/{esm2015/browser/browser.js → esm2020/browser/browser.mjs} +0 -0
  21. package/esm2020/browser/cookie.service.mjs +103 -0
  22. package/esm2020/browser/copy.mjs +9 -0
  23. package/{esm2015/browser/index.js → esm2020/browser/index.mjs} +0 -0
  24. package/{esm2015/browser/is-empty.js → esm2020/browser/is-empty.mjs} +0 -0
  25. package/esm2020/browser/scroll.service.mjs +88 -0
  26. package/{esm2015/browser/style.js → esm2020/browser/style.mjs} +2 -2
  27. package/{esm2015/config/abc/date-picker.type.js → esm2020/config/abc/date-picker.type.mjs} +0 -0
  28. package/{esm2015/config/abc/error-collect.type.js → esm2020/config/abc/error-collect.type.mjs} +0 -0
  29. package/{esm2015/config/abc/image.type.js → esm2020/config/abc/image.type.mjs} +0 -0
  30. package/{esm2015/config/abc/index.js → esm2020/config/abc/index.mjs} +0 -0
  31. package/{esm2015/config/abc/loading.type.js → esm2020/config/abc/loading.type.mjs} +0 -0
  32. package/{esm2015/config/abc/lodop.type.js → esm2020/config/abc/lodop.type.mjs} +0 -0
  33. package/{esm2015/config/abc/media.type.js → esm2020/config/abc/media.type.mjs} +0 -0
  34. package/{esm2015/config/abc/onboarding.type.js → esm2020/config/abc/onboarding.type.mjs} +0 -0
  35. package/{esm2015/config/abc/page-header.type.js → esm2020/config/abc/page-header.type.mjs} +0 -0
  36. package/{esm2015/config/abc/pdf.type.js → esm2020/config/abc/pdf.type.mjs} +0 -0
  37. package/{esm2015/config/abc/qr.type.js → esm2020/config/abc/qr.type.mjs} +0 -0
  38. package/{esm2015/config/abc/se.type.js → esm2020/config/abc/se.type.mjs} +0 -0
  39. package/{esm2015/config/abc/sg.type.js → esm2020/config/abc/sg.type.mjs} +0 -0
  40. package/{esm2015/config/abc/st.type.js → esm2020/config/abc/st.type.mjs} +0 -0
  41. package/{esm2015/config/abc/sv.type.js → esm2020/config/abc/sv.type.mjs} +0 -0
  42. package/{esm2015/config/abc/xlsx.type.js → esm2020/config/abc/xlsx.type.mjs} +0 -0
  43. package/{esm2015/config/abc/zip.type.js → esm2020/config/abc/zip.type.mjs} +0 -0
  44. package/{esm2015/config/acl/acl.type.js → esm2020/config/acl/acl.type.mjs} +0 -0
  45. package/{esm2015/config/auth/auth.type.js → esm2020/config/auth/auth.type.mjs} +0 -0
  46. package/{esm2015/config/bis/bis.type.js → esm2020/config/bis/bis.type.mjs} +0 -0
  47. package/{esm2015/config/cache/cache.type.js → esm2020/config/cache/cache.type.mjs} +0 -0
  48. package/{esm2015/config/chart/chart.type.js → esm2020/config/chart/chart.type.mjs} +0 -0
  49. package/esm2020/config/config.mjs +5 -0
  50. package/esm2020/config/config.service.mjs +37 -0
  51. package/{esm2015/config/config.types.js → esm2020/config/config.types.mjs} +0 -0
  52. package/{esm2015/config/index.js → esm2020/config/index.mjs} +0 -0
  53. package/{esm2015/config/mock/mock.type.js → esm2020/config/mock/mock.type.mjs} +0 -0
  54. package/{esm2015/config/sf/sf.type.js → esm2020/config/sf/sf.type.mjs} +0 -0
  55. package/{esm2015/config/stomp/stomp.type.js → esm2020/config/stomp/stomp.type.mjs} +0 -0
  56. package/{esm2015/config/theme/http.type.js → esm2020/config/theme/http.type.mjs} +0 -0
  57. package/{esm2015/config/theme/i18n.type.js → esm2020/config/theme/i18n.type.mjs} +0 -0
  58. package/{esm2015/config/theme/index.js → esm2020/config/theme/index.mjs} +0 -0
  59. package/{esm2015/config/theme/responsive.type.js → esm2020/config/theme/responsive.type.mjs} +0 -0
  60. package/{esm2015/config/util/array.type.js → esm2020/config/util/array.type.mjs} +0 -0
  61. package/{esm2015/config/util/currency.type.js → esm2020/config/util/currency.type.mjs} +0 -0
  62. package/esm2020/date-time/date-time.mjs +5 -0
  63. package/{esm2015/date-time/index.js → esm2020/date-time/index.mjs} +0 -0
  64. package/esm2020/date-time/picker.mjs +116 -0
  65. package/{esm2015/date-time/time.js → esm2020/date-time/time.mjs} +6 -2
  66. package/esm2020/decorator/convert.mjs +58 -0
  67. package/esm2020/decorator/decorator.mjs +5 -0
  68. package/{esm2015/decorator/index.js → esm2020/decorator/index.mjs} +0 -0
  69. package/esm2020/decorator/zone-outside.mjs +57 -0
  70. package/esm2020/form/form.mjs +5 -0
  71. package/{esm2015/form/index.js → esm2020/form/index.mjs} +0 -0
  72. package/{esm2015/form/match-control.js → esm2020/form/match-control.mjs} +0 -0
  73. package/{esm2015/form/validators.js → esm2020/form/validators.mjs} +0 -0
  74. package/esm2020/format/currency.service.mjs +238 -0
  75. package/{esm2015/format/currency.types.js → esm2020/format/currency.types.mjs} +0 -0
  76. package/esm2020/format/format.mjs +5 -0
  77. package/{esm2015/format/index.js → esm2020/format/index.mjs} +0 -0
  78. package/esm2020/format/string.mjs +85 -0
  79. package/{esm2015/format/validate.js → esm2020/format/validate.mjs} +0 -0
  80. package/{esm2015/index.js → esm2020/index.mjs} +0 -0
  81. package/{esm2015/math/in-range.js → esm2020/math/in-range.mjs} +0 -0
  82. package/{esm2015/math/index.js → esm2020/math/index.mjs} +0 -0
  83. package/esm2020/math/math.mjs +5 -0
  84. package/{esm2015/math/round.js → esm2020/math/round.mjs} +0 -0
  85. package/{esm2015/other/assert.js → esm2020/other/assert.mjs} +0 -0
  86. package/{esm2015/other/deep.js → esm2020/other/deep.mjs} +0 -0
  87. package/{esm2015/other/index.js → esm2020/other/index.mjs} +0 -0
  88. package/esm2020/other/lazy.service.mjs +119 -0
  89. package/{esm2015/other/logger.js → esm2020/other/logger.mjs} +0 -0
  90. package/esm2020/other/other.mjs +5 -0
  91. package/{esm2015/other/resize.js → esm2020/other/resize.mjs} +0 -0
  92. package/{esm2015/other/url.js → esm2020/other/url.mjs} +0 -0
  93. package/esm2020/pipes/currency/cny.pipe.mjs +23 -0
  94. package/{esm2015/pipes/currency/index.js → esm2020/pipes/currency/index.mjs} +2 -1
  95. package/esm2020/pipes/currency/mega.pipe.mjs +29 -0
  96. package/esm2020/pipes/currency/module.mjs +19 -0
  97. package/esm2020/pipes/currency/pipe-currency.mjs +5 -0
  98. package/esm2020/pipes/currency/price.pipe.mjs +27 -0
  99. package/esm2020/pipes/filter/filter.pipe.mjs +19 -0
  100. package/{esm2015/pipes/filter/index.js → esm2020/pipes/filter/index.mjs} +0 -0
  101. package/esm2020/pipes/filter/module.mjs +17 -0
  102. package/{esm2015/other/yelon-util-other.js → esm2020/pipes/filter/pipe-filter.mjs} +1 -1
  103. package/{esm2015/pipes/format/index.js → esm2020/pipes/format/index.mjs} +0 -0
  104. package/esm2020/pipes/format/mask.pipe.mjs +34 -0
  105. package/esm2020/pipes/format/module.mjs +17 -0
  106. package/{esm2015/array/yelon-util-array.js → esm2020/pipes/format/pipe-format.mjs} +1 -1
  107. package/{esm2015/pipes/index.js → esm2020/pipes/index.mjs} +0 -0
  108. package/esm2020/pipes/pipes.mjs +5 -0
  109. package/{esm2015/token/index.js → esm2020/token/index.mjs} +0 -0
  110. package/{esm2015/token/page-visibility.js → esm2020/token/page-visibility.mjs} +0 -0
  111. package/esm2020/token/token.mjs +5 -0
  112. package/{esm2015/token/window.js → esm2020/token/window.mjs} +0 -0
  113. package/{esm2015/yelon-util.js → esm2020/yelon-util.mjs} +0 -0
  114. package/fesm2015/{yelon-util-array.js → array.mjs} +8 -10
  115. package/fesm2015/array.mjs.map +1 -0
  116. package/fesm2015/{browser.js → browser.mjs} +28 -42
  117. package/fesm2015/browser.mjs.map +1 -0
  118. package/fesm2015/{yelon-util-config.js → config.mjs} +14 -8
  119. package/fesm2015/config.mjs.map +1 -0
  120. package/fesm2015/{yelon-util-date-time.js → date-time.mjs} +1 -1
  121. package/fesm2015/date-time.mjs.map +1 -0
  122. package/fesm2015/{yelon-util-decorator.js → decorator.mjs} +8 -4
  123. package/fesm2015/decorator.mjs.map +1 -0
  124. package/fesm2015/{yelon-util-form.js → form.mjs} +1 -1
  125. package/fesm2015/form.mjs.map +1 -0
  126. package/fesm2015/{yelon-util-format.js → format.mjs} +18 -14
  127. package/fesm2015/format.mjs.map +1 -0
  128. package/fesm2015/{yelon-util-math.js → math.mjs} +1 -1
  129. package/fesm2015/math.mjs.map +1 -0
  130. package/fesm2015/{yelon-util-other.js → other.mjs} +12 -9
  131. package/fesm2015/other.mjs.map +1 -0
  132. package/fesm2015/pipe-currency.mjs +96 -0
  133. package/fesm2015/pipe-currency.mjs.map +1 -0
  134. package/fesm2015/pipe-filter.mjs +40 -0
  135. package/fesm2015/pipe-filter.mjs.map +1 -0
  136. package/fesm2015/pipe-format.mjs +55 -0
  137. package/fesm2015/pipe-format.mjs.map +1 -0
  138. package/fesm2015/{yelon-util-pipes.js → pipes.mjs} +1 -1
  139. package/fesm2015/pipes.mjs.map +1 -0
  140. package/fesm2015/{yelon-util-token.js → token.mjs} +1 -1
  141. package/fesm2015/token.mjs.map +1 -0
  142. package/fesm2015/{yelon-util.js → yelon-util.mjs} +1 -1
  143. package/fesm2015/yelon-util.mjs.map +1 -0
  144. package/fesm2020/array.mjs +285 -0
  145. package/fesm2020/array.mjs.map +1 -0
  146. package/fesm2020/browser.mjs +260 -0
  147. package/fesm2020/browser.mjs.map +1 -0
  148. package/fesm2020/config.mjs +54 -0
  149. package/fesm2020/config.mjs.map +1 -0
  150. package/fesm2020/date-time.mjs +210 -0
  151. package/fesm2020/date-time.mjs.map +1 -0
  152. package/fesm2020/decorator.mjs +121 -0
  153. package/fesm2020/decorator.mjs.map +1 -0
  154. package/fesm2020/form.mjs +118 -0
  155. package/fesm2020/form.mjs.map +1 -0
  156. package/fesm2020/format.mjs +431 -0
  157. package/fesm2020/format.mjs.map +1 -0
  158. package/fesm2020/math.mjs +85 -0
  159. package/fesm2020/math.mjs.map +1 -0
  160. package/fesm2020/other.mjs +318 -0
  161. package/fesm2020/other.mjs.map +1 -0
  162. package/fesm2020/pipe-currency.mjs +94 -0
  163. package/fesm2020/pipe-currency.mjs.map +1 -0
  164. package/fesm2020/pipe-filter.mjs +40 -0
  165. package/fesm2020/pipe-filter.mjs.map +1 -0
  166. package/fesm2020/pipe-format.mjs +55 -0
  167. package/fesm2020/pipe-format.mjs.map +1 -0
  168. package/fesm2020/pipes.mjs +8 -0
  169. package/fesm2020/pipes.mjs.map +1 -0
  170. package/fesm2020/token.mjs +38 -0
  171. package/fesm2020/token.mjs.map +1 -0
  172. package/fesm2020/yelon-util.mjs +16 -0
  173. package/fesm2020/yelon-util.mjs.map +1 -0
  174. package/{array/yelon-util-array.d.ts → form/form.d.ts} +1 -0
  175. package/form/package.json +6 -7
  176. package/format/currency.service.d.ts +3 -0
  177. package/format/format.d.ts +5 -0
  178. package/format/package.json +6 -7
  179. package/{config/yelon-util-config.d.ts → math/math.d.ts} +1 -0
  180. package/math/package.json +6 -7
  181. package/other/lazy.service.d.ts +3 -0
  182. package/{decorator/yelon-util-decorator.d.ts → other/other.d.ts} +1 -0
  183. package/other/package.json +6 -7
  184. package/package.json +132 -8
  185. package/pipes/currency/cny.pipe.d.ts +3 -0
  186. package/pipes/currency/index.d.ts +1 -0
  187. package/pipes/currency/mega.pipe.d.ts +3 -0
  188. package/pipes/currency/module.d.ts +7 -0
  189. package/pipes/currency/package.json +6 -7
  190. package/pipes/currency/pipe-currency.d.ts +5 -0
  191. package/pipes/currency/price.pipe.d.ts +3 -0
  192. package/pipes/filter/filter.pipe.d.ts +3 -0
  193. package/pipes/filter/module.d.ts +5 -0
  194. package/pipes/filter/package.json +6 -7
  195. package/pipes/filter/pipe-filter.d.ts +5 -0
  196. package/pipes/format/mask.pipe.d.ts +3 -0
  197. package/pipes/format/module.d.ts +5 -0
  198. package/pipes/format/package.json +6 -7
  199. package/pipes/format/pipe-format.d.ts +5 -0
  200. package/pipes/package.json +6 -7
  201. package/pipes/pipes.d.ts +5 -0
  202. package/token/package.json +6 -7
  203. package/token/token.d.ts +5 -0
  204. package/yelon-util.d.ts +1 -0
  205. package/array/yelon-util-array.metadata.json +0 -1
  206. package/browser/browser.metadata.json +0 -1
  207. package/bundles/browser.umd.js +0 -325
  208. package/bundles/browser.umd.js.map +0 -1
  209. package/bundles/yelon-util-array.umd.js +0 -641
  210. package/bundles/yelon-util-array.umd.js.map +0 -1
  211. package/bundles/yelon-util-config.umd.js +0 -411
  212. package/bundles/yelon-util-config.umd.js.map +0 -1
  213. package/bundles/yelon-util-date-time.umd.js +0 -238
  214. package/bundles/yelon-util-date-time.umd.js.map +0 -1
  215. package/bundles/yelon-util-decorator.umd.js +0 -462
  216. package/bundles/yelon-util-decorator.umd.js.map +0 -1
  217. package/bundles/yelon-util-form.umd.js +0 -135
  218. package/bundles/yelon-util-form.umd.js.map +0 -1
  219. package/bundles/yelon-util-format.umd.js +0 -785
  220. package/bundles/yelon-util-format.umd.js.map +0 -1
  221. package/bundles/yelon-util-math.umd.js +0 -104
  222. package/bundles/yelon-util-math.umd.js.map +0 -1
  223. package/bundles/yelon-util-other.umd.js +0 -733
  224. package/bundles/yelon-util-other.umd.js.map +0 -1
  225. package/bundles/yelon-util-pipes-currency.umd.js +0 -108
  226. package/bundles/yelon-util-pipes-currency.umd.js.map +0 -1
  227. package/bundles/yelon-util-pipes-filter.umd.js +0 -374
  228. package/bundles/yelon-util-pipes-filter.umd.js.map +0 -1
  229. package/bundles/yelon-util-pipes-format.umd.js +0 -66
  230. package/bundles/yelon-util-pipes-format.umd.js.map +0 -1
  231. package/bundles/yelon-util-pipes.umd.js +0 -38
  232. package/bundles/yelon-util-pipes.umd.js.map +0 -1
  233. package/bundles/yelon-util-token.umd.js +0 -49
  234. package/bundles/yelon-util-token.umd.js.map +0 -1
  235. package/bundles/yelon-util.umd.js +0 -86
  236. package/bundles/yelon-util.umd.js.map +0 -1
  237. package/config/yelon-util-config.metadata.json +0 -1
  238. package/date-time/yelon-util-date-time.metadata.json +0 -1
  239. package/decorator/yelon-util-decorator.metadata.json +0 -1
  240. package/esm2015/array/array.service.js +0 -250
  241. package/esm2015/browser/cookie.service.js +0 -104
  242. package/esm2015/browser/copy.js +0 -27
  243. package/esm2015/browser/scroll.service.js +0 -89
  244. package/esm2015/config/config.service.js +0 -34
  245. package/esm2015/config/yelon-util-config.js +0 -5
  246. package/esm2015/date-time/picker.js +0 -116
  247. package/esm2015/date-time/yelon-util-date-time.js +0 -5
  248. package/esm2015/decorator/convert.js +0 -56
  249. package/esm2015/decorator/yelon-util-decorator.js +0 -5
  250. package/esm2015/decorator/zone-outside.js +0 -55
  251. package/esm2015/form/yelon-util-form.js +0 -5
  252. package/esm2015/format/currency.service.js +0 -225
  253. package/esm2015/format/string.js +0 -76
  254. package/esm2015/format/yelon-util-format.js +0 -5
  255. package/esm2015/math/yelon-util-math.js +0 -5
  256. package/esm2015/other/lazy.service.js +0 -118
  257. package/esm2015/pipes/currency/cny.pipe.js +0 -22
  258. package/esm2015/pipes/currency/mega.pipe.js +0 -26
  259. package/esm2015/pipes/currency/module.js +0 -14
  260. package/esm2015/pipes/currency/price.pipe.js +0 -26
  261. package/esm2015/pipes/currency/yelon-util-pipes-currency.js +0 -6
  262. package/esm2015/pipes/filter/filter.pipe.js +0 -15
  263. package/esm2015/pipes/filter/module.js +0 -12
  264. package/esm2015/pipes/filter/yelon-util-pipes-filter.js +0 -5
  265. package/esm2015/pipes/format/mask.pipe.js +0 -30
  266. package/esm2015/pipes/format/module.js +0 -12
  267. package/esm2015/pipes/format/yelon-util-pipes-format.js +0 -5
  268. package/esm2015/pipes/yelon-util-pipes.js +0 -5
  269. package/esm2015/token/yelon-util-token.js +0 -5
  270. package/fesm2015/browser.js.map +0 -1
  271. package/fesm2015/yelon-util-array.js.map +0 -1
  272. package/fesm2015/yelon-util-config.js.map +0 -1
  273. package/fesm2015/yelon-util-date-time.js.map +0 -1
  274. package/fesm2015/yelon-util-decorator.js.map +0 -1
  275. package/fesm2015/yelon-util-form.js.map +0 -1
  276. package/fesm2015/yelon-util-format.js.map +0 -1
  277. package/fesm2015/yelon-util-math.js.map +0 -1
  278. package/fesm2015/yelon-util-other.js.map +0 -1
  279. package/fesm2015/yelon-util-pipes-currency.js +0 -87
  280. package/fesm2015/yelon-util-pipes-currency.js.map +0 -1
  281. package/fesm2015/yelon-util-pipes-filter.js +0 -32
  282. package/fesm2015/yelon-util-pipes-filter.js.map +0 -1
  283. package/fesm2015/yelon-util-pipes-format.js +0 -47
  284. package/fesm2015/yelon-util-pipes-format.js.map +0 -1
  285. package/fesm2015/yelon-util-pipes.js.map +0 -1
  286. package/fesm2015/yelon-util-token.js.map +0 -1
  287. package/fesm2015/yelon-util.js.map +0 -1
  288. package/form/yelon-util-form.d.ts +0 -4
  289. package/form/yelon-util-form.metadata.json +0 -1
  290. package/format/yelon-util-format.d.ts +0 -4
  291. package/format/yelon-util-format.metadata.json +0 -1
  292. package/math/yelon-util-math.d.ts +0 -4
  293. package/math/yelon-util-math.metadata.json +0 -1
  294. package/other/yelon-util-other.d.ts +0 -4
  295. package/other/yelon-util-other.metadata.json +0 -1
  296. package/pipes/currency/yelon-util-pipes-currency.d.ts +0 -5
  297. package/pipes/currency/yelon-util-pipes-currency.metadata.json +0 -1
  298. package/pipes/filter/yelon-util-pipes-filter.d.ts +0 -4
  299. package/pipes/filter/yelon-util-pipes-filter.metadata.json +0 -1
  300. package/pipes/format/yelon-util-pipes-format.d.ts +0 -4
  301. package/pipes/format/yelon-util-pipes-format.metadata.json +0 -1
  302. package/pipes/yelon-util-pipes.d.ts +0 -4
  303. package/pipes/yelon-util-pipes.metadata.json +0 -1
  304. package/token/yelon-util-token.d.ts +0 -4
  305. package/token/yelon-util-token.metadata.json +0 -1
  306. package/yelon-util.metadata.json +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.mjs","sources":["../../../../packages/util/config/abc/sv.type.ts","../../../../packages/util/config/config.types.ts","../../../../packages/util/config/config.service.ts","../../../../packages/util/config/config.ts"],"sourcesContent":["export class YunzaiSVConfig {\n /** 大小,默认:`large` */\n size?: 'small' | 'large';\n /** 间距,默认:`32` */\n gutter?: number;\n /** 布局,默认:`horizontal` */\n layout?: 'horizontal' | 'vertical';\n /** 列数,默认:`3` */\n col?: number;\n /** 是否显示默认值,当内容为空值时显示 `-`,默认:`true` */\n default?: boolean;\n /** `label` 固定宽度,若 `null` 或 `undefined` 表示非固定,默认:`null` */\n labelWidth?: number;\n}\n","import { InjectionToken } from '@angular/core';\n\nimport {\n YunzaiDateRangePickerConfig,\n YunzaiErrorCollectConfig,\n YunzaiImageConfig,\n YunzaiLoadingConfig,\n YunzaiLodopConfig,\n YunzaiMediaConfig,\n YunzaiOnboardingConfig,\n YunzaiPageHeaderConfig,\n YunzaiPdfConfig,\n YunzaiQRConfig,\n YunzaiSEConfig,\n YunzaiSGConfig,\n YunzaiSTConfig,\n YunzaiSVConfig,\n YunzaiXlsxConfig,\n YunzaiZipConfig\n} from './abc/index';\nimport { YunzaiACLConfig } from './acl/acl.type';\nimport { YunzaiAuthConfig } from './auth/auth.type';\nimport { YunzaiBusinessConfig } from './bis/bis.type';\nimport { YunzaiCacheConfig } from './cache/cache.type';\nimport { YunzaiChartConfig } from './chart/chart.type';\nimport { YunzaiMockConfig } from './mock/mock.type';\nimport { YunzaiSFConfig } from './sf/sf.type';\nimport { YunzaiStompConfig } from './stomp/stomp.type';\nimport { YunzaiThemeHttpClientConfig } from './theme/http.type';\nimport { YunzaiThemeI18nConfig } from './theme/i18n.type';\nimport { YunzaiThemeResponsiveConfig } from './theme/responsive.type';\nimport { YunzaiUtilArrayConfig } from './util/array.type';\nimport { YunzaiUtilCurrencyConfig } from './util/currency.type';\n\nexport interface YunzaiConfig {\n bis?: YunzaiBusinessConfig;\n stomp?: YunzaiStompConfig;\n dataRange?: YunzaiDateRangePickerConfig;\n errorCollect?: YunzaiErrorCollectConfig;\n image?: YunzaiImageConfig;\n loading?: YunzaiLoadingConfig;\n onboarding?: YunzaiOnboardingConfig;\n lodop?: YunzaiLodopConfig;\n pageHeader?: YunzaiPageHeaderConfig;\n qr?: YunzaiQRConfig;\n se?: YunzaiSEConfig;\n sg?: YunzaiSGConfig;\n sv?: YunzaiSVConfig;\n st?: YunzaiSTConfig;\n sf?: YunzaiSFConfig;\n xlsx?: YunzaiXlsxConfig;\n zip?: YunzaiZipConfig;\n pdf?: YunzaiPdfConfig;\n media?: YunzaiMediaConfig;\n acl?: YunzaiACLConfig;\n auth?: YunzaiAuthConfig;\n cache?: YunzaiCacheConfig;\n chart?: YunzaiChartConfig;\n mock?: YunzaiMockConfig;\n utilArray?: YunzaiUtilArrayConfig;\n utilCurrency?: YunzaiUtilCurrencyConfig;\n themeHttp?: YunzaiThemeHttpClientConfig;\n themeResponsive?: YunzaiThemeResponsiveConfig;\n themeI18n?: YunzaiThemeI18nConfig;\n}\n\nexport type YunzaiConfigKey = keyof YunzaiConfig;\n\nexport const YUNZAI_CONFIG = new InjectionToken<YunzaiConfig>('yunzai-config', {\n providedIn: 'root',\n factory: YUNZAI_CONFIG_FACTORY\n});\n\nexport function YUNZAI_CONFIG_FACTORY(): YunzaiConfig {\n return {};\n}\n","import { Inject, Injectable, Optional } from '@angular/core';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nimport { deepMergeKey } from '@yelon/util/other';\n\nimport { YunzaiConfig, YunzaiConfigKey, YUNZAI_CONFIG } from './config.types';\n\n@Injectable({ providedIn: 'root' })\nexport class YunzaiConfigService {\n private config: YunzaiConfig;\n\n constructor(@Optional() @Inject(YUNZAI_CONFIG) defaultConfig?: YunzaiConfig) {\n this.config = { ...defaultConfig };\n }\n\n get<T extends YunzaiConfigKey>(componentName: T, key?: string): YunzaiConfig[T] {\n const res = ((this.config[componentName] as { [key: string]: unknown }) || {}) as NzSafeAny;\n return key ? { [key]: res[key] } : res;\n }\n\n merge<T extends YunzaiConfigKey>(componentName: T, ...defaultValues: Array<YunzaiConfig[T]>): YunzaiConfig[T] {\n return deepMergeKey({}, true, ...defaultValues, this.get(componentName));\n }\n\n attach<T extends YunzaiConfigKey>(componentThis: unknown, componentName: T, defaultValues: YunzaiConfig[T]): void {\n Object.assign(componentThis, this.merge(componentName, defaultValues));\n }\n\n attachKey<T extends YunzaiConfigKey>(componentThis: unknown, componentName: T, key: string): void {\n Object.assign(componentThis, this.get(componentName, key));\n }\n\n set<T extends YunzaiConfigKey>(componentName: T, value: YunzaiConfig[T]): void {\n this.config[componentName] = { ...this.config[componentName], ...value };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAAa,cAAc;;;MCoEd,aAAa,GAAG,IAAI,cAAc,CAAe,eAAe,EAAE;IAC7E,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,qBAAqB;CAC/B,EAAE;SAEa,qBAAqB;IACnC,OAAO,EAAE,CAAC;AACZ;;MClEa,mBAAmB;IAG9B,YAA+C,aAA4B;QACzE,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,aAAa,EAAE,CAAC;KACpC;IAED,GAAG,CAA4B,aAAgB,EAAE,GAAY;QAC3D,MAAM,GAAG,IAAK,IAAI,CAAC,MAAM,CAAC,aAAa,CAAgC,IAAI,EAAE,CAAc,CAAC;QAC5F,OAAO,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC;KACxC;IAED,KAAK,CAA4B,aAAgB,EAAE,GAAG,aAAqC;QACzF,OAAO,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;KAC1E;IAED,MAAM,CAA4B,aAAsB,EAAE,aAAgB,EAAE,aAA8B;QACxG,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC;KACxE;IAED,SAAS,CAA4B,aAAsB,EAAE,aAAgB,EAAE,GAAW;QACxF,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,CAAC;KAC5D;IAED,GAAG,CAA4B,aAAgB,EAAE,KAAsB;QACrE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;KAC1E;;gHA1BU,mBAAmB,kBAGE,aAAa;oHAHlC,mBAAmB,cADN,MAAM;2FACnB,mBAAmB;kBAD/B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;0BAInB,QAAQ;;0BAAI,MAAM;2BAAC,aAAa;;;ACZ/C;;;;;;"}
@@ -0,0 +1,210 @@
1
+ import { parse, addDays, startOfYear, subYears, endOfYear, startOfMonth, subMonths, endOfMonth, startOfWeek, subWeeks, endOfWeek, startOfDay, endOfDay, parseISO, format, differenceInCalendarDays, addSeconds } from 'date-fns';
2
+
3
+ /**
4
+ * Get the time range, return `[ Date, Date]` for the start and end dates
5
+ *
6
+ * 获取时间范围
7
+ *
8
+ * @param type 类型,带 `-` 表示过去一个时间,若指定 `number` 表示天数
9
+ * @param time 开始时间
10
+ */
11
+ function getTimeDistance(type, time) {
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 options = { 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, options), endOfWeek(time, options)];
31
+ break;
32
+ case '-week':
33
+ res = [startOfWeek(subWeeks(time, 1), options), endOfWeek(subWeeks(time, 1), options)];
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 fixEndTimeOfRange(res);
52
+ }
53
+ /**
54
+ * fix time is the most, big value
55
+ */
56
+ 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
+ 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
+
90
+ // TODO: timezone process
91
+ class DateTimePickerUtil {
92
+ /**
93
+ * Current local time
94
+ *
95
+ * 当前本地时间
96
+ */
97
+ get now() {
98
+ return new Date();
99
+ }
100
+ /**
101
+ * Current local date (not including time part)
102
+ *
103
+ * 当前本地日期(不包含时间部分)
104
+ */
105
+ get date() {
106
+ return this.removeTime(this.now);
107
+ }
108
+ /**
109
+ * Remove the time part of the date
110
+ *
111
+ * 移除日期的时间部分
112
+ */
113
+ removeTime(d) {
114
+ return new Date(d.toDateString());
115
+ }
116
+ /**
117
+ * Format date-time
118
+ *
119
+ * 格式化日期
120
+ */
121
+ format(d, formatString = 'yyyy-MM-dd HH:mm:ss') {
122
+ return format(d, formatString);
123
+ }
124
+ genTick(count) {
125
+ return new Array(count).fill(0).map((_, idx) => idx);
126
+ }
127
+ /**
128
+ * Calculate the number of days between two dates, `0` means the same day
129
+ *
130
+ * 计算两个日期相差天数,`0` 表示同一天
131
+ */
132
+ getDiffDays(dateLeft, dateRight) {
133
+ return differenceInCalendarDays(dateLeft, typeof dateRight === 'number' ? addDays(this.date, dateRight) : dateRight || this.date);
134
+ }
135
+ /**
136
+ * Disabled Before date (Default: today), Generally serves `nzDisabledDate`
137
+ *
138
+ * 禁用之前日期(默认:今天),一般服务于 `nzDisabledDate`
139
+ */
140
+ disabledBeforeDate(options) {
141
+ return (d) => this.getDiffDays(d, options?.offsetDays) < 0;
142
+ }
143
+ /**
144
+ * Disabled After date (Default: today), Generally serves `nzDisabledDate`
145
+ *
146
+ * 禁用之后日期(默认:今天),一般服务于 `nzDisabledDate`
147
+ */
148
+ disabledAfterDate(options) {
149
+ return (d) => this.getDiffDays(d, options?.offsetDays) > 0;
150
+ }
151
+ baseDisabledTime(type, offsetSeconds) {
152
+ const tick24 = this.genTick(24);
153
+ const tick60 = this.genTick(60);
154
+ return (current) => {
155
+ const cur = current;
156
+ if (cur == null) {
157
+ return {};
158
+ }
159
+ const now = addSeconds(this.now, offsetSeconds || 0);
160
+ const nowHours = now.getHours();
161
+ const nowMinutes = now.getMinutes();
162
+ const curHours = cur.getHours();
163
+ const isToday = this.getDiffDays(this.removeTime(cur)) === 0;
164
+ return {
165
+ nzDisabledHours: () => {
166
+ if (!isToday)
167
+ return [];
168
+ return type === 'before' ? tick24.slice(0, nowHours) : tick24.slice(nowHours + 1);
169
+ },
170
+ nzDisabledMinutes: () => {
171
+ if (isToday && curHours === nowHours) {
172
+ return type === 'before' ? tick60.slice(0, nowMinutes) : tick60.slice(nowMinutes + 1);
173
+ }
174
+ return [];
175
+ },
176
+ nzDisabledSeconds: () => {
177
+ if (isToday && curHours === nowHours && cur.getMinutes() === nowMinutes) {
178
+ const nowSeconds = now.getSeconds();
179
+ return type === 'before' ? tick60.slice(0, nowSeconds) : tick60.slice(nowSeconds + 1);
180
+ }
181
+ return [];
182
+ }
183
+ };
184
+ };
185
+ }
186
+ /**
187
+ * Disabled Before time (Default: now), Generally serves `nzDisabledTime`
188
+ *
189
+ * 禁用之前时间(默认:现在),一般服务于 `nzDisabledTime`
190
+ */
191
+ disabledBeforeTime(options) {
192
+ return this.baseDisabledTime('before', options?.offsetSeconds);
193
+ }
194
+ /**
195
+ * Disabled After time (Default: now), Generally serves `nzDisabledTime`
196
+ *
197
+ * 禁用之后时间(默认:现在),一般服务于 `nzDisabledTime`
198
+ */
199
+ disabledAfterTime(options) {
200
+ return this.baseDisabledTime('after', options?.offsetSeconds);
201
+ }
202
+ }
203
+ const dateTimePickerUtil = new DateTimePickerUtil();
204
+
205
+ /**
206
+ * Generated bundle index. Do not edit.
207
+ */
208
+
209
+ export { DateTimePickerUtil, dateTimePickerUtil, fixEndTimeOfRange, getTimeDistance, toDate };
210
+ //# sourceMappingURL=date-time.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-time.mjs","sources":["../../../../packages/util/date-time/time.ts","../../../../packages/util/date-time/picker.ts","../../../../packages/util/date-time/date-time.ts"],"sourcesContent":["import {\n addDays,\n endOfDay,\n endOfMonth,\n endOfWeek,\n endOfYear,\n parse,\n parseISO,\n startOfDay,\n startOfMonth,\n startOfWeek,\n startOfYear,\n subMonths,\n subWeeks,\n subYears\n} from 'date-fns';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\n/**\n * Get the time range, return `[ Date, Date]` for the start and end dates\n *\n * 获取时间范围\n *\n * @param type 类型,带 `-` 表示过去一个时间,若指定 `number` 表示天数\n * @param time 开始时间\n */\nexport function getTimeDistance(\n type: 'today' | '-today' | 'yesterday' | 'week' | '-week' | 'month' | '-month' | 'year' | '-year' | number,\n time?: Date | string | number\n): [Date, Date] {\n time = time\n ? typeof time === 'string'\n ? parse(time, 'yyyy-MM-dd HH:mm:ss', new Date())\n : new Date(time)\n : new Date();\n const options: { weekStartsOn: 1 } = { weekStartsOn: 1 };\n\n let res: [Date, Date];\n switch (type) {\n case 'today':\n res = [time, time];\n break;\n case '-today':\n res = [addDays(time, -1), time];\n break;\n case 'yesterday':\n res = [addDays(time, -1), addDays(time, -1)];\n break;\n case 'week':\n res = [startOfWeek(time, options), endOfWeek(time, options)];\n break;\n case '-week':\n res = [startOfWeek(subWeeks(time, 1), options), endOfWeek(subWeeks(time, 1), options)];\n break;\n case 'month':\n res = [startOfMonth(time), endOfMonth(time)];\n break;\n case '-month':\n res = [startOfMonth(subMonths(time, 1)), endOfMonth(subMonths(time, 1))];\n break;\n case 'year':\n res = [startOfYear(time), endOfYear(time)];\n break;\n case '-year':\n res = [startOfYear(subYears(time, 1)), endOfYear(subYears(time, 1))];\n break;\n default:\n res = type > 0 ? [time, addDays(time, type)] : [addDays(time, type), time];\n break;\n }\n return fixEndTimeOfRange(res);\n}\n\n/**\n * fix time is the most, big value\n */\nexport function fixEndTimeOfRange(dates: [Date, Date]): [Date, Date] {\n return [startOfDay(dates[0]), endOfDay(dates[1])];\n}\n\nexport type ToDateOptions = string | { formatString?: string; defaultValue?: NzSafeAny };\n\n/**\n * Return the date parsed from string using the given format string\n * - If the argument is a number, it is treated as a timestamp.\n *\n * @param formatString If parsing fails try to parse the date by pressing `formatString`\n * @param defaultValue If parsing fails returned default value, default: `new Date(NaN)`\n */\nexport function toDate(value: Date | string | number, options?: ToDateOptions): Date {\n if (typeof options === 'string') options = { formatString: options };\n const { formatString, defaultValue } = {\n formatString: 'yyyy-MM-dd HH:mm:ss',\n defaultValue: new Date(NaN),\n ...options\n };\n if (value == null) {\n return defaultValue;\n }\n if (value instanceof Date) {\n return value;\n }\n if (typeof value === 'number' || (typeof value === 'string' && /[0-9]{10,13}/.test(value))) {\n return new Date(+value);\n }\n let tryDate = parseISO(value);\n if (isNaN(tryDate as NzSafeAny)) {\n tryDate = parse(value, formatString!, new Date());\n }\n\n return isNaN(tryDate as NzSafeAny) ? defaultValue : tryDate;\n}\n","import { addDays, addSeconds, differenceInCalendarDays, format } from 'date-fns';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\nimport { DisabledDateFn, DisabledTimeConfig, DisabledTimeFn } from 'ng-zorro-antd/date-picker';\n\n// TODO: timezone process\nexport class DateTimePickerUtil {\n /**\n * Current local time\n *\n * 当前本地时间\n */\n get now(): Date {\n return new Date();\n }\n /**\n * Current local date (not including time part)\n *\n * 当前本地日期(不包含时间部分)\n */\n get date(): Date {\n return this.removeTime(this.now);\n }\n /**\n * Remove the time part of the date\n *\n * 移除日期的时间部分\n */\n removeTime(d: Date): Date {\n return new Date(d.toDateString());\n }\n /**\n * Format date-time\n *\n * 格式化日期\n */\n format(d: number | Date, formatString: string = 'yyyy-MM-dd HH:mm:ss'): string {\n return format(d, formatString);\n }\n private genTick(count: number): number[] {\n return new Array(count).fill(0).map((_, idx) => idx);\n }\n /**\n * Calculate the number of days between two dates, `0` means the same day\n *\n * 计算两个日期相差天数,`0` 表示同一天\n */\n getDiffDays(dateLeft: Date | number, dateRight?: Date | number): number {\n return differenceInCalendarDays(\n dateLeft,\n typeof dateRight === 'number' ? addDays(this.date, dateRight) : dateRight || this.date\n );\n }\n /**\n * Disabled Before date (Default: today), Generally serves `nzDisabledDate`\n *\n * 禁用之前日期(默认:今天),一般服务于 `nzDisabledDate`\n */\n disabledBeforeDate(options?: { offsetDays?: Date | number }): DisabledDateFn {\n return (d): boolean => this.getDiffDays(d, options?.offsetDays) < 0;\n }\n /**\n * Disabled After date (Default: today), Generally serves `nzDisabledDate`\n *\n * 禁用之后日期(默认:今天),一般服务于 `nzDisabledDate`\n */\n disabledAfterDate(options?: { offsetDays?: Date | number }): DisabledDateFn {\n return (d): boolean => this.getDiffDays(d, options?.offsetDays) > 0;\n }\n private baseDisabledTime(type: 'before' | 'after', offsetSeconds?: number): DisabledTimeFn {\n const tick24 = this.genTick(24);\n const tick60 = this.genTick(60);\n return (current): DisabledTimeConfig => {\n const cur = current as Date;\n if (cur == null) {\n return {} as NzSafeAny;\n }\n const now = addSeconds(this.now, offsetSeconds || 0);\n const nowHours = now.getHours();\n const nowMinutes = now.getMinutes();\n const curHours = cur.getHours();\n const isToday = this.getDiffDays(this.removeTime(cur)) === 0;\n return {\n nzDisabledHours: () => {\n if (!isToday) return [];\n return type === 'before' ? tick24.slice(0, nowHours) : tick24.slice(nowHours + 1);\n },\n nzDisabledMinutes: () => {\n if (isToday && curHours === nowHours) {\n return type === 'before' ? tick60.slice(0, nowMinutes) : tick60.slice(nowMinutes + 1);\n }\n return [];\n },\n nzDisabledSeconds: () => {\n if (isToday && curHours === nowHours && cur.getMinutes() === nowMinutes) {\n const nowSeconds = now.getSeconds();\n return type === 'before' ? tick60.slice(0, nowSeconds) : tick60.slice(nowSeconds + 1);\n }\n return [];\n }\n };\n };\n }\n /**\n * Disabled Before time (Default: now), Generally serves `nzDisabledTime`\n *\n * 禁用之前时间(默认:现在),一般服务于 `nzDisabledTime`\n */\n disabledBeforeTime(options?: { offsetSeconds?: number }): DisabledTimeFn {\n return this.baseDisabledTime('before', options?.offsetSeconds);\n }\n /**\n * Disabled After time (Default: now), Generally serves `nzDisabledTime`\n *\n * 禁用之后时间(默认:现在),一般服务于 `nzDisabledTime`\n */\n disabledAfterTime(options?: { offsetSeconds?: number }): DisabledTimeFn {\n return this.baseDisabledTime('after', options?.offsetSeconds);\n }\n}\n\nexport const dateTimePickerUtil = new DateTimePickerUtil();\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAmBA;;;;;;;;SAQgB,eAAe,CAC7B,IAA0G,EAC1G,IAA6B;IAE7B,IAAI,GAAG,IAAI;UACP,OAAO,IAAI,KAAK,QAAQ;cACtB,KAAK,CAAC,IAAI,EAAE,qBAAqB,EAAE,IAAI,IAAI,EAAE,CAAC;cAC9C,IAAI,IAAI,CAAC,IAAI,CAAC;UAChB,IAAI,IAAI,EAAE,CAAC;IACf,MAAM,OAAO,GAAwB,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;IAEzD,IAAI,GAAiB,CAAC;IACtB,QAAQ,IAAI;QACV,KAAK,OAAO;YACV,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACnB,MAAM;QACR,KAAK,QAAQ;YACX,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;YAChC,MAAM;QACR,KAAK,WAAW;YACd,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7C,MAAM;QACR,KAAK,MAAM;YACT,GAAG,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;YAC7D,MAAM;QACR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AAa,CAAC,CAAC;KAC/D;CACF;MAEY,kBAAkB,GAAG,IAAI,kBAAkB;;ACzHxD;;;;;;"}
@@ -0,0 +1,121 @@
1
+ import { warn } from '@yelon/util/other';
2
+
3
+ function propDecoratorFactory(name, fallback, defaultValue) {
4
+ function propDecorator(target, propName, originalDescriptor) {
5
+ const privatePropName = `$$__${propName}`;
6
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
7
+ if (Object.prototype.hasOwnProperty.call(target, privatePropName)) {
8
+ warn(`The prop "${privatePropName}" is already exist, it will be overrided by ${name} decorator.`);
9
+ }
10
+ }
11
+ Object.defineProperty(target, privatePropName, {
12
+ configurable: true,
13
+ writable: true
14
+ });
15
+ return {
16
+ get() {
17
+ return originalDescriptor && originalDescriptor.get
18
+ ? originalDescriptor.get.bind(this)()
19
+ : this[privatePropName];
20
+ },
21
+ set(value) {
22
+ if (originalDescriptor && originalDescriptor.set) {
23
+ originalDescriptor.set.bind(this)(fallback(value, defaultValue));
24
+ }
25
+ this[privatePropName] = fallback(value, defaultValue);
26
+ }
27
+ };
28
+ }
29
+ return propDecorator;
30
+ }
31
+ function toBoolean(value, defaultValue = false) {
32
+ return value == null ? defaultValue : `${value}` !== 'false';
33
+ }
34
+ /**
35
+ * Input decorator that handle a prop to do get/set automatically with toBoolean
36
+ *
37
+ * ```ts
38
+ * {AT}Input() {AT}InputBoolean() visible: boolean = false;
39
+ * {AT}Input() {AT}InputBoolean(null) visible: boolean = false;
40
+ * ```
41
+ */
42
+ function InputBoolean(defaultValue = false) {
43
+ return propDecoratorFactory('InputBoolean', toBoolean, defaultValue);
44
+ }
45
+ function toNumber(value, fallbackValue = 0) {
46
+ return !isNaN(parseFloat(value)) && !isNaN(Number(value)) ? Number(value) : fallbackValue;
47
+ }
48
+ /**
49
+ * Input decorator that handle a prop to do get/set automatically with toNumber
50
+ *
51
+ * ```ts
52
+ * {AT}Input() {AT}InputNumber() visible: number = 1;
53
+ * {AT}Input() {AT}InputNumber(null) visible: number = 2;
54
+ * ```
55
+ */
56
+ function InputNumber(defaultValue = 0) {
57
+ return propDecoratorFactory('InputNumber', toNumber, defaultValue);
58
+ }
59
+
60
+ function makeFn(type, options) {
61
+ return (_, __, descriptor) => {
62
+ const source = descriptor.value;
63
+ descriptor.value = function (...data) {
64
+ const that = this;
65
+ const ngZone = that[options?.ngZoneName || 'ngZone'];
66
+ if (!ngZone) {
67
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
68
+ warn(`ZoneOutside: Decorator should have 'ngZone' property with 'NgZone' class.`);
69
+ }
70
+ return source.call(this, ...data);
71
+ }
72
+ let res;
73
+ ngZone[type](() => {
74
+ res = source.call(this, ...data);
75
+ });
76
+ return res;
77
+ };
78
+ return descriptor;
79
+ };
80
+ }
81
+ /**
82
+ * The decoration method runs in `runOutsideAngular`
83
+ *
84
+ * 装饰方法运行在 `runOutsideAngular` 内
85
+ *
86
+ * ```ts
87
+ * class MockClass {
88
+ * constructor(public ngZone: NgZone) {}
89
+ *
90
+ * {AT}ZoneOutside()
91
+ * runOutsideAngular(): void {}
92
+ * }
93
+ * ```
94
+ */
95
+ function ZoneOutside(options) {
96
+ return makeFn('runOutsideAngular', options);
97
+ }
98
+ /**
99
+ * The decoration method runs in `run`
100
+ *
101
+ * 装饰方法运行在 `run` 内
102
+ *
103
+ * ```ts
104
+ * class MockClass {
105
+ * constructor(public ngZone: NgZone) {}
106
+ *
107
+ * {AT}ZoneRun()
108
+ * run(): void {}
109
+ * }
110
+ * ```
111
+ */
112
+ function ZoneRun(options) {
113
+ return makeFn('run', options);
114
+ }
115
+
116
+ /**
117
+ * Generated bundle index. Do not edit.
118
+ */
119
+
120
+ export { InputBoolean, InputNumber, ZoneOutside, ZoneRun, toBoolean, toNumber };
121
+ //# sourceMappingURL=decorator.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorator.mjs","sources":["../../../../packages/util/decorator/convert.ts","../../../../packages/util/decorator/zone-outside.ts","../../../../packages/util/decorator/decorator.ts"],"sourcesContent":["import { warn } from '@yelon/util/other';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nexport type BooleanInput = boolean | string | undefined | null;\nexport type NumberInput = number | string | undefined | null;\n\nfunction propDecoratorFactory<T, D>(\n name: string,\n fallback: (v: T, defaultValue: D) => D,\n defaultValue: NzSafeAny\n): (target: NzSafeAny, propName: string) => void {\n function propDecorator(\n target: NzSafeAny,\n propName: string,\n originalDescriptor?: TypedPropertyDescriptor<NzSafeAny>\n ): NzSafeAny {\n const privatePropName = `$$__${propName}`;\n\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n if (Object.prototype.hasOwnProperty.call(target, privatePropName)) {\n warn(`The prop \"${privatePropName}\" is already exist, it will be overrided by ${name} decorator.`);\n }\n }\n\n Object.defineProperty(target, privatePropName, {\n configurable: true,\n writable: true\n });\n\n return {\n get(): string {\n return originalDescriptor && originalDescriptor.get\n ? originalDescriptor.get.bind(this)()\n : this[privatePropName];\n },\n set(value: T): void {\n if (originalDescriptor && originalDescriptor.set) {\n originalDescriptor.set.bind(this)(fallback(value, defaultValue));\n }\n this[privatePropName] = fallback(value, defaultValue);\n }\n };\n }\n\n return propDecorator;\n}\n\nexport function toBoolean(\n value: unknown,\n defaultValue: boolean | null | undefined = false\n): boolean | null | undefined {\n return value == null ? defaultValue : `${value}` !== 'false';\n}\n\n/**\n * Input decorator that handle a prop to do get/set automatically with toBoolean\n *\n * ```ts\n * {AT}Input() {AT}InputBoolean() visible: boolean = false;\n * {AT}Input() {AT}InputBoolean(null) visible: boolean = false;\n * ```\n */\nexport function InputBoolean(defaultValue: boolean | null = false): NzSafeAny {\n return propDecoratorFactory('InputBoolean', toBoolean, defaultValue);\n}\n\nexport function toNumber(value: unknown): number;\nexport function toNumber<D>(value: unknown, fallback: D): number | D;\nexport function toNumber(value: unknown, fallbackValue: number = 0): number {\n return !isNaN(parseFloat(value as NzSafeAny)) && !isNaN(Number(value)) ? Number(value) : fallbackValue;\n}\n\n/**\n * Input decorator that handle a prop to do get/set automatically with toNumber\n *\n * ```ts\n * {AT}Input() {AT}InputNumber() visible: number = 1;\n * {AT}Input() {AT}InputNumber(null) visible: number = 2;\n * ```\n */\nexport function InputNumber(defaultValue: number | null = 0): NzSafeAny {\n return propDecoratorFactory('InputNumber', toNumber, defaultValue);\n}\n","import { warn } from '@yelon/util/other';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nexport interface ZoneOptions {\n ngZoneName?: string;\n}\n\ntype DecoratorType = (target: unknown, fn: string, descriptor: PropertyDescriptor) => PropertyDescriptor;\n\nfunction makeFn(type: 'runOutsideAngular' | 'run', options?: ZoneOptions): DecoratorType {\n return (_, __, descriptor) => {\n const source = descriptor.value;\n descriptor.value = function (...data: NzSafeAny[]): () => void {\n const that = this as NzSafeAny;\n const ngZone = that[options?.ngZoneName || 'ngZone'];\n if (!ngZone) {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n warn(`ZoneOutside: Decorator should have 'ngZone' property with 'NgZone' class.`);\n }\n return source.call(this, ...data);\n }\n let res: NzSafeAny;\n ngZone[type](() => {\n res = source.call(this, ...data);\n });\n return res;\n };\n\n return descriptor;\n };\n}\n\n/**\n * The decoration method runs in `runOutsideAngular`\n *\n * 装饰方法运行在 `runOutsideAngular` 内\n *\n * ```ts\n * class MockClass {\n * constructor(public ngZone: NgZone) {}\n *\n * {AT}ZoneOutside()\n * runOutsideAngular(): void {}\n * }\n * ```\n */\nexport function ZoneOutside(options?: ZoneOptions): DecoratorType {\n return makeFn('runOutsideAngular', options);\n}\n\n/**\n * The decoration method runs in `run`\n *\n * 装饰方法运行在 `run` 内\n *\n * ```ts\n * class MockClass {\n * constructor(public ngZone: NgZone) {}\n *\n * {AT}ZoneRun()\n * run(): void {}\n * }\n * ```\n */\nexport function ZoneRun(options?: ZoneOptions): DecoratorType {\n return makeFn('run', options);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAMA,SAAS,oB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E,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;;;;;;;;SAcgB,OAAO,CAAC,OAAqB;IAC3C,OAAO,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAChC;;AClEA;;;;;;"}
@@ -0,0 +1,118 @@
1
+ import { isNum, isInt, isDecimal, isIdCard, isMobile, isUrl, isIp, isColor, isChinese } from '@yelon/util/format';
2
+
3
+ /**
4
+ * A set of validators for reactive forms
5
+ *
6
+ * 一套用于响应式表单的验证器
7
+ */
8
+ class _Validators {
9
+ /**
10
+ * Wheter is number
11
+ *
12
+ * 是否为数字
13
+ */
14
+ static num(control) {
15
+ return isNum(control.value) ? null : { num: true };
16
+ }
17
+ /**
18
+ * Wheter is integer
19
+ *
20
+ * 是否为整数
21
+ */
22
+ static int(control) {
23
+ return isInt(control.value) ? null : { int: true };
24
+ }
25
+ /**
26
+ * Wheter is decimal
27
+ *
28
+ * 是否为小数点数值
29
+ */
30
+ static decimal(control) {
31
+ return isDecimal(control.value) ? null : { decimal: true };
32
+ }
33
+ /**
34
+ * Wheter is People's Republic of China identity card
35
+ *
36
+ * 是否为中华人民共和国居民身份证
37
+ */
38
+ static idCard(control) {
39
+ return isIdCard(control.value) ? null : { idCard: true };
40
+ }
41
+ /**
42
+ * Wheter is china mobile (China)
43
+ *
44
+ * 是否为手机号(中国)
45
+ */
46
+ static mobile(control) {
47
+ return isMobile(control.value) ? null : { mobile: true };
48
+ }
49
+ /**
50
+ * Wheter is url address
51
+ *
52
+ * 是否URL地址
53
+ */
54
+ static url(control) {
55
+ return isUrl(control.value) ? null : { url: true };
56
+ }
57
+ /**
58
+ * Wheter is IPv4 address (Support v4, v6)
59
+ *
60
+ * 是否IP4地址(支持v4、v6)
61
+ */
62
+ static ip(control) {
63
+ return isIp(control.value) ? null : { ip: true };
64
+ }
65
+ /**
66
+ * Wheter is color
67
+ *
68
+ * 是否颜色代码值
69
+ */
70
+ static color(control) {
71
+ return isColor(control.value) ? null : { color: true };
72
+ }
73
+ /**
74
+ * Wheter is chinese
75
+ *
76
+ * 是否中文
77
+ */
78
+ static chinese(control) {
79
+ return isChinese(control.value) ? null : { chinese: true };
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Match two control values
85
+ *
86
+ * 匹配两个控件值
87
+ * ```ts
88
+ * this.form = new FormGroup({
89
+ * pwd: new FormControl(''),
90
+ * repwd: new FormControl(''),
91
+ * }, {
92
+ * validators: MatchControl('pwd', 'repwd'),
93
+ * });
94
+ * ```
95
+ */
96
+ function MatchControl(controlName, matchingControlName) {
97
+ return (formGroup) => {
98
+ const control = formGroup.get(controlName);
99
+ const matchingControl = formGroup.get(matchingControlName);
100
+ if (matchingControl.errors && !matchingControl.errors.matchControl) {
101
+ return null;
102
+ }
103
+ if (control.value !== matchingControl.value) {
104
+ matchingControl.setErrors({ matchControl: true });
105
+ }
106
+ else {
107
+ matchingControl.setErrors(null);
108
+ }
109
+ return null;
110
+ };
111
+ }
112
+
113
+ /**
114
+ * Generated bundle index. Do not edit.
115
+ */
116
+
117
+ export { MatchControl, _Validators };
118
+ //# sourceMappingURL=form.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form.mjs","sources":["../../../../packages/util/form/validators.ts","../../../../packages/util/form/match-control.ts","../../../../packages/util/form/form.ts"],"sourcesContent":["import { AbstractControl, ValidationErrors } from '@angular/forms';\n\nimport { isChinese, isColor, isDecimal, isIdCard, isInt, isIp, isMobile, isNum, isUrl } from '@yelon/util/format';\n\n/**\n * A set of validators for reactive forms\n *\n * 一套用于响应式表单的验证器\n */\nexport class _Validators {\n /**\n * Wheter is number\n *\n * 是否为数字\n */\n static num(control: AbstractControl): ValidationErrors | null {\n return isNum(control.value) ? null : { num: true };\n }\n\n /**\n * Wheter is integer\n *\n * 是否为整数\n */\n static int(control: AbstractControl): ValidationErrors | null {\n return isInt(control.value) ? null : { int: true };\n }\n\n /**\n * Wheter is decimal\n *\n * 是否为小数点数值\n */\n static decimal(control: AbstractControl): ValidationErrors | null {\n return isDecimal(control.value) ? null : { decimal: true };\n }\n\n /**\n * Wheter is People's Republic of China identity card\n *\n * 是否为中华人民共和国居民身份证\n */\n static idCard(control: AbstractControl): ValidationErrors | null {\n return isIdCard(control.value) ? null : { idCard: true };\n }\n\n /**\n * Wheter is china mobile (China)\n *\n * 是否为手机号(中国)\n */\n static mobile(control: AbstractControl): ValidationErrors | null {\n return isMobile(control.value) ? null : { mobile: true };\n }\n\n /**\n * Wheter is url address\n *\n * 是否URL地址\n */\n static url(control: AbstractControl): ValidationErrors | null {\n return isUrl(control.value) ? null : { url: true };\n }\n\n /**\n * Wheter is IPv4 address (Support v4, v6)\n *\n * 是否IP4地址(支持v4、v6)\n */\n static ip(control: AbstractControl): ValidationErrors | null {\n return isIp(control.value) ? null : { ip: true };\n }\n\n /**\n * Wheter is color\n *\n * 是否颜色代码值\n */\n static color(control: AbstractControl): ValidationErrors | null {\n return isColor(control.value) ? null : { color: true };\n }\n\n /**\n * Wheter is chinese\n *\n * 是否中文\n */\n static chinese(control: AbstractControl): ValidationErrors | null {\n return isChinese(control.value) ? null : { chinese: true };\n }\n}\n","import { AbstractControl, ValidatorFn } from '@angular/forms';\n\n/**\n * Match two control values\n *\n * 匹配两个控件值\n * ```ts\n * this.form = new FormGroup({\n * pwd: new FormControl(''),\n * repwd: new FormControl(''),\n * }, {\n * validators: MatchControl('pwd', 'repwd'),\n * });\n * ```\n */\nexport function MatchControl(controlName: string, matchingControlName: string): ValidatorFn {\n return (formGroup: AbstractControl) => {\n const control = formGroup.get(controlName)!;\n const matchingControl = formGroup.get(matchingControlName)!;\n if (matchingControl.errors && !matchingControl.errors.matchControl) {\n return null;\n }\n if (control.value !== matchingControl.value) {\n matchingControl.setErrors({ matchControl: true });\n } else {\n matchingControl.setErrors(null);\n }\n return null;\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAIA;;;;;MAKa,WAAW;;;;;;IAMtB,OAAO,GAAG,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