@pega/cosmos-react-work 10.0.0-build.4.26 → 10.0.0-build.4.28
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/lib/components/GenAICoach/GenAICoach.d.ts +1 -1
- package/lib/components/GenAICoach/GenAICoach.d.ts.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.js +39 -6
- package/lib/components/GenAICoach/GenAICoach.js.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.styles.d.ts +9 -0
- package/lib/components/GenAICoach/GenAICoach.styles.d.ts.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.styles.js +17 -2
- package/lib/components/GenAICoach/GenAICoach.styles.js.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.test-ids.d.ts +1 -1
- package/lib/components/GenAICoach/GenAICoach.test-ids.d.ts.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.test-ids.js +3 -1
- package/lib/components/GenAICoach/GenAICoach.test-ids.js.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.types.d.ts +13 -1
- package/lib/components/GenAICoach/GenAICoach.types.d.ts.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.types.js.map +1 -1
- package/lib/components/GenAICoach/index.d.ts +1 -1
- package/lib/components/GenAICoach/index.d.ts.map +1 -1
- package/lib/components/GenAICoach/index.js.map +1 -1
- package/lib/components/Shortcuts/Shortcuts.d.ts +1 -1
- package/lib/components/Shortcuts/Shortcuts.d.ts.map +1 -1
- package/lib/components/Shortcuts/Shortcuts.js +9 -4
- package/lib/components/Shortcuts/Shortcuts.js.map +1 -1
- package/lib/components/Shortcuts/Shortcuts.test-ids.d.ts +1 -1
- package/lib/components/Shortcuts/Shortcuts.test-ids.d.ts.map +1 -1
- package/lib/components/Shortcuts/Shortcuts.test-ids.js +4 -3
- package/lib/components/Shortcuts/Shortcuts.test-ids.js.map +1 -1
- package/lib/components/Shortcuts/Shortcuts.types.d.ts +10 -0
- package/lib/components/Shortcuts/Shortcuts.types.d.ts.map +1 -1
- package/lib/components/Shortcuts/Shortcuts.types.js.map +1 -1
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@ import { type GenAICoachProps } from '.';
|
|
|
2
2
|
export declare const AgentIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export declare const AISuggestedBadge: () => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
declare const _default: ((props: GenAICoachProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
5
|
-
getTestIds: (testIdProp?: import("@pega/cosmos-react-core").TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["user-message", "coach-message", "system-message", "actions", "attachments"]>;
|
|
5
|
+
getTestIds: (testIdProp?: import("@pega/cosmos-react-core").TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["user-message", "coach-message", "system-message", "actions", "attachments", "agent-mode", "model-selector"]>;
|
|
6
6
|
};
|
|
7
7
|
export default _default;
|
|
8
8
|
//# sourceMappingURL=GenAICoach.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenAICoach.d.ts","sourceRoot":"","sources":["../../../src/components/GenAICoach/GenAICoach.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GenAICoach.d.ts","sourceRoot":"","sources":["../../../src/components/GenAICoach/GenAICoach.tsx"],"names":[],"mappings":"AA6GA,OAAO,EAAyC,KAAK,eAAe,EAAE,MAAM,GAAG,CAAC;AAyChF,eAAO,MAAM,SAAS,+CA2GrB,CAAC;AAEF,eAAO,MAAM,gBAAgB,+CAQ5B,CAAC;iCAk7DyB,eAAe;;;AAQ1C,wBAA6D"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { getLuminance } from 'polished';
|
|
4
|
-
import { Button, Flex, Icon, MenuButton, Progress, Text, createUID, menuHelpers, useI18n, useSpeechRecognition, useTestIds, useTheme, withTestIds, registerIcon, usePrevious, getFocusables, isMenuGroupProps, ErrorState, useArrows, useFocusTrap, useLiveLog, useOuterEvent, ThemeOverride, hasProp, getActiveElement, useElement, Actions, useFullscreenContext, useBreakpoint, Grid, useRefMap, VisuallyHiddenText, FileList, Lightbox, FormField, useUID, SpeechToTextButton, Toaster, useToaster, throttle } from '@pega/cosmos-react-core';
|
|
4
|
+
import { Button, Flex, Icon, MenuButton, Progress, Text, createUID, menuHelpers, useI18n, useSpeechRecognition, useTestIds, useTheme, withTestIds, registerIcon, usePrevious, getFocusables, isMenuGroupProps, ErrorState, useArrows, useFocusTrap, useLiveLog, useOuterEvent, ThemeOverride, hasProp, getActiveElement, useElement, Actions, useFullscreenContext, useBreakpoint, Grid, useRefMap, VisuallyHiddenText, FileList, Lightbox, FormField, useUID, SpeechToTextButton, Toaster, useToaster, throttle, Tooltip } from '@pega/cosmos-react-core';
|
|
5
5
|
import * as caretUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-up.icon';
|
|
6
6
|
import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
|
|
7
7
|
import * as caretDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-down.icon';
|
|
@@ -19,7 +19,7 @@ import * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icon
|
|
|
19
19
|
import * as caretRightIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-right.icon';
|
|
20
20
|
import { getGenAICoachTestIds } from './GenAICoach.test-ids';
|
|
21
21
|
import { getSelectedKeys, isCoachMessage, isInUtilities, isUserMessage } from './GenAICoach.utils';
|
|
22
|
-
import { StyledMessagesContainer, StyledDisclaimerText, StyledGenAICoachContainer, StyledGenAIOptionsMenu, StyledInitialMessageContainer, StyledInputContainer, StyledMenuSuggestions, StyledMessagesList, StyledGridContainer, StyledFlexWrapper, StyledErrorContainer, StyledInput, StyledGuidedSuggestions, StyledComposerSection, StyledSendButton, StyledStopGeneratingButton, StyledGenAIFormControl, StyledGenAITextArea, StyledInitialMessageGrid, StyledGenAIFooter, StyledAgentIcon, StyledActionsContainer, StyledHeaderContainer, StyledFullscreenWrapper, StyledScrollButton, StyledSuggestionCardsView, StyledSuggestionCardsBottomHalf, StyledStickyComposer, StyledAISuggestedBadge, StyledSalutation, StyledSubHeading, StyledComposerWrapper, StyledBannerSalutationBlock } from './GenAICoach.styles';
|
|
22
|
+
import { StyledMessagesContainer, StyledDisclaimerText, StyledGenAICoachContainer, StyledGenAIOptionsMenu, StyledInitialMessageContainer, StyledInputContainer, StyledMenuSuggestions, StyledMessagesList, StyledGridContainer, StyledFlexWrapper, StyledErrorContainer, StyledInput, StyledGuidedSuggestions, StyledComposerSection, StyledSendButton, StyledStopGeneratingButton, StyledGenAIFormControl, StyledGenAITextArea, StyledInitialMessageGrid, StyledGenAIFooter, StyledAgentIcon, StyledActionsContainer, StyledHeaderContainer, StyledFullscreenWrapper, StyledScrollButton, StyledSuggestionCardsView, StyledSuggestionCardsBottomHalf, StyledStickyComposer, StyledAISuggestedBadge, StyledSalutation, StyledSubHeading, StyledComposerWrapper, StyledBannerSalutationBlock, StyledComposerSelector } from './GenAICoach.styles';
|
|
23
23
|
import ActiveCases from './ActiveCases';
|
|
24
24
|
import CaseWorkflow from './CaseWorkflow';
|
|
25
25
|
import ConversationHistory from './ConversationHistory';
|
|
@@ -98,7 +98,7 @@ const HeaderActions = ({ actions, allowFullScreen, variant, isUserTriggeredRef,
|
|
|
98
98
|
}
|
|
99
99
|
return (_jsx(Actions, { ...(actions ?? {}), menuAt: 1, "data-testid": actionsTestId, contextualLabel: selectedCoach, items: mergedItems }));
|
|
100
100
|
};
|
|
101
|
-
const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachChange: onCoachChangeProp, messages = [], onSend, initialSuggestedMessages, suggestions, loading, error, variant, onOpen, guidedMode = false, actions, onNewChat, conversationHistory, onLayoutChange, onAddAttachment, attachments, attachmentsError, lightboxPreviewProps, allowFullScreen = true, isInLandingPageUtilities, stopProcess, voiceToTextProps, salutation, showSalutation = true, isPortalAgent = false, pagePanel, suggestionCardsView, draftMessage, caseWorkflow, activeCases, onStop, isCreatingConversation, conversationError, questionnaireData, onQuestionnaireDismiss, simplifiedAgent = false, subHeading, operatorName, ...restProps }) => {
|
|
101
|
+
const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachChange: onCoachChangeProp, messages = [], onSend, initialSuggestedMessages, suggestions, loading, error, variant, onOpen, guidedMode = false, actions, onNewChat, conversationHistory, onLayoutChange, onAddAttachment, attachments, attachmentsError, lightboxPreviewProps, allowFullScreen = true, isInLandingPageUtilities, stopProcess, voiceToTextProps, salutation, showSalutation = true, isPortalAgent = false, pagePanel, suggestionCardsView, draftMessage, caseWorkflow, activeCases, onStop, isCreatingConversation, conversationError, questionnaireData, onQuestionnaireDismiss, simplifiedAgent = false, subHeading, operatorName, agentModeProps, modelSelectorProps, ...restProps }) => {
|
|
102
102
|
const scrollTolerancePx = 2;
|
|
103
103
|
const scrollThresholdPx = 50;
|
|
104
104
|
const streamBufferLh = simplifiedAgent ? 15 : 5;
|
|
@@ -131,6 +131,8 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
|
|
|
131
131
|
const messageContainerRef = useRef(null);
|
|
132
132
|
const textAreaRef = useRef(null);
|
|
133
133
|
const [suggestionMenuButton, setSuggestionMenuButton] = useElement(null);
|
|
134
|
+
const [agentModeButtonEl, setAgentModeButtonEl] = useElement(null);
|
|
135
|
+
const [modelSelectorButtonEl, setModelSelectorButtonEl] = useElement(null);
|
|
134
136
|
const isGeneratingResponse = useRef(false);
|
|
135
137
|
const focusTextArea = useRef(false);
|
|
136
138
|
const historyViewRef = useRef(null);
|
|
@@ -440,6 +442,28 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
|
|
|
440
442
|
return coachOptions[0].primary;
|
|
441
443
|
}
|
|
442
444
|
}, [coachOptions]);
|
|
445
|
+
const selectedAgentModeLabel = useMemo(() => {
|
|
446
|
+
if (!agentModeProps)
|
|
447
|
+
return '';
|
|
448
|
+
const selected = menuHelpers.getSelected(agentModeProps.modes)[0];
|
|
449
|
+
if (selected)
|
|
450
|
+
return selected.primary;
|
|
451
|
+
if (agentModeProps.modes[0]) {
|
|
452
|
+
if (isMenuGroupProps(agentModeProps.modes[0])) {
|
|
453
|
+
return agentModeProps.modes[0].items[0].primary;
|
|
454
|
+
}
|
|
455
|
+
return agentModeProps.modes[0].primary;
|
|
456
|
+
}
|
|
457
|
+
return '';
|
|
458
|
+
}, [agentModeProps]);
|
|
459
|
+
const selectedModelLabel = useMemo(() => {
|
|
460
|
+
if (!modelSelectorProps)
|
|
461
|
+
return '';
|
|
462
|
+
return menuHelpers
|
|
463
|
+
.getSelected(modelSelectorProps.options)
|
|
464
|
+
.map(s => s.primary)
|
|
465
|
+
.join(' · ');
|
|
466
|
+
}, [modelSelectorProps]);
|
|
443
467
|
const onResult = useCallback(value => {
|
|
444
468
|
pendingResult.current = false;
|
|
445
469
|
setMessage(prevMessage => {
|
|
@@ -842,9 +866,9 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
|
|
|
842
866
|
}, autoResize: true, simplified: simplifiedAgent }), _jsxs(Flex, { container: {
|
|
843
867
|
direction: 'row',
|
|
844
868
|
justify: 'between',
|
|
845
|
-
gap:
|
|
869
|
+
gap: 2,
|
|
846
870
|
pad: [undefined, 1, 1, 1]
|
|
847
|
-
}, children: [_jsxs(Flex, { container: { alignItems: 'center' }, children: [!(messages.length === 0 && suggestionCardsView) && suggestions && (_jsx(MenuButton, { text: t('suggestions'), variant: 'simple', icon: 'chat-typing', iconOnly: true, as: StyledMenuSuggestions, menu: {
|
|
871
|
+
}, children: [_jsxs(Flex, { container: { alignItems: 'center' }, item: { grow: 1, shrink: 1, basis: '0%' }, children: [!(messages.length === 0 && suggestionCardsView) && suggestions && (_jsx(MenuButton, { text: t('suggestions'), variant: 'simple', icon: 'chat-typing', iconOnly: true, as: StyledMenuSuggestions, menu: {
|
|
848
872
|
items: suggestions,
|
|
849
873
|
onItemClick: id => {
|
|
850
874
|
const selected = menuHelpers.getItem(suggestions, id);
|
|
@@ -858,7 +882,16 @@ const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachCha
|
|
|
858
882
|
fileUploadInputRef.current.value = '';
|
|
859
883
|
}
|
|
860
884
|
fileUploadInputRef.current?.click();
|
|
861
|
-
}, variant: 'simple', label: t('add_attachment'), children: _jsx(Icon, { name: 'paper-clip' }) }), _jsx(StyledInput, { type: 'file', ref: fileUploadInputRef, onChange: onFileChange, multiple: false, "data-testid": testIds.attachments })] }))
|
|
885
|
+
}, variant: 'simple', label: t('add_attachment'), children: _jsx(Icon, { name: 'paper-clip' }) }), _jsx(StyledInput, { type: 'file', ref: fileUploadInputRef, onChange: onFileChange, multiple: false, "data-testid": testIds.attachments })] })), agentModeProps && agentModeProps.modes.length > 0 && (_jsxs(_Fragment, { children: [_jsx(StyledComposerSelector, { ref: setAgentModeButtonEl, text: selectedAgentModeLabel, "aria-label": t('agent_mode_selector', [selectedAgentModeLabel]), variant: 'simple', "data-testid": testIds.agentMode, menu: {
|
|
886
|
+
mode: 'single-select',
|
|
887
|
+
items: agentModeProps.modes,
|
|
888
|
+
onItemClick: agentModeProps.onAgentModeChange
|
|
889
|
+
}, showArrow: true }), agentModeButtonEl && selectedAgentModeLabel && (_jsx(Tooltip, { target: agentModeButtonEl, smart: true, showDelay: 'none', hideDelay: 'none', children: selectedAgentModeLabel }))] })), modelSelectorProps && modelSelectorProps.options.length > 0 && (_jsxs(_Fragment, { children: [_jsx(StyledComposerSelector, { ref: setModelSelectorButtonEl, text: selectedModelLabel, "aria-label": t('model_selector_button', [selectedModelLabel]), variant: 'simple', "data-testid": testIds.modelSelector, menu: {
|
|
890
|
+
mode: 'single-select',
|
|
891
|
+
variant: 'flyout',
|
|
892
|
+
items: modelSelectorProps.options,
|
|
893
|
+
onItemClick: modelSelectorProps.onModelChange
|
|
894
|
+
}, showArrow: true }), modelSelectorButtonEl && selectedModelLabel && (_jsx(Tooltip, { target: modelSelectorButtonEl, smart: true, showDelay: 'none', hideDelay: 'none', children: selectedModelLabel }))] }))] }), (() => {
|
|
862
895
|
if (active && pendingResult.current) {
|
|
863
896
|
return (_jsxs(Flex, { container: {
|
|
864
897
|
gap: 1,
|