@ringcentral/juno 2.5.0-beta.0 → 2.7.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/components/Buttons/IconButton/IconButton.d.ts +10 -2
- package/components/Buttons/IconButton/IconButton.js +10 -8
- package/components/Buttons/IconButton/styles/StyledIconButton.js +15 -7
- package/components/Buttons/IconButton/utils/IconButtonUtils.d.ts +1 -1
- package/components/Buttons/IconButton/utils/IconButtonUtils.js +9 -1
- package/components/Dialer/DialPad/DialPad.d.ts +50 -14
- package/components/Dialer/DialPad/DialPad.js +8 -8
- package/components/Dialer/DialPad/styles/StyledDialPad.d.ts +3 -1
- package/components/Dialer/DialPad/styles/StyledDialPad.js +9 -2
- package/components/Dialer/DialPad/utils/useDialKeyboard.d.ts +8 -9
- package/components/Dialer/DialPadButton/DialPadButton.d.ts +3 -3
- package/components/Dialer/DialPadButton/DialPadButton.js +4 -4
- package/components/Dialer/DialPadButton/styles/StyledDialPadButton.js +1 -2
- package/components/Dialer/DialTextField/DialTextField.d.ts +3 -1
- package/components/Dialer/DialTextField/DialTextField.js +7 -6
- package/components/Downshift/styles/DownshiftStyle.d.ts +1 -1
- package/components/Forms/Picker/DatePicker/styles/StyledDatePickerHeader.d.ts +1 -1
- package/components/Forms/Picker/DatePicker/styles/StyledYear.d.ts +1 -1
- package/components/Forms/Picker/TimePicker/styles/StyledSelectionItem.d.ts +1 -1
- package/components/Forms/Picker/TimePicker/styles/StyledTimeIconButton.d.ts +1 -1
- package/components/Forms/Picker/styles/PickerBaseIconButton.d.ts +1 -1
- package/components/Forms/TextField/styles/ClearIconButton.d.ts +2 -2
- package/components/InlineEditable/InlineEditable.d.ts +1 -1
- package/es6/components/Buttons/IconButton/IconButton.js +12 -10
- package/es6/components/Buttons/IconButton/styles/StyledIconButton.js +16 -8
- package/es6/components/Buttons/IconButton/utils/IconButtonUtils.js +9 -1
- package/es6/components/Dialer/DialPad/DialPad.js +10 -10
- package/es6/components/Dialer/DialPad/styles/StyledDialPad.js +9 -2
- package/es6/components/Dialer/DialPadButton/DialPadButton.js +4 -4
- package/es6/components/Dialer/DialPadButton/styles/StyledDialPadButton.js +1 -2
- package/es6/components/Dialer/DialTextField/DialTextField.js +7 -6
- package/es6/foundation/hooks/useEventListener/useEventListener.js +27 -8
- package/es6/foundation/hooks/useGlobalListener/createGlobalListener.js +81 -0
- package/es6/foundation/hooks/useGlobalListener/index.js +1 -0
- package/es6/foundation/hooks/useGlobalListener/useGlobalListener.js +67 -97
- package/es6/foundation/hooks/useLongPress/useLongPress.js +52 -33
- package/es6/foundation/hooks/useTouchMouseEvent/useTouchMouseEvent.js +27 -28
- package/foundation/hooks/useEventListener/useEventListener.d.ts +12 -16
- package/foundation/hooks/useEventListener/useEventListener.js +26 -7
- package/foundation/hooks/useGlobalListener/createGlobalListener.d.ts +55 -0
- package/foundation/hooks/useGlobalListener/createGlobalListener.js +83 -0
- package/foundation/hooks/useGlobalListener/index.d.ts +1 -0
- package/foundation/hooks/useGlobalListener/index.js +1 -0
- package/foundation/hooks/useGlobalListener/useGlobalListener.d.ts +11 -105
- package/foundation/hooks/useGlobalListener/useGlobalListener.js +67 -97
- package/foundation/hooks/useLongPress/useLongPress.d.ts +10 -8
- package/foundation/hooks/useLongPress/useLongPress.js +50 -31
- package/foundation/hooks/useTouchMouseEvent/useTouchMouseEvent.d.ts +27 -14
- package/foundation/hooks/useTouchMouseEvent/useTouchMouseEvent.js +27 -28
- package/foundation/typings/deepPartial.d.ts +1 -1
- package/package.json +1 -1
|
@@ -199,7 +199,7 @@ declare const RcInlineEditable: import("styled-components").StyledComponentClass
|
|
|
199
199
|
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
|
|
200
200
|
*/
|
|
201
201
|
inputProps?: import("@material-ui/core").InputBaseComponentProps | undefined;
|
|
202
|
-
} & Pick<React.DOMAttributes<HTMLDivElement>, "onFocus" | "onBlur" | "onKeyDown" | "onMouseDown"> & RcClassesProps<"label" | "placeholder" | "textField" | "saving"> & React.RefAttributes<any>, "ref" | "key" | "className" | "color" | "style" | "onFocus" | "onBlur" | "onChange" | "onKeyDown" | "onMouseDown" | "title" | "classes" | "placeholder" | "value" | "variant" | "disabled" | "fullWidth" | "TooltipProps" | "inputProps" | "
|
|
202
|
+
} & Pick<React.DOMAttributes<HTMLDivElement>, "onFocus" | "onBlur" | "onKeyDown" | "onMouseDown"> & RcClassesProps<"label" | "placeholder" | "textField" | "saving"> & React.RefAttributes<any>, "ref" | "key" | "className" | "color" | "style" | "onFocus" | "onBlur" | "onChange" | "onKeyDown" | "onMouseDown" | "title" | "classes" | "placeholder" | "value" | "variant" | "disabled" | "fullWidth" | "TooltipProps" | "inputProps" | "tooltipTitle" | "multiline" | "maxLength" | "automationId" | "saving" | "shouldRemoveNode" | "onSave"> & {
|
|
203
203
|
theme?: import("../../foundation").RcTheme | undefined;
|
|
204
204
|
}>;
|
|
205
205
|
export { RcInlineEditable };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __assign, __makeTemplateObject, __rest } from "tslib";
|
|
2
|
-
import React, { forwardRef, memo } from 'react';
|
|
2
|
+
import React, { forwardRef, memo, useMemo } from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import { combineProps, styled, useDeprecatedCheck, useTheme, useThemeProps, } from '../../../foundation';
|
|
4
|
+
import { combineProps, styled, useDeprecatedCheck, useTheme, useThemeProps, combineClasses, } from '../../../foundation';
|
|
5
5
|
import { RcIcon } from '../../Icon';
|
|
6
6
|
import { RcTooltip, withTooltip } from '../../Tooltip';
|
|
7
7
|
import { RcButtonBase } from '../ButtonBase';
|
|
@@ -15,20 +15,23 @@ var _RcIconButton = memo(forwardRef(function (inProps, ref) {
|
|
|
15
15
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
16
16
|
useDeprecatedCheck(RcIconButton, props, rcIconButtonWarning);
|
|
17
17
|
}
|
|
18
|
-
var _b = props.buttonRef, buttonRef = _b === void 0 ? ref : _b, className = props.className,
|
|
18
|
+
var _b = props.buttonRef, buttonRef = _b === void 0 ? ref : _b, IconProps = props.IconProps, className = props.className, classesProp = props.classes, children = props.children, title = props.title, disabledFakeBorder = props.disabledFakeBorder, symbol = props.symbol, disabled = props.disabled, invisible = props.invisible, type = props.type, loading = props.loading, TouchRippleProps = props.TouchRippleProps, variant = props.variant, CircularProgressProps = props.CircularProgressProps, color = props.color, shouldPersistBg = props.shouldPersistBg, stretchIcon = props.stretchIcon, iconColor = props.iconColor, iconSize = props.iconSize, disableTouchRipple = props.disableTouchRipple, useColorWhenDisabled = props.useColorWhenDisabled, size = props.size, radius = props.radius, elevation = props.elevation, activeElevation = props.activeElevation, aRef = props.aRef, tooltipTitle = props.tooltipTitle, tooltipForceHide = props.tooltipForceHide, disableToolTip = props.disableToolTip, alwaysEnableTooltip = props.alwaysEnableTooltip, tooltipPlacement = props.tooltipPlacement, ariaLabel = props.ariaLabel, popperProps = props.popperProps, externalLink = props.externalLink, download = props.download, autoFocus = props.autoFocus, href = props.href, rest = __rest(props, ["buttonRef", "IconProps", "className", "classes", "children", "title", "disabledFakeBorder", "symbol", "disabled", "invisible", "type", "loading", "TouchRippleProps", "variant", "CircularProgressProps", "color", "shouldPersistBg", "stretchIcon", "iconColor", "iconSize", "disableTouchRipple", "useColorWhenDisabled", "size", "radius", "elevation", "activeElevation", "aRef", "tooltipTitle", "tooltipForceHide", "disableToolTip", "alwaysEnableTooltip", "tooltipPlacement", "ariaLabel", "popperProps", "externalLink", "download", "autoFocus", "href"]);
|
|
19
19
|
var theme = useTheme();
|
|
20
20
|
var isOutline = variant === 'outline';
|
|
21
21
|
var isContained = variant === 'contained';
|
|
22
|
+
var isInverse = variant === 'inverse';
|
|
22
23
|
var isPlain = variant === 'plain';
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
_a[
|
|
26
|
-
_a[
|
|
27
|
-
_a[
|
|
24
|
+
var classes = useMemo(function () { return combineClasses(RcIconButtonClasses, classesProp); }, [classesProp]);
|
|
25
|
+
var IconClassName = clsx(className, classes.root, (_a = {},
|
|
26
|
+
_a[classes.disabled] = disabled,
|
|
27
|
+
_a[classes.invisible] = invisible,
|
|
28
|
+
_a[classes.outline] = isOutline,
|
|
29
|
+
_a[classes.contained] = isContained,
|
|
30
|
+
_a[classes.inverse] = isInverse,
|
|
28
31
|
_a));
|
|
29
32
|
var iconButton = (function () {
|
|
30
33
|
var _a, _b;
|
|
31
|
-
var icon = React.isValidElement(children) || children === '' ? children : (React.createElement(RcIcon, { symbol: symbol, className: classes.icon, loading: loading, CircularProgressProps: CircularProgressProps }, children));
|
|
34
|
+
var icon = React.isValidElement(children) || children === '' ? children : (React.createElement(RcIcon, __assign({ symbol: symbol, className: classes.icon, loading: loading, CircularProgressProps: CircularProgressProps }, IconProps), children));
|
|
32
35
|
var iconButton = (React.createElement(RcButtonBase, __assign({ ref: buttonRef, disableRipple: ((_b = (_a = theme.props) === null || _a === void 0 ? void 0 : _a.MuiButtonBase) === null || _b === void 0 ? void 0 : _b.disableRipple) || isPlain, type: type, disabled: disabled, "aria-label": ariaLabel || tooltipTitle || title, title: title, "aria-disabled": disabled, className: IconClassName, TouchRippleProps: combineProps({
|
|
33
36
|
classes: RcIconButtonTouchRippleClasses,
|
|
34
37
|
}, TouchRippleProps) }, rest), icon));
|
|
@@ -55,7 +58,6 @@ RcIconButton.defaultProps = {
|
|
|
55
58
|
type: 'button',
|
|
56
59
|
focusRipple: true,
|
|
57
60
|
disableTouchRipple: true,
|
|
58
|
-
centerRipple: true,
|
|
59
61
|
classes: {},
|
|
60
62
|
useRcTooltip: true,
|
|
61
63
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __makeTemplateObject } from "tslib";
|
|
2
|
-
import { backgroundTransition, css, focusVisible, focusVisibleColor, getParsePaletteColor, nonTouchHoverMedia, palette2, paletteContrastText, px, radius, setOpacity, shadows, } from '../../../../foundation';
|
|
2
|
+
import { backgroundTransition, css, focusVisible, focusVisibleColor, getParsePaletteColor, nonTouchHoverMedia, palette2, paletteContrastText, px, radius, setOpacity, shadows, fakeBorder, } from '../../../../foundation';
|
|
3
3
|
import { RcIcon } from '../../../Icon';
|
|
4
4
|
import { RcIconButtonClasses, RcIconButtonFocusVisibleInsetSize, RcIconButtonSizes, RcIconButtonTouchRippleClasses, } from '../utils';
|
|
5
5
|
export var getFocusVisibleInsetSize = function (_a) {
|
|
@@ -20,7 +20,7 @@ export var plainIconButtonFocusStyle = function (_a) {
|
|
|
20
20
|
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &:after {\n content: '';\n position: absolute;\n ", ";\n box-shadow: 0 0 0 1px ", ";\n border-radius: ", ";\n pointer-events: none;\n z-index: 1;\n }\n"], ["\n &:after {\n content: '';\n position: absolute;\n ", ";\n box-shadow: 0 0 0 1px ", ";\n border-radius: ", ";\n pointer-events: none;\n z-index: 1;\n }\n"])), getFocusVisibleInsetSize, focusVisibleColor, radius(radiusProp));
|
|
21
21
|
};
|
|
22
22
|
export var iconButtonStyle = function (_a) {
|
|
23
|
-
var variant = _a.variant, size = _a.size, stretchIcon = _a.stretchIcon, color = _a.color, disabled = _a.disabled, useColorWhenDisabled = _a.useColorWhenDisabled, shouldPersistBg = _a.shouldPersistBg, radiusProp = _a.radius, elevation = _a.elevation, activeElevation = _a.activeElevation;
|
|
23
|
+
var variant = _a.variant, size = _a.size, stretchIcon = _a.stretchIcon, color = _a.color, disabled = _a.disabled, useColorWhenDisabled = _a.useColorWhenDisabled, shouldPersistBg = _a.shouldPersistBg, radiusProp = _a.radius, disableRipple = _a.disableRipple, elevation = _a.elevation, disabledFakeBorder = _a.disabledFakeBorder, activeElevation = _a.activeElevation;
|
|
24
24
|
var iconSize = RcIconButtonSizes[size];
|
|
25
25
|
var isCircle = ['plain', 'round', 'inverse', 'contained'].includes(variant);
|
|
26
26
|
var isPlain = variant === 'plain';
|
|
@@ -34,19 +34,27 @@ export var iconButtonStyle = function (_a) {
|
|
|
34
34
|
var persistBgColor = setOpacity(mainColor, isInverse ? '16' : '12');
|
|
35
35
|
var defaultShadow = isContained ? shadows('1') : undefined;
|
|
36
36
|
var nowShadow = elevation !== undefined ? shadows(elevation) : defaultShadow;
|
|
37
|
-
|
|
37
|
+
var radiusValue = radius(currRadius);
|
|
38
|
+
var contrastColorBorder = !disabledFakeBorder &&
|
|
39
|
+
fakeBorder({
|
|
40
|
+
color: palette2('highContrast'),
|
|
41
|
+
radius: currRadius,
|
|
42
|
+
pseudo: true,
|
|
43
|
+
});
|
|
44
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n\n width: ", ";\n height: ", ";\n color: ", ";\n border-radius: ", ";\n transition: ", ";\n cursor: ", ";\n background-color: ", ";\n box-shadow: ", ";\n\n ", ";\n\n ", " {\n font-size: ", ";\n }\n\n ", " {\n &:hover {\n background-color: ", ";\n\n ", " {\n color: ", ";\n }\n }\n }\n\n &:active {\n ", " {\n color: ", ";\n }\n }\n\n ", " {\n background-color: ", ";\n\n &:active {\n ", " {\n color: ", ";\n }\n }\n\n ", ";\n }\n\n &.", " {\n background-color: ", ";\n }\n\n &.", " {\n ", " {\n color: ", ";\n }\n\n background-color: ", ";\n }\n\n &.", " {\n opacity: 0;\n visibility: hidden;\n width: 0;\n height: 0;\n }\n\n &.", " {\n border: 1px solid ", ";\n }\n\n &.", " {\n color: ", ";\n background-color: ", ";\n\n &:before {\n content: '';\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n border-radius: ", ";\n position: absolute;\n }\n\n ", ";\n\n ", " {\n &:hover {\n &:before {\n background-color: ", ";\n }\n\n color: ", ";\n }\n }\n\n ", " {\n &:before {\n background-color: ", ";\n }\n\n color: ", ";\n }\n\n &:active {\n ", "\n\n color: ", ";\n }\n }\n\n &.", " {\n ", ";\n }\n\n .", " {\n border-radius: 0;\n animation-name: none;\n opacity: 0;\n }\n\n ", "\n "], ["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n\n width: ", ";\n height: ", ";\n color: ", ";\n border-radius: ", ";\n transition: ", ";\n cursor: ", ";\n background-color: ", ";\n box-shadow: ", ";\n\n ",
|
|
38
45
|
";\n\n ", " {\n font-size: ",
|
|
39
46
|
";\n }\n\n ", " {\n &:hover {\n background-color: ",
|
|
40
47
|
";\n\n ", " {\n color: ", ";\n }\n }\n }\n\n &:active {\n ", " {\n color: ", ";\n }\n }\n\n ", " {\n background-color: ",
|
|
41
48
|
";\n\n &:active {\n ", " {\n color: ", ";\n }\n }\n\n ", ";\n }\n\n &.", " {\n background-color: ", ";\n }\n\n &.", " {\n ", " {\n color: ",
|
|
42
|
-
";\n }\n\n background-color: ", ";\n }\n\n &.", " {\n opacity: 0;\n visibility: hidden;\n width: 0;\n height: 0;\n }\n\n &.", " {\n border: 1px solid ", ";\n }\n\n &.", " {\n color: ", ";\n background-color: ", ";\n\n
|
|
49
|
+
";\n }\n\n background-color: ", ";\n }\n\n &.", " {\n opacity: 0;\n visibility: hidden;\n width: 0;\n height: 0;\n }\n\n &.", " {\n border: 1px solid ", ";\n }\n\n &.", " {\n color: ", ";\n background-color: ", ";\n\n &:before {\n content: '';\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n border-radius: ", ";\n position: absolute;\n }\n\n ", ";\n\n ", " {\n &:hover {\n &:before {\n background-color: ", ";\n }\n\n color: ", ";\n }\n }\n\n ", " {\n &:before {\n background-color: ", ";\n }\n\n color: ", ";\n }\n\n &:active {\n ",
|
|
50
|
+
"\n\n color: ", ";\n }\n }\n\n &.", " {\n ", ";\n }\n\n .", " {\n border-radius: 0;\n animation-name: none;\n opacity: 0;\n }\n\n "
|
|
43
51
|
/**
|
|
44
52
|
* that is equilateral triangle, the third Side length is
|
|
45
53
|
* Math.sqrt(2) = 1.414213562373095, so we scale that
|
|
46
54
|
* to make that full with this square
|
|
47
55
|
*/
|
|
48
56
|
,
|
|
49
|
-
"\n "])), containerSize, containerSize, mainColor,
|
|
57
|
+
"\n "])), containerSize, containerSize, mainColor, radiusValue, backgroundTransition, disabled ? 'default' : 'pointer', (shouldPersistBg || isInverse) && persistBgColor, nowShadow, nowShadow && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n transition: ", ";\n\n &:active {\n box-shadow: ", ";\n }\n "], ["\n transition: ", ";\n\n &:active {\n box-shadow: ",
|
|
50
58
|
";\n }\n "])), containedVariantTransitions, shadows(activeElevation !== null && activeElevation !== void 0 ? activeElevation : (elevation ? Math.min(+elevation + 11, 24) : '12'))), childrenClass, stretchIcon
|
|
51
59
|
? containerSize
|
|
52
60
|
: px(isOutline
|
|
@@ -57,13 +65,13 @@ export var iconButtonStyle = function (_a) {
|
|
|
57
65
|
? 'transparent'
|
|
58
66
|
: setOpacity(mainColor, isInverse ? '32' : '16'), childrenClass, setOpacity(mainColor, '88'), isPlain && plainIconButtonFocusStyle({ radius: currRadius }), RcIconButtonClasses.persistBg, persistBgColor, RcIconButtonClasses.disabled, childrenClass, useColorWhenDisabled
|
|
59
67
|
? setOpacity(mainColor, '32')
|
|
60
|
-
: palette2('disabled', 'f02'), isInverse && setOpacity(mainColor, '12'), RcIconButtonClasses.invisible, RcIconButtonClasses.outline, palette2('neutral', 'l03'), RcIconButtonClasses.contained, mainColorContrast, mainColor, nonTouchHoverMedia, setOpacity(
|
|
68
|
+
: palette2('disabled', 'f02'), isInverse && setOpacity(mainColor, '12'), RcIconButtonClasses.invisible, RcIconButtonClasses.outline, palette2('neutral', 'l03'), RcIconButtonClasses.contained, mainColorContrast, mainColor, radiusValue, contrastColorBorder, nonTouchHoverMedia, setOpacity(mainColorContrast, '08'), mainColorContrast, focusVisible, setOpacity(mainColorContrast, '16'), mainColorContrast, disableRipple && css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n &:before {\n background-color: ", ";\n }\n "], ["\n &:before {\n background-color: ", ";\n }\n "])), setOpacity(mainColorContrast, '24')), mainColorContrast, RcIconButtonClasses.inverse, contrastColorBorder, RcIconButtonTouchRippleClasses.ripplePulsate,
|
|
61
69
|
/**
|
|
62
70
|
* that is equilateral triangle, the third Side length is
|
|
63
71
|
* Math.sqrt(2) = 1.414213562373095, so we scale that
|
|
64
72
|
* to make that full with this square
|
|
65
73
|
*/
|
|
66
74
|
!isPlain &&
|
|
67
|
-
!['circle', 'round'].includes(currRadius) && css(
|
|
75
|
+
!['circle', 'round'].includes(currRadius) && css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n .", " {\n transform: scale(1.41421357);\n }\n "], ["\n .", " {\n transform: scale(1.41421357);\n }\n "])), RcIconButtonTouchRippleClasses.child));
|
|
68
76
|
};
|
|
69
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
77
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { omit, RcClasses } from '../../../../foundation';
|
|
2
2
|
import { RcIconSizes } from '../../../Icon/utils';
|
|
3
|
-
export var RcIconButtonClasses = RcClasses([
|
|
3
|
+
export var RcIconButtonClasses = RcClasses([
|
|
4
|
+
'root',
|
|
5
|
+
'disabled',
|
|
6
|
+
'invisible',
|
|
7
|
+
'outline',
|
|
8
|
+
'contained',
|
|
9
|
+
'inverse',
|
|
10
|
+
'persistBg',
|
|
11
|
+
], 'RcIconButton');
|
|
4
12
|
export var RcIconButtonTouchRippleClasses = RcClasses(['ripplePulsate', 'child'], 'RcIconButtonTouchRipple');
|
|
5
13
|
export var RcIconButtonSizes = omit(RcIconSizes, ['inherit']);
|
|
6
14
|
export var RcIconButtonFocusVisibleInsetSize = {
|
|
@@ -3,24 +3,24 @@ import React, { forwardRef, useEffect, useImperativeHandle, useRef, } from 'reac
|
|
|
3
3
|
import { styled, useDebounce, useEventCallback, useForkRef, useKeyboardMoveFocus, useOnlyOneFocusable, useThemeProps, } from '../../../foundation';
|
|
4
4
|
import { RcIconButtonClasses } from '../../Buttons/IconButton/utils';
|
|
5
5
|
import { RcVisuallyHidden } from '../../VisuallyHidden';
|
|
6
|
-
import {
|
|
6
|
+
import { RcDialPadButton } from '../DialPadButton';
|
|
7
7
|
import { useRcDialerContext } from '../utils';
|
|
8
|
-
import {
|
|
8
|
+
import { DialPadStyle } from './styles';
|
|
9
9
|
import { ACCEPTABLE_KEYS, DIALER_PAD_ICONS, DIALER_PAD_PLUS, useKeyAudio, } from './utils';
|
|
10
10
|
var DEBOUNCE_TIME = 30;
|
|
11
11
|
var _RcDialPad = forwardRef(function (inProps, ref) {
|
|
12
12
|
var props = useThemeProps({ props: inProps, name: 'RcDialPad' });
|
|
13
|
-
var sounds = props.sounds, volume = props.volume, muted = props.muted, classes = props.classes, onChangeProp = props.onChange, longPressDelay = props.longPressDelay, action = props.action, persistBgTime = props.persistBgTime, control = props.control, getDialPadButtonProps = props.getDialPadButtonProps, divProps = __rest(props, ["sounds", "volume", "muted", "classes", "onChange", "longPressDelay", "action", "persistBgTime", "control", "getDialPadButtonProps"]);
|
|
13
|
+
var sounds = props.sounds, volume = props.volume, autoSize = props.autoSize, muted = props.muted, classes = props.classes, onChangeProp = props.onChange, longPressDelay = props.longPressDelay, action = props.action, persistBgTime = props.persistBgTime, control = props.control, getDialPadButtonProps = props.getDialPadButtonProps, _a = props.externalWindow, externalWindow = _a === void 0 ? window : _a, divProps = __rest(props, ["sounds", "volume", "autoSize", "muted", "classes", "onChange", "longPressDelay", "action", "persistBgTime", "control", "getDialPadButtonProps", "externalWindow"]);
|
|
14
14
|
var containerRef = useRef(null);
|
|
15
15
|
var hiddenRef = useRef(null);
|
|
16
16
|
var keyTimerMapRef = useRef({});
|
|
17
17
|
var forkRef = useForkRef(containerRef, ref);
|
|
18
|
-
var
|
|
18
|
+
var _b = useRcDialerContext(), onInsertRef = _b.onInsertRef, dialPadActionRef = _b.dialPadActionRef;
|
|
19
19
|
var focusedIndexRef = useRef(0);
|
|
20
|
-
var
|
|
20
|
+
var _c = useOnlyOneFocusable({
|
|
21
21
|
focusedIndexRef: focusedIndexRef,
|
|
22
22
|
containerRef: containerRef,
|
|
23
|
-
}), focusIndex =
|
|
23
|
+
}), focusIndex = _c.focusIndex, getItemProps = _c.getItemProps, moveFocusedId = _c.moveFocusedId;
|
|
24
24
|
var dialButtonKey = moveFocusedId + "-dial-button";
|
|
25
25
|
var onKeyFocusedIndexHandle = useKeyboardMoveFocus({
|
|
26
26
|
options: DIALER_PAD_ICONS,
|
|
@@ -64,11 +64,11 @@ var _RcDialPad = forwardRef(function (inProps, ref) {
|
|
|
64
64
|
var handleKeyboardEffect = useDebounce(function (value, isKeyup) {
|
|
65
65
|
var _a, _b;
|
|
66
66
|
if (isKeyup) {
|
|
67
|
-
handleChange(value, '
|
|
67
|
+
handleChange(value, 'customKeyboard');
|
|
68
68
|
var toIndex = ACCEPTABLE_KEYS.findIndex(function (x) { return x === value; });
|
|
69
69
|
focusedIndexRef.current = toIndex;
|
|
70
70
|
// * mean that current focus on that dialPad, move focus to dialPad container
|
|
71
|
-
if (((_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.getAttribute(dialButtonKey)) !== null) {
|
|
71
|
+
if (((_a = externalWindow.document.activeElement) === null || _a === void 0 ? void 0 : _a.getAttribute(dialButtonKey)) !== null) {
|
|
72
72
|
(_b = hiddenRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -106,7 +106,7 @@ var _RcDialPad = forwardRef(function (inProps, ref) {
|
|
|
106
106
|
var ariaLabelArr = additionLabel
|
|
107
107
|
? [key, additionLabel]
|
|
108
108
|
: [key];
|
|
109
|
-
return (React.createElement(
|
|
109
|
+
return (React.createElement(RcDialPadButton, __assign({ classes: classes, symbol: symbol, key: key, value: key, onKeyEffect: handleKeyEffect }, getItemProps(index), { "aria-label": ariaLabelArr.join(','), onKeyDown: onKeyFocusedIndexHandle }, (_b = {}, _b[dialButtonKey] = key, _b), getDialPadButtonProps === null || getDialPadButtonProps === void 0 ? void 0 : getDialPadButtonProps(key), (key === '0'
|
|
110
110
|
? {
|
|
111
111
|
longPressValue: DIALER_PAD_PLUS,
|
|
112
112
|
longPressDelay: longPressDelay,
|
|
@@ -115,7 +115,7 @@ var _RcDialPad = forwardRef(function (inProps, ref) {
|
|
|
115
115
|
})));
|
|
116
116
|
});
|
|
117
117
|
/** @release */
|
|
118
|
-
var RcDialPad = styled(_RcDialPad)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])),
|
|
118
|
+
var RcDialPad = styled(_RcDialPad)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), DialPadStyle);
|
|
119
119
|
RcDialPad.defaultProps = {
|
|
120
120
|
persistBgTime: 200,
|
|
121
121
|
volume: 1,
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { __makeTemplateObject } from "tslib";
|
|
2
2
|
import { css } from '../../../../foundation';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { RcIcon } from '../../../Icon';
|
|
4
|
+
import { RcDialPadButton } from '../../DialPadButton';
|
|
5
|
+
var itemScale = "27.59%";
|
|
6
|
+
export var DialPadStyle = function (_a) {
|
|
7
|
+
var _b = _a.autoSize, autoSize = _b === void 0 ? true : _b;
|
|
8
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n flex-wrap: wrap;\n\n ", "\n "], ["\n display: flex;\n flex-wrap: wrap;\n\n ",
|
|
9
|
+
"\n "])), autoSize && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n justify-content: space-between;\n\n ", " {\n width: ", ";\n height: 0;\n padding-top: ", ";\n\n ", " {\n position: absolute;\n top: 0;\n left: 0;\n svg {\n height: 100%;\n width: 100%;\n }\n }\n }\n "], ["\n justify-content: space-between;\n\n ", " {\n width: ", ";\n height: 0;\n padding-top: ", ";\n\n ", " {\n position: absolute;\n top: 0;\n left: 0;\n svg {\n height: 100%;\n width: 100%;\n }\n }\n }\n "])), RcDialPadButton, itemScale, itemScale, RcIcon));
|
|
10
|
+
};
|
|
11
|
+
var templateObject_1, templateObject_2;
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { styled, useLongPress } from '../../../foundation';
|
|
4
4
|
import { RcIconButton } from '../../Buttons';
|
|
5
5
|
import { buttonWrapperStyle } from './styles';
|
|
6
|
-
var
|
|
6
|
+
var _RcDialPadButton = function (props) {
|
|
7
7
|
var value = props.value, longPressValue = props.longPressValue, longPressDelay = props.longPressDelay, onKeyEffect = props.onKeyEffect, rest = __rest(props, ["value", "longPressValue", "longPressDelay", "onKeyEffect"]);
|
|
8
8
|
var isPressEvent = typeof longPressDelay === 'number' && typeof longPressValue === 'string';
|
|
9
9
|
var _a = useLongPress({
|
|
@@ -18,7 +18,7 @@ var _DialPadButton = function (props) {
|
|
|
18
18
|
}, rest, { delay: longPressDelay }), ref = _a.ref, events = __rest(_a, ["ref"]);
|
|
19
19
|
return (React.createElement(RcIconButton, __assign({ ref: ref, variant: "round", stretchIcon: true }, rest, events)));
|
|
20
20
|
};
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
export {
|
|
21
|
+
var RcDialPadButton = styled(_RcDialPadButton)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), buttonWrapperStyle);
|
|
22
|
+
RcDialPadButton.displayName = 'RcDialPadButton';
|
|
23
|
+
export { RcDialPadButton };
|
|
24
24
|
var templateObject_1;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { __makeTemplateObject } from "tslib";
|
|
2
2
|
import { css, palette2 } from '../../../../foundation';
|
|
3
3
|
import { RcIcon } from '../../../Icon';
|
|
4
|
-
var
|
|
5
|
-
export var buttonWrapperStyle = css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n && {\n width: ", ";\n height: 0;\n }\n\n padding-top: ", ";\n\n ", " {\n position: absolute;\n top: 0;\n left: 0;\n svg {\n height: 100%;\n width: 100%;\n path:first-child {\n fill: ", ";\n }\n path:nth-child(2) {\n fill: ", ";\n }\n }\n }\n"], ["\n && {\n width: ", ";\n height: 0;\n }\n\n padding-top: ", ";\n\n ", " {\n position: absolute;\n top: 0;\n left: 0;\n svg {\n height: 100%;\n width: 100%;\n path:first-child {\n fill: ", ";\n }\n path:nth-child(2) {\n fill: ", ";\n }\n }\n }\n"])), itemScale, itemScale, RcIcon, palette2('neutral', 'f06'), palette2('neutral', 'f04'));
|
|
4
|
+
export var buttonWrapperStyle = css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", " {\n svg {\n path:first-child {\n fill: ", ";\n }\n path:nth-child(2) {\n fill: ", ";\n }\n }\n }\n"], ["\n ", " {\n svg {\n path:first-child {\n fill: ", ";\n }\n path:nth-child(2) {\n fill: ", ";\n }\n }\n }\n"])), RcIcon, palette2('neutral', 'f06'), palette2('neutral', 'f04'));
|
|
6
5
|
var templateObject_1;
|
|
@@ -8,9 +8,9 @@ import { DialTextFieldStyle } from './styles';
|
|
|
8
8
|
import { getDialPadValueOnlyRegex, useFixedEndSelection } from './utils';
|
|
9
9
|
var _RcDialTextField = forwardRef(function (inProps, ref) {
|
|
10
10
|
var props = useThemeProps({ props: inProps, name: 'RcDialTextField' });
|
|
11
|
-
var children = props.children, value = props.value, onChange = props.onChange, onEmit = props.onEmit, onKeyPress = props.onKeyPress, onKeyDown = props.onKeyDown, onKeyUp = props.onKeyUp, inputRefProp = props.inputRef, inputPropsProp = props.inputProps, InputPropsProp = props.InputProps, onlyAllowKeypadValue = props.onlyAllowKeypadValue, keypadMode = props.keypadMode, rest = __rest(props, ["children", "value", "onChange", "onEmit", "onKeyPress", "onKeyDown", "onKeyUp", "inputRef", "inputProps", "InputProps", "onlyAllowKeypadValue", "keypadMode"]);
|
|
11
|
+
var children = props.children, value = props.value, onChange = props.onChange, onEmit = props.onEmit, onKeyPress = props.onKeyPress, onKeyDown = props.onKeyDown, onKeyUp = props.onKeyUp, inputRefProp = props.inputRef, inputPropsProp = props.inputProps, InputPropsProp = props.InputProps, onlyAllowKeypadValue = props.onlyAllowKeypadValue, keypadMode = props.keypadMode, _a = props.externalWindow, externalWindow = _a === void 0 ? window : _a, rest = __rest(props, ["children", "value", "onChange", "onEmit", "onKeyPress", "onKeyDown", "onKeyUp", "inputRef", "inputProps", "InputProps", "onlyAllowKeypadValue", "keypadMode", "externalWindow"]);
|
|
12
12
|
var dialerContext = useRcDialerContext();
|
|
13
|
-
var
|
|
13
|
+
var _b = useFixedEndSelection(), inputRef = _b.ref, onKeypadModeFocus = _b.onFocus, onKeypadModeKeyDown = _b.onKeyDown, onKeypadModeClick = _b.onClick;
|
|
14
14
|
var forkContextRef = useForkRef(dialerContext.inputRef, inputRef);
|
|
15
15
|
var forkInputRef = useForkRef(inputRefProp, forkContextRef);
|
|
16
16
|
var scrollToPositionRef = useRef();
|
|
@@ -18,7 +18,7 @@ var _RcDialTextField = forwardRef(function (inProps, ref) {
|
|
|
18
18
|
var maxLength = keypadMode ? undefined : inputPropsProp === null || inputPropsProp === void 0 ? void 0 : inputPropsProp.maxLength;
|
|
19
19
|
var checkNotReFocus = useEventCallback(function (reason, isFocus) {
|
|
20
20
|
var elm = inputRef.current;
|
|
21
|
-
var isInputFocus = isFocus !== null && isFocus !== void 0 ? isFocus : document.activeElement === elm;
|
|
21
|
+
var isInputFocus = isFocus !== null && isFocus !== void 0 ? isFocus : externalWindow.document.activeElement === elm;
|
|
22
22
|
if (reason !== 'click' && !isInputFocus) {
|
|
23
23
|
// ! both keydown and touch, only when focus need re-focus
|
|
24
24
|
isNotTriggerRefocusRef.current = true;
|
|
@@ -42,7 +42,7 @@ var _RcDialTextField = forwardRef(function (inProps, ref) {
|
|
|
42
42
|
useImperativeHandle(dialerContext.onDeleteRef, function () { return function (e, reason) {
|
|
43
43
|
var elm = inputRef.current;
|
|
44
44
|
if (elm && (value === null || value === void 0 ? void 0 : value.length)) {
|
|
45
|
-
var isFocus = document.activeElement === elm;
|
|
45
|
+
var isFocus = externalWindow.document.activeElement === elm;
|
|
46
46
|
var toPosition = void 0;
|
|
47
47
|
var toValue = void 0;
|
|
48
48
|
if (isFocus) {
|
|
@@ -71,14 +71,14 @@ var _RcDialTextField = forwardRef(function (inProps, ref) {
|
|
|
71
71
|
onChange === null || onChange === void 0 ? void 0 : onChange(toValue);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
}; }, [checkNotReFocus, inputRef, onChange, value]);
|
|
74
|
+
}; }, [checkNotReFocus, externalWindow, inputRef, onChange, value]);
|
|
75
75
|
/**
|
|
76
76
|
* outside change value via this method, with check current input state
|
|
77
77
|
*/
|
|
78
78
|
useImperativeHandle(dialerContext.onInsertRef, function () { return function (addValue, reason) {
|
|
79
79
|
var elm = inputRef.current;
|
|
80
80
|
if (elm) {
|
|
81
|
-
var isFocus = document.activeElement === elm;
|
|
81
|
+
var isFocus = externalWindow.document.activeElement === elm;
|
|
82
82
|
var toPosition = void 0;
|
|
83
83
|
var toValue = void 0;
|
|
84
84
|
// * when keypadMode also add value at latest
|
|
@@ -104,6 +104,7 @@ var _RcDialTextField = forwardRef(function (inProps, ref) {
|
|
|
104
104
|
}
|
|
105
105
|
}; }, [
|
|
106
106
|
checkNotReFocus,
|
|
107
|
+
externalWindow,
|
|
107
108
|
inputRef,
|
|
108
109
|
keypadMode,
|
|
109
110
|
maxLength,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __assign, __rest } from "tslib";
|
|
2
2
|
import { useEffect, useRef } from 'react';
|
|
3
3
|
import { getRefElement } from '../../utils';
|
|
4
4
|
import { useEventCallback } from '../useEventCallback';
|
|
@@ -17,13 +17,14 @@ import { useEventCallback } from '../useEventCallback';
|
|
|
17
17
|
* useEventListener(window, 'keyup', () => console.log('window key up'))
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
export function useEventListener(target) {
|
|
21
|
-
var
|
|
22
|
-
for (var _i =
|
|
23
|
-
|
|
20
|
+
export function useEventListener(target, key, callback) {
|
|
21
|
+
var args = [];
|
|
22
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
|
23
|
+
args[_i - 3] = arguments[_i];
|
|
24
24
|
}
|
|
25
|
-
var _a =
|
|
26
|
-
var
|
|
25
|
+
var _a = getListenerOverloadOption(args), options = _a.options, config = _a.config;
|
|
26
|
+
var _b = (config || {}).startImmediately, startImmediately = _b === void 0 ? true : _b;
|
|
27
|
+
var listener = useEventCallback(callback);
|
|
27
28
|
var cancelRef = useRef(function () { });
|
|
28
29
|
var bindRef = useRef(function () { });
|
|
29
30
|
var currentRefElm = getRefElement(target);
|
|
@@ -38,7 +39,9 @@ export function useEventListener(target) {
|
|
|
38
39
|
cancelRef.current = function () {
|
|
39
40
|
return currentElm.removeEventListener(key, listener, options);
|
|
40
41
|
};
|
|
41
|
-
|
|
42
|
+
if (startImmediately) {
|
|
43
|
+
bindRef.current();
|
|
44
|
+
}
|
|
42
45
|
return cancelRef.current;
|
|
43
46
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
44
47
|
}, [target, currentRefElm]);
|
|
@@ -47,3 +50,19 @@ export function useEventListener(target) {
|
|
|
47
50
|
remove: function () { return cancelRef.current(); },
|
|
48
51
|
};
|
|
49
52
|
}
|
|
53
|
+
function getListenerOverloadOption(args) {
|
|
54
|
+
var options;
|
|
55
|
+
var config;
|
|
56
|
+
if (typeof args[0] === 'boolean') {
|
|
57
|
+
options = args[0];
|
|
58
|
+
config = args[1];
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
var _a = __assign(__assign({}, (args[0] || {})), (args[1] || {})), startImmediately = _a.startImmediately, restOptions = __rest(_a, ["startImmediately"]);
|
|
62
|
+
options = restOptions;
|
|
63
|
+
config = {
|
|
64
|
+
startImmediately: startImmediately,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return { options: options, config: config };
|
|
68
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { getRefElement } from '../../utils';
|
|
2
|
+
export var globalListenerEventMap = new Map();
|
|
3
|
+
/**
|
|
4
|
+
* create globalListener handler for share one listener event
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const globalListener = createGlobalListener('focus', () => { console.log('focus') });
|
|
9
|
+
* const globalListener2 = createGlobalListener('focus', () => { console.log('focus') });
|
|
10
|
+
* globalListener.listen();
|
|
11
|
+
* globalListener2.listen();
|
|
12
|
+
*
|
|
13
|
+
* => // that will only create an event listener on window, but every callback will get emit value when event triggered
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export var createGlobalListener = function (key, listener, options, _a) {
|
|
17
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.customKey, customKey = _c === void 0 ? key : _c, _d = _b.target, targetProp = _d === void 0 ? window : _d;
|
|
18
|
+
var listening = false;
|
|
19
|
+
var getMapValue = function () { return globalListenerEventMap.get(customKey); };
|
|
20
|
+
var addListener = function () {
|
|
21
|
+
if (listening)
|
|
22
|
+
return;
|
|
23
|
+
var savedEvent = getMapValue();
|
|
24
|
+
if (!(savedEvent === null || savedEvent === void 0 ? void 0 : savedEvent.exec)) {
|
|
25
|
+
var exec = function (e) {
|
|
26
|
+
var event = getMapValue();
|
|
27
|
+
event === null || event === void 0 ? void 0 : event.listeners.forEach(function (c) { return c(e); });
|
|
28
|
+
};
|
|
29
|
+
globalListenerEventMap.set(customKey, {
|
|
30
|
+
exec: exec,
|
|
31
|
+
listeners: new Set([listener]),
|
|
32
|
+
});
|
|
33
|
+
var target = getRefElement(targetProp);
|
|
34
|
+
target === null || target === void 0 ? void 0 : target.addEventListener(key, exec, options);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
savedEvent.listeners.add(listener);
|
|
38
|
+
}
|
|
39
|
+
listening = true;
|
|
40
|
+
};
|
|
41
|
+
var removeListener = function () {
|
|
42
|
+
if (!listening)
|
|
43
|
+
return;
|
|
44
|
+
listening = false;
|
|
45
|
+
var _savedEvent = getMapValue();
|
|
46
|
+
if (!_savedEvent)
|
|
47
|
+
return;
|
|
48
|
+
var listeners = _savedEvent.listeners;
|
|
49
|
+
listeners.delete(listener);
|
|
50
|
+
if (listeners.size === 0) {
|
|
51
|
+
var target = getRefElement(targetProp);
|
|
52
|
+
target === null || target === void 0 ? void 0 : target.removeEventListener(key, _savedEvent.exec, options);
|
|
53
|
+
globalListenerEventMap.delete(customKey);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
listen: function () { return addListener(); },
|
|
58
|
+
/**
|
|
59
|
+
* remove listener
|
|
60
|
+
*/
|
|
61
|
+
remove: function () { return removeListener(); },
|
|
62
|
+
/**
|
|
63
|
+
* current listener state
|
|
64
|
+
*/
|
|
65
|
+
get state() {
|
|
66
|
+
return {
|
|
67
|
+
/**
|
|
68
|
+
* current listener state count
|
|
69
|
+
*/
|
|
70
|
+
get count() {
|
|
71
|
+
var _a;
|
|
72
|
+
return ((_a = getMapValue()) === null || _a === void 0 ? void 0 : _a.listeners.size) || 0;
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* is that be listening
|
|
76
|
+
*/
|
|
77
|
+
listening: listening,
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
};
|