@ng-atomic/common 1.1.0 → 1.3.0

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.
Files changed (112) hide show
  1. package/bundles/ng-atomic-common-directives-ios-safari-scroll-buggyfill.umd.js +94 -0
  2. package/bundles/ng-atomic-common-directives-ios-safari-scroll-buggyfill.umd.js.map +1 -0
  3. package/bundles/ng-atomic-common-directives-ios-safari-scroll-buggyfill.umd.min.js +2 -0
  4. package/bundles/ng-atomic-common-directives-ios-safari-scroll-buggyfill.umd.min.js.map +1 -0
  5. package/bundles/ng-atomic-common-directives.umd.js +3 -4
  6. package/bundles/ng-atomic-common-directives.umd.js.map +1 -1
  7. package/bundles/ng-atomic-common-directives.umd.min.js +1 -1
  8. package/bundles/ng-atomic-common-directives.umd.min.js.map +1 -1
  9. package/bundles/ng-atomic-common-pipes.umd.js +170 -26
  10. package/bundles/ng-atomic-common-pipes.umd.js.map +1 -1
  11. package/bundles/ng-atomic-common-pipes.umd.min.js +1 -1
  12. package/bundles/ng-atomic-common-pipes.umd.min.js.map +1 -1
  13. package/bundles/ng-atomic-common-services.umd.js +104 -4
  14. package/bundles/ng-atomic-common-services.umd.js.map +1 -1
  15. package/bundles/ng-atomic-common-services.umd.min.js +2 -2
  16. package/bundles/ng-atomic-common-services.umd.min.js.map +1 -1
  17. package/bundles/ng-atomic-common-store.umd.js +32 -7
  18. package/bundles/ng-atomic-common-store.umd.js.map +1 -1
  19. package/bundles/ng-atomic-common-store.umd.min.js +2 -2
  20. package/bundles/ng-atomic-common-store.umd.min.js.map +1 -1
  21. package/bundles/ng-atomic-common-utils.umd.js +59 -23
  22. package/bundles/ng-atomic-common-utils.umd.js.map +1 -1
  23. package/bundles/ng-atomic-common-utils.umd.min.js +16 -1
  24. package/bundles/ng-atomic-common-utils.umd.min.js.map +1 -1
  25. package/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.directive.d.ts +1 -3
  26. package/directives/ios-safari-scroll-buggyfill/ng-atomic-common-directives-ios-safari-scroll-buggyfill.d.ts +5 -0
  27. package/directives/ios-safari-scroll-buggyfill/package.json +10 -0
  28. package/esm2015/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.directive.js +3 -6
  29. package/esm2015/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.directive.js.map +1 -1
  30. package/esm2015/directives/ios-safari-scroll-buggyfill/ng-atomic-common-directives-ios-safari-scroll-buggyfill.js +5 -0
  31. package/esm2015/directives/ios-safari-scroll-buggyfill/ng-atomic-common-directives-ios-safari-scroll-buggyfill.js.map +1 -0
  32. package/esm2015/pipes/index.js +2 -0
  33. package/esm2015/pipes/index.js.map +1 -1
  34. package/esm2015/pipes/smart-clamp/index.js +3 -0
  35. package/esm2015/pipes/smart-clamp/index.js.map +1 -0
  36. package/esm2015/pipes/smart-clamp/smart-clamp.module.js +27 -0
  37. package/esm2015/pipes/smart-clamp/smart-clamp.module.js.map +1 -0
  38. package/esm2015/pipes/smart-clamp/smart-clamp.pipe.js +45 -0
  39. package/esm2015/pipes/smart-clamp/smart-clamp.pipe.js.map +1 -0
  40. package/esm2015/pipes/smart-exp/smart-exp.pipe.js +15 -15
  41. package/esm2015/pipes/smart-exp/smart-exp.pipe.js.map +1 -1
  42. package/esm2015/pipes/smart-sort-by/index.js +3 -0
  43. package/esm2015/pipes/smart-sort-by/index.js.map +1 -0
  44. package/esm2015/pipes/smart-sort-by/smart-sort-by.module.js +27 -0
  45. package/esm2015/pipes/smart-sort-by/smart-sort-by.module.js.map +1 -0
  46. package/esm2015/pipes/smart-sort-by/smart-sort-by.pipe.js +32 -0
  47. package/esm2015/pipes/smart-sort-by/smart-sort-by.pipe.js.map +1 -0
  48. package/esm2015/pipes/yen/yen.pipe.js +2 -2
  49. package/esm2015/pipes/yen/yen.pipe.js.map +1 -1
  50. package/esm2015/services/form/form.service.js +33 -0
  51. package/esm2015/services/form/form.service.js.map +1 -0
  52. package/esm2015/services/form/index.js +2 -0
  53. package/esm2015/services/form/index.js.map +1 -0
  54. package/esm2015/services/index.js +2 -0
  55. package/esm2015/services/index.js.map +1 -1
  56. package/esm2015/services/query-resolver/index.js +2 -0
  57. package/esm2015/services/query-resolver/index.js.map +1 -0
  58. package/esm2015/services/query-resolver/query-resolver.service.js +28 -0
  59. package/esm2015/services/query-resolver/query-resolver.service.js.map +1 -0
  60. package/esm2015/store/entities.page.store.js +19 -5
  61. package/esm2015/store/entities.page.store.js.map +1 -1
  62. package/esm2015/store/entity.page.store.js +1 -1
  63. package/esm2015/store/entity.page.store.js.map +1 -1
  64. package/esm2015/utils/date-utils/date-utils.js +13 -0
  65. package/esm2015/utils/date-utils/date-utils.js.map +1 -0
  66. package/esm2015/utils/date-utils/index.js +2 -0
  67. package/esm2015/utils/date-utils/index.js.map +1 -0
  68. package/esm2015/utils/index.js +3 -1
  69. package/esm2015/utils/index.js.map +1 -1
  70. package/esm2015/utils/query/query.resolver.js +16 -8
  71. package/esm2015/utils/query/query.resolver.js.map +1 -1
  72. package/esm2015/utils/smart-exp-transformer/index.js +2 -0
  73. package/esm2015/utils/smart-exp-transformer/index.js.map +1 -0
  74. package/esm2015/utils/smart-exp-transformer/smart-exp-transformer.js +18 -0
  75. package/esm2015/utils/smart-exp-transformer/smart-exp-transformer.js.map +1 -0
  76. package/fesm2015/ng-atomic-common-directives-ios-safari-scroll-buggyfill.js +55 -0
  77. package/fesm2015/ng-atomic-common-directives-ios-safari-scroll-buggyfill.js.map +1 -0
  78. package/fesm2015/ng-atomic-common-directives.js +3 -6
  79. package/fesm2015/ng-atomic-common-directives.js.map +1 -1
  80. package/fesm2015/ng-atomic-common-pipes.js +140 -23
  81. package/fesm2015/ng-atomic-common-pipes.js.map +1 -1
  82. package/fesm2015/ng-atomic-common-services.js +60 -2
  83. package/fesm2015/ng-atomic-common-services.js.map +1 -1
  84. package/fesm2015/ng-atomic-common-store.js +21 -5
  85. package/fesm2015/ng-atomic-common-store.js.map +1 -1
  86. package/fesm2015/ng-atomic-common-utils.js +46 -19
  87. package/fesm2015/ng-atomic-common-utils.js.map +1 -1
  88. package/package.json +3 -3
  89. package/pipes/index.d.ts +2 -0
  90. package/pipes/smart-clamp/index.d.ts +2 -0
  91. package/pipes/smart-clamp/smart-clamp.module.d.ts +8 -0
  92. package/pipes/smart-clamp/smart-clamp.pipe.d.ts +14 -0
  93. package/pipes/smart-exp/smart-exp.pipe.d.ts +4 -1
  94. package/pipes/smart-sort-by/index.d.ts +2 -0
  95. package/pipes/smart-sort-by/smart-sort-by.module.d.ts +8 -0
  96. package/pipes/smart-sort-by/smart-sort-by.pipe.d.ts +12 -0
  97. package/services/form/form.service.d.ts +7 -0
  98. package/services/form/index.d.ts +1 -0
  99. package/services/index.d.ts +2 -0
  100. package/services/query-resolver/index.d.ts +1 -0
  101. package/services/query-resolver/query-resolver.service.d.ts +9 -0
  102. package/store/entities.page.store.d.ts +11 -3
  103. package/store/entity.page.store.d.ts +2 -1
  104. package/utils/date-utils/date-utils.d.ts +10 -0
  105. package/utils/date-utils/index.d.ts +1 -0
  106. package/utils/index.d.ts +2 -1
  107. package/utils/query/query.resolver.d.ts +2 -1
  108. package/utils/smart-exp-transformer/index.d.ts +1 -0
  109. package/utils/smart-exp-transformer/smart-exp-transformer.d.ts +6 -0
  110. package/esm2015/utils/define-element.js +0 -10
  111. package/esm2015/utils/define-element.js.map +0 -1
  112. package/utils/define-element.d.ts +0 -2
@@ -1,9 +1,6 @@
1
- import { Directive, ElementRef, HostListener } from '@angular/core';
1
+ import { Directive, HostListener } from '@angular/core';
2
2
  import * as i0 from "@angular/core";
3
3
  export class IosSafariScrollBuggyfillDirective {
4
- constructor(el) {
5
- this.el = el;
6
- }
7
4
  ngAfterViewInit() {
8
5
  // this.el.nativeElement.addEventListener('touchmove', (e: Event) => {
9
6
  // e.preventDefault();
@@ -13,14 +10,14 @@ export class IosSafariScrollBuggyfillDirective {
13
10
  event.preventDefault();
14
11
  }
15
12
  }
16
- IosSafariScrollBuggyfillDirective.ɵfac = function IosSafariScrollBuggyfillDirective_Factory(t) { return new (t || IosSafariScrollBuggyfillDirective)(i0.ɵɵdirectiveInject(i0.ElementRef)); };
13
+ IosSafariScrollBuggyfillDirective.ɵfac = function IosSafariScrollBuggyfillDirective_Factory(t) { return new (t || IosSafariScrollBuggyfillDirective)(); };
17
14
  IosSafariScrollBuggyfillDirective.ɵdir = i0.ɵɵngDeclareDirective({ version: "11.2.14", type: IosSafariScrollBuggyfillDirective, selector: "[iosSafariScrollBuggyfill]", host: { listeners: { "touchmove": "onTouchmove($event)" } }, ngImport: i0 });
18
15
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IosSafariScrollBuggyfillDirective, [{
19
16
  type: Directive,
20
17
  args: [{
21
18
  selector: '[iosSafariScrollBuggyfill]'
22
19
  }]
23
- }], function () { return [{ type: i0.ElementRef }]; }, { onTouchmove: [{
20
+ }], null, { onTouchmove: [{
24
21
  type: HostListener,
25
22
  args: ['touchmove', ['$event']]
26
23
  }] }); })();
@@ -1 +1 @@
1
- {"version":3,"file":"ios-safari-scroll-buggyfill.directive.js","sourceRoot":"","sources":["../../../../../../libs/common/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;;AAKnF,MAAM,OAAO,iCAAiC;IAE5C,YAAoB,EAAc;QAAd,OAAE,GAAF,EAAE,CAAY;IAAI,CAAC;IAEvC,eAAe;QACb,sEAAsE;QACtE,wBAAwB;QACxB,wBAAwB;IAC1B,CAAC;IAGD,WAAW,CAAC,KAAY;QACtB,KAAK,CAAC,cAAc,EAAE,CAAC;IACzB,CAAC;;kHAbU,iCAAiC;6FAAjC,iCAAiC;uFAAjC,iCAAiC;cAH7C,SAAS;eAAC;gBACT,QAAQ,EAAE,4BAA4B;aACvC;6DAYC,WAAW;kBADV,YAAY;mBAAC,WAAW,EAAE,CAAC,QAAQ,CAAC","sourcesContent":["import { AfterViewInit, Directive, ElementRef, HostListener } from '@angular/core';\n\n@Directive({\n selector: '[iosSafariScrollBuggyfill]'\n})\nexport class IosSafariScrollBuggyfillDirective implements AfterViewInit {\n\n constructor(private el: ElementRef) { }\n\n ngAfterViewInit(): void {\n // this.el.nativeElement.addEventListener('touchmove', (e: Event) => {\n // e.preventDefault();\n // }, {passive: false});\n }\n\n @HostListener('touchmove', ['$event'])\n onTouchmove(event: Event) {\n event.preventDefault();\n }\n\n}\n"]}
1
+ {"version":3,"file":"ios-safari-scroll-buggyfill.directive.js","sourceRoot":"","sources":["../../../../../../libs/common/directives/ios-safari-scroll-buggyfill/ios-safari-scroll-buggyfill.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;;AAKvE,MAAM,OAAO,iCAAiC;IAE5C,eAAe;QACb,sEAAsE;QACtE,wBAAwB;QACxB,wBAAwB;IAC1B,CAAC;IAGD,WAAW,CAAC,KAAY;QACtB,KAAK,CAAC,cAAc,EAAE,CAAC;IACzB,CAAC;;kHAXU,iCAAiC;6FAAjC,iCAAiC;uFAAjC,iCAAiC;cAH7C,SAAS;eAAC;gBACT,QAAQ,EAAE,4BAA4B;aACvC;gBAUC,WAAW;kBADV,YAAY;mBAAC,WAAW,EAAE,CAAC,QAAQ,CAAC","sourcesContent":["import { AfterViewInit, Directive, HostListener } from '@angular/core';\n\n@Directive({\n selector: '[iosSafariScrollBuggyfill]'\n})\nexport class IosSafariScrollBuggyfillDirective implements AfterViewInit {\n\n ngAfterViewInit(): void {\n // this.el.nativeElement.addEventListener('touchmove', (e: Event) => {\n // e.preventDefault();\n // }, {passive: false});\n }\n\n @HostListener('touchmove', ['$event'])\n onTouchmove(event: Event) {\n event.preventDefault();\n }\n\n}\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ export * from './index';
5
+ //# sourceMappingURL=ng-atomic-common-directives-ios-safari-scroll-buggyfill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ng-atomic-common-directives-ios-safari-scroll-buggyfill.js","sourceRoot":"","sources":["../../../../../../libs/common/directives/ios-safari-scroll-buggyfill/ng-atomic-common-directives-ios-safari-scroll-buggyfill.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC","sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"]}
@@ -1,5 +1,7 @@
1
1
  export * from './domain';
2
+ export * from './smart-clamp';
2
3
  export * from './smart-exp';
4
+ export * from './smart-sort-by';
3
5
  export * from './smart-field';
4
6
  export * from './yen';
5
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/common/pipes/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC","sourcesContent":["export * from './domain';\nexport * from './smart-exp';\nexport * from './smart-field';\nexport * from './yen';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/common/pipes/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC","sourcesContent":["export * from './domain';\nexport * from './smart-clamp';\nexport * from './smart-exp';\nexport * from './smart-sort-by';\nexport * from './smart-field';\nexport * from './yen';\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './smart-clamp.module';
2
+ export * from './smart-clamp.pipe';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/common/pipes/smart-clamp/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './smart-clamp.module';\nexport * from './smart-clamp.pipe';\n"]}
@@ -0,0 +1,27 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { SmartClampPipe } from './smart-clamp.pipe';
4
+ import * as i0 from "@angular/core";
5
+ export class SmartClampModule {
6
+ }
7
+ SmartClampModule.ɵfac = function SmartClampModule_Factory(t) { return new (t || SmartClampModule)(); };
8
+ SmartClampModule.ɵmod = i0.ɵɵdefineNgModule({ type: SmartClampModule });
9
+ SmartClampModule.ɵinj = i0.ɵɵdefineInjector({ imports: [[
10
+ CommonModule,
11
+ ]] });
12
+ (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(SmartClampModule, { declarations: [SmartClampPipe], imports: [CommonModule], exports: [SmartClampPipe] }); })();
13
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SmartClampModule, [{
14
+ type: NgModule,
15
+ args: [{
16
+ declarations: [
17
+ SmartClampPipe
18
+ ],
19
+ imports: [
20
+ CommonModule,
21
+ ],
22
+ exports: [
23
+ SmartClampPipe
24
+ ]
25
+ }]
26
+ }], null, null); })();
27
+ //# sourceMappingURL=smart-clamp.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smart-clamp.module.js","sourceRoot":"","sources":["../../../../../../libs/common/pipes/smart-clamp/smart-clamp.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;;AAepD,MAAM,OAAO,gBAAgB;;gFAAhB,gBAAgB;oDAAhB,gBAAgB;wDAPlB;YACP,YAAY;SACb;wFAKU,gBAAgB,mBATzB,cAAc,aAGd,YAAY,aAGZ,cAAc;uFAGL,gBAAgB;cAX5B,QAAQ;eAAC;gBACR,YAAY,EAAE;oBACZ,cAAc;iBACf;gBACD,OAAO,EAAE;oBACP,YAAY;iBACb;gBACD,OAAO,EAAE;oBACP,cAAc;iBACf;aACF","sourcesContent":["import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { SmartClampPipe } from './smart-clamp.pipe';\n\n\n\n@NgModule({\n declarations: [\n SmartClampPipe\n ],\n imports: [\n CommonModule,\n ],\n exports: [\n SmartClampPipe\n ]\n})\nexport class SmartClampModule { }\n"]}
@@ -0,0 +1,45 @@
1
+ import { SlicePipe } from '@angular/common';
2
+ import { Inject, Optional, Pipe } from '@angular/core';
3
+ import { smartSortByTransformer, SMART_SORT_BY_TRANSFORMER } from '../smart-sort-by';
4
+ import * as i0 from "@angular/core";
5
+ export class SmartClampPipe {
6
+ constructor(transformer) {
7
+ var _a;
8
+ this.transformer = transformer;
9
+ this.slicePipe = new SlicePipe();
10
+ this._input = null;
11
+ this._output = [];
12
+ (_a = this.transformer) !== null && _a !== void 0 ? _a : (this.transformer = smartSortByTransformer);
13
+ }
14
+ transform(items, store) {
15
+ const input = {
16
+ items,
17
+ sortKey: store.sortKey,
18
+ sortOrder: store.sortOrder,
19
+ start: store.page.start,
20
+ end: store.page.end,
21
+ };
22
+ if (JSON.stringify(input) === JSON.stringify(this._input)) {
23
+ return this._output;
24
+ }
25
+ this._input = input;
26
+ items = this.transformer(items, store === null || store === void 0 ? void 0 : store.sortKey, store === null || store === void 0 ? void 0 : store.sortOrder);
27
+ items = this.slicePipe.transform(items, store.page.start, store.page.end);
28
+ return this._output = items;
29
+ }
30
+ }
31
+ SmartClampPipe.ɵfac = function SmartClampPipe_Factory(t) { return new (t || SmartClampPipe)(i0.ɵɵdirectiveInject(SMART_SORT_BY_TRANSFORMER, 8)); };
32
+ SmartClampPipe.ɵpipe = i0.ɵɵngDeclarePipe({ version: "11.2.14", ngImport: i0, type: SmartClampPipe, name: "smartClamp", pure: false });
33
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SmartClampPipe, [{
34
+ type: Pipe,
35
+ args: [{
36
+ name: 'smartClamp',
37
+ pure: false,
38
+ }]
39
+ }], function () { return [{ type: undefined, decorators: [{
40
+ type: Optional
41
+ }, {
42
+ type: Inject,
43
+ args: [SMART_SORT_BY_TRANSFORMER]
44
+ }] }]; }, null); })();
45
+ //# sourceMappingURL=smart-clamp.pipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smart-clamp.pipe.js","sourceRoot":"","sources":["../../../../../../libs/common/pipes/smart-clamp/smart-clamp.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAiB,MAAM,eAAe,CAAC;AAEtE,OAAO,EAAE,sBAAsB,EAA0B,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;;AAM7G,MAAM,OAAO,cAAc;IAKzB,YAGU,WAAoC;;QAApC,gBAAW,GAAX,WAAW,CAAyB;QAPtC,cAAS,GAAG,IAAI,SAAS,EAAE,CAAC;QAC5B,WAAM,GAAG,IAAI,CAAC;QACd,YAAO,GAAG,EAAE,CAAC;QAOnB,MAAA,IAAI,CAAC,WAAW,oCAAhB,IAAI,CAAC,WAAW,GAAK,sBAAsB,EAAC;IAC9C,CAAC;IAED,SAAS,CAAI,KAAU,EAAE,KAAkC;QACzD,MAAM,KAAK,GAAG;YACZ,KAAK;YACL,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK;YACvB,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG;SACpB,CAAC;QAEF,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;YACzD,OAAO,IAAI,CAAC,OAAO,CAAC;SACrB;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAA2B,CAAC,CAAC;QACpF,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1E,OAAO,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IAC9B,CAAC;;4EA9BU,cAAc,uBAOf,yBAAyB;oFAPxB,cAAc;uFAAd,cAAc;cAJ1B,IAAI;eAAC;gBACJ,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,KAAK;aACZ;;sBAOI,QAAQ;;sBACR,MAAM;uBAAC,yBAAyB","sourcesContent":["import { SlicePipe } from '@angular/common';\nimport { Inject, Optional, Pipe, PipeTransform } from '@angular/core';\nimport { EntitiesPageStore } from '@ng-atomic/common/store';\nimport { smartSortByTransformer, SmartSortByTransformer, SMART_SORT_BY_TRANSFORMER } from '../smart-sort-by';\n\n@Pipe({\n name: 'smartClamp',\n pure: false,\n})\nexport class SmartClampPipe implements PipeTransform {\n private slicePipe = new SlicePipe();\n private _input = null;\n private _output = [];\n\n constructor(\n @Optional()\n @Inject(SMART_SORT_BY_TRANSFORMER)\n private transformer?: SmartSortByTransformer,\n ) {\n this.transformer ??= smartSortByTransformer;\n }\n\n transform<T>(items: T[], store: EntitiesPageStore<any, any>): T[] {\n const input = {\n items, \n sortKey: store.sortKey, \n sortOrder: store.sortOrder, \n start: store.page.start,\n end: store.page.end,\n };\n \n if (JSON.stringify(input) === JSON.stringify(this._input)) {\n return this._output;\n }\n\n this._input = input;\n items = this.transformer(items, store?.sortKey, store?.sortOrder as 'asc' | 'desc');\n items = this.slicePipe.transform(items, store.page.start, store.page.end);\n return this._output = items;\n }\n}\n"]}
@@ -1,22 +1,17 @@
1
- import { Pipe } from '@angular/core';
2
- import * as dayjs from 'dayjs';
3
- import { YenPipe } from '../yen/yen.pipe';
1
+ import { Inject, Optional, Pipe } from '@angular/core';
2
+ import { SMART_EXP_TRANSFORMER, smartExpTransformer } from '@ng-atomic/common/utils';
4
3
  import * as i0 from "@angular/core";
5
4
  export class SmartExpPipe {
5
+ constructor(transformer) {
6
+ var _a;
7
+ this.transformer = transformer;
8
+ (_a = this.transformer) !== null && _a !== void 0 ? _a : (this.transformer = smartExpTransformer);
9
+ }
6
10
  transform(input, key) {
7
- if (dayjs.isDayjs(input)) {
8
- return input.format('YY/MM/DD');
9
- }
10
- else if (Array.isArray(input)) {
11
- return `${input.length}個のアイテム`;
12
- }
13
- else if (typeof input === 'number' && input > 10000) {
14
- return new YenPipe().transform(input);
15
- }
16
- return input;
11
+ return this.transformer(input, key);
17
12
  }
18
13
  }
19
- SmartExpPipe.ɵfac = function SmartExpPipe_Factory(t) { return new (t || SmartExpPipe)(); };
14
+ SmartExpPipe.ɵfac = function SmartExpPipe_Factory(t) { return new (t || SmartExpPipe)(i0.ɵɵdirectiveInject(SMART_EXP_TRANSFORMER, 8)); };
20
15
  SmartExpPipe.ɵpipe = i0.ɵɵngDeclarePipe({ version: "11.2.14", ngImport: i0, type: SmartExpPipe, name: "smartExp" });
21
16
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SmartExpPipe, [{
22
17
  type: Pipe,
@@ -24,5 +19,10 @@ SmartExpPipe.ɵpipe = i0.ɵɵngDeclarePipe({ version: "11.2.14", ngImport: i0, t
24
19
  name: 'smartExp',
25
20
  pure: true,
26
21
  }]
27
- }], null, null); })();
22
+ }], function () { return [{ type: undefined, decorators: [{
23
+ type: Optional
24
+ }, {
25
+ type: Inject,
26
+ args: [SMART_EXP_TRANSFORMER]
27
+ }] }]; }, null); })();
28
28
  //# sourceMappingURL=smart-exp.pipe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"smart-exp.pipe.js","sourceRoot":"","sources":["../../../../../../libs/common/pipes/smart-exp/smart-exp.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;;AAM1C,MAAM,OAAO,YAAY;IACvB,SAAS,CAAC,KAA0C,EAAE,GAAY;QAChE,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACxB,OAAO,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;SACjC;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC/B,OAAO,GAAG,KAAK,CAAC,MAAM,QAAQ,CAAC;SAChC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,GAAG,KAAM,EAAE;YACtD,OAAO,IAAI,OAAO,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;SACvC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;;wEAVU,YAAY;kFAAZ,YAAY;uFAAZ,YAAY;cAJxB,IAAI;eAAC;gBACJ,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,IAAI;aACX","sourcesContent":["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}"]}
1
+ {"version":3,"file":"smart-exp.pipe.js","sourceRoot":"","sources":["../../../../../../libs/common/pipes/smart-exp/smart-exp.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAuB,MAAM,yBAAyB,CAAC;;AAM1G,MAAM,OAAO,YAAY;IACvB,YACqD,WAAgC;;QAAhC,gBAAW,GAAX,WAAW,CAAqB;QAEnF,MAAA,IAAI,CAAC,WAAW,oCAAhB,IAAI,CAAC,WAAW,GAAK,mBAAmB,EAAC;IAC3C,CAAC;IAED,SAAS,CAAC,KAA0C,EAAE,GAAY;QAChE,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACtC,CAAC;;wEATU,YAAY,uBAED,qBAAqB;kFAFhC,YAAY;uFAAZ,YAAY;cAJxB,IAAI;eAAC;gBACJ,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,IAAI;aACX;;sBAGI,QAAQ;;sBAAI,MAAM;uBAAC,qBAAqB","sourcesContent":["import { Inject, Optional, Pipe } from '@angular/core';\nimport * as dayjs from 'dayjs';\nimport { SMART_EXP_TRANSFORMER, smartExpTransformer, SmartExpTransformer } from '@ng-atomic/common/utils';\n\n@Pipe({\n name: 'smartExp',\n pure: true,\n})\nexport class SmartExpPipe {\n constructor(\n @Optional() @Inject(SMART_EXP_TRANSFORMER) private transformer: SmartExpTransformer\n ) {\n this.transformer ??= smartExpTransformer;\n }\n\n transform(input: string | number | dayjs.Dayjs | any, key?: string): string {\n return this.transformer(input, key);\n }\n}"]}
@@ -0,0 +1,3 @@
1
+ export * from './smart-sort-by.module';
2
+ export * from './smart-sort-by.pipe';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/common/pipes/smart-sort-by/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC","sourcesContent":["export * from './smart-sort-by.module';\nexport * from './smart-sort-by.pipe';\n"]}
@@ -0,0 +1,27 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { SmartSortByPipe } from './smart-sort-by.pipe';
4
+ import * as i0 from "@angular/core";
5
+ export class SmartSortByModule {
6
+ }
7
+ SmartSortByModule.ɵfac = function SmartSortByModule_Factory(t) { return new (t || SmartSortByModule)(); };
8
+ SmartSortByModule.ɵmod = i0.ɵɵdefineNgModule({ type: SmartSortByModule });
9
+ SmartSortByModule.ɵinj = i0.ɵɵdefineInjector({ imports: [[
10
+ CommonModule
11
+ ]] });
12
+ (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(SmartSortByModule, { declarations: [SmartSortByPipe], imports: [CommonModule], exports: [SmartSortByPipe] }); })();
13
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SmartSortByModule, [{
14
+ type: NgModule,
15
+ args: [{
16
+ declarations: [
17
+ SmartSortByPipe
18
+ ],
19
+ imports: [
20
+ CommonModule
21
+ ],
22
+ exports: [
23
+ SmartSortByPipe
24
+ ]
25
+ }]
26
+ }], null, null); })();
27
+ //# sourceMappingURL=smart-sort-by.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smart-sort-by.module.js","sourceRoot":"","sources":["../../../../../../libs/common/pipes/smart-sort-by/smart-sort-by.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;;AAevD,MAAM,OAAO,iBAAiB;;kFAAjB,iBAAiB;qDAAjB,iBAAiB;yDAPnB;YACP,YAAY;SACb;wFAKU,iBAAiB,mBAT1B,eAAe,aAGf,YAAY,aAGZ,eAAe;uFAGN,iBAAiB;cAX7B,QAAQ;eAAC;gBACR,YAAY,EAAE;oBACZ,eAAe;iBAChB;gBACD,OAAO,EAAE;oBACP,YAAY;iBACb;gBACD,OAAO,EAAE;oBACP,eAAe;iBAChB;aACF","sourcesContent":["import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { SmartSortByPipe } from './smart-sort-by.pipe';\n\n\n\n@NgModule({\n declarations: [\n SmartSortByPipe\n ],\n imports: [\n CommonModule\n ],\n exports: [\n SmartSortByPipe\n ]\n})\nexport class SmartSortByModule { }\n"]}
@@ -0,0 +1,32 @@
1
+ import { Inject, InjectionToken, Optional, Pipe } from '@angular/core';
2
+ import { sortBy } from 'lodash';
3
+ import * as i0 from "@angular/core";
4
+ export const SMART_SORT_BY_TRANSFORMER = new InjectionToken('[@ng-atomic/common] Smart Sort By Transformer');
5
+ export const smartSortByTransformer = (items, key, order) => {
6
+ return order === 'asc' ? sortBy(items, key) : sortBy(items, key).reverse();
7
+ };
8
+ export class SmartSortByPipe {
9
+ constructor(transformer) {
10
+ var _a;
11
+ this.transformer = transformer;
12
+ (_a = this.transformer) !== null && _a !== void 0 ? _a : (this.transformer = smartSortByTransformer);
13
+ }
14
+ transform(items, key, order = 'asc') {
15
+ return this.transformer(items, key, order);
16
+ }
17
+ }
18
+ SmartSortByPipe.ɵfac = function SmartSortByPipe_Factory(t) { return new (t || SmartSortByPipe)(i0.ɵɵdirectiveInject(SMART_SORT_BY_TRANSFORMER, 8)); };
19
+ SmartSortByPipe.ɵpipe = i0.ɵɵngDeclarePipe({ version: "11.2.14", ngImport: i0, type: SmartSortByPipe, name: "smartSortBy" });
20
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SmartSortByPipe, [{
21
+ type: Pipe,
22
+ args: [{
23
+ name: 'smartSortBy',
24
+ pure: true,
25
+ }]
26
+ }], function () { return [{ type: undefined, decorators: [{
27
+ type: Optional
28
+ }, {
29
+ type: Inject,
30
+ args: [SMART_SORT_BY_TRANSFORMER]
31
+ }] }]; }, null); })();
32
+ //# sourceMappingURL=smart-sort-by.pipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smart-sort-by.pipe.js","sourceRoot":"","sources":["../../../../../../libs/common/pipes/smart-sort-by/smart-sort-by.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAiB,MAAM,eAAe,CAAC;AACtF,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;AAEhC,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,cAAc,CAAC,+CAA+C,CAAC,CAAC;AAE7G,MAAM,CAAC,MAAM,sBAAsB,GAA2B,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;IAClF,OAAO,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;AAC7E,CAAC,CAAA;AAMD,MAAM,OAAO,eAAe;IAE1B,YAGU,WAAoC;;QAApC,gBAAW,GAAX,WAAW,CAAyB;QAE5C,MAAA,IAAI,CAAC,WAAW,oCAAhB,IAAI,CAAC,WAAW,GAAK,sBAAsB,EAAC;IAC9C,CAAC;IAED,SAAS,CAAI,KAAU,EAAE,GAAW,EAAE,QAAwB,KAAK;QACjE,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC;;8EAZU,eAAe,uBAIhB,yBAAyB;qFAJxB,eAAe;uFAAf,eAAe;cAJ3B,IAAI;eAAC;gBACJ,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,IAAI;aACX;;sBAII,QAAQ;;sBACR,MAAM;uBAAC,yBAAyB","sourcesContent":["import { Inject, InjectionToken, Optional, Pipe, PipeTransform } from '@angular/core';\nimport { sortBy } from 'lodash';\n\nexport const SMART_SORT_BY_TRANSFORMER = new InjectionToken('[@ng-atomic/common] Smart Sort By Transformer');\nexport type SmartSortByTransformer = <T>(items: T[], key: string, order: 'asc' | 'desc') => T[];\nexport const smartSortByTransformer: SmartSortByTransformer = (items, key, order) => {\n return order === 'asc' ? sortBy(items, key) : sortBy(items, key).reverse();\n}\n\n@Pipe({\n name: 'smartSortBy',\n pure: true,\n})\nexport class SmartSortByPipe implements PipeTransform {\n\n constructor(\n @Optional()\n @Inject(SMART_SORT_BY_TRANSFORMER)\n private transformer?: SmartSortByTransformer,\n ) {\n this.transformer ??= smartSortByTransformer;\n }\n\n transform<T>(items: T[], key: string, order: 'asc' | 'desc' = 'asc'): T[] {\n return this.transformer(items, key, order);\n }\n\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  import { Pipe } from '@angular/core';
2
- import { comma } from '@ng-atomic/common/utils';
2
+ import { yenTransform } from '@ng-atomic/common/utils';
3
3
  import * as i0 from "@angular/core";
4
4
  export class YenPipe {
5
5
  transform(value, _unit) {
6
- return value < 1 ? `${comma(value * 100)}%` : `${comma(value)}円`;
6
+ return yenTransform(value, _unit);
7
7
  }
8
8
  }
9
9
  YenPipe.ɵfac = function YenPipe_Factory(t) { return new (t || YenPipe)(); };
@@ -1 +1 @@
1
- {"version":3,"file":"yen.pipe.js","sourceRoot":"","sources":["../../../../../../libs/common/pipes/yen/yen.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAiB,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;;AAKhD,MAAM,OAAO,OAAO;IAElB,SAAS,CAAC,KAAa,EAAE,KAAc;QACrC,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;IACnE,CAAC;;8DAJU,OAAO;6EAAP,OAAO;uFAAP,OAAO;cAHnB,IAAI;eAAC;gBACJ,IAAI,EAAE,KAAK;aACZ","sourcesContent":["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"]}
1
+ {"version":3,"file":"yen.pipe.js","sourceRoot":"","sources":["../../../../../../libs/common/pipes/yen/yen.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAiB,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;;AAKvD,MAAM,OAAO,OAAO;IAElB,SAAS,CAAC,KAAa,EAAE,KAAc;QACrC,OAAO,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;;8DAJU,OAAO;6EAAP,OAAO;uFAAP,OAAO;cAHnB,IAAI;eAAC;gBACJ,IAAI,EAAE,KAAK;aACZ","sourcesContent":["import { Pipe, PipeTransform } from '@angular/core';\nimport { yenTransform } 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 yenTransform(value, _unit);\n }\n\n}\n"]}
@@ -0,0 +1,33 @@
1
+ import { toObject, isIsoString } from '@ng-atomic/common/utils';
2
+ import * as dayjs from 'dayjs';
3
+ import { unflatten, flatten } from 'flat';
4
+ import { omit, pick } from 'lodash';
5
+ const isNumeric = (v) => !isNaN(Number(v));
6
+ const parseQuery = (v, k) => k.match(/id$/i)
7
+ ? v
8
+ : typeof v === 'string' && isIsoString(v)
9
+ ? dayjs(v)
10
+ : isNumeric(v)
11
+ ? Number(v)
12
+ : v;
13
+ export class BaseFormService {
14
+ static fromQueryParams(obj) {
15
+ var _a, _b;
16
+ return Object.entries((_b = (_a = unflatten(obj)) === null || _a === void 0 ? void 0 : _a.form) !== null && _b !== void 0 ? _b : {}).reduce((m, [k, v]) => (Object.assign(Object.assign({}, m), { [k]: parseQuery(v, k) })), {});
17
+ }
18
+ static toQueryParams(obj) {
19
+ return flatten({ form: Object.entries(obj).reduce((m, [k, v]) => (Object.assign(Object.assign({}, m), { [k]: dayjs.isDayjs(v) ? v.isValid() ? v.toISOString() : null : v })), {}) });
20
+ }
21
+ static dayjsKeys(object) {
22
+ return Object.entries(object).filter(([_, v]) => dayjs.isDayjs(v)).map(([k]) => k);
23
+ }
24
+ static toValue(object) {
25
+ const keys = this.dayjsKeys(object);
26
+ return Object.assign(Object.assign({}, flatten(omit(toObject(object), keys))), pick(toObject(object), keys));
27
+ }
28
+ static fromValue(value) {
29
+ const keys = this.dayjsKeys(value);
30
+ return Object.assign(Object.assign({}, unflatten(omit(value, keys))), pick(value, keys));
31
+ }
32
+ }
33
+ //# sourceMappingURL=form.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form.service.js","sourceRoot":"","sources":["../../../../../../libs/common/services/form/form.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,SAAS,GAAG,CAAC,CAAS,EAAW,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AAE3D,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,CAAS,EAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;IAC/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AAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACrF,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,MAAc;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACpC,uCAAW,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,GAAK,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE;IACrF,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,KAAa;QAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACnC,uCAAW,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,GAAK,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE;IACjE,CAAC;CACF","sourcesContent":["import { toObject, isIsoString } from '@ng-atomic/common/utils';\nimport * as dayjs from 'dayjs';\nimport { unflatten, flatten } from 'flat';\nimport { omit, pick } from 'lodash';\n\nconst isNumeric = (v: string): boolean => !isNaN(Number(v)) \n\nconst parseQuery = (v: string, k: string): any => k.match(/id$/i) \n ? v\n : typeof v === 'string' && isIsoString(v) \n ? dayjs(v) \n : isNumeric(v)\n ? Number(v)\n : v;\n\nexport class BaseFormService {\n static fromQueryParams<T>(obj: T): object {\n return Object.entries((unflatten(obj) as any)?.form ?? {}).reduce((m, [k, v]: [string, string]) => ({\n ...m, [k]: parseQuery(v, k),\n }), {});\n }\n\n static toQueryParams<T>(obj: object): T { \n return flatten({form: Object.entries(obj).reduce((m, [k, v]) => ({\n ...m, [k]: dayjs.isDayjs(v) ? v.isValid() ? v.toISOString() : null : v,\n }), {})});\n }\n\n static dayjsKeys(object: object): string[] {\n return Object.entries(object).filter(([_, v]) => dayjs.isDayjs(v)).map(([k]) => k);\n }\n\n static toValue(object: object): object {\n const keys = this.dayjsKeys(object);\n return {...flatten(omit(toObject(object), keys)), ...pick(toObject(object), keys)};\n }\n\n static fromValue(value: object): object {\n const keys = this.dayjsKeys(value);\n return {...unflatten(omit(value, keys)), ...pick(value, keys)};\n }\n}"]}
@@ -0,0 +1,2 @@
1
+ export * from './form.service';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/common/services/form/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC","sourcesContent":["export * from './form.service';\n"]}
@@ -1,3 +1,5 @@
1
+ export * from './form';
1
2
  export * from './loading';
3
+ export * from './query-resolver';
2
4
  export * from './snack-bar';
3
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/common/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC","sourcesContent":["export * from './loading';\nexport * from './snack-bar';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/common/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC","sourcesContent":["export * from './form';\nexport * from './loading';\nexport * from './query-resolver';\nexport * from './snack-bar';\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './query-resolver.service';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/common/services/query-resolver/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC","sourcesContent":["export * from './query-resolver.service';\n"]}
@@ -0,0 +1,28 @@
1
+ import { Inject, Injectable, Optional } from "@angular/core";
2
+ import { filterByQuery } from "@ng-atomic/common/utils";
3
+ import { smartExpTransformer, SMART_EXP_TRANSFORMER } from '@ng-atomic/common/utils';
4
+ import * as i0 from "@angular/core";
5
+ export class QueryResolverService {
6
+ constructor(transformer) {
7
+ var _a;
8
+ this.transformer = transformer;
9
+ (_a = this.transformer) !== null && _a !== void 0 ? _a : (this.transformer = smartExpTransformer);
10
+ }
11
+ resolve(items, queryString, dlm = {}) {
12
+ return filterByQuery(items, queryString, dlm, this.transformer);
13
+ }
14
+ }
15
+ QueryResolverService.ɵfac = function QueryResolverService_Factory(t) { return new (t || QueryResolverService)(i0.ɵɵinject(SMART_EXP_TRANSFORMER, 8)); };
16
+ QueryResolverService.ɵprov = i0.ɵɵdefineInjectable({ token: QueryResolverService, factory: QueryResolverService.ɵfac, providedIn: 'root' });
17
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(QueryResolverService, [{
18
+ type: Injectable,
19
+ args: [{
20
+ providedIn: 'root'
21
+ }]
22
+ }], function () { return [{ type: undefined, decorators: [{
23
+ type: Optional
24
+ }, {
25
+ type: Inject,
26
+ args: [SMART_EXP_TRANSFORMER]
27
+ }] }]; }, null); })();
28
+ //# sourceMappingURL=query-resolver.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-resolver.service.js","sourceRoot":"","sources":["../../../../../../libs/common/services/query-resolver/query-resolver.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAuB,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;;AAM1G,MAAM,OAAO,oBAAoB;IAC/B,YACqD,WAAiC;;QAAjC,gBAAW,GAAX,WAAW,CAAsB;QAEpF,MAAA,IAAI,CAAC,WAAW,oCAAhB,IAAI,CAAC,WAAW,GAAK,mBAAmB,EAAC;IAC3C,CAAC;IAED,OAAO,CAAI,KAAU,EAAE,WAAmB,EAAE,MAA8B,EAAE;QAC1E,OAAO,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAClE,CAAC;;wFATU,oBAAoB,cAET,qBAAqB;4DAFhC,oBAAoB,WAApB,oBAAoB,mBAFnB,MAAM;uFAEP,oBAAoB;cAHhC,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB;;sBAGI,QAAQ;;sBAAI,MAAM;uBAAC,qBAAqB","sourcesContent":["import { Inject, Injectable, Optional } from \"@angular/core\";\nimport { filterByQuery } from \"@ng-atomic/common/utils\";\nimport { SmartExpTransformer, smartExpTransformer, SMART_EXP_TRANSFORMER } from '@ng-atomic/common/utils';\n\n\n@Injectable({\n providedIn: 'root'\n})\nexport class QueryResolverService {\n constructor(\n @Optional() @Inject(SMART_EXP_TRANSFORMER) private transformer?: SmartExpTransformer,\n ) {\n this.transformer ??= smartExpTransformer;\n }\n\n resolve<T>(items: T[], queryString: string, dlm: Record<string, string> = {}): T[] {\n return filterByQuery(items, queryString, dlm, this.transformer);\n }\n}"]}
@@ -1,30 +1,44 @@
1
1
  import { ComponentStore } from '@ngrx/component-store';
2
- // import { Page } from '../components/templates/smart-index';
3
- import { filterByQuery } from '@ng-atomic/common/utils';
2
+ import { QueryResolverService } from '@ng-atomic/common/services';
4
3
  import { compareById } from '@ng-atomic/common/utils';
5
4
  import { distinctUntilChanged, tap, map, filter, switchMap } from 'rxjs/operators';
6
5
  export class EntitiesPageStore extends ComponentStore {
7
- constructor(initialState) {
6
+ constructor(initialState, queryResolver = new QueryResolverService()) {
8
7
  super(initialState);
8
+ this.queryResolver = queryResolver;
9
9
  this.userId$ = this.select(state => state.userId).pipe(filter(userId => !!userId));
10
- this.entities$ = this.select(({ query, entities }) => filterByQuery(entities, query, this.LANG_MAP))
10
+ this.entities$ = this.select(({ query, entities }) => this.queryResolver.resolve(entities, query, this.LANG_MAP))
11
11
  .pipe(map((entities) => entities.sort(compareById)))
12
12
  .pipe(distinctUntilChanged((pre, cur) => JSON.stringify(pre) === JSON.stringify(cur)));
13
13
  this.setUserId = this.updater((state, userId) => (Object.assign(Object.assign({}, state), { userId })));
14
14
  this.setEntities = this.updater((state, entities) => (Object.assign(Object.assign({}, state), { entities })));
15
15
  this.setPage = this.updater((state, page) => (Object.assign(Object.assign({}, state), { page })));
16
16
  this.setIdSet = this.updater((state, idSet) => (Object.assign(Object.assign({}, state), { idSet })));
17
+ this.setSortKey = this.updater((state, sortKey) => (Object.assign(Object.assign({}, state), { sortKey })));
18
+ this.setSortOrder = this.updater((state, sortOrder) => (Object.assign(Object.assign({}, state), { sortOrder })));
17
19
  this.addId = this.updater((state, id) => (Object.assign(Object.assign({}, state), { idSet: new Set([...state.idSet, id]) })));
18
20
  this.removeId = this.updater((state, id) => {
19
21
  return Object.assign(Object.assign({}, state), { idSet: new Set([...state.idSet].filter(_id => _id !== id)) });
20
22
  });
21
23
  this.setQuery = this.updater((state, query) => (Object.assign(Object.assign({}, state), { query })));
22
24
  this.getPage = this.effect((entities$) => entities$.pipe(tap(({ length }) => this.setPage(this.page.patch({ length })))));
23
- 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'))));
25
+ this.getEntities = this.effect((userId$) => userId$.pipe(filter(userId => !!userId), tap(() => this.loading.setKey('[/entities] Get Entities')), switchMap((userId) => this._getEntities({ userId })), tap((entities) => this.setEntities(entities)), tap(() => this.loading.removeKey('[/entities] Get Entities'))));
24
26
  this.getPage(this.entities$);
25
27
  this.getEntities(this.userId$);
26
28
  }
27
29
  get page() { return this.get(state => state.page); }
30
+ get sortKey() { return this.get(state => state.sortKey); }
31
+ get sortOrder() { return this.get(state => state.sortOrder); }
28
32
  get idSet() { return this.get(state => state.idSet); }
33
+ changeSortFromEvent(name) {
34
+ if (name === this.sortKey) {
35
+ const order = this.sortOrder === 'asc' ? 'desc' : 'asc';
36
+ this.setSortOrder(order);
37
+ }
38
+ else {
39
+ this.setSortKey(name);
40
+ this.setSortOrder('asc');
41
+ }
42
+ }
29
43
  }
30
44
  //# sourceMappingURL=entities.page.store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"entities.page.store.js","sourceRoot":"","sources":["../../../../../libs/common/store/entities.page.store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,8DAA8D;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAYnF,MAAM,OAAgB,iBAA0E,SAAQ,cAAiB;IAWvH,YAAY,YAAe;QACzB,KAAK,CAAC,YAAY,CAAC,CAAC;QANtB,YAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9E,cAAS,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAC,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;aAC1F,IAAI,CAAC,GAAG,CAAC,CAAC,QAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;aACxD,IAAI,CAAC,oBAAoB,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAA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M,CAAC,CAAC,SAA0B,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAClE,GAAG,CAAC,CAAC,EAAC,MAAM,EAAM,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC,CAAC,CAChE,CAAC,CAAC;QAEH,gBAAW,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,OAA2B,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CACrE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAC1B,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC,EAC1D,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,EACpC,GAAG,CAAC,CAAC,QAAa,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,EAClD,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,0BAA0B,CAAC,CAAC,CAC9D,CAAC,CAAC;QAxBD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAZD,IAAI,IAAI,KAAW,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC1D,IAAI,KAAK,KAAkB,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;CAqCpE","sourcesContent":["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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,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAClE,IAAI,SAAS,KAAa,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACtE,IAAI,KAAK,KAAkB,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAwCnE,mBAAmB,CAAC,IAAY;QAC9B,IAAI,IAAI,KAAK,IAAI,CAAC,OAAO,EAAE;YACzB,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;YACxD,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;SAC1B;aAAM;YACL,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YACtB,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;SAC1B;IACH,CAAC;CAIF","sourcesContent":["import { ComponentStore } from '@ngrx/component-store';\nimport { LoadingService, QueryResolverService } from '@ng-atomic/common/services';\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 sortKey?: string;\n sortOrder?: 'asc' | 'desc';\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 sortKey(): string { return this.get(state => state.sortKey); }\n get sortOrder(): string { return this.get(state => state.sortOrder); }\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}) => this.queryResolver.resolve(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(\n initialState: S,\n public queryResolver = new QueryResolverService(),\n ) {\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 setSortKey = this.updater((state, sortKey: string) => ({...state, sortKey}));\n setSortOrder = this.updater((state, sortOrder: 'asc' | 'desc') => ({...state, sortOrder}));\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((userId) => this._getEntities({userId})),\n tap((entities: E[]) => this.setEntities(entities)),\n tap(() => this.loading.removeKey('[/entities] Get Entities')),\n )); \n\n changeSortFromEvent(name: string) {\n if (name === this.sortKey) {\n const order = this.sortOrder === 'asc' ? 'desc' : 'asc';\n this.setSortOrder(order);\n } else {\n this.setSortKey(name);\n this.setSortOrder('asc');\n }\n }\n\n abstract _getEntities(data?: object): Observable<E[]>;\n abstract loading: LoadingService;\n}"]}
@@ -1,7 +1,7 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { ComponentStore } from '@ngrx/component-store';
3
3
  import { filter, switchMap, tap } from 'rxjs/operators';
4
- const tryCatch = (promise) => new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
4
+ export const tryCatch = (promise) => new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
5
5
  try {
6
6
  resolve(yield promise);
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"entity.page.store.js","sourceRoot":"","sources":["../../../../../libs/common/store/entity.page.store.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAUxD,MAAM,QAAQ,GAAG,CAAC,OAAqB,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAO,OAAO,EAAE,MAAM,EAAE,EAAE;IAChF,IAAI;QAAE,OAAO,CAAC,MAAM,OAAO,CAAC,CAAC;KAAE;IAAC,OAAO,KAAK,EAAE;QAAE,MAAM,CAAC,KAAK,CAAC,CAAC;KAAE;AAClE,CAAC,CAAA,CAAC,CAAC;AAEH,MAAM,OAAgB,eAA2D,SAAQ,cAAiB;IAWxG,YAAY,YAAgB;QAC1B,KAAK,CAAC,YAAY,CAAC,CAAC;QATtB,UAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzC,cAAS,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1E,YAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAE7C,YAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,IAAU,EAAE,EAAE,CAAC,iCAAK,KAAK,KAAE,IAAI,IAAE,CAAC,CA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AAI,CAAC,OAAO,CAAC,MAAM,CAAC,yCAAyC,CAAC,CAAC;QAE/D,OAAO,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;aACxC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;aAChF,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,yCAAyC,CAAC,CAAC,CAAC;IACtF,CAAC;IAED,YAAY,CAAC,KAAsB;QACjC,MAAM,MAAM,GAAW,iCAAK,IAAI,CAAC,MAAM,GAAK,KAAK,EAAE,CAAC;QAEpD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,yCAAyC,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;aAC9B,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;aAChF,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,yCAAyC,CAAC,CAAC,CAAC;IACtF,CAAC;CASF","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"]}
1
+ {"version":3,"file":"entity.page.store.js","sourceRoot":"","sources":["../../../../../libs/common/store/entity.page.store.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE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AAC,OAAO,CAAC,SAAS,CAAC,yCAAyC,CAAC,CAAC,CAAC;IACtF,CAAC;IAED,YAAY,CAAC,KAAsB;QACjC,MAAM,MAAM,GAAW,iCAAK,IAAI,CAAC,MAAM,GAAK,KAAK,EAAE,CAAC;QAEpD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,yCAAyC,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;aAC9B,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;aAChF,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,yCAAyC,CAAC,CAAC,CAAC;IACtF,CAAC;CASF","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\nexport const 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 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(idOrParams: 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"]}
@@ -0,0 +1,13 @@
1
+ import * as dayjs from 'dayjs';
2
+ export const removeComma = (str) => str.replace(/\,/g, '');
3
+ export const DATE_FORMAT = 'YYYY-MM-DDTHH:mm:ss';
4
+ const DATE_REGEX = /^[0-9]{4}\/(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])$/;
5
+ const DATETIME_REGEX = /^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\+([+-][0-2]\d:[0-5]\d)$/;
6
+ export const isDateStr = (str) => str && !!str.match(DATE_REGEX);
7
+ export const isDateTimeStr = (str) => str && !!str.match(DATE_REGEX);
8
+ const ISO_REGEX = /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/;
9
+ export const isIsoString = (str) => str && !!str.match(ISO_REGEX);
10
+ export function timestampToDayjs(timestamp) {
11
+ return timestamp ? dayjs(timestamp.toDate()) : null;
12
+ }
13
+ //# sourceMappingURL=date-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-utils.js","sourceRoot":"","sources":["../../../../../../libs/common/utils/date-utils/date-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAEnE,MAAM,CAAC,MAAM,WAAW,GAAG,qBAAqB,CAAC;AACjD,MAAM,UAAU,GAAG,uDAAuD,CAAC;AAC3E,MAAM,cAAc,GAAG,uEAAuE,CAAC;AAC/F,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAkB,EAAiB,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AAC/F,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAkB,EAAiB,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AAEnG,MAAM,SAAS,GAAG,0EAA0E,CAAC;AAC7F,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAkB,EAAiB,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAOhG,MAAM,UAAU,gBAAgB,CAAC,SAA2B;IAC1D,OAAO,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACtD,CAAC","sourcesContent":["import * as dayjs from 'dayjs';\n\nexport const removeComma = (str: string) => str.replace(/\\,/g, '');\n\nexport const DATE_FORMAT = 'YYYY-MM-DDTHH:mm:ss';\nconst DATE_REGEX = /^[0-9]{4}\\/(0[1-9]|1[0-2])\\/(0[1-9]|[12][0-9]|3[01])$/;\nconst DATETIME_REGEX = /^\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d\\+([+-][0-2]\\d:[0-5]\\d)$/;\nexport const isDateStr = (str: string | null): str is string => str && !!str.match(DATE_REGEX);\nexport const isDateTimeStr = (str: string | null): str is string => str && !!str.match(DATE_REGEX);\n\nconst ISO_REGEX = /\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d\\.\\d+([+-][0-2]\\d:[0-5]\\d|Z)/;\nexport const isIsoString = (str: string | null): str is string => str && !!str.match(ISO_REGEX);\n\n\nexport interface Timestamp {\n toDate: () => Date;\n}\n\nexport function timestampToDayjs(timestamp: Timestamp | null): dayjs.Dayjs | null {\n return timestamp ? dayjs(timestamp.toDate()) : null;\n}"]}
@@ -0,0 +1,2 @@
1
+ export * from './date-utils';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/common/utils/date-utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC","sourcesContent":["export * from './date-utils';"]}
@@ -1,7 +1,9 @@
1
1
  export * from './comma';
2
2
  export * from './compare-by-id';
3
+ export * from './date-utils';
3
4
  export * from './mat-dayjs-date';
5
+ export * from './smart-exp-transformer';
4
6
  export * from './to-object';
5
7
  export * from './query';
6
- export * from './define-element';
8
+ // export * from './define-element';
7
9
  //# sourceMappingURL=index.js.map