@pega/cosmos-react-work 8.0.0-build.4.4 → 8.0.0-build.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/lib/components/AppAnnouncement/AppAnnouncement.d.ts +8 -4
  2. package/lib/components/AppAnnouncement/AppAnnouncement.d.ts.map +1 -1
  3. package/lib/components/AppAnnouncement/AppAnnouncement.js +6 -4
  4. package/lib/components/AppAnnouncement/AppAnnouncement.js.map +1 -1
  5. package/lib/components/Article/Article.d.ts +2 -6
  6. package/lib/components/Article/Article.d.ts.map +1 -1
  7. package/lib/components/Article/Article.js +2 -7
  8. package/lib/components/Article/Article.js.map +1 -1
  9. package/lib/components/ArticleList/AIArticleSummary.d.ts +1 -1
  10. package/lib/components/ArticleList/AIArticleSummary.d.ts.map +1 -1
  11. package/lib/components/ArticleList/ArticleBuddy.d.ts.map +1 -1
  12. package/lib/components/ArticleList/ArticleBuddy.js +6 -2
  13. package/lib/components/ArticleList/ArticleBuddy.js.map +1 -1
  14. package/lib/components/ArticleList/ArticleBuddyResponse.d.ts +3 -3
  15. package/lib/components/ArticleList/ArticleBuddyResponse.d.ts.map +1 -1
  16. package/lib/components/ArticleList/ArticleBuddyResponse.js +7 -8
  17. package/lib/components/ArticleList/ArticleBuddyResponse.js.map +1 -1
  18. package/lib/components/ArticleList/ArticleFeedback.d.ts +1 -1
  19. package/lib/components/ArticleList/ArticleFeedback.d.ts.map +1 -1
  20. package/lib/components/ArticleList/ArticleList.d.ts.map +1 -1
  21. package/lib/components/ArticleList/ArticleList.js +4 -4
  22. package/lib/components/ArticleList/ArticleList.js.map +1 -1
  23. package/lib/components/ArticleList/ArticleList.types.d.ts +9 -5
  24. package/lib/components/ArticleList/ArticleList.types.d.ts.map +1 -1
  25. package/lib/components/ArticleList/ArticleList.types.js.map +1 -1
  26. package/lib/components/ArticleList/ArticleListHeader.d.ts +1 -1
  27. package/lib/components/ArticleList/ArticleListHeader.d.ts.map +1 -1
  28. package/lib/components/ArticleList/ArticleListHeader.js +9 -6
  29. package/lib/components/ArticleList/ArticleListHeader.js.map +1 -1
  30. package/lib/components/ArticleList/ArticleSemanticSearch.d.ts.map +1 -1
  31. package/lib/components/ArticleList/ArticleSemanticSearch.js +11 -4
  32. package/lib/components/ArticleList/ArticleSemanticSearch.js.map +1 -1
  33. package/lib/components/ArticleList/ArticleSummaryHeader.js +1 -1
  34. package/lib/components/ArticleList/ArticleSummaryHeader.js.map +1 -1
  35. package/lib/components/ArticleList/ArticleTag.d.ts.map +1 -1
  36. package/lib/components/ArticleList/ArticleTag.js +3 -3
  37. package/lib/components/ArticleList/ArticleTag.js.map +1 -1
  38. package/lib/components/ArticleList/QuestionList.d.ts +1 -1
  39. package/lib/components/ArticleList/QuestionList.d.ts.map +1 -1
  40. package/lib/components/ArticleList/QuestionList.js +1 -1
  41. package/lib/components/ArticleList/QuestionList.js.map +1 -1
  42. package/lib/components/ArticleList/RelatedQuestions.d.ts +19 -0
  43. package/lib/components/ArticleList/RelatedQuestions.d.ts.map +1 -0
  44. package/lib/components/ArticleList/RelatedQuestions.js +40 -0
  45. package/lib/components/ArticleList/RelatedQuestions.js.map +1 -0
  46. package/lib/components/ArticleList/index.d.ts +1 -0
  47. package/lib/components/ArticleList/index.d.ts.map +1 -1
  48. package/lib/components/ArticleList/index.js +1 -0
  49. package/lib/components/ArticleList/index.js.map +1 -1
  50. package/lib/components/Assignments/Assignments.js +2 -2
  51. package/lib/components/Assignments/Assignments.js.map +1 -1
  52. package/lib/components/Assignments/Assignments.styles.d.ts +2 -2
  53. package/lib/components/Assignments/Assignments.styles.d.ts.map +1 -1
  54. package/lib/components/CaseHierarchy/CaseHierarchy.d.ts +6 -0
  55. package/lib/components/CaseHierarchy/CaseHierarchy.d.ts.map +1 -0
  56. package/lib/components/CaseHierarchy/CaseHierarchy.js +24 -0
  57. package/lib/components/CaseHierarchy/CaseHierarchy.js.map +1 -0
  58. package/lib/components/CaseHierarchy/CaseHierarchy.styles.d.ts +6 -0
  59. package/lib/components/CaseHierarchy/CaseHierarchy.styles.d.ts.map +1 -0
  60. package/lib/components/CaseHierarchy/CaseHierarchy.styles.js +51 -0
  61. package/lib/components/CaseHierarchy/CaseHierarchy.styles.js.map +1 -0
  62. package/lib/components/CaseHierarchy/CaseHierarchy.test-ids.d.ts +2 -0
  63. package/lib/components/CaseHierarchy/CaseHierarchy.test-ids.d.ts.map +1 -0
  64. package/lib/components/CaseHierarchy/CaseHierarchy.test-ids.js +6 -0
  65. package/lib/components/CaseHierarchy/CaseHierarchy.test-ids.js.map +1 -0
  66. package/lib/components/CaseHierarchy/CaseHierarchy.types.d.ts +23 -0
  67. package/lib/components/CaseHierarchy/CaseHierarchy.types.d.ts.map +1 -0
  68. package/lib/components/CaseHierarchy/CaseHierarchy.types.js +2 -0
  69. package/lib/components/CaseHierarchy/CaseHierarchy.types.js.map +1 -0
  70. package/lib/components/CaseHierarchy/index.d.ts +4 -0
  71. package/lib/components/CaseHierarchy/index.d.ts.map +1 -0
  72. package/lib/components/CaseHierarchy/index.js +3 -0
  73. package/lib/components/CaseHierarchy/index.js.map +1 -0
  74. package/lib/components/CasePreview/CasePreview.d.ts +3 -3
  75. package/lib/components/CasePreview/CasePreview.d.ts.map +1 -1
  76. package/lib/components/CasePreview/CasePreview.js +7 -6
  77. package/lib/components/CasePreview/CasePreview.js.map +1 -1
  78. package/lib/components/CaseView/CaseHeader/CaseHeader.d.ts.map +1 -1
  79. package/lib/components/CaseView/CaseHeader/CaseHeader.js +4 -3
  80. package/lib/components/CaseView/CaseHeader/CaseHeader.js.map +1 -1
  81. package/lib/components/CaseView/CaseHeader/Summary.d.ts +1 -1
  82. package/lib/components/CaseView/CaseHeader/Summary.d.ts.map +1 -1
  83. package/lib/components/CaseView/CaseView.d.ts.map +1 -1
  84. package/lib/components/CaseView/CaseView.js +65 -24
  85. package/lib/components/CaseView/CaseView.js.map +1 -1
  86. package/lib/components/CaseView/CaseView.styles.d.ts +12 -8
  87. package/lib/components/CaseView/CaseView.styles.d.ts.map +1 -1
  88. package/lib/components/CaseView/CaseView.styles.js +287 -110
  89. package/lib/components/CaseView/CaseView.styles.js.map +1 -1
  90. package/lib/components/CaseView/CaseView.types.d.ts +8 -2
  91. package/lib/components/CaseView/CaseView.types.d.ts.map +1 -1
  92. package/lib/components/CaseView/CaseView.types.js.map +1 -1
  93. package/lib/components/CaseView/UtilitiesSummary.d.ts +1 -0
  94. package/lib/components/CaseView/UtilitiesSummary.d.ts.map +1 -1
  95. package/lib/components/CaseView/UtilitiesSummary.js +85 -19
  96. package/lib/components/CaseView/UtilitiesSummary.js.map +1 -1
  97. package/lib/components/CaseView/UtilitySummaryItemDialog.js +1 -1
  98. package/lib/components/CaseView/UtilitySummaryItemDialog.js.map +1 -1
  99. package/lib/components/CaseView/index.d.ts +1 -1
  100. package/lib/components/CaseView/index.d.ts.map +1 -1
  101. package/lib/components/CaseView/index.js.map +1 -1
  102. package/lib/components/ConfigurableLayout/LayoutCell.d.ts +1 -1
  103. package/lib/components/ConfigurableLayout/LayoutCell.d.ts.map +1 -1
  104. package/lib/components/Confirmation/Confirmation.d.ts +3 -3
  105. package/lib/components/Confirmation/Confirmation.d.ts.map +1 -1
  106. package/lib/components/Confirmation/Confirmation.js.map +1 -1
  107. package/lib/components/Details/Details.d.ts +5 -3
  108. package/lib/components/Details/Details.d.ts.map +1 -1
  109. package/lib/components/Details/Details.js +4 -4
  110. package/lib/components/Details/Details.js.map +1 -1
  111. package/lib/components/Details/Details.styles.d.ts.map +1 -1
  112. package/lib/components/Details/Details.styles.js +17 -4
  113. package/lib/components/Details/Details.styles.js.map +1 -1
  114. package/lib/components/GenAICoach/ConversationHistory.d.ts +5 -0
  115. package/lib/components/GenAICoach/ConversationHistory.d.ts.map +1 -0
  116. package/lib/components/GenAICoach/ConversationHistory.js +73 -0
  117. package/lib/components/GenAICoach/ConversationHistory.js.map +1 -0
  118. package/lib/components/GenAICoach/GenAICoach.d.ts +1 -1
  119. package/lib/components/GenAICoach/GenAICoach.d.ts.map +1 -1
  120. package/lib/components/GenAICoach/GenAICoach.js +178 -140
  121. package/lib/components/GenAICoach/GenAICoach.js.map +1 -1
  122. package/lib/components/GenAICoach/GenAICoach.styles.d.ts +21 -10
  123. package/lib/components/GenAICoach/GenAICoach.styles.d.ts.map +1 -1
  124. package/lib/components/GenAICoach/GenAICoach.styles.js +106 -57
  125. package/lib/components/GenAICoach/GenAICoach.styles.js.map +1 -1
  126. package/lib/components/GenAICoach/GenAICoach.test-ids.d.ts +2 -1
  127. package/lib/components/GenAICoach/GenAICoach.test-ids.d.ts.map +1 -1
  128. package/lib/components/GenAICoach/GenAICoach.test-ids.js +9 -1
  129. package/lib/components/GenAICoach/GenAICoach.test-ids.js.map +1 -1
  130. package/lib/components/GenAICoach/GenAICoach.types.d.ts +49 -8
  131. package/lib/components/GenAICoach/GenAICoach.types.d.ts.map +1 -1
  132. package/lib/components/GenAICoach/GenAICoach.types.js.map +1 -1
  133. package/lib/components/GenAICoach/GenAIMessage.d.ts.map +1 -1
  134. package/lib/components/GenAICoach/GenAIMessage.js +77 -13
  135. package/lib/components/GenAICoach/GenAIMessage.js.map +1 -1
  136. package/lib/components/GenAICoach/InitialSuggestedMessage.js +1 -1
  137. package/lib/components/GenAICoach/InitialSuggestedMessage.js.map +1 -1
  138. package/lib/components/GenAICoach/index.d.ts +1 -1
  139. package/lib/components/GenAICoach/index.d.ts.map +1 -1
  140. package/lib/components/GenAICoach/index.js.map +1 -1
  141. package/lib/components/Glimpse/Glimpse.d.ts +3 -3
  142. package/lib/components/Glimpse/Glimpse.d.ts.map +1 -1
  143. package/lib/components/Glimpse/Glimpse.js.map +1 -1
  144. package/lib/components/HierarchicalAssignments/AssignmentContext.d.ts +28 -0
  145. package/lib/components/HierarchicalAssignments/AssignmentContext.d.ts.map +1 -0
  146. package/lib/components/HierarchicalAssignments/AssignmentContext.js +14 -0
  147. package/lib/components/HierarchicalAssignments/AssignmentContext.js.map +1 -0
  148. package/lib/components/HierarchicalAssignments/AssignmentDetail.d.ts +4 -1
  149. package/lib/components/HierarchicalAssignments/AssignmentDetail.d.ts.map +1 -1
  150. package/lib/components/HierarchicalAssignments/AssignmentDetail.js +2 -2
  151. package/lib/components/HierarchicalAssignments/AssignmentDetail.js.map +1 -1
  152. package/lib/components/HierarchicalAssignments/AssignmentNode.d.ts +19 -0
  153. package/lib/components/HierarchicalAssignments/AssignmentNode.d.ts.map +1 -0
  154. package/lib/components/HierarchicalAssignments/AssignmentNode.js +33 -0
  155. package/lib/components/HierarchicalAssignments/AssignmentNode.js.map +1 -0
  156. package/lib/components/HierarchicalAssignments/AssignmentTree.d.ts +15 -0
  157. package/lib/components/HierarchicalAssignments/AssignmentTree.d.ts.map +1 -0
  158. package/lib/components/HierarchicalAssignments/AssignmentTree.js +21 -0
  159. package/lib/components/HierarchicalAssignments/AssignmentTree.js.map +1 -0
  160. package/lib/components/HierarchicalAssignments/Assignments.styles.d.ts +22 -21
  161. package/lib/components/HierarchicalAssignments/Assignments.styles.d.ts.map +1 -1
  162. package/lib/components/HierarchicalAssignments/Assignments.styles.js +85 -69
  163. package/lib/components/HierarchicalAssignments/Assignments.styles.js.map +1 -1
  164. package/lib/components/HierarchicalAssignments/HierarchicalAssignments.d.ts +1 -2
  165. package/lib/components/HierarchicalAssignments/HierarchicalAssignments.d.ts.map +1 -1
  166. package/lib/components/HierarchicalAssignments/HierarchicalAssignments.js +117 -9
  167. package/lib/components/HierarchicalAssignments/HierarchicalAssignments.js.map +1 -1
  168. package/lib/components/HierarchicalAssignments/HierarchicalAssignments.test-ids.d.ts +1 -1
  169. package/lib/components/HierarchicalAssignments/HierarchicalAssignments.test-ids.d.ts.map +1 -1
  170. package/lib/components/HierarchicalAssignments/HierarchicalAssignments.test-ids.js +2 -1
  171. package/lib/components/HierarchicalAssignments/HierarchicalAssignments.test-ids.js.map +1 -1
  172. package/lib/components/HierarchicalAssignments/HierarchicalAssignments.types.d.ts +12 -12
  173. package/lib/components/HierarchicalAssignments/HierarchicalAssignments.types.d.ts.map +1 -1
  174. package/lib/components/HierarchicalAssignments/HierarchicalAssignments.types.js.map +1 -1
  175. package/lib/components/HierarchicalAssignments/helpers.d.ts +23 -0
  176. package/lib/components/HierarchicalAssignments/helpers.d.ts.map +1 -0
  177. package/lib/components/HierarchicalAssignments/helpers.js +167 -0
  178. package/lib/components/HierarchicalAssignments/helpers.js.map +1 -0
  179. package/lib/components/HierarchicalAssignments/nodeItems/AssignmentItem.d.ts +18 -0
  180. package/lib/components/HierarchicalAssignments/nodeItems/AssignmentItem.d.ts.map +1 -0
  181. package/lib/components/HierarchicalAssignments/nodeItems/AssignmentItem.js +105 -0
  182. package/lib/components/HierarchicalAssignments/nodeItems/AssignmentItem.js.map +1 -0
  183. package/lib/components/HierarchicalAssignments/nodeItems/CaseDetail.d.ts +23 -0
  184. package/lib/components/HierarchicalAssignments/nodeItems/CaseDetail.d.ts.map +1 -0
  185. package/lib/components/HierarchicalAssignments/nodeItems/CaseDetail.js +105 -0
  186. package/lib/components/HierarchicalAssignments/nodeItems/CaseDetail.js.map +1 -0
  187. package/lib/components/HierarchicalAssignments/nodeItems/useNodeFocus.d.ts +23 -0
  188. package/lib/components/HierarchicalAssignments/nodeItems/useNodeFocus.d.ts.map +1 -0
  189. package/lib/components/HierarchicalAssignments/nodeItems/useNodeFocus.js +42 -0
  190. package/lib/components/HierarchicalAssignments/nodeItems/useNodeFocus.js.map +1 -0
  191. package/lib/components/IntelligentGuidance/IntelligentGuidance.d.ts +2 -3
  192. package/lib/components/IntelligentGuidance/IntelligentGuidance.d.ts.map +1 -1
  193. package/lib/components/IntelligentGuidance/IntelligentGuidance.js +5 -2
  194. package/lib/components/IntelligentGuidance/IntelligentGuidance.js.map +1 -1
  195. package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.d.ts +2 -2
  196. package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.d.ts.map +1 -1
  197. package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.js +32 -21
  198. package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.js.map +1 -1
  199. package/lib/components/InteractionNotification/CountdownButton.d.ts +3 -3
  200. package/lib/components/InteractionNotification/CountdownButton.d.ts.map +1 -1
  201. package/lib/components/InteractionNotification/CountdownButton.js +1 -1
  202. package/lib/components/InteractionNotification/CountdownButton.js.map +1 -1
  203. package/lib/components/InteractionNotification/InteractionNotification.d.ts +3 -3
  204. package/lib/components/InteractionNotification/InteractionNotification.d.ts.map +1 -1
  205. package/lib/components/InteractionNotification/InteractionNotification.js +1 -1
  206. package/lib/components/InteractionNotification/InteractionNotification.js.map +1 -1
  207. package/lib/components/Predictions/Predictions.d.ts +2 -3
  208. package/lib/components/Predictions/Predictions.d.ts.map +1 -1
  209. package/lib/components/Predictions/Predictions.js +1 -0
  210. package/lib/components/Predictions/Predictions.js.map +1 -1
  211. package/lib/components/SearchResults/ActiveFilter.d.ts +1 -1
  212. package/lib/components/SearchResults/ActiveFilter.d.ts.map +1 -1
  213. package/lib/components/SearchResults/SearchResults.d.ts +2 -3
  214. package/lib/components/SearchResults/SearchResults.d.ts.map +1 -1
  215. package/lib/components/SearchResults/SearchResults.js +1 -2
  216. package/lib/components/SearchResults/SearchResults.js.map +1 -1
  217. package/lib/components/SearchResults/SearchResults.styles.d.ts +1 -1
  218. package/lib/components/SearchResults/SearchResults.styles.d.ts.map +1 -1
  219. package/lib/components/Stages/StageGlimpse.js +1 -1
  220. package/lib/components/Stages/StageGlimpse.js.map +1 -1
  221. package/lib/components/Stages/Stages.d.ts +2 -3
  222. package/lib/components/Stages/Stages.d.ts.map +1 -1
  223. package/lib/components/Stages/Stages.js +4 -1
  224. package/lib/components/Stages/Stages.js.map +1 -1
  225. package/lib/components/Stages/Stages.styles.d.ts +5 -3
  226. package/lib/components/Stages/Stages.styles.d.ts.map +1 -1
  227. package/lib/components/Stages/Stages.styles.js +6 -10
  228. package/lib/components/Stages/Stages.styles.js.map +1 -1
  229. package/lib/components/Stakeholders/StakeholderForm.d.ts +1 -1
  230. package/lib/components/Stakeholders/Stakeholders.d.ts +2 -3
  231. package/lib/components/Stakeholders/Stakeholders.d.ts.map +1 -1
  232. package/lib/components/Stakeholders/Stakeholders.js +37 -26
  233. package/lib/components/Stakeholders/Stakeholders.js.map +1 -1
  234. package/lib/components/Tags/Tags.d.ts +3 -3
  235. package/lib/components/Tags/Tags.d.ts.map +1 -1
  236. package/lib/components/Tags/Tags.js.map +1 -1
  237. package/lib/components/Tasks/TaskList.d.ts +10 -5
  238. package/lib/components/Tasks/TaskList.d.ts.map +1 -1
  239. package/lib/components/Tasks/TaskList.js +15 -7
  240. package/lib/components/Tasks/TaskList.js.map +1 -1
  241. package/lib/components/Tasks/Tasks.d.ts +6 -1
  242. package/lib/components/Tasks/Tasks.d.ts.map +1 -1
  243. package/lib/components/Tasks/Tasks.js +14 -4
  244. package/lib/components/Tasks/Tasks.js.map +1 -1
  245. package/lib/components/Timeline/Timeline.d.ts +3 -3
  246. package/lib/components/Timeline/Timeline.d.ts.map +1 -1
  247. package/lib/components/Timeline/Timeline.js +9 -2
  248. package/lib/components/Timeline/Timeline.js.map +1 -1
  249. package/lib/components/Timeline/Timeline.styles.d.ts +5 -5
  250. package/lib/components/Timeline/Timeline.styles.d.ts.map +1 -1
  251. package/lib/components/Timeline/Timeline.styles.js +10 -3
  252. package/lib/components/Timeline/Timeline.styles.js.map +1 -1
  253. package/lib/components/Timeline/Timeline.types.d.ts +11 -1
  254. package/lib/components/Timeline/Timeline.types.d.ts.map +1 -1
  255. package/lib/components/Timeline/Timeline.types.js.map +1 -1
  256. package/lib/components/Timeline/TimelineItem.d.ts +1 -2
  257. package/lib/components/Timeline/TimelineItem.d.ts.map +1 -1
  258. package/lib/components/Timeline/TimelineItem.js +10 -9
  259. package/lib/components/Timeline/TimelineItem.js.map +1 -1
  260. package/lib/components/Timeline/TimelineToolbar.d.ts +2 -3
  261. package/lib/components/Timeline/TimelineToolbar.d.ts.map +1 -1
  262. package/lib/components/Timeline/TimelineToolbar.js.map +1 -1
  263. package/lib/components/UtilitiesLayout/UtilitiesLayout.d.ts +5 -0
  264. package/lib/components/UtilitiesLayout/UtilitiesLayout.d.ts.map +1 -1
  265. package/lib/components/UtilitiesLayout/UtilitiesLayout.js +3 -3
  266. package/lib/components/UtilitiesLayout/UtilitiesLayout.js.map +1 -1
  267. package/lib/components/UtilitiesLayout/UtilitiesLayout.styles.d.ts +0 -2
  268. package/lib/components/UtilitiesLayout/UtilitiesLayout.styles.d.ts.map +1 -1
  269. package/lib/components/UtilitiesLayout/UtilitiesLayout.styles.js +2 -5
  270. package/lib/components/UtilitiesLayout/UtilitiesLayout.styles.js.map +1 -1
  271. package/lib/index.d.ts +2 -0
  272. package/lib/index.d.ts.map +1 -1
  273. package/lib/index.js +2 -0
  274. package/lib/index.js.map +1 -1
  275. package/package.json +9 -8
  276. package/lib/components/HierarchicalAssignments/AssignmentContainer.d.ts +0 -32
  277. package/lib/components/HierarchicalAssignments/AssignmentContainer.d.ts.map +0 -1
  278. package/lib/components/HierarchicalAssignments/AssignmentContainer.js +0 -46
  279. package/lib/components/HierarchicalAssignments/AssignmentContainer.js.map +0 -1
  280. package/lib/components/HierarchicalAssignments/AssignmentItem.d.ts +0 -10
  281. package/lib/components/HierarchicalAssignments/AssignmentItem.d.ts.map +0 -1
  282. package/lib/components/HierarchicalAssignments/AssignmentItem.js +0 -22
  283. package/lib/components/HierarchicalAssignments/AssignmentItem.js.map +0 -1
@@ -1,6 +1,6 @@
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 { Button, Flex, Icon, MenuButton, Progress, Text, TextArea, createUID, menuHelpers, useI18n, useTestIds, useTheme, withTestIds, Card, registerIcon, usePrevious, getFocusables, isMenuGroupProps, ErrorState, Tooltip, useElement, useArrows, focusableSelector, useLiveLog, useOuterEvent, Configuration, hasProp } from '@pega/cosmos-react-core';
3
+ import { Button, Flex, Icon, MenuButton, Progress, Text, TextArea, createUID, menuHelpers, useI18n, useTestIds, useTheme, withTestIds, registerIcon, usePrevious, getFocusables, isMenuGroupProps, ErrorState, useArrows, focusableSelector, useLiveLog, useOuterEvent, ThemeOverride, hasProp, getActiveElement, useElement, Actions, useBreakpoint, Grid } from '@pega/cosmos-react-core';
4
4
  import * as caretUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-up.icon';
5
5
  import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
6
6
  import * as caretDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-down.icon';
@@ -8,22 +8,29 @@ import * as minusIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/mi
8
8
  import * as polarisSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/polaris-solid.icon';
9
9
  import { getGenAICoachTestIds } from './GenAICoach.test-ids';
10
10
  import { isCoachMessage, isInUtilities, isUserMessage } from './GenAICoach.utils';
11
- import { StyledChatButton, StyledCloseButton, StyledMessagesContainer, StyledDisclaimerText, StyledGenAICoachContainer, StyledGenAIOptionsMenu, StyledInitialMessageContainer, StyledInputContainer, StyledStarterMessage, StyledSuggestions, StyledStarterMessageCard, StyledMessagesList } from './GenAICoach.styles';
11
+ import { StyledMessagesContainer, StyledDisclaimerText, StyledGenAICoachContainer, StyledGenAIOptionsMenu, StyledInitialMessageContainer, StyledInputContainer, StyledSuggestions, StyledMessagesList, StyledGridContainer, StyledFlexWrapper } from './GenAICoach.styles';
12
+ import ConversationHistory from './ConversationHistory';
12
13
  import { GenAIMessage, InitialSuggestedMessage } from '.';
13
14
  registerIcon(caretUpIcon, timesIcon, caretDownIcon, minusIcon, polarisSolidIcon);
14
- const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: onCoachChangeProp, messages = [], onSend, initialSuggestedMessages, suggestions, loading, error, starterMessage, variant, onOpen, guidedMode = false, ...restProps }) => {
15
+ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: onCoachChangeProp, messages = [], onSend, initialSuggestedMessages, suggestions, loading, error, variant, onOpen, guidedMode = false, actions, conversationHistory, onLayoutChange, ...restProps }) => {
15
16
  const theme = useTheme();
16
17
  const t = useI18n();
17
18
  const elementRef = useRef(null);
18
19
  const conversationRef = useRef(null);
19
20
  const genAICoachRef = useRef(null);
20
- const [starterMessageElement, setStarterMessageElement] = useElement(null);
21
+ const isSmallOrAbove = useBreakpoint('sm', {
22
+ breakpointRef: genAICoachRef
23
+ });
21
24
  const focusInMessageListRef = useRef(false);
22
25
  const isUserTriggered = useRef(false);
23
26
  const lastFocusedMessageRef = useRef(null);
24
27
  const initialFocusedElementRef = useRef(null);
25
28
  const messageContainerRef = useRef(null);
26
29
  const textAreaRef = useRef(null);
30
+ const [suggestionMenuButton, setSuggestionMenuButton] = useElement(null);
31
+ const isGeneratingResponse = useRef(false);
32
+ const focusTextArea = useRef(false);
33
+ const historyViewRef = useRef(null);
27
34
  const [message, setMessage] = useState('');
28
35
  const [coachOptions, setCoachOptions] = useState(coachOptionsProps);
29
36
  const [arrowKey, setArrowKey] = useState(null);
@@ -31,6 +38,10 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
31
38
  const testIds = useTestIds(testId, getGenAICoachTestIds);
32
39
  const { announcePolite } = useLiveLog();
33
40
  const latestMessage = messages.at(-1);
41
+ const condition = variant.placement === 'dialog' ||
42
+ variant.placement === 'utilities' ||
43
+ (variant.placement === 'fullpage' && !isSmallOrAbove) ||
44
+ !conversationHistory;
34
45
  const onCoachChange = (id) => {
35
46
  setCoachOptions(cur => {
36
47
  return cur.map(coach => {
@@ -76,20 +87,20 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
76
87
  if (coachOptions.length === 1) {
77
88
  return (_jsxs(Flex, { container: { gap: 1 }, children: [_jsx(Icon, { name: 'polaris-solid', color: theme.base.palette.ai }), _jsx(Text, { variant: 'h3', children: selectedCoach })] }));
78
89
  }
79
- return (_jsx(MenuButton, { text: selectedCoach, variant: 'text', as: StyledGenAIOptionsMenu, icon: 'polaris-solid', menu: {
90
+ return (_jsx(MenuButton, { text: selectedCoach, "aria-label": t('agent_switcher', [selectedCoach]), variant: 'text', as: StyledGenAIOptionsMenu, icon: 'polaris-solid', menu: {
80
91
  mode: 'single-select',
81
92
  items: coachOptions,
82
93
  onItemClick: onCoachChange
83
94
  } }));
84
95
  }, [coachOptions, selectedCoach]);
85
96
  const headerContent = useMemo(() => {
86
- return isInUtilities(variant) && variant.state === 'docked' ? (_jsxs(_Fragment, { children: [_jsxs(Flex, { container: { gap: 1 }, children: [_jsx(Icon, { name: 'polaris-solid', color: theme.base.palette.ai }), _jsx(Text, { variant: 'h3', children: selectedCoach })] }), _jsx(Flex, { container: { alignItems: 'center' }, children: _jsx(Button, { icon: true, label: t('maximize'), "aria-label": t('maximize_gen_ai', [t('coach', ['Pega Gen AI'])]), variant: 'simple', onClick: () => {
97
+ return isInUtilities(variant) && variant.state === 'minimized' ? (_jsxs(_Fragment, { children: [_jsxs(Flex, { container: { gap: 1 }, children: [_jsx(Icon, { name: 'polaris-solid', color: theme.base.palette.ai }), _jsx(Text, { variant: 'h3', children: selectedCoach })] }), _jsx(Flex, { container: { alignItems: 'center' }, children: _jsx(Button, { icon: true, label: t('maximize'), "aria-label": t('agent_noun', [t('maximize')]), variant: 'simple', onClick: () => {
87
98
  variant.onStateChange('maximized');
88
99
  isUserTriggered.current = true;
89
- }, children: _jsx(Icon, { name: 'caret-up' }) }) })] })) : (_jsxs(_Fragment, { children: [renderCoachOptions, isInUtilities(variant) && (_jsx(Button, { icon: true, label: t('minimize'), "aria-label": t('minimize_gen_ai', [t('coach', ['Pega Gen AI'])]), variant: 'simple', onClick: () => {
90
- variant.onStateChange('docked');
91
- isUserTriggered.current = true;
92
- }, children: _jsx(Icon, { name: 'minus' }) })), variant.placement === 'dialog' && (_jsx(Button, { icon: true, label: t('close'), "aria-label": t('close_gen_ai', [t('coach', ['Pega Gen AI'])]), variant: 'simple', onClick: variant.onClose, children: _jsx(Icon, { name: 'times' }) }))] }));
100
+ }, children: _jsx(Icon, { name: 'caret-up' }) }) })] })) : (_jsxs(_Fragment, { children: [renderCoachOptions, _jsxs(Flex, { container: true, children: [isInUtilities(variant) && (_jsx(Button, { icon: true, label: t('minimize'), "aria-label": t('agent_noun', [t('minimize')]), variant: 'simple', onClick: () => {
101
+ variant.onStateChange('minimized');
102
+ isUserTriggered.current = true;
103
+ }, 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' }) }))] })] }));
93
104
  }, [variant, coachOptions]);
94
105
  const setLastFocusableElement = () => {
95
106
  focusInMessageListRef.current = false;
@@ -116,7 +127,7 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
116
127
  }
117
128
  if (isUserTriggered.current) {
118
129
  if (isInUtilities(variant) &&
119
- (variant.state === 'docked' || (guidedMode && variant.state === 'maximized')) &&
130
+ (variant.state === 'minimized' || (guidedMode && variant.state === 'maximized')) &&
120
131
  getFocusables(genAICoachRef).length > 0) {
121
132
  getFocusables(genAICoachRef)[0].focus();
122
133
  isUserTriggered.current = false;
@@ -128,6 +139,9 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
128
139
  }
129
140
  }
130
141
  }, [variantState, variant.placement]);
142
+ useEffect(() => {
143
+ onLayoutChange?.(!condition);
144
+ }, [condition]);
131
145
  useEffect(() => {
132
146
  onOpen?.();
133
147
  window.addEventListener('resize', onResize);
@@ -136,9 +150,6 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
136
150
  };
137
151
  }, []);
138
152
  useEffect(() => {
139
- if (isInUtilities(variant) && variant.state !== 'maximized' && messages.length > 0) {
140
- variant.onStateChange('maximized');
141
- }
142
153
  const prevFilteredMsgs = previousMessages?.filter(item => !hasProp(item, 'loading')) ?? [];
143
154
  const currentFilteredMsgs = messages?.filter(item => !hasProp(item, 'loading')) ?? [];
144
155
  if (prevFilteredMsgs.length < currentFilteredMsgs.length ||
@@ -156,13 +167,22 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
156
167
  setArrowKey(null);
157
168
  }
158
169
  else if (latestMessage?.loading) {
159
- announcePolite({ message: t('generating_response') });
170
+ isGeneratingResponse.current = true;
160
171
  }
161
172
  else {
162
- announcePolite({ message: t('coach', [`${t('new_message')} ${t('from')}`]) });
173
+ announcePolite({ message: t('agent_noun', [`${t('new_message')} ${t('from')}`]) });
163
174
  }
164
175
  }
165
176
  }, [messages]);
177
+ useEffect(() => {
178
+ if (suggestionMenuButton && isGeneratingResponse.current) {
179
+ announcePolite({ message: t('response_generated') });
180
+ isGeneratingResponse.current = false;
181
+ const activeElement = getActiveElement();
182
+ if (activeElement && activeElement === document.body)
183
+ suggestionMenuButton.focus();
184
+ }
185
+ }, [suggestionMenuButton]);
166
186
  /** Supports arrow key behaviors */
167
187
  useEffect(() => {
168
188
  const focusables = getFocusables(elementRef);
@@ -191,56 +211,67 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
191
211
  setArrowKey(null);
192
212
  focusInMessageListRef.current = false;
193
213
  });
194
- return (_jsxs(Flex, { container: { direction: 'column' }, as: StyledGenAICoachContainer, "data-testid": testIds.root, variant: variant, starterMessage: starterMessage, ref: genAICoachRef, ...restProps, children: [_jsx(Flex, { container: { justify: 'between', alignItems: 'center', pad: 1 }, children: headerContent }), ((isInUtilities(variant) && variant.state !== 'docked') || !isInUtilities(variant)) && (_jsxs(_Fragment, { children: [_jsx(Flex, { as: StyledMessagesContainer, ref: messageContainerRef, container: starterMessage || loading || error
195
- ? { direction: 'column', pad: [0, 2], justify: 'center' }
196
- : { direction: 'column', pad: [0, 2] }, item: { grow: 1 }, 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 ? (_jsx(_Fragment, { children: starterMessage ? (_jsxs(Card, { container: { alignItems: 'center', pad: 1, justify: 'between' }, item: { grow: 0 }, as: StyledStarterMessageCard, children: [_jsx(StyledStarterMessage, { ref: setStarterMessageElement, children: starterMessage.message }), starterMessage.message && starterMessageElement && (_jsx(Tooltip, { target: starterMessageElement, smart: true, children: starterMessage.message })), _jsx(StyledCloseButton, { icon: true, label: t('close'), "aria-label": `${t('close')} ${t('starter_message')}`, variant: 'simple', onClick: starterMessage.onClose, children: _jsx(Icon, { name: 'times' }) })] })) : (_jsxs(Flex, { as: StyledInitialMessageContainer, container: {
197
- justify: 'center',
198
- direction: 'column',
199
- gap: 8
200
- }, item: { grow: 1 }, children: [((isInUtilities(variant) && variant.state === 'maximized') ||
201
- !isInUtilities(variant)) && (_jsxs(Flex, { container: { direction: 'column', alignItems: 'center', gap: 2 }, children: [_jsx(Icon, { name: 'polaris-solid', size: 'l', color: theme.base.palette.ai }), _jsx(Text, { variant: 'h2', children: t('welcome_text') })] })), _jsx(Flex, { container: { direction: 'column', gap: 1.5 }, children: initialSuggestedMessages?.map(initialSuggestedMessage => (_jsx(InitialSuggestedMessage, { ...initialSuggestedMessage, onSend: initialMessage => {
202
- onSend(initialMessage);
203
- isUserTriggered.current = true;
204
- }, testId: initialSuggestedMessage.id }))) })] })) })) : (_jsx(Flex, { as: StyledMessagesList, ref: conversationRef, container: { direction: 'column' }, onFocus: () => {
205
- if (!focusInMessageListRef.current) {
206
- if (lastFocusedMessageRef.current) {
207
- lastFocusedMessageRef.current.focus();
208
- }
209
- else {
210
- /** Focus on the latest message if the chat message list was never focused */
211
- const lastChild = conversationRef.current && conversationRef.current.lastElementChild;
212
- if (lastChild instanceof HTMLElement) {
213
- lastChild.focus();
214
- }
214
+ const GenAICoachElement = (_jsx(_Fragment, { children: ((isInUtilities(variant) && variant.state !== 'minimized') || !isInUtilities(variant)) && (_jsxs(Flex, { container: { direction: 'column' }, as: StyledFlexWrapper, children: [_jsx(Flex, { as: StyledMessagesContainer, ref: messageContainerRef, container: loading || error
215
+ ? { direction: 'column', pad: [0, 2], justify: 'center' }
216
+ : { direction: 'column', pad: [0, 2] }, item: { grow: 1 }, 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: {
217
+ justify: 'center',
218
+ direction: 'column',
219
+ gap: 8
220
+ }, item: { grow: 1 }, children: [((isInUtilities(variant) && variant.state === 'maximized') ||
221
+ !isInUtilities(variant)) && (_jsxs(Flex, { container: { direction: 'column', alignItems: 'center', gap: 2 }, children: [_jsx(Icon, { name: 'polaris-solid', size: 'l', color: theme.base.palette.ai }), _jsx(Text, { variant: 'h2', children: t('welcome_text') })] })), _jsx(Flex, { container: { direction: 'column', gap: 1.5 }, children: initialSuggestedMessages?.map(initialSuggestedMessage => (_jsx(InitialSuggestedMessage, { ...initialSuggestedMessage, onSend: initialMessage => {
222
+ onSend(initialMessage);
223
+ isUserTriggered.current = true;
224
+ }, testId: initialSuggestedMessage.id }))) })] })) : (_jsx(Flex, { as: StyledMessagesList, ref: conversationRef, "aria-label": `${t('conversation')} ${t('view')}`, container: { direction: 'column' }, onFocus: () => {
225
+ if (!focusInMessageListRef.current) {
226
+ if (lastFocusedMessageRef.current) {
227
+ lastFocusedMessageRef.current.focus();
228
+ }
229
+ else {
230
+ /** Focus on the latest message if the chat message list was never focused */
231
+ const lastChild = conversationRef.current && conversationRef.current.lastElementChild;
232
+ if (lastChild instanceof HTMLElement) {
233
+ lastChild.focus();
215
234
  }
216
235
  }
217
- focusInMessageListRef.current = true;
218
- setArrowKey(null);
219
- }, onKeyDown: (e) => {
220
- if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
236
+ }
237
+ focusInMessageListRef.current = true;
238
+ setArrowKey(null);
239
+ }, onKeyDown: (e) => {
240
+ if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
241
+ setArrowKey(e.key);
242
+ elementRef.current = null;
243
+ }
244
+ else if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
245
+ const currentElement = conversationRef.current?.querySelector('li:focus');
246
+ if (currentElement && currentElement instanceof HTMLElement) {
247
+ elementRef.current = currentElement;
248
+ }
249
+ else {
250
+ elementRef.current =
251
+ conversationRef.current
252
+ ?.querySelector(':focus')
253
+ ?.closest('li[type="message"]') || null;
254
+ }
255
+ initialFocusedElementRef.current = elementRef.current;
256
+ if (currentElement && getFocusables(currentElement).length > 0) {
221
257
  setArrowKey(e.key);
222
- elementRef.current = null;
223
258
  }
224
- else if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
225
- const currentElement = conversationRef.current?.querySelector('li:focus');
226
- if (currentElement && currentElement instanceof HTMLElement) {
227
- elementRef.current = currentElement;
259
+ }
260
+ else if (e.key === 'Tab') {
261
+ setLastFocusableElement();
262
+ if (e.shiftKey) {
263
+ if (!condition &&
264
+ conversationHistory &&
265
+ conversationHistory.selectedItemId) {
266
+ const selectedId = historyViewRef.current?.querySelector(`li[id="${conversationHistory.selectedItemId}"]`);
267
+ if (selectedId) {
268
+ selectedId.focus();
269
+ e.preventDefault();
270
+ }
228
271
  }
229
272
  else {
230
- elementRef.current =
231
- conversationRef.current
232
- ?.querySelector(':focus')
233
- ?.closest('li[type="message"]') || null;
234
- }
235
- initialFocusedElementRef.current = elementRef.current;
236
- if (currentElement && getFocusables(currentElement).length > 0) {
237
- setArrowKey(e.key);
238
- }
239
- }
240
- else if (e.key === 'Tab') {
241
- setLastFocusableElement();
242
- if (e.shiftKey) {
243
- const prevElement = conversationRef.current?.parentElement?.previousElementSibling;
273
+ const prevElement = conversationRef.current?.parentElement?.parentElement
274
+ ?.previousElementSibling;
244
275
  if (prevElement) {
245
276
  const focusables = getFocusables(prevElement);
246
277
  if (focusables.length) {
@@ -249,95 +280,102 @@ const GenAICoach = ({ testId, coachOptions: coachOptionsProps, onCoachChange: on
249
280
  }
250
281
  }
251
282
  }
252
- else {
253
- const nextElement = conversationRef.current?.parentElement?.nextElementSibling;
254
- if (nextElement) {
255
- const focusables = getFocusables(nextElement);
256
- if (focusables.length) {
257
- e.preventDefault();
258
- focusables[0].focus();
259
- }
283
+ }
284
+ else {
285
+ const nextElement = conversationRef.current?.parentElement?.nextElementSibling;
286
+ if (nextElement) {
287
+ const focusables = getFocusables(nextElement);
288
+ if (focusables.length) {
289
+ e.preventDefault();
290
+ focusables[0].focus();
260
291
  }
261
292
  }
262
293
  setArrowKey(null);
263
294
  }
264
- }, children: messages.map(item => {
265
- const messageProps = isCoachMessage(item)
266
- ? {
267
- ...item,
268
- onSend
269
- }
270
- : item;
271
- return _jsx(GenAIMessage, { ...messageProps, testId: item.id });
272
- }) })) })) }), !starterMessage &&
273
- ((isInUtilities(variant) &&
274
- variant.state !== 'docked' &&
275
- variant.state !== 'minimized') ||
276
- !isInUtilities(variant)) && (_jsx(Flex, { container: { direction: 'column' }, as: StyledInputContainer, children: guidedMode ? (_jsx(_Fragment, { children: suggestions && messages.length > 0 && (_jsxs(_Fragment, { children: [latestMessage && isCoachMessage(latestMessage) && latestMessage.loading ? (_jsxs(Flex, { container: {
277
- gap: 1,
278
- justify: 'center',
279
- alignItems: 'center',
280
- pad: 1
281
- }, children: [t('generating_response'), _jsx(Progress, { placement: 'inline' })] })) : (_jsx(Configuration, { theme: {
282
- components: {
283
- button: {
284
- color: theme.base.palette.ai,
285
- 'secondary-color': theme.base.palette.ai,
286
- 'secondary-fill-style': 'outline'
287
- }
288
- }
289
- }, children: _jsx(MenuButton, { text: t('ask_coach', [selectedCoach ?? '']), icon: 'polaris-solid', menu: {
290
- items: suggestions,
291
- onItemClick: id => {
292
- const selected = menuHelpers.getItem(suggestions, id);
293
- if (selected)
294
- onSend({
295
- id: selected.id,
296
- message: selected.primary
297
- });
298
- }
299
- } }) })), _jsx(StyledDisclaimerText, { 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 }), latestMessage && isCoachMessage(latestMessage) && latestMessage.loading ? (_jsxs(Flex, { container: {
295
+ }
296
+ }, children: messages.map(item => {
297
+ const messageProps = isCoachMessage(item)
298
+ ? {
299
+ ...item,
300
+ suggestions: messages.findLast(messageItem => isCoachMessage(messageItem))?.id ===
301
+ item.id
302
+ ? item.suggestions
303
+ : undefined,
304
+ onSend
305
+ }
306
+ : item;
307
+ return (_jsx(GenAIMessage, { ...messageProps, testId: item.id, announceInteraction: !focusInMessageListRef.current }));
308
+ }) })) })) }), ((isInUtilities(variant) && variant.state !== 'minimized') ||
309
+ !isInUtilities(variant)) && (_jsx(Flex, { container: { direction: 'column' }, as: StyledInputContainer, children: guidedMode ? (_jsx(_Fragment, { children: suggestions && messages.length > 0 && (_jsxs(_Fragment, { children: [latestMessage && isCoachMessage(latestMessage) && latestMessage.loading ? (_jsxs(Flex, { container: {
300
310
  gap: 1,
301
- justify: 'end',
311
+ justify: 'center',
302
312
  alignItems: 'center',
303
313
  pad: 1
304
- }, children: [t('generating_response'), _jsx(Progress, { placement: 'inline' })] })) : (_jsxs(Flex, { container: {
305
- gap: 2,
306
- justify: 'end',
307
- pad: 1
308
- }, children: [suggestions && (_jsx(MenuButton, { text: t('suggestions'), variant: 'text', icon: 'polaris-solid', as: StyledSuggestions, menu: {
309
- items: suggestions,
310
- onItemClick: id => {
311
- const selected = menuHelpers.getItem(suggestions, id);
312
- if (selected)
313
- onSend({
314
- id: selected.id,
315
- message: selected.primary
316
- });
317
- }
318
- } })), _jsx(Button, { variant: 'primary', onClick: message
319
- ? () => {
314
+ }, children: [t('generating_response'), _jsx(Progress, { placement: 'inline', focusOnVisible: true, message: t('generating_response') })] })) : (_jsx(ThemeOverride, { theme: {
315
+ components: {
316
+ button: {
317
+ color: theme.base.palette.ai,
318
+ 'secondary-color': theme.base.palette.ai,
319
+ 'secondary-fill-style': 'outline'
320
+ }
321
+ }
322
+ }, children: _jsx(MenuButton, { text: t('ask_coach', [selectedCoach ?? '']), variant: 'primary', icon: 'polaris-solid', ref: setSuggestionMenuButton, menu: {
323
+ items: suggestions,
324
+ onItemClick: id => {
325
+ const selected = menuHelpers.getItem(suggestions, id);
326
+ if (selected)
320
327
  onSend({
321
- id: createUID(),
322
- message
328
+ id: selected.id,
329
+ message: selected.primary
323
330
  });
324
- setMessage('');
325
- }
326
- : undefined, children: t('send') })] })), _jsx(StyledDisclaimerText, { children: t('ai_disclaimer') })] })) })), !loading &&
327
- !error &&
328
- messages.length === 0 &&
329
- ((isInUtilities(variant) && variant.state === 'minimized') || starterMessage) && (_jsx(StyledChatButton, { icon: true, onClick: () => {
330
- isUserTriggered.current = true;
331
- if (isInUtilities(variant)) {
332
- variant.onStateChange('maximized');
333
- }
334
- if (starterMessage && starterMessage.message) {
335
- onSend({
336
- id: starterMessage.id,
337
- message: starterMessage.message
338
- });
339
- }
340
- }, children: _jsxs(Flex, { container: { alignItems: 'center', gap: 1 }, children: [_jsx(Icon, { name: 'polaris-solid' }), t('start_chat')] }) }))] }))] }));
331
+ }
332
+ } }) })), _jsx(StyledDisclaimerText, { 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 }), latestMessage && isCoachMessage(latestMessage) && latestMessage.loading ? (_jsxs(Flex, { container: {
333
+ gap: 1,
334
+ justify: 'end',
335
+ alignItems: 'center',
336
+ pad: 1
337
+ }, children: [t('generating_response'), _jsx(Progress, { placement: 'inline' })] })) : (_jsxs(Flex, { container: {
338
+ gap: 2,
339
+ justify: 'end',
340
+ pad: [1, undefined, undefined]
341
+ }, children: [suggestions && (_jsx(MenuButton, { text: t('suggestions'), variant: 'text', icon: 'polaris-solid', as: StyledSuggestions, menu: {
342
+ items: suggestions,
343
+ onItemClick: id => {
344
+ const selected = menuHelpers.getItem(suggestions, id);
345
+ if (selected)
346
+ onSend({
347
+ id: selected.id,
348
+ message: selected.primary
349
+ });
350
+ }
351
+ } })), _jsx(Button, { variant: 'primary', onClick: message
352
+ ? () => {
353
+ onSend({
354
+ id: createUID(),
355
+ message
356
+ });
357
+ setMessage('');
358
+ }
359
+ : undefined, children: t('send') })] })), _jsx(StyledDisclaimerText, { inFullPage: !condition, children: t('ai_disclaimer') })] })) }))] })) }));
360
+ useEffect(() => {
361
+ if (focusTextArea.current && !conversationHistory && textAreaRef.current) {
362
+ textAreaRef.current.focus();
363
+ focusTextArea.current = false;
364
+ }
365
+ }, [conversationHistory, focusTextArea.current]);
366
+ const historyView = conversationHistory && (_jsx(ConversationHistory, { testId: testIds.root, ...conversationHistory, onItemClick: conversationId => {
367
+ if (condition) {
368
+ focusTextArea.current = true;
369
+ }
370
+ else {
371
+ textAreaRef.current?.focus();
372
+ }
373
+ conversationHistory.onItemClick?.(conversationId);
374
+ }, onDismiss: () => {
375
+ focusTextArea.current = true;
376
+ conversationHistory.onDismiss();
377
+ }, inFullPage: !condition, ref: historyViewRef }));
378
+ return (_jsxs(Flex, { container: { direction: 'column' }, as: StyledGenAICoachContainer, "data-testid": testIds.root, variant: variant, ref: genAICoachRef, ...restProps, 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] }))] }));
341
379
  };
342
380
  export default withTestIds(GenAICoach, getGenAICoachTestIds);
343
381
  //# sourceMappingURL=GenAICoach.js.map