@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.
Files changed (101) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +266 -2
  3. package/custom-elements.json +3613 -0
  4. package/mcp/server.js +408 -0
  5. package/package.json +72 -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/components/el-accordion.js +201 -0
  16. package/src/components/el-alert-dialog.js +186 -0
  17. package/src/components/el-alert.js +254 -0
  18. package/src/components/el-aspect-ratio.js +73 -0
  19. package/src/components/el-autocomplete.js +775 -0
  20. package/src/components/el-avatar.js +271 -0
  21. package/src/components/el-badge.js +131 -0
  22. package/src/components/el-border-beam.js +135 -0
  23. package/src/components/el-breadcrumb.js +203 -0
  24. package/src/components/el-button.js +220 -0
  25. package/src/components/el-calendar.js +413 -0
  26. package/src/components/el-callout.js +158 -0
  27. package/src/components/el-card.js +298 -0
  28. package/src/components/el-carousel.js +308 -0
  29. package/src/components/el-chart.js +632 -0
  30. package/src/components/el-checkbox-card.js +221 -0
  31. package/src/components/el-checkbox.js +208 -0
  32. package/src/components/el-chip.js +276 -0
  33. package/src/components/el-code-block.js +228 -0
  34. package/src/components/el-collapsible.js +124 -0
  35. package/src/components/el-command.js +556 -0
  36. package/src/components/el-context-menu.js +328 -0
  37. package/src/components/el-data-list.js +210 -0
  38. package/src/components/el-datepicker.js +192 -0
  39. package/src/components/el-dialog.js +272 -0
  40. package/src/components/el-diff-viewer.js +441 -0
  41. package/src/components/el-drawer.js +782 -0
  42. package/src/components/el-dropdown.js +182 -0
  43. package/src/components/el-dropzone.js +242 -0
  44. package/src/components/el-empty-state.js +130 -0
  45. package/src/components/el-field.js +394 -0
  46. package/src/components/el-form.js +185 -0
  47. package/src/components/el-input.js +212 -0
  48. package/src/components/el-inset.js +90 -0
  49. package/src/components/el-insight-card.js +263 -0
  50. package/src/components/el-kbd.js +151 -0
  51. package/src/components/el-menubar.js +254 -0
  52. package/src/components/el-meter.js +182 -0
  53. package/src/components/el-navbar.js +294 -0
  54. package/src/components/el-navigation-menu.js +327 -0
  55. package/src/components/el-number-field.js +510 -0
  56. package/src/components/el-number-flow.js +153 -0
  57. package/src/components/el-otp-input.js +266 -0
  58. package/src/components/el-pagination.js +229 -0
  59. package/src/components/el-popover.js +288 -0
  60. package/src/components/el-preview-card.js +202 -0
  61. package/src/components/el-progress.js +179 -0
  62. package/src/components/el-prompt-input.js +383 -0
  63. package/src/components/el-radio-card.js +360 -0
  64. package/src/components/el-radio.js +257 -0
  65. package/src/components/el-rating.js +165 -0
  66. package/src/components/el-reasoning-card.js +293 -0
  67. package/src/components/el-resizable.js +324 -0
  68. package/src/components/el-router.js +305 -0
  69. package/src/components/el-scroll-area.js +150 -0
  70. package/src/components/el-segmented-control.js +282 -0
  71. package/src/components/el-select.js +219 -0
  72. package/src/components/el-separator.js +85 -0
  73. package/src/components/el-sidebar.js +386 -0
  74. package/src/components/el-skeleton.js +156 -0
  75. package/src/components/el-slider.js +351 -0
  76. package/src/components/el-sources.js +288 -0
  77. package/src/components/el-spinner.js +159 -0
  78. package/src/components/el-streaming-text.js +199 -0
  79. package/src/components/el-switch.js +221 -0
  80. package/src/components/el-table.js +397 -0
  81. package/src/components/el-tabs.js +235 -0
  82. package/src/components/el-task-list.js +230 -0
  83. package/src/components/el-textarea.js +175 -0
  84. package/src/components/el-theme-switch.js +120 -0
  85. package/src/components/el-timeline.js +254 -0
  86. package/src/components/el-toast.js +778 -0
  87. package/src/components/el-toggle.js +311 -0
  88. package/src/components/el-tool-call.js +386 -0
  89. package/src/components/el-toolbar.js +183 -0
  90. package/src/components/el-tooltip.js +172 -0
  91. package/src/components/el-tree-view.js +261 -0
  92. package/src/components/el-visually-hidden.js +32 -0
  93. package/src/elementum.js +485 -0
  94. package/src/index.d.ts +1007 -0
  95. package/src/index.js +99 -0
  96. package/src/signal.js +194 -0
  97. package/src/ssr.js +136 -0
  98. package/src/template.js +321 -0
  99. package/src/tokens.css +416 -0
  100. package/tokens/figma-tokens.json +69 -0
  101. package/tokens/penpot-tokens.json +98 -0
@@ -0,0 +1,266 @@
1
+ import { Elementum } from '../elementum.js';
2
+ import { html, css } from '../template.js';
3
+ import { signal, effect } from '../signal.js';
4
+
5
+ /**
6
+ * <el-otp-input>
7
+ * Segmented PIN / verification code input component.
8
+ *
9
+ * @attr {number} length - Number of PIN slots (default: 6)
10
+ * @attr {string} name - Form field name
11
+ * @attr {string} value - Combined OTP value
12
+ * @attr {boolean} disabled - Whether the input is disabled
13
+ * @attr {boolean} required - Whether OTP is required
14
+ * @attr {string} type - 'text' | 'password' (mask characters)
15
+ *
16
+ * @fires change - Dispatched when value changes
17
+ * @fires complete - Dispatched when all digits are filled with { value }
18
+ */
19
+ export class ElOtpInput extends Elementum {
20
+ static formAssociated = true;
21
+
22
+ static observedAttributes = ['length', 'name', 'value', 'disabled', 'required', 'type'];
23
+
24
+ length = signal(6);
25
+ name = signal('');
26
+ value = signal('');
27
+ disabled = signal(false);
28
+ required = signal(false);
29
+ type = signal('text');
30
+ digits = signal([]);
31
+
32
+ connected() {
33
+ this.#sync();
34
+ this.setFormValue(this.value.value);
35
+ this.validate();
36
+
37
+ effect(() => {
38
+ this.setFormValue(this.value.value);
39
+ this.validate();
40
+ }, { signal: this.signal });
41
+ }
42
+
43
+ attributeChanged(name, oldValue, newValue) {
44
+ this.#sync();
45
+ }
46
+
47
+ #sync() {
48
+ const len = Number(this.getAttribute('length')) || 6;
49
+ this.length.value = len;
50
+ this.name.value = this.getAttribute('name') || '';
51
+ this.disabled.value = this.hasAttribute('disabled');
52
+ this.required.value = this.hasAttribute('required');
53
+ this.type.value = this.getAttribute('type') || 'text';
54
+
55
+ const val = this.getAttribute('value') || this.value.value || '';
56
+ const arr = new Array(len).fill('');
57
+ for (let i = 0; i < Math.min(val.length, len); i++) {
58
+ arr[i] = val[i];
59
+ }
60
+ this.digits.value = arr;
61
+ this.value.value = arr.join('');
62
+ }
63
+
64
+ static styles = css`
65
+ :host {
66
+ display: inline-block;
67
+ font-family: var(--el-font-sans, system-ui, sans-serif);
68
+ box-sizing: border-box;
69
+ }
70
+
71
+ .otp-container {
72
+ display: inline-flex;
73
+ align-items: center;
74
+ gap: 8px;
75
+ }
76
+
77
+ .otp-cell {
78
+ width: 44px;
79
+ height: 48px;
80
+ border: 1px solid var(--el-surface-border, #cbd5e1);
81
+ border-radius: var(--el-radius-md, 8px);
82
+ background: var(--el-surface-card, #ffffff);
83
+ color: var(--el-text-primary, #0f172a);
84
+ font-size: 1.25rem;
85
+ font-weight: 700;
86
+ text-align: center;
87
+ outline: none;
88
+ transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
89
+ box-sizing: border-box;
90
+ font-variant-numeric: tabular-nums;
91
+ padding: 0;
92
+ }
93
+
94
+ .otp-cell:focus {
95
+ border-color: var(--el-color-primary, #2563eb);
96
+ box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
97
+ transform: scale(1.04);
98
+ }
99
+
100
+ .otp-cell:disabled {
101
+ background: var(--el-surface-muted, #f1f5f9);
102
+ cursor: not-allowed;
103
+ opacity: 0.6;
104
+ }
105
+ `;
106
+
107
+ validate() {
108
+ const isRequired = Boolean(this.required.value);
109
+ const isFull = this.value.value.length === this.length.value;
110
+
111
+ if (isRequired && !isFull) {
112
+ this.setValidity(
113
+ { valueMissing: true },
114
+ `Please enter the full ${this.length.value}-digit verification code.`
115
+ );
116
+ this.setAttribute('aria-invalid', 'true');
117
+ return false;
118
+ }
119
+
120
+ this.setValidity({});
121
+ this.removeAttribute('aria-invalid');
122
+ return true;
123
+ }
124
+
125
+ focus() {
126
+ const firstEmpty = this.digits.value.findIndex((d) => !d);
127
+ const idx = firstEmpty >= 0 ? firstEmpty : 0;
128
+ const inputs = this.root.querySelectorAll('.otp-cell');
129
+ inputs[idx]?.focus();
130
+ }
131
+
132
+ clear() {
133
+ const len = this.length.value;
134
+ this.digits.value = new Array(len).fill('');
135
+ this.value.value = '';
136
+ const inputs = this.root.querySelectorAll('.otp-cell');
137
+ inputs.forEach((i) => (i.value = ''));
138
+ inputs[0]?.focus();
139
+ this.emit('change', { value: '' });
140
+ }
141
+
142
+ #onInput = (e, index) => {
143
+ const val = e.target.value.slice(-1); // Take only the last character
144
+ const arr = [...this.digits.value];
145
+ arr[index] = val;
146
+ this.digits.value = arr;
147
+ this.value.value = arr.join('');
148
+
149
+ const inputs = this.root.querySelectorAll('.otp-cell');
150
+ if (val && index < this.length.value - 1) {
151
+ inputs[index + 1]?.focus();
152
+ inputs[index + 1]?.select?.();
153
+ }
154
+
155
+ this.emit('change', { value: this.value.value });
156
+
157
+ if (this.value.value.length === this.length.value && !this.value.value.includes('')) {
158
+ this.emit('complete', { value: this.value.value });
159
+ }
160
+ };
161
+
162
+ #onKeyDown = (e, index) => {
163
+ const inputs = this.root.querySelectorAll('.otp-cell');
164
+
165
+ if (e.key === 'Backspace') {
166
+ if (!this.digits.value[index] && index > 0) {
167
+ inputs[index - 1]?.focus();
168
+ const arr = [...this.digits.value];
169
+ arr[index - 1] = '';
170
+ this.digits.value = arr;
171
+ this.value.value = arr.join('');
172
+ if (inputs[index - 1]) inputs[index - 1].value = '';
173
+ e.preventDefault();
174
+ } else {
175
+ const arr = [...this.digits.value];
176
+ arr[index] = '';
177
+ this.digits.value = arr;
178
+ this.value.value = arr.join('');
179
+ }
180
+ this.emit('change', { value: this.value.value });
181
+ } else if (e.key === 'ArrowLeft' && index > 0) {
182
+ inputs[index - 1]?.focus();
183
+ e.preventDefault();
184
+ } else if (e.key === 'ArrowRight' && index < this.length.value - 1) {
185
+ inputs[index + 1]?.focus();
186
+ e.preventDefault();
187
+ }
188
+ };
189
+
190
+ #onPaste = (e) => {
191
+ e.preventDefault();
192
+ const pasted = (e.clipboardData || window.clipboardData)?.getData('text') || '';
193
+ const cleaned = pasted.trim().slice(0, this.length.value);
194
+ if (!cleaned) return;
195
+
196
+ const arr = [...this.digits.value];
197
+ const inputs = this.root.querySelectorAll('.otp-cell');
198
+
199
+ for (let i = 0; i < cleaned.length; i++) {
200
+ arr[i] = cleaned[i];
201
+ if (inputs[i]) inputs[i].value = cleaned[i];
202
+ }
203
+
204
+ this.digits.value = arr;
205
+ this.value.value = arr.join('');
206
+
207
+ const nextIndex = Math.min(cleaned.length, this.length.value - 1);
208
+ inputs[nextIndex]?.focus();
209
+
210
+ this.emit('change', { value: this.value.value });
211
+ if (this.value.value.length === this.length.value) {
212
+ this.emit('complete', { value: this.value.value });
213
+ }
214
+ };
215
+
216
+ formReset() {
217
+ this.clear();
218
+ }
219
+
220
+ formResetCallback() {
221
+ this.clear();
222
+ }
223
+
224
+ render() {
225
+ const len = this.length.value;
226
+ const isMasked = this.type.value === 'password';
227
+
228
+ return html`
229
+ <div
230
+ class="otp-container"
231
+ part="container"
232
+ role="group"
233
+ aria-label="Verification Code Input"
234
+ @paste=${this.#onPaste}
235
+ >
236
+ ${() => {
237
+ const arr = [];
238
+ for (let i = 0; i < len; i++) {
239
+ const digitVal = this.digits.value[i] || '';
240
+ arr.push(html`
241
+ <input
242
+ type=${isMasked ? 'password' : 'text'}
243
+ inputmode="numeric"
244
+ maxlength="1"
245
+ class="otp-cell"
246
+ part="cell"
247
+ aria-label=${`Digit ${i + 1} of ${len}`}
248
+ .value=${digitVal}
249
+ ?disabled=${this.disabled}
250
+ @input=${(e) => this.#onInput(e, i)}
251
+ @keydown=${(e) => this.#onKeyDown(e, i)}
252
+ @paste=${this.#onPaste}
253
+ @focus=${(e) => e.target.select?.()}
254
+ />
255
+ `);
256
+ }
257
+ return arr;
258
+ }}
259
+ </div>
260
+ `;
261
+ }
262
+ }
263
+
264
+ if (typeof customElements !== 'undefined' && !customElements.get('el-otp-input')) {
265
+ customElements.define('el-otp-input', ElOtpInput);
266
+ }
@@ -0,0 +1,229 @@
1
+ import { Elementum } from '../elementum.js';
2
+ import { html, css } from '../template.js';
3
+ import { signal, computed } from '../signal.js';
4
+
5
+ export class ElPagination extends Elementum {
6
+ static observedAttributes = ['page', 'total', 'page-size', 'sibling-count'];
7
+
8
+ page = signal(1);
9
+ total = signal(0);
10
+ pageSize = signal(10);
11
+ siblingCount = signal(1);
12
+
13
+ totalPages = computed(() => {
14
+ const size = Math.max(1, Number(this.pageSize.value) || 10);
15
+ const tot = Math.max(0, Number(this.total.value) || 0);
16
+ return Math.max(1, Math.ceil(tot / size));
17
+ });
18
+
19
+ connected() {
20
+ this.#syncValues();
21
+ }
22
+
23
+ attributeChanged(name, oldValue, newValue) {
24
+ this.#syncValues();
25
+ }
26
+
27
+ #syncValues() {
28
+ const rawPage = this.getAttribute('page');
29
+ const rawTotal = this.getAttribute('total');
30
+ const rawSize = this.getAttribute('page-size');
31
+ const rawSiblings = this.getAttribute('sibling-count');
32
+
33
+ if (rawPage !== null) this.page.value = Math.max(1, Number(rawPage) || 1);
34
+ if (rawTotal !== null) this.total.value = Math.max(0, Number(rawTotal) || 0);
35
+ if (rawSize !== null) this.pageSize.value = Math.max(1, Number(rawSize) || 10);
36
+ if (rawSiblings !== null) this.siblingCount.value = Math.max(1, Number(rawSiblings) || 1);
37
+ }
38
+
39
+ setPage(p) {
40
+ const target = Math.min(this.totalPages.value, Math.max(1, Number(p) || 1));
41
+ if (this.page.value !== target) {
42
+ this.page.value = target;
43
+ this.setAttribute('page', String(target));
44
+ this.emit('pagechange', { page: target, pageSize: this.pageSize.value });
45
+ }
46
+ }
47
+
48
+ next() {
49
+ if (this.page.value < this.totalPages.value) {
50
+ this.setPage(this.page.value + 1);
51
+ }
52
+ }
53
+
54
+ prev() {
55
+ if (this.page.value > 1) {
56
+ this.setPage(this.page.value - 1);
57
+ }
58
+ }
59
+
60
+ #computePageRange() {
61
+ const total = this.totalPages.value;
62
+ const current = this.page.value;
63
+ const siblings = this.siblingCount.value;
64
+
65
+ const totalPageNumbers = siblings * 2 + 5; // 1 + siblings + current + siblings + last + 2*dots
66
+
67
+ if (total <= totalPageNumbers) {
68
+ return Array.from({ length: total }, (_, i) => i + 1);
69
+ }
70
+
71
+ const leftSiblingIndex = Math.max(current - siblings, 1);
72
+ const rightSiblingIndex = Math.min(current + siblings, total);
73
+
74
+ const shouldShowLeftDots = leftSiblingIndex > 2;
75
+ const shouldShowRightDots = rightSiblingIndex < total - 2;
76
+
77
+ if (!shouldShowLeftDots && shouldShowRightDots) {
78
+ const leftItemCount = 3 + 2 * siblings;
79
+ const leftRange = Array.from({ length: leftItemCount }, (_, i) => i + 1);
80
+ return [...leftRange, '...', total];
81
+ }
82
+
83
+ if (shouldShowLeftDots && !shouldShowRightDots) {
84
+ const rightItemCount = 3 + 2 * siblings;
85
+ const rightRange = Array.from({ length: rightItemCount }, (_, i) => total - rightItemCount + 1 + i);
86
+ return [1, '...', ...rightRange];
87
+ }
88
+
89
+ if (shouldShowLeftDots && shouldShowRightDots) {
90
+ const middleRange = Array.from(
91
+ { length: rightSiblingIndex - leftSiblingIndex + 1 },
92
+ (_, i) => leftSiblingIndex + i
93
+ );
94
+ return [1, '...', ...middleRange, '...', total];
95
+ }
96
+
97
+ return Array.from({ length: total }, (_, i) => i + 1);
98
+ }
99
+
100
+ static styles = css`
101
+ :host {
102
+ display: inline-flex;
103
+ vertical-align: middle;
104
+ font-family: var(--el-font-sans, system-ui, sans-serif);
105
+ font-variant-numeric: tabular-nums;
106
+ box-sizing: border-box;
107
+ user-select: none;
108
+ }
109
+
110
+ nav {
111
+ display: inline-flex;
112
+ align-items: center;
113
+ gap: 4px;
114
+ flex-wrap: wrap;
115
+ }
116
+
117
+ .page-btn,
118
+ .nav-btn {
119
+ display: inline-flex;
120
+ align-items: center;
121
+ justify-content: center;
122
+ min-width: 34px;
123
+ height: 34px;
124
+ padding: 0 8px;
125
+ border: 1px solid var(--el-surface-border, #e2e8f0);
126
+ background: var(--el-surface-card, #ffffff);
127
+ color: var(--el-text-primary, #0f172a);
128
+ border-radius: var(--el-radius-md, 8px);
129
+ font-size: 0.875rem;
130
+ font-weight: 500;
131
+ cursor: pointer;
132
+ box-sizing: border-box;
133
+ transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
134
+ font-family: inherit;
135
+ }
136
+
137
+ .page-btn:hover:not(:disabled):not(.active),
138
+ .nav-btn:hover:not(:disabled) {
139
+ background: var(--el-surface-muted, #f1f5f9);
140
+ border-color: #cbd5e1;
141
+ }
142
+
143
+ .page-btn.active {
144
+ background: var(--el-color-primary, #2563eb);
145
+ color: #ffffff;
146
+ border-color: var(--el-color-primary, #2563eb);
147
+ font-weight: 600;
148
+ }
149
+
150
+ .page-btn:focus-visible,
151
+ .nav-btn:focus-visible {
152
+ outline: 2px solid var(--el-color-primary, #2563eb);
153
+ outline-offset: 1px;
154
+ }
155
+
156
+ .nav-btn:disabled,
157
+ .page-btn:disabled {
158
+ opacity: 0.45;
159
+ cursor: not-allowed;
160
+ background: var(--el-surface-muted, #f8fafc);
161
+ }
162
+
163
+ .ellipsis {
164
+ display: inline-flex;
165
+ align-items: center;
166
+ justify-content: center;
167
+ min-width: 34px;
168
+ height: 34px;
169
+ color: var(--el-text-muted, #64748b);
170
+ font-size: 0.875rem;
171
+ }
172
+ `;
173
+
174
+ render() {
175
+ const isFirstPage = () => this.page.value <= 1;
176
+ const isLastPage = () => this.page.value >= this.totalPages.value;
177
+ const items = () => this.#computePageRange();
178
+
179
+ return html`
180
+ <nav role="navigation" aria-label="Pagination" part="pagination">
181
+ <button
182
+ type="button"
183
+ class="nav-btn prev-btn"
184
+ part="prev-button"
185
+ aria-label="Go to previous page"
186
+ ?disabled=${isFirstPage}
187
+ @click=${() => this.prev()}
188
+ >
189
+ ‹
190
+ </button>
191
+
192
+ ${() =>
193
+ items().map((item) => {
194
+ if (item === '...') {
195
+ return html`<span class="ellipsis" aria-hidden="true">…</span>`;
196
+ }
197
+ const isActive = this.page.value === item;
198
+ return html`
199
+ <button
200
+ type="button"
201
+ class=${() => `page-btn ${isActive ? 'active' : ''}`}
202
+ part=${isActive ? 'page-button active-page' : 'page-button'}
203
+ aria-label=${`Go to page ${item}`}
204
+ aria-current=${isActive ? 'page' : null}
205
+ @click=${() => this.setPage(item)}
206
+ >
207
+ ${item}
208
+ </button>
209
+ `;
210
+ })}
211
+
212
+ <button
213
+ type="button"
214
+ class="nav-btn next-btn"
215
+ part="next-button"
216
+ aria-label="Go to next page"
217
+ ?disabled=${isLastPage}
218
+ @click=${() => this.next()}
219
+ >
220
+ ›
221
+ </button>
222
+ </nav>
223
+ `;
224
+ }
225
+ }
226
+
227
+ if (typeof customElements !== 'undefined' && !customElements.get('el-pagination')) {
228
+ customElements.define('el-pagination', ElPagination);
229
+ }