@loccal/ui 0.0.0-stage → 0.2.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/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +38 -3
- package/dist/components/ui/accordion.d.ts +6 -0
- package/dist/components/ui/accordion.js +17 -0
- package/dist/components/ui/ai-panel.d.ts +47 -0
- package/dist/components/ui/ai-panel.js +74 -0
- package/dist/components/ui/alert-dialog.d.ts +18 -0
- package/dist/components/ui/alert-dialog.js +42 -0
- package/dist/components/ui/alert.d.ts +10 -0
- package/dist/components/ui/alert.js +27 -0
- package/dist/components/ui/avatar.d.ts +11 -0
- package/dist/components/ui/avatar.js +23 -0
- package/dist/components/ui/badge.d.ts +7 -0
- package/dist/components/ui/badge.js +36 -0
- package/dist/components/ui/breadcrumb.d.ts +10 -0
- package/dist/components/ui/breadcrumb.js +36 -0
- package/dist/components/ui/button-group.d.ts +10 -0
- package/dist/components/ui/button-group.js +36 -0
- package/dist/components/ui/button.d.ts +8 -0
- package/dist/components/ui/button.js +34 -0
- package/dist/components/ui/calendar.d.ts +10 -0
- package/dist/components/ui/calendar.js +76 -0
- package/dist/components/ui/card.d.ts +11 -0
- package/dist/components/ui/card.js +24 -0
- package/dist/components/ui/chart.d.ts +44 -0
- package/dist/components/ui/chart.js +132 -0
- package/dist/components/ui/checkbox.d.ts +3 -0
- package/dist/components/ui/checkbox.js +9 -0
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/collapsible.js +13 -0
- package/dist/components/ui/command-block.d.ts +28 -0
- package/dist/components/ui/command-block.js +58 -0
- package/dist/components/ui/command.d.ts +19 -0
- package/dist/components/ui/command.js +35 -0
- package/dist/components/ui/connection-status.d.ts +29 -0
- package/dist/components/ui/connection-status.js +26 -0
- package/dist/components/ui/context-menu.d.ts +29 -0
- package/dist/components/ui/context-menu.js +51 -0
- package/dist/components/ui/data-table.d.ts +49 -0
- package/dist/components/ui/data-table.js +100 -0
- package/dist/components/ui/dialog.d.ts +18 -0
- package/dist/components/ui/dialog.js +37 -0
- package/dist/components/ui/drawer.d.ts +16 -0
- package/dist/components/ui/drawer.js +75 -0
- package/dist/components/ui/dropdown-menu.d.ts +29 -0
- package/dist/components/ui/dropdown-menu.js +51 -0
- package/dist/components/ui/dropzone.d.ts +11 -0
- package/dist/components/ui/dropzone.js +39 -0
- package/dist/components/ui/empty.d.ts +11 -0
- package/dist/components/ui/empty.js +33 -0
- package/dist/components/ui/field.d.ts +24 -0
- package/dist/components/ui/field.js +68 -0
- package/dist/components/ui/file-tree.d.ts +42 -0
- package/dist/components/ui/file-tree.js +85 -0
- package/dist/components/ui/hash-chain.d.ts +43 -0
- package/dist/components/ui/hash-chain.js +34 -0
- package/dist/components/ui/history-palette.d.ts +37 -0
- package/dist/components/ui/history-palette.js +44 -0
- package/dist/components/ui/hover-card.d.ts +5 -0
- package/dist/components/ui/hover-card.js +14 -0
- package/dist/components/ui/icon-base.d.ts +15 -0
- package/dist/components/ui/icon-base.js +18 -0
- package/dist/components/ui/icon.d.ts +15 -0
- package/dist/components/ui/icon.js +32 -0
- package/dist/components/ui/icons-compat.d.ts +32 -0
- package/dist/components/ui/icons-compat.js +34 -0
- package/dist/components/ui/icons.d.ts +1048 -0
- package/dist/components/ui/icons.js +264 -0
- package/dist/components/ui/input-group.d.ts +18 -0
- package/dist/components/ui/input-group.js +57 -0
- package/dist/components/ui/input-otp.d.ts +11 -0
- package/dist/components/ui/input-otp.js +21 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/input.js +7 -0
- package/dist/components/ui/kbd.d.ts +3 -0
- package/dist/components/ui/kbd.js +9 -0
- package/dist/components/ui/label.d.ts +3 -0
- package/dist/components/ui/label.js +7 -0
- package/dist/components/ui/locale-switch.d.ts +9 -0
- package/dist/components/ui/locale-switch.js +31 -0
- package/dist/components/ui/log-panel.d.ts +28 -0
- package/dist/components/ui/log-panel.js +59 -0
- package/dist/components/ui/menubar.d.ts +29 -0
- package/dist/components/ui/menubar.js +56 -0
- package/dist/components/ui/metric-grid.d.ts +20 -0
- package/dist/components/ui/metric-grid.js +14 -0
- package/dist/components/ui/model-list.d.ts +33 -0
- package/dist/components/ui/model-list.js +69 -0
- package/dist/components/ui/navigation-menu.d.ts +11 -0
- package/dist/components/ui/navigation-menu.js +31 -0
- package/dist/components/ui/number-field.d.ts +29 -0
- package/dist/components/ui/number-field.js +65 -0
- package/dist/components/ui/pagination.d.ts +17 -0
- package/dist/components/ui/pagination.js +26 -0
- package/dist/components/ui/pane-tree.d.ts +18 -0
- package/dist/components/ui/pane-tree.js +65 -0
- package/dist/components/ui/popover.d.ts +9 -0
- package/dist/components/ui/popover.js +23 -0
- package/dist/components/ui/progress.d.ts +7 -0
- package/dist/components/ui/progress.js +20 -0
- package/dist/components/ui/radio-group.d.ts +5 -0
- package/dist/components/ui/radio-group.js +12 -0
- package/dist/components/ui/resizable.d.ts +7 -0
- package/dist/components/ui/resizable.js +14 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/scroll-area.js +11 -0
- package/dist/components/ui/select.d.ts +15 -0
- package/dist/components/ui/select.js +34 -0
- package/dist/components/ui/separator.d.ts +3 -0
- package/dist/components/ui/separator.js +8 -0
- package/dist/components/ui/settings-layout.d.ts +31 -0
- package/dist/components/ui/settings-layout.js +45 -0
- package/dist/components/ui/sheet.d.ts +14 -0
- package/dist/components/ui/sheet.js +37 -0
- package/dist/components/ui/shell-picker.d.ts +18 -0
- package/dist/components/ui/shell-picker.js +17 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/skeleton.js +6 -0
- package/dist/components/ui/slider.d.ts +3 -0
- package/dist/components/ui/slider.js +12 -0
- package/dist/components/ui/sonner.d.ts +3 -0
- package/dist/components/ui/sonner.js +25 -0
- package/dist/components/ui/spinner.d.ts +2 -0
- package/dist/components/ui/spinner.js +7 -0
- package/dist/components/ui/split-button.d.ts +21 -0
- package/dist/components/ui/split-button.js +14 -0
- package/dist/components/ui/stat.d.ts +10 -0
- package/dist/components/ui/stat.js +8 -0
- package/dist/components/ui/status-bar.d.ts +13 -0
- package/dist/components/ui/status-bar.js +15 -0
- package/dist/components/ui/stepper.d.ts +13 -0
- package/dist/components/ui/stepper.js +11 -0
- package/dist/components/ui/switch.d.ts +5 -0
- package/dist/components/ui/switch.js +8 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/table.js +28 -0
- package/dist/components/ui/tabs.d.ts +10 -0
- package/dist/components/ui/tabs.js +29 -0
- package/dist/components/ui/terminal-tabs.d.ts +31 -0
- package/dist/components/ui/terminal-tabs.js +109 -0
- package/dist/components/ui/terminal-view.d.ts +51 -0
- package/dist/components/ui/terminal-view.js +189 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/textarea.js +6 -0
- package/dist/components/ui/timeline.d.ts +9 -0
- package/dist/components/ui/timeline.js +18 -0
- package/dist/components/ui/toggle-group.d.ts +11 -0
- package/dist/components/ui/toggle-group.js +24 -0
- package/dist/components/ui/toggle.d.ts +8 -0
- package/dist/components/ui/toggle.js +26 -0
- package/dist/components/ui/tooltip.d.ts +6 -0
- package/dist/components/ui/tooltip.js +17 -0
- package/dist/components/ui/tree-view.d.ts +20 -0
- package/dist/components/ui/tree-view.js +41 -0
- package/dist/components/ui/window-frame.d.ts +35 -0
- package/dist/components/ui/window-frame.js +49 -0
- package/dist/lib/ai-markdown.d.ts +13 -0
- package/dist/lib/ai-markdown.js +46 -0
- package/dist/lib/command-risk.d.ts +6 -0
- package/dist/lib/command-risk.js +42 -0
- package/dist/lib/file-kind.d.ts +10 -0
- package/dist/lib/file-kind.js +63 -0
- package/dist/lib/format.d.ts +9 -0
- package/dist/lib/format.js +30 -0
- package/dist/lib/i18n-core.d.ts +20 -0
- package/dist/lib/i18n-core.js +36 -0
- package/dist/lib/i18n.d.ts +15 -0
- package/dist/lib/i18n.js +68 -0
- package/dist/lib/icon-data.d.ts +276 -0
- package/dist/lib/icon-data.js +307 -0
- package/dist/lib/icon-shapes.d.ts +14 -0
- package/dist/lib/icon-shapes.js +47 -0
- package/dist/lib/log-filter.d.ts +23 -0
- package/dist/lib/log-filter.js +44 -0
- package/dist/lib/number-field.d.ts +11 -0
- package/dist/lib/number-field.js +30 -0
- package/dist/lib/pane-tree.d.ts +39 -0
- package/dist/lib/pane-tree.js +92 -0
- package/dist/lib/platform.d.ts +10 -0
- package/dist/lib/platform.js +24 -0
- package/dist/lib/shell-meta.d.ts +7 -0
- package/dist/lib/shell-meta.js +70 -0
- package/dist/lib/tab-order.d.ts +6 -0
- package/dist/lib/tab-order.js +24 -0
- package/dist/lib/table-sort.d.ts +16 -0
- package/dist/lib/table-sort.js +66 -0
- package/dist/lib/terminal-themes.d.ts +30 -0
- package/dist/lib/terminal-themes.js +90 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +5 -0
- package/dist-cdn/loccal-ui.css +971 -0
- package/dist-cdn/loccal-ui.min.js +1 -0
- package/dist-wc/base.d.ts +31 -0
- package/dist-wc/base.js +104 -0
- package/dist-wc/button.d.ts +12 -0
- package/dist-wc/button.js +47 -0
- package/dist-wc/calendar.d.ts +16 -0
- package/dist-wc/calendar.js +106 -0
- package/dist-wc/choice.d.ts +17 -0
- package/dist-wc/choice.js +76 -0
- package/dist-wc/command.d.ts +32 -0
- package/dist-wc/command.js +181 -0
- package/dist-wc/data-table.d.ts +22 -0
- package/dist-wc/data-table.js +128 -0
- package/dist-wc/dialog.d.ts +29 -0
- package/dist-wc/dialog.js +94 -0
- package/dist-wc/disclosure.d.ts +17 -0
- package/dist-wc/disclosure.js +91 -0
- package/dist-wc/fields2.d.ts +38 -0
- package/dist-wc/fields2.js +133 -0
- package/dist-wc/file-tree.d.ts +19 -0
- package/dist-wc/file-tree.js +97 -0
- package/dist-wc/floating.d.ts +32 -0
- package/dist-wc/floating.js +91 -0
- package/dist-wc/index.d.ts +23 -0
- package/dist-wc/index.js +24 -0
- package/dist-wc/input-otp.d.ts +14 -0
- package/dist-wc/input-otp.js +82 -0
- package/dist-wc/navigation-menu.d.ts +14 -0
- package/dist-wc/navigation-menu.js +75 -0
- package/dist-wc/number-field.d.ts +13 -0
- package/dist-wc/number-field.js +67 -0
- package/dist-wc/resizable.d.ts +14 -0
- package/dist-wc/resizable.js +57 -0
- package/dist-wc/select.d.ts +17 -0
- package/dist-wc/select.js +80 -0
- package/dist-wc/static.d.ts +1 -0
- package/dist-wc/static.js +175 -0
- package/dist-wc/status-bar.d.ts +11 -0
- package/dist-wc/status-bar.js +54 -0
- package/dist-wc/styles.css +971 -0
- package/dist-wc/tabs.d.ts +16 -0
- package/dist-wc/tabs.js +62 -0
- package/dist-wc/terminal-tabs.d.ts +16 -0
- package/dist-wc/terminal-tabs.js +79 -0
- package/dist-wc/toaster.d.ts +16 -0
- package/dist-wc/toaster.js +68 -0
- package/dist-wc/toggle.d.ts +30 -0
- package/dist-wc/toggle.js +101 -0
- package/dist-wc/tree.d.ts +17 -0
- package/dist-wc/tree.js +72 -0
- package/docs/ARQUITETURA-VANILLA.md +54 -0
- package/docs/VERSIONING.md +88 -0
- package/package.json +1058 -6
- package/styles.css +426 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Arvore de paineis imutavel (splits recursivos). Sem dependencias de React:
|
|
2
|
+
// toda operacao devolve uma nova raiz e preserva por referencia os nos inalterados.
|
|
3
|
+
export const MIN_RATIO = 0.1;
|
|
4
|
+
export const MAX_RATIO = 0.9;
|
|
5
|
+
export function clampRatio(ratio) {
|
|
6
|
+
if (!Number.isFinite(ratio))
|
|
7
|
+
return 0.5;
|
|
8
|
+
return Math.min(MAX_RATIO, Math.max(MIN_RATIO, ratio));
|
|
9
|
+
}
|
|
10
|
+
export function leaf(id) {
|
|
11
|
+
return { type: "leaf", id };
|
|
12
|
+
}
|
|
13
|
+
/** Ids das folhas na ordem visual (primeiro -> segundo). */
|
|
14
|
+
export function leaves(node) {
|
|
15
|
+
if (node.type === "leaf")
|
|
16
|
+
return [node.id];
|
|
17
|
+
return [...leaves(node.first), ...leaves(node.second)];
|
|
18
|
+
}
|
|
19
|
+
export function hasLeaf(node, id) {
|
|
20
|
+
if (node.type === "leaf")
|
|
21
|
+
return node.id === id;
|
|
22
|
+
return hasLeaf(node.first, id) || hasLeaf(node.second, id);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Divide a folha `leafId`: ela vira `first` e a nova folha `newLeafId` vira `second`.
|
|
26
|
+
* `splitId` identifica o novo no de divisao. Se `leafId` nao existir, devolve a mesma raiz.
|
|
27
|
+
*/
|
|
28
|
+
export function splitLeaf(root, leafId, direction, newLeafId, splitId = `split-${newLeafId}`) {
|
|
29
|
+
if (root.type === "leaf") {
|
|
30
|
+
if (root.id !== leafId)
|
|
31
|
+
return root;
|
|
32
|
+
return { type: "split", id: splitId, direction, ratio: 0.5, first: root, second: leaf(newLeafId) };
|
|
33
|
+
}
|
|
34
|
+
const first = splitLeaf(root.first, leafId, direction, newLeafId, splitId);
|
|
35
|
+
if (first !== root.first)
|
|
36
|
+
return { ...root, first };
|
|
37
|
+
const second = splitLeaf(root.second, leafId, direction, newLeafId, splitId);
|
|
38
|
+
if (second !== root.second)
|
|
39
|
+
return { ...root, second };
|
|
40
|
+
return root;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Remove a folha `leafId`; o irmao assume o lugar da divisao pai.
|
|
44
|
+
* Devolve `null` quando a ultima folha e removida.
|
|
45
|
+
*/
|
|
46
|
+
export function removeLeaf(root, leafId) {
|
|
47
|
+
if (root.type === "leaf")
|
|
48
|
+
return root.id === leafId ? null : root;
|
|
49
|
+
if (root.first.type === "leaf" && root.first.id === leafId)
|
|
50
|
+
return root.second;
|
|
51
|
+
if (root.second.type === "leaf" && root.second.id === leafId)
|
|
52
|
+
return root.first;
|
|
53
|
+
const first = removeLeaf(root.first, leafId);
|
|
54
|
+
if (first !== root.first)
|
|
55
|
+
return first === null ? root.second : { ...root, first };
|
|
56
|
+
const second = removeLeaf(root.second, leafId);
|
|
57
|
+
if (second !== root.second)
|
|
58
|
+
return second === null ? root.first : { ...root, second };
|
|
59
|
+
return root;
|
|
60
|
+
}
|
|
61
|
+
/** Ajusta a proporcao de uma divisao (com clamp). */
|
|
62
|
+
export function setRatio(root, splitId, ratio) {
|
|
63
|
+
if (root.type === "leaf")
|
|
64
|
+
return root;
|
|
65
|
+
if (root.id === splitId) {
|
|
66
|
+
const next = clampRatio(ratio);
|
|
67
|
+
return next === root.ratio ? root : { ...root, ratio: next };
|
|
68
|
+
}
|
|
69
|
+
const first = setRatio(root.first, splitId, ratio);
|
|
70
|
+
if (first !== root.first)
|
|
71
|
+
return { ...root, first };
|
|
72
|
+
const second = setRatio(root.second, splitId, ratio);
|
|
73
|
+
if (second !== root.second)
|
|
74
|
+
return { ...root, second };
|
|
75
|
+
return root;
|
|
76
|
+
}
|
|
77
|
+
/** Proxima folha (delta = 1) ou anterior (delta = -1), circular. */
|
|
78
|
+
export function cycleLeaf(root, currentId, delta) {
|
|
79
|
+
const ids = leaves(root);
|
|
80
|
+
const idx = ids.indexOf(currentId);
|
|
81
|
+
if (idx === -1)
|
|
82
|
+
return ids[0];
|
|
83
|
+
return ids[(idx + delta + ids.length) % ids.length];
|
|
84
|
+
}
|
|
85
|
+
/** Folha a ser focada depois de remover `removedId` (a vizinha na ordem visual). */
|
|
86
|
+
export function focusAfterRemoval(before, removedId) {
|
|
87
|
+
const ids = leaves(before);
|
|
88
|
+
const idx = ids.indexOf(removedId);
|
|
89
|
+
if (idx === -1 || ids.length <= 1)
|
|
90
|
+
return null;
|
|
91
|
+
return ids[idx === 0 ? 1 : idx - 1];
|
|
92
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type Platform = "mac" | "windows" | "linux";
|
|
2
|
+
/** Detecta a plataforma pelo navegador/webview (Wails usa WebView2, WKWebView e WebKitGTK). Em SSR retorna `fallback`. */
|
|
3
|
+
export declare function detectPlatform(fallback?: Platform): Platform;
|
|
4
|
+
/** Rotulo da tecla modificadora principal: Command no macOS, Ctrl no Windows e Linux. */
|
|
5
|
+
export declare function modKeyLabel(platform: Platform): string;
|
|
6
|
+
/** Monta um atalho legivel: formatShortcut("linux", "K") => "Ctrl+K"; no macOS => "⌘K". */
|
|
7
|
+
export declare function formatShortcut(platform: Platform, key: string, opts?: {
|
|
8
|
+
shift?: boolean;
|
|
9
|
+
alt?: boolean;
|
|
10
|
+
}): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Detecta a plataforma pelo navegador/webview (Wails usa WebView2, WKWebView e WebKitGTK). Em SSR retorna `fallback`. */
|
|
2
|
+
export function detectPlatform(fallback = "windows") {
|
|
3
|
+
if (typeof navigator === "undefined")
|
|
4
|
+
return fallback;
|
|
5
|
+
const nav = navigator;
|
|
6
|
+
const raw = (nav.userAgentData?.platform ?? nav.platform ?? nav.userAgent ?? "").toLowerCase();
|
|
7
|
+
if (raw.includes("mac") || raw.includes("iphone") || raw.includes("ipad"))
|
|
8
|
+
return "mac";
|
|
9
|
+
if (raw.includes("win"))
|
|
10
|
+
return "windows";
|
|
11
|
+
if (raw.includes("linux") || raw.includes("x11") || raw.includes("cros"))
|
|
12
|
+
return "linux";
|
|
13
|
+
return fallback;
|
|
14
|
+
}
|
|
15
|
+
/** Rotulo da tecla modificadora principal: Command no macOS, Ctrl no Windows e Linux. */
|
|
16
|
+
export function modKeyLabel(platform) {
|
|
17
|
+
return platform === "mac" ? "⌘" : "Ctrl";
|
|
18
|
+
}
|
|
19
|
+
/** Monta um atalho legivel: formatShortcut("linux", "K") => "Ctrl+K"; no macOS => "⌘K". */
|
|
20
|
+
export function formatShortcut(platform, key, opts = {}) {
|
|
21
|
+
if (platform === "mac")
|
|
22
|
+
return `${opts.alt ? "⌥" : ""}${opts.shift ? "⇧" : ""}⌘${key}`;
|
|
23
|
+
return [modKeyLabel(platform), opts.alt ? "Alt" : "", opts.shift ? "Shift" : "", key].filter(Boolean).join("+");
|
|
24
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type ShellKind = "powershell" | "pwsh" | "cmd" | "bash" | "wsl" | "zsh" | "fish" | "nu" | "other";
|
|
2
|
+
export declare function shellKind(shellPath: string): ShellKind;
|
|
3
|
+
export declare function shellLabel(shellPath: string): string;
|
|
4
|
+
/** Nome curto para titulo de aba. */
|
|
5
|
+
export declare function shellTabName(shellPath: string): string;
|
|
6
|
+
/** Escapa um caminho para uso em `cd` no shell indicado. */
|
|
7
|
+
export declare function quoteForShell(shellPath: string, target: string): string;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Rotulos amigaveis para os executaveis de shell detectados pelo backend.
|
|
2
|
+
function baseName(shellPath) {
|
|
3
|
+
return (shellPath.split(/[\\/]/).pop() || shellPath).toLowerCase();
|
|
4
|
+
}
|
|
5
|
+
export function shellKind(shellPath) {
|
|
6
|
+
const base = baseName(shellPath);
|
|
7
|
+
if (base === "pwsh.exe" || base === "pwsh")
|
|
8
|
+
return "pwsh";
|
|
9
|
+
if (base === "powershell.exe" || base === "powershell")
|
|
10
|
+
return "powershell";
|
|
11
|
+
if (base === "cmd.exe" || base === "cmd")
|
|
12
|
+
return "cmd";
|
|
13
|
+
if (base === "wsl.exe" || base === "wsl")
|
|
14
|
+
return "wsl";
|
|
15
|
+
if (base === "nu.exe" || base === "nu")
|
|
16
|
+
return "nu";
|
|
17
|
+
if (base === "zsh")
|
|
18
|
+
return "zsh";
|
|
19
|
+
if (base === "fish")
|
|
20
|
+
return "fish";
|
|
21
|
+
if (base === "bash" || base === "bash.exe")
|
|
22
|
+
return "bash";
|
|
23
|
+
return "other";
|
|
24
|
+
}
|
|
25
|
+
export function shellLabel(shellPath) {
|
|
26
|
+
const lower = shellPath.toLowerCase();
|
|
27
|
+
const kind = shellKind(shellPath);
|
|
28
|
+
if (kind === "bash") {
|
|
29
|
+
if (lower.includes("git"))
|
|
30
|
+
return "Git Bash";
|
|
31
|
+
if (lower.includes("msys"))
|
|
32
|
+
return "MSYS2 Bash";
|
|
33
|
+
if (lower.includes("cygwin"))
|
|
34
|
+
return "Cygwin Bash";
|
|
35
|
+
return "Bash";
|
|
36
|
+
}
|
|
37
|
+
switch (kind) {
|
|
38
|
+
case "pwsh": return "PowerShell 7";
|
|
39
|
+
case "powershell": return "Windows PowerShell";
|
|
40
|
+
case "cmd": return "Command Prompt";
|
|
41
|
+
case "wsl": return "WSL";
|
|
42
|
+
case "nu": return "Nushell";
|
|
43
|
+
case "zsh": return "Zsh";
|
|
44
|
+
case "fish": return "Fish";
|
|
45
|
+
default: return shellPath.split(/[\\/]/).pop() || shellPath;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Nome curto para titulo de aba. */
|
|
49
|
+
export function shellTabName(shellPath) {
|
|
50
|
+
const lower = shellPath.toLowerCase();
|
|
51
|
+
const base = (shellPath.split(/[\\/]/).pop() || "shell").replace(/\.exe$/i, "").toLowerCase();
|
|
52
|
+
if (base === "bash") {
|
|
53
|
+
if (lower.includes("git"))
|
|
54
|
+
return "git-bash";
|
|
55
|
+
if (lower.includes("msys"))
|
|
56
|
+
return "msys-bash";
|
|
57
|
+
if (lower.includes("cygwin"))
|
|
58
|
+
return "cygwin-bash";
|
|
59
|
+
}
|
|
60
|
+
return base;
|
|
61
|
+
}
|
|
62
|
+
/** Escapa um caminho para uso em `cd` no shell indicado. */
|
|
63
|
+
export function quoteForShell(shellPath, target) {
|
|
64
|
+
const kind = shellKind(shellPath);
|
|
65
|
+
if (kind === "cmd")
|
|
66
|
+
return `"${target.replace(/"/g, "")}"`;
|
|
67
|
+
if (kind === "pwsh" || kind === "powershell" || kind === "nu")
|
|
68
|
+
return `'${target.replace(/'/g, "''")}'`;
|
|
69
|
+
return `'${target.replace(/'/g, `'\\''`)}'`;
|
|
70
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Move o item `fromId` para a posicao de `toId`. Ids desconhecidos ou iguais nao alteram a lista. */
|
|
2
|
+
export declare function moveTab<T extends {
|
|
3
|
+
id: string;
|
|
4
|
+
}>(tabs: T[], fromId: string, toId: string): T[];
|
|
5
|
+
/** Aba a ativar depois de fechar `closedId` (vizinha da direita, senao da esquerda). */
|
|
6
|
+
export declare function activeAfterClose(ids: string[], closedId: string, activeId: string): string | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Reordenacao de abas (puro).
|
|
2
|
+
/** Move o item `fromId` para a posicao de `toId`. Ids desconhecidos ou iguais nao alteram a lista. */
|
|
3
|
+
export function moveTab(tabs, fromId, toId) {
|
|
4
|
+
if (fromId === toId)
|
|
5
|
+
return tabs;
|
|
6
|
+
const from = tabs.findIndex((t) => t.id === fromId);
|
|
7
|
+
const to = tabs.findIndex((t) => t.id === toId);
|
|
8
|
+
if (from === -1 || to === -1)
|
|
9
|
+
return tabs;
|
|
10
|
+
const next = tabs.slice();
|
|
11
|
+
const [item] = next.splice(from, 1);
|
|
12
|
+
next.splice(to, 0, item);
|
|
13
|
+
return next;
|
|
14
|
+
}
|
|
15
|
+
/** Aba a ativar depois de fechar `closedId` (vizinha da direita, senao da esquerda). */
|
|
16
|
+
export function activeAfterClose(ids, closedId, activeId) {
|
|
17
|
+
if (activeId !== closedId)
|
|
18
|
+
return ids.includes(activeId) ? activeId : (ids[0] ?? null);
|
|
19
|
+
const idx = ids.indexOf(closedId);
|
|
20
|
+
const rest = ids.filter((id) => id !== closedId);
|
|
21
|
+
if (rest.length === 0)
|
|
22
|
+
return null;
|
|
23
|
+
return rest[Math.min(idx, rest.length - 1)];
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type SortDir = "asc" | "desc";
|
|
2
|
+
export type SortState = {
|
|
3
|
+
key: string;
|
|
4
|
+
dir: SortDir;
|
|
5
|
+
} | null;
|
|
6
|
+
/** Ciclo do clique no cabecalho: nenhum -> asc -> desc -> nenhum. Outra coluna reinicia em asc. */
|
|
7
|
+
export declare function nextSort(current: SortState, key: string): SortState;
|
|
8
|
+
export declare function compareValues(a: unknown, b: unknown): number;
|
|
9
|
+
/** Ordena sem mutar; estavel; vazios (null/undefined) sempre por ultimo, em qualquer direcao. */
|
|
10
|
+
export declare function sortRows<T>(rows: readonly T[], sort: SortState, value: (row: T, key: string) => unknown): T[];
|
|
11
|
+
/** Alterna um id em um conjunto de selecao sem mutar. */
|
|
12
|
+
export declare function toggleSelected(selected: ReadonlySet<string>, id: string): Set<string>;
|
|
13
|
+
/** Seleciona o intervalo entre dois ids na ordem visivel (Shift+clique). */
|
|
14
|
+
export declare function selectRange(order: readonly string[], selected: ReadonlySet<string>, from: string, to: string): Set<string>;
|
|
15
|
+
export type AllState = "none" | "some" | "all";
|
|
16
|
+
export declare function allState(order: readonly string[], selected: ReadonlySet<string>): AllState;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Ordenacao e selecao puras da DataTable (testaveis sem DOM).
|
|
2
|
+
/** Ciclo do clique no cabecalho: nenhum -> asc -> desc -> nenhum. Outra coluna reinicia em asc. */
|
|
3
|
+
export function nextSort(current, key) {
|
|
4
|
+
if (!current || current.key !== key)
|
|
5
|
+
return { key, dir: "asc" };
|
|
6
|
+
if (current.dir === "asc")
|
|
7
|
+
return { key, dir: "desc" };
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" });
|
|
11
|
+
export function compareValues(a, b) {
|
|
12
|
+
const an = a === null || a === undefined;
|
|
13
|
+
const bn = b === null || b === undefined;
|
|
14
|
+
if (an || bn)
|
|
15
|
+
return an === bn ? 0 : an ? 1 : -1;
|
|
16
|
+
if (typeof a === "number" && typeof b === "number")
|
|
17
|
+
return a - b;
|
|
18
|
+
if (a instanceof Date && b instanceof Date)
|
|
19
|
+
return a.getTime() - b.getTime();
|
|
20
|
+
if (typeof a === "boolean" && typeof b === "boolean")
|
|
21
|
+
return Number(a) - Number(b);
|
|
22
|
+
return collator.compare(String(a), String(b));
|
|
23
|
+
}
|
|
24
|
+
/** Ordena sem mutar; estavel; vazios (null/undefined) sempre por ultimo, em qualquer direcao. */
|
|
25
|
+
export function sortRows(rows, sort, value) {
|
|
26
|
+
if (!sort)
|
|
27
|
+
return [...rows];
|
|
28
|
+
const sign = sort.dir === "asc" ? 1 : -1;
|
|
29
|
+
return rows
|
|
30
|
+
.map((row, index) => ({ row, index, v: value(row, sort.key) }))
|
|
31
|
+
.sort((x, y) => {
|
|
32
|
+
const xn = x.v === null || x.v === undefined;
|
|
33
|
+
const yn = y.v === null || y.v === undefined;
|
|
34
|
+
if (xn || yn)
|
|
35
|
+
return xn === yn ? x.index - y.index : xn ? 1 : -1;
|
|
36
|
+
return compareValues(x.v, y.v) * sign || x.index - y.index;
|
|
37
|
+
})
|
|
38
|
+
.map((x) => x.row);
|
|
39
|
+
}
|
|
40
|
+
/** Alterna um id em um conjunto de selecao sem mutar. */
|
|
41
|
+
export function toggleSelected(selected, id) {
|
|
42
|
+
const next = new Set(selected);
|
|
43
|
+
if (next.has(id))
|
|
44
|
+
next.delete(id);
|
|
45
|
+
else
|
|
46
|
+
next.add(id);
|
|
47
|
+
return next;
|
|
48
|
+
}
|
|
49
|
+
/** Seleciona o intervalo entre dois ids na ordem visivel (Shift+clique). */
|
|
50
|
+
export function selectRange(order, selected, from, to) {
|
|
51
|
+
const a = order.indexOf(from);
|
|
52
|
+
const b = order.indexOf(to);
|
|
53
|
+
if (a < 0 || b < 0)
|
|
54
|
+
return new Set(selected);
|
|
55
|
+
const [lo, hi] = a <= b ? [a, b] : [b, a];
|
|
56
|
+
const next = new Set(selected);
|
|
57
|
+
for (let i = lo; i <= hi; i++)
|
|
58
|
+
next.add(order[i]);
|
|
59
|
+
return next;
|
|
60
|
+
}
|
|
61
|
+
export function allState(order, selected) {
|
|
62
|
+
if (order.length === 0)
|
|
63
|
+
return "none";
|
|
64
|
+
const n = order.filter((id) => selected.has(id)).length;
|
|
65
|
+
return n === 0 ? "none" : n === order.length ? "all" : "some";
|
|
66
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type TerminalTheme = {
|
|
2
|
+
background: string;
|
|
3
|
+
foreground: string;
|
|
4
|
+
cursor: string;
|
|
5
|
+
cursorAccent: string;
|
|
6
|
+
selectionBackground: string;
|
|
7
|
+
black: string;
|
|
8
|
+
red: string;
|
|
9
|
+
green: string;
|
|
10
|
+
yellow: string;
|
|
11
|
+
blue: string;
|
|
12
|
+
magenta: string;
|
|
13
|
+
cyan: string;
|
|
14
|
+
white: string;
|
|
15
|
+
brightBlack: string;
|
|
16
|
+
brightRed: string;
|
|
17
|
+
brightGreen: string;
|
|
18
|
+
brightYellow: string;
|
|
19
|
+
brightBlue: string;
|
|
20
|
+
brightMagenta: string;
|
|
21
|
+
brightCyan: string;
|
|
22
|
+
brightWhite: string;
|
|
23
|
+
};
|
|
24
|
+
export type TerminalPreset = {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
theme: TerminalTheme;
|
|
28
|
+
};
|
|
29
|
+
export declare const terminalPresets: TerminalPreset[];
|
|
30
|
+
export declare function getTerminalPreset(id: string): TerminalPreset;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Presets de cor do terminal. Mesma forma de ITheme do xterm, sem importar o xterm.
|
|
2
|
+
export const terminalPresets = [
|
|
3
|
+
{
|
|
4
|
+
id: "cyber-noir",
|
|
5
|
+
name: "Cyber Noir",
|
|
6
|
+
theme: {
|
|
7
|
+
background: "#09090b", foreground: "#a1a1aa", cursor: "#22d3ee", cursorAccent: "#09090b",
|
|
8
|
+
selectionBackground: "rgba(34, 211, 238, 0.25)",
|
|
9
|
+
black: "#18181b", red: "#ef4444", green: "#10b981", yellow: "#eab308",
|
|
10
|
+
blue: "#3b82f6", magenta: "#d946ef", cyan: "#06b6d4", white: "#e4e4e7",
|
|
11
|
+
brightBlack: "#3f3f46", brightRed: "#f87171", brightGreen: "#34d399", brightYellow: "#facc15",
|
|
12
|
+
brightBlue: "#60a5fa", brightMagenta: "#e879f9", brightCyan: "#22d3ee", brightWhite: "#ffffff",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: "pampulha-night",
|
|
17
|
+
name: "Pampulha Night",
|
|
18
|
+
theme: {
|
|
19
|
+
background: "#0f172a", foreground: "#cbd5e1", cursor: "#fbbf24", cursorAccent: "#0f172a",
|
|
20
|
+
selectionBackground: "rgba(251, 191, 36, 0.22)",
|
|
21
|
+
black: "#1e293b", red: "#e11d48", green: "#059669", yellow: "#d97706",
|
|
22
|
+
blue: "#2563eb", magenta: "#7c3aed", cyan: "#0891b2", white: "#f1f5f9",
|
|
23
|
+
brightBlack: "#475569", brightRed: "#f43f5e", brightGreen: "#10b981", brightYellow: "#fbbf24",
|
|
24
|
+
brightBlue: "#3b82f6", brightMagenta: "#8b5cf6", brightCyan: "#06b6d4", brightWhite: "#ffffff",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: "espresso-code",
|
|
29
|
+
name: "Espresso Code",
|
|
30
|
+
theme: {
|
|
31
|
+
background: "#1c1917", foreground: "#d6d3d1", cursor: "#d97706", cursorAccent: "#1c1917",
|
|
32
|
+
selectionBackground: "rgba(217, 119, 6, 0.25)",
|
|
33
|
+
black: "#292524", red: "#dc2626", green: "#65a30d", yellow: "#d97706",
|
|
34
|
+
blue: "#0284c7", magenta: "#9333ea", cyan: "#0d9488", white: "#e7e5e4",
|
|
35
|
+
brightBlack: "#57534e", brightRed: "#ef4444", brightGreen: "#84cc16", brightYellow: "#f59e0b",
|
|
36
|
+
brightBlue: "#0ea5e9", brightMagenta: "#a855f7", brightCyan: "#14b8a6", brightWhite: "#f5f5f4",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "gophers-forge",
|
|
41
|
+
name: "Gopher's Forge",
|
|
42
|
+
theme: {
|
|
43
|
+
background: "#121212", foreground: "#e0e0e0", cursor: "#00add8", cursorAccent: "#121212",
|
|
44
|
+
selectionBackground: "rgba(0, 173, 216, 0.28)",
|
|
45
|
+
black: "#242424", red: "#ff5c5c", green: "#5cff9d", yellow: "#ffdc5c",
|
|
46
|
+
blue: "#5c9dff", magenta: "#d85cff", cyan: "#00add8", white: "#f5f5f5",
|
|
47
|
+
brightBlack: "#484848", brightRed: "#ff8a8a", brightGreen: "#8affba", brightYellow: "#ffe78a",
|
|
48
|
+
brightBlue: "#8abaff", brightMagenta: "#e78aff", brightCyan: "#5ce6ff", brightWhite: "#ffffff",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: "phosphor",
|
|
53
|
+
name: "Phosphor",
|
|
54
|
+
theme: {
|
|
55
|
+
background: "#020b05", foreground: "#4ade80", cursor: "#86efac", cursorAccent: "#020b05",
|
|
56
|
+
selectionBackground: "rgba(74, 222, 128, 0.22)",
|
|
57
|
+
black: "#052e16", red: "#f87171", green: "#22c55e", yellow: "#a3e635",
|
|
58
|
+
blue: "#38bdf8", magenta: "#c084fc", cyan: "#2dd4bf", white: "#bbf7d0",
|
|
59
|
+
brightBlack: "#166534", brightRed: "#fca5a5", brightGreen: "#4ade80", brightYellow: "#bef264",
|
|
60
|
+
brightBlue: "#7dd3fc", brightMagenta: "#d8b4fe", brightCyan: "#5eead4", brightWhite: "#f0fdf4",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: "loccal-dark",
|
|
65
|
+
name: "Loccal Dark",
|
|
66
|
+
theme: {
|
|
67
|
+
background: "#09090b", foreground: "#f4f4f6", cursor: "#10b981", cursorAccent: "#09090b",
|
|
68
|
+
selectionBackground: "rgba(16, 185, 129, 0.28)",
|
|
69
|
+
black: "#18181b", red: "#f87171", green: "#34d399", yellow: "#fbbf24",
|
|
70
|
+
blue: "#60a5fa", magenta: "#c084fc", cyan: "#22d3ee", white: "#e4e4e7",
|
|
71
|
+
brightBlack: "#71717a", brightRed: "#fca5a5", brightGreen: "#6ee7b7", brightYellow: "#fde68a",
|
|
72
|
+
brightBlue: "#93c5fd", brightMagenta: "#d8b4fe", brightCyan: "#67e8f9", brightWhite: "#ffffff",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: "loccal-light",
|
|
77
|
+
name: "Loccal Light",
|
|
78
|
+
theme: {
|
|
79
|
+
background: "#ced5e2", foreground: "#111622", cursor: "#4338ca", cursorAccent: "#ced5e2",
|
|
80
|
+
selectionBackground: "rgba(67, 56, 202, 0.22)",
|
|
81
|
+
black: "#111622", red: "#b91c1c", green: "#047857", yellow: "#b45309",
|
|
82
|
+
blue: "#1d4ed8", magenta: "#6d28d9", cyan: "#0e7490", white: "#334155",
|
|
83
|
+
brightBlack: "#475569", brightRed: "#dc2626", brightGreen: "#059669", brightYellow: "#d97706",
|
|
84
|
+
brightBlue: "#2563eb", brightMagenta: "#7c3aed", brightCyan: "#0891b2", brightWhite: "#090d16",
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
export function getTerminalPreset(id) {
|
|
89
|
+
return terminalPresets.find((p) => p.id === id) ?? terminalPresets[0];
|
|
90
|
+
}
|