@microsoft/omnichannel-chat-widget 2.0.1-main.84e2c02 → 2.0.1-main.a610fd8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +57 -0
  2. package/lib/cjs/common/telemetry/TelemetryConstants.js +6 -0
  3. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +42 -25
  4. package/lib/cjs/components/livechatwidget/common/endChat.js +39 -0
  5. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +33 -9
  6. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +29 -1
  7. package/lib/cjs/components/livechatwidget/common/startChat.js +118 -36
  8. package/lib/cjs/components/livechatwidget/common/updateSessionDataForTelemetry.js +34 -5
  9. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +5 -17
  10. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
  11. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentForScreenReaderMiddleware.js +159 -0
  12. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +16 -2
  13. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +68 -40
  14. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +0 -27
  15. package/lib/esm/common/telemetry/TelemetryConstants.js +6 -0
  16. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +42 -25
  17. package/lib/esm/components/livechatwidget/common/endChat.js +39 -0
  18. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +31 -9
  19. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +28 -1
  20. package/lib/esm/components/livechatwidget/common/startChat.js +115 -34
  21. package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +34 -5
  22. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +6 -18
  23. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
  24. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentForScreenReaderMiddleware.js +153 -0
  25. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +16 -2
  26. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +65 -39
  27. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +0 -27
  28. package/lib/types/common/telemetry/TelemetryConstants.d.ts +3 -0
  29. package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +8 -0
  30. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +6 -1
  31. package/lib/types/components/livechatwidget/common/startChat.d.ts +5 -1
  32. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentForScreenReaderMiddleware.d.ts +11 -0
  33. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.d.ts +11 -4
  34. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +9 -2
  35. package/package.json +5 -6
@@ -0,0 +1,153 @@
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
+ /* eslint-disable @typescript-eslint/no-explicit-any */
8
+ /******
9
+ * AttachmentForScreenReaderMiddleware
10
+ *
11
+ * Web Chat reads an Adaptive Card to screen readers only from the card's `speak` property.
12
+ * A card without `speak` is announced as "A card" with no content.
13
+ * This middleware sets `speak` from the visible text of the card, then lets Web Chat render it as usual.
14
+ ******/
15
+
16
+ import React, { useMemo } from "react";
17
+ import { Constants } from "../../../../../common/Constants";
18
+ import { hooks } from "botframework-webchat";
19
+ const useAdaptiveCardsPackage = hooks.useAdaptiveCardsPackage,
20
+ useStyleOptions = hooks.useStyleOptions;
21
+ const ADAPTIVE_CARD_CONTENT_TYPE = "application/vnd.microsoft.card.adaptive";
22
+ const HTML_BLOCK_END = /<\/(p|li|h[1-6]|div|tr|td|th|blockquote|pre)>|<br\s*\/?>/gi;
23
+ // The "opens in a new window" icon of each link is left out: it describes the link target, not the content of the message.
24
+ const htmlToText = html => {
25
+ const body = new DOMParser().parseFromString(html.replace(HTML_BLOCK_END, "$& "), "text/html").body;
26
+ body.querySelectorAll(`script, style, template, img.${Constants.OpenLinkIconCssClass}`).forEach(element => element.remove());
27
+ body.querySelectorAll("img").forEach(image => image.replaceWith(` ${image.getAttribute("alt") ?? ""} `));
28
+ return (body.textContent ?? "").replace(/\s+/g, " ").trim();
29
+ };
30
+
31
+ // Renders the element as the visible card does: Adaptive Cards formats {{DATE()}} and {{TIME()}}, then the Markdown is rendered.
32
+ // Web Chat sets the static Markdown handler before each visible render, and this restores the previous handler after rendering.
33
+ const getRenderedText = (element, AdaptiveCard, renderMarkdownAsHTML) => {
34
+ const previousOnProcessMarkdown = AdaptiveCard.onProcessMarkdown;
35
+ try {
36
+ AdaptiveCard.onProcessMarkdown = (text, result) => {
37
+ result.outputHtml = renderMarkdownAsHTML(text);
38
+ result.didProcess = true;
39
+ };
40
+ const renderedElement = element.render();
41
+ return renderedElement ? htmlToText(renderedElement.outerHTML) : "";
42
+ } catch {
43
+ var _element$asString;
44
+ return ((_element$asString = element.asString) === null || _element$asString === void 0 ? void 0 : _element$asString.call(element)) ?? "";
45
+ } finally {
46
+ AdaptiveCard.onProcessMarkdown = previousOnProcessMarkdown;
47
+ }
48
+ };
49
+
50
+ // Collects the visible text of the card in document order, after the parser has applied element fallbacks.
51
+ // Inputs and actions are not collected because Web Chat already lists them after the card text.
52
+ export const getAdaptiveCardSpeak = (content, adaptiveCardsPackage, renderMarkdownAsHTML, adaptiveCardsParserMaxVersion) => {
53
+ const AdaptiveCard = adaptiveCardsPackage.AdaptiveCard,
54
+ FactSet = adaptiveCardsPackage.FactSet,
55
+ Image = adaptiveCardsPackage.Image,
56
+ RichTextBlock = adaptiveCardsPackage.RichTextBlock,
57
+ SerializationContext = adaptiveCardsPackage.SerializationContext,
58
+ TextBlock = adaptiveCardsPackage.TextBlock,
59
+ Version = adaptiveCardsPackage.Version;
60
+ const maxVersion = adaptiveCardsParserMaxVersion ? Version.parse(adaptiveCardsParserMaxVersion, new SerializationContext()) : undefined;
61
+ const card = new AdaptiveCard();
62
+ const texts = [];
63
+ card.parse(content, new SerializationContext(maxVersion !== null && maxVersion !== void 0 && maxVersion.isValid ? maxVersion : undefined));
64
+ const getFactText = (factSet, text) => {
65
+ const textBlock = new TextBlock(text);
66
+ textBlock.setParent(factSet);
67
+ return getRenderedText(textBlock, AdaptiveCard, renderMarkdownAsHTML);
68
+ };
69
+ const walk = element => {
70
+ if (!(element !== null && element !== void 0 && element.isVisible)) {
71
+ return;
72
+ }
73
+ if (element instanceof TextBlock || element instanceof RichTextBlock) {
74
+ texts.push(getRenderedText(element, AdaptiveCard, renderMarkdownAsHTML));
75
+ } else if (element instanceof FactSet) {
76
+ element.facts.forEach(_ref => {
77
+ let name = _ref.name,
78
+ value = _ref.value;
79
+ texts.push([name, value].map(text => text ? getFactText(element, text) : "").filter(Boolean).join(": "));
80
+ });
81
+ } else if (element instanceof Image) {
82
+ texts.push(element.altText);
83
+ }
84
+ if (element.getItemAt && element.getItemCount) {
85
+ for (let index = 0, count = element.getItemCount(); index < count; index++) {
86
+ walk(element.getItemAt(index));
87
+ }
88
+ }
89
+ };
90
+ walk(card);
91
+ return texts.filter(text => typeof text === "string" && text).join(" ").replace(/\s+/g, " ").trim();
92
+ };
93
+ const AdaptiveCardForScreenReader = _ref2 => {
94
+ let args = _ref2.args,
95
+ next = _ref2.next,
96
+ renderMarkdownAsHTML = _ref2.renderMarkdownAsHTML;
97
+ const _useAdaptiveCardsPack = useAdaptiveCardsPackage(),
98
+ _useAdaptiveCardsPack2 = _slicedToArray(_useAdaptiveCardsPack, 1),
99
+ adaptiveCardsPackage = _useAdaptiveCardsPack2[0];
100
+ const _useStyleOptions = useStyleOptions(),
101
+ _useStyleOptions2 = _slicedToArray(_useStyleOptions, 1),
102
+ adaptiveCardsParserMaxVersion = _useStyleOptions2[0].adaptiveCardsParserMaxVersion;
103
+ const _args = _slicedToArray(args, 1),
104
+ options = _args[0];
105
+ const attachment = options.attachment;
106
+
107
+ // The widget creates a new Markdown renderer on each render with the same settings, so the text is computed once for each attachment.
108
+ const contentWithSpeak = useMemo(() => {
109
+ try {
110
+ const content = typeof attachment.content === "string" ? JSON.parse(attachment.content) : attachment.content;
111
+ if (!content || typeof content !== "object" || content.speak) {
112
+ return undefined;
113
+ }
114
+ const speak = getAdaptiveCardSpeak(content, adaptiveCardsPackage, renderMarkdownAsHTML, adaptiveCardsParserMaxVersion);
115
+ return speak ? {
116
+ ...content,
117
+ speak
118
+ } : undefined;
119
+ } catch {
120
+ return undefined;
121
+ }
122
+ }, [adaptiveCardsPackage, adaptiveCardsParserMaxVersion, attachment]);
123
+ const render = contentWithSpeak ? next({
124
+ ...options,
125
+ attachment: {
126
+ ...attachment,
127
+ content: contentWithSpeak
128
+ }
129
+ }, ...args.slice(1)) : next(...args);
130
+ return typeof render === "function" ? render() : null;
131
+ };
132
+ export const createAttachmentForScreenReaderMiddleware = renderMarkdownAsHTML => {
133
+ const attachmentForScreenReaderMiddleware = () => next => function () {
134
+ var _args$;
135
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
136
+ args[_key] = arguments[_key];
137
+ }
138
+ const attachment = (_args$ = args[0]) === null || _args$ === void 0 ? void 0 : _args$.attachment;
139
+
140
+ // Web Chat renders nothing for a card without content, so it is left to Web Chat.
141
+ if ((attachment === null || attachment === void 0 ? void 0 : attachment.contentType) !== ADAPTIVE_CARD_CONTENT_TYPE || !attachment.content) {
142
+ return next(...args);
143
+ }
144
+
145
+ // eslint-disable-next-line react/display-name
146
+ return () => /*#__PURE__*/React.createElement(AdaptiveCardForScreenReader, {
147
+ args: args,
148
+ next: next,
149
+ renderMarkdownAsHTML: renderMarkdownAsHTML
150
+ });
151
+ };
152
+ return attachmentForScreenReaderMiddleware;
153
+ };
@@ -88,6 +88,19 @@ const AdaptiveCardAccessibilityWrapper = _ref => {
88
88
  }
89
89
  });
90
90
 
91
+ // action-button-double-read: the adaptivecards renderer writes the action
92
+ // title to the button text, aria-label AND title. The title becomes the
93
+ // accessible description, so TalkBack reads the label twice ("Submit,
94
+ // button, Submit"). Drop the title only when it repeats the button name;
95
+ // a distinct title (an action tooltip) adds information and is kept.
96
+ container.querySelectorAll("button[title]").forEach(btn => {
97
+ const title = (btn.getAttribute("title") || "").trim();
98
+ const name = (btn.getAttribute("aria-label") ?? btn.textContent ?? "").trim();
99
+ if (title && title === name) {
100
+ btn.removeAttribute("title");
101
+ }
102
+ });
103
+
91
104
  // Find all radio inputs inside the adaptive card
92
105
  const radios = container.querySelectorAll("input[type='radio']");
93
106
  if (radios.length === 0) return;
@@ -169,7 +182,8 @@ const AdaptiveCardAccessibilityWrapper = _ref => {
169
182
 
170
183
  // Use MutationObserver to patch after WebChat finishes rendering the card.
171
184
  // Also watch attribute changes on aria-hidden so we can re-apply if React
172
- // reconciliation removes it from labels.
185
+ // reconciliation removes it from labels, and on title so a re-added
186
+ // duplicate button title is removed again.
173
187
  const observer = new MutationObserver(() => {
174
188
  patchRadioGroups();
175
189
  });
@@ -177,7 +191,7 @@ const AdaptiveCardAccessibilityWrapper = _ref => {
177
191
  childList: true,
178
192
  subtree: true,
179
193
  attributes: true,
180
- attributeFilter: ["aria-hidden"]
194
+ attributeFilter: ["aria-hidden", "title"]
181
195
  });
182
196
 
183
197
  // Also run immediately in case the card is already rendered
@@ -2,26 +2,36 @@
2
2
  * AttachmentSentAnnouncementMiddleware
3
3
  *
4
4
  * When a file attachment is successfully sent, announces the result to
5
- * screen readers via an aria-live region so that assistive technology
6
- * users receive immediate feedback.
5
+ * screen readers so that assistive technology users receive immediate
6
+ * feedback ("File report.pdf sent").
7
+ *
8
+ * The announcement region lives inside the chat dialog. While the dialog is
9
+ * open it is aria-modal and its host siblings are aria-hidden, so screen
10
+ * readers (TalkBack, VoiceOver) ignore live regions outside it.
7
11
  ******/
8
12
 
9
13
  import { isWebChatAction } from "../../../interfaces/IWebChatAction";
10
14
  import { WebChatActionType } from "../../enums/WebChatActionType";
11
- const ARIA_LIVE_REGION_ID = "oc-lcw-attachment-announcement";
15
+ export const ATTACHMENT_ANNOUNCEMENT_REGION_ID = "oc-lcw-attachment-announcement";
16
+ const DEFAULT_FILE_SENT_TEXT = "File {2} sent";
17
+ const DEFAULT_FILES_SENT_TEXT = "{0} files sent";
18
+
19
+ // Let the send-box focus shift settle before speaking, then keep the node
20
+ // long enough for the screen reader to read it.
21
+ const ANNOUNCE_DELAY_MS = 100;
22
+ const ANNOUNCEMENT_LIFETIME_MS = 5000;
12
23
 
13
24
  /**
14
- * Ensures a visually-hidden aria-live region exists in the DOM for
15
- * announcing attachment upload results to screen readers.
25
+ * Ensures a visually-hidden aria-live region exists inside the chat dialog
26
+ * for announcing attachment upload results to screen readers.
16
27
  */
17
- const ensureAriaLiveRegion = () => {
18
- let region = document.getElementById(ARIA_LIVE_REGION_ID);
28
+ const ensureAriaLiveRegion = widgetElementId => {
29
+ const host = document.getElementById(widgetElementId) || document.body;
30
+ let region = document.getElementById(ATTACHMENT_ANNOUNCEMENT_REGION_ID);
19
31
  if (!region) {
20
32
  region = document.createElement("div");
21
- region.id = ARIA_LIVE_REGION_ID;
33
+ region.id = ATTACHMENT_ANNOUNCEMENT_REGION_ID;
22
34
  region.setAttribute("aria-live", "polite");
23
- region.setAttribute("role", "status");
24
- region.setAttribute("aria-atomic", "true");
25
35
  // Visually hidden but available to screen readers
26
36
  Object.assign(region.style, {
27
37
  position: "absolute",
@@ -34,44 +44,60 @@ const ensureAriaLiveRegion = () => {
34
44
  whiteSpace: "nowrap",
35
45
  border: "0"
36
46
  });
37
- const container = document.getElementById("oc-lcw-container");
38
- (container || document.body).appendChild(region);
47
+ }
48
+ if (region.parentElement !== host) {
49
+ host.appendChild(region);
39
50
  }
40
51
  return region;
41
52
  };
42
53
 
43
54
  /**
44
- * Announces a message to screen readers by updating the aria-live region.
45
- * Clears it briefly first so repeated identical messages are still announced.
55
+ * Announces a message by appending a fresh node to the live region.
56
+ * TalkBack reliably speaks newly added nodes but often misses text changes
57
+ * on an existing node, so each announcement gets its own element.
46
58
  */
47
- const announce = message => {
48
- const region = ensureAriaLiveRegion();
49
- region.textContent = "";
50
- // Small delay so the screen reader detects the content change
59
+ const announce = (message, widgetElementId) => {
60
+ const region = ensureAriaLiveRegion(widgetElementId);
51
61
  setTimeout(() => {
52
- region.textContent = message;
53
- }, 100);
62
+ const node = document.createElement("div");
63
+ node.textContent = message;
64
+ region.appendChild(node);
65
+ setTimeout(() => node.remove(), ANNOUNCEMENT_LIFETIME_MS);
66
+ }, ANNOUNCE_DELAY_MS);
54
67
  };
55
68
 
56
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
57
- const attachmentSentAnnouncementMiddleware = _ref => {
58
- let dispatch = _ref.dispatch;
59
- return next => action => {
60
- if (!isWebChatAction(action)) {
61
- return next(action);
62
- }
69
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
+ export const getFileSentMessage = (attachments, localizedTexts) => {
71
+ var _attachments$;
72
+ if (attachments.length > 1) {
73
+ // Replacer callbacks insert values literally; a string would treat "$&" or "$$" as patterns.
74
+ return ((localizedTexts === null || localizedTexts === void 0 ? void 0 : localizedTexts.MIDDLEWARE_BANNER_FILES_SENT) || DEFAULT_FILES_SENT_TEXT).replace("{0}", () => String(attachments.length));
75
+ }
76
+ const name = typeof ((_attachments$ = attachments[0]) === null || _attachments$ === void 0 ? void 0 : _attachments$.name) === "string" ? attachments[0].name.trim() : "";
77
+ return ((localizedTexts === null || localizedTexts === void 0 ? void 0 : localizedTexts.MIDDLEWARE_BANNER_FILE_SENT) || DEFAULT_FILE_SENT_TEXT).replace("{2}", () => name).replace(/\s{2,}/g, " ").trim();
78
+ };
79
+ export const createAttachmentSentAnnouncementMiddleware = function (localizedTexts) {
80
+ let widgetElementId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "oc-lcw";
81
+ return (
82
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
83
+ _ref => {
84
+ let dispatch = _ref.dispatch;
85
+ return next => action => {
86
+ if (!isWebChatAction(action)) {
87
+ return next(action);
88
+ }
63
89
 
64
- // Intercept successfully posted activities that contain attachments
65
- if (action.type === WebChatActionType.DIRECT_LINE_POST_ACTIVITY_FULFILLED) {
66
- var _action$payload;
67
- const attachments = (_action$payload = action.payload) === null || _action$payload === void 0 || (_action$payload = _action$payload.activity) === null || _action$payload === void 0 ? void 0 : _action$payload.attachments;
68
- if (attachments && attachments.length > 0) {
69
- const count = attachments.length;
70
- const message = count === 1 ? "File sent" : `${count} files sent`;
71
- announce(message);
72
- }
90
+ // Intercept successfully posted activities that contain attachments
91
+ if (action.type === WebChatActionType.DIRECT_LINE_POST_ACTIVITY_FULFILLED) {
92
+ var _action$payload;
93
+ const attachments = (_action$payload = action.payload) === null || _action$payload === void 0 || (_action$payload = _action$payload.activity) === null || _action$payload === void 0 ? void 0 : _action$payload.attachments;
94
+ if (attachments && attachments.length > 0) {
95
+ announce(getFileSentMessage(attachments, localizedTexts), widgetElementId);
96
+ }
97
+ }
98
+ return next(action);
99
+ };
73
100
  }
74
- return next(action);
75
- };
101
+ );
76
102
  };
77
- export default attachmentSentAnnouncementMiddleware;
103
+ export default createAttachmentSentAnnouncementMiddleware;
@@ -12,27 +12,6 @@ import { NotificationScenarios } from "../../enums/NotificationScenarios";
12
12
  import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
13
13
  import { WebChatActionType } from "../../enums/WebChatActionType";
14
14
  const MBtoBRatio = 1000000;
15
- const announceFileSent = message => {
16
- // TalkBack on Android WebView reliably announces newly *appended*
17
- // role="alert" nodes but often misses text-content updates on existing
18
- // nodes. Wait 500ms for the send-box focus shift to settle, then inject
19
- // a fresh alert element appended to document.body and remove it after 3s.
20
- setTimeout(() => {
21
- const el = document.createElement("div");
22
- el.setAttribute("role", "alert");
23
- el.setAttribute("aria-live", "assertive");
24
- el.setAttribute("aria-atomic", "true");
25
- el.style.cssText = "position:absolute;left:-9999px;top:auto;width:1px;height:1px;overflow:hidden;";
26
- el.textContent = message;
27
- document.body.appendChild(el);
28
- // Remove after TalkBack has had time to read it
29
- setTimeout(() => {
30
- if (el.parentNode) {
31
- el.parentNode.removeChild(el);
32
- }
33
- }, 3000);
34
- }, 500);
35
- };
36
15
 
37
16
  /*
38
17
  * If an attachment is invalid, delete this attachment from the attachments list
@@ -221,13 +200,7 @@ const createAttachmentUploadValidatorMiddleware = (allowedFileExtensions, maxFil
221
200
  var _payload$activity, _payload$activity2;
222
201
  const payload = action.payload;
223
202
  if (payload !== null && payload !== void 0 && payload.activity.attachments && payload.activity.attachments.length > 0 && (payload === null || payload === void 0 || (_payload$activity = payload.activity) === null || _payload$activity === void 0 || (_payload$activity = _payload$activity.attachments) === null || _payload$activity === void 0 ? void 0 : _payload$activity.length) === (payload === null || payload === void 0 || (_payload$activity2 = payload.activity) === null || _payload$activity2 === void 0 || (_payload$activity2 = _payload$activity2.channelData) === null || _payload$activity2 === void 0 || (_payload$activity2 = _payload$activity2.attachmentSizes) === null || _payload$activity2 === void 0 ? void 0 : _payload$activity2.length)) {
224
- var _validatedAction$payl;
225
203
  const validatedAction = validateAttachment(action, allowedFileExtensions, maxFileSizeSupportedByDynamics, localizedTexts);
226
-
227
- // Announce to screen readers that the file was sent when validation passes
228
- if (((_validatedAction$payl = validatedAction.payload) === null || _validatedAction$payl === void 0 || (_validatedAction$payl = _validatedAction$payl.activity) === null || _validatedAction$payl === void 0 || (_validatedAction$payl = _validatedAction$payl.attachments) === null || _validatedAction$payl === void 0 ? void 0 : _validatedAction$payl.length) > 0) {
229
- announceFileSent(localizedTexts.MIDDLEWARE_BANNER_FILE_SENT ?? "File sent successfully.");
230
- }
231
204
  return next(validatedAction);
232
205
  }
233
206
  }
@@ -98,6 +98,7 @@ export declare enum TelemetryEvent {
98
98
  RecoveryEligibilityEvaluated = "RecoveryEligibilityEvaluated",
99
99
  GetConversationDetailsCallStarted = "GetConversationDetailsCallStarted",
100
100
  GetConversationDetailsCallFailed = "GetConversationDetailsCallFailed",
101
+ UpdateTelemetryDataFailed = "UpdateTelemetryDataFailed",
101
102
  EndChatSDKCallFailed = "EndChatSDKCallFailed",
102
103
  DisconnectEndChatSDKCallFailed = "DisconnectEndChatSDKCallFailed",
103
104
  GetChatReconnectContextSDKCallStarted = "GetChatReconnectContextSDKCallStarted",
@@ -127,6 +128,8 @@ export declare enum TelemetryEvent {
127
128
  PrechatSubmitted = "PrechatSubmitted",
128
129
  StartChatSDKCall = "StartChatCall",
129
130
  StartChatEventReceived = "StartChatEventReceived",
131
+ ConcurrentStartChatRejected = "ConcurrentStartChatRejected",
132
+ ChatSDKStateCleanUpDisconnectFailed = "ChatSDKStateCleanUpDisconnectFailed",
130
133
  EndChatSDKCall = "EndChatSDKCall",
131
134
  PrepareEndChat = "PrepareEndChat",
132
135
  EndChatEventReceived = "EndChatEventReceived",
@@ -4,4 +4,12 @@ import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetA
4
4
  import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
5
5
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
6
6
  import { IWebChatProps } from "../../webchatcontainerstateful/interfaces/IWebChatProps";
7
+ import { IWebChatContainerStatefulProps } from "../../webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps";
8
+ /**
9
+ * Renders Markdown for the screen reader text of Adaptive Cards, from the same pieces as the visible card:
10
+ * the host renderMarkdown when set, the hyperlink text override, and the same sanitization.
11
+ * Markdown is always formatted, also when the widget shows Markdown unformatted, so that screen readers do not read the syntax.
12
+ * Styles are removed with their content because the card does not show them.
13
+ */
14
+ export declare const createScreenReaderMarkdownRenderer: (webChatContainerProps?: IWebChatContainerStatefulProps) => (text: string) => string;
7
15
  export declare const initWebChatComposer: (props: ILiveChatWidgetProps, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, facadeChatSDK: FacadeChatSDK, endChat: any) => IWebChatProps;
@@ -6,7 +6,12 @@ import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetA
6
6
  import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
7
7
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
8
8
  declare const handleChatReconnect: (facadeChatSDK: FacadeChatSDK, props: ILiveChatWidgetProps, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, initStartChat: any, state: ILiveChatWidgetContext) => Promise<boolean>;
9
+ /**
10
+ * Returns true when chat reconnect took over the start: it started the chat itself or showed the reconnect pane.
11
+ * In that case the caller must not start another chat.
12
+ */
13
+ declare const isReconnectTriggered: (facadeChatSDK: FacadeChatSDK, props: ILiveChatWidgetProps, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, initStartChat: any, state: ILiveChatWidgetContext) => Promise<boolean>;
9
14
  declare const getChatReconnectContext: (facadeChatSDK: FacadeChatSDK, chatConfig: ChatConfig, props: any, isAuthenticatedChat: boolean, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<import("@microsoft/omnichannel-chat-sdk/lib/core/ChatReconnectContext").default | undefined>;
10
15
  declare const isReconnectEnabled: (chatConfig?: ChatConfig) => boolean;
11
16
  declare const isPersistentEnabled: (chatConfig?: ChatConfig) => boolean;
12
- export { handleChatReconnect, isReconnectEnabled, isPersistentEnabled, getChatReconnectContext };
17
+ export { handleChatReconnect, isReconnectTriggered, isReconnectEnabled, isPersistentEnabled, getChatReconnectContext };
@@ -6,6 +6,10 @@ import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
6
6
  import StartChatOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/StartChatOptionalParams";
7
7
  declare const prepareStartChat: (props: ILiveChatWidgetProps, facadeChatSDK: FacadeChatSDK, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any) => Promise<void>;
8
8
  declare const setPreChatAndInitiateChat: (facadeChatSDK: FacadeChatSDK, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, isProactiveChat?: boolean | false, proactiveChatEnablePrechatState?: boolean | false, state?: ILiveChatWidgetContext, props?: ILiveChatWidgetProps) => Promise<void>;
9
- declare const initStartChat: (facadeChatSDK: FacadeChatSDK, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, state: ILiveChatWidgetContext | undefined, props?: ILiveChatWidgetProps, params?: StartChatOptionalParams, persistedState?: any) => Promise<void>;
9
+ /**
10
+ * Resolves to `true` when the chat reached Active, and `false` when it failed or the call was dropped.
11
+ * It resolves before React renders Active, so callers must use this value rather than reading the conversation state.
12
+ */
13
+ declare const initStartChat: (facadeChatSDK: FacadeChatSDK, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, state: ILiveChatWidgetContext | undefined, props?: ILiveChatWidgetProps, params?: StartChatOptionalParams, persistedState?: any) => Promise<boolean>;
10
14
  declare const checkIfConversationStillValid: (facadeChatSDK: FacadeChatSDK, dispatch: Dispatch<ILiveChatWidgetAction>, state: ILiveChatWidgetContext) => Promise<boolean>;
11
15
  export { prepareStartChat, initStartChat, setPreChatAndInitiateChat, checkIfConversationStillValid };
@@ -0,0 +1,11 @@
1
+ /******
2
+ * AttachmentForScreenReaderMiddleware
3
+ *
4
+ * Web Chat reads an Adaptive Card to screen readers only from the card's `speak` property.
5
+ * A card without `speak` is announced as "A card" with no content.
6
+ * This middleware sets `speak` from the visible text of the card, then lets Web Chat render it as usual.
7
+ ******/
8
+ type RenderMarkdownAsHTML = (markdown: string) => string;
9
+ export declare const getAdaptiveCardSpeak: (content: any, adaptiveCardsPackage: any, renderMarkdownAsHTML: RenderMarkdownAsHTML, adaptiveCardsParserMaxVersion?: string) => string;
10
+ export declare const createAttachmentForScreenReaderMiddleware: (renderMarkdownAsHTML: RenderMarkdownAsHTML) => () => (next: any) => (...args: any[]) => any;
11
+ export {};
@@ -2,9 +2,16 @@
2
2
  * AttachmentSentAnnouncementMiddleware
3
3
  *
4
4
  * When a file attachment is successfully sent, announces the result to
5
- * screen readers via an aria-live region so that assistive technology
6
- * users receive immediate feedback.
5
+ * screen readers so that assistive technology users receive immediate
6
+ * feedback ("File report.pdf sent").
7
+ *
8
+ * The announcement region lives inside the chat dialog. While the dialog is
9
+ * open it is aria-modal and its host siblings are aria-hidden, so screen
10
+ * readers (TalkBack, VoiceOver) ignore live regions outside it.
7
11
  ******/
12
+ import { ILiveChatWidgetLocalizedTexts } from "../../../../../contexts/common/ILiveChatWidgetLocalizedTexts";
8
13
  import { WebChatStoreMiddleware } from "../../../interfaces/IWebChatAction";
9
- declare const attachmentSentAnnouncementMiddleware: WebChatStoreMiddleware;
10
- export default attachmentSentAnnouncementMiddleware;
14
+ export declare const ATTACHMENT_ANNOUNCEMENT_REGION_ID = "oc-lcw-attachment-announcement";
15
+ export declare const getFileSentMessage: (attachments: any[], localizedTexts?: ILiveChatWidgetLocalizedTexts) => string;
16
+ export declare const createAttachmentSentAnnouncementMiddleware: (localizedTexts?: ILiveChatWidgetLocalizedTexts, widgetElementId?: string) => WebChatStoreMiddleware;
17
+ export default createAttachmentSentAnnouncementMiddleware;
@@ -35,10 +35,17 @@ export interface ILiveChatWidgetLocalizedTexts {
35
35
  */
36
36
  MIDDLEWARE_BANNER_FILE_IS_MALICIOUS?: string;
37
37
  /**
38
- * Success message announced by screen readers when a file is successfully sent.
39
- * e.g. "File sent successfully."
38
+ * Message announced by screen readers when one file is successfully sent.
39
+ * {2} - File name
40
+ * e.g. "File {2} sent"
40
41
  */
41
42
  MIDDLEWARE_BANNER_FILE_SENT?: string;
43
+ /**
44
+ * Message announced by screen readers when several files are sent in one message.
45
+ * {0} - Number of files
46
+ * e.g. "{0} files sent"
47
+ */
48
+ MIDDLEWARE_BANNER_FILES_SENT?: string;
42
49
  /**
43
50
  * Success message, indicating the email address introduced has been registered to receive the transcript.
44
51
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "2.0.1-main.84e2c02",
3
+ "version": "2.0.1-main.a610fd8",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -93,18 +93,17 @@
93
93
  "@azure/core-tracing": "^1.2.0",
94
94
  "@microsoft/applicationinsights-web": "^3.3.6",
95
95
  "@microsoft/omnichannel-chat-components": "1.2.0",
96
- "@microsoft/omnichannel-chat-sdk": "2.0.1",
96
+ "@microsoft/omnichannel-chat-sdk": "2.0.2-main.07ad838",
97
97
  "@opentelemetry/api": "^1.9.0",
98
98
  "abort-controller": "^3",
99
99
  "botframework-webchat": "4.18.1-hotfix.20260308.b15b405",
100
100
  "core-js-pure": "^3.42.0",
101
- "dompurify": "3.4.16",
102
- "markdown-it": "^14.3.0",
101
+ "dompurify": "3.4.17",
102
+ "markdown-it": "^14.3.3",
103
103
  "markdown-it-attrs": "^4.1.6",
104
104
  "markdown-it-for-inline": "^0.1.1",
105
105
  "md5-typescript": "^1.0.5",
106
106
  "rxjs": "5.5.12",
107
- "sanitize-html": "2.17.7",
108
107
  "simple-update-in": "2.2.0",
109
108
  "slack-markdown-it": "^1.0.5"
110
109
  },
@@ -164,7 +163,7 @@
164
163
  "**/@types/trusted-types": "2.0.7",
165
164
  "**/join-images": "1.1.5",
166
165
  "**/valibot": "1.4.2",
167
- "**/nanoid": "3.3.18"
166
+ "**/nanoid": "^3.3.20"
168
167
  },
169
168
  "jest": {
170
169
  "verbose": true,