@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.
- package/LICENSE +21 -0
- package/README.md +282 -2
- package/custom-elements.json +3613 -0
- package/mcp/server.js +593 -0
- package/package.json +77 -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/behaviors/index.js +760 -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 +231 -0
- package/src/components/el-calendar.js +436 -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 +230 -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 +229 -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 +183 -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 +164 -0
- package/src/components/el-otp-input.js +266 -0
- package/src/components/el-pagination.js +231 -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 +220 -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 +504 -0
- package/src/index.d.ts +1093 -0
- package/src/index.js +112 -0
- package/src/signal.js +215 -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,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <el-code-block>
|
|
3
|
+
* Accessible code snippet container with optional language header and one-click copy button.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Elementum } from '../elementum.js';
|
|
7
|
+
import { html, css } from '../template.js';
|
|
8
|
+
import { signal } from '../signal.js';
|
|
9
|
+
import { announce } from '../behaviors/index.js';
|
|
10
|
+
|
|
11
|
+
const LANGUAGE_LABELS = {
|
|
12
|
+
html: 'HTML',
|
|
13
|
+
js: 'JavaScript',
|
|
14
|
+
javascript: 'JavaScript',
|
|
15
|
+
ts: 'TypeScript',
|
|
16
|
+
css: 'CSS',
|
|
17
|
+
bash: 'Shell',
|
|
18
|
+
sh: 'Shell',
|
|
19
|
+
json: 'JSON',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export class ElCodeBlock extends Elementum {
|
|
23
|
+
static observedAttributes = ['code', 'language', 'copyable', 'compact'];
|
|
24
|
+
|
|
25
|
+
code = signal('');
|
|
26
|
+
// 'html' | 'js' | 'css' | 'bash' | 'json' | 'ts'
|
|
27
|
+
language = signal('');
|
|
28
|
+
copyable = signal(false);
|
|
29
|
+
compact = signal(false);
|
|
30
|
+
copied = signal(false);
|
|
31
|
+
|
|
32
|
+
#copyTimer = null;
|
|
33
|
+
|
|
34
|
+
static styles = css`
|
|
35
|
+
:host {
|
|
36
|
+
display: block;
|
|
37
|
+
font-family: var(--el-font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
|
|
38
|
+
box-sizing: border-box;
|
|
39
|
+
max-width: 100%;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
:host([compact]) {
|
|
43
|
+
display: inline-block;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.code-wrapper {
|
|
47
|
+
position: relative;
|
|
48
|
+
background: #0f172a;
|
|
49
|
+
color: #f8fafc;
|
|
50
|
+
border: 1px solid #1e293b;
|
|
51
|
+
border-radius: var(--el-radius-md, 10px);
|
|
52
|
+
overflow: hidden;
|
|
53
|
+
box-sizing: border-box;
|
|
54
|
+
transition: border-color 0.15s ease;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.code-wrapper:hover {
|
|
58
|
+
border-color: #334155;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.code-header {
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: space-between;
|
|
65
|
+
gap: 12px;
|
|
66
|
+
padding: 8px 14px;
|
|
67
|
+
background: rgba(15, 23, 42, 0.85);
|
|
68
|
+
border-bottom: 1px solid #1e293b;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.lang-tag {
|
|
72
|
+
font-family: var(--el-font-sans, system-ui, sans-serif);
|
|
73
|
+
font-size: 0.7rem;
|
|
74
|
+
font-weight: 700;
|
|
75
|
+
letter-spacing: 0.06em;
|
|
76
|
+
text-transform: uppercase;
|
|
77
|
+
color: #94a3b8;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.code-body {
|
|
81
|
+
display: flex;
|
|
82
|
+
align-items: center;
|
|
83
|
+
justify-content: space-between;
|
|
84
|
+
gap: 12px;
|
|
85
|
+
padding: 14px 16px;
|
|
86
|
+
overflow-x: auto;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
:host([compact]) .code-body {
|
|
90
|
+
padding: 10px 14px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
pre {
|
|
94
|
+
margin: 0;
|
|
95
|
+
padding: 0;
|
|
96
|
+
font-family: inherit;
|
|
97
|
+
font-size: 0.84rem;
|
|
98
|
+
line-height: 1.6;
|
|
99
|
+
color: #e2e8f0;
|
|
100
|
+
white-space: pre;
|
|
101
|
+
overflow-x: auto;
|
|
102
|
+
flex: 1 1 auto;
|
|
103
|
+
min-width: 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.inline-actions {
|
|
107
|
+
position: relative;
|
|
108
|
+
flex-shrink: 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.copy-btn {
|
|
112
|
+
display: inline-flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
gap: 5px;
|
|
115
|
+
background: #1e293b;
|
|
116
|
+
color: #e2e8f0;
|
|
117
|
+
border: 1px solid #334155;
|
|
118
|
+
border-radius: 6px;
|
|
119
|
+
padding: 4px 10px;
|
|
120
|
+
font-family: var(--el-font-sans, system-ui, sans-serif);
|
|
121
|
+
font-size: 0.72rem;
|
|
122
|
+
font-weight: 600;
|
|
123
|
+
cursor: pointer;
|
|
124
|
+
transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.copy-btn:hover {
|
|
128
|
+
background: var(--el-color-primary, #2563eb);
|
|
129
|
+
border-color: var(--el-color-primary, #2563eb);
|
|
130
|
+
color: #ffffff;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.copy-btn[data-copied="true"] {
|
|
134
|
+
background: var(--el-color-success, #16a34a);
|
|
135
|
+
border-color: var(--el-color-success, #16a34a);
|
|
136
|
+
color: #ffffff;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.copy-btn:focus-visible {
|
|
140
|
+
outline: 2px solid var(--el-color-primary, #2563eb);
|
|
141
|
+
outline-offset: 2px;
|
|
142
|
+
}
|
|
143
|
+
`;
|
|
144
|
+
|
|
145
|
+
disconnected() {
|
|
146
|
+
if (this.#copyTimer) {
|
|
147
|
+
clearTimeout(this.#copyTimer);
|
|
148
|
+
this.#copyTimer = null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
getCodeText() {
|
|
153
|
+
if (this.code.value) return this.code.value;
|
|
154
|
+
return (this.textContent || '').trim();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async copyCode(e) {
|
|
158
|
+
if (e) e.stopPropagation();
|
|
159
|
+
const text = this.getCodeText();
|
|
160
|
+
try {
|
|
161
|
+
if (typeof navigator !== 'undefined' && navigator.clipboard?.writeText) {
|
|
162
|
+
await navigator.clipboard.writeText(text);
|
|
163
|
+
}
|
|
164
|
+
} catch {
|
|
165
|
+
// Clipboard API may be unavailable in restricted contexts; still emit event & show feedback
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
this.copied.value = true;
|
|
169
|
+
if (this.#copyTimer) clearTimeout(this.#copyTimer);
|
|
170
|
+
this.#copyTimer = setTimeout(() => {
|
|
171
|
+
this.copied.value = false;
|
|
172
|
+
this.#copyTimer = null;
|
|
173
|
+
}, 1500);
|
|
174
|
+
|
|
175
|
+
this.emit('copy', { code: text });
|
|
176
|
+
announce('Code copied to clipboard', 'polite');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
#getLanguageLabel() {
|
|
180
|
+
const key = (this.language.value || '').trim().toLowerCase();
|
|
181
|
+
return LANGUAGE_LABELS[key] || (key ? key.toUpperCase() : '');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
#renderCopyButton() {
|
|
185
|
+
return html`
|
|
186
|
+
<button
|
|
187
|
+
class="copy-btn"
|
|
188
|
+
part="copy-button"
|
|
189
|
+
type="button"
|
|
190
|
+
data-copied=${() => (this.copied.value ? 'true' : 'false')}
|
|
191
|
+
aria-label=${() => (this.copied.value ? 'Copied to clipboard' : 'Copy code snippet')}
|
|
192
|
+
onclick=${(e) => this.copyCode(e)}
|
|
193
|
+
>
|
|
194
|
+
${() => (this.copied.value ? 'Copied ✓' : 'Copy')}
|
|
195
|
+
</button>
|
|
196
|
+
`;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
render() {
|
|
200
|
+
return html`
|
|
201
|
+
<div class="code-wrapper" part="container" role="region" aria-label="Code snippet">
|
|
202
|
+
${() => {
|
|
203
|
+
const langLabel = this.#getLanguageLabel();
|
|
204
|
+
const showHeader = Boolean(langLabel) && !this.compact.value;
|
|
205
|
+
if (!showHeader) return '';
|
|
206
|
+
return html`
|
|
207
|
+
<div class="code-header" part="header">
|
|
208
|
+
<span class="lang-tag" part="language">${() => langLabel}</span>
|
|
209
|
+
${() => (this.copyable.value ? this.#renderCopyButton() : '')}
|
|
210
|
+
</div>
|
|
211
|
+
`;
|
|
212
|
+
}}
|
|
213
|
+
<div class="code-body" part="body">
|
|
214
|
+
<pre part="pre" tabindex="0"><code part="code">${() => this.code.value}<slot style=${() => (this.code.value ? 'display:none;' : '')}></slot></code></pre>
|
|
215
|
+
${() => {
|
|
216
|
+
const langLabel = this.#getLanguageLabel();
|
|
217
|
+
const hasHeader = Boolean(langLabel) && !this.compact.value;
|
|
218
|
+
return this.copyable.value && !hasHeader
|
|
219
|
+
? html`<div class="inline-actions">${() => this.#renderCopyButton()}</div>`
|
|
220
|
+
: '';
|
|
221
|
+
}}
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
`;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (typeof customElements !== 'undefined' && !customElements.get('el-code-block')) {
|
|
229
|
+
customElements.define('el-code-block', ElCodeBlock);
|
|
230
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <el-collapsible>
|
|
3
|
+
* Accessible, zero-dependency collapsible disclosure primitive inspired by Base UI.
|
|
4
|
+
* Provides smooth animated height expansion via modern CSS grid transition,
|
|
5
|
+
* keyboard accessibility, and state attributes.
|
|
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 ElCollapsible extends Elementum {
|
|
13
|
+
static observedAttributes = ['open', 'disabled'];
|
|
14
|
+
|
|
15
|
+
isOpen = signal(false);
|
|
16
|
+
disabled = signal(false);
|
|
17
|
+
|
|
18
|
+
static styles = css`
|
|
19
|
+
:host {
|
|
20
|
+
display: block;
|
|
21
|
+
width: 100%;
|
|
22
|
+
font-family: var(--el-font-sans, system-ui, sans-serif);
|
|
23
|
+
color: var(--el-text-primary, #0f172a);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.trigger-container {
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
user-select: none;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
:host([disabled]) .trigger-container {
|
|
34
|
+
cursor: not-allowed;
|
|
35
|
+
opacity: 0.5;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.content-wrapper {
|
|
39
|
+
display: grid;
|
|
40
|
+
grid-template-rows: 0fr;
|
|
41
|
+
transition: grid-template-rows 200ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.content-wrapper.open {
|
|
45
|
+
grid-template-rows: 1fr;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.content-inner {
|
|
49
|
+
overflow: hidden;
|
|
50
|
+
min-height: 0;
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
connected() {
|
|
55
|
+
this.isOpen.value = this.hasAttribute('open');
|
|
56
|
+
this.disabled.value = this.hasAttribute('disabled');
|
|
57
|
+
this.setAttribute('data-state', this.isOpen.value ? 'open' : 'closed');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
attributeChanged(name, oldValue, newValue) {
|
|
61
|
+
if (name === 'open') {
|
|
62
|
+
const open = newValue !== null && newValue !== 'false';
|
|
63
|
+
if (open !== this.isOpen.value) {
|
|
64
|
+
if (open) this.open();
|
|
65
|
+
else this.close();
|
|
66
|
+
}
|
|
67
|
+
} else if (name === 'disabled') {
|
|
68
|
+
this.disabled.value = newValue !== null && newValue !== 'false';
|
|
69
|
+
}
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
open() {
|
|
74
|
+
if (this.disabled.value) return;
|
|
75
|
+
if (!this.isOpen.value) {
|
|
76
|
+
this.isOpen.value = true;
|
|
77
|
+
this.setAttribute('data-state', 'open');
|
|
78
|
+
this.emit('open');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
close() {
|
|
83
|
+
if (this.disabled.value) return;
|
|
84
|
+
if (this.isOpen.value) {
|
|
85
|
+
this.isOpen.value = false;
|
|
86
|
+
this.setAttribute('data-state', 'closed');
|
|
87
|
+
this.emit('close');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
toggle() {
|
|
92
|
+
if (this.isOpen.value) this.close();
|
|
93
|
+
else this.open();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
render() {
|
|
97
|
+
return html`
|
|
98
|
+
<div
|
|
99
|
+
class="trigger-container"
|
|
100
|
+
part="trigger"
|
|
101
|
+
@click=${() => this.toggle()}
|
|
102
|
+
aria-expanded=${() => (this.isOpen.value ? 'true' : 'false')}
|
|
103
|
+
aria-disabled=${() => (this.disabled.value ? 'true' : 'false')}
|
|
104
|
+
>
|
|
105
|
+
<slot name="trigger"></slot>
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
<div
|
|
109
|
+
class=${() => `content-wrapper ${this.isOpen.value ? 'open' : ''}`}
|
|
110
|
+
data-state=${() => (this.isOpen.value ? 'open' : 'closed')}
|
|
111
|
+
part="content"
|
|
112
|
+
role="region"
|
|
113
|
+
>
|
|
114
|
+
<div class="content-inner">
|
|
115
|
+
<slot></slot>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
`;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (typeof customElements !== 'undefined' && !customElements.get('el-collapsible')) {
|
|
123
|
+
customElements.define('el-collapsible', ElCollapsible);
|
|
124
|
+
}
|