@yelon/util 18.2.0 → 18.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/esm2022/array/array.service.mjs +4 -4
- package/esm2022/browser/cookie.service.mjs +4 -4
- package/esm2022/browser/scroll.service.mjs +4 -4
- package/esm2022/config/config.service.mjs +4 -4
- package/esm2022/format/currency.service.mjs +4 -4
- package/esm2022/other/lazy.service.mjs +4 -4
- package/esm2022/other/path-to-regexp.service.mjs +4 -4
- package/esm2022/pipes/currency/cny.pipe.mjs +4 -4
- package/esm2022/pipes/currency/mega.pipe.mjs +4 -4
- package/esm2022/pipes/currency/module.mjs +5 -5
- package/esm2022/pipes/currency/price.pipe.mjs +4 -4
- package/esm2022/pipes/filter/filter.pipe.mjs +4 -4
- package/esm2022/pipes/filter/module.mjs +5 -5
- package/esm2022/pipes/format/mask.pipe.mjs +4 -4
- package/esm2022/pipes/format/module.mjs +5 -5
- 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/date-time.mjs.map +1 -1
- package/fesm2022/decorator.mjs.map +1 -1
- package/fesm2022/form.mjs.map +1 -1
- package/fesm2022/format.mjs +3 -3
- package/fesm2022/format.mjs.map +1 -1
- package/fesm2022/math.mjs.map +1 -1
- 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/fesm2022/token.mjs.map +1 -1
- package/package.json +18 -18
@@ -13,11 +13,11 @@ export class CurrencyCNYPipe {
|
|
13
13
|
transform(value, options) {
|
14
14
|
return this.srv.cny(value, options);
|
15
15
|
}
|
16
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
17
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.2.
|
16
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CurrencyCNYPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
17
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.2.11", ngImport: i0, type: CurrencyCNYPipe, isStandalone: true, name: "cny" }); }
|
18
18
|
}
|
19
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
19
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CurrencyCNYPipe, decorators: [{
|
20
20
|
type: Pipe,
|
21
21
|
args: [{ name: 'cny', standalone: true }]
|
22
22
|
}] });
|
23
|
-
//# sourceMappingURL=data:application/json;base64,
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY255LnBpcGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy91dGlsL3BpcGVzL2N1cnJlbmN5L2NueS5waXBlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxJQUFJLEVBQWlCLE1BQU0sRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUU1RCxPQUFPLEVBQXNCLGVBQWUsRUFBRSxNQUFNLG9CQUFvQixDQUFDOztBQUV6RTs7OztHQUlHO0FBRUgsTUFBTSxPQUFPLGVBQWU7SUFENUI7UUFFbUIsUUFBRyxHQUFHLE1BQU0sQ0FBQyxlQUFlL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16
16
|
return res.value + (this.isCN ? res.unitI18n : res.unit);
|
17
17
|
}
|
18
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
19
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.2.
|
18
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CurrencyMegaPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
19
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.2.11", ngImport: i0, type: CurrencyMegaPipe, isStandalone: true, name: "mega" }); }
|
20
20
|
}
|
21
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
21
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CurrencyMegaPipe, decorators: [{
|
22
22
|
type: Pipe,
|
23
23
|
args: [{ name: 'mega', standalone: true }]
|
24
24
|
}] });
|
25
|
-
//# sourceMappingURL=data:application/json;base64,
|
25
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVnYS5waXBlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvdXRpbC9waXBlcy9jdXJyZW5jeS9tZWdhLnBpcGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFNBQVMsRUFBRSxJQUFJLEVBQWlCLE1BQU0sRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUV2RSxPQUFPLEVBQXVCLGVBQWUsRUFBRSxNQUFNLG9CQUFvQixDQUFDOztBQUUxRTs7OztHQUlHO0FBRUgsTUFBTSxPQUFPLGdCQUFnQjtJQUQ3QjtRQUVtQixRQUFHLEdBQUcsTUFBTS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dmF0ZSByZWFkb25seSBzcnYgPSBpbmplY3QoQ3VycmVuY3lTZXJ2aWNlKTtcbiAgcHJpdmF0ZSBpc0NOID0gaW5qZWN0KExPQ0FMRV9JRCkuc3RhcnRzV2l0aCgnemgnKTtcblxuICB0cmFuc2Zvcm0odmFsdWU6IG51bWJlciB8IHN0cmluZywgb3B0aW9ucz86IEN1cnJlbmN5TWVnYU9wdGlvbnMpOiBzdHJpbmcge1xuICAgIGNvbnN0IHJlcyA9IHRoaXMuc3J2Lm1lZ2EodmFsdWUsIG9wdGlvbnMpO1xuICAgIHJldHVybiByZXMudmFsdWUgKyAodGhpcy5pc0NOID8gcmVzLnVuaXRJMThuIDogcmVzLnVuaXQpO1xuICB9XG59XG4iXX0=
|
@@ -5,15 +5,15 @@ import { CurrencyPricePipe } from './price.pipe';
|
|
5
5
|
import * as i0 from "@angular/core";
|
6
6
|
const PIPES = [CurrencyMegaPipe, CurrencyPricePipe, CurrencyCNYPipe];
|
7
7
|
export class CurrencyPipeModule {
|
8
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
9
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.
|
10
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.
|
8
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CurrencyPipeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
9
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.11", ngImport: i0, type: CurrencyPipeModule, imports: [CurrencyMegaPipe, CurrencyPricePipe, CurrencyCNYPipe], exports: [CurrencyMegaPipe, CurrencyPricePipe, CurrencyCNYPipe] }); }
|
10
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CurrencyPipeModule }); }
|
11
11
|
}
|
12
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
12
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CurrencyPipeModule, decorators: [{
|
13
13
|
type: NgModule,
|
14
14
|
args: [{
|
15
15
|
imports: PIPES,
|
16
16
|
exports: PIPES
|
17
17
|
}]
|
18
18
|
}] });
|
19
|
-
//# sourceMappingURL=data:application/json;base64,
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvdXRpbC9waXBlcy9jdXJyZW5jeS9tb2R1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUV6QyxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sWUFBWSxDQUFDO0FBQzdDLE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUMvQyxPQUFPLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSxjQUFjLENBQUM7O0FBRWpELE1BQU0sS0FBSyxHQUFHLENBQUMsZ0JBQWdCLEVBQUUsaUJBQWlCLEVBQUUsZUFBZSxDQUFDLENBQUM7QUFNckUsTUFBTSxPQUFPLGtCQUFrQjsrR0FBbEIsa0JBQWtCO2dIQUFsQixrQkFBa0IsWUFOaEIsZ0JBQWdCLEVBQUUsaUJBQWlCLEVBQUUsZUFBZSxhQUFwRCxnQkFBZ0IsRUFBRSxpQkFBaUIsRUFBRSxlQUFlO2dIQU10RCxrQkFBa0I7OzRGQUFsQixrQkFBa0I7a0JBSjlCLFFBQVE7bUJBQUM7b0JBQ1IsT0FBTyxFQUFFLEtBQUs7b0JBQ2QsT0FBTyxFQUFFLEtBQUs7aUJBQ2YiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBOZ01vZHVsZSB9IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xuXG5pbXBvcnQgeyBDdXJyZW5jeUNOWVBpcGUgfSBmcm9tICcuL2NueS5waXBlJztcbmltcG9ydCB7IEN1cnJlbmN5TWVnYVBpcGUgfSBmcm9tICcuL21lZ2EucGlwZSc7XG5pbXBvcnQgeyBDdXJyZW5jeVByaWNlUGlwZSB9IGZyb20gJy4vcHJpY2UucGlwZSc7XG5cbmNvbnN0IFBJUEVTID0gW0N1cnJlbmN5TWVnYVBpcGUsIEN1cnJlbmN5UHJpY2VQaXBlLCBDdXJyZW5jeUNOWVBpcGVdO1xuXG5ATmdNb2R1bGUoe1xuICBpbXBvcnRzOiBQSVBFUyxcbiAgZXhwb3J0czogUElQRVNcbn0pXG5leHBvcnQgY2xhc3MgQ3VycmVuY3lQaXBlTW9kdWxlIHt9XG4iXX0=
|
@@ -17,11 +17,11 @@ export class CurrencyPricePipe {
|
|
17
17
|
transform(value, options) {
|
18
18
|
return this.srv.format(value, options);
|
19
19
|
}
|
20
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
21
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.2.
|
20
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CurrencyPricePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
21
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.2.11", ngImport: i0, type: CurrencyPricePipe, isStandalone: true, name: "price" }); }
|
22
22
|
}
|
23
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
23
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CurrencyPricePipe, decorators: [{
|
24
24
|
type: Pipe,
|
25
25
|
args: [{ name: 'price', standalone: true }]
|
26
26
|
}] });
|
27
|
-
//# sourceMappingURL=data:application/json;base64,
|
27
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpY2UucGlwZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL3V0aWwvcGlwZXMvY3VycmVuY3kvcHJpY2UucGlwZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsSUFBSSxFQUFpQixNQUFNLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFFNUQsT0FBTyxFQUF5QixlQUFlLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQzs7QUFFNUU7Ozs7Ozs7O0dBUUc7QUFFSCxNQUFNLE9BQU8saUJBQWlCO0lBRDlCO1FBRW1CLFFBQUcsR0FBRyxNQUFNLENBQUMsZUFBZSxDQUFDLENBQUM7S0FLaEQ7SUFIQyxTQUFTLENBQUMsS0FBc0IsRUFBRSxPQUErQjtRQUMvRCxPQUFPLElBQUksQ0FBQyxHQUFHLENBQUMsTUFBTSxDQUFDLEtBQUssRUFBRSxPQUFPLENBQUMsQ0FBQztJQUN6QyxDQUFDOytHQUxVLGlCQUFpQjs2R0FBakIsaUJBQWlCOzs0RkFBakIsaUJBQWlCO2tCQUQ3QixJQUFJO21CQUFDLEVBQUUsSUFBSSxFQUFFLE9BQU8sRUFBRSxVQUFVLEVBQUUsSUFBSSxFQUFFIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgUGlwZSwgUGlwZVRyYW5zZm9ybSwgaW5qZWN0IH0gZnJvbSAnQGFuZ3VsYXIvY29yZSc7XG5cbmltcG9ydCB7IEN1cnJlbmN5Rm9ybWF0T3B0aW9ucywgQ3VycmVuY3lTZXJ2aWNlIH0gZnJvbSAnQHllbG9uL3V0aWwvZm9ybWF0JztcblxuLyoqXG4gKiBGb3JtYXQgYSBudW1iZXIgd2l0aCBjb21tYXMgYXMgdGhvdXNhbmRzIHNlcGFyYXRvcnNcbiAqXG4gKiDmoLzlvI/ljJbotKfluIHvvIznlKjpgJflj7flsIbmlbDlrZfmoLzlvI/ljJbkuLrljYPkvY3liIbpmpTnrKZcbiAqIGBgYHRzXG4gKiAxMDAwMCA9PiBgMTAsMDAwYFxuICogMTAwMDAuNTY3ID0+IGAxMCwwMDAuNTdgXG4gKiBgYGBcbiAqL1xuQFBpcGUoeyBuYW1lOiAncHJpY2UnLCBzdGFuZGFsb25lOiB0cnVlIH0pXG5leHBvcnQgY2xhc3MgQ3VycmVuY3lQcmljZVBpcGUgaW1wbGVtZW50cyBQaXBlVHJhbnNmb3JtIHtcbiAgcHJpdmF0ZSByZWFkb25seSBzcnYgPSBpbmplY3QoQ3VycmVuY3lTZXJ2aWNlKTtcblxuICB0cmFuc2Zvcm0odmFsdWU6IG51bWJlciB8IHN0cmluZywgb3B0aW9ucz86IEN1cnJlbmN5Rm9ybWF0T3B0aW9ucyk6IHN0cmluZyB7XG4gICAgcmV0dXJuIHRoaXMuc3J2LmZvcm1hdCh2YWx1ZSwgb3B0aW9ucyk7XG4gIH1cbn1cbiJdfQ==
|
@@ -10,11 +10,11 @@ export class FilterPipe {
|
|
10
10
|
transform(array, matcher, ...args) {
|
11
11
|
return array.filter(i => matcher(i, ...args));
|
12
12
|
}
|
13
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
14
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.2.
|
13
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: FilterPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
14
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.2.11", ngImport: i0, type: FilterPipe, isStandalone: true, name: "filter", pure: false }); }
|
15
15
|
}
|
16
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
16
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: FilterPipe, decorators: [{
|
17
17
|
type: Pipe,
|
18
18
|
args: [{ name: 'filter', standalone: true, pure: false }]
|
19
19
|
}] });
|
20
|
-
//# sourceMappingURL=data:application/json;base64,
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlsdGVyLnBpcGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy91dGlsL3BpcGVzL2ZpbHRlci9maWx0ZXIucGlwZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsSUFBSSxFQUFpQixNQUFNLGVBQWUsQ0FBQzs7QUFJcEQ7Ozs7R0FJRztBQUNILDBEQUEwRDtBQUUxRCxNQUFNLE9BQU8sVUFBVTtJQUNyQixTQUFTLENBQUksS0FBbUIsRUFBRSxPQUFtRCxFQUFFLEdBQUcsSUFBaUI7UUFDekcsT0FBTyxLQUFLLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsT0FBTyxDQUFDLENBQUMsRUFBRSxHQUFHLElBQUksQ0FBQyxDQUFDLENBQUM7SUFDaEQsQ0FBQzsrR0FIVSxVQUFVOzZHQUFWLFVBQVU7OzRGQUFWLFVBQVU7a0JBRHRCLElBQUk7bUJBQUMsRUFBRSxJQUFJLEVBQUUsUUFBUSxFQUFFLFVBQVUsRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLEtBQUssRUFBRSIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IFBpcGUsIFBpcGVUcmFuc2Zvcm0gfSBmcm9tICdAYW5ndWxhci9jb3JlJztcblxuaW1wb3J0IHR5cGUgeyBOelNhZmVBbnkgfSBmcm9tICduZy16b3Jyby1hbnRkL2NvcmUvdHlwZXMnO1xuXG4vKipcbiAqIEZpbHRlciBhcnJheVxuICpcbiAqIOi/h+a7pOaVsOe7hFxuICovXG4vLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgQGFuZ3VsYXItZXNsaW50L25vLXBpcGUtaW1wdXJlXG5AUGlwZSh7IG5hbWU6ICdmaWx0ZXInLCBzdGFuZGFsb25lOiB0cnVlLCBwdXJlOiBmYWxzZSB9KVxuZXhwb3J0IGNsYXNzIEZpbHRlclBpcGUgaW1wbGVtZW50cyBQaXBlVHJhbnNmb3JtIHtcbiAgdHJhbnNmb3JtPFQ+KGFycmF5OiByZWFkb25seSBUW10sIG1hdGNoZXI6IChpdGVtOiBULCAuLi5hcmdzOiBOelNhZmVBbnlbXSkgPT4gYm9vbGVhbiwgLi4uYXJnczogTnpTYWZlQW55W10pOiBUW10ge1xuICAgIHJldHVybiBhcnJheS5maWx0ZXIoaSA9PiBtYXRjaGVyKGksIC4uLmFyZ3MpKTtcbiAgfVxufVxuIl19
|
@@ -3,15 +3,15 @@ import { FilterPipe } from './filter.pipe';
|
|
3
3
|
import * as i0 from "@angular/core";
|
4
4
|
const PIPES = [FilterPipe];
|
5
5
|
export class FilterPipeModule {
|
6
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
7
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.
|
8
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.
|
6
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: FilterPipeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
7
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.11", ngImport: i0, type: FilterPipeModule, imports: [FilterPipe], exports: [FilterPipe] }); }
|
8
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: FilterPipeModule }); }
|
9
9
|
}
|
10
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
10
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: FilterPipeModule, decorators: [{
|
11
11
|
type: NgModule,
|
12
12
|
args: [{
|
13
13
|
imports: PIPES,
|
14
14
|
exports: PIPES
|
15
15
|
}]
|
16
16
|
}] });
|
17
|
-
//# sourceMappingURL=data:application/json;base64,
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvdXRpbC9waXBlcy9maWx0ZXIvbW9kdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFFekMsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLGVBQWUsQ0FBQzs7QUFFM0MsTUFBTSxLQUFLLEdBQUcsQ0FBQyxVQUFVLENBQUMsQ0FBQztBQU0zQixNQUFNLE9BQU8sZ0JBQWdCOytHQUFoQixnQkFBZ0I7Z0hBQWhCLGdCQUFnQixZQU5kLFVBQVUsYUFBVixVQUFVO2dIQU1aLGdCQUFnQjs7NEZBQWhCLGdCQUFnQjtrQkFKNUIsUUFBUTttQkFBQztvQkFDUixPQUFPLEVBQUUsS0FBSztvQkFDZCxPQUFPLEVBQUUsS0FBSztpQkFDZiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IE5nTW9kdWxlIH0gZnJvbSAnQGFuZ3VsYXIvY29yZSc7XG5cbmltcG9ydCB7IEZpbHRlclBpcGUgfSBmcm9tICcuL2ZpbHRlci5waXBlJztcblxuY29uc3QgUElQRVMgPSBbRmlsdGVyUGlwZV07XG5cbkBOZ01vZHVsZSh7XG4gIGltcG9ydHM6IFBJUEVTLFxuICBleHBvcnRzOiBQSVBFU1xufSlcbmV4cG9ydCBjbGFzcyBGaWx0ZXJQaXBlTW9kdWxlIHt9XG4iXX0=
|
@@ -24,11 +24,11 @@ export 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: "18.2.
|
28
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.2.
|
27
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: FormatMaskPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
28
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.2.11", ngImport: i0, type: FormatMaskPipe, isStandalone: true, name: "mask" }); }
|
29
29
|
}
|
30
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
30
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: FormatMaskPipe, decorators: [{
|
31
31
|
type: Pipe,
|
32
32
|
args: [{ name: 'mask', standalone: true }]
|
33
33
|
}] });
|
34
|
-
//# sourceMappingURL=data:application/json;base64,
|
34
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFzay5waXBlLmpzIiwic291cmNlUm9vdCI6IiIsIn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g6L2s5o2i5aSn5YaZIHxcbiAqIHwgYExgIHwg6L2s5o2i5bCP5YaZIHxcbiAqIHwgYCpgIHwg6L2s5o2i5Li6IGAqYCDlrZfnrKYgfFxuICpcbiAqIGBgYHRzXG4gKiBmb3JtYXRNYXNrKCcxMjMnLCAnKCMjIyknKSA9PiAoMTIzKVxuICogZm9ybWF0TWFzaygnMTU5MDAwMDAwMDAnLCAnOTk5KioqKjk5OTknKSA9PiAxNTkqKioqMDAwMFxuICogYGBgXG4gKi9cbkBQaXBlKHsgbmFtZTogJ21hc2snLCBzdGFuZGFsb25lOiB0cnVlIH0pXG5leHBvcnQgY2xhc3MgRm9ybWF0TWFza1BpcGUgaW1wbGVtZW50cyBQaXBlVHJhbnNmb3JtIHtcbiAgdHJhbnNmb3JtKHZhbHVlOiBzdHJpbmcsIG1hc2s6IHN0cmluZyB8IEZvcm1hdE1hc2tPcHRpb24pOiBzdHJpbmcge1xuICAgIHJldHVybiBmb3JtYXRNYXNrKHZhbHVlLCBtYXNrKTtcbiAgfVxufVxuIl19
|
@@ -3,15 +3,15 @@ import { FormatMaskPipe } from './mask.pipe';
|
|
3
3
|
import * as i0 from "@angular/core";
|
4
4
|
const PIPES = [FormatMaskPipe];
|
5
5
|
export class FormatPipeModule {
|
6
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
7
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.
|
8
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.
|
6
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: FormatPipeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
7
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.11", ngImport: i0, type: FormatPipeModule, imports: [FormatMaskPipe], exports: [FormatMaskPipe] }); }
|
8
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: FormatPipeModule }); }
|
9
9
|
}
|
10
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
10
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: FormatPipeModule, decorators: [{
|
11
11
|
type: NgModule,
|
12
12
|
args: [{
|
13
13
|
imports: PIPES,
|
14
14
|
exports: PIPES
|
15
15
|
}]
|
16
16
|
}] });
|
17
|
-
//# sourceMappingURL=data:application/json;base64,
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvdXRpbC9waXBlcy9mb3JtYXQvbW9kdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFFekMsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLGFBQWEsQ0FBQzs7QUFFN0MsTUFBTSxLQUFLLEdBQUcsQ0FBQyxjQUFjLENBQUMsQ0FBQztBQU0vQixNQUFNLE9BQU8sZ0JBQWdCOytHQUFoQixnQkFBZ0I7Z0hBQWhCLGdCQUFnQixZQU5kLGNBQWMsYUFBZCxjQUFjO2dIQU1oQixnQkFBZ0I7OzRGQUFoQixnQkFBZ0I7a0JBSjVCLFFBQVE7bUJBQUM7b0JBQ1IsT0FBTyxFQUFFLEtBQUs7b0JBQ2QsT0FBTyxFQUFFLEtBQUs7aUJBQ2YiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBOZ01vZHVsZSB9IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xuXG5pbXBvcnQgeyBGb3JtYXRNYXNrUGlwZSB9IGZyb20gJy4vbWFzay5waXBlJztcblxuY29uc3QgUElQRVMgPSBbRm9ybWF0TWFza1BpcGVdO1xuXG5ATmdNb2R1bGUoe1xuICBpbXBvcnRzOiBQSVBFUyxcbiAgZXhwb3J0czogUElQRVNcbn0pXG5leHBvcnQgY2xhc3MgRm9ybWF0UGlwZU1vZHVsZSB7fVxuIl19
|
package/fesm2022/array.mjs
CHANGED
@@ -269,10 +269,10 @@ class ArrayService {
|
|
269
269
|
}, new Map())
|
270
270
|
.values());
|
271
271
|
}
|
272
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
273
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.
|
272
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ArrayService, deps: [{ token: i1.YunzaiConfigService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
273
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ArrayService, providedIn: 'root' }); }
|
274
274
|
}
|
275
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
275
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ArrayService, decorators: [{
|
276
276
|
type: Injectable,
|
277
277
|
args: [{ providedIn: 'root' }]
|
278
278
|
}], ctorParameters: () => [{ 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":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { 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;MAea,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,IAAI,EAAE;AACpB,gBAAA,CAAC,CAAC,GAAG,CAAC,WAAY,CAAC,GAAG,IAAI,CAAC;AAC3B,gBAAA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E,UAAU,EAAE,MAAM,EAAE,CAAA;;;ACdlC;;AAEG;;;;"}
|
1
|
+
{"version":3,"file":"array.mjs","sources":["../../../../packages/util/array/array.service.ts","../../../../packages/util/array/array.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { 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;MAea,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;AAClB,SAAA,CAAE;;AAGL;;;;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;SAC4B;QACjC,MAAM,MAAM,GAAkC,EAAE;QAChD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C,GAAG,EAAE,KAAK,KAAI;YACrB,MAAM,GAAG,GAAG;AACV,kBAAE,OAAO,SAAS,KAAK;AACrB,sBAAG,KAAa,CAAC,SAAS;AAC1B,sBAAE,SAAU,CAAC,KAAK;kBAClB,KAAK;YACT,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;AACjB,gBAAA,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC;;AAErB,YAAA,OAAO,GAAG;AACZ,SAAC,EAAE,IAAI,GAAG,EAAgC;aACzC,MAAM,EAAE,CACZ;;+GAhSQ,YAAY,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,mBAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAZ,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,cADC,MAAM,EAAA,CAAA,CAAA;;4FACnB,YAAY,EAAA,UAAA,EAAA,CAAA;kBADxB,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACdlC;;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: "18.2.
|
95
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.
|
94
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CookieService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
95
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CookieService, providedIn: 'root' }); }
|
96
96
|
}
|
97
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
97
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CookieService, decorators: [{
|
98
98
|
type: Injectable,
|
99
99
|
args: [{ providedIn: 'root' }]
|
100
100
|
}] });
|
@@ -219,10 +219,10 @@ class ScrollService {
|
|
219
219
|
}
|
220
220
|
this.scrollToElement(this._getDoc().body, topOffset);
|
221
221
|
}
|
222
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
223
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.
|
222
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ScrollService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
223
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ScrollService, providedIn: 'root' }); }
|
224
224
|
}
|
225
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
225
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ScrollService, decorators: [{
|
226
226
|
type: Injectable,
|
227
227
|
args: [{ providedIn: 'root' }]
|
228
228
|
}] });
|
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 { Injectable, inject } 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 readonly _doc = inject(DOCUMENT);\n private readonly platform = inject(Platform);\n\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 /**\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 />` is empty, useful for custom components.\n *\n * 用于校验 `<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 { Injectable, inject } from '@angular/core';\n\n@Injectable({ providedIn: 'root' })\nexport class ScrollService {\n private readonly _doc = inject(DOCUMENT);\n private readonly platform = inject(Platform);\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 /**\n * 获取滚动条位置\n *\n * @param element 指定元素,默认 `window`\n */\n getScrollPosition(element?: Element | Window | null): [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;AAD1B,IAAA,WAAA,GAAA;AAEmB,QAAA,IAAA,CAAA,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AACxB,QAAA,IAAA,CAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAwF9C,KAAA;AAtFC,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;AAED;;;;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,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACnC,YAAA,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YACtB,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAClC,YAAA,IAAI,KAAK,GAAG,CAAC,EAAE;AACb,gBAAA,MAAM,IAAI,GAAG,kBAAkB,CAAC,MAAM,CAAC,SAAS,C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a,EAAA,UAAA,EAAA,CAAA;kBADzB,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;;;ACFlC,SAAS,WAAW,CAAC,EAAe,EAAE,QAAsC,EAAE,QAAmB,EAAA;IAC/F,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,QAAQ,CAAC,WAAW,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,QAAQ,CAAC,EAAe,EAAE,QAAsC,EAAE,QAAmB,EAAA;AAC5F,IAAA,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE;AACxB,QAAA,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE;AACf,YAAA,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;SAC1B;KACF;AACH,CAAC;AAED;;;;;;;;;;;;;;;;AAgBG;AACG,SAAU,eAAe,CAC7B,EAAe,EACf,QAAmB,EACnB,QAAsC,EACtC,QAAA,GAAoB,KAAK,EAAA;AAEzB,IAAA,IAAI,QAAQ,KAAK,IAAI,EAAE;AACrB,QAAA,QAAQ,CAAC,eAAe,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;KACvC;SAAM;AACL,QAAA,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;KACrC;AACD,IAAA,QAAQ,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;AAC3B,IAAA,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACnC;;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 { Injectable, inject } 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 readonly _doc = inject(DOCUMENT);\n private readonly platform = inject(Platform);\n\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 /**\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 />` is empty, useful for custom components.\n *\n * 用于校验 `<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 { Injectable, inject } from '@angular/core';\n\n@Injectable({ providedIn: 'root' })\nexport class ScrollService {\n private readonly _doc = inject(DOCUMENT);\n private readonly platform = inject(Platform);\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 /**\n * 获取滚动条位置\n *\n * @param element 指定元素,默认 `window`\n */\n getScrollPosition(element?: Element | Window | null): [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;AAD1B,IAAA,WAAA,GAAA;AAEmB,QAAA,IAAA,CAAA,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC;AACvB,QAAA,IAAA,CAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AAwF7C;AAtFC,IAAA,IAAY,GAAG,GAAA;AACb,QAAA,OAAO,IAAI,CAAC,IAAI,IAAI,QAAQ;;AAG9B;;;;AAIG;AACH,IAAA,IAAI,MAAM,GAAA;AACR,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,EAAE;;AAGvD;;;;AAIG;IACH,MAAM,GAAA;QACJ,MAAM,GAAG,GAA8B,EAAE;QACzC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;AACnC,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACnC,YAAA,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC;YACrB,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;AACjC,YAAA,IAAI,KAAK,GAAG,CAAC,EAAE;AACb,gBAAA,MAAM,IAAI,GAAG,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAC3D,gBAAA,IAAI,GAAG,CAAC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;;;;;;;;;;;;;AAgBG;AACG,SAAU,eAAe,CAC7B,EAAe,EACf,QAAmB,EACnB,QAAsC,EACtC,QAAA,GAAoB,KAAK,EAAA;AAEzB,IAAA,IAAI,QAAQ,KAAK,IAAI,EAAE;AACrB,QAAA,QAAQ,CAAC,eAAe,CAAC,EAAE,EAAE,OAAO,CAAC;;SAChC;AACL,QAAA,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC;;AAErC,IAAA,QAAQ,GAAG,EAAE,GAAG,QAAQ,EAAE;AAC1B,IAAA,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC;AAClC;;AC5CA;;AAEG;;;;"}
|
package/fesm2022/config.mjs
CHANGED
@@ -37,10 +37,10 @@ class YunzaiConfigService {
|
|
37
37
|
set(componentName, value) {
|
38
38
|
this.config[componentName] = { ...this.config[componentName], ...value };
|
39
39
|
}
|
40
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
41
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.
|
40
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: YunzaiConfigService, deps: [{ token: YUNZAI_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
41
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: YunzaiConfigService, providedIn: 'root' }); }
|
42
42
|
}
|
43
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
43
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: YunzaiConfigService, decorators: [{
|
44
44
|
type: Injectable,
|
45
45
|
args: [{ providedIn: 'root' }]
|
46
46
|
}], ctorParameters: () => [{ 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 { EnvironmentProviders, InjectionToken, makeEnvironmentProviders } from '@angular/core';\n\nimport {\n YunzaiCellConfig,\n YunzaiDateRangePickerConfig,\n YunzaiErrorCollectConfig,\n YunzaiExceptionType,\n YunzaiImageConfig,\n YunzaiLoadingConfig,\n YunzaiLodopConfig,\n YunzaiMediaConfig,\n YunzaiOnboardingConfig,\n YunzaiPageHeaderConfig,\n YunzaiPdfConfig,\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 { YunzaiThemePipeConfig } from './theme/pipe.type';\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 se?: YunzaiSEConfig;\n sg?: YunzaiSGConfig;\n sv?: YunzaiSVConfig;\n st?: YunzaiSTConfig;\n sf?: YunzaiSFConfig;\n cell?: YunzaiCellConfig;\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 themePipe?: YunzaiThemePipeConfig;\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\nexport function provideYunzaiConfig(config: YunzaiConfig): EnvironmentProviders {\n return makeEnvironmentProviders([{ provide: YUNZAI_CONFIG, useValue: config }]);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { 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;;MCyDY,aAAa,GAAG,IAAI,cAAc,CAAe,eAAe,EAAE;AAC7E,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE
|
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 { EnvironmentProviders, InjectionToken, makeEnvironmentProviders } from '@angular/core';\n\nimport {\n YunzaiCellConfig,\n YunzaiDateRangePickerConfig,\n YunzaiErrorCollectConfig,\n YunzaiExceptionType,\n YunzaiImageConfig,\n YunzaiLoadingConfig,\n YunzaiLodopConfig,\n YunzaiMediaConfig,\n YunzaiOnboardingConfig,\n YunzaiPageHeaderConfig,\n YunzaiPdfConfig,\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 { YunzaiThemePipeConfig } from './theme/pipe.type';\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 se?: YunzaiSEConfig;\n sg?: YunzaiSGConfig;\n sv?: YunzaiSVConfig;\n st?: YunzaiSTConfig;\n sf?: YunzaiSFConfig;\n cell?: YunzaiCellConfig;\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 themePipe?: YunzaiThemePipeConfig;\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\nexport function provideYunzaiConfig(config: YunzaiConfig): EnvironmentProviders {\n return makeEnvironmentProviders([{ provide: YUNZAI_CONFIG, useValue: config }]);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { 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;;MCyDY,aAAa,GAAG,IAAI,cAAc,CAAe,eAAe,EAAE;AAC7E,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE;AACV,CAAA;SAEe,qBAAqB,GAAA;AACnC,IAAA,OAAO,EAAE;AACX;AAEM,SAAU,mBAAmB,CAAC,MAAoB,EAAA;AACtD,IAAA,OAAO,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;AACjF;;ACjFA;MASa,mBAAmB,CAAA;AAG9B,IAAA,WAAA,CAA+C,aAA4B,EAAA;AACzE,QAAA,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,aAAa,EAAE;;IAGpC,GAAG,CAA4B,aAAgB,EAAE,GAAY,EAAA;AAC3D,QAAA,MAAM,GAAG,IAAK,IAAI,CAAC,MAAM,CAAC,aAAa,CAAgC,IAAI,EAAE,CAAc;AAC3F,QAAA,OAAO,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG;;AAGxC,IAAA,KAAK,CAA4B,aAAgB,EAAE,GAAG,aAAqC,EAAA;AACzF,QAAA,OAAO,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,aA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date-time/time.ts","../../../../packages/util/date-time/picker.ts","../../../../packages/util/date-time/date-time.ts"],"sourcesContent":["import {\n addDays,\n endOfDay,\n endOfMonth,\n endOfWeek,\n endOfYear,\n parse,\n parseISO,\n startOfDay,\n startOfMonth,\n startOfWeek,\n startOfYear,\n subMonths,\n subWeeks,\n subYears,\n format,\n formatDistanceToNow\n} from 'date-fns';\n\nimport type { YunzaiThemePipeDateFormatCustom } from '@yelon/util/config';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\nimport { DateLocale } from 'ng-zorro-antd/i18n';\n\n/**\n * Get the time range, return `[ Date, Date]` for the start and end dates\n *\n * 获取时间范围\n *\n * @param type 类型,带 `-` 表示过去一个时间,若指定 `number` 表示天数\n * @param time 开始时间\n * @param ignoreMaxTime 忽略追加结束日期的最大时间值\n */\nexport function getTimeDistance(\n type: 'today' | '-today' | 'yesterday' | 'week' | '-week' | 'month' | '-month' | 'year' | '-year' | number,\n time?: Date | string | number,\n options?: { ignoreMaxTime?: boolean }\n): [Date, Date] {\n time = time\n ? typeof time === 'string'\n ? parse(time, 'yyyy-MM-dd HH:mm:ss', new Date())\n : new Date(time)\n : new Date();\n const opt: { weekStartsOn: 1 } = { weekStartsOn: 1 };\n\n let res: [Date, Date];\n switch (type) {\n case 'today':\n res = [time, time];\n break;\n case '-today':\n res = [addDays(time, -1), time];\n break;\n case 'yesterday':\n res = [addDays(time, -1), addDays(time, -1)];\n break;\n case 'week':\n res = [startOfWeek(time, opt), endOfWeek(time, opt)];\n break;\n case '-week':\n res = [startOfWeek(subWeeks(time, 1), opt), endOfWeek(subWeeks(time, 1), opt)];\n break;\n case 'month':\n res = [startOfMonth(time), endOfMonth(time)];\n break;\n case '-month':\n res = [startOfMonth(subMonths(time, 1)), endOfMonth(subMonths(time, 1))];\n break;\n case 'year':\n res = [startOfYear(time), endOfYear(time)];\n break;\n case '-year':\n res = [startOfYear(subYears(time, 1)), endOfYear(subYears(time, 1))];\n break;\n default:\n res = type > 0 ? [time, addDays(time, type)] : [addDays(time, type), time];\n break;\n }\n return options?.ignoreMaxTime ? res : fixEndTimeOfRange(res);\n}\n\n/**\n * fix time is the most, big value\n */\nexport function fixEndTimeOfRange(dates: [Date, Date]): [Date, Date] {\n return [startOfDay(dates[0]), endOfDay(dates[1])];\n}\n\nexport interface ToDateOptions {\n /** If parsing fails try to parse the date by pressing `formatString` */\n formatString?: string;\n /** If parsing fails returned default value, default: `new Date(NaN)` */\n defaultValue?: NzSafeAny;\n timestampSecond?: boolean;\n}\n\n/**\n * Convert to `Date` format\n *\n * @param value When is a number, it's treated as a timestamp; If it's seconds, you need to provide the `options.timestampSecond` parameter.\n */\nexport function toDate(value?: Date | string | number | null, options?: string | ToDateOptions): Date {\n const { formatString, defaultValue, timestampSecond } = {\n formatString: 'yyyy-MM-dd HH:mm:ss',\n defaultValue: new Date(NaN),\n timestampSecond: false,\n ...(typeof options === 'string' ? { formatString: options } : options)\n };\n if (value == null) {\n return defaultValue;\n }\n if (value instanceof Date) {\n return value;\n }\n if (typeof value === 'number' || (typeof value === 'string' && /^[0-9]+$/.test(value))) {\n const valueNumber = +value;\n return new Date(timestampSecond ? valueNumber * 1000 : valueNumber);\n }\n let tryDate = parseISO(value);\n if (isNaN(tryDate as NzSafeAny)) {\n tryDate = parse(value, formatString!, new Date());\n }\n\n return isNaN(tryDate as NzSafeAny) ? defaultValue : tryDate;\n}\n\n/**\n * Format date, supports `Date, number, string` types\n *\n * @param value When is a number, it is treated as a timestamp (Support seconds and milliseconds timestamp).\n * @param formatString Please refer to [date-fnd format](https://date-fns.org/v2.30.0/docs/format) for string format\n * @param dateLocale Recommended to be consistent with NG-ZORRO by using `inject(NZ_DATE_LOCALE)`\n */\nexport function formatDate(\n value: Date | string | number,\n formatString: string,\n options?: { locale?: DateLocale; customFormat?: YunzaiThemePipeDateFormatCustom }\n): string {\n value = toDate(value);\n if (isNaN(value as NzSafeAny)) return '';\n\n const langOpt = { locale: options?.locale };\n return formatString === 'fn'\n ? formatDistanceToNow(value, langOpt)\n : (options?.customFormat ?? format)(value, formatString, langOpt);\n}\n","import { addDays, addSeconds, differenceInCalendarDays, format } from 'date-fns';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\nimport type { DisabledDateFn, DisabledTimeConfig, DisabledTimeFn } from 'ng-zorro-antd/date-picker';\n\n// TODO: timezone process\nexport class DateTimePickerUtil {\n /**\n * Current local time\n *\n * 当前本地时间\n */\n get now(): Date {\n return new Date();\n }\n /**\n * Current local date (not including time part)\n *\n * 当前本地日期(不包含时间部分)\n */\n get date(): Date {\n return this.removeTime(this.now);\n }\n /**\n * Remove the time part of the date\n *\n * 移除日期的时间部分\n */\n removeTime(d: Date): Date {\n return new Date(d.toDateString());\n }\n /**\n * Format date-time\n *\n * 格式化日期\n */\n format(d: number | Date, formatString: string = 'yyyy-MM-dd HH:mm:ss'): string {\n return format(d, formatString);\n }\n private genTick(count: number): number[] {\n return new Array(count).fill(0).map((_, idx) => idx);\n }\n /**\n * Calculate the number of days between two dates, `0` means the same day\n *\n * 计算两个日期相差天数,`0` 表示同一天\n */\n getDiffDays(dateLeft: Date | number, dateRight?: Date | number): number {\n return differenceInCalendarDays(\n dateLeft,\n typeof dateRight === 'number' ? addDays(this.date, dateRight) : dateRight || this.date\n );\n }\n /**\n * Disabled Before date (Default: today), Generally serves `nzDisabledDate`\n *\n * 禁用之前日期(默认:今天),一般服务于 `nzDisabledDate`\n */\n disabledBeforeDate(options?: { offsetDays?: Date | number }): DisabledDateFn {\n return (d): boolean => this.getDiffDays(d, options?.offsetDays) < 0;\n }\n /**\n * Disabled After date (Default: today), Generally serves `nzDisabledDate`\n *\n * 禁用之后日期(默认:今天),一般服务于 `nzDisabledDate`\n */\n disabledAfterDate(options?: { offsetDays?: Date | number }): DisabledDateFn {\n return (d): boolean => this.getDiffDays(d, options?.offsetDays) > 0;\n }\n private baseDisabledTime(type: 'before' | 'after', offsetSeconds?: number): DisabledTimeFn {\n const tick24 = this.genTick(24);\n const tick60 = this.genTick(60);\n return (current): DisabledTimeConfig => {\n const cur = current as Date;\n if (cur == null) {\n return {} as NzSafeAny;\n }\n const now = addSeconds(this.now, offsetSeconds || 0);\n const nowHours = now.getHours();\n const nowMinutes = now.getMinutes();\n const curHours = cur.getHours();\n const isToday = this.getDiffDays(this.removeTime(cur)) === 0;\n return {\n nzDisabledHours: () => {\n if (!isToday) return [];\n return type === 'before' ? tick24.slice(0, nowHours) : tick24.slice(nowHours + 1);\n },\n nzDisabledMinutes: () => {\n if (isToday && curHours === nowHours) {\n return type === 'before' ? tick60.slice(0, nowMinutes) : tick60.slice(nowMinutes + 1);\n }\n return [];\n },\n nzDisabledSeconds: () => {\n if (isToday && curHours === nowHours && cur.getMinutes() === nowMinutes) {\n const nowSeconds = now.getSeconds();\n return type === 'before' ? tick60.slice(0, nowSeconds) : tick60.slice(nowSeconds + 1);\n }\n return [];\n }\n };\n };\n }\n /**\n * Disabled Before time (Default: now), Generally serves `nzDisabledTime`\n *\n * 禁用之前时间(默认:现在),一般服务于 `nzDisabledTime`\n */\n disabledBeforeTime(options?: { offsetSeconds?: number }): DisabledTimeFn {\n return this.baseDisabledTime('before', options?.offsetSeconds);\n }\n /**\n * Disabled After time (Default: now), Generally serves `nzDisabledTime`\n *\n * 禁用之后时间(默认:现在),一般服务于 `nzDisabledTime`\n */\n disabledAfterTime(options?: { offsetSeconds?: number }): DisabledTimeFn {\n return this.baseDisabledTime('after', options?.offsetSeconds);\n }\n}\n\nexport const dateTimePickerUtil = new DateTimePickerUtil();\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAuBA;;;;;;;;AAQG;SACa,eAAe,CAC7B,IAA0G,EAC1G,IAA6B,EAC7B,OAAqC,EAAA;AAErC,IAAA,IAAI,GAAG,IAAI;AACT,UAAE,OAAO,IAAI,KAAK,QAAQ;cACtB,KAAK,CAAC,IAAI,EAAE,qBAAqB,EAAE,IAAI,IAAI,EAAE,CAAC;AAChD,cAAE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O,IAAI,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,UAAU,EAAE,KAAK,UAAU,EAAE;AACvE,wBAAA,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;wBACpC,OAAO,IAAI,KAAK,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;qBACvF;AACD,oBAAA,OAAO,EAAE,CAAC;iBACX;aACF,CAAC;AACJ,SAAC,CAAC;KACH;AACD;;;;AAIG;AACH,IAAA,kBAAkB,CAAC,OAAoC,EAAA;QACrD,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;KAChE;AACD;;;;AAIG;AACH,IAAA,iBAAiB,CAAC,OAAoC,EAAA;QACpD,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;KAC/D;AACF,CAAA;AAEY,MAAA,kBAAkB,GAAG,IAAI,kBAAkB;;ACzHxD;;AAEG;;;;"}
|
1
|
+
{"version":3,"file":"date-time.mjs","sources":["../../../../packages/util/date-time/time.ts","../../../../packages/util/date-time/picker.ts","../../../../packages/util/date-time/date-time.ts"],"sourcesContent":["import {\n addDays,\n endOfDay,\n endOfMonth,\n endOfWeek,\n endOfYear,\n parse,\n parseISO,\n startOfDay,\n startOfMonth,\n startOfWeek,\n startOfYear,\n subMonths,\n subWeeks,\n subYears,\n format,\n formatDistanceToNow\n} from 'date-fns';\n\nimport type { YunzaiThemePipeDateFormatCustom } from '@yelon/util/config';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\nimport { DateLocale } from 'ng-zorro-antd/i18n';\n\n/**\n * Get the time range, return `[ Date, Date]` for the start and end dates\n *\n * 获取时间范围\n *\n * @param type 类型,带 `-` 表示过去一个时间,若指定 `number` 表示天数\n * @param time 开始时间\n * @param ignoreMaxTime 忽略追加结束日期的最大时间值\n */\nexport function getTimeDistance(\n type: 'today' | '-today' | 'yesterday' | 'week' | '-week' | 'month' | '-month' | 'year' | '-year' | number,\n time?: Date | string | number,\n options?: { ignoreMaxTime?: boolean }\n): [Date, Date] {\n time = time\n ? typeof time === 'string'\n ? parse(time, 'yyyy-MM-dd HH:mm:ss', new Date())\n : new Date(time)\n : new Date();\n const opt: { weekStartsOn: 1 } = { weekStartsOn: 1 };\n\n let res: [Date, Date];\n switch (type) {\n case 'today':\n res = [time, time];\n break;\n case '-today':\n res = [addDays(time, -1), time];\n break;\n case 'yesterday':\n res = [addDays(time, -1), addDays(time, -1)];\n break;\n case 'week':\n res = [startOfWeek(time, opt), endOfWeek(time, opt)];\n break;\n case '-week':\n res = [startOfWeek(subWeeks(time, 1), opt), endOfWeek(subWeeks(time, 1), opt)];\n break;\n case 'month':\n res = [startOfMonth(time), endOfMonth(time)];\n break;\n case '-month':\n res = [startOfMonth(subMonths(time, 1)), endOfMonth(subMonths(time, 1))];\n break;\n case 'year':\n res = [startOfYear(time), endOfYear(time)];\n break;\n case '-year':\n res = [startOfYear(subYears(time, 1)), endOfYear(subYears(time, 1))];\n break;\n default:\n res = type > 0 ? [time, addDays(time, type)] : [addDays(time, type), time];\n break;\n }\n return options?.ignoreMaxTime ? res : fixEndTimeOfRange(res);\n}\n\n/**\n * fix time is the most, big value\n */\nexport function fixEndTimeOfRange(dates: [Date, Date]): [Date, Date] {\n return [startOfDay(dates[0]), endOfDay(dates[1])];\n}\n\nexport interface ToDateOptions {\n /** If parsing fails try to parse the date by pressing `formatString` */\n formatString?: string;\n /** If parsing fails returned default value, default: `new Date(NaN)` */\n defaultValue?: NzSafeAny;\n timestampSecond?: boolean;\n}\n\n/**\n * Convert to `Date` format\n *\n * @param value When is a number, it's treated as a timestamp; If it's seconds, you need to provide the `options.timestampSecond` parameter.\n */\nexport function toDate(value?: Date | string | number | null, options?: string | ToDateOptions): Date {\n const { formatString, defaultValue, timestampSecond } = {\n formatString: 'yyyy-MM-dd HH:mm:ss',\n defaultValue: new Date(NaN),\n timestampSecond: false,\n ...(typeof options === 'string' ? { formatString: options } : options)\n };\n if (value == null) {\n return defaultValue;\n }\n if (value instanceof Date) {\n return value;\n }\n if (typeof value === 'number' || (typeof value === 'string' && /^[0-9]+$/.test(value))) {\n const valueNumber = +value;\n return new Date(timestampSecond ? valueNumber * 1000 : valueNumber);\n }\n let tryDate = parseISO(value);\n if (isNaN(tryDate as NzSafeAny)) {\n tryDate = parse(value, formatString!, new Date());\n }\n\n return isNaN(tryDate as NzSafeAny) ? defaultValue : tryDate;\n}\n\n/**\n * Format date, supports `Date, number, string` types\n *\n * @param value When is a number, it is treated as a timestamp (Support seconds and milliseconds timestamp).\n * @param formatString Please refer to [date-fnd format](https://date-fns.org/v2.30.0/docs/format) for string format\n * @param dateLocale Recommended to be consistent with NG-ZORRO by using `inject(NZ_DATE_LOCALE)`\n */\nexport function formatDate(\n value: Date | string | number,\n formatString: string,\n options?: { locale?: DateLocale; customFormat?: YunzaiThemePipeDateFormatCustom }\n): string {\n value = toDate(value);\n if (isNaN(value as NzSafeAny)) return '';\n\n const langOpt = { locale: options?.locale };\n return formatString === 'fn'\n ? formatDistanceToNow(value, langOpt)\n : (options?.customFormat ?? format)(value, formatString, langOpt);\n}\n","import { addDays, addSeconds, differenceInCalendarDays, format } from 'date-fns';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\nimport type { DisabledDateFn, DisabledTimeConfig, DisabledTimeFn } from 'ng-zorro-antd/date-picker';\n\n// TODO: timezone process\nexport class DateTimePickerUtil {\n /**\n * Current local time\n *\n * 当前本地时间\n */\n get now(): Date {\n return new Date();\n }\n /**\n * Current local date (not including time part)\n *\n * 当前本地日期(不包含时间部分)\n */\n get date(): Date {\n return this.removeTime(this.now);\n }\n /**\n * Remove the time part of the date\n *\n * 移除日期的时间部分\n */\n removeTime(d: Date): Date {\n return new Date(d.toDateString());\n }\n /**\n * Format date-time\n *\n * 格式化日期\n */\n format(d: number | Date, formatString: string = 'yyyy-MM-dd HH:mm:ss'): string {\n return format(d, formatString);\n }\n private genTick(count: number): number[] {\n return new Array(count).fill(0).map((_, idx) => idx);\n }\n /**\n * Calculate the number of days between two dates, `0` means the same day\n *\n * 计算两个日期相差天数,`0` 表示同一天\n */\n getDiffDays(dateLeft: Date | number, dateRight?: Date | number): number {\n return differenceInCalendarDays(\n dateLeft,\n typeof dateRight === 'number' ? addDays(this.date, dateRight) : dateRight || this.date\n );\n }\n /**\n * Disabled Before date (Default: today), Generally serves `nzDisabledDate`\n *\n * 禁用之前日期(默认:今天),一般服务于 `nzDisabledDate`\n */\n disabledBeforeDate(options?: { offsetDays?: Date | number }): DisabledDateFn {\n return (d): boolean => this.getDiffDays(d, options?.offsetDays) < 0;\n }\n /**\n * Disabled After date (Default: today), Generally serves `nzDisabledDate`\n *\n * 禁用之后日期(默认:今天),一般服务于 `nzDisabledDate`\n */\n disabledAfterDate(options?: { offsetDays?: Date | number }): DisabledDateFn {\n return (d): boolean => this.getDiffDays(d, options?.offsetDays) > 0;\n }\n private baseDisabledTime(type: 'before' | 'after', offsetSeconds?: number): DisabledTimeFn {\n const tick24 = this.genTick(24);\n const tick60 = this.genTick(60);\n return (current): DisabledTimeConfig => {\n const cur = current as Date;\n if (cur == null) {\n return {} as NzSafeAny;\n }\n const now = addSeconds(this.now, offsetSeconds || 0);\n const nowHours = now.getHours();\n const nowMinutes = now.getMinutes();\n const curHours = cur.getHours();\n const isToday = this.getDiffDays(this.removeTime(cur)) === 0;\n return {\n nzDisabledHours: () => {\n if (!isToday) return [];\n return type === 'before' ? tick24.slice(0, nowHours) : tick24.slice(nowHours + 1);\n },\n nzDisabledMinutes: () => {\n if (isToday && curHours === nowHours) {\n return type === 'before' ? tick60.slice(0, nowMinutes) : tick60.slice(nowMinutes + 1);\n }\n return [];\n },\n nzDisabledSeconds: () => {\n if (isToday && curHours === nowHours && cur.getMinutes() === nowMinutes) {\n const nowSeconds = now.getSeconds();\n return type === 'before' ? tick60.slice(0, nowSeconds) : tick60.slice(nowSeconds + 1);\n }\n return [];\n }\n };\n };\n }\n /**\n * Disabled Before time (Default: now), Generally serves `nzDisabledTime`\n *\n * 禁用之前时间(默认:现在),一般服务于 `nzDisabledTime`\n */\n disabledBeforeTime(options?: { offsetSeconds?: number }): DisabledTimeFn {\n return this.baseDisabledTime('before', options?.offsetSeconds);\n }\n /**\n * Disabled After time (Default: now), Generally serves `nzDisabledTime`\n *\n * 禁用之后时间(默认:现在),一般服务于 `nzDisabledTime`\n */\n disabledAfterTime(options?: { offsetSeconds?: number }): DisabledTimeFn {\n return this.baseDisabledTime('after', options?.offsetSeconds);\n }\n}\n\nexport const dateTimePickerUtil = new DateTimePickerUtil();\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAuBA;;;;;;;;AAQG;SACa,eAAe,CAC7B,IAA0G,EAC1G,IAA6B,EAC7B,OAAqC,EAAA;AAErC,IAAA,IAAI,GAAG;AACL,UAAE,OAAO,IAAI,KAAK;cACd,KAAK,CAAC,IAAI,EAAE,qBAAqB,EAAE,IAAI,IAAI,EAAE;AAC/C,cAAE,IAAI,IAAI,CAAC,IAAI;AACjB,UAAE,IAAI,IAAI,EAAE;AACd,IAAA,MAAM,GAAG,GAAwB,EAAE,YAAY,EAAE,CAAC,EAAE;AAEpD,IAAA,IAAI,GAAiB;IACrB,QAAQ,IAAI;AACV,QAAA,KAAK,OAAO;AACV,YAAA,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC;YAClB;AACF,QAAA,KAAK,QAAQ;AACX,YAAA,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;YAC/B;AACF,QAAA,KAAK,WAAW;AACd,YAAA,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,EAA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