@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.
- package/LICENSE +21 -0
- package/README.md +266 -2
- package/custom-elements.json +3613 -0
- package/mcp/server.js +408 -0
- package/package.json +72 -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/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 +220 -0
- package/src/components/el-calendar.js +413 -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 +228 -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 +212 -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 +182 -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 +153 -0
- package/src/components/el-otp-input.js +266 -0
- package/src/components/el-pagination.js +229 -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 +219 -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 +485 -0
- package/src/index.d.ts +1007 -0
- package/src/index.js +99 -0
- package/src/signal.js +194 -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,328 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <el-context-menu>
|
|
3
|
+
* Accessible context menu primitive inspired by Base UI.
|
|
4
|
+
* Opens at pointer coordinates on right-click or keyboard (Shift+F10)
|
|
5
|
+
* with viewport collision boundary detection, roving item focus, and light dismiss.
|
|
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 ElContextMenu extends Elementum {
|
|
13
|
+
static observedAttributes = ['disabled'];
|
|
14
|
+
|
|
15
|
+
isOpen = signal(false);
|
|
16
|
+
disabled = signal(false);
|
|
17
|
+
posX = signal(0);
|
|
18
|
+
posY = signal(0);
|
|
19
|
+
|
|
20
|
+
#touchStartX = 0;
|
|
21
|
+
#touchStartY = 0;
|
|
22
|
+
#touchTimer = null;
|
|
23
|
+
#isLongPress = false;
|
|
24
|
+
|
|
25
|
+
static styles = css`
|
|
26
|
+
:host {
|
|
27
|
+
display: block;
|
|
28
|
+
position: relative;
|
|
29
|
+
font-family: var(--el-font-sans, system-ui, sans-serif);
|
|
30
|
+
box-sizing: border-box;
|
|
31
|
+
-webkit-touch-callout: none;
|
|
32
|
+
-webkit-user-select: none;
|
|
33
|
+
user-select: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.trigger-area {
|
|
37
|
+
display: block;
|
|
38
|
+
width: 100%;
|
|
39
|
+
height: 100%;
|
|
40
|
+
-webkit-touch-callout: none;
|
|
41
|
+
-webkit-user-select: none;
|
|
42
|
+
user-select: none;
|
|
43
|
+
touch-action: pan-x pan-y;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
::slotted(:not([slot="menu"])) {
|
|
47
|
+
-webkit-touch-callout: none !important;
|
|
48
|
+
-webkit-user-select: none !important;
|
|
49
|
+
user-select: none !important;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.menu {
|
|
53
|
+
position: fixed;
|
|
54
|
+
z-index: 9999;
|
|
55
|
+
display: none;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
min-width: 180px;
|
|
58
|
+
padding: 4px;
|
|
59
|
+
background: var(--el-surface-base, #ffffff);
|
|
60
|
+
border: 1px solid var(--el-surface-border, #e2e8f0);
|
|
61
|
+
border-radius: var(--el-radius-md, 8px);
|
|
62
|
+
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
|
|
63
|
+
box-sizing: border-box;
|
|
64
|
+
outline: none;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
:host([data-state="open"]) .menu {
|
|
68
|
+
display: flex;
|
|
69
|
+
transform-origin: top left;
|
|
70
|
+
animation: el-fade-in 120ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@media (prefers-reduced-motion: reduce) {
|
|
74
|
+
:host([data-state="open"]) .menu {
|
|
75
|
+
animation: none;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
:root[data-theme="dark"] .menu {
|
|
80
|
+
background: #1e293b;
|
|
81
|
+
border-color: #334155;
|
|
82
|
+
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@keyframes el-fade-in {
|
|
86
|
+
from {
|
|
87
|
+
opacity: 0;
|
|
88
|
+
transform: scale(0.96);
|
|
89
|
+
}
|
|
90
|
+
to {
|
|
91
|
+
opacity: 1;
|
|
92
|
+
transform: scale(1);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
::slotted([role="menuitem"]),
|
|
97
|
+
::slotted(button),
|
|
98
|
+
::slotted(.menu-item) {
|
|
99
|
+
display: flex;
|
|
100
|
+
align-items: center;
|
|
101
|
+
gap: 8px;
|
|
102
|
+
width: 100%;
|
|
103
|
+
padding: 6px 10px;
|
|
104
|
+
font-size: 13px;
|
|
105
|
+
color: var(--el-text-base, #111827);
|
|
106
|
+
background: transparent;
|
|
107
|
+
border: none;
|
|
108
|
+
border-radius: var(--el-radius-sm, 4px);
|
|
109
|
+
text-align: left;
|
|
110
|
+
cursor: pointer;
|
|
111
|
+
font-family: inherit;
|
|
112
|
+
box-sizing: border-box;
|
|
113
|
+
outline: none;
|
|
114
|
+
transition: background-color 0.12s ease;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
::slotted([role="menuitem"]:hover),
|
|
118
|
+
::slotted(button:hover),
|
|
119
|
+
::slotted(.menu-item:hover),
|
|
120
|
+
::slotted([role="menuitem"]:focus-visible),
|
|
121
|
+
::slotted(button:focus-visible) {
|
|
122
|
+
background: var(--el-surface-muted, #f1f5f9);
|
|
123
|
+
color: var(--el-color-primary, #2563eb);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
:root[data-theme="dark"] ::slotted([role="menuitem"]:hover),
|
|
127
|
+
:root[data-theme="dark"] ::slotted(button:hover),
|
|
128
|
+
:root[data-theme="dark"] ::slotted(.menu-item:hover) {
|
|
129
|
+
background: #334155;
|
|
130
|
+
color: #93c5fd;
|
|
131
|
+
}
|
|
132
|
+
`;
|
|
133
|
+
|
|
134
|
+
connected() {
|
|
135
|
+
if (this.hasAttribute('disabled')) this.disabled.value = true;
|
|
136
|
+
this.setAttribute('data-state', 'closed');
|
|
137
|
+
|
|
138
|
+
this.addEventListener('contextmenu', this.#onContextMenu);
|
|
139
|
+
this.addEventListener('pointerdown', this.#onPointerDown);
|
|
140
|
+
this.addEventListener('pointermove', this.#onPointerMove);
|
|
141
|
+
this.addEventListener('pointerup', this.#onPointerUp);
|
|
142
|
+
this.addEventListener('pointercancel', this.#clearTouchTimer);
|
|
143
|
+
this.addEventListener('click', this.#onClick, true);
|
|
144
|
+
this.addEventListener('keydown', this.#onKeyDown);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
disconnected() {
|
|
148
|
+
this.#clearTouchTimer();
|
|
149
|
+
this.removeEventListener('contextmenu', this.#onContextMenu);
|
|
150
|
+
this.removeEventListener('pointerdown', this.#onPointerDown);
|
|
151
|
+
this.removeEventListener('pointermove', this.#onPointerMove);
|
|
152
|
+
this.removeEventListener('pointerup', this.#onPointerUp);
|
|
153
|
+
this.removeEventListener('pointercancel', this.#clearTouchTimer);
|
|
154
|
+
this.removeEventListener('click', this.#onClick, true);
|
|
155
|
+
this.removeEventListener('keydown', this.#onKeyDown);
|
|
156
|
+
this.#removeGlobalListeners();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
attributeChanged(name, oldValue, newValue) {
|
|
160
|
+
if (name === 'disabled') this.disabled.value = newValue !== null;
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
#isMenuEvent(e) {
|
|
165
|
+
const path = e.composedPath ? e.composedPath() : [];
|
|
166
|
+
const menu = this.shadowRoot?.querySelector('.menu');
|
|
167
|
+
return menu ? path.includes(menu) : false;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
#onContextMenu = (e) => {
|
|
171
|
+
if (this.disabled.value || this.#isMenuEvent(e)) return;
|
|
172
|
+
e.preventDefault();
|
|
173
|
+
this.#clearTouchTimer();
|
|
174
|
+
this.open(e.clientX, e.clientY);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
#onPointerDown = (e) => {
|
|
178
|
+
if (this.disabled.value || this.#isMenuEvent(e)) return;
|
|
179
|
+
if (e.pointerType === 'touch' || e.pointerType === 'pen') {
|
|
180
|
+
this.#touchStartX = e.clientX;
|
|
181
|
+
this.#touchStartY = e.clientY;
|
|
182
|
+
this.#isLongPress = false;
|
|
183
|
+
this.#clearTouchTimer();
|
|
184
|
+
|
|
185
|
+
this.#touchTimer = setTimeout(() => {
|
|
186
|
+
this.#isLongPress = true;
|
|
187
|
+
if (typeof window !== 'undefined' && window.getSelection) {
|
|
188
|
+
try { window.getSelection()?.removeAllRanges?.(); } catch (_) {}
|
|
189
|
+
}
|
|
190
|
+
if (typeof navigator !== 'undefined' && navigator.vibrate) {
|
|
191
|
+
try { navigator.vibrate(30); } catch (_) {}
|
|
192
|
+
}
|
|
193
|
+
this.open(this.#touchStartX, this.#touchStartY);
|
|
194
|
+
}, 500);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
#onPointerMove = (e) => {
|
|
199
|
+
if (!this.#touchTimer) return;
|
|
200
|
+
if (Math.hypot(e.clientX - this.#touchStartX, e.clientY - this.#touchStartY) > 10) {
|
|
201
|
+
this.#clearTouchTimer();
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
#onPointerUp = (e) => {
|
|
206
|
+
this.#clearTouchTimer();
|
|
207
|
+
if (this.#isLongPress) {
|
|
208
|
+
e.preventDefault();
|
|
209
|
+
setTimeout(() => { this.#isLongPress = false; }, 100);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
#onClick = (e) => {
|
|
214
|
+
if (this.#isLongPress) {
|
|
215
|
+
e.preventDefault();
|
|
216
|
+
e.stopPropagation();
|
|
217
|
+
this.#isLongPress = false;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
#clearTouchTimer = () => {
|
|
222
|
+
if (this.#touchTimer) {
|
|
223
|
+
clearTimeout(this.#touchTimer);
|
|
224
|
+
this.#touchTimer = null;
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
open(x = 100, y = 100) {
|
|
229
|
+
if (this.disabled.value) return;
|
|
230
|
+
this.posX.value = x;
|
|
231
|
+
this.posY.value = y;
|
|
232
|
+
this.isOpen.value = true;
|
|
233
|
+
this.setAttribute('data-state', 'open');
|
|
234
|
+
|
|
235
|
+
// Viewport collision adjustment
|
|
236
|
+
const winW = typeof window !== 'undefined' ? window.innerWidth : 1024;
|
|
237
|
+
const winH = typeof window !== 'undefined' ? window.innerHeight : 768;
|
|
238
|
+
const estimatedW = 180;
|
|
239
|
+
const estimatedH = 160;
|
|
240
|
+
|
|
241
|
+
let adjustedX = x;
|
|
242
|
+
let adjustedY = y;
|
|
243
|
+
if (x + estimatedW > winW) adjustedX = Math.max(8, x - estimatedW);
|
|
244
|
+
if (y + estimatedH > winH) adjustedY = Math.max(8, y - estimatedH);
|
|
245
|
+
|
|
246
|
+
this.posX.value = adjustedX;
|
|
247
|
+
this.posY.value = adjustedY;
|
|
248
|
+
|
|
249
|
+
this.#addGlobalListeners();
|
|
250
|
+
this.emit('open', { x: adjustedX, y: adjustedY });
|
|
251
|
+
|
|
252
|
+
const raf = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : (cb) => setTimeout(cb, 0);
|
|
253
|
+
raf(() => {
|
|
254
|
+
const firstItem = this.querySelector('[role="menuitem"], button, .menu-item');
|
|
255
|
+
firstItem?.focus();
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
close() {
|
|
260
|
+
if (!this.isOpen.value) return;
|
|
261
|
+
this.isOpen.value = false;
|
|
262
|
+
this.setAttribute('data-state', 'closed');
|
|
263
|
+
this.#removeGlobalListeners();
|
|
264
|
+
this.emit('close');
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
toggle(x, y) {
|
|
268
|
+
if (this.isOpen.value) this.close();
|
|
269
|
+
else this.open(x, y);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
#addGlobalListeners() {
|
|
273
|
+
this.#removeGlobalListeners();
|
|
274
|
+
document.addEventListener('pointerdown', this.#onPointerDownOutside, true);
|
|
275
|
+
window.addEventListener('keydown', this.#onWindowKeyDown, true);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
#removeGlobalListeners() {
|
|
279
|
+
document.removeEventListener('pointerdown', this.#onPointerDownOutside, true);
|
|
280
|
+
window.removeEventListener('keydown', this.#onWindowKeyDown, true);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
#onPointerDownOutside = (e) => {
|
|
284
|
+
if (!this.isOpen.value) return;
|
|
285
|
+
const path = e.composedPath ? e.composedPath() : [];
|
|
286
|
+
if (!path.includes(this)) {
|
|
287
|
+
this.close();
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
#onWindowKeyDown = (e) => {
|
|
292
|
+
if (!this.isOpen.value) return;
|
|
293
|
+
if (e.key === 'Escape') {
|
|
294
|
+
e.preventDefault();
|
|
295
|
+
this.close();
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
#onKeyDown = (e) => {
|
|
300
|
+
// Shift+F10 opens context menu via keyboard
|
|
301
|
+
if (e.shiftKey && e.key === 'F10') {
|
|
302
|
+
e.preventDefault();
|
|
303
|
+
const rect = this.getBoundingClientRect();
|
|
304
|
+
this.open(rect.left + rect.width / 2, rect.top + rect.height / 2);
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
render() {
|
|
309
|
+
return html`
|
|
310
|
+
<div class="trigger-area" part="trigger">
|
|
311
|
+
<slot></slot>
|
|
312
|
+
</div>
|
|
313
|
+
<div
|
|
314
|
+
class="menu"
|
|
315
|
+
part="menu"
|
|
316
|
+
role="menu"
|
|
317
|
+
tabindex="-1"
|
|
318
|
+
style=${() => `left: ${this.posX.value}px; top: ${this.posY.value}px;`}
|
|
319
|
+
>
|
|
320
|
+
<slot name="menu"></slot>
|
|
321
|
+
</div>
|
|
322
|
+
`;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (typeof customElements !== 'undefined' && !customElements.get('el-context-menu')) {
|
|
327
|
+
customElements.define('el-context-menu', ElContextMenu);
|
|
328
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { Elementum } from '../elementum.js';
|
|
2
|
+
import { html, css } from '../template.js';
|
|
3
|
+
import { signal } from '../signal.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* <el-data-list>
|
|
7
|
+
* Semantic key-value list inspired by Radix Themes.
|
|
8
|
+
* Renders data pairs with responsive horizontal/vertical orientation and copyable values.
|
|
9
|
+
*/
|
|
10
|
+
export class ElDataList extends Elementum {
|
|
11
|
+
static observedAttributes = ['orientation', 'size'];
|
|
12
|
+
|
|
13
|
+
orientation = signal('horizontal');
|
|
14
|
+
size = signal('md');
|
|
15
|
+
|
|
16
|
+
static styles = css`
|
|
17
|
+
:host {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
gap: 12px;
|
|
21
|
+
width: 100%;
|
|
22
|
+
font-family: inherit;
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:host([size="sm"]) {
|
|
27
|
+
gap: 8px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
:host([size="lg"]) {
|
|
31
|
+
gap: 16px;
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
connected() {
|
|
36
|
+
this.orientation.value = this.getAttribute('orientation') || 'horizontal';
|
|
37
|
+
this.size.value = this.getAttribute('size') || 'md';
|
|
38
|
+
this.#syncChildren();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
attributeChanged(name, oldValue, newValue) {
|
|
42
|
+
if (name === 'orientation') {
|
|
43
|
+
this.orientation.value = newValue || 'horizontal';
|
|
44
|
+
this.#syncChildren();
|
|
45
|
+
}
|
|
46
|
+
if (name === 'size') this.size.value = newValue || 'md';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
#syncChildren() {
|
|
50
|
+
const orient = this.orientation.value || 'horizontal';
|
|
51
|
+
this.querySelectorAll('el-data-list-item').forEach((item) => {
|
|
52
|
+
if (item.getAttribute('orientation') !== orient) {
|
|
53
|
+
item.setAttribute('orientation', orient);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
render() {
|
|
59
|
+
return html`<slot @slotchange=${() => this.#syncChildren()}></slot>`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* <el-data-list-item>
|
|
65
|
+
* An individual key-value row within <el-data-list>.
|
|
66
|
+
*/
|
|
67
|
+
export class ElDataListItem extends Elementum {
|
|
68
|
+
static observedAttributes = ['label', 'value', 'copyable'];
|
|
69
|
+
|
|
70
|
+
label = signal('');
|
|
71
|
+
value = signal('');
|
|
72
|
+
copyable = signal(false);
|
|
73
|
+
copied = signal(false);
|
|
74
|
+
|
|
75
|
+
static styles = css`
|
|
76
|
+
:host {
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: baseline;
|
|
79
|
+
justify-content: space-between;
|
|
80
|
+
gap: 16px;
|
|
81
|
+
font-size: var(--el-text-sm, 0.875rem);
|
|
82
|
+
line-height: 1.5;
|
|
83
|
+
padding: 6px 0;
|
|
84
|
+
border-bottom: 1px solid var(--el-surface-border, #e2e8f0);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
:host(:last-child) {
|
|
88
|
+
border-bottom: none;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
:host([orientation="vertical"]),
|
|
92
|
+
:host-context([orientation="vertical"]) {
|
|
93
|
+
flex-direction: column;
|
|
94
|
+
align-items: flex-start;
|
|
95
|
+
gap: 4px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.label {
|
|
99
|
+
color: var(--el-text-muted, #64748b);
|
|
100
|
+
font-weight: 500;
|
|
101
|
+
flex-shrink: 0;
|
|
102
|
+
min-width: 120px;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
:host-context([data-theme="dark"]) .label {
|
|
106
|
+
color: #94a3b8;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.value-container {
|
|
110
|
+
display: inline-flex;
|
|
111
|
+
align-items: center;
|
|
112
|
+
gap: 8px;
|
|
113
|
+
color: var(--el-text-primary, #0f172a);
|
|
114
|
+
font-weight: 400;
|
|
115
|
+
word-break: break-all;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
:host-context([data-theme="dark"]) .value-container {
|
|
119
|
+
color: #f8fafc;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.copy-btn {
|
|
123
|
+
display: inline-flex;
|
|
124
|
+
align-items: center;
|
|
125
|
+
justify-content: center;
|
|
126
|
+
background: none;
|
|
127
|
+
border: none;
|
|
128
|
+
padding: 2px 6px;
|
|
129
|
+
margin-left: 4px;
|
|
130
|
+
border-radius: var(--el-radius-sm, 4px);
|
|
131
|
+
cursor: pointer;
|
|
132
|
+
color: var(--el-text-muted, #64748b);
|
|
133
|
+
font-size: 0.75rem;
|
|
134
|
+
transition: background-color 0.15s ease, color 0.15s ease;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.copy-btn:hover {
|
|
138
|
+
background-color: var(--el-surface-muted, #f1f5f9);
|
|
139
|
+
color: var(--el-text-primary, #0f172a);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
:host-context([data-theme="dark"]) .copy-btn:hover {
|
|
143
|
+
background-color: #1e293b;
|
|
144
|
+
color: #f8fafc;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.copied-badge {
|
|
148
|
+
color: #10b981;
|
|
149
|
+
font-size: 0.75rem;
|
|
150
|
+
font-weight: 600;
|
|
151
|
+
}
|
|
152
|
+
`;
|
|
153
|
+
|
|
154
|
+
connected() {
|
|
155
|
+
this.label.value = this.getAttribute('label') || '';
|
|
156
|
+
this.value.value = this.getAttribute('value') || '';
|
|
157
|
+
this.copyable.value = this.hasAttribute('copyable');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
attributeChanged(name, oldValue, newValue) {
|
|
161
|
+
if (name === 'label') this.label.value = newValue || '';
|
|
162
|
+
if (name === 'value') this.value.value = newValue || '';
|
|
163
|
+
if (name === 'copyable') this.copyable.value = newValue !== null;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async copyValue() {
|
|
167
|
+
const text = this.value.value || this.textContent.trim();
|
|
168
|
+
if (!text) return;
|
|
169
|
+
try {
|
|
170
|
+
if (typeof navigator !== 'undefined' && navigator.clipboard) {
|
|
171
|
+
await navigator.clipboard.writeText(text);
|
|
172
|
+
}
|
|
173
|
+
this.copied.value = true;
|
|
174
|
+
setTimeout(() => {
|
|
175
|
+
this.copied.value = false;
|
|
176
|
+
}, 2000);
|
|
177
|
+
} catch {
|
|
178
|
+
// Fallback
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
render() {
|
|
183
|
+
return html`
|
|
184
|
+
<div class="label">
|
|
185
|
+
<slot name="label">${() => this.label.value}</slot>
|
|
186
|
+
</div>
|
|
187
|
+
<div class="value-container">
|
|
188
|
+
<slot>${() => this.value.value}</slot>
|
|
189
|
+
${() =>
|
|
190
|
+
this.copyable.value
|
|
191
|
+
? html`
|
|
192
|
+
<button
|
|
193
|
+
type="button"
|
|
194
|
+
class="copy-btn"
|
|
195
|
+
title="Copy to clipboard"
|
|
196
|
+
onclick="${() => this.copyValue()}"
|
|
197
|
+
>
|
|
198
|
+
${() => (this.copied.value ? html`<span class="copied-badge">✓ Copied</span>` : '📋')}
|
|
199
|
+
</button>
|
|
200
|
+
`
|
|
201
|
+
: ''}
|
|
202
|
+
</div>
|
|
203
|
+
`;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (typeof customElements !== 'undefined') {
|
|
208
|
+
if (!customElements.get('el-data-list')) customElements.define('el-data-list', ElDataList);
|
|
209
|
+
if (!customElements.get('el-data-list-item')) customElements.define('el-data-list-item', ElDataListItem);
|
|
210
|
+
}
|