@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,31 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
type TerminalTab = {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
/** "running" (padrao), "exited" (processo terminou) ou "error". */
|
|
6
|
+
status?: "running" | "exited" | "error";
|
|
7
|
+
exitCode?: number;
|
|
8
|
+
icon?: React.ReactNode;
|
|
9
|
+
};
|
|
10
|
+
type TerminalTabsLabels = {
|
|
11
|
+
new: string;
|
|
12
|
+
close: string;
|
|
13
|
+
rename: string;
|
|
14
|
+
};
|
|
15
|
+
type TerminalTabsProps = {
|
|
16
|
+
tabs: TerminalTab[];
|
|
17
|
+
activeId?: string;
|
|
18
|
+
onSelect: (id: string) => void;
|
|
19
|
+
onClose: (id: string) => void;
|
|
20
|
+
onNew?: () => void;
|
|
21
|
+
onRename?: (id: string, title: string) => void;
|
|
22
|
+
/** Chamado com a nova ordem completa depois de arrastar uma aba sobre outra. */
|
|
23
|
+
onReorder?: (tabs: TerminalTab[]) => void;
|
|
24
|
+
/** Conteudo extra ao lado do botao "+", por exemplo um menu de shells. */
|
|
25
|
+
trailing?: React.ReactNode;
|
|
26
|
+
labels?: Partial<TerminalTabsLabels>;
|
|
27
|
+
className?: string;
|
|
28
|
+
};
|
|
29
|
+
declare function TerminalTabs({ tabs, activeId, onSelect, onClose, onNew, onRename, onReorder, trailing, labels, className, }: TerminalTabsProps): React.JSX.Element;
|
|
30
|
+
export { TerminalTabs };
|
|
31
|
+
export type { TerminalTab, TerminalTabsProps };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { PlusIcon, XIcon } from "./icons.js";
|
|
5
|
+
import { cn } from "../../lib/utils.js";
|
|
6
|
+
import { moveTab } from "../../lib/tab-order.js";
|
|
7
|
+
const DEFAULT_LABELS = { new: "Nova aba", close: "Fechar aba", rename: "Renomear aba" };
|
|
8
|
+
const statusTone = {
|
|
9
|
+
running: "bg-success",
|
|
10
|
+
exited: "bg-muted-foreground/60",
|
|
11
|
+
error: "bg-destructive",
|
|
12
|
+
};
|
|
13
|
+
function TerminalTabs({ tabs, activeId, onSelect, onClose, onNew, onRename, onReorder, trailing, labels, className, }) {
|
|
14
|
+
const l = { ...DEFAULT_LABELS, ...labels };
|
|
15
|
+
const [editingId, setEditingId] = React.useState(null);
|
|
16
|
+
const [draft, setDraft] = React.useState("");
|
|
17
|
+
const [dragId, setDragId] = React.useState(null);
|
|
18
|
+
const [overId, setOverId] = React.useState(null);
|
|
19
|
+
const listRef = React.useRef(null);
|
|
20
|
+
const startRename = (tab) => {
|
|
21
|
+
if (!onRename)
|
|
22
|
+
return;
|
|
23
|
+
setDraft(tab.title);
|
|
24
|
+
setEditingId(tab.id);
|
|
25
|
+
};
|
|
26
|
+
const commitRename = () => {
|
|
27
|
+
if (editingId) {
|
|
28
|
+
const title = draft.trim();
|
|
29
|
+
const current = tabs.find((t) => t.id === editingId);
|
|
30
|
+
if (title && current && title !== current.title)
|
|
31
|
+
onRename?.(editingId, title);
|
|
32
|
+
}
|
|
33
|
+
setEditingId(null);
|
|
34
|
+
};
|
|
35
|
+
const focusTab = (id) => {
|
|
36
|
+
listRef.current?.querySelector(`[data-tab-id="${CSS.escape(id)}"]`)?.focus();
|
|
37
|
+
};
|
|
38
|
+
const onKeyDown = (e, tab, index) => {
|
|
39
|
+
if (editingId)
|
|
40
|
+
return;
|
|
41
|
+
let target;
|
|
42
|
+
if (e.key === "ArrowRight")
|
|
43
|
+
target = tabs[(index + 1) % tabs.length];
|
|
44
|
+
else if (e.key === "ArrowLeft")
|
|
45
|
+
target = tabs[(index - 1 + tabs.length) % tabs.length];
|
|
46
|
+
else if (e.key === "Home")
|
|
47
|
+
target = tabs[0];
|
|
48
|
+
else if (e.key === "End")
|
|
49
|
+
target = tabs[tabs.length - 1];
|
|
50
|
+
else if (e.key === "Enter" || e.key === " ") {
|
|
51
|
+
onSelect(tab.id);
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
else if (e.key === "F2") {
|
|
56
|
+
startRename(tab);
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
else if (e.key === "Delete") {
|
|
61
|
+
onClose(tab.id);
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (target) {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
onSelect(target.id);
|
|
68
|
+
focusTab(target.id);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
return (_jsxs("div", { "data-slot": "terminal-tabs", className: cn("flex h-9 shrink-0 items-stretch gap-0.5 border-b bg-sidebar px-1", className), children: [_jsx("div", { ref: listRef, role: "tablist", "aria-orientation": "horizontal", className: "flex min-w-0 items-stretch gap-0.5 overflow-x-auto overflow-y-hidden [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", children: tabs.map((tab, index) => {
|
|
72
|
+
const active = tab.id === activeId;
|
|
73
|
+
const status = tab.status ?? "running";
|
|
74
|
+
return (_jsxs("div", { role: "tab", "aria-selected": active, tabIndex: active || (!activeId && index === 0) ? 0 : -1, "data-tab-id": tab.id, "data-active": active, "data-over": overId === tab.id && dragId !== tab.id, draggable: Boolean(onReorder) && editingId !== tab.id, onDragStart: (e) => {
|
|
75
|
+
setDragId(tab.id);
|
|
76
|
+
e.dataTransfer.effectAllowed = "move";
|
|
77
|
+
e.dataTransfer.setData("text/plain", tab.id);
|
|
78
|
+
}, onDragOver: (e) => {
|
|
79
|
+
if (!dragId)
|
|
80
|
+
return;
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
setOverId(tab.id);
|
|
83
|
+
}, onDrop: (e) => {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
if (dragId)
|
|
86
|
+
onReorder?.(moveTab(tabs, dragId, tab.id));
|
|
87
|
+
setDragId(null);
|
|
88
|
+
setOverId(null);
|
|
89
|
+
}, onDragEnd: () => {
|
|
90
|
+
setDragId(null);
|
|
91
|
+
setOverId(null);
|
|
92
|
+
}, onClick: () => onSelect(tab.id), onDoubleClick: () => startRename(tab), onAuxClick: (e) => {
|
|
93
|
+
if (e.button === 1) {
|
|
94
|
+
e.preventDefault();
|
|
95
|
+
onClose(tab.id);
|
|
96
|
+
}
|
|
97
|
+
}, onKeyDown: (e) => onKeyDown(e, tab, index), className: cn("group/tab relative my-1 flex h-7 max-w-48 min-w-24 cursor-default items-center gap-1.5 rounded-md border border-transparent pr-1 pl-2 text-xs text-muted-foreground outline-none select-none", "hover:bg-accent/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60", "data-[active=true]:bg-background data-[active=true]:text-foreground data-[active=true]:shadow-surface", "data-[over=true]:border-brand/60"), children: [tab.icon ? _jsx("span", { className: "flex shrink-0 [&_svg]:size-3.5", children: tab.icon }) : null, _jsx("span", { "aria-hidden": true, title: status === "exited" && tab.exitCode !== undefined ? `exit ${tab.exitCode}` : undefined, className: cn("size-1.5 shrink-0 rounded-full", statusTone[status]) }), editingId === tab.id ? (_jsx("input", { autoFocus: true, "aria-label": l.rename, value: draft, onChange: (e) => setDraft(e.target.value), onBlur: commitRename, onKeyDown: (e) => {
|
|
98
|
+
e.stopPropagation();
|
|
99
|
+
if (e.key === "Enter")
|
|
100
|
+
commitRename();
|
|
101
|
+
else if (e.key === "Escape")
|
|
102
|
+
setEditingId(null);
|
|
103
|
+
}, onFocus: (e) => e.currentTarget.select(), className: "h-5 min-w-0 flex-1 rounded-sm bg-input/40 px-1 text-xs text-foreground outline-none ring-1 ring-ring" })) : (_jsx("span", { className: "min-w-0 flex-1 truncate", children: tab.title })), _jsx("button", { type: "button", tabIndex: -1, "aria-label": `${l.close}: ${tab.title}`, onClick: (e) => {
|
|
104
|
+
e.stopPropagation();
|
|
105
|
+
onClose(tab.id);
|
|
106
|
+
}, className: "flex size-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground group-hover/tab:opacity-100 group-data-[active=true]/tab:opacity-100", children: _jsx(XIcon, { className: "size-3" }) })] }, tab.id));
|
|
107
|
+
}) }), onNew ? (_jsx("button", { type: "button", "aria-label": l.new, title: l.new, onClick: onNew, className: "my-1 flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60", children: _jsx(PlusIcon, { className: "size-4" }) })) : null, trailing ? _jsx("div", { "data-slot": "terminal-tabs-trailing", className: "my-1 flex h-7 shrink-0 items-center", children: trailing }) : null] }));
|
|
108
|
+
}
|
|
109
|
+
export { TerminalTabs };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import "@xterm/xterm/css/xterm.css";
|
|
3
|
+
import { type TerminalTheme } from "../../lib/terminal-themes.js";
|
|
4
|
+
/**
|
|
5
|
+
* Contrato entre a view e o backend (Wails, WebSocket, mock...). A view nunca importa o runtime
|
|
6
|
+
* do Wails: quem monta o componente fornece o transporte.
|
|
7
|
+
*/
|
|
8
|
+
type TerminalTransport = {
|
|
9
|
+
/** Envia o que o usuario digitou ou colou para o processo. */
|
|
10
|
+
write: (data: string) => void | Promise<void>;
|
|
11
|
+
/** Informa o novo tamanho em colunas e linhas. */
|
|
12
|
+
resize: (cols: number, rows: number) => void | Promise<void>;
|
|
13
|
+
/** Registra o consumidor da saida do processo. Devolve a funcao que cancela o registro. */
|
|
14
|
+
subscribe: (onData: (chunk: string) => void) => () => void;
|
|
15
|
+
};
|
|
16
|
+
type TerminalViewHandle = {
|
|
17
|
+
focus: () => void;
|
|
18
|
+
clear: () => void;
|
|
19
|
+
fit: () => void;
|
|
20
|
+
/** Escreve texto direto na tela (nao envia ao processo). */
|
|
21
|
+
write: (data: string) => void;
|
|
22
|
+
paste: (text: string) => void;
|
|
23
|
+
getSelection: () => string;
|
|
24
|
+
findNext: (term: string) => boolean;
|
|
25
|
+
findPrevious: (term: string) => boolean;
|
|
26
|
+
clearSearch: () => void;
|
|
27
|
+
};
|
|
28
|
+
type TerminalViewProps = {
|
|
29
|
+
transport: TerminalTransport;
|
|
30
|
+
/** Id de um preset de `terminalPresets`, ou um tema completo. */
|
|
31
|
+
theme?: string | TerminalTheme;
|
|
32
|
+
fontFamily?: string;
|
|
33
|
+
fontSize?: number;
|
|
34
|
+
lineHeight?: number;
|
|
35
|
+
scrollback?: number;
|
|
36
|
+
copyOnSelect?: boolean;
|
|
37
|
+
cursorBlink?: boolean;
|
|
38
|
+
/** Quando verdadeiro, a view toma o foco (por exemplo, ao ser a aba ativa). */
|
|
39
|
+
active?: boolean;
|
|
40
|
+
/** Linhas escritas antes da subscricao (ex.: scrollback recuperado do backend). */
|
|
41
|
+
initialContent?: string;
|
|
42
|
+
onTitleChange?: (title: string) => void;
|
|
43
|
+
onReady?: (size: {
|
|
44
|
+
cols: number;
|
|
45
|
+
rows: number;
|
|
46
|
+
}) => void;
|
|
47
|
+
className?: string;
|
|
48
|
+
};
|
|
49
|
+
declare const TerminalView: React.ForwardRefExoticComponent<TerminalViewProps & React.RefAttributes<TerminalViewHandle>>;
|
|
50
|
+
export { TerminalView };
|
|
51
|
+
export type { TerminalTransport, TerminalViewHandle, TerminalViewProps };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import "@xterm/xterm/css/xterm.css";
|
|
5
|
+
import { cn } from "../../lib/utils.js";
|
|
6
|
+
import { getTerminalPreset } from "../../lib/terminal-themes.js";
|
|
7
|
+
const DEFAULT_FONT = '"Cascadia Code", "JetBrains Mono", Consolas, monospace';
|
|
8
|
+
function resolveTheme(theme) {
|
|
9
|
+
return typeof theme === "object" && theme ? theme : getTerminalPreset(theme ?? "loccal-dark").theme;
|
|
10
|
+
}
|
|
11
|
+
const TerminalView = React.forwardRef(function TerminalView({ transport, theme, fontFamily = DEFAULT_FONT, fontSize = 14, lineHeight = 1.2, scrollback = 1000, copyOnSelect = false, cursorBlink = true, active = true, initialContent, onTitleChange, onReady, className, }, ref) {
|
|
12
|
+
const hostRef = React.useRef(null);
|
|
13
|
+
const termRef = React.useRef(null);
|
|
14
|
+
const fitRef = React.useRef(null);
|
|
15
|
+
const searchRef = React.useRef(null);
|
|
16
|
+
// As props que mudam sem recriar o terminal ficam em refs para os handlers estaveis.
|
|
17
|
+
const transportRef = React.useRef(transport);
|
|
18
|
+
const copyRef = React.useRef(copyOnSelect);
|
|
19
|
+
const onTitleRef = React.useRef(onTitleChange);
|
|
20
|
+
const onReadyRef = React.useRef(onReady);
|
|
21
|
+
transportRef.current = transport;
|
|
22
|
+
copyRef.current = copyOnSelect;
|
|
23
|
+
onTitleRef.current = onTitleChange;
|
|
24
|
+
onReadyRef.current = onReady;
|
|
25
|
+
const lastSize = React.useRef({ cols: 0, rows: 0 });
|
|
26
|
+
const fit = React.useCallback(() => {
|
|
27
|
+
const term = termRef.current;
|
|
28
|
+
const addon = fitRef.current;
|
|
29
|
+
const host = hostRef.current;
|
|
30
|
+
if (!term || !addon || !host || host.clientWidth === 0 || host.clientHeight === 0)
|
|
31
|
+
return;
|
|
32
|
+
try {
|
|
33
|
+
addon.fit();
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const { cols, rows } = term;
|
|
39
|
+
if (cols !== lastSize.current.cols || rows !== lastSize.current.rows) {
|
|
40
|
+
lastSize.current = { cols, rows };
|
|
41
|
+
void transportRef.current.resize(cols, rows);
|
|
42
|
+
}
|
|
43
|
+
}, []);
|
|
44
|
+
React.useImperativeHandle(ref, () => ({
|
|
45
|
+
focus: () => termRef.current?.focus(),
|
|
46
|
+
clear: () => termRef.current?.clear(),
|
|
47
|
+
fit,
|
|
48
|
+
write: (data) => termRef.current?.write(data),
|
|
49
|
+
paste: (text) => termRef.current?.paste(text),
|
|
50
|
+
getSelection: () => termRef.current?.getSelection() ?? "",
|
|
51
|
+
findNext: (term) => searchRef.current?.findNext(term) ?? false,
|
|
52
|
+
findPrevious: (term) => searchRef.current?.findPrevious(term) ?? false,
|
|
53
|
+
clearSearch: () => searchRef.current?.clearDecorations(),
|
|
54
|
+
}), [fit]);
|
|
55
|
+
// Criacao unica: o transporte e as demais opcoes sao lidos por refs ou aplicados nos efeitos abaixo.
|
|
56
|
+
React.useEffect(() => {
|
|
57
|
+
const host = hostRef.current;
|
|
58
|
+
if (!host)
|
|
59
|
+
return;
|
|
60
|
+
let disposed = false;
|
|
61
|
+
let cleanup;
|
|
62
|
+
void (async () => {
|
|
63
|
+
const [{ Terminal }, { FitAddon }, { SearchAddon }, { WebLinksAddon }] = await Promise.all([
|
|
64
|
+
import("@xterm/xterm"),
|
|
65
|
+
import("@xterm/addon-fit"),
|
|
66
|
+
import("@xterm/addon-search"),
|
|
67
|
+
import("@xterm/addon-web-links"),
|
|
68
|
+
]);
|
|
69
|
+
if (disposed)
|
|
70
|
+
return;
|
|
71
|
+
const term = new Terminal({
|
|
72
|
+
allowProposedApi: true,
|
|
73
|
+
cursorBlink,
|
|
74
|
+
fontFamily,
|
|
75
|
+
fontSize,
|
|
76
|
+
lineHeight,
|
|
77
|
+
scrollback,
|
|
78
|
+
theme: resolveTheme(theme),
|
|
79
|
+
convertEol: false,
|
|
80
|
+
});
|
|
81
|
+
const fitAddon = new FitAddon();
|
|
82
|
+
const searchAddon = new SearchAddon();
|
|
83
|
+
term.loadAddon(fitAddon);
|
|
84
|
+
term.loadAddon(searchAddon);
|
|
85
|
+
term.loadAddon(new WebLinksAddon());
|
|
86
|
+
term.open(host);
|
|
87
|
+
termRef.current = term;
|
|
88
|
+
fitRef.current = fitAddon;
|
|
89
|
+
searchRef.current = searchAddon;
|
|
90
|
+
// WebGL quando disponivel; o renderer DOM/canvas padrao do xterm e o fallback.
|
|
91
|
+
let webgl;
|
|
92
|
+
void import("@xterm/addon-webgl")
|
|
93
|
+
.then(({ WebglAddon }) => {
|
|
94
|
+
if (disposed)
|
|
95
|
+
return;
|
|
96
|
+
const addon = new WebglAddon();
|
|
97
|
+
addon.onContextLoss(() => addon.dispose());
|
|
98
|
+
term.loadAddon(addon);
|
|
99
|
+
webgl = addon;
|
|
100
|
+
})
|
|
101
|
+
.catch(() => { });
|
|
102
|
+
// Ctrl+C copia quando ha selecao; Ctrl+V cola. O restante segue para o processo.
|
|
103
|
+
term.attachCustomKeyEventHandler((e) => {
|
|
104
|
+
if (e.type !== "keydown" || !e.ctrlKey || e.altKey || e.metaKey)
|
|
105
|
+
return true;
|
|
106
|
+
const key = e.key.toLowerCase();
|
|
107
|
+
if (key === "c" && !e.shiftKey && term.hasSelection()) {
|
|
108
|
+
void navigator.clipboard?.writeText(term.getSelection());
|
|
109
|
+
term.clearSelection();
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
if (key === "v") {
|
|
113
|
+
e.preventDefault();
|
|
114
|
+
void navigator.clipboard?.readText().then((text) => text && term.paste(text));
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
if (key === "c" && e.shiftKey && term.hasSelection()) {
|
|
118
|
+
void navigator.clipboard?.writeText(term.getSelection());
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
});
|
|
123
|
+
const disposables = [
|
|
124
|
+
term.onData((data) => void transportRef.current.write(data)),
|
|
125
|
+
term.onTitleChange((title) => onTitleRef.current?.(title)),
|
|
126
|
+
term.onSelectionChange(() => {
|
|
127
|
+
if (copyRef.current && term.hasSelection())
|
|
128
|
+
void navigator.clipboard?.writeText(term.getSelection());
|
|
129
|
+
}),
|
|
130
|
+
];
|
|
131
|
+
if (initialContent)
|
|
132
|
+
term.write(initialContent);
|
|
133
|
+
const unsubscribe = transportRef.current.subscribe((chunk) => term.write(chunk));
|
|
134
|
+
let frame = 0;
|
|
135
|
+
const observer = new ResizeObserver(() => {
|
|
136
|
+
cancelAnimationFrame(frame);
|
|
137
|
+
frame = requestAnimationFrame(fit);
|
|
138
|
+
});
|
|
139
|
+
observer.observe(host);
|
|
140
|
+
fit();
|
|
141
|
+
onReadyRef.current?.({ cols: term.cols, rows: term.rows });
|
|
142
|
+
cleanup = () => {
|
|
143
|
+
cancelAnimationFrame(frame);
|
|
144
|
+
observer.disconnect();
|
|
145
|
+
unsubscribe();
|
|
146
|
+
disposables.forEach((d) => d.dispose());
|
|
147
|
+
webgl?.dispose();
|
|
148
|
+
term.dispose();
|
|
149
|
+
termRef.current = null;
|
|
150
|
+
fitRef.current = null;
|
|
151
|
+
searchRef.current = null;
|
|
152
|
+
lastSize.current = { cols: 0, rows: 0 };
|
|
153
|
+
};
|
|
154
|
+
if (disposed)
|
|
155
|
+
cleanup();
|
|
156
|
+
})();
|
|
157
|
+
return () => {
|
|
158
|
+
disposed = true;
|
|
159
|
+
cleanup?.();
|
|
160
|
+
};
|
|
161
|
+
// Recriar o terminal perderia o historico visivel: opcoes de aparencia tem efeitos proprios.
|
|
162
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
163
|
+
}, []);
|
|
164
|
+
React.useEffect(() => {
|
|
165
|
+
const term = termRef.current;
|
|
166
|
+
if (term)
|
|
167
|
+
term.options.theme = resolveTheme(theme);
|
|
168
|
+
}, [theme]);
|
|
169
|
+
React.useEffect(() => {
|
|
170
|
+
const term = termRef.current;
|
|
171
|
+
if (!term)
|
|
172
|
+
return;
|
|
173
|
+
term.options.fontFamily = fontFamily;
|
|
174
|
+
term.options.fontSize = fontSize;
|
|
175
|
+
term.options.lineHeight = lineHeight;
|
|
176
|
+
term.options.scrollback = scrollback;
|
|
177
|
+
term.options.cursorBlink = cursorBlink;
|
|
178
|
+
fit();
|
|
179
|
+
}, [fontFamily, fontSize, lineHeight, scrollback, cursorBlink, fit]);
|
|
180
|
+
React.useEffect(() => {
|
|
181
|
+
if (active) {
|
|
182
|
+
termRef.current?.focus();
|
|
183
|
+
fit();
|
|
184
|
+
}
|
|
185
|
+
}, [active, fit]);
|
|
186
|
+
const background = resolveTheme(theme).background;
|
|
187
|
+
return (_jsx("div", { "data-slot": "terminal-view", "data-active": active, className: cn("size-full min-h-0 min-w-0 overflow-hidden p-1.5", className), style: { backgroundColor: background }, children: _jsx("div", { ref: hostRef, className: "size-full" }) }));
|
|
188
|
+
});
|
|
189
|
+
export { TerminalView };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../lib/utils.js";
|
|
3
|
+
function Textarea({ className, ...props }) {
|
|
4
|
+
return (_jsx("textarea", { "data-slot": "textarea", className: cn("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", className), ...props }));
|
|
5
|
+
}
|
|
6
|
+
export { Textarea };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare function Timeline({ className, ...props }: React.ComponentProps<"ol">): React.JSX.Element;
|
|
3
|
+
declare function TimelineItem({ className, tone, children, ...props }: React.ComponentProps<"li"> & {
|
|
4
|
+
tone?: "default" | "brand" | "success" | "destructive";
|
|
5
|
+
}): React.JSX.Element;
|
|
6
|
+
declare function TimelineTime({ className, ...props }: React.ComponentProps<"time">): React.JSX.Element;
|
|
7
|
+
declare function TimelineTitle({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
|
|
8
|
+
declare function TimelineDescription({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
|
|
9
|
+
export { Timeline, TimelineItem, TimelineTime, TimelineTitle, TimelineDescription };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../lib/utils.js";
|
|
3
|
+
function Timeline({ className, ...props }) {
|
|
4
|
+
return _jsx("ol", { "data-slot": "timeline", className: cn("relative flex flex-col", className), ...props });
|
|
5
|
+
}
|
|
6
|
+
function TimelineItem({ className, tone = "default", children, ...props }) {
|
|
7
|
+
return (_jsxs("li", { "data-slot": "timeline-item", "data-tone": tone, className: cn("group/timeline relative flex gap-4 pb-6 last:pb-0", className), ...props, children: [_jsxs("div", { className: "relative flex w-3 shrink-0 justify-center", children: [_jsx("span", { "aria-hidden": true, className: cn("relative z-10 mt-1.5 size-2.5 rounded-full bg-background ring-2 ring-border", "group-data-[tone=brand]/timeline:ring-brand group-data-[tone=success]/timeline:ring-success group-data-[tone=destructive]/timeline:ring-destructive") }), _jsx("span", { "aria-hidden": true, className: "absolute top-5 bottom-0 w-px bg-border group-last/timeline:hidden" })] }), _jsx("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: children })] }));
|
|
8
|
+
}
|
|
9
|
+
function TimelineTime({ className, ...props }) {
|
|
10
|
+
return _jsx("time", { className: cn("font-mono text-[11px] text-muted-foreground tabular", className), ...props });
|
|
11
|
+
}
|
|
12
|
+
function TimelineTitle({ className, ...props }) {
|
|
13
|
+
return _jsx("p", { className: cn("text-sm font-medium text-foreground", className), ...props });
|
|
14
|
+
}
|
|
15
|
+
function TimelineDescription({ className, ...props }) {
|
|
16
|
+
return _jsx("p", { className: cn("text-sm leading-relaxed text-muted-foreground", className), ...props });
|
|
17
|
+
}
|
|
18
|
+
export { Timeline, TimelineItem, TimelineTime, TimelineTitle, TimelineDescription };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
|
|
3
|
+
import { ToggleGroup as ToggleGroupPrimitive } from "@base-ui/react/toggle-group";
|
|
4
|
+
import { type VariantProps } from "class-variance-authority";
|
|
5
|
+
import { toggleVariants } from "./toggle.js";
|
|
6
|
+
declare function ToggleGroup({ className, variant, size, spacing, orientation, children, ...props }: ToggleGroupPrimitive.Props & VariantProps<typeof toggleVariants> & {
|
|
7
|
+
spacing?: number;
|
|
8
|
+
orientation?: "horizontal" | "vertical";
|
|
9
|
+
}): React.JSX.Element;
|
|
10
|
+
declare function ToggleGroupItem({ className, children, variant, size, ...props }: TogglePrimitive.Props & VariantProps<typeof toggleVariants>): React.JSX.Element;
|
|
11
|
+
export { ToggleGroup, ToggleGroupItem };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
|
|
5
|
+
import { ToggleGroup as ToggleGroupPrimitive } from "@base-ui/react/toggle-group";
|
|
6
|
+
import { cn } from "../../lib/utils.js";
|
|
7
|
+
import { toggleVariants } from "./toggle.js";
|
|
8
|
+
const ToggleGroupContext = React.createContext({
|
|
9
|
+
size: "default",
|
|
10
|
+
variant: "default",
|
|
11
|
+
spacing: 2,
|
|
12
|
+
orientation: "horizontal",
|
|
13
|
+
});
|
|
14
|
+
function ToggleGroup({ className, variant, size, spacing = 2, orientation = "horizontal", children, ...props }) {
|
|
15
|
+
return (_jsx(ToggleGroupPrimitive, { "data-slot": "toggle-group", "data-variant": variant, "data-size": size, "data-spacing": spacing, "data-orientation": orientation, style: { "--gap": spacing }, className: cn("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch", className), ...props, children: _jsx(ToggleGroupContext.Provider, { value: { variant, size, spacing, orientation }, children: children }) }));
|
|
16
|
+
}
|
|
17
|
+
function ToggleGroupItem({ className, children, variant = "default", size = "default", ...props }) {
|
|
18
|
+
const context = React.useContext(ToggleGroupContext);
|
|
19
|
+
return (_jsx(TogglePrimitive, { "data-slot": "toggle-group-item", "data-variant": context.variant || variant, "data-size": context.size || size, "data-spacing": context.spacing, className: cn("shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t", toggleVariants({
|
|
20
|
+
variant: context.variant || variant,
|
|
21
|
+
size: context.size || size,
|
|
22
|
+
}), className), ...props, children: children }));
|
|
23
|
+
}
|
|
24
|
+
export { ToggleGroup, ToggleGroupItem };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const toggleVariants: (props?: ({
|
|
4
|
+
variant?: "default" | "outline" | null | undefined;
|
|
5
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
declare function Toggle({ className, variant, size, ...props }: TogglePrimitive.Props & VariantProps<typeof toggleVariants>): import("react").JSX.Element;
|
|
8
|
+
export { Toggle, toggleVariants };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { cn } from "../../lib/utils.js";
|
|
6
|
+
const toggleVariants = cva("group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
default: "bg-transparent",
|
|
10
|
+
outline: "border border-input bg-transparent hover:bg-muted",
|
|
11
|
+
},
|
|
12
|
+
size: {
|
|
13
|
+
default: "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
14
|
+
sm: "h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
15
|
+
lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
variant: "default",
|
|
20
|
+
size: "default",
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
function Toggle({ className, variant = "default", size = "default", ...props }) {
|
|
24
|
+
return (_jsx(TogglePrimitive, { "data-slot": "toggle", className: cn(toggleVariants({ variant, size, className })), ...props }));
|
|
25
|
+
}
|
|
26
|
+
export { Toggle, toggleVariants };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip";
|
|
2
|
+
declare function TooltipProvider({ delay, ...props }: TooltipPrimitive.Provider.Props): import("react").JSX.Element;
|
|
3
|
+
declare function Tooltip({ ...props }: TooltipPrimitive.Root.Props): import("react").JSX.Element;
|
|
4
|
+
declare function TooltipTrigger({ ...props }: TooltipPrimitive.Trigger.Props): import("react").JSX.Element;
|
|
5
|
+
declare function TooltipContent({ className, side, sideOffset, align, alignOffset, children, ...props }: TooltipPrimitive.Popup.Props & Pick<TooltipPrimitive.Positioner.Props, "align" | "alignOffset" | "side" | "sideOffset">): import("react").JSX.Element;
|
|
6
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip";
|
|
4
|
+
import { cn } from "../../lib/utils.js";
|
|
5
|
+
function TooltipProvider({ delay = 0, ...props }) {
|
|
6
|
+
return (_jsx(TooltipPrimitive.Provider, { "data-slot": "tooltip-provider", delay: delay, ...props }));
|
|
7
|
+
}
|
|
8
|
+
function Tooltip({ ...props }) {
|
|
9
|
+
return _jsx(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props });
|
|
10
|
+
}
|
|
11
|
+
function TooltipTrigger({ ...props }) {
|
|
12
|
+
return _jsx(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
|
|
13
|
+
}
|
|
14
|
+
function TooltipContent({ className, side = "top", sideOffset = 4, align = "center", alignOffset = 0, children, ...props }) {
|
|
15
|
+
return (_jsx(TooltipPrimitive.Portal, { children: _jsx(TooltipPrimitive.Positioner, { align: align, alignOffset: alignOffset, side: side, sideOffset: sideOffset, className: "isolate z-50", children: _jsxs(TooltipPrimitive.Popup, { "data-slot": "tooltip-content", className: cn("z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className), ...props, children: [children, _jsx(TooltipPrimitive.Arrow, { className: "z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5" })] }) }) }));
|
|
16
|
+
}
|
|
17
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
type TreeItem = {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
icon?: React.ReactNode;
|
|
6
|
+
meta?: React.ReactNode;
|
|
7
|
+
children?: TreeItem[];
|
|
8
|
+
};
|
|
9
|
+
type TreeViewProps = {
|
|
10
|
+
items: TreeItem[];
|
|
11
|
+
defaultExpanded?: string[];
|
|
12
|
+
selectedId?: string;
|
|
13
|
+
defaultSelectedId?: string;
|
|
14
|
+
onSelect?: (item: TreeItem) => void;
|
|
15
|
+
className?: string;
|
|
16
|
+
"aria-label"?: string;
|
|
17
|
+
};
|
|
18
|
+
declare function TreeView({ items, defaultExpanded, selectedId, defaultSelectedId, onSelect, className, ...props }: TreeViewProps): React.JSX.Element;
|
|
19
|
+
export { TreeView };
|
|
20
|
+
export type { TreeItem };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { ChevronRightIcon } from "./icons.js";
|
|
5
|
+
import { cn } from "../../lib/utils.js";
|
|
6
|
+
function TreeView({ items, defaultExpanded = [], selectedId, defaultSelectedId, onSelect, className, ...props }) {
|
|
7
|
+
const [expanded, setExpanded] = React.useState(() => new Set(defaultExpanded));
|
|
8
|
+
const [internalSelected, setInternalSelected] = React.useState(defaultSelectedId);
|
|
9
|
+
const selected = selectedId ?? internalSelected;
|
|
10
|
+
const toggle = (id) => setExpanded((prev) => {
|
|
11
|
+
const next = new Set(prev);
|
|
12
|
+
if (next.has(id))
|
|
13
|
+
next.delete(id);
|
|
14
|
+
else
|
|
15
|
+
next.add(id);
|
|
16
|
+
return next;
|
|
17
|
+
});
|
|
18
|
+
const select = (item) => {
|
|
19
|
+
setInternalSelected(item.id);
|
|
20
|
+
onSelect?.(item);
|
|
21
|
+
};
|
|
22
|
+
return (_jsx("ul", { role: "tree", "aria-label": props["aria-label"], "data-slot": "tree-view", className: cn("flex flex-col text-sm", className), children: items.map((item) => (_jsx(TreeNode, { item: item, depth: 0, expanded: expanded, selected: selected, onToggle: toggle, onSelect: select }, item.id))) }));
|
|
23
|
+
}
|
|
24
|
+
function TreeNode({ item, depth, expanded, selected, onToggle, onSelect, }) {
|
|
25
|
+
const hasChildren = Boolean(item.children?.length);
|
|
26
|
+
const isOpen = expanded.has(item.id);
|
|
27
|
+
const isSelected = selected === item.id;
|
|
28
|
+
return (_jsxs("li", { role: "treeitem", "aria-expanded": hasChildren ? isOpen : undefined, "aria-selected": isSelected, children: [_jsxs("button", { type: "button", onClick: () => {
|
|
29
|
+
if (hasChildren)
|
|
30
|
+
onToggle(item.id);
|
|
31
|
+
onSelect(item);
|
|
32
|
+
}, onKeyDown: (e) => {
|
|
33
|
+
if (!hasChildren)
|
|
34
|
+
return;
|
|
35
|
+
if (e.key === "ArrowRight" && !isOpen)
|
|
36
|
+
onToggle(item.id);
|
|
37
|
+
if (e.key === "ArrowLeft" && isOpen)
|
|
38
|
+
onToggle(item.id);
|
|
39
|
+
}, style: { paddingLeft: `calc(${depth} * 0.875rem + 0.375rem)` }, "data-selected": isSelected, className: cn("group/tree flex h-7 w-full items-center gap-1.5 rounded-md pr-2 text-left text-muted-foreground transition-colors outline-none", "hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60", "data-[selected=true]:bg-accent data-[selected=true]:text-foreground"), children: [_jsx(ChevronRightIcon, { "aria-hidden": true, className: cn("size-3.5 shrink-0 transition-transform duration-150", hasChildren ? "opacity-70" : "opacity-0", isOpen && "rotate-90") }), item.icon ? _jsx("span", { className: "flex shrink-0 [&_svg]:size-4", children: item.icon }) : null, _jsx("span", { className: "truncate", children: item.label }), item.meta ? _jsx("span", { className: "ml-auto font-mono text-[11px] text-muted-foreground", children: item.meta }) : null] }), hasChildren && isOpen ? (_jsx("ul", { role: "group", className: "flex flex-col", children: item.children.map((child) => (_jsx(TreeNode, { item: child, depth: depth + 1, expanded: expanded, selected: selected, onToggle: onToggle, onSelect: onSelect }, child.id))) })) : null] }));
|
|
40
|
+
}
|
|
41
|
+
export { TreeView };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Platform } from "../../lib/platform.js";
|
|
3
|
+
type WindowLabels = {
|
|
4
|
+
minimise: string;
|
|
5
|
+
maximise: string;
|
|
6
|
+
restore: string;
|
|
7
|
+
close: string;
|
|
8
|
+
};
|
|
9
|
+
type WindowContextValue = {
|
|
10
|
+
labels: WindowLabels;
|
|
11
|
+
platform: Platform;
|
|
12
|
+
maximised: boolean;
|
|
13
|
+
onMinimise?: () => void;
|
|
14
|
+
onToggleMaximise?: () => void;
|
|
15
|
+
onClose?: () => void;
|
|
16
|
+
};
|
|
17
|
+
declare function useWindowFrame(): WindowContextValue;
|
|
18
|
+
type WindowFrameProps = React.ComponentProps<"div"> & {
|
|
19
|
+
platform?: Platform;
|
|
20
|
+
maximised?: boolean;
|
|
21
|
+
onMinimise?: () => void;
|
|
22
|
+
onToggleMaximise?: () => void;
|
|
23
|
+
onClose?: () => void;
|
|
24
|
+
/** Textos acessiveis dos controles da janela (i18n). */
|
|
25
|
+
labels?: Partial<WindowLabels>;
|
|
26
|
+
};
|
|
27
|
+
declare function WindowFrame({ platform, maximised, onMinimise, onToggleMaximise, onClose, labels, className, children, ...props }: WindowFrameProps): React.JSX.Element;
|
|
28
|
+
type TitleBarProps = React.ComponentProps<"header"> & {
|
|
29
|
+
title?: React.ReactNode;
|
|
30
|
+
icon?: React.ReactNode;
|
|
31
|
+
};
|
|
32
|
+
declare function TitleBar({ title, icon, className, children, ...props }: TitleBarProps): React.JSX.Element;
|
|
33
|
+
declare function WindowBody({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
34
|
+
export { WindowFrame, TitleBar, WindowBody, useWindowFrame };
|
|
35
|
+
export type { Platform };
|