@ringcentral/spring-ui 1.11.2 → 1.13.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/Accordion.js +90 -34
- package/AccordionHeader.js +72 -20
- package/Alert.js +120 -28
- package/Animation.js +2 -45
- package/Announcement.js +46 -35
- package/Autocomplete.js +1011 -580
- package/Avatar.js +134 -73
- package/AvatarGroup.js +50 -7
- package/Backdrop.js +45 -7
- package/Badge.js +77 -15
- package/Block.js +34 -12
- package/BlockHeader.js +55 -11
- package/BottomNavigation.js +181 -65
- package/BottomNavigationItem.js +93 -30
- package/Button.js +160 -24
- package/CallButton.js +53 -31
- package/Checkbox.js +88 -26
- package/Chip.js +126 -26
- package/CircularProgressIndicator.js +80 -8
- package/ClickAwayListener.js +4 -1
- package/ComponentsProps.js +1 -0
- package/DatePicker.js +611 -190
- package/DateUtilsContext.js +43 -25
- package/Dialer.js +576 -250
- package/Dialog.js +100 -45
- package/Divider.js +43 -7
- package/DragHandle.js +32 -6
- package/Drawer.js +117 -19
- package/Dropdown.js +154 -74
- package/EmptyState.js +63 -11
- package/FabButton.js +51 -17
- package/FocusTrap.js +109 -12
- package/FormField.js +106 -8
- package/FormLabel.js +81 -7
- package/Icon.js +1 -8
- package/IconButton.js +142 -26
- package/IconButtonGroup.js +35 -12
- package/InlineEditable.js +98 -44
- package/LinearProgressIndicator.js +73 -24
- package/Link.js +40 -11
- package/List.js +54 -9
- package/ListItem.js +152 -23
- package/ListItemText.js +44 -16
- package/ListNavigation.js +272 -20
- package/Menu.js +139 -23
- package/MenuActions.js +37 -12
- package/MenuDivider.js +34 -8
- package/MenuFooter.js +36 -12
- package/MenuHeader.js +54 -15
- package/MenuItem.js +402 -33
- package/MenuItemText.js +51 -8
- package/MenuList.js +87 -34
- package/Modal.js +345 -16
- package/NestedMenuContext.js +183 -11
- package/Option.js +32 -34
- package/Overlap.js +54 -7
- package/PageHeader.js +62 -24
- package/PickerTextField.js +156 -33
- package/Popover.js +262 -21
- package/Popper.js +130 -77
- package/PopperPaper.js +54 -8
- package/Portal.js +6 -1
- package/Radio.js +65 -21
- package/RadioGroup.js +56 -17
- package/Rating.js +223 -87
- package/Select.js +387 -41
- package/SingleFilter.js +148 -77
- package/Skeleton.js +68 -17
- package/Slider.js +168 -69
- package/Snackbar.js +122 -59
- package/SortableList.js +32 -12
- package/SortableListDndContext.js +69 -22
- package/SortableListItem.js +92 -47
- package/SortableVirtualizedList.js +52 -28
- package/SplitButton.js +124 -86
- package/Squircle.js +4 -7
- package/StatusIndicator.js +51 -9
- package/Step.js +63 -38
- package/StepButton.js +51 -23
- package/StepConnector.js +48 -8
- package/StepContent.js +68 -25
- package/StepIcon.js +90 -9
- package/StepLabel.js +90 -14
- package/Stepper.js +65 -23
- package/SubMenu.js +203 -99
- package/SwipeableDrawer.js +439 -194
- package/Switch.js +70 -23
- package/Tab.js +120 -57
- package/TabContext.js +59 -15
- package/TabPanel.js +40 -13
- package/Table.js +60 -17
- package/TableBody.js +42 -12
- package/TableCell.js +84 -50
- package/TableContainer.js +32 -10
- package/TableFooter.js +38 -10
- package/TableHead.js +49 -15
- package/TablePagination.js +153 -77
- package/TableRow.js +60 -21
- package/Tabs.js +593 -268
- package/Tag.js +51 -16
- package/Text.js +68 -37
- package/TextField.js +209 -29
- package/Textarea.js +51 -40
- package/TimePicker.js +490 -230
- package/Tooltip.js +48 -23
- package/Tray.js +237 -13
- package/TrayMenu.js +62 -41
- package/VirtualizedList.js +208 -109
- package/VirtualizedMenu.js +359 -29
- package/VisuallyHidden.js +29 -6
- package/chunks/1250.js +98 -0
- package/chunks/1294.js +126 -0
- package/chunks/2956.js +18 -0
- package/chunks/4476.js +460 -0
- package/chunks/4491.js +10 -0
- package/chunks/4535.js +364 -0
- package/chunks/5047.js +3 -0
- package/chunks/6335.js +24 -0
- package/chunks/7279.js +10 -0
- package/chunks/8011.js +8 -0
- package/chunks/8307.js +56 -0
- package/chunks/8467.js +8 -0
- package/chunks/8809.js +8 -0
- package/chunks/{RadioGroup.context.js → 9551.js} +12 -6
- package/chunks/987.js +8 -0
- package/index.css +2624 -2416
- package/index.js +245 -193
- package/internal/utils/index.d.ts +1 -0
- package/internal/utils/setRef.d.ts +2 -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/Animation/hooks/useMotionSafeTransition/useMotionSafeTransition.d.ts +2 -0
- 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/Button/Button.classes.d.ts +1 -1
- package/src/ComponentsProps.d.ts +111 -110
- package/src/DatePicker/DatePickerDataAttributes.d.ts +11 -0
- package/src/DatePicker/utils/DatePickerAriaLabelUtils.d.ts +2 -1
- package/src/DatePicker/utils/DatePickerUtils.d.ts +1 -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/MenuItem.type.d.ts +1 -0
- 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/MenuList/MenuListContext.d.ts +2 -3
- package/src/Modal/Modal.type.d.ts +1 -0
- package/src/NestedMenuContext/MenuOverlayGroupContext.d.ts +2 -2
- package/src/Popover/Popover.classes.d.ts +1 -1
- package/src/Popover/Popover.internal.d.ts +8 -0
- package/src/Popover/Popover.type.d.ts +1 -0
- package/src/Popper/Popper.type.d.ts +10 -7
- package/src/Rating/utils.d.ts +3 -2
- package/src/Select/Select.type.d.ts +7 -5
- 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
- package/src/Table/Table.type.d.ts +3 -0
- package/src/Table/TableContext.d.ts +3 -0
- package/src/Table/TableRowContext.d.ts +7 -0
- package/src/Table/index.d.ts +1 -0
- package/src/TableCell/TableCell.classes.d.ts +1 -1
- package/src/TableFooter/TableFooter.classes.d.ts +1 -1
- package/src/TableFooter/TableFooter.type.d.ts +1 -0
- package/src/TableHead/TableHead.classes.d.ts +1 -1
- package/src/TableHead/TableHead.type.d.ts +1 -0
- package/src/TableRow/TableRow.type.d.ts +2 -0
- package/chunks/AccordionContext.js +0 -6
- package/chunks/Alert.js +0 -48
- package/chunks/AvatarGroup.js +0 -22
- package/chunks/Backdrop.js +0 -18
- package/chunks/Badge.js +0 -32
- package/chunks/BottomNavigationItem.js +0 -36
- package/chunks/Button.js +0 -88
- package/chunks/Chip.js +0 -73
- package/chunks/CircularProgressIndicator.js +0 -36
- package/chunks/Divider.js +0 -19
- package/chunks/DragHandle.js +0 -11
- package/chunks/Drawer.js +0 -32
- package/chunks/ExpandCollapseCaret.js +0 -24
- package/chunks/FormLabel.js +0 -27
- package/chunks/Icon.js +0 -25
- package/chunks/IconButtonLabel.js +0 -68
- package/chunks/List.js +0 -22
- package/chunks/ListItem.js +0 -83
- package/chunks/Menu.js +0 -61
- package/chunks/MenuDivider.js +0 -14
- package/chunks/MenuItemText.js +0 -17
- package/chunks/MenuList.js +0 -46
- package/chunks/Modal.js +0 -212
- package/chunks/Overlap.js +0 -25
- package/chunks/PickerTextField.js +0 -85
- package/chunks/Popover.js +0 -53
- package/chunks/PopperPaper.js +0 -15
- package/chunks/Select.js +0 -220
- package/chunks/ShowHideEye.js +0 -56
- package/chunks/SlideIn.js +0 -19
- package/chunks/SortableArrow.js +0 -73
- package/chunks/Squircle.js +0 -31
- package/chunks/StatusIndicator.js +0 -20
- package/chunks/StepConnector.js +0 -21
- package/chunks/StepIcon.js +0 -43
- package/chunks/StepLabel.js +0 -29
- package/chunks/StepperContext.js +0 -9
- package/chunks/TableContext.js +0 -6
- package/chunks/Tablelvl2Context.js +0 -6
- package/chunks/TabsContext.js +0 -6
- package/chunks/TextField.js +0 -110
- package/chunks/Tooltip.js +0 -217
- package/chunks/VirtualizedMenu.js +0 -164
- package/chunks/VisuallyHidden.js +0 -12
- package/chunks/getFade.js +0 -27
- package/chunks/getGrow.js +0 -70
- package/chunks/getSlideIn.js +0 -30
- package/chunks/hasContent.js +0 -3
- package/chunks/useAnimationFrame.js +0 -15
- package/chunks/useFocusTrapStack.js +0 -36
- package/chunks/useHelperTextId.js +0 -22
- package/chunks/useListNavigation.js +0 -199
- package/chunks/useMenuItemSelect.js +0 -273
- package/chunks/useMotionSafeTransition.js +0 -9
- package/chunks/useNestedMenuItem.js +0 -27
- package/chunks/useNestedParentMenu.js +0 -113
- package/chunks/usePrefersReducedMotion.js +0 -36
- package/chunks/useTooltipForceHide.js +0 -27
- package/chunks/useTrayNavigate.js +0 -150
- package/chunks/withTooltip.js +0 -15
package/chunks/MenuList.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef, useMemo, useRef, useLayoutEffect } from 'react';
|
|
3
|
-
import { useClasses, useForkRef, useWindowContext } from '@ringcentral/spring-base';
|
|
4
|
-
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
5
|
-
import { L as List } from './List.js';
|
|
6
|
-
import { u as useMenuContext } from './Menu.js';
|
|
7
|
-
import { c as useMenuItemSelect, e as MenuListContext, a as MenuItemSelectContext } from './useMenuItemSelect.js';
|
|
8
|
-
import 'tabbable';
|
|
9
|
-
import './useListNavigation.js';
|
|
10
|
-
import '../VirtualizedList.js';
|
|
11
|
-
|
|
12
|
-
const MenuList = forwardRef((inProps, ref) => {
|
|
13
|
-
const props = useThemeProps({ props: inProps, name: 'MenuList' });
|
|
14
|
-
const { classes, className, children, widget, selectMode = 'single', nowrap, value: valueProp, onChange, autoFocus: autoFocusProp, ...rest } = props;
|
|
15
|
-
const menuContext = useMenuContext();
|
|
16
|
-
const autoFocus = Boolean(autoFocusProp || menuContext?.autoFocus);
|
|
17
|
-
const cls = useClasses('menu-list', classes, className);
|
|
18
|
-
const menuListContextValue = useMemo(() => ({
|
|
19
|
-
nowrap,
|
|
20
|
-
}), [nowrap]);
|
|
21
|
-
const { contextValue } = useMenuItemSelect({
|
|
22
|
-
widget,
|
|
23
|
-
selectMode,
|
|
24
|
-
value: valueProp,
|
|
25
|
-
onChange,
|
|
26
|
-
autoFocus,
|
|
27
|
-
});
|
|
28
|
-
const actions = useRef(null);
|
|
29
|
-
const listRef = useRef(null);
|
|
30
|
-
const handleListRef = useForkRef(listRef, ref);
|
|
31
|
-
const { document } = useWindowContext();
|
|
32
|
-
useLayoutEffect(() => {
|
|
33
|
-
if (autoFocus &&
|
|
34
|
-
!listRef.current?.contains(document?.activeElement ?? null)) {
|
|
35
|
-
actions.current?.focus();
|
|
36
|
-
}
|
|
37
|
-
}, [autoFocus]);
|
|
38
|
-
const listRole = widget === 'select' ? 'listbox' : 'menu';
|
|
39
|
-
const listboxProps = widget === 'select'
|
|
40
|
-
? { 'aria-multiselectable': selectMode === 'multiple' }
|
|
41
|
-
: {};
|
|
42
|
-
return (jsx(List, { className: cls('root'), role: listRole, ...listboxProps, ...rest, ref: handleListRef, actions: actions, children: jsx(MenuListContext.Provider, { value: menuListContextValue, children: jsx(MenuItemSelectContext.Provider, { value: contextValue, children: children }) }) }));
|
|
43
|
-
});
|
|
44
|
-
MenuList.displayName = 'SuiMenuList';
|
|
45
|
-
|
|
46
|
-
export { MenuList as M };
|
package/chunks/Modal.js
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { createContext, useContext, useRef, useCallback, useLayoutEffect, forwardRef, useState, useEffect } from 'react';
|
|
3
|
-
import { useAriaHideOutside, useForkRef, useClasses, useEventCallback, useBodyScrollLock, useWindowContext } from '@ringcentral/spring-base';
|
|
4
|
-
import { useThemeProps, useTheme } from '@ringcentral/spring-theme';
|
|
5
|
-
import { FocusTrap, Portal } from '@mui/base';
|
|
6
|
-
import { motion } from 'framer-motion';
|
|
7
|
-
import './Icon.js';
|
|
8
|
-
import { u as usePrefersReducedMotion } from './usePrefersReducedMotion.js';
|
|
9
|
-
import { g as getFade } from './getFade.js';
|
|
10
|
-
import { u as useFocusTrapStack } from './useFocusTrapStack.js';
|
|
11
|
-
import { B as Backdrop } from './Backdrop.js';
|
|
12
|
-
|
|
13
|
-
const ModalContext = createContext(null);
|
|
14
|
-
const useModalContext = () => useContext(ModalContext);
|
|
15
|
-
|
|
16
|
-
const createOverlayBranchRegistry = () => {
|
|
17
|
-
const branchRefCounts = new Map();
|
|
18
|
-
const listeners = new Set();
|
|
19
|
-
const notify = (node, isRegistered) => {
|
|
20
|
-
for (const listener of [...listeners]) {
|
|
21
|
-
listener(node, isRegistered);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
return {
|
|
25
|
-
getBranches: () => new Set(branchRefCounts.keys()),
|
|
26
|
-
register: (node) => {
|
|
27
|
-
const currentCount = branchRefCounts.get(node) ?? 0;
|
|
28
|
-
branchRefCounts.set(node, currentCount + 1);
|
|
29
|
-
if (currentCount === 0) {
|
|
30
|
-
notify(node, true);
|
|
31
|
-
}
|
|
32
|
-
let isCleanedUp = false;
|
|
33
|
-
return () => {
|
|
34
|
-
if (isCleanedUp) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
isCleanedUp = true;
|
|
38
|
-
const currentCount = branchRefCounts.get(node);
|
|
39
|
-
if (!currentCount) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (currentCount > 1) {
|
|
43
|
-
branchRefCounts.set(node, currentCount - 1);
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
branchRefCounts.delete(node);
|
|
47
|
-
notify(node, false);
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
subscribe: (listener) => {
|
|
51
|
-
listeners.add(listener);
|
|
52
|
-
return () => {
|
|
53
|
-
listeners.delete(listener);
|
|
54
|
-
};
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
const useOverlayBranchRegistry = () => {
|
|
59
|
-
const registryRef = useRef();
|
|
60
|
-
if (!registryRef.current) {
|
|
61
|
-
registryRef.current = createOverlayBranchRegistry();
|
|
62
|
-
}
|
|
63
|
-
return registryRef.current;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const useOverlayBranch = ({ active, registry, }) => {
|
|
67
|
-
const nodeRef = useRef(null);
|
|
68
|
-
const registrationRef = useRef(null);
|
|
69
|
-
const syncRegistration = useCallback((node) => {
|
|
70
|
-
const registration = registrationRef.current;
|
|
71
|
-
const shouldKeepRegistration = registration &&
|
|
72
|
-
active &&
|
|
73
|
-
registration.node === node &&
|
|
74
|
-
registration.registry === registry;
|
|
75
|
-
if (shouldKeepRegistration) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
registration?.unregister();
|
|
79
|
-
registrationRef.current = null;
|
|
80
|
-
if (active && node && registry) {
|
|
81
|
-
registrationRef.current = {
|
|
82
|
-
node,
|
|
83
|
-
registry,
|
|
84
|
-
unregister: registry.register(node),
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
}, [active, registry]);
|
|
88
|
-
const setBranchRef = useCallback((node) => {
|
|
89
|
-
nodeRef.current = node;
|
|
90
|
-
syncRegistration(node);
|
|
91
|
-
}, [syncRegistration]);
|
|
92
|
-
useLayoutEffect(() => {
|
|
93
|
-
syncRegistration(nodeRef.current);
|
|
94
|
-
}, [syncRegistration]);
|
|
95
|
-
useLayoutEffect(() => () => {
|
|
96
|
-
registrationRef.current?.unregister();
|
|
97
|
-
registrationRef.current = null;
|
|
98
|
-
}, []);
|
|
99
|
-
return setBranchRef;
|
|
100
|
-
};
|
|
101
|
-
const useOverlayBranchConsumer = (registry, listener) => {
|
|
102
|
-
useLayoutEffect(() => {
|
|
103
|
-
const unsubscribe = registry.subscribe(listener);
|
|
104
|
-
for (const node of registry.getBranches()) {
|
|
105
|
-
listener(node, true);
|
|
106
|
-
}
|
|
107
|
-
return () => {
|
|
108
|
-
unsubscribe();
|
|
109
|
-
for (const node of registry.getBranches()) {
|
|
110
|
-
listener(node, false);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
}, [listener, registry]);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const InnerModal = forwardRef((props, ref) => {
|
|
117
|
-
const { hideBackdrop: hideBackdropProp, children, motionProps, disableBackdropClick: disableBackdropClickProp, onBackdropClick, disableEscapeKeyDown: disableEscapeKeyDownProp, onEscapeKeyDown, onClose, onKeyDown, disableAutoFocus, disableEnforceFocus, disableRestoreFocus, classes, className, backdropProps, open, isEnabled, blocking = true, shouldUseInert: shouldUseInertProp, ...rest } = props;
|
|
118
|
-
const parentModalContext = useModalContext();
|
|
119
|
-
const ownOverlayBranchRegistry = useOverlayBranchRegistry();
|
|
120
|
-
const shouldUseInert = shouldUseInertProp ?? parentModalContext?.shouldUseInert ?? false;
|
|
121
|
-
const hideBackdrop = hideBackdropProp ?? !blocking;
|
|
122
|
-
const disableBackdropClick = disableBackdropClickProp ?? !blocking;
|
|
123
|
-
const disableEscapeKeyDown = disableEscapeKeyDownProp ?? !blocking;
|
|
124
|
-
const { ariaHideOutsideRef, ariaHideEnabled, setAriaHideOutsideTarget } = useAriaHideOutside({
|
|
125
|
-
enable: blocking && open,
|
|
126
|
-
shouldUseInert,
|
|
127
|
-
});
|
|
128
|
-
useOverlayBranchConsumer(ownOverlayBranchRegistry, setAriaHideOutsideTarget);
|
|
129
|
-
const parentOverlayBranchRegistry = parentModalContext?.overlayBranchRegistry;
|
|
130
|
-
const overlayBranchRegistry = ariaHideEnabled
|
|
131
|
-
? ownOverlayBranchRegistry
|
|
132
|
-
: parentOverlayBranchRegistry;
|
|
133
|
-
const isOverlayBranch = !blocking && open && parentOverlayBranchRegistry != null;
|
|
134
|
-
const ariaHideEnabledForChildren = ariaHideEnabled || parentModalContext?.ariaHideEnabled === true;
|
|
135
|
-
const overlayBranchRef = useOverlayBranch({
|
|
136
|
-
active: isOverlayBranch,
|
|
137
|
-
registry: parentOverlayBranchRegistry,
|
|
138
|
-
});
|
|
139
|
-
const handleRef = useForkRef(ref, ariaHideOutsideRef, overlayBranchRef);
|
|
140
|
-
const cls = useClasses('modal', classes, className);
|
|
141
|
-
const { onClick: externalOnClick, ...restBackdropProps } = backdropProps || {};
|
|
142
|
-
const handleBackdropClick = useEventCallback((event) => {
|
|
143
|
-
if (disableBackdropClick)
|
|
144
|
-
return;
|
|
145
|
-
if (event.target !== event.currentTarget) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
externalOnClick?.(event);
|
|
149
|
-
onBackdropClick?.(event);
|
|
150
|
-
onClose?.(event, 'backdropClick');
|
|
151
|
-
});
|
|
152
|
-
return (jsx(ModalContext.Provider, { value: {
|
|
153
|
-
ariaHideEnabled: ariaHideEnabledForChildren,
|
|
154
|
-
overlayBranchRegistry,
|
|
155
|
-
shouldUseInert,
|
|
156
|
-
}, children: jsxs(motion.div, { ...rest, ...motionProps, role: "presentation", className: cls('root', { 'non-blocking': !blocking }), onKeyDown: (e) => {
|
|
157
|
-
onKeyDown?.(e);
|
|
158
|
-
if (!disableEscapeKeyDown &&
|
|
159
|
-
e.key === 'Escape' &&
|
|
160
|
-
(isEnabled?.() ?? true)) {
|
|
161
|
-
onEscapeKeyDown?.(e);
|
|
162
|
-
onClose?.(e, 'escapeKeyDown');
|
|
163
|
-
}
|
|
164
|
-
}, ref: handleRef, children: [jsx(Backdrop, { ...restBackdropProps, isTransparent: hideBackdrop, onClick: handleBackdropClick }), jsx(FocusTrap, { open: open, isEnabled: isEnabled, disableAutoFocus: disableAutoFocus || !blocking, disableEnforceFocus: disableEnforceFocus || !blocking, disableRestoreFocus: disableRestoreFocus || !blocking, children: children })] }) }));
|
|
165
|
-
});
|
|
166
|
-
InnerModal.displayName = 'SuiInnerModal';
|
|
167
|
-
|
|
168
|
-
const Modal = forwardRef((inProps, ref) => {
|
|
169
|
-
const props = useThemeProps({ props: inProps, name: 'Modal' });
|
|
170
|
-
const { children, open, container: containerProp, disablePortal, onExitComplete, disableBackdropAnimation, motionProps, disableScrollLock: disableScrollLockProp, blocking = true, shouldUseInert: themeFallbackShouldUseInert, ...rest } = props;
|
|
171
|
-
const parentModalContext = useModalContext();
|
|
172
|
-
const shouldUseInert = inProps.shouldUseInert ??
|
|
173
|
-
parentModalContext?.shouldUseInert ??
|
|
174
|
-
themeFallbackShouldUseInert ??
|
|
175
|
-
false;
|
|
176
|
-
const disableScrollLock = disableScrollLockProp ?? !blocking;
|
|
177
|
-
const [shouldRender, setShouldRender] = useState(open);
|
|
178
|
-
const [modalElement, setModalElement] = useState(null);
|
|
179
|
-
const handleRef = useForkRef(setModalElement, ref);
|
|
180
|
-
const prefersReducedMotion = usePrefersReducedMotion();
|
|
181
|
-
const { isEnabled } = useFocusTrapStack({ open });
|
|
182
|
-
useBodyScrollLock(open, modalElement, {
|
|
183
|
-
disabled: disableScrollLock,
|
|
184
|
-
});
|
|
185
|
-
useEffect(() => {
|
|
186
|
-
if (open) {
|
|
187
|
-
setShouldRender(true);
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
if (disableBackdropAnimation) {
|
|
191
|
-
setShouldRender(false);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}, [open, disableBackdropAnimation]);
|
|
195
|
-
const { document } = useWindowContext();
|
|
196
|
-
const container = containerProp ?? document?.body;
|
|
197
|
-
const { scopeProps } = useTheme();
|
|
198
|
-
const onAnimationComplete = (e) => {
|
|
199
|
-
motionProps?.onAnimationComplete?.(e);
|
|
200
|
-
if (!open) {
|
|
201
|
-
onExitComplete?.();
|
|
202
|
-
setShouldRender(false);
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
return shouldRender ? (jsx(Portal, { disablePortal: disablePortal, container: container, children: jsx("div", { ...scopeProps, children: jsx(InnerModal, { ...rest, ref: handleRef, open: open, blocking: blocking, shouldUseInert: shouldUseInert, isEnabled: isEnabled, motionProps: {
|
|
206
|
-
...(motionProps ?? getFade({ prefersReducedMotion, toggle: open })),
|
|
207
|
-
onAnimationComplete,
|
|
208
|
-
}, children: children }) }) })) : null;
|
|
209
|
-
});
|
|
210
|
-
Modal.displayName = 'SuiModal';
|
|
211
|
-
|
|
212
|
-
export { InnerModal as I, Modal as M, ModalContext as a, useModalContext as u };
|
package/chunks/Overlap.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
import { useClasses } from '@ringcentral/spring-base';
|
|
4
|
-
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
5
|
-
|
|
6
|
-
function isKeyPosition(position) {
|
|
7
|
-
return typeof position === 'string';
|
|
8
|
-
}
|
|
9
|
-
const Overlap = forwardRef((inProps, ref) => {
|
|
10
|
-
const props = useThemeProps({ props: inProps, name: 'Overlap' });
|
|
11
|
-
const { classes, floater, position, children, className, showFloaterOnHoverOnly = false, component: OverlapRoot = 'div', ...rest } = props;
|
|
12
|
-
const cls = useClasses('overlap', classes, className);
|
|
13
|
-
let widget = null;
|
|
14
|
-
if (floater) {
|
|
15
|
-
const style = !isKeyPosition(position) ? position : undefined;
|
|
16
|
-
const classes = cls('floater', isKeyPosition(position) && position);
|
|
17
|
-
widget = jsx("div", { style: style, className: classes, children: floater });
|
|
18
|
-
}
|
|
19
|
-
return (jsxs(OverlapRoot, { ...rest, ref: ref, className: cls('root', {
|
|
20
|
-
'show-floater-on-hover-only': showFloaterOnHoverOnly,
|
|
21
|
-
}), children: [children, widget] }));
|
|
22
|
-
});
|
|
23
|
-
Overlap.displayName = 'SuiOverlap';
|
|
24
|
-
|
|
25
|
-
export { Overlap as O };
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef, useState, useRef, useImperativeHandle, useMemo } from 'react';
|
|
3
|
-
import { useId, useClasses, useForkRef, useA11yKeyEvent, useEventCallback, combineClasses } from '@ringcentral/spring-base';
|
|
4
|
-
import { I as Icon } from './Icon.js';
|
|
5
|
-
import { P as Popover } from './Popover.js';
|
|
6
|
-
import { u as useHelperTextId } from './useHelperTextId.js';
|
|
7
|
-
import { T as TextField } from './TextField.js';
|
|
8
|
-
import { V as VisuallyHidden } from './VisuallyHidden.js';
|
|
9
|
-
|
|
10
|
-
const PICKER_DISPLAY_NAME = 'SuiPickerTextField';
|
|
11
|
-
const PickerTextField = forwardRef((props, ref) => {
|
|
12
|
-
const { disabled, value, defaultValue, onClear, action, inputProps = {}, announcementText, PopoverProps, children, endIconSymbol, clearText, clearBtn, ClearButtonProps, onKeyDown, onClick, onClose, classes, textInputClasses, className, id: idProp, ...rest } = props;
|
|
13
|
-
const generatedId = useId(PICKER_DISPLAY_NAME, true);
|
|
14
|
-
const idForInput = idProp ?? inputProps.id ?? generatedId;
|
|
15
|
-
const [open, setOpen] = useState(false);
|
|
16
|
-
const [isPopoverExited, setIsPopoverExited] = useState(!open);
|
|
17
|
-
const cls = useClasses('picker-text-field', classes, className);
|
|
18
|
-
const anchorRef = useRef(null);
|
|
19
|
-
const handleRef = useForkRef(ref, anchorRef);
|
|
20
|
-
const idForHelperText = useHelperTextId({
|
|
21
|
-
helperText: rest.helperText,
|
|
22
|
-
id: idForInput,
|
|
23
|
-
FormHelperTextProps: rest.FormHelperTextProps,
|
|
24
|
-
});
|
|
25
|
-
const idForInstruction = announcementText
|
|
26
|
-
? `${idForInput}-instruction`
|
|
27
|
-
: undefined;
|
|
28
|
-
const ariaDescribedBy = Array.from(new Set([inputProps['aria-describedby'], idForHelperText, idForInstruction]
|
|
29
|
-
.filter(Boolean)
|
|
30
|
-
.flatMap((value) => `${value}`.split(/\s+/).filter(Boolean)))).join(' ');
|
|
31
|
-
const handleA11yKeydown = useA11yKeyEvent(() => {
|
|
32
|
-
handleOpen(true);
|
|
33
|
-
});
|
|
34
|
-
const handleOpen = useEventCallback((open) => {
|
|
35
|
-
if (disabled && open) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (open) {
|
|
39
|
-
setIsPopoverExited(false);
|
|
40
|
-
}
|
|
41
|
-
setOpen(open);
|
|
42
|
-
});
|
|
43
|
-
useImperativeHandle(action, () => ({
|
|
44
|
-
close: () => {
|
|
45
|
-
handleOpen(false);
|
|
46
|
-
},
|
|
47
|
-
}), [handleOpen]);
|
|
48
|
-
const toClasses = useMemo(() => combineClasses(textInputClasses, {
|
|
49
|
-
formFieldContent: cls('form-field-content', {
|
|
50
|
-
'has-value': Boolean(value),
|
|
51
|
-
}),
|
|
52
|
-
root: cls('root', {
|
|
53
|
-
'has-value': Boolean(value),
|
|
54
|
-
}),
|
|
55
|
-
input: cls('input'),
|
|
56
|
-
}), [cls, textInputClasses, value]);
|
|
57
|
-
return (jsxs(Fragment, { children: [jsx(TextField, { classes: toClasses, value: value, defaultValue: defaultValue, endAdornment: endIconSymbol && (jsx(Icon, { className: cls('end-icon'), symbol: endIconSymbol })), id: idForInput, ref: handleRef, focused: open || (!open && !isPopoverExited), disabled: disabled, clearBtn: clearBtn, clearText: clearText, ClearButtonProps: ClearButtonProps, onClick: (e) => {
|
|
58
|
-
handleOpen(true);
|
|
59
|
-
onClick?.(e);
|
|
60
|
-
}, onKeyDown: (e) => {
|
|
61
|
-
if (disabled)
|
|
62
|
-
return;
|
|
63
|
-
handleA11yKeydown(e);
|
|
64
|
-
onKeyDown?.(e);
|
|
65
|
-
}, inputProps: {
|
|
66
|
-
'aria-haspopup': true,
|
|
67
|
-
...inputProps,
|
|
68
|
-
'aria-describedby': ariaDescribedBy || undefined,
|
|
69
|
-
}, ...rest, readOnly: true, onClear: (e) => {
|
|
70
|
-
onClear?.(e);
|
|
71
|
-
e.stopPropagation();
|
|
72
|
-
} }), jsx(Popover, { bordered: true, open: open, anchorEl: anchorRef.current, onClose: (...args) => {
|
|
73
|
-
handleOpen(false);
|
|
74
|
-
onClose?.(...args);
|
|
75
|
-
}, placement: "bottom-start", transformOrigin: {
|
|
76
|
-
vertical: 'top',
|
|
77
|
-
horizontal: 'left',
|
|
78
|
-
}, ...PopoverProps, onExitComplete: () => {
|
|
79
|
-
PopoverProps?.onExitComplete?.();
|
|
80
|
-
setIsPopoverExited(true);
|
|
81
|
-
}, children: children }), idForInstruction && (jsx(VisuallyHidden, { id: idForInstruction, children: announcementText }))] }));
|
|
82
|
-
});
|
|
83
|
-
PickerTextField.displayName = PICKER_DISPLAY_NAME;
|
|
84
|
-
|
|
85
|
-
export { PickerTextField as P };
|
package/chunks/Popover.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef, useRef } from 'react';
|
|
3
|
-
import { size } from '@floating-ui/react-dom';
|
|
4
|
-
import { useClasses, useForkRef, combineProps } from '@ringcentral/spring-base';
|
|
5
|
-
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
6
|
-
import 'framer-motion';
|
|
7
|
-
import './Icon.js';
|
|
8
|
-
import { u as usePrefersReducedMotion } from './usePrefersReducedMotion.js';
|
|
9
|
-
import { g as getGrow, a as getTransformOriginStringForPlacement } from './getGrow.js';
|
|
10
|
-
import { M as Modal } from './Modal.js';
|
|
11
|
-
import { Popper } from '../Popper.js';
|
|
12
|
-
import { P as PopperPaper } from './PopperPaper.js';
|
|
13
|
-
|
|
14
|
-
const Popover = forwardRef((inProps, ref) => {
|
|
15
|
-
const props = useThemeProps({ props: inProps, name: 'Popover' });
|
|
16
|
-
const { classes, className, children, PopperProps, variant = 'standard', bordered = false, shadow = true, transformOrigin, motionProps: motionPropsProp, popperRef, placement, anchorEl, actions, onAvailableHeightChange, PopperPaperProps: popperPaperPropsProp, ...rest } = props;
|
|
17
|
-
const cls = useClasses('popover', classes, className);
|
|
18
|
-
const paperContentRef = useRef(null);
|
|
19
|
-
const handlePaperContentRef = useForkRef(popperPaperPropsProp?.contentRef, paperContentRef);
|
|
20
|
-
const prefersReducedMotion = usePrefersReducedMotion();
|
|
21
|
-
return (jsx(Modal, { ...rest, className: cls('root', 'popper'), ref: ref, motionProps: null, hideBackdrop: true, children: jsx(Popper, { arrowHeight: variant === 'standard' ? 0 : 10, arrowPadding: 12, offset: variant === 'standard' ? 2 : 4, ...combineProps({
|
|
22
|
-
middlewares: [
|
|
23
|
-
size({
|
|
24
|
-
padding: PopperProps?.padding,
|
|
25
|
-
apply({ availableHeight, availableWidth, }) {
|
|
26
|
-
onAvailableHeightChange?.(availableHeight);
|
|
27
|
-
if (paperContentRef.current) {
|
|
28
|
-
paperContentRef.current.style.maxHeight = `${availableHeight}px`;
|
|
29
|
-
paperContentRef.current.style.maxWidth = `${availableWidth}px`;
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
}),
|
|
33
|
-
],
|
|
34
|
-
}, PopperProps), className: cls('popper'), disablePortal: true, tabIndex: -1, ref: popperRef, placement: placement, anchorEl: anchorEl, actions: actions, children: ({ arrowStyle, arrowRef, placement: computedPlacement }) => {
|
|
35
|
-
const motionProps = motionPropsProp ??
|
|
36
|
-
getGrow({ transformOrigin, prefersReducedMotion });
|
|
37
|
-
const popperPaperProps = {
|
|
38
|
-
className: cls('paper', { bordered, shadow }),
|
|
39
|
-
};
|
|
40
|
-
if (!transformOrigin) {
|
|
41
|
-
popperPaperProps.style = {
|
|
42
|
-
...popperPaperProps.style,
|
|
43
|
-
transformOrigin: getTransformOriginStringForPlacement({
|
|
44
|
-
placement: computedPlacement,
|
|
45
|
-
}),
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
return (jsx(PopperPaper, { contentRef: handlePaperContentRef, arrowRef: arrowRef, arrowStyle: arrowStyle, ...combineProps(combineProps(motionProps, popperPaperProps), popperPaperPropsProp), children: children }));
|
|
49
|
-
} }) }));
|
|
50
|
-
});
|
|
51
|
-
Popover.displayName = 'SuiPopover';
|
|
52
|
-
|
|
53
|
-
export { Popover as P };
|
package/chunks/PopperPaper.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
import { motion } from 'framer-motion';
|
|
4
|
-
import { useClasses } from '@ringcentral/spring-base';
|
|
5
|
-
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
6
|
-
|
|
7
|
-
const PopperPaper = forwardRef((inProps, ref) => {
|
|
8
|
-
const props = useThemeProps({ props: inProps, name: 'PopperPaper' });
|
|
9
|
-
const { classes, className, children, arrowRef, arrowStyle, contentRef, ...rest } = props;
|
|
10
|
-
const cls = useClasses('popper-paper', classes, className);
|
|
11
|
-
return (jsxs(motion.div, { className: cls('root'), ...rest, ref: ref, children: [jsx("div", { ref: contentRef, className: cls('content'), children: children }), jsx("div", { className: cls('arrow'), ref: arrowRef, style: arrowStyle })] }));
|
|
12
|
-
});
|
|
13
|
-
PopperPaper.displayName = 'SuiPopperPaper';
|
|
14
|
-
|
|
15
|
-
export { PopperPaper as P };
|
package/chunks/Select.js
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef, useState, useRef, useEffect, useMemo } from 'react';
|
|
3
|
-
import { combineProps, useControlled, useClasses, useId, useEventCallback, combineClasses, getTitle } from '@ringcentral/spring-base';
|
|
4
|
-
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
5
|
-
import { E as ExpandCollapseCaret } from './ExpandCollapseCaret.js';
|
|
6
|
-
import 'framer-motion';
|
|
7
|
-
import { u as usePrefersReducedMotion } from './usePrefersReducedMotion.js';
|
|
8
|
-
import { g as getGrow } from './getGrow.js';
|
|
9
|
-
import './Icon.js';
|
|
10
|
-
import { u as useHelperTextId, F as FormField } from './useHelperTextId.js';
|
|
11
|
-
import { M as Menu, a as MenuContext } from './Menu.js';
|
|
12
|
-
import { c as useMenuItemSelect, a as MenuItemSelectContext } from './useMenuItemSelect.js';
|
|
13
|
-
import 'tabbable';
|
|
14
|
-
import './useListNavigation.js';
|
|
15
|
-
import '../VirtualizedList.js';
|
|
16
|
-
import { M as MenuList } from './MenuList.js';
|
|
17
|
-
import { S as Squircle } from './Squircle.js';
|
|
18
|
-
import { a as VirtualizedMenu } from './VirtualizedMenu.js';
|
|
19
|
-
|
|
20
|
-
const useSelect = (props) => {
|
|
21
|
-
const { open, handleOpen } = props;
|
|
22
|
-
const getButtonProps = (otherHandlers = {}) => {
|
|
23
|
-
const eventHandlers = combineProps({
|
|
24
|
-
onClick: () => {
|
|
25
|
-
handleOpen(!open);
|
|
26
|
-
},
|
|
27
|
-
onKeyDown: (e) => {
|
|
28
|
-
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
|
29
|
-
e.preventDefault();
|
|
30
|
-
handleOpen(true);
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
}, otherHandlers);
|
|
34
|
-
return {
|
|
35
|
-
'aria-expanded': open,
|
|
36
|
-
'aria-haspopup': 'listbox',
|
|
37
|
-
...eventHandlers,
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
const getListboxProps = () => ({
|
|
41
|
-
role: 'listbox',
|
|
42
|
-
});
|
|
43
|
-
return {
|
|
44
|
-
getButtonProps,
|
|
45
|
-
getListboxProps,
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const DEFAULT_PLACEMENT = 'bottom';
|
|
50
|
-
const Select = forwardRef((inProps, ref) => {
|
|
51
|
-
const props = useThemeProps({ props: inProps, name: 'Select' });
|
|
52
|
-
const { classes, className, children, name, id: idProp, value: valueProp, selectMode = 'single', defaultValue = selectMode === 'multiple' ? [] : null, onChange: onChangeProp, renderValue = (value) => Array.isArray(value) ? value.join(', ') : String(value), label, helperText, disabled, required, error, displayEmpty, placeholder, open: openProp, defaultOpen, onOpen, onClose, selectorProps: selectorPropsProp, MenuProps, variant = 'standard', inputProps, size = 'xlarge', virtualize = false, VirtualizedMenuProps: virtualizedMenuPropsProp, data, getSelectedIndex, FormHelperTextProps, ...rest } = props;
|
|
53
|
-
const [anchorEl, setAnchorEl] = useState(null);
|
|
54
|
-
const [open, setOpen] = useControlled({
|
|
55
|
-
controlled: openProp,
|
|
56
|
-
default: defaultOpen,
|
|
57
|
-
name: 'SuiSelect',
|
|
58
|
-
state: 'open',
|
|
59
|
-
});
|
|
60
|
-
const [didMenuExit, setDidMenuExit] = useState(!open);
|
|
61
|
-
const inputRef = useRef(null);
|
|
62
|
-
const prefersReducedMotion = usePrefersReducedMotion();
|
|
63
|
-
const cls = useClasses('select', classes, className);
|
|
64
|
-
const id = useId(idProp);
|
|
65
|
-
const helperTextId = useHelperTextId({
|
|
66
|
-
helperText,
|
|
67
|
-
id,
|
|
68
|
-
FormHelperTextProps,
|
|
69
|
-
});
|
|
70
|
-
const formFieldContentRef = useRef(null);
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
setAnchorEl(formFieldContentRef.current);
|
|
73
|
-
}, []);
|
|
74
|
-
const handleOpen = useEventCallback((newOpen) => {
|
|
75
|
-
if (disabled && newOpen)
|
|
76
|
-
return;
|
|
77
|
-
if (newOpen)
|
|
78
|
-
setDidMenuExit(false);
|
|
79
|
-
setOpen(newOpen);
|
|
80
|
-
if (newOpen) {
|
|
81
|
-
onOpen?.();
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
onClose?.();
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
if (disabled) {
|
|
89
|
-
handleOpen(false);
|
|
90
|
-
}
|
|
91
|
-
}, [disabled, handleOpen]);
|
|
92
|
-
const [value, setValue] = useControlled({
|
|
93
|
-
controlled: valueProp,
|
|
94
|
-
default: defaultValue,
|
|
95
|
-
name: 'SuiSelect',
|
|
96
|
-
state: 'value',
|
|
97
|
-
});
|
|
98
|
-
const handleInputChange = useEventCallback((e) => {
|
|
99
|
-
onChangeProp?.(e, inputRef.current);
|
|
100
|
-
});
|
|
101
|
-
const handleClose = useEventCallback(() => {
|
|
102
|
-
handleOpen(false);
|
|
103
|
-
});
|
|
104
|
-
const handleInitialFocus = useEventCallback(() => {
|
|
105
|
-
if (data && value !== null) {
|
|
106
|
-
if (getSelectedIndex)
|
|
107
|
-
return getSelectedIndex(value);
|
|
108
|
-
if (Array.isArray(value)) {
|
|
109
|
-
const lastSelectedItem = value.at(-1);
|
|
110
|
-
return lastSelectedItem ? data.indexOf(lastSelectedItem) : -1;
|
|
111
|
-
}
|
|
112
|
-
return data.findIndex((v) => v === value);
|
|
113
|
-
}
|
|
114
|
-
return true;
|
|
115
|
-
});
|
|
116
|
-
const handleMenuListChange = useEventCallback((newValue) => {
|
|
117
|
-
setValue(newValue);
|
|
118
|
-
if (inputRef.current) {
|
|
119
|
-
Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value')?.set?.call(inputRef.current, newValue);
|
|
120
|
-
const event = new Event('input', { bubbles: true });
|
|
121
|
-
Object.defineProperty(event, 'target', {
|
|
122
|
-
configurable: true,
|
|
123
|
-
get: () => {
|
|
124
|
-
return new Proxy(inputRef.current, {
|
|
125
|
-
get(obj, prop) {
|
|
126
|
-
if (prop === 'value') {
|
|
127
|
-
return newValue;
|
|
128
|
-
}
|
|
129
|
-
return obj[prop];
|
|
130
|
-
},
|
|
131
|
-
});
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
inputRef.current?.dispatchEvent(event);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
const { getButtonProps, getListboxProps } = useSelect({
|
|
138
|
-
open,
|
|
139
|
-
handleOpen,
|
|
140
|
-
});
|
|
141
|
-
const { contextValue: virtualizedContextValue } = useMenuItemSelect({
|
|
142
|
-
value,
|
|
143
|
-
onChange: handleMenuListChange,
|
|
144
|
-
onClose: handleClose,
|
|
145
|
-
selectMode,
|
|
146
|
-
});
|
|
147
|
-
const virtualizedMenuContextValue = useMemo(() => ({
|
|
148
|
-
close: handleClose,
|
|
149
|
-
autoFocus: true,
|
|
150
|
-
}), [handleClose]);
|
|
151
|
-
const selectorProps = getButtonProps(selectorPropsProp);
|
|
152
|
-
const selectedValue = value !== null || displayEmpty ? renderValue(value) : null;
|
|
153
|
-
const valueId = `${id}-value`;
|
|
154
|
-
const labelId = `${id}-label`;
|
|
155
|
-
let menu = null;
|
|
156
|
-
const baseMenuProps = {
|
|
157
|
-
onExitComplete: () => {
|
|
158
|
-
setDidMenuExit(true);
|
|
159
|
-
},
|
|
160
|
-
placement: DEFAULT_PLACEMENT,
|
|
161
|
-
open,
|
|
162
|
-
anchorEl,
|
|
163
|
-
PopperProps: {
|
|
164
|
-
offset: 4,
|
|
165
|
-
matchAnchorWidth: true,
|
|
166
|
-
},
|
|
167
|
-
classes: {
|
|
168
|
-
paper: cls('menu'),
|
|
169
|
-
},
|
|
170
|
-
onClose: handleClose,
|
|
171
|
-
};
|
|
172
|
-
const popperProps = combineProps(baseMenuProps.PopperProps, !virtualize
|
|
173
|
-
? MenuProps?.PopperProps
|
|
174
|
-
: virtualizedMenuPropsProp?.PopperProps);
|
|
175
|
-
if (popperProps.matchAnchorWidth) {
|
|
176
|
-
baseMenuProps.classes = combineClasses(baseMenuProps.classes, {
|
|
177
|
-
paper: 'min-w-0',
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
if (!virtualize) {
|
|
181
|
-
menu = (jsx(Menu, { ...baseMenuProps, ...MenuProps, PopperProps: popperProps, classes: combineClasses(baseMenuProps.classes, MenuProps?.classes), motionProps: getYAxisGrowMotion({
|
|
182
|
-
placement: MenuProps?.placement,
|
|
183
|
-
prefersReducedMotion: prefersReducedMotion,
|
|
184
|
-
}), children: jsx(MenuList, { value: value, onChange: handleMenuListChange, nowrap: false, widget: "select", selectMode: selectMode, ...getListboxProps(), children: children }) }));
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
menu = (jsx(MenuContext.Provider, { value: virtualizedMenuContextValue, children: jsx(MenuItemSelectContext.Provider, { value: virtualizedContextValue, children: jsx(VirtualizedMenu, { ...baseMenuProps, ...virtualizedMenuPropsProp, PopperProps: popperProps, classes: combineClasses(baseMenuProps.classes, virtualizedMenuPropsProp?.classes), initialFocus: handleInitialFocus, data: data, motionProps: getYAxisGrowMotion({
|
|
188
|
-
placement: virtualizedMenuPropsProp?.placement,
|
|
189
|
-
prefersReducedMotion: prefersReducedMotion,
|
|
190
|
-
}), children: children }) }) }));
|
|
191
|
-
}
|
|
192
|
-
return (jsxs(Fragment, { children: [jsxs(FormField, { disabled: disabled, required: required, variant: variant, error: error, focused: open || (!open && !didMenuExit), htmlFor: id, label: label, labelProps: {
|
|
193
|
-
id: labelId,
|
|
194
|
-
}, ref: ref, contentRef: formFieldContentRef, helperText: helperText, FormHelperTextProps: { id: helperTextId, ...FormHelperTextProps }, className: cls('root', { error }), classes: {
|
|
195
|
-
outlined: cls('outlined'),
|
|
196
|
-
standard: cls('standard'),
|
|
197
|
-
contained: cls('contained'),
|
|
198
|
-
content: cls('content'),
|
|
199
|
-
}, size: size, ...rest, children: [jsxs("button", { className: cls('selector', `${variant}-selector`, `${variant}-selector-${size}`, {
|
|
200
|
-
expanded: open,
|
|
201
|
-
}), type: 'button', disabled: disabled, "aria-labelledby": label ? `${labelId} ${valueId}` : valueId, "aria-describedby": helperTextId, ...selectorProps, id: id, children: [selectedValue ? (jsx("span", { id: valueId, "aria-live": "polite", className: cls('value'), title: getTitle(selectedValue), children: selectedValue })) : (jsx("span", { id: valueId, className: cls('placeholder'), title: getTitle(placeholder), children: placeholder })), jsx(Squircle, { className: cls('chevron'), interactive: false, children: jsx(ExpandCollapseCaret, { size: 'small', expanded: open }) })] }), jsx("input", { ref: inputRef, name: name, value: `${value}`, disabled: disabled, className: cls('native-input'), tabIndex: -1, "aria-hidden": true, "aria-invalid": error, onChange: handleInputChange, ...inputProps })] }), anchorEl && menu] }));
|
|
202
|
-
});
|
|
203
|
-
Select.displayName = 'SuiSelect';
|
|
204
|
-
function getYAxisGrowMotion(params) {
|
|
205
|
-
const { placement = DEFAULT_PLACEMENT, ...rest } = params;
|
|
206
|
-
let verticalTransformOrigin = 'top';
|
|
207
|
-
if (placement === 'top') {
|
|
208
|
-
verticalTransformOrigin = 'bottom';
|
|
209
|
-
}
|
|
210
|
-
return getGrow({
|
|
211
|
-
...rest,
|
|
212
|
-
direction: 'y',
|
|
213
|
-
transformOrigin: {
|
|
214
|
-
vertical: verticalTransformOrigin,
|
|
215
|
-
horizontal: 'center',
|
|
216
|
-
},
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export { Select as S, useSelect as u };
|