@pega/cosmos-react-work 9.0.0-build.9.9 → 9.0.1
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 -1
- package/lib/components/AppAnnouncement/AppAnnouncement.d.ts.map +1 -1
- package/lib/components/AppAnnouncement/AppAnnouncement.js +36 -21
- package/lib/components/AppAnnouncement/AppAnnouncement.js.map +1 -1
- package/lib/components/Article/ArticleRating.d.ts +1 -1
- package/lib/components/Article/ArticleRating.d.ts.map +1 -1
- package/lib/components/ArticleList/AIArticleSummary.d.ts +3 -1
- package/lib/components/ArticleList/AIArticleSummary.d.ts.map +1 -1
- package/lib/components/ArticleList/ArticleBuddy.d.ts +1 -1
- package/lib/components/ArticleList/ArticleBuddy.d.ts.map +1 -1
- package/lib/components/ArticleList/ArticleBuddy.js +5 -1
- package/lib/components/ArticleList/ArticleBuddy.js.map +1 -1
- package/lib/components/ArticleList/ArticleBuddyList.d.ts +1 -1
- package/lib/components/ArticleList/ArticleBuddyList.d.ts.map +1 -1
- package/lib/components/ArticleList/ArticleBuddyResponse.d.ts +189 -3
- package/lib/components/ArticleList/ArticleBuddyResponse.d.ts.map +1 -1
- package/lib/components/ArticleList/ArticleBuddyResponse.js +1 -1
- package/lib/components/ArticleList/ArticleBuddyResponse.js.map +1 -1
- package/lib/components/ArticleList/ArticleFeedback.d.ts +3 -1
- package/lib/components/ArticleList/ArticleFeedback.d.ts.map +1 -1
- package/lib/components/ArticleList/ArticleList.d.ts +2 -2
- package/lib/components/ArticleList/ArticleList.d.ts.map +1 -1
- package/lib/components/ArticleList/ArticleList.js +6 -0
- package/lib/components/ArticleList/ArticleList.js.map +1 -1
- package/lib/components/ArticleList/ArticleList.types.d.ts +17 -2
- package/lib/components/ArticleList/ArticleList.types.d.ts.map +1 -1
- package/lib/components/ArticleList/ArticleList.types.js.map +1 -1
- package/lib/components/ArticleList/ArticleListHeader.d.ts +183 -1
- package/lib/components/ArticleList/ArticleListHeader.d.ts.map +1 -1
- package/lib/components/ArticleList/ArticleSummary.styles.d.ts +2 -2
- package/lib/components/ArticleList/ArticleSummary.styles.d.ts.map +1 -1
- package/lib/components/ArticleList/ArticleSummaryHeader.d.ts.map +1 -1
- package/lib/components/ArticleList/ArticleSummaryHeader.js +3 -1
- package/lib/components/ArticleList/ArticleSummaryHeader.js.map +1 -1
- package/lib/components/ArticleList/QuestionList.d.ts +5 -3
- package/lib/components/ArticleList/QuestionList.d.ts.map +1 -1
- package/lib/components/ArticleList/RelatedQuestions.d.ts +4 -2
- package/lib/components/ArticleList/RelatedQuestions.d.ts.map +1 -1
- package/lib/components/Assignments/Assignments.d.ts +2 -2
- package/lib/components/Assignments/Assignments.d.ts.map +1 -1
- package/lib/components/Assignments/Assignments.js +1 -1
- package/lib/components/Assignments/Assignments.js.map +1 -1
- package/lib/components/Assignments/Assignments.styles.d.ts +7 -3
- package/lib/components/Assignments/Assignments.styles.d.ts.map +1 -1
- package/lib/components/CaseHierarchy/CaseHierarchy.d.ts +2 -2
- package/lib/components/CaseHierarchy/CaseHierarchy.d.ts.map +1 -1
- package/lib/components/CaseHierarchy/CaseHierarchy.js +4 -3
- package/lib/components/CaseHierarchy/CaseHierarchy.js.map +1 -1
- package/lib/components/CaseHierarchy/CaseHierarchy.styles.d.ts +7 -3
- package/lib/components/CaseHierarchy/CaseHierarchy.styles.d.ts.map +1 -1
- package/lib/components/CaseHierarchy/CaseHierarchy.styles.js +9 -7
- package/lib/components/CaseHierarchy/CaseHierarchy.styles.js.map +1 -1
- package/lib/components/CaseHierarchy/CaseHierarchy.test-ids.d.ts +1 -1
- package/lib/components/CaseHierarchy/CaseHierarchy.test-ids.d.ts.map +1 -1
- package/lib/components/CaseHierarchy/CaseHierarchy.test-ids.js +2 -1
- package/lib/components/CaseHierarchy/CaseHierarchy.test-ids.js.map +1 -1
- package/lib/components/CaseHierarchy/CaseHierarchy.types.d.ts +7 -1
- package/lib/components/CaseHierarchy/CaseHierarchy.types.d.ts.map +1 -1
- package/lib/components/CaseHierarchy/CaseHierarchy.types.js.map +1 -1
- package/lib/components/CasePreview/CasePreview.d.ts +1 -1
- package/lib/components/CasePreview/CasePreview.d.ts.map +1 -1
- package/lib/components/CasePreview/CasePreview.js +83 -115
- package/lib/components/CasePreview/CasePreview.js.map +1 -1
- package/lib/components/CaseView/CaseHeader/CaseHeader.d.ts.map +1 -1
- package/lib/components/CaseView/CaseHeader/CaseHeader.js +97 -27
- package/lib/components/CaseView/CaseHeader/CaseHeader.js.map +1 -1
- package/lib/components/CaseView/CaseHeader/Summary.d.ts.map +1 -1
- package/lib/components/CaseView/CaseHeader/Summary.js +8 -1
- package/lib/components/CaseView/CaseHeader/Summary.js.map +1 -1
- package/lib/components/CaseView/CaseSummaryFields.js +1 -1
- package/lib/components/CaseView/CaseSummaryFields.js.map +1 -1
- package/lib/components/CaseView/CaseView.d.ts.map +1 -1
- package/lib/components/CaseView/CaseView.js +49 -20
- package/lib/components/CaseView/CaseView.js.map +1 -1
- package/lib/components/CaseView/CaseView.styles.d.ts +83 -47
- package/lib/components/CaseView/CaseView.styles.d.ts.map +1 -1
- package/lib/components/CaseView/CaseView.styles.js +329 -122
- package/lib/components/CaseView/CaseView.styles.js.map +1 -1
- package/lib/components/CaseView/CaseView.types.d.ts +24 -8
- package/lib/components/CaseView/CaseView.types.d.ts.map +1 -1
- package/lib/components/CaseView/CaseView.types.js.map +1 -1
- package/lib/components/CaseView/UtilitiesSummary.d.ts +1 -1
- package/lib/components/CaseView/UtilitiesSummary.d.ts.map +1 -1
- package/lib/components/CaseView/UtilitiesSummary.js +14 -4
- package/lib/components/CaseView/UtilitiesSummary.js.map +1 -1
- package/lib/components/CaseView/UtilitySummaryItemDialog.d.ts.map +1 -1
- package/lib/components/CaseView/UtilitySummaryItemDialog.js +10 -4
- package/lib/components/CaseView/UtilitySummaryItemDialog.js.map +1 -1
- package/lib/components/ConfigurableLayout/LayoutCell.d.ts.map +1 -1
- package/lib/components/ConfigurableLayout/LayoutCell.js +25 -25
- package/lib/components/ConfigurableLayout/LayoutCell.js.map +1 -1
- package/lib/components/Confirmation/Confirmation.d.ts +10 -0
- package/lib/components/Confirmation/Confirmation.d.ts.map +1 -1
- package/lib/components/Confirmation/Confirmation.js +2 -2
- package/lib/components/Confirmation/Confirmation.js.map +1 -1
- package/lib/components/Confirmation/index.d.ts +1 -1
- package/lib/components/Confirmation/index.d.ts.map +1 -1
- package/lib/components/Confirmation/index.js.map +1 -1
- package/lib/components/Details/Details.d.ts +3 -2
- package/lib/components/Details/Details.d.ts.map +1 -1
- package/lib/components/Details/Details.js +6 -5
- package/lib/components/Details/Details.js.map +1 -1
- package/lib/components/Details/Details.styles.d.ts +17 -15
- package/lib/components/Details/Details.styles.d.ts.map +1 -1
- package/lib/components/Details/Details.styles.js +28 -15
- package/lib/components/Details/Details.styles.js.map +1 -1
- package/lib/components/Details/Details.test-ids.d.ts +1 -1
- package/lib/components/Details/Details.test-ids.d.ts.map +1 -1
- package/lib/components/Details/Details.test-ids.js +2 -1
- package/lib/components/Details/Details.test-ids.js.map +1 -1
- package/lib/components/Details/DetailsList.d.ts.map +1 -1
- package/lib/components/Details/DetailsList.js +1 -5
- package/lib/components/Details/DetailsList.js.map +1 -1
- package/lib/components/GenAICoach/ActiveCases.d.ts +5 -0
- package/lib/components/GenAICoach/ActiveCases.d.ts.map +1 -0
- package/lib/components/GenAICoach/ActiveCases.js +50 -0
- package/lib/components/GenAICoach/ActiveCases.js.map +1 -0
- package/lib/components/GenAICoach/CaseWorkflow.d.ts +5 -0
- package/lib/components/GenAICoach/CaseWorkflow.d.ts.map +1 -0
- package/lib/components/GenAICoach/CaseWorkflow.js +111 -0
- package/lib/components/GenAICoach/CaseWorkflow.js.map +1 -0
- package/lib/components/GenAICoach/ConversationHistory.d.ts.map +1 -1
- package/lib/components/GenAICoach/ConversationHistory.js +11 -13
- package/lib/components/GenAICoach/ConversationHistory.js.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.d.ts +4 -3
- package/lib/components/GenAICoach/GenAICoach.d.ts.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.js +721 -141
- package/lib/components/GenAICoach/GenAICoach.js.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.styles.d.ts +1639 -35
- package/lib/components/GenAICoach/GenAICoach.styles.d.ts.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.styles.js +867 -82
- package/lib/components/GenAICoach/GenAICoach.styles.js.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.test-ids.d.ts +3 -2
- package/lib/components/GenAICoach/GenAICoach.test-ids.d.ts.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.test-ids.js +6 -1
- package/lib/components/GenAICoach/GenAICoach.test-ids.js.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.types.d.ts +215 -9
- 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/GenAIMessage.d.ts +6 -0
- package/lib/components/GenAICoach/GenAIMessage.d.ts.map +1 -1
- package/lib/components/GenAICoach/GenAIMessage.js +101 -52
- package/lib/components/GenAICoach/GenAIMessage.js.map +1 -1
- package/lib/components/GenAICoach/GenAIMessageFeedback.d.ts +4 -0
- package/lib/components/GenAICoach/GenAIMessageFeedback.d.ts.map +1 -0
- package/lib/components/GenAICoach/GenAIMessageFeedback.js +95 -0
- package/lib/components/GenAICoach/GenAIMessageFeedback.js.map +1 -0
- package/lib/components/GenAICoach/GenAIMessageProgress.d.ts +4 -1
- package/lib/components/GenAICoach/GenAIMessageProgress.d.ts.map +1 -1
- package/lib/components/GenAICoach/GenAIMessageProgress.js +11 -35
- package/lib/components/GenAICoach/GenAIMessageProgress.js.map +1 -1
- package/lib/components/GenAICoach/InitialSuggestedMessage.d.ts.map +1 -1
- package/lib/components/GenAICoach/InitialSuggestedMessage.js +5 -6
- package/lib/components/GenAICoach/InitialSuggestedMessage.js.map +1 -1
- package/lib/components/GenAICoach/PortalAgentSplitView.d.ts +6 -0
- package/lib/components/GenAICoach/PortalAgentSplitView.d.ts.map +1 -0
- package/lib/components/GenAICoach/PortalAgentSplitView.js +75 -0
- package/lib/components/GenAICoach/PortalAgentSplitView.js.map +1 -0
- package/lib/components/GenAICoach/Questionnaire.d.ts +4 -0
- package/lib/components/GenAICoach/Questionnaire.d.ts.map +1 -0
- package/lib/components/GenAICoach/Questionnaire.js +155 -0
- package/lib/components/GenAICoach/Questionnaire.js.map +1 -0
- package/lib/components/GenAICoach/ToolCandidates.d.ts +4 -0
- package/lib/components/GenAICoach/ToolCandidates.d.ts.map +1 -0
- package/lib/components/GenAICoach/ToolCandidates.js +19 -0
- package/lib/components/GenAICoach/ToolCandidates.js.map +1 -0
- package/lib/components/GenAICoach/ToolConfirmationMessage.d.ts +4 -0
- package/lib/components/GenAICoach/ToolConfirmationMessage.d.ts.map +1 -0
- package/lib/components/GenAICoach/ToolConfirmationMessage.js +20 -0
- package/lib/components/GenAICoach/ToolConfirmationMessage.js.map +1 -0
- package/lib/components/GenAICoach/ToolDetails.d.ts +5 -0
- package/lib/components/GenAICoach/ToolDetails.d.ts.map +1 -0
- package/lib/components/GenAICoach/ToolDetails.js +99 -0
- package/lib/components/GenAICoach/ToolDetails.js.map +1 -0
- package/lib/components/GenAICoach/index.d.ts +5 -3
- package/lib/components/GenAICoach/index.d.ts.map +1 -1
- package/lib/components/GenAICoach/index.js +4 -2
- package/lib/components/GenAICoach/index.js.map +1 -1
- package/lib/components/HierarchicalAssignments/Assignments.styles.d.ts +55 -34
- package/lib/components/HierarchicalAssignments/Assignments.styles.d.ts.map +1 -1
- package/lib/components/HierarchicalAssignments/Assignments.styles.js +41 -11
- package/lib/components/HierarchicalAssignments/Assignments.styles.js.map +1 -1
- package/lib/components/HierarchicalAssignments/HierarchicalAssignments.types.d.ts +2 -0
- package/lib/components/HierarchicalAssignments/HierarchicalAssignments.types.d.ts.map +1 -1
- package/lib/components/HierarchicalAssignments/HierarchicalAssignments.types.js.map +1 -1
- package/lib/components/HierarchicalAssignments/nodeItems/AssignmentItem.d.ts +1 -1
- package/lib/components/HierarchicalAssignments/nodeItems/AssignmentItem.d.ts.map +1 -1
- package/lib/components/HierarchicalAssignments/nodeItems/AssignmentItem.js +7 -4
- package/lib/components/HierarchicalAssignments/nodeItems/AssignmentItem.js.map +1 -1
- package/lib/components/HierarchicalAssignments/nodeItems/CaseDetail.d.ts.map +1 -1
- package/lib/components/HierarchicalAssignments/nodeItems/CaseDetail.js +2 -2
- package/lib/components/HierarchicalAssignments/nodeItems/CaseDetail.js.map +1 -1
- package/lib/components/IntelligentGuidance/IntelligentGuidance.d.ts.map +1 -1
- package/lib/components/IntelligentGuidance/IntelligentGuidance.js +1 -1
- package/lib/components/IntelligentGuidance/IntelligentGuidance.js.map +1 -1
- package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.d.ts +9 -5
- package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.d.ts.map +1 -1
- package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.js +17 -3
- package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.js.map +1 -1
- package/lib/components/InteractionNotification/InteractionNotification.d.ts +31 -8
- package/lib/components/InteractionNotification/InteractionNotification.d.ts.map +1 -1
- package/lib/components/InteractionNotification/InteractionNotification.js +17 -10
- package/lib/components/InteractionNotification/InteractionNotification.js.map +1 -1
- package/lib/components/Predictions/Predictions.d.ts.map +1 -1
- package/lib/components/Predictions/Predictions.js +11 -2
- package/lib/components/Predictions/Predictions.js.map +1 -1
- package/lib/components/SearchResults/ActiveFilter.d.ts +1 -1
- package/lib/components/SearchResults/ActiveFilter.d.ts.map +1 -1
- package/lib/components/SearchResults/Filter.d.ts.map +1 -1
- package/lib/components/SearchResults/Filter.js +1 -1
- package/lib/components/SearchResults/Filter.js.map +1 -1
- package/lib/components/SearchResults/SearchResult.d.ts.map +1 -1
- package/lib/components/SearchResults/SearchResult.js +14 -6
- package/lib/components/SearchResults/SearchResult.js.map +1 -1
- package/lib/components/SearchResults/SearchResults.d.ts.map +1 -1
- package/lib/components/SearchResults/SearchResults.js +18 -3
- package/lib/components/SearchResults/SearchResults.js.map +1 -1
- package/lib/components/SearchResults/SearchResults.styles.d.ts +12 -10
- package/lib/components/SearchResults/SearchResults.styles.d.ts.map +1 -1
- package/lib/components/Shortcuts/Shortcuts.d.ts +7 -0
- package/lib/components/Shortcuts/Shortcuts.d.ts.map +1 -0
- package/lib/components/Shortcuts/Shortcuts.js +47 -0
- package/lib/components/Shortcuts/Shortcuts.js.map +1 -0
- package/lib/components/Shortcuts/Shortcuts.styles.d.ts +22 -0
- package/lib/components/Shortcuts/Shortcuts.styles.d.ts.map +1 -0
- package/lib/components/Shortcuts/Shortcuts.styles.js +114 -0
- package/lib/components/Shortcuts/Shortcuts.styles.js.map +1 -0
- package/lib/components/Shortcuts/Shortcuts.test-ids.d.ts +2 -0
- package/lib/components/Shortcuts/Shortcuts.test-ids.d.ts.map +1 -0
- package/lib/components/Shortcuts/Shortcuts.test-ids.js +8 -0
- package/lib/components/Shortcuts/Shortcuts.test-ids.js.map +1 -0
- package/lib/components/Shortcuts/Shortcuts.types.d.ts +64 -0
- package/lib/components/Shortcuts/Shortcuts.types.d.ts.map +1 -0
- package/lib/components/Shortcuts/Shortcuts.types.js +2 -0
- package/lib/components/Shortcuts/Shortcuts.types.js.map +1 -0
- package/lib/components/Shortcuts/index.d.ts +3 -0
- package/lib/components/Shortcuts/index.d.ts.map +1 -0
- package/lib/components/Shortcuts/index.js +2 -0
- package/lib/components/Shortcuts/index.js.map +1 -0
- package/lib/components/Stages/Stages.d.ts.map +1 -1
- package/lib/components/Stages/Stages.js +37 -12
- package/lib/components/Stages/Stages.js.map +1 -1
- package/lib/components/Stages/Stages.styles.d.ts +22 -15
- package/lib/components/Stages/Stages.styles.d.ts.map +1 -1
- package/lib/components/Stages/Stages.styles.js +285 -119
- package/lib/components/Stages/Stages.styles.js.map +1 -1
- package/lib/components/Stages/Stages.types.d.ts +5 -0
- package/lib/components/Stages/Stages.types.d.ts.map +1 -1
- package/lib/components/Stages/Stages.types.js.map +1 -1
- package/lib/components/Stakeholders/Stakeholders.d.ts.map +1 -1
- package/lib/components/Stakeholders/Stakeholders.js +109 -145
- package/lib/components/Stakeholders/Stakeholders.js.map +1 -1
- package/lib/components/Tags/Tags.d.ts +2 -2
- package/lib/components/Tags/Tags.d.ts.map +1 -1
- package/lib/components/Tags/Tags.js +12 -2
- package/lib/components/Tags/Tags.js.map +1 -1
- package/lib/components/Tasks/TaskList.d.ts +10 -3
- package/lib/components/Tasks/TaskList.d.ts.map +1 -1
- package/lib/components/Tasks/TaskList.js +59 -5
- package/lib/components/Tasks/TaskList.js.map +1 -1
- package/lib/components/Tasks/Tasks.d.ts +10 -3
- package/lib/components/Tasks/Tasks.d.ts.map +1 -1
- package/lib/components/Tasks/Tasks.js +29 -5
- package/lib/components/Tasks/Tasks.js.map +1 -1
- package/lib/components/UtilitiesLayout/UtilitiesLayout.d.ts.map +1 -1
- package/lib/components/UtilitiesLayout/UtilitiesLayout.js +3 -2
- package/lib/components/UtilitiesLayout/UtilitiesLayout.js.map +1 -1
- package/lib/components/UtilitiesLayout/UtilitiesLayout.styles.d.ts +2 -2
- package/lib/components/UtilitiesLayout/UtilitiesLayout.styles.d.ts.map +1 -1
- package/lib/components/UtilitiesLayout/UtilitiesLayout.styles.js +3 -2
- package/lib/components/UtilitiesLayout/UtilitiesLayout.styles.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/package.json +6 -7
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { getLuminance } from 'polished';
|
|
4
|
+
import { Button, Flex, Icon, MenuButton, Progress, Text, createUID, menuHelpers, useI18n, useSpeechRecognition, useTestIds, useTheme, withTestIds, registerIcon, usePrevious, getFocusables, isMenuGroupProps, ErrorState, useArrows, useFocusTrap, useLiveLog, useOuterEvent, ThemeOverride, hasProp, getActiveElement, useElement, Actions, useFullscreenContext, useBreakpoint, Grid, useRefMap, VisuallyHiddenText, FileList, Lightbox, FormField, useUID, SpeechToTextButton, Toaster, useToaster, throttle } from '@pega/cosmos-react-core';
|
|
4
5
|
import * as caretUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-up.icon';
|
|
5
6
|
import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
|
|
6
7
|
import * as caretDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-down.icon';
|
|
@@ -8,26 +9,89 @@ import * as minusIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/mi
|
|
|
8
9
|
import * as polarisSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/polaris-solid.icon';
|
|
9
10
|
import * as paperClipIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/paper-clip.icon';
|
|
10
11
|
import * as warnSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/warn-solid.icon';
|
|
12
|
+
import * as sendSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/send-solid.icon';
|
|
13
|
+
import * as squareSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/square-solid.icon';
|
|
14
|
+
import * as plusIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/plus.icon';
|
|
15
|
+
import * as dockIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/dock.icon';
|
|
16
|
+
import * as undockIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/undock.icon';
|
|
17
|
+
import * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';
|
|
18
|
+
import * as caretRightIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-right.icon';
|
|
11
19
|
import { getGenAICoachTestIds } from './GenAICoach.test-ids';
|
|
12
20
|
import { isCoachMessage, isInUtilities, isUserMessage } from './GenAICoach.utils';
|
|
13
|
-
import { StyledMessagesContainer, StyledDisclaimerText, StyledGenAICoachContainer, StyledGenAIOptionsMenu, StyledInitialMessageContainer, StyledInputContainer,
|
|
21
|
+
import { StyledMessagesContainer, StyledDisclaimerText, StyledGenAICoachContainer, StyledGenAIOptionsMenu, StyledInitialMessageContainer, StyledInputContainer, StyledMenuSuggestions, StyledMessagesList, StyledGridContainer, StyledFlexWrapper, StyledErrorContainer, StyledInput, StyledGuidedSuggestions, StyledComposerSection, StyledSendButton, StyledStopGeneratingButton, StyledGenAIFormControl, StyledGenAITextArea, StyledInitialMessageGrid, StyledGenAIFooter, StyledAgentIcon, StyledActionsContainer, StyledFullscreenWrapper, StyledScrollButton, StyledSuggestionCardsView, StyledSuggestionCardsBottomHalf, StyledStickyComposer, StyledAISuggestedBadge, StyledSalutation, StyledComposerWrapper } from './GenAICoach.styles';
|
|
22
|
+
import ActiveCases from './ActiveCases';
|
|
23
|
+
import CaseWorkflow from './CaseWorkflow';
|
|
14
24
|
import ConversationHistory from './ConversationHistory';
|
|
25
|
+
import Questionnaire from './Questionnaire';
|
|
15
26
|
import { GenAIMessage, InitialSuggestedMessage } from '.';
|
|
16
|
-
registerIcon(caretUpIcon, timesIcon, caretDownIcon, minusIcon, polarisSolidIcon, paperClipIcon, warnSolidIcon);
|
|
17
|
-
const
|
|
27
|
+
registerIcon(caretUpIcon, timesIcon, caretDownIcon, minusIcon, polarisSolidIcon, paperClipIcon, warnSolidIcon, squareSolidIcon, sendSolidIcon, plusIcon, dockIcon, undockIcon, caretLeftIcon, caretRightIcon);
|
|
28
|
+
export const AgentIcon = () => {
|
|
18
29
|
const theme = useTheme();
|
|
30
|
+
const uid = useUID();
|
|
31
|
+
const idA = `agent-gradient-a-${uid}`;
|
|
32
|
+
const idB = `agent-gradient-b-${uid}`;
|
|
33
|
+
const idC = `agent-clip-${uid}`;
|
|
34
|
+
const isLightTheme = getLuminance(theme.base.palette['foreground-color']) < 0.5;
|
|
35
|
+
return isLightTheme ? (_jsxs(StyledAgentIcon, { xmlns: 'http://www.w3.org/2000/svg', filter: 'drop-shadow(0 .125rem .125rem rgba(0,0,0,.03)) drop-shadow(.125rem .5rem .5rem rgba(0,0,0,.05)) drop-shadow(.125rem 1rem 1rem rgba(0,0,0,.08))', viewBox: '0 0 60 60', children: [_jsxs("linearGradient", { id: idA, x1: '30.586', x2: '3.059', y1: '58.111', y2: '30.584', gradientUnits: 'userSpaceOnUse', children: [_jsx("stop", { offset: '.115', stopColor: '#681fc3' }), _jsx("stop", { offset: '.418', stopColor: '#9795f3' }), _jsx("stop", { offset: '.591', stopColor: '#b3d2ff' }), _jsx("stop", { offset: '.966', stopColor: '#a467f0' })] }), _jsxs("linearGradient", { id: idB, x1: '7.137', x2: '29.565', y1: '0', y2: '60.151', gradientUnits: 'userSpaceOnUse', children: [_jsx("stop", { offset: '.457', stopColor: '#8165d2', stopOpacity: '0' }), _jsx("stop", { offset: '.524', stopColor: '#280096', stopOpacity: '.4' })] }), _jsx("clipPath", { id: idC, children: _jsx("path", { d: 'M0 0h60v60H0z' }) }), _jsxs("g", { fillRule: 'evenodd', clipPath: `url(#${idC})`, clipRule: 'evenodd', children: [_jsx("path", { fill: `url(#${idA})`, d: 'M60 30.002c-9.023.937-16.054 3.632-20.86 8.203C33.633 43.242 30.586 50.508 30 60c-1.173-9.61-4.453-16.875-9.727-21.914C15.35 33.516 8.555 30.82 0 30c9.023-.703 16.054-3.515 21.093-8.438C26.132 16.523 29.063 9.376 29.999 0c.704 10.43 4.102 18.164 10.313 23.202C45.352 27.186 51.914 29.413 60 30zm-3.75-18.75c-2.228.235-3.984.936-5.391 2.226-1.289 1.289-1.992 3.047-2.109 5.274-.235-2.227-.937-3.983-2.108-5.155-1.289-1.288-3.048-2.109-5.391-2.344 2.227-.116 3.867-.82 5.156-1.991 1.288-1.289 2.108-3.164 2.343-5.508.117 2.46.937 4.336 2.344 5.508 1.288 1.171 2.93 1.875 5.156 1.991zM18.75 48.75c-2.345.236-4.103.937-5.392 2.227-1.288 1.172-1.992 2.93-2.108 5.274-.235-2.46-1.055-4.218-2.46-5.507-1.056-1.055-2.812-1.758-5.04-1.992 1.993-.116 3.633-.703 4.804-1.758 1.524-1.172 2.46-3.047 2.696-5.743.116 1.992.703 3.751 1.875 5.156 1.172 1.288 3.047 2.108 5.626 2.344z' }), _jsx("path", { fill: `url(#${idB})`, d: 'M60 30.002c-9.023.937-16.054 3.632-20.86 8.203C33.633 43.242 30.586 50.508 30 60c-1.173-9.61-4.453-16.875-9.727-21.914C15.35 33.516 8.555 30.82 0 30c9.023-.703 16.054-3.515 21.093-8.438C26.132 16.523 29.063 9.376 29.999 0c.704 10.43 4.102 18.164 10.313 23.202C45.352 27.186 51.914 29.413 60 30zm-3.75-18.75c-2.228.235-3.984.936-5.391 2.226-1.289 1.289-1.992 3.047-2.109 5.274-.235-2.227-.937-3.983-2.108-5.155-1.289-1.288-3.048-2.109-5.391-2.344 2.227-.116 3.867-.82 5.156-1.991 1.288-1.289 2.108-3.164 2.343-5.508.117 2.46.937 4.336 2.344 5.508 1.288 1.171 2.93 1.875 5.156 1.991zM18.75 48.75c-2.345.236-4.103.937-5.392 2.227-1.288 1.172-1.992 2.93-2.108 5.274-.235-2.46-1.055-4.218-2.46-5.507-1.056-1.055-2.812-1.758-5.04-1.992 1.993-.116 3.633-.703 4.804-1.758 1.524-1.172 2.46-3.047 2.696-5.743.116 1.992.703 3.751 1.875 5.156 1.172 1.288 3.047 2.108 5.626 2.344z' })] })] })) : (_jsxs(StyledAgentIcon, { width: '26', height: '26', viewBox: '0 0 26 26', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', children: [_jsxs("g", { clipPath: `url(#${idC})`, children: [_jsx("path", { fillRule: 'evenodd', clipRule: 'evenodd', d: 'M26 13C22.0904 13.4036 19.0422 14.5723 16.9639 16.5542C14.5783 18.7349 13.259 21.8855 13 26C12.494 21.8374 11.0723 18.6867 8.78313 16.506C6.6506 14.5241 3.70482 13.3554 0 13C3.90964 12.6928 6.95783 11.4759 9.13855 9.34337C11.3193 7.16265 12.5904 4.06024 13 0C13.3072 4.51807 14.7771 7.87349 17.4699 10.0542C19.6506 11.7831 22.494 12.747 26 13ZM24.3735 4.87349C23.4096 4.9759 22.6446 5.27711 22.0361 5.83735C21.4759 6.39759 21.1747 7.15663 21.1205 8.12048C21.0181 7.15663 20.7169 6.39157 20.2048 5.88554C19.6446 5.3253 18.8855 4.96988 17.8675 4.86747C18.8313 4.81928 19.5422 4.51205 20.1024 4.00602C20.6627 3.44578 21.0181 2.63253 21.1205 1.62048C21.1687 2.68675 21.5241 3.5 22.1386 4.00602C22.6988 4.51205 23.4096 4.81928 24.3735 4.86747V4.87349ZM8.12651 21.1265C7.10843 21.2289 6.3494 21.5301 5.78916 22.0904C5.22892 22.5964 4.92771 23.3614 4.87349 24.3735C4.77108 23.3072 4.41566 22.5482 3.80723 21.988C3.3494 21.5301 2.59036 21.2289 1.62651 21.1265C2.48795 21.0783 3.1988 20.8193 3.71084 20.3675C4.37349 19.8614 4.77711 19.0482 4.87952 17.8795C4.92771 18.741 5.18675 19.506 5.69277 20.1145C6.1988 20.6747 7.01205 21.0301 8.13253 21.1325L8.12651 21.1265Z', fill: `url(#${idA})` }), _jsx("path", { fillRule: 'evenodd', clipRule: 'evenodd', d: 'M26 13C22.0904 13.4036 19.0422 14.5723 16.9639 16.5542C14.5783 18.7349 13.259 21.8855 13 26C12.494 21.8373 11.0723 18.6867 8.78313 16.506C6.6506 14.5241 3.70482 13.3554 0 13C3.90964 12.6928 6.95783 11.4759 9.13855 9.34337C11.3193 7.16265 12.5904 4.06024 13 0C13.3072 4.51807 14.7771 7.87349 17.4699 10.0542C19.6506 11.7831 22.494 12.747 26 13ZM24.3735 4.87349C23.4096 4.9759 22.6446 5.27711 22.0361 5.83735C21.4759 6.39759 21.1747 7.15663 21.1205 8.12048C21.0181 7.15663 20.7169 6.39157 20.2048 5.88554C19.6446 5.3253 18.8855 4.96988 17.8675 4.86747C18.8313 4.81928 19.5422 4.51205 20.1024 4.00602C20.6627 3.44578 21.0181 2.63253 21.1205 1.62048C21.1687 2.68675 21.5241 3.5 22.1386 4.00602C22.6988 4.51205 23.4096 4.81928 24.3735 4.86747V4.87349ZM8.12651 21.1265C7.10843 21.2289 6.3494 21.5301 5.78916 22.0904C5.22892 22.5964 4.92771 23.3614 4.87349 24.3735C4.77108 23.3072 4.41566 22.5482 3.80723 21.988C3.3494 21.5301 2.59036 21.2289 1.62651 21.1265C2.48795 21.0783 3.1988 20.8193 3.71084 20.3675C4.37349 19.8614 4.77711 19.0482 4.87952 17.8795C4.92771 18.741 5.18675 19.506 5.69277 20.1145C6.1988 20.6747 7.01205 21.0301 8.13253 21.1325L8.12651 21.1265Z', fill: `url(#${idB})` })] }), _jsxs("defs", { children: [_jsxs("linearGradient", { id: idA, x1: '19.2169', y1: '19.2169', x2: '7.28916', y2: '7.28916', gradientUnits: 'userSpaceOnUse', children: [_jsx("stop", { offset: '0.12', stopColor: '#D4B1FF' }), _jsx("stop", { offset: '0.42', stopColor: '#AE9AFE' }), _jsx("stop", { offset: '0.59', stopColor: '#AEB7FC' }), _jsx("stop", { offset: '0.97', stopColor: '#E4CAFF' })] }), _jsxs("linearGradient", { id: idB, x1: '7.53614', y1: '-1.65663', x2: '17.253', y2: '24.4096', gradientUnits: 'userSpaceOnUse', children: [_jsx("stop", { offset: '0.46', stopColor: '#8165D2', stopOpacity: '0' }), _jsx("stop", { offset: '0.52', stopColor: '#5B39B9', stopOpacity: '0.4' })] }), _jsx("clipPath", { id: idC, children: _jsx("rect", { width: '26', height: '26', fill: 'white' }) })] })] }));
|
|
36
|
+
};
|
|
37
|
+
export const AISuggestedBadge = () => {
|
|
38
|
+
const t = useI18n();
|
|
39
|
+
return (_jsxs(StyledAISuggestedBadge, { container: { alignItems: 'center', gap: 0.5 }, children: [_jsx(Icon, { name: 'polaris-solid', "aria-hidden": true, size: 'font-size' }), _jsx(Text, { children: t('ai_suggestion') })] }));
|
|
40
|
+
};
|
|
41
|
+
const HeaderActions = ({ actions, allowFullScreen, variant, isUserTriggeredRef, onFullscreenToggle, isFullscreen, selectedCoach, actionsTestId }) => {
|
|
19
42
|
const t = useI18n();
|
|
43
|
+
const fullscreenIcon = isFullscreen ? 'dock' : 'undock';
|
|
44
|
+
const extraItems = [
|
|
45
|
+
...(allowFullScreen
|
|
46
|
+
? [
|
|
47
|
+
{
|
|
48
|
+
id: 'fullscreen',
|
|
49
|
+
text: isFullscreen ? t('exit_fullscreen') : t('fullscreen'),
|
|
50
|
+
visual: _jsx(Icon, { name: fullscreenIcon }),
|
|
51
|
+
onClick: onFullscreenToggle
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
: []),
|
|
55
|
+
...(isInUtilities(variant) && !isFullscreen
|
|
56
|
+
? [
|
|
57
|
+
{
|
|
58
|
+
id: 'minimize',
|
|
59
|
+
text: t('minimize'),
|
|
60
|
+
visual: _jsx(Icon, { name: 'minus' }),
|
|
61
|
+
onClick: () => {
|
|
62
|
+
variant.onStateChange('minimized');
|
|
63
|
+
isUserTriggeredRef.current = true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
: [])
|
|
68
|
+
];
|
|
69
|
+
const mergedItems = [...(actions?.items ?? []), ...extraItems];
|
|
70
|
+
if (mergedItems.length === 0)
|
|
71
|
+
return null;
|
|
72
|
+
return (_jsx(Actions, { ...(actions ?? {}), menuAt: 1, "data-testid": actionsTestId, contextualLabel: selectedCoach, items: mergedItems }));
|
|
73
|
+
};
|
|
74
|
+
const GenAICoachContent = ({ testId, coachOptions: coachOptionsProps, onCoachChange: onCoachChangeProp, messages = [], onSend, initialSuggestedMessages, suggestions, loading, error, variant, onOpen, guidedMode = false, actions, onNewChat, conversationHistory, onLayoutChange, onAddAttachment, attachments, attachmentsError, lightboxPreviewProps, allowFullScreen = true, isInLandingPageUtilities, stopProcess, voiceToTextProps, salutation, showSalutation = true, isPortalAgent = false, pagePanel, suggestionCardsView, draftMessage, caseWorkflow, activeCases, onStop, isCreatingConversation, conversationError, questionnaireData, onQuestionnaireDismiss, ...restProps }) => {
|
|
75
|
+
const scrollTolerancePx = 2;
|
|
76
|
+
const scrollThresholdPx = 50;
|
|
77
|
+
const streamBufferLh = 5;
|
|
78
|
+
const bufferExtensionLh = 2;
|
|
79
|
+
const scrollThrottleMs = 50;
|
|
80
|
+
const resizeThrottleMs = 33;
|
|
81
|
+
const theme = useTheme();
|
|
82
|
+
const t = useI18n();
|
|
83
|
+
const testIds = useTestIds(testId, getGenAICoachTestIds);
|
|
84
|
+
const { announcePolite } = useLiveLog();
|
|
20
85
|
const elementRef = useRef(null);
|
|
21
86
|
const conversationRef = useRef(null);
|
|
22
87
|
const genAICoachRef = useRef(null);
|
|
23
88
|
const [messageEls, getMessageCbRef] = useRefMap();
|
|
24
|
-
const isSmallOrAbove = useBreakpoint('sm', {
|
|
25
|
-
breakpointRef: genAICoachRef
|
|
26
|
-
});
|
|
27
89
|
const focusInMessageListRef = useRef(false);
|
|
90
|
+
const mouseTriggeredFocusRef = useRef(false);
|
|
28
91
|
const isUserTriggered = useRef(false);
|
|
29
92
|
const lastFocusedMessageRef = useRef(null);
|
|
30
93
|
const initialFocusedElementRef = useRef(null);
|
|
94
|
+
const inputContainerRef = useRef(null);
|
|
31
95
|
const messageContainerRef = useRef(null);
|
|
32
96
|
const textAreaRef = useRef(null);
|
|
33
97
|
const [suggestionMenuButton, setSuggestionMenuButton] = useElement(null);
|
|
@@ -36,17 +100,287 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
|
|
|
36
100
|
const historyViewRef = useRef(null);
|
|
37
101
|
const fileUploadInputRef = useRef(null);
|
|
38
102
|
const attachmentsAdded = useRef(false);
|
|
103
|
+
const pendingResult = useRef(false);
|
|
104
|
+
const scrollStateRef = useRef({
|
|
105
|
+
userAtBottom: false,
|
|
106
|
+
isStreamingActive: false,
|
|
107
|
+
initialBufferApplied: false,
|
|
108
|
+
smoothScrollOnEnd: false,
|
|
109
|
+
ignoreNextScrollEvent: false,
|
|
110
|
+
lastScrollTop: null,
|
|
111
|
+
bufferMinHeight: null
|
|
112
|
+
});
|
|
113
|
+
const observersRef = useRef({
|
|
114
|
+
inputContainer: null,
|
|
115
|
+
messageContainer: null,
|
|
116
|
+
streamingMessage: null,
|
|
117
|
+
tileSync: null,
|
|
118
|
+
tileMutation: null
|
|
119
|
+
});
|
|
120
|
+
const isSmallOrAbove = useBreakpoint('sm', {
|
|
121
|
+
breakpointRef: genAICoachRef
|
|
122
|
+
});
|
|
39
123
|
const [message, setMessage] = useState('');
|
|
124
|
+
const [interimMessage, setInterimMessage] = useState('');
|
|
40
125
|
const [coachOptions, setCoachOptions] = useState(coachOptionsProps);
|
|
41
|
-
const [
|
|
126
|
+
const [focusedInMessage, setFocusedInMessage] = useState(false);
|
|
127
|
+
const scrollButtonRef = useRef(null);
|
|
128
|
+
const trapRef = useRef(null);
|
|
129
|
+
const [animationInitialCursorPos, setAnimationInitialCursorPos] = useState(0);
|
|
130
|
+
const [focused, setFocused] = useState(false);
|
|
131
|
+
const [formAnswers, setFormAnswers] = useState();
|
|
132
|
+
const [questionnaireDismissed, setQuestionnaireDismissed] = useState(false);
|
|
133
|
+
const [ctxFullscreen, toggleFullscreen] = useFullscreenContext() ?? [];
|
|
134
|
+
const fullScreen = !!ctxFullscreen;
|
|
135
|
+
const questionnaireKey = questionnaireData?.questions?.map(q => q.field).join(',') ?? '';
|
|
136
|
+
const [showScrollToBottom, setShowScrollToBottom] = useState(false);
|
|
137
|
+
const prevFullScreen = usePrevious(fullScreen);
|
|
138
|
+
const prevIsSmallOrAbove = usePrevious(isSmallOrAbove);
|
|
42
139
|
const previousMessages = usePrevious(messages);
|
|
43
|
-
const
|
|
44
|
-
const
|
|
140
|
+
const composerId = useUID();
|
|
141
|
+
const handleFormChange = useCallback((answers) => {
|
|
142
|
+
setFormAnswers(answers);
|
|
143
|
+
}, []);
|
|
144
|
+
const handleFormCancel = () => {
|
|
145
|
+
setFormAnswers(undefined);
|
|
146
|
+
setQuestionnaireDismissed(true);
|
|
147
|
+
textAreaRef.current?.focus();
|
|
148
|
+
onQuestionnaireDismiss?.();
|
|
149
|
+
};
|
|
45
150
|
const latestMessage = messages.at(-1);
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
151
|
+
const isLatestAgentMessageStreaming = !!latestMessage && isCoachMessage(latestMessage) && !!latestMessage.loading;
|
|
152
|
+
const shouldKeepSplitLayoutDuringFullscreenToggle = !!conversationHistory &&
|
|
153
|
+
variant.placement === 'fullpage' &&
|
|
154
|
+
prevFullScreen !== undefined &&
|
|
155
|
+
prevFullScreen !== fullScreen &&
|
|
156
|
+
!!prevIsSmallOrAbove;
|
|
157
|
+
const shouldRenderSideBySideHistory = !!conversationHistory &&
|
|
158
|
+
(fullScreen ||
|
|
159
|
+
(variant.placement === 'fullpage' &&
|
|
160
|
+
(isSmallOrAbove || shouldKeepSplitLayoutDuringFullscreenToggle)));
|
|
161
|
+
const condition = !shouldRenderSideBySideHistory &&
|
|
162
|
+
(variant.placement === 'dialog' ||
|
|
163
|
+
variant.placement === 'utilities' ||
|
|
164
|
+
(variant.placement === 'fullpage' && !isSmallOrAbove) ||
|
|
165
|
+
!conversationHistory);
|
|
166
|
+
const applyBuffer = useCallback(() => {
|
|
167
|
+
const container = messageContainerRef.current;
|
|
168
|
+
const conversationEl = conversationRef.current;
|
|
169
|
+
const scrollState = scrollStateRef.current;
|
|
170
|
+
if (!container || !conversationEl)
|
|
171
|
+
return;
|
|
172
|
+
const contentHeight = Array.from(conversationEl.children).reduce((sum, child) => {
|
|
173
|
+
if (child instanceof HTMLElement)
|
|
174
|
+
return sum + child.offsetHeight;
|
|
175
|
+
return sum;
|
|
176
|
+
}, 0);
|
|
177
|
+
const computedStyle = window.getComputedStyle(conversationEl);
|
|
178
|
+
const lineHeightPx = parseFloat(computedStyle.lineHeight) || 20;
|
|
179
|
+
const bufferSizePx = streamBufferLh * lineHeightPx;
|
|
180
|
+
const currentBuffer = scrollState.bufferMinHeight ?? 0;
|
|
181
|
+
const distanceToBufferEnd = currentBuffer - contentHeight;
|
|
182
|
+
const extensionThreshold = bufferExtensionLh * lineHeightPx;
|
|
183
|
+
if (currentBuffer === 0 || distanceToBufferEnd < extensionThreshold) {
|
|
184
|
+
const newBuffer = contentHeight + bufferSizePx;
|
|
185
|
+
scrollState.bufferMinHeight = newBuffer;
|
|
186
|
+
conversationEl.style.setProperty('--stream-buffer', `${newBuffer}px`);
|
|
187
|
+
}
|
|
188
|
+
}, []);
|
|
189
|
+
const manageBuffer = useCallback((action) => {
|
|
190
|
+
const container = messageContainerRef.current;
|
|
191
|
+
const conversationEl = conversationRef.current;
|
|
192
|
+
const scrollState = scrollStateRef.current;
|
|
193
|
+
if (!container || !conversationEl)
|
|
194
|
+
return;
|
|
195
|
+
if (action === 'clear') {
|
|
196
|
+
conversationEl.style.removeProperty('--stream-buffer');
|
|
197
|
+
scrollState.bufferMinHeight = null;
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (action === 'init') {
|
|
201
|
+
applyBuffer();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (!scrollState.isStreamingActive || !scrollState.userAtBottom)
|
|
205
|
+
return;
|
|
206
|
+
applyBuffer();
|
|
207
|
+
}, [applyBuffer]);
|
|
208
|
+
const followStreamingMessage = useCallback(() => {
|
|
209
|
+
const container = messageContainerRef.current;
|
|
210
|
+
const scrollState = scrollStateRef.current;
|
|
211
|
+
if (!container ||
|
|
212
|
+
!scrollState.isStreamingActive ||
|
|
213
|
+
!scrollState.userAtBottom ||
|
|
214
|
+
(scrollState.lastScrollTop !== null &&
|
|
215
|
+
container.scrollTop < scrollState.lastScrollTop - scrollTolerancePx))
|
|
216
|
+
return;
|
|
217
|
+
manageBuffer('extend');
|
|
218
|
+
const targetScroll = container.scrollHeight - container.clientHeight;
|
|
219
|
+
const currentScroll = container.scrollTop;
|
|
220
|
+
if (Math.abs(currentScroll - targetScroll) > scrollTolerancePx) {
|
|
221
|
+
scrollState.ignoreNextScrollEvent = true;
|
|
222
|
+
container.scrollTo({ top: targetScroll, behavior: 'auto' });
|
|
223
|
+
}
|
|
224
|
+
}, [manageBuffer]);
|
|
225
|
+
const scrollToLatest = useCallback((behavior = 'auto', preferLast = true) => {
|
|
226
|
+
const container = messageContainerRef.current;
|
|
227
|
+
const conversationEl = conversationRef.current;
|
|
228
|
+
const lastMessage = conversationEl?.lastElementChild;
|
|
229
|
+
if (!container)
|
|
230
|
+
return;
|
|
231
|
+
const scrollState = scrollStateRef.current;
|
|
232
|
+
if (preferLast && lastMessage && lastMessage instanceof HTMLElement) {
|
|
233
|
+
const scrollHeight = container.scrollHeight;
|
|
234
|
+
const clientHeight = container.clientHeight;
|
|
235
|
+
const targetScrollTop = scrollHeight - clientHeight - scrollThresholdPx / 2;
|
|
236
|
+
if (targetScrollTop > container.scrollTop) {
|
|
237
|
+
scrollState.ignoreNextScrollEvent = true;
|
|
238
|
+
container.scrollTo({ top: targetScrollTop, behavior: 'auto' });
|
|
239
|
+
}
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
scrollState.ignoreNextScrollEvent = true;
|
|
243
|
+
container.scrollTo({ top: container.scrollHeight, behavior });
|
|
244
|
+
}, []);
|
|
245
|
+
const updateScrollState = useCallback((isScrollEvent = false) => {
|
|
246
|
+
const container = messageContainerRef.current;
|
|
247
|
+
const conversationEl = conversationRef.current;
|
|
248
|
+
if (!container || !conversationEl) {
|
|
249
|
+
setShowScrollToBottom(false);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const state = scrollStateRef.current;
|
|
253
|
+
if (state.initialBufferApplied) {
|
|
254
|
+
scrollToLatest('auto', true);
|
|
255
|
+
setShowScrollToBottom(false);
|
|
256
|
+
state.initialBufferApplied = false;
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (state.smoothScrollOnEnd) {
|
|
260
|
+
scrollToLatest('smooth', false);
|
|
261
|
+
setShowScrollToBottom(false);
|
|
262
|
+
state.smoothScrollOnEnd = false;
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (isScrollEvent && state.ignoreNextScrollEvent) {
|
|
266
|
+
state.ignoreNextScrollEvent = false;
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const isUserScroll = isScrollEvent;
|
|
270
|
+
const { clientHeight, scrollHeight, scrollTop } = container;
|
|
271
|
+
const trueContentHeight = Array.from(conversationEl.children).reduce((sum, child) => (child instanceof HTMLElement ? sum + child.offsetHeight : sum), 0);
|
|
272
|
+
const hasOverflow = trueContentHeight > clientHeight + scrollTolerancePx;
|
|
273
|
+
const distanceFromBufferedBottom = scrollHeight - scrollTop - clientHeight;
|
|
274
|
+
const isAtBufferedBottom = distanceFromBufferedBottom <= scrollThresholdPx;
|
|
275
|
+
if (!state.isStreamingActive) {
|
|
276
|
+
const distanceFromBottom = trueContentHeight - scrollTop - clientHeight;
|
|
277
|
+
const isAtBottom = distanceFromBottom <= scrollThresholdPx;
|
|
278
|
+
setShowScrollToBottom(hasOverflow && !isAtBottom);
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
if (isUserScroll) {
|
|
282
|
+
const previousScrollTop = state.lastScrollTop;
|
|
283
|
+
state.lastScrollTop = scrollTop;
|
|
284
|
+
if (previousScrollTop !== null && scrollTop < previousScrollTop - scrollTolerancePx) {
|
|
285
|
+
state.userAtBottom = false;
|
|
286
|
+
}
|
|
287
|
+
else if (isAtBufferedBottom) {
|
|
288
|
+
state.userAtBottom = true;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (state.userAtBottom && isAtBufferedBottom) {
|
|
292
|
+
followStreamingMessage();
|
|
293
|
+
setShowScrollToBottom(false);
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
setShowScrollToBottom(hasOverflow && !isAtBufferedBottom);
|
|
297
|
+
}
|
|
298
|
+
}, [followStreamingMessage, scrollToLatest]);
|
|
299
|
+
const updateScrollStateOnResize = useMemo(() => throttle(() => updateScrollState(false), resizeThrottleMs), [updateScrollState]);
|
|
300
|
+
const updateScrollStateOnScrollEvent = useMemo(() => throttle(() => updateScrollState(true), scrollThrottleMs), [updateScrollState]);
|
|
301
|
+
const handleScrollToBottomClick = useCallback(() => {
|
|
302
|
+
const scrollState = scrollStateRef.current;
|
|
303
|
+
const isStreaming = scrollState.isStreamingActive;
|
|
304
|
+
scrollToLatest(isStreaming ? 'auto' : 'smooth', false);
|
|
305
|
+
if (isStreaming) {
|
|
306
|
+
scrollState.userAtBottom = true;
|
|
307
|
+
}
|
|
308
|
+
setShowScrollToBottom(false);
|
|
309
|
+
const lastMessage = conversationRef.current?.lastElementChild;
|
|
310
|
+
if (lastMessage instanceof HTMLElement) {
|
|
311
|
+
lastFocusedMessageRef.current = lastMessage;
|
|
312
|
+
focusInMessageListRef.current = true;
|
|
313
|
+
lastMessage.focus();
|
|
314
|
+
}
|
|
315
|
+
}, [scrollToLatest]);
|
|
316
|
+
const suggestionCardsViewElRef = useRef(null);
|
|
317
|
+
const setSuggestionCardsViewRef = useCallback((el) => {
|
|
318
|
+
if (suggestionCardsViewElRef.current === el)
|
|
319
|
+
return;
|
|
320
|
+
observersRef.current.tileSync?.disconnect();
|
|
321
|
+
observersRef.current.tileSync = null;
|
|
322
|
+
observersRef.current.tileMutation?.disconnect();
|
|
323
|
+
observersRef.current.tileMutation = null;
|
|
324
|
+
suggestionCardsViewElRef.current = el;
|
|
325
|
+
if (!el)
|
|
326
|
+
return;
|
|
327
|
+
const tileSelector = '[data-tile-content]';
|
|
328
|
+
let scheduled = false;
|
|
329
|
+
const measure = () => {
|
|
330
|
+
const tileContents = Array.from(el.querySelectorAll(tileSelector));
|
|
331
|
+
if (tileContents.length === 0) {
|
|
332
|
+
el.style.removeProperty('--tile-col-track');
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
tileContents.forEach(tileEl => {
|
|
336
|
+
tileEl.style.width = 'auto';
|
|
337
|
+
});
|
|
338
|
+
const maxWidth = Math.max(...tileContents.map(tileEl => Math.round(tileEl.getBoundingClientRect().width)));
|
|
339
|
+
tileContents.forEach(tileEl => {
|
|
340
|
+
tileEl.style.width = '';
|
|
341
|
+
});
|
|
342
|
+
const newTrack = `${maxWidth}px`;
|
|
343
|
+
if (el.style.getPropertyValue('--tile-col-track') !== newTrack) {
|
|
344
|
+
el.style.setProperty('--tile-col-track', newTrack);
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
const schedule = () => {
|
|
348
|
+
if (scheduled)
|
|
349
|
+
return;
|
|
350
|
+
scheduled = true;
|
|
351
|
+
requestAnimationFrame(() => {
|
|
352
|
+
scheduled = false;
|
|
353
|
+
measure();
|
|
354
|
+
});
|
|
355
|
+
};
|
|
356
|
+
const ro = new ResizeObserver(() => schedule());
|
|
357
|
+
ro.observe(el);
|
|
358
|
+
observersRef.current.tileSync = ro;
|
|
359
|
+
const mo = new MutationObserver(() => schedule());
|
|
360
|
+
mo.observe(el, { childList: true, subtree: true });
|
|
361
|
+
observersRef.current.tileMutation = mo;
|
|
362
|
+
}, []);
|
|
363
|
+
const setInputContainerRef = useCallback((el) => {
|
|
364
|
+
if (inputContainerRef.current === el)
|
|
365
|
+
return;
|
|
366
|
+
observersRef.current.inputContainer?.disconnect();
|
|
367
|
+
observersRef.current.inputContainer = null;
|
|
368
|
+
inputContainerRef.current = el;
|
|
369
|
+
if (!el)
|
|
370
|
+
return;
|
|
371
|
+
const ro = new ResizeObserver(entries => {
|
|
372
|
+
const entry = entries[0];
|
|
373
|
+
if (entry && genAICoachRef.current) {
|
|
374
|
+
const height = Math.round(entry.contentRect.height);
|
|
375
|
+
genAICoachRef.current.style.setProperty('--composer-height', `${height}px`);
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
ro.observe(el);
|
|
379
|
+
observersRef.current.inputContainer = ro;
|
|
380
|
+
}, []);
|
|
381
|
+
const setMessageContainerRef = useCallback((el) => {
|
|
382
|
+
messageContainerRef.current = el;
|
|
383
|
+
}, []);
|
|
50
384
|
const onCoachChange = (id) => {
|
|
51
385
|
setCoachOptions(cur => {
|
|
52
386
|
return cur.map(coach => {
|
|
@@ -69,22 +403,51 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
|
|
|
69
403
|
return coachOptions[0].primary;
|
|
70
404
|
}
|
|
71
405
|
}, [coachOptions]);
|
|
406
|
+
const onResult = useCallback(value => {
|
|
407
|
+
pendingResult.current = false;
|
|
408
|
+
setMessage(prevMessage => {
|
|
409
|
+
return prevMessage ? `${prevMessage} ${value}` : value;
|
|
410
|
+
});
|
|
411
|
+
setInterimMessage('');
|
|
412
|
+
}, []);
|
|
413
|
+
const onInterimResult = useCallback(value => {
|
|
414
|
+
if (value) {
|
|
415
|
+
pendingResult.current = true;
|
|
416
|
+
setInterimMessage(message ? ` ${value}` : value);
|
|
417
|
+
}
|
|
418
|
+
}, [message]);
|
|
419
|
+
const { supported, active, start, stop, error: voiceToTextError } = useSpeechRecognition({
|
|
420
|
+
onResult,
|
|
421
|
+
onInterimResult,
|
|
422
|
+
langCode: voiceToTextProps?.langCode
|
|
423
|
+
});
|
|
72
424
|
const handleSendMessage = useCallback(() => {
|
|
425
|
+
const hasFormAnswers = !!questionnaireData &&
|
|
426
|
+
formAnswers &&
|
|
427
|
+
Object.values(formAnswers).some(v => v.value.length > 0);
|
|
73
428
|
const isMessageAndAttachmentsEmpty = !message && (!attachments || attachments.length === 0);
|
|
74
429
|
const hasAttachmentsError = attachments &&
|
|
75
430
|
attachments.length > 0 &&
|
|
76
431
|
(attachmentsError || attachments.some(attachment => attachment.error));
|
|
77
432
|
const isCoachMessageLoading = latestMessage && isCoachMessage(latestMessage) && latestMessage.loading;
|
|
78
|
-
if (isMessageAndAttachmentsEmpty
|
|
433
|
+
if ((isMessageAndAttachmentsEmpty && !hasFormAnswers) ||
|
|
434
|
+
hasAttachmentsError ||
|
|
435
|
+
isCoachMessageLoading ||
|
|
436
|
+
(latestMessage && isCoachMessage(latestMessage) && latestMessage.isToolConfirmation))
|
|
79
437
|
return;
|
|
80
438
|
onSend({
|
|
81
439
|
id: createUID(),
|
|
82
440
|
message,
|
|
83
441
|
fromComposer: true,
|
|
84
|
-
attachmentIds: attachments?.map(({ id }) => id)
|
|
442
|
+
attachmentIds: attachments?.map(({ id }) => id),
|
|
443
|
+
formAnswers: hasFormAnswers ? formAnswers : undefined
|
|
85
444
|
});
|
|
445
|
+
setFormAnswers(undefined);
|
|
86
446
|
setMessage('');
|
|
87
|
-
|
|
447
|
+
if (active) {
|
|
448
|
+
stop();
|
|
449
|
+
}
|
|
450
|
+
}, [message, latestMessage, attachments, attachmentsError, formAnswers, questionnaireData]);
|
|
88
451
|
const handleEnterKeyDown = (e) => {
|
|
89
452
|
if (e.key === 'Enter' && !e.shiftKey) {
|
|
90
453
|
e.preventDefault();
|
|
@@ -100,23 +463,20 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
|
|
|
100
463
|
return null;
|
|
101
464
|
}
|
|
102
465
|
if (coachOptions.length === 1) {
|
|
103
|
-
return (
|
|
466
|
+
return (_jsx(Text, { variant: isPortalAgent && !pagePanel?.visible ? 'h1' : 'h2', children: selectedCoach }));
|
|
104
467
|
}
|
|
105
|
-
return (_jsx(MenuButton, { text: selectedCoach, "aria-label": t('agent_switcher', [selectedCoach]), variant: 'text', as: StyledGenAIOptionsMenu,
|
|
468
|
+
return (_jsx(MenuButton, { text: selectedCoach, "aria-label": t('agent_switcher', [selectedCoach]), variant: 'text', as: StyledGenAIOptionsMenu, menu: {
|
|
106
469
|
mode: 'single-select',
|
|
107
470
|
items: coachOptions,
|
|
108
471
|
onItemClick: onCoachChange
|
|
109
472
|
} }));
|
|
110
|
-
}, [coachOptions, selectedCoach]);
|
|
473
|
+
}, [coachOptions, selectedCoach, isPortalAgent, pagePanel?.visible]);
|
|
111
474
|
const headerContent = useMemo(() => {
|
|
112
|
-
return isInUtilities(variant) && variant.state === 'minimized' ? (_jsxs(_Fragment, { children: [
|
|
475
|
+
return isInUtilities(variant) && variant.state === 'minimized' ? (_jsxs(_Fragment, { children: [_jsx(Text, { variant: 'h2', children: selectedCoach }), _jsx(Flex, { container: { alignItems: 'center' }, children: _jsx(Button, { icon: true, label: t('maximize'), "aria-label": t('agent_noun', [t('maximize')]), variant: 'simple', onClick: () => {
|
|
113
476
|
variant.onStateChange('maximized');
|
|
114
477
|
isUserTriggered.current = true;
|
|
115
|
-
}, children: _jsx(Icon, { name: 'caret-up' }) }) })] })) : (_jsxs(_Fragment, { children: [renderCoachOptions, _jsxs(Flex, { container:
|
|
116
|
-
|
|
117
|
-
isUserTriggered.current = true;
|
|
118
|
-
}, children: _jsx(Icon, { name: 'minus' }) })), actions && (_jsx(Actions, { "data-testid": testIds.actions, contextualLabel: selectedCoach, ...actions })), variant.placement === 'dialog' && (_jsx(Button, { icon: true, label: t('close'), "aria-label": t('agent_noun', [t('close')]), variant: 'simple', onClick: variant.onClose, children: _jsx(Icon, { name: 'times' }) }))] })] }));
|
|
119
|
-
}, [variant, coachOptions]);
|
|
478
|
+
}, children: _jsx(Icon, { name: 'caret-up' }) }) })] })) : (_jsxs(_Fragment, { children: [renderCoachOptions, _jsxs(Flex, { container: { gap: 0.5 }, as: StyledActionsContainer, children: [activeCases && _jsx(ActiveCases, { activeCases: activeCases }), onNewChat && (_jsx(Button, { icon: true, variant: 'simple', label: t('new_chat'), "aria-label": t('new_chat'), onClick: onNewChat, children: _jsx(Icon, { name: 'plus' }) })), _jsx(HeaderActions, { actions: actions, allowFullScreen: allowFullScreen, variant: variant, isUserTriggeredRef: isUserTriggered, onFullscreenToggle: toggleFullscreen, isFullscreen: fullScreen, selectedCoach: selectedCoach, actionsTestId: testIds.actions }), variant.placement === 'dialog' && !fullScreen && (_jsx(Button, { icon: true, label: t('close'), "aria-label": t('close_chat_with_ai'), variant: 'simple', onClick: variant.onClose, children: _jsx(Icon, { name: 'times' }) }))] })] }));
|
|
479
|
+
}, [variant, coachOptions, activeCases, actions, allowFullScreen, onNewChat]);
|
|
120
480
|
const getMessageContainingElement = (element) => {
|
|
121
481
|
if (element)
|
|
122
482
|
return Array.from(messageEls.values()).find(el => el && el.contains(element));
|
|
@@ -131,21 +491,38 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
|
|
|
131
491
|
getMessageContainingElement(lastFocusedMessageRef.current) ?? null;
|
|
132
492
|
}
|
|
133
493
|
};
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
494
|
+
const focusLastMessageLi = useCallback((e) => {
|
|
495
|
+
if (e.key !== 'Tab' || !e.shiftKey)
|
|
496
|
+
return;
|
|
497
|
+
const target = lastFocusedMessageRef.current ?? conversationRef.current?.lastElementChild;
|
|
498
|
+
if (!(target instanceof HTMLElement))
|
|
499
|
+
return;
|
|
500
|
+
e.preventDefault();
|
|
501
|
+
focusInMessageListRef.current = true;
|
|
502
|
+
target.focus();
|
|
503
|
+
}, []);
|
|
140
504
|
const variantState = useMemo(() => {
|
|
141
505
|
if (variant.placement === 'utilities') {
|
|
142
506
|
return variant.state;
|
|
143
507
|
}
|
|
144
508
|
}, [variant]);
|
|
145
509
|
useEffect(() => {
|
|
146
|
-
if (
|
|
147
|
-
|
|
510
|
+
if (questionnaireData) {
|
|
511
|
+
setQuestionnaireDismissed(false);
|
|
512
|
+
setFormAnswers(undefined);
|
|
513
|
+
}
|
|
514
|
+
}, [questionnaireData]);
|
|
515
|
+
useEffect(() => {
|
|
516
|
+
if (draftMessage !== undefined) {
|
|
517
|
+
setMessage(draftMessage);
|
|
518
|
+
if (suggestionCardsView || draftMessage)
|
|
519
|
+
textAreaRef.current?.focus();
|
|
148
520
|
}
|
|
521
|
+
}, [draftMessage, suggestionCardsView]);
|
|
522
|
+
useEffect(() => {
|
|
523
|
+
setFormAnswers(undefined);
|
|
524
|
+
}, [questionnaireKey]);
|
|
525
|
+
useEffect(() => {
|
|
149
526
|
if (isUserTriggered.current) {
|
|
150
527
|
if (isInUtilities(variant) &&
|
|
151
528
|
(variant.state === 'minimized' || (guidedMode && variant.state === 'maximized')) &&
|
|
@@ -165,9 +542,10 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
|
|
|
165
542
|
}, [condition]);
|
|
166
543
|
useEffect(() => {
|
|
167
544
|
onOpen?.();
|
|
168
|
-
window.addEventListener('resize', onResize);
|
|
169
545
|
return () => {
|
|
170
|
-
|
|
546
|
+
Object.values(observersRef.current).forEach(observer => {
|
|
547
|
+
observer?.disconnect();
|
|
548
|
+
});
|
|
171
549
|
};
|
|
172
550
|
}, []);
|
|
173
551
|
useEffect(() => {
|
|
@@ -175,17 +553,10 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
|
|
|
175
553
|
const currentFilteredMsgs = messages?.filter(item => !hasProp(item, 'loading')) ?? [];
|
|
176
554
|
if (prevFilteredMsgs.length < currentFilteredMsgs.length ||
|
|
177
555
|
(latestMessage && hasProp(latestMessage, 'loading'))) {
|
|
178
|
-
setTimeout(() => {
|
|
179
|
-
conversationRef.current?.lastElementChild?.scrollIntoView({
|
|
180
|
-
behavior: 'smooth',
|
|
181
|
-
block: 'nearest'
|
|
182
|
-
});
|
|
183
|
-
}, 0);
|
|
184
556
|
if (latestMessage && isUserMessage(latestMessage)) {
|
|
185
557
|
textAreaRef.current?.focus();
|
|
186
558
|
setLastFocusableElement();
|
|
187
559
|
elementRef.current = null;
|
|
188
|
-
setArrowKey(null);
|
|
189
560
|
}
|
|
190
561
|
else if (latestMessage?.loading) {
|
|
191
562
|
isGeneratingResponse.current = true;
|
|
@@ -195,6 +566,72 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
|
|
|
195
566
|
}
|
|
196
567
|
}
|
|
197
568
|
}, [messages]);
|
|
569
|
+
useEffect(() => {
|
|
570
|
+
if (!isLatestAgentMessageStreaming)
|
|
571
|
+
return;
|
|
572
|
+
announcePolite({ type: 'status', message: t('generating_response') });
|
|
573
|
+
}, [isLatestAgentMessageStreaming]);
|
|
574
|
+
useEffect(() => {
|
|
575
|
+
const scrollState = scrollStateRef.current;
|
|
576
|
+
const wasStreaming = scrollState.isStreamingActive;
|
|
577
|
+
if (isLatestAgentMessageStreaming && !wasStreaming) {
|
|
578
|
+
scrollStateRef.current = {
|
|
579
|
+
...scrollStateRef.current,
|
|
580
|
+
isStreamingActive: true,
|
|
581
|
+
initialBufferApplied: true,
|
|
582
|
+
userAtBottom: false,
|
|
583
|
+
smoothScrollOnEnd: false,
|
|
584
|
+
lastScrollTop: null
|
|
585
|
+
};
|
|
586
|
+
requestAnimationFrame(() => {
|
|
587
|
+
manageBuffer('init');
|
|
588
|
+
});
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
if (!isLatestAgentMessageStreaming && wasStreaming) {
|
|
592
|
+
scrollStateRef.current = {
|
|
593
|
+
...scrollStateRef.current,
|
|
594
|
+
isStreamingActive: false,
|
|
595
|
+
initialBufferApplied: false,
|
|
596
|
+
userAtBottom: false,
|
|
597
|
+
smoothScrollOnEnd: true
|
|
598
|
+
};
|
|
599
|
+
manageBuffer('clear');
|
|
600
|
+
}
|
|
601
|
+
}, [isLatestAgentMessageStreaming, manageBuffer]);
|
|
602
|
+
useEffect(() => {
|
|
603
|
+
const container = messageContainerRef.current;
|
|
604
|
+
const content = conversationRef.current;
|
|
605
|
+
if (!container || !content)
|
|
606
|
+
return;
|
|
607
|
+
const containerRO = new ResizeObserver(updateScrollStateOnResize);
|
|
608
|
+
containerRO.observe(container);
|
|
609
|
+
containerRO.observe(content);
|
|
610
|
+
observersRef.current.messageContainer = containerRO;
|
|
611
|
+
let streamingMessageRO = null;
|
|
612
|
+
const lastMessageEl = content.lastElementChild;
|
|
613
|
+
if (isLatestAgentMessageStreaming && lastMessageEl) {
|
|
614
|
+
const handleStreamingUpdate = throttle(() => {
|
|
615
|
+
followStreamingMessage();
|
|
616
|
+
updateScrollState(false);
|
|
617
|
+
}, resizeThrottleMs);
|
|
618
|
+
streamingMessageRO = new ResizeObserver(handleStreamingUpdate);
|
|
619
|
+
streamingMessageRO.observe(lastMessageEl);
|
|
620
|
+
observersRef.current.streamingMessage = streamingMessageRO;
|
|
621
|
+
}
|
|
622
|
+
return () => {
|
|
623
|
+
containerRO.disconnect();
|
|
624
|
+
observersRef.current.messageContainer = null;
|
|
625
|
+
streamingMessageRO?.disconnect();
|
|
626
|
+
observersRef.current.streamingMessage = null;
|
|
627
|
+
};
|
|
628
|
+
}, [
|
|
629
|
+
messages.length,
|
|
630
|
+
isLatestAgentMessageStreaming,
|
|
631
|
+
followStreamingMessage,
|
|
632
|
+
updateScrollState,
|
|
633
|
+
updateScrollStateOnResize
|
|
634
|
+
]);
|
|
198
635
|
useEffect(() => {
|
|
199
636
|
if (suggestionMenuButton && isGeneratingResponse.current) {
|
|
200
637
|
announcePolite({ message: t('response_generated') });
|
|
@@ -204,16 +641,34 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
|
|
|
204
641
|
suggestionMenuButton.focus();
|
|
205
642
|
}
|
|
206
643
|
}, [suggestionMenuButton]);
|
|
207
|
-
/** Supports arrow key behaviors */
|
|
208
644
|
useEffect(() => {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
focusables[0]?.focus();
|
|
645
|
+
if (messages.length === 0 || loading || error) {
|
|
646
|
+
setShowScrollToBottom(false);
|
|
212
647
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
648
|
+
}, [messages.length, loading, error]);
|
|
649
|
+
/** Supports Enter key to enter a message and focus first focusable element inside it */
|
|
650
|
+
useEffect(() => {
|
|
651
|
+
if (!focusedInMessage)
|
|
652
|
+
return;
|
|
653
|
+
const focusables = getFocusables(elementRef);
|
|
654
|
+
focusables[0]?.focus();
|
|
655
|
+
}, [focusedInMessage, elementRef.current]);
|
|
656
|
+
/**
|
|
657
|
+
* While inside a message, stop ArrowUp/Down from bubbling to conversationRef
|
|
658
|
+
* so useArrows does not navigate between message rows.
|
|
659
|
+
*/
|
|
660
|
+
useEffect(() => {
|
|
661
|
+
const el = elementRef.current;
|
|
662
|
+
if (!focusedInMessage || !el)
|
|
663
|
+
return;
|
|
664
|
+
const blockArrows = (e) => {
|
|
665
|
+
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
|
666
|
+
e.stopPropagation();
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
el.addEventListener('keydown', blockArrows);
|
|
670
|
+
return () => el.removeEventListener('keydown', blockArrows);
|
|
671
|
+
}, [focusedInMessage]);
|
|
217
672
|
useArrows(conversationRef, {
|
|
218
673
|
cycle: true,
|
|
219
674
|
selector: ':scope > li',
|
|
@@ -221,66 +676,195 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
|
|
|
221
676
|
allowTabFocus: true,
|
|
222
677
|
initialFocusElement: initialFocusedElementRef.current
|
|
223
678
|
}, [messages, initialFocusedElementRef.current]);
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
allowTabFocus: true,
|
|
229
|
-
updateTabIndex: false
|
|
230
|
-
}, [messages, elementRef.current, arrowKey]);
|
|
231
|
-
useOuterEvent('mousedown', [conversationRef.current], () => {
|
|
232
|
-
setArrowKey(null);
|
|
679
|
+
useFocusTrap(trapRef, true, [focusedInMessage]);
|
|
680
|
+
useOuterEvent('mousedown', [focusedInMessage ? elementRef.current : conversationRef.current], () => {
|
|
681
|
+
setFocusedInMessage(false);
|
|
682
|
+
trapRef.current = null;
|
|
233
683
|
focusInMessageListRef.current = false;
|
|
234
684
|
});
|
|
685
|
+
const { push } = useToaster();
|
|
686
|
+
const onSpeechToTextButtonClick = useCallback(() => {
|
|
687
|
+
if (active) {
|
|
688
|
+
stop();
|
|
689
|
+
}
|
|
690
|
+
else {
|
|
691
|
+
start();
|
|
692
|
+
}
|
|
693
|
+
}, [active, stop, start]);
|
|
235
694
|
const onFileChange = (e) => {
|
|
236
695
|
if (e.target.files) {
|
|
237
696
|
const newFiles = Array.from(e.target.files);
|
|
238
697
|
onAddAttachment?.(newFiles);
|
|
239
698
|
}
|
|
240
699
|
};
|
|
241
|
-
const
|
|
700
|
+
const getGridColumns = () => {
|
|
701
|
+
const multiCol = 'repeat(auto-fit, minmax(calc(100% / 4 - 1rem), 1fr))';
|
|
702
|
+
const singleCol = '1fr';
|
|
703
|
+
return !isSmallOrAbove ? singleCol : multiCol;
|
|
704
|
+
};
|
|
705
|
+
useEffect(() => {
|
|
706
|
+
if (voiceToTextError) {
|
|
707
|
+
push({ content: voiceToTextError });
|
|
708
|
+
}
|
|
709
|
+
}, [voiceToTextError]);
|
|
710
|
+
const genAIFooter = (_jsxs(Flex, { container: { direction: 'column' }, as: StyledGenAIFooter, children: [_jsxs(StyledComposerWrapper, { focused: focused, hasQuestionnaire: !!questionnaireData && !questionnaireDismissed, onFocus: () => setFocused(true), onBlur: e => {
|
|
711
|
+
if (!(e.relatedTarget instanceof Node) || !e.currentTarget.contains(e.relatedTarget)) {
|
|
712
|
+
setFocused(false);
|
|
713
|
+
}
|
|
714
|
+
}, children: [questionnaireData && !questionnaireDismissed && !questionnaireData.inline && (_jsx(Questionnaire, { data: questionnaireData, onChange: handleFormChange, onCancel: handleFormCancel }, questionnaireKey)), _jsx(FormField, { label: t('message_pega_gen_ai_coach'), labelHidden: true, labelFor: composerId, info: conversationError || undefined, status: conversationError ? 'error' : undefined, children: _jsx(StyledGenAIFormControl, { focused: (!questionnaireData || questionnaireDismissed) && focused, status: conversationError ? 'error' : undefined, children: _jsxs(Flex, { container: { direction: 'column', gap: 0.25 }, children: [_jsx(StyledGenAITextArea, { id: composerId, ref: textAreaRef, value: interimMessage ? `${message}${interimMessage}` : message, placeholder: t('write_message'), onKeyDown: handleEnterKeyDown, onChange: handleTextAreaChange, onFocus: () => {
|
|
715
|
+
if (active)
|
|
716
|
+
stop();
|
|
717
|
+
}, autoResize: true }), _jsxs(Flex, { container: {
|
|
718
|
+
direction: 'row',
|
|
719
|
+
justify: 'between',
|
|
720
|
+
gap: 1,
|
|
721
|
+
pad: [undefined, 1, 1, 1]
|
|
722
|
+
}, children: [_jsxs(Flex, { container: { alignItems: 'center' }, children: [!(messages.length === 0 && suggestionCardsView) && suggestions && (_jsx(MenuButton, { text: t('suggestions'), variant: 'simple', icon: 'chat-typing', iconOnly: true, as: StyledMenuSuggestions, menu: {
|
|
723
|
+
items: suggestions,
|
|
724
|
+
onItemClick: id => {
|
|
725
|
+
const selected = menuHelpers.getItem(suggestions, id);
|
|
726
|
+
if (selected && !selected.onClick) {
|
|
727
|
+
setMessage(selected.primary);
|
|
728
|
+
textAreaRef.current?.focus();
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}, showArrow: false })), voiceToTextProps?.enableDictation && supported && (_jsx(SpeechToTextButton, { active: active, onClick: onSpeechToTextButtonClick })), onAddAttachment && (_jsxs(_Fragment, { children: [_jsx(Button, { icon: true, onClick: () => {
|
|
732
|
+
if (fileUploadInputRef.current) {
|
|
733
|
+
fileUploadInputRef.current.value = '';
|
|
734
|
+
}
|
|
735
|
+
fileUploadInputRef.current?.click();
|
|
736
|
+
}, variant: 'simple', label: t('add_attachment'), children: _jsx(Icon, { name: 'paper-clip' }) }), _jsx(StyledInput, { type: 'file', ref: fileUploadInputRef, onChange: onFileChange, multiple: false, "data-testid": testIds.attachments })] }))] }), (() => {
|
|
737
|
+
if (active && pendingResult.current) {
|
|
738
|
+
return (_jsxs(Flex, { container: {
|
|
739
|
+
gap: 1,
|
|
740
|
+
justify: 'end',
|
|
741
|
+
alignItems: 'center',
|
|
742
|
+
pad: 1
|
|
743
|
+
}, children: [t('processing_speech'), _jsx(Progress, { placement: 'inline' })] }));
|
|
744
|
+
}
|
|
745
|
+
const isToolConfirmation = latestMessage &&
|
|
746
|
+
isCoachMessage(latestMessage) &&
|
|
747
|
+
latestMessage.isToolConfirmation;
|
|
748
|
+
let onStopFn;
|
|
749
|
+
if (onStop) {
|
|
750
|
+
onStopFn = onStop;
|
|
751
|
+
}
|
|
752
|
+
else if (isToolConfirmation) {
|
|
753
|
+
onStopFn = stopProcess;
|
|
754
|
+
}
|
|
755
|
+
if (onStopFn) {
|
|
756
|
+
return (_jsx(StyledStopGeneratingButton, { variant: 'primary', icon: true, label: t('stop'), "aria-label": t('stop'), onClick: () => {
|
|
757
|
+
textAreaRef.current?.focus();
|
|
758
|
+
onStopFn?.();
|
|
759
|
+
}, children: _jsx(Icon, { name: 'square-solid' }) }));
|
|
760
|
+
}
|
|
761
|
+
const isLoading = latestMessage &&
|
|
762
|
+
isCoachMessage(latestMessage) &&
|
|
763
|
+
latestMessage.loading &&
|
|
764
|
+
!latestMessage.error;
|
|
765
|
+
const sendButton = (_jsx(StyledSendButton, { variant: 'primary', onClick: isCreatingConversation ? undefined : handleSendMessage, icon: true, label: t('send'), "aria-label": t('send_message'), children: _jsx(Icon, { name: 'send-solid' }) }));
|
|
766
|
+
if (isLoading) {
|
|
767
|
+
if (isCreatingConversation) {
|
|
768
|
+
return sendButton;
|
|
769
|
+
}
|
|
770
|
+
return (_jsxs(Flex, { container: {
|
|
771
|
+
gap: 1,
|
|
772
|
+
justify: 'end',
|
|
773
|
+
alignItems: 'center',
|
|
774
|
+
pad: 1
|
|
775
|
+
}, children: [t('generating_response'), _jsx(Progress, { placement: 'inline' })] }));
|
|
776
|
+
}
|
|
777
|
+
return sendButton;
|
|
778
|
+
})()] })] }) }) })] }), attachments && attachments.length > 0 && (_jsxs(_Fragment, { children: [_jsx(Flex, { as: FileList, type: 'item', "aria-label": `${t('attachments')}`, items: attachments, container: { pad: [1, 0] } }), attachmentsError && (_jsxs(Flex, { container: { gap: 1, alignItems: 'center' }, as: StyledErrorContainer, children: [_jsx(Icon, { name: 'warn-solid' }), _jsx(VisuallyHiddenText, { children: `${t('error')} ` }), attachmentsError] }))] })), _jsx(Flex, { container: { justify: 'center' }, children: _jsx(StyledDisclaimerText, { inFullPage: !condition, children: t('ai_disclaimer') }) })] }));
|
|
779
|
+
const isCompact = variant.placement === 'fullpage' &&
|
|
780
|
+
!fullScreen &&
|
|
781
|
+
!isInLandingPageUtilities &&
|
|
782
|
+
messages.length === 0;
|
|
783
|
+
const fullPageAndInitialScreen = (fullScreen || (variant.placement === 'fullpage' && !isInLandingPageUtilities)) &&
|
|
784
|
+
messages.length === 0;
|
|
785
|
+
const renderTextArea = fullPageAndInitialScreen ? null : genAIFooter;
|
|
786
|
+
const GenAICoachElement = (_jsx(_Fragment, { children: ((isInUtilities(variant) && variant.state !== 'minimized') || !isInUtilities(variant)) && (_jsxs(Flex, { container: { direction: 'column' }, as: StyledFlexWrapper, children: [caseWorkflow && _jsx(CaseWorkflow, { ...caseWorkflow }), _jsx(Flex, { as: StyledMessagesContainer, ref: setMessageContainerRef, withSuggestionCards: !loading && !error && messages.length === 0 && !!suggestionCardsView, container: loading || error
|
|
242
787
|
? { direction: 'column', pad: [0, 2], justify: 'center' }
|
|
243
|
-
: { direction: 'column', pad: [0, 2] },
|
|
244
|
-
|
|
788
|
+
: { direction: 'column', pad: [0, 2] }, ...(!loading && !error && messages.length === 0 && suggestionCardsView
|
|
789
|
+
? {}
|
|
790
|
+
: { item: { grow: 1 } }), onScroll: updateScrollStateOnScrollEvent, children: loading || error ? (_jsx(Flex, { container: { justify: 'center', alignItems: 'center' }, children: loading ? (_jsx(Progress, { variant: 'ring', placement: 'block', message: typeof loading === 'string' ? loading : t('loading') })) : (_jsx(ErrorState, { message: error })) })) : (_jsx(_Fragment, { children: messages.length === 0 ? (_jsxs(Flex, { as: StyledInitialMessageContainer, container: {
|
|
791
|
+
justify: suggestionCardsView ? undefined : 'center',
|
|
245
792
|
direction: 'column',
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
793
|
+
alignItems: 'center',
|
|
794
|
+
gap: 4,
|
|
795
|
+
pad: [6, 0, 2, 0]
|
|
796
|
+
}, ...(suggestionCardsView ? {} : { item: { grow: 1 } }), children: [((isInUtilities(variant) && variant.state === 'maximized') ||
|
|
797
|
+
!isInUtilities(variant)) &&
|
|
798
|
+
showSalutation && (_jsxs(Flex, { container: {
|
|
799
|
+
direction: 'column',
|
|
800
|
+
alignItems: 'center',
|
|
801
|
+
gap: 2,
|
|
802
|
+
pad: [0, 2]
|
|
803
|
+
}, children: [_jsx(AgentIcon, {}), _jsx(Text, { variant: 'h3', as: StyledSalutation, children: salutation ?? t('welcome_text') })] })), initialSuggestedMessages && initialSuggestedMessages.length > 0 && (_jsx(Grid, { as: StyledInitialMessageGrid, container: { cols: getGridColumns(), gap: 1.5 }, children: initialSuggestedMessages.map(initialSuggestedMessage => (_jsx(InitialSuggestedMessage, { ...initialSuggestedMessage, onSend: initialMessage => {
|
|
804
|
+
if (guidedMode) {
|
|
805
|
+
onSend({
|
|
806
|
+
id: initialMessage.id,
|
|
807
|
+
message: initialMessage.message
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
else {
|
|
811
|
+
setMessage(initialMessage.message ?? '');
|
|
812
|
+
}
|
|
250
813
|
isUserTriggered.current = true;
|
|
251
|
-
|
|
814
|
+
textAreaRef.current?.focus();
|
|
815
|
+
}, testId: initialSuggestedMessage.id }))) })), fullPageAndInitialScreen && !guidedMode && !suggestionCardsView && genAIFooter] })) : (_jsx(Flex, { as: StyledMessagesList, ref: conversationRef, "aria-label": `${t('conversation')} ${t('view')}`, container: { direction: 'column' }, onMouseDown: (e) => {
|
|
816
|
+
mouseTriggeredFocusRef.current = true;
|
|
817
|
+
const target = e.target instanceof Element ? e.target : null;
|
|
818
|
+
const clickedMessage = getMessageContainingElement(target);
|
|
819
|
+
if (clickedMessage) {
|
|
820
|
+
lastFocusedMessageRef.current = clickedMessage;
|
|
821
|
+
}
|
|
822
|
+
}, onMouseUp: () => {
|
|
823
|
+
mouseTriggeredFocusRef.current = false;
|
|
824
|
+
}, onFocus: () => {
|
|
825
|
+
if (mouseTriggeredFocusRef.current) {
|
|
826
|
+
mouseTriggeredFocusRef.current = false;
|
|
827
|
+
focusInMessageListRef.current = true;
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
252
830
|
if (!focusInMessageListRef.current) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
if (lastChild instanceof HTMLElement) {
|
|
260
|
-
lastChild.focus();
|
|
261
|
-
}
|
|
262
|
-
}
|
|
831
|
+
focusInMessageListRef.current = true;
|
|
832
|
+
const target = lastFocusedMessageRef.current ??
|
|
833
|
+
(conversationRef.current?.lastElementChild instanceof HTMLElement
|
|
834
|
+
? conversationRef.current.lastElementChild
|
|
835
|
+
: null);
|
|
836
|
+
target?.focus();
|
|
263
837
|
}
|
|
264
838
|
focusInMessageListRef.current = true;
|
|
265
|
-
setArrowKey(null);
|
|
266
839
|
}, onKeyDown: (e) => {
|
|
267
840
|
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
|
268
|
-
|
|
841
|
+
if (focusedInMessage)
|
|
842
|
+
return;
|
|
269
843
|
elementRef.current =
|
|
270
844
|
getMessageContainingElement(document.activeElement) ?? null;
|
|
271
845
|
lastFocusedMessageRef.current = elementRef.current;
|
|
272
846
|
}
|
|
273
|
-
else if (e.key === '
|
|
847
|
+
else if (e.key === 'Enter' && !focusedInMessage) {
|
|
274
848
|
const activeMessageElement = Array.from(messageEls.values()).find(el => el === document.activeElement);
|
|
275
849
|
elementRef.current =
|
|
276
850
|
getMessageContainingElement(document.activeElement) ?? null;
|
|
277
851
|
initialFocusedElementRef.current = elementRef.current;
|
|
278
852
|
if (activeMessageElement &&
|
|
279
853
|
getFocusables(activeMessageElement).length > 0) {
|
|
280
|
-
|
|
854
|
+
e.preventDefault();
|
|
855
|
+
trapRef.current = elementRef.current;
|
|
856
|
+
setFocusedInMessage(true);
|
|
281
857
|
}
|
|
282
858
|
}
|
|
859
|
+
else if (e.key === 'Escape' && focusedInMessage) {
|
|
860
|
+
e.preventDefault();
|
|
861
|
+
trapRef.current = null;
|
|
862
|
+
setFocusedInMessage(false);
|
|
863
|
+
elementRef.current?.focus();
|
|
864
|
+
}
|
|
283
865
|
else if (e.key === 'Tab') {
|
|
866
|
+
if (focusedInMessage)
|
|
867
|
+
return;
|
|
284
868
|
e.preventDefault();
|
|
285
869
|
setLastFocusableElement();
|
|
286
870
|
if (e.shiftKey) {
|
|
@@ -306,80 +890,75 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
|
|
|
306
890
|
}
|
|
307
891
|
}
|
|
308
892
|
else {
|
|
893
|
+
if (scrollButtonRef.current) {
|
|
894
|
+
scrollButtonRef.current.focus();
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
309
897
|
const nextElement = conversationRef.current?.parentElement?.nextElementSibling;
|
|
310
898
|
if (nextElement) {
|
|
311
899
|
const focusables = getFocusables(nextElement);
|
|
312
900
|
if (focusables.length) {
|
|
313
|
-
e.preventDefault();
|
|
314
901
|
focusables[0].focus();
|
|
315
902
|
}
|
|
316
903
|
}
|
|
317
|
-
setArrowKey(null);
|
|
318
904
|
}
|
|
319
905
|
}
|
|
320
906
|
}, children: messages.map(item => {
|
|
321
907
|
const messageProps = isCoachMessage(item)
|
|
322
908
|
? {
|
|
323
909
|
...item,
|
|
324
|
-
suggestions:
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
910
|
+
suggestions: latestMessage?.id === item.id ? item.suggestions : undefined,
|
|
911
|
+
onSend,
|
|
912
|
+
onSubmit: item.isToolConfirmation
|
|
913
|
+
? (tools) => {
|
|
914
|
+
onSend({
|
|
915
|
+
...item,
|
|
916
|
+
message: typeof item.message === 'string' ? item.message : '',
|
|
917
|
+
tools
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
: undefined
|
|
329
921
|
}
|
|
330
922
|
: item;
|
|
331
|
-
return (_jsx(GenAIMessage, { ...messageProps, ref: getMessageCbRef(item.id), testId: item.id, announceInteraction: !focusInMessageListRef.current
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
} }) })), _jsx(Flex, { container: { justify: 'start' }, children: _jsx(StyledDisclaimerText, { inFullPage: !condition, children: t('ai_disclaimer') }) })] })) })) : (_jsxs(_Fragment, { children: [_jsx(TextArea, { ref: textAreaRef, label: t('message_pega_gen_ai_coach', [selectedCoach ?? '']), value: message, onKeyDown: handleEnterKeyDown, onChange: handleTextAreaChange, autoResize: false }), attachments && attachments.length > 0 && (_jsxs(_Fragment, { children: [_jsx(Flex, { as: FileList, type: 'item', "aria-label": `${t('attachments')}`, items: attachments, container: { pad: [1, 0] } }), attachmentsError && (_jsxs(Flex, { container: { gap: 1, alignItems: 'center' }, as: StyledErrorContainer, children: [_jsx(Icon, { name: 'warn-solid' }), _jsx(VisuallyHiddenText, { children: `${t('error')} ` }), attachmentsError] }))] })), latestMessage && isCoachMessage(latestMessage) && latestMessage.loading ? (_jsxs(Flex, { container: {
|
|
359
|
-
gap: 1,
|
|
360
|
-
justify: 'end',
|
|
361
|
-
alignItems: 'center',
|
|
362
|
-
pad: 1
|
|
363
|
-
}, children: [t('generating_response'), _jsx(Progress, { placement: 'inline' })] })) : (_jsxs(Flex, { container: {
|
|
364
|
-
gap: 2,
|
|
365
|
-
justify: 'between',
|
|
366
|
-
pad: [1, undefined, undefined]
|
|
367
|
-
}, children: [suggestions && (_jsx(MenuButton, { text: t('suggestions'), variant: 'text', icon: 'polaris-solid', as: StyledSuggestions, menu: {
|
|
368
|
-
items: suggestions,
|
|
369
|
-
onItemClick: id => {
|
|
370
|
-
const selected = menuHelpers.getItem(suggestions, id);
|
|
371
|
-
if (selected)
|
|
372
|
-
onSend({
|
|
373
|
-
id: selected.id,
|
|
374
|
-
message: selected.primary
|
|
375
|
-
});
|
|
923
|
+
return (_jsx(GenAIMessage, { ...messageProps, ref: getMessageCbRef(item.id), testId: item.id, announceInteraction: !focusInMessageListRef.current, onAnimationCursorUpdate: animatedTillCursor => {
|
|
924
|
+
if (isCoachMessage(item)) {
|
|
925
|
+
setAnimationInitialCursorPos(animatedTillCursor);
|
|
926
|
+
}
|
|
927
|
+
}, ...(prevFullScreen !== fullScreen ? { animationInitialCursorPos } : {}) }));
|
|
928
|
+
}) })) })) }), showScrollToBottom && (_jsx(StyledScrollButton, { ref: scrollButtonRef, icon: true, onClick: handleScrollToBottomClick, ariaLabel: t('scroll_to_latest_message'), onKeyDown: focusLastMessageLi, children: _jsx(Icon, { name: 'caret-down' }) })), !loading && messages.length === 0 && suggestionCardsView ? (_jsxs(_Fragment, { children: [((isInUtilities(variant) && variant.state !== 'minimized') ||
|
|
929
|
+
!isInUtilities(variant)) &&
|
|
930
|
+
!guidedMode && (_jsx(StyledStickyComposer, { children: _jsx(Flex, { container: { direction: 'column' }, as: StyledInputContainer, ref: setInputContainerRef, children: _jsx(StyledComposerSection, { children: genAIFooter }) }) })), _jsx(Flex, { container: { direction: 'column' }, as: StyledSuggestionCardsBottomHalf, children: _jsx(StyledSuggestionCardsView, { ref: setSuggestionCardsViewRef, children: suggestionCardsView }) })] })) : (((isInUtilities(variant) && variant.state !== 'minimized') ||
|
|
931
|
+
!isInUtilities(variant)) &&
|
|
932
|
+
!loading && (_jsx(Flex, { container: { direction: 'column' }, as: StyledInputContainer, ref: setInputContainerRef, children: _jsxs(StyledComposerSection, { children: [guidedMode &&
|
|
933
|
+
questionnaireData &&
|
|
934
|
+
!questionnaireDismissed &&
|
|
935
|
+
!questionnaireData.inline && (_jsx(Questionnaire, { data: questionnaireData, onChange: handleFormChange, onCancel: handleFormCancel }, questionnaireKey)), guidedMode ? (_jsx(_Fragment, { children: suggestions && messages.length > 0 && (_jsxs(_Fragment, { children: [latestMessage &&
|
|
936
|
+
isCoachMessage(latestMessage) &&
|
|
937
|
+
latestMessage.loading ? (_jsxs(Flex, { container: {
|
|
938
|
+
gap: 1,
|
|
939
|
+
justify: 'center',
|
|
940
|
+
alignItems: 'center',
|
|
941
|
+
pad: 1
|
|
942
|
+
}, children: [t('generating_response'), _jsx(Progress, { placement: 'inline', focusOnVisible: true, message: t('generating_response') })] })) : (_jsx(ThemeOverride, { theme: {
|
|
943
|
+
components: {
|
|
944
|
+
button: {
|
|
945
|
+
color: theme.base.palette.ai,
|
|
946
|
+
'secondary-color': theme.base.palette.ai,
|
|
947
|
+
'secondary-fill-style': 'outline'
|
|
948
|
+
}
|
|
376
949
|
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
950
|
+
}, children: _jsx(MenuButton, { as: StyledGuidedSuggestions, text: t('ask_coach', [selectedCoach ?? '']), variant: 'primary', icon: 'polaris-solid', ref: setSuggestionMenuButton, menu: {
|
|
951
|
+
items: suggestions,
|
|
952
|
+
onItemClick: id => {
|
|
953
|
+
const selected = menuHelpers.getItem(suggestions, id);
|
|
954
|
+
if (selected && !selected.onClick) {
|
|
955
|
+
onSend({
|
|
956
|
+
id: selected.id,
|
|
957
|
+
message: selected.primary
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
} }) })), _jsx(Flex, { container: { justify: 'center' }, children: _jsx(StyledDisclaimerText, { inFullPage: !condition, children: t('ai_disclaimer') }) })] })) })) : (renderTextArea)] }) })))] })) }));
|
|
383
962
|
useEffect(() => {
|
|
384
963
|
if (focusTextArea.current && !conversationHistory && textAreaRef.current) {
|
|
385
964
|
textAreaRef.current.focus();
|
|
@@ -415,7 +994,8 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
|
|
|
415
994
|
focusTextArea.current = true;
|
|
416
995
|
conversationHistory.onDismiss();
|
|
417
996
|
}, inFullPage: !condition, ref: historyViewRef }));
|
|
418
|
-
return (_jsxs(Flex, { container: { direction: 'column' }, as: StyledGenAICoachContainer, "data-testid": testIds.root, variant: variant, ref: genAICoachRef,
|
|
997
|
+
return (_jsxs(Flex, { ...restProps, container: { direction: 'column' }, as: StyledGenAICoachContainer, "data-testid": testIds.root, variant: variant, fullScreen: fullScreen, isCompact: isCompact, isPortalAgent: isPortalAgent, ref: genAICoachRef, children: [_jsx(Flex, { container: { justify: 'between', alignItems: 'center', pad: [1.5, 2, 0.5] }, children: headerContent }), condition ? (_jsx(_Fragment, { children: conversationHistory ? historyView : GenAICoachElement })) : (_jsxs(Grid, { container: { gap: 0.5, cols: '2fr 3fr' }, as: StyledGridContainer, conversationHistory: !!conversationHistory, children: [historyView, GenAICoachElement] })), lightboxPreviewProps && _jsx(Lightbox, { ...lightboxPreviewProps })] }));
|
|
419
998
|
};
|
|
999
|
+
const GenAICoach = (props) => (_jsx(Toaster, { children: _jsx(StyledFullscreenWrapper, { children: _jsx(GenAICoachContent, { ...props }) }) }));
|
|
420
1000
|
export default withTestIds(GenAICoach, getGenAICoachTestIds);
|
|
421
1001
|
//# sourceMappingURL=GenAICoach.js.map
|