react-native-molecules 0.5.0-beta.3 → 0.5.0-beta.30
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 +2 -6
- package/components/Accordion/AccordionItem.tsx +16 -12
- package/components/Accordion/AccordionItemContent.tsx +6 -1
- package/components/Accordion/AccordionItemHeader.tsx +1 -1
- package/components/Accordion/utils.ts +6 -0
- package/components/ActivityIndicator/ActivityIndicator.tsx +6 -15
- package/components/Appbar/AppbarBase.tsx +18 -13
- package/components/Button/Button.tsx +211 -264
- package/components/Button/index.tsx +9 -3
- package/components/Button/types.ts +16 -2
- package/components/Button/utils.ts +230 -208
- package/components/Card/Card.tsx +1 -1
- package/components/Checkbox/Checkbox.tsx +125 -88
- package/components/Checkbox/CheckboxBase.ios.tsx +14 -23
- package/components/Checkbox/CheckboxBase.tsx +21 -137
- package/components/Checkbox/context.tsx +14 -0
- package/components/Checkbox/index.tsx +11 -4
- package/components/Checkbox/types.ts +63 -29
- package/components/Checkbox/utils.ts +25 -108
- package/components/Chip/Chip.tsx +41 -52
- package/components/Chip/utils.ts +3 -7
- package/components/DateField/DateField.tsx +111 -0
- package/components/DateField/index.tsx +6 -0
- package/components/{DatePickerInput/inputUtils.ts → DateField/useDateFieldState.ts} +19 -51
- package/components/DatePicker/DateCalendar.tsx +83 -0
- package/components/DatePicker/DatePickerActions.tsx +73 -0
- package/components/DatePicker/DatePickerModal.tsx +246 -0
- package/components/DatePicker/DatePickerPopover.tsx +79 -0
- package/components/DatePicker/DatePickerProvider.tsx +158 -0
- package/components/DatePicker/DatePickerTrigger.tsx +23 -0
- package/components/DatePicker/context.tsx +83 -0
- package/components/DatePicker/index.tsx +45 -0
- package/components/DatePicker/utils.ts +295 -0
- package/components/DatePickerInline/DatePickerDockedHeader.tsx +117 -0
- package/components/DatePickerInline/DatePickerInline.tsx +17 -16
- package/components/DatePickerInline/DatePickerInlineBase.tsx +11 -5
- package/components/DatePickerInline/DatePickerInlineHeader.tsx +50 -20
- package/components/DatePickerInline/Day.tsx +25 -1
- package/components/DatePickerInline/DayNames.tsx +13 -10
- package/components/DatePickerInline/DayRange.tsx +2 -4
- package/components/DatePickerInline/HeaderItem.tsx +44 -29
- package/components/DatePickerInline/Month.tsx +48 -67
- package/components/DatePickerInline/MonthPicker.tsx +80 -92
- package/components/DatePickerInline/Swiper.native.tsx +21 -4
- package/components/DatePickerInline/Swiper.tsx +169 -14
- package/components/DatePickerInline/SwiperUtils.ts +1 -1
- package/components/DatePickerInline/Week.tsx +6 -1
- package/components/DatePickerInline/YearPicker.tsx +220 -78
- package/components/DatePickerInline/dateUtils.tsx +18 -13
- package/components/DatePickerInline/store.tsx +27 -0
- package/components/DatePickerInline/types.ts +6 -2
- package/components/DatePickerInline/utils.ts +66 -29
- package/components/Divider/Divider.tsx +192 -0
- package/components/Divider/index.tsx +10 -0
- package/components/Drawer/Drawer.tsx +17 -6
- package/components/Drawer/DrawerItemGroup.tsx +3 -7
- package/components/ElementGroup/ElementGroup.tsx +1 -1
- package/components/FilePicker/FilePicker.tsx +48 -78
- package/components/FilePicker/index.tsx +2 -1
- package/components/FilePicker/utils.ts +9 -0
- package/components/HelperText/HelperText.tsx +0 -35
- package/components/Icon/iconFactory.tsx +5 -4
- package/components/Icon/index.tsx +1 -1
- package/components/Icon/types.ts +17 -6
- package/components/IconButton/IconButton.tsx +84 -84
- package/components/IconButton/index.tsx +1 -0
- package/components/IconButton/types.ts +10 -0
- package/components/IconButton/utils.ts +167 -33
- package/components/List/List.tsx +276 -0
- package/components/List/context.tsx +27 -0
- package/components/List/index.ts +8 -0
- package/components/List/types.ts +117 -0
- package/components/List/utils.ts +79 -0
- package/components/LoadingIndicator/LoadingIndicator.tsx +253 -0
- package/components/LoadingIndicator/LoadingIndicator.web.tsx +136 -0
- package/components/LoadingIndicator/index.tsx +13 -0
- package/components/LoadingIndicator/utils.ts +117 -0
- package/components/Menu/Menu.tsx +162 -39
- package/components/Menu/index.tsx +10 -7
- package/components/Menu/utils.ts +21 -70
- package/components/NavigationRail/NavigationRail.tsx +15 -9
- package/components/Popover/Popover.tsx +119 -145
- package/components/Popover/PopoverRoot.tsx +60 -0
- package/components/Popover/common.ts +54 -34
- package/components/Popover/index.ts +12 -1
- package/components/Popover/usePlatformMeasure.native.ts +90 -0
- package/components/Popover/usePlatformMeasure.ts +120 -0
- package/components/Popover/utils.ts +34 -0
- package/components/Portal/Portal.tsx +1 -2
- package/components/Radio/Radio.tsx +188 -0
- package/components/Radio/RadioBase.ios.tsx +69 -0
- package/components/Radio/RadioBase.tsx +136 -0
- package/components/Radio/context.tsx +23 -0
- package/components/Radio/index.tsx +20 -0
- package/components/Radio/types.ts +101 -0
- package/components/Radio/utils.ts +115 -0
- package/components/Rating/Rating.tsx +1 -1
- package/components/Select/Select.tsx +521 -785
- package/components/Select/context.tsx +81 -0
- package/components/Select/index.ts +26 -14
- package/components/Select/types.ts +65 -58
- package/components/Select/utils.ts +126 -0
- package/components/Slot/Slot.tsx +244 -0
- package/components/Slot/compose-refs.tsx +62 -0
- package/components/Slot/index.tsx +8 -0
- package/components/Surface/Surface.android.tsx +32 -7
- package/components/Surface/Surface.ios.tsx +34 -29
- package/components/Surface/Surface.tsx +31 -4
- package/components/Surface/utils.ts +44 -6
- package/components/Switch/Switch.ios.tsx +1 -1
- package/components/Switch/Switch.tsx +10 -3
- package/components/Tabs/TabItem.tsx +35 -58
- package/components/Tabs/TabLabel.tsx +5 -9
- package/components/Tabs/Tabs.tsx +156 -150
- package/components/Tabs/utils.ts +15 -2
- package/components/Text/textFactory.tsx +17 -5
- package/components/TextInput/TextInput.tsx +663 -579
- package/components/TextInput/index.tsx +19 -3
- package/components/TextInput/types.ts +77 -28
- package/components/TextInput/utils.ts +235 -145
- package/components/TimeField/TimeField.tsx +75 -0
- package/components/TimeField/index.tsx +6 -0
- package/components/TimeField/useTimeFieldState.ts +70 -0
- package/components/{TimePickerField/sanitizeTime.ts → TimeField/utils.ts} +77 -10
- package/components/TimePicker/AnalogClock.tsx +1 -1
- package/components/TimePicker/TimeInput.tsx +87 -42
- package/components/TimePicker/TimeInputs.tsx +138 -50
- package/components/TimePicker/TimePicker.tsx +74 -11
- package/components/TimePicker/TimePickerModal.tsx +186 -0
- package/components/TimePicker/context.tsx +17 -0
- package/components/TimePicker/index.tsx +15 -3
- package/components/TimePicker/utils.ts +93 -4
- package/components/Tooltip/Tooltip.tsx +42 -67
- package/components/Tooltip/TooltipContent.tsx +32 -5
- package/components/Tooltip/TooltipTrigger.tsx +20 -20
- package/components/Tooltip/index.tsx +1 -1
- package/components/TouchableRipple/TouchableRipple.native.tsx +83 -16
- package/components/TouchableRipple/TouchableRipple.tsx +150 -102
- package/components/TouchableRipple/rippleFromForegroundColor.ts +21 -0
- package/hocs/index.tsx +1 -1
- package/hocs/withKeyboardAccessibility.tsx +2 -3
- package/hocs/withPortal.tsx +1 -1
- package/hooks/index.tsx +2 -12
- package/hooks/useActionState.tsx +19 -8
- package/hooks/useContrastColor.ts +1 -2
- package/hooks/useFilePicker.tsx +7 -17
- package/hooks/useHandleNumberFormat.tsx +2 -2
- package/hooks/useMediaQuery.tsx +1 -2
- package/package.json +95 -111
- package/shortcuts-manager/ShortcutsManager/ShortcutsManager.tsx +6 -3
- package/shortcuts-manager/ShortcutsManager/utils.tsx +1 -1
- package/shortcuts-manager/useSetScopes/useSetScopes.tsx +1 -1
- package/shortcuts-manager/useShortcut/useShortcut.tsx +1 -1
- package/styles/shadow.ts +2 -1
- package/styles/themes/LightTheme.tsx +1 -1
- package/utils/DocumentPicker/documentPicker.ts +78 -27
- package/utils/DocumentPicker/types.ts +0 -1
- package/utils/extractSubcomponents.ts +89 -0
- package/utils/extractTextStyles.ts +1 -2
- package/utils/formatNumberWithMask/formatNumberWithMask.ts +2 -1
- package/utils/index.ts +0 -3
- package/utils/normalizeToNumberString/normalizeToNumberString.ts +1 -1
- package/components/DatePickerDocked/DatePickerDocked.tsx +0 -30
- package/components/DatePickerDocked/DatePickerDockedHeader.tsx +0 -129
- package/components/DatePickerDocked/index.tsx +0 -17
- package/components/DatePickerDocked/types.ts +0 -11
- package/components/DatePickerDocked/utils.ts +0 -157
- package/components/DatePickerInline/DatePickerContext.tsx +0 -21
- package/components/DatePickerInput/DatePickerInput.tsx +0 -139
- package/components/DatePickerInput/DatePickerInputModal.tsx +0 -48
- package/components/DatePickerInput/DatePickerInputWithoutModal.tsx +0 -77
- package/components/DatePickerInput/DateRangeInput.tsx +0 -88
- package/components/DatePickerInput/index.tsx +0 -10
- package/components/DatePickerInput/types.ts +0 -28
- package/components/DatePickerInput/utils.ts +0 -15
- package/components/DatePickerModal/AnimatedCrossView.tsx +0 -94
- package/components/DatePickerModal/CalendarEdit.tsx +0 -139
- package/components/DatePickerModal/DatePickerModal.tsx +0 -85
- package/components/DatePickerModal/DatePickerModalContent.tsx +0 -155
- package/components/DatePickerModal/DatePickerModalContentHeader.tsx +0 -213
- package/components/DatePickerModal/DatePickerModalHeader.tsx +0 -74
- package/components/DatePickerModal/DatePickerModalHeaderBackground.tsx +0 -13
- package/components/DatePickerModal/index.tsx +0 -16
- package/components/DatePickerModal/types.ts +0 -92
- package/components/DatePickerModal/utils.ts +0 -122
- package/components/DateTimePicker/DateTimePicker.tsx +0 -172
- package/components/DateTimePicker/index.tsx +0 -10
- package/components/DateTimePicker/utils.ts +0 -12
- package/components/HorizontalDivider/HorizontalDivider.tsx +0 -103
- package/components/HorizontalDivider/index.tsx +0 -9
- package/components/ListItem/ListItem.tsx +0 -136
- package/components/ListItem/ListItemDescription.tsx +0 -25
- package/components/ListItem/ListItemTitle.tsx +0 -25
- package/components/ListItem/index.tsx +0 -14
- package/components/ListItem/utils.ts +0 -115
- package/components/Menu/MenuDivider.tsx +0 -13
- package/components/Menu/MenuItem.tsx +0 -128
- package/components/Popover/Popover.native.tsx +0 -185
- package/components/RadioButton/RadioButton.tsx +0 -138
- package/components/RadioButton/RadioButtonAndroid.tsx +0 -188
- package/components/RadioButton/RadioButtonGroup.tsx +0 -98
- package/components/RadioButton/RadioButtonIOS.tsx +0 -106
- package/components/RadioButton/RadioButtonItem.tsx +0 -232
- package/components/RadioButton/index.ts +0 -22
- package/components/RadioButton/utils.ts +0 -165
- package/components/TimePickerField/TimePickerField.tsx +0 -152
- package/components/TimePickerField/index.tsx +0 -10
- package/components/TimePickerField/utils.ts +0 -94
- package/components/TimePickerModal/TimePickerModal.tsx +0 -115
- package/components/TimePickerModal/index.tsx +0 -10
- package/components/TimePickerModal/utils.ts +0 -47
- package/components/VerticalDivider/VerticalDivider.tsx +0 -100
- package/components/VerticalDivider/index.tsx +0 -9
- package/context-bridge/index.tsx +0 -87
- package/fast-context/index.tsx +0 -190
- package/hocs/typedMemo.tsx +0 -5
- package/hooks/useControlledValue.tsx +0 -68
- package/hooks/useLatest.tsx +0 -9
- package/hooks/useMergedRefs.ts +0 -14
- package/hooks/usePrevious.ts +0 -13
- package/hooks/useSearchable.tsx +0 -74
- package/hooks/useSubcomponents.tsx +0 -59
- package/hooks/useToggle.tsx +0 -24
- package/utils/color.ts +0 -22
- package/utils/compare/index.ts +0 -54
- package/utils/lodash.ts +0 -49
- package/utils/repository.ts +0 -53
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { add, format } from 'date-fns';
|
|
2
|
-
import { memo, useCallback, useMemo } from 'react';
|
|
3
|
-
import { View, type ViewStyle } from 'react-native';
|
|
4
|
-
|
|
5
|
-
import { useDatePickerStore } from '../DatePickerInline/DatePickerContext';
|
|
6
|
-
import type { DisableWeekDaysType } from '../DatePickerInline/dateUtils';
|
|
7
|
-
import DayNames from '../DatePickerInline/DayNames';
|
|
8
|
-
import HeaderItem from '../DatePickerInline/HeaderItem';
|
|
9
|
-
import { dayNamesHeight } from '../DatePickerInline/utils';
|
|
10
|
-
import { datePickerDockedHeaderStyles } from './utils';
|
|
11
|
-
|
|
12
|
-
const buttonContainerHeight = 56;
|
|
13
|
-
const buttonContainerMarginTop = 4;
|
|
14
|
-
const buttonContainerMarginBottom = 8;
|
|
15
|
-
|
|
16
|
-
export type CalendarHeaderProps = {
|
|
17
|
-
locale?: string;
|
|
18
|
-
disableWeekDays?: DisableWeekDaysType;
|
|
19
|
-
style?: ViewStyle;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
function DatePickerDockedHeader({
|
|
23
|
-
locale = 'en',
|
|
24
|
-
disableWeekDays,
|
|
25
|
-
style: styleProp,
|
|
26
|
-
}: CalendarHeaderProps) {
|
|
27
|
-
const [{ localDate, pickerType, startDateYear, endDateYear }, setStore] = useDatePickerStore(
|
|
28
|
-
state => ({
|
|
29
|
-
localDate: state.localDate,
|
|
30
|
-
pickerType: state.pickerType,
|
|
31
|
-
startDateYear: state.startDateYear,
|
|
32
|
-
endDateYear: state.endDateYear,
|
|
33
|
-
}),
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
// const componentStyles = useComponentStyles('DatePickerDocked_Header', styleProp);
|
|
37
|
-
|
|
38
|
-
const monthName = useMemo(() => {
|
|
39
|
-
return format(localDate, 'MMM');
|
|
40
|
-
}, [localDate]);
|
|
41
|
-
|
|
42
|
-
const { containerStyle, daysWrapperStyle } = useMemo(() => {
|
|
43
|
-
return {
|
|
44
|
-
containerStyle: [datePickerDockedHeaderStyles.datePickerHeader, styleProp],
|
|
45
|
-
daysWrapperStyle: datePickerDockedHeaderStyles.daysWrapperStyle,
|
|
46
|
-
};
|
|
47
|
-
}, [styleProp]);
|
|
48
|
-
|
|
49
|
-
const handlePressDropDown = useCallback(
|
|
50
|
-
(type: 'month' | 'year') => {
|
|
51
|
-
setStore(prev => ({
|
|
52
|
-
pickerType: prev.pickerType ? undefined : type,
|
|
53
|
-
}));
|
|
54
|
-
},
|
|
55
|
-
[setStore],
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
const isNotInRange = useCallback(
|
|
59
|
-
(date: Date) => {
|
|
60
|
-
const year = date.getFullYear();
|
|
61
|
-
const month = date.getMonth();
|
|
62
|
-
if (year < startDateYear || year > endDateYear || month > 11 || month < 0) {
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
},
|
|
67
|
-
[startDateYear, endDateYear],
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
const handleChange = useCallback(
|
|
71
|
-
(offset: number, type?: 'month' | 'year') => {
|
|
72
|
-
let newDate = localDate;
|
|
73
|
-
const prop = type === 'month' ? 'months' : 'years';
|
|
74
|
-
newDate = add(newDate, { [prop]: offset });
|
|
75
|
-
|
|
76
|
-
if (isNotInRange(newDate)) return;
|
|
77
|
-
|
|
78
|
-
setStore(() => ({
|
|
79
|
-
localDate: newDate,
|
|
80
|
-
}));
|
|
81
|
-
},
|
|
82
|
-
[isNotInRange, localDate, setStore],
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
const handleChangePrevious = useMemo(() => handleChange.bind(null, -1), [handleChange]);
|
|
86
|
-
const handleChangeNext = useMemo(() => handleChange.bind(null, 1), [handleChange]);
|
|
87
|
-
|
|
88
|
-
return (
|
|
89
|
-
<View>
|
|
90
|
-
<View style={containerStyle} pointerEvents={'box-none'}>
|
|
91
|
-
<HeaderItem
|
|
92
|
-
selecting={!!pickerType}
|
|
93
|
-
type="month"
|
|
94
|
-
value={monthName}
|
|
95
|
-
onNext={handleChangeNext}
|
|
96
|
-
onPrev={handleChangePrevious}
|
|
97
|
-
onPressDropdown={handlePressDropDown}
|
|
98
|
-
pickerType={pickerType}
|
|
99
|
-
/>
|
|
100
|
-
<HeaderItem
|
|
101
|
-
selecting={!!pickerType}
|
|
102
|
-
type="year"
|
|
103
|
-
value={localDate.getFullYear()}
|
|
104
|
-
onNext={handleChangeNext}
|
|
105
|
-
onPrev={handleChangePrevious}
|
|
106
|
-
onPressDropdown={handlePressDropDown}
|
|
107
|
-
pickerType={pickerType}
|
|
108
|
-
/>
|
|
109
|
-
</View>
|
|
110
|
-
<View style={daysWrapperStyle}>
|
|
111
|
-
<DayNames disableWeekDays={disableWeekDays} locale={locale} />
|
|
112
|
-
</View>
|
|
113
|
-
</View>
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export function getCalendarHeaderHeight(scrollMode: 'horizontal' | 'vertical') {
|
|
118
|
-
if (scrollMode === 'horizontal') {
|
|
119
|
-
return (
|
|
120
|
-
buttonContainerHeight +
|
|
121
|
-
buttonContainerMarginTop +
|
|
122
|
-
buttonContainerMarginBottom +
|
|
123
|
-
dayNamesHeight
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
return dayNamesHeight;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export default memo(DatePickerDockedHeader);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { getRegisteredComponentWithFallback } from '../../core';
|
|
2
|
-
import DatePickerDockedDefault from './DatePickerDocked';
|
|
3
|
-
|
|
4
|
-
export const DatePickerDocked = getRegisteredComponentWithFallback(
|
|
5
|
-
'DatePickerDocked',
|
|
6
|
-
DatePickerDockedDefault,
|
|
7
|
-
);
|
|
8
|
-
|
|
9
|
-
export type { DatePickerDockedProps } from './types';
|
|
10
|
-
export {
|
|
11
|
-
datePickerDockedHeaderStyles,
|
|
12
|
-
datePickerDockedMonthItemStyles,
|
|
13
|
-
datePickerDockedMonthStyles,
|
|
14
|
-
datePickerDockedStyles,
|
|
15
|
-
datePickerHeaderItemStyles,
|
|
16
|
-
datePickerMonthPickerStyles,
|
|
17
|
-
} from './utils';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ViewProps } from 'react-native';
|
|
2
|
-
|
|
3
|
-
import type { DatePickerSingleProps } from '../DatePickerInline';
|
|
4
|
-
|
|
5
|
-
export type DatePickerDockedProps = DatePickerSingleProps & {
|
|
6
|
-
triggerRef: any;
|
|
7
|
-
onToggle: () => void;
|
|
8
|
-
onClose: () => void;
|
|
9
|
-
isOpen: boolean;
|
|
10
|
-
popoverContentProps?: ViewProps;
|
|
11
|
-
};
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
|
|
3
|
-
import { getRegisteredComponentStylesWithFallback } from '../../core';
|
|
4
|
-
|
|
5
|
-
const datePickerDockedStylesDefault = StyleSheet.create(theme => ({
|
|
6
|
-
root: {
|
|
7
|
-
roundness: theme.shapes.corner.extraSmall,
|
|
8
|
-
headerBackgroundColor: theme.colors.surface,
|
|
9
|
-
} as any,
|
|
10
|
-
|
|
11
|
-
container: {
|
|
12
|
-
minHeight: 360,
|
|
13
|
-
minWidth: 360,
|
|
14
|
-
},
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
const datePickerDockedHeaderStylesDefault = StyleSheet.create(theme => ({
|
|
18
|
-
datePickerHeader: {
|
|
19
|
-
position: 'relative',
|
|
20
|
-
flexDirection: 'row',
|
|
21
|
-
alignItems: 'center',
|
|
22
|
-
justifyContent: 'space-evenly',
|
|
23
|
-
},
|
|
24
|
-
daysWrapperStyle: {
|
|
25
|
-
marginHorizontal: theme.spacings['3'],
|
|
26
|
-
},
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
const datePickerHeaderItemStylesDefault = StyleSheet.create(theme => ({
|
|
30
|
-
buttonContainer: {
|
|
31
|
-
height: 46,
|
|
32
|
-
width: '50%',
|
|
33
|
-
flexDirection: 'row',
|
|
34
|
-
alignItems: 'center',
|
|
35
|
-
},
|
|
36
|
-
buttonWrapper: {},
|
|
37
|
-
spacer: { flex: 1 },
|
|
38
|
-
labelStyle: {
|
|
39
|
-
...theme.typescale.bodyMedium,
|
|
40
|
-
opacity: 0.7,
|
|
41
|
-
},
|
|
42
|
-
buttonStyle: {
|
|
43
|
-
alignSelf: 'center',
|
|
44
|
-
borderRadius: theme.shapes.corner.extraSmall,
|
|
45
|
-
},
|
|
46
|
-
innerStyle: {
|
|
47
|
-
paddingLeft: theme.spacings['0'],
|
|
48
|
-
flexDirection: 'row',
|
|
49
|
-
alignItems: 'center',
|
|
50
|
-
borderRadius: theme.shapes.corner.extraSmall,
|
|
51
|
-
},
|
|
52
|
-
emtpyView: {
|
|
53
|
-
width: 30,
|
|
54
|
-
},
|
|
55
|
-
}));
|
|
56
|
-
|
|
57
|
-
const datePickerMonthPickerStylesDefault = StyleSheet.create(theme => ({
|
|
58
|
-
root: {
|
|
59
|
-
backgroundColor: theme.colors.surface,
|
|
60
|
-
},
|
|
61
|
-
month: {
|
|
62
|
-
flex: 1,
|
|
63
|
-
justifyContent: 'center',
|
|
64
|
-
alignItems: 'flex-start',
|
|
65
|
-
},
|
|
66
|
-
selectedMonth: { color: theme.colors.onSurface },
|
|
67
|
-
monthButton: {
|
|
68
|
-
width: '100%',
|
|
69
|
-
overflow: 'hidden',
|
|
70
|
-
},
|
|
71
|
-
monthInner: {
|
|
72
|
-
height: 46,
|
|
73
|
-
alignItems: 'center',
|
|
74
|
-
justifyContent: 'flex-start',
|
|
75
|
-
flexDirection: 'row',
|
|
76
|
-
},
|
|
77
|
-
selectedMonthInner: { backgroundColor: theme.colors.surfaceVariant },
|
|
78
|
-
monthLabel: {
|
|
79
|
-
fontSize: 16,
|
|
80
|
-
},
|
|
81
|
-
}));
|
|
82
|
-
|
|
83
|
-
const datePickerDockedMonthItemStylesDefault = StyleSheet.create(theme => ({
|
|
84
|
-
root: {
|
|
85
|
-
backgroundColor: theme.colors.surface,
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
monthButton: {
|
|
89
|
-
width: '100%',
|
|
90
|
-
overflow: 'hidden',
|
|
91
|
-
padding: theme.spacings['0'],
|
|
92
|
-
|
|
93
|
-
variants: {
|
|
94
|
-
state: {
|
|
95
|
-
selected: {
|
|
96
|
-
backgroundColor: theme.colors.surfaceVariant,
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
monthInner: {
|
|
102
|
-
height: 46,
|
|
103
|
-
alignItems: 'center',
|
|
104
|
-
justifyContent: 'flex-start',
|
|
105
|
-
flexDirection: 'row',
|
|
106
|
-
padding: theme.spacings['0'],
|
|
107
|
-
},
|
|
108
|
-
monthLabel: {
|
|
109
|
-
fontSize: 16,
|
|
110
|
-
|
|
111
|
-
variants: {
|
|
112
|
-
state: {
|
|
113
|
-
selected: {
|
|
114
|
-
color: theme.colors.onSurface,
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
}));
|
|
120
|
-
|
|
121
|
-
const datePickerDockedMonthStylesDefault = StyleSheet.create(theme => ({
|
|
122
|
-
dockedHeaderStyle: {
|
|
123
|
-
alignItems: 'flex-start',
|
|
124
|
-
marginLeft: theme.spacings['4'],
|
|
125
|
-
},
|
|
126
|
-
weekContainerStyle: {
|
|
127
|
-
marginHorizontal: theme.spacings['3'],
|
|
128
|
-
},
|
|
129
|
-
backDropStyle: {
|
|
130
|
-
backgroundColor: 'transparent',
|
|
131
|
-
},
|
|
132
|
-
}));
|
|
133
|
-
|
|
134
|
-
export const datePickerDockedStyles = getRegisteredComponentStylesWithFallback(
|
|
135
|
-
'DatePickerDocked',
|
|
136
|
-
datePickerDockedStylesDefault,
|
|
137
|
-
);
|
|
138
|
-
export const datePickerDockedHeaderStyles = getRegisteredComponentStylesWithFallback(
|
|
139
|
-
'DatePickerDocked_Header',
|
|
140
|
-
datePickerDockedHeaderStylesDefault,
|
|
141
|
-
);
|
|
142
|
-
export const datePickerHeaderItemStyles = getRegisteredComponentStylesWithFallback(
|
|
143
|
-
'DatePicker_HeaderItem',
|
|
144
|
-
datePickerHeaderItemStylesDefault,
|
|
145
|
-
);
|
|
146
|
-
export const datePickerMonthPickerStyles = getRegisteredComponentStylesWithFallback(
|
|
147
|
-
'DatePickerDocked_MonthPicker',
|
|
148
|
-
datePickerMonthPickerStylesDefault,
|
|
149
|
-
);
|
|
150
|
-
export const datePickerDockedMonthItemStyles = getRegisteredComponentStylesWithFallback(
|
|
151
|
-
'DatePickerDocked_MonthItem',
|
|
152
|
-
datePickerDockedMonthItemStylesDefault,
|
|
153
|
-
);
|
|
154
|
-
export const datePickerDockedMonthStyles = getRegisteredComponentStylesWithFallback(
|
|
155
|
-
'DatePickerDocked_Month',
|
|
156
|
-
datePickerDockedMonthStylesDefault,
|
|
157
|
-
);
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { createFastContext } from '../../fast-context';
|
|
2
|
-
|
|
3
|
-
export type Store = {
|
|
4
|
-
localDate: Date;
|
|
5
|
-
startDateYear: number;
|
|
6
|
-
endDateYear: number;
|
|
7
|
-
pickerType: 'month' | 'year' | undefined;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const defaultValue = {
|
|
11
|
-
localDate: new Date(),
|
|
12
|
-
startDateYear: 1800,
|
|
13
|
-
endDateYear: 2200,
|
|
14
|
-
pickerType: undefined,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const {
|
|
18
|
-
Provider,
|
|
19
|
-
useContext: useDatePickerStore,
|
|
20
|
-
useContextValue: useDatePickerStoreValue,
|
|
21
|
-
} = createFastContext<Store>();
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { forwardRef, memo, useCallback, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import { StyleSheet } from 'react-native';
|
|
3
|
-
|
|
4
|
-
import { useLatest, useToggle } from '../../hooks';
|
|
5
|
-
import { noop } from '../../utils/lodash';
|
|
6
|
-
import { DatePickerDocked } from '../DatePickerDocked';
|
|
7
|
-
import { IconButton } from '../IconButton';
|
|
8
|
-
import DatePickerInputModal from './DatePickerInputModal';
|
|
9
|
-
import DatePickerInputWithoutModal from './DatePickerInputWithoutModal';
|
|
10
|
-
import type { DatePickerInputProps } from './types';
|
|
11
|
-
|
|
12
|
-
function DatePickerInput(
|
|
13
|
-
{
|
|
14
|
-
withModal = true,
|
|
15
|
-
calendarIcon = 'calendar',
|
|
16
|
-
value,
|
|
17
|
-
locale,
|
|
18
|
-
inputMode,
|
|
19
|
-
validRange,
|
|
20
|
-
onChange = noop,
|
|
21
|
-
disabled = false,
|
|
22
|
-
pickerMode = 'modal',
|
|
23
|
-
startYear,
|
|
24
|
-
endYear,
|
|
25
|
-
dockedPopoverContentProps,
|
|
26
|
-
//locale = 'en',
|
|
27
|
-
...rest
|
|
28
|
-
}: DatePickerInputProps,
|
|
29
|
-
ref: any,
|
|
30
|
-
) {
|
|
31
|
-
const triggerRef = useRef(null);
|
|
32
|
-
const { state: isOpen, onToggle } = useToggle(false);
|
|
33
|
-
const [visible, setVisible] = useState<boolean>(false);
|
|
34
|
-
|
|
35
|
-
const onDismiss = useCallback(() => {
|
|
36
|
-
setVisible(false);
|
|
37
|
-
}, [setVisible]);
|
|
38
|
-
|
|
39
|
-
const onChangeRef = useLatest(onChange);
|
|
40
|
-
|
|
41
|
-
const onInnerConfirm = useCallback(
|
|
42
|
-
({ date }: any) => {
|
|
43
|
-
setVisible(false);
|
|
44
|
-
onChangeRef.current(date);
|
|
45
|
-
},
|
|
46
|
-
[setVisible, onChangeRef],
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
const onPressCalendarIcon = useCallback(() => {
|
|
50
|
-
if (pickerMode === 'docked') {
|
|
51
|
-
onToggle();
|
|
52
|
-
}
|
|
53
|
-
setVisible(true);
|
|
54
|
-
}, [pickerMode, onToggle]);
|
|
55
|
-
|
|
56
|
-
const renderers = useMemo(() => {
|
|
57
|
-
return {
|
|
58
|
-
modal: (
|
|
59
|
-
<DatePickerInputModal
|
|
60
|
-
date={value}
|
|
61
|
-
mode="single"
|
|
62
|
-
isOpen={visible}
|
|
63
|
-
onClose={onDismiss}
|
|
64
|
-
onConfirm={onInnerConfirm}
|
|
65
|
-
locale={locale}
|
|
66
|
-
validRange={validRange}
|
|
67
|
-
/>
|
|
68
|
-
),
|
|
69
|
-
docked: (
|
|
70
|
-
<DatePickerDocked
|
|
71
|
-
date={value}
|
|
72
|
-
locale={locale}
|
|
73
|
-
startYear={startYear}
|
|
74
|
-
endYear={endYear}
|
|
75
|
-
onChange={onInnerConfirm}
|
|
76
|
-
isOpen={isOpen}
|
|
77
|
-
onClose={onDismiss}
|
|
78
|
-
onToggle={onToggle}
|
|
79
|
-
triggerRef={triggerRef}
|
|
80
|
-
popoverContentProps={dockedPopoverContentProps}
|
|
81
|
-
/>
|
|
82
|
-
),
|
|
83
|
-
};
|
|
84
|
-
}, [
|
|
85
|
-
dockedPopoverContentProps,
|
|
86
|
-
endYear,
|
|
87
|
-
isOpen,
|
|
88
|
-
locale,
|
|
89
|
-
onDismiss,
|
|
90
|
-
onInnerConfirm,
|
|
91
|
-
onToggle,
|
|
92
|
-
startYear,
|
|
93
|
-
validRange,
|
|
94
|
-
value,
|
|
95
|
-
visible,
|
|
96
|
-
]);
|
|
97
|
-
|
|
98
|
-
const rightElement = useMemo(
|
|
99
|
-
() => (
|
|
100
|
-
<>
|
|
101
|
-
{withModal || pickerMode === 'docked' ? (
|
|
102
|
-
<>
|
|
103
|
-
<IconButton
|
|
104
|
-
ref={triggerRef}
|
|
105
|
-
style={styles.calendarButton}
|
|
106
|
-
name={calendarIcon}
|
|
107
|
-
onPress={onPressCalendarIcon}
|
|
108
|
-
disabled={disabled}
|
|
109
|
-
/>
|
|
110
|
-
{renderers[pickerMode]}
|
|
111
|
-
</>
|
|
112
|
-
) : null}
|
|
113
|
-
</>
|
|
114
|
-
),
|
|
115
|
-
[calendarIcon, disabled, onPressCalendarIcon, pickerMode, renderers, withModal],
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
return (
|
|
119
|
-
<DatePickerInputWithoutModal
|
|
120
|
-
ref={ref}
|
|
121
|
-
{...rest}
|
|
122
|
-
disabled={disabled}
|
|
123
|
-
value={value}
|
|
124
|
-
inputMode={inputMode}
|
|
125
|
-
validRange={validRange}
|
|
126
|
-
onChange={onChange}
|
|
127
|
-
// locale={locale}
|
|
128
|
-
inputButtons={rightElement}
|
|
129
|
-
/>
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const styles = StyleSheet.create({
|
|
134
|
-
calendarButton: {
|
|
135
|
-
marginRight: -4,
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
export default memo(forwardRef(DatePickerInput));
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { memo, useCallback, useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import type { DatePickerModalProps } from '../DatePickerModal';
|
|
4
|
-
import { DatePickerModal } from '../DatePickerModal/DatePickerModal';
|
|
5
|
-
|
|
6
|
-
const DatePickerInputModal = ({
|
|
7
|
-
date,
|
|
8
|
-
onConfirm: onConfirmProp,
|
|
9
|
-
onClose: onCloseProp,
|
|
10
|
-
...rest
|
|
11
|
-
}: DatePickerModalProps) => {
|
|
12
|
-
// want to control this by the input and only pass the value when onConfirm is clicked
|
|
13
|
-
const [value, onValueChange] = useState(date);
|
|
14
|
-
|
|
15
|
-
const onChange = useCallback(
|
|
16
|
-
(val: any) => {
|
|
17
|
-
onValueChange(val?.date);
|
|
18
|
-
},
|
|
19
|
-
[onValueChange],
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
const onConfirm = useCallback(() => {
|
|
23
|
-
onConfirmProp?.({ date: value } as any);
|
|
24
|
-
}, [onConfirmProp, value]);
|
|
25
|
-
|
|
26
|
-
const onClose = useCallback(() => {
|
|
27
|
-
onValueChange(date); // revert back before close it
|
|
28
|
-
|
|
29
|
-
onCloseProp?.();
|
|
30
|
-
}, [date, onCloseProp]);
|
|
31
|
-
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
onValueChange(date);
|
|
34
|
-
}, [date]);
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<DatePickerModal
|
|
38
|
-
{...rest}
|
|
39
|
-
onClose={onClose}
|
|
40
|
-
onConfirm={onConfirm}
|
|
41
|
-
date={value}
|
|
42
|
-
onChange={onChange}
|
|
43
|
-
mode="single"
|
|
44
|
-
/>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export default memo(DatePickerInputModal);
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { forwardRef, memo, useCallback, useImperativeHandle, useMemo, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { TextInputWithMask } from '../TextInputWithMask';
|
|
4
|
-
import useDateInput from './inputUtils';
|
|
5
|
-
import type { DatePickerInputWithoutModalProps } from './types';
|
|
6
|
-
import { datePickerInputStyles } from './utils';
|
|
7
|
-
|
|
8
|
-
function DatePickerInputWithoutModal(
|
|
9
|
-
{
|
|
10
|
-
label,
|
|
11
|
-
value,
|
|
12
|
-
onChange: onChangeProp,
|
|
13
|
-
// locale = 'en',
|
|
14
|
-
validRange,
|
|
15
|
-
inputMode,
|
|
16
|
-
inputButtons,
|
|
17
|
-
dateFormat = 'dd/MM/yyyy',
|
|
18
|
-
style,
|
|
19
|
-
onBlur: onBlurProp,
|
|
20
|
-
onFocus: onFocusProp,
|
|
21
|
-
...rest
|
|
22
|
-
}: DatePickerInputWithoutModalProps,
|
|
23
|
-
ref: any,
|
|
24
|
-
) {
|
|
25
|
-
const inputRef = useRef(null);
|
|
26
|
-
const isBlurredRef = useRef(true);
|
|
27
|
-
|
|
28
|
-
const onChange = useCallback(
|
|
29
|
-
(date: Date | null) => {
|
|
30
|
-
// because onChange was already trigger not need to trigger again on
|
|
31
|
-
if (!isBlurredRef.current) {
|
|
32
|
-
onChangeProp?.(date);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (!date && isBlurredRef.current) (inputRef.current as any)?.setDisplayValue('');
|
|
36
|
-
},
|
|
37
|
-
[onChangeProp],
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
const { formattedValue, onChangeText, onBlur, onFocus } = useDateInput({
|
|
41
|
-
// locale,
|
|
42
|
-
value,
|
|
43
|
-
validRange,
|
|
44
|
-
inputMode,
|
|
45
|
-
onChange,
|
|
46
|
-
dateFormat,
|
|
47
|
-
onBlur: onBlurProp,
|
|
48
|
-
onFocus: onFocusProp,
|
|
49
|
-
isBlurredRef,
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const inputStyle = useMemo(() => [datePickerInputStyles.root, style], [style]);
|
|
53
|
-
|
|
54
|
-
useImperativeHandle(ref, () => inputRef.current);
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<TextInputWithMask
|
|
58
|
-
placeholder={dateFormat}
|
|
59
|
-
style={inputStyle}
|
|
60
|
-
{...rest}
|
|
61
|
-
onBlur={onBlur}
|
|
62
|
-
onFocus={onFocus}
|
|
63
|
-
ref={inputRef}
|
|
64
|
-
label={label}
|
|
65
|
-
value={formattedValue}
|
|
66
|
-
keyboardType={'number-pad'}
|
|
67
|
-
mask={dateFormat}
|
|
68
|
-
onChangeText={onChangeText}
|
|
69
|
-
// keyboardAppearance={theme.dark ? 'dark' : 'default'}
|
|
70
|
-
// error={formattedValue ? !!error : false}
|
|
71
|
-
right={inputButtons}
|
|
72
|
-
// supportingText={formattedValue ? error || undefined : undefined}
|
|
73
|
-
/>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export default memo(forwardRef(DatePickerInputWithoutModal));
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { useCallback, useState } from 'react';
|
|
2
|
-
import { StyleSheet, View } from 'react-native';
|
|
3
|
-
|
|
4
|
-
import DatePickerModal from '../DatePickerModal/DatePickerModal';
|
|
5
|
-
import { IconButton } from '../IconButton';
|
|
6
|
-
import { Text } from '../Text';
|
|
7
|
-
|
|
8
|
-
// WORK IN PROGRESS
|
|
9
|
-
// PLEASE IGNORE THIS FILE
|
|
10
|
-
export default function DateRangeInput({
|
|
11
|
-
locale,
|
|
12
|
-
calendarIcon = 'calendar',
|
|
13
|
-
}: {
|
|
14
|
-
locale: string;
|
|
15
|
-
calendarIcon?: string;
|
|
16
|
-
}) {
|
|
17
|
-
const [visible, setVisible] = useState<boolean>(false);
|
|
18
|
-
const onDismiss = useCallback(() => {
|
|
19
|
-
setVisible(false);
|
|
20
|
-
}, [setVisible]);
|
|
21
|
-
const onConfirm = useCallback(
|
|
22
|
-
({ startDate, endDate }: { startDate: any; endDate: any }) => {
|
|
23
|
-
setVisible(false);
|
|
24
|
-
// eslint-disable-next-line no-console
|
|
25
|
-
console.log({ startDate, endDate });
|
|
26
|
-
},
|
|
27
|
-
[setVisible],
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<View style={styles.container}>
|
|
32
|
-
<View style={styles.textContainer}>
|
|
33
|
-
{/*<DatePickerInput*/}
|
|
34
|
-
{/* value={''}*/}
|
|
35
|
-
{/* keyboardType={'numeric'}*/}
|
|
36
|
-
{/* placeholder={'DD-MM-YYY'}*/}
|
|
37
|
-
{/* mask={'DD-MM-YYY'}*/}
|
|
38
|
-
{/* onChangeText={() => {}}*/}
|
|
39
|
-
{/*/>*/}
|
|
40
|
-
<Text>Van</Text>
|
|
41
|
-
</View>
|
|
42
|
-
<View>
|
|
43
|
-
<Text style={styles.text1}>to</Text>
|
|
44
|
-
<Text style={styles.text2} accessible={false}>
|
|
45
|
-
tot
|
|
46
|
-
</Text>
|
|
47
|
-
</View>
|
|
48
|
-
<View style={styles.textContainer}>
|
|
49
|
-
{/*<DatePickerInput*/}
|
|
50
|
-
{/* // value={''}*/}
|
|
51
|
-
{/* // keyboardType={'numeric'}*/}
|
|
52
|
-
{/* // placeholder={'DD-MM-YYY'}*/}
|
|
53
|
-
{/* // mask={'DD-MM-YYY'}*/}
|
|
54
|
-
{/* // onChangeText={() => {}}*/}
|
|
55
|
-
{/*/>*/}
|
|
56
|
-
<Text>Tot</Text>
|
|
57
|
-
</View>
|
|
58
|
-
<View>
|
|
59
|
-
<IconButton name={calendarIcon} onPress={() => setVisible(true)} />
|
|
60
|
-
<Text style={styles.text2} accessible={false}>
|
|
61
|
-
tot
|
|
62
|
-
</Text>
|
|
63
|
-
</View>
|
|
64
|
-
<DatePickerModal
|
|
65
|
-
locale={locale}
|
|
66
|
-
mode="range"
|
|
67
|
-
isOpen={visible}
|
|
68
|
-
onClose={onDismiss}
|
|
69
|
-
onConfirm={onConfirm}
|
|
70
|
-
startDate={undefined}
|
|
71
|
-
endDate={undefined}
|
|
72
|
-
/>
|
|
73
|
-
</View>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const styles = StyleSheet.create({
|
|
78
|
-
container: { flexDirection: 'row', alignItems: 'center' },
|
|
79
|
-
textContainer: { flex: 1 },
|
|
80
|
-
text1: {
|
|
81
|
-
fontSize: 16,
|
|
82
|
-
marginLeft: 12,
|
|
83
|
-
marginRight: 12,
|
|
84
|
-
},
|
|
85
|
-
text2: {
|
|
86
|
-
opacity: 0,
|
|
87
|
-
},
|
|
88
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { getRegisteredComponentWithFallback } from '../../core';
|
|
2
|
-
import DatePickerInputDefault from './DatePickerInput';
|
|
3
|
-
|
|
4
|
-
export const DatePickerInput = getRegisteredComponentWithFallback(
|
|
5
|
-
'DatePickerInput',
|
|
6
|
-
DatePickerInputDefault,
|
|
7
|
-
);
|
|
8
|
-
|
|
9
|
-
export type { DatePickerInputProps } from './types';
|
|
10
|
-
export { datePickerInputStyles } from './utils';
|