@microsoft/omnichannel-chat-widget 1.8.3-main.ec1328d → 1.8.4-main.7bdb634

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 (160) hide show
  1. package/lib/cjs/common/Constants.js +6 -0
  2. package/lib/cjs/common/facades/FacadeChatSDK.js +6 -0
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +34 -0
  4. package/lib/cjs/common/utils/SecureEventBus.js +307 -0
  5. package/lib/cjs/common/utils/dispatchCustomEvent.js +25 -0
  6. package/lib/cjs/components/citationpanestateful/CitationDim.js +29 -0
  7. package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +199 -0
  8. package/lib/cjs/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +70 -0
  9. package/lib/cjs/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
  10. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +4 -4
  11. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +127 -0
  12. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
  13. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +15 -0
  14. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +284 -0
  15. package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
  16. package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +18 -0
  17. package/lib/cjs/components/livechatwidget/common/endChat.js +28 -3
  18. package/lib/cjs/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
  19. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +8 -6
  20. package/lib/cjs/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
  21. package/lib/cjs/components/livechatwidget/common/startChat.js +5 -4
  22. package/lib/cjs/components/livechatwidget/interfaces/IMockProps.js +8 -2
  23. package/lib/cjs/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
  24. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +29 -5
  25. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +122 -11
  26. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
  27. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
  28. package/lib/cjs/components/webchatcontainerstateful/common/activities/botActivity.js +14 -0
  29. package/lib/cjs/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +17 -0
  30. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +97 -0
  31. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
  32. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +1 -1
  33. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
  34. package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +36 -2
  35. package/lib/cjs/components/webchatcontainerstateful/common/utils/fontUtils.js +28 -0
  36. package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +59 -0
  37. package/lib/cjs/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
  38. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +122 -0
  39. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +10 -0
  40. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +18 -0
  41. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1038 -0
  42. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +34 -0
  43. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +44 -0
  44. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +16 -2
  45. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  46. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +20 -0
  47. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
  48. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +2 -2
  49. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +59 -0
  50. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +4 -3
  51. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -2
  52. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +97 -30
  53. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
  54. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +46 -45
  55. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
  56. package/lib/cjs/contexts/createReducer.js +15 -0
  57. package/lib/cjs/index.js +9 -1
  58. package/lib/esm/common/Constants.js +6 -0
  59. package/lib/esm/common/facades/FacadeChatSDK.js +6 -0
  60. package/lib/esm/common/telemetry/TelemetryConstants.js +34 -0
  61. package/lib/esm/common/utils/SecureEventBus.js +328 -0
  62. package/lib/esm/common/utils/dispatchCustomEvent.js +18 -0
  63. package/lib/esm/components/citationpanestateful/CitationDim.js +20 -0
  64. package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +188 -0
  65. package/lib/esm/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +61 -0
  66. package/lib/esm/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
  67. package/lib/esm/components/livechatwidget/LiveChatWidget.js +4 -4
  68. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +120 -0
  69. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
  70. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +8 -0
  71. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +277 -0
  72. package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
  73. package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +11 -0
  74. package/lib/esm/components/livechatwidget/common/endChat.js +29 -4
  75. package/lib/esm/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
  76. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +8 -6
  77. package/lib/esm/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
  78. package/lib/esm/components/livechatwidget/common/startChat.js +5 -4
  79. package/lib/esm/components/livechatwidget/interfaces/IMockProps.js +3 -3
  80. package/lib/esm/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
  81. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +29 -5
  82. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +125 -12
  83. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
  84. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
  85. package/lib/esm/components/webchatcontainerstateful/common/activities/botActivity.js +7 -0
  86. package/lib/esm/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +9 -0
  87. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +90 -0
  88. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
  89. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
  90. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
  91. package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +32 -0
  92. package/lib/esm/components/webchatcontainerstateful/common/utils/fontUtils.js +21 -0
  93. package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +51 -0
  94. package/lib/esm/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
  95. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +115 -0
  96. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +3 -0
  97. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +10 -0
  98. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1060 -0
  99. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +25 -0
  100. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +42 -0
  101. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +13 -0
  102. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  103. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +13 -0
  104. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
  105. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +1 -1
  106. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +52 -0
  107. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -2
  108. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +1 -1
  109. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +98 -30
  110. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
  111. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +46 -45
  112. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
  113. package/lib/esm/contexts/createReducer.js +15 -0
  114. package/lib/esm/index.js +1 -0
  115. package/lib/types/common/Constants.d.ts +5 -0
  116. package/lib/types/common/facades/FacadeChatSDK.d.ts +3 -1
  117. package/lib/types/common/telemetry/TelemetryConstants.d.ts +33 -2
  118. package/lib/types/common/utils/SecureEventBus.d.ts +159 -0
  119. package/lib/types/common/utils/dispatchCustomEvent.d.ts +2 -0
  120. package/lib/types/components/citationpanestateful/CitationDim.d.ts +5 -0
  121. package/lib/types/components/citationpanestateful/CitationPaneStateful.d.ts +4 -0
  122. package/lib/types/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.d.ts +11 -0
  123. package/lib/types/components/citationpanestateful/interfaces/ICitationPaneStatefulProps.d.ts +19 -0
  124. package/lib/types/components/confirmationpanestateful/common/defaultProps/defaultConfirmationPaneLocalizedTexts.d.ts +1 -1
  125. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulProps.d.ts +1 -1
  126. package/lib/types/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.d.ts +45 -0
  127. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +7 -0
  128. package/lib/types/components/livechatwidget/common/PersistentConversationHandler.d.ts +28 -0
  129. package/lib/types/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.d.ts +2 -0
  130. package/lib/types/components/livechatwidget/common/getMockChatSDKIfApplicable.d.ts +2 -1
  131. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +5 -1
  132. package/lib/types/components/livechatwidget/interfaces/IMockProps.d.ts +5 -3
  133. package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +7 -0
  134. package/lib/types/components/webchatcontainerstateful/common/DesignerChatAdapter.d.ts +4 -2
  135. package/lib/types/components/webchatcontainerstateful/common/DesignerChatSDK.d.ts +5 -0
  136. package/lib/types/components/webchatcontainerstateful/common/activities/botActivity.d.ts +7 -0
  137. package/lib/types/components/webchatcontainerstateful/common/activities/conversationDividerActivity.d.ts +10 -0
  138. package/lib/types/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.d.ts +2 -0
  139. package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +6 -1
  140. package/lib/types/components/webchatcontainerstateful/common/utils/fontUtils.d.ts +10 -0
  141. package/lib/types/components/webchatcontainerstateful/hooks/usePersistentChatHistory.d.ts +4 -0
  142. package/lib/types/components/webchatcontainerstateful/interfaces/ICitation.d.ts +12 -0
  143. package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +7 -0
  144. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.d.ts +3 -0
  145. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.d.ts +4 -0
  146. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +326 -0
  147. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.d.ts +8 -0
  148. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -0
  149. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.d.ts +2 -0
  150. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.d.ts +2 -0
  151. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.d.ts +3 -4
  152. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +2 -2
  153. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  154. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +1 -0
  155. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +46 -45
  156. package/lib/types/index.d.ts +1 -0
  157. package/package.json +3 -3
  158. /package/lib/cjs/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
  159. /package/lib/esm/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
  160. /package/lib/types/components/confirmationpanestateful/interfaces/{IConfirmationPaneLocalizedText.d.ts → IConfirmationPaneLocalizedTexts.d.ts} +0 -0
@@ -0,0 +1,188 @@
1
+ import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
+ import React, { useEffect, useState } from "react";
3
+ import { createTimer, findAllFocusableElement, findParentFocusableElementsWithoutChildContainer, preventFocusToMoveOutOfElement, setTabIndices } from "../../common/utils";
4
+ import CitationDim from "./CitationDim";
5
+ import { CitationPane } from "@microsoft/omnichannel-chat-components";
6
+ import { HtmlAttributeNames } from "../../common/Constants";
7
+ import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
8
+ import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
9
+ import { defaultCitationPaneStyles } from "./common/defaultProps/defaultCitationPaneProps";
10
+ import useChatContextStore from "../../hooks/useChatContextStore";
11
+ let uiTimer;
12
+ export const CitationPaneStateful = props => {
13
+ var _props$styleProps3;
14
+ useEffect(() => {
15
+ uiTimer = createTimer();
16
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
17
+ Event: TelemetryEvent.UXCitationPaneStart
18
+ });
19
+ }, []);
20
+ const initialTabIndexMap = new Map();
21
+ let elements = [];
22
+
23
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
+ const [state, dispatch] = useChatContextStore();
25
+
26
+ // Use props.id if provided, otherwise fall back to default
27
+ const controlId = props.id || HtmlAttributeNames.ocwCitationPaneClassName;
28
+
29
+ // Pane style computed to match the webchat widget container bounds so the pane
30
+ // stays within the widget and scrolls only vertically. We also track an
31
+ // "isReady" flag so we don't render the pane contents until the style is
32
+ // computed — this prevents a transient render that can appear as a flicker.
33
+ const [paneStyle, setPaneStyle] = useState(null);
34
+ const [isReady, setIsReady] = useState(false);
35
+
36
+ // Move focus to the container
37
+ useEffect(() => {
38
+ preventFocusToMoveOutOfElement(controlId);
39
+ const focusableElements = findAllFocusableElement(`#${controlId}`);
40
+ requestAnimationFrame(() => {
41
+ if (focusableElements && focusableElements.length > 0 && focusableElements[0]) {
42
+ focusableElements[0].focus({
43
+ preventScroll: true
44
+ });
45
+ }
46
+ });
47
+ elements = findParentFocusableElementsWithoutChildContainer(controlId);
48
+ setTabIndices(elements, initialTabIndexMap, false);
49
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
50
+ Event: TelemetryEvent.CitationPaneLoaded
51
+ });
52
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
53
+ Event: TelemetryEvent.UXCitationPaneCompleted,
54
+ ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
55
+ });
56
+ }, []);
57
+
58
+ // Compute the widget bounds and set pane style accordingly (95% of widget size
59
+ // and centered inside the widget). If the widget container can't be found,
60
+ // fall back to the default pane styles from defaultCitationPaneProps.
61
+ useEffect(() => {
62
+ const compute = () => {
63
+ var _props$styleProps2;
64
+ try {
65
+ const container = document.querySelector(".webchat__stacked-layout_container");
66
+ if (container) {
67
+ var _props$styleProps;
68
+ const rect = container.getBoundingClientRect();
69
+ const widthPx = Math.round(rect.width * 0.95);
70
+ const heightPx = Math.round(rect.height * 0.95);
71
+ const leftPx = Math.round(rect.left + (rect.width - widthPx) / 2);
72
+ const topPx = Math.round(rect.top + (rect.height - heightPx) / 2);
73
+ // Clone defaults and remove transform so explicit left/top pixel
74
+ // coordinates are respected and the pane stays within the
75
+ // widget bounds.
76
+ const base = Object.assign({}, defaultCitationPaneStyles.pane);
77
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
+ if (base && base.transform) {
79
+ // remove centering transform when we compute exact pixel coords
80
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
+ delete base.transform;
82
+ }
83
+
84
+ // Merge user styles first, then computed positioning to ensure proper positioning
85
+ const computedStyle = {
86
+ left: `${leftPx}px`,
87
+ top: `${topPx}px`,
88
+ width: `${widthPx}px`,
89
+ height: `${heightPx}px`
90
+ };
91
+
92
+ // Apply user styles first, then override with computed positioning
93
+ const generalProps = (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyleProps;
94
+ const userStyles = generalProps && typeof generalProps === "object" ? Object.assign({}, generalProps) : {};
95
+ // Remove positioning properties from user styles that would interfere
96
+ delete userStyles.position;
97
+ delete userStyles.left;
98
+ delete userStyles.top;
99
+ delete userStyles.width;
100
+ delete userStyles.height;
101
+ setPaneStyle(Object.assign({}, base, userStyles, computedStyle));
102
+ // Make the pane visible after the next paint to avoid layout
103
+ // flashes on initial mount.
104
+ requestAnimationFrame(() => setIsReady(true));
105
+ return;
106
+ }
107
+ } catch (e) {
108
+ // ignore
109
+ }
110
+
111
+ // fallback - merge defaults with user-provided styles but preserve positioning
112
+ const generalProps = (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.generalStyleProps;
113
+ const userStyles = generalProps && typeof generalProps === "object" ? Object.assign({}, generalProps) : {};
114
+ // Remove positioning properties from user styles for fallback
115
+ delete userStyles.position;
116
+ delete userStyles.left;
117
+ delete userStyles.top;
118
+ delete userStyles.width;
119
+ delete userStyles.height;
120
+ const fallbackStyle = Object.assign({}, defaultCitationPaneStyles.pane, userStyles);
121
+ setPaneStyle(fallbackStyle);
122
+ requestAnimationFrame(() => setIsReady(true));
123
+ };
124
+ compute();
125
+ window.addEventListener("resize", compute);
126
+ return () => window.removeEventListener("resize", compute);
127
+ }, [(_props$styleProps3 = props.styleProps) === null || _props$styleProps3 === void 0 ? void 0 : _props$styleProps3.generalStyleProps]);
128
+ const handleClose = () => {
129
+ if (props.onClose) props.onClose();
130
+ dispatch({
131
+ type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID,
132
+ payload: null
133
+ });
134
+ setTabIndices(elements, initialTabIndexMap, true);
135
+ };
136
+
137
+ // Merge a safe style object for the container and cast to CSSProperties to satisfy TS
138
+ const baseStyle = Object.assign({
139
+ position: "relative"
140
+ }, paneStyle ?? {
141
+ position: "fixed"
142
+ });
143
+
144
+ // If paneStyle hasn't been computed yet, render the DimLayer so clicks
145
+ // still close overlays but hide the pane itself to avoid flashes.
146
+ const hiddenStyle = {
147
+ visibility: isReady ? "visible" : "hidden",
148
+ pointerEvents: isReady ? "auto" : "none"
149
+ };
150
+
151
+ // Default wrapper styles - these control the positioning container
152
+ const defaultWrapperStyles = {
153
+ display: "flex",
154
+ flexDirection: "column",
155
+ zIndex: 10001
156
+ };
157
+
158
+ // Wrapper styles for the positioning container
159
+ const wrapperStyles = Object.assign({}, baseStyle, hiddenStyle, defaultWrapperStyles);
160
+
161
+ // Merge the computed positioning styles with user's generalStyleProps for the CitationPane
162
+ const mergedStyleProps = props.styleProps ? {
163
+ ...props.styleProps,
164
+ generalStyleProps: Object.assign({}, props.styleProps.generalStyleProps)
165
+ } : undefined;
166
+ const controlProps = {
167
+ id: controlId,
168
+ dir: state.domainStates.globalDir,
169
+ titleText: props.title,
170
+ contentHtml: props.contentHtml,
171
+ brightnessValueOnDim: "0.2",
172
+ // Default brightness
173
+ onClose: handleClose,
174
+ ...(props === null || props === void 0 ? void 0 : props.controlProps) // User props override defaults
175
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
176
+ };
177
+
178
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CitationDim, {
179
+ brightness: controlProps.brightnessValueOnDim
180
+ }), /*#__PURE__*/React.createElement("div", {
181
+ style: wrapperStyles
182
+ }, /*#__PURE__*/React.createElement(CitationPane, {
183
+ componentOverrides: props === null || props === void 0 ? void 0 : props.componentOverrides,
184
+ controlProps: controlProps,
185
+ styleProps: mergedStyleProps
186
+ })));
187
+ };
188
+ export default CitationPaneStateful;
@@ -0,0 +1,61 @@
1
+ export const defaultCitationPaneStyles = {
2
+ pane: {
3
+ position: "fixed",
4
+ left: "50%",
5
+ top: "18%",
6
+ transform: "translateX(-50%)",
7
+ background: "#fff",
8
+ width: "85%",
9
+ height: "85%",
10
+ overflowY: "auto",
11
+ overflowX: "hidden",
12
+ padding: 16,
13
+ borderRadius: 6,
14
+ zIndex: 10001,
15
+ boxSizing: "border-box"
16
+ }
17
+ };
18
+ export const defaultCitationContentCSS = controlId => `
19
+ #${controlId} .citation-content {
20
+ flex: 1;
21
+ min-height: 0; /* allow flex child to scroll */
22
+ overflow-y: auto;
23
+ overflow-x: auto;
24
+ margin-bottom: 12px;
25
+ white-space: normal; /* wrap normal text */
26
+ word-break: break-word;
27
+ -webkit-overflow-scrolling: touch;
28
+ }
29
+
30
+ #${controlId} .citation-content pre,
31
+ #${controlId} .citation-content code {
32
+ white-space: pre; /* preserve formatting */
33
+ }
34
+
35
+ #${controlId} .citation-content table {
36
+ width: 100%;
37
+ border-collapse: collapse;
38
+ margin-bottom: 12px;
39
+ table-layout: auto;
40
+ overflow-x: auto;
41
+ display: block;
42
+ }
43
+
44
+ #${controlId} .citation-content table th,
45
+ #${controlId} .citation-content table td {
46
+ padding: 8px 12px;
47
+ border: 1px solid rgba(0,0,0,0.08);
48
+ text-align: left;
49
+ vertical-align: top;
50
+ word-break: break-word;
51
+ }
52
+
53
+ #${controlId} .citation-content img {
54
+ max-width: 100%;
55
+ height: auto;
56
+ }
57
+ `;
58
+ export default {
59
+ defaultCitationPaneStyles,
60
+ defaultCitationContentCSS
61
+ };
@@ -13,13 +13,13 @@ import { isPersistentChatEnabled } from "./common/liveChatConfigUtils";
13
13
  import overridePropsOnMockIfApplicable from "./common/overridePropsOnMockIfApplicable";
14
14
  import { registerTelemetryLoggers } from "./common/registerTelemetryLoggers";
15
15
  export const LiveChatWidget = props => {
16
- var _props$mock, _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv, _props$chatConfig2, _props$chatConfig2$Li;
16
+ var _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv, _props$chatConfig2, _props$chatConfig2$Li;
17
17
  const reducer = createReducer();
18
18
  const [state, dispatch] = useReducer(reducer, getLiveChatWidgetContextInitialState(props));
19
19
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
20
  const [adapter, setAdapter] = useState(undefined);
21
21
  const [facadeChatSDK, setFacadeChatSDK] = useState(undefined);
22
- const chatSDK = getMockChatSDKIfApplicable(props.chatSDK, props === null || props === void 0 ? void 0 : (_props$mock = props.mock) === null || _props$mock === void 0 ? void 0 : _props$mock.type);
22
+ const chatSDK = getMockChatSDKIfApplicable(props.chatSDK, props === null || props === void 0 ? void 0 : props.mock);
23
23
  const disableReauthentication = ((_props$featureConfigP = props.featureConfigProps) === null || _props$featureConfigP === void 0 ? void 0 : _props$featureConfigP.disableReauthentication) === true;
24
24
  overridePropsOnMockIfApplicable(props);
25
25
  if (!props.chatConfig) {
@@ -29,14 +29,14 @@ export const LiveChatWidget = props => {
29
29
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
30
  const isAuthenticatedChat = !!((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction) || isPersistentChatEnabled((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_conversationmode);
31
31
  if (!facadeChatSDK) {
32
- var _props$mock2;
32
+ var _props$mock;
33
33
  setFacadeChatSDK(new FacadeChatSDK({
34
34
  "chatSDK": chatSDK,
35
35
  "chatConfig": props.chatConfig,
36
36
  "isAuthenticated": isAuthenticatedChat,
37
37
  "getAuthToken": props === null || props === void 0 ? void 0 : props.getAuthToken,
38
38
  //when type is not undefined, it means the SDK is mocked
39
- "isSDKMocked": !isNullOrUndefined(props === null || props === void 0 ? void 0 : (_props$mock2 = props.mock) === null || _props$mock2 === void 0 ? void 0 : _props$mock2.type)
39
+ "isSDKMocked": !isNullOrUndefined(props === null || props === void 0 ? void 0 : (_props$mock = props.mock) === null || _props$mock === void 0 ? void 0 : _props$mock.type)
40
40
  }, disableReauthentication));
41
41
  }
42
42
  useEffect(() => {
@@ -0,0 +1,120 @@
1
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ import { BroadcastEvent } from "../../../../common/telemetry/TelemetryConstants";
8
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
9
+ import ChatWidgetEvents from "../ChatWidgetEvents";
10
+ import SecureEventBus from "../../../../common/utils/SecureEventBus";
11
+
12
+ /**
13
+ * The `AddActivitySubscriber` class is responsible for subscribing to the `ADD_ACTIVITY` event
14
+ * from the `ChatWidgetEvents` and notifying an observer when a new activity is added.
15
+ *
16
+ * This class implements the `IActivitySubscriber` interface and acts as a bridge between
17
+ * the event system and the observer pattern.
18
+ */
19
+ export let AddActivitySubscriber = /*#__PURE__*/function () {
20
+ /**
21
+ * The observer that will be notified when a new activity is added.
22
+ * This is expected to be an object with a `next` method, such as an RxJS `Observer`.
23
+ */
24
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
+
26
+ /**
27
+ * Set to track processed activity IDs to prevent duplicate processing.
28
+ */
29
+
30
+ /**
31
+ * Unsubscribe function for the secure event listener
32
+ */
33
+
34
+ /**
35
+ * Subscription for PersistentConversationReset event
36
+ */
37
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
+
39
+ /**
40
+ * Constructor initializes the `AddActivitySubscriber` and sets up a secure event listener
41
+ * for the `ChatWidgetEvents.ADD_ACTIVITY` event. When the event is triggered, it checks
42
+ * if the event payload contains an `activity` and notifies the observer.
43
+ */
44
+ function AddActivitySubscriber() {
45
+ _classCallCheck(this, AddActivitySubscriber);
46
+ _defineProperty(this, "observer", void 0);
47
+ _defineProperty(this, "processedActivityIds", new Set());
48
+ _defineProperty(this, "unsubscribeFromSecureEvent", null);
49
+ _defineProperty(this, "resetEventListener", void 0);
50
+ const eventBus = SecureEventBus.getInstance();
51
+
52
+ // Subscribe to the secure event bus instead of global window events
53
+ this.unsubscribeFromSecureEvent = eventBus.subscribe(ChatWidgetEvents.ADD_ACTIVITY, payload => {
54
+ if (payload !== null && payload !== void 0 && payload.activity) {
55
+ var _this$observer;
56
+ const activity = payload.activity;
57
+ const activityId = activity.id;
58
+ if (activity.identifier) {
59
+ if (this.processedActivityIds.has(activity === null || activity === void 0 ? void 0 : activity.identifier)) {
60
+ return; // Skip processing if already handled
61
+ }
62
+ // Add the activity ID to the processed set
63
+ this.processedActivityIds.add(activity === null || activity === void 0 ? void 0 : activity.identifier);
64
+ }
65
+
66
+ // Check if activity has an ID and if it has already been processed
67
+ if (activityId) {
68
+ if (this.processedActivityIds.has(activityId)) {
69
+ return; // Skip processing if already handled
70
+ }
71
+
72
+ // Add the activity ID to the processed set
73
+ this.processedActivityIds.add(activityId);
74
+ }
75
+
76
+ // Notify the observer with the new activity
77
+ (_this$observer = this.observer) === null || _this$observer === void 0 ? void 0 : _this$observer.next(activity);
78
+ }
79
+ });
80
+
81
+ // Subscribe to reset events for cleanup
82
+ this.resetEventListener = BroadcastService.getMessageByEventName(BroadcastEvent.PersistentConversationReset).subscribe(() => {
83
+ this.reset();
84
+ // Clean up the secure event listener when conversation resets
85
+ if (this.unsubscribeFromSecureEvent) {
86
+ this.unsubscribeFromSecureEvent();
87
+ this.unsubscribeFromSecureEvent = null;
88
+ }
89
+ // Unsubscribe from the reset event to prevent accumulation
90
+ if (this.resetEventListener) {
91
+ this.resetEventListener.unsubscribe();
92
+ }
93
+ });
94
+ }
95
+
96
+ /**
97
+ * The `next` method is a placeholder for processing the activity.
98
+ * This method can be overridden or extended as needed.
99
+ *
100
+ * @param activity - The activity object to process.
101
+ * @returns The activity object (asynchronously).
102
+ */
103
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
104
+ _createClass(AddActivitySubscriber, [{
105
+ key: "next",
106
+ value: async function next(activity) {
107
+ return activity;
108
+ }
109
+
110
+ /**
111
+ * Reset the processed activity IDs when a conversation resets
112
+ */
113
+ }, {
114
+ key: "reset",
115
+ value: function reset() {
116
+ this.processedActivityIds.clear();
117
+ }
118
+ }]);
119
+ return AddActivitySubscriber;
120
+ }();
@@ -13,7 +13,6 @@ import { TelemetryManager } from "../../../../common/telemetry/TelemetryManager"
13
13
  const supportedSignInCardContentTypes = ["application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"];
14
14
  const botOauthUrlRegex = /[\S]+.botframework.com\/api\/oauth\/signin\?signin=([\S]+)/;
15
15
  const delay = t => new Promise(resolve => setTimeout(resolve, t));
16
- let response;
17
16
  const extractSignInId = signInUrl => {
18
17
  const result = botOauthUrlRegex.exec(signInUrl);
19
18
  if (result && result[1]) {
@@ -49,20 +48,20 @@ const fetchBotAuthConfig = async (retries, interval) => {
49
48
  eventName: BroadcastEvent.BotAuthConfigRequest
50
49
  };
51
50
  BroadcastService.postMessage(botAuthConfigRequestEvent);
51
+ let response;
52
52
  const listener = BroadcastService.getMessageByEventName(BroadcastEvent.BotAuthConfigResponse).subscribe(data => {
53
53
  var _data$payload, _data$payload2;
54
54
  response = ((_data$payload = data.payload) === null || _data$payload === void 0 ? void 0 : _data$payload.response) !== undefined ? (_data$payload2 = data.payload) === null || _data$payload2 === void 0 ? void 0 : _data$payload2.response : response;
55
55
  listener.unsubscribe();
56
56
  });
57
- if (response !== undefined) {
58
- //return response;
59
- return response;
60
- }
61
57
  if (retries === 1) {
62
58
  // Base Case
63
59
  throw new Error();
64
60
  }
65
61
  await delay(interval);
62
+ if (response !== undefined) {
63
+ return response;
64
+ }
66
65
  return await fetchBotAuthConfig(--retries, interval);
67
66
  };
68
67
  export let BotAuthActivitySubscriber = /*#__PURE__*/function () {
@@ -0,0 +1,8 @@
1
+ var ChatWidgetEvents;
2
+ (function (ChatWidgetEvents) {
3
+ ChatWidgetEvents["ADD_ACTIVITY"] = "CHAT_WIDGET/ADD_ACTIVITY";
4
+ ChatWidgetEvents["FETCH_PERSISTENT_CHAT_HISTORY"] = "CHAT_WIDGET/FETCH_PERSISTENT_CHAT_HISTORY";
5
+ ChatWidgetEvents["NO_MORE_HISTORY_AVAILABLE"] = "CHAT_WIDGET/NO_MORE_HISTORY_AVAILABLE";
6
+ ChatWidgetEvents["HIDE_LOADING_BANNER"] = "CHAT_WIDGET/HIDE_LOADING_BANNER";
7
+ })(ChatWidgetEvents || (ChatWidgetEvents = {}));
8
+ export default ChatWidgetEvents;