@melodicdev/components 1.0.15 → 1.0.16

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.
@@ -1777,12 +1777,21 @@ var TemplateResult = class TemplateResult {
1777
1777
  }
1778
1778
  renderNestedTemplate(part, template) {
1779
1779
  this.ensureMarkers(part);
1780
+ if (part.nestedContainer) {
1781
+ if (part.nestedContainer.__templateKey === getTemplateKey(template.strings)) {
1782
+ template.renderInto(part.nestedContainer);
1783
+ return;
1784
+ }
1785
+ const oldParts = part.nestedContainer.__parts;
1786
+ if (oldParts) this.cleanupParts(oldParts);
1787
+ }
1780
1788
  this.clearRenderedNodes(part);
1781
1789
  part.node.textContent = "";
1782
- const fragment = document.createDocumentFragment();
1783
- template.renderInto(fragment);
1784
- part.renderedNodes = Array.from(fragment.childNodes);
1785
- part.endMarker.parentNode.insertBefore(fragment, part.endMarker);
1790
+ const container = document.createDocumentFragment();
1791
+ template.renderInto(container);
1792
+ part.nestedContainer = container;
1793
+ part.renderedNodes = Array.from(container.childNodes);
1794
+ part.endMarker.parentNode.insertBefore(container, part.endMarker);
1786
1795
  }
1787
1796
  renderNode(part, node) {
1788
1797
  this.ensureMarkers(part);
@@ -18538,13 +18547,6 @@ var DialogRef = class {
18538
18547
  this._dialogEl.addEventListener("cancel", this._handleCancel);
18539
18548
  this._dialogEl.addEventListener("click", this._handleBackdropClick);
18540
18549
  }
18541
- updateDialogElement(dialogEl) {
18542
- this._dialogEl.removeEventListener("cancel", this._handleCancel);
18543
- this._dialogEl.removeEventListener("click", this._handleBackdropClick);
18544
- this._dialogEl = dialogEl;
18545
- this._dialogEl.addEventListener("cancel", this._handleCancel);
18546
- this._dialogEl.addEventListener("click", this._handleBackdropClick);
18547
- }
18548
18550
  get dialogID() {
18549
18551
  return this._dialogID;
18550
18552
  }
@@ -18616,35 +18618,9 @@ var DialogService = class DialogService$1 {
18616
18618
  if (config) dialogElements.dialogRef.applyConfig(config);
18617
18619
  dialogComponent.component.onDialogRefSet?.(dialogElements.dialogRef);
18618
18620
  }
18619
- if (!dialogElements) {
18620
- const mlDialog = this.findDialogElement(dialogID);
18621
- if (mlDialog) {
18622
- mlDialog.component.open();
18623
- dialogElements = this._dialogs.get(dialogID);
18624
- }
18625
- if (!dialogElements) throw new Error(`Dialog "${dialogID}" not found. Ensure an <ml-dialog #${dialogID}> exists in the DOM.`);
18626
- return dialogElements.dialogRef;
18627
- }
18628
18621
  dialogElements.dialogRef.open();
18629
18622
  return dialogElements.dialogRef;
18630
18623
  }
18631
- findDialogElement(dialogID) {
18632
- for (const child of document.body.querySelectorAll("*")) if (child.shadowRoot) {
18633
- const result = this.deepFindDialog(child, dialogID);
18634
- if (result) return result;
18635
- }
18636
- return null;
18637
- }
18638
- deepFindDialog(root, dialogID) {
18639
- const shadowRoot = root.shadowRoot;
18640
- if (!shadowRoot) return null;
18641
- for (const el of shadowRoot.querySelectorAll("ml-dialog")) if (el.hasAttribute(`#${dialogID}`)) return el;
18642
- for (const child of shadowRoot.querySelectorAll("*")) if (child.shadowRoot) {
18643
- const result = this.deepFindDialog(child, dialogID);
18644
- if (result) return result;
18645
- }
18646
- return null;
18647
- }
18648
18624
  close(dialogID, result) {
18649
18625
  if (this._dialogs.has(dialogID)) this._dialogs.get(dialogID).dialogRef.close(result);
18650
18626
  }
@@ -18670,9 +18646,6 @@ var DialogComponent = class DialogComponent$1 {
18670
18646
  this._dialogID = newID();
18671
18647
  this._registered = false;
18672
18648
  }
18673
- onCreate() {
18674
- this.registerDialog();
18675
- }
18676
18649
  registerDialog() {
18677
18650
  if (this._registered) return;
18678
18651
  const dialogEl = this.elementRef.shadowRoot?.querySelector("dialog");
@@ -18688,11 +18661,6 @@ var DialogComponent = class DialogComponent$1 {
18688
18661
  }
18689
18662
  open() {
18690
18663
  this.registerDialog();
18691
- const dialogEl = this.elementRef.shadowRoot?.querySelector("dialog");
18692
- if (dialogEl && dialogEl !== this._dialogEl) {
18693
- this._dialogEl = dialogEl;
18694
- this._dialogRef.updateDialogElement(dialogEl);
18695
- }
18696
18664
  this._dialogRef.open();
18697
18665
  }
18698
18666
  close(result) {