@geosdi/ngx-primeng-modal-service 1.1.14 → 2.0.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.
package/README.md CHANGED
@@ -1,24 +1,125 @@
1
- # NgxPrimengModalService
1
+ # @geosdi/ngx-primeng-modal-service
2
2
 
3
- This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 15.2.0.
3
+ Opens PrimeNG dynamic dialogs by **type**: the application maps each type to a component, a header
4
+ and a size once, and then opens a dialog with the type alone. The header is a translation key, and
5
+ only one dialog is open at a time.
4
6
 
5
- ## Code scaffolding
7
+ ## Installation
6
8
 
7
- Run `ng generate component component-name --project ngx-primeng-modal-service` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ngx-primeng-modal-service`.
8
- > Note: Don't forget to add `--project ngx-primeng-modal-service` or else it will be added to the default project in your `angular.json` file.
9
+ `npm i @geosdi/ngx-primeng-modal-service --save`
9
10
 
10
- ## Build
11
+ Peer dependencies:
11
12
 
12
- Run `ng build ngx-primeng-modal-service` to build the project. The build artifacts will be stored in the `dist/` directory.
13
+ "@angular/common": ">=22.0.0",
14
+ "@angular/core": ">=22.0.0",
15
+ "primeng": ">=22.0.0",
16
+ "@ngx-translate/core": ">=16.0.0",
17
+ "rxjs": ">=7.4.0"
13
18
 
14
- ## Publishing
19
+ ## Usage
15
20
 
16
- After building your library with `ng build ngx-primeng-modal-service`, go to the dist folder `cd dist/ngx-primeng-modal-service` and run `npm publish`.
21
+ Extend `NgxPrimeNgModalService` and describe each type in `createModalComponent`. The service
22
+ injects PrimeNG's **`DialogService`**, which PrimeNG does not provide in `root`: provide it where
23
+ the service lives, and a configured `TranslateService` as well.
17
24
 
18
- ## Running unit tests
25
+ ```typescript
26
+ import { Injectable } from "@angular/core";
27
+ import {
28
+ NgxModalWindow,
29
+ NgxPrimeNgModalService,
30
+ } from "@geosdi/ngx-primeng-modal-service";
19
31
 
20
- Run `ng test ngx-primeng-modal-service` to execute the unit tests via [Karma](https://karma-runner.github.io).
32
+ @Injectable({ providedIn: "root" })
33
+ export class AppModalService extends NgxPrimeNgModalService {
34
+ protected createModalComponent(modalType: string): NgxModalWindow {
35
+ switch (modalType) {
36
+ case "user":
37
+ return {
38
+ component: UserFormComponent,
39
+ header: "users.edit",
40
+ width: "50vw",
41
+ breakpoints: { "960px": "90vw" },
42
+ onClosedFunction: () => this.reloadUsers(),
43
+ };
44
+ default:
45
+ return { component: NotFoundComponent, header: "modal.not_found" };
46
+ }
47
+ }
48
+ }
49
+ ```
21
50
 
22
- ## Further help
51
+ ```typescript
52
+ // bootstrapApplication providers
53
+ providers: [DialogService /* from primeng/dynamicdialog */];
23
54
 
24
- To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
55
+ // anywhere
56
+ const modals = inject(AppModalService);
57
+ modals.getModal("user", { data: { id: 42 } });
58
+ // or, with the same effect
59
+ modals.subjectOpenModal$.next({
60
+ modalType: "user",
61
+ config: { data: { id: 42 } },
62
+ });
63
+ ```
64
+
65
+ The opened component reads `data` from `DynamicDialogConfig` and closes itself with
66
+ `DynamicDialogRef`, as with any PrimeNG dynamic dialog.
67
+
68
+ ## API
69
+
70
+ ### `NgxPrimeNgModalService` (abstract)
71
+
72
+ | member | what it does |
73
+ | ----------------------------- | --------------------------------------------------------------------- |
74
+ | `getModal(modalType, config)` | closes the open dialog, if any, and opens the one of that type |
75
+ | `subjectOpenModal$` | `next({ modalType, config })` does the same as `getModal` |
76
+ | `close()` | closes the open dialog |
77
+ | `createModalComponent(type)` | **abstract**: describes a type; called **once** per type, then cached |
78
+
79
+ ### `NgxModalWindow`
80
+
81
+ | field | what it is |
82
+ | ------------------ | ----------------------------------------------- |
83
+ | `component` | **required**, the component shown in the dialog |
84
+ | `header` | **required**, translation key of the header |
85
+ | `width`, `height` | the dialog size |
86
+ | `styleClass` | css class of the dialog |
87
+ | `breakpoints` | PrimeNG `breakpoints` |
88
+ | `modal` | default `true` |
89
+ | `onClosedFunction` | called when the dialog closes |
90
+
91
+ ## Things to know
92
+
93
+ - **The `config` you pass is changed in place**, and its `styleClass`, `width`, `height`,
94
+ `breakpoints`, `modal` and `header` are always overwritten with those of the `NgxModalWindow` —
95
+ with `undefined` when the window does not set them. Anything else (`data`, `inputValues`,
96
+ `closable`, `motionOptions`…) reaches PrimeNG as it is.
97
+ - The header is translated once, when the dialog opens: changing language does not change it.
98
+
99
+ ## Known defects, not fixed
100
+
101
+ - **The first dialog may throw if the translations are not loaded yet.** The dialog is opened
102
+ inside the subscription to `translate.get(header)`, while the close callback is attached right
103
+ after it to the last dialog reference. When `get` answers later — the translation file still
104
+ loading — that reference is `undefined` on the first call
105
+ (`Cannot read properties of undefined (reading 'onClose')`), and on later calls it is the
106
+ previous dialog, so `onClosedFunction` is lost.
107
+ - **Opening a type while its dialog is still open may throw.** `getModal` closes the dialog and
108
+ opens the same component again at once; PrimeNG 22's `DialogService.open` returns `null` for a
109
+ component that is still among its open dialogs, unless the config has `duplicate: true`, and the
110
+ service then reads `onClose` of `null`. This follows from PrimeNG's code (the dialog is removed
111
+ only when it is destroyed) and has not been reproduced.
112
+
113
+ ## Changes in 2.0.0
114
+
115
+ - **A major version** because the peer dependencies now ask for Angular 22: an application on an
116
+ older Angular can no longer install it. The API is unchanged unless a point below says otherwise.
117
+ - **The peer dependencies on Angular and PrimeNG are `>=22.0.0`** (`primeng` included): the library
118
+ is compiled and tested with these versions only, so it no longer claims to install on older ones.
119
+ - Compiled with Angular 22 and PrimeNG 22.
120
+ - **The dialog no longer forces a 300 ms opening transition.** The service used to set
121
+ `transitionOptions: "300ms cubic-bezier(0, 0, 0.2, 1)"` on every dialog; PrimeNG 22 removed the
122
+ option, so the line is gone. The dialogs open with PrimeNG's default animation; to change it, pass
123
+ `motionOptions` in the config.
124
+ - Peer dependencies: `rxjs` added, since the code imports it. The package now has a description.
125
+ - This README, which replaces the one generated by Angular CLI.
@@ -1,63 +1,38 @@
1
- import { DialogService } from 'primeng/dynamicdialog';
2
- import { inject } from '@angular/core';
3
- import { TranslateService } from '@ngx-translate/core';
4
- import { Subject, take } from 'rxjs';
5
-
6
- class NgxPrimeNgModalService {
7
- constructor() {
8
- this.subjectOpenModal$ = new Subject();
9
- this.modalsMap = new Map();
10
- this.translate = inject(TranslateService);
11
- this.dialogService = inject(DialogService);
12
- this.subjectOpenModal$.subscribe((res) => {
13
- this.getModal(res.modalType, res.config);
14
- });
15
- }
16
- /**
17
- *
18
- * @param modalType
19
- * @param dialogService
20
- * @param config
21
- */
22
- getModal(modalType, config) {
23
- this.close();
24
- if (!this.modalsMap.has(modalType)) {
25
- this.modalsMap.set(modalType, this.createModalComponent(modalType));
26
- }
27
- const m = this.modalsMap.get(modalType);
28
- config.styleClass = m.styleClass;
29
- config.height = m.height;
30
- config.width = m.width;
31
- config.breakpoints = m.breakpoints;
32
- config.modal = m.modal !== undefined ? m.modal : true;
33
- config.transitionOptions = "300ms cubic-bezier(0, 0, 0.2, 1)";
34
- this.translate.get(m.header).subscribe((res) => {
35
- config.header = res;
36
- this.ref = this.dialogService.open(m.component, config);
37
- });
38
- this.ref.onClose.pipe(take(1)).subscribe(() => {
39
- if (m.onClosedFunction) {
40
- m.onClosedFunction();
41
- }
42
- });
43
- }
44
- /**
45
- *
46
- */
47
- close() {
48
- if (this.ref) {
49
- this.ref.close();
50
- }
51
- }
52
- }
53
-
54
- /*
55
- * Public API Surface of ngx-primeng-modal-service
56
- */
57
-
58
- /**
59
- * Generated bundle index. Do not edit.
60
- */
61
-
1
+ import { DialogService } from "primeng/dynamicdialog";
2
+ import { inject } from "@angular/core";
3
+ import { TranslateService } from "@ngx-translate/core";
4
+ import { Subject, take } from "rxjs";
5
+ var NgxPrimeNgModalService = class {
6
+ constructor() {
7
+ this.subjectOpenModal$ = new Subject();
8
+ this.modalsMap = /* @__PURE__ */ new Map();
9
+ this.translate = inject(TranslateService);
10
+ this.dialogService = inject(DialogService);
11
+ this.subjectOpenModal$.subscribe((res) => {
12
+ this.getModal(res.modalType, res.config);
13
+ });
14
+ }
15
+ getModal(modalType, config) {
16
+ this.close();
17
+ if (!this.modalsMap.has(modalType)) this.modalsMap.set(modalType, this.createModalComponent(modalType));
18
+ const m = this.modalsMap.get(modalType);
19
+ config.styleClass = m.styleClass;
20
+ config.height = m.height;
21
+ config.width = m.width;
22
+ config.breakpoints = m.breakpoints;
23
+ config.modal = m.modal !== void 0 ? m.modal : true;
24
+ this.translate.get(m.header).subscribe((res) => {
25
+ config.header = res;
26
+ this.ref = this.dialogService.open(m.component, config);
27
+ });
28
+ this.ref.onClose.pipe(take(1)).subscribe(() => {
29
+ if (m.onClosedFunction) m.onClosedFunction();
30
+ });
31
+ }
32
+ close() {
33
+ if (this.ref) this.ref.close();
34
+ }
35
+ };
62
36
  export { NgxPrimeNgModalService };
63
- //# sourceMappingURL=geosdi-ngx-primeng-modal-service.mjs.map
37
+
38
+ //# sourceMappingURL=geosdi-ngx-primeng-modal-service.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"geosdi-ngx-primeng-modal-service.mjs","sources":["../../../../projects/geosdi/components/ngx-primeng-modal-service/src/lib/ngx-primeng-modal.service.ts","../../../../projects/geosdi/components/ngx-primeng-modal-service/src/index.ts","../../../../projects/geosdi/components/ngx-primeng-modal-service/src/geosdi-ngx-primeng-modal-service.ts"],"sourcesContent":["import {\n DialogService,\n DynamicDialogConfig,\n DynamicDialogRef,\n} from \"primeng/dynamicdialog\";\nimport { Type, inject } from \"@angular/core\";\nimport { TranslateService } from \"@ngx-translate/core\";\nimport { Subject, take } from \"rxjs\";\n\n/**\n * @author Vito Salvia - CNR IMAA geoSDI Group\n * @email vito.salvia@gmail.com\n */\n\nexport interface NgxModalWindow {\n component: Type<any>;\n header: string;\n height?: string;\n width?: string;\n styleClass?: string;\n modal?: boolean | undefined;\n onClosedFunction?: any | undefined;\n breakpoints?: any;\n}\n\nexport abstract class NgxPrimeNgModalService {\n subjectOpenModal$: Subject<{\n modalType: any;\n config: DynamicDialogConfig;\n }> = new Subject<{ modalType: any; config: DynamicDialogConfig }>();\n private modalsMap: Map<string, NgxModalWindow> = new Map<\n string,\n NgxModalWindow\n >();\n private ref: DynamicDialogRef;\n private translate: TranslateService;\n private dialogService: DialogService;\n\n constructor() {\n this.translate = inject(TranslateService);\n this.dialogService = inject(DialogService);\n this.subjectOpenModal$.subscribe(\n (res: { modalType: any; config: DynamicDialogConfig }) => {\n this.getModal(res.modalType, res.config);\n },\n );\n }\n\n /**\n *\n * @param modalType\n * @param dialogService\n * @param config\n */\n public getModal(modalType: any, config: DynamicDialogConfig) {\n this.close();\n if (!this.modalsMap.has(modalType)) {\n this.modalsMap.set(modalType, this.createModalComponent(modalType));\n }\n const m: NgxModalWindow = this.modalsMap.get(modalType);\n config.styleClass = m.styleClass;\n config.height = m.height;\n config.width = m.width;\n config.breakpoints = m.breakpoints;\n config.modal = m.modal !== undefined ? m.modal : true;\n config.transitionOptions = \"300ms cubic-bezier(0, 0, 0.2, 1)\";\n this.translate.get(m.header).subscribe((res) => {\n config.header = res;\n this.ref = this.dialogService.open(m.component, config);\n });\n this.ref.onClose.pipe(take(1)).subscribe(() => {\n if (m.onClosedFunction) {\n m.onClosedFunction();\n }\n });\n }\n\n /**\n *\n */\n public close() {\n if (this.ref) {\n this.ref.close();\n }\n }\n\n /**\n *\n * @param modalType\n * @protected\n */\n protected abstract createModalComponent(modalType: any): NgxModalWindow;\n}\n","/*\n * Public API Surface of ngx-primeng-modal-service\n */\n\nexport * from \"./lib/ngx-primeng-modal.service\";\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;MAyBsB,sBAAsB,CAAA;AAaxC,IAAA,WAAA,GAAA;AAZA,QAAA,IAAA,CAAA,iBAAiB,GAGZ,IAAI,OAAO,EAAmD;AAC3D,QAAA,IAAA,CAAA,SAAS,GAAgC,IAAI,GAAG,EAGrD;AAMC,QAAA,IAAI,CAAC,SAAS,GA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,SAAC,CAAC;AACF,QAAA,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAK;AAC1C,YAAA,IAAI,CAAC,CAAC,gBAAgB,EAAE;gBACpB,CAAC,CAAC,gBAAgB,EAAE;;AAE5B,SAAC,CAAC;;AAGN;;AAEG;IACI,KAAK,GAAA;AACR,QAAA,IAAI,IAAI,CAAC,GAAG,EAAE;AACV,YAAA,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE;;;AAU3B;;AC5FD;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"geosdi-ngx-primeng-modal-service.mjs","names":[],"sources":["../../../../projects/geosdi/components/ngx-primeng-modal-service/src/lib/ngx-primeng-modal.service.ts"],"sourcesContent":["import {\n DialogService,\n DynamicDialogConfig,\n DynamicDialogRef,\n} from \"primeng/dynamicdialog\";\nimport { Type, inject } from \"@angular/core\";\nimport { TranslateService } from \"@ngx-translate/core\";\nimport { Subject, take } from \"rxjs\";\n\n/**\n * @author Vito Salvia - CNR IMAA geoSDI Group\n * @email vito.salvia@gmail.com\n */\n\nexport interface NgxModalWindow {\n component: Type<any>;\n header: string;\n height?: string;\n width?: string;\n styleClass?: string;\n modal?: boolean | undefined;\n onClosedFunction?: any | undefined;\n breakpoints?: any;\n}\n\nexport abstract class NgxPrimeNgModalService {\n subjectOpenModal$: Subject<{\n modalType: any;\n config: DynamicDialogConfig;\n }> = new Subject<{ modalType: any; config: DynamicDialogConfig }>();\n private modalsMap: Map<string, NgxModalWindow> = new Map<\n string,\n NgxModalWindow\n >();\n private ref: DynamicDialogRef;\n private translate: TranslateService;\n private dialogService: DialogService;\n\n constructor() {\n this.translate = inject(TranslateService);\n this.dialogService = inject(DialogService);\n this.subjectOpenModal$.subscribe(\n (res: { modalType: any; config: DynamicDialogConfig }) => {\n this.getModal(res.modalType, res.config);\n },\n );\n }\n\n /**\n *\n * @param modalType\n * @param dialogService\n * @param config\n */\n public getModal(modalType: any, config: DynamicDialogConfig) {\n this.close();\n if (!this.modalsMap.has(modalType)) {\n this.modalsMap.set(modalType, this.createModalComponent(modalType));\n }\n const m: NgxModalWindow = this.modalsMap.get(modalType);\n config.styleClass = m.styleClass;\n config.height = m.height;\n config.width = m.width;\n config.breakpoints = m.breakpoints;\n config.modal = m.modal !== undefined ? m.modal : true;\n // PrimeNG 22 ha tolto transitionOptions : durata e curva dell'apertura stanno nel css\n // del tema, e chi le vuole diverse passa motionOptions nella config, che arriva così com'è.\n this.translate.get(m.header).subscribe((res) => {\n config.header = res;\n this.ref = this.dialogService.open(m.component, config);\n });\n this.ref.onClose.pipe(take(1)).subscribe(() => {\n if (m.onClosedFunction) {\n m.onClosedFunction();\n }\n });\n }\n\n /**\n *\n */\n public close() {\n if (this.ref) {\n this.ref.close();\n }\n }\n\n /**\n *\n * @param modalType\n * @protected\n */\n protected abstract createModalComponent(modalType: any): NgxModalWindow;\n}\n"],"mappings":";;;;AAyBA,IAAsB,yBAAtB,MAA4C;CAaxC,cAAA;EAZA,KAAA,oBAGK,IAAI,QAAO;EACR,KAAA,4BAAyC,IAAI,IAAG;EASpD,KAAK,YAAY,OAAO,gBAAgB;EACxC,KAAK,gBAAgB,OAAO,aAAa;EACzC,KAAK,kBAAkB,WAClB,QAAwD;GACrD,KAAK,SAAS,IAAI,WAAW,IAAI,MAAM;EAC3C,CAAC;CAET;CAQO,SAAS,WAAgB,QAA2B;EACvD,KAAK,MAAK;EACV,IAAI,CAAC,KAAK,UAAU,IAAI,SAAS,GAC7B,KAAK,UAAU,IAAI,WAAW,KAAK,qBAAqB,SAAS,CAAC;EAEtE,MAAM,IAAoB,KAAK,UAAU,IAAI,SAAS;EACtD,OAAO,aAAa,EAAE;EACtB,OAAO,SAAS,EAAE;EAClB,OAAO,QAAQ,EAAE;EACjB,OAAO,cAAc,EAAE;EACvB,OAAO,QAAQ,EAAE,UAAU,SAAY,EAAE,QAAQ;EAGjD,KAAK,UAAU,IAAI,EAAE,MAAM,CAAC,CAAC,WAAW,QAAO;GAC3C,OAAO,SAAS;GAChB,KAAK,MAAM,KAAK,cAAc,KAAK,EAAE,WAAW,MAAM;EAC1D,CAAC;EACD,KAAK,IAAI,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,gBAAe;GAC1C,IAAI,EAAE,kBACF,EAAE,iBAAgB;EAE1B,CAAC;CACL;CAKO,QAAK;EACR,IAAI,KAAK,KACL,KAAK,IAAI,MAAK;CAEtB;AAQH"}
package/package.json CHANGED
@@ -1,26 +1,27 @@
1
1
  {
2
2
  "name": "@geosdi/ngx-primeng-modal-service",
3
- "version": "1.1.14",
3
+ "version": "2.0.0",
4
+ "description": "Open PrimeNG dynamic dialogs by type, with a translated header and shared defaults",
4
5
  "peerDependencies": {
5
- "@angular/common": ">=19.0.0",
6
- "@angular/core": ">=19.0.0",
7
- "primeng": ">=17.0.0",
8
- "@ngx-translate/core": ">=16.0.0"
6
+ "@angular/common": ">=22.0.0",
7
+ "@angular/core": ">=22.0.0",
8
+ "primeng": ">=22.0.0",
9
+ "@ngx-translate/core": ">=16.0.0",
10
+ "rxjs": ">=7.4.0"
9
11
  },
10
12
  "sideEffects": false,
11
13
  "module": "fesm2022/geosdi-ngx-primeng-modal-service.mjs",
12
- "typings": "index.d.ts",
14
+ "typings": "types/geosdi-ngx-primeng-modal-service.d.ts",
13
15
  "exports": {
14
16
  "./package.json": {
15
17
  "default": "./package.json"
16
18
  },
17
19
  ".": {
18
- "types": "./index.d.ts",
19
- "esm2022": "./esm2022/geosdi-ngx-primeng-modal-service.mjs",
20
- "esm": "./esm2022/geosdi-ngx-primeng-modal-service.mjs",
20
+ "types": "./types/geosdi-ngx-primeng-modal-service.d.ts",
21
21
  "default": "./fesm2022/geosdi-ngx-primeng-modal-service.mjs"
22
22
  }
23
23
  },
24
+ "type": "module",
24
25
  "dependencies": {
25
26
  "tslib": "^2.3.0"
26
27
  }
@@ -0,0 +1,45 @@
1
+ import { DynamicDialogConfig } from "primeng/dynamicdialog";
2
+ import { Type } from "@angular/core";
3
+ import { Subject } from "rxjs";
4
+ /**
5
+ * @author Vito Salvia - CNR IMAA geoSDI Group
6
+ * @email vito.salvia@gmail.com
7
+ */
8
+ export interface NgxModalWindow {
9
+ component: Type<any>;
10
+ header: string;
11
+ height?: string;
12
+ width?: string;
13
+ styleClass?: string;
14
+ modal?: boolean | undefined;
15
+ onClosedFunction?: any | undefined;
16
+ breakpoints?: any;
17
+ }
18
+ export declare abstract class NgxPrimeNgModalService {
19
+ subjectOpenModal$: Subject<{
20
+ modalType: any;
21
+ config: DynamicDialogConfig;
22
+ }>;
23
+ private modalsMap;
24
+ private ref;
25
+ private translate;
26
+ private dialogService;
27
+ constructor();
28
+ /**
29
+ *
30
+ * @param modalType
31
+ * @param dialogService
32
+ * @param config
33
+ */
34
+ getModal(modalType: any, config: DynamicDialogConfig): void;
35
+ /**
36
+ *
37
+ */
38
+ close(): void;
39
+ /**
40
+ *
41
+ * @param modalType
42
+ * @protected
43
+ */
44
+ protected abstract createModalComponent(modalType: any): NgxModalWindow;
45
+ }
@@ -1,5 +0,0 @@
1
- /**
2
- * Generated bundle index. Do not edit.
3
- */
4
- export * from './index';
5
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2Vvc2RpLW5neC1wcmltZW5nLW1vZGFsLXNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9nZW9zZGkvY29tcG9uZW50cy9uZ3gtcHJpbWVuZy1tb2RhbC1zZXJ2aWNlL3NyYy9nZW9zZGktbmd4LXByaW1lbmctbW9kYWwtc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsU0FBUyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL2luZGV4JztcbiJdfQ==
package/esm2022/index.mjs DELETED
@@ -1,5 +0,0 @@
1
- /*
2
- * Public API Surface of ngx-primeng-modal-service
3
- */
4
- export * from "./lib/ngx-primeng-modal.service";
5
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9nZW9zZGkvY29tcG9uZW50cy9uZ3gtcHJpbWVuZy1tb2RhbC1zZXJ2aWNlL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsaUNBQWlDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKlxuICogUHVibGljIEFQSSBTdXJmYWNlIG9mIG5neC1wcmltZW5nLW1vZGFsLXNlcnZpY2VcbiAqL1xuXG5leHBvcnQgKiBmcm9tIFwiLi9saWIvbmd4LXByaW1lbmctbW9kYWwuc2VydmljZVwiO1xuIl19
@@ -1,52 +0,0 @@
1
- import { DialogService, } from "primeng/dynamicdialog";
2
- import { inject } from "@angular/core";
3
- import { TranslateService } from "@ngx-translate/core";
4
- import { Subject, take } from "rxjs";
5
- export class NgxPrimeNgModalService {
6
- constructor() {
7
- this.subjectOpenModal$ = new Subject();
8
- this.modalsMap = new Map();
9
- this.translate = inject(TranslateService);
10
- this.dialogService = inject(DialogService);
11
- this.subjectOpenModal$.subscribe((res) => {
12
- this.getModal(res.modalType, res.config);
13
- });
14
- }
15
- /**
16
- *
17
- * @param modalType
18
- * @param dialogService
19
- * @param config
20
- */
21
- getModal(modalType, config) {
22
- this.close();
23
- if (!this.modalsMap.has(modalType)) {
24
- this.modalsMap.set(modalType, this.createModalComponent(modalType));
25
- }
26
- const m = this.modalsMap.get(modalType);
27
- config.styleClass = m.styleClass;
28
- config.height = m.height;
29
- config.width = m.width;
30
- config.breakpoints = m.breakpoints;
31
- config.modal = m.modal !== undefined ? m.modal : true;
32
- config.transitionOptions = "300ms cubic-bezier(0, 0, 0.2, 1)";
33
- this.translate.get(m.header).subscribe((res) => {
34
- config.header = res;
35
- this.ref = this.dialogService.open(m.component, config);
36
- });
37
- this.ref.onClose.pipe(take(1)).subscribe(() => {
38
- if (m.onClosedFunction) {
39
- m.onClosedFunction();
40
- }
41
- });
42
- }
43
- /**
44
- *
45
- */
46
- close() {
47
- if (this.ref) {
48
- this.ref.close();
49
- }
50
- }
51
- }
52
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmd4LXByaW1lbmctbW9kYWwuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL2dlb3NkaS9jb21wb25lbnRzL25neC1wcmltZW5nLW1vZGFsLXNlcnZpY2Uvc3JjL2xpYi9uZ3gtcHJpbWVuZy1tb2RhbC5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFDSCxhQUFhLEdBR2hCLE1BQU0sdUJBQXVCLENBQUM7QUFDL0IsT0FBTyxFQUFRLE1BQU0sRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUM3QyxPQUFPLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUN2RCxPQUFPLEVBQUUsT0FBTyxFQUFFLElBQUksRUFBRSxNQUFNLE1BQU0sQ0FBQztBQWtCckMsTUFBTSxPQUFnQixzQkFBc0I7SUFheEM7UUFaQSxzQkFBaUIsR0FHWixJQUFJLE9BQU8sRUFBbUQsQ0FBQztRQUM1RCxjQUFTLEdBQWdDLElBQUksR0FBRyxFQUdyRCxDQUFDO1FBTUEsSUFBSSxDQUFDLFNBQVMsR0FB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H1cblxuICAgIC8qKlxuICAgICAqXG4gICAgICogQHBhcmFtIG1vZGFsVHlwZVxuICAgICAqIEBwcm90ZWN0ZWRcbiAgICAgKi9cbiAgICBwcm90ZWN0ZWQgYWJzdHJhY3QgY3JlYXRlTW9kYWxDb21wb25lbnQobW9kYWxUeXBlOiBhbnkpOiBOZ3hNb2RhbFdpbmRvdztcbn1cbiJdfQ==
package/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./lib/ngx-primeng-modal.service";
@@ -1,45 +0,0 @@
1
- import { DynamicDialogConfig } from "primeng/dynamicdialog";
2
- import { Type } from "@angular/core";
3
- import { Subject } from "rxjs";
4
- /**
5
- * @author Vito Salvia - CNR IMAA geoSDI Group
6
- * @email vito.salvia@gmail.com
7
- */
8
- export interface NgxModalWindow {
9
- component: Type<any>;
10
- header: string;
11
- height?: string;
12
- width?: string;
13
- styleClass?: string;
14
- modal?: boolean | undefined;
15
- onClosedFunction?: any | undefined;
16
- breakpoints?: any;
17
- }
18
- export declare abstract class NgxPrimeNgModalService {
19
- subjectOpenModal$: Subject<{
20
- modalType: any;
21
- config: DynamicDialogConfig;
22
- }>;
23
- private modalsMap;
24
- private ref;
25
- private translate;
26
- private dialogService;
27
- constructor();
28
- /**
29
- *
30
- * @param modalType
31
- * @param dialogService
32
- * @param config
33
- */
34
- getModal(modalType: any, config: DynamicDialogConfig): void;
35
- /**
36
- *
37
- */
38
- close(): void;
39
- /**
40
- *
41
- * @param modalType
42
- * @protected
43
- */
44
- protected abstract createModalComponent(modalType: any): NgxModalWindow;
45
- }