@hero-design/rn 8.82.2-alpha.2 → 8.83.0-test.0
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/.turbo/turbo-build$colon$types.log +0 -0
- package/.turbo/turbo-build.log +8 -0
- package/.turbo/turbo-lint.log +183 -0
- package/.turbo/turbo-publish:npm.log +9 -0
- package/.turbo/turbo-test.log +4726 -0
- package/.turbo/turbo-type-check.log +0 -0
- package/CHANGELOG.md +6 -0
- package/es/index.js +120 -43
- package/eslint.config.js +4 -2
- package/lib/index.js +121 -43
- package/package.json +5 -3
- package/rollup.config.mjs +1 -0
- package/src/components/Slider/Range.tsx +177 -0
- package/src/components/Slider/Single.tsx +89 -0
- package/src/components/Slider/__tests__/Range.spec.tsx +105 -0
- package/src/components/Slider/__tests__/{index.spec.tsx → Single.spec.tsx} +1 -1
- package/src/components/Slider/__tests__/__snapshots__/Range.spec.tsx.snap +168 -0
- package/src/components/Slider/index.tsx +8 -83
- package/src/theme/components/slider.ts +12 -1
- package/src/types.ts +2 -0
- package/testUtils/setup.tsx +17 -0
- package/types/components/Accordion/AccordionItem.d.ts +1 -1
- package/types/components/Accordion/StyledAccordion.d.ts +11 -11
- package/types/components/Accordion/index.d.ts +1 -1
- package/types/components/Alert/StyledAlert.d.ts +16 -16
- package/types/components/Alert/index.d.ts +1 -1
- package/types/components/Attachment/StyledAttachment.d.ts +8 -8
- package/types/components/Attachment/index.d.ts +0 -0
- package/types/components/Avatar/Avatar.d.ts +0 -0
- package/types/components/Avatar/AvatarStack/StyledAvatarStack.d.ts +9 -9
- package/types/components/Avatar/AvatarStack/index.d.ts +0 -0
- package/types/components/Avatar/AvatarStack/utils.d.ts +0 -0
- package/types/components/Avatar/StyledAvatar.d.ts +10 -10
- package/types/components/Avatar/index.d.ts +0 -0
- package/types/components/Badge/Status.d.ts +0 -0
- package/types/components/Badge/StyledBadge.d.ts +12 -12
- package/types/components/Badge/index.d.ts +1 -1
- package/types/components/BottomNavigation/StyledBottomNavigation.d.ts +15 -15
- package/types/components/BottomNavigation/index.d.ts +1 -1
- package/types/components/BottomSheet/BottomSheetContext.d.ts +1 -1
- package/types/components/BottomSheet/Footer.d.ts +0 -0
- package/types/components/BottomSheet/Header.d.ts +2 -2
- package/types/components/BottomSheet/ScrollView.d.ts +0 -0
- package/types/components/BottomSheet/StyledBottomSheet.d.ts +22 -22
- package/types/components/BottomSheet/index.d.ts +0 -0
- package/types/components/Box/StyledBox.d.ts +2 -2
- package/types/components/Box/config.d.ts +2 -2
- package/types/components/Box/index.d.ts +0 -0
- package/types/components/Box/types.d.ts +3 -3
- package/types/components/Button/Button.d.ts +1 -1
- package/types/components/Button/IconButton.d.ts +0 -0
- package/types/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +6 -6
- package/types/components/Button/LoadingIndicator/index.d.ts +1 -1
- package/types/components/Button/StyledButton.d.ts +22 -22
- package/types/components/Button/UtilityButton/StyledUtilityButton.d.ts +6 -6
- package/types/components/Button/UtilityButton/index.d.ts +0 -0
- package/types/components/Button/index.d.ts +0 -0
- package/types/components/Calendar/CalendarRowItem.d.ts +0 -0
- package/types/components/Calendar/StyledCalendar.d.ts +22 -22
- package/types/components/Calendar/helpers.d.ts +0 -0
- package/types/components/Calendar/index.d.ts +0 -0
- package/types/components/Card/DataCard/StyledDataCard.d.ts +5 -5
- package/types/components/Card/DataCard/index.d.ts +0 -0
- package/types/components/Card/StyledCard.d.ts +4 -4
- package/types/components/Card/index.d.ts +0 -0
- package/types/components/Carousel/CardCarousel.d.ts +1 -1
- package/types/components/Carousel/CarouselItem.d.ts +0 -0
- package/types/components/Carousel/StyledCardCarousel.d.ts +8 -8
- package/types/components/Carousel/StyledCarousel.d.ts +21 -21
- package/types/components/Carousel/contants.d.ts +0 -0
- package/types/components/Carousel/index.d.ts +0 -0
- package/types/components/Carousel/types.d.ts +2 -2
- package/types/components/Checkbox/StyledCheckbox.d.ts +11 -11
- package/types/components/Checkbox/index.d.ts +1 -1
- package/types/components/Chip/StyledChip.d.ts +5 -5
- package/types/components/Collapse/StyledCollapse.d.ts +6 -6
- package/types/components/Collapse/index.d.ts +0 -0
- package/types/components/CompoundSearch/CompoundSearchHandler.d.ts +31 -0
- package/types/components/CompoundSearch/CompoundSearchTextInput.d.ts +60 -0
- package/types/components/CompoundSearch/StyledCompoundSearch.d.ts +40 -0
- package/types/components/CompoundSearch/index.d.ts +8 -0
- package/types/components/CompoundSearch/utils.d.ts +8 -0
- package/types/components/ContentNavigator/StyledContentNavigator.d.ts +2 -2
- package/types/components/ContentNavigator/index.d.ts +0 -0
- package/types/components/DatePicker/DatePickerAndroid.d.ts +1 -1
- package/types/components/DatePicker/DatePickerCalendar.d.ts +1 -1
- package/types/components/DatePicker/DatePickerIOS.d.ts +1 -1
- package/types/components/DatePicker/StyledDatePicker.d.ts +2 -2
- package/types/components/DatePicker/index.d.ts +0 -0
- package/types/components/DatePicker/types.d.ts +0 -0
- package/types/components/DatePicker/useCalculateDate.d.ts +1 -1
- package/types/components/Divider/StyledDivider.d.ts +5 -5
- package/types/components/Divider/index.d.ts +0 -0
- package/types/components/Drawer/DragableDrawer/helpers.d.ts +1 -1
- package/types/components/Drawer/DragableDrawer/index.d.ts +0 -0
- package/types/components/Drawer/StyledDrawer.d.ts +15 -15
- package/types/components/Drawer/index.d.ts +0 -0
- package/types/components/Empty/StyledEmpty.d.ts +7 -7
- package/types/components/Empty/index.d.ts +0 -0
- package/types/components/Error/StyledError.d.ts +21 -21
- package/types/components/Error/index.d.ts +0 -0
- package/types/components/FAB/ActionGroup/ActionItem.d.ts +0 -0
- package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +10 -10
- package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +6 -6
- package/types/components/FAB/ActionGroup/index.d.ts +1 -1
- package/types/components/FAB/AnimatedFABIcon.d.ts +1 -1
- package/types/components/FAB/FAB.d.ts +1 -1
- package/types/components/FAB/Pair/StyledFAB.d.ts +6 -6
- package/types/components/FAB/Pair/index.d.ts +1 -1
- package/types/components/FAB/StyledFAB.d.ts +9 -9
- package/types/components/FAB/index.d.ts +0 -0
- package/types/components/FloatingIsland/StyledFloatingIsland.d.ts +10 -10
- package/types/components/HeroDesignProvider/HeroDesignContext.d.ts +5 -0
- package/types/components/Icon/AnimatedIcon.d.ts +1 -1
- package/types/components/Icon/HeroIcon/index.d.ts +4 -4
- package/types/components/Icon/IconList.d.ts +0 -0
- package/types/components/Icon/index.d.ts +1 -1
- package/types/components/Icon/utils.d.ts +1 -2
- package/types/components/Image/index.d.ts +0 -0
- package/types/components/List/BasicListItem.d.ts +0 -0
- package/types/components/List/ListItem.d.ts +0 -0
- package/types/components/List/StyledBasicListItem.d.ts +10 -10
- package/types/components/List/StyledListItem.d.ts +18 -18
- package/types/components/List/index.d.ts +0 -0
- package/types/components/MapPin/StyledMapPin.d.ts +11 -11
- package/types/components/MapPin/types.d.ts +1 -1
- package/types/components/PageControl/StyledPageControl.d.ts +4 -4
- package/types/components/PageControl/index.d.ts +0 -0
- package/types/components/PinInput/PinCell.d.ts +0 -0
- package/types/components/PinInput/StyledPinInput.d.ts +21 -21
- package/types/components/PinInput/index.d.ts +0 -0
- package/types/components/Portal/reducer.d.ts +1 -1
- package/types/components/Portal/types.d.ts +1 -1
- package/types/components/Progress/ProgressBar.d.ts +0 -0
- package/types/components/Progress/ProgressCircle.d.ts +0 -0
- package/types/components/Progress/ProgressStep.d.ts +1 -1
- package/types/components/Progress/StyledProgressBar.d.ts +4 -4
- package/types/components/Progress/StyledProgressCircle.d.ts +12 -12
- package/types/components/Progress/StyledStep.d.ts +10 -10
- package/types/components/Progress/__tests__/index.spec.d.ts +0 -0
- package/types/components/Progress/constants.d.ts +0 -0
- package/types/components/Progress/index.d.ts +0 -0
- package/types/components/Progress/types.d.ts +1 -1
- package/types/components/Radio/Radio.d.ts +0 -0
- package/types/components/Radio/RadioGroup.d.ts +0 -0
- package/types/components/Radio/StyledRadio.d.ts +9 -9
- package/types/components/Radio/index.d.ts +1 -1
- package/types/components/Radio/types.d.ts +1 -1
- package/types/components/Rate/StyledRate.d.ts +4 -4
- package/types/components/RefreshControl/index.d.ts +1 -1
- package/types/components/RichTextEditor/EditorEvent.d.ts +1 -0
- package/types/components/RichTextEditor/EditorToolbar.d.ts +0 -0
- package/types/components/RichTextEditor/MentionList.d.ts +0 -0
- package/types/components/RichTextEditor/RichTextEditor.d.ts +1 -1
- package/types/components/RichTextEditor/StyledRichTextEditor.d.ts +4 -4
- package/types/components/RichTextEditor/StyledToolbar.d.ts +6 -6
- package/types/components/RichTextEditor/__mocks__/heroEditorApp.d.ts +0 -0
- package/types/components/RichTextEditor/constants.d.ts +0 -0
- package/types/components/RichTextEditor/heroEditorApp.d.ts +0 -0
- package/types/components/RichTextEditor/index.d.ts +0 -0
- package/types/components/RichTextEditor/types.d.ts +1 -1
- package/types/components/RichTextEditor/utils/events.d.ts +0 -0
- package/types/components/RichTextEditor/utils/rnWebView.d.ts +0 -0
- package/types/components/Search/SearchBasic.d.ts +31 -0
- package/types/components/Search/SearchCompound.d.ts +60 -0
- package/types/components/Search/SearchOneLine.d.ts +5 -5
- package/types/components/Search/StyledSearch.d.ts +18 -18
- package/types/components/Search/index.d.ts +1 -1
- package/types/components/Search/utils.d.ts +2 -2
- package/types/components/SectionHeading/StyledHeading.d.ts +7 -7
- package/types/components/SectionHeading/index.d.ts +0 -0
- package/types/components/Select/BaseOptionList.d.ts +1 -1
- package/types/components/Select/Footer.d.ts +0 -0
- package/types/components/Select/MultiSelect/Option.d.ts +2 -2
- package/types/components/Select/MultiSelect/OptionList.d.ts +1 -1
- package/types/components/Select/MultiSelect/index.d.ts +0 -0
- package/types/components/Select/SingleSelect/Option.d.ts +2 -2
- package/types/components/Select/SingleSelect/OptionList.d.ts +1 -1
- package/types/components/Select/SingleSelect/StyledSingleSelect.d.ts +1 -2
- package/types/components/Select/SingleSelect/index.d.ts +0 -0
- package/types/components/Select/StyledSelect.d.ts +6 -6
- package/types/components/Select/helpers.d.ts +2 -2
- package/types/components/Select/index.d.ts +0 -0
- package/types/components/Select/types.d.ts +6 -6
- package/types/components/Skeleton/StyledSkeleton.d.ts +6 -6
- package/types/components/Skeleton/index.d.ts +0 -0
- package/types/components/Slider/Range.d.ts +60 -0
- package/types/components/Slider/Single.d.ts +53 -0
- package/types/components/Slider/index.d.ts +6 -51
- package/types/components/Spinner/AnimatedSpinner.d.ts +2 -2
- package/types/components/Spinner/StyledSpinner.d.ts +13 -13
- package/types/components/Spinner/index.d.ts +0 -0
- package/types/components/Success/StyledSuccess.d.ts +19 -19
- package/types/components/Success/index.d.ts +0 -0
- package/types/components/Swipeable/StyledSwipeable.d.ts +3 -3
- package/types/components/Swipeable/SwipeableAction.d.ts +0 -0
- package/types/components/Swipeable/index.d.ts +2 -2
- package/types/components/Switch/SelectorSwitch/Option.d.ts +5 -3
- package/types/components/Switch/SelectorSwitch/StyledSelectorSwitch.d.ts +8 -8
- package/types/components/Switch/SelectorSwitch/index.d.ts +3 -3
- package/types/components/Switch/StyledSwitch.d.ts +5 -5
- package/types/components/Switch/index.d.ts +3 -3
- package/types/components/Tabs/ActiveTabIndicator.d.ts +0 -0
- package/types/components/Tabs/SceneView.d.ts +3 -3
- package/types/components/Tabs/ScrollableTabs.d.ts +0 -0
- package/types/components/Tabs/ScrollableTabsHeader/hooks/useInitHighlightedAnimation.d.ts +2 -2
- package/types/components/Tabs/ScrollableTabsHeader/hooks/useInitUnderlinedAnimation.d.ts +2 -2
- package/types/components/Tabs/ScrollableTabsHeader.d.ts +35 -0
- package/types/components/Tabs/StyledScrollableTabs.d.ts +17 -17
- package/types/components/Tabs/StyledTabs.d.ts +14 -14
- package/types/components/Tabs/TabWithBadge.d.ts +3 -3
- package/types/components/Tabs/index.d.ts +2 -2
- package/types/components/Tabs/useHandlePageScroll.d.ts +1 -1
- package/types/components/Tabs/useIsFocused.d.ts +0 -0
- package/types/components/Tabs/utils.d.ts +0 -0
- package/types/components/Tag/StyledTag.d.ts +5 -5
- package/types/components/Tag/index.d.ts +0 -0
- package/types/components/TextInput/StyledTextInput.d.ts +28 -28
- package/types/components/TextInput/index.d.ts +16 -16
- package/types/components/TimePicker/StyledTimePicker.d.ts +2 -2
- package/types/components/TimePicker/TimePickerAndroid.d.ts +0 -0
- package/types/components/TimePicker/TimePickerIOS.d.ts +0 -0
- package/types/components/TimePicker/index.d.ts +0 -0
- package/types/components/TimePicker/types.d.ts +0 -0
- package/types/components/Toast/StyledToast.d.ts +18 -18
- package/types/components/Toast/Toast.d.ts +0 -0
- package/types/components/Toast/ToastContainer.d.ts +0 -0
- package/types/components/Toast/ToastContext.d.ts +2 -2
- package/types/components/Toast/ToastProvider.d.ts +1 -1
- package/types/components/Toast/index.d.ts +0 -0
- package/types/components/Toast/types.d.ts +2 -2
- package/types/components/Toolbar/StyledToolbar.d.ts +25 -25
- package/types/components/Toolbar/ToolbarGroup.d.ts +0 -0
- package/types/components/Toolbar/ToolbarItem.d.ts +0 -0
- package/types/components/Toolbar/ToolbarMessage.d.ts +4 -4
- package/types/components/Toolbar/index.d.ts +0 -0
- package/types/components/Typography/Body/StyledBody.d.ts +4 -4
- package/types/components/Typography/Caption/StyledCaption.d.ts +3 -3
- package/types/components/Typography/Label/StyledLabel.d.ts +2 -2
- package/types/components/Typography/Text/StyledText.d.ts +6 -6
- package/types/components/Typography/Text/index.d.ts +0 -0
- package/types/components/Typography/Title/StyledTitle.d.ts +4 -4
- package/types/components/Typography/index.d.ts +0 -0
- package/types/components/Typography/types.d.ts +1 -1
- package/types/index.d.ts +0 -0
- package/types/testHelpers/renderWithTheme.d.ts +0 -0
- package/types/testHelpers/utils.d.ts +1 -1
- package/types/theme/ThemeProvider.d.ts +0 -0
- package/types/theme/ThemeSwitcher.d.ts +3 -3
- package/types/theme/components/accordion.d.ts +0 -0
- package/types/theme/components/alert.d.ts +0 -0
- package/types/theme/components/attachment.d.ts +0 -0
- package/types/theme/components/avatar.d.ts +0 -0
- package/types/theme/components/badge.d.ts +1 -1
- package/types/theme/components/bottomNavigation.d.ts +0 -0
- package/types/theme/components/bottomSheet.d.ts +0 -0
- package/types/theme/components/button.d.ts +1 -1
- package/types/theme/components/calendar.d.ts +0 -0
- package/types/theme/components/card.d.ts +0 -0
- package/types/theme/components/cardCarousel.d.ts +0 -0
- package/types/theme/components/carousel.d.ts +1 -1
- package/types/theme/components/checkbox.d.ts +0 -0
- package/types/theme/components/compoundSearch.d.ts +36 -0
- package/types/theme/components/contentNavigator.d.ts +0 -0
- package/types/theme/components/datePicker.d.ts +0 -0
- package/types/theme/components/divider.d.ts +0 -0
- package/types/theme/components/drawer.d.ts +0 -0
- package/types/theme/components/empty.d.ts +1 -1
- package/types/theme/components/error.d.ts +1 -1
- package/types/theme/components/fab.d.ts +1 -1
- package/types/theme/components/icon.d.ts +0 -0
- package/types/theme/components/image.d.ts +0 -0
- package/types/theme/components/list.d.ts +0 -0
- package/types/theme/components/pageControl.d.ts +0 -0
- package/types/theme/components/pinInput.d.ts +1 -1
- package/types/theme/components/progress.d.ts +0 -0
- package/types/theme/components/radio.d.ts +0 -0
- package/types/theme/components/refreshControl.d.ts +0 -0
- package/types/theme/components/richTextEditor.d.ts +0 -0
- package/types/theme/components/sectionHeading.d.ts +0 -0
- package/types/theme/components/select.d.ts +0 -0
- package/types/theme/components/skeleton.d.ts +0 -0
- package/types/theme/components/slider.d.ts +18 -0
- package/types/theme/components/spinner.d.ts +0 -0
- package/types/theme/components/success.d.ts +1 -1
- package/types/theme/components/swipeable.d.ts +0 -0
- package/types/theme/components/switch.d.ts +0 -0
- package/types/theme/components/tabs.d.ts +0 -0
- package/types/theme/components/tag.d.ts +1 -1
- package/types/theme/components/textInput.d.ts +0 -0
- package/types/theme/components/timePicker.d.ts +0 -0
- package/types/theme/components/toast.d.ts +0 -0
- package/types/theme/components/toolbar.d.ts +0 -0
- package/types/theme/components/typography.d.ts +0 -0
- package/types/theme/getTheme.d.ts +1 -1
- package/types/theme/global/borders.d.ts +0 -0
- package/types/theme/global/colors/eBens.d.ts +0 -0
- package/types/theme/global/colors/global.d.ts +0 -0
- package/types/theme/global/colors/globalDark.d.ts +0 -0
- package/types/theme/global/colors/jobs.d.ts +0 -0
- package/types/theme/global/colors/swag.d.ts +0 -0
- package/types/theme/global/colors/swagDark.d.ts +0 -0
- package/types/theme/global/colors/types.d.ts +3 -3
- package/types/theme/global/colors/wallet.d.ts +0 -0
- package/types/theme/global/colors/work.d.ts +0 -0
- package/types/theme/global/index.d.ts +4 -4
- package/types/theme/global/scale.d.ts +1 -1
- package/types/theme/global/shadows.d.ts +1 -1
- package/types/theme/global/sizes.d.ts +0 -0
- package/types/theme/global/space.d.ts +0 -0
- package/types/theme/global/typography.d.ts +1 -1
- package/types/theme/index.d.ts +0 -0
- package/types/types.d.ts +2 -1
- package/types/utils/functions.d.ts +0 -0
- package/types/utils/helpers.d.ts +0 -0
- package/types/utils/hooks.d.ts +0 -0
- package/types/utils/scale.d.ts +0 -0
- /package/src/components/Slider/__tests__/__snapshots__/{index.spec.tsx.snap → Single.spec.tsx.snap} +0 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import MultiSlider from '@ptomasroos/react-native-multi-slider';
|
|
3
|
+
|
|
4
|
+
import { LayoutChangeEvent, StyleProp, View, ViewStyle } from 'react-native';
|
|
5
|
+
import { useTheme } from '../../theme';
|
|
6
|
+
|
|
7
|
+
export type SliderRangeValue = {
|
|
8
|
+
start: number;
|
|
9
|
+
end: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export interface RangeSliderProps {
|
|
13
|
+
/**
|
|
14
|
+
* Minimum value of the slider.
|
|
15
|
+
*/
|
|
16
|
+
minimumValue: number;
|
|
17
|
+
/**
|
|
18
|
+
* Maximum value of the slider.
|
|
19
|
+
*/
|
|
20
|
+
maximumValue: number;
|
|
21
|
+
/**
|
|
22
|
+
* Step value of the slider.
|
|
23
|
+
* The value should be between 1 and (maximumValue - minimumValue).
|
|
24
|
+
* Defaults to 1.
|
|
25
|
+
*/
|
|
26
|
+
step?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Range value of the slider.
|
|
29
|
+
* Defaults to minimumValue.
|
|
30
|
+
*/
|
|
31
|
+
value?: SliderRangeValue;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the two markers should be allowed to overlap.
|
|
34
|
+
* Defaults to false.
|
|
35
|
+
*/
|
|
36
|
+
allowOverlap?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Callback continuously called while the user is dragging the slider.
|
|
39
|
+
*/
|
|
40
|
+
onValueChange?: (value: SliderRangeValue) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Callback that is called when the user picks up the slider.
|
|
43
|
+
* The initial value is passed as an argument to the callback handler.
|
|
44
|
+
*/
|
|
45
|
+
onSlidingStart?: () => void;
|
|
46
|
+
/**
|
|
47
|
+
* Callback that is called when the user releases the slider, regardless if the value has changed.
|
|
48
|
+
* The current value is passed as an argument to the callback handler.
|
|
49
|
+
*/
|
|
50
|
+
onSlidingComplete?: (value: SliderRangeValue) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Whether the slider is disabled.
|
|
53
|
+
*/
|
|
54
|
+
disabled?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Additional style.
|
|
57
|
+
*/
|
|
58
|
+
style?: StyleProp<ViewStyle>;
|
|
59
|
+
/**
|
|
60
|
+
* Testing id of the component.
|
|
61
|
+
*/
|
|
62
|
+
testID?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const Slider = ({
|
|
66
|
+
minimumValue,
|
|
67
|
+
maximumValue,
|
|
68
|
+
step = 1,
|
|
69
|
+
value,
|
|
70
|
+
onValueChange,
|
|
71
|
+
onSlidingStart,
|
|
72
|
+
onSlidingComplete,
|
|
73
|
+
disabled = false,
|
|
74
|
+
style,
|
|
75
|
+
testID,
|
|
76
|
+
allowOverlap = false,
|
|
77
|
+
}: RangeSliderProps) => {
|
|
78
|
+
const theme = useTheme();
|
|
79
|
+
const handleTwoWaySliderChange = React.useCallback(
|
|
80
|
+
(values: number[]) => {
|
|
81
|
+
if (onValueChange) {
|
|
82
|
+
onValueChange({ start: values[0], end: values[1] });
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
[onValueChange]
|
|
86
|
+
);
|
|
87
|
+
const [layoutSize, setLayoutSize] = useState({ width: 0, height: 0 });
|
|
88
|
+
const nativeValue = useMemo(() => {
|
|
89
|
+
return [value?.start ?? minimumValue, value?.end ?? maximumValue];
|
|
90
|
+
}, [value?.start, value?.end, minimumValue, maximumValue]);
|
|
91
|
+
|
|
92
|
+
const {
|
|
93
|
+
trackBackground,
|
|
94
|
+
disabledTrackBackground,
|
|
95
|
+
thumbTint,
|
|
96
|
+
disabledThumbTint,
|
|
97
|
+
} = theme.__hd__.slider.colors;
|
|
98
|
+
|
|
99
|
+
const { trackHeight } = theme.__hd__.slider.sizes;
|
|
100
|
+
|
|
101
|
+
const trackStyle = useMemo(() => {
|
|
102
|
+
return {
|
|
103
|
+
backgroundColor: disabled ? disabledTrackBackground : trackBackground,
|
|
104
|
+
height: trackHeight,
|
|
105
|
+
};
|
|
106
|
+
}, [disabled, disabledTrackBackground, trackBackground, trackHeight]);
|
|
107
|
+
|
|
108
|
+
const { marker: markerShadow } = theme.__hd__.slider.shadows;
|
|
109
|
+
|
|
110
|
+
const makerStyle = useMemo(() => {
|
|
111
|
+
return {
|
|
112
|
+
backgroundColor: disabled ? disabledThumbTint : thumbTint,
|
|
113
|
+
...markerShadow,
|
|
114
|
+
};
|
|
115
|
+
}, [disabled, disabledThumbTint, thumbTint, markerShadow]);
|
|
116
|
+
|
|
117
|
+
const selectedStyle = useMemo(() => {
|
|
118
|
+
return {
|
|
119
|
+
backgroundColor: disabled ? disabledThumbTint : thumbTint,
|
|
120
|
+
};
|
|
121
|
+
}, [disabled, disabledThumbTint, thumbTint, markerShadow]);
|
|
122
|
+
|
|
123
|
+
const handleOnValueChangeStart = useCallback(() => {
|
|
124
|
+
if (onSlidingStart) {
|
|
125
|
+
onSlidingStart();
|
|
126
|
+
}
|
|
127
|
+
}, [onSlidingStart]);
|
|
128
|
+
|
|
129
|
+
const handleOnValueChangeFinish = useCallback(
|
|
130
|
+
(values: number[]) => {
|
|
131
|
+
if (onSlidingComplete) {
|
|
132
|
+
onSlidingComplete({
|
|
133
|
+
start: values[0],
|
|
134
|
+
end: values[1],
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
[onSlidingComplete]
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const onLayoutCallback = useCallback((event: LayoutChangeEvent) => {
|
|
142
|
+
setLayoutSize({
|
|
143
|
+
width: event.nativeEvent.layout.width,
|
|
144
|
+
height: event.nativeEvent.layout.height,
|
|
145
|
+
});
|
|
146
|
+
}, []);
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<View
|
|
150
|
+
onLayout={onLayoutCallback}
|
|
151
|
+
style={style}
|
|
152
|
+
testID={testID}
|
|
153
|
+
accessibilityState={{
|
|
154
|
+
disabled,
|
|
155
|
+
}}
|
|
156
|
+
>
|
|
157
|
+
<MultiSlider
|
|
158
|
+
values={nativeValue}
|
|
159
|
+
onValuesChange={handleTwoWaySliderChange}
|
|
160
|
+
onValuesChangeStart={handleOnValueChangeStart}
|
|
161
|
+
onValuesChangeFinish={handleOnValueChangeFinish}
|
|
162
|
+
sliderLength={layoutSize.width}
|
|
163
|
+
min={minimumValue}
|
|
164
|
+
max={maximumValue}
|
|
165
|
+
step={step}
|
|
166
|
+
enabledOne={!disabled}
|
|
167
|
+
enabledTwo={!disabled}
|
|
168
|
+
allowOverlap={allowOverlap}
|
|
169
|
+
trackStyle={trackStyle}
|
|
170
|
+
markerStyle={makerStyle}
|
|
171
|
+
selectedStyle={selectedStyle}
|
|
172
|
+
/>
|
|
173
|
+
</View>
|
|
174
|
+
);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export default Slider;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import RnSlider from '@react-native-community/slider';
|
|
3
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
4
|
+
import { useTheme } from '../../theme';
|
|
5
|
+
|
|
6
|
+
export interface SingleSliderProps {
|
|
7
|
+
/**
|
|
8
|
+
* Minimum value of the slider.
|
|
9
|
+
* Defaults to 0.
|
|
10
|
+
*/
|
|
11
|
+
minimumValue?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Maximum value of the slider.
|
|
14
|
+
* Defaults to 1.
|
|
15
|
+
*/
|
|
16
|
+
maximumValue?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Step value of the slider.
|
|
19
|
+
* The value should be between 0 and (maximumValue - minimumValue).
|
|
20
|
+
* Defaults to 0.
|
|
21
|
+
*/
|
|
22
|
+
step?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Value of the slider.
|
|
25
|
+
* Defaults to 0.
|
|
26
|
+
*/
|
|
27
|
+
value?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Callback continuously called while the user is dragging the slider.
|
|
30
|
+
*/
|
|
31
|
+
onValueChange?: (value: number) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Callback that is called when the user picks up the slider.
|
|
34
|
+
* The initial value is passed as an argument to the callback handler.
|
|
35
|
+
*/
|
|
36
|
+
onSlidingStart?: (value: number) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Callback that is called when the user releases the slider, regardless if the value has changed.
|
|
39
|
+
* The current value is passed as an argument to the callback handler.
|
|
40
|
+
*/
|
|
41
|
+
onSlidingComplete?: (value: number) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the slider is disabled.
|
|
44
|
+
*/
|
|
45
|
+
disabled?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Additional style.
|
|
48
|
+
*/
|
|
49
|
+
style?: StyleProp<ViewStyle>;
|
|
50
|
+
/**
|
|
51
|
+
* Testing id of the component.
|
|
52
|
+
*/
|
|
53
|
+
testID?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const Slider = ({
|
|
57
|
+
minimumValue = 0,
|
|
58
|
+
maximumValue = 1,
|
|
59
|
+
step = 0,
|
|
60
|
+
value = 0,
|
|
61
|
+
onValueChange,
|
|
62
|
+
onSlidingStart,
|
|
63
|
+
onSlidingComplete,
|
|
64
|
+
disabled = false,
|
|
65
|
+
style,
|
|
66
|
+
testID,
|
|
67
|
+
}: SingleSliderProps) => {
|
|
68
|
+
const theme = useTheme();
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<RnSlider
|
|
72
|
+
minimumValue={minimumValue}
|
|
73
|
+
maximumValue={maximumValue}
|
|
74
|
+
step={step}
|
|
75
|
+
value={value}
|
|
76
|
+
onValueChange={onValueChange}
|
|
77
|
+
onSlidingStart={onSlidingStart}
|
|
78
|
+
onSlidingComplete={onSlidingComplete}
|
|
79
|
+
disabled={disabled}
|
|
80
|
+
minimumTrackTintColor={theme.__hd__.slider.colors.minimumTrackTint}
|
|
81
|
+
thumbTintColor={theme.__hd__.slider.colors.thumbTint}
|
|
82
|
+
maximumTrackTintColor={theme.__hd__.slider.colors.maximumTrackTint}
|
|
83
|
+
style={style}
|
|
84
|
+
testID={testID}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default Slider;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { fireEvent } from '@testing-library/react-native';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
4
|
+
import RangeSlider from '../Range';
|
|
5
|
+
|
|
6
|
+
describe('Slider.Range', () => {
|
|
7
|
+
it('renders correctly by default', async () => {
|
|
8
|
+
const { toJSON, getByTestId } = renderWithTheme(
|
|
9
|
+
<RangeSlider
|
|
10
|
+
maximumValue={20}
|
|
11
|
+
minimumValue={-10}
|
|
12
|
+
value={{
|
|
13
|
+
start: 0,
|
|
14
|
+
end: 10,
|
|
15
|
+
}}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
// Trigger the onLayout event
|
|
19
|
+
const nativeComponent = getByTestId('native-multi-slider');
|
|
20
|
+
fireEvent(nativeComponent, 'layout', {
|
|
21
|
+
nativeEvent: {
|
|
22
|
+
layout: { width: 100, height: 50 },
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
expect(toJSON()).toMatchSnapshot();
|
|
26
|
+
|
|
27
|
+
// verify style
|
|
28
|
+
expect(nativeComponent.props['markerStyle'].backgroundColor).toBe(
|
|
29
|
+
'#401960'
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
expect(nativeComponent.props['selectedStyle'].backgroundColor).toBe(
|
|
33
|
+
'#401960'
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
expect(nativeComponent.props['trackStyle'].backgroundColor).toBe('#ece8ef');
|
|
37
|
+
|
|
38
|
+
// verify prop
|
|
39
|
+
expect(nativeComponent).toHaveProp('sliderLength', 100);
|
|
40
|
+
expect(nativeComponent).toHaveProp('values', [0, 10]);
|
|
41
|
+
expect(nativeComponent).toHaveProp('min', -10);
|
|
42
|
+
expect(nativeComponent).toHaveProp('max', 20);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('when value is undefined, value should be minumum and maximum', () => {
|
|
46
|
+
const { getByTestId } = renderWithTheme(
|
|
47
|
+
<RangeSlider maximumValue={20} minimumValue={-10} />
|
|
48
|
+
);
|
|
49
|
+
const nativeComponent = getByTestId('native-multi-slider');
|
|
50
|
+
expect(nativeComponent.props['values']).toEqual([-10, 20]);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('renders correctly when disabled is $disabled', () => {
|
|
54
|
+
const { getByTestId, toJSON } = renderWithTheme(
|
|
55
|
+
<RangeSlider
|
|
56
|
+
testID="range-slider"
|
|
57
|
+
minimumValue={-10}
|
|
58
|
+
maximumValue={10}
|
|
59
|
+
disabled
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const slider = getByTestId('range-slider');
|
|
64
|
+
expect(slider).toHaveAccessibilityState({ disabled: true });
|
|
65
|
+
|
|
66
|
+
expect(toJSON()).toMatchSnapshot();
|
|
67
|
+
const nativeComponent = getByTestId('native-multi-slider');
|
|
68
|
+
expect(nativeComponent.props['markerStyle'].backgroundColor).toBe(
|
|
69
|
+
'#bfc1c5'
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
expect(nativeComponent.props['selectedStyle'].backgroundColor).toBe(
|
|
73
|
+
'#bfc1c5'
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
expect(nativeComponent.props['trackStyle'].backgroundColor).toBe('#f6f6f7');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('trigger options', () => {
|
|
80
|
+
const onValueChangeSpy = jest.fn();
|
|
81
|
+
const onSlidingStartSpy = jest.fn();
|
|
82
|
+
const onSlidingCompleteSpy = jest.fn();
|
|
83
|
+
const { getByTestId } = renderWithTheme(
|
|
84
|
+
<RangeSlider
|
|
85
|
+
value={{ start: 2, end: 5 }}
|
|
86
|
+
minimumValue={-10}
|
|
87
|
+
maximumValue={10}
|
|
88
|
+
step={0.25}
|
|
89
|
+
onValueChange={onValueChangeSpy}
|
|
90
|
+
onSlidingStart={onSlidingStartSpy}
|
|
91
|
+
onSlidingComplete={onSlidingCompleteSpy}
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const nativeComponent = getByTestId('native-multi-slider');
|
|
96
|
+
fireEvent(nativeComponent, 'valuesChangeStart', [2, 5]);
|
|
97
|
+
expect(onSlidingStartSpy).toHaveBeenCalled();
|
|
98
|
+
|
|
99
|
+
fireEvent(nativeComponent, 'valuesChange', [2, 5]);
|
|
100
|
+
expect(onValueChangeSpy).toHaveBeenCalledWith({ start: 2, end: 5 });
|
|
101
|
+
|
|
102
|
+
fireEvent(nativeComponent, 'valuesChangeFinish', [2, 5]);
|
|
103
|
+
expect(onSlidingCompleteSpy).toHaveBeenCalledWith({ start: 2, end: 5 });
|
|
104
|
+
});
|
|
105
|
+
});
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Slider.Range renders correctly by default 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
style={
|
|
6
|
+
{
|
|
7
|
+
"flex": 1,
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
>
|
|
11
|
+
<View
|
|
12
|
+
accessibilityState={
|
|
13
|
+
{
|
|
14
|
+
"disabled": false,
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
onLayout={[Function]}
|
|
18
|
+
>
|
|
19
|
+
<MultiSlider
|
|
20
|
+
allowOverlap={false}
|
|
21
|
+
enabledOne={true}
|
|
22
|
+
enabledTwo={true}
|
|
23
|
+
markerStyle={
|
|
24
|
+
{
|
|
25
|
+
"backgroundColor": "#401960",
|
|
26
|
+
"elevation": 3,
|
|
27
|
+
"shadowColor": "#001f23",
|
|
28
|
+
"shadowOffset": {
|
|
29
|
+
"height": 2,
|
|
30
|
+
"width": 0,
|
|
31
|
+
},
|
|
32
|
+
"shadowOpacity": 0.12,
|
|
33
|
+
"shadowRadius": 4,
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
max={20}
|
|
37
|
+
min={-10}
|
|
38
|
+
onValuesChange={[Function]}
|
|
39
|
+
onValuesChangeFinish={[Function]}
|
|
40
|
+
onValuesChangeStart={[Function]}
|
|
41
|
+
selectedStyle={
|
|
42
|
+
{
|
|
43
|
+
"backgroundColor": "#401960",
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
sliderLength={100}
|
|
47
|
+
step={1}
|
|
48
|
+
testID="native-multi-slider"
|
|
49
|
+
trackStyle={
|
|
50
|
+
{
|
|
51
|
+
"backgroundColor": "#ece8ef",
|
|
52
|
+
"height": 4,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
values={
|
|
56
|
+
[
|
|
57
|
+
0,
|
|
58
|
+
10,
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
/>
|
|
62
|
+
</View>
|
|
63
|
+
<View
|
|
64
|
+
pointerEvents="box-none"
|
|
65
|
+
position="bottom"
|
|
66
|
+
style={
|
|
67
|
+
[
|
|
68
|
+
{
|
|
69
|
+
"bottom": 0,
|
|
70
|
+
"elevation": 9999,
|
|
71
|
+
"flexDirection": "column-reverse",
|
|
72
|
+
"left": 0,
|
|
73
|
+
"paddingHorizontal": 24,
|
|
74
|
+
"paddingVertical": 16,
|
|
75
|
+
"position": "absolute",
|
|
76
|
+
"right": 0,
|
|
77
|
+
"top": 0,
|
|
78
|
+
},
|
|
79
|
+
undefined,
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
/>
|
|
83
|
+
</View>
|
|
84
|
+
`;
|
|
85
|
+
|
|
86
|
+
exports[`Slider.Range renders correctly when disabled is $disabled 1`] = `
|
|
87
|
+
<View
|
|
88
|
+
style={
|
|
89
|
+
{
|
|
90
|
+
"flex": 1,
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
>
|
|
94
|
+
<View
|
|
95
|
+
accessibilityState={
|
|
96
|
+
{
|
|
97
|
+
"disabled": true,
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
onLayout={[Function]}
|
|
101
|
+
testID="range-slider"
|
|
102
|
+
>
|
|
103
|
+
<MultiSlider
|
|
104
|
+
allowOverlap={false}
|
|
105
|
+
enabledOne={false}
|
|
106
|
+
enabledTwo={false}
|
|
107
|
+
markerStyle={
|
|
108
|
+
{
|
|
109
|
+
"backgroundColor": "#bfc1c5",
|
|
110
|
+
"elevation": 3,
|
|
111
|
+
"shadowColor": "#001f23",
|
|
112
|
+
"shadowOffset": {
|
|
113
|
+
"height": 2,
|
|
114
|
+
"width": 0,
|
|
115
|
+
},
|
|
116
|
+
"shadowOpacity": 0.12,
|
|
117
|
+
"shadowRadius": 4,
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
max={10}
|
|
121
|
+
min={-10}
|
|
122
|
+
onValuesChange={[Function]}
|
|
123
|
+
onValuesChangeFinish={[Function]}
|
|
124
|
+
onValuesChangeStart={[Function]}
|
|
125
|
+
selectedStyle={
|
|
126
|
+
{
|
|
127
|
+
"backgroundColor": "#bfc1c5",
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
sliderLength={0}
|
|
131
|
+
step={1}
|
|
132
|
+
testID="native-multi-slider"
|
|
133
|
+
trackStyle={
|
|
134
|
+
{
|
|
135
|
+
"backgroundColor": "#f6f6f7",
|
|
136
|
+
"height": 4,
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
values={
|
|
140
|
+
[
|
|
141
|
+
-10,
|
|
142
|
+
10,
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
/>
|
|
146
|
+
</View>
|
|
147
|
+
<View
|
|
148
|
+
pointerEvents="box-none"
|
|
149
|
+
position="bottom"
|
|
150
|
+
style={
|
|
151
|
+
[
|
|
152
|
+
{
|
|
153
|
+
"bottom": 0,
|
|
154
|
+
"elevation": 9999,
|
|
155
|
+
"flexDirection": "column-reverse",
|
|
156
|
+
"left": 0,
|
|
157
|
+
"paddingHorizontal": 24,
|
|
158
|
+
"paddingVertical": 16,
|
|
159
|
+
"position": "absolute",
|
|
160
|
+
"right": 0,
|
|
161
|
+
"top": 0,
|
|
162
|
+
},
|
|
163
|
+
undefined,
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
/>
|
|
167
|
+
</View>
|
|
168
|
+
`;
|
|
@@ -1,89 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
import Single from './Single';
|
|
3
|
+
import type { SingleSliderProps } from './Single';
|
|
4
|
+
import Range from './Range';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Minimum value of the slider.
|
|
9
|
-
* Defaults to 0.
|
|
10
|
-
*/
|
|
11
|
-
minimumValue?: number;
|
|
12
|
-
/**
|
|
13
|
-
* Maximum value of the slider.
|
|
14
|
-
* Defaults to 1.
|
|
15
|
-
*/
|
|
16
|
-
maximumValue?: number;
|
|
17
|
-
/**
|
|
18
|
-
* Step value of the slider.
|
|
19
|
-
* The value should be between 0 and (maximumValue - minimumValue).
|
|
20
|
-
* Defaults to 0.
|
|
21
|
-
*/
|
|
22
|
-
step?: number;
|
|
23
|
-
/**
|
|
24
|
-
* Value of the slider.
|
|
25
|
-
* Defaults to 0.
|
|
26
|
-
*/
|
|
27
|
-
value?: number;
|
|
28
|
-
/**
|
|
29
|
-
* Callback continuously called while the user is dragging the slider.
|
|
30
|
-
*/
|
|
31
|
-
onValueChange?: (value: number) => void;
|
|
32
|
-
/**
|
|
33
|
-
* Callback that is called when the user picks up the slider.
|
|
34
|
-
* The initial value is passed as an argument to the callback handler.
|
|
35
|
-
*/
|
|
36
|
-
onSlidingStart?: (value: number) => void;
|
|
37
|
-
/**
|
|
38
|
-
* Callback that is called when the user releases the slider, regardless if the value has changed.
|
|
39
|
-
* The current value is passed as an argument to the callback handler.
|
|
40
|
-
*/
|
|
41
|
-
onSlidingComplete?: (value: number) => void;
|
|
42
|
-
/**
|
|
43
|
-
* Whether the slider is disabled.
|
|
44
|
-
*/
|
|
45
|
-
disabled?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Additional style.
|
|
48
|
-
*/
|
|
49
|
-
style?: StyleProp<ViewStyle>;
|
|
50
|
-
/**
|
|
51
|
-
* Testing id of the component.
|
|
52
|
-
*/
|
|
53
|
-
testID?: string;
|
|
6
|
+
interface SliderProps extends FunctionComponent<SingleSliderProps> {
|
|
7
|
+
Range: typeof Range;
|
|
54
8
|
}
|
|
55
9
|
|
|
56
|
-
const Slider =
|
|
57
|
-
minimumValue = 0,
|
|
58
|
-
maximumValue = 1,
|
|
59
|
-
step = 0,
|
|
60
|
-
value = 0,
|
|
61
|
-
onValueChange,
|
|
62
|
-
onSlidingStart,
|
|
63
|
-
onSlidingComplete,
|
|
64
|
-
disabled = false,
|
|
65
|
-
style,
|
|
66
|
-
testID,
|
|
67
|
-
}: SliderProps) => {
|
|
68
|
-
const theme = useTheme();
|
|
10
|
+
const Slider = Single as SliderProps;
|
|
69
11
|
|
|
70
|
-
|
|
71
|
-
<RnSlider
|
|
72
|
-
minimumValue={minimumValue}
|
|
73
|
-
maximumValue={maximumValue}
|
|
74
|
-
step={step}
|
|
75
|
-
value={value}
|
|
76
|
-
onValueChange={onValueChange}
|
|
77
|
-
onSlidingStart={onSlidingStart}
|
|
78
|
-
onSlidingComplete={onSlidingComplete}
|
|
79
|
-
disabled={disabled}
|
|
80
|
-
minimumTrackTintColor={theme.__hd__.slider.colors.minimumTrackTint}
|
|
81
|
-
thumbTintColor={theme.__hd__.slider.colors.thumbTint}
|
|
82
|
-
maximumTrackTintColor={theme.__hd__.slider.colors.maximumTrackTint}
|
|
83
|
-
style={style}
|
|
84
|
-
testID={testID}
|
|
85
|
-
/>
|
|
86
|
-
);
|
|
87
|
-
};
|
|
12
|
+
Slider.Range = Range;
|
|
88
13
|
|
|
89
14
|
export default Slider;
|
|
@@ -5,9 +5,20 @@ const getSliderTheme = (theme: GlobalTheme) => {
|
|
|
5
5
|
minimumTrackTint: theme.colors.primary,
|
|
6
6
|
thumbTint: theme.colors.primary,
|
|
7
7
|
maximumTrackTint: theme.colors.highlightedSurface,
|
|
8
|
+
trackBackground: theme.colors.highlightedSurface,
|
|
9
|
+
disabledThumbTint: theme.colors.disabledOnDefaultGlobalSurface,
|
|
10
|
+
disabledTrackBackground: theme.colors.neutralGlobalSurface,
|
|
8
11
|
};
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
const shadows = {
|
|
14
|
+
marker: theme.shadows.default,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const sizes = {
|
|
18
|
+
trackHeight: theme.sizes.xsmall,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return { colors, shadows, sizes };
|
|
11
22
|
};
|
|
12
23
|
|
|
13
24
|
export default getSliderTheme;
|
package/src/types.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { TextProps } from './components/Typography/Text';
|
|
|
17
17
|
import { CardCarouselHandles } from './components/Carousel/CardCarousel';
|
|
18
18
|
import { FABHandles } from './components/FAB/FAB';
|
|
19
19
|
import { ActionGroupHandles } from './components/FAB/ActionGroup';
|
|
20
|
+
import type { SliderRangeValue } from './components/Slider/Range';
|
|
20
21
|
|
|
21
22
|
export type {
|
|
22
23
|
BottomNavigationTabType,
|
|
@@ -36,4 +37,5 @@ export type {
|
|
|
36
37
|
CardCarouselHandles,
|
|
37
38
|
FABHandles,
|
|
38
39
|
ActionGroupHandles,
|
|
40
|
+
SliderRangeValue,
|
|
39
41
|
};
|
package/testUtils/setup.tsx
CHANGED
|
@@ -68,6 +68,23 @@ jest.mock('@react-native-community/datetimepicker', () => {
|
|
|
68
68
|
};
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
+
jest.mock('@ptomasroos/react-native-multi-slider', () => {
|
|
72
|
+
const React = jest.requireActual('react');
|
|
73
|
+
|
|
74
|
+
return class Slider extends React.Component {
|
|
75
|
+
render() {
|
|
76
|
+
return React.createElement(
|
|
77
|
+
'MultiSlider',
|
|
78
|
+
{
|
|
79
|
+
...(this.props ?? {}),
|
|
80
|
+
testID: 'native-multi-slider',
|
|
81
|
+
},
|
|
82
|
+
this.props.children
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
|
|
71
88
|
jest.mock('@react-native-community/slider', () => {
|
|
72
89
|
const React = jest.requireActual('react');
|
|
73
90
|
|