@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
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
var _templateObject, _templateObject2;
|
|
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 _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; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
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); }
|
|
8
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
9
|
+
import classNames from 'classnames';
|
|
10
|
+
import React, { memo, useMemo } from 'react';
|
|
11
|
+
import { useClassNames } from "../hooks";
|
|
12
|
+
import { useCarouselContext } from "./CarouselContext";
|
|
13
|
+
import { useCarouselItem } from "./hooks/useCarouselItem";
|
|
14
|
+
var CarouselItem = /*#__PURE__*/memo(function (props) {
|
|
15
|
+
var _props$style;
|
|
16
|
+
var _props$classPrefix = props.classPrefix,
|
|
17
|
+
classPrefix = _props$classPrefix === void 0 ? 'carousel' : _props$classPrefix,
|
|
18
|
+
children = props.children;
|
|
19
|
+
var _useClassNames = useClassNames(classPrefix),
|
|
20
|
+
e = _useClassNames.e,
|
|
21
|
+
em = _useClassNames.em,
|
|
22
|
+
is = _useClassNames.is;
|
|
23
|
+
var _useCarouselContext = useCarouselContext(),
|
|
24
|
+
isCardType = _useCarouselContext.isCardType,
|
|
25
|
+
isVertical = _useCarouselContext.isVertical;
|
|
26
|
+
var _useCarouselItem = useCarouselItem(props),
|
|
27
|
+
carouselItemRef = _useCarouselItem.carouselItemRef,
|
|
28
|
+
state = _useCarouselItem.state,
|
|
29
|
+
handleItemClick = _useCarouselItem.handleItemClick;
|
|
30
|
+
var itemStyle = useMemo(function () {
|
|
31
|
+
var translateType = "translate".concat(isVertical ? 'Y' : 'X');
|
|
32
|
+
var _translate = "".concat(translateType, "(").concat(state.translate, "px)");
|
|
33
|
+
var _scale = "scale(".concat(state.scale, ")");
|
|
34
|
+
var transform = [_translate, _scale].join(' ');
|
|
35
|
+
return {
|
|
36
|
+
transform: transform
|
|
37
|
+
};
|
|
38
|
+
}, [isVertical, state.scale, state.translate]);
|
|
39
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
ref: carouselItemRef,
|
|
41
|
+
className: classNames(e(_templateObject || (_templateObject = _taggedTemplateLiteral(["item"]))), is({
|
|
42
|
+
active: state.active,
|
|
43
|
+
'in-stage': state.inStage,
|
|
44
|
+
hover: state.hover,
|
|
45
|
+
animating: state.animating
|
|
46
|
+
}), _defineProperty(_defineProperty({}, em('item', 'card'), isCardType), em('item', 'card-vertical'), isCardType && isVertical), props.className),
|
|
47
|
+
style: _objectSpread(_objectSpread({}, itemStyle), {}, {
|
|
48
|
+
display: state.ready ? '' : 'none'
|
|
49
|
+
}, (_props$style = props.style) !== null && _props$style !== void 0 ? _props$style : {}),
|
|
50
|
+
onClick: handleItemClick
|
|
51
|
+
}, isCardType && /*#__PURE__*/React.createElement("div", {
|
|
52
|
+
className: e(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["mask"]))),
|
|
53
|
+
style: {
|
|
54
|
+
display: !state.active ? '' : 'none'
|
|
55
|
+
}
|
|
56
|
+
}), children);
|
|
57
|
+
});
|
|
58
|
+
CarouselItem.displayName = 'ElCarouselItem';
|
|
59
|
+
export default CarouselItem;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/// <reference types="lodash" />
|
|
3
|
+
import { CarouselItemContext, CarouselProps } from '../typings';
|
|
4
|
+
export declare const useCarousel: (props: CarouselProps) => {
|
|
5
|
+
items: CarouselItemContext[];
|
|
6
|
+
addItem: (item: CarouselItemContext) => void;
|
|
7
|
+
removeItem: (uid: string) => void;
|
|
8
|
+
setContainerHeight: (_height: string | number) => void;
|
|
9
|
+
root: import("react").MutableRefObject<HTMLDivElement>;
|
|
10
|
+
activeIndex: number;
|
|
11
|
+
arrowDisplay: boolean;
|
|
12
|
+
hasLabel: boolean;
|
|
13
|
+
hover: boolean;
|
|
14
|
+
isCardType: boolean;
|
|
15
|
+
isTransitioning: boolean;
|
|
16
|
+
isVertical: boolean;
|
|
17
|
+
containerStyle: {
|
|
18
|
+
height: string | number;
|
|
19
|
+
overflow?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
height: number;
|
|
22
|
+
overflow: string;
|
|
23
|
+
};
|
|
24
|
+
isItemsTwoLength: import("react").MutableRefObject<boolean>;
|
|
25
|
+
handleButtonEnter: (_arrow: 'left' | 'right') => void;
|
|
26
|
+
handleTransitionEnd: () => void;
|
|
27
|
+
handleButtonLeave: () => void;
|
|
28
|
+
handleIndicatorClick: (index: number) => void;
|
|
29
|
+
handleMouseEnter: () => void;
|
|
30
|
+
handleMouseLeave: () => void;
|
|
31
|
+
setActiveItem: (index: number | string) => void;
|
|
32
|
+
prev: () => void;
|
|
33
|
+
next: () => void;
|
|
34
|
+
isTwoLengthShow: (index: number) => boolean;
|
|
35
|
+
throttledArrowClick: import("lodash").DebouncedFuncLeading<(index: number) => void>;
|
|
36
|
+
throttledIndicatorHover: import("lodash").DebouncedFuncLeading<(index: number) => void>;
|
|
37
|
+
};
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
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."); }
|
|
3
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure 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 _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; }
|
|
9
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
import { usePrevious } from 'ahooks';
|
|
12
|
+
import throttle from 'lodash/throttle';
|
|
13
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
14
|
+
import { isString, warning } from "../../Util/base";
|
|
15
|
+
var THROTTLE_TIME = 300;
|
|
16
|
+
export var useCarousel = function useCarousel(props) {
|
|
17
|
+
var direction = props.direction,
|
|
18
|
+
arrow = props.arrow,
|
|
19
|
+
height = props.height,
|
|
20
|
+
type = props.type,
|
|
21
|
+
autoplay = props.autoplay,
|
|
22
|
+
loop = props.loop,
|
|
23
|
+
interval = props.interval,
|
|
24
|
+
pauseOnHover = props.pauseOnHover,
|
|
25
|
+
trigger = props.trigger,
|
|
26
|
+
initialIndex = props.initialIndex,
|
|
27
|
+
onChange = props.onChange;
|
|
28
|
+
var _useState = useState([]),
|
|
29
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
30
|
+
items = _useState2[0],
|
|
31
|
+
setItem = _useState2[1];
|
|
32
|
+
var addItem = function addItem(item) {
|
|
33
|
+
return setItem(function (pre) {
|
|
34
|
+
return [].concat(_toConsumableArray(pre), [item]);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var removeItem = function removeItem(uid) {
|
|
38
|
+
return setItem(function (pre) {
|
|
39
|
+
return pre.filter(function (children) {
|
|
40
|
+
return children.uid !== uid;
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var _useState3 = useState(-1),
|
|
45
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
46
|
+
activeIndex = _useState4[0],
|
|
47
|
+
setActiveIndex = _useState4[1];
|
|
48
|
+
var _useState5 = useState(false),
|
|
49
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
50
|
+
hover = _useState6[0],
|
|
51
|
+
setHover = _useState6[1];
|
|
52
|
+
var _useState7 = useState(0),
|
|
53
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
54
|
+
containerHeight = _useState8[0],
|
|
55
|
+
setHeight = _useState8[1];
|
|
56
|
+
var _useState9 = useState(false),
|
|
57
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
58
|
+
isTransitioning = _useState10[0],
|
|
59
|
+
setIsTransitioning = _useState10[1];
|
|
60
|
+
var preActiveIndex = usePrevious(activeIndex);
|
|
61
|
+
var timer = useRef(null);
|
|
62
|
+
var root = useRef(null);
|
|
63
|
+
var isItemsTwoLength = useRef(true);
|
|
64
|
+
var isTransition = useRef(false);
|
|
65
|
+
var resizeObserver = useRef(null);
|
|
66
|
+
var isFirstCall = useRef(true);
|
|
67
|
+
var itemLen = useRef(0);
|
|
68
|
+
var activeIndexRef = useRef(-1);
|
|
69
|
+
var isVertical = useMemo(function () {
|
|
70
|
+
return direction === 'vertical';
|
|
71
|
+
}, [direction]);
|
|
72
|
+
var arrowDisplay = useMemo(function () {
|
|
73
|
+
return arrow !== 'never' && !isVertical;
|
|
74
|
+
}, [arrow, isVertical]);
|
|
75
|
+
var hasLabel = useMemo(function () {
|
|
76
|
+
return items.some(function (item) {
|
|
77
|
+
var _item$props;
|
|
78
|
+
return ((_item$props = item.props) === null || _item$props === void 0 || (_item$props = _item$props.label) === null || _item$props === void 0 || (_item$props = _item$props.toString()) === null || _item$props === void 0 ? void 0 : _item$props.length) > 0;
|
|
79
|
+
});
|
|
80
|
+
}, [items]);
|
|
81
|
+
var isCardType = useMemo(function () {
|
|
82
|
+
return type === 'card';
|
|
83
|
+
}, [type]);
|
|
84
|
+
var containerStyle = useMemo(function () {
|
|
85
|
+
if (height !== 'auto') {
|
|
86
|
+
return {
|
|
87
|
+
height: height
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
height: containerHeight,
|
|
92
|
+
overflow: 'hidden'
|
|
93
|
+
};
|
|
94
|
+
}, [containerHeight, height]);
|
|
95
|
+
var resetItemPosition = useCallback(function (oldIndex) {
|
|
96
|
+
items.forEach(function (item, index) {
|
|
97
|
+
item.translateItem(index, activeIndex, oldIndex);
|
|
98
|
+
});
|
|
99
|
+
}, [activeIndex, items]);
|
|
100
|
+
var playSlides = useCallback(function () {
|
|
101
|
+
if (!isFirstCall.current && !isTransition.current) {
|
|
102
|
+
isTransition.current = true;
|
|
103
|
+
setIsTransitioning(true);
|
|
104
|
+
}
|
|
105
|
+
isFirstCall.current = false;
|
|
106
|
+
if (activeIndexRef.current < itemLen.current - 1) {
|
|
107
|
+
setActiveIndex(function (pre) {
|
|
108
|
+
return pre + 1;
|
|
109
|
+
});
|
|
110
|
+
} else if (loop) {
|
|
111
|
+
setActiveIndex(0);
|
|
112
|
+
} else {
|
|
113
|
+
isTransition.current = false;
|
|
114
|
+
setIsTransitioning(false);
|
|
115
|
+
}
|
|
116
|
+
}, [loop]);
|
|
117
|
+
var startTimer = useCallback(function () {
|
|
118
|
+
if (interval <= 0 || !autoplay || timer.current) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
timer.current = setInterval(function () {
|
|
122
|
+
return playSlides();
|
|
123
|
+
}, interval);
|
|
124
|
+
}, [autoplay, interval, playSlides]);
|
|
125
|
+
var pauseTimer = useCallback(function () {
|
|
126
|
+
if (timer.current) {
|
|
127
|
+
clearInterval(timer.current);
|
|
128
|
+
timer.current = null;
|
|
129
|
+
}
|
|
130
|
+
}, []);
|
|
131
|
+
var resetTimer = useCallback(function () {
|
|
132
|
+
pauseTimer();
|
|
133
|
+
if (!pauseOnHover) {
|
|
134
|
+
startTimer();
|
|
135
|
+
}
|
|
136
|
+
}, [pauseOnHover, pauseTimer, startTimer]);
|
|
137
|
+
var setActiveItem = useCallback(function (index) {
|
|
138
|
+
if (!isFirstCall.current) {
|
|
139
|
+
isTransition.current = true;
|
|
140
|
+
setIsTransitioning(true);
|
|
141
|
+
}
|
|
142
|
+
isFirstCall.current = false;
|
|
143
|
+
if (isString(index)) {
|
|
144
|
+
var filteredItems = items.filter(function (item) {
|
|
145
|
+
return item.props.name === index;
|
|
146
|
+
});
|
|
147
|
+
if (filteredItems.length > 0) {
|
|
148
|
+
index = items.indexOf(filteredItems[0]);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
index = Number(index);
|
|
152
|
+
if (Number.isNaN(index) || index !== Math.floor(index)) {
|
|
153
|
+
warning(false, 'component ElCarouselItem: index must be integer.');
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
var itemCount = items.length;
|
|
157
|
+
var oldIndex = activeIndex;
|
|
158
|
+
if (index < 0) {
|
|
159
|
+
setActiveIndex(loop ? itemCount - 1 : 0);
|
|
160
|
+
} else if (index >= itemCount) {
|
|
161
|
+
setActiveIndex(loop ? 0 : itemCount - 1);
|
|
162
|
+
} else {
|
|
163
|
+
setActiveIndex(index);
|
|
164
|
+
}
|
|
165
|
+
if (oldIndex === activeIndex) {
|
|
166
|
+
resetItemPosition(oldIndex);
|
|
167
|
+
}
|
|
168
|
+
resetTimer();
|
|
169
|
+
}, [activeIndex, isFirstCall, items, loop, resetItemPosition, resetTimer]);
|
|
170
|
+
var throttledArrowClick = useCallback(function (index) {
|
|
171
|
+
setActiveItem(index);
|
|
172
|
+
}, [setActiveItem]);
|
|
173
|
+
var handleIndicatorHover = useCallback(function (index) {
|
|
174
|
+
if (trigger === 'hover' && index !== activeIndex) {
|
|
175
|
+
setActiveIndex(index);
|
|
176
|
+
if (!isFirstCall.current) {
|
|
177
|
+
isTransition.current = true;
|
|
178
|
+
setIsTransitioning(true);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}, [activeIndex, isFirstCall, trigger]);
|
|
182
|
+
var throttledIndicatorHover = useCallback(function (index) {
|
|
183
|
+
handleIndicatorHover(index);
|
|
184
|
+
}, [handleIndicatorHover]);
|
|
185
|
+
var isTwoLengthShow = useCallback(function (index) {
|
|
186
|
+
if (!isItemsTwoLength.current) {
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
return activeIndex <= 1 ? index <= 1 : index > 1;
|
|
190
|
+
}, [activeIndex]);
|
|
191
|
+
var itemInStage = useCallback(function (item, index) {
|
|
192
|
+
var _items$nextItemIndex, _items$prevItemIndex;
|
|
193
|
+
var itemCount = items.length;
|
|
194
|
+
if (itemCount === 0 || !item.states.inStage) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
var nextItemIndex = index + 1;
|
|
198
|
+
var prevItemIndex = index - 1;
|
|
199
|
+
var lastItemIndex = itemCount - 1;
|
|
200
|
+
var isLastItemActive = items[lastItemIndex].states.active;
|
|
201
|
+
var isFirstItemActive = items[0].states.active;
|
|
202
|
+
var isNextItemActive = (_items$nextItemIndex = items[nextItemIndex]) === null || _items$nextItemIndex === void 0 || (_items$nextItemIndex = _items$nextItemIndex.states) === null || _items$nextItemIndex === void 0 ? void 0 : _items$nextItemIndex.active;
|
|
203
|
+
var isPrevItemActive = (_items$prevItemIndex = items[prevItemIndex]) === null || _items$prevItemIndex === void 0 || (_items$prevItemIndex = _items$prevItemIndex.states) === null || _items$prevItemIndex === void 0 ? void 0 : _items$prevItemIndex.active;
|
|
204
|
+
if (index === lastItemIndex && isFirstItemActive || isNextItemActive) {
|
|
205
|
+
return 'left';
|
|
206
|
+
} else if (index === 0 && isLastItemActive || isPrevItemActive) {
|
|
207
|
+
return 'right';
|
|
208
|
+
}
|
|
209
|
+
return false;
|
|
210
|
+
}, [items]);
|
|
211
|
+
var handleMouseEnter = useCallback(function () {
|
|
212
|
+
setHover(true);
|
|
213
|
+
if (pauseOnHover) {
|
|
214
|
+
pauseTimer();
|
|
215
|
+
}
|
|
216
|
+
}, [pauseOnHover, pauseTimer]);
|
|
217
|
+
var handleMouseLeave = useCallback(function () {
|
|
218
|
+
setHover(false);
|
|
219
|
+
startTimer();
|
|
220
|
+
}, [startTimer]);
|
|
221
|
+
var handleTransitionEnd = useCallback(function () {
|
|
222
|
+
isTransition.current = false;
|
|
223
|
+
setIsTransitioning(false);
|
|
224
|
+
}, []);
|
|
225
|
+
var handleButtonEnter = useCallback(function (_arrow) {
|
|
226
|
+
if (isVertical) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
items.forEach(function (item, index) {
|
|
230
|
+
// @ts-ignore
|
|
231
|
+
if (_arrow === itemInStage(item, index)) {
|
|
232
|
+
item.setState({
|
|
233
|
+
hover: true
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}, [isVertical, itemInStage, items]);
|
|
238
|
+
var handleButtonLeave = useCallback(function () {
|
|
239
|
+
if (isVertical) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
items.forEach(function (item) {
|
|
243
|
+
item.setState({
|
|
244
|
+
hover: false
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
}, [isVertical, items]);
|
|
248
|
+
var handleIndicatorClick = function handleIndicatorClick(index) {
|
|
249
|
+
if (index !== activeIndex) {
|
|
250
|
+
if (!isFirstCall.current) {
|
|
251
|
+
isTransition.current = true;
|
|
252
|
+
setIsTransitioning(true);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
setActiveIndex(index);
|
|
256
|
+
};
|
|
257
|
+
var prev = useCallback(function () {
|
|
258
|
+
setActiveItem(activeIndex - 1);
|
|
259
|
+
}, [activeIndex, setActiveItem]);
|
|
260
|
+
var next = useCallback(function () {
|
|
261
|
+
setActiveItem(activeIndex + 1);
|
|
262
|
+
}, [activeIndex, setActiveItem]);
|
|
263
|
+
var setContainerHeight = useCallback(function (_height) {
|
|
264
|
+
if (height !== 'auto') {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
setHeight(_height);
|
|
268
|
+
}, [height]);
|
|
269
|
+
|
|
270
|
+
// const PlaceholderItem=() =>{
|
|
271
|
+
// // fix: https://github.com/element-plus/element-plus/issues/12139
|
|
272
|
+
// const defaultSlots = slots.default?.();
|
|
273
|
+
// if (!defaultSlots) return null;
|
|
274
|
+
|
|
275
|
+
// const flatSlots = flattedChildren(defaultSlots);
|
|
276
|
+
|
|
277
|
+
// const normalizeSlots = flatSlots.filter(slot => {
|
|
278
|
+
// return isVNode(slot) && (slot.type as any).name === CAROUSEL_ITEM_NAME;
|
|
279
|
+
// });
|
|
280
|
+
|
|
281
|
+
// if (normalizeSlots?.length === 2 && loop && !isCardType) {
|
|
282
|
+
// isItemsTwoLength = true;
|
|
283
|
+
// return normalizeSlots;
|
|
284
|
+
// }
|
|
285
|
+
// isItemsTwoLength = false;
|
|
286
|
+
// return null;
|
|
287
|
+
// }
|
|
288
|
+
|
|
289
|
+
useEffect(function () {
|
|
290
|
+
activeIndexRef.current = activeIndex;
|
|
291
|
+
resetItemPosition(preActiveIndex);
|
|
292
|
+
var current, _prev;
|
|
293
|
+
if (isItemsTwoLength.current) {
|
|
294
|
+
current = activeIndex % 2;
|
|
295
|
+
_prev = preActiveIndex % 2;
|
|
296
|
+
}
|
|
297
|
+
if (preActiveIndex > -1) {
|
|
298
|
+
onChange === null || onChange === void 0 || onChange(current, _prev);
|
|
299
|
+
}
|
|
300
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
301
|
+
}, [activeIndex]);
|
|
302
|
+
useEffect(function () {
|
|
303
|
+
setActiveItem(activeIndex);
|
|
304
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
305
|
+
}, [loop]);
|
|
306
|
+
useEffect(function () {
|
|
307
|
+
resetTimer();
|
|
308
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
309
|
+
}, [interval]);
|
|
310
|
+
useEffect(function () {
|
|
311
|
+
if (items.length > 0) {
|
|
312
|
+
setActiveItem(initialIndex);
|
|
313
|
+
}
|
|
314
|
+
itemLen.current = items.length;
|
|
315
|
+
isItemsTwoLength.current = (items === null || items === void 0 ? void 0 : items.length) === 2 && props.loop && !isCardType;
|
|
316
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
317
|
+
}, [items]);
|
|
318
|
+
useEffect(function () {
|
|
319
|
+
if (autoplay) {
|
|
320
|
+
startTimer();
|
|
321
|
+
} else {
|
|
322
|
+
pauseTimer();
|
|
323
|
+
}
|
|
324
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
325
|
+
}, [autoplay, items.length]);
|
|
326
|
+
useEffect(function () {
|
|
327
|
+
if (root.current) {
|
|
328
|
+
resizeObserver.current = new ResizeObserver(function () {
|
|
329
|
+
resetItemPosition();
|
|
330
|
+
});
|
|
331
|
+
resizeObserver.current.observe(root.current);
|
|
332
|
+
startTimer();
|
|
333
|
+
}
|
|
334
|
+
return function () {
|
|
335
|
+
pauseTimer();
|
|
336
|
+
if (resizeObserver.current) {
|
|
337
|
+
resizeObserver.current.disconnect();
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
341
|
+
}, []);
|
|
342
|
+
return {
|
|
343
|
+
items: items,
|
|
344
|
+
addItem: addItem,
|
|
345
|
+
removeItem: removeItem,
|
|
346
|
+
setContainerHeight: setContainerHeight,
|
|
347
|
+
root: root,
|
|
348
|
+
activeIndex: activeIndex,
|
|
349
|
+
arrowDisplay: arrowDisplay,
|
|
350
|
+
hasLabel: hasLabel,
|
|
351
|
+
hover: hover,
|
|
352
|
+
isCardType: isCardType,
|
|
353
|
+
isTransitioning: isTransitioning,
|
|
354
|
+
isVertical: isVertical,
|
|
355
|
+
containerStyle: containerStyle,
|
|
356
|
+
isItemsTwoLength: isItemsTwoLength,
|
|
357
|
+
handleButtonEnter: handleButtonEnter,
|
|
358
|
+
handleTransitionEnd: handleTransitionEnd,
|
|
359
|
+
handleButtonLeave: handleButtonLeave,
|
|
360
|
+
handleIndicatorClick: handleIndicatorClick,
|
|
361
|
+
handleMouseEnter: handleMouseEnter,
|
|
362
|
+
handleMouseLeave: handleMouseLeave,
|
|
363
|
+
setActiveItem: setActiveItem,
|
|
364
|
+
prev: prev,
|
|
365
|
+
next: next,
|
|
366
|
+
// PlaceholderItem,
|
|
367
|
+
isTwoLengthShow: isTwoLengthShow,
|
|
368
|
+
throttledArrowClick: throttle(throttledArrowClick, THROTTLE_TIME, {
|
|
369
|
+
trailing: true
|
|
370
|
+
}),
|
|
371
|
+
throttledIndicatorHover: throttle(throttledIndicatorHover, THROTTLE_TIME)
|
|
372
|
+
};
|
|
373
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CarouselItemProps, CarouselItemStates } from '../typings';
|
|
3
|
+
export declare const useCarouselItem: (props: CarouselItemProps) => {
|
|
4
|
+
carouselItemRef: import("react").MutableRefObject<HTMLDivElement>;
|
|
5
|
+
state: CarouselItemStates;
|
|
6
|
+
setState: (_state: Partial<CarouselItemStates>) => void;
|
|
7
|
+
handleItemClick: () => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
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); }
|
|
5
|
+
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; }
|
|
6
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
|
+
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); }
|
|
13
|
+
import omit from 'lodash/omit';
|
|
14
|
+
import { useCallback, useEffect, useId, useImperativeHandle, useReducer, useRef } from 'react';
|
|
15
|
+
import { useCarouselContext } from "../CarouselContext";
|
|
16
|
+
export var useCarouselItem = function useCarouselItem(props) {
|
|
17
|
+
var _useCarouselContext = useCarouselContext(),
|
|
18
|
+
isCardType = _useCarouselContext.isCardType,
|
|
19
|
+
loop = _useCarouselContext.loop,
|
|
20
|
+
isVertical = _useCarouselContext.isVertical,
|
|
21
|
+
cardScale = _useCarouselContext.cardScale,
|
|
22
|
+
root = _useCarouselContext.root,
|
|
23
|
+
items = _useCarouselContext.items,
|
|
24
|
+
addItem = _useCarouselContext.addItem,
|
|
25
|
+
removeItem = _useCarouselContext.removeItem,
|
|
26
|
+
setActiveItem = _useCarouselContext.setActiveItem,
|
|
27
|
+
setContainerHeight = _useCarouselContext.setContainerHeight;
|
|
28
|
+
var id = useId();
|
|
29
|
+
var carouselItemRef = useRef(null);
|
|
30
|
+
var ref = useRef(null);
|
|
31
|
+
var reducer = function reducer(state, action) {
|
|
32
|
+
switch (action.type) {
|
|
33
|
+
case 'setState':
|
|
34
|
+
return _objectSpread(_objectSpread({}, state), action.payload);
|
|
35
|
+
default:
|
|
36
|
+
return state;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var _useReducer = useReducer(reducer, {
|
|
40
|
+
ready: false,
|
|
41
|
+
hover: false,
|
|
42
|
+
translate: 0,
|
|
43
|
+
scale: 1,
|
|
44
|
+
animating: false,
|
|
45
|
+
active: false,
|
|
46
|
+
inStage: false
|
|
47
|
+
}),
|
|
48
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
49
|
+
state = _useReducer2[0],
|
|
50
|
+
dispatch = _useReducer2[1];
|
|
51
|
+
var setState = function setState(_state) {
|
|
52
|
+
return dispatch({
|
|
53
|
+
type: 'setState',
|
|
54
|
+
payload: _state
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
var calcCardTranslate = useCallback(function (index, activeIndex, inStage) {
|
|
58
|
+
var _root$current, _root$current2;
|
|
59
|
+
var parentWidth = isVertical ? ((_root$current = root.current) === null || _root$current === void 0 ? void 0 : _root$current.offsetHeight) || 0 : ((_root$current2 = root.current) === null || _root$current2 === void 0 ? void 0 : _root$current2.offsetWidth) || 0;
|
|
60
|
+
if (inStage) {
|
|
61
|
+
return parentWidth * ((2 - cardScale) * (index - activeIndex) + 1) / 4;
|
|
62
|
+
} else if (index < activeIndex) {
|
|
63
|
+
return -(1 + cardScale) * parentWidth / 4;
|
|
64
|
+
} else {
|
|
65
|
+
return (3 + cardScale) * parentWidth / 4;
|
|
66
|
+
}
|
|
67
|
+
}, [cardScale, isVertical, root]);
|
|
68
|
+
var calcTranslate = useCallback(function (index, activeIndex) {
|
|
69
|
+
var rootEl = root.current;
|
|
70
|
+
if (!rootEl) {
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
|
73
|
+
var distance = (isVertical ? rootEl.offsetHeight : rootEl.offsetWidth) || 0;
|
|
74
|
+
return distance * (index - activeIndex);
|
|
75
|
+
}, [isVertical, root]);
|
|
76
|
+
var translateItem = useCallback(function (index, activeIndex, oldIndex) {
|
|
77
|
+
var _items$length;
|
|
78
|
+
var carouselItemLength = (_items$length = items.length) !== null && _items$length !== void 0 ? _items$length : Number.NaN;
|
|
79
|
+
var isActive = index === activeIndex;
|
|
80
|
+
if (!isCardType && oldIndex != undefined) {
|
|
81
|
+
setState({
|
|
82
|
+
animating: isActive || index === oldIndex
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (!isActive && carouselItemLength > 2 && loop) {
|
|
86
|
+
index = processIndex(index, activeIndex, carouselItemLength);
|
|
87
|
+
}
|
|
88
|
+
setState({
|
|
89
|
+
active: isActive
|
|
90
|
+
});
|
|
91
|
+
if (isCardType) {
|
|
92
|
+
var inStage = Math.round(Math.abs(index - activeIndex)) <= 1;
|
|
93
|
+
setState({
|
|
94
|
+
inStage: inStage,
|
|
95
|
+
translate: calcCardTranslate(index, activeIndex, inStage),
|
|
96
|
+
scale: isActive ? 1 : cardScale
|
|
97
|
+
});
|
|
98
|
+
} else {
|
|
99
|
+
setState({
|
|
100
|
+
translate: calcTranslate(index, activeIndex)
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
setState({
|
|
104
|
+
ready: true
|
|
105
|
+
});
|
|
106
|
+
if (isActive && carouselItemRef.current) {
|
|
107
|
+
setContainerHeight(carouselItemRef.current.offsetHeight);
|
|
108
|
+
}
|
|
109
|
+
}, [calcCardTranslate, calcTranslate, cardScale, isCardType, items, loop, setContainerHeight]);
|
|
110
|
+
var handleItemClick = useCallback(function () {
|
|
111
|
+
if (isCardType) {
|
|
112
|
+
var index = items.findIndex(function (_ref) {
|
|
113
|
+
var uid = _ref.uid;
|
|
114
|
+
return uid === id;
|
|
115
|
+
});
|
|
116
|
+
setActiveItem(index);
|
|
117
|
+
}
|
|
118
|
+
}, [id, isCardType, items, setActiveItem]);
|
|
119
|
+
useImperativeHandle(ref, function () {
|
|
120
|
+
return {
|
|
121
|
+
translateItem: translateItem
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
useEffect(function () {
|
|
125
|
+
addItem({
|
|
126
|
+
props: omit(props, 'children'),
|
|
127
|
+
states: state,
|
|
128
|
+
setState: setState,
|
|
129
|
+
uid: id,
|
|
130
|
+
translateItem: function translateItem() {
|
|
131
|
+
var _ref$current;
|
|
132
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
133
|
+
args[_key] = arguments[_key];
|
|
134
|
+
}
|
|
135
|
+
return ref === null || ref === void 0 || (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.translateItem.apply(_ref$current, args);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
return function () {
|
|
139
|
+
return removeItem(id);
|
|
140
|
+
};
|
|
141
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
142
|
+
}, []);
|
|
143
|
+
return {
|
|
144
|
+
carouselItemRef: carouselItemRef,
|
|
145
|
+
state: state,
|
|
146
|
+
setState: setState,
|
|
147
|
+
handleItemClick: handleItemClick
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
var processIndex = function processIndex(index, activeIndex, length) {
|
|
151
|
+
var lastItemIndex = length - 1;
|
|
152
|
+
var prevItemIndex = activeIndex - 1;
|
|
153
|
+
var nextItemIndex = activeIndex + 1;
|
|
154
|
+
var halfItemIndex = length / 2;
|
|
155
|
+
if (activeIndex === 0 && index === lastItemIndex) {
|
|
156
|
+
return -1;
|
|
157
|
+
} else if (activeIndex === lastItemIndex && index === 0) {
|
|
158
|
+
return length;
|
|
159
|
+
} else if (index < prevItemIndex && activeIndex - index >= halfItemIndex) {
|
|
160
|
+
return length + 1;
|
|
161
|
+
} else if (index > nextItemIndex && index - activeIndex >= halfItemIndex) {
|
|
162
|
+
return -2;
|
|
163
|
+
}
|
|
164
|
+
return index;
|
|
165
|
+
};
|