@azure/communication-react 1.2.3-alpha-202205130015.0 → 1.2.3-alpha-202205180014.0

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.
@@ -191,7 +191,7 @@ const fromFlatCommunicationIdentifier = (id) => {
191
191
  // Copyright (c) Microsoft Corporation.
192
192
  // Licensed under the MIT license.
193
193
  // GENERATED FILE. DO NOT EDIT MANUALLY.
194
- var telemetryVersion = '1.2.3-alpha-202205130015.0';
194
+ var telemetryVersion = '1.2.3-alpha-202205180014.0';
195
195
 
196
196
  // Copyright (c) Microsoft Corporation.
197
197
  /**
@@ -2031,7 +2031,8 @@ const _FileCard = (props) => {
2031
2031
  width: '12rem',
2032
2032
  background: theme.palette.neutralLighter,
2033
2033
  borderRadius: theme.effects.roundedCorner4,
2034
- border: `${_pxToRem(1)} solid ${theme.palette.neutralQuaternary}`
2034
+ border: `${_pxToRem(1)} solid ${theme.palette.neutralQuaternary}`,
2035
+ cursor: 'pointer'
2035
2036
  });
2036
2037
  const fileInfoWrapperClassName = react.mergeStyles({
2037
2038
  padding: _pxToRem(12),
@@ -2063,7 +2064,9 @@ const _FileCard = (props) => {
2063
2064
  height: _pxToRem(progressBarThicknessPx)
2064
2065
  }
2065
2066
  };
2066
- return (React__default['default'].createElement(react.Stack, { className: containerClassName },
2067
+ return (React__default['default'].createElement(react.Stack, { className: containerClassName, onClick: () => {
2068
+ props.actionHandler && props.actionHandler();
2069
+ } },
2067
2070
  React__default['default'].createElement(react.Stack, { horizontal: true, horizontalAlign: "space-between", verticalAlign: "center", className: fileInfoWrapperClassName },
2068
2071
  React__default['default'].createElement(react.Stack, null,
2069
2072
  React__default['default'].createElement(react.Icon, Object.assign({}, reactFileTypeIcons.getFileTypeIconProps({
@@ -2073,9 +2076,7 @@ const _FileCard = (props) => {
2073
2076
  })))),
2074
2077
  React__default['default'].createElement(react.Stack, { className: fileNameContainerClassName },
2075
2078
  React__default['default'].createElement(react.Text, { className: fileNameTextClassName }, fileName)),
2076
- React__default['default'].createElement(react.Stack, { verticalAlign: "center", className: actionIconClassName, onClick: () => {
2077
- props.actionHandler && props.actionHandler();
2078
- } }, actionIcon && actionIcon)),
2079
+ React__default['default'].createElement(react.Stack, { verticalAlign: "center", className: actionIconClassName }, actionIcon && actionIcon)),
2079
2080
  showProgressIndicator && React__default['default'].createElement(react.ProgressIndicator, { percentComplete: progress, styles: progressIndicatorStyles })));
2080
2081
  };
2081
2082
 
@@ -6809,6 +6810,7 @@ const computeVariant = (callRecordState, callTranscribeState) => {
6809
6810
  };
6810
6811
 
6811
6812
  // Copyright (c) Microsoft Corporation.
6813
+ const BANNER_OVERWRITE_DELAY_MS = 3000;
6812
6814
  /**
6813
6815
  * A component that displays banners to notify the user when call recording and
6814
6816
  * transcription is enabled or disabled in a call.
@@ -6819,10 +6821,6 @@ const computeVariant = (callRecordState, callTranscribeState) => {
6819
6821
  * @internal
6820
6822
  */
6821
6823
  const _ComplianceBanner = (props) => {
6822
- //set variant when incoming state is different from current state
6823
- //when variant change, return message bar
6824
- //when message bar is dismissed,set variant to default nostate and if current state is stopped, set to off
6825
- const [variant, setVariant] = React.useState('NO_STATE');
6826
6824
  const cachedProps = React.useRef({
6827
6825
  latestBooleanState: {
6828
6826
  callTranscribeState: false,
@@ -6831,39 +6829,46 @@ const _ComplianceBanner = (props) => {
6831
6829
  latestStringState: {
6832
6830
  callTranscribeState: 'off',
6833
6831
  callRecordState: 'off'
6834
- }
6832
+ },
6833
+ lastUpdated: Date.now()
6835
6834
  });
6836
6835
  // Only update cached props and variant if there is _some_ change in the latest props.
6837
6836
  // This ensures that state machine is only updated if there is an actual change in the props.
6838
- if (props.callRecordState !== cachedProps.current.latestBooleanState.callRecordState ||
6839
- props.callTranscribeState !== cachedProps.current.latestBooleanState.callTranscribeState) {
6837
+ const shouldUpdateCached = props.callRecordState !== cachedProps.current.latestBooleanState.callRecordState ||
6838
+ props.callTranscribeState !== cachedProps.current.latestBooleanState.callTranscribeState;
6839
+ // The following three operations must be performed in this exact order:
6840
+ // [1]: Update cached state to transition the state machine.
6841
+ if (shouldUpdateCached) {
6840
6842
  cachedProps.current = {
6841
6843
  latestBooleanState: props,
6842
6844
  latestStringState: {
6843
6845
  callRecordState: determineStates(cachedProps.current.latestStringState.callRecordState, props.callRecordState),
6844
6846
  callTranscribeState: determineStates(cachedProps.current.latestStringState.callTranscribeState, props.callTranscribeState)
6845
- }
6847
+ },
6848
+ lastUpdated: Date.now()
6846
6849
  };
6847
- setVariant(computeVariant(cachedProps.current.latestStringState.callRecordState, cachedProps.current.latestStringState.callTranscribeState));
6848
- // when both states are stopped, after displaying message "RECORDING_AND_TRANSCRIPTION_STOPPED", change both states to off (going back to the default state)
6849
- if (cachedProps.current.latestStringState.callRecordState === 'stopped' &&
6850
- cachedProps.current.latestStringState.callTranscribeState === 'stopped') {
6851
- cachedProps.current.latestStringState.callRecordState = 'off';
6852
- cachedProps.current.latestStringState.callTranscribeState = 'off';
6853
- }
6854
6850
  }
6855
- return variant === 'NO_STATE' ? (React__default['default'].createElement(React__default['default'].Fragment, null)) : (React__default['default'].createElement(react.MessageBar, { messageBarType: react.MessageBarType.warning, onDismiss: () => {
6856
- // when closing the banner, change variant to nostate and change stopped state to off state.
6857
- // Reason: on banner close, going back to the default state
6858
- setVariant('NO_STATE');
6851
+ // [2]: Compute the variant, using the transitioned state machine.
6852
+ const variant = computeVariant(cachedProps.current.latestStringState.callRecordState, cachedProps.current.latestStringState.callTranscribeState);
6853
+ // [3]: Transition the state machine again to deal with some end-states.
6854
+ if (shouldUpdateCached &&
6855
+ cachedProps.current.latestStringState.callRecordState === 'stopped' &&
6856
+ cachedProps.current.latestStringState.callTranscribeState === 'stopped') {
6857
+ // When both states are stopped, after displaying message "RECORDING_AND_TRANSCRIPTION_STOPPED", change both states to off (going back to the default state).
6858
+ cachedProps.current.latestStringState.callRecordState = 'off';
6859
+ cachedProps.current.latestStringState.callTranscribeState = 'off';
6860
+ }
6861
+ return (React__default['default'].createElement(DelayedUpdateBanner, { variant: {
6862
+ variant,
6863
+ lastUpdated: cachedProps.current.lastUpdated
6864
+ }, strings: props.strings, onDismiss: () => {
6859
6865
  if (cachedProps.current.latestStringState.callRecordState === 'stopped') {
6860
6866
  cachedProps.current.latestStringState.callRecordState = 'off';
6861
6867
  }
6862
6868
  if (cachedProps.current.latestStringState.callTranscribeState === 'stopped') {
6863
6869
  cachedProps.current.latestStringState.callTranscribeState = 'off';
6864
6870
  }
6865
- }, dismissButtonAriaLabel: props.strings.close },
6866
- React__default['default'].createElement(BannerMessage, { variant: variant, strings: props.strings })));
6871
+ } }));
6867
6872
  };
6868
6873
  function determineStates(previous, current) {
6869
6874
  // if current state is on, then return on
@@ -6882,6 +6887,67 @@ function determineStates(previous, current) {
6882
6887
  }
6883
6888
  }
6884
6889
  }
6890
+ /**
6891
+ * Shows a {@link BannerMessage} in a {@link MessageBar} tracking `variant` internally.
6892
+ *
6893
+ * This component delays and combines frequent updates to `variant` such that:
6894
+ * - Updates that happen within {@link BANNER_OVERWRITE_DELAY_MS} are delayed.
6895
+ * - Once {@link BANNER_OVERWRITE_DELAY_MS} has passed since the last update, the _latest_ pending update is shown.
6896
+ *
6897
+ * This ensures that there is enough time for the user to see a banner message before it is overwritten.
6898
+ * In case of multiple delayed messages, the user always sees the final message as it reflects the final state
6899
+ * of recording and transcription.
6900
+ *
6901
+ * @private
6902
+ */
6903
+ function DelayedUpdateBanner(props) {
6904
+ const { variant, lastUpdated: variantLastUpdated } = props.variant;
6905
+ // Tracks the variant that is currently visible in the UI.
6906
+ const [visible, setVisible] = React.useState({
6907
+ variant,
6908
+ lastUpdated: Date.now()
6909
+ });
6910
+ const pendingUpdateHandle = React.useRef(null);
6911
+ if (variant !== visible.variant && variantLastUpdated > visible.lastUpdated) {
6912
+ // Always clear pending updates.
6913
+ // We'll either update now, or schedule an update for later.
6914
+ if (pendingUpdateHandle.current) {
6915
+ clearTimeout(pendingUpdateHandle.current);
6916
+ pendingUpdateHandle.current = null;
6917
+ }
6918
+ const now = Date.now();
6919
+ const timeToNextUpdate = BANNER_OVERWRITE_DELAY_MS - (now - visible.lastUpdated);
6920
+ if (variant === 'NO_STATE' || timeToNextUpdate <= 0) {
6921
+ setVisible({
6922
+ variant,
6923
+ lastUpdated: now
6924
+ });
6925
+ }
6926
+ else {
6927
+ pendingUpdateHandle.current = setTimeout(() => {
6928
+ // Set the actual update time, not the computed time when the update should happen.
6929
+ // The actual update might be later than we planned.
6930
+ setVisible({
6931
+ variant,
6932
+ lastUpdated: Date.now()
6933
+ });
6934
+ }, timeToNextUpdate);
6935
+ }
6936
+ }
6937
+ if (visible.variant === 'NO_STATE') {
6938
+ return React__default['default'].createElement(React__default['default'].Fragment, null);
6939
+ }
6940
+ return (React__default['default'].createElement(react.MessageBar, { messageBarType: react.MessageBarType.warning, onDismiss: () => {
6941
+ // when closing the banner, change variant to nostate and change stopped state to off state.
6942
+ // Reason: on banner close, going back to the default state.
6943
+ setVisible({
6944
+ variant: 'NO_STATE',
6945
+ lastUpdated: Date.now()
6946
+ });
6947
+ props.onDismiss();
6948
+ }, dismissButtonAriaLabel: props.strings.close },
6949
+ React__default['default'].createElement(BannerMessage, { variant: visible.variant, strings: props.strings })));
6950
+ }
6885
6951
  function BannerMessage(props) {
6886
6952
  const { variant, strings } = props;
6887
6953
  switch (variant) {
@@ -15382,7 +15448,7 @@ const CallWithChatControlBar = (props) => {
15382
15448
  isEnabled$1(options.cameraButton) && (React__default['default'].createElement(Camera, { displayType: options.displayType, styles: commonButtonStyles, splitButtonsForDeviceSelection: !props.mobileView })),
15383
15449
  props.mobileView && isEnabled$1(options === null || options === void 0 ? void 0 : options.chatButton) && chatButton,
15384
15450
  isEnabled$1(options.screenShareButton) && (React__default['default'].createElement(ScreenShare, { option: options.screenShareButton, displayType: options.displayType, styles: screenShareButtonStyles })),
15385
- props.mobileView && (React__default['default'].createElement(MoreButton, { "data-ui-id": "call-with-chat-composite-more-button", strings: moreButtonStrings, onClick: props.onMoreButtonClicked })),
15451
+ props.mobileView && (React__default['default'].createElement(MoreButton, { "data-ui-id": "call-with-chat-composite-more-button", strings: moreButtonStrings, onClick: props.onMoreButtonClicked, disabled: props.disableButtonsForLobbyPage })),
15386
15452
  React__default['default'].createElement(EndCall, { displayType: "compact", styles: endCallButtonStyles })))))),
15387
15453
  !props.mobileView && (React__default['default'].createElement(react.Stack, { horizontal: true, className: !props.mobileView ? react.mergeStyles(desktopButtonContainerStyle) : undefined },
15388
15454
  isEnabled$1(options === null || options === void 0 ? void 0 : options.peopleButton) && (React__default['default'].createElement(PeopleButton, { checked: props.peopleButtonChecked, showLabel: true, onClick: props.onPeopleButtonClicked, "data-ui-id": "call-with-chat-composite-people-button", disabled: props.disableButtonsForLobbyPage, strings: peopleButtonStrings, styles: commonButtonStyles })),
@@ -16369,10 +16435,20 @@ const CallWithChatScreen = (props) => {
16369
16435
  const closePane = React.useCallback(() => {
16370
16436
  setActivePane('none');
16371
16437
  }, [setActivePane]);
16438
+ const chatProps = React.useMemo(() => {
16439
+ return {
16440
+ adapter: new CallWithChatBackedChatAdapter(callWithChatAdapter)
16441
+ };
16442
+ }, [callWithChatAdapter]);
16443
+ const modalLayerHostId = reactHooks.useId('modalLayerhost');
16444
+ const isInLobbyOrConnecting = currentPage === 'lobby';
16445
+ const hasJoinedCall = !!(currentPage && hasJoinedCallFn(currentPage, currentCallState !== null && currentCallState !== void 0 ? currentCallState : 'None'));
16446
+ const showControlBar = isInLobbyOrConnecting || hasJoinedCall;
16447
+ const isMobileWithActivePane = mobileView && activePane !== 'none';
16372
16448
  /** Constant setting of id for the parent stack of the composite */
16373
16449
  const compositeParentDivId = reactHooks.useId('callWithChatCompositeParentDiv-internal');
16374
16450
  const toggleChat = React.useCallback(() => {
16375
- if (activePane === 'chat') {
16451
+ if (activePane === 'chat' || !hasJoinedCall) {
16376
16452
  setActivePane('none');
16377
16453
  }
16378
16454
  else {
@@ -16391,21 +16467,25 @@ const CallWithChatScreen = (props) => {
16391
16467
  clearInterval(chatFocusTimeout);
16392
16468
  }, 300);
16393
16469
  }
16394
- }, [activePane, setActivePane, compositeParentDivId]);
16470
+ }, [activePane, setActivePane, compositeParentDivId, hasJoinedCall]);
16395
16471
  const togglePeople = React.useCallback(() => {
16396
- if (activePane === 'people') {
16472
+ if (activePane === 'people' || !hasJoinedCall) {
16397
16473
  setActivePane('none');
16398
16474
  }
16399
16475
  else {
16400
16476
  setActivePane('people');
16401
16477
  }
16402
- }, [activePane, setActivePane]);
16478
+ }, [activePane, setActivePane, hasJoinedCall]);
16403
16479
  const selectChat = React.useCallback(() => {
16404
- setActivePane('chat');
16405
- }, [setActivePane]);
16480
+ if (hasJoinedCall) {
16481
+ setActivePane('chat');
16482
+ }
16483
+ }, [setActivePane, hasJoinedCall]);
16406
16484
  const selectPeople = React.useCallback(() => {
16407
- setActivePane('people');
16408
- }, [setActivePane]);
16485
+ if (hasJoinedCall) {
16486
+ setActivePane('people');
16487
+ }
16488
+ }, [setActivePane, hasJoinedCall]);
16409
16489
  const [showDrawer, setShowDrawer] = React.useState(false);
16410
16490
  const onMoreButtonClicked = React.useCallback(() => {
16411
16491
  closePane();
@@ -16418,16 +16498,6 @@ const CallWithChatScreen = (props) => {
16418
16498
  setShowDrawer(false);
16419
16499
  togglePeople();
16420
16500
  }, [togglePeople]);
16421
- const chatProps = React.useMemo(() => {
16422
- return {
16423
- adapter: new CallWithChatBackedChatAdapter(callWithChatAdapter)
16424
- };
16425
- }, [callWithChatAdapter]);
16426
- const modalLayerHostId = reactHooks.useId('modalLayerhost');
16427
- const isInLobbyOrConnecting = currentPage === 'lobby';
16428
- const hasJoinedCall = !!(currentPage && hasJoinedCallFn(currentPage, currentCallState !== null && currentCallState !== void 0 ? currentCallState : 'None'));
16429
- const showControlBar = isInLobbyOrConnecting || hasJoinedCall;
16430
- const isMobileWithActivePane = mobileView && activePane !== 'none';
16431
16501
  return (React__default['default'].createElement("div", { ref: containerRef, className: react.mergeStyles(containerDivStyles) },
16432
16502
  React__default['default'].createElement(react.Stack, { verticalFill: true, grow: true, styles: compositeOuterContainerStyles, id: compositeParentDivId },
16433
16503
  React__default['default'].createElement(react.Stack, { horizontal: true, grow: true },