stitchkit-tui 0.3.0 → 0.4.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/README.md +61 -16
- package/dist/{app-mqzzrp1t.js → app-2zw4ra7n.js} +36 -16
- package/dist/build/index.d.ts +42 -0
- package/dist/build/index.d.ts.map +1 -0
- package/dist/build/index.js +174 -0
- package/dist/cli.js +1 -1
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/core/index.js +27 -25
- package/dist/core/labels.d.ts +4 -0
- package/dist/core/labels.d.ts.map +1 -1
- package/dist/core/table.d.ts +18 -1
- package/dist/core/table.d.ts.map +1 -1
- package/dist/gallery/main.js +1 -1
- package/dist/gallery/monitor-page.d.ts.map +1 -1
- package/dist/{index-kz62sdr9.js → index-1qacnvfd.js} +1 -1
- package/dist/index-51qwgt9f.js +172 -0
- package/dist/index-ahfc59de.js +495 -0
- package/dist/{index-z4c2ehg4.js → index-djrp2fey.js} +107 -583
- package/dist/index-m0dhvt6x.js +160 -0
- package/dist/{index-fxx9ktw7.js → index-p6nn7fsx.js} +35 -39
- package/dist/{index-251fexwh.js → index-qhj2ne64.js} +1 -1
- package/dist/{index-54sqbm3r.js → index-wcbe2tnk.js} +168 -285
- package/dist/index.js +7 -4
- package/dist/{run-e1kdpzna.js → run-zchyzhwy.js} +7 -4
- package/dist/run.d.ts.map +1 -1
- package/dist/testing/index.d.ts +50 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +110 -0
- package/dist/widgets/app.d.ts +77 -0
- package/dist/widgets/app.d.ts.map +1 -0
- package/dist/widgets/form.d.ts.map +1 -1
- package/dist/widgets/index.d.ts +1 -0
- package/dist/widgets/index.d.ts.map +1 -1
- package/dist/widgets/index.js +20 -7
- package/dist/widgets/table.d.ts.map +1 -1
- package/dist/widgets/theme.d.ts +7 -1
- package/dist/widgets/theme.d.ts.map +1 -1
- package/package.json +12 -4
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
terminalHighlightRuns2,
|
|
4
|
-
terminalPalettes2,
|
|
5
|
-
resolveTerminalPalette2,
|
|
6
|
-
sampleTerminalTimeSeries2,
|
|
7
|
-
terminalSparkline2,
|
|
8
|
-
terminalBrailleChart2,
|
|
9
|
-
terminalTimeAxis2,
|
|
10
3
|
sanitizeTerminalText2,
|
|
11
4
|
terminalTextWidth2,
|
|
12
5
|
truncateTerminalText2,
|
|
13
6
|
fitTerminalText2,
|
|
14
7
|
wrapTerminalText2,
|
|
15
|
-
terminalTextEdit2
|
|
8
|
+
terminalTextEdit2
|
|
9
|
+
} from "./index-ahfc59de.js";
|
|
10
|
+
import {
|
|
11
|
+
terminalHighlightRuns2,
|
|
12
|
+
sampleTerminalTimeSeries2,
|
|
13
|
+
terminalSparkline2,
|
|
14
|
+
terminalBrailleChart2,
|
|
15
|
+
terminalTimeAxis2,
|
|
16
16
|
terminalJsonLines2,
|
|
17
17
|
layoutTerminalDetails2,
|
|
18
18
|
defineTerminalKeymap2,
|
|
19
19
|
matchTerminalKey2,
|
|
20
20
|
fitTerminalKeyHints2,
|
|
21
|
-
terminalLabelsEn2,
|
|
22
21
|
terminalTableKeymap2,
|
|
23
22
|
terminalTableKey2,
|
|
24
23
|
terminalTabsKeymap2,
|
|
@@ -36,52 +35,18 @@ import {
|
|
|
36
35
|
visibleTerminalTableRows2,
|
|
37
36
|
layoutTerminalTableColumns2,
|
|
38
37
|
terminalTableTreePrefix2
|
|
39
|
-
} from "./index-
|
|
40
|
-
|
|
41
|
-
// src/widgets/theme.tsx
|
|
42
|
-
import { useRenderer } from "@opentui/react";
|
|
38
|
+
} from "./index-djrp2fey.js";
|
|
43
39
|
import {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
var PaletteContext = createContext(terminalPalettes2.dark);
|
|
52
|
-
function useTerminalPalette2() {
|
|
53
|
-
return useContext(PaletteContext);
|
|
54
|
-
}
|
|
55
|
-
function useTerminalThemeMode2(mode) {
|
|
56
|
-
const renderer = useRenderer();
|
|
57
|
-
const [reported, setReported] = useState(renderer.themeMode);
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
if (mode !== "auto")
|
|
60
|
-
return;
|
|
61
|
-
const update = (next) => setReported(next);
|
|
62
|
-
renderer.on("theme_mode", update);
|
|
63
|
-
setReported(renderer.themeMode);
|
|
64
|
-
return () => {
|
|
65
|
-
renderer.off("theme_mode", update);
|
|
66
|
-
};
|
|
67
|
-
}, [mode, renderer]);
|
|
68
|
-
return mode === "auto" ? reported ?? "dark" : mode;
|
|
69
|
-
}
|
|
70
|
-
function TerminalThemeProvider2({
|
|
71
|
-
mode = "auto",
|
|
72
|
-
palette,
|
|
73
|
-
children
|
|
74
|
-
}) {
|
|
75
|
-
const resolved = useTerminalThemeMode2(mode);
|
|
76
|
-
const value = useMemo(() => resolveTerminalPalette2(resolved, palette), [resolved, palette]);
|
|
77
|
-
return /* @__PURE__ */ jsx(PaletteContext.Provider, {
|
|
78
|
-
value,
|
|
79
|
-
children
|
|
80
|
-
});
|
|
81
|
-
}
|
|
40
|
+
useTerminalLabels2,
|
|
41
|
+
useTerminalFocused2,
|
|
42
|
+
TerminalKeyPriority2,
|
|
43
|
+
useTerminalKeyboard2,
|
|
44
|
+
terminalToneAttributes2,
|
|
45
|
+
useTerminalPalette2
|
|
46
|
+
} from "./index-m0dhvt6x.js";
|
|
82
47
|
|
|
83
48
|
// src/widgets/chart.tsx
|
|
84
|
-
import { jsx
|
|
49
|
+
import { jsx, jsxs } from "@opentui/react/jsx-runtime";
|
|
85
50
|
function TerminalChart2({
|
|
86
51
|
series,
|
|
87
52
|
now,
|
|
@@ -108,14 +73,14 @@ function TerminalChart2({
|
|
|
108
73
|
return /* @__PURE__ */ jsxs("box", {
|
|
109
74
|
style: { flexDirection: "column", width, height: height + (axis ? 1 : 0) },
|
|
110
75
|
children: [
|
|
111
|
-
rows.map((segments, line) => /* @__PURE__ */
|
|
76
|
+
rows.map((segments, line) => /* @__PURE__ */ jsx("text", {
|
|
112
77
|
wrapMode: "none",
|
|
113
|
-
children: segments.map((segment, index) => /* @__PURE__ */
|
|
78
|
+
children: segments.map((segment, index) => /* @__PURE__ */ jsx("span", {
|
|
114
79
|
...segment.tone && { fg: palette[segment.tone] },
|
|
115
80
|
children: segment.text
|
|
116
81
|
}, index))
|
|
117
82
|
}, line)),
|
|
118
|
-
axis ? /* @__PURE__ */
|
|
83
|
+
axis ? /* @__PURE__ */ jsx("text", {
|
|
119
84
|
fg: palette.muted,
|
|
120
85
|
wrapMode: "none",
|
|
121
86
|
children: terminalTimeAxis2(windowMs, width)
|
|
@@ -133,7 +98,7 @@ function TerminalSparkline2({
|
|
|
133
98
|
}) {
|
|
134
99
|
const palette = useTerminalPalette2();
|
|
135
100
|
const values = sampleTerminalTimeSeries2(data, { now, count: width });
|
|
136
|
-
return /* @__PURE__ */
|
|
101
|
+
return /* @__PURE__ */ jsx("text", {
|
|
137
102
|
fg: palette[tone],
|
|
138
103
|
wrapMode: "none",
|
|
139
104
|
children: terminalSparkline2(values, {
|
|
@@ -143,116 +108,12 @@ function TerminalSparkline2({
|
|
|
143
108
|
});
|
|
144
109
|
}
|
|
145
110
|
|
|
146
|
-
// src/widgets/context.tsx
|
|
147
|
-
import { createContext as createContext2, useContext as useContext2, useMemo as useMemo2 } from "react";
|
|
148
|
-
import { jsx as jsx3 } from "@opentui/react/jsx-runtime";
|
|
149
|
-
var LabelsContext = createContext2(terminalLabelsEn2);
|
|
150
|
-
function TerminalLabelsProvider2({
|
|
151
|
-
labels,
|
|
152
|
-
children
|
|
153
|
-
}) {
|
|
154
|
-
return /* @__PURE__ */ jsx3(LabelsContext.Provider, {
|
|
155
|
-
value: labels,
|
|
156
|
-
children
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
function useTerminalLabels2() {
|
|
160
|
-
return useContext2(LabelsContext);
|
|
161
|
-
}
|
|
162
|
-
var FocusContext = createContext2(null);
|
|
163
|
-
function TerminalFocusProvider2({
|
|
164
|
-
state,
|
|
165
|
-
dispatch,
|
|
166
|
-
children
|
|
167
|
-
}) {
|
|
168
|
-
const value = useMemo2(() => ({ state, dispatch }), [state, dispatch]);
|
|
169
|
-
return /* @__PURE__ */ jsx3(FocusContext.Provider, {
|
|
170
|
-
value,
|
|
171
|
-
children
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
function useTerminalFocusContext2() {
|
|
175
|
-
return useContext2(FocusContext);
|
|
176
|
-
}
|
|
177
|
-
function useTerminalFocused2(focusId, focused) {
|
|
178
|
-
const context = useContext2(FocusContext);
|
|
179
|
-
if (focused !== undefined)
|
|
180
|
-
return focused;
|
|
181
|
-
if (focusId === undefined || context === null)
|
|
182
|
-
return true;
|
|
183
|
-
return context.state.focused === focusId;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// src/widgets/feedback.tsx
|
|
187
|
-
import { useEffect as useEffect3, useState as useState2 } from "react";
|
|
188
|
-
|
|
189
|
-
// src/widgets/keyboard.ts
|
|
190
|
-
import { useRenderer as useRenderer2 } from "@opentui/react";
|
|
191
|
-
import { useEffect as useEffect2, useRef } from "react";
|
|
192
|
-
var TerminalKeyPriority2 = Object.freeze({
|
|
193
|
-
input: 300,
|
|
194
|
-
layer: 200,
|
|
195
|
-
widget: 100,
|
|
196
|
-
global: 0
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
class KeyRouter {
|
|
200
|
-
registrations = new Set;
|
|
201
|
-
next = 0;
|
|
202
|
-
constructor(renderer) {
|
|
203
|
-
renderer.keyInput.on("keypress", (key) => this.route(key));
|
|
204
|
-
}
|
|
205
|
-
register(priority, handler) {
|
|
206
|
-
const registration = { order: this.next, priority, handler };
|
|
207
|
-
this.next += 1;
|
|
208
|
-
this.registrations.add(registration);
|
|
209
|
-
return registration;
|
|
210
|
-
}
|
|
211
|
-
unregister(registration) {
|
|
212
|
-
this.registrations.delete(registration);
|
|
213
|
-
}
|
|
214
|
-
route(key) {
|
|
215
|
-
if (key.propagationStopped)
|
|
216
|
-
return;
|
|
217
|
-
const ordered = [...this.registrations].sort((a, b) => b.priority - a.priority || a.order - b.order);
|
|
218
|
-
for (const registration of ordered) {
|
|
219
|
-
if (registration.handler(key)) {
|
|
220
|
-
key.preventDefault();
|
|
221
|
-
key.stopPropagation();
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
var routers = new WeakMap;
|
|
228
|
-
function routerFor(renderer) {
|
|
229
|
-
const existing = routers.get(renderer);
|
|
230
|
-
if (existing)
|
|
231
|
-
return existing;
|
|
232
|
-
const created = new KeyRouter(renderer);
|
|
233
|
-
routers.set(renderer, created);
|
|
234
|
-
return created;
|
|
235
|
-
}
|
|
236
|
-
function useTerminalKeyboard2(handler, options = {}) {
|
|
237
|
-
const renderer = useRenderer2();
|
|
238
|
-
const priority = options.priority ?? TerminalKeyPriority2.widget;
|
|
239
|
-
const active = options.active ?? true;
|
|
240
|
-
const latest = useRef(handler);
|
|
241
|
-
latest.current = handler;
|
|
242
|
-
const live = useRef(active);
|
|
243
|
-
live.current = active;
|
|
244
|
-
useEffect2(() => {
|
|
245
|
-
const router = routerFor(renderer);
|
|
246
|
-
const entry = router.register(priority, (key) => live.current && latest.current(key));
|
|
247
|
-
return () => router.unregister(entry);
|
|
248
|
-
}, [renderer, priority]);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
111
|
// src/widgets/feedback.tsx
|
|
252
|
-
import {
|
|
112
|
+
import { useEffect, useState } from "react";
|
|
113
|
+
import { jsx as jsx2, jsxs as jsxs2, Fragment } from "@opentui/react/jsx-runtime";
|
|
253
114
|
function useTerminalClock2(intervalMs, clock = Date.now) {
|
|
254
|
-
const [now, setNow] =
|
|
255
|
-
|
|
115
|
+
const [now, setNow] = useState(clock);
|
|
116
|
+
useEffect(() => {
|
|
256
117
|
const timer = setInterval(() => setNow(clock()), intervalMs);
|
|
257
118
|
return () => clearInterval(timer);
|
|
258
119
|
}, [intervalMs, clock]);
|
|
@@ -271,15 +132,15 @@ function TerminalSpinner2({
|
|
|
271
132
|
return /* @__PURE__ */ jsxs2("text", {
|
|
272
133
|
wrapMode: "none",
|
|
273
134
|
children: [
|
|
274
|
-
/* @__PURE__ */
|
|
135
|
+
/* @__PURE__ */ jsx2("span", {
|
|
275
136
|
fg: palette[tone],
|
|
276
137
|
children: `${terminalSpinnerFrame2(kind, elapsed)} `
|
|
277
138
|
}),
|
|
278
|
-
/* @__PURE__ */
|
|
139
|
+
/* @__PURE__ */ jsx2("span", {
|
|
279
140
|
fg: palette.primary,
|
|
280
141
|
children: sanitizeTerminalText2(label)
|
|
281
142
|
}),
|
|
282
|
-
/* @__PURE__ */
|
|
143
|
+
/* @__PURE__ */ jsx2("span", {
|
|
283
144
|
fg: palette.muted,
|
|
284
145
|
children: ` \xB7 ${formatTerminalDuration2(elapsed)}`
|
|
285
146
|
})
|
|
@@ -305,23 +166,23 @@ function TerminalProgressBar2({
|
|
|
305
166
|
return /* @__PURE__ */ jsxs2("text", {
|
|
306
167
|
wrapMode: "none",
|
|
307
168
|
children: [
|
|
308
|
-
/* @__PURE__ */
|
|
169
|
+
/* @__PURE__ */ jsx2("span", {
|
|
309
170
|
fg: palette.primary,
|
|
310
171
|
children: head
|
|
311
172
|
}),
|
|
312
|
-
/* @__PURE__ */
|
|
173
|
+
/* @__PURE__ */ jsx2("span", {
|
|
313
174
|
fg: palette.panelRaised,
|
|
314
175
|
children: "\u2501".repeat(start)
|
|
315
176
|
}),
|
|
316
|
-
/* @__PURE__ */
|
|
177
|
+
/* @__PURE__ */ jsx2("span", {
|
|
317
178
|
fg: palette.accent,
|
|
318
179
|
children: "\u2501".repeat(length)
|
|
319
180
|
}),
|
|
320
|
-
/* @__PURE__ */
|
|
181
|
+
/* @__PURE__ */ jsx2("span", {
|
|
321
182
|
fg: palette.panelRaised,
|
|
322
183
|
children: "\u2501".repeat(Math.max(0, barWidth - start - length))
|
|
323
184
|
}),
|
|
324
|
-
/* @__PURE__ */
|
|
185
|
+
/* @__PURE__ */ jsx2("span", {
|
|
325
186
|
fg: palette.muted,
|
|
326
187
|
children: tail
|
|
327
188
|
})
|
|
@@ -340,19 +201,19 @@ function TerminalProgressBar2({
|
|
|
340
201
|
return /* @__PURE__ */ jsxs2("text", {
|
|
341
202
|
wrapMode: "none",
|
|
342
203
|
children: [
|
|
343
|
-
/* @__PURE__ */
|
|
204
|
+
/* @__PURE__ */ jsx2("span", {
|
|
344
205
|
fg: palette.primary,
|
|
345
206
|
children: head
|
|
346
207
|
}),
|
|
347
|
-
/* @__PURE__ */
|
|
208
|
+
/* @__PURE__ */ jsx2("span", {
|
|
348
209
|
fg: palette[bar.tone],
|
|
349
210
|
children: bar.filled
|
|
350
211
|
}),
|
|
351
|
-
/* @__PURE__ */
|
|
212
|
+
/* @__PURE__ */ jsx2("span", {
|
|
352
213
|
fg: palette.panelRaised,
|
|
353
214
|
children: "\u2501".repeat(Math.max(0, barWidth - Array.from(bar.filled).length))
|
|
354
215
|
}),
|
|
355
|
-
/* @__PURE__ */
|
|
216
|
+
/* @__PURE__ */ jsx2("span", {
|
|
356
217
|
fg: palette.muted,
|
|
357
218
|
children: tail
|
|
358
219
|
})
|
|
@@ -368,7 +229,7 @@ function TerminalAsyncView2({
|
|
|
368
229
|
const palette = useTerminalPalette2();
|
|
369
230
|
const labels = useTerminalLabels2();
|
|
370
231
|
if (state.status === "loading") {
|
|
371
|
-
return /* @__PURE__ */
|
|
232
|
+
return /* @__PURE__ */ jsx2(TerminalSpinner2, {
|
|
372
233
|
label: state.label ?? labels.loading,
|
|
373
234
|
startedAt: state.startedAt,
|
|
374
235
|
...clock && { clock }
|
|
@@ -378,12 +239,12 @@ function TerminalAsyncView2({
|
|
|
378
239
|
return /* @__PURE__ */ jsxs2("box", {
|
|
379
240
|
style: { flexDirection: "column" },
|
|
380
241
|
children: [
|
|
381
|
-
/* @__PURE__ */
|
|
242
|
+
/* @__PURE__ */ jsx2("text", {
|
|
382
243
|
fg: palette.danger,
|
|
383
244
|
wrapMode: "none",
|
|
384
245
|
children: `\u2715 ${labels.error}`
|
|
385
246
|
}),
|
|
386
|
-
wrapTerminalText2(sanitizeTerminalText2(state.message), Math.max(1, width)).slice(0, 6).map((line, index) => /* @__PURE__ */
|
|
247
|
+
wrapTerminalText2(sanitizeTerminalText2(state.message), Math.max(1, width)).slice(0, 6).map((line, index) => /* @__PURE__ */ jsx2("text", {
|
|
387
248
|
fg: palette.primary,
|
|
388
249
|
wrapMode: "none",
|
|
389
250
|
children: line
|
|
@@ -392,12 +253,12 @@ function TerminalAsyncView2({
|
|
|
392
253
|
});
|
|
393
254
|
}
|
|
394
255
|
if (state.status === "empty") {
|
|
395
|
-
return /* @__PURE__ */
|
|
256
|
+
return /* @__PURE__ */ jsx2("text", {
|
|
396
257
|
fg: palette.muted,
|
|
397
258
|
children: state.message ?? labels.empty
|
|
398
259
|
});
|
|
399
260
|
}
|
|
400
|
-
return /* @__PURE__ */
|
|
261
|
+
return /* @__PURE__ */ jsx2(Fragment, {
|
|
401
262
|
children: children(state.data)
|
|
402
263
|
});
|
|
403
264
|
}
|
|
@@ -406,16 +267,16 @@ function TerminalDetails2({
|
|
|
406
267
|
width
|
|
407
268
|
}) {
|
|
408
269
|
const palette = useTerminalPalette2();
|
|
409
|
-
return /* @__PURE__ */
|
|
270
|
+
return /* @__PURE__ */ jsx2("box", {
|
|
410
271
|
style: { flexDirection: "column" },
|
|
411
272
|
children: layoutTerminalDetails2(pairs, width).map((pair, index) => /* @__PURE__ */ jsxs2("text", {
|
|
412
273
|
wrapMode: "none",
|
|
413
274
|
children: [
|
|
414
|
-
/* @__PURE__ */
|
|
275
|
+
/* @__PURE__ */ jsx2("span", {
|
|
415
276
|
fg: palette.muted,
|
|
416
277
|
children: pair.key
|
|
417
278
|
}),
|
|
418
|
-
/* @__PURE__ */
|
|
279
|
+
/* @__PURE__ */ jsx2("span", {
|
|
419
280
|
fg: palette[pair.tone],
|
|
420
281
|
children: pair.value
|
|
421
282
|
})
|
|
@@ -438,7 +299,7 @@ function TerminalDialog2({
|
|
|
438
299
|
const palette = useTerminalPalette2();
|
|
439
300
|
const labels = useTerminalLabels2();
|
|
440
301
|
const active = useTerminalFocused2(focusId, focused);
|
|
441
|
-
const [choice, setChoice] =
|
|
302
|
+
const [choice, setChoice] = useState("cancel");
|
|
442
303
|
useTerminalKeyboard2((key) => {
|
|
443
304
|
if (key.name === "y")
|
|
444
305
|
onConfirm();
|
|
@@ -461,7 +322,7 @@ function TerminalDialog2({
|
|
|
461
322
|
backgroundColor: palette.panel,
|
|
462
323
|
style: { flexDirection: "column", width, paddingLeft: 1, paddingRight: 1 },
|
|
463
324
|
children: [
|
|
464
|
-
wrapTerminalText2(sanitizeTerminalText2(message), inner).slice(0, 8).map((line, index) => /* @__PURE__ */
|
|
325
|
+
wrapTerminalText2(sanitizeTerminalText2(message), inner).slice(0, 8).map((line, index) => /* @__PURE__ */ jsx2("text", {
|
|
465
326
|
fg: palette.primary,
|
|
466
327
|
wrapMode: "none",
|
|
467
328
|
children: line
|
|
@@ -469,11 +330,11 @@ function TerminalDialog2({
|
|
|
469
330
|
/* @__PURE__ */ jsxs2("text", {
|
|
470
331
|
wrapMode: "none",
|
|
471
332
|
children: [
|
|
472
|
-
/* @__PURE__ */
|
|
333
|
+
/* @__PURE__ */ jsx2("span", {
|
|
473
334
|
fg: choice === "confirm" ? palette[tone] : palette.muted,
|
|
474
335
|
children: button(`${confirmLabel ?? labels.yes} (y)`, choice === "confirm")
|
|
475
336
|
}),
|
|
476
|
-
/* @__PURE__ */
|
|
337
|
+
/* @__PURE__ */ jsx2("span", {
|
|
477
338
|
fg: choice === "cancel" ? palette.primary : palette.muted,
|
|
478
339
|
children: button(`${cancelLabel ?? labels.no} (n)`, choice === "cancel")
|
|
479
340
|
})
|
|
@@ -487,23 +348,23 @@ function TerminalHelp2({
|
|
|
487
348
|
width
|
|
488
349
|
}) {
|
|
489
350
|
const palette = useTerminalPalette2();
|
|
490
|
-
return /* @__PURE__ */
|
|
351
|
+
return /* @__PURE__ */ jsx2("box", {
|
|
491
352
|
style: { flexDirection: "column", width },
|
|
492
353
|
children: groups.map((group) => /* @__PURE__ */ jsxs2("box", {
|
|
493
354
|
style: { flexDirection: "column", marginBottom: 1 },
|
|
494
355
|
children: [
|
|
495
|
-
/* @__PURE__ */
|
|
356
|
+
/* @__PURE__ */ jsx2("text", {
|
|
496
357
|
fg: palette.accent,
|
|
497
358
|
children: sanitizeTerminalText2(group.title)
|
|
498
359
|
}),
|
|
499
360
|
group.bindings.map((binding) => /* @__PURE__ */ jsxs2("text", {
|
|
500
361
|
wrapMode: "none",
|
|
501
362
|
children: [
|
|
502
|
-
/* @__PURE__ */
|
|
363
|
+
/* @__PURE__ */ jsx2("span", {
|
|
503
364
|
fg: palette.primary,
|
|
504
365
|
children: ` ${binding.keys.join(" ").padEnd(16)}`
|
|
505
366
|
}),
|
|
506
|
-
/* @__PURE__ */
|
|
367
|
+
/* @__PURE__ */ jsx2("span", {
|
|
507
368
|
fg: palette.muted,
|
|
508
369
|
children: truncateTerminalText2(sanitizeTerminalText2(binding.label), Math.max(1, width - 18))
|
|
509
370
|
})
|
|
@@ -515,8 +376,8 @@ function TerminalHelp2({
|
|
|
515
376
|
}
|
|
516
377
|
|
|
517
378
|
// src/widgets/form.tsx
|
|
518
|
-
import { useEffect as
|
|
519
|
-
import { jsx as
|
|
379
|
+
import { useEffect as useEffect2, useRef } from "react";
|
|
380
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "@opentui/react/jsx-runtime";
|
|
520
381
|
function terminalFormKeymap2(labels, cancel = true) {
|
|
521
382
|
return defineTerminalKeymap2([
|
|
522
383
|
{
|
|
@@ -576,8 +437,8 @@ function TerminalForm2({
|
|
|
576
437
|
const bindings = keymap ?? terminalFormKeymap2(labels, onCancel !== undefined);
|
|
577
438
|
const current = state.fields[state.focus];
|
|
578
439
|
const cycles = current?.kind === "boolean" || current?.kind === "choice";
|
|
579
|
-
const delivered =
|
|
580
|
-
|
|
440
|
+
const delivered = useRef(state.accepted?.serial ?? 0);
|
|
441
|
+
useEffect2(() => {
|
|
581
442
|
const accepted = state.accepted;
|
|
582
443
|
if (!accepted || accepted.serial === delivered.current)
|
|
583
444
|
return;
|
|
@@ -585,9 +446,16 @@ function TerminalForm2({
|
|
|
585
446
|
onSubmit(accepted.values);
|
|
586
447
|
}, [state.accepted, onSubmit]);
|
|
587
448
|
useTerminalKeyboard2((key) => {
|
|
588
|
-
if (!current)
|
|
589
|
-
return false;
|
|
590
449
|
const id = matchTerminalKey2(bindings, key)?.id;
|
|
450
|
+
if (state.fields.length === 0) {
|
|
451
|
+
if (id === "submit")
|
|
452
|
+
onAction({ type: "submit" });
|
|
453
|
+
else if (id === "cancel" && onCancel)
|
|
454
|
+
onCancel();
|
|
455
|
+
else
|
|
456
|
+
return false;
|
|
457
|
+
return true;
|
|
458
|
+
}
|
|
591
459
|
if (id === "change" && cycles)
|
|
592
460
|
onAction({ type: "cycle", delta: key.name === "left" ? -1 : 1 });
|
|
593
461
|
else if (id === "next")
|
|
@@ -608,7 +476,17 @@ function TerminalForm2({
|
|
|
608
476
|
return true;
|
|
609
477
|
}, { active, priority: TerminalKeyPriority2.input });
|
|
610
478
|
const labelWidth = Math.min(Math.max(4, ...state.fields.map(({ label, required }) => Array.from(label).length + (required ? 2 : 0) + 1)), Math.floor(width / 3));
|
|
611
|
-
|
|
479
|
+
if (state.fields.length === 0) {
|
|
480
|
+
return /* @__PURE__ */ jsx3("box", {
|
|
481
|
+
style: { flexDirection: "column", width },
|
|
482
|
+
children: /* @__PURE__ */ jsx3("text", {
|
|
483
|
+
fg: palette.muted,
|
|
484
|
+
wrapMode: "none",
|
|
485
|
+
children: truncateTerminalText2(labels.noFields, width)
|
|
486
|
+
})
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
return /* @__PURE__ */ jsx3("box", {
|
|
612
490
|
style: { flexDirection: "column", width },
|
|
613
491
|
children: state.fields.map((field, index) => {
|
|
614
492
|
const isFocused = index === state.focus && active;
|
|
@@ -626,30 +504,30 @@ function TerminalForm2({
|
|
|
626
504
|
wrapMode: "none",
|
|
627
505
|
...isFocused && { bg: palette.panelRaised },
|
|
628
506
|
children: [
|
|
629
|
-
/* @__PURE__ */
|
|
507
|
+
/* @__PURE__ */ jsx3("span", {
|
|
630
508
|
fg: isFocused ? palette.accent : palette.muted,
|
|
631
509
|
children: isFocused ? "\u203A " : " "
|
|
632
510
|
}),
|
|
633
|
-
/* @__PURE__ */
|
|
511
|
+
/* @__PURE__ */ jsx3("span", {
|
|
634
512
|
fg: error ? palette.danger : isFocused ? palette.primary : palette.muted,
|
|
635
513
|
children: fitTerminalText2(`${sanitizeTerminalText2(field.label)}${field.required ? " *" : ""}`, labelWidth)
|
|
636
514
|
}),
|
|
637
|
-
/* @__PURE__ */
|
|
515
|
+
/* @__PURE__ */ jsx3("span", {
|
|
638
516
|
fg: palette.primary,
|
|
639
517
|
children: value
|
|
640
518
|
}),
|
|
641
|
-
/* @__PURE__ */
|
|
519
|
+
/* @__PURE__ */ jsx3("span", {
|
|
642
520
|
fg: palette.muted,
|
|
643
521
|
children: fitTerminalText2(placeholder, Math.max(0, valueWidth - Array.from(value).length))
|
|
644
522
|
})
|
|
645
523
|
]
|
|
646
524
|
}),
|
|
647
|
-
description.map((line, offset) => /* @__PURE__ */
|
|
525
|
+
description.map((line, offset) => /* @__PURE__ */ jsx3("text", {
|
|
648
526
|
fg: palette.muted,
|
|
649
527
|
wrapMode: "none",
|
|
650
528
|
children: " ".repeat(labelWidth + 2) + line
|
|
651
529
|
}, offset)),
|
|
652
|
-
error ? /* @__PURE__ */
|
|
530
|
+
error ? /* @__PURE__ */ jsx3("text", {
|
|
653
531
|
fg: palette.danger,
|
|
654
532
|
wrapMode: "none",
|
|
655
533
|
children: " ".repeat(labelWidth + 2) + truncateTerminalText2(error, Math.max(1, width - labelWidth - 2))
|
|
@@ -661,7 +539,7 @@ function TerminalForm2({
|
|
|
661
539
|
}
|
|
662
540
|
|
|
663
541
|
// src/widgets/layout.tsx
|
|
664
|
-
import { jsx as
|
|
542
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "@opentui/react/jsx-runtime";
|
|
665
543
|
function TerminalPanel2({
|
|
666
544
|
title,
|
|
667
545
|
badge,
|
|
@@ -673,7 +551,7 @@ function TerminalPanel2({
|
|
|
673
551
|
}) {
|
|
674
552
|
const palette = useTerminalPalette2();
|
|
675
553
|
const heading = title === undefined ? undefined : ` ${title}${badge === undefined ? "" : ` \xB7 ${badge}`} `;
|
|
676
|
-
return /* @__PURE__ */
|
|
554
|
+
return /* @__PURE__ */ jsx4("box", {
|
|
677
555
|
border: true,
|
|
678
556
|
borderStyle: "rounded",
|
|
679
557
|
borderColor: focused ? palette.borderActive : palette.border,
|
|
@@ -708,9 +586,9 @@ function TerminalStatusBar2({
|
|
|
708
586
|
left -= terminalTextWidth2(text);
|
|
709
587
|
parts.push({ text, tone: segment.tone ?? "muted" });
|
|
710
588
|
});
|
|
711
|
-
return /* @__PURE__ */
|
|
589
|
+
return /* @__PURE__ */ jsx4("text", {
|
|
712
590
|
wrapMode: "none",
|
|
713
|
-
children: parts.map((part, index) => /* @__PURE__ */
|
|
591
|
+
children: parts.map((part, index) => /* @__PURE__ */ jsx4("span", {
|
|
714
592
|
fg: palette[part.tone],
|
|
715
593
|
children: part.text
|
|
716
594
|
}, index))
|
|
@@ -721,7 +599,7 @@ function TerminalKeyHints2({
|
|
|
721
599
|
width
|
|
722
600
|
}) {
|
|
723
601
|
const palette = useTerminalPalette2();
|
|
724
|
-
return /* @__PURE__ */
|
|
602
|
+
return /* @__PURE__ */ jsx4("text", {
|
|
725
603
|
fg: palette.muted,
|
|
726
604
|
wrapMode: "none",
|
|
727
605
|
children: fitTerminalText2(fitTerminalKeyHints2(bindings, width), width)
|
|
@@ -732,9 +610,9 @@ function TerminalNotices2({
|
|
|
732
610
|
width
|
|
733
611
|
}) {
|
|
734
612
|
const palette = useTerminalPalette2();
|
|
735
|
-
return /* @__PURE__ */
|
|
613
|
+
return /* @__PURE__ */ jsx4("box", {
|
|
736
614
|
style: { flexDirection: "column" },
|
|
737
|
-
children: state.notices.map((notice) => /* @__PURE__ */
|
|
615
|
+
children: state.notices.map((notice) => /* @__PURE__ */ jsx4("text", {
|
|
738
616
|
fg: palette[notice.tone],
|
|
739
617
|
bg: palette.panelRaised,
|
|
740
618
|
wrapMode: "none",
|
|
@@ -757,33 +635,33 @@ function TerminalAppShell2({
|
|
|
757
635
|
return /* @__PURE__ */ jsxs4("box", {
|
|
758
636
|
style: { flexDirection: "column", width, height },
|
|
759
637
|
children: [
|
|
760
|
-
/* @__PURE__ */
|
|
638
|
+
/* @__PURE__ */ jsx4("text", {
|
|
761
639
|
wrapMode: "none",
|
|
762
|
-
children: crumbs.map((crumb, index) => /* @__PURE__ */
|
|
640
|
+
children: crumbs.map((crumb, index) => /* @__PURE__ */ jsx4("span", {
|
|
763
641
|
fg: index === last ? palette.accent : palette.muted,
|
|
764
642
|
children: `${index === 0 ? "" : " \u203A "}${crumb}`
|
|
765
643
|
}, index))
|
|
766
644
|
}),
|
|
767
|
-
status.map((segments, index) => /* @__PURE__ */
|
|
645
|
+
status.map((segments, index) => /* @__PURE__ */ jsx4(TerminalStatusBar2, {
|
|
768
646
|
segments,
|
|
769
647
|
width
|
|
770
648
|
}, index)),
|
|
771
|
-
/* @__PURE__ */
|
|
649
|
+
/* @__PURE__ */ jsx4("text", {
|
|
772
650
|
fg: palette.border,
|
|
773
651
|
wrapMode: "none",
|
|
774
652
|
children: "\u2500".repeat(Math.max(0, width))
|
|
775
653
|
}),
|
|
776
|
-
/* @__PURE__ */
|
|
654
|
+
/* @__PURE__ */ jsx4("box", {
|
|
777
655
|
style: { flexDirection: "column", flexGrow: 1, flexShrink: 1, overflow: "hidden" },
|
|
778
656
|
children
|
|
779
657
|
}),
|
|
780
|
-
bindings.length > 0 ? /* @__PURE__ */
|
|
658
|
+
bindings.length > 0 ? /* @__PURE__ */ jsx4(TerminalKeyHints2, {
|
|
781
659
|
bindings,
|
|
782
660
|
width
|
|
783
661
|
}) : null,
|
|
784
|
-
notices && notices.notices.length > 0 ? /* @__PURE__ */
|
|
662
|
+
notices && notices.notices.length > 0 ? /* @__PURE__ */ jsx4("box", {
|
|
785
663
|
style: { position: "absolute", top: 1, right: 1, zIndex: 10 },
|
|
786
|
-
children: /* @__PURE__ */
|
|
664
|
+
children: /* @__PURE__ */ jsx4(TerminalNotices2, {
|
|
787
665
|
state: notices,
|
|
788
666
|
width
|
|
789
667
|
})
|
|
@@ -793,8 +671,8 @@ function TerminalAppShell2({
|
|
|
793
671
|
}
|
|
794
672
|
|
|
795
673
|
// src/widgets/list.tsx
|
|
796
|
-
import { useEffect as
|
|
797
|
-
import { jsx as
|
|
674
|
+
import { useEffect as useEffect3, useRef as useRef2 } from "react";
|
|
675
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "@opentui/react/jsx-runtime";
|
|
798
676
|
function terminalListKeymap2(labels, options = {}) {
|
|
799
677
|
return defineTerminalKeymap2([
|
|
800
678
|
{ id: "up", keys: ["up"], display: "\u2191\u2193", label: labels.move, priority: 0 },
|
|
@@ -846,8 +724,8 @@ function TerminalList2({
|
|
|
846
724
|
});
|
|
847
725
|
const searchRows = searchable ? 2 : 0;
|
|
848
726
|
const listRows = Math.max(1, height - searchRows - descriptionLines - 2);
|
|
849
|
-
const delivered =
|
|
850
|
-
|
|
727
|
+
const delivered = useRef2(state.activation?.serial ?? 0);
|
|
728
|
+
useEffect3(() => {
|
|
851
729
|
const activation = state.activation;
|
|
852
730
|
if (!activation || activation.serial === delivered.current)
|
|
853
731
|
return;
|
|
@@ -891,28 +769,28 @@ function TerminalList2({
|
|
|
891
769
|
searchable ? /* @__PURE__ */ jsxs5("text", {
|
|
892
770
|
wrapMode: "none",
|
|
893
771
|
children: [
|
|
894
|
-
/* @__PURE__ */
|
|
772
|
+
/* @__PURE__ */ jsx5("span", {
|
|
895
773
|
fg: palette.accent,
|
|
896
774
|
children: "\u2315 "
|
|
897
775
|
}),
|
|
898
|
-
/* @__PURE__ */
|
|
776
|
+
/* @__PURE__ */ jsx5("span", {
|
|
899
777
|
fg: state.query ? palette.primary : palette.muted,
|
|
900
778
|
children: fitTerminalText2(state.query || labels.search, Math.max(0, width - 2))
|
|
901
779
|
})
|
|
902
780
|
]
|
|
903
781
|
}) : null,
|
|
904
|
-
searchable ? /* @__PURE__ */
|
|
782
|
+
searchable ? /* @__PURE__ */ jsx5("text", {
|
|
905
783
|
fg: palette.border,
|
|
906
784
|
children: "\u2500".repeat(width)
|
|
907
785
|
}) : null,
|
|
908
|
-
/* @__PURE__ */
|
|
786
|
+
/* @__PURE__ */ jsx5("text", {
|
|
909
787
|
fg: palette.muted,
|
|
910
788
|
wrapMode: "none",
|
|
911
789
|
children: above > 0 ? labels.moreAbove(above) : " "
|
|
912
790
|
}),
|
|
913
|
-
/* @__PURE__ */
|
|
791
|
+
/* @__PURE__ */ jsx5("box", {
|
|
914
792
|
style: { flexDirection: "column", height: listRows },
|
|
915
|
-
children: !hasItems ? /* @__PURE__ */
|
|
793
|
+
children: !hasItems ? /* @__PURE__ */ jsx5("text", {
|
|
916
794
|
fg: palette.muted,
|
|
917
795
|
children: labels.nothingFound
|
|
918
796
|
}) : lines.map((line, slot) => {
|
|
@@ -920,11 +798,11 @@ function TerminalList2({
|
|
|
920
798
|
return /* @__PURE__ */ jsxs5("text", {
|
|
921
799
|
wrapMode: "none",
|
|
922
800
|
children: [
|
|
923
|
-
/* @__PURE__ */
|
|
801
|
+
/* @__PURE__ */ jsx5("span", {
|
|
924
802
|
fg: palette.accent,
|
|
925
803
|
children: truncateTerminalText2(sanitizeTerminalText2(line.title), width - 6)
|
|
926
804
|
}),
|
|
927
|
-
/* @__PURE__ */
|
|
805
|
+
/* @__PURE__ */ jsx5("span", {
|
|
928
806
|
fg: palette.muted,
|
|
929
807
|
children: ` ${line.count}`
|
|
930
808
|
})
|
|
@@ -945,23 +823,23 @@ function TerminalList2({
|
|
|
945
823
|
wrapMode: "none",
|
|
946
824
|
...isSelected && active && { bg: palette.panelRaised },
|
|
947
825
|
children: [
|
|
948
|
-
/* @__PURE__ */
|
|
826
|
+
/* @__PURE__ */ jsx5("span", {
|
|
949
827
|
fg: isSelected ? palette.accent : palette.muted,
|
|
950
828
|
children: isSelected ? "\u203A " : " "
|
|
951
829
|
}),
|
|
952
|
-
/* @__PURE__ */
|
|
830
|
+
/* @__PURE__ */ jsx5("span", {
|
|
953
831
|
fg: palette.accent,
|
|
954
832
|
children: mark
|
|
955
833
|
}),
|
|
956
|
-
terminalHighlightRuns2(title, line.titleRanges).map((run, index) => /* @__PURE__ */
|
|
834
|
+
terminalHighlightRuns2(title, line.titleRanges).map((run, index) => /* @__PURE__ */ jsx5("span", {
|
|
957
835
|
fg: run.highlighted ? palette.accent : tone,
|
|
958
836
|
children: run.text
|
|
959
837
|
}, index)),
|
|
960
|
-
/* @__PURE__ */
|
|
838
|
+
/* @__PURE__ */ jsx5("span", {
|
|
961
839
|
fg: palette.muted,
|
|
962
840
|
children: metaText + " ".repeat(pad)
|
|
963
841
|
}),
|
|
964
|
-
/* @__PURE__ */
|
|
842
|
+
/* @__PURE__ */ jsx5("span", {
|
|
965
843
|
fg: palette.muted,
|
|
966
844
|
children: badge
|
|
967
845
|
})
|
|
@@ -969,14 +847,14 @@ function TerminalList2({
|
|
|
969
847
|
}, slot);
|
|
970
848
|
})
|
|
971
849
|
}),
|
|
972
|
-
/* @__PURE__ */
|
|
850
|
+
/* @__PURE__ */ jsx5("text", {
|
|
973
851
|
fg: palette.muted,
|
|
974
852
|
wrapMode: "none",
|
|
975
853
|
children: below > 0 ? labels.moreBelow(below) : " "
|
|
976
854
|
}),
|
|
977
|
-
/* @__PURE__ */
|
|
855
|
+
/* @__PURE__ */ jsx5("box", {
|
|
978
856
|
style: { flexDirection: "column", height: descriptionLines },
|
|
979
|
-
children: description.map((line, index) => /* @__PURE__ */
|
|
857
|
+
children: description.map((line, index) => /* @__PURE__ */ jsx5("text", {
|
|
980
858
|
fg: palette.muted,
|
|
981
859
|
wrapMode: "none",
|
|
982
860
|
children: line
|
|
@@ -987,7 +865,7 @@ function TerminalList2({
|
|
|
987
865
|
}
|
|
988
866
|
|
|
989
867
|
// src/widgets/meter.tsx
|
|
990
|
-
import { jsx as
|
|
868
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "@opentui/react/jsx-runtime";
|
|
991
869
|
function TerminalMeter2({
|
|
992
870
|
label,
|
|
993
871
|
value,
|
|
@@ -1010,26 +888,26 @@ function TerminalMeter2({
|
|
|
1010
888
|
return /* @__PURE__ */ jsxs6("text", {
|
|
1011
889
|
wrapMode: "none",
|
|
1012
890
|
children: [
|
|
1013
|
-
/* @__PURE__ */
|
|
891
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1014
892
|
fg: palette.muted,
|
|
1015
893
|
children: fitTerminalText2(label, labelWidth, "left")
|
|
1016
894
|
}),
|
|
1017
|
-
/* @__PURE__ */
|
|
895
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1018
896
|
fg: palette.border,
|
|
1019
897
|
children: " ["
|
|
1020
898
|
}),
|
|
1021
|
-
/* @__PURE__ */
|
|
899
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1022
900
|
fg: palette[bar.tone],
|
|
1023
901
|
children: bar.filled
|
|
1024
902
|
}),
|
|
1025
|
-
/* @__PURE__ */
|
|
903
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1026
904
|
children: bar.empty
|
|
1027
905
|
}),
|
|
1028
|
-
/* @__PURE__ */
|
|
906
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1029
907
|
fg: palette.border,
|
|
1030
908
|
children: "]"
|
|
1031
909
|
}),
|
|
1032
|
-
/* @__PURE__ */
|
|
910
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1033
911
|
fg: bar.ratio === null ? palette.muted : palette.primary,
|
|
1034
912
|
children: fitTerminalText2(reading, textWidth, "right")
|
|
1035
913
|
})
|
|
@@ -1044,17 +922,17 @@ function TerminalMeterGrid2({
|
|
|
1044
922
|
}) {
|
|
1045
923
|
const grid = layoutTerminalMeterGrid2({ count: meters.length, width, minMeterWidth, gap });
|
|
1046
924
|
const labelWidth = Math.max(1, ...meters.map(({ label }) => label.length));
|
|
1047
|
-
return /* @__PURE__ */
|
|
925
|
+
return /* @__PURE__ */ jsx6("box", {
|
|
1048
926
|
style: { flexDirection: "column", width, height: grid.rows },
|
|
1049
|
-
children: grid.cells.map((row) => /* @__PURE__ */
|
|
927
|
+
children: grid.cells.map((row) => /* @__PURE__ */ jsx6("box", {
|
|
1050
928
|
style: { flexDirection: "row", height: 1, gap },
|
|
1051
929
|
children: row.map((index) => {
|
|
1052
930
|
const meter = meters[index];
|
|
1053
931
|
if (!meter)
|
|
1054
932
|
return null;
|
|
1055
|
-
return /* @__PURE__ */
|
|
933
|
+
return /* @__PURE__ */ jsx6("box", {
|
|
1056
934
|
style: { width: grid.meterWidth, height: 1 },
|
|
1057
|
-
children: /* @__PURE__ */
|
|
935
|
+
children: /* @__PURE__ */ jsx6(TerminalMeter2, {
|
|
1058
936
|
...meter,
|
|
1059
937
|
width: grid.meterWidth,
|
|
1060
938
|
labelWidth
|
|
@@ -1066,8 +944,8 @@ function TerminalMeterGrid2({
|
|
|
1066
944
|
}
|
|
1067
945
|
|
|
1068
946
|
// src/widgets/table.tsx
|
|
1069
|
-
import { useEffect as
|
|
1070
|
-
import { jsx as
|
|
947
|
+
import { useEffect as useEffect4, useMemo, useRef as useRef3, useState as useState2 } from "react";
|
|
948
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "@opentui/react/jsx-runtime";
|
|
1071
949
|
function TerminalTable2({
|
|
1072
950
|
state,
|
|
1073
951
|
onAction,
|
|
@@ -1081,26 +959,26 @@ function TerminalTable2({
|
|
|
1081
959
|
const palette = useTerminalPalette2();
|
|
1082
960
|
const labels = useTerminalLabels2();
|
|
1083
961
|
const active = useTerminalFocused2(focusId, focused);
|
|
1084
|
-
const bindings =
|
|
1085
|
-
const [filtering, setFilteringState] =
|
|
1086
|
-
const filteringNow =
|
|
962
|
+
const bindings = useMemo(() => keymap ?? terminalTableKeymap2(labels), [keymap, labels]);
|
|
963
|
+
const [filtering, setFilteringState] = useState2(false);
|
|
964
|
+
const filteringNow = useRef3(false);
|
|
1087
965
|
const setFiltering = (open) => {
|
|
1088
966
|
filteringNow.current = open;
|
|
1089
967
|
setFilteringState(open);
|
|
1090
968
|
};
|
|
1091
969
|
const capacity = Math.max(1, height - 2);
|
|
1092
|
-
|
|
970
|
+
useEffect4(() => {
|
|
1093
971
|
if (state.collection.capacity !== capacity)
|
|
1094
972
|
onAction({ type: "resize", capacity });
|
|
1095
973
|
}, [capacity, onAction, state.collection.capacity]);
|
|
1096
|
-
|
|
974
|
+
useEffect4(() => {
|
|
1097
975
|
if (active)
|
|
1098
976
|
return;
|
|
1099
977
|
filteringNow.current = false;
|
|
1100
978
|
setFilteringState(false);
|
|
1101
979
|
}, [active]);
|
|
1102
|
-
const delivered =
|
|
1103
|
-
|
|
980
|
+
const delivered = useRef3(state.activation?.serial ?? 0);
|
|
981
|
+
useEffect4(() => {
|
|
1104
982
|
const activation = state.activation;
|
|
1105
983
|
if (!activation || activation.serial === delivered.current)
|
|
1106
984
|
return;
|
|
@@ -1144,13 +1022,13 @@ function TerminalTable2({
|
|
|
1144
1022
|
return /* @__PURE__ */ jsxs7("box", {
|
|
1145
1023
|
style: { flexDirection: "column", width, height },
|
|
1146
1024
|
children: [
|
|
1147
|
-
/* @__PURE__ */
|
|
1025
|
+
/* @__PURE__ */ jsx7("text", {
|
|
1148
1026
|
fg: palette.muted,
|
|
1149
1027
|
wrapMode: "none",
|
|
1150
1028
|
children: columns.map(({ column, width }, index) => {
|
|
1151
1029
|
const mark = state.sort?.columnId === column.id ? state.sort.direction === "asc" ? "\u25B2" : "\u25BC" : "";
|
|
1152
1030
|
const align = column.align ?? (column.kind === "number" ? "right" : "left");
|
|
1153
|
-
return /* @__PURE__ */
|
|
1031
|
+
return /* @__PURE__ */ jsx7("span", {
|
|
1154
1032
|
fg: mark ? palette.accent : palette.muted,
|
|
1155
1033
|
children: `${index === 0 ? "" : " "}${fitTerminalText2(column.title + mark, width, align)}`
|
|
1156
1034
|
}, column.id);
|
|
@@ -1158,8 +1036,9 @@ function TerminalTable2({
|
|
|
1158
1036
|
}),
|
|
1159
1037
|
rows.map((view, slot) => {
|
|
1160
1038
|
const selected = view.row.key === state.collection.selectedKey;
|
|
1161
|
-
const
|
|
1162
|
-
|
|
1039
|
+
const rowTone = view.matched ? view.row.tone : undefined;
|
|
1040
|
+
const tone = rowTone ? palette[rowTone] : selected && active || view.matched ? palette.primary : palette.muted;
|
|
1041
|
+
return /* @__PURE__ */ jsx7("text", {
|
|
1163
1042
|
fg: tone,
|
|
1164
1043
|
...selected && { bg: palette.panelRaised },
|
|
1165
1044
|
wrapMode: "none",
|
|
@@ -1168,18 +1047,22 @@ function TerminalTable2({
|
|
|
1168
1047
|
const prefix = index === 0 ? terminalTableTreePrefix2(view) : "";
|
|
1169
1048
|
const text = formatTerminalTableCell2(column, view.row.cells[column.id] ?? null);
|
|
1170
1049
|
const cell = index === 0 ? fitTerminalText2(prefix + text, width, align) : ` ${fitTerminalText2(text, width, align)}`;
|
|
1171
|
-
const
|
|
1172
|
-
|
|
1173
|
-
|
|
1050
|
+
const value = view.row.cells[column.id] ?? null;
|
|
1051
|
+
const missing = value === null;
|
|
1052
|
+
const cellTone = missing || !view.matched ? undefined : column.tone?.(value, view.row);
|
|
1053
|
+
const fg = cellTone ? palette[cellTone] : missing && !selected ? palette.muted : undefined;
|
|
1054
|
+
return /* @__PURE__ */ jsx7("span", {
|
|
1055
|
+
...fg && { fg },
|
|
1056
|
+
attributes: terminalToneAttributes2(cellTone ?? rowTone),
|
|
1174
1057
|
children: cell
|
|
1175
1058
|
}, column.id);
|
|
1176
1059
|
})
|
|
1177
1060
|
}, slot);
|
|
1178
1061
|
}),
|
|
1179
|
-
blank > 0 && /* @__PURE__ */
|
|
1062
|
+
blank > 0 && /* @__PURE__ */ jsx7("box", {
|
|
1180
1063
|
style: { height: blank }
|
|
1181
1064
|
}),
|
|
1182
|
-
/* @__PURE__ */
|
|
1065
|
+
/* @__PURE__ */ jsx7("text", {
|
|
1183
1066
|
fg: filtering ? palette.accent : palette.muted,
|
|
1184
1067
|
wrapMode: "none",
|
|
1185
1068
|
children: fitTerminalText2(footer, width, "left")
|
|
@@ -1189,8 +1072,8 @@ function TerminalTable2({
|
|
|
1189
1072
|
}
|
|
1190
1073
|
|
|
1191
1074
|
// src/widgets/tabs.tsx
|
|
1192
|
-
import { useMemo as
|
|
1193
|
-
import { jsx as
|
|
1075
|
+
import { useMemo as useMemo2 } from "react";
|
|
1076
|
+
import { jsx as jsx8 } from "@opentui/react/jsx-runtime";
|
|
1194
1077
|
function TerminalTabs2({
|
|
1195
1078
|
state,
|
|
1196
1079
|
onAction,
|
|
@@ -1201,7 +1084,7 @@ function TerminalTabs2({
|
|
|
1201
1084
|
const palette = useTerminalPalette2();
|
|
1202
1085
|
const labels = useTerminalLabels2();
|
|
1203
1086
|
const active = useTerminalFocused2(focusId, focused);
|
|
1204
|
-
const bindings =
|
|
1087
|
+
const bindings = useMemo2(() => keymap ?? terminalTabsKeymap2(labels), [keymap, labels]);
|
|
1205
1088
|
useTerminalKeyboard2((key) => {
|
|
1206
1089
|
const action = terminalTabsKey2(key, bindings);
|
|
1207
1090
|
if (action === null)
|
|
@@ -1209,11 +1092,11 @@ function TerminalTabs2({
|
|
|
1209
1092
|
onAction(action);
|
|
1210
1093
|
return true;
|
|
1211
1094
|
}, { active });
|
|
1212
|
-
return /* @__PURE__ */
|
|
1095
|
+
return /* @__PURE__ */ jsx8("text", {
|
|
1213
1096
|
wrapMode: "none",
|
|
1214
1097
|
children: state.tabs.map((tab, index) => {
|
|
1215
1098
|
const selected = tab.id === state.selectedId;
|
|
1216
|
-
return /* @__PURE__ */
|
|
1099
|
+
return /* @__PURE__ */ jsx8("span", {
|
|
1217
1100
|
fg: selected ? palette.primary : palette.muted,
|
|
1218
1101
|
...selected && { bg: palette.panelRaised },
|
|
1219
1102
|
children: `${index === 0 ? "" : " "} ${index < 9 ? `${index + 1} ` : ""}${sanitizeTerminalText2(tab.label)}${tab.badge === null ? "" : ` ${tab.badge}`} `
|
|
@@ -1223,8 +1106,8 @@ function TerminalTabs2({
|
|
|
1223
1106
|
}
|
|
1224
1107
|
|
|
1225
1108
|
// src/widgets/text-view.tsx
|
|
1226
|
-
import { useMemo as
|
|
1227
|
-
import { jsx as
|
|
1109
|
+
import { useMemo as useMemo3, useState as useState3 } from "react";
|
|
1110
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "@opentui/react/jsx-runtime";
|
|
1228
1111
|
function terminalTextViewKeymap2(labels, back = true) {
|
|
1229
1112
|
return defineTerminalKeymap2([
|
|
1230
1113
|
{
|
|
@@ -1290,12 +1173,12 @@ function TerminalTextView2({
|
|
|
1290
1173
|
const labels = useTerminalLabels2();
|
|
1291
1174
|
const active = useTerminalFocused2(focusId, focused);
|
|
1292
1175
|
const bindings = terminalTextViewKeymap2(labels, onBack !== undefined);
|
|
1293
|
-
const lines =
|
|
1176
|
+
const lines = useMemo3(() => typeof content === "string" ? wrapTerminalText2(sanitizeTerminalText2(content), Math.max(1, width)).map((text) => [
|
|
1294
1177
|
{ text, tone: "primary" }
|
|
1295
1178
|
]) : [...content], [content, width]);
|
|
1296
1179
|
const rows = Math.max(1, height - 1);
|
|
1297
1180
|
const last = Math.max(0, lines.length - rows);
|
|
1298
|
-
const [start, setStart] =
|
|
1181
|
+
const [start, setStart] = useState3(0);
|
|
1299
1182
|
const top = Math.min(start, last);
|
|
1300
1183
|
useTerminalKeyboard2((key) => {
|
|
1301
1184
|
const id = matchTerminalKey2(bindings, key)?.id;
|
|
@@ -1322,17 +1205,17 @@ function TerminalTextView2({
|
|
|
1322
1205
|
return /* @__PURE__ */ jsxs8("box", {
|
|
1323
1206
|
style: { flexDirection: "column", width, height },
|
|
1324
1207
|
children: [
|
|
1325
|
-
/* @__PURE__ */
|
|
1208
|
+
/* @__PURE__ */ jsx9("box", {
|
|
1326
1209
|
style: { flexDirection: "column", height: rows },
|
|
1327
|
-
children: lines.slice(top, top + rows).map((line, slot) => /* @__PURE__ */
|
|
1210
|
+
children: lines.slice(top, top + rows).map((line, slot) => /* @__PURE__ */ jsx9("text", {
|
|
1328
1211
|
wrapMode: "none",
|
|
1329
|
-
children: line.map((run, index) => /* @__PURE__ */
|
|
1212
|
+
children: line.map((run, index) => /* @__PURE__ */ jsx9("span", {
|
|
1330
1213
|
fg: palette[run.tone],
|
|
1331
1214
|
children: run.text
|
|
1332
1215
|
}, index))
|
|
1333
1216
|
}, slot))
|
|
1334
1217
|
}),
|
|
1335
|
-
/* @__PURE__ */
|
|
1218
|
+
/* @__PURE__ */ jsx9("text", {
|
|
1336
1219
|
fg: palette.muted,
|
|
1337
1220
|
wrapMode: "none",
|
|
1338
1221
|
children: `${top + 1}\u2013${Math.min(lines.length, top + rows)} / ${lines.length} \xB7 ${labels.scroll(percent)}`
|
|
@@ -1344,11 +1227,11 @@ function TerminalJsonView2({
|
|
|
1344
1227
|
value,
|
|
1345
1228
|
...props
|
|
1346
1229
|
}) {
|
|
1347
|
-
const lines =
|
|
1348
|
-
return /* @__PURE__ */
|
|
1230
|
+
const lines = useMemo3(() => terminalJsonLines2(value), [value]);
|
|
1231
|
+
return /* @__PURE__ */ jsx9(TerminalTextView2, {
|
|
1349
1232
|
...props,
|
|
1350
1233
|
content: lines
|
|
1351
1234
|
});
|
|
1352
1235
|
}
|
|
1353
1236
|
|
|
1354
|
-
export {
|
|
1237
|
+
export { TerminalChart2, TerminalSparkline2, useTerminalClock2, TerminalSpinner2, TerminalProgressBar2, TerminalAsyncView2, TerminalDetails2, TerminalDialog2, TerminalHelp2, terminalFormKeymap2, TerminalForm2, TerminalPanel2, TerminalStatusBar2, TerminalKeyHints2, TerminalNotices2, TerminalAppShell2, terminalListKeymap2, TerminalList2, TerminalMeter2, TerminalMeterGrid2, TerminalTable2, TerminalTabs2, terminalTextViewKeymap2, TerminalTextView2, TerminalJsonView2 };
|