@yelon/util 16.0.5 → 16.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/config/bis/bis.type.d.ts +4 -0
- package/config/theme/responsive.type.d.ts +1 -1
- package/esm2022/analysis/global-event.subject.mjs +5 -6
- package/esm2022/array/array.service.mjs +5 -6
- package/esm2022/browser/cookie.service.mjs +5 -6
- package/esm2022/browser/scroll.service.mjs +5 -6
- package/esm2022/config/bis/bis.type.mjs +1 -1
- package/esm2022/config/config.service.mjs +5 -6
- package/esm2022/config/theme/responsive.type.mjs +1 -1
- package/esm2022/format/currency.service.mjs +5 -6
- package/esm2022/index.mjs +2 -2
- package/esm2022/mcache/index.mjs +2 -2
- package/esm2022/mcache/localStorageUtils.mjs +9 -9
- package/esm2022/mtypes/index.mjs +4 -4
- package/esm2022/mtypes/nav.types.mjs +1 -1
- package/esm2022/mtypes/page.mjs +1 -1
- package/esm2022/mtypes/response.mjs +1 -1
- package/esm2022/other/lazy.service.mjs +5 -6
- package/esm2022/other/path-to-regexp.service.mjs +5 -6
- package/esm2022/pipes/currency/cny.pipe.mjs +5 -6
- package/esm2022/pipes/currency/mega.pipe.mjs +5 -6
- package/esm2022/pipes/currency/module.mjs +6 -7
- package/esm2022/pipes/currency/price.pipe.mjs +5 -6
- package/esm2022/pipes/filter/filter.pipe.mjs +5 -6
- package/esm2022/pipes/filter/module.mjs +6 -7
- package/esm2022/pipes/format/mask.pipe.mjs +5 -6
- package/esm2022/pipes/format/module.mjs +6 -7
- package/fesm2022/analysis.mjs +3 -3
- package/fesm2022/analysis.mjs.map +1 -1
- package/fesm2022/array.mjs +3 -3
- package/fesm2022/array.mjs.map +1 -1
- package/fesm2022/browser.mjs +6 -6
- package/fesm2022/browser.mjs.map +1 -1
- package/fesm2022/config.mjs +3 -3
- package/fesm2022/config.mjs.map +1 -1
- package/fesm2022/format.mjs +3 -3
- package/fesm2022/format.mjs.map +1 -1
- package/fesm2022/mcache.mjs +8 -8
- package/fesm2022/mcache.mjs.map +1 -1
- package/fesm2022/mtypes.mjs.map +1 -1
- package/fesm2022/other.mjs +6 -6
- package/fesm2022/other.mjs.map +1 -1
- package/fesm2022/pipe-currency.mjs +13 -13
- package/fesm2022/pipe-currency.mjs.map +1 -1
- package/fesm2022/pipe-filter.mjs +7 -7
- package/fesm2022/pipe-filter.mjs.map +1 -1
- package/fesm2022/pipe-format.mjs +7 -7
- package/fesm2022/pipe-format.mjs.map +1 -1
- package/index.d.ts +1 -1
- package/mcache/index.d.ts +1 -1
- package/mcache/localStorageUtils.d.ts +5 -2
- package/mtypes/index.d.ts +3 -3
- package/mtypes/nav.types.d.ts +1 -4
- package/package.json +7 -7
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Pipe } from '@angular/core';
|
2
2
|
import { formatMask } from '@yelon/util/format';
|
3
3
|
import * as i0 from "@angular/core";
|
4
|
-
class FormatMaskPipe {
|
4
|
+
export class FormatMaskPipe {
|
5
5
|
/**
|
6
6
|
* Format mask
|
7
7
|
*
|
@@ -24,12 +24,11 @@ class FormatMaskPipe {
|
|
24
24
|
transform(value, mask) {
|
25
25
|
return formatMask(value, mask);
|
26
26
|
}
|
27
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1
|
28
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1
|
27
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: FormatMaskPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
28
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.1", ngImport: i0, type: FormatMaskPipe, name: "mask" }); }
|
29
29
|
}
|
30
|
-
|
31
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.8", ngImport: i0, type: FormatMaskPipe, decorators: [{
|
30
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: FormatMaskPipe, decorators: [{
|
32
31
|
type: Pipe,
|
33
32
|
args: [{ name: 'mask' }]
|
34
33
|
}] });
|
35
|
-
//# sourceMappingURL=data:application/json;base64,
|
34
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFzay5waXBlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvdXRpbC9waXBlcy9mb3JtYXQvbWFzay5waXBlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxJQUFJLEVBQWlCLE1BQU0sZUFBZSxDQUFDO0FBRXBELE9BQU8sRUFBRSxVQUFVLEVBQW9CLE1BQU0sb0JBQW9CLENBQUM7O0FBR2xFLE1BQU0sT0FBTyxjQUFjO0lBQ3pCOzs7Ozs7Ozs7Ozs7Ozs7Ozs7T0FrQkc7SUFDSCxTQUFTLENBQUMsS0FBYSxFQUFFLElBQStCO1FBQ3RELE9BQU8sVUFBVSxDQUFDLEtBQUssRUFBRSxJQUFJLENBQUMsQ0FBQztJQUNqQyxDQUFDOzhHQXRCVSxjQUFjOzRHQUFkLGNBQWM7OzJGQUFkLGNBQWM7a0JBRDFCLElBQUk7bUJBQUMsRUFBRSxJQUFJLEVBQUUsTUFBTSxFQUFFIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgUGlwZSwgUGlwZVRyYW5zZm9ybSB9IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xuXG5pbXBvcnQgeyBmb3JtYXRNYXNrLCBGb3JtYXRNYXNrT3B0aW9uIH0gZnJvbSAnQHllbG9uL3V0aWwvZm9ybWF0JztcblxuQFBpcGUoeyBuYW1lOiAnbWFzaycgfSlcbmV4cG9ydCBjbGFzcyBGb3JtYXRNYXNrUGlwZSBpbXBsZW1lbnRzIFBpcGVUcmFuc2Zvcm0ge1xuICAvKipcbiAgICogRm9ybWF0IG1hc2tcbiAgICpcbiAgICog5qC85byP5YyW5o6p56CBXG4gICAqXG4gICAqIHwg5a2X56ymIHwg5o+P6L+wIHxcbiAgICogfCAtLS0gfCAtLS0gfFxuICAgKiB8IGAwYCB8IOS7u+aEj+aVsOWtl++8jOiLpeivpeS9jee9ruWtl+espuS4jeespuWQiO+8jOWImem7mOiupOS4uiBgMGAg5aGr5YWFIHxcbiAgICogfCBgOWAgfCDku7vmhI/mlbDlrZcgfFxuICAgKiB8IGAjYCB8IOS7u+aEj+Wtl+espiB8XG4gICAqIHwgYFVgIHwg6L2s5o2i5aSn5YaZIHxcbiAgICogfCBgTGAgfCDovazmjaLlsI/lhpkgfFxuICAgKiB8IGAqYCB8IOi9rOaNouS4uiBgKmAg5a2X56ymIHxcbiAgICpcbiAgICogYGBgdHNcbiAgICogZm9ybWF0TWFzaygnMTIzJywgJygjIyMpJykgPT4gKDEyMylcbiAgICogZm9ybWF0TWFzaygnMTU5MDAwMDAwMDAnLCAnOTk5KioqKjk5OTknKSA9PiAxNTkqKioqMDAwMFxuICAgKiBgYGBcbiAgICovXG4gIHRyYW5zZm9ybSh2YWx1ZTogc3RyaW5nLCBtYXNrOiBzdHJpbmcgfCBGb3JtYXRNYXNrT3B0aW9uKTogc3RyaW5nIHtcbiAgICByZXR1cm4gZm9ybWF0TWFzayh2YWx1ZSwgbWFzayk7XG4gIH1cbn1cbiJdfQ==
|
@@ -2,17 +2,16 @@ import { NgModule } from '@angular/core';
|
|
2
2
|
import { FormatMaskPipe } from './mask.pipe';
|
3
3
|
import * as i0 from "@angular/core";
|
4
4
|
const PIPES = [FormatMaskPipe];
|
5
|
-
class FormatPipeModule {
|
6
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1
|
7
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1
|
8
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1
|
5
|
+
export class FormatPipeModule {
|
6
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: FormatPipeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
7
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.1", ngImport: i0, type: FormatPipeModule, declarations: [FormatMaskPipe], exports: [FormatMaskPipe] }); }
|
8
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: FormatPipeModule }); }
|
9
9
|
}
|
10
|
-
|
11
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.8", ngImport: i0, type: FormatPipeModule, decorators: [{
|
10
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: FormatPipeModule, decorators: [{
|
12
11
|
type: NgModule,
|
13
12
|
args: [{
|
14
13
|
declarations: PIPES,
|
15
14
|
exports: PIPES
|
16
15
|
}]
|
17
16
|
}] });
|
18
|
-
//# sourceMappingURL=data:application/json;base64,
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvdXRpbC9waXBlcy9mb3JtYXQvbW9kdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFFekMsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLGFBQWEsQ0FBQzs7QUFFN0MsTUFBTSxLQUFLLEdBQUcsQ0FBQyxjQUFjLENBQUMsQ0FBQztBQU0vQixNQUFNLE9BQU8sZ0JBQWdCOzhHQUFoQixnQkFBZ0I7K0dBQWhCLGdCQUFnQixpQkFOZCxjQUFjLGFBQWQsY0FBYzsrR0FNaEIsZ0JBQWdCOzsyRkFBaEIsZ0JBQWdCO2tCQUo1QixRQUFRO21CQUFDO29CQUNSLFlBQVksRUFBRSxLQUFLO29CQUNuQixPQUFPLEVBQUUsS0FBSztpQkFDZiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IE5nTW9kdWxlIH0gZnJvbSAnQGFuZ3VsYXIvY29yZSc7XG5cbmltcG9ydCB7IEZvcm1hdE1hc2tQaXBlIH0gZnJvbSAnLi9tYXNrLnBpcGUnO1xuXG5jb25zdCBQSVBFUyA9IFtGb3JtYXRNYXNrUGlwZV07XG5cbkBOZ01vZHVsZSh7XG4gIGRlY2xhcmF0aW9uczogUElQRVMsXG4gIGV4cG9ydHM6IFBJUEVTXG59KVxuZXhwb3J0IGNsYXNzIEZvcm1hdFBpcGVNb2R1bGUge31cbiJdfQ==
|
package/fesm2022/analysis.mjs
CHANGED
@@ -6,10 +6,10 @@ class GlobalEventSubjectService {
|
|
6
6
|
constructor() {
|
7
7
|
this.clickEvents = new Subject();
|
8
8
|
}
|
9
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1
|
10
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1
|
9
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: GlobalEventSubjectService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
10
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: GlobalEventSubjectService, providedIn: 'root' }); }
|
11
11
|
}
|
12
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1
|
12
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: GlobalEventSubjectService, decorators: [{
|
13
13
|
type: Injectable,
|
14
14
|
args: [{
|
15
15
|
providedIn: 'root'
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"analysis.mjs","sources":["../../../../packages/util/analysis/global-event.subject.ts","../../../../packages/util/analysis/analysis.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { Subject } from 'rxjs';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class GlobalEventSubjectService {\n public clickEvents = new Subject<Event>();\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;
|
1
|
+
{"version":3,"file":"analysis.mjs","sources":["../../../../packages/util/analysis/global-event.subject.ts","../../../../packages/util/analysis/analysis.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { Subject } from 'rxjs';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class GlobalEventSubjectService {\n public clickEvents = new Subject<Event>();\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAMa,yBAAyB,CAAA;AAHtC,IAAA,WAAA,GAAA;AAIS,QAAA,IAAA,CAAA,WAAW,GAAG,IAAI,OAAO,EAAS,CAAC;AAC3C,KAAA;8GAFY,yBAAyB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA,EAAA;AAAzB,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,yBAAyB,cAFxB,MAAM,EAAA,CAAA,CAAA,EAAA;;2FAEP,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBAHrC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA,CAAA;;;ACLD;;AAEG;;;;"}
|
package/fesm2022/array.mjs
CHANGED
@@ -268,10 +268,10 @@ class ArrayService {
|
|
268
268
|
}, new Map())
|
269
269
|
.values());
|
270
270
|
}
|
271
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1
|
272
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1
|
271
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: ArrayService, deps: [{ token: i1.YunzaiConfigService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
272
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: ArrayService, providedIn: 'root' }); }
|
273
273
|
}
|
274
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1
|
274
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: ArrayService, decorators: [{
|
275
275
|
type: Injectable,
|
276
276
|
args: [{ providedIn: 'root' }]
|
277
277
|
}], ctorParameters: function () { return [{ type: i1.YunzaiConfigService }]; } });
|
package/fesm2022/array.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"array.mjs","sources":["../../../../packages/util/array/array.service.ts","../../../../packages/util/array/array.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\n\nimport { YunzaiConfigService, YunzaiUtilArrayConfig } from '@yelon/util/config';\nimport { NzTreeNode } from 'ng-zorro-antd/core/tree';\n\nimport {\n ArrayServiceArrToTreeNodeOptions,\n ArrayServiceArrToTreeOptions,\n ArrayServiceGetKeysByTreeNodeOptions,\n ArrayServiceGroupByResult,\n ArrayServiceTreeToArrOptions\n} from './array-type.service';\n\n@Injectable({ providedIn: 'root' })\nexport class ArrayService {\n private c: YunzaiUtilArrayConfig;\n\n constructor(cog: YunzaiConfigService) {\n this.c = cog.merge('utilArray', {\n deepMapName: 'deep',\n parentMapName: 'parent',\n idMapName: 'id',\n parentIdMapName: 'parent_id',\n childrenMapName: 'children',\n titleMapName: 'title',\n checkedMapname: 'checked',\n selectedMapname: 'selected',\n expandedMapname: 'expanded',\n disabledMapname: 'disabled'\n })!;\n }\n\n /**\n * Convert tree structure to array structure\n *\n * 将树结构转换成数组结构\n */\n treeToArr<T extends object = any>(tree: readonly T[], options?: ArrayServiceTreeToArrOptions<T>): T[] {\n const opt = {\n deepMapName: this.c.deepMapName,\n parentMapName: this.c.parentMapName,\n childrenMapName: this.c.childrenMapName,\n clearChildren: true,\n cb: null,\n ...options\n } as ArrayServiceTreeToArrOptions;\n const result: Array<{ [key: string]: any }> = [];\n const inFn = (list: ReadonlyArray<{ [key: string]: any }>, parent: T | null, deep: number = 0): void => {\n for (const i of list) {\n i[opt.deepMapName!] = deep;\n i[opt.parentMapName!] = parent;\n if (opt.cb) {\n opt.cb(i, parent, deep);\n }\n result.push(i);\n const children = i[opt.childrenMapName!];\n if (children != null && Array.isArray(children) && children.length > 0) {\n inFn(children, i as T, deep + 1);\n }\n if (opt.clearChildren) {\n delete i[opt.childrenMapName!];\n }\n }\n };\n inFn(tree, null);\n return result as T[];\n }\n\n /**\n * Convert array structure to tree structure\n *\n * 数组转换成树数据\n */\n arrToTree<T extends object = any>(arr: readonly T[], options?: ArrayServiceArrToTreeOptions<T>): T[] {\n if (!Array.isArray(arr) || arr.length === 0) {\n return [];\n }\n\n const opt = {\n idMapName: this.c.idMapName,\n parentIdMapName: this.c.parentIdMapName,\n childrenMapName: this.c.childrenMapName,\n cb: null,\n ...options\n } as ArrayServiceArrToTreeOptions<T>;\n const tree: T[] = [];\n const childrenOf: { [key: string]: T[] } = {};\n let rootPid = opt.rootParentIdValue;\n const arrType = arr as ReadonlyArray<{ [key: string]: any }>;\n if (!rootPid) {\n const pids = arrType.map(i => i[opt.parentIdMapName!]);\n const emptyPid = pids.findIndex(w => w == null);\n rootPid = emptyPid !== -1 ? pids[emptyPid] : pids.sort()[0];\n }\n for (const item of arrType) {\n const id = item[opt.idMapName!];\n const pid = item[opt.parentIdMapName!];\n childrenOf[id] = childrenOf[id] || [];\n item[opt.childrenMapName!] = childrenOf[id];\n if (opt.cb) {\n opt.cb(item as T);\n }\n if (pid !== rootPid) {\n childrenOf[pid] = childrenOf[pid] || [];\n childrenOf[pid].push(item as T);\n } else {\n tree.push(item as T);\n }\n }\n return tree;\n }\n\n /**\n * 数组转换成 `nz-tree` 数据源,通过 `options` 转化项名,也可以使用 `options.cb` 更高级决定数据项\n */\n arrToTreeNode<T extends object = any>(arr: readonly T[], options?: ArrayServiceArrToTreeNodeOptions): NzTreeNode[] {\n const opt = {\n idMapName: this.c.idMapName,\n parentIdMapName: this.c.parentIdMapName,\n titleMapName: this.c.titleMapName,\n isLeafMapName: 'isLeaf',\n checkedMapname: this.c.checkedMapname,\n selectedMapname: this.c.selectedMapname,\n expandedMapname: this.c.expandedMapname,\n disabledMapname: this.c.disabledMapname,\n cb: null,\n ...options\n } as ArrayServiceArrToTreeNodeOptions<T>;\n const tree = this.arrToTree<T>(arr, {\n idMapName: opt.idMapName,\n parentIdMapName: opt.parentIdMapName,\n childrenMapName: 'children'\n });\n this.visitTree<T>(tree, (item: { [key: string]: any }, parent, deep) => {\n item.key = item[opt.idMapName!];\n item.title = item[opt.titleMapName!];\n item.checked = item[opt.checkedMapname!];\n item.selected = item[opt.selectedMapname!];\n item.expanded = item[opt.expandedMapname!];\n item.disabled = item[opt.disabledMapname!];\n if (item[opt.isLeafMapName!] == null) {\n item.isLeaf = item.children.length === 0;\n } else {\n item.isLeaf = item[opt.isLeafMapName!];\n }\n if (opt.cb) {\n opt.cb(item as any, parent, deep);\n }\n });\n return tree.map(node => new NzTreeNode(node as any));\n }\n\n /**\n * 递归访问整个树\n */\n visitTree<T extends object = any>(\n tree: readonly T[],\n cb: (item: T, parent: T | null, deep: number) => void,\n options?: {\n /** 子项名,默认:`'children'` */\n childrenMapName?: string;\n }\n ): void {\n options = {\n childrenMapName: this.c.childrenMapName,\n ...options\n };\n const inFn = (data: readonly T[], parent: T | null, deep: number): void => {\n for (const item of data) {\n cb(item, parent, deep);\n const childrenVal = (item as { [key: string]: any })[options!.childrenMapName!];\n if (Array.isArray(childrenVal) && childrenVal.length > 0) {\n inFn(childrenVal, item, deep + 1);\n }\n }\n };\n inFn(tree, null, 1);\n }\n\n /**\n * Return the value of the first tree value in the tree where predicate is true, and `undefined` otherwise\n *\n * 根据条件返回树的第一个值,否则返回 `undefined`\n */\n findTree<T extends object = any>(\n tree: readonly T[],\n predicate: (item: T) => boolean,\n options?: {\n /** 子项名,默认:`'children'` */\n childrenMapName?: string;\n }\n ): T | undefined {\n let res: T | undefined;\n this.visitTree<T>(\n tree,\n item => {\n if (res === undefined && predicate(item)) {\n res = item;\n }\n },\n options\n );\n return res;\n }\n\n /**\n * 获取所有已经选中的 `key` 值\n */\n getKeysByTreeNode(tree: NzTreeNode[], options?: ArrayServiceGetKeysByTreeNodeOptions): any[] {\n const opt = {\n includeHalfChecked: true,\n ...options\n } as ArrayServiceGetKeysByTreeNodeOptions;\n const keys: any[] = [];\n this.visitTree<NzTreeNode>(tree, (item, parent, deep) => {\n if (item.isChecked || (opt.includeHalfChecked && item.isHalfChecked)) {\n keys.push(opt.cb ? opt.cb(item, parent, deep) : opt.keyMapName ? item.origin[opt.keyMapName] : item.key);\n }\n });\n return keys;\n }\n private baseFlat(array: any[], depth: number, result: any[] = []): any[] {\n let index = -1;\n while (++index < array.length) {\n const value = array[index];\n if (depth > 0 && Array.isArray(value)) {\n if (depth > 1) {\n this.baseFlat(value, depth - 1, result);\n } else {\n let pushIndex = -1;\n const offset = result.length;\n\n while (++pushIndex < value.length) {\n result[offset + pushIndex] = value[pushIndex];\n }\n }\n } else {\n result[result.length] = value;\n }\n }\n return result;\n }\n /**\n * Recursively flattens array\n *\n * 递归扁平数组\n * ```ts\n * srv.flat([1, [2, 3, [4, 5, [6]]]]) => [1,2,3,4,5,6]\n * srv.flat([1, [2, 3, [4, 5, [6]]]], 1) => [1,2,3,[4, 5, [6]]]\n * ```\n */\n flat<T>(array: readonly T[], depth: number = 1 / 0): T[] {\n return Array.isArray(array) ? this.baseFlat(array as any[], depth) : (array as T[]);\n }\n /**\n * Group the array\n *\n * 对数组进行分组\n * ```ts\n * srv.groupBy([6.1, 4.2, 6.3], Math.floor) => {\"4\":[4.2],\"6\":[6.1,6.3]}\n * srv.groupBy(['one', 'two', 'three'], v => v.length) => {\"3\":[\"one\",\"two\"],\"5\":[\"three\"]}\n * ```\n */\n groupBy<T>(array: readonly T[], iteratee: (value: T) => string | number): ArrayServiceGroupByResult {\n if (!Array.isArray(array)) {\n return {};\n }\n return array.reduce((result, value) => {\n const key = iteratee(value);\n if (Object.prototype.hasOwnProperty.call(result, key)) {\n result[key].push(value);\n } else {\n result[key] = [value];\n }\n return result;\n }, {} as ArrayServiceGroupByResult);\n }\n /**\n * Creates a duplicate-free version of an array\n *\n * 创建去重后的数组\n * ```ts\n * uniq([1, 2, 2, 3, 1]) => [1,2,3]\n * uniq([{ a: 1 }, { a: 1 }, { a: 2 }], 'a') => [{\"a\":1},{\"a\":2}]\n * uniq([{ a: 1 }, { a: 1 }, { a: 2 }], i => (i.a === 1 ? 'a' : 'b')) => [{\"a\":1},{\"a\":2}]\n * ```\n */\n uniq<T>(array: readonly T[], predicate?: string | ((value: T) => string | number | boolean)): T[] {\n return Array.from(\n array\n .reduce((map, value) => {\n const key = predicate\n ? typeof predicate === 'string'\n ? (value as any)[predicate]\n : predicate!(value)\n : value;\n if (!map.has(key)) {\n map.set(key, value);\n }\n return map;\n }, new Map<string | number | boolean, T>())\n .values()\n );\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAaA,MACa,YAAY,CAAA;AAGvB,IAAA,WAAA,CAAY,GAAwB,EAAA;QAClC,IAAI,CAAC,CAAC,GAAG,GAAG,CA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service.ts","../../../../packages/util/array/array.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\n\nimport { YunzaiConfigService, YunzaiUtilArrayConfig } from '@yelon/util/config';\nimport { NzTreeNode } from 'ng-zorro-antd/core/tree';\n\nimport {\n ArrayServiceArrToTreeNodeOptions,\n ArrayServiceArrToTreeOptions,\n ArrayServiceGetKeysByTreeNodeOptions,\n ArrayServiceGroupByResult,\n ArrayServiceTreeToArrOptions\n} from './array-type.service';\n\n@Injectable({ providedIn: 'root' })\nexport class ArrayService {\n private c: YunzaiUtilArrayConfig;\n\n constructor(cog: YunzaiConfigService) {\n this.c = cog.merge('utilArray', {\n deepMapName: 'deep',\n parentMapName: 'parent',\n idMapName: 'id',\n parentIdMapName: 'parent_id',\n childrenMapName: 'children',\n titleMapName: 'title',\n checkedMapname: 'checked',\n selectedMapname: 'selected',\n expandedMapname: 'expanded',\n disabledMapname: 'disabled'\n })!;\n }\n\n /**\n * Convert tree structure to array structure\n *\n * 将树结构转换成数组结构\n */\n treeToArr<T extends object = any>(tree: readonly T[], options?: ArrayServiceTreeToArrOptions<T>): T[] {\n const opt = {\n deepMapName: this.c.deepMapName,\n parentMapName: this.c.parentMapName,\n childrenMapName: this.c.childrenMapName,\n clearChildren: true,\n cb: null,\n ...options\n } as ArrayServiceTreeToArrOptions;\n const result: Array<{ [key: string]: any }> = [];\n const inFn = (list: ReadonlyArray<{ [key: string]: any }>, parent: T | null, deep: number = 0): void => {\n for (const i of list) {\n i[opt.deepMapName!] = deep;\n i[opt.parentMapName!] = parent;\n if (opt.cb) {\n opt.cb(i, parent, deep);\n }\n result.push(i);\n const children = i[opt.childrenMapName!];\n if (children != null && Array.isArray(children) && children.length > 0) {\n inFn(children, i as T, deep + 1);\n }\n if (opt.clearChildren) {\n delete i[opt.childrenMapName!];\n }\n }\n };\n inFn(tree, null);\n return result as T[];\n }\n\n /**\n * Convert array structure to tree structure\n *\n * 数组转换成树数据\n */\n arrToTree<T extends object = any>(arr: readonly T[], options?: ArrayServiceArrToTreeOptions<T>): T[] {\n if (!Array.isArray(arr) || arr.length === 0) {\n return [];\n }\n\n const opt = {\n idMapName: this.c.idMapName,\n parentIdMapName: this.c.parentIdMapName,\n childrenMapName: this.c.childrenMapName,\n cb: null,\n ...options\n } as ArrayServiceArrToTreeOptions<T>;\n const tree: T[] = [];\n const childrenOf: { [key: string]: T[] } = {};\n let rootPid = opt.rootParentIdValue;\n const arrType = arr as ReadonlyArray<{ [key: string]: any }>;\n if (!rootPid) {\n const pids = arrType.map(i => i[opt.parentIdMapName!]);\n const emptyPid = pids.findIndex(w => w == null);\n rootPid = emptyPid !== -1 ? pids[emptyPid] : pids.sort()[0];\n }\n for (const item of arrType) {\n const id = item[opt.idMapName!];\n const pid = item[opt.parentIdMapName!];\n childrenOf[id] = childrenOf[id] || [];\n item[opt.childrenMapName!] = childrenOf[id];\n if (opt.cb) {\n opt.cb(item as T);\n }\n if (pid !== rootPid) {\n childrenOf[pid] = childrenOf[pid] || [];\n childrenOf[pid].push(item as T);\n } else {\n tree.push(item as T);\n }\n }\n return tree;\n }\n\n /**\n * 数组转换成 `nz-tree` 数据源,通过 `options` 转化项名,也可以使用 `options.cb` 更高级决定数据项\n */\n arrToTreeNode<T extends object = any>(arr: readonly T[], options?: ArrayServiceArrToTreeNodeOptions): NzTreeNode[] {\n const opt = {\n idMapName: this.c.idMapName,\n parentIdMapName: this.c.parentIdMapName,\n titleMapName: this.c.titleMapName,\n isLeafMapName: 'isLeaf',\n checkedMapname: this.c.checkedMapname,\n selectedMapname: this.c.selectedMapname,\n expandedMapname: this.c.expandedMapname,\n disabledMapname: this.c.disabledMapname,\n cb: null,\n ...options\n } as ArrayServiceArrToTreeNodeOptions<T>;\n const tree = this.arrToTree<T>(arr, {\n idMapName: opt.idMapName,\n parentIdMapName: opt.parentIdMapName,\n childrenMapName: 'children'\n });\n this.visitTree<T>(tree, (item: { [key: string]: any }, parent, deep) => {\n item.key = item[opt.idMapName!];\n item.title = item[opt.titleMapName!];\n item.checked = item[opt.checkedMapname!];\n item.selected = item[opt.selectedMapname!];\n item.expanded = item[opt.expandedMapname!];\n item.disabled = item[opt.disabledMapname!];\n if (item[opt.isLeafMapName!] == null) {\n item.isLeaf = item.children.length === 0;\n } else {\n item.isLeaf = item[opt.isLeafMapName!];\n }\n if (opt.cb) {\n opt.cb(item as any, parent, deep);\n }\n });\n return tree.map(node => new NzTreeNode(node as any));\n }\n\n /**\n * 递归访问整个树\n */\n visitTree<T extends object = any>(\n tree: readonly T[],\n cb: (item: T, parent: T | null, deep: number) => void,\n options?: {\n /** 子项名,默认:`'children'` */\n childrenMapName?: string;\n }\n ): void {\n options = {\n childrenMapName: this.c.childrenMapName,\n ...options\n };\n const inFn = (data: readonly T[], parent: T | null, deep: number): void => {\n for (const item of data) {\n cb(item, parent, deep);\n const childrenVal = (item as { [key: string]: any })[options!.childrenMapName!];\n if (Array.isArray(childrenVal) && childrenVal.length > 0) {\n inFn(childrenVal, item, deep + 1);\n }\n }\n };\n inFn(tree, null, 1);\n }\n\n /**\n * Return the value of the first tree value in the tree where predicate is true, and `undefined` otherwise\n *\n * 根据条件返回树的第一个值,否则返回 `undefined`\n */\n findTree<T extends object = any>(\n tree: readonly T[],\n predicate: (item: T) => boolean,\n options?: {\n /** 子项名,默认:`'children'` */\n childrenMapName?: string;\n }\n ): T | undefined {\n let res: T | undefined;\n this.visitTree<T>(\n tree,\n item => {\n if (res === undefined && predicate(item)) {\n res = item;\n }\n },\n options\n );\n return res;\n }\n\n /**\n * 获取所有已经选中的 `key` 值\n */\n getKeysByTreeNode(tree: NzTreeNode[], options?: ArrayServiceGetKeysByTreeNodeOptions): any[] {\n const opt = {\n includeHalfChecked: true,\n ...options\n } as ArrayServiceGetKeysByTreeNodeOptions;\n const keys: any[] = [];\n this.visitTree<NzTreeNode>(tree, (item, parent, deep) => {\n if (item.isChecked || (opt.includeHalfChecked && item.isHalfChecked)) {\n keys.push(opt.cb ? opt.cb(item, parent, deep) : opt.keyMapName ? item.origin[opt.keyMapName] : item.key);\n }\n });\n return keys;\n }\n private baseFlat(array: any[], depth: number, result: any[] = []): any[] {\n let index = -1;\n while (++index < array.length) {\n const value = array[index];\n if (depth > 0 && Array.isArray(value)) {\n if (depth > 1) {\n this.baseFlat(value, depth - 1, result);\n } else {\n let pushIndex = -1;\n const offset = result.length;\n\n while (++pushIndex < value.length) {\n result[offset + pushIndex] = value[pushIndex];\n }\n }\n } else {\n result[result.length] = value;\n }\n }\n return result;\n }\n /**\n * Recursively flattens array\n *\n * 递归扁平数组\n * ```ts\n * srv.flat([1, [2, 3, [4, 5, [6]]]]) => [1,2,3,4,5,6]\n * srv.flat([1, [2, 3, [4, 5, [6]]]], 1) => [1,2,3,[4, 5, [6]]]\n * ```\n */\n flat<T>(array: readonly T[], depth: number = 1 / 0): T[] {\n return Array.isArray(array) ? this.baseFlat(array as any[], depth) : (array as T[]);\n }\n /**\n * Group the array\n *\n * 对数组进行分组\n * ```ts\n * srv.groupBy([6.1, 4.2, 6.3], Math.floor) => {\"4\":[4.2],\"6\":[6.1,6.3]}\n * srv.groupBy(['one', 'two', 'three'], v => v.length) => {\"3\":[\"one\",\"two\"],\"5\":[\"three\"]}\n * ```\n */\n groupBy<T>(array: readonly T[], iteratee: (value: T) => string | number): ArrayServiceGroupByResult {\n if (!Array.isArray(array)) {\n return {};\n }\n return array.reduce((result, value) => {\n const key = iteratee(value);\n if (Object.prototype.hasOwnProperty.call(result, key)) {\n result[key].push(value);\n } else {\n result[key] = [value];\n }\n return result;\n }, {} as ArrayServiceGroupByResult);\n }\n /**\n * Creates a duplicate-free version of an array\n *\n * 创建去重后的数组\n * ```ts\n * uniq([1, 2, 2, 3, 1]) => [1,2,3]\n * uniq([{ a: 1 }, { a: 1 }, { a: 2 }], 'a') => [{\"a\":1},{\"a\":2}]\n * uniq([{ a: 1 }, { a: 1 }, { a: 2 }], i => (i.a === 1 ? 'a' : 'b')) => [{\"a\":1},{\"a\":2}]\n * ```\n */\n uniq<T>(array: readonly T[], predicate?: string | ((value: T) => string | number | boolean)): T[] {\n return Array.from(\n array\n .reduce((map, value) => {\n const key = predicate\n ? typeof predicate === 'string'\n ? (value as any)[predicate]\n : predicate!(value)\n : value;\n if (!map.has(key)) {\n map.set(key, value);\n }\n return map;\n }, new Map<string | number | boolean, T>())\n .values()\n );\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;MAca,YAAY,CAAA;AAGvB,IAAA,WAAA,CAAY,GAAwB,EAAA;QAClC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE;AAC9B,YAAA,WAAW,EAAE,MAAM;AACnB,YAAA,aAAa,EAAE,QAAQ;AACvB,YAAA,SAAS,EAAE,IAAI;AACf,YAAA,eAAe,EAAE,WAAW;AAC5B,YAAA,eAAe,EAAE,UAAU;AAC3B,YAAA,YAAY,EAAE,OAAO;AACrB,YAAA,cAAc,EAAE,SAAS;AACzB,YAAA,eAAe,EAAE,UAAU;AAC3B,YAAA,eAAe,EAAE,UAAU;AAC3B,YAAA,eAAe,EAAE,UAAU;AAC5B,SAAA,CAAE,CAAC;KACL;AAED;;;;AAIG;IACH,SAAS,CAAyB,IAAkB,EAAE,OAAyC,EAAA;AAC7F,QAAA,MAAM,GAAG,GAAG;AACV,YAAA,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW;AAC/B,YAAA,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC,aAAa;AACnC,YAAA,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,eAAe;AACvC,YAAA,aAAa,EAAE,IAAI;AACnB,YAAA,EAAE,EAAE,IAAI;AACR,YAAA,GAAG,OAAO;SACqB,CAAC;QAClC,MAAM,MAAM,GAAkC,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,CAAC,IAA2C,EAAE,MAAgB,EAAE,IAAA,GAAe,CAAC,KAAU;AACrG,YAAA,KAAK,MAAM,CAAC,IAAI,I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AZ,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,cADC,MAAM,EAAA,CAAA,CAAA,EAAA;;2FACnB,YAAY,EAAA,UAAA,EAAA,CAAA;kBADxB,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;;;ACblC;;AAEG;;;;"}
|
package/fesm2022/browser.mjs
CHANGED
@@ -91,10 +91,10 @@ class CookieService {
|
|
91
91
|
removeAll() {
|
92
92
|
this.doc.cookie = '';
|
93
93
|
}
|
94
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1
|
95
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1
|
94
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: CookieService, deps: [{ token: DOCUMENT }, { token: i1.Platform }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
95
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: CookieService, providedIn: 'root' }); }
|
96
96
|
}
|
97
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1
|
97
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: CookieService, decorators: [{
|
98
98
|
type: Injectable,
|
99
99
|
args: [{ providedIn: 'root' }]
|
100
100
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
@@ -222,10 +222,10 @@ class ScrollService {
|
|
222
222
|
}
|
223
223
|
this.scrollToElement(this._getDoc().body, topOffset);
|
224
224
|
}
|
225
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1
|
226
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1
|
225
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: ScrollService, deps: [{ token: DOCUMENT }, { token: i1.Platform }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
226
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: ScrollService, providedIn: 'root' }); }
|
227
227
|
}
|
228
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1
|
228
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: ScrollService, decorators: [{
|
229
229
|
type: Injectable,
|
230
230
|
args: [{ providedIn: 'root' }]
|
231
231
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
package/fesm2022/browser.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"browser.mjs","sources":["../../../../packages/util/browser/cookie.service.ts","../../../../packages/util/browser/copy.ts","../../../../packages/util/browser/is-empty.ts","../../../../packages/util/browser/scroll.service.ts","../../../../packages/util/browser/style.ts","../../../../packages/util/browser/browser.ts"],"sourcesContent":["import { Platform } from '@angular/cdk/platform';\nimport { DOCUMENT } from '@angular/common';\nimport { Inject, Injectable } from '@angular/core';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nexport interface CookieOptions {\n path?: string;\n domain?: string;\n /**\n * Expiration time, `number` is seconds\n *\n * 过期时间,`number` 类型表示秒数\n */\n expires?: number | Date | string;\n secure?: boolean;\n HttpOnly?: boolean;\n SameSite?: boolean | 'lax' | 'strict' | 'none';\n}\n\n/**\n * A set of simple Cookie manipulation classes.\n *\n * 一组简单的 Cookie 操作类。\n */\n@Injectable({ providedIn: 'root' })\nexport class CookieService {\n private get doc(): Document {\n return this._doc || document;\n }\n\n /**\n * Original cookie value\n *\n * 原始Cookie值\n */\n get cookie(): string {\n return this.platform.isBrowser ? this.doc.cookie : '';\n }\n\n constructor(@Inject(DOCUMENT) private _doc: NzSafeAny, private platform: Platform) {}\n\n /**\n * Get all cookie key-value pairs\n *\n * 获取所有Cookie键值对\n */\n getAll(): { [key: string]: string } {\n const ret: { [key: string]: string } = {};\n const arr = this.cookie.split('; ');\n for (let i = 0; i < arr.length; i++) {\n const cookie = arr[i];\n const index = cookie.indexOf('=');\n if (index > 0) {\n const name = decodeURIComponent(cookie.substring(0, index));\n if (ret[name] == null) {\n ret[name] = decodeURIComponent(cookie.substring(index + 1));\n }\n }\n }\n return ret;\n }\n\n /**\n * Get the value of given cookie `key`\n *\n * 获取指定 `key` 的值\n */\n get(key: string): string | undefined {\n return this.getAll()[key];\n }\n\n /**\n * Sets a value for given cookie key\n *\n * 设置指定 Cookie 键的值\n */\n put(key: string, value: string, options?: CookieOptions): void {\n if (!this.platform.isBrowser) {\n return;\n }\n const opt = { path: '/', ...options };\n if (typeof opt.expires === 'number') {\n opt.expires = new Date(+new Date() + opt.expires * 1e3);\n }\n if (typeof opt.expires !== 'string') {\n opt.expires = opt.expires ? opt.expires.toUTCString() : '';\n }\n const optStr: { [key: string]: string | boolean } = opt as NzSafeAny;\n const attributes = Object.keys(optStr)\n .filter(k => optStr[k] && optStr[k] !== true)\n .map(k => `${k}=${(optStr[k] as string).split(';')[0]}`)\n .join(';');\n this.doc.cookie = `${encodeURIComponent(String(key))}=${encodeURIComponent(String(value))}${\n attributes ? `; ${attributes}` : ''\n }`;\n }\n\n /**\n * Remove given cookie\n *\n * 移除指定 Cookie\n */\n remove(key: string, options?: CookieOptions): void {\n this.put(key, '', options);\n }\n\n /**\n * Remove all cookies\n *\n * 移除所有 Cookies\n */\n removeAll(): void {\n this.doc.cookie = '';\n }\n}\n","/**\n * Copy text to clipboard\n *\n * 复制字符串文档至剪贴板\n */\nexport function copy(value: string): Promise<string> {\n return new Promise<string>((resolve): void => {\n let copyTextArea: HTMLTextAreaElement | null = null;\n try {\n copyTextArea = document.createElement('textarea');\n copyTextArea.style.height = '0px';\n copyTextArea.style.opacity = '0';\n copyTextArea.style.width = '0px';\n document.body.appendChild(copyTextArea);\n copyTextArea.value = value;\n copyTextArea.select();\n // eslint-disable-next-line deprecation/deprecation\n document.execCommand('copy');\n resolve(value);\n } finally {\n if (copyTextArea && copyTextArea.parentNode) {\n copyTextArea.parentNode.removeChild(copyTextArea);\n }\n }\n });\n}\n","/**\n * Used to verify `<ng-content></ng-content>` is empty, useful for custom components.\n *\n * 用于校验 `<ng-content></ng-content>` 是否为空,自定义组件时蛮有用。\n */\nexport function isEmpty(element: HTMLElement): boolean {\n const nodes = element.childNodes;\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes.item(i);\n if (node.nodeType === 1 && (node as HTMLElement).outerHTML.toString().trim().length !== 0) {\n return false;\n } else if (node.nodeType === 3 && node.textContent!.toString().trim().length !== 0) {\n return false;\n }\n }\n return true;\n}\n","import { Platform } from '@angular/cdk/platform';\nimport { DOCUMENT } from '@angular/common';\nimport { Inject, Injectable } from '@angular/core';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\n@Injectable({ providedIn: 'root' })\nexport class ScrollService {\n private _getDoc(): Document {\n return this._doc || document;\n }\n\n private _getWin(): Window {\n const doc = this._getDoc();\n return doc.defaultView || window;\n }\n\n constructor(@Inject(DOCUMENT) private _doc: NzSafeAny, private platform: Platform) {}\n\n /**\n * 获取滚动条位置\n *\n * @param element 指定元素,默认 `window`\n */\n getScrollPosition(element?: Element | Window): [number, number] {\n if (!this.platform.isBrowser) {\n return [0, 0];\n }\n\n const win = this._getWin();\n if (element && element !== win) {\n return [(element as Element).scrollLeft, (element as Element).scrollTop];\n } else {\n return [win.scrollX, win.scrollY];\n }\n }\n\n /**\n * 设置滚动条位置\n *\n * @param element 指定元素\n */\n scrollToPosition(element: Element | Window | null | undefined, position: [number, number]): void {\n if (!this.platform.isBrowser) {\n return;\n }\n (element || this._getWin()).scrollTo(position[0], position[1]);\n }\n\n /**\n * 设置滚动条至指定元素\n *\n * @param element 指定元素,默认 `document.body`\n * @param topOffset 偏移值,默认 `0`\n */\n scrollToElement(element?: Element | null, topOffset: number = 0): void {\n if (!this.platform.isBrowser) {\n return;\n }\n if (!element) {\n element = this._getDoc().body;\n }\n\n element.scrollIntoView();\n\n const win = this._getWin();\n if (win && win.scrollBy) {\n win.scrollBy(0, element!.getBoundingClientRect().top - topOffset);\n\n if (win.scrollY < 20) {\n win.scrollBy(0, -win.scrollY);\n }\n }\n }\n\n /**\n * 滚动至顶部\n *\n * @param topOffset 偏移值,默认 `0`\n */\n scrollToTop(topOffset: number = 0): void {\n if (!this.platform.isBrowser) {\n return;\n }\n this.scrollToElement(this._getDoc().body, topOffset);\n }\n}\n","import { Renderer2 } from '@angular/core';\n\nfunction removeClass(el: HTMLElement, classMap: { [klass: string]: unknown }, renderer: Renderer2): void {\n Object.keys(classMap).forEach(key => renderer.removeClass(el, key));\n}\n\nfunction addClass(el: HTMLElement, classMap: { [klass: string]: unknown }, renderer: Renderer2): void {\n for (const i in classMap) {\n if (classMap[i]) {\n renderer.addClass(el, i);\n }\n }\n}\n\n/**\n * Update host component style `class`\n *\n * 更新宿主组件样式 `class`\n *\n * ```ts\n * updateHostClass(\n * this.el.nativeElement,\n * this.renderer,\n * {\n * [ 'classname' ]: true,\n * [ 'classname' ]: this.type === '1',\n * [ this.cls ]: true,\n * [ `a-${this.cls}` ]: true\n * })\n * ```\n */\nexport function updateHostClass(\n el: HTMLElement,\n renderer: Renderer2,\n classMap: { [klass: string]: unknown },\n preClean: boolean = false\n): void {\n if (preClean === true) {\n renderer.removeAttribute(el, 'class');\n } else {\n removeClass(el, classMap, renderer);\n }\n classMap = { ...classMap };\n addClass(el, classMap, renderer);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAoBA;;;;AAIG;AACH,MACa,aAAa,CAAA;AACxB,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AC5CA;;AAEG;;;;"}
|
1
|
+
{"version":3,"file":"browser.mjs","sources":["../../../../packages/util/browser/cookie.service.ts","../../../../packages/util/browser/copy.ts","../../../../packages/util/browser/is-empty.ts","../../../../packages/util/browser/scroll.service.ts","../../../../packages/util/browser/style.ts","../../../../packages/util/browser/browser.ts"],"sourcesContent":["import { Platform } from '@angular/cdk/platform';\nimport { DOCUMENT } from '@angular/common';\nimport { Inject, Injectable } from '@angular/core';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nexport interface CookieOptions {\n path?: string;\n domain?: string;\n /**\n * Expiration time, `number` is seconds\n *\n * 过期时间,`number` 类型表示秒数\n */\n expires?: number | Date | string;\n secure?: boolean;\n HttpOnly?: boolean;\n SameSite?: boolean | 'lax' | 'strict' | 'none';\n}\n\n/**\n * A set of simple Cookie manipulation classes.\n *\n * 一组简单的 Cookie 操作类。\n */\n@Injectable({ providedIn: 'root' })\nexport class CookieService {\n private get doc(): Document {\n return this._doc || document;\n }\n\n /**\n * Original cookie value\n *\n * 原始Cookie值\n */\n get cookie(): string {\n return this.platform.isBrowser ? this.doc.cookie : '';\n }\n\n constructor(\n @Inject(DOCUMENT) private _doc: NzSafeAny,\n private platform: Platform\n ) {}\n\n /**\n * Get all cookie key-value pairs\n *\n * 获取所有Cookie键值对\n */\n getAll(): { [key: string]: string } {\n const ret: { [key: string]: string } = {};\n const arr = this.cookie.split('; ');\n for (let i = 0; i < arr.length; i++) {\n const cookie = arr[i];\n const index = cookie.indexOf('=');\n if (index > 0) {\n const name = decodeURIComponent(cookie.substring(0, index));\n if (ret[name] == null) {\n ret[name] = decodeURIComponent(cookie.substring(index + 1));\n }\n }\n }\n return ret;\n }\n\n /**\n * Get the value of given cookie `key`\n *\n * 获取指定 `key` 的值\n */\n get(key: string): string | undefined {\n return this.getAll()[key];\n }\n\n /**\n * Sets a value for given cookie key\n *\n * 设置指定 Cookie 键的值\n */\n put(key: string, value: string, options?: CookieOptions): void {\n if (!this.platform.isBrowser) {\n return;\n }\n const opt = { path: '/', ...options };\n if (typeof opt.expires === 'number') {\n opt.expires = new Date(+new Date() + opt.expires * 1e3);\n }\n if (typeof opt.expires !== 'string') {\n opt.expires = opt.expires ? opt.expires.toUTCString() : '';\n }\n const optStr: { [key: string]: string | boolean } = opt as NzSafeAny;\n const attributes = Object.keys(optStr)\n .filter(k => optStr[k] && optStr[k] !== true)\n .map(k => `${k}=${(optStr[k] as string).split(';')[0]}`)\n .join(';');\n this.doc.cookie = `${encodeURIComponent(String(key))}=${encodeURIComponent(String(value))}${\n attributes ? `; ${attributes}` : ''\n }`;\n }\n\n /**\n * Remove given cookie\n *\n * 移除指定 Cookie\n */\n remove(key: string, options?: CookieOptions): void {\n this.put(key, '', options);\n }\n\n /**\n * Remove all cookies\n *\n * 移除所有 Cookies\n */\n removeAll(): void {\n this.doc.cookie = '';\n }\n}\n","/**\n * Copy text to clipboard\n *\n * 复制字符串文档至剪贴板\n */\nexport function copy(value: string): Promise<string> {\n return new Promise<string>((resolve): void => {\n let copyTextArea: HTMLTextAreaElement | null = null;\n try {\n copyTextArea = document.createElement('textarea');\n copyTextArea.style.height = '0px';\n copyTextArea.style.opacity = '0';\n copyTextArea.style.width = '0px';\n document.body.appendChild(copyTextArea);\n copyTextArea.value = value;\n copyTextArea.select();\n // eslint-disable-next-line deprecation/deprecation\n document.execCommand('copy');\n resolve(value);\n } finally {\n if (copyTextArea && copyTextArea.parentNode) {\n copyTextArea.parentNode.removeChild(copyTextArea);\n }\n }\n });\n}\n","/**\n * Used to verify `<ng-content></ng-content>` is empty, useful for custom components.\n *\n * 用于校验 `<ng-content></ng-content>` 是否为空,自定义组件时蛮有用。\n */\nexport function isEmpty(element: HTMLElement): boolean {\n const nodes = element.childNodes;\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes.item(i);\n if (node.nodeType === 1 && (node as HTMLElement).outerHTML.toString().trim().length !== 0) {\n return false;\n } else if (node.nodeType === 3 && node.textContent!.toString().trim().length !== 0) {\n return false;\n }\n }\n return true;\n}\n","import { Platform } from '@angular/cdk/platform';\nimport { DOCUMENT } from '@angular/common';\nimport { Inject, Injectable } from '@angular/core';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\n@Injectable({ providedIn: 'root' })\nexport class ScrollService {\n private _getDoc(): Document {\n return this._doc || document;\n }\n\n private _getWin(): Window {\n const doc = this._getDoc();\n return doc.defaultView || window;\n }\n\n constructor(\n @Inject(DOCUMENT) private _doc: NzSafeAny,\n private platform: Platform\n ) {}\n\n /**\n * 获取滚动条位置\n *\n * @param element 指定元素,默认 `window`\n */\n getScrollPosition(element?: Element | Window): [number, number] {\n if (!this.platform.isBrowser) {\n return [0, 0];\n }\n\n const win = this._getWin();\n if (element && element !== win) {\n return [(element as Element).scrollLeft, (element as Element).scrollTop];\n } else {\n return [win.scrollX, win.scrollY];\n }\n }\n\n /**\n * 设置滚动条位置\n *\n * @param element 指定元素\n */\n scrollToPosition(element: Element | Window | null | undefined, position: [number, number]): void {\n if (!this.platform.isBrowser) {\n return;\n }\n (element || this._getWin()).scrollTo(position[0], position[1]);\n }\n\n /**\n * 设置滚动条至指定元素\n *\n * @param element 指定元素,默认 `document.body`\n * @param topOffset 偏移值,默认 `0`\n */\n scrollToElement(element?: Element | null, topOffset: number = 0): void {\n if (!this.platform.isBrowser) {\n return;\n }\n if (!element) {\n element = this._getDoc().body;\n }\n\n element.scrollIntoView();\n\n const win = this._getWin();\n if (win && win.scrollBy) {\n win.scrollBy(0, element!.getBoundingClientRect().top - topOffset);\n\n if (win.scrollY < 20) {\n win.scrollBy(0, -win.scrollY);\n }\n }\n }\n\n /**\n * 滚动至顶部\n *\n * @param topOffset 偏移值,默认 `0`\n */\n scrollToTop(topOffset: number = 0): void {\n if (!this.platform.isBrowser) {\n return;\n }\n this.scrollToElement(this._getDoc().body, topOffset);\n }\n}\n","import { Renderer2 } from '@angular/core';\n\nfunction removeClass(el: HTMLElement, classMap: { [klass: string]: unknown }, renderer: Renderer2): void {\n Object.keys(classMap).forEach(key => renderer.removeClass(el, key));\n}\n\nfunction addClass(el: HTMLElement, classMap: { [klass: string]: unknown }, renderer: Renderer2): void {\n for (const i in classMap) {\n if (classMap[i]) {\n renderer.addClass(el, i);\n }\n }\n}\n\n/**\n * Update host component style `class`\n *\n * 更新宿主组件样式 `class`\n *\n * ```ts\n * updateHostClass(\n * this.el.nativeElement,\n * this.renderer,\n * {\n * [ 'classname' ]: true,\n * [ 'classname' ]: this.type === '1',\n * [ this.cls ]: true,\n * [ `a-${this.cls}` ]: true\n * })\n * ```\n */\nexport function updateHostClass(\n el: HTMLElement,\n renderer: Renderer2,\n classMap: { [klass: string]: unknown },\n preClean: boolean = false\n): void {\n if (preClean === true) {\n renderer.removeAttribute(el, 'class');\n } else {\n removeClass(el, classMap, renderer);\n }\n classMap = { ...classMap };\n addClass(el, classMap, renderer);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAoBA;;;;AAIG;MAEU,aAAa,CAAA;AACxB,IAAA,IAAY,GAAG,GAAA;AACb,QAAA,OAAO,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC;KAC9B;AAED;;;;AAIG;AACH,IAAA,IAAI,MAAM,GAAA;AACR,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC;KACvD;IAED,WAC4B,CAAA,IAAe,EACjC,QAAkB,EAAA;QADA,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAW;QACjC,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAU;KACxB;AAEJ;;;;AAIG;IACH,MAAM,GAAA;QACJ,MAAM,GAAG,GAA8B,EAAE,CAAC;QAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACpC,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,G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CAAC,IAAI,QAAQ,EAAE;AACxB,QAAA,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE;AACf,YAAA,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAC1B,SAAA;AACF,KAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;AAgBG;AACG,SAAU,eAAe,CAC7B,EAAe,EACf,QAAmB,EACnB,QAAsC,EACtC,QAAA,GAAoB,KAAK,EAAA;IAEzB,IAAI,QAAQ,KAAK,IAAI,EAAE;AACrB,QAAA,QAAQ,CAAC,eAAe,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;AACvC,KAAA;AAAM,SAAA;AACL,QAAA,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACrC,KAAA;AACD,IAAA,QAAQ,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;AAC3B,IAAA,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACnC;;AC5CA;;AAEG;;;;"}
|
package/fesm2022/config.mjs
CHANGED
@@ -33,10 +33,10 @@ class YunzaiConfigService {
|
|
33
33
|
set(componentName, value) {
|
34
34
|
this.config[componentName] = { ...this.config[componentName], ...value };
|
35
35
|
}
|
36
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1
|
37
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1
|
36
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: YunzaiConfigService, deps: [{ token: YUNZAI_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
37
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: YunzaiConfigService, providedIn: 'root' }); }
|
38
38
|
}
|
39
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1
|
39
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: YunzaiConfigService, decorators: [{
|
40
40
|
type: Injectable,
|
41
41
|
args: [{ providedIn: 'root' }]
|
42
42
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
package/fesm2022/config.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"config.mjs","sources":["../../../../packages/util/config/abc/sv.type.ts","../../../../packages/util/config/config.types.ts","../../../../packages/util/config/config.service.ts","../../../../packages/util/config/config.ts"],"sourcesContent":["export class YunzaiSVConfig {\n /** 大小,默认:`large` */\n size?: 'small' | 'large';\n /** 间距,默认:`32` */\n gutter?: number;\n /** 布局,默认:`horizontal` */\n layout?: 'horizontal' | 'vertical';\n /** 列数,默认:`3` */\n col?: number;\n /** 是否显示默认值,当内容为空值时显示 `-`,默认:`true` */\n default?: boolean;\n /** `label` 固定宽度,若 `null` 或 `undefined` 表示非固定,默认:`null` */\n labelWidth?: number;\n}\n","import { InjectionToken } from '@angular/core';\n\nimport {\n YunzaiDateRangePickerConfig,\n YunzaiErrorCollectConfig,\n YunzaiExceptionType,\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 { YunzaiSocketConfig } from './socket/socket.type';\nimport { YunzaiThemeHttpClientConfig, YunzaiThemeResponsiveConfig, YunzaiThemeI18nConfig } from './theme/index';\nimport { YunzaiUtilArrayConfig } from './util/array.type';\nimport { YunzaiUtilCurrencyConfig } from './util/currency.type';\n\nexport interface YunzaiConfig {\n bis?: YunzaiBusinessConfig;\n socket?: YunzaiSocketConfig;\n dataRange?: YunzaiDateRangePickerConfig;\n exception?: YunzaiExceptionType;\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 { deepMergeKey } from '@yelon/util/other';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\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 as any, this.merge(componentName, defaultValues));\n }\n\n attachKey<T extends YunzaiConfigKey>(componentThis: unknown, componentName: T, key: string): void {\n Object.assign(componentThis as any, 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,CAAA;AAa1B;;MCuDY,aAAa,GAAG,IAAI,cAAc,CAAe,eAAe,EAAE;AAC7E,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,qBAAqB;AAC/B,CAAA,EAAE;SAEa,qBAAqB,GAAA;AACnC,IAAA,OAAO,EAAE,CAAC;AACZ;;
|
1
|
+
{"version":3,"file":"config.mjs","sources":["../../../../packages/util/config/abc/sv.type.ts","../../../../packages/util/config/config.types.ts","../../../../packages/util/config/config.service.ts","../../../../packages/util/config/config.ts"],"sourcesContent":["export class YunzaiSVConfig {\n /** 大小,默认:`large` */\n size?: 'small' | 'large';\n /** 间距,默认:`32` */\n gutter?: number;\n /** 布局,默认:`horizontal` */\n layout?: 'horizontal' | 'vertical';\n /** 列数,默认:`3` */\n col?: number;\n /** 是否显示默认值,当内容为空值时显示 `-`,默认:`true` */\n default?: boolean;\n /** `label` 固定宽度,若 `null` 或 `undefined` 表示非固定,默认:`null` */\n labelWidth?: number;\n}\n","import { InjectionToken } from '@angular/core';\n\nimport {\n YunzaiDateRangePickerConfig,\n YunzaiErrorCollectConfig,\n YunzaiExceptionType,\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 { YunzaiSocketConfig } from './socket/socket.type';\nimport { YunzaiThemeHttpClientConfig, YunzaiThemeResponsiveConfig, YunzaiThemeI18nConfig } from './theme/index';\nimport { YunzaiUtilArrayConfig } from './util/array.type';\nimport { YunzaiUtilCurrencyConfig } from './util/currency.type';\n\nexport interface YunzaiConfig {\n bis?: YunzaiBusinessConfig;\n socket?: YunzaiSocketConfig;\n dataRange?: YunzaiDateRangePickerConfig;\n exception?: YunzaiExceptionType;\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 { deepMergeKey } from '@yelon/util/other';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\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 as any, this.merge(componentName, defaultValues));\n }\n\n attachKey<T extends YunzaiConfigKey>(componentThis: unknown, componentName: T, key: string): void {\n Object.assign(componentThis as any, 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,CAAA;AAa1B;;MCuDY,aAAa,GAAG,IAAI,cAAc,CAAe,eAAe,EAAE;AAC7E,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,qBAAqB;AAC/B,CAAA,EAAE;SAEa,qBAAqB,GAAA;AACnC,IAAA,OAAO,EAAE,CAAC;AACZ;;MCnEa,mBAAmB,CAAA;AAG9B,IAAA,WAAA,CAA+C,aAA4B,EAAA;AACzE,QAAA,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,aAAa,EAAE,CAAC;KACpC;IAED,GAAG,CAA4B,aAAgB,EAAE,GAAY,EAAA;AAC3D,QAAA,MAAM,GAAG,IAAK,IAAI,CAAC,MAAM,CAAC,aAAa,CAAgC,IAAI,EAAE,CAAc,CAAC;AAC5F,QAAA,OAAO,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC;KACxC;AAED,IAAA,KAAK,CAA4B,aAAgB,EAAE,GAAG,aAAqC,EAAA;AACzF,QAAA,OAAO,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;KAC1E;AAED,IAAA,MAAM,CAA4B,aAAsB,EAAE,aAAgB,EAAE,aAA8B,EAAA;AACxG,QAAA,MAAM,CAAC,MAAM,CAAC,aAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC;KAC/E;AAED,IAAA,SAAS,CAA4B,aAAsB,EAAE,aAAgB,EAAE,GAAW,EAAA;AACxF,QAAA,MAAM,CAAC,MAAM,CAAC,aAAoB,EAAE,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,CAAC;KACnE;IAED,GAAG,CAA4B,aAAgB,EAAE,KAAsB,EAAA;AACrE,QAAA,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;KAC1E;AA1BU,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,kBAGE,aAAa,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA,EAAA;AAHlC,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,cADN,MAAM,EAAA,CAAA,CAAA,EAAA;;2FACnB,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAD/B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;;0BAInB,QAAQ;;0BAAI,MAAM;2BAAC,aAAa,CAAA;;;ACX/C;;AAEG;;;;"}
|
package/fesm2022/format.mjs
CHANGED
@@ -409,10 +409,10 @@ class CurrencyService {
|
|
409
409
|
: integerRes + (decimalRes === '' ? '' : `点${decimalRes}`));
|
410
410
|
return ret;
|
411
411
|
}
|
412
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1
|
413
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1
|
412
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: CurrencyService, deps: [{ token: i1.YunzaiConfigService }, { token: LOCALE_ID }, { token: DEFAULT_CURRENCY_CODE }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
413
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: CurrencyService, providedIn: 'root' }); }
|
414
414
|
}
|
415
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1
|
415
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: CurrencyService, decorators: [{
|
416
416
|
type: Injectable,
|
417
417
|
args: [{ providedIn: 'root' }]
|
418
418
|
}], ctorParameters: function () { return [{ type: i1.YunzaiConfigService }, { type: undefined, decorators: [{
|
package/fesm2022/format.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"format.mjs","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/format.ts"],"sourcesContent":["import { deepGet } from '@yelon/util/other';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\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+))(?:[eE]([-+]?\\\\d+))?`,\n idCard: `(^\\\\d{15}$)|(^\\\\d{17}(?:[0-9]|X)$)`,\n mobile: `^(0|\\\\+?86|17951)?1[0-9]{10}$`,\n url: `(((^https?:(?:\\/\\/)?)(?:[-;:&=\\\\+\\\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\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,})?$)`,\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 { YunzaiConfigService, YunzaiUtilCurrencyConfig } from '@yelon/util/config';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\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.substring(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.substring(i - 3, 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":";;;;;;AAGA;;;;;;;;;;AAUG;AACG,SAAU,MAAM,CACpB,GAA8B,EAC9B,GAAiC,EACjC,cAAuB,KAAK,EAAA;IAE5B,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC,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AA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,eAAe,cADF,MAAM,EAAA,CAAA,CAAA,EAAA;;2FACnB,eAAe,EAAA,UAAA,EAAA,CAAA;kBAD3B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;;0BAO7B,MAAM;2BAAC,SAAS,CAAA;;0BAChB,MAAM;2BAAC,qBAAqB,CAAA;;;ACtBjC;;AAEG;;;;"}
|
1
|
+
{"version":3,"file":"format.mjs","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/format.ts"],"sourcesContent":["import { deepGet } from '@yelon/util/other';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\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+))(?:[eE]([-+]?\\\\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}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::[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,})?$)`,\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 { YunzaiConfigService, YunzaiUtilCurrencyConfig } from '@yelon/util/config';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\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.substring(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.substring(i - 3, 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":";;;;;;AAGA;;;;;;;;;;AAUG;AACG,SAAU,MAAM,CACpB,GAA8B,EAC9B,GAAiC,EACjC,cAAuB,KAAK,EAAA;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;;;;;;;;;;;;;;;;;;AAkBG;AACa,SAAA,UAAU,CAAC,KAAa,EAAE,MAAiC,EAAA;IACzE,IAAI,CAAC,KAAK,EAAE;AACV,QAAA,OAAO,EAAE,CAAC;AACX,KA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data) {
|
|
22
22
|
localStorage.setItem(key, JSON.stringify(data));
|
23
23
|
}
|
24
24
|
function useLocalStorageUser() {
|
25
|
-
const setFn =
|
25
|
+
const setFn = user => set(YZ_USER_KEY, user);
|
26
26
|
const getFn = () => get(YZ_USER_KEY);
|
27
27
|
return [setFn, getFn];
|
28
28
|
}
|
29
29
|
function useLocalStorageProjectInfo() {
|
30
|
-
const setFn =
|
30
|
+
const setFn = data => set(YZ_PROJECT_INFO_KEY, data);
|
31
31
|
const getFn = () => get(YZ_PROJECT_INFO_KEY);
|
32
32
|
return [setFn, getFn];
|
33
33
|
}
|
34
34
|
function useLocalStorageCurrent() {
|
35
|
-
const setFn =
|
35
|
+
const setFn = data => set(YZ_CURRENT_KEY, data);
|
36
36
|
const getFn = () => get(YZ_CURRENT_KEY);
|
37
37
|
return [setFn, getFn];
|
38
38
|
}
|
39
39
|
function useLocalStorageHeaderType() {
|
40
|
-
const setFn =
|
40
|
+
const setFn = data => set(YZ_HEADER_TYPE_KEY, data);
|
41
41
|
const getFn = () => get(YZ_HEADER_TYPE_KEY);
|
42
42
|
return [setFn, getFn];
|
43
43
|
}
|
44
44
|
function useLocalStorageHeader() {
|
45
|
-
const setFn =
|
45
|
+
const setFn = data => set(YZ_HEADER_KEY, data);
|
46
46
|
const getFn = () => get(YZ_HEADER_KEY);
|
47
47
|
return [setFn, getFn];
|
48
48
|
}
|
49
49
|
function useLocalStorageDefaultRoute() {
|
50
|
-
const setFn =
|
50
|
+
const setFn = data => set(YZ_DEFAULT_ROUTE_KEY, data);
|
51
51
|
const getFn = () => get(YZ_DEFAULT_ROUTE_KEY);
|
52
52
|
return [setFn, getFn];
|
53
53
|
}
|
54
54
|
function useLocalStorageTenant() {
|
55
|
-
const setFn =
|
55
|
+
const setFn = data => set(YZ_TENANT_KEY, data);
|
56
56
|
const getFn = () => get(YZ_TENANT_KEY);
|
57
57
|
return [setFn, getFn];
|
58
58
|
}
|
59
59
|
function useLocalStorageLangs() {
|
60
|
-
const setFn =
|
60
|
+
const setFn = data => set(YZ_LANGS_KEY, data);
|
61
61
|
const getFn = () => get(YZ_LANGS_KEY);
|
62
62
|
return [setFn, getFn];
|
63
63
|
}
|