@microsoft/omnichannel-chat-widget 1.8.4-main.cbab5fc → 1.8.4-main.cc63f01
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/README.md +13 -3
- package/lib/cjs/common/Constants.js +5 -0
- package/lib/cjs/common/facades/FacadeChatSDK.js +235 -9
- package/lib/cjs/common/telemetry/TelemetryConstants.js +14 -0
- package/lib/cjs/common/telemetry/TelemetryManager.js +6 -1
- package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +7 -7
- package/lib/cjs/common/telemetry/sanitizeSasInPayload.js +82 -0
- package/lib/cjs/common/utils/xssUtils.js +23 -51
- package/lib/cjs/common/utils.js +106 -17
- package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +8 -1
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -1
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +36 -13
- package/lib/cjs/components/errorboundary/ErrorBoundary.js +2 -1
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +9 -1
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +23 -6
- package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
- package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +9 -0
- package/lib/cjs/components/livechatwidget/common/authHelper.js +44 -4
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +3 -2
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +98 -5
- package/lib/cjs/components/livechatwidget/common/endChat.js +6 -0
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +186 -1
- package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +36 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +31 -14
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +124 -5
- package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +15 -3
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +7 -4
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +68 -2
- package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +2 -1
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +0 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +157 -34
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +10 -0
- package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +117 -16
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -0
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +5 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/common/utils/citationA11y.js +195 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +13 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +160 -167
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +27 -8
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +203 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +8 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -13
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +81 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +29 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +52 -8
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +55 -1
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +17 -1
- package/lib/cjs/contexts/createReducer.js +15 -0
- package/lib/cjs/controller/componentController.js +13 -1
- package/lib/cjs/plugins/newMessageEventHandler.js +20 -3
- package/lib/esm/common/Constants.js +5 -0
- package/lib/esm/common/facades/FacadeChatSDK.js +236 -10
- package/lib/esm/common/telemetry/TelemetryConstants.js +14 -0
- package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
- package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +7 -7
- package/lib/esm/common/telemetry/sanitizeSasInPayload.js +75 -0
- package/lib/esm/common/utils/xssUtils.js +23 -51
- package/lib/esm/common/utils.js +99 -14
- package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +8 -1
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -1
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +37 -14
- package/lib/esm/components/errorboundary/ErrorBoundary.js +4 -2
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +9 -1
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +23 -6
- package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
- package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +9 -0
- package/lib/esm/components/livechatwidget/common/authHelper.js +44 -4
- package/lib/esm/components/livechatwidget/common/createAdapter.js +3 -2
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +98 -5
- package/lib/esm/components/livechatwidget/common/endChat.js +6 -0
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +186 -1
- package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +33 -2
- package/lib/esm/components/livechatwidget/common/startChat.js +31 -14
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +125 -6
- package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +16 -4
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +7 -4
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +69 -3
- package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +2 -1
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -2
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +158 -35
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +10 -0
- package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +117 -16
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +5 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
- package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/utils/citationA11y.js +188 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +13 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +160 -171
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +24 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +195 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +8 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -13
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +74 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +29 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +52 -8
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +55 -1
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +17 -1
- package/lib/esm/contexts/createReducer.js +15 -0
- package/lib/esm/controller/componentController.js +13 -1
- package/lib/esm/plugins/newMessageEventHandler.js +20 -3
- package/lib/types/common/Constants.d.ts +4 -0
- package/lib/types/common/facades/FacadeChatSDK.d.ts +29 -0
- package/lib/types/common/facades/types/IFacadeChatSDKInput.d.ts +3 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +14 -2
- package/lib/types/common/telemetry/sanitizeSasInPayload.d.ts +24 -0
- package/lib/types/common/utils/xssUtils.d.ts +5 -21
- package/lib/types/common/utils.d.ts +12 -2
- package/lib/types/components/errorboundary/ErrorBoundary.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +9 -2
- package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +11 -0
- package/lib/types/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/common/utils/citationA11y.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotAuthConfig.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +14 -38
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.d.ts +18 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.d.ts +12 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.d.ts +7 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +17 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/package.json +37 -9
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
9
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
10
|
+
/******
|
|
11
|
+
* AdaptiveCardAccessibilityWrapper
|
|
12
|
+
*
|
|
13
|
+
* The `adaptivecards` renderer does not set `aria-setsize` or `aria-posinset`
|
|
14
|
+
* on radio buttons rendered by Input.ChoiceSet (style: "expanded"). Without
|
|
15
|
+
* these attributes, screen readers (TalkBack, VoiceOver, NVDA) cannot announce
|
|
16
|
+
* the correct option count (e.g. "1 of 2") and may say "1 of 1" for every item.
|
|
17
|
+
*
|
|
18
|
+
* This wrapper observes the rendered card via MutationObserver and patches each
|
|
19
|
+
* radio group with the correct ARIA attributes after the card finishes rendering.
|
|
20
|
+
******/
|
|
21
|
+
|
|
22
|
+
const AdaptiveCardAccessibilityWrapper = _ref => {
|
|
23
|
+
let {
|
|
24
|
+
id,
|
|
25
|
+
style,
|
|
26
|
+
children
|
|
27
|
+
} = _ref;
|
|
28
|
+
const containerRef = (0, _react.useRef)(null);
|
|
29
|
+
(0, _react.useEffect)(() => {
|
|
30
|
+
if (!containerRef.current) return;
|
|
31
|
+
const patchRadioGroups = () => {
|
|
32
|
+
const container = containerRef.current;
|
|
33
|
+
if (!container) return;
|
|
34
|
+
|
|
35
|
+
// dropdown-double-label: compact Input.ChoiceSet renders as a native
|
|
36
|
+
// <select> with both aria-labelledby and a sibling visible <label for>.
|
|
37
|
+
// Only remove aria-labelledby when it points solely at that same visible
|
|
38
|
+
// label; preserve composite labels that include required/error/context text.
|
|
39
|
+
const compactSelects = container.querySelectorAll(".ac-input-container select.ac-input.ac-multichoiceInput[aria-labelledby]");
|
|
40
|
+
compactSelects.forEach(select => {
|
|
41
|
+
const id = select.id;
|
|
42
|
+
if (!id) return;
|
|
43
|
+
const visibleLabel = container.querySelector(`label[for="${CSS.escape(id)}"]:not([aria-hidden='true'])`);
|
|
44
|
+
const labelledBy = (select.getAttribute("aria-labelledby") || "").trim().split(/\s+/);
|
|
45
|
+
if (visibleLabel !== null && visibleLabel !== void 0 && visibleLabel.id && labelledBy.length === 1 && labelledBy[0] === visibleLabel.id) {
|
|
46
|
+
select.removeAttribute("aria-labelledby");
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// internal tracking: non-radio inputs (Input.Text including
|
|
51
|
+
// isMultiline=true which renders as <textarea>, Input.Date,
|
|
52
|
+
// Input.Number, Input.Toggle, Input.ChoiceSet multi-select
|
|
53
|
+
// checkbox) rendered by adaptivecards can have THREE accessible-
|
|
54
|
+
// name sources resolving to the same string: a visible
|
|
55
|
+
// <label for>, aria-label, AND aria-labelledby. TalkBack walks
|
|
56
|
+
// each accessibility node independently and reads the duplicated
|
|
57
|
+
// name. When a visible <label for> exists and names the control,
|
|
58
|
+
// strip the redundant aria-label / aria-labelledby on the input
|
|
59
|
+
// so only one announceable source remains.
|
|
60
|
+
const labelledInputs = container.querySelectorAll(".ac-input-container input.ac-input[id]:not([type='radio']), .ac-input-container textarea.ac-input[id]");
|
|
61
|
+
labelledInputs.forEach(input => {
|
|
62
|
+
const id = input.id;
|
|
63
|
+
if (!id) return;
|
|
64
|
+
const visibleLabel = container.querySelector(`label[for="${CSS.escape(id)}"]:not([aria-hidden='true'])`);
|
|
65
|
+
if (!visibleLabel) return;
|
|
66
|
+
const labelText = (visibleLabel.textContent || "").trim();
|
|
67
|
+
if (!labelText) return;
|
|
68
|
+
const ariaLabel = input.getAttribute("aria-label");
|
|
69
|
+
if (ariaLabel && ariaLabel.trim() === labelText) {
|
|
70
|
+
input.removeAttribute("aria-label");
|
|
71
|
+
}
|
|
72
|
+
const labelledBy = (input.getAttribute("aria-labelledby") || "").trim();
|
|
73
|
+
if (labelledBy) {
|
|
74
|
+
const ids = labelledBy.split(/\s+/);
|
|
75
|
+
const resolved = ids.map(rid => {
|
|
76
|
+
var _document$getElementB;
|
|
77
|
+
return (((_document$getElementB = document.getElementById(rid)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.textContent) || "").trim();
|
|
78
|
+
}).filter(Boolean).join(" ");
|
|
79
|
+
if (resolved === labelText) {
|
|
80
|
+
input.removeAttribute("aria-labelledby");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// action-button-toggle / login-button-toggle: submit/login action buttons can be
|
|
86
|
+
// rendered with toggle-only ARIA that causes screen readers to announce them as
|
|
87
|
+
// switches instead of plain push buttons. Preserve Action.ToggleVisibility buttons,
|
|
88
|
+
// which own aria-controls and legitimately expose a pressed state.
|
|
89
|
+
const actionButtons = container.querySelectorAll(".ac-actionSet button.ac-pushButton:not([aria-controls])");
|
|
90
|
+
actionButtons.forEach(btn => {
|
|
91
|
+
if (btn.hasAttribute("aria-pressed")) {
|
|
92
|
+
btn.removeAttribute("aria-pressed");
|
|
93
|
+
}
|
|
94
|
+
const role = btn.getAttribute("role");
|
|
95
|
+
if (role === "switch") {
|
|
96
|
+
btn.removeAttribute("role");
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Find all radio inputs inside the adaptive card
|
|
101
|
+
const radios = container.querySelectorAll("input[type='radio']");
|
|
102
|
+
if (radios.length === 0) return;
|
|
103
|
+
|
|
104
|
+
// Group radios by their name attribute (each ChoiceSet has a unique name)
|
|
105
|
+
const groups = new Map();
|
|
106
|
+
radios.forEach(radio => {
|
|
107
|
+
var _groups$get;
|
|
108
|
+
const name = radio.getAttribute("name") || "__default";
|
|
109
|
+
if (!groups.has(name)) {
|
|
110
|
+
groups.set(name, []);
|
|
111
|
+
}
|
|
112
|
+
(_groups$get = groups.get(name)) === null || _groups$get === void 0 ? void 0 : _groups$get.push(radio);
|
|
113
|
+
});
|
|
114
|
+
groups.forEach(radioInputs => {
|
|
115
|
+
const groupSize = radioInputs.length;
|
|
116
|
+
radioInputs.forEach((radio, index) => {
|
|
117
|
+
radio.setAttribute("aria-setsize", String(groupSize));
|
|
118
|
+
radio.setAttribute("aria-posinset", String(index + 1));
|
|
119
|
+
|
|
120
|
+
// Ensure the parent container has radiogroup role
|
|
121
|
+
const parent = radio.closest("[role='radiogroup']") || radio.closest(".ac-input-container");
|
|
122
|
+
if (parent && !parent.getAttribute("role")) {
|
|
123
|
+
parent.setAttribute("role", "radiogroup");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// The adaptive card renders each choice as:
|
|
127
|
+
// <div style="display:flex"> ← flex wrapper
|
|
128
|
+
// <input type="radio">
|
|
129
|
+
// <div style="width:6px"></div> ← spacer
|
|
130
|
+
// <label><div><p>Text</p></div></label>
|
|
131
|
+
// </div>
|
|
132
|
+
//
|
|
133
|
+
// TalkBack focuses on the <label> text node (just "Standard")
|
|
134
|
+
// instead of the <input>, so it never announces "radio button" or count.
|
|
135
|
+
//
|
|
136
|
+
// Fix: hide the label and spacer from the accessibility tree so TalkBack
|
|
137
|
+
// lands directly on the <input> which already has aria-label,
|
|
138
|
+
// aria-setsize and aria-posinset. The input's aria-labelledby still
|
|
139
|
+
// resolves the accessible name from the hidden label per ARIA spec.
|
|
140
|
+
const flexWrapper = radio.parentElement;
|
|
141
|
+
if (flexWrapper) {
|
|
142
|
+
var _label$textContent;
|
|
143
|
+
// Hide label sibling — only set if not already applied to
|
|
144
|
+
// avoid re-triggering the attributeFilter observer in a loop
|
|
145
|
+
const label = flexWrapper.querySelector("label");
|
|
146
|
+
if (label && label.getAttribute("aria-hidden") !== "true") {
|
|
147
|
+
label.setAttribute("aria-hidden", "true");
|
|
148
|
+
}
|
|
149
|
+
// Hide spacer siblings (any non-input, non-label divs)
|
|
150
|
+
Array.from(flexWrapper.children).forEach(child => {
|
|
151
|
+
const tag = child.tagName.toLowerCase();
|
|
152
|
+
if (tag !== "input" && tag !== "label" && child.getAttribute("aria-hidden") !== "true") {
|
|
153
|
+
child.setAttribute("aria-hidden", "true");
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// TalkBack reads content-desc from the Android accessibility node,
|
|
158
|
+
// which Chrome populates from aria-label. However, aria-labelledby
|
|
159
|
+
// (set by the adaptive card renderer) takes precedence over aria-label.
|
|
160
|
+
// Since we hide the label (aria-hidden=true), Chrome can no longer
|
|
161
|
+
// resolve aria-labelledby and returns empty content-desc.
|
|
162
|
+
//
|
|
163
|
+
// Fix: remove aria-labelledby so Chrome falls back to aria-label,
|
|
164
|
+
// then encode the position count into aria-label so TalkBack announces
|
|
165
|
+
// e.g. "Standard, 1 of 2, radio button, not checked".
|
|
166
|
+
if (radio.hasAttribute("aria-labelledby")) {
|
|
167
|
+
radio.removeAttribute("aria-labelledby");
|
|
168
|
+
}
|
|
169
|
+
const labelText = (label === null || label === void 0 ? void 0 : (_label$textContent = label.textContent) === null || _label$textContent === void 0 ? void 0 : _label$textContent.trim()) || radio.getAttribute("aria-label") || "";
|
|
170
|
+
const expectedLabel = `${labelText}, ${index + 1} of ${groupSize}`;
|
|
171
|
+
if (radio.getAttribute("aria-label") !== expectedLabel) {
|
|
172
|
+
radio.setAttribute("aria-label", expectedLabel);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// Use MutationObserver to patch after WebChat finishes rendering the card.
|
|
180
|
+
// Also watch attribute changes on aria-hidden so we can re-apply if React
|
|
181
|
+
// reconciliation removes it from labels.
|
|
182
|
+
const observer = new MutationObserver(() => {
|
|
183
|
+
patchRadioGroups();
|
|
184
|
+
});
|
|
185
|
+
observer.observe(containerRef.current, {
|
|
186
|
+
childList: true,
|
|
187
|
+
subtree: true,
|
|
188
|
+
attributes: true,
|
|
189
|
+
attributeFilter: ["aria-hidden"]
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// Also run immediately in case the card is already rendered
|
|
193
|
+
patchRadioGroups();
|
|
194
|
+
return () => observer.disconnect();
|
|
195
|
+
}, []);
|
|
196
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
197
|
+
id: id,
|
|
198
|
+
style: style,
|
|
199
|
+
ref: containerRef
|
|
200
|
+
}, children);
|
|
201
|
+
};
|
|
202
|
+
var _default = AdaptiveCardAccessibilityWrapper;
|
|
203
|
+
exports.default = _default;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.defaultAvatarTextStyles = void 0;
|
|
7
7
|
const defaultAvatarTextStyles = {
|
|
8
8
|
margin: "0",
|
|
9
|
-
fontFamily: "'Segoe UI',
|
|
9
|
+
fontFamily: "'Segoe UI', Arial, sans-serif",
|
|
10
10
|
fontWeight: 600,
|
|
11
11
|
fontSize: "13px",
|
|
12
12
|
lineHeight: "18px",
|
|
@@ -11,8 +11,13 @@ const defaultSystemMessageStyles = {
|
|
|
11
11
|
fontSize: "12px",
|
|
12
12
|
borderRadius: 0,
|
|
13
13
|
minHeight: "auto",
|
|
14
|
-
fontFamily: "'Segoe UI',
|
|
15
|
-
lineHeight: "
|
|
16
|
-
padding: "0px 10px 0 10px"
|
|
14
|
+
fontFamily: "'Segoe UI', Arial, sans-serif",
|
|
15
|
+
lineHeight: "1.4",
|
|
16
|
+
padding: "0px 10px 0 10px",
|
|
17
|
+
// iOS Safari: position underlines below all glyphs so they do not
|
|
18
|
+
// intersect numbers. Also enforce lining figures for consistent baselines.
|
|
19
|
+
WebkitTextUnderlinePosition: "under",
|
|
20
|
+
textUnderlinePosition: "under",
|
|
21
|
+
fontVariantNumeric: "lining-nums"
|
|
17
22
|
};
|
|
18
23
|
exports.defaultSystemMessageStyles = defaultSystemMessageStyles;
|
|
@@ -8,6 +8,13 @@ var _defaultTimestampContentStyles = require("./defaultTimestampContentStyles");
|
|
|
8
8
|
const defaultTimestampRetryStyles = {
|
|
9
9
|
..._defaultTimestampContentStyles.defaultTimestampContentStyles,
|
|
10
10
|
color: "#0063B1",
|
|
11
|
-
cursor: "pointer"
|
|
11
|
+
cursor: "pointer",
|
|
12
|
+
border: "none",
|
|
13
|
+
padding: 0,
|
|
14
|
+
margin: 0,
|
|
15
|
+
textDecoration: "none",
|
|
16
|
+
display: "inline",
|
|
17
|
+
fontWeight: "inherit",
|
|
18
|
+
textAlign: "inherit"
|
|
12
19
|
};
|
|
13
20
|
exports.defaultTimestampRetryStyles = defaultTimestampRetryStyles;
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.NotDeliveredTimestamp = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _KeyCodes = require("../../../../../../common/KeyCodes");
|
|
9
8
|
var _react2 = require("@fluentui/react");
|
|
10
9
|
var _defaultMiddlewareLocalizedTexts = require("../../../../common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
11
10
|
var _defaultTimestampContentStyles = require("../defaultStyles/defaultTimestampContentStyles");
|
|
@@ -17,6 +16,8 @@ var _useChatContextStore = _interopRequireDefault(require("../../../../../../hoo
|
|
|
17
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
20
|
+
|
|
20
21
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
22
|
const NotDeliveredTimestamp = _ref => {
|
|
22
23
|
var _state$domainStates$r, _state$domainStates$r2, _state$domainStates$r3, _state$domainStates$r4, _state$domainStates$m, _state$domainStates$m2;
|
|
@@ -63,24 +64,15 @@ const NotDeliveredTimestamp = _ref => {
|
|
|
63
64
|
await postActivity(activity);
|
|
64
65
|
focus("sendBox");
|
|
65
66
|
}, [activity, focus, postActivity]);
|
|
66
|
-
const onRetryKeyEnter = event => {
|
|
67
|
-
if (event.code === _KeyCodes.KeyCodes.ENTER) {
|
|
68
|
-
event.preventDefault();
|
|
69
|
-
onRetryClick();
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
67
|
return /*#__PURE__*/_react.default.createElement(_react2.Stack, {
|
|
73
68
|
style: contentStyles,
|
|
74
69
|
dir: dir,
|
|
75
70
|
horizontal: true
|
|
76
71
|
}, /*#__PURE__*/_react.default.createElement("span", null, " ", (0, _utils.getTimestampHourMinute)(timestamp)), /*#__PURE__*/_react.default.createElement("span", null, " \xA0-\xA0 "), /*#__PURE__*/_react.default.createElement("span", {
|
|
77
72
|
style: failedTextStyles
|
|
78
|
-
}, " ", ((_state$domainStates$m = state.domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_MESSAGE_NOT_DELIVERED) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_MESSAGE_NOT_DELIVERED, " "), /*#__PURE__*/_react.default.createElement("span", null, " \xA0-\xA0 "), /*#__PURE__*/_react.default.createElement("
|
|
73
|
+
}, " ", ((_state$domainStates$m = state.domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_MESSAGE_NOT_DELIVERED) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_MESSAGE_NOT_DELIVERED, " "), /*#__PURE__*/_react.default.createElement("span", null, " \xA0-\xA0 "), /*#__PURE__*/_react.default.createElement("button", {
|
|
79
74
|
style: retryTextStyles,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
onKeyDown: onRetryKeyEnter,
|
|
83
|
-
tabIndex: 0
|
|
84
|
-
}, " ", ((_state$domainStates$m2 = state.domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m2 === void 0 ? void 0 : _state$domainStates$m2.MIDDLEWARE_MESSAGE_RETRY) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_MESSAGE_RETRY, " "));
|
|
75
|
+
onClick: onRetryClick
|
|
76
|
+
}, ((_state$domainStates$m2 = state.domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m2 === void 0 ? void 0 : _state$domainStates$m2.MIDDLEWARE_MESSAGE_RETRY) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_MESSAGE_RETRY));
|
|
85
77
|
};
|
|
86
78
|
exports.NotDeliveredTimestamp = NotDeliveredTimestamp;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _WebChatActionType = require("../../enums/WebChatActionType");
|
|
8
|
+
/******
|
|
9
|
+
* AttachmentSentAnnouncementMiddleware
|
|
10
|
+
*
|
|
11
|
+
* When a file attachment is successfully sent, announces the result to
|
|
12
|
+
* screen readers via an aria-live region so that assistive technology
|
|
13
|
+
* users receive immediate feedback.
|
|
14
|
+
******/
|
|
15
|
+
|
|
16
|
+
const ARIA_LIVE_REGION_ID = "oc-lcw-attachment-announcement";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Ensures a visually-hidden aria-live region exists in the DOM for
|
|
20
|
+
* announcing attachment upload results to screen readers.
|
|
21
|
+
*/
|
|
22
|
+
const ensureAriaLiveRegion = () => {
|
|
23
|
+
let region = document.getElementById(ARIA_LIVE_REGION_ID);
|
|
24
|
+
if (!region) {
|
|
25
|
+
region = document.createElement("div");
|
|
26
|
+
region.id = ARIA_LIVE_REGION_ID;
|
|
27
|
+
region.setAttribute("aria-live", "polite");
|
|
28
|
+
region.setAttribute("role", "status");
|
|
29
|
+
region.setAttribute("aria-atomic", "true");
|
|
30
|
+
// Visually hidden but available to screen readers
|
|
31
|
+
Object.assign(region.style, {
|
|
32
|
+
position: "absolute",
|
|
33
|
+
width: "1px",
|
|
34
|
+
height: "1px",
|
|
35
|
+
padding: "0",
|
|
36
|
+
margin: "-1px",
|
|
37
|
+
overflow: "hidden",
|
|
38
|
+
clip: "rect(0, 0, 0, 0)",
|
|
39
|
+
whiteSpace: "nowrap",
|
|
40
|
+
border: "0"
|
|
41
|
+
});
|
|
42
|
+
const container = document.getElementById("oc-lcw-container");
|
|
43
|
+
(container || document.body).appendChild(region);
|
|
44
|
+
}
|
|
45
|
+
return region;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Announces a message to screen readers by updating the aria-live region.
|
|
50
|
+
* Clears it briefly first so repeated identical messages are still announced.
|
|
51
|
+
*/
|
|
52
|
+
const announce = message => {
|
|
53
|
+
const region = ensureAriaLiveRegion();
|
|
54
|
+
region.textContent = "";
|
|
55
|
+
// Small delay so the screen reader detects the content change
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
region.textContent = message;
|
|
58
|
+
}, 100);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
62
|
+
const attachmentSentAnnouncementMiddleware = _ref => {
|
|
63
|
+
let {
|
|
64
|
+
dispatch
|
|
65
|
+
} = _ref;
|
|
66
|
+
return next => action => {
|
|
67
|
+
// Intercept successfully posted activities that contain attachments
|
|
68
|
+
if ((action === null || action === void 0 ? void 0 : action.type) === _WebChatActionType.WebChatActionType.DIRECT_LINE_POST_ACTIVITY_FULFILLED) {
|
|
69
|
+
var _action$payload, _action$payload$activ;
|
|
70
|
+
const attachments = action === null || action === void 0 ? void 0 : (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : (_action$payload$activ = _action$payload.activity) === null || _action$payload$activ === void 0 ? void 0 : _action$payload$activ.attachments;
|
|
71
|
+
if (attachments && attachments.length > 0) {
|
|
72
|
+
const count = attachments.length;
|
|
73
|
+
const message = count === 1 ? "File sent" : `${count} files sent`;
|
|
74
|
+
announce(message);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return next(action);
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
var _default = attachmentSentAnnouncementMiddleware;
|
|
81
|
+
exports.default = _default;
|
|
@@ -17,6 +17,27 @@ var _WebChatActionType = require("../../enums/WebChatActionType");
|
|
|
17
17
|
******/
|
|
18
18
|
|
|
19
19
|
const MBtoBRatio = 1000000;
|
|
20
|
+
const announceFileSent = message => {
|
|
21
|
+
// TalkBack on Android WebView reliably announces newly *appended*
|
|
22
|
+
// role="alert" nodes but often misses text-content updates on existing
|
|
23
|
+
// nodes. Wait 500ms for the send-box focus shift to settle, then inject
|
|
24
|
+
// a fresh alert element appended to document.body and remove it after 3s.
|
|
25
|
+
setTimeout(() => {
|
|
26
|
+
const el = document.createElement("div");
|
|
27
|
+
el.setAttribute("role", "alert");
|
|
28
|
+
el.setAttribute("aria-live", "assertive");
|
|
29
|
+
el.setAttribute("aria-atomic", "true");
|
|
30
|
+
el.style.cssText = "position:absolute;left:-9999px;top:auto;width:1px;height:1px;overflow:hidden;";
|
|
31
|
+
el.textContent = message;
|
|
32
|
+
document.body.appendChild(el);
|
|
33
|
+
// Remove after TalkBack has had time to read it
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
if (el.parentNode) {
|
|
36
|
+
el.parentNode.removeChild(el);
|
|
37
|
+
}
|
|
38
|
+
}, 3000);
|
|
39
|
+
}, 500);
|
|
40
|
+
};
|
|
20
41
|
|
|
21
42
|
/*
|
|
22
43
|
* If an attachment is invalid, delete this attachment from the attachments list
|
|
@@ -206,7 +227,14 @@ const createAttachmentUploadValidatorMiddleware = (allowedFileExtensions, maxFil
|
|
|
206
227
|
payload
|
|
207
228
|
} = action;
|
|
208
229
|
if (payload !== null && payload !== void 0 && payload.activity.attachments && payload.activity.attachments.length > 0 && (payload === null || payload === void 0 ? void 0 : (_payload$activity = payload.activity) === null || _payload$activity === void 0 ? void 0 : (_payload$activity$att = _payload$activity.attachments) === null || _payload$activity$att === void 0 ? void 0 : _payload$activity$att.length) === (payload === null || payload === void 0 ? void 0 : (_payload$activity2 = payload.activity) === null || _payload$activity2 === void 0 ? void 0 : (_payload$activity2$ch = _payload$activity2.channelData) === null || _payload$activity2$ch === void 0 ? void 0 : (_payload$activity2$ch2 = _payload$activity2$ch.attachmentSizes) === null || _payload$activity2$ch2 === void 0 ? void 0 : _payload$activity2$ch2.length)) {
|
|
209
|
-
|
|
230
|
+
var _validatedAction$payl, _validatedAction$payl2, _validatedAction$payl3;
|
|
231
|
+
const validatedAction = validateAttachment(action, allowedFileExtensions, maxFileSizeSupportedByDynamics, localizedTexts);
|
|
232
|
+
|
|
233
|
+
// Announce to screen readers that the file was sent when validation passes
|
|
234
|
+
if (((_validatedAction$payl = validatedAction.payload) === null || _validatedAction$payl === void 0 ? void 0 : (_validatedAction$payl2 = _validatedAction$payl.activity) === null || _validatedAction$payl2 === void 0 ? void 0 : (_validatedAction$payl3 = _validatedAction$payl2.attachments) === null || _validatedAction$payl3 === void 0 ? void 0 : _validatedAction$payl3.length) > 0) {
|
|
235
|
+
announceFileSent(localizedTexts.MIDDLEWARE_BANNER_FILE_SENT ?? "File sent successfully.");
|
|
236
|
+
}
|
|
237
|
+
return next(validatedAction);
|
|
210
238
|
}
|
|
211
239
|
}
|
|
212
240
|
return next(action);
|
|
@@ -12,9 +12,36 @@ var _utils = require("../../../../../common/utils");
|
|
|
12
12
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
13
13
|
|
|
14
14
|
let currentAgentInitials = _defaultWebChatStyles.defaultWebChatStyles.botAvatarInitials;
|
|
15
|
+
let currentAgentName = _defaultWebChatStyles.defaultWebChatStyles.botAvatarInitials;
|
|
15
16
|
|
|
16
17
|
// Optional external updater (React context dispatch wrapper) set at runtime
|
|
17
18
|
let externalInitialsUpdater;
|
|
19
|
+
const hasTransferTag = activity => {
|
|
20
|
+
var _activity$channelData;
|
|
21
|
+
const tags = [...(Array.isArray(activity === null || activity === void 0 ? void 0 : (_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 ? void 0 : _activity$channelData.tags) ? activity.channelData.tags : []), ...(Array.isArray(activity === null || activity === void 0 ? void 0 : activity.tags) ? activity.tags : [])];
|
|
22
|
+
return tags.some(tag => typeof tag === "string" && tag.toLowerCase().includes("transfer"));
|
|
23
|
+
};
|
|
24
|
+
const isTransferSystemMessage = activity => {
|
|
25
|
+
const text = ((activity === null || activity === void 0 ? void 0 : activity.text) || "").toString();
|
|
26
|
+
return hasTransferTag(activity) || /\btransfer(?:red|ring)?\b/i.test(text);
|
|
27
|
+
};
|
|
28
|
+
const resetCachedAgentName = dispatch => {
|
|
29
|
+
if (currentAgentName !== _defaultWebChatStyles.defaultWebChatStyles.botAvatarInitials || currentAgentInitials !== _defaultWebChatStyles.defaultWebChatStyles.botAvatarInitials) {
|
|
30
|
+
var _externalInitialsUpda;
|
|
31
|
+
currentAgentName = _defaultWebChatStyles.defaultWebChatStyles.botAvatarInitials;
|
|
32
|
+
currentAgentInitials = _defaultWebChatStyles.defaultWebChatStyles.botAvatarInitials;
|
|
33
|
+
(_externalInitialsUpda = externalInitialsUpdater) === null || _externalInitialsUpda === void 0 ? void 0 : _externalInitialsUpda(currentAgentInitials || "");
|
|
34
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
35
|
+
eventName: "BotAvatarInitialsUpdated",
|
|
36
|
+
payload: {
|
|
37
|
+
initials: currentAgentInitials
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
dispatch({
|
|
41
|
+
type: "__BOT_INITIALS_UPDATED__"
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
18
45
|
const localizedStringsBotInitialsMiddleware = onInitialsChange => _ref => {
|
|
19
46
|
let {
|
|
20
47
|
dispatch
|
|
@@ -28,16 +55,31 @@ const localizedStringsBotInitialsMiddleware = onInitialsChange => _ref => {
|
|
|
28
55
|
var _action$payload, _activity$from;
|
|
29
56
|
const activity = (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : _action$payload.activity;
|
|
30
57
|
if (activity !== null && activity !== void 0 && (_activity$from = activity.from) !== null && _activity$from !== void 0 && _activity$from.name && activity.from.role !== _Constants.Constants.userMessageTag && activity.from.name !== _Constants.Constants.userMessageTag) {
|
|
31
|
-
var _activity$
|
|
58
|
+
var _activity$channelData2, _activity$channelData3, _activity$tags;
|
|
32
59
|
const agentName = activity.from.name.trim();
|
|
33
|
-
const isSystemMessage = agentName === "__agent__" || agentName.startsWith("__") || ((_activity$
|
|
34
|
-
if (
|
|
60
|
+
const isSystemMessage = agentName === "__agent__" || agentName.startsWith("__") || ((_activity$channelData2 = activity.channelData) === null || _activity$channelData2 === void 0 ? void 0 : (_activity$channelData3 = _activity$channelData2.tags) === null || _activity$channelData3 === void 0 ? void 0 : _activity$channelData3.includes(_Constants.Constants.systemMessageTag)) || ((_activity$tags = activity.tags) === null || _activity$tags === void 0 ? void 0 : _activity$tags.includes(_Constants.Constants.systemMessageTag));
|
|
61
|
+
if (isSystemMessage) {
|
|
62
|
+
// transfer-stale-bot-name: when a transfer system message indicates the
|
|
63
|
+
// conversation has been routed to a different agent, the
|
|
64
|
+
// previously-cached agent name must NOT linger. Otherwise the
|
|
65
|
+
// next non-system activity (e.g. typing indicator, welcome
|
|
66
|
+
// message, or the new agent's first turn before their name
|
|
67
|
+
// is observed) is announced to screen readers as the OLD
|
|
68
|
+
// agent. Reset to defaults so the next observed name takes
|
|
69
|
+
// effect cleanly.
|
|
70
|
+
if (isTransferSystemMessage(activity)) {
|
|
71
|
+
resetCachedAgentName(dispatch);
|
|
72
|
+
}
|
|
73
|
+
} else if (agentName) {
|
|
35
74
|
const newInitials = (0, _utils.getIconText)(agentName) || currentAgentInitials;
|
|
36
|
-
|
|
37
|
-
|
|
75
|
+
const hasInitialsChanged = newInitials !== currentAgentInitials;
|
|
76
|
+
const hasNameChanged = agentName !== currentAgentName;
|
|
77
|
+
currentAgentName = agentName;
|
|
78
|
+
if (hasInitialsChanged) {
|
|
79
|
+
var _externalInitialsUpda2;
|
|
38
80
|
currentAgentInitials = newInitials;
|
|
39
81
|
// Notify external React context if provided
|
|
40
|
-
(
|
|
82
|
+
(_externalInitialsUpda2 = externalInitialsUpdater) === null || _externalInitialsUpda2 === void 0 ? void 0 : _externalInitialsUpda2(currentAgentInitials || "");
|
|
41
83
|
// Broadcast (optional) for multi-tab sync without forcing consumers
|
|
42
84
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
43
85
|
eventName: "BotAvatarInitialsUpdated",
|
|
@@ -45,6 +87,8 @@ const localizedStringsBotInitialsMiddleware = onInitialsChange => _ref => {
|
|
|
45
87
|
initials: currentAgentInitials
|
|
46
88
|
}
|
|
47
89
|
});
|
|
90
|
+
}
|
|
91
|
+
if (hasInitialsChanged || hasNameChanged) {
|
|
48
92
|
// Also dispatch a no-op action into WebChat store to encourage re-render (cheap)
|
|
49
93
|
dispatch({
|
|
50
94
|
type: "__BOT_INITIALS_UPDATED__"
|
|
@@ -65,10 +109,10 @@ const getOverriddenLocalizedStrings = existingOverrides => {
|
|
|
65
109
|
};
|
|
66
110
|
// Apply dynamic bot initials to alt text if not already overridden through props
|
|
67
111
|
if (!(existingOverrides !== null && existingOverrides !== void 0 && existingOverrides.ACTIVITY_BOT_SAID_ALT)) {
|
|
68
|
-
result.ACTIVITY_BOT_SAID_ALT = `${
|
|
112
|
+
result.ACTIVITY_BOT_SAID_ALT = `${currentAgentName} said:`;
|
|
69
113
|
}
|
|
70
114
|
if (!(existingOverrides !== null && existingOverrides !== void 0 && existingOverrides.ACTIVITY_BOT_ATTACHED_ALT)) {
|
|
71
|
-
result.ACTIVITY_BOT_ATTACHED_ALT = `${
|
|
115
|
+
result.ACTIVITY_BOT_ATTACHED_ALT = `${currentAgentName} attached:`;
|
|
72
116
|
}
|
|
73
117
|
return result;
|
|
74
118
|
};
|
|
@@ -14,8 +14,11 @@ var _TelemetryConstants = require("../../../../common/telemetry/TelemetryConstan
|
|
|
14
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
15
|
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); } }
|
|
16
16
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
17
|
+
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; }
|
|
17
18
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
18
19
|
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); }
|
|
20
|
+
const LIVE_REGION_ID = "oc-lcw-notification-live-region";
|
|
21
|
+
const LIVE_REGION_CLEAR_DELAY_MS = 1000;
|
|
19
22
|
let NotificationHandler = /*#__PURE__*/function () {
|
|
20
23
|
function NotificationHandler() {
|
|
21
24
|
_classCallCheck(this, NotificationHandler);
|
|
@@ -32,9 +35,59 @@ let NotificationHandler = /*#__PURE__*/function () {
|
|
|
32
35
|
message
|
|
33
36
|
}
|
|
34
37
|
});
|
|
38
|
+
NotificationHandler.announceToScreenReader(message);
|
|
35
39
|
NotificationHandler.setFocusOnNotificationCloseButton();
|
|
36
40
|
}
|
|
37
41
|
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Announces a message immediately to screen readers via an aria-live="assertive" region.
|
|
45
|
+
* This ensures notifications interrupt the current screen reader output
|
|
46
|
+
* instead of waiting for it to finish reading other content.
|
|
47
|
+
*/
|
|
48
|
+
}, {
|
|
49
|
+
key: "announceToScreenReader",
|
|
50
|
+
value: function announceToScreenReader(message) {
|
|
51
|
+
let liveRegion = document.getElementById(LIVE_REGION_ID);
|
|
52
|
+
if (!liveRegion) {
|
|
53
|
+
liveRegion = document.createElement("div");
|
|
54
|
+
liveRegion.id = LIVE_REGION_ID;
|
|
55
|
+
liveRegion.setAttribute("aria-live", "assertive");
|
|
56
|
+
liveRegion.setAttribute("role", "alert");
|
|
57
|
+
liveRegion.setAttribute("aria-atomic", "true");
|
|
58
|
+
// Visually hidden but accessible to screen readers
|
|
59
|
+
liveRegion.style.position = "absolute";
|
|
60
|
+
liveRegion.style.width = "1px";
|
|
61
|
+
liveRegion.style.height = "1px";
|
|
62
|
+
liveRegion.style.overflow = "hidden";
|
|
63
|
+
liveRegion.style.clip = "rect(0 0 0 0)";
|
|
64
|
+
liveRegion.style.clipPath = "inset(50%)";
|
|
65
|
+
liveRegion.style.whiteSpace = "nowrap";
|
|
66
|
+
const widgetContainer = document.getElementById(_Constants.HtmlIdNames.MSLiveChatWidget);
|
|
67
|
+
(widgetContainer || document.body).appendChild(liveRegion);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Clear first, then set after a microtask so the browser detects the change
|
|
71
|
+
// even when the same message is announced consecutively.
|
|
72
|
+
liveRegion.textContent = "";
|
|
73
|
+
requestAnimationFrame(() => {
|
|
74
|
+
if (liveRegion) {
|
|
75
|
+
liveRegion.textContent = message;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Cancel any previous clear timer to avoid prematurely clearing a newer message
|
|
80
|
+
if (NotificationHandler.clearTimeoutId) {
|
|
81
|
+
clearTimeout(NotificationHandler.clearTimeoutId);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Clear the live region after a delay so repeated identical messages still trigger
|
|
85
|
+
NotificationHandler.clearTimeoutId = setTimeout(() => {
|
|
86
|
+
if (liveRegion) {
|
|
87
|
+
liveRegion.textContent = "";
|
|
88
|
+
}
|
|
89
|
+
}, LIVE_REGION_CLEAR_DELAY_MS);
|
|
90
|
+
}
|
|
38
91
|
}, {
|
|
39
92
|
key: "dismissNotification",
|
|
40
93
|
value: function dismissNotification(id) {
|
|
@@ -109,4 +162,5 @@ let NotificationHandler = /*#__PURE__*/function () {
|
|
|
109
162
|
}]);
|
|
110
163
|
return NotificationHandler;
|
|
111
164
|
}();
|
|
112
|
-
exports.NotificationHandler = NotificationHandler;
|
|
165
|
+
exports.NotificationHandler = NotificationHandler;
|
|
166
|
+
_defineProperty(NotificationHandler, "clearTimeoutId", void 0);
|
|
@@ -57,4 +57,5 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
|
|
|
57
57
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATIONAL_SURVEY_DISPLAY"] = 47] = "SET_CONVERSATIONAL_SURVEY_DISPLAY";
|
|
58
58
|
LiveChatWidgetActionType[LiveChatWidgetActionType["GET_IN_MEMORY_STATE"] = 48] = "GET_IN_MEMORY_STATE";
|
|
59
59
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_AVATAR_INITIALS"] = 49] = "SET_BOT_AVATAR_INITIALS";
|
|
60
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_USER_AUTHENTICATED"] = 50] = "SET_USER_AUTHENTICATED";
|
|
60
61
|
})(LiveChatWidgetActionType || (exports.LiveChatWidgetActionType = LiveChatWidgetActionType = {}));
|
|
@@ -44,6 +44,21 @@ const getLiveChatWidgetContextInitialState = props => {
|
|
|
44
44
|
if (!initialStateFromCache.domainStates.botAvatarInitials) {
|
|
45
45
|
initialStateFromCache.domainStates.botAvatarInitials = _defaultWebChatStyles.defaultWebChatStyles.botAvatarInitials;
|
|
46
46
|
}
|
|
47
|
+
// Default isUserAuthenticated to false if not present in cache
|
|
48
|
+
if (initialStateFromCache.appStates.isUserAuthenticated === undefined) {
|
|
49
|
+
initialStateFromCache.appStates.isUserAuthenticated = false;
|
|
50
|
+
}
|
|
51
|
+
// internal tracking: transient modal pane visibility must NOT survive a page
|
|
52
|
+
// reload. If `showConfirmationPane` / `showEmailTranscriptPane` are
|
|
53
|
+
// restored as `true`, the corresponding pane re-mounts and installs
|
|
54
|
+
// its focus trap (and sets sibling tabindex=-1). The user has no
|
|
55
|
+
// context for why the modal appeared and Tab from the host page can
|
|
56
|
+
// no longer traverse out of the widget. Always start cold for these
|
|
57
|
+
// ephemeral UI flags.
|
|
58
|
+
if (initialStateFromCache.uiStates) {
|
|
59
|
+
initialStateFromCache.uiStates.showConfirmationPane = false;
|
|
60
|
+
initialStateFromCache.uiStates.showEmailTranscriptPane = false;
|
|
61
|
+
}
|
|
47
62
|
return initialStateFromCache;
|
|
48
63
|
}
|
|
49
64
|
const LiveChatWidgetContextInitialState = {
|
|
@@ -93,7 +108,8 @@ const getLiveChatWidgetContextInitialState = props => {
|
|
|
93
108
|
selectedSurveyMode: null,
|
|
94
109
|
postChatParticipantType: undefined,
|
|
95
110
|
isConversationalSurvey: false,
|
|
96
|
-
isConversationalSurveyEnabled: false
|
|
111
|
+
isConversationalSurveyEnabled: false,
|
|
112
|
+
isUserAuthenticated: false
|
|
97
113
|
},
|
|
98
114
|
uiStates: {
|
|
99
115
|
showConfirmationPane: false,
|