@cognizant-ai-lab/ui-common 1.3.3 → 1.4.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/README.md +287 -0
- package/dist/Theme/Palettes.d.ts +18 -0
- package/dist/Theme/Palettes.js +94 -0
- package/dist/Theme/Theme.d.ts +22 -0
- package/dist/Theme/Theme.js +58 -0
- package/dist/components/AgentChat/ChatCommon.d.ts +4 -2
- package/dist/components/AgentChat/ChatCommon.js +141 -105
- package/dist/components/AgentChat/ControlButtons.js +3 -1
- package/dist/components/AgentChat/FormattedMarkdown.d.ts +4 -4
- package/dist/components/AgentChat/FormattedMarkdown.js +5 -7
- package/dist/components/AgentChat/LlmChatButton.d.ts +2 -6
- package/dist/components/AgentChat/LlmChatButton.js +3 -3
- package/dist/components/AgentChat/UserQueryDisplay.js +2 -4
- package/dist/components/AgentChat/Utils.d.ts +2 -1
- package/dist/components/AgentChat/Utils.js +4 -1
- package/dist/components/AgentChat/VoiceChat/MicrophoneButton.d.ts +2 -2
- package/dist/components/AgentChat/VoiceChat/VoiceChat.d.ts +3 -3
- package/dist/components/AgentChat/VoiceChat/VoiceChat.js +5 -5
- package/dist/components/ChatBot/ChatBot.js +2 -2
- package/dist/components/Common/Breadcrumbs.js +1 -1
- package/dist/components/Common/{confirmationModal.js → ConfirmationModal.js} +2 -5
- package/dist/components/Common/CustomerLogo.d.ts +17 -0
- package/dist/components/Common/CustomerLogo.js +49 -0
- package/dist/components/Common/Footer.d.ts +18 -0
- package/dist/components/Common/Footer.js +59 -0
- package/dist/components/Common/LlmChatOptionsButton.d.ts +1 -4
- package/dist/components/Common/LlmChatOptionsButton.js +4 -4
- package/dist/components/Common/LoadingSpinner.js +1 -1
- package/dist/components/Common/MUIAccordion.d.ts +2 -2
- package/dist/components/Common/MUIAccordion.js +2 -12
- package/dist/components/Common/MUIAlert.d.ts +2 -1
- package/dist/components/Common/MUIAlert.js +4 -1
- package/dist/components/Common/MUIDialog.d.ts +1 -1
- package/dist/components/Common/MUIDialog.js +1 -1
- package/dist/components/Common/Navbar.d.ts +3 -1
- package/dist/components/Common/Navbar.js +60 -35
- package/dist/components/Common/PageLoader.js +3 -4
- package/dist/components/Common/Snackbar.d.ts +4 -1
- package/dist/components/Common/Snackbar.js +11 -19
- package/dist/components/Common/notification.d.ts +3 -3
- package/dist/components/Common/notification.js +6 -6
- package/dist/components/ErrorPage/ErrorBoundary.d.ts +2 -2
- package/dist/components/ErrorPage/ErrorBoundary.js +1 -1
- package/dist/components/ErrorPage/ErrorPage.js +6 -5
- package/dist/components/MultiAgentAccelerator/AgentConversations.d.ts +17 -0
- package/dist/components/MultiAgentAccelerator/AgentConversations.js +77 -0
- package/dist/components/MultiAgentAccelerator/AgentCounts.d.ts +12 -0
- package/dist/components/MultiAgentAccelerator/AgentCounts.js +21 -0
- package/dist/components/MultiAgentAccelerator/AgentFlow.d.ts +6 -4
- package/dist/components/MultiAgentAccelerator/AgentFlow.js +106 -185
- package/dist/components/MultiAgentAccelerator/AgentNode.d.ts +7 -5
- package/dist/components/MultiAgentAccelerator/AgentNode.js +93 -50
- package/dist/components/MultiAgentAccelerator/GraphLayouts.d.ts +20 -17
- package/dist/components/MultiAgentAccelerator/GraphLayouts.js +16 -14
- package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.d.ts +2 -3
- package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.js +214 -55
- package/dist/components/MultiAgentAccelerator/PlasmaEdge.d.ts +1 -1
- package/dist/components/MultiAgentAccelerator/PlasmaEdge.js +14 -12
- package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.d.ts +15 -0
- package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.js +104 -0
- package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.d.ts +17 -0
- package/dist/components/MultiAgentAccelerator/{Sidebar.js → Sidebar/Sidebar.js} +146 -59
- package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.d.ts +19 -0
- package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.js +113 -0
- package/dist/components/MultiAgentAccelerator/TemporaryNetworks.d.ts +26 -0
- package/dist/components/MultiAgentAccelerator/TemporaryNetworks.js +20 -0
- package/dist/components/MultiAgentAccelerator/ThoughtBubbleEdge.d.ts +10 -8
- package/dist/components/MultiAgentAccelerator/ThoughtBubbleEdge.js +1 -1
- package/dist/components/MultiAgentAccelerator/ThoughtBubbleOverlay.d.ts +3 -2
- package/dist/components/MultiAgentAccelerator/ThoughtBubbleOverlay.js +10 -13
- package/dist/components/MultiAgentAccelerator/const.d.ts +1 -3
- package/dist/components/MultiAgentAccelerator/const.js +4 -18
- package/dist/components/Settings/FadingCheckmark.d.ts +14 -0
- package/dist/components/Settings/FadingCheckmark.js +43 -0
- package/dist/components/Settings/SettingsDialog.d.ts +9 -0
- package/dist/components/Settings/SettingsDialog.js +265 -0
- package/dist/const.d.ts +1 -2
- package/dist/const.js +2 -3
- package/dist/controller/Types/AgentIconSuggestions.d.ts +4 -0
- package/dist/controller/Types/AgentIconSuggestions.js +1 -0
- package/dist/controller/Types/Branding.d.ts +12 -0
- package/dist/controller/Types/Branding.js +1 -0
- package/dist/controller/Types/NetworkIconSuggestions.d.ts +4 -0
- package/dist/controller/Types/NetworkIconSuggestions.js +1 -0
- package/dist/controller/agent/Agent.d.ts +32 -12
- package/dist/controller/agent/Agent.js +71 -19
- package/dist/controller/llm/LlmChat.d.ts +1 -1
- package/dist/controller/llm/LlmChat.js +2 -2
- package/dist/index.d.ts +10 -5
- package/dist/index.js +10 -5
- package/dist/state/{environment.d.ts → Environment.d.ts} +2 -0
- package/dist/state/{environment.js → Environment.js} +2 -0
- package/dist/state/Settings.d.ts +62 -0
- package/dist/state/Settings.js +62 -0
- package/dist/state/TemporaryNetworks.d.ts +32 -0
- package/dist/state/TemporaryNetworks.js +26 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/Authentication.d.ts +2 -2
- package/dist/utils/Authentication.js +6 -6
- package/dist/utils/text.d.ts +2 -2
- package/dist/utils/text.js +3 -5
- package/dist/utils/title.d.ts +1 -1
- package/dist/utils/title.js +2 -2
- package/dist/utils/useLocalStorage.d.ts +1 -1
- package/dist/utils/useLocalStorage.js +3 -3
- package/dist/utils/zIndexLayers.d.ts +1 -1
- package/dist/utils/zIndexLayers.js +3 -15
- package/package.json +23 -21
- package/dist/components/MultiAgentAccelerator/Sidebar.d.ts +0 -12
- package/dist/utils/Theme.d.ts +0 -7
- package/dist/utils/Theme.js +0 -7
- package/dist/utils/agentConversations.d.ts +0 -24
- package/dist/utils/agentConversations.js +0 -113
- /package/dist/components/Common/{confirmationModal.d.ts → ConfirmationModal.d.ts} +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
# @cognizant-ai-lab/ui-common
|
|
2
|
+
|
|
3
|
+
A comprehensive React component library and utilities package for building user interfaces for Neuro-san AI
|
|
4
|
+
applications. Contains components for chat interfaces, multi-agent flow visualization, theming and more.
|
|
5
|
+
|
|
6
|
+
## Copyright
|
|
7
|
+
|
|
8
|
+
Copyright 2026 Cognizant Technology Solutions Corp, www.cognizant.com.
|
|
9
|
+
|
|
10
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
you may not use this file except in compliance with the License.
|
|
12
|
+
You may obtain a copy of the License at
|
|
13
|
+
|
|
14
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
|
|
16
|
+
Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
See the License for the specific language governing permissions and
|
|
20
|
+
limitations under the License.
|
|
21
|
+
|
|
22
|
+
## Quickstart
|
|
23
|
+
|
|
24
|
+
For this quickstart, we'll show how to use the `MultiAgentAccelerator` component, which is a demo application
|
|
25
|
+
showcasing the components in this package.
|
|
26
|
+
|
|
27
|
+
You will need access to a Neuro-san API backend to use the components in this package.
|
|
28
|
+
|
|
29
|
+
If you don't already have a ReactJS application, create one, for example, using [Create React App](https://create-react-app.dev/):
|
|
30
|
+
The following assumes you're using TypeScript (recommended):
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npx create-react-app my-app --template typescript
|
|
34
|
+
cd my-app
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Install the library:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install @cognizant-ai-lab/ui-common
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Then edit `src/App.tsx` (assuming TypeScript) and replace the contents with the code below:
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
export default function MyApp() {
|
|
47
|
+
return (
|
|
48
|
+
<MultiAgentAccelerator
|
|
49
|
+
userInfo={{userName: "Alice", userImage: "https://example.com/alice.png"}}
|
|
50
|
+
backendNeuroSanApiUrl="https://my-neuro-san-api.example.com"
|
|
51
|
+
/>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Run your app with `npm start` or `yarn start`, and you should see the Multi-Agent Accelerator interface,
|
|
57
|
+
which is a demo application showcasing the components in this package. You can select an agent, chat with that agent
|
|
58
|
+
via the chat interface, and visualize the agent network flow.
|
|
59
|
+
|
|
60
|
+
## Features
|
|
61
|
+
|
|
62
|
+
- **UI Components**: Ready-to-use React components for AI chat interfaces, navigation, dialogs, and more
|
|
63
|
+
- **Multi-Agent Visualization**: Interactive flow diagrams for visualizing agent networks
|
|
64
|
+
- **Authentication**: Built-in authentication components supporting multiple providers
|
|
65
|
+
- **State Management**: Zustand-based stores for environment, settings, and user info
|
|
66
|
+
- **Theme Support**: Dark mode support with customizable, MUI-based theming
|
|
67
|
+
- **Type Safety**: Full TypeScript support with generated OpenAPI types
|
|
68
|
+
- **LLM Integration**: Controllers for interacting with language models and AI agents
|
|
69
|
+
|
|
70
|
+
## Technologies Used
|
|
71
|
+
|
|
72
|
+
Among the technologies and libraries used in this package are:
|
|
73
|
+
|
|
74
|
+
- ESLint and Prettier (for code quality)
|
|
75
|
+
- Jest and React Testing Library (for testing)
|
|
76
|
+
- MUI
|
|
77
|
+
- next-auth (for authentication)
|
|
78
|
+
- React
|
|
79
|
+
- React Flow (for multi-agent visualization)
|
|
80
|
+
- TypeScript
|
|
81
|
+
- Zustand
|
|
82
|
+
|
|
83
|
+
## Package Structure
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
ui-common/
|
|
87
|
+
├── components/ # React components
|
|
88
|
+
│ ├── AgentChat/ # Chat interface components
|
|
89
|
+
│ ├── Authentication/ # Auth components
|
|
90
|
+
│ ├── ChatBot/ # ChatBot components
|
|
91
|
+
│ ├── Common/ # Common UI components (dialogs, navbar, etc.)
|
|
92
|
+
│ ├── ErrorPage/ # Error handling components
|
|
93
|
+
│ ├── MultiAgentAccelerator/ # Agent flow visualization
|
|
94
|
+
│ └── Settings/ # Settings dialog components
|
|
95
|
+
├── controller/ # Backend interaction controllers
|
|
96
|
+
│ ├── agent/ # Agent API controllers
|
|
97
|
+
│ └── llm/ # LLM interaction controllers
|
|
98
|
+
├── state/ # Zustand state stores
|
|
99
|
+
├── Theme/ # Theming utilities
|
|
100
|
+
├── utils/ # Utility functions
|
|
101
|
+
└── generated/ # Auto-generated API types
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Usage
|
|
105
|
+
|
|
106
|
+
#### Example application
|
|
107
|
+
|
|
108
|
+
Refer to [MAUI](https://github.com/cognizant-ai-lab/neuro-san-ui/tree/main/apps/main), the Multi-Agent Accelerator UI,
|
|
109
|
+
for a real-world application example that uses these components.
|
|
110
|
+
|
|
111
|
+
### Basic Import
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import {ChatCommon, Navbar, MUIDialog, LoadingSpinner, useEnvironment, useUserInfo} from "@cognizant-ai-lab/ui-common"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Using Components
|
|
118
|
+
|
|
119
|
+
#### ChatCommon
|
|
120
|
+
|
|
121
|
+
See `ChatCommonProps` for all available props and their types. Here's a basic example of how to use the `ChatCommon`
|
|
122
|
+
component in a React application:
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
import {ChatCommon} from "@cognizant-ai-lab/ui-common"
|
|
126
|
+
import {AIMessage, HumanMessage} from "@langchain/core/messages"
|
|
127
|
+
import {useState} from "react"
|
|
128
|
+
|
|
129
|
+
function ChatInterface() {
|
|
130
|
+
const [isAwaitingLlm, setIsAwaitingLlm] = useState(false)
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<ChatCommon
|
|
134
|
+
id="agent-network-ui"
|
|
135
|
+
ref={chatRef} // If you need to access internal methods, like calling "Stop" when user clicks stop
|
|
136
|
+
neuroSanURL={neuroSanURL} // Base URL for Neuro-san API. Must point to a valid Neuro-san server
|
|
137
|
+
currentUser="Alice" // Current user's name, used for chat attribution in API calls and display
|
|
138
|
+
setIsAwaitingLlm={setIsAwaitingLlm} // Used to set whether we're currently waiting for an LLM response,
|
|
139
|
+
// which can be used to disable input and show loading states
|
|
140
|
+
isAwaitingLlm={isAwaitingLlm} // Used to indicate whether we're currently waiting for an LLM response
|
|
141
|
+
targetAgent={selectedNetwork} // The agent we're currently chatting with in Neuro-san.
|
|
142
|
+
onChunkReceived={onChunkReceived} // Callback function that will be called with each new chunk of response
|
|
143
|
+
// from the LLM. You can use this to update your UI in real time
|
|
144
|
+
// as the response comes in.
|
|
145
|
+
/>
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Using Controllers
|
|
151
|
+
|
|
152
|
+
#### Test Agent Connection
|
|
153
|
+
|
|
154
|
+
Used for testing connectivity to a Neuro-san server and retrieving version information.
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
import {testConnection} from "@cognizant-ai-lab/ui-common"
|
|
158
|
+
|
|
159
|
+
async function checkServer() {
|
|
160
|
+
const result = await testConnection("https://api.example.com")
|
|
161
|
+
|
|
162
|
+
if (result.success) {
|
|
163
|
+
console.log(`Connected! Version: ${result.version}`)
|
|
164
|
+
} else {
|
|
165
|
+
console.error(`Connection failed: ${result.status}`)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Send Chat Query
|
|
171
|
+
|
|
172
|
+
Send a chat query to the Agent LLM API. If you are using `ChatCommon`, you shouldn't need to call this directly.
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
import {sendChatQuery} from "@cognizant-ai-lab/ui-common"
|
|
176
|
+
async function sendMessage() {
|
|
177
|
+
const controller = new AbortController()
|
|
178
|
+
|
|
179
|
+
const response = await sendChatQuery(
|
|
180
|
+
neuroSanURL,
|
|
181
|
+
controller.signal,
|
|
182
|
+
"What is the weather in 90210 today?",
|
|
183
|
+
"weather_agent",
|
|
184
|
+
(chunk) => console.log("Received chunk:", chunk),
|
|
185
|
+
chatContext,
|
|
186
|
+
slyData,
|
|
187
|
+
currentUser
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
#### Send LLM Request
|
|
193
|
+
|
|
194
|
+
Lower-level interface to send chat messages to a designated LLM and stream response tokens to the supplied callback
|
|
195
|
+
function. You should not need to call this directly if you are using `ChatCommon`. It is a lower-level interface than
|
|
196
|
+
`sendChatQuery` and is used by that function under the hood. This function can also be used to send messages to
|
|
197
|
+
"legacy" agents, which are not built using the Agent API but still accept chat messages via the LLM API.
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
import {sendLlmRequest} from "@cognizant-ai-lab/ui-common"
|
|
201
|
+
import {HumanMessage} from "@langchain/core/messages"
|
|
202
|
+
|
|
203
|
+
async function chatWithAgent() {
|
|
204
|
+
const controller = new AbortController()
|
|
205
|
+
|
|
206
|
+
await sendLlmRequest(
|
|
207
|
+
(token) => console.log("Received:", token),
|
|
208
|
+
controller.signal,
|
|
209
|
+
"/api/chat",
|
|
210
|
+
{temperature: 0.7},
|
|
211
|
+
"What is the weather?",
|
|
212
|
+
[new HumanMessage("Hello")],
|
|
213
|
+
"user-123"
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Theme Support
|
|
219
|
+
|
|
220
|
+
The package includes built-in theme support using MUI theming. The components will automatically respond to
|
|
221
|
+
the currently active MUI theme.
|
|
222
|
+
|
|
223
|
+
## Available Components
|
|
224
|
+
|
|
225
|
+
### AgentChat
|
|
226
|
+
|
|
227
|
+
- `ChatCommon` - Main chat interface component
|
|
228
|
+
- `ControlButtons` - Chat control buttons (clear, scroll, etc.)
|
|
229
|
+
- `LlmChatButton` - Button to initiate LLM chat
|
|
230
|
+
- `SendButton` - Message send button
|
|
231
|
+
- `UserQueryDisplay` - Display user queries
|
|
232
|
+
|
|
233
|
+
### Multi-Agent Accelerator
|
|
234
|
+
|
|
235
|
+
- `MultiAgentAccelerator` - Main multi-agent flow component
|
|
236
|
+
- `AgentFlow` - Agent flow visualization
|
|
237
|
+
- `Sidebar` - Agent networks sidebar
|
|
238
|
+
|
|
239
|
+
## API Controllers
|
|
240
|
+
|
|
241
|
+
### Agent Controller
|
|
242
|
+
|
|
243
|
+
Various functions for interacting with the Neuro-san Agent API, such as retrieving lists of
|
|
244
|
+
agent networks and sending chat messages to agents.
|
|
245
|
+
|
|
246
|
+
## TypeScript Support
|
|
247
|
+
|
|
248
|
+
This package is written in TypeScript and includes full type definitions. All components, utilities, and API types are
|
|
249
|
+
exported for use in your TypeScript projects.
|
|
250
|
+
|
|
251
|
+
## Development
|
|
252
|
+
|
|
253
|
+
### Building from Source
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
# Install dependencies
|
|
257
|
+
yarn install
|
|
258
|
+
|
|
259
|
+
# Generate OpenAPI types
|
|
260
|
+
yarn generate
|
|
261
|
+
|
|
262
|
+
# Build the package
|
|
263
|
+
yarn build
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Contributing
|
|
268
|
+
|
|
269
|
+
This package is part of the [Neuro-san UI](https://github.com/cognizant-ai-lab/neuro-san-ui) project.
|
|
270
|
+
Please refer to the main repository [contribution guidelines](https://github.com/cognizant-ai-lab/neuro-san-ui/blob/main/CONTRIBUTING.md).
|
|
271
|
+
|
|
272
|
+
## License
|
|
273
|
+
|
|
274
|
+
Apache License 2.0 - See LICENSE file for details
|
|
275
|
+
|
|
276
|
+
## Support
|
|
277
|
+
|
|
278
|
+
For questions or issues, contact the Cognizant Neuro AI support team at NeuroAiSupport@cognizant.com
|
|
279
|
+
|
|
280
|
+
## Related Projects
|
|
281
|
+
|
|
282
|
+
- [neuro-san](https://github.com/cognizant-ai-lab/neuro-san) - Neuro-san core library
|
|
283
|
+
- [neuro-san-studio](https://github.com/cognizant-ai-lab/neuro-san-studio) - Neuro-san examples and studio
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
For more detailed documentation and examples, visit the [GitHub repository](https://github.com/cognizant-ai-lab/neuro-san-ui).
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const PALETTES: {
|
|
2
|
+
blue: string[];
|
|
3
|
+
red: string[];
|
|
4
|
+
green: string[];
|
|
5
|
+
yellow: string[];
|
|
6
|
+
grayScale: string[];
|
|
7
|
+
coldToHot: string[];
|
|
8
|
+
visionImpaired: string[];
|
|
9
|
+
};
|
|
10
|
+
export type PaletteKey = keyof typeof PALETTES | "brand";
|
|
11
|
+
/**
|
|
12
|
+
* Custom hook to get the current color palette based on user settings.
|
|
13
|
+
* If the user has selected custom branding, it will return the palette for that.
|
|
14
|
+
* Otherwise, it will return one of the predefined palettes from the PALETTES object based on the user's selection.
|
|
15
|
+
*
|
|
16
|
+
* @returns An array of color hex codes representing the current color palette.
|
|
17
|
+
*/
|
|
18
|
+
export declare const usePalette: () => string[];
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Palettes for progressive coloring of nodes based on depth or heatmap value
|
|
2
|
+
import { useSettingsStore } from "../state/Settings.js";
|
|
3
|
+
export const PALETTES = {
|
|
4
|
+
blue: [
|
|
5
|
+
"#f7fbff",
|
|
6
|
+
"#deebf7",
|
|
7
|
+
"#c6dbef",
|
|
8
|
+
"#9ecae1",
|
|
9
|
+
"#6baed6",
|
|
10
|
+
"#4292c6",
|
|
11
|
+
"#2171b5",
|
|
12
|
+
"#08519c",
|
|
13
|
+
"#08306b",
|
|
14
|
+
"#041c45",
|
|
15
|
+
],
|
|
16
|
+
red: ["#fff5f0", "#fee0d2", "#fcbba1", "#fc9272", "#fb6a4a", "#ef3b2c", "#cb181d", "#a50f15", "#67000d", "#3a0007"],
|
|
17
|
+
green: [
|
|
18
|
+
"#ffffe5",
|
|
19
|
+
"#f7fcb9",
|
|
20
|
+
"#d9f0a3",
|
|
21
|
+
"#addd8e",
|
|
22
|
+
"#78c679",
|
|
23
|
+
"#41ab5d",
|
|
24
|
+
"#238443",
|
|
25
|
+
"#006837",
|
|
26
|
+
"#004529",
|
|
27
|
+
"#002a1a",
|
|
28
|
+
],
|
|
29
|
+
yellow: [
|
|
30
|
+
"#ffffe5",
|
|
31
|
+
"#fff7bc",
|
|
32
|
+
"#fee391",
|
|
33
|
+
"#fec44f",
|
|
34
|
+
"#fe9929",
|
|
35
|
+
"#ec7014",
|
|
36
|
+
"#cc4c02",
|
|
37
|
+
"#993404",
|
|
38
|
+
"#662506",
|
|
39
|
+
"#331203",
|
|
40
|
+
],
|
|
41
|
+
grayScale: [
|
|
42
|
+
"#f7f7f7",
|
|
43
|
+
"#e1e1e1",
|
|
44
|
+
"#cfcfcf",
|
|
45
|
+
"#b1b1b1",
|
|
46
|
+
"#9e9e9e",
|
|
47
|
+
"#7e7e7e",
|
|
48
|
+
"#626262",
|
|
49
|
+
"#525252",
|
|
50
|
+
"#252525",
|
|
51
|
+
"#0d0d0d",
|
|
52
|
+
],
|
|
53
|
+
coldToHot: [
|
|
54
|
+
"#313695",
|
|
55
|
+
"#4575b4",
|
|
56
|
+
"#74add1",
|
|
57
|
+
"#abd9e9",
|
|
58
|
+
"#e0f3f8",
|
|
59
|
+
"#fee090",
|
|
60
|
+
"#fdae61",
|
|
61
|
+
"#f46d43",
|
|
62
|
+
"#d73027",
|
|
63
|
+
"#a50026",
|
|
64
|
+
],
|
|
65
|
+
visionImpaired: [
|
|
66
|
+
"#000000",
|
|
67
|
+
"#004949",
|
|
68
|
+
"#009292",
|
|
69
|
+
"#ff6db6",
|
|
70
|
+
"#ffb6db",
|
|
71
|
+
"#490092",
|
|
72
|
+
"#006ddb",
|
|
73
|
+
"#b66dff",
|
|
74
|
+
"#6db6ff",
|
|
75
|
+
"#b6dbff",
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Custom hook to get the current color palette based on user settings.
|
|
80
|
+
* If the user has selected custom branding, it will return the palette for that.
|
|
81
|
+
* Otherwise, it will return one of the predefined palettes from the PALETTES object based on the user's selection.
|
|
82
|
+
*
|
|
83
|
+
* @returns An array of color hex codes representing the current color palette.
|
|
84
|
+
*/
|
|
85
|
+
export const usePalette = () => {
|
|
86
|
+
const brandPalette = useSettingsStore((state) => state.settings.branding.rangePalette);
|
|
87
|
+
const paletteKey = useSettingsStore((state) => state.settings.appearance.rangePalette);
|
|
88
|
+
if (paletteKey === "brand" && brandPalette) {
|
|
89
|
+
return brandPalette;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
return PALETTES[paletteKey];
|
|
93
|
+
}
|
|
94
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper to determine if dark mode is active based on mode and systemMode.
|
|
3
|
+
* @param mode Current mode setting: "light", "dark", or "system"
|
|
4
|
+
* @param systemMode If mode is "system", this indicates the system preference: "light" or "dark"
|
|
5
|
+
* @returns true if dark mode is active, false otherwise
|
|
6
|
+
*/
|
|
7
|
+
export declare const isDarkMode: (mode: "light" | "dark" | "system", systemMode: "light" | "dark") => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Adjusts the brightness of a hex color by a given percentage.
|
|
10
|
+
* @param color - The hex color string (e.g., "#RRGGBB" or "#RGB").
|
|
11
|
+
* @param percent - The percentage to adjust brightness (-100 to 100). Positive values make the color lighter,
|
|
12
|
+
* negative values make it darker.
|
|
13
|
+
* @returns The adjusted hex color string.
|
|
14
|
+
*/
|
|
15
|
+
export declare const adjustBrightness: (color: string, percent: number) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Helper function to determine if a color is light
|
|
18
|
+
*
|
|
19
|
+
* @param color - The hex color string (e.g., "#RRGGBB" or "#RGB")
|
|
20
|
+
* @returns true if the color is light (per luminance calculation), false otherwise
|
|
21
|
+
*/
|
|
22
|
+
export declare const isLightColor: (color: string) => boolean;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper to determine if dark mode is active based on mode and systemMode.
|
|
3
|
+
* @param mode Current mode setting: "light", "dark", or "system"
|
|
4
|
+
* @param systemMode If mode is "system", this indicates the system preference: "light" or "dark"
|
|
5
|
+
* @returns true if dark mode is active, false otherwise
|
|
6
|
+
*/
|
|
7
|
+
export const isDarkMode = (mode, systemMode) => mode === "dark" || (mode === "system" && systemMode === "dark");
|
|
8
|
+
/**
|
|
9
|
+
* Expands 3-character hex colors to 6 characters.
|
|
10
|
+
* @param color - The hex color string (e.g., "#RGB" or "#RRGGBB")
|
|
11
|
+
* @returns The expanded hex color string (e.g., "#RRGGBB")
|
|
12
|
+
*/
|
|
13
|
+
const expandHexColor = (color) => {
|
|
14
|
+
if (color.length === 4 && color.startsWith("#")) {
|
|
15
|
+
return `#${color[1]}${color[1]}${color[2]}${color[2]}${color[3]}${color[3]}`;
|
|
16
|
+
}
|
|
17
|
+
return color;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Adjusts the brightness of a hex color by a given percentage.
|
|
21
|
+
* @param color - The hex color string (e.g., "#RRGGBB" or "#RGB").
|
|
22
|
+
* @param percent - The percentage to adjust brightness (-100 to 100). Positive values make the color lighter,
|
|
23
|
+
* negative values make it darker.
|
|
24
|
+
* @returns The adjusted hex color string.
|
|
25
|
+
*/
|
|
26
|
+
export const adjustBrightness = (color, percent) => {
|
|
27
|
+
if (!color?.startsWith("#") || (color?.length !== 7 && color?.length !== 4)) {
|
|
28
|
+
// Return original color if not in expected format
|
|
29
|
+
return color;
|
|
30
|
+
}
|
|
31
|
+
const hexColor = expandHexColor(color);
|
|
32
|
+
const num = parseInt(hexColor.replace("#", ""), 16);
|
|
33
|
+
const amt = Math.round(2.55 * percent);
|
|
34
|
+
const R = Math.min(255, Math.max(0, (num >> 16) + amt));
|
|
35
|
+
const G = Math.min(255, Math.max(0, ((num >> 8) & 0x00ff) + amt));
|
|
36
|
+
const B = Math.min(255, Math.max(0, (num & 0x0000ff) + amt));
|
|
37
|
+
return `#${((1 << 24) + (R << 16) + (G << 8) + B).toString(16).slice(1)}`;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Helper function to determine if a color is light
|
|
41
|
+
*
|
|
42
|
+
* @param color - The hex color string (e.g., "#RRGGBB" or "#RGB")
|
|
43
|
+
* @returns true if the color is light (per luminance calculation), false otherwise
|
|
44
|
+
*/
|
|
45
|
+
export const isLightColor = (color) => {
|
|
46
|
+
// Expand 3-character hex to 6-character hex if needed.
|
|
47
|
+
const hexColor = expandHexColor(color);
|
|
48
|
+
// Remove # if present
|
|
49
|
+
const colorWithoutHash = hexColor.replace("#", "");
|
|
50
|
+
// Convert to RGB
|
|
51
|
+
const r = parseInt(colorWithoutHash.substring(0, 2), 16);
|
|
52
|
+
const g = parseInt(colorWithoutHash.substring(2, 4), 16);
|
|
53
|
+
const b = parseInt(colorWithoutHash.substring(4, 6), 16);
|
|
54
|
+
// Calculate relative luminance (perceived brightness)
|
|
55
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
56
|
+
// Return true if light (threshold 0.5)
|
|
57
|
+
return luminance > 0.5;
|
|
58
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dispatch, SetStateAction } from "react";
|
|
1
|
+
import { Dispatch, Ref, SetStateAction } from "react";
|
|
2
2
|
import { CombinedAgentType } from "./Types.js";
|
|
3
3
|
export interface ChatCommonProps {
|
|
4
4
|
/**
|
|
@@ -91,4 +91,6 @@ export type ChatCommonHandle = {
|
|
|
91
91
|
* experience for users when chatting with agents. It handles user input as well as displaying and nicely formatting
|
|
92
92
|
* agent responses. Customization for inputs and outputs is provided via event handlers-like props.
|
|
93
93
|
*/
|
|
94
|
-
export declare const ChatCommon:
|
|
94
|
+
export declare const ChatCommon: ({ ref, ...props }: ChatCommonProps & {
|
|
95
|
+
ref?: Ref<ChatCommonHandle>;
|
|
96
|
+
}) => import("react/jsx-runtime").JSX.Element;
|