@azure/communication-react 1.5.1-alpha-202305250013 → 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.
- package/dist/communication-react.d.ts +10 -2
- package/dist/dist-cjs/communication-react/index.js +366 -205
- package/dist/dist-cjs/communication-react/index.js.map +1 -1
- package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js +1 -1
- package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js.map +1 -1
- package/dist/dist-esm/calling-component-bindings/src/baseSelectors.d.ts +2 -0
- package/dist/dist-esm/calling-component-bindings/src/baseSelectors.js +6 -0
- package/dist/dist-esm/calling-component-bindings/src/baseSelectors.js.map +1 -1
- package/dist/dist-esm/calling-component-bindings/src/captionsSelector.js +5 -2
- package/dist/dist-esm/calling-component-bindings/src/captionsSelector.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/CallClientState.d.ts +4 -0
- package/dist/dist-esm/calling-stateful-client/src/CallClientState.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/CallContext.d.ts +1 -0
- package/dist/dist-esm/calling-stateful-client/src/CallContext.js +9 -0
- package/dist/dist-esm/calling-stateful-client/src/CallContext.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/CallDeclarativeCommon.js +2 -1
- package/dist/dist-esm/calling-stateful-client/src/CallDeclarativeCommon.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/Converter.js +2 -1
- package/dist/dist-esm/calling-stateful-client/src/Converter.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/CaptionsBanner.d.ts +9 -0
- package/dist/dist-esm/react-components/src/components/CaptionsBanner.js +8 -6
- package/dist/dist-esm/react-components/src/components/CaptionsBanner.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/CaptionsSettingsModal.js +11 -4
- package/dist/dist-esm/react-components/src/components/CaptionsSettingsModal.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentAsEditBox.js +26 -22
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentAsEditBox.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/DevicesButton.js +9 -0
- package/dist/dist-esm/react-components/src/components/DevicesButton.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/Drawer/DrawerMenu.d.ts +5 -0
- package/dist/dist-esm/react-components/src/components/Drawer/DrawerMenu.js +1 -1
- package/dist/dist-esm/react-components/src/components/Drawer/DrawerMenu.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/Drawer/DrawerSurface.d.ts +5 -0
- package/dist/dist-esm/react-components/src/components/Drawer/DrawerSurface.js +23 -5
- package/dist/dist-esm/react-components/src/components/Drawer/DrawerSurface.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/InputBoxComponent.js +127 -28
- package/dist/dist-esm/react-components/src/components/InputBoxComponent.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/StartCaptionsButton.js +9 -2
- package/dist/dist-esm/react-components/src/components/StartCaptionsButton.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/VideoTile.js +3 -4
- package/dist/dist-esm/react-components/src/components/VideoTile.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/Captions.style.d.ts +4 -0
- package/dist/dist-esm/react-components/src/components/styles/Captions.style.js +6 -0
- package/dist/dist-esm/react-components/src/components/styles/Captions.style.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/ChatMessageComponent.styles.d.ts +10 -0
- package/dist/dist-esm/react-components/src/components/styles/ChatMessageComponent.styles.js +10 -0
- package/dist/dist-esm/react-components/src/components/styles/ChatMessageComponent.styles.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/VideoTile.styles.js +2 -1
- package/dist/dist-esm/react-components/src/components/styles/VideoTile.styles.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/Strings.d.ts +4 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/Strings.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/CallAdapter.d.ts +2 -2
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/CallAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/CallReadinessModal.js +3 -3
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/CallReadinessModal.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/MediaGallery.js +1 -2
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/MediaGallery.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/index.d.ts +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/index.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/AddPeopleDropdown.js +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/AddPeopleDropdown.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/CallingDialpad.js +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/CallingDialpad.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/CaptionsBanner.js +13 -5
- package/dist/dist-esm/react-composites/src/composites/common/CaptionsBanner.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/CaptionsBannerMoreButton.js +0 -3
- package/dist/dist-esm/react-composites/src/composites/common/CaptionsBannerMoreButton.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/ControlBar/DesktopMoreButton.js +0 -3
- package/dist/dist-esm/react-composites/src/composites/common/ControlBar/DesktopMoreButton.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/Drawer/MoreDrawer.js +1 -8
- package/dist/dist-esm/react-composites/src/composites/common/Drawer/MoreDrawer.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/Drawer/SpokenLanguageDrawer.styles.js +0 -1
- package/dist/dist-esm/react-composites/src/composites/common/Drawer/SpokenLanguageDrawer.styles.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/SendDtmfDialpad.js +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/SendDtmfDialpad.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/VideoEffectsPane.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/en-US/strings.json +2 -1
- package/package.json +8 -8
@@ -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;AAElC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAwB,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAwB,M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AC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;gBACjC,CAAC,IACD,CACH,CAAC,EACD,iBAAiB,aAAjB,iBAAiB;YAAjB,iBAAiB,CAAE,KAAK,CAAC,CAAC,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 =
|
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: (
|
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:
|
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;
|
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,cAAc,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC5F,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AA6C1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAA0B,EAAe,EAAE;;IACxE,MAAM,UAAU,GAAG,KAAK,CAAC,gBAAgB;QACvC,CAAC,CAAC,WAAW,CAAC,mBAAmB,EAAE,MAAA,KAAK,CAAC,MAAM,0CAAE,IAAI,CAAC;QACtD,CAAC,CAAC,WAAW,CAAC,mBAAmB,EAAE,mBAAmB,EAAE,MAAA,KAAK,CAAC,MAAM,0CAAE,IAAI,CAAC,CAAC;IAC9E,MAAM,eAAe,GAAG,cAAc,CAAC,4BAA4B,EAAE,MAAA,KAAK,CAAC,MAAM,0CAAE,sBAAsB,CAAC,CAAC;IAE3G,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,eAAe,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,IACpE,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;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
|
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
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
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
|
-
|
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
|
349
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
*
|