@azure/communication-react 1.11.1-alpha-202401140014 → 1.11.1-alpha-202401170012
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 +48 -25
- package/dist/dist-cjs/communication-react/index.js +482 -144
- 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/calling-component-bindings/src/callControlSelectors.d.ts +15 -0
- package/dist/dist-esm/calling-component-bindings/src/callControlSelectors.js +14 -0
- package/dist/dist-esm/calling-component-bindings/src/callControlSelectors.js.map +1 -1
- package/dist/dist-esm/calling-component-bindings/src/handlers/createCommonHandlers.d.ts +2 -0
- package/dist/dist-esm/calling-component-bindings/src/handlers/createCommonHandlers.js +23 -6
- package/dist/dist-esm/calling-component-bindings/src/handlers/createCommonHandlers.js.map +1 -1
- package/dist/dist-esm/calling-component-bindings/src/hooks/usePropsFor.js +12 -0
- package/dist/dist-esm/calling-component-bindings/src/hooks/usePropsFor.js.map +1 -1
- package/dist/dist-esm/calling-component-bindings/src/videoGallerySelector.js +1 -1
- package/dist/dist-esm/calling-component-bindings/src/videoGallerySelector.js.map +1 -1
- package/dist/dist-esm/chat-component-bindings/src/messageThreadSelector.js +17 -3
- package/dist/dist-esm/chat-component-bindings/src/messageThreadSelector.js.map +1 -1
- package/dist/dist-esm/chat-stateful-client/src/EventSubscriber.js +1 -0
- package/dist/dist-esm/chat-stateful-client/src/EventSubscriber.js.map +1 -1
- package/dist/dist-esm/communication-react/src/index.d.ts +2 -1
- package/dist/dist-esm/communication-react/src/index.js +1 -0
- package/dist/dist-esm/communication-react/src/index.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponent.d.ts +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponent.js +7 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponent.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentAsMessageBubble.d.ts +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentAsMessageBubble.js +34 -11
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentAsMessageBubble.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentWrapper.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageContent.js +17 -2
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageContent.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/FluentChatMessageComponentWrapper.js +17 -2
- package/dist/dist-esm/react-components/src/components/ChatMessage/FluentChatMessageComponentWrapper.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/FileDownloadCards.d.ts +6 -6
- package/dist/dist-esm/react-components/src/components/FileDownloadCards.js +8 -5
- package/dist/dist-esm/react-components/src/components/FileDownloadCards.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ImageGallery.d.ts +4 -4
- package/dist/dist-esm/react-components/src/components/ImageGallery.js +14 -3
- package/dist/dist-esm/react-components/src/components/ImageGallery.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/MessageThread.d.ts +2 -2
- package/dist/dist-esm/react-components/src/components/MessageThread.js +15 -3
- package/dist/dist-esm/react-components/src/components/MessageThread.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ReactionButton.d.ts +1 -1
- package/dist/dist-esm/react-components/src/components/ReactionButton.js +1 -1
- package/dist/dist-esm/react-components/src/components/ReactionButton.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/index.js +1 -0
- package/dist/dist-esm/react-components/src/components/index.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/ImageGallery.style.js +25 -19
- package/dist/dist-esm/react-components/src/components/styles/ImageGallery.style.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/ReactionButton.styles.d.ts +6 -2
- package/dist/dist-esm/react-components/src/components/styles/ReactionButton.styles.js +20 -4
- package/dist/dist-esm/react-components/src/components/styles/ReactionButton.styles.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/VideoTile.styles.js +4 -1
- package/dist/dist-esm/react-components/src/components/styles/VideoTile.styles.js.map +1 -1
- package/dist/dist-esm/react-components/src/localization/LocalizationProvider.js.map +1 -1
- package/dist/dist-esm/react-components/src/localization/locales/ar-SA/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/cs-CZ/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/de-DE/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/en-GB/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/es-ES/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/fi-FI/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/fr-FR/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/he-IL/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/it-IT/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/ja-JP/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/ko-KR/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/nb-NO/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/nl-NL/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/pl-PL/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/pt-BR/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/ru-RU/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/sv-SE/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/tr-TR/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/zh-CN/strings.json +5 -0
- package/dist/dist-esm/react-components/src/localization/locales/zh-TW/strings.json +5 -0
- package/dist/dist-esm/react-components/src/theming/icons.js +12 -2
- package/dist/dist-esm/react-components/src/theming/icons.js.map +1 -1
- package/dist/dist-esm/react-components/src/theming/themes.d.ts +9 -9
- package/dist/dist-esm/react-components/src/theming/themes.js +12 -10
- package/dist/dist-esm/react-components/src/theming/themes.js.map +1 -1
- package/dist/dist-esm/react-components/src/types/ChatMessage.d.ts +1 -1
- package/dist/dist-esm/react-components/src/types/ChatMessage.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/AzureCommunicationCallAdapter.d.ts +2 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/AzureCommunicationCallAdapter.js +10 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/AzureCommunicationCallAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/CallAdapter.d.ts +7 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/CallAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/CallControls.js +10 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/CallControls.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/buttons/Reaction.d.ts +13 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/buttons/Reaction.js +26 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/buttons/Reaction.js.map +1 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/hooks/useHandlers.js +4 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/hooks/useHandlers.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.d.ts +2 -0
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js +16 -2
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.d.ts +8 -0
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedCallAdapter.d.ts +2 -0
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedCallAdapter.js +2 -0
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedCallAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.js +1 -0
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreen.js +16 -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.d.ts +1 -2
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.js +16 -5
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapter.d.ts +1 -2
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/index.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/ControlBar/CommonCallControlBar.js +4 -0
- package/dist/dist-esm/react-composites/src/composites/common/ControlBar/CommonCallControlBar.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/icons.d.ts +2 -0
- package/dist/dist-esm/react-composites/src/composites/common/icons.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/types/CommonCallControlOptions.d.ts +7 -0
- package/dist/dist-esm/react-composites/src/composites/common/types/CommonCallControlOptions.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/ar-SA/strings.json +62 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/cs-CZ/strings.json +62 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/de-DE/strings.json +64 -2
- package/dist/dist-esm/react-composites/src/composites/localization/locales/en-GB/strings.json +62 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/es-ES/strings.json +62 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/fi-FI/strings.json +62 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/fr-FR/strings.json +62 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/he-IL/strings.json +62 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/it-IT/strings.json +62 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/ja-JP/strings.json +62 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/ko-KR/strings.json +62 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/nb-NO/strings.json +62 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/nl-NL/strings.json +62 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/pl-PL/strings.json +62 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/pt-BR/strings.json +62 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/ru-RU/strings.json +62 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/sv-SE/strings.json +62 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/tr-TR/strings.json +62 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/zh-CN/strings.json +62 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/zh-TW/strings.json +62 -0
- package/package.json +1 -1
@@ -39,13 +39,13 @@ export const _FileDownloadCards = (props) => {
|
|
39
39
|
return attachment.attachmentType === 'file';
|
40
40
|
return false;
|
41
41
|
}, []);
|
42
|
+
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
|
42
43
|
const isShowDownloadIcon = useCallback((attachment) => {
|
43
44
|
var _a;
|
44
45
|
/* @conditional-compile-remove(file-sharing) */
|
45
46
|
return attachment.attachmentType === 'file' && ((_a = attachment.payload) === null || _a === void 0 ? void 0 : _a.teamsFileAttachment) !== 'true';
|
46
47
|
return true;
|
47
48
|
}, []);
|
48
|
-
/* @conditional-compile-remove(file-sharing) */
|
49
49
|
const fileCardGroupDescription = useMemo(() => () => {
|
50
50
|
var _a, _b, _c, _d;
|
51
51
|
const fileGroupLocaleString = (_b = (_a = props.strings) === null || _a === void 0 ? void 0 : _a.fileCardGroupMessage) !== null && _b !== void 0 ? _b : localeStrings.fileCardGroupMessage;
|
@@ -78,11 +78,13 @@ export const _FileDownloadCards = (props) => {
|
|
78
78
|
}
|
79
79
|
}
|
80
80
|
}), [props]);
|
81
|
-
if (!fileMetadata ||
|
81
|
+
if (!fileMetadata ||
|
82
|
+
fileMetadata.length === 0 ||
|
83
|
+
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */ !fileMetadata.some(isFileSharingAttachment)) {
|
82
84
|
return React.createElement(React.Fragment, null);
|
83
85
|
}
|
84
86
|
return (React.createElement("div", { style: fileDownloadCardsStyle, "data-ui-id": "file-download-card-group" },
|
85
|
-
React.createElement(_FileCardGroup
|
87
|
+
React.createElement(_FileCardGroup, { ariaLabel: fileCardGroupDescription() }, fileMetadata &&
|
86
88
|
fileMetadata
|
87
89
|
.filter((attachment) => {
|
88
90
|
/* @conditional-compile-remove(file-sharing) */
|
@@ -91,7 +93,8 @@ export const _FileDownloadCards = (props) => {
|
|
91
93
|
})
|
92
94
|
.map((file) => file)
|
93
95
|
.map((file) => (React.createElement(TooltipHost, { content: downloadFileButtonString(), key: file.name },
|
94
|
-
React.createElement(_FileCard, { fileName: file.name, key: file.name, fileExtension: file.extension, actionIcon: showSpinner ? (React.createElement(Spinner, { size: SpinnerSize.medium, "aria-live": 'polite', role: 'status' })) : true &&
|
96
|
+
React.createElement(_FileCard, { fileName: file.name, key: file.name, fileExtension: file.extension, actionIcon: showSpinner ? (React.createElement(Spinner, { size: SpinnerSize.medium, "aria-live": 'polite', role: 'status' })) : true &&
|
97
|
+
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */ isShowDownloadIcon(file) ? (React.createElement(IconButton, { className: iconButtonClassName, ariaLabel: downloadFileButtonString() },
|
95
98
|
React.createElement(DownloadIconTrampoline, null))) : undefined, actionHandler: () => fileDownloadHandler(userId, file) })))))));
|
96
99
|
};
|
97
100
|
/**
|
@@ -104,7 +107,7 @@ const DownloadIconTrampoline = () => {
|
|
104
107
|
return React.createElement(Icon, { iconName: "EditBoxCancel", style: actionIconStyle });
|
105
108
|
};
|
106
109
|
const useLocaleStringsTrampoline = () => {
|
107
|
-
/* @conditional-compile-remove(file-sharing) */
|
110
|
+
/* @conditional-compile-remove(file-sharing) @conditional-compile-remove(teams-inline-images-and-file-sharing)*/
|
108
111
|
return useLocale().strings.messageThread;
|
109
112
|
return { downloadFile: '', fileCardGroupMessage: '' };
|
110
113
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"FileDownloadCards.js","sourceRoot":"","sources":["../../../../../../react-components/src/components/FileDownloadCards.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;AAElC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACtF,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,+CAA+C;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD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C,SAAS,EAAE,mBAAmB,EAAE,SAAS,EAAE,wBAAwB,EAAE;wBAC/E,oBAAC,sBAAsB,OAAG,CACf,CACd,CAAC,CAAC,CAAC,SAAS,EAEf,aAAa,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAqC,CAAC,GACvF,CACU,CACf,CAAC,CACS,CACb,CACP,CAAC;AACJ,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,sBAAsB,GAAG,GAAgB,EAAE;IAC/C,4CAA4C;IAC5C,OAAO,oBAAC,IAAI,kBAAY,kCAAkC,EAAC,QAAQ,EAAC,cAAc,EAAC,KAAK,EAAE,eAAe,GAAI,CAAC;IAC9G,+DAA+D;IAC/D,OAAO,oBAAC,IAAI,IAAC,QAAQ,EAAC,eAAe,EAAC,KAAK,EAAE,eAAe,GAAI,CAAC;AACnE,CAAC,CAAC;AAEF,MAAM,0BAA0B,GAAG,GAA8B,EAAE;IACjE,+CAA+C;IAC/C,OAAO,SAAS,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC;IACzC,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,oBAAoB,EAAE,EAAE,EAAE,CAAC;AACxD,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { Icon, IconButton, Spinner, SpinnerSize, TooltipHost } from '@fluentui/react';\nimport React, { useCallback, useState } from 'react';\nimport { useMemo } from 'react';\n/* @conditional-compile-remove(file-sharing) */\nimport { useLocale } from '../localization';\nimport { _FileCard } from './FileCard';\nimport { _FileCardGroup } from './FileCardGroup';\nimport { iconButtonClassName } from './styles/IconButton.styles';\nimport { _formatString } from '@internal/acs-ui-common';\n\n/**\n * Represents the type of attachment\n * @public\n */\nexport type ChatAttachmentType = 'inlineImage' | /* @conditional-compile-remove(file-sharing) */ 'file' | 'unknown';\n\n/**\n * Metadata containing basic information about the uploaded file.\n *\n * @beta\n */\nexport interface FileMetadata {\n attachmentType: 'file';\n /**\n * Extension hint, useful for rendering a specific icon.\n * An unknown or empty extension will be rendered as a generic icon.\n * Example: `pdf`\n */\n extension: string;\n /**\n * Unique ID of the file.\n */\n id: string;\n /**\n * File name to be displayed.\n */\n name: string;\n /**\n * Download URL for the file.\n */\n url: string;\n /*\n * Optional dictionary of meta data associated with the file.\n */\n payload?: Record<string, string>;\n}\n\n/**\n * Metadata for rendering images inline with a message.\n * This does not include images attached as files.\n * @public\n */\nexport interface InlineImageMetadata {\n /*\n * Type of the attachment\n */\n attachmentType: 'inlineImage';\n /**\n * Unique ID of the attachment.\n */\n id: string;\n /*\n * Preview URL for low resolution version.\n */\n previewUrl?: string;\n /**\n * Download URL for the full resolution version.\n */\n url: string;\n}\n\n/**\n * Metadata containing information about the uploaded file.\n * @public\n */\nexport type AttachmentMetadata = InlineImageMetadata | /* @conditional-compile-remove(file-sharing) */ FileMetadata;\n\n/**\n * Metadata of the attachment object returned by the ACS SDK.\n * @public\n */\nexport interface AttachmentDownloadResult {\n /**\n * Unique ID of the attachment.\n */\n attachmentId: string;\n /**\n * Blob URL for the attachment.\n */\n blobUrl: string;\n}\n\n/**\n * Strings of _FileDownloadCards that can be overridden.\n *\n * @internal\n */\nexport interface _FileDownloadCardsStrings {\n /** Aria label to notify user when focus is on file download button. */\n downloadFile: string;\n fileCardGroupMessage: string;\n}\n\n/**\n * @beta\n * A file download error returned via a {@link FileDownloadHandler}.\n * This error message is used to render an error message in the UI.\n */\nexport interface FileDownloadError {\n /** The error message to display in the UI */\n errorMessage: string;\n}\n\n/**\n * @beta\n *\n * A callback function for handling file downloads.\n * The function needs to return a promise that resolves to a file download URL.\n * If the promise is rejected, the {@link Error.message} will be used to display an error message to the user.\n *\n * @example\n * ```ts\n * const fileDownloadHandler: FileDownloadHandler = async (userId, fileData) => {\n * if (isUnauthorizedUser(userId)) {\n * return { errorMessage: 'You don’t have permission to download this file.' };\n * } else {\n * return new URL(fileData.url);\n * }\n * }\n *\n * const App = () => (\n * <ChatComposite\n * ...\n * fileSharing={{\n * fileDownloadHandler: fileDownloadHandler\n * }}\n * />\n * )\n *\n * ```\n * @param userId - The user ID of the user downloading the file.\n * @param fileMetadata - The {@link AttachmentMetadata} containing file `url`, `extension` and `name`.\n */\nexport type FileDownloadHandler = (\n userId: string,\n fileMetadata: AttachmentMetadata\n) => Promise<URL | FileDownloadError>;\n\n/**\n * @internal\n */\nexport interface _FileDownloadCardsProps {\n /**\n * User id of the local participant\n */\n userId: string;\n /**\n * A chat message metadata that includes file metadata\n */\n fileMetadata?: AttachmentMetadata[];\n /**\n * A function of type {@link FileDownloadHandler} for handling file downloads.\n * If the function is not specified, the file's `url` will be opened in a new tab to\n * initiate the download.\n */\n downloadHandler?: FileDownloadHandler;\n /**\n * Optional callback that runs if downloadHandler returns {@link FileDownloadError}.\n */\n onDownloadErrorMessage?: (errMsg: string) => void;\n /**\n * Optional aria label strings for file download cards\n */\n strings?: _FileDownloadCardsStrings;\n}\n\nconst fileDownloadCardsStyle = {\n marginTop: '0.25rem'\n};\n\nconst actionIconStyle = { height: '1rem' };\n\n/**\n * @internal\n */\nexport const _FileDownloadCards = (props: _FileDownloadCardsProps): JSX.Element => {\n const { userId, fileMetadata } = props;\n const [showSpinner, setShowSpinner] = useState(false);\n const localeStrings = useLocaleStringsTrampoline();\n\n const downloadFileButtonString = useMemo(\n () => () => {\n return props.strings?.downloadFile ?? localeStrings.downloadFile;\n },\n [props.strings?.downloadFile, localeStrings.downloadFile]\n );\n\n const isFileSharingAttachment = useCallback((attachment: AttachmentMetadata): boolean => {\n /* @conditional-compile-remove(file-sharing) */\n return attachment.attachmentType === 'file';\n return false;\n }, []);\n\n const isShowDownloadIcon = useCallback((attachment: AttachmentMetadata): boolean => {\n /* @conditional-compile-remove(file-sharing) */\n return attachment.attachmentType === 'file' && attachment.payload?.teamsFileAttachment !== 'true';\n return true;\n }, []);\n\n /* @conditional-compile-remove(file-sharing) */\n const fileCardGroupDescription = useMemo(\n () => () => {\n const fileGroupLocaleString = props.strings?.fileCardGroupMessage ?? localeStrings.fileCardGroupMessage;\n /* @conditional-compile-remove(file-sharing) */\n return _formatString(fileGroupLocaleString, {\n fileCount: `${fileMetadata?.filter(isFileSharingAttachment).length ?? 0}`\n });\n return _formatString(fileGroupLocaleString, {\n fileCount: `${fileMetadata?.length ?? 0}`\n });\n },\n [props.strings?.fileCardGroupMessage, localeStrings.fileCardGroupMessage, fileMetadata, isFileSharingAttachment]\n );\n\n const fileDownloadHandler = useCallback(\n async (userId: string, file: AttachmentMetadata) => {\n if (!props.downloadHandler) {\n window.open(file.url, '_blank', 'noopener,noreferrer');\n } else {\n setShowSpinner(true);\n try {\n const response = await props.downloadHandler(userId, file);\n setShowSpinner(false);\n if (response instanceof URL) {\n window.open(response.toString(), '_blank', 'noopener,noreferrer');\n } else {\n props.onDownloadErrorMessage && props.onDownloadErrorMessage(response.errorMessage);\n }\n } finally {\n setShowSpinner(false);\n }\n }\n },\n [props]\n );\n if (!fileMetadata || fileMetadata.length === 0 || !fileMetadata.some(isFileSharingAttachment)) {\n return <></>;\n }\n\n return (\n <div style={fileDownloadCardsStyle} data-ui-id=\"file-download-card-group\">\n <_FileCardGroup /* @conditional-compile-remove(file-sharing) */ ariaLabel={fileCardGroupDescription()}>\n {fileMetadata &&\n fileMetadata\n .filter((attachment) => {\n /* @conditional-compile-remove(file-sharing) */\n return isFileSharingAttachment(attachment);\n return true;\n })\n .map((file) => file as unknown as FileMetadata)\n .map((file) => (\n <TooltipHost content={downloadFileButtonString()} key={file.name}>\n <_FileCard\n fileName={file.name}\n key={file.name}\n fileExtension={file.extension}\n actionIcon={\n showSpinner ? (\n <Spinner size={SpinnerSize.medium} aria-live={'polite'} role={'status'} />\n ) : true && isShowDownloadIcon(file as unknown as AttachmentMetadata) ? (\n <IconButton className={iconButtonClassName} ariaLabel={downloadFileButtonString()}>\n <DownloadIconTrampoline />\n </IconButton>\n ) : undefined\n }\n actionHandler={() => fileDownloadHandler(userId, file as unknown as AttachmentMetadata)}\n />\n </TooltipHost>\n ))}\n </_FileCardGroup>\n </div>\n );\n};\n\n/**\n * @private\n */\nconst DownloadIconTrampoline = (): JSX.Element => {\n // @conditional-compile-remove(file-sharing)\n return <Icon data-ui-id=\"file-download-card-download-icon\" iconName=\"DownloadFile\" style={actionIconStyle} />;\n // Return _some_ available icon, as the real icon is beta-only.\n return <Icon iconName=\"EditBoxCancel\" style={actionIconStyle} />;\n};\n\nconst useLocaleStringsTrampoline = (): _FileDownloadCardsStrings => {\n /* @conditional-compile-remove(file-sharing) */\n return useLocale().strings.messageThread;\n return { downloadFile: '', fileCardGroupMessage: '' };\n};\n"]}
|
1
|
+
{"version":3,"file":"FileDownloadCards.js","sourceRoot":"","sources":["../../../../../../react-components/src/components/FileDownloadCards.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;AAElC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACtF,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,+CAA+C;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,mCAAgC;AAmLxD,MAAM,sBAAsB,GAAG;IAC7B,SAAS,EAAE,SAAS;CACrB,CAAC;AAEF,MAAM,eAAe,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAA8B,EAAe,EAAE;;IAChF,MAAM,EAAE,MAAM,EA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C/C,4CAA4C;IAC5C,OAAO,oBAAC,IAAI,kBAAY,kCAAkC,EAAC,QAAQ,EAAC,cAAc,EAAC,KAAK,EAAE,eAAe,GAAI,CAAC;IAC9G,+DAA+D;IAC/D,OAAO,oBAAC,IAAI,IAAC,QAAQ,EAAC,eAAe,EAAC,KAAK,EAAE,eAAe,GAAI,CAAC;AACnE,CAAC,CAAC;AAEF,MAAM,0BAA0B,GAAG,GAA8B,EAAE;IACjE,gHAAgH;IAChH,OAAO,SAAS,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC;IACzC,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,oBAAoB,EAAE,EAAE,EAAE,CAAC;AACxD,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { Icon, IconButton, Spinner, SpinnerSize, TooltipHost } from '@fluentui/react';\nimport React, { useCallback, useState } from 'react';\nimport { useMemo } from 'react';\n/* @conditional-compile-remove(file-sharing) */\nimport { useLocale } from '../localization';\nimport { _FileCard } from './FileCard';\nimport { _FileCardGroup } from './FileCardGroup';\nimport { iconButtonClassName } from './styles/IconButton.styles';\nimport { _formatString } from '@internal/acs-ui-common';\n\n/* @conditional-compile-remove(file-sharing) @conditional-compile-remove(teams-inline-images-and-file-sharing) */\n/**\n * Represents the type of attachment\n * @beta\n */\nexport type ChatAttachmentType =\n | 'unknown'\n | /* @conditional-compile-remove(teams-inline-images-and-file-sharing) */ 'inlineImage'\n | /* @conditional-compile-remove(file-sharing) */ 'file';\n\n/**\n * Metadata containing basic information about the uploaded file.\n *\n * @beta\n */\nexport interface FileMetadata {\n /* @conditional-compile-remove(file-sharing) */\n attachmentType: 'file';\n /**\n * Extension hint, useful for rendering a specific icon.\n * An unknown or empty extension will be rendered as a generic icon.\n * Example: `pdf`\n */\n extension: string;\n /**\n * Unique ID of the file.\n */\n /* @conditional-compile-remove(file-sharing) */\n id: string;\n /**\n * File name to be displayed.\n */\n name: string;\n /**\n * Download URL for the file.\n */\n url: string;\n /* @conditional-compile-remove(file-sharing) */\n /*\n * Optional dictionary of meta data associated with the file.\n */\n payload?: Record<string, string>;\n}\n\n/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */\n/**\n * Metadata for rendering images inline with a message.\n * This does not include images attached as files.\n * @beta\n */\nexport interface InlineImageMetadata {\n /*\n * Type of the attachment\n */\n attachmentType: 'inlineImage';\n /**\n * Unique ID of the attachment.\n */\n id: string;\n /*\n * Preview URL for low resolution version.\n */\n previewUrl?: string;\n /**\n * Download URL for the full resolution version.\n */\n url: string;\n}\n\n/**\n * Metadata containing information about the uploaded file.\n * @beta\n */\nexport type AttachmentMetadata =\n | FileMetadata\n | /* @conditional-compile-remove(teams-inline-images-and-file-sharing) */ InlineImageMetadata;\n\n/* @conditional-compile-remove(file-sharing) @conditional-compile-remove(teams-inline-images-and-file-sharing) */\n/**\n * Metadata of the attachment object returned by the ACS SDK.\n * @beta\n */\nexport interface AttachmentDownloadResult {\n /**\n * Unique ID of the attachment.\n */\n attachmentId: string;\n /**\n * Blob URL for the attachment.\n */\n blobUrl: string;\n}\n\n/**\n * Strings of _FileDownloadCards that can be overridden.\n *\n * @internal\n */\nexport interface _FileDownloadCardsStrings {\n /** Aria label to notify user when focus is on file download button. */\n downloadFile: string;\n fileCardGroupMessage: string;\n}\n\n/**\n * @beta\n * A file download error returned via a {@link FileDownloadHandler}.\n * This error message is used to render an error message in the UI.\n */\nexport interface FileDownloadError {\n /** The error message to display in the UI */\n errorMessage: string;\n}\n\n/**\n * @beta\n *\n * A callback function for handling file downloads.\n * The function needs to return a promise that resolves to a file download URL.\n * If the promise is rejected, the {@link Error.message} will be used to display an error message to the user.\n *\n * @example\n * ```ts\n * const fileDownloadHandler: FileDownloadHandler = async (userId, fileData) => {\n * if (isUnauthorizedUser(userId)) {\n * return { errorMessage: 'You don’t have permission to download this file.' };\n * } else {\n * return new URL(fileData.url);\n * }\n * }\n *\n * const App = () => (\n * <ChatComposite\n * ...\n * fileSharing={{\n * fileDownloadHandler: fileDownloadHandler\n * }}\n * />\n * )\n *\n * ```\n * @param userId - The user ID of the user downloading the file.\n * @param fileMetadata - The {@link AttachmentMetadata} containing file `url`, `extension` and `name`.\n */\nexport type FileDownloadHandler = (\n userId: string,\n fileMetadata: AttachmentMetadata\n) => Promise<URL | FileDownloadError>;\n\n/**\n * @internal\n */\nexport interface _FileDownloadCardsProps {\n /**\n * User id of the local participant\n */\n userId: string;\n /**\n * A chat message metadata that includes file metadata\n */\n fileMetadata?: AttachmentMetadata[];\n /**\n * A function of type {@link FileDownloadHandler} for handling file downloads.\n * If the function is not specified, the file's `url` will be opened in a new tab to\n * initiate the download.\n */\n downloadHandler?: FileDownloadHandler;\n /**\n * Optional callback that runs if downloadHandler returns {@link FileDownloadError}.\n */\n onDownloadErrorMessage?: (errMsg: string) => void;\n /**\n * Optional aria label strings for file download cards\n */\n strings?: _FileDownloadCardsStrings;\n}\n\nconst fileDownloadCardsStyle = {\n marginTop: '0.25rem'\n};\n\nconst actionIconStyle = { height: '1rem' };\n\n/**\n * @internal\n */\nexport const _FileDownloadCards = (props: _FileDownloadCardsProps): JSX.Element => {\n const { userId, fileMetadata } = props;\n const [showSpinner, setShowSpinner] = useState(false);\n const localeStrings = useLocaleStringsTrampoline();\n\n const downloadFileButtonString = useMemo(\n () => () => {\n return props.strings?.downloadFile ?? localeStrings.downloadFile;\n },\n [props.strings?.downloadFile, localeStrings.downloadFile]\n );\n\n const isFileSharingAttachment = useCallback((attachment: AttachmentMetadata): boolean => {\n /* @conditional-compile-remove(file-sharing) */\n return attachment.attachmentType === 'file';\n return false;\n }, []);\n\n /* @conditional-compile-remove(teams-inline-images-and-file-sharing) */\n const isShowDownloadIcon = useCallback((attachment: AttachmentMetadata): boolean => {\n /* @conditional-compile-remove(file-sharing) */\n return attachment.attachmentType === 'file' && attachment.payload?.teamsFileAttachment !== 'true';\n return true;\n }, []);\n\n const fileCardGroupDescription = useMemo(\n () => () => {\n const fileGroupLocaleString = props.strings?.fileCardGroupMessage ?? localeStrings.fileCardGroupMessage;\n /* @conditional-compile-remove(file-sharing) */\n return _formatString(fileGroupLocaleString, {\n fileCount: `${fileMetadata?.filter(isFileSharingAttachment).length ?? 0}`\n });\n return _formatString(fileGroupLocaleString, {\n fileCount: `${fileMetadata?.length ?? 0}`\n });\n },\n [props.strings?.fileCardGroupMessage, localeStrings.fileCardGroupMessage, fileMetadata, isFileSharingAttachment]\n );\n\n const fileDownloadHandler = useCallback(\n async (userId: string, file: AttachmentMetadata) => {\n if (!props.downloadHandler) {\n window.open(file.url, '_blank', 'noopener,noreferrer');\n } else {\n setShowSpinner(true);\n try {\n const response = await props.downloadHandler(userId, file);\n setShowSpinner(false);\n if (response instanceof URL) {\n window.open(response.toString(), '_blank', 'noopener,noreferrer');\n } else {\n props.onDownloadErrorMessage && props.onDownloadErrorMessage(response.errorMessage);\n }\n } finally {\n setShowSpinner(false);\n }\n }\n },\n [props]\n );\n if (\n !fileMetadata ||\n fileMetadata.length === 0 ||\n /* @conditional-compile-remove(teams-inline-images-and-file-sharing) */ !fileMetadata.some(isFileSharingAttachment)\n ) {\n return <></>;\n }\n\n return (\n <div style={fileDownloadCardsStyle} data-ui-id=\"file-download-card-group\">\n <_FileCardGroup ariaLabel={fileCardGroupDescription()}>\n {fileMetadata &&\n fileMetadata\n .filter((attachment) => {\n /* @conditional-compile-remove(file-sharing) */\n return isFileSharingAttachment(attachment);\n return true;\n })\n .map((file) => file as unknown as FileMetadata)\n .map((file) => (\n <TooltipHost content={downloadFileButtonString()} key={file.name}>\n <_FileCard\n fileName={file.name}\n key={file.name}\n fileExtension={file.extension}\n actionIcon={\n showSpinner ? (\n <Spinner size={SpinnerSize.medium} aria-live={'polite'} role={'status'} />\n ) : true &&\n /* @conditional-compile-remove(teams-inline-images-and-file-sharing) */ isShowDownloadIcon(\n file as unknown as AttachmentMetadata\n ) ? (\n <IconButton className={iconButtonClassName} ariaLabel={downloadFileButtonString()}>\n <DownloadIconTrampoline />\n </IconButton>\n ) : undefined\n }\n actionHandler={() => fileDownloadHandler(userId, file as unknown as AttachmentMetadata)}\n />\n </TooltipHost>\n ))}\n </_FileCardGroup>\n </div>\n );\n};\n\n/**\n * @private\n */\nconst DownloadIconTrampoline = (): JSX.Element => {\n // @conditional-compile-remove(file-sharing)\n return <Icon data-ui-id=\"file-download-card-download-icon\" iconName=\"DownloadFile\" style={actionIconStyle} />;\n // Return _some_ available icon, as the real icon is beta-only.\n return <Icon iconName=\"EditBoxCancel\" style={actionIconStyle} />;\n};\n\nconst useLocaleStringsTrampoline = (): _FileDownloadCardsStrings => {\n /* @conditional-compile-remove(file-sharing) @conditional-compile-remove(teams-inline-images-and-file-sharing)*/\n return useLocale().strings.messageThread;\n return { downloadFile: '', fileCardGroupMessage: '' };\n};\n"]}
|
@@ -2,7 +2,7 @@ import { SyntheticEvent } from 'react';
|
|
2
2
|
/**
|
3
3
|
* Props for {@link ImageGallery}.
|
4
4
|
*
|
5
|
-
* @
|
5
|
+
* @beta
|
6
6
|
*/
|
7
7
|
export interface ImageGalleryImageProps {
|
8
8
|
/** Image Url used to display the image in a large scale. */
|
@@ -19,7 +19,7 @@ export interface ImageGalleryImageProps {
|
|
19
19
|
/**
|
20
20
|
* Props for {@link ImageGallery}.
|
21
21
|
*
|
22
|
-
* @
|
22
|
+
* @beta
|
23
23
|
*/
|
24
24
|
export interface ImageGalleryProps {
|
25
25
|
/**
|
@@ -50,7 +50,7 @@ export interface ImageGalleryProps {
|
|
50
50
|
/**
|
51
51
|
* Strings of {@link ImageGallery} that can be overridden.
|
52
52
|
*
|
53
|
-
* @
|
53
|
+
* @beta
|
54
54
|
*/
|
55
55
|
export interface ImageGalleryStrings {
|
56
56
|
/**
|
@@ -65,7 +65,7 @@ export interface ImageGalleryStrings {
|
|
65
65
|
/**
|
66
66
|
* Component to render a fullscreen modal for a selected image.
|
67
67
|
*
|
68
|
-
* @
|
68
|
+
* @beta
|
69
69
|
*/
|
70
70
|
export declare const ImageGallery: (props: ImageGalleryProps) => JSX.Element;
|
71
71
|
//# sourceMappingURL=ImageGallery.d.ts.map
|
@@ -1,18 +1,25 @@
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
2
2
|
// Licensed under the MIT License.
|
3
|
+
/* @conditional-compile-remove(image-gallery) */
|
3
4
|
import { DefaultButton, Icon, IconButton, Modal, Stack, mergeStyles } from '@fluentui/react';
|
5
|
+
/* @conditional-compile-remove(image-gallery) */
|
4
6
|
import React, { useState } from 'react';
|
7
|
+
/* @conditional-compile-remove(image-gallery) */
|
5
8
|
import { bodyContainer, brokenImageStyle, cancelIcon, closeButtonStyles, controlBarContainerStyle, downloadButtonStyle, downloadIcon, downloadIconStyle, focusTrapZoneStyle, headerStyle, normalImageStyle, overlayStyles, scrollableContentStyle, smallDownloadButtonContainerStyle, titleBarContainerStyle, titleStyle } from './styles/ImageGallery.style';
|
9
|
+
/* @conditional-compile-remove(image-gallery) */
|
6
10
|
import { useTheme } from '../theming/FluentThemeProvider';
|
11
|
+
/* @conditional-compile-remove(image-gallery) */
|
7
12
|
import { useLocale } from '../localization';
|
13
|
+
/* @conditional-compile-remove(image-gallery) */
|
8
14
|
/**
|
9
15
|
* Component to render a fullscreen modal for a selected image.
|
10
16
|
*
|
11
|
-
* @
|
17
|
+
* @beta
|
12
18
|
*/
|
13
19
|
export const ImageGallery = (props) => {
|
14
20
|
const { isOpen, images, onImageDownloadButtonClicked, onDismiss, onError, startIndex = 0 } = props;
|
15
21
|
const theme = useTheme();
|
22
|
+
/* @conditional-compile-remove(image-gallery) */
|
16
23
|
const localeStrings = useLocale().strings.imageGallery;
|
17
24
|
const [isImageLoaded, setIsImageLoaded] = useState(true);
|
18
25
|
const imageStyle = isImageLoaded ? normalImageStyle : brokenImageStyle(theme);
|
@@ -23,9 +30,13 @@ export const ImageGallery = (props) => {
|
|
23
30
|
image.titleIcon,
|
24
31
|
React.createElement(Stack.Item, { className: mergeStyles(titleStyle(theme)), "aria-label": image === null || image === void 0 ? void 0 : image.title }, image === null || image === void 0 ? void 0 : image.title)),
|
25
32
|
React.createElement(Stack, { className: mergeStyles(controlBarContainerStyle) },
|
26
|
-
React.createElement(DefaultButton, { className: mergeStyles(downloadButtonStyle(theme)),
|
33
|
+
React.createElement(DefaultButton, { className: mergeStyles(downloadButtonStyle(theme)),
|
34
|
+
/* @conditional-compile-remove(image-gallery) */
|
35
|
+
text: localeStrings.downloadButtonLabel, onClick: () => onImageDownloadButtonClicked((image === null || image === void 0 ? void 0 : image.imageUrl) || '', (image === null || image === void 0 ? void 0 : image.downloadFilename) || 'image'), onRenderIcon: () => React.createElement(Icon, { iconName: downloadIcon.iconName, className: mergeStyles(downloadIconStyle) }), "aria-live": 'polite', "aria-label": localeStrings.downloadButtonLabel }),
|
27
36
|
React.createElement(IconButton, { iconProps: downloadIcon, className: mergeStyles(smallDownloadButtonContainerStyle(theme)), onClick: () => onImageDownloadButtonClicked(image === null || image === void 0 ? void 0 : image.imageUrl, image === null || image === void 0 ? void 0 : image.downloadFilename), "aria-label": localeStrings.downloadButtonLabel, "aria-live": 'polite' }),
|
28
|
-
React.createElement(IconButton, { iconProps: cancelIcon, className: mergeStyles(closeButtonStyles(theme)), onClick: onDismiss,
|
37
|
+
React.createElement(IconButton, { iconProps: cancelIcon, className: mergeStyles(closeButtonStyles(theme)), onClick: onDismiss,
|
38
|
+
/* @conditional-compile-remove(image-gallery) */
|
39
|
+
ariaLabel: localeStrings.dismissButtonAriaLabel, "aria-live": 'polite' }))));
|
29
40
|
};
|
30
41
|
const renderBodyWithLightDismiss = () => {
|
31
42
|
return (React.createElement(Stack, { className: mergeStyles(bodyContainer), onClick: () => props.onDismiss() }, images.length > startIndex && (React.createElement("img", { src: image === null || image === void 0 ? void 0 : image.imageUrl, className: mergeStyles(imageStyle), alt: (image === null || image === void 0 ? void 0 : image.altText) || 'image', "aria-label": 'image-gallery-main-image', "aria-live": 'polite', onError: (event) => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Image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AChD,MAAM,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,EAC/E,aAAa,EAAE,IAAI;QAElB,eAAe,EAAE;QACjB,0BAA0B,EAAE,CACvB,CACT,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { DefaultButton, Icon, IconButton, Modal, Stack, mergeStyles } from '@fluentui/react';\nimport React, { SyntheticEvent, useState } from 'react';\n\nimport {\n bodyContainer,\n brokenImageStyle,\n cancelIcon,\n closeButtonStyles,\n controlBarContainerStyle,\n downloadButtonStyle,\n downloadIcon,\n downloadIconStyle,\n focusTrapZoneStyle,\n headerStyle,\n normalImageStyle,\n overlayStyles,\n scrollableContentStyle,\n smallDownloadButtonContainerStyle,\n titleBarContainerStyle,\n titleStyle\n} from './styles/ImageGallery.style';\nimport { useTheme } from '../theming/FluentThemeProvider';\nimport { useLocale } from '../localization';\nimport { ChatTheme } from '../theming';\n/**\n * Props for {@link ImageGallery}.\n *\n * @public\n */\nexport interface ImageGalleryImageProps {\n /** Image Url used to display the image in a large scale. */\n imageUrl: string;\n /** String used as a file name when downloading this image to user's local device. */\n downloadFilename: string;\n /** Optional string used as a alt text for the image. @default 'image' */\n altText?: string;\n /** Optional string used as the title of the image and displayed on the top left corner of the ImageGallery. */\n title?: string;\n /** Optional JSX element used as a title icon and displayed to the left of the title element. */\n titleIcon?: JSX.Element;\n}\n\n/**\n * Props for {@link ImageGallery}.\n *\n * @public\n */\nexport interface ImageGalleryProps {\n /**\n * Boolean that controls whether the modal is displayed.\n */\n isOpen: boolean;\n /**\n * Array of images used to populate the ImageGallery\n */\n images: Array<ImageGalleryImageProps>;\n /**\n * Callback to invoke when the ImageGallery modal is dismissed\n */\n onDismiss: () => void;\n /**\n * Callback called when the download button is clicked.\n */\n onImageDownloadButtonClicked: (imageUrl: string, downloadFilename: string) => void;\n /**\n * Callback called when there's an error loading the image.\n */\n onError?: (event: SyntheticEvent<HTMLImageElement, Event>) => void;\n /**\n * Indicating which index of the images array to start with.\n */\n startIndex?: number;\n}\n\n/**\n * Strings of {@link ImageGallery} that can be overridden.\n *\n * @public\n */\nexport interface ImageGalleryStrings {\n /**\n * Download button label for ImageGallery\n */\n downloadButtonLabel: string;\n /**\n * Dismiss button aria label for ImageGallery\n */\n dismissButtonAriaLabel: string;\n}\n\n/**\n * Component to render a fullscreen modal for a selected image.\n *\n * @public\n */\nexport const ImageGallery = (props: ImageGalleryProps): JSX.Element => {\n const { isOpen, images, onImageDownloadButtonClicked, onDismiss, onError, startIndex = 0 } = props;\n const theme = useTheme() as unknown as ChatTheme;\n\n const localeStrings = useLocale().strings.imageGallery;\n\n const [isImageLoaded, setIsImageLoaded] = useState<boolean>(true);\n\n const imageStyle = isImageLoaded ? normalImageStyle : brokenImageStyle(theme);\n\n const image = images[startIndex];\n const renderHeaderBar = (): JSX.Element => {\n return (\n <Stack className={mergeStyles(headerStyle)}>\n <Stack className={mergeStyles(titleBarContainerStyle)}>\n {image?.titleIcon}\n <Stack.Item className={mergeStyles(titleStyle(theme))} aria-label={image?.title}>\n {image?.title}\n </Stack.Item>\n </Stack>\n <Stack className={mergeStyles(controlBarContainerStyle)}>\n <DefaultButton\n className={mergeStyles(downloadButtonStyle(theme))}\n text={localeStrings.downloadButtonLabel}\n onClick={() => onImageDownloadButtonClicked(image?.imageUrl || '', image?.downloadFilename || 'image')}\n onRenderIcon={() => <Icon iconName={downloadIcon.iconName} className={mergeStyles(downloadIconStyle)} />}\n aria-live={'polite'}\n aria-label={localeStrings.downloadButtonLabel}\n />\n <IconButton\n iconProps={downloadIcon}\n className={mergeStyles(smallDownloadButtonContainerStyle(theme))}\n onClick={() => onImageDownloadButtonClicked(image?.imageUrl, image?.downloadFilename)}\n aria-label={localeStrings.downloadButtonLabel}\n aria-live={'polite'}\n />\n <IconButton\n iconProps={cancelIcon}\n className={mergeStyles(closeButtonStyles(theme))}\n onClick={onDismiss}\n ariaLabel={localeStrings.dismissButtonAriaLabel}\n aria-live={'polite'}\n />\n </Stack>\n </Stack>\n );\n };\n\n const renderBodyWithLightDismiss = (): JSX.Element => {\n return (\n <Stack className={mergeStyles(bodyContainer)} onClick={() => props.onDismiss()}>\n {images.length > startIndex && (\n <img\n src={image?.imageUrl}\n className={mergeStyles(imageStyle)}\n alt={image?.altText || 'image'}\n aria-label={'image-gallery-main-image'}\n aria-live={'polite'}\n onError={(event) => {\n setIsImageLoaded(false);\n onError && onError(event);\n }}\n onClick={(event) => event.stopPropagation()}\n onDoubleClick={(event) => {\n event.persist();\n }}\n />\n )}\n </Stack>\n );\n };\n\n return (\n <Modal\n titleAriaId={image?.title}\n isOpen={isOpen}\n onDismiss={onDismiss}\n overlay={{ styles: { ...overlayStyles(theme) } }}\n styles={{ main: focusTrapZoneStyle, scrollableContent: scrollableContentStyle }}\n isDarkOverlay={true}\n >\n {renderHeaderBar()}\n {renderBodyWithLightDismiss()}\n </Modal>\n );\n};\n"]}
|
1
|
+
{"version":3,"file":"ImageGallery.js","sourceRoot":"","sources":["../../../../../../react-components/src/components/ImageGallery.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,gDAAgD;AAChD,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC7F,gDAAgD;AAChD,OAAO,KAAK,EAAE,EAAkB,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxD,gDAAgD;AAChD,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,sBAAsB,EACtB,iCAAiC,EACjC,sBAAsB,EACtB,UAAU,EACX,MAAM,6BAA6B,CAAC;AACrC,gDAAgD;AAChD,OAAO,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B,6BACE,GAAG,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,EACpB,SAAS,EAAE,WAAW,CAAC,UAAU,CAAC,EAClC,GAAG,EAAE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,KAAI,OAAO,gBAClB,0BAA0B,eAC3B,QAAQ,EACnB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;gBACjB,gBAAgB,CAAC,KAAK,CAAC,CAAC;gBACxB,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC,EACD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,eAAe,EAAE,EAC3C,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE;gBACvB,KAAK,CAAC,OAAO,EAAE,CAAC;YAClB,CAAC,GACD,CACH,CACK,CACT,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,KAAK,IACJ,WAAW,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,EACzB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,EAAE,MAAM,oBAAO,aAAa,CAAC,KAAK,CAAC,CAAE,EAAE,EAChD,MAAM,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,EAC/E,aAAa,EAAE,IAAI;QAElB,eAAe,EAAE;QACjB,0BAA0B,EAAE,CACvB,CACT,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/* @conditional-compile-remove(image-gallery) */\nimport { DefaultButton, Icon, IconButton, Modal, Stack, mergeStyles } from '@fluentui/react';\n/* @conditional-compile-remove(image-gallery) */\nimport React, { SyntheticEvent, useState } from 'react';\n/* @conditional-compile-remove(image-gallery) */\nimport {\n bodyContainer,\n brokenImageStyle,\n cancelIcon,\n closeButtonStyles,\n controlBarContainerStyle,\n downloadButtonStyle,\n downloadIcon,\n downloadIconStyle,\n focusTrapZoneStyle,\n headerStyle,\n normalImageStyle,\n overlayStyles,\n scrollableContentStyle,\n smallDownloadButtonContainerStyle,\n titleBarContainerStyle,\n titleStyle\n} from './styles/ImageGallery.style';\n/* @conditional-compile-remove(image-gallery) */\nimport { useTheme } from '../theming/FluentThemeProvider';\n/* @conditional-compile-remove(image-gallery) */\nimport { useLocale } from '../localization';\n/* @conditional-compile-remove(image-gallery) */\nimport { ChatTheme } from '../theming';\n/**\n * Props for {@link ImageGallery}.\n *\n * @beta\n */\nexport interface ImageGalleryImageProps {\n /** Image Url used to display the image in a large scale. */\n imageUrl: string;\n /** String used as a file name when downloading this image to user's local device. */\n downloadFilename: string;\n /** Optional string used as a alt text for the image. @default 'image' */\n altText?: string;\n /** Optional string used as the title of the image and displayed on the top left corner of the ImageGallery. */\n title?: string;\n /** Optional JSX element used as a title icon and displayed to the left of the title element. */\n titleIcon?: JSX.Element;\n}\n/* @conditional-compile-remove(image-gallery) */\n/**\n * Props for {@link ImageGallery}.\n *\n * @beta\n */\nexport interface ImageGalleryProps {\n /**\n * Boolean that controls whether the modal is displayed.\n */\n isOpen: boolean;\n /**\n * Array of images used to populate the ImageGallery\n */\n images: Array<ImageGalleryImageProps>;\n /**\n * Callback to invoke when the ImageGallery modal is dismissed\n */\n onDismiss: () => void;\n /**\n * Callback called when the download button is clicked.\n */\n onImageDownloadButtonClicked: (imageUrl: string, downloadFilename: string) => void;\n /**\n * Callback called when there's an error loading the image.\n */\n onError?: (event: SyntheticEvent<HTMLImageElement, Event>) => void;\n /**\n * Indicating which index of the images array to start with.\n */\n startIndex?: number;\n}\n/* @conditional-compile-remove(image-gallery) */\n/**\n * Strings of {@link ImageGallery} that can be overridden.\n *\n * @beta\n */\nexport interface ImageGalleryStrings {\n /**\n * Download button label for ImageGallery\n */\n downloadButtonLabel: string;\n /**\n * Dismiss button aria label for ImageGallery\n */\n dismissButtonAriaLabel: string;\n}\n/* @conditional-compile-remove(image-gallery) */\n/**\n * Component to render a fullscreen modal for a selected image.\n *\n * @beta\n */\nexport const ImageGallery = (props: ImageGalleryProps): JSX.Element => {\n const { isOpen, images, onImageDownloadButtonClicked, onDismiss, onError, startIndex = 0 } = props;\n const theme = useTheme() as unknown as ChatTheme;\n\n /* @conditional-compile-remove(image-gallery) */\n const localeStrings = useLocale().strings.imageGallery;\n\n const [isImageLoaded, setIsImageLoaded] = useState<boolean>(true);\n\n const imageStyle = isImageLoaded ? normalImageStyle : brokenImageStyle(theme);\n\n const image = images[startIndex];\n const renderHeaderBar = (): JSX.Element => {\n return (\n <Stack className={mergeStyles(headerStyle)}>\n <Stack className={mergeStyles(titleBarContainerStyle)}>\n {image?.titleIcon}\n <Stack.Item className={mergeStyles(titleStyle(theme))} aria-label={image?.title}>\n {image?.title}\n </Stack.Item>\n </Stack>\n <Stack className={mergeStyles(controlBarContainerStyle)}>\n <DefaultButton\n className={mergeStyles(downloadButtonStyle(theme))}\n /* @conditional-compile-remove(image-gallery) */\n text={localeStrings.downloadButtonLabel}\n onClick={() => onImageDownloadButtonClicked(image?.imageUrl || '', image?.downloadFilename || 'image')}\n onRenderIcon={() => <Icon iconName={downloadIcon.iconName} className={mergeStyles(downloadIconStyle)} />}\n aria-live={'polite'}\n /* @conditional-compile-remove(image-gallery) */\n aria-label={localeStrings.downloadButtonLabel}\n />\n <IconButton\n iconProps={downloadIcon}\n className={mergeStyles(smallDownloadButtonContainerStyle(theme))}\n onClick={() => onImageDownloadButtonClicked(image?.imageUrl, image?.downloadFilename)}\n /* @conditional-compile-remove(image-gallery) */\n aria-label={localeStrings.downloadButtonLabel}\n aria-live={'polite'}\n />\n <IconButton\n iconProps={cancelIcon}\n className={mergeStyles(closeButtonStyles(theme))}\n onClick={onDismiss}\n /* @conditional-compile-remove(image-gallery) */\n ariaLabel={localeStrings.dismissButtonAriaLabel}\n aria-live={'polite'}\n />\n </Stack>\n </Stack>\n );\n };\n\n const renderBodyWithLightDismiss = (): JSX.Element => {\n return (\n <Stack className={mergeStyles(bodyContainer)} onClick={() => props.onDismiss()}>\n {images.length > startIndex && (\n <img\n src={image?.imageUrl}\n className={mergeStyles(imageStyle)}\n alt={image?.altText || 'image'}\n aria-label={'image-gallery-main-image'}\n aria-live={'polite'}\n onError={(event) => {\n setIsImageLoaded(false);\n onError && onError(event);\n }}\n onClick={(event) => event.stopPropagation()}\n onDoubleClick={(event) => {\n event.persist();\n }}\n />\n )}\n </Stack>\n );\n };\n\n return (\n <Modal\n titleAriaId={image?.title}\n isOpen={isOpen}\n onDismiss={onDismiss}\n overlay={{ styles: { ...overlayStyles(theme) } }}\n styles={{ main: focusTrapZoneStyle, scrollableContent: scrollableContentStyle }}\n isDarkOverlay={true}\n >\n {renderHeaderBar()}\n {renderBodyWithLightDismiss()}\n </Modal>\n );\n};\n"]}
|
@@ -238,7 +238,7 @@ export type MessageThreadProps = {
|
|
238
238
|
/**
|
239
239
|
* Optional callback to retrieve the inline image in a message.
|
240
240
|
* @param attachment - AttachmentMetadata object we want to render
|
241
|
-
* @
|
241
|
+
* @beta
|
242
242
|
*/
|
243
243
|
onFetchAttachments?: (attachments: AttachmentMetadata[]) => Promise<AttachmentDownloadResult[]>;
|
244
244
|
/**
|
@@ -301,7 +301,7 @@ export type MessageThreadProps = {
|
|
301
301
|
mentionOptions?: MentionOptions;
|
302
302
|
/**
|
303
303
|
* Optional callback called when an inline image is clicked.
|
304
|
-
* @
|
304
|
+
* @beta
|
305
305
|
*/
|
306
306
|
onInlineImageClicked?: (attachmentId: string, messageId: string) => Promise<void>;
|
307
307
|
};
|
@@ -161,9 +161,13 @@ export const MessageThreadWrapper = (props) => {
|
|
161
161
|
var _a;
|
162
162
|
const { messages: newMessages, userId, participantCount, readReceiptsBySenderId, styles, disableJumpToNewMessageButton = false, showMessageDate = false, showMessageStatus = false, numberOfChatMessagesToReload = 5, onMessageSeen, onRenderMessageStatus, onRenderAvatar, onLoadPreviousChatMessages, onRenderJumpToNewMessageButton, onRenderMessage, onUpdateMessage, onCancelEditMessage, onDeleteMessage, onSendMessage,
|
163
163
|
/* @conditional-compile-remove(date-time-customization) */
|
164
|
-
onDisplayDateTimeString,
|
164
|
+
onDisplayDateTimeString,
|
165
|
+
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
|
166
|
+
onFetchAttachments,
|
165
167
|
/* @conditional-compile-remove(mention) */
|
166
|
-
mentionOptions,
|
168
|
+
mentionOptions,
|
169
|
+
/* @conditional-compile-remove(image-gallery) */
|
170
|
+
onInlineImageClicked,
|
167
171
|
/* @conditional-compile-remove(file-sharing) */
|
168
172
|
onRenderFileDownloads } = props;
|
169
173
|
// We need this state to wait for one tick and scroll to bottom after messages have been initialized.
|
@@ -180,7 +184,9 @@ export const MessageThreadWrapper = (props) => {
|
|
180
184
|
const [lastSendingChatMessage, setLastSendingChatMessage] = useState(undefined);
|
181
185
|
// readCount and participantCount will only need to be updated on-fly when user hover on an indicator
|
182
186
|
const [readCountForHoveredIndicator, setReadCountForHoveredIndicator] = useState(undefined);
|
187
|
+
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
|
183
188
|
const [inlineAttachments, setInlineAttachments] = useState({});
|
189
|
+
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
|
184
190
|
const onFetchInlineAttachment = useCallback((attachments, messageId) => __awaiter(void 0, void 0, void 0, function* () {
|
185
191
|
if (!onFetchAttachments || attachments.length === 0) {
|
186
192
|
return;
|
@@ -497,7 +503,13 @@ export const MessageThreadWrapper = (props) => {
|
|
497
503
|
className: mergeClasses(classes.root, mergeStyles(styles === null || styles === void 0 ? void 0 : styles.chatContainer)), ref: chatScrollDivRef, style: Object.assign({}, createStyleFromV8Style(styles === null || styles === void 0 ? void 0 : styles.chatContainer)) }, messagesToDisplay.map((message) => {
|
498
504
|
return (React.createElement(MemoChatMessageComponentWrapper, Object.assign({}, message, { userId: userId, key: message.key, styles: styles, shouldOverlapAvatarAndMessage: isNarrow, strings: strings, onRenderAvatar: onRenderAvatar, onRenderMessage: onRenderMessage, onRenderMessageStatus: onRenderMessageStatus, defaultStatusRenderer: defaultStatusRenderer, onActionButtonClick: onActionButtonClickMemo, readCount: readCountForHoveredIndicator, participantCount: participantCount,
|
499
505
|
/* @conditional-compile-remove(file-sharing) */
|
500
|
-
fileDownloadHandler: props.fileDownloadHandler,
|
506
|
+
fileDownloadHandler: props.fileDownloadHandler,
|
507
|
+
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
|
508
|
+
onFetchInlineAttachment: onFetchInlineAttachment,
|
509
|
+
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
|
510
|
+
inlineAttachments: inlineAttachments,
|
511
|
+
/* @conditional-compile-remove(image-gallery) */
|
512
|
+
onInlineImageClicked: onInlineImageClicked,
|
501
513
|
/* @conditional-compile-remove(date-time-customization) */
|
502
514
|
onDisplayDateTimeString: onDisplayDateTimeString,
|
503
515
|
/* @conditional-compile-remove(mention) */
|