@simon_he/vue-tui 1.0.0-rc.0 → 1.0.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 +17 -8
- package/dist/{TSelect-BmSkar0D.js → TSelect-BwJJbuTt.js} +1275 -3883
- package/dist/TTree-DK_DQBYm.js +6480 -0
- package/dist/agent.cjs +39416 -0
- package/dist/agent.d.cts +44 -0
- package/dist/agent.d.ts +44 -0
- package/dist/agent.js +828 -0
- package/dist/ansi-palette-CNXqFciC.js +57 -0
- package/dist/block-source-CKUOnkgT.js +1663 -0
- package/dist/cli/node-file-writers.d.ts +1 -0
- package/dist/cli.cjs +508 -111
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +443 -89
- package/dist/core/terminal/create-terminal.d.ts +3 -2
- package/dist/core.cjs +120 -39
- package/dist/core.js +7 -5
- package/dist/{ansi-palette-Bv5Vqr4k.js → create-terminal-C2oiWFJU.js} +19 -84
- package/dist/create-terminal-app.d.ts +2 -0
- package/dist/{dom-renderer-CDVQIcIL.js → dom-renderer-BqGijQID.js} +3 -2
- package/dist/env-Cl8qmNFN.js +19 -0
- package/dist/experimental.cjs +2747 -509
- package/dist/experimental.d.cts +3 -0
- package/dist/experimental.d.ts +3 -0
- package/dist/experimental.js +9 -7519
- package/dist/frame-perf-C6Xfg85O.js +24 -0
- package/dist/{hyperlink-B5PD7a3Q.js → hyperlink-Bn02UXJb.js} +89 -1
- package/dist/index.cjs +4628 -618
- package/dist/index.d.cts +22 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +16 -12
- package/dist/linkify-D_gzn9Xq.js +562 -0
- package/dist/markdown.cjs +447 -118
- package/dist/markdown.d.cts +2 -1
- package/dist/markdown.d.ts +2 -1
- package/dist/markdown.js +34 -1493
- package/dist/observability/frame-perf-store.d.ts +5 -0
- package/dist/observability/perf-sink.d.ts +56 -0
- package/dist/observability.cjs +125 -3
- package/dist/observability.d.cts +2 -0
- package/dist/observability.d.ts +2 -0
- package/dist/observability.js +3 -2
- package/dist/{path-DDiSCXrQ.js → path-mnSgEpCm.js} +1 -19
- package/dist/{path-suggest-0Q2BDsuj.js → path-suggest-BNqcuE3-.js} +1 -1
- package/dist/renderer-dom.cjs +0 -6
- package/dist/renderer-dom.js +5 -4
- package/dist/{runtime-DtrcQidD.js → runtime-rfcZCyJq.js} +1 -1
- package/dist/runtime.cjs +4 -3
- package/dist/runtime.js +2 -2
- package/dist/selection/terminal-selection.d.ts +2 -1
- package/dist/{terminal-selection-BCOh9jsL.js → terminal-selection-DBinO6p5.js} +3 -2
- package/dist/tlog-theme-qPBt5rge.js +9254 -0
- package/dist/trace-CjzYeIxN.js +182 -0
- package/dist/utils/grapheme.d.ts +5 -0
- package/dist/vue/agent/view-models.d.ts +98 -0
- package/dist/vue/components/TAnchor.d.ts +7 -7
- package/dist/vue/components/TCommandPalette.d.ts +587 -0
- package/dist/vue/components/TDataTable.d.ts +367 -0
- package/dist/vue/components/TDebugOverlay.d.ts +1 -1
- package/dist/vue/components/TDialog.d.ts +16 -17
- package/dist/vue/components/TFeedback.d.ts +635 -0
- package/dist/vue/components/TForm.d.ts +1230 -0
- package/dist/vue/components/TInput.d.ts +50 -59
- package/dist/vue/components/TInputBox.d.ts +6 -6
- package/dist/vue/components/TJsonEditor.d.ts +4 -4
- package/dist/vue/components/TLink.d.ts +239 -0
- package/dist/vue/components/TLinkifyText.d.ts +141 -0
- package/dist/vue/components/TList.d.ts +5 -5
- package/dist/vue/components/TLogLinksPanel.d.ts +4 -4
- package/dist/vue/components/TLogMinimap.d.ts +10 -10
- package/dist/vue/components/TLogScrollbar.d.ts +12 -12
- package/dist/vue/components/TLogSearchBar.d.ts +7 -7
- package/dist/vue/components/TLogSearchResults.d.ts +6 -6
- package/dist/vue/components/TLogView.d.ts +54 -20
- package/dist/vue/components/TLogVirtualLinksPanel.d.ts +4 -4
- package/dist/vue/components/TLogVirtualSearchResults.d.ts +4 -4
- package/dist/vue/components/TMarkdownText.d.ts +3 -3
- package/dist/vue/components/TNavigation.d.ts +324 -0
- package/dist/vue/components/TOverlay.d.ts +366 -0
- package/dist/vue/components/TPanels.d.ts +244 -0
- package/dist/vue/components/TPathPicker.d.ts +22 -22
- package/dist/vue/components/TSelect.d.ts +140 -20
- package/dist/vue/components/TTable.d.ts +317 -0
- package/dist/vue/components/TText.d.ts +1 -1
- package/dist/vue/components/TThinkingView.d.ts +233 -0
- package/dist/vue/components/TToolCallView.d.ts +384 -0
- package/dist/vue/components/TTranscriptView.d.ts +221 -0
- package/dist/vue/components/TTree.d.ts +200 -0
- package/dist/vue/components/TUserMessageView.d.ts +344 -0
- package/dist/vue/components/TView.d.ts +11 -11
- package/dist/vue/components/TVirtualList.d.ts +5 -5
- package/dist/vue/components/TVirtualMarkdown.d.ts +6 -6
- package/dist/vue/components/TVirtualRows.d.ts +247 -0
- package/dist/vue/components/TerminalProvider.d.ts +23 -0
- package/dist/vue/components/link/host.d.ts +15 -0
- package/dist/vue/components/simple-utils.d.ts +5 -0
- package/dist/vue/index.d.ts +31 -1
- package/dist/vue/linkify.d.ts +11 -0
- package/dist/vue/markdown/document.d.ts +2 -0
- package/dist/vue/markdown/layout.d.ts +6 -1
- package/dist/vue/markdown/types.d.ts +12 -0
- package/dist/vue/overlay.d.ts +27 -0
- package/dist/vue/theme.d.ts +48 -0
- package/dist/vue/transcript/hit-regions.d.ts +2 -0
- package/dist/vue/transcript/layout.d.ts +20 -0
- package/dist/vue/transcript/plain-text.d.ts +2 -0
- package/dist/vue/transcript/types.d.ts +122 -0
- package/dist/vue/utils/row-scroll.d.ts +25 -0
- package/dist/vue/utils/text.d.ts +1 -0
- package/dist/vue.cjs +17210 -12424
- package/dist/vue.d.cts +0 -2
- package/dist/vue.d.ts +0 -2
- package/dist/vue.js +918 -27
- package/dist/{wheel-scroll-B-WlFuNB.js → wheel-scroll-vBRaQ7p-.js} +48 -43
- package/package.json +24 -4
- package/dist/frame-perf-C-w8mjJL.js +0 -98
- package/dist/style-cache-i0ZABZRq.js +0 -178
- /package/dist/{sgr-DMK2AvuT.js → sgr-BmzxEjAO.js} +0 -0
package/dist/vue.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./
|
|
3
|
-
import
|
|
4
|
-
import "./
|
|
5
|
-
import "./
|
|
6
|
-
import "./
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import "./
|
|
10
|
-
import
|
|
11
|
-
import "./
|
|
12
|
-
import
|
|
1
|
+
import "./create-terminal-C2oiWFJU.js";
|
|
2
|
+
import { charCellWidth } from "./hyperlink-Bn02UXJb.js";
|
|
3
|
+
import "./sgr-BmzxEjAO.js";
|
|
4
|
+
import "./ansi-palette-CNXqFciC.js";
|
|
5
|
+
import "./dom-renderer-BqGijQID.js";
|
|
6
|
+
import { EventZIndexContextKey, LayoutContextKey, RenderStackKey, TInputPluginsContextKey, TPathPickerProviderContextKey, VisibilityContextKey, applyWheelScroll, createWheelScrollState, injectionKey, intersectRect, padEndByCells$1 as padEndByCells, repeatChar, sanitizeInlineText, sanitizeTextBlock, sliceByCells, sliceByCellsRange, spaces, textCellWidth$1 as textCellWidth, translateRect, useLayout, useRenderNode, useRenderStack, useTerminal, useTerminalNode, useVisibility, wrapByCells } from "./wheel-scroll-vBRaQ7p-.js";
|
|
7
|
+
import { TView, createTheme, linkifyTextSegments, tuiDefaultTheme } from "./linkify-D_gzn9Xq.js";
|
|
8
|
+
import "./runtime-rfcZCyJq.js";
|
|
9
|
+
import "./trace-CjzYeIxN.js";
|
|
10
|
+
import "./env-Cl8qmNFN.js";
|
|
11
|
+
import { TAutocompleteInput, TBadge, TCheckbox, TCode, TDataTable, TDivider, TForm, TFormContextKey, TFormField, TLink, TLinkifyText, TList, TPasswordInput, TProgress, TRadioGroup, TSlider, TSpinner, TSwitch, TTable, TTag, TToastViewport, TTree, TerminalProvider, createTInputHostPlugin, useTForm } from "./TTree-DK_DQBYm.js";
|
|
12
|
+
import "./terminal-selection-DBinO6p5.js";
|
|
13
|
+
import { TBox, TCommandPalette, TDialog, TInput, TRenderPlane, TSelect, TText, clamp as clamp$1, clamp$1 as clamp, computeCommandPaletteMatchRanges, createOverlayFocusStack, fitCellText, isCommitMention, isWhitespace, mentionChipStyle, mergeStyle, padEndByCells as padEndByCells$1, resolveOverlayPlacement, sliceByCellsWindow, textCellWidth as textCellWidth$1 } from "./TSelect-BwJJbuTt.js";
|
|
14
|
+
import "./frame-perf-C6Xfg85O.js";
|
|
15
|
+
import { normalizePath, stripTrailingSlash } from "./path-mnSgEpCm.js";
|
|
16
|
+
import { parsePathQuery, resolveUserPath, suggestPaths } from "./path-suggest-BNqcuE3-.js";
|
|
13
17
|
import { computed, defineComponent, h, inject, onBeforeUnmount, onMounted, onUnmounted, provide, reactive, ref, shallowReactive, shallowRef, watch, watchEffect } from "vue";
|
|
14
18
|
|
|
15
19
|
//#region src/observability/cli-latency.ts
|
|
@@ -492,7 +496,7 @@ function writeHighlightedText$1(opts) {
|
|
|
492
496
|
y,
|
|
493
497
|
style: currentStyle
|
|
494
498
|
});
|
|
495
|
-
cursorX += textCellWidth(buffer);
|
|
499
|
+
cursorX += textCellWidth$1(buffer);
|
|
496
500
|
buffer = "";
|
|
497
501
|
};
|
|
498
502
|
for (let i = 0; i < text.length && cellPos < safeMax;) {
|
|
@@ -949,8 +953,8 @@ function createPromptMentionPlugin(options = {}) {
|
|
|
949
953
|
const rawValue = sanitizeInlineText(match.item.value);
|
|
950
954
|
const rawDetail = match.item.detail ? sanitizeInlineText(match.item.detail) : "";
|
|
951
955
|
const highlightRanges = query ? computeHighlightRanges$1(rawValue, query) : [];
|
|
952
|
-
const valueCells = textCellWidth(rawValue);
|
|
953
|
-
const detailCells = rawDetail ? textCellWidth(rawDetail) : 0;
|
|
956
|
+
const valueCells = textCellWidth$1(rawValue);
|
|
957
|
+
const detailCells = rawDetail ? textCellWidth$1(rawDetail) : 0;
|
|
954
958
|
const minGap = 2;
|
|
955
959
|
const availableForDetail = contentW - valueCells - minGap;
|
|
956
960
|
if (rawDetail && availableForDetail >= 4) {
|
|
@@ -1026,7 +1030,7 @@ function createPromptMentionPlugin(options = {}) {
|
|
|
1026
1030
|
const y = y0 + 1;
|
|
1027
1031
|
ctx.terminal.put(x0, y, "│", borderStyle);
|
|
1028
1032
|
ctx.terminal.put(x0 + w - 1, y, "│", borderStyle);
|
|
1029
|
-
const msg = padEndByCells(sliceByCellsWindow("(no matches)", 0, contentW), contentW);
|
|
1033
|
+
const msg = padEndByCells$1(sliceByCellsWindow("(no matches)", 0, contentW), contentW);
|
|
1030
1034
|
if (sidePad > 0) ctx.terminal.write(spaces(sidePad), {
|
|
1031
1035
|
x: x0 + 1,
|
|
1032
1036
|
y,
|
|
@@ -1516,6 +1520,350 @@ const TFlow = defineComponent({
|
|
|
1516
1520
|
}
|
|
1517
1521
|
});
|
|
1518
1522
|
|
|
1523
|
+
//#endregion
|
|
1524
|
+
//#region src/vue/components/TPanels.ts
|
|
1525
|
+
function normalizeCellCount(value) {
|
|
1526
|
+
const n = Math.floor(Number(value));
|
|
1527
|
+
return Number.isFinite(n) ? Math.max(0, n) : 0;
|
|
1528
|
+
}
|
|
1529
|
+
function normalizePaneSize(value, fallback = 0) {
|
|
1530
|
+
const n = Math.floor(Number(value));
|
|
1531
|
+
if (Number.isFinite(n)) return Math.max(0, n);
|
|
1532
|
+
return normalizeCellCount(fallback);
|
|
1533
|
+
}
|
|
1534
|
+
function findEnabledTabIndex(items, start, delta) {
|
|
1535
|
+
const total = items.length;
|
|
1536
|
+
if (total <= 0) return null;
|
|
1537
|
+
for (let step = 1; step <= total; step++) {
|
|
1538
|
+
const index = (start + step * delta + total) % total;
|
|
1539
|
+
if (!items[index]?.disabled) return index;
|
|
1540
|
+
}
|
|
1541
|
+
return null;
|
|
1542
|
+
}
|
|
1543
|
+
function edgeEnabledTabIndex(items, edge) {
|
|
1544
|
+
if (edge === "first") {
|
|
1545
|
+
for (let index = 0; index < items.length; index++) if (!items[index]?.disabled) return index;
|
|
1546
|
+
return null;
|
|
1547
|
+
}
|
|
1548
|
+
for (let index = items.length - 1; index >= 0; index--) if (!items[index]?.disabled) return index;
|
|
1549
|
+
return null;
|
|
1550
|
+
}
|
|
1551
|
+
const TTabs = defineComponent({
|
|
1552
|
+
name: "TTabs",
|
|
1553
|
+
props: {
|
|
1554
|
+
x: {
|
|
1555
|
+
type: Number,
|
|
1556
|
+
required: true
|
|
1557
|
+
},
|
|
1558
|
+
y: {
|
|
1559
|
+
type: Number,
|
|
1560
|
+
required: true
|
|
1561
|
+
},
|
|
1562
|
+
w: {
|
|
1563
|
+
type: Number,
|
|
1564
|
+
required: true
|
|
1565
|
+
},
|
|
1566
|
+
zIndex: {
|
|
1567
|
+
type: Number,
|
|
1568
|
+
default: 0
|
|
1569
|
+
},
|
|
1570
|
+
items: {
|
|
1571
|
+
type: Array,
|
|
1572
|
+
required: true
|
|
1573
|
+
},
|
|
1574
|
+
activeKey: {
|
|
1575
|
+
type: String,
|
|
1576
|
+
required: true
|
|
1577
|
+
},
|
|
1578
|
+
style: {
|
|
1579
|
+
type: Object,
|
|
1580
|
+
default: void 0
|
|
1581
|
+
},
|
|
1582
|
+
activeStyle: {
|
|
1583
|
+
type: Object,
|
|
1584
|
+
default: () => ({ inverse: true })
|
|
1585
|
+
},
|
|
1586
|
+
disabledStyle: {
|
|
1587
|
+
type: Object,
|
|
1588
|
+
default: () => ({ dim: true })
|
|
1589
|
+
}
|
|
1590
|
+
},
|
|
1591
|
+
emits: {
|
|
1592
|
+
"update:activeKey": (_key) => true,
|
|
1593
|
+
change: (_item) => true
|
|
1594
|
+
},
|
|
1595
|
+
setup(props, { emit }) {
|
|
1596
|
+
const { defaultStyle } = useTerminal();
|
|
1597
|
+
const focusedKey = ref(null);
|
|
1598
|
+
const baseStyle = computed(() => mergeStyle(defaultStyle.value, props.style));
|
|
1599
|
+
function activate(item) {
|
|
1600
|
+
if (item.disabled) return;
|
|
1601
|
+
if (item.key === props.activeKey) return;
|
|
1602
|
+
emit("update:activeKey", item.key);
|
|
1603
|
+
emit("change", item);
|
|
1604
|
+
}
|
|
1605
|
+
function enabledTabIndexByKey(key) {
|
|
1606
|
+
if (!key) return -1;
|
|
1607
|
+
return props.items.findIndex((item) => item.key === key && !item.disabled);
|
|
1608
|
+
}
|
|
1609
|
+
function activateIndex(index, opts = {}) {
|
|
1610
|
+
const item = props.items[index];
|
|
1611
|
+
if (!item) return;
|
|
1612
|
+
if (opts.trackFocus && !item.disabled) focusedKey.value = item.key;
|
|
1613
|
+
activate(item);
|
|
1614
|
+
}
|
|
1615
|
+
function navigationBaseIndex(fallbackIndex) {
|
|
1616
|
+
const activeIndex = enabledTabIndexByKey(props.activeKey);
|
|
1617
|
+
return activeIndex >= 0 ? activeIndex : fallbackIndex;
|
|
1618
|
+
}
|
|
1619
|
+
function activationBaseIndex(fallbackIndex) {
|
|
1620
|
+
const focusedIndex = enabledTabIndexByKey(focusedKey.value);
|
|
1621
|
+
return focusedIndex >= 0 ? focusedIndex : fallbackIndex;
|
|
1622
|
+
}
|
|
1623
|
+
function onTabKeydown(event, index) {
|
|
1624
|
+
const key = event?.key;
|
|
1625
|
+
if (key === "Enter" || key === " ") {
|
|
1626
|
+
event.preventDefault?.();
|
|
1627
|
+
activateIndex(activationBaseIndex(index));
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1630
|
+
const baseIndex = navigationBaseIndex(index);
|
|
1631
|
+
const next = key === "ArrowRight" ? findEnabledTabIndex(props.items, baseIndex, 1) : key === "ArrowLeft" ? findEnabledTabIndex(props.items, baseIndex, -1) : key === "Home" ? edgeEnabledTabIndex(props.items, "first") : key === "End" ? edgeEnabledTabIndex(props.items, "last") : null;
|
|
1632
|
+
if (next == null) return;
|
|
1633
|
+
event.preventDefault?.();
|
|
1634
|
+
activateIndex(next, { trackFocus: true });
|
|
1635
|
+
}
|
|
1636
|
+
return () => {
|
|
1637
|
+
const width = normalizeCellCount(props.w);
|
|
1638
|
+
let x = 0;
|
|
1639
|
+
const children = [h(TText, {
|
|
1640
|
+
x: 0,
|
|
1641
|
+
y: 0,
|
|
1642
|
+
w: width,
|
|
1643
|
+
value: " ".repeat(width),
|
|
1644
|
+
style: baseStyle.value
|
|
1645
|
+
})];
|
|
1646
|
+
for (let index = 0; index < props.items.length; index++) {
|
|
1647
|
+
const item = props.items[index];
|
|
1648
|
+
const label = item.badge == null ? item.label : `${item.label} ${item.badge}`;
|
|
1649
|
+
const text = ` ${label} `;
|
|
1650
|
+
const itemWidth = Math.min(width - x, textCellWidth(text));
|
|
1651
|
+
if (itemWidth <= 0) break;
|
|
1652
|
+
const active = item.key === props.activeKey;
|
|
1653
|
+
children.push(h(TText, {
|
|
1654
|
+
key: `text:${item.key}`,
|
|
1655
|
+
x,
|
|
1656
|
+
y: 0,
|
|
1657
|
+
w: itemWidth,
|
|
1658
|
+
value: fitCellText(text, itemWidth),
|
|
1659
|
+
style: item.disabled ? mergeStyle(baseStyle.value, props.disabledStyle) : active ? mergeStyle(baseStyle.value, props.activeStyle) : baseStyle.value
|
|
1660
|
+
}), h(TView, {
|
|
1661
|
+
key: `hit:${item.key}`,
|
|
1662
|
+
x,
|
|
1663
|
+
y: 0,
|
|
1664
|
+
w: itemWidth,
|
|
1665
|
+
h: 1,
|
|
1666
|
+
focusable: !item.disabled,
|
|
1667
|
+
onClick: () => {
|
|
1668
|
+
if (!item.disabled) focusedKey.value = item.key;
|
|
1669
|
+
activate(item);
|
|
1670
|
+
},
|
|
1671
|
+
onFocus: () => {
|
|
1672
|
+
if (!item.disabled) focusedKey.value = item.key;
|
|
1673
|
+
},
|
|
1674
|
+
onKeydown: (event) => onTabKeydown(event, index)
|
|
1675
|
+
}));
|
|
1676
|
+
x += itemWidth;
|
|
1677
|
+
}
|
|
1678
|
+
return h(TView, {
|
|
1679
|
+
x: props.x,
|
|
1680
|
+
y: props.y,
|
|
1681
|
+
w: width,
|
|
1682
|
+
h: 1,
|
|
1683
|
+
zIndex: props.zIndex
|
|
1684
|
+
}, () => children);
|
|
1685
|
+
};
|
|
1686
|
+
}
|
|
1687
|
+
});
|
|
1688
|
+
function resolvePaneSizes(sizes, minSizes, available) {
|
|
1689
|
+
const count = sizes.length;
|
|
1690
|
+
if (count === 0) return [];
|
|
1691
|
+
if (available <= 0) return sizes.map(() => 0);
|
|
1692
|
+
const mins = sizes.map((_, index) => normalizePaneSize(minSizes[index], 1));
|
|
1693
|
+
const minTotal = mins.reduce((sum, min) => sum + min, 0);
|
|
1694
|
+
if (minTotal >= available) {
|
|
1695
|
+
if (minTotal === 0) return sizes.map(() => 0);
|
|
1696
|
+
const out$1 = mins.map((min) => Math.floor(available * min / minTotal));
|
|
1697
|
+
let remaining = available - out$1.reduce((sum, size) => sum + size, 0);
|
|
1698
|
+
const order = mins.map((min, index) => ({
|
|
1699
|
+
index,
|
|
1700
|
+
fraction: available * min / minTotal - Math.floor(available * min / minTotal)
|
|
1701
|
+
})).sort((a, b) => b.fraction - a.fraction || a.index - b.index);
|
|
1702
|
+
for (let i = 0; remaining > 0 && i < order.length; i++, remaining--) out$1[order[i].index] += 1;
|
|
1703
|
+
return out$1;
|
|
1704
|
+
}
|
|
1705
|
+
const out = sizes.map((size, index) => Math.max(mins[index], normalizePaneSize(size, mins[index])));
|
|
1706
|
+
const used = out.reduce((sum, size) => sum + size, 0);
|
|
1707
|
+
if (used > available) {
|
|
1708
|
+
let overflow = used - available;
|
|
1709
|
+
for (let i = out.length - 1; i >= 0 && overflow > 0; i--) {
|
|
1710
|
+
const shrink = Math.min(out[i] - mins[i], overflow);
|
|
1711
|
+
out[i] -= shrink;
|
|
1712
|
+
overflow -= shrink;
|
|
1713
|
+
}
|
|
1714
|
+
return out;
|
|
1715
|
+
}
|
|
1716
|
+
if (used < available) out[out.length - 1] += available - used;
|
|
1717
|
+
return out;
|
|
1718
|
+
}
|
|
1719
|
+
const TSplitPane = defineComponent({
|
|
1720
|
+
name: "TSplitPane",
|
|
1721
|
+
props: {
|
|
1722
|
+
x: {
|
|
1723
|
+
type: Number,
|
|
1724
|
+
required: true
|
|
1725
|
+
},
|
|
1726
|
+
y: {
|
|
1727
|
+
type: Number,
|
|
1728
|
+
required: true
|
|
1729
|
+
},
|
|
1730
|
+
w: {
|
|
1731
|
+
type: Number,
|
|
1732
|
+
required: true
|
|
1733
|
+
},
|
|
1734
|
+
h: {
|
|
1735
|
+
type: Number,
|
|
1736
|
+
required: true
|
|
1737
|
+
},
|
|
1738
|
+
zIndex: {
|
|
1739
|
+
type: Number,
|
|
1740
|
+
default: 0
|
|
1741
|
+
},
|
|
1742
|
+
direction: {
|
|
1743
|
+
type: String,
|
|
1744
|
+
default: "horizontal"
|
|
1745
|
+
},
|
|
1746
|
+
sizes: {
|
|
1747
|
+
type: Array,
|
|
1748
|
+
required: true
|
|
1749
|
+
},
|
|
1750
|
+
minSizes: {
|
|
1751
|
+
type: Array,
|
|
1752
|
+
default: () => []
|
|
1753
|
+
},
|
|
1754
|
+
separatorStyle: {
|
|
1755
|
+
type: Object,
|
|
1756
|
+
default: () => ({ dim: true })
|
|
1757
|
+
}
|
|
1758
|
+
},
|
|
1759
|
+
emits: {
|
|
1760
|
+
"update:sizes": (_sizes) => true,
|
|
1761
|
+
resize: (_sizes) => true
|
|
1762
|
+
},
|
|
1763
|
+
setup(props, { emit, slots }) {
|
|
1764
|
+
const { defaultStyle } = useTerminal();
|
|
1765
|
+
const panes = computed(() => {
|
|
1766
|
+
const width = normalizeCellCount(props.w);
|
|
1767
|
+
const height = normalizeCellCount(props.h);
|
|
1768
|
+
const sizes = props.sizes.length ? props.sizes : [1];
|
|
1769
|
+
const count = Math.max(1, sizes.length);
|
|
1770
|
+
const total = props.direction === "horizontal" ? width : height;
|
|
1771
|
+
const separatorTotal = Math.max(0, count - 1);
|
|
1772
|
+
const available = Math.max(0, total - separatorTotal);
|
|
1773
|
+
const paneSizes = resolvePaneSizes(sizes, props.minSizes, available);
|
|
1774
|
+
let cursor = 0;
|
|
1775
|
+
return paneSizes.map((paneSize) => {
|
|
1776
|
+
const rect = props.direction === "horizontal" ? {
|
|
1777
|
+
x: cursor,
|
|
1778
|
+
y: 0,
|
|
1779
|
+
w: paneSize,
|
|
1780
|
+
h: height
|
|
1781
|
+
} : {
|
|
1782
|
+
x: 0,
|
|
1783
|
+
y: cursor,
|
|
1784
|
+
w: width,
|
|
1785
|
+
h: paneSize
|
|
1786
|
+
};
|
|
1787
|
+
cursor += paneSize + 1;
|
|
1788
|
+
return rect;
|
|
1789
|
+
});
|
|
1790
|
+
});
|
|
1791
|
+
function resizeAt(index, delta) {
|
|
1792
|
+
const count = Math.max(1, props.sizes.length);
|
|
1793
|
+
const total = props.direction === "horizontal" ? normalizeCellCount(props.w) : normalizeCellCount(props.h);
|
|
1794
|
+
const separatorTotal = Math.max(0, count - 1);
|
|
1795
|
+
const available = Math.max(0, total - separatorTotal);
|
|
1796
|
+
const sizes = props.sizes.length ? props.sizes : [1];
|
|
1797
|
+
const next = resolvePaneSizes(sizes, props.minSizes, available);
|
|
1798
|
+
if (index < 0 || index >= next.length - 1) return;
|
|
1799
|
+
const left0 = next[index];
|
|
1800
|
+
const right0 = next[index + 1];
|
|
1801
|
+
const leftMin = normalizePaneSize(props.minSizes[index], 1);
|
|
1802
|
+
const rightMin = normalizePaneSize(props.minSizes[index + 1], 1);
|
|
1803
|
+
const applied = Math.max(leftMin - left0, Math.min(right0 - rightMin, delta));
|
|
1804
|
+
next[index] = left0 + applied;
|
|
1805
|
+
next[index + 1] = right0 - applied;
|
|
1806
|
+
emit("update:sizes", next);
|
|
1807
|
+
emit("resize", next);
|
|
1808
|
+
}
|
|
1809
|
+
return () => {
|
|
1810
|
+
const paneChildren = slots.default?.({ panes: panes.value }) ?? [];
|
|
1811
|
+
const separatorChildren = panes.value.slice(0, -1).map((pane, index) => {
|
|
1812
|
+
const separator = props.direction === "horizontal" ? {
|
|
1813
|
+
x: pane.x + pane.w,
|
|
1814
|
+
y: 0,
|
|
1815
|
+
w: 1,
|
|
1816
|
+
h: pane.h,
|
|
1817
|
+
text: "|"
|
|
1818
|
+
} : {
|
|
1819
|
+
x: 0,
|
|
1820
|
+
y: pane.y + pane.h,
|
|
1821
|
+
w: pane.w,
|
|
1822
|
+
h: 1,
|
|
1823
|
+
text: "-".repeat(pane.w)
|
|
1824
|
+
};
|
|
1825
|
+
return h(TView, {
|
|
1826
|
+
key: `separator:${index}`,
|
|
1827
|
+
x: separator.x,
|
|
1828
|
+
y: separator.y,
|
|
1829
|
+
w: separator.w,
|
|
1830
|
+
h: separator.h,
|
|
1831
|
+
focusable: true,
|
|
1832
|
+
onKeydown: (event) => {
|
|
1833
|
+
const forward = props.direction === "horizontal" ? event.key === "ArrowRight" : event.key === "ArrowDown";
|
|
1834
|
+
const backward = props.direction === "horizontal" ? event.key === "ArrowLeft" : event.key === "ArrowUp";
|
|
1835
|
+
if (!forward && !backward) return;
|
|
1836
|
+
event.preventDefault?.();
|
|
1837
|
+
resizeAt(index, forward ? 1 : -1);
|
|
1838
|
+
}
|
|
1839
|
+
}, () => props.direction === "horizontal" ? Array.from({ length: separator.h }, (_, row) => h(TText, {
|
|
1840
|
+
key: `separator-line:${row}`,
|
|
1841
|
+
x: 0,
|
|
1842
|
+
y: row,
|
|
1843
|
+
w: 1,
|
|
1844
|
+
value: separator.text,
|
|
1845
|
+
style: mergeStyle(defaultStyle.value, props.separatorStyle)
|
|
1846
|
+
})) : h(TText, {
|
|
1847
|
+
x: 0,
|
|
1848
|
+
y: 0,
|
|
1849
|
+
w: separator.w,
|
|
1850
|
+
h: separator.h,
|
|
1851
|
+
value: separator.text,
|
|
1852
|
+
style: mergeStyle(defaultStyle.value, props.separatorStyle)
|
|
1853
|
+
}));
|
|
1854
|
+
});
|
|
1855
|
+
const children = [...paneChildren, ...separatorChildren];
|
|
1856
|
+
return h(TView, {
|
|
1857
|
+
x: props.x,
|
|
1858
|
+
y: props.y,
|
|
1859
|
+
w: normalizeCellCount(props.w),
|
|
1860
|
+
h: normalizeCellCount(props.h),
|
|
1861
|
+
zIndex: props.zIndex
|
|
1862
|
+
}, () => children);
|
|
1863
|
+
};
|
|
1864
|
+
}
|
|
1865
|
+
});
|
|
1866
|
+
|
|
1519
1867
|
//#endregion
|
|
1520
1868
|
//#region src/vue/components/TInputBox.ts
|
|
1521
1869
|
const TInputBox = defineComponent({
|
|
@@ -2156,7 +2504,7 @@ const TMultilineModal = defineComponent({
|
|
|
2156
2504
|
const lineIndex = startLine + row;
|
|
2157
2505
|
const line = lines[lineIndex] ?? "";
|
|
2158
2506
|
const visible = sliceByCells(line, innerW);
|
|
2159
|
-
const padded = padEndByCells
|
|
2507
|
+
const padded = padEndByCells(visible, innerW);
|
|
2160
2508
|
terminal.write(padded, {
|
|
2161
2509
|
x: r.x + 1,
|
|
2162
2510
|
y: r.y + 1 + row,
|
|
@@ -2169,9 +2517,552 @@ const TMultilineModal = defineComponent({
|
|
|
2169
2517
|
}
|
|
2170
2518
|
});
|
|
2171
2519
|
|
|
2520
|
+
//#endregion
|
|
2521
|
+
//#region src/vue/components/TNavigation.ts
|
|
2522
|
+
const TKeyHint = defineComponent({
|
|
2523
|
+
name: "TKeyHint",
|
|
2524
|
+
props: {
|
|
2525
|
+
x: {
|
|
2526
|
+
type: Number,
|
|
2527
|
+
required: true
|
|
2528
|
+
},
|
|
2529
|
+
y: {
|
|
2530
|
+
type: Number,
|
|
2531
|
+
required: true
|
|
2532
|
+
},
|
|
2533
|
+
w: {
|
|
2534
|
+
type: Number,
|
|
2535
|
+
default: void 0
|
|
2536
|
+
},
|
|
2537
|
+
zIndex: {
|
|
2538
|
+
type: Number,
|
|
2539
|
+
default: 0
|
|
2540
|
+
},
|
|
2541
|
+
combo: {
|
|
2542
|
+
type: String,
|
|
2543
|
+
required: true
|
|
2544
|
+
},
|
|
2545
|
+
label: {
|
|
2546
|
+
type: String,
|
|
2547
|
+
required: true
|
|
2548
|
+
},
|
|
2549
|
+
style: {
|
|
2550
|
+
type: Object,
|
|
2551
|
+
default: void 0
|
|
2552
|
+
},
|
|
2553
|
+
comboStyle: {
|
|
2554
|
+
type: Object,
|
|
2555
|
+
default: () => ({ inverse: true })
|
|
2556
|
+
}
|
|
2557
|
+
},
|
|
2558
|
+
setup(props) {
|
|
2559
|
+
const { defaultStyle } = useTerminal();
|
|
2560
|
+
const baseStyle = computed(() => mergeStyle(defaultStyle.value, props.style));
|
|
2561
|
+
const comboStyle = computed(() => mergeStyle(baseStyle.value, props.comboStyle));
|
|
2562
|
+
return () => {
|
|
2563
|
+
const comboW = textCellWidth(props.combo);
|
|
2564
|
+
const gap = props.label ? 1 : 0;
|
|
2565
|
+
const comboRenderW = props.w == null ? comboW : Math.min(comboW, Math.max(0, props.w));
|
|
2566
|
+
const gapW = props.w == null ? gap : Math.min(gap, Math.max(0, props.w - comboW));
|
|
2567
|
+
const labelW = props.w == null ? void 0 : Math.max(0, props.w - comboW - gap);
|
|
2568
|
+
const children = [h(TText, {
|
|
2569
|
+
x: props.x,
|
|
2570
|
+
y: props.y,
|
|
2571
|
+
zIndex: props.zIndex,
|
|
2572
|
+
w: comboRenderW,
|
|
2573
|
+
value: props.combo,
|
|
2574
|
+
style: comboStyle.value
|
|
2575
|
+
})];
|
|
2576
|
+
if (gapW > 0) children.push(h(TText, {
|
|
2577
|
+
x: props.x + comboW,
|
|
2578
|
+
y: props.y,
|
|
2579
|
+
zIndex: props.zIndex,
|
|
2580
|
+
w: gapW,
|
|
2581
|
+
value: " ",
|
|
2582
|
+
style: baseStyle.value
|
|
2583
|
+
}));
|
|
2584
|
+
children.push(h(TText, {
|
|
2585
|
+
x: props.x + comboW + gap,
|
|
2586
|
+
y: props.y,
|
|
2587
|
+
zIndex: props.zIndex,
|
|
2588
|
+
w: labelW,
|
|
2589
|
+
value: props.label,
|
|
2590
|
+
style: baseStyle.value
|
|
2591
|
+
}));
|
|
2592
|
+
return children;
|
|
2593
|
+
};
|
|
2594
|
+
}
|
|
2595
|
+
});
|
|
2596
|
+
const TBreadcrumb = defineComponent({
|
|
2597
|
+
name: "TBreadcrumb",
|
|
2598
|
+
props: {
|
|
2599
|
+
x: {
|
|
2600
|
+
type: Number,
|
|
2601
|
+
required: true
|
|
2602
|
+
},
|
|
2603
|
+
y: {
|
|
2604
|
+
type: Number,
|
|
2605
|
+
required: true
|
|
2606
|
+
},
|
|
2607
|
+
w: {
|
|
2608
|
+
type: Number,
|
|
2609
|
+
required: true
|
|
2610
|
+
},
|
|
2611
|
+
zIndex: {
|
|
2612
|
+
type: Number,
|
|
2613
|
+
default: 0
|
|
2614
|
+
},
|
|
2615
|
+
items: {
|
|
2616
|
+
type: Array,
|
|
2617
|
+
required: true
|
|
2618
|
+
},
|
|
2619
|
+
separator: {
|
|
2620
|
+
type: String,
|
|
2621
|
+
default: "/"
|
|
2622
|
+
},
|
|
2623
|
+
style: {
|
|
2624
|
+
type: Object,
|
|
2625
|
+
default: void 0
|
|
2626
|
+
},
|
|
2627
|
+
activeStyle: {
|
|
2628
|
+
type: Object,
|
|
2629
|
+
default: () => ({ bold: true })
|
|
2630
|
+
},
|
|
2631
|
+
disabledStyle: {
|
|
2632
|
+
type: Object,
|
|
2633
|
+
default: () => ({ dim: true })
|
|
2634
|
+
}
|
|
2635
|
+
},
|
|
2636
|
+
emits: { select: (_payload) => true },
|
|
2637
|
+
setup(props, { emit }) {
|
|
2638
|
+
const { defaultStyle } = useTerminal();
|
|
2639
|
+
const baseStyle = computed(() => mergeStyle(defaultStyle.value, props.style));
|
|
2640
|
+
return () => {
|
|
2641
|
+
let x = 0;
|
|
2642
|
+
const children = [];
|
|
2643
|
+
for (let index = 0; index < props.items.length; index++) {
|
|
2644
|
+
const item = props.items[index];
|
|
2645
|
+
const suffix = index < props.items.length - 1 ? ` ${props.separator} ` : "";
|
|
2646
|
+
const text = `${item.label}${suffix}`;
|
|
2647
|
+
const remaining = props.w - x;
|
|
2648
|
+
const cellW = textCellWidth(text);
|
|
2649
|
+
const w = Math.min(remaining, cellW);
|
|
2650
|
+
if (w <= 0) break;
|
|
2651
|
+
children.push(h(TView, {
|
|
2652
|
+
key: item.id,
|
|
2653
|
+
x,
|
|
2654
|
+
y: 0,
|
|
2655
|
+
w,
|
|
2656
|
+
h: 1,
|
|
2657
|
+
focusable: !item.disabled,
|
|
2658
|
+
onClick: () => {
|
|
2659
|
+
if (!item.disabled) emit("select", {
|
|
2660
|
+
item,
|
|
2661
|
+
index
|
|
2662
|
+
});
|
|
2663
|
+
},
|
|
2664
|
+
onKeydown: (event) => {
|
|
2665
|
+
if (item.disabled || event.key !== "Enter" && event.key !== " ") return;
|
|
2666
|
+
event.preventDefault?.();
|
|
2667
|
+
emit("select", {
|
|
2668
|
+
item,
|
|
2669
|
+
index
|
|
2670
|
+
});
|
|
2671
|
+
}
|
|
2672
|
+
}, () => h(TText, {
|
|
2673
|
+
x: 0,
|
|
2674
|
+
y: 0,
|
|
2675
|
+
w,
|
|
2676
|
+
value: fitCellText(text, w),
|
|
2677
|
+
style: item.disabled ? mergeStyle(baseStyle.value, props.disabledStyle) : index === props.items.length - 1 ? mergeStyle(baseStyle.value, props.activeStyle) : baseStyle.value
|
|
2678
|
+
})));
|
|
2679
|
+
x += w;
|
|
2680
|
+
if (w < cellW) break;
|
|
2681
|
+
}
|
|
2682
|
+
return h(TView, {
|
|
2683
|
+
x: props.x,
|
|
2684
|
+
y: props.y,
|
|
2685
|
+
w: props.w,
|
|
2686
|
+
h: 1,
|
|
2687
|
+
zIndex: props.zIndex
|
|
2688
|
+
}, () => children);
|
|
2689
|
+
};
|
|
2690
|
+
}
|
|
2691
|
+
});
|
|
2692
|
+
const TStatusBar = defineComponent({
|
|
2693
|
+
name: "TStatusBar",
|
|
2694
|
+
props: {
|
|
2695
|
+
x: {
|
|
2696
|
+
type: Number,
|
|
2697
|
+
required: true
|
|
2698
|
+
},
|
|
2699
|
+
y: {
|
|
2700
|
+
type: Number,
|
|
2701
|
+
required: true
|
|
2702
|
+
},
|
|
2703
|
+
w: {
|
|
2704
|
+
type: Number,
|
|
2705
|
+
required: true
|
|
2706
|
+
},
|
|
2707
|
+
zIndex: {
|
|
2708
|
+
type: Number,
|
|
2709
|
+
default: 0
|
|
2710
|
+
},
|
|
2711
|
+
left: {
|
|
2712
|
+
type: String,
|
|
2713
|
+
default: ""
|
|
2714
|
+
},
|
|
2715
|
+
center: {
|
|
2716
|
+
type: String,
|
|
2717
|
+
default: ""
|
|
2718
|
+
},
|
|
2719
|
+
right: {
|
|
2720
|
+
type: String,
|
|
2721
|
+
default: ""
|
|
2722
|
+
},
|
|
2723
|
+
style: {
|
|
2724
|
+
type: Object,
|
|
2725
|
+
default: () => ({ inverse: true })
|
|
2726
|
+
}
|
|
2727
|
+
},
|
|
2728
|
+
setup(props, { slots }) {
|
|
2729
|
+
const { defaultStyle } = useTerminal();
|
|
2730
|
+
const baseStyle = computed(() => mergeStyle(defaultStyle.value, props.style));
|
|
2731
|
+
return () => {
|
|
2732
|
+
const children = slots.default?.();
|
|
2733
|
+
if (children?.length) return h(TView, {
|
|
2734
|
+
x: props.x,
|
|
2735
|
+
y: props.y,
|
|
2736
|
+
w: props.w,
|
|
2737
|
+
h: 1,
|
|
2738
|
+
zIndex: props.zIndex
|
|
2739
|
+
}, () => children);
|
|
2740
|
+
const leftW = Math.max(0, Math.floor(props.w / 3));
|
|
2741
|
+
const rightW = leftW;
|
|
2742
|
+
const centerW = Math.max(0, props.w - leftW - rightW);
|
|
2743
|
+
return h(TView, {
|
|
2744
|
+
x: props.x,
|
|
2745
|
+
y: props.y,
|
|
2746
|
+
w: props.w,
|
|
2747
|
+
h: 1,
|
|
2748
|
+
zIndex: props.zIndex
|
|
2749
|
+
}, () => [
|
|
2750
|
+
h(TText, {
|
|
2751
|
+
x: 0,
|
|
2752
|
+
y: 0,
|
|
2753
|
+
w: leftW,
|
|
2754
|
+
value: props.left,
|
|
2755
|
+
style: baseStyle.value
|
|
2756
|
+
}),
|
|
2757
|
+
h(TText, {
|
|
2758
|
+
x: leftW,
|
|
2759
|
+
y: 0,
|
|
2760
|
+
w: centerW,
|
|
2761
|
+
value: props.center,
|
|
2762
|
+
style: baseStyle.value
|
|
2763
|
+
}),
|
|
2764
|
+
h(TText, {
|
|
2765
|
+
x: leftW + centerW,
|
|
2766
|
+
y: 0,
|
|
2767
|
+
w: rightW,
|
|
2768
|
+
value: props.right,
|
|
2769
|
+
style: baseStyle.value
|
|
2770
|
+
})
|
|
2771
|
+
]);
|
|
2772
|
+
};
|
|
2773
|
+
}
|
|
2774
|
+
});
|
|
2775
|
+
|
|
2776
|
+
//#endregion
|
|
2777
|
+
//#region src/vue/components/TOverlay.ts
|
|
2778
|
+
const TContextMenu = defineComponent({
|
|
2779
|
+
name: "TContextMenu",
|
|
2780
|
+
props: {
|
|
2781
|
+
modelValue: {
|
|
2782
|
+
type: Boolean,
|
|
2783
|
+
required: true
|
|
2784
|
+
},
|
|
2785
|
+
x: {
|
|
2786
|
+
type: Number,
|
|
2787
|
+
required: true
|
|
2788
|
+
},
|
|
2789
|
+
y: {
|
|
2790
|
+
type: Number,
|
|
2791
|
+
required: true
|
|
2792
|
+
},
|
|
2793
|
+
w: {
|
|
2794
|
+
type: Number,
|
|
2795
|
+
default: 24
|
|
2796
|
+
},
|
|
2797
|
+
zIndex: {
|
|
2798
|
+
type: Number,
|
|
2799
|
+
default: 20
|
|
2800
|
+
},
|
|
2801
|
+
items: {
|
|
2802
|
+
type: Array,
|
|
2803
|
+
required: true
|
|
2804
|
+
},
|
|
2805
|
+
selectedIndex: {
|
|
2806
|
+
type: Number,
|
|
2807
|
+
default: void 0
|
|
2808
|
+
},
|
|
2809
|
+
closeOnOutside: {
|
|
2810
|
+
type: Boolean,
|
|
2811
|
+
default: true
|
|
2812
|
+
},
|
|
2813
|
+
style: {
|
|
2814
|
+
type: Object,
|
|
2815
|
+
default: void 0
|
|
2816
|
+
},
|
|
2817
|
+
activeStyle: {
|
|
2818
|
+
type: Object,
|
|
2819
|
+
default: () => ({ inverse: true })
|
|
2820
|
+
},
|
|
2821
|
+
disabledStyle: {
|
|
2822
|
+
type: Object,
|
|
2823
|
+
default: () => ({ dim: true })
|
|
2824
|
+
}
|
|
2825
|
+
},
|
|
2826
|
+
emits: {
|
|
2827
|
+
"update:modelValue": (_value) => true,
|
|
2828
|
+
"update:selectedIndex": (_index) => true,
|
|
2829
|
+
select: (_payload) => true,
|
|
2830
|
+
close: () => true
|
|
2831
|
+
},
|
|
2832
|
+
setup(props, { emit }) {
|
|
2833
|
+
const { terminal, defaultStyle } = useTerminal();
|
|
2834
|
+
const innerSelectedIndex = ref(0);
|
|
2835
|
+
const baseStyle = computed(() => mergeStyle(defaultStyle.value, props.style));
|
|
2836
|
+
function close() {
|
|
2837
|
+
emit("update:modelValue", false);
|
|
2838
|
+
emit("close");
|
|
2839
|
+
}
|
|
2840
|
+
function select(index) {
|
|
2841
|
+
const item = props.items[index];
|
|
2842
|
+
if (!item || item.disabled) return;
|
|
2843
|
+
emit("select", {
|
|
2844
|
+
item,
|
|
2845
|
+
index
|
|
2846
|
+
});
|
|
2847
|
+
close();
|
|
2848
|
+
}
|
|
2849
|
+
function firstEnabledIndex() {
|
|
2850
|
+
return props.items.findIndex((item) => !item.disabled);
|
|
2851
|
+
}
|
|
2852
|
+
function selectedIndex() {
|
|
2853
|
+
if (!props.items.length) return 0;
|
|
2854
|
+
const clamped = clamp$1(props.selectedIndex ?? innerSelectedIndex.value, 0, props.items.length - 1);
|
|
2855
|
+
if (!props.items[clamped]?.disabled) return clamped;
|
|
2856
|
+
const first = firstEnabledIndex();
|
|
2857
|
+
return first >= 0 ? first : clamped;
|
|
2858
|
+
}
|
|
2859
|
+
function nextEnabledIndex(index, direction) {
|
|
2860
|
+
let next = index + direction;
|
|
2861
|
+
while (next >= 0 && next < props.items.length) {
|
|
2862
|
+
if (!props.items[next]?.disabled) return next;
|
|
2863
|
+
next += direction;
|
|
2864
|
+
}
|
|
2865
|
+
return index;
|
|
2866
|
+
}
|
|
2867
|
+
function setSelected(index) {
|
|
2868
|
+
innerSelectedIndex.value = index;
|
|
2869
|
+
emit("update:selectedIndex", index);
|
|
2870
|
+
}
|
|
2871
|
+
function handleMenuKeydown(event) {
|
|
2872
|
+
if (event.key === "Escape") {
|
|
2873
|
+
event.preventDefault?.();
|
|
2874
|
+
close();
|
|
2875
|
+
} else if (event.key === "Enter") {
|
|
2876
|
+
event.preventDefault?.();
|
|
2877
|
+
select(selectedIndex());
|
|
2878
|
+
} else if (event.key === "ArrowDown") {
|
|
2879
|
+
event.preventDefault?.();
|
|
2880
|
+
setSelected(nextEnabledIndex(selectedIndex(), 1));
|
|
2881
|
+
} else if (event.key === "ArrowUp") {
|
|
2882
|
+
event.preventDefault?.();
|
|
2883
|
+
setSelected(nextEnabledIndex(selectedIndex(), -1));
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
function closeFromOutside(event) {
|
|
2887
|
+
event.preventDefault?.();
|
|
2888
|
+
event.stopPropagation?.();
|
|
2889
|
+
close();
|
|
2890
|
+
}
|
|
2891
|
+
function stopInsideClick(event) {
|
|
2892
|
+
event.stopPropagation?.();
|
|
2893
|
+
}
|
|
2894
|
+
return () => {
|
|
2895
|
+
if (!props.modelValue) return null;
|
|
2896
|
+
const size = terminal.size();
|
|
2897
|
+
const hgt = Math.max(2, props.items.length + 2);
|
|
2898
|
+
const activeIndex = selectedIndex();
|
|
2899
|
+
const hasEnabledItem = props.items.some((item) => !item.disabled);
|
|
2900
|
+
const menu = h(TView, {
|
|
2901
|
+
key: "menu",
|
|
2902
|
+
x: props.x,
|
|
2903
|
+
y: props.y,
|
|
2904
|
+
w: props.w,
|
|
2905
|
+
h: hgt,
|
|
2906
|
+
zIndex: props.closeOnOutside ? props.zIndex + 1 : props.zIndex,
|
|
2907
|
+
focusable: !hasEnabledItem,
|
|
2908
|
+
autoFocus: !hasEnabledItem,
|
|
2909
|
+
onClick: props.closeOnOutside ? stopInsideClick : void 0,
|
|
2910
|
+
onKeydown: handleMenuKeydown
|
|
2911
|
+
}, () => h(TBox, {
|
|
2912
|
+
x: 0,
|
|
2913
|
+
y: 0,
|
|
2914
|
+
w: props.w,
|
|
2915
|
+
h: hgt,
|
|
2916
|
+
style: baseStyle.value
|
|
2917
|
+
}, () => props.items.map((item, index) => {
|
|
2918
|
+
const active = index === activeIndex;
|
|
2919
|
+
const text = item.shortcut ? `${item.label} ${item.shortcut}` : item.label;
|
|
2920
|
+
return h(TView, {
|
|
2921
|
+
key: item.id,
|
|
2922
|
+
x: 0,
|
|
2923
|
+
y: index,
|
|
2924
|
+
w: Math.max(1, props.w - 2),
|
|
2925
|
+
h: 1,
|
|
2926
|
+
focusable: !item.disabled,
|
|
2927
|
+
autoFocus: active && !item.disabled,
|
|
2928
|
+
onClick: () => select(index)
|
|
2929
|
+
}, () => h(TText, {
|
|
2930
|
+
x: 0,
|
|
2931
|
+
y: 0,
|
|
2932
|
+
w: Math.max(1, props.w - 2),
|
|
2933
|
+
value: fitCellText(text, Math.max(1, props.w - 2)),
|
|
2934
|
+
style: item.disabled ? mergeStyle(baseStyle.value, props.disabledStyle) : active ? mergeStyle(baseStyle.value, props.activeStyle) : baseStyle.value
|
|
2935
|
+
}));
|
|
2936
|
+
})));
|
|
2937
|
+
if (!props.closeOnOutside) return menu;
|
|
2938
|
+
return [h(TView, {
|
|
2939
|
+
key: "outside",
|
|
2940
|
+
x: 0,
|
|
2941
|
+
y: 0,
|
|
2942
|
+
w: size.cols,
|
|
2943
|
+
h: size.rows,
|
|
2944
|
+
zIndex: props.zIndex,
|
|
2945
|
+
onClick: closeFromOutside
|
|
2946
|
+
}), menu];
|
|
2947
|
+
};
|
|
2948
|
+
}
|
|
2949
|
+
});
|
|
2950
|
+
const TPopover = defineComponent({
|
|
2951
|
+
name: "TPopover",
|
|
2952
|
+
props: {
|
|
2953
|
+
modelValue: {
|
|
2954
|
+
type: Boolean,
|
|
2955
|
+
required: true
|
|
2956
|
+
},
|
|
2957
|
+
x: {
|
|
2958
|
+
type: Number,
|
|
2959
|
+
required: true
|
|
2960
|
+
},
|
|
2961
|
+
y: {
|
|
2962
|
+
type: Number,
|
|
2963
|
+
required: true
|
|
2964
|
+
},
|
|
2965
|
+
w: {
|
|
2966
|
+
type: Number,
|
|
2967
|
+
required: true
|
|
2968
|
+
},
|
|
2969
|
+
h: {
|
|
2970
|
+
type: Number,
|
|
2971
|
+
required: true
|
|
2972
|
+
},
|
|
2973
|
+
zIndex: {
|
|
2974
|
+
type: Number,
|
|
2975
|
+
default: 15
|
|
2976
|
+
},
|
|
2977
|
+
title: {
|
|
2978
|
+
type: String,
|
|
2979
|
+
default: ""
|
|
2980
|
+
},
|
|
2981
|
+
content: {
|
|
2982
|
+
type: String,
|
|
2983
|
+
default: ""
|
|
2984
|
+
},
|
|
2985
|
+
style: {
|
|
2986
|
+
type: Object,
|
|
2987
|
+
default: void 0
|
|
2988
|
+
},
|
|
2989
|
+
contentStyle: {
|
|
2990
|
+
type: Object,
|
|
2991
|
+
default: void 0
|
|
2992
|
+
}
|
|
2993
|
+
},
|
|
2994
|
+
setup(props, { slots }) {
|
|
2995
|
+
const { defaultStyle } = useTerminal();
|
|
2996
|
+
const baseStyle = computed(() => mergeStyle(defaultStyle.value, props.style));
|
|
2997
|
+
const contentStyle = computed(() => mergeStyle(defaultStyle.value, props.contentStyle));
|
|
2998
|
+
return () => props.modelValue ? h(TBox, {
|
|
2999
|
+
x: props.x,
|
|
3000
|
+
y: props.y,
|
|
3001
|
+
w: props.w,
|
|
3002
|
+
h: props.h,
|
|
3003
|
+
zIndex: props.zIndex,
|
|
3004
|
+
title: props.title,
|
|
3005
|
+
style: baseStyle.value
|
|
3006
|
+
}, () => slots.default?.() ?? h(TText, {
|
|
3007
|
+
x: 0,
|
|
3008
|
+
y: 0,
|
|
3009
|
+
w: Math.max(1, props.w - 2),
|
|
3010
|
+
h: Math.max(1, props.h - 2),
|
|
3011
|
+
value: props.content,
|
|
3012
|
+
wrap: true,
|
|
3013
|
+
style: contentStyle.value
|
|
3014
|
+
})) : null;
|
|
3015
|
+
}
|
|
3016
|
+
});
|
|
3017
|
+
const TTooltip = defineComponent({
|
|
3018
|
+
name: "TTooltip",
|
|
3019
|
+
props: {
|
|
3020
|
+
modelValue: {
|
|
3021
|
+
type: Boolean,
|
|
3022
|
+
default: true
|
|
3023
|
+
},
|
|
3024
|
+
x: {
|
|
3025
|
+
type: Number,
|
|
3026
|
+
required: true
|
|
3027
|
+
},
|
|
3028
|
+
y: {
|
|
3029
|
+
type: Number,
|
|
3030
|
+
required: true
|
|
3031
|
+
},
|
|
3032
|
+
w: {
|
|
3033
|
+
type: Number,
|
|
3034
|
+
default: void 0
|
|
3035
|
+
},
|
|
3036
|
+
zIndex: {
|
|
3037
|
+
type: Number,
|
|
3038
|
+
default: 30
|
|
3039
|
+
},
|
|
3040
|
+
content: {
|
|
3041
|
+
type: String,
|
|
3042
|
+
required: true
|
|
3043
|
+
},
|
|
3044
|
+
style: {
|
|
3045
|
+
type: Object,
|
|
3046
|
+
default: () => ({ inverse: true })
|
|
3047
|
+
}
|
|
3048
|
+
},
|
|
3049
|
+
setup(props) {
|
|
3050
|
+
const { defaultStyle } = useTerminal();
|
|
3051
|
+
const baseStyle = computed(() => mergeStyle(defaultStyle.value, props.style));
|
|
3052
|
+
return () => props.modelValue ? h(TText, {
|
|
3053
|
+
x: props.x,
|
|
3054
|
+
y: props.y,
|
|
3055
|
+
zIndex: props.zIndex,
|
|
3056
|
+
w: props.w,
|
|
3057
|
+
value: props.content,
|
|
3058
|
+
style: baseStyle.value
|
|
3059
|
+
}) : null;
|
|
3060
|
+
}
|
|
3061
|
+
});
|
|
3062
|
+
|
|
2172
3063
|
//#endregion
|
|
2173
3064
|
//#region src/vue/components/TPathPicker.ts
|
|
2174
|
-
function clamp$
|
|
3065
|
+
function clamp$2(n, min, max) {
|
|
2175
3066
|
return Math.max(min, Math.min(max, n));
|
|
2176
3067
|
}
|
|
2177
3068
|
function getWheelScrollInput(e) {
|
|
@@ -2252,7 +3143,7 @@ function writeHighlightedText(opts) {
|
|
|
2252
3143
|
y,
|
|
2253
3144
|
style: currentStyle
|
|
2254
3145
|
});
|
|
2255
|
-
cursorX += textCellWidth
|
|
3146
|
+
cursorX += textCellWidth(buffer);
|
|
2256
3147
|
buffer = "";
|
|
2257
3148
|
};
|
|
2258
3149
|
for (let i = 0; i < text.length && cellPos < safeMax;) {
|
|
@@ -2395,9 +3286,9 @@ const TPathPicker = defineComponent({
|
|
|
2395
3286
|
return;
|
|
2396
3287
|
}
|
|
2397
3288
|
const maxTop = Math.max(0, suggestions.value.length - h$1);
|
|
2398
|
-
scrollTop.value = clamp$
|
|
3289
|
+
scrollTop.value = clamp$2(scrollTop.value, 0, maxTop);
|
|
2399
3290
|
if (active.value < scrollTop.value) scrollTop.value = active.value;
|
|
2400
|
-
else if (active.value >= scrollTop.value + h$1) scrollTop.value = clamp$
|
|
3291
|
+
else if (active.value >= scrollTop.value + h$1) scrollTop.value = clamp$2(active.value - (h$1 - 1), 0, maxTop);
|
|
2401
3292
|
}
|
|
2402
3293
|
watch([
|
|
2403
3294
|
() => active.value,
|
|
@@ -2434,7 +3325,7 @@ const TPathPicker = defineComponent({
|
|
|
2434
3325
|
});
|
|
2435
3326
|
if (seq !== refreshSeq) return;
|
|
2436
3327
|
suggestions.value = res.suggestions;
|
|
2437
|
-
active.value = clamp$
|
|
3328
|
+
active.value = clamp$2(active.value, 0, Math.max(0, suggestions.value.length - 1));
|
|
2438
3329
|
ensureActiveVisible();
|
|
2439
3330
|
scheduler.invalidate();
|
|
2440
3331
|
}
|
|
@@ -2461,7 +3352,7 @@ const TPathPicker = defineComponent({
|
|
|
2461
3352
|
function moveActive(delta) {
|
|
2462
3353
|
const len = suggestions.value.length;
|
|
2463
3354
|
if (len <= 0) return;
|
|
2464
|
-
const next = clamp$
|
|
3355
|
+
const next = clamp$2(active.value + delta, 0, len - 1);
|
|
2465
3356
|
if (next !== active.value) {
|
|
2466
3357
|
active.value = next;
|
|
2467
3358
|
ensureActiveVisible();
|
|
@@ -2635,7 +3526,7 @@ const TPathPicker = defineComponent({
|
|
|
2635
3526
|
const visibleEnd = nextTop + h$1 - 1;
|
|
2636
3527
|
if (active.value < visibleStart || active.value > visibleEnd) {
|
|
2637
3528
|
const newActive = dir > 0 ? visibleEnd : visibleStart;
|
|
2638
|
-
active.value = clamp$
|
|
3529
|
+
active.value = clamp$2(newActive, 0, Math.max(0, suggestions.value.length - 1));
|
|
2639
3530
|
}
|
|
2640
3531
|
scheduler.invalidate({ reason: "scroll" });
|
|
2641
3532
|
}
|
|
@@ -2669,7 +3560,7 @@ const TPathPicker = defineComponent({
|
|
|
2669
3560
|
if (r.w <= 0 || r.h <= 0) return;
|
|
2670
3561
|
const base = props.style ?? defaultStyle.value;
|
|
2671
3562
|
const query = parsePathQuery(String(props.modelValue ?? "")).query;
|
|
2672
|
-
const top = clamp$
|
|
3563
|
+
const top = clamp$2(scrollTop.value, 0, Math.max(0, suggestions.value.length - r.h));
|
|
2673
3564
|
for (let i = 0; i < r.h; i++) {
|
|
2674
3565
|
const idx = top + i;
|
|
2675
3566
|
const s = suggestions.value[idx];
|
|
@@ -2706,7 +3597,7 @@ const TPathPicker = defineComponent({
|
|
|
2706
3597
|
}
|
|
2707
3598
|
if (suggestions.value.length === 0 && r.h > 0) {
|
|
2708
3599
|
const msg = error.value ? `(${sanitizeInlineText(error.value)})` : "(no matches)";
|
|
2709
|
-
terminal.write(padEndByCells
|
|
3600
|
+
terminal.write(padEndByCells(sliceByCells(msg, r.w), r.w), {
|
|
2710
3601
|
x: r.x,
|
|
2711
3602
|
y: r.y,
|
|
2712
3603
|
style: {
|
|
@@ -3063,4 +3954,4 @@ const TRouterView = defineComponent({
|
|
|
3063
3954
|
});
|
|
3064
3955
|
|
|
3065
3956
|
//#endregion
|
|
3066
|
-
export { TAnchor, TBox, TDebugOverlay, TDialog, TFlow, TInput, TInputBox, TInputPluginsContextKey, TJsonEditor, TList, TMultilineModal, TPathPicker, TRenderLayer, TRenderPlane, TRouterView, TSelect, TText, TTransition, TView, TerminalProvider,
|
|
3957
|
+
export { TAnchor, TAutocompleteInput, TBadge, TBox, TBreadcrumb, TCheckbox, TCode, TCommandPalette, TContextMenu, TDataTable, TDebugOverlay, TDialog, TDivider, TFlow, TForm, TFormContextKey, TFormField, TInput, TInputBox, TInputPluginsContextKey, TJsonEditor, TKeyHint, TLink, TLinkifyText, TList, TMultilineModal, TPasswordInput, TPathPicker, TPopover, TProgress, TRadioGroup, TRenderLayer, TRenderPlane, TRouterView, TSelect, TSlider, TSpinner, TSplitPane, TStatusBar, TSwitch, TTable, TTabs, TTag, TText, TToastViewport, TTooltip, TTransition, TTree, TView, TerminalProvider, computeCommandPaletteMatchRanges, createOverlayFocusStack, createPromptMentionPlugin, createTInputHostPlugin, createTerminalRouter, createTextRestrictionPlugin, createTheme, linkifyTextSegments, lintJsonText, padEndByCells, resolveOverlayPlacement, sliceByCells, sliceByCellsRange, spaces, textCellWidth, tuiDefaultTheme, useLayout, useRenderNode, useRoute, useRouter, useTForm, useTerminal, useTerminalNode, useTerminalRuntime, useVisibility, wrapByCells };
|