@rxap/material-table-system 12.5.0 → 12.5.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.
@@ -1,5 +1,6 @@
1
1
  import { Directive, NgModule, Input } from '@angular/core';
2
2
  import { MatPaginator } from '@angular/material/paginator';
3
+ import { tap } from 'rxjs/operators';
3
4
  import * as i0 from "@angular/core";
4
5
  import * as i1 from "@angular/material/paginator";
5
6
  export class PersistentPaginatorDirective {
@@ -11,9 +12,11 @@ export class PersistentPaginatorDirective {
11
12
  if (config) {
12
13
  this.matPaginator.pageSize = config.pageSize;
13
14
  }
15
+ this._subscription = this.matPaginator.page.pipe(tap(() => this.storeConfig())).subscribe();
14
16
  }
15
17
  ngOnDestroy() {
16
- this.storeConfig();
18
+ var _a;
19
+ (_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
17
20
  }
18
21
  getKey() {
19
22
  return 'rxap_mat-paginator-persistent' + this.id;
@@ -1 +1 @@
1
- {"version":3,"file":"persistent-paginator.directive.js","sourceRoot":"","sources":["../../../../../../libs/material/table-system/src/lib/persistent-paginator.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,QAAQ,EACR,KAAK,EAGN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;;;AAK3D,MAAM,OAAO,4BAA4B;IAKvC,YACmB,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAC1C,CAAC;IAEG,QAAQ;QACb,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACpC,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,YAAY,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;SAC9C;IACH,CAAC;IAEM,WAAW;QAChB,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAEM,MAAM;QACX,OAAO,+BAA+B,GAAG,IAAI,CAAC,EAAE,CAAC;IACnD,CAAC;IAEM,WAAW;QAChB,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;QAC5C,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IACpE,CAAC;IAEM,aAAa;QAClB,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAC1D,IAAI,aAAa,EAAE;YACjB,IAAI;gBACF,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;aAClC;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;aAC/E;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;;yHAvCU,4BAA4B;6GAA5B,4BAA4B;2FAA5B,4BAA4B;kBAHxC,SAAS;mBAAC;oBACT,QAAQ,EAAE,+BAA+B;iBAC1C;mGAIQ,EAAE;sBADR,KAAK;;AA6CR,MAAM,OAAO,kCAAkC;;+HAAlC,kCAAkC;gIAAlC,kCAAkC,iBA/ClC,4BAA4B,aAA5B,4BAA4B;gIA+C5B,kCAAkC;2FAAlC,kCAAkC;kBAJ9C,QAAQ;mBAAC;oBACR,OAAO,EAAE,CAAE,4BAA4B,CAAE;oBACzC,YAAY,EAAE,CAAE,4BAA4B,CAAE;iBAC/C","sourcesContent":["import {\n Directive,\n NgModule,\n Input,\n OnDestroy,\n OnInit\n} from '@angular/core';\nimport { MatPaginator } from '@angular/material/paginator';\n\n@Directive({\n selector: 'mat-paginator[rxapPersistent]'\n})\nexport class PersistentPaginatorDirective implements OnInit, OnDestroy {\n\n @Input()\n public id?: string;\n\n constructor(\n private readonly matPaginator: MatPaginator\n ) {}\n\n public ngOnInit() {\n const config = this.restoreConfig();\n if (config) {\n this.matPaginator.pageSize = config.pageSize;\n }\n }\n\n public ngOnDestroy() {\n this.storeConfig();\n }\n\n public getKey() {\n return 'rxap_mat-paginator-persistent' + this.id;\n }\n\n public storeConfig() {\n const pageSize = this.matPaginator.pageSize;\n localStorage.setItem(this.getKey(), JSON.stringify({ pageSize }));\n }\n\n public restoreConfig(): { pageSize: number } | null {\n const configStorage = localStorage.getItem(this.getKey());\n if (configStorage) {\n try {\n return JSON.parse(configStorage);\n } catch (e) {\n console.warn(`Could not parse mat paginator persistent config: ${e.message}`);\n }\n }\n return null;\n }\n\n}\n\n@NgModule({\n exports: [ PersistentPaginatorDirective ],\n declarations: [ PersistentPaginatorDirective ]\n})\nexport class PersistentPaginatorDirectiveModule {}\n"]}
1
+ {"version":3,"file":"persistent-paginator.directive.js","sourceRoot":"","sources":["../../../../../../libs/material/table-system/src/lib/persistent-paginator.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,QAAQ,EACR,KAAK,EAGN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;;;AAKrC,MAAM,OAAO,4BAA4B;IAOvC,YACmB,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAC1C,CAAC;IAEG,QAAQ;QACb,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACpC,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,YAAY,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;SAC9C;QACD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAC9C,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAC9B,CAAC,SAAS,EAAE,CAAA;IACf,CAAC;IAEM,WAAW;;QAChB,MAAA,IAAI,CAAC,aAAa,0CAAE,WAAW,EAAE,CAAC;IACpC,CAAC;IAEM,MAAM;QACX,OAAO,+BAA+B,GAAG,IAAI,CAAC,EAAE,CAAC;IACnD,CAAC;IAEM,WAAW;QAChB,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;QAC5C,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IACpE,CAAC;IAEM,aAAa;QAClB,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAC1D,IAAI,aAAa,EAAE;YACjB,IAAI;gBACF,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;aAClC;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;aAC/E;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;;yHA5CU,4BAA4B;6GAA5B,4BAA4B;2FAA5B,4BAA4B;kBAHxC,SAAS;mBAAC;oBACT,QAAQ,EAAE,+BAA+B;iBAC1C;mGAIQ,EAAE;sBADR,KAAK;;AAkDR,MAAM,OAAO,kCAAkC;;+HAAlC,kCAAkC;gIAAlC,kCAAkC,iBApDlC,4BAA4B,aAA5B,4BAA4B;gIAoD5B,kCAAkC;2FAAlC,kCAAkC;kBAJ9C,QAAQ;mBAAC;oBACR,OAAO,EAAE,CAAE,4BAA4B,CAAE;oBACzC,YAAY,EAAE,CAAE,4BAA4B,CAAE;iBAC/C","sourcesContent":["import {\n Directive,\n NgModule,\n Input,\n OnDestroy,\n OnInit\n} from '@angular/core';\nimport { MatPaginator } from '@angular/material/paginator';\nimport { Subscription } from 'rxjs';\nimport { tap } from 'rxjs/operators';\n\n@Directive({\n selector: 'mat-paginator[rxapPersistent]'\n})\nexport class PersistentPaginatorDirective implements OnInit, OnDestroy {\n\n @Input()\n public id?: string;\n\n private _subscription?: Subscription;\n\n constructor(\n private readonly matPaginator: MatPaginator,\n ) {}\n\n public ngOnInit() {\n const config = this.restoreConfig();\n if (config) {\n this.matPaginator.pageSize = config.pageSize;\n }\n this._subscription = this.matPaginator.page.pipe(\n tap(() => this.storeConfig())\n ).subscribe()\n }\n\n public ngOnDestroy() {\n this._subscription?.unsubscribe();\n }\n\n public getKey() {\n return 'rxap_mat-paginator-persistent' + this.id;\n }\n\n public storeConfig() {\n const pageSize = this.matPaginator.pageSize;\n localStorage.setItem(this.getKey(), JSON.stringify({ pageSize }));\n }\n\n public restoreConfig(): { pageSize: number } | null {\n const configStorage = localStorage.getItem(this.getKey());\n if (configStorage) {\n try {\n return JSON.parse(configStorage);\n } catch (e) {\n console.warn(`Could not parse mat paginator persistent config: ${e.message}`);\n }\n }\n return null;\n }\n\n}\n\n@NgModule({\n exports: [ PersistentPaginatorDirective ],\n declarations: [ PersistentPaginatorDirective ]\n})\nexport class PersistentPaginatorDirectiveModule {}\n"]}
@@ -713,9 +713,11 @@ class PersistentPaginatorDirective {
713
713
  if (config) {
714
714
  this.matPaginator.pageSize = config.pageSize;
715
715
  }
716
+ this._subscription = this.matPaginator.page.pipe(tap(() => this.storeConfig())).subscribe();
716
717
  }
717
718
  ngOnDestroy() {
718
- this.storeConfig();
719
+ var _a;
720
+ (_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
719
721
  }
720
722
  getKey() {
721
723
  return 'rxap_mat-paginator-persistent' + this.id;