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,119 +0,0 @@
|
|
|
1
|
-
import { memo, useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import { KeyboardAvoidingView, Platform, View } from 'react-native';
|
|
3
|
-
|
|
4
|
-
import { format } from '../../utils/date-fns';
|
|
5
|
-
import { Button } from '../Button';
|
|
6
|
-
import { IconButton } from '../IconButton';
|
|
7
|
-
import { Modal, type ModalProps } from '../Modal';
|
|
8
|
-
import { Portal } from '../Portal';
|
|
9
|
-
import { Text } from '../Text';
|
|
10
|
-
import TimePicker from '../TimePicker/TimePicker';
|
|
11
|
-
import {
|
|
12
|
-
clockTypes,
|
|
13
|
-
getTimeInputTypeIcon,
|
|
14
|
-
inputTypes,
|
|
15
|
-
type PossibleClockTypes,
|
|
16
|
-
type PossibleInputTypes,
|
|
17
|
-
reverseInputTypes,
|
|
18
|
-
} from '../TimePicker/timeUtils';
|
|
19
|
-
import { styles } from './utils';
|
|
20
|
-
|
|
21
|
-
export type Props = Omit<ModalProps, 'children'> & {
|
|
22
|
-
is24Hour?: boolean;
|
|
23
|
-
label?: string;
|
|
24
|
-
uppercase?: boolean;
|
|
25
|
-
cancelLabel?: string;
|
|
26
|
-
confirmLabel?: string;
|
|
27
|
-
time?: string;
|
|
28
|
-
onConfirm: (time: string) => any;
|
|
29
|
-
keyboardIcon?: string;
|
|
30
|
-
clockIcon?: string;
|
|
31
|
-
isLandscape?: boolean;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export function TimePickerModal({
|
|
35
|
-
isOpen,
|
|
36
|
-
onClose,
|
|
37
|
-
onConfirm: onConfirmProp,
|
|
38
|
-
time: timeProp,
|
|
39
|
-
label = 'Select time',
|
|
40
|
-
uppercase = false,
|
|
41
|
-
cancelLabel = 'Cancel',
|
|
42
|
-
confirmLabel = 'Ok',
|
|
43
|
-
is24Hour,
|
|
44
|
-
keyboardIcon = 'keyboard-outline',
|
|
45
|
-
clockIcon = 'clock-outline',
|
|
46
|
-
isLandscape = false,
|
|
47
|
-
style,
|
|
48
|
-
...rest
|
|
49
|
-
}: Props) {
|
|
50
|
-
const [inputType, setInputType] = useState<PossibleInputTypes>(inputTypes.picker);
|
|
51
|
-
const [focused, setFocused] = useState<PossibleClockTypes>(clockTypes.hours);
|
|
52
|
-
const [time, setTime] = useState(() => timeProp || format(new Date(), 'HH:mm'));
|
|
53
|
-
|
|
54
|
-
const modelStyle = useMemo(() => [styles.modalContent, style], [style]);
|
|
55
|
-
|
|
56
|
-
const onFocusInput = useCallback((type: PossibleClockTypes) => setFocused(type), []);
|
|
57
|
-
|
|
58
|
-
const onChange = useCallback(
|
|
59
|
-
(params: { focused?: PossibleClockTypes | undefined; time: string }) => {
|
|
60
|
-
if (params.focused) {
|
|
61
|
-
setFocused(params.focused);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
setTime(params.time);
|
|
65
|
-
},
|
|
66
|
-
[setFocused, setTime],
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
const onConfirm = useCallback(() => onConfirmProp(time), [onConfirmProp, time]);
|
|
70
|
-
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
setTime(timeProp || format(new Date(), 'HH:mm'));
|
|
73
|
-
}, [timeProp]);
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<Portal>
|
|
77
|
-
<Modal {...rest} isOpen={isOpen} style={modelStyle} onClose={onClose}>
|
|
78
|
-
<KeyboardAvoidingView
|
|
79
|
-
style={styles.keyboardView}
|
|
80
|
-
behavior={Platform.OS === 'ios' ? 'padding' : undefined}>
|
|
81
|
-
<View style={styles.labelContainer}>
|
|
82
|
-
<Text style={styles.label}>{uppercase ? label.toUpperCase() : label}</Text>
|
|
83
|
-
</View>
|
|
84
|
-
<View style={styles.timePickerContainer}>
|
|
85
|
-
<TimePicker
|
|
86
|
-
is24Hour={is24Hour}
|
|
87
|
-
inputType={inputType}
|
|
88
|
-
focused={focused}
|
|
89
|
-
time={time}
|
|
90
|
-
onTimeChange={onChange}
|
|
91
|
-
onFocusInput={onFocusInput}
|
|
92
|
-
isLandscape={isLandscape}
|
|
93
|
-
/>
|
|
94
|
-
</View>
|
|
95
|
-
<View style={styles.footer}>
|
|
96
|
-
<IconButton
|
|
97
|
-
name={getTimeInputTypeIcon(inputType, {
|
|
98
|
-
keyboard: keyboardIcon,
|
|
99
|
-
picker: clockIcon,
|
|
100
|
-
})}
|
|
101
|
-
onPress={() => setInputType(reverseInputTypes[inputType])}
|
|
102
|
-
style={styles.inputTypeToggle}
|
|
103
|
-
accessibilityLabel="toggle keyboard"
|
|
104
|
-
/>
|
|
105
|
-
<View style={styles.fill} />
|
|
106
|
-
<Button onPress={onClose}>
|
|
107
|
-
<Button.Text>{cancelLabel}</Button.Text>
|
|
108
|
-
</Button>
|
|
109
|
-
<Button onPress={onConfirm}>
|
|
110
|
-
<Button.Text>{confirmLabel}</Button.Text>
|
|
111
|
-
</Button>
|
|
112
|
-
</View>
|
|
113
|
-
</KeyboardAvoidingView>
|
|
114
|
-
</Modal>
|
|
115
|
-
</Portal>
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export default memo(TimePickerModal);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { getRegisteredComponentWithFallback } from '../../core';
|
|
2
|
-
import TimePickerModalDefault from './TimePickerModal';
|
|
3
|
-
|
|
4
|
-
export const TimePickerModal = getRegisteredComponentWithFallback(
|
|
5
|
-
'TimePickerModal',
|
|
6
|
-
TimePickerModalDefault,
|
|
7
|
-
);
|
|
8
|
-
|
|
9
|
-
export type { Props as TimePickerModalProps } from './TimePickerModal';
|
|
10
|
-
export { styles } from './utils';
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
|
|
3
|
-
import { getRegisteredComponentStylesWithFallback } from '../../core';
|
|
4
|
-
|
|
5
|
-
const timepickerModalStylesDefault = StyleSheet.create(theme => ({
|
|
6
|
-
keyboardView: {
|
|
7
|
-
justifyContent: 'center',
|
|
8
|
-
alignItems: 'center',
|
|
9
|
-
flex: 1,
|
|
10
|
-
},
|
|
11
|
-
modalContent: {
|
|
12
|
-
minWidth: 287,
|
|
13
|
-
width: undefined,
|
|
14
|
-
maxWidth: undefined,
|
|
15
|
-
flex: undefined,
|
|
16
|
-
borderRadius: theme.shapes.corner.extraLarge,
|
|
17
|
-
},
|
|
18
|
-
labelContainer: {
|
|
19
|
-
height: 28,
|
|
20
|
-
justifyContent: 'flex-end',
|
|
21
|
-
paddingLeft: theme.spacings['6'],
|
|
22
|
-
paddingRight: theme.spacings['6'],
|
|
23
|
-
alignSelf: 'flex-start',
|
|
24
|
-
},
|
|
25
|
-
label: {
|
|
26
|
-
letterSpacing: 1,
|
|
27
|
-
fontSize: theme.typescale.labelLarge.fontSize,
|
|
28
|
-
color: theme.colors.onSurface,
|
|
29
|
-
fontWeight: theme.typescale.labelLarge.fontWeight,
|
|
30
|
-
},
|
|
31
|
-
timePickerContainer: {
|
|
32
|
-
padding: theme.spacings['6'],
|
|
33
|
-
},
|
|
34
|
-
footer: {
|
|
35
|
-
flexDirection: 'row',
|
|
36
|
-
alignItems: 'center',
|
|
37
|
-
padding: theme.spacings['2'],
|
|
38
|
-
width: '100%',
|
|
39
|
-
},
|
|
40
|
-
inputTypeToggle: { margin: theme.spacings['1'] },
|
|
41
|
-
fill: { flex: 1 },
|
|
42
|
-
}));
|
|
43
|
-
|
|
44
|
-
export const styles = getRegisteredComponentStylesWithFallback(
|
|
45
|
-
'TimePickerModal',
|
|
46
|
-
timepickerModalStylesDefault,
|
|
47
|
-
);
|