@wcomp/elementum 0.0.0-stage → 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.
Files changed (102) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +282 -2
  3. package/custom-elements.json +3613 -0
  4. package/mcp/server.js +593 -0
  5. package/package.json +77 -4
  6. package/skills/elementum-break-ui/CATALOG.md +11 -0
  7. package/skills/elementum-break-ui/SKILL.md +16 -0
  8. package/skills/elementum-mobile/SKILL.md +18 -0
  9. package/skills/elementum-motion/SKILL.md +18 -0
  10. package/skills/elementum-motion/STANDARDS.md +15 -0
  11. package/skills/elementum-penpot/SKILL.md +45 -0
  12. package/skills/elementum-ui/CATALOG.md +14 -0
  13. package/skills/elementum-ui/SKILL.md +21 -0
  14. package/src/ag-ui.js +474 -0
  15. package/src/behaviors/index.js +760 -0
  16. package/src/components/el-accordion.js +201 -0
  17. package/src/components/el-alert-dialog.js +186 -0
  18. package/src/components/el-alert.js +254 -0
  19. package/src/components/el-aspect-ratio.js +73 -0
  20. package/src/components/el-autocomplete.js +775 -0
  21. package/src/components/el-avatar.js +271 -0
  22. package/src/components/el-badge.js +131 -0
  23. package/src/components/el-border-beam.js +135 -0
  24. package/src/components/el-breadcrumb.js +203 -0
  25. package/src/components/el-button.js +231 -0
  26. package/src/components/el-calendar.js +436 -0
  27. package/src/components/el-callout.js +158 -0
  28. package/src/components/el-card.js +298 -0
  29. package/src/components/el-carousel.js +308 -0
  30. package/src/components/el-chart.js +632 -0
  31. package/src/components/el-checkbox-card.js +221 -0
  32. package/src/components/el-checkbox.js +208 -0
  33. package/src/components/el-chip.js +276 -0
  34. package/src/components/el-code-block.js +230 -0
  35. package/src/components/el-collapsible.js +124 -0
  36. package/src/components/el-command.js +556 -0
  37. package/src/components/el-context-menu.js +328 -0
  38. package/src/components/el-data-list.js +210 -0
  39. package/src/components/el-datepicker.js +192 -0
  40. package/src/components/el-dialog.js +272 -0
  41. package/src/components/el-diff-viewer.js +441 -0
  42. package/src/components/el-drawer.js +782 -0
  43. package/src/components/el-dropdown.js +182 -0
  44. package/src/components/el-dropzone.js +242 -0
  45. package/src/components/el-empty-state.js +130 -0
  46. package/src/components/el-field.js +394 -0
  47. package/src/components/el-form.js +185 -0
  48. package/src/components/el-input.js +229 -0
  49. package/src/components/el-inset.js +90 -0
  50. package/src/components/el-insight-card.js +263 -0
  51. package/src/components/el-kbd.js +151 -0
  52. package/src/components/el-menubar.js +254 -0
  53. package/src/components/el-meter.js +183 -0
  54. package/src/components/el-navbar.js +294 -0
  55. package/src/components/el-navigation-menu.js +327 -0
  56. package/src/components/el-number-field.js +510 -0
  57. package/src/components/el-number-flow.js +164 -0
  58. package/src/components/el-otp-input.js +266 -0
  59. package/src/components/el-pagination.js +231 -0
  60. package/src/components/el-popover.js +288 -0
  61. package/src/components/el-preview-card.js +202 -0
  62. package/src/components/el-progress.js +179 -0
  63. package/src/components/el-prompt-input.js +383 -0
  64. package/src/components/el-radio-card.js +360 -0
  65. package/src/components/el-radio.js +257 -0
  66. package/src/components/el-rating.js +165 -0
  67. package/src/components/el-reasoning-card.js +293 -0
  68. package/src/components/el-resizable.js +324 -0
  69. package/src/components/el-router.js +305 -0
  70. package/src/components/el-scroll-area.js +150 -0
  71. package/src/components/el-segmented-control.js +282 -0
  72. package/src/components/el-select.js +220 -0
  73. package/src/components/el-separator.js +85 -0
  74. package/src/components/el-sidebar.js +386 -0
  75. package/src/components/el-skeleton.js +156 -0
  76. package/src/components/el-slider.js +351 -0
  77. package/src/components/el-sources.js +288 -0
  78. package/src/components/el-spinner.js +159 -0
  79. package/src/components/el-streaming-text.js +199 -0
  80. package/src/components/el-switch.js +221 -0
  81. package/src/components/el-table.js +397 -0
  82. package/src/components/el-tabs.js +235 -0
  83. package/src/components/el-task-list.js +230 -0
  84. package/src/components/el-textarea.js +175 -0
  85. package/src/components/el-theme-switch.js +120 -0
  86. package/src/components/el-timeline.js +254 -0
  87. package/src/components/el-toast.js +778 -0
  88. package/src/components/el-toggle.js +311 -0
  89. package/src/components/el-tool-call.js +386 -0
  90. package/src/components/el-toolbar.js +183 -0
  91. package/src/components/el-tooltip.js +172 -0
  92. package/src/components/el-tree-view.js +261 -0
  93. package/src/components/el-visually-hidden.js +32 -0
  94. package/src/elementum.js +504 -0
  95. package/src/index.d.ts +1093 -0
  96. package/src/index.js +112 -0
  97. package/src/signal.js +215 -0
  98. package/src/ssr.js +136 -0
  99. package/src/template.js +321 -0
  100. package/src/tokens.css +416 -0
  101. package/tokens/figma-tokens.json +69 -0
  102. package/tokens/penpot-tokens.json +98 -0
@@ -0,0 +1,201 @@
1
+ /**
2
+ * <el-accordion> and <el-accordion-item>
3
+ * Accessible disclosure/accordion components following W3C patterns.
4
+ */
5
+
6
+ import { Elementum } from '../elementum.js';
7
+ import { html, css } from '../template.js';
8
+ import { signal } from '../signal.js';
9
+
10
+ let nextItemId = 0;
11
+
12
+ export class ElAccordionItem extends Elementum {
13
+ static observedAttributes = ['title', 'heading', 'value', 'open', 'disabled'];
14
+
15
+ itemTitle = signal('');
16
+ value = signal('');
17
+ isOpen = signal(false);
18
+ disabled = signal(false);
19
+
20
+ #id = `el-acc-item-${++nextItemId}`;
21
+
22
+ static styles = css`
23
+ :host {
24
+ display: block;
25
+ border-bottom: 1px solid var(--el-surface-border, #e5e7eb);
26
+ }
27
+
28
+ :host(:last-of-type) {
29
+ border-bottom: none;
30
+ }
31
+
32
+ .header-btn {
33
+ width: 100%;
34
+ display: flex;
35
+ align-items: center;
36
+ justify-content: space-between;
37
+ padding: var(--el-spacing-md, 16px) 0;
38
+ background: none;
39
+ border: none;
40
+ font-family: inherit;
41
+ font-size: 1rem;
42
+ font-weight: 600;
43
+ color: var(--el-text-base, #111827);
44
+ text-align: left;
45
+ cursor: pointer;
46
+ outline: none;
47
+ transition: color 0.15s ease;
48
+ }
49
+
50
+ .header-btn:hover:not(:disabled) {
51
+ color: var(--el-color-primary, #2563eb);
52
+ }
53
+
54
+ .header-btn:focus-visible {
55
+ outline: 2px solid var(--el-color-primary, #2563eb);
56
+ outline-offset: 2px;
57
+ border-radius: var(--el-radius-sm, 4px);
58
+ }
59
+
60
+ .header-btn:disabled {
61
+ cursor: not-allowed;
62
+ opacity: 0.5;
63
+ }
64
+
65
+ .chevron {
66
+ font-size: 0.75rem;
67
+ transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
68
+ color: var(--el-text-muted, #6b7280);
69
+ }
70
+
71
+ .chevron.open {
72
+ transform: rotate(180deg);
73
+ }
74
+
75
+ .panel {
76
+ display: none;
77
+ padding-bottom: var(--el-spacing-md, 16px);
78
+ color: var(--el-text-base, #374151);
79
+ font-size: 0.9375rem;
80
+ line-height: 1.6;
81
+ }
82
+
83
+ .panel.open {
84
+ display: block;
85
+ }
86
+ `;
87
+
88
+ connected() {
89
+ this.itemTitle.value = this.getAttribute('title') || this.getAttribute('heading') || '';
90
+ this.value.value = this.getAttribute('value') || this.#id;
91
+ this.isOpen.value = this.hasAttribute('open');
92
+ this.disabled.value = this.hasAttribute('disabled');
93
+ }
94
+
95
+ attributeChanged(name, oldValue, newValue) {
96
+ if (name === 'open') {
97
+ this.isOpen.value = newValue !== null && newValue !== 'false';
98
+ } else if (name === 'title' || name === 'heading') {
99
+ this.itemTitle.value = newValue || '';
100
+ } else if (name === 'disabled') {
101
+ this.disabled.value = newValue !== null && newValue !== 'false';
102
+ }
103
+ }
104
+
105
+ toggle() {
106
+ if (this.disabled.value) return;
107
+ this.isOpen.value = !this.isOpen.value;
108
+ if (this.isOpen.value) {
109
+ this.setAttribute('open', '');
110
+ } else {
111
+ this.removeAttribute('open');
112
+ }
113
+ this.emit('toggle', { value: this.value.value, open: this.isOpen.value });
114
+ }
115
+
116
+ render() {
117
+ const buttonId = `${this.#id}-btn`;
118
+ const panelId = `${this.#id}-panel`;
119
+
120
+ return html`
121
+ <button
122
+ type="button"
123
+ id=${buttonId}
124
+ class="header-btn"
125
+ part="header"
126
+ ?disabled=${this.disabled}
127
+ aria-expanded=${() => (this.isOpen.value ? 'true' : 'false')}
128
+ aria-controls=${panelId}
129
+ @click=${() => this.toggle()}
130
+ >
131
+ <span part="title"><slot name="title">${this.itemTitle}</slot></span>
132
+ <span class=${() => `chevron ${this.isOpen.value ? 'open' : ''}`} part="chevron">▼</span>
133
+ </button>
134
+ <div
135
+ id=${panelId}
136
+ role="region"
137
+ aria-labelledby=${buttonId}
138
+ class=${() => `panel ${this.isOpen.value ? 'open' : ''}`}
139
+ part="panel"
140
+ >
141
+ <slot></slot>
142
+ </div>
143
+ `;
144
+ }
145
+ }
146
+
147
+ if (typeof customElements !== 'undefined' && !customElements.get('el-accordion-item')) {
148
+ customElements.define('el-accordion-item', ElAccordionItem);
149
+ }
150
+
151
+ export class ElAccordion extends Elementum {
152
+ static observedAttributes = ['multiple'];
153
+
154
+ multiple = signal(false);
155
+
156
+ static styles = css`
157
+ :host {
158
+ display: block;
159
+ border: 1px solid var(--el-surface-border, #e5e7eb);
160
+ border-radius: var(--el-radius-md, 8px);
161
+ padding: 0 var(--el-spacing-md, 16px);
162
+ background: var(--el-surface-base, #ffffff);
163
+ }
164
+ `;
165
+
166
+ connected() {
167
+ this.multiple.value = this.hasAttribute('multiple');
168
+ this.addEventListener('toggle', this.#onItemToggle);
169
+ }
170
+
171
+ attributeChanged(name, oldValue, newValue) {
172
+ if (name === 'multiple') {
173
+ this.multiple.value = newValue !== null && newValue !== 'false';
174
+ }
175
+ }
176
+
177
+ #onItemToggle = (e) => {
178
+ // If not multiple and this item opened, close all other items
179
+ if (!this.multiple.value && e.detail.open) {
180
+ const items = this.querySelectorAll('el-accordion-item');
181
+ for (const item of items) {
182
+ if (item !== e.target && item.isOpen.value) {
183
+ item.isOpen.value = false;
184
+ item.removeAttribute('open');
185
+ }
186
+ }
187
+ }
188
+ this.emit('change', {
189
+ value: e.detail.value,
190
+ open: e.detail.open,
191
+ });
192
+ };
193
+
194
+ render() {
195
+ return html`<slot></slot>`;
196
+ }
197
+ }
198
+
199
+ if (typeof customElements !== 'undefined' && !customElements.get('el-accordion')) {
200
+ customElements.define('el-accordion', ElAccordion);
201
+ }
@@ -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
+ }