@grackle-ai/web-components 0.107.2
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/.rush/temp/3ae72563f781afd72723475938136f113846603e.untar.log +10 -0
- package/.rush/temp/bc1d5bf9201ce71abeaeaddd096deb9b0805d703.untar.log +10 -0
- package/.rush/temp/operation/_phase_build/all.log +18 -0
- package/.rush/temp/operation/_phase_build/log-chunks.jsonl +18 -0
- package/.rush/temp/operation/_phase_build/state.json +3 -0
- package/.rush/temp/operation/_phase_test/all.log +121 -0
- package/.rush/temp/operation/_phase_test/log-chunks.jsonl +121 -0
- package/.rush/temp/operation/_phase_test/state.json +3 -0
- package/.rush/temp/shrinkwrap-deps.json +938 -0
- package/.storybook/main.ts +22 -0
- package/.storybook/preview.tsx +30 -0
- package/config/rig.json +4 -0
- package/config/rush-project.json +12 -0
- package/dist/index.css +1 -0
- package/dist/index.js +39221 -0
- package/eslint.config.cjs +5 -0
- package/package.json +83 -0
- package/rush-logs/web-components._phase_build.cache.log +4 -0
- package/rush-logs/web-components._phase_test.cache.log +4 -0
- package/src/components/chat/ChatInput.module.scss +81 -0
- package/src/components/chat/ChatInput.stories.tsx +91 -0
- package/src/components/chat/ChatInput.tsx +168 -0
- package/src/components/chat/index.ts +6 -0
- package/src/components/dag/DagView.module.scss +149 -0
- package/src/components/dag/DagView.stories.tsx +125 -0
- package/src/components/dag/DagView.tsx +109 -0
- package/src/components/dag/TaskNode.stories.tsx +133 -0
- package/src/components/dag/TaskNode.tsx +40 -0
- package/src/components/dag/useDagLayout.ts +139 -0
- package/src/components/display/Breadcrumbs.module.scss +71 -0
- package/src/components/display/Breadcrumbs.stories.tsx +80 -0
- package/src/components/display/Breadcrumbs.tsx +46 -0
- package/src/components/display/Button.module.scss +110 -0
- package/src/components/display/Button.stories.tsx +88 -0
- package/src/components/display/Button.tsx +40 -0
- package/src/components/display/ConfirmDialog.module.scss +67 -0
- package/src/components/display/ConfirmDialog.stories.tsx +81 -0
- package/src/components/display/ConfirmDialog.tsx +88 -0
- package/src/components/display/CopyButton.module.scss +41 -0
- package/src/components/display/CopyButton.stories.tsx +78 -0
- package/src/components/display/CopyButton.tsx +64 -0
- package/src/components/display/DemoBanner.module.scss +37 -0
- package/src/components/display/DemoBanner.stories.tsx +40 -0
- package/src/components/display/DemoBanner.tsx +23 -0
- package/src/components/display/EventHoverRow.module.scss +102 -0
- package/src/components/display/EventHoverRow.stories.tsx +99 -0
- package/src/components/display/EventHoverRow.tsx +154 -0
- package/src/components/display/EventRenderer.module.scss +272 -0
- package/src/components/display/EventRenderer.stories.tsx +186 -0
- package/src/components/display/EventRenderer.tsx +271 -0
- package/src/components/display/EventStream.module.scss +93 -0
- package/src/components/display/EventStream.stories.tsx +249 -0
- package/src/components/display/EventStream.tsx +369 -0
- package/src/components/display/FloatingActionBar.module.scss +107 -0
- package/src/components/display/FloatingActionBar.stories.tsx +122 -0
- package/src/components/display/FloatingActionBar.tsx +119 -0
- package/src/components/display/SessionAttemptSelector.module.scss +50 -0
- package/src/components/display/SessionAttemptSelector.stories.tsx +78 -0
- package/src/components/display/SessionAttemptSelector.tsx +49 -0
- package/src/components/display/SessionPicker.module.scss +200 -0
- package/src/components/display/SessionPicker.stories.tsx +169 -0
- package/src/components/display/SessionPicker.tsx +214 -0
- package/src/components/display/Skeleton.module.scss +58 -0
- package/src/components/display/Skeleton.stories.tsx +94 -0
- package/src/components/display/Skeleton.tsx +127 -0
- package/src/components/display/Spinner.module.scss +41 -0
- package/src/components/display/Spinner.stories.tsx +66 -0
- package/src/components/display/Spinner.tsx +32 -0
- package/src/components/display/SplashScreen.module.scss +20 -0
- package/src/components/display/SplashScreen.stories.tsx +26 -0
- package/src/components/display/SplashScreen.tsx +16 -0
- package/src/components/display/SplitButton.module.scss +166 -0
- package/src/components/display/SplitButton.stories.tsx +95 -0
- package/src/components/display/SplitButton.tsx +128 -0
- package/src/components/display/Tooltip.module.scss +84 -0
- package/src/components/display/Tooltip.stories.tsx +240 -0
- package/src/components/display/Tooltip.tsx +184 -0
- package/src/components/display/extractText.test.tsx +48 -0
- package/src/components/display/index.ts +20 -0
- package/src/components/editable/EditableCheckbox.stories.tsx +54 -0
- package/src/components/editable/EditableCheckbox.tsx +39 -0
- package/src/components/editable/EditableField.module.scss +135 -0
- package/src/components/editable/EditableSelect.tsx +164 -0
- package/src/components/editable/EditableTextArea.stories.tsx +50 -0
- package/src/components/editable/EditableTextArea.tsx +148 -0
- package/src/components/editable/EditableTextField.stories.tsx +62 -0
- package/src/components/editable/EditableTextField.tsx +153 -0
- package/src/components/editable/EnvironmentSelect.module.scss +17 -0
- package/src/components/editable/EnvironmentSelect.stories.tsx +61 -0
- package/src/components/editable/EnvironmentSelect.tsx +87 -0
- package/src/components/editable/index.ts +13 -0
- package/src/components/editable/useEditableField.test.tsx +233 -0
- package/src/components/editable/useEditableField.ts +173 -0
- package/src/components/index.ts +20 -0
- package/src/components/knowledge/KnowledgeDetailPanel.module.scss +162 -0
- package/src/components/knowledge/KnowledgeDetailPanel.stories.tsx +208 -0
- package/src/components/knowledge/KnowledgeDetailPanel.tsx +122 -0
- package/src/components/knowledge/KnowledgeGraph.module.scss +110 -0
- package/src/components/knowledge/KnowledgeGraph.stories.tsx +180 -0
- package/src/components/knowledge/KnowledgeGraph.tsx +455 -0
- package/src/components/knowledge/KnowledgeNav.module.scss +130 -0
- package/src/components/knowledge/KnowledgeNav.stories.tsx +108 -0
- package/src/components/knowledge/KnowledgeNav.tsx +138 -0
- package/src/components/knowledge/index.ts +3 -0
- package/src/components/layout/AppNav.module.scss +82 -0
- package/src/components/layout/AppNav.stories.tsx +115 -0
- package/src/components/layout/AppNav.tsx +133 -0
- package/src/components/layout/BottomStatusBar.module.scss +58 -0
- package/src/components/layout/BottomStatusBar.stories.tsx +35 -0
- package/src/components/layout/BottomStatusBar.tsx +206 -0
- package/src/components/layout/Sidebar.module.scss +60 -0
- package/src/components/layout/Sidebar.stories.tsx +46 -0
- package/src/components/layout/Sidebar.tsx +84 -0
- package/src/components/layout/StatusBar.module.scss +108 -0
- package/src/components/layout/StatusBar.stories.tsx +119 -0
- package/src/components/layout/StatusBar.tsx +70 -0
- package/src/components/layout/index.ts +9 -0
- package/src/components/lists/EnvironmentNav.module.scss +118 -0
- package/src/components/lists/EnvironmentNav.stories.tsx +121 -0
- package/src/components/lists/EnvironmentNav.tsx +133 -0
- package/src/components/lists/FindingsNav.module.scss +126 -0
- package/src/components/lists/FindingsNav.tsx +146 -0
- package/src/components/lists/TaskList.module.scss +206 -0
- package/src/components/lists/TaskList.stories.tsx +401 -0
- package/src/components/lists/TaskList.tsx +509 -0
- package/src/components/lists/index.ts +6 -0
- package/src/components/lists/listHelpers.tsx +130 -0
- package/src/components/notifications/Callout.module.scss +83 -0
- package/src/components/notifications/Callout.stories.tsx +81 -0
- package/src/components/notifications/Callout.tsx +64 -0
- package/src/components/notifications/Toast.module.scss +86 -0
- package/src/components/notifications/Toast.stories.tsx +71 -0
- package/src/components/notifications/Toast.tsx +51 -0
- package/src/components/notifications/ToastContainer.module.scss +23 -0
- package/src/components/notifications/ToastContainer.stories.tsx +66 -0
- package/src/components/notifications/ToastContainer.tsx +29 -0
- package/src/components/notifications/UpdateBanner.stories.tsx +77 -0
- package/src/components/notifications/UpdateBanner.test.tsx +64 -0
- package/src/components/notifications/UpdateBanner.tsx +44 -0
- package/src/components/notifications/index.ts +8 -0
- package/src/components/panels/AboutPanel.stories.tsx +70 -0
- package/src/components/panels/AboutPanel.tsx +66 -0
- package/src/components/panels/AppearancePanel.stories.tsx +45 -0
- package/src/components/panels/AppearancePanel.tsx +97 -0
- package/src/components/panels/CredentialProvidersPanel.stories.tsx +62 -0
- package/src/components/panels/CredentialProvidersPanel.tsx +111 -0
- package/src/components/panels/EnvironmentEditPanel.module.scss +170 -0
- package/src/components/panels/EnvironmentEditPanel.stories.tsx +206 -0
- package/src/components/panels/EnvironmentEditPanel.tsx +785 -0
- package/src/components/panels/FindingsPanel.module.scss +94 -0
- package/src/components/panels/FindingsPanel.stories.tsx +109 -0
- package/src/components/panels/FindingsPanel.tsx +76 -0
- package/src/components/panels/KeyboardShortcutsPanel.module.scss +65 -0
- package/src/components/panels/KeyboardShortcutsPanel.stories.tsx +40 -0
- package/src/components/panels/KeyboardShortcutsPanel.tsx +104 -0
- package/src/components/panels/PluginsPanel.tsx +77 -0
- package/src/components/panels/SettingsPanel.module.scss +336 -0
- package/src/components/panels/TaskActionButtons.module.scss +22 -0
- package/src/components/panels/TaskActionButtons.stories.tsx +125 -0
- package/src/components/panels/TaskActionButtons.tsx +87 -0
- package/src/components/panels/TaskEditPanel.module.scss +202 -0
- package/src/components/panels/TaskEditPanel.stories.tsx +75 -0
- package/src/components/panels/TaskEditPanel.tsx +328 -0
- package/src/components/panels/TaskOverviewPanel.module.scss +236 -0
- package/src/components/panels/TaskOverviewPanel.stories.tsx +219 -0
- package/src/components/panels/TaskOverviewPanel.tsx +270 -0
- package/src/components/panels/TokensPanel.stories.tsx +131 -0
- package/src/components/panels/TokensPanel.tsx +143 -0
- package/src/components/panels/WorkpadPanel.module.scss +39 -0
- package/src/components/panels/WorkpadPanel.stories.tsx +56 -0
- package/src/components/panels/WorkpadPanel.tsx +63 -0
- package/src/components/panels/index.ts +13 -0
- package/src/components/personas/McpToolSelector.module.scss +109 -0
- package/src/components/personas/McpToolSelector.stories.tsx +129 -0
- package/src/components/personas/McpToolSelector.tsx +180 -0
- package/src/components/personas/PersonaManager.module.scss +233 -0
- package/src/components/personas/PersonaManager.stories.tsx +139 -0
- package/src/components/personas/PersonaManager.tsx +122 -0
- package/src/components/schedules/ScheduleManager.module.scss +98 -0
- package/src/components/schedules/ScheduleManager.stories.tsx +78 -0
- package/src/components/schedules/ScheduleManager.tsx +160 -0
- package/src/components/settings/SettingsNav.module.scss +82 -0
- package/src/components/settings/SettingsNav.stories.tsx +83 -0
- package/src/components/settings/SettingsNav.tsx +104 -0
- package/src/components/streams/StreamDetailPanel.module.scss +206 -0
- package/src/components/streams/StreamDetailPanel.stories.tsx +132 -0
- package/src/components/streams/StreamDetailPanel.tsx +119 -0
- package/src/components/streams/StreamList.module.scss +92 -0
- package/src/components/streams/StreamList.stories.tsx +99 -0
- package/src/components/streams/StreamList.tsx +114 -0
- package/src/components/streams/index.ts +10 -0
- package/src/components/tools/AgentToolCard.module.scss +118 -0
- package/src/components/tools/AgentToolCard.stories.tsx +304 -0
- package/src/components/tools/AgentToolCard.tsx +247 -0
- package/src/components/tools/FileEditCard.stories.tsx +138 -0
- package/src/components/tools/FileEditCard.tsx +160 -0
- package/src/components/tools/FileReadCard.stories.tsx +120 -0
- package/src/components/tools/FileReadCard.tsx +106 -0
- package/src/components/tools/FindingCard.stories.tsx +124 -0
- package/src/components/tools/FindingCard.tsx +178 -0
- package/src/components/tools/GenericToolCard.stories.tsx +80 -0
- package/src/components/tools/GenericToolCard.tsx +111 -0
- package/src/components/tools/IpcCard.stories.tsx +129 -0
- package/src/components/tools/IpcCard.tsx +178 -0
- package/src/components/tools/KnowledgeCard.stories.tsx +112 -0
- package/src/components/tools/KnowledgeCard.tsx +165 -0
- package/src/components/tools/MetadataCard.stories.tsx +32 -0
- package/src/components/tools/MetadataCard.tsx +39 -0
- package/src/components/tools/SearchCard.stories.tsx +74 -0
- package/src/components/tools/SearchCard.tsx +86 -0
- package/src/components/tools/ShellCard.stories.tsx +112 -0
- package/src/components/tools/ShellCard.tsx +106 -0
- package/src/components/tools/TaskCard.stories.tsx +123 -0
- package/src/components/tools/TaskCard.tsx +203 -0
- package/src/components/tools/TodoCard.module.scss +131 -0
- package/src/components/tools/TodoCard.stories.tsx +202 -0
- package/src/components/tools/TodoCard.tsx +200 -0
- package/src/components/tools/ToolCard.stories.tsx +177 -0
- package/src/components/tools/ToolCard.tsx +60 -0
- package/src/components/tools/ToolCardProps.ts +20 -0
- package/src/components/tools/ToolSearchCard.stories.tsx +81 -0
- package/src/components/tools/ToolSearchCard.tsx +86 -0
- package/src/components/tools/WorkpadCard.stories.tsx +106 -0
- package/src/components/tools/WorkpadCard.tsx +125 -0
- package/src/components/tools/classifyTool.test.ts +44 -0
- package/src/components/tools/classifyTool.ts +134 -0
- package/src/components/tools/parseDiff.ts +95 -0
- package/src/components/tools/parseShellOutput.ts +28 -0
- package/src/components/tools/toolCardHelpers.test.ts +53 -0
- package/src/components/tools/toolCards.module.scss +234 -0
- package/src/components/workspace/WorkspaceBoard.module.scss +238 -0
- package/src/components/workspace/WorkspaceBoard.stories.tsx +240 -0
- package/src/components/workspace/WorkspaceBoard.tsx +232 -0
- package/src/components/workspace/WorkspaceFormFields.module.scss +79 -0
- package/src/components/workspace/WorkspaceFormFields.stories.tsx +133 -0
- package/src/components/workspace/WorkspaceFormFields.tsx +185 -0
- package/src/context/GrackleContext.ts +28 -0
- package/src/context/GrackleContextTypes.ts +64 -0
- package/src/context/SidebarContext.tsx +53 -0
- package/src/context/ThemeContext.tsx +21 -0
- package/src/context/ToastContext.tsx +56 -0
- package/src/hooks/types.ts +864 -0
- package/src/hooks/useEventSelection.test.ts +204 -0
- package/src/hooks/useEventSelection.ts +158 -0
- package/src/hooks/useSmartScroll.ts +151 -0
- package/src/hooks/useTheme.ts +228 -0
- package/src/index.ts +210 -0
- package/src/mocks/MockGrackleProvider.tsx +1397 -0
- package/src/mocks/mockData.ts +1966 -0
- package/src/mocks/mockKnowledgeData.ts +294 -0
- package/src/scss.d.ts +12 -0
- package/src/styles/global.scss +244 -0
- package/src/styles/mixins.scss +278 -0
- package/src/styles/prism-theme.scss +148 -0
- package/src/styles/theme.scss +1102 -0
- package/src/test-utils/storybook-decorators.tsx +50 -0
- package/src/test-utils/storybook-helpers.ts +262 -0
- package/src/themes.ts +142 -0
- package/src/utils/boardColumns.ts +141 -0
- package/src/utils/breadcrumbs.test.ts +285 -0
- package/src/utils/breadcrumbs.ts +222 -0
- package/src/utils/dashboard.test.ts +156 -0
- package/src/utils/dashboard.ts +195 -0
- package/src/utils/eventContent.test.ts +353 -0
- package/src/utils/eventContent.ts +209 -0
- package/src/utils/findingCategory.ts +33 -0
- package/src/utils/format.ts +27 -0
- package/src/utils/iconSize.ts +18 -0
- package/src/utils/navigation.ts +205 -0
- package/src/utils/route-config.test.ts +128 -0
- package/src/utils/scrollUtils.test.ts +65 -0
- package/src/utils/scrollUtils.ts +49 -0
- package/src/utils/sessionEvents.test.ts +302 -0
- package/src/utils/sessionEvents.ts +233 -0
- package/src/utils/taskStatus.tsx +137 -0
- package/src/utils/time.ts +92 -0
- package/tsconfig.json +8 -0
- package/vite.config.ts +20 -0
- package/vitest.config.ts +10 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { useCallback, useEffect, useSyncExternalStore } from "react";
|
|
2
|
+
import { THEMES, THEME_IDS, DEFAULT_THEME_ID, getThemeById } from "../themes.js";
|
|
3
|
+
import type { ThemeDefinition } from "../themes.js";
|
|
4
|
+
|
|
5
|
+
interface ThemeSnapshot {
|
|
6
|
+
themeId: string;
|
|
7
|
+
systemDark: boolean;
|
|
8
|
+
preferSystem: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const STORAGE_KEY: string = "grackle-theme";
|
|
12
|
+
const PREFER_SYSTEM_KEY: string = "grackle-prefer-system";
|
|
13
|
+
const MEDIA_QUERY: string = "(prefers-color-scheme: dark)";
|
|
14
|
+
|
|
15
|
+
let listeners: Array<() => void> = [];
|
|
16
|
+
let lastSnapshot: ThemeSnapshot | undefined = undefined;
|
|
17
|
+
|
|
18
|
+
/** Notify all subscribers of a state change. */
|
|
19
|
+
function emitChange(): void {
|
|
20
|
+
lastSnapshot = undefined;
|
|
21
|
+
for (const listener of listeners) {
|
|
22
|
+
listener();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Check whether the OS prefers dark mode. */
|
|
27
|
+
function getSystemDark(): boolean {
|
|
28
|
+
if (typeof window === "undefined") {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return window.matchMedia(MEDIA_QUERY).matches;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Read the persisted theme ID from localStorage, defaulting to the registry default. */
|
|
35
|
+
function getStored(): string {
|
|
36
|
+
if (typeof localStorage === "undefined") {
|
|
37
|
+
return DEFAULT_THEME_ID;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const raw: string | null = localStorage.getItem(STORAGE_KEY);
|
|
41
|
+
if (raw !== null && THEME_IDS.has(raw)) {
|
|
42
|
+
return raw;
|
|
43
|
+
}
|
|
44
|
+
} catch {
|
|
45
|
+
// localStorage may be unavailable
|
|
46
|
+
}
|
|
47
|
+
return DEFAULT_THEME_ID;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Read the persisted prefer-system flag from localStorage. */
|
|
51
|
+
function getPreferSystem(): boolean {
|
|
52
|
+
if (typeof localStorage === "undefined") {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
return localStorage.getItem(PREFER_SYSTEM_KEY) === "true";
|
|
57
|
+
} catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Find the parent theme for a hidden variant ID (e.g., "grackle-dark" → Grackle). */
|
|
63
|
+
function findParentTheme(variantId: string): ThemeDefinition | undefined {
|
|
64
|
+
return THEMES.find((t) => t.variantLightId === variantId || t.variantDarkId === variantId);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Resolve a theme ID to the data-theme attribute value applied to the document. */
|
|
68
|
+
function resolveDataTheme(themeId: string, preferSystem: boolean): string {
|
|
69
|
+
const def = getThemeById(themeId);
|
|
70
|
+
// Parent theme with variants → resolve to light or dark
|
|
71
|
+
if (def?.variantDarkId) {
|
|
72
|
+
if (preferSystem && def.variantLightId) {
|
|
73
|
+
return getSystemDark() ? def.variantDarkId : def.variantLightId;
|
|
74
|
+
}
|
|
75
|
+
return def.variantDarkId;
|
|
76
|
+
}
|
|
77
|
+
// Concrete variant ID (e.g., "grackle-dark") — if preferSystem, resolve via parent
|
|
78
|
+
if (def?.hidden && preferSystem) {
|
|
79
|
+
const parent = findParentTheme(themeId);
|
|
80
|
+
if (parent?.variantLightId && parent.variantDarkId) {
|
|
81
|
+
return getSystemDark() ? parent.variantDarkId : parent.variantLightId;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return themeId;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Apply the resolved theme to the document root element. */
|
|
88
|
+
function applyTheme(themeId: string, preferSystem: boolean, suppressTransitions: boolean = false): void {
|
|
89
|
+
if (suppressTransitions) {
|
|
90
|
+
document.documentElement.classList.add("no-transitions");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
document.documentElement.dataset.theme = resolveDataTheme(themeId, preferSystem);
|
|
94
|
+
|
|
95
|
+
if (suppressTransitions) {
|
|
96
|
+
// Force a reflow so the no-transitions class takes effect before removal
|
|
97
|
+
// eslint-disable-next-line no-unused-expressions
|
|
98
|
+
document.documentElement.offsetHeight;
|
|
99
|
+
requestAnimationFrame(() => {
|
|
100
|
+
document.documentElement.classList.remove("no-transitions");
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Apply immediately on module load to prevent flash of wrong theme
|
|
106
|
+
if (typeof document !== "undefined") {
|
|
107
|
+
applyTheme(getStored(), getPreferSystem());
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Build the current snapshot for useSyncExternalStore. */
|
|
111
|
+
function getSnapshot(): ThemeSnapshot {
|
|
112
|
+
if (lastSnapshot === undefined) {
|
|
113
|
+
lastSnapshot = {
|
|
114
|
+
themeId: getStored(),
|
|
115
|
+
systemDark: getSystemDark(),
|
|
116
|
+
preferSystem: getPreferSystem(),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return lastSnapshot;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Subscribe to snapshot changes. */
|
|
123
|
+
function subscribe(listener: () => void): () => void {
|
|
124
|
+
listeners = [...listeners, listener];
|
|
125
|
+
return () => {
|
|
126
|
+
listeners = listeners.filter((l) => l !== listener);
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Result shape for the useTheme hook. */
|
|
131
|
+
export interface UseThemeResult {
|
|
132
|
+
/** The user's chosen theme ID. */
|
|
133
|
+
themeId: string;
|
|
134
|
+
/** The actually-applied data-theme value after resolving system preference. */
|
|
135
|
+
resolvedThemeId: string;
|
|
136
|
+
/** Set a new theme by ID. */
|
|
137
|
+
setTheme: (nextId: string) => void;
|
|
138
|
+
/** Whether the theme follows the OS light/dark preference. */
|
|
139
|
+
preferSystem: boolean;
|
|
140
|
+
/** Toggle the OS preference auto-switch behavior. */
|
|
141
|
+
setPreferSystem: (prefer: boolean) => void;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** React hook for reading and setting the application theme. */
|
|
145
|
+
export function useTheme(): UseThemeResult {
|
|
146
|
+
const snapshot = useSyncExternalStore(subscribe, getSnapshot);
|
|
147
|
+
const { themeId, preferSystem } = snapshot;
|
|
148
|
+
|
|
149
|
+
const resolvedThemeId: string = resolveDataTheme(themeId, preferSystem);
|
|
150
|
+
|
|
151
|
+
const setTheme = useCallback((nextId: string) => {
|
|
152
|
+
if (!THEME_IDS.has(nextId)) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
localStorage.setItem(STORAGE_KEY, nextId);
|
|
157
|
+
} catch {
|
|
158
|
+
// localStorage may be unavailable
|
|
159
|
+
}
|
|
160
|
+
applyTheme(nextId, getPreferSystem(), true);
|
|
161
|
+
emitChange();
|
|
162
|
+
}, []);
|
|
163
|
+
|
|
164
|
+
const setPreferSystem = useCallback((prefer: boolean) => {
|
|
165
|
+
try {
|
|
166
|
+
localStorage.setItem(PREFER_SYSTEM_KEY, prefer ? "true" : "false");
|
|
167
|
+
} catch {
|
|
168
|
+
// localStorage may be unavailable
|
|
169
|
+
}
|
|
170
|
+
// When enabling preferSystem, convert variant ID to parent ID
|
|
171
|
+
if (prefer) {
|
|
172
|
+
const stored = getStored();
|
|
173
|
+
const def = getThemeById(stored);
|
|
174
|
+
if (def?.hidden) {
|
|
175
|
+
const parent = findParentTheme(stored);
|
|
176
|
+
if (parent) {
|
|
177
|
+
try {
|
|
178
|
+
localStorage.setItem(STORAGE_KEY, parent.id);
|
|
179
|
+
} catch {
|
|
180
|
+
// localStorage may be unavailable
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
applyTheme(getStored(), prefer, true);
|
|
186
|
+
emitChange();
|
|
187
|
+
}, []);
|
|
188
|
+
|
|
189
|
+
// Keep DOM in sync on mount/change
|
|
190
|
+
useEffect(() => {
|
|
191
|
+
applyTheme(themeId, preferSystem);
|
|
192
|
+
}, [themeId, preferSystem]);
|
|
193
|
+
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
if (typeof window === "undefined") {
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const mediaQueryList: MediaQueryList = window.matchMedia(MEDIA_QUERY);
|
|
200
|
+
const handleChange = (): void => {
|
|
201
|
+
const stored: string = getStored();
|
|
202
|
+
const prefer: boolean = getPreferSystem();
|
|
203
|
+
if (prefer) {
|
|
204
|
+
const def = getThemeById(stored);
|
|
205
|
+
// Parent theme with variants
|
|
206
|
+
if (def?.variantDarkId && def.variantLightId) {
|
|
207
|
+
applyTheme(stored, prefer);
|
|
208
|
+
}
|
|
209
|
+
// Concrete variant — resolve via parent
|
|
210
|
+
if (def?.hidden) {
|
|
211
|
+
const parent = findParentTheme(stored);
|
|
212
|
+
if (parent?.variantDarkId && parent.variantLightId) {
|
|
213
|
+
applyTheme(stored, prefer);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
emitChange();
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
mediaQueryList.addEventListener("change", handleChange);
|
|
221
|
+
|
|
222
|
+
return () => {
|
|
223
|
+
mediaQueryList.removeEventListener("change", handleChange);
|
|
224
|
+
};
|
|
225
|
+
}, []);
|
|
226
|
+
|
|
227
|
+
return { themeId, setTheme, resolvedThemeId, preferSystem, setPreferSystem };
|
|
228
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @grackle-ai/web-components — Presentational React component library.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// ─── Components ──────────────────────────────────────────────────────────────
|
|
8
|
+
|
|
9
|
+
// Chat
|
|
10
|
+
export { ChatInput } from "./components/chat/index.js";
|
|
11
|
+
export type { ChatInputProps } from "./components/chat/index.js";
|
|
12
|
+
|
|
13
|
+
// DAG visualization
|
|
14
|
+
export { DagView } from "./components/dag/DagView.js";
|
|
15
|
+
export { TaskNode } from "./components/dag/TaskNode.js";
|
|
16
|
+
export { useDagLayout } from "./components/dag/useDagLayout.js";
|
|
17
|
+
|
|
18
|
+
// Display primitives
|
|
19
|
+
export {
|
|
20
|
+
Breadcrumbs, Button, CopyButton, DemoBanner, SplitButton,
|
|
21
|
+
EventRenderer, ConfirmDialog, Skeleton, SkeletonText, SkeletonCard,
|
|
22
|
+
Spinner, SplashScreen, Tooltip,
|
|
23
|
+
} from "./components/display/index.js";
|
|
24
|
+
export type { ButtonProps, ButtonVariant, ButtonSize } from "./components/display/index.js";
|
|
25
|
+
export type { TooltipProps, TooltipPlacement } from "./components/display/index.js";
|
|
26
|
+
export { EventStream } from "./components/display/EventStream.js";
|
|
27
|
+
export { EventHoverRow } from "./components/display/EventHoverRow.js";
|
|
28
|
+
export type { EventHoverRowProps } from "./components/display/EventHoverRow.js";
|
|
29
|
+
export { FloatingActionBar } from "./components/display/FloatingActionBar.js";
|
|
30
|
+
export type { FloatingActionBarProps } from "./components/display/FloatingActionBar.js";
|
|
31
|
+
export { SessionAttemptSelector } from "./components/display/SessionAttemptSelector.js";
|
|
32
|
+
export type { SessionAttemptSelectorProps } from "./components/display/SessionAttemptSelector.js";
|
|
33
|
+
export { SessionPicker } from "./components/display/SessionPicker.js";
|
|
34
|
+
export type { SessionPickerProps, SessionPickerEntry } from "./components/display/SessionPicker.js";
|
|
35
|
+
|
|
36
|
+
// Editable fields
|
|
37
|
+
export {
|
|
38
|
+
EditableTextField, EditableTextArea, EditableSelect,
|
|
39
|
+
EditableCheckbox, EnvironmentSelect, useEditableField,
|
|
40
|
+
} from "./components/editable/index.js";
|
|
41
|
+
export type {
|
|
42
|
+
EditableTextFieldProps, EditableTextAreaProps,
|
|
43
|
+
EditableSelectProps, SelectOption,
|
|
44
|
+
EditableCheckboxProps, EnvironmentSelectProps,
|
|
45
|
+
UseEditableFieldOptions, UseEditableFieldReturn,
|
|
46
|
+
} from "./components/editable/index.js";
|
|
47
|
+
|
|
48
|
+
// Knowledge graph
|
|
49
|
+
export { KnowledgeGraph, KnowledgeDetailPanel, KnowledgeNav } from "./components/knowledge/index.js";
|
|
50
|
+
|
|
51
|
+
// Layout
|
|
52
|
+
export { StatusBar, AppNav, Sidebar, BottomStatusBar, TABS } from "./components/layout/index.js";
|
|
53
|
+
export type { AppTab } from "./components/layout/index.js";
|
|
54
|
+
|
|
55
|
+
// Lists
|
|
56
|
+
export { EnvironmentNav, FindingsNav } from "./components/lists/index.js";
|
|
57
|
+
export { TaskList } from "./components/lists/TaskList.js";
|
|
58
|
+
export { HighlightedText, buildTaskTree, groupTasksByStatus } from "./components/lists/listHelpers.js";
|
|
59
|
+
|
|
60
|
+
// Notifications
|
|
61
|
+
export { Toast, ToastContainer, Callout } from "./components/notifications/index.js";
|
|
62
|
+
export type { CalloutVariant } from "./components/notifications/index.js";
|
|
63
|
+
export { UpdateBanner } from "./components/notifications/UpdateBanner.js";
|
|
64
|
+
|
|
65
|
+
// Panels
|
|
66
|
+
export { FindingsPanel, TokensPanel, AppearancePanel, AboutPanel, TaskEditPanel, TaskActionButtons, TaskOverviewPanel, PluginsPanel } from "./components/panels/index.js";
|
|
67
|
+
export type { PluginsPanelProps } from "./components/panels/index.js";
|
|
68
|
+
export type { TaskActionButtonsProps } from "./components/panels/TaskActionButtons.js";
|
|
69
|
+
export type { TaskOverviewPanelProps } from "./components/panels/TaskOverviewPanel.js";
|
|
70
|
+
export { EnvironmentEditPanel } from "./components/panels/EnvironmentEditPanel.js";
|
|
71
|
+
export { KeyboardShortcutsPanel } from "./components/panels/KeyboardShortcutsPanel.js";
|
|
72
|
+
export { WorkpadPanel } from "./components/panels/WorkpadPanel.js";
|
|
73
|
+
export { CredentialProvidersPanel } from "./components/panels/CredentialProvidersPanel.js";
|
|
74
|
+
|
|
75
|
+
// Personas
|
|
76
|
+
export { PersonaManager } from "./components/personas/PersonaManager.js";
|
|
77
|
+
export { McpToolSelector } from "./components/personas/McpToolSelector.js";
|
|
78
|
+
export type { PersonaManagerProps } from "./components/personas/PersonaManager.js";
|
|
79
|
+
|
|
80
|
+
// Schedules
|
|
81
|
+
export { ScheduleManager } from "./components/schedules/ScheduleManager.js";
|
|
82
|
+
export type { ScheduleManagerProps } from "./components/schedules/ScheduleManager.js";
|
|
83
|
+
|
|
84
|
+
// Settings
|
|
85
|
+
export { SettingsNav } from "./components/settings/SettingsNav.js";
|
|
86
|
+
|
|
87
|
+
// Streams
|
|
88
|
+
export { StreamList, StreamDetailPanel } from "./components/streams/index.js";
|
|
89
|
+
export type { StreamListProps, StreamDetailPanelProps } from "./components/streams/index.js";
|
|
90
|
+
|
|
91
|
+
// Tools
|
|
92
|
+
export { ToolCard } from "./components/tools/ToolCard.js";
|
|
93
|
+
export { FileEditCard } from "./components/tools/FileEditCard.js";
|
|
94
|
+
export { FileReadCard } from "./components/tools/FileReadCard.js";
|
|
95
|
+
export { ShellCard } from "./components/tools/ShellCard.js";
|
|
96
|
+
export { SearchCard } from "./components/tools/SearchCard.js";
|
|
97
|
+
export { TodoCard } from "./components/tools/TodoCard.js";
|
|
98
|
+
export { MetadataCard } from "./components/tools/MetadataCard.js";
|
|
99
|
+
export { GenericToolCard } from "./components/tools/GenericToolCard.js";
|
|
100
|
+
export { AgentToolCard } from "./components/tools/AgentToolCard.js";
|
|
101
|
+
export { classifyTool } from "./components/tools/classifyTool.js";
|
|
102
|
+
export { parseUnifiedDiff, diffFromOldNew, diffStats } from "./components/tools/parseDiff.js";
|
|
103
|
+
export type { DiffLine, DiffStats } from "./components/tools/parseDiff.js";
|
|
104
|
+
export { parseShellOutput } from "./components/tools/parseShellOutput.js";
|
|
105
|
+
|
|
106
|
+
// Workspace
|
|
107
|
+
export { WorkspaceBoard } from "./components/workspace/WorkspaceBoard.js";
|
|
108
|
+
export { WorkspaceFormFields, defaultFormValues } from "./components/workspace/WorkspaceFormFields.js";
|
|
109
|
+
export type { WorkspaceFormValues } from "./components/workspace/WorkspaceFormFields.js";
|
|
110
|
+
|
|
111
|
+
// ─── Contexts ────────────────────────────────────────────────────────────────
|
|
112
|
+
|
|
113
|
+
export { ToastProvider, useToast } from "./context/ToastContext.js";
|
|
114
|
+
export type { ToastItem, ToastVariant } from "./context/ToastContext.js";
|
|
115
|
+
|
|
116
|
+
export { ThemeProvider, useThemeContext } from "./context/ThemeContext.js";
|
|
117
|
+
|
|
118
|
+
export { SidebarProvider, useSidebarContent, useSidebarSetter } from "./context/SidebarContext.js";
|
|
119
|
+
|
|
120
|
+
export { GrackleContext, useGrackle } from "./context/GrackleContext.js";
|
|
121
|
+
export type { UseGrackleSocketResult, GrackleContextType } from "./context/GrackleContext.js";
|
|
122
|
+
|
|
123
|
+
// ─── Types ───────────────────────────────────────────────────────────────────
|
|
124
|
+
|
|
125
|
+
export type {
|
|
126
|
+
Environment, Session, UsageStats, SessionEvent,
|
|
127
|
+
Workspace, TaskData, FindingData, TokenInfo,
|
|
128
|
+
CredentialProviderConfig, Codespace, PersonaData,
|
|
129
|
+
ScheduleData, ScheduleUpdate, UseSchedulesResult,
|
|
130
|
+
ProvisionStatus, GrackleEvent, WsMessage, SendFunction,
|
|
131
|
+
GraphNode, GraphLink, NodeDetail, UseKnowledgeResult,
|
|
132
|
+
UseEnvironmentsResult, UseSessionsResult, UseWorkspacesResult,
|
|
133
|
+
UseTasksResult, UseFindingsResult, UseTokensResult,
|
|
134
|
+
UseCredentialsResult, UseCodespacesResult, UsePersonasResult,
|
|
135
|
+
UsePluginsResult, PluginData,
|
|
136
|
+
StreamData, StreamSubscriberData, UseStreamsResult,
|
|
137
|
+
DomainHook,
|
|
138
|
+
ConnectionStatus,
|
|
139
|
+
} from "./hooks/types.js";
|
|
140
|
+
export {
|
|
141
|
+
isObject, warnBadPayload, isGrackleEvent, isSessionEvent,
|
|
142
|
+
isCredentialProviderConfig, parseWsMessage,
|
|
143
|
+
mapSessionStatus, mapEndReason,
|
|
144
|
+
WS_RECONNECT_DELAY_MS, MAX_EVENTS, WS_CLOSE_UNAUTHORIZED,
|
|
145
|
+
} from "./hooks/types.js";
|
|
146
|
+
|
|
147
|
+
// ─── Hooks ───────────────────────────────────────────────────────────────────
|
|
148
|
+
|
|
149
|
+
export { useSmartScroll } from "./hooks/useSmartScroll.js";
|
|
150
|
+
export { useEventSelection } from "./hooks/useEventSelection.js";
|
|
151
|
+
export type { UseEventSelectionOptions, UseEventSelectionReturn } from "./hooks/useEventSelection.js";
|
|
152
|
+
|
|
153
|
+
// ─── Utilities ───────────────────────────────────────────────────────────────
|
|
154
|
+
|
|
155
|
+
export {
|
|
156
|
+
useAppNavigate, sessionUrl, workspaceUrl, taskUrl, taskEditUrl,
|
|
157
|
+
newTaskUrl, newChatUrl, ENVIRONMENTS_URL, NEW_ENVIRONMENT_URL,
|
|
158
|
+
environmentUrl, environmentEditUrl, SETTINGS_URL,
|
|
159
|
+
SETTINGS_ENVIRONMENTS_URL, SETTINGS_CREDENTIALS_URL,
|
|
160
|
+
PERSONAS_URL, NEW_PERSONA_URL, personaUrl,
|
|
161
|
+
SCHEDULES_URL, NEW_SCHEDULE_URL, scheduleUrl,
|
|
162
|
+
SETTINGS_APPEARANCE_URL, SETTINGS_ABOUT_URL, SETTINGS_SHORTCUTS_URL,
|
|
163
|
+
PAIR_PATH, NEW_WORKSPACE_URL, KNOWLEDGE_URL, HOME_URL,
|
|
164
|
+
FINDINGS_URL, findingsUrl, findingUrl,
|
|
165
|
+
CHAT_URL, chatStreamUrl, TASKS_URL,
|
|
166
|
+
} from "./utils/navigation.js";
|
|
167
|
+
|
|
168
|
+
export {
|
|
169
|
+
TASK_STATUS_STYLES, getStatusStyle, STATUS_BADGE_CLASS_MAP,
|
|
170
|
+
getStatusBadgeClassKey, SIDEBAR_STATUS_ORDER, BOARD_COLUMN_ORDER,
|
|
171
|
+
resolveStatus, STATUS_CSS_VAR_MAP,
|
|
172
|
+
} from "./utils/taskStatus.js";
|
|
173
|
+
export type { TaskStatusKey, VirtualStatus, DisplayStatus, TaskStatusStyle } from "./utils/taskStatus.js";
|
|
174
|
+
|
|
175
|
+
export { formatTokens, formatCost } from "./utils/format.js";
|
|
176
|
+
export { formatRelativeTime, formatCountdown } from "./utils/time.js";
|
|
177
|
+
export { CATEGORY_COLORS, getCategoryColor } from "./utils/findingCategory.js";
|
|
178
|
+
export type { CategoryColor } from "./utils/findingCategory.js";
|
|
179
|
+
|
|
180
|
+
export type { BreadcrumbSegment } from "./utils/breadcrumbs.js";
|
|
181
|
+
export {
|
|
182
|
+
buildTaskAncestorChain, buildHomeBreadcrumbs, buildSettingsBreadcrumbs,
|
|
183
|
+
buildEnvironmentsBreadcrumbs, buildNewEnvironmentBreadcrumbs,
|
|
184
|
+
buildNewChatBreadcrumbs, buildSessionBreadcrumbs,
|
|
185
|
+
buildWorkspaceBreadcrumbs, buildTaskBreadcrumbs, buildNewTaskBreadcrumbs,
|
|
186
|
+
buildFindingsBreadcrumbs, buildFindingBreadcrumbs,
|
|
187
|
+
} from "./utils/breadcrumbs.js";
|
|
188
|
+
|
|
189
|
+
export { groupConsecutiveTextEvents, pairToolEvents } from "./utils/sessionEvents.js";
|
|
190
|
+
export type { DisplayEvent } from "./utils/sessionEvents.js";
|
|
191
|
+
|
|
192
|
+
export { isContentBearingEvent, getEventCopyText, formatEventsAsMarkdown, formatForwardEnvelope } from "./utils/eventContent.js";
|
|
193
|
+
|
|
194
|
+
export type { BoardColumn, BoardTask } from "./utils/boardColumns.js";
|
|
195
|
+
export { buildBoardColumns } from "./utils/boardColumns.js";
|
|
196
|
+
|
|
197
|
+
export type { DashboardKpis, AttentionTask, ActiveSession, WorkspaceSnapshot } from "./utils/dashboard.js";
|
|
198
|
+
export { computeKpis, getAttentionTasks, getActiveSessions, getWorkspaceSnapshots } from "./utils/dashboard.js";
|
|
199
|
+
|
|
200
|
+
export { isNearAnchor, computeScrollCompensation, SCROLL_ANCHOR_THRESHOLD_PX } from "./utils/scrollUtils.js";
|
|
201
|
+
|
|
202
|
+
// ─── Themes ──────────────────────────────────────────────────────────────────
|
|
203
|
+
|
|
204
|
+
export { THEMES, THEME_IDS, DEFAULT_THEME_ID, getThemeById } from "./themes.js";
|
|
205
|
+
export type { ThemeDefinition } from "./themes.js";
|
|
206
|
+
|
|
207
|
+
// ─── Mocks & Test Utilities ─────────────────────────────────────────────────
|
|
208
|
+
|
|
209
|
+
export { MockGrackleProvider } from "./mocks/MockGrackleProvider.js";
|
|
210
|
+
export { withMockGrackle, withMockGrackleRoute, makePersona, makeSchedule } from "./test-utils/storybook-helpers.js";
|