@yelon/util 15.2.4 → 16.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (276) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +22 -22
  3. package/analysis/global-event.subject.d.ts +7 -7
  4. package/analysis/index.d.ts +1 -1
  5. package/array/array-type.service.d.ts +68 -68
  6. package/array/array.service.d.ts +78 -78
  7. package/array/index.d.ts +2 -2
  8. package/browser/cookie.service.d.ts +67 -67
  9. package/browser/copy.d.ts +6 -6
  10. package/browser/index.d.ts +5 -5
  11. package/browser/is-empty.d.ts +6 -6
  12. package/browser/scroll.service.d.ts +37 -37
  13. package/browser/style.d.ts +21 -21
  14. package/config/abc/date-picker.type.d.ts +52 -52
  15. package/config/abc/error-collect.type.d.ts +10 -10
  16. package/config/abc/exception.type.d.ts +9 -9
  17. package/config/abc/image.type.d.ts +15 -15
  18. package/config/abc/index.d.ts +17 -17
  19. package/config/abc/loading.type.d.ts +31 -31
  20. package/config/abc/lodop.type.d.ts +33 -33
  21. package/config/abc/media.type.d.ts +11 -11
  22. package/config/abc/onboarding.type.d.ts +4 -4
  23. package/config/abc/page-header.type.d.ts +39 -39
  24. package/config/abc/pdf.type.d.ts +35 -35
  25. package/config/abc/qr.type.d.ts +25 -25
  26. package/config/abc/se.type.d.ts +32 -32
  27. package/config/abc/sg.type.d.ts +10 -10
  28. package/config/abc/st.type.d.ts +465 -465
  29. package/config/abc/sv.type.d.ts +14 -14
  30. package/config/abc/xlsx.type.d.ts +12 -12
  31. package/config/abc/zip.type.d.ts +10 -10
  32. package/config/acl/acl.type.d.ts +32 -32
  33. package/config/auth/auth.type.d.ts +55 -55
  34. package/config/bis/bis.type.d.ts +7 -7
  35. package/config/cache/cache.type.d.ts +40 -40
  36. package/config/chart/chart.type.d.ts +33 -33
  37. package/config/config.service.d.ts +13 -13
  38. package/config/config.types.d.ts +48 -48
  39. package/config/index.d.ts +14 -14
  40. package/config/mock/mock.type.d.ts +18 -18
  41. package/config/sf/sf.type.d.ts +133 -133
  42. package/config/socket/socket.type.d.ts +4 -4
  43. package/config/theme/http.type.d.ts +14 -14
  44. package/config/theme/i18n.type.d.ts +14 -14
  45. package/config/theme/index.d.ts +3 -3
  46. package/config/theme/responsive.type.d.ts +12 -12
  47. package/config/util/array.type.d.ts +22 -22
  48. package/config/util/currency.type.d.ts +39 -39
  49. package/date-time/index.d.ts +2 -2
  50. package/date-time/picker.d.ts +68 -68
  51. package/date-time/time.d.ts +29 -29
  52. package/decorator/convert.d.ts +24 -24
  53. package/decorator/index.d.ts +2 -2
  54. package/decorator/zone-outside.d.ts +35 -35
  55. package/{esm2020 → esm2022}/analysis/analysis.mjs +4 -4
  56. package/esm2022/analysis/global-event.subject.mjs +18 -0
  57. package/{esm2020 → esm2022}/analysis/index.mjs +2 -2
  58. package/{esm2020 → esm2022}/array/array-type.service.mjs +1 -1
  59. package/{esm2020 → esm2022}/array/array.mjs +4 -4
  60. package/esm2022/array/array.service.mjs +278 -0
  61. package/{esm2020 → esm2022}/array/index.mjs +2 -2
  62. package/{esm2020 → esm2022}/browser/browser.mjs +4 -4
  63. package/esm2022/browser/cookie.service.mjs +104 -0
  64. package/{esm2020 → esm2022}/browser/copy.mjs +27 -27
  65. package/{esm2020 → esm2022}/browser/index.mjs +5 -5
  66. package/{esm2020 → esm2022}/browser/is-empty.mjs +18 -18
  67. package/esm2022/browser/scroll.service.mjs +89 -0
  68. package/{esm2020 → esm2022}/browser/style.mjs +37 -37
  69. package/{esm2020 → esm2022}/config/abc/date-picker.type.mjs +1 -1
  70. package/{esm2020 → esm2022}/config/abc/error-collect.type.mjs +1 -1
  71. package/{esm2020 → esm2022}/config/abc/exception.type.mjs +1 -1
  72. package/{esm2020 → esm2022}/config/abc/image.type.mjs +1 -1
  73. package/{esm2020 → esm2022}/config/abc/index.mjs +17 -17
  74. package/{esm2020 → esm2022}/config/abc/loading.type.mjs +1 -1
  75. package/{esm2020 → esm2022}/config/abc/lodop.type.mjs +1 -1
  76. package/{esm2020 → esm2022}/config/abc/media.type.mjs +1 -1
  77. package/{esm2020 → esm2022}/config/abc/onboarding.type.mjs +1 -1
  78. package/{esm2020 → esm2022}/config/abc/page-header.type.mjs +1 -1
  79. package/esm2022/config/abc/pdf.type.mjs +2 -0
  80. package/{esm2020 → esm2022}/config/abc/qr.type.mjs +1 -1
  81. package/{esm2020 → esm2022}/config/abc/se.type.mjs +1 -1
  82. package/{esm2020 → esm2022}/config/abc/sg.type.mjs +1 -1
  83. package/{esm2020 → esm2022}/config/abc/st.type.mjs +1 -1
  84. package/{esm2020 → esm2022}/config/abc/sv.type.mjs +2 -2
  85. package/{esm2020 → esm2022}/config/abc/xlsx.type.mjs +1 -1
  86. package/{esm2020 → esm2022}/config/abc/zip.type.mjs +1 -1
  87. package/{esm2020 → esm2022}/config/acl/acl.type.mjs +1 -1
  88. package/{esm2020 → esm2022}/config/auth/auth.type.mjs +1 -1
  89. package/{esm2020 → esm2022}/config/bis/bis.type.mjs +1 -1
  90. package/{esm2020 → esm2022}/config/cache/cache.type.mjs +1 -1
  91. package/{esm2020 → esm2022}/config/chart/chart.type.mjs +1 -1
  92. package/{esm2020 → esm2022}/config/config.mjs +4 -4
  93. package/esm2022/config/config.service.mjs +38 -0
  94. package/{esm2020 → esm2022}/config/config.types.mjs +8 -8
  95. package/{esm2020 → esm2022}/config/index.mjs +14 -14
  96. package/{esm2020 → esm2022}/config/mock/mock.type.mjs +1 -1
  97. package/{esm2020 → esm2022}/config/sf/sf.type.mjs +1 -1
  98. package/{esm2020 → esm2022}/config/socket/socket.type.mjs +1 -1
  99. package/{esm2020 → esm2022}/config/theme/http.type.mjs +1 -1
  100. package/{esm2020 → esm2022}/config/theme/i18n.type.mjs +1 -1
  101. package/{esm2020 → esm2022}/config/theme/index.mjs +3 -3
  102. package/{esm2020 → esm2022}/config/theme/responsive.type.mjs +1 -1
  103. package/{esm2020 → esm2022}/config/util/array.type.mjs +1 -1
  104. package/{esm2020 → esm2022}/config/util/currency.type.mjs +1 -1
  105. package/{esm2020 → esm2022}/date-time/date-time.mjs +4 -4
  106. package/{esm2020 → esm2022}/date-time/index.mjs +2 -2
  107. package/{esm2020 → esm2022}/date-time/picker.mjs +115 -115
  108. package/{esm2020 → esm2022}/date-time/time.mjs +88 -88
  109. package/{esm2020 → esm2022}/decorator/convert.mjs +57 -57
  110. package/{esm2020 → esm2022}/decorator/decorator.mjs +4 -4
  111. package/{esm2020 → esm2022}/decorator/index.mjs +2 -2
  112. package/{esm2020 → esm2022}/decorator/zone-outside.mjs +56 -56
  113. package/{esm2020 → esm2022}/form/form.mjs +4 -4
  114. package/{esm2020 → esm2022}/form/index.mjs +2 -2
  115. package/{esm2020 → esm2022}/form/match-control.mjs +29 -29
  116. package/{esm2020 → esm2022}/form/validators.mjs +80 -80
  117. package/esm2022/format/currency.service.mjs +239 -0
  118. package/{esm2020 → esm2022}/format/currency.types.mjs +7 -7
  119. package/{esm2020 → esm2022}/format/format.mjs +4 -4
  120. package/{esm2020 → esm2022}/format/index.mjs +4 -4
  121. package/{esm2020 → esm2022}/format/string.mjs +84 -84
  122. package/{esm2020 → esm2022}/format/validate.mjs +93 -93
  123. package/{esm2020 → esm2022}/index.mjs +12 -12
  124. package/{esm2020 → esm2022}/math/in-range.mjs +24 -24
  125. package/{esm2020 → esm2022}/math/index.mjs +2 -2
  126. package/{esm2020 → esm2022}/math/math.mjs +4 -4
  127. package/{esm2020 → esm2022}/math/round.mjs +52 -52
  128. package/{esm2020 → esm2022}/other/assert.mjs +66 -66
  129. package/{esm2020 → esm2022}/other/deep.mjs +77 -77
  130. package/{esm2020 → esm2022}/other/favicon.mjs +28 -28
  131. package/{esm2020 → esm2022}/other/index.mjs +7 -7
  132. package/esm2022/other/lazy.service.mjs +133 -0
  133. package/{esm2020 → esm2022}/other/logger.mjs +32 -32
  134. package/{esm2020 → esm2022}/other/other.mjs +4 -4
  135. package/esm2022/other/path-to-regexp.service.mjs +240 -0
  136. package/{esm2020 → esm2022}/other/resize.mjs +3 -3
  137. package/esm2022/pipes/currency/cny.pipe.mjs +24 -0
  138. package/{esm2020 → esm2022}/pipes/currency/index.mjs +4 -4
  139. package/esm2022/pipes/currency/mega.pipe.mjs +30 -0
  140. package/esm2022/pipes/currency/module.mjs +20 -0
  141. package/{esm2020 → esm2022}/pipes/currency/pipe-currency.mjs +4 -4
  142. package/esm2022/pipes/currency/price.pipe.mjs +28 -0
  143. package/esm2022/pipes/filter/filter.pipe.mjs +20 -0
  144. package/{esm2020 → esm2022}/pipes/filter/index.mjs +2 -2
  145. package/esm2022/pipes/filter/module.mjs +18 -0
  146. package/{esm2020 → esm2022}/pipes/filter/pipe-filter.mjs +4 -4
  147. package/{esm2020 → esm2022}/pipes/format/index.mjs +2 -2
  148. package/esm2022/pipes/format/mask.pipe.mjs +35 -0
  149. package/esm2022/pipes/format/module.mjs +18 -0
  150. package/{esm2020 → esm2022}/pipes/format/pipe-format.mjs +4 -4
  151. package/{esm2020 → esm2022}/pipes/index.mjs +3 -3
  152. package/{esm2020 → esm2022}/pipes/pipes.mjs +4 -4
  153. package/{esm2020 → esm2022}/token/index.mjs +2 -2
  154. package/{esm2020 → esm2022}/token/page-visibility.mjs +14 -14
  155. package/{esm2020 → esm2022}/token/token.mjs +4 -4
  156. package/{esm2020 → esm2022}/token/window.mjs +16 -16
  157. package/{esm2020 → esm2022}/yelon-util.mjs +4 -4
  158. package/{fesm2020 → fesm2022}/analysis.mjs +24 -24
  159. package/fesm2022/analysis.mjs.map +1 -0
  160. package/{fesm2020 → fesm2022}/array.mjs +284 -284
  161. package/{fesm2015 → fesm2022}/array.mjs.map +1 -1
  162. package/{fesm2020 → fesm2022}/browser.mjs +279 -279
  163. package/{fesm2020 → fesm2022}/browser.mjs.map +1 -1
  164. package/{fesm2020 → fesm2022}/config.mjs +54 -54
  165. package/{fesm2020 → fesm2022}/config.mjs.map +1 -1
  166. package/{fesm2020 → fesm2022}/date-time.mjs +211 -211
  167. package/{fesm2020 → fesm2022}/decorator.mjs +121 -121
  168. package/{fesm2020 → fesm2022}/form.mjs +118 -118
  169. package/{fesm2020 → fesm2022}/format.mjs +431 -431
  170. package/{fesm2020 → fesm2022}/format.mjs.map +1 -1
  171. package/{fesm2020 → fesm2022}/math.mjs +85 -85
  172. package/{fesm2020 → fesm2022}/other.mjs +586 -586
  173. package/{fesm2020 → fesm2022}/other.mjs.map +1 -1
  174. package/{fesm2020 → fesm2022}/pipe-currency.mjs +94 -94
  175. package/{fesm2020 → fesm2022}/pipe-currency.mjs.map +1 -1
  176. package/fesm2022/pipe-filter.mjs +40 -0
  177. package/{fesm2015 → fesm2022}/pipe-filter.mjs.map +1 -1
  178. package/{fesm2020 → fesm2022}/pipe-format.mjs +55 -55
  179. package/{fesm2015 → fesm2022}/pipe-format.mjs.map +1 -1
  180. package/{fesm2015 → fesm2022}/pipes.mjs +8 -8
  181. package/{fesm2020 → fesm2022}/token.mjs +37 -37
  182. package/{fesm2015 → fesm2022}/yelon-util.mjs +17 -17
  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 +12 -12
  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 +129 -165
  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
  219. package/esm2020/analysis/global-event.subject.mjs +0 -17
  220. package/esm2020/array/array.service.mjs +0 -277
  221. package/esm2020/browser/cookie.service.mjs +0 -103
  222. package/esm2020/browser/scroll.service.mjs +0 -88
  223. package/esm2020/config/abc/pdf.type.mjs +0 -2
  224. package/esm2020/config/config.service.mjs +0 -37
  225. package/esm2020/format/currency.service.mjs +0 -238
  226. package/esm2020/other/lazy.service.mjs +0 -132
  227. package/esm2020/other/path-to-regexp.service.mjs +0 -239
  228. package/esm2020/pipes/currency/cny.pipe.mjs +0 -23
  229. package/esm2020/pipes/currency/mega.pipe.mjs +0 -29
  230. package/esm2020/pipes/currency/module.mjs +0 -19
  231. package/esm2020/pipes/currency/price.pipe.mjs +0 -27
  232. package/esm2020/pipes/filter/filter.pipe.mjs +0 -19
  233. package/esm2020/pipes/filter/module.mjs +0 -17
  234. package/esm2020/pipes/format/mask.pipe.mjs +0 -34
  235. package/esm2020/pipes/format/module.mjs +0 -17
  236. package/fesm2015/analysis.mjs +0 -24
  237. package/fesm2015/analysis.mjs.map +0 -1
  238. package/fesm2015/array.mjs +0 -254
  239. package/fesm2015/browser.mjs +0 -283
  240. package/fesm2015/browser.mjs.map +0 -1
  241. package/fesm2015/config.mjs +0 -56
  242. package/fesm2015/config.mjs.map +0 -1
  243. package/fesm2015/date-time.mjs +0 -207
  244. package/fesm2015/date-time.mjs.map +0 -1
  245. package/fesm2015/decorator.mjs +0 -121
  246. package/fesm2015/decorator.mjs.map +0 -1
  247. package/fesm2015/form.mjs +0 -118
  248. package/fesm2015/format.mjs +0 -413
  249. package/fesm2015/format.mjs.map +0 -1
  250. package/fesm2015/math.mjs +0 -85
  251. package/fesm2015/other.mjs +0 -589
  252. package/fesm2015/other.mjs.map +0 -1
  253. package/fesm2015/pipe-currency.mjs +0 -96
  254. package/fesm2015/pipe-currency.mjs.map +0 -1
  255. package/fesm2015/pipe-filter.mjs +0 -40
  256. package/fesm2015/pipe-format.mjs +0 -55
  257. package/fesm2015/token.mjs +0 -37
  258. package/fesm2020/analysis.mjs.map +0 -1
  259. package/fesm2020/array.mjs.map +0 -1
  260. package/fesm2020/form.mjs.map +0 -1
  261. package/fesm2020/math.mjs.map +0 -1
  262. package/fesm2020/pipe-filter.mjs +0 -40
  263. package/fesm2020/pipe-filter.mjs.map +0 -1
  264. package/fesm2020/pipe-format.mjs.map +0 -1
  265. package/fesm2020/pipes.mjs +0 -8
  266. package/fesm2020/pipes.mjs.map +0 -1
  267. package/fesm2020/token.mjs.map +0 -1
  268. package/fesm2020/yelon-util.mjs +0 -17
  269. package/fesm2020/yelon-util.mjs.map +0 -1
  270. /package/{fesm2020 → fesm2022}/date-time.mjs.map +0 -0
  271. /package/{fesm2020 → fesm2022}/decorator.mjs.map +0 -0
  272. /package/{fesm2015 → fesm2022}/form.mjs.map +0 -0
  273. /package/{fesm2015 → fesm2022}/math.mjs.map +0 -0
  274. /package/{fesm2015 → fesm2022}/pipes.mjs.map +0 -0
  275. /package/{fesm2015 → fesm2022}/token.mjs.map +0 -0
  276. /package/{fesm2015 → fesm2022}/yelon-util.mjs.map +0 -0
@@ -1,238 +0,0 @@
1
- import { CurrencyPipe, formatNumber } from '@angular/common';
2
- import { DEFAULT_CURRENCY_CODE, Inject, Injectable, LOCALE_ID } from '@angular/core';
3
- import { CurrencyMega_Powers } from './currency.types';
4
- import * as i0 from "@angular/core";
5
- import * as i1 from "@yelon/util/config";
6
- export class CurrencyService {
7
- constructor(cog, locale, _defaultCurrencyCode = 'USD') {
8
- this.locale = locale;
9
- this.currencyPipe = new CurrencyPipe(locale, _defaultCurrencyCode);
10
- this.c = cog.merge('utilCurrency', {
11
- startingUnit: 'yuan',
12
- megaUnit: { Q: '京', T: '兆', B: '亿', M: '万', K: '千' },
13
- precision: 2,
14
- ignoreZeroPrecision: true
15
- });
16
- }
17
- /**
18
- * Format a number with commas as thousands separators
19
- *
20
- * 格式化货币,用逗号将数字格式化为千位分隔符
21
- * ```ts
22
- * 10000 => `10,000`
23
- * 10000.567 => `10,000.57`
24
- * ```
25
- */
26
- format(value, options) {
27
- options = {
28
- startingUnit: this.c.startingUnit,
29
- precision: this.c.precision,
30
- ignoreZeroPrecision: this.c.ignoreZeroPrecision,
31
- ngCurrency: this.c.ngCurrency,
32
- ...options
33
- };
34
- let truthValue = Number(value);
35
- if (value == null || isNaN(truthValue)) {
36
- return '';
37
- }
38
- if (options.startingUnit === 'cent') {
39
- truthValue = truthValue / 100;
40
- }
41
- if (options.ngCurrency != null) {
42
- const cur = options.ngCurrency;
43
- return this.currencyPipe.transform(truthValue, cur.currencyCode, cur.display, cur.digitsInfo, cur.locale || this.locale);
44
- }
45
- const res = formatNumber(truthValue, this.locale, `.${options.ignoreZeroPrecision ? 1 : options.precision}-${options.precision}`);
46
- return options.ignoreZeroPrecision ? res.replace(/(?:\.[0]+)$/g, '') : res;
47
- }
48
- /**
49
- * Large number format filter
50
- *
51
- * 大数据格式化
52
- * ```ts
53
- * 1000 => { value: '1', unit: 'K', unitI18n: '千' }
54
- * 12456 => { value: '12.46', unit: 'K', unitI18n: '千' }
55
- * ```
56
- */
57
- mega(value, options) {
58
- options = { precision: this.c.precision, unitI18n: this.c.megaUnit, startingUnit: this.c.startingUnit, ...options };
59
- let num = Number(value);
60
- const res = { raw: value, value: '', unit: '', unitI18n: '' };
61
- if (isNaN(num) || num === 0) {
62
- res.value = value.toString();
63
- return res;
64
- }
65
- if (options.startingUnit === 'cent') {
66
- num = num / 100;
67
- }
68
- let abs = Math.abs(+num);
69
- const rounder = Math.pow(10, options.precision);
70
- const isNegative = num < 0;
71
- for (const p of CurrencyMega_Powers) {
72
- let reduced = abs / p.value;
73
- reduced = Math.round(reduced * rounder) / rounder;
74
- if (reduced >= 1) {
75
- abs = reduced;
76
- res.unit = p.unit;
77
- break;
78
- }
79
- }
80
- res.value = (isNegative ? '-' : '') + abs;
81
- res.unitI18n = options.unitI18n[res.unit];
82
- return res;
83
- }
84
- /**
85
- * Converted into RMB notation.
86
- *
87
- * 转化成人民币表示法
88
- */
89
- cny(value, options) {
90
- options = {
91
- inWords: true,
92
- minusSymbol: '负',
93
- startingUnit: this.c.startingUnit,
94
- ...options
95
- };
96
- value = Number(value);
97
- if (isNaN(value)) {
98
- return '';
99
- }
100
- if (options.startingUnit === 'cent') {
101
- value = value / 100;
102
- }
103
- value = value.toString();
104
- let integer;
105
- let decimal;
106
- [integer, decimal] = value.split('.');
107
- let symbol = '';
108
- if (integer.startsWith('-')) {
109
- symbol = options.minusSymbol;
110
- integer = integer.substring(1);
111
- }
112
- if (/^-?\d+$/.test(value)) {
113
- decimal = null;
114
- }
115
- integer = (+integer).toString();
116
- const inWords = options.inWords;
117
- const unit = {
118
- num: inWords
119
- ? ['', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '点']
120
- : ['', '一', '二', '三', '四', '五', '六', '七', '八', '九', '点'],
121
- radice: inWords
122
- ? [
123
- '',
124
- '拾',
125
- '佰',
126
- '仟',
127
- '万',
128
- '拾',
129
- '佰',
130
- '仟',
131
- '亿',
132
- '拾',
133
- '佰',
134
- '仟',
135
- '万亿',
136
- '拾',
137
- '佰',
138
- '仟',
139
- '兆',
140
- '拾',
141
- '佰',
142
- '仟'
143
- ]
144
- : [
145
- '',
146
- '十',
147
- '百',
148
- '千',
149
- '万',
150
- '十',
151
- '百',
152
- '千',
153
- '亿',
154
- '十',
155
- '百',
156
- '千',
157
- '万亿',
158
- '十',
159
- '百',
160
- '千',
161
- '兆',
162
- '十',
163
- '百',
164
- '千'
165
- ],
166
- dec: ['角', '分', '厘', '毫']
167
- };
168
- if (inWords) {
169
- value = (+value).toFixed(5).toString();
170
- }
171
- let integerRes = '';
172
- const integerCount = integer.length;
173
- if (integer === '0' || integerCount === 0) {
174
- integerRes = '零';
175
- }
176
- else {
177
- let cnDesc = '';
178
- for (let i = 0; i < integerCount; i++) {
179
- const n = +integer[i];
180
- const j = integerCount - i - 1;
181
- const isZero = i > 1 && n !== 0 && integer[i - 1] === '0';
182
- const cnZero = isZero ? '零' : '';
183
- const isEmpptyUnit = (n === 0 && j % 4 !== 0) || integer.substring(i - 3, i - 3 + 4) === '0000';
184
- const descMark = cnDesc;
185
- let cnNum = unit.num[n];
186
- cnDesc = isEmpptyUnit ? '' : unit.radice[j];
187
- // 第一位是一十
188
- if (i === 0 && cnNum === '一' && cnDesc === '十')
189
- cnNum = '';
190
- const isChangeEr = n > 1 &&
191
- cnNum === '二' && // 去除首位
192
- ['', '十', '百'].indexOf(cnDesc) === -1 && // 不读两\两十\两百
193
- descMark !== '十'; // 不读十两
194
- if (isChangeEr)
195
- cnNum = '两';
196
- integerRes += cnZero + cnNum + cnDesc;
197
- }
198
- }
199
- // 小数部分拼接
200
- let decimalRes = '';
201
- const decimalCount = decimal ? decimal.toString().length : 0;
202
- if (decimal === null) {
203
- decimalRes = inWords ? '整' : '';
204
- }
205
- else if (decimal === '0') {
206
- decimalRes = '零';
207
- }
208
- else {
209
- for (let i = 0; i < decimalCount; i++) {
210
- if (inWords && i > unit.dec.length - 1)
211
- break;
212
- const n = decimal[i];
213
- const cnZero = n === '0' ? '零' : '';
214
- const cnNum = unit.num[+n];
215
- const cnDesc = inWords ? unit.dec[i] : '';
216
- decimalRes += cnZero + cnNum + cnDesc;
217
- }
218
- }
219
- const ret = symbol +
220
- (inWords
221
- ? integerRes + (decimalRes === '零' ? '元整' : `元${decimalRes}`)
222
- : integerRes + (decimalRes === '' ? '' : `点${decimalRes}`));
223
- return ret;
224
- }
225
- }
226
- CurrencyService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CurrencyService, deps: [{ token: i1.YunzaiConfigService }, { token: LOCALE_ID }, { token: DEFAULT_CURRENCY_CODE }], target: i0.ɵɵFactoryTarget.Injectable });
227
- CurrencyService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CurrencyService, providedIn: 'root' });
228
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CurrencyService, decorators: [{
229
- type: Injectable,
230
- args: [{ providedIn: 'root' }]
231
- }], ctorParameters: function () { return [{ type: i1.YunzaiConfigService }, { type: undefined, decorators: [{
232
- type: Inject,
233
- args: [LOCALE_ID]
234
- }] }, { type: undefined, decorators: [{
235
- type: Inject,
236
- args: [DEFAULT_CURRENCY_CODE]
237
- }] }]; } });
238
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3VycmVuY3kuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL3V0aWwvZm9ybWF0L2N1cnJlbmN5LnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFlBQVksRUFBRSxZQUFZLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUM3RCxPQUFPLEVBQUUscUJBQXFCLEVBQUUsTUFBTSxFQUFFLFVBQVUsRUFBRSxTQUFTLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFLckYsT0FBTyxFQUtMLG1CQUFtQixFQUNwQixNQUFNLGtCQUFrQixDQUFDOzs7QUFHMUIsTUFBTSxPQUFPLGVBQWU7SUFJMUIsWUFDRSxHQUF3QixFQUNHLE1BQWMsRUFDVix1QkFBK0IsS0FBSztRQUR4QyxXQUFNLEdBQU4sTUFBTSxDQUFRO1FBR3pDLElB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SB2YWx1ZS5zcGxpdCgnLicpO1xuICAgIGxldCBzeW1ib2wgPSAnJztcbiAgICBpZiAoaW50ZWdlci5zdGFydHNXaXRoKCctJykpIHtcbiAgICAgIHN5bWJvbCA9IG9wdGlvbnMubWludXNTeW1ib2whO1xuICAgICAgaW50ZWdlciA9IGludGVnZXIuc3Vic3RyaW5nKDEpO1xuICAgIH1cbiAgICBpZiAoL14tP1xcZCskLy50ZXN0KHZhbHVlKSkge1xuICAgICAgZGVjaW1hbCA9IG51bGw7XG4gICAgfVxuICAgIGludGVnZXIgPSAoK2ludGVnZXIpLnRvU3RyaW5nKCk7XG4gICAgY29uc3QgaW5Xb3JkcyA9IG9wdGlvbnMuaW5Xb3JkcztcbiAgICBjb25zdCB1bml0OiB7IFtrZXk6IHN0cmluZ106IHN0cmluZ1tdIH0gPSB7XG4gICAgICBudW06IGluV29yZHNcbiAgICAgICAgPyBbJycsICflo7knLCAn6LSwJywgJ+WPgScsICfogoYnLCAn5LyNJywgJ+mZhicsICfmn5InLCAn5o2MJywgJ+eOlicsICfngrknXVxuICAgICAgICA6IFsnJywgJ+S4gCcsICfkuownLCAn5LiJJywgJ+WbmycsICfkupQnLCAn5YWtJywgJ+S4gycsICflhasnLCAn5LmdJywgJ+eCuSddLFxuICAgICAgcmFkaWNlOiBpbldvcmRzXG4gICAgICAgID8gW1xuICAgICAgICAgICAgJycsXG4gICAgICAgICAgICAn5ou+JyxcbiAgICAgICAgICAgICfkvbAnLFxuICAgICAgICAgICAgJ+S7nycsXG4gICAgICAgICAgICAn5LiHJyxcbiAgICAgICAgICAgICfmi74nLFxuICAgICAgICAgICAgJ+S9sCcsXG4gICAgICAgICAgICAn5LufJyxcbiAgICAgICAgICAgICfkur8nLFxuICAgICAgICAgICAgJ+aLvicsXG4gICAgICAgICAgICAn5L2wJyxcbiAgICAgICAgICAgICfku58nLFxuICAgICAgICAgICAgJ+S4h+S6vycsXG4gICAgICAgICAgICAn5ou+JyxcbiAgICAgICAgICAgICfkvbAnLFxuICAgICAgICAgICAgJ+S7nycsXG4gICAgICAgICAgICAn5YWGJyxcbiAgICAgICAgICAgICfmi74nLFxuICAgICAgICAgICAgJ+S9sCcsXG4gICAgICAgICAgICAn5LufJ1xuICAgICAgICAgIF1cbiAgICAgICAgOiBbXG4gICAgICAgICAgICAnJyxcbiAgICAgICAgICAgICfljYEnLFxuICAgICAgICAgICAgJ+eZvicsXG4gICAgICAgICAgICAn5Y2DJyxcbiAgICAgICAgICAgICfkuIcnLFxuICAgICAgICAgICAgJ+WNgScsXG4gICAgICAgICAgICAn55m+JyxcbiAgICAgICAgICAgICfljYMnLFxuICAgICAgICAgICAgJ+S6vycsXG4gICAgICAgICAgICAn5Y2BJyxcbiAgICAgICAgICAgICfnmb4nLFxuICAgICAgICAgICAgJ+WNgycsXG4gICAgICAgICAgICAn5LiH5Lq/JyxcbiAgICAgICAgICAgICfljYEnLFxuICAgICAgICAgICAgJ+eZvicsXG4gICAgICAgICAgICAn5Y2DJyxcbiAgICAgICAgICAgICflhYYnLFxuICAgICAgICAgICAgJ+WNgScsXG4gICAgICAgICAgICAn55m+JyxcbiAgICAgICAgICAgICfljYMnXG4gICAgICAgICAgXSxcbiAgICAgIGRlYzogWyfop5InLCAn5YiGJywgJ+WOmCcsICfmr6snXVxuICAgIH07XG4gICAgaWYgKGluV29yZHMpIHtcbiAgICAgIHZhbHVlID0gKCt2YWx1ZSkudG9GaXhlZCg1KS50b1N0cmluZygpO1xuICAgIH1cbiAgICBsZXQgaW50ZWdlclJlcyA9ICcnO1xuICAgIGNvbnN0IGludGVnZXJDb3VudCA9IGludGVnZXIubGVuZ3RoO1xuICAgIGlmIChpbnRlZ2VyID09PSAnMCcgfHwgaW50ZWdlckNvdW50ID09PSAwKSB7XG4gICAgICBpbnRlZ2VyUmVzID0gJ+mbtic7XG4gICAgfSBlbHNlIHtcbiAgICAgIGxldCBjbkRlc2MgPSAnJztcbiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgaW50ZWdlckNvdW50OyBpKyspIHtcbiAgICAgICAgY29uc3QgbiA9ICtpbnRlZ2VyW2ldO1xuICAgICAgICBjb25zdCBqID0gaW50ZWdlckNvdW50IC0gaSAtIDE7XG4gICAgICAgIGNvbnN0IGlzWmVybyA9IGkgPiAxICYmIG4gIT09IDAgJiYgaW50ZWdlcltpIC0gMV0gPT09ICcwJztcbiAgICAgICAgY29uc3QgY25aZXJvID0gaXNaZXJvID8gJ+mbticgOiAnJztcbiAgICAgICAgY29uc3QgaXNFbXBwdHlVbml0ID0gKG4gPT09IDAgJiYgaiAlIDQgIT09IDApIHx8IGludGVnZXIuc3Vic3RyaW5nKGkgLSAzLCBpIC0gMyArIDQpID09PSAnMDAwMCc7XG4gICAgICAgIGNvbnN0IGRlc2NNYXJrID0gY25EZXNjO1xuICAgICAgICBsZXQgY25OdW0gPSB1bml0Lm51bVtuXTtcblxuICAgICAgICBjbkRlc2MgPSBpc0VtcHB0eVVuaXQgPyAnJyA6IHVuaXQucmFkaWNlW2pdO1xuICAgICAgICAvLyDnrKzkuIDkvY3mmK/kuIDljYFcbiAgICAgICAgaWYgKGkgPT09IDAgJiYgY25OdW0gPT09ICfkuIAnICYmIGNuRGVzYyA9PT0gJ+WNgScpIGNuTnVtID0gJyc7XG4gICAgICAgIGNvbnN0IGlzQ2hhbmdlRXIgPVxuICAgICAgICAgIG4gPiAxICYmXG4gICAgICAgICAgY25OdW0gPT09ICfkuownICYmIC8vIOWOu+mZpOmmluS9jVxuICAgICAgICAgIFsnJywgJ+WNgScsICfnmb4nXS5pbmRleE9mKGNuRGVzYykgPT09IC0xICYmIC8vIOS4jeivu+S4pFxc5Lik5Y2BXFzkuKTnmb5cbiAgICAgICAgICBkZXNjTWFyayAhPT0gJ+WNgSc7IC8vIOS4jeivu+WNgeS4pFxuICAgICAgICBpZiAoaXNDaGFuZ2VFcikgY25OdW0gPSAn5LikJztcbiAgICAgICAgaW50ZWdlclJlcyArPSBjblplcm8gKyBjbk51bSArIGNuRGVzYzt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XG4gIH1cbn1cbiJdfQ==
@@ -1,132 +0,0 @@
1
- import { DOCUMENT } from '@angular/common';
2
- import { Inject, Injectable } from '@angular/core';
3
- import { BehaviorSubject, filter, share } from 'rxjs';
4
- import * as i0 from "@angular/core";
5
- /**
6
- * `LazyService` delay loading JS or CSS files.
7
- *
8
- * 延迟加载资源(js 或 css)服务
9
- */
10
- export class LazyService {
11
- constructor(doc) {
12
- this.doc = doc;
13
- this.list = {};
14
- this.cached = {};
15
- this._notify = new BehaviorSubject([]);
16
- }
17
- get change() {
18
- return this._notify.asObservable().pipe(share(), filter(ls => ls.length !== 0));
19
- }
20
- clear() {
21
- this.list = {};
22
- this.cached = {};
23
- }
24
- attachAttributes(el, attributes) {
25
- if (attributes == null)
26
- return;
27
- Object.entries(attributes).forEach(([key, value]) => {
28
- el.setAttribute(key, value);
29
- });
30
- }
31
- /**
32
- * Load script or style files
33
- */
34
- load(paths) {
35
- if (!Array.isArray(paths)) {
36
- paths = [paths];
37
- }
38
- const promises = [];
39
- paths
40
- .map(v => (typeof v !== 'object' ? { path: v } : v))
41
- .forEach(item => {
42
- if (item.path.endsWith('.js')) {
43
- promises.push(this.loadScript(item.path, item.options));
44
- }
45
- else {
46
- promises.push(this.loadStyle(item.path, item.options));
47
- }
48
- });
49
- return Promise.all(promises).then(res => {
50
- this._notify.next(res);
51
- return Promise.resolve(res);
52
- });
53
- }
54
- loadScript(path, innerContent, attributes) {
55
- const options = typeof innerContent === 'object'
56
- ? innerContent
57
- : {
58
- innerContent,
59
- attributes
60
- };
61
- return new Promise(resolve => {
62
- if (this.list[path] === true) {
63
- resolve({ ...this.cached[path], status: 'loading' });
64
- return;
65
- }
66
- this.list[path] = true;
67
- const onSuccess = (item) => {
68
- this.cached[path] = item;
69
- resolve(item);
70
- this._notify.next([item]);
71
- };
72
- const node = this.doc.createElement('script');
73
- node.type = 'text/javascript';
74
- node.src = path;
75
- this.attachAttributes(node, options.attributes);
76
- if (options.innerContent) {
77
- node.innerHTML = options.innerContent;
78
- }
79
- node.onload = () => onSuccess({
80
- path,
81
- status: 'ok'
82
- });
83
- node.onerror = error => onSuccess({
84
- path,
85
- status: 'error',
86
- error
87
- });
88
- this.doc.getElementsByTagName('head')[0].appendChild(node);
89
- });
90
- }
91
- loadStyle(path, rel, innerContent, attributes) {
92
- const options = typeof rel === 'object'
93
- ? rel
94
- : {
95
- rel,
96
- innerContent,
97
- attributes
98
- };
99
- return new Promise(resolve => {
100
- if (this.list[path] === true) {
101
- resolve(this.cached[path]);
102
- return;
103
- }
104
- this.list[path] = true;
105
- const node = this.doc.createElement('link');
106
- node.rel = options.rel ?? 'stylesheet';
107
- node.type = 'text/css';
108
- node.href = path;
109
- this.attachAttributes(node, options.attributes);
110
- if (options.innerContent) {
111
- node.innerHTML = options.innerContent;
112
- }
113
- this.doc.getElementsByTagName('head')[0].appendChild(node);
114
- const item = {
115
- path,
116
- status: 'ok'
117
- };
118
- this.cached[path] = item;
119
- resolve(item);
120
- });
121
- }
122
- }
123
- LazyService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LazyService, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
124
- LazyService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LazyService, providedIn: 'root' });
125
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LazyService, decorators: [{
126
- type: Injectable,
127
- args: [{ providedIn: 'root' }]
128
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
129
- type: Inject,
130
- args: [DOCUMENT]
131
- }] }]; } });
132
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eS5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvdXRpbC9vdGhlci9sYX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