@comma-agents/tui 2.0.0-rc.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/LICENSE +21 -0
- package/README.md +10 -0
- package/dist/App/App.d.ts +24 -0
- package/dist/App/App.theme.d.ts +12 -0
- package/dist/App/App.types.d.ts +8 -0
- package/dist/App/index.d.ts +4 -0
- package/dist/Theme/DefineTheme.d.ts +53 -0
- package/dist/Theme/Theme.d.ts +11 -0
- package/dist/Theme/Theme.types.d.ts +100 -0
- package/dist/Theme/index.d.ts +9 -0
- package/dist/Theme/themes/dark.d.ts +14 -0
- package/dist/Theme/themes/dracula.d.ts +9 -0
- package/dist/Theme/themes/index.d.ts +25 -0
- package/dist/Theme/themes/light.d.ts +10 -0
- package/dist/Theme/themes/solarized-dark.d.ts +9 -0
- package/dist/Theme/useTheme/index.d.ts +3 -0
- package/dist/Theme/useTheme/useTheme.context.d.ts +31 -0
- package/dist/Theme/useTheme/useTheme.d.ts +11 -0
- package/dist/Theme/useTheme/useTheme.types.d.ts +10 -0
- package/dist/components/BorderedPanel/BorderedPanel.d.ts +70 -0
- package/dist/components/BorderedPanel/BorderedPanel.theme.d.ts +59 -0
- package/dist/components/BorderedPanel/index.d.ts +4 -0
- package/dist/components/Button/Button.d.ts +69 -0
- package/dist/components/Button/Button.theme.d.ts +50 -0
- package/dist/components/Button/Button.types.d.ts +9 -0
- package/dist/components/Button/index.d.ts +4 -0
- package/dist/components/ChatTextArea/ChatTextArea.d.ts +85 -0
- package/dist/components/ChatTextArea/ChatTextArea.theme.d.ts +34 -0
- package/dist/components/ChatTextArea/index.d.ts +2 -0
- package/dist/components/CodeView/CodeView.constants.d.ts +9 -0
- package/dist/components/CodeView/CodeView.d.ts +23 -0
- package/dist/components/CodeView/CodeView.theme.d.ts +26 -0
- package/dist/components/CodeView/index.d.ts +4 -0
- package/dist/components/CommandPalette/CommandPalette.constants.d.ts +8 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts +62 -0
- package/dist/components/CommandPalette/CommandPalette.theme.d.ts +50 -0
- package/dist/components/CommandPalette/CommandPalette.types.d.ts +50 -0
- package/dist/components/CommandPalette/CommandPalette.utils.d.ts +6 -0
- package/dist/components/CommandPalette/index.d.ts +5 -0
- package/dist/components/CommandPalette/pages/HelpPage/HelpPage.constants.d.ts +2 -0
- package/dist/components/CommandPalette/pages/HelpPage/HelpPage.d.ts +12 -0
- package/dist/components/CommandPalette/pages/HelpPage/HelpPage.types.d.ts +5 -0
- package/dist/components/CommandPalette/pages/HelpPage/index.d.ts +3 -0
- package/dist/components/CommandPalette/pages/ListProvidersPage/ListProvidersPage.d.ts +42 -0
- package/dist/components/CommandPalette/pages/ListProvidersPage/index.d.ts +1 -0
- package/dist/components/CommandPalette/pages/RegisteredProvidersPage/RegisteredProvidersPage.constants.d.ts +3 -0
- package/dist/components/CommandPalette/pages/RegisteredProvidersPage/RegisteredProvidersPage.d.ts +40 -0
- package/dist/components/CommandPalette/pages/RegisteredProvidersPage/RegisteredProvidersPage.types.d.ts +13 -0
- package/dist/components/CommandPalette/pages/RegisteredProvidersPage/RegisteredProvidersPage.utils.d.ts +9 -0
- package/dist/components/CommandPalette/pages/RegisteredProvidersPage/index.d.ts +2 -0
- package/dist/components/CommandPalette/pages/RunPickerPage/RunPickerPage.constants.d.ts +3 -0
- package/dist/components/CommandPalette/pages/RunPickerPage/RunPickerPage.d.ts +31 -0
- package/dist/components/CommandPalette/pages/RunPickerPage/RunPickerPage.types.d.ts +8 -0
- package/dist/components/CommandPalette/pages/RunPickerPage/RunPickerPage.utils.d.ts +7 -0
- package/dist/components/CommandPalette/pages/RunPickerPage/index.d.ts +3 -0
- package/dist/components/CommandPalette/pages/SettingsPage/SettingsPage.d.ts +24 -0
- package/dist/components/CommandPalette/pages/SettingsPage/index.d.ts +2 -0
- package/dist/components/Frame/Frame.d.ts +48 -0
- package/dist/components/Frame/Frame.theme.d.ts +52 -0
- package/dist/components/Frame/index.d.ts +4 -0
- package/dist/components/Hide/Hide.d.ts +20 -0
- package/dist/components/Hide/Hide.types.d.ts +12 -0
- package/dist/components/Hide/index.d.ts +2 -0
- package/dist/components/MessageList/AgentMessage/AgentMessage.d.ts +71 -0
- package/dist/components/MessageList/AgentMessage/index.d.ts +2 -0
- package/dist/components/MessageList/ContextUsageModal/ContextUsageModal.constants.d.ts +2 -0
- package/dist/components/MessageList/ContextUsageModal/ContextUsageModal.d.ts +9 -0
- package/dist/components/MessageList/ContextUsageModal/ContextUsageModal.types.d.ts +12 -0
- package/dist/components/MessageList/ContextUsageModal/index.d.ts +4 -0
- package/dist/components/MessageList/MarkdownView/MarkdownView.constants.d.ts +51 -0
- package/dist/components/MessageList/MarkdownView/MarkdownView.d.ts +34 -0
- package/dist/components/MessageList/MarkdownView/MarkdownView.theme.d.ts +89 -0
- package/dist/components/MessageList/MarkdownView/MarkdownView.types.d.ts +96 -0
- package/dist/components/MessageList/MarkdownView/MarkdownView.utils.d.ts +58 -0
- package/dist/components/MessageList/MarkdownView/index.d.ts +6 -0
- package/dist/components/MessageList/MessageList.d.ts +20 -0
- package/dist/components/MessageList/MessageList.theme.d.ts +170 -0
- package/dist/components/MessageList/MessageList.types.d.ts +26 -0
- package/dist/components/MessageList/OutputModal/OutputModal.constants.d.ts +22 -0
- package/dist/components/MessageList/OutputModal/OutputModal.d.ts +37 -0
- package/dist/components/MessageList/OutputModal/OutputModal.theme.d.ts +68 -0
- package/dist/components/MessageList/OutputModal/OutputModal.types.d.ts +56 -0
- package/dist/components/MessageList/OutputModal/OutputModal.utils.d.ts +3 -0
- package/dist/components/MessageList/OutputModal/index.d.ts +6 -0
- package/dist/components/MessageList/SpawnedStrategyView/SpawnedStrategyView.d.ts +47 -0
- package/dist/components/MessageList/SpawnedStrategyView/SpawnedStrategyView.theme.d.ts +58 -0
- package/dist/components/MessageList/SpawnedStrategyView/index.d.ts +4 -0
- package/dist/components/MessageList/SystemMessage/SystemMessage.d.ts +21 -0
- package/dist/components/MessageList/SystemMessage/index.d.ts +2 -0
- package/dist/components/MessageList/ToolCallView/ToolCallView.constants.d.ts +42 -0
- package/dist/components/MessageList/ToolCallView/ToolCallView.d.ts +71 -0
- package/dist/components/MessageList/ToolCallView/ToolCallView.theme.d.ts +47 -0
- package/dist/components/MessageList/ToolCallView/ToolCallView.types.d.ts +60 -0
- package/dist/components/MessageList/ToolCallView/ToolCallView.utils.d.ts +40 -0
- package/dist/components/MessageList/ToolCallView/index.d.ts +8 -0
- package/dist/components/MessageList/UserMessage/UserMessage.d.ts +25 -0
- package/dist/components/MessageList/UserMessage/index.d.ts +2 -0
- package/dist/components/MessageList/index.d.ts +14 -0
- package/dist/components/Modal/Modal.d.ts +64 -0
- package/dist/components/Modal/Modal.theme.d.ts +29 -0
- package/dist/components/Modal/index.d.ts +4 -0
- package/dist/components/MouseProvider/MouseContext.d.ts +36 -0
- package/dist/components/MouseProvider/MouseProvider.d.ts +20 -0
- package/dist/components/MouseProvider/index.d.ts +4 -0
- package/dist/components/PermissionPrompt/PermissionPrompt.d.ts +33 -0
- package/dist/components/PermissionPrompt/index.d.ts +2 -0
- package/dist/components/QuestionPrompt/QuestionPrompt.d.ts +4 -0
- package/dist/components/QuestionPrompt/QuestionPrompt.types.d.ts +18 -0
- package/dist/components/QuestionPrompt/index.d.ts +2 -0
- package/dist/components/ScrollableList/ScrollableList.d.ts +33 -0
- package/dist/components/ScrollableList/ScrollableList.theme.d.ts +33 -0
- package/dist/components/ScrollableList/ScrollableList.types.d.ts +66 -0
- package/dist/components/ScrollableList/index.d.ts +4 -0
- package/dist/components/ScrollableView/ScrollableView.d.ts +34 -0
- package/dist/components/ScrollableView/ScrollableView.theme.d.ts +34 -0
- package/dist/components/ScrollableView/ScrollableView.types.d.ts +113 -0
- package/dist/components/ScrollableView/index.d.ts +4 -0
- package/dist/components/Scrollbar/Scrollbar.d.ts +21 -0
- package/dist/components/Scrollbar/Scrollbar.theme.d.ts +16 -0
- package/dist/components/Scrollbar/Scrollbar.types.d.ts +27 -0
- package/dist/components/Scrollbar/Scrollbar.utils.d.ts +21 -0
- package/dist/components/Scrollbar/index.d.ts +4 -0
- package/dist/components/SearchInput/SearchInput.d.ts +22 -0
- package/dist/components/SearchInput/SearchInput.theme.d.ts +30 -0
- package/dist/components/SearchInput/SearchInput.types.d.ts +25 -0
- package/dist/components/SearchInput/SearchInput.utils.d.ts +22 -0
- package/dist/components/SearchInput/index.d.ts +5 -0
- package/dist/components/Separator/Separator.d.ts +39 -0
- package/dist/components/Separator/Separator.theme.d.ts +22 -0
- package/dist/components/Separator/index.d.ts +4 -0
- package/dist/components/StatusBar/StatusBar.d.ts +4 -0
- package/dist/components/StatusBar/StatusBar.theme.d.ts +35 -0
- package/dist/components/StatusBar/StatusBar.types.d.ts +24 -0
- package/dist/components/StatusBar/index.d.ts +2 -0
- package/dist/components/TextAreaInput/TextAreaInput.d.ts +68 -0
- package/dist/components/TextAreaInput/TextAreaInput.theme.d.ts +14 -0
- package/dist/components/TextAreaInput/TextAreaInput.utils.d.ts +69 -0
- package/dist/components/TextAreaInput/index.d.ts +2 -0
- package/dist/components/TitleIcon/TitleIcon.d.ts +13 -0
- package/dist/components/TitleIcon/TitleIcon.theme.d.ts +19 -0
- package/dist/components/TitleIcon/index.d.ts +1 -0
- package/dist/components/index.d.ts +61 -0
- package/dist/hooks/index.d.ts +27 -0
- package/dist/hooks/useBreakpoint/index.d.ts +2 -0
- package/dist/hooks/useBreakpoint/useBreakpoint.d.ts +15 -0
- package/dist/hooks/useBreakpoint/useBreakpoint.types.d.ts +18 -0
- package/dist/hooks/useChat/index.d.ts +22 -0
- package/dist/hooks/useChat/useChat.context.d.ts +7 -0
- package/dist/hooks/useChat/useChat.d.ts +11 -0
- package/dist/hooks/useChat/useChat.types.d.ts +209 -0
- package/dist/hooks/useChat/useChat.utils.d.ts +18 -0
- package/dist/hooks/useChat/useChatActions.d.ts +10 -0
- package/dist/hooks/useChat/useChatAgentMessages/index.d.ts +1 -0
- package/dist/hooks/useChat/useChatAgentMessages/useChatAgentMessages.d.ts +2 -0
- package/dist/hooks/useChat/useChatInputRequests/index.d.ts +2 -0
- package/dist/hooks/useChat/useChatInputRequests/useChatInputRequests.d.ts +3 -0
- package/dist/hooks/useChat/useChatInputRequests/useChatInputRequests.types.d.ts +4 -0
- package/dist/hooks/useChat/useChatLifecycle.d.ts +5 -0
- package/dist/hooks/useChat/useChatPermissionRequests/index.d.ts +2 -0
- package/dist/hooks/useChat/useChatPermissionRequests/useChatPermissionRequestSubscriptions.d.ts +2 -0
- package/dist/hooks/useChat/useChatPermissionRequests/useChatPermissionRequests.d.ts +3 -0
- package/dist/hooks/useChat/useChatPermissionRequests/useChatPermissionRequests.types.d.ts +4 -0
- package/dist/hooks/useChat/useChatQuestionRequests/index.d.ts +2 -0
- package/dist/hooks/useChat/useChatQuestionRequests/useChatQuestionRequestSubscriptions.d.ts +2 -0
- package/dist/hooks/useChat/useChatQuestionRequests/useChatQuestionRequests.d.ts +3 -0
- package/dist/hooks/useChat/useChatQuestionRequests/useChatQuestionRequests.types.d.ts +4 -0
- package/dist/hooks/useChat/useChatRunLifecycle/index.d.ts +2 -0
- package/dist/hooks/useChat/useChatRunLifecycle/useChatRunLifecycle.d.ts +3 -0
- package/dist/hooks/useChat/useChatRunLifecycle/useChatRunLifecycle.types.d.ts +11 -0
- package/dist/hooks/useChat/useChatRunLifecycle/useChatRunLifecycleSubscriptions.d.ts +2 -0
- package/dist/hooks/useChat/useChatRunStore/index.d.ts +1 -0
- package/dist/hooks/useChat/useChatRunStore/useChatRunStore.d.ts +3 -0
- package/dist/hooks/useChat/useChatRuns.d.ts +10 -0
- package/dist/hooks/useChat/useChatState.d.ts +17 -0
- package/dist/hooks/useChat/useChatSteering/index.d.ts +2 -0
- package/dist/hooks/useChat/useChatSteering/useChatSteering.d.ts +3 -0
- package/dist/hooks/useChat/useChatSteering/useChatSteering.types.d.ts +4 -0
- package/dist/hooks/useChat/useChatStepMessages/index.d.ts +1 -0
- package/dist/hooks/useChat/useChatStepMessages/useChatStepMessages.d.ts +2 -0
- package/dist/hooks/useChat/usePersistedRunList/index.d.ts +2 -0
- package/dist/hooks/useChat/usePersistedRunList/usePersistedRunList.d.ts +3 -0
- package/dist/hooks/useChat/usePersistedRunList/usePersistedRunList.types.d.ts +5 -0
- package/dist/hooks/useDaemon/index.d.ts +6 -0
- package/dist/hooks/useDaemon/useDaemon.context.d.ts +18 -0
- package/dist/hooks/useDaemon/useDaemon.d.ts +7 -0
- package/dist/hooks/useDaemon/useDaemon.types.d.ts +62 -0
- package/dist/hooks/useDaemon/useDaemonCommand/index.d.ts +2 -0
- package/dist/hooks/useDaemon/useDaemonCommand/useDaemonCommand.d.ts +20 -0
- package/dist/hooks/useDaemon/useDaemonCommand/useDaemonCommand.types.d.ts +28 -0
- package/dist/hooks/useDaemon/useDaemonSubscription/index.d.ts +1 -0
- package/dist/hooks/useDaemon/useDaemonSubscription/useDaemonSubscription.d.ts +18 -0
- package/dist/hooks/useDebugRender/index.d.ts +2 -0
- package/dist/hooks/useDebugRender/useDebugRender.constants.d.ts +18 -0
- package/dist/hooks/useDebugRender/useDebugRender.d.ts +35 -0
- package/dist/hooks/useDebugRender/useDebugRender.types.d.ts +60 -0
- package/dist/hooks/useDebugRender/useDebugRender.utils.d.ts +34 -0
- package/dist/hooks/useLogs/index.d.ts +3 -0
- package/dist/hooks/useLogs/logStore.d.ts +18 -0
- package/dist/hooks/useLogs/useLogs.constants.d.ts +2 -0
- package/dist/hooks/useLogs/useLogs.d.ts +15 -0
- package/dist/hooks/useLogs/useLogs.types.d.ts +47 -0
- package/dist/hooks/useLogs/useLogs.utils.d.ts +13 -0
- package/dist/hooks/useModal/index.d.ts +3 -0
- package/dist/hooks/useModal/useModal.context.d.ts +20 -0
- package/dist/hooks/useModal/useModal.d.ts +22 -0
- package/dist/hooks/useModal/useModal.types.d.ts +49 -0
- package/dist/hooks/useMouse/index.d.ts +2 -0
- package/dist/hooks/useMouse/useMouse.types.d.ts +43 -0
- package/dist/hooks/useMouse/useMouse.utils.d.ts +30 -0
- package/dist/hooks/useMouseClick/index.d.ts +2 -0
- package/dist/hooks/useMouseClick/useMouseClick.d.ts +23 -0
- package/dist/hooks/useMouseClick/useMouseClick.types.d.ts +28 -0
- package/dist/hooks/useMouseHover/index.d.ts +2 -0
- package/dist/hooks/useMouseHover/useMouseHover.d.ts +25 -0
- package/dist/hooks/useMouseHover/useMouseHover.types.d.ts +38 -0
- package/dist/hooks/useMouseWheelScroll/index.d.ts +2 -0
- package/dist/hooks/useMouseWheelScroll/useMouseWheelScroll.d.ts +28 -0
- package/dist/hooks/useMouseWheelScroll/useMouseWheelScroll.types.d.ts +32 -0
- package/dist/hooks/useRegion/index.d.ts +3 -0
- package/dist/hooks/useRegion/useRegion.d.ts +21 -0
- package/dist/hooks/useRegion/useRegion.types.d.ts +41 -0
- package/dist/hooks/useRegion/useRegion.utils.d.ts +51 -0
- package/dist/hooks/useStrategies/useStrategies.d.ts +10 -0
- package/dist/hooks/useToolSpinner/index.d.ts +1 -0
- package/dist/hooks/useToolSpinner/useToolSpinner.d.ts +28 -0
- package/dist/hooks/useUserConfig/index.d.ts +4 -0
- package/dist/hooks/useUserConfig/useUserConfig.constants.d.ts +17 -0
- package/dist/hooks/useUserConfig/useUserConfig.context.d.ts +9 -0
- package/dist/hooks/useUserConfig/useUserConfig.d.ts +9 -0
- package/dist/hooks/useUserConfig/useUserConfig.types.d.ts +30 -0
- package/dist/hooks/useUserConfig/useUserConfig.utils.d.ts +19 -0
- package/dist/hooks/useWebSocket/index.d.ts +2 -0
- package/dist/hooks/useWebSocket/useWebSocket.d.ts +17 -0
- package/dist/hooks/useWebSocket/useWebSocket.types.d.ts +27 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +10592 -0
- package/dist/main.js +10655 -0
- package/dist/pages/ChatPage/ChatPage.constants.d.ts +2 -0
- package/dist/pages/ChatPage/ChatPage.d.ts +25 -0
- package/dist/pages/ChatPage/ChatPage.theme.d.ts +56 -0
- package/dist/pages/ChatPage/index.d.ts +4 -0
- package/dist/pages/IntroPage/IntroPage.d.ts +14 -0
- package/dist/pages/IntroPage/IntroPage.theme.d.ts +13 -0
- package/dist/pages/IntroPage/index.d.ts +4 -0
- package/dist/pages/LogsPage/LogsPage.d.ts +14 -0
- package/dist/pages/LogsPage/LogsPage.theme.d.ts +49 -0
- package/dist/pages/LogsPage/LogsPage.utils.d.ts +5 -0
- package/dist/pages/LogsPage/index.d.ts +4 -0
- package/dist/pages/SpawnedStrategyPage/SpawnedStrategyPage.d.ts +12 -0
- package/dist/pages/SpawnedStrategyPage/index.d.ts +2 -0
- package/dist/run-tui.d.ts +12 -0
- package/dist/run-tui.types.d.ts +12 -0
- package/dist/utils/debug.d.ts +12 -0
- package/dist/utils/mouseEscape.d.ts +29 -0
- package/dist/utils/yogaLayout.d.ts +32 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 CloAI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import type { TabDefinition } from "../components/Frame/Frame";
|
|
3
|
+
export interface AppProps {
|
|
4
|
+
/** Whether to enable developer-specific tabs and tools. @default false */
|
|
5
|
+
readonly devMode?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function App({ devMode }: AppProps): React.ReactElement;
|
|
8
|
+
export interface AppRenderProps {
|
|
9
|
+
/** The list of tabs to display in the frame. */
|
|
10
|
+
readonly tabs: readonly TabDefinition[];
|
|
11
|
+
/** The path of the currently active tab. */
|
|
12
|
+
readonly activeTabPath: string;
|
|
13
|
+
/** Callback invoked when a tab is selected. */
|
|
14
|
+
readonly onTabSelect: (path: string) => void;
|
|
15
|
+
/** Whether the command palette modal is currently open. */
|
|
16
|
+
readonly commandPaletteOpen: boolean;
|
|
17
|
+
/** Callback invoked to close the command palette. */
|
|
18
|
+
readonly onCommandPaletteClose: () => void;
|
|
19
|
+
/** Callback invoked to exit the application. */
|
|
20
|
+
readonly onExitApp: () => void;
|
|
21
|
+
/** Callback invoked to reset the chat history. */
|
|
22
|
+
readonly onResetChat: () => void;
|
|
23
|
+
}
|
|
24
|
+
export declare function AppRender({ tabs, activeTabPath, onTabSelect, commandPaletteOpen, onCommandPaletteClose, onExitApp, onResetChat, }: AppRenderProps): React.ReactElement;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AppTheme } from "./App.types";
|
|
2
|
+
/**
|
|
3
|
+
* Hook that returns themed style objects for the App component.
|
|
4
|
+
* Consumes global tokens via `useTheme()`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* const theme = useAppTheme();
|
|
9
|
+
* return <div style={theme.root}>...</div>;
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function useAppTheme(): AppTheme;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Theme } from "./Theme.types";
|
|
2
|
+
/**
|
|
3
|
+
* Builder function passed to `defineTheme`. Receives the global theme tokens
|
|
4
|
+
* and returns the component's spread-ready style objects.
|
|
5
|
+
*
|
|
6
|
+
* The returned object's literal shape is preserved by inference, so callers
|
|
7
|
+
* never have to hand-write a parallel `XTheme` interface — `ThemeOf<typeof
|
|
8
|
+
* useXTheme>` extracts it.
|
|
9
|
+
*/
|
|
10
|
+
export type ThemeBuilder<ThemeShape> = (tokens: Theme) => ThemeShape;
|
|
11
|
+
/**
|
|
12
|
+
* Define a memoized component-theme hook with the result type inferred
|
|
13
|
+
* directly from the builder's return value.
|
|
14
|
+
*
|
|
15
|
+
* Per-component theme files used to declare an `XTheme` interface and a
|
|
16
|
+
* `useXTheme()` hook that returned a parallel object literal — every field
|
|
17
|
+
* was duplicated between the type and the value. `defineTheme` collapses
|
|
18
|
+
* the two: write the value once, the type is the value.
|
|
19
|
+
*
|
|
20
|
+
* Use `satisfies BoxProps` / `satisfies TextProps` on nested style objects
|
|
21
|
+
* intended to be spread into Ink `<Box>` / `<Text>`. This gives full
|
|
22
|
+
* autocomplete on Ink prop names AND keeps literal types narrow without
|
|
23
|
+
* `as const` — the literal `"column"` is checked against the union
|
|
24
|
+
* `"row" | "column" | …` so it never widens to `string`.
|
|
25
|
+
*
|
|
26
|
+
* @param builder - Pure function that maps global tokens to spread-ready style objects.
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* import type { BoxProps, TextProps } from "ink";
|
|
30
|
+
*
|
|
31
|
+
* export const useChatPageTheme = defineTheme((tokens) => ({
|
|
32
|
+
* root: { flexDirection: "column", height: "100%" } satisfies BoxProps,
|
|
33
|
+
* header: {
|
|
34
|
+
* paddingX: tokens.spacing.sm,
|
|
35
|
+
* title: {
|
|
36
|
+
* bold: tokens.typography.headerBold,
|
|
37
|
+
* color: tokens.colors.primary,
|
|
38
|
+
* } satisfies TextProps,
|
|
39
|
+
* },
|
|
40
|
+
* }));
|
|
41
|
+
*
|
|
42
|
+
* // Components consume the inferred type via `ThemeOf` — no parallel
|
|
43
|
+
* // interface to maintain.
|
|
44
|
+
* export type ChatPageTheme = ThemeOf<typeof useChatPageTheme>;
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function defineTheme<ThemeShape>(builder: ThemeBuilder<ThemeShape>): () => ThemeShape;
|
|
48
|
+
/**
|
|
49
|
+
* Extract the resolved theme shape from a `useXTheme` hook produced by
|
|
50
|
+
* `defineTheme`. Lets components type their `theme` prop without a parallel
|
|
51
|
+
* interface declaration.
|
|
52
|
+
*/
|
|
53
|
+
export type ThemeOf<ThemeHook extends () => unknown> = ReturnType<ThemeHook>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Theme } from "./Theme.types";
|
|
2
|
+
/**
|
|
3
|
+
* Default theme — Material Dark (Material Design 3 palette).
|
|
4
|
+
*
|
|
5
|
+
* All colors in the registered themes use absolute hex literals (truecolor
|
|
6
|
+
* SGR) so rendering is identical across terminals regardless of the user's
|
|
7
|
+
* palette / theme preferences. Named ANSI colors ({@code "cyan"}, {@code
|
|
8
|
+
* "red"}, etc.) are re-mapped by every terminal to its current color
|
|
9
|
+
* scheme — never use them in tokens.
|
|
10
|
+
*/
|
|
11
|
+
export declare const defaultTheme: Theme;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/** Color palette used throughout the TUI. */
|
|
2
|
+
export interface ThemeColors {
|
|
3
|
+
/** Primary accent (headers, active elements). */
|
|
4
|
+
readonly primary: string;
|
|
5
|
+
/** Secondary accent (descriptions, hints). */
|
|
6
|
+
readonly secondary: string;
|
|
7
|
+
/** Success state. */
|
|
8
|
+
readonly success: string;
|
|
9
|
+
/** Warning state. */
|
|
10
|
+
readonly warning: string;
|
|
11
|
+
/** Error state. */
|
|
12
|
+
readonly error: string;
|
|
13
|
+
/** Muted/dim text. */
|
|
14
|
+
readonly muted: string;
|
|
15
|
+
/** App background color (the global canvas). */
|
|
16
|
+
readonly background: string;
|
|
17
|
+
/** Depth backgrounds for layering multiple widgets */
|
|
18
|
+
readonly backgroundLayerOne: string;
|
|
19
|
+
readonly backgroundLayerTwo: string;
|
|
20
|
+
readonly backgroundLayerThree: string;
|
|
21
|
+
/**
|
|
22
|
+
* Elevated surface background (input fields, modals, panels) — sits one
|
|
23
|
+
* step above {@link ThemeColors.background} so interactive areas read as
|
|
24
|
+
* distinct from the frame canvas.
|
|
25
|
+
*/
|
|
26
|
+
readonly surface: string;
|
|
27
|
+
/** Cursor highlight color. */
|
|
28
|
+
readonly cursor: string;
|
|
29
|
+
/** Scrollbar thumb (active region). */
|
|
30
|
+
readonly scrollThumb: string;
|
|
31
|
+
/** Scrollbar track (inactive region). */
|
|
32
|
+
readonly scrollTrack: string;
|
|
33
|
+
/** User message color. */
|
|
34
|
+
readonly userMessage: string;
|
|
35
|
+
/** Agent message color. */
|
|
36
|
+
readonly agentMessage: string;
|
|
37
|
+
/** System message color. */
|
|
38
|
+
readonly systemMessage: string;
|
|
39
|
+
/** Input prompt color. */
|
|
40
|
+
readonly prompt: string;
|
|
41
|
+
/** Waiting-for-input state. */
|
|
42
|
+
readonly waitingInput: string;
|
|
43
|
+
}
|
|
44
|
+
/** Spacing values (applied to padding/margin). */
|
|
45
|
+
export interface ThemeSpacing {
|
|
46
|
+
/** No spacing. */
|
|
47
|
+
readonly none: number;
|
|
48
|
+
/** Tight spacing (1). */
|
|
49
|
+
readonly xs: number;
|
|
50
|
+
/** Standard horizontal padding (1). */
|
|
51
|
+
readonly sm: number;
|
|
52
|
+
/** Medium spacing (2). */
|
|
53
|
+
readonly md: number;
|
|
54
|
+
/** Large spacing (3). */
|
|
55
|
+
readonly lg: number;
|
|
56
|
+
}
|
|
57
|
+
/** Typography tokens for text styling. */
|
|
58
|
+
export interface ThemeTypography {
|
|
59
|
+
/** Whether headers are bold. */
|
|
60
|
+
readonly headerBold: boolean;
|
|
61
|
+
/** Whether labels are bold. */
|
|
62
|
+
readonly labelBold: boolean;
|
|
63
|
+
/** Whether dim styling is used for secondary text. */
|
|
64
|
+
readonly secondaryDim: boolean;
|
|
65
|
+
}
|
|
66
|
+
/** Border styling tokens. */
|
|
67
|
+
export interface ThemeBorders {
|
|
68
|
+
/** Default border style for boxes. */
|
|
69
|
+
readonly style: string;
|
|
70
|
+
/** Default border color. */
|
|
71
|
+
readonly color: string;
|
|
72
|
+
}
|
|
73
|
+
/** Separator configuration. */
|
|
74
|
+
export interface ThemeSeparator {
|
|
75
|
+
/** Character used for horizontal separators. */
|
|
76
|
+
readonly char: string;
|
|
77
|
+
/** Width of the separator (number of characters). */
|
|
78
|
+
readonly width: number;
|
|
79
|
+
}
|
|
80
|
+
/** Named breakpoint for terminal width thresholds (mobile-first, min-width). */
|
|
81
|
+
export type BreakpointName = "xs" | "sm" | "md" | "lg" | "xl";
|
|
82
|
+
/** Terminal width breakpoints in columns (mobile-first, min-width). */
|
|
83
|
+
export type ThemeBreakpoints = Readonly<Record<BreakpointName, number>>;
|
|
84
|
+
/**
|
|
85
|
+
* Responsive container width per breakpoint.
|
|
86
|
+
*
|
|
87
|
+
* `undefined` means full terminal width (no max constraint).
|
|
88
|
+
* A number means a fixed column width.
|
|
89
|
+
*/
|
|
90
|
+
export type ThemeContainerWidths = Readonly<Record<BreakpointName, number | undefined>>;
|
|
91
|
+
/** Complete theme token set. */
|
|
92
|
+
export interface Theme {
|
|
93
|
+
readonly colors: ThemeColors;
|
|
94
|
+
readonly spacing: ThemeSpacing;
|
|
95
|
+
readonly typography: ThemeTypography;
|
|
96
|
+
readonly borders: ThemeBorders;
|
|
97
|
+
readonly separator: ThemeSeparator;
|
|
98
|
+
readonly breakpoints: ThemeBreakpoints;
|
|
99
|
+
readonly containerWidths: ThemeContainerWidths;
|
|
100
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { BoxProps, TextProps } from "ink";
|
|
2
|
+
export type { ThemeBuilder, ThemeOf } from "./DefineTheme";
|
|
3
|
+
export { defineTheme } from "./DefineTheme";
|
|
4
|
+
export { defaultTheme } from "./Theme";
|
|
5
|
+
export type { BreakpointName, Theme, ThemeBorders, ThemeBreakpoints, ThemeColors, ThemeContainerWidths, ThemeSeparator, ThemeSpacing, ThemeTypography, } from "./Theme.types";
|
|
6
|
+
export type { ThemeName, ThemeRegistryEntry } from "./themes";
|
|
7
|
+
export { DEFAULT_THEME_NAME, darkTheme, draculaTheme, lightTheme, resolveThemeByName, solarizedDarkTheme, THEME_REGISTRY, } from "./themes";
|
|
8
|
+
export type { ThemeContextProviderProps } from "./useTheme";
|
|
9
|
+
export { ThemeContextProvider, useTheme } from "./useTheme";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Theme } from "../Theme.types";
|
|
2
|
+
/**
|
|
3
|
+
* Material Dark — Material Design 3 dark palette with a clear elevation-based
|
|
4
|
+
* depth system and minimal spacing.
|
|
5
|
+
*
|
|
6
|
+
* Depth layers ascend from the deepest background through progressively
|
|
7
|
+
* lighter surfaces, creating a visual hierarchy: `background` (canvas) ←
|
|
8
|
+
* `surface` (cards) ← `backgroundLayerOne` (panels) ←
|
|
9
|
+
* `backgroundLayerTwo` (inputs, modals) ← `backgroundLayerThree` (dialogs).
|
|
10
|
+
*
|
|
11
|
+
* All colors are absolute hex literals (truecolor SGR) for consistent
|
|
12
|
+
* rendering across terminals.
|
|
13
|
+
*/
|
|
14
|
+
export declare const darkTheme: Theme;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Theme } from "../Theme.types";
|
|
2
|
+
/**
|
|
3
|
+
* Dracula — dark palette with purple/cyan/pink accents.
|
|
4
|
+
*
|
|
5
|
+
* Background layers ascend from deepest to lightest, creating a consistent
|
|
6
|
+
* elevation gradient: `background` (canvas) ← `backgroundLayerOne` ←
|
|
7
|
+
* `backgroundLayerTwo` ← `backgroundLayerThree` ← `surface` (interactive).
|
|
8
|
+
*/
|
|
9
|
+
export declare const draculaTheme: Theme;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Theme } from "../Theme.types";
|
|
2
|
+
import { darkTheme } from "./dark";
|
|
3
|
+
import { draculaTheme } from "./dracula";
|
|
4
|
+
import { lightTheme } from "./light";
|
|
5
|
+
import { solarizedDarkTheme } from "./solarized-dark";
|
|
6
|
+
/** Stable identifier for a built-in theme. */
|
|
7
|
+
export type ThemeName = "dark" | "light" | "dracula" | "solarized-dark";
|
|
8
|
+
/** Display metadata for a theme registry entry. */
|
|
9
|
+
export interface ThemeRegistryEntry {
|
|
10
|
+
/** Stable identifier persisted in the user config. */
|
|
11
|
+
readonly name: ThemeName;
|
|
12
|
+
/** Human-readable label shown in pickers. */
|
|
13
|
+
readonly label: string;
|
|
14
|
+
/** One-line description shown next to the label. */
|
|
15
|
+
readonly description: string;
|
|
16
|
+
/** Resolved theme tokens. */
|
|
17
|
+
readonly theme: Theme;
|
|
18
|
+
}
|
|
19
|
+
/** All built-in themes, keyed for the settings dropdown. */
|
|
20
|
+
export declare const THEME_REGISTRY: ReadonlyMap<ThemeName, ThemeRegistryEntry>;
|
|
21
|
+
/** Default theme name when none is configured. */
|
|
22
|
+
export declare const DEFAULT_THEME_NAME: ThemeName;
|
|
23
|
+
/** Resolve a theme by name, falling back to the default if unknown. */
|
|
24
|
+
export declare function resolveThemeByName(themeName: ThemeName): Theme;
|
|
25
|
+
export { darkTheme, lightTheme, draculaTheme, solarizedDarkTheme };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Theme } from "../Theme.types";
|
|
2
|
+
/**
|
|
3
|
+
* Light — bright background with dark text, suitable for light terminals.
|
|
4
|
+
*
|
|
5
|
+
* Background layers descend from bright canvas to progressively darker
|
|
6
|
+
* elevation steps, mimicking shadow depth in a light environment:
|
|
7
|
+
* `background` (canvas) ← `backgroundLayerOne` ← `backgroundLayerTwo` ←
|
|
8
|
+
* `backgroundLayerThree` ← `surface` (interactive).
|
|
9
|
+
*/
|
|
10
|
+
export declare const lightTheme: Theme;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Theme } from "../Theme.types";
|
|
2
|
+
/**
|
|
3
|
+
* Solarized Dark — low-contrast balanced palette popular for terminals.
|
|
4
|
+
*
|
|
5
|
+
* Background layers ascend from deepest to lightest, creating a consistent
|
|
6
|
+
* elevation gradient: `background` (canvas) ← `backgroundLayerOne` ←
|
|
7
|
+
* `backgroundLayerTwo` ← `backgroundLayerThree` ← `surface` (interactive).
|
|
8
|
+
*/
|
|
9
|
+
export declare const solarizedDarkTheme: Theme;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Theme } from "../Theme.types";
|
|
2
|
+
import type { ThemeContextProviderProps } from "./useTheme.types";
|
|
3
|
+
/**
|
|
4
|
+
* Default context value is `defaultTheme` so components rendered outside a
|
|
5
|
+
* live `<ThemeContextProvider>` — most importantly inside the detached tree
|
|
6
|
+
* Ink builds for `measureLayout` calls — still resolve a usable theme.
|
|
7
|
+
*
|
|
8
|
+
* Provider-aware consumers (the running app) override this via
|
|
9
|
+
* `<ThemeContextProvider>` higher up.
|
|
10
|
+
*/
|
|
11
|
+
export declare const ThemeContext: import("react").Context<Theme>;
|
|
12
|
+
/**
|
|
13
|
+
* Provides design tokens to descendant components and theme hooks.
|
|
14
|
+
*
|
|
15
|
+
* When `theme` is supplied, it wins. Otherwise the active theme is read
|
|
16
|
+
* from `useUserConfig` so the dropdown in the command palette settings
|
|
17
|
+
* page can switch themes globally without prop drilling. Must therefore
|
|
18
|
+
* be mounted *inside* a `<UserConfigContextProvider>` when no explicit
|
|
19
|
+
* `theme` is passed.
|
|
20
|
+
*
|
|
21
|
+
* @param props - Theme provider configuration including optional theme override.
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <UserConfigContextProvider>
|
|
25
|
+
* <ThemeContextProvider>
|
|
26
|
+
* <App />
|
|
27
|
+
* </ThemeContextProvider>
|
|
28
|
+
* </UserConfigContextProvider>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function ThemeContextProvider({ theme, children, }: ThemeContextProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Theme } from "../Theme.types";
|
|
2
|
+
/**
|
|
3
|
+
* Access the current theme tokens.
|
|
4
|
+
*
|
|
5
|
+
* Returns the `Theme` object from the nearest `<ThemeContextProvider>`,
|
|
6
|
+
* or `defaultTheme` when called outside any provider. The fallback exists
|
|
7
|
+
* primarily so components remain renderable inside the detached
|
|
8
|
+
* `measureLayout` tree, which has no provider chain of its own. Within
|
|
9
|
+
* the live app the provider always wins.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useTheme(): Theme;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Theme } from "../Theme.types";
|
|
2
|
+
/** Shape of the theme context value. */
|
|
3
|
+
export type ThemeContextType = Theme;
|
|
4
|
+
/** Props for `ThemeContextProvider`. */
|
|
5
|
+
export interface ThemeContextProviderProps {
|
|
6
|
+
/** Optional theme override. Defaults to `defaultTheme`. */
|
|
7
|
+
readonly theme?: Theme;
|
|
8
|
+
/** Child components that can consume the theme. */
|
|
9
|
+
readonly children: React.ReactNode;
|
|
10
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type DOMElement } from "ink";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { BorderedPanelTheme } from "./BorderedPanel.theme";
|
|
4
|
+
export interface BorderedPanelProps {
|
|
5
|
+
/**
|
|
6
|
+
* Label embedded into the top border, e.g. an agent name or sender role.
|
|
7
|
+
*
|
|
8
|
+
* Rendered inline in the top border row by overlaying the label text on
|
|
9
|
+
* top of Ink's built-in border via an absolutely-positioned child.
|
|
10
|
+
*/
|
|
11
|
+
readonly header: React.ReactNode;
|
|
12
|
+
/** Optional ref attached to the header overlay for mouse hit testing. */
|
|
13
|
+
readonly headerRef?: React.RefObject<DOMElement | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Color applied to every border glyph (top, left, right, bottom).
|
|
16
|
+
* Defaults to the theme's neutral border color when omitted.
|
|
17
|
+
*/
|
|
18
|
+
readonly borderColor?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Background color for the panel body. Also painted behind the header
|
|
21
|
+
* label so the underlying top border is masked out where the label sits.
|
|
22
|
+
*/
|
|
23
|
+
readonly backgroundColor?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Color applied to the header label text. Defaults to the theme's
|
|
26
|
+
* primary foreground color when omitted; callers typically pass a
|
|
27
|
+
* role-specific color so the label matches the message owner.
|
|
28
|
+
*/
|
|
29
|
+
readonly headerColor?: string;
|
|
30
|
+
/** Body content rendered inside the panel. */
|
|
31
|
+
readonly children: React.ReactNode;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A column-shaped panel whose top border embeds a text label.
|
|
35
|
+
*
|
|
36
|
+
* Implementation: the body uses Ink's built-in `borderStyle: "single"` so
|
|
37
|
+
* Yoga draws the entire frame (top, sides, bottom). The header label is
|
|
38
|
+
* then painted over the top border via an absolutely-positioned child
|
|
39
|
+
* with `marginTop: -1`, offset one column from the left corner so the
|
|
40
|
+
* `┌` glyph stays visible. The label `<Text>` carries the panel's
|
|
41
|
+
* background color so the dashes underneath are masked out — visually
|
|
42
|
+
* indistinguishable from a hand-drawn `┌─ label ─...─┐` line, but with
|
|
43
|
+
* **zero measurement**: no `useBoxMetrics`, no stdout listener, no
|
|
44
|
+
* dash-fill math. Yoga handles the border and clipping for free.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* <BorderedPanel header="planner" borderColor={colors.agentMessage}>
|
|
49
|
+
* <Text>...</Text>
|
|
50
|
+
* </BorderedPanel>
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function BorderedPanel({ header, headerRef, borderColor, headerColor, backgroundColor, children, }: BorderedPanelProps): React.ReactElement;
|
|
54
|
+
export interface BorderedPanelRenderProps {
|
|
55
|
+
/** Resolved BorderedPanel theme. */
|
|
56
|
+
readonly theme: BorderedPanelTheme;
|
|
57
|
+
/** Header label embedded into the top border. */
|
|
58
|
+
readonly header: React.ReactNode;
|
|
59
|
+
/** Optional ref attached to the header overlay for mouse hit testing. */
|
|
60
|
+
readonly headerRef?: React.RefObject<DOMElement | null>;
|
|
61
|
+
/** Resolved border color (no fallback handling here). */
|
|
62
|
+
readonly borderColor: string;
|
|
63
|
+
/** Resolved header label color (no fallback handling here). */
|
|
64
|
+
readonly headerColor: string;
|
|
65
|
+
/** Resolved background color (also masks the border behind the label). */
|
|
66
|
+
readonly backgroundColor: string;
|
|
67
|
+
/** Body content. */
|
|
68
|
+
readonly children: React.ReactNode;
|
|
69
|
+
}
|
|
70
|
+
export declare function BorderedPanelRender({ theme, header, headerRef, borderColor, headerColor, backgroundColor, children, }: BorderedPanelRenderProps): React.ReactElement;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type ThemeOf } from "../../Theme";
|
|
2
|
+
/**
|
|
3
|
+
* Memoized themed style objects for the `BorderedPanel` component.
|
|
4
|
+
*
|
|
5
|
+
* The header line is drawn manually (so we can embed a label inside the
|
|
6
|
+
* top-border characters); the body's left/right/bottom borders use Ink's
|
|
7
|
+
* built-in border rendering. Both must use the same glyph set or the
|
|
8
|
+
* panel will look mismatched.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useBorderedPanelTheme: () => {
|
|
11
|
+
/** Outer column wrapping the header line and the body. */
|
|
12
|
+
container: {
|
|
13
|
+
flexDirection: "column";
|
|
14
|
+
width: string;
|
|
15
|
+
borderStyle: "round";
|
|
16
|
+
borderBottom: false;
|
|
17
|
+
borderRight: false;
|
|
18
|
+
paddingX: number;
|
|
19
|
+
};
|
|
20
|
+
/** Single-row header line: `┌─ label ──...──┐`. */
|
|
21
|
+
header: {
|
|
22
|
+
position: "absolute";
|
|
23
|
+
marginTop: number;
|
|
24
|
+
marginLeft: number;
|
|
25
|
+
flexDirection: "row";
|
|
26
|
+
text: {
|
|
27
|
+
bold: true;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Glyphs used to compose the manual header line. Must match the
|
|
32
|
+
* `borderStyle` of the body so the corners line up with the body's
|
|
33
|
+
* left/right border characters.
|
|
34
|
+
*/
|
|
35
|
+
glyphs: {
|
|
36
|
+
/** Top-left corner: `┌`. */
|
|
37
|
+
cornerLeft: string;
|
|
38
|
+
/** Top-right corner: `┐`. */
|
|
39
|
+
cornerRight: string;
|
|
40
|
+
/** Horizontal fill character: `─`. */
|
|
41
|
+
horizontal: string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Default color applied to every part of the panel border (header
|
|
45
|
+
* glyphs + body border). Callers override per-message via the
|
|
46
|
+
* `borderColor` prop.
|
|
47
|
+
*/
|
|
48
|
+
borderColor: string;
|
|
49
|
+
/**
|
|
50
|
+
* Default color for the header label text. Callers override per
|
|
51
|
+
* message via `headerColor`.
|
|
52
|
+
*/
|
|
53
|
+
headerColor: string;
|
|
54
|
+
backgroundColor: string;
|
|
55
|
+
/** Whether the header label is bold by default. */
|
|
56
|
+
headerBold: boolean;
|
|
57
|
+
};
|
|
58
|
+
/** Resolved style object shape returned by {@link useBorderedPanelTheme}. */
|
|
59
|
+
export type BorderedPanelTheme = ThemeOf<typeof useBorderedPanelTheme>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { BorderedPanelProps, BorderedPanelRenderProps, } from "./BorderedPanel";
|
|
2
|
+
export { BorderedPanel, BorderedPanelRender, } from "./BorderedPanel";
|
|
3
|
+
export type { BorderedPanelTheme } from "./BorderedPanel.theme";
|
|
4
|
+
export { useBorderedPanelTheme } from "./BorderedPanel.theme";
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type DOMElement } from "ink";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import { type RefObject } from "react";
|
|
4
|
+
import { type ButtonTheme } from "./Button.theme";
|
|
5
|
+
import type { ButtonVariant } from "./Button.types";
|
|
6
|
+
export interface ButtonProps {
|
|
7
|
+
/** Ink focus id. When supplied the button participates in Ink's global focus cycle. When omitted the button manages its own internal focus zone. */
|
|
8
|
+
readonly id?: string;
|
|
9
|
+
/** Text label rendered inside the button. */
|
|
10
|
+
readonly label: string;
|
|
11
|
+
/** Visual variant that controls border and text coloring. @default "primary" */
|
|
12
|
+
readonly variant?: ButtonVariant;
|
|
13
|
+
/** Callback invoked when the button is activated (Enter key or left/right click). */
|
|
14
|
+
readonly onPress: () => void;
|
|
15
|
+
/** When `true` the button is rendered as disabled: it does not respond to clicks or key presses and is visually dimmed. @default false */
|
|
16
|
+
readonly disabled?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Interactive button with focus, hover, and click support.
|
|
20
|
+
*
|
|
21
|
+
* Responds to:
|
|
22
|
+
* - **Enter** key when focused → triggers `onPress`.
|
|
23
|
+
* - **Left click** (button 0) → focuses the button then triggers `onPress`.
|
|
24
|
+
* - **Right click** (button 2) → triggers `onPress` without stealing focus.
|
|
25
|
+
*
|
|
26
|
+
* Visual states:
|
|
27
|
+
* - `variant` controls the color scheme (`primary`, `secondary`, `danger`, `ghost`).
|
|
28
|
+
* - Focus and hover both highlight the button using an `inverse` text style.
|
|
29
|
+
* - `disabled` dims the button and suppresses all interactions.
|
|
30
|
+
*
|
|
31
|
+
* Must be rendered inside a `<Frame>` (which mounts `<MouseProvider>`) for
|
|
32
|
+
* mouse events to work.
|
|
33
|
+
*
|
|
34
|
+
* @param props - The button properties including label, variant, and activation callback.
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* <Button label="Confirm" variant="primary" onPress={() => submit()} />
|
|
38
|
+
* <Button label="Delete" variant="danger" onPress={() => remove()} />
|
|
39
|
+
* <Button label="Cancel" variant="ghost" onPress={() => close()} />
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function Button({ id, label, variant, onPress, disabled, }: ButtonProps): React.ReactElement;
|
|
43
|
+
export interface ButtonRenderProps {
|
|
44
|
+
/** Resolved Button theme. */
|
|
45
|
+
readonly theme: ButtonTheme;
|
|
46
|
+
/** Text label rendered inside the button. */
|
|
47
|
+
readonly label: string;
|
|
48
|
+
/** Active visual variant. */
|
|
49
|
+
readonly variant: ButtonVariant;
|
|
50
|
+
/** Whether the button currently has keyboard focus. */
|
|
51
|
+
readonly isFocused: boolean;
|
|
52
|
+
/** Whether the mouse cursor is hovering over the button. */
|
|
53
|
+
readonly isHovered: boolean;
|
|
54
|
+
/** Whether the button is disabled. */
|
|
55
|
+
readonly disabled: boolean;
|
|
56
|
+
/** Ref attached to the root `<Box>` for AABB hit-testing. */
|
|
57
|
+
readonly boxRef: RefObject<DOMElement | null>;
|
|
58
|
+
/** Node rendered inside the box (supplied by the container). */
|
|
59
|
+
readonly children?: React.ReactNode;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Pure render function for the `Button` component.
|
|
63
|
+
*
|
|
64
|
+
* Accepts fully-resolved props — no theme fallback logic, no hooks.
|
|
65
|
+
* Useful for isolated visual testing and Storybook stories.
|
|
66
|
+
*
|
|
67
|
+
* @param props - The resolved rendering properties for the button.
|
|
68
|
+
*/
|
|
69
|
+
export declare function ButtonRender({ theme, label, variant, isFocused, isHovered, disabled, boxRef, }: ButtonRenderProps): React.ReactElement;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type ThemeOf } from "../../Theme";
|
|
2
|
+
/**
|
|
3
|
+
* Memoized themed style objects for the `Button` component.
|
|
4
|
+
*
|
|
5
|
+
* Each variant gets its own resolved color set so the render function only
|
|
6
|
+
* needs to index by `ButtonVariant` — no conditional logic inside JSX.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const theme = useButtonTheme();
|
|
11
|
+
* const styles = theme.variants.primary;
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const useButtonTheme: () => {
|
|
15
|
+
buttonContainer: {
|
|
16
|
+
flexDirection: "row";
|
|
17
|
+
paddingX: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Per-variant color pairs used to style the border and label text.
|
|
21
|
+
* Both `color` and `focusColor` are terminal color strings passed
|
|
22
|
+
* directly to Ink `<Text>` / `<Box>` props.
|
|
23
|
+
*/
|
|
24
|
+
variants: {
|
|
25
|
+
primary: {
|
|
26
|
+
/** Normal (unfocused, unhovered) border and label color. */
|
|
27
|
+
color: string;
|
|
28
|
+
/** Color when focused or hovered. */
|
|
29
|
+
focusColor: string;
|
|
30
|
+
};
|
|
31
|
+
secondary: {
|
|
32
|
+
color: string;
|
|
33
|
+
focusColor: string;
|
|
34
|
+
};
|
|
35
|
+
danger: {
|
|
36
|
+
color: string;
|
|
37
|
+
focusColor: string;
|
|
38
|
+
};
|
|
39
|
+
ghost: {
|
|
40
|
+
color: string;
|
|
41
|
+
focusColor: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
/** Label is bold when the button has focus. */
|
|
45
|
+
labelBold: boolean;
|
|
46
|
+
/** Color applied to the entire button when disabled. */
|
|
47
|
+
disabledColor: string;
|
|
48
|
+
};
|
|
49
|
+
/** Resolved style object shape returned by {@link useButtonTheme}. */
|
|
50
|
+
export type ButtonTheme = ThemeOf<typeof useButtonTheme>;
|