@cognizant-ai-lab/ui-common 1.7.0 → 1.8.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/dist/Theme/Palettes.d.ts +0 -9
- package/dist/Theme/Palettes.js +0 -18
- package/dist/components/AgentChat/ChatCommon/ChatCommon.d.ts +4 -1
- package/dist/components/AgentChat/ChatCommon/ChatCommon.js +74 -47
- package/dist/components/AgentChat/ChatCommon/Const.d.ts +1 -0
- package/dist/components/AgentChat/ChatCommon/Const.js +2 -0
- package/dist/components/AgentChat/ChatCommon/ControlButtons.d.ts +1 -1
- package/dist/components/AgentChat/ChatCommon/ControlButtons.js +7 -4
- package/dist/components/AgentChat/ChatCommon/FormattedMarkdown.js +3 -0
- package/dist/components/AgentChat/ChatCommon/SendButton.js +7 -6
- package/dist/components/AgentChat/ChatCommon/SyntaxHighlighterThemes.js +1 -1
- package/dist/components/AgentChat/ChatCommon/Thinking.d.ts +1 -0
- package/dist/components/AgentChat/ChatCommon/Thinking.js +10 -7
- package/dist/components/AgentChat/Common/LlmChatButton.d.ts +0 -2
- package/dist/components/AgentChat/Common/LlmChatButton.js +6 -9
- package/dist/components/AgentChat/VoiceChat/MicrophoneButton.js +12 -10
- package/dist/components/Common/Navbar.js +24 -22
- package/dist/components/Common/StatusLight.d.ts +9 -0
- package/dist/components/Common/StatusLight.js +21 -0
- package/dist/components/ErrorPage/ErrorBoundary.js +1 -1
- package/dist/components/ErrorPage/ErrorPage.d.ts +3 -3
- package/dist/components/ErrorPage/ErrorPage.js +4 -3
- package/dist/components/Logo/Common.d.ts +4 -0
- package/dist/components/Logo/Common.js +8 -0
- package/dist/components/Logo/CustomerLogo.d.ts +23 -0
- package/dist/components/Logo/CustomerLogo.js +41 -0
- package/dist/components/MultiAgentAccelerator/AgentConversations.js +0 -1
- package/dist/components/MultiAgentAccelerator/AgentFlow.js +85 -53
- package/dist/components/MultiAgentAccelerator/AgentNode.js +23 -27
- package/dist/components/MultiAgentAccelerator/GraphLayouts.d.ts +17 -10
- package/dist/components/MultiAgentAccelerator/GraphLayouts.js +4 -6
- package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.d.ts +3 -9
- package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.js +28 -32
- package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.d.ts +0 -5
- package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.js +30 -25
- package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.d.ts +3 -4
- package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.js +84 -168
- package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.d.ts +30 -13
- package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.js +157 -100
- package/dist/components/MultiAgentAccelerator/Tour/MainTourSteps.js +10 -8
- package/dist/components/MultiAgentAccelerator/const.d.ts +2 -0
- package/dist/components/MultiAgentAccelerator/const.js +4 -0
- package/dist/components/Settings/ApiKeyInput.js +7 -8
- package/dist/components/Settings/InfoTip.d.ts +8 -0
- package/dist/components/Settings/InfoTip.js +14 -0
- package/dist/components/Settings/SettingsDialog.js +355 -181
- package/dist/components/Settings/SettingsRow.d.ts +18 -0
- package/dist/components/Settings/SettingsRow.js +35 -0
- package/dist/controller/agent/Agent.d.ts +3 -20
- package/dist/controller/agent/Agent.js +9 -43
- package/dist/controller/agent/IconSuggestions.d.ts +35 -0
- package/dist/controller/agent/IconSuggestions.js +85 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/state/IconSuggestions.d.ts +27 -0
- package/dist/state/IconSuggestions.js +50 -0
- package/dist/state/Settings.d.ts +17 -3
- package/dist/state/Settings.js +23 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/title.js +1 -1
- package/package.json +5 -1
- package/dist/components/Common/CustomerLogo.d.ts +0 -17
- package/dist/components/Common/CustomerLogo.js +0 -47
- package/dist/components/Common/MUIAccordion.d.ts +0 -17
- package/dist/components/Common/MUIAccordion.js +0 -66
- package/dist/utils/useLocalStorage.d.ts +0 -1
- package/dist/utils/useLocalStorage.js +0 -55
package/dist/utils/title.js
CHANGED
|
@@ -15,6 +15,6 @@ limitations under the License.
|
|
|
15
15
|
*/
|
|
16
16
|
// Miscellaneous utilities for dealing with browser tab title
|
|
17
17
|
export const getTitleBase = () => {
|
|
18
|
-
const subdomain = window.location.host.split(".")[0];
|
|
18
|
+
const subdomain = window.location.host.split(".", 1)[0];
|
|
19
19
|
return `${subdomain[0].toUpperCase()}${subdomain.slice(1)}`;
|
|
20
20
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cognizant-ai-lab/ui-common",
|
|
3
3
|
"description": "A shared UI component library for Cognizant AI Labs projects",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.8.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "yarn clean && yarn generate && yarn run --top-level tsc --project tsconfig.build.json && fix-esm-import-path dist > /dev/null",
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@dagrejs/dagre": "1.0.4",
|
|
14
14
|
"@langchain/core": "1.1.17",
|
|
15
|
+
"@mui/icons-material": "9.0.1",
|
|
16
|
+
"@mui/material": "9.0.1",
|
|
17
|
+
"@mui/system": "9.0.1",
|
|
18
|
+
"@mui/x-tree-view": "9.1.0",
|
|
15
19
|
"@xyflow/react": "12.10.1",
|
|
16
20
|
"http-status": "1.7.3",
|
|
17
21
|
"lodash-es": "4.18.1",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { FC, ReactElement } from "react";
|
|
2
|
-
interface CustomerLogoProps {
|
|
3
|
-
readonly fallbackElement?: ReactElement | string;
|
|
4
|
-
readonly logoServiceToken?: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Returns a JSX element for the Cognizant logo, wrapped in a link to the Cognizant website.
|
|
8
|
-
*/
|
|
9
|
-
export declare const getCognizantLogoImage: () => import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
/**
|
|
11
|
-
* Component to display the customer's logo based on the settings.
|
|
12
|
-
* @param logoServiceToken - Optional token for fetching the logo from logo.dev
|
|
13
|
-
* @returns JSX element representing the customer's logo, MUI icon, or Cognizant fallback, or null if no logo
|
|
14
|
-
* should be displayed or if the logo.dev token is missing/invalid.
|
|
15
|
-
*/
|
|
16
|
-
export declare const CustomerLogo: FC<CustomerLogoProps>;
|
|
17
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
// Have to suppress this lint error to allow dynamic access of MUI icons
|
|
3
|
-
// eslint-disable-next-line no-restricted-imports
|
|
4
|
-
import * as MuiIcons from "@mui/icons-material";
|
|
5
|
-
import { useSettingsStore } from "../../state/Settings.js";
|
|
6
|
-
/**
|
|
7
|
-
* Returns a JSX element for the Cognizant logo, wrapped in a link to the Cognizant website.
|
|
8
|
-
*/
|
|
9
|
-
export const getCognizantLogoImage = () => (_jsx("a", { id: "splash-logo-link", href: "https://www.cognizant.com/us/en", style: {
|
|
10
|
-
display: "flex",
|
|
11
|
-
paddingLeft: "0.15rem",
|
|
12
|
-
}, target: "_blank", rel: "noopener noreferrer", children: _jsx("img", { id: "logo-img", width: "200", height: "45", src: "/cognizant-logo-white.svg", alt: "Cognizant Logo" }) }));
|
|
13
|
-
/**
|
|
14
|
-
* Component to display the customer's logo based on the settings.
|
|
15
|
-
* @param logoServiceToken - Optional token for fetching the logo from logo.dev
|
|
16
|
-
* @returns JSX element representing the customer's logo, MUI icon, or Cognizant fallback, or null if no logo
|
|
17
|
-
* should be displayed or if the logo.dev token is missing/invalid.
|
|
18
|
-
*/
|
|
19
|
-
export const CustomerLogo = ({ fallbackElement, logoServiceToken }) => {
|
|
20
|
-
const customer = useSettingsStore((state) => state.settings.branding.customer);
|
|
21
|
-
const iconSuggestion = useSettingsStore((state) => state.settings.branding.iconSuggestion);
|
|
22
|
-
const logoSource = useSettingsStore((state) => state.settings.branding.logoSource);
|
|
23
|
-
// null: render Cognizant logo (default)
|
|
24
|
-
if (logoSource === null) {
|
|
25
|
-
return customer?.trim().length ? null : getCognizantLogoImage();
|
|
26
|
-
}
|
|
27
|
-
// "none": explicitly render no logo
|
|
28
|
-
if (logoSource === "none") {
|
|
29
|
-
return fallbackElement;
|
|
30
|
-
}
|
|
31
|
-
// "generic": try MUI icon, then Cognizant fallback
|
|
32
|
-
if (logoSource === "generic") {
|
|
33
|
-
const MuiIcon = MuiIcons[iconSuggestion];
|
|
34
|
-
if (MuiIcon) {
|
|
35
|
-
return _jsx(MuiIcon, { sx: { fontSize: "2rem" } });
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
console.warn(`Icon "${iconSuggestion}" not found in MUI icons. Falling back to default.`);
|
|
39
|
-
return fallbackElement;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
// "auto": use logo.dev service
|
|
43
|
-
const logoUrl = logoServiceToken && customer?.trim().length > 0
|
|
44
|
-
? `https://img.logo.dev/name/${encodeURIComponent(customer)}?token=${logoServiceToken}&theme=dark&format=png&size=75`
|
|
45
|
-
: null;
|
|
46
|
-
return logoUrl ? (_jsx("img", { src: logoUrl, alt: `${customer} Logo`, width: 40, height: 40, style: { borderRadius: "50%" } })) : (fallbackElement);
|
|
47
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { SxProps } from "@mui/material/styles";
|
|
2
|
-
import { FC, ReactNode } from "react";
|
|
3
|
-
interface MUIAccordionItem {
|
|
4
|
-
content: ReactNode;
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
title: ReactNode;
|
|
7
|
-
}
|
|
8
|
-
interface MUIAccordionProps {
|
|
9
|
-
arrowPosition?: "left" | "right";
|
|
10
|
-
defaultExpandedPanelKey?: number;
|
|
11
|
-
expandOnlyOnePanel?: boolean;
|
|
12
|
-
id: string;
|
|
13
|
-
items: MUIAccordionItem[];
|
|
14
|
-
sx?: SxProps;
|
|
15
|
-
}
|
|
16
|
-
export declare const MUIAccordion: FC<MUIAccordionProps>;
|
|
17
|
-
export {};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
Copyright 2025 Cognizant Technology Solutions Corp, www.cognizant.com.
|
|
4
|
-
|
|
5
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
you may not use this file except in compliance with the License.
|
|
7
|
-
You may obtain a copy of the License at
|
|
8
|
-
|
|
9
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
|
|
11
|
-
Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
See the License for the specific language governing permissions and
|
|
15
|
-
limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import ArrowForwardIosSharpIcon from "@mui/icons-material/ArrowForwardIosSharp";
|
|
18
|
-
import MuiAccordion from "@mui/material/Accordion";
|
|
19
|
-
import MuiAccordionDetails from "@mui/material/AccordionDetails";
|
|
20
|
-
import MuiAccordionSummary, { accordionSummaryClasses } from "@mui/material/AccordionSummary";
|
|
21
|
-
import { styled } from "@mui/material/styles";
|
|
22
|
-
import Typography from "@mui/material/Typography";
|
|
23
|
-
import { useCallback, useState } from "react";
|
|
24
|
-
// #region: Styled Components
|
|
25
|
-
const Accordion = styled((props) => (_jsx(MuiAccordion, { disableGutters: true, elevation: 0, id: "mui-accordion", ...props })))(({ theme }) => ({
|
|
26
|
-
border: `1px solid ${theme.palette.divider}`,
|
|
27
|
-
"&::before": {
|
|
28
|
-
display: "none",
|
|
29
|
-
},
|
|
30
|
-
}));
|
|
31
|
-
const AccordionSummary = styled((props) => (_jsx(MuiAccordionSummary, { id: "mui-accordion-summary", expandIcon: _jsx(ArrowForwardIosSharpIcon, { id: "arrow-forward", sx: { fontSize: "0.9rem" } }), ...props })))(({ theme }) => ({
|
|
32
|
-
[`& .${accordionSummaryClasses.expandIconWrapper}.${accordionSummaryClasses.expanded}`]: {
|
|
33
|
-
transform: "rotate(90deg)",
|
|
34
|
-
},
|
|
35
|
-
[`& .${accordionSummaryClasses.content}`]: {
|
|
36
|
-
marginLeft: theme.spacing(1),
|
|
37
|
-
},
|
|
38
|
-
}));
|
|
39
|
-
const AccordionDetails = styled(MuiAccordionDetails)(({ theme }) => ({
|
|
40
|
-
borderTop: "1px solid rgba(0, 0, 0, .125)",
|
|
41
|
-
padding: theme.spacing(2),
|
|
42
|
-
}));
|
|
43
|
-
// #endregion: Types
|
|
44
|
-
export const MUIAccordion = ({ arrowPosition = "left", defaultExpandedPanelKey, expandOnlyOnePanel = false, id, items, sx, }) => {
|
|
45
|
-
const [expandedList, setExpandedList] = useState(defaultExpandedPanelKey ? [defaultExpandedPanelKey] : []);
|
|
46
|
-
const handleChange = useCallback((panelKey) => (_event, newExpanded) => {
|
|
47
|
-
setExpandedList((prevExpandedList) => {
|
|
48
|
-
if (!expandOnlyOnePanel) {
|
|
49
|
-
return newExpanded
|
|
50
|
-
? [...prevExpandedList, panelKey]
|
|
51
|
-
: prevExpandedList.filter((key) => key !== panelKey);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
return newExpanded ? [panelKey] : [];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}, [expandOnlyOnePanel]);
|
|
58
|
-
const isExpanded = useCallback((panelKey) => expandedList.includes(panelKey), [expandedList]);
|
|
59
|
-
return (_jsx(_Fragment, { children: items.map(({ content, disabled = false, title }, index) => {
|
|
60
|
-
const panelKey = index + 1; // Start with index 1
|
|
61
|
-
const baseIdAndPanelKey = `${id}-${panelKey}`;
|
|
62
|
-
return (_jsxs(Accordion, { disabled: disabled, expanded: isExpanded(panelKey), id: `${baseIdAndPanelKey}-accordion`, onChange: handleChange(panelKey), sx: sx, children: [_jsx(AccordionSummary, { "aria-controls": `${baseIdAndPanelKey}-summary`, id: `${baseIdAndPanelKey}-summary`, sx: {
|
|
63
|
-
flexDirection: arrowPosition === "left" ? "row-reverse" : undefined,
|
|
64
|
-
}, children: _jsx(Typography, { component: "span", id: `${baseIdAndPanelKey}-summary-typography`, sx: { fontSize: "0.9rem" }, children: title }) }), _jsx(AccordionDetails, { id: `${baseIdAndPanelKey}-details`, children: _jsx(Typography, { component: "span", id: `${baseIdAndPanelKey}-details-typography`, sx: { fontSize: "0.85rem" }, children: content }) })] }, `${baseIdAndPanelKey}-accordion`));
|
|
65
|
-
}) }));
|
|
66
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useLocalStorage: (key: string, initialValue: unknown) => any[];
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2025 Cognizant Technology Solutions Corp, www.cognizant.com.
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { useState } from "react";
|
|
17
|
-
export const useLocalStorage = (key, initialValue) => {
|
|
18
|
-
// State to store our value
|
|
19
|
-
// Pass initial state function to useState so logic is only executed once
|
|
20
|
-
const [storedValue, setStoredValue] = useState(() => {
|
|
21
|
-
if (typeof window === "undefined") {
|
|
22
|
-
return initialValue;
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
// Get from local storage by key
|
|
26
|
-
const item = window.localStorage.getItem(key);
|
|
27
|
-
// Parse stored JSON or if none return initialValue
|
|
28
|
-
return item ? JSON.parse(item) : initialValue;
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
// If error also return initialValue
|
|
32
|
-
console.error(error);
|
|
33
|
-
return initialValue;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
// Return a wrapped version of useState's setter function that ...
|
|
37
|
-
// ... persists the new value to localStorage.
|
|
38
|
-
const setValue = (value) => {
|
|
39
|
-
try {
|
|
40
|
-
// Allow value to be a function so we have same API as useState
|
|
41
|
-
const valueToStore = typeof value === "function" ? value(storedValue) : value;
|
|
42
|
-
// Save state
|
|
43
|
-
setStoredValue(valueToStore);
|
|
44
|
-
// Save to local storage
|
|
45
|
-
if (typeof window !== "undefined") {
|
|
46
|
-
window.localStorage.setItem(key, JSON.stringify(valueToStore));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
// A more advanced implementation would handle the error case
|
|
51
|
-
console.error(error);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
return [storedValue, setValue];
|
|
55
|
-
};
|