@ringcentral/spring-ui 1.7.0 → 1.8.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/Alert.js +3 -3
- package/Announcement.js +1 -1
- package/Autocomplete.js +174 -236
- package/Avatar.js +27 -13
- package/BottomNavigation.js +0 -3
- package/Checkbox.js +0 -2
- package/DatePicker.js +5 -13
- package/DateUtilsContext.js +0 -1
- package/Dialer.js +2 -50
- package/Dialog.js +4 -4
- package/Dropdown.js +0 -7
- package/FocusTrap.js +0 -32
- package/InlineEditable.js +0 -4
- package/Link.js +1 -1
- package/ListItem.js +1 -1
- package/ListNavigation.js +0 -6
- package/Menu.js +1 -1
- package/MenuDivider.js +2 -2
- package/MenuFooter.js +4 -4
- package/MenuHeader.js +4 -4
- package/MenuItem.js +1 -1
- package/MenuItemText.js +1 -1
- package/PageHeader.js +6 -4
- package/Popper.js +0 -1
- package/Rating.js +0 -5
- package/SingleFilter.js +0 -1
- package/Slider.js +1 -4
- package/Snackbar.js +0 -14
- package/SortableListItem.js +0 -1
- package/SplitButton.js +1 -3
- package/StatusIndicator.js +1 -1
- package/SubMenu.js +0 -4
- package/SwipeableDrawer.js +8 -146
- package/Switch.js +1 -4
- package/Tab.js +7 -8
- package/TabContext.js +0 -5
- package/TableBody.js +1 -1
- package/TableCell.js +0 -6
- package/TableRow.js +0 -1
- package/Tabs.js +20 -118
- package/Text.js +2 -4
- package/TimePicker.js +7 -46
- package/VirtualizedList.js +2 -30
- package/chunks/Alert.js +8 -7
- package/chunks/BottomNavigationItem.js +0 -1
- package/chunks/Button.js +0 -1
- package/chunks/Chip.js +0 -5
- package/chunks/Drawer.js +1 -30
- package/chunks/ListItem.js +3 -6
- package/chunks/Menu.js +3 -3
- package/chunks/MenuDivider.js +2 -3
- package/chunks/MenuItemText.js +3 -3
- package/chunks/MenuList.js +0 -3
- package/chunks/PickerTextField.js +0 -1
- package/chunks/Popover.js +0 -5
- package/chunks/Select.js +2 -39
- package/chunks/Squircle.js +0 -7
- package/chunks/StatusIndicator.js +1 -0
- package/chunks/StepIcon.js +1 -3
- package/chunks/StepperContext.js +0 -7
- package/chunks/Tooltip.js +0 -36
- package/chunks/VirtualizedMenu.js +2 -78
- package/chunks/getFade.js +2 -0
- package/chunks/useFocusTrapStack.js +0 -8
- package/chunks/useHelperTextId.js +0 -24
- package/chunks/useListNavigation.js +2 -17
- package/chunks/useMenuItemSelect.js +6 -19
- package/chunks/useMotionSafeTransition.js +0 -4
- package/chunks/useNestedParentMenu.js +0 -2
- package/chunks/usePrefersReducedMotion.js +0 -10
- package/chunks/useTooltipForceHide.js +0 -4
- package/chunks/useTrayNavigate.js +0 -1
- package/index.css +392 -120
- package/index.js +1 -1
- package/package.json +4 -4
- package/src/Accordion/Accordion.type.d.ts +0 -21
- package/src/AccordionHeader/AccordionHeader.type.d.ts +0 -14
- package/src/Alert/Alert.type.d.ts +0 -32
- package/src/Animation/components/ExpandCollapseCaret/ExpandCollapseCaret.d.ts +0 -4
- package/src/Animation/components/ShowHideEye/ShowHideEye.d.ts +0 -4
- package/src/Animation/hooks/useMotionSafeTransition/useMotionSafeTransition.d.ts +0 -4
- package/src/Autocomplete/Autocomplete.d.ts +0 -5
- package/src/Autocomplete/Autocomplete.type.d.ts +0 -84
- package/src/Autocomplete/SuggestionList/SuggestionList.d.ts +5 -89
- package/src/Autocomplete/SuggestionList/SuggestionListItem.d.ts +0 -2
- package/src/Autocomplete/SuggestionList/utils/SuggestionListItem.d.ts +1 -13
- package/src/Autocomplete/SuggestionList/utils/useDynamicHeight.d.ts +0 -6
- package/src/Autocomplete/SuggestionList/utils/useHighlightScroll.d.ts +0 -20
- package/src/Autocomplete/SuggestionList/utils/useSuggestionList.d.ts +3 -41
- package/src/Autocomplete/SuggestionList/utils/useSuggestionListGroup.d.ts +0 -49
- package/src/Autocomplete/useAutocomplete.d.ts +1 -62
- package/src/Autocomplete/useAutocompleteTag.d.ts +0 -33
- package/src/Avatar/Avatar.type.d.ts +0 -58
- package/src/AvatarGroup/AvatarGroup.type.d.ts +0 -3
- package/src/Backdrop/Backdrop.type.d.ts +0 -4
- package/src/Badge/Badge.type.d.ts +0 -33
- package/src/Block/Block.type.d.ts +0 -24
- package/src/BlockHeader/BlockHeader.type.d.ts +0 -5
- package/src/BottomNavigation/BottomNavigation.type.d.ts +0 -34
- package/src/BottomNavigationItem/BottomNavigationItem.type.d.ts +0 -39
- package/src/Button/Button.type.d.ts +0 -30
- package/src/CallButton/CallButton.type.d.ts +0 -4
- package/src/Checkbox/Checkbox.type.d.ts +0 -17
- package/src/Chip/Chip.type.d.ts +0 -41
- package/src/CircularProgressIndicator/CircularProgressIndicator.type.d.ts +0 -19
- package/src/DatePicker/Calendar.d.ts +1 -20
- package/src/DatePicker/DatePicker.type.d.ts +0 -18
- package/src/DatePicker/DatePickerHeader.d.ts +1 -12
- package/src/DatePicker/Day.d.ts +0 -7
- package/src/DatePicker/Year.d.ts +0 -6
- package/src/DatePicker/Years.d.ts +0 -7
- package/src/Dialer/DialDelete/DialDelete.d.ts +0 -3
- package/src/Dialer/DialPad/DialPad.d.ts +0 -106
- package/src/Dialer/DialPad/utils/types.d.ts +0 -5
- package/src/Dialer/DialPad/utils/useDialKeyboard.d.ts +0 -5
- package/src/Dialer/DialPad/utils/useKeyAudio.d.ts +0 -9
- package/src/Dialer/DialPadButton/DialPadButton.d.ts +0 -14
- package/src/Dialer/DialTextField/DialTextField.d.ts +0 -23
- package/src/Dialer/DialTextField/utils/getDialPadValueOnlyRegex.d.ts +0 -3
- package/src/Dialer/DialTextField/utils/useFixedEndSelection.d.ts +0 -3
- package/src/Dialog/Dialog.type.d.ts +0 -11
- package/src/Divider/Divider.type.d.ts +0 -17
- package/src/DragHandle/DragHandle.type.d.ts +0 -4
- package/src/Drawer/Drawer.d.ts +0 -28
- package/src/Drawer/Drawer.type.d.ts +0 -84
- package/src/Dropdown/Dropdown.type.d.ts +0 -64
- package/src/EmptyState/EmptyState.type.d.ts +0 -12
- package/src/FabButton/FabButton.type.d.ts +0 -5
- package/src/FocusTrap/FocusTrap.d.ts +0 -38
- package/src/FocusTrap/useFocusTrapStack.d.ts +0 -9
- package/src/FormField/FormField.type.d.ts +0 -26
- package/src/FormField/useHelperTextId.d.ts +0 -25
- package/src/FormLabel/FormLabel.type.d.ts +0 -14
- package/src/Icon/Icon.type.d.ts +0 -15
- package/src/IconButton/IconButton.type.d.ts +0 -30
- package/src/IconButton/IconButtonLabel.type.d.ts +0 -3
- package/src/IconButtonGroup/IconButtonGroup.type.d.ts +0 -8
- package/src/InlineEditable/InlineEditable.type.d.ts +0 -75
- package/src/LinearProgressIndicator/LinearProgressIndicator.type.d.ts +0 -31
- package/src/Link/Link.classes.d.ts +1 -1
- package/src/Link/Link.type.d.ts +1 -10
- package/src/ListItem/ListItem.type.d.ts +0 -41
- package/src/ListItemText/ListItemText.type.d.ts +0 -21
- package/src/ListNavigation/useListNavigation.d.ts +0 -16
- package/src/Menu/Menu.type.d.ts +0 -10
- package/src/MenuFooter/MenuFooter.type.d.ts +0 -4
- package/src/MenuHeader/MenuHeader.type.d.ts +0 -10
- package/src/MenuItem/MenuItem.type.d.ts +0 -19
- package/src/MenuItem/MenuItemSelectContext.d.ts +0 -3
- package/src/MenuItem/useMenuItemSelect.d.ts +0 -21
- package/src/MenuItemText/MenuItemText.type.d.ts +0 -17
- package/src/MenuList/MenuList.type.d.ts +0 -4
- package/src/MenuList/MenuListContext.d.ts +0 -6
- package/src/Modal/InnerModal.type.d.ts +0 -5
- package/src/Modal/Modal.type.d.ts +0 -11
- package/src/Modal/ModalContext.d.ts +0 -4
- package/src/Option/Option.type.d.ts +0 -3
- package/src/Overlap/Overlap.type.d.ts +0 -11
- package/src/PageHeader/PageHeader.type.d.ts +0 -4
- package/src/PickerTextField/PickerTextField.type.d.ts +0 -10
- package/src/Popover/Popover.type.d.ts +0 -29
- package/src/Popper/Popper.type.d.ts +0 -61
- package/src/Radio/Radio.type.d.ts +0 -5
- package/src/RadioGroup/RadioGroup.type.d.ts +0 -4
- package/src/Rating/Rating.type.d.ts +0 -74
- package/src/Select/Select.type.d.ts +0 -84
- package/src/SingleFilter/FilterButton/FilterButton.type.d.ts +0 -16
- package/src/SingleFilter/SingleFilter.type.d.ts +0 -26
- package/src/Skeleton/Skeleton.type.d.ts +0 -1
- package/src/Skeleton/SkeletonContainer/SkeletonContainer.classes.d.ts +1 -1
- package/src/Slider/Slider.classes.d.ts +1 -5
- package/src/Slider/Slider.type.d.ts +0 -104
- package/src/Snackbar/Snackbar.type.d.ts +0 -18
- package/src/SplitButton/SplitButton.type.d.ts +0 -21
- package/src/Squircle/Squircle.type.d.ts +0 -3
- package/src/StatusIndicator/StatusIndicator.classes.d.ts +1 -1
- package/src/StatusIndicator/StatusIndicator.type.d.ts +1 -9
- package/src/Step/Step.type.d.ts +0 -29
- package/src/Step/StepContext.d.ts +0 -7
- package/src/StepButton/StepButton.type.d.ts +0 -15
- package/src/StepContent/StepContent.type.d.ts +0 -7
- package/src/StepIcon/StepIcon.type.d.ts +0 -26
- package/src/StepLabel/StepLabel.type.d.ts +0 -23
- package/src/Stepper/Stepper.type.d.ts +0 -27
- package/src/SwipeableDrawer/SwipeableDrawer.d.ts +0 -26
- package/src/SwipeableDrawer/SwipeableDrawer.types.d.ts +0 -67
- package/src/SwipeableDrawer/hooks/useDrawerGestures.d.ts +0 -110
- package/src/SwipeableDrawer/hooks/useElementSizeObserver.d.ts +0 -5
- package/src/SwipeableDrawer/hooks/useSnapPoints.d.ts +0 -60
- package/src/Switch/Switch.type.d.ts +0 -9
- package/src/Tab/Tab.classes.d.ts +3 -2
- package/src/Tab/Tab.type.d.ts +0 -29
- package/src/TabContext/TabContext.d.ts +0 -4
- package/src/TabContext/TabContext.type.d.ts +0 -7
- package/src/TabPanel/TabPanel.type.d.ts +0 -10
- package/src/Table/Table.type.d.ts +0 -19
- package/src/TableBody/TableBody.type.d.ts +0 -3
- package/src/TableCell/TableCell.d.ts +0 -4
- package/src/TableCell/TableCell.type.d.ts +0 -35
- package/src/TableContainer/TableContainer.type.d.ts +0 -7
- package/src/TableFooter/TableFooter.type.d.ts +0 -3
- package/src/TableHead/TableHead.type.d.ts +0 -6
- package/src/TablePagination/TablePagination.type.d.ts +0 -47
- package/src/TableRow/TableRow.type.d.ts +0 -17
- package/src/Tabs/TabMoreMenu.d.ts +0 -16
- package/src/Tabs/TabScrollButton.d.ts +0 -10
- package/src/Tabs/Tabs.classes.d.ts +1 -1
- package/src/Tabs/Tabs.d.ts +1 -1
- package/src/Tabs/Tabs.type.d.ts +2 -36
- package/src/Tabs/TabsContext.d.ts +2 -0
- package/src/Tabs/hooks/useTabsScroller.d.ts +0 -30
- package/src/Tag/Tag.type.d.ts +0 -12
- package/src/Text/Text.type.d.ts +0 -13
- package/src/TextField/TextField.type.d.ts +0 -64
- package/src/Textarea/Textarea.type.d.ts +0 -13
- package/src/TimePicker/NumberPicker.type.d.ts +0 -12
- package/src/TimePicker/SelectionView.d.ts +0 -6
- package/src/TimePicker/TimeButton.d.ts +0 -3
- package/src/TimePicker/TimePicker.type.d.ts +0 -11
- package/src/TimePicker/ToggleText.type.d.ts +0 -3
- package/src/TimePicker/utils/TimeBoundary.d.ts +0 -3
- package/src/TimePicker/utils/TimePickerHelper.d.ts +0 -19
- package/src/TimePicker/utils/getNumberPickerBoundary.d.ts +0 -3
- package/src/Tooltip/TooltipTrigger.a11y.d.ts +0 -9
- package/src/Tooltip/TooltipTrigger.type.d.ts +0 -44
- package/src/Tooltip/TooltipView.type.d.ts +0 -25
- package/src/Tooltip/useTooltipForceHide.d.ts +0 -4
- package/src/Tray/Tray.type.d.ts +0 -13
- package/src/Tray/TrayContext.d.ts +0 -4
- package/src/Tray/hooks/useTray.d.ts +0 -16
- package/src/Tray/hooks/useTrayPanel.d.ts +0 -3
- package/src/VirtualizedList/VirtualizedList.type.d.ts +0 -27
- package/src/VirtualizedMenu/VirtualizedMenu.type.d.ts +0 -17
package/Avatar.js
CHANGED
|
@@ -21,6 +21,15 @@ const IconSizeMap = {
|
|
|
21
21
|
xsmall: 'xsmall',
|
|
22
22
|
xxsmall: 'xsmall',
|
|
23
23
|
};
|
|
24
|
+
const StatusIndicatorSizeMap = {
|
|
25
|
+
xxlarge: 'large',
|
|
26
|
+
xlarge: 'large',
|
|
27
|
+
large: 'medium',
|
|
28
|
+
medium: 'medium',
|
|
29
|
+
small: 'small',
|
|
30
|
+
xsmall: undefined,
|
|
31
|
+
xxsmall: undefined,
|
|
32
|
+
};
|
|
24
33
|
const Avatar = forwardRef((inProps, ref) => {
|
|
25
34
|
const props = useThemeProps({ props: inProps, name: 'Avatar' });
|
|
26
35
|
const { component, classes, className, children: childrenProp, imgProps, alt, src, srcSet, size: sizeProp, color = 'default', variant = 'circle', clickable: clickableProp, symbol, avatarShapeRef, showStatusIndicator, IndicatorProps, rootProps, disabled, ...rest } = props;
|
|
@@ -65,6 +74,7 @@ const Avatar = forwardRef((inProps, ref) => {
|
|
|
65
74
|
const { focusVisible, focusVisibleRef, focusVisibleHandlers } = useFocusVisible(props);
|
|
66
75
|
const avatarRef = useForkRef(avatarShapeRef, focusVisibleRef);
|
|
67
76
|
const clickable = clickableProp !== false && rest.onClick ? true : clickableProp ?? false;
|
|
77
|
+
const interactive = clickable && !disabled;
|
|
68
78
|
const supportsStatusIndicator = size !== 'xxsmall' && size !== 'xsmall';
|
|
69
79
|
let AvatarShape = component ?? 'div';
|
|
70
80
|
if (variant === 'squircle') {
|
|
@@ -73,32 +83,36 @@ const Avatar = forwardRef((inProps, ref) => {
|
|
|
73
83
|
else if (clickable) {
|
|
74
84
|
AvatarShape = 'button';
|
|
75
85
|
}
|
|
86
|
+
const isButtonElement = AvatarShape === 'button' || component === 'button';
|
|
76
87
|
const shapeProps = variant === 'squircle'
|
|
77
88
|
? {
|
|
78
89
|
component,
|
|
79
|
-
focusVisible: focusVisible &&
|
|
90
|
+
focusVisible: focusVisible && interactive,
|
|
80
91
|
fillShape,
|
|
81
|
-
interactive
|
|
92
|
+
interactive,
|
|
82
93
|
}
|
|
83
94
|
: {};
|
|
84
|
-
const ariaProps =
|
|
95
|
+
const ariaProps = isButtonElement
|
|
85
96
|
? {
|
|
86
97
|
disabled,
|
|
87
98
|
}
|
|
88
|
-
:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
99
|
+
: clickable && disabled
|
|
100
|
+
? {
|
|
101
|
+
'aria-disabled': true,
|
|
102
|
+
}
|
|
103
|
+
: {};
|
|
104
|
+
const nonInteractiveShapeProps = !isButtonElement && clickable && disabled
|
|
105
|
+
? {
|
|
106
|
+
tabIndex: -1,
|
|
107
|
+
}
|
|
108
|
+
: {};
|
|
95
109
|
return (jsx(Overlap, { position: {
|
|
96
110
|
bottom: '-1px',
|
|
97
111
|
right: '-1px',
|
|
98
|
-
}, floater: supportsStatusIndicator && showStatusIndicator ? (jsx(StatusIndicator, { size:
|
|
112
|
+
}, floater: supportsStatusIndicator && showStatusIndicator ? (jsx(StatusIndicator, { size: StatusIndicatorSizeMap[size], ...IndicatorProps })) : undefined, className: clsx(className, groupClassName), classes: {
|
|
99
113
|
root: cls('root', size, { disabled }),
|
|
100
|
-
floater: cls('indicator',
|
|
101
|
-
}, ...rootProps, ref: ref, children: jsxs(AvatarShape, { className: cls('shape', variant, color, { clickable },
|
|
114
|
+
floater: cls('indicator', interactive && 'clickable-indicator'),
|
|
115
|
+
}, ...rootProps, ref: ref, children: jsxs(AvatarShape, { className: cls('shape', variant, color, { clickable }, interactive && 'clickable-shape', interactive && `clickable-${variant}`), ...focusVisibleHandlers, ...shapeProps, ...ariaProps, ...nonInteractiveShapeProps, ...rest, ref: avatarRef, children: [jsx("div", { className: cls('content', `${variant}-content`, `${size}-content`, `${variant}-${color}`), children: children }), variant === 'circle' && (jsx("div", { className: cls('hover-tint', interactive && 'clickable-hover-tint', interactive && `clickable-hover-tint-${color}-${variant}`) })), variant === 'squircle' && interactive && (jsx(Squircle, { interactive: false, className: cls('hover-tint', interactive && 'clickable-hover-tint', interactive && `clickable-hover-tint-${color}-${variant}`) }))] }) }));
|
|
102
116
|
});
|
|
103
117
|
Avatar.displayName = 'SuiAvatar';
|
|
104
118
|
|
package/BottomNavigation.js
CHANGED
|
@@ -49,8 +49,6 @@ const BottomNavigation = forwardRef((inProps, ref) => {
|
|
|
49
49
|
name: 'SuiBottomNavigation',
|
|
50
50
|
state: 'value',
|
|
51
51
|
});
|
|
52
|
-
// TODO: setData will be used when dnd is implemented
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
54
52
|
const [data, setData] = useControlled({
|
|
55
53
|
controlled: dataProp,
|
|
56
54
|
default: defaultData,
|
|
@@ -72,7 +70,6 @@ const BottomNavigation = forwardRef((inProps, ref) => {
|
|
|
72
70
|
const [expanded, setExpanded] = useState(false);
|
|
73
71
|
const [animationComplete, setAnimationComplete] = useState();
|
|
74
72
|
const transition = useMotionSafeTransition(motionTransition['haste-01-fast']);
|
|
75
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
73
|
const handleClose = (e, reason) => {
|
|
77
74
|
if (!expanded)
|
|
78
75
|
return;
|
package/Checkbox.js
CHANGED
|
@@ -20,7 +20,6 @@ const Checkbox = forwardRef((inProps, ref) => {
|
|
|
20
20
|
disabled: disabledProp,
|
|
21
21
|
id: inputProps?.id,
|
|
22
22
|
});
|
|
23
|
-
// TODO: wait useCheckBox ready, see https://github.com/mui/material-ui/issues/27170
|
|
24
23
|
const { getInputProps, checked, focusVisible } = useSwitch({
|
|
25
24
|
...rest,
|
|
26
25
|
disabled,
|
|
@@ -34,7 +33,6 @@ const Checkbox = forwardRef((inProps, ref) => {
|
|
|
34
33
|
if (autoFocus) {
|
|
35
34
|
inputRef.current?.focus();
|
|
36
35
|
}
|
|
37
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
38
36
|
}, []);
|
|
39
37
|
useEffect(() => {
|
|
40
38
|
if (inputRef.current) {
|
package/DatePicker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { useFocusVisible, useForkRef, combineProps, useOnlyOneFocusable, useKeyboardMoveFocus, usePrevious, useEventCallback, useWindowContext, runKeyHandler,
|
|
2
|
+
import { useFocusVisible, useForkRef, combineProps, useOnlyOneFocusable, useKeyboardMoveFocus, usePrevious, useEventCallback, useWindowContext, runKeyHandler, useControlled } from '@ringcentral/spring-base';
|
|
3
3
|
import { createContext, useContext, useRef, forwardRef, useMemo, useLayoutEffect, createElement, useState, useCallback, useEffect } from 'react';
|
|
4
4
|
import { B as Button } from './chunks/Button.js';
|
|
5
5
|
import { C as CircularProgressIndicator } from './chunks/CircularProgressIndicator.js';
|
|
@@ -7,7 +7,7 @@ import { useDateUtilsContext, DateUtilsProvider } from './DateUtilsContext.js';
|
|
|
7
7
|
import { CaretLeftMd, CaretRightMd, CalendarMd } from '@ringcentral/spring-icon';
|
|
8
8
|
import { E as ExpandCollapseCaret } from './chunks/ExpandCollapseCaret.js';
|
|
9
9
|
import 'framer-motion';
|
|
10
|
-
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
10
|
+
import { useThemeProps, useClassesWithMode } from '@ringcentral/spring-theme';
|
|
11
11
|
import './chunks/Icon.js';
|
|
12
12
|
import { I as IconButton } from './chunks/IconButtonLabel.js';
|
|
13
13
|
import { V as VisuallyHidden } from './chunks/VisuallyHidden.js';
|
|
@@ -127,7 +127,6 @@ const findClosestEnabledDate = ({ date, utils, minDate, maxDate, disableFuture,
|
|
|
127
127
|
backward = utils.addDays(backward, -1);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
// fallback to today if no enabled days
|
|
131
130
|
return utils.date();
|
|
132
131
|
};
|
|
133
132
|
|
|
@@ -220,7 +219,6 @@ const Years = forwardRef((props, ref) => {
|
|
|
220
219
|
useLayoutEffect(() => {
|
|
221
220
|
const index = years.findIndex((x) => utils.getYearText(x) === currentYear);
|
|
222
221
|
focusIndex(index);
|
|
223
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
224
222
|
}, []);
|
|
225
223
|
const cls = useDatePickerClasses();
|
|
226
224
|
return (jsx("div", { role: "presentation", className: cls('years-panel'), ref: combineRef, onKeyDown: handleKeyDown, children: years.map((year, index) => {
|
|
@@ -362,12 +360,10 @@ const Calendar = forwardRef(({ onMonthChange, date, shouldDisableDate, dateRange
|
|
|
362
360
|
useLayoutEffect(() => {
|
|
363
361
|
if (viewChange)
|
|
364
362
|
return;
|
|
365
|
-
// same month anchor switch
|
|
366
363
|
if (sameMonthDate) {
|
|
367
364
|
focusDayElement();
|
|
368
365
|
return;
|
|
369
366
|
}
|
|
370
|
-
// different month anchor switch and not switch by header action
|
|
371
367
|
const activeEl = document?.activeElement;
|
|
372
368
|
if (activeEl &&
|
|
373
369
|
!activeEl.hasAttribute('data-sui-picker-next-month') &&
|
|
@@ -381,7 +377,6 @@ const Calendar = forwardRef(({ onMonthChange, date, shouldDisableDate, dateRange
|
|
|
381
377
|
}
|
|
382
378
|
return undefined;
|
|
383
379
|
});
|
|
384
|
-
// when view change and current is day also focusDay again
|
|
385
380
|
useLayoutEffect(() => {
|
|
386
381
|
if (previousView && view === 'day' && viewChange) {
|
|
387
382
|
focusDayElement();
|
|
@@ -394,14 +389,14 @@ const Calendar = forwardRef(({ onMonthChange, date, shouldDisableDate, dateRange
|
|
|
394
389
|
});
|
|
395
390
|
Calendar.displayName = 'RcCalendar';
|
|
396
391
|
|
|
397
|
-
var DatePicker$1 = {"sui-date-picker-calendar":"sui-date-picker-calendar","sui-date-picker-header":"sui-date-picker-header","sui-date-picker-header-action":"sui-date-picker-header-action","sui-focus-visible":"sui-focus-visible","sui-disabled":"sui-disabled","sui-date-picker-switch-year-action":"sui-date-picker-switch-year-action","sui-date-picker-switch-year-action-caret":"sui-date-picker-switch-year-action-caret","sui-date-picker-switch-month-actions-group":"sui-date-picker-switch-month-actions-group","sui-date-picker-switch-month-action":"sui-date-picker-switch-month-action","sui-date-picker-date-button":"sui-date-picker-date-button","sui-selected":"sui-selected","sui-date-picker-current-date":"sui-date-picker-current-date","sui-date-picker-day":"sui-date-picker-day","sui-date-picker-year":"sui-date-picker-year","sui-date-picker-years-panel":"sui-date-picker-years-panel","sui-date-picker-days-panel":"sui-date-picker-days-panel","sui-date-picker-days-grid":"sui-date-picker-days-grid","sui-date-picker-weekdays":"sui-date-picker-weekdays","sui-date-picker-weekday":"sui-date-picker-weekday","sui-date-picker-loading-container":"sui-date-picker-loading-container","sui-date-picker-today-button":"sui-date-picker-today-button"};
|
|
392
|
+
var DatePicker$1 = {"sui-date-picker-calendar":"sui-date-picker-calendar","sui-date-picker-header":"sui-date-picker-header","sui-date-picker-header-action":"sui-date-picker-header-action","sui-focus-visible":"sui-focus-visible","sui-disabled":"sui-disabled","sui-date-picker-switch-year-action":"sui-date-picker-switch-year-action","sui-date-picker-switch-year-action-caret":"sui-date-picker-switch-year-action-caret","sui-date-picker-switch-month-actions-group":"sui-date-picker-switch-month-actions-group","sui-date-picker-switch-month-action":"sui-date-picker-switch-month-action","sui-date-picker-date-button":"sui-date-picker-date-button","sui-selected":"sui-selected","sui-date-picker-current-date":"sui-date-picker-current-date","sui-date-picker-day":"sui-date-picker-day","sui-date-picker-year":"sui-date-picker-year","sui-date-picker-years-panel":"sui-date-picker-years-panel","sui-date-picker-days-panel":"sui-date-picker-days-panel","sui-date-picker-days-grid":"sui-date-picker-days-grid","sui-date-picker-weekdays":"sui-date-picker-weekdays","sui-date-picker-weekday":"sui-date-picker-weekday","sui-date-picker-loading-container":"sui-date-picker-loading-container","sui-date-picker-today-button":"sui-date-picker-today-button","sui-compact":"sui-compact"};
|
|
398
393
|
|
|
399
394
|
const defaultMinDate = new Date('1900-01-01');
|
|
400
395
|
const defaultMaxDate = new Date('2100-01-01');
|
|
401
396
|
const DEFAULT_FORMAT = 'MM/DD/YYYY';
|
|
402
397
|
const InnerDatePicker = (props) => {
|
|
403
398
|
const { innerRef, value, onChange, formatString = DEFAULT_FORMAT, todayButtonText = 'Today', min: minDate = null, max: maxDate = null, disableFuture, disablePast, loadingIndicator, onMonthChange, renderDay, disabled, shouldDisableDate: shouldDisableDateProp, onClose, onClear, classes, PopoverProps, screenReaderProps, clearBtn = true, label = 'Date', className, ...rest } = props;
|
|
404
|
-
const cls =
|
|
399
|
+
const cls = useClassesWithMode('date-picker', classes, className, ['calendar']);
|
|
405
400
|
const utils = useDateUtilsContext();
|
|
406
401
|
const [controlledValue, setControlledValue] = useControlled({
|
|
407
402
|
controlled: value,
|
|
@@ -444,7 +439,6 @@ const InnerDatePicker = (props) => {
|
|
|
444
439
|
const handleChange = (toDate, fromUserSelect) => {
|
|
445
440
|
actionRef.current?.close();
|
|
446
441
|
setControlledValue(toDate);
|
|
447
|
-
// save inner change value
|
|
448
442
|
emitValueRef.current = toDate;
|
|
449
443
|
onChange?.(toDate, fromUserSelect);
|
|
450
444
|
};
|
|
@@ -453,9 +447,7 @@ const InnerDatePicker = (props) => {
|
|
|
453
447
|
handleChange(newDay, fromUserSelect);
|
|
454
448
|
});
|
|
455
449
|
useEffect(() => {
|
|
456
|
-
if (
|
|
457
|
-
// only when inner value change need check again is that value is valid
|
|
458
|
-
dayjsValue &&
|
|
450
|
+
if (dayjsValue &&
|
|
459
451
|
value !== emitValueRef.current &&
|
|
460
452
|
shouldDisableDate(dayjsValue)) {
|
|
461
453
|
const closestEnabledDate = getClosestEnabledDate(dayjsValue);
|
package/DateUtilsContext.js
CHANGED
|
@@ -8,7 +8,6 @@ const DateUtilsProvider = (props) => {
|
|
|
8
8
|
const utils = useMemo(() => {
|
|
9
9
|
const dateUtils = new DateUtils({ locale });
|
|
10
10
|
const customUtils = {
|
|
11
|
-
// displaying methods
|
|
12
11
|
getCalendarHeaderText: (date) => {
|
|
13
12
|
return dateUtils.formatByString(date, 'MMMM YYYY');
|
|
14
13
|
},
|
package/Dialer.js
CHANGED
|
@@ -53,7 +53,6 @@ DialDelete.displayName = 'SuiDialDelete';
|
|
|
53
53
|
var DialPadButton$1 = {"sui-dial-pad-button-root":"sui-dial-pad-button-root","sui-icon":"sui-icon","sui-dial-pad-button-medium":"sui-dial-pad-button-medium","sui-dial-pad-button-large":"sui-dial-pad-button-large","sui-dial-pad-button-label-container":"sui-dial-pad-button-label-container"};
|
|
54
54
|
|
|
55
55
|
const emptyFunction = () => {
|
|
56
|
-
//
|
|
57
56
|
};
|
|
58
57
|
const DialPadButton = (props) => {
|
|
59
58
|
const { value, classes, longPressValue, longPressDelay = 1000, onKeyEffect = emptyFunction, className, iconSize = 'medium', size = 'xxlarge', label, ...rest } = props;
|
|
@@ -98,14 +97,8 @@ const ACCEPTABLE_KEYS = [
|
|
|
98
97
|
DIALER_PAD_PLUS,
|
|
99
98
|
];
|
|
100
99
|
|
|
101
|
-
/**
|
|
102
|
-
* Provide you can get event apply on trigger events area
|
|
103
|
-
* @param options onKeyDown, onKeyUp that you also want apply on target
|
|
104
|
-
* @returns onKeyDown, onKeyUp, control
|
|
105
|
-
*/
|
|
106
100
|
const useDialKeyboard = ({ onKeyDown: onKeyDownArg, onKeyUp: onKeyUpArg, } = {}) => {
|
|
107
101
|
const control = useRef(null);
|
|
108
|
-
// we need `onKeyup` & `onKeydown` to get called in same amount, but also make sure of the performance.
|
|
109
102
|
const keyBufferRef = useRef([]);
|
|
110
103
|
const onKeyDown = useEventCallback((e) => {
|
|
111
104
|
onKeyDownArg?.(e);
|
|
@@ -133,12 +126,6 @@ const useDialKeyboard = ({ onKeyDown: onKeyDownArg, onKeyUp: onKeyUpArg, } = {})
|
|
|
133
126
|
return { onKeyDown, onKeyUp, control };
|
|
134
127
|
};
|
|
135
128
|
|
|
136
|
-
/**
|
|
137
|
-
* Custom hook that handles playing audio for key presses in a dial pad.
|
|
138
|
-
*
|
|
139
|
-
* @param audioOption - The audio options for configuring the hook.
|
|
140
|
-
* @returns A function that plays the audio for a given key.
|
|
141
|
-
*/
|
|
142
129
|
const useKeyAudio = ({ sounds, processor }) => {
|
|
143
130
|
const audio = useAudio();
|
|
144
131
|
const lastPlayRef = useRef();
|
|
@@ -147,9 +134,6 @@ const useKeyAudio = ({ sounds, processor }) => {
|
|
|
147
134
|
}, [audio, processor]);
|
|
148
135
|
const play = async (src) => {
|
|
149
136
|
const lastPlay = lastPlayRef.current;
|
|
150
|
-
/* https://developers.google.com/web/updates/2017/06/play-request-was-interrupted
|
|
151
|
-
* prevent play request interrupted
|
|
152
|
-
*/
|
|
153
137
|
if (lastPlay)
|
|
154
138
|
await lastPlay;
|
|
155
139
|
audio.currentTime = 0;
|
|
@@ -205,9 +189,7 @@ const DialPad = forwardRef((inProps, ref) => {
|
|
|
205
189
|
if (typeof muted !== 'undefined')
|
|
206
190
|
audio.muted = muted;
|
|
207
191
|
if (typeof audio['setSinkId'] === 'function')
|
|
208
|
-
audio['setSinkId'](
|
|
209
|
-
// when pass undefined, use '' to remove sinkId to default
|
|
210
|
-
sinkId || '');
|
|
192
|
+
audio['setSinkId'](sinkId || '');
|
|
211
193
|
}, [muted, sinkId, volume]);
|
|
212
194
|
const play = useKeyAudio({
|
|
213
195
|
sounds,
|
|
@@ -217,7 +199,6 @@ const DialPad = forwardRef((inProps, ref) => {
|
|
|
217
199
|
const key = value === DIALER_PAD_PLUS ? '0' : value;
|
|
218
200
|
const keyButtonElm = containerRef.current?.querySelector(`[${dialButtonKey}="${key}"]`);
|
|
219
201
|
if (keyButtonElm) {
|
|
220
|
-
// * to keep color when quick trigger insert key or click very quick
|
|
221
202
|
const oldTimer = keyTimerMapRef.current[key];
|
|
222
203
|
if (oldTimer)
|
|
223
204
|
clearTimeout(oldTimer);
|
|
@@ -239,7 +220,6 @@ const DialPad = forwardRef((inProps, ref) => {
|
|
|
239
220
|
handleChange(value, 'customKeyboard');
|
|
240
221
|
const toIndex = ACCEPTABLE_KEYS.findIndex((x) => x === value);
|
|
241
222
|
focusedIndexRef.current = toIndex;
|
|
242
|
-
// * mean that current focus on that dialPad, move focus to dialPad container
|
|
243
223
|
if (externalWindow &&
|
|
244
224
|
externalWindow.document.activeElement?.getAttribute(dialButtonKey) !==
|
|
245
225
|
null) {
|
|
@@ -255,7 +235,6 @@ const DialPad = forwardRef((inProps, ref) => {
|
|
|
255
235
|
useImperativeHandle(control, () => ({ handleKeyboardEffect }), [
|
|
256
236
|
handleKeyboardEffect,
|
|
257
237
|
]);
|
|
258
|
-
// * clean when unmount
|
|
259
238
|
useEffect(() => () => {
|
|
260
239
|
for (const timer of Object.values(keyTimerMapRef.current)) {
|
|
261
240
|
clearTimeout(timer);
|
|
@@ -309,18 +288,10 @@ var DialerPadSoundsMPEG = {
|
|
|
309
288
|
'*': 'data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU5LjI3LjEwMAAAAAAAAAAAAAAA//tAwAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAAAHAAAIjQBqampqampqampqampqaoODg4ODg4ODg4ODg4ODmJiYmJiYmJiYmJiYmJi8vLy8vLy8vLy8vLy8vLzn5+fn5+fn5+fn5+fn5/Pz8/Pz8/Pz8/Pz8/Pz//////////////////8AAAAATGF2YzU5LjM3AAAAAAAAAAAAAAAAJAPpAAAAAAAACI0Bco0qAAAAAAD/+8DEAAAHUDswdYeAIn6XJPc9wAABTcADPPPPPPcBqBltEADyMjLVmEZjCgvDwR8JGS9nveG/jxKAgCAIAmD/BA5wff4IAgCYPg+fggCGkAAAAACNNeb6B0JAAABFAwCgHoyVQHqxUAWMCACUxFSkzAtAwMJY9t+jDUGBMMkVozBiejUqLUNYYts2SCKjWDHtOCgkAA8yI4zGoDMtNIyGAjDIFAQkgYWAqykhi/M97U2WNpAiw0M3oKXdTfCmbySkf+N1lAUhX2iz78//jc5Ty+MQ5Vmo0/1Xn///+Hdczz7TTMZhmt2r0QQMxEelTqrwAAAB8MIAANJlMEA0ABI4wDQBzBhAgMA0CASAuCoHBg5g9GLWz4cQDn5lzDkmLQQKbRUdhuPlmGNiN4ByB4gbci4FEeBYOh7oYiE7OISkGEJTVE1MSZDaS6l+s9Lht////+o9//rQ8AABtwH9dJGURkmEhVcZFsYBiZNIcVcYE0AqmD/hJhoiYaaYSOAgmCBA7BhX6HkYd8EbGBSgXJtauddHGJEwcvjwA27yS93IhL8P7utb/9f/6/5bWcq09f////kq33FAAAWwAACXSFPMmo95TgoAx4IiYPlULDsZMJ44Ch8FCw4uSxuOAobhUEcoJRI6z6CZq6+kUk97ryAAAAANvwJc9ZIAKts8Ecpj1gyAsEk3Bg6gYmNoOgfjxT5jzBeGDqOSYuflpkTD6mAQEEaAJHJmhhosHKKFzQYVRMncOPYkSwgQP0yn+PAqaAAAAACf+GAAIzLlNQEKdkyI46pI1xM2aI3+QwUA+zD7X4Oc2CEw8RZjDFFjNfCUM4LRUzD+CaMGQIYwZxQxUIswCACkV2AQHQGBGBCRAFg4CRqc5cXZYhtubyYORz3ok2DgAnuAAJZn//j4f/EegAAAD/0ZbYxYAMFFxQuFAkxBMOijDQ4ELkBu7eYIoC8GGSkr5tnJmkYbKEwmBf/7UMT1gUzcoxu96oAhcowjPa/tFCiCBkSTdEZhaHVGC5AVJgIQE4YG8EDmAbAXpgJIAsVB0il8pFAgJrMWfNTAaVCroACEPK0iyZhRC7IGDTIbQBbpyFp4g1tujaEpy3rEMSZyKsvuWP+val8xet+2Nv34xvU8eirp2t5Ya////3/f/////nzFT/3qxhhrD+1GjrH9aKrks7qOK9Pt+xOT76eVAAAAKPesAAw0R2jBmIPMCgBgwvQ5jHKHzMB88siNEMF4O8mAPMGYQcxey/j/+0DE8QBHLD8zzHMooT+Ho32fbRXP6uHPMRfczORGDNuOWO3PHg2EyczI+DmMHIAcwcAhDEJBQHgPBAMcKILAakaaYDHHhSyACfOIAQGHOaBsCEY0DAcu4pfAWLY4OAFl0WBkkGNAkVxwIERHvyocgJX6FyTAMLRzzNNLZEIwNCflBOg486toyUvdoqMrCuluVVoU4q6ntGAfKTYbSFIaNKLqNmD6iqstJfrmkz7NPZWmzKns1P/7cMT8gE3UixnteOnq7Zzh9b/lHNmU3Rg+NTdIeSDYbEpINhoZSS1KWxLRTtiXksbIr30NVld9tVSkAAAALu9MNY1xBAqdRYNQM1KCHWAIWIHkhgbMmYf9m7cFmfBLcRtARCJSdLWoNlk8IVzKJsMkS5kVHAkFRonJS00IfgTEMDSFA1qqEmO35wVYuOxcinJNykpMCHiEAWif/wAAPzlgrWG2IADSlUANmCBjHUKAoLR9pF26s4wC/M1bwiVt9ZCBCteQCMMay1D6Sl2Cs7GcAWUNvbJ5fKJOcISw5G1mkP09QdVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUz/+4DE+YBeXQ0T72UxqWuR472cJH1BTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7EMT+AMd4dR3jZGXoToUgIAfglVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//sQxNYDwAAB/gAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVU=',
|
|
310
289
|
};
|
|
311
290
|
|
|
312
|
-
// ! alway new Regex for regex will have index issue
|
|
313
|
-
// https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/RegExp
|
|
314
|
-
/**
|
|
315
|
-
* return regex with only allow dialPad value `1234567890*+#-`
|
|
316
|
-
*/
|
|
317
291
|
function getDialPadValueOnlyRegex() {
|
|
318
292
|
return /[1234567890*+#]+/g;
|
|
319
293
|
}
|
|
320
294
|
|
|
321
|
-
/**
|
|
322
|
-
* bind with ref, let input can always focus at end of latest character
|
|
323
|
-
*/
|
|
324
295
|
const useFixedEndSelection = () => {
|
|
325
296
|
const ref = useRef(null);
|
|
326
297
|
const keypadModeFixedAtLatest = useEventCallback(() => {
|
|
@@ -361,9 +332,7 @@ const useFixedEndSelection = () => {
|
|
|
361
332
|
|
|
362
333
|
const DialTextField = forwardRef((inProps, ref) => {
|
|
363
334
|
const props = useThemeProps({ props: inProps, name: 'DialTextField' });
|
|
364
|
-
const { value, onChange, onEmit, onKeyDown, onKeyUp, inputRef: inputRefProp, inputProps: inputPropsProp, keypadMode, onlyAllowKeypadValue = keypadMode, externalWindow = window,
|
|
365
|
-
// textVariant = 'headline1',
|
|
366
|
-
...rest } = props;
|
|
335
|
+
const { value, onChange, onEmit, onKeyDown, onKeyUp, inputRef: inputRefProp, inputProps: inputPropsProp, keypadMode, onlyAllowKeypadValue = keypadMode, externalWindow = window, ...rest } = props;
|
|
367
336
|
const dialerContext = useDialerContext();
|
|
368
337
|
const playAudio = (key) => {
|
|
369
338
|
dialerContext.dialPadActionRef?.current?.playAudio(key);
|
|
@@ -378,25 +347,16 @@ const DialTextField = forwardRef((inProps, ref) => {
|
|
|
378
347
|
const elm = inputRef.current;
|
|
379
348
|
const isInputFocus = isFocus ?? externalWindow.document.activeElement === elm;
|
|
380
349
|
if (reason !== 'click' && !isInputFocus) {
|
|
381
|
-
// ! both keydown and touch, only when focus need re-focus
|
|
382
350
|
isNotTriggerRefocusRef.current = true;
|
|
383
351
|
}
|
|
384
352
|
});
|
|
385
|
-
/**
|
|
386
|
-
* outside clear via this method, with check current input state
|
|
387
|
-
*/
|
|
388
353
|
useImperativeHandle(dialerContext.onClearRef, () => (e, reason) => {
|
|
389
|
-
// * when clear from keyboard,
|
|
390
|
-
// * must need re-focus, so not check,
|
|
391
354
|
if (reason !== 'keyboard') {
|
|
392
355
|
checkNotReFocus(reason);
|
|
393
356
|
}
|
|
394
357
|
scrollToPositionRef.current = 0;
|
|
395
358
|
onChange?.('');
|
|
396
359
|
}, [checkNotReFocus, onChange]);
|
|
397
|
-
/**
|
|
398
|
-
* outside delete value via this method, with check current input state
|
|
399
|
-
*/
|
|
400
360
|
useImperativeHandle(dialerContext.onDeleteRef, () => (e, reason) => {
|
|
401
361
|
const elm = inputRef.current;
|
|
402
362
|
if (elm && value?.length) {
|
|
@@ -420,8 +380,6 @@ const DialTextField = forwardRef((inProps, ref) => {
|
|
|
420
380
|
toValue = value.slice(0, -1);
|
|
421
381
|
}
|
|
422
382
|
if (toValue !== undefined) {
|
|
423
|
-
// * when delete from keyboard and value to be empty,
|
|
424
|
-
// * must need re-focus, so not check,
|
|
425
383
|
if (!(reason === 'keyboard' && toValue === '')) {
|
|
426
384
|
checkNotReFocus(reason);
|
|
427
385
|
}
|
|
@@ -430,16 +388,12 @@ const DialTextField = forwardRef((inProps, ref) => {
|
|
|
430
388
|
}
|
|
431
389
|
}
|
|
432
390
|
}, [checkNotReFocus, externalWindow, inputRef, onChange, value]);
|
|
433
|
-
/**
|
|
434
|
-
* outside change value via this method, with check current input state
|
|
435
|
-
*/
|
|
436
391
|
useImperativeHandle(dialerContext.onInsertRef, () => (addValue, reason) => {
|
|
437
392
|
const elm = inputRef.current;
|
|
438
393
|
if (elm) {
|
|
439
394
|
const isFocus = externalWindow.document.activeElement === elm;
|
|
440
395
|
let toPosition;
|
|
441
396
|
let toValue;
|
|
442
|
-
// * when keypadMode also add value at latest
|
|
443
397
|
if (!isFocus || keypadMode) {
|
|
444
398
|
toValue = value + addValue;
|
|
445
399
|
toPosition = toValue.length;
|
|
@@ -499,7 +453,6 @@ const DialTextField = forwardRef((inProps, ref) => {
|
|
|
499
453
|
const { sleep } = useSleep();
|
|
500
454
|
const handleChange = useEventCallback((e) => {
|
|
501
455
|
const currValue = e.target.value;
|
|
502
|
-
// * handle copy paste
|
|
503
456
|
if (onlyAllowKeypadValue) {
|
|
504
457
|
const filterValue = (currValue.match(getDialPadValueOnlyRegex()) || []).join('');
|
|
505
458
|
if (filterValue === value)
|
|
@@ -551,7 +504,6 @@ const DialTextField = forwardRef((inProps, ref) => {
|
|
|
551
504
|
onKeyDown: events.onKeyDown,
|
|
552
505
|
onKeyUp: events.onKeyUp,
|
|
553
506
|
maxLength,
|
|
554
|
-
// in dialer not need autoComplete
|
|
555
507
|
autoComplete: 'off',
|
|
556
508
|
}, inputPropsProp), [
|
|
557
509
|
keypadMode,
|
package/Dialog.js
CHANGED
|
@@ -2,9 +2,9 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
2
2
|
import { forwardRef, useMemo } from 'react';
|
|
3
3
|
import { motion } from 'framer-motion';
|
|
4
4
|
import kebabCase from 'lodash/kebabCase';
|
|
5
|
-
import {
|
|
5
|
+
import { useEventCallback, useClasses } from '@ringcentral/spring-base';
|
|
6
6
|
import { Xsm } from '@ringcentral/spring-icon';
|
|
7
|
-
import { useThemeProps, motionTransition } from '@ringcentral/spring-theme';
|
|
7
|
+
import { useThemeProps, useClassesWithMode, motionTransition } from '@ringcentral/spring-theme';
|
|
8
8
|
import './chunks/Icon.js';
|
|
9
9
|
import { u as usePrefersReducedMotion } from './chunks/usePrefersReducedMotion.js';
|
|
10
10
|
import { g as getSlideIn } from './chunks/getSlideIn.js';
|
|
@@ -22,12 +22,12 @@ import './chunks/PopperPaper.js';
|
|
|
22
22
|
import './chunks/useFocusTrapStack.js';
|
|
23
23
|
import './chunks/Backdrop.js';
|
|
24
24
|
|
|
25
|
-
var Dialog$1 = {"sui-dialog-body":"sui-dialog-body","sui-dialog-root":"sui-dialog-root","sui-dialog-small":"sui-dialog-small","sui-dialog-medium":"sui-dialog-medium","sui-dialog-large":"sui-dialog-large","sui-dialog-title-root":"sui-dialog-title-root","sui-dialog-content-root":"sui-dialog-content-root","sui-dialog-actions-root":"sui-dialog-actions-root","sui-dialog-right":"sui-dialog-right","sui-dialog-right-close-button":"sui-dialog-right-close-button","sui-dialog-left":"sui-dialog-left","sui-dialog-left-close-button":"sui-dialog-left-close-button","sui-dialog-full-height":"sui-dialog-full-height","sui-dialog-close-button":"sui-dialog-close-button","sui-dialog-full-screen":"sui-dialog-full-screen"};
|
|
25
|
+
var Dialog$1 = {"sui-dialog-body":"sui-dialog-body","sui-dialog-root":"sui-dialog-root","sui-dialog-small":"sui-dialog-small","sui-dialog-medium":"sui-dialog-medium","sui-dialog-large":"sui-dialog-large","sui-dialog-title-root":"sui-dialog-title-root","sui-dialog-content-root":"sui-dialog-content-root","sui-dialog-actions-root":"sui-dialog-actions-root","sui-dialog-right":"sui-dialog-right","sui-dialog-right-close-button":"sui-dialog-right-close-button","sui-dialog-left":"sui-dialog-left","sui-dialog-left-close-button":"sui-dialog-left-close-button","sui-dialog-full-height":"sui-dialog-full-height","sui-dialog-close-button":"sui-dialog-close-button","sui-dialog-full-screen":"sui-dialog-full-screen","sui-compact":"sui-compact"};
|
|
26
26
|
|
|
27
27
|
const Dialog = forwardRef((inProps, ref) => {
|
|
28
28
|
const props = useThemeProps({ props: inProps, name: 'Dialog' });
|
|
29
29
|
const { bodyProps, classes, className, children, size = 'medium', placement = 'right', open, onClose, ...rest } = props;
|
|
30
|
-
const cls =
|
|
30
|
+
const cls = useClassesWithMode('dialog', classes, className);
|
|
31
31
|
const toSize = useMemo(() => kebabCase(size), [size]);
|
|
32
32
|
const isFullHeight = size === 'fullHeight';
|
|
33
33
|
const slideInProps = getSlideIn({
|
package/Dropdown.js
CHANGED
|
@@ -53,11 +53,8 @@ const Dropdown = forwardRef((inProps, ref) => {
|
|
|
53
53
|
}, []);
|
|
54
54
|
const cls = useClasses('dropdown', classes, className);
|
|
55
55
|
const handleOpen = useEventCallback((isOpen) => {
|
|
56
|
-
// prevent trigger onOpenChange when open state is not change
|
|
57
56
|
if (open !== isOpen) {
|
|
58
|
-
// for uncontrolled mode
|
|
59
57
|
setOpen(isOpen);
|
|
60
|
-
// for controlled mode
|
|
61
58
|
onOpenChange?.(isOpen);
|
|
62
59
|
}
|
|
63
60
|
});
|
|
@@ -71,9 +68,7 @@ const Dropdown = forwardRef((inProps, ref) => {
|
|
|
71
68
|
state: 'value',
|
|
72
69
|
});
|
|
73
70
|
const handleMenuListChange = useEventCallback((newValue) => {
|
|
74
|
-
// for uncontrolled mode
|
|
75
71
|
setValue(newValue);
|
|
76
|
-
// for controlled mode
|
|
77
72
|
onChangeProp?.(newValue);
|
|
78
73
|
handleOpen(false);
|
|
79
74
|
});
|
|
@@ -89,7 +84,6 @@ const Dropdown = forwardRef((inProps, ref) => {
|
|
|
89
84
|
},
|
|
90
85
|
onKeyDown: (e) => {
|
|
91
86
|
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
|
92
|
-
// prevent scroll
|
|
93
87
|
e.preventDefault();
|
|
94
88
|
handleOpen(true);
|
|
95
89
|
}
|
|
@@ -98,7 +92,6 @@ const Dropdown = forwardRef((inProps, ref) => {
|
|
|
98
92
|
const { focusVisible, focusVisibleRef, focusVisibleHandlers } = useFocusVisible(buttonProps);
|
|
99
93
|
const handleButtonRef = useForkRef(buttonRef, focusVisibleRef);
|
|
100
94
|
useEffect(() => {
|
|
101
|
-
// close menu when disabled
|
|
102
95
|
if (disabled) {
|
|
103
96
|
handleOpen(false);
|
|
104
97
|
}
|
package/FocusTrap.js
CHANGED
|
@@ -4,38 +4,6 @@ import { useImperativeHandle } from 'react';
|
|
|
4
4
|
import { u as useFocusTrapStack } from './chunks/useFocusTrapStack.js';
|
|
5
5
|
import '@ringcentral/spring-base';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Utility component that locks focus inside the component.
|
|
9
|
-
*
|
|
10
|
-
* @deprecated This component is deprecated. Use `useFocusTrapStack` hook directly with MUI's FocusTrap instead.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```tsx
|
|
14
|
-
* import { FocusTrap } from '@mui/base';
|
|
15
|
-
* import { useFocusTrapStack } from '@ringcentral/spring-ui';
|
|
16
|
-
*
|
|
17
|
-
* function MyModal({ open, children }) {
|
|
18
|
-
* // Call useFocusTrapStack where the `open` prop changes first (typically in Modal/Dialog)
|
|
19
|
-
* // This prevents race conditions between stack registration and autofocus behavior
|
|
20
|
-
* const { isEnabled } = useFocusTrapStack({ open });
|
|
21
|
-
*
|
|
22
|
-
* return open ? (
|
|
23
|
-
* <Portal>
|
|
24
|
-
* <div className="modal-backdrop">
|
|
25
|
-
* <FocusTrap
|
|
26
|
-
* open={open}
|
|
27
|
-
* isEnabled={isEnabled}
|
|
28
|
-
* >
|
|
29
|
-
* <div className="modal-content" tabIndex={-1}>
|
|
30
|
-
* {children}
|
|
31
|
-
* </div>
|
|
32
|
-
* </FocusTrap>
|
|
33
|
-
* </div>
|
|
34
|
-
* </Portal>
|
|
35
|
-
* ) : null;
|
|
36
|
-
* }
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
7
|
const FocusTrap = (props) => {
|
|
40
8
|
const { open, children, action, ...rest } = props;
|
|
41
9
|
const { isEnabled } = useFocusTrapStack({ open });
|
package/InlineEditable.js
CHANGED
|
@@ -55,7 +55,6 @@ const InlineEditable = forwardRef((inProps, ref) => {
|
|
|
55
55
|
const handleKeyDown = (e) => {
|
|
56
56
|
onKeyDown?.(e);
|
|
57
57
|
const { key, shiftKey } = e;
|
|
58
|
-
// Enter + Shift in textarea creates a new line
|
|
59
58
|
if (!isEditing || (multiline && key === 'Enter' && shiftKey)) {
|
|
60
59
|
return;
|
|
61
60
|
}
|
|
@@ -80,12 +79,9 @@ const InlineEditable = forwardRef((inProps, ref) => {
|
|
|
80
79
|
const { document } = useWindowContext();
|
|
81
80
|
useEffect(() => {
|
|
82
81
|
if (previousIsEditing && !isEditing && inputRef.current) {
|
|
83
|
-
// * enter/esc should blur the input (tab does this automatically)
|
|
84
82
|
document?.activeElement === inputRef.current && inputRef.current.blur();
|
|
85
83
|
}
|
|
86
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
87
84
|
}, [isEditing, previousIsEditing]);
|
|
88
|
-
// close tooltip temporarily during editing
|
|
89
85
|
const tooltipOpenProps = useTooltipForceHide(isEditing);
|
|
90
86
|
const slot = multiline ? 'textarea' : 'input';
|
|
91
87
|
const editableContent = (jsx(Component, { className: cls(slot, `${variant}-${slot}`, { disabled }), value: value, autoComplete: "off", placeholder: placeholder, ref: handleRef, onFocus: handleFocus, onKeyDown: handleKeyDown, onBlur: handleBlur, disabled: disabled, "aria-label": TooltipProps?.['title'], ...rest, children: children }));
|
package/Link.js
CHANGED
|
@@ -3,7 +3,7 @@ import { forwardRef } from 'react';
|
|
|
3
3
|
import { useClasses, useFocusVisible, useForkRef } from '@ringcentral/spring-base';
|
|
4
4
|
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
5
5
|
|
|
6
|
-
var Link$1 = {"sui-link-root":"sui-link-root","sui-focus-visible":"sui-focus-visible","sui-link-none":"sui-link-none","sui-link-hover":"sui-link-hover","sui-link-always":"sui-link-always","sui-link":"sui-link","sui-link-primary":"sui-link-primary","sui-link-secondary":"sui-link-secondary"};
|
|
6
|
+
var Link$1 = {"sui-link-root":"sui-link-root","sui-focus-visible":"sui-focus-visible","sui-link-none":"sui-link-none","sui-link-hover":"sui-link-hover","sui-link-always":"sui-link-always","sui-link":"sui-link","sui-link-primary":"sui-link-primary","sui-link-secondary":"sui-link-secondary","sui-link-inverted":"sui-link-inverted"};
|
|
7
7
|
|
|
8
8
|
const Link = forwardRef((inProps, ref) => {
|
|
9
9
|
const props = useThemeProps({ props: inProps, name: 'Link' });
|
package/ListItem.js
CHANGED
|
@@ -17,6 +17,6 @@ import './chunks/usePrefersReducedMotion.js';
|
|
|
17
17
|
import './chunks/SlideIn.js';
|
|
18
18
|
import './chunks/getSlideIn.js';
|
|
19
19
|
|
|
20
|
-
var ListItem = {"sui-list-item-root":"sui-list-item-root","sui-list-item-content":"sui-list-item-content","sui-list-item-text":"sui-list-item-text","sui-list-item-divider":"sui-list-item-divider","sui-list-item-container":"sui-list-item-container","sui-list-item-hover-actions":"sui-list-item-hover-actions","sui-list-item-small":"sui-list-item-small","sui-list-item-large":"sui-list-item-large","sui-list-item-auto":"sui-list-item-auto","sui-focus-visible":"sui-focus-visible","sui-focused":"sui-focused","sui-list-item-hoverable":"sui-list-item-hoverable","sui-focus-visible-within":"sui-focus-visible-within","sui-list-item-clickable":"sui-list-item-clickable","sui-selected":"sui-selected","sui-list-item-highlighted":"sui-list-item-highlighted","sui-dragged":"sui-dragged","sui-active":"sui-active"};
|
|
20
|
+
var ListItem = {"sui-list-item-root":"sui-list-item-root","sui-list-item-content":"sui-list-item-content","sui-list-item-text":"sui-list-item-text","sui-list-item-divider":"sui-list-item-divider","sui-list-item-container":"sui-list-item-container","sui-list-item-hover-actions":"sui-list-item-hover-actions","sui-list-item-small":"sui-list-item-small","sui-list-item-large":"sui-list-item-large","sui-list-item-auto":"sui-list-item-auto","sui-focus-visible":"sui-focus-visible","sui-focused":"sui-focused","sui-list-item-hoverable":"sui-list-item-hoverable","sui-focus-visible-within":"sui-focus-visible-within","sui-list-item-clickable":"sui-list-item-clickable","sui-selected":"sui-selected","sui-list-item-highlighted":"sui-list-item-highlighted","sui-dragged":"sui-dragged","sui-active":"sui-active","sui-compact":"sui-compact"};
|
|
21
21
|
|
|
22
22
|
export { ListItem as listItemStyle };
|
package/ListNavigation.js
CHANGED
|
@@ -5,7 +5,6 @@ import { tabbable } from 'tabbable';
|
|
|
5
5
|
import 'react/jsx-runtime';
|
|
6
6
|
import '@ringcentral/spring-base';
|
|
7
7
|
|
|
8
|
-
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
9
8
|
const useItemNavigation = () => {
|
|
10
9
|
const itemRef = useRef(null);
|
|
11
10
|
const navContextValue = useListNavigationContext();
|
|
@@ -13,10 +12,7 @@ const useItemNavigation = () => {
|
|
|
13
12
|
return {
|
|
14
13
|
keyboardNavHandlers: {
|
|
15
14
|
onKeyDown: (e) => {
|
|
16
|
-
// There some problems if `itemRef.current` is null.
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
18
15
|
const itemEl = itemRef.current;
|
|
19
|
-
// All tabbable element in item. No include item self.
|
|
20
16
|
const allTabbable = tabbable(itemEl);
|
|
21
17
|
const { key, shiftKey, target, currentTarget } = e;
|
|
22
18
|
if (key === 'Tab') {
|
|
@@ -25,9 +21,7 @@ const useItemNavigation = () => {
|
|
|
25
21
|
navContextValue.onShiftTab();
|
|
26
22
|
}
|
|
27
23
|
else if (allTabbable.at(0) === target) {
|
|
28
|
-
// prevent default focus logic
|
|
29
24
|
e.preventDefault();
|
|
30
|
-
// focus item manual, because tabindex of item is -1
|
|
31
25
|
itemEl.focus();
|
|
32
26
|
}
|
|
33
27
|
}
|
package/Menu.js
CHANGED
|
@@ -18,6 +18,6 @@ import './chunks/Backdrop.js';
|
|
|
18
18
|
import './Popper.js';
|
|
19
19
|
import './chunks/PopperPaper.js';
|
|
20
20
|
|
|
21
|
-
var Menu = {"sui-menu-paper":"sui-menu-paper"};
|
|
21
|
+
var Menu = {"sui-menu-paper":"sui-menu-paper","sui-menu-root":"sui-menu-root","sui-compact":"sui-compact"};
|
|
22
22
|
|
|
23
23
|
export { Menu as menuStyle };
|
package/MenuDivider.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { M as MenuDivider } from './chunks/MenuDivider.js';
|
|
2
2
|
import 'react/jsx-runtime';
|
|
3
3
|
import 'react';
|
|
4
|
-
import '@ringcentral/spring-base';
|
|
5
4
|
import '@ringcentral/spring-theme';
|
|
6
5
|
import './chunks/Divider.js';
|
|
6
|
+
import '@ringcentral/spring-base';
|
|
7
7
|
|
|
8
|
-
var MenuDivider = {"sui-menu-divider-root":"sui-menu-divider-root"};
|
|
8
|
+
var MenuDivider = {"sui-menu-divider-root":"sui-menu-divider-root","sui-compact":"sui-compact"};
|
|
9
9
|
|
|
10
10
|
export { MenuDivider as menuDividerStyle };
|
package/MenuFooter.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
3
|
+
import { useThemeProps, useClassesWithMode } from '@ringcentral/spring-theme';
|
|
5
4
|
import { M as MenuDivider } from './chunks/MenuDivider.js';
|
|
6
5
|
import './chunks/Divider.js';
|
|
6
|
+
import '@ringcentral/spring-base';
|
|
7
7
|
|
|
8
|
-
var MenuFooter$1 = {"sui-menu-footer-root":"sui-menu-footer-root"};
|
|
8
|
+
var MenuFooter$1 = {"sui-menu-footer-root":"sui-menu-footer-root","sui-compact":"sui-compact"};
|
|
9
9
|
|
|
10
10
|
const MenuFooter = forwardRef((inProps, ref) => {
|
|
11
11
|
const props = useThemeProps({ props: inProps, name: 'MenuFooter' });
|
|
12
12
|
const { classes, className, children, divider = true, ...rest } = props;
|
|
13
|
-
const cls =
|
|
13
|
+
const cls = useClassesWithMode('menu-footer', classes, className);
|
|
14
14
|
return (jsxs(Fragment, { children: [divider && jsx(MenuDivider, {}), jsx("div", { className: cls('root'), ...rest, ref: ref, children: children })] }));
|
|
15
15
|
});
|
|
16
16
|
MenuFooter.displayName = 'SuiMenuFooter';
|
package/MenuHeader.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
3
|
+
import { useThemeProps, useClassesWithMode } from '@ringcentral/spring-theme';
|
|
5
4
|
import { M as MenuDivider } from './chunks/MenuDivider.js';
|
|
6
5
|
import './chunks/Divider.js';
|
|
6
|
+
import '@ringcentral/spring-base';
|
|
7
7
|
|
|
8
|
-
var MenuHeader$1 = {"sui-menu-header-root":"sui-menu-header-root","sui-menu-header-title":"sui-menu-header-title","sui-menu-header-start":"sui-menu-header-start","sui-menu-header-end":"sui-menu-header-end"};
|
|
8
|
+
var MenuHeader$1 = {"sui-menu-header-root":"sui-menu-header-root","sui-menu-header-title":"sui-menu-header-title","sui-menu-header-start":"sui-menu-header-start","sui-menu-header-end":"sui-menu-header-end","sui-compact":"sui-compact"};
|
|
9
9
|
|
|
10
10
|
const MenuHeader = forwardRef((inProps, ref) => {
|
|
11
11
|
const props = useThemeProps({ props: inProps, name: 'MenuHeader' });
|
|
12
12
|
const { classes, className, children, start, end, divider = true, ...rest } = props;
|
|
13
|
-
const cls =
|
|
13
|
+
const cls = useClassesWithMode('menu-header', classes, className);
|
|
14
14
|
return (jsxs(Fragment, { children: [jsxs("div", { className: cls('root'), ...rest, ref: ref, children: [start && jsx("div", { className: cls('start'), children: start }), end && jsx("div", { className: cls('end'), children: end }), typeof children === 'string' ? (jsx("span", { className: cls('title'), title: children, children: children })) : (children)] }), divider && jsx(MenuDivider, {})] }));
|
|
15
15
|
});
|
|
16
16
|
MenuHeader.displayName = 'SuiMenuHeader';
|