rsuite 6.1.2 → 6.1.3
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 +9 -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.js +9 -9
- 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 +7 -16
- 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 +1 -3
- package/cjs/Form/Form.js +9 -11
- package/cjs/Form/hooks/useFormRef.d.ts +0 -1
- package/cjs/Form/hooks/useFormValidate.d.ts +0 -1
- package/cjs/Form/hooks/useFormValidate.js +19 -19
- package/cjs/Form/hooks/useFormValue.d.ts +0 -1
- 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 +1 -1
- package/cjs/Timeline/Timeline.js +1 -4
- 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 +1 -1
- 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.js +18 -24
- 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/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 +4 -12
- 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.js +223 -223
- 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.js +9 -9
- 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 +7 -16
- 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 +1 -3
- package/esm/Form/Form.js +9 -11
- package/esm/Form/hooks/useFormRef.d.ts +0 -1
- package/esm/Form/hooks/useFormValidate.d.ts +0 -1
- package/esm/Form/hooks/useFormValidate.js +19 -19
- package/esm/Form/hooks/useFormValue.d.ts +0 -1
- 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 +1 -1
- package/esm/Timeline/Timeline.js +1 -4
- 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 +1 -1
- 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.js +18 -24
- 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/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 +4 -12
- 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
|
@@ -65,9 +65,8 @@ function createDragPreview(name, className) {
|
|
|
65
65
|
* Removes the drag preview element from the DOM.
|
|
66
66
|
*/
|
|
67
67
|
function removeDragPreview() {
|
|
68
|
-
var _dragPreview$parentNo, _dragPreview$parentNo2;
|
|
69
68
|
const dragPreview = document.getElementById('rs-tree-drag-preview');
|
|
70
|
-
dragPreview
|
|
69
|
+
dragPreview?.parentNode?.removeChild?.(dragPreview);
|
|
71
70
|
}
|
|
72
71
|
/**
|
|
73
72
|
* Custom hook for handling tree node dragging.
|
|
@@ -106,7 +105,7 @@ function useTreeDrag(props) {
|
|
|
106
105
|
const getDragNodeKeys = (0, _react.useCallback)(dragNode => {
|
|
107
106
|
let dragNodeKeys = [dragNode[valueKey]];
|
|
108
107
|
const traverse = data => {
|
|
109
|
-
if (
|
|
108
|
+
if (data?.length > 0) {
|
|
110
109
|
data.forEach(node => {
|
|
111
110
|
dragNodeKeys = dragNodeKeys.concat([node[valueKey]]);
|
|
112
111
|
if (node[childrenKey]) {
|
|
@@ -202,12 +201,11 @@ function useTreeDrag(props) {
|
|
|
202
201
|
}, [createDragTreeDataFunction, dropNodePosition]);
|
|
203
202
|
const handleDragStart = (0, _hooks.useEventCallback)((nodeData, event) => {
|
|
204
203
|
if (draggable) {
|
|
205
|
-
var _event$dataTransfer;
|
|
206
204
|
const dragMoverNode = createDragPreview((0, _utils.stringifyReactNode)(nodeData[labelKey]), prefix('drag-preview'));
|
|
207
|
-
|
|
205
|
+
event.dataTransfer?.setDragImage(dragMoverNode, 0, 0);
|
|
208
206
|
setDragNodeKeys(getDragNodeKeys(nodeData));
|
|
209
207
|
setDragNode(flattenedNodes[nodeData.refKey]);
|
|
210
|
-
onDragStart
|
|
208
|
+
onDragStart?.(nodeData, event);
|
|
211
209
|
}
|
|
212
210
|
});
|
|
213
211
|
const handleDragEnter = (0, _hooks.useEventCallback)((nodeData, event) => {
|
|
@@ -218,7 +216,7 @@ function useTreeDrag(props) {
|
|
|
218
216
|
setDragOverNodeKey(nodeData[valueKey]);
|
|
219
217
|
setDropNodePosition(calDropNodePosition(event, treeNodesRefs[nodeData.refKey]));
|
|
220
218
|
}
|
|
221
|
-
onDragEnter
|
|
219
|
+
onDragEnter?.(nodeData, event);
|
|
222
220
|
});
|
|
223
221
|
const handleDragOver = (0, _hooks.useEventCallback)((nodeData, event) => {
|
|
224
222
|
if (dragNodeKeys.some(d => (0, _utils.shallowEqual)(d, nodeData[valueKey]))) {
|
|
@@ -230,24 +228,24 @@ function useTreeDrag(props) {
|
|
|
230
228
|
if (lastDropNodePosition === dropNodePosition) return;
|
|
231
229
|
setDropNodePosition(lastDropNodePosition);
|
|
232
230
|
}
|
|
233
|
-
onDragOver
|
|
231
|
+
onDragOver?.(nodeData, event);
|
|
234
232
|
});
|
|
235
233
|
const handleDragLeave = (0, _hooks.useEventCallback)((nodeData, event) => {
|
|
236
|
-
onDragLeave
|
|
234
|
+
onDragLeave?.(nodeData, event);
|
|
237
235
|
});
|
|
238
236
|
const handleDragEnd = (0, _hooks.useEventCallback)((nodeData, event) => {
|
|
239
237
|
removeDragPreview();
|
|
240
238
|
setDragNode(null);
|
|
241
239
|
setDragNodeKeys([]);
|
|
242
240
|
setDragOverNodeKey(null);
|
|
243
|
-
onDragEnd
|
|
241
|
+
onDragEnd?.(nodeData, event);
|
|
244
242
|
});
|
|
245
243
|
const handleDrop = (0, _hooks.useEventCallback)((nodeData, event) => {
|
|
246
244
|
if (dragNodeKeys.some(d => (0, _utils.shallowEqual)(d, nodeData[valueKey]))) {
|
|
247
245
|
console.error('Cannot drag a node to itself and its children');
|
|
248
246
|
} else {
|
|
249
247
|
const dropData = getDropData(nodeData);
|
|
250
|
-
onDrop
|
|
248
|
+
onDrop?.(dropData, event);
|
|
251
249
|
}
|
|
252
250
|
removeDragPreview();
|
|
253
251
|
setDragNode(null);
|
|
@@ -263,7 +261,7 @@ function useTreeDrag(props) {
|
|
|
263
261
|
onDrop: handleDrop
|
|
264
262
|
};
|
|
265
263
|
return {
|
|
266
|
-
dragNode: dragNode
|
|
264
|
+
dragNode: dragNode?.current,
|
|
267
265
|
dragOverNodeKey,
|
|
268
266
|
dropNodePosition,
|
|
269
267
|
dragEvents
|
|
@@ -39,7 +39,7 @@ function useTreeNodeProps(props) {
|
|
|
39
39
|
const {
|
|
40
40
|
visible
|
|
41
41
|
} = nodeData;
|
|
42
|
-
const draggingNode = dragNode
|
|
42
|
+
const draggingNode = dragNode ?? {};
|
|
43
43
|
const nodeValue = nodeData[valueKey];
|
|
44
44
|
const nodeLabel = nodeData[labelKey];
|
|
45
45
|
const children = nodeData[childrenKey];
|
|
@@ -39,21 +39,21 @@ function useTreeSearch(props) {
|
|
|
39
39
|
}, [childrenKey, labelKey, searchBy]);
|
|
40
40
|
|
|
41
41
|
// Use search keywords to filter options.
|
|
42
|
-
const [keyword, setSearchKeyword] = (0, _react.useState)(searchKeyword
|
|
42
|
+
const [keyword, setSearchKeyword] = (0, _react.useState)(searchKeyword ?? '');
|
|
43
43
|
const [filteredData, setFilteredData] = (0, _react.useState)(() => filterVisibleData(data, keyword));
|
|
44
44
|
const handleSearch = (searchKeyword, event) => {
|
|
45
45
|
const filteredData = filterVisibleData(data, searchKeyword);
|
|
46
46
|
setFilteredData(filteredData);
|
|
47
47
|
setSearchKeyword(searchKeyword);
|
|
48
48
|
if (event) {
|
|
49
|
-
callback
|
|
49
|
+
callback?.(searchKeyword, filteredData, event);
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
(0, _react.useEffect)(() => {
|
|
53
|
-
handleSearch(searchKeyword
|
|
53
|
+
handleSearch(searchKeyword ?? '');
|
|
54
54
|
}, [searchKeyword]);
|
|
55
55
|
(0, _react.useEffect)(() => {
|
|
56
|
-
setSearchKeyword(searchKeyword
|
|
56
|
+
setSearchKeyword(searchKeyword ?? '');
|
|
57
57
|
}, [searchKeyword, setSearchKeyword]);
|
|
58
58
|
const setVisibleData = (0, _react.useCallback)((data, searchKeyword) => {
|
|
59
59
|
setFilteredData(filterVisibleData(data, searchKeyword));
|
|
@@ -40,14 +40,14 @@ function useVirtualizedTreeData(nodes, data, options) {
|
|
|
40
40
|
} = options;
|
|
41
41
|
return (0, _flattenTree.UNSAFE_flattenTree)(data, childrenKey, node => {
|
|
42
42
|
let formatted = {};
|
|
43
|
-
const curNode = nodes
|
|
43
|
+
const curNode = nodes?.[node.refKey];
|
|
44
44
|
const parentKeys = (0, _getNodeParentKeys.getNodeParentKeys)(nodes, curNode, valueKey);
|
|
45
45
|
/**
|
|
46
46
|
* When using virtualized,
|
|
47
47
|
* if the parent node is collapsed, the child nodes should be hidden
|
|
48
48
|
* avoid component height calculation errors
|
|
49
49
|
*/
|
|
50
|
-
let visible = curNode
|
|
50
|
+
let visible = curNode?.parent ? shouldShowNodeByParentExpanded(expandItemValues, parentKeys) : true;
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* when searching, every node default expand
|
package/cjs/Tree/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { BaseBoxProps } from '../internals/Box';
|
|
3
2
|
import type { ListProps } from '../internals/Windowing';
|
|
4
3
|
import type { TreeNode } from '../internals/Tree/types';
|
|
@@ -6,8 +5,8 @@ import type { TreeNode } from '../internals/Tree/types';
|
|
|
6
5
|
* Tree Node Drag Type
|
|
7
6
|
*/
|
|
8
7
|
export declare enum TREE_NODE_DROP_POSITION {
|
|
9
|
-
DRAG_OVER = 0
|
|
10
|
-
DRAG_OVER_TOP = 1
|
|
8
|
+
DRAG_OVER = 0,// drag node in tree node
|
|
9
|
+
DRAG_OVER_TOP = 1,// drag node on tree node
|
|
11
10
|
DRAG_OVER_BOTTOM = 2
|
|
12
11
|
}
|
|
13
12
|
export interface DropData<T> {
|
|
@@ -70,9 +70,8 @@ const getActiveItem = (focusItemValue, flattenedNodes, valueKey) => {
|
|
|
70
70
|
*/
|
|
71
71
|
exports.getActiveItem = getActiveItem;
|
|
72
72
|
const focusTreeNode = (refKey, treeNodeRefs) => {
|
|
73
|
-
var _treeItem$focus;
|
|
74
73
|
const treeItem = treeNodeRefs[refKey];
|
|
75
|
-
treeItem
|
|
74
|
+
treeItem?.focus?.();
|
|
76
75
|
};
|
|
77
76
|
exports.focusTreeNode = focusTreeNode;
|
|
78
77
|
/**
|
|
@@ -176,9 +175,8 @@ function scrollToActiveTreeNode(props) {
|
|
|
176
175
|
formattedNodes
|
|
177
176
|
} = props;
|
|
178
177
|
if (virtualized && value) {
|
|
179
|
-
var _list$scrollToItem;
|
|
180
178
|
const scrollIndex = getScrollToIndex(formattedNodes, value, valueKey);
|
|
181
|
-
list
|
|
179
|
+
list?.scrollToItem?.(scrollIndex);
|
|
182
180
|
}
|
|
183
181
|
}
|
|
184
182
|
const focusCurrentItem = props => {
|
|
@@ -186,11 +184,10 @@ const focusCurrentItem = props => {
|
|
|
186
184
|
selector = SELECTED_TREEITEM_SELECTOR,
|
|
187
185
|
container
|
|
188
186
|
} = props;
|
|
189
|
-
const activeItem = container
|
|
187
|
+
const activeItem = container?.querySelector(selector);
|
|
190
188
|
if (activeItem) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return (_activeItem$dataset = activeItem.dataset) === null || _activeItem$dataset === void 0 ? void 0 : _activeItem$dataset.key;
|
|
189
|
+
activeItem?.focus?.();
|
|
190
|
+
return activeItem.dataset?.key;
|
|
194
191
|
}
|
|
195
192
|
};
|
|
196
193
|
exports.focusCurrentItem = focusCurrentItem;
|
|
@@ -9,11 +9,9 @@ exports.getNodeParentKeys = getNodeParentKeys;
|
|
|
9
9
|
function getNodeParentKeys(nodes, node, valueKey) {
|
|
10
10
|
const parentKeys = [];
|
|
11
11
|
const traverse = node => {
|
|
12
|
-
|
|
13
|
-
if (node !== null && node !== void 0 && (_node$parent = node.parent) !== null && _node$parent !== void 0 && _node$parent.refKey) {
|
|
14
|
-
var _node$parent2;
|
|
12
|
+
if (node?.parent?.refKey) {
|
|
15
13
|
traverse(nodes[node.parent.refKey]);
|
|
16
|
-
parentKeys.push(node
|
|
14
|
+
parentKeys.push(node?.parent?.[valueKey]);
|
|
17
15
|
}
|
|
18
16
|
};
|
|
19
17
|
traverse(node);
|
|
@@ -2,4 +2,4 @@ import type { TreeNode } from '../../internals/Tree/types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Checks if a node has visible children.
|
|
4
4
|
*/
|
|
5
|
-
export declare function hasVisibleChildren(node: TreeNode, childrenKey: string):
|
|
5
|
+
export declare function hasVisibleChildren(node: TreeNode, childrenKey: string): boolean;
|
|
@@ -22,8 +22,8 @@ function handleLeftArrow(props) {
|
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
if (expand) {
|
|
25
|
-
onExpand
|
|
26
|
-
} else if (focusItem
|
|
25
|
+
onExpand?.(focusItem, expand);
|
|
26
|
+
} else if (focusItem?.parent) {
|
|
27
27
|
onFocusItem();
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -46,7 +46,7 @@ function handleRightArrow(props) {
|
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
if (!expand) {
|
|
49
|
-
onExpand
|
|
49
|
+
onExpand?.(focusItem, expand);
|
|
50
50
|
} else {
|
|
51
51
|
onFocusItem();
|
|
52
52
|
}
|
|
@@ -141,8 +141,7 @@ const TreePicker = (0, _utils.forwardRef)((props, ref) => {
|
|
|
141
141
|
onEntered
|
|
142
142
|
});
|
|
143
143
|
const handleSelect = (0, _hooks.useEventCallback)((treeNode, value, event) => {
|
|
144
|
-
|
|
145
|
-
onSelect === null || onSelect === void 0 || onSelect(treeNode, value, event);
|
|
144
|
+
onSelect?.(treeNode, value, event);
|
|
146
145
|
|
|
147
146
|
// Only leaf nodes can update the value and close the picker.
|
|
148
147
|
if (onlyLeafSelectable && !(0, _utils3.isLeafNode)(treeNode)) {
|
|
@@ -150,8 +149,8 @@ const TreePicker = (0, _utils.forwardRef)((props, ref) => {
|
|
|
150
149
|
}
|
|
151
150
|
setFocusItemValue(value);
|
|
152
151
|
handleChange(value, event);
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
target.current?.focus();
|
|
153
|
+
trigger.current?.close?.();
|
|
155
154
|
});
|
|
156
155
|
const handleClean = (0, _hooks.useEventCallback)(event => {
|
|
157
156
|
const target = event.target;
|
|
@@ -160,7 +159,7 @@ const TreePicker = (0, _utils.forwardRef)((props, ref) => {
|
|
|
160
159
|
return;
|
|
161
160
|
}
|
|
162
161
|
setValue(null);
|
|
163
|
-
onChange
|
|
162
|
+
onChange?.(null, event);
|
|
164
163
|
});
|
|
165
164
|
const handleTreePressEnter = (0, _hooks.useEventCallback)(event => {
|
|
166
165
|
if ((0, _isNil.default)(focusItemValue)) {
|
|
@@ -189,7 +188,7 @@ const TreePicker = (0, _utils.forwardRef)((props, ref) => {
|
|
|
189
188
|
});
|
|
190
189
|
const handleChange = (0, _hooks.useEventCallback)((nextValue, event) => {
|
|
191
190
|
setValue(nextValue);
|
|
192
|
-
onChange
|
|
191
|
+
onChange?.(nextValue, event);
|
|
193
192
|
});
|
|
194
193
|
const treeContext = (0, _react.useMemo)(() => ({
|
|
195
194
|
register,
|
|
@@ -239,7 +238,7 @@ const TreePicker = (0, _utils.forwardRef)((props, ref) => {
|
|
|
239
238
|
ref: (0, _utils.mergeRefs)(overlay, speakerRef),
|
|
240
239
|
onKeyDown: onPickerKeydown,
|
|
241
240
|
target: trigger
|
|
242
|
-
}, renderTree ? renderTree(tree) : tree, renderExtraFooter
|
|
241
|
+
}, renderTree ? renderTree(tree) : tree, renderExtraFooter?.());
|
|
243
242
|
};
|
|
244
243
|
|
|
245
244
|
/**
|
|
@@ -249,7 +248,7 @@ const TreePicker = (0, _utils.forwardRef)((props, ref) => {
|
|
|
249
248
|
let hasValidValue = !(0, _isNil.default)(activeNode) || !(0, _isNil.default)(value) && (0, _isFunction.default)(renderValue);
|
|
250
249
|
let selectedElement = placeholder;
|
|
251
250
|
if (hasValidValue) {
|
|
252
|
-
const node = activeNode
|
|
251
|
+
const node = activeNode ?? {};
|
|
253
252
|
selectedElement = node[labelKey];
|
|
254
253
|
if ((0, _isFunction.default)(renderValue) && value) {
|
|
255
254
|
selectedElement = renderValue(value, node, selectedElement);
|
|
@@ -290,7 +289,7 @@ const TreePicker = (0, _utils.forwardRef)((props, ref) => {
|
|
|
290
289
|
placement: placement,
|
|
291
290
|
inputValue: value,
|
|
292
291
|
focusItemValue: focusItemValue
|
|
293
|
-
}, rest), selectedElement ||
|
|
292
|
+
}, rest), selectedElement || locale?.placeholder));
|
|
294
293
|
});
|
|
295
294
|
TreePicker.displayName = 'TreePicker';
|
|
296
295
|
var _default = exports.default = TreePicker;
|
|
@@ -14,27 +14,23 @@ function useFocusState(props) {
|
|
|
14
14
|
const [active, setActive] = (0, _react.useState)(false);
|
|
15
15
|
const [focusItemValue, setFocusItemValue] = (0, _react.useState)(null);
|
|
16
16
|
const focusTarget = (0, _hooks.useEventCallback)(() => {
|
|
17
|
-
|
|
18
|
-
(_target$current = target.current) === null || _target$current === void 0 || _target$current.focus();
|
|
17
|
+
target.current?.focus();
|
|
19
18
|
});
|
|
20
19
|
const onEnter = (0, _hooks.useEventCallback)(node => {
|
|
21
|
-
var _props$onEnter;
|
|
22
20
|
setActive(true);
|
|
23
|
-
|
|
21
|
+
props.onEnter?.(node);
|
|
24
22
|
});
|
|
25
23
|
const onExit = (0, _hooks.useEventCallback)(node => {
|
|
26
|
-
var _props$onExit;
|
|
27
24
|
setActive(false);
|
|
28
25
|
focusTarget();
|
|
29
|
-
|
|
26
|
+
props.onExit?.(node);
|
|
30
27
|
});
|
|
31
28
|
const onEntered = (0, _hooks.useEventCallback)(node => {
|
|
32
|
-
var _props$onEntered;
|
|
33
29
|
if (value) {
|
|
34
30
|
setFocusItemValue(value);
|
|
35
31
|
focusActiveNode();
|
|
36
32
|
}
|
|
37
|
-
|
|
33
|
+
props.onEntered?.(node);
|
|
38
34
|
});
|
|
39
35
|
return {
|
|
40
36
|
active,
|
|
@@ -70,13 +70,12 @@ const UploadFileItem = (0, _utils.forwardRef)((props, ref) => {
|
|
|
70
70
|
* Get thumbnail of image file
|
|
71
71
|
*/
|
|
72
72
|
const getThumbnail = (0, _react.useCallback)(callback => {
|
|
73
|
-
var _file$blobFile;
|
|
74
73
|
if (!~['picture-text', 'picture'].indexOf(listType)) {
|
|
75
74
|
return;
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
// The thumbnail file size cannot be larger than the preset value.
|
|
79
|
-
if (!file.blobFile ||
|
|
78
|
+
if (!file.blobFile || file?.blobFile?.size > maxPreviewFileSize) {
|
|
80
79
|
return;
|
|
81
80
|
}
|
|
82
81
|
(0, _previewFile.previewFile)(file.blobFile, callback);
|
|
@@ -92,19 +91,19 @@ const UploadFileItem = (0, _utils.forwardRef)((props, ref) => {
|
|
|
92
91
|
if (disabled) {
|
|
93
92
|
return;
|
|
94
93
|
}
|
|
95
|
-
onPreview
|
|
94
|
+
onPreview?.(file, event);
|
|
96
95
|
}, [disabled, file, onPreview]);
|
|
97
96
|
const handleRemove = (0, _react.useCallback)(event => {
|
|
98
97
|
if (disabled) {
|
|
99
98
|
return;
|
|
100
99
|
}
|
|
101
|
-
onCancel
|
|
100
|
+
onCancel?.(file.fileKey, event);
|
|
102
101
|
}, [disabled, file.fileKey, onCancel]);
|
|
103
102
|
const handleReupload = (0, _react.useCallback)(event => {
|
|
104
103
|
if (disabled) {
|
|
105
104
|
return;
|
|
106
105
|
}
|
|
107
|
-
onReupload
|
|
106
|
+
onReupload?.(file, event);
|
|
108
107
|
}, [disabled, file, onReupload]);
|
|
109
108
|
|
|
110
109
|
/**
|
|
@@ -180,8 +179,8 @@ const UploadFileItem = (0, _utils.forwardRef)((props, ref) => {
|
|
|
180
179
|
return null;
|
|
181
180
|
}
|
|
182
181
|
let closeLabel = 'Remove file';
|
|
183
|
-
if (locale
|
|
184
|
-
closeLabel =
|
|
182
|
+
if (locale?.removeFile) {
|
|
183
|
+
closeLabel = locale?.removeFile + (file?.name ? `: ${file?.name}` : '');
|
|
185
184
|
}
|
|
186
185
|
return /*#__PURE__*/_react.default.createElement(_CloseButton.default, {
|
|
187
186
|
className: prefix('btn-remove'),
|
|
@@ -201,7 +200,7 @@ const UploadFileItem = (0, _utils.forwardRef)((props, ref) => {
|
|
|
201
200
|
if (file.status === 'error') {
|
|
202
201
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
203
202
|
className: prefix('status')
|
|
204
|
-
}, /*#__PURE__*/_react.default.createElement("span", null, locale
|
|
203
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, locale?.error), allowReupload && /*#__PURE__*/_react.default.createElement("a", {
|
|
205
204
|
role: "button",
|
|
206
205
|
tabIndex: -1,
|
|
207
206
|
onClick: handleReupload,
|
|
@@ -218,10 +217,9 @@ const UploadFileItem = (0, _utils.forwardRef)((props, ref) => {
|
|
|
218
217
|
*/
|
|
219
218
|
const renderFileSize = () => {
|
|
220
219
|
if (file.status !== 'error' && file.blobFile) {
|
|
221
|
-
var _file$blobFile2;
|
|
222
220
|
return /*#__PURE__*/_react.default.createElement("span", {
|
|
223
221
|
className: prefix('size')
|
|
224
|
-
}, formatSize(file
|
|
222
|
+
}, formatSize(file?.blobFile?.size));
|
|
225
223
|
}
|
|
226
224
|
return null;
|
|
227
225
|
};
|
|
@@ -11,7 +11,6 @@ var _utils = require("../internals/utils");
|
|
|
11
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
12
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
13
|
const UploadTrigger = (0, _utils.forwardRef)((props, ref) => {
|
|
14
|
-
var _children$props;
|
|
15
14
|
const {
|
|
16
15
|
as: Component = _Button.default,
|
|
17
16
|
name,
|
|
@@ -43,8 +42,7 @@ const UploadTrigger = (0, _utils.forwardRef)((props, ref) => {
|
|
|
43
42
|
'drag-over': dragOver
|
|
44
43
|
}));
|
|
45
44
|
const handleClick = (0, _hooks.useEventCallback)(() => {
|
|
46
|
-
|
|
47
|
-
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.click();
|
|
45
|
+
inputRef.current?.click();
|
|
48
46
|
});
|
|
49
47
|
const handleClearInput = (0, _hooks.useEventCallback)(() => {
|
|
50
48
|
if (inputRef.current) {
|
|
@@ -56,26 +54,26 @@ const UploadTrigger = (0, _utils.forwardRef)((props, ref) => {
|
|
|
56
54
|
event.preventDefault();
|
|
57
55
|
setDragOver(true);
|
|
58
56
|
}
|
|
59
|
-
onDragEnter
|
|
57
|
+
onDragEnter?.(event);
|
|
60
58
|
});
|
|
61
59
|
const handleDragLeave = (0, _hooks.useEventCallback)(event => {
|
|
62
60
|
if (draggable) {
|
|
63
61
|
event.preventDefault();
|
|
64
62
|
setDragOver(false);
|
|
65
63
|
}
|
|
66
|
-
onDragLeave
|
|
64
|
+
onDragLeave?.(event);
|
|
67
65
|
});
|
|
68
66
|
const handleDragOver = (0, _hooks.useEventCallback)(event => {
|
|
69
67
|
draggable && event.preventDefault();
|
|
70
|
-
onDragOver
|
|
68
|
+
onDragOver?.(event);
|
|
71
69
|
});
|
|
72
70
|
const handleDrop = (0, _hooks.useEventCallback)(event => {
|
|
73
71
|
if (draggable) {
|
|
74
72
|
event.preventDefault();
|
|
75
73
|
setDragOver(false);
|
|
76
|
-
onChange
|
|
74
|
+
onChange?.(event);
|
|
77
75
|
}
|
|
78
|
-
onDrop
|
|
76
|
+
onDrop?.(event);
|
|
79
77
|
});
|
|
80
78
|
(0, _react.useImperativeHandle)(ref, () => ({
|
|
81
79
|
root: rootRef.current,
|
|
@@ -98,8 +96,8 @@ const UploadTrigger = (0, _utils.forwardRef)((props, ref) => {
|
|
|
98
96
|
};
|
|
99
97
|
const trigger = children ? (/*#__PURE__*/_react.default.cloneElement(children, {
|
|
100
98
|
...buttonProps,
|
|
101
|
-
className: (0, _classnames.default)(
|
|
102
|
-
})) : /*#__PURE__*/_react.default.createElement(Component, buttonProps, locale
|
|
99
|
+
className: (0, _classnames.default)(children.props?.className, prefix('btn'))
|
|
100
|
+
})) : /*#__PURE__*/_react.default.createElement(Component, buttonProps, locale?.upload);
|
|
103
101
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
104
102
|
ref: rootRef,
|
|
105
103
|
className: classes,
|
package/cjs/Uploader/Uploader.js
CHANGED
|
@@ -18,9 +18,8 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
18
18
|
// Define several states of the file during the upload process.
|
|
19
19
|
|
|
20
20
|
const getFiles = event => {
|
|
21
|
-
if (typeof
|
|
22
|
-
|
|
23
|
-
return event === null || event === void 0 || (_event$dataTransfer = event['dataTransfer']) === null || _event$dataTransfer === void 0 ? void 0 : _event$dataTransfer.files;
|
|
21
|
+
if (typeof event?.['dataTransfer'] === 'object') {
|
|
22
|
+
return event?.['dataTransfer']?.files;
|
|
24
23
|
}
|
|
25
24
|
if (event.target) {
|
|
26
25
|
return event.target['files'];
|
|
@@ -38,7 +37,6 @@ const createFile = file => {
|
|
|
38
37
|
};
|
|
39
38
|
};
|
|
40
39
|
function fileListReducer(files, action) {
|
|
41
|
-
var _action$files;
|
|
42
40
|
switch (action.type) {
|
|
43
41
|
// Add one or more files
|
|
44
42
|
case 'push':
|
|
@@ -56,10 +54,10 @@ function fileListReducer(files, action) {
|
|
|
56
54
|
|
|
57
55
|
// Initialization file list
|
|
58
56
|
case 'init':
|
|
59
|
-
return
|
|
57
|
+
return action.files?.map(file => {
|
|
60
58
|
// The state of the file needs to be preserved when the `fileList` is controlled.
|
|
61
59
|
return files.find(f => f.fileKey === file.fileKey) || createFile(file);
|
|
62
|
-
})
|
|
60
|
+
}) || [];
|
|
63
61
|
default:
|
|
64
62
|
throw new Error();
|
|
65
63
|
}
|
|
@@ -70,8 +68,7 @@ const useFileList = (defaultFileList = []) => {
|
|
|
70
68
|
const [fileList, dispatch] = (0, _react.useReducer)(fileListReducer, fileListRef.current);
|
|
71
69
|
fileListRef.current = fileList;
|
|
72
70
|
(0, _react.useEffect)(() => {
|
|
73
|
-
|
|
74
|
-
(_fileListUpdateCallba = fileListUpdateCallback.current) === null || _fileListUpdateCallba === void 0 || _fileListUpdateCallba.call(fileListUpdateCallback, fileList);
|
|
71
|
+
fileListUpdateCallback.current?.(fileList);
|
|
75
72
|
fileListUpdateCallback.current = null;
|
|
76
73
|
}, [fileList]);
|
|
77
74
|
(0, _hooks.useWillUnmount)(() => {
|
|
@@ -167,8 +164,7 @@ const Uploader = (0, _utils.forwardRef)((props, ref) => {
|
|
|
167
164
|
* Clear the value in input.
|
|
168
165
|
*/
|
|
169
166
|
const cleanInputValue = (0, _react.useCallback)(() => {
|
|
170
|
-
|
|
171
|
-
(_trigger$current = trigger.current) === null || _trigger$current === void 0 || _trigger$current.clearInput();
|
|
167
|
+
trigger.current?.clearInput();
|
|
172
168
|
}, []);
|
|
173
169
|
|
|
174
170
|
/**
|
|
@@ -185,7 +181,7 @@ const Uploader = (0, _utils.forwardRef)((props, ref) => {
|
|
|
185
181
|
progress: 100
|
|
186
182
|
};
|
|
187
183
|
updateFileStatus(nextFile);
|
|
188
|
-
onSuccess
|
|
184
|
+
onSuccess?.(response, nextFile, event, xhr);
|
|
189
185
|
}, [onSuccess, updateFileStatus]);
|
|
190
186
|
|
|
191
187
|
/**
|
|
@@ -201,7 +197,7 @@ const Uploader = (0, _utils.forwardRef)((props, ref) => {
|
|
|
201
197
|
status: 'error'
|
|
202
198
|
};
|
|
203
199
|
updateFileStatus(nextFile);
|
|
204
|
-
onError
|
|
200
|
+
onError?.(status, nextFile, event, xhr);
|
|
205
201
|
}, [onError, updateFileStatus]);
|
|
206
202
|
|
|
207
203
|
/**
|
|
@@ -218,7 +214,7 @@ const Uploader = (0, _utils.forwardRef)((props, ref) => {
|
|
|
218
214
|
progress: percent
|
|
219
215
|
};
|
|
220
216
|
updateFileStatus(nextFile);
|
|
221
|
-
onProgress
|
|
217
|
+
onProgress?.(percent, nextFile, event, xhr);
|
|
222
218
|
}, [onProgress, updateFileStatus]);
|
|
223
219
|
|
|
224
220
|
/**
|
|
@@ -250,11 +246,11 @@ const Uploader = (0, _utils.forwardRef)((props, ref) => {
|
|
|
250
246
|
if (file.fileKey) {
|
|
251
247
|
xhrs.current[file.fileKey] = xhr;
|
|
252
248
|
}
|
|
253
|
-
onUpload
|
|
249
|
+
onUpload?.(file, uploadData, xhr);
|
|
254
250
|
});
|
|
255
251
|
const handleAjaxUpload = (0, _hooks.useEventCallback)(() => {
|
|
256
252
|
fileList.current.forEach(file => {
|
|
257
|
-
const checkState = shouldUpload
|
|
253
|
+
const checkState = shouldUpload?.(file);
|
|
258
254
|
if (checkState instanceof Promise) {
|
|
259
255
|
checkState.then(res => {
|
|
260
256
|
if (res) {
|
|
@@ -283,13 +279,13 @@ const Uploader = (0, _utils.forwardRef)((props, ref) => {
|
|
|
283
279
|
});
|
|
284
280
|
});
|
|
285
281
|
const nextFileList = [...fileList.current, ...newFileList];
|
|
286
|
-
const checkState = shouldQueueUpdate
|
|
282
|
+
const checkState = shouldQueueUpdate?.(nextFileList, newFileList);
|
|
287
283
|
if (checkState === false) {
|
|
288
284
|
cleanInputValue();
|
|
289
285
|
return;
|
|
290
286
|
}
|
|
291
287
|
const upload = () => {
|
|
292
|
-
onChange
|
|
288
|
+
onChange?.(nextFileList, event);
|
|
293
289
|
if (rootRef.current) {
|
|
294
290
|
dispatch({
|
|
295
291
|
type: 'push',
|
|
@@ -308,24 +304,22 @@ const Uploader = (0, _utils.forwardRef)((props, ref) => {
|
|
|
308
304
|
upload();
|
|
309
305
|
});
|
|
310
306
|
const handleRemoveFile = (0, _hooks.useEventCallback)((fileKey, event) => {
|
|
311
|
-
var _xhrs$current;
|
|
312
307
|
const file = (0, _find.default)(fileList.current, f => f.fileKey === fileKey);
|
|
313
308
|
const nextFileList = fileList.current.filter(f => f.fileKey !== fileKey);
|
|
314
|
-
if (
|
|
315
|
-
|
|
316
|
-
(_xhrs$current$file$fi = xhrs.current[file.fileKey]) === null || _xhrs$current$file$fi === void 0 || _xhrs$current$file$fi.abort();
|
|
309
|
+
if (xhrs.current?.[file.fileKey]?.readyState !== 4) {
|
|
310
|
+
xhrs.current[file.fileKey]?.abort();
|
|
317
311
|
}
|
|
318
312
|
dispatch({
|
|
319
313
|
type: 'remove',
|
|
320
314
|
fileKey
|
|
321
315
|
});
|
|
322
|
-
onRemove
|
|
323
|
-
onChange
|
|
316
|
+
onRemove?.(file);
|
|
317
|
+
onChange?.(nextFileList, event);
|
|
324
318
|
cleanInputValue();
|
|
325
319
|
});
|
|
326
320
|
const handleReupload = (0, _hooks.useEventCallback)(file => {
|
|
327
321
|
autoUpload && handleUploadFile(file);
|
|
328
|
-
onReupload
|
|
322
|
+
onReupload?.(file);
|
|
329
323
|
});
|
|
330
324
|
|
|
331
325
|
// public API
|
|
@@ -52,7 +52,7 @@ function ajaxUpload(options) {
|
|
|
52
52
|
if (timeout) {
|
|
53
53
|
xhr.timeout = timeout;
|
|
54
54
|
xhr.ontimeout = event => {
|
|
55
|
-
onError
|
|
55
|
+
onError?.({
|
|
56
56
|
type: 'timeout'
|
|
57
57
|
}, event, xhr);
|
|
58
58
|
};
|
|
@@ -63,13 +63,13 @@ function ajaxUpload(options) {
|
|
|
63
63
|
xhr.onload = event => {
|
|
64
64
|
const resp = getResponse(xhr);
|
|
65
65
|
if (xhr.status < 200 || xhr.status >= 300) {
|
|
66
|
-
onError
|
|
66
|
+
onError?.({
|
|
67
67
|
type: 'server_error',
|
|
68
68
|
response: resp
|
|
69
69
|
}, event, xhr);
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
|
-
onSuccess
|
|
72
|
+
onSuccess?.(resp, event, xhr);
|
|
73
73
|
};
|
|
74
74
|
if (xhr.upload) {
|
|
75
75
|
xhr.upload.onprogress = event => {
|
|
@@ -77,11 +77,11 @@ function ajaxUpload(options) {
|
|
|
77
77
|
if (event.lengthComputable) {
|
|
78
78
|
percent = event.loaded / event.total * 100;
|
|
79
79
|
}
|
|
80
|
-
onProgress
|
|
80
|
+
onProgress?.(percent, event, xhr);
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
xhr.onerror = event => {
|
|
84
|
-
onError
|
|
84
|
+
onError?.({
|
|
85
85
|
type: 'xhr_error'
|
|
86
86
|
}, event, xhr);
|
|
87
87
|
};
|