@pega/cosmos-react-work 7.0.0-build.17.9 → 7.0.0-build.18.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.
Files changed (69) hide show
  1. package/lib/components/CasePreview/CasePreview.d.ts.map +1 -1
  2. package/lib/components/CasePreview/CasePreview.js +22 -3
  3. package/lib/components/CasePreview/CasePreview.js.map +1 -1
  4. package/lib/components/CaseView/CaseView.d.ts.map +1 -1
  5. package/lib/components/CaseView/CaseView.js +36 -10
  6. package/lib/components/CaseView/CaseView.js.map +1 -1
  7. package/lib/components/CaseView/CaseView.styles.d.ts +7 -1
  8. package/lib/components/CaseView/CaseView.styles.d.ts.map +1 -1
  9. package/lib/components/CaseView/CaseView.styles.js +51 -11
  10. package/lib/components/CaseView/CaseView.styles.js.map +1 -1
  11. package/lib/components/CaseView/CaseView.types.d.ts +10 -2
  12. package/lib/components/CaseView/CaseView.types.d.ts.map +1 -1
  13. package/lib/components/CaseView/CaseView.types.js.map +1 -1
  14. package/lib/components/CaseView/UtilitySummaryItemDialog.d.ts.map +1 -1
  15. package/lib/components/CaseView/UtilitySummaryItemDialog.js +0 -1
  16. package/lib/components/CaseView/UtilitySummaryItemDialog.js.map +1 -1
  17. package/lib/components/Details/Details.d.ts +22 -17
  18. package/lib/components/Details/Details.d.ts.map +1 -1
  19. package/lib/components/Details/Details.js +61 -49
  20. package/lib/components/Details/Details.js.map +1 -1
  21. package/lib/components/Details/Details.styles.d.ts +17 -27
  22. package/lib/components/Details/Details.styles.d.ts.map +1 -1
  23. package/lib/components/Details/Details.styles.js +168 -127
  24. package/lib/components/Details/Details.styles.js.map +1 -1
  25. package/lib/components/Details/DetailsList.d.ts +14 -0
  26. package/lib/components/Details/DetailsList.d.ts.map +1 -0
  27. package/lib/components/Details/DetailsList.js +31 -0
  28. package/lib/components/Details/DetailsList.js.map +1 -0
  29. package/lib/components/Details/index.d.ts +2 -1
  30. package/lib/components/Details/index.d.ts.map +1 -1
  31. package/lib/components/Details/index.js +2 -1
  32. package/lib/components/Details/index.js.map +1 -1
  33. package/lib/components/GenAICoach/GenAICoach.d.ts +7 -0
  34. package/lib/components/GenAICoach/GenAICoach.d.ts.map +1 -0
  35. package/lib/components/GenAICoach/GenAICoach.js +151 -0
  36. package/lib/components/GenAICoach/GenAICoach.js.map +1 -0
  37. package/lib/components/GenAICoach/GenAICoach.styles.d.ts +29 -0
  38. package/lib/components/GenAICoach/GenAICoach.styles.d.ts.map +1 -0
  39. package/lib/components/GenAICoach/GenAICoach.styles.js +211 -0
  40. package/lib/components/GenAICoach/GenAICoach.styles.js.map +1 -0
  41. package/lib/components/GenAICoach/GenAICoach.test-ids.d.ts +2 -0
  42. package/lib/components/GenAICoach/GenAICoach.test-ids.d.ts.map +1 -0
  43. package/lib/components/GenAICoach/GenAICoach.test-ids.js +3 -0
  44. package/lib/components/GenAICoach/GenAICoach.test-ids.js.map +1 -0
  45. package/lib/components/GenAICoach/GenAICoach.types.d.ts +53 -0
  46. package/lib/components/GenAICoach/GenAICoach.types.d.ts.map +1 -0
  47. package/lib/components/GenAICoach/GenAICoach.types.js +2 -0
  48. package/lib/components/GenAICoach/GenAICoach.types.js.map +1 -0
  49. package/lib/components/GenAICoach/GenAICoach.utils.d.ts +9 -0
  50. package/lib/components/GenAICoach/GenAICoach.utils.d.ts.map +1 -0
  51. package/lib/components/GenAICoach/GenAICoach.utils.js +10 -0
  52. package/lib/components/GenAICoach/GenAICoach.utils.js.map +1 -0
  53. package/lib/components/GenAICoach/GenAIMessage.d.ts +5 -0
  54. package/lib/components/GenAICoach/GenAIMessage.d.ts.map +1 -0
  55. package/lib/components/GenAICoach/GenAIMessage.js +25 -0
  56. package/lib/components/GenAICoach/GenAIMessage.js.map +1 -0
  57. package/lib/components/GenAICoach/InitialSuggestedMessage.d.ts +5 -0
  58. package/lib/components/GenAICoach/InitialSuggestedMessage.d.ts.map +1 -0
  59. package/lib/components/GenAICoach/InitialSuggestedMessage.js +18 -0
  60. package/lib/components/GenAICoach/InitialSuggestedMessage.js.map +1 -0
  61. package/lib/components/GenAICoach/index.d.ts +6 -0
  62. package/lib/components/GenAICoach/index.d.ts.map +1 -0
  63. package/lib/components/GenAICoach/index.js +5 -0
  64. package/lib/components/GenAICoach/index.js.map +1 -0
  65. package/lib/index.d.ts +2 -0
  66. package/lib/index.d.ts.map +1 -1
  67. package/lib/index.js +2 -0
  68. package/lib/index.js.map +1 -1
  69. package/package.json +2 -2
@@ -0,0 +1,151 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
3
+ import { Button, Flex, Grid, Icon, MenuButton, Progress, Text, TextArea, createUID, menuHelpers, useBreakpoint, useI18n, useTestIds, useTheme, withTestIds, Card, registerIcon, usePrevious, getFocusables, isMenuGroupProps } from '@pega/cosmos-react-core';
4
+ import * as caretUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-up.icon';
5
+ import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
6
+ import * as caretDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-down.icon';
7
+ import * as minusIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/minus.icon';
8
+ import * as polarisSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/polaris-solid.icon';
9
+ import CaseViewContext from '../CaseView/CaseView.context';
10
+ import { getGenAICoachTestIds } from './GenAICoach.test-ids';
11
+ import { StyledChatButton, StyledCloseButton, StyledMessagesContainer, StyledDisclaimerText, StyledGenAICoachContainer, StyledGenAIOptionsMenu, StyledInitialMessageContainer, StyledInputContainer, StyledMessageWrapper, StyledProgressContainer, StyledStarterMessage, StyledSuggestions } from './GenAICoach.styles';
12
+ import { isCoachMessage, isInUtilities, isUserMessage } from './GenAICoach.utils';
13
+ import { GenAIMessage, InitialSuggestedMessage } from '.';
14
+ registerIcon(caretUpIcon, timesIcon, caretDownIcon, minusIcon, polarisSolidIcon);
15
+ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: onCoachChangeProp, messages = [], onSend, initialSuggestedMessages, suggestions, loading, starterMessage, variant, onOpen, ...restProps }) => {
16
+ const elementRef = useRef(null);
17
+ const conversationRef = useRef(null);
18
+ const genAICoachRef = useRef(null);
19
+ const textAreaRef = useRef(null);
20
+ const [message, setMessage] = useState('');
21
+ const [coachOptions, setCoachOptions] = useState(coachOptionsProps);
22
+ const smOrAbove = useBreakpoint('sm', { breakpointRef: genAICoachRef });
23
+ const previousMessages = usePrevious(messages);
24
+ const theme = useTheme();
25
+ const t = useI18n();
26
+ const { setGenAIHeight, aboveLG } = useContext(CaseViewContext);
27
+ const testIds = useTestIds(testId, getGenAICoachTestIds);
28
+ const onCoachChange = (id) => {
29
+ setCoachOptions(cur => menuHelpers.toggleSelected(cur, id, 'single-select'));
30
+ onCoachChangeProp?.(id);
31
+ };
32
+ const selectedCoach = useMemo(() => {
33
+ const selected = menuHelpers.getSelected(coachOptions)[0];
34
+ if (selected)
35
+ return selected.primary;
36
+ if (coachOptions[0] && !isMenuGroupProps(coachOptions[0]))
37
+ return coachOptions[0].primary;
38
+ }, [coachOptions]);
39
+ const handleEnterKeyDown = useCallback((e) => {
40
+ if (e.key === 'Enter' && !e.shiftKey) {
41
+ onSend({
42
+ id: createUID(),
43
+ message
44
+ });
45
+ setMessage('');
46
+ e.preventDefault();
47
+ e.stopPropagation();
48
+ }
49
+ }, [message]);
50
+ const handleTextAreaChange = useCallback((e) => {
51
+ setMessage(e.currentTarget.value);
52
+ }, [setMessage]);
53
+ const scrollToBottom = () => {
54
+ if (conversationRef.current) {
55
+ conversationRef.current.scrollTop = conversationRef.current.scrollHeight;
56
+ }
57
+ };
58
+ const headerContent = useMemo(() => {
59
+ return isInUtilities(variant) && variant.state === 'docked' ? (_jsxs(_Fragment, { children: [_jsxs(Flex, { container: { gap: 2 }, children: [_jsx(Icon, { name: 'polaris-solid', color: theme.base.palette.ai }), _jsx(Text, { variant: 'h3', children: selectedCoach })] }), _jsx(Flex, { container: { alignItems: 'center' }, children: _jsx(Button, { icon: true, label: t('maximize'), "aria-label": t('maximize_gen_ai', [t('coach', ['Pega Gen AI'])]), variant: 'simple', onClick: () => variant.onStateChange('maximized'), children: _jsx(Icon, { name: 'caret-up' }) }) })] })) : (_jsxs(_Fragment, { children: [_jsx(MenuButton, { text: selectedCoach || '', variant: 'text', as: StyledGenAIOptionsMenu, icon: 'polaris-solid', menu: {
60
+ mode: 'single-select',
61
+ items: coachOptions,
62
+ onItemClick: onCoachChange
63
+ } }), isInUtilities(variant) && (_jsx(Button, { icon: true, label: t('minimize'), "aria-label": t('minimize_gen_ai', [t('coach', ['Pega Gen AI'])]), variant: 'simple', onClick: () => variant.onStateChange('docked'), children: _jsx(Icon, { name: 'minus' }) })), variant.placement === 'dialog' && (_jsx(Button, { icon: true, label: t('close'), "aria-label": t('close_gen_ai', [t('coach', ['Pega Gen AI'])]), variant: 'simple', onClick: variant.onClose, children: _jsx(Icon, { name: 'times' }) }))] }));
64
+ }, [variant, coachOptions]);
65
+ const onResize = () => {
66
+ if (genAICoachRef.current) {
67
+ const height = genAICoachRef.current.clientHeight;
68
+ setGenAIHeight?.(height);
69
+ }
70
+ };
71
+ useEffect(() => {
72
+ if (isInUtilities(variant)) {
73
+ onResize();
74
+ }
75
+ }, [variant]);
76
+ useEffect(() => {
77
+ onResize();
78
+ if (variant.placement !== 'fullpage') {
79
+ textAreaRef.current?.focus();
80
+ }
81
+ if (isInUtilities(variant) &&
82
+ variant.state === 'docked' &&
83
+ getFocusables(genAICoachRef).length > 0) {
84
+ getFocusables(genAICoachRef)[0].focus();
85
+ }
86
+ }, [textAreaRef.current]);
87
+ useEffect(() => {
88
+ onOpen?.();
89
+ window.addEventListener('resize', onResize);
90
+ return () => {
91
+ window.removeEventListener('resize', onResize);
92
+ };
93
+ }, []);
94
+ useEffect(() => {
95
+ if (isInUtilities(variant) && variant.state !== 'maximized' && messages.length > 0) {
96
+ variant.onStateChange('maximized');
97
+ }
98
+ if (messages.length > 0 && previousMessages?.length !== messages.length) {
99
+ scrollToBottom();
100
+ if (isUserMessage(messages[messages.length - 1]))
101
+ textAreaRef.current?.focus();
102
+ }
103
+ }, [messages]);
104
+ return (_jsxs(Flex, { container: { direction: 'column' }, as: StyledGenAICoachContainer, "data-testid": testIds.root, variant: variant, starterMessage: starterMessage, ref: genAICoachRef, aboveLG: aboveLG, ...restProps, children: [_jsx(Flex, { container: { justify: 'between', alignItems: 'center', pad: 1 }, children: headerContent }), ((isInUtilities(variant) && variant.state !== 'docked') || !isInUtilities(variant)) && (_jsxs(_Fragment, { children: [_jsxs(Flex, { as: StyledMessagesContainer, ref: conversationRef, container: starterMessage || loading
105
+ ? { direction: 'column', pad: [0, 2], justify: 'center' }
106
+ : { direction: 'column', pad: [0, 2] }, item: { grow: 1 }, children: [loading && (_jsx(StyledProgressContainer, { container: true, children: _jsx(Progress, { variant: 'ring', placement: 'block' }) })), !loading && messages.length === 0 && (_jsx(_Fragment, { children: starterMessage ? (_jsxs(Card, { container: { alignItems: 'center', pad: 1.5 }, item: { grow: 0 }, as: StyledStarterMessage, children: [starterMessage.message, _jsx(StyledCloseButton, { icon: true, label: t('close'), "aria-label": `${t('close')} ${t('starter_message')}`, variant: 'simple', onClick: starterMessage.onClose, children: _jsx(Icon, { name: 'times' }) })] })) : (_jsxs(Flex, { as: StyledInitialMessageContainer, container: {
107
+ justify: 'center',
108
+ direction: 'column',
109
+ gap: 8
110
+ }, item: { grow: 1 }, children: [((isInUtilities(variant) && variant.state === 'maximized') ||
111
+ !isInUtilities(variant)) && (_jsxs(Flex, { container: { direction: 'column', alignItems: 'center', gap: 2 }, children: [_jsx(Icon, { name: 'polaris-solid', size: 'l', color: theme.base.palette.ai }), _jsx(Text, { variant: 'h2', children: t('welcome_text') })] })), _jsx(Grid, { container: { cols: smOrAbove ? 'repeat(2, 1fr)' : '1fr', gap: 1.5 }, children: initialSuggestedMessages?.map(initialSuggestedMessage => (_jsx(InitialSuggestedMessage, { ...initialSuggestedMessage, onSend: initialMessage => {
112
+ onSend(initialMessage);
113
+ }, testId: initialSuggestedMessage.id }))) })] })) })), !loading && messages.length > 0 && (_jsx(_Fragment, { children: messages.map(item => {
114
+ const messageProps = isCoachMessage(item)
115
+ ? {
116
+ ...item,
117
+ onSend
118
+ }
119
+ : item;
120
+ return (_jsx(StyledMessageWrapper, { ref: elementRef, children: _jsx(GenAIMessage, { ...messageProps, testId: item.id }) }));
121
+ }) }))] }), !starterMessage &&
122
+ ((isInUtilities(variant) &&
123
+ variant.state !== 'docked' &&
124
+ variant.state !== 'minimized') ||
125
+ !isInUtilities(variant)) && (_jsxs(Flex, { container: { direction: 'column' }, as: StyledInputContainer, children: [_jsx(TextArea, { ref: textAreaRef, label: t('message_pega_gen_ai_coach', [selectedCoach || '']), value: message, onKeyDown: handleEnterKeyDown, onChange: handleTextAreaChange, autoResize: false }), _jsxs(Flex, { container: { direction: 'row', gap: 2, justify: 'end', pad: 1 }, children: [suggestions && (_jsx(MenuButton, { text: t('suggestions'), variant: 'text', as: StyledSuggestions, icon: 'polaris-solid', menu: {
126
+ items: suggestions,
127
+ onItemClick: id => {
128
+ const selected = menuHelpers.getItem(suggestions, id);
129
+ if (selected)
130
+ onSend({ id: selected.id, message: selected.primary });
131
+ }
132
+ } })), _jsx(Button, { variant: 'primary', onClick: message
133
+ ? () => {
134
+ onSend({
135
+ id: createUID(),
136
+ message
137
+ });
138
+ setMessage('');
139
+ }
140
+ : undefined, children: t('send') })] }), _jsx(StyledDisclaimerText, { children: t('ai_disclaimer') })] })), !loading &&
141
+ messages.length === 0 &&
142
+ ((isInUtilities(variant) && variant.state === 'minimized') || starterMessage) && (_jsx(StyledChatButton, { icon: true, onClick: () => {
143
+ if (isInUtilities(variant))
144
+ variant.onStateChange('maximized');
145
+ if (starterMessage && starterMessage.message) {
146
+ onSend({ id: starterMessage.id, message: starterMessage.message });
147
+ }
148
+ }, children: _jsxs(Flex, { container: { alignItems: 'center', gap: 1 }, children: [_jsx(Icon, { name: 'polaris-solid' }), t('start_chat')] }) }))] }))] }));
149
+ };
150
+ export default withTestIds(GenAICoach, getGenAICoachTestIds);
151
+ //# sourceMappingURL=GenAICoach.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenAICoach.js","sourceRoot":"","sources":["../../../src/components/GenAICoach/GenAICoach.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtF,OAAO,EACL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,WAAW,EACX,aAAa,EACb,OAAO,EACP,UAAU,EACV,QAAQ,EACR,WAAW,EACX,IAAI,EACJ,YAAY,EACZ,WAAW,EACX,aAAa,EACb,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,WAAW,MAAM,iEAAiE,CAAC;AAC/F,OAAO,KAAK,SAAS,MAAM,8DAA8D,CAAC;AAC1F,OAAO,KAAK,aAAa,MAAM,mEAAmE,CAAC;AACnG,OAAO,KAAK,SAAS,MAAM,8DAA8D,CAAC;AAC1F,OAAO,KAAK,gBAAgB,MAAM,sEAAsE,CAAC;AAEzG,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,6BAA6B,EAC7B,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,aAA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C,KAAC,IAAI,IAAC,IAAI,EAAC,eAAe,GAAG,EAC5B,CAAC,CAAC,YAAY,CAAC,IACX,GACU,CACpB,IACF,CACJ,IACI,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport type { ChangeEvent, FunctionComponent } from 'react';\n\nimport {\n Button,\n Flex,\n Grid,\n Icon,\n MenuButton,\n Progress,\n Text,\n TextArea,\n createUID,\n menuHelpers,\n useBreakpoint,\n useI18n,\n useTestIds,\n useTheme,\n withTestIds,\n Card,\n registerIcon,\n usePrevious,\n getFocusables,\n isMenuGroupProps\n} from '@pega/cosmos-react-core';\nimport type { MenuItemProps, MenuProps } from '@pega/cosmos-react-core';\nimport * as caretUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-up.icon';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\nimport * as caretDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-down.icon';\nimport * as minusIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/minus.icon';\nimport * as polarisSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/polaris-solid.icon';\n\nimport CaseViewContext from '../CaseView/CaseView.context';\n\nimport { getGenAICoachTestIds } from './GenAICoach.test-ids';\nimport type { GenAICoachProps } from './GenAICoach.types';\nimport {\n StyledChatButton,\n StyledCloseButton,\n StyledMessagesContainer,\n StyledDisclaimerText,\n StyledGenAICoachContainer,\n StyledGenAIOptionsMenu,\n StyledInitialMessageContainer,\n StyledInputContainer,\n StyledMessageWrapper,\n StyledProgressContainer,\n StyledStarterMessage,\n StyledSuggestions\n} from './GenAICoach.styles';\nimport { isCoachMessage, isInUtilities, isUserMessage } from './GenAICoach.utils';\n\nimport { GenAIMessage, InitialSuggestedMessage } from '.';\n\nregisterIcon(caretUpIcon, timesIcon, caretDownIcon, minusIcon, polarisSolidIcon);\n\nconst GenAICoach: FunctionComponent<GenAICoachProps> = ({\n testId,\n coachOptions: coachOptionsProps,\n onCoachChange: onCoachChangeProp,\n messages = [],\n onSend,\n initialSuggestedMessages,\n suggestions,\n loading,\n starterMessage,\n variant,\n onOpen,\n ...restProps\n}) => {\n const elementRef = useRef<HTMLLIElement>(null);\n const conversationRef = useRef<HTMLUListElement>(null);\n const genAICoachRef = useRef<HTMLElement>(null);\n const textAreaRef = useRef<HTMLTextAreaElement>(null);\n\n const [message, setMessage] = useState('');\n const [coachOptions, setCoachOptions] = useState<MenuProps['items']>(coachOptionsProps);\n\n const smOrAbove = useBreakpoint('sm', { breakpointRef: genAICoachRef });\n const previousMessages = usePrevious(messages);\n const theme = useTheme();\n const t = useI18n();\n const { setGenAIHeight, aboveLG } = useContext(CaseViewContext);\n\n const testIds = useTestIds(testId, getGenAICoachTestIds);\n\n const onCoachChange = (id: MenuItemProps['id']) => {\n setCoachOptions(cur => menuHelpers.toggleSelected(cur, id, 'single-select'));\n onCoachChangeProp?.(id);\n };\n\n const selectedCoach = useMemo(() => {\n const selected = menuHelpers.getSelected(coachOptions)[0];\n if (selected) return selected.primary;\n if (coachOptions[0] && !isMenuGroupProps(coachOptions[0])) return coachOptions[0].primary;\n }, [coachOptions]);\n\n const handleEnterKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n onSend({\n id: createUID(),\n message\n });\n setMessage('');\n e.preventDefault();\n e.stopPropagation();\n }\n },\n [message]\n );\n\n const handleTextAreaChange = useCallback(\n (e: ChangeEvent<HTMLTextAreaElement>) => {\n setMessage(e.currentTarget.value);\n },\n [setMessage]\n );\n\n const scrollToBottom = () => {\n if (conversationRef.current) {\n conversationRef.current.scrollTop = conversationRef.current.scrollHeight;\n }\n };\n\n const headerContent = useMemo(() => {\n return isInUtilities(variant) && variant.state === 'docked' ? (\n <>\n <Flex container={{ gap: 2 }}>\n <Icon name='polaris-solid' color={theme.base.palette.ai} />\n <Text variant='h3'>{selectedCoach}</Text>\n </Flex>\n <Flex container={{ alignItems: 'center' }}>\n <Button\n icon\n label={t('maximize')}\n aria-label={t('maximize_gen_ai', [t('coach', ['Pega Gen AI'])])}\n variant='simple'\n onClick={() => variant.onStateChange('maximized')}\n >\n <Icon name='caret-up' />\n </Button>\n </Flex>\n </>\n ) : (\n <>\n <MenuButton\n text={selectedCoach || ''}\n variant='text'\n as={StyledGenAIOptionsMenu}\n icon='polaris-solid'\n menu={{\n mode: 'single-select',\n items: coachOptions,\n onItemClick: onCoachChange\n }}\n />\n\n {isInUtilities(variant) && (\n <Button\n icon\n label={t('minimize')}\n aria-label={t('minimize_gen_ai', [t('coach', ['Pega Gen AI'])])}\n variant='simple'\n onClick={() => variant.onStateChange('docked')}\n >\n <Icon name='minus' />\n </Button>\n )}\n {variant.placement === 'dialog' && (\n <Button\n icon\n label={t('close')}\n aria-label={t('close_gen_ai', [t('coach', ['Pega Gen AI'])])}\n variant='simple'\n onClick={variant.onClose}\n >\n <Icon name='times' />\n </Button>\n )}\n </>\n );\n }, [variant, coachOptions]);\n\n const onResize = () => {\n if (genAICoachRef.current) {\n const height = genAICoachRef.current.clientHeight;\n setGenAIHeight?.(height);\n }\n };\n\n useEffect(() => {\n if (isInUtilities(variant)) {\n onResize();\n }\n }, [variant]);\n\n useEffect(() => {\n onResize();\n if (variant.placement !== 'fullpage') {\n textAreaRef.current?.focus();\n }\n if (\n isInUtilities(variant) &&\n variant.state === 'docked' &&\n getFocusables(genAICoachRef).length > 0\n ) {\n getFocusables(genAICoachRef)[0].focus();\n }\n }, [textAreaRef.current]);\n\n useEffect(() => {\n onOpen?.();\n window.addEventListener('resize', onResize);\n\n return () => {\n window.removeEventListener('resize', onResize);\n };\n }, []);\n\n useEffect(() => {\n if (isInUtilities(variant) && variant.state !== 'maximized' && messages.length > 0) {\n variant.onStateChange('maximized');\n }\n if (messages.length > 0 && previousMessages?.length !== messages.length) {\n scrollToBottom();\n if (isUserMessage(messages[messages.length - 1])) textAreaRef.current?.focus();\n }\n }, [messages]);\n\n return (\n <Flex\n container={{ direction: 'column' }}\n as={StyledGenAICoachContainer}\n data-testid={testIds.root}\n variant={variant}\n starterMessage={starterMessage}\n ref={genAICoachRef}\n aboveLG={aboveLG}\n {...restProps}\n >\n <Flex container={{ justify: 'between', alignItems: 'center', pad: 1 }}>{headerContent}</Flex>\n {((isInUtilities(variant) && variant.state !== 'docked') || !isInUtilities(variant)) && (\n <>\n <Flex\n as={StyledMessagesContainer}\n ref={conversationRef}\n container={\n starterMessage || loading\n ? { direction: 'column', pad: [0, 2], justify: 'center' }\n : { direction: 'column', pad: [0, 2] }\n }\n item={{ grow: 1 }}\n >\n {loading && (\n <StyledProgressContainer container>\n <Progress variant='ring' placement='block' />\n </StyledProgressContainer>\n )}\n {!loading && messages.length === 0 && (\n <>\n {starterMessage ? (\n <Card\n container={{ alignItems: 'center', pad: 1.5 }}\n item={{ grow: 0 }}\n as={StyledStarterMessage}\n >\n {starterMessage.message}\n <StyledCloseButton\n icon\n label={t('close')}\n aria-label={`${t('close')} ${t('starter_message')}`}\n variant='simple'\n onClick={starterMessage.onClose}\n >\n <Icon name='times' />\n </StyledCloseButton>\n </Card>\n ) : (\n <Flex\n as={StyledInitialMessageContainer}\n container={{\n justify: 'center',\n direction: 'column',\n gap: 8\n }}\n item={{ grow: 1 }}\n >\n {((isInUtilities(variant) && variant.state === 'maximized') ||\n !isInUtilities(variant)) && (\n <Flex container={{ direction: 'column', alignItems: 'center', gap: 2 }}>\n <Icon name='polaris-solid' size='l' color={theme.base.palette.ai} />\n <Text variant='h2'>{t('welcome_text')}</Text>\n </Flex>\n )}\n <Grid container={{ cols: smOrAbove ? 'repeat(2, 1fr)' : '1fr', gap: 1.5 }}>\n {initialSuggestedMessages?.map(initialSuggestedMessage => (\n <InitialSuggestedMessage\n {...initialSuggestedMessage}\n onSend={initialMessage => {\n onSend(initialMessage);\n }}\n testId={initialSuggestedMessage.id}\n />\n ))}\n </Grid>\n </Flex>\n )}\n </>\n )}\n {!loading && messages.length > 0 && (\n <>\n {messages.map(item => {\n const messageProps = isCoachMessage(item)\n ? {\n ...item,\n onSend\n }\n : item;\n\n return (\n <StyledMessageWrapper ref={elementRef}>\n <GenAIMessage {...messageProps} testId={item.id} />\n </StyledMessageWrapper>\n );\n })}\n </>\n )}\n </Flex>\n\n {!starterMessage &&\n ((isInUtilities(variant) &&\n variant.state !== 'docked' &&\n variant.state !== 'minimized') ||\n !isInUtilities(variant)) && (\n <Flex container={{ direction: 'column' }} as={StyledInputContainer}>\n <TextArea\n ref={textAreaRef}\n label={t('message_pega_gen_ai_coach', [selectedCoach || ''])}\n value={message}\n onKeyDown={handleEnterKeyDown}\n onChange={handleTextAreaChange}\n autoResize={false}\n />\n <Flex container={{ direction: 'row', gap: 2, justify: 'end', pad: 1 }}>\n {suggestions && (\n <MenuButton\n text={t('suggestions')}\n variant='text'\n as={StyledSuggestions}\n icon='polaris-solid'\n menu={{\n items: suggestions,\n onItemClick: id => {\n const selected = menuHelpers.getItem(suggestions, id);\n if (selected) onSend({ id: selected.id, message: selected.primary });\n }\n }}\n />\n )}\n <Button\n variant='primary'\n onClick={\n message\n ? () => {\n onSend({\n id: createUID(),\n message\n });\n setMessage('');\n }\n : undefined\n }\n >\n {t('send')}\n </Button>\n </Flex>\n <StyledDisclaimerText>{t('ai_disclaimer')}</StyledDisclaimerText>\n </Flex>\n )}\n {!loading &&\n messages.length === 0 &&\n ((isInUtilities(variant) && variant.state === 'minimized') || starterMessage) && (\n <StyledChatButton\n icon\n onClick={() => {\n if (isInUtilities(variant)) variant.onStateChange('maximized');\n if (starterMessage && starterMessage.message) {\n onSend({ id: starterMessage.id, message: starterMessage.message });\n }\n }}\n >\n <Flex container={{ alignItems: 'center', gap: 1 }}>\n <Icon name='polaris-solid' />\n {t('start_chat')}\n </Flex>\n </StyledChatButton>\n )}\n </>\n )}\n </Flex>\n );\n};\n\nexport default withTestIds(GenAICoach, getGenAICoachTestIds);\n"]}
@@ -0,0 +1,29 @@
1
+ import type { CaseViewContextValue } from '../CaseView/CaseView.types';
2
+ import type { GenAICoachProps } from './GenAICoach.types';
3
+ export declare const StyledMessageWrapper: import("styled-components").StyledComponent<"li", import("styled-components").DefaultTheme, {}, never>;
4
+ export declare const StyledGenAICoachContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
5
+ variant: GenAICoachProps['variant'];
6
+ starterMessage: GenAICoachProps['starterMessage'];
7
+ aboveLG: CaseViewContextValue['aboveLG'];
8
+ }, never>;
9
+ export declare const StyledGenAIOptionsMenu: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").ForwardProps & import("@pega/cosmos-react-core").MenuButtonProps> & {
10
+ getTestIds: (testIdProp?: string | undefined) => import("@pega/cosmos-react-core").TestIdsRecord<readonly []>;
11
+ }, import("styled-components").DefaultTheme, {}, never>;
12
+ export declare const StyledSuggestions: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").ForwardProps & import("@pega/cosmos-react-core").MenuButtonProps> & {
13
+ getTestIds: (testIdProp?: string | undefined) => import("@pega/cosmos-react-core").TestIdsRecord<readonly []>;
14
+ }, import("styled-components").DefaultTheme, {}, never>;
15
+ export declare const StyledDisclaimerText: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").TextProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
16
+ export declare const StyledMessagesContainer: import("styled-components").StyledComponent<"ul", import("styled-components").DefaultTheme, {}, never>;
17
+ export declare const StyledStarterMessage: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
18
+ export declare const StyledCloseButton: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").ButtonProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
19
+ export declare const StyledInitialMessageContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
20
+ export declare const StyledInputContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
21
+ export declare const StyledProgressContainer: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").FlexProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
22
+ export declare const StyledChatButton: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").ButtonProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
23
+ export declare const StyledParagraph: import("styled-components").StyledComponent<"p", import("styled-components").DefaultTheme, {}, never>;
24
+ export declare const StyledSuggestion: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").ButtonProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
25
+ export declare const StyledSuggestionsContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
26
+ export declare const StyledTimeStamp: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").TextProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
27
+ export declare const StyledMessage: import("styled-components").StyledComponent<"p", import("styled-components").DefaultTheme, {}, never>;
28
+ export declare const StyledSuggestedMessage: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
29
+ //# sourceMappingURL=GenAICoach.styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenAICoach.styles.d.ts","sourceRoot":"","sources":["../../../src/components/GenAICoach/GenAICoach.styles.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG1D,eAAO,MAAM,oBAAoB,wGAAc,CAAC;AAEhD,eAAO,MAAM,yBAAyB;aAC3B,eAAe,CAAC,SAAS,CAAC;oBACnB,eAAe,CAAC,gBAAgB,CAAC;aACxC,oBAAoB,CAAC,SAAS,CAAC;SA0EzC,CAAC;AAIF,eAAO,MAAM,sBAAsB;;uDAqBjC,CAAC;AAIH,eAAO,MAAM,iBAAiB;;uDAc5B,CAAC;AAIH,eAAO,MAAM,oBAAoB,mOAW/B,CAAC;AAIH,eAAO,MAAM,uBAAuB,wGAgBnC,CAAC;AAIF,eAAO,MAAM,oBAAoB,yGAYhC,CAAC;AAIF,eAAO,MAAM,iBAAiB,qOAE7B,CAAC;AAIF,eAAO,MAAM,6BAA6B,yGAUzC,CAAC;AAIF,eAAO,MAAM,oBAAoB,yGAWhC,CAAC;AAIF,eAAO,MAAM,uBAAuB,mOAGnC,CAAC;AAEF,eAAO,MAAM,gBAAgB,qOAuB3B,CAAC;AAIH,eAAO,MAAM,eAAe,uGAI1B,CAAC;AAIH,eAAO,MAAM,gBAAgB,qOAS3B,CAAC;AAIH,eAAO,MAAM,0BAA0B,yGAUtC,CAAC;AAIF,eAAO,MAAM,eAAe,mOAK1B,CAAC;AAIH,eAAO,MAAM,aAAa,uGAKxB,CAAC;AAIH,eAAO,MAAM,sBAAsB,yGAcjC,CAAC"}
@@ -0,0 +1,211 @@
1
+ import styled, { css } from 'styled-components';
2
+ import { useContext } from 'react';
3
+ import { AppShellContext, Button, Flex, MenuButton, StyledIcon, StyledText, Text, calculateFontSize, defaultThemeProp, getHoverColors } from '@pega/cosmos-react-core';
4
+ import { isInUtilities } from './GenAICoach.utils';
5
+ export const StyledMessageWrapper = styled.li ``;
6
+ export const StyledGenAICoachContainer = styled.div(({ theme: { base: { palette, 'z-index': zIndex, spacing, breakpoints }, components: { card: { 'border-radius': borderRadius } } }, variant, aboveLG, starterMessage }) => {
7
+ const { previewActive } = useContext(AppShellContext);
8
+ return css `
9
+ background: ${palette['primary-background']};
10
+ min-width: var(--utilities-drawer-min-width);
11
+ border-radius: ${borderRadius};
12
+ ${isInUtilities(variant) &&
13
+ css `
14
+ min-height: 3rem;
15
+ max-width: 31.25rem;
16
+ box-shadow: 0 -1rem 1rem ${palette['app-background']};
17
+ position: fixed;
18
+ inset-block-end: calc(2 * ${spacing});
19
+ inset-inline-end: calc(2 * ${spacing});
20
+ z-index: calc(${zIndex.drawer} + 1);
21
+ ${aboveLG
22
+ ? css `
23
+ width: 25rem;
24
+ `
25
+ : css `
26
+ width: calc(var(--utilities-drawer-width) - 2rem);
27
+ `}
28
+
29
+ ${previewActive &&
30
+ css `
31
+ @media (min-width: ${breakpoints.xl}) {
32
+ margin-inline-end: clamp(21.875rem, (100vw - 31.25rem) / 10 + 21.875rem, 31.25rem);
33
+ }
34
+ `}
35
+
36
+ ${variant.state === 'minimized' &&
37
+ css `
38
+ max-height: 20rem;
39
+ height: 20rem;
40
+ `}
41
+
42
+ ${variant.state === 'docked' &&
43
+ css `
44
+ height: 3rem;
45
+ `}
46
+
47
+
48
+ &::after {
49
+ content: '';
50
+ height: calc(2 * ${spacing});
51
+ width: 100%;
52
+ background: ${palette['app-background']};
53
+ position: fixed;
54
+ inset-block-end: 0;
55
+ z-index: calc(${zIndex.drawer} + 1);
56
+ }
57
+ `}
58
+
59
+ /** 85 percent of Utilities height */
60
+ ${!starterMessage &&
61
+ ((isInUtilities(variant) && variant.state === 'maximized') || !isInUtilities(variant)) &&
62
+ css `
63
+ height: calc(0.85 * var(--case-view-height, 95vh));
64
+ `}
65
+ `;
66
+ });
67
+ StyledGenAICoachContainer.defaultProps = defaultThemeProp;
68
+ export const StyledGenAIOptionsMenu = styled(MenuButton)(({ theme: { base: { 'font-size': fontSize, 'font-scale': fontScale, 'font-weight': fontWeight, palette: { ai } } } }) => {
69
+ const { l } = calculateFontSize(fontSize, fontScale);
70
+ return css `
71
+ color: inherit;
72
+ ${StyledIcon}:first-child {
73
+ color: ${ai};
74
+ }
75
+ ${StyledText} {
76
+ font-weight: ${fontWeight['semi-bold']};
77
+ font-size: ${l};
78
+ }
79
+ `;
80
+ });
81
+ StyledGenAIOptionsMenu.defaultProps = defaultThemeProp;
82
+ export const StyledSuggestions = styled(MenuButton)(({ theme: { base: { 'font-size': fontSize, 'font-scale': fontScale, palette: { ai } } } }) => {
83
+ const { xxs: buttonFontSize } = calculateFontSize(fontSize, fontScale);
84
+ return css `
85
+ color: ${ai};
86
+ font-size: ${buttonFontSize};
87
+ `;
88
+ });
89
+ StyledSuggestions.defaultProps = defaultThemeProp;
90
+ export const StyledDisclaimerText = styled(Text)(({ theme: { base: { 'font-size': fontSize, 'font-scale': fontScale, spacing } } }) => {
91
+ const systemFontSize = calculateFontSize(fontSize, fontScale).xs;
92
+ return css `
93
+ font-size: ${systemFontSize};
94
+ margin-block-start: ${spacing};
95
+ opacity: 0.7;
96
+ `;
97
+ });
98
+ StyledDisclaimerText.defaultProps = defaultThemeProp;
99
+ export const StyledMessagesContainer = styled.ul(({ theme: { base: { spacing } } }) => {
100
+ return css `
101
+ list-style-type: none;
102
+ margin-block-end: calc(2 * ${spacing});
103
+ overflow-y: auto;
104
+
105
+ ${StyledMessageWrapper} {
106
+ padding-block: ${spacing};
107
+ }
108
+ `;
109
+ });
110
+ StyledMessagesContainer.defaultProps = defaultThemeProp;
111
+ export const StyledStarterMessage = styled.div(({ theme: { base: { palette, 'border-radius': borderRadius } } }) => {
112
+ return css `
113
+ border: 0.0625rem solid ${palette['border-line']};
114
+ border-radius: calc(0.5 * ${borderRadius});
115
+ max-height: 10rem;
116
+ `;
117
+ });
118
+ StyledStarterMessage.defaultProps = defaultThemeProp;
119
+ export const StyledCloseButton = styled(Button) `
120
+ align-self: flex-start;
121
+ `;
122
+ StyledCloseButton.defaultProps = defaultThemeProp;
123
+ export const StyledInitialMessageContainer = styled.div(({ theme: { base: { spacing } } }) => {
124
+ return css `
125
+ margin-block: calc(2 * ${spacing});
126
+ `;
127
+ });
128
+ StyledInitialMessageContainer.defaultProps = defaultThemeProp;
129
+ export const StyledInputContainer = styled.div(({ theme: { base: { spacing } } }) => {
130
+ return css `
131
+ margin-block-end: calc(2 * ${spacing});
132
+ margin-inline: calc(2 * ${spacing});
133
+ `;
134
+ });
135
+ StyledInputContainer.defaultProps = defaultThemeProp;
136
+ export const StyledProgressContainer = styled(Flex) `
137
+ height: 100%;
138
+ align-items: center;
139
+ `;
140
+ export const StyledChatButton = styled(Button)(({ theme: { base: { palette: { ai, 'primary-background': primaryBackground }, spacing } } }) => {
141
+ const hoverColors = getHoverColors(ai);
142
+ return css `
143
+ background-color: ${ai};
144
+ color: ${primaryBackground};
145
+ border: none;
146
+ margin: ${spacing};
147
+ &:hover {
148
+ background-color: ${hoverColors.background};
149
+ color: ${hoverColors.foreground};
150
+ border: none;
151
+ }
152
+ &:focus {
153
+ border: none;
154
+ }
155
+ `;
156
+ });
157
+ StyledChatButton.defaultProps = defaultThemeProp;
158
+ export const StyledParagraph = styled.p(({ theme }) => {
159
+ return css `
160
+ margin-block-start: calc(0.5 * ${theme.base.spacing});
161
+ `;
162
+ });
163
+ StyledParagraph.defaultProps = defaultThemeProp;
164
+ export const StyledSuggestion = styled(Button)(({ theme }) => {
165
+ return css `
166
+ width: fit-content;
167
+ & + & {
168
+ margin-inline-start: 0;
169
+ text-align: left;
170
+ padding: ${theme.base.spacing};
171
+ }
172
+ `;
173
+ });
174
+ StyledSuggestion.defaultProps = defaultThemeProp;
175
+ export const StyledSuggestionsContainer = styled.div(({ theme: { base: { spacing } } }) => {
176
+ return css `
177
+ margin-block-start: calc(1.5 * ${spacing});
178
+ `;
179
+ });
180
+ StyledSuggestionsContainer.defaultProps = defaultThemeProp;
181
+ export const StyledTimeStamp = styled(Text)(() => {
182
+ return css `
183
+ display: flex;
184
+ align-items: center;
185
+ `;
186
+ });
187
+ StyledTimeStamp.defaultProps = defaultThemeProp;
188
+ export const StyledMessage = styled.p(({ theme }) => {
189
+ return css `
190
+ margin-block-start: calc(0.5 * ${theme.base.spacing});
191
+ overflow-wrap: break-word;
192
+ `;
193
+ });
194
+ StyledMessage.defaultProps = defaultThemeProp;
195
+ export const StyledSuggestedMessage = styled.div(({ theme }) => {
196
+ return css `
197
+ column-gap: calc(2 * ${theme.base.spacing});
198
+ min-height: 2rem;
199
+ text-align: left;
200
+ border: 0.0625rem solid ${theme.base.palette['border-line']};
201
+ border-radius: calc(0.5 * ${theme.base['border-radius']});
202
+ padding-inline-end: calc(2 * ${theme.base.spacing});
203
+ cursor: pointer;
204
+ &:hover,
205
+ &:focus {
206
+ border: 0.0625rem solid ${theme.base.palette.interactive};
207
+ }
208
+ `;
209
+ });
210
+ StyledSuggestedMessage.defaultProps = defaultThemeProp;
211
+ //# sourceMappingURL=GenAICoach.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenAICoach.styles.js","sourceRoot":"","sources":["../../../src/components/GenAICoach/GenAICoach.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EACL,eAAe,EACf,MAAM,EACN,IAAI,EACJ,UAAU,EACV,UAAU,EACV,UAAU,EACV,IAAI,EACJ,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACf,MAAM,yBAAyB,CAAC;AAKjC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,EAAE,CAAA,EAAE,CAAC;AAEhD,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,GAAG,CAKjD,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,EAC1D,UAAU,EAAE,EACV,IAAI,EAAE,EAAE,eAAe,EAAE,YAAY,EAAE,EACxC,EACF,EACD,OAAO,EACP,OAAO,EACP,cAAc,EACf,EAAE,EAAE;IACH,MAAM,EAAE,aAAa,E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AG,EAAE;IAC/C,OAAO,GAAG,CAAA;;;GAGT,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEhD,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAClD,OAAO,GAAG,CAAA;qCACyB,KAAK,CAAC,IAAI,CAAC,OAAO;;GAEpD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,aAAa,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE9C,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC7D,OAAO,GAAG,CAAA;2BACe,KAAK,CAAC,IAAI,CAAC,OAAO;;;8BAGf,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;gCAC/B,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;mCACxB,KAAK,CAAC,IAAI,CAAC,OAAO;;;;gCAIrB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW;;GAE3D,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,sBAAsB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport { useContext } from 'react';\n\nimport {\n AppShellContext,\n Button,\n Flex,\n MenuButton,\n StyledIcon,\n StyledText,\n Text,\n calculateFontSize,\n defaultThemeProp,\n getHoverColors\n} from '@pega/cosmos-react-core';\n\nimport type { CaseViewContextValue } from '../CaseView/CaseView.types';\n\nimport type { GenAICoachProps } from './GenAICoach.types';\nimport { isInUtilities } from './GenAICoach.utils';\n\nexport const StyledMessageWrapper = styled.li``;\n\nexport const StyledGenAICoachContainer = styled.div<{\n variant: GenAICoachProps['variant'];\n starterMessage: GenAICoachProps['starterMessage'];\n aboveLG: CaseViewContextValue['aboveLG'];\n}>(\n ({\n theme: {\n base: { palette, 'z-index': zIndex, spacing, breakpoints },\n components: {\n card: { 'border-radius': borderRadius }\n }\n },\n variant,\n aboveLG,\n starterMessage\n }) => {\n const { previewActive } = useContext(AppShellContext);\n\n return css`\n background: ${palette['primary-background']};\n min-width: var(--utilities-drawer-min-width);\n border-radius: ${borderRadius};\n ${isInUtilities(variant) &&\n css`\n min-height: 3rem;\n max-width: 31.25rem;\n box-shadow: 0 -1rem 1rem ${palette['app-background']};\n position: fixed;\n inset-block-end: calc(2 * ${spacing});\n inset-inline-end: calc(2 * ${spacing});\n z-index: calc(${zIndex.drawer} + 1);\n ${aboveLG\n ? css`\n width: 25rem;\n `\n : css`\n width: calc(var(--utilities-drawer-width) - 2rem);\n `}\n\n ${previewActive &&\n css`\n @media (min-width: ${breakpoints.xl}) {\n margin-inline-end: clamp(21.875rem, (100vw - 31.25rem) / 10 + 21.875rem, 31.25rem);\n }\n `}\n\n ${variant.state === 'minimized' &&\n css`\n max-height: 20rem;\n height: 20rem;\n `}\n\n ${variant.state === 'docked' &&\n css`\n height: 3rem;\n `}\n\n\n &::after {\n content: '';\n height: calc(2 * ${spacing});\n width: 100%;\n background: ${palette['app-background']};\n position: fixed;\n inset-block-end: 0;\n z-index: calc(${zIndex.drawer} + 1);\n }\n `}\n\n /** 85 percent of Utilities height */\n ${!starterMessage &&\n ((isInUtilities(variant) && variant.state === 'maximized') || !isInUtilities(variant)) &&\n css`\n height: calc(0.85 * var(--case-view-height, 95vh));\n `}\n `;\n }\n);\n\nStyledGenAICoachContainer.defaultProps = defaultThemeProp;\n\nexport const StyledGenAIOptionsMenu = styled(MenuButton)(({\n theme: {\n base: {\n 'font-size': fontSize,\n 'font-scale': fontScale,\n 'font-weight': fontWeight,\n palette: { ai }\n }\n }\n}) => {\n const { l } = calculateFontSize(fontSize, fontScale);\n return css`\n color: inherit;\n ${StyledIcon}:first-child {\n color: ${ai};\n }\n ${StyledText} {\n font-weight: ${fontWeight['semi-bold']};\n font-size: ${l};\n }\n `;\n});\n\nStyledGenAIOptionsMenu.defaultProps = defaultThemeProp;\n\nexport const StyledSuggestions = styled(MenuButton)(({\n theme: {\n base: {\n 'font-size': fontSize,\n 'font-scale': fontScale,\n palette: { ai }\n }\n }\n}) => {\n const { xxs: buttonFontSize } = calculateFontSize(fontSize, fontScale);\n return css`\n color: ${ai};\n font-size: ${buttonFontSize};\n `;\n});\n\nStyledSuggestions.defaultProps = defaultThemeProp;\n\nexport const StyledDisclaimerText = styled(Text)(({\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing }\n }\n}) => {\n const systemFontSize = calculateFontSize(fontSize, fontScale).xs;\n return css`\n font-size: ${systemFontSize};\n margin-block-start: ${spacing};\n opacity: 0.7;\n `;\n});\n\nStyledDisclaimerText.defaultProps = defaultThemeProp;\n\nexport const StyledMessagesContainer = styled.ul(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n return css`\n list-style-type: none;\n margin-block-end: calc(2 * ${spacing});\n overflow-y: auto;\n\n ${StyledMessageWrapper} {\n padding-block: ${spacing};\n }\n `;\n }\n);\n\nStyledMessagesContainer.defaultProps = defaultThemeProp;\n\nexport const StyledStarterMessage = styled.div(\n ({\n theme: {\n base: { palette, 'border-radius': borderRadius }\n }\n }) => {\n return css`\n border: 0.0625rem solid ${palette['border-line']};\n border-radius: calc(0.5 * ${borderRadius});\n max-height: 10rem;\n `;\n }\n);\n\nStyledStarterMessage.defaultProps = defaultThemeProp;\n\nexport const StyledCloseButton = styled(Button)`\n align-self: flex-start;\n`;\n\nStyledCloseButton.defaultProps = defaultThemeProp;\n\nexport const StyledInitialMessageContainer = styled.div(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n return css`\n margin-block: calc(2 * ${spacing});\n `;\n }\n);\n\nStyledInitialMessageContainer.defaultProps = defaultThemeProp;\n\nexport const StyledInputContainer = styled.div(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n return css`\n margin-block-end: calc(2 * ${spacing});\n margin-inline: calc(2 * ${spacing});\n `;\n }\n);\n\nStyledInputContainer.defaultProps = defaultThemeProp;\n\nexport const StyledProgressContainer = styled(Flex)`\n height: 100%;\n align-items: center;\n`;\n\nexport const StyledChatButton = styled(Button)(({\n theme: {\n base: {\n palette: { ai, 'primary-background': primaryBackground },\n spacing\n }\n }\n}) => {\n const hoverColors = getHoverColors(ai);\n return css`\n background-color: ${ai};\n color: ${primaryBackground};\n border: none;\n margin: ${spacing};\n &:hover {\n background-color: ${hoverColors.background};\n color: ${hoverColors.foreground};\n border: none;\n }\n &:focus {\n border: none;\n }\n `;\n});\n\nStyledChatButton.defaultProps = defaultThemeProp;\n\nexport const StyledParagraph = styled.p(({ theme }) => {\n return css`\n margin-block-start: calc(0.5 * ${theme.base.spacing});\n `;\n});\n\nStyledParagraph.defaultProps = defaultThemeProp;\n\nexport const StyledSuggestion = styled(Button)(({ theme }) => {\n return css`\n width: fit-content;\n & + & {\n margin-inline-start: 0;\n text-align: left;\n padding: ${theme.base.spacing};\n }\n `;\n});\n\nStyledSuggestion.defaultProps = defaultThemeProp;\n\nexport const StyledSuggestionsContainer = styled.div(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n return css`\n margin-block-start: calc(1.5 * ${spacing});\n `;\n }\n);\n\nStyledSuggestionsContainer.defaultProps = defaultThemeProp;\n\nexport const StyledTimeStamp = styled(Text)(() => {\n return css`\n display: flex;\n align-items: center;\n `;\n});\n\nStyledTimeStamp.defaultProps = defaultThemeProp;\n\nexport const StyledMessage = styled.p(({ theme }) => {\n return css`\n margin-block-start: calc(0.5 * ${theme.base.spacing});\n overflow-wrap: break-word;\n `;\n});\n\nStyledMessage.defaultProps = defaultThemeProp;\n\nexport const StyledSuggestedMessage = styled.div(({ theme }) => {\n return css`\n column-gap: calc(2 * ${theme.base.spacing});\n min-height: 2rem;\n text-align: left;\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n padding-inline-end: calc(2 * ${theme.base.spacing});\n cursor: pointer;\n &:hover,\n &:focus {\n border: 0.0625rem solid ${theme.base.palette.interactive};\n }\n `;\n});\n\nStyledSuggestedMessage.defaultProps = defaultThemeProp;\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const getGenAICoachTestIds: (testIdProp?: string | undefined) => import("@pega/cosmos-react-core").TestIdsRecord<readonly []>;
2
+ //# sourceMappingURL=GenAICoach.test-ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenAICoach.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/GenAICoach/GenAICoach.test-ids.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,mGAA6C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { createTestIds } from '@pega/cosmos-react-core';
2
+ export const getGenAICoachTestIds = createTestIds('gen-ai-coach', []);
3
+ //# sourceMappingURL=GenAICoach.test-ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenAICoach.test-ids.js","sourceRoot":"","sources":["../../../src/components/GenAICoach/GenAICoach.test-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAC,cAAc,EAAE,EAAW,CAAC,CAAC","sourcesContent":["import { createTestIds } from '@pega/cosmos-react-core';\n\nexport const getGenAICoachTestIds = createTestIds('gen-ai-coach', [] as const);\n"]}
@@ -0,0 +1,53 @@
1
+ import type { BaseProps, MenuProps, RequireAtLeastOne, TestIdProp, WithAttributes } from '@pega/cosmos-react-core';
2
+ export type State = 'docked' | 'minimized' | 'maximized';
3
+ export type Variant = {
4
+ placement: 'utilities';
5
+ state: State;
6
+ onStateChange: (state: State) => void;
7
+ } | {
8
+ placement: 'fullpage';
9
+ } | {
10
+ placement: 'dialog';
11
+ onClose: () => void;
12
+ };
13
+ export interface MessageProps {
14
+ id: string;
15
+ message: string;
16
+ }
17
+ export type InitialSuggestedMessageProps = Pick<GenAICoachProps, 'onSend'> & BaseProps & TestIdProp & MessageProps;
18
+ export interface UserMessageProps extends BaseProps, TestIdProp, MessageProps {
19
+ from: 'user';
20
+ }
21
+ export type CoachMessageProps = RequireAtLeastOne<Partial<Pick<GenAICoachProps, 'onSend'>> & BaseProps & TestIdProp & Pick<MessageProps, 'id'> & {
22
+ from: 'coach';
23
+ coachName: string;
24
+ suggestions?: MessageProps[];
25
+ loading?: boolean;
26
+ message?: MessageProps['message'];
27
+ }, 'loading' | 'message'>;
28
+ export type GenAIMessageProps = UserMessageProps | CoachMessageProps;
29
+ export type GenAICoachProps = WithAttributes<'div', TestIdProp & {
30
+ /** Chat loading indicator */
31
+ loading?: boolean;
32
+ /** Coaches available in the chat header */
33
+ coachOptions: MenuProps['items'];
34
+ /** Handle the coach selections */
35
+ onCoachChange: (id: MenuProps['id']) => void;
36
+ /** Suggested messages to start the conversation */
37
+ initialSuggestedMessages?: MessageProps[];
38
+ /** Additional suggestions presented at the bottom of the chat window */
39
+ suggestions?: MenuProps['items'];
40
+ /** Send prompts */
41
+ onSend: (message: MessageProps) => void;
42
+ /** Messages to be shown in the chatting window. */
43
+ messages?: GenAIMessageProps[];
44
+ /** starter message */
45
+ starterMessage?: GenAIMessageProps & {
46
+ onClose: () => void;
47
+ };
48
+ /** Placement of the component */
49
+ variant: Variant;
50
+ /** callback when component is mounted */
51
+ onOpen?: () => void;
52
+ }>;
53
+ //# sourceMappingURL=GenAICoach.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenAICoach.types.d.ts","sourceRoot":"","sources":["../../../src/components/GenAICoach/GenAICoach.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,KAAK,GAAG,QAAQ,GAAG,WAAW,GAAG,WAAW,CAAC;AAEzD,MAAM,MAAM,OAAO,GACf;IACE,SAAS,EAAE,W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AS,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IAC7C,mDAAmD;IACnD,wBAAwB,CAAC,EAAE,YAAY,EAAE,CAAC;IAC1C,wEAAwE;IACxE,WAAW,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,mBAAmB;IACnB,MAAM,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC,mDAAmD;IACnD,QAAQ,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC/B,sBAAsB;IACtB,cAAc,CAAC,EAAE,iBAAiB,GAAG;QAAE,OAAO,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC;IAC7D,mCAAmC;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB,CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=GenAICoach.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenAICoach.types.js","sourceRoot":"","sources":["../../../src/components/GenAICoach/GenAICoach.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n BaseProps,\n MenuProps,\n RequireAtLeastOne,\n TestIdProp,\n WithAttributes\n} from '@pega/cosmos-react-core';\n\nexport type State = 'docked' | 'minimized' | 'maximized';\n\nexport type Variant =\n | {\n placement: 'utilities';\n state: State;\n onStateChange: (state: State) => void;\n }\n | { placement: 'fullpage' }\n | { placement: 'dialog'; onClose: () => void };\n\nexport interface MessageProps {\n id: string;\n message: string;\n}\nexport type InitialSuggestedMessageProps = Pick<GenAICoachProps, 'onSend'> &\n BaseProps &\n TestIdProp &\n MessageProps;\n\nexport interface UserMessageProps extends BaseProps, TestIdProp, MessageProps {\n from: 'user';\n}\n\nexport type CoachMessageProps = RequireAtLeastOne<\n Partial<Pick<GenAICoachProps, 'onSend'>> &\n BaseProps &\n TestIdProp &\n Pick<MessageProps, 'id'> & {\n from: 'coach';\n coachName: string;\n suggestions?: MessageProps[];\n loading?: boolean;\n message?: MessageProps['message'];\n },\n 'loading' | 'message'\n>;\n\nexport type GenAIMessageProps = UserMessageProps | CoachMessageProps;\n\nexport type GenAICoachProps = WithAttributes<\n 'div',\n TestIdProp & {\n /** Chat loading indicator */\n loading?: boolean;\n /** Coaches available in the chat header */\n coachOptions: MenuProps['items'];\n /** Handle the coach selections */\n onCoachChange: (id: MenuProps['id']) => void;\n /** Suggested messages to start the conversation */\n initialSuggestedMessages?: MessageProps[];\n /** Additional suggestions presented at the bottom of the chat window */\n suggestions?: MenuProps['items'];\n /** Send prompts */\n onSend: (message: MessageProps) => void;\n /** Messages to be shown in the chatting window. */\n messages?: GenAIMessageProps[];\n /** starter message */\n starterMessage?: GenAIMessageProps & { onClose: () => void };\n /** Placement of the component */\n variant: Variant;\n /** callback when component is mounted */\n onOpen?: () => void;\n }\n>;\n"]}
@@ -0,0 +1,9 @@
1
+ import type { CoachMessageProps, GenAIMessageProps, State, UserMessageProps, Variant } from './GenAICoach.types';
2
+ export declare const isCoachMessage: (message: GenAIMessageProps) => message is CoachMessageProps;
3
+ export declare const isUserMessage: (message: GenAIMessageProps) => message is UserMessageProps;
4
+ export declare const isInUtilities: (item: Variant) => item is {
5
+ placement: 'utilities';
6
+ state: State;
7
+ onStateChange: (state: State) => void;
8
+ };
9
+ //# sourceMappingURL=GenAICoach.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenAICoach.utils.d.ts","sourceRoot":"","sources":["../../../src/components/GenAICoach/GenAICoach.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,EACL,gBAAgB,EAChB,OAAO,EACR,MAAM,oBAAoB,CAAC;AAE5B,eAAO,MAAM,cAAc,YAAa,iBAAiB,iCAExD,CAAC;AAEF,eAAO,MAAM,aAAa,YAAa,iBAAiB,gCAEvD,CAAC;AAEF,eAAO,MAAM,aAAa,SAClB,OAAO;eAEF,WAAW;WACf,KAAK;2BACW,KAAK,KAAK,IAAI;CAGtC,CAAC"}
@@ -0,0 +1,10 @@
1
+ export const isCoachMessage = (message) => {
2
+ return message.from === 'coach';
3
+ };
4
+ export const isUserMessage = (message) => {
5
+ return message.from === 'user';
6
+ };
7
+ export const isInUtilities = (item) => {
8
+ return item.placement === 'utilities';
9
+ };
10
+ //# sourceMappingURL=GenAICoach.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenAICoach.utils.js","sourceRoot":"","sources":["../../../src/components/GenAICoach/GenAICoach.utils.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAA0B,EAAgC,EAAE;IACzF,OAAO,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC;AAClC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAA0B,EAA+B,EAAE;IACvF,OAAO,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC;AACjC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,IAAa,EAKb,EAAE;IACF,OAAO,IAAI,CAAC,SAAS,KAAK,WAAW,CAAC;AACxC,CAAC,CAAC","sourcesContent":["import type {\n CoachMessageProps,\n GenAIMessageProps,\n State,\n UserMessageProps,\n Variant\n} from './GenAICoach.types';\n\nexport const isCoachMessage = (message: GenAIMessageProps): message is CoachMessageProps => {\n return message.from === 'coach';\n};\n\nexport const isUserMessage = (message: GenAIMessageProps): message is UserMessageProps => {\n return message.from === 'user';\n};\n\nexport const isInUtilities = (\n item: Variant\n): item is {\n placement: 'utilities';\n state: State;\n onStateChange: (state: State) => void;\n} => {\n return item.placement === 'utilities';\n};\n"]}
@@ -0,0 +1,5 @@
1
+ import type { FunctionComponent } from 'react';
2
+ import type { GenAIMessageProps } from './GenAICoach.types';
3
+ declare const GenAIMessage: FunctionComponent<GenAIMessageProps>;
4
+ export default GenAIMessage;
5
+ //# sourceMappingURL=GenAIMessage.d.ts.map