react-native-molecules 0.5.0-beta.2 → 0.5.0-beta.20
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/README.md +1 -1
- 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 +209 -264
- package/components/Button/index.tsx +9 -3
- package/components/Button/types.ts +16 -2
- package/components/Button/utils.ts +230 -208
- package/components/Checkbox/CheckboxBase.tsx +23 -128
- package/components/Checkbox/utils.ts +0 -25
- package/components/Chip/Chip.tsx +40 -52
- package/components/Chip/utils.ts +3 -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 +293 -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/Drawer/Drawer.tsx +17 -6
- package/components/ElementGroup/ElementGroup.tsx +16 -14
- 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 +3 -3
- package/components/Icon/index.tsx +1 -1
- package/components/Icon/types.ts +17 -6
- package/components/IconButton/IconButton.tsx +42 -57
- package/components/IconButton/utils.ts +142 -33
- package/components/ListItem/ListItem.tsx +3 -1
- package/components/ListItem/utils.ts +1 -1
- 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 +3 -18
- package/components/NavigationRail/NavigationRail.tsx +15 -9
- package/components/Popover/Popover.tsx +122 -145
- package/components/Popover/PopoverRoot.tsx +74 -0
- package/components/Popover/common.ts +50 -34
- package/components/Popover/index.ts +18 -1
- package/components/Popover/usePlatformMeasure.native.ts +90 -0
- package/components/Popover/usePlatformMeasure.ts +118 -0
- package/components/Popover/utils.ts +34 -0
- package/components/Select/Select.tsx +368 -507
- package/components/Select/context.tsx +72 -0
- package/components/Select/index.ts +8 -14
- package/components/Select/types.ts +2 -4
- package/components/Select/utils.ts +144 -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 +34 -8
- package/components/Surface/Surface.ios.tsx +36 -29
- package/components/Surface/Surface.tsx +31 -4
- package/components/Surface/utils.ts +44 -30
- package/components/Switch/Switch.tsx +8 -2
- package/components/Tabs/TabItem.tsx +35 -58
- package/components/Tabs/TabLabel.tsx +5 -9
- package/components/Tabs/Tabs.tsx +154 -148
- package/components/Tabs/utils.ts +15 -2
- package/components/TextInput/TextInput.tsx +658 -575
- package/components/TextInput/index.tsx +19 -3
- package/components/TextInput/types.ts +76 -27
- package/components/TextInput/utils.ts +225 -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/TimeInput.tsx +87 -37
- package/components/TimePicker/TimeInputs.tsx +137 -49
- package/components/TimePicker/TimePicker.tsx +73 -10
- 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 -0
- 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 +50 -14
- package/components/TouchableRipple/TouchableRipple.tsx +137 -47
- package/hocs/withPortal.tsx +1 -1
- package/hooks/index.tsx +0 -6
- package/hooks/useActionState.tsx +19 -8
- package/hooks/useControlledValue.tsx +20 -4
- package/hooks/useFilePicker.tsx +6 -16
- package/hooks/useWhatHasUpdated.tsx +48 -0
- package/package.json +17 -13
- package/shortcuts-manager/ShortcutsManager/ShortcutsManager.tsx +5 -2
- 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/extractPropertiesFromStyles.ts +25 -0
- package/utils/extractSubcomponents.ts +89 -0
- package/utils/lodash.ts +77 -5
- 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 -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/Popover/Popover.native.tsx +0 -185
- 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/hooks/useSearchable.tsx +0 -74
- package/hooks/useSubcomponents.tsx +0 -59
|
@@ -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';
|
|
@@ -1,28 +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'> {
|
|
27
|
-
inputButtons?: any;
|
|
28
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
|
|
3
|
-
import { getRegisteredComponentStylesWithFallback } from '../../core';
|
|
4
|
-
|
|
5
|
-
const datePickerInputStylesDefault = StyleSheet.create({
|
|
6
|
-
root: {
|
|
7
|
-
minWidth: 150,
|
|
8
|
-
justifyContent: 'center',
|
|
9
|
-
},
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
export const datePickerInputStyles = getRegisteredComponentStylesWithFallback(
|
|
13
|
-
'DatePickerInput',
|
|
14
|
-
datePickerInputStylesDefault,
|
|
15
|
-
);
|
|
@@ -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
|
-
}));
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { memo, useCallback, useEffect, useRef } from 'react';
|
|
2
|
-
import { Keyboard, TextInput as TextInputNative, View } from 'react-native';
|
|
3
|
-
|
|
4
|
-
import type { ModeType, ValidRangeType } from '../DatePickerInline';
|
|
5
|
-
import DatePickerInputWithoutModal from '../DatePickerInput/DatePickerInputWithoutModal';
|
|
6
|
-
import type { LocalState, LocalStateRange, LocalStateSingle } from './types';
|
|
7
|
-
import { datePickerModalEditStyles } from './utils';
|
|
8
|
-
|
|
9
|
-
type Props = {
|
|
10
|
-
mode: ModeType;
|
|
11
|
-
label?: string;
|
|
12
|
-
startLabel?: string;
|
|
13
|
-
endLabel?: string;
|
|
14
|
-
state: LocalState;
|
|
15
|
-
collapsed: boolean;
|
|
16
|
-
onChange: (s: LocalState) => any;
|
|
17
|
-
validRange: ValidRangeType | undefined;
|
|
18
|
-
// locale: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
function CalendarEdit({
|
|
22
|
-
mode,
|
|
23
|
-
state,
|
|
24
|
-
label = '',
|
|
25
|
-
startLabel = 'Start',
|
|
26
|
-
endLabel = 'End',
|
|
27
|
-
collapsed,
|
|
28
|
-
onChange,
|
|
29
|
-
validRange,
|
|
30
|
-
}: // locale,
|
|
31
|
-
Props) {
|
|
32
|
-
const dateInput = useRef<TextInputNative | null>(null);
|
|
33
|
-
const startInput = useRef<TextInputNative | null>(null);
|
|
34
|
-
const endInput = useRef<TextInputNative | null>(null);
|
|
35
|
-
|
|
36
|
-
// when switching views focus, or un-focus text input
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
// hide open keyboard
|
|
39
|
-
if (collapsed) {
|
|
40
|
-
Keyboard.dismiss();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const inputsToFocus = [dateInput.current, startInput.current].filter(
|
|
44
|
-
n => n,
|
|
45
|
-
) as TextInputNative[];
|
|
46
|
-
|
|
47
|
-
const inputsToBlur = [dateInput.current, startInput.current, endInput.current].filter(
|
|
48
|
-
n => n,
|
|
49
|
-
) as TextInputNative[];
|
|
50
|
-
|
|
51
|
-
if (collapsed) {
|
|
52
|
-
inputsToBlur.forEach(ip => ip.blur());
|
|
53
|
-
} else {
|
|
54
|
-
inputsToFocus.forEach(ip => ip.focus());
|
|
55
|
-
}
|
|
56
|
-
}, [mode, startInput, endInput, dateInput, collapsed]);
|
|
57
|
-
|
|
58
|
-
const onSubmitStartInput = useCallback(() => {
|
|
59
|
-
if (endInput.current) {
|
|
60
|
-
endInput.current.focus();
|
|
61
|
-
}
|
|
62
|
-
}, [endInput]);
|
|
63
|
-
|
|
64
|
-
const onSubmitEndInput = useCallback(() => {
|
|
65
|
-
// TODO: close modal and persist range
|
|
66
|
-
}, []);
|
|
67
|
-
|
|
68
|
-
const onSubmitInput = useCallback(() => {
|
|
69
|
-
// TODO: close modal and persist range
|
|
70
|
-
}, []);
|
|
71
|
-
|
|
72
|
-
const onSingleInputChange = useCallback(
|
|
73
|
-
(date: Date | null) => onChange({ ...state, date }),
|
|
74
|
-
[onChange, state],
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
const onStartDateChange = useCallback(
|
|
78
|
-
(startDate: Date | null) => onChange({ ...state, startDate }),
|
|
79
|
-
[onChange, state],
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
const onEndDateChange = useCallback(
|
|
83
|
-
(endDate: Date | null) => onChange({ ...state, endDate }),
|
|
84
|
-
[onChange, state],
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<View style={datePickerModalEditStyles.container}>
|
|
89
|
-
<>
|
|
90
|
-
{mode === 'single' ? (
|
|
91
|
-
<DatePickerInputWithoutModal
|
|
92
|
-
inputMode="start"
|
|
93
|
-
ref={dateInput}
|
|
94
|
-
label={label}
|
|
95
|
-
value={(state as LocalStateSingle).date}
|
|
96
|
-
onChange={onSingleInputChange}
|
|
97
|
-
onSubmitEditing={onSubmitInput}
|
|
98
|
-
validRange={validRange}
|
|
99
|
-
// locale={locale}
|
|
100
|
-
autoComplete={'off'}
|
|
101
|
-
/>
|
|
102
|
-
) : null}
|
|
103
|
-
</>
|
|
104
|
-
|
|
105
|
-
<>
|
|
106
|
-
{mode === 'range' ? (
|
|
107
|
-
<View style={datePickerModalEditStyles.inner}>
|
|
108
|
-
<DatePickerInputWithoutModal
|
|
109
|
-
inputMode="start"
|
|
110
|
-
ref={startInput}
|
|
111
|
-
label={startLabel}
|
|
112
|
-
value={(state as LocalStateRange).startDate}
|
|
113
|
-
onChange={onStartDateChange}
|
|
114
|
-
returnKeyType={'next'}
|
|
115
|
-
onSubmitEditing={onSubmitStartInput}
|
|
116
|
-
validRange={validRange}
|
|
117
|
-
// locale={locale}
|
|
118
|
-
autoComplete={'off'}
|
|
119
|
-
/>
|
|
120
|
-
<View style={datePickerModalEditStyles.separator} />
|
|
121
|
-
<DatePickerInputWithoutModal
|
|
122
|
-
inputMode="end"
|
|
123
|
-
ref={endInput}
|
|
124
|
-
label={endLabel}
|
|
125
|
-
value={(state as LocalStateRange).endDate}
|
|
126
|
-
onChange={onEndDateChange}
|
|
127
|
-
onSubmitEditing={onSubmitEndInput}
|
|
128
|
-
validRange={validRange}
|
|
129
|
-
// locale={locale}
|
|
130
|
-
autoComplete="off"
|
|
131
|
-
/>
|
|
132
|
-
</View>
|
|
133
|
-
) : null}
|
|
134
|
-
</>
|
|
135
|
-
</View>
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export default memo(CalendarEdit);
|