rsuite 5.2.1 → 5.3.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/Avatar/styles/index.less +2 -2
- package/AvatarGroup/package.json +7 -0
- package/AvatarGroup/styles/index.less +19 -0
- package/Button/styles/index.less +6 -0
- package/ButtonGroup/styles/index.less +0 -18
- package/CHANGELOG.md +49 -0
- package/CheckTreePicker/styles/index.less +14 -1
- package/PanelGroup/styles/index.less +12 -12
- package/Table/styles/index.less +0 -4
- package/TreePicker/styles/index.less +10 -0
- package/cjs/@types/common.d.ts +9 -8
- package/cjs/@types/utils.d.ts +12 -0
- package/cjs/Affix/Affix.js +5 -5
- package/cjs/Animation/Transition.d.ts +21 -12
- package/cjs/Animation/Transition.js +4 -1
- package/cjs/AutoComplete/AutoComplete.js +1 -1
- package/cjs/AutoComplete/utils.d.ts +1 -1
- package/cjs/Avatar/Avatar.js +10 -3
- package/cjs/AvatarGroup/AvatarGroup.d.ts +15 -0
- package/cjs/AvatarGroup/AvatarGroup.js +71 -0
- package/cjs/AvatarGroup/index.d.ts +3 -0
- package/cjs/AvatarGroup/index.js +11 -0
- package/cjs/Breadcrumb/Breadcrumb.js +1 -1
- package/cjs/Button/Button.js +8 -2
- package/cjs/ButtonGroup/ButtonGroup.js +8 -2
- package/cjs/ButtonGroup/ButtonGroupContext.d.ts +7 -0
- package/cjs/ButtonGroup/ButtonGroupContext.js +13 -0
- package/cjs/ButtonGroup/index.d.ts +2 -0
- package/cjs/ButtonGroup/index.js +3 -0
- package/cjs/Calendar/Calendar.d.ts +4 -4
- package/cjs/Calendar/Calendar.js +5 -2
- package/cjs/Calendar/CalendarContext.js +1 -1
- package/cjs/Calendar/TableRow.js +1 -1
- package/cjs/Calendar/TimeDropdown.js +6 -5
- package/cjs/Calendar/types.d.ts +2 -2
- package/cjs/Calendar/useCalendarDate.d.ts +2 -2
- package/cjs/Carousel/Carousel.d.ts +2 -2
- package/cjs/Carousel/Carousel.js +1 -1
- package/cjs/Cascader/Cascader.d.ts +1 -1
- package/cjs/Cascader/Cascader.js +10 -10
- package/cjs/Cascader/DropdownMenu.d.ts +5 -4
- package/cjs/Cascader/utils.d.ts +3 -3
- package/cjs/CheckPicker/CheckPicker.js +4 -4
- package/cjs/CheckTreePicker/CheckTreeNode.d.ts +1 -1
- package/cjs/CheckTreePicker/CheckTreeNode.js +7 -9
- package/cjs/CheckTreePicker/CheckTreePicker.js +34 -27
- package/cjs/CheckTreePicker/utils.d.ts +3 -1
- package/cjs/CheckTreePicker/utils.js +12 -10
- package/cjs/Checkbox/Checkbox.d.ts +1 -1
- package/cjs/CheckboxGroup/CheckboxGroup.js +2 -2
- package/cjs/CustomProvider/CustomProvider.d.ts +31 -57
- package/cjs/DOMHelper/index.d.ts +12 -12
- package/cjs/DatePicker/DatePicker.d.ts +1 -1
- package/cjs/DatePicker/DatePicker.js +15 -9
- package/cjs/DatePicker/Toolbar.d.ts +12 -9
- package/cjs/DatePicker/Toolbar.js +6 -8
- package/cjs/DatePicker/types.d.ts +4 -4
- package/cjs/DatePicker/utils.d.ts +4 -3
- package/cjs/DateRangePicker/Calendar.d.ts +9 -7
- package/cjs/DateRangePicker/Calendar.js +27 -6
- package/cjs/DateRangePicker/DateRangePicker.d.ts +8 -6
- package/cjs/DateRangePicker/DateRangePicker.js +126 -107
- package/cjs/DateRangePicker/types.d.ts +2 -1
- package/cjs/DateRangePicker/utils.d.ts +6 -6
- package/cjs/DateRangePicker/utils.js +7 -2
- package/cjs/Disclosure/Disclosure.js +4 -2
- package/cjs/Disclosure/DisclosureButton.js +9 -7
- package/cjs/Disclosure/DisclosureContent.js +4 -6
- package/cjs/Disclosure/DisclosureContext.d.ts +2 -2
- package/cjs/Disclosure/useDisclosureContext.d.ts +2 -0
- package/cjs/Disclosure/useDisclosureContext.js +20 -0
- package/cjs/Dropdown/Dropdown.d.ts +1 -1
- package/cjs/Dropdown/DropdownContext.d.ts +2 -2
- package/cjs/Dropdown/DropdownItem.js +3 -2
- package/cjs/Dropdown/DropdownMenu.d.ts +3 -3
- package/cjs/Dropdown/DropdownState.d.ts +1 -1
- package/cjs/Dropdown/DropdownToggle.js +2 -1
- package/cjs/Dropdown/useRenderDropdownItem.d.ts +1 -1
- package/cjs/Form/Form.js +1 -1
- package/cjs/Form/FormContext.d.ts +1 -1
- package/cjs/FormControl/FormControl.d.ts +1 -1
- package/cjs/FormControl/FormControl.js +5 -4
- package/cjs/FormGroup/FormGroup.d.ts +1 -1
- package/cjs/Input/Input.d.ts +3 -2
- package/cjs/InputGroup/InputGroup.d.ts +1 -1
- package/cjs/InputNumber/InputNumber.js +6 -2
- package/cjs/InputPicker/InputAutosize.js +4 -4
- package/cjs/InputPicker/InputPicker.d.ts +2 -2
- package/cjs/InputPicker/InputPicker.js +16 -11
- package/cjs/List/ListContext.d.ts +1 -1
- package/cjs/List/ListContext.js +8 -1
- package/cjs/List/helper/AutoScroller.js +4 -2
- package/cjs/List/helper/useManager.d.ts +3 -3
- package/cjs/List/helper/useManager.js +1 -1
- package/cjs/List/helper/useSortHelper.d.ts +3 -3
- package/cjs/List/helper/useSortHelper.js +6 -4
- package/cjs/List/helper/utils.d.ts +2 -2
- package/cjs/MaskedInput/MaskedInput.d.ts +5 -42
- package/cjs/MaskedInput/MaskedInput.js +9 -63
- package/cjs/MaskedInput/TextMask.d.ts +43 -0
- package/cjs/MaskedInput/TextMask.js +80 -0
- package/cjs/MaskedInput/adjustCaretPosition.d.ts +6 -6
- package/cjs/MaskedInput/conformToMask.js +5 -4
- package/cjs/MaskedInput/createTextMaskInputElement.d.ts +2 -2
- package/cjs/MaskedInput/utilities.d.ts +1 -1
- package/cjs/Menu/Menu.js +60 -41
- package/cjs/Menu/MenuContext.d.ts +1 -1
- package/cjs/Menu/MenuItem.d.ts +1 -1
- package/cjs/Menu/MenuItem.js +31 -23
- package/cjs/Menu/Menubar.js +8 -8
- package/cjs/Menu/useMenu.js +17 -7
- package/cjs/Modal/Modal.js +12 -6
- package/cjs/Modal/ModalContext.d.ts +2 -2
- package/cjs/Modal/utils.d.ts +1 -1
- package/cjs/Modal/utils.js +12 -15
- package/cjs/MultiCascader/DropdownMenu.d.ts +4 -4
- package/cjs/MultiCascader/MultiCascader.js +6 -6
- package/cjs/MultiCascader/utils.d.ts +14 -14
- package/cjs/Nav/Nav.d.ts +1 -1
- package/cjs/Nav/NavContext.d.ts +1 -1
- package/cjs/Nav/NavItem.d.ts +1 -1
- package/cjs/Navbar/Navbar.js +1 -1
- package/cjs/Navbar/NavbarItem.d.ts +1 -1
- package/cjs/Overlay/Modal.d.ts +2 -2
- package/cjs/Overlay/Modal.js +41 -31
- package/cjs/Overlay/ModalManager.d.ts +17 -8
- package/cjs/Overlay/ModalManager.js +11 -20
- package/cjs/Overlay/Overlay.d.ts +2 -2
- package/cjs/Overlay/Overlay.js +1 -1
- package/cjs/Overlay/OverlayTrigger.d.ts +11 -11
- package/cjs/Overlay/OverlayTrigger.js +14 -6
- package/cjs/Overlay/Position.d.ts +3 -3
- package/cjs/Overlay/Position.js +21 -12
- package/cjs/Overlay/positionUtils.d.ts +1 -1
- package/cjs/Overlay/positionUtils.js +8 -8
- package/cjs/Pagination/Pagination.d.ts +1 -1
- package/cjs/Pagination/PaginationButton.d.ts +3 -3
- package/cjs/Pagination/PaginationGroup.js +5 -3
- package/cjs/Panel/Panel.d.ts +1 -1
- package/cjs/Panel/Panel.js +2 -2
- package/cjs/PanelGroup/PanelGroup.d.ts +2 -2
- package/cjs/Picker/DropdownMenu.d.ts +8 -5
- package/cjs/Picker/DropdownMenu.js +5 -5
- package/cjs/Picker/PickerOverlay.js +4 -3
- package/cjs/Picker/PickerToggle.js +11 -8
- package/cjs/Picker/PickerToggleTrigger.d.ts +2 -6
- package/cjs/Picker/SearchBar.d.ts +1 -1
- package/cjs/Picker/SelectedElement.js +2 -1
- package/cjs/Picker/VirtualizedList.d.ts +29 -2
- package/cjs/Picker/propTypes.d.ts +2 -2
- package/cjs/Picker/utils.d.ts +17 -25
- package/cjs/Picker/utils.js +71 -46
- package/cjs/Placeholder/PlaceholderGrid.js +1 -1
- package/cjs/Plaintext/Plaintext.js +2 -1
- package/cjs/Radio/Radio.d.ts +1 -1
- package/cjs/RadioGroup/RadioGroup.d.ts +2 -2
- package/cjs/RadioGroup/RadioGroup.js +3 -3
- package/cjs/RangeSlider/RangeSlider.d.ts +2 -2
- package/cjs/RangeSlider/RangeSlider.js +6 -4
- package/cjs/Rate/Character.js +4 -2
- package/cjs/Rate/Rate.js +5 -2
- package/cjs/Ripple/Ripple.js +1 -1
- package/cjs/SelectPicker/SelectPicker.js +4 -4
- package/cjs/Sidenav/Node.d.ts +1 -1
- package/cjs/Sidenav/Sidenav.d.ts +4 -4
- package/cjs/Sidenav/Sidenav.js +5 -2
- package/cjs/Sidenav/SidenavDropdown.js +11 -8
- package/cjs/Sidenav/SidenavDropdownItem.js +10 -5
- package/cjs/Sidenav/SidenavDropdownMenu.js +9 -5
- package/cjs/Sidenav/SidenavItem.d.ts +1 -1
- package/cjs/Sidenav/SidenavItem.js +4 -0
- package/cjs/Slider/Graduated.d.ts +5 -5
- package/cjs/Slider/Handle.d.ts +1 -1
- package/cjs/Slider/Handle.js +10 -6
- package/cjs/Slider/Mark.d.ts +1 -1
- package/cjs/Slider/Slider.d.ts +1 -1
- package/cjs/Slider/Slider.js +2 -2
- package/cjs/Slider/utils.d.ts +2 -1
- package/cjs/Slider/utils.js +4 -5
- package/cjs/Steps/StepItem.js +2 -2
- package/cjs/TagInput/index.js +1 -1
- package/cjs/Toggle/Toggle.js +1 -1
- package/cjs/Tree/Tree.d.ts +3 -1
- package/cjs/TreePicker/TreeNode.js +6 -8
- package/cjs/TreePicker/TreePicker.js +36 -27
- package/cjs/Uploader/UploadFileItem.d.ts +1 -1
- package/cjs/Uploader/UploadFileItem.js +2 -2
- package/cjs/Uploader/UploadTrigger.d.ts +1 -1
- package/cjs/Uploader/UploadTrigger.js +2 -3
- package/cjs/Uploader/Uploader.d.ts +5 -5
- package/cjs/Uploader/Uploader.js +1 -2
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +5 -1
- package/cjs/locales/index.d.ts +3 -3
- package/cjs/toaster/ToastContainer.d.ts +1 -1
- package/cjs/toaster/ToastContainer.js +1 -1
- package/cjs/toaster/toaster.js +3 -1
- package/cjs/utils/BrowserDetection.js +1 -1
- package/cjs/utils/ReactChildren.d.ts +2 -2
- package/cjs/utils/ajaxUpload.d.ts +1 -1
- package/cjs/utils/ajaxUpload.js +5 -4
- package/cjs/utils/appendTooltip.d.ts +1 -1
- package/cjs/utils/constants.d.ts +4 -4
- package/cjs/utils/createChainedFunction.d.ts +1 -1
- package/cjs/utils/getDataGroupBy.d.ts +1 -1
- package/cjs/utils/mergeRefs.d.ts +2 -2
- package/cjs/utils/previewFile.d.ts +1 -1
- package/cjs/utils/propTypeChecker.d.ts +6 -2
- package/cjs/utils/propTypeChecker.js +7 -6
- package/cjs/utils/reactToString.d.ts +2 -1
- package/cjs/utils/statusIcons.d.ts +1 -1
- package/cjs/utils/stringToObject.d.ts +1 -1
- package/cjs/utils/treeUtils.d.ts +32 -29
- package/cjs/utils/treeUtils.js +46 -23
- package/cjs/utils/useControlled.d.ts +6 -1
- package/cjs/utils/useControlled.js +0 -8
- package/cjs/utils/useCustom.js +6 -4
- package/cjs/utils/useElementResize.d.ts +1 -1
- package/cjs/utils/useElementResize.js +11 -6
- package/cjs/utils/useFocus.d.ts +2 -2
- package/cjs/utils/usePortal.d.ts +1 -1
- package/cjs/utils/useRootClose.d.ts +2 -2
- package/cjs/utils/useTimeout.d.ts +1 -1
- package/cjs/utils/useTimeout.js +5 -3
- package/dist/rsuite-rtl.css +85 -165
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +85 -165
- package/dist/rsuite.js +468 -445
- package/dist/rsuite.js.map +1 -1
- package/dist/rsuite.min.css +1 -1
- package/dist/rsuite.min.css.map +1 -1
- package/dist/rsuite.min.js +1 -1
- package/dist/rsuite.min.js.LICENSE.txt +9 -0
- package/dist/rsuite.min.js.map +1 -1
- package/esm/@types/common.d.ts +9 -8
- package/esm/@types/utils.d.ts +12 -0
- package/esm/Affix/Affix.js +5 -5
- package/esm/Animation/Transition.d.ts +21 -12
- package/esm/Animation/Transition.js +4 -1
- package/esm/AutoComplete/AutoComplete.js +1 -1
- package/esm/AutoComplete/utils.d.ts +1 -1
- package/esm/Avatar/Avatar.js +7 -3
- package/esm/AvatarGroup/AvatarGroup.d.ts +15 -0
- package/esm/AvatarGroup/AvatarGroup.js +54 -0
- package/esm/AvatarGroup/index.d.ts +3 -0
- package/esm/AvatarGroup/index.js +2 -0
- package/esm/Breadcrumb/Breadcrumb.js +1 -1
- package/esm/Button/Button.js +6 -2
- package/esm/ButtonGroup/ButtonGroup.js +7 -2
- package/esm/ButtonGroup/ButtonGroupContext.d.ts +7 -0
- package/esm/ButtonGroup/ButtonGroupContext.js +3 -0
- package/esm/ButtonGroup/index.d.ts +2 -0
- package/esm/ButtonGroup/index.js +2 -0
- package/esm/Calendar/Calendar.d.ts +4 -4
- package/esm/Calendar/Calendar.js +5 -2
- package/esm/Calendar/CalendarContext.js +1 -1
- package/esm/Calendar/TableRow.js +1 -1
- package/esm/Calendar/TimeDropdown.js +5 -4
- package/esm/Calendar/types.d.ts +2 -2
- package/esm/Calendar/useCalendarDate.d.ts +2 -2
- package/esm/Carousel/Carousel.d.ts +2 -2
- package/esm/Carousel/Carousel.js +1 -1
- package/esm/Cascader/Cascader.d.ts +1 -1
- package/esm/Cascader/Cascader.js +10 -10
- package/esm/Cascader/DropdownMenu.d.ts +5 -4
- package/esm/Cascader/utils.d.ts +3 -3
- package/esm/CheckPicker/CheckPicker.js +4 -4
- package/esm/CheckTreePicker/CheckTreeNode.d.ts +1 -1
- package/esm/CheckTreePicker/CheckTreeNode.js +4 -7
- package/esm/CheckTreePicker/CheckTreePicker.js +33 -25
- package/esm/CheckTreePicker/utils.d.ts +3 -1
- package/esm/CheckTreePicker/utils.js +12 -10
- package/esm/Checkbox/Checkbox.d.ts +1 -1
- package/esm/CheckboxGroup/CheckboxGroup.js +2 -2
- package/esm/CustomProvider/CustomProvider.d.ts +31 -57
- package/esm/DOMHelper/index.d.ts +12 -12
- package/esm/DatePicker/DatePicker.d.ts +1 -1
- package/esm/DatePicker/DatePicker.js +14 -9
- package/esm/DatePicker/Toolbar.d.ts +12 -9
- package/esm/DatePicker/Toolbar.js +6 -8
- package/esm/DatePicker/types.d.ts +4 -4
- package/esm/DatePicker/utils.d.ts +4 -3
- package/esm/DateRangePicker/Calendar.d.ts +9 -7
- package/esm/DateRangePicker/Calendar.js +28 -6
- package/esm/DateRangePicker/DateRangePicker.d.ts +8 -6
- package/esm/DateRangePicker/DateRangePicker.js +124 -107
- package/esm/DateRangePicker/types.d.ts +2 -1
- package/esm/DateRangePicker/utils.d.ts +6 -6
- package/esm/DateRangePicker/utils.js +6 -2
- package/esm/Disclosure/Disclosure.js +4 -2
- package/esm/Disclosure/DisclosureButton.js +8 -7
- package/esm/Disclosure/DisclosureContent.js +5 -7
- package/esm/Disclosure/DisclosureContext.d.ts +2 -2
- package/esm/Disclosure/useDisclosureContext.d.ts +2 -0
- package/esm/Disclosure/useDisclosureContext.js +11 -0
- package/esm/Dropdown/Dropdown.d.ts +1 -1
- package/esm/Dropdown/DropdownContext.d.ts +2 -2
- package/esm/Dropdown/DropdownItem.js +3 -2
- package/esm/Dropdown/DropdownMenu.d.ts +3 -3
- package/esm/Dropdown/DropdownState.d.ts +1 -1
- package/esm/Dropdown/DropdownToggle.js +2 -1
- package/esm/Dropdown/useRenderDropdownItem.d.ts +1 -1
- package/esm/Form/Form.js +1 -1
- package/esm/Form/FormContext.d.ts +1 -1
- package/esm/FormControl/FormControl.d.ts +1 -1
- package/esm/FormControl/FormControl.js +5 -4
- package/esm/FormGroup/FormGroup.d.ts +1 -1
- package/esm/Input/Input.d.ts +3 -2
- package/esm/InputGroup/InputGroup.d.ts +1 -1
- package/esm/InputNumber/InputNumber.js +6 -2
- package/esm/InputPicker/InputAutosize.js +4 -4
- package/esm/InputPicker/InputPicker.d.ts +2 -2
- package/esm/InputPicker/InputPicker.js +16 -11
- package/esm/List/ListContext.d.ts +1 -1
- package/esm/List/ListContext.js +7 -1
- package/esm/List/helper/AutoScroller.js +4 -2
- package/esm/List/helper/useManager.d.ts +3 -3
- package/esm/List/helper/useManager.js +1 -1
- package/esm/List/helper/useSortHelper.d.ts +3 -3
- package/esm/List/helper/useSortHelper.js +6 -4
- package/esm/List/helper/utils.d.ts +2 -2
- package/esm/MaskedInput/MaskedInput.d.ts +5 -42
- package/esm/MaskedInput/MaskedInput.js +9 -63
- package/esm/MaskedInput/TextMask.d.ts +43 -0
- package/esm/MaskedInput/TextMask.js +67 -0
- package/esm/MaskedInput/adjustCaretPosition.d.ts +6 -6
- package/esm/MaskedInput/conformToMask.js +5 -4
- package/esm/MaskedInput/createTextMaskInputElement.d.ts +2 -2
- package/esm/MaskedInput/utilities.d.ts +1 -1
- package/esm/Menu/Menu.js +59 -43
- package/esm/Menu/MenuContext.d.ts +1 -1
- package/esm/Menu/MenuItem.d.ts +1 -1
- package/esm/Menu/MenuItem.js +30 -23
- package/esm/Menu/Menubar.js +7 -8
- package/esm/Menu/useMenu.js +17 -7
- package/esm/Modal/Modal.js +12 -6
- package/esm/Modal/ModalContext.d.ts +2 -2
- package/esm/Modal/utils.d.ts +1 -1
- package/esm/Modal/utils.js +11 -12
- package/esm/MultiCascader/DropdownMenu.d.ts +4 -4
- package/esm/MultiCascader/MultiCascader.js +6 -6
- package/esm/MultiCascader/utils.d.ts +14 -14
- package/esm/Nav/Nav.d.ts +1 -1
- package/esm/Nav/NavContext.d.ts +1 -1
- package/esm/Nav/NavItem.d.ts +1 -1
- package/esm/Navbar/Navbar.js +1 -1
- package/esm/Navbar/NavbarItem.d.ts +1 -1
- package/esm/Overlay/Modal.d.ts +2 -2
- package/esm/Overlay/Modal.js +42 -32
- package/esm/Overlay/ModalManager.d.ts +17 -8
- package/esm/Overlay/ModalManager.js +11 -20
- package/esm/Overlay/Overlay.d.ts +2 -2
- package/esm/Overlay/Overlay.js +1 -1
- package/esm/Overlay/OverlayTrigger.d.ts +11 -11
- package/esm/Overlay/OverlayTrigger.js +14 -6
- package/esm/Overlay/Position.d.ts +3 -3
- package/esm/Overlay/Position.js +20 -11
- package/esm/Overlay/positionUtils.d.ts +1 -1
- package/esm/Overlay/positionUtils.js +6 -6
- package/esm/Pagination/Pagination.d.ts +1 -1
- package/esm/Pagination/PaginationButton.d.ts +3 -3
- package/esm/Pagination/PaginationGroup.js +5 -3
- package/esm/Panel/Panel.d.ts +1 -1
- package/esm/Panel/Panel.js +2 -2
- package/esm/PanelGroup/PanelGroup.d.ts +2 -2
- package/esm/Picker/DropdownMenu.d.ts +8 -5
- package/esm/Picker/DropdownMenu.js +5 -5
- package/esm/Picker/PickerOverlay.js +4 -3
- package/esm/Picker/PickerToggle.js +11 -8
- package/esm/Picker/PickerToggleTrigger.d.ts +2 -6
- package/esm/Picker/SearchBar.d.ts +1 -1
- package/esm/Picker/SelectedElement.js +2 -1
- package/esm/Picker/VirtualizedList.d.ts +29 -2
- package/esm/Picker/propTypes.d.ts +2 -2
- package/esm/Picker/utils.d.ts +17 -25
- package/esm/Picker/utils.js +70 -46
- package/esm/Placeholder/PlaceholderGrid.js +1 -1
- package/esm/Plaintext/Plaintext.js +2 -1
- package/esm/Radio/Radio.d.ts +1 -1
- package/esm/RadioGroup/RadioGroup.d.ts +2 -2
- package/esm/RadioGroup/RadioGroup.js +3 -3
- package/esm/RangeSlider/RangeSlider.d.ts +2 -2
- package/esm/RangeSlider/RangeSlider.js +5 -4
- package/esm/Rate/Character.js +3 -2
- package/esm/Rate/Rate.js +4 -2
- package/esm/Ripple/Ripple.js +1 -1
- package/esm/SelectPicker/SelectPicker.js +4 -4
- package/esm/Sidenav/Node.d.ts +1 -1
- package/esm/Sidenav/Sidenav.d.ts +4 -4
- package/esm/Sidenav/Sidenav.js +5 -2
- package/esm/Sidenav/SidenavDropdown.js +11 -7
- package/esm/Sidenav/SidenavDropdownItem.js +11 -5
- package/esm/Sidenav/SidenavDropdownMenu.js +9 -5
- package/esm/Sidenav/SidenavItem.d.ts +1 -1
- package/esm/Sidenav/SidenavItem.js +4 -0
- package/esm/Slider/Graduated.d.ts +5 -5
- package/esm/Slider/Handle.d.ts +1 -1
- package/esm/Slider/Handle.js +10 -6
- package/esm/Slider/Mark.d.ts +1 -1
- package/esm/Slider/Slider.d.ts +1 -1
- package/esm/Slider/Slider.js +2 -2
- package/esm/Slider/utils.d.ts +2 -1
- package/esm/Slider/utils.js +5 -2
- package/esm/Steps/StepItem.js +2 -2
- package/esm/TagInput/index.js +1 -1
- package/esm/Toggle/Toggle.js +1 -1
- package/esm/Tree/Tree.d.ts +3 -1
- package/esm/TreePicker/TreeNode.js +4 -7
- package/esm/TreePicker/TreePicker.js +35 -25
- package/esm/Uploader/UploadFileItem.d.ts +1 -1
- package/esm/Uploader/UploadFileItem.js +2 -2
- package/esm/Uploader/UploadTrigger.d.ts +1 -1
- package/esm/Uploader/UploadTrigger.js +2 -3
- package/esm/Uploader/Uploader.d.ts +5 -5
- package/esm/Uploader/Uploader.js +1 -2
- package/esm/index.d.ts +2 -0
- package/esm/index.js +1 -0
- package/esm/locales/index.d.ts +3 -3
- package/esm/toaster/ToastContainer.d.ts +1 -1
- package/esm/toaster/ToastContainer.js +1 -1
- package/esm/toaster/toaster.js +3 -1
- package/esm/utils/BrowserDetection.js +1 -1
- package/esm/utils/ReactChildren.d.ts +2 -2
- package/esm/utils/ajaxUpload.d.ts +1 -1
- package/esm/utils/ajaxUpload.js +5 -4
- package/esm/utils/appendTooltip.d.ts +1 -1
- package/esm/utils/constants.d.ts +4 -4
- package/esm/utils/createChainedFunction.d.ts +1 -1
- package/esm/utils/getDataGroupBy.d.ts +1 -1
- package/esm/utils/mergeRefs.d.ts +2 -2
- package/esm/utils/previewFile.d.ts +1 -1
- package/esm/utils/propTypeChecker.d.ts +6 -2
- package/esm/utils/propTypeChecker.js +7 -6
- package/esm/utils/reactToString.d.ts +2 -1
- package/esm/utils/statusIcons.d.ts +1 -1
- package/esm/utils/stringToObject.d.ts +1 -1
- package/esm/utils/treeUtils.d.ts +32 -29
- package/esm/utils/treeUtils.js +45 -21
- package/esm/utils/useControlled.d.ts +6 -1
- package/esm/utils/useControlled.js +0 -8
- package/esm/utils/useCustom.js +6 -4
- package/esm/utils/useElementResize.d.ts +1 -1
- package/esm/utils/useElementResize.js +12 -5
- package/esm/utils/useFocus.d.ts +2 -2
- package/esm/utils/usePortal.d.ts +1 -1
- package/esm/utils/useRootClose.d.ts +2 -2
- package/esm/utils/useTimeout.d.ts +1 -1
- package/esm/utils/useTimeout.js +5 -3
- package/package.json +4 -4
- package/styles/index.less +1 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
4
|
+
import omit from 'lodash/omit';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import createTextMaskInputElement from './createTextMaskInputElement';
|
|
7
|
+
import { mergeRefs } from '../utils';
|
|
8
|
+
/**
|
|
9
|
+
* https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#guide
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
var defaultRender = function defaultRender(ref, props) {
|
|
13
|
+
return /*#__PURE__*/React.createElement("input", _extends({
|
|
14
|
+
ref: ref
|
|
15
|
+
}, props));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
var TextMask = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
19
|
+
var mask = props.mask,
|
|
20
|
+
_props$guide = props.guide,
|
|
21
|
+
guide = _props$guide === void 0 ? true : _props$guide,
|
|
22
|
+
placeholderChar = props.placeholderChar,
|
|
23
|
+
value = props.value,
|
|
24
|
+
showMask = props.showMask,
|
|
25
|
+
pipe = props.pipe,
|
|
26
|
+
_props$render = props.render,
|
|
27
|
+
render = _props$render === void 0 ? defaultRender : _props$render,
|
|
28
|
+
onChange = props.onChange,
|
|
29
|
+
rest = _objectWithoutPropertiesLoose(props, ["mask", "guide", "placeholderChar", "value", "showMask", "pipe", "render", "onChange"]);
|
|
30
|
+
|
|
31
|
+
var inputRef = useRef(null);
|
|
32
|
+
var textMaskInputElement = useRef();
|
|
33
|
+
var initTextMask = useCallback(function () {
|
|
34
|
+
var _textMaskInputElement;
|
|
35
|
+
|
|
36
|
+
textMaskInputElement.current = createTextMaskInputElement(_extends({
|
|
37
|
+
inputElement: inputRef.current
|
|
38
|
+
}, props));
|
|
39
|
+
(_textMaskInputElement = textMaskInputElement.current) === null || _textMaskInputElement === void 0 ? void 0 : _textMaskInputElement.update(value);
|
|
40
|
+
}, [props, value]);
|
|
41
|
+
var handleChange = useCallback(function (event) {
|
|
42
|
+
var _textMaskInputElement2;
|
|
43
|
+
|
|
44
|
+
(_textMaskInputElement2 = textMaskInputElement.current) === null || _textMaskInputElement2 === void 0 ? void 0 : _textMaskInputElement2.update();
|
|
45
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
46
|
+
}, [onChange]);
|
|
47
|
+
useEffect(function () {
|
|
48
|
+
initTextMask();
|
|
49
|
+
}, [guide, placeholderChar, showMask, pipe, mask, value, initTextMask]);
|
|
50
|
+
return render(mergeRefs(inputRef, ref), _extends({
|
|
51
|
+
onChange: handleChange,
|
|
52
|
+
defaultValue: value
|
|
53
|
+
}, omit(rest, ['keepCharPositions'])));
|
|
54
|
+
});
|
|
55
|
+
TextMask.displayName = 'TextMask';
|
|
56
|
+
TextMask.propTypes = {
|
|
57
|
+
render: PropTypes.func,
|
|
58
|
+
onChange: PropTypes.func,
|
|
59
|
+
mask: PropTypes.oneOfType([PropTypes.array, PropTypes.func, PropTypes.bool]).isRequired,
|
|
60
|
+
guide: PropTypes.bool,
|
|
61
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
62
|
+
pipe: PropTypes.func,
|
|
63
|
+
placeholderChar: PropTypes.string,
|
|
64
|
+
keepCharPositions: PropTypes.bool,
|
|
65
|
+
showMask: PropTypes.bool
|
|
66
|
+
};
|
|
67
|
+
export default TextMask;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export default function adjustCaretPosition({ previousConformedValue, previousPlaceholder, currentCaretPosition, conformedValue, rawValue, placeholderChar, placeholder, indexesOfPipedChars, caretTrapIndexes }: {
|
|
2
|
-
previousConformedValue?: string;
|
|
3
|
-
previousPlaceholder?: string;
|
|
4
|
-
currentCaretPosition?: number;
|
|
2
|
+
previousConformedValue?: string | undefined;
|
|
3
|
+
previousPlaceholder?: string | undefined;
|
|
4
|
+
currentCaretPosition?: number | undefined;
|
|
5
5
|
conformedValue: any;
|
|
6
6
|
rawValue: any;
|
|
7
7
|
placeholderChar: any;
|
|
8
8
|
placeholder: any;
|
|
9
|
-
indexesOfPipedChars?:
|
|
10
|
-
caretTrapIndexes?:
|
|
11
|
-
}): number;
|
|
9
|
+
indexesOfPipedChars?: string[] | undefined;
|
|
10
|
+
caretTrapIndexes?: number[] | undefined;
|
|
11
|
+
}): number | undefined;
|
|
@@ -41,7 +41,8 @@ export default function conformToMask(rawValue, mask, config) {
|
|
|
41
41
|
placeholderChar = _config$placeholderCh === void 0 ? defaultPlaceholderChar : _config$placeholderCh,
|
|
42
42
|
_config$placeholder = _config.placeholder,
|
|
43
43
|
placeholder = _config$placeholder === void 0 ? convertMaskToPlaceholder(mask, placeholderChar) : _config$placeholder,
|
|
44
|
-
|
|
44
|
+
_config$currentCaretP = _config.currentCaretPosition,
|
|
45
|
+
currentCaretPosition = _config$currentCaretP === void 0 ? 0 : _config$currentCaretP,
|
|
45
46
|
keepCharPositions = _config.keepCharPositions; // The configs below indicate that the user wants the algorithm to work in *no guide* mode
|
|
46
47
|
|
|
47
48
|
var suppressGuide = guide === false && previousConformedValue !== undefined; // Calculate lengths once for performance
|
|
@@ -122,9 +123,9 @@ export default function conformToMask(rawValue, mask, config) {
|
|
|
122
123
|
// or we find at least one character that we can map.
|
|
123
124
|
while (rawValueArr.length > 0) {
|
|
124
125
|
// Let's retrieve the first user character in the queue of characters we have left
|
|
125
|
-
var
|
|
126
|
-
rawValueChar =
|
|
127
|
-
isNew =
|
|
126
|
+
var _ref = rawValueArr.shift(),
|
|
127
|
+
rawValueChar = _ref.char,
|
|
128
|
+
isNew = _ref.isNew; // If the character we got from the user input is a placeholder character (which happens
|
|
128
129
|
// regularly because user input could be something like (540) 90_-____, which includes
|
|
129
130
|
// a bunch of `_` which are placeholder characters) and we are not in *no guide* mode,
|
|
130
131
|
// then we map this placeholder character to the current spot in the placeholder
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default function createTextMaskInputElement(config: any): {
|
|
2
2
|
state: {
|
|
3
|
-
previousConformedValue:
|
|
4
|
-
previousPlaceholder:
|
|
3
|
+
previousConformedValue: undefined;
|
|
4
|
+
previousPlaceholder: undefined;
|
|
5
5
|
};
|
|
6
6
|
update(rawValue: any, { inputElement, mask: providedMask, guide, pipe, placeholderChar, keepCharPositions, showMask }?: any): void;
|
|
7
7
|
};
|
|
@@ -3,5 +3,5 @@ export declare const defaultPlaceholderChar = "_";
|
|
|
3
3
|
export declare function convertMaskToPlaceholder(mask?: MaskType | MaskFunctionType, placeholderChar?: string): string;
|
|
4
4
|
export declare function processCaretTraps(mask: any): {
|
|
5
5
|
maskWithoutCaretTraps: any;
|
|
6
|
-
indexes:
|
|
6
|
+
indexes: number[];
|
|
7
7
|
};
|
package/esm/Menu/Menu.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import React, { useCallback, useContext, useRef } from 'react';
|
|
2
|
+
import React, { useCallback, useContext, useRef, useMemo } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
+
import isNil from 'lodash/isNil';
|
|
4
5
|
import MenuContext, { MenuActionTypes, MoveFocusTo } from './MenuContext';
|
|
5
6
|
import { KEY_VALUES, useCustom } from '../utils';
|
|
6
7
|
import useUniqueId from '../utils/useUniqueId';
|
|
@@ -25,8 +26,8 @@ function Menu(props) {
|
|
|
25
26
|
renderMenuButton = props.renderMenuButton,
|
|
26
27
|
renderMenuPopup = props.renderMenuPopup,
|
|
27
28
|
onToggleMenu = props.onToggleMenu;
|
|
28
|
-
var buttonElementRef = useRef();
|
|
29
|
-
var menuElementRef = useRef();
|
|
29
|
+
var buttonElementRef = useRef(null);
|
|
30
|
+
var menuElementRef = useRef(null);
|
|
30
31
|
var parentMenu = useContext(MenuContext);
|
|
31
32
|
var isSubmenu = !!parentMenu;
|
|
32
33
|
var menu = useMenu();
|
|
@@ -39,8 +40,11 @@ function Menu(props) {
|
|
|
39
40
|
var _useCustom = useCustom('Menu'),
|
|
40
41
|
rtl = _useCustom.rtl;
|
|
41
42
|
|
|
42
|
-
var activeItem = (_items$activeItemInde = items[activeItemIndex]) === null || _items$activeItemInde === void 0 ? void 0 : _items$activeItemInde.element;
|
|
43
|
-
|
|
43
|
+
var activeItem = isNil(activeItemIndex) ? null : (_items$activeItemInde = items[activeItemIndex]) === null || _items$activeItemInde === void 0 ? void 0 : _items$activeItemInde.element;
|
|
44
|
+
|
|
45
|
+
var _useFocus = useFocus(menuElementRef),
|
|
46
|
+
grabFocus = _useFocus.grab;
|
|
47
|
+
|
|
44
48
|
var openMenu = useCallback(function (event) {
|
|
45
49
|
dispatch({
|
|
46
50
|
type: MenuActionTypes.OpenMenu
|
|
@@ -54,8 +58,8 @@ function Menu(props) {
|
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
onToggleMenu === null || onToggleMenu === void 0 ? void 0 : onToggleMenu(true, event);
|
|
57
|
-
|
|
58
|
-
}, [dispatch, onToggleMenu,
|
|
61
|
+
grabFocus();
|
|
62
|
+
}, [dispatch, onToggleMenu, grabFocus]);
|
|
59
63
|
var closeMenu = useCallback(function (event, returnFocusToButton) {
|
|
60
64
|
if (returnFocusToButton === void 0) {
|
|
61
65
|
returnFocusToButton = true;
|
|
@@ -71,7 +75,9 @@ function Menu(props) {
|
|
|
71
75
|
onToggleMenu === null || onToggleMenu === void 0 ? void 0 : onToggleMenu(false, event);
|
|
72
76
|
|
|
73
77
|
if (returnFocusToButton) {
|
|
74
|
-
|
|
78
|
+
var _buttonElementRef$cur;
|
|
79
|
+
|
|
80
|
+
(_buttonElementRef$cur = buttonElementRef.current) === null || _buttonElementRef$cur === void 0 ? void 0 : _buttonElementRef$cur.focus({
|
|
75
81
|
preventScroll: true
|
|
76
82
|
});
|
|
77
83
|
}
|
|
@@ -86,7 +92,9 @@ function Menu(props) {
|
|
|
86
92
|
useClickOutside({
|
|
87
93
|
enabled: open,
|
|
88
94
|
isOutside: function isOutside(event) {
|
|
89
|
-
|
|
95
|
+
var _buttonElementRef$cur2, _menuElementRef$curre;
|
|
96
|
+
|
|
97
|
+
return !((_buttonElementRef$cur2 = buttonElementRef.current) !== null && _buttonElementRef$cur2 !== void 0 && _buttonElementRef$cur2.contains(event.target)) && !((_menuElementRef$curre = menuElementRef.current) !== null && _menuElementRef$curre !== void 0 && _menuElementRef$curre.contains(event.target));
|
|
90
98
|
},
|
|
91
99
|
// fixme if clicking on a focusable element, don't move focus to menu button
|
|
92
100
|
handle: function handle(event) {
|
|
@@ -150,41 +158,48 @@ function Menu(props) {
|
|
|
150
158
|
if (disabled) return;
|
|
151
159
|
openMenu(event);
|
|
152
160
|
}, [open, disabled, openMenu]);
|
|
153
|
-
var buttonEventHandlers = {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
var buttonEventHandlers = useMemo(function () {
|
|
162
|
+
var buttonEventHandlers = {
|
|
163
|
+
onKeyDown: handleButtonKeydown
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Bind event of trigger,
|
|
167
|
+
* not used in in the expanded state of '<Sidenav>'
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
if (openMenuOn !== null && openMenuOn !== void 0 && openMenuOn.includes('click')) {
|
|
171
|
+
buttonEventHandlers.onClick = handleButtonClick;
|
|
172
|
+
}
|
|
164
173
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
174
|
+
if (openMenuOn !== null && openMenuOn !== void 0 && openMenuOn.includes('contextmenu')) {
|
|
175
|
+
buttonEventHandlers.onContextMenu = handleButtonContextMenu;
|
|
176
|
+
}
|
|
168
177
|
|
|
178
|
+
return buttonEventHandlers;
|
|
179
|
+
}, [openMenuOn, handleButtonKeydown, handleButtonClick, handleButtonContextMenu]);
|
|
169
180
|
var buttonId = useUniqueId('menubutton-');
|
|
170
|
-
var menuId = useUniqueId('menu-');
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
181
|
+
var menuId = useUniqueId('menu-');
|
|
182
|
+
var buttonAriaAttributes = useMemo(function () {
|
|
183
|
+
// Ref: https://www.w3.org/TR/wai-aria-practices-1.2/#wai-aria-roles-states-and-properties-14
|
|
184
|
+
return {
|
|
185
|
+
role: 'button',
|
|
186
|
+
'aria-haspopup': 'menu',
|
|
187
|
+
'aria-expanded': open || undefined,
|
|
188
|
+
// it's recommend to remove aria-expanded when menu is hidden
|
|
189
|
+
'aria-controls': menuId
|
|
190
|
+
};
|
|
191
|
+
}, [open, menuId]);
|
|
192
|
+
var buttonProps = useMemo(function () {
|
|
193
|
+
return _extends({
|
|
194
|
+
id: buttonId
|
|
195
|
+
}, buttonAriaAttributes, buttonEventHandlers, {
|
|
196
|
+
// render props
|
|
197
|
+
open: open
|
|
198
|
+
});
|
|
199
|
+
}, [buttonId, buttonAriaAttributes, buttonEventHandlers, open]);
|
|
200
|
+
var customMenuButton = useMemo(function () {
|
|
201
|
+
return renderMenuButton === null || renderMenuButton === void 0 ? void 0 : renderMenuButton(buttonProps, buttonElementRef);
|
|
202
|
+
}, [renderMenuButton, buttonProps, buttonElementRef]);
|
|
188
203
|
var buttonElement = customMenuButton !== null && customMenuButton !== void 0 ? customMenuButton : /*#__PURE__*/React.createElement("button", _extends({
|
|
189
204
|
ref: buttonElementRef
|
|
190
205
|
}, buttonProps), menuButtonText);
|
|
@@ -320,7 +335,8 @@ function Menu(props) {
|
|
|
320
335
|
|
|
321
336
|
var customMenuPopup = renderMenuPopup === null || renderMenuPopup === void 0 ? void 0 : renderMenuPopup(_extends({}, menuProps, {
|
|
322
337
|
open: open
|
|
323
|
-
}), menuElementRef);
|
|
338
|
+
}), menuElementRef); // fixme Wrong children here
|
|
339
|
+
|
|
324
340
|
var menuElement = customMenuPopup !== null && customMenuPopup !== void 0 ? customMenuPopup : /*#__PURE__*/React.createElement("ul", _extends({
|
|
325
341
|
ref: menuElementRef
|
|
326
342
|
}, menuProps, {
|
|
@@ -336,7 +352,7 @@ function Menu(props) {
|
|
|
336
352
|
closeMenu(e);
|
|
337
353
|
}
|
|
338
354
|
}, [disabled, closeMenu]);
|
|
339
|
-
var rootElementRef = useRef();
|
|
355
|
+
var rootElementRef = useRef(null);
|
|
340
356
|
var handleContainerBlur = useCallback(function (event) {
|
|
341
357
|
if (isFocusLeaving(event)) {
|
|
342
358
|
closeMenu(event, false);
|
package/esm/Menu/MenuItem.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface MenuItemProps {
|
|
|
8
8
|
/** Render prop */
|
|
9
9
|
children: (menuitem: React.LiHTMLAttributes<HTMLLIElement> & MenuitemRenderProps, ref: React.Ref<HTMLLIElement>) => React.ReactElement;
|
|
10
10
|
/** Callback when menuitem is being activated */
|
|
11
|
-
onActivate?:
|
|
11
|
+
onActivate?: React.MouseEventHandler;
|
|
12
12
|
}
|
|
13
13
|
export interface MenuitemRenderProps {
|
|
14
14
|
selected: boolean;
|
package/esm/Menu/MenuItem.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useCallback, useContext, useEffect, useRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
+
import isNil from 'lodash/isNil';
|
|
3
4
|
import useUniqueId from '../utils/useUniqueId';
|
|
4
5
|
import MenuContext, { MenuActionTypes, MoveFocusTo } from './MenuContext';
|
|
5
6
|
|
|
@@ -7,22 +8,24 @@ import MenuContext, { MenuActionTypes, MoveFocusTo } from './MenuContext';
|
|
|
7
8
|
* Headless ARIA `menuitem`
|
|
8
9
|
*/
|
|
9
10
|
function MenuItem(props) {
|
|
10
|
-
var _menuState$items$menu;
|
|
11
|
-
|
|
12
11
|
var children = props.children,
|
|
13
|
-
selected = props.selected,
|
|
14
|
-
|
|
12
|
+
_props$selected = props.selected,
|
|
13
|
+
selected = _props$selected === void 0 ? false : _props$selected,
|
|
14
|
+
_props$disabled = props.disabled,
|
|
15
|
+
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
15
16
|
onActivate = props.onActivate;
|
|
16
|
-
var menuitemRef = useRef();
|
|
17
|
+
var menuitemRef = useRef(null);
|
|
17
18
|
var menuitemId = useUniqueId('menuitem-');
|
|
18
|
-
var menu = useContext(MenuContext);
|
|
19
|
+
var menu = useContext(MenuContext);
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
if (!menu) {
|
|
22
|
+
throw new Error('<MenuItem> must be rendered within a <Menu>');
|
|
23
|
+
}
|
|
23
24
|
|
|
25
|
+
var menuState = menu[0],
|
|
26
|
+
dispatch = menu[1]; // Whether this menuitem has focus (indicated by `aria-activedescendant` from parent menu)
|
|
24
27
|
|
|
25
|
-
var hasFocus = (
|
|
28
|
+
var hasFocus = !isNil(menuitemRef.current) && !isNil(menuState.activeItemIndex) && menuState.items[menuState.activeItemIndex].element === menuitemRef.current;
|
|
26
29
|
var handleClick = useCallback(function (event) {
|
|
27
30
|
if (disabled) {
|
|
28
31
|
return;
|
|
@@ -32,20 +35,24 @@ function MenuItem(props) {
|
|
|
32
35
|
}, [disabled, onActivate]); // Gain/release focus on mousedown in `menubar`
|
|
33
36
|
|
|
34
37
|
var handleMouseDown = useCallback(function () {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
if (!isNil(menuitemRef.current) && !hasFocus) {
|
|
39
|
+
dispatch({
|
|
40
|
+
type: MenuActionTypes.MoveFocus,
|
|
41
|
+
to: MoveFocusTo.Specific,
|
|
42
|
+
id: menuitemRef.current.id
|
|
43
|
+
});
|
|
44
|
+
}
|
|
40
45
|
}, [dispatch]); // Gain/release focus on mouseenter/mouseleave in `menu`
|
|
41
46
|
|
|
42
47
|
var handleMouseMove = useCallback(function () {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
if (!isNil(menuitemRef.current) && !hasFocus) {
|
|
49
|
+
dispatch({
|
|
50
|
+
type: MenuActionTypes.MoveFocus,
|
|
51
|
+
to: MoveFocusTo.Specific,
|
|
52
|
+
id: menuitemRef.current.id
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}, [hasFocus, dispatch]);
|
|
49
56
|
var handleMouseLeave = useCallback(function () {
|
|
50
57
|
dispatch({
|
|
51
58
|
type: MenuActionTypes.MoveFocus,
|
|
@@ -54,7 +61,7 @@ function MenuItem(props) {
|
|
|
54
61
|
}, [dispatch]);
|
|
55
62
|
useEffect(function () {
|
|
56
63
|
var menuitemElement = menuitemRef.current;
|
|
57
|
-
dispatch
|
|
64
|
+
dispatch({
|
|
58
65
|
type: MenuActionTypes.RegisterItem,
|
|
59
66
|
element: menuitemElement,
|
|
60
67
|
props: {
|
|
@@ -62,7 +69,7 @@ function MenuItem(props) {
|
|
|
62
69
|
}
|
|
63
70
|
});
|
|
64
71
|
return function () {
|
|
65
|
-
dispatch
|
|
72
|
+
dispatch({
|
|
66
73
|
type: MenuActionTypes.UnregisterItem,
|
|
67
74
|
id: menuitemElement.id
|
|
68
75
|
});
|
package/esm/Menu/Menubar.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// Headless ARIA `menubar`
|
|
2
2
|
import React, { useCallback, useRef } from 'react';
|
|
3
|
+
import isNil from 'lodash/isNil';
|
|
3
4
|
import MenuContext, { MenuActionTypes, MoveFocusTo } from './MenuContext';
|
|
4
5
|
import { KEY_VALUES, useCustom } from '../utils';
|
|
5
6
|
import { isFocusEntering, isFocusLeaving } from '../utils/events';
|
|
6
7
|
import useMenu from './useMenu';
|
|
7
8
|
export default function Menubar(_ref) {
|
|
8
|
-
var _items$activeItemInde;
|
|
9
|
-
|
|
10
9
|
var _ref$vertical = _ref.vertical,
|
|
11
10
|
vertical = _ref$vertical === void 0 ? false : _ref$vertical,
|
|
12
11
|
children = _ref.children,
|
|
@@ -18,7 +17,7 @@ export default function Menubar(_ref) {
|
|
|
18
17
|
items = _menubar$.items,
|
|
19
18
|
activeItemIndex = _menubar$.activeItemIndex,
|
|
20
19
|
dispatch = menubar[1];
|
|
21
|
-
var menubarElementRef = useRef();
|
|
20
|
+
var menubarElementRef = useRef(null);
|
|
22
21
|
var onFocus = useCallback(function (event) {
|
|
23
22
|
// Focus moves inside Menubar
|
|
24
23
|
if (isFocusEntering(event)) {
|
|
@@ -44,7 +43,7 @@ export default function Menubar(_ref) {
|
|
|
44
43
|
rtl = _useCustom.rtl;
|
|
45
44
|
|
|
46
45
|
var onKeyDown = useCallback(function (event) {
|
|
47
|
-
var
|
|
46
|
+
var activeItemElement = isNil(activeItemIndex) ? null : items[activeItemIndex].element;
|
|
48
47
|
|
|
49
48
|
switch (true) {
|
|
50
49
|
case !vertical && !rtl && event.key === KEY_VALUES.RIGHT:
|
|
@@ -90,10 +89,10 @@ export default function Menubar(_ref) {
|
|
|
90
89
|
case !vertical && event.key === KEY_VALUES.DOWN:
|
|
91
90
|
case vertical && !rtl && event.key === KEY_VALUES.RIGHT:
|
|
92
91
|
case vertical && rtl && event.key === KEY_VALUES.LEFT:
|
|
93
|
-
if ((
|
|
92
|
+
if ((activeItemElement === null || activeItemElement === void 0 ? void 0 : activeItemElement.getAttribute('aria-haspopup')) === 'menu') {
|
|
94
93
|
event.preventDefault();
|
|
95
94
|
event.stopPropagation();
|
|
96
|
-
|
|
95
|
+
activeItemElement.click();
|
|
97
96
|
}
|
|
98
97
|
|
|
99
98
|
break;
|
|
@@ -102,7 +101,7 @@ export default function Menubar(_ref) {
|
|
|
102
101
|
case event.key === KEY_VALUES.SPACE:
|
|
103
102
|
event.preventDefault();
|
|
104
103
|
event.stopPropagation();
|
|
105
|
-
|
|
104
|
+
activeItemElement === null || activeItemElement === void 0 ? void 0 : activeItemElement.click();
|
|
106
105
|
break;
|
|
107
106
|
}
|
|
108
107
|
}, [rtl, items, activeItemIndex, dispatch, vertical]); // Only used for handling click events bubbling from children
|
|
@@ -124,7 +123,7 @@ export default function Menubar(_ref) {
|
|
|
124
123
|
onBlur: onBlur,
|
|
125
124
|
onKeyDown: onKeyDown,
|
|
126
125
|
onClick: onClick,
|
|
127
|
-
'aria-activedescendant': (
|
|
126
|
+
'aria-activedescendant': isNil(activeItemIndex) ? undefined : items[activeItemIndex].element.id,
|
|
128
127
|
'aria-orientation': vertical ? 'vertical' : undefined // implicitly set 'horizontal'
|
|
129
128
|
|
|
130
129
|
}, menubarElementRef));
|
package/esm/Menu/useMenu.js
CHANGED
|
@@ -43,8 +43,10 @@ export function menuReducer(state, action) {
|
|
|
43
43
|
|
|
44
44
|
switch (action.to) {
|
|
45
45
|
case MoveFocusTo.Next:
|
|
46
|
-
for (var i =
|
|
47
|
-
|
|
46
|
+
for (var i = activeItemIndex === null ? 0 : activeItemIndex + 1; i < items.length; i++) {
|
|
47
|
+
var _items$i$props;
|
|
48
|
+
|
|
49
|
+
if (!((_items$i$props = items[i].props) !== null && _items$i$props !== void 0 && _items$i$props.disabled)) {
|
|
48
50
|
nextActiveItemIndex = i;
|
|
49
51
|
break;
|
|
50
52
|
}
|
|
@@ -53,8 +55,10 @@ export function menuReducer(state, action) {
|
|
|
53
55
|
break;
|
|
54
56
|
|
|
55
57
|
case MoveFocusTo.Prev:
|
|
56
|
-
for (var _i =
|
|
57
|
-
|
|
58
|
+
for (var _i = activeItemIndex === null ? items.length - 1 : activeItemIndex - 1; _i >= 0; _i--) {
|
|
59
|
+
var _items$_i$props;
|
|
60
|
+
|
|
61
|
+
if (!((_items$_i$props = items[_i].props) !== null && _items$_i$props !== void 0 && _items$_i$props.disabled)) {
|
|
58
62
|
nextActiveItemIndex = _i;
|
|
59
63
|
break;
|
|
60
64
|
}
|
|
@@ -64,7 +68,9 @@ export function menuReducer(state, action) {
|
|
|
64
68
|
|
|
65
69
|
case MoveFocusTo.First:
|
|
66
70
|
for (var _i2 = 0; _i2 < items.length; _i2++) {
|
|
67
|
-
|
|
71
|
+
var _items$_i2$props;
|
|
72
|
+
|
|
73
|
+
if (!((_items$_i2$props = items[_i2].props) !== null && _items$_i2$props !== void 0 && _items$_i2$props.disabled)) {
|
|
68
74
|
nextActiveItemIndex = _i2;
|
|
69
75
|
break;
|
|
70
76
|
}
|
|
@@ -74,7 +80,9 @@ export function menuReducer(state, action) {
|
|
|
74
80
|
|
|
75
81
|
case MoveFocusTo.Last:
|
|
76
82
|
for (var _i3 = items.length - 1; _i3 >= 0; _i3--) {
|
|
77
|
-
|
|
83
|
+
var _items$_i3$props;
|
|
84
|
+
|
|
85
|
+
if (!((_items$_i3$props = items[_i3].props) !== null && _items$_i3$props !== void 0 && _items$_i3$props.disabled)) {
|
|
78
86
|
nextActiveItemIndex = _i3;
|
|
79
87
|
break;
|
|
80
88
|
}
|
|
@@ -84,7 +92,9 @@ export function menuReducer(state, action) {
|
|
|
84
92
|
|
|
85
93
|
case MoveFocusTo.Specific:
|
|
86
94
|
for (var _i4 = 0; _i4 < items.length; _i4++) {
|
|
87
|
-
|
|
95
|
+
var _items$_i4$props;
|
|
96
|
+
|
|
97
|
+
if (items[_i4].element.id === action.id && !((_items$_i4$props = items[_i4].props) !== null && _items$_i4$props !== void 0 && _items$_i4$props.disabled)) {
|
|
88
98
|
nextActiveItemIndex = _i4;
|
|
89
99
|
break;
|
|
90
100
|
}
|
package/esm/Modal/Modal.js
CHANGED
|
@@ -8,7 +8,7 @@ import React, { useRef, useMemo, useState, useEffect, useCallback } from 'react'
|
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import pick from 'lodash/pick';
|
|
10
10
|
import on from 'dom-lib/on';
|
|
11
|
-
import
|
|
11
|
+
import getAnimationEnd from 'dom-lib/getAnimationEnd';
|
|
12
12
|
import BaseModal, { modalPropTypes } from '../Overlay/Modal';
|
|
13
13
|
import Bounce from '../Animation/Bounce';
|
|
14
14
|
import { useClassNames, mergeRefs, SIZE } from '../utils';
|
|
@@ -43,7 +43,8 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
43
43
|
animationTimeout = _props$animationTimeo === void 0 ? 300 : _props$animationTimeo,
|
|
44
44
|
_props$overflow = props.overflow,
|
|
45
45
|
overflow = _props$overflow === void 0 ? true : _props$overflow,
|
|
46
|
-
drawer = props.drawer,
|
|
46
|
+
_props$drawer = props.drawer,
|
|
47
|
+
drawer = _props$drawer === void 0 ? false : _props$drawer,
|
|
47
48
|
onClose = props.onClose,
|
|
48
49
|
onEntered = props.onEntered,
|
|
49
50
|
onEntering = props.onEntering,
|
|
@@ -66,7 +67,7 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
66
67
|
var classes = merge(className, prefix(size, {
|
|
67
68
|
full: full
|
|
68
69
|
}));
|
|
69
|
-
var dialogRef = useRef();
|
|
70
|
+
var dialogRef = useRef(null);
|
|
70
71
|
var transitionEndListener = useRef(); // The style of the Modal body will be updated with the size of the window or container.
|
|
71
72
|
|
|
72
73
|
var _useBodyStyles = useBodyStyles(dialogRef, {
|
|
@@ -98,9 +99,13 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
98
99
|
// When the value of `backdrop` is `static`, a jitter animation will be added to the dialog when clicked.
|
|
99
100
|
if (backdrop === 'static') {
|
|
100
101
|
setShake(true);
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
|
|
103
|
+
if (!transitionEndListener.current && dialogRef.current) {
|
|
104
|
+
//fix: https://github.com/rsuite/rsuite/blob/a93d13c14fb20cc58204babe3331d3c3da3fe1fd/src/Modal/styles/index.less#L59
|
|
105
|
+
transitionEndListener.current = on(dialogRef.current, getAnimationEnd(), function () {
|
|
106
|
+
setShake(false);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
104
109
|
}
|
|
105
110
|
}, [backdrop]);
|
|
106
111
|
var handleExited = useCallback(function (node) {
|
|
@@ -109,6 +114,7 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
109
114
|
onExited === null || onExited === void 0 ? void 0 : onExited(node);
|
|
110
115
|
onDestroyEvents();
|
|
111
116
|
(_transitionEndListene = transitionEndListener.current) === null || _transitionEndListene === void 0 ? void 0 : _transitionEndListene.off();
|
|
117
|
+
transitionEndListener.current = null;
|
|
112
118
|
}, [onDestroyEvents, onExited]);
|
|
113
119
|
var handleEntered = useCallback(function (node) {
|
|
114
120
|
onEntered === null || onEntered === void 0 ? void 0 : onEntered(node);
|
|
@@ -3,10 +3,10 @@ export interface ModalContextProps {
|
|
|
3
3
|
/** ID of the dialog element */
|
|
4
4
|
dialogId: string;
|
|
5
5
|
/** Pass the close event callback to the header close button. */
|
|
6
|
-
onModalClose
|
|
6
|
+
onModalClose?: (event: React.MouseEvent<Element, MouseEvent>) => void;
|
|
7
7
|
/** Pass the latest style to body. */
|
|
8
8
|
getBodyStyles?: () => React.CSSProperties;
|
|
9
9
|
/** Whether this Modal is a Drawer */
|
|
10
10
|
isDrawer: boolean;
|
|
11
11
|
}
|
|
12
|
-
export declare const ModalContext: React.Context<ModalContextProps>;
|
|
12
|
+
export declare const ModalContext: React.Context<ModalContextProps | null>;
|
package/esm/Modal/utils.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export declare const useBodyStyles: (ref: React.RefObject<HTMLElement>, options:
|
|
|
3
3
|
overflow: boolean;
|
|
4
4
|
drawer: boolean;
|
|
5
5
|
prefix: (...classes: any) => string;
|
|
6
|
-
}) => [import("react").CSSProperties, (entering?: boolean) => void, () => void];
|
|
6
|
+
}) => [import("react").CSSProperties, (entering?: boolean | undefined) => void, () => void];
|
package/esm/Modal/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
2
|
-
import bindElementResize, { unbind as unbindElementResize } from 'element-resize-event';
|
|
3
2
|
import getHeight from 'dom-lib/getHeight';
|
|
4
3
|
import on from 'dom-lib/on';
|
|
4
|
+
import { ResizeObserver } from '@juggle/resize-observer';
|
|
5
5
|
export var useBodyStyles = function useBodyStyles(ref, options) {
|
|
6
6
|
var _useState = useState({}),
|
|
7
7
|
bodyStyles = _useState[0],
|
|
@@ -11,7 +11,8 @@ export var useBodyStyles = function useBodyStyles(ref, options) {
|
|
|
11
11
|
drawer = options.drawer,
|
|
12
12
|
prefix = options.prefix;
|
|
13
13
|
var windowResizeListener = useRef();
|
|
14
|
-
var contentElement = useRef();
|
|
14
|
+
var contentElement = useRef(null);
|
|
15
|
+
var contentElementResizeObserver = useRef();
|
|
15
16
|
var updateBodyStyles = useCallback(function (_event, entering) {
|
|
16
17
|
var dialog = ref.current;
|
|
17
18
|
var scrollHeight = dialog ? dialog.scrollHeight : 0;
|
|
@@ -40,22 +41,20 @@ export var useBodyStyles = function useBodyStyles(ref, options) {
|
|
|
40
41
|
setBodyStyles(styles);
|
|
41
42
|
}, [prefix, ref]);
|
|
42
43
|
var onDestroyEvents = useCallback(function () {
|
|
43
|
-
var _windowResizeListener, _windowResizeListener2;
|
|
44
|
+
var _windowResizeListener, _windowResizeListener2, _contentElementResize;
|
|
44
45
|
|
|
45
46
|
(_windowResizeListener = windowResizeListener.current) === null || _windowResizeListener === void 0 ? void 0 : (_windowResizeListener2 = _windowResizeListener.off) === null || _windowResizeListener2 === void 0 ? void 0 : _windowResizeListener2.call(_windowResizeListener);
|
|
46
|
-
|
|
47
|
-
if (contentElement.current) {
|
|
48
|
-
unbindElementResize(contentElement.current);
|
|
49
|
-
}
|
|
47
|
+
(_contentElementResize = contentElementResizeObserver.current) === null || _contentElementResize === void 0 ? void 0 : _contentElementResize.disconnect();
|
|
50
48
|
}, []);
|
|
51
49
|
var onChangeBodyStyles = useCallback(function (entering) {
|
|
52
50
|
if (overflow && !drawer) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
updateBodyStyles(null, entering);
|
|
56
|
-
contentElement.current = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector("." + prefix('content'));
|
|
51
|
+
updateBodyStyles(undefined, entering);
|
|
52
|
+
contentElement.current = ref.current.querySelector("." + prefix('content'));
|
|
57
53
|
windowResizeListener.current = on(window, 'resize', updateBodyStyles);
|
|
58
|
-
|
|
54
|
+
contentElementResizeObserver.current = new ResizeObserver(function () {
|
|
55
|
+
return updateBodyStyles();
|
|
56
|
+
});
|
|
57
|
+
contentElementResizeObserver.current.observe(contentElement.current);
|
|
59
58
|
}
|
|
60
59
|
}, [drawer, overflow, prefix, ref, updateBodyStyles]);
|
|
61
60
|
useEffect(function () {
|