@melodicdev/components 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21046,13 +21046,26 @@ var Es = class {
21046
21046
  const a = new Es(t, r);
21047
21047
  return this._dialogs.set(t, {
21048
21048
  dialogRef: a,
21049
+ dialogEl: r,
21049
21050
  dialogComponent: void 0
21050
21051
  }), r.addEventListener("close", () => {
21051
21052
  const l = this._dialogs.get(t);
21052
21053
  this.cleanUpDialog(t, l?.dialogComponent);
21053
21054
  }), a;
21054
21055
  }
21055
- removeDialog(t) {
21056
+ /**
21057
+ * Remove a dialog's registration.
21058
+ *
21059
+ * When `dialogEl` is supplied (component teardown), the entry is only
21060
+ * deleted if it still belongs to that element. This prevents a stale
21061
+ * `<ml-dialog>`'s late `onDestroy` from wiping the registration a freshly
21062
+ * re-rendered instance (same id) just created.
21063
+ */
21064
+ removeDialog(t, r) {
21065
+ if (r) {
21066
+ const a = this._dialogs.get(t);
21067
+ if (!a || a.dialogEl !== r) return;
21068
+ }
21056
21069
  this._dialogs.delete(t);
21057
21070
  }
21058
21071
  open(t, r) {
@@ -21091,7 +21104,7 @@ var Er, Be = class {
21091
21104
  t && (this._dialogEl = t, this._dialogID = this.createDialogID(), this._dialogEl.id = this._dialogID, this._dialogRef = this._dialogService.addDialog(this._dialogID, this._dialogEl), this._registered = !0);
21092
21105
  }
21093
21106
  onDestroy() {
21094
- this._dialogService.removeDialog(this._dialogID);
21107
+ this._registered && this._dialogService.removeDialog(this._dialogID, this._dialogEl);
21095
21108
  }
21096
21109
  open() {
21097
21110
  this.registerDialog(), this._dialogRef.open();
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.component.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/dialog/dialog.component.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAKzE,qBAMa,eAAgB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IAChE,UAAU,EAAG,WAAW,CAAC;IAGhC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAEhD,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,WAAW,CAAS;IAErB,QAAQ,IAAI,IAAI;IAIvB,OAAO,CAAC,cAAc;IAaf,SAAS,IAAI,IAAI;IAIjB,IAAI,IAAI,IAAI;IAKZ,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI;IAI3C,OAAO,CAAC,cAAc;CAQtB"}
1
+ {"version":3,"file":"dialog.component.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/dialog/dialog.component.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAKzE,qBAMa,eAAgB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IAChE,UAAU,EAAG,WAAW,CAAC;IAGhC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAEhD,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,WAAW,CAAS;IAErB,QAAQ,IAAI,IAAI;IAIvB,OAAO,CAAC,cAAc;IAaf,SAAS,IAAI,IAAI;IAQjB,IAAI,IAAI,IAAI;IAKZ,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI;IAI3C,OAAO,CAAC,cAAc;CAQtB"}
@@ -33,7 +33,12 @@ let DialogComponent = class DialogComponent {
33
33
  this._registered = true;
34
34
  }
35
35
  onDestroy() {
36
- this._dialogService.removeDialog(this._dialogID);
36
+ // Only this element should be able to remove its own registration. On a
37
+ // re-render the new instance registers (same id) before this stale one
38
+ // tears down; passing our element lets the service ignore that delete.
39
+ if (!this._registered)
40
+ return;
41
+ this._dialogService.removeDialog(this._dialogID, this._dialogEl);
37
42
  }
38
43
  open() {
39
44
  this.registerDialog();
@@ -4,7 +4,15 @@ import type { IDialogConfig } from './dialog-config.interface';
4
4
  export declare class DialogService {
5
5
  private readonly _dialogs;
6
6
  addDialog(dialogID: UniqueID, dialogEl: HTMLDialogElement): DialogRef;
7
- removeDialog(dialogID: UniqueID): void;
7
+ /**
8
+ * Remove a dialog's registration.
9
+ *
10
+ * When `dialogEl` is supplied (component teardown), the entry is only
11
+ * deleted if it still belongs to that element. This prevents a stale
12
+ * `<ml-dialog>`'s late `onDestroy` from wiping the registration a freshly
13
+ * re-rendered instance (same id) just created.
14
+ */
15
+ removeDialog(dialogID: UniqueID, dialogEl?: HTMLDialogElement): void;
8
16
  open<TResult = unknown, TData = unknown>(dialogComponent: new (...args: any[]) => any, config?: IDialogConfig<TData>): DialogRef<TResult, TData>;
9
17
  open<TResult = unknown, TData = unknown>(dialogID: UniqueID): DialogRef<TResult, TData>;
10
18
  close<T = unknown>(dialogID: UniqueID, result?: T): void;
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.service.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/dialog/dialog.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAW/D,qBACa,aAAa;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwC;IAE1D,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,GAAG,SAAS;IAerE,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAItC,IAAI,CAAC,OAAO,GA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C;IAChJ,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,KAAK,GAAG,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC;IA2BvF,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI;IAO/D,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,aAAa;CAGrB"}
@@ -14,6 +14,7 @@ let DialogService = class DialogService {
14
14
  const dialogRef = new DialogRef(dialogID, dialogEl);
15
15
  this._dialogs.set(dialogID, {
16
16
  dialogRef,
17
+ dialogEl,
17
18
  dialogComponent: undefined
18
19
  });
19
20
  dialogEl.addEventListener('close', () => {
@@ -22,7 +23,21 @@ let DialogService = class DialogService {
22
23
  });
23
24
  return dialogRef;
24
25
  }
25
- removeDialog(dialogID) {
26
+ /**
27
+ * Remove a dialog's registration.
28
+ *
29
+ * When `dialogEl` is supplied (component teardown), the entry is only
30
+ * deleted if it still belongs to that element. This prevents a stale
31
+ * `<ml-dialog>`'s late `onDestroy` from wiping the registration a freshly
32
+ * re-rendered instance (same id) just created.
33
+ */
34
+ removeDialog(dialogID, dialogEl) {
35
+ if (dialogEl) {
36
+ const elements = this._dialogs.get(dialogID);
37
+ if (!elements || elements.dialogEl !== dialogEl) {
38
+ return;
39
+ }
40
+ }
26
41
  this._dialogs.delete(dialogID);
27
42
  }
28
43
  open(dialogComponentOrID, config) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melodicdev/components",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Themeable UI component library built on the Melodic Framework",
5
5
  "license": "MIT",
6
6
  "author": "Melodic Development",