@mhmo91/schmancy 0.2.187 → 0.2.189

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.
@@ -26,6 +26,7 @@ export declare class DialogService {
26
26
  private static instance;
27
27
  private static DEFAULT_OPTIONS;
28
28
  private activeDialogs;
29
+ private activeRawDialogs;
29
30
  private constructor();
30
31
  /**
31
32
  * Get the singleton instance
@@ -37,7 +38,13 @@ export declare class DialogService {
37
38
  */
38
39
  confirm(options: DialogOptions): Promise<boolean>;
39
40
  /**
40
- * Dismiss the most recently opened dialog
41
+ * Show a dialog with custom component content
42
+ * Always renders content directly without any headers or action buttons
43
+ * @returns Promise that resolves when dialog is closed
44
+ */
45
+ component(content: TemplateResult | HTMLElement | (() => HTMLElement | TemplateResult), options?: Omit<DialogOptions, 'content' | 'message'>): Promise<boolean>;
46
+ /**
47
+ * Dismiss the most recently opened dialog (either confirm or component type)
41
48
  * @returns true if a dialog was dismissed, false if no dialogs were open
42
49
  */
43
50
  dismiss(): boolean;
@@ -51,11 +58,6 @@ export declare class DialogService {
51
58
  * @returns Promise that resolves to true (confirm) or false (cancel)
52
59
  */
53
60
  danger(options: Omit<DialogOptions, 'variant'>): Promise<boolean>;
54
- /**
55
- * Show a dialog with custom component content
56
- * @returns Promise that resolves to true (confirm) or false (cancel)
57
- */
58
- component(content: TemplateResult | HTMLElement | (() => HTMLElement | TemplateResult), options?: Omit<DialogOptions, 'content' | 'message'>): Promise<boolean>;
59
61
  /**
60
62
  * Get a centered position for the dialog
61
63
  */
@@ -82,11 +84,12 @@ export declare const $dialog: {
82
84
  danger: (options: Omit<DialogOptions, "variant">) => Promise<boolean>;
83
85
  /**
84
86
  * Show a dialog with custom component content
85
- * @returns Promise that resolves to true (confirm) or false (cancel)
87
+ * @returns Promise that resolves when dialog is closed
86
88
  */
87
89
  component: (content: TemplateResult | HTMLElement | (() => HTMLElement | TemplateResult), options?: Omit<DialogOptions, "content" | "message">) => Promise<boolean>;
88
90
  /**
89
91
  * Show a simple dialog without title or actions, just content
92
+ * This is an alias for component() since all component dialogs are now simple by design
90
93
  * @returns Promise that resolves when dialog is closed
91
94
  */
92
95
  simple: (content: TemplateResult | HTMLElement | (() => HTMLElement | TemplateResult), options?: Omit<DialogOptions, "content" | "message" | "title" | "confirmText" | "cancelText">) => Promise<boolean>;
@@ -14,6 +14,14 @@ export declare class SchmancyDialog extends SchmancyDialog_base {
14
14
  * Current active promise resolver
15
15
  */
16
16
  private resolvePromise?;
17
+ /**
18
+ * Store cleanup function for position auto-updates
19
+ */
20
+ private cleanupAutoUpdate?;
21
+ /**
22
+ * Virtual element to use as reference for positioning
23
+ */
24
+ private virtualReference?;
17
25
  /**
18
26
  * Simple API: Show the dialog at a specific position
19
27
  * @returns Promise that resolves when dialog is closed
@@ -27,10 +35,18 @@ export declare class SchmancyDialog extends SchmancyDialog_base {
27
35
  */
28
36
  hide(result?: boolean): void;
29
37
  /**
30
- * Calculate optimal position based on click coordinates
31
- * with viewport boundary checks to prevent dialogs from appearing off-screen
38
+ * Set up position auto-updating when dialog content changes or window resizes
39
+ */
40
+ private setupPositioning;
41
+ /**
42
+ * Update dialog position using Floating UI
43
+ */
44
+ private updatePosition;
45
+ private resizeSubscription?;
46
+ /**
47
+ * Handle component disconnection from DOM
32
48
  */
33
- private calculatePosition;
49
+ disconnectedCallback(): void;
34
50
  /**
35
51
  * Handle lifecycle callback when dialog is first rendered
36
52
  */
@@ -1,3 +1,5 @@
1
1
  export * from './dailog';
2
2
  export * from './dialog-service';
3
3
  export * from './dialog.component';
4
+ export * from './dialog-content';
5
+ export * from './dialog-content';
@@ -1,260 +0,0 @@
1
- import "rxjs";
2
- import "lit/directives/class-map.js";
3
- import "lit/directives/style-map.js";
4
- import { $ as y } from "./litElement.mixin-CkrfRzHl.js";
5
- import "./tailwind.mixin-CGefB_52.js";
6
- import { css as x, html as m, render as g } from "lit";
7
- import { property as f, customElement as w } from "lit/decorators.js";
8
- import { when as u } from "lit/directives/when.js";
9
- var b = Object.defineProperty, T = Object.getOwnPropertyDescriptor, d = (t, e, i, n) => {
10
- for (var s, o = n > 1 ? void 0 : n ? T(e, i) : e, a = t.length - 1; a >= 0; a--) (s = t[a]) && (o = (n ? s(e, i, o) : s(o)) || o);
11
- return n && o && b(e, i, o), o;
12
- };
13
- let h = class extends y(x`
14
- :host {
15
- position: fixed;
16
- z-index: 10000;
17
- inset: 0;
18
- display: none;
19
- --dialog-width: 360px;
20
- }
21
-
22
- :host([active]) {
23
- display: block;
24
- }
25
-
26
- .overlay {
27
- position: fixed;
28
- inset: 0;
29
- background: rgba(0, 0, 0, 0.4);
30
- }
31
-
32
- .dialog {
33
- position: absolute;
34
- max-width: var(--dialog-width);
35
- width: max-content;
36
- max-height: calc(100vh - 40px); /* Prevent exceeding viewport height */
37
- /* Center initially */
38
- top: 50%;
39
- left: 50%;
40
- transform: translate(-50%, -55%); /* Slight upward shift looks better */
41
- overflow: auto; /* Allow scrolling for oversized content */
42
- }
43
- `) {
44
- constructor() {
45
- super(...arguments), this.title = void 0, this.message = void 0, this.confirmText = "Confirm", this.cancelText = "Cancel", this.variant = "default", this.position = { x: 0, y: 0 };
46
- }
47
- async show(t) {
48
- let e, i;
49
- if (t) if ("clientX" in t) e = t.clientX, i = t.clientY;
50
- else if ("touches" in t && t.touches.length) e = t.touches[0].clientX, i = t.touches[0].clientY;
51
- else {
52
- const n = t;
53
- e = n.x, i = n.y;
54
- }
55
- else e = window.innerWidth / 2, i = window.innerHeight / 2;
56
- return this.position = this.calculatePosition(e, i), this.setAttribute("active", ""), new Promise((n) => {
57
- this.resolvePromise = n;
58
- });
59
- }
60
- hide(t = !1) {
61
- this.removeAttribute("active"), this.resolvePromise && (this.resolvePromise(t), this.resolvePromise = void 0);
62
- }
63
- calculatePosition(t, e) {
64
- const i = window.innerWidth, n = window.innerHeight;
65
- return { x: t = Math.max(20, Math.min(t, i - 20)), y: e = Math.max(20, Math.min(e, n - 20)) };
66
- }
67
- firstUpdated() {
68
- var p;
69
- const t = (p = this.shadowRoot) == null ? void 0 : p.querySelector(".dialog");
70
- if (!t) return;
71
- const e = t.offsetWidth, i = t.offsetHeight, n = window.innerWidth, s = window.innerHeight, o = 20;
72
- let { x: a, y: r } = this.position;
73
- Math.abs(a - n / 2) < 10 && Math.abs(r - s / 2) < 10 || (a + e > n - o && (a = n - e - o), a < o && (a = o), e > n - 40 && (a = (n - e) / 2), r + i > s - o && (r = r > i + o ? r - i - o : Math.max(o, (s - i) / 2)), r < o && (r = o), i > s - 40 && (r = o), t.style.transform = "none", t.style.left = `${Math.max(0, Math.round(a))}px`, t.style.top = `${Math.max(0, Math.round(r))}px`);
74
- }
75
- handleConfirm() {
76
- this.hide(!0), this.dispatchEvent(new CustomEvent("confirm", { bubbles: !0, composed: !0 }));
77
- }
78
- handleCancel() {
79
- this.hide(!1), this.dispatchEvent(new CustomEvent("cancel", { bubbles: !0, composed: !0 }));
80
- }
81
- render() {
82
- const t = this.querySelectorAll('[slot="content"]').length > 0, e = this.confirmText && this.cancelText;
83
- return m`
84
- <div class="overlay" @click=${this.handleCancel}></div>
85
-
86
- <div class="dialog" role="alertdialog" aria-modal="true">
87
- <schmancy-surface rounded="all" elevation="3" type="containerHigh">
88
- <schmancy-form @submit=${this.handleConfirm} class="p-4">
89
- ${u(this.title, () => m` <schmancy-typography type="title" token="md" class="mb-2"> ${this.title} </schmancy-typography>`)}
90
- ${t ? m`<div class="${e ? "mb-4" : ""}"><slot name="content"></slot></div>` : m`<schmancy-typography type="body" class="mb-4"> ${this.message} </schmancy-typography>`}
91
-
92
- ${u(e, () => m`
93
- <div class="flex justify-end gap-3">
94
- <schmancy-button variant="outlined" @click=${this.handleCancel}> ${this.cancelText} </schmancy-button>
95
- <schmancy-button type="submit" variant="filled"> ${this.confirmText} </schmancy-button>
96
- </div>
97
- `)}
98
- </schmancy-form>
99
- </schmancy-surface>
100
- </div>
101
- `;
102
- }
103
- static async confirm(t) {
104
- let e = document.querySelector("confirm-dialog");
105
- return e || (e = document.createElement("confirm-dialog"), document.body.appendChild(e)), t.title && (e.title = t.title), t.message && (e.message = t.message), t.confirmText && (e.confirmText = t.confirmText), t.cancelText && (e.cancelText = t.cancelText), t.variant && (e.variant = t.variant), t.width && e.style.setProperty("--dialog-width", t.width), e.show(t.position);
106
- }
107
- static async ask(t, e) {
108
- return this.confirm({ message: t, position: e });
109
- }
110
- };
111
- d([f({ type: String })], h.prototype, "title", 2), d([f({ type: String })], h.prototype, "message", 2), d([f({ type: String, attribute: "confirm-text" })], h.prototype, "confirmText", 2), d([f({ type: String, attribute: "cancel-text" })], h.prototype, "cancelText", 2), d([f({ type: String })], h.prototype, "variant", 2), h = d([w("confirm-dialog")], h);
112
- const l = class l {
113
- constructor() {
114
- this.activeDialogs = [];
115
- }
116
- static getInstance() {
117
- return l.instance || (l.instance = new l()), l.instance;
118
- }
119
- confirm(e) {
120
- const i = { ...l.DEFAULT_OPTIONS, ...e };
121
- i.position || (i.position = this.getCenteredPosition());
122
- let n = document.querySelector("confirm-dialog");
123
- if (n || (n = document.createElement("confirm-dialog"), document.body.appendChild(n)), i.title && (n.title = i.title), i.message && (n.message = i.message), i.confirmText && (n.confirmText = i.confirmText), i.cancelText && (n.cancelText = i.cancelText), i.variant && (n.variant = i.variant), i.width && n.style.setProperty("--dialog-width", i.width), i.content) {
124
- const s = document.createElement("div");
125
- if (s.slot = "content", typeof i.content == "function") {
126
- const o = i.content();
127
- o instanceof HTMLElement ? s.appendChild(o) : g(o, s);
128
- } else i.content instanceof HTMLElement ? s.appendChild(i.content) : g(i.content, s);
129
- n.appendChild(s);
130
- }
131
- if (i.onConfirm) {
132
- const s = (o) => {
133
- i.onConfirm(), n.removeEventListener("confirm", s);
134
- };
135
- n.addEventListener("confirm", s);
136
- }
137
- if (i.onCancel) {
138
- const s = (o) => {
139
- i.onCancel(), n.removeEventListener("cancel", s);
140
- };
141
- n.addEventListener("cancel", s);
142
- }
143
- return this.activeDialogs.push(n), n.show(i.position).finally(() => {
144
- const s = this.activeDialogs.indexOf(n);
145
- if (s !== -1 && this.activeDialogs.splice(s, 1), i.content) {
146
- const o = n.querySelector('[slot="content"]');
147
- o && n.removeChild(o);
148
- }
149
- });
150
- }
151
- dismiss() {
152
- return this.activeDialogs.length === 0 ? !1 : (this.activeDialogs[this.activeDialogs.length - 1].hide(!1), !0);
153
- }
154
- ask(e, i) {
155
- return this.confirm({ message: e, position: i });
156
- }
157
- danger(e) {
158
- return this.confirm({ ...e, variant: "danger" });
159
- }
160
- component(e, i = {}) {
161
- return i.hideActions === !1 ? this.confirm({ ...i, content: e, title: void 0, message: void 0 }) : this.confirm({ ...i, content: e, title: void 0, message: void 0, confirmText: "", cancelText: "" });
162
- }
163
- getCenteredPosition() {
164
- return { x: window.innerWidth / 2, y: window.innerHeight / 2 };
165
- }
166
- };
167
- l.DEFAULT_OPTIONS = { title: void 0, confirmText: void 0, cancelText: "Cancel", variant: "default", width: "360px" };
168
- let c = l;
169
- const A = { confirm: (t) => c.getInstance().confirm(t), ask: (t, e) => c.getInstance().ask(t, e), danger: (t) => c.getInstance().danger(t), component: (t, e) => c.getInstance().component(t, e), simple: (t, e) => c.getInstance().component(t, e), dismiss: () => c.getInstance().dismiss() };
170
- var C = Object.getOwnPropertyDescriptor;
171
- let v = class extends y(x`
172
- :host {
173
- position: fixed;
174
- z-index: 10000;
175
- inset: 0;
176
- display: none;
177
- --dialog-width: 360px;
178
- }
179
-
180
- :host([active]) {
181
- display: block;
182
- }
183
-
184
- .overlay {
185
- position: fixed;
186
- inset: 0;
187
- background: rgba(0, 0, 0, 0.4);
188
- }
189
-
190
- .dialog {
191
- position: absolute;
192
- max-width: var(--dialog-width);
193
- width: max-content;
194
- max-height: calc(100vh - 40px); /* Prevent exceeding viewport height */
195
- /* Center initially */
196
- top: 50%;
197
- left: 50%;
198
- transform: translate(-50%, -55%); /* Slight upward shift looks better */
199
- overflow: auto; /* Allow scrolling for oversized content */
200
- }
201
- `) {
202
- constructor() {
203
- super(...arguments), this.position = { x: 0, y: 0 };
204
- }
205
- async show(t) {
206
- let e, i;
207
- if (t) if ("clientX" in t) e = t.clientX, i = t.clientY;
208
- else if ("touches" in t && t.touches.length) e = t.touches[0].clientX, i = t.touches[0].clientY;
209
- else {
210
- const n = t;
211
- e = n.x, i = n.y;
212
- }
213
- else e = window.innerWidth / 2, i = window.innerHeight / 2;
214
- return this.position = this.calculatePosition(e, i), this.setAttribute("active", ""), new Promise((n) => {
215
- this.resolvePromise = n;
216
- });
217
- }
218
- hide(t = !1) {
219
- this.removeAttribute("active"), this.resolvePromise && (this.resolvePromise(t), this.resolvePromise = void 0);
220
- }
221
- calculatePosition(t, e) {
222
- const i = window.innerWidth, n = window.innerHeight;
223
- return { x: t = Math.max(20, Math.min(t, i - 20)), y: e = Math.max(20, Math.min(e, n - 20)) };
224
- }
225
- firstUpdated() {
226
- var p;
227
- const t = (p = this.shadowRoot) == null ? void 0 : p.querySelector(".dialog");
228
- if (!t) return;
229
- const e = t.offsetWidth, i = t.offsetHeight, n = window.innerWidth, s = window.innerHeight, o = 20;
230
- let { x: a, y: r } = this.position;
231
- Math.abs(a - n / 2) < 10 && Math.abs(r - s / 2) < 10 || (a + e > n - o && (a = n - e - o), a < o && (a = o), e > n - 40 && (a = (n - e) / 2), r + i > s - o && (r = r > i + o ? r - i - o : Math.max(o, (s - i) / 2)), r < o && (r = o), i > s - 40 && (r = o), t.style.transform = "none", t.style.left = `${Math.max(0, Math.round(a))}px`, t.style.top = `${Math.max(0, Math.round(r))}px`);
232
- }
233
- handleClose() {
234
- this.hide(!1), this.dispatchEvent(new CustomEvent("close", { bubbles: !0, composed: !0 }));
235
- }
236
- render() {
237
- return m`
238
- <div class="overlay" @click=${this.handleClose}></div>
239
-
240
- <div class="dialog" role="dialog" aria-modal="true">
241
- <schmancy-surface rounded="all" elevation="3" type="containerHigh">
242
- <div class="p-4">
243
- <slot></slot>
244
- </div>
245
- </schmancy-surface>
246
- </div>
247
- `;
248
- }
249
- };
250
- v = ((t, e, i, n) => {
251
- for (var s, o = n > 1 ? void 0 : n ? C(e, i) : e, a = t.length - 1; a >= 0; a--) (s = t[a]) && (o = s(o) || o);
252
- return o;
253
- })([w("schmancy-dialog")], v);
254
- export {
255
- A as $,
256
- h as C,
257
- c as D,
258
- v as S
259
- };
260
- //# sourceMappingURL=dialog.component-B6E5SlZk.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dialog.component-B6E5SlZk.js","sources":["../src/dialog/dailog.ts","../src/dialog/dialog-service.ts","../src/dialog/dialog.component.ts"],"sourcesContent":["import { $LitElement } from '@mixins/index'\nimport { css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { when } from 'lit/directives/when.js'\n\n/**\n * A confirm dialog web component with custom content support\n *\n * @element confirm-dialog\n * @slot content - Optional slot for custom content\n */\n@customElement('confirm-dialog')\nexport class ConfirmDialog extends $LitElement(css`\n\t:host {\n\t\tposition: fixed;\n\t\tz-index: 10000;\n\t\tinset: 0;\n\t\tdisplay: none;\n\t\t--dialog-width: 360px;\n\t}\n\n\t:host([active]) {\n\t\tdisplay: block;\n\t}\n\n\t.overlay {\n\t\tposition: fixed;\n\t\tinset: 0;\n\t\tbackground: rgba(0, 0, 0, 0.4);\n\t}\n\n\t.dialog {\n\t\tposition: absolute;\n\t\tmax-width: var(--dialog-width);\n\t\twidth: max-content;\n\t\tmax-height: calc(100vh - 40px); /* Prevent exceeding viewport height */\n\t\t/* Center initially */\n\t\ttop: 50%;\n\t\tleft: 50%;\n\t\ttransform: translate(-50%, -55%); /* Slight upward shift looks better */\n\t\toverflow: auto; /* Allow scrolling for oversized content */\n\t}\n`) {\n\t/**\n\t * Dialog title\n\t */\n\t@property({ type: String })\n\ttitle = undefined\n\n\t/**\n\t * Dialog message\n\t */\n\t@property({ type: String })\n\tmessage = undefined\n\n\t/**\n\t * Text for confirm button\n\t */\n\t@property({ type: String, attribute: 'confirm-text' })\n\tconfirmText = 'Confirm'\n\n\t/**\n\t * Text for cancel button\n\t */\n\t@property({ type: String, attribute: 'cancel-text' })\n\tcancelText = 'Cancel'\n\n\t/**\n\t * Dialog variant (affects button colors)\n\t */\n\t@property({ type: String })\n\tvariant: 'default' | 'danger' = 'default'\n\n\t/**\n\t * Current position of the dialog\n\t */\n\tprivate position = { x: 0, y: 0 }\n\n\t/**\n\t * Current active promise resolver\n\t */\n\tprivate resolvePromise?: (value: boolean) => void\n\n\t/**\n\t * Simple API: Show the dialog at a specific position\n\t * @returns Promise that resolves to true (confirm) or false (cancel)\n\t */\n\tasync show(positionOrEvent?: { x: number; y: number } | MouseEvent | TouchEvent): Promise<boolean> {\n\t\t// Extract position from event or use direct coordinates\n\t\tlet x: number, y: number\n\n\t\tif (!positionOrEvent) {\n\t\t\t// Default to center of viewport if no position provided\n\t\t\tx = window.innerWidth / 2\n\t\t\ty = window.innerHeight / 2\n\t\t} else if ('clientX' in positionOrEvent) {\n\t\t\t// It's a mouse event\n\t\t\tx = positionOrEvent.clientX\n\t\t\ty = positionOrEvent.clientY\n\t\t} else if ('touches' in positionOrEvent && positionOrEvent.touches.length) {\n\t\t\t// It's a touch event\n\t\t\tx = positionOrEvent.touches[0].clientX\n\t\t\ty = positionOrEvent.touches[0].clientY\n\t\t} else {\n\t\t\t// It's a position object with x,y coordinates\n\t\t\tconst pos = positionOrEvent as { x: number; y: number }\n\t\t\tx = pos.x\n\t\t\ty = pos.y\n\t\t}\n\n\t\t// Pre-calculate position before showing dialog\n\t\tthis.position = this.calculatePosition(x, y)\n\n\t\t// Make dialog active but ensure position is calculated first\n\t\t// to prevent visual bouncing\n\t\tthis.setAttribute('active', '')\n\n\t\t// Return a promise that resolves when the user makes a choice\n\t\treturn new Promise<boolean>(resolve => {\n\t\t\tthis.resolvePromise = resolve\n\t\t})\n\t}\n\n\t/**\n\t * Simple API: Hide the dialog\n\t */\n\thide(confirmed = false) {\n\t\tthis.removeAttribute('active')\n\n\t\t// Resolve any pending promise\n\t\tif (this.resolvePromise) {\n\t\t\tthis.resolvePromise(confirmed)\n\t\t\tthis.resolvePromise = undefined\n\t\t}\n\t}\n\n\t/**\n\t * Calculate optimal position based on click coordinates\n\t * with viewport boundary checks to prevent dialogs from appearing off-screen\n\t */\n\tprivate calculatePosition(x: number, y: number) {\n\t\t// We can't know the exact dimensions until the dialog is rendered\n\t\t// But we can make an initial adjustment to improve positioning\n\t\t// For more accurate positioning, we'll do a second adjustment in firstUpdated\n\n\t\t// Provide some margin from edges\n\t\tconst margin = 20\n\n\t\t// Get viewport dimensions\n\t\tconst viewportWidth = window.innerWidth\n\t\tconst viewportHeight = window.innerHeight\n\n\t\t// Ensure initial x is within viewport bounds\n\t\tx = Math.max(margin, Math.min(x, viewportWidth - margin))\n\n\t\t// Ensure initial y is within viewport bounds\n\t\ty = Math.max(margin, Math.min(y, viewportHeight - margin))\n\n\t\treturn { x, y }\n\t}\n\n\t/**\n\t * Handle lifecycle callback when dialog is first rendered\n\t */\n\tfirstUpdated() {\n\t\t// Immediate positioning without animations\n\t\tconst dialog = this.shadowRoot?.querySelector('.dialog') as HTMLElement\n\t\tif (!dialog) return\n\n\t\t// Run synchronously to ensure immediate positioning\n\t\t// Get dialog dimensions\n\t\tconst width = dialog.offsetWidth\n\t\tconst height = dialog.offsetHeight\n\n\t\t// Get viewport dimensions\n\t\tconst viewportWidth = window.innerWidth\n\t\tconst viewportHeight = window.innerHeight\n\n\t\t// Standard margin from edges\n\t\tconst margin = 20\n\n\t\t// Get dialog initial position\n\t\tlet { x, y } = this.position\n\n\t\t// Check if this is a centered dialog (default case or explicitly centered)\n\t\tconst isCentered = Math.abs(x - viewportWidth / 2) < 10 && Math.abs(y - viewportHeight / 2) < 10\n\n\t\tif (isCentered) {\n\t\t\t// For centered dialogs, keep using the CSS transform-based centering\n\t\t\treturn\n\t\t}\n\n\t\t// For non-centered dialogs, calculate the ideal position\n\t\t// HORIZONTAL POSITIONING\n\t\t// First check if dialog extends beyond right edge\n\t\tif (x + width > viewportWidth - margin) {\n\t\t\t// Try to align to right edge with margin\n\t\t\tx = viewportWidth - width - margin\n\t\t}\n\n\t\t// Make sure it's not off the left edge either\n\t\tif (x < margin) {\n\t\t\tx = margin\n\t\t}\n\n\t\t// If dialog is wider than viewport, center it\n\t\tif (width > viewportWidth - margin * 2) {\n\t\t\tx = (viewportWidth - width) / 2\n\t\t}\n\n\t\t// VERTICAL POSITIONING\n\t\t// Check if the dialog extends beyond bottom edge\n\t\tif (y + height > viewportHeight - margin) {\n\t\t\t// Try to position above the click point if there's space\n\t\t\tif (y > height + margin) {\n\t\t\t\t// Position above the click point\n\t\t\t\ty = y - height - margin\n\t\t\t} else {\n\t\t\t\t// Otherwise, try to center vertically\n\t\t\t\ty = Math.max(margin, (viewportHeight - height) / 2)\n\t\t\t}\n\t\t}\n\n\t\t// Make sure it's not off the top edge\n\t\tif (y < margin) {\n\t\t\ty = margin\n\t\t}\n\n\t\t// If dialog is taller than viewport, align to top with margin\n\t\tif (height > viewportHeight - margin * 2) {\n\t\t\ty = margin\n\t\t}\n\n\t\t// Apply position immediately without animations\n\t\tdialog.style.transform = 'none' // Remove transform-based centering\n\t\tdialog.style.left = `${Math.max(0, Math.round(x))}px`\n\t\tdialog.style.top = `${Math.max(0, Math.round(y))}px`\n\t}\n\n\t/**\n\t * Handle confirm action\n\t */\n\tprivate handleConfirm() {\n\t\tthis.hide(true)\n\t\tthis.dispatchEvent(\n\t\t\tnew CustomEvent('confirm', {\n\t\t\t\tbubbles: true,\n\t\t\t\tcomposed: true,\n\t\t\t}),\n\t\t)\n\t}\n\n\t/**\n\t * Handle cancel action\n\t */\n\tprivate handleCancel() {\n\t\tthis.hide(false)\n\t\tthis.dispatchEvent(\n\t\t\tnew CustomEvent('cancel', {\n\t\t\t\tbubbles: true,\n\t\t\t\tcomposed: true,\n\t\t\t}),\n\t\t)\n\t}\n\n\trender() {\n\t\t// For initial rendering, use transform-based centering from CSS\n\t\t// firstUpdated will handle precise positioning after measuring\n\t\tconst hasCustomContent = this.querySelectorAll('[slot=\"content\"]').length > 0\n\t\tconst showButtons = this.confirmText && this.cancelText\n\n\t\treturn html`\n\t\t\t<div class=\"overlay\" @click=${this.handleCancel}></div>\n\n\t\t\t<div class=\"dialog\" role=\"alertdialog\" aria-modal=\"true\">\n\t\t\t\t<schmancy-surface rounded=\"all\" elevation=\"3\" type=\"containerHigh\">\n\t\t\t\t\t<schmancy-form @submit=${this.handleConfirm} class=\"p-4\">\n\t\t\t\t\t\t${when(\n\t\t\t\t\t\t\tthis.title,\n\t\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\t\thtml` <schmancy-typography type=\"title\" token=\"md\" class=\"mb-2\"> ${this.title} </schmancy-typography>`,\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t${hasCustomContent\n\t\t\t\t\t\t\t? html`<div class=\"${showButtons ? 'mb-4' : ''}\"><slot name=\"content\"></slot></div>`\n\t\t\t\t\t\t\t: html`<schmancy-typography type=\"body\" class=\"mb-4\"> ${this.message} </schmancy-typography>`}\n\n\t\t\t\t\t\t${when(\n\t\t\t\t\t\t\tshowButtons,\n\t\t\t\t\t\t\t() => html`\n\t\t\t\t\t\t\t\t<div class=\"flex justify-end gap-3\">\n\t\t\t\t\t\t\t\t\t<schmancy-button variant=\"outlined\" @click=${this.handleCancel}> ${this.cancelText} </schmancy-button>\n\t\t\t\t\t\t\t\t\t<schmancy-button type=\"submit\" variant=\"filled\"> ${this.confirmText} </schmancy-button>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t`\n\t\t\t\t\t\t)}\n\t\t\t\t\t</schmancy-form>\n\t\t\t\t</schmancy-surface>\n\t\t\t</div>\n\t\t`\n\t}\n\n\t/**\n\t * Static helper for even simpler API\n\t */\n\tstatic async confirm(options: {\n\t\ttitle?: string\n\t\tmessage?: string\n\t\tconfirmText?: string\n\t\tcancelText?: string\n\t\tvariant?: 'default' | 'danger'\n\t\tposition?: { x: number; y: number } | MouseEvent | TouchEvent\n\t\twidth?: string\n\t}): Promise<boolean> {\n\t\t// Create dialog if it doesn't exist\n\t\tlet dialog = document.querySelector('confirm-dialog') as ConfirmDialog\n\n\t\tif (!dialog) {\n\t\t\tdialog = document.createElement('confirm-dialog') as ConfirmDialog\n\t\t\tdocument.body.appendChild(dialog)\n\t\t}\n\n\t\t// Set options\n\t\tif (options.title) dialog.title = options.title\n\t\tif (options.message) dialog.message = options.message\n\t\tif (options.confirmText) dialog.confirmText = options.confirmText\n\t\tif (options.cancelText) dialog.cancelText = options.cancelText\n\t\tif (options.variant) dialog.variant = options.variant\n\t\tif (options.width) dialog.style.setProperty('--dialog-width', options.width)\n\n\t\t// Show dialog and return promise\n\t\treturn dialog.show(options.position)\n\t}\n\n\t/**\n\t * Even simpler shorthand method - just pass message and optionally an event\n\t */\n\tstatic async ask(message: string, event?: MouseEvent | TouchEvent): Promise<boolean> {\n\t\treturn this.confirm({\n\t\t\tmessage,\n\t\t\tposition: event,\n\t\t})\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'confirm-dialog': ConfirmDialog\n\t}\n}\n","import { render, TemplateResult } from 'lit'\nimport { ConfirmDialog } from './dailog'\n\n/**\n * Dialog service options interface with component support\n */\nexport interface DialogOptions {\n\ttitle?: string\n\tmessage?: string\n\tconfirmText?: string\n\tcancelText?: string\n\tvariant?: 'default' | 'danger'\n\tposition?: { x: number; y: number } | MouseEvent | TouchEvent\n\n\t// New options for component rendering\n\tcontent?: TemplateResult | HTMLElement | (() => HTMLElement | TemplateResult)\n\twidth?: string\n\tonConfirm?: () => void\n\tonCancel?: () => void\n\thideActions?: boolean // Set to true to hide all buttons and title\n}\n\n/**\n * Dialog service for centralized dialog management.\n * Provides a simple API for showing dialogs with optional custom components.\n */\nexport class DialogService {\n\tprivate static instance: DialogService\n\n\t// Default dialog options\n\tprivate static DEFAULT_OPTIONS: Partial<DialogOptions> = {\n\t\ttitle: undefined,\n\t\tconfirmText: undefined,\n\t\tcancelText: 'Cancel',\n\t\tvariant: 'default',\n\t\twidth: '360px',\n\t}\n\n\t// Track active dialogs to handle dismissing the most recent one\n\tprivate activeDialogs: ConfirmDialog[] = []\n\n\t// Private constructor for singleton pattern\n\tprivate constructor() {}\n\n\t/**\n\t * Get the singleton instance\n\t */\n\tpublic static getInstance(): DialogService {\n\t\tif (!DialogService.instance) {\n\t\t\tDialogService.instance = new DialogService()\n\t\t}\n\t\treturn DialogService.instance\n\t}\n\n\t/**\n\t * Show a confirmation dialog\n\t * @returns Promise that resolves to true (confirm) or false (cancel)\n\t */\n\tpublic confirm(options: DialogOptions): Promise<boolean> {\n\t\t// Apply default options\n\t\tconst completeOptions = {\n\t\t\t...DialogService.DEFAULT_OPTIONS,\n\t\t\t...options,\n\t\t}\n\n\t\t// If no position is provided, center the dialog\n\t\tif (!completeOptions.position) {\n\t\t\tcompleteOptions.position = this.getCenteredPosition()\n\t\t}\n\n\t\t// Create or find the dialog\n\t\tlet dialog = document.querySelector('confirm-dialog') as ConfirmDialog\n\t\tif (!dialog) {\n\t\t\tdialog = document.createElement('confirm-dialog') as ConfirmDialog\n\t\t\tdocument.body.appendChild(dialog)\n\t\t}\n\n\t\t// Set basic options\n\t\tif (completeOptions.title) dialog.title = completeOptions.title\n\t\tif (completeOptions.message) dialog.message = completeOptions.message\n\t\tif (completeOptions.confirmText) dialog.confirmText = completeOptions.confirmText\n\t\tif (completeOptions.cancelText) dialog.cancelText = completeOptions.cancelText\n\t\tif (completeOptions.variant) dialog.variant = completeOptions.variant\n\t\tif (completeOptions.width) dialog.style.setProperty('--dialog-width', completeOptions.width)\n\n\t\t// Handle custom content if provided\n\t\tif (completeOptions.content) {\n\t\t\tconst contentContainer = document.createElement('div')\n\t\t\tcontentContainer.slot = 'content'\n\n\t\t\tif (typeof completeOptions.content === 'function') {\n\t\t\t\tconst result = completeOptions.content()\n\t\t\t\tif (result instanceof HTMLElement) {\n\t\t\t\t\tcontentContainer.appendChild(result)\n\t\t\t\t} else {\n\t\t\t\t\trender(result, contentContainer)\n\t\t\t\t}\n\t\t\t} else if (completeOptions.content instanceof HTMLElement) {\n\t\t\t\tcontentContainer.appendChild(completeOptions.content)\n\t\t\t} else {\n\t\t\t\trender(completeOptions.content, contentContainer)\n\t\t\t}\n\n\t\t\tdialog.appendChild(contentContainer)\n\t\t}\n\n\t\t// Set up event listeners for optional callbacks\n\t\tif (completeOptions.onConfirm) {\n\t\t\tconst onConfirm = (_e: Event) => {\n\t\t\t\tcompleteOptions.onConfirm!()\n\t\t\t\tdialog.removeEventListener('confirm', onConfirm)\n\t\t\t}\n\t\t\tdialog.addEventListener('confirm', onConfirm)\n\t\t}\n\n\t\tif (completeOptions.onCancel) {\n\t\t\tconst onCancel = (_e: Event) => {\n\t\t\t\tcompleteOptions.onCancel!()\n\t\t\t\tdialog.removeEventListener('cancel', onCancel)\n\t\t\t}\n\t\t\tdialog.addEventListener('cancel', onCancel)\n\t\t}\n\n\t\t// Add this dialog to active dialogs\n\t\tthis.activeDialogs.push(dialog)\n\n\t\t// Show dialog and return promise\n\t\treturn dialog.show(completeOptions.position).finally(() => {\n\t\t\t// Remove from active dialogs when closed\n\t\t\tconst index = this.activeDialogs.indexOf(dialog)\n\t\t\tif (index !== -1) {\n\t\t\t\tthis.activeDialogs.splice(index, 1)\n\t\t\t}\n\n\t\t\t// Clean up the content when dialog closes\n\t\t\tif (completeOptions.content) {\n\t\t\t\tconst contentEl = dialog.querySelector('[slot=\"content\"]')\n\t\t\t\tif (contentEl) {\n\t\t\t\t\tdialog.removeChild(contentEl)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\t/**\n\t * Dismiss the most recently opened dialog\n\t * @returns true if a dialog was dismissed, false if no dialogs were open\n\t */\n\tpublic dismiss(): boolean {\n\t\tif (this.activeDialogs.length === 0) {\n\t\t\treturn false\n\t\t}\n\n\t\t// Get the most recently opened dialog (last in the array)\n\t\tconst dialog = this.activeDialogs[this.activeDialogs.length - 1]\n\n\t\t// Hide the dialog (with cancel result)\n\t\tdialog.hide(false)\n\n\t\treturn true\n\t}\n\n\t/**\n\t * Show a simple confirmation dialog with just a message\n\t * @returns Promise that resolves to true (confirm) or false (cancel)\n\t */\n\tpublic ask(message: string, event?: MouseEvent | TouchEvent): Promise<boolean> {\n\t\treturn this.confirm({\n\t\t\tmessage,\n\t\t\tposition: event,\n\t\t})\n\t}\n\n\t/**\n\t * Show a danger confirmation dialog\n\t * @returns Promise that resolves to true (confirm) or false (cancel)\n\t */\n\tpublic danger(options: Omit<DialogOptions, 'variant'>): Promise<boolean> {\n\t\treturn this.confirm({\n\t\t\t...options,\n\t\t\tvariant: 'danger',\n\t\t})\n\t}\n\n\t/**\n\t * Show a dialog with custom component content\n\t * @returns Promise that resolves to true (confirm) or false (cancel)\n\t */\n\tpublic component(\n\t\tcontent: TemplateResult | HTMLElement | (() => HTMLElement | TemplateResult),\n\t\toptions: Omit<DialogOptions, 'content' | 'message'> = {},\n\t): Promise<boolean> {\n\t\t// By default, component dialogs have hideActions=true\n\t\tconst useActions = options.hideActions === false;\n\t\t\n\t\tif (!useActions) {\n\t\t\treturn this.confirm({\n\t\t\t\t...options,\n\t\t\t\tcontent,\n\t\t\t\ttitle: undefined,\n\t\t\t\tmessage: undefined,\n\t\t\t\tconfirmText: '', // Hide buttons by setting empty text\n\t\t\t\tcancelText: '',\n\t\t\t})\n\t\t}\n\t\t\n\t\treturn this.confirm({\n\t\t\t...options,\n\t\t\tcontent,\n\t\t\t// Clear message if content is provided\n\t\t\ttitle: undefined,\n\t\t\tmessage: undefined,\n\t\t})\n\t}\n\n\t/**\n\t * Get a centered position for the dialog\n\t */\n\tprivate getCenteredPosition(): { x: number; y: number } {\n\t\treturn {\n\t\t\tx: window.innerWidth / 2,\n\t\t\ty: window.innerHeight / 2,\n\t\t}\n\t}\n\n}\n\n/**\n * Global dialog utility - provides a quick way to show dialogs\n */\nexport const $dialog = {\n\t/**\n\t * Show a confirmation dialog\n\t * @returns Promise that resolves to true (confirm) or false (cancel)\n\t */\n\tconfirm: (options: DialogOptions): Promise<boolean> => {\n\t\treturn DialogService.getInstance().confirm(options)\n\t},\n\n\t/**\n\t * Show a simple confirmation dialog with just a message\n\t * @returns Promise that resolves to true (confirm) or false (cancel)\n\t */\n\task: (message: string, event?: MouseEvent | TouchEvent): Promise<boolean> => {\n\t\treturn DialogService.getInstance().ask(message, event)\n\t},\n\n\t/**\n\t * Show a danger confirmation dialog\n\t * @returns Promise that resolves to true (confirm) or false (cancel)\n\t */\n\tdanger: (options: Omit<DialogOptions, 'variant'>): Promise<boolean> => {\n\t\treturn DialogService.getInstance().danger(options)\n\t},\n\n\t/**\n\t * Show a dialog with custom component content\n\t * @returns Promise that resolves to true (confirm) or false (cancel)\n\t */\n\tcomponent: (\n\t\tcontent: TemplateResult | HTMLElement | (() => HTMLElement | TemplateResult),\n\t\toptions?: Omit<DialogOptions, 'content' | 'message'>,\n\t): Promise<boolean> => {\n\t\treturn DialogService.getInstance().component(content, options)\n\t},\n\n\t/**\n\t * Show a simple dialog without title or actions, just content\n\t * @returns Promise that resolves when dialog is closed\n\t */\n\tsimple: (\n\t\tcontent: TemplateResult | HTMLElement | (() => HTMLElement | TemplateResult),\n\t\toptions?: Omit<DialogOptions, 'content' | 'message' | 'title' | 'confirmText' | 'cancelText'>,\n\t): Promise<boolean> => {\n\t\treturn DialogService.getInstance().component(content, options)\n\t},\n\n\t/**\n\t * Dismiss the most recently opened dialog\n\t * @returns true if a dialog was dismissed, false if no dialogs were open\n\t */\n\tdismiss: (): boolean => {\n\t\treturn DialogService.getInstance().dismiss()\n\t},\n}\n\nexport default DialogService\n","import { $LitElement } from '@mixins/index'\nimport { css, html } from 'lit'\nimport { customElement } from 'lit/decorators.js'\n\n/**\n * A basic dialog web component without title or actions\n *\n * @element schmancy-dialog\n * @slot default - Content slot for dialog body\n */\n@customElement('schmancy-dialog')\nexport class SchmancyDialog extends $LitElement(css`\n\t:host {\n\t\tposition: fixed;\n\t\tz-index: 10000;\n\t\tinset: 0;\n\t\tdisplay: none;\n\t\t--dialog-width: 360px;\n\t}\n\n\t:host([active]) {\n\t\tdisplay: block;\n\t}\n\n\t.overlay {\n\t\tposition: fixed;\n\t\tinset: 0;\n\t\tbackground: rgba(0, 0, 0, 0.4);\n\t}\n\n\t.dialog {\n\t\tposition: absolute;\n\t\tmax-width: var(--dialog-width);\n\t\twidth: max-content;\n\t\tmax-height: calc(100vh - 40px); /* Prevent exceeding viewport height */\n\t\t/* Center initially */\n\t\ttop: 50%;\n\t\tleft: 50%;\n\t\ttransform: translate(-50%, -55%); /* Slight upward shift looks better */\n\t\toverflow: auto; /* Allow scrolling for oversized content */\n\t}\n`) {\n\t/**\n\t * Current position of the dialog\n\t */\n\tprivate position = { x: 0, y: 0 }\n\n\t/**\n\t * Current active promise resolver\n\t */\n\tprivate resolvePromise?: (value: boolean) => void\n\n\t/**\n\t * Simple API: Show the dialog at a specific position\n\t * @returns Promise that resolves when dialog is closed\n\t */\n\tasync show(positionOrEvent?: { x: number; y: number } | MouseEvent | TouchEvent): Promise<boolean> {\n\t\t// Extract position from event or use direct coordinates\n\t\tlet x: number, y: number\n\n\t\tif (!positionOrEvent) {\n\t\t\t// Default to center of viewport if no position provided\n\t\t\tx = window.innerWidth / 2\n\t\t\ty = window.innerHeight / 2\n\t\t} else if ('clientX' in positionOrEvent) {\n\t\t\t// It's a mouse event\n\t\t\tx = positionOrEvent.clientX\n\t\t\ty = positionOrEvent.clientY\n\t\t} else if ('touches' in positionOrEvent && positionOrEvent.touches.length) {\n\t\t\t// It's a touch event\n\t\t\tx = positionOrEvent.touches[0].clientX\n\t\t\ty = positionOrEvent.touches[0].clientY\n\t\t} else {\n\t\t\t// It's a position object with x,y coordinates\n\t\t\tconst pos = positionOrEvent as { x: number; y: number }\n\t\t\tx = pos.x\n\t\t\ty = pos.y\n\t\t}\n\n\t\t// Pre-calculate position before showing dialog\n\t\tthis.position = this.calculatePosition(x, y)\n\n\t\t// Make dialog active but ensure position is calculated first\n\t\t// to prevent visual bouncing\n\t\tthis.setAttribute('active', '')\n\n\t\t// Return a promise that resolves when the user makes a choice\n\t\treturn new Promise<boolean>(resolve => {\n\t\t\tthis.resolvePromise = resolve\n\t\t})\n\t}\n\n\t/**\n\t * Simple API: Hide the dialog\n\t */\n\thide(result = false) {\n\t\tthis.removeAttribute('active')\n\n\t\t// Resolve any pending promise\n\t\tif (this.resolvePromise) {\n\t\t\tthis.resolvePromise(result)\n\t\t\tthis.resolvePromise = undefined\n\t\t}\n\t}\n\n\t/**\n\t * Calculate optimal position based on click coordinates\n\t * with viewport boundary checks to prevent dialogs from appearing off-screen\n\t */\n\tprivate calculatePosition(x: number, y: number) {\n\t\t// We can't know the exact dimensions until the dialog is rendered\n\t\t// But we can make an initial adjustment to improve positioning\n\t\t// For more accurate positioning, we'll do a second adjustment in firstUpdated\n\n\t\t// Provide some margin from edges\n\t\tconst margin = 20\n\n\t\t// Get viewport dimensions\n\t\tconst viewportWidth = window.innerWidth\n\t\tconst viewportHeight = window.innerHeight\n\n\t\t// Ensure initial x is within viewport bounds\n\t\tx = Math.max(margin, Math.min(x, viewportWidth - margin))\n\n\t\t// Ensure initial y is within viewport bounds\n\t\ty = Math.max(margin, Math.min(y, viewportHeight - margin))\n\n\t\treturn { x, y }\n\t}\n\n\t/**\n\t * Handle lifecycle callback when dialog is first rendered\n\t */\n\tfirstUpdated() {\n\t\t// Immediate positioning without animations\n\t\tconst dialog = this.shadowRoot?.querySelector('.dialog') as HTMLElement\n\t\tif (!dialog) return\n\n\t\t// Run synchronously to ensure immediate positioning\n\t\t// Get dialog dimensions\n\t\tconst width = dialog.offsetWidth\n\t\tconst height = dialog.offsetHeight\n\n\t\t// Get viewport dimensions\n\t\tconst viewportWidth = window.innerWidth\n\t\tconst viewportHeight = window.innerHeight\n\n\t\t// Standard margin from edges\n\t\tconst margin = 20\n\n\t\t// Get dialog initial position\n\t\tlet { x, y } = this.position\n\n\t\t// Check if this is a centered dialog (default case or explicitly centered)\n\t\tconst isCentered = Math.abs(x - viewportWidth / 2) < 10 && Math.abs(y - viewportHeight / 2) < 10\n\n\t\tif (isCentered) {\n\t\t\t// For centered dialogs, keep using the CSS transform-based centering\n\t\t\treturn\n\t\t}\n\n\t\t// For non-centered dialogs, calculate the ideal position\n\t\t// HORIZONTAL POSITIONING\n\t\t// First check if dialog extends beyond right edge\n\t\tif (x + width > viewportWidth - margin) {\n\t\t\t// Try to align to right edge with margin\n\t\t\tx = viewportWidth - width - margin\n\t\t}\n\n\t\t// Make sure it's not off the left edge either\n\t\tif (x < margin) {\n\t\t\tx = margin\n\t\t}\n\n\t\t// If dialog is wider than viewport, center it\n\t\tif (width > viewportWidth - margin * 2) {\n\t\t\tx = (viewportWidth - width) / 2\n\t\t}\n\n\t\t// VERTICAL POSITIONING\n\t\t// Check if the dialog extends beyond bottom edge\n\t\tif (y + height > viewportHeight - margin) {\n\t\t\t// Try to position above the click point if there's space\n\t\t\tif (y > height + margin) {\n\t\t\t\t// Position above the click point\n\t\t\t\ty = y - height - margin\n\t\t\t} else {\n\t\t\t\t// Otherwise, try to center vertically\n\t\t\t\ty = Math.max(margin, (viewportHeight - height) / 2)\n\t\t\t}\n\t\t}\n\n\t\t// Make sure it's not off the top edge\n\t\tif (y < margin) {\n\t\t\ty = margin\n\t\t}\n\n\t\t// If dialog is taller than viewport, align to top with margin\n\t\tif (height > viewportHeight - margin * 2) {\n\t\t\ty = margin\n\t\t}\n\n\t\t// Apply position immediately without animations\n\t\tdialog.style.transform = 'none' // Remove transform-based centering\n\t\tdialog.style.left = `${Math.max(0, Math.round(x))}px`\n\t\tdialog.style.top = `${Math.max(0, Math.round(y))}px`\n\t}\n\n\t/**\n\t * Handle close action\n\t */\n\tprivate handleClose() {\n\t\tthis.hide(false)\n\t\tthis.dispatchEvent(\n\t\t\tnew CustomEvent('close', {\n\t\t\t\tbubbles: true,\n\t\t\t\tcomposed: true,\n\t\t\t}),\n\t\t)\n\t}\n\n\trender() {\n\t\treturn html`\n\t\t\t<div class=\"overlay\" @click=${this.handleClose}></div>\n\n\t\t\t<div class=\"dialog\" role=\"dialog\" aria-modal=\"true\">\n\t\t\t\t<schmancy-surface rounded=\"all\" elevation=\"3\" type=\"containerHigh\">\n\t\t\t\t\t<div class=\"p-4\">\n\t\t\t\t\t\t<slot></slot>\n\t\t\t\t\t</div>\n\t\t\t\t</schmancy-surface>\n\t\t\t</div>\n\t\t`\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'schmancy-dialog': SchmancyDialog\n\t}\n}"],"names":["ConfirmDialog","$LitElement","css","super","arguments","this","title","message","confirmText","cancelText","variant","position","x","y","positionOrEvent","clientX","clientY","touches","length","pos","window","innerWidth","innerHeight","calculatePosition","setAttribute","Promise","resolve","resolvePromise","confirmed","removeAttribute","viewportWidth","viewportHeight","Math","max","min","firstUpdated","dialog","shadowRoot","querySelector","width","offsetWidth","height","offsetHeight","margin","abs","style","transform","left","round","top","hide","dispatchEvent","CustomEvent","bubbles","composed","render","hasCustomContent","querySelectorAll","showButtons","html","handleCancel","handleConfirm","when","options","document","createElement","body","appendChild","setProperty","show","event","confirm","__decorateClass","property","type","String","prototype","attribute","customElement","DialogService","constructor","activeDialogs","getInstance","instance","completeOptions","DEFAULT_OPTIONS","getCenteredPosition","content","contentContainer","slot","result","HTMLElement","onConfirm","_e","removeEventListener","addEventListener","onCancel","push","finally","index","indexOf","splice","contentEl","removeChild","dismiss","hideActions","_d","$dialog","ask","danger","component","simple","SchmancyDialog","handleClose"],"mappings":";;;;;;;;;;;;AAYa,IAAAA,IAAN,cAA4BC,EAAYC;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,CAAxC,EAAA;AAAA,EAAA,cAAAC;AAAAA,UAAAA,GAAAC,SAmCEC,GAAAA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ASZ,IAAiBU,KAAU,CAK/C5B,IAAAA,IAAI8B,MACH9B,IAAA8B,IAIDF,IAASV,IAAiBY,OACzB9B,IAAA8B,IAILP,EAAOS,MAAMC,YAAY,QAClBV,EAAAS,MAAME,OAAO,GAAGf,KAAKC,IAAI,GAAGD,KAAKgB,MAAMpC,CAAAA,CAAAA,CAAAA,MACvCwB,EAAAS,MAAMI,MAAM,GAAGjB,KAAKC,IAAI,GAAGD,KAAKgB,MAAMnC,CAAAA,CAAAA,CAAAA;AAAAA,EAAG;AAAA,EAMzC;AACPR,SAAK6C,KAAAA,EACA7C,GAAAA,KAAA8C,cACJ,IAAIC,YAAY,SAAS,EACxBC,SAAAA,IACAC,UAAAA,GAEF,CAAA,CAAA;AAAA,EAAA;AAAA,EAGD,SAAAC;AACQ,WAAAI;AAAAA,iCACwBtD,KAAK4G,WAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,EAAW;AAAA;AApNpCD;;;GAAN,CADNlC,EAAc,qBACFkC;"}
@@ -1,90 +0,0 @@
1
- "use strict";require("rxjs"),require("lit/directives/class-map.js"),require("lit/directives/style-map.js");const u=require("./litElement.mixin-Ct7SS5n6.cjs");require("./tailwind.mixin-Cezttl4Z.cjs");const c=require("lit"),d=require("lit/decorators.js"),g=require("lit/directives/when.js");var f=Object.defineProperty,v=Object.getOwnPropertyDescriptor,m=(t,e,i,n)=>{for(var s,o=n>1?void 0:n?v(e,i):e,a=t.length-1;a>=0;a--)(s=t[a])&&(o=(n?s(e,i,o):s(o))||o);return n&&o&&f(e,i,o),o};exports.ConfirmDialog=class extends u.$LitElement(c.css`
2
- :host {
3
- position: fixed;
4
- z-index: 10000;
5
- inset: 0;
6
- display: none;
7
- --dialog-width: 360px;
8
- }
9
-
10
- :host([active]) {
11
- display: block;
12
- }
13
-
14
- .overlay {
15
- position: fixed;
16
- inset: 0;
17
- background: rgba(0, 0, 0, 0.4);
18
- }
19
-
20
- .dialog {
21
- position: absolute;
22
- max-width: var(--dialog-width);
23
- width: max-content;
24
- max-height: calc(100vh - 40px); /* Prevent exceeding viewport height */
25
- /* Center initially */
26
- top: 50%;
27
- left: 50%;
28
- transform: translate(-50%, -55%); /* Slight upward shift looks better */
29
- overflow: auto; /* Allow scrolling for oversized content */
30
- }
31
- `){constructor(){super(...arguments),this.title=void 0,this.message=void 0,this.confirmText="Confirm",this.cancelText="Cancel",this.variant="default",this.position={x:0,y:0}}async show(t){let e,i;if(t)if("clientX"in t)e=t.clientX,i=t.clientY;else if("touches"in t&&t.touches.length)e=t.touches[0].clientX,i=t.touches[0].clientY;else{const n=t;e=n.x,i=n.y}else e=window.innerWidth/2,i=window.innerHeight/2;return this.position=this.calculatePosition(e,i),this.setAttribute("active",""),new Promise(n=>{this.resolvePromise=n})}hide(t=!1){this.removeAttribute("active"),this.resolvePromise&&(this.resolvePromise(t),this.resolvePromise=void 0)}calculatePosition(t,e){const i=window.innerWidth,n=window.innerHeight;return{x:t=Math.max(20,Math.min(t,i-20)),y:e=Math.max(20,Math.min(e,n-20))}}firstUpdated(){var p;const t=(p=this.shadowRoot)==null?void 0:p.querySelector(".dialog");if(!t)return;const e=t.offsetWidth,i=t.offsetHeight,n=window.innerWidth,s=window.innerHeight,o=20;let{x:a,y:r}=this.position;Math.abs(a-n/2)<10&&Math.abs(r-s/2)<10||(a+e>n-o&&(a=n-e-o),a<o&&(a=o),e>n-40&&(a=(n-e)/2),r+i>s-o&&(r=r>i+o?r-i-o:Math.max(o,(s-i)/2)),r<o&&(r=o),i>s-40&&(r=o),t.style.transform="none",t.style.left=`${Math.max(0,Math.round(a))}px`,t.style.top=`${Math.max(0,Math.round(r))}px`)}handleConfirm(){this.hide(!0),this.dispatchEvent(new CustomEvent("confirm",{bubbles:!0,composed:!0}))}handleCancel(){this.hide(!1),this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))}render(){const t=this.querySelectorAll('[slot="content"]').length>0,e=this.confirmText&&this.cancelText;return c.html`
32
- <div class="overlay" @click=${this.handleCancel}></div>
33
-
34
- <div class="dialog" role="alertdialog" aria-modal="true">
35
- <schmancy-surface rounded="all" elevation="3" type="containerHigh">
36
- <schmancy-form @submit=${this.handleConfirm} class="p-4">
37
- ${g.when(this.title,()=>c.html` <schmancy-typography type="title" token="md" class="mb-2"> ${this.title} </schmancy-typography>`)}
38
- ${t?c.html`<div class="${e?"mb-4":""}"><slot name="content"></slot></div>`:c.html`<schmancy-typography type="body" class="mb-4"> ${this.message} </schmancy-typography>`}
39
-
40
- ${g.when(e,()=>c.html`
41
- <div class="flex justify-end gap-3">
42
- <schmancy-button variant="outlined" @click=${this.handleCancel}> ${this.cancelText} </schmancy-button>
43
- <schmancy-button type="submit" variant="filled"> ${this.confirmText} </schmancy-button>
44
- </div>
45
- `)}
46
- </schmancy-form>
47
- </schmancy-surface>
48
- </div>
49
- `}static async confirm(t){let e=document.querySelector("confirm-dialog");return e||(e=document.createElement("confirm-dialog"),document.body.appendChild(e)),t.title&&(e.title=t.title),t.message&&(e.message=t.message),t.confirmText&&(e.confirmText=t.confirmText),t.cancelText&&(e.cancelText=t.cancelText),t.variant&&(e.variant=t.variant),t.width&&e.style.setProperty("--dialog-width",t.width),e.show(t.position)}static async ask(t,e){return this.confirm({message:t,position:e})}},m([d.property({type:String})],exports.ConfirmDialog.prototype,"title",2),m([d.property({type:String})],exports.ConfirmDialog.prototype,"message",2),m([d.property({type:String,attribute:"confirm-text"})],exports.ConfirmDialog.prototype,"confirmText",2),m([d.property({type:String,attribute:"cancel-text"})],exports.ConfirmDialog.prototype,"cancelText",2),m([d.property({type:String})],exports.ConfirmDialog.prototype,"variant",2),exports.ConfirmDialog=m([d.customElement("confirm-dialog")],exports.ConfirmDialog);const h=class h{constructor(){this.activeDialogs=[]}static getInstance(){return h.instance||(h.instance=new h),h.instance}confirm(e){const i={...h.DEFAULT_OPTIONS,...e};i.position||(i.position=this.getCenteredPosition());let n=document.querySelector("confirm-dialog");if(n||(n=document.createElement("confirm-dialog"),document.body.appendChild(n)),i.title&&(n.title=i.title),i.message&&(n.message=i.message),i.confirmText&&(n.confirmText=i.confirmText),i.cancelText&&(n.cancelText=i.cancelText),i.variant&&(n.variant=i.variant),i.width&&n.style.setProperty("--dialog-width",i.width),i.content){const s=document.createElement("div");if(s.slot="content",typeof i.content=="function"){const o=i.content();o instanceof HTMLElement?s.appendChild(o):c.render(o,s)}else i.content instanceof HTMLElement?s.appendChild(i.content):c.render(i.content,s);n.appendChild(s)}if(i.onConfirm){const s=o=>{i.onConfirm(),n.removeEventListener("confirm",s)};n.addEventListener("confirm",s)}if(i.onCancel){const s=o=>{i.onCancel(),n.removeEventListener("cancel",s)};n.addEventListener("cancel",s)}return this.activeDialogs.push(n),n.show(i.position).finally(()=>{const s=this.activeDialogs.indexOf(n);if(s!==-1&&this.activeDialogs.splice(s,1),i.content){const o=n.querySelector('[slot="content"]');o&&n.removeChild(o)}})}dismiss(){return this.activeDialogs.length===0?!1:(this.activeDialogs[this.activeDialogs.length-1].hide(!1),!0)}ask(e,i){return this.confirm({message:e,position:i})}danger(e){return this.confirm({...e,variant:"danger"})}component(e,i={}){return i.hideActions===!1?this.confirm({...i,content:e,title:void 0,message:void 0}):this.confirm({...i,content:e,title:void 0,message:void 0,confirmText:"",cancelText:""})}getCenteredPosition(){return{x:window.innerWidth/2,y:window.innerHeight/2}}};h.DEFAULT_OPTIONS={title:void 0,confirmText:void 0,cancelText:"Cancel",variant:"default",width:"360px"};let l=h;const y={confirm:t=>l.getInstance().confirm(t),ask:(t,e)=>l.getInstance().ask(t,e),danger:t=>l.getInstance().danger(t),component:(t,e)=>l.getInstance().component(t,e),simple:(t,e)=>l.getInstance().component(t,e),dismiss:()=>l.getInstance().dismiss()};var x=Object.getOwnPropertyDescriptor;exports.SchmancyDialog=class extends u.$LitElement(c.css`
50
- :host {
51
- position: fixed;
52
- z-index: 10000;
53
- inset: 0;
54
- display: none;
55
- --dialog-width: 360px;
56
- }
57
-
58
- :host([active]) {
59
- display: block;
60
- }
61
-
62
- .overlay {
63
- position: fixed;
64
- inset: 0;
65
- background: rgba(0, 0, 0, 0.4);
66
- }
67
-
68
- .dialog {
69
- position: absolute;
70
- max-width: var(--dialog-width);
71
- width: max-content;
72
- max-height: calc(100vh - 40px); /* Prevent exceeding viewport height */
73
- /* Center initially */
74
- top: 50%;
75
- left: 50%;
76
- transform: translate(-50%, -55%); /* Slight upward shift looks better */
77
- overflow: auto; /* Allow scrolling for oversized content */
78
- }
79
- `){constructor(){super(...arguments),this.position={x:0,y:0}}async show(t){let e,i;if(t)if("clientX"in t)e=t.clientX,i=t.clientY;else if("touches"in t&&t.touches.length)e=t.touches[0].clientX,i=t.touches[0].clientY;else{const n=t;e=n.x,i=n.y}else e=window.innerWidth/2,i=window.innerHeight/2;return this.position=this.calculatePosition(e,i),this.setAttribute("active",""),new Promise(n=>{this.resolvePromise=n})}hide(t=!1){this.removeAttribute("active"),this.resolvePromise&&(this.resolvePromise(t),this.resolvePromise=void 0)}calculatePosition(t,e){const i=window.innerWidth,n=window.innerHeight;return{x:t=Math.max(20,Math.min(t,i-20)),y:e=Math.max(20,Math.min(e,n-20))}}firstUpdated(){var p;const t=(p=this.shadowRoot)==null?void 0:p.querySelector(".dialog");if(!t)return;const e=t.offsetWidth,i=t.offsetHeight,n=window.innerWidth,s=window.innerHeight,o=20;let{x:a,y:r}=this.position;Math.abs(a-n/2)<10&&Math.abs(r-s/2)<10||(a+e>n-o&&(a=n-e-o),a<o&&(a=o),e>n-40&&(a=(n-e)/2),r+i>s-o&&(r=r>i+o?r-i-o:Math.max(o,(s-i)/2)),r<o&&(r=o),i>s-40&&(r=o),t.style.transform="none",t.style.left=`${Math.max(0,Math.round(a))}px`,t.style.top=`${Math.max(0,Math.round(r))}px`)}handleClose(){this.hide(!1),this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))}render(){return c.html`
80
- <div class="overlay" @click=${this.handleClose}></div>
81
-
82
- <div class="dialog" role="dialog" aria-modal="true">
83
- <schmancy-surface rounded="all" elevation="3" type="containerHigh">
84
- <div class="p-4">
85
- <slot></slot>
86
- </div>
87
- </schmancy-surface>
88
- </div>
89
- `}},exports.SchmancyDialog=((t,e,i,n)=>{for(var s,o=n>1?void 0:n?x(e,i):e,a=t.length-1;a>=0;a--)(s=t[a])&&(o=s(o)||o);return o})([d.customElement("schmancy-dialog")],exports.SchmancyDialog),exports.$dialog=y,exports.DialogService=l;
90
- //# sourceMappingURL=dialog.component-Cxen6yCU.cjs.map