@onesy/ui-react 1.0.130 → 1.0.131
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/Accordion/Accordion.js +342 -242
- package/Accordion/index.js +12 -7
- package/AdvancedTextField/AdvancedTextField.js +165 -157
- package/AdvancedTextField/index.js +12 -7
- package/Append/Append.js +502 -519
- package/Append/index.js +12 -7
- package/AreaChart/AreaChart.js +53 -40
- package/AreaChart/index.js +12 -7
- package/AreaChartItem/AreaChartItem.js +325 -237
- package/AreaChartItem/index.js +12 -7
- package/AudioPlayer/AudioPlayer.js +683 -466
- package/AudioPlayer/index.js +12 -7
- package/AudioRecorder/AudioRecorder.js +359 -259
- package/AudioRecorder/index.js +12 -7
- package/AutoComplete/AutoComplete.js +693 -568
- package/AutoComplete/index.js +12 -7
- package/AutoCompleteCountry/AutoCompleteCountry.js +99 -62
- package/AutoCompleteCountry/index.js +12 -7
- package/AutoCompleteCurrency/AutoCompleteCurrency.js +73 -61
- package/AutoCompleteCurrency/index.js +12 -7
- package/Avatar/Avatar.js +113 -86
- package/Avatar/index.js +12 -7
- package/AvatarGroup/AvatarGroup.js +104 -87
- package/AvatarGroup/index.js +12 -7
- package/Backdrop/Backdrop.js +160 -139
- package/Backdrop/index.js +12 -7
- package/Badge/Badge.js +116 -96
- package/Badge/index.js +12 -7
- package/Banner/Banner.js +126 -85
- package/Banner/index.js +12 -7
- package/BottomAppBar/BottomAppBar.js +89 -60
- package/BottomAppBar/index.js +12 -7
- package/BottomSheet/BottomSheet.js +66 -59
- package/BottomSheet/index.js +12 -7
- package/Box/Box.js +43 -35
- package/Box/index.js +12 -7
- package/Breadcrumbs/Breadcrumbs.js +168 -144
- package/Breadcrumbs/index.js +12 -7
- package/BubbleChart/BubbleChart.js +261 -132
- package/BubbleChart/index.js +12 -7
- package/BubbleChartItem/BubbleChartItem.js +228 -161
- package/BubbleChartItem/index.js +12 -7
- package/Button/Button.js +488 -467
- package/Button/index.js +12 -7
- package/Buttons/Buttons.js +366 -293
- package/Buttons/index.js +12 -7
- package/Calendar/Calendar.js +715 -452
- package/Calendar/index.js +12 -7
- package/CalendarAvailability/CalendarAvailability.js +709 -388
- package/CalendarAvailability/index.js +12 -7
- package/CalendarMenu/CalendarMenu.js +430 -303
- package/CalendarMenu/index.js +12 -7
- package/CalendarMonth/CalendarMonth.js +537 -498
- package/CalendarMonth/index.js +12 -7
- package/CalendarViews/CalendarViews.js +403 -254
- package/CalendarViews/index.js +12 -7
- package/CalendarWeek/CalendarWeek.js +536 -395
- package/CalendarWeek/index.js +12 -7
- package/Card/Card.js +133 -101
- package/Card/index.js +12 -7
- package/CardButton/CardButton.js +78 -58
- package/CardButton/index.js +12 -7
- package/CardFooter/CardFooter.js +58 -39
- package/CardFooter/index.js +12 -7
- package/CardHeader/CardHeader.js +61 -44
- package/CardHeader/index.js +12 -7
- package/CardImage/CardImage.js +80 -67
- package/CardImage/index.js +12 -7
- package/CardMain/CardMain.js +53 -39
- package/CardMain/index.js +12 -7
- package/Carousel/Carousel.js +1025 -913
- package/Carousel/index.js +12 -7
- package/Chart/Chart.js +1325 -1174
- package/Chart/index.js +12 -7
- package/Checkbox/Checkbox.js +339 -325
- package/Checkbox/index.js +12 -7
- package/Chip/Chip.js +131 -102
- package/Chip/index.js +12 -7
- package/Chips/Chips.js +121 -94
- package/Chips/index.js +12 -7
- package/ClickListener/ClickListener.js +86 -89
- package/ClickListener/index.js +12 -7
- package/Clock/Clock.js +470 -417
- package/Clock/index.js +12 -7
- package/ColorTextField/ColorTextField.js +234 -171
- package/ColorTextField/index.js +12 -7
- package/ColumnChart/ColumnChart.js +63 -46
- package/ColumnChart/index.js +12 -7
- package/ColumnChartItem/ColumnChartItem.js +208 -149
- package/ColumnChartItem/index.js +12 -7
- package/Confirm/Confirm.js +184 -129
- package/Confirm/Context.js +9 -7
- package/Confirm/index.js +32 -13
- package/Confirm/useConfirm.js +11 -10
- package/Container/Container.js +154 -133
- package/Container/index.js +12 -7
- package/CookieBanner/CookieBanner.js +142 -76
- package/CookieBanner/index.js +12 -7
- package/Countdown/Countdown.js +403 -255
- package/Countdown/index.js +12 -7
- package/DatePicker/DatePicker.js +802 -547
- package/DatePicker/index.js +12 -7
- package/DateRangePicker/DateRangePicker.js +44 -37
- package/DateRangePicker/index.js +12 -7
- package/DateTimePicker/DateTimePicker.js +672 -459
- package/DateTimePicker/index.js +12 -7
- package/DateTimeRangePicker/DateTimeRangePicker.js +44 -37
- package/DateTimeRangePicker/index.js +12 -7
- package/Divider/Divider.js +198 -185
- package/Divider/index.js +12 -7
- package/DonutChart/DonutChart.js +49 -42
- package/DonutChart/index.js +12 -7
- package/DragAndDropList/DragAndDropList.js +160 -156
- package/DragAndDropList/index.js +12 -7
- package/Drawing/Drawing.js +850 -523
- package/Drawing/index.js +12 -7
- package/DropZone/DropZone.js +239 -201
- package/DropZone/index.js +12 -7
- package/Emojis/Emojis.js +409 -317
- package/Emojis/emojis_list.js +7279 -9250
- package/Emojis/index.js +19 -9
- package/Expand/Expand.js +201 -149
- package/Expand/index.js +12 -7
- package/Fab/Fab.js +46 -26
- package/Fab/index.js +12 -7
- package/Fade/Fade.js +131 -101
- package/Fade/index.js +12 -7
- package/FileChoose/FileChoose.js +218 -150
- package/FileChoose/index.js +12 -7
- package/Focus/Focus.js +87 -88
- package/Focus/index.js +12 -7
- package/Form/Form.js +194 -120
- package/Form/index.js +12 -7
- package/FormRow/FormRow.js +123 -78
- package/FormRow/index.js +12 -7
- package/Forms/Forms.js +55 -41
- package/Forms/index.js +12 -7
- package/Frame/Frame.js +212 -150
- package/Frame/index.js +12 -7
- package/Grid/Grid.js +231 -166
- package/Grid/index.js +12 -7
- package/Grow/Grow.js +137 -109
- package/Grow/index.js +12 -7
- package/HTMLCanvas/HTMLCanvas.js +752 -542
- package/HTMLCanvas/index.js +24 -21
- package/IFrame/IFrame.js +122 -104
- package/IFrame/index.js +12 -7
- package/Icon/Icon.js +112 -95
- package/Icon/index.js +24 -21
- package/IconButton/IconButton.js +49 -37
- package/IconButton/index.js +12 -7
- package/Image/Image.js +285 -252
- package/Image/index.js +12 -7
- package/ImageCrop/ImageCrop.js +1073 -1048
- package/ImageCrop/index.js +12 -7
- package/ImageEdit/ImageEdit.js +1088 -783
- package/ImageEdit/index.js +12 -7
- package/ImageGallery/ImageGallery.js +518 -473
- package/ImageGallery/index.js +12 -7
- package/ImageList/ImageList.js +136 -129
- package/ImageList/index.js +12 -7
- package/ImageListItem/ImageListItem.js +101 -87
- package/ImageListItem/index.js +12 -7
- package/ImageListItemBox/ImageListItemBox.js +61 -50
- package/ImageListItemBox/index.js +12 -7
- package/Info/Info.js +99 -63
- package/Info/index.js +12 -7
- package/Interaction/Interaction.js +405 -345
- package/Interaction/index.js +12 -7
- package/Keyframes/Context.js +9 -7
- package/Keyframes/Keyframes.js +189 -174
- package/Keyframes/index.js +42 -25
- package/Keyframes/useKeyframes.js +11 -10
- package/Label/Label.js +177 -151
- package/Label/index.js +12 -7
- package/Labels/Labels.js +126 -98
- package/Labels/index.js +12 -7
- package/Line/Line.js +296 -174
- package/Line/index.js +12 -7
- package/LineChart/LineChart.js +57 -40
- package/LineChart/index.js +12 -7
- package/LineChartItem/LineChartItem.js +239 -177
- package/LineChartItem/index.js +12 -7
- package/LinearMeter/LinearMeter.js +453 -377
- package/LinearMeter/index.js +12 -7
- package/LinearProgress/LinearProgress.js +324 -255
- package/LinearProgress/index.js +12 -7
- package/Link/Link.js +182 -127
- package/Link/index.js +12 -7
- package/Links/Links.js +277 -156
- package/Links/index.js +12 -7
- package/List/List.js +148 -113
- package/List/index.js +12 -7
- package/ListItem/ListItem.js +388 -362
- package/ListItem/index.js +12 -7
- package/ListSubheader/ListSubheader.js +52 -44
- package/ListSubheader/index.js +12 -7
- package/MainProgress/Context.js +9 -7
- package/MainProgress/MainProgress.js +193 -161
- package/MainProgress/index.js +32 -13
- package/MainProgress/useMainProgress.js +11 -10
- package/Markdown/Markdown.js +676 -704
- package/Markdown/index.js +12 -7
- package/Masonry/Masonry.js +207 -181
- package/Masonry/index.js +12 -7
- package/Medias/Medias.js +436 -398
- package/Medias/index.js +12 -7
- package/Menu/Menu.js +278 -243
- package/Menu/index.js +12 -7
- package/MenuDesktop/MenuDesktop.js +496 -419
- package/MenuDesktop/index.js +12 -7
- package/MenuItem/MenuItem.js +286 -231
- package/MenuItem/index.js +12 -7
- package/Meta/Meta.js +78 -54
- package/Meta/index.js +12 -7
- package/Modal/Modal.js +333 -272
- package/Modal/index.js +12 -7
- package/ModalFooter/ModalFooter.js +50 -39
- package/ModalFooter/index.js +12 -7
- package/ModalHeader/ModalHeader.js +51 -39
- package/ModalHeader/index.js +12 -7
- package/ModalIcon/ModalIcon.js +29 -23
- package/ModalIcon/index.js +12 -7
- package/ModalMain/ModalMain.js +50 -41
- package/ModalMain/index.js +12 -7
- package/ModalText/ModalText.js +47 -37
- package/ModalText/index.js +12 -7
- package/ModalTitle/ModalTitle.js +47 -37
- package/ModalTitle/index.js +12 -7
- package/MoreOptions/MoreOptions.js +72 -52
- package/MoreOptions/index.js +12 -7
- package/Move/Move.js +166 -141
- package/Move/index.js +12 -7
- package/NavigationBar/NavigationBar.js +133 -109
- package/NavigationBar/index.js +12 -7
- package/NavigationDrawer/NavigationDrawer.js +241 -211
- package/NavigationDrawer/index.js +12 -7
- package/NavigationItem/NavigationItem.js +293 -262
- package/NavigationItem/index.js +12 -7
- package/NavigationRail/NavigationRail.js +187 -150
- package/NavigationRail/index.js +12 -7
- package/NotFound/NotFound.js +89 -66
- package/NotFound/index.js +12 -7
- package/NumericTextField/NumericTextField.js +217 -212
- package/NumericTextField/index.js +12 -7
- package/Page/Page.js +131 -67
- package/Page/index.js +12 -7
- package/PageTransition/PageTransition.js +112 -102
- package/PageTransition/index.js +12 -7
- package/Pagination/Pagination.js +153 -98
- package/Pagination/index.js +12 -7
- package/PaginationItem/PaginationItem.js +85 -65
- package/PaginationItem/index.js +12 -7
- package/Parallax/Parallax.js +138 -145
- package/Parallax/index.js +12 -7
- package/Path/Path.js +40 -35
- package/Path/index.js +12 -7
- package/PieChart/PieChart.js +382 -267
- package/PieChart/index.js +12 -7
- package/Placeholder/Placeholder.js +125 -117
- package/Placeholder/index.js +12 -7
- package/Portal/Portal.js +37 -38
- package/Portal/index.js +12 -7
- package/Properties/Properties.js +85 -64
- package/Properties/index.js +12 -7
- package/Property/Property.js +120 -108
- package/Property/index.js +12 -7
- package/Radio/Radio.js +211 -181
- package/Radio/index.js +12 -7
- package/Radios/Radios.js +124 -92
- package/Radios/index.js +12 -7
- package/Rating/Rating.js +353 -360
- package/Rating/index.js +12 -7
- package/Reset/Reset.js +19 -24
- package/Reset/index.js +12 -7
- package/Reveal/Reveal.js +98 -89
- package/Reveal/index.js +12 -7
- package/RichTextEditor/RichTextEditor.js +1764 -972
- package/RichTextEditor/index.js +12 -7
- package/RoundMeter/RoundMeter.js +629 -537
- package/RoundMeter/index.js +12 -7
- package/RoundProgress/RoundProgress.js +233 -174
- package/RoundProgress/index.js +12 -7
- package/ScatterChart/ScatterChart.js +53 -40
- package/ScatterChart/index.js +12 -7
- package/ScatterChartItem/ScatterChartItem.js +214 -153
- package/ScatterChartItem/index.js +12 -7
- package/ScreenCapture/ScreenCapture.js +427 -335
- package/ScreenCapture/index.js +12 -7
- package/Section/Section.js +380 -319
- package/Section/index.js +12 -7
- package/SectionAction/SectionAction.js +72 -61
- package/SectionAction/index.js +12 -7
- package/SectionBoxes/SectionBoxes.js +240 -208
- package/SectionBoxes/index.js +12 -7
- package/SectionCards/SectionCards.js +256 -217
- package/SectionCards/index.js +12 -7
- package/SectionCarousel/SectionCarousel.js +284 -242
- package/SectionCarousel/index.js +12 -7
- package/SectionContact/SectionContact.js +174 -116
- package/SectionContact/index.js +12 -7
- package/SectionImageGallery/SectionImageGallery.js +64 -51
- package/SectionImageGallery/index.js +12 -7
- package/SectionLogos/SectionLogos.js +123 -109
- package/SectionLogos/index.js +12 -7
- package/SectionMedia/SectionMedia.js +170 -152
- package/SectionMedia/index.js +12 -7
- package/SectionReviews/SectionReviews.js +170 -129
- package/SectionReviews/index.js +12 -7
- package/SectionTextMedia/SectionTextMedia.js +187 -142
- package/SectionTextMedia/index.js +12 -7
- package/SectionTimeline/SectionTimeline.js +126 -95
- package/SectionTimeline/index.js +12 -7
- package/SectionWatch/SectionWatch.js +65 -53
- package/SectionWatch/index.js +12 -7
- package/Select/Select.js +517 -406
- package/Select/index.js +12 -7
- package/Share/Share.js +458 -319
- package/Share/index.js +12 -7
- package/Slide/Slide.js +184 -140
- package/Slide/index.js +12 -7
- package/Slider/Slider.js +927 -837
- package/Slider/index.js +12 -7
- package/SmartTextField/SmartTextField.js +1406 -1014
- package/SmartTextField/index.js +12 -7
- package/Snackbar/Snackbar.js +227 -185
- package/Snackbar/index.js +12 -7
- package/Snackbars/Context.js +9 -7
- package/Snackbars/Snackbars.js +234 -210
- package/Snackbars/index.js +32 -13
- package/Snackbars/useSnackbars.js +11 -10
- package/Space/Space.js +1683 -968
- package/Space/index.js +24 -21
- package/SpeechToText/SpeechToText.js +207 -172
- package/SpeechToText/index.js +12 -7
- package/SpeedDial/SpeedDial.js +434 -398
- package/SpeedDial/index.js +12 -7
- package/SpeedDialItem/SpeedDialItem.js +89 -63
- package/SpeedDialItem/index.js +12 -7
- package/SpyScroll/SpyScroll.js +154 -142
- package/SpyScroll/index.js +12 -7
- package/Step/Step.js +181 -127
- package/Step/index.js +12 -7
- package/Stepper/Stepper.js +159 -139
- package/Stepper/index.js +12 -7
- package/Surface/Surface.js +760 -798
- package/Surface/index.js +12 -7
- package/Switch/Switch.js +688 -532
- package/Switch/index.js +12 -7
- package/Tab/Tab.js +185 -150
- package/Tab/index.js +12 -7
- package/Table/Table.js +100 -77
- package/Table/index.js +12 -7
- package/TableBody/TableBody.js +76 -63
- package/TableBody/index.js +12 -7
- package/TableCell/TableCell.js +258 -220
- package/TableCell/index.js +12 -7
- package/TableFooter/TableFooter.js +60 -48
- package/TableFooter/index.js +12 -7
- package/TableHead/TableHead.js +139 -120
- package/TableHead/index.js +12 -7
- package/TableHeader/TableHeader.js +65 -50
- package/TableHeader/index.js +12 -7
- package/TablePagination/TablePagination.js +171 -98
- package/TablePagination/index.js +12 -7
- package/TableRow/TableRow.js +77 -64
- package/TableRow/index.js +12 -7
- package/Tabs/Tabs.js +425 -377
- package/Tabs/index.js +12 -7
- package/Text/Text.js +131 -113
- package/Text/index.js +12 -7
- package/TextField/TextField.js +940 -879
- package/TextField/index.js +12 -7
- package/TextToSpeech/TextToSpeech.js +176 -153
- package/TextToSpeech/index.js +12 -7
- package/TimePicker/TimePicker.js +985 -718
- package/TimePicker/index.js +12 -7
- package/TimeRangePicker/TimeRangePicker.js +44 -37
- package/TimeRangePicker/index.js +12 -7
- package/Timeline/Timeline.js +54 -42
- package/Timeline/index.js +12 -7
- package/TimelineItem/TimelineItem.js +144 -147
- package/TimelineItem/index.js +12 -7
- package/Timer/Timer.js +321 -204
- package/Timer/index.js +12 -7
- package/ToggleButton/ToggleButton.js +67 -58
- package/ToggleButton/index.js +12 -7
- package/ToggleButtons/ToggleButtons.js +46 -37
- package/ToggleButtons/index.js +12 -7
- package/Tooltip/Tooltip.js +489 -454
- package/Tooltip/index.js +12 -7
- package/TopAppBar/TopAppBar.js +237 -197
- package/TopAppBar/index.js +12 -7
- package/Transition/Context.js +9 -7
- package/Transition/Transition.js +321 -339
- package/Transition/index.js +42 -25
- package/Transition/useTransition.js +11 -10
- package/Transitions/Transitions.js +215 -179
- package/Transitions/index.js +12 -7
- package/Tree/Tree.js +375 -312
- package/Tree/index.js +12 -7
- package/Type/Type.js +251 -152
- package/Type/index.js +12 -7
- package/VideoPlayer/VideoPlayer.js +866 -656
- package/VideoPlayer/index.js +12 -7
- package/ViewSplit/ViewSplit.js +413 -387
- package/ViewSplit/index.js +12 -7
- package/Watch/Watch.js +436 -290
- package/Watch/index.js +12 -7
- package/Weather/Weather.js +294 -247
- package/Weather/index.js +12 -7
- package/Whiteboard/Whiteboard.js +1392 -1292
- package/Whiteboard/index.js +12 -7
- package/Widgets/Context.js +9 -7
- package/Widgets/Widgets.js +220 -168
- package/Widgets/index.js +32 -13
- package/Widgets/useWidgets.js +11 -10
- package/WindowSplit/WindowSplit.js +381 -336
- package/WindowSplit/index.js +12 -7
- package/Zoom/Zoom.js +126 -99
- package/Zoom/index.js +12 -7
- package/esm/Buttons/Buttons.js +1 -1
- package/esm/index.js +1 -1
- package/index.js +4053 -660
- package/package.json +1 -1
- package/types.js +4 -1
- package/useForm/index.js +25 -11
- package/useForm/useForm.js +203 -174
- package/useForm/validate.js +215 -203
- package/useLocation/index.js +12 -7
- package/useLocation/useLocation.js +54 -49
- package/useMediaQuery/index.js +12 -7
- package/useMediaQuery/useMediaQuery.js +44 -43
- package/useQuery/index.js +12 -7
- package/useQuery/useQuery.js +14 -10
- package/useScroll/index.js +12 -7
- package/useScroll/useScroll.js +61 -56
- package/useSubscription/index.js +12 -7
- package/useSubscription/useSubscription.js +35 -35
- package/useSwipe/index.js +12 -7
- package/useSwipe/useSwipe.js +157 -131
- package/useVisible/index.js +12 -7
- package/useVisible/useVisible.js +86 -76
- package/utils.js +1224 -1362
package/Carousel/Carousel.js
CHANGED
|
@@ -1,935 +1,1047 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
flex: '0 0 auto',
|
|
44
|
-
'& img': {
|
|
45
|
-
width: 'auto',
|
|
46
|
-
maxHeight: '100%'
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
item_transition: {
|
|
50
|
-
position: 'absolute',
|
|
51
|
-
width: '100%',
|
|
52
|
-
height: '100%',
|
|
53
|
-
'& img': {
|
|
54
|
-
width: 'auto',
|
|
55
|
-
maxHeight: '100%'
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
item_version_regular_autoHeight: {
|
|
59
|
-
width: '100%',
|
|
60
|
-
height: 'unset'
|
|
61
|
-
},
|
|
62
|
-
item_version_transition_autoHeight: {
|
|
63
|
-
width: '100%',
|
|
64
|
-
height: 'unset'
|
|
65
|
-
},
|
|
66
|
-
item_itemSize_auto: {
|
|
67
|
-
width: 'auto',
|
|
68
|
-
height: 'auto'
|
|
69
|
-
},
|
|
70
|
-
background: {
|
|
71
|
-
width: '100%',
|
|
72
|
-
height: '100%',
|
|
73
|
-
backgroundRepeat: 'no-repeat',
|
|
74
|
-
backgroundPosition: 'center',
|
|
75
|
-
backgroundSize: 'cover'
|
|
76
|
-
},
|
|
77
|
-
carousel: {
|
|
78
|
-
position: 'relative',
|
|
79
|
-
width: '100%',
|
|
80
|
-
height: '100%',
|
|
81
|
-
touchAction: 'none'
|
|
82
|
-
},
|
|
83
|
-
carousel_version_regular: {
|
|
84
|
-
transition: theme.methods.transitions.make('transform')
|
|
85
|
-
},
|
|
86
|
-
progress: {
|
|
87
|
-
position: 'absolute'
|
|
88
|
-
},
|
|
89
|
-
progress_orientation_horizontal: {
|
|
90
|
-
width: '100%',
|
|
91
|
-
left: '50%',
|
|
92
|
-
transform: 'translateX(-50%)',
|
|
93
|
-
bottom: '24px'
|
|
94
|
-
},
|
|
95
|
-
progress_orientation_vertical: {
|
|
96
|
-
height: '100%',
|
|
97
|
-
top: '50%',
|
|
98
|
-
transform: 'translateY(-50%)',
|
|
99
|
-
right: '24px'
|
|
100
|
-
},
|
|
101
|
-
progress_item: {
|
|
102
|
-
width: '5px',
|
|
103
|
-
height: '5px',
|
|
104
|
-
backgroundColor: 'currentColor',
|
|
105
|
-
borderRadius: theme.methods.shape.radius.value(40, 'px'),
|
|
106
|
-
cursor: 'pointer',
|
|
107
|
-
transition: theme.methods.transitions.make('transform'),
|
|
108
|
-
'&:hover': {
|
|
109
|
-
transform: 'scale(1.4)'
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
progress_item_active: {
|
|
113
|
-
transform: 'scale(1.7)'
|
|
114
|
-
},
|
|
115
|
-
arrow: {
|
|
116
|
-
position: 'absolute !important'
|
|
117
|
-
},
|
|
118
|
-
arrow_previous: {},
|
|
119
|
-
arrow_previous_orientation_horizontal: {
|
|
120
|
-
top: '50%',
|
|
121
|
-
transform: 'translateY(-50%)',
|
|
122
|
-
left: '24px'
|
|
123
|
-
},
|
|
124
|
-
arrow_previous_orientation_vertical: {
|
|
125
|
-
left: '50%',
|
|
126
|
-
transform: 'translateX(-50%)',
|
|
127
|
-
top: '24px'
|
|
128
|
-
},
|
|
129
|
-
arrow_next: {},
|
|
130
|
-
arrow_next_orientation_horizontal: {
|
|
131
|
-
top: '50%',
|
|
132
|
-
transform: 'translateY(-50%)',
|
|
133
|
-
right: '24px'
|
|
134
|
-
},
|
|
135
|
-
arrow_next_orientation_vertical: {
|
|
136
|
-
left: '50%',
|
|
137
|
-
transform: 'translateX(-50%)',
|
|
138
|
-
bottom: '24px'
|
|
139
|
-
},
|
|
140
|
-
icon_previous_orientation_vertical: {
|
|
141
|
-
transform: 'rotate(90deg)'
|
|
142
|
-
},
|
|
143
|
-
icon_next_orientation_vertical: {
|
|
144
|
-
transform: 'rotate(90deg)'
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _react = _interopRequireDefault(require("react"));
|
|
12
|
+
var _utils = require("@onesy/utils");
|
|
13
|
+
var _styleReact = require("@onesy/style-react");
|
|
14
|
+
var _IconMaterialNavigateBeforeW = _interopRequireDefault(require("@onesy/icons-material-rounded-react/IconMaterialNavigateBeforeW100"));
|
|
15
|
+
var _IconMaterialNavigateNextW = _interopRequireDefault(require("@onesy/icons-material-rounded-react/IconMaterialNavigateNextW100"));
|
|
16
|
+
var _Line = _interopRequireDefault(require("../Line"));
|
|
17
|
+
var _Fade = _interopRequireDefault(require("../Fade"));
|
|
18
|
+
var _IconButton = _interopRequireDefault(require("../IconButton"));
|
|
19
|
+
var _Transitions = _interopRequireDefault(require("../Transitions"));
|
|
20
|
+
var _Surface = _interopRequireDefault(require("../Surface"));
|
|
21
|
+
var _useMediaQuery = _interopRequireDefault(require("../useMediaQuery"));
|
|
22
|
+
var _utils2 = require("../utils");
|
|
23
|
+
const _excluded = ["tonal", "color", "version", "valueDefault", "value", "onChange", "id", "items", "orientation", "itemSize", "gap", "move", "moveValue", "moveItems", "moveBeyondEdge", "free", "swipe", "background", "index", "autoPlay", "autoHeight", "autoHeightDelay", "autoPlayInterval", "pauseOnHover", "round", "arrows", "mouseScroll", "momentum", "previousSub", "nextSub", "updateSub", "arrowsVisibility", "arrowHideOnStartEnd", "renderProgress", "renderArrowPrevious", "renderArrowNext", "progress", "progressVisibility", "start", "end", "noTransition", "onUpdatePosition", "onInit", "onUpdateItems", "onBlur", "onFocus", "onMouseEnter", "onMouseLeave", "TransitionComponent", "ProgressTransitionComponent", "ArrowTransitionComponent", "ArrowPreviousTransitionComponent", "ArrowNextTransitionComponent", "IconButtonPrevious", "IconButtonNext", "IconPrevious", "IconNext", "ArrowProps", "ArrowPreviousProps", "ArrowNextProps", "CarouselProps", "TransitionsProps", "TransitionComponentProps", "ArrowTransitionComponentProps", "ArrowPreviousTransitionComponentProps", "ArrowNextTransitionComponentProps", "ProgressTransitionComponentProps", "ItemWrapperProps", "Component", "className", "children"];
|
|
24
|
+
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; }
|
|
25
|
+
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) { (0, _defineProperty2.default)(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; }
|
|
26
|
+
const useStyle = (0, _styleReact.style)(theme => ({
|
|
27
|
+
root: {
|
|
28
|
+
position: 'relative',
|
|
29
|
+
width: '100%',
|
|
30
|
+
height: '540px',
|
|
31
|
+
overflow: 'hidden'
|
|
32
|
+
},
|
|
33
|
+
autoHeight: {
|
|
34
|
+
transition: theme.methods.transitions.make('height')
|
|
35
|
+
},
|
|
36
|
+
item: {
|
|
37
|
+
width: '100%',
|
|
38
|
+
height: '100%',
|
|
39
|
+
flex: '0 0 auto',
|
|
40
|
+
'& img': {
|
|
41
|
+
width: 'auto',
|
|
42
|
+
maxHeight: '100%'
|
|
145
43
|
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
44
|
+
},
|
|
45
|
+
item_transition: {
|
|
46
|
+
position: 'absolute',
|
|
47
|
+
width: '100%',
|
|
48
|
+
height: '100%',
|
|
49
|
+
'& img': {
|
|
50
|
+
width: 'auto',
|
|
51
|
+
maxHeight: '100%'
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
item_version_regular_autoHeight: {
|
|
55
|
+
width: '100%',
|
|
56
|
+
height: 'unset'
|
|
57
|
+
},
|
|
58
|
+
item_version_transition_autoHeight: {
|
|
59
|
+
width: '100%',
|
|
60
|
+
height: 'unset'
|
|
61
|
+
},
|
|
62
|
+
item_itemSize_auto: {
|
|
63
|
+
width: 'auto',
|
|
64
|
+
height: 'auto'
|
|
65
|
+
},
|
|
66
|
+
background: {
|
|
67
|
+
width: '100%',
|
|
68
|
+
height: '100%',
|
|
69
|
+
backgroundRepeat: 'no-repeat',
|
|
70
|
+
backgroundPosition: 'center',
|
|
71
|
+
backgroundSize: 'cover'
|
|
72
|
+
},
|
|
73
|
+
carousel: {
|
|
74
|
+
position: 'relative',
|
|
75
|
+
width: '100%',
|
|
76
|
+
height: '100%',
|
|
77
|
+
touchAction: 'none'
|
|
78
|
+
},
|
|
79
|
+
carousel_version_regular: {
|
|
80
|
+
transition: theme.methods.transitions.make('transform')
|
|
81
|
+
},
|
|
82
|
+
progress: {
|
|
83
|
+
position: 'absolute'
|
|
84
|
+
},
|
|
85
|
+
progress_orientation_horizontal: {
|
|
86
|
+
width: '100%',
|
|
87
|
+
left: '50%',
|
|
88
|
+
transform: 'translateX(-50%)',
|
|
89
|
+
bottom: '24px'
|
|
90
|
+
},
|
|
91
|
+
progress_orientation_vertical: {
|
|
92
|
+
height: '100%',
|
|
93
|
+
top: '50%',
|
|
94
|
+
transform: 'translateY(-50%)',
|
|
95
|
+
right: '24px'
|
|
96
|
+
},
|
|
97
|
+
progress_item: {
|
|
98
|
+
width: '5px',
|
|
99
|
+
height: '5px',
|
|
100
|
+
backgroundColor: 'currentColor',
|
|
101
|
+
borderRadius: theme.methods.shape.radius.value(40, 'px'),
|
|
102
|
+
cursor: 'pointer',
|
|
103
|
+
transition: theme.methods.transitions.make('transform'),
|
|
104
|
+
'&:hover': {
|
|
105
|
+
transform: 'scale(1.4)'
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
progress_item_active: {
|
|
109
|
+
transform: 'scale(1.7)'
|
|
110
|
+
},
|
|
111
|
+
arrow: {
|
|
112
|
+
position: 'absolute !important'
|
|
113
|
+
},
|
|
114
|
+
arrow_previous: {},
|
|
115
|
+
arrow_previous_orientation_horizontal: {
|
|
116
|
+
top: '50%',
|
|
117
|
+
transform: 'translateY(-50%)',
|
|
118
|
+
left: '24px'
|
|
119
|
+
},
|
|
120
|
+
arrow_previous_orientation_vertical: {
|
|
121
|
+
left: '50%',
|
|
122
|
+
transform: 'translateX(-50%)',
|
|
123
|
+
top: '24px'
|
|
124
|
+
},
|
|
125
|
+
arrow_next: {},
|
|
126
|
+
arrow_next_orientation_horizontal: {
|
|
127
|
+
top: '50%',
|
|
128
|
+
transform: 'translateY(-50%)',
|
|
129
|
+
right: '24px'
|
|
130
|
+
},
|
|
131
|
+
arrow_next_orientation_vertical: {
|
|
132
|
+
left: '50%',
|
|
133
|
+
transform: 'translateX(-50%)',
|
|
134
|
+
bottom: '24px'
|
|
135
|
+
},
|
|
136
|
+
icon_previous_orientation_vertical: {
|
|
137
|
+
transform: 'rotate(90deg)'
|
|
138
|
+
},
|
|
139
|
+
icon_next_orientation_vertical: {
|
|
140
|
+
transform: 'rotate(90deg)'
|
|
141
|
+
}
|
|
142
|
+
}), {
|
|
143
|
+
name: 'onesy-Carousel'
|
|
144
|
+
});
|
|
145
|
+
const Carousel = /*#__PURE__*/_react.default.forwardRef((props_, ref) => {
|
|
146
|
+
var _refs$carousel$curren;
|
|
147
|
+
const theme = (0, _styleReact.useOnesyTheme)();
|
|
148
|
+
const props = _react.default.useMemo(() => {
|
|
149
|
+
var _theme$ui, _theme$ui2;
|
|
150
|
+
return _objectSpread(_objectSpread(_objectSpread({}, theme === null || theme === void 0 || (_theme$ui = theme.ui) === null || _theme$ui === void 0 || (_theme$ui = _theme$ui.elements) === null || _theme$ui === void 0 || (_theme$ui = _theme$ui.all) === null || _theme$ui === void 0 || (_theme$ui = _theme$ui.props) === null || _theme$ui === void 0 ? void 0 : _theme$ui.default), theme === null || theme === void 0 || (_theme$ui2 = theme.ui) === null || _theme$ui2 === void 0 || (_theme$ui2 = _theme$ui2.elements) === null || _theme$ui2 === void 0 || (_theme$ui2 = _theme$ui2.onesyCarousel) === null || _theme$ui2 === void 0 || (_theme$ui2 = _theme$ui2.props) === null || _theme$ui2 === void 0 ? void 0 : _theme$ui2.default), props_);
|
|
151
|
+
}, [props_]);
|
|
152
|
+
const Line = _react.default.useMemo(() => {
|
|
153
|
+
var _theme$elements;
|
|
154
|
+
return (theme === null || theme === void 0 || (_theme$elements = theme.elements) === null || _theme$elements === void 0 ? void 0 : _theme$elements.Line) || _Line.default;
|
|
155
|
+
}, [theme]);
|
|
156
|
+
const IconButton = _react.default.useMemo(() => {
|
|
157
|
+
var _theme$elements2;
|
|
158
|
+
return (theme === null || theme === void 0 || (_theme$elements2 = theme.elements) === null || _theme$elements2 === void 0 ? void 0 : _theme$elements2.IconButton) || _IconButton.default;
|
|
159
|
+
}, [theme]);
|
|
160
|
+
const Fade = _react.default.useMemo(() => {
|
|
161
|
+
var _theme$elements3;
|
|
162
|
+
return (theme === null || theme === void 0 || (_theme$elements3 = theme.elements) === null || _theme$elements3 === void 0 ? void 0 : _theme$elements3.Fade) || _Fade.default;
|
|
163
|
+
}, [theme]);
|
|
164
|
+
const Surface = _react.default.useMemo(() => {
|
|
165
|
+
var _theme$elements4;
|
|
166
|
+
return (theme === null || theme === void 0 || (_theme$elements4 = theme.elements) === null || _theme$elements4 === void 0 ? void 0 : _theme$elements4.Surface) || _Surface.default;
|
|
167
|
+
}, [theme]);
|
|
168
|
+
const Transitions = _react.default.useMemo(() => {
|
|
169
|
+
var _theme$elements5;
|
|
170
|
+
return (theme === null || theme === void 0 || (_theme$elements5 = theme.elements) === null || _theme$elements5 === void 0 ? void 0 : _theme$elements5.Transitions) || _Transitions.default;
|
|
171
|
+
}, [theme]);
|
|
172
|
+
const {
|
|
173
|
+
tonal = true,
|
|
174
|
+
color = 'default',
|
|
175
|
+
version: version_,
|
|
176
|
+
valueDefault,
|
|
177
|
+
value: value_,
|
|
178
|
+
onChange,
|
|
179
|
+
// id if it updates
|
|
180
|
+
// update items
|
|
181
|
+
id,
|
|
182
|
+
// Array of string or object
|
|
183
|
+
// object having element as a string or element
|
|
184
|
+
// and a transition element
|
|
185
|
+
items: items_,
|
|
186
|
+
orientation: orientation_,
|
|
187
|
+
itemSize: itemSize_,
|
|
188
|
+
gap: gap_,
|
|
189
|
+
move: move_,
|
|
190
|
+
moveValue: moveValue_,
|
|
191
|
+
moveItems: moveItems_,
|
|
192
|
+
moveBeyondEdge: moveBeyondEdge_,
|
|
193
|
+
free: free_,
|
|
194
|
+
swipe: swipe_,
|
|
195
|
+
background: background_,
|
|
196
|
+
index: index_,
|
|
197
|
+
autoPlay: autoPlay_,
|
|
198
|
+
autoHeight: autoHeight_,
|
|
199
|
+
autoHeightDelay = theme.transitions.duration.rg + 14,
|
|
200
|
+
autoPlayInterval = 4000,
|
|
201
|
+
pauseOnHover = true,
|
|
202
|
+
round: round_,
|
|
203
|
+
arrows: arrows_,
|
|
204
|
+
mouseScroll,
|
|
205
|
+
momentum: momentum_,
|
|
206
|
+
// OnesySubscription methods
|
|
207
|
+
previousSub,
|
|
208
|
+
nextSub,
|
|
209
|
+
updateSub,
|
|
210
|
+
// on mobile visible
|
|
211
|
+
arrowsVisibility: arrowsVisibility_,
|
|
212
|
+
arrowHideOnStartEnd: arrowHideOnStartEnd_,
|
|
213
|
+
renderProgress,
|
|
214
|
+
renderArrowPrevious,
|
|
215
|
+
renderArrowNext,
|
|
216
|
+
progress: progress_,
|
|
217
|
+
// on mobile visible
|
|
218
|
+
progressVisibility: progressVisibility_,
|
|
219
|
+
start: start_,
|
|
220
|
+
end: end_,
|
|
221
|
+
noTransition: noTransition_,
|
|
222
|
+
onUpdatePosition: onUpdatePosition_,
|
|
223
|
+
onInit,
|
|
224
|
+
onUpdateItems,
|
|
225
|
+
onBlur: onBlur_,
|
|
226
|
+
onFocus: onFocus_,
|
|
227
|
+
onMouseEnter: onMouseEnter_,
|
|
228
|
+
onMouseLeave: onMouseLeave_,
|
|
229
|
+
TransitionComponent: TransitionComponent_ = Fade,
|
|
230
|
+
ProgressTransitionComponent = Fade,
|
|
231
|
+
ArrowTransitionComponent = Fade,
|
|
232
|
+
ArrowPreviousTransitionComponent,
|
|
233
|
+
ArrowNextTransitionComponent,
|
|
234
|
+
IconButtonPrevious,
|
|
235
|
+
IconButtonNext,
|
|
236
|
+
IconPrevious = _IconMaterialNavigateBeforeW.default,
|
|
237
|
+
IconNext = _IconMaterialNavigateNextW.default,
|
|
238
|
+
ArrowProps,
|
|
239
|
+
ArrowPreviousProps: ArrowPreviousProps_,
|
|
240
|
+
ArrowNextProps: ArrowNextProps_,
|
|
241
|
+
CarouselProps,
|
|
242
|
+
TransitionsProps,
|
|
243
|
+
TransitionComponentProps,
|
|
244
|
+
ArrowTransitionComponentProps,
|
|
245
|
+
ArrowPreviousTransitionComponentProps,
|
|
246
|
+
ArrowNextTransitionComponentProps,
|
|
247
|
+
ProgressTransitionComponentProps,
|
|
248
|
+
ItemWrapperProps,
|
|
249
|
+
Component = 'div',
|
|
250
|
+
className,
|
|
251
|
+
children
|
|
252
|
+
} = props,
|
|
253
|
+
other = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
254
|
+
const {
|
|
255
|
+
classes
|
|
256
|
+
} = useStyle();
|
|
257
|
+
const refs = {
|
|
258
|
+
root: _react.default.useRef(undefined),
|
|
259
|
+
item: _react.default.useRef(undefined),
|
|
260
|
+
items: _react.default.useRef(undefined),
|
|
261
|
+
value: _react.default.useRef(undefined),
|
|
262
|
+
autoPlayTimeout: _react.default.useRef(undefined),
|
|
263
|
+
autoPlay: _react.default.useRef(undefined),
|
|
264
|
+
carousel: _react.default.useRef(undefined),
|
|
265
|
+
mouseDown: _react.default.useRef(undefined),
|
|
266
|
+
focus: _react.default.useRef(undefined),
|
|
267
|
+
gap: _react.default.useRef(undefined),
|
|
268
|
+
previousMouseEvent: _react.default.useRef(undefined),
|
|
269
|
+
move: _react.default.useRef(undefined),
|
|
270
|
+
moveValue: _react.default.useRef(undefined),
|
|
271
|
+
moveItems: _react.default.useRef(undefined),
|
|
272
|
+
moveBeyondEdge: _react.default.useRef(undefined),
|
|
273
|
+
free: _react.default.useRef(undefined),
|
|
274
|
+
swipe: _react.default.useRef(undefined),
|
|
275
|
+
mouseDownPosition: _react.default.useRef(undefined),
|
|
276
|
+
mouseDownStart: _react.default.useRef(undefined),
|
|
277
|
+
mouseDownDuration: _react.default.useRef(undefined),
|
|
278
|
+
orientation: _react.default.useRef(undefined),
|
|
279
|
+
version: _react.default.useRef(undefined),
|
|
280
|
+
itemSize: _react.default.useRef(undefined),
|
|
281
|
+
itemsLength: _react.default.useRef(undefined),
|
|
282
|
+
momentum: _react.default.useRef(undefined),
|
|
283
|
+
round: _react.default.useRef(undefined),
|
|
284
|
+
velocity: _react.default.useRef(undefined),
|
|
285
|
+
momentumID: _react.default.useRef(undefined),
|
|
286
|
+
width: _react.default.useRef(undefined),
|
|
287
|
+
onInit: _react.default.useRef(undefined),
|
|
288
|
+
ids: {
|
|
289
|
+
items: _react.default.useId()
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
const keys = _react.default.useMemo(() => {
|
|
293
|
+
const result = [];
|
|
294
|
+
const properties = [version_, orientation_, itemSize_, gap_, move_, moveValue_, moveItems_, moveBeyondEdge_, swipe_, background_, autoPlay_, autoHeight_, round_, arrows_, arrowsVisibility_, arrowHideOnStartEnd_, progress_, progressVisibility_, noTransition_];
|
|
295
|
+
properties.forEach(item => {
|
|
296
|
+
if ((0, _utils.is)('object', item)) Object.keys(item).filter(key => theme.breakpoints.media[key]).forEach(key => result.push(key));
|
|
297
|
+
});
|
|
298
|
+
return (0, _utils.unique)(result);
|
|
299
|
+
}, [version_, orientation_, itemSize_, gap_, move_, moveValue_, moveItems_, moveBeyondEdge_, swipe_, background_, autoPlay_, autoHeight_, round_, arrows_, arrowsVisibility_, arrowHideOnStartEnd_, progress_, progressVisibility_, noTransition_]);
|
|
300
|
+
const breakpoints = {};
|
|
301
|
+
keys.forEach(key => {
|
|
302
|
+
breakpoints[key] = (0, _useMediaQuery.default)(theme.breakpoints.media[key], {
|
|
303
|
+
element: refs.root.current
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
const version = (0, _utils2.valueBreakpoints)(version_, 'regular', breakpoints, theme);
|
|
307
|
+
const orientation = (0, _utils2.valueBreakpoints)(orientation_, 'horizontal', breakpoints, theme);
|
|
308
|
+
const itemSize = (0, _utils2.valueBreakpoints)(itemSize_, undefined, breakpoints, theme);
|
|
309
|
+
const gap = (0, _utils2.valueBreakpoints)(gap_, 4, breakpoints, theme);
|
|
310
|
+
const move = (0, _utils2.valueBreakpoints)(move_, true, breakpoints, theme);
|
|
311
|
+
const moveValue = (0, _utils2.valueBreakpoints)(moveValue_, undefined, breakpoints, theme);
|
|
312
|
+
const moveItems = (0, _utils2.valueBreakpoints)(moveItems_, undefined, breakpoints, theme);
|
|
313
|
+
const moveBeyondEdge = (0, _utils2.valueBreakpoints)(moveBeyondEdge_, true, breakpoints, theme);
|
|
314
|
+
const swipe = (0, _utils2.valueBreakpoints)(swipe_, true, breakpoints, theme);
|
|
315
|
+
const background = (0, _utils2.valueBreakpoints)(background_, true, breakpoints, theme);
|
|
316
|
+
const autoPlay = (0, _utils2.valueBreakpoints)(autoPlay_, undefined, breakpoints, theme);
|
|
317
|
+
const autoHeight = (0, _utils2.valueBreakpoints)(autoHeight_, undefined, breakpoints, theme);
|
|
318
|
+
const round = (0, _utils2.valueBreakpoints)(round_, true, breakpoints, theme);
|
|
319
|
+
const arrows = (0, _utils2.valueBreakpoints)(arrows_, true, breakpoints, theme);
|
|
320
|
+
const arrowsVisibility = (0, _utils2.valueBreakpoints)(arrowsVisibility_, 'hover', breakpoints, theme);
|
|
321
|
+
const arrowHideOnStartEnd = (0, _utils2.valueBreakpoints)(arrowHideOnStartEnd_, undefined, breakpoints, theme);
|
|
322
|
+
const progress = (0, _utils2.valueBreakpoints)(progress_, true, breakpoints, theme);
|
|
323
|
+
const progressVisibility = (0, _utils2.valueBreakpoints)(progressVisibility_, 'hover', breakpoints, theme);
|
|
324
|
+
const noTransition = (0, _utils2.valueBreakpoints)(noTransition_, undefined, breakpoints, theme);
|
|
325
|
+
let free = (0, _utils2.valueBreakpoints)(free_, undefined, breakpoints, theme);
|
|
326
|
+
let momentum = (0, _utils2.valueBreakpoints)(momentum_, undefined, breakpoints, theme);
|
|
327
|
+
if (momentum && version !== 'regular') momentum = false;
|
|
328
|
+
if (momentum) free = true;
|
|
329
|
+
if (free && momentum === undefined) momentum = true;
|
|
330
|
+
const [init, setInit] = _react.default.useState();
|
|
331
|
+
const [items, setItems] = _react.default.useState(items_ || []);
|
|
332
|
+
const [value, setValue] = _react.default.useState(valueDefault !== undefined ? valueDefault : value_);
|
|
333
|
+
const [hover, setHover] = _react.default.useState();
|
|
334
|
+
const [mouseDown, setMouseDown] = _react.default.useState();
|
|
335
|
+
const [focus, setFocus] = _react.default.useState();
|
|
336
|
+
const styles = {
|
|
337
|
+
carousel: {}
|
|
338
|
+
};
|
|
339
|
+
refs.items.current = items;
|
|
340
|
+
refs.value.current = value;
|
|
341
|
+
refs.gap.current = gap;
|
|
342
|
+
refs.mouseDown.current = mouseDown;
|
|
343
|
+
refs.focus.current = focus;
|
|
344
|
+
refs.move.current = move;
|
|
345
|
+
refs.moveValue.current = moveValue;
|
|
346
|
+
refs.moveItems.current = moveItems;
|
|
347
|
+
refs.moveBeyondEdge.current = moveBeyondEdge;
|
|
348
|
+
refs.free.current = free;
|
|
349
|
+
refs.swipe.current = swipe;
|
|
350
|
+
refs.orientation.current = orientation;
|
|
351
|
+
refs.version.current = version;
|
|
352
|
+
refs.itemSize.current = itemSize;
|
|
353
|
+
refs.momentum.current = momentum;
|
|
354
|
+
refs.round.current = round;
|
|
355
|
+
refs.onInit.current = onInit;
|
|
356
|
+
const {
|
|
357
|
+
scrollWidth,
|
|
358
|
+
scrollHeight
|
|
359
|
+
} = refs.carousel.current || {};
|
|
360
|
+
const {
|
|
361
|
+
width,
|
|
362
|
+
height
|
|
363
|
+
} = ((_refs$carousel$curren = refs.carousel.current) === null || _refs$carousel$curren === void 0 ? void 0 : _refs$carousel$curren.getBoundingClientRect()) || {};
|
|
364
|
+
refs.width.current = width;
|
|
365
|
+
refs.itemsLength.current = items.length;
|
|
366
|
+
if (itemSize === 'auto') {
|
|
367
|
+
if (moveValue) refs.itemsLength.current = orientation === 'horizontal' ? Math.ceil(scrollWidth / moveValue) : Math.ceil(scrollHeight / moveValue);
|
|
368
|
+
if (moveItems) refs.itemsLength.current = Math.ceil(items.length / (0, _utils.clamp)(moveItems, 1, items.length));
|
|
369
|
+
}
|
|
370
|
+
const updateValue = valueNew => {
|
|
371
|
+
setValue(valueNew);
|
|
372
|
+
if ((0, _utils.is)('function', onChange)) onChange(valueNew);
|
|
373
|
+
};
|
|
374
|
+
const momentumClear = () => {
|
|
375
|
+
cancelAnimationFrame(refs.momentumID.current);
|
|
376
|
+
};
|
|
377
|
+
const momentumMethod = () => {
|
|
378
|
+
var _refs$value$current, _refs$value$current2;
|
|
379
|
+
const valueNew = refs.orientation.current === 'horizontal' ? (((_refs$value$current = refs.value.current) === null || _refs$value$current === void 0 ? void 0 : _refs$value$current.x) || 0) + refs.velocity.current : (((_refs$value$current2 = refs.value.current) === null || _refs$value$current2 === void 0 ? void 0 : _refs$value$current2.y) || 0) + refs.velocity.current;
|
|
380
|
+
const {
|
|
381
|
+
width: width_,
|
|
382
|
+
height: height_
|
|
383
|
+
} = refs.carousel.current.getBoundingClientRect();
|
|
384
|
+
const {
|
|
385
|
+
scrollWidth: scrollWidth_,
|
|
386
|
+
scrollHeight: scrollHeight_
|
|
387
|
+
} = refs.carousel.current;
|
|
388
|
+
if (refs.orientation.current === 'horizontal') {
|
|
389
|
+
const min = 0;
|
|
390
|
+
let max = (width_ + gap * theme.space.unit) * (refs.itemsLength.current - 1);
|
|
391
|
+
if (refs.itemSize.current === 'auto') {
|
|
392
|
+
max = scrollWidth_ - scrollWidth_ / refs.itemsLength.current + gap * theme.space.unit * (refs.itemsLength.current - 1);
|
|
393
|
+
}
|
|
394
|
+
refs.value.current = _objectSpread(_objectSpread({}, refs.value.current), {}, {
|
|
395
|
+
index: Math.floor(valueNew / (max / (refs.itemsLength.current - 1))),
|
|
396
|
+
x: valueNew
|
|
397
|
+
});
|
|
398
|
+
if (valueNew <= min || valueNew >= max) {
|
|
399
|
+
var _refs$carousel$curren2;
|
|
400
|
+
// Done
|
|
401
|
+
return (_refs$carousel$curren2 = refs.carousel.current) === null || _refs$carousel$curren2 === void 0 ? void 0 : _refs$carousel$curren2.style.removeProperty('transition');
|
|
402
|
+
} else {
|
|
403
|
+
refs.value.current = _objectSpread(_objectSpread({}, refs.value.current), {}, {
|
|
404
|
+
index: Math.floor(valueNew / (max / (refs.itemsLength.current - 1))),
|
|
405
|
+
x: valueNew
|
|
406
|
+
});
|
|
407
|
+
onUpdatePosition(refs.value.current);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
if (refs.orientation.current === 'vertical') {
|
|
411
|
+
const min = 0;
|
|
412
|
+
let max = (height_ + gap * theme.space.unit) * (refs.itemsLength.current - 1);
|
|
413
|
+
if (refs.itemSize.current === 'auto') {
|
|
414
|
+
max = scrollHeight_ - scrollHeight_ / refs.itemsLength.current + gap * theme.space.unit * (refs.itemsLength.current - 1);
|
|
415
|
+
}
|
|
416
|
+
if (valueNew <= min || valueNew >= max) {
|
|
417
|
+
var _refs$carousel$curren3;
|
|
418
|
+
// Done
|
|
419
|
+
return (_refs$carousel$curren3 = refs.carousel.current) === null || _refs$carousel$curren3 === void 0 ? void 0 : _refs$carousel$curren3.style.removeProperty('transition');
|
|
420
|
+
} else {
|
|
421
|
+
refs.value.current = _objectSpread(_objectSpread({}, refs.value.current), {}, {
|
|
422
|
+
index: Math.floor(valueNew / (max / (refs.itemsLength.current - 1))),
|
|
423
|
+
y: valueNew
|
|
212
424
|
});
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
425
|
+
onUpdatePosition(refs.value.current);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
refs.velocity.current *= 0.95;
|
|
429
|
+
if (Math.abs(refs.velocity.current) > 0.5) refs.momentumID.current = requestAnimationFrame(momentumMethod);else {
|
|
430
|
+
var _refs$carousel$curren4;
|
|
431
|
+
// Done
|
|
432
|
+
(_refs$carousel$curren4 = refs.carousel.current) === null || _refs$carousel$curren4 === void 0 || _refs$carousel$curren4.style.removeProperty('transition');
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
const momentumStart = () => {
|
|
436
|
+
refs.momentumID.current = requestAnimationFrame(momentumMethod);
|
|
437
|
+
};
|
|
438
|
+
const onUpdatePosition = valuePosition_ => {
|
|
439
|
+
// Momentum
|
|
440
|
+
momentumClear();
|
|
441
|
+
const valueNew = _objectSpread(_objectSpread({}, valuePosition_), {}, {
|
|
442
|
+
additional: 0
|
|
218
443
|
});
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const moveBeyondEdge = (0, utils_2.valueBreakpoints)(moveBeyondEdge_, true, breakpoints, theme);
|
|
227
|
-
const swipe = (0, utils_2.valueBreakpoints)(swipe_, true, breakpoints, theme);
|
|
228
|
-
const background = (0, utils_2.valueBreakpoints)(background_, true, breakpoints, theme);
|
|
229
|
-
const autoPlay = (0, utils_2.valueBreakpoints)(autoPlay_, undefined, breakpoints, theme);
|
|
230
|
-
const autoHeight = (0, utils_2.valueBreakpoints)(autoHeight_, undefined, breakpoints, theme);
|
|
231
|
-
const round = (0, utils_2.valueBreakpoints)(round_, true, breakpoints, theme);
|
|
232
|
-
const arrows = (0, utils_2.valueBreakpoints)(arrows_, true, breakpoints, theme);
|
|
233
|
-
const arrowsVisibility = (0, utils_2.valueBreakpoints)(arrowsVisibility_, 'hover', breakpoints, theme);
|
|
234
|
-
const arrowHideOnStartEnd = (0, utils_2.valueBreakpoints)(arrowHideOnStartEnd_, undefined, breakpoints, theme);
|
|
235
|
-
const progress = (0, utils_2.valueBreakpoints)(progress_, true, breakpoints, theme);
|
|
236
|
-
const progressVisibility = (0, utils_2.valueBreakpoints)(progressVisibility_, 'hover', breakpoints, theme);
|
|
237
|
-
const noTransition = (0, utils_2.valueBreakpoints)(noTransition_, undefined, breakpoints, theme);
|
|
238
|
-
let free = (0, utils_2.valueBreakpoints)(free_, undefined, breakpoints, theme);
|
|
239
|
-
let momentum = (0, utils_2.valueBreakpoints)(momentum_, undefined, breakpoints, theme);
|
|
240
|
-
if (momentum && version !== 'regular')
|
|
241
|
-
momentum = false;
|
|
242
|
-
if (momentum)
|
|
243
|
-
free = true;
|
|
244
|
-
if (free && momentum === undefined)
|
|
245
|
-
momentum = true;
|
|
246
|
-
const [init, setInit] = react_1.default.useState();
|
|
247
|
-
const [items, setItems] = react_1.default.useState(items_ || []);
|
|
248
|
-
const [value, setValue] = react_1.default.useState(valueDefault !== undefined ? valueDefault : value_);
|
|
249
|
-
const [hover, setHover] = react_1.default.useState();
|
|
250
|
-
const [mouseDown, setMouseDown] = react_1.default.useState();
|
|
251
|
-
const [focus, setFocus] = react_1.default.useState();
|
|
252
|
-
const styles = {
|
|
253
|
-
carousel: {}
|
|
254
|
-
};
|
|
255
|
-
refs.items.current = items;
|
|
256
|
-
refs.value.current = value;
|
|
257
|
-
refs.gap.current = gap;
|
|
258
|
-
refs.mouseDown.current = mouseDown;
|
|
259
|
-
refs.focus.current = focus;
|
|
260
|
-
refs.move.current = move;
|
|
261
|
-
refs.moveValue.current = moveValue;
|
|
262
|
-
refs.moveItems.current = moveItems;
|
|
263
|
-
refs.moveBeyondEdge.current = moveBeyondEdge;
|
|
264
|
-
refs.free.current = free;
|
|
265
|
-
refs.swipe.current = swipe;
|
|
266
|
-
refs.orientation.current = orientation;
|
|
267
|
-
refs.version.current = version;
|
|
268
|
-
refs.itemSize.current = itemSize;
|
|
269
|
-
refs.momentum.current = momentum;
|
|
270
|
-
refs.round.current = round;
|
|
271
|
-
refs.onInit.current = onInit;
|
|
272
|
-
const { scrollWidth, scrollHeight } = (refs.carousel.current || {});
|
|
273
|
-
const { width, height } = (((_a = refs.carousel.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) || {});
|
|
274
|
-
refs.width.current = width;
|
|
275
|
-
refs.itemsLength.current = items.length;
|
|
276
|
-
if (itemSize === 'auto') {
|
|
277
|
-
if (moveValue)
|
|
278
|
-
refs.itemsLength.current = orientation === 'horizontal' ? Math.ceil(scrollWidth / moveValue) : Math.ceil(scrollHeight / moveValue);
|
|
279
|
-
if (moveItems)
|
|
280
|
-
refs.itemsLength.current = Math.ceil(items.length / (0, utils_1.clamp)(moveItems, 1, items.length));
|
|
444
|
+
if (valuePosition_.additional === undefined && refs.version.current === 'regular' && refs.itemSize.current !== 'auto') {
|
|
445
|
+
var _refs$mouseDownPositi;
|
|
446
|
+
const max = refs.width.current / 2;
|
|
447
|
+
const valuePosition = valueNew[refs.orientation.current === 'horizontal' ? 'x' : 'y'];
|
|
448
|
+
const part = valuePosition - (((_refs$mouseDownPositi = refs.mouseDownPosition.current) === null || _refs$mouseDownPositi === void 0 ? void 0 : _refs$mouseDownPositi[refs.orientation.current === 'horizontal' ? 'x' : 'y']) || 0);
|
|
449
|
+
const additional = part / max * 100;
|
|
450
|
+
valueNew.additional = additional;
|
|
281
451
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
// Done
|
|
331
|
-
(_e = refs.carousel.current) === null || _e === void 0 ? void 0 : _e.style.removeProperty('transition');
|
|
452
|
+
updateValue(valueNew);
|
|
453
|
+
if ((0, _utils.is)('function', onUpdatePosition_)) onUpdatePosition_(valueNew);
|
|
454
|
+
};
|
|
455
|
+
const onUpdate = _react.default.useCallback((to = 'next', values = refs.items.current) => {
|
|
456
|
+
var _refs$carousel$curren5, _refs$value$current3;
|
|
457
|
+
// Momentum
|
|
458
|
+
momentumClear();
|
|
459
|
+
|
|
460
|
+
// Momentum clean up
|
|
461
|
+
(_refs$carousel$curren5 = refs.carousel.current) === null || _refs$carousel$curren5 === void 0 || _refs$carousel$curren5.style.removeProperty('transition');
|
|
462
|
+
let index = (_refs$value$current3 = refs.value.current) === null || _refs$value$current3 === void 0 ? void 0 : _refs$value$current3.index;
|
|
463
|
+
if (index === undefined) index = 0;else if ((0, _utils.is)('number', to)) index = (0, _utils.clamp)(to, 0, refs.itemsLength.current - 1);else {
|
|
464
|
+
index = to === 'next' ? index + 1 : index - 1;
|
|
465
|
+
if (index < 0) index = refs.round.current ? refs.itemsLength.current - 1 : 0;
|
|
466
|
+
if (index > refs.itemsLength.current - 1) index = refs.round.current ? 0 : refs.itemsLength.current - 1;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// Regular
|
|
470
|
+
if (version === 'regular' && refs.carousel.current) {
|
|
471
|
+
if (refs.orientation.current === 'horizontal') {
|
|
472
|
+
if (refs.itemSize.current === 'auto' && refs.moveValue.current !== undefined) {
|
|
473
|
+
const x = index * refs.moveValue.current;
|
|
474
|
+
onUpdatePosition({
|
|
475
|
+
index,
|
|
476
|
+
x,
|
|
477
|
+
additional: 0
|
|
478
|
+
});
|
|
479
|
+
} else if (refs.itemSize.current === 'auto' && refs.moveItems.current !== undefined) {
|
|
480
|
+
let item = index * (0, _utils.clamp)(moveItems, 1, refs.items.current.length);
|
|
481
|
+
item = refs.carousel.current.children[item];
|
|
482
|
+
if (item) {
|
|
483
|
+
const x = item.offsetLeft;
|
|
484
|
+
onUpdatePosition({
|
|
485
|
+
index,
|
|
486
|
+
x,
|
|
487
|
+
additional: 0
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
} else {
|
|
491
|
+
const width_ = refs.carousel.current.getBoundingClientRect().width;
|
|
492
|
+
const scrollWidth_ = refs.carousel.current.scrollWidth;
|
|
493
|
+
const part = refs.itemSize.current === 'auto' ? scrollWidth_ / refs.itemsLength.current : width_;
|
|
494
|
+
const x = index * part + index * (gap * theme.space.unit);
|
|
495
|
+
onUpdatePosition({
|
|
496
|
+
index,
|
|
497
|
+
x,
|
|
498
|
+
additional: 0
|
|
499
|
+
});
|
|
332
500
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
refs.
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
if (
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
const
|
|
347
|
-
|
|
501
|
+
}
|
|
502
|
+
if (refs.orientation.current === 'vertical') {
|
|
503
|
+
if (refs.itemSize.current === 'auto' && refs.moveValue.current !== undefined) {
|
|
504
|
+
const y = index * refs.moveValue.current;
|
|
505
|
+
onUpdatePosition({
|
|
506
|
+
index,
|
|
507
|
+
y,
|
|
508
|
+
additional: 0
|
|
509
|
+
});
|
|
510
|
+
} else if (refs.itemSize.current === 'auto' && refs.moveItems.current !== undefined) {
|
|
511
|
+
let item = index * (0, _utils.clamp)(moveItems, 1, refs.items.current.length);
|
|
512
|
+
item = refs.carousel.current.children[item];
|
|
513
|
+
if (item) {
|
|
514
|
+
const y = item.offsetTop;
|
|
515
|
+
onUpdatePosition({
|
|
516
|
+
index,
|
|
517
|
+
y,
|
|
518
|
+
additional: 0
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
} else {
|
|
522
|
+
const height_ = refs.carousel.current.getBoundingClientRect().height;
|
|
523
|
+
const scrollHeight_ = refs.carousel.current.scrollHeight;
|
|
524
|
+
const part = refs.itemSize.current === 'auto' ? scrollHeight_ / refs.itemsLength.current : height_;
|
|
525
|
+
const y = index * part + index * (gap * theme.space.unit);
|
|
526
|
+
onUpdatePosition({
|
|
527
|
+
index,
|
|
528
|
+
y,
|
|
529
|
+
additional: 0
|
|
530
|
+
});
|
|
348
531
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
if (
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
if (index < 0)
|
|
367
|
-
index = refs.round.current ? refs.itemsLength.current - 1 : 0;
|
|
368
|
-
if (index > refs.itemsLength.current - 1)
|
|
369
|
-
index = refs.round.current ? 0 : refs.itemsLength.current - 1;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// Transition
|
|
536
|
+
const itemNew = values[index];
|
|
537
|
+
if (itemNew) {
|
|
538
|
+
if (version === 'transition') updateValue({
|
|
539
|
+
index,
|
|
540
|
+
element: itemNew
|
|
541
|
+
});
|
|
542
|
+
if (autoHeight) {
|
|
543
|
+
if (version === 'regular') {
|
|
544
|
+
setTimeout(() => {
|
|
545
|
+
var _refs$carousel$curren6, _refs$value$current4;
|
|
546
|
+
const height_ = (_refs$carousel$curren6 = refs.carousel.current.children[(_refs$value$current4 = refs.value.current) === null || _refs$value$current4 === void 0 ? void 0 : _refs$value$current4.index]) === null || _refs$carousel$curren6 === void 0 || (_refs$carousel$curren6 = _refs$carousel$curren6.children[0]) === null || _refs$carousel$curren6 === void 0 ? void 0 : _refs$carousel$curren6.getBoundingClientRect().height;
|
|
547
|
+
if (height_ > 0) refs.root.current.style.height = `${height_}px`;
|
|
548
|
+
}, 1);
|
|
370
549
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
index,
|
|
378
|
-
x,
|
|
379
|
-
additional: 0
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
else if (refs.itemSize.current === 'auto' && refs.moveItems.current !== undefined) {
|
|
383
|
-
let item = index * (0, utils_1.clamp)(moveItems, 1, refs.items.current.length);
|
|
384
|
-
item = refs.carousel.current.children[item];
|
|
385
|
-
if (item) {
|
|
386
|
-
const x = item.offsetLeft;
|
|
387
|
-
onUpdatePosition({
|
|
388
|
-
index,
|
|
389
|
-
x,
|
|
390
|
-
additional: 0
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
else {
|
|
395
|
-
const width_ = refs.carousel.current.getBoundingClientRect().width;
|
|
396
|
-
const scrollWidth_ = refs.carousel.current.scrollWidth;
|
|
397
|
-
const part = refs.itemSize.current === 'auto' ? scrollWidth_ / refs.itemsLength.current : width_;
|
|
398
|
-
const x = (index * part) + (index * (gap * theme.space.unit));
|
|
399
|
-
onUpdatePosition({
|
|
400
|
-
index,
|
|
401
|
-
x,
|
|
402
|
-
additional: 0
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
if (refs.orientation.current === 'vertical') {
|
|
407
|
-
if (refs.itemSize.current === 'auto' && refs.moveValue.current !== undefined) {
|
|
408
|
-
const y = index * refs.moveValue.current;
|
|
409
|
-
onUpdatePosition({
|
|
410
|
-
index,
|
|
411
|
-
y,
|
|
412
|
-
additional: 0
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
else if (refs.itemSize.current === 'auto' && refs.moveItems.current !== undefined) {
|
|
416
|
-
let item = index * (0, utils_1.clamp)(moveItems, 1, refs.items.current.length);
|
|
417
|
-
item = refs.carousel.current.children[item];
|
|
418
|
-
if (item) {
|
|
419
|
-
const y = item.offsetTop;
|
|
420
|
-
onUpdatePosition({
|
|
421
|
-
index,
|
|
422
|
-
y,
|
|
423
|
-
additional: 0
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
else {
|
|
428
|
-
const height_ = refs.carousel.current.getBoundingClientRect().height;
|
|
429
|
-
const scrollHeight_ = refs.carousel.current.scrollHeight;
|
|
430
|
-
const part = refs.itemSize.current === 'auto' ? scrollHeight_ / refs.itemsLength.current : height_;
|
|
431
|
-
const y = (index * part) + (index * (gap * theme.space.unit));
|
|
432
|
-
onUpdatePosition({
|
|
433
|
-
index,
|
|
434
|
-
y,
|
|
435
|
-
additional: 0
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
}
|
|
550
|
+
if (version === 'transition') {
|
|
551
|
+
setTimeout(() => {
|
|
552
|
+
var _refs$carousel$curren7;
|
|
553
|
+
const height_ = (_refs$carousel$curren7 = refs.carousel.current.children[0]) === null || _refs$carousel$curren7 === void 0 || (_refs$carousel$curren7 = _refs$carousel$curren7.children[0]) === null || _refs$carousel$curren7 === void 0 ? void 0 : _refs$carousel$curren7.getBoundingClientRect().height;
|
|
554
|
+
if (height_ > 0) refs.root.current.style.height = `${height_}px`;
|
|
555
|
+
}, autoHeightDelay);
|
|
439
556
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}, [gap, version, autoHeight, autoHeightDelay]);
|
|
560
|
+
const onMouseUp = _react.default.useCallback(event => {
|
|
561
|
+
if (refs.mouseDown.current) {
|
|
562
|
+
var _refs$carousel$curren8;
|
|
563
|
+
if (refs.mouseDown.current && !refs.momentum.current) (_refs$carousel$curren8 = refs.carousel.current) === null || _refs$carousel$curren8 === void 0 || _refs$carousel$curren8.style.removeProperty('transition');
|
|
564
|
+
refs.mouseDownDuration.current = new Date().getTime() - refs.mouseDownStart.current;
|
|
565
|
+
if (refs.free.current) {
|
|
566
|
+
setMouseDown(false);
|
|
567
|
+
if (refs.momentum.current) momentumStart();
|
|
568
|
+
refs.previousMouseEvent.current = undefined;
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// Swipe
|
|
573
|
+
// less than 140 ms
|
|
574
|
+
if (refs.swipe.current && refs.mouseDownDuration.current <= 140) {
|
|
575
|
+
var _refs$mouseDown$curre;
|
|
576
|
+
const {
|
|
577
|
+
clientX: previousClientX,
|
|
578
|
+
clientY: previousClientY
|
|
579
|
+
} = ((_refs$mouseDown$curre = refs.mouseDown.current.touches) === null || _refs$mouseDown$curre === void 0 ? void 0 : _refs$mouseDown$curre[0]) || refs.mouseDown.current;
|
|
580
|
+
const {
|
|
581
|
+
clientX,
|
|
582
|
+
clientY
|
|
583
|
+
} = refs.previousMouseEvent.current || event;
|
|
584
|
+
refs.previousMouseEvent.current = undefined;
|
|
585
|
+
setMouseDown(false);
|
|
586
|
+
if (refs.orientation.current === 'horizontal') {
|
|
587
|
+
var _refs$value$current5;
|
|
588
|
+
// As move already updates the index
|
|
589
|
+
// so move to that index
|
|
590
|
+
if (previousClientX < clientX) return onUpdate((_refs$value$current5 = refs.value.current) === null || _refs$value$current5 === void 0 ? void 0 : _refs$value$current5.index);
|
|
591
|
+
if (previousClientX > clientX) return onUpdate('next');
|
|
463
592
|
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
if (refs.mouseDown.current && !refs.momentum.current)
|
|
469
|
-
(_a = refs.carousel.current) === null || _a === void 0 ? void 0 : _a.style.removeProperty('transition');
|
|
470
|
-
refs.mouseDownDuration.current = new Date().getTime() - refs.mouseDownStart.current;
|
|
471
|
-
if (refs.free.current) {
|
|
472
|
-
setMouseDown(false);
|
|
473
|
-
if (refs.momentum.current)
|
|
474
|
-
momentumStart();
|
|
475
|
-
refs.previousMouseEvent.current = undefined;
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
// Swipe
|
|
479
|
-
// less than 140 ms
|
|
480
|
-
if (refs.swipe.current && refs.mouseDownDuration.current <= 140) {
|
|
481
|
-
const { clientX: previousClientX, clientY: previousClientY } = ((_b = refs.mouseDown.current.touches) === null || _b === void 0 ? void 0 : _b[0]) || refs.mouseDown.current;
|
|
482
|
-
const { clientX, clientY } = refs.previousMouseEvent.current || event;
|
|
483
|
-
refs.previousMouseEvent.current = undefined;
|
|
484
|
-
setMouseDown(false);
|
|
485
|
-
if (refs.orientation.current === 'horizontal') {
|
|
486
|
-
// As move already updates the index
|
|
487
|
-
// so move to that index
|
|
488
|
-
if (previousClientX < clientX)
|
|
489
|
-
return onUpdate((_c = refs.value.current) === null || _c === void 0 ? void 0 : _c.index);
|
|
490
|
-
if (previousClientX > clientX)
|
|
491
|
-
return onUpdate('next');
|
|
492
|
-
}
|
|
493
|
-
if (refs.orientation.current === 'vertical') {
|
|
494
|
-
if (previousClientY < clientY)
|
|
495
|
-
return onUpdate((_d = refs.value.current) === null || _d === void 0 ? void 0 : _d.index);
|
|
496
|
-
if (previousClientY > clientY)
|
|
497
|
-
return onUpdate('next');
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
// Move
|
|
501
|
-
if (refs.version.current === 'regular' && refs.value.current) {
|
|
502
|
-
if (refs.orientation.current === 'horizontal') {
|
|
503
|
-
const { x } = refs.value.current;
|
|
504
|
-
let index = refs.value.current.index;
|
|
505
|
-
if (((_e = refs.mouseDownPosition.current) === null || _e === void 0 ? void 0 : _e.x) > x)
|
|
506
|
-
index++;
|
|
507
|
-
const width_ = refs.carousel.current.getBoundingClientRect().width;
|
|
508
|
-
const original = index * width_ + index * (gap * theme.space.unit);
|
|
509
|
-
const threshold = width_ / 4;
|
|
510
|
-
const moved = Math.abs(original - x);
|
|
511
|
-
if (x > 0 && x < original && moved >= threshold)
|
|
512
|
-
onUpdate(index - 1);
|
|
513
|
-
else if (x > original && moved >= threshold)
|
|
514
|
-
onUpdate(index + 1);
|
|
515
|
-
else
|
|
516
|
-
onUpdate(index);
|
|
517
|
-
}
|
|
518
|
-
if (refs.orientation.current === 'vertical') {
|
|
519
|
-
const { y } = refs.value.current;
|
|
520
|
-
let index = refs.value.current.index;
|
|
521
|
-
if (((_f = refs.mouseDownPosition.current) === null || _f === void 0 ? void 0 : _f.y) > y)
|
|
522
|
-
index++;
|
|
523
|
-
const height_ = refs.carousel.current.getBoundingClientRect().height;
|
|
524
|
-
const original = index * height_ + index * (gap * theme.space.unit);
|
|
525
|
-
const threshold = height_ / 4;
|
|
526
|
-
const moved = Math.abs(original - y);
|
|
527
|
-
if (y > 0 && y < original && moved >= threshold)
|
|
528
|
-
onUpdate(index - 1);
|
|
529
|
-
else if (y > original && moved >= threshold)
|
|
530
|
-
onUpdate(index + 1);
|
|
531
|
-
else
|
|
532
|
-
onUpdate(index);
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
setMouseDown(false);
|
|
536
|
-
refs.previousMouseEvent.current = undefined;
|
|
593
|
+
if (refs.orientation.current === 'vertical') {
|
|
594
|
+
var _refs$value$current6;
|
|
595
|
+
if (previousClientY < clientY) return onUpdate((_refs$value$current6 = refs.value.current) === null || _refs$value$current6 === void 0 ? void 0 : _refs$value$current6.index);
|
|
596
|
+
if (previousClientY > clientY) return onUpdate('next');
|
|
537
597
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
var _a, _b, _c, _d, _e, _f;
|
|
555
|
-
if (refs.version.current === 'regular' && refs.move.current && refs.mouseDown.current && refs.previousMouseEvent.current) {
|
|
556
|
-
const incX = x_ - refs.previousMouseEvent.current.clientX;
|
|
557
|
-
const incY = y_ - refs.previousMouseEvent.current.clientY;
|
|
558
|
-
const { width: width_, height: height_ } = refs.carousel.current.getBoundingClientRect();
|
|
559
|
-
const { scrollWidth: scrollWidth_, scrollHeight: scrollHeight_ } = refs.carousel.current;
|
|
560
|
-
if (refs.orientation.current === 'horizontal' && incX !== 0) {
|
|
561
|
-
const min = 0;
|
|
562
|
-
let max = ((width_ + (gap * theme.space.unit)) * (refs.itemsLength.current - 1));
|
|
563
|
-
if (refs.itemSize.current === 'auto') {
|
|
564
|
-
max = (scrollWidth_ - (scrollWidth_ / refs.itemsLength.current)) + ((gap * theme.space.unit) * (refs.itemsLength.current - 1));
|
|
565
|
-
}
|
|
566
|
-
let x = (((_a = refs.value.current) === null || _a === void 0 ? void 0 : _a.x) || 0) - incX;
|
|
567
|
-
if (refs.free.current || !refs.moveBeyondEdge.current)
|
|
568
|
-
x = (0, utils_1.clamp)(x, min, max);
|
|
569
|
-
// Move beyond min, max
|
|
570
|
-
if (x < min || x > max)
|
|
571
|
-
x = (((_b = refs.value.current) === null || _b === void 0 ? void 0 : _b.x) || 0) - (incX / 1.7);
|
|
572
|
-
refs.velocity.current = x - (((_c = refs.value.current) === null || _c === void 0 ? void 0 : _c.x) || 0);
|
|
573
|
-
onUpdatePosition({
|
|
574
|
-
index: Math.floor(x / (max / (refs.itemsLength.current - 1))),
|
|
575
|
-
x
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
if (refs.orientation.current === 'vertical' && incY !== 0) {
|
|
579
|
-
const min = 0;
|
|
580
|
-
let max = ((height_ + (gap * theme.space.unit)) * (refs.itemsLength.current - 1));
|
|
581
|
-
if (refs.itemSize.current === 'auto') {
|
|
582
|
-
max = (scrollHeight_ - (scrollHeight_ / refs.itemsLength.current)) + ((gap * theme.space.unit) * (refs.itemsLength.current - 1));
|
|
583
|
-
}
|
|
584
|
-
let y = (((_d = refs.value.current) === null || _d === void 0 ? void 0 : _d.y) || 0) - incY;
|
|
585
|
-
if (refs.free.current || !refs.moveBeyondEdge.current)
|
|
586
|
-
y = (0, utils_1.clamp)(y, min, max);
|
|
587
|
-
// Move beyond min, max
|
|
588
|
-
if (y < min || y > max)
|
|
589
|
-
y = (((_e = refs.value.current) === null || _e === void 0 ? void 0 : _e.y) || 0) - (incY / 1.7);
|
|
590
|
-
refs.velocity.current = y - (((_f = refs.value.current) === null || _f === void 0 ? void 0 : _f.y) || 0);
|
|
591
|
-
onUpdatePosition({
|
|
592
|
-
index: Math.floor(y / (max / (refs.itemsLength.current - 1))),
|
|
593
|
-
y
|
|
594
|
-
});
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
};
|
|
598
|
-
// Mouse move
|
|
599
|
-
const onMouseMove = (event) => {
|
|
600
|
-
if (refs.mouseDown.current) {
|
|
601
|
-
const { clientY, clientX } = event;
|
|
602
|
-
onMove(clientX, clientY);
|
|
603
|
-
refs.previousMouseEvent.current = event;
|
|
604
|
-
}
|
|
605
|
-
};
|
|
606
|
-
// Touch move
|
|
607
|
-
const onTouchMove = (event) => {
|
|
608
|
-
if (refs.mouseDown.current) {
|
|
609
|
-
const { clientY, clientX } = event.touches[0];
|
|
610
|
-
onMove(clientX, clientY);
|
|
611
|
-
refs.previousMouseEvent.current = event;
|
|
612
|
-
// Normalize for use as a mouseDown value
|
|
613
|
-
refs.previousMouseEvent.current.clientY = clientY;
|
|
614
|
-
refs.previousMouseEvent.current.clientX = clientX;
|
|
615
|
-
}
|
|
616
|
-
};
|
|
617
|
-
const method = () => { var _a; return onUpdate((_a = refs.value.current) === null || _a === void 0 ? void 0 : _a.index); };
|
|
618
|
-
const observer = new ResizeObserver(method);
|
|
619
|
-
method();
|
|
620
|
-
observer.observe(refs.root.current);
|
|
621
|
-
const rootDocument = (0, utils_1.isEnvironment)('browser') ? (((_a = refs.root.current) === null || _a === void 0 ? void 0 : _a.ownerDocument) || window.document) : undefined;
|
|
622
|
-
rootDocument.addEventListener('keydown', onKeyDown);
|
|
623
|
-
rootDocument.addEventListener('mouseup', onMouseUp);
|
|
624
|
-
rootDocument.addEventListener('mousemove', onMouseMove);
|
|
625
|
-
rootDocument.addEventListener('touchend', onMouseUp);
|
|
626
|
-
rootDocument.addEventListener('touchmove', onTouchMove, { passive: true });
|
|
627
|
-
setInit(true);
|
|
628
|
-
if ((0, utils_1.is)('function', refs.onInit.current))
|
|
629
|
-
refs.onInit.current();
|
|
630
|
-
return () => {
|
|
631
|
-
observer.disconnect();
|
|
632
|
-
rootDocument.removeEventListener('keydown', onKeyDown);
|
|
633
|
-
rootDocument.removeEventListener('mousemove', onMouseMove);
|
|
634
|
-
rootDocument.removeEventListener('mouseup', onMouseUp);
|
|
635
|
-
rootDocument.removeEventListener('touchmove', onTouchMove);
|
|
636
|
-
rootDocument.removeEventListener('touchend', onMouseUp);
|
|
637
|
-
};
|
|
638
|
-
}, []);
|
|
639
|
-
react_1.default.useEffect(() => {
|
|
640
|
-
if (value_ !== undefined && !(0, utils_1.equalDeep)(value_, refs.value.current))
|
|
641
|
-
setValue((valuePrevious) => (Object.assign(Object.assign({}, valuePrevious), value_)));
|
|
642
|
-
}, [value_]);
|
|
643
|
-
react_1.default.useEffect(() => {
|
|
644
|
-
var _a;
|
|
645
|
-
if (init) {
|
|
646
|
-
if (index_ >= 0 && index_ <= refs.itemsLength.current && index_ !== ((_a = refs.value.current) === null || _a === void 0 ? void 0 : _a.index))
|
|
647
|
-
onUpdate(index_);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
// Move
|
|
601
|
+
if (refs.version.current === 'regular' && refs.value.current) {
|
|
602
|
+
if (refs.orientation.current === 'horizontal') {
|
|
603
|
+
var _refs$mouseDownPositi2;
|
|
604
|
+
const {
|
|
605
|
+
x
|
|
606
|
+
} = refs.value.current;
|
|
607
|
+
let index = refs.value.current.index;
|
|
608
|
+
if (((_refs$mouseDownPositi2 = refs.mouseDownPosition.current) === null || _refs$mouseDownPositi2 === void 0 ? void 0 : _refs$mouseDownPositi2.x) > x) index++;
|
|
609
|
+
const width_ = refs.carousel.current.getBoundingClientRect().width;
|
|
610
|
+
const original = index * width_ + index * (gap * theme.space.unit);
|
|
611
|
+
const threshold = width_ / 4;
|
|
612
|
+
const moved = Math.abs(original - x);
|
|
613
|
+
if (x > 0 && x < original && moved >= threshold) onUpdate(index - 1);else if (x > original && moved >= threshold) onUpdate(index + 1);else onUpdate(index);
|
|
648
614
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
refs.autoPlay.current = false;
|
|
662
|
-
};
|
|
663
|
-
const start = () => {
|
|
664
|
-
clear();
|
|
665
|
-
if (!autoPlay || mouseDown || focus)
|
|
666
|
-
return;
|
|
667
|
-
if (pauseOnHover && hover)
|
|
668
|
-
return;
|
|
669
|
-
refs.autoPlayTimeout.current = setTimeout(onUpdate, autoPlayInterval);
|
|
670
|
-
refs.autoPlay.current = true;
|
|
671
|
-
};
|
|
672
|
-
// autoPlay
|
|
673
|
-
react_1.default.useEffect(() => {
|
|
674
|
-
start();
|
|
675
|
-
}, [items, value, autoPlay, autoPlayInterval]);
|
|
676
|
-
// OnesySubscription methods
|
|
677
|
-
react_1.default.useEffect(() => {
|
|
678
|
-
const method = (...args) => onUpdate(...args);
|
|
679
|
-
if ((0, utils_1.is)('function', updateSub === null || updateSub === void 0 ? void 0 : updateSub.subscribe))
|
|
680
|
-
updateSub === null || updateSub === void 0 ? void 0 : updateSub.subscribe(method);
|
|
681
|
-
return () => {
|
|
682
|
-
if ((0, utils_1.is)('function', updateSub === null || updateSub === void 0 ? void 0 : updateSub.unsubscribe))
|
|
683
|
-
updateSub === null || updateSub === void 0 ? void 0 : updateSub.unsubscribe(method);
|
|
684
|
-
};
|
|
685
|
-
}, [updateSub]);
|
|
686
|
-
react_1.default.useEffect(() => {
|
|
687
|
-
const method = (...args) => onUpdate(...args);
|
|
688
|
-
if ((0, utils_1.is)('function', previousSub === null || previousSub === void 0 ? void 0 : previousSub.subscribe))
|
|
689
|
-
previousSub === null || previousSub === void 0 ? void 0 : previousSub.subscribe(method);
|
|
690
|
-
return () => {
|
|
691
|
-
if ((0, utils_1.is)('function', previousSub === null || previousSub === void 0 ? void 0 : previousSub.unsubscribe))
|
|
692
|
-
previousSub === null || previousSub === void 0 ? void 0 : previousSub.unsubscribe(method);
|
|
693
|
-
};
|
|
694
|
-
}, [previousSub]);
|
|
695
|
-
react_1.default.useEffect(() => {
|
|
696
|
-
const method = (...args) => onUpdate(...args);
|
|
697
|
-
if ((0, utils_1.is)('function', nextSub === null || nextSub === void 0 ? void 0 : nextSub.subscribe))
|
|
698
|
-
nextSub === null || nextSub === void 0 ? void 0 : nextSub.subscribe(method);
|
|
699
|
-
return () => {
|
|
700
|
-
if ((0, utils_1.is)('function', nextSub === null || nextSub === void 0 ? void 0 : nextSub.unsubscribe))
|
|
701
|
-
nextSub === null || nextSub === void 0 ? void 0 : nextSub.unsubscribe(method);
|
|
702
|
-
};
|
|
703
|
-
}, [nextSub]);
|
|
704
|
-
react_1.default.useEffect(() => {
|
|
705
|
-
const values = (0, utils_1.unique)([
|
|
706
|
-
...items_,
|
|
707
|
-
...react_1.default.Children.toArray(children)
|
|
708
|
-
])
|
|
709
|
-
.filter(Boolean);
|
|
710
|
-
const previous = refs.items.current.reduce((result, item) => result += (0, utils_1.is)('string', item) ? item : item === null || item === void 0 ? void 0 : item.key, '');
|
|
711
|
-
const updated = values.reduce((result, item) => result += (0, utils_1.is)('string', item) ? item : item === null || item === void 0 ? void 0 : item.key, '');
|
|
712
|
-
if (updated !== previous) {
|
|
713
|
-
onUpdate('next', values);
|
|
714
|
-
setItems(values);
|
|
615
|
+
if (refs.orientation.current === 'vertical') {
|
|
616
|
+
var _refs$mouseDownPositi3;
|
|
617
|
+
const {
|
|
618
|
+
y
|
|
619
|
+
} = refs.value.current;
|
|
620
|
+
let index = refs.value.current.index;
|
|
621
|
+
if (((_refs$mouseDownPositi3 = refs.mouseDownPosition.current) === null || _refs$mouseDownPositi3 === void 0 ? void 0 : _refs$mouseDownPositi3.y) > y) index++;
|
|
622
|
+
const height_ = refs.carousel.current.getBoundingClientRect().height;
|
|
623
|
+
const original = index * height_ + index * (gap * theme.space.unit);
|
|
624
|
+
const threshold = height_ / 4;
|
|
625
|
+
const moved = Math.abs(original - y);
|
|
626
|
+
if (y > 0 && y < original && moved >= threshold) onUpdate(index - 1);else if (y > original && moved >= threshold) onUpdate(index + 1);else onUpdate(index);
|
|
715
627
|
}
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
628
|
+
}
|
|
629
|
+
setMouseDown(false);
|
|
630
|
+
refs.previousMouseEvent.current = undefined;
|
|
631
|
+
}
|
|
632
|
+
}, []);
|
|
633
|
+
_react.default.useEffect(() => {
|
|
634
|
+
var _refs$root$current;
|
|
635
|
+
const onKeyDown = event => {
|
|
636
|
+
if (refs.focus.current) {
|
|
637
|
+
switch (event.key) {
|
|
638
|
+
case 'ArrowLeft':
|
|
722
639
|
return onUpdate('previous');
|
|
723
|
-
|
|
724
|
-
if ((refs.orientation.current === 'horizontal' && event.deltaX > 0) ||
|
|
725
|
-
(refs.orientation.current === 'vertical' && event.deltaY > 0)) {
|
|
726
|
-
event.preventDefault();
|
|
727
|
-
event.stopPropagation();
|
|
640
|
+
case 'ArrowRight':
|
|
728
641
|
return onUpdate('next');
|
|
642
|
+
default:
|
|
643
|
+
break;
|
|
729
644
|
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
if ((0, utils_1.is)('function', onMouseLeave_))
|
|
762
|
-
onMouseLeave_(event);
|
|
763
|
-
}, []);
|
|
764
|
-
const onArrowMouseEnter = react_1.default.useCallback((event) => {
|
|
765
|
-
setHover(true);
|
|
766
|
-
if (refs.autoPlay.current)
|
|
767
|
-
clear();
|
|
768
|
-
}, []);
|
|
769
|
-
const ArrowPreviousTransitionComponent_ = ArrowPreviousTransitionComponent || ArrowTransitionComponent;
|
|
770
|
-
const ArrowNextTransitionComponent_ = ArrowNextTransitionComponent || ArrowTransitionComponent;
|
|
771
|
-
let TransitionComponent = TransitionComponent_;
|
|
772
|
-
if (noTransition)
|
|
773
|
-
TransitionComponent = react_1.default.Fragment;
|
|
774
|
-
if (version === 'regular') {
|
|
775
|
-
styles.carousel.transform = `translate3d(${orientation === 'horizontal' ? `${-((value === null || value === void 0 ? void 0 : value.x) || 0)}px, 0` : `0, ${-((value === null || value === void 0 ? void 0 : value.y) || 0)}px`}, 0)`;
|
|
776
|
-
}
|
|
777
|
-
const indexActive = value === null || value === void 0 ? void 0 : value.index;
|
|
778
|
-
let arrowPreviousIn = focus || (arrowsVisibility === 'hover' && hover) || arrowsVisibility === 'visible';
|
|
779
|
-
let arrowNextIn = focus || (arrowsVisibility === 'hover' && hover) || arrowsVisibility === 'visible';
|
|
780
|
-
if (arrowHideOnStartEnd) {
|
|
781
|
-
const min = 0;
|
|
782
|
-
let maxX = ((width + (gap * theme.space.unit)) * (refs.itemsLength.current - 1));
|
|
783
|
-
let maxY = ((height + (gap * theme.space.unit)) * (refs.itemsLength.current - 1));
|
|
784
|
-
if (refs.itemSize.current === 'auto') {
|
|
785
|
-
maxX = (scrollWidth - (scrollWidth / refs.itemsLength.current)) + ((gap * theme.space.unit) * (refs.itemsLength.current - 1));
|
|
786
|
-
maxY = (scrollHeight - (scrollHeight / refs.itemsLength.current)) + ((gap * theme.space.unit) * (refs.itemsLength.current - 1));
|
|
787
|
-
}
|
|
788
|
-
if ((value === null || value === void 0 ? void 0 : value.x) === min || (value === null || value === void 0 ? void 0 : value.y) === min)
|
|
789
|
-
arrowPreviousIn = false;
|
|
790
|
-
if (itemSize === 'auto') {
|
|
791
|
-
if (((value === null || value === void 0 ? void 0 : value.x) !== undefined && (value === null || value === void 0 ? void 0 : value.x) + 1 >= maxX) || ((value === null || value === void 0 ? void 0 : value.y) !== undefined && (value === null || value === void 0 ? void 0 : value.y) + 1 >= maxY))
|
|
792
|
-
arrowNextIn = false;
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
const onMove = (x_, y_) => {
|
|
648
|
+
if (refs.version.current === 'regular' && refs.move.current && refs.mouseDown.current && refs.previousMouseEvent.current) {
|
|
649
|
+
const incX = x_ - refs.previousMouseEvent.current.clientX;
|
|
650
|
+
const incY = y_ - refs.previousMouseEvent.current.clientY;
|
|
651
|
+
const {
|
|
652
|
+
width: width_,
|
|
653
|
+
height: height_
|
|
654
|
+
} = refs.carousel.current.getBoundingClientRect();
|
|
655
|
+
const {
|
|
656
|
+
scrollWidth: scrollWidth_,
|
|
657
|
+
scrollHeight: scrollHeight_
|
|
658
|
+
} = refs.carousel.current;
|
|
659
|
+
if (refs.orientation.current === 'horizontal' && incX !== 0) {
|
|
660
|
+
var _refs$value$current7, _refs$value$current8, _refs$value$current9;
|
|
661
|
+
const min = 0;
|
|
662
|
+
let max = (width_ + gap * theme.space.unit) * (refs.itemsLength.current - 1);
|
|
663
|
+
if (refs.itemSize.current === 'auto') {
|
|
664
|
+
max = scrollWidth_ - scrollWidth_ / refs.itemsLength.current + gap * theme.space.unit * (refs.itemsLength.current - 1);
|
|
665
|
+
}
|
|
666
|
+
let x = (((_refs$value$current7 = refs.value.current) === null || _refs$value$current7 === void 0 ? void 0 : _refs$value$current7.x) || 0) - incX;
|
|
667
|
+
if (refs.free.current || !refs.moveBeyondEdge.current) x = (0, _utils.clamp)(x, min, max);
|
|
668
|
+
|
|
669
|
+
// Move beyond min, max
|
|
670
|
+
if (x < min || x > max) x = (((_refs$value$current8 = refs.value.current) === null || _refs$value$current8 === void 0 ? void 0 : _refs$value$current8.x) || 0) - incX / 1.7;
|
|
671
|
+
refs.velocity.current = x - (((_refs$value$current9 = refs.value.current) === null || _refs$value$current9 === void 0 ? void 0 : _refs$value$current9.x) || 0);
|
|
672
|
+
onUpdatePosition({
|
|
673
|
+
index: Math.floor(x / (max / (refs.itemsLength.current - 1))),
|
|
674
|
+
x
|
|
675
|
+
});
|
|
793
676
|
}
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
677
|
+
if (refs.orientation.current === 'vertical' && incY !== 0) {
|
|
678
|
+
var _refs$value$current10, _refs$value$current11, _refs$value$current12;
|
|
679
|
+
const min = 0;
|
|
680
|
+
let max = (height_ + gap * theme.space.unit) * (refs.itemsLength.current - 1);
|
|
681
|
+
if (refs.itemSize.current === 'auto') {
|
|
682
|
+
max = scrollHeight_ - scrollHeight_ / refs.itemsLength.current + gap * theme.space.unit * (refs.itemsLength.current - 1);
|
|
683
|
+
}
|
|
684
|
+
let y = (((_refs$value$current10 = refs.value.current) === null || _refs$value$current10 === void 0 ? void 0 : _refs$value$current10.y) || 0) - incY;
|
|
685
|
+
if (refs.free.current || !refs.moveBeyondEdge.current) y = (0, _utils.clamp)(y, min, max);
|
|
686
|
+
|
|
687
|
+
// Move beyond min, max
|
|
688
|
+
if (y < min || y > max) y = (((_refs$value$current11 = refs.value.current) === null || _refs$value$current11 === void 0 ? void 0 : _refs$value$current11.y) || 0) - incY / 1.7;
|
|
689
|
+
refs.velocity.current = y - (((_refs$value$current12 = refs.value.current) === null || _refs$value$current12 === void 0 ? void 0 : _refs$value$current12.y) || 0);
|
|
690
|
+
onUpdatePosition({
|
|
691
|
+
index: Math.floor(y / (max / (refs.itemsLength.current - 1))),
|
|
692
|
+
y
|
|
693
|
+
});
|
|
797
694
|
}
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
// Mouse move
|
|
699
|
+
const onMouseMove = event => {
|
|
700
|
+
if (refs.mouseDown.current) {
|
|
701
|
+
const {
|
|
702
|
+
clientY,
|
|
703
|
+
clientX
|
|
704
|
+
} = event;
|
|
705
|
+
onMove(clientX, clientY);
|
|
706
|
+
refs.previousMouseEvent.current = event;
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
// Touch move
|
|
711
|
+
const onTouchMove = event => {
|
|
712
|
+
if (refs.mouseDown.current) {
|
|
713
|
+
const {
|
|
714
|
+
clientY,
|
|
715
|
+
clientX
|
|
716
|
+
} = event.touches[0];
|
|
717
|
+
onMove(clientX, clientY);
|
|
718
|
+
refs.previousMouseEvent.current = event;
|
|
719
|
+
|
|
720
|
+
// Normalize for use as a mouseDown value
|
|
721
|
+
refs.previousMouseEvent.current.clientY = clientY;
|
|
722
|
+
refs.previousMouseEvent.current.clientX = clientX;
|
|
723
|
+
}
|
|
724
|
+
};
|
|
725
|
+
const method = () => {
|
|
726
|
+
var _refs$value$current13;
|
|
727
|
+
return onUpdate((_refs$value$current13 = refs.value.current) === null || _refs$value$current13 === void 0 ? void 0 : _refs$value$current13.index);
|
|
728
|
+
};
|
|
729
|
+
const observer = new ResizeObserver(method);
|
|
730
|
+
method();
|
|
731
|
+
observer.observe(refs.root.current);
|
|
732
|
+
const rootDocument = (0, _utils.isEnvironment)('browser') ? ((_refs$root$current = refs.root.current) === null || _refs$root$current === void 0 ? void 0 : _refs$root$current.ownerDocument) || window.document : undefined;
|
|
733
|
+
rootDocument.addEventListener('keydown', onKeyDown);
|
|
734
|
+
rootDocument.addEventListener('mouseup', onMouseUp);
|
|
735
|
+
rootDocument.addEventListener('mousemove', onMouseMove);
|
|
736
|
+
rootDocument.addEventListener('touchend', onMouseUp);
|
|
737
|
+
rootDocument.addEventListener('touchmove', onTouchMove, {
|
|
738
|
+
passive: true
|
|
739
|
+
});
|
|
740
|
+
setInit(true);
|
|
741
|
+
if ((0, _utils.is)('function', refs.onInit.current)) refs.onInit.current();
|
|
742
|
+
return () => {
|
|
743
|
+
observer.disconnect();
|
|
744
|
+
rootDocument.removeEventListener('keydown', onKeyDown);
|
|
745
|
+
rootDocument.removeEventListener('mousemove', onMouseMove);
|
|
746
|
+
rootDocument.removeEventListener('mouseup', onMouseUp);
|
|
747
|
+
rootDocument.removeEventListener('touchmove', onTouchMove);
|
|
748
|
+
rootDocument.removeEventListener('touchend', onMouseUp);
|
|
749
|
+
};
|
|
750
|
+
}, []);
|
|
751
|
+
_react.default.useEffect(() => {
|
|
752
|
+
if (value_ !== undefined && !(0, _utils.equalDeep)(value_, refs.value.current)) setValue(valuePrevious => _objectSpread(_objectSpread({}, valuePrevious), value_));
|
|
753
|
+
}, [value_]);
|
|
754
|
+
_react.default.useEffect(() => {
|
|
755
|
+
if (init) {
|
|
756
|
+
var _refs$value$current14;
|
|
757
|
+
if (index_ >= 0 && index_ <= refs.itemsLength.current && index_ !== ((_refs$value$current14 = refs.value.current) === null || _refs$value$current14 === void 0 ? void 0 : _refs$value$current14.index)) onUpdate(index_);
|
|
798
758
|
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
759
|
+
}, [index_]);
|
|
760
|
+
_react.default.useEffect(() => {
|
|
761
|
+
if ((0, _utils.is)('function', onUpdateItems)) onUpdateItems();
|
|
762
|
+
}, [items, onUpdateItems, theme.palette.light]);
|
|
763
|
+
_react.default.useEffect(() => {
|
|
764
|
+
setItems(items_);
|
|
765
|
+
}, [id, items_]);
|
|
766
|
+
const onPrevious = () => onUpdate('previous');
|
|
767
|
+
const onNext = () => onUpdate('next');
|
|
768
|
+
const clear = () => {
|
|
769
|
+
clearTimeout(refs.autoPlayTimeout.current);
|
|
770
|
+
refs.autoPlay.current = false;
|
|
771
|
+
};
|
|
772
|
+
const start = () => {
|
|
773
|
+
clear();
|
|
774
|
+
if (!autoPlay || mouseDown || focus) return;
|
|
775
|
+
if (pauseOnHover && hover) return;
|
|
776
|
+
refs.autoPlayTimeout.current = setTimeout(onUpdate, autoPlayInterval);
|
|
777
|
+
refs.autoPlay.current = true;
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
// autoPlay
|
|
781
|
+
_react.default.useEffect(() => {
|
|
782
|
+
start();
|
|
783
|
+
}, [items, value, autoPlay, autoPlayInterval]);
|
|
784
|
+
|
|
785
|
+
// OnesySubscription methods
|
|
786
|
+
_react.default.useEffect(() => {
|
|
787
|
+
const method = (...args) => onUpdate(...args);
|
|
788
|
+
if ((0, _utils.is)('function', updateSub === null || updateSub === void 0 ? void 0 : updateSub.subscribe)) updateSub === null || updateSub === void 0 || updateSub.subscribe(method);
|
|
789
|
+
return () => {
|
|
790
|
+
if ((0, _utils.is)('function', updateSub === null || updateSub === void 0 ? void 0 : updateSub.unsubscribe)) updateSub === null || updateSub === void 0 || updateSub.unsubscribe(method);
|
|
791
|
+
};
|
|
792
|
+
}, [updateSub]);
|
|
793
|
+
_react.default.useEffect(() => {
|
|
794
|
+
const method = (...args) => onUpdate(...args);
|
|
795
|
+
if ((0, _utils.is)('function', previousSub === null || previousSub === void 0 ? void 0 : previousSub.subscribe)) previousSub === null || previousSub === void 0 || previousSub.subscribe(method);
|
|
796
|
+
return () => {
|
|
797
|
+
if ((0, _utils.is)('function', previousSub === null || previousSub === void 0 ? void 0 : previousSub.unsubscribe)) previousSub === null || previousSub === void 0 || previousSub.unsubscribe(method);
|
|
821
798
|
};
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
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
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
799
|
+
}, [previousSub]);
|
|
800
|
+
_react.default.useEffect(() => {
|
|
801
|
+
const method = (...args) => onUpdate(...args);
|
|
802
|
+
if ((0, _utils.is)('function', nextSub === null || nextSub === void 0 ? void 0 : nextSub.subscribe)) nextSub === null || nextSub === void 0 || nextSub.subscribe(method);
|
|
803
|
+
return () => {
|
|
804
|
+
if ((0, _utils.is)('function', nextSub === null || nextSub === void 0 ? void 0 : nextSub.unsubscribe)) nextSub === null || nextSub === void 0 || nextSub.unsubscribe(method);
|
|
805
|
+
};
|
|
806
|
+
}, [nextSub]);
|
|
807
|
+
_react.default.useEffect(() => {
|
|
808
|
+
const values = (0, _utils.unique)([...items_, ..._react.default.Children.toArray(children)]).filter(Boolean);
|
|
809
|
+
const previous = refs.items.current.reduce((result, item) => result += (0, _utils.is)('string', item) ? item : item === null || item === void 0 ? void 0 : item.key, '');
|
|
810
|
+
const updated = values.reduce((result, item) => result += (0, _utils.is)('string', item) ? item : item === null || item === void 0 ? void 0 : item.key, '');
|
|
811
|
+
if (updated !== previous) {
|
|
812
|
+
onUpdate('next', values);
|
|
813
|
+
setItems(values);
|
|
814
|
+
}
|
|
815
|
+
}, [items_, background, children]);
|
|
816
|
+
const onWheel = _react.default.useCallback((0, _utils.debounce)(event => {
|
|
817
|
+
if (refs.orientation.current === 'horizontal' && event.deltaX < 0 || refs.orientation.current === 'vertical' && event.deltaY < 0) {
|
|
818
|
+
event.preventDefault();
|
|
819
|
+
event.stopPropagation();
|
|
820
|
+
return onUpdate('previous');
|
|
821
|
+
}
|
|
822
|
+
if (refs.orientation.current === 'horizontal' && event.deltaX > 0 || refs.orientation.current === 'vertical' && event.deltaY > 0) {
|
|
823
|
+
event.preventDefault();
|
|
824
|
+
event.stopPropagation();
|
|
825
|
+
return onUpdate('next');
|
|
826
|
+
}
|
|
827
|
+
}, 40), []);
|
|
828
|
+
const onBlur = _react.default.useCallback(event => {
|
|
829
|
+
setFocus(false);
|
|
830
|
+
if ((0, _utils.is)('function', onBlur_)) onBlur_(event);
|
|
831
|
+
}, []);
|
|
832
|
+
const onFocus = _react.default.useCallback(event => {
|
|
833
|
+
setFocus(true);
|
|
834
|
+
if ((0, _utils.is)('function', onFocus_)) onFocus_(event);
|
|
835
|
+
}, []);
|
|
836
|
+
const onMouseDown = _react.default.useCallback(event => {
|
|
837
|
+
// Momentum
|
|
838
|
+
momentumClear();
|
|
839
|
+
setMouseDown(event);
|
|
840
|
+
refs.mouseDownPosition.current = _objectSpread({}, refs.value.current);
|
|
841
|
+
refs.mouseDownStart.current = new Date().getTime();
|
|
842
|
+
refs.carousel.current.style.transition = 'none';
|
|
843
|
+
}, []);
|
|
844
|
+
const onMouseEnter = _react.default.useCallback(event => {
|
|
845
|
+
setHover(true);
|
|
846
|
+
if (refs.autoPlay.current) clear();
|
|
847
|
+
if ((0, _utils.is)('function', onMouseEnter_)) onMouseEnter_(event);
|
|
848
|
+
}, []);
|
|
849
|
+
const onMouseLeave = _react.default.useCallback(event => {
|
|
850
|
+
setFocus(false);
|
|
851
|
+
setHover(false);
|
|
852
|
+
if (!refs.autoPlay.current) start();
|
|
853
|
+
if ((0, _utils.is)('function', onMouseLeave_)) onMouseLeave_(event);
|
|
854
|
+
}, []);
|
|
855
|
+
const onArrowMouseEnter = _react.default.useCallback(event => {
|
|
856
|
+
setHover(true);
|
|
857
|
+
if (refs.autoPlay.current) clear();
|
|
858
|
+
}, []);
|
|
859
|
+
const ArrowPreviousTransitionComponent_ = ArrowPreviousTransitionComponent || ArrowTransitionComponent;
|
|
860
|
+
const ArrowNextTransitionComponent_ = ArrowNextTransitionComponent || ArrowTransitionComponent;
|
|
861
|
+
let TransitionComponent = TransitionComponent_;
|
|
862
|
+
if (noTransition) TransitionComponent = _react.default.Fragment;
|
|
863
|
+
if (version === 'regular') {
|
|
864
|
+
styles.carousel.transform = `translate3d(${orientation === 'horizontal' ? `${-((value === null || value === void 0 ? void 0 : value.x) || 0)}px, 0` : `0, ${-((value === null || value === void 0 ? void 0 : value.y) || 0)}px`}, 0)`;
|
|
865
|
+
}
|
|
866
|
+
const indexActive = value === null || value === void 0 ? void 0 : value.index;
|
|
867
|
+
let arrowPreviousIn = focus || arrowsVisibility === 'hover' && hover || arrowsVisibility === 'visible';
|
|
868
|
+
let arrowNextIn = focus || arrowsVisibility === 'hover' && hover || arrowsVisibility === 'visible';
|
|
869
|
+
if (arrowHideOnStartEnd) {
|
|
870
|
+
const min = 0;
|
|
871
|
+
let maxX = (width + gap * theme.space.unit) * (refs.itemsLength.current - 1);
|
|
872
|
+
let maxY = (height + gap * theme.space.unit) * (refs.itemsLength.current - 1);
|
|
873
|
+
if (refs.itemSize.current === 'auto') {
|
|
874
|
+
maxX = scrollWidth - scrollWidth / refs.itemsLength.current + gap * theme.space.unit * (refs.itemsLength.current - 1);
|
|
875
|
+
maxY = scrollHeight - scrollHeight / refs.itemsLength.current + gap * theme.space.unit * (refs.itemsLength.current - 1);
|
|
876
|
+
}
|
|
877
|
+
if ((value === null || value === void 0 ? void 0 : value.x) === min || (value === null || value === void 0 ? void 0 : value.y) === min) arrowPreviousIn = false;
|
|
878
|
+
if (itemSize === 'auto') {
|
|
879
|
+
if ((value === null || value === void 0 ? void 0 : value.x) !== undefined && (value === null || value === void 0 ? void 0 : value.x) + 1 >= maxX || (value === null || value === void 0 ? void 0 : value.y) !== undefined && (value === null || value === void 0 ? void 0 : value.y) + 1 >= maxY) arrowNextIn = false;
|
|
880
|
+
} else {
|
|
881
|
+
if ((value === null || value === void 0 ? void 0 : value.x) !== undefined && (value === null || value === void 0 ? void 0 : value.x) + 1 >= maxX || (value === null || value === void 0 ? void 0 : value.y) + 1 !== undefined && (value === null || value === void 0 ? void 0 : value.y) >= maxY) arrowNextIn = false;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
const ArrowPreviousProps = _objectSpread(_objectSpread({}, ArrowPreviousProps_), {}, {
|
|
885
|
+
'aria-label': 'Arrow previous',
|
|
886
|
+
'aria-controls': refs.ids.items
|
|
887
|
+
});
|
|
888
|
+
const ArrowNextProps = _objectSpread(_objectSpread({}, ArrowNextProps_), {}, {
|
|
889
|
+
'aria-label': 'Arrow next',
|
|
890
|
+
'aria-controls': refs.ids.items
|
|
891
|
+
});
|
|
892
|
+
const resolveItem = Item => {
|
|
893
|
+
if (!Item) return null;
|
|
894
|
+
if ((0, _utils.is)('string', Item)) {
|
|
895
|
+
if (background) return /*#__PURE__*/_react.default.createElement("div", {
|
|
896
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Carousel', theme) && ['onesy-Carousel-background'], classes.background]),
|
|
897
|
+
style: {
|
|
898
|
+
backgroundImage: `url(${Item})`
|
|
899
|
+
}
|
|
900
|
+
});
|
|
901
|
+
return /*#__PURE__*/_react.default.createElement("img", {
|
|
902
|
+
src: Item,
|
|
903
|
+
alt: ""
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
if ((0, _utils.is)('function', Item)) return Item(refs.value.current);
|
|
907
|
+
if (Item !== null && Item !== void 0 && Item.element) return /*#__PURE__*/_react.default.cloneElement(Item.element);
|
|
908
|
+
return /*#__PURE__*/_react.default.cloneElement(Item);
|
|
909
|
+
};
|
|
910
|
+
return /*#__PURE__*/_react.default.createElement(Surface, (0, _extends2.default)({
|
|
911
|
+
ref: item => {
|
|
912
|
+
if (ref) {
|
|
913
|
+
if ((0, _utils.is)('function', ref)) ref(item);else ref.current = item;
|
|
914
|
+
}
|
|
915
|
+
refs.root.current = item;
|
|
916
|
+
},
|
|
917
|
+
tabIndex: "0",
|
|
918
|
+
role: "region",
|
|
919
|
+
"aria-roledescription": "carousel",
|
|
920
|
+
tonal: tonal,
|
|
921
|
+
color: color,
|
|
922
|
+
onFocus: onFocus,
|
|
923
|
+
onBlur: onBlur,
|
|
924
|
+
onMouseEnter: onMouseEnter,
|
|
925
|
+
onMouseLeave: onMouseLeave,
|
|
926
|
+
Component: Component,
|
|
927
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Carousel', theme) && ['onesy-Carousel-root'], className, classes.root, autoHeight && classes.autoHeight])
|
|
928
|
+
}, other), start_, version === 'regular' && /*#__PURE__*/_react.default.createElement(Line, (0, _extends2.default)({
|
|
929
|
+
ref: refs.carousel,
|
|
930
|
+
gap: gap,
|
|
931
|
+
direction: orientation === 'horizontal' ? theme.direction === 'ltr' ? 'row' : 'row-reverse' : 'column',
|
|
932
|
+
align: "center",
|
|
933
|
+
justify: "flex-start",
|
|
934
|
+
onWheel: mouseScroll && onWheel,
|
|
935
|
+
onMouseDown: onMouseDown,
|
|
936
|
+
onTouchStart: onMouseDown,
|
|
937
|
+
onMouseUp: onMouseUp,
|
|
938
|
+
onTouchEnd: onMouseUp,
|
|
939
|
+
id: refs.ids.items,
|
|
940
|
+
"aria-live": "polite"
|
|
941
|
+
}, CarouselProps, {
|
|
942
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Carousel', theme) && ['onesy-Carousel-carousel'], CarouselProps === null || CarouselProps === void 0 ? void 0 : CarouselProps.className, classes.carousel, classes[`carousel_version_${version}`]]),
|
|
943
|
+
style: _objectSpread(_objectSpread({}, styles.carousel), CarouselProps === null || CarouselProps === void 0 ? void 0 : CarouselProps.style)
|
|
944
|
+
}), items.map((item, index) => /*#__PURE__*/_react.default.createElement(Line, (0, _extends2.default)({
|
|
945
|
+
key: index,
|
|
946
|
+
gap: 0,
|
|
947
|
+
direction: "column",
|
|
948
|
+
align: "center",
|
|
949
|
+
justify: "center",
|
|
950
|
+
role: "group",
|
|
951
|
+
"aria-roledescription": "slide",
|
|
952
|
+
"aria-label": `${index + 1} out of ${refs.itemsLength.current}`
|
|
953
|
+
}, ItemWrapperProps, {
|
|
954
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Carousel', theme) && ['onesy-Carousel-item'], ItemWrapperProps === null || ItemWrapperProps === void 0 ? void 0 : ItemWrapperProps.className, classes.item, autoHeight && classes[`item_version_${version}_autoHeight`], itemSize && classes[`item_itemSize_${itemSize}`]])
|
|
955
|
+
}), resolveItem(item)))), version === 'transition' && /*#__PURE__*/_react.default.createElement(Line, (0, _extends2.default)({
|
|
956
|
+
ref: refs.carousel,
|
|
957
|
+
gap: 0.5,
|
|
958
|
+
direction: orientation === 'horizontal' ? theme.direction === 'ltr' ? 'row' : 'row-reverse' : 'column',
|
|
959
|
+
align: "center",
|
|
960
|
+
justify: "center",
|
|
961
|
+
onWheel: mouseScroll && onWheel,
|
|
962
|
+
onMouseDown: onMouseDown,
|
|
963
|
+
onTouchStart: onMouseDown,
|
|
964
|
+
onMouseUp: onMouseUp,
|
|
965
|
+
onTouchEnd: onMouseUp,
|
|
966
|
+
id: refs.ids.items,
|
|
967
|
+
"aria-live": "polite"
|
|
968
|
+
}, CarouselProps, {
|
|
969
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Carousel', theme) && ['onesy-Carousel-carousel'], CarouselProps === null || CarouselProps === void 0 ? void 0 : CarouselProps.className, classes.carousel])
|
|
970
|
+
}), value && /*#__PURE__*/_react.default.createElement(Transitions, (0, _extends2.default)({
|
|
971
|
+
mode: "in-out-follow",
|
|
972
|
+
switch: true
|
|
973
|
+
}, TransitionsProps), /*#__PURE__*/_react.default.createElement(TransitionComponent, (0, _extends2.default)({
|
|
974
|
+
key: indexActive
|
|
975
|
+
}, TransitionComponentProps), /*#__PURE__*/_react.default.createElement(Line, {
|
|
976
|
+
ref: refs.item,
|
|
977
|
+
gap: 0,
|
|
978
|
+
direction: "column",
|
|
979
|
+
align: "center",
|
|
980
|
+
justify: "center",
|
|
981
|
+
role: "group",
|
|
982
|
+
"aria-roledescription": "slide",
|
|
983
|
+
"aria-label": `${value.index + 1} out of ${refs.itemsLength.current}`,
|
|
984
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Carousel', theme) && ['onesy-Carousel-item-transition'], classes.item_transition, autoHeight && classes[`item_version_${version}_autoHeight`]])
|
|
985
|
+
}, resolveItem(value.element))))), progress && /*#__PURE__*/_react.default.createElement(ProgressTransitionComponent, (0, _extends2.default)({
|
|
986
|
+
in: focus || progressVisibility === 'hover' && hover || progressVisibility === 'visible'
|
|
987
|
+
}, ProgressTransitionComponentProps), (0, _utils.is)('function', renderProgress) ? renderProgress(onUpdate) : /*#__PURE__*/_react.default.createElement(Line, {
|
|
988
|
+
gap: 1,
|
|
989
|
+
direction: orientation === 'horizontal' ? theme.direction === 'ltr' ? 'row' : 'row-reverse' : 'column',
|
|
990
|
+
align: "center",
|
|
991
|
+
justify: "center",
|
|
992
|
+
wrap: "wrap",
|
|
993
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Carousel', theme) && ['onesy-Carousel-progress'], classes.progress, classes[`progress_orientation_${orientation}`]])
|
|
994
|
+
}, Array.from({
|
|
995
|
+
length: refs.itemsLength.current
|
|
996
|
+
}).map((item, index) => /*#__PURE__*/_react.default.createElement("span", {
|
|
997
|
+
key: index,
|
|
998
|
+
onClick: () => onUpdate(index),
|
|
999
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Carousel', theme) && ['onesy-Carousel-progress-item', indexActive === index && 'onesy-Carousel-progress-item-active'], classes.progress_item, indexActive === index && classes.progress_item_active])
|
|
1000
|
+
})))), arrows && /*#__PURE__*/_react.default.createElement(ArrowPreviousTransitionComponent_, (0, _extends2.default)({
|
|
1001
|
+
in: arrowPreviousIn
|
|
1002
|
+
}, ArrowTransitionComponentProps, ArrowPreviousTransitionComponentProps), (0, _utils.is)('function', renderArrowPrevious) ? renderArrowPrevious(() => onUpdate('previous')) : IconButtonPrevious ? /*#__PURE__*/_react.default.cloneElement(IconButtonPrevious, _objectSpread(_objectSpread(_objectSpread({
|
|
1003
|
+
tonal,
|
|
1004
|
+
color,
|
|
1005
|
+
onClick: onPrevious,
|
|
1006
|
+
onMouseEnter: onArrowMouseEnter
|
|
1007
|
+
}, ArrowProps), ArrowPreviousProps), {}, {
|
|
1008
|
+
disabled: !round && indexActive === 0,
|
|
1009
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Carousel', theme) && ['onesy-Carousel-arrow', 'onesy-Carousel-arrow-previous'], ArrowProps === null || ArrowProps === void 0 ? void 0 : ArrowProps.className, ArrowPreviousProps === null || ArrowPreviousProps === void 0 ? void 0 : ArrowPreviousProps.className, classes.arrow, classes.arrow_previous, classes[`arrow_previous_orientation_${orientation}`]])
|
|
1010
|
+
})) : /*#__PURE__*/_react.default.createElement(IconButton, (0, _extends2.default)({
|
|
1011
|
+
tonal: tonal,
|
|
1012
|
+
color: color,
|
|
1013
|
+
version: "filled",
|
|
1014
|
+
onClick: onPrevious,
|
|
1015
|
+
onMouseEnter: onArrowMouseEnter
|
|
1016
|
+
}, ArrowProps, ArrowPreviousProps, {
|
|
1017
|
+
disabled: !round && indexActive === 0,
|
|
1018
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Carousel', theme) && ['onesy-Carousel-arrow', 'onesy-Carousel-arrow-previous'], ArrowProps === null || ArrowProps === void 0 ? void 0 : ArrowProps.className, ArrowPreviousProps === null || ArrowPreviousProps === void 0 ? void 0 : ArrowPreviousProps.className, classes.arrow, classes.arrow_previous, classes[`arrow_previous_orientation_${orientation}`]])
|
|
1019
|
+
}), /*#__PURE__*/_react.default.createElement(IconPrevious, {
|
|
1020
|
+
noRtl: true,
|
|
1021
|
+
className: (0, _styleReact.classNames)([classes[`icon_previous_orientation_${orientation}`]])
|
|
1022
|
+
}))), arrows && /*#__PURE__*/_react.default.createElement(ArrowNextTransitionComponent_, (0, _extends2.default)({
|
|
1023
|
+
in: arrowNextIn
|
|
1024
|
+
}, ArrowTransitionComponentProps, ArrowNextTransitionComponentProps), (0, _utils.is)('function', renderArrowNext) ? renderArrowNext(() => onUpdate('next')) : IconButtonNext ? /*#__PURE__*/_react.default.cloneElement(IconButtonNext, _objectSpread(_objectSpread(_objectSpread({
|
|
1025
|
+
tonal,
|
|
1026
|
+
color,
|
|
1027
|
+
onClick: onNext,
|
|
1028
|
+
onMouseEnter: onArrowMouseEnter
|
|
1029
|
+
}, ArrowProps), ArrowNextProps), {}, {
|
|
1030
|
+
disabled: !round && indexActive === items.length - 1,
|
|
1031
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Carousel', theme) && ['onesy-Carousel-arrow', 'onesy-Carousel-arrow-next'], ArrowProps === null || ArrowProps === void 0 ? void 0 : ArrowProps.className, ArrowNextProps === null || ArrowNextProps === void 0 ? void 0 : ArrowNextProps.className, classes.arrow, classes.arrow_next, classes[`arrow_next_orientation_${orientation}`]])
|
|
1032
|
+
})) : /*#__PURE__*/_react.default.createElement(IconButton, (0, _extends2.default)({
|
|
1033
|
+
tonal: tonal,
|
|
1034
|
+
color: color,
|
|
1035
|
+
version: "filled",
|
|
1036
|
+
onClick: onNext,
|
|
1037
|
+
onMouseEnter: onArrowMouseEnter
|
|
1038
|
+
}, ArrowProps, ArrowNextProps, {
|
|
1039
|
+
disabled: !round && indexActive === items.length - 1,
|
|
1040
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Carousel', theme) && ['onesy-Carousel-arrow', 'onesy-Carousel-arrow-next'], ArrowProps === null || ArrowProps === void 0 ? void 0 : ArrowProps.className, ArrowNextProps === null || ArrowNextProps === void 0 ? void 0 : ArrowNextProps.className, classes.arrow, classes.arrow_next, classes[`arrow_next_orientation_${orientation}`]])
|
|
1041
|
+
}), /*#__PURE__*/_react.default.createElement(IconNext, {
|
|
1042
|
+
noRtl: true,
|
|
1043
|
+
className: (0, _styleReact.classNames)([classes[`icon_next_orientation_${orientation}`]])
|
|
1044
|
+
}))), end_);
|
|
933
1045
|
});
|
|
934
1046
|
Carousel.displayName = 'onesy-Carousel';
|
|
935
|
-
exports.default = Carousel;
|
|
1047
|
+
var _default = exports.default = Carousel;
|