@simon_he/vue-tui 1.0.1 → 1.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/README.md +139 -46
- package/dist/TMermaidText-frVr8Ysb.js +885 -0
- package/dist/{TSelect-HzILuti9.js → TSelect-tJ87rKPM.js} +59 -242
- package/dist/{TTree-ChOot2Bh.js → TTree-CGdE-CYu.js} +138 -102
- package/dist/agent/mermaid.cjs +2 -0
- package/dist/agent/mermaid.d.cts +2 -0
- package/dist/agent/mermaid.d.ts +2 -0
- package/dist/agent/mermaid.js +1 -0
- package/dist/agent.cjs +31188 -24907
- package/dist/agent.d.cts +11 -1
- package/dist/agent.d.ts +11 -1
- package/dist/agent.js +516 -11
- package/dist/{block-source-CKUOnkgT.js → block-source-CrlmaBM5.js} +1039 -66
- package/dist/cli/input.d.ts +8 -0
- package/dist/cli/stdin-buffer.d.ts +1 -1
- package/dist/cli/video/ffmpeg-frame-source.d.ts +10 -0
- package/dist/cli/video/png-frame-parser.d.ts +4 -0
- package/dist/cli/video/raw-frame-parser.d.ts +1 -0
- package/dist/cli/video/yt-dlp-frame-source.d.ts +11 -0
- package/dist/cli.cjs +5470 -6176
- package/dist/cli.d.cts +6 -2
- package/dist/cli.d.ts +6 -2
- package/dist/cli.js +3747 -350
- package/dist/core/buffer/buffer.d.ts +2 -2
- package/dist/core/buffer/eaw-ranges-unicode-17.d.ts +14 -0
- package/dist/core/perf/instrumentation-noop.d.ts +48 -0
- package/dist/core/perf/instrumentation.d.ts +136 -0
- package/dist/core/terminal/create-terminal.d.ts +1 -0
- package/dist/core/types.d.ts +0 -4
- package/dist/core.cjs +851 -1462
- package/dist/core.js +4 -5
- package/dist/create-terminal-app.d.ts +24 -1
- package/dist/debug-logger-CmsGI4of.js +74 -0
- package/dist/{dom-renderer-BqGijQID.js → dom-renderer-DXx8fWzD.js} +2 -3
- package/dist/experimental/3d/bun/contributor-avatar-atlas.d.ts +12 -0
- package/dist/experimental/3d/bun/png.d.ts +1 -0
- package/dist/experimental/3d/bun/terminal-badge-scene.d.ts +11 -0
- package/dist/experimental/3d/bun/terminal-badge.wgsl.d.ts +1 -0
- package/dist/experimental/3d/bun/webgpu-renderer.d.ts +26 -0
- package/dist/experimental/3d/bun.cjs +7271 -0
- package/dist/experimental/3d/bun.d.cts +4 -0
- package/dist/experimental/3d/bun.d.ts +4 -0
- package/dist/experimental/3d/bun.js +7390 -0
- package/dist/experimental/video/node.cjs +497 -0
- package/dist/experimental/video/node.d.cts +4 -0
- package/dist/experimental/video/node.d.ts +4 -0
- package/dist/experimental/video/node.js +610 -0
- package/dist/experimental.cjs +6876 -6192
- package/dist/experimental.d.cts +7 -0
- package/dist/experimental.d.ts +7 -0
- package/dist/experimental.js +3005 -9
- package/dist/frame-perf-CHpWhbC4.js +111 -0
- package/dist/{create-terminal-C2oiWFJU.js → hyperlink-_1FAj7Wq.js} +455 -19
- package/dist/index.cjs +5025 -10332
- package/dist/index.js +14 -13
- package/dist/{linkify-D_gzn9Xq.js → linkify-D68T7rdW.js} +193 -3
- package/dist/markdown.cjs +21295 -12691
- package/dist/markdown.d.cts +1 -1
- package/dist/markdown.d.ts +1 -1
- package/dist/markdown.js +211 -51
- package/dist/mermaid-BNhM1jAZ.js +123 -0
- package/dist/mermaid.cjs +1707 -0
- package/dist/mermaid.d.cts +3 -0
- package/dist/mermaid.d.ts +3 -0
- package/dist/mermaid.js +6 -0
- package/dist/observability/frame-perf-store.d.ts +2 -1
- package/dist/observability/frame-perf.d.ts +33 -0
- package/dist/observability.cjs +106 -107
- package/dist/observability.d.cts +2 -2
- package/dist/observability.d.ts +2 -2
- package/dist/observability.js +3 -3
- package/dist/{wheel-scroll-vBRaQ7p-.js → rect-DUpeDfBg.js} +253 -117
- package/dist/renderer/cli/index.d.ts +1 -1
- package/dist/renderer/cli/stdout-metrics.d.ts +10 -0
- package/dist/renderer/cli/stdout-renderer.d.ts +53 -7
- package/dist/renderer/terminal-graphic-render-queue.d.ts +50 -0
- package/dist/renderer/terminal-graphics-trace.d.ts +53 -0
- package/dist/renderer/terminal-graphics.d.ts +147 -0
- package/dist/renderer-dom.cjs +364 -903
- package/dist/renderer-dom.js +4 -5
- package/dist/runtime/index.d.ts +2 -0
- package/dist/{runtime-rfcZCyJq.js → runtime-Byf8XXOT.js} +28 -15
- package/dist/runtime.cjs +427 -889
- package/dist/runtime.js +2 -2
- package/dist/terminal-graphics-Bbe83wSr.js +597 -0
- package/dist/{terminal-selection-DBinO6p5.js → terminal-selection-4W1SJj4c.js} +4 -1
- package/dist/{tlog-theme-CvLFNMwk.js → tlog-theme-Bul2Na3u.js} +1237 -12
- package/dist/{trace-CjzYeIxN.js → trace-Bh8WnoMo.js} +5 -0
- package/dist/vue/agent/create-png-terminal-graphic-renderer.d.ts +19 -0
- package/dist/vue/components/T3DViewport.d.ts +473 -0
- package/dist/vue/components/TAgentTerminalGraphic.d.ts +494 -0
- package/dist/vue/components/TCharts.d.ts +1121 -0
- package/dist/vue/components/TFeedback.d.ts +1 -1
- package/dist/vue/components/TFlex.d.ts +389 -0
- package/dist/vue/components/TForm.d.ts +4 -4
- package/dist/vue/components/TLogSearchBar.d.ts +3 -3
- package/dist/vue/components/TLogSearchPager.d.ts +2 -2
- package/dist/vue/components/TMarkdownText.d.ts +162 -4
- package/dist/vue/components/TMermaidText.d.ts +900 -0
- package/dist/vue/components/TVideo.d.ts +291 -0
- package/dist/vue/components/TVirtualList.d.ts +9 -0
- package/dist/vue/components/TVirtualMarkdown.d.ts +170 -9
- package/dist/vue/components/TVirtualRows.d.ts +9 -0
- package/dist/vue/components/TerminalProvider.d.ts +2 -0
- package/dist/vue/context.d.ts +24 -0
- package/dist/vue/index.d.ts +5 -0
- package/dist/vue/layout/flex.d.ts +67 -0
- package/dist/vue/markdown/ast.d.ts +5 -2
- package/dist/vue/markdown/document.d.ts +5 -0
- package/dist/vue/markdown/image-actions.d.ts +14 -0
- package/dist/vue/markdown/image.d.ts +11 -0
- package/dist/vue/markdown/link-actions.d.ts +14 -0
- package/dist/vue/markdown/math-actions.d.ts +14 -0
- package/dist/vue/markdown/math.d.ts +6 -0
- package/dist/vue/markdown/render.d.ts +28 -0
- package/dist/vue/markdown/types.d.ts +78 -0
- package/dist/vue/mermaid/beautiful-mermaid.d.ts +1436 -0
- package/dist/vue/render/render-manager.d.ts +7 -0
- package/dist/vue/video/types.d.ts +39 -0
- package/dist/vue.cjs +7215 -12430
- package/dist/vue.js +704 -38
- package/dist/wheel-scroll-DASkEZr-.js +106 -0
- package/dist/{hyperlink-Bn02UXJb.js → width-GqllnV8C.js} +166 -111
- package/package.json +141 -18
- package/dist/frame-perf-C6Xfg85O.js +0 -24
- package/dist/sgr-BmzxEjAO.js +0 -304
- /package/dist/{ansi-palette-CNXqFciC.js → ansi-palette-CH6jc2Z7.js} +0 -0
- /package/dist/{path-suggest-BNqcuE3-.js → path-suggest-Dndu4dTi.js} +0 -0
package/dist/vue.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import { charCellWidth } from "./
|
|
3
|
-
import "./
|
|
4
|
-
import "./
|
|
5
|
-
import "./
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import "./
|
|
9
|
-
import "./trace-
|
|
1
|
+
import "./hyperlink-_1FAj7Wq.js";
|
|
2
|
+
import { charCellWidth } from "./width-GqllnV8C.js";
|
|
3
|
+
import "./ansi-palette-CH6jc2Z7.js";
|
|
4
|
+
import "./dom-renderer-DXx8fWzD.js";
|
|
5
|
+
import { EventZIndexContextKey, LayoutContextKey, RenderStackKey, TInputPluginsContextKey, TPathPickerProviderContextKey, VisibilityContextKey, 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 "./rect-DUpeDfBg.js";
|
|
6
|
+
import { TText, TView, clamp, createTheme, fitCellText, linkifyTextSegments, mergeStyle, tuiDefaultTheme } from "./linkify-D68T7rdW.js";
|
|
7
|
+
import "./runtime-Byf8XXOT.js";
|
|
8
|
+
import "./frame-perf-CHpWhbC4.js";
|
|
9
|
+
import "./trace-Bh8WnoMo.js";
|
|
10
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-
|
|
12
|
-
import "./terminal-selection-
|
|
13
|
-
import
|
|
14
|
-
import "./
|
|
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-CGdE-CYu.js";
|
|
12
|
+
import "./terminal-selection-4W1SJj4c.js";
|
|
13
|
+
import "./debug-logger-CmsGI4of.js";
|
|
14
|
+
import { TBox, TCommandPalette, TDialog, TInput, TRenderPlane, TSelect, clamp$1, computeCommandPaletteMatchRanges, createOverlayFocusStack, isCommitMention, isWhitespace, mentionChipStyle, padEndByCells as padEndByCells$1, resolveOverlayPlacement, sliceByCellsWindow, textCellWidth as textCellWidth$1 } from "./TSelect-tJ87rKPM.js";
|
|
15
15
|
import { normalizePath, stripTrailingSlash } from "./path-mnSgEpCm.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { applyWheelScroll, createWheelScrollState } from "./wheel-scroll-DASkEZr-.js";
|
|
17
|
+
import { parsePathQuery, resolveUserPath, suggestPaths } from "./path-suggest-Dndu4dTi.js";
|
|
18
|
+
import { TMermaid$1 as TMermaid, TMermaidText$1 as TMermaidText, isSimpleMermaidFlowchartSource, markMermaidRenderErrorFatal } from "./TMermaidText-frVr8Ysb.js";
|
|
19
|
+
import { Comment, Fragment, computed, defineComponent, h, inject, onBeforeUnmount, onMounted, onUnmounted, provide, reactive, ref, shallowReactive, shallowRef, watch, watchEffect } from "vue";
|
|
18
20
|
|
|
19
21
|
//#region src/observability/cli-latency.ts
|
|
20
22
|
const GLOBAL_PROFILER_KEY = "__vueTuiCliLatencyProfiler";
|
|
@@ -60,7 +62,7 @@ function isMentionChar(ch) {
|
|
|
60
62
|
}
|
|
61
63
|
function computePromptContext(value, cursorIndex, triggers) {
|
|
62
64
|
if (!triggers.length) return null;
|
|
63
|
-
const idx = clamp(cursorIndex, 0, value.length);
|
|
65
|
+
const idx = clamp$1(cursorIndex, 0, value.length);
|
|
64
66
|
const lineStart = value.lastIndexOf("\n", Math.max(0, idx - 1)) + 1;
|
|
65
67
|
let matchedTrigger = null;
|
|
66
68
|
for (const t of triggers) if (t && value.slice(lineStart, lineStart + t.length) === t) {
|
|
@@ -88,7 +90,7 @@ function computePromptContext(value, cursorIndex, triggers) {
|
|
|
88
90
|
}
|
|
89
91
|
function computeMentionContext(value, cursorIndex, trigger, multilineToken, mentionToken) {
|
|
90
92
|
if (!trigger) return null;
|
|
91
|
-
const idx = clamp(cursorIndex, 0, value.length);
|
|
93
|
+
const idx = clamp$1(cursorIndex, 0, value.length);
|
|
92
94
|
let start = -1;
|
|
93
95
|
for (let i = idx - 1; i >= 0; i--) {
|
|
94
96
|
const ch = value[i];
|
|
@@ -109,7 +111,7 @@ function computeMentionContext(value, cursorIndex, trigger, multilineToken, ment
|
|
|
109
111
|
} else while (end < value.length && isMentionChar(value[end])) end++;
|
|
110
112
|
if (idx < start || idx > end) return null;
|
|
111
113
|
const tokenText = value.slice(start, end);
|
|
112
|
-
const queryEnd = clamp(idx, start + trigger.length, end);
|
|
114
|
+
const queryEnd = clamp$1(idx, start + trigger.length, end);
|
|
113
115
|
const query = value.slice(start + trigger.length, queryEnd);
|
|
114
116
|
const key = `${start}:${tokenText}`;
|
|
115
117
|
return {
|
|
@@ -331,7 +333,7 @@ function usePromptMentionState(options) {
|
|
|
331
333
|
return [...pathMatches, ...otherMatches];
|
|
332
334
|
});
|
|
333
335
|
watch(() => promptMatches.value.length, (len) => {
|
|
334
|
-
promptActive.value = clamp(promptActive.value, 0, Math.max(0, len - 1));
|
|
336
|
+
promptActive.value = clamp$1(promptActive.value, 0, Math.max(0, len - 1));
|
|
335
337
|
});
|
|
336
338
|
const promptMaxVisible = computed(() => {
|
|
337
339
|
const ctx = activeContext.value;
|
|
@@ -346,7 +348,7 @@ function usePromptMentionState(options) {
|
|
|
346
348
|
if (total <= 0 || maxVisible <= 0) return 0;
|
|
347
349
|
const visible = Math.min(maxVisible, total);
|
|
348
350
|
const maxStart = Math.max(0, total - visible);
|
|
349
|
-
return clamp(promptActive.value - (visible - 1), 0, maxStart);
|
|
351
|
+
return clamp$1(promptActive.value - (visible - 1), 0, maxStart);
|
|
350
352
|
});
|
|
351
353
|
const promptMatchesVisible = computed(() => {
|
|
352
354
|
const total = promptMatches.value.length;
|
|
@@ -359,7 +361,7 @@ function usePromptMentionState(options) {
|
|
|
359
361
|
const promptActiveVisible = computed(() => {
|
|
360
362
|
const start = promptWindowStart.value;
|
|
361
363
|
const rel = promptActive.value - start;
|
|
362
|
-
return clamp(rel, 0, Math.max(0, promptMatchesVisible.value.length - 1));
|
|
364
|
+
return clamp$1(rel, 0, Math.max(0, promptMatchesVisible.value.length - 1));
|
|
363
365
|
});
|
|
364
366
|
const promptVisible = computed(() => {
|
|
365
367
|
const ctx = activeContext.value;
|
|
@@ -377,19 +379,19 @@ function usePromptMentionState(options) {
|
|
|
377
379
|
h: s.rows
|
|
378
380
|
};
|
|
379
381
|
const listH = Math.max(1, promptMatchesVisible.value.length || 1);
|
|
380
|
-
const h$1 = clamp(2 + listH, 3, Math.max(3, Math.floor(clip.h)));
|
|
381
|
-
const w = clamp(Math.floor(base.w), 0, Math.max(0, Math.floor(clip.w)));
|
|
382
|
+
const h$1 = clamp$1(2 + listH, 3, Math.max(3, Math.floor(clip.h)));
|
|
383
|
+
const w = clamp$1(Math.floor(base.w), 0, Math.max(0, Math.floor(clip.w)));
|
|
382
384
|
const preferAboveY = Math.floor(base.y) - h$1;
|
|
383
385
|
const preferBelowY = Math.floor(base.y) + Math.floor(base.h);
|
|
384
386
|
const aboveFits = preferAboveY >= Math.floor(clip.y);
|
|
385
387
|
const belowFits = preferBelowY + h$1 <= Math.floor(clip.y) + Math.floor(clip.h);
|
|
386
388
|
const yPref = aboveFits ? preferAboveY : belowFits ? preferBelowY : preferAboveY;
|
|
387
|
-
const y = clamp(yPref, Math.floor(clip.y), Math.floor(clip.y) + Math.floor(clip.h) - h$1);
|
|
389
|
+
const y = clamp$1(yPref, Math.floor(clip.y), Math.floor(clip.y) + Math.floor(clip.h) - h$1);
|
|
388
390
|
const align = props.promptAlign || "input";
|
|
389
391
|
const baseX = Math.floor(base.x);
|
|
390
392
|
const centeredX = Math.floor(Math.floor(clip.x) + Math.floor((Math.floor(clip.w) - w) / 2));
|
|
391
393
|
const preferX = align === "center" ? centeredX : baseX;
|
|
392
|
-
const x = clamp(preferX, Math.floor(clip.x), Math.floor(clip.x) + Math.floor(clip.w) - w);
|
|
394
|
+
const x = clamp$1(preferX, Math.floor(clip.x), Math.floor(clip.x) + Math.floor(clip.w) - w);
|
|
393
395
|
return {
|
|
394
396
|
x,
|
|
395
397
|
y,
|
|
@@ -534,7 +536,7 @@ function buildPromptMatchHighlightStyle(baseStyle, overrideStyle) {
|
|
|
534
536
|
}
|
|
535
537
|
function countMentionTokens(value, mentionToken, endIndex = value.length) {
|
|
536
538
|
let count = 0;
|
|
537
|
-
const limit = clamp(endIndex, 0, value.length);
|
|
539
|
+
const limit = clamp$1(endIndex, 0, value.length);
|
|
538
540
|
for (let i = 0; i < limit; i++) if (value[i] === mentionToken) count++;
|
|
539
541
|
return count;
|
|
540
542
|
}
|
|
@@ -628,8 +630,8 @@ function createPromptMentionPlugin(options = {}) {
|
|
|
628
630
|
const cleaned = String(absPath || "").trim();
|
|
629
631
|
if (!cleaned) return;
|
|
630
632
|
const value = ctx.getValue();
|
|
631
|
-
const start = clamp(tokenStart, 0, value.length);
|
|
632
|
-
const end = clamp(tokenEnd, start, value.length);
|
|
633
|
+
const start = clamp$1(tokenStart, 0, value.length);
|
|
634
|
+
const end = clamp$1(tokenEnd, start, value.length);
|
|
633
635
|
const currentMentions = getProps().mentions ?? [];
|
|
634
636
|
const nextMentions = [...currentMentions];
|
|
635
637
|
let before = value.slice(0, start);
|
|
@@ -655,7 +657,7 @@ function createPromptMentionPlugin(options = {}) {
|
|
|
655
657
|
const ctx0 = promptMention.activeContext.value;
|
|
656
658
|
if (!ctx0) return;
|
|
657
659
|
const list = promptMention.promptMatches.value;
|
|
658
|
-
const match = list[clamp(index, 0, Math.max(0, list.length - 1))];
|
|
660
|
+
const match = list[clamp$1(index, 0, Math.max(0, list.length - 1))];
|
|
659
661
|
if (!match) return;
|
|
660
662
|
const suggestion = match.item;
|
|
661
663
|
const mentionTrigger = getProps().mentionTrigger || "@";
|
|
@@ -720,8 +722,8 @@ function createPromptMentionPlugin(options = {}) {
|
|
|
720
722
|
if (!insert.startsWith(mentionTrigger)) return false;
|
|
721
723
|
if (!insert.endsWith("/") && !insert.endsWith("\\")) insert = `${insert}/`;
|
|
722
724
|
const value = ctx.getValue();
|
|
723
|
-
const before = value.slice(0, clamp(ctx0.tokenStart, 0, value.length));
|
|
724
|
-
const after = value.slice(clamp(ctx0.tokenEnd, 0, value.length));
|
|
725
|
+
const before = value.slice(0, clamp$1(ctx0.tokenStart, 0, value.length));
|
|
726
|
+
const after = value.slice(clamp$1(ctx0.tokenEnd, 0, value.length));
|
|
725
727
|
const nextValue = `${before}${insert}${after}`;
|
|
726
728
|
const nextCursor = before.length + insert.length;
|
|
727
729
|
promptMention.promptSuppressedKey.value = null;
|
|
@@ -747,7 +749,7 @@ function createPromptMentionPlugin(options = {}) {
|
|
|
747
749
|
e.preventDefault();
|
|
748
750
|
if (len <= 0) promptMention.promptActive.value = 0;
|
|
749
751
|
else if (promptMention.promptActive.value >= len - 1) promptMention.promptActive.value = 0;
|
|
750
|
-
else promptMention.promptActive.value = clamp(promptMention.promptActive.value + 1, 0, len - 1);
|
|
752
|
+
else promptMention.promptActive.value = clamp$1(promptMention.promptActive.value + 1, 0, len - 1);
|
|
751
753
|
ctx.scheduler.invalidate();
|
|
752
754
|
return true;
|
|
753
755
|
}
|
|
@@ -756,7 +758,7 @@ function createPromptMentionPlugin(options = {}) {
|
|
|
756
758
|
e.preventDefault();
|
|
757
759
|
if (len <= 0) promptMention.promptActive.value = 0;
|
|
758
760
|
else if (promptMention.promptActive.value <= 0) promptMention.promptActive.value = len - 1;
|
|
759
|
-
else promptMention.promptActive.value = clamp(promptMention.promptActive.value - 1, 0, len - 1);
|
|
761
|
+
else promptMention.promptActive.value = clamp$1(promptMention.promptActive.value - 1, 0, len - 1);
|
|
760
762
|
ctx.scheduler.invalidate();
|
|
761
763
|
return true;
|
|
762
764
|
}
|
|
@@ -768,7 +770,7 @@ function createPromptMentionPlugin(options = {}) {
|
|
|
768
770
|
const isSkill = Boolean(skillTrigger && ctx0?.tokenText?.startsWith(skillTrigger) && !isMention);
|
|
769
771
|
if (e.key === "Enter" && !e.shiftKey && !isMention && !isSkill) {
|
|
770
772
|
if (len === 0) return false;
|
|
771
|
-
const match = promptMention.promptMatches.value[clamp(promptMention.promptActive.value, 0, Math.max(0, promptMention.promptMatches.value.length - 1))];
|
|
773
|
+
const match = promptMention.promptMatches.value[clamp$1(promptMention.promptActive.value, 0, Math.max(0, promptMention.promptMatches.value.length - 1))];
|
|
772
774
|
const typed = String(ctx0?.tokenText ?? "");
|
|
773
775
|
const candidate = String(match?.item?.value ?? "");
|
|
774
776
|
if (!typed || !candidate.startsWith(typed)) return false;
|
|
@@ -782,7 +784,7 @@ function createPromptMentionPlugin(options = {}) {
|
|
|
782
784
|
e.preventDefault();
|
|
783
785
|
if (len === 0) return true;
|
|
784
786
|
const list = promptMention.promptMatches.value;
|
|
785
|
-
const match = list[clamp(promptMention.promptActive.value, 0, Math.max(0, list.length - 1))];
|
|
787
|
+
const match = list[clamp$1(promptMention.promptActive.value, 0, Math.max(0, list.length - 1))];
|
|
786
788
|
if (isMention && match && ctx0 && completeMentionDirectory(match.item, ctx0)) return true;
|
|
787
789
|
acceptPrompt(promptMention.promptActive.value);
|
|
788
790
|
return true;
|
|
@@ -1066,7 +1068,7 @@ function createPromptMentionPlugin(options = {}) {
|
|
|
1066
1068
|
const idx = y - 1;
|
|
1067
1069
|
const start = promptMention.promptWindowStart.value;
|
|
1068
1070
|
const globalIdx = start + idx;
|
|
1069
|
-
promptMention.promptActive.value = clamp(globalIdx, 0, Math.max(0, promptMention.promptMatches.value.length - 1));
|
|
1071
|
+
promptMention.promptActive.value = clamp$1(globalIdx, 0, Math.max(0, promptMention.promptMatches.value.length - 1));
|
|
1070
1072
|
acceptPrompt(promptMention.promptActive.value);
|
|
1071
1073
|
} }
|
|
1072
1074
|
}));
|
|
@@ -1446,6 +1448,670 @@ const TDebugOverlay = defineComponent({
|
|
|
1446
1448
|
}
|
|
1447
1449
|
});
|
|
1448
1450
|
|
|
1451
|
+
//#endregion
|
|
1452
|
+
//#region src/vue/layout/flex.ts
|
|
1453
|
+
function normalizeCellCount$1(value, fallback = 0) {
|
|
1454
|
+
const n = Math.floor(Number(value));
|
|
1455
|
+
return Number.isFinite(n) ? Math.max(0, n) : fallback;
|
|
1456
|
+
}
|
|
1457
|
+
function normalizeOptionalCellCount(value) {
|
|
1458
|
+
if (value == null) return void 0;
|
|
1459
|
+
const n = Math.floor(Number(value));
|
|
1460
|
+
if (!Number.isFinite(n)) return void 0;
|
|
1461
|
+
return Math.max(0, n);
|
|
1462
|
+
}
|
|
1463
|
+
function normalizeRatio(value, fallback) {
|
|
1464
|
+
const n = Number(value);
|
|
1465
|
+
return Number.isFinite(n) ? Math.max(0, n) : fallback;
|
|
1466
|
+
}
|
|
1467
|
+
function resolveSize(value, reference) {
|
|
1468
|
+
if (value == null) return void 0;
|
|
1469
|
+
if (typeof value === "number") return normalizeOptionalCellCount(value);
|
|
1470
|
+
const n = Number(value.slice(0, -1));
|
|
1471
|
+
if (!Number.isFinite(n)) return void 0;
|
|
1472
|
+
return Math.max(0, Math.floor(reference * n / 100));
|
|
1473
|
+
}
|
|
1474
|
+
function clampSize(value, min, max) {
|
|
1475
|
+
return Math.min(max, Math.max(min, value));
|
|
1476
|
+
}
|
|
1477
|
+
function resolveMainMin(item, direction, reference) {
|
|
1478
|
+
return (direction === "row" ? resolveSize(item.minWidth, reference) : resolveSize(item.minHeight, reference)) ?? 0;
|
|
1479
|
+
}
|
|
1480
|
+
function resolveMainMax(item, direction, reference, min) {
|
|
1481
|
+
return Math.max(min, (direction === "row" ? resolveSize(item.maxWidth, reference) : resolveSize(item.maxHeight, reference)) ?? Number.POSITIVE_INFINITY);
|
|
1482
|
+
}
|
|
1483
|
+
function measureItem(item, direction, mainReference, crossReference) {
|
|
1484
|
+
if (!item.measure) return {
|
|
1485
|
+
main: void 0,
|
|
1486
|
+
cross: void 0
|
|
1487
|
+
};
|
|
1488
|
+
const constraints = direction === "row" ? {
|
|
1489
|
+
maxWidth: mainReference,
|
|
1490
|
+
maxHeight: crossReference,
|
|
1491
|
+
direction
|
|
1492
|
+
} : {
|
|
1493
|
+
maxWidth: crossReference,
|
|
1494
|
+
maxHeight: mainReference,
|
|
1495
|
+
direction
|
|
1496
|
+
};
|
|
1497
|
+
const cacheKey = `${constraints.direction}:${constraints.maxWidth}:${constraints.maxHeight}`;
|
|
1498
|
+
const cached = item.measureCache?.get(cacheKey);
|
|
1499
|
+
if (cached) return cached;
|
|
1500
|
+
const measured = item.measure(constraints);
|
|
1501
|
+
const width = normalizeOptionalCellCount(measured?.width ?? measured?.w);
|
|
1502
|
+
const height = normalizeOptionalCellCount(measured?.height ?? measured?.h);
|
|
1503
|
+
const resolved = direction === "row" ? {
|
|
1504
|
+
main: width,
|
|
1505
|
+
cross: height
|
|
1506
|
+
} : {
|
|
1507
|
+
main: height,
|
|
1508
|
+
cross: width
|
|
1509
|
+
};
|
|
1510
|
+
item.measureCache?.set(cacheKey, resolved);
|
|
1511
|
+
return resolved;
|
|
1512
|
+
}
|
|
1513
|
+
function resolveMeasuredMain(item, direction, mainReference, crossReference) {
|
|
1514
|
+
return measureItem(item, direction, mainReference, crossReference).main;
|
|
1515
|
+
}
|
|
1516
|
+
function resolveMeasuredCross(item, direction, mainReference, crossReference) {
|
|
1517
|
+
return measureItem(item, direction, mainReference, crossReference).cross;
|
|
1518
|
+
}
|
|
1519
|
+
function resolveMainBase(item, direction, reference, crossReference, min, max) {
|
|
1520
|
+
const fixed = direction === "row" ? resolveSize(item.width, reference) : resolveSize(item.height, reference);
|
|
1521
|
+
const measured = resolveMeasuredMain(item, direction, reference, crossReference);
|
|
1522
|
+
const basis = resolveSize(item.basis, reference) ?? fixed ?? measured ?? 0;
|
|
1523
|
+
return clampSize(basis, min, max);
|
|
1524
|
+
}
|
|
1525
|
+
function resolveCrossBase(item, direction, reference, mainReference) {
|
|
1526
|
+
const fixed = direction === "row" ? resolveSize(item.height, reference) : resolveSize(item.width, reference);
|
|
1527
|
+
const measured = resolveMeasuredCross(item, direction, mainReference, reference);
|
|
1528
|
+
const min = (direction === "row" ? resolveSize(item.minHeight, reference) : resolveSize(item.minWidth, reference)) ?? 0;
|
|
1529
|
+
const max = Math.max(min, (direction === "row" ? resolveSize(item.maxHeight, reference) : resolveSize(item.maxWidth, reference)) ?? Number.POSITIVE_INFINITY);
|
|
1530
|
+
return fixed == null ? clampSize(measured ?? min, min, max) : clampSize(fixed, min, max);
|
|
1531
|
+
}
|
|
1532
|
+
function mainBefore(item, direction) {
|
|
1533
|
+
return direction === "row" ? item.marginLeft : item.marginTop;
|
|
1534
|
+
}
|
|
1535
|
+
function mainAfter(item, direction) {
|
|
1536
|
+
return direction === "row" ? item.marginRight : item.marginBottom;
|
|
1537
|
+
}
|
|
1538
|
+
function crossBefore(item, direction) {
|
|
1539
|
+
return direction === "row" ? item.marginTop : item.marginLeft;
|
|
1540
|
+
}
|
|
1541
|
+
function crossAfter(item, direction) {
|
|
1542
|
+
return direction === "row" ? item.marginBottom : item.marginRight;
|
|
1543
|
+
}
|
|
1544
|
+
function mainMargin(item, direction) {
|
|
1545
|
+
return mainBefore(item, direction) + mainAfter(item, direction);
|
|
1546
|
+
}
|
|
1547
|
+
function crossMargin(item, direction) {
|
|
1548
|
+
return crossBefore(item, direction) + crossAfter(item, direction);
|
|
1549
|
+
}
|
|
1550
|
+
function fitEdges(edges, width, height) {
|
|
1551
|
+
const left = Math.min(edges.left, width);
|
|
1552
|
+
const right = Math.min(edges.right, Math.max(0, width - left));
|
|
1553
|
+
const top = Math.min(edges.top, height);
|
|
1554
|
+
const bottom = Math.min(edges.bottom, Math.max(0, height - top));
|
|
1555
|
+
return {
|
|
1556
|
+
top,
|
|
1557
|
+
right,
|
|
1558
|
+
bottom,
|
|
1559
|
+
left
|
|
1560
|
+
};
|
|
1561
|
+
}
|
|
1562
|
+
function proportionalSizes(weights, available) {
|
|
1563
|
+
if (available <= 0) return weights.map(() => 0);
|
|
1564
|
+
const total = weights.reduce((sum, next) => sum + next, 0);
|
|
1565
|
+
if (total <= 0) return weights.map(() => 0);
|
|
1566
|
+
const out = weights.map((weight) => Math.floor(available * weight / total));
|
|
1567
|
+
let remaining = available - out.reduce((sum, next) => sum + next, 0);
|
|
1568
|
+
const order = weights.map((weight, index) => ({
|
|
1569
|
+
index,
|
|
1570
|
+
fraction: available * weight / total - out[index]
|
|
1571
|
+
})).sort((a, b) => b.fraction - a.fraction || a.index - b.index);
|
|
1572
|
+
for (let i = 0; remaining > 0 && i < order.length; i++, remaining--) out[order[i].index] += 1;
|
|
1573
|
+
return out;
|
|
1574
|
+
}
|
|
1575
|
+
function growSizes(sizes, weights, maxes, remaining) {
|
|
1576
|
+
while (remaining > 0) {
|
|
1577
|
+
const open = weights.map((weight, index) => ({
|
|
1578
|
+
index,
|
|
1579
|
+
weight
|
|
1580
|
+
})).filter(({ index, weight }) => weight > 0 && sizes[index] < maxes[index]);
|
|
1581
|
+
if (open.length === 0) return;
|
|
1582
|
+
const weightTotal = open.reduce((sum, next) => sum + next.weight, 0);
|
|
1583
|
+
let assigned = 0;
|
|
1584
|
+
const order = open.map(({ index, weight }) => {
|
|
1585
|
+
const raw = remaining * weight / weightTotal;
|
|
1586
|
+
const grant = Math.min(maxes[index] - sizes[index], Math.floor(raw));
|
|
1587
|
+
sizes[index] += grant;
|
|
1588
|
+
assigned += grant;
|
|
1589
|
+
return {
|
|
1590
|
+
index,
|
|
1591
|
+
fraction: raw - grant
|
|
1592
|
+
};
|
|
1593
|
+
}).sort((a, b) => b.fraction - a.fraction || a.index - b.index);
|
|
1594
|
+
remaining -= assigned;
|
|
1595
|
+
for (const { index } of order) {
|
|
1596
|
+
if (remaining <= 0) break;
|
|
1597
|
+
if (sizes[index] >= maxes[index]) continue;
|
|
1598
|
+
sizes[index] += 1;
|
|
1599
|
+
remaining -= 1;
|
|
1600
|
+
}
|
|
1601
|
+
if (assigned === 0 && order.every(({ index }) => sizes[index] >= maxes[index])) return;
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
function shrinkSizes(sizes, weights, mins, overflow) {
|
|
1605
|
+
while (overflow > 0) {
|
|
1606
|
+
const open = weights.map((weight, index) => ({
|
|
1607
|
+
index,
|
|
1608
|
+
weight
|
|
1609
|
+
})).filter(({ index, weight }) => weight > 0 && sizes[index] > mins[index]);
|
|
1610
|
+
if (open.length === 0) return;
|
|
1611
|
+
const weightTotal = open.reduce((sum, next) => sum + next.weight, 0);
|
|
1612
|
+
let assigned = 0;
|
|
1613
|
+
const order = open.map(({ index, weight }) => {
|
|
1614
|
+
const raw = overflow * weight / weightTotal;
|
|
1615
|
+
const shrink = Math.min(sizes[index] - mins[index], Math.floor(raw));
|
|
1616
|
+
sizes[index] -= shrink;
|
|
1617
|
+
assigned += shrink;
|
|
1618
|
+
return {
|
|
1619
|
+
index,
|
|
1620
|
+
fraction: raw - shrink
|
|
1621
|
+
};
|
|
1622
|
+
}).sort((a, b) => b.fraction - a.fraction || b.index - a.index);
|
|
1623
|
+
overflow -= assigned;
|
|
1624
|
+
for (const { index } of order) {
|
|
1625
|
+
if (overflow <= 0) break;
|
|
1626
|
+
if (sizes[index] <= mins[index]) continue;
|
|
1627
|
+
sizes[index] -= 1;
|
|
1628
|
+
overflow -= 1;
|
|
1629
|
+
}
|
|
1630
|
+
if (assigned === 0 && order.every(({ index }) => sizes[index] <= mins[index])) return;
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
function resolveMainSizes(items, direction, available, crossReference) {
|
|
1634
|
+
const mins = items.map((item) => resolveMainMin(item, direction, available));
|
|
1635
|
+
const maxes = items.map((item, index) => resolveMainMax(item, direction, available, mins[index]));
|
|
1636
|
+
const minTotal = mins.reduce((sum, next) => sum + next, 0);
|
|
1637
|
+
if (minTotal >= available) return proportionalSizes(mins, available);
|
|
1638
|
+
const sizes = items.map((item, index) => resolveMainBase(item, direction, available, crossReference, mins[index], maxes[index]));
|
|
1639
|
+
const total = sizes.reduce((sum, next) => sum + next, 0);
|
|
1640
|
+
if (total < available) growSizes(sizes, items.map((item) => item.grow), maxes, available - total);
|
|
1641
|
+
else if (total > available) shrinkSizes(sizes, items.map((item, index) => item.shrink * Math.max(1, sizes[index])), mins, total - available);
|
|
1642
|
+
return sizes;
|
|
1643
|
+
}
|
|
1644
|
+
function resolveCrossSize(item, direction, align, available, reference = available, mainReference = available) {
|
|
1645
|
+
const fixed = direction === "row" ? resolveSize(item.height, reference) : resolveSize(item.width, reference);
|
|
1646
|
+
const measured = resolveMeasuredCross(item, direction, mainReference, reference);
|
|
1647
|
+
const min = (direction === "row" ? resolveSize(item.minHeight, reference) : resolveSize(item.minWidth, reference)) ?? 0;
|
|
1648
|
+
const max = Math.max(min, (direction === "row" ? resolveSize(item.maxHeight, reference) : resolveSize(item.maxWidth, reference)) ?? Number.POSITIVE_INFINITY);
|
|
1649
|
+
const size = fixed ?? (align === "stretch" ? available : measured ?? available);
|
|
1650
|
+
return clampSize(size, min, max);
|
|
1651
|
+
}
|
|
1652
|
+
function justifyOffset(justify, slack) {
|
|
1653
|
+
if (justify === "end") return slack;
|
|
1654
|
+
if (justify === "center") return Math.floor(slack / 2);
|
|
1655
|
+
return 0;
|
|
1656
|
+
}
|
|
1657
|
+
function alignContentOffset(alignContent, slack) {
|
|
1658
|
+
if (alignContent === "end") return slack;
|
|
1659
|
+
if (alignContent === "center") return Math.floor(slack / 2);
|
|
1660
|
+
return 0;
|
|
1661
|
+
}
|
|
1662
|
+
function layoutFlexLine(items, options) {
|
|
1663
|
+
const totalGap = Math.max(0, items.length - 1) * options.gap;
|
|
1664
|
+
const availableMain = Math.max(0, options.mainSize - totalGap);
|
|
1665
|
+
const totalMainMargin = items.reduce((sum, item) => sum + mainMargin(item, options.direction), 0);
|
|
1666
|
+
const availableContentMain = Math.max(0, availableMain - totalMainMargin);
|
|
1667
|
+
const mainSizes = resolveMainSizes(items, options.direction, availableContentMain, options.crossReference);
|
|
1668
|
+
const usedMain = mainSizes.reduce((sum, next) => sum + next, 0) + totalMainMargin;
|
|
1669
|
+
const slack = Math.max(0, availableMain - usedMain);
|
|
1670
|
+
const gapExtras = items.map(() => 0);
|
|
1671
|
+
if (options.justifyContent === "space-between" && items.length > 1 && slack > 0) {
|
|
1672
|
+
const slots = items.length - 1;
|
|
1673
|
+
const extra = Math.floor(slack / slots);
|
|
1674
|
+
let remaining = slack - extra * slots;
|
|
1675
|
+
for (let i = 0; i < slots; i++) {
|
|
1676
|
+
gapExtras[i] = extra + (remaining > 0 ? 1 : 0);
|
|
1677
|
+
if (remaining > 0) remaining -= 1;
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
let cursor = options.mainStart + (options.justifyContent === "space-between" ? 0 : justifyOffset(options.justifyContent, slack));
|
|
1681
|
+
return items.map((item, index) => {
|
|
1682
|
+
const main = mainSizes[index] ?? 0;
|
|
1683
|
+
const align = item.alignSelf ?? options.alignItems;
|
|
1684
|
+
const itemCrossMargin = crossMargin(item, options.direction);
|
|
1685
|
+
const cross = resolveCrossSize(item, options.direction, align, Math.max(0, options.crossSize - itemCrossMargin), options.crossReference, options.mainSize);
|
|
1686
|
+
const outerCross = cross + itemCrossMargin;
|
|
1687
|
+
const crossOffset = align === "end" ? options.crossSize - outerCross : align === "center" ? Math.floor((options.crossSize - outerCross) / 2) : 0;
|
|
1688
|
+
const itemMainStart = cursor + mainBefore(item, options.direction);
|
|
1689
|
+
const itemCrossStart = options.crossStart + crossOffset + crossBefore(item, options.direction);
|
|
1690
|
+
const rect = options.direction === "row" ? {
|
|
1691
|
+
x: itemMainStart,
|
|
1692
|
+
y: itemCrossStart,
|
|
1693
|
+
w: main,
|
|
1694
|
+
h: cross
|
|
1695
|
+
} : {
|
|
1696
|
+
x: itemCrossStart,
|
|
1697
|
+
y: itemMainStart,
|
|
1698
|
+
w: cross,
|
|
1699
|
+
h: main
|
|
1700
|
+
};
|
|
1701
|
+
cursor += mainMargin(item, options.direction) + main + options.gap + (gapExtras[index] ?? 0);
|
|
1702
|
+
return {
|
|
1703
|
+
item,
|
|
1704
|
+
rect
|
|
1705
|
+
};
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
function lineBaseUsedMain(items, direction, mainSize, crossReference, gap) {
|
|
1709
|
+
const totalGap = Math.max(0, items.length - 1) * gap;
|
|
1710
|
+
const totalMainMargin = items.reduce((sum, item) => sum + mainMargin(item, direction), 0);
|
|
1711
|
+
const reference = Math.max(0, mainSize - totalGap - totalMainMargin);
|
|
1712
|
+
return totalGap + totalMainMargin + items.reduce((sum, item) => {
|
|
1713
|
+
const min = resolveMainMin(item, direction, reference);
|
|
1714
|
+
const max = resolveMainMax(item, direction, reference, min);
|
|
1715
|
+
return sum + resolveMainBase(item, direction, reference, crossReference, min, max);
|
|
1716
|
+
}, 0);
|
|
1717
|
+
}
|
|
1718
|
+
function createWrappedLines(items, direction, availableMain, crossReference, gap) {
|
|
1719
|
+
const lines = [];
|
|
1720
|
+
let line = [];
|
|
1721
|
+
for (const item of items) {
|
|
1722
|
+
const nextLine = [...line, item];
|
|
1723
|
+
const nextUsed = lineBaseUsedMain(nextLine, direction, availableMain, crossReference, gap);
|
|
1724
|
+
if (line.length > 0 && nextUsed > availableMain) {
|
|
1725
|
+
lines.push(line);
|
|
1726
|
+
line = [item];
|
|
1727
|
+
continue;
|
|
1728
|
+
}
|
|
1729
|
+
line = nextLine;
|
|
1730
|
+
}
|
|
1731
|
+
if (line.length > 0) lines.push(line);
|
|
1732
|
+
return lines;
|
|
1733
|
+
}
|
|
1734
|
+
function resolveWrappedLineCrossSizes(lines, direction, availableCross, crossReference, mainReference) {
|
|
1735
|
+
const bases = lines.map((line) => Math.max(1, ...line.map((item) => resolveCrossBase(item, direction, crossReference, mainReference) + crossMargin(item, direction))));
|
|
1736
|
+
const baseTotal = bases.reduce((sum, next) => sum + next, 0);
|
|
1737
|
+
if (baseTotal <= availableCross) return bases;
|
|
1738
|
+
return bases;
|
|
1739
|
+
}
|
|
1740
|
+
function layoutFlexItems(items, options) {
|
|
1741
|
+
const padding = fitEdges(options.padding, options.w, options.h);
|
|
1742
|
+
const contentX = padding.left;
|
|
1743
|
+
const contentY = padding.top;
|
|
1744
|
+
const contentW = Math.max(0, options.w - padding.left - padding.right);
|
|
1745
|
+
const contentH = Math.max(0, options.h - padding.top - padding.bottom);
|
|
1746
|
+
const mainSize = options.direction === "row" ? contentW : contentH;
|
|
1747
|
+
const crossSize = options.direction === "row" ? contentH : contentW;
|
|
1748
|
+
if (!options.wrap) return layoutFlexLine(items, {
|
|
1749
|
+
direction: options.direction,
|
|
1750
|
+
gap: options.mainGap,
|
|
1751
|
+
alignItems: options.alignItems,
|
|
1752
|
+
justifyContent: options.justifyContent,
|
|
1753
|
+
mainStart: options.direction === "row" ? contentX : contentY,
|
|
1754
|
+
crossStart: options.direction === "row" ? contentY : contentX,
|
|
1755
|
+
mainSize,
|
|
1756
|
+
crossSize,
|
|
1757
|
+
crossReference: crossSize
|
|
1758
|
+
});
|
|
1759
|
+
const lines = createWrappedLines(items, options.direction, mainSize, crossSize, options.mainGap);
|
|
1760
|
+
const availableCross = Math.max(0, crossSize - Math.max(0, lines.length - 1) * options.crossGap);
|
|
1761
|
+
const lineCrossSizes = resolveWrappedLineCrossSizes(lines, options.direction, availableCross, crossSize, mainSize);
|
|
1762
|
+
let slack = Math.max(0, availableCross - lineCrossSizes.reduce((sum, next) => sum + next, 0));
|
|
1763
|
+
const crossGapExtras = lines.map(() => 0);
|
|
1764
|
+
if (options.alignContent === "stretch" && lineCrossSizes.length > 0 && slack > 0) {
|
|
1765
|
+
const extraSizes = proportionalSizes(lineCrossSizes.map(() => 1), slack);
|
|
1766
|
+
for (let i = 0; i < lineCrossSizes.length; i++) lineCrossSizes[i] += extraSizes[i] ?? 0;
|
|
1767
|
+
slack = 0;
|
|
1768
|
+
} else if (options.alignContent === "space-between" && lines.length > 1 && slack > 0) {
|
|
1769
|
+
const extraGaps = proportionalSizes(Array.from({ length: lines.length - 1 }, () => 1), slack);
|
|
1770
|
+
for (let i = 0; i < extraGaps.length; i++) crossGapExtras[i] = extraGaps[i] ?? 0;
|
|
1771
|
+
slack = 0;
|
|
1772
|
+
}
|
|
1773
|
+
let crossCursor = (options.direction === "row" ? contentY : contentX) + alignContentOffset(options.alignContent, slack);
|
|
1774
|
+
const out = [];
|
|
1775
|
+
for (let index = 0; index < lines.length; index++) {
|
|
1776
|
+
const line = lines[index];
|
|
1777
|
+
const lineCross = lineCrossSizes[index] ?? 0;
|
|
1778
|
+
out.push(...layoutFlexLine(line, {
|
|
1779
|
+
direction: options.direction,
|
|
1780
|
+
gap: options.mainGap,
|
|
1781
|
+
alignItems: options.alignItems,
|
|
1782
|
+
justifyContent: options.justifyContent,
|
|
1783
|
+
mainStart: options.direction === "row" ? contentX : contentY,
|
|
1784
|
+
crossStart: crossCursor,
|
|
1785
|
+
mainSize,
|
|
1786
|
+
crossSize: lineCross,
|
|
1787
|
+
crossReference: crossSize
|
|
1788
|
+
}));
|
|
1789
|
+
crossCursor += lineCross + options.crossGap + (crossGapExtras[index] ?? 0);
|
|
1790
|
+
}
|
|
1791
|
+
return out;
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
//#endregion
|
|
1795
|
+
//#region src/vue/components/TFlex.ts
|
|
1796
|
+
function normalizeInteger(value, fallback = 0) {
|
|
1797
|
+
const n = Math.floor(Number(value));
|
|
1798
|
+
return Number.isFinite(n) ? n : fallback;
|
|
1799
|
+
}
|
|
1800
|
+
function edgeProp(props, key) {
|
|
1801
|
+
return normalizeOptionalCellCount(props?.[key]);
|
|
1802
|
+
}
|
|
1803
|
+
function resolveEdges(props, options) {
|
|
1804
|
+
const all = edgeProp(props, options.all) ?? 0;
|
|
1805
|
+
const x = edgeProp(props, options.x) ?? all;
|
|
1806
|
+
const y = edgeProp(props, options.y) ?? all;
|
|
1807
|
+
return {
|
|
1808
|
+
top: edgeProp(props, options.top) ?? y,
|
|
1809
|
+
right: edgeProp(props, options.right) ?? x,
|
|
1810
|
+
bottom: edgeProp(props, options.bottom) ?? y,
|
|
1811
|
+
left: edgeProp(props, options.left) ?? x
|
|
1812
|
+
};
|
|
1813
|
+
}
|
|
1814
|
+
function sizeProp(props, key) {
|
|
1815
|
+
const value = props?.[key];
|
|
1816
|
+
if (value == null) return void 0;
|
|
1817
|
+
if (typeof value === "number") return Number.isFinite(value) ? Math.max(0, value) : void 0;
|
|
1818
|
+
if (typeof value !== "string") return void 0;
|
|
1819
|
+
const text = value.trim();
|
|
1820
|
+
if (text.endsWith("%")) {
|
|
1821
|
+
const n = Number(text.slice(0, -1));
|
|
1822
|
+
if (!Number.isFinite(n)) return void 0;
|
|
1823
|
+
return `${Math.max(0, n)}%`;
|
|
1824
|
+
}
|
|
1825
|
+
return normalizeOptionalCellCount(text);
|
|
1826
|
+
}
|
|
1827
|
+
function collectChildren(nodes) {
|
|
1828
|
+
const out = [];
|
|
1829
|
+
for (const node of nodes) {
|
|
1830
|
+
if (node.type === Comment) continue;
|
|
1831
|
+
if (node.type === Fragment && Array.isArray(node.children)) {
|
|
1832
|
+
out.push(...collectChildren(node.children));
|
|
1833
|
+
continue;
|
|
1834
|
+
}
|
|
1835
|
+
out.push(node);
|
|
1836
|
+
}
|
|
1837
|
+
return out;
|
|
1838
|
+
}
|
|
1839
|
+
function isFlexItemVNode(vnode) {
|
|
1840
|
+
return vnode.type === TFlexItem;
|
|
1841
|
+
}
|
|
1842
|
+
function createFlexItem(vnode, slotIndex) {
|
|
1843
|
+
const props = vnode.props;
|
|
1844
|
+
const margin = resolveEdges(props, {
|
|
1845
|
+
all: "margin",
|
|
1846
|
+
x: "marginX",
|
|
1847
|
+
y: "marginY",
|
|
1848
|
+
top: "marginTop",
|
|
1849
|
+
right: "marginRight",
|
|
1850
|
+
bottom: "marginBottom",
|
|
1851
|
+
left: "marginLeft"
|
|
1852
|
+
});
|
|
1853
|
+
return {
|
|
1854
|
+
vnode,
|
|
1855
|
+
isFlexItem: isFlexItemVNode(vnode),
|
|
1856
|
+
grow: normalizeRatio(props?.grow, 0),
|
|
1857
|
+
shrink: normalizeRatio(props?.shrink, 1),
|
|
1858
|
+
basis: sizeProp(props, "basis"),
|
|
1859
|
+
width: sizeProp(props, "width") ?? sizeProp(props, "w"),
|
|
1860
|
+
height: sizeProp(props, "height") ?? sizeProp(props, "h"),
|
|
1861
|
+
minWidth: sizeProp(props, "minWidth"),
|
|
1862
|
+
minHeight: sizeProp(props, "minHeight"),
|
|
1863
|
+
maxWidth: sizeProp(props, "maxWidth"),
|
|
1864
|
+
maxHeight: sizeProp(props, "maxHeight"),
|
|
1865
|
+
measure: typeof props?.measure === "function" ? props.measure : void 0,
|
|
1866
|
+
measureCache: typeof props?.measure === "function" ? new Map() : void 0,
|
|
1867
|
+
order: normalizeInteger(props?.order),
|
|
1868
|
+
slotIndex,
|
|
1869
|
+
zIndex: normalizeInteger(props?.zIndex),
|
|
1870
|
+
marginTop: margin.top,
|
|
1871
|
+
marginRight: margin.right,
|
|
1872
|
+
marginBottom: margin.bottom,
|
|
1873
|
+
marginLeft: margin.left,
|
|
1874
|
+
alignSelf: props?.alignSelf
|
|
1875
|
+
};
|
|
1876
|
+
}
|
|
1877
|
+
function renderFlexItemChildren(item, rect) {
|
|
1878
|
+
if (!item.isFlexItem) return item.vnode;
|
|
1879
|
+
const children = item.vnode.children;
|
|
1880
|
+
if (typeof children === "function") return children({ rect });
|
|
1881
|
+
if (children && typeof children === "object" && !Array.isArray(children)) {
|
|
1882
|
+
const defaultSlot = children.default;
|
|
1883
|
+
if (defaultSlot) return defaultSlot({ rect });
|
|
1884
|
+
}
|
|
1885
|
+
return Array.isArray(children) ? children : children ?? null;
|
|
1886
|
+
}
|
|
1887
|
+
const TFlexItem = defineComponent({
|
|
1888
|
+
name: "TFlexItem",
|
|
1889
|
+
props: {
|
|
1890
|
+
grow: {
|
|
1891
|
+
type: Number,
|
|
1892
|
+
default: 0
|
|
1893
|
+
},
|
|
1894
|
+
shrink: {
|
|
1895
|
+
type: Number,
|
|
1896
|
+
default: 1
|
|
1897
|
+
},
|
|
1898
|
+
basis: {
|
|
1899
|
+
type: [Number, String],
|
|
1900
|
+
default: void 0
|
|
1901
|
+
},
|
|
1902
|
+
w: {
|
|
1903
|
+
type: [Number, String],
|
|
1904
|
+
default: void 0
|
|
1905
|
+
},
|
|
1906
|
+
width: {
|
|
1907
|
+
type: [Number, String],
|
|
1908
|
+
default: void 0
|
|
1909
|
+
},
|
|
1910
|
+
h: {
|
|
1911
|
+
type: [Number, String],
|
|
1912
|
+
default: void 0
|
|
1913
|
+
},
|
|
1914
|
+
height: {
|
|
1915
|
+
type: [Number, String],
|
|
1916
|
+
default: void 0
|
|
1917
|
+
},
|
|
1918
|
+
minWidth: {
|
|
1919
|
+
type: [Number, String],
|
|
1920
|
+
default: void 0
|
|
1921
|
+
},
|
|
1922
|
+
minHeight: {
|
|
1923
|
+
type: [Number, String],
|
|
1924
|
+
default: void 0
|
|
1925
|
+
},
|
|
1926
|
+
maxWidth: {
|
|
1927
|
+
type: [Number, String],
|
|
1928
|
+
default: void 0
|
|
1929
|
+
},
|
|
1930
|
+
maxHeight: {
|
|
1931
|
+
type: [Number, String],
|
|
1932
|
+
default: void 0
|
|
1933
|
+
},
|
|
1934
|
+
measure: {
|
|
1935
|
+
type: Function,
|
|
1936
|
+
default: void 0
|
|
1937
|
+
},
|
|
1938
|
+
order: {
|
|
1939
|
+
type: Number,
|
|
1940
|
+
default: 0
|
|
1941
|
+
},
|
|
1942
|
+
zIndex: {
|
|
1943
|
+
type: Number,
|
|
1944
|
+
default: 0
|
|
1945
|
+
},
|
|
1946
|
+
margin: {
|
|
1947
|
+
type: Number,
|
|
1948
|
+
default: 0
|
|
1949
|
+
},
|
|
1950
|
+
marginX: {
|
|
1951
|
+
type: Number,
|
|
1952
|
+
default: void 0
|
|
1953
|
+
},
|
|
1954
|
+
marginY: {
|
|
1955
|
+
type: Number,
|
|
1956
|
+
default: void 0
|
|
1957
|
+
},
|
|
1958
|
+
marginTop: {
|
|
1959
|
+
type: Number,
|
|
1960
|
+
default: void 0
|
|
1961
|
+
},
|
|
1962
|
+
marginRight: {
|
|
1963
|
+
type: Number,
|
|
1964
|
+
default: void 0
|
|
1965
|
+
},
|
|
1966
|
+
marginBottom: {
|
|
1967
|
+
type: Number,
|
|
1968
|
+
default: void 0
|
|
1969
|
+
},
|
|
1970
|
+
marginLeft: {
|
|
1971
|
+
type: Number,
|
|
1972
|
+
default: void 0
|
|
1973
|
+
},
|
|
1974
|
+
alignSelf: {
|
|
1975
|
+
type: String,
|
|
1976
|
+
default: void 0
|
|
1977
|
+
}
|
|
1978
|
+
},
|
|
1979
|
+
setup(_props, { slots }) {
|
|
1980
|
+
return () => slots.default?.() ?? null;
|
|
1981
|
+
}
|
|
1982
|
+
});
|
|
1983
|
+
const TFlex = defineComponent({
|
|
1984
|
+
name: "TFlex",
|
|
1985
|
+
props: {
|
|
1986
|
+
x: {
|
|
1987
|
+
type: Number,
|
|
1988
|
+
required: true
|
|
1989
|
+
},
|
|
1990
|
+
y: {
|
|
1991
|
+
type: Number,
|
|
1992
|
+
required: true
|
|
1993
|
+
},
|
|
1994
|
+
w: {
|
|
1995
|
+
type: Number,
|
|
1996
|
+
required: true
|
|
1997
|
+
},
|
|
1998
|
+
h: {
|
|
1999
|
+
type: Number,
|
|
2000
|
+
required: true
|
|
2001
|
+
},
|
|
2002
|
+
direction: {
|
|
2003
|
+
type: String,
|
|
2004
|
+
default: "row"
|
|
2005
|
+
},
|
|
2006
|
+
gap: {
|
|
2007
|
+
type: Number,
|
|
2008
|
+
default: 0
|
|
2009
|
+
},
|
|
2010
|
+
rowGap: {
|
|
2011
|
+
type: Number,
|
|
2012
|
+
default: void 0
|
|
2013
|
+
},
|
|
2014
|
+
columnGap: {
|
|
2015
|
+
type: Number,
|
|
2016
|
+
default: void 0
|
|
2017
|
+
},
|
|
2018
|
+
padding: {
|
|
2019
|
+
type: Number,
|
|
2020
|
+
default: 0
|
|
2021
|
+
},
|
|
2022
|
+
paddingX: {
|
|
2023
|
+
type: Number,
|
|
2024
|
+
default: void 0
|
|
2025
|
+
},
|
|
2026
|
+
paddingY: {
|
|
2027
|
+
type: Number,
|
|
2028
|
+
default: void 0
|
|
2029
|
+
},
|
|
2030
|
+
paddingTop: {
|
|
2031
|
+
type: Number,
|
|
2032
|
+
default: void 0
|
|
2033
|
+
},
|
|
2034
|
+
paddingRight: {
|
|
2035
|
+
type: Number,
|
|
2036
|
+
default: void 0
|
|
2037
|
+
},
|
|
2038
|
+
paddingBottom: {
|
|
2039
|
+
type: Number,
|
|
2040
|
+
default: void 0
|
|
2041
|
+
},
|
|
2042
|
+
paddingLeft: {
|
|
2043
|
+
type: Number,
|
|
2044
|
+
default: void 0
|
|
2045
|
+
},
|
|
2046
|
+
wrap: {
|
|
2047
|
+
type: Boolean,
|
|
2048
|
+
default: false
|
|
2049
|
+
},
|
|
2050
|
+
alignItems: {
|
|
2051
|
+
type: String,
|
|
2052
|
+
default: "stretch"
|
|
2053
|
+
},
|
|
2054
|
+
justifyContent: {
|
|
2055
|
+
type: String,
|
|
2056
|
+
default: "start"
|
|
2057
|
+
},
|
|
2058
|
+
alignContent: {
|
|
2059
|
+
type: String,
|
|
2060
|
+
default: "start"
|
|
2061
|
+
},
|
|
2062
|
+
zIndex: {
|
|
2063
|
+
type: Number,
|
|
2064
|
+
default: 0
|
|
2065
|
+
}
|
|
2066
|
+
},
|
|
2067
|
+
setup(props, { slots }) {
|
|
2068
|
+
return () => {
|
|
2069
|
+
const items = collectChildren(slots.default?.() ?? []).map((vnode, index) => ({
|
|
2070
|
+
item: createFlexItem(vnode, index),
|
|
2071
|
+
index
|
|
2072
|
+
})).sort((a, b) => a.item.order - b.item.order || a.index - b.index).map(({ item }) => item);
|
|
2073
|
+
const gap = normalizeCellCount$1(props.gap);
|
|
2074
|
+
const rowGap = props.rowGap == null ? gap : normalizeCellCount$1(props.rowGap);
|
|
2075
|
+
const columnGap = props.columnGap == null ? gap : normalizeCellCount$1(props.columnGap);
|
|
2076
|
+
const padding = resolveEdges(props, {
|
|
2077
|
+
all: "padding",
|
|
2078
|
+
x: "paddingX",
|
|
2079
|
+
y: "paddingY",
|
|
2080
|
+
top: "paddingTop",
|
|
2081
|
+
right: "paddingRight",
|
|
2082
|
+
bottom: "paddingBottom",
|
|
2083
|
+
left: "paddingLeft"
|
|
2084
|
+
});
|
|
2085
|
+
const layout = layoutFlexItems(items, {
|
|
2086
|
+
w: normalizeCellCount$1(props.w),
|
|
2087
|
+
h: normalizeCellCount$1(props.h),
|
|
2088
|
+
direction: props.direction,
|
|
2089
|
+
mainGap: props.direction === "row" ? columnGap : rowGap,
|
|
2090
|
+
crossGap: props.direction === "row" ? rowGap : columnGap,
|
|
2091
|
+
padding,
|
|
2092
|
+
wrap: props.wrap,
|
|
2093
|
+
alignItems: props.alignItems,
|
|
2094
|
+
justifyContent: props.justifyContent,
|
|
2095
|
+
alignContent: props.alignContent
|
|
2096
|
+
});
|
|
2097
|
+
return h(TView, {
|
|
2098
|
+
x: props.x,
|
|
2099
|
+
y: props.y,
|
|
2100
|
+
w: normalizeCellCount$1(props.w),
|
|
2101
|
+
h: normalizeCellCount$1(props.h),
|
|
2102
|
+
zIndex: props.zIndex
|
|
2103
|
+
}, () => layout.map(({ item, rect }) => h(TView, {
|
|
2104
|
+
key: item.vnode.key ?? item.slotIndex,
|
|
2105
|
+
x: rect.x,
|
|
2106
|
+
y: rect.y,
|
|
2107
|
+
w: rect.w,
|
|
2108
|
+
h: rect.h,
|
|
2109
|
+
zIndex: item.zIndex
|
|
2110
|
+
}, () => renderFlexItemChildren(item, rect))));
|
|
2111
|
+
};
|
|
2112
|
+
}
|
|
2113
|
+
});
|
|
2114
|
+
|
|
1449
2115
|
//#endregion
|
|
1450
2116
|
//#region src/vue/components/TFlow.ts
|
|
1451
2117
|
const TFlow = defineComponent({
|
|
@@ -2851,7 +3517,7 @@ const TContextMenu = defineComponent({
|
|
|
2851
3517
|
}
|
|
2852
3518
|
function selectedIndex() {
|
|
2853
3519
|
if (!props.items.length) return 0;
|
|
2854
|
-
const clamped = clamp
|
|
3520
|
+
const clamped = clamp(props.selectedIndex ?? innerSelectedIndex.value, 0, props.items.length - 1);
|
|
2855
3521
|
if (!props.items[clamped]?.disabled) return clamped;
|
|
2856
3522
|
const first = firstEnabledIndex();
|
|
2857
3523
|
return first >= 0 ? first : clamped;
|
|
@@ -3954,4 +4620,4 @@ const TRouterView = defineComponent({
|
|
|
3954
4620
|
});
|
|
3955
4621
|
|
|
3956
4622
|
//#endregion
|
|
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 };
|
|
4623
|
+
export { TAnchor, TAutocompleteInput, TBadge, TBox, TBreadcrumb, TCheckbox, TCode, TCommandPalette, TContextMenu, TDataTable, TDebugOverlay, TDialog, TDivider, TFlex, TFlexItem, TFlow, TForm, TFormContextKey, TFormField, TInput, TInputBox, TInputPluginsContextKey, TJsonEditor, TKeyHint, TLink, TLinkifyText, TList, TMermaid, TMermaidText, 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, isSimpleMermaidFlowchartSource, linkifyTextSegments, lintJsonText, markMermaidRenderErrorFatal, padEndByCells, resolveOverlayPlacement, sliceByCells, sliceByCellsRange, spaces, textCellWidth, tuiDefaultTheme, useLayout, useRenderNode, useRoute, useRouter, useTForm, useTerminal, useTerminalNode, useTerminalRuntime, useVisibility, wrapByCells };
|