react-native-molecules 0.5.0-beta.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/components/Accordion/Accordion.tsx +89 -0
- package/components/Accordion/AccordionItem.tsx +94 -0
- package/components/Accordion/AccordionItemContent.tsx +17 -0
- package/components/Accordion/AccordionItemHeader.tsx +122 -0
- package/components/Accordion/index.tsx +36 -0
- package/components/Accordion/utils.ts +62 -0
- package/components/ActivityIndicator/ActivityIndicator.ios.tsx +1 -0
- package/components/ActivityIndicator/ActivityIndicator.tsx +200 -0
- package/components/ActivityIndicator/AnimatedSpinner.tsx +121 -0
- package/components/ActivityIndicator/index.tsx +17 -0
- package/components/Appbar/AppbarActions.tsx +13 -0
- package/components/Appbar/AppbarBase.tsx +60 -0
- package/components/Appbar/AppbarCenterAligned.tsx +13 -0
- package/components/Appbar/AppbarLarge.tsx +13 -0
- package/components/Appbar/AppbarLeft.tsx +26 -0
- package/components/Appbar/AppbarMedium.tsx +13 -0
- package/components/Appbar/AppbarRight.tsx +40 -0
- package/components/Appbar/AppbarSmall.tsx +13 -0
- package/components/Appbar/AppbarTitle.tsx +49 -0
- package/components/Appbar/index.tsx +46 -0
- package/components/Appbar/types.ts +19 -0
- package/components/Appbar/utils.ts +127 -0
- package/components/Avatar/Avatar.tsx +189 -0
- package/components/Avatar/index.tsx +11 -0
- package/components/Avatar/utils.ts +35 -0
- package/components/Backdrop/Backdrop.tsx +18 -0
- package/components/Backdrop/index.tsx +11 -0
- package/components/Backdrop/types.ts +3 -0
- package/components/Backdrop/utils.ts +21 -0
- package/components/Badge/Badge.tsx +29 -0
- package/components/Badge/index.tsx +11 -0
- package/components/Badge/utils.ts +38 -0
- package/components/Button/Button.tsx +349 -0
- package/components/Button/index.tsx +11 -0
- package/components/Button/types.ts +5 -0
- package/components/Button/utils.ts +416 -0
- package/components/Card/Card.tsx +160 -0
- package/components/Card/CardActions.tsx +18 -0
- package/components/Card/CardContent.tsx +29 -0
- package/components/Card/CardHeader.tsx +31 -0
- package/components/Card/CardHeadline.tsx +15 -0
- package/components/Card/CardMedia.tsx +36 -0
- package/components/Card/CardSubhead.tsx +15 -0
- package/components/Card/CardText.tsx +13 -0
- package/components/Card/CardTypography.tsx +113 -0
- package/components/Card/index.tsx +38 -0
- package/components/Card/types.ts +1 -0
- package/components/Card/utils.ts +23 -0
- package/components/Checkbox/Checkbox.tsx +123 -0
- package/components/Checkbox/CheckboxBase.ios.tsx +86 -0
- package/components/Checkbox/CheckboxBase.tsx +216 -0
- package/components/Checkbox/index.tsx +11 -0
- package/components/Checkbox/types.ts +72 -0
- package/components/Checkbox/utils.ts +210 -0
- package/components/Chip/Chip.tsx +416 -0
- package/components/Chip/index.tsx +51 -0
- package/components/Chip/utils.ts +100 -0
- package/components/DatePickerDocked/DatePickerDocked.tsx +30 -0
- package/components/DatePickerDocked/DatePickerDockedHeader.tsx +129 -0
- package/components/DatePickerDocked/index.tsx +21 -0
- package/components/DatePickerDocked/types.ts +11 -0
- package/components/DatePickerDocked/utils.ts +155 -0
- package/components/DatePickerInline/AutoSizer.tsx +46 -0
- package/components/DatePickerInline/DatePickerContext.tsx +21 -0
- package/components/DatePickerInline/DatePickerInline.tsx +82 -0
- package/components/DatePickerInline/DatePickerInlineBase.tsx +181 -0
- package/components/DatePickerInline/DatePickerInlineHeader.tsx +108 -0
- package/components/DatePickerInline/Day.tsx +88 -0
- package/components/DatePickerInline/DayName.tsx +17 -0
- package/components/DatePickerInline/DayNames.tsx +32 -0
- package/components/DatePickerInline/DayRange.tsx +48 -0
- package/components/DatePickerInline/HeaderItem.tsx +111 -0
- package/components/DatePickerInline/Month.tsx +233 -0
- package/components/DatePickerInline/MonthPicker.tsx +174 -0
- package/components/DatePickerInline/Swiper.native.tsx +172 -0
- package/components/DatePickerInline/Swiper.tsx +172 -0
- package/components/DatePickerInline/SwiperUtils.ts +40 -0
- package/components/DatePickerInline/Week.tsx +67 -0
- package/components/DatePickerInline/YearPicker.tsx +139 -0
- package/components/DatePickerInline/dateUtils.tsx +334 -0
- package/components/DatePickerInline/index.tsx +41 -0
- package/components/DatePickerInline/types.ts +104 -0
- package/components/DatePickerInline/utils.ts +367 -0
- package/components/DatePickerInput/DatePickerInput.tsx +139 -0
- package/components/DatePickerInput/DatePickerInputModal.tsx +48 -0
- package/components/DatePickerInput/DatePickerInputWithoutModal.tsx +77 -0
- package/components/DatePickerInput/DateRangeInput.tsx +88 -0
- package/components/DatePickerInput/index.tsx +14 -0
- package/components/DatePickerInput/inputUtils.ts +138 -0
- package/components/DatePickerInput/types.ts +28 -0
- package/components/DatePickerInput/utils.ts +16 -0
- package/components/DatePickerModal/AnimatedCrossView.tsx +94 -0
- package/components/DatePickerModal/CalendarEdit.tsx +139 -0
- package/components/DatePickerModal/DatePickerModal.tsx +85 -0
- package/components/DatePickerModal/DatePickerModalContent.tsx +155 -0
- package/components/DatePickerModal/DatePickerModalContentHeader.tsx +213 -0
- package/components/DatePickerModal/DatePickerModalHeader.tsx +74 -0
- package/components/DatePickerModal/DatePickerModalHeaderBackground.tsx +13 -0
- package/components/DatePickerModal/index.tsx +20 -0
- package/components/DatePickerModal/types.ts +92 -0
- package/components/DatePickerModal/utils.ts +121 -0
- package/components/DateTimePicker/DateTimePicker.tsx +172 -0
- package/components/DateTimePicker/index.tsx +14 -0
- package/components/DateTimePicker/utils.ts +13 -0
- package/components/Dialog/Dialog.tsx +66 -0
- package/components/Dialog/DialogActions.tsx +89 -0
- package/components/Dialog/DialogContent.tsx +37 -0
- package/components/Dialog/DialogIcon.tsx +69 -0
- package/components/Dialog/DialogTitle.tsx +68 -0
- package/components/Dialog/index.tsx +37 -0
- package/components/Dialog/utils.ts +80 -0
- package/components/Drawer/Collapsible/DrawerCollapsible.tsx +22 -0
- package/components/Drawer/Collapsible/DrawerCollapsibleItem.tsx +38 -0
- package/components/Drawer/Collapsible/DrawerCollapsibleItemContent.tsx +16 -0
- package/components/Drawer/Collapsible/DrawerCollapsibleItemHeader.tsx +48 -0
- package/components/Drawer/Collapsible/index.tsx +23 -0
- package/components/Drawer/Collapsible/utils.ts +49 -0
- package/components/Drawer/Drawer.tsx +43 -0
- package/components/Drawer/DrawerContent.tsx +35 -0
- package/components/Drawer/DrawerFooter.tsx +27 -0
- package/components/Drawer/DrawerHeader.tsx +27 -0
- package/components/Drawer/DrawerItem.tsx +206 -0
- package/components/Drawer/DrawerItemGroup.tsx +82 -0
- package/components/Drawer/index.tsx +47 -0
- package/components/Drawer/types.ts +3 -0
- package/components/Drawer/utils.ts +8 -0
- package/components/ElementGroup/ElementGroup.tsx +139 -0
- package/components/ElementGroup/index.tsx +11 -0
- package/components/ElementGroup/utils.ts +25 -0
- package/components/FAB/FAB.tsx +176 -0
- package/components/FAB/index.tsx +12 -0
- package/components/FAB/types.ts +1 -0
- package/components/FAB/utils.ts +221 -0
- package/components/FilePicker/FilePicker.tsx +133 -0
- package/components/FilePicker/index.tsx +11 -0
- package/components/FilePicker/utils.ts +13 -0
- package/components/HelperText/HelperText.tsx +139 -0
- package/components/HelperText/index.tsx +11 -0
- package/components/HelperText/utils.ts +29 -0
- package/components/HorizontalDivider/HorizontalDivider.tsx +101 -0
- package/components/HorizontalDivider/index.tsx +13 -0
- package/components/Icon/CrossFadeIcon.tsx +116 -0
- package/components/Icon/Icon.tsx +41 -0
- package/components/Icon/iconFactory.tsx +23 -0
- package/components/Icon/index.tsx +11 -0
- package/components/Icon/types.ts +35 -0
- package/components/IconButton/IconButton.tsx +218 -0
- package/components/IconButton/index.tsx +11 -0
- package/components/IconButton/types.ts +1 -0
- package/components/IconButton/utils.ts +325 -0
- package/components/If/index.tsx +13 -0
- package/components/InputAddon/InputAddon.tsx +27 -0
- package/components/InputAddon/index.tsx +11 -0
- package/components/InputAddon/utils.ts +33 -0
- package/components/Link/Link.tsx +48 -0
- package/components/Link/index.tsx +11 -0
- package/components/Link/utils.ts +37 -0
- package/components/ListItem/ListItem.tsx +136 -0
- package/components/ListItem/ListItemDescription.tsx +25 -0
- package/components/ListItem/ListItemTitle.tsx +25 -0
- package/components/ListItem/index.tsx +18 -0
- package/components/ListItem/utils.ts +113 -0
- package/components/Menu/Menu.tsx +69 -0
- package/components/Menu/MenuDivider.tsx +13 -0
- package/components/Menu/MenuItem.tsx +128 -0
- package/components/Menu/index.tsx +19 -0
- package/components/Menu/utils.ts +92 -0
- package/components/Modal/Modal.tsx +261 -0
- package/components/Modal/index.tsx +11 -0
- package/components/Modal/utils.ts +45 -0
- package/components/NavigationRail/NavigationRail.tsx +32 -0
- package/components/NavigationRail/NavigationRailContent.tsx +25 -0
- package/components/NavigationRail/NavigationRailFooter.tsx +18 -0
- package/components/NavigationRail/NavigationRailHeader.tsx +18 -0
- package/components/NavigationRail/NavigationRailItem.tsx +226 -0
- package/components/NavigationRail/index.tsx +35 -0
- package/components/NavigationRail/utils.ts +170 -0
- package/components/NavigationStack/NavigationStack.tsx +85 -0
- package/components/NavigationStack/NavigationStackItem.tsx +60 -0
- package/components/NavigationStack/index.tsx +20 -0
- package/components/NavigationStack/utils.tsx +16 -0
- package/components/Popover/Popover.native.tsx +185 -0
- package/components/Popover/Popover.tsx +198 -0
- package/components/Popover/common.ts +459 -0
- package/components/Popover/index.ts +2 -0
- package/components/Portal/Portal.tsx +13 -0
- package/components/Portal/index.tsx +12 -0
- package/components/RadioButton/RadioButton.tsx +138 -0
- package/components/RadioButton/RadioButtonAndroid.tsx +188 -0
- package/components/RadioButton/RadioButtonGroup.tsx +98 -0
- package/components/RadioButton/RadioButtonIOS.tsx +106 -0
- package/components/RadioButton/RadioButtonItem.tsx +232 -0
- package/components/RadioButton/index.ts +27 -0
- package/components/RadioButton/utils.ts +164 -0
- package/components/Rating/Rating.tsx +149 -0
- package/components/Rating/RatingItem.tsx +125 -0
- package/components/Rating/index.tsx +13 -0
- package/components/Rating/utils.ts +38 -0
- package/components/Select/Select.tsx +1038 -0
- package/components/Select/index.ts +14 -0
- package/components/Select/types.ts +115 -0
- package/components/StateLayer/StateLayer.tsx +12 -0
- package/components/StateLayer/index.tsx +11 -0
- package/components/StateLayer/utils.ts +17 -0
- package/components/Surface/BackgroundContextWrapper.tsx +27 -0
- package/components/Surface/Surface.android.tsx +62 -0
- package/components/Surface/Surface.ios.tsx +123 -0
- package/components/Surface/Surface.tsx +48 -0
- package/components/Surface/index.tsx +12 -0
- package/components/Surface/utils.ts +106 -0
- package/components/Switch/Switch.ios.tsx +67 -0
- package/components/Switch/Switch.tsx +278 -0
- package/components/Switch/index.tsx +11 -0
- package/components/Switch/utils.ts +283 -0
- package/components/Tabs/TabItem.tsx +150 -0
- package/components/Tabs/TabLabel.tsx +84 -0
- package/components/Tabs/Tabs.tsx +398 -0
- package/components/Tabs/index.tsx +21 -0
- package/components/Tabs/utils.ts +126 -0
- package/components/Text/Text.tsx +23 -0
- package/components/Text/index.tsx +2 -0
- package/components/Text/textFactory.tsx +33 -0
- package/components/TextInput/InputLabel.tsx +181 -0
- package/components/TextInput/TextInput.tsx +693 -0
- package/components/TextInput/index.tsx +16 -0
- package/components/TextInput/types.ts +96 -0
- package/components/TextInput/utils.ts +544 -0
- package/components/TextInputWithMask/TextInputMask.tsx +57 -0
- package/components/TextInputWithMask/index.tsx +11 -0
- package/components/TextInputWithMask/utils.ts +56 -0
- package/components/TimePicker/AmPmSwitcher.tsx +99 -0
- package/components/TimePicker/AnalogClock.tsx +165 -0
- package/components/TimePicker/AnalogClockHours.tsx +163 -0
- package/components/TimePicker/AnalogClockMinutes.tsx +68 -0
- package/components/TimePicker/AnimatedClockSwitcher.tsx +72 -0
- package/components/TimePicker/DisplayModeContext.tsx +6 -0
- package/components/TimePicker/TimeInput.tsx +112 -0
- package/components/TimePicker/TimeInputs.tsx +148 -0
- package/components/TimePicker/TimePicker.tsx +130 -0
- package/components/TimePicker/index.tsx +19 -0
- package/components/TimePicker/timeUtils.ts +159 -0
- package/components/TimePicker/utils.ts +285 -0
- package/components/TimePickerField/TimePickerField.tsx +152 -0
- package/components/TimePickerField/index.tsx +14 -0
- package/components/TimePickerField/sanitizeTime.ts +85 -0
- package/components/TimePickerField/utils.ts +95 -0
- package/components/TimePickerModal/TimePickerModal.tsx +115 -0
- package/components/TimePickerModal/index.tsx +14 -0
- package/components/TimePickerModal/utils.ts +48 -0
- package/components/Tooltip/Tooltip.tsx +137 -0
- package/components/Tooltip/TooltipContent.tsx +12 -0
- package/components/Tooltip/TooltipTrigger.tsx +94 -0
- package/components/Tooltip/index.tsx +20 -0
- package/components/Tooltip/utils.ts +21 -0
- package/components/TouchableRipple/TouchableRipple.native.tsx +105 -0
- package/components/TouchableRipple/TouchableRipple.tsx +286 -0
- package/components/TouchableRipple/index.tsx +14 -0
- package/components/TouchableRipple/utils.ts +15 -0
- package/components/VerticalDivider/VerticalDivider.tsx +99 -0
- package/components/VerticalDivider/index.tsx +13 -0
- package/context-bridge/index.tsx +87 -0
- package/core/componentsRegistry.ts +164 -0
- package/core/index.tsx +2 -0
- package/fast-context/index.tsx +190 -0
- package/hocs/index.tsx +5 -0
- package/hocs/typedMemo.tsx +5 -0
- package/hocs/withKeyboardAccessibility.tsx +231 -0
- package/hocs/withPortal.tsx +16 -0
- package/hooks/createPsuedoHook.tsx +50 -0
- package/hooks/index.tsx +29 -0
- package/hooks/useActionState.native.tsx +22 -0
- package/hooks/useActionState.tsx +34 -0
- package/hooks/useActive.tsx +5 -0
- package/hooks/useBreakpoints.tsx +7 -0
- package/hooks/useColorMode.tsx +17 -0
- package/hooks/useContrastColor.ts +15 -0
- package/hooks/useControlledValue.tsx +68 -0
- package/hooks/useFilePicker.tsx +48 -0
- package/hooks/useFocus.tsx +5 -0
- package/hooks/useHandleNumberFormat.tsx +106 -0
- package/hooks/useHover.tsx +5 -0
- package/hooks/useKeyboardDismissable.ts +66 -0
- package/hooks/useLatest.tsx +9 -0
- package/hooks/useMediaQuery.tsx +64 -0
- package/hooks/useMergedRefs.ts +14 -0
- package/hooks/usePrevious.ts +13 -0
- package/hooks/useQueryFilter.tsx +35 -0
- package/hooks/useSearchable.tsx +74 -0
- package/hooks/useSubcomponents.tsx +59 -0
- package/hooks/useTheme.ts +3 -0
- package/hooks/useToggle.tsx +24 -0
- package/package.json +114 -0
- package/shortcuts-manager/EventsManager.tsx +121 -0
- package/shortcuts-manager/ShortcutsManager/ShortcutsManager.native.tsx +9 -0
- package/shortcuts-manager/ShortcutsManager/ShortcutsManager.tsx +58 -0
- package/shortcuts-manager/ShortcutsManager/index.tsx +2 -0
- package/shortcuts-manager/ShortcutsManager/utils.tsx +30 -0
- package/shortcuts-manager/index.tsx +6 -0
- package/shortcuts-manager/types.ts +24 -0
- package/shortcuts-manager/useIsKeyPressed/index.tsx +1 -0
- package/shortcuts-manager/useIsKeyPressed/useIsKeyPress.tsx +9 -0
- package/shortcuts-manager/useSetScopes/index.tsx +1 -0
- package/shortcuts-manager/useSetScopes/useSetScopes.native.tsx +9 -0
- package/shortcuts-manager/useSetScopes/useSetScopes.tsx +25 -0
- package/shortcuts-manager/useShortcut/index.tsx +2 -0
- package/shortcuts-manager/useShortcut/types.ts +3 -0
- package/shortcuts-manager/useShortcut/useShortcut.native.tsx +9 -0
- package/shortcuts-manager/useShortcut/useShortcut.tsx +61 -0
- package/shortcuts-manager/utils.ts +105 -0
- package/styles/index.ts +4 -0
- package/styles/overlay.ts +69 -0
- package/styles/shadow.ts +21 -0
- package/styles/themes/DarkTheme.tsx +98 -0
- package/styles/themes/LightTheme.tsx +212 -0
- package/styles/themes/tokens.ts +248 -0
- package/styles/utils.ts +11 -0
- package/types/index.ts +129 -0
- package/types/theme.ts +159 -0
- package/utils/DocumentPicker/documentPicker.native.ts +10 -0
- package/utils/DocumentPicker/documentPicker.ts +76 -0
- package/utils/DocumentPicker/index.ts +2 -0
- package/utils/DocumentPicker/types.ts +28 -0
- package/utils/addEventListener.tsx +51 -0
- package/utils/backgroundContext.ts +9 -0
- package/utils/color.ts +22 -0
- package/utils/compare/index.ts +54 -0
- package/utils/composeEventHandlers.ts +9 -0
- package/utils/createNumberMask/createNumberMask.ts +98 -0
- package/utils/createNumberMask/index.ts +5 -0
- package/utils/createSyntheticEvent.ts +31 -0
- package/utils/date-fns.ts +7 -0
- package/utils/dateTimePicker.ts +5 -0
- package/utils/escapeRegex.ts +9 -0
- package/utils/extractTextStyles.ts +52 -0
- package/utils/formatNumberWithMask/formatNumberWithMask.ts +26 -0
- package/utils/formatNumberWithMask/formatWithMask.ts +119 -0
- package/utils/formatNumberWithMask/index.ts +6 -0
- package/utils/getCursorStyle/getCursorStyle.native.ts +1 -0
- package/utils/getCursorStyle/getCursorStyle.ts +1 -0
- package/utils/getCursorStyle/index.ts +1 -0
- package/utils/getOS/getOS.native.ts +7 -0
- package/utils/getOS/getOS.ts +24 -0
- package/utils/getOS/index.ts +1 -0
- package/utils/getyearRange.ts +5 -0
- package/utils/index.ts +20 -0
- package/utils/lodash.ts +50 -0
- package/utils/mergeRefs.ts +13 -0
- package/utils/normalizeBorderRadiuses.ts +24 -0
- package/utils/normalizeSpacings.ts +110 -0
- package/utils/normalizeToNumberString/index.ts +4 -0
- package/utils/normalizeToNumberString/normalizeToNumberString.ts +48 -0
- package/utils/repository.ts +103 -0
- package/utils/resolveColorMode.ts +9 -0
- package/utils/resolveStateVariant.ts +26 -0
- package/utils/tokenStylesParser.ts +7 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { memo, useCallback, useEffect, useMemo } from 'react';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { useLatest } from '../../hooks';
|
|
5
|
+
import { defaultValue, Provider, useDatePickerStore } from './DatePickerContext';
|
|
6
|
+
import { areDatesOnSameDay, dateToUnix, getEndOfDay, getInitialIndex } from './dateUtils';
|
|
7
|
+
import Month from './Month';
|
|
8
|
+
import MonthPicker from './MonthPicker';
|
|
9
|
+
import Swiper from './Swiper';
|
|
10
|
+
import type {
|
|
11
|
+
CalendarDate,
|
|
12
|
+
CalendarDates,
|
|
13
|
+
DatePickerInlineBaseProps,
|
|
14
|
+
MultiChange,
|
|
15
|
+
RangeChange,
|
|
16
|
+
SingleChange,
|
|
17
|
+
} from './types';
|
|
18
|
+
import YearPicker from './YearPicker';
|
|
19
|
+
|
|
20
|
+
function DatePickerInlineBase(props: DatePickerInlineBaseProps) {
|
|
21
|
+
return (
|
|
22
|
+
<Provider value={defaultValue}>
|
|
23
|
+
<DatePickerInlineComponent {...props} />
|
|
24
|
+
</Provider>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function DatePickerInlineBaseChild(props: DatePickerInlineBaseProps) {
|
|
29
|
+
const {
|
|
30
|
+
locale = 'en',
|
|
31
|
+
mode = 'single',
|
|
32
|
+
onChange,
|
|
33
|
+
startYear = 1800,
|
|
34
|
+
endYear = 2200,
|
|
35
|
+
startDate,
|
|
36
|
+
endDate,
|
|
37
|
+
date,
|
|
38
|
+
disableWeekDays,
|
|
39
|
+
dates,
|
|
40
|
+
validRange,
|
|
41
|
+
dateMode = 'start',
|
|
42
|
+
style,
|
|
43
|
+
HeaderComponent,
|
|
44
|
+
onToggle,
|
|
45
|
+
monthStyle,
|
|
46
|
+
} = props;
|
|
47
|
+
const [pickerType, setStore] = useDatePickerStore(state => state.pickerType);
|
|
48
|
+
|
|
49
|
+
const scrollMode = mode === 'range' || mode === 'multiple' ? 'vertical' : 'horizontal';
|
|
50
|
+
const isHorizontal = scrollMode === 'horizontal';
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
setStore(() => ({
|
|
54
|
+
localDate: date || new Date(),
|
|
55
|
+
startDateYear: startYear,
|
|
56
|
+
endDateYear: endYear,
|
|
57
|
+
}));
|
|
58
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
|
+
}, []);
|
|
60
|
+
|
|
61
|
+
// prevent re-rendering all months when something changed we only need the
|
|
62
|
+
// latest version of the props and we don't want the useCallback to change
|
|
63
|
+
const startDateRef = useLatest<CalendarDate>(startDate);
|
|
64
|
+
const endDateRef = useLatest<CalendarDate>(endDate);
|
|
65
|
+
const onChangeRef = useLatest<RangeChange | SingleChange | MultiChange | undefined>(onChange);
|
|
66
|
+
const datesRef = useLatest<CalendarDates>(dates);
|
|
67
|
+
|
|
68
|
+
const onPressDate = useCallback(
|
|
69
|
+
(d: Date) => {
|
|
70
|
+
if (mode === 'single') {
|
|
71
|
+
(onChangeRef.current as SingleChange)({
|
|
72
|
+
date: dateMode === 'start' ? d : getEndOfDay(d),
|
|
73
|
+
});
|
|
74
|
+
} else if (mode === 'range') {
|
|
75
|
+
const sd = startDateRef.current;
|
|
76
|
+
const ed = endDateRef.current;
|
|
77
|
+
let isStart: boolean = true;
|
|
78
|
+
if (sd && !ed && dateToUnix(d) >= dateToUnix(sd!)) {
|
|
79
|
+
isStart = false;
|
|
80
|
+
}
|
|
81
|
+
(onChangeRef.current as RangeChange)({
|
|
82
|
+
startDate: isStart ? d : sd,
|
|
83
|
+
endDate: !isStart ? getEndOfDay(d) : undefined,
|
|
84
|
+
});
|
|
85
|
+
} else if (mode === 'multiple') {
|
|
86
|
+
datesRef.current = datesRef.current || [];
|
|
87
|
+
const exists = datesRef.current.some(ed => areDatesOnSameDay(ed, d));
|
|
88
|
+
|
|
89
|
+
const newDates = exists
|
|
90
|
+
? datesRef.current.filter(ed => !areDatesOnSameDay(ed, d))
|
|
91
|
+
: [...datesRef.current, d];
|
|
92
|
+
|
|
93
|
+
newDates.sort((a, b) => a.getTime() - b.getTime());
|
|
94
|
+
(onChangeRef.current as MultiChange)({
|
|
95
|
+
dates: newDates,
|
|
96
|
+
datePressed: d,
|
|
97
|
+
change: exists ? 'removed' : 'added',
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
onToggle?.();
|
|
101
|
+
},
|
|
102
|
+
[mode, dateMode, onChangeRef, startDateRef, endDateRef, datesRef, onToggle],
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const { containerStyle, initialIndex } = useMemo(() => {
|
|
106
|
+
return {
|
|
107
|
+
containerStyle: [styles.root, style],
|
|
108
|
+
initialIndex: getInitialIndex(startDate || date || dates?.[0]),
|
|
109
|
+
};
|
|
110
|
+
}, [date, dates, startDate, style]);
|
|
111
|
+
|
|
112
|
+
const renderMonthComponent = useCallback(
|
|
113
|
+
(index: number) => {
|
|
114
|
+
return (
|
|
115
|
+
<Month
|
|
116
|
+
locale={locale}
|
|
117
|
+
mode={mode}
|
|
118
|
+
validRange={validRange}
|
|
119
|
+
index={index}
|
|
120
|
+
date={date}
|
|
121
|
+
dates={dates}
|
|
122
|
+
startDate={startDate}
|
|
123
|
+
endDate={endDate}
|
|
124
|
+
onPressDate={onPressDate}
|
|
125
|
+
scrollMode={scrollMode}
|
|
126
|
+
disableWeekDays={disableWeekDays}
|
|
127
|
+
customMonthStyles={monthStyle}
|
|
128
|
+
/>
|
|
129
|
+
);
|
|
130
|
+
},
|
|
131
|
+
[
|
|
132
|
+
locale,
|
|
133
|
+
mode,
|
|
134
|
+
validRange,
|
|
135
|
+
date,
|
|
136
|
+
dates,
|
|
137
|
+
startDate,
|
|
138
|
+
endDate,
|
|
139
|
+
onPressDate,
|
|
140
|
+
scrollMode,
|
|
141
|
+
disableWeekDays,
|
|
142
|
+
monthStyle,
|
|
143
|
+
],
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const renderCalenderHeader = useCallback(() => {
|
|
147
|
+
if (HeaderComponent) {
|
|
148
|
+
return (
|
|
149
|
+
<HeaderComponent
|
|
150
|
+
// TODO - fix ts issues
|
|
151
|
+
// @ts-ignore
|
|
152
|
+
scrollMode={scrollMode}
|
|
153
|
+
disableWeekDays={disableWeekDays}
|
|
154
|
+
locale={locale}
|
|
155
|
+
/>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
}, [HeaderComponent, scrollMode, disableWeekDays, locale]);
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<View style={containerStyle}>
|
|
163
|
+
<Swiper
|
|
164
|
+
initialIndex={initialIndex}
|
|
165
|
+
scrollMode={scrollMode}
|
|
166
|
+
renderItem={renderMonthComponent}
|
|
167
|
+
renderHeader={renderCalenderHeader}
|
|
168
|
+
/>
|
|
169
|
+
{isHorizontal && pickerType === 'year' && <YearPicker />}
|
|
170
|
+
{isHorizontal && pickerType === 'month' && <MonthPicker />}
|
|
171
|
+
</View>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const styles = StyleSheet.create({
|
|
176
|
+
root: { flex: 1 },
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
const DatePickerInlineComponent = memo(DatePickerInlineBaseChild);
|
|
180
|
+
|
|
181
|
+
export default memo(DatePickerInlineBase);
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { add, format } from 'date-fns';
|
|
2
|
+
import { memo, useCallback, useMemo } from 'react';
|
|
3
|
+
import { type StyleProp, View, type ViewStyle } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import { useDatePickerStore, useDatePickerStoreValue } from './DatePickerContext';
|
|
6
|
+
import type { DisableWeekDaysType } from './dateUtils';
|
|
7
|
+
import DayNames from './DayNames';
|
|
8
|
+
import HeaderItem from './HeaderItem';
|
|
9
|
+
import { datePickerHeaderStyles, dayNamesHeight } from './utils';
|
|
10
|
+
|
|
11
|
+
const buttonContainerHeight = 56;
|
|
12
|
+
const buttonContainerMarginTop = 4;
|
|
13
|
+
const buttonContainerMarginBottom = 8;
|
|
14
|
+
|
|
15
|
+
export type CalendarHeaderProps = {
|
|
16
|
+
locale?: string;
|
|
17
|
+
scrollMode: 'horizontal' | 'vertical';
|
|
18
|
+
disableWeekDays?: DisableWeekDaysType;
|
|
19
|
+
style?: ViewStyle;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function DatePickerInlineHeader({
|
|
23
|
+
locale = 'en',
|
|
24
|
+
scrollMode,
|
|
25
|
+
disableWeekDays,
|
|
26
|
+
style: styleProp,
|
|
27
|
+
}: CalendarHeaderProps) {
|
|
28
|
+
const [_, setStore] = useDatePickerStore(state => state);
|
|
29
|
+
const { localDate, isYearPickerType } = useDatePickerStoreValue(state => ({
|
|
30
|
+
localDate: state.localDate,
|
|
31
|
+
isYearPickerType: state.pickerType === 'year',
|
|
32
|
+
}));
|
|
33
|
+
const isHorizontal = scrollMode === 'horizontal';
|
|
34
|
+
|
|
35
|
+
const { monthName, year } = useMemo(() => {
|
|
36
|
+
const y = localDate.getFullYear();
|
|
37
|
+
|
|
38
|
+
return { monthName: format(localDate, 'LLLL'), year: y };
|
|
39
|
+
}, [localDate]);
|
|
40
|
+
|
|
41
|
+
const { containerStyle } = useMemo(() => {
|
|
42
|
+
// const { datePickerHeader, buttonContainer, buttonWrapper, spacer, ...rest } =
|
|
43
|
+
// componentStyles;
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
containerStyle: [
|
|
47
|
+
datePickerHeaderStyles.datePickerHeader,
|
|
48
|
+
datePickerHeaderStyles,
|
|
49
|
+
styleProp,
|
|
50
|
+
] as StyleProp<ViewStyle>,
|
|
51
|
+
buttonContainerStyle: datePickerHeaderStyles.buttonContainer,
|
|
52
|
+
buttonWrapperStyle: datePickerHeaderStyles.buttonWrapper,
|
|
53
|
+
spacerStyle: datePickerHeaderStyles.spacer,
|
|
54
|
+
};
|
|
55
|
+
}, [styleProp]);
|
|
56
|
+
|
|
57
|
+
const handleOnYearPress = useCallback(() => {
|
|
58
|
+
isHorizontal && setStore(prev => ({ pickerType: prev.pickerType ? undefined : 'year' }));
|
|
59
|
+
}, [isHorizontal, setStore]);
|
|
60
|
+
|
|
61
|
+
const handleOnPrev = useCallback(() => {
|
|
62
|
+
setStore(prev => ({ localDate: add(prev.localDate, { months: -1 }) }));
|
|
63
|
+
}, [setStore]);
|
|
64
|
+
|
|
65
|
+
const handleOnNext = useCallback(() => {
|
|
66
|
+
setStore(prev => ({ localDate: add(prev.localDate, { months: 1 }) }));
|
|
67
|
+
}, [setStore]);
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<View pointerEvents={'box-none'}>
|
|
71
|
+
<>
|
|
72
|
+
{isHorizontal && (
|
|
73
|
+
<View style={containerStyle}>
|
|
74
|
+
<HeaderItem
|
|
75
|
+
onPressDropdown={handleOnYearPress}
|
|
76
|
+
type="year"
|
|
77
|
+
value={`${monthName} ${year}`}
|
|
78
|
+
pickerType="year"
|
|
79
|
+
selecting={isYearPickerType}
|
|
80
|
+
/>
|
|
81
|
+
<HeaderItem
|
|
82
|
+
onNext={handleOnNext}
|
|
83
|
+
onPrev={handleOnPrev}
|
|
84
|
+
selecting={false}
|
|
85
|
+
value={year}
|
|
86
|
+
pickerType="year"
|
|
87
|
+
/>
|
|
88
|
+
</View>
|
|
89
|
+
)}
|
|
90
|
+
</>
|
|
91
|
+
<DayNames disableWeekDays={disableWeekDays} locale={locale} />
|
|
92
|
+
</View>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function getCalendarHeaderHeight(scrollMode: 'horizontal' | 'vertical') {
|
|
97
|
+
if (scrollMode === 'horizontal') {
|
|
98
|
+
return (
|
|
99
|
+
buttonContainerHeight +
|
|
100
|
+
buttonContainerMarginTop +
|
|
101
|
+
buttonContainerMarginBottom +
|
|
102
|
+
dayNamesHeight
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
return dayNamesHeight;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default memo(DatePickerInlineHeader);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { memo, useCallback, useMemo } from 'react';
|
|
2
|
+
import { type StyleProp, View, type ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { resolveStateVariant } from '../../utils';
|
|
5
|
+
import { Text } from '../Text';
|
|
6
|
+
import { TouchableRipple } from '../TouchableRipple';
|
|
7
|
+
import DayRange from './DayRange';
|
|
8
|
+
import { datePickerDayEmptyStyles, datePickerDayStyles } from './utils';
|
|
9
|
+
|
|
10
|
+
function EmptyDayPure() {
|
|
11
|
+
return <View style={datePickerDayEmptyStyles.root} />;
|
|
12
|
+
}
|
|
13
|
+
export const EmptyDay = memo(EmptyDayPure);
|
|
14
|
+
|
|
15
|
+
// TODO hover state
|
|
16
|
+
function Day(props: {
|
|
17
|
+
day: number;
|
|
18
|
+
month: number;
|
|
19
|
+
year: number;
|
|
20
|
+
selected: boolean;
|
|
21
|
+
inRange: boolean;
|
|
22
|
+
leftCrop: boolean;
|
|
23
|
+
rightCrop: boolean;
|
|
24
|
+
isToday: boolean;
|
|
25
|
+
disabled: boolean;
|
|
26
|
+
onPressDate: (date: Date) => any;
|
|
27
|
+
}) {
|
|
28
|
+
const {
|
|
29
|
+
day,
|
|
30
|
+
month,
|
|
31
|
+
year,
|
|
32
|
+
selected,
|
|
33
|
+
inRange,
|
|
34
|
+
leftCrop,
|
|
35
|
+
rightCrop,
|
|
36
|
+
onPressDate,
|
|
37
|
+
isToday,
|
|
38
|
+
disabled,
|
|
39
|
+
} = props;
|
|
40
|
+
const state = resolveStateVariant({
|
|
41
|
+
disabled,
|
|
42
|
+
selected,
|
|
43
|
+
inRange,
|
|
44
|
+
today: isToday,
|
|
45
|
+
});
|
|
46
|
+
datePickerDayStyles.useVariants({
|
|
47
|
+
state: state as any,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const onPress = useCallback(() => {
|
|
51
|
+
onPressDate(new Date(year, month, day));
|
|
52
|
+
}, [onPressDate, year, month, day]);
|
|
53
|
+
|
|
54
|
+
const { containerStyle, buttonStyle, dayStyle, textStyle } = useMemo(() => {
|
|
55
|
+
return {
|
|
56
|
+
containerStyle: datePickerDayStyles.containerStyle,
|
|
57
|
+
buttonStyle: datePickerDayStyles.button,
|
|
58
|
+
dayStyle: [
|
|
59
|
+
datePickerDayStyles.day,
|
|
60
|
+
isToday ? datePickerDayStyles.today : null,
|
|
61
|
+
] as StyleProp<ViewStyle>,
|
|
62
|
+
textStyle: datePickerDayStyles.text,
|
|
63
|
+
};
|
|
64
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
|
+
}, [isToday, state]);
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<View style={containerStyle}>
|
|
69
|
+
<DayRange inRange={inRange} leftCrop={leftCrop} rightCrop={rightCrop} />
|
|
70
|
+
|
|
71
|
+
<TouchableRipple
|
|
72
|
+
testID={`day-${year}-${month}-${day}`}
|
|
73
|
+
disabled={disabled}
|
|
74
|
+
borderless={true}
|
|
75
|
+
onPress={disabled ? undefined : onPress}
|
|
76
|
+
style={buttonStyle}
|
|
77
|
+
accessibilityRole="button">
|
|
78
|
+
<View style={dayStyle}>
|
|
79
|
+
<Text style={textStyle} selectable={false}>
|
|
80
|
+
{day}
|
|
81
|
+
</Text>
|
|
82
|
+
</View>
|
|
83
|
+
</TouchableRipple>
|
|
84
|
+
</View>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default memo(Day);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { Text } from '../Text';
|
|
5
|
+
import { dateDayNameStyles } from './utils';
|
|
6
|
+
|
|
7
|
+
function DayName({ label }: { label: string }) {
|
|
8
|
+
return (
|
|
9
|
+
<View style={dateDayNameStyles.dayName}>
|
|
10
|
+
<Text style={dateDayNameStyles.dayName} selectable={false}>
|
|
11
|
+
{label}
|
|
12
|
+
</Text>
|
|
13
|
+
</View>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default memo(DayName);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { addDays, format, startOfWeek } from '../../utils/date-fns';
|
|
5
|
+
import { type DisableWeekDaysType, showWeekDay } from './dateUtils';
|
|
6
|
+
import DayName from './DayName';
|
|
7
|
+
import { dateDayNameStyles } from './utils';
|
|
8
|
+
|
|
9
|
+
const shortDayNames = (() => {
|
|
10
|
+
const firstDOW = startOfWeek(new Date());
|
|
11
|
+
return Array.from(Array(7)).map((_, i) => format(addDays(firstDOW, i), 'EEEEE'));
|
|
12
|
+
})();
|
|
13
|
+
|
|
14
|
+
function DayNames({
|
|
15
|
+
disableWeekDays,
|
|
16
|
+
}: // locale,
|
|
17
|
+
{
|
|
18
|
+
disableWeekDays?: DisableWeekDaysType;
|
|
19
|
+
locale?: string;
|
|
20
|
+
}) {
|
|
21
|
+
return (
|
|
22
|
+
<View style={dateDayNameStyles.container} pointerEvents={'none'}>
|
|
23
|
+
{shortDayNames
|
|
24
|
+
.filter((_, dayIndex) => showWeekDay(dayIndex, disableWeekDays))
|
|
25
|
+
.map((dayName, i) => (
|
|
26
|
+
<DayName key={`${dayName}_${i}`} label={dayName} />
|
|
27
|
+
))}
|
|
28
|
+
</View>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default memo(DayNames);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { resolveStateVariant } from '../../utils';
|
|
5
|
+
import { datePickerDayRangeStyles } from './utils';
|
|
6
|
+
|
|
7
|
+
function DayRange({
|
|
8
|
+
leftCrop,
|
|
9
|
+
rightCrop,
|
|
10
|
+
inRange,
|
|
11
|
+
}: {
|
|
12
|
+
leftCrop: boolean;
|
|
13
|
+
rightCrop: boolean;
|
|
14
|
+
inRange: boolean;
|
|
15
|
+
}) {
|
|
16
|
+
const bothWays = inRange && leftCrop && rightCrop;
|
|
17
|
+
const isCrop = inRange && (leftCrop || rightCrop) && !(leftCrop && rightCrop);
|
|
18
|
+
|
|
19
|
+
datePickerDayRangeStyles.useVariants({
|
|
20
|
+
state: resolveStateVariant({
|
|
21
|
+
isRightCrop: rightCrop,
|
|
22
|
+
isLeftCrop: leftCrop,
|
|
23
|
+
inRange,
|
|
24
|
+
bothWays,
|
|
25
|
+
isCrop,
|
|
26
|
+
}) as any,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
{(inRange || isCrop) && (
|
|
32
|
+
<View
|
|
33
|
+
pointerEvents="none"
|
|
34
|
+
style={[StyleSheet.absoluteFill, datePickerDayRangeStyles.container]}>
|
|
35
|
+
{isCrop && (
|
|
36
|
+
<>
|
|
37
|
+
<View style={datePickerDayRangeStyles.rightCrop} />
|
|
38
|
+
<View style={datePickerDayRangeStyles.centerCrop} />
|
|
39
|
+
<View style={datePickerDayRangeStyles.leftCrop} />
|
|
40
|
+
</>
|
|
41
|
+
)}
|
|
42
|
+
</View>
|
|
43
|
+
)}
|
|
44
|
+
</>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default memo(DayRange);
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { memo, useCallback, useMemo } from 'react';
|
|
2
|
+
import { type StyleProp, View, type ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { datePickerHeaderItemStyles } from '../DatePickerDocked/utils';
|
|
5
|
+
import { IconButton } from '../IconButton';
|
|
6
|
+
import { Text } from '../Text';
|
|
7
|
+
import { TouchableRipple } from '../TouchableRipple';
|
|
8
|
+
import { useDatePickerStoreValue } from './DatePickerContext';
|
|
9
|
+
|
|
10
|
+
function HeaderItem({
|
|
11
|
+
value,
|
|
12
|
+
selecting,
|
|
13
|
+
type,
|
|
14
|
+
pickerType,
|
|
15
|
+
onPressDropdown,
|
|
16
|
+
onNext,
|
|
17
|
+
onPrev,
|
|
18
|
+
}: {
|
|
19
|
+
value: number | string;
|
|
20
|
+
type?: 'month' | 'year';
|
|
21
|
+
selecting?: boolean;
|
|
22
|
+
pickerType: 'month' | 'year' | undefined;
|
|
23
|
+
onPressDropdown?: (type: 'month' | 'year') => void;
|
|
24
|
+
onNext?: (type: 'month' | 'year' | undefined) => void;
|
|
25
|
+
onPrev?: (type: 'month' | 'year' | undefined) => void;
|
|
26
|
+
}) {
|
|
27
|
+
const { startDateYear, endDateYear } = useDatePickerStoreValue(state => ({
|
|
28
|
+
startDateYear: state.startDateYear,
|
|
29
|
+
endDateYear: state.endDateYear,
|
|
30
|
+
}));
|
|
31
|
+
const disabled = pickerType && pickerType !== type;
|
|
32
|
+
|
|
33
|
+
const handlePressDropDown = useCallback(() => {
|
|
34
|
+
type && onPressDropdown && onPressDropdown(type);
|
|
35
|
+
}, [onPressDropdown, type]);
|
|
36
|
+
|
|
37
|
+
const handleOnPrevious = useCallback(() => {
|
|
38
|
+
onPrev && onPrev(type);
|
|
39
|
+
}, [onPrev, type]);
|
|
40
|
+
|
|
41
|
+
const handleOnNext = useCallback(() => {
|
|
42
|
+
onNext && onNext(type);
|
|
43
|
+
}, [onNext, type]);
|
|
44
|
+
|
|
45
|
+
const containerStyle = useMemo(
|
|
46
|
+
() =>
|
|
47
|
+
[
|
|
48
|
+
datePickerHeaderItemStyles.buttonContainer,
|
|
49
|
+
{
|
|
50
|
+
justifyContent: !onPressDropdown
|
|
51
|
+
? 'flex-end'
|
|
52
|
+
: !onNext
|
|
53
|
+
? 'flex-start'
|
|
54
|
+
: 'center',
|
|
55
|
+
},
|
|
56
|
+
] as StyleProp<ViewStyle>,
|
|
57
|
+
[onPressDropdown, onNext],
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<View style={containerStyle} pointerEvents={'box-none'}>
|
|
62
|
+
{!selecting && onPrev && (
|
|
63
|
+
<View style={datePickerHeaderItemStyles.buttonWrapper}>
|
|
64
|
+
<IconButton
|
|
65
|
+
type="material-community"
|
|
66
|
+
name="chevron-left"
|
|
67
|
+
size="md"
|
|
68
|
+
// Todo: Translate
|
|
69
|
+
accessibilityLabel={'Previous'}
|
|
70
|
+
onPress={handleOnPrevious}
|
|
71
|
+
disabled={value === startDateYear}
|
|
72
|
+
/>
|
|
73
|
+
</View>
|
|
74
|
+
)}
|
|
75
|
+
{type && (
|
|
76
|
+
<TouchableRipple
|
|
77
|
+
disabled={disabled}
|
|
78
|
+
onPress={handlePressDropDown}
|
|
79
|
+
accessibilityRole="button"
|
|
80
|
+
accessibilityLabel={`${value}`}
|
|
81
|
+
style={datePickerHeaderItemStyles.buttonStyle}>
|
|
82
|
+
<View style={datePickerHeaderItemStyles.innerStyle}>
|
|
83
|
+
<Text style={datePickerHeaderItemStyles.labelStyle} selectable={false}>
|
|
84
|
+
{value}
|
|
85
|
+
</Text>
|
|
86
|
+
<IconButton
|
|
87
|
+
onPress={handlePressDropDown}
|
|
88
|
+
name={selecting && type === pickerType ? 'menu-up' : 'menu-down'}
|
|
89
|
+
size="sm"
|
|
90
|
+
disabled={disabled}
|
|
91
|
+
/>
|
|
92
|
+
</View>
|
|
93
|
+
</TouchableRipple>
|
|
94
|
+
)}
|
|
95
|
+
{!selecting && onNext && (
|
|
96
|
+
<View style={datePickerHeaderItemStyles.buttonWrapper}>
|
|
97
|
+
<IconButton
|
|
98
|
+
name="chevron-right"
|
|
99
|
+
size="md"
|
|
100
|
+
// Todo: Translate
|
|
101
|
+
accessibilityLabel={'Next'}
|
|
102
|
+
onPress={handleOnNext}
|
|
103
|
+
disabled={value === endDateYear}
|
|
104
|
+
/>
|
|
105
|
+
</View>
|
|
106
|
+
)}
|
|
107
|
+
</View>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export default memo(HeaderItem);
|