@wcomp/elementum 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +266 -2
- package/custom-elements.json +3613 -0
- package/mcp/server.js +408 -0
- package/package.json +72 -4
- package/skills/elementum-break-ui/CATALOG.md +11 -0
- package/skills/elementum-break-ui/SKILL.md +16 -0
- package/skills/elementum-mobile/SKILL.md +18 -0
- package/skills/elementum-motion/SKILL.md +18 -0
- package/skills/elementum-motion/STANDARDS.md +15 -0
- package/skills/elementum-penpot/SKILL.md +45 -0
- package/skills/elementum-ui/CATALOG.md +14 -0
- package/skills/elementum-ui/SKILL.md +21 -0
- package/src/ag-ui.js +474 -0
- package/src/components/el-accordion.js +201 -0
- package/src/components/el-alert-dialog.js +186 -0
- package/src/components/el-alert.js +254 -0
- package/src/components/el-aspect-ratio.js +73 -0
- package/src/components/el-autocomplete.js +775 -0
- package/src/components/el-avatar.js +271 -0
- package/src/components/el-badge.js +131 -0
- package/src/components/el-border-beam.js +135 -0
- package/src/components/el-breadcrumb.js +203 -0
- package/src/components/el-button.js +220 -0
- package/src/components/el-calendar.js +413 -0
- package/src/components/el-callout.js +158 -0
- package/src/components/el-card.js +298 -0
- package/src/components/el-carousel.js +308 -0
- package/src/components/el-chart.js +632 -0
- package/src/components/el-checkbox-card.js +221 -0
- package/src/components/el-checkbox.js +208 -0
- package/src/components/el-chip.js +276 -0
- package/src/components/el-code-block.js +228 -0
- package/src/components/el-collapsible.js +124 -0
- package/src/components/el-command.js +556 -0
- package/src/components/el-context-menu.js +328 -0
- package/src/components/el-data-list.js +210 -0
- package/src/components/el-datepicker.js +192 -0
- package/src/components/el-dialog.js +272 -0
- package/src/components/el-diff-viewer.js +441 -0
- package/src/components/el-drawer.js +782 -0
- package/src/components/el-dropdown.js +182 -0
- package/src/components/el-dropzone.js +242 -0
- package/src/components/el-empty-state.js +130 -0
- package/src/components/el-field.js +394 -0
- package/src/components/el-form.js +185 -0
- package/src/components/el-input.js +212 -0
- package/src/components/el-inset.js +90 -0
- package/src/components/el-insight-card.js +263 -0
- package/src/components/el-kbd.js +151 -0
- package/src/components/el-menubar.js +254 -0
- package/src/components/el-meter.js +182 -0
- package/src/components/el-navbar.js +294 -0
- package/src/components/el-navigation-menu.js +327 -0
- package/src/components/el-number-field.js +510 -0
- package/src/components/el-number-flow.js +153 -0
- package/src/components/el-otp-input.js +266 -0
- package/src/components/el-pagination.js +229 -0
- package/src/components/el-popover.js +288 -0
- package/src/components/el-preview-card.js +202 -0
- package/src/components/el-progress.js +179 -0
- package/src/components/el-prompt-input.js +383 -0
- package/src/components/el-radio-card.js +360 -0
- package/src/components/el-radio.js +257 -0
- package/src/components/el-rating.js +165 -0
- package/src/components/el-reasoning-card.js +293 -0
- package/src/components/el-resizable.js +324 -0
- package/src/components/el-router.js +305 -0
- package/src/components/el-scroll-area.js +150 -0
- package/src/components/el-segmented-control.js +282 -0
- package/src/components/el-select.js +219 -0
- package/src/components/el-separator.js +85 -0
- package/src/components/el-sidebar.js +386 -0
- package/src/components/el-skeleton.js +156 -0
- package/src/components/el-slider.js +351 -0
- package/src/components/el-sources.js +288 -0
- package/src/components/el-spinner.js +159 -0
- package/src/components/el-streaming-text.js +199 -0
- package/src/components/el-switch.js +221 -0
- package/src/components/el-table.js +397 -0
- package/src/components/el-tabs.js +235 -0
- package/src/components/el-task-list.js +230 -0
- package/src/components/el-textarea.js +175 -0
- package/src/components/el-theme-switch.js +120 -0
- package/src/components/el-timeline.js +254 -0
- package/src/components/el-toast.js +778 -0
- package/src/components/el-toggle.js +311 -0
- package/src/components/el-tool-call.js +386 -0
- package/src/components/el-toolbar.js +183 -0
- package/src/components/el-tooltip.js +172 -0
- package/src/components/el-tree-view.js +261 -0
- package/src/components/el-visually-hidden.js +32 -0
- package/src/elementum.js +485 -0
- package/src/index.d.ts +1007 -0
- package/src/index.js +99 -0
- package/src/signal.js +194 -0
- package/src/ssr.js +136 -0
- package/src/template.js +321 -0
- package/src/tokens.css +416 -0
- package/tokens/figma-tokens.json +69 -0
- package/tokens/penpot-tokens.json +98 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <el-alert-dialog>
|
|
3
|
+
* Accessible, zero-dependency alert dialog primitive inspired by Base UI.
|
|
4
|
+
* Designed for destructive or critical confirmation flows with strict modal focus trapping
|
|
5
|
+
* and non-dismissible backdrop.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Elementum } from '../elementum.js';
|
|
9
|
+
import { html, css } from '../template.js';
|
|
10
|
+
import { signal } from '../signal.js';
|
|
11
|
+
|
|
12
|
+
export class ElAlertDialog extends Elementum {
|
|
13
|
+
static observedAttributes = ['open', 'heading', 'title'];
|
|
14
|
+
|
|
15
|
+
isOpen = signal(false);
|
|
16
|
+
heading = signal('');
|
|
17
|
+
|
|
18
|
+
#previousFocused = null;
|
|
19
|
+
|
|
20
|
+
static styles = css`
|
|
21
|
+
:host {
|
|
22
|
+
display: inline-block;
|
|
23
|
+
font-family: var(--el-font-sans, system-ui, sans-serif);
|
|
24
|
+
color: var(--el-text-primary, #0f172a);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.backdrop {
|
|
28
|
+
position: fixed;
|
|
29
|
+
inset: 0;
|
|
30
|
+
background: rgba(15, 23, 42, 0.65);
|
|
31
|
+
backdrop-filter: blur(4px);
|
|
32
|
+
z-index: 9998;
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
padding: 16px;
|
|
37
|
+
box-sizing: border-box;
|
|
38
|
+
opacity: 0;
|
|
39
|
+
pointer-events: none;
|
|
40
|
+
transition: opacity 200ms ease;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.backdrop.open {
|
|
44
|
+
opacity: 1;
|
|
45
|
+
pointer-events: auto;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.dialog-window {
|
|
49
|
+
background: var(--el-surface-base, #ffffff);
|
|
50
|
+
border: 1px solid var(--el-surface-border, #e2e8f0);
|
|
51
|
+
border-radius: var(--el-radius-lg, 12px);
|
|
52
|
+
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.08);
|
|
53
|
+
width: 100%;
|
|
54
|
+
max-width: 480px;
|
|
55
|
+
padding: 24px;
|
|
56
|
+
box-sizing: border-box;
|
|
57
|
+
transform: scale(0.95) translateY(8px);
|
|
58
|
+
opacity: 0;
|
|
59
|
+
transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1), opacity 200ms ease;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
:root[data-theme="dark"] .dialog-window {
|
|
63
|
+
background: var(--el-surface-elevated, #1e293b);
|
|
64
|
+
border-color: #334155;
|
|
65
|
+
color: #f8fafc;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.backdrop.open .dialog-window {
|
|
69
|
+
transform: scale(1) translateY(0);
|
|
70
|
+
opacity: 1;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@starting-style {
|
|
74
|
+
.backdrop.open {
|
|
75
|
+
opacity: 0;
|
|
76
|
+
}
|
|
77
|
+
.backdrop.open .dialog-window {
|
|
78
|
+
transform: scale(0.95) translateY(8px);
|
|
79
|
+
opacity: 0;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.dialog-header {
|
|
84
|
+
margin-bottom: 12px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.dialog-title {
|
|
88
|
+
font-size: 1.125rem;
|
|
89
|
+
font-weight: 700;
|
|
90
|
+
margin: 0;
|
|
91
|
+
color: var(--el-text-primary, #0f172a);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
:root[data-theme="dark"] .dialog-title {
|
|
95
|
+
color: #f8fafc;
|
|
96
|
+
}
|
|
97
|
+
`;
|
|
98
|
+
|
|
99
|
+
connected() {
|
|
100
|
+
this.isOpen.value = this.hasAttribute('open');
|
|
101
|
+
this.heading.value = this.getAttribute('heading') || this.getAttribute('title') || '';
|
|
102
|
+
this.setAttribute('data-state', this.isOpen.value ? 'open' : 'closed');
|
|
103
|
+
|
|
104
|
+
this.addEventListener('keydown', (e) => {
|
|
105
|
+
if (this.isOpen.value && e.key === 'Escape') {
|
|
106
|
+
e.preventDefault(); // Alert dialogs require explicit action, but can emit cancel
|
|
107
|
+
this.emit('cancel');
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
attributeChanged(name, oldValue, newValue) {
|
|
113
|
+
if (name === 'open') {
|
|
114
|
+
const open = newValue !== null && newValue !== 'false';
|
|
115
|
+
if (open) this.open();
|
|
116
|
+
else this.close();
|
|
117
|
+
} else if (name === 'heading' || name === 'title') {
|
|
118
|
+
this.heading.value = newValue || '';
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
open() {
|
|
124
|
+
if (!this.isOpen.value) {
|
|
125
|
+
this.#previousFocused = document.activeElement;
|
|
126
|
+
this.isOpen.value = true;
|
|
127
|
+
this.setAttribute('data-state', 'open');
|
|
128
|
+
this.emit('open');
|
|
129
|
+
|
|
130
|
+
const schedule = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : (cb) => setTimeout(cb, 0);
|
|
131
|
+
schedule(() => {
|
|
132
|
+
const focusable = this.root.querySelector('.dialog-window button, .dialog-window [tabindex="0"]') ||
|
|
133
|
+
this.querySelector('button, [tabindex="0"]');
|
|
134
|
+
if (focusable) focusable.focus();
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
close() {
|
|
140
|
+
if (this.isOpen.value) {
|
|
141
|
+
this.isOpen.value = false;
|
|
142
|
+
this.setAttribute('data-state', 'closed');
|
|
143
|
+
this.emit('close');
|
|
144
|
+
if (this.#previousFocused && typeof this.#previousFocused.focus === 'function') {
|
|
145
|
+
this.#previousFocused.focus();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
show() { this.open(); }
|
|
151
|
+
showModal() { this.open(); }
|
|
152
|
+
|
|
153
|
+
render() {
|
|
154
|
+
return html`
|
|
155
|
+
<slot name="trigger" @click=${() => this.open()}></slot>
|
|
156
|
+
|
|
157
|
+
<div
|
|
158
|
+
class=${() => `backdrop ${this.isOpen.value ? 'open' : ''}`}
|
|
159
|
+
data-state=${() => (this.isOpen.value ? 'open' : 'closed')}
|
|
160
|
+
role="presentation"
|
|
161
|
+
>
|
|
162
|
+
<div
|
|
163
|
+
class="dialog-window"
|
|
164
|
+
part="dialog"
|
|
165
|
+
role="alertdialog"
|
|
166
|
+
aria-modal="true"
|
|
167
|
+
aria-labelledby="dialog-title"
|
|
168
|
+
>
|
|
169
|
+
${() =>
|
|
170
|
+
this.heading.value
|
|
171
|
+
? html`
|
|
172
|
+
<div class="dialog-header">
|
|
173
|
+
<h3 id="dialog-title" class="dialog-title">${() => this.heading.value}</h3>
|
|
174
|
+
</div>
|
|
175
|
+
`
|
|
176
|
+
: ''}
|
|
177
|
+
<slot></slot>
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
`;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (typeof customElements !== 'undefined' && !customElements.get('el-alert-dialog')) {
|
|
185
|
+
customElements.define('el-alert-dialog', ElAlertDialog);
|
|
186
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <el-alert>
|
|
3
|
+
* Accessible inline alert banner inspired by shadcn/ui.
|
|
4
|
+
* Supports variants (default, info, success, warning, destructive),
|
|
5
|
+
* optional title, slot description, dismiss button, and ARIA alert roles.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Elementum } from '../elementum.js';
|
|
9
|
+
import { html, css } from '../template.js';
|
|
10
|
+
import { signal } from '../signal.js';
|
|
11
|
+
|
|
12
|
+
export class ElAlert extends Elementum {
|
|
13
|
+
static observedAttributes = ['variant', 'title', 'dismissible', 'label', 'message'];
|
|
14
|
+
|
|
15
|
+
variant = signal('default');
|
|
16
|
+
alertTitle = signal('');
|
|
17
|
+
dismissible = signal(false);
|
|
18
|
+
isDismissed = signal(false);
|
|
19
|
+
label = signal('');
|
|
20
|
+
message = signal('');
|
|
21
|
+
|
|
22
|
+
static styles = css`
|
|
23
|
+
:host {
|
|
24
|
+
display: block;
|
|
25
|
+
font-family: var(--el-font-sans, system-ui, sans-serif);
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
margin-bottom: 12px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
:host([hidden]) {
|
|
31
|
+
display: none !important;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.alert {
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: flex-start;
|
|
37
|
+
gap: 12px;
|
|
38
|
+
padding: 14px 16px;
|
|
39
|
+
border-radius: var(--el-radius-md, 8px);
|
|
40
|
+
border: 1px solid var(--el-surface-border, #e2e8f0);
|
|
41
|
+
background: var(--el-surface-base, #ffffff);
|
|
42
|
+
color: var(--el-text-primary, #0f172a);
|
|
43
|
+
position: relative;
|
|
44
|
+
box-sizing: border-box;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.icon-area {
|
|
48
|
+
flex-shrink: 0;
|
|
49
|
+
margin-top: 1px;
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.content-area {
|
|
56
|
+
flex: 1;
|
|
57
|
+
min-width: 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.title {
|
|
61
|
+
font-size: 0.95rem;
|
|
62
|
+
font-weight: 600;
|
|
63
|
+
line-height: 1.3;
|
|
64
|
+
margin: 0 0 4px 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.description {
|
|
68
|
+
font-size: 0.875rem;
|
|
69
|
+
line-height: 1.45;
|
|
70
|
+
color: var(--el-text-secondary, #475569);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
:root[data-theme="dark"] .description {
|
|
74
|
+
color: #94a3b8;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.dismiss-btn {
|
|
78
|
+
flex-shrink: 0;
|
|
79
|
+
background: transparent;
|
|
80
|
+
border: none;
|
|
81
|
+
color: var(--el-text-muted, #94a3b8);
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
padding: 4px;
|
|
84
|
+
border-radius: var(--el-radius-sm, 4px);
|
|
85
|
+
display: inline-flex;
|
|
86
|
+
align-items: center;
|
|
87
|
+
justify-content: center;
|
|
88
|
+
transition: color 0.15s ease, background-color 0.15s ease;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.dismiss-btn:hover {
|
|
92
|
+
color: var(--el-text-primary, #0f172a);
|
|
93
|
+
background: rgba(0, 0, 0, 0.05);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
:root[data-theme="dark"] .dismiss-btn:hover {
|
|
97
|
+
color: #f8fafc;
|
|
98
|
+
background: rgba(255, 255, 255, 0.1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* Variants */
|
|
102
|
+
:host([variant="info"]) .alert {
|
|
103
|
+
background: #eff6ff;
|
|
104
|
+
border-color: #bfdbfe;
|
|
105
|
+
color: #1e40af;
|
|
106
|
+
}
|
|
107
|
+
:host([variant="info"]) .title { color: #1e3a8a; }
|
|
108
|
+
:host([variant="info"]) .description { color: #1e40af; }
|
|
109
|
+
|
|
110
|
+
:root[data-theme="dark"] :host([variant="info"]) .alert {
|
|
111
|
+
background: rgba(30, 58, 138, 0.25);
|
|
112
|
+
border-color: #1e3a8a;
|
|
113
|
+
color: #bfdbfe;
|
|
114
|
+
}
|
|
115
|
+
:root[data-theme="dark"] :host([variant="info"]) .title { color: #93c5fd; }
|
|
116
|
+
:root[data-theme="dark"] :host([variant="info"]) .description { color: #bfdbfe; }
|
|
117
|
+
|
|
118
|
+
:host([variant="success"]) .alert {
|
|
119
|
+
background: #f0fdf4;
|
|
120
|
+
border-color: #bbf7d0;
|
|
121
|
+
color: #166534;
|
|
122
|
+
}
|
|
123
|
+
:host([variant="success"]) .title { color: #14532d; }
|
|
124
|
+
:host([variant="success"]) .description { color: #166534; }
|
|
125
|
+
|
|
126
|
+
:root[data-theme="dark"] :host([variant="success"]) .alert {
|
|
127
|
+
background: rgba(20, 83, 45, 0.25);
|
|
128
|
+
border-color: #166534;
|
|
129
|
+
color: #bbf7d0;
|
|
130
|
+
}
|
|
131
|
+
:root[data-theme="dark"] :host([variant="success"]) .title { color: #86efac; }
|
|
132
|
+
:root[data-theme="dark"] :host([variant="success"]) .description { color: #bbf7d0; }
|
|
133
|
+
|
|
134
|
+
:host([variant="warning"]) .alert {
|
|
135
|
+
background: #fffbeb;
|
|
136
|
+
border-color: #fde68a;
|
|
137
|
+
color: #92400e;
|
|
138
|
+
}
|
|
139
|
+
:host([variant="warning"]) .title { color: #78350f; }
|
|
140
|
+
:host([variant="warning"]) .description { color: #92400e; }
|
|
141
|
+
|
|
142
|
+
:root[data-theme="dark"] :host([variant="warning"]) .alert {
|
|
143
|
+
background: rgba(120, 53, 15, 0.25);
|
|
144
|
+
border-color: #92400e;
|
|
145
|
+
color: #fde68a;
|
|
146
|
+
}
|
|
147
|
+
:root[data-theme="dark"] :host([variant="warning"]) .title { color: #fcd34d; }
|
|
148
|
+
:root[data-theme="dark"] :host([variant="warning"]) .description { color: #fde68a; }
|
|
149
|
+
|
|
150
|
+
:host([variant="destructive"]) .alert,
|
|
151
|
+
:host([variant="danger"]) .alert,
|
|
152
|
+
:host([variant="error"]) .alert {
|
|
153
|
+
background: #fef2f2;
|
|
154
|
+
border-color: #fecaca;
|
|
155
|
+
color: #991b1b;
|
|
156
|
+
}
|
|
157
|
+
:host([variant="destructive"]) .title,
|
|
158
|
+
:host([variant="danger"]) .title,
|
|
159
|
+
:host([variant="error"]) .title { color: #7f1d1d; }
|
|
160
|
+
:host([variant="destructive"]) .description,
|
|
161
|
+
:host([variant="danger"]) .description,
|
|
162
|
+
:host([variant="error"]) .description { color: #991b1b; }
|
|
163
|
+
|
|
164
|
+
:root[data-theme="dark"] :host([variant="destructive"]) .alert,
|
|
165
|
+
:root[data-theme="dark"] :host([variant="danger"]) .alert,
|
|
166
|
+
:root[data-theme="dark"] :host([variant="error"]) .alert {
|
|
167
|
+
background: rgba(127, 29, 29, 0.25);
|
|
168
|
+
border-color: #991b1b;
|
|
169
|
+
color: #fecaca;
|
|
170
|
+
}
|
|
171
|
+
:root[data-theme="dark"] :host([variant="destructive"]) .title,
|
|
172
|
+
:root[data-theme="dark"] :host([variant="danger"]) .title,
|
|
173
|
+
:root[data-theme="dark"] :host([variant="error"]) .title { color: #fca5a5; }
|
|
174
|
+
:root[data-theme="dark"] :host([variant="destructive"]) .description,
|
|
175
|
+
:root[data-theme="dark"] :host([variant="danger"]) .description,
|
|
176
|
+
:root[data-theme="dark"] :host([variant="error"]) .description { color: #fecaca; }
|
|
177
|
+
`;
|
|
178
|
+
|
|
179
|
+
connected() {
|
|
180
|
+
this.#syncAttrs();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
attributeChanged(name, oldValue, newValue) {
|
|
184
|
+
this.#syncAttrs();
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
#syncAttrs() {
|
|
189
|
+
this.variant.value = this.getAttribute('variant') || 'default';
|
|
190
|
+
this.alertTitle.value = this.getAttribute('title') || '';
|
|
191
|
+
this.dismissible.value = this.hasAttribute('dismissible');
|
|
192
|
+
this.label.value = this.getAttribute('label') || '';
|
|
193
|
+
this.message.value = this.getAttribute('message') || '';
|
|
194
|
+
if (!this.hasAttribute('variant')) this.setAttribute('variant', 'default');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
dismiss = () => {
|
|
198
|
+
this.isDismissed.value = true;
|
|
199
|
+
this.setAttribute('hidden', '');
|
|
200
|
+
this.emit('dismiss');
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
#renderDefaultIcon() {
|
|
204
|
+
const v = this.variant.value;
|
|
205
|
+
if (v === 'destructive' || v === 'danger' || v === 'error') {
|
|
206
|
+
return html`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>`;
|
|
207
|
+
}
|
|
208
|
+
if (v === 'warning') {
|
|
209
|
+
return html`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>`;
|
|
210
|
+
}
|
|
211
|
+
if (v === 'success') {
|
|
212
|
+
return html`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>`;
|
|
213
|
+
}
|
|
214
|
+
// info or default
|
|
215
|
+
return html`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>`;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
render() {
|
|
219
|
+
const role = () => (['destructive', 'danger', 'error'].includes(this.variant.value) ? 'alert' : 'status');
|
|
220
|
+
|
|
221
|
+
return html`
|
|
222
|
+
<div class="alert" part="alert" role=${role}>
|
|
223
|
+
<div class="icon-area" part="icon">
|
|
224
|
+
<slot name="icon">${() => this.#renderDefaultIcon()}</slot>
|
|
225
|
+
</div>
|
|
226
|
+
<div class="content-area" part="content">
|
|
227
|
+
${() => (this.alertTitle.value ? html`<h5 class="title" part="title">${() => this.alertTitle.value}</h5>` : '')}
|
|
228
|
+
<div class="description" part="description">
|
|
229
|
+
<slot>${() => this.message.value || this.label.value || ''}</slot>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
${() =>
|
|
233
|
+
this.dismissible.value
|
|
234
|
+
? html`
|
|
235
|
+
<button
|
|
236
|
+
type="button"
|
|
237
|
+
class="dismiss-btn"
|
|
238
|
+
part="dismiss"
|
|
239
|
+
aria-label="Dismiss alert"
|
|
240
|
+
onclick=${this.dismiss}
|
|
241
|
+
>
|
|
242
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
|
243
|
+
</button>
|
|
244
|
+
`
|
|
245
|
+
: ''
|
|
246
|
+
}
|
|
247
|
+
</div>
|
|
248
|
+
`;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (typeof customElements !== 'undefined' && !customElements.get('el-alert')) {
|
|
253
|
+
customElements.define('el-alert', ElAlert);
|
|
254
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <el-aspect-ratio>
|
|
3
|
+
* Responsive aspect-ratio container inspired by shadcn/ui.
|
|
4
|
+
* Enforces fixed dimensions (e.g. 16/9, 4/3, 1/1, 21/9) to eliminate
|
|
5
|
+
* Cumulative Layout Shift (CLS) for videos, embeds, and hero images.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Elementum } from '../elementum.js';
|
|
9
|
+
import { html, css } from '../template.js';
|
|
10
|
+
import { signal } from '../signal.js';
|
|
11
|
+
|
|
12
|
+
export class ElAspectRatio extends Elementum {
|
|
13
|
+
static observedAttributes = ['ratio'];
|
|
14
|
+
|
|
15
|
+
ratio = signal('16/9');
|
|
16
|
+
|
|
17
|
+
static styles = css`
|
|
18
|
+
:host {
|
|
19
|
+
display: block;
|
|
20
|
+
width: 100%;
|
|
21
|
+
position: relative;
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.container {
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: 100%;
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
position: relative;
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
::slotted(img),
|
|
37
|
+
::slotted(video),
|
|
38
|
+
::slotted(iframe),
|
|
39
|
+
::slotted(canvas) {
|
|
40
|
+
width: 100% !important;
|
|
41
|
+
height: 100% !important;
|
|
42
|
+
object-fit: cover !important;
|
|
43
|
+
display: block !important;
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
connected() {
|
|
48
|
+
this.#syncRatio();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
attributeChanged(name, oldValue, newValue) {
|
|
52
|
+
if (name === 'ratio') this.#syncRatio();
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#syncRatio() {
|
|
57
|
+
const raw = this.getAttribute('ratio') || '16/9';
|
|
58
|
+
this.ratio.value = raw;
|
|
59
|
+
this.style.aspectRatio = raw.replace(':', '/');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
render() {
|
|
63
|
+
return html`
|
|
64
|
+
<div class="container" part="container">
|
|
65
|
+
<slot></slot>
|
|
66
|
+
</div>
|
|
67
|
+
`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (typeof customElements !== 'undefined' && !customElements.get('el-aspect-ratio')) {
|
|
72
|
+
customElements.define('el-aspect-ratio', ElAspectRatio);
|
|
73
|
+
}
|