rsuite 6.1.2 → 6.2.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 +27 -0
- package/Timeline/styles/index.css +11 -0
- package/Timeline/styles/index.scss +13 -0
- package/Uploader/styles/index.css +3 -0
- package/Uploader/styles/index.scss +3 -0
- package/cjs/Affix/Affix.js +4 -4
- package/cjs/Animation/Collapse.js +4 -5
- package/cjs/Animation/Transition.d.ts +2 -2
- package/cjs/Animation/Transition.js +17 -20
- package/cjs/AutoComplete/AutoComplete.d.ts +2 -0
- package/cjs/AutoComplete/AutoComplete.js +12 -10
- package/cjs/Avatar/useImage.js +1 -1
- package/cjs/AvatarGroup/AvatarGroup.d.ts +2 -2
- package/cjs/Badge/Badge.js +1 -4
- package/cjs/Breadcrumb/Breadcrumb.js +4 -4
- package/cjs/Button/Button.js +6 -6
- package/cjs/Calendar/Calendar.js +5 -5
- package/cjs/Calendar/CalendarBody.js +1 -1
- package/cjs/Calendar/CalendarContainer.js +14 -33
- package/cjs/Calendar/CalendarHeader.js +7 -8
- package/cjs/Calendar/Grid/GridCell.js +2 -2
- package/cjs/Calendar/Grid/GridHeaderRow.js +1 -1
- package/cjs/Calendar/Grid/GridRow.js +5 -6
- package/cjs/Calendar/MonthDropdown/MonthDropdown.js +1 -1
- package/cjs/Calendar/MonthDropdown/MonthDropdownItem.js +1 -1
- package/cjs/Calendar/TimeDropdown/TimeDropdown.js +12 -14
- package/cjs/Calendar/hooks/useCalendar.d.ts +16 -17
- package/cjs/Calendar/hooks/useCalendar.js +2 -4
- package/cjs/Calendar/hooks/useCalendarDate.js +5 -9
- package/cjs/Calendar/hooks/useCalendarState.js +6 -12
- package/cjs/Calendar/types.d.ts +0 -1
- package/cjs/Carousel/Carousel.js +5 -6
- package/cjs/CascadeTree/CascadeTree.js +6 -16
- package/cjs/CascadeTree/TreeView.js +5 -7
- package/cjs/CascadeTree/hooks/useSearch.d.ts +0 -1
- package/cjs/CascadeTree/hooks/useSearch.js +1 -1
- package/cjs/CascadeTree/hooks/useSelect.d.ts +0 -1
- package/cjs/CascadeTree/hooks/useSelect.js +3 -4
- package/cjs/CascadeTree/types.d.ts +0 -1
- package/cjs/CascadeTree/utils.js +1 -2
- package/cjs/Cascader/Cascader.js +18 -29
- package/cjs/Cascader/useActive.d.ts +0 -1
- package/cjs/Cascader/useActive.js +4 -6
- package/cjs/CheckPicker/CheckPicker.js +14 -15
- package/cjs/CheckTree/CheckTree.js +1 -1
- package/cjs/CheckTree/CheckTreeNode.js +3 -4
- package/cjs/CheckTree/CheckTreeView.js +5 -5
- package/cjs/CheckTree/hooks/useTreeCheckState.js +2 -2
- package/cjs/CheckTree/utils.js +9 -17
- package/cjs/CheckTreePicker/CheckTreePicker.js +7 -7
- package/cjs/CheckTreePicker/hooks/useFocusState.d.ts +0 -1
- package/cjs/CheckTreePicker/hooks/useFocusState.js +3 -6
- package/cjs/Checkbox/Checkbox.js +4 -5
- package/cjs/Checkbox/hooks/useIndeterminateCheckbox.d.ts +0 -1
- package/cjs/Checkbox/hooks/useIndeterminateCheckbox.js +1 -1
- package/cjs/CheckboxGroup/CheckboxGroup.js +2 -2
- package/cjs/DOMHelper/index.d.ts +1 -2
- package/cjs/DOMHelper/isElement.js +1 -1
- package/cjs/DateInput/DateField.d.ts +122 -3
- package/cjs/DateInput/DateField.js +12 -15
- package/cjs/DateInput/DateInput.js +3 -4
- package/cjs/DateInput/hooks/useDateInputState.d.ts +124 -4
- package/cjs/DateInput/hooks/useDateInputState.js +2 -2
- package/cjs/DateInput/hooks/useIsFocused.js +2 -2
- package/cjs/DateInput/hooks/useKeyboardInputEvent.d.ts +0 -1
- package/cjs/DateInput/hooks/useKeyboardInputEvent.js +8 -9
- package/cjs/DateInput/hooks/useSelectedState.d.ts +0 -1
- package/cjs/DateInput/utils.d.ts +0 -1
- package/cjs/DateInput/utils.js +2 -3
- package/cjs/DatePicker/DatePicker.js +18 -25
- package/cjs/DatePicker/PredefinedRanges.js +3 -3
- package/cjs/DatePicker/Toolbar.js +4 -4
- package/cjs/DatePicker/hooks/useCustomizedInput.d.ts +0 -1
- package/cjs/DatePicker/hooks/useFocus.js +5 -8
- package/cjs/DatePicker/hooks/useMonthView.d.ts +0 -1
- package/cjs/DatePicker/hooks/useMonthView.js +1 -1
- package/cjs/DatePicker/utils.d.ts +1 -2
- package/cjs/DatePicker/utils.js +2 -2
- package/cjs/DateRangeInput/DateRangeInput.js +8 -9
- package/cjs/DateRangePicker/Calendar.js +2 -2
- package/cjs/DateRangePicker/DateRangePicker.js +25 -29
- package/cjs/DateRangePicker/Header.js +3 -3
- package/cjs/DateRangePicker/disabledDateUtils.js +2 -2
- package/cjs/DateRangePicker/hooks/useCalendarHandlers.d.ts +0 -1
- package/cjs/DateRangePicker/hooks/useCalendarHandlers.js +5 -5
- package/cjs/DateRangePicker/utils.js +1 -2
- package/cjs/Dropdown/Dropdown.js +3 -3
- package/cjs/Dropdown/DropdownItem.js +4 -5
- package/cjs/Dropdown/DropdownMenu.d.ts +1 -1
- package/cjs/Dropdown/DropdownMenu.js +1 -1
- package/cjs/Form/Form.d.ts +38 -3
- package/cjs/Form/Form.js +25 -12
- package/cjs/Form/hooks/useFormRef.d.ts +0 -1
- package/cjs/Form/hooks/useFormValidate.d.ts +2 -1
- package/cjs/Form/hooks/useFormValidate.js +136 -20
- package/cjs/Form/hooks/useFormValue.d.ts +0 -1
- package/cjs/Form/index.d.ts +1 -0
- package/cjs/Form/resolvers.d.ts +59 -0
- package/cjs/Form/resolvers.js +4 -0
- package/cjs/FormControl/FormControl.js +5 -5
- package/cjs/FormGroup/FormGroupContext.d.ts +1 -1
- package/cjs/Highlight/utils/highlightText.js +1 -1
- package/cjs/InlineEdit/renderChildren.js +5 -6
- package/cjs/InlineEdit/useEditState.js +9 -12
- package/cjs/InlineEdit/useFocusEvent.d.ts +0 -1
- package/cjs/InlineEdit/useFocusEvent.js +7 -11
- package/cjs/Input/Input.js +1 -1
- package/cjs/InputGroup/InputGroupContext.d.ts +2 -1
- package/cjs/InputNumber/index.d.ts +0 -1
- package/cjs/InputPicker/InputAutosize.js +1 -1
- package/cjs/InputPicker/InputPicker.js +30 -35
- package/cjs/InputPicker/InputSearch.js +1 -2
- package/cjs/InputPicker/hooks/useData.d.ts +0 -1
- package/cjs/InputPicker/hooks/useData.js +1 -1
- package/cjs/InputPicker/hooks/useInput.js +3 -6
- package/cjs/InputPicker/hooks/useMaxWidth.js +2 -4
- package/cjs/List/helper/AutoScroller.js +2 -4
- package/cjs/List/helper/useSortHelper.d.ts +4 -4
- package/cjs/List/helper/useSortHelper.js +13 -19
- package/cjs/MaskedInput/TextMask.d.ts +5 -5
- package/cjs/MaskedInput/TextMask.js +3 -5
- package/cjs/MaskedInput/conformToMask.d.ts +1 -1
- package/cjs/MaskedInput/createTextMaskInputElement.js +2 -3
- package/cjs/Menu/MenuItem.js +3 -4
- package/cjs/Message/Message.js +1 -1
- package/cjs/Modal/Modal.js +8 -10
- package/cjs/Modal/ModalBody.js +1 -1
- package/cjs/Modal/utils.d.ts +2 -3
- package/cjs/Modal/utils.js +2 -3
- package/cjs/MultiCascadeTree/SearchView.js +1 -1
- package/cjs/MultiCascadeTree/TreeView.js +2 -2
- package/cjs/MultiCascadeTree/hooks/useCascadeValue.d.ts +0 -1
- package/cjs/MultiCascadeTree/hooks/useCascadeValue.js +5 -8
- package/cjs/MultiCascadeTree/hooks/useColumnData.d.ts +0 -1
- package/cjs/MultiCascadeTree/hooks/useSearch.d.ts +0 -1
- package/cjs/MultiCascadeTree/hooks/useSearch.js +2 -2
- package/cjs/MultiCascadeTree/hooks/useSelect.js +3 -4
- package/cjs/MultiCascadeTree/types.d.ts +0 -1
- package/cjs/MultiCascadeTree/utils.d.ts +4 -4
- package/cjs/MultiCascadeTree/utils.js +2 -3
- package/cjs/MultiCascader/MultiCascader.js +13 -16
- package/cjs/Nav/AdaptiveNavItem.js +2 -3
- package/cjs/Nav/Nav.d.ts +1 -1
- package/cjs/Nav/Nav.js +4 -4
- package/cjs/Nav/NavDropdown.d.ts +1 -1
- package/cjs/Nav/NavDropdown.js +3 -3
- package/cjs/Nav/NavDropdownItem.js +2 -2
- package/cjs/Nav/NavDropdownMenu.d.ts +1 -1
- package/cjs/Nav/NavDropdownMenu.js +1 -1
- package/cjs/Nav/NavItem.js +4 -4
- package/cjs/Navbar/Navbar.js +1 -1
- package/cjs/Navbar/NavbarContent.js +1 -1
- package/cjs/Navbar/NavbarDrawer.js +1 -1
- package/cjs/Navbar/NavbarDropdown.d.ts +1 -1
- package/cjs/Navbar/NavbarDropdown.js +3 -3
- package/cjs/Navbar/NavbarDropdownItem.js +5 -6
- package/cjs/Navbar/NavbarDropdownMenu.d.ts +1 -1
- package/cjs/Navbar/NavbarDropdownMenu.js +1 -1
- package/cjs/Navbar/NavbarItem.js +4 -4
- package/cjs/Navbar/NavbarToggle.js +2 -2
- package/cjs/Notification/Notification.js +1 -1
- package/cjs/NumberInput/NumberInput.js +3 -3
- package/cjs/NumberInput/hooks/useEvents.d.ts +0 -1
- package/cjs/NumberInput/hooks/useEvents.js +2 -3
- package/cjs/NumberInput/hooks/useWheelHandler.js +1 -2
- package/cjs/Pagination/Pagination.js +1 -1
- package/cjs/Pagination/PaginationButton.js +1 -1
- package/cjs/Pagination/PaginationGroup.js +3 -4
- package/cjs/Panel/Panel.js +2 -2
- package/cjs/PanelGroup/PanelGroup.js +1 -1
- package/cjs/PasswordInput/PasswordInput.js +2 -2
- package/cjs/PinInput/PinInput.js +1 -1
- package/cjs/PinInput/hooks/usePinInputRefs.d.ts +0 -1
- package/cjs/PinInput/hooks/usePinInputRefs.js +2 -4
- package/cjs/PinInput/hooks/usePinValue.d.ts +1 -1
- package/cjs/PinInput/hooks/usePinValue.js +2 -2
- package/cjs/Progress/ProgressLine.js +1 -1
- package/cjs/Progress/types.d.ts +0 -1
- package/cjs/ProgressCircle/hooks/useProgressCirclePath.d.ts +0 -1
- package/cjs/Radio/Radio.js +3 -3
- package/cjs/RadioGroup/RadioGroup.js +1 -1
- package/cjs/RadioTile/RadioTile.js +2 -2
- package/cjs/RadioTileGroup/RadioTileGroup.js +1 -1
- package/cjs/RangeSlider/RangeSlider.js +6 -6
- package/cjs/Rate/Character.js +2 -2
- package/cjs/Rate/Rate.js +3 -3
- package/cjs/Rate/useRatingStates.d.ts +0 -1
- package/cjs/SegmentedControl/SegmentedControl.js +3 -3
- package/cjs/SegmentedControl/hooks/useIndicatorPosition.js +1 -1
- package/cjs/SelectPicker/SelectPicker.js +13 -16
- package/cjs/Sidebar/Sidebar.js +1 -1
- package/cjs/Sidenav/ExpandedSidenavDropdown.js +6 -6
- package/cjs/Sidenav/ExpandedSidenavDropdownItem.js +4 -5
- package/cjs/Sidenav/Node.js +9 -16
- package/cjs/Sidenav/Sidenav.js +2 -2
- package/cjs/Sidenav/SidenavDropdown.d.ts +1 -1
- package/cjs/Sidenav/SidenavDropdown.js +4 -4
- package/cjs/Sidenav/SidenavDropdownItem.js +3 -4
- package/cjs/Sidenav/SidenavItem.js +5 -6
- package/cjs/Sidenav/SidenavToggle.js +2 -2
- package/cjs/Slider/Slider.js +3 -3
- package/cjs/Slider/useDrag.d.ts +0 -1
- package/cjs/Slider/useDrag.js +7 -12
- package/cjs/Slider/utils.d.ts +1 -2
- package/cjs/Slider/utils.js +2 -3
- package/cjs/Steps/StepItem.js +1 -2
- package/cjs/Table/Table.d.ts +3 -3
- package/cjs/Tabs/Tabs.js +3 -4
- package/cjs/TimePicker/TimePicker.js +2 -2
- package/cjs/Timeline/Timeline.d.ts +6 -1
- package/cjs/Timeline/Timeline.js +14 -10
- package/cjs/Toggle/Toggle.js +2 -2
- package/cjs/Tree/Tree.js +2 -2
- package/cjs/Tree/TreeNode.js +10 -11
- package/cjs/Tree/TreeView.js +5 -5
- package/cjs/Tree/hooks/useExpandTree.js +1 -1
- package/cjs/Tree/hooks/useFlattenTree.js +6 -9
- package/cjs/Tree/hooks/useFocusTree.d.ts +1 -2
- package/cjs/Tree/hooks/useFocusTree.js +12 -14
- package/cjs/Tree/hooks/useTreeDrag.d.ts +0 -1
- package/cjs/Tree/hooks/useTreeDrag.js +10 -12
- package/cjs/Tree/hooks/useTreeNodeProps.js +1 -1
- package/cjs/Tree/hooks/useTreeSearch.js +4 -4
- package/cjs/Tree/hooks/useVirtualizedTreeData.js +2 -2
- package/cjs/Tree/types.d.ts +2 -3
- package/cjs/Tree/utils/flattenTree.d.ts +1 -1
- package/cjs/Tree/utils/focusableTree.js +5 -8
- package/cjs/Tree/utils/getNodeParentKeys.js +2 -4
- package/cjs/Tree/utils/hasVisibleChildren.d.ts +1 -1
- package/cjs/Tree/utils/treeKeyboardInteractions.js +3 -3
- package/cjs/TreePicker/TreePicker.js +8 -9
- package/cjs/TreePicker/hooks/useFocusState.d.ts +0 -1
- package/cjs/TreePicker/hooks/useFocusState.js +4 -8
- package/cjs/Uploader/UploadFileItem.js +8 -10
- package/cjs/Uploader/UploadTrigger.js +8 -10
- package/cjs/Uploader/Uploader.d.ts +2 -0
- package/cjs/Uploader/Uploader.js +66 -26
- package/cjs/Uploader/utils/ajaxUpload.js +5 -5
- package/cjs/Uploader/utils/previewFile.js +1 -1
- package/cjs/internals/Disclosure/Disclosure.js +5 -8
- package/cjs/internals/Disclosure/DisclosureButton.js +2 -2
- package/cjs/internals/InputBase/InputBase.js +5 -6
- package/cjs/internals/Menu/Menu.js +16 -20
- package/cjs/internals/Menu/MenuItem.js +4 -5
- package/cjs/internals/Menu/Menubar.js +5 -7
- package/cjs/internals/Menu/useMenu.js +5 -10
- package/cjs/internals/Overlay/Modal.js +8 -11
- package/cjs/internals/Overlay/ModalManager.js +3 -5
- package/cjs/internals/Overlay/Overlay.js +1 -1
- package/cjs/internals/Overlay/OverlayTrigger.d.ts +0 -1
- package/cjs/internals/Overlay/OverlayTrigger.js +5 -7
- package/cjs/internals/Overlay/Position.js +6 -8
- package/cjs/internals/Picker/ListCheckItem.js +3 -3
- package/cjs/internals/Picker/ListItem.js +1 -1
- package/cjs/internals/Picker/Listbox.js +9 -10
- package/cjs/internals/Picker/PickerIndicator.js +13 -11
- package/cjs/internals/Picker/PickerPopup.js +4 -5
- package/cjs/internals/Picker/PickerToggle.js +3 -4
- package/cjs/internals/Picker/SelectedElement.js +1 -1
- package/cjs/internals/Picker/hooks/useFocusItemValue.d.ts +0 -1
- package/cjs/internals/Picker/hooks/useFocusItemValue.js +14 -28
- package/cjs/internals/Picker/hooks/usePickerRef.d.ts +0 -1
- package/cjs/internals/Picker/hooks/usePickerRef.js +9 -15
- package/cjs/internals/Picker/hooks/useSearch.d.ts +0 -1
- package/cjs/internals/Picker/hooks/useSearch.js +2 -2
- package/cjs/internals/Picker/hooks/useToggleKeyDownEvent.d.ts +0 -1
- package/cjs/internals/Picker/hooks/useToggleKeyDownEvent.js +13 -17
- package/cjs/internals/Picker/utils.js +9 -9
- package/cjs/internals/Ripple/Ripple.js +3 -4
- package/cjs/internals/SafeAnchor/SafeAnchor.js +1 -1
- package/cjs/internals/ScrollView/hooks/useScrollState.d.ts +0 -1
- package/cjs/internals/ScrollView/hooks/useScrollState.js +2 -3
- package/cjs/internals/Tree/TreeProvider.d.ts +4 -4
- package/cjs/internals/Tree/TreeProvider.js +2 -8
- package/cjs/internals/Tree/types.d.ts +0 -1
- package/cjs/internals/Tree/utils/getParentMap.d.ts +0 -1
- package/cjs/internals/Windowing/AutoSizer.js +2 -3
- package/cjs/internals/Windowing/List.js +4 -8
- package/cjs/internals/constants/index.d.ts +2 -2
- package/cjs/internals/hooks/useClickOutside.js +2 -4
- package/cjs/internals/hooks/useCustom.d.ts +0 -1
- package/cjs/internals/hooks/useCustom.js +5 -7
- package/cjs/internals/hooks/useElementResize.d.ts +0 -1
- package/cjs/internals/hooks/useEventCallback.js +1 -2
- package/cjs/internals/hooks/useEventListener.js +1 -1
- package/cjs/internals/hooks/useFocus.js +2 -4
- package/cjs/internals/hooks/useFocusVirtualListItem.d.ts +0 -1
- package/cjs/internals/hooks/useMount.js +1 -2
- package/cjs/internals/hooks/useRootClose.js +6 -6
- package/cjs/internals/hooks/useTimeout.js +1 -2
- package/cjs/internals/hooks/useToggleCaret.d.ts +0 -1
- package/cjs/internals/hooks/useUniqueId.js +1 -1
- package/cjs/internals/hooks/useUpdatedRef.d.ts +0 -1
- package/cjs/internals/styled-system/style-manager.js +1 -1
- package/cjs/internals/styled-system/useStyled.js +2 -2
- package/cjs/internals/types/utils.d.ts +0 -1
- package/cjs/internals/utils/colours.d.ts +4 -4
- package/cjs/internals/utils/colours.js +1 -1
- package/cjs/internals/utils/date/disableTime.js +6 -12
- package/cjs/internals/utils/date/omitHideDisabledProps.d.ts +1 -1
- package/cjs/internals/utils/date/useDateMode.d.ts +1 -1
- package/cjs/internals/utils/react/ReactChildren.js +1 -2
- package/cjs/internals/utils/react/deprecateComponent.js +1 -2
- package/cjs/internals/utils/react/getDOMNode.js +4 -5
- package/cjs/internals/utils/sizes.d.ts +2 -2
- package/cjs/internals/utils/style-sheet/css.d.ts +0 -1
- package/cjs/internals/utils/style-sheet/css.js +1 -1
- package/cjs/internals/utils/style-sheet/prefix.d.ts +0 -1
- package/cjs/internals/utils/style-sheet/responsive.d.ts +1 -1
- package/cjs/internals/utils/style-sheet/styles.d.ts +3 -3
- package/cjs/internals/utils/style-sheet/styles.js +1 -1
- package/cjs/toaster/ToastContainer.js +3 -5
- package/cjs/toaster/hooks/useDelayedClosure.d.ts +0 -1
- package/cjs/toaster/hooks/useDelayedClosure.js +3 -4
- package/cjs/toaster/toaster.js +42 -15
- package/cjs/useDialog/Dialog.d.ts +1 -1
- package/cjs/useDialog/Dialog.js +1 -1
- package/cjs/useDialog/useDialog.d.ts +1 -1
- package/cjs/useDialog/useDialog.js +3 -3
- package/cjs/useFormControl/hooks/useField.d.ts +0 -1
- package/cjs/useFormControl/hooks/useField.js +5 -7
- package/cjs/useFormControl/hooks/useRegisterModel.js +2 -2
- package/cjs/useFormControl/useFormControl.js +8 -8
- package/cjs/useToaster/useToaster.js +4 -5
- package/dist/rsuite-no-reset.css +14 -0
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite.css +14 -0
- package/dist/rsuite.js +224 -224
- package/dist/rsuite.min.css +1 -1
- package/dist/rsuite.min.js +1 -1
- package/dist/rsuite.min.js.map +1 -1
- package/esm/Affix/Affix.js +4 -4
- package/esm/Animation/Collapse.js +1 -2
- package/esm/Animation/Transition.d.ts +2 -2
- package/esm/Animation/Transition.js +17 -20
- package/esm/AutoComplete/AutoComplete.d.ts +2 -0
- package/esm/AutoComplete/AutoComplete.js +12 -10
- package/esm/Avatar/useImage.js +1 -1
- package/esm/AvatarGroup/AvatarGroup.d.ts +2 -2
- package/esm/Badge/Badge.js +1 -4
- package/esm/Breadcrumb/Breadcrumb.js +4 -4
- package/esm/Button/Button.js +6 -6
- package/esm/Calendar/Calendar.js +5 -5
- package/esm/Calendar/CalendarBody.js +1 -1
- package/esm/Calendar/CalendarContainer.js +14 -33
- package/esm/Calendar/CalendarHeader.js +7 -8
- package/esm/Calendar/Grid/GridCell.js +2 -2
- package/esm/Calendar/Grid/GridHeaderRow.js +1 -1
- package/esm/Calendar/Grid/GridRow.js +5 -6
- package/esm/Calendar/MonthDropdown/MonthDropdown.js +1 -1
- package/esm/Calendar/MonthDropdown/MonthDropdownItem.js +1 -1
- package/esm/Calendar/TimeDropdown/TimeDropdown.js +12 -14
- package/esm/Calendar/hooks/useCalendar.d.ts +16 -17
- package/esm/Calendar/hooks/useCalendar.js +2 -4
- package/esm/Calendar/hooks/useCalendarDate.js +5 -9
- package/esm/Calendar/hooks/useCalendarState.js +6 -12
- package/esm/Calendar/types.d.ts +0 -1
- package/esm/Carousel/Carousel.js +5 -6
- package/esm/CascadeTree/CascadeTree.js +6 -16
- package/esm/CascadeTree/TreeView.js +5 -7
- package/esm/CascadeTree/hooks/useSearch.d.ts +0 -1
- package/esm/CascadeTree/hooks/useSearch.js +1 -1
- package/esm/CascadeTree/hooks/useSelect.d.ts +0 -1
- package/esm/CascadeTree/hooks/useSelect.js +3 -4
- package/esm/CascadeTree/types.d.ts +0 -1
- package/esm/CascadeTree/utils.js +1 -2
- package/esm/Cascader/Cascader.js +18 -29
- package/esm/Cascader/useActive.d.ts +0 -1
- package/esm/Cascader/useActive.js +4 -6
- package/esm/CheckPicker/CheckPicker.js +14 -15
- package/esm/CheckTree/CheckTree.js +1 -1
- package/esm/CheckTree/CheckTreeNode.js +3 -4
- package/esm/CheckTree/CheckTreeView.js +5 -5
- package/esm/CheckTree/hooks/useTreeCheckState.js +2 -2
- package/esm/CheckTree/utils.js +9 -17
- package/esm/CheckTreePicker/CheckTreePicker.js +7 -7
- package/esm/CheckTreePicker/hooks/useFocusState.d.ts +0 -1
- package/esm/CheckTreePicker/hooks/useFocusState.js +3 -6
- package/esm/Checkbox/Checkbox.js +4 -5
- package/esm/Checkbox/hooks/useIndeterminateCheckbox.d.ts +0 -1
- package/esm/Checkbox/hooks/useIndeterminateCheckbox.js +1 -1
- package/esm/CheckboxGroup/CheckboxGroup.js +2 -2
- package/esm/DOMHelper/index.d.ts +1 -2
- package/esm/DOMHelper/isElement.js +1 -1
- package/esm/DateInput/DateField.d.ts +122 -3
- package/esm/DateInput/DateField.js +12 -15
- package/esm/DateInput/DateInput.js +3 -4
- package/esm/DateInput/hooks/useDateInputState.d.ts +124 -4
- package/esm/DateInput/hooks/useDateInputState.js +2 -2
- package/esm/DateInput/hooks/useIsFocused.js +2 -2
- package/esm/DateInput/hooks/useKeyboardInputEvent.d.ts +0 -1
- package/esm/DateInput/hooks/useKeyboardInputEvent.js +8 -9
- package/esm/DateInput/hooks/useSelectedState.d.ts +0 -1
- package/esm/DateInput/utils.d.ts +0 -1
- package/esm/DateInput/utils.js +2 -3
- package/esm/DatePicker/DatePicker.js +18 -25
- package/esm/DatePicker/PredefinedRanges.js +3 -3
- package/esm/DatePicker/Toolbar.js +4 -4
- package/esm/DatePicker/hooks/useCustomizedInput.d.ts +0 -1
- package/esm/DatePicker/hooks/useFocus.js +5 -8
- package/esm/DatePicker/hooks/useMonthView.d.ts +0 -1
- package/esm/DatePicker/hooks/useMonthView.js +1 -1
- package/esm/DatePicker/utils.d.ts +1 -2
- package/esm/DatePicker/utils.js +2 -2
- package/esm/DateRangeInput/DateRangeInput.js +8 -9
- package/esm/DateRangePicker/Calendar.js +2 -2
- package/esm/DateRangePicker/DateRangePicker.js +25 -29
- package/esm/DateRangePicker/Header.js +3 -3
- package/esm/DateRangePicker/disabledDateUtils.js +2 -2
- package/esm/DateRangePicker/hooks/useCalendarHandlers.d.ts +0 -1
- package/esm/DateRangePicker/hooks/useCalendarHandlers.js +5 -5
- package/esm/DateRangePicker/utils.js +1 -2
- package/esm/Dropdown/Dropdown.js +3 -3
- package/esm/Dropdown/DropdownItem.js +4 -5
- package/esm/Dropdown/DropdownMenu.d.ts +1 -1
- package/esm/Dropdown/DropdownMenu.js +1 -1
- package/esm/Form/Form.d.ts +38 -3
- package/esm/Form/Form.js +25 -12
- package/esm/Form/hooks/useFormRef.d.ts +0 -1
- package/esm/Form/hooks/useFormValidate.d.ts +2 -1
- package/esm/Form/hooks/useFormValidate.js +136 -20
- package/esm/Form/hooks/useFormValue.d.ts +0 -1
- package/esm/Form/index.d.ts +1 -0
- package/esm/Form/resolvers.d.ts +59 -0
- package/esm/Form/resolvers.js +2 -0
- package/esm/FormControl/FormControl.js +5 -5
- package/esm/FormGroup/FormGroupContext.d.ts +1 -1
- package/esm/Highlight/utils/highlightText.js +1 -1
- package/esm/InlineEdit/renderChildren.js +5 -6
- package/esm/InlineEdit/useEditState.js +9 -12
- package/esm/InlineEdit/useFocusEvent.d.ts +0 -1
- package/esm/InlineEdit/useFocusEvent.js +7 -11
- package/esm/Input/Input.js +1 -1
- package/esm/InputGroup/InputGroupContext.d.ts +2 -1
- package/esm/InputNumber/index.d.ts +0 -1
- package/esm/InputPicker/InputAutosize.js +1 -1
- package/esm/InputPicker/InputPicker.js +30 -35
- package/esm/InputPicker/InputSearch.js +1 -2
- package/esm/InputPicker/hooks/useData.d.ts +0 -1
- package/esm/InputPicker/hooks/useData.js +1 -1
- package/esm/InputPicker/hooks/useInput.js +3 -6
- package/esm/InputPicker/hooks/useMaxWidth.js +2 -4
- package/esm/List/helper/AutoScroller.js +2 -4
- package/esm/List/helper/useSortHelper.d.ts +4 -4
- package/esm/List/helper/useSortHelper.js +13 -19
- package/esm/MaskedInput/TextMask.d.ts +5 -5
- package/esm/MaskedInput/TextMask.js +3 -5
- package/esm/MaskedInput/conformToMask.d.ts +1 -1
- package/esm/MaskedInput/createTextMaskInputElement.js +2 -3
- package/esm/Menu/MenuItem.js +3 -4
- package/esm/Message/Message.js +1 -1
- package/esm/Modal/Modal.js +8 -10
- package/esm/Modal/ModalBody.js +1 -1
- package/esm/Modal/utils.d.ts +2 -3
- package/esm/Modal/utils.js +2 -3
- package/esm/MultiCascadeTree/SearchView.js +1 -1
- package/esm/MultiCascadeTree/TreeView.js +2 -2
- package/esm/MultiCascadeTree/hooks/useCascadeValue.d.ts +0 -1
- package/esm/MultiCascadeTree/hooks/useCascadeValue.js +5 -8
- package/esm/MultiCascadeTree/hooks/useColumnData.d.ts +0 -1
- package/esm/MultiCascadeTree/hooks/useSearch.d.ts +0 -1
- package/esm/MultiCascadeTree/hooks/useSearch.js +2 -2
- package/esm/MultiCascadeTree/hooks/useSelect.js +3 -4
- package/esm/MultiCascadeTree/types.d.ts +0 -1
- package/esm/MultiCascadeTree/utils.d.ts +4 -4
- package/esm/MultiCascadeTree/utils.js +2 -3
- package/esm/MultiCascader/MultiCascader.js +13 -16
- package/esm/Nav/AdaptiveNavItem.js +2 -3
- package/esm/Nav/Nav.d.ts +1 -1
- package/esm/Nav/Nav.js +4 -4
- package/esm/Nav/NavDropdown.d.ts +1 -1
- package/esm/Nav/NavDropdown.js +3 -3
- package/esm/Nav/NavDropdownItem.js +2 -2
- package/esm/Nav/NavDropdownMenu.d.ts +1 -1
- package/esm/Nav/NavDropdownMenu.js +1 -1
- package/esm/Nav/NavItem.js +4 -4
- package/esm/Navbar/Navbar.js +1 -1
- package/esm/Navbar/NavbarContent.js +1 -1
- package/esm/Navbar/NavbarDrawer.js +1 -1
- package/esm/Navbar/NavbarDropdown.d.ts +1 -1
- package/esm/Navbar/NavbarDropdown.js +3 -3
- package/esm/Navbar/NavbarDropdownItem.js +5 -6
- package/esm/Navbar/NavbarDropdownMenu.d.ts +1 -1
- package/esm/Navbar/NavbarDropdownMenu.js +1 -1
- package/esm/Navbar/NavbarItem.js +4 -4
- package/esm/Navbar/NavbarToggle.js +2 -2
- package/esm/Notification/Notification.js +1 -1
- package/esm/NumberInput/NumberInput.js +3 -3
- package/esm/NumberInput/hooks/useEvents.d.ts +0 -1
- package/esm/NumberInput/hooks/useEvents.js +2 -3
- package/esm/NumberInput/hooks/useWheelHandler.js +1 -2
- package/esm/Pagination/Pagination.js +1 -1
- package/esm/Pagination/PaginationButton.js +1 -1
- package/esm/Pagination/PaginationGroup.js +3 -4
- package/esm/Panel/Panel.js +2 -2
- package/esm/PanelGroup/PanelGroup.js +1 -1
- package/esm/PasswordInput/PasswordInput.js +2 -2
- package/esm/PinInput/PinInput.js +1 -1
- package/esm/PinInput/hooks/usePinInputRefs.d.ts +0 -1
- package/esm/PinInput/hooks/usePinInputRefs.js +2 -4
- package/esm/PinInput/hooks/usePinValue.d.ts +1 -1
- package/esm/PinInput/hooks/usePinValue.js +2 -2
- package/esm/Progress/ProgressLine.js +1 -1
- package/esm/Progress/types.d.ts +0 -1
- package/esm/ProgressCircle/hooks/useProgressCirclePath.d.ts +0 -1
- package/esm/Radio/Radio.js +3 -3
- package/esm/RadioGroup/RadioGroup.js +1 -1
- package/esm/RadioTile/RadioTile.js +2 -2
- package/esm/RadioTileGroup/RadioTileGroup.js +1 -1
- package/esm/RangeSlider/RangeSlider.js +6 -6
- package/esm/Rate/Character.js +2 -2
- package/esm/Rate/Rate.js +3 -3
- package/esm/Rate/useRatingStates.d.ts +0 -1
- package/esm/SegmentedControl/SegmentedControl.js +3 -3
- package/esm/SegmentedControl/hooks/useIndicatorPosition.js +1 -1
- package/esm/SelectPicker/SelectPicker.js +13 -16
- package/esm/Sidebar/Sidebar.js +1 -1
- package/esm/Sidenav/ExpandedSidenavDropdown.js +6 -6
- package/esm/Sidenav/ExpandedSidenavDropdownItem.js +4 -5
- package/esm/Sidenav/Node.js +9 -16
- package/esm/Sidenav/Sidenav.js +2 -2
- package/esm/Sidenav/SidenavDropdown.d.ts +1 -1
- package/esm/Sidenav/SidenavDropdown.js +4 -4
- package/esm/Sidenav/SidenavDropdownItem.js +3 -4
- package/esm/Sidenav/SidenavItem.js +5 -6
- package/esm/Sidenav/SidenavToggle.js +2 -2
- package/esm/Slider/Slider.js +3 -3
- package/esm/Slider/useDrag.d.ts +0 -1
- package/esm/Slider/useDrag.js +7 -12
- package/esm/Slider/utils.d.ts +1 -2
- package/esm/Slider/utils.js +2 -3
- package/esm/Steps/StepItem.js +1 -2
- package/esm/Table/Table.d.ts +3 -3
- package/esm/Tabs/Tabs.js +3 -4
- package/esm/TimePicker/TimePicker.js +2 -2
- package/esm/Timeline/Timeline.d.ts +6 -1
- package/esm/Timeline/Timeline.js +14 -10
- package/esm/Toggle/Toggle.js +2 -2
- package/esm/Tree/Tree.js +2 -2
- package/esm/Tree/TreeNode.js +10 -11
- package/esm/Tree/TreeView.js +5 -5
- package/esm/Tree/hooks/useExpandTree.js +1 -1
- package/esm/Tree/hooks/useFlattenTree.js +6 -9
- package/esm/Tree/hooks/useFocusTree.d.ts +1 -2
- package/esm/Tree/hooks/useFocusTree.js +12 -14
- package/esm/Tree/hooks/useTreeDrag.d.ts +0 -1
- package/esm/Tree/hooks/useTreeDrag.js +10 -12
- package/esm/Tree/hooks/useTreeNodeProps.js +1 -1
- package/esm/Tree/hooks/useTreeSearch.js +4 -4
- package/esm/Tree/hooks/useVirtualizedTreeData.js +2 -2
- package/esm/Tree/types.d.ts +2 -3
- package/esm/Tree/utils/flattenTree.d.ts +1 -1
- package/esm/Tree/utils/focusableTree.js +5 -8
- package/esm/Tree/utils/getNodeParentKeys.js +2 -4
- package/esm/Tree/utils/hasVisibleChildren.d.ts +1 -1
- package/esm/Tree/utils/treeKeyboardInteractions.js +3 -3
- package/esm/TreePicker/TreePicker.js +8 -9
- package/esm/TreePicker/hooks/useFocusState.d.ts +0 -1
- package/esm/TreePicker/hooks/useFocusState.js +4 -8
- package/esm/Uploader/UploadFileItem.js +8 -10
- package/esm/Uploader/UploadTrigger.js +8 -10
- package/esm/Uploader/Uploader.d.ts +2 -0
- package/esm/Uploader/Uploader.js +66 -26
- package/esm/Uploader/utils/ajaxUpload.js +5 -5
- package/esm/Uploader/utils/previewFile.js +1 -1
- package/esm/internals/Disclosure/Disclosure.js +5 -8
- package/esm/internals/Disclosure/DisclosureButton.js +2 -2
- package/esm/internals/InputBase/InputBase.js +5 -6
- package/esm/internals/Menu/Menu.js +16 -20
- package/esm/internals/Menu/MenuItem.js +4 -5
- package/esm/internals/Menu/Menubar.js +5 -7
- package/esm/internals/Menu/useMenu.js +5 -10
- package/esm/internals/Overlay/Modal.js +8 -11
- package/esm/internals/Overlay/ModalManager.js +3 -5
- package/esm/internals/Overlay/Overlay.js +1 -1
- package/esm/internals/Overlay/OverlayTrigger.d.ts +0 -1
- package/esm/internals/Overlay/OverlayTrigger.js +5 -7
- package/esm/internals/Overlay/Position.js +6 -8
- package/esm/internals/Picker/ListCheckItem.js +3 -3
- package/esm/internals/Picker/ListItem.js +1 -1
- package/esm/internals/Picker/Listbox.js +9 -10
- package/esm/internals/Picker/PickerIndicator.js +13 -11
- package/esm/internals/Picker/PickerPopup.js +4 -5
- package/esm/internals/Picker/PickerToggle.js +3 -4
- package/esm/internals/Picker/SelectedElement.js +1 -1
- package/esm/internals/Picker/hooks/useFocusItemValue.d.ts +0 -1
- package/esm/internals/Picker/hooks/useFocusItemValue.js +14 -28
- package/esm/internals/Picker/hooks/usePickerRef.d.ts +0 -1
- package/esm/internals/Picker/hooks/usePickerRef.js +9 -15
- package/esm/internals/Picker/hooks/useSearch.d.ts +0 -1
- package/esm/internals/Picker/hooks/useSearch.js +2 -2
- package/esm/internals/Picker/hooks/useToggleKeyDownEvent.d.ts +0 -1
- package/esm/internals/Picker/hooks/useToggleKeyDownEvent.js +13 -17
- package/esm/internals/Picker/utils.js +9 -9
- package/esm/internals/Ripple/Ripple.js +3 -4
- package/esm/internals/SafeAnchor/SafeAnchor.js +1 -1
- package/esm/internals/ScrollView/hooks/useScrollState.d.ts +0 -1
- package/esm/internals/ScrollView/hooks/useScrollState.js +2 -3
- package/esm/internals/Tree/TreeProvider.d.ts +4 -4
- package/esm/internals/Tree/TreeProvider.js +2 -8
- package/esm/internals/Tree/types.d.ts +0 -1
- package/esm/internals/Tree/utils/getParentMap.d.ts +0 -1
- package/esm/internals/Windowing/AutoSizer.js +2 -3
- package/esm/internals/Windowing/List.js +4 -8
- package/esm/internals/constants/index.d.ts +2 -2
- package/esm/internals/hooks/useClickOutside.js +2 -4
- package/esm/internals/hooks/useCustom.d.ts +0 -1
- package/esm/internals/hooks/useCustom.js +5 -7
- package/esm/internals/hooks/useElementResize.d.ts +0 -1
- package/esm/internals/hooks/useEventCallback.js +1 -2
- package/esm/internals/hooks/useEventListener.js +1 -1
- package/esm/internals/hooks/useFocus.js +2 -4
- package/esm/internals/hooks/useFocusVirtualListItem.d.ts +0 -1
- package/esm/internals/hooks/useMount.js +1 -2
- package/esm/internals/hooks/useRootClose.js +6 -6
- package/esm/internals/hooks/useTimeout.js +1 -2
- package/esm/internals/hooks/useToggleCaret.d.ts +0 -1
- package/esm/internals/hooks/useUniqueId.js +1 -1
- package/esm/internals/hooks/useUpdatedRef.d.ts +0 -1
- package/esm/internals/styled-system/style-manager.js +1 -1
- package/esm/internals/styled-system/useStyled.js +2 -2
- package/esm/internals/types/utils.d.ts +0 -1
- package/esm/internals/utils/colours.d.ts +4 -4
- package/esm/internals/utils/colours.js +1 -1
- package/esm/internals/utils/date/disableTime.js +6 -12
- package/esm/internals/utils/date/omitHideDisabledProps.d.ts +1 -1
- package/esm/internals/utils/date/useDateMode.d.ts +1 -1
- package/esm/internals/utils/react/ReactChildren.js +1 -2
- package/esm/internals/utils/react/deprecateComponent.js +1 -2
- package/esm/internals/utils/react/getDOMNode.js +4 -5
- package/esm/internals/utils/sizes.d.ts +2 -2
- package/esm/internals/utils/style-sheet/css.d.ts +0 -1
- package/esm/internals/utils/style-sheet/css.js +1 -1
- package/esm/internals/utils/style-sheet/prefix.d.ts +0 -1
- package/esm/internals/utils/style-sheet/responsive.d.ts +1 -1
- package/esm/internals/utils/style-sheet/styles.d.ts +3 -3
- package/esm/internals/utils/style-sheet/styles.js +1 -1
- package/esm/toaster/ToastContainer.js +3 -5
- package/esm/toaster/hooks/useDelayedClosure.d.ts +0 -1
- package/esm/toaster/hooks/useDelayedClosure.js +3 -4
- package/esm/toaster/toaster.js +42 -15
- package/esm/useDialog/Dialog.d.ts +1 -1
- package/esm/useDialog/Dialog.js +1 -1
- package/esm/useDialog/useDialog.d.ts +1 -1
- package/esm/useDialog/useDialog.js +3 -3
- package/esm/useFormControl/hooks/useField.d.ts +0 -1
- package/esm/useFormControl/hooks/useField.js +5 -7
- package/esm/useFormControl/hooks/useRegisterModel.js +2 -2
- package/esm/useFormControl/useFormControl.js +8 -8
- package/esm/useToaster/useToaster.js +4 -5
- package/package.json +1 -1
package/cjs/Form/Form.js
CHANGED
|
@@ -58,6 +58,7 @@ const Form = (0, _utils.forwardRef)((props, ref) => {
|
|
|
58
58
|
fluid,
|
|
59
59
|
layout,
|
|
60
60
|
model: formModel = defaultSchema,
|
|
61
|
+
resolver,
|
|
61
62
|
readOnly,
|
|
62
63
|
plaintext,
|
|
63
64
|
children,
|
|
@@ -88,7 +89,8 @@ const Form = (0, _utils.forwardRef)((props, ref) => {
|
|
|
88
89
|
getCombinedModel,
|
|
89
90
|
onCheck,
|
|
90
91
|
onError,
|
|
91
|
-
nestedField
|
|
92
|
+
nestedField,
|
|
93
|
+
resolver
|
|
92
94
|
};
|
|
93
95
|
const {
|
|
94
96
|
formError,
|
|
@@ -104,23 +106,35 @@ const Form = (0, _utils.forwardRef)((props, ref) => {
|
|
|
104
106
|
cleanErrorForField
|
|
105
107
|
} = (0, _useFormValidate.default)(controlledFormError, formValidateProps);
|
|
106
108
|
const submit = (0, _hooks.useEventCallback)(event => {
|
|
109
|
+
if (resolver) {
|
|
110
|
+
// When a resolver is provided, always use the async validation path so that
|
|
111
|
+
// both sync and async resolvers are handled correctly.
|
|
112
|
+
checkAsync().then(({
|
|
113
|
+
hasError
|
|
114
|
+
}) => {
|
|
115
|
+
if (!hasError) {
|
|
116
|
+
onSubmit?.(formValue, event);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
107
122
|
// Check the form before submitting
|
|
108
123
|
if (check()) {
|
|
109
|
-
onSubmit
|
|
124
|
+
onSubmit?.(formValue, event);
|
|
110
125
|
}
|
|
111
126
|
});
|
|
112
127
|
const reset = (0, _hooks.useEventCallback)(event => {
|
|
113
128
|
resetErrors();
|
|
114
129
|
const resetValue = resetFormValue();
|
|
115
130
|
if (resetValue) {
|
|
116
|
-
onChange
|
|
131
|
+
onChange?.(resetValue);
|
|
117
132
|
}
|
|
118
|
-
onReset
|
|
133
|
+
onReset?.(resetValue, event);
|
|
119
134
|
});
|
|
120
135
|
const handleSubmit = (0, _hooks.useEventCallback)(event => {
|
|
121
|
-
|
|
122
|
-
event
|
|
123
|
-
event === null || event === void 0 || (_event$stopPropagatio = event.stopPropagation) === null || _event$stopPropagatio === void 0 || _event$stopPropagatio.call(event);
|
|
136
|
+
event?.preventDefault?.();
|
|
137
|
+
event?.stopPropagation?.();
|
|
124
138
|
|
|
125
139
|
// Prevent submission when the form is disabled, readOnly, or plaintext
|
|
126
140
|
if (disabled || readOnly || plaintext) {
|
|
@@ -129,9 +143,8 @@ const Form = (0, _utils.forwardRef)((props, ref) => {
|
|
|
129
143
|
submit(event);
|
|
130
144
|
});
|
|
131
145
|
const handleReset = (0, _hooks.useEventCallback)(event => {
|
|
132
|
-
|
|
133
|
-
event
|
|
134
|
-
event === null || event === void 0 || (_event$stopPropagatio2 = event.stopPropagation) === null || _event$stopPropagatio2 === void 0 || _event$stopPropagatio2.call(event);
|
|
146
|
+
event?.preventDefault?.();
|
|
147
|
+
event?.stopPropagation?.();
|
|
135
148
|
|
|
136
149
|
// Prevent reset when the form is disabled, readOnly, or plaintext
|
|
137
150
|
if (disabled || readOnly || plaintext) {
|
|
@@ -155,14 +168,14 @@ const Form = (0, _utils.forwardRef)((props, ref) => {
|
|
|
155
168
|
});
|
|
156
169
|
const removeFieldValue = (0, _hooks.useEventCallback)(name => {
|
|
157
170
|
const formValue = onRemoveValue(name);
|
|
158
|
-
onChange
|
|
171
|
+
onChange?.(formValue);
|
|
159
172
|
});
|
|
160
173
|
const removeFieldError = (0, _hooks.useEventCallback)(name => {
|
|
161
174
|
onRemoveError(name);
|
|
162
175
|
});
|
|
163
176
|
const onFieldChange = (0, _hooks.useEventCallback)((name, value, event) => {
|
|
164
177
|
const nextFormValue = setFieldValue(name, value);
|
|
165
|
-
onChange
|
|
178
|
+
onChange?.(nextFormValue, event);
|
|
166
179
|
});
|
|
167
180
|
const formContextValue = {
|
|
168
181
|
errorFromContext,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Resolver } from '../resolvers';
|
|
2
2
|
export interface FormErrorProps {
|
|
3
3
|
formValue: any;
|
|
4
4
|
getCombinedModel: () => any;
|
|
5
5
|
onCheck?: (formError: any) => void;
|
|
6
6
|
onError?: (formError: any) => void;
|
|
7
7
|
nestedField?: boolean;
|
|
8
|
+
resolver?: Resolver;
|
|
8
9
|
}
|
|
9
10
|
export default function useFormValidate(_formError: any, props: FormErrorProps): {
|
|
10
11
|
formError: any;
|
|
@@ -15,7 +15,8 @@ function useFormValidate(_formError, props) {
|
|
|
15
15
|
getCombinedModel,
|
|
16
16
|
onCheck,
|
|
17
17
|
onError,
|
|
18
|
-
nestedField
|
|
18
|
+
nestedField,
|
|
19
|
+
resolver
|
|
19
20
|
} = props;
|
|
20
21
|
const [realFormError, setFormError] = (0, _hooks.useControlled)(_formError, {});
|
|
21
22
|
const checkOptions = {
|
|
@@ -24,12 +25,64 @@ function useFormValidate(_formError, props) {
|
|
|
24
25
|
const realFormErrorRef = (0, _react.useRef)(realFormError);
|
|
25
26
|
realFormErrorRef.current = realFormError;
|
|
26
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Returns true when an error value is considered non-empty (i.e. the field has an error).
|
|
30
|
+
*/
|
|
31
|
+
const isValidError = error => error !== undefined && error !== null && error !== '';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Merges resolver errors into the current form error state, removing entries that
|
|
35
|
+
* are no longer invalid according to the latest resolver result.
|
|
36
|
+
*/
|
|
37
|
+
const mergeResolverErrors = (current, resolverErrors) => {
|
|
38
|
+
const next = {
|
|
39
|
+
...current
|
|
40
|
+
};
|
|
41
|
+
Object.keys({
|
|
42
|
+
...current,
|
|
43
|
+
...resolverErrors
|
|
44
|
+
}).forEach(key => {
|
|
45
|
+
if (isValidError(resolverErrors[key])) {
|
|
46
|
+
next[key] = resolverErrors[key];
|
|
47
|
+
} else {
|
|
48
|
+
delete next[key];
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return next;
|
|
52
|
+
};
|
|
53
|
+
|
|
27
54
|
/**
|
|
28
55
|
* Validate the form data and return a boolean.
|
|
29
56
|
* The error message after verification is returned in the callback.
|
|
57
|
+
*
|
|
58
|
+
* When a `resolver` is provided and the resolver returns a Promise (async resolver),
|
|
59
|
+
* this method cannot resolve the result synchronously. In that case it returns `false`
|
|
60
|
+
* immediately and you should use `checkAsync()` instead.
|
|
30
61
|
* @param callback
|
|
31
62
|
*/
|
|
32
63
|
const check = (0, _hooks.useEventCallback)(callback => {
|
|
64
|
+
if (resolver) {
|
|
65
|
+
const result = resolver(formValue || {});
|
|
66
|
+
|
|
67
|
+
// Async resolver: cannot handle synchronously
|
|
68
|
+
if (result instanceof Promise) {
|
|
69
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
70
|
+
console.warn('[rsuite] The `resolver` provided to <Form> returns a Promise. ' + 'Use `checkAsync()` or rely on `onSubmit` for async validation.');
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
const {
|
|
75
|
+
errors
|
|
76
|
+
} = result;
|
|
77
|
+
const hasError = Object.keys(errors).length > 0;
|
|
78
|
+
setFormError(errors);
|
|
79
|
+
onCheck?.(errors);
|
|
80
|
+
callback?.(errors);
|
|
81
|
+
if (hasError) {
|
|
82
|
+
onError?.(errors);
|
|
83
|
+
}
|
|
84
|
+
return !hasError;
|
|
85
|
+
}
|
|
33
86
|
const formError = {};
|
|
34
87
|
let errorCount = 0;
|
|
35
88
|
const model = getCombinedModel();
|
|
@@ -38,16 +91,16 @@ function useFormValidate(_formError, props) {
|
|
|
38
91
|
const checkResult = type.check(value, formValue, key);
|
|
39
92
|
if (checkResult.hasError === true) {
|
|
40
93
|
errorCount += 1;
|
|
41
|
-
formErrorObj[key] =
|
|
94
|
+
formErrorObj[key] = checkResult?.errorMessage || checkResult;
|
|
42
95
|
}
|
|
43
96
|
|
|
44
97
|
// Check nested object
|
|
45
|
-
if (type
|
|
98
|
+
if (type?.objectTypeSchemaSpec) {
|
|
46
99
|
Object.entries(type.objectTypeSchemaSpec).forEach(([nestedKey, nestedType]) => {
|
|
47
100
|
formErrorObj[key] = formErrorObj[key] || {
|
|
48
101
|
object: {}
|
|
49
102
|
};
|
|
50
|
-
checkField(nestedKey, nestedType, value
|
|
103
|
+
checkField(nestedKey, nestedType, value?.[nestedKey], formErrorObj[key].object);
|
|
51
104
|
});
|
|
52
105
|
}
|
|
53
106
|
};
|
|
@@ -55,15 +108,44 @@ function useFormValidate(_formError, props) {
|
|
|
55
108
|
checkField(key, type, formValue[key], formError);
|
|
56
109
|
});
|
|
57
110
|
setFormError(formError);
|
|
58
|
-
onCheck
|
|
59
|
-
callback
|
|
111
|
+
onCheck?.(formError);
|
|
112
|
+
callback?.(formError);
|
|
60
113
|
if (errorCount > 0) {
|
|
61
|
-
onError
|
|
114
|
+
onError?.(formError);
|
|
62
115
|
return false;
|
|
63
116
|
}
|
|
64
117
|
return true;
|
|
65
118
|
});
|
|
66
119
|
const checkFieldForNextValue = (0, _hooks.useEventCallback)((fieldName, nextValue, callback) => {
|
|
120
|
+
if (resolver) {
|
|
121
|
+
const result = resolver(nextValue);
|
|
122
|
+
if (result instanceof Promise) {
|
|
123
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
124
|
+
console.warn('[rsuite] The `resolver` provided to <Form> returns a Promise. ' + 'Use `checkAsync()` or `checkForFieldAsync()` for async validation.');
|
|
125
|
+
}
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
const {
|
|
129
|
+
errors
|
|
130
|
+
} = result;
|
|
131
|
+
const fieldError = errors[fieldName];
|
|
132
|
+
const hasFieldError = isValidError(fieldError);
|
|
133
|
+
// Merge resolver errors with existing errors, clearing fields that now pass
|
|
134
|
+
const nextFormError = mergeResolverErrors(realFormError, errors);
|
|
135
|
+
setFormError(nextFormError);
|
|
136
|
+
onCheck?.(nextFormError);
|
|
137
|
+
const callbackResult = {
|
|
138
|
+
hasError: hasFieldError,
|
|
139
|
+
errorMessage: fieldError
|
|
140
|
+
};
|
|
141
|
+
callback?.(hasFieldError ? callbackResult : {
|
|
142
|
+
hasError: false
|
|
143
|
+
});
|
|
144
|
+
if (Object.keys(nextFormError).length > 0) {
|
|
145
|
+
onError?.(nextFormError);
|
|
146
|
+
}
|
|
147
|
+
return !hasFieldError;
|
|
148
|
+
}
|
|
67
149
|
const model = getCombinedModel();
|
|
68
150
|
const resultOfCurrentField = model.checkForField(fieldName, nextValue, checkOptions);
|
|
69
151
|
let nextFormError = {
|
|
@@ -77,10 +159,10 @@ function useFormValidate(_formError, props) {
|
|
|
77
159
|
if (nestedField) {
|
|
78
160
|
nextFormError = (0, _set.default)(nextFormError, (0, _nameToPath.nameToPath)(fieldName), resultOfCurrentField);
|
|
79
161
|
setFormError(nextFormError);
|
|
80
|
-
onCheck
|
|
81
|
-
callback
|
|
162
|
+
onCheck?.(nextFormError);
|
|
163
|
+
callback?.(resultOfCurrentField);
|
|
82
164
|
if (resultOfCurrentField.hasError) {
|
|
83
|
-
onError
|
|
165
|
+
onError?.(nextFormError);
|
|
84
166
|
}
|
|
85
167
|
return !resultOfCurrentField.hasError;
|
|
86
168
|
} else {
|
|
@@ -101,10 +183,10 @@ function useFormValidate(_formError, props) {
|
|
|
101
183
|
}
|
|
102
184
|
});
|
|
103
185
|
setFormError(nextFormError);
|
|
104
|
-
onCheck
|
|
105
|
-
callback
|
|
186
|
+
onCheck?.(nextFormError);
|
|
187
|
+
callback?.(resultOfCurrentField);
|
|
106
188
|
if (hasError) {
|
|
107
|
-
onError
|
|
189
|
+
onError?.(nextFormError);
|
|
108
190
|
}
|
|
109
191
|
return !hasError;
|
|
110
192
|
}
|
|
@@ -122,6 +204,22 @@ function useFormValidate(_formError, props) {
|
|
|
122
204
|
* Check form data asynchronously and return a Promise
|
|
123
205
|
*/
|
|
124
206
|
const checkAsync = (0, _hooks.useEventCallback)(() => {
|
|
207
|
+
if (resolver) {
|
|
208
|
+
return Promise.resolve(resolver(formValue || {})).then(({
|
|
209
|
+
errors
|
|
210
|
+
}) => {
|
|
211
|
+
const hasError = Object.keys(errors).length > 0;
|
|
212
|
+
onCheck?.(errors);
|
|
213
|
+
setFormError(errors);
|
|
214
|
+
if (hasError) {
|
|
215
|
+
onError?.(errors);
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
hasError,
|
|
219
|
+
formError: errors
|
|
220
|
+
};
|
|
221
|
+
});
|
|
222
|
+
}
|
|
125
223
|
const promises = [];
|
|
126
224
|
const keys = [];
|
|
127
225
|
const model = getCombinedModel();
|
|
@@ -138,10 +236,10 @@ function useFormValidate(_formError, props) {
|
|
|
138
236
|
formError[keys[i]] = values[i].errorMessage;
|
|
139
237
|
}
|
|
140
238
|
}
|
|
141
|
-
onCheck
|
|
239
|
+
onCheck?.(formError);
|
|
142
240
|
setFormError(formError);
|
|
143
241
|
if (errorCount > 0) {
|
|
144
|
-
onError
|
|
242
|
+
onError?.(formError);
|
|
145
243
|
}
|
|
146
244
|
return {
|
|
147
245
|
hasError: errorCount > 0,
|
|
@@ -150,6 +248,24 @@ function useFormValidate(_formError, props) {
|
|
|
150
248
|
});
|
|
151
249
|
});
|
|
152
250
|
const checkFieldAsyncForNextValue = (0, _hooks.useEventCallback)((fieldName, nextValue) => {
|
|
251
|
+
if (resolver) {
|
|
252
|
+
return Promise.resolve(resolver(nextValue)).then(({
|
|
253
|
+
errors
|
|
254
|
+
}) => {
|
|
255
|
+
const fieldError = errors[fieldName];
|
|
256
|
+
const hasFieldError = isValidError(fieldError);
|
|
257
|
+
const nextFormError = mergeResolverErrors(realFormError, errors);
|
|
258
|
+
onCheck?.(nextFormError);
|
|
259
|
+
setFormError(nextFormError);
|
|
260
|
+
if (Object.keys(nextFormError).length > 0) {
|
|
261
|
+
onError?.(nextFormError);
|
|
262
|
+
}
|
|
263
|
+
return {
|
|
264
|
+
hasError: hasFieldError,
|
|
265
|
+
errorMessage: fieldError
|
|
266
|
+
};
|
|
267
|
+
});
|
|
268
|
+
}
|
|
153
269
|
const model = getCombinedModel();
|
|
154
270
|
return model.checkForFieldAsync(fieldName, nextValue, checkOptions).then(resultOfCurrentField => {
|
|
155
271
|
let nextFormError = {
|
|
@@ -163,10 +279,10 @@ function useFormValidate(_formError, props) {
|
|
|
163
279
|
|
|
164
280
|
if (nestedField) {
|
|
165
281
|
nextFormError = (0, _set.default)(nextFormError, (0, _nameToPath.nameToPath)(fieldName), resultOfCurrentField);
|
|
166
|
-
onCheck
|
|
282
|
+
onCheck?.(nextFormError);
|
|
167
283
|
setFormError(nextFormError);
|
|
168
284
|
if (resultOfCurrentField.hasError) {
|
|
169
|
-
onError
|
|
285
|
+
onError?.(nextFormError);
|
|
170
286
|
}
|
|
171
287
|
return resultOfCurrentField;
|
|
172
288
|
} else {
|
|
@@ -187,9 +303,9 @@ function useFormValidate(_formError, props) {
|
|
|
187
303
|
}
|
|
188
304
|
});
|
|
189
305
|
setFormError(nextFormError);
|
|
190
|
-
onCheck
|
|
306
|
+
onCheck?.(nextFormError);
|
|
191
307
|
if (hasError) {
|
|
192
|
-
onError
|
|
308
|
+
onError?.(nextFormError);
|
|
193
309
|
}
|
|
194
310
|
return resultOfCurrentField;
|
|
195
311
|
}
|
|
@@ -211,7 +327,7 @@ function useFormValidate(_formError, props) {
|
|
|
211
327
|
const formError = (0, _omit.default)(realFormErrorRef.current, [nestedField ? (0, _nameToPath.nameToPath)(name) : name]);
|
|
212
328
|
realFormErrorRef.current = formError;
|
|
213
329
|
setFormError(formError);
|
|
214
|
-
onCheck
|
|
330
|
+
onCheck?.(formError);
|
|
215
331
|
return formError;
|
|
216
332
|
}, [nestedField, onCheck, setFormError]);
|
|
217
333
|
const cleanErrors = (0, _hooks.useEventCallback)(() => {
|
package/cjs/Form/index.d.ts
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The result returned by a validation resolver.
|
|
3
|
+
*
|
|
4
|
+
* @template E - The type of the form error map. Defaults to a record of string keys to any.
|
|
5
|
+
*/
|
|
6
|
+
export interface ResolverResult<E = Record<string, any>> {
|
|
7
|
+
errors: E;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A resolver is a function that integrates third-party validation libraries
|
|
11
|
+
* (e.g. Yup, Zod, AJV, Joi, Valibot…) with the rsuite `Form` component.
|
|
12
|
+
*
|
|
13
|
+
* The resolver receives the current form values and an optional context object,
|
|
14
|
+
* and must return (or resolve to) a `ResolverResult` whose `errors` property is
|
|
15
|
+
* a plain object that maps field names to error messages / error objects.
|
|
16
|
+
*
|
|
17
|
+
* An **empty** `errors` object means the form is valid.
|
|
18
|
+
*
|
|
19
|
+
* @template V - The shape of the form values. Defaults to `Record<string, any>`.
|
|
20
|
+
* @template E - The shape of the error map. Defaults to `Record<string, any>`.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* // Yup example
|
|
25
|
+
* import * as yup from 'yup';
|
|
26
|
+
* import type { Resolver } from 'rsuite';
|
|
27
|
+
*
|
|
28
|
+
* const schema = yup.object({ name: yup.string().email('Invalid email').required() });
|
|
29
|
+
*
|
|
30
|
+
* const resolver: Resolver = async (formValue) => {
|
|
31
|
+
* try {
|
|
32
|
+
* await schema.validate(formValue, { abortEarly: false });
|
|
33
|
+
* return { errors: {} };
|
|
34
|
+
* } catch (e: any) {
|
|
35
|
+
* const errors: Record<string, string> = {};
|
|
36
|
+
* e.inner.forEach((err: yup.ValidationError) => {
|
|
37
|
+
* if (err.path) errors[err.path] = err.message;
|
|
38
|
+
* });
|
|
39
|
+
* return { errors };
|
|
40
|
+
* }
|
|
41
|
+
* };
|
|
42
|
+
*
|
|
43
|
+
* // Zod example
|
|
44
|
+
* import { z } from 'zod';
|
|
45
|
+
*
|
|
46
|
+
* const schema = z.object({ name: z.string().email('Invalid email') });
|
|
47
|
+
*
|
|
48
|
+
* const resolver: Resolver = (formValue) => {
|
|
49
|
+
* const result = schema.safeParse(formValue);
|
|
50
|
+
* if (result.success) return { errors: {} };
|
|
51
|
+
* const errors: Record<string, string> = {};
|
|
52
|
+
* result.error.issues.forEach(err => {
|
|
53
|
+
* if (err.path.length) errors[err.path[0]] = err.message;
|
|
54
|
+
* });
|
|
55
|
+
* return { errors };
|
|
56
|
+
* };
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export type Resolver<V = Record<string, any>, E = Record<string, any>> = (formValue: V, context?: any) => ResolverResult<E> | Promise<ResolverResult<E>>;
|
|
@@ -74,9 +74,9 @@ const FormControl = (0, _utils.forwardRef)((props, ref) => {
|
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
// Combine props and context values
|
|
77
|
-
const resolvedReadOnly = readOnly
|
|
78
|
-
const resolvedPlaintext = plaintext
|
|
79
|
-
const resolvedDisabled = disabled
|
|
77
|
+
const resolvedReadOnly = readOnly ?? contextReadOnly;
|
|
78
|
+
const resolvedPlaintext = plaintext ?? contextPlaintext;
|
|
79
|
+
const resolvedDisabled = disabled ?? contextDisabled;
|
|
80
80
|
const {
|
|
81
81
|
withPrefix,
|
|
82
82
|
prefix
|
|
@@ -86,13 +86,13 @@ const FormControl = (0, _utils.forwardRef)((props, ref) => {
|
|
|
86
86
|
// Handle onChange with both hook's implementation and prop callback
|
|
87
87
|
const handleChange = (value, event) => {
|
|
88
88
|
handleFieldChange(value, event);
|
|
89
|
-
propsOnChange
|
|
89
|
+
propsOnChange?.(value, event);
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
// Handle onBlur with both hook's implementation and prop callback
|
|
93
93
|
const handleBlur = event => {
|
|
94
94
|
handleFieldBlur(); // onBlur doesn't take parameters in the hook
|
|
95
|
-
propsOnBlur
|
|
95
|
+
propsOnBlur?.(event);
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
// Toggle component is a special case that uses `checked` and `defaultChecked` instead of `value` and `defaultValue` props.
|
|
@@ -16,11 +16,10 @@ function defaultRenderInput(props, ref) {
|
|
|
16
16
|
}
|
|
17
17
|
const pickers = ['DatePicker', 'DateRangePicker', 'TimePicker', 'TimeRangePicker', 'InputPicker', 'TagPicker', 'Cascader', 'MultiCascader', 'SelectPicker', 'CheckPicker', 'CheckTreePicker', 'TreePicker'];
|
|
18
18
|
function getDisplayName(Component) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return Component === null || Component === void 0 ? void 0 : Component.type;
|
|
19
|
+
if (typeof Component?.type === 'string') {
|
|
20
|
+
return Component?.type;
|
|
22
21
|
}
|
|
23
|
-
return
|
|
22
|
+
return Component?.type?.displayName || '';
|
|
24
23
|
}
|
|
25
24
|
function renderChildren(children, props, ref) {
|
|
26
25
|
if (typeof children === 'function') {
|
|
@@ -40,8 +39,8 @@ function renderChildren(children, props, ref) {
|
|
|
40
39
|
...rest,
|
|
41
40
|
// Pass onBlur to the child component to automatically save or cancel after the focus event is processed.
|
|
42
41
|
// Special handling in the Picker component, call onBlur when onExit and onClean
|
|
43
|
-
onExit: (0, _utils.createChainedFunction)(() => onBlur
|
|
44
|
-
onClean: (0, _utils.createChainedFunction)(() => onBlur
|
|
42
|
+
onExit: (0, _utils.createChainedFunction)(() => onBlur?.(), onExit),
|
|
43
|
+
onClean: (0, _utils.createChainedFunction)(() => onBlur?.(), onClean),
|
|
45
44
|
ref
|
|
46
45
|
});
|
|
47
46
|
}
|
|
@@ -27,40 +27,37 @@ const useEditState = props => {
|
|
|
27
27
|
if (disabled) {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
onClick
|
|
31
|
-
onEdit
|
|
30
|
+
onClick?.(event);
|
|
31
|
+
onEdit?.(event);
|
|
32
32
|
setIsEditing(true);
|
|
33
33
|
setResetValue(value);
|
|
34
34
|
});
|
|
35
35
|
const handleFocus = (0, _hooks.useEventCallback)(event => {
|
|
36
36
|
if (disabled || isEditing) return;
|
|
37
|
-
onFocus
|
|
37
|
+
onFocus?.(event);
|
|
38
38
|
setIsEditing(true);
|
|
39
39
|
setResetValue(value);
|
|
40
40
|
});
|
|
41
41
|
const handleChange = (0, _hooks.useEventCallback)((value, event) => {
|
|
42
42
|
setValue(value);
|
|
43
|
-
onChange
|
|
43
|
+
onChange?.(value, event);
|
|
44
44
|
});
|
|
45
45
|
const handleCancel = (0, _hooks.useEventCallback)(event => {
|
|
46
|
-
var _event$stopPropagatio;
|
|
47
46
|
setIsEditing(false);
|
|
48
47
|
setValue(resetValue);
|
|
49
|
-
onCancel
|
|
50
|
-
event
|
|
48
|
+
onCancel?.(event);
|
|
49
|
+
event?.stopPropagation?.();
|
|
51
50
|
});
|
|
52
51
|
const handleSave = (0, _hooks.useEventCallback)(event => {
|
|
53
|
-
var _event$stopPropagatio2;
|
|
54
52
|
setIsEditing(false);
|
|
55
|
-
onSave
|
|
56
|
-
event
|
|
53
|
+
onSave?.(event);
|
|
54
|
+
event?.stopPropagation?.();
|
|
57
55
|
});
|
|
58
56
|
const handleKeyDown = (0, _hooks.useEventCallback)(event => {
|
|
59
|
-
var _event$target;
|
|
60
57
|
if (isEditing) {
|
|
61
58
|
switch (event.key) {
|
|
62
59
|
case 'Enter':
|
|
63
|
-
if (
|
|
60
|
+
if (event.target?.tagName === 'INPUT') {
|
|
64
61
|
handleSave(event);
|
|
65
62
|
}
|
|
66
63
|
break;
|
|
@@ -13,38 +13,34 @@ const useFocusEvent = ({
|
|
|
13
13
|
onSave,
|
|
14
14
|
onCancel
|
|
15
15
|
}) => {
|
|
16
|
-
var _ref$current;
|
|
17
16
|
const ref = (0, _react.useRef)(null);
|
|
18
17
|
const rootRef = (0, _react.useRef)(null);
|
|
19
|
-
const isPicker =
|
|
18
|
+
const isPicker = ref.current?.type === _symbols.RSUITE_PICKER_TYPE;
|
|
20
19
|
const focus = () => {
|
|
21
20
|
if (isPicker) {
|
|
22
21
|
setTimeout(() => {
|
|
23
|
-
var _picker$target, _picker$target$focus, _picker$open;
|
|
24
22
|
const picker = ref.current;
|
|
25
23
|
// Auto focus the search input
|
|
26
|
-
picker
|
|
24
|
+
picker?.target?.focus?.();
|
|
27
25
|
|
|
28
26
|
// Open the picker
|
|
29
|
-
picker
|
|
27
|
+
picker?.open?.();
|
|
30
28
|
}, 100);
|
|
31
29
|
} else {
|
|
32
|
-
|
|
33
|
-
(_ref$current2 = ref.current) === null || _ref$current2 === void 0 || (_ref$current2$focus = _ref$current2.focus) === null || _ref$current2$focus === void 0 || _ref$current2$focus.call(_ref$current2);
|
|
30
|
+
ref.current?.focus?.();
|
|
34
31
|
}
|
|
35
32
|
};
|
|
36
33
|
const handleBlur = (0, _hooks.useEventCallback)(event => {
|
|
37
34
|
if (event) {
|
|
38
|
-
|
|
39
|
-
const relatedTarget = (_event$relatedTarget = event.relatedTarget) !== null && _event$relatedTarget !== void 0 ? _event$relatedTarget : (0, _domLib.ownerDocument)(event.currentTarget).activeElement;
|
|
35
|
+
const relatedTarget = event.relatedTarget ?? (0, _domLib.ownerDocument)(event.currentTarget).activeElement;
|
|
40
36
|
if (rootRef.current && (0, _domLib.contains)(rootRef.current, relatedTarget)) {
|
|
41
37
|
return;
|
|
42
38
|
}
|
|
43
39
|
}
|
|
44
40
|
if (stateOnBlur === 'save') {
|
|
45
|
-
onSave
|
|
41
|
+
onSave?.(event);
|
|
46
42
|
} else if (stateOnBlur === 'cancel') {
|
|
47
|
-
onCancel
|
|
43
|
+
onCancel?.(event);
|
|
48
44
|
}
|
|
49
45
|
});
|
|
50
46
|
(0, _hooks.useIsomorphicLayoutEffect)(() => {
|
package/cjs/Input/Input.js
CHANGED
|
@@ -24,7 +24,7 @@ const Input = (0, _utils.forwardRef)((props, ref) => {
|
|
|
24
24
|
const {
|
|
25
25
|
type = 'text',
|
|
26
26
|
htmlSize,
|
|
27
|
-
size =
|
|
27
|
+
size = inputGroup?.size || 'md',
|
|
28
28
|
classPrefix = 'input',
|
|
29
29
|
...rest
|
|
30
30
|
} = propsWithDefaults;
|
|
@@ -56,7 +56,7 @@ const useInputWidth = (props, sizerRef, placeholderRef) => {
|
|
|
56
56
|
}
|
|
57
57
|
if (width !== inputWidth) {
|
|
58
58
|
setInputWidth(width);
|
|
59
|
-
onAutosize
|
|
59
|
+
onAutosize?.(width);
|
|
60
60
|
}
|
|
61
61
|
}, [minWidth, placeholder, inputWidth, value, placeholderRef, sizerRef, onAutosize]);
|
|
62
62
|
return inputWidth;
|