@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,441 @@
|
|
|
1
|
+
import { Elementum } from '../elementum.js';
|
|
2
|
+
import { html, css } from '../template.js';
|
|
3
|
+
import { signal, computed } from '../signal.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Computes a clean LCS-based line diff between two strings (zero dependencies).
|
|
7
|
+
* @param {string} beforeText
|
|
8
|
+
* @param {string} afterText
|
|
9
|
+
* @returns {Array<{ type: 'same' | 'add' | 'remove', text: string, oldLine: number | null, newLine: number | null }>}
|
|
10
|
+
*/
|
|
11
|
+
export function computeLineDiff(beforeText = '', afterText = '') {
|
|
12
|
+
const a = beforeText === '' ? [] : String(beforeText).split(/\r?\n/);
|
|
13
|
+
const b = afterText === '' ? [] : String(afterText).split(/\r?\n/);
|
|
14
|
+
const m = a.length;
|
|
15
|
+
const n = b.length;
|
|
16
|
+
|
|
17
|
+
// Build LCS table
|
|
18
|
+
const dp = Array.from({ length: m + 1 }, () => new Int32Array(n + 1));
|
|
19
|
+
for (let i = m - 1; i >= 0; i--) {
|
|
20
|
+
for (let j = n - 1; j >= 0; j--) {
|
|
21
|
+
if (a[i] === b[j]) dp[i][j] = dp[i + 1][j + 1] + 1;
|
|
22
|
+
else dp[i][j] = Math.max(dp[i + 1][j], dp[i][j + 1]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const rows = [];
|
|
27
|
+
let i = 0;
|
|
28
|
+
let j = 0;
|
|
29
|
+
while (i < m && j < n) {
|
|
30
|
+
if (a[i] === b[j]) {
|
|
31
|
+
rows.push({ type: 'same', text: a[i], oldLine: i + 1, newLine: j + 1 });
|
|
32
|
+
i++;
|
|
33
|
+
j++;
|
|
34
|
+
} else if (dp[i + 1][j] >= dp[i][j + 1]) {
|
|
35
|
+
rows.push({ type: 'remove', text: a[i], oldLine: i + 1, newLine: null });
|
|
36
|
+
i++;
|
|
37
|
+
} else {
|
|
38
|
+
rows.push({ type: 'add', text: b[j], oldLine: null, newLine: j + 1 });
|
|
39
|
+
j++;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
while (i < m) {
|
|
43
|
+
rows.push({ type: 'remove', text: a[i], oldLine: i + 1, newLine: null });
|
|
44
|
+
i++;
|
|
45
|
+
}
|
|
46
|
+
while (j < n) {
|
|
47
|
+
rows.push({ type: 'add', text: b[j], oldLine: null, newLine: j + 1 });
|
|
48
|
+
j++;
|
|
49
|
+
}
|
|
50
|
+
return rows;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* <el-diff-viewer>
|
|
55
|
+
* AI-native code and config diff viewer with unified/split modes and optional HITL approval actions.
|
|
56
|
+
*
|
|
57
|
+
* @element el-diff-viewer
|
|
58
|
+
* @attr {string} filename - File path or resource label
|
|
59
|
+
* @attr {string} before - Original text content
|
|
60
|
+
* @attr {string} after - Proposed text content
|
|
61
|
+
* @attr {'unified' | 'split'} mode - View mode (default: 'unified')
|
|
62
|
+
* @attr {boolean} approval - Show Accept / Reject HITL patch controls
|
|
63
|
+
* @fires accept - Fired when user accepts the proposed diff
|
|
64
|
+
* @fires reject - Fired when user rejects the proposed diff
|
|
65
|
+
*/
|
|
66
|
+
export class ElDiffViewer extends Elementum {
|
|
67
|
+
static observedAttributes = ['filename', 'before', 'after', 'mode', 'approval'];
|
|
68
|
+
|
|
69
|
+
filename = signal('changes.js');
|
|
70
|
+
before = signal('');
|
|
71
|
+
after = signal('');
|
|
72
|
+
mode = signal('unified');
|
|
73
|
+
approval = signal(false);
|
|
74
|
+
|
|
75
|
+
diffRows = computed(() => computeLineDiff(this.before.value, this.after.value));
|
|
76
|
+
stats = computed(() => {
|
|
77
|
+
let added = 0;
|
|
78
|
+
let removed = 0;
|
|
79
|
+
for (const r of this.diffRows.value) {
|
|
80
|
+
if (r.type === 'add') added++;
|
|
81
|
+
else if (r.type === 'remove') removed++;
|
|
82
|
+
}
|
|
83
|
+
return { added, removed };
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
connected() {
|
|
87
|
+
this.#sync();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
attributeChanged() {
|
|
91
|
+
this.#sync();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
#sync() {
|
|
95
|
+
if (this.hasAttribute('filename')) this.filename.value = this.getAttribute('filename') || 'changes.js';
|
|
96
|
+
if (this.hasAttribute('before')) this.before.value = this.getAttribute('before') || '';
|
|
97
|
+
if (this.hasAttribute('after')) this.after.value = this.getAttribute('after') || '';
|
|
98
|
+
const m = this.getAttribute('mode');
|
|
99
|
+
if (m === 'split' || m === 'unified') this.mode.value = m;
|
|
100
|
+
this.approval.value = this.hasAttribute('approval') && this.getAttribute('approval') !== 'false';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
setMode(nextMode) {
|
|
104
|
+
if (nextMode !== 'unified' && nextMode !== 'split') return;
|
|
105
|
+
this.mode.value = nextMode;
|
|
106
|
+
this.setAttribute('mode', nextMode);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
#onAccept = () => {
|
|
110
|
+
this.emit('accept', {
|
|
111
|
+
filename: this.filename.value,
|
|
112
|
+
before: this.before.value,
|
|
113
|
+
after: this.after.value,
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
#onReject = () => {
|
|
118
|
+
this.emit('reject', {
|
|
119
|
+
filename: this.filename.value,
|
|
120
|
+
before: this.before.value,
|
|
121
|
+
after: this.after.value,
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
static styles = css`
|
|
126
|
+
:host {
|
|
127
|
+
display: block;
|
|
128
|
+
font-family: var(--el-font-sans, system-ui, -apple-system, sans-serif);
|
|
129
|
+
box-sizing: border-box;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.diff-shell {
|
|
133
|
+
border: 1px solid var(--el-surface-border, #e2e8f0);
|
|
134
|
+
border-radius: var(--el-radius-md, 10px);
|
|
135
|
+
background: var(--el-surface-base, #ffffff);
|
|
136
|
+
overflow: hidden;
|
|
137
|
+
box-shadow: var(--el-shadow-subtle, 0 1px 2px rgba(0, 0, 0, 0.04));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.diff-header {
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
justify-content: space-between;
|
|
144
|
+
flex-wrap: wrap;
|
|
145
|
+
gap: 10px;
|
|
146
|
+
padding: 10px 14px;
|
|
147
|
+
background: var(--el-surface-muted, #f8fafc);
|
|
148
|
+
border-bottom: 1px solid var(--el-surface-border, #e2e8f0);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.file-meta {
|
|
152
|
+
display: flex;
|
|
153
|
+
align-items: center;
|
|
154
|
+
gap: 10px;
|
|
155
|
+
min-width: 0;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.filename {
|
|
159
|
+
font-family: var(--el-font-mono, ui-monospace, monospace);
|
|
160
|
+
font-size: 0.82rem;
|
|
161
|
+
font-weight: 600;
|
|
162
|
+
color: var(--el-text-primary, #0f172a);
|
|
163
|
+
overflow: hidden;
|
|
164
|
+
text-overflow: ellipsis;
|
|
165
|
+
white-space: nowrap;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.stats {
|
|
169
|
+
display: inline-flex;
|
|
170
|
+
gap: 6px;
|
|
171
|
+
font-family: var(--el-font-mono, ui-monospace, monospace);
|
|
172
|
+
font-size: 0.75rem;
|
|
173
|
+
font-weight: 700;
|
|
174
|
+
font-variant-numeric: tabular-nums;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.stat-add {
|
|
178
|
+
color: #047857;
|
|
179
|
+
background: #d1fae5;
|
|
180
|
+
padding: 2px 6px;
|
|
181
|
+
border-radius: 9999px;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.stat-del {
|
|
185
|
+
color: #b91c1c;
|
|
186
|
+
background: #fee2e2;
|
|
187
|
+
padding: 2px 6px;
|
|
188
|
+
border-radius: 9999px;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.mode-switch {
|
|
192
|
+
display: inline-flex;
|
|
193
|
+
gap: 4px;
|
|
194
|
+
background: var(--el-surface-base, #ffffff);
|
|
195
|
+
border: 1px solid var(--el-surface-border, #e2e8f0);
|
|
196
|
+
border-radius: 7px;
|
|
197
|
+
padding: 2px;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.mode-btn,
|
|
201
|
+
.action-btn {
|
|
202
|
+
font-family: inherit;
|
|
203
|
+
font-size: 0.75rem;
|
|
204
|
+
font-weight: 600;
|
|
205
|
+
border-radius: 6px;
|
|
206
|
+
cursor: pointer;
|
|
207
|
+
touch-action: manipulation;
|
|
208
|
+
-webkit-tap-highlight-color: transparent;
|
|
209
|
+
transition: background-color 140ms ease, color 140ms ease, transform 120ms var(--el-ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.mode-btn {
|
|
213
|
+
border: none;
|
|
214
|
+
background: transparent;
|
|
215
|
+
color: var(--el-text-secondary, #475569);
|
|
216
|
+
padding: 4px 10px;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.mode-btn.active {
|
|
220
|
+
background: var(--el-color-primary, #2563eb);
|
|
221
|
+
color: #ffffff;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.mode-btn:active,
|
|
225
|
+
.action-btn:active {
|
|
226
|
+
transform: scale(0.97);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.diff-body {
|
|
230
|
+
overflow-x: auto;
|
|
231
|
+
font-family: var(--el-font-mono, ui-monospace, monospace);
|
|
232
|
+
font-size: 0.8rem;
|
|
233
|
+
line-height: 1.55;
|
|
234
|
+
font-variant-numeric: tabular-nums;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.row {
|
|
238
|
+
display: grid;
|
|
239
|
+
grid-template-columns: 44px 44px 20px 1fr;
|
|
240
|
+
padding: 1px 10px 1px 0;
|
|
241
|
+
white-space: pre;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.row.add {
|
|
245
|
+
background: rgba(16, 185, 129, 0.12);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.row.remove {
|
|
249
|
+
background: rgba(239, 68, 68, 0.12);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.ln {
|
|
253
|
+
text-align: right;
|
|
254
|
+
padding: 0 8px;
|
|
255
|
+
color: var(--el-text-muted, #94a3b8);
|
|
256
|
+
user-select: none;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.sigil {
|
|
260
|
+
text-align: center;
|
|
261
|
+
font-weight: 700;
|
|
262
|
+
user-select: none;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.row.add .sigil { color: #059669; }
|
|
266
|
+
.row.remove .sigil { color: #dc2626; }
|
|
267
|
+
|
|
268
|
+
.code-cell {
|
|
269
|
+
color: var(--el-text-primary, #0f172a);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.split-grid {
|
|
273
|
+
display: grid;
|
|
274
|
+
grid-template-columns: 1fr 1fr;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.split-col {
|
|
278
|
+
min-width: 0;
|
|
279
|
+
overflow-x: auto;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.split-col:first-child {
|
|
283
|
+
border-right: 1px solid var(--el-surface-border, #e2e8f0);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.split-row {
|
|
287
|
+
display: grid;
|
|
288
|
+
grid-template-columns: 40px 1fr;
|
|
289
|
+
padding: 1px 10px 1px 0;
|
|
290
|
+
white-space: pre;
|
|
291
|
+
min-height: 1.55em;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.split-row.remove { background: rgba(239, 68, 68, 0.12); }
|
|
295
|
+
.split-row.add { background: rgba(16, 185, 129, 0.12); }
|
|
296
|
+
|
|
297
|
+
.diff-footer {
|
|
298
|
+
display: flex;
|
|
299
|
+
justify-content: flex-end;
|
|
300
|
+
gap: 8px;
|
|
301
|
+
padding: 10px 14px;
|
|
302
|
+
border-top: 1px solid var(--el-surface-border, #e2e8f0);
|
|
303
|
+
background: var(--el-surface-muted, #f8fafc);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.action-btn {
|
|
307
|
+
padding: 6px 12px;
|
|
308
|
+
border: 1px solid transparent;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.btn-accept {
|
|
312
|
+
background: var(--el-color-success, #10b981);
|
|
313
|
+
color: #ffffff;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.btn-reject {
|
|
317
|
+
background: var(--el-surface-base, #ffffff);
|
|
318
|
+
color: var(--el-color-danger, #dc2626);
|
|
319
|
+
border-color: rgba(220, 38, 38, 0.35);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
:root[data-theme="dark"] .diff-shell {
|
|
323
|
+
background: #0f172a;
|
|
324
|
+
border-color: #334155;
|
|
325
|
+
}
|
|
326
|
+
:root[data-theme="dark"] .diff-header,
|
|
327
|
+
:root[data-theme="dark"] .diff-footer {
|
|
328
|
+
background: #1e293b;
|
|
329
|
+
border-color: #334155;
|
|
330
|
+
}
|
|
331
|
+
:root[data-theme="dark"] .filename,
|
|
332
|
+
:root[data-theme="dark"] .code-cell {
|
|
333
|
+
color: #f8fafc;
|
|
334
|
+
}
|
|
335
|
+
:root[data-theme="dark"] .mode-switch {
|
|
336
|
+
background: #0f172a;
|
|
337
|
+
border-color: #334155;
|
|
338
|
+
}
|
|
339
|
+
:root[data-theme="dark"] .stat-add {
|
|
340
|
+
background: rgba(16, 185, 129, 0.2);
|
|
341
|
+
color: #6ee7b7;
|
|
342
|
+
}
|
|
343
|
+
:root[data-theme="dark"] .stat-del {
|
|
344
|
+
background: rgba(239, 68, 68, 0.2);
|
|
345
|
+
color: #fca5a5;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
@media (prefers-reduced-motion: reduce) {
|
|
349
|
+
.mode-btn, .action-btn { transition: none; }
|
|
350
|
+
.mode-btn:active, .action-btn:active { transform: none; }
|
|
351
|
+
}
|
|
352
|
+
`;
|
|
353
|
+
|
|
354
|
+
render() {
|
|
355
|
+
return html`
|
|
356
|
+
<div class="diff-shell" part="container">
|
|
357
|
+
<div class="diff-header" part="header">
|
|
358
|
+
<div class="file-meta">
|
|
359
|
+
<span class="filename">${this.filename}</span>
|
|
360
|
+
<span class="stats">
|
|
361
|
+
<span class="stat-add">+${() => this.stats.value.added}</span>
|
|
362
|
+
<span class="stat-del">-${() => this.stats.value.removed}</span>
|
|
363
|
+
</span>
|
|
364
|
+
</div>
|
|
365
|
+
<div class="mode-switch" role="group" aria-label="Diff view mode">
|
|
366
|
+
<button
|
|
367
|
+
type="button"
|
|
368
|
+
class=${() => `mode-btn ${this.mode.value === 'unified' ? 'active' : ''}`}
|
|
369
|
+
@click=${() => this.setMode('unified')}
|
|
370
|
+
>Unified</button>
|
|
371
|
+
<button
|
|
372
|
+
type="button"
|
|
373
|
+
class=${() => `mode-btn ${this.mode.value === 'split' ? 'active' : ''}`}
|
|
374
|
+
@click=${() => this.setMode('split')}
|
|
375
|
+
>Split</button>
|
|
376
|
+
</div>
|
|
377
|
+
</div>
|
|
378
|
+
|
|
379
|
+
<div class="diff-body" part="body">
|
|
380
|
+
${() => {
|
|
381
|
+
const rows = this.diffRows.value;
|
|
382
|
+
if (this.mode.value === 'split') {
|
|
383
|
+
const leftRows = rows.filter((r) => r.type !== 'add');
|
|
384
|
+
const rightRows = rows.filter((r) => r.type !== 'remove');
|
|
385
|
+
return html`
|
|
386
|
+
<div class="split-grid">
|
|
387
|
+
<div class="split-col">
|
|
388
|
+
${leftRows.map(
|
|
389
|
+
(r) => html`
|
|
390
|
+
<div class=${`split-row ${r.type}`}>
|
|
391
|
+
<span class="ln">${r.oldLine ?? ''}</span>
|
|
392
|
+
<span class="code-cell">${r.text}</span>
|
|
393
|
+
</div>
|
|
394
|
+
`
|
|
395
|
+
)}
|
|
396
|
+
</div>
|
|
397
|
+
<div class="split-col">
|
|
398
|
+
${rightRows.map(
|
|
399
|
+
(r) => html`
|
|
400
|
+
<div class=${`split-row ${r.type}`}>
|
|
401
|
+
<span class="ln">${r.newLine ?? ''}</span>
|
|
402
|
+
<span class="code-cell">${r.text}</span>
|
|
403
|
+
</div>
|
|
404
|
+
`
|
|
405
|
+
)}
|
|
406
|
+
</div>
|
|
407
|
+
</div>
|
|
408
|
+
`;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
return rows.map((r) => {
|
|
412
|
+
const sigil = r.type === 'add' ? '+' : r.type === 'remove' ? '-' : ' ';
|
|
413
|
+
return html`
|
|
414
|
+
<div class=${`row ${r.type}`}>
|
|
415
|
+
<span class="ln">${r.oldLine ?? ''}</span>
|
|
416
|
+
<span class="ln">${r.newLine ?? ''}</span>
|
|
417
|
+
<span class="sigil">${sigil}</span>
|
|
418
|
+
<span class="code-cell">${r.text}</span>
|
|
419
|
+
</div>
|
|
420
|
+
`;
|
|
421
|
+
});
|
|
422
|
+
}}
|
|
423
|
+
</div>
|
|
424
|
+
|
|
425
|
+
${() =>
|
|
426
|
+
this.approval.value
|
|
427
|
+
? html`
|
|
428
|
+
<div class="diff-footer" part="footer">
|
|
429
|
+
<button type="button" class="action-btn btn-reject" @click=${this.#onReject}>Reject</button>
|
|
430
|
+
<button type="button" class="action-btn btn-accept" @click=${this.#onAccept}>Accept Patch</button>
|
|
431
|
+
</div>
|
|
432
|
+
`
|
|
433
|
+
: ''}
|
|
434
|
+
</div>
|
|
435
|
+
`;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
if (typeof customElements !== 'undefined' && !customElements.get('el-diff-viewer')) {
|
|
440
|
+
customElements.define('el-diff-viewer', ElDiffViewer);
|
|
441
|
+
}
|