@idealyst/datepicker 1.0.58 → 1.0.60
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idealyst/datepicker",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.60",
|
|
4
4
|
"description": "Cross-platform date and time picker components for React and React Native",
|
|
5
5
|
"documentation": "https://github.com/IdealystIO/idealyst-framework/tree/main/packages/datepicker#readme",
|
|
6
6
|
"readme": "README.md",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"publish:npm": "npm publish"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@idealyst/components": "^1.0.
|
|
40
|
-
"@idealyst/theme": "^1.0.
|
|
39
|
+
"@idealyst/components": "^1.0.60",
|
|
40
|
+
"@idealyst/theme": "^1.0.60",
|
|
41
41
|
"react": ">=16.8.0",
|
|
42
42
|
"react-native": ">=0.60.0",
|
|
43
43
|
"react-native-svg": ">=13.0.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { View,
|
|
2
|
+
import { View, Input, Text } from '@idealyst/components';
|
|
3
3
|
import { DateInputBase } from './DateInputBase';
|
|
4
4
|
import { DateInputProps } from './types';
|
|
5
5
|
import { dateInputStyles } from './DateInput.styles';
|
|
@@ -18,12 +18,6 @@ export const DateInput: React.FC<DateInputProps> = (props) => {
|
|
|
18
18
|
...baseProps
|
|
19
19
|
} = props;
|
|
20
20
|
|
|
21
|
-
// Initialize styles
|
|
22
|
-
dateInputStyles.useVariants({
|
|
23
|
-
size,
|
|
24
|
-
variant,
|
|
25
|
-
state: disabled ? 'disabled' : error ? 'error' : undefined,
|
|
26
|
-
});
|
|
27
21
|
|
|
28
22
|
return (
|
|
29
23
|
<View style={style} testID={testID}>
|
|
@@ -33,36 +27,23 @@ export const DateInput: React.FC<DateInputProps> = (props) => {
|
|
|
33
27
|
</Text>
|
|
34
28
|
)}
|
|
35
29
|
|
|
36
|
-
<DateInputBase
|
|
37
|
-
{
|
|
38
|
-
|
|
39
|
-
testID={testID}
|
|
40
|
-
renderInput={({
|
|
41
|
-
value,
|
|
42
|
-
onChangeText,
|
|
43
|
-
onFocus,
|
|
44
|
-
onBlur,
|
|
45
|
-
placeholder,
|
|
46
|
-
editable,
|
|
47
|
-
style: inputStyleProp,
|
|
48
|
-
testID: inputTestID,
|
|
49
|
-
}) => (
|
|
50
|
-
<TextInput
|
|
30
|
+
<DateInputBase {...baseProps} disabled={disabled} testID={testID}>
|
|
31
|
+
{({ value, onChangeText, onFocus, onBlur, placeholder, disabled: inputDisabled, testID: inputTestID }) => (
|
|
32
|
+
<Input
|
|
51
33
|
value={value}
|
|
52
34
|
onChangeText={onChangeText}
|
|
53
35
|
onFocus={onFocus}
|
|
54
36
|
onBlur={onBlur}
|
|
55
37
|
placeholder={placeholder}
|
|
56
|
-
|
|
57
|
-
|
|
38
|
+
disabled={inputDisabled}
|
|
39
|
+
size={size}
|
|
40
|
+
variant={variant}
|
|
41
|
+
hasError={error ? true : false}
|
|
42
|
+
style={inputStyle}
|
|
58
43
|
testID={inputTestID}
|
|
59
|
-
autoComplete="off"
|
|
60
|
-
autoCorrect={false}
|
|
61
|
-
spellCheck={false}
|
|
62
|
-
keyboardType="default"
|
|
63
44
|
/>
|
|
64
45
|
)}
|
|
65
|
-
|
|
46
|
+
</DateInputBase>
|
|
66
47
|
|
|
67
48
|
{error && (
|
|
68
49
|
<Text style={dateInputStyles.errorText} testID={testID ? `${testID}-error` : undefined}>
|
|
@@ -1,118 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
2
|
|
|
3
|
-
export const dateInputStyles =
|
|
3
|
+
export const dateInputStyles = StyleSheet.create((theme) => ({
|
|
4
4
|
container: {
|
|
5
5
|
width: '100%',
|
|
6
6
|
},
|
|
7
7
|
|
|
8
|
-
input: {
|
|
9
|
-
borderWidth: 1,
|
|
10
|
-
borderColor: theme.colors.border,
|
|
11
|
-
borderRadius: theme.radius.medium,
|
|
12
|
-
paddingHorizontal: theme.spacing.medium,
|
|
13
|
-
paddingVertical: theme.spacing.small,
|
|
14
|
-
fontSize: theme.typography.body.fontSize,
|
|
15
|
-
fontFamily: theme.typography.body.fontFamily,
|
|
16
|
-
color: theme.colors.text,
|
|
17
|
-
backgroundColor: theme.colors.background,
|
|
18
|
-
|
|
19
|
-
variants: {
|
|
20
|
-
size: {
|
|
21
|
-
small: {
|
|
22
|
-
paddingHorizontal: theme.spacing.small,
|
|
23
|
-
paddingVertical: theme.spacing.xs,
|
|
24
|
-
fontSize: theme.typography.caption.fontSize,
|
|
25
|
-
},
|
|
26
|
-
medium: {
|
|
27
|
-
paddingHorizontal: theme.spacing.medium,
|
|
28
|
-
paddingVertical: theme.spacing.small,
|
|
29
|
-
fontSize: theme.typography.body.fontSize,
|
|
30
|
-
},
|
|
31
|
-
large: {
|
|
32
|
-
paddingHorizontal: theme.spacing.large,
|
|
33
|
-
paddingVertical: theme.spacing.medium,
|
|
34
|
-
fontSize: theme.typography.subtitle.fontSize,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
variant: {
|
|
39
|
-
outlined: {
|
|
40
|
-
borderWidth: 1,
|
|
41
|
-
backgroundColor: 'transparent',
|
|
42
|
-
},
|
|
43
|
-
filled: {
|
|
44
|
-
borderWidth: 0,
|
|
45
|
-
backgroundColor: theme.colors.surfaceVariant,
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
state: {
|
|
50
|
-
focused: {
|
|
51
|
-
borderColor: theme.colors.primary,
|
|
52
|
-
borderWidth: 2,
|
|
53
|
-
},
|
|
54
|
-
disabled: {
|
|
55
|
-
backgroundColor: theme.colors.disabled,
|
|
56
|
-
color: theme.colors.onDisabled,
|
|
57
|
-
borderColor: theme.colors.outline,
|
|
58
|
-
},
|
|
59
|
-
error: {
|
|
60
|
-
borderColor: theme.colors.error,
|
|
61
|
-
borderWidth: 2,
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
_web: {
|
|
67
|
-
outlineStyle: 'none',
|
|
68
|
-
cursor: 'text',
|
|
69
|
-
|
|
70
|
-
':focus': {
|
|
71
|
-
borderColor: theme.colors.primary,
|
|
72
|
-
borderWidth: 2,
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
':disabled': {
|
|
76
|
-
cursor: 'not-allowed',
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
inputError: {
|
|
82
|
-
borderColor: theme.colors.error,
|
|
83
|
-
borderWidth: 2,
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
inputFocused: {
|
|
87
|
-
borderColor: theme.colors.primary,
|
|
88
|
-
borderWidth: 2,
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
inputDisabled: {
|
|
92
|
-
backgroundColor: theme.colors.disabled,
|
|
93
|
-
color: theme.colors.onDisabled,
|
|
94
|
-
borderColor: theme.colors.outline,
|
|
95
|
-
},
|
|
96
|
-
|
|
97
8
|
label: {
|
|
98
|
-
fontSize: theme.typography
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
marginBottom: theme.spacing.xs,
|
|
9
|
+
fontSize: theme.typography?.sizes?.small || 14,
|
|
10
|
+
color: theme.colors?.text?.primary || '#1f2937',
|
|
11
|
+
marginBottom: theme.spacing?.xs || 4,
|
|
102
12
|
fontWeight: '500',
|
|
103
13
|
},
|
|
104
14
|
|
|
105
15
|
helperText: {
|
|
106
|
-
fontSize: theme.typography
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
marginTop: theme.spacing.xs,
|
|
16
|
+
fontSize: theme.typography?.sizes?.small || 12,
|
|
17
|
+
color: theme.colors?.text?.secondary || '#6b7280',
|
|
18
|
+
marginTop: theme.spacing?.xs || 4,
|
|
110
19
|
},
|
|
111
20
|
|
|
112
21
|
errorText: {
|
|
113
|
-
fontSize: theme.typography
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
marginTop: theme.spacing.xs,
|
|
22
|
+
fontSize: theme.typography?.sizes?.small || 12,
|
|
23
|
+
color: theme.colors?.text?.error || '#dc2626',
|
|
24
|
+
marginTop: theme.spacing?.xs || 4,
|
|
117
25
|
},
|
|
118
26
|
}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { View,
|
|
2
|
+
import { View, Input, Text } from '@idealyst/components';
|
|
3
3
|
import { DateInputBase } from './DateInputBase';
|
|
4
4
|
import { DateInputProps } from './types';
|
|
5
5
|
import { dateInputStyles } from './DateInput.styles';
|
|
@@ -18,12 +18,6 @@ export const DateInput: React.FC<DateInputProps> = (props) => {
|
|
|
18
18
|
...baseProps
|
|
19
19
|
} = props;
|
|
20
20
|
|
|
21
|
-
// Initialize styles
|
|
22
|
-
dateInputStyles.useVariants({
|
|
23
|
-
size,
|
|
24
|
-
variant,
|
|
25
|
-
state: disabled ? 'disabled' : error ? 'error' : undefined,
|
|
26
|
-
});
|
|
27
21
|
|
|
28
22
|
return (
|
|
29
23
|
<View style={style} testID={testID}>
|
|
@@ -33,35 +27,23 @@ export const DateInput: React.FC<DateInputProps> = (props) => {
|
|
|
33
27
|
</Text>
|
|
34
28
|
)}
|
|
35
29
|
|
|
36
|
-
<DateInputBase
|
|
37
|
-
{
|
|
38
|
-
|
|
39
|
-
testID={testID}
|
|
40
|
-
renderInput={({
|
|
41
|
-
value,
|
|
42
|
-
onChangeText,
|
|
43
|
-
onFocus,
|
|
44
|
-
onBlur,
|
|
45
|
-
placeholder,
|
|
46
|
-
editable,
|
|
47
|
-
style: inputStyleProp,
|
|
48
|
-
testID: inputTestID,
|
|
49
|
-
}) => (
|
|
50
|
-
<TextInput
|
|
30
|
+
<DateInputBase {...baseProps} disabled={disabled} testID={testID}>
|
|
31
|
+
{({ value, onChangeText, onFocus, onBlur, placeholder, disabled: inputDisabled, testID: inputTestID }) => (
|
|
32
|
+
<Input
|
|
51
33
|
value={value}
|
|
52
34
|
onChangeText={onChangeText}
|
|
53
35
|
onFocus={onFocus}
|
|
54
36
|
onBlur={onBlur}
|
|
55
37
|
placeholder={placeholder}
|
|
56
|
-
|
|
57
|
-
|
|
38
|
+
disabled={inputDisabled}
|
|
39
|
+
size={size}
|
|
40
|
+
variant={variant}
|
|
41
|
+
hasError={error ? true : false}
|
|
42
|
+
style={inputStyle}
|
|
58
43
|
testID={inputTestID}
|
|
59
|
-
autoComplete="off"
|
|
60
|
-
autoCorrect={false}
|
|
61
|
-
spellCheck={false}
|
|
62
44
|
/>
|
|
63
45
|
)}
|
|
64
|
-
|
|
46
|
+
</DateInputBase>
|
|
65
47
|
|
|
66
48
|
{error && (
|
|
67
49
|
<Text style={dateInputStyles.errorText} testID={testID ? `${testID}-error` : undefined}>
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import React, { useState, useCallback, useRef, useEffect } from 'react';
|
|
2
|
-
import { View
|
|
2
|
+
import { View } from '@idealyst/components';
|
|
3
3
|
import { DateInputProps } from './types';
|
|
4
4
|
import { dateInputStyles } from './DateInput.styles';
|
|
5
5
|
|
|
6
6
|
interface DateInputBaseProps extends DateInputProps {
|
|
7
|
-
|
|
7
|
+
children: (props: {
|
|
8
8
|
value: string;
|
|
9
9
|
onChangeText: (text: string) => void;
|
|
10
10
|
onFocus: () => void;
|
|
11
11
|
onBlur: () => void;
|
|
12
12
|
placeholder?: string;
|
|
13
|
-
|
|
14
|
-
style?: any;
|
|
13
|
+
disabled: boolean;
|
|
15
14
|
testID?: string;
|
|
16
15
|
}) => React.ReactNode;
|
|
17
16
|
}
|
|
@@ -52,7 +51,7 @@ export const DateInputBase: React.FC<DateInputBaseProps> = ({
|
|
|
52
51
|
testID,
|
|
53
52
|
onFocus,
|
|
54
53
|
onBlur,
|
|
55
|
-
|
|
54
|
+
children,
|
|
56
55
|
}) => {
|
|
57
56
|
const [inputValue, setInputValue] = useState('');
|
|
58
57
|
const [isFocused, setIsFocused] = useState(false);
|
|
@@ -215,17 +214,13 @@ export const DateInputBase: React.FC<DateInputBaseProps> = ({
|
|
|
215
214
|
|
|
216
215
|
return (
|
|
217
216
|
<View style={[dateInputStyles.container, style]} testID={testID}>
|
|
218
|
-
{
|
|
217
|
+
{children({
|
|
219
218
|
value: inputValue,
|
|
220
219
|
onChangeText: handleChangeText,
|
|
221
220
|
onFocus: handleFocus,
|
|
222
221
|
onBlur: handleBlur,
|
|
223
222
|
placeholder,
|
|
224
|
-
|
|
225
|
-
style: [
|
|
226
|
-
dateInputStyles.input,
|
|
227
|
-
hasError && dateInputStyles.inputError,
|
|
228
|
-
],
|
|
223
|
+
disabled,
|
|
229
224
|
testID: testID ? `${testID}-input` : undefined,
|
|
230
225
|
})}
|
|
231
226
|
</View>
|