@qsxy/element-plus-react 1.0.0-next.1 → 1.0.0-next.11
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/README.md +95 -0
- package/dist/Avatar/Avatar.d.ts +4 -0
- package/dist/Avatar/Avatar.js +87 -0
- package/dist/Avatar/index.d.ts +2 -0
- package/dist/Avatar/index.js +1 -0
- package/dist/Avatar/typings.d.ts +21 -0
- package/dist/Avatar/typings.js +1 -0
- package/dist/Badge/Badge.d.ts +2 -2
- package/dist/Badge/Badge.js +63 -61
- package/dist/Badge/index.js +1 -39
- package/dist/Badge/typings.d.ts +11 -1
- package/dist/Badge/typings.js +1 -17
- package/dist/Breadcrumb/Breadcrumb.js +23 -53
- package/dist/Breadcrumb/BreadcrumbItem.js +45 -51
- package/dist/Breadcrumb/index.js +2 -42
- package/dist/Breadcrumb/typings.d.ts +4 -0
- package/dist/Breadcrumb/typings.js +1 -17
- package/dist/Button/Button.d.ts +0 -1
- package/dist/Button/Button.js +132 -93
- package/dist/Button/ButtonGroup.js +29 -48
- package/dist/Button/ButtonGroupContext.js +2 -30
- package/dist/Button/index.js +2 -42
- package/dist/Button/typings.d.ts +32 -2
- package/dist/Button/typings.js +1 -17
- package/dist/Button/useButtonCustomStyle.d.ts +4 -0
- package/dist/Button/useButtonCustomStyle.js +65 -0
- package/dist/Calendar/Calendar.js +310 -238
- package/dist/Calendar/CalendarContext.d.ts +10 -0
- package/dist/Calendar/CalendarContext.js +3 -27
- package/dist/Calendar/DatePanel.js +191 -158
- package/dist/Calendar/DateRangePanel.js +140 -125
- package/dist/Calendar/Footer.js +41 -52
- package/dist/Calendar/Header.js +83 -70
- package/dist/Calendar/MonthPanel.js +138 -124
- package/dist/Calendar/MonthRangePanel.js +137 -124
- package/dist/Calendar/ShortCuts.d.ts +2 -0
- package/dist/Calendar/ShortCuts.js +21 -40
- package/dist/Calendar/WeekPanel.js +213 -145
- package/dist/Calendar/YearPanel.js +150 -125
- package/dist/Calendar/YearRangePanel.js +138 -128
- package/dist/Calendar/index.js +4 -47
- package/dist/Calendar/typings.d.ts +18 -0
- package/dist/Calendar/typings.js +1 -17
- package/dist/Calendar/util.js +26 -68
- package/dist/Card/Card.js +36 -46
- package/dist/Card/index.js +1 -39
- package/dist/Card/typings.d.ts +4 -0
- package/dist/Card/typings.js +1 -17
- package/dist/Carousel/Carousel.d.ts +4 -0
- package/dist/Carousel/Carousel.js +204 -0
- package/dist/Carousel/CarouselContext.d.ts +4 -0
- package/dist/Carousel/CarouselContext.js +24 -0
- package/dist/Carousel/CarouselItem.d.ts +4 -0
- package/dist/Carousel/CarouselItem.js +59 -0
- package/dist/Carousel/hooks/useCarousel.d.ts +37 -0
- package/dist/Carousel/hooks/useCarousel.js +373 -0
- package/dist/Carousel/hooks/useCarouselItem.d.ts +8 -0
- package/dist/Carousel/hooks/useCarouselItem.js +165 -0
- package/dist/Carousel/index.d.ts +3 -0
- package/dist/Carousel/index.js +2 -0
- package/dist/Carousel/typings.d.ts +83 -0
- package/dist/Carousel/typings.js +1 -0
- package/dist/Cascader/Cascader.js +694 -604
- package/dist/Cascader/CascaderContext.d.ts +4 -10
- package/dist/Cascader/CascaderContext.js +10 -50
- package/dist/Cascader/CascaderDropdown.d.ts +1 -0
- package/dist/Cascader/CascaderDropdown.js +90 -77
- package/dist/Cascader/CascaderMenu.js +100 -186
- package/dist/Cascader/Utils.d.ts +0 -2
- package/dist/Cascader/Utils.js +6 -77
- package/dist/Cascader/index.d.ts +1 -1
- package/dist/Cascader/index.js +1 -39
- package/dist/Cascader/typings.d.ts +77 -13
- package/dist/Cascader/typings.js +1 -17
- package/dist/Cascader/useCascader.d.ts +61 -3
- package/dist/Cascader/useCascader.js +651 -488
- package/dist/Checkbox/Checkbox.d.ts +3 -3
- package/dist/Checkbox/Checkbox.js +136 -165
- package/dist/Checkbox/CheckboxButton.js +132 -161
- package/dist/Checkbox/index.js +2 -42
- package/dist/Checkbox/typings.d.ts +12 -1
- package/dist/Checkbox/typings.js +1 -17
- package/dist/CheckboxGroup/CheckboxGroup.d.ts +4 -0
- package/dist/CheckboxGroup/CheckboxGroup.js +133 -112
- package/dist/CheckboxGroup/CheckboxGroupContext.d.ts +1 -0
- package/dist/CheckboxGroup/CheckboxGroupContext.js +2 -30
- package/dist/CheckboxGroup/index.js +2 -42
- package/dist/Col/Col.js +53 -79
- package/dist/Col/index.js +1 -39
- package/dist/Col/typings.d.ts +10 -0
- package/dist/Col/typings.js +1 -17
- package/dist/Collapse/Collapse.js +36 -45
- package/dist/Collapse/CollapseContext.d.ts +3 -0
- package/dist/Collapse/CollapseContext.js +3 -31
- package/dist/Collapse/CollapseItem.js +88 -71
- package/dist/Collapse/CollapseTransition.d.ts +7 -6
- package/dist/Collapse/CollapseTransition.js +50 -70
- package/dist/Collapse/index.js +2 -42
- package/dist/Collapse/typings.d.ts +7 -0
- package/dist/Collapse/typings.js +1 -17
- package/dist/ColorPicker/AlphaSlider.d.ts +7 -0
- package/dist/ColorPicker/AlphaSlider.js +117 -100
- package/dist/ColorPicker/ColorPicker.d.ts +1 -1
- package/dist/ColorPicker/ColorPicker.js +233 -190
- package/dist/ColorPicker/HueSlider.d.ts +7 -0
- package/dist/ColorPicker/HueSlider.js +102 -97
- package/dist/ColorPicker/Predefine.d.ts +7 -0
- package/dist/ColorPicker/Predefine.js +65 -67
- package/dist/ColorPicker/SvPanel.d.ts +7 -0
- package/dist/ColorPicker/SvPanel.js +95 -82
- package/dist/ColorPicker/color.js +301 -213
- package/dist/ColorPicker/draggable.js +30 -48
- package/dist/ColorPicker/index.js +1 -39
- package/dist/ColorPicker/typings.d.ts +9 -0
- package/dist/ColorPicker/typings.js +1 -17
- package/dist/ColorPicker/util.js +23 -60
- package/dist/ConfigProvider/ConfigProvider.d.ts +5 -0
- package/dist/ConfigProvider/ConfigProvider.js +4 -28
- package/dist/ConfigProvider/index.js +1 -39
- package/dist/DatePicker/DatePicker.d.ts +3 -3
- package/dist/DatePicker/DatePicker.js +251 -216
- package/dist/DatePicker/DateRangePicker.d.ts +3 -3
- package/dist/DatePicker/DateRangePicker.js +279 -275
- package/dist/DatePicker/index.js +2 -39
- package/dist/DatePicker/main.d.ts +2 -2
- package/dist/DatePicker/main.js +21 -44
- package/dist/DatePicker/typings.d.ts +92 -16
- package/dist/DatePicker/typings.js +1 -17
- package/dist/DateTimePicker/DateTimePicker.d.ts +3 -5
- package/dist/DateTimePicker/DateTimePicker.js +290 -217
- package/dist/DateTimePicker/index.js +1 -39
- package/dist/DateTimePicker/typings.d.ts +10 -12
- package/dist/DateTimePicker/typings.js +1 -17
- package/dist/DateTimePicker/util.js +5 -35
- package/dist/Descriptions/Descriptions.js +83 -67
- package/dist/Descriptions/DescriptionsCell.js +67 -79
- package/dist/Descriptions/DescriptionsContext.d.ts +2 -0
- package/dist/Descriptions/DescriptionsContext.js +4 -32
- package/dist/Descriptions/DescriptionsItem.js +4 -27
- package/dist/Descriptions/DescriptionsRow.js +42 -44
- package/dist/Descriptions/index.js +2 -42
- package/dist/Descriptions/typings.d.ts +13 -0
- package/dist/Descriptions/typings.js +1 -17
- package/dist/Dialog/Dialog.d.ts +0 -1
- package/dist/Dialog/Dialog.js +224 -179
- package/dist/Dialog/DialogBody.js +52 -62
- package/dist/Dialog/DialogContext.d.ts +8 -0
- package/dist/Dialog/DialogContext.js +6 -44
- package/dist/Dialog/DialogFooter.js +21 -45
- package/dist/Dialog/DialogHeader.js +44 -53
- package/dist/Dialog/index.js +1 -39
- package/dist/Dialog/typings.d.ts +39 -3
- package/dist/Dialog/typings.js +1 -17
- package/dist/Dialog/useDraggable.js +52 -79
- package/dist/Divider/Divider.d.ts +7 -3
- package/dist/Divider/Divider.js +38 -49
- package/dist/Divider/index.js +1 -39
- package/dist/Drawer/Drawer.js +145 -123
- package/dist/Drawer/DrawerBody.js +35 -60
- package/dist/Drawer/DrawerContext.d.ts +10 -0
- package/dist/Drawer/DrawerContext.js +13 -44
- package/dist/Drawer/DrawerFooter.js +22 -43
- package/dist/Drawer/DrawerHeader.js +41 -51
- package/dist/Drawer/index.js +1 -39
- package/dist/Drawer/typings.d.ts +16 -0
- package/dist/Drawer/typings.js +1 -17
- package/dist/Dropdown/Dropdown.js +89 -103
- package/dist/Dropdown/DropdownContext.d.ts +2 -0
- package/dist/Dropdown/DropdownContext.js +5 -43
- package/dist/Dropdown/DropdownItem.js +40 -60
- package/dist/Dropdown/DropdownMenu.js +28 -56
- package/dist/Dropdown/index.js +3 -45
- package/dist/Dropdown/typings.d.ts +16 -1
- package/dist/Dropdown/typings.js +1 -17
- package/dist/Empty/Empty.js +32 -56
- package/dist/Empty/ImgEmpty.js +115 -117
- package/dist/Empty/index.js +1 -39
- package/dist/Form/FieldContext.js +8 -37
- package/dist/Form/Form.js +167 -158
- package/dist/Form/FormContext.js +58 -97
- package/dist/Form/FormItem.d.ts +12 -0
- package/dist/Form/FormItem.js +620 -350
- package/dist/Form/FormItemContext.js +3 -31
- package/dist/Form/List.js +121 -104
- package/dist/Form/ListContext.js +3 -27
- package/dist/Form/index.js +3 -45
- package/dist/Form/typings.d.ts +79 -3
- package/dist/Form/typings.js +1 -17
- package/dist/Form/useForm.d.ts +22 -0
- package/dist/Form/useForm.js +830 -690
- package/dist/Form/useWatch.js +64 -79
- package/dist/Form/utils/NameMap.d.ts +3 -0
- package/dist/Form/utils/NameMap.js +98 -69
- package/dist/Form/utils/asyncUtil.js +9 -37
- package/dist/Form/utils/classUtil.js +26 -48
- package/dist/Form/utils/cloneDeep.js +8 -29
- package/dist/Form/utils/get.js +6 -30
- package/dist/Form/utils/messages.js +25 -53
- package/dist/Form/utils/set.js +31 -44
- package/dist/Form/utils/typeUtil.js +3 -31
- package/dist/Form/utils/util.js +18 -55
- package/dist/Form/utils/validateUtil.d.ts +4 -0
- package/dist/Form/utils/validateUtil.js +284 -159
- package/dist/Form/utils/valueUtil.d.ts +17 -0
- package/dist/Form/utils/valueUtil.js +102 -107
- package/dist/Icon/Icon.js +39 -66
- package/dist/Icon/IconList/Check.js +25 -65
- package/dist/Icon/IconList/Close.js +23 -52
- package/dist/Icon/IconList/Delete.js +25 -65
- package/dist/Icon/IconList/Down.js +25 -65
- package/dist/Icon/IconList/Eye.js +25 -65
- package/dist/Icon/IconList/EyeClose.js +25 -65
- package/dist/Icon/IconList/Left.js +25 -65
- package/dist/Icon/IconList/Link.js +19 -55
- package/dist/Icon/IconList/More.js +25 -65
- package/dist/Icon/IconList/Question.js +25 -65
- package/dist/Icon/IconList/Right.js +25 -65
- package/dist/Icon/IconList/Search.js +25 -65
- package/dist/Icon/IconList/Up.js +25 -65
- package/dist/Icon/IconList/Upload.js +25 -65
- package/dist/Icon/IconList/index.js +14 -68
- package/dist/Icon/index.js +2 -42
- package/dist/Icon/typings.d.ts +7 -0
- package/dist/Icon/typings.js +1 -17
- package/dist/Input/Input.js +334 -350
- package/dist/Input/InputGroup.js +27 -43
- package/dist/Input/InputRange.js +295 -305
- package/dist/Input/TextArea.js +129 -116
- package/dist/Input/index.js +3 -45
- package/dist/Input/typings.d.ts +61 -0
- package/dist/Input/typings.js +1 -17
- package/dist/InputNumber/InputNumber.js +219 -200
- package/dist/InputNumber/index.js +1 -39
- package/dist/InputNumber/typings.d.ts +22 -1
- package/dist/InputNumber/typings.js +1 -17
- package/dist/Link/Link.js +43 -63
- package/dist/Link/index.js +1 -39
- package/dist/Link/typings.d.ts +6 -1
- package/dist/Link/typings.js +1 -17
- package/dist/Loading/Loading.js +97 -62
- package/dist/Loading/index.js +1 -39
- package/dist/Loading/typings.d.ts +5 -0
- package/dist/Loading/typings.js +1 -17
- package/dist/Message/Main.d.ts +7 -0
- package/dist/Message/Main.js +41 -66
- package/dist/Message/Message.js +167 -127
- package/dist/Message/index.d.ts +8 -0
- package/dist/Message/index.js +68 -88
- package/dist/Message/typings.d.ts +11 -0
- package/dist/Message/typings.js +1 -17
- package/dist/MessageBox/Main.js +42 -65
- package/dist/MessageBox/MessageBox.js +253 -202
- package/dist/MessageBox/index.d.ts +17 -3
- package/dist/MessageBox/index.js +74 -79
- package/dist/MessageBox/typings.d.ts +50 -0
- package/dist/MessageBox/typings.js +1 -17
- package/dist/Notification/Main.d.ts +7 -0
- package/dist/Notification/Main.js +41 -66
- package/dist/Notification/Notification.js +148 -128
- package/dist/Notification/index.d.ts +15 -0
- package/dist/Notification/index.js +76 -92
- package/dist/Notification/typings.d.ts +13 -0
- package/dist/Notification/typings.js +1 -17
- package/dist/Pagination/Options.js +104 -99
- package/dist/Pagination/Pager.js +30 -61
- package/dist/Pagination/Pagination.js +462 -376
- package/dist/Pagination/index.js +1 -39
- package/dist/Pagination/typings.d.ts +28 -0
- package/dist/Pagination/typings.js +1 -17
- package/dist/Pagination/util.js +10 -41
- package/dist/Popconfirm/Popconfirm.js +109 -113
- package/dist/Popconfirm/index.js +1 -39
- package/dist/Popconfirm/typings.d.ts +12 -1
- package/dist/Popconfirm/typings.js +1 -17
- package/dist/Popover/Popover.js +87 -85
- package/dist/Popover/index.js +1 -39
- package/dist/Popover/typings.d.ts +13 -1
- package/dist/Popover/typings.js +1 -17
- package/dist/Popper/Popper.js +172 -145
- package/dist/Popper/index.js +1 -39
- package/dist/Popper/popperOptions.js +79 -90
- package/dist/Popper/typings.d.ts +7 -1
- package/dist/Popper/typings.js +1 -17
- package/dist/Progress/Progress.js +186 -151
- package/dist/Progress/index.js +1 -39
- package/dist/Progress/typings.d.ts +12 -0
- package/dist/Progress/typings.js +1 -17
- package/dist/Radio/Radio.js +158 -117
- package/dist/Radio/RadioButton.js +127 -117
- package/dist/Radio/index.js +1 -39
- package/dist/Radio/typings.d.ts +7 -0
- package/dist/Radio/typings.js +1 -17
- package/dist/RadioGroup/RadioGroup.js +63 -78
- package/dist/RadioGroup/index.js +1 -39
- package/dist/RadioGroup/typings.d.ts +1 -0
- package/dist/RadioGroup/typings.js +1 -17
- package/dist/Row/Row.js +41 -59
- package/dist/Row/RowContext.d.ts +1 -0
- package/dist/Row/RowContext.js +3 -31
- package/dist/Row/index.js +2 -42
- package/dist/Row/typings.d.ts +4 -0
- package/dist/Row/typings.js +1 -17
- package/dist/Scrollbar/Scrollbar.js +172 -129
- package/dist/Scrollbar/Thumb.js +108 -96
- package/dist/Scrollbar/index.js +1 -39
- package/dist/Scrollbar/typings.d.ts +31 -2
- package/dist/Scrollbar/typings.js +1 -17
- package/dist/Scrollbar/util.js +24 -51
- package/dist/Select/Option.js +50 -75
- package/dist/Select/OptionGroup.js +31 -47
- package/dist/Select/Select.js +25 -48
- package/dist/Select/SelectContext.js +8 -46
- package/dist/Select/SelectCore.js +449 -374
- package/dist/Select/SelectDropdown.js +200 -160
- package/dist/Select/index.js +2 -42
- package/dist/Select/typings.d.ts +34 -1
- package/dist/Select/typings.js +1 -17
- package/dist/Skeleton/PlaceholderGraph.d.ts +4 -0
- package/dist/Skeleton/PlaceholderGraph.js +39 -45
- package/dist/Skeleton/PlaceholderGrid.d.ts +4 -0
- package/dist/Skeleton/PlaceholderGrid.js +55 -71
- package/dist/Skeleton/PlaceholderParagraph.d.ts +4 -0
- package/dist/Skeleton/PlaceholderParagraph.js +51 -56
- package/dist/Skeleton/Skeleton.js +8 -42
- package/dist/Skeleton/index.js +1 -39
- package/dist/Switch/Switch.js +177 -151
- package/dist/Switch/index.js +1 -39
- package/dist/Switch/typings.d.ts +15 -0
- package/dist/Switch/typings.js +1 -17
- package/dist/Table/Colgroup.d.ts +1 -0
- package/dist/Table/Colgroup.js +17 -41
- package/dist/Table/Table.js +246 -184
- package/dist/Table/TableBody.js +265 -231
- package/dist/Table/TableCell.js +461 -325
- package/dist/Table/TableColumn.js +9 -47
- package/dist/Table/TableContext.d.ts +8 -0
- package/dist/Table/TableContext.js +44 -63
- package/dist/Table/TableHeader.js +112 -102
- package/dist/Table/TableHeaderCell.js +211 -158
- package/dist/Table/hooks/useResize.js +69 -83
- package/dist/Table/hooks/useScroll.js +88 -114
- package/dist/Table/hooks/useSelection.d.ts +10 -0
- package/dist/Table/hooks/useSelection.js +145 -110
- package/dist/Table/hooks/useTable.d.ts +7 -0
- package/dist/Table/hooks/useTable.js +411 -309
- package/dist/Table/index.js +2 -42
- package/dist/Table/treeUtil.d.ts +39 -0
- package/dist/Table/treeUtil.js +99 -77
- package/dist/Table/typings.d.ts +137 -1
- package/dist/Table/typings.js +1 -17
- package/dist/Table/util.d.ts +10 -0
- package/dist/Table/util.js +168 -109
- package/dist/Tabs/TabPane.js +51 -53
- package/dist/Tabs/Tabs.js +277 -181
- package/dist/Tabs/TabsContext.js +4 -32
- package/dist/Tabs/index.js +2 -42
- package/dist/Tabs/typings.d.ts +38 -0
- package/dist/Tabs/typings.js +1 -17
- package/dist/Tag/Tag.d.ts +1 -1
- package/dist/Tag/Tag.js +75 -75
- package/dist/Tag/index.js +1 -39
- package/dist/Tag/typings.d.ts +10 -0
- package/dist/Tag/typings.js +1 -17
- package/dist/TimeLine/TimeLine.js +13 -42
- package/dist/TimeLine/TimeLineItem.js +66 -51
- package/dist/TimeLine/index.js +2 -42
- package/dist/TimeLine/typings.d.ts +9 -0
- package/dist/TimeLine/typings.js +1 -17
- package/dist/TimePicker/TimePicker.d.ts +1 -4
- package/dist/TimePicker/TimePicker.js +275 -211
- package/dist/TimePicker/TimePickerPanel.js +62 -71
- package/dist/TimePicker/TimePickerRange.d.ts +4 -4
- package/dist/TimePicker/TimePickerRange.js +372 -332
- package/dist/TimePicker/TimeRangePanel.js +182 -165
- package/dist/TimePicker/TimeSpinnerPanel.js +321 -269
- package/dist/TimePicker/index.d.ts +2 -3
- package/dist/TimePicker/index.js +1 -42
- package/dist/TimePicker/main.d.ts +9 -0
- package/dist/TimePicker/main.js +17 -0
- package/dist/TimePicker/typings.d.ts +39 -21
- package/dist/TimePicker/typings.js +1 -17
- package/dist/TimePicker/useTimePicker.d.ts +7 -0
- package/dist/TimePicker/useTimePicker.js +62 -65
- package/dist/TimePicker/util.js +8 -40
- package/dist/Tooltip/Tooltip.js +172 -187
- package/dist/Tooltip/TooltipContext.d.ts +1 -0
- package/dist/Tooltip/TooltipContext.js +8 -46
- package/dist/Tooltip/index.js +2 -42
- package/dist/Tooltip/typings.d.ts +14 -1
- package/dist/Tooltip/typings.js +1 -17
- package/dist/Transfer/List.js +290 -237
- package/dist/Transfer/ListBody.js +92 -106
- package/dist/Transfer/ListItem.d.ts +1 -0
- package/dist/Transfer/ListItem.js +38 -51
- package/dist/Transfer/Transfer.js +323 -276
- package/dist/Transfer/index.js +1 -39
- package/dist/Transfer/interface.js +1 -17
- package/dist/Transfer/operation.js +35 -48
- package/dist/Transfer/search.js +30 -62
- package/dist/Transfer/typings/index.d.ts +27 -0
- package/dist/Transfer/typings/index.js +1 -17
- package/dist/Transfer/typings/list.d.ts +25 -0
- package/dist/Transfer/typings/list.js +1 -17
- package/dist/Transfer/typings/listBody.d.ts +1 -0
- package/dist/Transfer/typings/listBody.js +2 -30
- package/dist/Transition/Transition.d.ts +16 -3
- package/dist/Transition/Transition.js +271 -232
- package/dist/Transition/TransitionGroup.d.ts +59 -0
- package/dist/Transition/TransitionGroup.js +136 -88
- package/dist/Transition/TransitionGroupContext.js +2 -26
- package/dist/Transition/childMapping.d.ts +23 -0
- package/dist/Transition/childMapping.js +84 -71
- package/dist/Transition/index.js +2 -42
- package/dist/Transition/util.d.ts +0 -1
- package/dist/Transition/util.js +6 -47
- package/dist/Tree/DirectoryTree.d.ts +6 -13
- package/dist/Tree/DirectoryTree.js +149 -170
- package/dist/Tree/DropIndicator.d.ts +4 -2
- package/dist/Tree/DropIndicator.js +16 -41
- package/dist/Tree/Indent.d.ts +2 -2
- package/dist/Tree/Indent.js +23 -54
- package/dist/Tree/MotionTreeNode.d.ts +4 -5
- package/dist/Tree/MotionTreeNode.js +120 -104
- package/dist/Tree/NodeList.d.ts +18 -11
- package/dist/Tree/NodeList.js +232 -216
- package/dist/Tree/RCTree.d.ts +92 -75
- package/dist/Tree/RCTree.js +980 -702
- package/dist/Tree/Tree.d.ts +18 -3
- package/dist/Tree/Tree.js +65 -80
- package/dist/Tree/TreeNode.d.ts +5 -83
- package/dist/Tree/TreeNode.js +367 -473
- package/dist/Tree/contextTypes.d.ts +40 -30
- package/dist/Tree/contextTypes.js +8 -29
- package/dist/Tree/index.d.ts +2 -2
- package/dist/Tree/index.js +4 -48
- package/dist/Tree/typings.d.ts +63 -19
- package/dist/Tree/typings.js +1 -29
- package/dist/Tree/typings.tsx--bak +245 -0
- package/dist/Tree/useUnmount.d.ts +5 -0
- package/dist/Tree/useUnmount.js +34 -0
- package/dist/Tree/util.d.ts +31 -18
- package/dist/Tree/util.js +160 -169
- package/dist/Tree/utils/conductUtil.d.ts +8 -2
- package/dist/Tree/utils/conductUtil.js +113 -93
- package/dist/Tree/utils/dictUtil.d.ts +8 -3
- package/dist/Tree/utils/dictUtil.js +44 -55
- package/dist/Tree/utils/diffUtil.d.ts +4 -3
- package/dist/Tree/utils/diffUtil.js +26 -43
- package/dist/Tree/utils/dropIndicator.js +23 -51
- package/dist/Tree/utils/iconUtil.js +44 -51
- package/dist/Tree/utils/keyUtil.d.ts +2 -0
- package/dist/Tree/utils/keyUtil.js +3 -0
- package/dist/Tree/utils/motion.js +34 -71
- package/dist/Tree/utils/pickAttrs.d.ts +5 -0
- package/dist/Tree/utils/pickAttrs.js +30 -58
- package/dist/Tree/utils/treeUtil.d.ts +40 -18
- package/dist/Tree/utils/treeUtil.js +268 -187
- package/dist/TreeSelect/TreeSelect.js +527 -464
- package/dist/TreeSelect/Utils.d.ts +2 -1
- package/dist/TreeSelect/Utils.js +15 -36
- package/dist/TreeSelect/index.js +1 -39
- package/dist/TreeSelect/typings.d.ts +20 -1
- package/dist/TreeSelect/typings.js +1 -17
- package/dist/Upload/Upload.js +106 -108
- package/dist/Upload/UploadContent.js +227 -182
- package/dist/Upload/UploadContext.js +5 -33
- package/dist/Upload/UploadDrag.js +77 -97
- package/dist/Upload/UploadList.js +104 -72
- package/dist/Upload/ajax.js +45 -71
- package/dist/Upload/index.js +1 -39
- package/dist/Upload/typings.d.ts +34 -0
- package/dist/Upload/typings.js +34 -36
- package/dist/Upload/use-handlers.d.ts +1 -0
- package/dist/Upload/use-handlers.js +182 -126
- package/dist/Util/Math.d.ts +34 -0
- package/dist/Util/Math.js +81 -78
- package/dist/Util/PopupManager.js +5 -27
- package/dist/Util/base.d.ts +22 -0
- package/dist/Util/base.js +109 -162
- package/dist/Util/genFileId.js +3 -29
- package/dist/Util/index.js +6 -51
- package/dist/Util/resize-event.js +31 -54
- package/dist/Util/shallowEqual.d.ts +11 -0
- package/dist/Util/shallowEqual.js +30 -28
- package/dist/Util/treeUtils.d.ts +8 -0
- package/dist/Util/treeUtils.js +68 -64
- package/dist/config/Constants.js +17 -47
- package/dist/display.css +1 -0
- package/dist/fonts/fa-brands-400.ttf +0 -0
- package/dist/fonts/fa-brands-400.woff2 +0 -0
- package/dist/fonts/fa-duotone-900.ttf +0 -0
- package/dist/fonts/fa-duotone-900.woff2 +0 -0
- package/dist/fonts/fa-light-300.ttf +0 -0
- package/dist/fonts/fa-light-300.woff2 +0 -0
- package/dist/fonts/fa-regular-400.ttf +0 -0
- package/dist/fonts/fa-regular-400.woff2 +0 -0
- package/dist/fonts/fa-solid-900.ttf +0 -0
- package/dist/fonts/fa-solid-900.woff2 +0 -0
- package/dist/fonts/fa-thin-100.ttf +0 -0
- package/dist/fonts/fa-thin-100.woff2 +0 -0
- package/dist/fonts/fa-v4compatibility.ttf +0 -0
- package/dist/fonts/fa-v4compatibility.woff2 +0 -0
- package/dist/hooks/animationPropsUtils.d.ts +12 -0
- package/dist/hooks/animationPropsUtils.js +25 -49
- package/dist/hooks/htmlPropsUtils.d.ts +8 -0
- package/dist/hooks/htmlPropsUtils.js +54 -121
- package/dist/hooks/index.js +14 -73
- package/dist/hooks/popperPropsUtils.d.ts +12 -0
- package/dist/hooks/popperPropsUtils.js +25 -67
- package/dist/hooks/prefix.d.ts +1 -1
- package/dist/hooks/prefix.js +22 -55
- package/dist/hooks/treePropsUtils.d.ts +12 -0
- package/dist/hooks/treePropsUtils.js +24 -103
- package/dist/hooks/useChildrenInstance.d.ts +11 -0
- package/dist/hooks/useChildrenInstance.js +51 -60
- package/dist/hooks/useClassNames.d.ts +81 -0
- package/dist/hooks/useClassNames.js +284 -192
- package/dist/hooks/useClickOutside.js +37 -62
- package/dist/hooks/useCommonProps.js +17 -53
- package/dist/hooks/useComponentWillMount.js +4 -28
- package/dist/hooks/useControlled.d.ts +8 -0
- package/dist/hooks/useControlled.js +31 -37
- package/dist/hooks/useForceUpdate.d.ts +1 -0
- package/dist/hooks/useForceUpdate.js +16 -34
- package/dist/hooks/useUpdateEffect.js +6 -29
- package/dist/index.css +1 -58071
- package/dist/index.d.ts +8 -7
- package/dist/index.js +69 -234
- package/dist/theme-chalk/avatar/index.scss +50 -0
- package/dist/theme-chalk/build.scss +2 -0
- package/dist/theme-chalk/calendar/month-table.scss +1 -1
- package/dist/theme-chalk/carousel/index.scss +237 -0
- package/dist/theme-chalk/checkbox/index.scss +2 -2
- package/dist/theme-chalk/common/_var.scss +1 -0
- package/dist/theme-chalk/common/index.js +1 -2
- package/dist/theme-chalk/common/index.scss +2 -2
- package/dist/theme-chalk/date-picker/index.scss +1 -1
- package/dist/theme-chalk/dev.scss +2 -0
- package/dist/theme-chalk/display.scss +46 -0
- package/dist/theme-chalk/doc.scss +2 -0
- package/dist/theme-chalk/fonts/fa-brands-400.ttf +0 -0
- package/dist/theme-chalk/fonts/fa-brands-400.woff2 +0 -0
- package/dist/theme-chalk/fonts/fa-duotone-900.ttf +0 -0
- package/dist/theme-chalk/fonts/fa-duotone-900.woff2 +0 -0
- package/dist/theme-chalk/fonts/fa-light-300.ttf +0 -0
- package/dist/theme-chalk/fonts/fa-light-300.woff2 +0 -0
- package/dist/theme-chalk/fonts/fa-regular-400.ttf +0 -0
- package/dist/theme-chalk/fonts/fa-regular-400.woff2 +0 -0
- package/dist/theme-chalk/fonts/fa-solid-900.ttf +0 -0
- package/dist/theme-chalk/fonts/fa-solid-900.woff2 +0 -0
- package/dist/theme-chalk/fonts/fa-thin-100.ttf +0 -0
- package/dist/theme-chalk/fonts/fa-thin-100.woff2 +0 -0
- package/dist/theme-chalk/fonts/fa-v4compatibility.ttf +0 -0
- package/dist/theme-chalk/fonts/fa-v4compatibility.woff2 +0 -0
- package/dist/theme-chalk/form/index.scss +21 -2
- package/dist/theme-chalk/icon/fonts.scss +9 -0
- package/dist/theme-chalk/icon/index.scss +0 -9
- package/dist/theme-chalk/icon/scss/_shims.scss +318 -318
- package/dist/theme-chalk/icon/scss/_variables.scss +1 -3
- package/dist/theme-chalk/icon/scss/brands.scss +0 -5
- package/dist/theme-chalk/icon/scss/duotone.scss +0 -5
- package/dist/theme-chalk/icon/scss/fontawesome.scss +0 -8
- package/dist/theme-chalk/icon/scss/light.scss +2 -7
- package/dist/theme-chalk/icon/scss/regular.scss +2 -7
- package/dist/theme-chalk/icon/scss/solid.scss +2 -7
- package/dist/theme-chalk/icon/scss/thin.scss +2 -7
- package/dist/theme-chalk/icon/scss/v4-shims.scss +0 -8
- package/dist/theme-chalk/index.scss +3 -0
- package/dist/theme-chalk/input/input.scss +5 -3
- package/dist/theme-chalk/link/index.scss +0 -85
- package/dist/theme-chalk/loading/index.scss +5 -7
- package/dist/theme-chalk/message/index.scss +5 -5
- package/dist/theme-chalk/notification/index.scss +5 -5
- package/dist/theme-chalk/pagination/index.scss +1 -1
- package/dist/theme-chalk/tabs/index.scss +1 -1
- package/dist/types/common.d.ts +24 -0
- package/dist/types/common.js +1 -17
- package/dist/types/type.d.ts +5 -0
- package/dist/types/type.js +16 -28
- package/package.json +8 -23
- package/theme-chalk/avatar/index.scss +50 -0
- package/theme-chalk/badge/index.scss +63 -0
- package/theme-chalk/breadcrumb/index.scss +65 -0
- package/theme-chalk/build.scss +2 -0
- package/{dist/theme-chalk/bak/mixins/_button.scss → theme-chalk/button/_mixins.scss} +151 -58
- package/theme-chalk/button/button-group.scss +83 -0
- package/theme-chalk/button/button.scss +382 -0
- package/theme-chalk/button/index.scss +2 -0
- package/theme-chalk/calendar/date-picker.scss +112 -0
- package/theme-chalk/calendar/date-range-picker.scss +139 -0
- package/theme-chalk/calendar/date-table.scss +156 -0
- package/theme-chalk/calendar/index.scss +6 -0
- package/theme-chalk/calendar/month-table.scss +92 -0
- package/theme-chalk/calendar/picker-panel.scss +136 -0
- package/theme-chalk/calendar/year-table.scss +107 -0
- package/theme-chalk/card/index.scss +44 -0
- package/theme-chalk/carousel/index.scss +237 -0
- package/theme-chalk/cascader/cascader-panel.scss +184 -0
- package/theme-chalk/cascader/cascader.scss +239 -0
- package/theme-chalk/cascader/index.scss +2 -0
- package/theme-chalk/checkbox/index.scss +255 -0
- package/theme-chalk/checkbox-button/index.scss +117 -0
- package/theme-chalk/checkbox-group/index.scss +33 -0
- package/{dist/theme-chalk/bak/mixins/_col.scss → theme-chalk/col/_mixins.scss} +27 -3
- package/theme-chalk/col/index.scss +50 -0
- package/theme-chalk/collapse/index.scss +84 -0
- package/theme-chalk/color-picker/index.scss +340 -0
- package/{dist/theme-chalk/bak/mixins/config.scss → theme-chalk/common/_var.scss} +1 -0
- package/theme-chalk/common/index.scss +222 -0
- package/theme-chalk/common/index.ts +1 -0
- package/theme-chalk/date-picker/index.scss +253 -0
- package/theme-chalk/date-time-picker/index.scss +3 -0
- package/theme-chalk/date-time-picker/time-picker.scss +83 -0
- package/theme-chalk/date-time-picker/time-range-picker.scss +32 -0
- package/theme-chalk/descriptions/descriptions-item.scss +66 -0
- package/theme-chalk/descriptions/descriptions.scss +160 -0
- package/theme-chalk/descriptions/index.scss +2 -0
- package/theme-chalk/dev.scss +2 -0
- package/theme-chalk/dialog/index.scss +190 -0
- package/theme-chalk/display.scss +46 -0
- package/theme-chalk/divider/index.scss +51 -0
- package/theme-chalk/doc.scss +2 -0
- package/theme-chalk/drawer/index.scss +250 -0
- package/theme-chalk/dropdown/index.scss +147 -0
- package/theme-chalk/empty/index.scss +69 -0
- package/theme-chalk/fonts/fa-brands-400.ttf +0 -0
- package/theme-chalk/fonts/fa-brands-400.woff2 +0 -0
- package/theme-chalk/fonts/fa-duotone-900.ttf +0 -0
- package/theme-chalk/fonts/fa-duotone-900.woff2 +0 -0
- package/theme-chalk/fonts/fa-light-300.ttf +0 -0
- package/theme-chalk/fonts/fa-light-300.woff2 +0 -0
- package/theme-chalk/fonts/fa-regular-400.ttf +0 -0
- package/theme-chalk/fonts/fa-regular-400.woff2 +0 -0
- package/theme-chalk/fonts/fa-solid-900.ttf +0 -0
- package/theme-chalk/fonts/fa-solid-900.woff2 +0 -0
- package/theme-chalk/fonts/fa-thin-100.ttf +0 -0
- package/theme-chalk/fonts/fa-thin-100.woff2 +0 -0
- package/theme-chalk/fonts/fa-v4compatibility.ttf +0 -0
- package/theme-chalk/fonts/fa-v4compatibility.woff2 +0 -0
- package/theme-chalk/form/index.scss +378 -0
- package/theme-chalk/icon/fonts.scss +9 -0
- package/theme-chalk/icon/index.scss +44 -0
- package/theme-chalk/icon/scss/_animated.scss +205 -0
- package/theme-chalk/icon/scss/_bordered-pulled.scss +20 -0
- package/theme-chalk/icon/scss/_core.scss +33 -0
- package/theme-chalk/icon/scss/_duotone-icons.scss +12 -0
- package/theme-chalk/icon/scss/_fixed-width.scss +7 -0
- package/theme-chalk/icon/scss/_functions.scss +57 -0
- package/theme-chalk/icon/scss/_icons.scss +11 -0
- package/theme-chalk/icon/scss/_list.scss +20 -0
- package/theme-chalk/icon/scss/_mixins.scss +102 -0
- package/theme-chalk/icon/scss/_rotated-flipped.scss +31 -0
- package/theme-chalk/icon/scss/_screen-reader.scss +14 -0
- package/theme-chalk/icon/scss/_shims.scss +2606 -0
- package/theme-chalk/icon/scss/_sizing.scss +16 -0
- package/theme-chalk/icon/scss/_stacked.scss +32 -0
- package/theme-chalk/icon/scss/_variables.scss +9189 -0
- package/theme-chalk/icon/scss/brands.scss +27 -0
- package/theme-chalk/icon/scss/duotone.scss +72 -0
- package/theme-chalk/icon/scss/fontawesome.scss +13 -0
- package/theme-chalk/icon/scss/index.scss +15 -0
- package/theme-chalk/icon/scss/light.scss +21 -0
- package/theme-chalk/icon/scss/regular.scss +21 -0
- package/theme-chalk/icon/scss/solid.scss +21 -0
- package/theme-chalk/icon/scss/thin.scss +21 -0
- package/theme-chalk/icon/scss/v4-shims.scss +3 -0
- package/theme-chalk/index.scss +67 -0
- package/theme-chalk/input/_mixins.scss +16 -0
- package/theme-chalk/input/index.scss +3 -0
- package/theme-chalk/input/input-range.scss +208 -0
- package/theme-chalk/input/input.scss +577 -0
- package/theme-chalk/input-number/index.scss +172 -0
- package/theme-chalk/link/index.scss +99 -0
- package/theme-chalk/loading/index.scss +94 -0
- package/theme-chalk/message/index.scss +169 -0
- package/theme-chalk/message-box/index.scss +184 -0
- package/theme-chalk/notification/index.scss +155 -0
- package/theme-chalk/pagination/index.scss +515 -0
- package/theme-chalk/placeholder/index.scss +135 -0
- package/theme-chalk/popconfirm/index.scss +35 -0
- package/theme-chalk/popover/index.scss +54 -0
- package/theme-chalk/popper/index.scss +86 -0
- package/theme-chalk/progress/index.scss +155 -0
- package/theme-chalk/radio/index.scss +2 -0
- package/theme-chalk/radio/radio-button.scss +128 -0
- package/theme-chalk/radio/radio.scss +171 -0
- package/theme-chalk/radio-group/index.scss +31 -0
- package/theme-chalk/row/index.scss +30 -0
- package/theme-chalk/scrollbar/index.scss +103 -0
- package/theme-chalk/select/index.scss +244 -0
- package/theme-chalk/select/option-group.scss +54 -0
- package/theme-chalk/select/option.scss +63 -0
- package/theme-chalk/select/select-dropdown.scss +57 -0
- package/theme-chalk/switch/index.scss +273 -0
- package/theme-chalk/table/index.scss +714 -0
- package/theme-chalk/tabs/index.scss +620 -0
- package/theme-chalk/tag/index.scss +360 -0
- package/theme-chalk/time-line/_timeline-item.scss +90 -0
- package/theme-chalk/time-line/_timeline.scss +50 -0
- package/theme-chalk/time-line/index.scss +2 -0
- package/theme-chalk/time-picker/index.scss +109 -0
- package/theme-chalk/tooltip/index.scss +13 -0
- package/theme-chalk/transfer/index.scss +247 -0
- package/theme-chalk/transition/index.scss +756 -0
- package/theme-chalk/tree/_directory.scss +73 -0
- package/theme-chalk/tree/_tree.scss +401 -0
- package/theme-chalk/tree/index.scss +2 -0
- package/theme-chalk/tree-select/index.scss +25 -0
- package/theme-chalk/upload/index.scss +631 -0
- package/dist/Tree/utils/KeyCode.d.ts +0 -110
- package/dist/Tree/utils/KeyCode.js +0 -550
- package/dist/VirtualList/Filler.d.ts +0 -11
- package/dist/VirtualList/Filler.js +0 -78
- package/dist/VirtualList/Item.d.ts +0 -7
- package/dist/VirtualList/Item.js +0 -37
- package/dist/VirtualList/ScrollBar.d.ts +0 -43
- package/dist/VirtualList/ScrollBar.js +0 -216
- package/dist/VirtualList/VirtualList.d.ts +0 -33
- package/dist/VirtualList/VirtualList.js +0 -280
- package/dist/VirtualList/hooks/useChildren.d.ts +0 -3
- package/dist/VirtualList/hooks/useChildren.js +0 -46
- package/dist/VirtualList/hooks/useDiffItem.d.ts +0 -2
- package/dist/VirtualList/hooks/useDiffItem.js +0 -39
- package/dist/VirtualList/hooks/useFrameWheel.d.ts +0 -6
- package/dist/VirtualList/hooks/useFrameWheel.js +0 -72
- package/dist/VirtualList/hooks/useHeights.d.ts +0 -3
- package/dist/VirtualList/hooks/useHeights.js +0 -83
- package/dist/VirtualList/hooks/useLayoutEffect.d.ts +0 -3
- package/dist/VirtualList/hooks/useLayoutEffect.js +0 -30
- package/dist/VirtualList/hooks/useMobileTouchMove.d.ts +0 -2
- package/dist/VirtualList/hooks/useMobileTouchMove.js +0 -92
- package/dist/VirtualList/hooks/useOriginScroll.d.ts +0 -2
- package/dist/VirtualList/hooks/useOriginScroll.js +0 -56
- package/dist/VirtualList/hooks/useScrollTo.d.ts +0 -5
- package/dist/VirtualList/hooks/useScrollTo.js +0 -111
- package/dist/VirtualList/index.d.ts +0 -2
- package/dist/VirtualList/index.js +0 -39
- package/dist/VirtualList/interface.d.ts +0 -8
- package/dist/VirtualList/interface.js +0 -17
- package/dist/VirtualList/mock.d.ts +0 -6
- package/dist/VirtualList/mock.js +0 -29
- package/dist/VirtualList/utils/CacheMap.d.ts +0 -7
- package/dist/VirtualList/utils/CacheMap.js +0 -36
- package/dist/VirtualList/utils/algorithmUtil.d.ts +0 -6
- package/dist/VirtualList/utils/algorithmUtil.js +0 -81
- package/dist/VirtualList/utils/findDOMNode.d.ts +0 -2
- package/dist/VirtualList/utils/findDOMNode.js +0 -30
- package/dist/VirtualList/utils/isFirefox.d.ts +0 -2
- package/dist/VirtualList/utils/isFirefox.js +0 -26
- package/dist/VirtualList/utils/raf.d.ts +0 -5
- package/dist/VirtualList/utils/raf.js +0 -57
- package/dist/theme-chalk/bak/common/popup.scss +0 -47
- package/dist/theme-chalk/bak/common/transition.scss +0 -118
- package/dist/theme-chalk/bak/common/var.scss +0 -1476
- package/dist/theme-chalk/bak/mixins/_var.scss +0 -55
- package/dist/theme-chalk/bak/mixins/function.scss +0 -85
- package/dist/theme-chalk/bak/mixins/mixins.scss +0 -215
- package/dist/theme-chalk/bak/mixins/utils.scss +0 -39
package/dist/Tree/RCTree.js
CHANGED
|
@@ -1,56 +1,57 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var import_DropIndicator = __toESM(require("./DropIndicator"));
|
|
41
|
-
var import_NodeList = __toESM(require("./NodeList"));
|
|
42
|
-
var import_TreeNode = __toESM(require("./TreeNode"));
|
|
43
|
-
var import_contextTypes = require("./contextTypes");
|
|
44
|
-
var import_util = require("./util");
|
|
45
|
-
var import_conductUtil = require("./utils/conductUtil");
|
|
46
|
-
var import_treeUtil = require("./utils/treeUtil");
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
13
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
14
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
15
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
16
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
17
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
18
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
19
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
20
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
21
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
23
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
24
|
+
// TODO: https://www.w3.org/TR/2017/NOTE-wai-aria-practices-1.1-20171214/examples/treeview/treeview-2/treeview-2a.html
|
|
25
|
+
// Fully accessibility support
|
|
26
|
+
|
|
27
|
+
import classNames from 'classnames';
|
|
28
|
+
import KeyCode from 'rc-util/lib/KeyCode';
|
|
29
|
+
import pickAttrs from 'rc-util/lib/pickAttrs';
|
|
30
|
+
import warning from 'rc-util/lib/warning';
|
|
31
|
+
import * as React from 'react';
|
|
32
|
+
import DropIndicator from "./DropIndicator";
|
|
33
|
+
import NodeList, { MOTION_KEY, MotionEntity } from "./NodeList";
|
|
34
|
+
import TreeNode from "./TreeNode";
|
|
35
|
+
import { TreeContext } from "./contextTypes";
|
|
36
|
+
import { arrAdd, arrDel, calcDropPosition, calcSelectedKeys, conductExpandParent, getDragChildrenKeys, parseCheckedKeys, posToArr } from "./util";
|
|
37
|
+
import { conductCheck } from "./utils/conductUtil";
|
|
38
|
+
import getEntity from "./utils/keyUtil";
|
|
39
|
+
import { convertDataToEntities, convertNodePropsToEventData, convertTreeToData, fillFieldNames, flattenTreeData, getTreeNodeProps, warningWithoutKey } from "./utils/treeUtil";
|
|
47
40
|
var MAX_RETRY_TIMES = 10;
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this
|
|
41
|
+
var Tree = /*#__PURE__*/function (_React$Component) {
|
|
42
|
+
_inherits(Tree, _React$Component);
|
|
43
|
+
var _super = _createSuper(Tree);
|
|
44
|
+
function Tree() {
|
|
45
|
+
var _this;
|
|
46
|
+
_classCallCheck(this, Tree);
|
|
47
|
+
for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
48
|
+
_args[_key] = arguments[_key];
|
|
49
|
+
}
|
|
50
|
+
_this = _super.call.apply(_super, [this].concat(_args));
|
|
51
|
+
_defineProperty(_assertThisInitialized(_this), "destroyed", false);
|
|
52
|
+
_defineProperty(_assertThisInitialized(_this), "delayedDragEnterLogic", void 0);
|
|
53
|
+
_defineProperty(_assertThisInitialized(_this), "loadingRetryTimes", {});
|
|
54
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
54
55
|
keyEntities: {},
|
|
55
56
|
indent: null,
|
|
56
57
|
selectedKeys: [],
|
|
@@ -85,217 +86,265 @@ var RCTree = class extends import_react.Component {
|
|
|
85
86
|
activeKey: null,
|
|
86
87
|
listChanging: false,
|
|
87
88
|
prevProps: null,
|
|
88
|
-
fieldNames:
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
89
|
+
fieldNames: fillFieldNames()
|
|
90
|
+
});
|
|
91
|
+
_defineProperty(_assertThisInitialized(_this), "dragStartMousePosition", null);
|
|
92
|
+
_defineProperty(_assertThisInitialized(_this), "dragNodeProps", null);
|
|
93
|
+
_defineProperty(_assertThisInitialized(_this), "currentMouseOverDroppableNodeKey", null);
|
|
94
|
+
_defineProperty(_assertThisInitialized(_this), "listRef", /*#__PURE__*/React.createRef());
|
|
95
|
+
_defineProperty(_assertThisInitialized(_this), "onNodeDragStart", function (event, nodeProps) {
|
|
96
|
+
var _this$state = _this.state,
|
|
97
|
+
expandedKeys = _this$state.expandedKeys,
|
|
98
|
+
keyEntities = _this$state.keyEntities;
|
|
99
|
+
var onDragStart = _this.props.onDragStart;
|
|
100
|
+
var eventKey = nodeProps.eventKey;
|
|
101
|
+
_this.dragNodeProps = nodeProps;
|
|
102
|
+
_this.dragStartMousePosition = {
|
|
99
103
|
x: event.clientX,
|
|
100
104
|
y: event.clientY
|
|
101
105
|
};
|
|
102
|
-
|
|
103
|
-
|
|
106
|
+
var newExpandedKeys = arrDel(expandedKeys, eventKey);
|
|
107
|
+
_this.setState({
|
|
104
108
|
draggingNodeKey: eventKey,
|
|
105
|
-
dragChildrenKeys:
|
|
106
|
-
indent:
|
|
109
|
+
dragChildrenKeys: getDragChildrenKeys(eventKey, keyEntities),
|
|
110
|
+
indent: _this.listRef.current.getIndentWidth()
|
|
107
111
|
});
|
|
108
|
-
|
|
109
|
-
window.addEventListener(
|
|
110
|
-
onDragStart
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
*
|
|
117
|
-
*
|
|
112
|
+
_this.setExpandedKeys(newExpandedKeys);
|
|
113
|
+
window.addEventListener('dragend', _this.onWindowDragEnd);
|
|
114
|
+
onDragStart === null || onDragStart === void 0 || onDragStart({
|
|
115
|
+
event: event,
|
|
116
|
+
node: convertNodePropsToEventData(nodeProps)
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
/**
|
|
120
|
+
* [Legacy] Select handler is smaller than node,
|
|
121
|
+
* so that this will trigger when drag enter node or select handler.
|
|
122
|
+
* This is a little tricky if customize css without padding.
|
|
123
|
+
* Better for use mouse move event to refresh drag state.
|
|
124
|
+
* But let's just keep it to avoid event trigger logic change.
|
|
118
125
|
*/
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
_defineProperty(_assertThisInitialized(_this), "onNodeDragEnter", function (event, nodeProps) {
|
|
127
|
+
var _this$state2 = _this.state,
|
|
128
|
+
expandedKeys = _this$state2.expandedKeys,
|
|
129
|
+
keyEntities = _this$state2.keyEntities,
|
|
130
|
+
dragChildrenKeys = _this$state2.dragChildrenKeys,
|
|
131
|
+
flattenNodes = _this$state2.flattenNodes,
|
|
132
|
+
indent = _this$state2.indent;
|
|
133
|
+
var _this$props = _this.props,
|
|
134
|
+
onDragEnter = _this$props.onDragEnter,
|
|
135
|
+
onExpand = _this$props.onExpand,
|
|
136
|
+
allowDrop = _this$props.allowDrop,
|
|
137
|
+
direction = _this$props.direction;
|
|
138
|
+
var pos = nodeProps.pos,
|
|
139
|
+
eventKey = nodeProps.eventKey;
|
|
140
|
+
|
|
141
|
+
// record the key of node which is latest entered, used in dragleave event.
|
|
142
|
+
if (_this.currentMouseOverDroppableNodeKey !== eventKey) {
|
|
143
|
+
_this.currentMouseOverDroppableNodeKey = eventKey;
|
|
144
|
+
}
|
|
145
|
+
if (!_this.dragNodeProps) {
|
|
146
|
+
_this.resetDragState();
|
|
129
147
|
return;
|
|
130
148
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
keyEntities,
|
|
140
|
-
expandedKeys,
|
|
141
|
-
direction
|
|
142
|
-
);
|
|
149
|
+
var _calcDropPosition = calcDropPosition(event, _this.dragNodeProps, nodeProps, indent, _this.dragStartMousePosition, allowDrop, flattenNodes, keyEntities, expandedKeys, direction),
|
|
150
|
+
dropPosition = _calcDropPosition.dropPosition,
|
|
151
|
+
dropLevelOffset = _calcDropPosition.dropLevelOffset,
|
|
152
|
+
dropTargetKey = _calcDropPosition.dropTargetKey,
|
|
153
|
+
dropContainerKey = _calcDropPosition.dropContainerKey,
|
|
154
|
+
dropTargetPos = _calcDropPosition.dropTargetPos,
|
|
155
|
+
dropAllowed = _calcDropPosition.dropAllowed,
|
|
156
|
+
dragOverNodeKey = _calcDropPosition.dragOverNodeKey;
|
|
143
157
|
if (
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
) {
|
|
148
|
-
|
|
158
|
+
// don't allow drop inside its children
|
|
159
|
+
dragChildrenKeys.includes(dropTargetKey) ||
|
|
160
|
+
// don't allow drop when drop is not allowed caculated by calcDropPosition
|
|
161
|
+
!dropAllowed) {
|
|
162
|
+
_this.resetDragState();
|
|
149
163
|
return;
|
|
150
164
|
}
|
|
151
|
-
|
|
152
|
-
|
|
165
|
+
|
|
166
|
+
// Side effect for delay drag
|
|
167
|
+
if (!_this.delayedDragEnterLogic) {
|
|
168
|
+
_this.delayedDragEnterLogic = {};
|
|
153
169
|
}
|
|
154
|
-
Object.keys(
|
|
155
|
-
clearTimeout(
|
|
170
|
+
Object.keys(_this.delayedDragEnterLogic).forEach(function (key) {
|
|
171
|
+
clearTimeout(_this.delayedDragEnterLogic[key]);
|
|
156
172
|
});
|
|
157
|
-
if (
|
|
173
|
+
if (_this.dragNodeProps.eventKey !== nodeProps.eventKey) {
|
|
174
|
+
// hoist expand logic here
|
|
175
|
+
// since if logic is on the bottom
|
|
176
|
+
// it will be blocked by abstract dragover node check
|
|
177
|
+
// => if you dragenter from top, you mouse will still be consider as in the top node
|
|
158
178
|
event.persist();
|
|
159
|
-
|
|
160
|
-
if (
|
|
179
|
+
_this.delayedDragEnterLogic[pos] = window.setTimeout(function () {
|
|
180
|
+
if (_this.state.draggingNodeKey === null) {
|
|
161
181
|
return;
|
|
162
182
|
}
|
|
163
|
-
|
|
164
|
-
|
|
183
|
+
var newExpandedKeys = _toConsumableArray(expandedKeys);
|
|
184
|
+
var entity = getEntity(keyEntities, nodeProps.eventKey);
|
|
165
185
|
if (entity && (entity.children || []).length) {
|
|
166
|
-
newExpandedKeys =
|
|
186
|
+
newExpandedKeys = arrAdd(expandedKeys, nodeProps.eventKey);
|
|
167
187
|
}
|
|
168
|
-
if (!(
|
|
169
|
-
|
|
188
|
+
if (!Object.prototype.hasOwnProperty.call(_this.props, 'expandedKeys')) {
|
|
189
|
+
_this.setExpandedKeys(newExpandedKeys);
|
|
170
190
|
}
|
|
171
|
-
onExpand
|
|
172
|
-
node:
|
|
191
|
+
onExpand === null || onExpand === void 0 || onExpand(newExpandedKeys, {
|
|
192
|
+
node: convertNodePropsToEventData(nodeProps),
|
|
173
193
|
expanded: true,
|
|
174
194
|
nativeEvent: event.nativeEvent
|
|
175
195
|
});
|
|
176
196
|
}, 800);
|
|
177
197
|
}
|
|
178
|
-
|
|
179
|
-
|
|
198
|
+
|
|
199
|
+
// Skip if drag node is self
|
|
200
|
+
if (_this.dragNodeProps.eventKey === dropTargetKey && dropLevelOffset === 0) {
|
|
201
|
+
_this.resetDragState();
|
|
180
202
|
return;
|
|
181
203
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
204
|
+
|
|
205
|
+
// Update drag over node and drag state
|
|
206
|
+
_this.setState({
|
|
207
|
+
dragOverNodeKey: dragOverNodeKey,
|
|
208
|
+
dropPosition: dropPosition,
|
|
209
|
+
dropLevelOffset: dropLevelOffset,
|
|
210
|
+
dropTargetKey: dropTargetKey,
|
|
211
|
+
dropContainerKey: dropContainerKey,
|
|
212
|
+
dropTargetPos: dropTargetPos,
|
|
213
|
+
dropAllowed: dropAllowed
|
|
190
214
|
});
|
|
191
|
-
onDragEnter
|
|
192
|
-
event,
|
|
193
|
-
node:
|
|
194
|
-
expandedKeys
|
|
215
|
+
onDragEnter === null || onDragEnter === void 0 || onDragEnter({
|
|
216
|
+
event: event,
|
|
217
|
+
node: convertNodePropsToEventData(nodeProps),
|
|
218
|
+
expandedKeys: expandedKeys
|
|
195
219
|
});
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
220
|
+
});
|
|
221
|
+
_defineProperty(_assertThisInitialized(_this), "onNodeDragOver", function (event, nodeProps) {
|
|
222
|
+
var _this$state3 = _this.state,
|
|
223
|
+
dragChildrenKeys = _this$state3.dragChildrenKeys,
|
|
224
|
+
flattenNodes = _this$state3.flattenNodes,
|
|
225
|
+
keyEntities = _this$state3.keyEntities,
|
|
226
|
+
expandedKeys = _this$state3.expandedKeys,
|
|
227
|
+
indent = _this$state3.indent;
|
|
228
|
+
var _this$props2 = _this.props,
|
|
229
|
+
onDragOver = _this$props2.onDragOver,
|
|
230
|
+
allowDrop = _this$props2.allowDrop,
|
|
231
|
+
direction = _this$props2.direction;
|
|
232
|
+
if (!_this.dragNodeProps) {
|
|
202
233
|
return;
|
|
203
234
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
);
|
|
216
|
-
if (dragChildrenKeys.indexOf(dropTargetKey) !== -1 || !dropAllowed) {
|
|
235
|
+
var _calcDropPosition2 = calcDropPosition(event, _this.dragNodeProps, nodeProps, indent, _this.dragStartMousePosition, allowDrop, flattenNodes, keyEntities, expandedKeys, direction),
|
|
236
|
+
dropPosition = _calcDropPosition2.dropPosition,
|
|
237
|
+
dropLevelOffset = _calcDropPosition2.dropLevelOffset,
|
|
238
|
+
dropTargetKey = _calcDropPosition2.dropTargetKey,
|
|
239
|
+
dropContainerKey = _calcDropPosition2.dropContainerKey,
|
|
240
|
+
dropTargetPos = _calcDropPosition2.dropTargetPos,
|
|
241
|
+
dropAllowed = _calcDropPosition2.dropAllowed,
|
|
242
|
+
dragOverNodeKey = _calcDropPosition2.dragOverNodeKey;
|
|
243
|
+
if (dragChildrenKeys.includes(dropTargetKey) || !dropAllowed) {
|
|
244
|
+
// don't allow drop inside its children
|
|
245
|
+
// don't allow drop when drop is not allowed calculated by calcDropPosition
|
|
217
246
|
return;
|
|
218
247
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
248
|
+
|
|
249
|
+
// Update drag position
|
|
250
|
+
|
|
251
|
+
if (_this.dragNodeProps.eventKey === dropTargetKey && dropLevelOffset === 0) {
|
|
252
|
+
if (!(_this.state.dropPosition === null && _this.state.dropLevelOffset === null && _this.state.dropTargetKey === null && _this.state.dropContainerKey === null && _this.state.dropTargetPos === null && _this.state.dropAllowed === false && _this.state.dragOverNodeKey === null)) {
|
|
253
|
+
_this.resetDragState();
|
|
222
254
|
}
|
|
223
|
-
} else if (!(dropPosition ===
|
|
224
|
-
|
|
225
|
-
dropPosition,
|
|
226
|
-
dropLevelOffset,
|
|
227
|
-
dropTargetKey,
|
|
228
|
-
dropContainerKey,
|
|
229
|
-
dropTargetPos,
|
|
230
|
-
dropAllowed,
|
|
231
|
-
dragOverNodeKey
|
|
255
|
+
} else if (!(dropPosition === _this.state.dropPosition && dropLevelOffset === _this.state.dropLevelOffset && dropTargetKey === _this.state.dropTargetKey && dropContainerKey === _this.state.dropContainerKey && dropTargetPos === _this.state.dropTargetPos && dropAllowed === _this.state.dropAllowed && dragOverNodeKey === _this.state.dragOverNodeKey)) {
|
|
256
|
+
_this.setState({
|
|
257
|
+
dropPosition: dropPosition,
|
|
258
|
+
dropLevelOffset: dropLevelOffset,
|
|
259
|
+
dropTargetKey: dropTargetKey,
|
|
260
|
+
dropContainerKey: dropContainerKey,
|
|
261
|
+
dropTargetPos: dropTargetPos,
|
|
262
|
+
dropAllowed: dropAllowed,
|
|
263
|
+
dragOverNodeKey: dragOverNodeKey
|
|
232
264
|
});
|
|
233
265
|
}
|
|
234
|
-
onDragOver
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
266
|
+
onDragOver === null || onDragOver === void 0 || onDragOver({
|
|
267
|
+
event: event,
|
|
268
|
+
node: convertNodePropsToEventData(nodeProps)
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
_defineProperty(_assertThisInitialized(_this), "onNodeDragLeave", function (event, nodeProps) {
|
|
272
|
+
// if it is outside the droppable area
|
|
273
|
+
// currentMouseOverDroppableNodeKey will be updated in dragenter event when into another droppable receiver.
|
|
274
|
+
if (_this.currentMouseOverDroppableNodeKey === nodeProps.eventKey && !event.currentTarget.contains(event.relatedTarget)) {
|
|
275
|
+
_this.resetDragState();
|
|
276
|
+
_this.currentMouseOverDroppableNodeKey = null;
|
|
240
277
|
}
|
|
241
|
-
|
|
242
|
-
onDragLeave
|
|
243
|
-
|
|
278
|
+
var onDragLeave = _this.props.onDragLeave;
|
|
279
|
+
onDragLeave === null || onDragLeave === void 0 || onDragLeave({
|
|
280
|
+
event: event,
|
|
281
|
+
node: convertNodePropsToEventData(nodeProps)
|
|
282
|
+
});
|
|
283
|
+
});
|
|
244
284
|
// since stopPropagation() is called in treeNode
|
|
245
285
|
// if onWindowDrag is called, whice means state is keeped, drag state should be cleared
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
window.removeEventListener(
|
|
249
|
-
};
|
|
286
|
+
_defineProperty(_assertThisInitialized(_this), "onWindowDragEnd", function (event) {
|
|
287
|
+
_this.onNodeDragEnd(event, null, true);
|
|
288
|
+
window.removeEventListener('dragend', _this.onWindowDragEnd);
|
|
289
|
+
});
|
|
250
290
|
// if onNodeDragEnd is called, onWindowDragEnd won't be called since stopPropagation() is called
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
291
|
+
_defineProperty(_assertThisInitialized(_this), "onNodeDragEnd", function (event, nodeProps) {
|
|
292
|
+
var onDragEnd = _this.props.onDragEnd;
|
|
293
|
+
_this.setState({
|
|
254
294
|
dragOverNodeKey: null
|
|
255
295
|
});
|
|
256
|
-
|
|
257
|
-
onDragEnd
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
296
|
+
_this.cleanDragState();
|
|
297
|
+
onDragEnd === null || onDragEnd === void 0 || onDragEnd({
|
|
298
|
+
event: event,
|
|
299
|
+
node: convertNodePropsToEventData(nodeProps)
|
|
300
|
+
});
|
|
301
|
+
_this.dragNodeProps = null;
|
|
302
|
+
window.removeEventListener('dragend', _this.onWindowDragEnd);
|
|
303
|
+
});
|
|
304
|
+
_defineProperty(_assertThisInitialized(_this), "onNodeDrop", function (event, _) {
|
|
305
|
+
var _this$getActiveItem;
|
|
306
|
+
var outsideTree = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
307
|
+
var _this$state4 = _this.state,
|
|
308
|
+
dragChildrenKeys = _this$state4.dragChildrenKeys,
|
|
309
|
+
dropPosition = _this$state4.dropPosition,
|
|
310
|
+
dropTargetKey = _this$state4.dropTargetKey,
|
|
311
|
+
dropTargetPos = _this$state4.dropTargetPos,
|
|
312
|
+
dropAllowed = _this$state4.dropAllowed;
|
|
263
313
|
if (!dropAllowed) {
|
|
264
314
|
return;
|
|
265
315
|
}
|
|
266
|
-
|
|
267
|
-
|
|
316
|
+
var onDrop = _this.props.onDrop;
|
|
317
|
+
_this.setState({
|
|
268
318
|
dragOverNodeKey: null
|
|
269
319
|
});
|
|
270
|
-
|
|
320
|
+
_this.cleanDragState();
|
|
271
321
|
if (dropTargetKey === null) {
|
|
272
322
|
return;
|
|
273
323
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
dragNodesKeys: [this.dragNode.props.eventKey].concat(dragChildrenKeys),
|
|
324
|
+
var abstractDropNodeProps = _objectSpread(_objectSpread({}, getTreeNodeProps(dropTargetKey, _this.getTreeNodeRequiredProps())), {}, {
|
|
325
|
+
active: ((_this$getActiveItem = _this.getActiveItem()) === null || _this$getActiveItem === void 0 ? void 0 : _this$getActiveItem.key) === dropTargetKey,
|
|
326
|
+
data: getEntity(_this.state.keyEntities, dropTargetKey).node
|
|
327
|
+
});
|
|
328
|
+
var dropToChild = dragChildrenKeys.includes(dropTargetKey);
|
|
329
|
+
warning(!dropToChild, 'Can not drop to dragNodes children node. This is a bug of rc-tree. Please report an issue.');
|
|
330
|
+
var posArr = posToArr(dropTargetPos);
|
|
331
|
+
var dropResult = {
|
|
332
|
+
event: event,
|
|
333
|
+
node: convertNodePropsToEventData(abstractDropNodeProps),
|
|
334
|
+
dragNode: _this.dragNodeProps ? convertNodePropsToEventData(_this.dragNodeProps) : null,
|
|
335
|
+
dragNodesKeys: [_this.dragNodeProps.eventKey].concat(dragChildrenKeys),
|
|
287
336
|
dropToGap: dropPosition !== 0,
|
|
288
337
|
dropPosition: dropPosition + Number(posArr[posArr.length - 1])
|
|
289
338
|
};
|
|
290
339
|
if (!outsideTree) {
|
|
291
|
-
onDrop
|
|
340
|
+
onDrop === null || onDrop === void 0 || onDrop(dropResult);
|
|
292
341
|
}
|
|
293
|
-
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
|
|
342
|
+
_this.dragNodeProps = null;
|
|
343
|
+
});
|
|
344
|
+
_defineProperty(_assertThisInitialized(_this), "cleanDragState", function () {
|
|
345
|
+
var draggingNodeKey = _this.state.draggingNodeKey;
|
|
297
346
|
if (draggingNodeKey !== null) {
|
|
298
|
-
|
|
347
|
+
_this.setState({
|
|
299
348
|
draggingNodeKey: null,
|
|
300
349
|
dropPosition: null,
|
|
301
350
|
dropContainerKey: null,
|
|
@@ -305,171 +354,292 @@ var RCTree = class extends import_react.Component {
|
|
|
305
354
|
dragOverNodeKey: null
|
|
306
355
|
});
|
|
307
356
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
357
|
+
_this.dragStartMousePosition = null;
|
|
358
|
+
_this.currentMouseOverDroppableNodeKey = null;
|
|
359
|
+
});
|
|
360
|
+
_defineProperty(_assertThisInitialized(_this), "triggerExpandActionExpand", function (e, treeNode) {
|
|
361
|
+
var _this$state5 = _this.state,
|
|
362
|
+
expandedKeys = _this$state5.expandedKeys,
|
|
363
|
+
flattenNodes = _this$state5.flattenNodes;
|
|
364
|
+
var expanded = treeNode.expanded,
|
|
365
|
+
key = treeNode.key,
|
|
366
|
+
isLeaf = treeNode.isLeaf;
|
|
367
|
+
if (isLeaf || e.shiftKey || e.metaKey || e.ctrlKey) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
var node = flattenNodes.filter(function (nodeItem) {
|
|
371
|
+
return nodeItem.key === key;
|
|
372
|
+
})[0];
|
|
373
|
+
var eventNode = convertNodePropsToEventData(_objectSpread(_objectSpread({}, getTreeNodeProps(key, _this.getTreeNodeRequiredProps())), {}, {
|
|
374
|
+
data: node.data
|
|
375
|
+
}));
|
|
376
|
+
_this.setExpandedKeys(expanded ? arrDel(expandedKeys, key) : arrAdd(expandedKeys, key));
|
|
377
|
+
_this.onNodeExpand(e, eventNode);
|
|
378
|
+
});
|
|
379
|
+
_defineProperty(_assertThisInitialized(_this), "onNodeClick", function (e, treeNode) {
|
|
380
|
+
var _this$props3 = _this.props,
|
|
381
|
+
onClick = _this$props3.onClick,
|
|
382
|
+
expandAction = _this$props3.expandAction;
|
|
383
|
+
if (expandAction === 'click') {
|
|
384
|
+
_this.triggerExpandActionExpand(e, treeNode);
|
|
385
|
+
}
|
|
386
|
+
onClick === null || onClick === void 0 || onClick(e, treeNode);
|
|
387
|
+
});
|
|
388
|
+
_defineProperty(_assertThisInitialized(_this), "onNodeDoubleClick", function (e, treeNode) {
|
|
389
|
+
var _this$props4 = _this.props,
|
|
390
|
+
onDoubleClick = _this$props4.onDoubleClick,
|
|
391
|
+
expandAction = _this$props4.expandAction;
|
|
392
|
+
if (expandAction === 'doubleClick') {
|
|
393
|
+
_this.triggerExpandActionExpand(e, treeNode);
|
|
394
|
+
}
|
|
395
|
+
onDoubleClick === null || onDoubleClick === void 0 || onDoubleClick(e, treeNode);
|
|
396
|
+
});
|
|
397
|
+
_defineProperty(_assertThisInitialized(_this), "onNodeSelect", function (e, treeNode) {
|
|
398
|
+
var selectedKeys = _this.state.selectedKeys;
|
|
399
|
+
var _this$state6 = _this.state,
|
|
400
|
+
keyEntities = _this$state6.keyEntities,
|
|
401
|
+
fieldNames = _this$state6.fieldNames;
|
|
402
|
+
var _this$props5 = _this.props,
|
|
403
|
+
onSelect = _this$props5.onSelect,
|
|
404
|
+
multiple = _this$props5.multiple;
|
|
405
|
+
var selected = treeNode.selected;
|
|
406
|
+
var key = treeNode[fieldNames.key];
|
|
407
|
+
var targetSelected = !selected;
|
|
408
|
+
|
|
409
|
+
// Update selected keys
|
|
326
410
|
if (!targetSelected) {
|
|
327
|
-
selectedKeys =
|
|
411
|
+
selectedKeys = arrDel(selectedKeys, key);
|
|
328
412
|
} else if (!multiple) {
|
|
329
413
|
selectedKeys = [key];
|
|
330
414
|
} else {
|
|
331
|
-
selectedKeys =
|
|
415
|
+
selectedKeys = arrAdd(selectedKeys, key);
|
|
332
416
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
417
|
+
|
|
418
|
+
// [Legacy] Not found related usage in doc or upper libs
|
|
419
|
+
var selectedNodes = selectedKeys.map(function (selectedKey) {
|
|
420
|
+
var entity = getEntity(keyEntities, selectedKey);
|
|
421
|
+
return entity ? entity.node : null;
|
|
422
|
+
}).filter(Boolean);
|
|
423
|
+
_this.setUncontrolledState({
|
|
424
|
+
selectedKeys: selectedKeys
|
|
425
|
+
});
|
|
426
|
+
onSelect === null || onSelect === void 0 || onSelect(selectedKeys, {
|
|
427
|
+
event: 'select',
|
|
343
428
|
selected: targetSelected,
|
|
344
429
|
node: treeNode,
|
|
345
|
-
selectedNodes,
|
|
430
|
+
selectedNodes: selectedNodes,
|
|
346
431
|
nativeEvent: e.nativeEvent
|
|
347
432
|
});
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
433
|
+
});
|
|
434
|
+
_defineProperty(_assertThisInitialized(_this), "onNodeCheck", function (e, treeNode, checked) {
|
|
435
|
+
var _this$state7 = _this.state,
|
|
436
|
+
keyEntities = _this$state7.keyEntities,
|
|
437
|
+
oriCheckedKeys = _this$state7.checkedKeys,
|
|
438
|
+
oriHalfCheckedKeys = _this$state7.halfCheckedKeys;
|
|
439
|
+
var _this$props6 = _this.props,
|
|
440
|
+
checkStrictly = _this$props6.checkStrictly,
|
|
441
|
+
onCheck = _this$props6.onCheck;
|
|
442
|
+
var key = treeNode.key;
|
|
443
|
+
|
|
444
|
+
// Prepare trigger arguments
|
|
445
|
+
var checkedObj;
|
|
446
|
+
var eventObj = {
|
|
447
|
+
event: 'check',
|
|
356
448
|
node: treeNode,
|
|
357
|
-
checked,
|
|
449
|
+
checked: checked,
|
|
358
450
|
nativeEvent: e.nativeEvent
|
|
359
451
|
};
|
|
360
452
|
if (checkStrictly) {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
checkedObj = {
|
|
364
|
-
|
|
365
|
-
|
|
453
|
+
var checkedKeys = checked ? arrAdd(oriCheckedKeys, key) : arrDel(oriCheckedKeys, key);
|
|
454
|
+
var halfCheckedKeys = arrDel(oriHalfCheckedKeys, key);
|
|
455
|
+
checkedObj = {
|
|
456
|
+
checked: checkedKeys,
|
|
457
|
+
halfChecked: halfCheckedKeys
|
|
458
|
+
};
|
|
459
|
+
eventObj.checkedNodes = checkedKeys.map(function (checkedKey) {
|
|
460
|
+
return getEntity(keyEntities, checkedKey);
|
|
461
|
+
}).filter(Boolean).map(function (entity) {
|
|
462
|
+
return entity.node;
|
|
463
|
+
});
|
|
464
|
+
_this.setUncontrolledState({
|
|
465
|
+
checkedKeys: checkedKeys
|
|
466
|
+
});
|
|
366
467
|
} else {
|
|
367
|
-
|
|
468
|
+
// Always fill first
|
|
469
|
+
var _conductCheck = conductCheck([].concat(_toConsumableArray(oriCheckedKeys), [key]), true, keyEntities),
|
|
470
|
+
_checkedKeys = _conductCheck.checkedKeys,
|
|
471
|
+
_halfCheckedKeys = _conductCheck.halfCheckedKeys;
|
|
472
|
+
|
|
473
|
+
// If remove, we do it again to correction
|
|
368
474
|
if (!checked) {
|
|
369
|
-
|
|
475
|
+
var keySet = new Set(_checkedKeys);
|
|
370
476
|
keySet.delete(key);
|
|
371
|
-
|
|
477
|
+
var _conductCheck2 = conductCheck(Array.from(keySet), {
|
|
478
|
+
checked: false,
|
|
479
|
+
halfCheckedKeys: _halfCheckedKeys
|
|
480
|
+
}, keyEntities);
|
|
481
|
+
_checkedKeys = _conductCheck2.checkedKeys;
|
|
482
|
+
_halfCheckedKeys = _conductCheck2.halfCheckedKeys;
|
|
372
483
|
}
|
|
373
|
-
checkedObj =
|
|
484
|
+
checkedObj = _checkedKeys;
|
|
485
|
+
|
|
486
|
+
// [Legacy] This is used for `rc-tree-select`
|
|
374
487
|
eventObj.checkedNodes = [];
|
|
375
488
|
eventObj.checkedNodesPositions = [];
|
|
376
|
-
eventObj.halfCheckedKeys =
|
|
377
|
-
|
|
378
|
-
|
|
489
|
+
eventObj.halfCheckedKeys = _halfCheckedKeys;
|
|
490
|
+
_checkedKeys.forEach(function (checkedKey) {
|
|
491
|
+
var entity = getEntity(keyEntities, checkedKey);
|
|
379
492
|
if (!entity) {
|
|
380
493
|
return;
|
|
381
494
|
}
|
|
382
|
-
|
|
495
|
+
var node = entity.node,
|
|
496
|
+
pos = entity.pos;
|
|
383
497
|
eventObj.checkedNodes.push(node);
|
|
384
|
-
eventObj.checkedNodesPositions.push({
|
|
498
|
+
eventObj.checkedNodesPositions.push({
|
|
499
|
+
node: node,
|
|
500
|
+
pos: pos
|
|
501
|
+
});
|
|
385
502
|
});
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
503
|
+
_this.setUncontrolledState({
|
|
504
|
+
checkedKeys: _checkedKeys
|
|
505
|
+
}, false, {
|
|
506
|
+
halfCheckedKeys: _halfCheckedKeys
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
onCheck === null || onCheck === void 0 || onCheck(checkedObj, eventObj);
|
|
510
|
+
});
|
|
511
|
+
_defineProperty(_assertThisInitialized(_this), "onNodeLoad", function (treeNode) {
|
|
512
|
+
var _entity$children;
|
|
513
|
+
var key = treeNode.key;
|
|
514
|
+
var keyEntities = _this.state.keyEntities;
|
|
515
|
+
|
|
516
|
+
// Skip if has children already
|
|
517
|
+
var entity = getEntity(keyEntities, key);
|
|
518
|
+
if (entity !== null && entity !== void 0 && (_entity$children = entity.children) !== null && _entity$children !== void 0 && _entity$children.length) {
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
var loadPromise = new Promise(function (resolve, reject) {
|
|
522
|
+
// We need to get the latest state of loading/loaded keys
|
|
523
|
+
_this.setState(function (_ref) {
|
|
524
|
+
var _ref$loadedKeys = _ref.loadedKeys,
|
|
525
|
+
loadedKeys = _ref$loadedKeys === void 0 ? [] : _ref$loadedKeys,
|
|
526
|
+
_ref$loadingKeys = _ref.loadingKeys,
|
|
527
|
+
loadingKeys = _ref$loadingKeys === void 0 ? [] : _ref$loadingKeys;
|
|
528
|
+
var _this$props7 = _this.props,
|
|
529
|
+
loadData = _this$props7.loadData,
|
|
530
|
+
onLoad = _this$props7.onLoad;
|
|
531
|
+
if (!loadData || loadedKeys.includes(key) || loadingKeys.includes(key)) {
|
|
404
532
|
return null;
|
|
405
533
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
534
|
+
|
|
535
|
+
// Process load data
|
|
536
|
+
var promise = loadData(treeNode);
|
|
537
|
+
promise.then(function () {
|
|
538
|
+
var currentLoadedKeys = _this.state.loadedKeys;
|
|
539
|
+
var newLoadedKeys = arrAdd(currentLoadedKeys, key);
|
|
540
|
+
|
|
541
|
+
// onLoad should trigger before internal setState to avoid `loadData` trigger twice.
|
|
542
|
+
// https://github.com/ant-design/ant-design/issues/12464
|
|
543
|
+
onLoad === null || onLoad === void 0 || onLoad(newLoadedKeys, {
|
|
544
|
+
event: 'load',
|
|
412
545
|
node: treeNode
|
|
413
546
|
});
|
|
414
|
-
|
|
547
|
+
_this.setUncontrolledState({
|
|
415
548
|
loadedKeys: newLoadedKeys
|
|
416
549
|
});
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
550
|
+
_this.setState(function (prevState) {
|
|
551
|
+
return {
|
|
552
|
+
loadingKeys: arrDel(prevState.loadingKeys, key)
|
|
553
|
+
};
|
|
554
|
+
});
|
|
420
555
|
resolve();
|
|
421
|
-
}).catch((e)
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
556
|
+
}).catch(function (e) {
|
|
557
|
+
_this.setState(function (prevState) {
|
|
558
|
+
return {
|
|
559
|
+
loadingKeys: arrDel(prevState.loadingKeys, key)
|
|
560
|
+
};
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
// If exceed max retry times, we give up retry
|
|
564
|
+
_this.loadingRetryTimes[key] = (_this.loadingRetryTimes[key] || 0) + 1;
|
|
565
|
+
if (_this.loadingRetryTimes[key] >= MAX_RETRY_TIMES) {
|
|
566
|
+
var currentLoadedKeys = _this.state.loadedKeys;
|
|
567
|
+
warning(false, 'Retry for `loadData` many times but still failed. No more retry.');
|
|
568
|
+
_this.setUncontrolledState({
|
|
569
|
+
loadedKeys: arrAdd(currentLoadedKeys, key)
|
|
431
570
|
});
|
|
432
571
|
resolve();
|
|
433
572
|
}
|
|
434
573
|
reject(e);
|
|
435
574
|
});
|
|
436
575
|
return {
|
|
437
|
-
loadingKeys:
|
|
576
|
+
loadingKeys: arrAdd(loadingKeys, key)
|
|
438
577
|
};
|
|
439
578
|
});
|
|
440
579
|
});
|
|
441
|
-
|
|
580
|
+
|
|
581
|
+
// Not care warning if we ignore this
|
|
582
|
+
loadPromise.catch(function () {
|
|
583
|
+
//
|
|
442
584
|
});
|
|
443
585
|
return loadPromise;
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
onMouseEnter
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
586
|
+
});
|
|
587
|
+
_defineProperty(_assertThisInitialized(_this), "onNodeMouseEnter", function (event, node) {
|
|
588
|
+
var onMouseEnter = _this.props.onMouseEnter;
|
|
589
|
+
onMouseEnter === null || onMouseEnter === void 0 || onMouseEnter({
|
|
590
|
+
event: event,
|
|
591
|
+
node: node
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
_defineProperty(_assertThisInitialized(_this), "onNodeMouseLeave", function (event, node) {
|
|
595
|
+
var onMouseLeave = _this.props.onMouseLeave;
|
|
596
|
+
onMouseLeave === null || onMouseLeave === void 0 || onMouseLeave({
|
|
597
|
+
event: event,
|
|
598
|
+
node: node
|
|
599
|
+
});
|
|
600
|
+
});
|
|
601
|
+
_defineProperty(_assertThisInitialized(_this), "onNodeContextMenu", function (event, node) {
|
|
602
|
+
var onRightClick = _this.props.onRightClick;
|
|
455
603
|
if (onRightClick) {
|
|
456
604
|
event.preventDefault();
|
|
457
|
-
onRightClick({
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
605
|
+
onRightClick({
|
|
606
|
+
event: event,
|
|
607
|
+
node: node
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
_defineProperty(_assertThisInitialized(_this), "onFocus", function () {
|
|
612
|
+
var onFocus = _this.props.onFocus;
|
|
613
|
+
_this.setState({
|
|
614
|
+
focused: true
|
|
615
|
+
});
|
|
616
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
617
|
+
args[_key2] = arguments[_key2];
|
|
618
|
+
}
|
|
619
|
+
onFocus === null || onFocus === void 0 || onFocus.apply(void 0, args);
|
|
620
|
+
});
|
|
621
|
+
_defineProperty(_assertThisInitialized(_this), "onBlur", function () {
|
|
622
|
+
var onBlur = _this.props.onBlur;
|
|
623
|
+
_this.setState({
|
|
624
|
+
focused: false
|
|
625
|
+
});
|
|
626
|
+
_this.onActiveChange(null);
|
|
627
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
628
|
+
args[_key3] = arguments[_key3];
|
|
629
|
+
}
|
|
630
|
+
onBlur === null || onBlur === void 0 || onBlur.apply(void 0, args);
|
|
631
|
+
});
|
|
632
|
+
_defineProperty(_assertThisInitialized(_this), "getTreeNodeRequiredProps", function () {
|
|
633
|
+
var _this$state8 = _this.state,
|
|
634
|
+
expandedKeys = _this$state8.expandedKeys,
|
|
635
|
+
selectedKeys = _this$state8.selectedKeys,
|
|
636
|
+
loadedKeys = _this$state8.loadedKeys,
|
|
637
|
+
loadingKeys = _this$state8.loadingKeys,
|
|
638
|
+
checkedKeys = _this$state8.checkedKeys,
|
|
639
|
+
halfCheckedKeys = _this$state8.halfCheckedKeys,
|
|
640
|
+
dragOverNodeKey = _this$state8.dragOverNodeKey,
|
|
641
|
+
dropPosition = _this$state8.dropPosition,
|
|
642
|
+
keyEntities = _this$state8.keyEntities;
|
|
473
643
|
return {
|
|
474
644
|
expandedKeys: expandedKeys || [],
|
|
475
645
|
selectedKeys: selectedKeys || [],
|
|
@@ -477,178 +647,224 @@ var RCTree = class extends import_react.Component {
|
|
|
477
647
|
loadingKeys: loadingKeys || [],
|
|
478
648
|
checkedKeys: checkedKeys || [],
|
|
479
649
|
halfCheckedKeys: halfCheckedKeys || [],
|
|
480
|
-
dragOverNodeKey,
|
|
481
|
-
dropPosition,
|
|
482
|
-
keyEntities
|
|
650
|
+
dragOverNodeKey: dragOverNodeKey,
|
|
651
|
+
dropPosition: dropPosition,
|
|
652
|
+
keyEntities: keyEntities
|
|
483
653
|
};
|
|
484
|
-
};
|
|
654
|
+
});
|
|
485
655
|
// =========================== Expanded ===========================
|
|
486
656
|
/** Set uncontrolled `expandedKeys`. This will also auto update `flattenNodes`. */
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
657
|
+
_defineProperty(_assertThisInitialized(_this), "setExpandedKeys", function (expandedKeys) {
|
|
658
|
+
var _this$state9 = _this.state,
|
|
659
|
+
treeData = _this$state9.treeData,
|
|
660
|
+
fieldNames = _this$state9.fieldNames;
|
|
661
|
+
var flattenNodes = flattenTreeData(treeData, expandedKeys, fieldNames);
|
|
662
|
+
_this.setUncontrolledState({
|
|
663
|
+
expandedKeys: expandedKeys,
|
|
664
|
+
flattenNodes: flattenNodes
|
|
665
|
+
}, true);
|
|
666
|
+
});
|
|
667
|
+
_defineProperty(_assertThisInitialized(_this), "onNodeExpand", function (e, treeNode) {
|
|
668
|
+
var expandedKeys = _this.state.expandedKeys;
|
|
669
|
+
var _this$state10 = _this.state,
|
|
670
|
+
listChanging = _this$state10.listChanging,
|
|
671
|
+
fieldNames = _this$state10.fieldNames;
|
|
672
|
+
var _this$props8 = _this.props,
|
|
673
|
+
onExpand = _this$props8.onExpand,
|
|
674
|
+
loadData = _this$props8.loadData;
|
|
675
|
+
var expanded = treeNode.expanded;
|
|
676
|
+
var key = treeNode[fieldNames.key];
|
|
677
|
+
|
|
678
|
+
// Do nothing when motion is in progress
|
|
508
679
|
if (listChanging) {
|
|
509
680
|
return;
|
|
510
681
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
this.setExpandedKeys(expandedKeys);
|
|
520
|
-
onExpand == null ? void 0 : onExpand(expandedKeys, {
|
|
682
|
+
|
|
683
|
+
// Update selected keys
|
|
684
|
+
var certain = expandedKeys.includes(key);
|
|
685
|
+
var targetExpanded = !expanded;
|
|
686
|
+
warning(expanded && certain || !expanded && !certain, 'Expand state not sync with index check');
|
|
687
|
+
expandedKeys = targetExpanded ? arrAdd(expandedKeys, key) : arrDel(expandedKeys, key);
|
|
688
|
+
_this.setExpandedKeys(expandedKeys);
|
|
689
|
+
onExpand === null || onExpand === void 0 || onExpand(expandedKeys, {
|
|
521
690
|
node: treeNode,
|
|
522
691
|
expanded: targetExpanded,
|
|
523
692
|
nativeEvent: e.nativeEvent
|
|
524
693
|
});
|
|
694
|
+
|
|
695
|
+
// Async Load data
|
|
525
696
|
if (targetExpanded && loadData) {
|
|
526
|
-
|
|
697
|
+
var loadPromise = _this.onNodeLoad(treeNode);
|
|
527
698
|
if (loadPromise) {
|
|
528
|
-
loadPromise.then(()
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
699
|
+
loadPromise.then(function () {
|
|
700
|
+
// [Legacy] Refresh logic
|
|
701
|
+
var newFlattenTreeData = flattenTreeData(_this.state.treeData, expandedKeys, fieldNames);
|
|
702
|
+
_this.setUncontrolledState({
|
|
703
|
+
flattenNodes: newFlattenTreeData
|
|
704
|
+
});
|
|
705
|
+
}).catch(function () {
|
|
706
|
+
var currentExpandedKeys = _this.state.expandedKeys;
|
|
707
|
+
var expandedKeysToRestore = arrDel(currentExpandedKeys, key);
|
|
708
|
+
_this.setExpandedKeys(expandedKeysToRestore);
|
|
535
709
|
});
|
|
536
710
|
}
|
|
537
711
|
}
|
|
538
|
-
};
|
|
539
|
-
|
|
540
|
-
|
|
712
|
+
});
|
|
713
|
+
_defineProperty(_assertThisInitialized(_this), "onListChangeStart", function () {
|
|
714
|
+
_this.setUncontrolledState({
|
|
541
715
|
listChanging: true
|
|
542
716
|
});
|
|
543
|
-
};
|
|
544
|
-
|
|
545
|
-
setTimeout(()
|
|
546
|
-
|
|
717
|
+
});
|
|
718
|
+
_defineProperty(_assertThisInitialized(_this), "onListChangeEnd", function () {
|
|
719
|
+
setTimeout(function () {
|
|
720
|
+
_this.setUncontrolledState({
|
|
547
721
|
listChanging: false
|
|
548
722
|
});
|
|
549
723
|
});
|
|
550
|
-
};
|
|
724
|
+
});
|
|
551
725
|
// =========================== Keyboard ===========================
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
726
|
+
_defineProperty(_assertThisInitialized(_this), "onActiveChange", function (newActiveKey) {
|
|
727
|
+
var activeKey = _this.state.activeKey;
|
|
728
|
+
var _this$props9 = _this.props,
|
|
729
|
+
onActiveChange = _this$props9.onActiveChange,
|
|
730
|
+
_this$props9$itemScro = _this$props9.itemScrollOffset,
|
|
731
|
+
itemScrollOffset = _this$props9$itemScro === void 0 ? 0 : _this$props9$itemScro;
|
|
555
732
|
if (activeKey === newActiveKey) {
|
|
556
733
|
return;
|
|
557
734
|
}
|
|
558
|
-
|
|
735
|
+
_this.setState({
|
|
736
|
+
activeKey: newActiveKey
|
|
737
|
+
});
|
|
559
738
|
if (newActiveKey !== null) {
|
|
560
|
-
|
|
739
|
+
_this.scrollTo({
|
|
740
|
+
key: newActiveKey,
|
|
741
|
+
offset: itemScrollOffset
|
|
742
|
+
});
|
|
561
743
|
}
|
|
562
|
-
onActiveChange
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
|
|
744
|
+
onActiveChange === null || onActiveChange === void 0 || onActiveChange(newActiveKey);
|
|
745
|
+
});
|
|
746
|
+
_defineProperty(_assertThisInitialized(_this), "getActiveItem", function () {
|
|
747
|
+
var _this$state11 = _this.state,
|
|
748
|
+
activeKey = _this$state11.activeKey,
|
|
749
|
+
flattenNodes = _this$state11.flattenNodes;
|
|
566
750
|
if (activeKey === null) {
|
|
567
751
|
return null;
|
|
568
752
|
}
|
|
569
|
-
return flattenNodes.find((
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
753
|
+
return flattenNodes.find(function (_ref2) {
|
|
754
|
+
var key = _ref2.key;
|
|
755
|
+
return key === activeKey;
|
|
756
|
+
}) || null;
|
|
757
|
+
});
|
|
758
|
+
_defineProperty(_assertThisInitialized(_this), "offsetActiveKey", function (offset) {
|
|
759
|
+
var _this$state12 = _this.state,
|
|
760
|
+
flattenNodes = _this$state12.flattenNodes,
|
|
761
|
+
activeKey = _this$state12.activeKey;
|
|
762
|
+
var index = flattenNodes.findIndex(function (_ref3) {
|
|
763
|
+
var key = _ref3.key;
|
|
764
|
+
return key === activeKey;
|
|
765
|
+
});
|
|
766
|
+
|
|
767
|
+
// Align with index
|
|
574
768
|
if (index === -1 && offset < 0) {
|
|
575
769
|
index = flattenNodes.length;
|
|
576
770
|
}
|
|
577
771
|
index = (index + offset + flattenNodes.length) % flattenNodes.length;
|
|
578
|
-
|
|
772
|
+
var item = flattenNodes[index];
|
|
579
773
|
if (item) {
|
|
580
|
-
|
|
581
|
-
|
|
774
|
+
var _key4 = item.key;
|
|
775
|
+
_this.onActiveChange(_key4);
|
|
582
776
|
} else {
|
|
583
|
-
|
|
777
|
+
_this.onActiveChange(null);
|
|
584
778
|
}
|
|
585
|
-
};
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
779
|
+
});
|
|
780
|
+
_defineProperty(_assertThisInitialized(_this), "onKeyDown", function (event) {
|
|
781
|
+
var _this$state13 = _this.state,
|
|
782
|
+
activeKey = _this$state13.activeKey,
|
|
783
|
+
expandedKeys = _this$state13.expandedKeys,
|
|
784
|
+
checkedKeys = _this$state13.checkedKeys,
|
|
785
|
+
fieldNames = _this$state13.fieldNames;
|
|
786
|
+
var _this$props10 = _this.props,
|
|
787
|
+
onKeyDown = _this$props10.onKeyDown,
|
|
788
|
+
checkable = _this$props10.checkable,
|
|
789
|
+
selectable = _this$props10.selectable;
|
|
790
|
+
|
|
791
|
+
// >>>>>>>>>> Direction
|
|
589
792
|
switch (event.which) {
|
|
590
|
-
case
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
793
|
+
case KeyCode.UP:
|
|
794
|
+
{
|
|
795
|
+
_this.offsetActiveKey(-1);
|
|
796
|
+
event.preventDefault();
|
|
797
|
+
break;
|
|
798
|
+
}
|
|
799
|
+
case KeyCode.DOWN:
|
|
800
|
+
{
|
|
801
|
+
_this.offsetActiveKey(1);
|
|
802
|
+
event.preventDefault();
|
|
803
|
+
break;
|
|
804
|
+
}
|
|
600
805
|
}
|
|
601
|
-
|
|
806
|
+
|
|
807
|
+
// >>>>>>>>>> Expand & Selection
|
|
808
|
+
var activeItem = _this.getActiveItem();
|
|
602
809
|
if (activeItem && activeItem.data) {
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
...(0, import_treeUtil.getTreeNodeProps)(activeKey, treeNodeRequiredProps),
|
|
810
|
+
var treeNodeRequiredProps = _this.getTreeNodeRequiredProps();
|
|
811
|
+
var expandable = activeItem.data.isLeaf === false || !!(activeItem.data[fieldNames.children] || []).length;
|
|
812
|
+
var eventNode = convertNodePropsToEventData(_objectSpread(_objectSpread({}, getTreeNodeProps(activeKey, treeNodeRequiredProps)), {}, {
|
|
607
813
|
data: activeItem.data,
|
|
608
814
|
active: true
|
|
609
|
-
});
|
|
815
|
+
}));
|
|
610
816
|
switch (event.which) {
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
817
|
+
// >>> Expand
|
|
818
|
+
case KeyCode.LEFT:
|
|
819
|
+
{
|
|
820
|
+
// Collapse if possible
|
|
821
|
+
if (expandable && expandedKeys.includes(activeKey)) {
|
|
822
|
+
_this.onNodeExpand({}, eventNode);
|
|
823
|
+
} else if (activeItem.parent) {
|
|
824
|
+
_this.onActiveChange(activeItem.parent.key);
|
|
825
|
+
}
|
|
826
|
+
event.preventDefault();
|
|
827
|
+
break;
|
|
616
828
|
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
829
|
+
case KeyCode.RIGHT:
|
|
830
|
+
{
|
|
831
|
+
// Expand if possible
|
|
832
|
+
if (expandable && !expandedKeys.includes(activeKey)) {
|
|
833
|
+
_this.onNodeExpand({}, eventNode);
|
|
834
|
+
} else if (activeItem.children && activeItem.children.length) {
|
|
835
|
+
_this.onActiveChange(activeItem.children[0].key);
|
|
836
|
+
}
|
|
837
|
+
event.preventDefault();
|
|
838
|
+
break;
|
|
625
839
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
case
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
840
|
+
|
|
841
|
+
// Selection
|
|
842
|
+
case KeyCode.ENTER:
|
|
843
|
+
case KeyCode.SPACE:
|
|
844
|
+
{
|
|
845
|
+
if (checkable && !eventNode.disabled && eventNode.checkable !== false && !eventNode.disableCheckbox) {
|
|
846
|
+
_this.onNodeCheck({}, eventNode, !checkedKeys.includes(activeKey));
|
|
847
|
+
} else if (!checkable && selectable && !eventNode.disabled && eventNode.selectable !== false) {
|
|
848
|
+
_this.onNodeSelect({}, eventNode);
|
|
849
|
+
}
|
|
850
|
+
break;
|
|
635
851
|
}
|
|
636
|
-
break;
|
|
637
|
-
}
|
|
638
852
|
}
|
|
639
853
|
}
|
|
640
|
-
onKeyDown
|
|
641
|
-
};
|
|
642
|
-
/**
|
|
643
|
-
* Only update the value which is not in props
|
|
854
|
+
onKeyDown === null || onKeyDown === void 0 || onKeyDown(event);
|
|
855
|
+
});
|
|
856
|
+
/**
|
|
857
|
+
* Only update the value which is not in props
|
|
644
858
|
*/
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
859
|
+
_defineProperty(_assertThisInitialized(_this), "setUncontrolledState", function (state) {
|
|
860
|
+
var atomic = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
861
|
+
var forceState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
862
|
+
if (!_this.destroyed) {
|
|
863
|
+
var needSync = false;
|
|
864
|
+
var allPassed = true;
|
|
865
|
+
var newState = {};
|
|
866
|
+
Object.keys(state).forEach(function (name) {
|
|
867
|
+
if (Object.prototype.hasOwnProperty.call(_this.props, name)) {
|
|
652
868
|
allPassed = false;
|
|
653
869
|
return;
|
|
654
870
|
}
|
|
@@ -656,267 +872,326 @@ var RCTree = class extends import_react.Component {
|
|
|
656
872
|
newState[name] = state[name];
|
|
657
873
|
});
|
|
658
874
|
if (needSync && (!atomic || allPassed)) {
|
|
659
|
-
|
|
660
|
-
...newState,
|
|
661
|
-
...forceState
|
|
662
|
-
});
|
|
875
|
+
_this.setState(_objectSpread(_objectSpread({}, newState), forceState));
|
|
663
876
|
}
|
|
664
877
|
}
|
|
665
|
-
};
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
};
|
|
669
|
-
|
|
670
|
-
componentDidMount() {
|
|
671
|
-
this.onUpdated();
|
|
672
|
-
}
|
|
673
|
-
componentDidUpdate() {
|
|
674
|
-
this.onUpdated();
|
|
675
|
-
}
|
|
676
|
-
onUpdated() {
|
|
677
|
-
const { activeKey } = this.props;
|
|
678
|
-
if (activeKey !== void 0 && activeKey !== this.state.activeKey) {
|
|
679
|
-
this.setState({ activeKey });
|
|
680
|
-
if (activeKey !== null) {
|
|
681
|
-
this.scrollTo({ key: activeKey });
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
componentWillUnmount() {
|
|
686
|
-
window.removeEventListener("dragend", this.onWindowDragEnd);
|
|
687
|
-
this.destroyed = true;
|
|
878
|
+
});
|
|
879
|
+
_defineProperty(_assertThisInitialized(_this), "scrollTo", function (scroll) {
|
|
880
|
+
_this.listRef.current.scrollTo(scroll);
|
|
881
|
+
});
|
|
882
|
+
return _this;
|
|
688
883
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
function needSync(name) {
|
|
695
|
-
return !prevProps && name in props || prevProps && prevProps[name] !== props[name];
|
|
884
|
+
_createClass(Tree, [{
|
|
885
|
+
key: "componentDidMount",
|
|
886
|
+
value: function componentDidMount() {
|
|
887
|
+
this.destroyed = false;
|
|
888
|
+
this.onUpdated();
|
|
696
889
|
}
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
newState.fieldNames = fieldNames;
|
|
890
|
+
}, {
|
|
891
|
+
key: "componentDidUpdate",
|
|
892
|
+
value: function componentDidUpdate() {
|
|
893
|
+
this.onUpdated();
|
|
702
894
|
}
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
895
|
+
}, {
|
|
896
|
+
key: "onUpdated",
|
|
897
|
+
value: function onUpdated() {
|
|
898
|
+
var _this$props11 = this.props,
|
|
899
|
+
activeKey = _this$props11.activeKey,
|
|
900
|
+
_this$props11$itemScr = _this$props11.itemScrollOffset,
|
|
901
|
+
itemScrollOffset = _this$props11$itemScr === void 0 ? 0 : _this$props11$itemScr;
|
|
902
|
+
if (activeKey !== undefined && activeKey !== this.state.activeKey) {
|
|
903
|
+
this.setState({
|
|
904
|
+
activeKey: activeKey
|
|
905
|
+
});
|
|
906
|
+
if (activeKey !== null) {
|
|
907
|
+
this.scrollTo({
|
|
908
|
+
key: activeKey,
|
|
909
|
+
offset: itemScrollOffset
|
|
910
|
+
});
|
|
911
|
+
}
|
|
718
912
|
}
|
|
719
913
|
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
delete cloneKeyEntities[import_NodeList.MOTION_KEY];
|
|
726
|
-
newState.expandedKeys = Object.keys(cloneKeyEntities).map((key) => cloneKeyEntities[key].key);
|
|
727
|
-
} else if (!prevProps && props.defaultExpandedKeys) {
|
|
728
|
-
newState.expandedKeys = props.autoExpandParent || props.defaultExpandParent ? (0, import_util.conductExpandParent)(props.defaultExpandedKeys, keyEntities) : props.defaultExpandedKeys;
|
|
914
|
+
}, {
|
|
915
|
+
key: "componentWillUnmount",
|
|
916
|
+
value: function componentWillUnmount() {
|
|
917
|
+
window.removeEventListener('dragend', this.onWindowDragEnd);
|
|
918
|
+
this.destroyed = true;
|
|
729
919
|
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
920
|
+
}, {
|
|
921
|
+
key: "resetDragState",
|
|
922
|
+
value: function resetDragState() {
|
|
923
|
+
this.setState({
|
|
924
|
+
dragOverNodeKey: null,
|
|
925
|
+
dropPosition: null,
|
|
926
|
+
dropLevelOffset: null,
|
|
927
|
+
dropTargetKey: null,
|
|
928
|
+
dropContainerKey: null,
|
|
929
|
+
dropTargetPos: null,
|
|
930
|
+
dropAllowed: false
|
|
931
|
+
});
|
|
736
932
|
}
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
933
|
+
}, {
|
|
934
|
+
key: "render",
|
|
935
|
+
value: function render() {
|
|
936
|
+
var _this$state14 = this.state,
|
|
937
|
+
focused = _this$state14.focused,
|
|
938
|
+
flattenNodes = _this$state14.flattenNodes,
|
|
939
|
+
keyEntities = _this$state14.keyEntities,
|
|
940
|
+
draggingNodeKey = _this$state14.draggingNodeKey,
|
|
941
|
+
activeKey = _this$state14.activeKey,
|
|
942
|
+
dropLevelOffset = _this$state14.dropLevelOffset,
|
|
943
|
+
dropContainerKey = _this$state14.dropContainerKey,
|
|
944
|
+
dropTargetKey = _this$state14.dropTargetKey,
|
|
945
|
+
dropPosition = _this$state14.dropPosition,
|
|
946
|
+
dragOverNodeKey = _this$state14.dragOverNodeKey,
|
|
947
|
+
indent = _this$state14.indent;
|
|
948
|
+
var _this$props12 = this.props,
|
|
949
|
+
prefixCls = _this$props12.prefixCls,
|
|
950
|
+
className = _this$props12.className,
|
|
951
|
+
style = _this$props12.style,
|
|
952
|
+
styles = _this$props12.styles,
|
|
953
|
+
treeClassNames = _this$props12.classNames,
|
|
954
|
+
showLine = _this$props12.showLine,
|
|
955
|
+
focusable = _this$props12.focusable,
|
|
956
|
+
_this$props12$tabInde = _this$props12.tabIndex,
|
|
957
|
+
tabIndex = _this$props12$tabInde === void 0 ? 0 : _this$props12$tabInde,
|
|
958
|
+
selectable = _this$props12.selectable,
|
|
959
|
+
showIcon = _this$props12.showIcon,
|
|
960
|
+
icon = _this$props12.icon,
|
|
961
|
+
switcherIcon = _this$props12.switcherIcon,
|
|
962
|
+
draggable = _this$props12.draggable,
|
|
963
|
+
checkable = _this$props12.checkable,
|
|
964
|
+
checkStrictly = _this$props12.checkStrictly,
|
|
965
|
+
disabled = _this$props12.disabled,
|
|
966
|
+
motion = _this$props12.motion,
|
|
967
|
+
loadData = _this$props12.loadData,
|
|
968
|
+
filterTreeNode = _this$props12.filterTreeNode,
|
|
969
|
+
height = _this$props12.height,
|
|
970
|
+
itemHeight = _this$props12.itemHeight,
|
|
971
|
+
scrollWidth = _this$props12.scrollWidth,
|
|
972
|
+
virtual = _this$props12.virtual,
|
|
973
|
+
titleRender = _this$props12.titleRender,
|
|
974
|
+
dropIndicatorRender = _this$props12.dropIndicatorRender,
|
|
975
|
+
onContextMenu = _this$props12.onContextMenu,
|
|
976
|
+
onScroll = _this$props12.onScroll,
|
|
977
|
+
direction = _this$props12.direction,
|
|
978
|
+
rootClassName = _this$props12.rootClassName,
|
|
979
|
+
rootStyle = _this$props12.rootStyle;
|
|
980
|
+
var domProps = pickAttrs(this.props, {
|
|
981
|
+
aria: true,
|
|
982
|
+
data: true
|
|
983
|
+
});
|
|
984
|
+
|
|
985
|
+
// It's better move to hooks but we just simply keep here
|
|
986
|
+
var draggableConfig;
|
|
987
|
+
if (draggable) {
|
|
988
|
+
if (_typeof(draggable) === 'object') {
|
|
989
|
+
draggableConfig = draggable;
|
|
990
|
+
} else if (typeof draggable === 'function') {
|
|
991
|
+
draggableConfig = {
|
|
992
|
+
nodeDraggable: draggable
|
|
993
|
+
};
|
|
994
|
+
} else {
|
|
995
|
+
draggableConfig = {};
|
|
996
|
+
}
|
|
742
997
|
}
|
|
998
|
+
var contextValue = {
|
|
999
|
+
styles: styles,
|
|
1000
|
+
classNames: treeClassNames,
|
|
1001
|
+
prefixCls: prefixCls,
|
|
1002
|
+
selectable: selectable,
|
|
1003
|
+
showIcon: showIcon,
|
|
1004
|
+
icon: icon,
|
|
1005
|
+
switcherIcon: switcherIcon,
|
|
1006
|
+
draggable: draggableConfig,
|
|
1007
|
+
draggingNodeKey: draggingNodeKey,
|
|
1008
|
+
checkable: checkable,
|
|
1009
|
+
checkStrictly: checkStrictly,
|
|
1010
|
+
disabled: disabled,
|
|
1011
|
+
keyEntities: keyEntities,
|
|
1012
|
+
dropLevelOffset: dropLevelOffset,
|
|
1013
|
+
dropContainerKey: dropContainerKey,
|
|
1014
|
+
dropTargetKey: dropTargetKey,
|
|
1015
|
+
dropPosition: dropPosition,
|
|
1016
|
+
dragOverNodeKey: dragOverNodeKey,
|
|
1017
|
+
indent: indent,
|
|
1018
|
+
direction: direction,
|
|
1019
|
+
dropIndicatorRender: dropIndicatorRender,
|
|
1020
|
+
loadData: loadData,
|
|
1021
|
+
filterTreeNode: filterTreeNode,
|
|
1022
|
+
titleRender: titleRender,
|
|
1023
|
+
onNodeClick: this.onNodeClick,
|
|
1024
|
+
onNodeDoubleClick: this.onNodeDoubleClick,
|
|
1025
|
+
onNodeExpand: this.onNodeExpand,
|
|
1026
|
+
onNodeSelect: this.onNodeSelect,
|
|
1027
|
+
onNodeCheck: this.onNodeCheck,
|
|
1028
|
+
onNodeLoad: this.onNodeLoad,
|
|
1029
|
+
onNodeMouseEnter: this.onNodeMouseEnter,
|
|
1030
|
+
onNodeMouseLeave: this.onNodeMouseLeave,
|
|
1031
|
+
onNodeContextMenu: this.onNodeContextMenu,
|
|
1032
|
+
onNodeDragStart: this.onNodeDragStart,
|
|
1033
|
+
onNodeDragEnter: this.onNodeDragEnter,
|
|
1034
|
+
onNodeDragOver: this.onNodeDragOver,
|
|
1035
|
+
onNodeDragLeave: this.onNodeDragLeave,
|
|
1036
|
+
onNodeDragEnd: this.onNodeDragEnd,
|
|
1037
|
+
onNodeDrop: this.onNodeDrop
|
|
1038
|
+
};
|
|
1039
|
+
return /*#__PURE__*/React.createElement(TreeContext.Provider, {
|
|
1040
|
+
value: contextValue
|
|
1041
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1042
|
+
className: classNames(prefixCls, className, rootClassName, _defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-show-line"), showLine), "".concat(prefixCls, "-focused"), focused), "".concat(prefixCls, "-active-focused"), activeKey !== null)),
|
|
1043
|
+
style: rootStyle
|
|
1044
|
+
}, /*#__PURE__*/React.createElement(NodeList, _extends({
|
|
1045
|
+
ref: this.listRef,
|
|
1046
|
+
prefixCls: prefixCls,
|
|
1047
|
+
style: style,
|
|
1048
|
+
data: flattenNodes,
|
|
1049
|
+
disabled: disabled,
|
|
1050
|
+
selectable: selectable,
|
|
1051
|
+
checkable: !!checkable,
|
|
1052
|
+
motion: motion,
|
|
1053
|
+
dragging: draggingNodeKey !== null,
|
|
1054
|
+
height: height,
|
|
1055
|
+
itemHeight: itemHeight,
|
|
1056
|
+
virtual: virtual,
|
|
1057
|
+
focusable: focusable,
|
|
1058
|
+
focused: focused,
|
|
1059
|
+
tabIndex: tabIndex,
|
|
1060
|
+
activeItem: this.getActiveItem(),
|
|
1061
|
+
onFocus: this.onFocus,
|
|
1062
|
+
onBlur: this.onBlur,
|
|
1063
|
+
onKeyDown: this.onKeyDown,
|
|
1064
|
+
onActiveChange: this.onActiveChange,
|
|
1065
|
+
onListChangeStart: this.onListChangeStart,
|
|
1066
|
+
onListChangeEnd: this.onListChangeEnd,
|
|
1067
|
+
onContextMenu: onContextMenu,
|
|
1068
|
+
onScroll: onScroll,
|
|
1069
|
+
scrollWidth: scrollWidth
|
|
1070
|
+
}, this.getTreeNodeRequiredProps(), domProps))));
|
|
743
1071
|
}
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
1072
|
+
}], [{
|
|
1073
|
+
key: "getDerivedStateFromProps",
|
|
1074
|
+
value: function getDerivedStateFromProps(props, prevState) {
|
|
1075
|
+
var prevProps = prevState.prevProps;
|
|
1076
|
+
var newState = {
|
|
1077
|
+
prevProps: props
|
|
1078
|
+
};
|
|
1079
|
+
function needSync(name) {
|
|
1080
|
+
return !prevProps && Object.prototype.hasOwnProperty.call(props, name) || prevProps && prevProps[name] !== props[name];
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
// ================== Tree Node ==================
|
|
1084
|
+
var treeData;
|
|
1085
|
+
|
|
1086
|
+
// fieldNames
|
|
1087
|
+
var fieldNames = prevState.fieldNames;
|
|
1088
|
+
if (needSync('fieldNames')) {
|
|
1089
|
+
fieldNames = fillFieldNames(props.fieldNames);
|
|
1090
|
+
newState.fieldNames = fieldNames;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
// Check if `treeData` or `children` changed and save into the state.
|
|
1094
|
+
if (needSync('treeData')) {
|
|
1095
|
+
treeData = props.treeData;
|
|
1096
|
+
} else if (needSync('children')) {
|
|
1097
|
+
warning(false, '`children` of Tree is deprecated. Please use `treeData` instead.');
|
|
1098
|
+
treeData = convertTreeToData(props.children);
|
|
755
1099
|
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
1100
|
+
|
|
1101
|
+
// Save flatten nodes info and convert `treeData` into keyEntities
|
|
1102
|
+
if (treeData) {
|
|
1103
|
+
newState.treeData = treeData;
|
|
1104
|
+
var entitiesMap = convertDataToEntities(treeData, {
|
|
1105
|
+
fieldNames: fieldNames
|
|
1106
|
+
});
|
|
1107
|
+
newState.keyEntities = _objectSpread(_defineProperty({}, MOTION_KEY, MotionEntity), entitiesMap.keyEntities);
|
|
1108
|
+
|
|
1109
|
+
// Warning if treeNode not provide key
|
|
1110
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1111
|
+
warningWithoutKey(treeData, fieldNames);
|
|
761
1112
|
}
|
|
762
|
-
newState.checkedKeys = checkedKeys;
|
|
763
|
-
newState.halfCheckedKeys = halfCheckedKeys;
|
|
764
1113
|
}
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
prefixCls,
|
|
786
|
-
className,
|
|
787
|
-
style,
|
|
788
|
-
showLine,
|
|
789
|
-
focusable,
|
|
790
|
-
tabIndex = 0,
|
|
791
|
-
selectable,
|
|
792
|
-
showIcon,
|
|
793
|
-
icon,
|
|
794
|
-
switcherIcon,
|
|
795
|
-
draggable,
|
|
796
|
-
checkable,
|
|
797
|
-
checkStrictly,
|
|
798
|
-
disabled,
|
|
799
|
-
motion,
|
|
800
|
-
loadData,
|
|
801
|
-
filterTreeNode,
|
|
802
|
-
height,
|
|
803
|
-
itemHeight,
|
|
804
|
-
virtual,
|
|
805
|
-
titleRender,
|
|
806
|
-
dropIndicatorRender,
|
|
807
|
-
onContextMenu,
|
|
808
|
-
onScroll,
|
|
809
|
-
direction,
|
|
810
|
-
rootClassName,
|
|
811
|
-
rootStyle
|
|
812
|
-
} = this.props;
|
|
813
|
-
const domProps = (0, import_pickAttrs.default)(this.props, {
|
|
814
|
-
aria: true,
|
|
815
|
-
data: true
|
|
816
|
-
});
|
|
817
|
-
let draggableConfig;
|
|
818
|
-
if (draggable) {
|
|
819
|
-
if (typeof draggable === "object") {
|
|
820
|
-
draggableConfig = draggable;
|
|
821
|
-
} else if (typeof draggable === "function") {
|
|
822
|
-
draggableConfig = {
|
|
823
|
-
nodeDraggable: draggable
|
|
824
|
-
};
|
|
825
|
-
} else {
|
|
826
|
-
draggableConfig = {};
|
|
1114
|
+
var keyEntities = newState.keyEntities || prevState.keyEntities;
|
|
1115
|
+
|
|
1116
|
+
// ================ expandedKeys =================
|
|
1117
|
+
if (needSync('expandedKeys') || prevProps && needSync('autoExpandParent')) {
|
|
1118
|
+
newState.expandedKeys = props.autoExpandParent || !prevProps && props.defaultExpandParent ? conductExpandParent(props.expandedKeys, keyEntities) : props.expandedKeys;
|
|
1119
|
+
} else if (!prevProps && props.defaultExpandAll) {
|
|
1120
|
+
var cloneKeyEntities = _objectSpread({}, keyEntities);
|
|
1121
|
+
delete cloneKeyEntities[MOTION_KEY];
|
|
1122
|
+
|
|
1123
|
+
// Only take the key who has the children to enhance the performance
|
|
1124
|
+
var nextExpandedKeys = [];
|
|
1125
|
+
Object.keys(cloneKeyEntities).forEach(function (key) {
|
|
1126
|
+
var entity = cloneKeyEntities[key];
|
|
1127
|
+
if (entity.children && entity.children.length) {
|
|
1128
|
+
nextExpandedKeys.push(entity.key);
|
|
1129
|
+
}
|
|
1130
|
+
});
|
|
1131
|
+
newState.expandedKeys = nextExpandedKeys;
|
|
1132
|
+
} else if (!prevProps && props.defaultExpandedKeys) {
|
|
1133
|
+
newState.expandedKeys = props.autoExpandParent || props.defaultExpandParent ? conductExpandParent(props.defaultExpandedKeys, keyEntities) : props.defaultExpandedKeys;
|
|
827
1134
|
}
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
dropLevelOffset,
|
|
845
|
-
dropContainerKey,
|
|
846
|
-
dropTargetKey,
|
|
847
|
-
dropPosition,
|
|
848
|
-
dragOverNodeKey,
|
|
849
|
-
indent,
|
|
850
|
-
direction,
|
|
851
|
-
dropIndicatorRender,
|
|
852
|
-
loadData,
|
|
853
|
-
filterTreeNode,
|
|
854
|
-
titleRender,
|
|
855
|
-
onNodeClick: this.onNodeClick,
|
|
856
|
-
onNodeDoubleClick: this.onNodeDoubleClick,
|
|
857
|
-
onNodeExpand: this.onNodeExpand,
|
|
858
|
-
onNodeSelect: this.onNodeSelect,
|
|
859
|
-
onNodeCheck: this.onNodeCheck,
|
|
860
|
-
onNodeLoad: this.onNodeLoad,
|
|
861
|
-
onNodeMouseEnter: this.onNodeMouseEnter,
|
|
862
|
-
onNodeMouseLeave: this.onNodeMouseLeave,
|
|
863
|
-
onNodeContextMenu: this.onNodeContextMenu,
|
|
864
|
-
onNodeDragStart: this.onNodeDragStart,
|
|
865
|
-
onNodeDragEnter: this.onNodeDragEnter,
|
|
866
|
-
onNodeDragOver: this.onNodeDragOver,
|
|
867
|
-
onNodeDragLeave: this.onNodeDragLeave,
|
|
868
|
-
onNodeDragEnd: this.onNodeDragEnd,
|
|
869
|
-
onNodeDrop: this.onNodeDrop
|
|
1135
|
+
if (!newState.expandedKeys) {
|
|
1136
|
+
delete newState.expandedKeys;
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
// ================ flattenNodes =================
|
|
1140
|
+
if (treeData || newState.expandedKeys) {
|
|
1141
|
+
var flattenNodes = flattenTreeData(treeData || prevState.treeData, newState.expandedKeys || prevState.expandedKeys, fieldNames);
|
|
1142
|
+
newState.flattenNodes = flattenNodes;
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
// ================ selectedKeys =================
|
|
1146
|
+
if (props.selectable) {
|
|
1147
|
+
if (needSync('selectedKeys')) {
|
|
1148
|
+
newState.selectedKeys = calcSelectedKeys(props.selectedKeys, props);
|
|
1149
|
+
} else if (!prevProps && props.defaultSelectedKeys) {
|
|
1150
|
+
newState.selectedKeys = calcSelectedKeys(props.defaultSelectedKeys, props);
|
|
870
1151
|
}
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
virtual,
|
|
898
|
-
focusable,
|
|
899
|
-
focused,
|
|
900
|
-
tabIndex,
|
|
901
|
-
activeItem: this.getActiveItem(),
|
|
902
|
-
onFocus: this.onFocus,
|
|
903
|
-
onBlur: this.onBlur,
|
|
904
|
-
onKeyDown: this.onKeyDown,
|
|
905
|
-
onActiveChange: this.onActiveChange,
|
|
906
|
-
onListChangeStart: this.onListChangeStart,
|
|
907
|
-
onListChangeEnd: this.onListChangeEnd,
|
|
908
|
-
onContextMenu,
|
|
909
|
-
onScroll,
|
|
910
|
-
...this.getTreeNodeRequiredProps(),
|
|
911
|
-
...domProps
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
// ================= checkedKeys =================
|
|
1155
|
+
if (props.checkable) {
|
|
1156
|
+
var checkedKeyEntity;
|
|
1157
|
+
if (needSync('checkedKeys')) {
|
|
1158
|
+
checkedKeyEntity = parseCheckedKeys(props.checkedKeys) || {};
|
|
1159
|
+
} else if (!prevProps && props.defaultCheckedKeys) {
|
|
1160
|
+
checkedKeyEntity = parseCheckedKeys(props.defaultCheckedKeys) || {};
|
|
1161
|
+
} else if (treeData) {
|
|
1162
|
+
// If `treeData` changed, we also need check it
|
|
1163
|
+
checkedKeyEntity = parseCheckedKeys(props.checkedKeys) || {
|
|
1164
|
+
checkedKeys: prevState.checkedKeys,
|
|
1165
|
+
halfCheckedKeys: prevState.halfCheckedKeys
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
if (checkedKeyEntity) {
|
|
1169
|
+
var _checkedKeyEntity = checkedKeyEntity,
|
|
1170
|
+
_checkedKeyEntity$che = _checkedKeyEntity.checkedKeys,
|
|
1171
|
+
checkedKeys = _checkedKeyEntity$che === void 0 ? [] : _checkedKeyEntity$che,
|
|
1172
|
+
_checkedKeyEntity$hal = _checkedKeyEntity.halfCheckedKeys,
|
|
1173
|
+
halfCheckedKeys = _checkedKeyEntity$hal === void 0 ? [] : _checkedKeyEntity$hal;
|
|
1174
|
+
if (!props.checkStrictly) {
|
|
1175
|
+
var conductKeys = conductCheck(checkedKeys, true, keyEntities);
|
|
1176
|
+
checkedKeys = conductKeys.checkedKeys;
|
|
1177
|
+
halfCheckedKeys = conductKeys.halfCheckedKeys;
|
|
912
1178
|
}
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
1179
|
+
newState.checkedKeys = checkedKeys;
|
|
1180
|
+
newState.halfCheckedKeys = halfCheckedKeys;
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
// ================= loadedKeys ==================
|
|
1185
|
+
if (needSync('loadedKeys')) {
|
|
1186
|
+
newState.loadedKeys = props.loadedKeys;
|
|
1187
|
+
}
|
|
1188
|
+
return newState;
|
|
1189
|
+
}
|
|
1190
|
+
}]);
|
|
1191
|
+
return Tree;
|
|
1192
|
+
}(React.Component);
|
|
1193
|
+
_defineProperty(Tree, "defaultProps", {
|
|
1194
|
+
prefixCls: 'el-tree',
|
|
920
1195
|
showLine: false,
|
|
921
1196
|
showIcon: true,
|
|
922
1197
|
selectable: true,
|
|
@@ -931,8 +1206,11 @@ RCTree.defaultProps = {
|
|
|
931
1206
|
defaultExpandedKeys: [],
|
|
932
1207
|
defaultCheckedKeys: [],
|
|
933
1208
|
defaultSelectedKeys: [],
|
|
934
|
-
dropIndicatorRender:
|
|
935
|
-
allowDrop: ()
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
1209
|
+
dropIndicatorRender: DropIndicator,
|
|
1210
|
+
allowDrop: function allowDrop() {
|
|
1211
|
+
return true;
|
|
1212
|
+
},
|
|
1213
|
+
expandAction: false
|
|
1214
|
+
});
|
|
1215
|
+
_defineProperty(Tree, "TreeNode", TreeNode);
|
|
1216
|
+
export default Tree;
|