@azure/communication-react 1.4.2-alpha-202211240014.0 → 1.4.2-alpha-202211260013.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/communication-react.d.ts +4 -0
- package/dist/dist-cjs/communication-react/index.js +121 -74
- 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/react-components/src/components/Dialpad/Dialpad.js +12 -9
- package/dist/dist-esm/react-components/src/components/Dialpad/Dialpad.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/VideoTile.d.ts +4 -0
- package/dist/dist-esm/react-components/src/components/VideoTile.js +25 -2
- package/dist/dist-esm/react-components/src/components/VideoTile.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/utils/useLongPress.d.ts +12 -10
- package/dist/dist-esm/react-components/src/components/utils/useLongPress.js +61 -37
- package/dist/dist-esm/react-components/src/components/utils/useLongPress.js.map +1 -1
- package/package.json +8 -8
@@ -8343,6 +8343,10 @@ export declare interface VideoTileProps {
|
|
8343
8343
|
*/
|
8344
8344
|
participantState?: ParticipantState;
|
8345
8345
|
strings?: VideoTileStrings;
|
8346
|
+
/**
|
8347
|
+
* Callback triggered by video tile on touch and hold.
|
8348
|
+
*/
|
8349
|
+
onLongTouch?: () => void;
|
8346
8350
|
}
|
8347
8351
|
|
8348
8352
|
/**
|
@@ -202,7 +202,7 @@ const _toCommunicationIdentifier = (id) => {
|
|
202
202
|
// Copyright (c) Microsoft Corporation.
|
203
203
|
// Licensed under the MIT license.
|
204
204
|
// GENERATED FILE. DO NOT EDIT MANUALLY.
|
205
|
-
var telemetryVersion = '1.4.2-alpha-
|
205
|
+
var telemetryVersion = '1.4.2-alpha-202211260013.0';
|
206
206
|
|
207
207
|
// Copyright (c) Microsoft Corporation.
|
208
208
|
/**
|
@@ -8043,6 +8043,93 @@ const getVideoTileOverrideColor = (isVideoRendered, theme, color) => {
|
|
8043
8043
|
return { color: isVideoRendered ? react.DefaultPalette[color] : theme.palette[color] };
|
8044
8044
|
};
|
8045
8045
|
|
8046
|
+
// Copyright (c) Microsoft Corporation.
|
8047
|
+
/**
|
8048
|
+
* @private
|
8049
|
+
*/
|
8050
|
+
function useLongPress(props) {
|
8051
|
+
const { onClick, onLongPress, touchEventsOnly = false } = props;
|
8052
|
+
const timerRef = React.useRef();
|
8053
|
+
const [isLongPress, setIsLongPress] = React.useState(false);
|
8054
|
+
const [action, setAction] = React.useState(false);
|
8055
|
+
React.useEffect(() => {
|
8056
|
+
if (timerRef.current) {
|
8057
|
+
clearTimeout(timerRef.current);
|
8058
|
+
}
|
8059
|
+
return () => {
|
8060
|
+
if (timerRef.current) {
|
8061
|
+
clearTimeout(timerRef.current);
|
8062
|
+
}
|
8063
|
+
};
|
8064
|
+
}, [onClick, onLongPress, touchEventsOnly]);
|
8065
|
+
const startPressTimer = React.useCallback(() => {
|
8066
|
+
setIsLongPress(false);
|
8067
|
+
timerRef.current = setTimeout(() => {
|
8068
|
+
setIsLongPress(true);
|
8069
|
+
onLongPress();
|
8070
|
+
}, 500);
|
8071
|
+
}, [onLongPress]);
|
8072
|
+
const handleOnClick = React.useCallback(() => {
|
8073
|
+
if (touchEventsOnly || !onClick) {
|
8074
|
+
return;
|
8075
|
+
}
|
8076
|
+
if (!isLongPress) {
|
8077
|
+
onClick();
|
8078
|
+
}
|
8079
|
+
}, [isLongPress, onClick, touchEventsOnly]);
|
8080
|
+
const handleOnKeyDown = React.useCallback(() => {
|
8081
|
+
if (touchEventsOnly) {
|
8082
|
+
return;
|
8083
|
+
}
|
8084
|
+
if (action) {
|
8085
|
+
setAction(false);
|
8086
|
+
startPressTimer();
|
8087
|
+
}
|
8088
|
+
}, [action, startPressTimer, touchEventsOnly]);
|
8089
|
+
const handleOnKeyUp = React.useCallback(() => {
|
8090
|
+
if (touchEventsOnly) {
|
8091
|
+
return;
|
8092
|
+
}
|
8093
|
+
setAction(true);
|
8094
|
+
timerRef.current && clearTimeout(timerRef.current);
|
8095
|
+
}, [touchEventsOnly]);
|
8096
|
+
const handleOnMouseDown = React.useCallback(() => {
|
8097
|
+
if (touchEventsOnly) {
|
8098
|
+
return;
|
8099
|
+
}
|
8100
|
+
startPressTimer();
|
8101
|
+
}, [startPressTimer, touchEventsOnly]);
|
8102
|
+
const handleOnMouseUp = React.useCallback(() => {
|
8103
|
+
if (touchEventsOnly) {
|
8104
|
+
return;
|
8105
|
+
}
|
8106
|
+
timerRef.current && clearTimeout(timerRef.current);
|
8107
|
+
}, [touchEventsOnly]);
|
8108
|
+
const handleOnTouchStart = React.useCallback(() => {
|
8109
|
+
startPressTimer();
|
8110
|
+
}, [startPressTimer]);
|
8111
|
+
const handleOnTouchEnd = React.useCallback(() => {
|
8112
|
+
timerRef.current && clearTimeout(timerRef.current);
|
8113
|
+
}, []);
|
8114
|
+
return React.useMemo(() => ({
|
8115
|
+
onClick: handleOnClick,
|
8116
|
+
onMouseDown: handleOnMouseDown,
|
8117
|
+
onMouseUp: handleOnMouseUp,
|
8118
|
+
onTouchStart: handleOnTouchStart,
|
8119
|
+
onTouchEnd: handleOnTouchEnd,
|
8120
|
+
onKeyDown: handleOnKeyDown,
|
8121
|
+
onKeyUp: handleOnKeyUp
|
8122
|
+
}), [
|
8123
|
+
handleOnClick,
|
8124
|
+
handleOnKeyDown,
|
8125
|
+
handleOnKeyUp,
|
8126
|
+
handleOnMouseDown,
|
8127
|
+
handleOnMouseUp,
|
8128
|
+
handleOnTouchEnd,
|
8129
|
+
handleOnTouchStart
|
8130
|
+
]);
|
8131
|
+
}
|
8132
|
+
|
8046
8133
|
// Copyright (c) Microsoft Corporation.
|
8047
8134
|
// Coin max size is set to PersonaSize.size100
|
8048
8135
|
const DEFAULT_PERSONA_MAX_SIZE_PX = 100;
|
@@ -8095,6 +8182,26 @@ const VideoTile = (props) => {
|
|
8095
8182
|
const currentObserver = observer.current;
|
8096
8183
|
return () => currentObserver.disconnect();
|
8097
8184
|
}, [observer, videoTileRef]);
|
8185
|
+
/* @conditional-compile-remove(pinned-participants) */
|
8186
|
+
const useLongPressProps = React.useMemo(() => {
|
8187
|
+
return {
|
8188
|
+
onLongPress: () => {
|
8189
|
+
var _a;
|
8190
|
+
(_a = props.onLongTouch) === null || _a === void 0 ? void 0 : _a.call(props);
|
8191
|
+
},
|
8192
|
+
touchEventsOnly: true
|
8193
|
+
};
|
8194
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
8195
|
+
}, [props.onLongTouch]);
|
8196
|
+
/* @conditional-compile-remove(pinned-participants) */
|
8197
|
+
const longPressHandlers = useLongPress(useLongPressProps);
|
8198
|
+
const longPressHandlersTrampoline = React.useMemo(() => {
|
8199
|
+
/* @conditional-compile-remove(pinned-participants) */
|
8200
|
+
return longPressHandlers;
|
8201
|
+
}, [
|
8202
|
+
/* @conditional-compile-remove(pinned-participants) */
|
8203
|
+
longPressHandlers
|
8204
|
+
]);
|
8098
8205
|
const placeholderOptions = {
|
8099
8206
|
userId,
|
8100
8207
|
text: initialsName || displayName,
|
@@ -8109,7 +8216,7 @@ const VideoTile = (props) => {
|
|
8109
8216
|
const canShowLabel = showLabel && (displayName || (showMuteIndicator && isMuted));
|
8110
8217
|
const participantStateString = participantStateStringTrampoline(props, locale);
|
8111
8218
|
return (React__default['default'].createElement(reactNorthstar.Ref, { innerRef: videoTileRef },
|
8112
|
-
React__default['default'].createElement(react.Stack, { "data-ui-id": ids.videoTile, className: react.mergeStyles(rootStyles, {
|
8219
|
+
React__default['default'].createElement(react.Stack, Object.assign({ "data-ui-id": ids.videoTile, className: react.mergeStyles(rootStyles, {
|
8113
8220
|
background: theme.palette.neutralLighter,
|
8114
8221
|
borderRadius: theme.effects.roundedCorner4
|
8115
8222
|
}, isSpeaking && {
|
@@ -8122,7 +8229,7 @@ const VideoTile = (props) => {
|
|
8122
8229
|
width: '100%',
|
8123
8230
|
height: '100%'
|
8124
8231
|
}
|
8125
|
-
}, styles === null || styles === void 0 ? void 0 : styles.root) },
|
8232
|
+
}, styles === null || styles === void 0 ? void 0 : styles.root) }, longPressHandlersTrampoline),
|
8126
8233
|
isVideoRendered ? (React__default['default'].createElement(react.Stack, { className: react.mergeStyles(videoContainerStyles, isMirrored && { transform: 'scaleX(-1)' }, styles === null || styles === void 0 ? void 0 : styles.videoContainer) }, renderElement)) : (React__default['default'].createElement(react.Stack, { className: react.mergeStyles(videoContainerStyles), style: { opacity: participantStateString ? 0.4 : 1 } }, onRenderPlaceholder ? (onRenderPlaceholder(userId !== null && userId !== void 0 ? userId : '', placeholderOptions, DefaultPlaceholder)) : (React__default['default'].createElement(DefaultPlaceholder, Object.assign({}, placeholderOptions))))),
|
8127
8234
|
(canShowLabel || participantStateString) && (React__default['default'].createElement(react.Stack, { horizontal: true, className: tileInfoContainerStyle, tokens: tileInfoContainerTokens },
|
8128
8235
|
React__default['default'].createElement(react.Stack, { horizontal: true, className: tileInfoStyle },
|
@@ -11161,69 +11268,6 @@ const formatPhoneNumber = (phoneNumber) => {
|
|
11161
11268
|
return `${countryCodeNA}(${phoneNumber.slice(0, 3)}) ${phoneNumber.slice(3, 6)}-${phoneNumber.slice(6, phoneNumber.length)}`;
|
11162
11269
|
};
|
11163
11270
|
|
11164
|
-
// Copyright (c) Microsoft Corporation.
|
11165
|
-
/**
|
11166
|
-
* @private
|
11167
|
-
*/
|
11168
|
-
function useLongPress(onClick, onLongPress, isMobile) {
|
11169
|
-
const timerRef = React.useRef();
|
11170
|
-
const [isLongPress, setIsLongPress] = React.useState(false);
|
11171
|
-
const [action, setAction] = React.useState(false);
|
11172
|
-
function startPressTimer() {
|
11173
|
-
setIsLongPress(false);
|
11174
|
-
timerRef.current = setTimeout(() => {
|
11175
|
-
setIsLongPress(true);
|
11176
|
-
}, 500);
|
11177
|
-
}
|
11178
|
-
function handleOnClick() {
|
11179
|
-
// when it's mobile use ontouchstart and ontouchend to fire onclick and onlongpress event
|
11180
|
-
if (isMobile) {
|
11181
|
-
return;
|
11182
|
-
}
|
11183
|
-
onClick();
|
11184
|
-
if (isLongPress) {
|
11185
|
-
onLongPress();
|
11186
|
-
return;
|
11187
|
-
}
|
11188
|
-
}
|
11189
|
-
function handleOnKeyDown() {
|
11190
|
-
if (action) {
|
11191
|
-
setAction(false);
|
11192
|
-
startPressTimer();
|
11193
|
-
}
|
11194
|
-
}
|
11195
|
-
function handleOnKeyUp() {
|
11196
|
-
setAction(true);
|
11197
|
-
timerRef.current && clearTimeout(timerRef.current);
|
11198
|
-
}
|
11199
|
-
function handleOnMouseDown() {
|
11200
|
-
startPressTimer();
|
11201
|
-
}
|
11202
|
-
function handleOnMouseUp() {
|
11203
|
-
timerRef.current && clearTimeout(timerRef.current);
|
11204
|
-
}
|
11205
|
-
function handleOnTouchStart() {
|
11206
|
-
startPressTimer();
|
11207
|
-
}
|
11208
|
-
function handleOnTouchEnd() {
|
11209
|
-
if (isMobile) {
|
11210
|
-
isLongPress ? onLongPress() : onClick();
|
11211
|
-
}
|
11212
|
-
timerRef.current && clearTimeout(timerRef.current);
|
11213
|
-
}
|
11214
|
-
return {
|
11215
|
-
handlers: {
|
11216
|
-
onClick: handleOnClick,
|
11217
|
-
onMouseDown: handleOnMouseDown,
|
11218
|
-
onMouseUp: handleOnMouseUp,
|
11219
|
-
onTouchStart: handleOnTouchStart,
|
11220
|
-
onTouchEnd: handleOnTouchEnd,
|
11221
|
-
onKeyDown: handleOnKeyDown,
|
11222
|
-
onKeyUp: handleOnKeyUp
|
11223
|
-
}
|
11224
|
-
};
|
11225
|
-
}
|
11226
|
-
|
11227
11271
|
// Copyright (c) Microsoft Corporation.
|
11228
11272
|
// Licensed under the MIT license.
|
11229
11273
|
var __awaiter$j = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -11267,14 +11311,17 @@ const DialpadButton = (props) => {
|
|
11267
11311
|
var _a, _b, _c, _d;
|
11268
11312
|
const theme = react.useTheme();
|
11269
11313
|
const { digit, index, onClick, onLongPress, isMobile = false } = props;
|
11270
|
-
const
|
11271
|
-
onClick(
|
11272
|
-
|
11273
|
-
|
11274
|
-
onLongPress(
|
11275
|
-
|
11276
|
-
|
11277
|
-
|
11314
|
+
const useLongPressProps = React__default['default'].useMemo(() => ({
|
11315
|
+
onClick: () => __awaiter$j(void 0, void 0, void 0, function* () {
|
11316
|
+
onClick(digit, index);
|
11317
|
+
}),
|
11318
|
+
onLongPress: () => __awaiter$j(void 0, void 0, void 0, function* () {
|
11319
|
+
onLongPress(digit, index);
|
11320
|
+
}),
|
11321
|
+
touchEventsOnly: isMobile
|
11322
|
+
}), [digit, index, isMobile, onClick, onLongPress]);
|
11323
|
+
const longPressHandlers = useLongPress(useLongPressProps);
|
11324
|
+
return (React__default['default'].createElement(react.DefaultButton, Object.assign({ "data-test-id": `dialpad-button-${props.index}`, styles: react.concatStyleSets(buttonStyles(), (_a = props.styles) === null || _a === void 0 ? void 0 : _a.button) }, longPressHandlers),
|
11278
11325
|
React__default['default'].createElement(react.Stack, null,
|
11279
11326
|
React__default['default'].createElement(react.Text, { className: react.mergeStyles(digitStyles(theme), (_b = props.styles) === null || _b === void 0 ? void 0 : _b.digit) }, props.digit),
|
11280
11327
|
React__default['default'].createElement(react.Text, { className: react.mergeStyles(letterStyles(theme), (_c = props.styles) === null || _c === void 0 ? void 0 : _c.letter) }, (_d = props.letter) !== null && _d !== void 0 ? _d : ' '))));
|