@azure/communication-react 1.11.1-alpha-202401090013 → 1.11.1-alpha-202401110013
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/dist/communication-react.d.ts +32 -7
- package/dist/dist-cjs/communication-react/index.js +70 -118
- package/dist/dist-cjs/communication-react/index.js.map +1 -1
- package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js +1 -1
- package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js.map +1 -1
- package/dist/dist-esm/chat-component-bindings/src/errorBarSelector.js +5 -4
- package/dist/dist-esm/chat-component-bindings/src/errorBarSelector.js.map +1 -1
- package/dist/dist-esm/chat-component-bindings/src/hooks/usePropsFor.js.map +1 -1
- package/dist/dist-esm/chat-stateful-client/src/index.d.ts +2 -1
- package/dist/dist-esm/chat-stateful-client/src/index.js +1 -0
- package/dist/dist-esm/chat-stateful-client/src/index.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageContent.js +46 -69
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageContent.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/Dialpad/Dialpad.d.ts +32 -7
- package/dist/dist-esm/react-components/src/components/Dialpad/Dialpad.js +11 -31
- package/dist/dist-esm/react-components/src/components/Dialpad/Dialpad.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/FileDownloadCards.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/v8StyleShim.d.ts +2 -2
- package/dist/dist-esm/react-components/src/components/styles/v8StyleShim.js.map +1 -1
- package/dist/dist-esm/react-components/src/theming/generateTheme.js +5 -1
- package/dist/dist-esm/react-components/src/theming/generateTheme.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/ChatButton/NotificationIcon.js +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/ChatButton/NotificationIcon.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/ChatButton/useUnreadMessagesTracker.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreen.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.js +7 -16
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/BaseComposite.js.map +1 -1
- package/package.json +2 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"telemetryVersion.js","sourceRoot":"","sources":["../../../../../acs-ui-common/src/telemetryVersion.js"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;AAElC,wCAAwC;AAExC,MAAM,CAAC,OAAO,GAAG,2BAA2B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// GENERATED FILE. DO NOT EDIT MANUALLY.\n\nmodule.exports = '1.11.1-alpha-
|
1
|
+
{"version":3,"file":"telemetryVersion.js","sourceRoot":"","sources":["../../../../../acs-ui-common/src/telemetryVersion.js"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;AAElC,wCAAwC;AAExC,MAAM,CAAC,OAAO,GAAG,2BAA2B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// GENERATED FILE. DO NOT EDIT MANUALLY.\n\nmodule.exports = '1.11.1-alpha-202401110013';\n"]}
|
@@ -71,12 +71,12 @@ const accessErrorTargets = [
|
|
71
71
|
];
|
72
72
|
const latestUnableToReachChatServiceError = (latestErrors) => {
|
73
73
|
return latestActiveErrorSatisfying(latestErrors, 'unableToReachChatService', (error) => {
|
74
|
-
return !!error && !!error.innerError && error.innerError
|
74
|
+
return (!!error && !!error.innerError && 'code' in error.innerError && error.innerError.code === 'REQUEST_SEND_ERROR');
|
75
75
|
});
|
76
76
|
};
|
77
77
|
const latestAccessDeniedError = (latestErrors) => {
|
78
78
|
return latestActiveErrorSatisfying(latestErrors, 'accessDenied', (error) => {
|
79
|
-
return !!error && !!error.innerError && error.innerError
|
79
|
+
return !!error && !!error.innerError && 'statusCode' in error.innerError && error.innerError.statusCode === 401;
|
80
80
|
});
|
81
81
|
};
|
82
82
|
const latestNotInThisThreadError = (latestErrors) => {
|
@@ -93,11 +93,12 @@ const latestNotInThisThreadError = (latestErrors) => {
|
|
93
93
|
}
|
94
94
|
// Chat service returns 403 if a user has been removed from a thread.
|
95
95
|
// Chat service returns either 400 or 404 if the thread ID is malformed, depending on how the thread ID is malformed.
|
96
|
-
return [400, 403, 404].some((statusCode) => error.innerError
|
96
|
+
return [400, 403, 404].some((statusCode) => 'statusCode' in error.innerError && error.innerError.statusCode === statusCode);
|
97
97
|
});
|
98
98
|
};
|
99
99
|
const botContactMRIPrefix = '28:';
|
100
|
-
const isErrorDueToBotContact = (error) =>
|
100
|
+
const isErrorDueToBotContact = (error) => 'statusCode' in error.innerError &&
|
101
|
+
error.innerError.statusCode === 400 &&
|
101
102
|
error.innerError.message.includes(`Identifier format is not supported (${botContactMRIPrefix}`);
|
102
103
|
const latestActiveErrorSatisfying = (errors, activeErrorType, predicate) => {
|
103
104
|
const activeErrorMessages = [];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"errorBarSelector.js","sourceRoot":"","sources":["../../../../../chat-component-bindings/src/errorBarSelector.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAyB,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEzE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAe1C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAqB,cAAc,CAC9D,CAAC,eAAe,CAAC,EACjB,CAAC,YAAY,EAAiD,EAAE;;IAC9D,kHAAkH;IAClH,8CAA8C;IAC9C,wEAAwE;IACxE,iCAAiC;IACjC,EAAE;IACF,iHAAiH;IACjH,8BAA8B;IAC9B,MAAM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0CAAE,OAAO,EAAE,mCAAI,CAAC,CAAC,CAAA,EAAA,CAChH,CAAC;IACF,OAAO,mBAAmB,CAAC,mBAAmB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC7D,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { ChatBaseSelectorProps, getLatestErrors } from './baseSelectors';\nimport { ActiveErrorMessage, ErrorType } from '@internal/react-components';\nimport { createSelector } from 'reselect';\nimport { ChatClientState, ChatError, ChatErrors, ChatErrorTarget } from '@internal/chat-stateful-client';\n\n/**\n * Selector type for {@link ErrorBar} component.\n *\n * @public\n */\nexport type ErrorBarSelector = (\n state: ChatClientState,\n props: ChatBaseSelectorProps\n) => {\n activeErrorMessages: ActiveErrorMessage[];\n};\n\n/**\n * Select the first fiew active errors from the state for the {@link ErrorBar} component.\n *\n * In case there are many errors, only a few top errors are returned to avoid\n * filling up the UI with too many errors.\n *\n * Invariants:\n * - {@link ErrorType} is never repeated in the returned errors.\n * - Errors are returned in a fixed order by {@link ErrorType}.\n *\n * @public\n */\nexport const errorBarSelector: ErrorBarSelector = createSelector(\n [getLatestErrors],\n (latestErrors): { activeErrorMessages: ActiveErrorMessage[] } => {\n // The order in which the errors are returned is significant: The `ErrorBar` shows errors on the UI in that order.\n // There are several options for the ordering:\n // - Sorted by when the errors happened (latest first / oldest first).\n // - Stable sort by error type.\n //\n // We chose to stable sort by error type: We intend to show only a small number of errors on the UI and we do not\n // have timestamps for errors.\n const activeErrorMessages: ActiveErrorMessage[] = [];\n let specificSendMessageErrorSeen = false;\n {\n const error = latestUnableToReachChatServiceError(latestErrors);\n if (error !== undefined) {\n activeErrorMessages.push(error);\n }\n }\n {\n const error = latestAccessDeniedError(latestErrors);\n if (error !== undefined) {\n activeErrorMessages.push(error);\n }\n }\n\n const sendMessageError = latestErrors['ChatThreadClient.sendMessage'];\n {\n const error = latestNotInThisThreadError(latestErrors);\n if (error !== undefined) {\n if (sendMessageError !== undefined) {\n activeErrorMessages.push({\n type: 'sendMessageNotInChatThread',\n // Set the latest timestamp of all the errors that translated to an active error.\n timestamp:\n sendMessageError.timestamp > (error.timestamp ?? 0) ? sendMessageError.timestamp : error.timestamp\n });\n specificSendMessageErrorSeen = true;\n } else {\n activeErrorMessages.push(error);\n }\n }\n }\n\n if (!specificSendMessageErrorSeen && sendMessageError !== undefined) {\n activeErrorMessages.push({ type: 'sendMessageGeneric', timestamp: sendMessageError.timestamp });\n }\n\n // We only return the first few errors to avoid filling up the UI with too many `MessageBar`s.\n activeErrorMessages.splice(maxErrorCount);\n return { activeErrorMessages: activeErrorMessages };\n }\n);\n\nconst maxErrorCount = 3;\n\nconst accessErrorTargets: ChatErrorTarget[] = [\n 'ChatThreadClient.getProperties',\n 'ChatThreadClient.listMessages',\n 'ChatThreadClient.listParticipants',\n 'ChatThreadClient.sendMessage',\n 'ChatThreadClient.sendTypingNotification'\n];\n\nconst latestUnableToReachChatServiceError = (latestErrors: ChatErrors): ActiveErrorMessage | undefined => {\n return latestActiveErrorSatisfying(latestErrors, 'unableToReachChatService', (error: ChatError): boolean => {\n return !!error && !!error.innerError && error.innerError['code'] === 'REQUEST_SEND_ERROR';\n });\n};\n\nconst latestAccessDeniedError = (latestErrors: ChatErrors): ActiveErrorMessage | undefined => {\n return latestActiveErrorSatisfying(latestErrors, 'accessDenied', (error: ChatError): boolean => {\n return !!error && !!error.innerError && error.innerError['statusCode'] === 401;\n });\n};\n\nconst latestNotInThisThreadError = (latestErrors: ChatErrors): ActiveErrorMessage | undefined => {\n return latestActiveErrorSatisfying(latestErrors, 'userNotInChatThread', (error: ChatError): boolean => {\n if (!error || !error.innerError) {\n return false;\n }\n\n // Explicitly ignore 400 REST error when listParticipants() is called and a BotContact MRI is found in the participants.\n // This check should be removed when the chat SDK has handled this issue. Note: The this does not stop the error being logged to the console.\n // To the best of our ability we have confirmed this to have no impact on the participantList returned (all valid participants are still returned), nor\n // does it have an impact on the participant list updating on other participants joining/leaving or on individual participant actions like removeParticipant.\n if (isErrorDueToBotContact(error)) {\n return false;\n }\n\n // Chat service returns 403 if a user has been removed from a thread.\n // Chat service returns either 400 or 404 if the thread ID is malformed, depending on how the thread ID is malformed.\n return [400, 403, 404].some((statusCode) => error.innerError['statusCode'] === statusCode);\n });\n};\n\nconst botContactMRIPrefix = '28:';\nconst isErrorDueToBotContact = (error: ChatError): boolean =>\n error.innerError['statusCode'] === 400 &&\n error.innerError.message.includes(`Identifier format is not supported (${botContactMRIPrefix}`);\n\nconst latestActiveErrorSatisfying = (\n errors: ChatErrors,\n activeErrorType: ErrorType,\n predicate: (error: ChatError) => boolean\n): ActiveErrorMessage | undefined => {\n const activeErrorMessages: ActiveErrorMessage[] = [];\n for (const target of accessErrorTargets) {\n const error = errors[target];\n if (predicate(error)) {\n activeErrorMessages.push({ type: activeErrorType, timestamp: error.timestamp });\n }\n }\n\n if (activeErrorMessages.length === 0) {\n return undefined;\n }\n // We're actually sure that both timestamps will always exist, because we set them above.\n activeErrorMessages.sort(\n (a: ActiveErrorMessage, b: ActiveErrorMessage) => (a.timestamp?.getTime() ?? 0) - (b.timestamp?.getTime() ?? 0)\n );\n return activeErrorMessages[activeErrorMessages.length - 1];\n};\n"]}
|
1
|
+
{"version":3,"file":"errorBarSelector.js","sourceRoot":"","sources":["../../../../../chat-component-bindings/src/errorBarSelector.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAyB,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEzE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAe1C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAqB,cAAc,CAC9D,CAAC,eAAe,CAAC,EACjB,CAAC,YAAY,EAAiD,EAAE;;IAC9D,kHAAkH;IAClH,8CAA8C;IAC9C,wEAAwE;IACxE,iCAAiC;IACjC,EAAE;IACF,iHAAiH;IACjH,8BAA8B;IAC9B,MAAM,mB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AAC,OAAA,CAAC,MAAA,MAAA,CAAC,CAAC,SAAS,0CAAE,OAAO,EAAE,mCAAI,CAAC,CAAC,GAAG,CAAC,MAAA,MAAA,CAAC,CAAC,SAAS,0CAAE,OAAO,EAAE,mCAAI,CAAC,CAAC,CAAA,EAAA,CAChH,CAAC;IACF,OAAO,mBAAmB,CAAC,mBAAmB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC7D,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { ChatBaseSelectorProps, getLatestErrors } from './baseSelectors';\nimport { ActiveErrorMessage, ErrorType } from '@internal/react-components';\nimport { createSelector } from 'reselect';\nimport { ChatClientState, ChatError, ChatErrors, ChatErrorTarget } from '@internal/chat-stateful-client';\n\n/**\n * Selector type for {@link ErrorBar} component.\n *\n * @public\n */\nexport type ErrorBarSelector = (\n state: ChatClientState,\n props: ChatBaseSelectorProps\n) => {\n activeErrorMessages: ActiveErrorMessage[];\n};\n\n/**\n * Select the first fiew active errors from the state for the {@link ErrorBar} component.\n *\n * In case there are many errors, only a few top errors are returned to avoid\n * filling up the UI with too many errors.\n *\n * Invariants:\n * - {@link ErrorType} is never repeated in the returned errors.\n * - Errors are returned in a fixed order by {@link ErrorType}.\n *\n * @public\n */\nexport const errorBarSelector: ErrorBarSelector = createSelector(\n [getLatestErrors],\n (latestErrors): { activeErrorMessages: ActiveErrorMessage[] } => {\n // The order in which the errors are returned is significant: The `ErrorBar` shows errors on the UI in that order.\n // There are several options for the ordering:\n // - Sorted by when the errors happened (latest first / oldest first).\n // - Stable sort by error type.\n //\n // We chose to stable sort by error type: We intend to show only a small number of errors on the UI and we do not\n // have timestamps for errors.\n const activeErrorMessages: ActiveErrorMessage[] = [];\n let specificSendMessageErrorSeen = false;\n {\n const error = latestUnableToReachChatServiceError(latestErrors);\n if (error !== undefined) {\n activeErrorMessages.push(error);\n }\n }\n {\n const error = latestAccessDeniedError(latestErrors);\n if (error !== undefined) {\n activeErrorMessages.push(error);\n }\n }\n\n const sendMessageError = latestErrors['ChatThreadClient.sendMessage'];\n {\n const error = latestNotInThisThreadError(latestErrors);\n if (error !== undefined) {\n if (sendMessageError !== undefined) {\n activeErrorMessages.push({\n type: 'sendMessageNotInChatThread',\n // Set the latest timestamp of all the errors that translated to an active error.\n timestamp:\n sendMessageError.timestamp > (error.timestamp ?? 0) ? sendMessageError.timestamp : error.timestamp\n });\n specificSendMessageErrorSeen = true;\n } else {\n activeErrorMessages.push(error);\n }\n }\n }\n\n if (!specificSendMessageErrorSeen && sendMessageError !== undefined) {\n activeErrorMessages.push({ type: 'sendMessageGeneric', timestamp: sendMessageError.timestamp });\n }\n\n // We only return the first few errors to avoid filling up the UI with too many `MessageBar`s.\n activeErrorMessages.splice(maxErrorCount);\n return { activeErrorMessages: activeErrorMessages };\n }\n);\n\nconst maxErrorCount = 3;\n\nconst accessErrorTargets: ChatErrorTarget[] = [\n 'ChatThreadClient.getProperties',\n 'ChatThreadClient.listMessages',\n 'ChatThreadClient.listParticipants',\n 'ChatThreadClient.sendMessage',\n 'ChatThreadClient.sendTypingNotification'\n];\n\nconst latestUnableToReachChatServiceError = (latestErrors: ChatErrors): ActiveErrorMessage | undefined => {\n return latestActiveErrorSatisfying(latestErrors, 'unableToReachChatService', (error: ChatError): boolean => {\n return (\n !!error && !!error.innerError && 'code' in error.innerError && error.innerError.code === 'REQUEST_SEND_ERROR'\n );\n });\n};\n\nconst latestAccessDeniedError = (latestErrors: ChatErrors): ActiveErrorMessage | undefined => {\n return latestActiveErrorSatisfying(latestErrors, 'accessDenied', (error: ChatError): boolean => {\n return !!error && !!error.innerError && 'statusCode' in error.innerError && error.innerError.statusCode === 401;\n });\n};\n\nconst latestNotInThisThreadError = (latestErrors: ChatErrors): ActiveErrorMessage | undefined => {\n return latestActiveErrorSatisfying(latestErrors, 'userNotInChatThread', (error: ChatError): boolean => {\n if (!error || !error.innerError) {\n return false;\n }\n\n // Explicitly ignore 400 REST error when listParticipants() is called and a BotContact MRI is found in the participants.\n // This check should be removed when the chat SDK has handled this issue. Note: The this does not stop the error being logged to the console.\n // To the best of our ability we have confirmed this to have no impact on the participantList returned (all valid participants are still returned), nor\n // does it have an impact on the participant list updating on other participants joining/leaving or on individual participant actions like removeParticipant.\n if (isErrorDueToBotContact(error)) {\n return false;\n }\n\n // Chat service returns 403 if a user has been removed from a thread.\n // Chat service returns either 400 or 404 if the thread ID is malformed, depending on how the thread ID is malformed.\n return [400, 403, 404].some(\n (statusCode) => 'statusCode' in error.innerError && error.innerError.statusCode === statusCode\n );\n });\n};\n\nconst botContactMRIPrefix = '28:';\nconst isErrorDueToBotContact = (error: ChatError): boolean =>\n 'statusCode' in error.innerError &&\n error.innerError.statusCode === 400 &&\n error.innerError.message.includes(`Identifier format is not supported (${botContactMRIPrefix}`);\n\nconst latestActiveErrorSatisfying = (\n errors: ChatErrors,\n activeErrorType: ErrorType,\n predicate: (error: ChatError) => boolean\n): ActiveErrorMessage | undefined => {\n const activeErrorMessages: ActiveErrorMessage[] = [];\n for (const target of accessErrorTargets) {\n const error = errors[target];\n if (predicate(error)) {\n activeErrorMessages.push({ type: activeErrorType, timestamp: error.timestamp });\n }\n }\n\n if (activeErrorMessages.length === 0) {\n return undefined;\n }\n // We're actually sure that both timestamps will always exist, because we set them above.\n activeErrorMessages.sort(\n (a: ActiveErrorMessage, b: ActiveErrorMessage) => (a.timestamp?.getTime() ?? 0) - (b.timestamp?.getTime() ?? 0)\n );\n return activeErrorMessages[activeErrorMessages.length - 1];\n};\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"usePropsFor.js","sourceRoot":"","sources":["../../../../../../chat-component-bindings/src/hooks/usePropsFor.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAEhH,OAAO,EAAE,WAAW,EAAE,MAA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AU,CAAC,uBAAuB,CAAC,0CAAE,QAAQ,mCAAI,iCAAiC,CAAC;QACpG,IAAI,yBAAyB,GAAG,8BAA8B,CAAC,QAAQ,CAAC,CAAC;QACzE,IAAI,CAAC,yBAAyB,EAAE,CAAC;YAC/B,8BAA8B,CAAC,QAAQ,CAAC,GAAG,+BAA+B,EAAE,CAAC;YAC7E,yBAAyB,GAAG,8BAA8B,CAAC,QAAQ,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,yBAAyB,CAAC;IACnC,CAAC,CAAC;IAEF,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,OAAO;YACV,OAAO,eAAe,CAAC;QACzB,KAAK,aAAa;YAChB,OAAO,wBAAwB,EAAE,CAAC;QACpC,KAAK,eAAe;YAClB,OAAO,uBAAuB,CAAC;QACjC,KAAK,eAAe;YAClB,OAAO,2BAA2B,CAAC;QACrC,KAAK,QAAQ;YACX,OAAO,gBAAgB,CAAC;IAC5B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { ErrorBar, MessageThread, ParticipantList, SendBox, TypingIndicator } from '@internal/react-components';\n\nimport { useHandlers } from './useHandlers';\nimport { useSelector } from './useSelector';\nimport { SendBoxSelector, sendBoxSelector } from '../sendBoxSelector';\nimport { MessageThreadSelector, messageThreadSelectorWithThread } from '../messageThreadSelector';\nimport { TypingIndicatorSelector, typingIndicatorSelector } from '../typingIndicatorSelector';\nimport { Common, AreEqual } from '@internal/acs-ui-common';\nimport { ChatHandlers } from '../handlers/createHandlers';\nimport { ChatParticipantListSelector, chatParticipantListSelector } from '../chatParticipantListSelector';\nimport { ErrorBarSelector, errorBarSelector } from '../errorBarSelector';\nimport { ChatThreadClientContext } from '../providers/ChatThreadClientProvider';\nimport { useContext } from 'react';\n\n/**\n * Primary hook to get all hooks necessary for a chat Component.\n *\n * Most straightforward usage of chat components looks like:\n *\n * @example\n * ```\n * import { ParticipantList, usePropsFor } from '@azure/communication-react';\n *\n * const App = (): JSX.Element => {\n * // ... code to setup Providers ...\n *\n * return <ParticipantList {...usePropsFor(ParticipantList)}/>\n * }\n * ```\n *\n * @public\n */\nexport const usePropsFor = <Component extends (props: any) => JSX.Element>(\n component: Component\n): GetSelector<Component> extends (props: any) => any\n ? ReturnType<GetSelector<Component>> & Common<ChatHandlers, Parameters<Component>[0]>\n : undefined => {\n const selector = getSelector(component);\n const props = useSelector(selector);\n const handlers = useHandlers<Parameters<Component>[0]>(component);\n if (props !== undefined) {\n return { ...props, ...handlers } as any;\n }\n return undefined as any;\n};\n\n/**\n * Specific type of the selector applicable to a given Component.\n *\n * @public\n */\nexport type GetSelector<Component extends (props: any) => JSX.Element | undefined> = AreEqual<\n Component,\n typeof SendBox\n> extends true\n ? SendBoxSelector\n : AreEqual<Component, typeof MessageThread> extends true\n ? MessageThreadSelector\n : AreEqual<Component, typeof TypingIndicator> extends true\n ? TypingIndicatorSelector\n : AreEqual<Component, typeof ParticipantList> extends true\n ? ChatParticipantListSelector\n : AreEqual<Component, typeof ErrorBar> extends true\n ? ErrorBarSelector\n : undefined;\n\n/**\n * Get the selector for a specified component.\n *\n * Useful when implementing a custom component that utilizes the providers\n * exported from this library.\n *\n * @public\n */\nexport const getSelector = <Component extends (props: any) => JSX.Element | undefined>(\n component: Component\n): GetSelector<Component> => {\n return findSelector(component);\n};\n\nconst messageThreadSelectorsByThread: { [key: string]: MessageThreadSelector } = {};\n\nconst findSelector = (component: (props: any) => JSX.Element | undefined): any => {\n // For the message thread selector we need to create a new one for each thread\n // If we have just one for the entire app, then we will have updates when not expecting due to\n // the arguments changing\n const getMessageThreadSelector: () => MessageThreadSelector = () => {\n const threadId = useContext(ChatThreadClientContext)?.threadId ?? 'default-id-when-not-in-provider';\n let messageThreadSelectorImpl = messageThreadSelectorsByThread[threadId];\n if (!messageThreadSelectorImpl) {\n messageThreadSelectorsByThread[threadId] = messageThreadSelectorWithThread();\n messageThreadSelectorImpl = messageThreadSelectorsByThread[threadId];\n }\n return messageThreadSelectorImpl;\n };\n\n switch (component) {\n case SendBox:\n return sendBoxSelector;\n case MessageThread:\n return getMessageThreadSelector();\n case TypingIndicator:\n return typingIndicatorSelector;\n case ParticipantList:\n return chatParticipantListSelector;\n case ErrorBar:\n return errorBarSelector;\n }\n return undefined;\n};\n"]}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
export { createStatefulChatClient, _createStatefulChatClientInner, _createStatefulChatClientWithDeps } from './StatefulChatClient';
|
2
2
|
export type { StatefulChatClient, StatefulChatClientArgs, StatefulChatClientOptions } from './StatefulChatClient';
|
3
3
|
export type { ChatMessageWithStatus } from './types/ChatMessageWithStatus';
|
4
|
-
export
|
4
|
+
export { ChatError } from './ChatClientState';
|
5
|
+
export type { ChatClientState, ChatErrors, ChatThreadClientState, ChatThreadProperties, ChatErrorTarget } from './ChatClientState';
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1,4 +1,5 @@
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
2
2
|
// Licensed under the MIT License.
|
3
3
|
export { createStatefulChatClient, _createStatefulChatClientInner, _createStatefulChatClientWithDeps } from './StatefulChatClient';
|
4
|
+
export { ChatError } from './ChatClientState';
|
4
5
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../chat-stateful-client/src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,wBAAwB,EACxB,8BAA8B,EAC9B,iCAAiC,EAClC,MAAM,sBAAsB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport {\n createStatefulChatClient,\n _createStatefulChatClientInner,\n _createStatefulChatClientWithDeps\n} from './StatefulChatClient';\n\nexport type { StatefulChatClient, StatefulChatClientArgs, StatefulChatClientOptions } from './StatefulChatClient';\nexport type { ChatMessageWithStatus } from './types/ChatMessageWithStatus';\nexport type {\n ChatClientState,\n
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../chat-stateful-client/src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,wBAAwB,EACxB,8BAA8B,EAC9B,iCAAiC,EAClC,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport {\n createStatefulChatClient,\n _createStatefulChatClientInner,\n _createStatefulChatClientWithDeps\n} from './StatefulChatClient';\n\nexport type { StatefulChatClient, StatefulChatClientArgs, StatefulChatClientOptions } from './StatefulChatClient';\nexport type { ChatMessageWithStatus } from './types/ChatMessageWithStatus';\nexport { ChatError } from './ChatClientState';\nexport type {\n ChatClientState,\n ChatErrors,\n ChatThreadClientState,\n ChatThreadProperties,\n ChatErrorTarget\n} from './ChatClientState';\n"]}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
import React from 'react';
|
4
4
|
import { useEffect } from 'react';
|
5
5
|
import { _formatString } from "../../../../acs-ui-common/src";
|
6
|
-
import {
|
6
|
+
import parse, { Element as DOMElement, attributesToProps } from 'html-react-parser';
|
7
7
|
import Linkify from 'react-linkify';
|
8
8
|
import { Link } from '@fluentui/react';
|
9
9
|
/* @conditional-compile-remove(data-loss-prevention) */
|
@@ -94,76 +94,53 @@ const messageContentAriaText = (props) => {
|
|
94
94
|
})
|
95
95
|
: undefined;
|
96
96
|
};
|
97
|
-
const processNodeDefinitions = ProcessNodeDefinitions();
|
98
|
-
const htmlToReactParser = Parser();
|
99
|
-
const processInlineImage = (props) => ({
|
100
|
-
// Custom <img> processing
|
101
|
-
shouldProcessNode: (node) => {
|
102
|
-
var _a;
|
103
|
-
function matchingImageNode(imageMetadata) {
|
104
|
-
return imageMetadata.id === node.attribs.id;
|
105
|
-
}
|
106
|
-
// Process img node with id in attachments list
|
107
|
-
return (node.name &&
|
108
|
-
node.name === 'img' &&
|
109
|
-
node.attribs &&
|
110
|
-
node.attribs.id &&
|
111
|
-
((_a = props.message.inlineImages) === null || _a === void 0 ? void 0 : _a.find(matchingImageNode)));
|
112
|
-
},
|
113
|
-
processNode: (node, children, index) => {
|
114
|
-
node.attribs = Object.assign(Object.assign({}, node.attribs), { 'aria-label': node.attribs.name });
|
115
|
-
// logic to check id in map/list
|
116
|
-
if (props.attachmentsMap && node.attribs.id in props.attachmentsMap) {
|
117
|
-
node.attribs = Object.assign(Object.assign({}, node.attribs), { src: props.attachmentsMap[node.attribs.id] });
|
118
|
-
}
|
119
|
-
const handleOnClick = () => {
|
120
|
-
props.onInlineImageClicked && props.onInlineImageClicked(node.attribs.id);
|
121
|
-
};
|
122
|
-
return (React.createElement("span", { "data-ui-id": node.attribs.id, onClick: handleOnClick, tabIndex: 0, role: "button", style: {
|
123
|
-
cursor: 'pointer'
|
124
|
-
}, onKeyDown: (e) => {
|
125
|
-
if (e.key === 'Enter') {
|
126
|
-
handleOnClick();
|
127
|
-
}
|
128
|
-
} }, processNodeDefinitions.processDefaultNode(node, children, index)));
|
129
|
-
return processNodeDefinitions.processDefaultNode(node, children, index);
|
130
|
-
}
|
131
|
-
});
|
132
|
-
/* @conditional-compile-remove(mention) */
|
133
|
-
const processMention = (props) => ({
|
134
|
-
shouldProcessNode: (node) => {
|
135
|
-
var _a;
|
136
|
-
if ((_a = props.mentionDisplayOptions) === null || _a === void 0 ? void 0 : _a.onRenderMention) {
|
137
|
-
// Override the handling of the <msft-mention> tag in the HTML if there's a custom renderer
|
138
|
-
return node.name === 'msft-mention';
|
139
|
-
}
|
140
|
-
return false;
|
141
|
-
},
|
142
|
-
processNode: (node) => {
|
143
|
-
var _a, _b, _c;
|
144
|
-
if ((_a = props.mentionDisplayOptions) === null || _a === void 0 ? void 0 : _a.onRenderMention) {
|
145
|
-
const { id } = node.attribs;
|
146
|
-
const mention = {
|
147
|
-
id: id,
|
148
|
-
displayText: (_c = (_b = node.children[0]) === null || _b === void 0 ? void 0 : _b.data) !== null && _c !== void 0 ? _c : ''
|
149
|
-
};
|
150
|
-
return props.mentionDisplayOptions.onRenderMention(mention, defaultOnMentionRender);
|
151
|
-
}
|
152
|
-
return processNodeDefinitions.processDefaultNode;
|
153
|
-
}
|
154
|
-
});
|
155
97
|
const processHtmlToReact = (props) => {
|
156
98
|
var _a;
|
157
|
-
const
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
99
|
+
const options = {
|
100
|
+
transform(reactNode, domNode) {
|
101
|
+
var _a, _b, _c;
|
102
|
+
if (domNode instanceof DOMElement && domNode.attribs) {
|
103
|
+
// Transform custom rendering of mentions
|
104
|
+
/* @conditional-compile-remove(mention) */
|
105
|
+
if (((_a = props.mentionDisplayOptions) === null || _a === void 0 ? void 0 : _a.onRenderMention) && domNode.name === 'msft-mention') {
|
106
|
+
const { id } = domNode.attribs;
|
107
|
+
const mention = {
|
108
|
+
id: id,
|
109
|
+
displayText: (_b = domNode.children[0].nodeValue) !== null && _b !== void 0 ? _b : ''
|
110
|
+
};
|
111
|
+
return props.mentionDisplayOptions.onRenderMention(mention, defaultOnMentionRender);
|
112
|
+
}
|
113
|
+
// Transform inline images
|
114
|
+
if (domNode.name &&
|
115
|
+
domNode.name === 'img' &&
|
116
|
+
domNode.attribs &&
|
117
|
+
domNode.attribs.id &&
|
118
|
+
((_c = props.message.inlineImages) === null || _c === void 0 ? void 0 : _c.find((metadata) => {
|
119
|
+
return metadata.id === domNode.attribs.id;
|
120
|
+
}))) {
|
121
|
+
domNode.attribs['aria-label'] = domNode.attribs.name;
|
122
|
+
// logic to check id in map/list
|
123
|
+
if (props.attachmentsMap && domNode.attribs.id in props.attachmentsMap) {
|
124
|
+
domNode.attribs.src = props.attachmentsMap[domNode.attribs.id];
|
125
|
+
}
|
126
|
+
const handleOnClick = () => {
|
127
|
+
props.onInlineImageClicked && props.onInlineImageClicked(domNode.attribs.id);
|
128
|
+
};
|
129
|
+
const imgProps = attributesToProps(domNode.attribs);
|
130
|
+
return (React.createElement("span", { "data-ui-id": domNode.attribs.id, onClick: handleOnClick, tabIndex: 0, role: "button", style: {
|
131
|
+
cursor: 'pointer'
|
132
|
+
}, onKeyDown: (e) => {
|
133
|
+
if (e.key === 'Enter') {
|
134
|
+
handleOnClick();
|
135
|
+
}
|
136
|
+
} },
|
137
|
+
React.createElement("img", Object.assign({}, imgProps))));
|
138
|
+
}
|
139
|
+
}
|
140
|
+
// Pass through the original node
|
141
|
+
return reactNode;
|
165
142
|
}
|
166
|
-
|
167
|
-
return
|
143
|
+
};
|
144
|
+
return React.createElement(React.Fragment, null, parse((_a = props.message.content) !== null && _a !== void 0 ? _a : '', options));
|
168
145
|
};
|
169
146
|
//# sourceMappingURL=ChatMessageContent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ChatMessageContent.js","sourceRoot":"","sources":["../../../../../../../react-components/src/components/ChatMessage/ChatMessageContent.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,sCAAgC;AACxD,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,sBAAsB,EAA6B,MAAM,eAAe,CAAC;AAElH,OAAO,OAAO,MAAM,eAAe,CAAC;AAIpC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAIvC,uDAAuD;AACvD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAGlD,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,0CAA0C;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,SAAS,MAAM,WAAW,CAAC;AAyBlC,eAAe;AACf,MA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K,CAAC;QACzB,0CAA0C;QAC1C,cAAc,CAAC,KAAK,CAAC;QACrB;YACE,6CAA6C;YAC7C,iBAAiB,EAAE,sBAAsB,CAAC,WAAW;YACrD,WAAW,EAAE,sBAAsB,CAAC,kBAAkB;SACvD;KACF,CAAC;IAEF,OAAO,iBAAiB,CAAC,qBAAqB,CAC5C,MAAA,KAAK,CAAC,OAAO,CAAC,OAAO,mCAAI,EAAE,EAC3B,sBAAsB,CAAC,WAAW,EAClC,KAAK,CACN,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport React from 'react';\nimport { useEffect } from 'react';\nimport { _formatString } from '@internal/acs-ui-common';\nimport { Parser, ProcessNodeDefinitions, IsValidNodeDefinitions, ProcessingInstructionType } from 'html-to-react';\n\nimport Linkify from 'react-linkify';\nimport { ChatMessage } from '../../types/ChatMessage';\n/* @conditional-compile-remove(data-loss-prevention) */\nimport { BlockedMessage } from '../../types/ChatMessage';\nimport { Link } from '@fluentui/react';\n/* @conditional-compile-remove(mention) */\nimport { MentionDisplayOptions, Mention } from '../MentionPopover';\n\n/* @conditional-compile-remove(data-loss-prevention) */\nimport { FontIcon, Stack } from '@fluentui/react';\nimport { MessageThreadStrings } from '../MessageThread';\nimport { AttachmentMetadata, InlineImageMetadata } from '../FileDownloadCards';\nimport LiveMessage from '../Announcer/LiveMessage';\n/* @conditional-compile-remove(mention) */\nimport { defaultOnMentionRender } from './MentionRenderer';\nimport DOMPurify from 'dompurify';\n\ntype ChatMessageContentProps = {\n message: ChatMessage;\n strings: MessageThreadStrings;\n /* @conditional-compile-remove(mention) */\n mentionDisplayOptions?: MentionDisplayOptions;\n attachmentsMap?: Record<string, string>;\n onFetchAttachments?: (attachments: AttachmentMetadata[], messageId: string) => Promise<void>;\n onInlineImageClicked?: (attachmentId: string) => void;\n};\n\n/* @conditional-compile-remove(data-loss-prevention) */\ntype BlockedMessageContentProps = {\n message: BlockedMessage;\n strings: MessageThreadStrings;\n};\n\ntype MessageContentWithLiveAriaProps = {\n message: ChatMessage | /* @conditional-compile-remove(data-loss-prevention) */ BlockedMessage;\n liveMessage: string;\n ariaLabel?: string;\n content: JSX.Element;\n};\n\n/** @private */\nexport const ChatMessageContent = (props: ChatMessageContentProps): JSX.Element => {\n switch (props.message.contentType) {\n case 'text':\n return MessageContentAsText(props);\n case 'html':\n return MessageContentAsRichTextHTML(props);\n case 'richtext/html':\n return MessageContentAsRichTextHTML(props);\n default:\n console.warn('unknown message content type');\n return <></>;\n }\n};\n\nconst MessageContentWithLiveAria = (props: MessageContentWithLiveAriaProps): JSX.Element => {\n return (\n <div data-ui-status={props.message.status} role=\"text\" aria-label={props.ariaLabel}>\n <LiveMessage message={props.liveMessage} ariaLive=\"polite\" />\n {props.content}\n </div>\n );\n};\n\nconst MessageContentAsRichTextHTML = (props: ChatMessageContentProps): JSX.Element => {\n const { message, attachmentsMap, onFetchAttachments } = props;\n useEffect(() => {\n if (!attachmentsMap || !onFetchAttachments) {\n return;\n }\n const attachments = message.inlineImages?.filter((inlinedImages) => {\n return attachmentsMap[inlinedImages.id] === undefined;\n });\n if (attachments && attachments.length > 0) {\n onFetchAttachments(attachments, message.messageId);\n }\n }, [message.inlineImages, message.messageId, onFetchAttachments, attachmentsMap]);\n\n return (\n <MessageContentWithLiveAria\n message={props.message}\n liveMessage={generateLiveMessage(props)}\n ariaLabel={messageContentAriaText(props)}\n content={processHtmlToReact(props)}\n />\n );\n};\n\nconst MessageContentAsText = (props: ChatMessageContentProps): JSX.Element => {\n return (\n <MessageContentWithLiveAria\n message={props.message}\n liveMessage={generateLiveMessage(props)}\n ariaLabel={messageContentAriaText(props)}\n content={\n <Linkify\n componentDecorator={(decoratedHref: string, decoratedText: string, key: number) => {\n return (\n <Link target=\"_blank\" href={decoratedHref} key={key}>\n {decoratedText}\n </Link>\n );\n }}\n >\n {props.message.content}\n </Linkify>\n }\n />\n );\n};\n\n/* @conditional-compile-remove(data-loss-prevention) */\n/**\n * @private\n */\nexport const BlockedMessageContent = (props: BlockedMessageContentProps): JSX.Element => {\n const Icon: JSX.Element = <FontIcon iconName={'DataLossPreventionProhibited'} />;\n const blockedMessage =\n props.message.warningText === undefined ? props.strings.blockedWarningText : props.message.warningText;\n const blockedMessageLink = props.message.link;\n const blockedMessageLinkText = blockedMessageLink\n ? props.message.linkText ?? props.strings.blockedWarningLinkText\n : '';\n\n const liveAuthor =\n props.message.mine || props.message.senderDisplayName === undefined ? '' : props.message.senderDisplayName;\n const liveBlockedWarningText = `${liveAuthor} ${blockedMessage} ${blockedMessageLinkText}`;\n return (\n <MessageContentWithLiveAria\n message={props.message}\n liveMessage={liveBlockedWarningText}\n ariaLabel={liveBlockedWarningText}\n content={\n <Stack horizontal wrap>\n {Icon}\n {blockedMessage && <p>{blockedMessage}</p>}\n {blockedMessageLink && (\n <Link target={'_blank'} href={blockedMessageLink}>\n {blockedMessageLinkText}\n </Link>\n )}\n </Stack>\n }\n />\n );\n};\n\n// https://stackoverflow.com/questions/28899298/extract-the-text-out-of-html-string-using-javascript\nconst extractContent = (s: string): string => {\n const span = document.createElement('span');\n span.innerHTML = s;\n return span.textContent || span.innerText;\n};\n\nconst generateLiveMessage = (props: ChatMessageContentProps): string => {\n const liveAuthor = _formatString(props.strings.liveAuthorIntro, { author: `${props.message.senderDisplayName}` });\n\n return `${props.message.editedOn ? props.strings.editedTag : ''} ${\n props.message.mine ? '' : liveAuthor\n } ${extractContent(props.message.content || '')} `;\n};\n\nconst messageContentAriaText = (props: ChatMessageContentProps): string | undefined => {\n // Strip all html tags from the content for aria.\n\n return props.message.content\n ? props.message.mine\n ? _formatString(props.strings.messageContentMineAriaText, {\n message: DOMPurify.sanitize(props.message.content, { ALLOWED_TAGS: [] })\n })\n : _formatString(props.strings.messageContentAriaText, {\n author: `${props.message.senderDisplayName}`,\n message: DOMPurify.sanitize(props.message.content, { ALLOWED_TAGS: [] })\n })\n : undefined;\n};\n\nconst processNodeDefinitions = ProcessNodeDefinitions();\nconst htmlToReactParser = Parser();\n\nconst processInlineImage = (props: ChatMessageContentProps): ProcessingInstructionType => ({\n // Custom <img> processing\n shouldProcessNode: (node): boolean => {\n function matchingImageNode(imageMetadata: InlineImageMetadata): boolean {\n return imageMetadata.id === node.attribs.id;\n }\n\n // Process img node with id in attachments list\n return (\n node.name &&\n node.name === 'img' &&\n node.attribs &&\n node.attribs.id &&\n props.message.inlineImages?.find(matchingImageNode)\n );\n },\n processNode: (node, children, index): JSX.Element => {\n node.attribs = { ...node.attribs, 'aria-label': node.attribs.name };\n // logic to check id in map/list\n if (props.attachmentsMap && node.attribs.id in props.attachmentsMap) {\n node.attribs = { ...node.attribs, src: props.attachmentsMap[node.attribs.id] };\n }\n const handleOnClick = (): void => {\n props.onInlineImageClicked && props.onInlineImageClicked(node.attribs.id);\n };\n\n return (\n <span\n data-ui-id={node.attribs.id}\n onClick={handleOnClick}\n tabIndex={0}\n role=\"button\"\n style={{\n cursor: 'pointer'\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n handleOnClick();\n }\n }}\n >\n {processNodeDefinitions.processDefaultNode(node, children, index)}\n </span>\n );\n return processNodeDefinitions.processDefaultNode(node, children, index);\n }\n});\n\n/* @conditional-compile-remove(mention) */\nconst processMention = (props: ChatMessageContentProps): ProcessingInstructionType => ({\n shouldProcessNode: (node) => {\n if (props.mentionDisplayOptions?.onRenderMention) {\n // Override the handling of the <msft-mention> tag in the HTML if there's a custom renderer\n return node.name === 'msft-mention';\n }\n return false;\n },\n processNode: (node) => {\n if (props.mentionDisplayOptions?.onRenderMention) {\n const { id } = node.attribs;\n const mention: Mention = {\n id: id,\n displayText: node.children[0]?.data ?? ''\n };\n return props.mentionDisplayOptions.onRenderMention(mention, defaultOnMentionRender);\n }\n return processNodeDefinitions.processDefaultNode;\n }\n});\n\nconst processHtmlToReact = (props: ChatMessageContentProps): JSX.Element => {\n const steps: ProcessingInstructionType[] = [\n processInlineImage(props),\n /* @conditional-compile-remove(mention) */\n processMention(props),\n {\n // Process everything else in the default way\n shouldProcessNode: IsValidNodeDefinitions.alwaysValid,\n processNode: processNodeDefinitions.processDefaultNode\n }\n ];\n\n return htmlToReactParser.parseWithInstructions(\n props.message.content ?? '',\n IsValidNodeDefinitions.alwaysValid,\n steps\n );\n};\n"]}
|
1
|
+
{"version":3,"file":"ChatMessageContent.js","sourceRoot":"","sources":["../../../../../../../react-components/src/components/ChatMessage/ChatMessageContent.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,sCAAgC;AACxD,OAAO,KAAK,EAAE,EAA0B,OAAO,IAAI,UAAU,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE5G,OAAO,OAAO,MAAM,eAAe,CAAC;AAIpC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAIvC,uDAAuD;AACvD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAGlD,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,0CAA0C;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,SAAS,MAAM,WAAW,CAAC;AAyBlC,eAAe;AACf,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAA8B,EAAe,EAAE;IAChF,QAAQ,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAClC,KAAK,MAAM;YACT,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAC;QACrC,KAAK,MAAM;YACT,OAAO,4BAA4B,CAAC,KAAK,CAAC,CAAC;QAC7C,KAAK,eAAe;YAClB,OAAO,4BAA4B,CAAC,KAAK,CAAC,CAAC;QAC7C;YACE,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;Y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AAE,CAAC,CAAC,EAAE,EAAE;4BACf,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;gCACtB,aAAa,EAAE,CAAC;4BAClB,CAAC;wBACH,CAAC;wBAED,6CAAS,QAAQ,EAAI,CAChB,CACR,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,iCAAiC;YACjC,OAAO,SAAmC,CAAC;QAC7C,CAAC;KACF,CAAC;IACF,OAAO,0CAAG,KAAK,CAAC,MAAA,KAAK,CAAC,OAAO,CAAC,OAAO,mCAAI,EAAE,EAAE,OAAO,CAAC,CAAI,CAAC;AAC5D,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport React from 'react';\nimport { useEffect } from 'react';\nimport { _formatString } from '@internal/acs-ui-common';\nimport parse, { HTMLReactParserOptions, Element as DOMElement, attributesToProps } from 'html-react-parser';\n\nimport Linkify from 'react-linkify';\nimport { ChatMessage } from '../../types/ChatMessage';\n/* @conditional-compile-remove(data-loss-prevention) */\nimport { BlockedMessage } from '../../types/ChatMessage';\nimport { Link } from '@fluentui/react';\n/* @conditional-compile-remove(mention) */\nimport { MentionDisplayOptions, Mention } from '../MentionPopover';\n\n/* @conditional-compile-remove(data-loss-prevention) */\nimport { FontIcon, Stack } from '@fluentui/react';\nimport { MessageThreadStrings } from '../MessageThread';\nimport { AttachmentMetadata } from '../FileDownloadCards';\nimport LiveMessage from '../Announcer/LiveMessage';\n/* @conditional-compile-remove(mention) */\nimport { defaultOnMentionRender } from './MentionRenderer';\nimport DOMPurify from 'dompurify';\n\ntype ChatMessageContentProps = {\n message: ChatMessage;\n strings: MessageThreadStrings;\n /* @conditional-compile-remove(mention) */\n mentionDisplayOptions?: MentionDisplayOptions;\n attachmentsMap?: Record<string, string>;\n onFetchAttachments?: (attachments: AttachmentMetadata[], messageId: string) => Promise<void>;\n onInlineImageClicked?: (attachmentId: string) => void;\n};\n\n/* @conditional-compile-remove(data-loss-prevention) */\ntype BlockedMessageContentProps = {\n message: BlockedMessage;\n strings: MessageThreadStrings;\n};\n\ntype MessageContentWithLiveAriaProps = {\n message: ChatMessage | /* @conditional-compile-remove(data-loss-prevention) */ BlockedMessage;\n liveMessage: string;\n ariaLabel?: string;\n content: JSX.Element;\n};\n\n/** @private */\nexport const ChatMessageContent = (props: ChatMessageContentProps): JSX.Element => {\n switch (props.message.contentType) {\n case 'text':\n return MessageContentAsText(props);\n case 'html':\n return MessageContentAsRichTextHTML(props);\n case 'richtext/html':\n return MessageContentAsRichTextHTML(props);\n default:\n console.warn('unknown message content type');\n return <></>;\n }\n};\n\nconst MessageContentWithLiveAria = (props: MessageContentWithLiveAriaProps): JSX.Element => {\n return (\n <div data-ui-status={props.message.status} role=\"text\" aria-label={props.ariaLabel}>\n <LiveMessage message={props.liveMessage} ariaLive=\"polite\" />\n {props.content}\n </div>\n );\n};\n\nconst MessageContentAsRichTextHTML = (props: ChatMessageContentProps): JSX.Element => {\n const { message, attachmentsMap, onFetchAttachments } = props;\n useEffect(() => {\n if (!attachmentsMap || !onFetchAttachments) {\n return;\n }\n const attachments = message.inlineImages?.filter((inlinedImages) => {\n return attachmentsMap[inlinedImages.id] === undefined;\n });\n if (attachments && attachments.length > 0) {\n onFetchAttachments(attachments, message.messageId);\n }\n }, [message.inlineImages, message.messageId, onFetchAttachments, attachmentsMap]);\n\n return (\n <MessageContentWithLiveAria\n message={props.message}\n liveMessage={generateLiveMessage(props)}\n ariaLabel={messageContentAriaText(props)}\n content={processHtmlToReact(props)}\n />\n );\n};\n\nconst MessageContentAsText = (props: ChatMessageContentProps): JSX.Element => {\n return (\n <MessageContentWithLiveAria\n message={props.message}\n liveMessage={generateLiveMessage(props)}\n ariaLabel={messageContentAriaText(props)}\n content={\n <Linkify\n componentDecorator={(decoratedHref: string, decoratedText: string, key: number) => {\n return (\n <Link target=\"_blank\" href={decoratedHref} key={key}>\n {decoratedText}\n </Link>\n );\n }}\n >\n {props.message.content}\n </Linkify>\n }\n />\n );\n};\n\n/* @conditional-compile-remove(data-loss-prevention) */\n/**\n * @private\n */\nexport const BlockedMessageContent = (props: BlockedMessageContentProps): JSX.Element => {\n const Icon: JSX.Element = <FontIcon iconName={'DataLossPreventionProhibited'} />;\n const blockedMessage =\n props.message.warningText === undefined ? props.strings.blockedWarningText : props.message.warningText;\n const blockedMessageLink = props.message.link;\n const blockedMessageLinkText = blockedMessageLink\n ? props.message.linkText ?? props.strings.blockedWarningLinkText\n : '';\n\n const liveAuthor =\n props.message.mine || props.message.senderDisplayName === undefined ? '' : props.message.senderDisplayName;\n const liveBlockedWarningText = `${liveAuthor} ${blockedMessage} ${blockedMessageLinkText}`;\n return (\n <MessageContentWithLiveAria\n message={props.message}\n liveMessage={liveBlockedWarningText}\n ariaLabel={liveBlockedWarningText}\n content={\n <Stack horizontal wrap>\n {Icon}\n {blockedMessage && <p>{blockedMessage}</p>}\n {blockedMessageLink && (\n <Link target={'_blank'} href={blockedMessageLink}>\n {blockedMessageLinkText}\n </Link>\n )}\n </Stack>\n }\n />\n );\n};\n\n// https://stackoverflow.com/questions/28899298/extract-the-text-out-of-html-string-using-javascript\nconst extractContent = (s: string): string => {\n const span = document.createElement('span');\n span.innerHTML = s;\n return span.textContent || span.innerText;\n};\n\nconst generateLiveMessage = (props: ChatMessageContentProps): string => {\n const liveAuthor = _formatString(props.strings.liveAuthorIntro, { author: `${props.message.senderDisplayName}` });\n\n return `${props.message.editedOn ? props.strings.editedTag : ''} ${\n props.message.mine ? '' : liveAuthor\n } ${extractContent(props.message.content || '')} `;\n};\n\nconst messageContentAriaText = (props: ChatMessageContentProps): string | undefined => {\n // Strip all html tags from the content for aria.\n\n return props.message.content\n ? props.message.mine\n ? _formatString(props.strings.messageContentMineAriaText, {\n message: DOMPurify.sanitize(props.message.content, { ALLOWED_TAGS: [] })\n })\n : _formatString(props.strings.messageContentAriaText, {\n author: `${props.message.senderDisplayName}`,\n message: DOMPurify.sanitize(props.message.content, { ALLOWED_TAGS: [] })\n })\n : undefined;\n};\n\nconst processHtmlToReact = (props: ChatMessageContentProps): JSX.Element => {\n const options: HTMLReactParserOptions = {\n transform(reactNode, domNode) {\n if (domNode instanceof DOMElement && domNode.attribs) {\n // Transform custom rendering of mentions\n /* @conditional-compile-remove(mention) */\n if (props.mentionDisplayOptions?.onRenderMention && domNode.name === 'msft-mention') {\n const { id } = domNode.attribs;\n const mention: Mention = {\n id: id,\n displayText: (domNode.children[0] as unknown as Text).nodeValue ?? ''\n };\n return props.mentionDisplayOptions.onRenderMention(mention, defaultOnMentionRender);\n }\n\n // Transform inline images\n if (\n domNode.name &&\n domNode.name === 'img' &&\n domNode.attribs &&\n domNode.attribs.id &&\n props.message.inlineImages?.find((metadata) => {\n return metadata.id === domNode.attribs.id;\n })\n ) {\n domNode.attribs['aria-label'] = domNode.attribs.name;\n // logic to check id in map/list\n if (props.attachmentsMap && domNode.attribs.id in props.attachmentsMap) {\n domNode.attribs.src = props.attachmentsMap[domNode.attribs.id];\n }\n const handleOnClick = (): void => {\n props.onInlineImageClicked && props.onInlineImageClicked(domNode.attribs.id);\n };\n const imgProps = attributesToProps(domNode.attribs);\n return (\n <span\n data-ui-id={domNode.attribs.id}\n onClick={handleOnClick}\n tabIndex={0}\n role=\"button\"\n style={{\n cursor: 'pointer'\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n handleOnClick();\n }\n }}\n >\n <img {...imgProps} />\n </span>\n );\n }\n }\n // Pass through the original node\n return reactNode as unknown as JSX.Element;\n }\n };\n return <>{parse(props.message.content ?? '', options)}</>;\n};\n"]}
|
@@ -35,21 +35,46 @@ export type DtmfTone = 'A' | 'B' | 'C' | 'D' | 'Flash' | 'Num0' | 'Num1' | 'Num2
|
|
35
35
|
*/
|
36
36
|
export interface DialpadProps {
|
37
37
|
strings?: DialpadStrings;
|
38
|
-
/**
|
38
|
+
/**
|
39
|
+
* function to send dtmf tones on button click
|
40
|
+
*/
|
39
41
|
onSendDtmfTone?: (dtmfTone: DtmfTone) => Promise<void>;
|
40
|
-
/**
|
42
|
+
/**
|
43
|
+
* Callback for dialpad button behavior
|
44
|
+
*/
|
41
45
|
onClickDialpadButton?: (buttonValue: string, buttonIndex: number) => void;
|
42
|
-
/**
|
46
|
+
/**
|
47
|
+
* set dialpad textfield content
|
48
|
+
*/
|
43
49
|
textFieldValue?: string;
|
44
|
-
/**
|
50
|
+
/**
|
51
|
+
* on change function for text field, provides an unformatted plain text
|
52
|
+
*/
|
45
53
|
onChange?: (input: string) => void;
|
46
|
-
/**
|
54
|
+
/**
|
55
|
+
* flag to determine when to show/hide delete button, default true
|
56
|
+
*/
|
47
57
|
showDeleteButton?: boolean;
|
48
|
-
/**
|
58
|
+
/**
|
59
|
+
* flag to determine if dialpad is in mobile view, default false
|
60
|
+
*/
|
49
61
|
isMobile?: boolean;
|
62
|
+
/**
|
63
|
+
* Styles for customizing the dialpad component
|
64
|
+
*/
|
50
65
|
styles?: DialpadStyles;
|
51
|
-
/**
|
66
|
+
/**
|
67
|
+
* Disables DTMF sounds when dialpad buttons are pressed. the actual
|
68
|
+
* tones are still sent to the call.
|
69
|
+
*/
|
52
70
|
disableDtmfPlayback?: boolean;
|
71
|
+
/**
|
72
|
+
* Enable the ability to edit the number in the text box.
|
73
|
+
* This mode is for when dailing someone to call to that the user can edit the number before calling if needed.
|
74
|
+
* @default false
|
75
|
+
*
|
76
|
+
*/
|
77
|
+
enableInputEditing?: boolean;
|
53
78
|
}
|
54
79
|
/**
|
55
80
|
* A component to allow users to enter phone number through clicking on dialpad/using keyboard
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
10
10
|
});
|
11
11
|
};
|
12
12
|
import React, { useEffect } from 'react';
|
13
|
-
/* @conditional-compile-remove(dtmf-dialer) */
|
14
13
|
import { useRef } from 'react';
|
15
14
|
import { IconButton } from '@fluentui/react';
|
16
15
|
import { concatStyleSets, DefaultButton, FocusZone, mergeStyles, Stack, Text, TextField, useTheme } from '@fluentui/react';
|
@@ -20,7 +19,6 @@ import { useLocale } from '../../localization';
|
|
20
19
|
import { buttonStyles, containerStyles, iconButtonStyles, digitStyles, letterStyles, textFieldStyles } from '../styles/Dialpad.styles';
|
21
20
|
import { formatPhoneNumber } from '../utils/formatPhoneNumber';
|
22
21
|
import useLongPress from '../utils/useLongPress';
|
23
|
-
/* @conditional-compile-remove(dtmf-dialer) */
|
24
22
|
import { dtmfFrequencies, Tone } from './DTMFToneGenerator';
|
25
23
|
const dialPadButtonsDefault = [
|
26
24
|
[{ digit: '1' }, { digit: '2', letter: 'ABC' }, { digit: '3', letter: 'DEF' }],
|
@@ -53,12 +51,8 @@ const DtmfTones = [
|
|
53
51
|
const DialpadButton = (props) => {
|
54
52
|
var _a, _b, _c, _d;
|
55
53
|
const theme = useTheme();
|
56
|
-
const { digit, index, onClick, onLongPress, isMobile = false,
|
57
|
-
/* @conditional-compile-remove(dtmf-dialer) */ dtmfToneAudioContext,
|
58
|
-
/* @conditional-compile-remove(dtmf-dialer) */ disableDtmfPlayback } = props;
|
59
|
-
/* @conditional-compile-remove(dtmf-dialer) */
|
54
|
+
const { digit, index, onClick, onLongPress, isMobile = false, dtmfToneAudioContext, disableDtmfPlayback } = props;
|
60
55
|
const [buttonPressed, setButtonPressed] = useState(false);
|
61
|
-
/* @conditional-compile-remove(dtmf-dialer) */
|
62
56
|
const dtmfToneSound = useRef(new Tone(dtmfToneAudioContext, dtmfFrequencies[digit].f1, dtmfFrequencies[digit].f2));
|
63
57
|
const useLongPressProps = React.useMemo(() => ({
|
64
58
|
onClick: () => __awaiter(void 0, void 0, void 0, function* () {
|
@@ -71,7 +65,6 @@ const DialpadButton = (props) => {
|
|
71
65
|
}), [digit, index, isMobile, onClick, onLongPress]);
|
72
66
|
const longPressHandlers = useLongPress(useLongPressProps);
|
73
67
|
return (React.createElement(DefaultButton, Object.assign({ "data-test-id": `dialpad-button-${props.index}`, styles: concatStyleSets(buttonStyles(theme), (_a = props.styles) === null || _a === void 0 ? void 0 : _a.button) }, longPressHandlers, { onKeyDown: (e) => {
|
74
|
-
/* @conditional-compile-remove(dtmf-dialer) */
|
75
68
|
if ((e.key === 'Enter' || e.key === ' ') && !buttonPressed) {
|
76
69
|
if (!disableDtmfPlayback) {
|
77
70
|
dtmfToneSound.current.play();
|
@@ -82,7 +75,6 @@ const DialpadButton = (props) => {
|
|
82
75
|
}
|
83
76
|
longPressHandlers.onKeyDown();
|
84
77
|
}, onKeyUp: (e) => {
|
85
|
-
/* @conditional-compile-remove(dtmf-dialer) */
|
86
78
|
if ((e.key === 'Enter' || e.key === ' ') && buttonPressed) {
|
87
79
|
dtmfToneSound.current.stop();
|
88
80
|
longPressHandlers.onKeyUp();
|
@@ -90,26 +82,21 @@ const DialpadButton = (props) => {
|
|
90
82
|
}
|
91
83
|
longPressHandlers.onKeyUp();
|
92
84
|
}, onMouseDown: () => {
|
93
|
-
/* @conditional-compile-remove(dtmf-dialer) */
|
94
85
|
if (!disableDtmfPlayback) {
|
95
86
|
dtmfToneSound.current.play();
|
96
87
|
}
|
97
88
|
longPressHandlers.onMouseDown();
|
98
89
|
}, onMouseUp: () => {
|
99
|
-
/* @conditional-compile-remove(dtmf-dialer) */
|
100
90
|
dtmfToneSound.current.stop();
|
101
91
|
longPressHandlers.onMouseUp();
|
102
92
|
}, onMouseLeave: () => {
|
103
|
-
/* @conditional-compile-remove(dtmf-dialer) */
|
104
93
|
dtmfToneSound.current.stop();
|
105
94
|
}, onTouchStart: () => {
|
106
|
-
/* @conditional-compile-remove(dtmf-dialer) */
|
107
95
|
if (!disableDtmfPlayback) {
|
108
96
|
dtmfToneSound.current.play();
|
109
97
|
}
|
110
98
|
longPressHandlers.onTouchStart();
|
111
99
|
}, onTouchEnd: () => {
|
112
|
-
/* @conditional-compile-remove(dtmf-dialer) */
|
113
100
|
dtmfToneSound.current.stop();
|
114
101
|
longPressHandlers.onTouchEnd();
|
115
102
|
} }),
|
@@ -120,9 +107,8 @@ const DialpadButton = (props) => {
|
|
120
107
|
const DialpadContainer = (props) => {
|
121
108
|
var _a, _b;
|
122
109
|
const theme = useTheme();
|
123
|
-
const { onSendDtmfTone, onClickDialpadButton, textFieldValue, onChange, showDeleteButton = true, isMobile = false } = props;
|
110
|
+
const { onSendDtmfTone, onClickDialpadButton, textFieldValue, onChange, showDeleteButton = true, isMobile = false, disableDtmfPlayback, enableInputEditing } = props;
|
124
111
|
const [plainTextValue, setPlainTextValue] = useState(textFieldValue !== null && textFieldValue !== void 0 ? textFieldValue : '');
|
125
|
-
/* @conditional-compile-remove(dtmf-dialer) */
|
126
112
|
const dtmfToneAudioContext = useRef(new AudioContext());
|
127
113
|
useEffect(() => {
|
128
114
|
if (onChange) {
|
@@ -166,18 +152,16 @@ const DialpadContainer = (props) => {
|
|
166
152
|
setText(modifiedInput);
|
167
153
|
};
|
168
154
|
return (React.createElement("div", { className: mergeStyles(containerStyles(theme), (_a = props.styles) === null || _a === void 0 ? void 0 : _a.root), "data-test-id": "dialpadContainer", "data-ui-id": "dialpadContainer" },
|
169
|
-
React.createElement(TextField, { styles: concatStyleSets(textFieldStyles(theme), (_b = props.styles) === null || _b === void 0 ? void 0 : _b.textField), value: textFieldValue ? textFieldValue : formatPhoneNumber(plainTextValue),
|
155
|
+
React.createElement(TextField, { styles: concatStyleSets(textFieldStyles(theme), (_b = props.styles) === null || _b === void 0 ? void 0 : _b.textField), value: textFieldValue ? textFieldValue : enableInputEditing ? formatPhoneNumber(plainTextValue) : plainTextValue,
|
170
156
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
171
157
|
onChange: (e) => {
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
onClick: (e) => {
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
input.setSelectionRange(end, end);
|
180
|
-
input.focus();
|
158
|
+
if (enableInputEditing) {
|
159
|
+
setText(e.target.value);
|
160
|
+
}
|
161
|
+
}, onClick: (e) => {
|
162
|
+
if (!enableInputEditing) {
|
163
|
+
e.preventDefault();
|
164
|
+
}
|
181
165
|
}, placeholder: props.strings.placeholderText, "data-test-id": "dialpad-input", onRenderSuffix: () => {
|
182
166
|
var _a;
|
183
167
|
return (React.createElement(React.Fragment, null, showDeleteButton && plainTextValue.length !== 0 && (React.createElement(IconButton, { ariaLabel: props.strings.deleteButtonAriaLabel, onClick: deleteNumbers, styles: concatStyleSets(iconButtonStyles(theme), (_a = props.styles) === null || _a === void 0 ? void 0 : _a.deleteIcon), iconProps: { iconName: 'DialpadBackspace' } }))));
|
@@ -201,11 +185,7 @@ const DialpadContainer = (props) => {
|
|
201
185
|
then use this index to locate the corresponding dtmf tones
|
202
186
|
DtmfTones[index]
|
203
187
|
*/
|
204
|
-
index: columnIndex + rowIndex * rows.length, digit: button.digit, letter: button.letter, styles: props.styles, onClick: onClickDialpad, onLongPress: onLongPressDialpad, isMobile: isMobile,
|
205
|
-
/* @conditional-compile-remove(dtmf-dialer) */
|
206
|
-
dtmfToneAudioContext: dtmfToneAudioContext.current,
|
207
|
-
/* @conditional-compile-remove(dtmf-dialer) */
|
208
|
-
disableDtmfPlayback: props.disableDtmfPlayback })))));
|
188
|
+
index: columnIndex + rowIndex * rows.length, digit: button.digit, letter: button.letter, styles: props.styles, onClick: onClickDialpad, onLongPress: onLongPressDialpad, isMobile: isMobile, dtmfToneAudioContext: dtmfToneAudioContext.current, disableDtmfPlayback: disableDtmfPlayback })))));
|
209
189
|
}))));
|
210
190
|
};
|
211
191
|
/**
|