@idealyst/datepicker 1.0.59 → 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,18 +18,6 @@ export const DateInput: React.FC<DateInputProps> = (props) => {
|
|
|
18
18
|
...baseProps
|
|
19
19
|
} = props;
|
|
20
20
|
|
|
21
|
-
// Determine input style based on state
|
|
22
|
-
const getInputStyle = () => {
|
|
23
|
-
const styles = [dateInputStyles.input];
|
|
24
|
-
|
|
25
|
-
if (disabled) {
|
|
26
|
-
styles.push(dateInputStyles.inputDisabled);
|
|
27
|
-
} else if (error) {
|
|
28
|
-
styles.push(dateInputStyles.inputError);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return styles;
|
|
32
|
-
};
|
|
33
21
|
|
|
34
22
|
return (
|
|
35
23
|
<View style={style} testID={testID}>
|
|
@@ -39,36 +27,23 @@ export const DateInput: React.FC<DateInputProps> = (props) => {
|
|
|
39
27
|
</Text>
|
|
40
28
|
)}
|
|
41
29
|
|
|
42
|
-
<DateInputBase
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
testID={testID}
|
|
46
|
-
renderInput={({
|
|
47
|
-
value,
|
|
48
|
-
onChangeText,
|
|
49
|
-
onFocus,
|
|
50
|
-
onBlur,
|
|
51
|
-
placeholder,
|
|
52
|
-
editable,
|
|
53
|
-
style: inputStyleProp,
|
|
54
|
-
testID: inputTestID,
|
|
55
|
-
}) => (
|
|
56
|
-
<TextInput
|
|
30
|
+
<DateInputBase {...baseProps} disabled={disabled} testID={testID}>
|
|
31
|
+
{({ value, onChangeText, onFocus, onBlur, placeholder, disabled: inputDisabled, testID: inputTestID }) => (
|
|
32
|
+
<Input
|
|
57
33
|
value={value}
|
|
58
34
|
onChangeText={onChangeText}
|
|
59
35
|
onFocus={onFocus}
|
|
60
36
|
onBlur={onBlur}
|
|
61
37
|
placeholder={placeholder}
|
|
62
|
-
|
|
63
|
-
|
|
38
|
+
disabled={inputDisabled}
|
|
39
|
+
size={size}
|
|
40
|
+
variant={variant}
|
|
41
|
+
hasError={error ? true : false}
|
|
42
|
+
style={inputStyle}
|
|
64
43
|
testID={inputTestID}
|
|
65
|
-
autoComplete="off"
|
|
66
|
-
autoCorrect={false}
|
|
67
|
-
spellCheck={false}
|
|
68
|
-
keyboardType="default"
|
|
69
44
|
/>
|
|
70
45
|
)}
|
|
71
|
-
|
|
46
|
+
</DateInputBase>
|
|
72
47
|
|
|
73
48
|
{error && (
|
|
74
49
|
<Text style={dateInputStyles.errorText} testID={testID ? `${testID}-error` : undefined}>
|
|
@@ -5,60 +5,6 @@ export const dateInputStyles = StyleSheet.create((theme) => ({
|
|
|
5
5
|
width: '100%',
|
|
6
6
|
},
|
|
7
7
|
|
|
8
|
-
input: {
|
|
9
|
-
borderWidth: 1,
|
|
10
|
-
borderColor: theme.colors?.border?.primary || '#e5e7eb',
|
|
11
|
-
borderRadius: theme.borderRadius?.md || 8,
|
|
12
|
-
paddingHorizontal: theme.spacing?.md || 12,
|
|
13
|
-
paddingVertical: theme.spacing?.sm || 8,
|
|
14
|
-
fontSize: theme.typography?.sizes?.medium || 16,
|
|
15
|
-
color: theme.colors?.text?.primary || '#1f2937',
|
|
16
|
-
backgroundColor: theme.colors?.surface?.primary || '#ffffff',
|
|
17
|
-
|
|
18
|
-
_web: {
|
|
19
|
-
outlineStyle: 'none',
|
|
20
|
-
cursor: 'text',
|
|
21
|
-
border: `1px solid ${theme.colors?.border?.primary || '#e5e7eb'}`,
|
|
22
|
-
borderWidth: undefined,
|
|
23
|
-
borderColor: undefined,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
inputError: {
|
|
28
|
-
borderColor: theme.colors?.text?.error || '#dc2626',
|
|
29
|
-
borderWidth: 2,
|
|
30
|
-
|
|
31
|
-
_web: {
|
|
32
|
-
border: `2px solid ${theme.colors?.text?.error || '#dc2626'}`,
|
|
33
|
-
borderWidth: undefined,
|
|
34
|
-
borderColor: undefined,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
inputFocused: {
|
|
39
|
-
borderColor: theme.colors?.primary || '#3b82f6',
|
|
40
|
-
borderWidth: 2,
|
|
41
|
-
|
|
42
|
-
_web: {
|
|
43
|
-
border: `2px solid ${theme.colors?.primary || '#3b82f6'}`,
|
|
44
|
-
borderWidth: undefined,
|
|
45
|
-
borderColor: undefined,
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
inputDisabled: {
|
|
50
|
-
backgroundColor: theme.colors?.surface?.disabled || '#f9fafb',
|
|
51
|
-
color: theme.colors?.text?.disabled || '#9ca3af',
|
|
52
|
-
borderColor: theme.colors?.border?.disabled || '#d1d5db',
|
|
53
|
-
|
|
54
|
-
_web: {
|
|
55
|
-
cursor: 'not-allowed',
|
|
56
|
-
border: `1px solid ${theme.colors?.border?.disabled || '#d1d5db'}`,
|
|
57
|
-
borderWidth: undefined,
|
|
58
|
-
borderColor: undefined,
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
|
|
62
8
|
label: {
|
|
63
9
|
fontSize: theme.typography?.sizes?.small || 14,
|
|
64
10
|
color: theme.colors?.text?.primary || '#1f2937',
|
|
@@ -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,18 +18,6 @@ export const DateInput: React.FC<DateInputProps> = (props) => {
|
|
|
18
18
|
...baseProps
|
|
19
19
|
} = props;
|
|
20
20
|
|
|
21
|
-
// Determine input style based on state
|
|
22
|
-
const getInputStyle = () => {
|
|
23
|
-
const styles = [dateInputStyles.input];
|
|
24
|
-
|
|
25
|
-
if (disabled) {
|
|
26
|
-
styles.push(dateInputStyles.inputDisabled);
|
|
27
|
-
} else if (error) {
|
|
28
|
-
styles.push(dateInputStyles.inputError);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return styles;
|
|
32
|
-
};
|
|
33
21
|
|
|
34
22
|
return (
|
|
35
23
|
<View style={style} testID={testID}>
|
|
@@ -39,35 +27,23 @@ export const DateInput: React.FC<DateInputProps> = (props) => {
|
|
|
39
27
|
</Text>
|
|
40
28
|
)}
|
|
41
29
|
|
|
42
|
-
<DateInputBase
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
testID={testID}
|
|
46
|
-
renderInput={({
|
|
47
|
-
value,
|
|
48
|
-
onChangeText,
|
|
49
|
-
onFocus,
|
|
50
|
-
onBlur,
|
|
51
|
-
placeholder,
|
|
52
|
-
editable,
|
|
53
|
-
style: inputStyleProp,
|
|
54
|
-
testID: inputTestID,
|
|
55
|
-
}) => (
|
|
56
|
-
<TextInput
|
|
30
|
+
<DateInputBase {...baseProps} disabled={disabled} testID={testID}>
|
|
31
|
+
{({ value, onChangeText, onFocus, onBlur, placeholder, disabled: inputDisabled, testID: inputTestID }) => (
|
|
32
|
+
<Input
|
|
57
33
|
value={value}
|
|
58
34
|
onChangeText={onChangeText}
|
|
59
35
|
onFocus={onFocus}
|
|
60
36
|
onBlur={onBlur}
|
|
61
37
|
placeholder={placeholder}
|
|
62
|
-
|
|
63
|
-
|
|
38
|
+
disabled={inputDisabled}
|
|
39
|
+
size={size}
|
|
40
|
+
variant={variant}
|
|
41
|
+
hasError={error ? true : false}
|
|
42
|
+
style={inputStyle}
|
|
64
43
|
testID={inputTestID}
|
|
65
|
-
autoComplete="off"
|
|
66
|
-
autoCorrect={false}
|
|
67
|
-
spellCheck={false}
|
|
68
44
|
/>
|
|
69
45
|
)}
|
|
70
|
-
|
|
46
|
+
</DateInputBase>
|
|
71
47
|
|
|
72
48
|
{error && (
|
|
73
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,14 +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: inputStyleProp,
|
|
223
|
+
disabled,
|
|
226
224
|
testID: testID ? `${testID}-input` : undefined,
|
|
227
225
|
})}
|
|
228
226
|
</View>
|