@azure/communication-react 1.5.1-alpha-202305260013 → 1.5.1-alpha-202305270013

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/communication-react.d.ts +2 -2
  2. package/dist/dist-cjs/communication-react/index.js +168 -42
  3. package/dist/dist-cjs/communication-react/index.js.map +1 -1
  4. package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js +1 -1
  5. package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js.map +1 -1
  6. package/dist/dist-esm/react-components/src/components/DevicesButton.js +9 -0
  7. package/dist/dist-esm/react-components/src/components/DevicesButton.js.map +1 -1
  8. package/dist/dist-esm/react-components/src/components/Drawer/DrawerMenu.d.ts +5 -0
  9. package/dist/dist-esm/react-components/src/components/Drawer/DrawerMenu.js +1 -1
  10. package/dist/dist-esm/react-components/src/components/Drawer/DrawerMenu.js.map +1 -1
  11. package/dist/dist-esm/react-components/src/components/Drawer/DrawerSurface.d.ts +5 -0
  12. package/dist/dist-esm/react-components/src/components/Drawer/DrawerSurface.js +23 -5
  13. package/dist/dist-esm/react-components/src/components/Drawer/DrawerSurface.js.map +1 -1
  14. package/dist/dist-esm/react-components/src/components/InputBoxComponent.js +127 -28
  15. package/dist/dist-esm/react-components/src/components/InputBoxComponent.js.map +1 -1
  16. package/dist/dist-esm/react-components/src/components/styles/VideoTile.styles.js +2 -1
  17. package/dist/dist-esm/react-components/src/components/styles/VideoTile.styles.js.map +1 -1
  18. package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/CallAdapter.d.ts +2 -2
  19. package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/CallAdapter.js.map +1 -1
  20. package/dist/dist-esm/react-composites/src/composites/CallComposite/components/CallReadinessModal.js +3 -3
  21. package/dist/dist-esm/react-composites/src/composites/CallComposite/components/CallReadinessModal.js.map +1 -1
  22. package/dist/dist-esm/react-composites/src/composites/CallComposite/index.d.ts +1 -1
  23. package/dist/dist-esm/react-composites/src/composites/CallComposite/index.js.map +1 -1
  24. package/dist/dist-esm/react-composites/src/composites/common/AddPeopleDropdown.js +1 -1
  25. package/dist/dist-esm/react-composites/src/composites/common/AddPeopleDropdown.js.map +1 -1
  26. package/dist/dist-esm/react-composites/src/composites/common/CallingDialpad.js +1 -1
  27. package/dist/dist-esm/react-composites/src/composites/common/CallingDialpad.js.map +1 -1
  28. package/dist/dist-esm/react-composites/src/composites/common/Drawer/SpokenLanguageDrawer.styles.js +0 -1
  29. package/dist/dist-esm/react-composites/src/composites/common/Drawer/SpokenLanguageDrawer.styles.js.map +1 -1
  30. package/dist/dist-esm/react-composites/src/composites/common/SendDtmfDialpad.js +1 -1
  31. package/dist/dist-esm/react-composites/src/composites/common/SendDtmfDialpad.js.map +1 -1
  32. package/dist/dist-esm/react-composites/src/composites/common/VideoEffectsPane.js.map +1 -1
  33. package/package.json +8 -8
@@ -2,5 +2,5 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
4
  // GENERATED FILE. DO NOT EDIT MANUALLY.
5
- module.exports = '1.5.1-alpha-202305260013';
5
+ module.exports = '1.5.1-alpha-202305270013';
6
6
  //# sourceMappingURL=telemetryVersion.js.map
@@ -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,0BAA0B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// GENERATED FILE. DO NOT EDIT MANUALLY.\n\nmodule.exports = '1.5.1-alpha-202305260013';\n"]}
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,0BAA0B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// GENERATED FILE. DO NOT EDIT MANUALLY.\n\nmodule.exports = '1.5.1-alpha-202305270013';\n"]}
@@ -43,6 +43,9 @@ export const generateDefaultDeviceMenuProps = (props, strings, primaryActionItem
43
43
  key: 'sectionCamera',
44
44
  title: strings.cameraMenuTooltip,
45
45
  subMenuProps: {
46
+ calloutProps: {
47
+ preventDismissOnEvent
48
+ },
46
49
  items: cameras.map((camera) => ({
47
50
  key: camera.id,
48
51
  text: camera.name,
@@ -83,6 +86,9 @@ export const generateDefaultDeviceMenuProps = (props, strings, primaryActionItem
83
86
  key: key,
84
87
  title: title,
85
88
  subMenuProps: {
89
+ calloutProps: {
90
+ preventDismissOnEvent
91
+ },
86
92
  items: microphones.map((microphone) => ({
87
93
  key: microphone.id,
88
94
  text: microphone.name,
@@ -115,6 +121,9 @@ export const generateDefaultDeviceMenuProps = (props, strings, primaryActionItem
115
121
  {
116
122
  key: 'sectionSpeaker',
117
123
  subMenuProps: {
124
+ calloutProps: {
125
+ preventDismissOnEvent
126
+ },
118
127
  items: speakers.map((speaker) => ({
119
128
  key: speaker.id,
120
129
  text: speaker.name,
@@ -1 +1 @@
1
- {"version":3,"file":"DevicesButton.js","sourceRoot":"","sources":["../../../../../../react-components/src/components/DevicesButton.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,sBAAsB,EAKtB,KAAK,EACN,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAiD,MAAM,oBAAoB,CAAC;AACrG,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAA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,OAAO,CACL,oBAAC,gBAAgB,oBACX,KAAK,IACT,SAAS,EAAE,iBAAiB,EAC5B,aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAC/B,YAAY,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,mBAAmB,EACjD,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAA,KAAK,CAAC,QAAQ,mCAAI,oBAAoB,IAChD,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n ContextualMenuItemType,\n IContextualMenuItem,\n IContextualMenuItemStyles,\n IContextualMenuProps,\n IContextualMenuStyles,\n merge\n} from '@fluentui/react';\nimport React from 'react';\nimport { useLocale } from '../localization';\nimport { ControlBarButton, ControlBarButtonProps, ControlBarButtonStyles } from './ControlBarButton';\nimport { _HighContrastAwareIcon } from './HighContrastAwareIcon';\nimport { buttonFlyoutItemStyles } from './styles/ControlBar.styles';\nimport { _preventDismissOnEvent as preventDismissOnEvent } from '@internal/acs-ui-common';\n\n/**\n * Styles for the {@link DevicesButton} menu.\n *\n * @public\n */\nexport interface DevicesButtonContextualMenuStyles extends IContextualMenuStyles {\n /**\n * Styles for the items inside the {@link DevicesButton} button menu.\n */\n menuItemStyles?: IContextualMenuItemStyles;\n}\n\n/**\n * Styles for the Devices button menu items.\n *\n * @public\n */\nexport interface DevicesButtonStyles extends ControlBarButtonStyles {\n /**\n * Styles for the {@link DevicesButton} menu.\n */\n menuStyles?: Partial<DevicesButtonContextualMenuStyles>;\n}\n\n/**\n * A device, e.g. camera, microphone, or speaker, in the {@link DevicesButton} flyout.\n *\n * @public\n */\nexport interface OptionsDevice {\n /**\n * Device unique identifier\n */\n id: string;\n /**\n * Device name\n */\n name: string;\n}\n\n/**\n * Strings of {@link DevicesButton} that can be overridden.\n *\n * @public\n */\nexport interface DevicesButtonStrings {\n /**\n * Label of button\n */\n label: string;\n /**\n * Button tooltip content.\n */\n tooltipContent?: string;\n /**\n * Title of camera menu\n */\n cameraMenuTitle: string;\n /**\n * Title of microphone menu\n */\n microphoneMenuTitle: string;\n /**\n * Title of speaker menu\n */\n speakerMenuTitle: string;\n /**\n * Tooltip of camera menu\n */\n cameraMenuTooltip: string;\n /**\n * Tooltip of microphone menu\n */\n microphoneMenuTooltip: string;\n /**\n * Tooltip of speaker menu\n */\n speakerMenuTooltip: string;\n}\n\n/**\n * Props for {@link DevicesButton}.\n *\n * @public\n */\nexport interface DevicesButtonProps extends ControlBarButtonProps {\n /**\n * Available microphones for selection\n */\n microphones?: OptionsDevice[];\n /**\n * Available speakers for selection\n */\n speakers?: OptionsDevice[];\n /**\n * Available cameras for selection\n */\n cameras?: OptionsDevice[];\n /**\n * Microphone that is shown as currently selected\n */\n selectedMicrophone?: OptionsDevice;\n /**\n * Speaker that is shown as currently selected\n */\n selectedSpeaker?: OptionsDevice;\n /**\n * Camera that is shown as currently selected\n */\n selectedCamera?: OptionsDevice;\n /**\n * Callback when a camera is selected\n */\n onSelectCamera?: (device: OptionsDevice) => Promise<void>;\n /**\n * Callback when a microphone is selected\n */\n onSelectMicrophone?: (device: OptionsDevice) => Promise<void>;\n /**\n * Speaker when a speaker is selected\n */\n onSelectSpeaker?: (device: OptionsDevice) => Promise<void>;\n /**\n * Optional strings to override in component\n */\n strings?: Partial<DevicesButtonStrings>;\n /**\n * Option to increase the touch targets of the button flyout menu items from 36px to 48px.\n * Recommended for mobile devices.\n */\n styles?: DevicesButtonStyles;\n}\n\n/**\n * Subset props for various buttons that show device selection menus.\n *\n * @private\n */\nexport interface DeviceMenuProps {\n microphones?: OptionsDevice[];\n speakers?: OptionsDevice[];\n cameras?: OptionsDevice[];\n selectedMicrophone?: OptionsDevice;\n selectedSpeaker?: OptionsDevice;\n selectedCamera?: OptionsDevice;\n onSelectCamera?: (device: OptionsDevice) => Promise<void>;\n onSelectMicrophone?: (device: OptionsDevice) => Promise<void>;\n onSelectSpeaker?: (device: OptionsDevice) => Promise<void>;\n styles?: Partial<DeviceMenuStyles>;\n}\n\n/**\n * Subset of strings for various buttons that show device selection menus.\n *\n * @private\n */\nexport interface DeviceMenuStrings {\n /**\n * Title for Camera section in the contextual menu\n */\n cameraMenuTitle?: string;\n /**\n * Title for Audio Device section in the contextual menu\n *\n * @remark Used in place of microphoneMenuTitle when speakers can be enumerated\n */\n audioDeviceMenuTitle?: string;\n /**\n * Title for Microphone section in the contextual menu\n *\n * @remark Used when speakers can be enumerated\n */\n microphoneMenuTitle?: string;\n /**\n * Title for Speaker section in the contextual menu\n */\n speakerMenuTitle?: string;\n /**\n * Tooltip label for Camera section in the contextual menu\n */\n cameraMenuTooltip?: string;\n /**\n * Tooltip label for Audio Device section in the contextual menu\n *\n * @remark Used in place of microphoneMenuTooltip when speakers can be enumerated\n */\n audioDeviceMenuTooltip?: string;\n /**\n * Tooltip label for Microphone section in the contextual menu\n *\n * @remark Used when speakers can be enumerated\n */\n microphoneMenuTooltip?: string;\n /**\n * Tooltip label for Speaker section in the contextual menu\n */\n speakerMenuTooltip?: string;\n}\n\n/**\n * Styles for flyouts used by various buttons for device selection flyouts.\n *\n * @private\n */\nexport interface DeviceMenuStyles extends IContextualMenuStyles {\n menuItemStyles?: IContextualMenuItemStyles;\n}\n\n/**\n * Generates default {@link IContextualMenuProps} for buttons that\n * show a drop-down to select devices to use.\n *\n * @private\n */\nexport const generateDefaultDeviceMenuProps = (\n props: DeviceMenuProps,\n strings: DeviceMenuStrings,\n primaryActionItem?: IContextualMenuItem,\n isSelectCamAllowed = true,\n isSelectMicAllowed = true\n): { items: IContextualMenuItem[] } | undefined => {\n const {\n microphones,\n speakers,\n cameras,\n selectedMicrophone,\n selectedSpeaker,\n selectedCamera,\n onSelectCamera,\n onSelectMicrophone,\n onSelectSpeaker\n } = props;\n\n const defaultMenuProps: IContextualMenuProps = {\n items: [],\n styles: props.styles,\n calloutProps: {\n styles: {\n root: {\n // Confine the menu to the parents bounds.\n // More info: https://github.com/microsoft/fluentui/issues/18835\n // NB: 95% to keep some space for margin, drop shadow etc around the Callout.\n maxWidth: '95%'\n }\n },\n preventDismissOnEvent\n }\n };\n\n const menuItemStyles = merge(buttonFlyoutItemStyles, props.styles?.menuItemStyles ?? {});\n\n if (cameras && selectedCamera && onSelectCamera && isSelectCamAllowed) {\n defaultMenuProps.items.push({\n key: 'cameras',\n itemType: ContextualMenuItemType.Section,\n sectionProps: {\n title: strings.cameraMenuTitle,\n items: [\n {\n key: 'sectionCamera',\n title: strings.cameraMenuTooltip,\n subMenuProps: {\n items: cameras.map((camera) => ({\n key: camera.id,\n text: camera.name,\n title: camera.name,\n itemProps: {\n styles: menuItemStyles\n },\n canCheck: true,\n isChecked: camera.id === selectedCamera?.id,\n onClick: () => {\n if (camera.id !== selectedCamera?.id) {\n onSelectCamera(camera);\n }\n }\n }))\n },\n text: selectedCamera.name\n }\n ]\n }\n });\n if (primaryActionItem) {\n defaultMenuProps.items.push(primaryActionItem);\n }\n }\n\n if (microphones && selectedMicrophone && onSelectMicrophone && isSelectMicAllowed) {\n // Set props as Microphone if speakers can be enumerated else set as Audio Device\n const speakersAvailable = speakers && speakers.length > 0;\n const key = speakersAvailable ? 'sectionMicrophone' : 'sectionAudioDevice';\n const title = speakersAvailable ? strings.microphoneMenuTooltip : strings.audioDeviceMenuTooltip;\n\n defaultMenuProps.items.push({\n key: 'microphones',\n itemType: ContextualMenuItemType.Section,\n sectionProps: {\n title: strings.microphoneMenuTitle,\n items: [\n {\n key: key,\n title: title,\n subMenuProps: {\n items: microphones.map((microphone) => ({\n key: microphone.id,\n text: microphone.name,\n title: microphone.name,\n itemProps: {\n styles: menuItemStyles\n },\n canCheck: true,\n isChecked: microphone.id === selectedMicrophone?.id,\n onClick: () => {\n if (microphone.id !== selectedMicrophone?.id) {\n onSelectMicrophone(microphone);\n }\n }\n }))\n },\n text: selectedMicrophone.name\n }\n ]\n }\n });\n }\n\n if (speakers && selectedSpeaker && onSelectSpeaker) {\n defaultMenuProps.items.push({\n key: 'speakers',\n itemType: ContextualMenuItemType.Section,\n sectionProps: {\n title: strings.speakerMenuTitle,\n items: [\n {\n key: 'sectionSpeaker',\n subMenuProps: {\n items: speakers.map((speaker) => ({\n key: speaker.id,\n text: speaker.name,\n title: speaker.name,\n itemProps: {\n styles: menuItemStyles\n },\n canCheck: true,\n isChecked: speaker.id === selectedSpeaker?.id,\n onClick: () => {\n if (speaker.id !== selectedSpeaker?.id) {\n onSelectSpeaker(speaker);\n }\n }\n }))\n },\n text: selectedSpeaker.name\n }\n ]\n }\n });\n }\n if (microphones && selectedMicrophone && onSelectMicrophone && isSelectMicAllowed && primaryActionItem) {\n defaultMenuProps.items.push(primaryActionItem);\n }\n\n if (defaultMenuProps.items.length === 0) {\n // Avoids creating an empty context menu.\n return undefined;\n }\n return defaultMenuProps;\n};\n\n/**\n * A button to open a menu that controls device options.\n *\n * Can be used with {@link ControlBar}.\n *\n * @public\n */\nexport const DevicesButton = (props: DevicesButtonProps): JSX.Element => {\n const { onRenderIcon } = props;\n\n const localeStrings = useLocale().strings.devicesButton;\n const strings = { ...localeStrings, ...props.strings };\n\n const devicesButtonMenu =\n props.menuProps ?? generateDefaultDeviceMenuProps({ ...props, styles: props.styles?.menuStyles }, strings);\n\n const onRenderOptionsIcon = (): JSX.Element => {\n return <_HighContrastAwareIcon disabled={props.disabled} iconName=\"ControlButtonOptions\" />;\n };\n\n return (\n <ControlBarButton\n {...props}\n menuProps={devicesButtonMenu}\n menuIconProps={{ hidden: true }}\n onRenderIcon={onRenderIcon ?? onRenderOptionsIcon}\n strings={strings}\n labelKey={props.labelKey ?? 'devicesButtonLabel'}\n />\n );\n};\n\"../../../acs-ui-common/src\""]}
1
+ {"version":3,"file":"DevicesButton.js","sourceRoot":"","sources":["../../../../../../react-components/src/components/DevicesButton.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,sBAAsB,EAKtB,KAAK,EACN,MAAM,iBAAiB,CAAC;AACzB,OA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AQ,aAAa,GAAK,KAAK,CAAC,OAAO,CAAE,CAAC;IAEvD,MAAM,iBAAiB,GACrB,MAAA,KAAK,CAAC,SAAS,mCAAI,8BAA8B,iCAAM,KAAK,KAAE,MAAM,EAAE,MAAA,KAAK,CAAC,MAAM,0CAAE,UAAU,KAAI,OAAO,CAAC,CAAC;IAE7G,MAAM,mBAAmB,GAAG,GAAgB,EAAE;QAC5C,OAAO,oBAAC,sBAAsB,IAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAC,sBAAsB,GAAG,CAAC;IAC9F,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,gBAAgB,oBACX,KAAK,IACT,SAAS,EAAE,iBAAiB,EAC5B,aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAC/B,YAAY,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,mBAAmB,EACjD,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAA,KAAK,CAAC,QAAQ,mCAAI,oBAAoB,IAChD,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n ContextualMenuItemType,\n IContextualMenuItem,\n IContextualMenuItemStyles,\n IContextualMenuProps,\n IContextualMenuStyles,\n merge\n} from '@fluentui/react';\nimport React from 'react';\nimport { useLocale } from '../localization';\nimport { ControlBarButton, ControlBarButtonProps, ControlBarButtonStyles } from './ControlBarButton';\nimport { _HighContrastAwareIcon } from './HighContrastAwareIcon';\nimport { buttonFlyoutItemStyles } from './styles/ControlBar.styles';\nimport { _preventDismissOnEvent as preventDismissOnEvent } from '@internal/acs-ui-common';\n\n/**\n * Styles for the {@link DevicesButton} menu.\n *\n * @public\n */\nexport interface DevicesButtonContextualMenuStyles extends IContextualMenuStyles {\n /**\n * Styles for the items inside the {@link DevicesButton} button menu.\n */\n menuItemStyles?: IContextualMenuItemStyles;\n}\n\n/**\n * Styles for the Devices button menu items.\n *\n * @public\n */\nexport interface DevicesButtonStyles extends ControlBarButtonStyles {\n /**\n * Styles for the {@link DevicesButton} menu.\n */\n menuStyles?: Partial<DevicesButtonContextualMenuStyles>;\n}\n\n/**\n * A device, e.g. camera, microphone, or speaker, in the {@link DevicesButton} flyout.\n *\n * @public\n */\nexport interface OptionsDevice {\n /**\n * Device unique identifier\n */\n id: string;\n /**\n * Device name\n */\n name: string;\n}\n\n/**\n * Strings of {@link DevicesButton} that can be overridden.\n *\n * @public\n */\nexport interface DevicesButtonStrings {\n /**\n * Label of button\n */\n label: string;\n /**\n * Button tooltip content.\n */\n tooltipContent?: string;\n /**\n * Title of camera menu\n */\n cameraMenuTitle: string;\n /**\n * Title of microphone menu\n */\n microphoneMenuTitle: string;\n /**\n * Title of speaker menu\n */\n speakerMenuTitle: string;\n /**\n * Tooltip of camera menu\n */\n cameraMenuTooltip: string;\n /**\n * Tooltip of microphone menu\n */\n microphoneMenuTooltip: string;\n /**\n * Tooltip of speaker menu\n */\n speakerMenuTooltip: string;\n}\n\n/**\n * Props for {@link DevicesButton}.\n *\n * @public\n */\nexport interface DevicesButtonProps extends ControlBarButtonProps {\n /**\n * Available microphones for selection\n */\n microphones?: OptionsDevice[];\n /**\n * Available speakers for selection\n */\n speakers?: OptionsDevice[];\n /**\n * Available cameras for selection\n */\n cameras?: OptionsDevice[];\n /**\n * Microphone that is shown as currently selected\n */\n selectedMicrophone?: OptionsDevice;\n /**\n * Speaker that is shown as currently selected\n */\n selectedSpeaker?: OptionsDevice;\n /**\n * Camera that is shown as currently selected\n */\n selectedCamera?: OptionsDevice;\n /**\n * Callback when a camera is selected\n */\n onSelectCamera?: (device: OptionsDevice) => Promise<void>;\n /**\n * Callback when a microphone is selected\n */\n onSelectMicrophone?: (device: OptionsDevice) => Promise<void>;\n /**\n * Speaker when a speaker is selected\n */\n onSelectSpeaker?: (device: OptionsDevice) => Promise<void>;\n /**\n * Optional strings to override in component\n */\n strings?: Partial<DevicesButtonStrings>;\n /**\n * Option to increase the touch targets of the button flyout menu items from 36px to 48px.\n * Recommended for mobile devices.\n */\n styles?: DevicesButtonStyles;\n}\n\n/**\n * Subset props for various buttons that show device selection menus.\n *\n * @private\n */\nexport interface DeviceMenuProps {\n microphones?: OptionsDevice[];\n speakers?: OptionsDevice[];\n cameras?: OptionsDevice[];\n selectedMicrophone?: OptionsDevice;\n selectedSpeaker?: OptionsDevice;\n selectedCamera?: OptionsDevice;\n onSelectCamera?: (device: OptionsDevice) => Promise<void>;\n onSelectMicrophone?: (device: OptionsDevice) => Promise<void>;\n onSelectSpeaker?: (device: OptionsDevice) => Promise<void>;\n styles?: Partial<DeviceMenuStyles>;\n}\n\n/**\n * Subset of strings for various buttons that show device selection menus.\n *\n * @private\n */\nexport interface DeviceMenuStrings {\n /**\n * Title for Camera section in the contextual menu\n */\n cameraMenuTitle?: string;\n /**\n * Title for Audio Device section in the contextual menu\n *\n * @remark Used in place of microphoneMenuTitle when speakers can be enumerated\n */\n audioDeviceMenuTitle?: string;\n /**\n * Title for Microphone section in the contextual menu\n *\n * @remark Used when speakers can be enumerated\n */\n microphoneMenuTitle?: string;\n /**\n * Title for Speaker section in the contextual menu\n */\n speakerMenuTitle?: string;\n /**\n * Tooltip label for Camera section in the contextual menu\n */\n cameraMenuTooltip?: string;\n /**\n * Tooltip label for Audio Device section in the contextual menu\n *\n * @remark Used in place of microphoneMenuTooltip when speakers can be enumerated\n */\n audioDeviceMenuTooltip?: string;\n /**\n * Tooltip label for Microphone section in the contextual menu\n *\n * @remark Used when speakers can be enumerated\n */\n microphoneMenuTooltip?: string;\n /**\n * Tooltip label for Speaker section in the contextual menu\n */\n speakerMenuTooltip?: string;\n}\n\n/**\n * Styles for flyouts used by various buttons for device selection flyouts.\n *\n * @private\n */\nexport interface DeviceMenuStyles extends IContextualMenuStyles {\n menuItemStyles?: IContextualMenuItemStyles;\n}\n\n/**\n * Generates default {@link IContextualMenuProps} for buttons that\n * show a drop-down to select devices to use.\n *\n * @private\n */\nexport const generateDefaultDeviceMenuProps = (\n props: DeviceMenuProps,\n strings: DeviceMenuStrings,\n primaryActionItem?: IContextualMenuItem,\n isSelectCamAllowed = true,\n isSelectMicAllowed = true\n): { items: IContextualMenuItem[] } | undefined => {\n const {\n microphones,\n speakers,\n cameras,\n selectedMicrophone,\n selectedSpeaker,\n selectedCamera,\n onSelectCamera,\n onSelectMicrophone,\n onSelectSpeaker\n } = props;\n\n const defaultMenuProps: IContextualMenuProps = {\n items: [],\n styles: props.styles,\n calloutProps: {\n styles: {\n root: {\n // Confine the menu to the parents bounds.\n // More info: https://github.com/microsoft/fluentui/issues/18835\n // NB: 95% to keep some space for margin, drop shadow etc around the Callout.\n maxWidth: '95%'\n }\n },\n preventDismissOnEvent\n }\n };\n\n const menuItemStyles = merge(buttonFlyoutItemStyles, props.styles?.menuItemStyles ?? {});\n\n if (cameras && selectedCamera && onSelectCamera && isSelectCamAllowed) {\n defaultMenuProps.items.push({\n key: 'cameras',\n itemType: ContextualMenuItemType.Section,\n sectionProps: {\n title: strings.cameraMenuTitle,\n items: [\n {\n key: 'sectionCamera',\n title: strings.cameraMenuTooltip,\n subMenuProps: {\n calloutProps: {\n preventDismissOnEvent\n },\n items: cameras.map((camera) => ({\n key: camera.id,\n text: camera.name,\n title: camera.name,\n itemProps: {\n styles: menuItemStyles\n },\n canCheck: true,\n isChecked: camera.id === selectedCamera?.id,\n onClick: () => {\n if (camera.id !== selectedCamera?.id) {\n onSelectCamera(camera);\n }\n }\n }))\n },\n text: selectedCamera.name\n }\n ]\n }\n });\n if (primaryActionItem) {\n defaultMenuProps.items.push(primaryActionItem);\n }\n }\n\n if (microphones && selectedMicrophone && onSelectMicrophone && isSelectMicAllowed) {\n // Set props as Microphone if speakers can be enumerated else set as Audio Device\n const speakersAvailable = speakers && speakers.length > 0;\n const key = speakersAvailable ? 'sectionMicrophone' : 'sectionAudioDevice';\n const title = speakersAvailable ? strings.microphoneMenuTooltip : strings.audioDeviceMenuTooltip;\n\n defaultMenuProps.items.push({\n key: 'microphones',\n itemType: ContextualMenuItemType.Section,\n sectionProps: {\n title: strings.microphoneMenuTitle,\n items: [\n {\n key: key,\n title: title,\n subMenuProps: {\n calloutProps: {\n preventDismissOnEvent\n },\n items: microphones.map((microphone) => ({\n key: microphone.id,\n text: microphone.name,\n title: microphone.name,\n itemProps: {\n styles: menuItemStyles\n },\n canCheck: true,\n isChecked: microphone.id === selectedMicrophone?.id,\n onClick: () => {\n if (microphone.id !== selectedMicrophone?.id) {\n onSelectMicrophone(microphone);\n }\n }\n }))\n },\n text: selectedMicrophone.name\n }\n ]\n }\n });\n }\n\n if (speakers && selectedSpeaker && onSelectSpeaker) {\n defaultMenuProps.items.push({\n key: 'speakers',\n itemType: ContextualMenuItemType.Section,\n sectionProps: {\n title: strings.speakerMenuTitle,\n items: [\n {\n key: 'sectionSpeaker',\n subMenuProps: {\n calloutProps: {\n preventDismissOnEvent\n },\n items: speakers.map((speaker) => ({\n key: speaker.id,\n text: speaker.name,\n title: speaker.name,\n itemProps: {\n styles: menuItemStyles\n },\n canCheck: true,\n isChecked: speaker.id === selectedSpeaker?.id,\n onClick: () => {\n if (speaker.id !== selectedSpeaker?.id) {\n onSelectSpeaker(speaker);\n }\n }\n }))\n },\n text: selectedSpeaker.name\n }\n ]\n }\n });\n }\n if (microphones && selectedMicrophone && onSelectMicrophone && isSelectMicAllowed && primaryActionItem) {\n defaultMenuProps.items.push(primaryActionItem);\n }\n\n if (defaultMenuProps.items.length === 0) {\n // Avoids creating an empty context menu.\n return undefined;\n }\n return defaultMenuProps;\n};\n\n/**\n * A button to open a menu that controls device options.\n *\n * Can be used with {@link ControlBar}.\n *\n * @public\n */\nexport const DevicesButton = (props: DevicesButtonProps): JSX.Element => {\n const { onRenderIcon } = props;\n\n const localeStrings = useLocale().strings.devicesButton;\n const strings = { ...localeStrings, ...props.strings };\n\n const devicesButtonMenu =\n props.menuProps ?? generateDefaultDeviceMenuProps({ ...props, styles: props.styles?.menuStyles }, strings);\n\n const onRenderOptionsIcon = (): JSX.Element => {\n return <_HighContrastAwareIcon disabled={props.disabled} iconName=\"ControlButtonOptions\" />;\n };\n\n return (\n <ControlBarButton\n {...props}\n menuProps={devicesButtonMenu}\n menuIconProps={{ hidden: true }}\n onRenderIcon={onRenderIcon ?? onRenderOptionsIcon}\n strings={strings}\n labelKey={props.labelKey ?? 'devicesButtonLabel'}\n />\n );\n};\n\"../../../acs-ui-common/src\""]}
@@ -26,6 +26,11 @@ export interface _DrawerMenuProps {
26
26
  * String to show in heading of drawer menu
27
27
  */
28
28
  heading?: string;
29
+ /**
30
+ * By default, maxHeight value is set to 75%.
31
+ * Set value to true for no default maxHeight to be applied on drawerSurface
32
+ */
33
+ disableMaxHeight?: boolean;
29
34
  styles?: _DrawerMenuStyles;
30
35
  }
31
36
  /**
@@ -43,7 +43,7 @@ export const _DrawerMenu = (props) => {
43
43
  borderTopLeftRadius: borderRadius
44
44
  }
45
45
  }), [firstItemStyle, borderRadius]);
46
- return (React.createElement(_DrawerSurface, { styles: (_b = props.styles) === null || _b === void 0 ? void 0 : _b.drawerSurfaceStyles, onLightDismiss: props.onLightDismiss, heading: props.heading },
46
+ return (React.createElement(_DrawerSurface, { disableMaxHeight: props.disableMaxHeight, styles: (_b = props.styles) === null || _b === void 0 ? void 0 : _b.drawerSurfaceStyles, onLightDismiss: props.onLightDismiss, heading: props.heading },
47
47
  React.createElement(Stack, { styles: props.styles, role: "menu", "data-ui-id": "drawer-menu" }, menuItemsToRender === null || menuItemsToRender === void 0 ? void 0 :
48
48
  menuItemsToRender.slice(0, 1).map((item) => (React.createElement(DrawerMenuItem, Object.assign({}, item, { key: '0', styles: modifiedFirstItemStyle, onItemClick: (ev, itemKey) => {
49
49
  onItemClick(item, ev, itemKey);
@@ -1 +1 @@
1
- {"version":3,"file":"DrawerMenu.js","sourceRoot":"","sources":["../../../../../../../react-components/src/components/Drawer/DrawerMenu.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;A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AE,CAAC,CAC5C,oBAAC,cAAc,oBACT,IAAI,IACR,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,EACf,WAAW,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE;oBAC3B,WAAW,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;gBACjC,CAAC,IACD,CACH,CAAC,CACI,CACO,CAClB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { merge, Stack } from '@fluentui/react';\nimport React, { useCallback, useMemo, useState } from 'react';\nimport { _DrawerSurfaceProps } from '.';\nimport { useTheme } from '../../theming/FluentThemeProvider';\nimport { BaseCustomStyles } from '../../types';\nimport { DrawerMenuItem, _DrawerMenuItemProps } from './DrawerMenuItem';\nimport { _DrawerSurface, _DrawerSurfaceStyles } from './DrawerSurface';\n\n/**\n * Styles for the {@link _DrawerMenu}.\n *\n * @internal\n */\nexport interface _DrawerMenuStyles extends BaseCustomStyles {\n /** Styles for the {@link DrawerSurface} container. */\n drawerSurfaceStyles?: _DrawerSurfaceStyles;\n}\n\n/**\n * Props for the {@link _DrawerMenu}\n *\n * @internal\n */\nexport interface _DrawerMenuProps {\n items: _DrawerMenuItemProps[];\n\n /**\n * Callback when the drawer's light-dismissal is triggered.\n */\n onLightDismiss: () => void;\n\n /**\n * String to show in heading of drawer menu\n */\n heading?: string;\n\n styles?: _DrawerMenuStyles;\n}\n\n/**\n * Takes a set of menu items and returns a created menu inside a {@link _DrawerSurface}.\n *\n * @internal\n */\nexport const _DrawerMenu = (props: _DrawerMenuProps): JSX.Element => {\n // This component breaks from a pure component pattern in order to internally support sub menus.\n // When a sub menu item is clicked the menu items displayed is updated to be that of the submenu.\n // To track this state we store a list of the keys clicked up until this point.\n const [selectedKeyPath, setSelectedKeyPath] = useState<string[]>([]);\n\n // Get the menu items that should be rendered\n const menuItemsToRender = useMemo(() => {\n let items: _DrawerMenuItemProps[] | undefined = props.items;\n for (const subMenuKey of selectedKeyPath) {\n items = items?.find((item) => item.itemKey === subMenuKey)?.subMenuProps;\n }\n return items;\n }, [props.items, selectedKeyPath]);\n\n // When an item is clicked and it contains a submenu, push the key for the submenu. This will ensure\n // a new render is triggered, menuItemsToRender will be re-calculated and the submenu will render.\n const onItemClick = useCallback(\n (\n item: _DrawerMenuItemProps,\n ev?: React.MouseEvent<HTMLElement, MouseEvent> | React.KeyboardEvent<HTMLElement> | undefined,\n itemKey?: string | undefined\n ): void => {\n if (item.subMenuProps) {\n setSelectedKeyPath([...selectedKeyPath, item.itemKey]);\n }\n\n item.onItemClick?.(ev, itemKey);\n },\n [selectedKeyPath]\n );\n\n // Ensure the first item has a border radius that matches the DrawerSurface\n const borderRadius = useTheme().effects.roundedCorner4;\n const firstItemStyle = menuItemsToRender && menuItemsToRender[0]?.styles;\n const modifiedFirstItemStyle = useMemo(\n () =>\n merge(firstItemStyle ?? {}, {\n root: {\n borderTopRightRadius: borderRadius,\n borderTopLeftRadius: borderRadius\n }\n }),\n [firstItemStyle, borderRadius]\n );\n\n return (\n <_DrawerSurface\n styles={props.styles?.drawerSurfaceStyles}\n onLightDismiss={props.onLightDismiss}\n heading={props.heading}\n >\n <Stack styles={props.styles} role=\"menu\" data-ui-id=\"drawer-menu\">\n {menuItemsToRender?.slice(0, 1).map((item) => (\n <DrawerMenuItem\n {...item}\n key={'0'}\n styles={modifiedFirstItemStyle}\n onItemClick={(ev, itemKey) => {\n onItemClick(item, ev, itemKey);\n }}\n />\n ))}\n {menuItemsToRender?.slice(1).map((item, i) => (\n <DrawerMenuItem\n {...item}\n key={`${i + 1}`}\n onItemClick={(ev, itemKey) => {\n onItemClick(item, ev, itemKey);\n }}\n />\n ))}\n </Stack>\n </_DrawerSurface>\n );\n};\n"]}
1
+ {"version":3,"file":"DrawerMenu.js","sourceRoot":"","sources":["../../../../../../../react-components/src/components/Drawer/DrawerMenu.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC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,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAC5C,oBAAC,cAAc,oBACT,IAAI,IACR,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,EACf,WAAW,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE;oBAC3B,WAAW,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;gBACjC,CAAC,IACD,CACH,CAAC,CACI,CACO,CAClB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { merge, Stack } from '@fluentui/react';\nimport React, { useCallback, useMemo, useState } from 'react';\nimport { _DrawerSurfaceProps } from '.';\nimport { useTheme } from '../../theming/FluentThemeProvider';\nimport { BaseCustomStyles } from '../../types';\nimport { DrawerMenuItem, _DrawerMenuItemProps } from './DrawerMenuItem';\nimport { _DrawerSurface, _DrawerSurfaceStyles } from './DrawerSurface';\n\n/**\n * Styles for the {@link _DrawerMenu}.\n *\n * @internal\n */\nexport interface _DrawerMenuStyles extends BaseCustomStyles {\n /** Styles for the {@link DrawerSurface} container. */\n drawerSurfaceStyles?: _DrawerSurfaceStyles;\n}\n\n/**\n * Props for the {@link _DrawerMenu}\n *\n * @internal\n */\nexport interface _DrawerMenuProps {\n items: _DrawerMenuItemProps[];\n\n /**\n * Callback when the drawer's light-dismissal is triggered.\n */\n onLightDismiss: () => void;\n\n /**\n * String to show in heading of drawer menu\n */\n heading?: string;\n\n /**\n * By default, maxHeight value is set to 75%.\n * Set value to true for no default maxHeight to be applied on drawerSurface\n */\n disableMaxHeight?: boolean;\n\n styles?: _DrawerMenuStyles;\n}\n\n/**\n * Takes a set of menu items and returns a created menu inside a {@link _DrawerSurface}.\n *\n * @internal\n */\nexport const _DrawerMenu = (props: _DrawerMenuProps): JSX.Element => {\n // This component breaks from a pure component pattern in order to internally support sub menus.\n // When a sub menu item is clicked the menu items displayed is updated to be that of the submenu.\n // To track this state we store a list of the keys clicked up until this point.\n const [selectedKeyPath, setSelectedKeyPath] = useState<string[]>([]);\n\n // Get the menu items that should be rendered\n const menuItemsToRender = useMemo(() => {\n let items: _DrawerMenuItemProps[] | undefined = props.items;\n for (const subMenuKey of selectedKeyPath) {\n items = items?.find((item) => item.itemKey === subMenuKey)?.subMenuProps;\n }\n return items;\n }, [props.items, selectedKeyPath]);\n\n // When an item is clicked and it contains a submenu, push the key for the submenu. This will ensure\n // a new render is triggered, menuItemsToRender will be re-calculated and the submenu will render.\n const onItemClick = useCallback(\n (\n item: _DrawerMenuItemProps,\n ev?: React.MouseEvent<HTMLElement, MouseEvent> | React.KeyboardEvent<HTMLElement> | undefined,\n itemKey?: string | undefined\n ): void => {\n if (item.subMenuProps) {\n setSelectedKeyPath([...selectedKeyPath, item.itemKey]);\n }\n\n item.onItemClick?.(ev, itemKey);\n },\n [selectedKeyPath]\n );\n\n // Ensure the first item has a border radius that matches the DrawerSurface\n const borderRadius = useTheme().effects.roundedCorner4;\n const firstItemStyle = menuItemsToRender && menuItemsToRender[0]?.styles;\n const modifiedFirstItemStyle = useMemo(\n () =>\n merge(firstItemStyle ?? {}, {\n root: {\n borderTopRightRadius: borderRadius,\n borderTopLeftRadius: borderRadius\n }\n }),\n [firstItemStyle, borderRadius]\n );\n\n return (\n <_DrawerSurface\n disableMaxHeight={props.disableMaxHeight}\n styles={props.styles?.drawerSurfaceStyles}\n onLightDismiss={props.onLightDismiss}\n heading={props.heading}\n >\n <Stack styles={props.styles} role=\"menu\" data-ui-id=\"drawer-menu\">\n {menuItemsToRender?.slice(0, 1).map((item) => (\n <DrawerMenuItem\n {...item}\n key={'0'}\n styles={modifiedFirstItemStyle}\n onItemClick={(ev, itemKey) => {\n onItemClick(item, ev, itemKey);\n }}\n />\n ))}\n {menuItemsToRender?.slice(1).map((item, i) => (\n <DrawerMenuItem\n {...item}\n key={`${i + 1}`}\n onItemClick={(ev, itemKey) => {\n onItemClick(item, ev, itemKey);\n }}\n />\n ))}\n </Stack>\n </_DrawerSurface>\n );\n};\n"]}
@@ -29,6 +29,11 @@ export interface _DrawerSurfaceProps {
29
29
  * String to show in heading of drawer surface
30
30
  */
31
31
  heading?: string;
32
+ /**
33
+ * By default, maxHeight value is set to 75%.
34
+ * Set value to true for no default maxHeight to be applied on drawerSurface
35
+ */
36
+ disableMaxHeight?: boolean;
32
37
  /** Styles for the {@link DrawerSurface} */
33
38
  styles?: _DrawerSurfaceStyles;
34
39
  }
@@ -1,6 +1,6 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
- import { FocusTrapZone, mergeStyles, Stack } from '@fluentui/react';
3
+ import { FocusTrapZone, mergeStyles, mergeStyleSets, Stack } from '@fluentui/react';
4
4
  import React from 'react';
5
5
  import { DrawerContentContainer } from './DrawerContentContainer';
6
6
  import { DrawerLightDismiss } from './DrawerLightDismiss';
@@ -11,10 +11,13 @@ import { DrawerLightDismiss } from './DrawerLightDismiss';
11
11
  * @internal
12
12
  */
13
13
  export const _DrawerSurface = (props) => {
14
- var _a, _b, _c;
15
- const rootStyles = mergeStyles(drawerSurfaceStyles, (_a = props.styles) === null || _a === void 0 ? void 0 : _a.root);
14
+ var _a, _b, _c, _d;
15
+ const rootStyles = props.disableMaxHeight
16
+ ? mergeStyles(drawerSurfaceStyles, (_a = props.styles) === null || _a === void 0 ? void 0 : _a.root)
17
+ : mergeStyles(drawerSurfaceStyles, focusTrapZoneStyles, (_b = props.styles) === null || _b === void 0 ? void 0 : _b.root);
18
+ const containerStyles = mergeStyleSets(drawerContentContainerStyles, (_c = props.styles) === null || _c === void 0 ? void 0 : _c.drawerContentContainer);
16
19
  return (React.createElement(Stack, { className: rootStyles },
17
- React.createElement(DrawerLightDismiss, { styles: (_b = props.styles) === null || _b === void 0 ? void 0 : _b.lightDismissRoot, onDismiss: props.onLightDismiss }),
20
+ React.createElement(DrawerLightDismiss, { styles: (_d = props.styles) === null || _d === void 0 ? void 0 : _d.lightDismissRoot, onDismiss: props.onLightDismiss }),
18
21
  React.createElement(FocusTrapZone, { onKeyDown: (e) => {
19
22
  if (e.key === 'Escape' || e.key === 'Esc') {
20
23
  props.onLightDismiss && props.onLightDismiss();
@@ -23,11 +26,26 @@ export const _DrawerSurface = (props) => {
23
26
  // Ensure when the focus trap has focus, the light dismiss area can still be clicked with mouse to dismiss.
24
27
  // Note: this still correctly captures keyboard focus, this just allows mouse click outside of the focus trap.
25
28
  isClickableOutsideFocusTrap: true },
26
- React.createElement(DrawerContentContainer, { styles: (_c = props.styles) === null || _c === void 0 ? void 0 : _c.drawerContentContainer, heading: props.heading }, props.children))));
29
+ React.createElement(DrawerContentContainer, { styles: containerStyles, heading: props.heading }, props.children))));
27
30
  };
28
31
  const drawerSurfaceStyles = {
29
32
  width: '100%',
30
33
  height: '100%',
31
34
  background: 'rgba(0,0,0,0.4)'
32
35
  };
36
+ const focusTrapZoneStyles = {
37
+ // Targets FocusTrapZone in drawer.
38
+ // Setting percentage to Height to transform a container does not work unless the
39
+ // direct parent container also has a Height set other than 'auto'.
40
+ '> div:nth-child(2)': {
41
+ maxHeight: '75%',
42
+ overflow: 'auto'
43
+ }
44
+ };
45
+ const drawerContentContainerStyles = {
46
+ root: {
47
+ // Needed to fill max height from parent, drawerSurfaceStyles
48
+ height: '100%'
49
+ }
50
+ };
33
51
  //# sourceMappingURL=DrawerSurface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DrawerSurface.js","sourceRoot":"","sources":["../../../../../../../react-components/src/components/Drawer/DrawerSurface.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAU,WAAW,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAuC1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAA0B,EAAe,EAAE;;IACxE,MAAM,UAAU,GAAG,WAAW,CAAC,mBAAmB,EAAE,MAAA,KAAK,CAAC,MAAM,0CAAE,IAAI,CAAC,CAAC;IAExE,OAAO,CACL,oBAAC,KAAK,IAAC,SAAS,EAAE,UAAU;QAC1B,oBAAC,kBAAkB,IAAC,MAAM,EAAE,MAAA,KAAK,CAAC,MAAM,0CAAE,gBAAgB,EAAE,SAAS,EAAE,KAAK,CAAC,cAAc,GAAI;QAC/F,oBAAC,aAAa,IACZ,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;gBACf,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,IAAI,CAAC,CAAC,GAAG,KAAK,KAAK,EAAE;oBACzC,KAAK,CAAC,cAAc,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;iBAChD;YACH,CAAC;YACD,2GAA2G;YAC3G,8GAA8G;YAC9G,2BAA2B,EAAE,IAAI;YAEjC,oBAAC,sBAAsB,IAAC,MAAM,EAAE,MAAA,KAAK,CAAC,MAAM,0CAAE,sBAAsB,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,IACzF,KAAK,CAAC,QAAQ,CACQ,CACX,CACV,CACT,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAW;IAClC,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,iBAAiB;CAC9B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { FocusTrapZone, IStyle, mergeStyles, Stack } from '@fluentui/react';\nimport React from 'react';\nimport { BaseCustomStyles } from '../../types';\nimport { DrawerContentContainer } from './DrawerContentContainer';\nimport { DrawerLightDismiss } from './DrawerLightDismiss';\n\n/**\n * Styles for the {@link _DrawerSurface}.\n *\n * @internal\n */\nexport interface _DrawerSurfaceStyles extends BaseCustomStyles {\n /** Styles for the root of the container of the {@link DrawerSurface} content. */\n drawerContentRoot?: BaseCustomStyles;\n /** Styles for the container of the {@link DrawerSurface} content. */\n drawerContentContainer?: BaseCustomStyles;\n /** Styles for the light dismiss element of the {@link DrawerSurface}. */\n lightDismissRoot?: BaseCustomStyles;\n}\n\n/**\n * Props for {@link DrawerSurface} component.\n *\n * @internal\n */\nexport interface _DrawerSurfaceProps {\n /** Content of the Drawer */\n children: React.ReactNode;\n\n /**\n * Callback when the drawer's light-dismissal is triggered.\n */\n onLightDismiss: () => void;\n\n /**\n * String to show in heading of drawer surface\n */\n heading?: string;\n\n /** Styles for the {@link DrawerSurface} */\n styles?: _DrawerSurfaceStyles;\n}\n\n/**\n * A `Drawer` can be used to reveal lightweight views inside your application.\n * They appear from the bottom of the screen upwards and are light-dismissed.\n *\n * @internal\n */\nexport const _DrawerSurface = (props: _DrawerSurfaceProps): JSX.Element => {\n const rootStyles = mergeStyles(drawerSurfaceStyles, props.styles?.root);\n\n return (\n <Stack className={rootStyles}>\n <DrawerLightDismiss styles={props.styles?.lightDismissRoot} onDismiss={props.onLightDismiss} />\n <FocusTrapZone\n onKeyDown={(e) => {\n if (e.key === 'Escape' || e.key === 'Esc') {\n props.onLightDismiss && props.onLightDismiss();\n }\n }}\n // Ensure when the focus trap has focus, the light dismiss area can still be clicked with mouse to dismiss.\n // Note: this still correctly captures keyboard focus, this just allows mouse click outside of the focus trap.\n isClickableOutsideFocusTrap={true}\n >\n <DrawerContentContainer styles={props.styles?.drawerContentContainer} heading={props.heading}>\n {props.children}\n </DrawerContentContainer>\n </FocusTrapZone>\n </Stack>\n );\n};\n\nconst drawerSurfaceStyles: IStyle = {\n width: '100%',\n height: '100%',\n background: 'rgba(0,0,0,0.4)'\n};\n"]}
1
+ {"version":3,"file":"DrawerSurface.js","sourceRoot":"","sources":["../../../../../../../react-components/src/components/Drawer/DrawerSurface.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAU,WA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CAAC;AAEF,MAAM,mBAAmB,GAAW;IAClC,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,iBAAiB;CAC9B,CAAC;AAEF,MAAM,mBAAmB,GAAW;IAClC,mCAAmC;IACnC,iFAAiF;IACjF,mEAAmE;IACnE,oBAAoB,EAAE;QACpB,SAAS,EAAE,KAAK;QAChB,QAAQ,EAAE,MAAM;KACjB;CACF,CAAC;AAEF,MAAM,4BAA4B,GAAqB;IACrD,IAAI,EAAE;QACJ,6DAA6D;QAC7D,MAAM,EAAE,MAAM;KACf;CACF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { FocusTrapZone, IStyle, mergeStyles, mergeStyleSets, Stack } from '@fluentui/react';\nimport React from 'react';\nimport { BaseCustomStyles } from '../../types';\nimport { DrawerContentContainer } from './DrawerContentContainer';\nimport { DrawerLightDismiss } from './DrawerLightDismiss';\n\n/**\n * Styles for the {@link _DrawerSurface}.\n *\n * @internal\n */\nexport interface _DrawerSurfaceStyles extends BaseCustomStyles {\n /** Styles for the root of the container of the {@link DrawerSurface} content. */\n drawerContentRoot?: BaseCustomStyles;\n /** Styles for the container of the {@link DrawerSurface} content. */\n drawerContentContainer?: BaseCustomStyles;\n /** Styles for the light dismiss element of the {@link DrawerSurface}. */\n lightDismissRoot?: BaseCustomStyles;\n}\n\n/**\n * Props for {@link DrawerSurface} component.\n *\n * @internal\n */\nexport interface _DrawerSurfaceProps {\n /** Content of the Drawer */\n children: React.ReactNode;\n\n /**\n * Callback when the drawer's light-dismissal is triggered.\n */\n onLightDismiss: () => void;\n\n /**\n * String to show in heading of drawer surface\n */\n heading?: string;\n\n /**\n * By default, maxHeight value is set to 75%.\n * Set value to true for no default maxHeight to be applied on drawerSurface\n */\n disableMaxHeight?: boolean;\n\n /** Styles for the {@link DrawerSurface} */\n styles?: _DrawerSurfaceStyles;\n}\n\n/**\n * A `Drawer` can be used to reveal lightweight views inside your application.\n * They appear from the bottom of the screen upwards and are light-dismissed.\n *\n * @internal\n */\nexport const _DrawerSurface = (props: _DrawerSurfaceProps): JSX.Element => {\n const rootStyles = props.disableMaxHeight\n ? mergeStyles(drawerSurfaceStyles, props.styles?.root)\n : mergeStyles(drawerSurfaceStyles, focusTrapZoneStyles, props.styles?.root);\n const containerStyles = mergeStyleSets(drawerContentContainerStyles, props.styles?.drawerContentContainer);\n\n return (\n <Stack className={rootStyles}>\n <DrawerLightDismiss styles={props.styles?.lightDismissRoot} onDismiss={props.onLightDismiss} />\n <FocusTrapZone\n onKeyDown={(e) => {\n if (e.key === 'Escape' || e.key === 'Esc') {\n props.onLightDismiss && props.onLightDismiss();\n }\n }}\n // Ensure when the focus trap has focus, the light dismiss area can still be clicked with mouse to dismiss.\n // Note: this still correctly captures keyboard focus, this just allows mouse click outside of the focus trap.\n isClickableOutsideFocusTrap={true}\n >\n <DrawerContentContainer styles={containerStyles} heading={props.heading}>\n {props.children}\n </DrawerContentContainer>\n </FocusTrapZone>\n </Stack>\n );\n};\n\nconst drawerSurfaceStyles: IStyle = {\n width: '100%',\n height: '100%',\n background: 'rgba(0,0,0,0.4)'\n};\n\nconst focusTrapZoneStyles: IStyle = {\n // Targets FocusTrapZone in drawer.\n // Setting percentage to Height to transform a container does not work unless the\n // direct parent container also has a Height set other than 'auto'.\n '> div:nth-child(2)': {\n maxHeight: '75%',\n overflow: 'auto'\n }\n};\n\nconst drawerContentContainerStyles: BaseCustomStyles = {\n root: {\n // Needed to fill max height from parent, drawerSurfaceStyles\n height: '100%'\n }\n};\n"]}
@@ -56,9 +56,17 @@ export const InputBoxComponent = (props) => {
56
56
  // Index of the previous selection end in the text field
57
57
  const [selectionEndValue, setSelectionEndValue] = useState(null);
58
58
  /* @conditional-compile-remove(mention) */
59
- // Boolean value to check if onMouseDown event should be handled during select as selection range for onMouseDown event is not updated yet and the selection range for mouse click/taps will be updated in onSelect event if needed.
59
+ // Boolean value to check if onMouseDown event should be handled during select as selection range
60
+ // for onMouseDown event is not updated yet and the selection range for mouse click/taps will be
61
+ // updated in onSelect event if needed.
60
62
  const [shouldHandleOnMouseDownDuringSelect, setShouldHandleOnMouseDownDuringSelect] = useState(true);
61
63
  /* @conditional-compile-remove(mention) */
64
+ // Point of start of touch/mouse selection
65
+ const [interactionStartPoint, setInteractionStartPoint] = useState();
66
+ /* @conditional-compile-remove(mention) */
67
+ // Target selection from mouse movement
68
+ const [targetSelection, setTargetSelection] = useState();
69
+ /* @conditional-compile-remove(mention) */
62
70
  // Caret position in the text field
63
71
  const [caretPosition, setCaretPosition] = useState(undefined);
64
72
  /* @conditional-compile-remove(mention) */
@@ -227,10 +235,6 @@ export const InputBoxComponent = (props) => {
227
235
  /* @conditional-compile-remove(mention) */
228
236
  const debouncedQueryUpdate = useDebouncedCallback((query) => __awaiter(void 0, void 0, void 0, function* () {
229
237
  var _a;
230
- if (query === undefined) {
231
- updateMentionSuggestions([]);
232
- return;
233
- }
234
238
  const suggestions = (_a = (yield (mentionLookupOptions === null || mentionLookupOptions === void 0 ? void 0 : mentionLookupOptions.onQueryUpdated(query)))) !== null && _a !== void 0 ? _a : [];
235
239
  if (suggestions.length === 0) {
236
240
  setActiveSuggestionIndex(undefined);
@@ -320,33 +324,54 @@ export const InputBoxComponent = (props) => {
320
324
  }, [setSelectionStartValue, setSelectionEndValue]);
321
325
  /* @conditional-compile-remove(mention) */
322
326
  const handleOnSelect = useCallback((event, inputTextValue, tags, shouldHandleOnMouseDownDuringSelect, selectionStartValue, selectionEndValue) => {
323
- var _a, _b, _c;
324
- /* @conditional-compile-remove(mention) */
325
- if (shouldHandleOnMouseDownDuringSelect && event.currentTarget.selectionStart !== null) {
326
- // on select was triggered by mouse down
327
- const mentionTag = findMentionTagForSelection(tags, event.currentTarget.selectionStart);
328
- if (mentionTag !== undefined && mentionTag.plainTextBeginIndex !== undefined) {
329
- // handle mention click
330
- if (event.currentTarget.selectionDirection === null) {
331
- event.currentTarget.setSelectionRange(mentionTag.plainTextBeginIndex, (_a = mentionTag.plainTextEndIndex) !== null && _a !== void 0 ? _a : mentionTag.plainTextBeginIndex);
327
+ if (shouldHandleOnMouseDownDuringSelect) {
328
+ if (targetSelection !== undefined) {
329
+ setSelectionStartValue(targetSelection.start);
330
+ setSelectionEndValue(targetSelection.end);
331
+ event.currentTarget.setSelectionRange(targetSelection.start, targetSelection.end);
332
+ setTargetSelection(undefined);
333
+ }
334
+ else if (event.currentTarget.selectionStart !== null) {
335
+ // on select was triggered by mouse down/up with no movement
336
+ const mentionTag = findMentionTagForSelection(tags, event.currentTarget.selectionStart);
337
+ if (mentionTag !== undefined && mentionTag.plainTextBeginIndex !== undefined) {
338
+ // handle mention click
339
+ // Get range of word that was clicked on
340
+ const selectionRange = rangeOfWordInSelection({
341
+ textInput: inputTextValue,
342
+ selectionStart: event.currentTarget.selectionStart,
343
+ selectionEnd: event.currentTarget.selectionEnd,
344
+ tag: mentionTag
345
+ });
346
+ if (event.currentTarget.selectionDirection === null) {
347
+ event.currentTarget.setSelectionRange(selectionRange.start, selectionRange.end);
348
+ }
349
+ else {
350
+ event.currentTarget.setSelectionRange(selectionRange.start, selectionRange.end, event.currentTarget.selectionDirection);
351
+ }
352
+ setSelectionStartValue(selectionRange.start);
353
+ setSelectionEndValue(selectionRange.end);
332
354
  }
333
355
  else {
334
- event.currentTarget.setSelectionRange(mentionTag.plainTextBeginIndex, (_b = mentionTag.plainTextEndIndex) !== null && _b !== void 0 ? _b : mentionTag.plainTextBeginIndex, event.currentTarget.selectionDirection);
356
+ setSelectionStartValue(event.currentTarget.selectionStart);
357
+ setSelectionEndValue(event.currentTarget.selectionEnd);
335
358
  }
336
- setSelectionStartValue(mentionTag.plainTextBeginIndex);
337
- setSelectionEndValue((_c = mentionTag.plainTextEndIndex) !== null && _c !== void 0 ? _c : mentionTag.plainTextBeginIndex);
338
- }
339
- else {
340
- setSelectionStartValue(event.currentTarget.selectionStart);
341
- setSelectionEndValue(event.currentTarget.selectionEnd);
342
359
  }
343
360
  }
344
361
  else {
345
362
  // selection was changed by keyboard
346
363
  updateSelectionIndexesWithMentionIfNeeded(event, inputTextValue, selectionStartValue, selectionEndValue, tags);
347
364
  }
348
- // don't set setShouldHandleOnMouseDownDuringSelect(false) here as setSelectionRange could trigger additional calls of onSelect event and they may not be handled correctly (because of setSelectionRange calls or rerender)
349
- }, [updateSelectionIndexesWithMentionIfNeeded]);
365
+ // don't set setShouldHandleOnMouseDownDuringSelect(false) here as setSelectionRange
366
+ // could trigger additional calls of onSelect event and they may not be handled correctly
367
+ // (because of setSelectionRange calls or rerender)
368
+ }, [
369
+ updateSelectionIndexesWithMentionIfNeeded,
370
+ targetSelection,
371
+ setTargetSelection,
372
+ setSelectionStartValue,
373
+ setSelectionEndValue
374
+ ]);
350
375
  /* @conditional-compile-remove(mention) */
351
376
  const handleOnChange = useCallback((event, tagsValue, htmlTextValue, inputTextValue, currentTriggerStartIndex, previousSelectionStart, previousSelectionEnd, currentSelectionStart, currentSelectionEnd, updatedValue) => __awaiter(void 0, void 0, void 0, function* () {
352
377
  var _b;
@@ -405,7 +430,7 @@ export const InputBoxComponent = (props) => {
405
430
  setCurrentTriggerStartIndex(tagIndex);
406
431
  }
407
432
  if (tagIndex === -1) {
408
- yield debouncedQueryUpdate(undefined);
433
+ updateMentionSuggestions([]);
409
434
  }
410
435
  else {
411
436
  // In the middle of a @mention lookup
@@ -455,12 +480,44 @@ export const InputBoxComponent = (props) => {
455
480
  }
456
481
  }
457
482
  onChange && onChange(event, result);
458
- }), [onChange, mentionLookupOptions, setCaretIndex, setCaretPosition, debouncedQueryUpdate]);
483
+ }), [onChange, mentionLookupOptions, setCaretIndex, setCaretPosition, updateMentionSuggestions, debouncedQueryUpdate]);
459
484
  const getInputFieldTextValue = () => {
460
485
  /* @conditional-compile-remove(mention) */
461
486
  return inputTextValue;
462
487
  return textValue;
463
488
  };
489
+ /* @conditional-compile-remove(mention) */
490
+ // Adjust the selection range based on a mouse / touch interaction
491
+ const handleOnMove = useCallback((event) => {
492
+ var _a;
493
+ let targetStart = event.currentTarget.selectionStart;
494
+ let targetEnd = event.currentTarget.selectionEnd;
495
+ // Should we do anything?
496
+ if (interactionStartPoint !== undefined &&
497
+ // And did selection change?
498
+ targetStart !== null &&
499
+ (targetStart !== (targetSelection === null || targetSelection === void 0 ? void 0 : targetSelection.start) || targetEnd !== (targetSelection === null || targetSelection === void 0 ? void 0 : targetSelection.end))) {
500
+ const direction = event.clientX > interactionStartPoint.x ? 'forward' : 'backward';
501
+ const mentionTag = findMentionTagForSelection(tagsValue, direction === 'backward'
502
+ ? event.currentTarget.selectionStart
503
+ : (_a = event.currentTarget.selectionEnd) !== null && _a !== void 0 ? _a : event.currentTarget.selectionStart);
504
+ let updateCurrentTarget = false;
505
+ if (mentionTag !== undefined && mentionTag.plainTextBeginIndex !== undefined) {
506
+ targetStart = Math.min(mentionTag.plainTextBeginIndex, targetStart);
507
+ if (mentionTag.plainTextEndIndex !== undefined && targetEnd !== null) {
508
+ targetEnd = Math.max(mentionTag.plainTextEndIndex, targetEnd);
509
+ }
510
+ updateCurrentTarget = true;
511
+ setShouldHandleOnMouseDownDuringSelect(false);
512
+ }
513
+ // Update selection range
514
+ setTargetSelection({ start: targetStart, end: targetEnd });
515
+ if (updateCurrentTarget) {
516
+ // Only set the control, if the values are updated
517
+ event.currentTarget.setSelectionRange(targetStart, targetEnd, direction);
518
+ }
519
+ }
520
+ }, [setTargetSelection, targetSelection, setShouldHandleOnMouseDownDuringSelect, interactionStartPoint, tagsValue]);
464
521
  return (React.createElement(Stack, { className: mergedRootStyle },
465
522
  React.createElement("div", { className: mergedTextContainerStyle },
466
523
  /* @conditional-compile-remove(mention) */ mentionSuggestions.length > 0 && (React.createElement(_MentionPopover, { suggestions: mentionSuggestions, activeSuggestionIndex: activeSuggestionIndex, target: inputBoxRef, targetPositionOffset: caretPosition, onRenderSuggestionItem: mentionLookupOptions === null || mentionLookupOptions === void 0 ? void 0 : mentionLookupOptions.onRenderSuggestionItem, onSuggestionSelected: onSuggestionSelected, onDismiss: () => {
@@ -493,8 +550,9 @@ export const InputBoxComponent = (props) => {
493
550
  handleOnSelect(e, inputTextValue, tagsValue, shouldHandleOnMouseDownDuringSelect, selectionStartValue, selectionEndValue);
494
551
  },
495
552
  /* @conditional-compile-remove(mention) */
496
- onMouseDown: () => {
497
- // as events order is onMouseDown -> onSelect -> onClick
553
+ onMouseDown: (e) => {
554
+ setInteractionStartPoint({ x: e.clientX, y: e.clientY });
555
+ // as events order is onMouseDown -> onMouseMove -> onMouseUp -> onSelect -> onClick
498
556
  // onClick and onMouseDown can't handle clicking on mention event because
499
557
  // onMouseDown doesn't have correct selectionRange yet and
500
558
  // onClick already has wrong range as it's called after onSelect that updates the selection range
@@ -502,11 +560,27 @@ export const InputBoxComponent = (props) => {
502
560
  setShouldHandleOnMouseDownDuringSelect(true);
503
561
  },
504
562
  /* @conditional-compile-remove(mention) */
505
- onTouchStart: () => {
563
+ onMouseMove: handleOnMove,
564
+ /* @conditional-compile-remove(mention) */
565
+ onMouseUp: () => {
566
+ setInteractionStartPoint(undefined);
567
+ },
568
+ /* @conditional-compile-remove(mention) */
569
+ onTouchStart: (e) => {
570
+ setInteractionStartPoint({
571
+ x: e.targetTouches.item(0).clientX,
572
+ y: e.targetTouches.item(0).clientY
573
+ });
506
574
  // see onMouseDown for more details
507
575
  setShouldHandleOnMouseDownDuringSelect(true);
508
576
  },
509
577
  /* @conditional-compile-remove(mention) */
578
+ onTouchMove: handleOnMove,
579
+ /* @conditional-compile-remove(mention) */
580
+ onTouchEnd: () => {
581
+ setInteractionStartPoint(undefined);
582
+ },
583
+ /* @conditional-compile-remove(mention) */
510
584
  onBlur: () => {
511
585
  // setup all flags to default values when text field loses focus
512
586
  setShouldHandleOnMouseDownDuringSelect(false);
@@ -592,6 +666,31 @@ const findMentionTagForSelection = (tags, selection) => {
592
666
  return mentionTag;
593
667
  };
594
668
  /* @conditional-compile-remove(mention) */
669
+ const rangeOfWordInSelection = ({ textInput, selectionStart, selectionEnd, tag }) => {
670
+ var _a;
671
+ if (tag.plainTextBeginIndex === undefined) {
672
+ return { start: selectionStart, end: selectionEnd === null ? selectionStart : selectionEnd };
673
+ }
674
+ // Look at start word index and optionally end word index.
675
+ // Select combination of the two and return the range.
676
+ let start = selectionStart;
677
+ let end = selectionEnd === null ? selectionStart : selectionEnd;
678
+ const firstWordStartIndex = textInput.lastIndexOf(' ', selectionStart);
679
+ if (firstWordStartIndex === tag.plainTextBeginIndex) {
680
+ start = firstWordStartIndex;
681
+ }
682
+ else {
683
+ start = Math.max(firstWordStartIndex + 1, tag.plainTextBeginIndex);
684
+ }
685
+ const firstWordEndIndex = textInput.indexOf(' ', selectionStart);
686
+ end = Math.max(firstWordEndIndex + 1, (_a = tag.plainTextEndIndex) !== null && _a !== void 0 ? _a : firstWordEndIndex + 1);
687
+ if (selectionEnd !== null && tag.plainTextEndIndex !== undefined) {
688
+ const lastWordEndIndex = textInput.indexOf(' ', selectionEnd);
689
+ end = Math.max(lastWordEndIndex > -1 ? lastWordEndIndex : tag.plainTextEndIndex, selectionEnd);
690
+ }
691
+ return { start, end };
692
+ };
693
+ /* @conditional-compile-remove(mention) */
595
694
  /**
596
695
  * Find a new the selection index.
597
696
  *