@melodicdev/components 1.0.9 → 1.0.11

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.
@@ -18609,9 +18609,39 @@ var DialogService = class DialogService$1 {
18609
18609
  if (config) dialogElements.dialogRef.applyConfig(config);
18610
18610
  dialogComponent.component.onDialogRefSet?.(dialogElements.dialogRef);
18611
18611
  }
18612
+ if (!dialogElements) {
18613
+ const mlDialog = this.findDialogElement(dialogID);
18614
+ if (mlDialog) {
18615
+ mlDialog.open();
18616
+ dialogElements = this._dialogs.get(dialogID);
18617
+ }
18618
+ if (!dialogElements) throw new Error(`Dialog "${dialogID}" not found. Ensure an <ml-dialog #${dialogID}> exists in the DOM.`);
18619
+ return dialogElements.dialogRef;
18620
+ }
18612
18621
  dialogElements.dialogRef.open();
18613
18622
  return dialogElements.dialogRef;
18614
18623
  }
18624
+ findDialogElement(dialogID) {
18625
+ const allDialogs = document.querySelectorAll("ml-dialog");
18626
+ for (const dialog of allDialogs) if (dialog.hasAttribute(`#${dialogID}`)) return dialog;
18627
+ return this.deepFindDialog(document.body, dialogID);
18628
+ }
18629
+ deepFindDialog(root, dialogID) {
18630
+ const shadowRoot = root.shadowRoot;
18631
+ if (shadowRoot) {
18632
+ const match = shadowRoot.querySelector(`ml-dialog[\\#${dialogID}]`);
18633
+ if (match) return match;
18634
+ for (const child of shadowRoot.querySelectorAll("*")) {
18635
+ const result = this.deepFindDialog(child, dialogID);
18636
+ if (result) return result;
18637
+ }
18638
+ }
18639
+ for (const child of root.querySelectorAll("*")) if (child.shadowRoot) {
18640
+ const result = this.deepFindDialog(child, dialogID);
18641
+ if (result) return result;
18642
+ }
18643
+ return null;
18644
+ }
18615
18645
  close(dialogID, result) {
18616
18646
  if (this._dialogs.has(dialogID)) this._dialogs.get(dialogID).dialogRef.close(result);
18617
18647
  }
@@ -18637,12 +18667,6 @@ var DialogComponent = class DialogComponent$1 {
18637
18667
  this._dialogID = newID();
18638
18668
  this._registered = false;
18639
18669
  }
18640
- onCreate() {
18641
- this.registerDialog();
18642
- }
18643
- onRender() {
18644
- this.registerDialog();
18645
- }
18646
18670
  registerDialog() {
18647
18671
  if (this._registered) return;
18648
18672
  const dialogEl = this.elementRef.shadowRoot?.querySelector("dialog");
@@ -18657,6 +18681,7 @@ var DialogComponent = class DialogComponent$1 {
18657
18681
  this._dialogService.removeDialog(this._dialogID);
18658
18682
  }
18659
18683
  open() {
18684
+ this.registerDialog();
18660
18685
  this._dialogRef.open();
18661
18686
  }
18662
18687
  close(result) {