rsuite 5.39.0 → 5.41.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/CHANGELOG.md +26 -0
- package/Navbar/styles/index.less +1 -1
- package/SelectPicker/styles/index.less +4 -8
- package/cjs/@types/common.js +1 -0
- package/cjs/@types/utils.js +12 -2
- package/cjs/Affix/Affix.js +39 -59
- package/cjs/Affix/index.js +1 -3
- package/cjs/Animation/Bounce.js +4 -13
- package/cjs/Animation/Collapse.js +19 -40
- package/cjs/Animation/Fade.js +6 -15
- package/cjs/Animation/Slide.js +6 -15
- package/cjs/Animation/Transition.js +16 -83
- package/cjs/Animation/index.js +1 -7
- package/cjs/Animation/utils.js +1 -6
- package/cjs/AutoComplete/AutoComplete.js +55 -90
- package/cjs/AutoComplete/index.js +1 -3
- package/cjs/AutoComplete/utils.js +1 -9
- package/cjs/Avatar/Avatar.js +18 -32
- package/cjs/Avatar/index.js +1 -3
- package/cjs/AvatarGroup/AvatarGroup.js +13 -27
- package/cjs/AvatarGroup/index.js +1 -3
- package/cjs/Badge/Badge.js +14 -27
- package/cjs/Badge/index.js +1 -3
- package/cjs/Breadcrumb/Breadcrumb.js +19 -41
- package/cjs/Breadcrumb/BreadcrumbItem.js +14 -26
- package/cjs/Breadcrumb/index.js +1 -3
- package/cjs/Button/Button.js +22 -40
- package/cjs/Button/index.js +1 -3
- package/cjs/ButtonGroup/ButtonGroup.js +15 -26
- package/cjs/ButtonGroup/ButtonGroupContext.js +1 -4
- package/cjs/ButtonGroup/index.js +1 -4
- package/cjs/ButtonToolbar/ButtonToolbar.js +10 -20
- package/cjs/ButtonToolbar/index.js +1 -3
- package/cjs/Calendar/Calendar.js +24 -43
- package/cjs/Calendar/CalendarBody.js +14 -28
- package/cjs/Calendar/CalendarContainer.js +46 -69
- package/cjs/Calendar/CalendarContext.js +1 -6
- package/cjs/Calendar/CalendarHeader.js +32 -59
- package/cjs/Calendar/MonthDropdown.js +22 -45
- package/cjs/Calendar/MonthDropdownItem.js +16 -31
- package/cjs/Calendar/Table.js +10 -21
- package/cjs/Calendar/TableHeaderRow.js +11 -25
- package/cjs/Calendar/TableRow.js +35 -66
- package/cjs/Calendar/TimeDropdown.js +24 -64
- package/cjs/Calendar/index.js +1 -8
- package/cjs/Calendar/types.js +1 -0
- package/cjs/Calendar/useCalendarDate.js +3 -13
- package/cjs/Calendar/useCalendarState.js +3 -8
- package/cjs/Carousel/Carousel.js +40 -65
- package/cjs/Carousel/index.js +1 -3
- package/cjs/Cascader/Cascader.js +126 -197
- package/cjs/Cascader/DropdownMenu.js +33 -65
- package/cjs/Cascader/index.js +1 -3
- package/cjs/Cascader/utils.js +13 -24
- package/cjs/CheckPicker/CheckPicker.js +105 -156
- package/cjs/CheckPicker/index.js +1 -3
- package/cjs/CheckTree/index.js +1 -8
- package/cjs/CheckTreePicker/CheckTreeNode.js +28 -54
- package/cjs/CheckTreePicker/CheckTreePicker.js +166 -248
- package/cjs/CheckTreePicker/index.js +1 -3
- package/cjs/CheckTreePicker/utils.d.ts +1 -1
- package/cjs/CheckTreePicker/utils.js +14 -54
- package/cjs/Checkbox/Checkbox.js +48 -77
- package/cjs/Checkbox/index.js +1 -3
- package/cjs/CheckboxGroup/CheckboxGroup.js +20 -38
- package/cjs/CheckboxGroup/CheckboxGroupContext.js +1 -4
- package/cjs/CheckboxGroup/index.js +1 -4
- package/cjs/CloseButton/CloseButton.js +10 -20
- package/cjs/CloseButton/index.js +1 -3
- package/cjs/Col/Col.js +10 -23
- package/cjs/Col/index.js +1 -3
- package/cjs/Container/Container.js +11 -24
- package/cjs/Container/index.js +1 -3
- package/cjs/Content/Content.js +1 -3
- package/cjs/Content/index.js +1 -3
- package/cjs/CustomProvider/CustomProvider.js +13 -28
- package/cjs/CustomProvider/FormattedDate.js +3 -9
- package/cjs/CustomProvider/index.js +1 -6
- package/cjs/DOMHelper/index.js +1 -7
- package/cjs/DOMHelper/isElement.js +1 -2
- package/cjs/DatePicker/DatePicker.js +108 -161
- package/cjs/DatePicker/PredefinedRanges.js +12 -29
- package/cjs/DatePicker/Toolbar.js +20 -36
- package/cjs/DatePicker/index.js +1 -3
- package/cjs/DatePicker/types.js +1 -0
- package/cjs/DatePicker/utils.js +5 -13
- package/cjs/DateRangePicker/Calendar.js +18 -28
- package/cjs/DateRangePicker/DateRangePicker.js +128 -207
- package/cjs/DateRangePicker/DateRangePickerContext.js +1 -6
- package/cjs/DateRangePicker/disabledDateUtils.js +9 -32
- package/cjs/DateRangePicker/index.js +1 -3
- package/cjs/DateRangePicker/types.js +1 -0
- package/cjs/DateRangePicker/utils.js +7 -20
- package/cjs/Disclosure/Disclosure.js +14 -34
- package/cjs/Disclosure/DisclosureButton.js +4 -12
- package/cjs/Disclosure/DisclosureContent.js +1 -5
- package/cjs/Disclosure/DisclosureContext.js +1 -6
- package/cjs/Disclosure/index.js +1 -3
- package/cjs/Disclosure/useDisclosureContext.js +1 -6
- package/cjs/Divider/Divider.js +11 -20
- package/cjs/Divider/index.js +1 -3
- package/cjs/Drawer/Drawer.js +10 -27
- package/cjs/Drawer/index.js +1 -3
- package/cjs/Dropdown/Dropdown.js +35 -68
- package/cjs/Dropdown/DropdownContext.js +1 -4
- package/cjs/Dropdown/DropdownItem.js +22 -49
- package/cjs/Dropdown/DropdownMenu.js +36 -63
- package/cjs/Dropdown/DropdownSeparator.js +8 -17
- package/cjs/Dropdown/DropdownState.js +1 -10
- package/cjs/Dropdown/DropdownToggle.js +17 -29
- package/cjs/Dropdown/index.js +1 -3
- package/cjs/Dropdown/useRenderDropdownItem.js +1 -5
- package/cjs/FlexboxGrid/FlexboxGrid.js +12 -22
- package/cjs/FlexboxGrid/FlexboxGridItem.js +12 -22
- package/cjs/FlexboxGrid/index.js +1 -3
- package/cjs/Footer/Footer.js +1 -3
- package/cjs/Footer/index.js +1 -3
- package/cjs/Form/Form.js +36 -76
- package/cjs/Form/FormContext.js +1 -8
- package/cjs/Form/index.js +1 -4
- package/cjs/Form/useFormClassNames.js +11 -14
- package/cjs/Form/useSchemaModel.js +2 -6
- package/cjs/FormControl/FormControl.js +50 -82
- package/cjs/FormControl/index.js +1 -3
- package/cjs/FormControl/useRegisterModel.js +1 -3
- package/cjs/FormControlLabel/FormControlLabel.js +10 -22
- package/cjs/FormControlLabel/index.js +1 -3
- package/cjs/FormErrorMessage/FormErrorMessage.js +12 -27
- package/cjs/FormErrorMessage/index.js +1 -3
- package/cjs/FormGroup/FormGroup.js +9 -21
- package/cjs/FormGroup/index.js +1 -3
- package/cjs/FormHelpText/FormHelpText.js +11 -28
- package/cjs/FormHelpText/index.js +1 -3
- package/cjs/Grid/Grid.js +10 -19
- package/cjs/Grid/index.js +1 -3
- package/cjs/Header/Header.js +1 -3
- package/cjs/Header/index.js +1 -3
- package/cjs/IconButton/IconButton.js +11 -21
- package/cjs/IconButton/index.js +1 -3
- package/cjs/Input/Input.js +26 -43
- package/cjs/Input/index.js +1 -3
- package/cjs/InputGroup/InputGroup.js +23 -39
- package/cjs/InputGroup/InputGroupAddon.js +9 -18
- package/cjs/InputGroup/InputGroupButton.js +7 -17
- package/cjs/InputGroup/index.js +1 -3
- package/cjs/InputNumber/InputNumber.js +42 -88
- package/cjs/InputNumber/index.js +1 -3
- package/cjs/InputPicker/InputAutosize.js +17 -42
- package/cjs/InputPicker/InputPicker.js +149 -250
- package/cjs/InputPicker/InputSearch.js +15 -28
- package/cjs/InputPicker/index.js +1 -3
- package/cjs/List/List.js +37 -51
- package/cjs/List/ListContext.js +1 -5
- package/cjs/List/ListItem.js +26 -40
- package/cjs/List/helper/AutoScroller.js +11 -21
- package/cjs/List/helper/useManager.js +1 -8
- package/cjs/List/helper/useSortHelper.js +58 -82
- package/cjs/List/helper/utils.js +6 -19
- package/cjs/List/index.js +1 -3
- package/cjs/Loader/Loader.js +17 -26
- package/cjs/Loader/index.js +1 -3
- package/cjs/MaskedInput/MaskedInput.js +2 -8
- package/cjs/MaskedInput/TextMask.js +14 -23
- package/cjs/MaskedInput/adjustCaretPosition.js +99 -70
- package/cjs/MaskedInput/conformToMask.js +79 -73
- package/cjs/MaskedInput/createTextMaskInputElement.js +65 -71
- package/cjs/MaskedInput/index.js +1 -3
- package/cjs/MaskedInput/types.js +1 -0
- package/cjs/MaskedInput/utilities.js +1 -8
- package/cjs/Menu/Menu.js +35 -79
- package/cjs/Menu/MenuContext.js +1 -8
- package/cjs/Menu/MenuItem.js +15 -26
- package/cjs/Menu/Menubar.js +13 -32
- package/cjs/Menu/index.js +1 -3
- package/cjs/Menu/useMenu.js +5 -34
- package/cjs/Message/Message.js +23 -45
- package/cjs/Message/index.js +1 -3
- package/cjs/Modal/Modal.js +70 -91
- package/cjs/Modal/ModalBody.js +11 -25
- package/cjs/Modal/ModalContext.js +1 -4
- package/cjs/Modal/ModalDialog.js +14 -26
- package/cjs/Modal/ModalFooter.js +1 -3
- package/cjs/Modal/ModalHeader.js +14 -29
- package/cjs/Modal/ModalTitle.js +9 -20
- package/cjs/Modal/index.js +1 -3
- package/cjs/Modal/utils.js +8 -19
- package/cjs/MultiCascader/DropdownMenu.js +38 -64
- package/cjs/MultiCascader/MultiCascader.js +129 -192
- package/cjs/MultiCascader/index.js +1 -3
- package/cjs/MultiCascader/utils.js +44 -106
- package/cjs/Nav/Nav.js +27 -69
- package/cjs/Nav/NavContext.js +1 -4
- package/cjs/Nav/NavDropdown.js +28 -60
- package/cjs/Nav/NavDropdownItem.js +20 -42
- package/cjs/Nav/NavDropdownMenu.js +26 -54
- package/cjs/Nav/NavDropdownToggle.js +12 -26
- package/cjs/Nav/NavItem.js +20 -39
- package/cjs/Nav/NavMenu.js +2 -28
- package/cjs/Nav/index.js +1 -3
- package/cjs/Navbar/Navbar.js +10 -23
- package/cjs/Navbar/NavbarBody.js +1 -6
- package/cjs/Navbar/NavbarBrand.js +1 -3
- package/cjs/Navbar/NavbarDropdown.js +25 -49
- package/cjs/Navbar/NavbarDropdownItem.js +18 -44
- package/cjs/Navbar/NavbarDropdownMenu.js +22 -51
- package/cjs/Navbar/NavbarDropdownToggle.js +12 -25
- package/cjs/Navbar/NavbarHeader.js +1 -6
- package/cjs/Navbar/NavbarItem.js +19 -35
- package/cjs/Navbar/index.js +1 -3
- package/cjs/Notification/Notification.js +20 -43
- package/cjs/Notification/index.js +1 -3
- package/cjs/Overlay/Modal.js +40 -79
- package/cjs/Overlay/ModalManager.js +1 -26
- package/cjs/Overlay/Overlay.js +28 -50
- package/cjs/Overlay/OverlayContext.js +1 -4
- package/cjs/Overlay/OverlayTrigger.js +67 -116
- package/cjs/Overlay/Position.js +25 -64
- package/cjs/Overlay/index.js +1 -3
- package/cjs/Overlay/positionUtils.js +25 -86
- package/cjs/Pagination/Pagination.js +30 -70
- package/cjs/Pagination/PaginationButton.js +15 -29
- package/cjs/Pagination/PaginationGroup.js +38 -63
- package/cjs/Pagination/index.js +1 -3
- package/cjs/Panel/Panel.js +37 -61
- package/cjs/Panel/index.js +1 -3
- package/cjs/PanelGroup/PanelGroup.js +16 -29
- package/cjs/PanelGroup/index.js +1 -3
- package/cjs/Picker/DropdownMenu.js +50 -93
- package/cjs/Picker/DropdownMenuCheckItem.js +22 -33
- package/cjs/Picker/DropdownMenuGroup.js +10 -22
- package/cjs/Picker/DropdownMenuItem.js +15 -26
- package/cjs/Picker/PickerOverlay.js +12 -28
- package/cjs/Picker/PickerToggle.js +57 -89
- package/cjs/Picker/PickerToggleTrigger.js +8 -19
- package/cjs/Picker/SearchBar.js +14 -26
- package/cjs/Picker/SelectedElement.js +9 -17
- package/cjs/Picker/ToggleButton.js +1 -6
- package/cjs/Picker/index.js +1 -24
- package/cjs/Picker/propTypes.js +1 -7
- package/cjs/Picker/types.js +1 -0
- package/cjs/Picker/utils.js +94 -200
- package/cjs/Placeholder/Placeholder.js +1 -5
- package/cjs/Placeholder/PlaceholderGraph.js +13 -22
- package/cjs/Placeholder/PlaceholderGrid.js +18 -34
- package/cjs/Placeholder/PlaceholderParagraph.js +17 -29
- package/cjs/Placeholder/index.js +1 -3
- package/cjs/Plaintext/Plaintext.js +14 -23
- package/cjs/Plaintext/index.js +1 -3
- package/cjs/Popover/Popover.js +16 -27
- package/cjs/Popover/index.js +1 -3
- package/cjs/Progress/Progress.js +1 -4
- package/cjs/Progress/ProgressCircle.js +30 -47
- package/cjs/Progress/ProgressLine.js +19 -29
- package/cjs/Progress/index.js +1 -3
- package/cjs/Radio/Radio.js +42 -62
- package/cjs/Radio/index.js +1 -3
- package/cjs/RadioGroup/RadioGroup.js +22 -37
- package/cjs/RadioGroup/index.js +1 -3
- package/cjs/RadioTile/RadioTile.js +30 -47
- package/cjs/RadioTile/index.js +1 -3
- package/cjs/RadioTileGroup/RadioTileGroup.js +17 -32
- package/cjs/RadioTileGroup/index.js +1 -3
- package/cjs/RangeSlider/RangeSlider.js +63 -104
- package/cjs/RangeSlider/index.js +1 -3
- package/cjs/Rate/Character.js +16 -31
- package/cjs/Rate/Rate.js +35 -62
- package/cjs/Rate/index.js +1 -3
- package/cjs/Rate/utils.js +1 -6
- package/cjs/Ripple/Ripple.js +16 -40
- package/cjs/Ripple/index.js +1 -3
- package/cjs/Row/Row.js +11 -22
- package/cjs/Row/index.js +1 -3
- package/cjs/SafeAnchor/SafeAnchor.js +8 -19
- package/cjs/SafeAnchor/index.js +1 -3
- package/cjs/Schema/Schema.js +1 -2
- package/cjs/Schema/index.js +1 -3
- package/cjs/SelectPicker/SelectPicker.js +136 -170
- package/cjs/SelectPicker/index.js +1 -3
- package/cjs/Sidebar/Sidebar.js +13 -26
- package/cjs/Sidebar/index.js +1 -3
- package/cjs/Sidenav/ExpandedSidenavDropdown.js +32 -54
- package/cjs/Sidenav/ExpandedSidenavDropdownItem.js +19 -41
- package/cjs/Sidenav/ExpandedSidenavDropdownMenu.js +22 -46
- package/cjs/Sidenav/Node.js +1 -12
- package/cjs/Sidenav/Sidenav.js +22 -45
- package/cjs/Sidenav/SidenavBody.js +1 -3
- package/cjs/Sidenav/SidenavDropdown.js +39 -70
- package/cjs/Sidenav/SidenavDropdownCollapse.js +9 -22
- package/cjs/Sidenav/SidenavDropdownItem.js +19 -45
- package/cjs/Sidenav/SidenavDropdownMenu.js +26 -54
- package/cjs/Sidenav/SidenavDropdownToggle.js +12 -25
- package/cjs/Sidenav/SidenavHeader.js +1 -3
- package/cjs/Sidenav/SidenavItem.js +27 -55
- package/cjs/Sidenav/SidenavToggle.js +11 -31
- package/cjs/Sidenav/index.js +1 -3
- package/cjs/Slider/Graduated.js +14 -29
- package/cjs/Slider/Handle.js +27 -52
- package/cjs/Slider/Input.js +2 -8
- package/cjs/Slider/Mark.js +11 -20
- package/cjs/Slider/ProgressBar.js +14 -23
- package/cjs/Slider/Slider.js +51 -84
- package/cjs/Slider/index.js +1 -3
- package/cjs/Slider/utils.js +1 -6
- package/cjs/Stack/Stack.js +22 -35
- package/cjs/Stack/StackItem.js +11 -17
- package/cjs/Stack/index.js +1 -3
- package/cjs/Steps/StepItem.js +16 -32
- package/cjs/Steps/Steps.js +18 -32
- package/cjs/Steps/index.js +1 -3
- package/cjs/Table/Table.js +6 -16
- package/cjs/Table/index.js +1 -3
- package/cjs/Tag/Tag.js +16 -28
- package/cjs/Tag/index.js +1 -3
- package/cjs/TagGroup/TagGroup.js +1 -3
- package/cjs/TagGroup/index.js +1 -3
- package/cjs/TagInput/index.js +7 -14
- package/cjs/TagPicker/index.js +5 -12
- package/cjs/Timeline/Timeline.js +14 -29
- package/cjs/Timeline/TimelineItem.js +14 -23
- package/cjs/Timeline/index.js +1 -3
- package/cjs/Toggle/Toggle.js +26 -45
- package/cjs/Toggle/index.js +1 -3
- package/cjs/Tooltip/Tooltip.js +13 -22
- package/cjs/Tooltip/index.js +1 -3
- package/cjs/Tree/Tree.js +1 -10
- package/cjs/Tree/TreeContext.js +1 -4
- package/cjs/Tree/index.js +1 -3
- package/cjs/TreePicker/TreeNode.js +37 -60
- package/cjs/TreePicker/TreePicker.js +155 -231
- package/cjs/TreePicker/index.js +1 -3
- package/cjs/Uploader/UploadFileItem.js +37 -82
- package/cjs/Uploader/UploadTrigger.js +24 -46
- package/cjs/Uploader/Uploader.js +89 -141
- package/cjs/Uploader/index.js +1 -3
- package/cjs/Whisper/Whisper.js +8 -20
- package/cjs/Whisper/index.js +1 -3
- package/cjs/Windowing/AutoSizer.js +13 -33
- package/cjs/Windowing/List.d.ts +2 -2
- package/cjs/Windowing/List.js +6 -22
- package/cjs/Windowing/index.js +1 -7
- package/cjs/index.js +1 -164
- package/cjs/locales/ar_EG.js +1 -4
- package/cjs/locales/da_DK.js +1 -5
- package/cjs/locales/de_DE.js +1 -5
- package/cjs/locales/default.js +1 -5
- package/cjs/locales/en_GB.js +1 -3
- package/cjs/locales/en_US.js +1 -4
- package/cjs/locales/es_AR.js +1 -5
- package/cjs/locales/es_ES.js +1 -5
- package/cjs/locales/fa_IR.js +1 -4
- package/cjs/locales/fi_FI.js +1 -5
- package/cjs/locales/fr_FR.js +1 -4
- package/cjs/locales/hu_HU.js +1 -5
- package/cjs/locales/index.js +1 -47
- package/cjs/locales/it_IT.js +1 -5
- package/cjs/locales/ja_JP.js +1 -5
- package/cjs/locales/kk_KZ.js +1 -4
- package/cjs/locales/ko_KR.js +1 -5
- package/cjs/locales/ne_NP.js +1 -5
- package/cjs/locales/nl_NL.js +1 -4
- package/cjs/locales/pt_BR.js +1 -4
- package/cjs/locales/ru_RU.js +1 -4
- package/cjs/locales/sv_SE.js +1 -5
- package/cjs/locales/tr_TR.js +1 -4
- package/cjs/locales/zh_CN.js +1 -4
- package/cjs/locales/zh_TW.js +1 -4
- package/cjs/toaster/ToastContainer.js +29 -52
- package/cjs/toaster/ToastContext.js +1 -4
- package/cjs/toaster/index.js +1 -4
- package/cjs/toaster/toaster.js +4 -27
- package/cjs/toaster/useToaster.js +2 -8
- package/cjs/utils/BrowserDetection.js +7 -24
- package/cjs/utils/ReactChildren.js +2 -19
- package/cjs/utils/ajaxUpload.js +15 -33
- package/cjs/utils/appendTooltip.js +3 -9
- package/cjs/utils/attachParent.js +1 -1
- package/cjs/utils/clone.js +1 -2
- package/cjs/utils/composeFunctions.js +1 -3
- package/cjs/utils/constants.js +3 -8
- package/cjs/utils/createChainedFunction.js +2 -6
- package/cjs/utils/createComponent.js +12 -24
- package/cjs/utils/dateUtils.js +7 -121
- package/cjs/utils/deprecateComponent.js +1 -8
- package/cjs/utils/deprecatePropType.js +2 -9
- package/cjs/utils/dom.js +3 -2
- package/cjs/utils/events.js +2 -3
- package/cjs/utils/getDOMNode.js +16 -9
- package/cjs/utils/getDataGroupBy.d.ts +0 -23
- package/cjs/utils/getDataGroupBy.js +5 -44
- package/cjs/utils/getSafeRegExpString.js +1 -1
- package/cjs/utils/guid.js +1 -1
- package/cjs/utils/htmlPropsUtils.js +23 -20
- package/cjs/utils/index.js +1 -86
- package/cjs/utils/isOneOf.js +1 -2
- package/cjs/utils/mergeRefs.js +1 -2
- package/cjs/utils/placementPolyfill.js +2 -5
- package/cjs/utils/prefix.js +4 -15
- package/cjs/utils/previewFile.js +1 -6
- package/cjs/utils/propTypeChecker.js +1 -8
- package/cjs/utils/reactToString.js +1 -5
- package/cjs/utils/render.js +3 -10
- package/cjs/utils/scrollTopAnimation.js +1 -9
- package/cjs/utils/shallowEqual.js +8 -14
- package/cjs/utils/shallowEqualArray.js +1 -7
- package/cjs/utils/statusIcons.js +1 -9
- package/cjs/utils/stringToObject.js +1 -7
- package/cjs/utils/tplTransform.js +2 -7
- package/cjs/utils/treeUtils.d.ts +1 -1
- package/cjs/utils/treeUtils.js +119 -334
- package/cjs/utils/useClassNames.js +9 -15
- package/cjs/utils/useClickOutside.js +4 -8
- package/cjs/utils/useControlled.js +11 -7
- package/cjs/utils/useCustom.js +12 -25
- package/cjs/utils/useElementResize.js +1 -6
- package/cjs/utils/useEnsuredRef.js +1 -4
- package/cjs/utils/useEventCallback.js +1 -4
- package/cjs/utils/useEventListener.js +1 -5
- package/cjs/utils/useFocus.js +5 -6
- package/cjs/utils/useInternalId.js +1 -6
- package/cjs/utils/useIsMounted.js +1 -3
- package/cjs/utils/useMap.js +5 -7
- package/cjs/utils/useMount.js +1 -4
- package/cjs/utils/usePortal.js +7 -20
- package/cjs/utils/useRootClose.js +9 -19
- package/cjs/utils/useTimeout.js +3 -8
- package/cjs/utils/useToggleCaret.js +2 -14
- package/cjs/utils/useUniqueId.js +2 -9
- package/cjs/utils/useUpdateEffect.js +3 -5
- package/cjs/utils/useUpdatedRef.js +1 -2
- package/cjs/utils/useWillUnmount.js +3 -5
- package/cjs/utils/warnOnce.js +2 -2
- package/dist/rsuite-no-reset-rtl.css +23 -25
- package/dist/rsuite-no-reset-rtl.min.css +1 -1
- package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
- package/dist/rsuite-no-reset.css +23 -25
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite-no-reset.min.css.map +1 -1
- package/dist/rsuite-rtl.css +23 -25
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +23 -25
- package/dist/rsuite.js +407 -440
- 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.map +1 -1
- package/esm/@types/common.js +1 -0
- package/esm/@types/utils.js +14 -2
- package/esm/Affix/Affix.js +39 -50
- package/esm/Affix/index.js +1 -0
- package/esm/Animation/Bounce.js +4 -5
- package/esm/Animation/Collapse.js +19 -26
- package/esm/Animation/Fade.js +6 -7
- package/esm/Animation/Slide.js +6 -7
- package/esm/Animation/Transition.js +16 -69
- package/esm/Animation/index.js +1 -0
- package/esm/Animation/utils.js +1 -2
- package/esm/AutoComplete/AutoComplete.js +55 -75
- package/esm/AutoComplete/index.js +1 -0
- package/esm/AutoComplete/utils.js +1 -4
- package/esm/Avatar/Avatar.js +18 -22
- package/esm/Avatar/index.js +1 -0
- package/esm/AvatarGroup/AvatarGroup.js +13 -16
- package/esm/AvatarGroup/index.js +1 -0
- package/esm/Badge/Badge.js +14 -19
- package/esm/Badge/index.js +1 -0
- package/esm/Breadcrumb/Breadcrumb.js +19 -30
- package/esm/Breadcrumb/BreadcrumbItem.js +14 -17
- package/esm/Breadcrumb/index.js +1 -0
- package/esm/Button/Button.js +22 -28
- package/esm/Button/index.js +1 -0
- package/esm/ButtonGroup/ButtonGroup.js +15 -16
- package/esm/ButtonGroup/ButtonGroupContext.js +1 -0
- package/esm/ButtonGroup/index.js +1 -0
- package/esm/ButtonToolbar/ButtonToolbar.js +10 -12
- package/esm/ButtonToolbar/index.js +1 -0
- package/esm/Calendar/Calendar.js +24 -29
- package/esm/Calendar/CalendarBody.js +14 -18
- package/esm/Calendar/CalendarContainer.js +46 -51
- package/esm/Calendar/CalendarContext.js +1 -0
- package/esm/Calendar/CalendarHeader.js +32 -41
- package/esm/Calendar/MonthDropdown.js +22 -27
- package/esm/Calendar/MonthDropdownItem.js +16 -20
- package/esm/Calendar/Table.js +10 -11
- package/esm/Calendar/TableHeaderRow.js +11 -15
- package/esm/Calendar/TableRow.js +36 -50
- package/esm/Calendar/TimeDropdown.js +24 -48
- package/esm/Calendar/index.js +1 -0
- package/esm/Calendar/types.js +1 -0
- package/esm/Calendar/useCalendarDate.js +3 -11
- package/esm/Calendar/useCalendarState.js +3 -6
- package/esm/Carousel/Carousel.js +40 -52
- package/esm/Carousel/index.js +1 -0
- package/esm/Cascader/Cascader.js +126 -178
- package/esm/Cascader/DropdownMenu.js +33 -45
- package/esm/Cascader/index.js +1 -0
- package/esm/Cascader/utils.js +13 -22
- package/esm/CheckPicker/CheckPicker.js +105 -139
- package/esm/CheckPicker/index.js +1 -0
- package/esm/CheckTree/index.js +1 -0
- package/esm/CheckTreePicker/CheckTreeNode.js +28 -44
- package/esm/CheckTreePicker/CheckTreePicker.js +166 -233
- package/esm/CheckTreePicker/index.js +1 -0
- package/esm/CheckTreePicker/utils.d.ts +1 -1
- package/esm/CheckTreePicker/utils.js +14 -37
- package/esm/Checkbox/Checkbox.js +48 -66
- package/esm/Checkbox/index.js +1 -0
- package/esm/CheckboxGroup/CheckboxGroup.js +20 -25
- package/esm/CheckboxGroup/CheckboxGroupContext.js +1 -0
- package/esm/CheckboxGroup/index.js +1 -0
- package/esm/CloseButton/CloseButton.js +10 -13
- package/esm/CloseButton/index.js +1 -0
- package/esm/Col/Col.js +10 -13
- package/esm/Col/index.js +1 -0
- package/esm/Container/Container.js +11 -13
- package/esm/Container/index.js +1 -0
- package/esm/Content/Content.js +1 -1
- package/esm/Content/index.js +1 -0
- package/esm/CustomProvider/CustomProvider.js +13 -16
- package/esm/CustomProvider/FormattedDate.js +3 -6
- package/esm/CustomProvider/index.js +1 -0
- package/esm/DOMHelper/index.js +1 -2
- package/esm/DOMHelper/isElement.js +1 -1
- package/esm/DatePicker/DatePicker.js +108 -131
- package/esm/DatePicker/PredefinedRanges.js +12 -19
- package/esm/DatePicker/Toolbar.js +20 -26
- package/esm/DatePicker/index.js +1 -0
- package/esm/DatePicker/types.js +1 -0
- package/esm/DatePicker/utils.js +5 -8
- package/esm/DateRangePicker/Calendar.js +18 -18
- package/esm/DateRangePicker/DateRangePicker.js +128 -184
- package/esm/DateRangePicker/DateRangePickerContext.js +1 -0
- package/esm/DateRangePicker/disabledDateUtils.js +9 -24
- package/esm/DateRangePicker/index.js +1 -0
- package/esm/DateRangePicker/types.js +1 -0
- package/esm/DateRangePicker/utils.js +7 -12
- package/esm/Disclosure/Disclosure.js +13 -24
- package/esm/Disclosure/DisclosureButton.js +4 -7
- package/esm/Disclosure/DisclosureContent.js +1 -2
- package/esm/Disclosure/DisclosureContext.js +1 -2
- package/esm/Disclosure/index.js +1 -0
- package/esm/Disclosure/useDisclosureContext.js +1 -2
- package/esm/Divider/Divider.js +11 -12
- package/esm/Divider/index.js +1 -0
- package/esm/Drawer/Drawer.js +10 -11
- package/esm/Drawer/index.js +1 -0
- package/esm/Dropdown/Dropdown.js +35 -50
- package/esm/Dropdown/DropdownContext.js +1 -0
- package/esm/Dropdown/DropdownItem.js +22 -31
- package/esm/Dropdown/DropdownMenu.js +36 -49
- package/esm/Dropdown/DropdownSeparator.js +8 -10
- package/esm/Dropdown/DropdownState.js +1 -7
- package/esm/Dropdown/DropdownToggle.js +17 -17
- package/esm/Dropdown/index.js +1 -0
- package/esm/Dropdown/useRenderDropdownItem.js +1 -2
- package/esm/FlexboxGrid/FlexboxGrid.js +12 -13
- package/esm/FlexboxGrid/FlexboxGridItem.js +12 -14
- package/esm/FlexboxGrid/index.js +1 -0
- package/esm/Footer/Footer.js +1 -0
- package/esm/Footer/index.js +1 -0
- package/esm/Form/Form.js +36 -63
- package/esm/Form/FormContext.js +1 -0
- package/esm/Form/index.js +1 -0
- package/esm/Form/useFormClassNames.js +11 -13
- package/esm/Form/useSchemaModel.js +2 -4
- package/esm/FormControl/FormControl.js +48 -68
- package/esm/FormControl/index.js +1 -0
- package/esm/FormControl/useRegisterModel.js +1 -2
- package/esm/FormControlLabel/FormControlLabel.js +10 -12
- package/esm/FormControlLabel/index.js +1 -0
- package/esm/FormErrorMessage/FormErrorMessage.js +12 -18
- package/esm/FormErrorMessage/index.js +1 -0
- package/esm/FormGroup/FormGroup.js +9 -10
- package/esm/FormGroup/index.js +1 -0
- package/esm/FormHelpText/FormHelpText.js +11 -15
- package/esm/FormHelpText/index.js +1 -0
- package/esm/Grid/Grid.js +10 -11
- package/esm/Grid/index.js +1 -0
- package/esm/Header/Header.js +1 -0
- package/esm/Header/index.js +1 -0
- package/esm/IconButton/IconButton.js +11 -12
- package/esm/IconButton/index.js +1 -0
- package/esm/Input/Input.js +26 -32
- package/esm/Input/index.js +1 -0
- package/esm/InputGroup/InputGroup.js +23 -26
- package/esm/InputGroup/InputGroupAddon.js +9 -10
- package/esm/InputGroup/InputGroupButton.js +7 -9
- package/esm/InputGroup/index.js +1 -0
- package/esm/InputNumber/InputNumber.js +42 -72
- package/esm/InputNumber/index.js +1 -0
- package/esm/InputPicker/InputAutosize.js +17 -37
- package/esm/InputPicker/InputPicker.js +149 -225
- package/esm/InputPicker/InputSearch.js +15 -20
- package/esm/InputPicker/index.js +1 -0
- package/esm/List/List.js +37 -39
- package/esm/List/ListContext.js +1 -0
- package/esm/List/ListItem.js +26 -30
- package/esm/List/helper/AutoScroller.js +11 -21
- package/esm/List/helper/useManager.js +1 -6
- package/esm/List/helper/useSortHelper.js +58 -74
- package/esm/List/helper/utils.js +6 -11
- package/esm/List/index.js +1 -0
- package/esm/Loader/Loader.js +17 -19
- package/esm/Loader/index.js +1 -0
- package/esm/MaskedInput/MaskedInput.js +2 -1
- package/esm/MaskedInput/TextMask.js +12 -14
- package/esm/MaskedInput/adjustCaretPosition.js +99 -69
- package/esm/MaskedInput/conformToMask.js +79 -70
- package/esm/MaskedInput/createTextMaskInputElement.js +65 -62
- package/esm/MaskedInput/index.js +1 -0
- package/esm/MaskedInput/types.js +1 -0
- package/esm/MaskedInput/utilities.js +1 -6
- package/esm/Menu/Menu.js +35 -66
- package/esm/Menu/MenuContext.js +1 -4
- package/esm/Menu/MenuItem.js +15 -19
- package/esm/Menu/Menubar.js +13 -23
- package/esm/Menu/index.js +1 -0
- package/esm/Menu/useMenu.js +4 -27
- package/esm/Message/Message.js +23 -34
- package/esm/Message/index.js +1 -0
- package/esm/Modal/Modal.js +70 -69
- package/esm/Modal/ModalBody.js +11 -13
- package/esm/Modal/ModalContext.js +1 -0
- package/esm/Modal/ModalDialog.js +14 -18
- package/esm/Modal/ModalFooter.js +1 -0
- package/esm/Modal/ModalHeader.js +14 -16
- package/esm/Modal/ModalTitle.js +9 -10
- package/esm/Modal/index.js +1 -0
- package/esm/Modal/utils.js +8 -12
- package/esm/MultiCascader/DropdownMenu.js +38 -48
- package/esm/MultiCascader/MultiCascader.js +129 -174
- package/esm/MultiCascader/index.js +1 -0
- package/esm/MultiCascader/utils.js +44 -87
- package/esm/Nav/Nav.js +27 -45
- package/esm/Nav/NavContext.js +1 -0
- package/esm/Nav/NavDropdown.js +28 -44
- package/esm/Nav/NavDropdownItem.js +20 -31
- package/esm/Nav/NavDropdownMenu.js +26 -42
- package/esm/Nav/NavDropdownToggle.js +12 -15
- package/esm/Nav/NavItem.js +20 -28
- package/esm/Nav/NavMenu.js +2 -13
- package/esm/Nav/index.js +1 -0
- package/esm/Navbar/Navbar.js +10 -11
- package/esm/Navbar/NavbarBody.js +1 -0
- package/esm/Navbar/NavbarBrand.js +1 -0
- package/esm/Navbar/NavbarDropdown.js +25 -33
- package/esm/Navbar/NavbarDropdownItem.js +18 -30
- package/esm/Navbar/NavbarDropdownMenu.js +22 -37
- package/esm/Navbar/NavbarDropdownToggle.js +12 -14
- package/esm/Navbar/NavbarHeader.js +1 -0
- package/esm/Navbar/NavbarItem.js +19 -23
- package/esm/Navbar/index.js +1 -0
- package/esm/Notification/Notification.js +20 -32
- package/esm/Notification/index.js +1 -0
- package/esm/Overlay/Modal.js +40 -64
- package/esm/Overlay/ModalManager.js +1 -19
- package/esm/Overlay/Overlay.js +28 -37
- package/esm/Overlay/OverlayContext.js +1 -0
- package/esm/Overlay/OverlayTrigger.js +68 -101
- package/esm/Overlay/Position.js +25 -47
- package/esm/Overlay/index.js +1 -0
- package/esm/Overlay/positionUtils.js +25 -73
- package/esm/Pagination/Pagination.js +30 -55
- package/esm/Pagination/PaginationButton.js +15 -19
- package/esm/Pagination/PaginationGroup.js +38 -49
- package/esm/Pagination/index.js +1 -0
- package/esm/Panel/Panel.js +37 -49
- package/esm/Panel/index.js +1 -0
- package/esm/PanelGroup/PanelGroup.js +16 -18
- package/esm/PanelGroup/index.js +1 -0
- package/esm/Picker/DropdownMenu.js +50 -72
- package/esm/Picker/DropdownMenuCheckItem.js +22 -24
- package/esm/Picker/DropdownMenuGroup.js +10 -13
- package/esm/Picker/DropdownMenuItem.js +15 -18
- package/esm/Picker/PickerOverlay.js +12 -17
- package/esm/Picker/PickerToggle.js +57 -71
- package/esm/Picker/PickerToggleTrigger.js +8 -10
- package/esm/Picker/SearchBar.js +14 -15
- package/esm/Picker/SelectedElement.js +9 -14
- package/esm/Picker/ToggleButton.js +1 -0
- package/esm/Picker/index.js +1 -0
- package/esm/Picker/propTypes.js +1 -1
- package/esm/Picker/types.js +1 -0
- package/esm/Picker/utils.js +94 -182
- package/esm/Placeholder/Placeholder.js +1 -0
- package/esm/Placeholder/PlaceholderGraph.js +13 -16
- package/esm/Placeholder/PlaceholderGrid.js +18 -25
- package/esm/Placeholder/PlaceholderParagraph.js +17 -20
- package/esm/Placeholder/index.js +1 -0
- package/esm/Plaintext/Plaintext.js +14 -17
- package/esm/Plaintext/index.js +1 -0
- package/esm/Popover/Popover.js +16 -21
- package/esm/Popover/index.js +1 -0
- package/esm/Progress/Progress.js +1 -0
- package/esm/Progress/ProgressCircle.js +30 -39
- package/esm/Progress/ProgressLine.js +19 -21
- package/esm/Progress/index.js +1 -0
- package/esm/Radio/Radio.js +42 -52
- package/esm/Radio/index.js +1 -0
- package/esm/RadioGroup/RadioGroup.js +22 -25
- package/esm/RadioGroup/index.js +1 -0
- package/esm/RadioTile/RadioTile.js +30 -34
- package/esm/RadioTile/index.js +1 -0
- package/esm/RadioTileGroup/RadioTileGroup.js +17 -20
- package/esm/RadioTileGroup/index.js +1 -0
- package/esm/RangeSlider/RangeSlider.js +63 -86
- package/esm/RangeSlider/index.js +1 -0
- package/esm/Rate/Character.js +16 -21
- package/esm/Rate/Rate.js +35 -48
- package/esm/Rate/index.js +1 -0
- package/esm/Rate/utils.js +1 -2
- package/esm/Ripple/Ripple.js +16 -30
- package/esm/Ripple/index.js +1 -0
- package/esm/Row/Row.js +11 -14
- package/esm/Row/index.js +1 -0
- package/esm/SafeAnchor/SafeAnchor.js +8 -13
- package/esm/SafeAnchor/index.js +1 -0
- package/esm/Schema/Schema.js +1 -0
- package/esm/Schema/index.js +1 -0
- package/esm/SelectPicker/SelectPicker.js +137 -157
- package/esm/SelectPicker/index.js +1 -0
- package/esm/Sidebar/Sidebar.js +13 -18
- package/esm/Sidebar/index.js +1 -0
- package/esm/Sidenav/ExpandedSidenavDropdown.js +32 -35
- package/esm/Sidenav/ExpandedSidenavDropdownItem.js +19 -27
- package/esm/Sidenav/ExpandedSidenavDropdownMenu.js +22 -29
- package/esm/Sidenav/Node.js +1 -10
- package/esm/Sidenav/Sidenav.js +22 -28
- package/esm/Sidenav/SidenavBody.js +1 -0
- package/esm/Sidenav/SidenavDropdown.js +39 -52
- package/esm/Sidenav/SidenavDropdownCollapse.js +9 -13
- package/esm/Sidenav/SidenavDropdownItem.js +19 -31
- package/esm/Sidenav/SidenavDropdownMenu.js +26 -41
- package/esm/Sidenav/SidenavDropdownToggle.js +12 -14
- package/esm/Sidenav/SidenavHeader.js +1 -0
- package/esm/Sidenav/SidenavItem.js +27 -37
- package/esm/Sidenav/SidenavToggle.js +11 -18
- package/esm/Sidenav/index.js +1 -0
- package/esm/Slider/Graduated.js +14 -21
- package/esm/Slider/Handle.js +27 -39
- package/esm/Slider/Input.js +2 -2
- package/esm/Slider/Mark.js +11 -14
- package/esm/Slider/ProgressBar.js +14 -18
- package/esm/Slider/Slider.js +51 -67
- package/esm/Slider/index.js +1 -0
- package/esm/Slider/utils.js +1 -5
- package/esm/Stack/Stack.js +22 -27
- package/esm/Stack/StackItem.js +11 -11
- package/esm/Stack/index.js +1 -0
- package/esm/Steps/StepItem.js +16 -22
- package/esm/Steps/Steps.js +18 -22
- package/esm/Steps/index.js +1 -0
- package/esm/Table/Table.js +6 -7
- package/esm/Table/index.js +1 -0
- package/esm/Tag/Tag.js +16 -19
- package/esm/Tag/index.js +1 -0
- package/esm/TagGroup/TagGroup.js +1 -0
- package/esm/TagGroup/index.js +1 -0
- package/esm/TagInput/index.js +7 -7
- package/esm/TagPicker/index.js +5 -5
- package/esm/Timeline/Timeline.js +14 -19
- package/esm/Timeline/TimelineItem.js +14 -15
- package/esm/Timeline/index.js +1 -0
- package/esm/Toggle/Toggle.js +26 -35
- package/esm/Toggle/index.js +1 -0
- package/esm/Tooltip/Tooltip.js +13 -16
- package/esm/Tooltip/index.js +1 -0
- package/esm/Tree/Tree.js +1 -3
- package/esm/Tree/TreeContext.js +1 -0
- package/esm/Tree/index.js +1 -0
- package/esm/TreePicker/TreeNode.js +37 -49
- package/esm/TreePicker/TreePicker.js +155 -218
- package/esm/TreePicker/index.js +1 -0
- package/esm/Uploader/UploadFileItem.js +37 -68
- package/esm/Uploader/UploadTrigger.js +24 -38
- package/esm/Uploader/Uploader.js +90 -132
- package/esm/Uploader/index.js +1 -0
- package/esm/Whisper/Whisper.js +8 -10
- package/esm/Whisper/index.js +1 -0
- package/esm/Windowing/AutoSizer.js +13 -24
- package/esm/Windowing/List.d.ts +2 -2
- package/esm/Windowing/List.js +6 -15
- package/esm/Windowing/index.js +1 -0
- package/esm/index.js +3 -0
- package/esm/locales/ar_EG.js +1 -0
- package/esm/locales/da_DK.js +1 -1
- package/esm/locales/de_DE.js +1 -1
- package/esm/locales/default.js +1 -1
- package/esm/locales/en_GB.js +1 -0
- package/esm/locales/en_US.js +1 -0
- package/esm/locales/es_AR.js +1 -1
- package/esm/locales/es_ES.js +1 -1
- package/esm/locales/fa_IR.js +1 -0
- package/esm/locales/fi_FI.js +1 -1
- package/esm/locales/fr_FR.js +1 -0
- package/esm/locales/hu_HU.js +1 -1
- package/esm/locales/index.js +1 -0
- package/esm/locales/it_IT.js +1 -1
- package/esm/locales/ja_JP.js +1 -1
- package/esm/locales/kk_KZ.js +1 -0
- package/esm/locales/ko_KR.js +1 -1
- package/esm/locales/ne_NP.js +1 -1
- package/esm/locales/nl_NL.js +1 -0
- package/esm/locales/pt_BR.js +1 -0
- package/esm/locales/ru_RU.js +1 -0
- package/esm/locales/sv_SE.js +1 -1
- package/esm/locales/tr_TR.js +1 -0
- package/esm/locales/zh_CN.js +1 -0
- package/esm/locales/zh_TW.js +1 -0
- package/esm/toaster/ToastContainer.js +29 -42
- package/esm/toaster/ToastContext.js +1 -0
- package/esm/toaster/index.js +1 -0
- package/esm/toaster/toaster.js +4 -22
- package/esm/toaster/useToaster.js +3 -5
- package/esm/utils/BrowserDetection.js +9 -9
- package/esm/utils/ReactChildren.js +2 -8
- package/esm/utils/ajaxUpload.js +15 -32
- package/esm/utils/appendTooltip.js +3 -3
- package/esm/utils/attachParent.js +1 -0
- package/esm/utils/clone.js +1 -1
- package/esm/utils/composeFunctions.js +1 -1
- package/esm/utils/constants.js +4 -7
- package/esm/utils/createChainedFunction.js +2 -5
- package/esm/utils/createComponent.js +12 -16
- package/esm/utils/dateUtils.js +7 -23
- package/esm/utils/deprecateComponent.js +2 -2
- package/esm/utils/deprecatePropType.js +4 -6
- package/esm/utils/dom.js +3 -1
- package/esm/utils/events.js +2 -1
- package/esm/utils/getDOMNode.js +15 -8
- package/esm/utils/getDataGroupBy.d.ts +0 -23
- package/esm/utils/getDataGroupBy.js +5 -39
- package/esm/utils/getSafeRegExpString.js +1 -0
- package/esm/utils/guid.js +1 -0
- package/esm/utils/htmlPropsUtils.js +23 -14
- package/esm/utils/index.js +2 -1
- package/esm/utils/isOneOf.js +1 -1
- package/esm/utils/mergeRefs.js +1 -1
- package/esm/utils/placementPolyfill.js +2 -4
- package/esm/utils/prefix.js +4 -4
- package/esm/utils/previewFile.js +1 -3
- package/esm/utils/propTypeChecker.js +1 -3
- package/esm/utils/reactToString.js +1 -2
- package/esm/utils/render.js +3 -5
- package/esm/utils/scrollTopAnimation.js +1 -5
- package/esm/utils/shallowEqual.js +8 -13
- package/esm/utils/shallowEqualArray.js +1 -5
- package/esm/utils/statusIcons.js +1 -0
- package/esm/utils/stringToObject.js +3 -4
- package/esm/utils/tplTransform.js +2 -4
- package/esm/utils/treeUtils.d.ts +1 -1
- package/esm/utils/treeUtils.js +120 -272
- package/esm/utils/useClassNames.js +9 -9
- package/esm/utils/useClickOutside.js +4 -6
- package/esm/utils/useControlled.js +12 -6
- package/esm/utils/useCustom.js +12 -20
- package/esm/utils/useElementResize.js +2 -4
- package/esm/utils/useEnsuredRef.js +2 -3
- package/esm/utils/useEventCallback.js +2 -3
- package/esm/utils/useEventListener.js +2 -2
- package/esm/utils/useFocus.js +5 -4
- package/esm/utils/useInternalId.js +2 -3
- package/esm/utils/useIsMounted.js +1 -2
- package/esm/utils/useMap.js +5 -5
- package/esm/utils/useMount.js +1 -3
- package/esm/utils/usePortal.js +7 -13
- package/esm/utils/useRootClose.js +9 -13
- package/esm/utils/useTimeout.js +3 -7
- package/esm/utils/useToggleCaret.js +2 -7
- package/esm/utils/useUniqueId.js +2 -4
- package/esm/utils/useUpdateEffect.js +3 -4
- package/esm/utils/useUpdatedRef.js +2 -1
- package/esm/utils/useWillUnmount.js +4 -2
- package/esm/utils/warnOnce.js +2 -2
- package/package.json +2 -2
- package/styles/color-modes/light.less +4 -4
- package/styles/mixins/listbox.less +0 -2
- package/cjs/SelectPicker/Listbox.d.ts +0 -34
- package/cjs/SelectPicker/Listbox.js +0 -263
- package/cjs/SelectPicker/ListboxOption.d.ts +0 -11
- package/cjs/SelectPicker/ListboxOption.js +0 -50
- package/cjs/SelectPicker/ListboxOptionGroup.d.ts +0 -9
- package/cjs/SelectPicker/ListboxOptionGroup.js +0 -69
- package/esm/SelectPicker/Listbox.d.ts +0 -34
- package/esm/SelectPicker/Listbox.js +0 -240
- package/esm/SelectPicker/ListboxOption.d.ts +0 -11
- package/esm/SelectPicker/ListboxOption.js +0 -37
- package/esm/SelectPicker/ListboxOptionGroup.d.ts +0 -9
- package/esm/SelectPicker/ListboxOptionGroup.js +0 -53
|
@@ -1,66 +1,69 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
"use strict";
|
|
2
3
|
|
|
3
4
|
exports.__esModule = true;
|
|
4
5
|
exports.default = adjustCaretPosition;
|
|
5
6
|
var defaultArray = [];
|
|
6
7
|
var emptyString = '';
|
|
7
|
-
|
|
8
8
|
function adjustCaretPosition(_ref) {
|
|
9
9
|
var _ref$previousConforme = _ref.previousConformedValue,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
previousConformedValue = _ref$previousConforme === void 0 ? emptyString : _ref$previousConforme,
|
|
11
|
+
_ref$previousPlacehol = _ref.previousPlaceholder,
|
|
12
|
+
previousPlaceholder = _ref$previousPlacehol === void 0 ? emptyString : _ref$previousPlacehol,
|
|
13
|
+
_ref$currentCaretPosi = _ref.currentCaretPosition,
|
|
14
|
+
currentCaretPosition = _ref$currentCaretPosi === void 0 ? 0 : _ref$currentCaretPosi,
|
|
15
|
+
conformedValue = _ref.conformedValue,
|
|
16
|
+
rawValue = _ref.rawValue,
|
|
17
|
+
placeholderChar = _ref.placeholderChar,
|
|
18
|
+
placeholder = _ref.placeholder,
|
|
19
|
+
_ref$indexesOfPipedCh = _ref.indexesOfPipedChars,
|
|
20
|
+
indexesOfPipedChars = _ref$indexesOfPipedCh === void 0 ? defaultArray : _ref$indexesOfPipedCh,
|
|
21
|
+
_ref$caretTrapIndexes = _ref.caretTrapIndexes,
|
|
22
|
+
caretTrapIndexes = _ref$caretTrapIndexes === void 0 ? defaultArray : _ref$caretTrapIndexes;
|
|
24
23
|
if (currentCaretPosition === 0 || !rawValue.length) {
|
|
25
24
|
return 0;
|
|
26
|
-
}
|
|
27
|
-
|
|
25
|
+
}
|
|
28
26
|
|
|
27
|
+
// Store lengths for faster performance?
|
|
29
28
|
var rawValueLength = rawValue.length;
|
|
30
29
|
var previousConformedValueLength = previousConformedValue.length;
|
|
31
30
|
var placeholderLength = placeholder.length;
|
|
32
|
-
var conformedValueLength = conformedValue.length;
|
|
31
|
+
var conformedValueLength = conformedValue.length;
|
|
32
|
+
|
|
33
|
+
// This tells us how long the edit is. If user modified input from `(2__)` to `(243__)`,
|
|
33
34
|
// we know the user in this instance pasted two characters
|
|
35
|
+
var editLength = rawValueLength - previousConformedValueLength;
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
// If the edit length is positive, that means the user is adding characters, not deleting.
|
|
38
|
+
var isAddition = editLength > 0;
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
// This is the first raw value the user entered that needs to be conformed to mask
|
|
41
|
+
var isFirstRawValue = previousConformedValueLength === 0;
|
|
38
42
|
|
|
39
|
-
|
|
43
|
+
// A partial multi-character edit happens when the user makes a partial selection in their
|
|
40
44
|
// input and edits that selection. That is going from `(123) 432-4348` to `() 432-4348` by
|
|
41
45
|
// selecting the first 3 digits and pressing backspace.
|
|
42
46
|
//
|
|
43
47
|
// Such cases can also happen when the user presses the backspace while holding down the ALT
|
|
44
48
|
// key.
|
|
49
|
+
var isPartialMultiCharEdit = editLength > 1 && !isFirstRawValue;
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
// This algorithm doesn't support all cases of multi-character edits, so we just return
|
|
47
52
|
// the current caret position.
|
|
48
53
|
//
|
|
49
54
|
// This works fine for most cases.
|
|
50
|
-
|
|
51
55
|
if (isPartialMultiCharEdit) {
|
|
52
56
|
return currentCaretPosition;
|
|
53
|
-
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// For a mask like (111), if the `previousConformedValue` is (1__) and user attempts to enter
|
|
54
60
|
// `f` so the `rawValue` becomes (1f__), the new `conformedValue` would be (1__), which is the
|
|
55
61
|
// same as the original `previousConformedValue`. We handle this case differently for caret
|
|
56
62
|
// positioning.
|
|
57
|
-
|
|
58
|
-
|
|
59
63
|
var possiblyHasRejectedChar = isAddition && (previousConformedValue === conformedValue || conformedValue === placeholder);
|
|
60
64
|
var startingSearchIndex = 0;
|
|
61
65
|
var trackRightCharacter;
|
|
62
66
|
var targetChar;
|
|
63
|
-
|
|
64
67
|
if (possiblyHasRejectedChar) {
|
|
65
68
|
startingSearchIndex = currentCaretPosition - editLength;
|
|
66
69
|
} else {
|
|
@@ -69,114 +72,131 @@ function adjustCaretPosition(_ref) {
|
|
|
69
72
|
//
|
|
70
73
|
// We do that by seeing what character lies immediately before the caret, and then look for that
|
|
71
74
|
// same character in the conformed input and place the caret there.
|
|
75
|
+
|
|
72
76
|
// First, we need to normalize the inputs so that letter capitalization between raw input and
|
|
73
77
|
// conformed input wouldn't matter.
|
|
74
78
|
var normalizedConformedValue = conformedValue.toLowerCase();
|
|
75
|
-
var normalizedRawValue = rawValue.toLowerCase();
|
|
79
|
+
var normalizedRawValue = rawValue.toLowerCase();
|
|
76
80
|
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
// Then we take all characters that come before where the caret currently is.
|
|
82
|
+
var leftHalfChars = normalizedRawValue.substr(0, currentCaretPosition).split(emptyString);
|
|
79
83
|
|
|
84
|
+
// Now we find all the characters in the left half that exist in the conformed input
|
|
85
|
+
// This step ensures that we don't look for a character that was filtered out or rejected by `conformToMask`.
|
|
80
86
|
var intersection = leftHalfChars.filter(function (char) {
|
|
81
87
|
return normalizedConformedValue.indexOf(char) !== -1;
|
|
82
|
-
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// The last character in the intersection is the character we want to look for in the conformed
|
|
83
91
|
// value and the one we want to adjust the caret close to
|
|
92
|
+
targetChar = intersection[intersection.length - 1];
|
|
84
93
|
|
|
85
|
-
|
|
94
|
+
// Calculate the number of mask characters in the previous placeholder
|
|
86
95
|
// from the start of the string up to the place where the caret is
|
|
87
|
-
|
|
88
96
|
var previousLeftMaskChars = previousPlaceholder.substr(0, intersection.length).split(emptyString).filter(function (char) {
|
|
89
97
|
return char !== placeholderChar;
|
|
90
|
-
}).length;
|
|
91
|
-
// from the start of the string up to the place where the caret is
|
|
98
|
+
}).length;
|
|
92
99
|
|
|
100
|
+
// Calculate the number of mask characters in the current placeholder
|
|
101
|
+
// from the start of the string up to the place where the caret is
|
|
93
102
|
var leftMaskChars = placeholder.substr(0, intersection.length).split(emptyString).filter(function (char) {
|
|
94
103
|
return char !== placeholderChar;
|
|
95
|
-
}).length;
|
|
104
|
+
}).length;
|
|
105
|
+
|
|
106
|
+
// Has the number of mask characters up to the caret changed?
|
|
107
|
+
var masklengthChanged = leftMaskChars !== previousLeftMaskChars;
|
|
96
108
|
|
|
97
|
-
|
|
109
|
+
// Detect if `targetChar` is a mask character and has moved to the left
|
|
110
|
+
var targetIsMaskMovingLeft = previousPlaceholder[intersection.length - 1] !== undefined && placeholder[intersection.length - 2] !== undefined && previousPlaceholder[intersection.length - 1] !== placeholderChar && previousPlaceholder[intersection.length - 1] !== placeholder[intersection.length - 1] && previousPlaceholder[intersection.length - 1] === placeholder[intersection.length - 2];
|
|
98
111
|
|
|
99
|
-
|
|
112
|
+
// If deleting and the `targetChar` `is a mask character and `masklengthChanged` is true
|
|
100
113
|
// or the mask is moving to the left, we can't use the selected `targetChar` any longer
|
|
101
114
|
// if we are not at the end of the string.
|
|
102
115
|
// In this case, change tracking strategy and track the character to the right of the caret.
|
|
103
|
-
|
|
104
116
|
if (!isAddition && (masklengthChanged || targetIsMaskMovingLeft) && previousLeftMaskChars > 0 && placeholder.indexOf(targetChar) > -1 && rawValue[currentCaretPosition] !== undefined) {
|
|
105
117
|
trackRightCharacter = true;
|
|
106
118
|
targetChar = rawValue[currentCaretPosition];
|
|
107
|
-
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// It is possible that `targetChar` will appear multiple times in the conformed value.
|
|
108
122
|
// We need to know not to select a character that looks like our target character from the placeholder or
|
|
109
123
|
// the piped characters, so we inspect the piped characters and the placeholder to see if they contain
|
|
110
124
|
// characters that match our target character.
|
|
125
|
+
|
|
111
126
|
// If the `conformedValue` got piped, we need to know which characters were piped in so that when we look for
|
|
112
127
|
// our `targetChar`, we don't select a piped char by mistake
|
|
113
|
-
|
|
114
|
-
|
|
115
128
|
var pipedChars = indexesOfPipedChars.map(function (index) {
|
|
116
129
|
return normalizedConformedValue[index];
|
|
117
|
-
});
|
|
130
|
+
});
|
|
118
131
|
|
|
132
|
+
// We need to know how many times the `targetChar` occurs in the piped characters.
|
|
119
133
|
var countTargetCharInPipedChars = pipedChars.filter(function (char) {
|
|
120
134
|
return char === targetChar;
|
|
121
|
-
}).length;
|
|
135
|
+
}).length;
|
|
122
136
|
|
|
137
|
+
// We need to know how many times it occurs in the intersection
|
|
123
138
|
var countTargetCharInIntersection = intersection.filter(function (char) {
|
|
124
139
|
return char === targetChar;
|
|
125
|
-
}).length;
|
|
126
|
-
// our `targetChar`, so we don't select one of those by mistake.
|
|
140
|
+
}).length;
|
|
127
141
|
|
|
142
|
+
// We need to know if the placeholder contains characters that look like
|
|
143
|
+
// our `targetChar`, so we don't select one of those by mistake.
|
|
128
144
|
var countTargetCharInPlaceholder = placeholder.substr(0, placeholder.indexOf(placeholderChar)).split(emptyString).filter(function (char, index) {
|
|
129
|
-
return (
|
|
130
|
-
|
|
145
|
+
return (
|
|
146
|
+
// Check if `char` is the same as our `targetChar`, so we account for it
|
|
147
|
+
char === targetChar &&
|
|
148
|
+
// but also make sure that both the `rawValue` and placeholder don't have the same character at the same
|
|
131
149
|
// index because if they are equal, that means we are already counting those characters in
|
|
132
150
|
// `countTargetCharInIntersection`
|
|
133
151
|
rawValue[index] !== char
|
|
134
152
|
);
|
|
135
|
-
}).length;
|
|
136
|
-
// for is:
|
|
153
|
+
}).length;
|
|
137
154
|
|
|
138
|
-
|
|
155
|
+
// The number of times we need to see occurrences of the `targetChar` before we know it is the one we're looking
|
|
156
|
+
// for is:
|
|
157
|
+
var requiredNumberOfMatches = countTargetCharInPlaceholder + countTargetCharInIntersection + countTargetCharInPipedChars + (
|
|
158
|
+
// The character to the right of the caret isn't included in `intersection`
|
|
139
159
|
// so add one if we are tracking the character to the right
|
|
140
|
-
trackRightCharacter ? 1 : 0);
|
|
160
|
+
trackRightCharacter ? 1 : 0);
|
|
161
|
+
|
|
162
|
+
// Now we start looking for the location of the `targetChar`.
|
|
141
163
|
// We keep looping forward and store the index in every iteration. Once we have encountered
|
|
142
164
|
// enough occurrences of the target character, we break out of the loop
|
|
143
165
|
// If are searching for the second `1` in `1214`, `startingSearchIndex` will point at `4`.
|
|
144
|
-
|
|
145
166
|
var numberOfEncounteredMatches = 0;
|
|
146
|
-
|
|
147
167
|
for (var i = 0; i < conformedValueLength; i++) {
|
|
148
168
|
var conformedValueChar = normalizedConformedValue[i];
|
|
149
169
|
startingSearchIndex = i + 1;
|
|
150
|
-
|
|
151
170
|
if (conformedValueChar === targetChar) {
|
|
152
171
|
numberOfEncounteredMatches++;
|
|
153
172
|
}
|
|
154
|
-
|
|
155
173
|
if (numberOfEncounteredMatches >= requiredNumberOfMatches) {
|
|
156
174
|
break;
|
|
157
175
|
}
|
|
158
176
|
}
|
|
159
|
-
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// At this point, if we simply return `startingSearchIndex` as the adjusted caret position,
|
|
160
180
|
// most cases would be handled. However, we want to fast forward or rewind the caret to the
|
|
161
181
|
// closest placeholder character if it happens to be in a non-editable spot. That's what the next
|
|
162
182
|
// logic is for.
|
|
163
|
-
// In case of addition, we fast forward.
|
|
164
|
-
|
|
165
183
|
|
|
184
|
+
// In case of addition, we fast forward.
|
|
166
185
|
if (isAddition) {
|
|
167
186
|
// We want to remember the last placeholder character encountered so that if the mask
|
|
168
187
|
// contains more characters after the last placeholder character, we don't forward the caret
|
|
169
188
|
// that far to the right. Instead, we stop it at the last encountered placeholder character.
|
|
170
189
|
var lastPlaceholderChar = startingSearchIndex;
|
|
171
|
-
|
|
172
190
|
for (var _i = startingSearchIndex; _i <= placeholderLength; _i++) {
|
|
173
191
|
if (placeholder[_i] === placeholderChar) {
|
|
174
192
|
lastPlaceholderChar = _i;
|
|
175
193
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
placeholder[_i] === placeholderChar ||
|
|
179
|
-
|
|
194
|
+
if (
|
|
195
|
+
// If we're adding, we can position the caret at the next placeholder character.
|
|
196
|
+
placeholder[_i] === placeholderChar ||
|
|
197
|
+
// If a caret trap was set by a mask function, we need to stop at the trap.
|
|
198
|
+
caretTrapIndexes.indexOf(_i) !== -1 ||
|
|
199
|
+
// This is the end of the placeholder. We cannot move any further. Let's put the caret there.
|
|
180
200
|
_i === placeholderLength) {
|
|
181
201
|
return lastPlaceholderChar;
|
|
182
202
|
}
|
|
@@ -189,10 +209,14 @@ function adjustCaretPosition(_ref) {
|
|
|
189
209
|
for (var _i2 = startingSearchIndex - 1; _i2 >= 0; _i2--) {
|
|
190
210
|
// If tracking the character to the right of the cursor, we move to the left until
|
|
191
211
|
// we found the character and then place the caret right before it
|
|
192
|
-
|
|
212
|
+
|
|
213
|
+
if (
|
|
214
|
+
// `targetChar` should be in `conformedValue`, since it was in `rawValue`, just
|
|
193
215
|
// to the right of the caret
|
|
194
|
-
conformedValue[_i2] === targetChar ||
|
|
195
|
-
|
|
216
|
+
conformedValue[_i2] === targetChar ||
|
|
217
|
+
// If a caret trap was set by a mask function, we need to stop at the trap.
|
|
218
|
+
caretTrapIndexes.indexOf(_i2) !== -1 ||
|
|
219
|
+
// This is the beginning of the placeholder. We cannot move any further.
|
|
196
220
|
// Let's put the caret there.
|
|
197
221
|
_i2 === 0) {
|
|
198
222
|
return _i2;
|
|
@@ -200,14 +224,19 @@ function adjustCaretPosition(_ref) {
|
|
|
200
224
|
}
|
|
201
225
|
} else {
|
|
202
226
|
// Searching for the first placeholder or caret trap to the left
|
|
227
|
+
|
|
203
228
|
for (var _i3 = startingSearchIndex; _i3 >= 0; _i3--) {
|
|
204
229
|
// If we're deleting, we stop the caret right before the placeholder character.
|
|
205
230
|
// For example, for mask `(111) 11`, current conformed input `(456) 86`. If user
|
|
206
231
|
// modifies input to `(456 86`. That is, they deleted the `)`, we place the caret
|
|
207
232
|
// right after the first `6`
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
233
|
+
|
|
234
|
+
if (
|
|
235
|
+
// If we're deleting, we can position the caret right before the placeholder character
|
|
236
|
+
placeholder[_i3 - 1] === placeholderChar ||
|
|
237
|
+
// If a caret trap was set by a mask function, we need to stop at the trap.
|
|
238
|
+
caretTrapIndexes.indexOf(_i3) !== -1 ||
|
|
239
|
+
// This is the beginning of the placeholder. We cannot move any further.
|
|
211
240
|
// Let's put the caret there.
|
|
212
241
|
_i3 === 0) {
|
|
213
242
|
return _i3;
|
|
@@ -1,28 +1,23 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
"use strict";
|
|
2
3
|
|
|
3
4
|
exports.__esModule = true;
|
|
4
5
|
exports.isArray = isArray;
|
|
5
6
|
exports.default = conformToMask;
|
|
6
|
-
|
|
7
7
|
var _utilities = require("./utilities");
|
|
8
|
-
|
|
9
8
|
function isArray(value) {
|
|
10
9
|
return Array.isArray && Array.isArray(value) || value instanceof Array;
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
function conformToMask(rawValue, mask, config) {
|
|
14
12
|
if (rawValue === void 0) {
|
|
15
13
|
rawValue = '';
|
|
16
14
|
}
|
|
17
|
-
|
|
18
15
|
if (mask === void 0) {
|
|
19
16
|
mask = [];
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
if (config === void 0) {
|
|
23
19
|
config = {};
|
|
24
20
|
}
|
|
25
|
-
|
|
26
21
|
if (!isArray(mask)) {
|
|
27
22
|
// If someone passes a function as the mask property, we should call the
|
|
28
23
|
// function to get the mask array - Normally this is handled by the
|
|
@@ -30,43 +25,50 @@ function conformToMask(rawValue, mask, config) {
|
|
|
30
25
|
// to be used directly with `conformToMask`
|
|
31
26
|
if (typeof mask === 'function') {
|
|
32
27
|
// call the mask function to get the mask array
|
|
33
|
-
mask = mask(rawValue, config);
|
|
34
|
-
// the mask for any caret traps. `processCaretTraps` will remove the caret traps from the mask
|
|
28
|
+
mask = mask(rawValue, config);
|
|
35
29
|
|
|
30
|
+
// mask functions can setup caret traps to have some control over how the caret moves. We need to process
|
|
31
|
+
// the mask for any caret traps. `processCaretTraps` will remove the caret traps from the mask
|
|
36
32
|
mask = (0, _utilities.processCaretTraps)(mask).maskWithoutCaretTraps;
|
|
37
33
|
} else {
|
|
38
34
|
throw new Error('Text-mask:conformToMask; The mask property must be an array.');
|
|
39
35
|
}
|
|
40
|
-
}
|
|
41
|
-
|
|
36
|
+
}
|
|
42
37
|
|
|
38
|
+
// These configurations tell us how to conform the mask
|
|
43
39
|
var _config = config,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
40
|
+
_config$guide = _config.guide,
|
|
41
|
+
guide = _config$guide === void 0 ? true : _config$guide,
|
|
42
|
+
_config$previousConfo = _config.previousConformedValue,
|
|
43
|
+
previousConformedValue = _config$previousConfo === void 0 ? '' : _config$previousConfo,
|
|
44
|
+
_config$placeholderCh = _config.placeholderChar,
|
|
45
|
+
placeholderChar = _config$placeholderCh === void 0 ? _utilities.defaultPlaceholderChar : _config$placeholderCh,
|
|
46
|
+
_config$placeholder = _config.placeholder,
|
|
47
|
+
placeholder = _config$placeholder === void 0 ? (0, _utilities.convertMaskToPlaceholder)(mask, placeholderChar) : _config$placeholder,
|
|
48
|
+
_config$currentCaretP = _config.currentCaretPosition,
|
|
49
|
+
currentCaretPosition = _config$currentCaretP === void 0 ? 0 : _config$currentCaretP,
|
|
50
|
+
keepCharPositions = _config.keepCharPositions; // The configs below indicate that the user wants the algorithm to work in *no guide* mode
|
|
51
|
+
var suppressGuide = guide === false && previousConformedValue !== undefined;
|
|
52
|
+
|
|
53
|
+
// Calculate lengths once for performance
|
|
58
54
|
var rawValueLength = rawValue.length;
|
|
59
55
|
var previousConformedValueLength = previousConformedValue.length;
|
|
60
56
|
var placeholderLength = placeholder.length;
|
|
61
|
-
var maskLength = mask.length;
|
|
57
|
+
var maskLength = mask.length;
|
|
62
58
|
|
|
63
|
-
|
|
59
|
+
// This tells us the number of edited characters and the direction in which they were edited (+/-)
|
|
60
|
+
var editDistance = rawValueLength - previousConformedValueLength;
|
|
64
61
|
|
|
65
|
-
|
|
62
|
+
// In *no guide* mode, we need to know if the user is trying to add a character or not
|
|
63
|
+
var isAddition = editDistance > 0;
|
|
66
64
|
|
|
67
|
-
|
|
65
|
+
// Tells us the index of the first change. For (438) 394-4938 to (38) 394-4938, that would be 1
|
|
66
|
+
var indexOfFirstChange = currentCaretPosition + (isAddition ? -editDistance : 0);
|
|
68
67
|
|
|
69
|
-
|
|
68
|
+
// We're also gonna need the index of last change, which we can derive as follows...
|
|
69
|
+
var indexOfLastChange = indexOfFirstChange + Math.abs(editDistance);
|
|
70
|
+
|
|
71
|
+
// If `conformToMask` is configured to keep character positions, that is, for mask 111, previous value
|
|
70
72
|
// _2_ and raw value 3_2_, the new conformed value should be 32_, not 3_2 (default behavior). That's in the case of
|
|
71
73
|
// addition. And in the case of deletion, previous value _23, raw value _3, the new conformed string should be
|
|
72
74
|
// __3, not _3_ (default behavior)
|
|
@@ -74,56 +76,57 @@ function conformToMask(rawValue, mask, config) {
|
|
|
74
76
|
// The next block of logic handles keeping character positions for the case of deletion. (Keeping
|
|
75
77
|
// character positions for the case of addition is further down since it is handled differently.)
|
|
76
78
|
// To do this, we want to compensate for all characters that were deleted
|
|
77
|
-
|
|
78
79
|
if (keepCharPositions === true && !isAddition) {
|
|
79
80
|
// We will be storing the new placeholder characters in this variable.
|
|
80
|
-
var compensatingPlaceholderChars = '';
|
|
81
|
+
var compensatingPlaceholderChars = '';
|
|
81
82
|
|
|
83
|
+
// For every character that was deleted from a placeholder position, we add a placeholder char
|
|
82
84
|
for (var i = indexOfFirstChange; i < indexOfLastChange; i++) {
|
|
83
85
|
if (placeholder[i] === placeholderChar) {
|
|
84
86
|
compensatingPlaceholderChars += placeholderChar;
|
|
85
87
|
}
|
|
86
|
-
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Now we trick our algorithm by modifying the raw value to make it contain additional placeholder characters
|
|
87
91
|
// That way when the we start laying the characters again on the mask, it will keep the non-deleted characters
|
|
88
92
|
// in their positions.
|
|
89
|
-
|
|
90
|
-
|
|
91
93
|
rawValue = rawValue.slice(0, indexOfFirstChange) + compensatingPlaceholderChars + rawValue.slice(indexOfFirstChange, rawValueLength);
|
|
92
|
-
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Convert `rawValue` string to an array, and mark characters based on whether they are newly added or have
|
|
93
97
|
// existed in the previous conformed value. Identifying new and old characters is needed for `conformToMask`
|
|
94
98
|
// to work if it is configured to keep character positions.
|
|
95
|
-
|
|
96
|
-
|
|
97
99
|
var rawValueArr = rawValue.split('').map(function (char, i) {
|
|
98
100
|
return {
|
|
99
101
|
char: char,
|
|
100
102
|
isNew: i >= indexOfFirstChange && i < indexOfLastChange
|
|
101
103
|
};
|
|
102
|
-
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// The loop below removes masking characters from user input. For example, for mask
|
|
103
107
|
// `00 (111)`, the placeholder would be `00 (___)`. If user input is `00 (234)`, the loop below
|
|
104
108
|
// would remove all characters but `234` from the `rawValueArr`. The rest of the algorithm
|
|
105
109
|
// then would lay `234` on top of the available placeholder positions in the mask.
|
|
106
|
-
|
|
107
110
|
for (var _i = rawValueLength - 1; _i >= 0; _i--) {
|
|
108
111
|
var char = rawValueArr[_i].char;
|
|
109
|
-
|
|
110
112
|
if (char !== placeholderChar) {
|
|
111
113
|
var shouldOffset = _i >= indexOfFirstChange && previousConformedValueLength === maskLength;
|
|
112
|
-
|
|
113
114
|
if (char === placeholder[shouldOffset ? _i - editDistance : _i]) {
|
|
114
115
|
rawValueArr.splice(_i, 1);
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
|
-
}
|
|
118
|
-
// in the algorithm below
|
|
119
|
-
|
|
118
|
+
}
|
|
120
119
|
|
|
120
|
+
// This is the variable that we will be filling with characters as we figure them out
|
|
121
|
+
// in the algorithm below
|
|
121
122
|
var conformedValue = '';
|
|
122
|
-
var someCharsRejected = false;
|
|
123
|
+
var someCharsRejected = false;
|
|
123
124
|
|
|
125
|
+
// Ok, so first we loop through the placeholder looking for placeholder characters to fill up.
|
|
124
126
|
placeholderLoop: for (var _i2 = 0; _i2 < placeholderLength; _i2++) {
|
|
125
|
-
var charInPlaceholder = placeholder[_i2];
|
|
127
|
+
var charInPlaceholder = placeholder[_i2];
|
|
126
128
|
|
|
129
|
+
// We see one. Let's find out what we can put in it.
|
|
127
130
|
if (charInPlaceholder === placeholderChar) {
|
|
128
131
|
// But before that, do we actually have any user characters that need a place?
|
|
129
132
|
if (rawValueArr.length > 0) {
|
|
@@ -133,17 +136,18 @@ function conformToMask(rawValue, mask, config) {
|
|
|
133
136
|
// Let's retrieve the first user character in the queue of characters we have left
|
|
134
137
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
135
138
|
var _ref = rawValueArr.shift(),
|
|
136
|
-
|
|
137
|
-
|
|
139
|
+
rawValueChar = _ref.char,
|
|
140
|
+
isNew = _ref.isNew; // If the character we got from the user input is a placeholder character (which happens
|
|
138
141
|
// regularly because user input could be something like (540) 90_-____, which includes
|
|
139
142
|
// a bunch of `_` which are placeholder characters) and we are not in *no guide* mode,
|
|
140
143
|
// then we map this placeholder character to the current spot in the placeholder
|
|
141
|
-
|
|
142
|
-
|
|
143
144
|
if (rawValueChar === placeholderChar && suppressGuide !== true) {
|
|
144
|
-
conformedValue += placeholderChar;
|
|
145
|
+
conformedValue += placeholderChar;
|
|
145
146
|
|
|
146
|
-
|
|
147
|
+
// And we go to find the next placeholder character that needs filling
|
|
148
|
+
continue placeholderLoop;
|
|
149
|
+
|
|
150
|
+
// Else if, the character we got from the user input is not a placeholder, let's see
|
|
147
151
|
// if the current position in the mask can accept it.
|
|
148
152
|
} else if (mask[_i2].test(rawValueChar)) {
|
|
149
153
|
// we map the character differently based on whether we are keeping character positions or not.
|
|
@@ -160,76 +164,79 @@ function conformToMask(rawValue, mask, config) {
|
|
|
160
164
|
// `9`, to the first available placeholder position, but then, there are no more spots available for the
|
|
161
165
|
// `4` and `2`. So, we discard them and end up with a conformed value of `92__`.
|
|
162
166
|
var rawValueArrLength = rawValueArr.length;
|
|
163
|
-
var indexOfNextAvailablePlaceholderChar = null;
|
|
167
|
+
var indexOfNextAvailablePlaceholderChar = null;
|
|
168
|
+
|
|
169
|
+
// Let's loop through the remaining raw value characters. We are looking for either a suitable spot, ie,
|
|
164
170
|
// a placeholder character or a non-suitable spot, ie, a non-placeholder character that is not new.
|
|
165
171
|
// If we see a suitable spot first, we store its position and exit the loop. If we see a non-suitable
|
|
166
172
|
// spot first, we exit the loop and our `indexOfNextAvailablePlaceholderChar` will stay as `null`.
|
|
167
|
-
|
|
168
173
|
for (var _i3 = 0; _i3 < rawValueArrLength; _i3++) {
|
|
169
174
|
var charData = rawValueArr[_i3];
|
|
170
|
-
|
|
171
175
|
if (charData.char !== placeholderChar && charData.isNew === false) {
|
|
172
176
|
break;
|
|
173
177
|
}
|
|
174
|
-
|
|
175
178
|
if (charData.char === placeholderChar) {
|
|
176
179
|
indexOfNextAvailablePlaceholderChar = _i3;
|
|
177
180
|
break;
|
|
178
181
|
}
|
|
179
|
-
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// If `indexOfNextAvailablePlaceholderChar` is not `null`, that means the character is not blocked.
|
|
180
185
|
// We can map it. And to keep the character positions, we remove the placeholder character
|
|
181
186
|
// from the remaining characters
|
|
182
|
-
|
|
183
|
-
|
|
184
187
|
if (indexOfNextAvailablePlaceholderChar !== null) {
|
|
185
188
|
conformedValue += rawValueChar;
|
|
186
|
-
rawValueArr.splice(indexOfNextAvailablePlaceholderChar, 1);
|
|
189
|
+
rawValueArr.splice(indexOfNextAvailablePlaceholderChar, 1);
|
|
190
|
+
|
|
191
|
+
// If `indexOfNextAvailablePlaceholderChar` is `null`, that means the character is blocked. We have to
|
|
187
192
|
// discard it.
|
|
188
193
|
} else {
|
|
189
194
|
_i2--;
|
|
190
195
|
}
|
|
191
|
-
}
|
|
192
|
-
|
|
196
|
+
}
|
|
193
197
|
|
|
198
|
+
// Since we've mapped this placeholder position. We move on to the next one.
|
|
194
199
|
continue placeholderLoop;
|
|
195
200
|
} else {
|
|
196
201
|
someCharsRejected = true;
|
|
197
202
|
}
|
|
198
203
|
}
|
|
199
|
-
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// We reach this point when we've mapped all the user input characters to placeholder
|
|
200
207
|
// positions in the mask. In *guide* mode, we append the left over characters in the
|
|
201
208
|
// placeholder to the `conformedString`, but in *no guide* mode, we don't wanna do that.
|
|
202
209
|
//
|
|
203
210
|
// That is, for mask `(111)` and user input `2`, we want to return `(2`, not `(2__)`.
|
|
204
|
-
|
|
205
|
-
|
|
206
211
|
if (suppressGuide === false) {
|
|
207
212
|
conformedValue += placeholder.substr(_i2, placeholderLength);
|
|
208
|
-
}
|
|
213
|
+
}
|
|
209
214
|
|
|
215
|
+
// And we break
|
|
216
|
+
break;
|
|
210
217
|
|
|
211
|
-
|
|
218
|
+
// Else, the charInPlaceholder is not a placeholderChar. That is, we cannot fill it
|
|
212
219
|
// with user input. So we just map it to the final output
|
|
213
220
|
} else {
|
|
214
221
|
conformedValue += charInPlaceholder;
|
|
215
222
|
}
|
|
216
|
-
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// The following logic is needed to deal with the case of deletion in *no guide* mode.
|
|
217
226
|
//
|
|
218
227
|
// Consider the silly mask `(111) /// 1`. What if user tries to delete the last placeholder
|
|
219
228
|
// position? Something like `(589) /// `. We want to conform that to `(589`. Not `(589) /// `.
|
|
220
229
|
// That's why the logic below finds the last filled placeholder character, and removes everything
|
|
221
230
|
// from that point on.
|
|
222
|
-
|
|
223
|
-
|
|
224
231
|
if (suppressGuide && isAddition === false) {
|
|
225
|
-
var indexOfLastFilledPlaceholderChar = null;
|
|
232
|
+
var indexOfLastFilledPlaceholderChar = null;
|
|
226
233
|
|
|
234
|
+
// Find the last filled placeholder position and substring from there
|
|
227
235
|
for (var _i4 = 0; _i4 < conformedValue.length; _i4++) {
|
|
228
236
|
if (placeholder[_i4] === placeholderChar) {
|
|
229
237
|
indexOfLastFilledPlaceholderChar = _i4;
|
|
230
238
|
}
|
|
231
239
|
}
|
|
232
|
-
|
|
233
240
|
if (indexOfLastFilledPlaceholderChar !== null) {
|
|
234
241
|
// We substring from the beginning until the position after the last filled placeholder char.
|
|
235
242
|
conformedValue = conformedValue.substr(0, indexOfLastFilledPlaceholderChar + 1);
|
|
@@ -239,7 +246,6 @@ function conformToMask(rawValue, mask, config) {
|
|
|
239
246
|
conformedValue = '';
|
|
240
247
|
}
|
|
241
248
|
}
|
|
242
|
-
|
|
243
249
|
return {
|
|
244
250
|
conformedValue: conformedValue,
|
|
245
251
|
meta: {
|