@ringcentral/spring-ui 1.11.2 → 1.12.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/AccordionHeader.js +4 -2
- package/Animation.js +10 -9
- package/Autocomplete.js +5 -2
- package/BlockHeader.js +3 -1
- package/DatePicker.js +5 -3
- package/Dialer.js +36 -21
- package/Dialog.js +4 -3
- package/Dropdown.js +7 -4
- package/EmptyState.js +3 -1
- package/FormField.js +2 -0
- package/ListItemText.js +1 -0
- package/MenuHeader.js +1 -0
- package/MenuItem.js +2 -0
- package/MenuItemText.js +1 -0
- package/MenuList.js +2 -0
- package/Option.js +3 -1
- package/PickerTextField.js +2 -0
- package/Popper.js +28 -25
- package/Rating.js +2 -2
- package/Select.js +3 -0
- package/SingleFilter.js +2 -0
- package/Slider.js +3 -2
- package/SortableVirtualizedList.js +10 -10
- package/SplitButton.js +3 -0
- package/Squircle.js +2 -2
- package/StepContent.js +1 -1
- package/SubMenu.js +2 -0
- package/TableCell.js +1 -1
- package/TablePagination.js +2 -0
- package/Tabs.js +9 -5
- package/TextField.js +2 -0
- package/Textarea.js +2 -0
- package/TimePicker.js +3 -1
- package/TrayMenu.js +2 -0
- package/VirtualizedList.js +3 -2
- package/chunks/Alert.js +2 -2
- package/chunks/Badge.js +1 -1
- package/chunks/Drawer.js +3 -2
- package/chunks/MenuItemText.js +1 -0
- package/chunks/MenuList.js +2 -1
- package/chunks/Modal.js +2 -3
- package/chunks/Popover.js +13 -5
- package/chunks/Select.js +26 -21
- package/chunks/SlideIn.js +2 -1
- package/chunks/Squircle.js +2 -2
- package/chunks/VirtualizedMenu.js +3 -5
- package/chunks/composeEventHandlers.js +10 -0
- package/chunks/getSlideIn.js +2 -2
- package/chunks/useFocusTrapStack.js +3 -1
- package/chunks/useHelperTextId.js +4 -2
- package/chunks/useMenuItemSelect.js +34 -25
- package/index.css +205 -172
- package/index.js +3 -1
- package/internal/utils/index.d.ts +1 -0
- package/internal/utils/setRef.d.ts +1 -0
- package/package.json +8 -8
- package/src/Alert/Alert.type.d.ts +2 -1
- package/src/Animation/components/Fade/Fade.d.ts +4 -2
- package/src/Animation/components/Grow/Grow.d.ts +4 -2
- package/src/Animation/components/ShowHideEye/ShowHideEye.d.ts +1 -1
- package/src/Animation/components/SlideIn/SlideIn.d.ts +4 -2
- package/src/Animation/components/SlideIn/getSlideIn.d.ts +1 -1
- package/src/Autocomplete/SuggestionList/SuggestionList.d.ts +1 -1
- package/src/Autocomplete/useAutocomplete.d.ts +18 -18
- package/src/Autocomplete/useAutocompleteTag.d.ts +18 -18
- package/src/Badge/Badge.d.ts +2 -1
- package/src/DatePicker/utils/DatePickerAriaLabelUtils.d.ts +2 -1
- package/src/Dialer/DialDelete/DialDelete.d.ts +2 -2
- package/src/Dialer/DialPad/DialPad.d.ts +2 -2
- package/src/Dialer/Dialer.d.ts +4 -2
- package/src/Dropdown/Dropdown.type.d.ts +2 -2
- package/src/InlineEditable/InlineEditable.type.d.ts +2 -1
- package/src/ListNavigation/useListNavigation.d.ts +3 -3
- package/src/MenuActions/MenuActions.d.ts +2 -2
- package/src/MenuItem/useMenuItem.d.ts +1 -1
- package/src/MenuItem/useVirtualizedMenuItem.d.ts +1 -1
- package/src/MenuList/MenuList.type.d.ts +1 -1
- package/src/NestedMenuContext/MenuOverlayGroupContext.d.ts +2 -2
- package/src/Popper/Popper.type.d.ts +10 -7
- package/src/Rating/utils.d.ts +3 -2
- package/src/Select/Select.type.d.ts +1 -1
- package/src/Slider/Slider.d.ts +2 -2
- package/src/Slider/SliderThumb.d.ts +2 -1
- package/src/Squircle/Squircle.d.ts +1 -1
- package/src/StatusIndicator/StatusIndicator.d.ts +2 -1
- package/src/SubMenu/PopperMenu.type.d.ts +4 -1
|
@@ -3,17 +3,19 @@ import { forwardRef } from 'react';
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { useClasses } from '@ringcentral/spring-base';
|
|
5
5
|
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
6
|
+
import { h as hasContent } from './hasContent.js';
|
|
7
|
+
import '@mui/utils';
|
|
6
8
|
|
|
7
9
|
const FormField = forwardRef((inProps, ref) => {
|
|
8
10
|
const props = useThemeProps({ props: inProps, name: 'FormField' });
|
|
9
11
|
const { classes, className, children, htmlFor, label, labelProps, helperText, required, disabled, error, variant = 'standard', size = 'xlarge', contentRef, contentProps, focused, FormHelperTextProps, ...rest } = props;
|
|
10
12
|
const cls = useClasses('form-field', classes, className);
|
|
11
|
-
return (jsxs("div", { ...rest, ref: ref, className: cls('root', variant, { disabled, error, focused }), "aria-disabled": disabled, children: [label && (jsxs("label", { htmlFor: htmlFor, ...labelProps, className: clsx(cls('label', `${variant}-label`, error && 'error-label'), labelProps?.className), children: [label, required ? ' *' : ''] })), jsxs("div", { className: cls('container', error && 'error-container'), children: [jsx("div", { className: cls('content', size, `${size}-content`, `${variant}-${size}`, `${variant}-content`, error && 'error-content', error && `error-${variant}-content`), ref: contentRef, ...contentProps, children: children }), jsx("div", { className: cls('focus-effect', `${variant}-focus-effect`, error && 'error-focus-effect') })] }), helperText && (jsx("div", { ...FormHelperTextProps, className: clsx(cls('helper-text', error && 'error-helper-text'), FormHelperTextProps?.className), children: helperText }))] }));
|
|
13
|
+
return (jsxs("div", { ...rest, ref: ref, className: cls('root', variant, { disabled, error, focused }), "aria-disabled": disabled, children: [hasContent(label) && (jsxs("label", { htmlFor: htmlFor, ...labelProps, className: clsx(cls('label', `${variant}-label`, error && 'error-label'), labelProps?.className), children: [label, required ? ' *' : ''] })), jsxs("div", { className: cls('container', error && 'error-container'), children: [jsx("div", { className: cls('content', size, `${size}-content`, `${variant}-${size}`, `${variant}-content`, error && 'error-content', error && `error-${variant}-content`), ref: contentRef, ...contentProps, children: children }), jsx("div", { className: cls('focus-effect', `${variant}-focus-effect`, error && 'error-focus-effect') })] }), hasContent(helperText) && (jsx("div", { ...FormHelperTextProps, className: clsx(cls('helper-text', error && 'error-helper-text'), FormHelperTextProps?.className), children: helperText }))] }));
|
|
12
14
|
});
|
|
13
15
|
FormField.displayName = 'SuiFormField';
|
|
14
16
|
|
|
15
17
|
const useHelperTextId = ({ helperText, id, FormHelperTextProps, }) => {
|
|
16
|
-
if (!helperText) {
|
|
18
|
+
if (!hasContent(helperText)) {
|
|
17
19
|
return undefined;
|
|
18
20
|
}
|
|
19
21
|
return FormHelperTextProps?.id || `${id}-helper-text`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { createContext, useContext, forwardRef, useRef, useLayoutEffect, useCallback, useMemo } from 'react';
|
|
3
|
-
import { useFocusVisible, useActive, useForkRef, useId, useHover, useEventCallback } from '@ringcentral/spring-base';
|
|
3
|
+
import { useFocusVisible, useActive, useForkRef, combineProps, useId, useHover, useEventCallback } from '@ringcentral/spring-base';
|
|
4
4
|
import { CheckBoldMd } from '@ringcentral/spring-icon';
|
|
5
5
|
import { useThemeProps, useClassesWithMode } from '@ringcentral/spring-theme';
|
|
6
6
|
import { I as Icon } from './Icon.js';
|
|
@@ -8,6 +8,8 @@ import { u as useAnimationFrame } from './useAnimationFrame.js';
|
|
|
8
8
|
import './useNestedParentMenu.js';
|
|
9
9
|
import { u as useNestedMenuItem } from './useNestedMenuItem.js';
|
|
10
10
|
import { useVirtualizedItemPropsContext } from '../VirtualizedList.js';
|
|
11
|
+
import { c as composeEventHandlers } from './composeEventHandlers.js';
|
|
12
|
+
import { unstable_setRef } from '@mui/utils';
|
|
11
13
|
import { useItemNavigation } from '../ListNavigation.js';
|
|
12
14
|
import { u as useMenuContext } from './Menu.js';
|
|
13
15
|
|
|
@@ -21,15 +23,6 @@ const SubMenuTriggerNestedIdContext = createContext(null);
|
|
|
21
23
|
const MenuItemSelectContext = createContext(null);
|
|
22
24
|
const useMenuItemSelectContext = () => useContext(MenuItemSelectContext);
|
|
23
25
|
|
|
24
|
-
const composeEventHandlers = (externalEventHandler, internalEventHandler, options = {}) => (event, ...args) => {
|
|
25
|
-
const { checkForDefaultPrevented = true } = options;
|
|
26
|
-
externalEventHandler?.(event, ...args);
|
|
27
|
-
if (checkForDefaultPrevented && event.defaultPrevented) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
internalEventHandler?.(event, ...args);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
26
|
const useMenuItem = (props) => {
|
|
34
27
|
const { onBlur, onFocus, onKeyDown, onKeyUp, onClick, ref, disabled, autoClose, } = props;
|
|
35
28
|
const { keyboardNavHandlers, itemRef } = useItemNavigation() ?? {};
|
|
@@ -60,15 +53,20 @@ const useMenuItem = (props) => {
|
|
|
60
53
|
onClick: handleClick,
|
|
61
54
|
});
|
|
62
55
|
const handleItemRef = useForkRef(ref, focusVisibleRef, itemRef);
|
|
63
|
-
const getRootProps = (otherProps) => {
|
|
56
|
+
const getRootProps = (otherProps = {}) => {
|
|
57
|
+
const { ref: otherRef, ...restOtherProps } = otherProps;
|
|
64
58
|
return {
|
|
65
59
|
role: 'menuitem',
|
|
66
60
|
tabIndex: '-1',
|
|
67
|
-
disabled,
|
|
68
|
-
...
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
61
|
+
...(disabled ? { 'aria-disabled': true } : null),
|
|
62
|
+
...combineProps(restOtherProps, {
|
|
63
|
+
...focusVisibleHandlers,
|
|
64
|
+
...activeHandlers,
|
|
65
|
+
}),
|
|
66
|
+
ref: (instance) => {
|
|
67
|
+
unstable_setRef(otherRef, instance);
|
|
68
|
+
unstable_setRef(handleItemRef, instance);
|
|
69
|
+
},
|
|
72
70
|
};
|
|
73
71
|
};
|
|
74
72
|
return { getRootProps, focusVisible, active };
|
|
@@ -105,15 +103,21 @@ const useVirtualizedMenuItem = (props) => {
|
|
|
105
103
|
onClick: handleClick,
|
|
106
104
|
});
|
|
107
105
|
const handleItemRef = useForkRef(ref, focusVisibleRef, itemRef);
|
|
108
|
-
const getRootProps = (otherProps) => {
|
|
106
|
+
const getRootProps = (otherProps = {}) => {
|
|
107
|
+
const { ref: otherRef, ...restOtherProps } = otherProps;
|
|
109
108
|
return {
|
|
110
109
|
role: 'menuitem',
|
|
111
110
|
tabIndex: -1,
|
|
112
|
-
...
|
|
113
|
-
...
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
...(disabled ? { 'aria-disabled': true } : null),
|
|
112
|
+
...combineProps(restOtherProps, {
|
|
113
|
+
...focusVisibleHandlers,
|
|
114
|
+
...activeHandlers,
|
|
115
|
+
...vlItemProps,
|
|
116
|
+
}),
|
|
117
|
+
ref: (instance) => {
|
|
118
|
+
unstable_setRef(otherRef, instance);
|
|
119
|
+
unstable_setRef(handleItemRef, instance);
|
|
120
|
+
},
|
|
117
121
|
};
|
|
118
122
|
};
|
|
119
123
|
return { getRootProps, focusVisible, active };
|
|
@@ -121,7 +125,7 @@ const useVirtualizedMenuItem = (props) => {
|
|
|
121
125
|
|
|
122
126
|
const MenuItem = forwardRef((inProps, ref) => {
|
|
123
127
|
const props = useThemeProps({ props: inProps, name: 'MenuItem' });
|
|
124
|
-
const { classes, className, children, selected, disabled, onMouseEnter, onMouseLeave, onPointerMove, highlighted = false, focused = false, autoClose = true, autoFocus, ...rest } = props;
|
|
128
|
+
const { classes, className, children, selected, disabled, onMouseEnter, onMouseLeave, onPointerMove, onBlur, onFocus, onKeyDown, onKeyUp, onClick, highlighted = false, focused = false, autoClose = true, autoFocus, ...rest } = props;
|
|
125
129
|
const cls = useClassesWithMode('menu-item', classes, className);
|
|
126
130
|
const vlItemProps = useVirtualizedItemPropsContext();
|
|
127
131
|
const isInVlRef = useRef(Boolean(vlItemProps));
|
|
@@ -137,8 +141,13 @@ const MenuItem = forwardRef((inProps, ref) => {
|
|
|
137
141
|
const itemRef = useRef(null);
|
|
138
142
|
const handleRef = useForkRef(itemRef, ref);
|
|
139
143
|
const { getRootProps, focusVisible, active } = useMenuItemHook({
|
|
140
|
-
...props,
|
|
141
144
|
autoClose,
|
|
145
|
+
disabled,
|
|
146
|
+
onBlur,
|
|
147
|
+
onClick,
|
|
148
|
+
onFocus,
|
|
149
|
+
onKeyDown,
|
|
150
|
+
onKeyUp,
|
|
142
151
|
ref: handleRef,
|
|
143
152
|
});
|
|
144
153
|
const selectable = !(selected === undefined);
|
|
@@ -270,4 +279,4 @@ const useMenuItemSelect = (props) => {
|
|
|
270
279
|
};
|
|
271
280
|
};
|
|
272
281
|
|
|
273
|
-
export { Action as A, MenuItem as M, SubMenuTriggerNestedIdContext as S, MenuItemSelectContext as a, useMenuItem as b, useMenuItemSelect as c, useVirtualizedMenuItem as d, MenuListContext as e, useMenuListContext as f,
|
|
282
|
+
export { Action as A, MenuItem as M, SubMenuTriggerNestedIdContext as S, MenuItemSelectContext as a, useMenuItem as b, useMenuItemSelect as c, useVirtualizedMenuItem as d, MenuListContext as e, useMenuListContext as f, useMenuItemSelectContext as u };
|