@microsoft/omnichannel-chat-widget 1.8.3-main.ec1328d → 1.8.4-main.4478bbf
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/cjs/common/Constants.js +7 -0
- package/lib/cjs/common/facades/FacadeChatSDK.js +6 -0
- package/lib/cjs/common/telemetry/AppInsightsEvents.js +4 -5
- package/lib/cjs/common/telemetry/TelemetryConstants.js +46 -2
- package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +26 -10
- package/lib/cjs/common/utils/SecureEventBus.js +307 -0
- package/lib/cjs/common/utils/dispatchCustomEvent.js +25 -0
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +16 -4
- package/lib/cjs/components/citationpanestateful/CitationDim.js +29 -0
- package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +199 -0
- package/lib/cjs/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +70 -0
- package/lib/cjs/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
- package/lib/cjs/components/headerstateful/HeaderStateful.js +8 -2
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +4 -4
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +127 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
- package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +15 -0
- package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +284 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +18 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +28 -3
- package/lib/cjs/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +8 -6
- package/lib/cjs/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
- package/lib/cjs/components/livechatwidget/common/startChat.js +10 -5
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +24 -4
- package/lib/cjs/components/livechatwidget/interfaces/IMockProps.js +8 -2
- package/lib/cjs/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +41 -8
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +29 -2
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +12 -3
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +122 -11
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
- package/lib/cjs/components/webchatcontainerstateful/common/activities/botActivity.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +17 -0
- package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +97 -0
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +36 -2
- package/lib/cjs/components/webchatcontainerstateful/common/utils/fontUtils.js +28 -0
- package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +59 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +122 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +10 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +18 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1038 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +34 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +44 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +16 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +20 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +59 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +97 -30
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +46 -45
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
- package/lib/cjs/contexts/createReducer.js +15 -0
- package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
- package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
- package/lib/cjs/index.js +9 -1
- package/lib/cjs/plugins/newMessageEventHandler.js +4 -1
- package/lib/esm/common/Constants.js +7 -0
- package/lib/esm/common/facades/FacadeChatSDK.js +6 -0
- package/lib/esm/common/telemetry/AppInsightsEvents.js +4 -5
- package/lib/esm/common/telemetry/TelemetryConstants.js +44 -1
- package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +27 -11
- package/lib/esm/common/utils/SecureEventBus.js +328 -0
- package/lib/esm/common/utils/dispatchCustomEvent.js +18 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -5
- package/lib/esm/components/citationpanestateful/CitationDim.js +20 -0
- package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +188 -0
- package/lib/esm/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +61 -0
- package/lib/esm/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
- package/lib/esm/components/headerstateful/HeaderStateful.js +9 -3
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +4 -4
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +120 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
- package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +8 -0
- package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +277 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +11 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +29 -4
- package/lib/esm/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +8 -6
- package/lib/esm/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +12 -7
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +23 -4
- package/lib/esm/components/livechatwidget/interfaces/IMockProps.js +3 -3
- package/lib/esm/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +42 -9
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +31 -4
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +13 -4
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +125 -12
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
- package/lib/esm/components/webchatcontainerstateful/common/activities/botActivity.js +7 -0
- package/lib/esm/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +9 -0
- package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +90 -0
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +32 -0
- package/lib/esm/components/webchatcontainerstateful/common/utils/fontUtils.js +21 -0
- package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +51 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +115 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +10 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1060 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +25 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +42 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +13 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +13 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +52 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +3 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +98 -30
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +46 -45
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
- package/lib/esm/contexts/createReducer.js +15 -0
- package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
- package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
- package/lib/esm/index.js +1 -0
- package/lib/esm/plugins/newMessageEventHandler.js +4 -1
- package/lib/types/common/Constants.d.ts +6 -0
- package/lib/types/common/facades/FacadeChatSDK.d.ts +3 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +41 -2
- package/lib/types/common/utils/SecureEventBus.d.ts +159 -0
- package/lib/types/common/utils/dispatchCustomEvent.d.ts +2 -0
- package/lib/types/components/citationpanestateful/CitationDim.d.ts +5 -0
- package/lib/types/components/citationpanestateful/CitationPaneStateful.d.ts +4 -0
- package/lib/types/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.d.ts +11 -0
- package/lib/types/components/citationpanestateful/interfaces/ICitationPaneStatefulProps.d.ts +19 -0
- package/lib/types/components/confirmationpanestateful/common/defaultProps/defaultConfirmationPaneLocalizedTexts.d.ts +1 -1
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulProps.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.d.ts +45 -0
- package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/PersistentConversationHandler.d.ts +28 -0
- package/lib/types/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.d.ts +2 -0
- package/lib/types/components/livechatwidget/common/getMockChatSDKIfApplicable.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +5 -1
- package/lib/types/components/livechatwidget/interfaces/IMockProps.d.ts +5 -3
- package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/common/DesignerChatAdapter.d.ts +4 -2
- package/lib/types/components/webchatcontainerstateful/common/DesignerChatSDK.d.ts +5 -0
- package/lib/types/components/webchatcontainerstateful/common/activities/botActivity.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/common/activities/conversationDividerActivity.d.ts +10 -0
- package/lib/types/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +6 -1
- package/lib/types/components/webchatcontainerstateful/common/utils/fontUtils.d.ts +10 -0
- package/lib/types/components/webchatcontainerstateful/hooks/usePersistentChatHistory.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/ICitation.d.ts +12 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +326 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.d.ts +8 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.d.ts +3 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +2 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +1 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +46 -45
- package/lib/types/index.d.ts +1 -0
- package/package.json +3 -3
- /package/lib/cjs/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
- /package/lib/esm/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
- /package/lib/types/components/confirmationpanestateful/interfaces/{IConfirmationPaneLocalizedText.d.ts → IConfirmationPaneLocalizedTexts.d.ts} +0 -0
|
@@ -0,0 +1,328 @@
|
|
|
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 { TelemetryHelper } from "../telemetry/TelemetryHelper";
|
|
8
|
+
import { LogLevel, TelemetryEvent } from "../telemetry/TelemetryConstants";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* SecureEventBus - A private, authenticated event system for internal chat widget communication
|
|
12
|
+
*
|
|
13
|
+
* This replaces the vulnerable global window event system to prevent external scripts
|
|
14
|
+
* from injecting malicious events into the chat widget.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
19
|
+
* const token = eventBus.getAuthToken();
|
|
20
|
+
*
|
|
21
|
+
* // Subscribe to an event
|
|
22
|
+
* const unsubscribe = eventBus.subscribe('userMessage', (payload) => {
|
|
23
|
+
* console.log('Message received:', payload);
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* // Dispatch an event
|
|
27
|
+
* eventBus.dispatch('userMessage', { text: 'Hello' }, token);
|
|
28
|
+
*
|
|
29
|
+
* // Unsubscribe
|
|
30
|
+
* unsubscribe();
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Interface representing an event listener with callback and unique identifier
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* SecureEventBus class implementing the singleton pattern for secure event communication.
|
|
39
|
+
* Provides authentication-based event dispatching to prevent unauthorized external access.
|
|
40
|
+
*/
|
|
41
|
+
let SecureEventBus = /*#__PURE__*/function () {
|
|
42
|
+
/**
|
|
43
|
+
* Private constructor to enforce singleton pattern.
|
|
44
|
+
* Generates a unique authentication token for this session.
|
|
45
|
+
*/
|
|
46
|
+
function SecureEventBus() {
|
|
47
|
+
_classCallCheck(this, SecureEventBus);
|
|
48
|
+
_defineProperty(this, "listeners", new Map());
|
|
49
|
+
_defineProperty(this, "authToken", void 0);
|
|
50
|
+
_defineProperty(this, "eventCounter", 0);
|
|
51
|
+
// Generate a secure, unique token for this session
|
|
52
|
+
this.authToken = this.generateAuthToken();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Get the singleton instance of SecureEventBus.
|
|
57
|
+
* Creates a new instance if one doesn't exist.
|
|
58
|
+
*
|
|
59
|
+
* @returns The singleton instance of SecureEventBus
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
_createClass(SecureEventBus, [{
|
|
67
|
+
key: "generateAuthToken",
|
|
68
|
+
value:
|
|
69
|
+
/**
|
|
70
|
+
* Generate a cryptographically secure authentication token.
|
|
71
|
+
* Uses crypto.getRandomValues when available, falls back to Math.random.
|
|
72
|
+
*
|
|
73
|
+
* @private
|
|
74
|
+
* @returns A 64-character hexadecimal string representing the authentication token
|
|
75
|
+
*/
|
|
76
|
+
function generateAuthToken() {
|
|
77
|
+
const array = new Uint8Array(32);
|
|
78
|
+
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
79
|
+
crypto.getRandomValues(array);
|
|
80
|
+
} else {
|
|
81
|
+
// Fallback for environments without crypto.getRandomValues
|
|
82
|
+
for (let i = 0; i < array.length; i++) {
|
|
83
|
+
array[i] = Math.floor(Math.random() * 256);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return Array.from(array, byte => byte.toString(16).padStart(2, "0")).join("");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Get the authentication token for this SecureEventBus instance.
|
|
91
|
+
* This token is required for dispatching events and should only be used internally.
|
|
92
|
+
*
|
|
93
|
+
* @returns The authentication token string
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
98
|
+
* const token = eventBus.getAuthToken();
|
|
99
|
+
* eventBus.dispatch('myEvent', { data: 'value' }, token);
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
}, {
|
|
103
|
+
key: "getAuthToken",
|
|
104
|
+
value: function getAuthToken() {
|
|
105
|
+
return this.authToken;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Dispatch an event with authentication to all registered listeners.
|
|
110
|
+
* Verifies the authentication token before dispatching to prevent unauthorized access.
|
|
111
|
+
*
|
|
112
|
+
* @param eventName - The name of the event to dispatch
|
|
113
|
+
* @param payload - The data to send with the event (optional)
|
|
114
|
+
* @param token - Authentication token (must match the internal token)
|
|
115
|
+
* @returns true if event was successfully dispatched, false if unauthorized or error occurred
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
120
|
+
* const token = eventBus.getAuthToken();
|
|
121
|
+
*
|
|
122
|
+
* // Dispatch with payload
|
|
123
|
+
* const success = eventBus.dispatch('userAction', { action: 'click', target: 'button' }, token);
|
|
124
|
+
*
|
|
125
|
+
* // Dispatch without payload
|
|
126
|
+
* eventBus.dispatch('windowClosed', undefined, token);
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
130
|
+
}, {
|
|
131
|
+
key: "dispatch",
|
|
132
|
+
value: function dispatch(eventName, payload, token) {
|
|
133
|
+
// Verify authentication token
|
|
134
|
+
if (token !== this.authToken) {
|
|
135
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
136
|
+
Event: TelemetryEvent.SecureEventBusUnauthorizedDispatch,
|
|
137
|
+
Description: `Unauthorized event dispatch attempt blocked: ${eventName}`,
|
|
138
|
+
ExceptionDetails: {
|
|
139
|
+
eventName,
|
|
140
|
+
providedToken: token ? "provided" : "missing",
|
|
141
|
+
expectedToken: "secured"
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
const listeners = this.listeners.get(eventName);
|
|
147
|
+
if (!listeners || listeners.length === 0) {
|
|
148
|
+
return true; // No listeners, but not an error
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Dispatch to all registered listeners
|
|
152
|
+
try {
|
|
153
|
+
listeners.forEach(listener => {
|
|
154
|
+
try {
|
|
155
|
+
listener.callback(payload);
|
|
156
|
+
} catch (error) {
|
|
157
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
158
|
+
Event: TelemetryEvent.SecureEventBusListenerError,
|
|
159
|
+
Description: `Error in event listener for event: ${eventName}`,
|
|
160
|
+
ExceptionDetails: error
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
return true;
|
|
165
|
+
} catch (error) {
|
|
166
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
167
|
+
Event: TelemetryEvent.SecureEventBusDispatchError,
|
|
168
|
+
Description: `Error dispatching event: ${eventName}`,
|
|
169
|
+
ExceptionDetails: error
|
|
170
|
+
});
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Subscribe to an event with a callback function.
|
|
177
|
+
* The callback will be executed whenever the specified event is dispatched.
|
|
178
|
+
*
|
|
179
|
+
* @param eventName - The name of the event to listen for
|
|
180
|
+
* @param callback - The function to execute when the event is fired
|
|
181
|
+
* @returns A function that can be called to unsubscribe from the event
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```typescript
|
|
185
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
186
|
+
*
|
|
187
|
+
* // Subscribe to an event
|
|
188
|
+
* const unsubscribe = eventBus.subscribe('chatMessage', (message) => {
|
|
189
|
+
* console.log('New message:', message.text);
|
|
190
|
+
* console.log('From user:', message.userId);
|
|
191
|
+
* });
|
|
192
|
+
*
|
|
193
|
+
* // Later, unsubscribe
|
|
194
|
+
* unsubscribe();
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
198
|
+
}, {
|
|
199
|
+
key: "subscribe",
|
|
200
|
+
value: function subscribe(eventName, callback) {
|
|
201
|
+
const listenerId = `listener_${++this.eventCounter}`;
|
|
202
|
+
if (!this.listeners.has(eventName)) {
|
|
203
|
+
this.listeners.set(eventName, []);
|
|
204
|
+
}
|
|
205
|
+
const listeners = this.listeners.get(eventName);
|
|
206
|
+
if (!listeners) {
|
|
207
|
+
throw new Error(`Listeners for event "${eventName}" not found.`);
|
|
208
|
+
}
|
|
209
|
+
const listener = {
|
|
210
|
+
callback,
|
|
211
|
+
id: listenerId
|
|
212
|
+
};
|
|
213
|
+
listeners.push(listener);
|
|
214
|
+
|
|
215
|
+
// Return unsubscribe function
|
|
216
|
+
return () => {
|
|
217
|
+
const currentListeners = this.listeners.get(eventName);
|
|
218
|
+
if (currentListeners) {
|
|
219
|
+
const index = currentListeners.findIndex(l => l.id === listenerId);
|
|
220
|
+
if (index !== -1) {
|
|
221
|
+
currentListeners.splice(index, 1);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Clean up empty listener arrays
|
|
225
|
+
if (currentListeners.length === 0) {
|
|
226
|
+
this.listeners.delete(eventName);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Remove all listeners for a specific event.
|
|
234
|
+
* This completely removes the event from the internal listeners map.
|
|
235
|
+
*
|
|
236
|
+
* @param eventName - The name of the event to remove all listeners for
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```typescript
|
|
240
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
241
|
+
*
|
|
242
|
+
* // Remove all listeners for 'chatClosed' event
|
|
243
|
+
* eventBus.removeAllListeners('chatClosed');
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
}, {
|
|
247
|
+
key: "removeAllListeners",
|
|
248
|
+
value: function removeAllListeners(eventName) {
|
|
249
|
+
this.listeners.delete(eventName);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Clear all listeners for all events.
|
|
254
|
+
* This resets the entire event bus to its initial state.
|
|
255
|
+
* Useful for cleanup during application shutdown or testing.
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```typescript
|
|
259
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
260
|
+
*
|
|
261
|
+
* // Clear all event listeners
|
|
262
|
+
* eventBus.clear();
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
}, {
|
|
266
|
+
key: "clear",
|
|
267
|
+
value: function clear() {
|
|
268
|
+
this.listeners.clear();
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Get the number of listeners for a specific event.
|
|
273
|
+
* Useful for debugging and monitoring purposes.
|
|
274
|
+
*
|
|
275
|
+
* @param eventName - The name of the event to count listeners for
|
|
276
|
+
* @returns The number of listeners registered for the event
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```typescript
|
|
280
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
281
|
+
*
|
|
282
|
+
* // Check how many listeners are registered for 'userAction'
|
|
283
|
+
* const count = eventBus.getListenerCount('userAction');
|
|
284
|
+
* console.log(`${count} listeners registered for userAction`);
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
}, {
|
|
288
|
+
key: "getListenerCount",
|
|
289
|
+
value: function getListenerCount(eventName) {
|
|
290
|
+
var _this$listeners$get;
|
|
291
|
+
return ((_this$listeners$get = this.listeners.get(eventName)) === null || _this$listeners$get === void 0 ? void 0 : _this$listeners$get.length) || 0;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Get all registered event names.
|
|
296
|
+
* Returns an array of event names that currently have listeners.
|
|
297
|
+
* Useful for debugging and monitoring purposes.
|
|
298
|
+
*
|
|
299
|
+
* @returns An array of event names that have registered listeners
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```typescript
|
|
303
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
304
|
+
*
|
|
305
|
+
* // Get all registered events
|
|
306
|
+
* const events = eventBus.getRegisteredEvents();
|
|
307
|
+
* console.log('Active events:', events);
|
|
308
|
+
* // Output: ['userAction', 'chatMessage', 'windowResize']
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
311
|
+
}, {
|
|
312
|
+
key: "getRegisteredEvents",
|
|
313
|
+
value: function getRegisteredEvents() {
|
|
314
|
+
return Array.from(this.listeners.keys());
|
|
315
|
+
}
|
|
316
|
+
}], [{
|
|
317
|
+
key: "getInstance",
|
|
318
|
+
value: function getInstance() {
|
|
319
|
+
if (!SecureEventBus.instance) {
|
|
320
|
+
SecureEventBus.instance = new SecureEventBus();
|
|
321
|
+
}
|
|
322
|
+
return SecureEventBus.instance;
|
|
323
|
+
}
|
|
324
|
+
}]);
|
|
325
|
+
return SecureEventBus;
|
|
326
|
+
}();
|
|
327
|
+
_defineProperty(SecureEventBus, "instance", null);
|
|
328
|
+
export default SecureEventBus;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import SecureEventBus from "./SecureEventBus";
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
+
const dispatchCustomEvent = (name, payload) => {
|
|
5
|
+
try {
|
|
6
|
+
const eventBus = SecureEventBus.getInstance();
|
|
7
|
+
const authToken = eventBus.getAuthToken();
|
|
8
|
+
|
|
9
|
+
// Dispatch through the secure event bus instead of global window
|
|
10
|
+
const success = eventBus.dispatch(name, payload, authToken);
|
|
11
|
+
if (!success) {
|
|
12
|
+
console.error("Failed to dispatch secure event:", name);
|
|
13
|
+
}
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.error("Error dispatching secure custom event:", name, payload, error);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export default dispatchCustomEvent;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
1
|
+
import { ConversationStage, LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import React, { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { createTimer, setFocusOnElement } from "../../common/utils";
|
|
4
4
|
import { ChatButton } from "@microsoft/omnichannel-chat-components";
|
|
@@ -17,7 +17,10 @@ export const ChatButtonStateful = props => {
|
|
|
17
17
|
uiTimer = createTimer();
|
|
18
18
|
TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.INFO, {
|
|
19
19
|
Event: TelemetryEvent.UXLCWChatButtonLoadingStart,
|
|
20
|
-
Description: "Chat button loading started"
|
|
20
|
+
Description: "Chat button loading started",
|
|
21
|
+
CustomProperties: {
|
|
22
|
+
ConversationStage: ConversationStage.Initialization
|
|
23
|
+
}
|
|
21
24
|
});
|
|
22
25
|
}, []);
|
|
23
26
|
|
|
@@ -40,7 +43,10 @@ export const ChatButtonStateful = props => {
|
|
|
40
43
|
ref.current = async () => {
|
|
41
44
|
TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
|
|
42
45
|
Event: TelemetryEvent.LCWChatButtonClicked,
|
|
43
|
-
Description: "Chat button click action started"
|
|
46
|
+
Description: "Chat button click action started",
|
|
47
|
+
CustomProperties: {
|
|
48
|
+
ConversationStage: ConversationStage.Initialization
|
|
49
|
+
}
|
|
44
50
|
});
|
|
45
51
|
if (state.appStates.isMinimized) {
|
|
46
52
|
dispatch({
|
|
@@ -60,7 +66,10 @@ export const ChatButtonStateful = props => {
|
|
|
60
66
|
}
|
|
61
67
|
TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
|
|
62
68
|
Event: TelemetryEvent.LCWChatButtonActionCompleted,
|
|
63
|
-
Description: "Chat button action completed"
|
|
69
|
+
Description: "Chat button action completed",
|
|
70
|
+
CustomProperties: {
|
|
71
|
+
ConversationStage: ConversationStage.Initialization
|
|
72
|
+
}
|
|
64
73
|
});
|
|
65
74
|
};
|
|
66
75
|
const outOfOfficeStyleProps = Object.assign({}, defaultOutOfOfficeChatButtonStyleProps, outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.styleProps);
|
|
@@ -114,7 +123,10 @@ export const ChatButtonStateful = props => {
|
|
|
114
123
|
TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.INFO, {
|
|
115
124
|
Event: TelemetryEvent.UXLCWChatButtonLoadingCompleted,
|
|
116
125
|
Description: "Chat button loading completed",
|
|
117
|
-
ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
|
|
126
|
+
ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed,
|
|
127
|
+
CustomProperties: {
|
|
128
|
+
ConversationStage: ConversationStage.Initialization
|
|
129
|
+
}
|
|
118
130
|
});
|
|
119
131
|
}, []);
|
|
120
132
|
useEffect(() => {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import ReactDOM from "react-dom";
|
|
3
|
+
import { DimLayer } from "../dimlayer/DimLayer";
|
|
4
|
+
const CONTAINER_SELECTOR = ".webchat__stacked-layout_container";
|
|
5
|
+
export const CitationDim = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
brightness = "0.2"
|
|
8
|
+
} = _ref;
|
|
9
|
+
const container = document.querySelector(CONTAINER_SELECTOR);
|
|
10
|
+
if (!container) return null;
|
|
11
|
+
return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement("div", {
|
|
12
|
+
style: {
|
|
13
|
+
position: "absolute",
|
|
14
|
+
inset: 0
|
|
15
|
+
}
|
|
16
|
+
}, /*#__PURE__*/React.createElement(DimLayer, {
|
|
17
|
+
brightness: brightness
|
|
18
|
+
})), container);
|
|
19
|
+
};
|
|
20
|
+
export default CitationDim;
|
|
@@ -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;
|
package/lib/esm/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js
ADDED
|
@@ -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
|
+
};
|
package/lib/esm/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|