@masterteam/components 0.0.166 → 0.0.168

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.
@@ -8,6 +8,7 @@ class ModalService {
8
8
  drawerService = inject(DrawerService);
9
9
  dialogService = inject(DialogService);
10
10
  dir = inject(Directionality, { optional: true });
11
+ openRefs = new Set();
11
12
  footerClass = 'mt-modal-footer';
12
13
  contentClass = 'mt-modal-content';
13
14
  modalConfig;
@@ -21,8 +22,26 @@ class ModalService {
21
22
  else {
22
23
  ref = this.dialogService.open(component, config);
23
24
  }
25
+ this.trackRef(ref);
24
26
  return ref;
25
27
  }
28
+ /**
29
+ * Closes every modal/drawer opened through this service.
30
+ * Useful on session expiry, forced logout, or any global reset
31
+ * where leftover popups would confuse the user.
32
+ */
33
+ closeAll() {
34
+ const refs = Array.from(this.openRefs);
35
+ this.openRefs.clear();
36
+ for (const ref of refs) {
37
+ try {
38
+ ref?.close?.();
39
+ }
40
+ catch {
41
+ // best-effort: ignore failures on individual refs
42
+ }
43
+ }
44
+ }
26
45
  handelStartEndPosition(position) {
27
46
  if (position === 'start') {
28
47
  return this.dir?.value === 'rtl' ? 'right' : 'left';
@@ -34,6 +53,22 @@ class ModalService {
34
53
  return position || 'right';
35
54
  }
36
55
  }
56
+ trackRef(ref) {
57
+ if (!ref)
58
+ return;
59
+ this.openRefs.add(ref);
60
+ const cleanup = () => this.openRefs.delete(ref);
61
+ ref.onClose?.subscribe({
62
+ next: cleanup,
63
+ error: cleanup,
64
+ complete: cleanup,
65
+ });
66
+ ref.onDestroy?.subscribe({
67
+ next: cleanup,
68
+ error: cleanup,
69
+ complete: cleanup,
70
+ });
71
+ }
37
72
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: ModalService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
38
73
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: ModalService, providedIn: 'root' });
39
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"masterteam-components-modal.mjs","sources":["../../../../packages/masterteam/components/modal/modal.ts","../../../../packages/masterteam/components/modal/masterteam-components-modal.ts"],"sourcesContent":["import {\r\n DynamicDrawerConfigInterface,\r\n DrawerService,\r\n} from '@masterteam/components/dynamic-drawer';\r\nimport {\r\n DynamicDialogConfig,\r\n DialogService,\r\n} from '@masterteam/components/dialog';\r\nimport { inject, Injectable } from '@angular/core';\r\nimport { Directionality } from '@angular/cdk/bidi'; // Import from Angular CDK\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class ModalService {\r\n readonly drawerService: DrawerService = inject(DrawerService);\r\n readonly dialogService: DialogService = inject(DialogService);\r\n private dir = inject(Directionality, { optional: true });\r\n\r\n footerClass: string = 'mt-modal-footer';\r\n contentClass: string = 'mt-modal-content';\r\n modalConfig: any;\r\n\r\n openModal(\r\n component: any,\r\n modalType: 'drawer' | 'dialog',\r\n config: DynamicDialogConfig | DynamicDrawerConfigInterface,\r\n ) {\r\n let ref: any;\r\n if (modalType === 'drawer') {\r\n config.position = this.handelStartEndPosition(config.position);\r\n console.log('Opening drawer with config:', config);\r\n ref = this.drawerService.open(component, config);\r\n } else {\r\n ref = this.dialogService.open(component, config);\r\n }\r\n\r\n return ref;\r\n }\r\n\r\n handelStartEndPosition(position: string | undefined) {\r\n if (position === 'start') {\r\n return this.dir?.value === 'rtl' ? 'right' : 'left';\r\n } else if (position === 'end') {\r\n return this.dir?.value === 'rtl' ? 'left' : 'right';\r\n } else {\r\n return position || 'right';\r\n }\r\n }\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;MAYa,YAAY,CAAA;AACd,IAAA,aAAa,GAAkB,MAAM,CAAC,aAAa,CAAC;AACpD,IAAA,aAAa,GAAkB,MAAM,CAAC,aAAa,CAAC;IACrD,GAAG,GAAG,MAAM,CAAC,cAAc,E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B,YAAY,EAAA,UAAA,EAAA,CAAA;kBADxB,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACXlC;;AAEG;;;;"}
1
+ {"version":3,"file":"masterteam-components-modal.mjs","sources":["../../../../packages/masterteam/components/modal/modal.ts","../../../../packages/masterteam/components/modal/masterteam-components-modal.ts"],"sourcesContent":["import {\r\n DynamicDrawerConfigInterface,\r\n DrawerService,\r\n} from '@masterteam/components/dynamic-drawer';\r\nimport {\r\n DynamicDialogConfig,\r\n DynamicDialogRef,\r\n DialogService,\r\n} from '@masterteam/components/dialog';\r\nimport { inject, Injectable } from '@angular/core';\r\nimport { Directionality } from '@angular/cdk/bidi'; // Import from Angular CDK\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class ModalService {\r\n readonly drawerService: DrawerService = inject(DrawerService);\r\n readonly dialogService: DialogService = inject(DialogService);\r\n private dir = inject(Directionality, { optional: true });\r\n\r\n private readonly openRefs = new Set<DynamicDialogRef>();\r\n\r\n footerClass: string = 'mt-modal-footer';\r\n contentClass: string = 'mt-modal-content';\r\n modalConfig: any;\r\n\r\n openModal(\r\n component: any,\r\n modalType: 'drawer' | 'dialog',\r\n config: DynamicDialogConfig | DynamicDrawerConfigInterface,\r\n ) {\r\n let ref: DynamicDialogRef;\r\n if (modalType === 'drawer') {\r\n config.position = this.handelStartEndPosition(config.position);\r\n console.log('Opening drawer with config:', config);\r\n ref = this.drawerService.open(component, config);\r\n } else {\r\n ref = this.dialogService.open(component, config) as DynamicDialogRef;\r\n }\r\n\r\n this.trackRef(ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Closes every modal/drawer opened through this service.\r\n * Useful on session expiry, forced logout, or any global reset\r\n * where leftover popups would confuse the user.\r\n */\r\n closeAll(): void {\r\n const refs = Array.from(this.openRefs);\r\n this.openRefs.clear();\r\n for (const ref of refs) {\r\n try {\r\n ref?.close?.();\r\n } catch {\r\n // best-effort: ignore failures on individual refs\r\n }\r\n }\r\n }\r\n\r\n handelStartEndPosition(position: string | undefined) {\r\n if (position === 'start') {\r\n return this.dir?.value === 'rtl' ? 'right' : 'left';\r\n } else if (position === 'end') {\r\n return this.dir?.value === 'rtl' ? 'left' : 'right';\r\n } else {\r\n return position || 'right';\r\n }\r\n }\r\n\r\n private trackRef(ref: DynamicDialogRef | undefined | null): void {\r\n if (!ref) return;\r\n this.openRefs.add(ref);\r\n const cleanup = () => this.openRefs.delete(ref);\r\n ref.onClose?.subscribe({\r\n next: cleanup,\r\n error: cleanup,\r\n complete: cleanup,\r\n });\r\n ref.onDestroy?.subscribe({\r\n next: cleanup,\r\n error: cleanup,\r\n complete: cleanup,\r\n });\r\n }\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;MAaa,YAAY,CAAA;AACd,IAAA,aAAa,GAAkB,MAAM,CAAC,aAAa,CAAC;AACpD,IAAA,aAAa,GAAkB,MAAM,CAAC,aAAa,CAAC;IACrD,GAAG,GAAG,MAAM,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAEvC,IAAA,QAAQ,GAAG,IAAI,GAAG,EAAoB;IAEvD,WAAW,GAAW,iBAAiB;IACvC,YAAY,GAAW,kBAAkB;AACzC,IAAA,WAAW;AAEX,IAAA,SAAS,CACP,SAAc,EACd,SAA8B,EAC9B,MAA0D,EAAA;AAE1D,QAAA,IAAI,GAAqB;AACzB,QAAA,IAAI,SAAS,KAAK,QAAQ,EAAE;YAC1B,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC;AAC9D,YAAA,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,MAAM,CAAC;YAClD,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC;QAClD;aAAO;YACL,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,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