react-native-molecules 0.5.0-beta.15 → 0.5.0-beta.17
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/AccordionItem.tsx +1 -7
- package/components/DateField/DateField.tsx +110 -0
- package/components/DateField/index.tsx +6 -0
- package/components/{DatePickerInput/inputUtils.ts → DateField/useDateFieldState.ts} +17 -49
- package/components/DatePicker/DateCalendar.tsx +83 -0
- package/components/DatePicker/DatePickerActions.tsx +73 -0
- package/components/DatePicker/DatePickerModal.tsx +234 -0
- package/components/DatePicker/DatePickerPopover.tsx +79 -0
- package/components/DatePicker/DatePickerProvider.tsx +152 -0
- package/components/DatePicker/DatePickerTrigger.tsx +23 -0
- package/components/DatePicker/context.tsx +82 -0
- package/components/DatePicker/index.tsx +44 -0
- package/components/DatePicker/utils.ts +292 -0
- package/components/DatePickerInline/DatePickerContext.tsx +1 -0
- package/components/DatePickerInline/DatePickerDockedHeader.tsx +113 -0
- package/components/DatePickerInline/DatePickerInline.tsx +16 -15
- package/components/DatePickerInline/DatePickerInlineBase.tsx +7 -1
- package/components/DatePickerInline/Day.tsx +25 -1
- package/components/DatePickerInline/DayRange.tsx +2 -4
- package/components/DatePickerInline/HeaderItem.tsx +42 -27
- package/components/DatePickerInline/Month.tsx +45 -65
- package/components/DatePickerInline/MonthPicker.tsx +25 -41
- package/components/DatePickerInline/Swiper.native.tsx +21 -4
- package/components/DatePickerInline/Swiper.tsx +168 -13
- package/components/DatePickerInline/Week.tsx +6 -1
- package/components/DatePickerInline/YearPicker.tsx +206 -53
- package/components/DatePickerInline/dateUtils.tsx +17 -12
- package/components/DatePickerInline/types.ts +3 -0
- package/components/DatePickerInline/utils.ts +66 -29
- package/components/FilePicker/index.tsx +1 -1
- package/components/ListItem/ListItem.tsx +3 -1
- package/components/ListItem/utils.ts +1 -1
- package/components/LoadingIndicator/index.tsx +1 -1
- package/components/Popover/Popover.native.tsx +4 -25
- package/components/Popover/Popover.tsx +4 -26
- package/components/Popover/utils.ts +41 -0
- package/components/Select/Select.tsx +7 -8
- package/components/Select/context.tsx +72 -0
- package/components/Select/index.ts +1 -0
- package/components/Select/utils.ts +0 -71
- package/components/Slot/compose-refs.tsx +2 -0
- 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/TimePicker.tsx +53 -9
- 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 +50 -0
- package/hooks/useActionState.tsx +19 -8
- package/package.json +6 -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/DatePickerInput/DatePickerInput.tsx +0 -130
- package/components/DatePickerInput/DatePickerInputModal.tsx +0 -48
- package/components/DatePickerInput/DatePickerInputWithoutModal.tsx +0 -73
- package/components/DatePickerInput/DateRangeInput.tsx +0 -88
- package/components/DatePickerInput/index.tsx +0 -11
- package/components/DatePickerInput/types.ts +0 -26
- package/components/DatePickerInput/utils.ts +0 -24
- package/components/DatePickerModal/AnimatedCrossView.tsx +0 -94
- package/components/DatePickerModal/CalendarEdit.tsx +0 -140
- 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/TimePickerField/TimePickerField.tsx +0 -154
- package/components/TimePickerField/index.tsx +0 -10
- package/components/TimePickerField/utils.ts +0 -94
- package/components/TimePickerModal/TimePickerModal.tsx +0 -119
- package/components/TimePickerModal/index.tsx +0 -10
- package/components/TimePickerModal/utils.ts +0 -47
|
@@ -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,130 +0,0 @@
|
|
|
1
|
-
import { forwardRef, memo, useCallback, useMemo, useRef } 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 { TextInput } from '../TextInput';
|
|
9
|
-
import DatePickerInputModal from './DatePickerInputModal';
|
|
10
|
-
import DatePickerInputWithoutModal from './DatePickerInputWithoutModal';
|
|
11
|
-
import type { DatePickerInputProps } from './types';
|
|
12
|
-
import { DatePickerInputContext } from './utils';
|
|
13
|
-
|
|
14
|
-
function DatePickerInput(
|
|
15
|
-
{
|
|
16
|
-
withModal = true,
|
|
17
|
-
calendarIcon = 'calendar',
|
|
18
|
-
value,
|
|
19
|
-
locale,
|
|
20
|
-
inputMode,
|
|
21
|
-
validRange,
|
|
22
|
-
onChange = noop,
|
|
23
|
-
disabled = false,
|
|
24
|
-
pickerMode = 'modal',
|
|
25
|
-
startYear,
|
|
26
|
-
endYear,
|
|
27
|
-
dockedPopoverContentProps,
|
|
28
|
-
children,
|
|
29
|
-
//locale = 'en',
|
|
30
|
-
...rest
|
|
31
|
-
}: DatePickerInputProps,
|
|
32
|
-
ref: any,
|
|
33
|
-
) {
|
|
34
|
-
const triggerRef = useRef(null);
|
|
35
|
-
const { state: isOpen, onToggle, handleOpen, handleClose } = useToggle(false);
|
|
36
|
-
|
|
37
|
-
const onDismiss = useCallback(() => {
|
|
38
|
-
handleClose();
|
|
39
|
-
}, [handleClose]);
|
|
40
|
-
|
|
41
|
-
const onChangeRef = useLatest(onChange);
|
|
42
|
-
|
|
43
|
-
const onInnerConfirm = useCallback(
|
|
44
|
-
({ date }: any) => {
|
|
45
|
-
handleClose();
|
|
46
|
-
onChangeRef.current(date);
|
|
47
|
-
},
|
|
48
|
-
[handleClose, onChangeRef],
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
const onPressCalendarIcon = useCallback(() => {
|
|
52
|
-
if (pickerMode === 'docked') {
|
|
53
|
-
onToggle();
|
|
54
|
-
} else {
|
|
55
|
-
handleOpen();
|
|
56
|
-
}
|
|
57
|
-
}, [pickerMode, onToggle, handleOpen]);
|
|
58
|
-
|
|
59
|
-
const renderers = {
|
|
60
|
-
modal: (
|
|
61
|
-
<DatePickerInputModal
|
|
62
|
-
date={value}
|
|
63
|
-
mode="single"
|
|
64
|
-
isOpen={isOpen}
|
|
65
|
-
onClose={onDismiss}
|
|
66
|
-
onConfirm={onInnerConfirm}
|
|
67
|
-
locale={locale}
|
|
68
|
-
validRange={validRange}
|
|
69
|
-
/>
|
|
70
|
-
),
|
|
71
|
-
docked: (
|
|
72
|
-
<DatePickerDocked
|
|
73
|
-
date={value}
|
|
74
|
-
locale={locale}
|
|
75
|
-
startYear={startYear}
|
|
76
|
-
endYear={endYear}
|
|
77
|
-
onChange={onInnerConfirm}
|
|
78
|
-
isOpen={isOpen}
|
|
79
|
-
onClose={onDismiss}
|
|
80
|
-
onToggle={onToggle}
|
|
81
|
-
triggerRef={triggerRef}
|
|
82
|
-
popoverContentProps={dockedPopoverContentProps}
|
|
83
|
-
/>
|
|
84
|
-
),
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const contextValue = useMemo(
|
|
88
|
-
() => ({ isOpen, onPressTrigger: onPressCalendarIcon }),
|
|
89
|
-
[isOpen, onPressCalendarIcon],
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
return (
|
|
93
|
-
<DatePickerInputContext value={contextValue}>
|
|
94
|
-
<DatePickerInputWithoutModal
|
|
95
|
-
ref={ref}
|
|
96
|
-
{...rest}
|
|
97
|
-
disabled={disabled}
|
|
98
|
-
value={value}
|
|
99
|
-
inputMode={inputMode}
|
|
100
|
-
validRange={validRange}
|
|
101
|
-
onChange={onChange}
|
|
102
|
-
// locale={locale}
|
|
103
|
-
>
|
|
104
|
-
<TextInput.Right>
|
|
105
|
-
{withModal || pickerMode === 'docked' ? (
|
|
106
|
-
<>
|
|
107
|
-
<IconButton
|
|
108
|
-
ref={triggerRef}
|
|
109
|
-
style={styles.calendarButton}
|
|
110
|
-
name={calendarIcon}
|
|
111
|
-
onPress={onPressCalendarIcon}
|
|
112
|
-
disabled={disabled}
|
|
113
|
-
/>
|
|
114
|
-
</>
|
|
115
|
-
) : null}
|
|
116
|
-
</TextInput.Right>
|
|
117
|
-
{children}
|
|
118
|
-
{renderers[pickerMode]}
|
|
119
|
-
</DatePickerInputWithoutModal>
|
|
120
|
-
</DatePickerInputContext>
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const styles = StyleSheet.create({
|
|
125
|
-
calendarButton: {
|
|
126
|
-
marginRight: -4,
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
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,73 +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
|
-
value,
|
|
11
|
-
onChange: onChangeProp,
|
|
12
|
-
// locale = 'en',
|
|
13
|
-
validRange,
|
|
14
|
-
inputMode,
|
|
15
|
-
dateFormat = 'dd/MM/yyyy',
|
|
16
|
-
style,
|
|
17
|
-
onBlur: onBlurProp,
|
|
18
|
-
onFocus: onFocusProp,
|
|
19
|
-
...rest
|
|
20
|
-
}: DatePickerInputWithoutModalProps,
|
|
21
|
-
ref: any,
|
|
22
|
-
) {
|
|
23
|
-
const inputRef = useRef(null);
|
|
24
|
-
const isBlurredRef = useRef(true);
|
|
25
|
-
|
|
26
|
-
const onChange = useCallback(
|
|
27
|
-
(date: Date | null) => {
|
|
28
|
-
// because onChange was already trigger not need to trigger again on
|
|
29
|
-
if (!isBlurredRef.current) {
|
|
30
|
-
onChangeProp?.(date);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (!date && isBlurredRef.current) (inputRef.current as any)?.setDisplayValue('');
|
|
34
|
-
},
|
|
35
|
-
[onChangeProp],
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const { formattedValue, onChangeText, onBlur, onFocus } = useDateInput({
|
|
39
|
-
// locale,
|
|
40
|
-
value,
|
|
41
|
-
validRange,
|
|
42
|
-
inputMode,
|
|
43
|
-
onChange,
|
|
44
|
-
dateFormat,
|
|
45
|
-
onBlur: onBlurProp,
|
|
46
|
-
onFocus: onFocusProp,
|
|
47
|
-
isBlurredRef,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const inputStyle = useMemo(() => [datePickerInputStyles.root, style], [style]);
|
|
51
|
-
|
|
52
|
-
useImperativeHandle(ref, () => inputRef.current);
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<TextInputWithMask
|
|
56
|
-
placeholder={dateFormat}
|
|
57
|
-
style={inputStyle}
|
|
58
|
-
{...rest}
|
|
59
|
-
onBlur={onBlur}
|
|
60
|
-
onFocus={onFocus}
|
|
61
|
-
ref={inputRef}
|
|
62
|
-
value={formattedValue}
|
|
63
|
-
keyboardType={'number-pad'}
|
|
64
|
-
mask={dateFormat}
|
|
65
|
-
onChangeText={onChangeText}
|
|
66
|
-
// keyboardAppearance={theme.dark ? 'dark' : 'default'}
|
|
67
|
-
// error={formattedValue ? !!error : false}
|
|
68
|
-
// supportingText={formattedValue ? error || undefined : undefined}
|
|
69
|
-
/>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
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,11 +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 { DatePickerInputContext, datePickerInputStyles } from './utils';
|
|
11
|
-
export type { DatePickerInputContextType } from './utils';
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { ViewProps } from 'react-native';
|
|
2
|
-
|
|
3
|
-
import type { ValidRangeType } from '../DatePickerInline';
|
|
4
|
-
import type { TextInputProps } from '../TextInput';
|
|
5
|
-
|
|
6
|
-
export interface DatePickerInputProps
|
|
7
|
-
extends Omit<TextInputProps, 'value' | 'onChange' | 'onChangeText' | 'inputMode'> {
|
|
8
|
-
inputMode: 'start' | 'end';
|
|
9
|
-
locale?: string;
|
|
10
|
-
onChange?: (date: Date | null) => void;
|
|
11
|
-
value?: Date | null;
|
|
12
|
-
validRange?: ValidRangeType | undefined;
|
|
13
|
-
withModal?: boolean;
|
|
14
|
-
calendarIcon?: string;
|
|
15
|
-
/**
|
|
16
|
-
* date format of the input
|
|
17
|
-
* should be date-fns accepted format
|
|
18
|
-
* We currently only accept the variations of dd MM yyyy
|
|
19
|
-
* */
|
|
20
|
-
dateFormat?: string;
|
|
21
|
-
pickerMode?: 'docked' | 'modal';
|
|
22
|
-
startYear?: number;
|
|
23
|
-
endYear?: number;
|
|
24
|
-
dockedPopoverContentProps?: ViewProps;
|
|
25
|
-
}
|
|
26
|
-
export interface DatePickerInputWithoutModalProps extends Omit<DatePickerInputProps, 'withModal'> {}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { createContext } from 'react';
|
|
2
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
3
|
-
|
|
4
|
-
import { getRegisteredComponentStylesWithFallback } from '../../core';
|
|
5
|
-
|
|
6
|
-
export type DatePickerInputContextType = {
|
|
7
|
-
onPressTrigger: () => void;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const DatePickerInputContext = createContext<DatePickerInputContextType>({
|
|
11
|
-
onPressTrigger: () => {},
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const datePickerInputStylesDefault = StyleSheet.create({
|
|
15
|
-
root: {
|
|
16
|
-
minWidth: 150,
|
|
17
|
-
justifyContent: 'center',
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
export const datePickerInputStyles = getRegisteredComponentStylesWithFallback(
|
|
22
|
-
'DatePickerInput',
|
|
23
|
-
datePickerInputStylesDefault,
|
|
24
|
-
);
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { useEffect, useMemo, useRef } from 'react';
|
|
2
|
-
import { Animated, View } from 'react-native';
|
|
3
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
-
|
|
5
|
-
export default function AnimatedCrossView({
|
|
6
|
-
// visible,
|
|
7
|
-
collapsed,
|
|
8
|
-
calendar,
|
|
9
|
-
calendarEdit,
|
|
10
|
-
}: {
|
|
11
|
-
calendar: any;
|
|
12
|
-
calendarEdit: any;
|
|
13
|
-
// visible: boolean
|
|
14
|
-
collapsed: boolean;
|
|
15
|
-
}) {
|
|
16
|
-
const calendarOpacity = useRef<Animated.Value>(new Animated.Value(collapsed ? 1 : 0));
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
// if (visible) {
|
|
19
|
-
Animated.timing(calendarOpacity.current, {
|
|
20
|
-
toValue: collapsed ? 1 : 0,
|
|
21
|
-
duration: 250,
|
|
22
|
-
useNativeDriver: true,
|
|
23
|
-
}).start();
|
|
24
|
-
// }
|
|
25
|
-
}, [collapsed]);
|
|
26
|
-
|
|
27
|
-
const { calendarStyle, calendarEditStyle } = useMemo(() => {
|
|
28
|
-
return {
|
|
29
|
-
calendarStyle: [
|
|
30
|
-
styles.calendar,
|
|
31
|
-
{
|
|
32
|
-
opacity: calendarOpacity.current,
|
|
33
|
-
transform: [
|
|
34
|
-
{
|
|
35
|
-
scaleY: calendarOpacity.current.interpolate({
|
|
36
|
-
inputRange: [0, 1],
|
|
37
|
-
outputRange: [0.85, 1],
|
|
38
|
-
}),
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
scaleX: calendarOpacity.current.interpolate({
|
|
42
|
-
inputRange: [0, 1],
|
|
43
|
-
outputRange: [0.95, 1],
|
|
44
|
-
}),
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
calendarEditStyle: [
|
|
50
|
-
styles.calendarEdit,
|
|
51
|
-
{
|
|
52
|
-
opacity: calendarOpacity.current.interpolate({
|
|
53
|
-
inputRange: [0, 1],
|
|
54
|
-
outputRange: [1, 0],
|
|
55
|
-
}),
|
|
56
|
-
transform: [
|
|
57
|
-
{
|
|
58
|
-
scale: calendarOpacity.current.interpolate({
|
|
59
|
-
inputRange: [0, 1],
|
|
60
|
-
outputRange: [1, 0.95],
|
|
61
|
-
}),
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
};
|
|
67
|
-
}, []);
|
|
68
|
-
|
|
69
|
-
// TODO Create AnimatedCrossView Component
|
|
70
|
-
return (
|
|
71
|
-
<View style={styles.root}>
|
|
72
|
-
<Animated.View pointerEvents={collapsed ? 'auto' : 'none'} style={calendarStyle}>
|
|
73
|
-
{calendar}
|
|
74
|
-
</Animated.View>
|
|
75
|
-
<Animated.View pointerEvents={collapsed ? 'none' : 'auto'} style={calendarEditStyle}>
|
|
76
|
-
{calendarEdit}
|
|
77
|
-
</Animated.View>
|
|
78
|
-
</View>
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const styles = StyleSheet.create(theme => ({
|
|
83
|
-
root: { flex: 1 },
|
|
84
|
-
calendarEdit: {
|
|
85
|
-
position: 'absolute',
|
|
86
|
-
|
|
87
|
-
left: 0,
|
|
88
|
-
right: 0,
|
|
89
|
-
backgroundColor: theme.colors.surface,
|
|
90
|
-
},
|
|
91
|
-
calendar: {
|
|
92
|
-
flex: 1,
|
|
93
|
-
},
|
|
94
|
-
}));
|