@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,383 @@
1
+ import { Elementum } from '../elementum.js';
2
+ import { html, css } from '../template.js';
3
+ import { signal, effect } from '../signal.js';
4
+
5
+ /**
6
+ * <el-prompt-input>
7
+ * Beautiful UI-style auto-expanding AI prompt composer with action slots,
8
+ * model tags, and keyboard submit handling (Enter to submit, Shift+Enter for newline).
9
+ *
10
+ * @element el-prompt-input
11
+ * @fires submit - Dispatched when the user submits prompt via Enter or submit button
12
+ * @fires input - Dispatched as the user types
13
+ * @fires change - Dispatched on value commit
14
+ * @slot tools - Left side action bar (e.g. Model Selector, Deep Think toggle, Attachments)
15
+ * @slot actions - Right side custom actions/buttons
16
+ * @csspart container - The outer wrapper container
17
+ * @csspart textarea - The native auto-expanding textarea
18
+ * @csspart bottom-bar - The actions footer bar
19
+ * @csspart submit-button - The built-in submit arrow button
20
+ */
21
+ export class ElPromptInput extends Elementum {
22
+ static formAssociated = true;
23
+ static observedAttributes = [
24
+ 'value',
25
+ 'placeholder',
26
+ 'disabled',
27
+ 'loading',
28
+ 'max-rows',
29
+ 'min-rows',
30
+ 'clear-on-submit',
31
+ 'autofocus'
32
+ ];
33
+
34
+ value = signal('');
35
+ placeholder = signal('Type a message or prompt... (Enter to send, Shift+Enter for newline)');
36
+ disabled = signal(false);
37
+ loading = signal(false);
38
+ maxRows = signal(10);
39
+ minRows = signal(2);
40
+ clearOnSubmit = signal(true);
41
+
42
+ #textarea = null;
43
+
44
+ connected() {
45
+ this.value.value = this.getAttribute('value') || '';
46
+ if (this.hasAttribute('placeholder')) {
47
+ this.placeholder.value = this.getAttribute('placeholder');
48
+ }
49
+ this.disabled.value = this.hasAttribute('disabled');
50
+ this.loading.value = this.hasAttribute('loading');
51
+ if (this.hasAttribute('max-rows')) {
52
+ this.maxRows.value = parseInt(this.getAttribute('max-rows'), 10) || 10;
53
+ }
54
+ if (this.hasAttribute('min-rows')) {
55
+ this.minRows.value = parseInt(this.getAttribute('min-rows'), 10) || 2;
56
+ }
57
+ if (this.hasAttribute('clear-on-submit')) {
58
+ this.clearOnSubmit.value = this.getAttribute('clear-on-submit') !== 'false';
59
+ }
60
+
61
+ this.#textarea = this.root.querySelector('textarea');
62
+ this.setFormValue(this.value.value);
63
+
64
+ // Sync signal changes to textarea & height
65
+ effect(() => {
66
+ const val = this.value.value;
67
+ if (this.#textarea && this.#textarea.value !== val) {
68
+ this.#textarea.value = val;
69
+ this.#autoResize();
70
+ }
71
+ this.setFormValue(val);
72
+ }, { signal: this.signal });
73
+
74
+ if (typeof requestAnimationFrame === 'function') {
75
+ requestAnimationFrame(() => this.#autoResize());
76
+ } else {
77
+ this.#autoResize();
78
+ }
79
+ }
80
+
81
+ attributeChangedCallback(name, oldValue, newValue) {
82
+ if (oldValue === newValue) return;
83
+ switch (name) {
84
+ case 'value':
85
+ this.value.value = newValue || '';
86
+ break;
87
+ case 'placeholder':
88
+ this.placeholder.value = newValue || '';
89
+ break;
90
+ case 'disabled':
91
+ this.disabled.value = newValue !== null;
92
+ break;
93
+ case 'loading':
94
+ this.loading.value = newValue !== null;
95
+ break;
96
+ case 'max-rows':
97
+ this.maxRows.value = parseInt(newValue, 10) || 10;
98
+ this.#autoResize();
99
+ break;
100
+ case 'min-rows':
101
+ this.minRows.value = parseInt(newValue, 10) || 2;
102
+ this.#autoResize();
103
+ break;
104
+ case 'clear-on-submit':
105
+ this.clearOnSubmit.value = newValue !== 'false';
106
+ break;
107
+ }
108
+ }
109
+
110
+ #autoResize() {
111
+ const el = this.#textarea || this.root?.querySelector?.('textarea');
112
+ if (!el) return;
113
+
114
+ el.style.height = 'auto';
115
+ const computed = typeof window.getComputedStyle === 'function' ? window.getComputedStyle(el) : null;
116
+ const lineHeight = parseFloat(computed?.lineHeight) || 24;
117
+ const paddingTop = parseFloat(computed?.paddingTop) || 0;
118
+ const paddingBottom = parseFloat(computed?.paddingBottom) || 0;
119
+ const padding = paddingTop + paddingBottom;
120
+
121
+ const minH = lineHeight * this.minRows.value + padding;
122
+ const maxH = lineHeight * this.maxRows.value + padding;
123
+
124
+ const scrollHeight = el.scrollHeight || minH;
125
+ const newH = Math.min(Math.max(scrollHeight, minH), maxH);
126
+ el.style.height = `${newH}px`;
127
+ el.style.overflowY = scrollHeight > maxH ? 'auto' : 'hidden';
128
+ }
129
+
130
+ #handleInput = (e) => {
131
+ this.value.value = e.target.value;
132
+ this.dispatchEvent(new CustomEvent('input', { bubbles: true, composed: true, detail: { value: this.value.value } }));
133
+ this.#autoResize();
134
+ };
135
+
136
+ #handleChange = () => {
137
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: { value: this.value.value } }));
138
+ };
139
+
140
+ #handleKeyDown = (e) => {
141
+ if (e.key === 'Enter' && !e.shiftKey && !e.isComposing) {
142
+ e.preventDefault();
143
+ this.submit();
144
+ }
145
+ };
146
+
147
+ /**
148
+ * Programmatically trigger prompt submission
149
+ */
150
+ submit() {
151
+ if (this.disabled.value || this.loading.value) return;
152
+ const val = this.value.value.trim();
153
+ if (!val) return;
154
+
155
+ const event = new CustomEvent('submit', {
156
+ bubbles: true,
157
+ composed: true,
158
+ cancelable: true,
159
+ detail: { value: val }
160
+ });
161
+
162
+ const notCancelled = this.dispatchEvent(event);
163
+ if (notCancelled && this.clearOnSubmit.value) {
164
+ this.value.value = '';
165
+ if (this.#textarea) {
166
+ this.#textarea.value = '';
167
+ this.#autoResize();
168
+ }
169
+ }
170
+ }
171
+
172
+ formResetCallback() {
173
+ this.value.value = '';
174
+ if (this.#textarea) {
175
+ this.#textarea.value = '';
176
+ this.#autoResize();
177
+ }
178
+ }
179
+
180
+ focus() {
181
+ if (this.#textarea) this.#textarea.focus();
182
+ }
183
+
184
+ blur() {
185
+ if (this.#textarea) this.#textarea.blur();
186
+ }
187
+
188
+ static styles = css`
189
+ :host {
190
+ display: block;
191
+ box-sizing: border-box;
192
+ width: 100%;
193
+ font-family: var(--el-font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
194
+ }
195
+
196
+ .container {
197
+ position: relative;
198
+ display: flex;
199
+ flex-direction: column;
200
+ background: var(--el-surface-elevated, #ffffff);
201
+ border: 1px solid var(--el-border-translucent, rgba(15, 23, 42, 0.1));
202
+ border-radius: var(--el-radius-xl, 16px);
203
+ box-shadow: var(--el-shadow-card, 0 1px 3px rgba(0,0,0,0.06), 0 8px 16px -4px rgba(0,0,0,0.04));
204
+ padding: 12px 14px 10px 14px;
205
+ transition: border-color var(--el-transition-fluid, 280ms cubic-bezier(0.16, 1, 0.3, 1)),
206
+ box-shadow var(--el-transition-fluid, 280ms cubic-bezier(0.16, 1, 0.3, 1));
207
+ box-sizing: border-box;
208
+ }
209
+
210
+ .container:focus-within {
211
+ border-color: var(--el-color-primary, #2563eb);
212
+ box-shadow: 0 0 0 3px var(--el-color-primary-focus, rgba(37, 99, 235, 0.15)),
213
+ var(--el-shadow-card, 0 1px 3px rgba(0,0,0,0.06), 0 8px 16px -4px rgba(0,0,0,0.04));
214
+ }
215
+
216
+ :host([disabled]) .container {
217
+ opacity: 0.6;
218
+ background: var(--el-surface-muted, #f8fafc);
219
+ cursor: not-allowed;
220
+ }
221
+
222
+ .textarea-wrapper {
223
+ position: relative;
224
+ width: 100%;
225
+ }
226
+
227
+ textarea {
228
+ width: 100%;
229
+ min-height: 48px;
230
+ max-height: 320px;
231
+ padding: 2px 0 6px 0;
232
+ border: none;
233
+ outline: none;
234
+ background: transparent;
235
+ resize: none;
236
+ font-family: inherit;
237
+ font-size: 0.9375rem;
238
+ line-height: 1.5;
239
+ color: var(--el-text-primary, #0f172a);
240
+ box-sizing: border-box;
241
+ overflow-y: hidden;
242
+ }
243
+
244
+ textarea::placeholder {
245
+ color: var(--el-text-muted, #94a3b8);
246
+ }
247
+
248
+ textarea:disabled {
249
+ cursor: not-allowed;
250
+ }
251
+
252
+ .bottom-bar {
253
+ display: flex;
254
+ align-items: center;
255
+ justify-content: space-between;
256
+ gap: 12px;
257
+ margin-top: 6px;
258
+ padding-top: 6px;
259
+ border-top: 1px solid var(--el-border-translucent, rgba(15, 23, 42, 0.05));
260
+ }
261
+
262
+ .tools-slot {
263
+ display: flex;
264
+ align-items: center;
265
+ gap: 8px;
266
+ flex-wrap: wrap;
267
+ flex: 1;
268
+ }
269
+
270
+ .actions-slot {
271
+ display: flex;
272
+ align-items: center;
273
+ gap: 8px;
274
+ }
275
+
276
+ .submit-button {
277
+ display: inline-flex;
278
+ align-items: center;
279
+ justify-content: center;
280
+ width: 34px;
281
+ height: 34px;
282
+ padding: 0;
283
+ border: none;
284
+ border-radius: var(--el-radius-full, 9999px);
285
+ background: var(--el-color-primary, #2563eb);
286
+ color: #ffffff;
287
+ cursor: pointer;
288
+ transition: transform var(--el-transition-snappy, 150ms ease),
289
+ background-color var(--el-transition-snappy, 150ms ease),
290
+ opacity 0.2s ease;
291
+ flex-shrink: 0;
292
+ }
293
+
294
+ .submit-button:hover:not(:disabled) {
295
+ background: var(--el-color-primary-hover, #1d4ed8);
296
+ transform: scale(1.04);
297
+ }
298
+
299
+ .submit-button:active:not(:disabled) {
300
+ transform: scale(0.96);
301
+ }
302
+
303
+ .submit-button:disabled {
304
+ background: var(--el-surface-muted, #e2e8f0);
305
+ color: var(--el-text-muted, #94a3b8);
306
+ cursor: not-allowed;
307
+ }
308
+
309
+ .spinner {
310
+ width: 16px;
311
+ height: 16px;
312
+ border: 2px solid rgba(255, 255, 255, 0.3);
313
+ border-top-color: #ffffff;
314
+ border-radius: 50%;
315
+ animation: spin 0.7s linear infinite;
316
+ }
317
+
318
+ @keyframes spin {
319
+ to { transform: rotate(360deg); }
320
+ }
321
+
322
+ @media (prefers-reduced-motion: reduce) {
323
+ .container, .submit-button {
324
+ transition: none;
325
+ }
326
+ .spinner {
327
+ animation-duration: 1.5s;
328
+ }
329
+ }
330
+
331
+ @media (pointer: coarse) {
332
+ textarea {
333
+ font-size: max(16px, 1em);
334
+ }
335
+ }
336
+ `;
337
+
338
+ render() {
339
+ return html`
340
+ <div class="container" part="container">
341
+ <div class="textarea-wrapper">
342
+ <textarea
343
+ part="textarea"
344
+ .placeholder=${() => this.placeholder.value}
345
+ .value=${() => this.value.value}
346
+ ?disabled=${() => Boolean(this.disabled.value)}
347
+ @input=${this.#handleInput}
348
+ @change=${this.#handleChange}
349
+ @keydown=${this.#handleKeyDown}
350
+ rows="2"
351
+ aria-label=${() => this.placeholder.value}
352
+ ></textarea>
353
+ </div>
354
+ <div class="bottom-bar" part="bottom-bar">
355
+ <div class="tools-slot" part="tools">
356
+ <slot name="tools"></slot>
357
+ </div>
358
+ <div class="actions-slot" part="actions">
359
+ <slot name="actions">
360
+ <button
361
+ type="button"
362
+ class="submit-button"
363
+ part="submit-button"
364
+ ?disabled=${() => !this.value.value.trim() || this.disabled.value || this.loading.value}
365
+ @click=${() => this.submit()}
366
+ aria-label="Submit prompt"
367
+ >
368
+ ${() => this.loading.value
369
+ ? html`<div class="spinner" aria-label="Loading"></div>`
370
+ : html`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg>`
371
+ }
372
+ </button>
373
+ </slot>
374
+ </div>
375
+ </div>
376
+ </div>
377
+ `;
378
+ }
379
+ }
380
+
381
+ if (typeof customElements !== 'undefined' && !customElements.get('el-prompt-input')) {
382
+ customElements.define('el-prompt-input', ElPromptInput);
383
+ }