@ringcentral/spring-ui 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Accordion.js +64 -0
- package/AccordionHeader.js +33 -0
- package/Alert.js +28 -0
- package/Animation.js +46 -0
- package/Announcement.js +48 -0
- package/Autocomplete.js +1767 -0
- package/Avatar.js +105 -0
- package/AvatarGroup.js +9 -0
- package/Backdrop.js +9 -0
- package/Badge.js +15 -0
- package/Block.js +20 -0
- package/BlockHeader.js +18 -0
- package/BottomNavigation.js +145 -0
- package/BottomNavigationItem.js +30 -0
- package/Button.js +24 -0
- package/CallButton.js +39 -0
- package/Checkbox.js +55 -0
- package/Chip.js +26 -0
- package/CircularProgressIndicator.js +10 -0
- package/ClickAwayListener.js +1 -0
- package/ComponentsProps.js +1 -0
- package/DatePicker.js +485 -0
- package/DateUtilsContext.js +56 -0
- package/Dialer.js +587 -0
- package/Dialog.js +62 -0
- package/Divider.js +9 -0
- package/DragHandle.js +8 -0
- package/Drawer.js +19 -0
- package/Dropdown.js +132 -0
- package/EmptyState.js +17 -0
- package/FabButton.js +32 -0
- package/FocusTrap.js +48 -0
- package/FormField.js +10 -0
- package/FormLabel.js +9 -0
- package/Icon.js +9 -0
- package/IconButton.js +26 -0
- package/IconButtonGroup.js +18 -0
- package/InlineEditable.js +98 -0
- package/LICENSE +22 -0
- package/LinearProgressIndicator.js +44 -0
- package/Link.js +18 -0
- package/List.js +11 -0
- package/ListItem.js +22 -0
- package/ListItemText.js +18 -0
- package/ListNavigation.js +57 -0
- package/Menu.js +23 -0
- package/MenuActions.js +21 -0
- package/MenuDivider.js +10 -0
- package/MenuFooter.js +18 -0
- package/MenuHeader.js +18 -0
- package/MenuItem.js +32 -0
- package/MenuItemText.js +9 -0
- package/MenuList.js +33 -0
- package/Modal.js +16 -0
- package/NestedMenuContext.js +23 -0
- package/Option.js +46 -0
- package/Overlap.js +9 -0
- package/PageHeader.js +56 -0
- package/PickerTextField.js +33 -0
- package/Popover.js +21 -0
- package/Popper.js +127 -0
- package/PopperPaper.js +10 -0
- package/Portal.js +1 -0
- package/README.md +76 -0
- package/Radio.js +34 -0
- package/RadioGroup.js +29 -0
- package/Rating.js +235 -0
- package/Select.js +40 -0
- package/SingleFilter.js +130 -0
- package/Skeleton.js +32 -0
- package/Slider.js +110 -0
- package/Snackbar.js +118 -0
- package/SortableList.js +17 -0
- package/SortableListDndContext.js +49 -0
- package/SortableListItem.js +69 -0
- package/SortableVirtualizedList.js +36 -0
- package/SplitButton.js +173 -0
- package/Squircle.js +9 -0
- package/StatusIndicator.js +11 -0
- package/Step.js +65 -0
- package/StepButton.js +41 -0
- package/StepConnector.js +10 -0
- package/StepContent.js +53 -0
- package/StepIcon.js +11 -0
- package/StepLabel.js +14 -0
- package/Stepper.js +37 -0
- package/SubMenu.js +142 -0
- package/SwipeableDrawer.js +742 -0
- package/Switch.js +43 -0
- package/Tab.js +103 -0
- package/TabContext.js +34 -0
- package/TabPanel.js +26 -0
- package/Table.js +24 -0
- package/TableBody.js +20 -0
- package/TableCell.js +86 -0
- package/TableContainer.js +16 -0
- package/TableFooter.js +16 -0
- package/TableHead.js +24 -0
- package/TablePagination.js +122 -0
- package/TableRow.js +37 -0
- package/Tabs.js +827 -0
- package/Tag.js +28 -0
- package/Text.js +61 -0
- package/TextField.js +29 -0
- package/Textarea.js +67 -0
- package/TimePicker.js +600 -0
- package/Tooltip.js +23 -0
- package/Tray.js +13 -0
- package/TrayMenu.js +60 -0
- package/VirtualizedList.js +291 -0
- package/VirtualizedMenu.js +28 -0
- package/VisuallyHidden.js +8 -0
- package/chunks/AccordionContext.js +6 -0
- package/chunks/Alert.js +47 -0
- package/chunks/AvatarGroup.js +22 -0
- package/chunks/Backdrop.js +18 -0
- package/chunks/Badge.js +32 -0
- package/chunks/BottomNavigationItem.js +37 -0
- package/chunks/Button.js +89 -0
- package/chunks/Chip.js +78 -0
- package/chunks/CircularProgressIndicator.js +62 -0
- package/chunks/Divider.js +19 -0
- package/chunks/DragHandle.js +11 -0
- package/chunks/Drawer.js +61 -0
- package/chunks/ExpandCollapseCaret.js +24 -0
- package/chunks/FormLabel.js +27 -0
- package/chunks/Icon.js +25 -0
- package/chunks/IconButtonLabel.js +69 -0
- package/chunks/List.js +22 -0
- package/chunks/ListItem.js +86 -0
- package/chunks/Menu.js +41 -0
- package/chunks/MenuDivider.js +15 -0
- package/chunks/MenuItemText.js +16 -0
- package/chunks/MenuList.js +49 -0
- package/chunks/Modal.js +88 -0
- package/chunks/Overlap.js +25 -0
- package/chunks/PickerTextField.js +75 -0
- package/chunks/Popover.js +58 -0
- package/chunks/PopperPaper.js +15 -0
- package/chunks/RadioGroup.context.js +19 -0
- package/chunks/Select.js +257 -0
- package/chunks/ShowHideEye.js +56 -0
- package/chunks/SlideIn.js +19 -0
- package/chunks/SortableArrow.js +73 -0
- package/chunks/Squircle.js +38 -0
- package/chunks/StatusIndicator.js +19 -0
- package/chunks/StepConnector.js +21 -0
- package/chunks/StepIcon.js +45 -0
- package/chunks/StepLabel.js +29 -0
- package/chunks/StepperContext.js +16 -0
- package/chunks/TableContext.js +6 -0
- package/chunks/Tablelvl2Context.js +6 -0
- package/chunks/TabsContext.js +6 -0
- package/chunks/TextField.js +111 -0
- package/chunks/Tooltip.js +253 -0
- package/chunks/VirtualizedMenu.js +216 -0
- package/chunks/VisuallyHidden.js +12 -0
- package/chunks/getFade.js +23 -0
- package/chunks/getGrow.js +70 -0
- package/chunks/getSlideIn.js +30 -0
- package/chunks/useFocusTrapStack.js +44 -0
- package/chunks/useHelperTextId.js +46 -0
- package/chunks/useListNavigation.js +211 -0
- package/chunks/useMenuItemSelect.js +252 -0
- package/chunks/useMotionSafeTransition.js +13 -0
- package/chunks/useNestedMenuItem.js +16 -0
- package/chunks/useNestedParentMenu.js +54 -0
- package/chunks/usePrefersReducedMotion.js +42 -0
- package/chunks/useTooltipForceHide.js +31 -0
- package/chunks/useTrayNavigate.js +151 -0
- package/chunks/withTooltip.js +15 -0
- package/index.css +10891 -0
- package/index.d.ts +1 -0
- package/index.js +191 -0
- package/package.json +41 -0
- package/src/Accordion/Accordion.classes.d.ts +7 -0
- package/src/Accordion/Accordion.d.ts +5 -0
- package/src/Accordion/Accordion.type.d.ts +31 -0
- package/src/Accordion/AccordionContext.d.ts +9 -0
- package/src/Accordion/index.d.ts +4 -0
- package/src/AccordionHeader/AccordionHeader.classes.d.ts +7 -0
- package/src/AccordionHeader/AccordionHeader.d.ts +5 -0
- package/src/AccordionHeader/AccordionHeader.type.d.ts +25 -0
- package/src/AccordionHeader/index.d.ts +3 -0
- package/src/Alert/Alert.classes.d.ts +8 -0
- package/src/Alert/Alert.d.ts +7 -0
- package/src/Alert/Alert.type.d.ts +56 -0
- package/src/Alert/AlertTitle.classes.d.ts +7 -0
- package/src/Alert/index.d.ts +4 -0
- package/src/Animation/components/ExpandCollapseCaret/ExpandCollapseCaret.classes.d.ts +7 -0
- package/src/Animation/components/ExpandCollapseCaret/ExpandCollapseCaret.d.ts +17 -0
- package/src/Animation/components/ExpandCollapseCaret/index.d.ts +2 -0
- package/src/Animation/components/Fade/Fade.d.ts +5 -0
- package/src/Animation/components/Fade/getFade.d.ts +4 -0
- package/src/Animation/components/Fade/index.d.ts +2 -0
- package/src/Animation/components/Grow/Grow.d.ts +5 -0
- package/src/Animation/components/Grow/getGrow.d.ts +19 -0
- package/src/Animation/components/Grow/index.d.ts +2 -0
- package/src/Animation/components/ShowHideEye/ShowHideEye.classes.d.ts +7 -0
- package/src/Animation/components/ShowHideEye/ShowHideEye.d.ts +14 -0
- package/src/Animation/components/ShowHideEye/index.d.ts +2 -0
- package/src/Animation/components/SlideIn/SlideIn.d.ts +5 -0
- package/src/Animation/components/SlideIn/getSlideIn.d.ts +9 -0
- package/src/Animation/components/SlideIn/index.d.ts +2 -0
- package/src/Animation/components/SortableArrow/SortableArrow.classes.d.ts +7 -0
- package/src/Animation/components/SortableArrow/SortableArrow.d.ts +9 -0
- package/src/Animation/components/SortableArrow/index.d.ts +2 -0
- package/src/Animation/components/index.d.ts +7 -0
- package/src/Animation/components/types.d.ts +9 -0
- package/src/Animation/hooks/__mocks__/MatchMedia.mock.d.ts +12 -0
- package/src/Animation/hooks/index.d.ts +2 -0
- package/src/Animation/hooks/useMotionSafeTransition/index.d.ts +1 -0
- package/src/Animation/hooks/useMotionSafeTransition/useMotionSafeTransition.d.ts +10 -0
- package/src/Animation/hooks/usePrefersReducedMotion/index.d.ts +1 -0
- package/src/Animation/hooks/usePrefersReducedMotion/usePrefersReducedMotion.d.ts +1 -0
- package/src/Animation/index.d.ts +2 -0
- package/src/Announcement/Announcement.classes.d.ts +8 -0
- package/src/Announcement/Announcement.d.ts +5 -0
- package/src/Announcement/Announcement.type.d.ts +4 -0
- package/src/Announcement/index.d.ts +3 -0
- package/src/Autocomplete/Autocomplete.classes.d.ts +14 -0
- package/src/Autocomplete/Autocomplete.d.ts +11 -0
- package/src/Autocomplete/Autocomplete.type.d.ts +141 -0
- package/src/Autocomplete/SuggestionList/SuggestionList.classes.d.ts +7 -0
- package/src/Autocomplete/SuggestionList/SuggestionList.d.ts +144 -0
- package/src/Autocomplete/SuggestionList/SuggestionListItem.d.ts +28 -0
- package/src/Autocomplete/SuggestionList/index.d.ts +4 -0
- package/src/Autocomplete/SuggestionList/utils/SuggestionListItem.d.ts +33 -0
- package/src/Autocomplete/SuggestionList/utils/index.d.ts +5 -0
- package/src/Autocomplete/SuggestionList/utils/useDynamicHeight.d.ts +20 -0
- package/src/Autocomplete/SuggestionList/utils/useHighlightScroll.d.ts +33 -0
- package/src/Autocomplete/SuggestionList/utils/useSuggestionList.d.ts +101 -0
- package/src/Autocomplete/SuggestionList/utils/useSuggestionListGroup.d.ts +71 -0
- package/src/Autocomplete/index.d.ts +6 -0
- package/src/Autocomplete/useAutocomplete.d.ts +640 -0
- package/src/Autocomplete/useAutocompleteTag.d.ts +599 -0
- package/src/Avatar/Avatar.classes.d.ts +10 -0
- package/src/Avatar/Avatar.d.ts +4 -0
- package/src/Avatar/Avatar.type.d.ts +91 -0
- package/src/Avatar/index.d.ts +3 -0
- package/src/AvatarGroup/AvatarGroup.classes.d.ts +7 -0
- package/src/AvatarGroup/AvatarGroup.d.ts +6 -0
- package/src/AvatarGroup/AvatarGroup.type.d.ts +21 -0
- package/src/AvatarGroup/index.d.ts +3 -0
- package/src/Backdrop/Backdrop.classes.d.ts +7 -0
- package/src/Backdrop/Backdrop.d.ts +5 -0
- package/src/Backdrop/Backdrop.type.d.ts +9 -0
- package/src/Backdrop/index.d.ts +3 -0
- package/src/Badge/Badge.classes.d.ts +11 -0
- package/src/Badge/Badge.d.ts +8 -0
- package/src/Badge/Badge.type.d.ts +52 -0
- package/src/Badge/index.d.ts +3 -0
- package/src/Block/Block.classes.d.ts +8 -0
- package/src/Block/Block.d.ts +4 -0
- package/src/Block/Block.type.d.ts +44 -0
- package/src/Block/index.d.ts +3 -0
- package/src/BlockHeader/BlockHeader.classes.d.ts +7 -0
- package/src/BlockHeader/BlockHeader.d.ts +4 -0
- package/src/BlockHeader/BlockHeader.type.d.ts +19 -0
- package/src/BlockHeader/index.d.ts +3 -0
- package/src/BottomNavigation/BottomNavigation.classes.d.ts +7 -0
- package/src/BottomNavigation/BottomNavigation.d.ts +4 -0
- package/src/BottomNavigation/BottomNavigation.type.d.ts +62 -0
- package/src/BottomNavigation/BottomNavigationContext.d.ts +9 -0
- package/src/BottomNavigation/BottomNavigationGroup/BottomNavigationGroup.classes.d.ts +7 -0
- package/src/BottomNavigation/BottomNavigationGroup/BottomNavigationGroup.d.ts +5 -0
- package/src/BottomNavigation/BottomNavigationGroup/BottomNavigationGroup.type.d.ts +3 -0
- package/src/BottomNavigation/BottomNavigationGroup/index.d.ts +3 -0
- package/src/BottomNavigation/index.d.ts +5 -0
- package/src/BottomNavigationItem/BottomNavigationItem.classes.d.ts +7 -0
- package/src/BottomNavigationItem/BottomNavigationItem.d.ts +4 -0
- package/src/BottomNavigationItem/BottomNavigationItem.type.d.ts +63 -0
- package/src/BottomNavigationItem/index.d.ts +3 -0
- package/src/Button/Button.classes.d.ts +8 -0
- package/src/Button/Button.d.ts +6 -0
- package/src/Button/Button.type.d.ts +57 -0
- package/src/Button/index.d.ts +3 -0
- package/src/CallButton/CallButton.classes.d.ts +7 -0
- package/src/CallButton/CallButton.d.ts +4 -0
- package/src/CallButton/CallButton.type.d.ts +19 -0
- package/src/CallButton/index.d.ts +3 -0
- package/src/Checkbox/Checkbox.classes.d.ts +8 -0
- package/src/Checkbox/Checkbox.d.ts +13 -0
- package/src/Checkbox/Checkbox.type.d.ts +30 -0
- package/src/Checkbox/index.d.ts +3 -0
- package/src/Chip/Chip.classes.d.ts +7 -0
- package/src/Chip/Chip.d.ts +4 -0
- package/src/Chip/Chip.type.d.ts +65 -0
- package/src/Chip/index.d.ts +3 -0
- package/src/CircularProgressIndicator/CircularProgressIndicator.classes.d.ts +10 -0
- package/src/CircularProgressIndicator/CircularProgressIndicator.d.ts +5 -0
- package/src/CircularProgressIndicator/CircularProgressIndicator.type.d.ts +32 -0
- package/src/CircularProgressIndicator/index.d.ts +3 -0
- package/src/ClickAwayListener/index.d.ts +2 -0
- package/src/ComponentsProps.d.ts +207 -0
- package/src/DatePicker/Calendar.d.ts +41 -0
- package/src/DatePicker/DatePicker.classes.d.ts +7 -0
- package/src/DatePicker/DatePicker.context.d.ts +6 -0
- package/src/DatePicker/DatePicker.d.ts +6 -0
- package/src/DatePicker/DatePicker.type.d.ts +36 -0
- package/src/DatePicker/DatePickerHeader.d.ts +27 -0
- package/src/DatePicker/Day.d.ts +23 -0
- package/src/DatePicker/HearderAction.d.ts +3 -0
- package/src/DatePicker/SlideDirection.d.ts +1 -0
- package/src/DatePicker/Year.d.ts +21 -0
- package/src/DatePicker/Years.d.ts +21 -0
- package/src/DatePicker/index.d.ts +12 -0
- package/src/DatePicker/utils/DatePickerAriaLabelUtils.d.ts +16 -0
- package/src/DatePicker/utils/DatePickerUtils.d.ts +13 -0
- package/src/DatePicker/utils/findClosestEnabledDate.d.ts +13 -0
- package/src/DatePicker/utils/index.d.ts +3 -0
- package/src/DateUtilsContext/DateUtilsContext.d.ts +22 -0
- package/src/DateUtilsContext/index.d.ts +1 -0
- package/src/Dialer/DialDelete/DialDelete.d.ts +14 -0
- package/src/Dialer/DialDelete/index.d.ts +1 -0
- package/src/Dialer/DialPad/DialPad.classes.d.ts +7 -0
- package/src/Dialer/DialPad/DialPad.d.ts +143 -0
- package/src/Dialer/DialPad/assets/DialerPadSoundsMPEG.d.ts +15 -0
- package/src/Dialer/DialPad/assets/DialerPadSoundsOGG.d.ts +15 -0
- package/src/Dialer/DialPad/assets/index.d.ts +3 -0
- package/src/Dialer/DialPad/index.d.ts +4 -0
- package/src/Dialer/DialPad/utils/DialPadUtils.d.ts +16 -0
- package/src/Dialer/DialPad/utils/index.d.ts +4 -0
- package/src/Dialer/DialPad/utils/types.d.ts +11 -0
- package/src/Dialer/DialPad/utils/useDialKeyboard.d.ts +16 -0
- package/src/Dialer/DialPad/utils/useKeyAudio.d.ts +15 -0
- package/src/Dialer/DialPadButton/DialPadButton.classes.d.ts +7 -0
- package/src/Dialer/DialPadButton/DialPadButton.d.ts +27 -0
- package/src/Dialer/DialPadButton/index.d.ts +2 -0
- package/src/Dialer/DialTextField/DialTextField.d.ts +37 -0
- package/src/Dialer/DialTextField/index.d.ts +2 -0
- package/src/Dialer/DialTextField/utils/getDialPadValueOnlyRegex.d.ts +4 -0
- package/src/Dialer/DialTextField/utils/index.d.ts +2 -0
- package/src/Dialer/DialTextField/utils/useFixedEndSelection.d.ts +10 -0
- package/src/Dialer/Dialer.d.ts +5 -0
- package/src/Dialer/index.d.ts +6 -0
- package/src/Dialer/utils/DialerContext.d.ts +13 -0
- package/src/Dialer/utils/index.d.ts +1 -0
- package/src/Dialog/Dialog.classes.d.ts +29 -0
- package/src/Dialog/Dialog.d.ts +8 -0
- package/src/Dialog/Dialog.type.d.ts +26 -0
- package/src/Dialog/index.d.ts +3 -0
- package/src/Divider/Divider.classes.d.ts +10 -0
- package/src/Divider/Divider.d.ts +4 -0
- package/src/Divider/Divider.type.d.ts +35 -0
- package/src/Divider/index.d.ts +3 -0
- package/src/DragHandle/DragHandle.classes.d.ts +8 -0
- package/src/DragHandle/DragHandle.d.ts +4 -0
- package/src/DragHandle/DragHandle.type.d.ts +17 -0
- package/src/DragHandle/index.d.ts +3 -0
- package/src/Drawer/Drawer.classes.d.ts +10 -0
- package/src/Drawer/Drawer.d.ts +33 -0
- package/src/Drawer/Drawer.type.d.ts +107 -0
- package/src/Drawer/index.d.ts +3 -0
- package/src/Dropdown/Dropdown.classes.d.ts +7 -0
- package/src/Dropdown/Dropdown.d.ts +4 -0
- package/src/Dropdown/Dropdown.type.d.ts +96 -0
- package/src/Dropdown/index.d.ts +3 -0
- package/src/EmptyState/EmptyState.classes.d.ts +7 -0
- package/src/EmptyState/EmptyState.d.ts +5 -0
- package/src/EmptyState/EmptyState.type.d.ts +21 -0
- package/src/EmptyState/index.d.ts +3 -0
- package/src/FabButton/FabButton.classes.d.ts +7 -0
- package/src/FabButton/FabButton.d.ts +4 -0
- package/src/FabButton/FabButton.type.d.ts +22 -0
- package/src/FabButton/index.d.ts +3 -0
- package/src/FocusTrap/FocusTrap.d.ts +49 -0
- package/src/FocusTrap/index.d.ts +2 -0
- package/src/FocusTrap/useFocusTrapStack.d.ts +16 -0
- package/src/FormField/FormField.classes.d.ts +9 -0
- package/src/FormField/FormField.d.ts +5 -0
- package/src/FormField/FormField.type.d.ts +46 -0
- package/src/FormField/index.d.ts +4 -0
- package/src/FormField/useHelperTextId.d.ts +30 -0
- package/src/FormLabel/FormLabel.classes.d.ts +10 -0
- package/src/FormLabel/FormLabel.d.ts +5 -0
- package/src/FormLabel/FormLabel.type.d.ts +26 -0
- package/src/FormLabel/FormLabelContext.d.ts +8 -0
- package/src/FormLabel/index.d.ts +4 -0
- package/src/Icon/Icon.classes.d.ts +7 -0
- package/src/Icon/Icon.d.ts +5 -0
- package/src/Icon/Icon.type.d.ts +25 -0
- package/src/Icon/index.d.ts +3 -0
- package/src/IconButton/IconButton.classes.d.ts +8 -0
- package/src/IconButton/IconButton.d.ts +4 -0
- package/src/IconButton/IconButton.type.d.ts +58 -0
- package/src/IconButton/IconButtonLabel.classes.d.ts +7 -0
- package/src/IconButton/IconButtonLabel.d.ts +5 -0
- package/src/IconButton/IconButtonLabel.type.d.ts +12 -0
- package/src/IconButton/index.d.ts +6 -0
- package/src/IconButtonGroup/IconButtonGroup.classes.d.ts +7 -0
- package/src/IconButtonGroup/IconButtonGroup.d.ts +4 -0
- package/src/IconButtonGroup/IconButtonGroup.type.d.ts +22 -0
- package/src/IconButtonGroup/index.d.ts +3 -0
- package/src/InlineEditable/InlineEditable.classes.d.ts +9 -0
- package/src/InlineEditable/InlineEditable.d.ts +5 -0
- package/src/InlineEditable/InlineEditable.type.d.ts +116 -0
- package/src/InlineEditable/index.d.ts +3 -0
- package/src/LinearProgressIndicator/LinearProgressIndicator.classes.d.ts +9 -0
- package/src/LinearProgressIndicator/LinearProgressIndicator.d.ts +5 -0
- package/src/LinearProgressIndicator/LinearProgressIndicator.type.d.ts +46 -0
- package/src/LinearProgressIndicator/index.d.ts +3 -0
- package/src/Link/Link.classes.d.ts +8 -0
- package/src/Link/Link.d.ts +4 -0
- package/src/Link/Link.type.d.ts +22 -0
- package/src/Link/index.d.ts +3 -0
- package/src/List/List.classes.d.ts +7 -0
- package/src/List/List.d.ts +5 -0
- package/src/List/List.type.d.ts +4 -0
- package/src/List/index.d.ts +3 -0
- package/src/ListItem/HoverActions.d.ts +8 -0
- package/src/ListItem/ListItem.classes.d.ts +7 -0
- package/src/ListItem/ListItem.d.ts +5 -0
- package/src/ListItem/ListItem.type.d.ts +58 -0
- package/src/ListItem/index.d.ts +4 -0
- package/src/ListItemText/ListItemText.classes.d.ts +9 -0
- package/src/ListItemText/ListItemText.d.ts +5 -0
- package/src/ListItemText/ListItemText.type.d.ts +33 -0
- package/src/ListItemText/index.d.ts +3 -0
- package/src/ListNavigation/ListNavigationContext.d.ts +8 -0
- package/src/ListNavigation/index.d.ts +3 -0
- package/src/ListNavigation/useItemNavigation.d.ts +9 -0
- package/src/ListNavigation/useListNavigation.d.ts +49 -0
- package/src/Menu/Menu.classes.d.ts +7 -0
- package/src/Menu/Menu.d.ts +5 -0
- package/src/Menu/Menu.type.d.ts +19 -0
- package/src/Menu/MenuContext.d.ts +7 -0
- package/src/Menu/index.d.ts +4 -0
- package/src/MenuActions/MenuActions.classes.d.ts +13 -0
- package/src/MenuActions/MenuActions.d.ts +9 -0
- package/src/MenuActions/MenuActions.type.d.ts +3 -0
- package/src/MenuActions/index.d.ts +3 -0
- package/src/MenuDivider/MenuDivider.classes.d.ts +7 -0
- package/src/MenuDivider/MenuDivider.d.ts +5 -0
- package/src/MenuDivider/MenuDivider.type.d.ts +3 -0
- package/src/MenuDivider/index.d.ts +3 -0
- package/src/MenuFooter/MenuFooter.classes.d.ts +7 -0
- package/src/MenuFooter/MenuFooter.d.ts +5 -0
- package/src/MenuFooter/MenuFooter.type.d.ts +9 -0
- package/src/MenuFooter/index.d.ts +3 -0
- package/src/MenuHeader/MenuHeader.classes.d.ts +7 -0
- package/src/MenuHeader/MenuHeader.d.ts +5 -0
- package/src/MenuHeader/MenuHeader.type.d.ts +18 -0
- package/src/MenuHeader/index.d.ts +3 -0
- package/src/MenuItem/MenuItem.classes.d.ts +7 -0
- package/src/MenuItem/MenuItem.d.ts +5 -0
- package/src/MenuItem/MenuItem.type.d.ts +29 -0
- package/src/MenuItem/MenuItemSelectContext.d.ts +18 -0
- package/src/MenuItem/index.d.ts +7 -0
- package/src/MenuItem/useMenuItem.d.ts +16 -0
- package/src/MenuItem/useMenuItemSelect.d.ts +62 -0
- package/src/MenuItem/useVirtualizedMenuItem.d.ts +15 -0
- package/src/MenuItemText/MenuItemText.classes.d.ts +7 -0
- package/src/MenuItemText/MenuItemText.d.ts +5 -0
- package/src/MenuItemText/MenuItemText.type.d.ts +27 -0
- package/src/MenuItemText/index.d.ts +3 -0
- package/src/MenuList/MenuList.classes.d.ts +7 -0
- package/src/MenuList/MenuList.d.ts +4 -0
- package/src/MenuList/MenuList.type.d.ts +16 -0
- package/src/MenuList/MenuListContext.d.ts +12 -0
- package/src/MenuList/index.d.ts +4 -0
- package/src/Modal/InnerModal.d.ts +18 -0
- package/src/Modal/InnerModal.type.d.ts +23 -0
- package/src/Modal/Modal.classes.d.ts +7 -0
- package/src/Modal/Modal.d.ts +24 -0
- package/src/Modal/Modal.type.d.ts +19 -0
- package/src/Modal/ModalContext.d.ts +10 -0
- package/src/Modal/index.d.ts +6 -0
- package/src/NestedMenuContext/NestedMenuContext.d.ts +11 -0
- package/src/NestedMenuContext/index.d.ts +4 -0
- package/src/NestedMenuContext/useNestedChildMenu.d.ts +6 -0
- package/src/NestedMenuContext/useNestedMenuItem.d.ts +5 -0
- package/src/NestedMenuContext/useNestedParentMenu.d.ts +8 -0
- package/src/Option/Option.d.ts +4 -0
- package/src/Option/Option.type.d.ts +7 -0
- package/src/Option/index.d.ts +2 -0
- package/src/Overlap/Overlap.classes.d.ts +7 -0
- package/src/Overlap/Overlap.d.ts +4 -0
- package/src/Overlap/Overlap.type.d.ts +30 -0
- package/src/Overlap/index.d.ts +3 -0
- package/src/PageHeader/PageHeader.classes.d.ts +32 -0
- package/src/PageHeader/PageHeader.d.ts +9 -0
- package/src/PageHeader/PageHeader.type.d.ts +14 -0
- package/src/PageHeader/index.d.ts +3 -0
- package/src/PickerTextField/PickerTextField.classes.d.ts +7 -0
- package/src/PickerTextField/PickerTextField.d.ts +5 -0
- package/src/PickerTextField/PickerTextField.type.d.ts +30 -0
- package/src/PickerTextField/index.d.ts +3 -0
- package/src/Popover/Popover.classes.d.ts +7 -0
- package/src/Popover/Popover.d.ts +5 -0
- package/src/Popover/Popover.type.d.ts +50 -0
- package/src/Popover/index.d.ts +3 -0
- package/src/Popper/Popper.d.ts +4 -0
- package/src/Popper/Popper.type.d.ts +92 -0
- package/src/Popper/index.d.ts +2 -0
- package/src/PopperPaper/PopperPaper.classes.d.ts +7 -0
- package/src/PopperPaper/PopperPaper.d.ts +5 -0
- package/src/PopperPaper/PopperPaper.type.d.ts +8 -0
- package/src/PopperPaper/index.d.ts +3 -0
- package/src/Portal/Portal.d.ts +2 -0
- package/src/Portal/index.d.ts +1 -0
- package/src/Radio/Radio.classes.d.ts +7 -0
- package/src/Radio/Radio.d.ts +12 -0
- package/src/Radio/Radio.type.d.ts +16 -0
- package/src/Radio/index.d.ts +3 -0
- package/src/RadioGroup/RadioGroup.classes.d.ts +7 -0
- package/src/RadioGroup/RadioGroup.context.d.ts +15 -0
- package/src/RadioGroup/RadioGroup.d.ts +5 -0
- package/src/RadioGroup/RadioGroup.type.d.ts +14 -0
- package/src/RadioGroup/index.d.ts +4 -0
- package/src/Rating/Rating.classes.d.ts +7 -0
- package/src/Rating/Rating.d.ts +5 -0
- package/src/Rating/Rating.type.d.ts +106 -0
- package/src/Rating/RatingItem.d.ts +3 -0
- package/src/Rating/index.d.ts +5 -0
- package/src/Rating/utils.d.ts +5 -0
- package/src/Select/Select.classes.d.ts +11 -0
- package/src/Select/Select.d.ts +4 -0
- package/src/Select/Select.type.d.ts +118 -0
- package/src/Select/index.d.ts +4 -0
- package/src/Select/useSelect.d.ts +16 -0
- package/src/SingleFilter/FilterButton/FilterButton.classes.d.ts +7 -0
- package/src/SingleFilter/FilterButton/FilterButton.d.ts +5 -0
- package/src/SingleFilter/FilterButton/FilterButton.type.d.ts +27 -0
- package/src/SingleFilter/FilterButton/index.d.ts +3 -0
- package/src/SingleFilter/SingleFilter.classes.d.ts +7 -0
- package/src/SingleFilter/SingleFilter.d.ts +5 -0
- package/src/SingleFilter/SingleFilter.type.d.ts +44 -0
- package/src/SingleFilter/index.d.ts +4 -0
- package/src/Skeleton/Skeleton.classes.d.ts +7 -0
- package/src/Skeleton/Skeleton.d.ts +5 -0
- package/src/Skeleton/Skeleton.type.d.ts +6 -0
- package/src/Skeleton/SkeletonContainer/SkeletonContainer.classes.d.ts +7 -0
- package/src/Skeleton/SkeletonContainer/SkeletonContainer.d.ts +5 -0
- package/src/Skeleton/SkeletonContainer/SkeletonContainer.type.d.ts +11 -0
- package/src/Skeleton/SkeletonContainer/index.d.ts +3 -0
- package/src/Skeleton/index.d.ts +4 -0
- package/src/Slider/Slider.classes.d.ts +13 -0
- package/src/Slider/Slider.d.ts +10 -0
- package/src/Slider/Slider.type.d.ts +137 -0
- package/src/Slider/SliderThumb.d.ts +16 -0
- package/src/Slider/index.d.ts +3 -0
- package/src/Slider/utils.d.ts +1 -0
- package/src/Snackbar/Snackbar.classes.d.ts +7 -0
- package/src/Snackbar/Snackbar.d.ts +5 -0
- package/src/Snackbar/Snackbar.hook.d.ts +1 -0
- package/src/Snackbar/Snackbar.type.d.ts +27 -0
- package/src/Snackbar/SnackbarContent/SnackbarContent.classes.d.ts +8 -0
- package/src/Snackbar/SnackbarContent/SnackbarContent.d.ts +5 -0
- package/src/Snackbar/SnackbarContent/SnackbarContent.type.d.ts +4 -0
- package/src/Snackbar/SnackbarContent/index.d.ts +3 -0
- package/src/Snackbar/index.d.ts +5 -0
- package/src/SortableList/SortableList.d.ts +3 -0
- package/src/SortableList/SortableList.type.d.ts +20 -0
- package/src/SortableList/index.d.ts +2 -0
- package/src/SortableListDndContext/DndKeyboardBlocker.d.ts +2 -0
- package/src/SortableListDndContext/SortableListDndContext.d.ts +4 -0
- package/src/SortableListDndContext/SortableListDndContext.type.d.ts +5 -0
- package/src/SortableListDndContext/index.d.ts +5 -0
- package/src/SortableListDndContext/useSortableListDndContext.d.ts +2 -0
- package/src/SortableListDndContext/utils.d.ts +1 -0
- package/src/SortableListItem/SortableListItem.d.ts +4 -0
- package/src/SortableListItem/SortableListItem.type.d.ts +6 -0
- package/src/SortableListItem/SortableListItemOverlay.d.ts +4 -0
- package/src/SortableListItem/SortableListItemOverlay.type.d.ts +8 -0
- package/src/SortableListItem/index.d.ts +4 -0
- package/src/SortableVirtualizedList/SortableVirtualizedList.d.ts +3 -0
- package/src/SortableVirtualizedList/SortableVirtualizedList.type.d.ts +19 -0
- package/src/SortableVirtualizedList/index.d.ts +2 -0
- package/src/SplitButton/SplitButton.classes.d.ts +8 -0
- package/src/SplitButton/SplitButton.d.ts +5 -0
- package/src/SplitButton/SplitButton.type.d.ts +37 -0
- package/src/SplitButton/index.d.ts +3 -0
- package/src/Squircle/Squircle.d.ts +4 -0
- package/src/Squircle/Squircle.type.d.ts +19 -0
- package/src/Squircle/index.d.ts +3 -0
- package/src/Squircle/squircle.classes.d.ts +7 -0
- package/src/StatusIndicator/StatusIndicator.classes.d.ts +7 -0
- package/src/StatusIndicator/StatusIndicator.d.ts +8 -0
- package/src/StatusIndicator/StatusIndicator.type.d.ts +14 -0
- package/src/StatusIndicator/index.d.ts +3 -0
- package/src/Step/Step.classes.d.ts +7 -0
- package/src/Step/Step.d.ts +4 -0
- package/src/Step/Step.type.d.ts +50 -0
- package/src/Step/StepContext.d.ts +22 -0
- package/src/Step/index.d.ts +4 -0
- package/src/StepButton/StepButton.classes.d.ts +7 -0
- package/src/StepButton/StepButton.d.ts +4 -0
- package/src/StepButton/StepButton.type.d.ts +34 -0
- package/src/StepButton/index.d.ts +3 -0
- package/src/StepConnector/StepConnector.classes.d.ts +7 -0
- package/src/StepConnector/StepConnector.d.ts +5 -0
- package/src/StepConnector/StepConnector.type.d.ts +3 -0
- package/src/StepConnector/index.d.ts +3 -0
- package/src/StepContent/StepContent.classes.d.ts +7 -0
- package/src/StepContent/StepContent.d.ts +5 -0
- package/src/StepContent/StepContent.type.d.ts +14 -0
- package/src/StepContent/index.d.ts +3 -0
- package/src/StepIcon/StepIcon.classes.d.ts +7 -0
- package/src/StepIcon/StepIcon.d.ts +5 -0
- package/src/StepIcon/StepIcon.type.d.ts +38 -0
- package/src/StepIcon/index.d.ts +3 -0
- package/src/StepLabel/StepLabel.classes.d.ts +10 -0
- package/src/StepLabel/StepLabel.d.ts +5 -0
- package/src/StepLabel/StepLabel.type.d.ts +36 -0
- package/src/StepLabel/index.d.ts +3 -0
- package/src/Stepper/Stepper.classes.d.ts +7 -0
- package/src/Stepper/Stepper.d.ts +4 -0
- package/src/Stepper/Stepper.type.d.ts +47 -0
- package/src/Stepper/StepperContext.d.ts +11 -0
- package/src/Stepper/index.d.ts +4 -0
- package/src/SubMenu/PopperMenu.classes.d.ts +7 -0
- package/src/SubMenu/PopperMenu.d.ts +5 -0
- package/src/SubMenu/PopperMenu.type.d.ts +4 -0
- package/src/SubMenu/SubMenu.d.ts +4 -0
- package/src/SubMenu/SubMenu.type.d.ts +6 -0
- package/src/SubMenu/index.d.ts +5 -0
- package/src/SwipeableDrawer/SwipeableDrawer.classes.d.ts +7 -0
- package/src/SwipeableDrawer/SwipeableDrawer.d.ts +31 -0
- package/src/SwipeableDrawer/SwipeableDrawer.types.d.ts +82 -0
- package/src/SwipeableDrawer/hooks/index.d.ts +5 -0
- package/src/SwipeableDrawer/hooks/useDimensions.d.ts +17 -0
- package/src/SwipeableDrawer/hooks/useDrawerGestures.d.ts +151 -0
- package/src/SwipeableDrawer/hooks/useElementSizeObserver.d.ts +10 -0
- package/src/SwipeableDrawer/hooks/useReady.d.ts +4 -0
- package/src/SwipeableDrawer/hooks/useSnapPoints.d.ts +94 -0
- package/src/SwipeableDrawer/index.d.ts +3 -0
- package/src/Switch/Switch.classes.d.ts +7 -0
- package/src/Switch/Switch.d.ts +11 -0
- package/src/Switch/Switch.type.d.ts +19 -0
- package/src/Switch/index.d.ts +3 -0
- package/src/Tab/Tab.classes.d.ts +10 -0
- package/src/Tab/Tab.d.ts +5 -0
- package/src/Tab/Tab.type.d.ts +50 -0
- package/src/Tab/index.d.ts +3 -0
- package/src/TabContext/TabContext.d.ts +20 -0
- package/src/TabContext/TabContext.type.d.ts +13 -0
- package/src/TabContext/index.d.ts +2 -0
- package/src/TabPanel/TabPanel.classes.d.ts +7 -0
- package/src/TabPanel/TabPanel.d.ts +5 -0
- package/src/TabPanel/TabPanel.type.d.ts +18 -0
- package/src/TabPanel/index.d.ts +3 -0
- package/src/Table/Table.classes.d.ts +7 -0
- package/src/Table/Table.d.ts +4 -0
- package/src/Table/Table.type.d.ts +36 -0
- package/src/Table/TableContext.d.ts +8 -0
- package/src/Table/Tablelvl2Context.d.ts +7 -0
- package/src/Table/index.d.ts +5 -0
- package/src/TableBody/TableBody.classes.d.ts +7 -0
- package/src/TableBody/TableBody.d.ts +4 -0
- package/src/TableBody/TableBody.type.d.ts +17 -0
- package/src/TableBody/index.d.ts +3 -0
- package/src/TableCell/TableCell.classes.d.ts +7 -0
- package/src/TableCell/TableCell.d.ts +8 -0
- package/src/TableCell/TableCell.type.d.ts +59 -0
- package/src/TableCell/index.d.ts +3 -0
- package/src/TableContainer/TableContainer.classes.d.ts +8 -0
- package/src/TableContainer/TableContainer.d.ts +4 -0
- package/src/TableContainer/TableContainer.type.d.ts +23 -0
- package/src/TableContainer/index.d.ts +3 -0
- package/src/TableFooter/TableFooter.classes.d.ts +8 -0
- package/src/TableFooter/TableFooter.d.ts +5 -0
- package/src/TableFooter/TableFooter.type.d.ts +9 -0
- package/src/TableFooter/index.d.ts +2 -0
- package/src/TableHead/TableHead.classes.d.ts +7 -0
- package/src/TableHead/TableHead.d.ts +4 -0
- package/src/TableHead/TableHead.type.d.ts +21 -0
- package/src/TableHead/index.d.ts +3 -0
- package/src/TablePagination/TablePagination.classes.d.ts +8 -0
- package/src/TablePagination/TablePagination.d.ts +4 -0
- package/src/TablePagination/TablePagination.type.d.ts +73 -0
- package/src/TablePagination/index.d.ts +2 -0
- package/src/TableRow/TableRow.classes.d.ts +7 -0
- package/src/TableRow/TableRow.d.ts +4 -0
- package/src/TableRow/TableRow.type.d.ts +34 -0
- package/src/TableRow/index.d.ts +3 -0
- package/src/Tabs/TabMoreMenu.d.ts +36 -0
- package/src/Tabs/TabScrollButton.d.ts +21 -0
- package/src/Tabs/Tabs.classes.d.ts +19 -0
- package/src/Tabs/Tabs.d.ts +5 -0
- package/src/Tabs/Tabs.type.d.ts +54 -0
- package/src/Tabs/TabsContext.d.ts +9 -0
- package/src/Tabs/hooks/index.d.ts +2 -0
- package/src/Tabs/hooks/useComputedTabs.d.ts +20 -0
- package/src/Tabs/hooks/useTabsScroller.d.ts +48 -0
- package/src/Tabs/index.d.ts +7 -0
- package/src/Tag/Tag.classes.d.ts +8 -0
- package/src/Tag/Tag.d.ts +5 -0
- package/src/Tag/Tag.type.d.ts +23 -0
- package/src/Tag/index.d.ts +3 -0
- package/src/Text/Text.classes.d.ts +7 -0
- package/src/Text/Text.d.ts +4 -0
- package/src/Text/Text.type.d.ts +34 -0
- package/src/Text/index.d.ts +3 -0
- package/src/TextField/TextField.classes.d.ts +7 -0
- package/src/TextField/TextField.d.ts +5 -0
- package/src/TextField/TextField.type.d.ts +112 -0
- package/src/TextField/index.d.ts +3 -0
- package/src/Textarea/Textarea.classes.d.ts +10 -0
- package/src/Textarea/Textarea.d.ts +5 -0
- package/src/Textarea/Textarea.type.d.ts +26 -0
- package/src/Textarea/index.d.ts +3 -0
- package/src/TimePicker/NumberPicker.d.ts +5 -0
- package/src/TimePicker/NumberPicker.type.d.ts +36 -0
- package/src/TimePicker/PickerView.d.ts +4 -0
- package/src/TimePicker/PickerView.type.d.ts +25 -0
- package/src/TimePicker/SelectionView.d.ts +19 -0
- package/src/TimePicker/TimeButton.d.ts +11 -0
- package/src/TimePicker/TimePicker.classes.d.ts +7 -0
- package/src/TimePicker/TimePicker.context.d.ts +6 -0
- package/src/TimePicker/TimePicker.d.ts +5 -0
- package/src/TimePicker/TimePicker.type.d.ts +30 -0
- package/src/TimePicker/ToggleText.d.ts +5 -0
- package/src/TimePicker/ToggleText.type.d.ts +14 -0
- package/src/TimePicker/constant.d.ts +7 -0
- package/src/TimePicker/index.d.ts +14 -0
- package/src/TimePicker/utils/A11yUtils.d.ts +2 -0
- package/src/TimePicker/utils/TimeBoundary.d.ts +27 -0
- package/src/TimePicker/utils/TimePickerHelper.d.ts +52 -0
- package/src/TimePicker/utils/getNumberPickerBoundary.d.ts +22 -0
- package/src/TimePicker/utils/index.d.ts +4 -0
- package/src/TimePicker/utils/runKeyHandler.d.ts +4 -0
- package/src/Tooltip/Tooltip.d.ts +5 -0
- package/src/Tooltip/Tooltip.type.d.ts +5 -0
- package/src/Tooltip/TooltipTrigger.a11y.d.ts +38 -0
- package/src/Tooltip/TooltipTrigger.d.ts +4 -0
- package/src/Tooltip/TooltipTrigger.type.d.ts +59 -0
- package/src/Tooltip/TooltipView.classes.d.ts +8 -0
- package/src/Tooltip/TooltipView.d.ts +16 -0
- package/src/Tooltip/TooltipView.type.d.ts +44 -0
- package/src/Tooltip/index.d.ts +9 -0
- package/src/Tooltip/useTooltipForceHide.d.ts +8 -0
- package/src/Tooltip/withTooltip/index.d.ts +1 -0
- package/src/Tooltip/withTooltip/withTooltip.d.ts +6 -0
- package/src/Tray/Tray.classes.d.ts +13 -0
- package/src/Tray/Tray.d.ts +5 -0
- package/src/Tray/Tray.type.d.ts +26 -0
- package/src/Tray/TrayContext.d.ts +14 -0
- package/src/Tray/TrayPanel.d.ts +7 -0
- package/src/Tray/hooks/index.d.ts +3 -0
- package/src/Tray/hooks/useTray.d.ts +33 -0
- package/src/Tray/hooks/useTrayNavigate.d.ts +5 -0
- package/src/Tray/hooks/useTrayPanel.d.ts +14 -0
- package/src/Tray/index.d.ts +7 -0
- package/src/Tray/types.d.ts +2 -0
- package/src/TrayMenu/TrayMenu.d.ts +4 -0
- package/src/TrayMenu/TrayMenu.type.d.ts +3 -0
- package/src/TrayMenu/TrayMenuItem.d.ts +9 -0
- package/src/TrayMenu/index.d.ts +3 -0
- package/src/VirtualizedList/VirtualizedItemPropsContext.d.ts +5 -0
- package/src/VirtualizedList/VirtualizedList.d.ts +3 -0
- package/src/VirtualizedList/VirtualizedList.type.d.ts +51 -0
- package/src/VirtualizedList/VirtuosoComponents.d.ts +16 -0
- package/src/VirtualizedList/VirtuosoContextType.d.ts +14 -0
- package/src/VirtualizedList/index.d.ts +5 -0
- package/src/VirtualizedMenu/VirtualizedMenu.classes.d.ts +7 -0
- package/src/VirtualizedMenu/VirtualizedMenu.context.d.ts +6 -0
- package/src/VirtualizedMenu/VirtualizedMenu.d.ts +4 -0
- package/src/VirtualizedMenu/VirtualizedMenu.type.d.ts +35 -0
- package/src/VirtualizedMenu/VirtualizedMenuList.d.ts +6 -0
- package/src/VirtualizedMenu/index.d.ts +5 -0
- package/src/VisuallyHidden/VisuallyHidden.classes.d.ts +7 -0
- package/src/VisuallyHidden/VisuallyHidden.d.ts +5 -0
- package/src/VisuallyHidden/VisuallyHidden.type.d.ts +3 -0
- package/src/VisuallyHidden/index.d.ts +3 -0
- package/src/index.d.ts +112 -0
|
@@ -0,0 +1,742 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useCallback, useEffect, useLayoutEffect, useMemo, useRef, forwardRef, useImperativeHandle } from 'react';
|
|
3
|
+
import { useWindowContext, useEventCallback, useClasses } from '@ringcentral/spring-base';
|
|
4
|
+
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import { D as Drawer } from './chunks/Drawer.js';
|
|
7
|
+
import { D as DragHandle } from './chunks/DragHandle.js';
|
|
8
|
+
import { useMotionValue, animate, useTransform } from 'framer-motion';
|
|
9
|
+
import { rubberbandIfOutOfBounds, useDrag } from '@use-gesture/react';
|
|
10
|
+
import { ResizeObserver } from '@juggle/resize-observer';
|
|
11
|
+
import './chunks/Icon.js';
|
|
12
|
+
import './chunks/usePrefersReducedMotion.js';
|
|
13
|
+
import './chunks/getSlideIn.js';
|
|
14
|
+
import './chunks/Modal.js';
|
|
15
|
+
import '@mui/base';
|
|
16
|
+
import './chunks/getFade.js';
|
|
17
|
+
import './chunks/useFocusTrapStack.js';
|
|
18
|
+
import './chunks/Backdrop.js';
|
|
19
|
+
|
|
20
|
+
var SwipeableDrawer$1 = {"sui-swipeable-drawer-header-drag":"sui-swipeable-drawer-header-drag"};
|
|
21
|
+
|
|
22
|
+
// Keeps track of whether everything is good to go or not, in the most efficient way possible
|
|
23
|
+
function useReady() {
|
|
24
|
+
const [ready, setReady] = useState(false);
|
|
25
|
+
const [readyMap, updateReadyMap] = useState({});
|
|
26
|
+
const registerReady = useCallback((key) => {
|
|
27
|
+
// Register the check we're gonna wait for until it's ready
|
|
28
|
+
updateReadyMap((ready) => ({ ...ready, [key]: false }));
|
|
29
|
+
return () => {
|
|
30
|
+
// Set it to ready
|
|
31
|
+
updateReadyMap((ready) => ({ ...ready, [key]: true }));
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const states = Object.values(readyMap);
|
|
36
|
+
if (states.length === 0) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const isReady = states.every(Boolean);
|
|
40
|
+
if (isReady) {
|
|
41
|
+
setReady(true);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
setReady(false);
|
|
45
|
+
}
|
|
46
|
+
}, [readyMap]);
|
|
47
|
+
return { ready, registerReady };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Hook for determining the size of an element using the Resize Observer API
|
|
51
|
+
const observerOptions = {
|
|
52
|
+
// Respond to changes to padding, happens often on iOS when using env(safe-area-inset-bottom)
|
|
53
|
+
// And the user hides or shows the Safari browser toolbar
|
|
54
|
+
box: 'border-box',
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Hook for determining the size of an element using the Resize Observer API.
|
|
58
|
+
*
|
|
59
|
+
* @param ref - A React ref to an element
|
|
60
|
+
*/
|
|
61
|
+
function useElementSizeObserver(ref, { enabled, resizeSourceRef, }) {
|
|
62
|
+
const [size, setSize] = useState(0);
|
|
63
|
+
const handleResize = useCallback((entries) => {
|
|
64
|
+
// we only observe one element, so accessing the first entry here is fine
|
|
65
|
+
const entry = entries?.[0];
|
|
66
|
+
if (!entry) {
|
|
67
|
+
// Early return if no entry - can happen during observer disconnect
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const el = entry.target;
|
|
71
|
+
if (!el) {
|
|
72
|
+
// Early return if no target element
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// Prefer intrinsic content size to visible height so drag doesn’t change the measured height
|
|
76
|
+
// @juggle/resize-observer provides consistent borderBoxSize access across browsers
|
|
77
|
+
const roBlock = entry?.borderBoxSize?.[0]?.blockSize ?? 0;
|
|
78
|
+
const contentRectH = entry?.contentRect?.height ?? 0;
|
|
79
|
+
const scrollH = el?.scrollHeight ?? 0;
|
|
80
|
+
const offsetH = el?.offsetHeight ?? 0;
|
|
81
|
+
const newSize = Math.max(scrollH, roBlock, contentRectH, offsetH);
|
|
82
|
+
setSize(newSize);
|
|
83
|
+
// Update resize source if provided
|
|
84
|
+
if (resizeSourceRef) {
|
|
85
|
+
resizeSourceRef.current = 'element';
|
|
86
|
+
}
|
|
87
|
+
}, [resizeSourceRef]);
|
|
88
|
+
useLayoutEffect(() => {
|
|
89
|
+
if (!enabled) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
let resizeObserver = null;
|
|
93
|
+
let rafId = 0;
|
|
94
|
+
let initialMeasurementRafId = 0;
|
|
95
|
+
const startObserving = () => {
|
|
96
|
+
const el = ref.current;
|
|
97
|
+
if (!el || !el.isConnected)
|
|
98
|
+
return;
|
|
99
|
+
// @juggle/resize-observer provides cross-browser compatibility and polyfills
|
|
100
|
+
resizeObserver = new ResizeObserver(handleResize);
|
|
101
|
+
resizeObserver.observe(el, observerOptions);
|
|
102
|
+
// Seed an initial measurement in case RO hasn't fired yet
|
|
103
|
+
initialMeasurementRafId = requestAnimationFrame(() => {
|
|
104
|
+
const initial = Math.max(el.scrollHeight, el.offsetHeight, el.getBoundingClientRect().height);
|
|
105
|
+
if (initial > 0) {
|
|
106
|
+
setSize(initial);
|
|
107
|
+
}
|
|
108
|
+
// else keep waiting for RO to update on next ticks
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
// If the element is not yet mounted (e.g. Modal shouldRender=false), keep
|
|
112
|
+
// polling via rAF until it's available, then attach the observer.
|
|
113
|
+
const waitForElement = () => {
|
|
114
|
+
if (ref.current) {
|
|
115
|
+
startObserving();
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
rafId = requestAnimationFrame(waitForElement);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
if (ref.current) {
|
|
122
|
+
startObserving();
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
rafId = requestAnimationFrame(waitForElement);
|
|
126
|
+
}
|
|
127
|
+
return () => {
|
|
128
|
+
if (rafId)
|
|
129
|
+
cancelAnimationFrame(rafId);
|
|
130
|
+
if (initialMeasurementRafId)
|
|
131
|
+
cancelAnimationFrame(initialMeasurementRafId);
|
|
132
|
+
if (resizeObserver) {
|
|
133
|
+
resizeObserver.disconnect();
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}, [ref, handleResize, enabled]);
|
|
137
|
+
return enabled ? size : 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Hook for measuring drawer dimensions
|
|
141
|
+
// Hook for tracking viewport height
|
|
142
|
+
function useMaxHeight(registerReady) {
|
|
143
|
+
const { globalThis } = useWindowContext();
|
|
144
|
+
const setReady = useMemo(() => {
|
|
145
|
+
return registerReady ? registerReady('maxHeight') : undefined;
|
|
146
|
+
}, [registerReady]);
|
|
147
|
+
const [maxHeight, setMaxHeight] = useState(() => globalThis.innerHeight ?? 0);
|
|
148
|
+
const raf = useRef(0);
|
|
149
|
+
const maxReadyCalledRef = useRef(false);
|
|
150
|
+
// Reset the ready flag when setReady changes (drawer reset)
|
|
151
|
+
useLayoutEffect(() => {
|
|
152
|
+
maxReadyCalledRef.current = false;
|
|
153
|
+
}, [setReady]);
|
|
154
|
+
useLayoutEffect(() => {
|
|
155
|
+
const handleResize = () => {
|
|
156
|
+
if (raf.current) {
|
|
157
|
+
// bail to throttle the amount of resize changes
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
// throttle state changes using rAF
|
|
161
|
+
raf.current = requestAnimationFrame(() => {
|
|
162
|
+
// Check if cleanup already ran (raf.current would be 0)
|
|
163
|
+
if (raf.current !== 0) {
|
|
164
|
+
setMaxHeight(globalThis.innerHeight); // ✅ Safe to update
|
|
165
|
+
raf.current = 0;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
globalThis.addEventListener('resize', handleResize);
|
|
170
|
+
setMaxHeight(globalThis.innerHeight);
|
|
171
|
+
// Call setReady exactly once for window height readiness
|
|
172
|
+
if (setReady && !maxReadyCalledRef.current) {
|
|
173
|
+
maxReadyCalledRef.current = true;
|
|
174
|
+
setReady();
|
|
175
|
+
}
|
|
176
|
+
return () => {
|
|
177
|
+
globalThis.removeEventListener('resize', handleResize);
|
|
178
|
+
cancelAnimationFrame(raf.current);
|
|
179
|
+
};
|
|
180
|
+
}, [setReady, globalThis]);
|
|
181
|
+
return maxHeight;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Custom hook to preserve last non-zero height values
|
|
185
|
+
*/
|
|
186
|
+
function usePreservedHeight(currentHeight) {
|
|
187
|
+
const lastHeightRef = useRef(0);
|
|
188
|
+
useLayoutEffect(() => {
|
|
189
|
+
if (currentHeight > 0) {
|
|
190
|
+
lastHeightRef.current = currentHeight;
|
|
191
|
+
}
|
|
192
|
+
}, [currentHeight]);
|
|
193
|
+
return currentHeight > 0 ? currentHeight : lastHeightRef.current;
|
|
194
|
+
}
|
|
195
|
+
function useDimensions({ contentRef, footerEnabled, footerRef, headerEnabled, headerRef, registerReady, resizeSourceRef, open, }) {
|
|
196
|
+
const setReady = useMemo(() => registerReady('contentHeight'), [registerReady]);
|
|
197
|
+
// Do not re-register contentHeight readiness on disconnect; register once above and let
|
|
198
|
+
// the ResizeObserver drive readiness when size > 0. This avoids readiness loops.
|
|
199
|
+
// (Intentionally removed disconnection re-register logic)
|
|
200
|
+
const maxHeight = useMaxHeight(registerReady);
|
|
201
|
+
// Measure all elements - only when drawer is open
|
|
202
|
+
const headerHeight = useElementSizeObserver(headerRef, {
|
|
203
|
+
enabled: open && headerEnabled,
|
|
204
|
+
resizeSourceRef,
|
|
205
|
+
});
|
|
206
|
+
const contentHeight = useElementSizeObserver(contentRef, {
|
|
207
|
+
enabled: open,
|
|
208
|
+
resizeSourceRef,
|
|
209
|
+
});
|
|
210
|
+
const footerHeight = useElementSizeObserver(footerRef, {
|
|
211
|
+
enabled: open && footerEnabled,
|
|
212
|
+
resizeSourceRef,
|
|
213
|
+
});
|
|
214
|
+
// Preserve last non-zero heights to avoid collapsing to 0 when the
|
|
215
|
+
// modal/portal temporarily unmounts or RO reports 0 during transitions
|
|
216
|
+
const effectiveContentHeight = usePreservedHeight(contentHeight);
|
|
217
|
+
const effectiveHeaderHeight = usePreservedHeight(headerHeight);
|
|
218
|
+
const effectiveFooterHeight = usePreservedHeight(footerHeight);
|
|
219
|
+
// When content is measured (>0), mark ready for contentHeight
|
|
220
|
+
useLayoutEffect(() => {
|
|
221
|
+
if (!setReady)
|
|
222
|
+
return;
|
|
223
|
+
const ok = contentHeight > 0;
|
|
224
|
+
if (ok) {
|
|
225
|
+
setReady();
|
|
226
|
+
}
|
|
227
|
+
}, [contentHeight, contentRef, setReady]);
|
|
228
|
+
// Calculate available space for content, ensuring it's never negative
|
|
229
|
+
const availableContentSpace = Math.max(0, maxHeight - effectiveHeaderHeight - effectiveFooterHeight);
|
|
230
|
+
const minHeight = Math.min(availableContentSpace, effectiveContentHeight) +
|
|
231
|
+
effectiveHeaderHeight +
|
|
232
|
+
effectiveFooterHeight;
|
|
233
|
+
return {
|
|
234
|
+
maxHeight,
|
|
235
|
+
minHeight,
|
|
236
|
+
headerHeight,
|
|
237
|
+
footerHeight: effectiveFooterHeight,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Hook for calculating snap points
|
|
242
|
+
function roundAndCheckForNaN(value) {
|
|
243
|
+
const rounded = Math.round(value);
|
|
244
|
+
if (Number.isNaN(rounded)) {
|
|
245
|
+
throw new TypeError(`Found a NaN! Check your snapPoints / snapTo`);
|
|
246
|
+
}
|
|
247
|
+
return rounded;
|
|
248
|
+
}
|
|
249
|
+
// Clamp function with clear NaN handling
|
|
250
|
+
function clamp(number, lower, upper) {
|
|
251
|
+
number = +number;
|
|
252
|
+
lower = +lower;
|
|
253
|
+
upper = +upper;
|
|
254
|
+
// Handle NaN values with sensible defaults
|
|
255
|
+
const safeLower = Number.isNaN(lower) ? 0 : lower;
|
|
256
|
+
const safeUpper = Number.isNaN(upper) ? Number.POSITIVE_INFINITY : upper;
|
|
257
|
+
// Ensure lower <= upper to avoid invalid ranges
|
|
258
|
+
const finalLower = Math.min(safeLower, safeUpper);
|
|
259
|
+
const finalUpper = Math.max(safeLower, safeUpper);
|
|
260
|
+
if (Number.isNaN(number)) {
|
|
261
|
+
return finalLower;
|
|
262
|
+
}
|
|
263
|
+
return Math.min(Math.max(number, finalLower), finalUpper);
|
|
264
|
+
}
|
|
265
|
+
function processSnapPoints(snapPoints, maxHeight) {
|
|
266
|
+
// Validate maxHeight input
|
|
267
|
+
if (!Number.isFinite(maxHeight) || maxHeight <= 0) {
|
|
268
|
+
throw new Error(`Invalid maxHeight: ${maxHeight}. Must be a positive finite number.`);
|
|
269
|
+
}
|
|
270
|
+
// Match React Spring Bottom Sheet implementation exactly
|
|
271
|
+
const safeSnaps = []
|
|
272
|
+
.concat(snapPoints)
|
|
273
|
+
.map(roundAndCheckForNaN);
|
|
274
|
+
const snapPointsDedupedSet = safeSnaps.reduce((acc, snapPoint) => {
|
|
275
|
+
acc.add(clamp(snapPoint, 0, maxHeight));
|
|
276
|
+
return acc;
|
|
277
|
+
}, new Set());
|
|
278
|
+
const processedPoints = Array.from(snapPointsDedupedSet);
|
|
279
|
+
// Handle empty snap points array
|
|
280
|
+
if (processedPoints.length === 0) {
|
|
281
|
+
throw new Error('No valid snap points available. The snapPoints function must return at least one valid number.\n' +
|
|
282
|
+
'Example: snapPoints: ({ minHeight, maxHeight }) => [minHeight, maxHeight]');
|
|
283
|
+
}
|
|
284
|
+
const minSnap = Math.min(...processedPoints);
|
|
285
|
+
if (Number.isNaN(minSnap)) {
|
|
286
|
+
throw new TypeError('minSnap is NaN');
|
|
287
|
+
}
|
|
288
|
+
const maxSnap = Math.max(...processedPoints);
|
|
289
|
+
if (Number.isNaN(maxSnap)) {
|
|
290
|
+
throw new TypeError('maxSnap is NaN');
|
|
291
|
+
}
|
|
292
|
+
return {
|
|
293
|
+
snapPoints: processedPoints,
|
|
294
|
+
minSnap,
|
|
295
|
+
maxSnap,
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function useSnapPoints({ contentRef, footerEnabled, footerRef, getSnapPoints, headerEnabled, headerRef, heightRef, lastSnapRef, ready, registerReady, resizeSourceRef, open, }) {
|
|
299
|
+
const { maxHeight, minHeight, headerHeight, footerHeight } = useDimensions({
|
|
300
|
+
contentRef,
|
|
301
|
+
footerEnabled,
|
|
302
|
+
footerRef,
|
|
303
|
+
headerEnabled,
|
|
304
|
+
headerRef,
|
|
305
|
+
registerReady,
|
|
306
|
+
resizeSourceRef,
|
|
307
|
+
open,
|
|
308
|
+
});
|
|
309
|
+
const { snapPoints, minSnap, maxSnap } = processSnapPoints(ready
|
|
310
|
+
? getSnapPoints({
|
|
311
|
+
height: heightRef.current ?? 0,
|
|
312
|
+
footerHeight,
|
|
313
|
+
headerHeight,
|
|
314
|
+
minHeight,
|
|
315
|
+
maxHeight,
|
|
316
|
+
})
|
|
317
|
+
: [0], maxHeight);
|
|
318
|
+
function findSnap(numberOrCallback) {
|
|
319
|
+
// Defensive check: should never happen due to processSnapPoints validation
|
|
320
|
+
if (snapPoints.length === 0) {
|
|
321
|
+
throw new Error('Cannot find snap point: no snap points available');
|
|
322
|
+
}
|
|
323
|
+
let unsafeSearch;
|
|
324
|
+
if (typeof numberOrCallback === 'function') {
|
|
325
|
+
try {
|
|
326
|
+
unsafeSearch = numberOrCallback({
|
|
327
|
+
footerHeight,
|
|
328
|
+
headerHeight,
|
|
329
|
+
height: heightRef.current ?? 0,
|
|
330
|
+
minHeight,
|
|
331
|
+
maxHeight,
|
|
332
|
+
snapPoints,
|
|
333
|
+
lastSnap: lastSnapRef.current,
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
catch (error) {
|
|
337
|
+
// If callback throws, fall back to current position or minSnap
|
|
338
|
+
unsafeSearch = heightRef.current ?? minSnap;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
unsafeSearch = numberOrCallback;
|
|
343
|
+
}
|
|
344
|
+
let querySnap;
|
|
345
|
+
try {
|
|
346
|
+
querySnap = roundAndCheckForNaN(unsafeSearch);
|
|
347
|
+
}
|
|
348
|
+
catch (error) {
|
|
349
|
+
// If number is invalid (NaN, etc), fall back to current position or minSnap
|
|
350
|
+
querySnap = heightRef.current ?? minSnap;
|
|
351
|
+
}
|
|
352
|
+
// Support index-based selection: if querySnap is a small integer and within bounds, treat as index
|
|
353
|
+
const isValidIndex = querySnap >= 0 &&
|
|
354
|
+
querySnap < snapPoints.length &&
|
|
355
|
+
Number.isInteger(querySnap);
|
|
356
|
+
if (isValidIndex) {
|
|
357
|
+
return snapPoints[querySnap];
|
|
358
|
+
}
|
|
359
|
+
// Otherwise, find closest snap point by value
|
|
360
|
+
return snapPoints.reduce((prev, curr) => Math.abs(curr - querySnap) < Math.abs(prev - querySnap) ? curr : prev, minSnap);
|
|
361
|
+
}
|
|
362
|
+
return { minSnap, maxSnap, findSnap, maxHeight, snapPoints };
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
//implementation for Drawer gestures
|
|
366
|
+
// Standardized spring configuration
|
|
367
|
+
const SPRING_CONFIG = {
|
|
368
|
+
type: 'spring',
|
|
369
|
+
stiffness: 600,
|
|
370
|
+
damping: 50,
|
|
371
|
+
mass: 1,
|
|
372
|
+
};
|
|
373
|
+
// Rubberband effect constants
|
|
374
|
+
const RUBBERBAND_RESISTANCE = 0.8;
|
|
375
|
+
const SINGLE_SNAP_STRETCH_FACTOR = 1.2;
|
|
376
|
+
const MULTI_SNAP_STRETCH_FACTOR = 1.8;
|
|
377
|
+
// Gesture behavior constants
|
|
378
|
+
const DISMISS_THRESHOLD = 50; // Minimum movement in pixels to trigger dismiss
|
|
379
|
+
const VELOCITY_THRESHOLD = 0.1; // Minimum velocity to apply to spring animation
|
|
380
|
+
const PREDICTION_MULTIPLIER = 2; // Multiplier for velocity-based position prediction
|
|
381
|
+
const DISMISS_POSITION_FACTOR = 2; // Divisor for calculating dismiss threshold (minSnap / 2)
|
|
382
|
+
// Default functions
|
|
383
|
+
function defaultSnapPoints({ minHeight }) {
|
|
384
|
+
// When no snap points are specified, just use content height
|
|
385
|
+
// This means the drawer shows content at natural size and can only dismiss
|
|
386
|
+
return [minHeight];
|
|
387
|
+
}
|
|
388
|
+
function defaultInitialSnap({ snapPoints, lastSnap: _lastSnap, }) {
|
|
389
|
+
// Default behavior: choose the smallest snap point (usually content height)
|
|
390
|
+
// Users can override this in their initialSnap function if they want lastSnap behavior
|
|
391
|
+
return Math.min(...snapPoints);
|
|
392
|
+
}
|
|
393
|
+
function useDrawerGestures(options) {
|
|
394
|
+
const { anchor, open, onClose, snapPoints: getSnapPoints = defaultSnapPoints, initialSnap: getInitialSnap = defaultInitialSnap, contentRef, headerRef, footerRef, headerEnabled, footerEnabled, } = options;
|
|
395
|
+
const { ready, registerReady } = useReady();
|
|
396
|
+
// Height tracking refs
|
|
397
|
+
const heightRef = useRef(0);
|
|
398
|
+
const lastSnapRef = useRef(null);
|
|
399
|
+
const resizeSourceRef = useRef('window');
|
|
400
|
+
// Animation cleanup ref to prevent memory leaks
|
|
401
|
+
const animationRef = useRef(null);
|
|
402
|
+
// Cleanup animations on unmount to prevent memory leaks
|
|
403
|
+
useLayoutEffect(() => {
|
|
404
|
+
return () => {
|
|
405
|
+
animationRef.current?.stop();
|
|
406
|
+
};
|
|
407
|
+
}, []);
|
|
408
|
+
// Motion values
|
|
409
|
+
const heightMotionValue = useMotionValue(0);
|
|
410
|
+
// We animate with spring only on release; during drag we set the value directly for immediate follow
|
|
411
|
+
// Ensure motion value starts with correct value when drawer opens
|
|
412
|
+
useLayoutEffect(() => {
|
|
413
|
+
if (open &&
|
|
414
|
+
ready &&
|
|
415
|
+
heightRef.current > 0 &&
|
|
416
|
+
heightMotionValue.get() === 0) {
|
|
417
|
+
heightMotionValue.set(heightRef.current);
|
|
418
|
+
}
|
|
419
|
+
}, [open, ready, heightMotionValue]);
|
|
420
|
+
// Snap points calculation
|
|
421
|
+
const { minSnap, maxSnap, findSnap, maxHeight } = useSnapPoints({
|
|
422
|
+
contentRef: contentRef,
|
|
423
|
+
footerEnabled,
|
|
424
|
+
footerRef: footerRef,
|
|
425
|
+
getSnapPoints,
|
|
426
|
+
headerEnabled,
|
|
427
|
+
headerRef: headerRef,
|
|
428
|
+
heightRef,
|
|
429
|
+
lastSnapRef,
|
|
430
|
+
ready,
|
|
431
|
+
registerReady,
|
|
432
|
+
resizeSourceRef,
|
|
433
|
+
open,
|
|
434
|
+
});
|
|
435
|
+
// Calculate initial snap
|
|
436
|
+
const defaultSnap = useMemo(() => {
|
|
437
|
+
if (!ready)
|
|
438
|
+
return 0;
|
|
439
|
+
// If initial snap is a function, it receives state via findSnap
|
|
440
|
+
return findSnap(getInitialSnap);
|
|
441
|
+
}, [ready, getInitialSnap, findSnap]);
|
|
442
|
+
// Only set the initial height once per open cycle when content is present
|
|
443
|
+
const didInitRef = useRef(false);
|
|
444
|
+
const isContentPresent = !!contentRef?.current && contentRef.current.isConnected;
|
|
445
|
+
useLayoutEffect(() => {
|
|
446
|
+
if (!open || !ready)
|
|
447
|
+
return;
|
|
448
|
+
if (didInitRef.current)
|
|
449
|
+
return;
|
|
450
|
+
// Use the calculated defaultSnap (which may or may not include lastSnap based on user's initialSnap function)
|
|
451
|
+
const safeInitial = defaultSnap > 0 ? defaultSnap : minSnap;
|
|
452
|
+
// If we don't have content present and no valid fallback height, wait
|
|
453
|
+
if (!isContentPresent && safeInitial <= 0)
|
|
454
|
+
return;
|
|
455
|
+
// 1. Set to 0 immediately
|
|
456
|
+
heightMotionValue.set(0);
|
|
457
|
+
// 2. Update heightRef
|
|
458
|
+
heightRef.current = safeInitial;
|
|
459
|
+
// 3. Animate to target position
|
|
460
|
+
animationRef.current = animate(heightMotionValue, safeInitial, SPRING_CONFIG);
|
|
461
|
+
didInitRef.current = true;
|
|
462
|
+
}, [
|
|
463
|
+
open,
|
|
464
|
+
ready,
|
|
465
|
+
isContentPresent,
|
|
466
|
+
defaultSnap,
|
|
467
|
+
minSnap,
|
|
468
|
+
heightMotionValue,
|
|
469
|
+
lastSnapRef.current,
|
|
470
|
+
]);
|
|
471
|
+
// Content resize:
|
|
472
|
+
useLayoutEffect(() => {
|
|
473
|
+
if (!open || !ready || !isContentPresent)
|
|
474
|
+
return;
|
|
475
|
+
if (!didInitRef.current)
|
|
476
|
+
return; // Only after initial setup is complete
|
|
477
|
+
// Find closest snap point to current height (preserves user positioning)
|
|
478
|
+
const currentHeight = heightRef.current ?? 0;
|
|
479
|
+
if (currentHeight > 0) {
|
|
480
|
+
const closestSnap = findSnap(currentHeight);
|
|
481
|
+
animationRef.current = animate(heightMotionValue, closestSnap, SPRING_CONFIG);
|
|
482
|
+
heightRef.current = closestSnap;
|
|
483
|
+
lastSnapRef.current = closestSnap;
|
|
484
|
+
}
|
|
485
|
+
}, [minSnap, maxSnap]); // Triggers when snap points change (content resize)
|
|
486
|
+
// Reset init flag when closing so next open can initialize again
|
|
487
|
+
useLayoutEffect(() => {
|
|
488
|
+
if (!open) {
|
|
489
|
+
didInitRef.current = false;
|
|
490
|
+
// Preserve the current height as lastSnap for next open
|
|
491
|
+
if (heightRef.current > 0) {
|
|
492
|
+
lastSnapRef.current = heightRef.current;
|
|
493
|
+
}
|
|
494
|
+
// Animate motion value to 0 on close
|
|
495
|
+
animationRef.current = animate(heightMotionValue, 0, SPRING_CONFIG);
|
|
496
|
+
}
|
|
497
|
+
}, [open, heightMotionValue]);
|
|
498
|
+
// Drag handler
|
|
499
|
+
const handleDrag = useEventCallback(({ args: [{ closeOnTap = false } = {}] = [], cancel, down, last, memo = heightMotionValue.get(), movement: [_mx, _my], tap, velocity: [_, velocityY], event, }) => {
|
|
500
|
+
if (!ready) {
|
|
501
|
+
cancel();
|
|
502
|
+
return memo;
|
|
503
|
+
}
|
|
504
|
+
// Handle close on tap (backdrop tap)
|
|
505
|
+
if (closeOnTap && tap) {
|
|
506
|
+
cancel();
|
|
507
|
+
// Use timeout to avoid tap events on backdrop triggering click events underneath
|
|
508
|
+
onClose(event, 'gestureSwipe');
|
|
509
|
+
return memo;
|
|
510
|
+
}
|
|
511
|
+
// Filter out taps
|
|
512
|
+
if (tap) {
|
|
513
|
+
return memo;
|
|
514
|
+
}
|
|
515
|
+
// dismissal logic for all anchors
|
|
516
|
+
const getDismissInfo = () => {
|
|
517
|
+
switch (anchor) {
|
|
518
|
+
case 'bottom':
|
|
519
|
+
return {
|
|
520
|
+
isDismissDirection: _my > 0,
|
|
521
|
+
movement: _my,
|
|
522
|
+
threshold: DISMISS_THRESHOLD,
|
|
523
|
+
};
|
|
524
|
+
case 'top':
|
|
525
|
+
return {
|
|
526
|
+
isDismissDirection: _my < 0,
|
|
527
|
+
movement: Math.abs(_my),
|
|
528
|
+
threshold: DISMISS_THRESHOLD,
|
|
529
|
+
};
|
|
530
|
+
case 'left':
|
|
531
|
+
return {
|
|
532
|
+
isDismissDirection: _mx < 0,
|
|
533
|
+
movement: Math.abs(_mx),
|
|
534
|
+
threshold: DISMISS_THRESHOLD,
|
|
535
|
+
};
|
|
536
|
+
case 'right':
|
|
537
|
+
return {
|
|
538
|
+
isDismissDirection: _mx > 0,
|
|
539
|
+
movement: Math.abs(_mx),
|
|
540
|
+
threshold: DISMISS_THRESHOLD,
|
|
541
|
+
};
|
|
542
|
+
default:
|
|
543
|
+
return {
|
|
544
|
+
isDismissDirection: false,
|
|
545
|
+
movement: 0,
|
|
546
|
+
threshold: DISMISS_THRESHOLD,
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
const { isDismissDirection, movement, threshold } = getDismissInfo();
|
|
551
|
+
// For horizontal drawers, only handle dismiss (no snap points)
|
|
552
|
+
const isVertical = anchor === 'top' || anchor === 'bottom';
|
|
553
|
+
if (!isVertical) {
|
|
554
|
+
// Check for dismiss condition (horizontal drawers only)
|
|
555
|
+
if (!down && isDismissDirection && movement > threshold) {
|
|
556
|
+
cancel();
|
|
557
|
+
onClose(event, 'gestureSwipe');
|
|
558
|
+
return memo;
|
|
559
|
+
}
|
|
560
|
+
return memo;
|
|
561
|
+
}
|
|
562
|
+
const my = anchor === 'bottom' ? _my * -1 : _my;
|
|
563
|
+
const rawY = memo + my;
|
|
564
|
+
const predictedDistance = my * velocityY;
|
|
565
|
+
const predictedY = Math.max(minSnap, Math.min(maxHeight, rawY + predictedDistance * PREDICTION_MULTIPLIER));
|
|
566
|
+
// Check for vertical dismissal - only when trying to go below minimum snap point
|
|
567
|
+
if (!down && isDismissDirection) {
|
|
568
|
+
const dismissThreshold = minSnap / DISMISS_POSITION_FACTOR;
|
|
569
|
+
const currentPosition = rawY + predictedDistance;
|
|
570
|
+
if (currentPosition < dismissThreshold) {
|
|
571
|
+
cancel();
|
|
572
|
+
onClose(event, 'gestureSwipe');
|
|
573
|
+
return memo;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
let newY;
|
|
577
|
+
if (down) {
|
|
578
|
+
if (minSnap === maxSnap) {
|
|
579
|
+
// Special case when min and max snap are the same (only one snap point)
|
|
580
|
+
if (rawY < minSnap) {
|
|
581
|
+
newY = rawY; // Allow smooth dragging down (toward dismiss) with no resistance
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
// Strong resistance when dragging up beyond content
|
|
585
|
+
newY = rubberbandIfOutOfBounds(rawY, minSnap, maxSnap * SINGLE_SNAP_STRETCH_FACTOR, RUBBERBAND_RESISTANCE);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
else {
|
|
589
|
+
// Multiple snap points: allow stretching beyond maxSnap for rubberband effect
|
|
590
|
+
newY = rubberbandIfOutOfBounds(rawY, 0, maxSnap * MULTI_SNAP_STRETCH_FACTOR, RUBBERBAND_RESISTANCE);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
// On release: use predicted position
|
|
595
|
+
newY = predictedY;
|
|
596
|
+
}
|
|
597
|
+
if (last) {
|
|
598
|
+
// End of gesture: find closest snap point and animate to it
|
|
599
|
+
const targetSnap = findSnap(newY);
|
|
600
|
+
// Animate to target snap point using spring
|
|
601
|
+
animationRef.current = animate(heightMotionValue, targetSnap, {
|
|
602
|
+
...SPRING_CONFIG,
|
|
603
|
+
velocity: Math.abs(velocityY) > VELOCITY_THRESHOLD ? velocityY : 0,
|
|
604
|
+
});
|
|
605
|
+
heightRef.current = targetSnap;
|
|
606
|
+
lastSnapRef.current = targetSnap;
|
|
607
|
+
return memo;
|
|
608
|
+
}
|
|
609
|
+
// During drag: directly set height to follow finger with rubberband
|
|
610
|
+
heightMotionValue.set(newY);
|
|
611
|
+
return memo;
|
|
612
|
+
});
|
|
613
|
+
// Gesture binding
|
|
614
|
+
const isVertical = anchor === 'top' || anchor === 'bottom';
|
|
615
|
+
const bind = useDrag(handleDrag, {
|
|
616
|
+
filterTaps: true,
|
|
617
|
+
});
|
|
618
|
+
// animate height for vertical drawers only
|
|
619
|
+
const heightStyle = useTransform(heightMotionValue, (y) => {
|
|
620
|
+
// Ensure drawer never exceeds viewport bounds
|
|
621
|
+
const clamped = Math.max(0, Math.min(y, maxHeight));
|
|
622
|
+
return `${Math.round(clamped)}px`;
|
|
623
|
+
});
|
|
624
|
+
// Imperative snapTo function
|
|
625
|
+
const snapTo = useCallback((numberOrCallback) => {
|
|
626
|
+
if (!ready)
|
|
627
|
+
return;
|
|
628
|
+
const targetSnap = findSnap(numberOrCallback);
|
|
629
|
+
// Animate to target snap point
|
|
630
|
+
animationRef.current = animate(heightMotionValue, targetSnap, SPRING_CONFIG);
|
|
631
|
+
// Update refs
|
|
632
|
+
heightRef.current = targetSnap;
|
|
633
|
+
lastSnapRef.current = targetSnap;
|
|
634
|
+
}, [ready, findSnap, heightMotionValue, heightRef, lastSnapRef]);
|
|
635
|
+
return {
|
|
636
|
+
bind,
|
|
637
|
+
motionProps: {
|
|
638
|
+
style: ready && isVertical
|
|
639
|
+
? {
|
|
640
|
+
height: heightStyle,
|
|
641
|
+
}
|
|
642
|
+
: {},
|
|
643
|
+
},
|
|
644
|
+
isGestureEnabled: ready,
|
|
645
|
+
contentRef,
|
|
646
|
+
headerRef,
|
|
647
|
+
footerRef,
|
|
648
|
+
snapTo,
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* SwipeableDrawer Component - Gesture-enhanced drawer with swipe support
|
|
654
|
+
*
|
|
655
|
+
* Wraps the base Drawer component and adds touch/mouse gesture support for resizing and closing.
|
|
656
|
+
* Perfect for mobile bottom sheets and interactive panels.
|
|
657
|
+
*
|
|
658
|
+
* @example
|
|
659
|
+
* ```tsx
|
|
660
|
+
* bottom sheet with gestures
|
|
661
|
+
* <SwipeableDrawer
|
|
662
|
+
* open={open}
|
|
663
|
+
* onClose={onClose}
|
|
664
|
+
* anchor="bottom"
|
|
665
|
+
* gestureControlsProps={{
|
|
666
|
+
* snapPoints: ({ minHeight, maxHeight }) => [
|
|
667
|
+
* minHeight, // Content height
|
|
668
|
+
* maxHeight * 0.6, // 60% of screen
|
|
669
|
+
* maxHeight // Full screen
|
|
670
|
+
* ],
|
|
671
|
+
* initialSnap: 0 // Start at content height
|
|
672
|
+
* }}
|
|
673
|
+
* >
|
|
674
|
+
* <Content />
|
|
675
|
+
* </SwipeableDrawer>
|
|
676
|
+
* ```
|
|
677
|
+
*/
|
|
678
|
+
const SwipeableDrawer = forwardRef((inProps, ref) => {
|
|
679
|
+
const props = useThemeProps({
|
|
680
|
+
props: inProps,
|
|
681
|
+
name: 'SwipeableDrawer',
|
|
682
|
+
});
|
|
683
|
+
const { anchor = 'bottom', bodyProps, classes, className, children, header, footer, open, onClose, variant = 'temporary', blocking = true, gestureControlsProps, ...rest } = props;
|
|
684
|
+
// Refs for gesture system
|
|
685
|
+
const contentRef = useRef(null);
|
|
686
|
+
const headerRef = useRef(null);
|
|
687
|
+
const footerRef = useRef(null);
|
|
688
|
+
const isVertical = anchor === 'top' || anchor === 'bottom';
|
|
689
|
+
// Stabilize header/footer enabled state to prevent measurement fluctuations
|
|
690
|
+
// Header is enabled if there's a header prop OR if there's a drag handle (for vertical drawers)
|
|
691
|
+
const headerEnabled = useMemo(() => !!header || isVertical, [header, isVertical]);
|
|
692
|
+
const footerEnabled = useMemo(() => !!footer, [footer]);
|
|
693
|
+
const cls = useClasses('swipeable-drawer', classes, className);
|
|
694
|
+
const { action, ...gestureProps } = gestureControlsProps || {};
|
|
695
|
+
const gestureControls = useDrawerGestures({
|
|
696
|
+
anchor,
|
|
697
|
+
open,
|
|
698
|
+
onClose: (event, reason) => {
|
|
699
|
+
onClose?.(event, reason);
|
|
700
|
+
},
|
|
701
|
+
contentRef,
|
|
702
|
+
headerRef,
|
|
703
|
+
footerRef,
|
|
704
|
+
headerEnabled,
|
|
705
|
+
footerEnabled,
|
|
706
|
+
...gestureProps,
|
|
707
|
+
});
|
|
708
|
+
// Expose snapTo function through action ref
|
|
709
|
+
useImperativeHandle(action, () => ({
|
|
710
|
+
snapTo: gestureControls.snapTo,
|
|
711
|
+
}), [gestureControls.snapTo]);
|
|
712
|
+
const gestureBindProps = gestureControls.bind();
|
|
713
|
+
// Enhanced body props that include gesture motion
|
|
714
|
+
const enhancedBodyProps = {
|
|
715
|
+
...bodyProps,
|
|
716
|
+
// Apply gesture bindings for horizontal drawers (left/right)
|
|
717
|
+
// Vertical drawers (top/bottom) use motion values instead
|
|
718
|
+
...(!isVertical ? gestureBindProps : {}),
|
|
719
|
+
style: {
|
|
720
|
+
...bodyProps?.style,
|
|
721
|
+
// Apply motion styles for vertical drawers (top/bottom)
|
|
722
|
+
...(isVertical && {
|
|
723
|
+
...gestureControls.motionProps.style,
|
|
724
|
+
}),
|
|
725
|
+
},
|
|
726
|
+
};
|
|
727
|
+
// Consolidate measurement refs (refs only)
|
|
728
|
+
const measurementRefs = {
|
|
729
|
+
header: headerRef,
|
|
730
|
+
footer: footerRef,
|
|
731
|
+
content: contentRef,
|
|
732
|
+
};
|
|
733
|
+
// Gesture props for header
|
|
734
|
+
const headerGestureProps = {
|
|
735
|
+
className: clsx(isVertical && cls('header-drag')),
|
|
736
|
+
...(isVertical && gestureBindProps),
|
|
737
|
+
};
|
|
738
|
+
return (jsx(Drawer, { ref: ref, anchor: anchor, open: open, onClose: onClose, variant: variant, blocking: blocking, bodyProps: enhancedBodyProps, classes: classes, className: className, measurementRefs: measurementRefs, headerProps: headerGestureProps, header: isVertical ? (jsxs(Fragment, { children: [jsx(DragHandle, { anchor: anchor }), header] })) : (header), footer: footer, ...rest, children: children }));
|
|
739
|
+
});
|
|
740
|
+
SwipeableDrawer.displayName = 'SuiSwipeableDrawer';
|
|
741
|
+
|
|
742
|
+
export { SwipeableDrawer, SwipeableDrawer$1 as swipeableDrawerStyles };
|