@azure/communication-react 1.27.0-alpha-202505130018 → 1.27.0-alpha-202505140018
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 +103 -12
- package/dist/dist-cjs/communication-react/{ChatMessageComponentAsRichTextEditBox-lebdeYFI.js → ChatMessageComponentAsRichTextEditBox-D-rMS-Hv.js} +2 -2
- package/dist/dist-cjs/communication-react/{ChatMessageComponentAsRichTextEditBox-lebdeYFI.js.map → ChatMessageComponentAsRichTextEditBox-D-rMS-Hv.js.map} +1 -1
- package/dist/dist-cjs/communication-react/{RichTextSendBoxWrapper-BG5TP-SA.js → RichTextSendBoxWrapper-CkWpS6-b.js} +2 -2
- package/dist/dist-cjs/communication-react/{RichTextSendBoxWrapper-BG5TP-SA.js.map → RichTextSendBoxWrapper-CkWpS6-b.js.map} +1 -1
- package/dist/dist-cjs/communication-react/{index-BHKNAQgT.js → index-Qeoq3j5U.js} +11 -12
- package/dist/dist-cjs/communication-react/{index-BHKNAQgT.js.map → index-Qeoq3j5U.js.map} +1 -1
- package/dist/dist-cjs/communication-react/index.js +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/acs-ui-javascript-loaders/src/callCompositeLoader.d.ts +25 -3
- package/dist/dist-esm/acs-ui-javascript-loaders/src/callCompositeLoader.js +12 -2
- package/dist/dist-esm/acs-ui-javascript-loaders/src/callCompositeLoader.js.map +1 -1
- package/dist/dist-esm/acs-ui-javascript-loaders/src/callWithChatCompositeLoader.d.ts +29 -3
- package/dist/dist-esm/acs-ui-javascript-loaders/src/callWithChatCompositeLoader.js +12 -2
- package/dist/dist-esm/acs-ui-javascript-loaders/src/callWithChatCompositeLoader.js.map +1 -1
- package/dist/dist-esm/acs-ui-javascript-loaders/src/chatCompositeLoader.d.ts +21 -3
- package/dist/dist-esm/acs-ui-javascript-loaders/src/chatCompositeLoader.js +11 -2
- package/dist/dist-esm/acs-ui-javascript-loaders/src/chatCompositeLoader.js.map +1 -1
- package/dist/dist-esm/acs-ui-javascript-loaders/src/outboundCallCompositeLoader.d.ts +28 -3
- package/dist/dist-esm/acs-ui-javascript-loaders/src/outboundCallCompositeLoader.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/CaptionsBanner.js +5 -7
- package/dist/dist-esm/react-components/src/components/CaptionsBanner.js.map +1 -1
- package/package.json +1 -1
@@ -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.27.0-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.27.0-alpha-202505140018';\n"]}
|
@@ -9,16 +9,38 @@ import { AzureCommunicationCallAdapterOptions, CallAdapter, CallAdapterLocator,
|
|
9
9
|
*
|
10
10
|
* @public
|
11
11
|
*/
|
12
|
-
export
|
12
|
+
export interface CallCompositeLoaderProps extends Partial<BaseCompositeProps<CallCompositeIcons>> {
|
13
|
+
/**
|
14
|
+
* UserId for the local user.
|
15
|
+
*/
|
13
16
|
userId: CommunicationUserIdentifier;
|
17
|
+
/**
|
18
|
+
* CommunicationTokenCredential for the local user.
|
19
|
+
*/
|
14
20
|
credential: CommunicationTokenCredential;
|
21
|
+
/**
|
22
|
+
* Display name for the local user.
|
23
|
+
*/
|
15
24
|
displayName: string;
|
25
|
+
/**
|
26
|
+
* locator for the call
|
27
|
+
*/
|
16
28
|
locator: CallAdapterLocator;
|
29
|
+
/**
|
30
|
+
* Options for the {@link AzureCommunicationCallAdapter}
|
31
|
+
* This is used to configure the call adapter.
|
32
|
+
*/
|
17
33
|
callAdapterOptions?: AzureCommunicationCallAdapterOptions;
|
34
|
+
/**
|
35
|
+
* Options for the {@link CallComposite} {@link CallCompositeOptions}
|
36
|
+
* This is used to configure the call composite.
|
37
|
+
*/
|
18
38
|
callCompositeOptions?: CallCompositeOptions;
|
19
|
-
|
39
|
+
/**
|
40
|
+
* Device form factor for the composite.
|
41
|
+
*/
|
20
42
|
formFactor?: 'mobile' | 'desktop';
|
21
|
-
}
|
43
|
+
}
|
22
44
|
/**
|
23
45
|
* Loader function for the CallComposite that you can use in your application. This
|
24
46
|
* function will load the CallComposite into the provided HTML element. The best use case for this
|
@@ -26,7 +26,7 @@ import { initializeIcons } from '@fluentui/react';
|
|
26
26
|
export const loadCallComposite = function (loaderArgs, htmlElement) {
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
28
28
|
initializeIcons();
|
29
|
-
const { userId, credential, displayName, locator, callAdapterOptions, callCompositeOptions,
|
29
|
+
const { userId, credential, displayName, locator, callAdapterOptions, callCompositeOptions, formFactor, fluentTheme, icons, onFetchAvatarPersonaData, onFetchParticipantMenuItems, rtl, locale } = loaderArgs;
|
30
30
|
const adapter = yield createAzureCommunicationCallAdapter({
|
31
31
|
userId,
|
32
32
|
displayName: displayName !== null && displayName !== void 0 ? displayName : 'anonymous',
|
@@ -37,7 +37,17 @@ export const loadCallComposite = function (loaderArgs, htmlElement) {
|
|
37
37
|
if (!htmlElement) {
|
38
38
|
throw new Error('Failed to find the root element');
|
39
39
|
}
|
40
|
-
createRoot(htmlElement).render(React.createElement(CallComposite,
|
40
|
+
createRoot(htmlElement).render(React.createElement(CallComposite, {
|
41
|
+
options: callCompositeOptions,
|
42
|
+
adapter,
|
43
|
+
formFactor,
|
44
|
+
fluentTheme,
|
45
|
+
icons,
|
46
|
+
locale,
|
47
|
+
onFetchAvatarPersonaData,
|
48
|
+
onFetchParticipantMenuItems,
|
49
|
+
rtl
|
50
|
+
}, null));
|
41
51
|
return adapter;
|
42
52
|
});
|
43
53
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"callCompositeLoader.js","sourceRoot":"","sources":["../../../../../acs-ui-javascript-loaders/src/callCompositeLoader.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;AAElC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC;AACnC,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EACL,aAAa,EACb,mCAAmC,EAOpC,gDAAmC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"callCompositeLoader.js","sourceRoot":"","sources":["../../../../../acs-ui-javascript-loaders/src/callCompositeLoader.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;AAElC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC;AACnC,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EACL,aAAa,EACb,mCAAmC,EAOpC,gDAAmC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AA4ClD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAC/B,UAAoC,EACpC,WAAwB;;QAExB,eAAe,EAAE,CAAC;QAClB,MAAM,EACJ,MAAM,EACN,UAAU,EACV,WAAW,EACX,OAAO,EACP,kBAAkB,EAClB,oBAAoB,EACpB,UAAU,EACV,WAAW,EACX,KAAK,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,GAAG,EACH,MAAM,EACP,GAAG,UAAU,CAAC;QACf,MAAM,OAAO,GAAG,MAAM,mCAAmC,CAAC;YACxD,MAAM;YACN,WAAW,EAAE,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,WAAW;YACvC,UAAU;YACV,OAAO;YACP,OAAO,EAAE,kBAAkB;SAC5B,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QAED,UAAU,CAAC,WAAW,CAAC,CAAC,MAAM,CAC5B,KAAK,CAAC,aAAa,CACjB,aAAa,EACb;YACE,OAAO,EAAE,oBAAoB;YAC7B,OAAO;YACP,UAAU;YACV,WAAW;YACX,KAAK;YACL,MAAM;YACN,wBAAwB;YACxB,2BAA2B;YAC3B,GAAG;SACJ,EACD,IAAI,CACL,CACF,CAAC;QACF,OAAO,OAAO,CAAC;IACjB,CAAC;CAAA,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport React from 'react';\nimport { parseReactVersion } from './utils';\n\nconst reactVersion = React.version;\nparseReactVersion(reactVersion);\n\nimport { createRoot } from 'react-dom/client';\nimport { CommunicationTokenCredential, CommunicationUserIdentifier } from '@azure/communication-common';\nimport {\n CallComposite,\n createAzureCommunicationCallAdapter,\n AzureCommunicationCallAdapterOptions,\n CallAdapter,\n CallAdapterLocator,\n CallCompositeOptions,\n BaseCompositeProps,\n CallCompositeIcons\n} from '@internal/react-composites';\nimport { initializeIcons } from '@fluentui/react';\n\n/**\n * Props for the OutboundCallComposite that you can use in your application.\n *\n * Contains two options bags:\n * - adapterOptions: Options for the {@link AzureCommunicationCallAdapter}\n * - callCompositeOptions: Options for the {@link CallComposite} {@link CallCompositeOptions}\n *\n * @public\n */\nexport interface CallCompositeLoaderProps extends Partial<BaseCompositeProps<CallCompositeIcons>> {\n /**\n * UserId for the local user.\n */\n userId: CommunicationUserIdentifier;\n /**\n * CommunicationTokenCredential for the local user.\n */\n credential: CommunicationTokenCredential;\n /**\n * Display name for the local user.\n */\n displayName: string;\n /**\n * locator for the call\n */\n locator: CallAdapterLocator;\n /**\n * Options for the {@link AzureCommunicationCallAdapter}\n * This is used to configure the call adapter.\n */\n callAdapterOptions?: AzureCommunicationCallAdapterOptions;\n /**\n * Options for the {@link CallComposite} {@link CallCompositeOptions}\n * This is used to configure the call composite.\n */\n callCompositeOptions?: CallCompositeOptions;\n /**\n * Device form factor for the composite.\n */\n formFactor?: 'mobile' | 'desktop';\n}\n\n/**\n * Loader function for the CallComposite that you can use in your application. This\n * function will load the CallComposite into the provided HTML element. The best use case for this\n * is in a Node ui framework that is not React based.\n *\n * @public\n */\nexport const loadCallComposite = async function (\n loaderArgs: CallCompositeLoaderProps,\n htmlElement: HTMLElement\n): Promise<CallAdapter | undefined> {\n initializeIcons();\n const {\n userId,\n credential,\n displayName,\n locator,\n callAdapterOptions,\n callCompositeOptions,\n formFactor,\n fluentTheme,\n icons,\n onFetchAvatarPersonaData,\n onFetchParticipantMenuItems,\n rtl,\n locale\n } = loaderArgs;\n const adapter = await createAzureCommunicationCallAdapter({\n userId,\n displayName: displayName ?? 'anonymous',\n credential,\n locator,\n options: callAdapterOptions\n });\n\n if (!htmlElement) {\n throw new Error('Failed to find the root element');\n }\n\n createRoot(htmlElement).render(\n React.createElement(\n CallComposite,\n {\n options: callCompositeOptions,\n adapter,\n formFactor,\n fluentTheme,\n icons,\n locale,\n onFetchAvatarPersonaData,\n onFetchParticipantMenuItems,\n rtl\n },\n null\n )\n );\n return adapter;\n};\n"]}
|
@@ -8,17 +8,43 @@ import { CallWithChatAdapter, CallAndChatLocator, CallWithChatCompositeOptions,
|
|
8
8
|
* - callCompositeOptions: Options for the {@link CallWithChatComposite} {@link CallWithChatCompositeOptions}
|
9
9
|
* @public
|
10
10
|
*/
|
11
|
-
export
|
11
|
+
export interface CallWithChatCompositeLoaderProps extends Partial<BaseCompositeProps<CallWithChatCompositeIcons>> {
|
12
|
+
/**
|
13
|
+
* UserId for the local user.
|
14
|
+
*/
|
12
15
|
userId: CommunicationUserIdentifier;
|
16
|
+
/**
|
17
|
+
* CommunicationTokenCredential for the local user.
|
18
|
+
*/
|
13
19
|
credential: CommunicationTokenCredential;
|
20
|
+
/**
|
21
|
+
* Display name for the local user.
|
22
|
+
*/
|
14
23
|
displayName: string;
|
24
|
+
/**
|
25
|
+
* Azure communication service endpoint. This used for the token and joining the chat thread.
|
26
|
+
*/
|
15
27
|
endpoint: string;
|
28
|
+
/**
|
29
|
+
* Locator for the call and the chat thread.
|
30
|
+
* This is used to join the call and the chat thread.
|
31
|
+
*/
|
16
32
|
locator: CallAndChatLocator;
|
33
|
+
/**
|
34
|
+
* Options for the {@link AzureCommunicationCallAdapterOptions}
|
35
|
+
* This is used to configure the call adapter.
|
36
|
+
*/
|
17
37
|
callAdapterOptions?: AzureCommunicationCallAdapterOptions;
|
38
|
+
/**
|
39
|
+
* Options for the {@link CallWithChatComposite} {@link CallWithChatCompositeOptions}
|
40
|
+
* This is used to configure the call composite.
|
41
|
+
*/
|
18
42
|
callWithChatCompositeOptions?: CallWithChatCompositeOptions;
|
19
|
-
|
43
|
+
/**
|
44
|
+
* Device form factor for the composite.
|
45
|
+
*/
|
20
46
|
formFactor?: 'mobile' | 'desktop';
|
21
|
-
}
|
47
|
+
}
|
22
48
|
/**
|
23
49
|
* Props for the CallWithChatComposite that you can use in your application. This
|
24
50
|
* function will load the CallWithChatComposite into the provided HTML element.
|
@@ -26,7 +26,7 @@ import { initializeIcons } from '@fluentui/react';
|
|
26
26
|
export const loadCallWithChatComposite = function (loaderArgs, htmlElement) {
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
28
28
|
initializeIcons();
|
29
|
-
const { userId, credential, displayName, endpoint, locator, callAdapterOptions, callWithChatCompositeOptions,
|
29
|
+
const { userId, credential, displayName, endpoint, locator, callAdapterOptions, callWithChatCompositeOptions, formFactor, fluentTheme, locale, icons, onFetchAvatarPersonaData, onFetchParticipantMenuItems, rtl } = loaderArgs;
|
30
30
|
const adapter = yield createAzureCommunicationCallWithChatAdapter({
|
31
31
|
userId,
|
32
32
|
displayName: displayName !== null && displayName !== void 0 ? displayName : 'anonymous',
|
@@ -38,7 +38,17 @@ export const loadCallWithChatComposite = function (loaderArgs, htmlElement) {
|
|
38
38
|
if (!htmlElement) {
|
39
39
|
throw new Error('Failed to find the root element');
|
40
40
|
}
|
41
|
-
createRoot(htmlElement).render(React.createElement(CallWithChatComposite,
|
41
|
+
createRoot(htmlElement).render(React.createElement(CallWithChatComposite, {
|
42
|
+
options: callWithChatCompositeOptions,
|
43
|
+
adapter,
|
44
|
+
formFactor,
|
45
|
+
fluentTheme,
|
46
|
+
icons,
|
47
|
+
locale,
|
48
|
+
onFetchAvatarPersonaData,
|
49
|
+
onFetchParticipantMenuItems,
|
50
|
+
rtl
|
51
|
+
}, null));
|
42
52
|
return adapter;
|
43
53
|
});
|
44
54
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"callWithChatCompositeLoader.js","sourceRoot":"","sources":["../../../../../acs-ui-javascript-loaders/src/callWithChatCompositeLoader.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;AAElC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC;AACnC,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAIL,2CAA2C,EAC3C,qBAAqB,EAItB,gDAAmC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"callWithChatCompositeLoader.js","sourceRoot":"","sources":["../../../../../acs-ui-javascript-loaders/src/callWithChatCompositeLoader.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;AAElC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC;AACnC,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAIL,2CAA2C,EAC3C,qBAAqB,EAItB,gDAAmC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAgDlD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,UACvC,UAA4C,EAC5C,WAAwB;;QAExB,eAAe,EAAE,CAAC;QAClB,MAAM,EACJ,MAAM,EACN,UAAU,EACV,WAAW,EACX,QAAQ,EACR,OAAO,EACP,kBAAkB,EAClB,4BAA4B,EAC5B,UAAU,EACV,WAAW,EACX,MAAM,EACN,KAAK,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,GAAG,EACJ,GAAG,UAAU,CAAC;QACf,MAAM,OAAO,GAAG,MAAM,2CAA2C,CAAC;YAChE,MAAM;YACN,WAAW,EAAE,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,WAAW;YACvC,UAAU;YACV,QAAQ,EAAE,QAAQ;YAClB,OAAO,EAAE,OAAO;YAChB,kBAAkB;SACnB,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QAED,UAAU,CAAC,WAAW,CAAC,CAAC,MAAM,CAC5B,KAAK,CAAC,aAAa,CACjB,qBAAqB,EACrB;YACE,OAAO,EAAE,4BAA4B;YACrC,OAAO;YACP,UAAU;YACV,WAAW;YACX,KAAK;YACL,MAAM;YACN,wBAAwB;YACxB,2BAA2B;YAC3B,GAAG;SACJ,EACD,IAAI,CACL,CACF,CAAC;QACF,OAAO,OAAO,CAAC;IACjB,CAAC;CAAA,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport React from 'react';\nimport { parseReactVersion } from './utils';\n\nconst reactVersion = React.version;\nparseReactVersion(reactVersion);\n\nimport { createRoot } from 'react-dom/client';\nimport { CommunicationTokenCredential, CommunicationUserIdentifier } from '@azure/communication-common';\nimport {\n CallWithChatAdapter,\n CallAndChatLocator,\n CallWithChatCompositeOptions,\n createAzureCommunicationCallWithChatAdapter,\n CallWithChatComposite,\n AzureCommunicationCallAdapterOptions,\n BaseCompositeProps,\n CallWithChatCompositeIcons\n} from '@internal/react-composites';\nimport { initializeIcons } from '@fluentui/react';\n\n/**\n * Props for the CallWithChatComposite that you can use in your application.\n *\n * Contains two options bags:\n * - adapterOptions: Options for the {@link AzureCommunicationCallAdapterOptions}\n * - callCompositeOptions: Options for the {@link CallWithChatComposite} {@link CallWithChatCompositeOptions}\n * @public\n */\nexport interface CallWithChatCompositeLoaderProps extends Partial<BaseCompositeProps<CallWithChatCompositeIcons>> {\n /**\n * UserId for the local user.\n */\n userId: CommunicationUserIdentifier;\n /**\n * CommunicationTokenCredential for the local user.\n */\n credential: CommunicationTokenCredential;\n /**\n * Display name for the local user.\n */\n displayName: string;\n /**\n * Azure communication service endpoint. This used for the token and joining the chat thread.\n */\n endpoint: string;\n /**\n * Locator for the call and the chat thread.\n * This is used to join the call and the chat thread.\n */\n locator: CallAndChatLocator;\n /**\n * Options for the {@link AzureCommunicationCallAdapterOptions}\n * This is used to configure the call adapter.\n */\n callAdapterOptions?: AzureCommunicationCallAdapterOptions;\n /**\n * Options for the {@link CallWithChatComposite} {@link CallWithChatCompositeOptions}\n * This is used to configure the call composite.\n */\n callWithChatCompositeOptions?: CallWithChatCompositeOptions;\n /**\n * Device form factor for the composite.\n */\n formFactor?: 'mobile' | 'desktop';\n}\n\n/**\n * Props for the CallWithChatComposite that you can use in your application. This\n * function will load the CallWithChatComposite into the provided HTML element.\n * The best use case for this is in a Node UI framework that is not React based.\n *\n * @public\n */\nexport const loadCallWithChatComposite = async function (\n loaderArgs: CallWithChatCompositeLoaderProps,\n htmlElement: HTMLElement\n): Promise<CallWithChatAdapter | undefined> {\n initializeIcons();\n const {\n userId,\n credential,\n displayName,\n endpoint,\n locator,\n callAdapterOptions,\n callWithChatCompositeOptions,\n formFactor,\n fluentTheme,\n locale,\n icons,\n onFetchAvatarPersonaData,\n onFetchParticipantMenuItems,\n rtl\n } = loaderArgs;\n const adapter = await createAzureCommunicationCallWithChatAdapter({\n userId,\n displayName: displayName ?? 'anonymous',\n credential,\n endpoint: endpoint,\n locator: locator,\n callAdapterOptions\n });\n\n if (!htmlElement) {\n throw new Error('Failed to find the root element');\n }\n\n createRoot(htmlElement).render(\n React.createElement(\n CallWithChatComposite,\n {\n options: callWithChatCompositeOptions,\n adapter,\n formFactor,\n fluentTheme,\n icons,\n locale,\n onFetchAvatarPersonaData,\n onFetchParticipantMenuItems,\n rtl\n },\n null\n )\n );\n return adapter;\n};\n"]}
|
@@ -5,15 +5,33 @@ import { BaseCompositeProps, ChatAdapter, ChatCompositeIcons, ChatCompositeOptio
|
|
5
5
|
* options for the {@link ChatComposite} {@link ChatCompositeOptions}.
|
6
6
|
* @public
|
7
7
|
*/
|
8
|
-
export
|
8
|
+
export interface ChatCompositeLoaderProps extends Partial<BaseCompositeProps<ChatCompositeIcons>> {
|
9
|
+
/**
|
10
|
+
* UserId for the local user.
|
11
|
+
*/
|
9
12
|
userId: CommunicationUserIdentifier;
|
13
|
+
/**
|
14
|
+
* CommunicationTokenCredential for the local user.
|
15
|
+
*/
|
10
16
|
credential: CommunicationTokenCredential;
|
17
|
+
/**
|
18
|
+
* Display name for the local user.
|
19
|
+
*/
|
11
20
|
displayName?: string;
|
21
|
+
/**
|
22
|
+
* Communication service endpoint. This is used for the token and joining the chat thread.
|
23
|
+
*/
|
12
24
|
endpoint: string;
|
25
|
+
/**
|
26
|
+
* Communication threadId for the chat thread.
|
27
|
+
*/
|
13
28
|
threadId: string;
|
29
|
+
/**
|
30
|
+
* Options for the {@link AzureCommunicationChatAdapter}
|
31
|
+
* This is used to configure the chat adapter.
|
32
|
+
*/
|
14
33
|
chatCompositeOptions?: ChatCompositeOptions;
|
15
|
-
|
16
|
-
};
|
34
|
+
}
|
17
35
|
/**
|
18
36
|
* Loader function for the ChatComposite that you can use in your application. This
|
19
37
|
* function will load the ChatComposite into the provided HTML element.
|
@@ -26,7 +26,7 @@ import { initializeIcons } from '@fluentui/react';
|
|
26
26
|
export const loadChatComposite = function (loaderArgs, htmlElement) {
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
28
28
|
initializeIcons();
|
29
|
-
const { userId, credential, endpoint, threadId, displayName, chatCompositeOptions,
|
29
|
+
const { userId, credential, endpoint, threadId, displayName, chatCompositeOptions, fluentTheme, locale, icons, onFetchAvatarPersonaData, onFetchParticipantMenuItems, rtl } = loaderArgs;
|
30
30
|
const adapter = yield createAzureCommunicationChatAdapter({
|
31
31
|
endpoint,
|
32
32
|
userId,
|
@@ -37,7 +37,16 @@ export const loadChatComposite = function (loaderArgs, htmlElement) {
|
|
37
37
|
if (!htmlElement) {
|
38
38
|
throw new Error('Failed to find the root element');
|
39
39
|
}
|
40
|
-
createRoot(htmlElement).render(React.createElement(ChatComposite,
|
40
|
+
createRoot(htmlElement).render(React.createElement(ChatComposite, {
|
41
|
+
options: chatCompositeOptions,
|
42
|
+
adapter,
|
43
|
+
fluentTheme,
|
44
|
+
icons,
|
45
|
+
locale,
|
46
|
+
onFetchAvatarPersonaData,
|
47
|
+
onFetchParticipantMenuItems,
|
48
|
+
rtl
|
49
|
+
}, null));
|
41
50
|
return adapter;
|
42
51
|
});
|
43
52
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"chatCompositeLoader.js","sourceRoot":"","sources":["../../../../../acs-ui-javascript-loaders/src/chatCompositeLoader.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;AAElC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC;AACnC,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAGL,aAAa,EAGb,mCAAmC,EACpC,gDAAmC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"chatCompositeLoader.js","sourceRoot":"","sources":["../../../../../acs-ui-javascript-loaders/src/chatCompositeLoader.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;AAElC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC;AACnC,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAGL,aAAa,EAGb,mCAAmC,EACpC,gDAAmC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAmClD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAC/B,UAAoC,EACpC,WAAwB;;QAExB,eAAe,EAAE,CAAC;QAClB,MAAM,EACJ,MAAM,EACN,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,oBAAoB,EACpB,WAAW,EACX,MAAM,EACN,KAAK,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,GAAG,EACJ,GAAG,UAAU,CAAC;QACf,MAAM,OAAO,GAAG,MAAM,mCAAmC,CAAC;YACxD,QAAQ;YACR,MAAM;YACN,WAAW,EAAE,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,WAAW;YACvC,UAAU;YACV,QAAQ;SACT,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QAED,UAAU,CAAC,WAAW,CAAC,CAAC,MAAM,CAC5B,KAAK,CAAC,aAAa,CACjB,aAAa,EACb;YACE,OAAO,EAAE,oBAAoB;YAC7B,OAAO;YACP,WAAW;YACX,KAAK;YACL,MAAM;YACN,wBAAwB;YACxB,2BAA2B;YAC3B,GAAG;SACJ,EACD,IAAI,CACL,CACF,CAAC;QACF,OAAO,OAAO,CAAC;IACjB,CAAC;CAAA,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport React from 'react';\nimport { parseReactVersion } from './utils';\n\nconst reactVersion = React.version;\nparseReactVersion(reactVersion);\n\nimport { createRoot } from 'react-dom/client';\nimport { CommunicationTokenCredential, CommunicationUserIdentifier } from '@azure/communication-common';\nimport {\n BaseCompositeProps,\n ChatAdapter,\n ChatComposite,\n ChatCompositeIcons,\n ChatCompositeOptions,\n createAzureCommunicationChatAdapter\n} from '@internal/react-composites';\nimport { initializeIcons } from '@fluentui/react';\n\n/**\n * Props for the ChatComposite that you can use in your application. Contains the\n * options for the {@link ChatComposite} {@link ChatCompositeOptions}.\n * @public\n */\nexport interface ChatCompositeLoaderProps extends Partial<BaseCompositeProps<ChatCompositeIcons>> {\n /**\n * UserId for the local user.\n */\n userId: CommunicationUserIdentifier;\n /**\n * CommunicationTokenCredential for the local user.\n */\n credential: CommunicationTokenCredential;\n /**\n * Display name for the local user.\n */\n displayName?: string;\n /**\n * Communication service endpoint. This is used for the token and joining the chat thread.\n */\n endpoint: string;\n /**\n * Communication threadId for the chat thread.\n */\n threadId: string;\n /**\n * Options for the {@link AzureCommunicationChatAdapter}\n * This is used to configure the chat adapter.\n */\n chatCompositeOptions?: ChatCompositeOptions;\n}\n\n/**\n * Loader function for the ChatComposite that you can use in your application. This\n * function will load the ChatComposite into the provided HTML element.\n * The best use case for this is in a Node UI framework that is not React based.\n *\n * @public\n */\nexport const loadChatComposite = async function (\n loaderArgs: ChatCompositeLoaderProps,\n htmlElement: HTMLElement\n): Promise<ChatAdapter | undefined> {\n initializeIcons();\n const {\n userId,\n credential,\n endpoint,\n threadId,\n displayName,\n chatCompositeOptions,\n fluentTheme,\n locale,\n icons,\n onFetchAvatarPersonaData,\n onFetchParticipantMenuItems,\n rtl\n } = loaderArgs;\n const adapter = await createAzureCommunicationChatAdapter({\n endpoint,\n userId,\n displayName: displayName ?? 'anonymous',\n credential,\n threadId\n });\n\n if (!htmlElement) {\n throw new Error('Failed to find the root element');\n }\n\n createRoot(htmlElement).render(\n React.createElement(\n ChatComposite,\n {\n options: chatCompositeOptions,\n adapter,\n fluentTheme,\n icons,\n locale,\n onFetchAvatarPersonaData,\n onFetchParticipantMenuItems,\n rtl\n },\n null\n )\n );\n return adapter;\n};\n"]}
|
@@ -9,15 +9,40 @@ import { CallCompositeOptions, StartCallIdentifier, AzureCommunicationCallAdapte
|
|
9
9
|
*
|
10
10
|
* @public
|
11
11
|
*/
|
12
|
-
export
|
12
|
+
export interface OutboundCallCompositeLoaderProps extends Partial<BaseCompositeProps<CallCompositeIcons>> {
|
13
|
+
/**
|
14
|
+
* UserId for the local user.
|
15
|
+
*/
|
13
16
|
userId: CommunicationUserIdentifier;
|
17
|
+
/**
|
18
|
+
* CommunicationTokenCredential for the local user.
|
19
|
+
*/
|
14
20
|
credential: CommunicationTokenCredential;
|
21
|
+
/**
|
22
|
+
* Display name for the local user.
|
23
|
+
*/
|
15
24
|
displayName: string;
|
25
|
+
/**
|
26
|
+
* Participants that will be called.
|
27
|
+
* This can be a list of either {@link CommunicationUserIdentifier} or string identifiers.
|
28
|
+
*/
|
16
29
|
targetCallees: string[] | StartCallIdentifier[];
|
30
|
+
/**
|
31
|
+
* Options for the {@link AzureCommunicationCallAdapter}
|
32
|
+
* This is used to configure the call adapter.
|
33
|
+
*/
|
17
34
|
callAdapterOptions?: AzureCommunicationCallAdapterOptions;
|
18
|
-
|
35
|
+
/**
|
36
|
+
* Options for the {@link CallComposite} {@link CallCompositeOptions}
|
37
|
+
* This is used to configure the call composite.
|
38
|
+
*/
|
19
39
|
callCompositeOptions?: CallCompositeOptions;
|
20
|
-
|
40
|
+
/**
|
41
|
+
* Device form factor for the composite.
|
42
|
+
* This is used to configure the call composite.
|
43
|
+
*/
|
44
|
+
formFactor?: 'mobile' | 'desktop';
|
45
|
+
}
|
21
46
|
/**
|
22
47
|
* Loader function for the OutboundCallComposite that you can use in your application. This
|
23
48
|
* function will load the CallComposite into the provided HTML element to make outbound calls.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"outboundCallCompositeLoader.js","sourceRoot":"","sources":["../../../../../acs-ui-javascript-loaders/src/outboundCallCompositeLoader.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;AAElC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC;AACnC,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,+BAA+B,EAAE,gCAAgC;AAC1E,OAAO,EACL,aAAa,EACb,mCAAmC,EAOpC,gDAAmC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"outboundCallCompositeLoader.js","sourceRoot":"","sources":["../../../../../acs-ui-javascript-loaders/src/outboundCallCompositeLoader.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;AAElC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC;AACnC,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,+BAA+B,EAAE,gCAAgC;AAC1E,OAAO,EACL,aAAa,EACb,mCAAmC,EAOpC,gDAAmC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AA8ClD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,UACvC,UAA4C,EAC5C,WAAwB;;;QAExB,eAAe,EAAE,CAAC;QAClB,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,GAAG,UAAU,CAAC;QAChH,MAAM,sBAAsB,GAC1B,OAAO,aAAa,CAAC,CAAC,CAAC,KAAK,QAAQ;YAClC,CAAC,CAAE,aAA0B,CAAC,GAAG,CAAC,CAAC,MAAc,EAAE,EAAE;gBACjD,OAAO,+BAA+B,CAAC,MAAM,CAAC,CAAC;YACjD,CAAC,CAAC;YACJ,CAAC,CAAC,SAAS,CAAC;QAEhB,MAAM,OAAO,GAAG,MAAM,mCAAmC,CAAC;YACxD,MAAM;YACN,WAAW,EAAE,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,WAAW;YACvC,UAAU;YACV,aAAa,EAAE,MAAC,sBAAgD,mCAAK,aAAuC;YAC5G,OAAO,EAAE,kBAAkB;SAC5B,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QAED,UAAU,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;QACrH,OAAO,OAAO,CAAC;IACjB,CAAC;CAAA,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport React from 'react';\nimport { parseReactVersion } from './utils';\n\nconst reactVersion = React.version;\nparseReactVersion(reactVersion);\n\nimport { createRoot } from 'react-dom/client';\nimport { CommunicationTokenCredential, CommunicationUserIdentifier } from '@azure/communication-common';\nimport { fromFlatCommunicationIdentifier } from '@internal/acs-ui-common';\nimport {\n CallComposite,\n createAzureCommunicationCallAdapter,\n CallCompositeOptions,\n StartCallIdentifier,\n AzureCommunicationCallAdapterOptions,\n CallAdapter,\n BaseCompositeProps,\n CallCompositeIcons\n} from '@internal/react-composites';\nimport { initializeIcons } from '@fluentui/react';\n\n/**\n * Props for the OutboundCallComposite that you can use in your application.\n *\n * Contains two options bags:\n * - adapterOptions: Options for the {@link AzureCommunicationCallAdapter}\n * - callCompositeOptions: Options for the {@link CallComposite} {@link CallCompositeOptions}\n *\n * @public\n */\nexport interface OutboundCallCompositeLoaderProps extends Partial<BaseCompositeProps<CallCompositeIcons>> {\n /**\n * UserId for the local user.\n */\n userId: CommunicationUserIdentifier;\n /**\n * CommunicationTokenCredential for the local user.\n */\n credential: CommunicationTokenCredential;\n /**\n * Display name for the local user.\n */\n displayName: string;\n /**\n * Participants that will be called.\n * This can be a list of either {@link CommunicationUserIdentifier} or string identifiers.\n */\n targetCallees: string[] | StartCallIdentifier[];\n /**\n * Options for the {@link AzureCommunicationCallAdapter}\n * This is used to configure the call adapter.\n */\n callAdapterOptions?: AzureCommunicationCallAdapterOptions;\n /**\n * Options for the {@link CallComposite} {@link CallCompositeOptions}\n * This is used to configure the call composite.\n */\n callCompositeOptions?: CallCompositeOptions;\n /**\n * Device form factor for the composite.\n * This is used to configure the call composite.\n */\n formFactor?: 'mobile' | 'desktop';\n}\n\n/**\n * Loader function for the OutboundCallComposite that you can use in your application. This\n * function will load the CallComposite into the provided HTML element to make outbound calls.\n * The best use case for this is in a Node UI framework that is not React based.\n *\n * @public\n */\nexport const loadOutboundCallComposite = async function (\n loaderArgs: OutboundCallCompositeLoaderProps,\n htmlElement: HTMLElement\n): Promise<CallAdapter | undefined> {\n initializeIcons();\n const { userId, credential, displayName, targetCallees, callAdapterOptions, callCompositeOptions } = loaderArgs;\n const formattedTargetCallees =\n typeof targetCallees[0] === 'string'\n ? (targetCallees as string[]).map((callee: string) => {\n return fromFlatCommunicationIdentifier(callee);\n })\n : undefined;\n\n const adapter = await createAzureCommunicationCallAdapter({\n userId,\n displayName: displayName ?? 'anonymous',\n credential,\n targetCallees: (formattedTargetCallees as StartCallIdentifier[]) ?? (targetCallees as StartCallIdentifier[]),\n options: callAdapterOptions\n });\n\n if (!htmlElement) {\n throw new Error('Failed to find the root element');\n }\n\n createRoot(htmlElement).render(React.createElement(CallComposite, { options: callCompositeOptions, adapter }, null));\n return adapter;\n};\n"]}
|
@@ -103,24 +103,22 @@ export const CaptionsBanner = (props) => {
|
|
103
103
|
.filter((caption) => caption)
|
104
104
|
.map((caption) => {
|
105
105
|
if ('message' in caption) {
|
106
|
-
return (React.createElement("
|
106
|
+
return (React.createElement("div", { key: `RealTimeText - ${caption.id}`, className: captionContainerClassName, "data-is-focusable": true },
|
107
107
|
React.createElement(RealTimeText, Object.assign({}, caption))));
|
108
108
|
}
|
109
|
-
return (React.createElement("
|
109
|
+
return (React.createElement("div", { key: `Captions - ${caption.id}`, className: captionContainerClassName, "data-is-focusable": true },
|
110
110
|
React.createElement(_Caption, Object.assign({}, caption, { onRenderAvatar: onRenderAvatar }))));
|
111
|
-
return React.createElement(React.Fragment, null);
|
112
111
|
})));
|
113
112
|
};
|
114
113
|
return (React.createElement(React.Fragment, null, (startCaptionsInProgress || isCaptionsOn || isRealTimeTextOn) && (React.createElement(FocusZone, { shouldFocusOnMount: true, className: captionsContainerClassName, "data-ui-id": "captions-banner" },
|
115
114
|
(isCaptionsOn || isRealTimeTextOn) && formFactor === 'compact' && (React.createElement(Stack, { horizontal: true, horizontalAlign: "space-between", verticalAlign: "center", className: bannerTitleContainerClassName },
|
116
115
|
React.createElement(Text, { className: titleClassName }, getTitle()),
|
117
116
|
React.createElement(IconButton, { "data-ui-id": "captions-banner-expand-icon", iconProps: { iconName: expandBannerHeight ? 'MinimizeIcon' : 'ExpandIcon' }, ariaLabel: expandBannerHeight ? strings.minimizeButtonAriaLabel : strings.expandButtonAriaLabel, onClick: () => setExpandBannerHeight(!expandBannerHeight), styles: expandIconClassName(theme) }))),
|
118
|
-
(isCaptionsOn || isRealTimeTextOn) && (React.createElement("
|
117
|
+
(isCaptionsOn || isRealTimeTextOn) && (React.createElement("div", { ref: captionsScrollDivRef, className: (captionsOptions === null || captionsOptions === void 0 ? void 0 : captionsOptions.height) === 'full'
|
119
118
|
? captionsBannerFullHeightClassName(theme)
|
120
119
|
: captionsBannerClassName(formFactor, expandBannerHeight), "data-ui-id": "captions-banner-inner", "data-is-focusable": true },
|
121
|
-
isRealTimeTextOn && (React.createElement(
|
122
|
-
React.createElement(
|
123
|
-
React.createElement(_RTTDisclosureBanner, { strings: realTimeTextDisclosureBannerStrings })))),
|
120
|
+
isRealTimeTextOn && (React.createElement(Stack, { className: rttDisclosureBannerClassName() },
|
121
|
+
React.createElement(_RTTDisclosureBanner, { strings: realTimeTextDisclosureBannerStrings }))),
|
124
122
|
captionsAndRealTimeText())),
|
125
123
|
isRealTimeTextOn && onSendRealTimeText && (React.createElement(TextField, { styles: realTimeTextInputBoxStyles(theme), placeholder: strings.realTimeTextInputBoxDefaultText, value: textFieldValue, onKeyDown: handleKeyDown, onChange: (_, newValue) => {
|
126
124
|
setTextFieldValue(newValue || '');
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CaptionsBanner.js","sourceRoot":"","sources":["../../../../../../react-components/src/components/CaptionsBanner.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,iCAAiC,EACjC,0BAA0B,EAC1B,6BAA6B,EAC7B,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EACL,mBAAmB,EACnB,6BAA6B,EAC7B,0BAA0B,EAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA2LnD,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAA0B,EAAe,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,eAAe,CAAE,MAAM,MAAK,MAAM;gBAChC,CAAC,CAAC,6BAA6B,CAAC,KAAK,CAAC;gBACtC,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC,uBAElB,IAAI;YAEvB,oBAAC,OAAO,IAAC,KAAK,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,yBAAyB,EAAE,QAAQ,EAAC,WAAW,EAAC,aAAa,EAAC,OAAO,GAAG,CAC3F,CACT,CACS,CACb,CACA,CACJ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { Stack, FocusZone, Spinner, useTheme } from '@fluentui/react';\nimport { TextField } from '@fluentui/react';\nimport React, { useEffect, useRef, useState, useCallback } from 'react';\nimport { useMemo } from 'react';\nimport { _Caption } from './Caption';\nimport {\n captionContainerClassName,\n captionsBannerClassName,\n captionsBannerFullHeightClassName,\n captionsContainerClassName,\n loadingBannerFullHeightStyles,\n loadingBannerStyles\n} from './styles/Captions.style';\nimport { rttDisclosureBannerClassName } from './styles/Captions.style';\nimport { OnRenderAvatarCallback } from '../types';\nimport { useLocale } from '../localization';\nimport { RealTimeText } from './RealTimeText';\nimport { _RTTDisclosureBanner } from './RTTDisclosureBanner';\nimport { sortCaptionsAndRealTimeTexts } from './utils/sortCaptionsAndRealTimeTexts';\nimport {\n expandIconClassName,\n bannerTitleContainerClassName,\n realTimeTextInputBoxStyles\n} from './styles/Captions.style';\nimport { titleClassName } from './styles/CaptionsSettingsModal.styles';\nimport { Text, IconButton } from '@fluentui/react';\n\n/**\n * @public\n * information required for each line of caption\n */\nexport type CaptionsInformation = {\n /**\n * unique id for each caption\n */\n id: string;\n /**\n * speaker's display name\n */\n displayName: string;\n /**\n * content of the caption\n */\n captionText: string;\n /**\n * id of the speaker\n */\n userId?: string;\n /**\n * timestamp when the caption was created\n * Please note that this value is essential for determining the order of captions and real time text messages\n * If you are using both captions and real time text, please ensure that the createdTimeStamp is populated\n */\n createdTimeStamp?: Date;\n};\n\n/**\n * @public\n * information required for each line of real time text\n */\nexport type RealTimeTextInformation = {\n /**\n * The id of the real time text.\n */\n id: number;\n /**\n * sender's display name\n */\n displayName: string;\n /**\n * id of the sender\n */\n userId?: string;\n /**\n * The real time text message.\n */\n message: string;\n /**\n * if the real time text received is partial\n */\n isTyping: boolean;\n /**\n * timestamp when the real time text was finalized\n */\n finalizedTimeStamp: Date;\n /**\n * If message originated from the local participant\n * default value is false\n */\n isMe?: boolean;\n};\n/**\n * @public\n * strings for captions banner\n */\nexport interface CaptionsBannerStrings {\n /**\n * Spinner text for captions banner\n */\n captionsBannerSpinnerText?: string;\n\n /**\n * Default text for RTT input text box\n */\n realTimeTextInputBoxDefaultText?: string;\n\n /**\n * Error message for RTT input text box when the size exceeds the limit 2000\n */\n realTimeTextInputErrorMessage?: string;\n\n /**\n * Real time text disclosure banner title\n */\n realTimeTextBannerTitle?: string;\n\n /**\n * Real time text disclosure banner content\n */\n realTimeTextBannerContent?: string;\n\n /**\n * Real time text disclosure banner link label\n */\n realTimeTextBannerLinkLabel?: string;\n\n /**\n * Title for the container when only captions is enabled\n */\n captionsOnlyContainerTitle?: string;\n /**\n * Title for the container when only real time text is enabled\n */\n realTimeTextOnlyContainerTitle?: string;\n /**\n * Title for the container when both captions and real time text is enabled\n */\n captionsAndRealTimeTextContainerTitle?: string;\n /**\n * Expand button aria label\n */\n expandButtonAriaLabel?: string;\n /**\n * Minimize button aria label\n */\n minimizeButtonAriaLabel?: string;\n}\n\n/**\n * @public\n * CaptionsBanner Component Props.\n */\nexport interface CaptionsBannerProps {\n /**\n * Array of captions to be displayed\n */\n captions: CaptionsInformation[];\n /**\n * Array of finalized and partial real time text messages\n */\n realTimeTexts?: {\n completedMessages?: RealTimeTextInformation[];\n currentInProgress?: RealTimeTextInformation[];\n myInProgress?: RealTimeTextInformation;\n };\n /**\n * Flag to indicate if captions are on\n */\n isCaptionsOn?: boolean;\n\n /**\n * Flag to indicate if real time text is on\n */\n isRealTimeTextOn?: boolean;\n /**\n * Flag to indicate if captions are being started\n * This is used to show spinner while captions are being started\n */\n startCaptionsInProgress?: boolean;\n /**\n * Optional callback to override render of the avatar.\n *\n * @param userId - user Id\n */\n onRenderAvatar?: OnRenderAvatarCallback;\n /**\n * Optional strings for the component\n */\n strings?: CaptionsBannerStrings;\n /**\n * Optional form factor for the component.\n * @defaultValue 'default'\n */\n formFactor?: 'default' | 'compact';\n /**\n * Optional options for the component.\n */\n captionsOptions?: {\n height: 'full' | 'default';\n };\n\n /**\n * Optional callback to send real time text.\n */\n onSendRealTimeText?: (text: string, isFinalized: boolean) => Promise<void>;\n\n /**\n * Latest local real time text\n */\n latestLocalRealTimeText?: RealTimeTextInformation;\n}\n\nconst SCROLL_OFFSET_ALLOWANCE = 20;\n\n/**\n * @public\n * A component for displaying a CaptionsBanner with user icon, displayName and captions text.\n */\nexport const CaptionsBanner = (props: CaptionsBannerProps): JSX.Element => {\n const {\n captions,\n realTimeTexts,\n isCaptionsOn,\n startCaptionsInProgress,\n onRenderAvatar,\n formFactor = 'default',\n captionsOptions,\n isRealTimeTextOn,\n onSendRealTimeText,\n latestLocalRealTimeText\n } = props;\n const localeStrings = useLocale().strings.captionsBanner;\n const strings = { ...localeStrings, ...props.strings };\n const captionsScrollDivRef = useRef<HTMLUListElement>(null);\n const [isAtBottomOfScroll, setIsAtBottomOfScroll] = useState<boolean>(true);\n const theme = useTheme();\n\n const [expandBannerHeight, setExpandBannerHeight] = useState<boolean>(false);\n\n const getTitle = (): string => {\n if (isCaptionsOn && isRealTimeTextOn) {\n return strings.captionsAndRealTimeTextContainerTitle ?? '';\n } else if (isCaptionsOn) {\n return strings.captionsOnlyContainerTitle ?? '';\n } else if (isRealTimeTextOn) {\n return strings.realTimeTextOnlyContainerTitle ?? '';\n }\n return '';\n };\n\n // merge realtimetexts and captions into one array based on timestamp\n // Combine captions and realTimeTexts into one list\n const combinedList: (CaptionsInformation | RealTimeTextInformation)[] = useMemo(() => {\n return sortCaptionsAndRealTimeTexts(captions, realTimeTexts?.completedMessages ?? []);\n }, [captions, realTimeTexts?.completedMessages]);\n\n const mergedCaptions: (CaptionsInformation | RealTimeTextInformation)[] = useMemo(() => {\n return [...combinedList, ...(realTimeTexts?.currentInProgress ?? []), realTimeTexts?.myInProgress].slice(-50) as (\n | CaptionsInformation\n | RealTimeTextInformation\n )[];\n }, [combinedList, realTimeTexts]);\n\n const scrollToBottom = (): void => {\n if (captionsScrollDivRef.current) {\n captionsScrollDivRef.current.scrollTop = captionsScrollDivRef.current.scrollHeight;\n }\n };\n\n const handleScrollToTheBottom = useCallback((): void => {\n if (!captionsScrollDivRef.current) {\n return;\n }\n const atBottom =\n Math.ceil(captionsScrollDivRef.current.scrollTop) >=\n captionsScrollDivRef.current.scrollHeight - captionsScrollDivRef.current.clientHeight - SCROLL_OFFSET_ALLOWANCE;\n\n setIsAtBottomOfScroll(atBottom);\n }, []);\n\n useEffect(() => {\n const captionsScrollDiv = captionsScrollDivRef.current;\n captionsScrollDiv?.addEventListener('scroll', handleScrollToTheBottom);\n\n return () => {\n captionsScrollDiv?.removeEventListener('scroll', handleScrollToTheBottom);\n };\n }, [handleScrollToTheBottom, isCaptionsOn, isRealTimeTextOn]);\n\n useEffect(() => {\n // only auto scroll to bottom is already is at bottom of scroll before new caption comes in\n if (isAtBottomOfScroll) {\n scrollToBottom();\n }\n }, [captions, realTimeTexts, isAtBottomOfScroll]);\n\n const [textFieldValue, setTextFieldValue] = useState<string>('');\n\n useEffect(() => {\n // if the latest real time text sent by myself is final, clear the text field\n if (latestLocalRealTimeText && !latestLocalRealTimeText.isTyping) {\n setTextFieldValue('');\n }\n }, [latestLocalRealTimeText]);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>): void => {\n if (event.key === 'Enter') {\n event.preventDefault();\n if (textFieldValue && onSendRealTimeText) {\n onSendRealTimeText(textFieldValue, true);\n setTextFieldValue('');\n }\n }\n };\n\n const realTimeTextDisclosureBannerStrings = {\n bannerTitle: strings.realTimeTextBannerTitle ?? '',\n bannerContent: strings.realTimeTextBannerContent ?? '',\n bannerLinkLabel: strings.realTimeTextBannerLinkLabel ?? ''\n };\n\n const captionsAndRealTimeText = (): JSX.Element => {\n return (\n <>\n {mergedCaptions\n .filter((caption) => caption)\n .map((caption) => {\n if ('message' in caption) {\n return (\n <li key={`RealTimeText - ${caption.id}`} className={captionContainerClassName} data-is-focusable={true}>\n <RealTimeText {...(caption as RealTimeTextInformation)} />\n </li>\n );\n }\n return (\n <li key={`Captions - ${caption.id}`} className={captionContainerClassName} data-is-focusable={true}>\n <_Caption {...(caption as CaptionsInformation)} onRenderAvatar={onRenderAvatar} />\n </li>\n );\n return <></>;\n })}\n </>\n );\n };\n\n return (\n <>\n {(startCaptionsInProgress || isCaptionsOn || isRealTimeTextOn) && (\n <FocusZone shouldFocusOnMount className={captionsContainerClassName} data-ui-id=\"captions-banner\">\n {(isCaptionsOn || isRealTimeTextOn) && formFactor === 'compact' && (\n <Stack\n horizontal\n horizontalAlign=\"space-between\"\n verticalAlign=\"center\"\n className={bannerTitleContainerClassName}\n >\n <Text className={titleClassName}>{getTitle()}</Text>\n <IconButton\n data-ui-id=\"captions-banner-expand-icon\"\n iconProps={{ iconName: expandBannerHeight ? 'MinimizeIcon' : 'ExpandIcon' }}\n ariaLabel={expandBannerHeight ? strings.minimizeButtonAriaLabel : strings.expandButtonAriaLabel}\n onClick={() => setExpandBannerHeight(!expandBannerHeight)}\n styles={expandIconClassName(theme)}\n />\n </Stack>\n )}\n {(isCaptionsOn || isRealTimeTextOn) && (\n <ul\n ref={captionsScrollDivRef}\n className={\n captionsOptions?.height === 'full'\n ? captionsBannerFullHeightClassName(theme)\n : captionsBannerClassName(formFactor, expandBannerHeight)\n }\n data-ui-id=\"captions-banner-inner\"\n data-is-focusable={true}\n >\n {isRealTimeTextOn && (\n <li>\n <Stack className={rttDisclosureBannerClassName()}>\n <_RTTDisclosureBanner strings={realTimeTextDisclosureBannerStrings} />\n </Stack>\n </li>\n )}\n {captionsAndRealTimeText()}\n </ul>\n )}\n {isRealTimeTextOn && onSendRealTimeText && (\n <TextField\n styles={realTimeTextInputBoxStyles(theme)}\n placeholder={strings.realTimeTextInputBoxDefaultText}\n value={textFieldValue}\n onKeyDown={handleKeyDown}\n onChange={(_, newValue) => {\n setTextFieldValue(newValue || '');\n onSendRealTimeText(newValue || '', false);\n }}\n maxLength={2000}\n errorMessage={textFieldValue.length >= 2000 ? strings.realTimeTextInputErrorMessage : undefined}\n />\n )}\n {!isCaptionsOn && !isRealTimeTextOn && (\n <Stack\n verticalAlign=\"center\"\n styles={\n captionsOptions?.height === 'full'\n ? loadingBannerFullHeightStyles(theme)\n : loadingBannerStyles(formFactor)\n }\n data-is-focusable={true}\n >\n <Spinner label={strings?.captionsBannerSpinnerText} ariaLive=\"assertive\" labelPosition=\"right\" />\n </Stack>\n )}\n </FocusZone>\n )}\n </>\n );\n};\n"]}
|
1
|
+
{"version":3,"file":"CaptionsBanner.js","sourceRoot":"","sources":["../../../../../../react-components/src/components/CaptionsBanner.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,iCAAiC,EACjC,0BAA0B,EAC1B,6BAA6B,EAC7B,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAy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EACrB,SAAS,EAAE,aAAa,EACxB,QAAQ,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE;gBACxB,iBAAiB,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;gBAClC,kBAAkB,CAAC,QAAQ,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;YAC5C,CAAC,EACD,SAAS,EAAE,IAAI,EACf,YAAY,EAAE,cAAc,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC,CAAC,SAAS,GAC/F,CACH;QACA,CAAC,YAAY,IAAI,CAAC,gBAAgB,IAAI,CACrC,oBAAC,KAAK,IACJ,aAAa,EAAC,QAAQ,EACtB,MAAM,EACJ,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,MAAM,MAAK,MAAM;gBAChC,CAAC,CAAC,6BAA6B,CAAC,KAAK,CAAC;gBACtC,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC,uBAElB,IAAI;YAEvB,oBAAC,OAAO,IAAC,KAAK,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,yBAAyB,EAAE,QAAQ,EAAC,WAAW,EAAC,aAAa,EAAC,OAAO,GAAG,CAC3F,CACT,CACS,CACb,CACA,CACJ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { Stack, FocusZone, Spinner, useTheme } from '@fluentui/react';\nimport { TextField } from '@fluentui/react';\nimport React, { useEffect, useRef, useState, useCallback } from 'react';\nimport { useMemo } from 'react';\nimport { _Caption } from './Caption';\nimport {\n captionContainerClassName,\n captionsBannerClassName,\n captionsBannerFullHeightClassName,\n captionsContainerClassName,\n loadingBannerFullHeightStyles,\n loadingBannerStyles\n} from './styles/Captions.style';\nimport { rttDisclosureBannerClassName } from './styles/Captions.style';\nimport { OnRenderAvatarCallback } from '../types';\nimport { useLocale } from '../localization';\nimport { RealTimeText } from './RealTimeText';\nimport { _RTTDisclosureBanner } from './RTTDisclosureBanner';\nimport { sortCaptionsAndRealTimeTexts } from './utils/sortCaptionsAndRealTimeTexts';\nimport {\n expandIconClassName,\n bannerTitleContainerClassName,\n realTimeTextInputBoxStyles\n} from './styles/Captions.style';\nimport { titleClassName } from './styles/CaptionsSettingsModal.styles';\nimport { Text, IconButton } from '@fluentui/react';\n\n/**\n * @public\n * information required for each line of caption\n */\nexport type CaptionsInformation = {\n /**\n * unique id for each caption\n */\n id: string;\n /**\n * speaker's display name\n */\n displayName: string;\n /**\n * content of the caption\n */\n captionText: string;\n /**\n * id of the speaker\n */\n userId?: string;\n /**\n * timestamp when the caption was created\n * Please note that this value is essential for determining the order of captions and real time text messages\n * If you are using both captions and real time text, please ensure that the createdTimeStamp is populated\n */\n createdTimeStamp?: Date;\n};\n\n/**\n * @public\n * information required for each line of real time text\n */\nexport type RealTimeTextInformation = {\n /**\n * The id of the real time text.\n */\n id: number;\n /**\n * sender's display name\n */\n displayName: string;\n /**\n * id of the sender\n */\n userId?: string;\n /**\n * The real time text message.\n */\n message: string;\n /**\n * if the real time text received is partial\n */\n isTyping: boolean;\n /**\n * timestamp when the real time text was finalized\n */\n finalizedTimeStamp: Date;\n /**\n * If message originated from the local participant\n * default value is false\n */\n isMe?: boolean;\n};\n/**\n * @public\n * strings for captions banner\n */\nexport interface CaptionsBannerStrings {\n /**\n * Spinner text for captions banner\n */\n captionsBannerSpinnerText?: string;\n\n /**\n * Default text for RTT input text box\n */\n realTimeTextInputBoxDefaultText?: string;\n\n /**\n * Error message for RTT input text box when the size exceeds the limit 2000\n */\n realTimeTextInputErrorMessage?: string;\n\n /**\n * Real time text disclosure banner title\n */\n realTimeTextBannerTitle?: string;\n\n /**\n * Real time text disclosure banner content\n */\n realTimeTextBannerContent?: string;\n\n /**\n * Real time text disclosure banner link label\n */\n realTimeTextBannerLinkLabel?: string;\n\n /**\n * Title for the container when only captions is enabled\n */\n captionsOnlyContainerTitle?: string;\n /**\n * Title for the container when only real time text is enabled\n */\n realTimeTextOnlyContainerTitle?: string;\n /**\n * Title for the container when both captions and real time text is enabled\n */\n captionsAndRealTimeTextContainerTitle?: string;\n /**\n * Expand button aria label\n */\n expandButtonAriaLabel?: string;\n /**\n * Minimize button aria label\n */\n minimizeButtonAriaLabel?: string;\n}\n\n/**\n * @public\n * CaptionsBanner Component Props.\n */\nexport interface CaptionsBannerProps {\n /**\n * Array of captions to be displayed\n */\n captions: CaptionsInformation[];\n /**\n * Array of finalized and partial real time text messages\n */\n realTimeTexts?: {\n completedMessages?: RealTimeTextInformation[];\n currentInProgress?: RealTimeTextInformation[];\n myInProgress?: RealTimeTextInformation;\n };\n /**\n * Flag to indicate if captions are on\n */\n isCaptionsOn?: boolean;\n\n /**\n * Flag to indicate if real time text is on\n */\n isRealTimeTextOn?: boolean;\n /**\n * Flag to indicate if captions are being started\n * This is used to show spinner while captions are being started\n */\n startCaptionsInProgress?: boolean;\n /**\n * Optional callback to override render of the avatar.\n *\n * @param userId - user Id\n */\n onRenderAvatar?: OnRenderAvatarCallback;\n /**\n * Optional strings for the component\n */\n strings?: CaptionsBannerStrings;\n /**\n * Optional form factor for the component.\n * @defaultValue 'default'\n */\n formFactor?: 'default' | 'compact';\n /**\n * Optional options for the component.\n */\n captionsOptions?: {\n height: 'full' | 'default';\n };\n\n /**\n * Optional callback to send real time text.\n */\n onSendRealTimeText?: (text: string, isFinalized: boolean) => Promise<void>;\n\n /**\n * Latest local real time text\n */\n latestLocalRealTimeText?: RealTimeTextInformation;\n}\n\nconst SCROLL_OFFSET_ALLOWANCE = 20;\n\n/**\n * @public\n * A component for displaying a CaptionsBanner with user icon, displayName and captions text.\n */\nexport const CaptionsBanner = (props: CaptionsBannerProps): JSX.Element => {\n const {\n captions,\n realTimeTexts,\n isCaptionsOn,\n startCaptionsInProgress,\n onRenderAvatar,\n formFactor = 'default',\n captionsOptions,\n isRealTimeTextOn,\n onSendRealTimeText,\n latestLocalRealTimeText\n } = props;\n const localeStrings = useLocale().strings.captionsBanner;\n const strings = { ...localeStrings, ...props.strings };\n const captionsScrollDivRef = useRef<HTMLDivElement>(null);\n const [isAtBottomOfScroll, setIsAtBottomOfScroll] = useState<boolean>(true);\n const theme = useTheme();\n\n const [expandBannerHeight, setExpandBannerHeight] = useState<boolean>(false);\n\n const getTitle = (): string => {\n if (isCaptionsOn && isRealTimeTextOn) {\n return strings.captionsAndRealTimeTextContainerTitle ?? '';\n } else if (isCaptionsOn) {\n return strings.captionsOnlyContainerTitle ?? '';\n } else if (isRealTimeTextOn) {\n return strings.realTimeTextOnlyContainerTitle ?? '';\n }\n return '';\n };\n\n // merge realtimetexts and captions into one array based on timestamp\n // Combine captions and realTimeTexts into one list\n const combinedList: (CaptionsInformation | RealTimeTextInformation)[] = useMemo(() => {\n return sortCaptionsAndRealTimeTexts(captions, realTimeTexts?.completedMessages ?? []);\n }, [captions, realTimeTexts?.completedMessages]);\n\n const mergedCaptions: (CaptionsInformation | RealTimeTextInformation)[] = useMemo(() => {\n return [...combinedList, ...(realTimeTexts?.currentInProgress ?? []), realTimeTexts?.myInProgress].slice(-50) as (\n | CaptionsInformation\n | RealTimeTextInformation\n )[];\n }, [combinedList, realTimeTexts]);\n\n const scrollToBottom = (): void => {\n if (captionsScrollDivRef.current) {\n captionsScrollDivRef.current.scrollTop = captionsScrollDivRef.current.scrollHeight;\n }\n };\n\n const handleScrollToTheBottom = useCallback((): void => {\n if (!captionsScrollDivRef.current) {\n return;\n }\n const atBottom =\n Math.ceil(captionsScrollDivRef.current.scrollTop) >=\n captionsScrollDivRef.current.scrollHeight - captionsScrollDivRef.current.clientHeight - SCROLL_OFFSET_ALLOWANCE;\n\n setIsAtBottomOfScroll(atBottom);\n }, []);\n\n useEffect(() => {\n const captionsScrollDiv = captionsScrollDivRef.current;\n captionsScrollDiv?.addEventListener('scroll', handleScrollToTheBottom);\n\n return () => {\n captionsScrollDiv?.removeEventListener('scroll', handleScrollToTheBottom);\n };\n }, [handleScrollToTheBottom, isCaptionsOn, isRealTimeTextOn]);\n\n useEffect(() => {\n // only auto scroll to bottom is already is at bottom of scroll before new caption comes in\n if (isAtBottomOfScroll) {\n scrollToBottom();\n }\n }, [captions, realTimeTexts, isAtBottomOfScroll]);\n\n const [textFieldValue, setTextFieldValue] = useState<string>('');\n\n useEffect(() => {\n // if the latest real time text sent by myself is final, clear the text field\n if (latestLocalRealTimeText && !latestLocalRealTimeText.isTyping) {\n setTextFieldValue('');\n }\n }, [latestLocalRealTimeText]);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>): void => {\n if (event.key === 'Enter') {\n event.preventDefault();\n if (textFieldValue && onSendRealTimeText) {\n onSendRealTimeText(textFieldValue, true);\n setTextFieldValue('');\n }\n }\n };\n\n const realTimeTextDisclosureBannerStrings = {\n bannerTitle: strings.realTimeTextBannerTitle ?? '',\n bannerContent: strings.realTimeTextBannerContent ?? '',\n bannerLinkLabel: strings.realTimeTextBannerLinkLabel ?? ''\n };\n\n const captionsAndRealTimeText = (): JSX.Element => {\n return (\n <>\n {mergedCaptions\n .filter((caption) => caption)\n .map((caption) => {\n if ('message' in caption) {\n return (\n <div\n key={`RealTimeText - ${caption.id}`}\n className={captionContainerClassName}\n data-is-focusable={true}\n >\n <RealTimeText {...(caption as RealTimeTextInformation)} />\n </div>\n );\n }\n return (\n <div key={`Captions - ${caption.id}`} className={captionContainerClassName} data-is-focusable={true}>\n <_Caption {...(caption as CaptionsInformation)} onRenderAvatar={onRenderAvatar} />\n </div>\n );\n })}\n </>\n );\n };\n\n return (\n <>\n {(startCaptionsInProgress || isCaptionsOn || isRealTimeTextOn) && (\n <FocusZone shouldFocusOnMount className={captionsContainerClassName} data-ui-id=\"captions-banner\">\n {(isCaptionsOn || isRealTimeTextOn) && formFactor === 'compact' && (\n <Stack\n horizontal\n horizontalAlign=\"space-between\"\n verticalAlign=\"center\"\n className={bannerTitleContainerClassName}\n >\n <Text className={titleClassName}>{getTitle()}</Text>\n <IconButton\n data-ui-id=\"captions-banner-expand-icon\"\n iconProps={{ iconName: expandBannerHeight ? 'MinimizeIcon' : 'ExpandIcon' }}\n ariaLabel={expandBannerHeight ? strings.minimizeButtonAriaLabel : strings.expandButtonAriaLabel}\n onClick={() => setExpandBannerHeight(!expandBannerHeight)}\n styles={expandIconClassName(theme)}\n />\n </Stack>\n )}\n {(isCaptionsOn || isRealTimeTextOn) && (\n <div\n ref={captionsScrollDivRef}\n className={\n captionsOptions?.height === 'full'\n ? captionsBannerFullHeightClassName(theme)\n : captionsBannerClassName(formFactor, expandBannerHeight)\n }\n data-ui-id=\"captions-banner-inner\"\n data-is-focusable={true}\n >\n {isRealTimeTextOn && (\n <Stack className={rttDisclosureBannerClassName()}>\n <_RTTDisclosureBanner strings={realTimeTextDisclosureBannerStrings} />\n </Stack>\n )}\n {captionsAndRealTimeText()}\n </div>\n )}\n {isRealTimeTextOn && onSendRealTimeText && (\n <TextField\n styles={realTimeTextInputBoxStyles(theme)}\n placeholder={strings.realTimeTextInputBoxDefaultText}\n value={textFieldValue}\n onKeyDown={handleKeyDown}\n onChange={(_, newValue) => {\n setTextFieldValue(newValue || '');\n onSendRealTimeText(newValue || '', false);\n }}\n maxLength={2000}\n errorMessage={textFieldValue.length >= 2000 ? strings.realTimeTextInputErrorMessage : undefined}\n />\n )}\n {!isCaptionsOn && !isRealTimeTextOn && (\n <Stack\n verticalAlign=\"center\"\n styles={\n captionsOptions?.height === 'full'\n ? loadingBannerFullHeightStyles(theme)\n : loadingBannerStyles(formFactor)\n }\n data-is-focusable={true}\n >\n <Spinner label={strings?.captionsBannerSpinnerText} ariaLive=\"assertive\" labelPosition=\"right\" />\n </Stack>\n )}\n </FocusZone>\n )}\n </>\n );\n};\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@azure/communication-react",
|
3
|
-
"version": "1.27.0-alpha-
|
3
|
+
"version": "1.27.0-alpha-202505140018",
|
4
4
|
"sideEffects": false,
|
5
5
|
"description": "React library for building modern communication user experiences utilizing Azure Communication Services",
|
6
6
|
"keywords": [
|