@yelon/util 12.0.7 → 12.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. package/bundles/browser.umd.js +5 -7
  2. package/bundles/browser.umd.js.map +1 -1
  3. package/bundles/yelon-util-array.umd.js +5 -7
  4. package/bundles/yelon-util-array.umd.js.map +1 -1
  5. package/bundles/yelon-util-config.umd.js +5 -7
  6. package/bundles/yelon-util-config.umd.js.map +1 -1
  7. package/bundles/yelon-util-date-time.umd.js +4 -4
  8. package/bundles/yelon-util-decorator.umd.js +3 -3
  9. package/bundles/yelon-util-form.umd.js +3 -3
  10. package/bundles/yelon-util-format.umd.js +44 -14
  11. package/bundles/yelon-util-format.umd.js.map +1 -1
  12. package/bundles/yelon-util-math.umd.js +3 -3
  13. package/bundles/yelon-util-other.umd.js +6 -8
  14. package/bundles/yelon-util-other.umd.js.map +1 -1
  15. package/bundles/yelon-util-pipes-currency.umd.js +4 -4
  16. package/bundles/yelon-util-pipes-filter.umd.js +3 -3
  17. package/bundles/yelon-util-pipes-format.umd.js +14 -3
  18. package/bundles/yelon-util-pipes-format.umd.js.map +1 -1
  19. package/bundles/yelon-util-pipes.umd.js +6 -12
  20. package/bundles/yelon-util-pipes.umd.js.map +1 -1
  21. package/bundles/yelon-util-token.umd.js +3 -3
  22. package/bundles/yelon-util.umd.js +15 -37
  23. package/bundles/yelon-util.umd.js.map +1 -1
  24. package/config/config.types.d.ts +2 -0
  25. package/config/index.d.ts +1 -0
  26. package/config/stomp/stomp.type.d.ts +2 -0
  27. package/config/yelon-util-config.metadata.json +1 -1
  28. package/esm2015/config/config.types.js +1 -1
  29. package/esm2015/config/index.js +2 -1
  30. package/esm2015/config/stomp/stomp.type.js +2 -0
  31. package/esm2015/format/string.js +40 -8
  32. package/esm2015/pipes/format/mask.pipe.js +12 -1
  33. package/fesm2015/yelon-util-config.js.map +1 -1
  34. package/fesm2015/yelon-util-format.js +39 -7
  35. package/fesm2015/yelon-util-format.js.map +1 -1
  36. package/fesm2015/yelon-util-pipes-format.js +11 -0
  37. package/fesm2015/yelon-util-pipes-format.js.map +1 -1
  38. package/format/string.d.ts +23 -1
  39. package/format/yelon-util-format.metadata.json +1 -1
  40. package/package.json +1 -1
  41. package/pipes/format/mask.pipe.d.ts +13 -1
@@ -6,4 +6,4 @@ export const YUNZAI_CONFIG = new InjectionToken('yunzai-config', {
6
6
  export function YUNZAI_CONFIG_FACTORY() {
7
7
  return {};
8
8
  }
9
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLnR5cGVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvdXRpbC9jb25maWcvY29uZmlnLnR5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFrRS9DLE1BQU0sQ0FBQyxNQUFNLGFBQWEsR0FBRyxJQUFJLGNBQWMsQ0FBZSxlQUFlLEVBQUU7SUFDN0UsVUFBVSxFQUFFLE1BQU07SUFDbEIsT0FBTyxFQUFFLHFCQUFxQjtDQUMvQixDQUFDLENBQUM7QUFFSCxNQUFNLFVBQVUscUJBQXFCO0lBQ25DLE9BQU8sRUFBRSxDQUFDO0FBQ1osQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IEluamVjdGlvblRva2VuIH0gZnJvbSAnQGFuZ3VsYXIvY29yZSc7XG5cbmltcG9ydCB7XG4gIFl1bnphaURhdGVSYW5nZVBpY2tlckNvbmZpZyxcbiAgWXVuemFpRXJyb3JDb2xsZWN0Q29uZmlnLFxuICBZdW56YWlJbWFnZUNvbmZpZyxcbiAgWXVuemFpTG9hZGluZ0NvbmZpZyxcbiAgWXVuemFpTG9kb3BDb25maWcsXG4gIFl1bnphaU1lZGlhQ29uZmlnLFxuICBZdW56YWlPbmJvYXJkaW5nQ29uZmlnLFx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G5leHBvcnQgZnVuY3Rpb24gWVVOWkFJX0NPTkZJR19GQUNUT1JZKCk6IFl1bnphaUNvbmZpZyB7XG4gIHJldHVybiB7fTtcbn1cbiJdfQ==
@@ -9,6 +9,7 @@ export * from './theme/index';
9
9
  export * from './mock/mock.type';
10
10
  export * from './sf/sf.type';
11
11
  export * from './bis/bis.type';
12
+ export * from './stomp/stomp.type';
12
13
  export * from './config.types';
13
14
  export * from './config.service';
14
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy91dGlsL2NvbmZpZy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLGFBQWEsQ0FBQztBQUM1QixjQUFjLGdCQUFnQixDQUFDO0FBQy9CLGNBQWMsa0JBQWtCLENBQUM7QUFDakMsY0FBYyxvQkFBb0IsQ0FBQztBQUNuQyxjQUFjLG9CQUFvQixDQUFDO0FBQ25DLGNBQWMsbUJBQW1CLENBQUM7QUFDbEMsY0FBYyxzQkFBc0IsQ0FBQztBQUNyQyxjQUFjLGVBQWUsQ0FBQztBQUM5QixjQUFjLGtCQUFrQixDQUFDO0FBQ2pDLGNBQWMsY0FBYyxDQUFDO0FBQzdCLGNBQWMsZ0JBQWdCLENBQUM7QUFFL0IsY0FBYyxnQkFBZ0IsQ0FBQztBQUMvQixjQUFjLGtCQUFrQixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9hYmMvaW5kZXgnO1xuZXhwb3J0ICogZnJvbSAnLi9hY2wvYWNsLnR5cGUnO1xuZXhwb3J0ICogZnJvbSAnLi9hdXRoL2F1dGgudHlwZSc7XG5leHBvcnQgKiBmcm9tICcuL2NhY2hlL2NhY2hlLnR5cGUnO1xuZXhwb3J0ICogZnJvbSAnLi9jaGFydC9j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Cc7XG5leHBvcnQgKiBmcm9tICcuL2FjbC9hY2wudHlwZSc7XG5leHBvcnQgKiBmcm9tICcuL2F1dGgvYXV0aC50eXBlJztcbmV4cG9ydCAqIGZyb20gJy4vY2FjaGUvY2FjaGUudHlwZSc7XG5leHBvcnQgKiBmcm9tICcuL2NoYXJ0L2NoYXJ0LnR5cGUnO1xuZXhwb3J0ICogZnJvbSAnLi91dGlsL2FycmF5LnR5cGUnO1xuZXhwb3J0ICogZnJvbSAnLi91dGlsL2N1cnJlbmN5LnR5cGUnO1xuZXhwb3J0ICogZnJvbSAnLi90aGVtZS9pbmRleCc7XG5leHBvcnQgKiBmcm9tICcuL21vY2svbW9jay50eXBlJztcbmV4cG9ydCAqIGZyb20gJy4vc2Yvc2YudHlwZSc7XG5leHBvcnQgKiBmcm9tICcuL2Jpcy9iaXMudHlwZSc7XG5leHBvcnQgKiBmcm9tICcuL3N0b21wL3N0b21wLnR5cGUnO1xuXG5leHBvcnQgKiBmcm9tICcuL2NvbmZpZy50eXBlcyc7XG5leHBvcnQgKiBmcm9tICcuL2NvbmZpZy5zZXJ2aWNlJztcbiJdfQ==
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvbXAudHlwZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL3V0aWwvY29uZmlnL3N0b21wL3N0b21wLnR5cGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IFJ4U3RvbXBDb25maWcgfSBmcm9tICdAc3RvbXAvcngtc3RvbXAnO1xuXG5leHBvcnQgdHlwZSBZdW56YWlTdG9tcENvbmZpZyA9IFJ4U3RvbXBDb25maWc7XG4iXX0=
@@ -17,28 +17,60 @@ export function format(str, obj, needDeepGet = false) {
17
17
  * Format mask
18
18
  *
19
19
  * 格式化掩码
20
+ *
21
+ * | 字符 | 描述 |
22
+ * | --- | --- |
23
+ * | `0` | 任意数字,若该位置字符不符合,则默认为 `0` 填充 |
24
+ * | `9` | 任意数字 |
25
+ * | `#` | 任意字符 |
26
+ * | `U` | 转换大写 |
27
+ * | `L` | 转换小写 |
28
+ * | `*` | 转换为 `*` 字符 |
29
+ *
20
30
  * ```ts
21
31
  * formatMask('123', '(###)') => (123)
32
+ * formatMask('15900000000', '999****9999') => 159****0000
22
33
  * ```
23
34
  */
24
- export function formatMask(value, mask) {
35
+ export function formatMask(value, option) {
25
36
  if (!value) {
26
37
  return '';
27
38
  }
39
+ const opt = Object.assign({}, (typeof option === 'string' ? { mask: option } : option));
40
+ const tokens = Object.assign({ '0': { pattern: /\d/, default: '0' }, '9': { pattern: /\d/ }, '#': { pattern: /[a-zA-Z0-9]/ }, U: {
41
+ pattern: /[a-zA-Z]/,
42
+ transform: char => char.toLocaleUpperCase()
43
+ }, L: {
44
+ pattern: /[a-zA-Z]/,
45
+ transform: char => char.toLocaleLowerCase()
46
+ }, '*': {
47
+ pattern: /.*/,
48
+ transform: _ => `*`
49
+ } }, opt.tokens);
28
50
  const splitValue = value.split('');
29
- return mask
51
+ return opt.mask
30
52
  .split('')
31
53
  .reduce((res, cur) => {
32
- if (cur === '#') {
33
- if (splitValue.length > 0) {
34
- res.push(splitValue.shift());
35
- }
54
+ var _a;
55
+ const token = tokens[cur];
56
+ if (!token) {
57
+ res.push(cur);
58
+ return res;
59
+ }
60
+ const value = (_a = splitValue.shift()) !== null && _a !== void 0 ? _a : '';
61
+ if (!token.pattern.test(value)) {
62
+ if (token.default)
63
+ res.push(token.default);
64
+ return res;
65
+ }
66
+ if (typeof token.transform === 'function') {
67
+ res.push(token.transform(value));
36
68
  }
37
69
  else {
38
- res.push(cur);
70
+ res.push(value);
39
71
  }
40
72
  return res;
41
73
  }, [])
42
74
  .join('');
43
75
  }
44
- //# sourceMappingURL=data:application/json;base64,eyJ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uICByZXR1cm4gKHN0ciB8fCAnJykucmVwbGFjZSgvXFwkeyhbXn1dKyl9L2csIChfd29yazogc3RyaW5nLCBrZXk6IHN0cmluZykgPT5cbiAgICBuZWVkRGVlcEdldCA/IGRlZXBHZXQob2JqLCBrZXkuc3BsaXQoJy4nKSwgJycpIDogKG9iaiB8fCB7fSlba2V5XSB8fCAnJ1xuICApO1xufVxuXG4vKipcbiAqIEZvcm1hdCBtYXNrXG4gKlxuICog5qC85byP5YyW5o6p56CBXG4gKiBgYGB0c1xuICogZm9ybWF0TWFzaygnMTIzJywgJygjIyMpJykgPT4gKDEyMylcbiAqIGBgYFxuICovXG5leHBvcnQgZnVuY3Rpb24gZm9ybWF0TWFzayh2YWx1ZTogc3RyaW5nLCBtYXNrOiBzdHJpbmcpOiBzdHJpbmcge1xuICBpZiAoIXZhbHVlKSB7XG4gICAgcmV0dXJuICcnO1xuICB9XG5cbiAgY29uc3Qgc3BsaXRWYWx1ZSA9IHZhbHVlLnNwbGl0KCcnKTtcbiAgcmV0dXJuIG1hc2tcbiAgICAuc3BsaXQoJycpXG4gICAgLnJlZHVjZSgocmVzLCBjdXIpID0+IHtcbiAgICAgIGlmIChjdXIgPT09ICcjJykge1xuICAgICAgICBpZiAoc3BsaXRWYWx1ZS5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgcmVzLnB1c2goc3BsaXRWYWx1ZS5zaGlmdCgpISk7XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHJlcy5wdXNoKGN1cik7XG4gICAgICB9XG4gICAgICByZXR1cm4gcmVzO1xuICAgIH0sIFtdIGFzIHN0cmluZ1tdKVxuICAgIC5qb2luKCcnKTtcbn1cbiJdfQ==
76
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RyaW5nLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvdXRpbC9mb3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S5zcGxpdCgnJyk7XG4gIHJldHVybiBvcHQubWFza1xuICAgIC5zcGxpdCgnJylcbiAgICAucmVkdWNlKChyZXMsIGN1cikgPT4ge1xuICAgICAgY29uc3QgdG9rZW4gPSB0b2tlbnNbY3VyXTtcbiAgICAgIGlmICghdG9rZW4pIHtcbiAgICAgICAgcmVzLnB1c2goY3VyKTtcbiAgICAgICAgcmV0dXJuIHJlcztcbiAgICAgIH1cblxuICAgICAgY29uc3QgdmFsdWUgPSBzcGxpdFZhbHVlLnNoaWZ0KCkgPz8gJyc7XG4gICAgICBpZiAoIXRva2VuLnBhdHRlcm4udGVzdCh2YWx1ZSkpIHtcbiAgICAgICAgaWYgKHRva2VuLmRlZmF1bHQpIHJlcy5wdXNoKHRva2VuLmRlZmF1bHQpO1xuICAgICAgICByZXR1cm4gcmVzO1xuICAgICAgfVxuXG4gICAgICBpZiAodHlwZW9mIHRva2VuLnRyYW5zZm9ybSA9PT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICByZXMucHVzaCh0b2tlbi50cmFuc2Zvcm0odmFsdWUpKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHJlcy5wdXNoKHZhbHVlKTtcbiAgICAgIH1cbiAgICAgIHJldHVybiByZXM7XG4gICAgfSwgW10gYXMgc3RyaW5nW10pXG4gICAgLmpvaW4oJycpO1xufVxuIl19
@@ -5,8 +5,19 @@ export class FormatMaskPipe {
5
5
  * Format mask
6
6
  *
7
7
  * 格式化掩码
8
+ *
9
+ * | 字符 | 描述 |
10
+ * | --- | --- |
11
+ * | `0` | 任意数字,若该位置字符不符合,则默认为 `0` 填充 |
12
+ * | `9` | 任意数字 |
13
+ * | `#` | 任意字符 |
14
+ * | `U` | 转换大写 |
15
+ * | `L` | 转换小写 |
16
+ * | `*` | 转换为 `*` 字符 |
17
+ *
8
18
  * ```ts
9
19
  * formatMask('123', '(###)') => (123)
20
+ * formatMask('15900000000', '999****9999') => 159****0000
10
21
  * ```
11
22
  */
12
23
  transform(value, mask) {
@@ -16,4 +27,4 @@ export class FormatMaskPipe {
16
27
  FormatMaskPipe.decorators = [
17
28
  { type: Pipe, args: [{ name: 'mask' },] }
18
29
  ];
19
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFzay5waXBlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvdXRpbC9waXBlcy9mb3JtYXQvbWFzay5waXBlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxJQUFJLEVBQWlCLE1BQU0sZUFBZSxDQUFDO0FBRXBELE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUdoRCxNQUFNLE9BQU8sY0FBYztJQUN6Qjs7Ozs7OztPQU9HO0lBQ0gsU0FBUyxDQUFDLEtBQWEsRUFBRSxJQUFZO1FBQ25DLE9BQU8sVUFBVSxDQUFDLEtBQUssRUFBRSxJQUFJLENBQUMsQ0FBQztJQUNqQyxDQUFDOzs7WUFaRixJQUFJLFNBQUMsRUFBRSxJQUFJLEVBQUUsTUFBTSxFQUFFIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgUGlwZSwgUGlwZVRyYW5zZm9ybSB9IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xuXG5pbXBvcnQgeyBmb3JtYXRNYXNrIH0gZnJvbSAnQHllbG9uL3V0aWwvZm9ybWF0JztcblxuQFBpcGUoeyBuYW1lOiAnbWFzaycgfSlcbmV4cG9ydCBjbGFzcyBGb3JtYXRNYXNrUGlwZSBpbXBsZW1lbnRzIFBpcGVUcmFuc2Zvcm0ge1xuICAvKipcbiAgICogRm9ybWF0IG1hc2tcbiAgICpcbiAgICog5qC85byP5YyW5o6p56CBXG4gICAqIGBgYHRzXG4gICAqIGZvcm1hdE1hc2soJzEyMycsICcoIyMjKScpID0+IC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ICogRm9ybWF0IG1hc2tcbiAgICpcbiAgICog5qC85byP5YyW5o6p56CBXG4gICAqXG4gICAqIHwg5a2X56ymIHwg5o+P6L+wIHxcbiAgICogfCAtLS0gfCAtLS0gfFxuICAgKiB8IGAwYCB8IOS7u+aEj+aVsOWtl++8jOiLpeivpeS9jee9ruWtl+espuS4jeespuWQiO+8jOWImem7mOiupOS4uiBgMGAg5aGr5YWFIHxcbiAgICogfCBgOWAgfCDku7vmhI/mlbDlrZcgfFxuICAgKiB8IGAjYCB8IOS7u+aEj+Wtl+espiB8XG4gICAqIHwgYFVgIHwg6L2s5o2i5aSn5YaZIHxcbiAgICogfCBgTGAgfCDovazmjaLlsI/lhpkgfFxuICAgKiB8IGAqYCB8IOi9rOaNouS4uiBgKmAg5a2X56ymIHxcbiAgICpcbiAgICogYGBgdHNcbiAgICogZm9ybWF0TWFzaygnMTIzJywgJygjIyMpJykgPT4gKDEyMylcbiAgICogZm9ybWF0TWFzaygnMTU5MDAwMDAwMDAnLCAnOTk5KioqKjk5OTknKSA9PiAxNTkqKioqMDAwMFxuICAgKiBgYGBcbiAgICovXG4gIHRyYW5zZm9ybSh2YWx1ZTogc3RyaW5nLCBtYXNrOiBzdHJpbmcgfCBGb3JtYXRNYXNrT3B0aW9uKTogc3RyaW5nIHtcbiAgICByZXR1cm4gZm9ybWF0TWFzayh2YWx1ZSwgbWFzayk7XG4gIH1cbn1cbiJdfQ==
@@ -1 +1 @@
1
- {"version":3,"file":"yelon-util-config.js","sources":["../../../../packages/util/config/abc/sv.type.ts","../../../../packages/util/config/config.types.ts","../../../../packages/util/config/config.service.ts","../../../../packages/util/config/yelon-util-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 { 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 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;;;MCkEd,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;;MChEa,mBAAmB;IAG9B,YAA+C,aAA4B;QACzE,IAAI,CAAC,MAAM,qBAAQ,aAAa,CAAE,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,mCAAQ,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAK,KAAK,CAAE,CAAC;KAC1E;;;;YA3BF,UAAU,SAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;4CAInB,QAAQ,YAAI,MAAM,SAAC,aAAa;;;ACZ/C;;;;;;"}
1
+ {"version":3,"file":"yelon-util-config.js","sources":["../../../../packages/util/config/abc/sv.type.ts","../../../../packages/util/config/config.types.ts","../../../../packages/util/config/config.service.ts","../../../../packages/util/config/yelon-util-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,qBAAQ,aAAa,CAAE,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,mCAAQ,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAK,KAAK,CAAE,CAAC;KAC1E;;;;YA3BF,UAAU,SAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;4CAInB,QAAQ,YAAI,MAAM,SAAC,aAAa;;;ACZ/C;;;;;;"}
@@ -23,25 +23,57 @@ function format(str, obj, needDeepGet = false) {
23
23
  * Format mask
24
24
  *
25
25
  * 格式化掩码
26
+ *
27
+ * | 字符 | 描述 |
28
+ * | --- | --- |
29
+ * | `0` | 任意数字,若该位置字符不符合,则默认为 `0` 填充 |
30
+ * | `9` | 任意数字 |
31
+ * | `#` | 任意字符 |
32
+ * | `U` | 转换大写 |
33
+ * | `L` | 转换小写 |
34
+ * | `*` | 转换为 `*` 字符 |
35
+ *
26
36
  * ```ts
27
37
  * formatMask('123', '(###)') => (123)
38
+ * formatMask('15900000000', '999****9999') => 159****0000
28
39
  * ```
29
40
  */
30
- function formatMask(value, mask) {
41
+ function formatMask(value, option) {
31
42
  if (!value) {
32
43
  return '';
33
44
  }
45
+ const opt = Object.assign({}, (typeof option === 'string' ? { mask: option } : option));
46
+ const tokens = Object.assign({ '0': { pattern: /\d/, default: '0' }, '9': { pattern: /\d/ }, '#': { pattern: /[a-zA-Z0-9]/ }, U: {
47
+ pattern: /[a-zA-Z]/,
48
+ transform: char => char.toLocaleUpperCase()
49
+ }, L: {
50
+ pattern: /[a-zA-Z]/,
51
+ transform: char => char.toLocaleLowerCase()
52
+ }, '*': {
53
+ pattern: /.*/,
54
+ transform: _ => `*`
55
+ } }, opt.tokens);
34
56
  const splitValue = value.split('');
35
- return mask
57
+ return opt.mask
36
58
  .split('')
37
59
  .reduce((res, cur) => {
38
- if (cur === '#') {
39
- if (splitValue.length > 0) {
40
- res.push(splitValue.shift());
41
- }
60
+ var _a;
61
+ const token = tokens[cur];
62
+ if (!token) {
63
+ res.push(cur);
64
+ return res;
65
+ }
66
+ const value = (_a = splitValue.shift()) !== null && _a !== void 0 ? _a : '';
67
+ if (!token.pattern.test(value)) {
68
+ if (token.default)
69
+ res.push(token.default);
70
+ return res;
71
+ }
72
+ if (typeof token.transform === 'function') {
73
+ res.push(token.transform(value));
42
74
  }
43
75
  else {
44
- res.push(cur);
76
+ res.push(value);
45
77
  }
46
78
  return res;
47
79
  }, [])
@@ -1 +1 @@
1
- {"version":3,"file":"yelon-util-format.js","sources":["../../../../packages/util/format/string.ts","../../../../packages/util/format/validate.ts","../../../../packages/util/format/currency.types.ts","../../../../packages/util/format/currency.service.ts","../../../../packages/util/format/yelon-util-format.ts"],"sourcesContent":["import type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nimport { deepGet } from '@yelon/util/other';\n\n/**\n * String formatting\n *\n * 字符串格式化\n * ```\n * format('this is ${name}', { name: 'asdf' })\n * // output: this is asdf\n * format('this is ${user.name}', { user: { name: 'asdf' } }, true)\n * // output: this is asdf\n * ```\n */\nexport function format(\n str: string | null | undefined,\n obj: NzSafeAny | null | undefined,\n needDeepGet: boolean = false\n): string {\n return (str || '').replace(/\\${([^}]+)}/g, (_work: string, key: string) =>\n needDeepGet ? deepGet(obj, key.split('.'), '') : (obj || {})[key] || ''\n );\n}\n\n/**\n * Format mask\n *\n * 格式化掩码\n * ```ts\n * formatMask('123', '(###)') => (123)\n * ```\n */\nexport function formatMask(value: string, mask: string): string {\n if (!value) {\n return '';\n }\n\n const splitValue = value.split('');\n return mask\n .split('')\n .reduce((res, cur) => {\n if (cur === '#') {\n if (splitValue.length > 0) {\n res.push(splitValue.shift()!);\n }\n } else {\n res.push(cur);\n }\n return res;\n }, [] as string[])\n .join('');\n}\n","export const REGEX_STR = {\n num: `((-?\\\\d+\\\\.\\\\d+)|(-?\\\\d+)|(-?\\\\.\\\\d+))`,\n idCard: `(^\\\\d{15}$)|(^\\\\d{17}(?:[0-9]|X)$)`,\n mobile: `^(0|\\\\+?86|17951)?1[0-9]{10}$`,\n url: `(((^https?:(?:\\/\\/)?)(?:[-;:&=\\\\+\\\\$,\\\\w]+@)?[A-Za-z0-9.-]+(?::\\\\d+)?|(?:www.|[-;:&=\\\\+\\\\$,\\\\w]+@)[A-Za-z0-9.-]+)((?:\\/[\\\\+~%\\\\/.\\\\w-_]*)?\\\\??(?:[-\\\\+=&;%@.\\\\w_]*)#?(?:[\\\\w]*))?)`,\n ip: `(?:^(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)){3}$)|(?:^(?:(?:[a-fA-F\\\\d]{1,4}:){7}(?:[a-fA-F\\\\d]{1,4}|:)|(?:[a-fA-F\\\\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)){3}|:[a-fA-F\\\\d]{1,4}|:)|(?:[a-fA-F\\\\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\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-9a-zA-Z]{1,})?$)`,\n color: `(?:#|0x)(?:[a-f0-9]{3}|[a-f0-9]{6})\\\\b|(?:rgb|hsl)a?\\\\([^\\\\)]*\\\\)`,\n chinese: `[\\u4e00-\\u9fa5]+`\n};\n\nfunction genRegex(str: string, flags?: string): RegExp {\n return new RegExp(`^${str}$`, flags);\n}\n\nexport const REGEX = {\n num: genRegex(REGEX_STR.num),\n idCard: genRegex(REGEX_STR.idCard, 'i'),\n mobile: genRegex(REGEX_STR.mobile),\n url: genRegex(REGEX_STR.url),\n ip: genRegex(REGEX_STR.ip),\n color: genRegex(REGEX_STR.color),\n chinese: genRegex(REGEX_STR.chinese)\n};\n\n/**\n * Wheter is number\n *\n * 是否为数字\n */\nexport function isNum(value: string | number): boolean {\n return REGEX.num.test(value.toString());\n}\n\n/**\n * Wheter is integer\n *\n * 是否为整数\n */\nexport function isInt(value: string | number): boolean {\n return isNum(value) && parseInt(value.toString(), 10).toString() === value.toString();\n}\n\n/**\n * Wheter is decimal\n *\n * 是否为小数点数值\n */\nexport function isDecimal(value: string | number): boolean {\n return isNum(value) && !isInt(value);\n}\n\n/**\n * Wheter is People's Republic of China identity card\n *\n * 是否为中华人民共和国居民身份证\n */\nexport function isIdCard(value: string): boolean {\n return REGEX.idCard.test(value);\n}\n\n/**\n * Wheter is china mobile (China)\n *\n * 是否为手机号(中国)\n */\nexport function isMobile(value: string): boolean {\n return REGEX.mobile.test(value);\n}\n\n/**\n * Wheter is url address\n *\n * 是否URL地址\n */\nexport function isUrl(url: string): boolean {\n return REGEX.url.test(url);\n}\n\n/**\n * Wheter is IPv4 address (Support v4, v6)\n *\n * 是否IP4地址(支持v4、v6)\n */\nexport function isIp(ip: string): boolean {\n return REGEX.ip.test(ip);\n}\n\n/**\n * Wheter is color\n *\n * 是否颜色代码值\n */\nexport function isColor(color: string): boolean {\n return REGEX.color.test(color);\n}\n\n/**\n * Wheter is chinese\n *\n * 是否中文\n */\nexport function isChinese(value: string): boolean {\n return REGEX.chinese.test(value);\n}\n","export type CurrencyStartingUnit = 'yuan' | 'cent';\n\nexport interface CurrencyStartingUnitOptions {\n /**\n * The starting unit of the value, `yuan` means 元, `cent` means 分, default: `yuan`\n *\n * 值的起始单位,`yuan` 元,`cent` 分,默认:`yuan`\n */\n startingUnit?: CurrencyStartingUnit;\n}\n\nexport interface CurrencyFormatOptions extends CurrencyStartingUnitOptions {\n /**\n * Using `DEFAULT_CURRENCY_CODE` when value is `true\n *\n * 是否使用 `CurrencyPipe` 来替代\n */\n useAngular?: boolean;\n /**\n * 精度,默认:`2`\n */\n precision?: number;\n /**\n * 是否忽略精度 `.0` 或 `.00` 结尾的字符,默认:`true`\n */\n ignoreZeroPrecision?: boolean;\n\n /**\n * Use anguar `currency` pipe parse when is set, pls refer to [document](https://angular.io/api/common/CurrencyPipe)\n *\n * 若指定则表示使用 Angular 自带的 `currency` 管道来解析,见[文档](https://angular.cn/api/common/CurrencyPipe)\n */\n ngCurrency?: {\n display: 'code' | 'symbol' | 'symbol-narrow';\n currencyCode?: string;\n digitsInfo?: string;\n locale?: string;\n };\n}\n\nexport interface CurrencyMegaOptions extends CurrencyStartingUnitOptions {\n /**\n * 精度,默认:`2`\n */\n precision?: number;\n\n /**\n * 单位国际化,默认:`{Q: '京', T: '兆', B: '亿', M: '万', K: '千',}`\n */\n unitI18n?: CurrencyMegaUnitI18n;\n}\n\nexport interface CurrencyMegaResult {\n raw: number | string;\n value: string;\n unit: string;\n unitI18n: string;\n}\n\nexport const CurrencyMega_Powers = [\n { unit: 'Q', value: Math.pow(10, 15) },\n { unit: 'T', value: Math.pow(10, 12) },\n { unit: 'B', value: Math.pow(10, 9) },\n { unit: 'M', value: Math.pow(10, 6) },\n { unit: 'K', value: 1000 }\n];\n\nexport interface CurrencyMegaUnitI18n {\n Q: string;\n T: string;\n B: string;\n M: string;\n K: string;\n}\n\nexport interface CurrencyCNYOptions extends CurrencyStartingUnitOptions {\n /**\n * Whether to return to uppercase notation, default: `true`\n *\n * 是否返回大写表示法,默认:`true`\n */\n inWords?: boolean;\n /**\n * Specify negative sign, default: `negative`\n *\n * 指定负数符号,默认:`负`\n */\n minusSymbol?: string;\n}\n","import { CurrencyPipe, formatNumber } from '@angular/common';\nimport { DEFAULT_CURRENCY_CODE, Inject, Injectable, LOCALE_ID } from '@angular/core';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nimport { YunzaiConfigService, YunzaiUtilCurrencyConfig } from '@yelon/util/config';\n\nimport {\n CurrencyCNYOptions,\n CurrencyFormatOptions,\n CurrencyMegaOptions,\n CurrencyMegaResult,\n CurrencyMega_Powers\n} from './currency.types';\n\n@Injectable({ providedIn: 'root' })\nexport class CurrencyService {\n private c: YunzaiUtilCurrencyConfig;\n private readonly currencyPipe: CurrencyPipe;\n\n constructor(\n cog: YunzaiConfigService,\n @Inject(LOCALE_ID) private locale: string,\n @Inject(DEFAULT_CURRENCY_CODE) _defaultCurrencyCode: string = 'USD'\n ) {\n this.currencyPipe = new CurrencyPipe(locale, _defaultCurrencyCode);\n this.c = cog.merge('utilCurrency', {\n startingUnit: 'yuan',\n megaUnit: { Q: '京', T: '兆', B: '亿', M: '万', K: '千' },\n precision: 2,\n ignoreZeroPrecision: true\n })!;\n }\n\n /**\n * Format a number with commas as thousands separators\n *\n * 格式化货币,用逗号将数字格式化为千位分隔符\n * ```ts\n * 10000 => `10,000`\n * 10000.567 => `10,000.57`\n * ```\n */\n format(value: number | string, options?: CurrencyFormatOptions): string {\n options = {\n startingUnit: this.c.startingUnit,\n precision: this.c.precision,\n ignoreZeroPrecision: this.c.ignoreZeroPrecision,\n ngCurrency: this.c.ngCurrency,\n ...options\n };\n let truthValue = Number(value);\n if (value == null || isNaN(truthValue)) {\n return '';\n }\n if (options.startingUnit === 'cent') {\n truthValue = truthValue / 100;\n }\n if (options.ngCurrency != null) {\n const cur = options.ngCurrency!;\n return this.currencyPipe.transform(\n truthValue,\n cur.currencyCode,\n cur.display,\n cur.digitsInfo,\n cur.locale || this.locale\n )!;\n }\n const res = formatNumber(\n truthValue,\n this.locale,\n `.${options.ignoreZeroPrecision ? 1 : options.precision}-${options.precision}`\n );\n return options.ignoreZeroPrecision ? res.replace(/(?:\\.[0]+)$/g, '') : res;\n }\n\n /**\n * Large number format filter\n *\n * 大数据格式化\n * ```ts\n * 1000 => { value: '1', unit: 'K', unitI18n: '千' }\n * 12456 => { value: '12.46', unit: 'K', unitI18n: '千' }\n * ```\n */\n mega(value: number | string, options?: CurrencyMegaOptions): CurrencyMegaResult {\n options = { precision: this.c.precision, unitI18n: this.c.megaUnit, startingUnit: this.c.startingUnit, ...options };\n let num = Number(value);\n const res: CurrencyMegaResult = { raw: value, value: '', unit: '', unitI18n: '' };\n if (isNaN(num) || num === 0) {\n res.value = value.toString();\n return res;\n }\n if (options.startingUnit === 'cent') {\n num = num / 100;\n }\n let abs = Math.abs(+num);\n const rounder = Math.pow(10, options.precision!);\n const isNegative = num < 0;\n for (const p of CurrencyMega_Powers) {\n let reduced = abs / p.value;\n\n reduced = Math.round(reduced * rounder) / rounder;\n\n if (reduced >= 1) {\n abs = reduced;\n res.unit = p.unit;\n break;\n }\n }\n\n res.value = (isNegative ? '-' : '') + abs;\n res.unitI18n = (options.unitI18n as { [key: string]: NzSafeAny })[res.unit];\n return res;\n }\n\n /**\n * Converted into RMB notation.\n *\n * 转化成人民币表示法\n */\n cny(value: number | string, options?: CurrencyCNYOptions): string {\n options = {\n inWords: true,\n minusSymbol: '负',\n startingUnit: this.c.startingUnit,\n ...options\n };\n\n value = Number(value);\n if (isNaN(value)) {\n return '';\n }\n if (options.startingUnit === 'cent') {\n value = value / 100;\n }\n value = value.toString();\n let integer: number | string;\n let decimal: number | string | null;\n [integer, decimal] = value.split('.');\n let symbol = '';\n if (integer.startsWith('-')) {\n symbol = options.minusSymbol!;\n integer = integer.substr(1);\n }\n if (/^-?\\d+$/.test(value)) {\n decimal = null;\n }\n integer = (+integer).toString();\n const inWords = options.inWords;\n const unit: { [key: string]: string[] } = {\n num: inWords\n ? ['', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '点']\n : ['', '一', '二', '三', '四', '五', '六', '七', '八', '九', '点'],\n radice: inWords\n ? [\n '',\n '拾',\n '佰',\n '仟',\n '万',\n '拾',\n '佰',\n '仟',\n '亿',\n '拾',\n '佰',\n '仟',\n '万亿',\n '拾',\n '佰',\n '仟',\n '兆',\n '拾',\n '佰',\n '仟'\n ]\n : [\n '',\n '十',\n '百',\n '千',\n '万',\n '十',\n '百',\n '千',\n '亿',\n '十',\n '百',\n '千',\n '万亿',\n '十',\n '百',\n '千',\n '兆',\n '十',\n '百',\n '千'\n ],\n dec: ['角', '分', '厘', '毫']\n };\n if (inWords) {\n value = (+value).toFixed(5).toString();\n }\n let integerRes = '';\n const integerCount = integer.length;\n if (integer === '0' || integerCount === 0) {\n integerRes = '零';\n } else {\n let cnDesc = '';\n for (let i = 0; i < integerCount; i++) {\n const n = +integer[i];\n const j = integerCount - i - 1;\n const isZero = i > 1 && n !== 0 && integer[i - 1] === '0';\n const cnZero = isZero ? '零' : '';\n const isEmpptyUnit = (n === 0 && j % 4 !== 0) || integer.substr(i - 3, 4) === '0000';\n const descMark = cnDesc;\n let cnNum = unit.num[n];\n\n cnDesc = isEmpptyUnit ? '' : unit.radice[j];\n // 第一位是一十\n if (i === 0 && cnNum === '一' && cnDesc === '十') cnNum = '';\n const isChangeEr =\n n > 1 &&\n cnNum === '二' && // 去除首位\n ['', '十', '百'].indexOf(cnDesc) === -1 && // 不读两\\两十\\两百\n descMark !== '十'; // 不读十两\n if (isChangeEr) cnNum = '两';\n integerRes += cnZero + cnNum + cnDesc;\n }\n }\n\n // 小数部分拼接\n let decimalRes = '';\n const decimalCount = decimal ? decimal.toString().length : 0;\n if (decimal === null) {\n decimalRes = inWords ? '整' : '';\n } else if (decimal === '0') {\n decimalRes = '零';\n } else {\n for (let i = 0; i < decimalCount; i++) {\n if (inWords && i > unit.dec.length - 1) break;\n const n = decimal[i];\n const cnZero = n === '0' ? '零' : '';\n const cnNum = unit.num[+n];\n const cnDesc = inWords ? unit.dec[i] : '';\n decimalRes += cnZero + cnNum + cnDesc;\n }\n }\n const ret =\n symbol +\n (inWords\n ? integerRes + (decimalRes === '零' ? '元整' : `元${decimalRes}`)\n : integerRes + (decimalRes === '' ? '' : `点${decimalRes}`));\n return ret;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAIA;;;;;;;;;;;SAWgB,MAAM,CACpB,GAA8B,EAC9B,GAAiC,EACjC,cAAuB,KAAK;IAE5B,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC,KAAa,EAAE,GAAW,KACpE,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,CACxE,CAAC;AACJ,CAAC;AAED;;;;;;;;SAQgB,UAAU,CAAC,KAAa,EAAE,IAAY;IACpD,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,EAAE,CAAC;KACX;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACnC,OAAO,IAAI;SACR,KAAK,CAAC,EAAE,CAAC;SACT,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG;QACf,IAAI,GAAG,KAAK,GAAG,EAAE;YACf,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;gBACzB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAG,CAAC,CAAC;aAC/B;SACF;aAAM;YACL,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACf;QACD,OAAO,GAAG,CAAC;KACZ,EAAE,EAAc,CAAC;SACjB,IAAI,CAAC,EAAE,CAAC,CAAC;AACd;;MCpDa,SAAS,GAAG;I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,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC;QAChE,OAAO,GAAG,CAAC;KACZ;;;;YAhPF,UAAU,SAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;YAVzB,mBAAmB;yCAiBvB,MAAM,SAAC,SAAS;yCAChB,MAAM,SAAC,qBAAqB;;;ACvBjC;;;;;;"}
1
+ {"version":3,"file":"yelon-util-format.js","sources":["../../../../packages/util/format/string.ts","../../../../packages/util/format/validate.ts","../../../../packages/util/format/currency.types.ts","../../../../packages/util/format/currency.service.ts","../../../../packages/util/format/yelon-util-format.ts"],"sourcesContent":["import type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nimport { deepGet } from '@yelon/util/other';\n\n/**\n * String formatting\n *\n * 字符串格式化\n * ```\n * format('this is ${name}', { name: 'asdf' })\n * // output: this is asdf\n * format('this is ${user.name}', { user: { name: 'asdf' } }, true)\n * // output: this is asdf\n * ```\n */\nexport function format(\n str: string | null | undefined,\n obj: NzSafeAny | null | undefined,\n needDeepGet: boolean = false\n): string {\n return (str || '').replace(/\\${([^}]+)}/g, (_work: string, key: string) =>\n needDeepGet ? deepGet(obj, key.split('.'), '') : (obj || {})[key] || ''\n );\n}\n\nexport interface FormatMaskOption {\n mask: string;\n tokens?: { [key: string]: FormatMaskToken };\n}\n\nexport interface FormatMaskToken {\n pattern: RegExp;\n default?: NzSafeAny;\n transform?: (char: string) => string;\n}\n\n/**\n * Format mask\n *\n * 格式化掩码\n *\n * | 字符 | 描述 |\n * | --- | --- |\n * | `0` | 任意数字,若该位置字符不符合,则默认为 `0` 填充 |\n * | `9` | 任意数字 |\n * | `#` | 任意字符 |\n * | `U` | 转换大写 |\n * | `L` | 转换小写 |\n * | `*` | 转换为 `*` 字符 |\n *\n * ```ts\n * formatMask('123', '(###)') => (123)\n * formatMask('15900000000', '999****9999') => 159****0000\n * ```\n */\nexport function formatMask(value: string, option: string | FormatMaskOption): string {\n if (!value) {\n return '';\n }\n const opt: FormatMaskOption = {\n ...(typeof option === 'string' ? { mask: option } : option)\n };\n const tokens: { [key: string]: FormatMaskToken } = {\n '0': { pattern: /\\d/, default: '0' },\n '9': { pattern: /\\d/ },\n '#': { pattern: /[a-zA-Z0-9]/ },\n U: {\n pattern: /[a-zA-Z]/,\n transform: char => char.toLocaleUpperCase()\n },\n L: {\n pattern: /[a-zA-Z]/,\n transform: char => char.toLocaleLowerCase()\n },\n '*': {\n pattern: /.*/,\n transform: _ => `*`\n },\n ...opt.tokens\n };\n\n const splitValue = value.split('');\n return opt.mask\n .split('')\n .reduce((res, cur) => {\n const token = tokens[cur];\n if (!token) {\n res.push(cur);\n return res;\n }\n\n const value = splitValue.shift() ?? '';\n if (!token.pattern.test(value)) {\n if (token.default) res.push(token.default);\n return res;\n }\n\n if (typeof token.transform === 'function') {\n res.push(token.transform(value));\n } else {\n res.push(value);\n }\n return res;\n }, [] as string[])\n .join('');\n}\n","export const REGEX_STR = {\n num: `((-?\\\\d+\\\\.\\\\d+)|(-?\\\\d+)|(-?\\\\.\\\\d+))`,\n idCard: `(^\\\\d{15}$)|(^\\\\d{17}(?:[0-9]|X)$)`,\n mobile: `^(0|\\\\+?86|17951)?1[0-9]{10}$`,\n url: `(((^https?:(?:\\/\\/)?)(?:[-;:&=\\\\+\\\\$,\\\\w]+@)?[A-Za-z0-9.-]+(?::\\\\d+)?|(?:www.|[-;:&=\\\\+\\\\$,\\\\w]+@)[A-Za-z0-9.-]+)((?:\\/[\\\\+~%\\\\/.\\\\w-_]*)?\\\\??(?:[-\\\\+=&;%@.\\\\w_]*)#?(?:[\\\\w]*))?)`,\n ip: `(?:^(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)){3}$)|(?:^(?:(?:[a-fA-F\\\\d]{1,4}:){7}(?:[a-fA-F\\\\d]{1,4}|:)|(?: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]\\\\d|\\\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)){3}|(?::[a-fA-F\\\\d]{1,4}){1,6}|:)|(?::(?:(?::[a-fA-F\\\\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)){3}|(?::[a-fA-F\\\\d]{1,4}){1,7}|:)))(?:%[0-9a-zA-Z]{1,})?$)`,\n color: `(?:#|0x)(?:[a-f0-9]{3}|[a-f0-9]{6})\\\\b|(?:rgb|hsl)a?\\\\([^\\\\)]*\\\\)`,\n chinese: `[\\u4e00-\\u9fa5]+`\n};\n\nfunction genRegex(str: string, flags?: string): RegExp {\n return new RegExp(`^${str}$`, flags);\n}\n\nexport const REGEX = {\n num: genRegex(REGEX_STR.num),\n idCard: genRegex(REGEX_STR.idCard, 'i'),\n mobile: genRegex(REGEX_STR.mobile),\n url: genRegex(REGEX_STR.url),\n ip: genRegex(REGEX_STR.ip),\n color: genRegex(REGEX_STR.color),\n chinese: genRegex(REGEX_STR.chinese)\n};\n\n/**\n * Wheter is number\n *\n * 是否为数字\n */\nexport function isNum(value: string | number): boolean {\n return REGEX.num.test(value.toString());\n}\n\n/**\n * Wheter is integer\n *\n * 是否为整数\n */\nexport function isInt(value: string | number): boolean {\n return isNum(value) && parseInt(value.toString(), 10).toString() === value.toString();\n}\n\n/**\n * Wheter is decimal\n *\n * 是否为小数点数值\n */\nexport function isDecimal(value: string | number): boolean {\n return isNum(value) && !isInt(value);\n}\n\n/**\n * Wheter is People's Republic of China identity card\n *\n * 是否为中华人民共和国居民身份证\n */\nexport function isIdCard(value: string): boolean {\n return REGEX.idCard.test(value);\n}\n\n/**\n * Wheter is china mobile (China)\n *\n * 是否为手机号(中国)\n */\nexport function isMobile(value: string): boolean {\n return REGEX.mobile.test(value);\n}\n\n/**\n * Wheter is url address\n *\n * 是否URL地址\n */\nexport function isUrl(url: string): boolean {\n return REGEX.url.test(url);\n}\n\n/**\n * Wheter is IPv4 address (Support v4, v6)\n *\n * 是否IP4地址(支持v4、v6)\n */\nexport function isIp(ip: string): boolean {\n return REGEX.ip.test(ip);\n}\n\n/**\n * Wheter is color\n *\n * 是否颜色代码值\n */\nexport function isColor(color: string): boolean {\n return REGEX.color.test(color);\n}\n\n/**\n * Wheter is chinese\n *\n * 是否中文\n */\nexport function isChinese(value: string): boolean {\n return REGEX.chinese.test(value);\n}\n","export type CurrencyStartingUnit = 'yuan' | 'cent';\n\nexport interface CurrencyStartingUnitOptions {\n /**\n * The starting unit of the value, `yuan` means 元, `cent` means 分, default: `yuan`\n *\n * 值的起始单位,`yuan` 元,`cent` 分,默认:`yuan`\n */\n startingUnit?: CurrencyStartingUnit;\n}\n\nexport interface CurrencyFormatOptions extends CurrencyStartingUnitOptions {\n /**\n * Using `DEFAULT_CURRENCY_CODE` when value is `true\n *\n * 是否使用 `CurrencyPipe` 来替代\n */\n useAngular?: boolean;\n /**\n * 精度,默认:`2`\n */\n precision?: number;\n /**\n * 是否忽略精度 `.0` 或 `.00` 结尾的字符,默认:`true`\n */\n ignoreZeroPrecision?: boolean;\n\n /**\n * Use anguar `currency` pipe parse when is set, pls refer to [document](https://angular.io/api/common/CurrencyPipe)\n *\n * 若指定则表示使用 Angular 自带的 `currency` 管道来解析,见[文档](https://angular.cn/api/common/CurrencyPipe)\n */\n ngCurrency?: {\n display: 'code' | 'symbol' | 'symbol-narrow';\n currencyCode?: string;\n digitsInfo?: string;\n locale?: string;\n };\n}\n\nexport interface CurrencyMegaOptions extends CurrencyStartingUnitOptions {\n /**\n * 精度,默认:`2`\n */\n precision?: number;\n\n /**\n * 单位国际化,默认:`{Q: '京', T: '兆', B: '亿', M: '万', K: '千',}`\n */\n unitI18n?: CurrencyMegaUnitI18n;\n}\n\nexport interface CurrencyMegaResult {\n raw: number | string;\n value: string;\n unit: string;\n unitI18n: string;\n}\n\nexport const CurrencyMega_Powers = [\n { unit: 'Q', value: Math.pow(10, 15) },\n { unit: 'T', value: Math.pow(10, 12) },\n { unit: 'B', value: Math.pow(10, 9) },\n { unit: 'M', value: Math.pow(10, 6) },\n { unit: 'K', value: 1000 }\n];\n\nexport interface CurrencyMegaUnitI18n {\n Q: string;\n T: string;\n B: string;\n M: string;\n K: string;\n}\n\nexport interface CurrencyCNYOptions extends CurrencyStartingUnitOptions {\n /**\n * Whether to return to uppercase notation, default: `true`\n *\n * 是否返回大写表示法,默认:`true`\n */\n inWords?: boolean;\n /**\n * Specify negative sign, default: `negative`\n *\n * 指定负数符号,默认:`负`\n */\n minusSymbol?: string;\n}\n","import { CurrencyPipe, formatNumber } from '@angular/common';\nimport { DEFAULT_CURRENCY_CODE, Inject, Injectable, LOCALE_ID } from '@angular/core';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nimport { YunzaiConfigService, YunzaiUtilCurrencyConfig } from '@yelon/util/config';\n\nimport {\n CurrencyCNYOptions,\n CurrencyFormatOptions,\n CurrencyMegaOptions,\n CurrencyMegaResult,\n CurrencyMega_Powers\n} from './currency.types';\n\n@Injectable({ providedIn: 'root' })\nexport class CurrencyService {\n private c: YunzaiUtilCurrencyConfig;\n private readonly currencyPipe: CurrencyPipe;\n\n constructor(\n cog: YunzaiConfigService,\n @Inject(LOCALE_ID) private locale: string,\n @Inject(DEFAULT_CURRENCY_CODE) _defaultCurrencyCode: string = 'USD'\n ) {\n this.currencyPipe = new CurrencyPipe(locale, _defaultCurrencyCode);\n this.c = cog.merge('utilCurrency', {\n startingUnit: 'yuan',\n megaUnit: { Q: '京', T: '兆', B: '亿', M: '万', K: '千' },\n precision: 2,\n ignoreZeroPrecision: true\n })!;\n }\n\n /**\n * Format a number with commas as thousands separators\n *\n * 格式化货币,用逗号将数字格式化为千位分隔符\n * ```ts\n * 10000 => `10,000`\n * 10000.567 => `10,000.57`\n * ```\n */\n format(value: number | string, options?: CurrencyFormatOptions): string {\n options = {\n startingUnit: this.c.startingUnit,\n precision: this.c.precision,\n ignoreZeroPrecision: this.c.ignoreZeroPrecision,\n ngCurrency: this.c.ngCurrency,\n ...options\n };\n let truthValue = Number(value);\n if (value == null || isNaN(truthValue)) {\n return '';\n }\n if (options.startingUnit === 'cent') {\n truthValue = truthValue / 100;\n }\n if (options.ngCurrency != null) {\n const cur = options.ngCurrency!;\n return this.currencyPipe.transform(\n truthValue,\n cur.currencyCode,\n cur.display,\n cur.digitsInfo,\n cur.locale || this.locale\n )!;\n }\n const res = formatNumber(\n truthValue,\n this.locale,\n `.${options.ignoreZeroPrecision ? 1 : options.precision}-${options.precision}`\n );\n return options.ignoreZeroPrecision ? res.replace(/(?:\\.[0]+)$/g, '') : res;\n }\n\n /**\n * Large number format filter\n *\n * 大数据格式化\n * ```ts\n * 1000 => { value: '1', unit: 'K', unitI18n: '千' }\n * 12456 => { value: '12.46', unit: 'K', unitI18n: '千' }\n * ```\n */\n mega(value: number | string, options?: CurrencyMegaOptions): CurrencyMegaResult {\n options = { precision: this.c.precision, unitI18n: this.c.megaUnit, startingUnit: this.c.startingUnit, ...options };\n let num = Number(value);\n const res: CurrencyMegaResult = { raw: value, value: '', unit: '', unitI18n: '' };\n if (isNaN(num) || num === 0) {\n res.value = value.toString();\n return res;\n }\n if (options.startingUnit === 'cent') {\n num = num / 100;\n }\n let abs = Math.abs(+num);\n const rounder = Math.pow(10, options.precision!);\n const isNegative = num < 0;\n for (const p of CurrencyMega_Powers) {\n let reduced = abs / p.value;\n\n reduced = Math.round(reduced * rounder) / rounder;\n\n if (reduced >= 1) {\n abs = reduced;\n res.unit = p.unit;\n break;\n }\n }\n\n res.value = (isNegative ? '-' : '') + abs;\n res.unitI18n = (options.unitI18n as { [key: string]: NzSafeAny })[res.unit];\n return res;\n }\n\n /**\n * Converted into RMB notation.\n *\n * 转化成人民币表示法\n */\n cny(value: number | string, options?: CurrencyCNYOptions): string {\n options = {\n inWords: true,\n minusSymbol: '负',\n startingUnit: this.c.startingUnit,\n ...options\n };\n\n value = Number(value);\n if (isNaN(value)) {\n return '';\n }\n if (options.startingUnit === 'cent') {\n value = value / 100;\n }\n value = value.toString();\n let integer: number | string;\n let decimal: number | string | null;\n [integer, decimal] = value.split('.');\n let symbol = '';\n if (integer.startsWith('-')) {\n symbol = options.minusSymbol!;\n integer = integer.substr(1);\n }\n if (/^-?\\d+$/.test(value)) {\n decimal = null;\n }\n integer = (+integer).toString();\n const inWords = options.inWords;\n const unit: { [key: string]: string[] } = {\n num: inWords\n ? ['', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '点']\n : ['', '一', '二', '三', '四', '五', '六', '七', '八', '九', '点'],\n radice: inWords\n ? [\n '',\n '拾',\n '佰',\n '仟',\n '万',\n '拾',\n '佰',\n '仟',\n '亿',\n '拾',\n '佰',\n '仟',\n '万亿',\n '拾',\n '佰',\n '仟',\n '兆',\n '拾',\n '佰',\n '仟'\n ]\n : [\n '',\n '十',\n '百',\n '千',\n '万',\n '十',\n '百',\n '千',\n '亿',\n '十',\n '百',\n '千',\n '万亿',\n '十',\n '百',\n '千',\n '兆',\n '十',\n '百',\n '千'\n ],\n dec: ['角', '分', '厘', '毫']\n };\n if (inWords) {\n value = (+value).toFixed(5).toString();\n }\n let integerRes = '';\n const integerCount = integer.length;\n if (integer === '0' || integerCount === 0) {\n integerRes = '零';\n } else {\n let cnDesc = '';\n for (let i = 0; i < integerCount; i++) {\n const n = +integer[i];\n const j = integerCount - i - 1;\n const isZero = i > 1 && n !== 0 && integer[i - 1] === '0';\n const cnZero = isZero ? '零' : '';\n const isEmpptyUnit = (n === 0 && j % 4 !== 0) || integer.substr(i - 3, 4) === '0000';\n const descMark = cnDesc;\n let cnNum = unit.num[n];\n\n cnDesc = isEmpptyUnit ? '' : unit.radice[j];\n // 第一位是一十\n if (i === 0 && cnNum === '一' && cnDesc === '十') cnNum = '';\n const isChangeEr =\n n > 1 &&\n cnNum === '二' && // 去除首位\n ['', '十', '百'].indexOf(cnDesc) === -1 && // 不读两\\两十\\两百\n descMark !== '十'; // 不读十两\n if (isChangeEr) cnNum = '两';\n integerRes += cnZero + cnNum + cnDesc;\n }\n }\n\n // 小数部分拼接\n let decimalRes = '';\n const decimalCount = decimal ? decimal.toString().length : 0;\n if (decimal === null) {\n decimalRes = inWords ? '整' : '';\n } else if (decimal === '0') {\n decimalRes = '零';\n } else {\n for (let i = 0; i < decimalCount; i++) {\n if (inWords && i > unit.dec.length - 1) break;\n const n = decimal[i];\n const cnZero = n === '0' ? '零' : '';\n const cnNum = unit.num[+n];\n const cnDesc = inWords ? unit.dec[i] : '';\n decimalRes += cnZero + cnNum + cnDesc;\n }\n }\n const ret =\n symbol +\n (inWords\n ? integerRes + (decimalRes === '零' ? '元整' : `元${decimalRes}`)\n : integerRes + (decimalRes === '' ? '' : `点${decimalRes}`));\n return ret;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAIA;;;;;;;;;;;SAWgB,MAAM,CACpB,GAA8B,EAC9B,GAAiC,EACjC,cAAuB,KAAK;IAE5B,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC,KAAa,EAAE,GAAW,KACpE,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,CACxE,CAAC;AACJ,CAAC;AAaD;;;;;;;;;;;;;;;;;;;SAmBgB,UAAU,CAAC,KAAa,EAAE,MAAiC;IACzE,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,EAAE,CAAC;KACX;IACD,MAAM,GAAG,sBACH,OAAO,MAAM,KAAK,QAAQ,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAC3D,CAAC;IACF,MA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GAAG,MAAM,CAAC;aACvC;SACF;QACD,MAAM,GAAG,GACP,MAAM;aACL,OAAO;kBACJ,UAAU,IAAI,UAAU,KAAK,GAAG,GAAG,IAAI,GAAG,IAAI,UAAU,EAAE,CAAC;kBAC3D,UAAU,IAAI,UAAU,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC;QAChE,OAAO,GAAG,CAAC;KACZ;;;;YAhPF,UAAU,SAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;YAVzB,mBAAmB;yCAiBvB,MAAM,SAAC,SAAS;yCAChB,MAAM,SAAC,qBAAqB;;;ACvBjC;;;;;;"}
@@ -6,8 +6,19 @@ class FormatMaskPipe {
6
6
  * Format mask
7
7
  *
8
8
  * 格式化掩码
9
+ *
10
+ * | 字符 | 描述 |
11
+ * | --- | --- |
12
+ * | `0` | 任意数字,若该位置字符不符合,则默认为 `0` 填充 |
13
+ * | `9` | 任意数字 |
14
+ * | `#` | 任意字符 |
15
+ * | `U` | 转换大写 |
16
+ * | `L` | 转换小写 |
17
+ * | `*` | 转换为 `*` 字符 |
18
+ *
9
19
  * ```ts
10
20
  * formatMask('123', '(###)') => (123)
21
+ * formatMask('15900000000', '999****9999') => 159****0000
11
22
  * ```
12
23
  */
13
24
  transform(value, mask) {
@@ -1 +1 @@
1
- {"version":3,"file":"yelon-util-pipes-format.js","sources":["../../../../packages/util/pipes/format/mask.pipe.ts","../../../../packages/util/pipes/format/module.ts","../../../../packages/util/pipes/format/yelon-util-pipes-format.ts"],"sourcesContent":["import { Pipe, PipeTransform } from '@angular/core';\n\nimport { formatMask } from '@yelon/util/format';\n\n@Pipe({ name: 'mask' })\nexport class FormatMaskPipe implements PipeTransform {\n /**\n * Format mask\n *\n * 格式化掩码\n * ```ts\n * formatMask('123', '(###)') => (123)\n * ```\n */\n transform(value: string, mask: string): string {\n return formatMask(value, mask);\n }\n}\n","import { NgModule } from '@angular/core';\n\nimport { FormatMaskPipe } from './mask.pipe';\n\nconst PIPES = [FormatMaskPipe];\n\n@NgModule({\n declarations: PIPES,\n exports: PIPES\n})\nexport class FormatPipeModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;MAKa,cAAc;;;;;;;;;IASzB,SAAS,CAAC,KAAa,EAAE,IAAY;QACnC,OAAO,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;KAChC;;;YAZF,IAAI,SAAC,EAAE,IAAI,EAAE,MAAM,EAAE;;;ACAtB,MAAM,KAAK,GAAG,CAAC,cAAc,CAAC,CAAC;MAMlB,gBAAgB;;;YAJ5B,QAAQ,SAAC;gBACR,YAAY,EAAE,KAAK;gBACnB,OAAO,EAAE,KAAK;aACf;;;ACTD;;;;;;"}
1
+ {"version":3,"file":"yelon-util-pipes-format.js","sources":["../../../../packages/util/pipes/format/mask.pipe.ts","../../../../packages/util/pipes/format/module.ts","../../../../packages/util/pipes/format/yelon-util-pipes-format.ts"],"sourcesContent":["import { Pipe, PipeTransform } from '@angular/core';\n\nimport { formatMask, FormatMaskOption } from '@yelon/util/format';\n\n@Pipe({ name: 'mask' })\nexport class FormatMaskPipe implements PipeTransform {\n /**\n * Format mask\n *\n * 格式化掩码\n *\n * | 字符 | 描述 |\n * | --- | --- |\n * | `0` | 任意数字,若该位置字符不符合,则默认为 `0` 填充 |\n * | `9` | 任意数字 |\n * | `#` | 任意字符 |\n * | `U` | 转换大写 |\n * | `L` | 转换小写 |\n * | `*` | 转换为 `*` 字符 |\n *\n * ```ts\n * formatMask('123', '(###)') => (123)\n * formatMask('15900000000', '999****9999') => 159****0000\n * ```\n */\n transform(value: string, mask: string | FormatMaskOption): string {\n return formatMask(value, mask);\n }\n}\n","import { NgModule } from '@angular/core';\n\nimport { FormatMaskPipe } from './mask.pipe';\n\nconst PIPES = [FormatMaskPipe];\n\n@NgModule({\n declarations: PIPES,\n exports: PIPES\n})\nexport class FormatPipeModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;MAKa,cAAc;;;;;;;;;;;;;;;;;;;;IAoBzB,SAAS,CAAC,KAAa,EAAE,IAA+B;QACtD,OAAO,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;KAChC;;;YAvBF,IAAI,SAAC,EAAE,IAAI,EAAE,MAAM,EAAE;;;ACAtB,MAAM,KAAK,GAAG,CAAC,cAAc,CAAC,CAAC;MAMlB,gBAAgB;;;YAJ5B,QAAQ,SAAC;gBACR,YAAY,EAAE,KAAK;gBACnB,OAAO,EAAE,KAAK;aACf;;;ACTD;;;;;;"}
@@ -11,12 +11,34 @@ import type { NzSafeAny } from 'ng-zorro-antd/core/types';
11
11
  * ```
12
12
  */
13
13
  export declare function format(str: string | null | undefined, obj: NzSafeAny | null | undefined, needDeepGet?: boolean): string;
14
+ export interface FormatMaskOption {
15
+ mask: string;
16
+ tokens?: {
17
+ [key: string]: FormatMaskToken;
18
+ };
19
+ }
20
+ export interface FormatMaskToken {
21
+ pattern: RegExp;
22
+ default?: NzSafeAny;
23
+ transform?: (char: string) => string;
24
+ }
14
25
  /**
15
26
  * Format mask
16
27
  *
17
28
  * 格式化掩码
29
+ *
30
+ * | 字符 | 描述 |
31
+ * | --- | --- |
32
+ * | `0` | 任意数字,若该位置字符不符合,则默认为 `0` 填充 |
33
+ * | `9` | 任意数字 |
34
+ * | `#` | 任意字符 |
35
+ * | `U` | 转换大写 |
36
+ * | `L` | 转换小写 |
37
+ * | `*` | 转换为 `*` 字符 |
38
+ *
18
39
  * ```ts
19
40
  * formatMask('123', '(###)') => (123)
41
+ * formatMask('15900000000', '999****9999') => 159****0000
20
42
  * ```
21
43
  */
22
- export declare function formatMask(value: string, mask: string): string;
44
+ export declare function formatMask(value: string, option: string | FormatMaskOption): string;
@@ -1 +1 @@
1
- {"__symbolic":"module","version":4,"metadata":{"format":{"__symbolic":"function","parameters":["str","obj","needDeepGet"],"defaults":[null,null,false],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"reference","name":"str"},"right":""},"member":"replace"},"arguments":[{"__symbolic":"error","message":"Expression form not supported","line":20,"character":29,"module":"./string"},{"__symbolic":"error","message":"Lambda not supported","line":20,"character":45,"module":"./string"}]}},"formatMask":{"__symbolic":"function"},"REGEX_STR":{"num":"((-?\\d+\\.\\d+)|(-?\\d+)|(-?\\.\\d+))","idCard":"(^\\d{15}$)|(^\\d{17}(?:[0-9]|X)$)","mobile":"^(0|\\+?86|17951)?1[0-9]{10}$","url":"(((^https?:(?://)?)(?:[-;:&=\\+\\$,\\w]+@)?[A-Za-z0-9.-]+(?::\\d+)?|(?:www.|[-;:&=\\+\\$,\\w]+@)[A-Za-z0-9.-]+)((?:/[\\+~%\\/.\\w-_]*)?\\??(?:[-\\+=&;%@.\\w_]*)#?(?:[\\w]*))?)","ip":"(?:^(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}$)|(?:^(?:(?:[a-fA-F\\d]{1,4}:){7}(?:[a-fA-F\\d]{1,4}|:)|(?:[a-fA-F\\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|:[a-fA-F\\d]{1,4}|:)|(?:[a-fA-F\\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,2}|:)|(?:[a-fA-F\\d]{1,4}:){4}(?:(?::[a-fA-F\\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,3}|:)|(?:[a-fA-F\\d]{1,4}:){3}(?:(?::[a-fA-F\\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,4}|:)|(?:[a-fA-F\\d]{1,4}:){2}(?:(?::[a-fA-F\\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,5}|:)|(?:[a-fA-F\\d]{1,4}:){1}(?:(?::[a-fA-F\\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,6}|:)|(?::(?:(?::[a-fA-F\\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,7}|:)))(?:%[0-9a-zA-Z]{1,})?$)","color":"(?:#|0x)(?:[a-f0-9]{3}|[a-f0-9]{6})\\b|(?:rgb|hsl)a?\\([^\\)]*\\)","chinese":"[一-龥]+"},"REGEX":{"__symbolic":"error","message":"Reference to a non-exported function","line":10,"character":9,"context":{"name":"genRegex"},"module":"./validate"},"isNum":{"__symbolic":"function","parameters":["value"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"REGEX"},"member":"num"},"member":"test"},"arguments":[{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"value"},"member":"toString"}}]}},"isInt":{"__symbolic":"function","parameters":["value"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isNum"},"arguments":[{"__symbolic":"reference","name":"value"}]},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"parseInt"},"arguments":[{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"value"},"member":"toString"}},10]},"member":"toString"}},"right":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"value"},"member":"toString"}}}}},"isDecimal":{"__symbolic":"function","parameters":["value"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isNum"},"arguments":[{"__symbolic":"reference","name":"value"}]},"right":{"__symbolic":"pre","operator":"!","operand":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isInt"},"arguments":[{"__symbolic":"reference","name":"value"}]}}}},"isIdCard":{"__symbolic":"function","parameters":["value"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"REGEX"},"member":"idCard"},"member":"test"},"arguments":[{"__symbolic":"reference","name":"value"}]}},"isMobile":{"__symbolic":"function","parameters":["value"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"REGEX"},"member":"mobile"},"member":"test"},"arguments":[{"__symbolic":"reference","name":"value"}]}},"isUrl":{"__symbolic":"function","parameters":["url"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"REGEX"},"member":"url"},"member":"test"},"arguments":[{"__symbolic":"reference","name":"url"}]}},"isIp":{"__symbolic":"function","parameters":["ip"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"REGEX"},"member":"ip"},"member":"test"},"arguments":[{"__symbolic":"reference","name":"ip"}]}},"isColor":{"__symbolic":"function","parameters":["color"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"REGEX"},"member":"color"},"member":"test"},"arguments":[{"__symbolic":"reference","name":"color"}]}},"isChinese":{"__symbolic":"function","parameters":["value"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"REGEX"},"member":"chinese"},"member":"test"},"arguments":[{"__symbolic":"reference","name":"value"}]}},"CurrencyService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":15,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":22,"character":5},"arguments":[{"__symbolic":"reference","module":"@angular/core","name":"LOCALE_ID","line":22,"character":12}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":23,"character":5},"arguments":[{"__symbolic":"reference","module":"@angular/core","name":"DEFAULT_CURRENCY_CODE","line":23,"character":12}]}]],"parameters":[{"__symbolic":"reference","module":"@yelon/util/config","name":"YunzaiConfigService","line":21,"character":9},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"}]}],"format":[{"__symbolic":"method"}],"mega":[{"__symbolic":"method"}],"cny":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}},"CurrencyStartingUnit":{"__symbolic":"interface"},"CurrencyStartingUnitOptions":{"__symbolic":"interface"},"CurrencyFormatOptions":{"__symbolic":"interface"},"CurrencyMegaOptions":{"__symbolic":"interface"},"CurrencyMegaResult":{"__symbolic":"interface"},"CurrencyMega_Powers":[{"unit":"Q","value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Math"},"member":"pow"},"arguments":[10,15]}},{"unit":"T","value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Math"},"member":"pow"},"arguments":[10,12]}},{"unit":"B","value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Math"},"member":"pow"},"arguments":[10,9]}},{"unit":"M","value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Math"},"member":"pow"},"arguments":[10,6]}},{"unit":"K","value":1000}],"CurrencyMegaUnitI18n":{"__symbolic":"interface"},"CurrencyCNYOptions":{"__symbolic":"interface"}},"origins":{"format":"./string","formatMask":"./string","REGEX_STR":"./validate","REGEX":"./validate","isNum":"./validate","isInt":"./validate","isDecimal":"./validate","isIdCard":"./validate","isMobile":"./validate","isUrl":"./validate","isIp":"./validate","isColor":"./validate","isChinese":"./validate","CurrencyService":"./currency.service","CurrencyStartingUnit":"./currency.types","CurrencyStartingUnitOptions":"./currency.types","CurrencyFormatOptions":"./currency.types","CurrencyMegaOptions":"./currency.types","CurrencyMegaResult":"./currency.types","CurrencyMega_Powers":"./currency.types","CurrencyMegaUnitI18n":"./currency.types","CurrencyCNYOptions":"./currency.types"},"importAs":"@yelon/util/format"}
1
+ {"__symbolic":"module","version":4,"metadata":{"format":{"__symbolic":"function","parameters":["str","obj","needDeepGet"],"defaults":[null,null,false],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"reference","name":"str"},"right":""},"member":"replace"},"arguments":[{"__symbolic":"error","message":"Expression form not supported","line":20,"character":29,"module":"./string"},{"__symbolic":"error","message":"Lambda not supported","line":20,"character":45,"module":"./string"}]}},"FormatMaskOption":{"__symbolic":"interface"},"FormatMaskToken":{"__symbolic":"interface"},"formatMask":{"__symbolic":"function"},"REGEX_STR":{"num":"((-?\\d+\\.\\d+)|(-?\\d+)|(-?\\.\\d+))","idCard":"(^\\d{15}$)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(?:(?::[a-fA-F\\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,5}|:)|(?:[a-fA-F\\d]{1,4}:){1}(?:(?::[a-fA-F\\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,6}|:)|(?::(?:(?::[a-fA-F\\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,7}|:)))(?:%[0-9a-zA-Z]{1,})?$)","color":"(?:#|0x)(?:[a-f0-9]{3}|[a-f0-9]{6})\\b|(?:rgb|hsl)a?\\([^\\)]*\\)","chinese":"[一-龥]+"},"REGEX":{"__symbolic":"error","message":"Reference to a non-exported function","line":10,"character":9,"context":{"name":"genRegex"},"module":"./validate"},"isNum":{"__symbolic":"function","parameters":["value"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"REGEX"},"member":"num"},"member":"test"},"arguments":[{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"value"},"member":"toString"}}]}},"isInt":{"__symbolic":"function","parameters":["value"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isNum"},"arguments":[{"__symbolic":"reference","name":"value"}]},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"parseInt"},"arguments":[{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"value"},"member":"toString"}},10]},"member":"toString"}},"right":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"value"},"member":"toString"}}}}},"isDecimal":{"__symbolic":"function","parameters":["value"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isNum"},"arguments":[{"__symbolic":"reference","name":"value"}]},"right":{"__symbolic":"pre","operator":"!","operand":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"isInt"},"arguments":[{"__symbolic":"reference","name":"value"}]}}}},"isIdCard":{"__symbolic":"function","parameters":["value"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"REGEX"},"member":"idCard"},"member":"test"},"arguments":[{"__symbolic":"reference","name":"value"}]}},"isMobile":{"__symbolic":"function","parameters":["value"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"REGEX"},"member":"mobile"},"member":"test"},"arguments":[{"__symbolic":"reference","name":"value"}]}},"isUrl":{"__symbolic":"function","parameters":["url"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"REGEX"},"member":"url"},"member":"test"},"arguments":[{"__symbolic":"reference","name":"url"}]}},"isIp":{"__symbolic":"function","parameters":["ip"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"REGEX"},"member":"ip"},"member":"test"},"arguments":[{"__symbolic":"reference","name":"ip"}]}},"isColor":{"__symbolic":"function","parameters":["color"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"REGEX"},"member":"color"},"member":"test"},"arguments":[{"__symbolic":"reference","name":"color"}]}},"isChinese":{"__symbolic":"function","parameters":["value"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"REGEX"},"member":"chinese"},"member":"test"},"arguments":[{"__symbolic":"reference","name":"value"}]}},"CurrencyService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":15,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":22,"character":5},"arguments":[{"__symbolic":"reference","module":"@angular/core","name":"LOCALE_ID","line":22,"character":12}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":23,"character":5},"arguments":[{"__symbolic":"reference","module":"@angular/core","name":"DEFAULT_CURRENCY_CODE","line":23,"character":12}]}]],"parameters":[{"__symbolic":"reference","module":"@yelon/util/config","name":"YunzaiConfigService","line":21,"character":9},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"}]}],"format":[{"__symbolic":"method"}],"mega":[{"__symbolic":"method"}],"cny":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}},"CurrencyStartingUnit":{"__symbolic":"interface"},"CurrencyStartingUnitOptions":{"__symbolic":"interface"},"CurrencyFormatOptions":{"__symbolic":"interface"},"CurrencyMegaOptions":{"__symbolic":"interface"},"CurrencyMegaResult":{"__symbolic":"interface"},"CurrencyMega_Powers":[{"unit":"Q","value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Math"},"member":"pow"},"arguments":[10,15]}},{"unit":"T","value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Math"},"member":"pow"},"arguments":[10,12]}},{"unit":"B","value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Math"},"member":"pow"},"arguments":[10,9]}},{"unit":"M","value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Math"},"member":"pow"},"arguments":[10,6]}},{"unit":"K","value":1000}],"CurrencyMegaUnitI18n":{"__symbolic":"interface"},"CurrencyCNYOptions":{"__symbolic":"interface"}},"origins":{"format":"./string","FormatMaskOption":"./string","FormatMaskToken":"./string","formatMask":"./string","REGEX_STR":"./validate","REGEX":"./validate","isNum":"./validate","isInt":"./validate","isDecimal":"./validate","isIdCard":"./validate","isMobile":"./validate","isUrl":"./validate","isIp":"./validate","isColor":"./validate","isChinese":"./validate","CurrencyService":"./currency.service","CurrencyStartingUnit":"./currency.types","CurrencyStartingUnitOptions":"./currency.types","CurrencyFormatOptions":"./currency.types","CurrencyMegaOptions":"./currency.types","CurrencyMegaResult":"./currency.types","CurrencyMega_Powers":"./currency.types","CurrencyMegaUnitI18n":"./currency.types","CurrencyCNYOptions":"./currency.types"},"importAs":"@yelon/util/format"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yelon/util",
3
- "version": "12.0.7",
3
+ "version": "12.0.11",
4
4
  "author": "devcui<devcui@outlook.com>",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -1,12 +1,24 @@
1
1
  import { PipeTransform } from '@angular/core';
2
+ import { FormatMaskOption } from '@yelon/util/format';
2
3
  export declare class FormatMaskPipe implements PipeTransform {
3
4
  /**
4
5
  * Format mask
5
6
  *
6
7
  * 格式化掩码
8
+ *
9
+ * | 字符 | 描述 |
10
+ * | --- | --- |
11
+ * | `0` | 任意数字,若该位置字符不符合,则默认为 `0` 填充 |
12
+ * | `9` | 任意数字 |
13
+ * | `#` | 任意字符 |
14
+ * | `U` | 转换大写 |
15
+ * | `L` | 转换小写 |
16
+ * | `*` | 转换为 `*` 字符 |
17
+ *
7
18
  * ```ts
8
19
  * formatMask('123', '(###)') => (123)
20
+ * formatMask('15900000000', '999****9999') => 159****0000
9
21
  * ```
10
22
  */
11
- transform(value: string, mask: string): string;
23
+ transform(value: string, mask: string | FormatMaskOption): string;
12
24
  }