@onesy/ui-react 1.0.129 → 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/BottomAppBar/BottomAppBar.js +5 -4
- 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/Slider/Slider.js
CHANGED
|
@@ -1,857 +1,947 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
let value__ = (0, utils_1.valueFromPercentageWithinRange)(valueMouse * 100, refs.min.current, refs.max.current);
|
|
394
|
-
if (refs.direction.current === 'rtl' && orientation === 'horizontal')
|
|
395
|
-
value__ = (refs.max.current + refs.min.current) - value__;
|
|
396
|
-
if (value__ <= refs.min.current)
|
|
397
|
-
return refs.min.current;
|
|
398
|
-
if (value__ >= refs.max.current)
|
|
399
|
-
return refs.max.current;
|
|
400
|
-
// previous value
|
|
401
|
-
let previous = (0, utils_1.clamp)(+(value__ - (value__ % precision)).toFixed(valueDecimals), refs.min.current, refs.max.current);
|
|
402
|
-
if (value__ < 0)
|
|
403
|
-
previous -= precision;
|
|
404
|
-
if (onlyMarks && (0, utils_1.is)('array', marks)) {
|
|
405
|
-
const previousMark = marks.map(item => item.value).sort((a, b) => b - a).find(item => item <= value__);
|
|
406
|
-
previous = previousMark !== undefined ? previousMark : refs.min.current;
|
|
407
|
-
}
|
|
408
|
-
// next value
|
|
409
|
-
let next = (0, utils_1.clamp)(+(previous + precision).toFixed(valueDecimals), refs.min.current, refs.max.current);
|
|
410
|
-
if (onlyMarks && (0, utils_1.is)('array', marks)) {
|
|
411
|
-
const nextMark = marks.map(item => item.value).sort((a, b) => a - b).find(item => item >= value__);
|
|
412
|
-
next = nextMark !== undefined ? nextMark : refs.max.current;
|
|
413
|
-
}
|
|
414
|
-
const valueNew = value__ < previous + ((next - previous) / 2) ? previous : next;
|
|
415
|
-
if (mouseDownButtonUpdate && (0, utils_1.is)('array', refs.value.current)) {
|
|
416
|
-
const items = refs.value.current.map(item => Math.abs(valueNew - item));
|
|
417
|
-
const minItem = Math.min(...items);
|
|
418
|
-
const index = items.findIndex(item => item === minItem);
|
|
419
|
-
setMouseDownButton(index);
|
|
420
|
-
refs.mouseDownButton.current = index;
|
|
421
|
-
}
|
|
422
|
-
return valueNew;
|
|
423
|
-
};
|
|
424
|
-
react_1.default.useEffect(() => {
|
|
425
|
-
var _a;
|
|
426
|
-
const onMouseUp = () => {
|
|
427
|
-
if (!disabled && !readOnly) {
|
|
428
|
-
setMouseDown(false);
|
|
429
|
-
setMouseDownButton(false);
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
const onMouseMove = (event) => {
|
|
433
|
-
if (!refs.props.current.disabled && !refs.props.current.readOnly && refs.mouseDown.current) {
|
|
434
|
-
let x;
|
|
435
|
-
let y;
|
|
436
|
-
if (event.clientX !== undefined) {
|
|
437
|
-
x = event.clientX;
|
|
438
|
-
y = event.clientY;
|
|
439
|
-
}
|
|
440
|
-
else {
|
|
441
|
-
x = event.touches[0].clientX;
|
|
442
|
-
y = event.touches[0].clientY;
|
|
443
|
-
}
|
|
444
|
-
const rect = refs.root.current.getBoundingClientRect();
|
|
445
|
-
const { width, height } = rect;
|
|
446
|
-
// Value to the precision point value
|
|
447
|
-
const value__ = valuePrecision(orientation === 'horizontal' ? (x - rect.x) / width : (1 - (y - rect.y) / height));
|
|
448
|
-
const valueNew = (0, utils_1.is)('array', refs.value.current) ? [...refs.value.current] : value__;
|
|
449
|
-
if ((0, utils_1.is)('array', refs.value.current)) {
|
|
450
|
-
let index = (0, utils_1.is)('number', refs.mouseDownButton.current) ? refs.mouseDownButton.current : 0;
|
|
451
|
-
if (index > 0 && value__ < refs.value.current[index - 1]) {
|
|
452
|
-
index -= 1;
|
|
453
|
-
setMouseDownButton(index);
|
|
454
|
-
}
|
|
455
|
-
if (index < refs.value.current.length - 1 && value__ > refs.value.current[index + 1]) {
|
|
456
|
-
index += 1;
|
|
457
|
-
setMouseDownButton(index);
|
|
458
|
-
}
|
|
459
|
-
valueNew[index] = value__;
|
|
460
|
-
}
|
|
461
|
-
if (!(0, utils_1.equalDeep)(valueNew, refs.value.current)) {
|
|
462
|
-
// Inner controlled value
|
|
463
|
-
if (!props.hasOwnProperty('value'))
|
|
464
|
-
setValue(valueNew);
|
|
465
|
-
if ((0, utils_1.is)('function', onChange))
|
|
466
|
-
onChange(valueNew);
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
};
|
|
470
|
-
const rootDocument = (0, utils_1.isEnvironment)('browser') ? (((_a = refs.root.current) === null || _a === void 0 ? void 0 : _a.ownerDocument) || window.document) : undefined;
|
|
471
|
-
rootDocument.addEventListener('mouseup', onMouseUp);
|
|
472
|
-
rootDocument.addEventListener('mousemove', onMouseMove);
|
|
473
|
-
rootDocument.addEventListener('touchend', onMouseUp, { passive: true });
|
|
474
|
-
rootDocument.addEventListener('touchmove', onMouseMove, { passive: true });
|
|
475
|
-
setInit(true);
|
|
476
|
-
return () => {
|
|
477
|
-
rootDocument.removeEventListener('mouseup', onMouseUp);
|
|
478
|
-
rootDocument.removeEventListener('touchend', onMouseUp);
|
|
479
|
-
rootDocument.removeEventListener('mousemove', onMouseMove);
|
|
480
|
-
rootDocument.removeEventListener('touchmove', onMouseMove);
|
|
481
|
-
};
|
|
482
|
-
}, []);
|
|
483
|
-
react_1.default.useEffect(() => {
|
|
484
|
-
if (init && value_ !== value)
|
|
485
|
-
setValue(value_);
|
|
486
|
-
}, [value_]);
|
|
487
|
-
const move = react_1.default.useCallback((x, y) => {
|
|
488
|
-
if (!disabled && !readOnly) {
|
|
489
|
-
const rect = refs.root.current.getBoundingClientRect();
|
|
490
|
-
const { width, height } = rect;
|
|
491
|
-
// Value to the precision point value
|
|
492
|
-
const value__ = valuePrecision(orientation === 'horizontal' ? (x - rect.x) / width : (1 - (y - rect.y) / height), true);
|
|
493
|
-
const valueNew = (0, utils_1.is)('array', refs.value.current) ? [...refs.value.current] : value__;
|
|
494
|
-
if ((0, utils_1.is)('array', refs.value.current)) {
|
|
495
|
-
let index = (0, utils_1.is)('number', refs.mouseDownButton.current) ? refs.mouseDownButton.current : 0;
|
|
496
|
-
if (index > 0 && value__ <= refs.value.current[index - 1]) {
|
|
497
|
-
index -= 1;
|
|
498
|
-
setMouseDownButton(index);
|
|
499
|
-
}
|
|
500
|
-
if (index < refs.value.current.length - 1 && value__ >= refs.value.current[index + 1]) {
|
|
501
|
-
index += 1;
|
|
502
|
-
setMouseDownButton(index);
|
|
503
|
-
}
|
|
504
|
-
valueNew[index] = value__;
|
|
505
|
-
}
|
|
506
|
-
if (!(0, utils_1.equalDeep)(valueNew, refs.value.current)) {
|
|
507
|
-
// Inner controlled value
|
|
508
|
-
if (!props.hasOwnProperty('value'))
|
|
509
|
-
setValue(valueNew);
|
|
510
|
-
if ((0, utils_1.is)('function', onChange))
|
|
511
|
-
onChange(valueNew);
|
|
512
|
-
}
|
|
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 _IconButton = _interopRequireDefault(require("../IconButton"));
|
|
15
|
+
var _Tooltip = _interopRequireDefault(require("../Tooltip"));
|
|
16
|
+
var _Zoom = _interopRequireDefault(require("../Zoom"));
|
|
17
|
+
var _Type = _interopRequireDefault(require("../Type"));
|
|
18
|
+
var _utils2 = require("../utils");
|
|
19
|
+
const _excluded = ["tonal", "color", "size", "value", "valueDefault", "onChange", "orientation", "marks", "precision", "min", "max", "tooltip", "labels", "onlyMarks", "labelTooltipResolve", "iconButtonPositionResolve", "noTrack", "noButtons", "square", "inverted", "readOnly", "disabled", "icon", "onMouseDown", "onTouchStart", "IconButtonProps", "LabelProps", "TooltipProps", "Component", "style", "className", "children"];
|
|
20
|
+
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; }
|
|
21
|
+
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; }
|
|
22
|
+
const useStyle = (0, _styleReact.style)(theme => {
|
|
23
|
+
const rail = {
|
|
24
|
+
position: 'absolute',
|
|
25
|
+
display: 'inline-flex',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
justifyContent: 'center',
|
|
28
|
+
borderRadius: 'inherit'
|
|
29
|
+
};
|
|
30
|
+
const horizontal = {
|
|
31
|
+
top: '50%',
|
|
32
|
+
transform: 'translateY(-50%)'
|
|
33
|
+
};
|
|
34
|
+
const vertical = {
|
|
35
|
+
left: '50%',
|
|
36
|
+
transform: 'translateX(-50%)'
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
root: {
|
|
40
|
+
position: 'relative',
|
|
41
|
+
display: 'inline-flex',
|
|
42
|
+
borderRadius: `${theme.shape.radius.unit * 0.75}px`,
|
|
43
|
+
cursor: 'pointer',
|
|
44
|
+
touchAction: 'none'
|
|
45
|
+
},
|
|
46
|
+
root_orientation_horizontal: {
|
|
47
|
+
width: '100vw',
|
|
48
|
+
maxWidth: 'clamp(100px, 400px, 100%)',
|
|
49
|
+
height: 4,
|
|
50
|
+
margin: '16px 0 28px'
|
|
51
|
+
},
|
|
52
|
+
root_orientation_vertical: {
|
|
53
|
+
height: '100vh',
|
|
54
|
+
maxHeight: 240,
|
|
55
|
+
width: 4,
|
|
56
|
+
margin: '0 16px 0 28px'
|
|
57
|
+
},
|
|
58
|
+
rail: _objectSpread({}, rail),
|
|
59
|
+
rail_orientation_horizontal: {
|
|
60
|
+
insetInline: '0'
|
|
61
|
+
},
|
|
62
|
+
rail_orientation_vertical: {
|
|
63
|
+
insetBlock: '0'
|
|
64
|
+
},
|
|
65
|
+
rail_orientation_horizontal_size_small: {
|
|
66
|
+
height: '3px'
|
|
67
|
+
},
|
|
68
|
+
rail_orientation_horizontal_size_regular: {
|
|
69
|
+
height: '4px'
|
|
70
|
+
},
|
|
71
|
+
rail_orientation_horizontal_size_large: {
|
|
72
|
+
height: '5px'
|
|
73
|
+
},
|
|
74
|
+
rail_orientation_vertical_size_small: {
|
|
75
|
+
width: '3px'
|
|
76
|
+
},
|
|
77
|
+
rail_orientation_vertical_size_regular: {
|
|
78
|
+
width: '4px'
|
|
79
|
+
},
|
|
80
|
+
rail_orientation_vertical_size_large: {
|
|
81
|
+
width: '5px'
|
|
82
|
+
},
|
|
83
|
+
track: _objectSpread({}, rail),
|
|
84
|
+
track_orientation_horizontal: {
|
|
85
|
+
insetInlineStart: '0'
|
|
86
|
+
},
|
|
87
|
+
track_orientation_vertical: {
|
|
88
|
+
insetBlockEnd: '0'
|
|
89
|
+
},
|
|
90
|
+
track_orientation_horizontal_size_small: {
|
|
91
|
+
height: '5px'
|
|
92
|
+
},
|
|
93
|
+
track_orientation_horizontal_size_regular: {
|
|
94
|
+
height: '6px'
|
|
95
|
+
},
|
|
96
|
+
track_orientation_horizontal_size_large: {
|
|
97
|
+
height: '7px'
|
|
98
|
+
},
|
|
99
|
+
track_orientation_vertical_size_small: {
|
|
100
|
+
width: '5px'
|
|
101
|
+
},
|
|
102
|
+
track_orientation_vertical_size_regular: {
|
|
103
|
+
width: '6px'
|
|
104
|
+
},
|
|
105
|
+
track_orientation_vertical_size_large: {
|
|
106
|
+
width: '7px'
|
|
107
|
+
},
|
|
108
|
+
// Color
|
|
109
|
+
// rail
|
|
110
|
+
rail_color_default: {
|
|
111
|
+
background: theme.methods.palette.color.value('default', 40, true)
|
|
112
|
+
},
|
|
113
|
+
rail_color_neutral: {
|
|
114
|
+
background: theme.methods.palette.color.value('neutral', 40, true)
|
|
115
|
+
},
|
|
116
|
+
rail_color_primary: {
|
|
117
|
+
background: theme.methods.palette.color.value('primary', 40, true)
|
|
118
|
+
},
|
|
119
|
+
rail_color_secondary: {
|
|
120
|
+
background: theme.methods.palette.color.value('secondary', 40, true)
|
|
121
|
+
},
|
|
122
|
+
rail_color_tertiary: {
|
|
123
|
+
background: theme.methods.palette.color.value('tertiary', 40, true)
|
|
124
|
+
},
|
|
125
|
+
rail_color_quaternary: {
|
|
126
|
+
background: theme.methods.palette.color.value('quaternary', 40, true)
|
|
127
|
+
},
|
|
128
|
+
rail_color_info: {
|
|
129
|
+
background: theme.methods.palette.color.value('info', 40, true)
|
|
130
|
+
},
|
|
131
|
+
rail_color_success: {
|
|
132
|
+
background: theme.methods.palette.color.value('success', 40, true)
|
|
133
|
+
},
|
|
134
|
+
rail_color_warning: {
|
|
135
|
+
background: theme.methods.palette.color.value('warning', 40, true)
|
|
136
|
+
},
|
|
137
|
+
rail_color_error: {
|
|
138
|
+
background: theme.methods.palette.color.value('info', 40, true)
|
|
139
|
+
},
|
|
140
|
+
// track
|
|
141
|
+
track_color_default: {
|
|
142
|
+
background: theme.methods.palette.color.value('default', 30, true)
|
|
143
|
+
},
|
|
144
|
+
track_color_neutral: {
|
|
145
|
+
background: theme.methods.palette.color.value('neutral', 30, true)
|
|
146
|
+
},
|
|
147
|
+
track_color_primary: {
|
|
148
|
+
background: theme.methods.palette.color.value('primary', 30, true)
|
|
149
|
+
},
|
|
150
|
+
track_color_secondary: {
|
|
151
|
+
background: theme.methods.palette.color.value('secondary', 30, true)
|
|
152
|
+
},
|
|
153
|
+
track_color_tertiary: {
|
|
154
|
+
background: theme.methods.palette.color.value('tertiary', 30, true)
|
|
155
|
+
},
|
|
156
|
+
track_color_quaternary: {
|
|
157
|
+
background: theme.methods.palette.color.value('quaternary', 30, true)
|
|
158
|
+
},
|
|
159
|
+
track_color_info: {
|
|
160
|
+
background: theme.methods.palette.color.value('info', 30, true)
|
|
161
|
+
},
|
|
162
|
+
track_color_success: {
|
|
163
|
+
background: theme.methods.palette.color.value('success', 30, true)
|
|
164
|
+
},
|
|
165
|
+
track_color_warning: {
|
|
166
|
+
background: theme.methods.palette.color.value('warning', 30, true)
|
|
167
|
+
},
|
|
168
|
+
track_color_error: {
|
|
169
|
+
background: theme.methods.palette.color.value('error', 30, true)
|
|
170
|
+
},
|
|
171
|
+
// Tonal
|
|
172
|
+
track_tonal_color_neutral: {
|
|
173
|
+
background: theme.methods.palette.color.value('neutral', 20, true)
|
|
174
|
+
},
|
|
175
|
+
track_tonal_color_primary: {
|
|
176
|
+
background: theme.methods.palette.color.value('primary', 20, true)
|
|
177
|
+
},
|
|
178
|
+
track_tonal_color_secondary: {
|
|
179
|
+
background: theme.methods.palette.color.value('secondary', 20, true)
|
|
180
|
+
},
|
|
181
|
+
track_tonal_color_tertiary: {
|
|
182
|
+
background: theme.methods.palette.color.value('tertiary', 20, true)
|
|
183
|
+
},
|
|
184
|
+
track_tonal_color_quaternary: {
|
|
185
|
+
background: theme.methods.palette.color.value('quaternary', 20, true)
|
|
186
|
+
},
|
|
187
|
+
track_tonal_color_info: {
|
|
188
|
+
background: theme.methods.palette.color.value('info', 20, true)
|
|
189
|
+
},
|
|
190
|
+
track_tonal_color_success: {
|
|
191
|
+
background: theme.methods.palette.color.value('success', 20, true)
|
|
192
|
+
},
|
|
193
|
+
track_tonal_color_warning: {
|
|
194
|
+
background: theme.methods.palette.color.value('warning', 20, true)
|
|
195
|
+
},
|
|
196
|
+
track_tonal_color_error: {
|
|
197
|
+
background: theme.methods.palette.color.value('info', 20, true)
|
|
198
|
+
},
|
|
199
|
+
// iconButton
|
|
200
|
+
iconButton_color_default: {
|
|
201
|
+
'&.onesy-IconButton-root': {
|
|
202
|
+
color: theme.palette.text.default.primary
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
iconButton_color_neutral: {
|
|
206
|
+
'&.onesy-IconButton-root': {
|
|
207
|
+
color: theme.palette.color.neutral.main
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
iconButton_color_primary: {
|
|
211
|
+
'&.onesy-IconButton-root': {
|
|
212
|
+
color: theme.palette.color.primary.main
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
iconButton_color_secondary: {
|
|
216
|
+
'&.onesy-IconButton-root': {
|
|
217
|
+
color: theme.palette.color.secondary.main
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
iconButton_color_tertiary: {
|
|
221
|
+
'&.onesy-IconButton-root': {
|
|
222
|
+
color: theme.palette.color.tertiary.main
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
iconButton_color_quaternary: {
|
|
226
|
+
'&.onesy-IconButton-root': {
|
|
227
|
+
color: theme.palette.color.quaternary.main
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
iconButton_color_info: {
|
|
231
|
+
'&.onesy-IconButton-root': {
|
|
232
|
+
color: theme.palette.color.info.main
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
iconButton_color_success: {
|
|
236
|
+
'&.onesy-IconButton-root': {
|
|
237
|
+
color: theme.palette.color.success.main
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
iconButton_color_warning: {
|
|
241
|
+
'&.onesy-IconButton-root': {
|
|
242
|
+
color: theme.palette.color.warning.main
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
iconButton_color_error: {
|
|
246
|
+
'&.onesy-IconButton-root': {
|
|
247
|
+
color: theme.palette.color.error.main
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
// Tonal
|
|
251
|
+
iconButton_tonal_color_neutral: {
|
|
252
|
+
'&.onesy-IconButton-root': {
|
|
253
|
+
color: theme.methods.palette.color.value('default', 70)
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
iconButton_tonal_color_primary: {
|
|
257
|
+
'&.onesy-IconButton-root': {
|
|
258
|
+
color: theme.methods.palette.color.value('primary', 70)
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
iconButton_tonal_color_secondary: {
|
|
262
|
+
'&.onesy-IconButton-root': {
|
|
263
|
+
color: theme.methods.palette.color.value('secondary', 70)
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
iconButton_tonal_color_tertiary: {
|
|
267
|
+
'&.onesy-IconButton-root': {
|
|
268
|
+
color: theme.methods.palette.color.value('tertiary', 70)
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
iconButton_tonal_color_quaternary: {
|
|
272
|
+
'&.onesy-IconButton-root': {
|
|
273
|
+
color: theme.methods.palette.color.value('quaternary', 70)
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
iconButton_tonal_color_info: {
|
|
277
|
+
'&.onesy-IconButton-root': {
|
|
278
|
+
color: theme.methods.palette.color.value('info', 70)
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
iconButton_tonal_color_success: {
|
|
282
|
+
'&.onesy-IconButton-root': {
|
|
283
|
+
color: theme.methods.palette.color.value('success', 70)
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
iconButton_tonal_color_warning: {
|
|
287
|
+
'&.onesy-IconButton-root': {
|
|
288
|
+
color: theme.methods.palette.color.value('warning', 70)
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
iconButton_tonal_color_error: {
|
|
292
|
+
'&.onesy-IconButton-root': {
|
|
293
|
+
color: theme.methods.palette.color.value('error', 70)
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
square: {
|
|
297
|
+
borderRadius: '0px'
|
|
298
|
+
},
|
|
299
|
+
iconButton: {
|
|
300
|
+
position: 'absolute'
|
|
301
|
+
},
|
|
302
|
+
icon: {
|
|
303
|
+
display: 'inline-flex',
|
|
304
|
+
alignItems: 'center',
|
|
305
|
+
justifyContent: 'center',
|
|
306
|
+
borderRadius: `calc(${theme.shape.radius.unit / 8} * 0.5em)`,
|
|
307
|
+
transform: 'scale(0.7)',
|
|
308
|
+
transition: theme.methods.transitions.make('transform', {
|
|
309
|
+
duration: 'xs'
|
|
310
|
+
})
|
|
311
|
+
},
|
|
312
|
+
iconActive: {
|
|
313
|
+
transform: 'scale(1)'
|
|
314
|
+
},
|
|
315
|
+
icon_size_small: {
|
|
316
|
+
width: '16px',
|
|
317
|
+
height: '16px'
|
|
318
|
+
},
|
|
319
|
+
icon_size_regular: {
|
|
320
|
+
width: '20px',
|
|
321
|
+
height: '20px'
|
|
322
|
+
},
|
|
323
|
+
icon_size_large: {
|
|
324
|
+
width: '24px',
|
|
325
|
+
height: '24px'
|
|
326
|
+
},
|
|
327
|
+
marks: _objectSpread({
|
|
328
|
+
inset: '0'
|
|
329
|
+
}, rail),
|
|
330
|
+
mark: {
|
|
331
|
+
position: 'absolute',
|
|
332
|
+
width: '2px',
|
|
333
|
+
height: '2px',
|
|
334
|
+
borderRadius: theme.methods.shape.radius.value(40, 'px')
|
|
335
|
+
},
|
|
336
|
+
orientation_horizontal: _objectSpread({}, horizontal),
|
|
337
|
+
orientation_vertical: _objectSpread({}, vertical),
|
|
338
|
+
labels: {
|
|
339
|
+
position: 'absolute',
|
|
340
|
+
whiteSpace: 'nowrap',
|
|
341
|
+
userSelect: 'none'
|
|
342
|
+
},
|
|
343
|
+
labels_orientation_horizontal: {
|
|
344
|
+
width: '100%',
|
|
345
|
+
left: '0',
|
|
346
|
+
top: '15px'
|
|
347
|
+
},
|
|
348
|
+
labels_orientation_vertical: {
|
|
349
|
+
height: '100%',
|
|
350
|
+
top: '0',
|
|
351
|
+
insetInlineStart: '21px'
|
|
352
|
+
},
|
|
353
|
+
label: {
|
|
354
|
+
position: 'absolute',
|
|
355
|
+
transition: theme.methods.transitions.make('color', {
|
|
356
|
+
duration: 'xs'
|
|
357
|
+
}),
|
|
358
|
+
color: theme.palette.text.default.secondary
|
|
359
|
+
},
|
|
360
|
+
label_orientation_horizontal: {
|
|
361
|
+
transform: 'translateX(-50%)'
|
|
362
|
+
},
|
|
363
|
+
label_orientation_horizontal_rtl: {
|
|
364
|
+
transform: 'translateX(50%)'
|
|
365
|
+
},
|
|
366
|
+
label_orientation_vertical: {
|
|
367
|
+
transform: 'translateY(50%)'
|
|
368
|
+
},
|
|
369
|
+
label_active: {
|
|
370
|
+
color: theme.palette.text.default.primary
|
|
371
|
+
},
|
|
372
|
+
focus_outline: {
|
|
373
|
+
outline: `1px solid ${theme.palette.text.default.secondary}`,
|
|
374
|
+
outlineOffset: '8px'
|
|
375
|
+
},
|
|
376
|
+
readOnly: {
|
|
377
|
+
cursor: 'default'
|
|
378
|
+
},
|
|
379
|
+
tooltip: {
|
|
380
|
+
'& .onesy-Tooltip-name': {
|
|
381
|
+
padding: '0',
|
|
382
|
+
lineHeight: '0',
|
|
383
|
+
minWidth: '30px',
|
|
384
|
+
paddingTop: '100%',
|
|
385
|
+
overflow: 'hidden',
|
|
386
|
+
borderRadius: `${theme.methods.shape.radius.value(40, 'px')} ${theme.methods.shape.radius.value(40, 'px')} ${theme.methods.shape.radius.value(40, 'px')} 0px`,
|
|
387
|
+
transform: 'rotate(-45deg)',
|
|
388
|
+
'& .onesy-Tooltip-name-text': {
|
|
389
|
+
position: 'absolute',
|
|
390
|
+
top: '50%',
|
|
391
|
+
left: '50%',
|
|
392
|
+
transform: 'translate(-50%, -50%) rotate(45deg)'
|
|
513
393
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
let index = refs.focusButton.current || 0;
|
|
519
|
-
let value__ = (0, utils_1.is)('array', valueNew) ? valueNew[index] : valueNew;
|
|
520
|
-
// previous value
|
|
521
|
-
let previous = (0, utils_1.clamp)(+(value__ - precision).toFixed(valueDecimals), refs.min.current, refs.max.current);
|
|
522
|
-
if (onlyMarks && (0, utils_1.is)('array', marks)) {
|
|
523
|
-
const previousMark = marks.map(item => item.value).sort((a, b) => b - a).find(item => item < value__);
|
|
524
|
-
previous = previousMark !== undefined ? previousMark : refs.min.current;
|
|
394
|
+
},
|
|
395
|
+
'&.onesy-Tooltip-position-left': {
|
|
396
|
+
'& .onesy-Tooltip-name': {
|
|
397
|
+
borderRadius: `${theme.methods.shape.radius.value(40, 'px')} ${theme.methods.shape.radius.value(40, 'px')} 0px ${theme.methods.shape.radius.value(40, 'px')}`
|
|
525
398
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
next = nextMark !== undefined ? nextMark : refs.max.current;
|
|
399
|
+
},
|
|
400
|
+
'&.onesy-Tooltip-position-right': {
|
|
401
|
+
'& .onesy-Tooltip-name': {
|
|
402
|
+
borderRadius: `0px ${theme.methods.shape.radius.value(40, 'px')} ${theme.methods.shape.radius.value(40, 'px')} ${theme.methods.shape.radius.value(40, 'px')}`
|
|
531
403
|
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
}
|
|
540
|
-
if (index < refs.value.current.length - 1 && value__ > refs.value.current[index + 1]) {
|
|
541
|
-
index += 1;
|
|
542
|
-
refs.focusButton.current = index;
|
|
543
|
-
setFocusButton(index);
|
|
544
|
-
refs.iconButtons.current[index].focus();
|
|
545
|
-
}
|
|
546
|
-
valueNew[index] = value__;
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
tooltip_switch_orientation_horizontal_ltr: {
|
|
407
|
+
'& .onesy-Tooltip-name': {
|
|
408
|
+
transform: 'rotate(135deg)',
|
|
409
|
+
'& .onesy-Tooltip-name-text': {
|
|
410
|
+
transform: 'translate(-50%, -50%) rotate(-135deg)'
|
|
547
411
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
tooltip_switch_orientation_horizontal_rtl: {
|
|
415
|
+
'& .onesy-Tooltip-name': {
|
|
416
|
+
transform: 'rotate(135deg)',
|
|
417
|
+
'& .onesy-Tooltip-name-text': {
|
|
418
|
+
transform: 'translate(-50%, -50%) rotate(-135deg)'
|
|
555
419
|
}
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
tooltipLabelText: {
|
|
423
|
+
minWidth: '40px',
|
|
424
|
+
textAlign: 'center'
|
|
425
|
+
},
|
|
426
|
+
disabled: {
|
|
427
|
+
cursor: 'default',
|
|
428
|
+
pointerEvents: 'none',
|
|
429
|
+
opacity: theme.palette.visual_contrast.default.opacity.disabled
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
}, {
|
|
433
|
+
name: 'onesy-Slider'
|
|
434
|
+
});
|
|
435
|
+
const Slider = /*#__PURE__*/_react.default.forwardRef((props_, ref) => {
|
|
436
|
+
var _String$split$;
|
|
437
|
+
const theme = (0, _styleReact.useOnesyTheme)();
|
|
438
|
+
const props = _react.default.useMemo(() => {
|
|
439
|
+
var _theme$ui, _theme$ui2;
|
|
440
|
+
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.onesySlider) === null || _theme$ui2 === void 0 || (_theme$ui2 = _theme$ui2.props) === null || _theme$ui2 === void 0 ? void 0 : _theme$ui2.default), props_);
|
|
441
|
+
}, [props_]);
|
|
442
|
+
const IconButton = _react.default.useMemo(() => {
|
|
443
|
+
var _theme$elements;
|
|
444
|
+
return (theme === null || theme === void 0 || (_theme$elements = theme.elements) === null || _theme$elements === void 0 ? void 0 : _theme$elements.IconButton) || _IconButton.default;
|
|
445
|
+
}, [theme]);
|
|
446
|
+
const Tooltip = _react.default.useMemo(() => {
|
|
447
|
+
var _theme$elements2;
|
|
448
|
+
return (theme === null || theme === void 0 || (_theme$elements2 = theme.elements) === null || _theme$elements2 === void 0 ? void 0 : _theme$elements2.Tooltip) || _Tooltip.default;
|
|
449
|
+
}, [theme]);
|
|
450
|
+
const Zoom = _react.default.useMemo(() => {
|
|
451
|
+
var _theme$elements3;
|
|
452
|
+
return (theme === null || theme === void 0 || (_theme$elements3 = theme.elements) === null || _theme$elements3 === void 0 ? void 0 : _theme$elements3.Zoom) || _Zoom.default;
|
|
453
|
+
}, [theme]);
|
|
454
|
+
const Type = _react.default.useMemo(() => {
|
|
455
|
+
var _theme$elements4;
|
|
456
|
+
return (theme === null || theme === void 0 || (_theme$elements4 = theme.elements) === null || _theme$elements4 === void 0 ? void 0 : _theme$elements4.Type) || _Type.default;
|
|
457
|
+
}, [theme]);
|
|
458
|
+
const {
|
|
459
|
+
tonal = true,
|
|
460
|
+
color: color_ = 'primary',
|
|
461
|
+
size = 'regular',
|
|
462
|
+
value: value_,
|
|
463
|
+
valueDefault,
|
|
464
|
+
onChange,
|
|
465
|
+
orientation = 'horizontal',
|
|
466
|
+
marks,
|
|
467
|
+
precision = 0.001,
|
|
468
|
+
min = 0,
|
|
469
|
+
max = 100,
|
|
470
|
+
tooltip,
|
|
471
|
+
labels,
|
|
472
|
+
onlyMarks,
|
|
473
|
+
labelTooltipResolve,
|
|
474
|
+
iconButtonPositionResolve,
|
|
475
|
+
noTrack,
|
|
476
|
+
noButtons,
|
|
477
|
+
square,
|
|
478
|
+
inverted,
|
|
479
|
+
readOnly,
|
|
480
|
+
disabled,
|
|
481
|
+
icon,
|
|
482
|
+
onMouseDown: onMouseDown_,
|
|
483
|
+
onTouchStart: onTouchStart_,
|
|
484
|
+
IconButtonProps,
|
|
485
|
+
LabelProps,
|
|
486
|
+
TooltipProps,
|
|
487
|
+
Component = 'span',
|
|
488
|
+
style,
|
|
489
|
+
className,
|
|
490
|
+
children
|
|
491
|
+
} = props,
|
|
492
|
+
other = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
493
|
+
const {
|
|
494
|
+
classes
|
|
495
|
+
} = useStyle();
|
|
496
|
+
const [init, setInit] = _react.default.useState(false);
|
|
497
|
+
const [value, setValue] = _react.default.useState(() => {
|
|
498
|
+
const valueNew = (valueDefault !== undefined ? valueDefault : value_) || ((0, _utils.is)('number', min) ? min : 0);
|
|
499
|
+
return (0, _utils.is)('array', valueNew) ? valueNew.sort((a, b) => a - b).map(item => (0, _utils.clamp)(item, min, max)) : (0, _utils.clamp)(valueNew, min, max);
|
|
500
|
+
});
|
|
501
|
+
const [mouseDown, setMouseDown] = _react.default.useState(false);
|
|
502
|
+
const [mouseDownButton, setMouseDownButton] = _react.default.useState(false);
|
|
503
|
+
const [focus, setFocus] = _react.default.useState(false);
|
|
504
|
+
const [focusButton, setFocusButton] = _react.default.useState(false);
|
|
505
|
+
const refs = {
|
|
506
|
+
root: _react.default.useRef(undefined),
|
|
507
|
+
value: _react.default.useRef(undefined),
|
|
508
|
+
props: _react.default.useRef(undefined),
|
|
509
|
+
mouseDown: _react.default.useRef(undefined),
|
|
510
|
+
mouseDownButton: _react.default.useRef(undefined),
|
|
511
|
+
focusButton: _react.default.useRef(undefined),
|
|
512
|
+
direction: _react.default.useRef(undefined),
|
|
513
|
+
iconButtons: _react.default.useRef([]),
|
|
514
|
+
min: _react.default.useRef(min),
|
|
515
|
+
max: _react.default.useRef(max)
|
|
516
|
+
};
|
|
517
|
+
refs.value.current = value;
|
|
518
|
+
refs.props.current = props;
|
|
519
|
+
refs.mouseDown.current = mouseDown;
|
|
520
|
+
refs.mouseDownButton.current = mouseDownButton;
|
|
521
|
+
refs.focusButton.current = focusButton;
|
|
522
|
+
refs.direction.current = theme.direction;
|
|
523
|
+
refs.min.current = min;
|
|
524
|
+
refs.max.current = max;
|
|
525
|
+
let color = color_;
|
|
526
|
+
if (disabled) color = 'default';
|
|
527
|
+
const valueDecimals = (String(precision).includes('e-') ? +String(precision).split('e-')[1] : (_String$split$ = String(precision).split('.')[1]) === null || _String$split$ === void 0 ? void 0 : _String$split$.length) || 0;
|
|
528
|
+
const valuePrecision = (valueMouse, mouseDownButtonUpdate = false) => {
|
|
529
|
+
let value__ = (0, _utils.valueFromPercentageWithinRange)(valueMouse * 100, refs.min.current, refs.max.current);
|
|
530
|
+
if (refs.direction.current === 'rtl' && orientation === 'horizontal') value__ = refs.max.current + refs.min.current - value__;
|
|
531
|
+
if (value__ <= refs.min.current) return refs.min.current;
|
|
532
|
+
if (value__ >= refs.max.current) return refs.max.current;
|
|
533
|
+
|
|
534
|
+
// previous value
|
|
535
|
+
let previous = (0, _utils.clamp)(+(value__ - value__ % precision).toFixed(valueDecimals), refs.min.current, refs.max.current);
|
|
536
|
+
if (value__ < 0) previous -= precision;
|
|
537
|
+
if (onlyMarks && (0, _utils.is)('array', marks)) {
|
|
538
|
+
const previousMark = marks.map(item => item.value).sort((a, b) => b - a).find(item => item <= value__);
|
|
539
|
+
previous = previousMark !== undefined ? previousMark : refs.min.current;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// next value
|
|
543
|
+
let next = (0, _utils.clamp)(+(previous + precision).toFixed(valueDecimals), refs.min.current, refs.max.current);
|
|
544
|
+
if (onlyMarks && (0, _utils.is)('array', marks)) {
|
|
545
|
+
const nextMark = marks.map(item => item.value).sort((a, b) => a - b).find(item => item >= value__);
|
|
546
|
+
next = nextMark !== undefined ? nextMark : refs.max.current;
|
|
547
|
+
}
|
|
548
|
+
const valueNew = value__ < previous + (next - previous) / 2 ? previous : next;
|
|
549
|
+
if (mouseDownButtonUpdate && (0, _utils.is)('array', refs.value.current)) {
|
|
550
|
+
const items = refs.value.current.map(item => Math.abs(valueNew - item));
|
|
551
|
+
const minItem = Math.min(...items);
|
|
552
|
+
const index = items.findIndex(item => item === minItem);
|
|
553
|
+
setMouseDownButton(index);
|
|
554
|
+
refs.mouseDownButton.current = index;
|
|
555
|
+
}
|
|
556
|
+
return valueNew;
|
|
557
|
+
};
|
|
558
|
+
_react.default.useEffect(() => {
|
|
559
|
+
var _refs$root$current;
|
|
560
|
+
const onMouseUp = () => {
|
|
561
|
+
if (!disabled && !readOnly) {
|
|
562
|
+
setMouseDown(false);
|
|
563
|
+
setMouseDownButton(false);
|
|
564
|
+
}
|
|
556
565
|
};
|
|
557
|
-
const
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
valueNew[0] = refs.min.current;
|
|
568
|
-
}
|
|
569
|
-
else
|
|
570
|
-
valueNew = refs.min.current;
|
|
571
|
-
if (!props.hasOwnProperty('value'))
|
|
572
|
-
setValue(valueNew);
|
|
573
|
-
if ((0, utils_1.is)('function', onChange))
|
|
574
|
-
return onChange(valueNew);
|
|
575
|
-
return;
|
|
576
|
-
case 'Home':
|
|
577
|
-
if ((0, utils_1.is)('array', refs.value.current)) {
|
|
578
|
-
valueNew = [...refs.value.current];
|
|
579
|
-
valueNew[valueNew.length - 1] = refs.max.current;
|
|
580
|
-
}
|
|
581
|
-
else
|
|
582
|
-
valueNew = refs.max.current;
|
|
583
|
-
if (!props.hasOwnProperty('value'))
|
|
584
|
-
setValue(valueNew);
|
|
585
|
-
if ((0, utils_1.is)('function', onChange))
|
|
586
|
-
return onChange(valueNew);
|
|
587
|
-
return;
|
|
588
|
-
case 'ArrowUp':
|
|
589
|
-
case 'ArrowRight':
|
|
590
|
-
return moveItem();
|
|
591
|
-
case 'ArrowDown':
|
|
592
|
-
case 'ArrowLeft':
|
|
593
|
-
return moveItem(false);
|
|
594
|
-
default:
|
|
595
|
-
break;
|
|
596
|
-
}
|
|
597
|
-
}
|
|
566
|
+
const onMouseMove = event => {
|
|
567
|
+
if (!refs.props.current.disabled && !refs.props.current.readOnly && refs.mouseDown.current) {
|
|
568
|
+
let x;
|
|
569
|
+
let y;
|
|
570
|
+
if (event.clientX !== undefined) {
|
|
571
|
+
x = event.clientX;
|
|
572
|
+
y = event.clientY;
|
|
573
|
+
} else {
|
|
574
|
+
x = event.touches[0].clientX;
|
|
575
|
+
y = event.touches[0].clientY;
|
|
598
576
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
const onMouseDownButton = react_1.default.useCallback((event, index) => {
|
|
613
|
-
if (!disabled && !readOnly)
|
|
577
|
+
const rect = refs.root.current.getBoundingClientRect();
|
|
578
|
+
const {
|
|
579
|
+
width,
|
|
580
|
+
height
|
|
581
|
+
} = rect;
|
|
582
|
+
|
|
583
|
+
// Value to the precision point value
|
|
584
|
+
const value__ = valuePrecision(orientation === 'horizontal' ? (x - rect.x) / width : 1 - (y - rect.y) / height);
|
|
585
|
+
const valueNew = (0, _utils.is)('array', refs.value.current) ? [...refs.value.current] : value__;
|
|
586
|
+
if ((0, _utils.is)('array', refs.value.current)) {
|
|
587
|
+
let index = (0, _utils.is)('number', refs.mouseDownButton.current) ? refs.mouseDownButton.current : 0;
|
|
588
|
+
if (index > 0 && value__ < refs.value.current[index - 1]) {
|
|
589
|
+
index -= 1;
|
|
614
590
|
setMouseDownButton(index);
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
const y = event.clientY ? event.clientY : (_d = (_c = event.touches) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.clientY;
|
|
622
|
-
move(x, y);
|
|
591
|
+
}
|
|
592
|
+
if (index < refs.value.current.length - 1 && value__ > refs.value.current[index + 1]) {
|
|
593
|
+
index += 1;
|
|
594
|
+
setMouseDownButton(index);
|
|
595
|
+
}
|
|
596
|
+
valueNew[index] = value__;
|
|
623
597
|
}
|
|
624
|
-
if ((0,
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
var _a, _b, _c, _d;
|
|
629
|
-
if (!disabled && !readOnly) {
|
|
630
|
-
setMouseDown(true);
|
|
631
|
-
const x = event.clientX ? event.clientX : (_b = (_a = event.touches) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.clientX;
|
|
632
|
-
const y = event.clientY ? event.clientY : (_d = (_c = event.touches) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.clientY;
|
|
633
|
-
move(x, y);
|
|
598
|
+
if (!(0, _utils.equalDeep)(valueNew, refs.value.current)) {
|
|
599
|
+
// Inner controlled value
|
|
600
|
+
if (!props.hasOwnProperty('value')) setValue(valueNew);
|
|
601
|
+
if ((0, _utils.is)('function', onChange)) onChange(valueNew);
|
|
634
602
|
}
|
|
635
|
-
|
|
636
|
-
onMouseDown_(event);
|
|
637
|
-
}, [disabled, readOnly, onTouchStart_]);
|
|
638
|
-
const styles = {
|
|
639
|
-
root: {},
|
|
640
|
-
icon: {},
|
|
641
|
-
iconButton: {},
|
|
642
|
-
rail: {},
|
|
643
|
-
track: {},
|
|
644
|
-
markRail: {},
|
|
645
|
-
markTrack: {},
|
|
646
|
-
label: {},
|
|
647
|
-
};
|
|
648
|
-
const palette = !theme.palette.color[color] && theme.methods.color(color);
|
|
649
|
-
if (!theme.palette.color[color] && color !== 'default') {
|
|
650
|
-
styles.markRail.background = styles.rail.background = theme.methods.palette.color.value(undefined, theme.palette.light ? 40 : 90, true, palette);
|
|
651
|
-
styles.label.background = styles.markTrack.background = styles.icon.background = styles.track.background = styles.iconButton.color = !tonal ? palette.main : theme.methods.palette.color.value(undefined, 40, true, palette);
|
|
652
|
-
styles.label.color = theme.methods.palette.color.text(styles.label.background, true, 'light');
|
|
653
|
-
}
|
|
654
|
-
styles.label.background = !tonal ? ((palette === null || palette === void 0 ? void 0 : palette[40]) || (color === 'default' ? theme.palette.text.default.primary : theme.palette.color[color].main)) : theme.methods.palette.color.value(color, 40, true, palette);
|
|
655
|
-
styles.label.color = theme.methods.palette.color.text(styles.label.background, true, 'light');
|
|
656
|
-
const values = ((0, utils_1.is)('array', value) ? value : [value]);
|
|
657
|
-
const valueValue = (value__ = values[0]) => {
|
|
658
|
-
let valueNew = value__;
|
|
659
|
-
if (value__ === refs.min.current)
|
|
660
|
-
valueNew = 0;
|
|
661
|
-
else if (value__ === refs.max.current)
|
|
662
|
-
valueNew = 100;
|
|
663
|
-
else
|
|
664
|
-
valueNew = (0, utils_1.percentageFromValueWithinRange)(value__, refs.min.current, refs.max.current);
|
|
665
|
-
return (0, utils_1.clamp)(valueNew, 0, 100);
|
|
666
|
-
};
|
|
667
|
-
const valueMark = (value__) => {
|
|
668
|
-
if (value__ === refs.min.current)
|
|
669
|
-
return 0;
|
|
670
|
-
if (value__ === refs.max.current)
|
|
671
|
-
return `calc(100% - 2px)`;
|
|
672
|
-
return `calc(${valueValue(value__)}% - 1px)`;
|
|
603
|
+
}
|
|
673
604
|
};
|
|
674
|
-
const
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
}
|
|
690
|
-
return style_;
|
|
605
|
+
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;
|
|
606
|
+
rootDocument.addEventListener('mouseup', onMouseUp);
|
|
607
|
+
rootDocument.addEventListener('mousemove', onMouseMove);
|
|
608
|
+
rootDocument.addEventListener('touchend', onMouseUp, {
|
|
609
|
+
passive: true
|
|
610
|
+
});
|
|
611
|
+
rootDocument.addEventListener('touchmove', onMouseMove, {
|
|
612
|
+
passive: true
|
|
613
|
+
});
|
|
614
|
+
setInit(true);
|
|
615
|
+
return () => {
|
|
616
|
+
rootDocument.removeEventListener('mouseup', onMouseUp);
|
|
617
|
+
rootDocument.removeEventListener('touchend', onMouseUp);
|
|
618
|
+
rootDocument.removeEventListener('mousemove', onMouseMove);
|
|
619
|
+
rootDocument.removeEventListener('touchmove', onMouseMove);
|
|
691
620
|
};
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
621
|
+
}, []);
|
|
622
|
+
_react.default.useEffect(() => {
|
|
623
|
+
if (init && value_ !== value) setValue(value_);
|
|
624
|
+
}, [value_]);
|
|
625
|
+
const move = _react.default.useCallback((x, y) => {
|
|
626
|
+
if (!disabled && !readOnly) {
|
|
627
|
+
const rect = refs.root.current.getBoundingClientRect();
|
|
628
|
+
const {
|
|
629
|
+
width,
|
|
630
|
+
height
|
|
631
|
+
} = rect;
|
|
632
|
+
|
|
633
|
+
// Value to the precision point value
|
|
634
|
+
const value__ = valuePrecision(orientation === 'horizontal' ? (x - rect.x) / width : 1 - (y - rect.y) / height, true);
|
|
635
|
+
const valueNew = (0, _utils.is)('array', refs.value.current) ? [...refs.value.current] : value__;
|
|
636
|
+
if ((0, _utils.is)('array', refs.value.current)) {
|
|
637
|
+
let index = (0, _utils.is)('number', refs.mouseDownButton.current) ? refs.mouseDownButton.current : 0;
|
|
638
|
+
if (index > 0 && value__ <= refs.value.current[index - 1]) {
|
|
639
|
+
index -= 1;
|
|
640
|
+
setMouseDownButton(index);
|
|
701
641
|
}
|
|
702
|
-
if (
|
|
703
|
-
|
|
704
|
-
|
|
642
|
+
if (index < refs.value.current.length - 1 && value__ >= refs.value.current[index + 1]) {
|
|
643
|
+
index += 1;
|
|
644
|
+
setMouseDownButton(index);
|
|
705
645
|
}
|
|
646
|
+
valueNew[index] = value__;
|
|
647
|
+
}
|
|
648
|
+
if (!(0, _utils.equalDeep)(valueNew, refs.value.current)) {
|
|
649
|
+
// Inner controlled value
|
|
650
|
+
if (!props.hasOwnProperty('value')) setValue(valueNew);
|
|
651
|
+
if ((0, _utils.is)('function', onChange)) onChange(valueNew);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}, [disabled, readOnly, onChange, value, mouseDownButton]);
|
|
655
|
+
const moveItem = (forward_ = true) => {
|
|
656
|
+
const forward = orientation === 'vertical' || theme.direction === 'ltr' && orientation === 'horizontal' ? forward_ : !forward_;
|
|
657
|
+
let valueNew = (0, _utils.is)('array', refs.value.current) ? [...refs.value.current] : refs.value.current;
|
|
658
|
+
let index = refs.focusButton.current || 0;
|
|
659
|
+
let value__ = (0, _utils.is)('array', valueNew) ? valueNew[index] : valueNew;
|
|
660
|
+
|
|
661
|
+
// previous value
|
|
662
|
+
let previous = (0, _utils.clamp)(+(value__ - precision).toFixed(valueDecimals), refs.min.current, refs.max.current);
|
|
663
|
+
if (onlyMarks && (0, _utils.is)('array', marks)) {
|
|
664
|
+
const previousMark = marks.map(item => item.value).sort((a, b) => b - a).find(item => item < value__);
|
|
665
|
+
previous = previousMark !== undefined ? previousMark : refs.min.current;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
// next value
|
|
669
|
+
let next = (0, _utils.clamp)(+(value__ + precision).toFixed(valueDecimals), refs.min.current, refs.max.current);
|
|
670
|
+
if (onlyMarks && (0, _utils.is)('array', marks)) {
|
|
671
|
+
const nextMark = marks.map(item => item.value).sort((a, b) => a - b).find(item => item > value__);
|
|
672
|
+
next = nextMark !== undefined ? nextMark : refs.max.current;
|
|
706
673
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
674
|
+
value__ = forward ? next : previous;
|
|
675
|
+
if ((0, _utils.is)('array', refs.value.current)) {
|
|
676
|
+
if (index > 0 && value__ < refs.value.current[index - 1]) {
|
|
677
|
+
index -= 1;
|
|
678
|
+
refs.focusButton.current = index;
|
|
679
|
+
setFocusButton(index);
|
|
680
|
+
refs.iconButtons.current[index].focus();
|
|
681
|
+
}
|
|
682
|
+
if (index < refs.value.current.length - 1 && value__ > refs.value.current[index + 1]) {
|
|
683
|
+
index += 1;
|
|
684
|
+
refs.focusButton.current = index;
|
|
685
|
+
setFocusButton(index);
|
|
686
|
+
refs.iconButtons.current[index].focus();
|
|
687
|
+
}
|
|
688
|
+
valueNew[index] = value__;
|
|
689
|
+
} else valueNew = value__;
|
|
690
|
+
if (!(0, _utils.equalDeep)(valueNew, refs.value.current)) {
|
|
691
|
+
if (!props.hasOwnProperty('value')) setValue(valueNew);
|
|
692
|
+
if ((0, _utils.is)('function', onChange)) onChange(valueNew);
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
const onKeyDown = _react.default.useCallback(event => {
|
|
696
|
+
if (!disabled && !readOnly) {
|
|
697
|
+
if (['Enter', 'Escape', 'ArrowUp', 'ArrowRight', 'ArrowDown', 'ArrowLeft', 'Home', 'End'].includes(event.key)) {
|
|
698
|
+
// Prevent default
|
|
699
|
+
event.preventDefault();
|
|
700
|
+
let valueNew = refs.value.current;
|
|
701
|
+
switch (event.key) {
|
|
702
|
+
case 'End':
|
|
703
|
+
if ((0, _utils.is)('array', refs.value.current)) {
|
|
704
|
+
valueNew = [...refs.value.current];
|
|
705
|
+
valueNew[0] = refs.min.current;
|
|
706
|
+
} else valueNew = refs.min.current;
|
|
707
|
+
if (!props.hasOwnProperty('value')) setValue(valueNew);
|
|
708
|
+
if ((0, _utils.is)('function', onChange)) return onChange(valueNew);
|
|
709
|
+
return;
|
|
710
|
+
case 'Home':
|
|
711
|
+
if ((0, _utils.is)('array', refs.value.current)) {
|
|
712
|
+
valueNew = [...refs.value.current];
|
|
713
|
+
valueNew[valueNew.length - 1] = refs.max.current;
|
|
714
|
+
} else valueNew = refs.max.current;
|
|
715
|
+
if (!props.hasOwnProperty('value')) setValue(valueNew);
|
|
716
|
+
if ((0, _utils.is)('function', onChange)) return onChange(valueNew);
|
|
717
|
+
return;
|
|
718
|
+
case 'ArrowUp':
|
|
719
|
+
case 'ArrowRight':
|
|
720
|
+
return moveItem();
|
|
721
|
+
case 'ArrowDown':
|
|
722
|
+
case 'ArrowLeft':
|
|
723
|
+
return moveItem(false);
|
|
724
|
+
default:
|
|
725
|
+
break;
|
|
722
726
|
}
|
|
727
|
+
}
|
|
723
728
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
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
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
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
|
-
|
|
729
|
+
}, [disabled, readOnly, value, precision, focusButton]);
|
|
730
|
+
const onFocus = _react.default.useCallback(() => {
|
|
731
|
+
if (!disabled && !readOnly && !mouseDown) setFocus(true);
|
|
732
|
+
}, [disabled, readOnly, mouseDown]);
|
|
733
|
+
const onBlur = _react.default.useCallback(() => {
|
|
734
|
+
if (!disabled && !readOnly) setFocus(false);
|
|
735
|
+
}, [disabled, readOnly]);
|
|
736
|
+
const onFocusButton = _react.default.useCallback(index => {
|
|
737
|
+
if (!disabled && !readOnly) setFocusButton(index);
|
|
738
|
+
}, [disabled, readOnly]);
|
|
739
|
+
const onMouseDownButton = _react.default.useCallback((event, index) => {
|
|
740
|
+
if (!disabled && !readOnly) setMouseDownButton(index);
|
|
741
|
+
}, [disabled, readOnly]);
|
|
742
|
+
const onMouseDown = _react.default.useCallback(event => {
|
|
743
|
+
if (!disabled && !readOnly) {
|
|
744
|
+
var _touches, _touches2;
|
|
745
|
+
setMouseDown(true);
|
|
746
|
+
const x = event.clientX ? event.clientX : (_touches = event.touches) === null || _touches === void 0 || (_touches = _touches[0]) === null || _touches === void 0 ? void 0 : _touches.clientX;
|
|
747
|
+
const y = event.clientY ? event.clientY : (_touches2 = event.touches) === null || _touches2 === void 0 || (_touches2 = _touches2[0]) === null || _touches2 === void 0 ? void 0 : _touches2.clientY;
|
|
748
|
+
move(x, y);
|
|
749
|
+
}
|
|
750
|
+
if ((0, _utils.is)('function', onMouseDown_)) onMouseDown_(event);
|
|
751
|
+
}, [disabled, readOnly, onMouseDown_]);
|
|
752
|
+
const onTouchStart = _react.default.useCallback(event => {
|
|
753
|
+
if (!disabled && !readOnly) {
|
|
754
|
+
var _touches3, _touches4;
|
|
755
|
+
setMouseDown(true);
|
|
756
|
+
const x = event.clientX ? event.clientX : (_touches3 = event.touches) === null || _touches3 === void 0 || (_touches3 = _touches3[0]) === null || _touches3 === void 0 ? void 0 : _touches3.clientX;
|
|
757
|
+
const y = event.clientY ? event.clientY : (_touches4 = event.touches) === null || _touches4 === void 0 || (_touches4 = _touches4[0]) === null || _touches4 === void 0 ? void 0 : _touches4.clientY;
|
|
758
|
+
move(x, y);
|
|
759
|
+
}
|
|
760
|
+
if ((0, _utils.is)('function', onMouseDown_)) onMouseDown_(event);
|
|
761
|
+
}, [disabled, readOnly, onTouchStart_]);
|
|
762
|
+
const styles = {
|
|
763
|
+
root: {},
|
|
764
|
+
icon: {},
|
|
765
|
+
iconButton: {},
|
|
766
|
+
rail: {},
|
|
767
|
+
track: {},
|
|
768
|
+
markRail: {},
|
|
769
|
+
markTrack: {},
|
|
770
|
+
label: {}
|
|
771
|
+
};
|
|
772
|
+
const palette = !theme.palette.color[color] && theme.methods.color(color);
|
|
773
|
+
if (!theme.palette.color[color] && color !== 'default') {
|
|
774
|
+
styles.markRail.background = styles.rail.background = theme.methods.palette.color.value(undefined, theme.palette.light ? 40 : 90, true, palette);
|
|
775
|
+
styles.label.background = styles.markTrack.background = styles.icon.background = styles.track.background = styles.iconButton.color = !tonal ? palette.main : theme.methods.palette.color.value(undefined, 40, true, palette);
|
|
776
|
+
styles.label.color = theme.methods.palette.color.text(styles.label.background, true, 'light');
|
|
777
|
+
}
|
|
778
|
+
styles.label.background = !tonal ? (palette === null || palette === void 0 ? void 0 : palette[40]) || (color === 'default' ? theme.palette.text.default.primary : theme.palette.color[color].main) : theme.methods.palette.color.value(color, 40, true, palette);
|
|
779
|
+
styles.label.color = theme.methods.palette.color.text(styles.label.background, true, 'light');
|
|
780
|
+
const values = (0, _utils.is)('array', value) ? value : [value];
|
|
781
|
+
const valueValue = (value__ = values[0]) => {
|
|
782
|
+
let valueNew = value__;
|
|
783
|
+
if (value__ === refs.min.current) valueNew = 0;else if (value__ === refs.max.current) valueNew = 100;else valueNew = (0, _utils.percentageFromValueWithinRange)(value__, refs.min.current, refs.max.current);
|
|
784
|
+
return (0, _utils.clamp)(valueNew, 0, 100);
|
|
785
|
+
};
|
|
786
|
+
const valueMark = value__ => {
|
|
787
|
+
if (value__ === refs.min.current) return 0;
|
|
788
|
+
if (value__ === refs.max.current) return `calc(100% - 2px)`;
|
|
789
|
+
return `calc(${valueValue(value__)}% - 1px)`;
|
|
790
|
+
};
|
|
791
|
+
const propInset = orientation === 'horizontal' ? 'insetInlineStart' : 'insetBlockEnd';
|
|
792
|
+
const iconButtonStyles = value__ => {
|
|
793
|
+
const style_ = {};
|
|
794
|
+
if ((0, _utils.is)('function', iconButtonPositionResolve)) style_[propInset] = iconButtonPositionResolve(value__, valueValue(value__), size);else {
|
|
795
|
+
if (size === 'small') {
|
|
796
|
+
style_[propInset] = `calc(${valueValue(value__)}% - 15px)`;
|
|
797
|
+
}
|
|
798
|
+
if (size === 'regular') {
|
|
799
|
+
style_[propInset] = `calc(${valueValue(value__)}% - 20px)`;
|
|
800
|
+
}
|
|
801
|
+
if (size === 'large') {
|
|
802
|
+
style_[propInset] = `calc(${valueValue(value__)}% - 25px)`;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
return style_;
|
|
806
|
+
};
|
|
807
|
+
const propTrac = orientation === 'horizontal' ? 'width' : 'height';
|
|
808
|
+
if (values.length === 1) styles.track[propTrac] = `${valueValue()}%`;else {
|
|
809
|
+
const start = Math.min(...values);
|
|
810
|
+
const end = Math.max(...values);
|
|
811
|
+
if (orientation === 'horizontal') {
|
|
812
|
+
styles.track.insetInlineStart = `${valueValue(start)}%`;
|
|
813
|
+
styles.track.insetInlineEnd = `${100 - valueValue(end)}%`;
|
|
814
|
+
}
|
|
815
|
+
if (orientation === 'vertical') {
|
|
816
|
+
styles.track.insetBlockStart = `${100 - valueValue(end)}%`;
|
|
817
|
+
styles.track.insetBlockEnd = `${valueValue(start)}%`;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
const marksValue = Math.ceil((refs.max.current - refs.min.current) / precision);
|
|
821
|
+
let marks_ = [];
|
|
822
|
+
if (marks) {
|
|
823
|
+
if ((0, _utils.is)('array', marks)) marks_ = marks;else if (marksValue <= 1e3) {
|
|
824
|
+
let markSum = refs.min.current;
|
|
825
|
+
let index = 1;
|
|
826
|
+
marks_.push({
|
|
827
|
+
value: refs.min.current,
|
|
828
|
+
label: refs.min.current
|
|
829
|
+
});
|
|
830
|
+
while (markSum <= refs.max.current) {
|
|
831
|
+
markSum = refs.min.current + precision * index++;
|
|
832
|
+
if (markSum < refs.max.current) marks_.push({
|
|
833
|
+
value: markSum,
|
|
834
|
+
label: markSum
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
marks_.push({
|
|
838
|
+
value: refs.max.current,
|
|
839
|
+
label: refs.max.current
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
const markTrack = value__ => {
|
|
844
|
+
if (values.length === 1) return !inverted ? value__ <= values[0] : value__ > values[0];else return !inverted ? value__ >= values[0] && value__ <= values[values.length - 1] : value__ < values[0] || value__ > values[values.length - 1];
|
|
845
|
+
};
|
|
846
|
+
const labelMethod = (0, _utils.is)('function', labelTooltipResolve) ? labelTooltipResolve : value__ => +value__.toFixed();
|
|
847
|
+
return /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({
|
|
848
|
+
ref: item => {
|
|
849
|
+
if (ref) {
|
|
850
|
+
if ((0, _utils.is)('function', ref)) ref(item);else ref.current = item;
|
|
851
|
+
}
|
|
852
|
+
refs.root.current = item;
|
|
853
|
+
},
|
|
854
|
+
tabIndex: noButtons ? 0 : -1,
|
|
855
|
+
onFocus: onFocus,
|
|
856
|
+
onBlur: onBlur,
|
|
857
|
+
onTouchStart: onTouchStart,
|
|
858
|
+
onMouseDown: onMouseDown,
|
|
859
|
+
onKeyDown: onKeyDown,
|
|
860
|
+
role: "slider",
|
|
861
|
+
"aria-orientation": orientation,
|
|
862
|
+
"aria-valuenow": valueValue(),
|
|
863
|
+
"aria-valuetext": `${valueValue()}%`,
|
|
864
|
+
"aria-valuemin": min,
|
|
865
|
+
"aria-valuemax": max,
|
|
866
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Slider', theme) && ['onesy-Slider-root', `onesy-Slider-size-${size}`, mouseDown && `onesy-Slider-mouse-down`, focus && `onesy-Slider-focus`, readOnly && `onesy-Slider-read-only`, disabled && `onesy-Slider-disabled`], className, classes.root, classes[`color_${color}`], tonal && classes[`tonal_color_${color}`], classes[`root_orientation_${orientation}`], noButtons && focus && classes.focus_outline, square && classes.square, readOnly && classes.readOnly, disabled && classes.disabled]),
|
|
867
|
+
style: _objectSpread(_objectSpread({}, styles.root), style)
|
|
868
|
+
}, other), /*#__PURE__*/_react.default.createElement("span", {
|
|
869
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Slider', theme) && ['onesy-Slider-rail'], classes.rail, classes[`orientation_${orientation}`], classes[`rail_orientation_${orientation}`], classes[`rail_orientation_${orientation}_size_${size}`], !inverted ? [classes[`rail_color_${color}`]] : [classes[`track_color_${color}`], tonal && classes[`track_tonal_color_${color}`]]]),
|
|
870
|
+
style: styles.rail
|
|
871
|
+
}), !noTrack && /*#__PURE__*/_react.default.createElement("span", {
|
|
872
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Slider', theme) && ['onesy-Slider-track'], classes.track, classes[`orientation_${orientation}`], classes[`track_orientation_${orientation}`], classes[`track_orientation_${orientation}_size_${size}`], !inverted ? [classes[`track_color_${color}`], tonal && classes[`track_tonal_color_${color}`]] : [classes[`rail_color_${color}`]]]),
|
|
873
|
+
style: styles.track
|
|
874
|
+
}), !!marks_.length && /*#__PURE__*/_react.default.createElement("span", {
|
|
875
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Slider', theme) && ['onesy-Slider-marks'], classes.marks, classes[`orientation_${orientation}`], classes[`track_size_${size}`]])
|
|
876
|
+
}, marks_.map((item, index) => /*#__PURE__*/_react.default.createElement("span", {
|
|
877
|
+
key: index,
|
|
878
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Slider', theme) && ['onesy-Slider-mark'], classes.mark, markTrack(item.value) ? classes[`rail_color_${color}`] : [classes[`track_color_${color}`], tonal && classes[`track_tonal_color_${color}`]]]),
|
|
879
|
+
style: _objectSpread(_objectSpread({}, markTrack(item.value) ? styles.markRail : styles.markTrack), {}, {
|
|
880
|
+
[propInset]: valueMark(item.value)
|
|
881
|
+
})
|
|
882
|
+
}))), labels && !!marks_.length && /*#__PURE__*/_react.default.createElement("span", {
|
|
883
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Slider', theme) && ['onesy-Slider-labels'], classes.labels, classes[`labels_orientation_${orientation}`]])
|
|
884
|
+
}, marks_.map((item, index) => /*#__PURE__*/_react.default.createElement(Type, (0, _extends2.default)({
|
|
885
|
+
key: index,
|
|
886
|
+
version: size === 'large' ? 'b1' : size === 'regular' ? 'b2' : 'b3'
|
|
887
|
+
}, LabelProps, {
|
|
888
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Slider', theme) && ['onesy-Slider-label'], LabelProps === null || LabelProps === void 0 ? void 0 : LabelProps.className, classes.label, classes[`label_orientation_${orientation}`], theme.direction === 'rtl' && classes[`label_orientation_${orientation}_rtl`], item.value <= value && classes.label_active]),
|
|
889
|
+
style: _objectSpread({
|
|
890
|
+
[propInset]: valueMark(item.value)
|
|
891
|
+
}, LabelProps === null || LabelProps === void 0 ? void 0 : LabelProps.style)
|
|
892
|
+
}), item.label))), !noButtons && values.map((value__, index) => {
|
|
893
|
+
var _icon$props, _icon$props2;
|
|
894
|
+
const classNameIcon = (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Slider', theme) && ['onesy-Slider-icon'], classes.icon, classes[`track_color_${color}`], tonal && classes[`track_tonal_color_${color}`], classes[`icon_size_${size}`], mouseDownButton === index && classes.iconActive]);
|
|
895
|
+
return /*#__PURE__*/_react.default.createElement(Tooltip, (0, _extends2.default)({
|
|
896
|
+
key: index,
|
|
897
|
+
className: (0, _styleReact.classNames)([classes.tooltip, classes[`tooltip_orientation_${orientation}`]]),
|
|
898
|
+
classNameSwitch: classes[`tooltip_switch_orientation_${orientation}_${theme.direction}`]
|
|
899
|
+
}, tooltip === 'always' || tooltip !== undefined && mouseDownButton === index ? {
|
|
900
|
+
open: true
|
|
901
|
+
} : tooltip === undefined ? {
|
|
902
|
+
open: false
|
|
903
|
+
} : {}, {
|
|
904
|
+
label: labelMethod(value__),
|
|
905
|
+
position: orientation === 'horizontal' ? 'top' : theme.direction === 'ltr' ? 'left' : 'right',
|
|
906
|
+
alignment: "center",
|
|
907
|
+
TransitionComponent: Zoom,
|
|
908
|
+
transformOrigin: orientation === 'horizontal' ? 'center bottom' : 'center right',
|
|
909
|
+
transformOriginSwitch: orientation === 'horizontal' ? 'center top' : 'center left',
|
|
910
|
+
transformOriginRtl: orientation === 'horizontal' ? 'center bottom' : 'center left',
|
|
911
|
+
transformOriginRtlSwitch: orientation === 'horizontal' ? 'center top' : 'center right',
|
|
912
|
+
noMargin: true,
|
|
913
|
+
LabelProps: {
|
|
914
|
+
style: styles.label
|
|
915
|
+
},
|
|
916
|
+
LabelTextProps: {
|
|
917
|
+
className: classes.tooltipLabelText
|
|
918
|
+
}
|
|
919
|
+
}, TooltipProps), /*#__PURE__*/_react.default.createElement(IconButton, (0, _extends2.default)({
|
|
920
|
+
ref: item => refs.iconButtons.current.push(item),
|
|
921
|
+
size: size,
|
|
922
|
+
tonal: tonal,
|
|
923
|
+
color: color,
|
|
924
|
+
onBlur: onBlur,
|
|
925
|
+
onFocus: () => {
|
|
926
|
+
onFocus();
|
|
927
|
+
onFocusButton(index);
|
|
928
|
+
},
|
|
929
|
+
onMouseDown: event => onMouseDownButton(event, index),
|
|
930
|
+
"aria-valuenow": valueValue(value__),
|
|
931
|
+
"aria-valuetext": `${valueValue(value__)}%`,
|
|
932
|
+
"aria-valuemin": min,
|
|
933
|
+
"aria-valuemax": max
|
|
934
|
+
}, IconButtonProps, {
|
|
935
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('Slider', theme) && ['onesy-Slider-icon-button'], IconButtonProps === null || IconButtonProps === void 0 ? void 0 : IconButtonProps.className, classes.iconButton, classes[`orientation_${orientation}`], !tonal && classes[`iconButton_color_${color}`], tonal && classes[`iconButton_tonal_color_${color}`]]),
|
|
936
|
+
style: _objectSpread(_objectSpread({}, iconButtonStyles(value__)), IconButtonProps === null || IconButtonProps === void 0 ? void 0 : IconButtonProps.style)
|
|
937
|
+
}), icon ? /*#__PURE__*/_react.default.cloneElement(icon, {
|
|
938
|
+
className: (0, _styleReact.classNames)([icon === null || icon === void 0 || (_icon$props = icon.props) === null || _icon$props === void 0 ? void 0 : _icon$props.className, classNameIcon]),
|
|
939
|
+
style: _objectSpread(_objectSpread({}, styles.icon), icon === null || icon === void 0 || (_icon$props2 = icon.props) === null || _icon$props2 === void 0 ? void 0 : _icon$props2.style)
|
|
940
|
+
}) : /*#__PURE__*/_react.default.createElement("span", {
|
|
941
|
+
className: classNameIcon,
|
|
942
|
+
style: styles.icon
|
|
943
|
+
})));
|
|
944
|
+
}));
|
|
855
945
|
});
|
|
856
946
|
Slider.displayName = 'onesy-Slider';
|
|
857
|
-
exports.default = Slider;
|
|
947
|
+
var _default = exports.default = Slider;
|