@zentto/studio 0.1.0 → 0.2.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/fields/zs-confirm-dialog.d.ts +62 -0
- package/dist/fields/zs-confirm-dialog.d.ts.map +1 -0
- package/dist/fields/zs-confirm-dialog.js +234 -0
- package/dist/fields/zs-confirm-dialog.js.map +1 -0
- package/dist/fields/zs-modal.d.ts +39 -0
- package/dist/fields/zs-modal.d.ts.map +1 -0
- package/dist/fields/zs-modal.js +352 -0
- package/dist/fields/zs-modal.js.map +1 -0
- package/dist/fields/zs-toast.d.ts +40 -0
- package/dist/fields/zs-toast.d.ts.map +1 -0
- package/dist/fields/zs-toast.js +218 -0
- package/dist/fields/zs-toast.js.map +1 -0
- package/dist/zentto-studio-app.d.ts +2 -1
- package/dist/zentto-studio-app.d.ts.map +1 -1
- package/dist/zentto-studio-app.js +27 -5
- package/dist/zentto-studio-app.js.map +1 -1
- package/dist/zentto-studio-renderer.d.ts +8 -0
- package/dist/zentto-studio-renderer.d.ts.map +1 -1
- package/dist/zentto-studio-renderer.js +10 -1
- package/dist/zentto-studio-renderer.js.map +1 -1
- package/package.json +5 -2
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
// @zentto/studio — Modal / Dialog system
|
|
2
|
+
// Supports: alert, confirm, form, custom content, fullscreen, side-panel
|
|
3
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
+
};
|
|
9
|
+
import { LitElement, html, css } from 'lit';
|
|
10
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
11
|
+
import { studioTokens } from '../styles/tokens.js';
|
|
12
|
+
let ZsModal = class ZsModal extends LitElement {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.open = false;
|
|
16
|
+
this.title = '';
|
|
17
|
+
this.subtitle = '';
|
|
18
|
+
this.icon = '';
|
|
19
|
+
this.size = 'md';
|
|
20
|
+
this.variant = 'default';
|
|
21
|
+
this.closable = true;
|
|
22
|
+
this.closeOnBackdrop = true;
|
|
23
|
+
this.hideFooter = false;
|
|
24
|
+
this.hideHeader = false;
|
|
25
|
+
// Confirm dialog props
|
|
26
|
+
this.confirmText = '';
|
|
27
|
+
this.cancelText = 'Cancelar';
|
|
28
|
+
this.okText = 'Aceptar';
|
|
29
|
+
this.okVariant = 'primary';
|
|
30
|
+
this.loading = false;
|
|
31
|
+
// Confirm with input (type to confirm)
|
|
32
|
+
this.confirmInput = ''; // if set, user must type this to confirm
|
|
33
|
+
this.confirmInputValue = '';
|
|
34
|
+
this.handleKeydown = (e) => {
|
|
35
|
+
if (e.key === 'Escape' && this.closable)
|
|
36
|
+
this.close('escape');
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
static { this.styles = [studioTokens, css `
|
|
40
|
+
:host { display: contents; }
|
|
41
|
+
|
|
42
|
+
/* Backdrop */
|
|
43
|
+
.zs-backdrop {
|
|
44
|
+
position: fixed; inset: 0; z-index: 9998;
|
|
45
|
+
background: rgba(0, 0, 0, 0.5);
|
|
46
|
+
backdrop-filter: blur(4px);
|
|
47
|
+
display: flex; align-items: center; justify-content: center;
|
|
48
|
+
opacity: 0; pointer-events: none;
|
|
49
|
+
transition: opacity 200ms ease;
|
|
50
|
+
}
|
|
51
|
+
.zs-backdrop--open { opacity: 1; pointer-events: auto; }
|
|
52
|
+
|
|
53
|
+
/* Dialog */
|
|
54
|
+
.zs-dialog {
|
|
55
|
+
background: var(--zs-bg, #fff);
|
|
56
|
+
border-radius: 12px;
|
|
57
|
+
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
|
|
58
|
+
display: flex; flex-direction: column;
|
|
59
|
+
max-height: 90vh;
|
|
60
|
+
transform: translateY(20px) scale(0.97);
|
|
61
|
+
transition: transform 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
62
|
+
overflow: hidden;
|
|
63
|
+
}
|
|
64
|
+
.zs-backdrop--open .zs-dialog {
|
|
65
|
+
transform: translateY(0) scale(1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* Sizes */
|
|
69
|
+
.zs-dialog--sm { width: 400px; }
|
|
70
|
+
.zs-dialog--md { width: 560px; }
|
|
71
|
+
.zs-dialog--lg { width: 760px; }
|
|
72
|
+
.zs-dialog--xl { width: 960px; }
|
|
73
|
+
.zs-dialog--fullscreen {
|
|
74
|
+
width: 100vw; height: 100vh; max-height: 100vh;
|
|
75
|
+
border-radius: 0;
|
|
76
|
+
}
|
|
77
|
+
.zs-dialog--side-right {
|
|
78
|
+
position: fixed; right: 0; top: 0; bottom: 0;
|
|
79
|
+
width: 480px; max-height: 100vh; height: 100vh;
|
|
80
|
+
border-radius: 12px 0 0 12px;
|
|
81
|
+
transform: translateX(100%);
|
|
82
|
+
}
|
|
83
|
+
.zs-backdrop--open .zs-dialog--side-right { transform: translateX(0); }
|
|
84
|
+
.zs-dialog--side-left {
|
|
85
|
+
position: fixed; left: 0; top: 0; bottom: 0;
|
|
86
|
+
width: 480px; max-height: 100vh; height: 100vh;
|
|
87
|
+
border-radius: 0 12px 12px 0;
|
|
88
|
+
transform: translateX(-100%);
|
|
89
|
+
}
|
|
90
|
+
.zs-backdrop--open .zs-dialog--side-left { transform: translateX(0); }
|
|
91
|
+
|
|
92
|
+
/* Header */
|
|
93
|
+
.zs-dialog-header {
|
|
94
|
+
display: flex; align-items: center; gap: 12px;
|
|
95
|
+
padding: 20px 24px 16px;
|
|
96
|
+
border-bottom: 1px solid var(--zs-border, #dee2e6);
|
|
97
|
+
}
|
|
98
|
+
.zs-dialog-icon {
|
|
99
|
+
width: 40px; height: 40px; border-radius: 10px;
|
|
100
|
+
display: flex; align-items: center; justify-content: center;
|
|
101
|
+
font-size: 20px; flex-shrink: 0;
|
|
102
|
+
}
|
|
103
|
+
.zs-dialog-icon--default { background: var(--zs-bg-secondary); }
|
|
104
|
+
.zs-dialog-icon--danger { background: #fde8e8; color: #e74c3c; }
|
|
105
|
+
.zs-dialog-icon--success { background: #d4edda; color: #27ae60; }
|
|
106
|
+
.zs-dialog-icon--warning { background: #fff3cd; color: #f39c12; }
|
|
107
|
+
.zs-dialog-icon--info { background: #d1ecf1; color: #3498db; }
|
|
108
|
+
.zs-dialog-title {
|
|
109
|
+
font-size: 18px; font-weight: 600; color: var(--zs-text, #212529);
|
|
110
|
+
margin: 0; flex: 1;
|
|
111
|
+
}
|
|
112
|
+
.zs-dialog-subtitle {
|
|
113
|
+
font-size: 13px; color: var(--zs-text-secondary, #6c757d);
|
|
114
|
+
margin: 2px 0 0;
|
|
115
|
+
}
|
|
116
|
+
.zs-dialog-close {
|
|
117
|
+
width: 32px; height: 32px; border-radius: 8px;
|
|
118
|
+
border: none; background: none; cursor: pointer;
|
|
119
|
+
font-size: 18px; color: var(--zs-text-muted, #adb5bd);
|
|
120
|
+
display: flex; align-items: center; justify-content: center;
|
|
121
|
+
transition: all 150ms;
|
|
122
|
+
}
|
|
123
|
+
.zs-dialog-close:hover {
|
|
124
|
+
background: var(--zs-bg-hover, #f1f3f5);
|
|
125
|
+
color: var(--zs-text, #212529);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* Body */
|
|
129
|
+
.zs-dialog-body {
|
|
130
|
+
padding: 20px 24px;
|
|
131
|
+
overflow-y: auto; flex: 1;
|
|
132
|
+
font-size: 14px; color: var(--zs-text, #212529);
|
|
133
|
+
line-height: 1.6;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* Footer */
|
|
137
|
+
.zs-dialog-footer {
|
|
138
|
+
display: flex; gap: 8px; justify-content: flex-end;
|
|
139
|
+
padding: 16px 24px;
|
|
140
|
+
border-top: 1px solid var(--zs-border, #dee2e6);
|
|
141
|
+
background: var(--zs-bg-secondary, #f8f9fa);
|
|
142
|
+
}
|
|
143
|
+
.zs-dialog-footer--spread { justify-content: space-between; }
|
|
144
|
+
|
|
145
|
+
/* Buttons */
|
|
146
|
+
.zs-dlg-btn {
|
|
147
|
+
padding: 9px 20px; border-radius: 8px;
|
|
148
|
+
font-family: var(--zs-font-family, sans-serif);
|
|
149
|
+
font-size: 14px; font-weight: 500;
|
|
150
|
+
cursor: pointer; border: 1px solid transparent;
|
|
151
|
+
transition: all 150ms;
|
|
152
|
+
}
|
|
153
|
+
.zs-dlg-btn--primary { background: var(--zs-primary, #e67e22); color: white; }
|
|
154
|
+
.zs-dlg-btn--primary:hover { filter: brightness(0.9); }
|
|
155
|
+
.zs-dlg-btn--secondary {
|
|
156
|
+
background: var(--zs-bg, #fff); color: var(--zs-text, #212529);
|
|
157
|
+
border-color: var(--zs-border, #dee2e6);
|
|
158
|
+
}
|
|
159
|
+
.zs-dlg-btn--secondary:hover { background: var(--zs-bg-hover, #f1f3f5); }
|
|
160
|
+
.zs-dlg-btn--danger { background: #e74c3c; color: white; }
|
|
161
|
+
.zs-dlg-btn--danger:hover { background: #c0392b; }
|
|
162
|
+
.zs-dlg-btn--success { background: #27ae60; color: white; }
|
|
163
|
+
.zs-dlg-btn--success:hover { background: #219a52; }
|
|
164
|
+
.zs-dlg-btn--ghost {
|
|
165
|
+
background: none; color: var(--zs-text-secondary, #6c757d);
|
|
166
|
+
}
|
|
167
|
+
.zs-dlg-btn--ghost:hover { color: var(--zs-text); background: var(--zs-bg-hover); }
|
|
168
|
+
.zs-dlg-btn:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
169
|
+
.zs-dlg-btn--loading {
|
|
170
|
+
position: relative; color: transparent; pointer-events: none;
|
|
171
|
+
}
|
|
172
|
+
.zs-dlg-btn--loading::after {
|
|
173
|
+
content: ''; position: absolute; inset: 0;
|
|
174
|
+
display: flex; align-items: center; justify-content: center;
|
|
175
|
+
font-size: 14px; color: white;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/* Confirm specific */
|
|
179
|
+
.zs-confirm-text { font-size: 15px; line-height: 1.6; color: var(--zs-text); }
|
|
180
|
+
.zs-confirm-input {
|
|
181
|
+
width: 100%; margin-top: 12px; padding: 8px 12px;
|
|
182
|
+
border: 1px solid var(--zs-border); border-radius: 6px;
|
|
183
|
+
font-size: 14px; font-family: var(--zs-font-family);
|
|
184
|
+
outline: none; box-sizing: border-box;
|
|
185
|
+
}
|
|
186
|
+
.zs-confirm-input:focus { border-color: var(--zs-primary); }
|
|
187
|
+
.zs-confirm-hint {
|
|
188
|
+
font-size: 12px; color: var(--zs-text-muted);
|
|
189
|
+
margin-top: 4px;
|
|
190
|
+
}
|
|
191
|
+
`]; }
|
|
192
|
+
get canConfirm() {
|
|
193
|
+
if (!this.confirmInput)
|
|
194
|
+
return true;
|
|
195
|
+
return this.confirmInputValue === this.confirmInput;
|
|
196
|
+
}
|
|
197
|
+
handleBackdropClick(e) {
|
|
198
|
+
if (e.target === e.currentTarget && this.closeOnBackdrop && this.closable) {
|
|
199
|
+
this.close('backdrop');
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
connectedCallback() {
|
|
203
|
+
super.connectedCallback();
|
|
204
|
+
document.addEventListener('keydown', this.handleKeydown);
|
|
205
|
+
}
|
|
206
|
+
disconnectedCallback() {
|
|
207
|
+
super.disconnectedCallback();
|
|
208
|
+
document.removeEventListener('keydown', this.handleKeydown);
|
|
209
|
+
}
|
|
210
|
+
close(reason = 'close') {
|
|
211
|
+
this.open = false;
|
|
212
|
+
this.confirmInputValue = '';
|
|
213
|
+
this.dispatchEvent(new CustomEvent('modal-close', {
|
|
214
|
+
detail: { reason },
|
|
215
|
+
bubbles: true, composed: true,
|
|
216
|
+
}));
|
|
217
|
+
}
|
|
218
|
+
confirm() {
|
|
219
|
+
if (!this.canConfirm)
|
|
220
|
+
return;
|
|
221
|
+
this.dispatchEvent(new CustomEvent('modal-confirm', {
|
|
222
|
+
detail: {},
|
|
223
|
+
bubbles: true, composed: true,
|
|
224
|
+
}));
|
|
225
|
+
if (!this.loading)
|
|
226
|
+
this.close('ok');
|
|
227
|
+
}
|
|
228
|
+
cancel() {
|
|
229
|
+
this.dispatchEvent(new CustomEvent('modal-cancel', {
|
|
230
|
+
detail: {},
|
|
231
|
+
bubbles: true, composed: true,
|
|
232
|
+
}));
|
|
233
|
+
this.close('cancel');
|
|
234
|
+
}
|
|
235
|
+
getVariantIcon() {
|
|
236
|
+
if (this.icon)
|
|
237
|
+
return this.icon;
|
|
238
|
+
const icons = {
|
|
239
|
+
default: '💬',
|
|
240
|
+
danger: '⚠️',
|
|
241
|
+
success: '✅',
|
|
242
|
+
warning: '⚡',
|
|
243
|
+
info: 'ℹ️',
|
|
244
|
+
};
|
|
245
|
+
return icons[this.variant];
|
|
246
|
+
}
|
|
247
|
+
render() {
|
|
248
|
+
const backdropClass = `zs-backdrop ${this.open ? 'zs-backdrop--open' : ''}`;
|
|
249
|
+
const dialogClass = `zs-dialog zs-dialog--${this.size}`;
|
|
250
|
+
const iconClass = `zs-dialog-icon zs-dialog-icon--${this.variant}`;
|
|
251
|
+
return html `
|
|
252
|
+
<div class="${backdropClass}" @click="${this.handleBackdropClick}">
|
|
253
|
+
<div class="${dialogClass}" @click="${(e) => e.stopPropagation()}">
|
|
254
|
+
|
|
255
|
+
${!this.hideHeader ? html `
|
|
256
|
+
<div class="zs-dialog-header">
|
|
257
|
+
<div class="${iconClass}">${this.getVariantIcon()}</div>
|
|
258
|
+
<div style="flex:1;">
|
|
259
|
+
<h3 class="zs-dialog-title">${this.title}</h3>
|
|
260
|
+
${this.subtitle ? html `<p class="zs-dialog-subtitle">${this.subtitle}</p>` : ''}
|
|
261
|
+
</div>
|
|
262
|
+
${this.closable ? html `
|
|
263
|
+
<button class="zs-dialog-close" @click="${() => this.close('close')}">✕</button>
|
|
264
|
+
` : ''}
|
|
265
|
+
</div>
|
|
266
|
+
` : ''}
|
|
267
|
+
|
|
268
|
+
<div class="zs-dialog-body">
|
|
269
|
+
${this.confirmText ? html `
|
|
270
|
+
<p class="zs-confirm-text">${this.confirmText}</p>
|
|
271
|
+
${this.confirmInput ? html `
|
|
272
|
+
<input class="zs-confirm-input"
|
|
273
|
+
placeholder="Escribe '${this.confirmInput}' para confirmar"
|
|
274
|
+
.value="${this.confirmInputValue}"
|
|
275
|
+
@input="${(e) => { this.confirmInputValue = e.target.value; }}"
|
|
276
|
+
/>
|
|
277
|
+
<div class="zs-confirm-hint">Escribe <strong>${this.confirmInput}</strong> para habilitar el boton</div>
|
|
278
|
+
` : ''}
|
|
279
|
+
` : ''}
|
|
280
|
+
<slot></slot>
|
|
281
|
+
</div>
|
|
282
|
+
|
|
283
|
+
${!this.hideFooter ? html `
|
|
284
|
+
<div class="zs-dialog-footer">
|
|
285
|
+
<button class="zs-dlg-btn zs-dlg-btn--secondary" @click="${this.cancel}">${this.cancelText}</button>
|
|
286
|
+
<button class="zs-dlg-btn zs-dlg-btn--${this.okVariant} ${this.loading ? 'zs-dlg-btn--loading' : ''}"
|
|
287
|
+
?disabled="${!this.canConfirm || this.loading}"
|
|
288
|
+
@click="${this.confirm}"
|
|
289
|
+
>${this.loading ? '...' : this.okText}</button>
|
|
290
|
+
</div>
|
|
291
|
+
` : ''}
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
294
|
+
`;
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
__decorate([
|
|
298
|
+
property({ type: Boolean, reflect: true })
|
|
299
|
+
], ZsModal.prototype, "open", void 0);
|
|
300
|
+
__decorate([
|
|
301
|
+
property()
|
|
302
|
+
], ZsModal.prototype, "title", void 0);
|
|
303
|
+
__decorate([
|
|
304
|
+
property()
|
|
305
|
+
], ZsModal.prototype, "subtitle", void 0);
|
|
306
|
+
__decorate([
|
|
307
|
+
property()
|
|
308
|
+
], ZsModal.prototype, "icon", void 0);
|
|
309
|
+
__decorate([
|
|
310
|
+
property()
|
|
311
|
+
], ZsModal.prototype, "size", void 0);
|
|
312
|
+
__decorate([
|
|
313
|
+
property()
|
|
314
|
+
], ZsModal.prototype, "variant", void 0);
|
|
315
|
+
__decorate([
|
|
316
|
+
property({ type: Boolean })
|
|
317
|
+
], ZsModal.prototype, "closable", void 0);
|
|
318
|
+
__decorate([
|
|
319
|
+
property({ type: Boolean })
|
|
320
|
+
], ZsModal.prototype, "closeOnBackdrop", void 0);
|
|
321
|
+
__decorate([
|
|
322
|
+
property({ type: Boolean })
|
|
323
|
+
], ZsModal.prototype, "hideFooter", void 0);
|
|
324
|
+
__decorate([
|
|
325
|
+
property({ type: Boolean })
|
|
326
|
+
], ZsModal.prototype, "hideHeader", void 0);
|
|
327
|
+
__decorate([
|
|
328
|
+
property()
|
|
329
|
+
], ZsModal.prototype, "confirmText", void 0);
|
|
330
|
+
__decorate([
|
|
331
|
+
property()
|
|
332
|
+
], ZsModal.prototype, "cancelText", void 0);
|
|
333
|
+
__decorate([
|
|
334
|
+
property()
|
|
335
|
+
], ZsModal.prototype, "okText", void 0);
|
|
336
|
+
__decorate([
|
|
337
|
+
property()
|
|
338
|
+
], ZsModal.prototype, "okVariant", void 0);
|
|
339
|
+
__decorate([
|
|
340
|
+
property({ type: Boolean })
|
|
341
|
+
], ZsModal.prototype, "loading", void 0);
|
|
342
|
+
__decorate([
|
|
343
|
+
property()
|
|
344
|
+
], ZsModal.prototype, "confirmInput", void 0);
|
|
345
|
+
__decorate([
|
|
346
|
+
state()
|
|
347
|
+
], ZsModal.prototype, "confirmInputValue", void 0);
|
|
348
|
+
ZsModal = __decorate([
|
|
349
|
+
customElement('zs-modal')
|
|
350
|
+
], ZsModal);
|
|
351
|
+
export { ZsModal };
|
|
352
|
+
//# sourceMappingURL=zs-modal.js.map
|
|
@@ -0,0 +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,IAAI,EAAE,CAAC;qCAAc;AAC7C;IAAX,QAAQ,EAAE;sCAAY;AACX;IAAX,QAAQ,EAAE;yCAAe;AACd;IAAX,QAAQ,EAAE;qCAAW;AACV;IAAX,QAAQ,EAAE;qCAAwB;AACvB;IAAX,QAAQ,EAAE;wCAAmC;AACjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCAAiB;AAChB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAAwB;AACvB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CAAoB;AACnB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CAAoB;AAGpC;IAAX,QAAQ,EAAE;4CAAkB;AACjB;IAAX,QAAQ,EAAE;2CAAyB;AACxB;IAAX,QAAQ,EAAE;uCAAoB;AACnB;IAAX,QAAQ,EAAE;0CAAyD;AACvC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCAAiB;AAGjC;IAAX,QAAQ,EAAE;6CAAmB;AACb;IAAhB,KAAK,EAAE;kDAAgC;AA/K7B,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CAkSnB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export interface ToastMessage {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
message?: string;
|
|
6
|
+
type: 'success' | 'error' | 'warning' | 'info';
|
|
7
|
+
duration?: number;
|
|
8
|
+
action?: string;
|
|
9
|
+
actionId?: string;
|
|
10
|
+
dismissable?: boolean;
|
|
11
|
+
icon?: string;
|
|
12
|
+
progress?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare class ZsToast extends LitElement {
|
|
15
|
+
static styles: import("lit").CSSResult[];
|
|
16
|
+
position: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';
|
|
17
|
+
maxVisible: number;
|
|
18
|
+
private toasts;
|
|
19
|
+
private getDefaultIcon;
|
|
20
|
+
/** Add a toast notification */
|
|
21
|
+
show(toast: Omit<ToastMessage, 'id'> & {
|
|
22
|
+
id?: string;
|
|
23
|
+
}): void;
|
|
24
|
+
/** Dismiss a toast by ID */
|
|
25
|
+
dismiss(id: string): void;
|
|
26
|
+
/** Clear all toasts */
|
|
27
|
+
clear(): void;
|
|
28
|
+
/** Convenience methods */
|
|
29
|
+
success(title: string, message?: string): void;
|
|
30
|
+
error(title: string, message?: string): void;
|
|
31
|
+
warning(title: string, message?: string): void;
|
|
32
|
+
info(title: string, message?: string): void;
|
|
33
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
34
|
+
}
|
|
35
|
+
declare global {
|
|
36
|
+
interface HTMLElementTagNameMap {
|
|
37
|
+
'zs-toast': ZsToast;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=zs-toast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zs-toast.d.ts","sourceRoot":"","sources":["../../src/fields/zs-toast.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAIrD,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,qBACa,OAAQ,SAAQ,UAAU;IACrC,MAAM,CAAC,MAAM,4BA+FV;IAES,QAAQ,EAAE,WAAW,GAAG,UAAU,GAAG,cAAc,GAAG,aAAa,GAAG,YAAY,GAAG,eAAe,CAAe;IACnG,UAAU,SAAK;IAElC,OAAO,CAAC,MAAM,CAAuF;IAE9G,OAAO,CAAC,cAAc;IAItB,+BAA+B;IAC/B,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE;IAgCtD,4BAA4B;IAC5B,OAAO,CAAC,EAAE,EAAE,MAAM;IAYlB,uBAAuB;IACvB,KAAK;IAOL,0BAA0B;IAC1B,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IACvC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IACrC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IACvC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IAEpC,MAAM;CA6BP;AAED,OAAO,CAAC,MAAM,CAAC;IAAE,UAAU,qBAAqB;QAAG,UAAU,EAAE,OAAO,CAAC;KAAE;CAAE"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// @zentto/studio — Toast notification system
|
|
2
|
+
// Stackable toasts with auto-dismiss, action buttons, progress bar
|
|
3
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
+
};
|
|
9
|
+
import { LitElement, html, css } from 'lit';
|
|
10
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
11
|
+
import { studioTokens } from '../styles/tokens.js';
|
|
12
|
+
let ZsToast = class ZsToast extends LitElement {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.position = 'top-right';
|
|
16
|
+
this.maxVisible = 5;
|
|
17
|
+
this.toasts = [];
|
|
18
|
+
}
|
|
19
|
+
static { this.styles = [studioTokens, css `
|
|
20
|
+
:host { display: contents; }
|
|
21
|
+
|
|
22
|
+
.zs-toast-container {
|
|
23
|
+
position: fixed; z-index: 9999;
|
|
24
|
+
display: flex; flex-direction: column; gap: 8px;
|
|
25
|
+
max-width: 420px; width: 100%;
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
}
|
|
28
|
+
.zs-toast-container--top-right { top: 16px; right: 16px; }
|
|
29
|
+
.zs-toast-container--top-left { top: 16px; left: 16px; }
|
|
30
|
+
.zs-toast-container--bottom-right { bottom: 16px; right: 16px; }
|
|
31
|
+
.zs-toast-container--bottom-left { bottom: 16px; left: 16px; }
|
|
32
|
+
.zs-toast-container--top-center { top: 16px; left: 50%; transform: translateX(-50%); }
|
|
33
|
+
.zs-toast-container--bottom-center { bottom: 16px; left: 50%; transform: translateX(-50%); }
|
|
34
|
+
|
|
35
|
+
.zs-toast-item {
|
|
36
|
+
display: flex; align-items: flex-start; gap: 12px;
|
|
37
|
+
padding: 14px 16px;
|
|
38
|
+
background: var(--zs-bg, #fff);
|
|
39
|
+
border-radius: 10px;
|
|
40
|
+
border-left: 4px solid;
|
|
41
|
+
box-shadow: 0 8px 30px rgba(0,0,0,0.12);
|
|
42
|
+
pointer-events: auto;
|
|
43
|
+
animation: zs-toast-in 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
44
|
+
position: relative;
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
transition: all 200ms;
|
|
47
|
+
}
|
|
48
|
+
.zs-toast-item--removing {
|
|
49
|
+
animation: zs-toast-out 200ms ease forwards;
|
|
50
|
+
}
|
|
51
|
+
.zs-toast-item--success { border-left-color: #27ae60; }
|
|
52
|
+
.zs-toast-item--error { border-left-color: #e74c3c; }
|
|
53
|
+
.zs-toast-item--warning { border-left-color: #f39c12; }
|
|
54
|
+
.zs-toast-item--info { border-left-color: #3498db; }
|
|
55
|
+
|
|
56
|
+
@keyframes zs-toast-in {
|
|
57
|
+
from { opacity: 0; transform: translateX(30px) scale(0.95); }
|
|
58
|
+
to { opacity: 1; transform: translateX(0) scale(1); }
|
|
59
|
+
}
|
|
60
|
+
@keyframes zs-toast-out {
|
|
61
|
+
from { opacity: 1; transform: translateX(0); max-height: 200px; }
|
|
62
|
+
to { opacity: 0; transform: translateX(60px); max-height: 0; padding: 0; margin: 0; }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.zs-toast-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
|
|
66
|
+
.zs-toast-content { flex: 1; min-width: 0; }
|
|
67
|
+
.zs-toast-title {
|
|
68
|
+
font-size: 14px; font-weight: 600;
|
|
69
|
+
color: var(--zs-text, #212529);
|
|
70
|
+
margin: 0;
|
|
71
|
+
}
|
|
72
|
+
.zs-toast-message {
|
|
73
|
+
font-size: 13px; color: var(--zs-text-secondary, #6c757d);
|
|
74
|
+
margin: 2px 0 0; line-height: 1.4;
|
|
75
|
+
}
|
|
76
|
+
.zs-toast-actions {
|
|
77
|
+
display: flex; gap: 8px; margin-top: 8px;
|
|
78
|
+
}
|
|
79
|
+
.zs-toast-action {
|
|
80
|
+
padding: 4px 12px; border-radius: 6px;
|
|
81
|
+
font-size: 12px; font-weight: 600;
|
|
82
|
+
cursor: pointer; border: none;
|
|
83
|
+
transition: all 100ms;
|
|
84
|
+
}
|
|
85
|
+
.zs-toast-action--primary {
|
|
86
|
+
background: var(--zs-primary, #e67e22); color: white;
|
|
87
|
+
}
|
|
88
|
+
.zs-toast-action--primary:hover { filter: brightness(0.9); }
|
|
89
|
+
.zs-toast-action--secondary {
|
|
90
|
+
background: var(--zs-bg-secondary, #f8f9fa);
|
|
91
|
+
color: var(--zs-text-secondary); border: 1px solid var(--zs-border);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.zs-toast-close {
|
|
95
|
+
border: none; background: none; cursor: pointer;
|
|
96
|
+
color: var(--zs-text-muted, #adb5bd); font-size: 16px;
|
|
97
|
+
padding: 0; line-height: 1; transition: color 100ms;
|
|
98
|
+
flex-shrink: 0;
|
|
99
|
+
}
|
|
100
|
+
.zs-toast-close:hover { color: var(--zs-text); }
|
|
101
|
+
|
|
102
|
+
/* Progress bar */
|
|
103
|
+
.zs-toast-progress {
|
|
104
|
+
position: absolute; bottom: 0; left: 0; right: 0;
|
|
105
|
+
height: 3px; background: rgba(0,0,0,0.06);
|
|
106
|
+
}
|
|
107
|
+
.zs-toast-progress-bar {
|
|
108
|
+
height: 100%; transition: width 100ms linear;
|
|
109
|
+
}
|
|
110
|
+
.zs-toast-progress-bar--success { background: #27ae60; }
|
|
111
|
+
.zs-toast-progress-bar--error { background: #e74c3c; }
|
|
112
|
+
.zs-toast-progress-bar--warning { background: #f39c12; }
|
|
113
|
+
.zs-toast-progress-bar--info { background: #3498db; }
|
|
114
|
+
`]; }
|
|
115
|
+
getDefaultIcon(type) {
|
|
116
|
+
return { success: '✅', error: '❌', warning: '⚠️', info: 'ℹ️' }[type] ?? 'ℹ️';
|
|
117
|
+
}
|
|
118
|
+
/** Add a toast notification */
|
|
119
|
+
show(toast) {
|
|
120
|
+
const id = toast.id ?? `toast-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
121
|
+
const duration = toast.duration ?? 4000;
|
|
122
|
+
const item = {
|
|
123
|
+
...toast, id,
|
|
124
|
+
dismissable: toast.dismissable ?? true,
|
|
125
|
+
progress: toast.progress ?? true,
|
|
126
|
+
_progress: 100,
|
|
127
|
+
};
|
|
128
|
+
this.toasts = [...this.toasts.slice(-(this.maxVisible - 1)), item];
|
|
129
|
+
if (duration > 0) {
|
|
130
|
+
const startTime = Date.now();
|
|
131
|
+
const tick = () => {
|
|
132
|
+
const elapsed = Date.now() - startTime;
|
|
133
|
+
const remaining = Math.max(0, 100 - (elapsed / duration) * 100);
|
|
134
|
+
const t = this.toasts.find(t => t.id === id);
|
|
135
|
+
if (t) {
|
|
136
|
+
t._progress = remaining;
|
|
137
|
+
this.requestUpdate();
|
|
138
|
+
}
|
|
139
|
+
if (remaining > 0) {
|
|
140
|
+
item._timer = requestAnimationFrame(tick);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
this.dismiss(id);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
item._timer = requestAnimationFrame(tick);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/** Dismiss a toast by ID */
|
|
150
|
+
dismiss(id) {
|
|
151
|
+
const t = this.toasts.find(t => t.id === id);
|
|
152
|
+
if (t) {
|
|
153
|
+
if (t._timer)
|
|
154
|
+
cancelAnimationFrame(t._timer);
|
|
155
|
+
t._removing = true;
|
|
156
|
+
this.requestUpdate();
|
|
157
|
+
setTimeout(() => {
|
|
158
|
+
this.toasts = this.toasts.filter(t => t.id !== id);
|
|
159
|
+
}, 200);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/** Clear all toasts */
|
|
163
|
+
clear() {
|
|
164
|
+
this.toasts.forEach(t => {
|
|
165
|
+
if (t._timer)
|
|
166
|
+
cancelAnimationFrame(t._timer);
|
|
167
|
+
});
|
|
168
|
+
this.toasts = [];
|
|
169
|
+
}
|
|
170
|
+
/** Convenience methods */
|
|
171
|
+
success(title, message) { this.show({ title, message, type: 'success' }); }
|
|
172
|
+
error(title, message) { this.show({ title, message, type: 'error', duration: 6000 }); }
|
|
173
|
+
warning(title, message) { this.show({ title, message, type: 'warning' }); }
|
|
174
|
+
info(title, message) { this.show({ title, message, type: 'info' }); }
|
|
175
|
+
render() {
|
|
176
|
+
return html `
|
|
177
|
+
<div class="zs-toast-container zs-toast-container--${this.position}">
|
|
178
|
+
${this.toasts.map(t => html `
|
|
179
|
+
<div class="zs-toast-item zs-toast-item--${t.type} ${t._removing ? 'zs-toast-item--removing' : ''}">
|
|
180
|
+
<span class="zs-toast-icon">${t.icon ?? this.getDefaultIcon(t.type)}</span>
|
|
181
|
+
<div class="zs-toast-content">
|
|
182
|
+
<div class="zs-toast-title">${t.title}</div>
|
|
183
|
+
${t.message ? html `<div class="zs-toast-message">${t.message}</div>` : ''}
|
|
184
|
+
${t.action ? html `
|
|
185
|
+
<div class="zs-toast-actions">
|
|
186
|
+
<button class="zs-toast-action zs-toast-action--primary" @click="${() => {
|
|
187
|
+
this.dispatchEvent(new CustomEvent('toast-action', { detail: { id: t.id, actionId: t.actionId ?? t.action }, bubbles: true, composed: true }));
|
|
188
|
+
this.dismiss(t.id);
|
|
189
|
+
}}">${t.action}</button>
|
|
190
|
+
</div>
|
|
191
|
+
` : ''}
|
|
192
|
+
</div>
|
|
193
|
+
${t.dismissable ? html `<button class="zs-toast-close" @click="${() => this.dismiss(t.id)}">✕</button>` : ''}
|
|
194
|
+
${t.progress && t.duration !== 0 ? html `
|
|
195
|
+
<div class="zs-toast-progress">
|
|
196
|
+
<div class="zs-toast-progress-bar zs-toast-progress-bar--${t.type}" style="width:${t._progress ?? 100}%"></div>
|
|
197
|
+
</div>
|
|
198
|
+
` : ''}
|
|
199
|
+
</div>
|
|
200
|
+
`)}
|
|
201
|
+
</div>
|
|
202
|
+
`;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
__decorate([
|
|
206
|
+
property()
|
|
207
|
+
], ZsToast.prototype, "position", void 0);
|
|
208
|
+
__decorate([
|
|
209
|
+
property({ type: Number })
|
|
210
|
+
], ZsToast.prototype, "maxVisible", void 0);
|
|
211
|
+
__decorate([
|
|
212
|
+
state()
|
|
213
|
+
], ZsToast.prototype, "toasts", void 0);
|
|
214
|
+
ZsToast = __decorate([
|
|
215
|
+
customElement('zs-toast')
|
|
216
|
+
], ZsToast);
|
|
217
|
+
export { ZsToast };
|
|
218
|
+
//# sourceMappingURL=zs-toast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zs-toast.js","sourceRoot":"","sources":["../../src/fields/zs-toast.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,mEAAmE;;;;;;;AAEnE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAW,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAgB5C,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,UAAU;IAAhC;;QAkGO,aAAQ,GAA+F,WAAW,CAAC;QACnG,eAAU,GAAG,CAAC,CAAC;QAE1B,WAAM,GAAoF,EAAE,CAAC;IA+FhH,CAAC;aAnMQ,WAAM,GAAG,CAAC,YAAY,EAAE,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+FjC,CAAC,AA/FW,CA+FV;IAOK,cAAc,CAAC,IAAY;QACjC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;IAC/E,CAAC;IAED,+BAA+B;IAC/B,IAAI,CAAC,KAAiD;QACpD,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,IAAI,SAAS,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,C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C,CAAC,CAAC,EAAE;;cAEN,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAA,0CAA0C,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE;cACzG,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;;2EAEwB,CAAC,CAAC,IAAI,kBAAkB,CAAC,CAAC,SAAS,IAAI,GAAG;;aAExG,CAAC,CAAC,CAAC,EAAE;;SAET,CAAC;;KAEL,CAAC;IACJ,CAAC;;AAjGW;IAAX,QAAQ,EAAE;yCAAoH;AACnG;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAgB;AAE1B;IAAhB,KAAK,EAAE;uCAAsG;AArGnG,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CAoMnB"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { LitElement, type TemplateResult } from 'lit';
|
|
2
|
-
import type { AppConfig } from '@zentto/studio-core';
|
|
2
|
+
import type { AppConfig, StudioProvider } from '@zentto/studio-core';
|
|
3
3
|
import './zentto-studio-renderer.js';
|
|
4
4
|
export declare class ZenttoStudioApp extends LitElement {
|
|
5
5
|
static styles: import("lit").CSSResult[];
|
|
6
6
|
config: AppConfig | null;
|
|
7
|
+
provider: StudioProvider;
|
|
7
8
|
customCss: string;
|
|
8
9
|
cssVars: Record<string, string>;
|
|
9
10
|
private currentSegment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zentto-studio-app.d.ts","sourceRoot":"","sources":["../src/zentto-studio-app.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAsB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAI1E,OAAO,KAAK,EACV,SAAS,
|
|
1
|
+
{"version":3,"file":"zentto-studio-app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