@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,311 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <el-toggle> & <el-toggle-group>
|
|
3
|
+
* Accessible, zero-dependency 2-state pressable buttons and groups inspired by Base UI.
|
|
4
|
+
* Standard for toolbars, text alignment, and multi/single view selections.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Elementum } from '../elementum.js';
|
|
8
|
+
import { html, css } from '../template.js';
|
|
9
|
+
import { signal } from '../signal.js';
|
|
10
|
+
|
|
11
|
+
export class ElToggle extends Elementum {
|
|
12
|
+
static observedAttributes = ['pressed', 'disabled', 'value', 'size', 'variant', 'label'];
|
|
13
|
+
|
|
14
|
+
isPressed = signal(false);
|
|
15
|
+
disabled = signal(false);
|
|
16
|
+
value = signal('');
|
|
17
|
+
size = signal('md');
|
|
18
|
+
variant = signal('default');
|
|
19
|
+
label = signal('');
|
|
20
|
+
|
|
21
|
+
static styles = css`
|
|
22
|
+
:host {
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
font-family: var(--el-font-sans, system-ui, sans-serif);
|
|
25
|
+
box-sizing: border-box;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
button {
|
|
29
|
+
display: inline-flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
gap: 6px;
|
|
33
|
+
font-family: inherit;
|
|
34
|
+
font-weight: 500;
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
border: 1px solid var(--el-surface-border, #e2e8f0);
|
|
37
|
+
background: var(--el-surface-base, #ffffff);
|
|
38
|
+
color: var(--el-text-secondary, #475569);
|
|
39
|
+
border-radius: var(--el-radius-md, 6px);
|
|
40
|
+
transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease, transform 120ms var(--el-ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1));
|
|
41
|
+
user-select: none;
|
|
42
|
+
touch-action: manipulation;
|
|
43
|
+
-webkit-tap-highlight-color: transparent;
|
|
44
|
+
outline: none;
|
|
45
|
+
line-height: 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
button:active:not(:disabled) {
|
|
49
|
+
transform: scale(0.97);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@media (prefers-reduced-motion: reduce) {
|
|
53
|
+
button {
|
|
54
|
+
transition: none;
|
|
55
|
+
}
|
|
56
|
+
button:active:not(:disabled) {
|
|
57
|
+
transform: none;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
:host([size="sm"]) button {
|
|
62
|
+
padding: 6px 10px;
|
|
63
|
+
font-size: 12px;
|
|
64
|
+
height: 30px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
:host([size="md"]) button,
|
|
68
|
+
button {
|
|
69
|
+
padding: 8px 14px;
|
|
70
|
+
font-size: 13px;
|
|
71
|
+
height: 36px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
:host([size="lg"]) button {
|
|
75
|
+
padding: 10px 18px;
|
|
76
|
+
font-size: 14px;
|
|
77
|
+
height: 42px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
button:hover:not(:disabled) {
|
|
81
|
+
background: var(--el-surface-muted, #f1f5f9);
|
|
82
|
+
color: var(--el-text-primary, #0f172a);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
button:focus-visible {
|
|
86
|
+
box-shadow: 0 0 0 2px var(--el-color-primary, #2563eb);
|
|
87
|
+
border-color: var(--el-color-primary, #2563eb);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
button.pressed,
|
|
91
|
+
:host([data-state="on"]) button {
|
|
92
|
+
background: var(--el-color-primary, #2563eb);
|
|
93
|
+
color: #ffffff;
|
|
94
|
+
border-color: var(--el-color-primary, #2563eb);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
button.pressed:hover:not(:disabled),
|
|
98
|
+
:host([data-state="on"]) button:hover:not(:disabled) {
|
|
99
|
+
background: var(--el-color-primary-hover, #1d4ed8);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
button:disabled {
|
|
103
|
+
cursor: not-allowed;
|
|
104
|
+
opacity: 0.5;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
:root[data-theme="dark"] button {
|
|
108
|
+
background: var(--el-surface-elevated, #1e293b);
|
|
109
|
+
border-color: #334155;
|
|
110
|
+
color: #94a3b8;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
:root[data-theme="dark"] button:hover:not(:disabled) {
|
|
114
|
+
background: #334155;
|
|
115
|
+
color: #f8fafc;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
:root[data-theme="dark"] button.pressed {
|
|
119
|
+
background: var(--el-color-primary, #2563eb);
|
|
120
|
+
color: #ffffff;
|
|
121
|
+
border-color: var(--el-color-primary, #2563eb);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* Color Variants (from Figma tokens) */
|
|
125
|
+
:host([variant="primary"]) button.pressed,
|
|
126
|
+
:host(:not([variant])) button.pressed {
|
|
127
|
+
background-color: var(--el-color-primary, #2563eb);
|
|
128
|
+
color: #ffffff;
|
|
129
|
+
}
|
|
130
|
+
:host([variant="primary"]:not([disabled])) button.pressed:not([disabled]):hover,
|
|
131
|
+
:host(:not([variant]):not([disabled])) button.pressed:not([disabled]):hover {
|
|
132
|
+
background-color: var(--el-color-primary-hover, #1d4ed8);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
:host([variant="secondary"]) button.pressed {
|
|
136
|
+
background-color: var(--el-surface-muted, #f3f4f6);
|
|
137
|
+
color: var(--el-text-primary, #0f172a);
|
|
138
|
+
border-color: var(--el-surface-border, #e5e7eb);
|
|
139
|
+
}
|
|
140
|
+
:host([variant="secondary"]:not([disabled])) button.pressed:not([disabled]):hover {
|
|
141
|
+
background-color: var(--el-step-4, var(--el-surface-border, #e2e8f0));
|
|
142
|
+
color: var(--el-text-primary, #0f172a);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
:host([variant="danger"]) button.pressed {
|
|
146
|
+
background-color: var(--el-color-danger, #dc2626);
|
|
147
|
+
color: #ffffff;
|
|
148
|
+
}
|
|
149
|
+
:host([variant="danger"]:not([disabled])) button.pressed:not([disabled]):hover {
|
|
150
|
+
background-color: #b91c1c;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
:host([variant="success"]) button.pressed,
|
|
154
|
+
:host([variant="success"][data-state="on"]) button {
|
|
155
|
+
background-color: var(--el-color-success, #16a34a);
|
|
156
|
+
border-color: var(--el-color-success, #16a34a);
|
|
157
|
+
color: #ffffff;
|
|
158
|
+
}
|
|
159
|
+
:host([variant="success"]:not([disabled])) button.pressed:not([disabled]):hover {
|
|
160
|
+
background-color: #15803d;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
:host([variant="warning"]) button.pressed,
|
|
164
|
+
:host([variant="warning"][data-state="on"]) button {
|
|
165
|
+
background-color: var(--el-color-warning, #d97706);
|
|
166
|
+
border-color: var(--el-color-warning, #d97706);
|
|
167
|
+
color: #ffffff;
|
|
168
|
+
}
|
|
169
|
+
:host([variant="warning"]:not([disabled])) button.pressed:not([disabled]):hover {
|
|
170
|
+
background-color: #b45309;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
:host([variant="info"]) button.pressed,
|
|
174
|
+
:host([variant="info"][data-state="on"]) button {
|
|
175
|
+
background-color: var(--el-color-info, #0284c7);
|
|
176
|
+
border-color: var(--el-color-info, #0284c7);
|
|
177
|
+
color: #ffffff;
|
|
178
|
+
}
|
|
179
|
+
:host([variant="info"]:not([disabled])) button.pressed:not([disabled]):hover {
|
|
180
|
+
background-color: #0369a1;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
:host([variant="outline"]) button {
|
|
184
|
+
background-color: transparent;
|
|
185
|
+
border-color: var(--el-surface-border, #cbd5e1);
|
|
186
|
+
color: var(--el-text-primary, #0f172a);
|
|
187
|
+
}
|
|
188
|
+
:host([variant="outline"]) button.pressed,
|
|
189
|
+
:host([variant="outline"][data-state="on"]) button {
|
|
190
|
+
background-color: rgba(37, 99, 235, 0.08);
|
|
191
|
+
border-color: var(--el-color-primary, #2563eb);
|
|
192
|
+
color: var(--el-color-primary, #2563eb);
|
|
193
|
+
}
|
|
194
|
+
`;
|
|
195
|
+
|
|
196
|
+
connected() {
|
|
197
|
+
this.isPressed.value = this.hasAttribute('pressed');
|
|
198
|
+
this.disabled.value = this.hasAttribute('disabled');
|
|
199
|
+
if (this.hasAttribute('value')) this.value.value = this.getAttribute('value');
|
|
200
|
+
if (this.hasAttribute('size')) this.size.value = this.getAttribute('size');
|
|
201
|
+
if (this.hasAttribute('label')) this.label.value = this.getAttribute('label');
|
|
202
|
+
this.setAttribute('data-state', this.isPressed.value ? 'on' : 'off');
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
attributeChanged(name, oldValue, newValue) {
|
|
206
|
+
if (name === 'pressed') {
|
|
207
|
+
this.isPressed.value = newValue !== null && newValue !== 'false';
|
|
208
|
+
this.setAttribute('data-state', this.isPressed.value ? 'on' : 'off');
|
|
209
|
+
} else if (name === 'disabled') {
|
|
210
|
+
this.disabled.value = newValue !== null && newValue !== 'false';
|
|
211
|
+
} else if (name === 'value') {
|
|
212
|
+
this.value.value = newValue || '';
|
|
213
|
+
} else if (name === 'size') {
|
|
214
|
+
this.size.value = newValue || 'md';
|
|
215
|
+
} else if (name === 'variant') {
|
|
216
|
+
this.variant.value = newValue || 'default';
|
|
217
|
+
} else if (name === 'label') {
|
|
218
|
+
this.label.value = newValue || '';
|
|
219
|
+
}
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
toggle() {
|
|
224
|
+
if (this.disabled.value) return;
|
|
225
|
+
this.isPressed.value = !this.isPressed.value;
|
|
226
|
+
this.setAttribute('data-state', this.isPressed.value ? 'on' : 'off');
|
|
227
|
+
this.emit('toggle', { pressed: this.isPressed.value, value: this.value.value });
|
|
228
|
+
this.emit('change', { pressed: this.isPressed.value, value: this.value.value });
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
render() {
|
|
232
|
+
return html`
|
|
233
|
+
<button
|
|
234
|
+
type="button"
|
|
235
|
+
class=${() => (this.isPressed.value ? 'pressed' : '')}
|
|
236
|
+
aria-pressed=${() => (this.isPressed.value ? 'true' : 'false')}
|
|
237
|
+
disabled=${() => this.disabled.value}
|
|
238
|
+
@click=${() => this.toggle()}
|
|
239
|
+
part="button"
|
|
240
|
+
>
|
|
241
|
+
<slot>${() => this.label.value || ''}</slot>
|
|
242
|
+
</button>
|
|
243
|
+
`;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export class ElToggleGroup extends Elementum {
|
|
248
|
+
static observedAttributes = ['type', 'value', 'disabled'];
|
|
249
|
+
|
|
250
|
+
type = signal('single'); // 'single' | 'multiple'
|
|
251
|
+
value = signal('');
|
|
252
|
+
disabled = signal(false);
|
|
253
|
+
|
|
254
|
+
static styles = css`
|
|
255
|
+
:host {
|
|
256
|
+
display: inline-flex;
|
|
257
|
+
align-items: center;
|
|
258
|
+
gap: 4px;
|
|
259
|
+
padding: 3px;
|
|
260
|
+
background: var(--el-surface-muted, #f1f5f9);
|
|
261
|
+
border-radius: var(--el-radius-md, 8px);
|
|
262
|
+
box-sizing: border-box;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
:root[data-theme="dark"] :host {
|
|
266
|
+
background: #0f172a;
|
|
267
|
+
border: 1px solid #1e293b;
|
|
268
|
+
}
|
|
269
|
+
`;
|
|
270
|
+
|
|
271
|
+
connected() {
|
|
272
|
+
if (this.hasAttribute('type')) this.type.value = this.getAttribute('type');
|
|
273
|
+
if (this.hasAttribute('value')) this.value.value = this.getAttribute('value');
|
|
274
|
+
this.disabled.value = this.hasAttribute('disabled');
|
|
275
|
+
this.setAttribute('role', 'group');
|
|
276
|
+
|
|
277
|
+
this.addEventListener('toggle', (e) => {
|
|
278
|
+
const toggleEl = e.target;
|
|
279
|
+
if (toggleEl.tagName.toLowerCase() !== 'el-toggle') return;
|
|
280
|
+
|
|
281
|
+
const itemVal = toggleEl.getAttribute('value') || '';
|
|
282
|
+
if (this.type.value === 'single') {
|
|
283
|
+
const toggles = this.querySelectorAll('el-toggle');
|
|
284
|
+
toggles.forEach((t) => {
|
|
285
|
+
if (t !== toggleEl) {
|
|
286
|
+
t.removeAttribute('pressed');
|
|
287
|
+
t.isPressed.value = false;
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
this.value.value = toggleEl.isPressed.value ? itemVal : '';
|
|
291
|
+
this.emit('change', { value: this.value.value });
|
|
292
|
+
} else {
|
|
293
|
+
const activeVals = [];
|
|
294
|
+
this.querySelectorAll('el-toggle').forEach((t) => {
|
|
295
|
+
if (t.isPressed.value) activeVals.push(t.getAttribute('value') || '');
|
|
296
|
+
});
|
|
297
|
+
this.value.value = activeVals.join(',');
|
|
298
|
+
this.emit('change', { value: activeVals });
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
render() {
|
|
304
|
+
return html`<slot></slot>`;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (typeof customElements !== 'undefined') {
|
|
309
|
+
if (!customElements.get('el-toggle')) customElements.define('el-toggle', ElToggle);
|
|
310
|
+
if (!customElements.get('el-toggle-group')) customElements.define('el-toggle-group', ElToggleGroup);
|
|
311
|
+
}
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <el-tool-call>
|
|
3
|
+
* Agentic UI component for visualizing AG-UI tool call execution lifecycles
|
|
4
|
+
* (TOOL_CALL_START -> TOOL_CALL_ARGS -> TOOL_CALL_END / TOOL_CALL_RESULT)
|
|
5
|
+
* with collapsible JSON arguments, results, and Human-in-the-Loop (HITL) approval actions.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Elementum } from '../elementum.js';
|
|
9
|
+
import { html, css } from '../template.js';
|
|
10
|
+
import { signal } from '../signal.js';
|
|
11
|
+
import './el-badge.js';
|
|
12
|
+
|
|
13
|
+
const STATUS_BADGES = {
|
|
14
|
+
running: { variant: 'primary', label: 'Running', icon: '⚡' },
|
|
15
|
+
'awaiting-approval': { variant: 'warning', label: 'Awaiting Approval', icon: '🛡️' },
|
|
16
|
+
completed: { variant: 'success', label: 'Completed', icon: '✓' },
|
|
17
|
+
error: { variant: 'danger', label: 'Error', icon: '✕' },
|
|
18
|
+
rejected: { variant: 'danger', label: 'Rejected', icon: '✕' },
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export class ElToolCall extends Elementum {
|
|
22
|
+
static observedAttributes = ['name', 'status', 'args', 'result', 'call-id', 'approval', 'open'];
|
|
23
|
+
|
|
24
|
+
name = signal('tool_call');
|
|
25
|
+
// 'running' | 'awaiting-approval' | 'completed' | 'error' | 'rejected'
|
|
26
|
+
status = signal('running');
|
|
27
|
+
args = signal('');
|
|
28
|
+
result = signal('');
|
|
29
|
+
callId = signal('');
|
|
30
|
+
approval = signal(false);
|
|
31
|
+
open = signal(true);
|
|
32
|
+
|
|
33
|
+
static styles = css`
|
|
34
|
+
:host {
|
|
35
|
+
display: block;
|
|
36
|
+
width: 100%;
|
|
37
|
+
box-sizing: border-box;
|
|
38
|
+
font-family: var(--el-font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.card {
|
|
42
|
+
background: var(--el-surface-card, #ffffff);
|
|
43
|
+
border: 1px solid var(--el-surface-border, #e2e8f0);
|
|
44
|
+
border-radius: var(--el-radius-lg, 12px);
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
box-shadow: var(--el-shadow-subtle, 0 1px 2px rgba(0, 0, 0, 0.05));
|
|
47
|
+
color: var(--el-text-primary, #0f172a);
|
|
48
|
+
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
:host([status="awaiting-approval"]) .card,
|
|
52
|
+
:host([approval]) .card {
|
|
53
|
+
border-color: rgba(245, 158, 11, 0.45);
|
|
54
|
+
box-shadow: 0 4px 14px -4px rgba(245, 158, 11, 0.18);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
:host([status="error"]) .card,
|
|
58
|
+
:host([status="rejected"]) .card {
|
|
59
|
+
border-color: rgba(239, 68, 68, 0.4);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.header-btn {
|
|
63
|
+
width: 100%;
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: space-between;
|
|
67
|
+
gap: 10px;
|
|
68
|
+
padding: 12px 14px;
|
|
69
|
+
background: var(--el-surface-muted, #f8fafc);
|
|
70
|
+
border: none;
|
|
71
|
+
border-bottom: 1px solid transparent;
|
|
72
|
+
color: var(--el-text-primary, #0f172a);
|
|
73
|
+
font-family: inherit;
|
|
74
|
+
font-size: 0.875rem;
|
|
75
|
+
font-weight: 600;
|
|
76
|
+
text-align: left;
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
box-sizing: border-box;
|
|
79
|
+
transition: background-color 0.15s ease;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.header-btn:hover {
|
|
83
|
+
background: var(--el-step-4, var(--el-surface-border, #e2e8f0));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.header-btn[aria-expanded="true"] {
|
|
87
|
+
border-bottom-color: var(--el-surface-border, #e2e8f0);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.header-btn:focus-visible {
|
|
91
|
+
outline: 2px solid var(--el-color-primary, #2563eb);
|
|
92
|
+
outline-offset: -2px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.header-left {
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
gap: 8px;
|
|
99
|
+
min-width: 0;
|
|
100
|
+
flex: 1 1 auto;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.status-icon {
|
|
104
|
+
display: inline-flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
justify-content: center;
|
|
107
|
+
width: 22px;
|
|
108
|
+
height: 22px;
|
|
109
|
+
border-radius: 6px;
|
|
110
|
+
background: rgba(37, 99, 235, 0.12);
|
|
111
|
+
font-size: 0.78rem;
|
|
112
|
+
flex-shrink: 0;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
:host([status="running"]) .status-icon {
|
|
116
|
+
animation: el-tool-pulse 1.4s ease-in-out infinite;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@keyframes el-tool-pulse {
|
|
120
|
+
0%, 100% { transform: scale(1); opacity: 1; }
|
|
121
|
+
50% { transform: scale(1.08); opacity: 0.65; }
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.tool-name {
|
|
125
|
+
font-family: var(--el-font-mono, ui-monospace, monospace);
|
|
126
|
+
font-size: 0.84rem;
|
|
127
|
+
font-weight: 700;
|
|
128
|
+
color: var(--el-text-primary, #0f172a);
|
|
129
|
+
white-space: nowrap;
|
|
130
|
+
overflow: hidden;
|
|
131
|
+
text-overflow: ellipsis;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.call-id {
|
|
135
|
+
font-family: var(--el-font-mono, ui-monospace, monospace);
|
|
136
|
+
font-size: 0.72rem;
|
|
137
|
+
color: var(--el-text-muted, #64748b);
|
|
138
|
+
white-space: nowrap;
|
|
139
|
+
flex-shrink: 0;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.header-right {
|
|
143
|
+
display: flex;
|
|
144
|
+
align-items: center;
|
|
145
|
+
gap: 8px;
|
|
146
|
+
flex-shrink: 0;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.chevron {
|
|
150
|
+
font-size: 0.72rem;
|
|
151
|
+
color: var(--el-text-muted, #64748b);
|
|
152
|
+
transition: transform 0.2s ease;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.header-btn[aria-expanded="true"] .chevron {
|
|
156
|
+
transform: rotate(180deg);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.tool-body {
|
|
160
|
+
display: none;
|
|
161
|
+
flex-direction: column;
|
|
162
|
+
gap: 12px;
|
|
163
|
+
padding: 14px;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.tool-body.open {
|
|
167
|
+
display: flex;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.section-label {
|
|
171
|
+
font-size: 0.7rem;
|
|
172
|
+
font-weight: 700;
|
|
173
|
+
text-transform: uppercase;
|
|
174
|
+
letter-spacing: 0.06em;
|
|
175
|
+
color: var(--el-text-muted, #64748b);
|
|
176
|
+
margin-bottom: 5px;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.payload-box {
|
|
180
|
+
margin: 0;
|
|
181
|
+
padding: 10px 12px;
|
|
182
|
+
border-radius: var(--el-radius-md, 8px);
|
|
183
|
+
background: #0f172a;
|
|
184
|
+
color: #e2e8f0;
|
|
185
|
+
border: 1px solid #1e293b;
|
|
186
|
+
font-family: var(--el-font-mono, ui-monospace, monospace);
|
|
187
|
+
font-size: 0.78rem;
|
|
188
|
+
line-height: 1.5;
|
|
189
|
+
overflow-x: auto;
|
|
190
|
+
white-space: pre-wrap;
|
|
191
|
+
word-break: break-word;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.result-box {
|
|
195
|
+
border-left: 3px solid var(--el-color-success, #16a34a);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.hitl-footer {
|
|
199
|
+
display: flex;
|
|
200
|
+
align-items: center;
|
|
201
|
+
justify-content: space-between;
|
|
202
|
+
flex-wrap: wrap;
|
|
203
|
+
gap: 10px;
|
|
204
|
+
padding: 10px 12px;
|
|
205
|
+
border-radius: var(--el-radius-md, 8px);
|
|
206
|
+
background: rgba(245, 158, 11, 0.09);
|
|
207
|
+
border: 1px solid rgba(245, 158, 11, 0.25);
|
|
208
|
+
font-size: 0.8125rem;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.hitl-prompt {
|
|
212
|
+
font-weight: 600;
|
|
213
|
+
color: var(--el-text-primary, #0f172a);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.hitl-actions {
|
|
217
|
+
display: flex;
|
|
218
|
+
align-items: center;
|
|
219
|
+
gap: 8px;
|
|
220
|
+
flex-wrap: wrap;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.hitl-btn {
|
|
224
|
+
padding: 6px 12px;
|
|
225
|
+
border-radius: 6px;
|
|
226
|
+
font-family: inherit;
|
|
227
|
+
font-size: 0.78rem;
|
|
228
|
+
font-weight: 600;
|
|
229
|
+
cursor: pointer;
|
|
230
|
+
border: 1px solid transparent;
|
|
231
|
+
transition: background-color 0.15s ease, transform 0.1s ease;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.approve-btn {
|
|
235
|
+
background: var(--el-color-success, #16a34a);
|
|
236
|
+
color: #ffffff;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.approve-btn:hover {
|
|
240
|
+
background: #15803d;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.reject-btn {
|
|
244
|
+
background: var(--el-surface-card, #ffffff);
|
|
245
|
+
color: var(--el-color-danger, #dc2626);
|
|
246
|
+
border-color: rgba(220, 38, 38, 0.35);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.reject-btn:hover {
|
|
250
|
+
background: rgba(220, 38, 38, 0.1);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
@media (prefers-reduced-motion: reduce) {
|
|
254
|
+
*, *::before, *::after {
|
|
255
|
+
animation: none !important;
|
|
256
|
+
transition: none !important;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
`;
|
|
260
|
+
|
|
261
|
+
#statusInfo() {
|
|
262
|
+
const key = String(this.status.value || 'running').toLowerCase();
|
|
263
|
+
return STATUS_BADGES[key] || STATUS_BADGES.running;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
#formatPayload(raw) {
|
|
267
|
+
if (raw === null || raw === undefined || raw === '') return '';
|
|
268
|
+
if (typeof raw === 'object') return JSON.stringify(raw, null, 2);
|
|
269
|
+
const trimmed = String(raw).trim();
|
|
270
|
+
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
|
|
271
|
+
try {
|
|
272
|
+
return JSON.stringify(JSON.parse(trimmed), null, 2);
|
|
273
|
+
} catch {
|
|
274
|
+
return trimmed;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return trimmed;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
toggleOpen() {
|
|
281
|
+
this.open.value = !this.open.value;
|
|
282
|
+
this.emit('toggle', { open: this.open.value });
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
approveTool(e) {
|
|
286
|
+
if (e) e.stopPropagation();
|
|
287
|
+
this.status.value = 'completed';
|
|
288
|
+
this.approval.value = false;
|
|
289
|
+
this.emit('approve', {
|
|
290
|
+
callId: this.callId.value,
|
|
291
|
+
name: this.name.value,
|
|
292
|
+
args: this.args.value,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
rejectTool(e) {
|
|
297
|
+
if (e) e.stopPropagation();
|
|
298
|
+
this.status.value = 'rejected';
|
|
299
|
+
this.approval.value = false;
|
|
300
|
+
this.emit('reject', {
|
|
301
|
+
callId: this.callId.value,
|
|
302
|
+
name: this.name.value,
|
|
303
|
+
args: this.args.value,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
render() {
|
|
308
|
+
return html`
|
|
309
|
+
<div class="card" part="container">
|
|
310
|
+
<button
|
|
311
|
+
type="button"
|
|
312
|
+
class="header-btn"
|
|
313
|
+
part="header"
|
|
314
|
+
aria-expanded=${() => (this.open.value ? 'true' : 'false')}
|
|
315
|
+
onclick=${() => this.toggleOpen()}
|
|
316
|
+
>
|
|
317
|
+
<span class="header-left">
|
|
318
|
+
<span class="status-icon" part="icon" aria-hidden="true">${() => this.#statusInfo().icon}</span>
|
|
319
|
+
<span class="tool-name" part="name">${() => this.name.value || 'tool_call'}</span>
|
|
320
|
+
${() => (this.callId.value ? html`<span class="call-id">#${() => this.callId.value}</span>` : '')}
|
|
321
|
+
</span>
|
|
322
|
+
<span class="header-right">
|
|
323
|
+
<el-badge
|
|
324
|
+
part="badge"
|
|
325
|
+
size="sm"
|
|
326
|
+
variant=${() => this.#statusInfo().variant}
|
|
327
|
+
count=${() => this.#statusInfo().label}
|
|
328
|
+
></el-badge>
|
|
329
|
+
<span class="chevron" aria-hidden="true">▾</span>
|
|
330
|
+
</span>
|
|
331
|
+
</button>
|
|
332
|
+
|
|
333
|
+
<div class=${() => (this.open.value ? 'tool-body open' : 'tool-body')} part="body">
|
|
334
|
+
<div>
|
|
335
|
+
<div class="section-label">Arguments</div>
|
|
336
|
+
<pre class="payload-box" part="args"><code>${() => this.#formatPayload(this.args.value) || '{}'}</code></pre>
|
|
337
|
+
</div>
|
|
338
|
+
|
|
339
|
+
${() =>
|
|
340
|
+
this.result.value
|
|
341
|
+
? html`
|
|
342
|
+
<div>
|
|
343
|
+
<div class="section-label">Result</div>
|
|
344
|
+
<pre class="payload-box result-box" part="result"><code>${() => this.#formatPayload(this.result.value)}</code></pre>
|
|
345
|
+
</div>
|
|
346
|
+
`
|
|
347
|
+
: ''}
|
|
348
|
+
|
|
349
|
+
<slot></slot>
|
|
350
|
+
|
|
351
|
+
${() =>
|
|
352
|
+
this.approval.value || this.status.value === 'awaiting-approval'
|
|
353
|
+
? html`
|
|
354
|
+
<div class="hitl-footer" part="approval">
|
|
355
|
+
<span class="hitl-prompt">Human-in-the-Loop approval required</span>
|
|
356
|
+
<div class="hitl-actions">
|
|
357
|
+
<button
|
|
358
|
+
type="button"
|
|
359
|
+
class="hitl-btn reject-btn"
|
|
360
|
+
part="reject-button"
|
|
361
|
+
onclick=${(e) => this.rejectTool(e)}
|
|
362
|
+
>
|
|
363
|
+
Reject
|
|
364
|
+
</button>
|
|
365
|
+
<button
|
|
366
|
+
type="button"
|
|
367
|
+
class="hitl-btn approve-btn"
|
|
368
|
+
part="approve-button"
|
|
369
|
+
onclick=${(e) => this.approveTool(e)}
|
|
370
|
+
>
|
|
371
|
+
Approve Execution
|
|
372
|
+
</button>
|
|
373
|
+
<slot name="actions"></slot>
|
|
374
|
+
</div>
|
|
375
|
+
</div>
|
|
376
|
+
`
|
|
377
|
+
: ''}
|
|
378
|
+
</div>
|
|
379
|
+
</div>
|
|
380
|
+
`;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
if (typeof customElements !== 'undefined' && !customElements.get('el-tool-call')) {
|
|
385
|
+
customElements.define('el-tool-call', ElToolCall);
|
|
386
|
+
}
|