@pega/cosmos-react-work 9.5.4 → 9.5.5-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/AppAnnouncement/AppAnnouncement.d.ts +2 -0
- package/lib/components/AppAnnouncement/AppAnnouncement.d.ts.map +1 -1
- package/lib/components/AppAnnouncement/AppAnnouncement.js +8 -3
- package/lib/components/AppAnnouncement/AppAnnouncement.js.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.d.ts.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.js +183 -34
- package/lib/components/GenAICoach/GenAICoach.js.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.styles.d.ts +216 -9
- package/lib/components/GenAICoach/GenAICoach.styles.d.ts.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.styles.js +148 -57
- package/lib/components/GenAICoach/GenAICoach.styles.js.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.types.d.ts +19 -3
- 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/GenAICoach.utils.d.ts +2 -1
- package/lib/components/GenAICoach/GenAICoach.utils.d.ts.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.utils.js +1 -0
- package/lib/components/GenAICoach/GenAICoach.utils.js.map +1 -1
- package/lib/components/GenAICoach/GenAIMessage.d.ts.map +1 -1
- package/lib/components/GenAICoach/GenAIMessage.js +35 -17
- package/lib/components/GenAICoach/GenAIMessage.js.map +1 -1
- package/lib/components/GenAICoach/Questionnaire.d.ts.map +1 -1
- package/lib/components/GenAICoach/Questionnaire.js +20 -21
- package/lib/components/GenAICoach/Questionnaire.js.map +1 -1
- package/lib/components/Shortcuts/Shortcuts.d.ts.map +1 -1
- package/lib/components/Shortcuts/Shortcuts.js +20 -10
- package/lib/components/Shortcuts/Shortcuts.js.map +1 -1
- package/lib/components/Shortcuts/Shortcuts.styles.d.ts +1 -0
- package/lib/components/Shortcuts/Shortcuts.styles.d.ts.map +1 -1
- package/lib/components/Shortcuts/Shortcuts.styles.js +6 -1
- package/lib/components/Shortcuts/Shortcuts.styles.js.map +1 -1
- package/lib/components/Tasks/TaskCard.js +1 -1
- package/lib/components/Tasks/TaskCard.js.map +1 -1
- package/lib/components/Tasks/TaskList.d.ts +2 -1
- package/lib/components/Tasks/TaskList.d.ts.map +1 -1
- package/lib/components/Tasks/TaskList.js +25 -17
- package/lib/components/Tasks/TaskList.js.map +1 -1
- package/lib/components/Tasks/Tasks.d.ts +5 -0
- package/lib/components/Tasks/Tasks.d.ts.map +1 -1
- package/lib/components/Tasks/Tasks.js +7 -5
- package/lib/components/Tasks/Tasks.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, forwardRef, useEffect, useMemo, useRef } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { readableColor, transparentize } from 'polished';
|
|
4
|
+
import { Avatar, Button, Flex, Progress, registerIcon, useI18n, useTestIds, ErrorState, markdownToPlainText, Actions, Icon, useModalManager, ThemeOverride, useTheme, calculateForegroundColor, tryCatch } from '@pega/cosmos-react-core';
|
|
4
5
|
import * as polarisSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/polaris-solid.icon';
|
|
5
6
|
import * as brainIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/brain.icon';
|
|
6
7
|
import { RichTextViewer } from '@pega/cosmos-react-rte';
|
|
7
8
|
import { useAnimatedText } from '@pega/cosmos-react-core';
|
|
8
|
-
import { StyledActionsContainer, StyledAttachmentsList, StyledMessage, StyledSuggestion, StyledSuggestionsContainer, StyledSystemMessage, StyledUserMessage } from './GenAICoach.styles';
|
|
9
|
+
import { StyledActionsContainer, StyledAttachmentsList, StyledGenAIAvatar, StyledMessageSender, StyledMessage, StyledSuggestion, StyledSuggestionsContainer, StyledSystemMessage, StyledUserMessage } from './GenAICoach.styles';
|
|
9
10
|
import { getGenAICoachTestIds } from './GenAICoach.test-ids';
|
|
10
11
|
import { isCoachMessage, isUserMessage } from './GenAICoach.utils';
|
|
11
12
|
import GenAIMessageProgress from './GenAIMessageProgress';
|
|
@@ -30,8 +31,9 @@ const GenAIMessage = forwardRef(function GenAIMessage(props, ref) {
|
|
|
30
31
|
const testIds = useTestIds(props.testId, getGenAICoachTestIds);
|
|
31
32
|
const t = useI18n();
|
|
32
33
|
const { create } = useModalManager();
|
|
34
|
+
const theme = useTheme();
|
|
33
35
|
const modalMethodsRef = useRef(null);
|
|
34
|
-
const { message, announceInteraction, ...restProps } = props;
|
|
36
|
+
const { message, announceInteraction, simplifiedAgent, ...restProps } = props;
|
|
35
37
|
const isStringMessage = typeof message === 'string';
|
|
36
38
|
const rawPlainTextMessage = isStringMessage ? markdownToPlainText(message ?? '') : '';
|
|
37
39
|
let fallbackAriaLabel = '';
|
|
@@ -89,7 +91,9 @@ const GenAIMessage = forwardRef(function GenAIMessage(props, ref) {
|
|
|
89
91
|
return { isStreamingMessage, isStreamingInProgress: isCoachMessage(props) && props.loading };
|
|
90
92
|
}, [isStreamingMessage, props]);
|
|
91
93
|
if (isCoachMessage(props)) {
|
|
92
|
-
const { id: messageId, coachName, suggestions, onSend, loading, error, feedback, markdownMap, messageActions } = props;
|
|
94
|
+
const { id: messageId, coachName, suggestions, onSend, loading, error, feedback, markdownMap, messageActions, showSenderInfo } = props;
|
|
95
|
+
const agentBackground = theme.components.agent.background;
|
|
96
|
+
const agentForeground = calculateForegroundColor(agentBackground, theme.components.agent['foreground-color']);
|
|
93
97
|
const { reaction } = feedback ?? {};
|
|
94
98
|
const { toolState, onViewToolsConsidered } = toolCandidates ?? {};
|
|
95
99
|
let selectedFeedbackResponse;
|
|
@@ -120,16 +124,26 @@ const GenAIMessage = forwardRef(function GenAIMessage(props, ref) {
|
|
|
120
124
|
onViewToolsConsidered?.(messageId);
|
|
121
125
|
};
|
|
122
126
|
const streamingContent = isStreamingMessage && (_jsx(_Fragment, { children: message ? (_jsxs(_Fragment, { children: [_jsx(StreamingContext.Provider, { value: streamingContext, children: isStringMessage ? (_jsx(RichTextViewer, { content: isStreamingMessage ? streamingMessage : message, type: 'markdown', markdownMap: markdownMap })) : (message) }), loading && _jsx(Progress, { variant: 'ellipsis', placement: 'inline' })] })) : ((loading || props.progressSteps?.length) && (_jsx(GenAIMessageProgress, { messages: props.progressSteps?.length ? props.progressSteps : undefined, completedSteps: props.progressSteps?.length ? props.progressStepsCompleted : undefined }))) }));
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
const messageContent = (_jsxs(StyledMessage, { simplified: simplifiedAgent && !showSenderInfo, children: [streamingContent, loading || error ? (_jsxs(_Fragment, { children: [loading && !isStreamingMessage && (_jsx(LoadingContent, { message: isStringMessage ? message : undefined, markdownMap: markdownMap, progressSteps: props.progressSteps, progressStepsCompleted: props.progressStepsCompleted })), error && _jsx(ErrorState, { message: error })] })) : (_jsxs(_Fragment, { children: [!isStreamingMessage &&
|
|
128
|
+
message &&
|
|
129
|
+
(isStringMessage ? (_jsx(RichTextViewer, { content: message, type: 'markdown', markdownMap: markdownMap })) : (message)), props.isToolConfirmation && _jsx(ToolConfirmationMessage, { ...props }), (feedback || messageActions || onViewToolsConsidered) && (_jsxs(Flex, { container: {
|
|
130
|
+
direction: 'row',
|
|
131
|
+
gap: 1,
|
|
132
|
+
pad: [1, undefined],
|
|
133
|
+
alignItems: 'center'
|
|
134
|
+
}, as: StyledActionsContainer, children: [feedback && (_jsx(GenAIMessageFeedbackButtons, { messageId: messageId, feedback: feedback })), onViewToolsConsidered && (_jsx(Button, { label: t('semantic_discovery_results'), variant: 'simple', icon: true, compact: true, onClick: onClickToolsConsidered, children: _jsx(Icon, { name: 'brain' }) })), messageActions && _jsx(Actions, { ...messageActions })] })), suggestions && suggestions.length > 0 && (_jsx(Flex, { as: StyledSuggestionsContainer, container: { gap: 1, justify: 'end', wrap: 'wrap' }, children: suggestions.map(({ id, message: prompt, selected }) => {
|
|
135
|
+
return (_jsx(Button, { as: StyledSuggestion, onClick: onSend ? () => onSend({ id, message: prompt }) : undefined, variant: selected ? 'primary' : undefined, children: prompt }, id));
|
|
136
|
+
}) }))] }))] }));
|
|
137
|
+
return (_jsx(ThemeOverride, { theme: {
|
|
138
|
+
base: {
|
|
139
|
+
palette: {
|
|
140
|
+
'foreground-color': agentForeground,
|
|
141
|
+
...(simplifiedAgent && {
|
|
142
|
+
'secondary-background': tryCatch(() => transparentize(0.7, readableColor(agentForeground)))
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}, children: _jsx(Flex, { as: 'li', "data-testid": testIds.coachMessage, ...restProps, container: { direction: 'row', pad: [1, 0], gap: 1 }, type: 'message', "aria-label": ariaLabel, ref: ref, children: simplifiedAgent ? (_jsxs(_Fragment, { children: [showSenderInfo && (_jsx(StyledGenAIAvatar, { size: 'l', name: coachName ?? t('agent'), icon: 'polaris-solid' })), _jsxs(Flex, { item: { grow: 1 }, container: { direction: 'column', gap: 0.75 }, children: [coachName && showSenderInfo && (_jsx(StyledMessageSender, { variant: 'primary', children: coachName })), messageContent] })] })) : (messageContent) }) }));
|
|
133
147
|
}
|
|
134
148
|
if (isUserMessage(props)) {
|
|
135
149
|
if (plainTextMessage) {
|
|
@@ -138,9 +152,13 @@ const GenAIMessage = forwardRef(function GenAIMessage(props, ref) {
|
|
|
138
152
|
if (announceInteraction) {
|
|
139
153
|
ariaLabel = `${ariaLabel} ${t('interaction_message')}`;
|
|
140
154
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
155
|
+
const attachmentsAndMessage = (_jsxs(_Fragment, { children: [props.attachments && props.attachments.length > 0 && (_jsx(StyledAttachmentsList, { type: 'display', items: props.attachments })), props.message && _jsx(RichTextViewer, { content: props.message, type: 'markdown' })] }));
|
|
156
|
+
if (!simplifiedAgent) {
|
|
157
|
+
return (_jsx(StyledUserMessage, { "data-testid": testIds.userMessage, ...restProps,
|
|
158
|
+
// @ts-expect-error FIXME: Need to validate if we can remove message, and double 'as'
|
|
159
|
+
type: 'message', "aria-label": ariaLabel, ref: ref, children: attachmentsAndMessage }));
|
|
160
|
+
}
|
|
161
|
+
return (_jsxs(Flex, { as: 'li', "data-testid": testIds.userMessage, ...restProps, container: { direction: 'row', gap: 1, justify: 'end', alignItems: 'start' }, type: 'message', "aria-label": ariaLabel, ref: ref, children: [_jsxs(Flex, { container: { direction: 'column', alignItems: 'end', gap: 0.75 }, children: [props.userName !== undefined && (_jsx(StyledMessageSender, { variant: 'primary', children: props.userName.split(' ')[0] || t('you') })), _jsx(StyledUserMessage, { as: 'div', children: attachmentsAndMessage })] }), props.userName && _jsx(Avatar, { name: props.userName, size: 'l', shape: 'circle' })] }));
|
|
144
162
|
}
|
|
145
163
|
if (props.from === 'system') {
|
|
146
164
|
const displayMessage = props.stopped && !message ? t('generation_stopped') : message;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenAIMessage.js","sourceRoot":"","sources":["../../../src/components/GenAICoach/GenAIMessage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG9E,OAAO,EACL,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,OAAO,EACP,UAAU,EACV,UAAU,EACV,mBAAmB,EAEnB,OAAO,EACP,IAAI,EACJ,eAAe,EAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,gBAAgB,MAAM,sEAAsE,CAAC;AACzG,OAAO,KAAK,SAAS,MAAM,8DAA8D,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAw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C,CAAC,CAAC,CAAC,OAAO,CAAC;QACrF,MAAM,eAAe,GAAG,OAAO,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC;QACxF,OAAO,CACL,KAAC,mBAAmB,IAClB,OAAO,EAAE,KAAK,CAAC,OAAO,iBACT,OAAO,CAAC,WAAW,gBACpB,eAAe,EAC3B,GAAG,EAAE,GAAG,YAEP,cAAc,GACK,CACvB,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { createContext, forwardRef, useEffect, useMemo, useRef } from 'react';\nimport type { PropsWithoutRef } from 'react';\n\nimport {\n Button,\n Flex,\n Progress,\n registerIcon,\n useI18n,\n useTestIds,\n ErrorState,\n markdownToPlainText,\n type ForwardRefForwardPropsComponent,\n Actions,\n Icon,\n useModalManager\n} from '@pega/cosmos-react-core';\nimport * as polarisSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/polaris-solid.icon';\nimport * as brainIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/brain.icon';\nimport { RichTextViewer } from '@pega/cosmos-react-rte';\nimport { useAnimatedText } from '@pega/cosmos-react-core';\n\nimport type { CoachLoadingContentProps, GenAIMessageProps } from './GenAICoach.types';\nimport {\n StyledActionsContainer,\n StyledAttachmentsList,\n StyledMessage,\n StyledSuggestion,\n StyledSuggestionsContainer,\n StyledSystemMessage,\n StyledUserMessage\n} from './GenAICoach.styles';\nimport { getGenAICoachTestIds } from './GenAICoach.test-ids';\nimport { isCoachMessage, isUserMessage } from './GenAICoach.utils';\nimport GenAIMessageProgress from './GenAIMessageProgress';\nimport ToolConfirmationMessage from './ToolConfirmationMessage';\nimport GenAIMessageFeedbackButtons from './GenAIMessageFeedback';\nimport ToolCandidates from './ToolCandidates';\n\nregisterIcon(polarisSolidIcon, brainIcon);\n\ntype StreamingContextProps = {\n isStreamingMessage?: boolean;\n isStreamingInProgress?: boolean;\n};\n\n/** Metadata Context */\nexport const StreamingContext = createContext<StreamingContextProps | undefined>({\n isStreamingMessage: false\n});\n\nconst LoadingContent = ({\n message,\n markdownMap,\n progressSteps,\n progressStepsCompleted\n}: CoachLoadingContentProps) => {\n if (!progressSteps?.length) {\n return <GenAIMessageProgress messages={message ? [message] : undefined} />;\n }\n\n if (message) {\n return (\n <>\n <RichTextViewer content={message} type='markdown' markdownMap={markdownMap} />\n <Progress variant='ellipsis' placement='inline' />\n </>\n );\n }\n\n return <GenAIMessageProgress messages={progressSteps} completedSteps={progressStepsCompleted} />;\n};\n\nconst GenAIMessage: ForwardRefForwardPropsComponent<GenAIMessageProps> = forwardRef(\n function GenAIMessage(props: PropsWithoutRef<GenAIMessageProps>, ref: GenAIMessageProps['ref']) {\n const testIds = useTestIds(props.testId, getGenAICoachTestIds);\n const t = useI18n();\n const { create } = useModalManager();\n\n const modalMethodsRef = useRef<ReturnType<typeof create> | null>(null);\n\n const { message, announceInteraction, ...restProps } = props;\n const isStringMessage = typeof message === 'string';\n const rawPlainTextMessage = isStringMessage ? markdownToPlainText(message ?? '') : '';\n\n let fallbackAriaLabel = '';\n if (isCoachMessage(props)) {\n fallbackAriaLabel = t('agent_message');\n } else if (isUserMessage(props)) {\n fallbackAriaLabel = t('user_message');\n }\n const plainTextMessage = rawPlainTextMessage || fallbackAriaLabel;\n let ariaLabel = plainTextMessage;\n\n const toolCandidates = isCoachMessage(props) ? props.toolCandidates : undefined;\n\n const isStreamingMessage = isCoachMessage(props) && props.enableStreaming;\n const allChunksReceived = isCoachMessage(props) && props.allChunksReceived;\n const enableStreaming = !!isStreamingMessage && !allChunksReceived;\n\n const {\n text: streamingMessage,\n isAnimationDone: isStreamingDone,\n animatedTillCursor\n } = useAnimatedText({\n text: isStringMessage ? message : '',\n allContentReceived: allChunksReceived === undefined ? true : allChunksReceived,\n enabled: isStringMessage && enableStreaming,\n tokenizeMarkdown: true,\n cursorStartIndex:\n isCoachMessage(props) && props.animationInitialCursorPos\n ? props.animationInitialCursorPos\n : undefined\n });\n\n useEffect(() => {\n if (isCoachMessage(props) && props.onAnimationCursorUpdate) {\n props.onAnimationCursorUpdate(animatedTillCursor);\n }\n }, [animatedTillCursor]);\n\n useEffect(() => {\n if (isStreamingMessage && props.onStreamingUpdate) {\n props.onStreamingUpdate(!!allChunksReceived && isStreamingDone);\n }\n }, [enableStreaming, isStreamingDone, allChunksReceived]);\n\n useEffect(() => {\n if (isCoachMessage(props) && toolCandidates && modalMethodsRef.current) {\n modalMethodsRef.current.update({\n loading: toolCandidates.toolState?.loading,\n error: toolCandidates.toolState?.error,\n renderCandidatesTable: toolCandidates.toolState?.renderCandidatesTable\n });\n }\n }, [toolCandidates]);\n\n useEffect(() => {\n return () => {\n const modalMethods = modalMethodsRef.current;\n\n if (!modalMethods) {\n return;\n }\n\n modalMethods.dismiss();\n modalMethods.unmount();\n };\n }, []);\n\n const streamingContext: StreamingContextProps = useMemo(() => {\n return { isStreamingMessage, isStreamingInProgress: isCoachMessage(props) && props.loading };\n }, [isStreamingMessage, props]);\n\n if (isCoachMessage(props)) {\n const {\n id: messageId,\n coachName,\n suggestions,\n onSend,\n loading,\n error,\n feedback,\n markdownMap,\n messageActions\n } = props;\n\n const { reaction } = feedback ?? {};\n const { toolState, onViewToolsConsidered } = toolCandidates ?? {};\n\n let selectedFeedbackResponse;\n\n let feedbackAriaLabel = t('sender_replied_message', [coachName, plainTextMessage ?? '']);\n\n if (feedback && reaction) {\n selectedFeedbackResponse = t('selected_noun', [\n reaction === 'liked' ? t('good_response') : t('bad_response')\n ]);\n\n feedbackAriaLabel = `${feedbackAriaLabel} ${selectedFeedbackResponse}`;\n }\n\n ariaLabel =\n suggestions && suggestions.length > 0\n ? `${feedbackAriaLabel} ${t('suggestions_in_message', [suggestions.length])}`\n : feedbackAriaLabel;\n\n const hasInteractiveContent = !!(\n suggestions?.length ||\n feedback ||\n messageActions ||\n toolState?.renderCandidatesTable\n );\n\n if (announceInteraction && hasInteractiveContent) {\n ariaLabel = `${ariaLabel} ${t('interaction_message')}`;\n }\n\n const onClickToolsConsidered = () => {\n modalMethodsRef.current = create(ToolCandidates, {\n loading: toolState?.loading,\n error: toolState?.error,\n renderCandidatesTable: toolState?.renderCandidatesTable\n });\n\n onViewToolsConsidered?.(messageId);\n };\n\n const streamingContent = isStreamingMessage && (\n <>\n {message ? (\n <>\n <StreamingContext.Provider value={streamingContext}>\n {isStringMessage ? (\n <RichTextViewer\n content={isStreamingMessage ? streamingMessage : message}\n type='markdown'\n markdownMap={markdownMap}\n />\n ) : (\n message\n )}\n </StreamingContext.Provider>\n\n {loading && <Progress variant='ellipsis' placement='inline' />}\n </>\n ) : (\n (loading || props.progressSteps?.length) && (\n <GenAIMessageProgress\n messages={props.progressSteps?.length ? props.progressSteps : undefined}\n completedSteps={\n props.progressSteps?.length ? props.progressStepsCompleted : undefined\n }\n />\n )\n )}\n </>\n );\n\n return (\n <Flex\n as='li'\n data-testid={testIds.coachMessage}\n {...restProps}\n container={{ direction: 'row', pad: [1, 0], gap: 1 }}\n type='message'\n aria-label={ariaLabel}\n ref={ref}\n >\n <StyledMessage>\n {/* Streaming loader and content */}\n {streamingContent}\n\n {loading || error ? (\n <>\n {loading && !isStreamingMessage && (\n <LoadingContent\n message={isStringMessage ? message : undefined}\n markdownMap={markdownMap}\n progressSteps={props.progressSteps}\n progressStepsCompleted={props.progressStepsCompleted}\n />\n )}\n {error && <ErrorState message={error} />}\n </>\n ) : (\n <>\n {/* Non streaming content */}\n {!isStreamingMessage &&\n message &&\n (isStringMessage ? (\n <RichTextViewer content={message} type='markdown' markdownMap={markdownMap} />\n ) : (\n message\n ))}\n\n {props.isToolConfirmation && <ToolConfirmationMessage {...props} />}\n\n {(feedback || messageActions || onViewToolsConsidered) && (\n <Flex\n container={{\n direction: 'row',\n gap: 1,\n pad: [1, undefined],\n alignItems: 'center'\n }}\n as={StyledActionsContainer}\n >\n {feedback && (\n <GenAIMessageFeedbackButtons messageId={messageId} feedback={feedback} />\n )}\n\n {onViewToolsConsidered && (\n <Button\n label={t('semantic_discovery_results')}\n variant='simple'\n icon\n compact\n onClick={onClickToolsConsidered}\n >\n <Icon name='brain' />\n </Button>\n )}\n\n {messageActions && <Actions {...messageActions} />}\n </Flex>\n )}\n\n {suggestions && suggestions.length > 0 && (\n <Flex\n as={StyledSuggestionsContainer}\n container={{ gap: 1, justify: 'end', wrap: 'wrap' }}\n >\n {suggestions.map(({ id, message: prompt }) => {\n return (\n <Button\n as={StyledSuggestion}\n onClick={onSend ? () => onSend({ id, message: prompt }) : undefined}\n key={id}\n >\n {prompt}\n </Button>\n );\n })}\n </Flex>\n )}\n </>\n )}\n </StyledMessage>\n </Flex>\n );\n }\n\n if (isUserMessage(props)) {\n if (plainTextMessage) {\n ariaLabel = t('you_asked', [plainTextMessage]);\n }\n\n if (announceInteraction) {\n ariaLabel = `${ariaLabel} ${t('interaction_message')}`;\n }\n\n return (\n <StyledUserMessage\n as={StyledUserMessage}\n data-testid={testIds.userMessage}\n {...restProps}\n // @ts-expect-error FIXME: Need to validate if we can remove message, and double 'as'\n type='message'\n aria-label={ariaLabel}\n ref={ref}\n >\n {props.attachments && props.attachments.length > 0 && (\n <StyledAttachmentsList type='display' items={props.attachments} />\n )}\n {props.message && <RichTextViewer content={props.message} type='markdown' />}\n </StyledUserMessage>\n );\n }\n\n if (props.from === 'system') {\n const displayMessage = props.stopped && !message ? t('generation_stopped') : message;\n const systemAriaLabel = typeof displayMessage === 'string' ? displayMessage : ariaLabel;\n return (\n <StyledSystemMessage\n stopped={props.stopped}\n data-testid={testIds.userMessage}\n aria-label={systemAriaLabel}\n ref={ref}\n >\n {displayMessage}\n </StyledSystemMessage>\n );\n }\n\n return null;\n }\n);\n\nexport default GenAIMessage;\n"]}
|
|
1
|
+
{"version":3,"file":"GenAIMessage.js","sourceRoot":"","sources":["../../../src/components/GenAICoach/GenAIMessage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EA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AK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACrF,MAAM,eAAe,GAAG,OAAO,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC;QACxF,OAAO,CACL,KAAC,mBAAmB,IAClB,OAAO,EAAE,KAAK,CAAC,OAAO,iBACT,OAAO,CAAC,WAAW,gBACpB,eAAe,EAC3B,GAAG,EAAE,GAAG,YAEP,cAAc,GACK,CACvB,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { createContext, forwardRef, useEffect, useMemo, useRef } from 'react';\nimport type { PropsWithoutRef } from 'react';\nimport { readableColor, transparentize } from 'polished';\n\nimport {\n Avatar,\n Button,\n Flex,\n Progress,\n registerIcon,\n useI18n,\n useTestIds,\n ErrorState,\n markdownToPlainText,\n type ForwardRefForwardPropsComponent,\n Actions,\n Icon,\n useModalManager,\n ThemeOverride,\n useTheme,\n calculateForegroundColor,\n tryCatch\n} from '@pega/cosmos-react-core';\nimport * as polarisSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/polaris-solid.icon';\nimport * as brainIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/brain.icon';\nimport { RichTextViewer } from '@pega/cosmos-react-rte';\nimport { useAnimatedText } from '@pega/cosmos-react-core';\n\nimport type { CoachLoadingContentProps, GenAIMessageProps } from './GenAICoach.types';\nimport {\n StyledActionsContainer,\n StyledAttachmentsList,\n StyledGenAIAvatar,\n StyledMessageSender,\n StyledMessage,\n StyledSuggestion,\n StyledSuggestionsContainer,\n StyledSystemMessage,\n StyledUserMessage\n} from './GenAICoach.styles';\nimport { getGenAICoachTestIds } from './GenAICoach.test-ids';\nimport { isCoachMessage, isUserMessage } from './GenAICoach.utils';\nimport GenAIMessageProgress from './GenAIMessageProgress';\nimport ToolConfirmationMessage from './ToolConfirmationMessage';\nimport GenAIMessageFeedbackButtons from './GenAIMessageFeedback';\nimport ToolCandidates from './ToolCandidates';\n\nregisterIcon(polarisSolidIcon, brainIcon);\n\ntype StreamingContextProps = {\n isStreamingMessage?: boolean;\n isStreamingInProgress?: boolean;\n};\n\n/** Metadata Context */\nexport const StreamingContext = createContext<StreamingContextProps | undefined>({\n isStreamingMessage: false\n});\n\nconst LoadingContent = ({\n message,\n markdownMap,\n progressSteps,\n progressStepsCompleted\n}: CoachLoadingContentProps) => {\n if (!progressSteps?.length) {\n return <GenAIMessageProgress messages={message ? [message] : undefined} />;\n }\n\n if (message) {\n return (\n <>\n <RichTextViewer content={message} type='markdown' markdownMap={markdownMap} />\n <Progress variant='ellipsis' placement='inline' />\n </>\n );\n }\n\n return <GenAIMessageProgress messages={progressSteps} completedSteps={progressStepsCompleted} />;\n};\n\nconst GenAIMessage: ForwardRefForwardPropsComponent<GenAIMessageProps> = forwardRef(\n function GenAIMessage(props: PropsWithoutRef<GenAIMessageProps>, ref: GenAIMessageProps['ref']) {\n const testIds = useTestIds(props.testId, getGenAICoachTestIds);\n const t = useI18n();\n const { create } = useModalManager();\n const theme = useTheme();\n\n const modalMethodsRef = useRef<ReturnType<typeof create> | null>(null);\n\n const { message, announceInteraction, simplifiedAgent, ...restProps } = props;\n const isStringMessage = typeof message === 'string';\n const rawPlainTextMessage = isStringMessage ? markdownToPlainText(message ?? '') : '';\n\n let fallbackAriaLabel = '';\n if (isCoachMessage(props)) {\n fallbackAriaLabel = t('agent_message');\n } else if (isUserMessage(props)) {\n fallbackAriaLabel = t('user_message');\n }\n const plainTextMessage = rawPlainTextMessage || fallbackAriaLabel;\n let ariaLabel = plainTextMessage;\n\n const toolCandidates = isCoachMessage(props) ? props.toolCandidates : undefined;\n\n const isStreamingMessage = isCoachMessage(props) && props.enableStreaming;\n const allChunksReceived = isCoachMessage(props) && props.allChunksReceived;\n const enableStreaming = !!isStreamingMessage && !allChunksReceived;\n\n const {\n text: streamingMessage,\n isAnimationDone: isStreamingDone,\n animatedTillCursor\n } = useAnimatedText({\n text: isStringMessage ? message : '',\n allContentReceived: allChunksReceived === undefined ? true : allChunksReceived,\n enabled: isStringMessage && enableStreaming,\n tokenizeMarkdown: true,\n cursorStartIndex:\n isCoachMessage(props) && props.animationInitialCursorPos\n ? props.animationInitialCursorPos\n : undefined\n });\n\n useEffect(() => {\n if (isCoachMessage(props) && props.onAnimationCursorUpdate) {\n props.onAnimationCursorUpdate(animatedTillCursor);\n }\n }, [animatedTillCursor]);\n\n useEffect(() => {\n if (isStreamingMessage && props.onStreamingUpdate) {\n props.onStreamingUpdate(!!allChunksReceived && isStreamingDone);\n }\n }, [enableStreaming, isStreamingDone, allChunksReceived]);\n\n useEffect(() => {\n if (isCoachMessage(props) && toolCandidates && modalMethodsRef.current) {\n modalMethodsRef.current.update({\n loading: toolCandidates.toolState?.loading,\n error: toolCandidates.toolState?.error,\n renderCandidatesTable: toolCandidates.toolState?.renderCandidatesTable\n });\n }\n }, [toolCandidates]);\n\n useEffect(() => {\n return () => {\n const modalMethods = modalMethodsRef.current;\n\n if (!modalMethods) {\n return;\n }\n\n modalMethods.dismiss();\n modalMethods.unmount();\n };\n }, []);\n\n const streamingContext: StreamingContextProps = useMemo(() => {\n return { isStreamingMessage, isStreamingInProgress: isCoachMessage(props) && props.loading };\n }, [isStreamingMessage, props]);\n\n if (isCoachMessage(props)) {\n const {\n id: messageId,\n coachName,\n suggestions,\n onSend,\n loading,\n error,\n feedback,\n markdownMap,\n messageActions,\n showSenderInfo\n } = props;\n const agentBackground = theme.components.agent.background;\n const agentForeground = calculateForegroundColor(\n agentBackground,\n theme.components.agent['foreground-color']\n );\n\n const { reaction } = feedback ?? {};\n const { toolState, onViewToolsConsidered } = toolCandidates ?? {};\n\n let selectedFeedbackResponse;\n\n let feedbackAriaLabel = t('sender_replied_message', [coachName, plainTextMessage ?? '']);\n\n if (feedback && reaction) {\n selectedFeedbackResponse = t('selected_noun', [\n reaction === 'liked' ? t('good_response') : t('bad_response')\n ]);\n\n feedbackAriaLabel = `${feedbackAriaLabel} ${selectedFeedbackResponse}`;\n }\n\n ariaLabel =\n suggestions && suggestions.length > 0\n ? `${feedbackAriaLabel} ${t('suggestions_in_message', [suggestions.length])}`\n : feedbackAriaLabel;\n\n const hasInteractiveContent = !!(\n suggestions?.length ||\n feedback ||\n messageActions ||\n toolState?.renderCandidatesTable\n );\n\n if (announceInteraction && hasInteractiveContent) {\n ariaLabel = `${ariaLabel} ${t('interaction_message')}`;\n }\n\n const onClickToolsConsidered = () => {\n modalMethodsRef.current = create(ToolCandidates, {\n loading: toolState?.loading,\n error: toolState?.error,\n renderCandidatesTable: toolState?.renderCandidatesTable\n });\n\n onViewToolsConsidered?.(messageId);\n };\n\n const streamingContent = isStreamingMessage && (\n <>\n {message ? (\n <>\n <StreamingContext.Provider value={streamingContext}>\n {isStringMessage ? (\n <RichTextViewer\n content={isStreamingMessage ? streamingMessage : message}\n type='markdown'\n markdownMap={markdownMap}\n />\n ) : (\n message\n )}\n </StreamingContext.Provider>\n\n {loading && <Progress variant='ellipsis' placement='inline' />}\n </>\n ) : (\n (loading || props.progressSteps?.length) && (\n <GenAIMessageProgress\n messages={props.progressSteps?.length ? props.progressSteps : undefined}\n completedSteps={\n props.progressSteps?.length ? props.progressStepsCompleted : undefined\n }\n />\n )\n )}\n </>\n );\n\n const messageContent = (\n <StyledMessage simplified={simplifiedAgent && !showSenderInfo}>\n {/* Streaming loader and content */}\n {streamingContent}\n\n {loading || error ? (\n <>\n {loading && !isStreamingMessage && (\n <LoadingContent\n message={isStringMessage ? message : undefined}\n markdownMap={markdownMap}\n progressSteps={props.progressSteps}\n progressStepsCompleted={props.progressStepsCompleted}\n />\n )}\n {error && <ErrorState message={error} />}\n </>\n ) : (\n <>\n {/* Non streaming content */}\n {!isStreamingMessage &&\n message &&\n (isStringMessage ? (\n <RichTextViewer content={message} type='markdown' markdownMap={markdownMap} />\n ) : (\n message\n ))}\n\n {props.isToolConfirmation && <ToolConfirmationMessage {...props} />}\n\n {(feedback || messageActions || onViewToolsConsidered) && (\n <Flex\n container={{\n direction: 'row',\n gap: 1,\n pad: [1, undefined],\n alignItems: 'center'\n }}\n as={StyledActionsContainer}\n >\n {feedback && (\n <GenAIMessageFeedbackButtons messageId={messageId} feedback={feedback} />\n )}\n\n {onViewToolsConsidered && (\n <Button\n label={t('semantic_discovery_results')}\n variant='simple'\n icon\n compact\n onClick={onClickToolsConsidered}\n >\n <Icon name='brain' />\n </Button>\n )}\n\n {messageActions && <Actions {...messageActions} />}\n </Flex>\n )}\n\n {suggestions && suggestions.length > 0 && (\n <Flex\n as={StyledSuggestionsContainer}\n container={{ gap: 1, justify: 'end', wrap: 'wrap' }}\n >\n {suggestions.map(({ id, message: prompt, selected }) => {\n return (\n <Button\n as={StyledSuggestion}\n onClick={onSend ? () => onSend({ id, message: prompt }) : undefined}\n key={id}\n variant={selected ? 'primary' : undefined}\n >\n {prompt}\n </Button>\n );\n })}\n </Flex>\n )}\n </>\n )}\n </StyledMessage>\n );\n\n return (\n <ThemeOverride\n theme={{\n base: {\n palette: {\n 'foreground-color': agentForeground,\n ...(simplifiedAgent && {\n 'secondary-background': tryCatch(() =>\n transparentize(0.7, readableColor(agentForeground))\n )\n })\n }\n }\n }}\n >\n <Flex\n as='li'\n data-testid={testIds.coachMessage}\n {...restProps}\n container={{ direction: 'row', pad: [1, 0], gap: 1 }}\n type='message'\n aria-label={ariaLabel}\n ref={ref}\n >\n {simplifiedAgent ? (\n <>\n {showSenderInfo && (\n <StyledGenAIAvatar size='l' name={coachName ?? t('agent')} icon='polaris-solid' />\n )}\n <Flex item={{ grow: 1 }} container={{ direction: 'column', gap: 0.75 }}>\n {coachName && showSenderInfo && (\n <StyledMessageSender variant='primary'>{coachName}</StyledMessageSender>\n )}\n {messageContent}\n </Flex>\n </>\n ) : (\n messageContent\n )}\n </Flex>\n </ThemeOverride>\n );\n }\n\n if (isUserMessage(props)) {\n if (plainTextMessage) {\n ariaLabel = t('you_asked', [plainTextMessage]);\n }\n\n if (announceInteraction) {\n ariaLabel = `${ariaLabel} ${t('interaction_message')}`;\n }\n\n const attachmentsAndMessage = (\n <>\n {props.attachments && props.attachments.length > 0 && (\n <StyledAttachmentsList type='display' items={props.attachments} />\n )}\n {props.message && <RichTextViewer content={props.message} type='markdown' />}\n </>\n );\n\n if (!simplifiedAgent) {\n return (\n <StyledUserMessage\n data-testid={testIds.userMessage}\n {...restProps}\n // @ts-expect-error FIXME: Need to validate if we can remove message, and double 'as'\n type='message'\n aria-label={ariaLabel}\n ref={ref}\n >\n {attachmentsAndMessage}\n </StyledUserMessage>\n );\n }\n\n return (\n <Flex\n as='li'\n data-testid={testIds.userMessage}\n {...restProps}\n container={{ direction: 'row', gap: 1, justify: 'end', alignItems: 'start' }}\n type='message'\n aria-label={ariaLabel}\n ref={ref}\n >\n <Flex container={{ direction: 'column', alignItems: 'end', gap: 0.75 }}>\n {props.userName !== undefined && (\n <StyledMessageSender variant='primary'>\n {props.userName.split(' ')[0] || t('you')}\n </StyledMessageSender>\n )}\n <StyledUserMessage as='div'>{attachmentsAndMessage}</StyledUserMessage>\n </Flex>\n {props.userName && <Avatar name={props.userName} size='l' shape='circle' />}\n </Flex>\n );\n }\n\n if (props.from === 'system') {\n const displayMessage = props.stopped && !message ? t('generation_stopped') : message;\n const systemAriaLabel = typeof displayMessage === 'string' ? displayMessage : ariaLabel;\n return (\n <StyledSystemMessage\n stopped={props.stopped}\n data-testid={testIds.userMessage}\n aria-label={systemAriaLabel}\n ref={ref}\n >\n {displayMessage}\n </StyledSystemMessage>\n );\n }\n\n return null;\n }\n);\n\nexport default GenAIMessage;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Questionnaire.d.ts","sourceRoot":"","sources":["../../../src/components/GenAICoach/Questionnaire.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAKV,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"Questionnaire.d.ts","sourceRoot":"","sources":["../../../src/components/GenAICoach/Questionnaire.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAKV,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAgN5B,QAAA,MAAM,aAAa,GAAI,8BAA8B,kBAAkB,mDA+FtE,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -3,13 +3,14 @@ import { useCallback, useMemo, useState } from 'react';
|
|
|
3
3
|
import { Button, Card, CardContent, CardFooter, CardHeader, Checkbox, CheckboxGroup, ComboBox, Flex, Icon, RadioButton, RadioButtonGroup, Text, useI18n, registerIcon } from '@pega/cosmos-react-core';
|
|
4
4
|
import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
|
|
5
5
|
import { StyledComboBoxWrapper, StyledQuestionBlock, StyledQuestionnaireCard } from './GenAICoach.styles';
|
|
6
|
+
import { getSelectedKeys } from './GenAICoach.utils';
|
|
6
7
|
registerIcon(timesIcon);
|
|
7
8
|
const getLabel = (option) => option.displayLabel ?? option.label;
|
|
8
|
-
const
|
|
9
|
-
value:
|
|
9
|
+
const createAnswer = (question) => ({
|
|
10
|
+
value: getSelectedKeys(question),
|
|
10
11
|
questionText: question.questionText
|
|
11
12
|
});
|
|
12
|
-
const buildInitialAnswers = (questions) => Object.fromEntries(questions.map(q => [q.field,
|
|
13
|
+
const buildInitialAnswers = (questions) => Object.fromEntries(questions.map(q => [q.field, createAnswer(q)]));
|
|
13
14
|
const splitOptions = (optionItems, maxInlineOptions) => {
|
|
14
15
|
if (optionItems.length <= maxInlineOptions) {
|
|
15
16
|
return { inlineOptions: optionItems, overflowOptions: [] };
|
|
@@ -25,16 +26,14 @@ const QuestionItem = ({ question, answer, onChange }) => {
|
|
|
25
26
|
const maxInlineOptions = 5;
|
|
26
27
|
const { inlineOptions, overflowOptions } = splitOptions(question.optionItems, maxInlineOptions);
|
|
27
28
|
const hasOverflow = overflowOptions.length > 0;
|
|
28
|
-
const [selectedOverflowKey, setSelectedOverflowKey] = useState('');
|
|
29
|
-
const [isOverflowActive, setIsOverflowActive] = useState(false);
|
|
30
29
|
const [searchTerm, setSearchTerm] = useState('');
|
|
31
|
-
const overflowKeySet = useMemo(() => new Set(overflowOptions.map(o => o.key)), []);
|
|
32
|
-
const overflowOptionsByKey = useMemo(() => new Map(overflowOptions.map(o => [o.key, o])), []);
|
|
30
|
+
const overflowKeySet = useMemo(() => new Set(overflowOptions.map(o => o.key)), [overflowOptions]);
|
|
31
|
+
const overflowOptionsByKey = useMemo(() => new Map(overflowOptions.map(o => [o.key, o])), [overflowOptions]);
|
|
32
|
+
const activeOverflowKey = answer.value.find(v => overflowKeySet.has(v)) ?? '';
|
|
33
|
+
const isOverflowSelected = activeOverflowKey.length > 0;
|
|
33
34
|
const isSelected = (key) => answer.value.includes(key);
|
|
34
35
|
const clearOverflowState = () => {
|
|
35
|
-
setSelectedOverflowKey('');
|
|
36
36
|
setSearchTerm('');
|
|
37
|
-
setIsOverflowActive(false);
|
|
38
37
|
};
|
|
39
38
|
const handleInlineSelect = (key) => {
|
|
40
39
|
clearOverflowState();
|
|
@@ -52,11 +51,11 @@ const QuestionItem = ({ question, answer, onChange }) => {
|
|
|
52
51
|
}, [searchTerm, answer]);
|
|
53
52
|
const overflowSelection = useMemo(() => {
|
|
54
53
|
if (isSingleSelect) {
|
|
55
|
-
if (!
|
|
54
|
+
if (!activeOverflowKey)
|
|
56
55
|
return undefined;
|
|
57
|
-
const option = overflowOptionsByKey.get(
|
|
58
|
-
const displayText = option ? getLabel(option) :
|
|
59
|
-
return { items: { id:
|
|
56
|
+
const option = overflowOptionsByKey.get(activeOverflowKey);
|
|
57
|
+
const displayText = option ? getLabel(option) : activeOverflowKey;
|
|
58
|
+
return { items: { id: activeOverflowKey, text: displayText } };
|
|
60
59
|
}
|
|
61
60
|
const selectedOverflowValues = answer.value.filter(v => overflowKeySet.has(v));
|
|
62
61
|
if (selectedOverflowValues.length === 0)
|
|
@@ -70,8 +69,7 @@ const QuestionItem = ({ question, answer, onChange }) => {
|
|
|
70
69
|
};
|
|
71
70
|
}, [
|
|
72
71
|
isSingleSelect,
|
|
73
|
-
|
|
74
|
-
selectedOverflowKey,
|
|
72
|
+
activeOverflowKey,
|
|
75
73
|
answer,
|
|
76
74
|
overflowKeySet,
|
|
77
75
|
overflowOptionsByKey,
|
|
@@ -82,8 +80,6 @@ const QuestionItem = ({ question, answer, onChange }) => {
|
|
|
82
80
|
if (isSingleSelect) {
|
|
83
81
|
const option = overflowOptionsByKey.get(id);
|
|
84
82
|
if (option) {
|
|
85
|
-
setSelectedOverflowKey(option.key);
|
|
86
|
-
setIsOverflowActive(true);
|
|
87
83
|
setSearchTerm('');
|
|
88
84
|
onChange(question.field, option.key, true);
|
|
89
85
|
}
|
|
@@ -93,7 +89,7 @@ const QuestionItem = ({ question, answer, onChange }) => {
|
|
|
93
89
|
}
|
|
94
90
|
}, [isSingleSelect, answer, question.field, onChange, overflowOptionsByKey]);
|
|
95
91
|
const activateOverflow = () => {
|
|
96
|
-
|
|
92
|
+
setSearchTerm('');
|
|
97
93
|
};
|
|
98
94
|
const deselectAllOverflow = () => {
|
|
99
95
|
answer.value
|
|
@@ -107,7 +103,7 @@ const QuestionItem = ({ question, answer, onChange }) => {
|
|
|
107
103
|
return (_jsx(StyledQuestionBlock, { children: isSingleSelect ? (_jsx(RadioButtonGroup, { name: question.field, labelHidden: true, children: overflowComboBox
|
|
108
104
|
? [
|
|
109
105
|
...inlineRadioButtons,
|
|
110
|
-
_jsx(RadioButton, { label: overflowComboBox, name: question.field, checked:
|
|
106
|
+
_jsx(RadioButton, { label: overflowComboBox, name: question.field, checked: isOverflowSelected, onChange: activateOverflow }, 'overflow')
|
|
111
107
|
]
|
|
112
108
|
: inlineRadioButtons })) : (_jsx(CheckboxGroup, { labelHidden: true, children: overflowComboBox
|
|
113
109
|
? [
|
|
@@ -138,7 +134,10 @@ const Questionnaire = ({ data, onChange, onCancel }) => {
|
|
|
138
134
|
}
|
|
139
135
|
const nextAnswers = {
|
|
140
136
|
...prev,
|
|
141
|
-
[field]: {
|
|
137
|
+
[field]: {
|
|
138
|
+
questionText: question?.questionText ?? prev[field]?.questionText ?? '',
|
|
139
|
+
value: updatedValues
|
|
140
|
+
}
|
|
142
141
|
};
|
|
143
142
|
onChange(nextAnswers);
|
|
144
143
|
return nextAnswers;
|
|
@@ -147,7 +146,7 @@ const Questionnaire = ({ data, onChange, onCancel }) => {
|
|
|
147
146
|
if (totalSteps === 0)
|
|
148
147
|
return null;
|
|
149
148
|
const activeQuestion = questions[currentStep];
|
|
150
|
-
const activeAnswer = answers[activeQuestion.field] ??
|
|
149
|
+
const activeAnswer = answers[activeQuestion.field] ?? createAnswer(activeQuestion);
|
|
151
150
|
const isMultiStep = totalSteps > 1;
|
|
152
151
|
return (_jsxs(Card, { as: StyledQuestionnaireCard, children: [_jsx(CardHeader, { actions: _jsx(Button, { variant: 'simple', icon: true, onClick: onCancel, "aria-label": t('dismiss'), children: _jsx(Icon, { name: 'times' }) }), children: _jsx(Text, { variant: 'h4', children: activeQuestion.questionText }) }), _jsx(CardContent, { children: _jsx(QuestionItem, { question: activeQuestion, answer: activeAnswer, onChange: handleChange }, activeQuestion.field) }), isMultiStep && (_jsx(CardFooter, { justify: 'center', children: _jsxs(Flex, { container: { direction: 'row', alignItems: 'center', gap: 0.5 }, children: [_jsx(Button, { variant: 'simple', icon: true, onClick: () => setCurrentStep(s => s - 1), disabled: currentStep === 0, "aria-label": t('pagination_prev'), children: _jsx(Icon, { name: 'caret-left' }) }), _jsx(Text, { variant: 'secondary', children: t('x_of_y', [currentStep + 1, totalSteps]) }), _jsx(Button, { variant: 'simple', icon: true, onClick: () => setCurrentStep(s => s + 1), disabled: currentStep === totalSteps - 1, "aria-label": t('pagination_next'), children: _jsx(Icon, { name: 'caret-right' }) })] }) }))] }));
|
|
153
152
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Questionnaire.js","sourceRoot":"","sources":["../../../src/components/GenAICoach/Questionnaire.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,EACL,MAAM,EACN,IAAI,EACJ,WAAW,EACX,UAAU,EACV,UAAU,EACV,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,gBAAgB,EAChB,IAAI,EACJ,OAAO,EACP,YAAY,EACb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,SAAS,MAAM,8DAA8D,CAAC;AAS1F,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;AAE7B,YAAY,CAAC,SAAS,CAAC,CAAC;AAExB,MAAM,QAAQ,GAAG,CAAC,MAAkB,EAAU,EAAE,CAAC,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,KAAK,CAAC;AAErF,MAAM,iBAAiB,GAAG,CAAC,QAAkB,EAAc,EAAE,CAAC,CAAC;IAC7D,KAAK,EAAE,EAAE;IACT,YAAY,EAAE,QAAQ,CAAC,YAAY;CACpC,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAG,CAAC,SAAqB,EAA8B,EAAE,CAChF,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE1E,MAAM,YAAY,GAAG,CACnB,WAAyB,EACzB,gBAAwB,EACwC,EAAE;IAClE,IAAI,WAAW,CAAC,MAAM,IAAI,gBAAgB,EAAE,CAAC;QAC3C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE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C","sourcesContent":["import type { ChangeEvent } from 'react';\nimport { useCallback, useMemo, useState } from 'react';\n\nimport {\n Button,\n Card,\n CardContent,\n CardFooter,\n CardHeader,\n Checkbox,\n CheckboxGroup,\n ComboBox,\n Flex,\n Icon,\n RadioButton,\n RadioButtonGroup,\n Text,\n useI18n,\n registerIcon\n} from '@pega/cosmos-react-core';\nimport type { MenuItemProps } from '@pega/cosmos-react-core';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\n\nimport type {\n FormAnswer,\n OptionItem,\n Question,\n QuestionItemProps,\n QuestionnaireProps\n} from './GenAICoach.types';\nimport {\n StyledComboBoxWrapper,\n StyledQuestionBlock,\n StyledQuestionnaireCard\n} from './GenAICoach.styles';\n\nregisterIcon(timesIcon);\n\nconst getLabel = (option: OptionItem): string => option.displayLabel ?? option.label;\n\nconst createEmptyAnswer = (question: Question): FormAnswer => ({\n value: [],\n questionText: question.questionText\n});\n\nconst buildInitialAnswers = (questions: Question[]): Record<string, FormAnswer> =>\n Object.fromEntries(questions.map(q => [q.field, createEmptyAnswer(q)]));\n\nconst splitOptions = (\n optionItems: OptionItem[],\n maxInlineOptions: number\n): { inlineOptions: OptionItem[]; overflowOptions: OptionItem[] } => {\n if (optionItems.length <= maxInlineOptions) {\n return { inlineOptions: optionItems, overflowOptions: [] };\n }\n\n return {\n inlineOptions: optionItems.slice(0, maxInlineOptions - 1),\n overflowOptions: optionItems.slice(maxInlineOptions - 1)\n };\n};\n\nconst QuestionItem = ({ question, answer, onChange }: QuestionItemProps) => {\n const t = useI18n();\n\n const isSingleSelect = question.type === 'single';\n const maxInlineOptions = 5;\n\n const { inlineOptions, overflowOptions } = splitOptions(question.optionItems, maxInlineOptions);\n const hasOverflow = overflowOptions.length > 0;\n\n const [selectedOverflowKey, setSelectedOverflowKey] = useState('');\n const [isOverflowActive, setIsOverflowActive] = useState(false);\n const [searchTerm, setSearchTerm] = useState('');\n\n const overflowKeySet = useMemo(() => new Set(overflowOptions.map(o => o.key)), []);\n const overflowOptionsByKey = useMemo(() => new Map(overflowOptions.map(o => [o.key, o])), []);\n\n const isSelected = (key: string) => answer.value.includes(key);\n\n const clearOverflowState = () => {\n setSelectedOverflowKey('');\n setSearchTerm('');\n setIsOverflowActive(false);\n };\n\n const handleInlineSelect = (key: string) => {\n clearOverflowState();\n onChange(question.field, key, true);\n };\n\n const overflowMenuItems: MenuItemProps[] = useMemo(() => {\n const search = searchTerm.toLowerCase();\n\n return overflowOptions\n .map(opt => ({\n id: opt.key,\n primary: getLabel(opt),\n selected: isSelected(opt.key)\n }))\n .filter(item => !search || item.primary.toLowerCase().includes(search));\n }, [searchTerm, answer]);\n\n const overflowSelection = useMemo(() => {\n if (isSingleSelect) {\n if (!isOverflowActive || !selectedOverflowKey) return undefined;\n\n const option = overflowOptionsByKey.get(selectedOverflowKey);\n const displayText = option ? getLabel(option) : selectedOverflowKey;\n\n return { items: { id: selectedOverflowKey, text: displayText } };\n }\n\n const selectedOverflowValues = answer.value.filter(v => overflowKeySet.has(v));\n\n if (selectedOverflowValues.length === 0) return undefined;\n\n return {\n items: selectedOverflowValues.map(key => {\n const option = overflowOptionsByKey.get(key);\n return { id: key, text: option ? getLabel(option) : key };\n }),\n onRemove: (id: MenuItemProps['id']) => onChange(question.field, id, false)\n };\n }, [\n isSingleSelect,\n isOverflowActive,\n selectedOverflowKey,\n answer,\n overflowKeySet,\n overflowOptionsByKey,\n question.field,\n onChange\n ]);\n\n const handleOverflowSelect = useCallback(\n (id: MenuItemProps['id']) => {\n if (isSingleSelect) {\n const option = overflowOptionsByKey.get(id);\n\n if (option) {\n setSelectedOverflowKey(option.key);\n setIsOverflowActive(true);\n setSearchTerm('');\n onChange(question.field, option.key, true);\n }\n } else {\n onChange(question.field, id, !isSelected(id));\n }\n },\n [isSingleSelect, answer, question.field, onChange, overflowOptionsByKey]\n );\n\n const activateOverflow = () => {\n setIsOverflowActive(true);\n };\n\n const deselectAllOverflow = () => {\n answer.value\n .filter(v => overflowKeySet.has(v))\n .forEach(key => onChange(question.field, key, false));\n };\n\n const otherLabel = t('other');\n\n const overflowComboBox = hasOverflow ? (\n <StyledComboBoxWrapper>\n <ComboBox\n labelHidden\n label={otherLabel}\n placeholder={otherLabel}\n value={searchTerm}\n selected={overflowSelection}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setSearchTerm(e.target.value)}\n onBlur={() => setSearchTerm('')}\n mode={isSingleSelect ? undefined : 'multi-select'}\n menu={{ items: overflowMenuItems, onItemClick: handleOverflowSelect }}\n />\n </StyledComboBoxWrapper>\n ) : null;\n\n const inlineRadioButtons = inlineOptions.map(option => (\n <RadioButton\n key={option.key}\n label={getLabel(option)}\n name={question.field}\n checked={isSelected(option.key)}\n onChange={() => handleInlineSelect(option.key)}\n />\n ));\n\n const inlineCheckboxes = inlineOptions.map(option => (\n <Checkbox\n key={option.key}\n label={getLabel(option)}\n checked={isSelected(option.key)}\n onChange={e => onChange(question.field, option.key, e.target.checked)}\n />\n ));\n\n return (\n <StyledQuestionBlock>\n {isSingleSelect ? (\n <RadioButtonGroup name={question.field} labelHidden>\n {overflowComboBox\n ? [\n ...inlineRadioButtons,\n <RadioButton\n key='overflow'\n label={overflowComboBox}\n name={question.field}\n checked={isOverflowActive}\n onChange={activateOverflow}\n />\n ]\n : inlineRadioButtons}\n </RadioButtonGroup>\n ) : (\n <CheckboxGroup labelHidden>\n {overflowComboBox\n ? [\n ...inlineCheckboxes,\n <Checkbox\n key='overflow'\n label={overflowComboBox}\n checked={answer.value.some(v => overflowKeySet.has(v))}\n onChange={e => {\n if (!e.target.checked) deselectAllOverflow();\n }}\n />\n ]\n : inlineCheckboxes}\n </CheckboxGroup>\n )}\n </StyledQuestionBlock>\n );\n};\n\nconst Questionnaire = ({ data, onChange, onCancel }: QuestionnaireProps) => {\n const t = useI18n();\n const questions = data.questions ?? [];\n const totalSteps = questions.length;\n\n const [currentStep, setCurrentStep] = useState(0);\n const [answers, setAnswers] = useState<Record<string, FormAnswer>>(() =>\n buildInitialAnswers(questions)\n );\n\n const handleChange = useCallback(\n (field: string, key: string, selected: boolean) => {\n setAnswers(prev => {\n const question = questions.find(q => q.field === field);\n const currentValues = prev[field]?.value ?? [];\n let updatedValues: string[];\n\n if (question?.type === 'single') {\n updatedValues = selected ? [key] : [];\n } else {\n updatedValues = selected ? [...currentValues, key] : currentValues.filter(v => v !== key);\n }\n\n const nextAnswers = {\n ...prev,\n [field]: { ...prev[field], value: updatedValues }\n };\n\n onChange(nextAnswers);\n\n return nextAnswers;\n });\n },\n [onChange, questions]\n );\n\n if (totalSteps === 0) return null;\n\n const activeQuestion = questions[currentStep];\n const activeAnswer = answers[activeQuestion.field] ?? createEmptyAnswer(activeQuestion);\n const isMultiStep = totalSteps > 1;\n\n return (\n <Card as={StyledQuestionnaireCard}>\n <CardHeader\n actions={\n <Button variant='simple' icon onClick={onCancel} aria-label={t('dismiss')}>\n <Icon name='times' />\n </Button>\n }\n >\n <Text variant='h4'>{activeQuestion.questionText}</Text>\n </CardHeader>\n\n <CardContent>\n <QuestionItem\n key={activeQuestion.field}\n question={activeQuestion}\n answer={activeAnswer}\n onChange={handleChange}\n />\n </CardContent>\n\n {isMultiStep && (\n <CardFooter justify='center'>\n <Flex container={{ direction: 'row', alignItems: 'center', gap: 0.5 }}>\n <Button\n variant='simple'\n icon\n onClick={() => setCurrentStep(s => s - 1)}\n disabled={currentStep === 0}\n aria-label={t('pagination_prev')}\n >\n <Icon name='caret-left' />\n </Button>\n\n <Text variant='secondary'>{t('x_of_y', [currentStep + 1, totalSteps])}</Text>\n\n <Button\n variant='simple'\n icon\n onClick={() => setCurrentStep(s => s + 1)}\n disabled={currentStep === totalSteps - 1}\n aria-label={t('pagination_next')}\n >\n <Icon name='caret-right' />\n </Button>\n </Flex>\n </CardFooter>\n )}\n </Card>\n );\n};\n\nexport default Questionnaire;\n"]}
|
|
1
|
+
{"version":3,"file":"Questionnaire.js","sourceRoot":"","sources":["../../../src/components/GenAICoach/Questionnaire.tsx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,YAAY,IAEX,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,YAAY,IAHjB,cAAc,CAAC,KAAK,CAIzB,GACU,EAEb,WAAW,IAAI,CACd,KAAC,UAAU,IAAC,OAAO,EAAC,QAAQ,YAC1B,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,aACnE,KAAC,MAAM,IACL,OAAO,EAAC,QAAQ,EAChB,IAAI,QACJ,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EACzC,QAAQ,EAAE,WAAW,KAAK,CAAC,gBACf,CAAC,CAAC,iBAAiB,CAAC,YAEhC,KAAC,IAAI,IAAC,IAAI,EAAC,YAAY,GAAG,GACnB,EAET,KAAC,IAAI,IAAC,OAAO,EAAC,WAAW,YAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,WAAW,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC,GAAQ,EAE7E,KAAC,MAAM,IACL,OAAO,EAAC,QAAQ,EAChB,IAAI,QACJ,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EACzC,QAAQ,EAAE,WAAW,KAAK,UAAU,GAAG,CAAC,gBAC5B,CAAC,CAAC,iBAAiB,CAAC,YAEhC,KAAC,IAAI,IAAC,IAAI,EAAC,aAAa,GAAG,GACpB,IACJ,GACI,CACd,IACI,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import type { ChangeEvent } from 'react';\nimport { useCallback, useMemo, useState } from 'react';\n\nimport {\n Button,\n Card,\n CardContent,\n CardFooter,\n CardHeader,\n Checkbox,\n CheckboxGroup,\n ComboBox,\n Flex,\n Icon,\n RadioButton,\n RadioButtonGroup,\n Text,\n useI18n,\n registerIcon\n} from '@pega/cosmos-react-core';\nimport type { MenuItemProps } from '@pega/cosmos-react-core';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\n\nimport type {\n FormAnswer,\n OptionItem,\n Question,\n QuestionItemProps,\n QuestionnaireProps\n} from './GenAICoach.types';\nimport {\n StyledComboBoxWrapper,\n StyledQuestionBlock,\n StyledQuestionnaireCard\n} from './GenAICoach.styles';\nimport { getSelectedKeys } from './GenAICoach.utils';\n\nregisterIcon(timesIcon);\n\nconst getLabel = (option: OptionItem): string => option.displayLabel ?? option.label;\n\nconst createAnswer = (question: Question): FormAnswer => ({\n value: getSelectedKeys(question),\n questionText: question.questionText\n});\n\nconst buildInitialAnswers = (questions: Question[]): Record<string, FormAnswer> =>\n Object.fromEntries(questions.map(q => [q.field, createAnswer(q)]));\n\nconst splitOptions = (\n optionItems: OptionItem[],\n maxInlineOptions: number\n): { inlineOptions: OptionItem[]; overflowOptions: OptionItem[] } => {\n if (optionItems.length <= maxInlineOptions) {\n return { inlineOptions: optionItems, overflowOptions: [] };\n }\n\n return {\n inlineOptions: optionItems.slice(0, maxInlineOptions - 1),\n overflowOptions: optionItems.slice(maxInlineOptions - 1)\n };\n};\n\nconst QuestionItem = ({ question, answer, onChange }: QuestionItemProps) => {\n const t = useI18n();\n\n const isSingleSelect = question.type === 'single';\n const maxInlineOptions = 5;\n\n const { inlineOptions, overflowOptions } = splitOptions(question.optionItems, maxInlineOptions);\n const hasOverflow = overflowOptions.length > 0;\n\n const [searchTerm, setSearchTerm] = useState('');\n\n const overflowKeySet = useMemo(() => new Set(overflowOptions.map(o => o.key)), [overflowOptions]);\n const overflowOptionsByKey = useMemo(\n () => new Map(overflowOptions.map(o => [o.key, o])),\n [overflowOptions]\n );\n const activeOverflowKey = answer.value.find(v => overflowKeySet.has(v)) ?? '';\n const isOverflowSelected = activeOverflowKey.length > 0;\n\n const isSelected = (key: string) => answer.value.includes(key);\n\n const clearOverflowState = () => {\n setSearchTerm('');\n };\n\n const handleInlineSelect = (key: string) => {\n clearOverflowState();\n onChange(question.field, key, true);\n };\n\n const overflowMenuItems: MenuItemProps[] = useMemo(() => {\n const search = searchTerm.toLowerCase();\n\n return overflowOptions\n .map(opt => ({\n id: opt.key,\n primary: getLabel(opt),\n selected: isSelected(opt.key)\n }))\n .filter(item => !search || item.primary.toLowerCase().includes(search));\n }, [searchTerm, answer]);\n\n const overflowSelection = useMemo(() => {\n if (isSingleSelect) {\n if (!activeOverflowKey) return undefined;\n\n const option = overflowOptionsByKey.get(activeOverflowKey);\n const displayText = option ? getLabel(option) : activeOverflowKey;\n\n return { items: { id: activeOverflowKey, text: displayText } };\n }\n\n const selectedOverflowValues = answer.value.filter(v => overflowKeySet.has(v));\n\n if (selectedOverflowValues.length === 0) return undefined;\n\n return {\n items: selectedOverflowValues.map(key => {\n const option = overflowOptionsByKey.get(key);\n return { id: key, text: option ? getLabel(option) : key };\n }),\n onRemove: (id: MenuItemProps['id']) => onChange(question.field, id, false)\n };\n }, [\n isSingleSelect,\n activeOverflowKey,\n answer,\n overflowKeySet,\n overflowOptionsByKey,\n question.field,\n onChange\n ]);\n\n const handleOverflowSelect = useCallback(\n (id: MenuItemProps['id']) => {\n if (isSingleSelect) {\n const option = overflowOptionsByKey.get(id);\n\n if (option) {\n setSearchTerm('');\n onChange(question.field, option.key, true);\n }\n } else {\n onChange(question.field, id, !isSelected(id));\n }\n },\n [isSingleSelect, answer, question.field, onChange, overflowOptionsByKey]\n );\n\n const activateOverflow = () => {\n setSearchTerm('');\n };\n\n const deselectAllOverflow = () => {\n answer.value\n .filter(v => overflowKeySet.has(v))\n .forEach(key => onChange(question.field, key, false));\n };\n\n const otherLabel = t('other');\n\n const overflowComboBox = hasOverflow ? (\n <StyledComboBoxWrapper>\n <ComboBox\n labelHidden\n label={otherLabel}\n placeholder={otherLabel}\n value={searchTerm}\n selected={overflowSelection}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setSearchTerm(e.target.value)}\n onBlur={() => setSearchTerm('')}\n mode={isSingleSelect ? undefined : 'multi-select'}\n menu={{ items: overflowMenuItems, onItemClick: handleOverflowSelect }}\n />\n </StyledComboBoxWrapper>\n ) : null;\n\n const inlineRadioButtons = inlineOptions.map(option => (\n <RadioButton\n key={option.key}\n label={getLabel(option)}\n name={question.field}\n checked={isSelected(option.key)}\n onChange={() => handleInlineSelect(option.key)}\n />\n ));\n\n const inlineCheckboxes = inlineOptions.map(option => (\n <Checkbox\n key={option.key}\n label={getLabel(option)}\n checked={isSelected(option.key)}\n onChange={e => onChange(question.field, option.key, e.target.checked)}\n />\n ));\n\n return (\n <StyledQuestionBlock>\n {isSingleSelect ? (\n <RadioButtonGroup name={question.field} labelHidden>\n {overflowComboBox\n ? [\n ...inlineRadioButtons,\n <RadioButton\n key='overflow'\n label={overflowComboBox}\n name={question.field}\n checked={isOverflowSelected}\n onChange={activateOverflow}\n />\n ]\n : inlineRadioButtons}\n </RadioButtonGroup>\n ) : (\n <CheckboxGroup labelHidden>\n {overflowComboBox\n ? [\n ...inlineCheckboxes,\n <Checkbox\n key='overflow'\n label={overflowComboBox}\n checked={answer.value.some(v => overflowKeySet.has(v))}\n onChange={e => {\n if (!e.target.checked) deselectAllOverflow();\n }}\n />\n ]\n : inlineCheckboxes}\n </CheckboxGroup>\n )}\n </StyledQuestionBlock>\n );\n};\n\nconst Questionnaire = ({ data, onChange, onCancel }: QuestionnaireProps) => {\n const t = useI18n();\n const questions = data.questions ?? [];\n const totalSteps = questions.length;\n\n const [currentStep, setCurrentStep] = useState(0);\n const [answers, setAnswers] = useState<Record<string, FormAnswer>>(() =>\n buildInitialAnswers(questions)\n );\n\n const handleChange = useCallback(\n (field: string, key: string, selected: boolean) => {\n setAnswers(prev => {\n const question = questions.find(q => q.field === field);\n const currentValues = prev[field]?.value ?? [];\n let updatedValues: string[];\n\n if (question?.type === 'single') {\n updatedValues = selected ? [key] : [];\n } else {\n updatedValues = selected ? [...currentValues, key] : currentValues.filter(v => v !== key);\n }\n\n const nextAnswers = {\n ...prev,\n [field]: {\n questionText: question?.questionText ?? prev[field]?.questionText ?? '',\n value: updatedValues\n }\n };\n\n onChange(nextAnswers);\n\n return nextAnswers;\n });\n },\n [onChange, questions]\n );\n\n if (totalSteps === 0) return null;\n\n const activeQuestion = questions[currentStep];\n const activeAnswer = answers[activeQuestion.field] ?? createAnswer(activeQuestion);\n const isMultiStep = totalSteps > 1;\n\n return (\n <Card as={StyledQuestionnaireCard}>\n <CardHeader\n actions={\n <Button variant='simple' icon onClick={onCancel} aria-label={t('dismiss')}>\n <Icon name='times' />\n </Button>\n }\n >\n <Text variant='h4'>{activeQuestion.questionText}</Text>\n </CardHeader>\n\n <CardContent>\n <QuestionItem\n key={activeQuestion.field}\n question={activeQuestion}\n answer={activeAnswer}\n onChange={handleChange}\n />\n </CardContent>\n\n {isMultiStep && (\n <CardFooter justify='center'>\n <Flex container={{ direction: 'row', alignItems: 'center', gap: 0.5 }}>\n <Button\n variant='simple'\n icon\n onClick={() => setCurrentStep(s => s - 1)}\n disabled={currentStep === 0}\n aria-label={t('pagination_prev')}\n >\n <Icon name='caret-left' />\n </Button>\n\n <Text variant='secondary'>{t('x_of_y', [currentStep + 1, totalSteps])}</Text>\n\n <Button\n variant='simple'\n icon\n onClick={() => setCurrentStep(s => s + 1)}\n disabled={currentStep === totalSteps - 1}\n aria-label={t('pagination_next')}\n >\n <Icon name='caret-right' />\n </Button>\n </Flex>\n </CardFooter>\n )}\n </Card>\n );\n};\n\nexport default Questionnaire;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Shortcuts.d.ts","sourceRoot":"","sources":["../../../src/components/Shortcuts/Shortcuts.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,eAAe,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Shortcuts.d.ts","sourceRoot":"","sources":["../../../src/components/Shortcuts/Shortcuts.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,eAAe,EAAE,MAAM,OAAO,CAAC;AAsBxD,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,mBAAmB,CAAC;;;;AAgLtE,wBAA2D"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useRef, forwardRef } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import { Card, CardContent, CardHeader, EmptyState, Flex, Text, VisuallyHiddenText, registerIcon, tryCatch, useArrows, useI18n, useTestIds, useTheme, withTestIds } from '@pega/cosmos-react-core';
|
|
3
|
+
import { calculateForegroundColor, Card, CardContent, CardHeader, EmptyState, Flex, Text, VisuallyHiddenText, readableColor, registerIcon, isSolidColor, useArrows, useI18n, useTestIds, useTheme, withTestIds } from '@pega/cosmos-react-core';
|
|
5
4
|
import * as openNewTabIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/open.icon';
|
|
6
5
|
import { StyledExternalIcon, StyledLabelRow, StyledShortcutsCard, StyledShortcutsCardButton, StyledShortcutsCardsContainer, StyledShortcutsCardsWrapper, StyledShortcutsCategoriesContainer, StyledShortcutsCategoryHeading, StyledShortcutsCardIcon, StyledText } from './Shortcuts.styles';
|
|
7
6
|
import { getShortcutsTestIds } from './Shortcuts.test-ids';
|
|
@@ -12,15 +11,26 @@ const itemLinkProps = (item) => {
|
|
|
12
11
|
}
|
|
13
12
|
return { onClick: item.onClick };
|
|
14
13
|
};
|
|
15
|
-
const CardItem = ({ item,
|
|
14
|
+
const CardItem = ({ item, variant }) => {
|
|
15
|
+
const { components: { card, shortcuts: { icon: { background: configuredIconBackground, foreground: configuredIconForeground } } } } = useTheme();
|
|
16
|
+
const iconBackground = configuredIconBackground;
|
|
17
|
+
const withIconBackground = Boolean(isSolidColor(iconBackground));
|
|
18
|
+
const cardForeground = calculateForegroundColor(card.background, card['foreground-color']);
|
|
19
|
+
let iconForeground = configuredIconForeground;
|
|
20
|
+
if (configuredIconForeground === 'auto') {
|
|
21
|
+
iconForeground = withIconBackground
|
|
22
|
+
? readableColor(iconBackground, { mode: 'light', level: 'AANonText' })
|
|
23
|
+
: cardForeground;
|
|
24
|
+
}
|
|
25
|
+
const commonIconProps = {
|
|
26
|
+
name: item.icon,
|
|
27
|
+
layoutVariant: variant
|
|
28
|
+
};
|
|
29
|
+
return (_jsx(StyledShortcutsCard, { children: _jsxs(StyledShortcutsCardButton, { variant: 'link', layoutVariant: variant, ...itemLinkProps(item), children: [withIconBackground ? (_jsx(StyledShortcutsCardIcon, { ...commonIconProps, background: iconBackground, foreground: iconForeground })) : (_jsx(StyledShortcutsCardIcon, { ...commonIconProps, iconColor: iconForeground })), _jsxs(StyledLabelRow, { children: [_jsx(StyledText, { children: item.label }), item.type === 'external' && _jsx(StyledExternalIcon, { name: 'open' })] })] }) }));
|
|
30
|
+
};
|
|
16
31
|
const Shortcuts = forwardRef(function Shortcuts({ heading, items = [], categories, showHeader = true, variant = 'inline', testId, ...restProps }, ref) {
|
|
17
32
|
const t = useI18n();
|
|
18
33
|
const testIds = useTestIds(testId, getShortcutsTestIds);
|
|
19
|
-
const { base: { palette: { 'brand-accent': brandAccent, 'brand-primary': brandPrimary } } } = useTheme();
|
|
20
|
-
const iconBackground = tryCatch(() => {
|
|
21
|
-
parseToRgb(brandAccent);
|
|
22
|
-
return brandAccent;
|
|
23
|
-
}) ?? brandPrimary;
|
|
24
34
|
const flatListRef = useRef(null);
|
|
25
35
|
const categoriesContainerRef = useRef(null);
|
|
26
36
|
useArrows(flatListRef, { dir: 'both', cycle: true });
|
|
@@ -29,10 +39,10 @@ const Shortcuts = forwardRef(function Shortcuts({ heading, items = [], categorie
|
|
|
29
39
|
const withCardShell = (content) => (_jsxs(Card, { ...restProps, "data-testid": testIds.root, ref: ref, children: [_jsx(CardHeader, { children: _jsx(Text, { variant: 'h2', children: heading ?? t('shortcuts') }) }), _jsx(CardContent, { children: content })] }));
|
|
30
40
|
if (categories) {
|
|
31
41
|
const visibleCategories = categories.filter(cat => cat.items.length > 0);
|
|
32
|
-
const categorySections = (_jsx(StyledShortcutsCategoriesContainer, { ref: categoriesContainerRef, children: visibleCategories.map(cat => (_jsxs(Flex, { container: { direction: 'column' }, "aria-labelledby": `cat-${cat.id}`, "data-testid": testIds.categorySection, as: 'section', children: [_jsx(StyledShortcutsCategoryHeading, { id: `cat-${cat.id}`, "data-testid": testIds.categoryHeading, variant: 'h3', children: cat.label }), _jsx(StyledShortcutsCardsContainer, { role: 'list', "aria-label": cat.label, children: cat.items.map(item => (_jsx(CardItem, { item: item,
|
|
42
|
+
const categorySections = (_jsx(StyledShortcutsCategoriesContainer, { ref: categoriesContainerRef, children: visibleCategories.map(cat => (_jsxs(Flex, { container: { direction: 'column' }, "aria-labelledby": `cat-${cat.id}`, "data-testid": testIds.categorySection, as: 'section', children: [_jsx(StyledShortcutsCategoryHeading, { id: `cat-${cat.id}`, "data-testid": testIds.categoryHeading, variant: 'h3', children: cat.label }), _jsx(StyledShortcutsCardsContainer, { role: 'list', "aria-label": cat.label, children: cat.items.map(item => (_jsx(CardItem, { item: item, variant: variant }, item.id))) })] }, cat.id))) }));
|
|
33
43
|
return withCardShell(visibleCategories.length === 0 ? emptyState : categorySections);
|
|
34
44
|
}
|
|
35
|
-
const cardGrid = (_jsx(StyledShortcutsCardsWrapper, { children: _jsx(StyledShortcutsCardsContainer, { ref: flatListRef, role: 'list', "data-testid": testIds.list, "aria-label": heading ?? t('shortcuts'), children: items.map(item => (_jsx(CardItem, { item: item,
|
|
45
|
+
const cardGrid = (_jsx(StyledShortcutsCardsWrapper, { children: _jsx(StyledShortcutsCardsContainer, { ref: flatListRef, role: 'list', "data-testid": testIds.list, "aria-label": heading ?? t('shortcuts'), children: items.map(item => (_jsx(CardItem, { item: item, variant: variant }, item.id))) }) }));
|
|
36
46
|
if (!showHeader) {
|
|
37
47
|
if (items.length === 0)
|
|
38
48
|
return null;
|
|
@@ -1 +1 @@
|
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AAO,IAHX,IAAI,CAAC,EAAE,CAIZ,CACH,CAAC,GAC4B,KAtB3B,GAAG,CAAC,EAAE,CAuBN,CACR,CAAC,GACiC,CACtC,CAAC;QAEF,OAAO,aAAa,CAAC,iBAAiB,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;IACvF,CAAC;IAED,MAAM,QAAQ,GAAG,CACf,KAAC,2BAA2B,cAC1B,KAAC,6BAA6B,IAC5B,GAAG,EAAE,WAAW,EAChB,IAAI,EAAC,MAAM,iBACE,OAAO,CAAC,IAAI,gBACb,OAAO,IAAI,CAAC,CAAC,WAAW,CAAC,YAEpC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CACjB,KAAC,QAAQ,IAAe,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,IAArE,IAAI,CAAC,EAAE,CAAkE,CACzF,CAAC,GAC4B,GACJ,CAC/B,CAAC;IAEF,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAEpC,OAAO,CACL,8BAAkB,OAAO,CAAC,IAAI,KAAM,SAAS,EAAE,GAAG,EAAE,GAAG,aACrD,KAAC,kBAAkB,cAAE,OAAO,IAAI,CAAC,CAAC,WAAW,CAAC,GAAsB,EACnE,QAAQ,IACL,CACP,CAAC;IACJ,CAAC;IAED,OAAO,aAAa,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AACnE,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { useRef, forwardRef } from 'react';\nimport type { ReactNode, PropsWithoutRef } from 'react';\nimport { parseToRgb } from 'polished';\n\nimport {\n Card,\n CardContent,\n CardHeader,\n EmptyState,\n Flex,\n Text,\n VisuallyHiddenText,\n registerIcon,\n tryCatch,\n useArrows,\n useI18n,\n useTestIds,\n useTheme,\n withTestIds\n} from '@pega/cosmos-react-core';\nimport * as openNewTabIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/open.icon';\n\nimport type { ShortcutsProps, ShortcutItem } from './Shortcuts.types';\nimport {\n StyledExternalIcon,\n StyledLabelRow,\n StyledShortcutsCard,\n StyledShortcutsCardButton,\n StyledShortcutsCardsContainer,\n StyledShortcutsCardsWrapper,\n StyledShortcutsCategoriesContainer,\n StyledShortcutsCategoryHeading,\n StyledShortcutsCardIcon,\n StyledText\n} from './Shortcuts.styles';\nimport { getShortcutsTestIds } from './Shortcuts.test-ids';\n\nregisterIcon(openNewTabIcon);\n\nconst itemLinkProps = (\n item: ShortcutItem\n): {\n href?: string;\n target?: string;\n rel?: string;\n onClick?: () => void;\n} => {\n if (item.type === 'external') {\n return { href: item.href, target: '_blank', rel: 'noopener noreferrer' };\n }\n\n return { onClick: item.onClick };\n};\n\nconst CardItem = ({\n item,\n iconBackground,\n variant\n}: {\n item: ShortcutItem;\n iconBackground: string;\n variant: 'stacked' | 'inline';\n}) => (\n <StyledShortcutsCard>\n <StyledShortcutsCardButton variant='link' layoutVariant={variant} {...itemLinkProps(item)}>\n <StyledShortcutsCardIcon\n name={item.icon}\n background={iconBackground}\n shape='square'\n layoutVariant={variant}\n />\n <StyledLabelRow>\n <StyledText>{item.label}</StyledText>\n\n {item.type === 'external' && <StyledExternalIcon name='open' />}\n </StyledLabelRow>\n </StyledShortcutsCardButton>\n </StyledShortcutsCard>\n);\n\nconst Shortcuts = forwardRef(function Shortcuts(\n {\n heading,\n items = [],\n categories,\n showHeader = true,\n variant = 'inline',\n testId,\n ...restProps\n }: PropsWithoutRef<ShortcutsProps>,\n ref: ShortcutsProps['ref']\n) {\n const t = useI18n();\n const testIds = useTestIds(testId, getShortcutsTestIds);\n const {\n base: {\n palette: { 'brand-accent': brandAccent, 'brand-primary': brandPrimary }\n }\n } = useTheme();\n\n const iconBackground =\n tryCatch(() => {\n parseToRgb(brandAccent);\n return brandAccent;\n }) ?? brandPrimary;\n\n const flatListRef = useRef<HTMLUListElement>(null);\n const categoriesContainerRef = useRef<HTMLDivElement>(null);\n\n useArrows(flatListRef, { dir: 'both', cycle: true });\n useArrows(categoriesContainerRef, { dir: 'both', cycle: true });\n\n const emptyState = <EmptyState message={t('no_items')} data-testid={testIds.emptyState} />;\n\n const withCardShell = (content: ReactNode) => (\n <Card {...restProps} data-testid={testIds.root} ref={ref}>\n <CardHeader>\n <Text variant='h2'>{heading ?? t('shortcuts')}</Text>\n </CardHeader>\n <CardContent>{content}</CardContent>\n </Card>\n );\n\n if (categories) {\n const visibleCategories = categories.filter(cat => cat.items.length > 0);\n\n const categorySections = (\n <StyledShortcutsCategoriesContainer ref={categoriesContainerRef}>\n {visibleCategories.map(cat => (\n <Flex\n container={{ direction: 'column' }}\n key={cat.id}\n aria-labelledby={`cat-${cat.id}`}\n data-testid={testIds.categorySection}\n as='section'\n >\n <StyledShortcutsCategoryHeading\n id={`cat-${cat.id}`}\n data-testid={testIds.categoryHeading}\n variant='h3'\n >\n {cat.label}\n </StyledShortcutsCategoryHeading>\n\n <StyledShortcutsCardsContainer role='list' aria-label={cat.label}>\n {cat.items.map(item => (\n <CardItem\n key={item.id}\n item={item}\n iconBackground={iconBackground}\n variant={variant}\n />\n ))}\n </StyledShortcutsCardsContainer>\n </Flex>\n ))}\n </StyledShortcutsCategoriesContainer>\n );\n\n return withCardShell(visibleCategories.length === 0 ? emptyState : categorySections);\n }\n\n const cardGrid = (\n <StyledShortcutsCardsWrapper>\n <StyledShortcutsCardsContainer\n ref={flatListRef}\n role='list'\n data-testid={testIds.list}\n aria-label={heading ?? t('shortcuts')}\n >\n {items.map(item => (\n <CardItem key={item.id} item={item} iconBackground={iconBackground} variant={variant} />\n ))}\n </StyledShortcutsCardsContainer>\n </StyledShortcutsCardsWrapper>\n );\n\n if (!showHeader) {\n if (items.length === 0) return null;\n\n return (\n <div data-testid={testIds.root} {...restProps} ref={ref}>\n <VisuallyHiddenText>{heading ?? t('shortcuts')}</VisuallyHiddenText>\n {cardGrid}\n </div>\n );\n }\n\n return withCardShell(items.length === 0 ? emptyState : cardGrid);\n});\n\nexport default withTestIds(Shortcuts, getShortcutsTestIds);\n"]}
|
|
1
|
+
{"version":3,"file":"Shortcuts.js","sourceRoot":"","sources":["../../../src/components/Shortcuts/Shortcuts.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAG3C,OAAO,EACL,wBAAwB,EACxB,IAAI,EACJ,WAAW,EACX,UAAU,EACV,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,OAAO,EACP,UAAU,EACV,QAAQ,EACR,WAAW,EACZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,cAAc,MAAM,6DAA6D,CAAC;AAG9F,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,yBAAyB,EACzB,6BAA6B,EAC7B,2BAA2B,EAC3B,kCAAkC,EAClC,8BAA8B,EAC9B,uBAAuB,EACvB,UAAU,EACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,YAAY,CAAC,cAAc,CAAC,CAAC;AAE7B,MAAM,aAAa,GAAG,CACpB,IAAkB,EAMlB,EAAE;IACF,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC7B,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,qBAAqB,EAAE,CAAC;IAC3E,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;AACn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,KAAC,QAAQ,IAAe,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,IAArC,IAAI,CAAC,EAAE,CAAkC,CACzD,CAAC,GAC4B,GACJ,CAC/B,CAAC;IAEF,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAEpC,OAAO,CACL,8BAAkB,OAAO,CAAC,IAAI,KAAM,SAAS,EAAE,GAAG,EAAE,GAAG,aACrD,KAAC,kBAAkB,cAAE,OAAO,IAAI,CAAC,CAAC,WAAW,CAAC,GAAsB,EACnE,QAAQ,IACL,CACP,CAAC;IACJ,CAAC;IAED,OAAO,aAAa,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AACnE,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { useRef, forwardRef } from 'react';\nimport type { ReactNode, PropsWithoutRef } from 'react';\n\nimport {\n calculateForegroundColor,\n Card,\n CardContent,\n CardHeader,\n EmptyState,\n Flex,\n Text,\n VisuallyHiddenText,\n readableColor,\n registerIcon,\n isSolidColor,\n useArrows,\n useI18n,\n useTestIds,\n useTheme,\n withTestIds\n} from '@pega/cosmos-react-core';\nimport * as openNewTabIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/open.icon';\n\nimport type { ShortcutsProps, ShortcutItem } from './Shortcuts.types';\nimport {\n StyledExternalIcon,\n StyledLabelRow,\n StyledShortcutsCard,\n StyledShortcutsCardButton,\n StyledShortcutsCardsContainer,\n StyledShortcutsCardsWrapper,\n StyledShortcutsCategoriesContainer,\n StyledShortcutsCategoryHeading,\n StyledShortcutsCardIcon,\n StyledText\n} from './Shortcuts.styles';\nimport { getShortcutsTestIds } from './Shortcuts.test-ids';\n\nregisterIcon(openNewTabIcon);\n\nconst itemLinkProps = (\n item: ShortcutItem\n): {\n href?: string;\n target?: string;\n rel?: string;\n onClick?: () => void;\n} => {\n if (item.type === 'external') {\n return { href: item.href, target: '_blank', rel: 'noopener noreferrer' };\n }\n\n return { onClick: item.onClick };\n};\n\nconst CardItem = ({ item, variant }: { item: ShortcutItem; variant: 'stacked' | 'inline' }) => {\n const {\n components: {\n card,\n shortcuts: {\n icon: { background: configuredIconBackground, foreground: configuredIconForeground }\n }\n }\n } = useTheme();\n\n const iconBackground = configuredIconBackground;\n const withIconBackground = Boolean(isSolidColor(iconBackground));\n\n const cardForeground = calculateForegroundColor(card.background, card['foreground-color']);\n let iconForeground = configuredIconForeground;\n\n if (configuredIconForeground === 'auto') {\n iconForeground = withIconBackground\n ? readableColor(iconBackground, { mode: 'light', level: 'AANonText' })\n : cardForeground;\n }\n\n const commonIconProps = {\n name: item.icon,\n layoutVariant: variant\n };\n\n return (\n <StyledShortcutsCard>\n <StyledShortcutsCardButton variant='link' layoutVariant={variant} {...itemLinkProps(item)}>\n {withIconBackground ? (\n <StyledShortcutsCardIcon\n {...commonIconProps}\n background={iconBackground}\n foreground={iconForeground}\n />\n ) : (\n <StyledShortcutsCardIcon {...commonIconProps} iconColor={iconForeground} />\n )}\n <StyledLabelRow>\n <StyledText>{item.label}</StyledText>\n\n {item.type === 'external' && <StyledExternalIcon name='open' />}\n </StyledLabelRow>\n </StyledShortcutsCardButton>\n </StyledShortcutsCard>\n );\n};\n\nconst Shortcuts = forwardRef(function Shortcuts(\n {\n heading,\n items = [],\n categories,\n showHeader = true,\n variant = 'inline',\n testId,\n ...restProps\n }: PropsWithoutRef<ShortcutsProps>,\n ref: ShortcutsProps['ref']\n) {\n const t = useI18n();\n const testIds = useTestIds(testId, getShortcutsTestIds);\n\n const flatListRef = useRef<HTMLUListElement>(null);\n const categoriesContainerRef = useRef<HTMLDivElement>(null);\n\n useArrows(flatListRef, { dir: 'both', cycle: true });\n useArrows(categoriesContainerRef, { dir: 'both', cycle: true });\n\n const emptyState = <EmptyState message={t('no_items')} data-testid={testIds.emptyState} />;\n\n const withCardShell = (content: ReactNode) => (\n <Card {...restProps} data-testid={testIds.root} ref={ref}>\n <CardHeader>\n <Text variant='h2'>{heading ?? t('shortcuts')}</Text>\n </CardHeader>\n <CardContent>{content}</CardContent>\n </Card>\n );\n\n if (categories) {\n const visibleCategories = categories.filter(cat => cat.items.length > 0);\n\n const categorySections = (\n <StyledShortcutsCategoriesContainer ref={categoriesContainerRef}>\n {visibleCategories.map(cat => (\n <Flex\n container={{ direction: 'column' }}\n key={cat.id}\n aria-labelledby={`cat-${cat.id}`}\n data-testid={testIds.categorySection}\n as='section'\n >\n <StyledShortcutsCategoryHeading\n id={`cat-${cat.id}`}\n data-testid={testIds.categoryHeading}\n variant='h3'\n >\n {cat.label}\n </StyledShortcutsCategoryHeading>\n\n <StyledShortcutsCardsContainer role='list' aria-label={cat.label}>\n {cat.items.map(item => (\n <CardItem key={item.id} item={item} variant={variant} />\n ))}\n </StyledShortcutsCardsContainer>\n </Flex>\n ))}\n </StyledShortcutsCategoriesContainer>\n );\n\n return withCardShell(visibleCategories.length === 0 ? emptyState : categorySections);\n }\n\n const cardGrid = (\n <StyledShortcutsCardsWrapper>\n <StyledShortcutsCardsContainer\n ref={flatListRef}\n role='list'\n data-testid={testIds.list}\n aria-label={heading ?? t('shortcuts')}\n >\n {items.map(item => (\n <CardItem key={item.id} item={item} variant={variant} />\n ))}\n </StyledShortcutsCardsContainer>\n </StyledShortcutsCardsWrapper>\n );\n\n if (!showHeader) {\n if (items.length === 0) return null;\n\n return (\n <div data-testid={testIds.root} {...restProps} ref={ref}>\n <VisuallyHiddenText>{heading ?? t('shortcuts')}</VisuallyHiddenText>\n {cardGrid}\n </div>\n );\n }\n\n return withCardShell(items.length === 0 ? emptyState : cardGrid);\n});\n\nexport default withTestIds(Shortcuts, getShortcutsTestIds);\n"]}
|
|
@@ -12,6 +12,7 @@ export declare const StyledShortcutsCardButton: import("styled-components/dist/t
|
|
|
12
12
|
}>> & string & Omit<import("@pega/cosmos-react-core").ForwardRefForwardPropsComponent<import("@pega/cosmos-react-core").ButtonProps>, keyof import("react").Component<any, {}, any>>;
|
|
13
13
|
export declare const StyledShortcutsCardIcon: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("@pega/cosmos-react-core").IconProps & import("styled-components/dist/types").BaseObject, {
|
|
14
14
|
layoutVariant: "stacked" | "inline";
|
|
15
|
+
iconColor?: string;
|
|
15
16
|
}>> & string & Omit<import("react").ForwardRefExoticComponent<import("@pega/cosmos-react-core").IconProps>, keyof import("react").Component<any, {}, any>>;
|
|
16
17
|
export declare const StyledLabelRow: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
|
|
17
18
|
export declare const StyledText: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Shortcuts.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Shortcuts/Shortcuts.styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,2BAA2B,6NAEvC,CAAC;AAEF,eAAO,MAAM,6BAA6B,iOAqBxC,CAAC;AAIH,eAAO,MAAM,kCAAkC,6NAS9C,CAAC;AAIF,eAAO,MAAM,8BAA8B;;yLAIzC,CAAC;AAIH,eAAO,MAAM,mBAAmB,6NAG/B,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;mBAAmC,SAAS,GAAG,QAAQ;oLAwC3F,CAAC;AAIH,eAAO,MAAM,uBAAuB;
|
|
1
|
+
{"version":3,"file":"Shortcuts.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Shortcuts/Shortcuts.styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,2BAA2B,6NAEvC,CAAC;AAEF,eAAO,MAAM,6BAA6B,iOAqBxC,CAAC;AAIH,eAAO,MAAM,kCAAkC,6NAS9C,CAAC;AAIF,eAAO,MAAM,8BAA8B;;yLAIzC,CAAC;AAIH,eAAO,MAAM,mBAAmB,6NAG/B,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;mBAAmC,SAAS,GAAG,QAAQ;oLAwC3F,CAAC;AAIH,eAAO,MAAM,uBAAuB;mBACnB,SAAS,GAAG,QAAQ;gBACvB,MAAM;0JAgBnB,CAAC;AAIF,eAAO,MAAM,cAAc,+NAM1B,CAAC;AAIF,eAAO,MAAM,UAAU,+NAMtB,CAAC;AAIF,eAAO,MAAM,kBAAkB,kaAE9B,CAAC"}
|
|
@@ -82,7 +82,7 @@ export const StyledShortcutsCardButton = styled(Button)(({ theme: { base, compon
|
|
|
82
82
|
`;
|
|
83
83
|
});
|
|
84
84
|
StyledShortcutsCardButton.defaultProps = defaultThemeProp;
|
|
85
|
-
export const StyledShortcutsCardIcon = styled(Icon)(({ layoutVariant }) => css `
|
|
85
|
+
export const StyledShortcutsCardIcon = styled(Icon)(({ layoutVariant, iconColor }) => css `
|
|
86
86
|
flex-shrink: 0;
|
|
87
87
|
|
|
88
88
|
${layoutVariant === 'stacked' &&
|
|
@@ -90,6 +90,11 @@ export const StyledShortcutsCardIcon = styled(Icon)(({ layoutVariant }) => css `
|
|
|
90
90
|
width: 3rem;
|
|
91
91
|
height: 3rem;
|
|
92
92
|
`}
|
|
93
|
+
|
|
94
|
+
${iconColor &&
|
|
95
|
+
css `
|
|
96
|
+
color: ${iconColor};
|
|
97
|
+
`}
|
|
93
98
|
`);
|
|
94
99
|
StyledShortcutsCardIcon.defaultProps = defaultThemeProp;
|
|
95
100
|
export const StyledLabelRow = styled.span(({ theme: { base } }) => css `
|