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