@duskmoon-dev/el-dialog 1.6.0 → 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.
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/el-dm-dialog.ts
2
- import { BaseElement, css, animationStyles } from "@duskmoon-dev/el-base";
2
+ import { BaseElement, css } from "@duskmoon-dev/el-base";
3
3
  import { css as dialogCSS } from "@duskmoon-dev/core/components/dialog";
4
4
  var SIZE_CLASSES = {
5
5
  sm: "dialog-sm",
@@ -20,111 +20,9 @@ var styles = css`
20
20
 
21
21
  ${coreStyles}
22
22
 
23
- .dialog-wrapper {
24
- position: fixed;
25
- inset: 0;
26
- z-index: 1000;
27
- display: flex;
28
- align-items: center;
29
- justify-content: center;
30
- opacity: 0;
31
- visibility: hidden;
32
- transition:
33
- opacity 200ms ease,
34
- visibility 200ms ease;
35
- }
36
-
37
- .dialog-wrapper.open {
38
- opacity: 1;
39
- visibility: visible;
40
- }
41
-
42
- .dialog-backdrop {
43
- position: absolute;
44
- inset: 0;
45
- background-color: rgba(0, 0, 0, 0.5);
46
- }
47
-
48
- .dialog {
49
- position: relative;
50
- display: flex;
51
- flex-direction: column;
52
- max-height: 90vh;
53
- max-width: 90vw;
54
- min-width: 320px;
55
- background-color: var(--color-surface);
56
- border-radius: 1rem;
57
- box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
58
- transform: scale(0.95);
59
- transition: transform 200ms ease;
23
+ dialog.dialog {
60
24
  font-family: inherit;
61
25
  }
62
-
63
- .dialog-wrapper.open .dialog {
64
- transform: scale(1);
65
- }
66
-
67
- .dialog-sm {
68
- max-width: 400px;
69
- }
70
- .dialog-lg {
71
- max-width: 800px;
72
- }
73
- .dialog-xl {
74
- max-width: 1140px;
75
- }
76
- .dialog-fullscreen {
77
- max-width: 100vw;
78
- max-height: 100vh;
79
- width: 100vw;
80
- height: 100vh;
81
- border-radius: 0;
82
- }
83
-
84
- .dialog-header {
85
- display: flex;
86
- align-items: center;
87
- justify-content: space-between;
88
- padding: 1rem 1.5rem;
89
- border-bottom: 1px solid var(--color-outline);
90
- }
91
-
92
- .dialog-body {
93
- flex: 1;
94
- padding: 1.5rem;
95
- overflow-y: auto;
96
- }
97
-
98
- .dialog-footer {
99
- display: flex;
100
- align-items: center;
101
- justify-content: flex-end;
102
- gap: 0.5rem;
103
- padding: 1rem 1.5rem;
104
- border-top: 1px solid var(--color-outline);
105
- }
106
-
107
- .dialog-close {
108
- display: flex;
109
- align-items: center;
110
- justify-content: center;
111
- width: 2rem;
112
- height: 2rem;
113
- border: none;
114
- background: transparent;
115
- border-radius: 0.5rem;
116
- cursor: pointer;
117
- color: var(--color-on-surface);
118
- opacity: 0.7;
119
- transition:
120
- opacity 150ms ease,
121
- background-color 150ms ease;
122
- }
123
-
124
- .dialog-close:hover {
125
- opacity: 1;
126
- background-color: var(--color-surface-variant);
127
- }
128
26
  `;
129
27
 
130
28
  class ElDmDialog extends BaseElement {
@@ -135,23 +33,29 @@ class ElDmDialog extends BaseElement {
135
33
  noDismiss: { type: Boolean, reflect: true, attribute: "no-dismiss" },
136
34
  noBackdrop: { type: Boolean, reflect: true, attribute: "no-backdrop" }
137
35
  };
36
+ _syncing = false;
37
+ _structureKey = "";
138
38
  constructor() {
139
39
  super();
140
- this.attachStyles([styles, animationStyles]);
40
+ this.attachStyles(styles);
41
+ }
42
+ connectedCallback() {
43
+ super.connectedCallback();
44
+ this.addEventListener("command", this._handleCommand);
45
+ }
46
+ disconnectedCallback() {
47
+ super.disconnectedCallback?.();
48
+ this.removeEventListener("command", this._handleCommand);
141
49
  }
142
50
  _canDismiss() {
143
51
  return this.dismissible && !this.noDismiss;
144
52
  }
145
- _handleBackdropClick(event) {
146
- if (this._canDismiss() && event.target === event.currentTarget) {
147
- this.close();
148
- }
53
+ _getDialog() {
54
+ return this.query("dialog");
55
+ }
56
+ _getStructureKey() {
57
+ return [this.size ?? "", this.dismissible ? "1" : "0", this.noDismiss ? "1" : "0"].join("|");
149
58
  }
150
- _handleKeyDown = (event) => {
151
- if (event.key === "Escape" && this._canDismiss()) {
152
- this.close();
153
- }
154
- };
155
59
  _getDialogClasses() {
156
60
  const classes = ["dialog"];
157
61
  if (this.size && SIZE_CLASSES[this.size]) {
@@ -159,16 +63,119 @@ class ElDmDialog extends BaseElement {
159
63
  }
160
64
  return classes.join(" ");
161
65
  }
66
+ _handleCancel = (event) => {
67
+ if (!this._canDismiss()) {
68
+ event.preventDefault();
69
+ }
70
+ };
71
+ _handleNativeClose = () => {
72
+ if (this._syncing)
73
+ return;
74
+ if (!this.open)
75
+ return;
76
+ this.open = false;
77
+ this.emit("close");
78
+ };
79
+ _handleBackdropClick = (event) => {
80
+ if (this._canDismiss() && event.target === event.currentTarget) {
81
+ this.close();
82
+ }
83
+ };
84
+ _handleCloseClick = () => {
85
+ this.close();
86
+ };
87
+ _handleCommand = (event) => {
88
+ const dialog = this._getDialog();
89
+ if (!dialog)
90
+ return;
91
+ const command = "command" in event ? String(event.command) : "";
92
+ switch (command) {
93
+ case "show-modal":
94
+ this._openNativeDialog(dialog, true);
95
+ break;
96
+ case "show":
97
+ this._openNativeDialog(dialog, false);
98
+ break;
99
+ case "close":
100
+ if (dialog.open) {
101
+ dialog.close();
102
+ }
103
+ break;
104
+ case "request-close":
105
+ this._requestNativeClose(dialog);
106
+ break;
107
+ case "toggle":
108
+ if (dialog.open) {
109
+ dialog.close();
110
+ } else {
111
+ this._openNativeDialog(dialog, !this.noBackdrop);
112
+ }
113
+ break;
114
+ default:
115
+ break;
116
+ }
117
+ };
118
+ _openNativeDialog(dialog, modal) {
119
+ if (!dialog.open) {
120
+ if (modal) {
121
+ dialog.showModal();
122
+ } else {
123
+ dialog.show();
124
+ }
125
+ }
126
+ if (!this.open) {
127
+ this.open = true;
128
+ this.emit("open");
129
+ }
130
+ }
131
+ _requestNativeClose(dialog) {
132
+ if (!dialog.open)
133
+ return;
134
+ const requestClose = dialog.requestClose;
135
+ if (typeof requestClose === "function") {
136
+ requestClose.call(dialog);
137
+ return;
138
+ }
139
+ const cancel = new Event("cancel", { cancelable: true });
140
+ const allowed = dialog.dispatchEvent(cancel);
141
+ if (allowed && !cancel.defaultPrevented) {
142
+ dialog.close();
143
+ }
144
+ }
145
+ _bindDialog() {
146
+ const dialog = this._getDialog();
147
+ if (!dialog)
148
+ return;
149
+ dialog.addEventListener("cancel", this._handleCancel);
150
+ dialog.addEventListener("close", this._handleNativeClose);
151
+ dialog.addEventListener("click", this._handleBackdropClick);
152
+ this.query(".dialog-close")?.addEventListener("click", this._handleCloseClick);
153
+ }
154
+ _syncNativeDialog() {
155
+ const dialog = this._getDialog();
156
+ if (!dialog)
157
+ return;
158
+ if (this.open && !dialog.open) {
159
+ if (this.noBackdrop) {
160
+ dialog.show();
161
+ } else {
162
+ dialog.showModal();
163
+ }
164
+ } else if (!this.open && dialog.open) {
165
+ dialog.close();
166
+ }
167
+ }
162
168
  show() {
163
169
  this.open = true;
164
- document.addEventListener("keydown", this._handleKeyDown);
165
- document.body.style.overflow = "hidden";
166
170
  this.emit("open");
167
171
  }
172
+ showModal() {
173
+ this.show();
174
+ }
168
175
  close() {
176
+ if (!this.open)
177
+ return;
169
178
  this.open = false;
170
- document.removeEventListener("keydown", this._handleKeyDown);
171
- document.body.style.overflow = "";
172
179
  this.emit("close");
173
180
  }
174
181
  toggle() {
@@ -178,20 +185,16 @@ class ElDmDialog extends BaseElement {
178
185
  this.show();
179
186
  }
180
187
  }
181
- disconnectedCallback() {
182
- super.disconnectedCallback?.();
183
- document.removeEventListener("keydown", this._handleKeyDown);
184
- document.body.style.overflow = "";
185
- }
186
188
  render() {
187
189
  const dialogClasses = this._getDialogClasses();
188
190
  return `
189
- <div class="dialog-wrapper ${this.open ? "open" : ""}" part="wrapper">
190
- ${!this.noBackdrop ? '<div class="dialog-backdrop" part="backdrop"></div>' : ""}
191
- <div class="${dialogClasses}" role="dialog" aria-modal="true" part="dialog">
191
+ <dialog class="${dialogClasses}" part="dialog">
192
+ <div class="dialog-box" part="box">
192
193
  <div class="dialog-header" part="header">
193
- <slot name="header"></slot>
194
- ${this._canDismiss() ? '<button class="dialog-close" part="close" aria-label="Close">✕</button>' : ""}
194
+ <div class="dialog-title" part="title">
195
+ <slot name="header"></slot>
196
+ </div>
197
+ ${this._canDismiss() ? '<button type="button" class="dialog-close" part="close" aria-label="Close">&times;</button>' : ""}
195
198
  </div>
196
199
  <div class="dialog-body" part="body">
197
200
  <slot></slot>
@@ -200,15 +203,24 @@ class ElDmDialog extends BaseElement {
200
203
  <slot name="footer"></slot>
201
204
  </div>
202
205
  </div>
203
- </div>
206
+ </dialog>
204
207
  `;
205
208
  }
206
209
  update() {
207
- super.update();
208
- const backdrop = this.shadowRoot?.querySelector(".dialog-backdrop");
209
- backdrop?.addEventListener("click", this._handleBackdropClick.bind(this));
210
- const closeBtn = this.shadowRoot?.querySelector(".dialog-close");
211
- closeBtn?.addEventListener("click", () => this.close());
210
+ const key = this._getStructureKey();
211
+ const dialog = this._getDialog();
212
+ const needsRender = !dialog || key !== this._structureKey;
213
+ this._syncing = true;
214
+ try {
215
+ if (needsRender) {
216
+ super.update();
217
+ this._structureKey = key;
218
+ this._bindDialog();
219
+ }
220
+ this._syncNativeDialog();
221
+ } finally {
222
+ this._syncing = false;
223
+ }
212
224
  }
213
225
  }
214
226
 
@@ -223,5 +235,5 @@ export {
223
235
  ElDmDialog
224
236
  };
225
237
 
226
- //# debugId=7B4E3E7E12712CD564756E2164756E21
238
+ //# debugId=A735D98D0D0563F064756E2164756E21
227
239
  //# sourceMappingURL=index.js.map
@@ -2,10 +2,10 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/el-dm-dialog.ts", "../../src/index.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
  ],
8
- "mappings": ";AA8BA;AACA,gBAAS;AAET,IAAM,eAAuC;AAAA,EAC3C,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AACR;AAIA,IAAM,aAAa,UAAU,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;A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