@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
package/Tabs.js
ADDED
|
@@ -0,0 +1,827 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import React, { forwardRef, useState, useMemo, useRef, Children, isValidElement, cloneElement, useEffect, useLayoutEffect, useCallback } from 'react';
|
|
3
|
+
import { useTab, useTabsList, TabsListProvider } from '@mui/base';
|
|
4
|
+
import { useClasses, combineClasses, getTitle, useFontLoaded, useWindowContext, logInDev, usePrevious, useEventCallback, useOnReRender, useForkRef } from '@ringcentral/spring-base';
|
|
5
|
+
import { OverflowMd, CaretLeftMd, CaretRightMd } from '@ringcentral/spring-icon';
|
|
6
|
+
import { B as Badge } from './chunks/Badge.js';
|
|
7
|
+
import { I as IconButton } from './chunks/IconButtonLabel.js';
|
|
8
|
+
import { M as Menu } from './chunks/Menu.js';
|
|
9
|
+
import { M as MenuItem } from './chunks/useMenuItemSelect.js';
|
|
10
|
+
import 'tabbable';
|
|
11
|
+
import './chunks/useListNavigation.js';
|
|
12
|
+
import './VirtualizedList.js';
|
|
13
|
+
import { M as MenuItemText } from './chunks/MenuItemText.js';
|
|
14
|
+
import { M as MenuList } from './chunks/MenuList.js';
|
|
15
|
+
import { T as Tooltip } from './chunks/Tooltip.js';
|
|
16
|
+
import { u as useTabsContext, T as TabsContext } from './chunks/TabsContext.js';
|
|
17
|
+
import { animate, useMotionValue, motion } from 'framer-motion';
|
|
18
|
+
import { motionTransition, useThemeProps } from '@ringcentral/spring-theme';
|
|
19
|
+
import './chunks/Icon.js';
|
|
20
|
+
import { u as usePrefersReducedMotion } from './chunks/usePrefersReducedMotion.js';
|
|
21
|
+
import { u as useMotionSafeTransition } from './chunks/useMotionSafeTransition.js';
|
|
22
|
+
import isEqual from 'lodash/isEqual';
|
|
23
|
+
import throttle from 'lodash/throttle';
|
|
24
|
+
import { useInternalTabsContext, generateTabStableIds } from './TabContext.js';
|
|
25
|
+
import 'lodash/isNumber';
|
|
26
|
+
import 'lodash/kebabCase';
|
|
27
|
+
import './chunks/Squircle.js';
|
|
28
|
+
import './chunks/withTooltip.js';
|
|
29
|
+
import './chunks/useNestedParentMenu.js';
|
|
30
|
+
import './chunks/Popover.js';
|
|
31
|
+
import '@floating-ui/react-dom';
|
|
32
|
+
import './chunks/getGrow.js';
|
|
33
|
+
import './chunks/Modal.js';
|
|
34
|
+
import './chunks/getFade.js';
|
|
35
|
+
import './chunks/useFocusTrapStack.js';
|
|
36
|
+
import './chunks/Backdrop.js';
|
|
37
|
+
import './Popper.js';
|
|
38
|
+
import './chunks/PopperPaper.js';
|
|
39
|
+
import './chunks/useNestedMenuItem.js';
|
|
40
|
+
import './ListNavigation.js';
|
|
41
|
+
import 'react-virtuoso';
|
|
42
|
+
import './chunks/List.js';
|
|
43
|
+
import 'clsx';
|
|
44
|
+
|
|
45
|
+
const TabMenuItem = forwardRef((props, ref) => {
|
|
46
|
+
const { label, component: MenuItemComponent = MenuItem, onKeyDown } = props;
|
|
47
|
+
const { onChange, ...rest } = props;
|
|
48
|
+
const { getRootProps } = useTab({
|
|
49
|
+
...rest,
|
|
50
|
+
rootRef: ref,
|
|
51
|
+
});
|
|
52
|
+
return (
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
jsx(MenuItemComponent, { ...props, ...getRootProps(), onKeyDown: onKeyDown, children: jsx(MenuItemText, { children: label }) }));
|
|
55
|
+
});
|
|
56
|
+
const TabMoreMenu = forwardRef((props, ref) => {
|
|
57
|
+
const { classes, className, menuItems, TooltipProps, BadgeProps, ButtonProps, MenuProps, MenuItemComponent, ...rest } = props;
|
|
58
|
+
const [anchor, setAnchor] = useState(null);
|
|
59
|
+
const cls = useClasses('tab-more-menu', classes, className);
|
|
60
|
+
const { pill } = useTabsContext();
|
|
61
|
+
const iconButtonProps = useMemo(() => (pill
|
|
62
|
+
? {
|
|
63
|
+
shape: 'circular',
|
|
64
|
+
variant: 'outlined',
|
|
65
|
+
size: 'large',
|
|
66
|
+
background: true,
|
|
67
|
+
}
|
|
68
|
+
: {
|
|
69
|
+
shape: 'squircle',
|
|
70
|
+
variant: 'contained',
|
|
71
|
+
size: 'small',
|
|
72
|
+
background: false,
|
|
73
|
+
}), [pill]);
|
|
74
|
+
let iconButtonClasses = {
|
|
75
|
+
root: cls('button'),
|
|
76
|
+
};
|
|
77
|
+
if (ButtonProps?.classes) {
|
|
78
|
+
iconButtonClasses = combineClasses(iconButtonClasses, ButtonProps.classes);
|
|
79
|
+
}
|
|
80
|
+
let badgeClasses = {
|
|
81
|
+
root: cls('badge-root', {
|
|
82
|
+
'pill-badge': pill,
|
|
83
|
+
}),
|
|
84
|
+
};
|
|
85
|
+
if (BadgeProps?.classes) {
|
|
86
|
+
badgeClasses = combineClasses(badgeClasses, BadgeProps.classes);
|
|
87
|
+
}
|
|
88
|
+
const badgeProps = {
|
|
89
|
+
color: 'secondary',
|
|
90
|
+
variant: pill ? 'outlined' : 'contained',
|
|
91
|
+
...BadgeProps,
|
|
92
|
+
classes: badgeClasses,
|
|
93
|
+
};
|
|
94
|
+
const handleClose = (event, reason) => {
|
|
95
|
+
setAnchor(null);
|
|
96
|
+
MenuProps?.onClose?.(event, reason);
|
|
97
|
+
};
|
|
98
|
+
const iconButton = (jsx(IconButton, { color: 'secondary', symbol: OverflowMd, ...iconButtonProps, onClick: (e) => {
|
|
99
|
+
setAnchor((prev) => (prev ? null : e.currentTarget));
|
|
100
|
+
}, "aria-expanded": Boolean(anchor), "aria-label": getTitle(TooltipProps?.title), ...ButtonProps, classes: iconButtonClasses }));
|
|
101
|
+
return (jsxs(Fragment, { children: [jsxs("div", { className: cls('root'), ref: ref, ...rest, children: [TooltipProps ? (jsx(Tooltip, { ...TooltipProps, children: iconButton })) : (iconButton), Number(BadgeProps?.count) > 0 ? jsx(Badge, { ...badgeProps }) : null] }), jsx(Menu, { open: Boolean(anchor), anchorEl: anchor, onClose: handleClose, children: jsx(MenuList, { children: menuItems.map(({ ref, ...props }, index) => (jsx(TabMenuItem, { ...props, ref: ref, component: MenuItemComponent }, props.value || `TabMenuItem-${index}`))) }) })] }));
|
|
102
|
+
});
|
|
103
|
+
TabMoreMenu.displayName = 'SuiTabMoreMenu';
|
|
104
|
+
|
|
105
|
+
const TabScrollButton = forwardRef((props, ref) => {
|
|
106
|
+
const { classes, className, ButtonProps, direction = 'left', onClick, ...rest } = props;
|
|
107
|
+
const cls = useClasses('tab-scroll-button', classes, className);
|
|
108
|
+
const iconButtonClasses = useMemo(() => {
|
|
109
|
+
let combinedClasses = {
|
|
110
|
+
root: cls('button'),
|
|
111
|
+
};
|
|
112
|
+
if (ButtonProps?.classes) {
|
|
113
|
+
combinedClasses = combineClasses(combinedClasses, ButtonProps.classes);
|
|
114
|
+
}
|
|
115
|
+
return combinedClasses;
|
|
116
|
+
}, [ButtonProps?.classes, cls]);
|
|
117
|
+
const icon = direction === 'left' ? CaretLeftMd : CaretRightMd;
|
|
118
|
+
return (jsx("div", { className: cls('root', {
|
|
119
|
+
start: direction === 'left',
|
|
120
|
+
}), ref: ref, ...rest, children: jsx(IconButton, { "aria-hidden": "true", role: "presentation", tabIndex: -1, component: "div", color: "secondary", symbol: icon, shape: "circular", variant: "outlined", size: "large", background: true, onClick: onClick, ...ButtonProps, classes: iconButtonClasses }) }));
|
|
121
|
+
});
|
|
122
|
+
TabScrollButton.displayName = 'SuiTabScrollButton';
|
|
123
|
+
|
|
124
|
+
/* eslint-disable sonarjs/cognitive-complexity */
|
|
125
|
+
function useComputedTabs(props) {
|
|
126
|
+
const { variant, value, children, pill, pillGap, onGroupInfoUpdate, floatingUnderlineLeftMotionValue, floatingUnderlineWidthMotionValue, tabListRef, scrollerRef, moreRef, } = props;
|
|
127
|
+
const fontsLoaded = useFontLoaded(variant === 'moreMenu');
|
|
128
|
+
const prefersReducedMotion = usePrefersReducedMotion();
|
|
129
|
+
const { externalWindow } = useWindowContext();
|
|
130
|
+
const ResizeObserverClass = (externalWindow || window).ResizeObserver;
|
|
131
|
+
const [moreMenuItems, setMoreMenuItems] = useState([]);
|
|
132
|
+
// Render the more button initially to get the offsetWidth to compute
|
|
133
|
+
const [showMore, setShowMore] = useState(variant === 'moreMenu');
|
|
134
|
+
const moreBtnWidth = useRef(0);
|
|
135
|
+
const switchToMoreMenu = useRef(variant === 'moreMenu');
|
|
136
|
+
// Store a ref to visibleTabs and hiddenTabs for data comparison
|
|
137
|
+
const visibleTabsRef = useRef();
|
|
138
|
+
const hiddenTabsRef = useRef();
|
|
139
|
+
const shouldUpdate = useRef(false);
|
|
140
|
+
// Cache children info to reduce render times when computing more menu
|
|
141
|
+
const tabsChildrenCache = useRef();
|
|
142
|
+
const { tabsInstanceId } = useInternalTabsContext();
|
|
143
|
+
const processedChildren = useMemo(() => {
|
|
144
|
+
let childIndex = 0;
|
|
145
|
+
const visibleTabs = new Map();
|
|
146
|
+
Children.forEach(children, (child) => {
|
|
147
|
+
if (isValidElement(child)) {
|
|
148
|
+
if (process.env.NODE_ENV !== 'production' &&
|
|
149
|
+
child.type === React.Fragment) {
|
|
150
|
+
logInDev({
|
|
151
|
+
scope: 'Tabs',
|
|
152
|
+
level: 'error',
|
|
153
|
+
message: [
|
|
154
|
+
"The Tabs component doesn't accept a Fragment as a child.",
|
|
155
|
+
'Consider providing an array instead.',
|
|
156
|
+
].join('\n'),
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
const childValue = child.props.value === undefined ? childIndex : child.props.value;
|
|
160
|
+
// Only clone element when necessary: no user-provided id
|
|
161
|
+
let finalChild = child;
|
|
162
|
+
if (child.props.id === undefined) {
|
|
163
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
164
|
+
logInDev({
|
|
165
|
+
scope: 'Tabs',
|
|
166
|
+
level: 'warn',
|
|
167
|
+
message: [
|
|
168
|
+
`Tab component missing recommended 'id' prop.`,
|
|
169
|
+
`Tab value: "${childValue}"`,
|
|
170
|
+
`Tab label: "${child.props.label || 'No label'}"`,
|
|
171
|
+
'',
|
|
172
|
+
'To fix this warning, add a unique id prop to the Tab component:',
|
|
173
|
+
`<Tab id="unique-tab-id" label="Your label" />`,
|
|
174
|
+
'',
|
|
175
|
+
'Unique ids are required for accessibility and correct tab-panel linking.',
|
|
176
|
+
'If no id is provided, each Tab element will be cloned to provide its auto-generated id, which may have a performance cost.',
|
|
177
|
+
].join('\n'),
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
const { tabId } = generateTabStableIds(tabsInstanceId, childValue);
|
|
181
|
+
finalChild = cloneElement(child, {
|
|
182
|
+
...child.props,
|
|
183
|
+
id: tabId,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
visibleTabs.set(childValue, { childIndex, child: finalChild });
|
|
187
|
+
childIndex += 1;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
return visibleTabs;
|
|
191
|
+
}, [children, tabsInstanceId]);
|
|
192
|
+
const [visibleTabs, setVisibleTabs] = useState(processedChildren);
|
|
193
|
+
const visibleTabsChildren = useMemo(() => {
|
|
194
|
+
return Array.from(visibleTabs.entries()).map(([childValue, { child }]) => {
|
|
195
|
+
return { ...child, props: { ...child.props, value: childValue } };
|
|
196
|
+
});
|
|
197
|
+
}, [visibleTabs]);
|
|
198
|
+
const prevChildren = usePrevious(() => children);
|
|
199
|
+
const cacheTabsChildren = useEventCallback(() => {
|
|
200
|
+
// If this is a full update clear the cache
|
|
201
|
+
if (shouldUpdate.current === 'full')
|
|
202
|
+
tabsChildrenCache.current = new Map();
|
|
203
|
+
// We can't cache if the tabListRef is not available
|
|
204
|
+
if (!tabListRef.current?.children || !tabsChildrenCache.current)
|
|
205
|
+
return;
|
|
206
|
+
const tabsChildren = tabListRef.current?.children;
|
|
207
|
+
for (const [childValue, { childIndex, child }] of visibleTabs.entries()) {
|
|
208
|
+
const childElement = tabsChildren[childIndex];
|
|
209
|
+
if (!child || !childElement)
|
|
210
|
+
return;
|
|
211
|
+
tabsChildrenCache.current?.set(childValue, {
|
|
212
|
+
// @ts-ignore
|
|
213
|
+
child,
|
|
214
|
+
element: childElement,
|
|
215
|
+
width: childElement.offsetWidth,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
const getSelectedTabElement = useEventCallback(() => {
|
|
220
|
+
const children = tabListRef.current?.children;
|
|
221
|
+
if (!children || children.length === 0 || value === null)
|
|
222
|
+
return undefined;
|
|
223
|
+
let selectedIndex = -1;
|
|
224
|
+
if (variant === 'moreMenu' && visibleTabsRef.current) {
|
|
225
|
+
/**
|
|
226
|
+
* When the variant is `moreMenu`, visibleTabs may have a different
|
|
227
|
+
* order than processed children as some tabs are hidden in the more menu.
|
|
228
|
+
*/
|
|
229
|
+
selectedIndex = Array.from(visibleTabsRef.current).findIndex(([key]) => {
|
|
230
|
+
return key === value;
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
selectedIndex = visibleTabs.get(value)?.childIndex;
|
|
235
|
+
}
|
|
236
|
+
const selectedTabElement = children[selectedIndex];
|
|
237
|
+
if (process.env.NODE_ENV !== 'production' &&
|
|
238
|
+
selectedTabElement === undefined) {
|
|
239
|
+
logInDev({
|
|
240
|
+
scope: 'Tabs',
|
|
241
|
+
message: [
|
|
242
|
+
`The \`value\` provided to the Tabs component is invalid.`,
|
|
243
|
+
`None of the Tabs' children match with "${value}".`,
|
|
244
|
+
].join('\n'),
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
// provide the first tab as default selected tab when value is invalid
|
|
248
|
+
return selectedTabElement || children[0];
|
|
249
|
+
});
|
|
250
|
+
// main logic for computing whether show more menu when variant is 'moreMenu'
|
|
251
|
+
const computeMoreMenuWithCache = useEventCallback(() => {
|
|
252
|
+
if (variant !== 'moreMenu' || !tabsChildrenCache.current)
|
|
253
|
+
return;
|
|
254
|
+
const width = scrollerRef.current?.offsetWidth || 0; // Includes padding
|
|
255
|
+
const visibleWidth = width +
|
|
256
|
+
pillGap -
|
|
257
|
+
(tabListRef.current ? getHorizontalPadding(tabListRef.current) : 0); // Excludes padding
|
|
258
|
+
const selectedItemWidth = (value !== null && tabsChildrenCache.current.get(value)?.width) || 0;
|
|
259
|
+
const spaceForMoreBtn = moreBtnWidth.current + pillGap; // more button needs left margin
|
|
260
|
+
let consumedWidth = spaceForMoreBtn;
|
|
261
|
+
let isSelectedItemVisible = false;
|
|
262
|
+
let noWidthForUnselectedTab = false;
|
|
263
|
+
const visibleItems = new Map();
|
|
264
|
+
const hiddenItems = new Map();
|
|
265
|
+
const cache = Array.from(tabsChildrenCache.current);
|
|
266
|
+
for (let i = 0; i < cache.length; i++) {
|
|
267
|
+
const [key, itemInfo] = cache[i];
|
|
268
|
+
const { child, width: itemWidth } = itemInfo;
|
|
269
|
+
const width = itemWidth + pillGap;
|
|
270
|
+
/**
|
|
271
|
+
* If there's not enough space to accommodate an unselected tab and
|
|
272
|
+
* the tab isn't selected we'll hide it, aka put it in the more menu.
|
|
273
|
+
*/
|
|
274
|
+
if (noWidthForUnselectedTab && key !== value) {
|
|
275
|
+
hiddenItems.set(key, child);
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (isSelectedItemVisible) {
|
|
279
|
+
// Check if this is the last tab in the list
|
|
280
|
+
if (cache.length === i + 1) {
|
|
281
|
+
// Check if there is enough space to accommodate the tab without the more button
|
|
282
|
+
if (visibleWidth >= consumedWidth - spaceForMoreBtn + width) {
|
|
283
|
+
// There's enough space available, show the last tab
|
|
284
|
+
visibleItems.set(key, child);
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
// There's not enough space available, put the last item inside more menu
|
|
288
|
+
hiddenItems.set(key, child);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
// The current item is not the last tab in the list
|
|
293
|
+
// Check if there is enough space to accommodate this tab
|
|
294
|
+
if (visibleWidth >= consumedWidth + width) {
|
|
295
|
+
consumedWidth += width;
|
|
296
|
+
// There's enough space available, show this tab in the list
|
|
297
|
+
visibleItems.set(key, child);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
// There's not enoguh space available put the tab inside the more menu (hide it)
|
|
301
|
+
hiddenItems.set(key, child);
|
|
302
|
+
noWidthForUnselectedTab = true;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
// The selected tab is not visible yet. Check if the current tab is selected
|
|
308
|
+
if (key === value) {
|
|
309
|
+
// Show the selected tab, it should never be inside the more menu
|
|
310
|
+
visibleItems.set(key, child);
|
|
311
|
+
// Check if the current tab is not the last one in the list, if it isn't we need to account for its width
|
|
312
|
+
if (cache.length !== i + 1)
|
|
313
|
+
consumedWidth += width;
|
|
314
|
+
isSelectedItemVisible = true;
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
// The current tab is not selected. Check if there is enough space for the current tab, the selected tab and more button
|
|
318
|
+
if (visibleWidth >= consumedWidth + width + selectedItemWidth) {
|
|
319
|
+
consumedWidth += width;
|
|
320
|
+
visibleItems.set(key, child);
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
// There's not enough space available. Check if current tab immediately precedes the last selected tab
|
|
324
|
+
const isSecondToLast = cache.length - 1 === i + 1;
|
|
325
|
+
// Check if there is enough space for the current tab and the last selected tab without the more button
|
|
326
|
+
const hasSpaceForLast2Items = visibleWidth >=
|
|
327
|
+
consumedWidth - spaceForMoreBtn + width + selectedItemWidth;
|
|
328
|
+
if (isSecondToLast && hasSpaceForLast2Items) {
|
|
329
|
+
// If it's second to last and has enough space, show the tab
|
|
330
|
+
visibleItems.set(key, child);
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
// Otherwise hide the tab and put it in the more menu
|
|
334
|
+
hiddenItems.set(key, child);
|
|
335
|
+
noWidthForUnselectedTab = true;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (hiddenItems.size) {
|
|
339
|
+
setShowMore(true);
|
|
340
|
+
setMoreMenuItems(Array.from(hiddenItems.entries()).map(([childValue, child]) => {
|
|
341
|
+
return { ...child.props, value: childValue, ref: child.ref };
|
|
342
|
+
}));
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
setShowMore(false);
|
|
346
|
+
}
|
|
347
|
+
// @ts-ignore
|
|
348
|
+
const newVisibleTabs = new Map();
|
|
349
|
+
let childIndex = 0;
|
|
350
|
+
for (const [childValue, child] of visibleItems.entries()) {
|
|
351
|
+
newVisibleTabs.set(childValue, { childIndex, child });
|
|
352
|
+
childIndex++;
|
|
353
|
+
}
|
|
354
|
+
setVisibleTabs(newVisibleTabs);
|
|
355
|
+
shouldUpdate.current = false;
|
|
356
|
+
// Check if visibleTabs or hiddenTabs has changed
|
|
357
|
+
if (!isEqual([...(visibleTabsRef.current?.keys() || [])], [...visibleItems.keys()]) ||
|
|
358
|
+
!isEqual([...(hiddenTabsRef.current?.keys() || [])], [...hiddenItems.keys()])) {
|
|
359
|
+
// If it has changed, invoke onGroupInfoUpdate with the updated group data
|
|
360
|
+
onGroupInfoUpdate?.([...visibleItems.keys()], [...hiddenItems.keys()]);
|
|
361
|
+
}
|
|
362
|
+
visibleTabsRef.current = visibleItems;
|
|
363
|
+
hiddenTabsRef.current = hiddenItems;
|
|
364
|
+
});
|
|
365
|
+
const computeFloatingUnderline = useEventCallback((withoutAnimation = false) => {
|
|
366
|
+
const selectedTabElement = getSelectedTabElement();
|
|
367
|
+
if (!selectedTabElement)
|
|
368
|
+
return;
|
|
369
|
+
const currentWidth = floatingUnderlineWidthMotionValue.get();
|
|
370
|
+
const currentLeft = floatingUnderlineLeftMotionValue.get();
|
|
371
|
+
const targetWidth = selectedTabElement.offsetWidth;
|
|
372
|
+
const targetLeft = selectedTabElement.offsetLeft;
|
|
373
|
+
const updateWithoutAnimation = withoutAnimation || prefersReducedMotion;
|
|
374
|
+
if (updateWithoutAnimation) {
|
|
375
|
+
floatingUnderlineWidthMotionValue.set(targetWidth);
|
|
376
|
+
floatingUnderlineLeftMotionValue.set(targetLeft);
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
// Only animate if either value has changed
|
|
380
|
+
if (currentWidth !== targetWidth || currentLeft !== targetLeft) {
|
|
381
|
+
const transition = motionTransition['spring-01-fast'];
|
|
382
|
+
animate(floatingUnderlineWidthMotionValue, targetWidth, transition);
|
|
383
|
+
animate(floatingUnderlineLeftMotionValue, targetLeft, transition);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
// variant 'moreMenu', check if cache need to be updated when visibleTabs changed
|
|
387
|
+
// also need to update the cache when fonts are loaded after the initial mount
|
|
388
|
+
useEffect(() => {
|
|
389
|
+
if (variant !== 'moreMenu')
|
|
390
|
+
return;
|
|
391
|
+
if (moreRef.current) {
|
|
392
|
+
moreBtnWidth.current = moreRef.current.offsetWidth;
|
|
393
|
+
}
|
|
394
|
+
if (tabsChildrenCache.current) {
|
|
395
|
+
if (!shouldUpdate.current) {
|
|
396
|
+
// Check if the rendered visibleTabs have a different width than the cached tabs
|
|
397
|
+
for (const [childValue, { childIndex: index, child },] of visibleTabs.entries()) {
|
|
398
|
+
if (shouldUpdate.current || !child)
|
|
399
|
+
continue;
|
|
400
|
+
const cachedWidth = tabsChildrenCache.current?.get(childValue)?.width;
|
|
401
|
+
const childElement = tabListRef.current?.children[index];
|
|
402
|
+
// If the cached width is different, we should perform a partial update
|
|
403
|
+
if (cachedWidth !== childElement.offsetWidth) {
|
|
404
|
+
shouldUpdate.current = 'partial';
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (shouldUpdate.current) {
|
|
409
|
+
cacheTabsChildren();
|
|
410
|
+
computeMoreMenuWithCache();
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
414
|
+
}, [visibleTabs, fontsLoaded]);
|
|
415
|
+
useEffect(() => {
|
|
416
|
+
if (prevChildren && children !== prevChildren) {
|
|
417
|
+
setVisibleTabs(processedChildren);
|
|
418
|
+
shouldUpdate.current = 'full';
|
|
419
|
+
}
|
|
420
|
+
}, [children, prevChildren, processedChildren]);
|
|
421
|
+
// initial cache for variant 'moreMenu', used for computing more menu
|
|
422
|
+
useLayoutEffect(() => {
|
|
423
|
+
if (switchToMoreMenu.current && tabListRef.current?.children) {
|
|
424
|
+
switchToMoreMenu.current = false;
|
|
425
|
+
// initial cache of tabsChildrenCache
|
|
426
|
+
tabsChildrenCache.current = new Map();
|
|
427
|
+
cacheTabsChildren();
|
|
428
|
+
// initial cache of moreBtnWidth
|
|
429
|
+
moreBtnWidth.current = moreRef.current?.offsetWidth || 0;
|
|
430
|
+
computeMoreMenuWithCache();
|
|
431
|
+
}
|
|
432
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
433
|
+
}, [showMore]);
|
|
434
|
+
// handle switch variant situation
|
|
435
|
+
useOnReRender(() => {
|
|
436
|
+
if (variant !== 'moreMenu') {
|
|
437
|
+
setShowMore(false);
|
|
438
|
+
setVisibleTabs(processedChildren);
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
switchToMoreMenu.current = true;
|
|
442
|
+
setShowMore(true);
|
|
443
|
+
}
|
|
444
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
445
|
+
}, [variant]);
|
|
446
|
+
// Check if we need to update the cache and update the more menu when any tab child is resized
|
|
447
|
+
useEffect(() => {
|
|
448
|
+
if (variant !== 'moreMenu')
|
|
449
|
+
return;
|
|
450
|
+
let initialObservation = true;
|
|
451
|
+
const handleResize = throttle((entries) => {
|
|
452
|
+
if (initialObservation) {
|
|
453
|
+
/**
|
|
454
|
+
* We handle the computation of the more menu after the initial mount,
|
|
455
|
+
* or we re-compute when the `showMore` prop has updated. There's
|
|
456
|
+
* no need to compute here.
|
|
457
|
+
*/
|
|
458
|
+
initialObservation = false;
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
if (entries) {
|
|
462
|
+
// Partially update the cache before computing the more menu
|
|
463
|
+
cacheTabsChildren();
|
|
464
|
+
if (moreRef.current)
|
|
465
|
+
moreBtnWidth.current = moreRef.current.offsetWidth;
|
|
466
|
+
}
|
|
467
|
+
computeMoreMenuWithCache();
|
|
468
|
+
/**
|
|
469
|
+
* For variants other than moreMenu, we compute the floating underline using a dedicated
|
|
470
|
+
* ResizeObserver for the selected tab. When we're on the moreMenu we already have a resize
|
|
471
|
+
* observer for the tabList, so we don't need to create a dedicated one for the selected tab,
|
|
472
|
+
* then we compute the floating underline as part of the resize event we otherwise use for
|
|
473
|
+
* the more menu.
|
|
474
|
+
*/
|
|
475
|
+
computeFloatingUnderline(true);
|
|
476
|
+
}, 200);
|
|
477
|
+
let resizeObserver;
|
|
478
|
+
// Check if ResizeObserver is supported in this environment
|
|
479
|
+
if (typeof ResizeObserverClass !== 'undefined') {
|
|
480
|
+
resizeObserver = new ResizeObserverClass(handleResize);
|
|
481
|
+
if (scrollerRef.current)
|
|
482
|
+
resizeObserver.observe(scrollerRef.current);
|
|
483
|
+
if (tabListRef && tabListRef.current) {
|
|
484
|
+
const tabsChildren = tabListRef.current.children;
|
|
485
|
+
Array.from(tabsChildren).forEach((child, index) => {
|
|
486
|
+
// The last child when the pill prop is enabled is the underline element, no need to observe it
|
|
487
|
+
if (pill && index === tabsChildren.length - 1)
|
|
488
|
+
return;
|
|
489
|
+
// When the pill props is disabled, the last 2 children are the underline and floating underline elements, no need to observe them
|
|
490
|
+
if (!pill && index >= tabsChildren.length - 2)
|
|
491
|
+
return;
|
|
492
|
+
resizeObserver?.observe(child);
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
return () => {
|
|
497
|
+
handleResize.cancel();
|
|
498
|
+
resizeObserver?.disconnect();
|
|
499
|
+
};
|
|
500
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
501
|
+
}, [variant, pill, ResizeObserverClass]);
|
|
502
|
+
useEffect(() => {
|
|
503
|
+
// The ResizeObserver for the moreMenu automatically handles floating underline computation
|
|
504
|
+
if (variant === 'moreMenu')
|
|
505
|
+
return;
|
|
506
|
+
let initialObservation = true;
|
|
507
|
+
const handleSelectedTabResize = throttle(() => {
|
|
508
|
+
if (initialObservation) {
|
|
509
|
+
/**
|
|
510
|
+
* We handle the initial computation of the floating underline in the
|
|
511
|
+
* Tabs component after the value has changed, we don't need to compute
|
|
512
|
+
* it here again. This also allows us to distinguish between when the
|
|
513
|
+
* selected tab is resized and when the user selects a different tab,
|
|
514
|
+
* meaning we can apply an instant transition during resizing, but use
|
|
515
|
+
* a spring transition when switching tabs.
|
|
516
|
+
*/
|
|
517
|
+
initialObservation = false;
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
computeFloatingUnderline(true);
|
|
521
|
+
}, 16);
|
|
522
|
+
let selectedTabResizeObserver;
|
|
523
|
+
// Check if ResizeObserver is supported in this environment
|
|
524
|
+
if (typeof ResizeObserverClass !== 'undefined') {
|
|
525
|
+
selectedTabResizeObserver = new ResizeObserverClass(handleSelectedTabResize);
|
|
526
|
+
const selectedTabElement = getSelectedTabElement();
|
|
527
|
+
if (selectedTabElement) {
|
|
528
|
+
selectedTabResizeObserver.observe(selectedTabElement);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
return () => {
|
|
532
|
+
handleSelectedTabResize.cancel();
|
|
533
|
+
selectedTabResizeObserver?.disconnect();
|
|
534
|
+
};
|
|
535
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
536
|
+
}, [variant, value, ResizeObserverClass]);
|
|
537
|
+
const prevVariant = usePrevious(() => variant);
|
|
538
|
+
useEffect(() => {
|
|
539
|
+
// If only the variant is changed, we need to update the floating underline without animation
|
|
540
|
+
if (prevVariant !== variant) {
|
|
541
|
+
computeFloatingUnderline(true);
|
|
542
|
+
}
|
|
543
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
544
|
+
}, [variant]);
|
|
545
|
+
useEffect(() => {
|
|
546
|
+
if (variant === 'moreMenu' &&
|
|
547
|
+
value !== null &&
|
|
548
|
+
hiddenTabsRef.current?.has(value)) {
|
|
549
|
+
// Re-compute when a hidden tab (i.e. tab in the more menu) is selected
|
|
550
|
+
computeMoreMenuWithCache();
|
|
551
|
+
}
|
|
552
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
553
|
+
}, [value]);
|
|
554
|
+
return {
|
|
555
|
+
visibleTabsChildren,
|
|
556
|
+
showMore,
|
|
557
|
+
moreMenuItems,
|
|
558
|
+
processedChildren,
|
|
559
|
+
getSelectedTabElement,
|
|
560
|
+
computeMoreMenuWithCache,
|
|
561
|
+
computeFloatingUnderline,
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
function getHorizontalPadding(element) {
|
|
565
|
+
const style = getComputedStyle(element);
|
|
566
|
+
const paddingLeft = parseInt(style.getPropertyValue('padding-left'), 10);
|
|
567
|
+
const paddingRight = parseInt(style.getPropertyValue('padding-right'), 10);
|
|
568
|
+
return paddingLeft + paddingRight;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
const THRESHOLD_FOR_SUB_PIXEL_CALCULATION = 0.5;
|
|
572
|
+
/**
|
|
573
|
+
* This `useTabsScroller` hook manages the state and behavior of scroll buttons at both ends of the tab list (start and end) when the tab list exceeds the visible container width
|
|
574
|
+
*/
|
|
575
|
+
const useTabsScroller = ({ enable, scrollerRef, tabListRef, scroll, ScrollButtonStartProps, ScrollButtonEndProps, }) => {
|
|
576
|
+
const [displayStartScroll, setDisplayStartScroll] = useState(false);
|
|
577
|
+
const [displayEndScroll, setDisplayEndScroll] = useState(false);
|
|
578
|
+
const { externalWindow } = useWindowContext();
|
|
579
|
+
const ResizeObserverClass = (externalWindow || window).ResizeObserver;
|
|
580
|
+
useLayoutEffect(() => {
|
|
581
|
+
if (!enable)
|
|
582
|
+
return;
|
|
583
|
+
const checkScroll = throttle(() => {
|
|
584
|
+
if (!scrollerRef.current)
|
|
585
|
+
return;
|
|
586
|
+
const { scrollLeft, scrollWidth, clientWidth } = scrollerRef.current;
|
|
587
|
+
const maxScrollLeft = scrollWidth - clientWidth;
|
|
588
|
+
setDisplayStartScroll(scrollLeft > 0);
|
|
589
|
+
setDisplayEndScroll(maxScrollLeft - scrollLeft > THRESHOLD_FOR_SUB_PIXEL_CALCULATION);
|
|
590
|
+
}, 100);
|
|
591
|
+
// add scroll event listener
|
|
592
|
+
const currentTabsRef = scrollerRef.current;
|
|
593
|
+
currentTabsRef?.addEventListener('scroll', checkScroll);
|
|
594
|
+
// ResizeObserver for tabs list
|
|
595
|
+
let resizeObserver;
|
|
596
|
+
if (typeof ResizeObserverClass !== 'undefined') {
|
|
597
|
+
resizeObserver = new ResizeObserverClass(checkScroll);
|
|
598
|
+
if (currentTabsRef) {
|
|
599
|
+
resizeObserver.observe(currentTabsRef);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
checkScroll(); // Initial check
|
|
603
|
+
return () => {
|
|
604
|
+
currentTabsRef?.removeEventListener('scroll', checkScroll);
|
|
605
|
+
checkScroll.cancel();
|
|
606
|
+
// Disconnect the ResizeObserver on cleanup
|
|
607
|
+
resizeObserver?.disconnect();
|
|
608
|
+
};
|
|
609
|
+
}, [enable, scrollerRef, ResizeObserverClass]);
|
|
610
|
+
const moveTabsScroll = useCallback((delta) => {
|
|
611
|
+
const scrollValue = scrollerRef.current
|
|
612
|
+
? scrollerRef.current.scrollLeft + delta * 1
|
|
613
|
+
: 0;
|
|
614
|
+
scroll(scrollValue, 'neutral-01-slow');
|
|
615
|
+
}, [scroll, scrollerRef]);
|
|
616
|
+
const getScrollSize = useCallback(() => {
|
|
617
|
+
if (!scrollerRef.current || !tabListRef.current)
|
|
618
|
+
return 0;
|
|
619
|
+
const containerSize = scrollerRef.current.clientWidth;
|
|
620
|
+
let totalSize = 0;
|
|
621
|
+
const children = Array.from(tabListRef.current.children);
|
|
622
|
+
for (let i = 0; i < children.length; i += 1) {
|
|
623
|
+
const tab = children[i];
|
|
624
|
+
if (totalSize + tab.clientWidth > containerSize) {
|
|
625
|
+
if (i === 0) {
|
|
626
|
+
totalSize = containerSize;
|
|
627
|
+
}
|
|
628
|
+
break;
|
|
629
|
+
}
|
|
630
|
+
totalSize += tab.clientWidth;
|
|
631
|
+
}
|
|
632
|
+
return totalSize;
|
|
633
|
+
}, [scrollerRef, tabListRef]);
|
|
634
|
+
const handleStartScrollClick = useCallback(() => {
|
|
635
|
+
moveTabsScroll(-getScrollSize());
|
|
636
|
+
}, [moveTabsScroll, getScrollSize]);
|
|
637
|
+
const handleEndScrollClick = useCallback(() => {
|
|
638
|
+
moveTabsScroll(getScrollSize());
|
|
639
|
+
}, [moveTabsScroll, getScrollSize]);
|
|
640
|
+
return useMemo(() => ({
|
|
641
|
+
scrollButtonStart: enable && displayStartScroll ? (jsx(TabScrollButton, { direction: 'left', onClick: handleStartScrollClick, ButtonProps: ScrollButtonStartProps })) : null,
|
|
642
|
+
scrollButtonEnd: enable && displayEndScroll ? (jsx(TabScrollButton, { direction: 'right', onClick: handleEndScrollClick, ButtonProps: ScrollButtonEndProps })) : null,
|
|
643
|
+
}), [
|
|
644
|
+
enable,
|
|
645
|
+
displayStartScroll,
|
|
646
|
+
handleStartScrollClick,
|
|
647
|
+
ScrollButtonStartProps,
|
|
648
|
+
displayEndScroll,
|
|
649
|
+
handleEndScrollClick,
|
|
650
|
+
ScrollButtonEndProps,
|
|
651
|
+
]);
|
|
652
|
+
};
|
|
653
|
+
|
|
654
|
+
var Tabs$1 = {"sui-tabs-root":"sui-tabs-root","sui-tabs-scroller":"sui-tabs-scroller","sui-tabs-scrollable":"sui-tabs-scrollable","sui-tab":"sui-tab","sui-tabs-tab-list":"sui-tabs-tab-list","sui-tabs-underline":"sui-tabs-underline","sui-tabs-indicator":"sui-tabs-indicator","sui-tabs-compact":"sui-tabs-compact","sui-tabs-pill":"sui-tabs-pill","sui-tab-more-menu-root":"sui-tab-more-menu-root","sui-tab-more-menu-button":"sui-tab-more-menu-button","sui-tabs-scroll-left":"sui-tabs-scroll-left","sui-tabs-scroll-right":"sui-tabs-scroll-right","sui-tabs-scroll-both":"sui-tabs-scroll-both","sui-tabs-floating-underline":"sui-tabs-floating-underline","sui-tab-more-menu-badge-root":"sui-tab-more-menu-badge-root","sui-badge-dot":"sui-badge-dot","sui-badge-content":"sui-badge-content","sui-tab-more-menu-pill-badge":"sui-tab-more-menu-pill-badge","sui-tab-scroll-button-root":"sui-tab-scroll-button-root","sui-tab-scroll-button-start":"sui-tab-scroll-button-start"};
|
|
655
|
+
|
|
656
|
+
const DEFAULT_PILL_GAP = 4;
|
|
657
|
+
const Tabs = forwardRef((inProps, ref) => {
|
|
658
|
+
const props = useThemeProps({ props: inProps, name: 'Tabs' });
|
|
659
|
+
const { classes, className, children, onBlur, onFocus, variant = 'standard', onGroupInfoUpdate, MoreMenuProps, pill, pillGap: pillGapProp = DEFAULT_PILL_GAP, color = 'default', ScrollButtonStartProps, ScrollButtonEndProps, enableScrollButtons = true, ...rest } = props;
|
|
660
|
+
const pillGap = pill ? pillGapProp : 0;
|
|
661
|
+
const tabsRef = useRef(null);
|
|
662
|
+
const scrollerRef = useRef(null);
|
|
663
|
+
const tabListRef = useRef(null);
|
|
664
|
+
const rootRef = useForkRef(tabsRef, ref);
|
|
665
|
+
const moreRef = useRef(null);
|
|
666
|
+
const tabMoreMenuRef = useForkRef(MoreMenuProps?.ref, moreRef);
|
|
667
|
+
const floatingUnderlineWidthMotionValue = useMotionValue(0);
|
|
668
|
+
const floatingUnderlineLeftMotionValue = useMotionValue(0);
|
|
669
|
+
const floatingUnderlineOpacityMotionValue = useMotionValue(1);
|
|
670
|
+
const floatingUnderlineTransition = useMotionSafeTransition(motionTransition['spring-01-fast']);
|
|
671
|
+
const prefersReducedMotion = usePrefersReducedMotion();
|
|
672
|
+
const cls = useClasses('tabs', classes, className);
|
|
673
|
+
const { onGroupInfoUpdate: groupInfoUpdateHandler, ...restProps } = props;
|
|
674
|
+
const { getRootProps, contextValue, selectedValue: value, } = useTabsList({
|
|
675
|
+
...restProps,
|
|
676
|
+
rootRef,
|
|
677
|
+
});
|
|
678
|
+
const { processedChildren, visibleTabsChildren, showMore, moreMenuItems, getSelectedTabElement, computeFloatingUnderline, } = useComputedTabs({
|
|
679
|
+
variant,
|
|
680
|
+
value,
|
|
681
|
+
children,
|
|
682
|
+
pillGap,
|
|
683
|
+
onGroupInfoUpdate,
|
|
684
|
+
floatingUnderlineLeftMotionValue,
|
|
685
|
+
floatingUnderlineWidthMotionValue,
|
|
686
|
+
tabListRef,
|
|
687
|
+
scrollerRef,
|
|
688
|
+
moreRef,
|
|
689
|
+
});
|
|
690
|
+
const getTabsMeta = useEventCallback(() => {
|
|
691
|
+
const tabsNode = scrollerRef.current;
|
|
692
|
+
let tabsMeta;
|
|
693
|
+
if (tabsNode) {
|
|
694
|
+
const rect = tabsNode.getBoundingClientRect();
|
|
695
|
+
// create a new object with ClientRect class props + scrollLeft
|
|
696
|
+
tabsMeta = {
|
|
697
|
+
clientWidth: tabsNode.clientWidth,
|
|
698
|
+
scrollLeft: tabsNode.scrollLeft,
|
|
699
|
+
scrollTop: tabsNode.scrollTop,
|
|
700
|
+
scrollWidth: tabsNode.scrollWidth,
|
|
701
|
+
top: rect.top,
|
|
702
|
+
bottom: rect.bottom,
|
|
703
|
+
left: rect.left,
|
|
704
|
+
right: rect.right,
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
let tabMeta;
|
|
708
|
+
if (tabsNode && value !== null) {
|
|
709
|
+
const tab = getSelectedTabElement();
|
|
710
|
+
if (tab) {
|
|
711
|
+
const rect = tab.getBoundingClientRect();
|
|
712
|
+
tabMeta = {
|
|
713
|
+
// Use offsetWidth/offsetHeight to negate any transforms that might be applied
|
|
714
|
+
height: tab.offsetHeight,
|
|
715
|
+
width: tab.offsetWidth,
|
|
716
|
+
x: rect.x,
|
|
717
|
+
y: rect.y,
|
|
718
|
+
top: rect.top,
|
|
719
|
+
right: rect.right,
|
|
720
|
+
bottom: rect.bottom,
|
|
721
|
+
left: rect.left,
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
return { tabsMeta, tabMeta };
|
|
726
|
+
});
|
|
727
|
+
const scrollStart = 'scrollLeft';
|
|
728
|
+
const start = 'left';
|
|
729
|
+
const end = 'right';
|
|
730
|
+
const scroll = (scrollValue, transitionType) => {
|
|
731
|
+
if (!scrollerRef.current)
|
|
732
|
+
return;
|
|
733
|
+
const from = scrollerRef.current[scrollStart];
|
|
734
|
+
const to = Number(Number.parseFloat(scrollValue.toString()).toFixed(2));
|
|
735
|
+
if (from.toFixed(2) === to.toFixed(2)) {
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
if (transitionType === null || prefersReducedMotion) {
|
|
739
|
+
// if transitionType is null or prefersReducedMotion, set the scroll value without animation
|
|
740
|
+
scrollerRef.current[scrollStart] = to;
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
const transition = motionTransition[transitionType ? transitionType : 'haste-01-fast'];
|
|
744
|
+
animate(from, to, {
|
|
745
|
+
...transition,
|
|
746
|
+
onUpdate: (value) => {
|
|
747
|
+
if (!scrollerRef.current)
|
|
748
|
+
return;
|
|
749
|
+
scrollerRef.current[scrollStart] = value;
|
|
750
|
+
},
|
|
751
|
+
});
|
|
752
|
+
};
|
|
753
|
+
const scrollSelectedIntoView = useEventCallback((noAnimation) => {
|
|
754
|
+
const { tabsMeta, tabMeta } = getTabsMeta();
|
|
755
|
+
if (!tabMeta || !tabsMeta) {
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
758
|
+
// Check if the left side of the tab is out of view
|
|
759
|
+
if (tabMeta[start] < tabsMeta[start]) {
|
|
760
|
+
const nextScrollStart = tabsMeta[scrollStart] + (tabMeta[start] - tabsMeta[start]);
|
|
761
|
+
scroll(nextScrollStart, noAnimation ? null : undefined);
|
|
762
|
+
// Check if the right side of the tab is out of view
|
|
763
|
+
}
|
|
764
|
+
else if (tabMeta[end] > tabsMeta[end]) {
|
|
765
|
+
const nextScrollStart = tabsMeta[scrollStart] + Math.abs(tabMeta[end] - tabsMeta[end]);
|
|
766
|
+
scroll(nextScrollStart, noAnimation ? null : undefined);
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
const { scrollButtonStart, scrollButtonEnd } = useTabsScroller({
|
|
770
|
+
enable: !!pill && variant === 'scrollable' && enableScrollButtons,
|
|
771
|
+
scrollerRef,
|
|
772
|
+
tabListRef,
|
|
773
|
+
scroll,
|
|
774
|
+
ScrollButtonStartProps,
|
|
775
|
+
ScrollButtonEndProps,
|
|
776
|
+
});
|
|
777
|
+
const prevValueAfterChildrenUpdate = useRef(value);
|
|
778
|
+
const prevVisibleTabsChildren = useRef(visibleTabsChildren);
|
|
779
|
+
useEffect(() => {
|
|
780
|
+
const noAnimationWhenFirstRender = floatingUnderlineWidthMotionValue.get() === 0;
|
|
781
|
+
if (variant !== 'moreMenu') {
|
|
782
|
+
/**
|
|
783
|
+
* Invoke scrollSelectedIntoView when visibleTabsChildren has been updated or the selected
|
|
784
|
+
* tab has changed. It will be updated when the variant is switched from `moreMenu`
|
|
785
|
+
* to another value. If the variant is `moreMenu`, `visibleTabsChildren` will also be
|
|
786
|
+
* updated when resized.
|
|
787
|
+
*/
|
|
788
|
+
scrollSelectedIntoView(noAnimationWhenFirstRender);
|
|
789
|
+
}
|
|
790
|
+
// If the visibleTabsChildren has been updated but selected tab has not changed,
|
|
791
|
+
// we don't need to animate the floating underline
|
|
792
|
+
const noAnimationWhenNoValueChange = prevVisibleTabsChildren.current !== visibleTabsChildren &&
|
|
793
|
+
prevValueAfterChildrenUpdate.current === value;
|
|
794
|
+
if (prevVisibleTabsChildren.current !== visibleTabsChildren) {
|
|
795
|
+
prevVisibleTabsChildren.current = visibleTabsChildren;
|
|
796
|
+
prevValueAfterChildrenUpdate.current = value;
|
|
797
|
+
}
|
|
798
|
+
computeFloatingUnderline(noAnimationWhenFirstRender || noAnimationWhenNoValueChange);
|
|
799
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
800
|
+
}, [visibleTabsChildren, value]);
|
|
801
|
+
const tabsContextValue = useMemo(() => ({
|
|
802
|
+
pill,
|
|
803
|
+
pillGap,
|
|
804
|
+
color,
|
|
805
|
+
setFloatingUnderlineVisibility: (isVisible) => {
|
|
806
|
+
floatingUnderlineOpacityMotionValue.set(isVisible ? 1 : 0);
|
|
807
|
+
},
|
|
808
|
+
}), [floatingUnderlineOpacityMotionValue, pill, pillGap, color]);
|
|
809
|
+
if (!processedChildren.size) {
|
|
810
|
+
return null;
|
|
811
|
+
}
|
|
812
|
+
return (jsx(TabsListProvider, { value: contextValue, children: jsx(TabsContext.Provider, { value: tabsContextValue, children: jsxs("div", { className: cls('root', {
|
|
813
|
+
pill,
|
|
814
|
+
scrollable: variant === 'scrollable',
|
|
815
|
+
compact: variant === 'moreMenu',
|
|
816
|
+
'scroll-left': !!scrollButtonStart,
|
|
817
|
+
'scroll-right': !!scrollButtonEnd,
|
|
818
|
+
'scroll-both': !!(scrollButtonStart && scrollButtonEnd),
|
|
819
|
+
}), ...rest, ...getRootProps(), children: [scrollButtonStart, jsx("div", { className: cls('scroller'), ref: scrollerRef, children: jsxs("div", { className: cls('tab-list'), ref: tabListRef, children: [visibleTabsChildren, showMore && (jsx(TabMoreMenu, { menuItems: moreMenuItems, ...MoreMenuProps, ref: tabMoreMenuRef })), jsx("div", { className: cls('underline') }), !pill && (jsx(motion.div, { style: {
|
|
820
|
+
left: floatingUnderlineLeftMotionValue,
|
|
821
|
+
width: floatingUnderlineWidthMotionValue,
|
|
822
|
+
opacity: floatingUnderlineOpacityMotionValue,
|
|
823
|
+
}, transition: floatingUnderlineTransition, className: cls('floating-underline') }))] }) }), scrollButtonEnd] }) }) }));
|
|
824
|
+
});
|
|
825
|
+
Tabs.displayName = 'SuiTabs';
|
|
826
|
+
|
|
827
|
+
export { TabMoreMenu, TabScrollButton, Tabs, TabsContext, Tabs$1 as tabsStyle, useComputedTabs, useTabsContext, useTabsScroller };
|