@ng-atomic/common 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/bundles/ng-atomic-common-directives.umd.js +95 -0
- package/bundles/ng-atomic-common-directives.umd.js.map +1 -0
- package/bundles/ng-atomic-common-directives.umd.min.js +2 -0
- package/bundles/ng-atomic-common-directives.umd.min.js.map +1 -0
- package/bundles/ng-atomic-common-models.umd.js +11 -0
- package/bundles/ng-atomic-common-models.umd.js.map +1 -0
- package/bundles/ng-atomic-common-models.umd.min.js +2 -0
- package/bundles/ng-atomic-common-models.umd.min.js.map +1 -0
- package/bundles/ng-atomic-common-pipes.umd.js +266 -0
- package/bundles/ng-atomic-common-pipes.umd.js.map +1 -0
- package/bundles/ng-atomic-common-pipes.umd.min.js +2 -0
- package/bundles/ng-atomic-common-pipes.umd.min.js.map +1 -0
- package/bundles/ng-atomic-common-services.umd.js +429 -0
- package/bundles/ng-atomic-common-services.umd.js.map +1 -0
- package/bundles/ng-atomic-common-services.umd.min.js +16 -0
- package/bundles/ng-atomic-common-services.umd.min.js.map +1 -0
- package/bundles/ng-atomic-common-store.umd.js +435 -0
- package/bundles/ng-atomic-common-store.umd.js.map +1 -0
- package/bundles/ng-atomic-common-store.umd.min.js +16 -0
- package/bundles/ng-atomic-common-store.umd.min.js.map +1 -0
- package/bundles/ng-atomic-common-utils.umd.js +727 -0
- package/bundles/ng-atomic-common-utils.umd.js.map +1 -0
- package/bundles/ng-atomic-common-utils.umd.min.js +2 -0
- package/bundles/ng-atomic-common-utils.umd.min.js.map +1 -0
- package/bundles/ng-atomic-common.umd.js +11 -0
- package/bundles/ng-atomic-common.umd.js.map +1 -0
- package/bundles/ng-atomic-common.umd.min.js +2 -0
- package/bundles/ng-atomic-common.umd.min.js.map +1 -0
- package/directives/index.d.ts +1 -0
- package/directives/ios-safari-scroll-buggyfill/index.d.ts +2 -0
- package/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.directive.d.ts +10 -0
- package/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.module.d.ts +8 -0
- package/directives/ng-atomic-common-directives.d.ts +5 -0
- package/directives/package.json +10 -0
- package/esm2015/directives/index.js +2 -0
- package/esm2015/directives/index.js.map +1 -0
- package/esm2015/directives/ios-safari-scroll-buggyfill/index.js +3 -0
- package/esm2015/directives/ios-safari-scroll-buggyfill/index.js.map +1 -0
- package/esm2015/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.directive.js +27 -0
- package/esm2015/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.directive.js.map +1 -0
- package/esm2015/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.module.js +27 -0
- package/esm2015/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.module.js.map +1 -0
- package/esm2015/directives/ng-atomic-common-directives.js +5 -0
- package/esm2015/directives/ng-atomic-common-directives.js.map +1 -0
- package/esm2015/index.js +2 -0
- package/esm2015/index.js.map +1 -0
- package/esm2015/models/action-item.js +2 -0
- package/esm2015/models/action-item.js.map +1 -0
- package/esm2015/models/index.js +2 -0
- package/esm2015/models/index.js.map +1 -0
- package/esm2015/models/menu-item.js +2 -0
- package/esm2015/models/menu-item.js.map +1 -0
- package/esm2015/models/ng-atomic-common-models.js +5 -0
- package/esm2015/models/ng-atomic-common-models.js.map +1 -0
- package/esm2015/models/public_api.js +3 -0
- package/esm2015/models/public_api.js.map +1 -0
- package/esm2015/ng-atomic-common.js +5 -0
- package/esm2015/ng-atomic-common.js.map +1 -0
- package/esm2015/pipes/domain/domain.module.js +27 -0
- package/esm2015/pipes/domain/domain.module.js.map +1 -0
- package/esm2015/pipes/domain/domain.pipe.js +29 -0
- package/esm2015/pipes/domain/domain.pipe.js.map +1 -0
- package/esm2015/pipes/domain/index.js +3 -0
- package/esm2015/pipes/domain/index.js.map +1 -0
- package/esm2015/pipes/index.js +5 -0
- package/esm2015/pipes/index.js.map +1 -0
- package/esm2015/pipes/ng-atomic-common-pipes.js +5 -0
- package/esm2015/pipes/ng-atomic-common-pipes.js.map +1 -0
- package/esm2015/pipes/smart-exp/index.js +3 -0
- package/esm2015/pipes/smart-exp/index.js.map +1 -0
- package/esm2015/pipes/smart-exp/smart-exp.module.js +17 -0
- package/esm2015/pipes/smart-exp/smart-exp.module.js.map +1 -0
- package/esm2015/pipes/smart-exp/smart-exp.pipe.js +28 -0
- package/esm2015/pipes/smart-exp/smart-exp.pipe.js.map +1 -0
- package/esm2015/pipes/smart-field/index.js +3 -0
- package/esm2015/pipes/smart-field/index.js.map +1 -0
- package/esm2015/pipes/smart-field/smart-field.module.js +27 -0
- package/esm2015/pipes/smart-field/smart-field.module.js.map +1 -0
- package/esm2015/pipes/smart-field/smart-field.pipe.js +33 -0
- package/esm2015/pipes/smart-field/smart-field.pipe.js.map +1 -0
- package/esm2015/pipes/yen/index.js +3 -0
- package/esm2015/pipes/yen/index.js.map +1 -0
- package/esm2015/pipes/yen/yen.module.js +27 -0
- package/esm2015/pipes/yen/yen.module.js.map +1 -0
- package/esm2015/pipes/yen/yen.pipe.js +17 -0
- package/esm2015/pipes/yen/yen.pipe.js.map +1 -0
- package/esm2015/services/index.js +3 -0
- package/esm2015/services/index.js.map +1 -0
- package/esm2015/services/loading/index.js +2 -0
- package/esm2015/services/loading/index.js.map +1 -0
- package/esm2015/services/loading/loading.service.js +32 -0
- package/esm2015/services/loading/loading.service.js.map +1 -0
- package/esm2015/services/ng-atomic-common-services.js +5 -0
- package/esm2015/services/ng-atomic-common-services.js.map +1 -0
- package/esm2015/services/snack-bar/index.js +3 -0
- package/esm2015/services/snack-bar/index.js.map +1 -0
- package/esm2015/services/snack-bar/snack-bar.module.js +25 -0
- package/esm2015/services/snack-bar/snack-bar.module.js.map +1 -0
- package/esm2015/services/snack-bar/snack-bar.service.js +23 -0
- package/esm2015/services/snack-bar/snack-bar.service.js.map +1 -0
- package/esm2015/store/entities.page.store.js +30 -0
- package/esm2015/store/entities.page.store.js.map +1 -0
- package/esm2015/store/entity.page.store.js +41 -0
- package/esm2015/store/entity.page.store.js.map +1 -0
- package/esm2015/store/index.js +3 -0
- package/esm2015/store/index.js.map +1 -0
- package/esm2015/store/ng-atomic-common-store.js +5 -0
- package/esm2015/store/ng-atomic-common-store.js.map +1 -0
- package/esm2015/utils/comma/comma.js +4 -0
- package/esm2015/utils/comma/comma.js.map +1 -0
- package/esm2015/utils/comma/index.js +2 -0
- package/esm2015/utils/comma/index.js.map +1 -0
- package/esm2015/utils/compare-by-id/compare-by-id.js +2 -0
- package/esm2015/utils/compare-by-id/compare-by-id.js.map +1 -0
- package/esm2015/utils/compare-by-id/index.js +2 -0
- package/esm2015/utils/compare-by-id/index.js.map +1 -0
- package/esm2015/utils/index.js +6 -0
- package/esm2015/utils/index.js.map +1 -0
- package/esm2015/utils/mat-dayjs-date/dayjs-date.adapter.js +189 -0
- package/esm2015/utils/mat-dayjs-date/dayjs-date.adapter.js.map +1 -0
- package/esm2015/utils/mat-dayjs-date/dayjs-date.formats.js +15 -0
- package/esm2015/utils/mat-dayjs-date/dayjs-date.formats.js.map +1 -0
- package/esm2015/utils/mat-dayjs-date/dayjs-date.module.js +42 -0
- package/esm2015/utils/mat-dayjs-date/dayjs-date.module.js.map +1 -0
- package/esm2015/utils/mat-dayjs-date/dayjs-jp-providers.js +20 -0
- package/esm2015/utils/mat-dayjs-date/dayjs-jp-providers.js.map +1 -0
- package/esm2015/utils/mat-dayjs-date/index.js +5 -0
- package/esm2015/utils/mat-dayjs-date/index.js.map +1 -0
- package/esm2015/utils/ng-atomic-common-utils.js +5 -0
- package/esm2015/utils/ng-atomic-common-utils.js.map +1 -0
- package/esm2015/utils/query/index.js +2 -0
- package/esm2015/utils/query/index.js.map +1 -0
- package/esm2015/utils/query/query.resolver.js +59 -0
- package/esm2015/utils/query/query.resolver.js.map +1 -0
- package/esm2015/utils/to-object/index.js +2 -0
- package/esm2015/utils/to-object/index.js.map +1 -0
- package/esm2015/utils/to-object/to-object.js +10 -0
- package/esm2015/utils/to-object/to-object.js.map +1 -0
- package/fesm2015/ng-atomic-common-directives.js +58 -0
- package/fesm2015/ng-atomic-common-directives.js.map +1 -0
- package/fesm2015/ng-atomic-common-models.js +4 -0
- package/fesm2015/ng-atomic-common-models.js.map +1 -0
- package/fesm2015/ng-atomic-common-pipes.js +191 -0
- package/fesm2015/ng-atomic-common-pipes.js.map +1 -0
- package/fesm2015/ng-atomic-common-services.js +80 -0
- package/fesm2015/ng-atomic-common-services.js.map +1 -0
- package/fesm2015/ng-atomic-common-store.js +74 -0
- package/fesm2015/ng-atomic-common-store.js.map +1 -0
- package/fesm2015/ng-atomic-common-utils.js +340 -0
- package/fesm2015/ng-atomic-common-utils.js.map +1 -0
- package/fesm2015/ng-atomic-common.js +4 -0
- package/fesm2015/ng-atomic-common.js.map +1 -0
- package/index.d.ts +1 -0
- package/models/action-item.d.ts +6 -0
- package/models/index.d.ts +1 -0
- package/models/menu-item.d.ts +4 -0
- package/models/ng-atomic-common-models.d.ts +5 -0
- package/models/package.json +10 -0
- package/models/public_api.d.ts +2 -0
- package/ng-atomic-common.d.ts +5 -0
- package/package.json +21 -0
- package/pipes/domain/domain.module.d.ts +8 -0
- package/pipes/domain/domain.pipe.d.ts +11 -0
- package/pipes/domain/index.d.ts +2 -0
- package/pipes/index.d.ts +4 -0
- package/pipes/ng-atomic-common-pipes.d.ts +5 -0
- package/pipes/package.json +10 -0
- package/pipes/smart-exp/index.d.ts +2 -0
- package/pipes/smart-exp/smart-exp.module.d.ts +7 -0
- package/pipes/smart-exp/smart-exp.pipe.d.ts +7 -0
- package/pipes/smart-field/index.d.ts +2 -0
- package/pipes/smart-field/smart-field.module.d.ts +8 -0
- package/pipes/smart-field/smart-field.pipe.d.ts +31 -0
- package/pipes/yen/index.d.ts +2 -0
- package/pipes/yen/yen.module.d.ts +8 -0
- package/pipes/yen/yen.pipe.d.ts +7 -0
- package/services/index.d.ts +2 -0
- package/services/loading/index.d.ts +1 -0
- package/services/loading/loading.service.d.ts +14 -0
- package/services/ng-atomic-common-services.d.ts +5 -0
- package/services/package.json +10 -0
- package/services/snack-bar/index.d.ts +2 -0
- package/services/snack-bar/snack-bar.module.d.ts +8 -0
- package/services/snack-bar/snack-bar.service.d.ts +9 -0
- package/store/entities.page.store.d.ts +32 -0
- package/store/entity.page.store.d.ts +28 -0
- package/store/index.d.ts +2 -0
- package/store/ng-atomic-common-store.d.ts +5 -0
- package/store/package.json +10 -0
- package/utils/comma/comma.d.ts +3 -0
- package/utils/comma/index.d.ts +1 -0
- package/utils/compare-by-id/compare-by-id.d.ts +4 -0
- package/utils/compare-by-id/index.d.ts +1 -0
- package/utils/index.d.ts +5 -0
- package/utils/mat-dayjs-date/dayjs-date.adapter.d.ts +60 -0
- package/utils/mat-dayjs-date/dayjs-date.formats.d.ts +5 -0
- package/utils/mat-dayjs-date/dayjs-date.module.d.ts +11 -0
- package/utils/mat-dayjs-date/dayjs-jp-providers.d.ts +10 -0
- package/utils/mat-dayjs-date/index.d.ts +4 -0
- package/utils/ng-atomic-common-utils.d.ts +5 -0
- package/utils/package.json +10 -0
- package/utils/query/index.d.ts +1 -0
- package/utils/query/query.resolver.d.ts +1 -0
- package/utils/to-object/index.d.ts +1 -0
- package/utils/to-object/to-object.d.ts +1 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, ɵɵdirectiveInject, ɵɵngDeclarePipe, ɵsetClassMetadata, Pipe, Optional, Inject, ɵɵdefineNgModule, ɵɵdefineInjector, ɵɵsetNgModuleScope, NgModule } from '@angular/core';
|
|
3
|
+
import { CommonModule } from '@angular/common';
|
|
4
|
+
import { isDayjs } from 'dayjs';
|
|
5
|
+
import { comma } from '@ng-atomic/common/utils';
|
|
6
|
+
|
|
7
|
+
const DOMAIN_LANG_MAP = new InjectionToken('domain lang map');
|
|
8
|
+
class DomainPipe {
|
|
9
|
+
constructor(map) {
|
|
10
|
+
var _a;
|
|
11
|
+
this.map = map;
|
|
12
|
+
(_a = this.map) !== null && _a !== void 0 ? _a : (this.map = {});
|
|
13
|
+
}
|
|
14
|
+
transform(input) {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
return (_b = (_a = this.map) === null || _a === void 0 ? void 0 : _a[input]) !== null && _b !== void 0 ? _b : input;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
DomainPipe.ɵfac = function DomainPipe_Factory(t) { return new (t || DomainPipe)(ɵɵdirectiveInject(DOMAIN_LANG_MAP, 8)); };
|
|
20
|
+
DomainPipe.ɵpipe = ɵɵngDeclarePipe({ version: "11.2.14", ngImport: i0, type: DomainPipe, name: "D" });
|
|
21
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(DomainPipe, [{
|
|
22
|
+
type: Pipe,
|
|
23
|
+
args: [{
|
|
24
|
+
name: 'D',
|
|
25
|
+
pure: true,
|
|
26
|
+
}]
|
|
27
|
+
}], function () { return [{ type: undefined, decorators: [{
|
|
28
|
+
type: Optional
|
|
29
|
+
}, {
|
|
30
|
+
type: Inject,
|
|
31
|
+
args: [DOMAIN_LANG_MAP]
|
|
32
|
+
}] }]; }, null); })();
|
|
33
|
+
|
|
34
|
+
class DomainModule {
|
|
35
|
+
}
|
|
36
|
+
DomainModule.ɵfac = function DomainModule_Factory(t) { return new (t || DomainModule)(); };
|
|
37
|
+
DomainModule.ɵmod = ɵɵdefineNgModule({ type: DomainModule });
|
|
38
|
+
DomainModule.ɵinj = ɵɵdefineInjector({ imports: [[
|
|
39
|
+
CommonModule
|
|
40
|
+
]] });
|
|
41
|
+
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && ɵɵsetNgModuleScope(DomainModule, { declarations: [DomainPipe], imports: [CommonModule], exports: [DomainPipe] }); })();
|
|
42
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(DomainModule, [{
|
|
43
|
+
type: NgModule,
|
|
44
|
+
args: [{
|
|
45
|
+
declarations: [
|
|
46
|
+
DomainPipe
|
|
47
|
+
],
|
|
48
|
+
imports: [
|
|
49
|
+
CommonModule
|
|
50
|
+
],
|
|
51
|
+
exports: [
|
|
52
|
+
DomainPipe
|
|
53
|
+
]
|
|
54
|
+
}]
|
|
55
|
+
}], null, null); })();
|
|
56
|
+
|
|
57
|
+
class YenPipe {
|
|
58
|
+
transform(value, _unit) {
|
|
59
|
+
return value < 1 ? `${comma(value * 100)}%` : `${comma(value)}円`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
YenPipe.ɵfac = function YenPipe_Factory(t) { return new (t || YenPipe)(); };
|
|
63
|
+
YenPipe.ɵpipe = ɵɵngDeclarePipe({ version: "11.2.14", ngImport: i0, type: YenPipe, name: "yen" });
|
|
64
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(YenPipe, [{
|
|
65
|
+
type: Pipe,
|
|
66
|
+
args: [{
|
|
67
|
+
name: 'yen'
|
|
68
|
+
}]
|
|
69
|
+
}], null, null); })();
|
|
70
|
+
|
|
71
|
+
class SmartExpPipe {
|
|
72
|
+
transform(input, key) {
|
|
73
|
+
if (isDayjs(input)) {
|
|
74
|
+
return input.format('YY/MM/DD');
|
|
75
|
+
}
|
|
76
|
+
else if (Array.isArray(input)) {
|
|
77
|
+
return `${input.length}個のアイテム`;
|
|
78
|
+
}
|
|
79
|
+
else if (typeof input === 'number' && input > 10000) {
|
|
80
|
+
return new YenPipe().transform(input);
|
|
81
|
+
}
|
|
82
|
+
return input;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
SmartExpPipe.ɵfac = function SmartExpPipe_Factory(t) { return new (t || SmartExpPipe)(); };
|
|
86
|
+
SmartExpPipe.ɵpipe = ɵɵngDeclarePipe({ version: "11.2.14", ngImport: i0, type: SmartExpPipe, name: "smartExp" });
|
|
87
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(SmartExpPipe, [{
|
|
88
|
+
type: Pipe,
|
|
89
|
+
args: [{
|
|
90
|
+
name: 'smartExp',
|
|
91
|
+
pure: true,
|
|
92
|
+
}]
|
|
93
|
+
}], null, null); })();
|
|
94
|
+
|
|
95
|
+
class SmartExpModule {
|
|
96
|
+
}
|
|
97
|
+
SmartExpModule.ɵfac = function SmartExpModule_Factory(t) { return new (t || SmartExpModule)(); };
|
|
98
|
+
SmartExpModule.ɵmod = ɵɵdefineNgModule({ type: SmartExpModule });
|
|
99
|
+
SmartExpModule.ɵinj = ɵɵdefineInjector({});
|
|
100
|
+
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && ɵɵsetNgModuleScope(SmartExpModule, { declarations: [SmartExpPipe], exports: [SmartExpPipe] }); })();
|
|
101
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(SmartExpModule, [{
|
|
102
|
+
type: NgModule,
|
|
103
|
+
args: [{
|
|
104
|
+
declarations: [SmartExpPipe],
|
|
105
|
+
exports: [SmartExpPipe]
|
|
106
|
+
}]
|
|
107
|
+
}], null, null); })();
|
|
108
|
+
|
|
109
|
+
const FORM_FIELD_MAP = new InjectionToken('[@ng-atomic] Smart Form Field');
|
|
110
|
+
class SmartFieldPipe {
|
|
111
|
+
constructor(map) {
|
|
112
|
+
var _a;
|
|
113
|
+
this.map = map;
|
|
114
|
+
(_a = this.map) !== null && _a !== void 0 ? _a : (this.map = {
|
|
115
|
+
createdAt: { type: 'date' },
|
|
116
|
+
updatedAt: { type: 'date' },
|
|
117
|
+
deletedAt: { type: 'date' },
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
transform(key) {
|
|
121
|
+
var _a;
|
|
122
|
+
return (_a = this.map[key]) !== null && _a !== void 0 ? _a : { type: 'input' };
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
SmartFieldPipe.ɵfac = function SmartFieldPipe_Factory(t) { return new (t || SmartFieldPipe)(ɵɵdirectiveInject(FORM_FIELD_MAP, 8)); };
|
|
126
|
+
SmartFieldPipe.ɵpipe = ɵɵngDeclarePipe({ version: "11.2.14", ngImport: i0, type: SmartFieldPipe, name: "smartField" });
|
|
127
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(SmartFieldPipe, [{
|
|
128
|
+
type: Pipe,
|
|
129
|
+
args: [{
|
|
130
|
+
name: 'smartField',
|
|
131
|
+
pure: true,
|
|
132
|
+
}]
|
|
133
|
+
}], function () { return [{ type: undefined, decorators: [{
|
|
134
|
+
type: Optional
|
|
135
|
+
}, {
|
|
136
|
+
type: Inject,
|
|
137
|
+
args: [FORM_FIELD_MAP]
|
|
138
|
+
}] }]; }, null); })();
|
|
139
|
+
|
|
140
|
+
class SmartFieldModule {
|
|
141
|
+
}
|
|
142
|
+
SmartFieldModule.ɵfac = function SmartFieldModule_Factory(t) { return new (t || SmartFieldModule)(); };
|
|
143
|
+
SmartFieldModule.ɵmod = ɵɵdefineNgModule({ type: SmartFieldModule });
|
|
144
|
+
SmartFieldModule.ɵinj = ɵɵdefineInjector({ imports: [[
|
|
145
|
+
CommonModule
|
|
146
|
+
]] });
|
|
147
|
+
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && ɵɵsetNgModuleScope(SmartFieldModule, { declarations: [SmartFieldPipe], imports: [CommonModule], exports: [SmartFieldPipe] }); })();
|
|
148
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(SmartFieldModule, [{
|
|
149
|
+
type: NgModule,
|
|
150
|
+
args: [{
|
|
151
|
+
declarations: [
|
|
152
|
+
SmartFieldPipe
|
|
153
|
+
],
|
|
154
|
+
imports: [
|
|
155
|
+
CommonModule
|
|
156
|
+
],
|
|
157
|
+
exports: [
|
|
158
|
+
SmartFieldPipe
|
|
159
|
+
]
|
|
160
|
+
}]
|
|
161
|
+
}], null, null); })();
|
|
162
|
+
|
|
163
|
+
class YenModule {
|
|
164
|
+
}
|
|
165
|
+
YenModule.ɵfac = function YenModule_Factory(t) { return new (t || YenModule)(); };
|
|
166
|
+
YenModule.ɵmod = ɵɵdefineNgModule({ type: YenModule });
|
|
167
|
+
YenModule.ɵinj = ɵɵdefineInjector({ imports: [[
|
|
168
|
+
CommonModule
|
|
169
|
+
]] });
|
|
170
|
+
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && ɵɵsetNgModuleScope(YenModule, { declarations: [YenPipe], imports: [CommonModule], exports: [YenPipe] }); })();
|
|
171
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(YenModule, [{
|
|
172
|
+
type: NgModule,
|
|
173
|
+
args: [{
|
|
174
|
+
declarations: [
|
|
175
|
+
YenPipe
|
|
176
|
+
],
|
|
177
|
+
imports: [
|
|
178
|
+
CommonModule
|
|
179
|
+
],
|
|
180
|
+
exports: [
|
|
181
|
+
YenPipe
|
|
182
|
+
]
|
|
183
|
+
}]
|
|
184
|
+
}], null, null); })();
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Generated bundle index. Do not edit.
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
export { DOMAIN_LANG_MAP, DomainModule, DomainPipe, FORM_FIELD_MAP, SmartExpModule, SmartExpPipe, SmartFieldModule, SmartFieldPipe, YenModule, YenPipe };
|
|
191
|
+
//# sourceMappingURL=ng-atomic-common-pipes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-atomic-common-pipes.js","sources":["../../../../libs/common/pipes/domain/domain.pipe.ts","../../../../libs/common/pipes/domain/domain.module.ts","../../../../libs/common/pipes/yen/yen.pipe.ts","../../../../libs/common/pipes/smart-exp/smart-exp.pipe.ts","../../../../libs/common/pipes/smart-exp/smart-exp.module.ts","../../../../libs/common/pipes/smart-field/smart-field.pipe.ts","../../../../libs/common/pipes/smart-field/smart-field.module.ts","../../../../libs/common/pipes/yen/yen.module.ts","../../../../libs/common/pipes/ng-atomic-common-pipes.ts"],"sourcesContent":["import { Inject, InjectionToken, Optional, Pipe } from '@angular/core';\n\nexport type DomainLangMap = Record<string, string>;\nexport const DOMAIN_LANG_MAP = new InjectionToken<DomainLangMap>('domain lang map');\n\n@Pipe({\n name: 'D',\n pure: true,\n})\nexport class DomainPipe {\n constructor(@Optional() @Inject(DOMAIN_LANG_MAP) private map: DomainLangMap) {\n this.map ??= {};\n }\n\n transform(input: string) {\n return this.map?.[input] ?? input;\n }\n}\n\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { DomainPipe } from './domain.pipe';\n\n\n\n@NgModule({\n declarations: [\n DomainPipe\n ],\n imports: [\n CommonModule\n ],\n exports: [\n DomainPipe\n ]\n})\nexport class DomainModule { }\n","import { Pipe, PipeTransform } from '@angular/core';\nimport { comma } from '@ng-atomic/common/utils';\n\n@Pipe({\n name: 'yen'\n})\nexport class YenPipe implements PipeTransform {\n\n transform(value: number, _unit?: string): string {\n return value < 1 ? `${comma(value * 100)}%` : `${comma(value)}円`;\n }\n\n}\n","import { Pipe } from '@angular/core';\nimport * as dayjs from 'dayjs';\nimport { YenPipe } from '../yen/yen.pipe';\n\n@Pipe({\n name: 'smartExp',\n pure: true,\n})\nexport class SmartExpPipe {\n transform(input: string | number | dayjs.Dayjs | any, key?: string): string {\n if (dayjs.isDayjs(input)) {\n return input.format('YY/MM/DD');\n } else if (Array.isArray(input)) {\n return `${input.length}個のアイテム`;\n } else if (typeof input === 'number' && input > 10_000) {\n return new YenPipe().transform(input);\n }\n return input;\n }\n}","import { NgModule } from \"@angular/core\";\nimport { SmartExpPipe } from \"./smart-exp.pipe\";\n\n@NgModule({\n declarations: [SmartExpPipe],\n exports: [SmartExpPipe]\n})\nexport class SmartExpModule { }","import { Inject, InjectionToken, Optional, Pipe, PipeTransform } from '@angular/core';\n\ninterface Option<T> {\n name: string;\n value: T;\n}\n\ninterface InputField {\n type: 'input';\n}\n\ninterface DateInputField {\n type: 'date';\n}\n\ninterface SelectField<T> {\n type: 'select';\n options: Option<T>[];\n}\n\ninterface MultiSelectField<T> {\n type: 'multi-select';\n options: Option<T>[];\n}\n\ntype FormField<V> = InputField\n | DateInputField\n | SelectField<V>\n | MultiSelectField<V>;\n\nexport type FormFieldMap = Record<string, FormField<any>>;\n\nexport const FORM_FIELD_MAP = new InjectionToken<FormFieldMap>('[@ng-atomic] Smart Form Field');\n\n@Pipe({\n name: 'smartField',\n pure: true,\n})\nexport class SmartFieldPipe implements PipeTransform {\n\n constructor(\n @Optional() @Inject(FORM_FIELD_MAP) private map: Record<string, FormField<any>>\n ) {\n this.map ??= {\n createdAt: { type: 'date' },\n updatedAt: { type: 'date' },\n deletedAt: { type: 'date' },\n };\n }\n\n transform(key: string): FormField<any> {\n return this.map[key] ?? {type: 'input'};\n }\n\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { SmartFieldPipe } from './smart-field.pipe';\n\n\n\n@NgModule({\n declarations: [\n SmartFieldPipe\n ],\n imports: [\n CommonModule\n ],\n exports: [\n SmartFieldPipe\n ]\n})\nexport class SmartFieldModule { }\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { YenPipe } from './yen.pipe';\n\n\n\n@NgModule({\n declarations: [\n YenPipe\n ],\n imports: [\n CommonModule\n ],\n exports: [\n YenPipe\n ]\n})\nexport class YenModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["dayjs.isDayjs"],"mappings":";;;;;;MAGa,eAAe,GAAG,IAAI,cAAc,CAAgB,iBAAiB,EAAE;MAMvE,UAAU;IACrB,YAAyD,GAAkB;;QAAlB,QAAG,GAAH,GAAG,CAAe;QACzE,MAAA,IAAI,CAAC,GAAG,oCAAR,IAAI,CAAC,GAAG,GAAK,EAAE,EAAC;KACjB;IAED,SAAS,CAAC,KAAa;;QACrB,mBAAO,IAAI,CAAC,GAAG,0CAAG,KAAK,oCAAK,KAAK,CAAC;KACnC;;oEAPU,UAAU,oBACW,eAAe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,YAAY,aAGZ,OAAO;oFAGE,SAAS;cAXrB,QAAQ;eAAC;gBACR,YAAY,EAAE;oBACZ,OAAO;iBACR;gBACD,OAAO,EAAE;oBACP,YAAY;iBACb;gBACD,OAAO,EAAE;oBACP,OAAO;iBACR;aACF;;;AChBD;;;;;;"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ɵɵdefineInjectable, ɵsetClassMetadata, Injectable, ɵɵinject, ɵɵdefineNgModule, ɵɵdefineInjector, ɵɵsetNgModuleScope, NgModule } from '@angular/core';
|
|
2
|
+
import { Subject } from 'rxjs';
|
|
3
|
+
import { scan, map, distinctUntilChanged, delay } from 'rxjs/operators';
|
|
4
|
+
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
|
5
|
+
import { CommonModule } from '@angular/common';
|
|
6
|
+
|
|
7
|
+
class LoadingService {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.loadingEntries$ = new Subject();
|
|
10
|
+
this.loadingMap = {};
|
|
11
|
+
this.loadingMap$ = this.loadingEntries$.pipe(scan((pre, [key, value]) => (Object.assign(Object.assign({}, pre), { [key]: value })), {}), map((m) => Object.entries(m)
|
|
12
|
+
.filter(([k, v]) => v)
|
|
13
|
+
.reduce((p, [k, v]) => (Object.assign(Object.assign({}, p), { [k]: v })), {})), distinctUntilChanged((pre, cur) => JSON.stringify(pre) === JSON.stringify(cur)));
|
|
14
|
+
this.isLoading$ = this.loadingMap$.pipe(map((m) => !!Object.keys(m).length), delay(0));
|
|
15
|
+
this.loadingMap$.subscribe((m) => {
|
|
16
|
+
this.loadingMap = m;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
setKey(key) {
|
|
20
|
+
this.loadingEntries$.next([key, true]);
|
|
21
|
+
}
|
|
22
|
+
removeKey(key) {
|
|
23
|
+
this.loadingEntries$.next([key, false]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
LoadingService.ɵfac = function LoadingService_Factory(t) { return new (t || LoadingService)(); };
|
|
27
|
+
LoadingService.ɵprov = ɵɵdefineInjectable({ token: LoadingService, factory: LoadingService.ɵfac, providedIn: 'root' });
|
|
28
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(LoadingService, [{
|
|
29
|
+
type: Injectable,
|
|
30
|
+
args: [{
|
|
31
|
+
providedIn: 'root',
|
|
32
|
+
}]
|
|
33
|
+
}], function () { return []; }, null); })();
|
|
34
|
+
|
|
35
|
+
class SnackBarService {
|
|
36
|
+
constructor(snackBar) {
|
|
37
|
+
this.snackBar = snackBar;
|
|
38
|
+
}
|
|
39
|
+
openSnackBar(message, action) {
|
|
40
|
+
this.snackBar.open(message, action, {
|
|
41
|
+
duration: 2000,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
SnackBarService.ɵfac = function SnackBarService_Factory(t) { return new (t || SnackBarService)(ɵɵinject(MatSnackBar)); };
|
|
46
|
+
SnackBarService.ɵprov = ɵɵdefineInjectable({ token: SnackBarService, factory: SnackBarService.ɵfac, providedIn: 'root' });
|
|
47
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(SnackBarService, [{
|
|
48
|
+
type: Injectable,
|
|
49
|
+
args: [{
|
|
50
|
+
providedIn: 'root'
|
|
51
|
+
}]
|
|
52
|
+
}], function () { return [{ type: MatSnackBar }]; }, null); })();
|
|
53
|
+
|
|
54
|
+
class SnackBarModule {
|
|
55
|
+
}
|
|
56
|
+
SnackBarModule.ɵfac = function SnackBarModule_Factory(t) { return new (t || SnackBarModule)(); };
|
|
57
|
+
SnackBarModule.ɵmod = ɵɵdefineNgModule({ type: SnackBarModule });
|
|
58
|
+
SnackBarModule.ɵinj = ɵɵdefineInjector({ imports: [[
|
|
59
|
+
CommonModule,
|
|
60
|
+
MatSnackBarModule
|
|
61
|
+
]] });
|
|
62
|
+
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && ɵɵsetNgModuleScope(SnackBarModule, { imports: [CommonModule,
|
|
63
|
+
MatSnackBarModule] }); })();
|
|
64
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(SnackBarModule, [{
|
|
65
|
+
type: NgModule,
|
|
66
|
+
args: [{
|
|
67
|
+
declarations: [],
|
|
68
|
+
imports: [
|
|
69
|
+
CommonModule,
|
|
70
|
+
MatSnackBarModule
|
|
71
|
+
]
|
|
72
|
+
}]
|
|
73
|
+
}], null, null); })();
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Generated bundle index. Do not edit.
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
export { LoadingService, SnackBarModule, SnackBarService };
|
|
80
|
+
//# sourceMappingURL=ng-atomic-common-services.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-atomic-common-services.js","sources":["../../../../libs/common/services/loading/loading.service.ts","../../../../libs/common/services/snack-bar/snack-bar.service.ts","../../../../libs/common/services/snack-bar/snack-bar.module.ts","../../../../libs/common/services/ng-atomic-common-services.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { Subject } from 'rxjs';\nimport { scan, map, distinctUntilChanged, delay } from 'rxjs/operators';\n\ntype LoadingMap = Record<string, boolean>;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class LoadingService {\n private loadingEntries$ = new Subject<[string, boolean]>();\n\n loadingMap: LoadingMap = {};\n loadingMap$ = this.loadingEntries$.pipe(\n scan((pre, [key, value]) => ({ ...pre, [key]: value }), {} as LoadingMap),\n map((m: LoadingMap) => Object.entries(m)\n .filter(([k, v]: [string, boolean]) => v)\n .reduce((p, [k, v]) => ({ ...p, [k]: v }), {} as LoadingMap)),\n distinctUntilChanged((pre, cur) => JSON.stringify(pre) === JSON.stringify(cur)),\n );\n\n isLoading$ = this.loadingMap$.pipe(\n map((m) => !!Object.keys(m).length),\n delay(0),\n );\n\n constructor() {\n this.loadingMap$.subscribe((m) => {\n this.loadingMap = m;\n });\n }\n\n setKey(key: string): void {\n this.loadingEntries$.next([key, true]);\n }\n\n removeKey(key: string): void {\n this.loadingEntries$.next([key, false]);\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { MatSnackBar } from '@angular/material/snack-bar';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class SnackBarService {\n\n constructor(private snackBar: MatSnackBar) {}\n\n openSnackBar(message: string, action?: string) {\n this.snackBar.open(message, action, {\n duration: 2000,\n });\n }\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\n\nimport { MatSnackBarModule } from '@angular/material/snack-bar';\n\n@NgModule({\n declarations: [],\n imports: [\n CommonModule,\n MatSnackBarModule\n ]\n})\nexport class SnackBarModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;MASa,cAAc;IAiBzB;QAhBQ,oBAAe,GAAG,IAAI,OAAO,EAAqB,CAAC;QAE3D,eAAU,GAAe,EAAE,CAAC;QAC5B,gBAAW,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CACrC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,sCAAW,GAAG,KAAE,CAAC,GAAG,GAAG,KAAK,IAAG,EAAE,EAAgB,CAAC,EACzE,GAAG,CAAC,CAAC,CAAa,KAAK,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;aACrC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAoB,KAAK,CAAC,CAAC;aACxC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,sCAAW,CAAC,KAAE,CAAC,CAAC,GAAG,CAAC,IAAG,EAAE,EAAgB,CAAC,CAAC,EAC/D,oBAAoB,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAChF,CAAC;QAE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;;;ACXD;;;;;;"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
2
|
+
import { ComponentStore } from '@ngrx/component-store';
|
|
3
|
+
import { filter, tap, switchMap, map, distinctUntilChanged } from 'rxjs/operators';
|
|
4
|
+
import { filterByQuery, compareById } from '@ng-atomic/common/utils';
|
|
5
|
+
|
|
6
|
+
const tryCatch = (promise) => new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
7
|
+
try {
|
|
8
|
+
resolve(yield promise);
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
reject(error);
|
|
12
|
+
}
|
|
13
|
+
}));
|
|
14
|
+
class EntityPageStore extends ComponentStore {
|
|
15
|
+
constructor(initialState) {
|
|
16
|
+
super(initialState);
|
|
17
|
+
this.mode$ = this.select(state => state.mode);
|
|
18
|
+
this.entityId$ = this.select(state => state.entityId).pipe(filter(id => !!id));
|
|
19
|
+
this.entity$ = this.select(state => state.entity);
|
|
20
|
+
this.setMode = this.updater((state, mode) => (Object.assign(Object.assign({}, state), { mode })));
|
|
21
|
+
this.setEntityId = this.updater((state, entityId) => (Object.assign(Object.assign({}, state), { entityId })));
|
|
22
|
+
this.setEntity = this.updater((state, entity) => (Object.assign(Object.assign({}, state), { entity })));
|
|
23
|
+
this.getEntityIdAndMode = this.effect((entityId$) => entityId$.pipe(tap(id => this.setMode(id === 'new' ? 'create' : 'update')), filter(id => id !== 'new'), tap((id) => this.setEntityId(id))));
|
|
24
|
+
this.getEntity = this.effect((entityId$) => entityId$.pipe(switchMap(id => this._getEntity(id)), tap((entity) => this.setEntity(entity))));
|
|
25
|
+
this.getEntity(this.entityId$);
|
|
26
|
+
}
|
|
27
|
+
get entity() { return this.get().entity; }
|
|
28
|
+
createEntity(value) {
|
|
29
|
+
const entity = (Object.assign(Object.assign({}, this.entity), value));
|
|
30
|
+
this.loading.setKey('[pages/stores/pages/store] Create Store');
|
|
31
|
+
return tryCatch(this._createEntity(entity))
|
|
32
|
+
.catch(error => (console.error(error), this.snackBar.openSnackBar('作成に失敗しました。')))
|
|
33
|
+
.finally(() => this.loading.removeKey('[pages/stores/pages/store] Create Store'));
|
|
34
|
+
}
|
|
35
|
+
updateEntity(value) {
|
|
36
|
+
const entity = (Object.assign(Object.assign({}, this.entity), value));
|
|
37
|
+
this.loading.setKey('[pages/stores/pages/store] Create Store');
|
|
38
|
+
return this._updateEntity(entity)
|
|
39
|
+
.catch(error => (console.error(error), this.snackBar.openSnackBar('更新に失敗しました。')))
|
|
40
|
+
.finally(() => this.loading.removeKey('[pages/stores/pages/store] Create Store'));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
class EntitiesPageStore extends ComponentStore {
|
|
45
|
+
constructor(initialState) {
|
|
46
|
+
super(initialState);
|
|
47
|
+
this.userId$ = this.select(state => state.userId).pipe(filter(userId => !!userId));
|
|
48
|
+
this.entities$ = this.select(({ query, entities }) => filterByQuery(entities, query, this.LANG_MAP))
|
|
49
|
+
.pipe(map((entities) => entities.sort(compareById)))
|
|
50
|
+
.pipe(distinctUntilChanged((pre, cur) => JSON.stringify(pre) === JSON.stringify(cur)));
|
|
51
|
+
this.setUserId = this.updater((state, userId) => (Object.assign(Object.assign({}, state), { userId })));
|
|
52
|
+
this.setEntities = this.updater((state, entities) => (Object.assign(Object.assign({}, state), { entities })));
|
|
53
|
+
this.setPage = this.updater((state, page) => (Object.assign(Object.assign({}, state), { page })));
|
|
54
|
+
this.setIdSet = this.updater((state, idSet) => (Object.assign(Object.assign({}, state), { idSet })));
|
|
55
|
+
this.addId = this.updater((state, id) => (Object.assign(Object.assign({}, state), { idSet: new Set([...state.idSet, id]) })));
|
|
56
|
+
this.removeId = this.updater((state, id) => {
|
|
57
|
+
return Object.assign(Object.assign({}, state), { idSet: new Set([...state.idSet].filter(_id => _id !== id)) });
|
|
58
|
+
});
|
|
59
|
+
this.setQuery = this.updater((state, query) => (Object.assign(Object.assign({}, state), { query })));
|
|
60
|
+
this.getPage = this.effect((entities$) => entities$.pipe(tap(({ length }) => this.setPage(this.page.patch({ length })))));
|
|
61
|
+
this.getEntities = this.effect((userId$) => userId$.pipe(filter(userId => !!userId), tap(() => this.loading.setKey('[/entities] Get Entities')), switchMap(() => this._getEntities()), tap((entities) => this.setEntities(entities)), tap(() => this.loading.removeKey('[/entities] Get Entities'))));
|
|
62
|
+
this.getPage(this.entities$);
|
|
63
|
+
this.getEntities(this.userId$);
|
|
64
|
+
}
|
|
65
|
+
get page() { return this.get(state => state.page); }
|
|
66
|
+
get idSet() { return this.get(state => state.idSet); }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Generated bundle index. Do not edit.
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
export { EntitiesPageStore, EntityPageStore };
|
|
74
|
+
//# sourceMappingURL=ng-atomic-common-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-atomic-common-store.js","sources":["../../../../libs/common/store/entity.page.store.ts","../../../../libs/common/store/entities.page.store.ts","../../../../libs/common/store/ng-atomic-common-store.ts"],"sourcesContent":["import { ComponentStore } from '@ngrx/component-store';\nimport { LoadingService, SnackBarService } from '@ng-atomic/common/services';\nimport { Observable } from 'rxjs';\nimport { filter, switchMap, tap } from 'rxjs/operators';\n\nexport type Mode = 'create' | 'update'\n\nexport interface EntityPageState<Entity> {\n mode: Mode;\n entityId: string;\n entity: Entity;\n}\n\nconst tryCatch = (promise: Promise<any>) => new Promise(async (resolve, reject) => {\n try { resolve(await promise); } catch (error) { reject(error); }\n});\n\nexport abstract class EntityPageStore<S extends EntityPageState<Entity>, Entity> extends ComponentStore<S> {\n get entity() { return this.get().entity}\n\n mode$ = this.select(state => state.mode);\n entityId$ = this.select(state => state.entityId).pipe(filter(id => !!id));\n entity$ = this.select(state => state.entity);\n\n setMode = this.updater((state, mode: Mode) => ({...state, mode}));\n setEntityId = this.updater((state, entityId: string) => ({...state, entityId}));\n setEntity = this.updater((state, entity: Entity) => ({...state, entity}));\n\n constructor(initialState?: S) {\n super(initialState);\n this.getEntity(this.entityId$);\n }\n\n getEntityIdAndMode = this.effect((entityId$: Observable<string>) => entityId$.pipe(\n tap(id => this.setMode(id === 'new' ? 'create' : 'update')),\n filter(id => id !== 'new'),\n tap((id: string) => this.setEntityId(id)),\n ));\n\n getEntity = this.effect((entityId$: Observable<string>) => entityId$.pipe(\n switchMap(id => this._getEntity(id)),\n tap((entity: Entity) => this.setEntity(entity)),\n ));\n\n\n\n createEntity(value: Partial<Entity>) {\n const entity: Entity = ({...this.entity, ...value});\n\n this.loading.setKey('[pages/stores/pages/store] Create Store');\n\n return tryCatch(this._createEntity(entity))\n .catch(error => (console.error(error), this.snackBar.openSnackBar('作成に失敗しました。')))\n .finally(() => this.loading.removeKey('[pages/stores/pages/store] Create Store'));\n }\n\n updateEntity(value: Partial<Entity>) {\n const entity: Entity = ({...this.entity, ...value});\n\n this.loading.setKey('[pages/stores/pages/store] Create Store');\n return this._updateEntity(entity)\n .catch(error => (console.error(error), this.snackBar.openSnackBar('更新に失敗しました。')))\n .finally(() => this.loading.removeKey('[pages/stores/pages/store] Create Store'));\n }\n\n abstract _getEntity(id: string): Observable<Entity>;\n abstract _createEntity(entity: Entity): Promise<Entity>;\n abstract _updateEntity(entity: Entity): Promise<void>;\n\n abstract get loading(): LoadingService;\n abstract get snackBar(): SnackBarService;\n\n}\n","import { ComponentStore } from '@ngrx/component-store';\nimport { LoadingService } from '@ng-atomic/common/services';\n// import { Page } from '../components/templates/smart-index';\nimport { filterByQuery } from '@ng-atomic/common/utils';\nimport { compareById } from '@ng-atomic/common/utils';\nimport { Observable } from 'rxjs';\nimport { distinctUntilChanged, tap, map, filter, switchMap } from 'rxjs/operators';\n\nexport type Page = any\n\nexport interface EntitiesPageState<E> {\n userId: string; \n idSet: Set<string>;\n query: string;\n entities: E[]\n page: Page;\n}\n\nexport abstract class EntitiesPageStore<S extends EntitiesPageState<E>, E extends {id: string}> extends ComponentStore<S> {\n abstract LANG_MAP: Record<string, string>;\n\n get page(): Page { return this.get(state => state.page); }\n get idSet(): Set<string> { return this.get(state => state.idSet); }\n\n userId$ = this.select(state => state.userId).pipe(filter(userId => !!userId));\n entities$ = this.select(({query, entities}) => filterByQuery(entities, query, this.LANG_MAP))\n .pipe(map((entities: E[]) => entities.sort(compareById)))\n .pipe(distinctUntilChanged((pre, cur) => JSON.stringify(pre) === JSON.stringify(cur)));\n\n constructor(initialState: S) {\n super(initialState);\n this.getPage(this.entities$);\n this.getEntities(this.userId$);\n }\n\n setUserId = this.updater((state, userId: string) => ({...state, userId}));\n setEntities = this.updater((state, entities: E[]) => ({...state, entities}));\n setPage = this.updater((state, page: Page) => ({...state, page}));\n setIdSet = this.updater((state, idSet: Set<string>) => ({...state, idSet}));\n addId = this.updater((state, id: string) => ({...state, idSet: new Set([...state.idSet, id])}));\n removeId = this.updater((state, id: string) => {\n return {...state, idSet: new Set([...state.idSet].filter(_id => _id !== id))}\n });\n setQuery = this.updater((state, query: string) => ({...state, query}));\n\n getPage = this.effect((entities$: Observable<E[]>) => entities$.pipe(\n tap(({length}: E[]) => this.setPage(this.page.patch({length}))),\n ));\n\n getEntities = this.effect((userId$: Observable<string>) => userId$.pipe(\n filter(userId => !!userId),\n tap(() => this.loading.setKey('[/entities] Get Entities')),\n switchMap(() => this._getEntities()),\n tap((entities: E[]) => this.setEntities(entities)),\n tap(() => this.loading.removeKey('[/entities] Get Entities')),\n )); \n\n abstract _getEntities(): Observable<E[]>;\n abstract loading: LoadingService;\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAaA,MAAM,QAAQ,GAAG,CAAC,OAAqB,KAAK,IAAI,OAAO,CAAC,CAAO,OAAO,EAAE,MAAM;IAC5E,IAAI;QAAE,OAAO,CAAC,MAAM,OAAO,CAAC,CAAC;KAAE;IAAC,OAAO,KAAK,EAAE;QAAE,MAAM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