@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,298 @@
1
+ /**
2
+ * <el-card> family
3
+ * Accessible structured card container inspired by shadcn/ui.
4
+ * Includes <el-card-header>, <el-card-title>, <el-card-description>,
5
+ * <el-card-content>, and <el-card-footer>.
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 ElCardTitle extends Elementum {
13
+ static observedAttributes = ['size', 'align'];
14
+
15
+ size = signal('md');
16
+ align = signal('left');
17
+
18
+ static styles = css`
19
+ :host {
20
+ display: block;
21
+ font-size: 1.25rem;
22
+ font-weight: 700;
23
+ letter-spacing: -0.025em;
24
+ line-height: 1.3;
25
+ color: var(--el-text-primary, #0f172a);
26
+ margin: 0;
27
+ }
28
+ :host([size="sm"]) { font-size: 1rem; }
29
+ :host([size="lg"]) { font-size: 1.5rem; }
30
+ :host([align="center"]) { text-align: center; }
31
+ :host([align="right"]) { text-align: right; }
32
+ :root[data-theme="dark"] :host {
33
+ color: #f8fafc;
34
+ }
35
+ `;
36
+ render() {
37
+ return html`<slot></slot>`;
38
+ }
39
+ }
40
+
41
+ export class ElCardDescription extends Elementum {
42
+ static observedAttributes = ['align', 'truncate'];
43
+
44
+ align = signal('left');
45
+ truncate = signal(false);
46
+
47
+ static styles = css`
48
+ :host {
49
+ display: block;
50
+ font-size: 0.875rem;
51
+ line-height: 1.4;
52
+ color: var(--el-text-muted, #64748b);
53
+ margin-top: 4px;
54
+ }
55
+ :host([align="center"]) { text-align: center; }
56
+ :host([align="right"]) { text-align: right; }
57
+ :host([truncate]) {
58
+ white-space: nowrap;
59
+ overflow: hidden;
60
+ text-overflow: ellipsis;
61
+ }
62
+ :root[data-theme="dark"] :host {
63
+ color: #94a3b8;
64
+ }
65
+ `;
66
+ render() {
67
+ return html`<slot></slot>`;
68
+ }
69
+ }
70
+
71
+ export class ElCardHeader extends Elementum {
72
+ static observedAttributes = ['bordered', 'compact', 'align'];
73
+
74
+ bordered = signal(false);
75
+ compact = signal(false);
76
+ align = signal('left');
77
+
78
+ static styles = css`
79
+ :host {
80
+ display: flex;
81
+ flex-direction: column;
82
+ gap: 4px;
83
+ padding: 24px 24px 16px 24px;
84
+ box-sizing: border-box;
85
+ }
86
+ :host([compact]) {
87
+ padding: 14px 16px 10px 16px;
88
+ }
89
+ :host([bordered]) {
90
+ border-bottom: 1px solid var(--el-surface-border, #e2e8f0);
91
+ margin-bottom: 16px;
92
+ }
93
+ :host([align="center"]) {
94
+ align-items: center;
95
+ text-align: center;
96
+ }
97
+ :host([align="right"]) {
98
+ align-items: flex-end;
99
+ text-align: right;
100
+ }
101
+ :root[data-theme="dark"] :host([bordered]) {
102
+ border-bottom-color: #334155;
103
+ }
104
+ `;
105
+ render() {
106
+ return html`<slot></slot>`;
107
+ }
108
+ }
109
+
110
+ export class ElCardContent extends Elementum {
111
+ static observedAttributes = ['compact', 'flush'];
112
+
113
+ compact = signal(false);
114
+ flush = signal(false);
115
+
116
+ static styles = css`
117
+ :host {
118
+ display: block;
119
+ padding: 0 24px 24px 24px;
120
+ box-sizing: border-box;
121
+ flex: 1;
122
+ }
123
+ :host([compact]) {
124
+ padding: 0 16px 16px 16px;
125
+ }
126
+ :host([flush]) {
127
+ padding: 0;
128
+ }
129
+ `;
130
+ render() {
131
+ return html`<slot></slot>`;
132
+ }
133
+ }
134
+
135
+ export class ElCardFooter extends Elementum {
136
+ static observedAttributes = ['align', 'bordered'];
137
+
138
+ align = signal('end');
139
+ bordered = signal(false);
140
+
141
+ static styles = css`
142
+ :host {
143
+ display: flex;
144
+ align-items: center;
145
+ justify-content: flex-end;
146
+ padding: 0 24px 24px 24px;
147
+ box-sizing: border-box;
148
+ gap: 12px;
149
+ }
150
+ :host([align="start"]) { justify-content: flex-start; }
151
+ :host([align="center"]) { justify-content: center; }
152
+ :host([align="end"]) { justify-content: flex-end; }
153
+ :host([align="between"]) { justify-content: space-between; }
154
+ :host([bordered]) {
155
+ border-top: 1px solid var(--el-surface-border, #e2e8f0);
156
+ padding-top: 16px;
157
+ }
158
+ :root[data-theme="dark"] :host([bordered]) {
159
+ border-top-color: #334155;
160
+ }
161
+ `;
162
+ render() {
163
+ return html`<slot></slot>`;
164
+ }
165
+ }
166
+
167
+ export class ElCard extends Elementum {
168
+ static observedAttributes = ['title', 'bordered', 'glass', 'hoverable'];
169
+
170
+ title = signal('');
171
+ bordered = signal(true);
172
+ glass = signal(false);
173
+ hoverable = signal(false);
174
+
175
+ static styles = css`
176
+ :host {
177
+ display: flex;
178
+ flex-direction: column;
179
+ background: var(--el-surface-base, #ffffff);
180
+ border: 1px solid var(--el-surface-border, #e2e8f0);
181
+ border-radius: var(--el-radius-lg, 12px);
182
+ box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
183
+ color: var(--el-text-primary, #0f172a);
184
+ font-family: var(--el-font-sans, system-ui, sans-serif);
185
+ box-sizing: border-box;
186
+ overflow: hidden;
187
+ transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
188
+ }
189
+
190
+ :root[data-theme="dark"] :host {
191
+ background: #1e293b;
192
+ border-color: #334155;
193
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
194
+ }
195
+
196
+ :host([bordered="false"]) {
197
+ border-color: transparent !important;
198
+ box-shadow: none;
199
+ }
200
+
201
+ :host([glass]) {
202
+ background: rgba(255, 255, 255, 0.68);
203
+ backdrop-filter: blur(12px);
204
+ -webkit-backdrop-filter: blur(12px);
205
+ border-color: rgba(148, 163, 184, 0.35);
206
+ box-shadow: 0 8px 32px rgba(15, 23, 42, 0.08);
207
+ }
208
+
209
+ :root[data-theme="dark"] :host([glass]) {
210
+ background: rgba(30, 41, 59, 0.68);
211
+ border-color: rgba(148, 163, 184, 0.25);
212
+ }
213
+
214
+ :host([hoverable]) {
215
+ cursor: pointer;
216
+ }
217
+
218
+ :host([hoverable]:hover) {
219
+ transform: translateY(-2px);
220
+ box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
221
+ border-color: var(--el-color-primary, #2563eb);
222
+ }
223
+
224
+ .card-auto-header {
225
+ padding: 18px 24px 0 24px;
226
+ font-size: 1.125rem;
227
+ font-weight: 700;
228
+ letter-spacing: -0.02em;
229
+ color: var(--el-text-primary, #0f172a);
230
+ }
231
+
232
+ :root[data-theme="dark"] .card-auto-header {
233
+ color: #f8fafc;
234
+ }
235
+
236
+ .card-body {
237
+ display: flex;
238
+ flex-direction: column;
239
+ flex: 1;
240
+ box-sizing: border-box;
241
+ }
242
+
243
+ :host(:not([data-compound])) .card-body {
244
+ padding: 16px 24px 20px 24px;
245
+ }
246
+ `;
247
+
248
+ connected() {
249
+ this.title.value = this.getAttribute('title') || '';
250
+ this.bordered.value = this.getAttribute('bordered') !== 'false';
251
+ this.glass.value = this.hasAttribute('glass') && this.getAttribute('glass') !== 'false';
252
+ this.hoverable.value = this.hasAttribute('hoverable') && this.getAttribute('hoverable') !== 'false';
253
+ this.#checkCompound();
254
+ }
255
+
256
+ rendered() {
257
+ this.#checkCompound();
258
+ }
259
+
260
+ attributeChanged(name, oldValue, newValue) {
261
+ if (name === 'title') this.title.value = newValue || '';
262
+ else if (name === 'bordered') this.bordered.value = newValue !== 'false';
263
+ else if (name === 'glass') this.glass.value = newValue !== null && newValue !== 'false';
264
+ else if (name === 'hoverable') this.hoverable.value = newValue !== null && newValue !== 'false';
265
+ }
266
+
267
+ #checkCompound() {
268
+ const hasCompound = Boolean(
269
+ this.querySelector('el-card-header, el-card-content, el-card-footer')
270
+ );
271
+ if (hasCompound) {
272
+ this.setAttribute('data-compound', '');
273
+ } else {
274
+ this.removeAttribute('data-compound');
275
+ }
276
+ }
277
+
278
+ render() {
279
+ return html`
280
+ ${() =>
281
+ this.title.value
282
+ ? html`<div class="card-auto-header" part="header">${this.title.value}</div>`
283
+ : null}
284
+ <div class="card-body" part="body">
285
+ <slot></slot>
286
+ </div>
287
+ `;
288
+ }
289
+ }
290
+
291
+ if (typeof customElements !== 'undefined') {
292
+ if (!customElements.get('el-card-title')) customElements.define('el-card-title', ElCardTitle);
293
+ if (!customElements.get('el-card-description')) customElements.define('el-card-description', ElCardDescription);
294
+ if (!customElements.get('el-card-header')) customElements.define('el-card-header', ElCardHeader);
295
+ if (!customElements.get('el-card-content')) customElements.define('el-card-content', ElCardContent);
296
+ if (!customElements.get('el-card-footer')) customElements.define('el-card-footer', ElCardFooter);
297
+ if (!customElements.get('el-card')) customElements.define('el-card', ElCard);
298
+ }
@@ -0,0 +1,308 @@
1
+ /**
2
+ * <el-carousel> & <el-carousel-slide>
3
+ * Accessible swipeable/clickable carousel inspired by shadcn/ui.
4
+ * Supports auto-play, loop, swipe gestures, keyboard arrow navigation,
5
+ * dots indicators, and previous/next buttons.
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 ElCarouselSlide extends Elementum {
13
+ static styles = css`
14
+ :host {
15
+ flex: 0 0 100%;
16
+ width: 100%;
17
+ min-width: 100%;
18
+ height: 100%;
19
+ box-sizing: border-box;
20
+ display: flex;
21
+ flex-direction: column;
22
+ align-items: stretch;
23
+ justify-content: center;
24
+ position: relative;
25
+ }
26
+
27
+ ::slotted(*) {
28
+ width: 100%;
29
+ box-sizing: border-box;
30
+ }
31
+ `;
32
+
33
+ render() {
34
+ return html`<slot></slot>`;
35
+ }
36
+ }
37
+
38
+ export class ElCarousel extends Elementum {
39
+ static observedAttributes = ['auto-play', 'autoplay', 'interval', 'loop'];
40
+
41
+ currentIndex = signal(0);
42
+ totalSlides = signal(0);
43
+ autoPlay = signal(false);
44
+ interval = signal(4000);
45
+ loop = signal(true);
46
+
47
+ #autoPlayTimer = null;
48
+ #startX = 0;
49
+ #isSwiping = false;
50
+
51
+ static styles = css`
52
+ :host {
53
+ display: flex;
54
+ flex-direction: column;
55
+ position: relative;
56
+ width: 100%;
57
+ height: 100%;
58
+ min-height: 160px;
59
+ overflow: hidden;
60
+ font-family: var(--el-font-sans, system-ui, sans-serif);
61
+ box-sizing: border-box;
62
+ border-radius: var(--el-radius-md, 8px);
63
+ }
64
+
65
+ .viewport {
66
+ overflow: hidden;
67
+ flex: 1;
68
+ width: 100%;
69
+ height: 100%;
70
+ min-height: 160px;
71
+ position: relative;
72
+ display: flex;
73
+ touch-action: pan-y pinch-zoom;
74
+ }
75
+
76
+ .track {
77
+ display: flex;
78
+ flex: 1;
79
+ width: 100%;
80
+ height: 100%;
81
+ transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
82
+ box-sizing: border-box;
83
+ }
84
+
85
+ ::slotted(el-carousel-slide) {
86
+ flex: 0 0 100%;
87
+ width: 100%;
88
+ height: 100%;
89
+ min-height: 100%;
90
+ box-sizing: border-box;
91
+ }
92
+
93
+ /* Controls */
94
+ .controls {
95
+ display: flex;
96
+ align-items: center;
97
+ justify-content: space-between;
98
+ position: absolute;
99
+ top: 50%;
100
+ left: 10px;
101
+ right: 10px;
102
+ transform: translateY(-50%);
103
+ pointer-events: none;
104
+ z-index: 10;
105
+ }
106
+
107
+ .nav-btn {
108
+ pointer-events: auto;
109
+ width: 34px;
110
+ height: 34px;
111
+ border-radius: 999px;
112
+ border: 1px solid var(--el-surface-border, rgba(255, 255, 255, 0.2));
113
+ background: var(--el-surface-elevated, #ffffff);
114
+ color: var(--el-text-primary, #0f172a);
115
+ display: inline-flex;
116
+ align-items: center;
117
+ justify-content: center;
118
+ cursor: pointer;
119
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
120
+ transition: background-color 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
121
+ backdrop-filter: blur(8px);
122
+ }
123
+
124
+ .nav-btn:hover {
125
+ background: var(--el-surface-muted, #f1f5f9);
126
+ transform: scale(1.08);
127
+ }
128
+
129
+ /* Indicators (Dots) */
130
+ .dots {
131
+ display: flex;
132
+ align-items: center;
133
+ justify-content: center;
134
+ gap: 6px;
135
+ position: absolute;
136
+ bottom: 12px;
137
+ left: 0;
138
+ right: 0;
139
+ z-index: 10;
140
+ }
141
+
142
+ .dot {
143
+ width: 8px;
144
+ height: 8px;
145
+ border-radius: 999px;
146
+ background: rgba(255, 255, 255, 0.45);
147
+ border: 1px solid rgba(0, 0, 0, 0.15);
148
+ padding: 0;
149
+ cursor: pointer;
150
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
151
+ transition: width 0.2s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s ease;
152
+ }
153
+
154
+ .dot.active {
155
+ width: 22px;
156
+ background: var(--el-color-primary, #3b82f6);
157
+ border-color: transparent;
158
+ }
159
+ `;
160
+
161
+ connected() {
162
+ this.#syncAttrs();
163
+
164
+ this.#updateSlidesCount();
165
+
166
+ const observer = new MutationObserver(() => this.#updateSlidesCount());
167
+ observer.observe(this, { childList: true });
168
+ this._observer = observer;
169
+
170
+ this.addEventListener('keydown', this.#onKeyDown);
171
+ this.addEventListener('pointerdown', this.#onPointerDown);
172
+ }
173
+
174
+ attributeChanged(name, oldValue, newValue) {
175
+ this.#syncAttrs();
176
+ }
177
+
178
+ #syncAttrs() {
179
+ const autoAttr = this.getAttribute('auto-play') ?? this.getAttribute('autoplay');
180
+ this.autoPlay.value = (this.hasAttribute('auto-play') || this.hasAttribute('autoplay')) && autoAttr !== 'false';
181
+ this.interval.value = parseInt(this.getAttribute('interval') || '4000', 10) || 4000;
182
+ this.loop.value = this.getAttribute('loop') !== 'false';
183
+
184
+ if (this.autoPlay.value) {
185
+ this.#startAutoPlay();
186
+ } else {
187
+ this.#stopAutoPlay();
188
+ }
189
+ }
190
+
191
+ disconnected() {
192
+ this._observer?.disconnect();
193
+ this.removeEventListener('keydown', this.#onKeyDown);
194
+ this.removeEventListener('pointerdown', this.#onPointerDown);
195
+ this.#stopAutoPlay();
196
+ }
197
+
198
+ #updateSlidesCount() {
199
+ const slides = Array.from(this.querySelectorAll('el-carousel-slide'));
200
+ this.totalSlides.value = slides.length;
201
+ }
202
+
203
+ #startAutoPlay() {
204
+ this.#stopAutoPlay();
205
+ this.#autoPlayTimer = setInterval(() => {
206
+ this.next();
207
+ }, this.interval.value);
208
+ }
209
+
210
+ #stopAutoPlay() {
211
+ if (this.#autoPlayTimer) {
212
+ clearInterval(this.#autoPlayTimer);
213
+ this.#autoPlayTimer = null;
214
+ }
215
+ }
216
+
217
+ next = () => {
218
+ const total = this.totalSlides.value;
219
+ if (total === 0) return;
220
+ if (this.currentIndex.value < total - 1) {
221
+ this.goTo(this.currentIndex.value + 1);
222
+ } else if (this.loop.value) {
223
+ this.goTo(0);
224
+ }
225
+ };
226
+
227
+ prev = () => {
228
+ const total = this.totalSlides.value;
229
+ if (total === 0) return;
230
+ if (this.currentIndex.value > 0) {
231
+ this.goTo(this.currentIndex.value - 1);
232
+ } else if (this.loop.value) {
233
+ this.goTo(total - 1);
234
+ }
235
+ };
236
+
237
+ goTo(index) {
238
+ this.currentIndex.value = index;
239
+ const track = this.shadowRoot?.querySelector('.track');
240
+ if (track) {
241
+ track.style.transform = `translateX(-${index * 100}%)`;
242
+ }
243
+ this.emit('slide-change', { index });
244
+ }
245
+
246
+ #onKeyDown = (e) => {
247
+ if (e.key === 'ArrowLeft') {
248
+ e.preventDefault();
249
+ this.prev();
250
+ } else if (e.key === 'ArrowRight') {
251
+ e.preventDefault();
252
+ this.next();
253
+ }
254
+ };
255
+
256
+ #onPointerDown = (e) => {
257
+ this.#startX = e.clientX;
258
+ this.#isSwiping = true;
259
+ window.addEventListener('pointerup', this.#onPointerUp, { once: true });
260
+ };
261
+
262
+ #onPointerUp = (e) => {
263
+ if (!this.#isSwiping) return;
264
+ this.#isSwiping = false;
265
+ const deltaX = e.clientX - this.#startX;
266
+ if (deltaX > 40) this.prev();
267
+ else if (deltaX < -40) this.next();
268
+ };
269
+
270
+ render() {
271
+ return html`
272
+ <div class="viewport" part="viewport" tabindex="0" aria-roledescription="carousel">
273
+ <div class="track" part="track">
274
+ <slot></slot>
275
+ </div>
276
+
277
+ <div class="controls" part="controls">
278
+ <button type="button" class="nav-btn prev" aria-label="Previous slide" onclick=${this.prev}>
279
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="m15 18-6-6 6-6"/></svg>
280
+ </button>
281
+ <button type="button" class="nav-btn next" aria-label="Next slide" onclick=${this.next}>
282
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="m9 18 6-6-6-6"/></svg>
283
+ </button>
284
+ </div>
285
+
286
+ <div class="dots" part="dots">
287
+ ${() => {
288
+ const count = this.totalSlides.value;
289
+ const current = this.currentIndex.value;
290
+ return Array.from({ length: count }).map((_, i) =>
291
+ html`<button
292
+ type="button"
293
+ class=${() => `dot ${i === current ? 'active' : ''}`}
294
+ aria-label=${() => `Go to slide ${i + 1}`}
295
+ onclick=${() => this.goTo(i)}
296
+ ></button>`
297
+ );
298
+ }}
299
+ </div>
300
+ </div>
301
+ `;
302
+ }
303
+ }
304
+
305
+ if (typeof customElements !== 'undefined') {
306
+ if (!customElements.get('el-carousel-slide')) customElements.define('el-carousel-slide', ElCarouselSlide);
307
+ if (!customElements.get('el-carousel')) customElements.define('el-carousel', ElCarousel);
308
+ }