@duskmoon-dev/el-dialog 1.5.7 → 1.7.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.
@@ -66,111 +66,9 @@ var styles = import_el_base.css`
66
66
 
67
67
  ${coreStyles}
68
68
 
69
- .dialog-wrapper {
70
- position: fixed;
71
- inset: 0;
72
- z-index: 1000;
73
- display: flex;
74
- align-items: center;
75
- justify-content: center;
76
- opacity: 0;
77
- visibility: hidden;
78
- transition:
79
- opacity 200ms ease,
80
- visibility 200ms ease;
81
- }
82
-
83
- .dialog-wrapper.open {
84
- opacity: 1;
85
- visibility: visible;
86
- }
87
-
88
- .dialog-backdrop {
89
- position: absolute;
90
- inset: 0;
91
- background-color: rgba(0, 0, 0, 0.5);
92
- }
93
-
94
- .dialog {
95
- position: relative;
96
- display: flex;
97
- flex-direction: column;
98
- max-height: 90vh;
99
- max-width: 90vw;
100
- min-width: 320px;
101
- background-color: var(--color-surface);
102
- border-radius: 1rem;
103
- box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
104
- transform: scale(0.95);
105
- transition: transform 200ms ease;
69
+ dialog.dialog {
106
70
  font-family: inherit;
107
71
  }
108
-
109
- .dialog-wrapper.open .dialog {
110
- transform: scale(1);
111
- }
112
-
113
- .dialog-sm {
114
- max-width: 400px;
115
- }
116
- .dialog-lg {
117
- max-width: 800px;
118
- }
119
- .dialog-xl {
120
- max-width: 1140px;
121
- }
122
- .dialog-fullscreen {
123
- max-width: 100vw;
124
- max-height: 100vh;
125
- width: 100vw;
126
- height: 100vh;
127
- border-radius: 0;
128
- }
129
-
130
- .dialog-header {
131
- display: flex;
132
- align-items: center;
133
- justify-content: space-between;
134
- padding: 1rem 1.5rem;
135
- border-bottom: 1px solid var(--color-outline);
136
- }
137
-
138
- .dialog-body {
139
- flex: 1;
140
- padding: 1.5rem;
141
- overflow-y: auto;
142
- }
143
-
144
- .dialog-footer {
145
- display: flex;
146
- align-items: center;
147
- justify-content: flex-end;
148
- gap: 0.5rem;
149
- padding: 1rem 1.5rem;
150
- border-top: 1px solid var(--color-outline);
151
- }
152
-
153
- .dialog-close {
154
- display: flex;
155
- align-items: center;
156
- justify-content: center;
157
- width: 2rem;
158
- height: 2rem;
159
- border: none;
160
- background: transparent;
161
- border-radius: 0.5rem;
162
- cursor: pointer;
163
- color: var(--color-on-surface);
164
- opacity: 0.7;
165
- transition:
166
- opacity 150ms ease,
167
- background-color 150ms ease;
168
- }
169
-
170
- .dialog-close:hover {
171
- opacity: 1;
172
- background-color: var(--color-surface-variant);
173
- }
174
72
  `;
175
73
 
176
74
  class ElDmDialog extends import_el_base.BaseElement {
@@ -181,23 +79,29 @@ class ElDmDialog extends import_el_base.BaseElement {
181
79
  noDismiss: { type: Boolean, reflect: true, attribute: "no-dismiss" },
182
80
  noBackdrop: { type: Boolean, reflect: true, attribute: "no-backdrop" }
183
81
  };
82
+ _syncing = false;
83
+ _structureKey = "";
184
84
  constructor() {
185
85
  super();
186
- this.attachStyles([styles, import_el_base.animationStyles]);
86
+ this.attachStyles(styles);
87
+ }
88
+ connectedCallback() {
89
+ super.connectedCallback();
90
+ this.addEventListener("command", this._handleCommand);
91
+ }
92
+ disconnectedCallback() {
93
+ super.disconnectedCallback?.();
94
+ this.removeEventListener("command", this._handleCommand);
187
95
  }
188
96
  _canDismiss() {
189
97
  return this.dismissible && !this.noDismiss;
190
98
  }
191
- _handleBackdropClick(event) {
192
- if (this._canDismiss() && event.target === event.currentTarget) {
193
- this.close();
194
- }
99
+ _getDialog() {
100
+ return this.query("dialog");
101
+ }
102
+ _getStructureKey() {
103
+ return [this.size ?? "", this.dismissible ? "1" : "0", this.noDismiss ? "1" : "0"].join("|");
195
104
  }
196
- _handleKeyDown = (event) => {
197
- if (event.key === "Escape" && this._canDismiss()) {
198
- this.close();
199
- }
200
- };
201
105
  _getDialogClasses() {
202
106
  const classes = ["dialog"];
203
107
  if (this.size && SIZE_CLASSES[this.size]) {
@@ -205,16 +109,119 @@ class ElDmDialog extends import_el_base.BaseElement {
205
109
  }
206
110
  return classes.join(" ");
207
111
  }
112
+ _handleCancel = (event) => {
113
+ if (!this._canDismiss()) {
114
+ event.preventDefault();
115
+ }
116
+ };
117
+ _handleNativeClose = () => {
118
+ if (this._syncing)
119
+ return;
120
+ if (!this.open)
121
+ return;
122
+ this.open = false;
123
+ this.emit("close");
124
+ };
125
+ _handleBackdropClick = (event) => {
126
+ if (this._canDismiss() && event.target === event.currentTarget) {
127
+ this.close();
128
+ }
129
+ };
130
+ _handleCloseClick = () => {
131
+ this.close();
132
+ };
133
+ _handleCommand = (event) => {
134
+ const dialog = this._getDialog();
135
+ if (!dialog)
136
+ return;
137
+ const command = "command" in event ? String(event.command) : "";
138
+ switch (command) {
139
+ case "show-modal":
140
+ this._openNativeDialog(dialog, true);
141
+ break;
142
+ case "show":
143
+ this._openNativeDialog(dialog, false);
144
+ break;
145
+ case "close":
146
+ if (dialog.open) {
147
+ dialog.close();
148
+ }
149
+ break;
150
+ case "request-close":
151
+ this._requestNativeClose(dialog);
152
+ break;
153
+ case "toggle":
154
+ if (dialog.open) {
155
+ dialog.close();
156
+ } else {
157
+ this._openNativeDialog(dialog, !this.noBackdrop);
158
+ }
159
+ break;
160
+ default:
161
+ break;
162
+ }
163
+ };
164
+ _openNativeDialog(dialog, modal) {
165
+ if (!dialog.open) {
166
+ if (modal) {
167
+ dialog.showModal();
168
+ } else {
169
+ dialog.show();
170
+ }
171
+ }
172
+ if (!this.open) {
173
+ this.open = true;
174
+ this.emit("open");
175
+ }
176
+ }
177
+ _requestNativeClose(dialog) {
178
+ if (!dialog.open)
179
+ return;
180
+ const requestClose = dialog.requestClose;
181
+ if (typeof requestClose === "function") {
182
+ requestClose.call(dialog);
183
+ return;
184
+ }
185
+ const cancel = new Event("cancel", { cancelable: true });
186
+ const allowed = dialog.dispatchEvent(cancel);
187
+ if (allowed && !cancel.defaultPrevented) {
188
+ dialog.close();
189
+ }
190
+ }
191
+ _bindDialog() {
192
+ const dialog = this._getDialog();
193
+ if (!dialog)
194
+ return;
195
+ dialog.addEventListener("cancel", this._handleCancel);
196
+ dialog.addEventListener("close", this._handleNativeClose);
197
+ dialog.addEventListener("click", this._handleBackdropClick);
198
+ this.query(".dialog-close")?.addEventListener("click", this._handleCloseClick);
199
+ }
200
+ _syncNativeDialog() {
201
+ const dialog = this._getDialog();
202
+ if (!dialog)
203
+ return;
204
+ if (this.open && !dialog.open) {
205
+ if (this.noBackdrop) {
206
+ dialog.show();
207
+ } else {
208
+ dialog.showModal();
209
+ }
210
+ } else if (!this.open && dialog.open) {
211
+ dialog.close();
212
+ }
213
+ }
208
214
  show() {
209
215
  this.open = true;
210
- document.addEventListener("keydown", this._handleKeyDown);
211
- document.body.style.overflow = "hidden";
212
216
  this.emit("open");
213
217
  }
218
+ showModal() {
219
+ this.show();
220
+ }
214
221
  close() {
222
+ if (!this.open)
223
+ return;
215
224
  this.open = false;
216
- document.removeEventListener("keydown", this._handleKeyDown);
217
- document.body.style.overflow = "";
218
225
  this.emit("close");
219
226
  }
220
227
  toggle() {
@@ -224,20 +231,16 @@ class ElDmDialog extends import_el_base.BaseElement {
224
231
  this.show();
225
232
  }
226
233
  }
227
- disconnectedCallback() {
228
- super.disconnectedCallback?.();
229
- document.removeEventListener("keydown", this._handleKeyDown);
230
- document.body.style.overflow = "";
231
- }
232
234
  render() {
233
235
  const dialogClasses = this._getDialogClasses();
234
236
  return `
235
- <div class="dialog-wrapper ${this.open ? "open" : ""}" part="wrapper">
236
- ${!this.noBackdrop ? '<div class="dialog-backdrop" part="backdrop"></div>' : ""}
237
- <div class="${dialogClasses}" role="dialog" aria-modal="true" part="dialog">
237
+ <dialog class="${dialogClasses}" part="dialog">
238
+ <div class="dialog-box" part="box">
238
239
  <div class="dialog-header" part="header">
239
- <slot name="header"></slot>
240
- ${this._canDismiss() ? '<button class="dialog-close" part="close" aria-label="Close">✕</button>' : ""}
240
+ <div class="dialog-title" part="title">
241
+ <slot name="header"></slot>
242
+ </div>
243
+ ${this._canDismiss() ? '<button type="button" class="dialog-close" part="close" aria-label="Close">&times;</button>' : ""}
241
244
  </div>
242
245
  <div class="dialog-body" part="body">
243
246
  <slot></slot>
@@ -246,15 +249,24 @@ class ElDmDialog extends import_el_base.BaseElement {
246
249
  <slot name="footer"></slot>
247
250
  </div>
248
251
  </div>
249
- </div>
252
+ </dialog>
250
253
  `;
251
254
  }
252
255
  update() {
253
- super.update();
254
- const backdrop = this.shadowRoot?.querySelector(".dialog-backdrop");
255
- backdrop?.addEventListener("click", this._handleBackdropClick.bind(this));
256
- const closeBtn = this.shadowRoot?.querySelector(".dialog-close");
257
- closeBtn?.addEventListener("click", () => this.close());
256
+ const key = this._getStructureKey();
257
+ const dialog = this._getDialog();
258
+ const needsRender = !dialog || key !== this._structureKey;
259
+ this._syncing = true;
260
+ try {
261
+ if (needsRender) {
262
+ super.update();
263
+ this._structureKey = key;
264
+ this._bindDialog();
265
+ }
266
+ this._syncNativeDialog();
267
+ } finally {
268
+ this._syncing = false;
269
+ }
258
270
  }
259
271
  }
260
272
 
@@ -268,5 +280,5 @@ function register() {
268
280
  // src/register.ts
269
281
  register();
270
282
 
271
- //# debugId=1A067A5E6237203464756E2164756E21
283
+ //# debugId=2150B720A44D03C564756E2164756E21
272
284
  //# sourceMappingURL=register.js.map
@@ -2,11 +2,11 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/el-dm-dialog.ts", "../../src/index.ts", "../../src/register.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * DuskMoon Dialog Element\n *\n * A modal dialog component for displaying content that requires user attention.\n * Uses styles from @duskmoon-dev/core for consistent theming.\n *\n * @element el-dm-dialog\n *\n * @attr {boolean} open - Whether the dialog is open\n * @attr {string} size - Dialog size: sm, md, lg, xl, full\n * @attr {boolean} dismissible - Whether clicking backdrop closes dialog\n * @attr {boolean} no-dismiss - Prevents closing via backdrop click or Escape key\n * @attr {boolean} no-backdrop - Hide the backdrop\n *\n * @slot - Default slot for dialog content\n * @slot header - Dialog header/title\n * @slot footer - Dialog footer/actions\n *\n * @csspart dialog - The dialog container\n * @csspart backdrop - The backdrop overlay\n * @csspart content - The content wrapper\n * @csspart header - The header section\n * @csspart body - The body section\n * @csspart footer - The footer section\n * @csspart close - The close button\n *\n * @fires open - Fired when dialog opens\n * @fires close - Fired when dialog closes\n */\n\nimport { BaseElement, css, animationStyles } from '@duskmoon-dev/el-base';\nimport { css as dialogCSS } from '@duskmoon-dev/core/components/dialog';\n\nconst SIZE_CLASSES: Record<string, string> = {\n sm: 'dialog-sm',\n md: '',\n lg: 'dialog-lg',\n xl: 'dialog-xl',\n full: 'dialog-fullscreen',\n};\n\nexport type DialogSize = 'sm' | 'md' | 'lg' | 'xl' | 'full';\n\nconst coreStyles = dialogCSS.replace(/@layer\\s+components\\s*\\{/, '').replace(/\\}\\s*$/, '');\n\nconst styles = css`\n :host {\n display: contents;\n }\n\n :host([hidden]) {\n display: none !important;\n }\n\n ${coreStyles}\n\n .dialog-wrapper {\n position: fixed;\n inset: 0;\n z-index: 1000;\n display: flex;\n align-items: center;\n justify-content: center;\n opacity: 0;\n visibility: hidden;\n transition:\n opacity 200ms ease,\n visibility 200ms ease;\n }\n\n .dialog-wrapper.open {\n opacity: 1;\n visibility: visible;\n }\n\n .dialog-backdrop {\n position: absolute;\n inset: 0;\n background-color: rgba(0, 0, 0, 0.5);\n }\n\n .dialog {\n position: relative;\n display: flex;\n flex-direction: column;\n max-height: 90vh;\n max-width: 90vw;\n min-width: 320px;\n background-color: var(--color-surface);\n border-radius: 1rem;\n box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n transform: scale(0.95);\n transition: transform 200ms ease;\n font-family: inherit;\n }\n\n .dialog-wrapper.open .dialog {\n transform: scale(1);\n }\n\n .dialog-sm {\n max-width: 400px;\n }\n .dialog-lg {\n max-width: 800px;\n }\n .dialog-xl {\n max-width: 1140px;\n }\n .dialog-fullscreen {\n max-width: 100vw;\n max-height: 100vh;\n width: 100vw;\n height: 100vh;\n border-radius: 0;\n }\n\n .dialog-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 1rem 1.5rem;\n border-bottom: 1px solid var(--color-outline);\n }\n\n .dialog-body {\n flex: 1;\n padding: 1.5rem;\n overflow-y: auto;\n }\n\n .dialog-footer {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 0.5rem;\n padding: 1rem 1.5rem;\n border-top: 1px solid var(--color-outline);\n }\n\n .dialog-close {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n border: none;\n background: transparent;\n border-radius: 0.5rem;\n cursor: pointer;\n color: var(--color-on-surface);\n opacity: 0.7;\n transition:\n opacity 150ms ease,\n background-color 150ms ease;\n }\n\n .dialog-close:hover {\n opacity: 1;\n background-color: var(--color-surface-variant);\n }\n`;\n\nexport class ElDmDialog extends BaseElement {\n static properties = {\n open: { type: Boolean, reflect: true },\n size: { type: String, reflect: true },\n dismissible: { type: Boolean, reflect: true, default: true },\n noDismiss: { type: Boolean, reflect: true, attribute: 'no-dismiss' },\n noBackdrop: { type: Boolean, reflect: true, attribute: 'no-backdrop' },\n };\n\n declare open: boolean;\n declare size: DialogSize;\n declare dismissible: boolean;\n declare noDismiss: boolean;\n declare noBackdrop: boolean;\n\n constructor() {\n super();\n this.attachStyles([styles, animationStyles]);\n }\n\n private _canDismiss(): boolean {\n return this.dismissible && !this.noDismiss;\n }\n\n private _handleBackdropClick(event: Event): void {\n if (this._canDismiss() && event.target === event.currentTarget) {\n this.close();\n }\n }\n\n private _handleKeyDown = (event: KeyboardEvent): void => {\n if (event.key === 'Escape' && this._canDismiss()) {\n this.close();\n }\n };\n\n private _getDialogClasses(): string {\n const classes = ['dialog'];\n if (this.size && SIZE_CLASSES[this.size]) {\n classes.push(SIZE_CLASSES[this.size]);\n }\n return classes.join(' ');\n }\n\n show(): void {\n this.open = true;\n document.addEventListener('keydown', this._handleKeyDown);\n document.body.style.overflow = 'hidden';\n this.emit('open');\n }\n\n close(): void {\n this.open = false;\n document.removeEventListener('keydown', this._handleKeyDown);\n document.body.style.overflow = '';\n this.emit('close');\n }\n\n toggle(): void {\n if (this.open) {\n this.close();\n } else {\n this.show();\n }\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback?.();\n document.removeEventListener('keydown', this._handleKeyDown);\n document.body.style.overflow = '';\n }\n\n render(): string {\n const dialogClasses = this._getDialogClasses();\n\n return `\n <div class=\"dialog-wrapper ${this.open ? 'open' : ''}\" part=\"wrapper\">\n ${!this.noBackdrop ? '<div class=\"dialog-backdrop\" part=\"backdrop\"></div>' : ''}\n <div class=\"${dialogClasses}\" role=\"dialog\" aria-modal=\"true\" part=\"dialog\">\n <div class=\"dialog-header\" part=\"header\">\n <slot name=\"header\"></slot>\n ${this._canDismiss() ? '<button class=\"dialog-close\" part=\"close\" aria-label=\"Close\">✕</button>' : ''}\n </div>\n <div class=\"dialog-body\" part=\"body\">\n <slot></slot>\n </div>\n <div class=\"dialog-footer\" part=\"footer\">\n <slot name=\"footer\"></slot>\n </div>\n </div>\n </div>\n `;\n }\n\n update(): void {\n super.update();\n const backdrop = this.shadowRoot?.querySelector('.dialog-backdrop');\n backdrop?.addEventListener('click', this._handleBackdropClick.bind(this));\n\n const closeBtn = this.shadowRoot?.querySelector('.dialog-close');\n closeBtn?.addEventListener('click', () => this.close());\n }\n}\n",
5
+ "/**\n * DuskMoon Dialog Element\n *\n * A modal dialog built on the native HTML <dialog> element.\n * Uses styles from @duskmoon-dev/core for consistent theming.\n * HTML Invoker Commands (`command` / `commandfor`) are forwarded to the\n * inner native dialog so built-in show-modal / close / request-close work.\n *\n * @element el-dm-dialog\n *\n * @attr {boolean} open - Whether the dialog is open\n * @attr {string} size - Dialog size: sm, md, lg, xl, full\n * @attr {boolean} dismissible - Whether clicking backdrop closes dialog\n * @attr {boolean} no-dismiss - Prevents closing via backdrop click or Escape key\n * @attr {boolean} no-backdrop - Open as a non-modal dialog (no ::backdrop)\n *\n * @slot - Default slot for dialog content\n * @slot header - Dialog header/title\n * @slot footer - Dialog footer/actions\n *\n * @csspart dialog - The native dialog element\n * @csspart box - The inner dialog-box container\n * @csspart header - The header section\n * @csspart title - The title wrapper\n * @csspart body - The body section\n * @csspart footer - The footer section\n * @csspart close - The close button\n *\n * @fires open - Fired when dialog opens\n * @fires close - Fired when dialog closes\n */\n\nimport { BaseElement, css } from '@duskmoon-dev/el-base';\nimport { css as dialogCSS } from '@duskmoon-dev/core/components/dialog';\n\nconst SIZE_CLASSES: Record<string, string> = {\n sm: 'dialog-sm',\n md: '',\n lg: 'dialog-lg',\n xl: 'dialog-xl',\n full: 'dialog-fullscreen',\n};\n\nexport type DialogSize = 'sm' | 'md' | 'lg' | 'xl' | 'full';\n\nconst coreStyles = dialogCSS.replace(/@layer\\s+components\\s*\\{/, '').replace(/\\}\\s*$/, '');\n\nconst styles = css`\n :host {\n display: contents;\n }\n\n :host([hidden]) {\n display: none !important;\n }\n\n ${coreStyles}\n\n dialog.dialog {\n font-family: inherit;\n }\n`;\n\nexport class ElDmDialog extends BaseElement {\n static properties = {\n open: { type: Boolean, reflect: true },\n size: { type: String, reflect: true },\n dismissible: { type: Boolean, reflect: true, default: true },\n noDismiss: { type: Boolean, reflect: true, attribute: 'no-dismiss' },\n noBackdrop: { type: Boolean, reflect: true, attribute: 'no-backdrop' },\n };\n\n declare open: boolean;\n declare size: DialogSize;\n declare dismissible: boolean;\n declare noDismiss: boolean;\n declare noBackdrop: boolean;\n\n /** Ignore native close events fired while shadow DOM is being rebuilt. */\n private _syncing = false;\n\n /** Structural template key — open changes must not rebuild the dialog. */\n private _structureKey = '';\n\n constructor() {\n super();\n this.attachStyles(styles);\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener('command', this._handleCommand);\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback?.();\n this.removeEventListener('command', this._handleCommand);\n }\n\n private _canDismiss(): boolean {\n return this.dismissible && !this.noDismiss;\n }\n\n private _getDialog(): HTMLDialogElement | null {\n return this.query<HTMLDialogElement>('dialog');\n }\n\n private _getStructureKey(): string {\n return [this.size ?? '', this.dismissible ? '1' : '0', this.noDismiss ? '1' : '0'].join('|');\n }\n\n private _getDialogClasses(): string {\n const classes = ['dialog'];\n if (this.size && SIZE_CLASSES[this.size]) {\n classes.push(SIZE_CLASSES[this.size]);\n }\n return classes.join(' ');\n }\n\n private _handleCancel = (event: Event): void => {\n if (!this._canDismiss()) {\n event.preventDefault();\n }\n };\n\n private _handleNativeClose = (): void => {\n if (this._syncing) return;\n if (!this.open) return;\n this.open = false;\n this.emit('close');\n };\n\n private _handleBackdropClick = (event: Event): void => {\n if (this._canDismiss() && event.target === event.currentTarget) {\n this.close();\n }\n };\n\n private _handleCloseClick = (): void => {\n this.close();\n };\n\n /**\n * Forward Invoker Commands to the native <dialog>.\n * commandfor points at this host; built-in dialog commands must run on the\n * inner HTMLDialogElement, not via a full show()/close() re-render cycle.\n */\n private _handleCommand = (event: Event): void => {\n const dialog = this._getDialog();\n if (!dialog) return;\n\n const command = 'command' in event ? String((event as { command: string }).command) : '';\n\n switch (command) {\n case 'show-modal':\n this._openNativeDialog(dialog, true);\n break;\n case 'show':\n this._openNativeDialog(dialog, false);\n break;\n case 'close':\n if (dialog.open) {\n dialog.close();\n }\n break;\n case 'request-close':\n this._requestNativeClose(dialog);\n break;\n case 'toggle':\n if (dialog.open) {\n dialog.close();\n } else {\n this._openNativeDialog(dialog, !this.noBackdrop);\n }\n break;\n default:\n break;\n }\n };\n\n private _openNativeDialog(dialog: HTMLDialogElement, modal: boolean): void {\n if (!dialog.open) {\n if (modal) {\n dialog.showModal();\n } else {\n dialog.show();\n }\n }\n\n if (!this.open) {\n this.open = true;\n this.emit('open');\n }\n }\n\n private _requestNativeClose(dialog: HTMLDialogElement): void {\n if (!dialog.open) return;\n\n const requestClose = (dialog as HTMLDialogElement & { requestClose?: () => void }).requestClose;\n\n if (typeof requestClose === 'function') {\n requestClose.call(dialog);\n return;\n }\n\n const cancel = new Event('cancel', { cancelable: true });\n const allowed = dialog.dispatchEvent(cancel);\n if (allowed && !cancel.defaultPrevented) {\n dialog.close();\n }\n }\n\n private _bindDialog(): void {\n const dialog = this._getDialog();\n if (!dialog) return;\n\n dialog.addEventListener('cancel', this._handleCancel);\n dialog.addEventListener('close', this._handleNativeClose);\n dialog.addEventListener('click', this._handleBackdropClick);\n this.query('.dialog-close')?.addEventListener('click', this._handleCloseClick);\n }\n\n private _syncNativeDialog(): void {\n const dialog = this._getDialog();\n if (!dialog) return;\n\n if (this.open && !dialog.open) {\n if (this.noBackdrop) {\n dialog.show();\n } else {\n dialog.showModal();\n }\n } else if (!this.open && dialog.open) {\n dialog.close();\n }\n }\n\n show(): void {\n this.open = true;\n this.emit('open');\n }\n\n showModal(): void {\n this.show();\n }\n\n close(): void {\n if (!this.open) return;\n this.open = false;\n this.emit('close');\n }\n\n toggle(): void {\n if (this.open) {\n this.close();\n } else {\n this.show();\n }\n }\n\n render(): string {\n const dialogClasses = this._getDialogClasses();\n\n return `\n <dialog class=\"${dialogClasses}\" part=\"dialog\">\n <div class=\"dialog-box\" part=\"box\">\n <div class=\"dialog-header\" part=\"header\">\n <div class=\"dialog-title\" part=\"title\">\n <slot name=\"header\"></slot>\n </div>\n ${\n this._canDismiss()\n ? '<button type=\"button\" class=\"dialog-close\" part=\"close\" aria-label=\"Close\">&times;</button>'\n : ''\n }\n </div>\n <div class=\"dialog-body\" part=\"body\">\n <slot></slot>\n </div>\n <div class=\"dialog-footer\" part=\"footer\">\n <slot name=\"footer\"></slot>\n </div>\n </div>\n </dialog>\n `;\n }\n\n update(): void {\n const key = this._getStructureKey();\n const dialog = this._getDialog();\n const needsRender = !dialog || key !== this._structureKey;\n\n this._syncing = true;\n try {\n if (needsRender) {\n super.update();\n this._structureKey = key;\n this._bindDialog();\n }\n this._syncNativeDialog();\n } finally {\n this._syncing = false;\n }\n }\n}\n",
6
6
  "import { ElDmDialog } from './el-dm-dialog.js';\n\nexport { ElDmDialog };\nexport type { DialogSize } from './el-dm-dialog.js';\n\nexport function register(): void {\n if (!customElements.get('el-dm-dialog')) {\n customElements.define('el-dm-dialog', ElDmDialog);\n }\n}\n",
7
7
  "import { register } from './index.js';\nregister();\n"
8
8
  ],
9
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BkD,IAAlD;AACiC,IAAjC;AAEA,IAAM,eAAuC;AAAA,EAC3C,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AACR;AAIA,IAAM,aAAa,kBAAU,QAAQ,4BAA4B,EAAE,EAAE,QAAQ,UAAU,EAAE;AAEzF,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6GG,MAAM,mBAAmB,2BAAY;AAAA,SACnC,aAAa;AAAA,IAClB,MAAM,EAA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