ikualo-ui-kit-mobile 1.3.0 → 1.3.2
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": "ikualo-ui-kit-mobile",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"main": "src/index.ts",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "expo start",
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@expo/metro-runtime": "^4.0.0",
|
|
13
13
|
"@expo/vector-icons": "^14.0.2",
|
|
14
|
-
"@react-native-community/datetimepicker": "8.2.0",
|
|
15
14
|
"@react-navigation/bottom-tabs": "^6.5.20",
|
|
16
15
|
"@react-navigation/native": "^6.1.17",
|
|
17
16
|
"@react-navigation/stack": "^6.3.29",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ScrollView, View } from 'react-native';
|
|
2
|
-
import { InputCheckbox, Input, InputEmail, InputPassword, Text
|
|
2
|
+
import { InputCheckbox, Input, InputEmail, InputPassword, Text } from '../..';
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import useStore from '../../store';
|
|
5
5
|
|
|
@@ -23,22 +23,6 @@ export const InputsExamples = () => {
|
|
|
23
23
|
<Text fontWeight="MontserratSemiBold600" fontSize={18} color={theme.colors.text_h}>
|
|
24
24
|
Campos de entrada
|
|
25
25
|
</Text>
|
|
26
|
-
<InputDateTime
|
|
27
|
-
lang="es-ES"
|
|
28
|
-
textBtnSave="Guardar"
|
|
29
|
-
label="Fecha"
|
|
30
|
-
onChange={(e) => {
|
|
31
|
-
setValueDate(e);
|
|
32
|
-
}}
|
|
33
|
-
type="date"
|
|
34
|
-
value={valueDate}
|
|
35
|
-
isValid={true}
|
|
36
|
-
onInvalid={() => {}}
|
|
37
|
-
msgHelper="Fecha de prueba"
|
|
38
|
-
msgError="Error"
|
|
39
|
-
required={true}
|
|
40
|
-
msgErrorRequired="Campo requerido"
|
|
41
|
-
/>
|
|
42
26
|
<Input
|
|
43
27
|
label="Prueba"
|
|
44
28
|
onChange={(e) => {
|
package/src/index.ts
CHANGED
|
@@ -11,7 +11,6 @@ export * from './elements/buttons/BtnCircle';
|
|
|
11
11
|
export * from './elements/inputs/InputPassword';
|
|
12
12
|
export * from './elements/inputs/Input';
|
|
13
13
|
export * from './elements/inputs/InputEmail';
|
|
14
|
-
export * from './elements/inputs/InputDateTime';
|
|
15
14
|
|
|
16
15
|
export * from './elements/timer/Timer';
|
|
17
16
|
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { HelperText, TextInput, Text } from 'react-native-paper';
|
|
2
|
-
import { getStyleInput } from '../../../assets/styles/elements/inputs';
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
import { Platform, View } from 'react-native';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import useStore from '../../store';
|
|
7
|
-
import { IInputDate } from '../../models';
|
|
8
|
-
import { ErrorInputIcon } from '../../../assets/icons/svgs';
|
|
9
|
-
import { MaterialCommunityIcons } from '@expo/vector-icons';
|
|
10
|
-
import RNDateTimePicker, { DateTimePickerAndroid } from '@react-native-community/datetimepicker';
|
|
11
|
-
import { DialogDown } from '../dialogs/DialogDown';
|
|
12
|
-
import { BtnContained } from '../buttons/BtnContained';
|
|
13
|
-
|
|
14
|
-
export const InputDateTime = (props: IInputDate) => {
|
|
15
|
-
const theme = useStore().theme;
|
|
16
|
-
const styleInput = getStyleInput(theme);
|
|
17
|
-
const [isFocus, setIsFocus] = useState<boolean>(false);
|
|
18
|
-
const [errorRequired, setErrorRequired] = useState<boolean>(false);
|
|
19
|
-
const [showDialogDate, setDialogDate] = useState<boolean>(false);
|
|
20
|
-
const {
|
|
21
|
-
label,
|
|
22
|
-
lang,
|
|
23
|
-
isDisabled,
|
|
24
|
-
onChange,
|
|
25
|
-
error,
|
|
26
|
-
style,
|
|
27
|
-
value,
|
|
28
|
-
isValid,
|
|
29
|
-
onFocus,
|
|
30
|
-
onBlur,
|
|
31
|
-
type,
|
|
32
|
-
onInvalid,
|
|
33
|
-
msgHelper,
|
|
34
|
-
msgError,
|
|
35
|
-
placeholder = lang === 'es-ES' ? 'DD-MM-YYYY' : 'DD-MM-YYYY',
|
|
36
|
-
required,
|
|
37
|
-
msgErrorRequired,
|
|
38
|
-
readonly = true,
|
|
39
|
-
textBtnSave,
|
|
40
|
-
} = props;
|
|
41
|
-
|
|
42
|
-
const onChangeText = (date: Date) => {
|
|
43
|
-
onChange(date);
|
|
44
|
-
setErrorRequired(false);
|
|
45
|
-
};
|
|
46
|
-
const formatDate = (date: Date) => {
|
|
47
|
-
const day = date.getDate().toString().padStart(2, '0');
|
|
48
|
-
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
|
49
|
-
const year = date.getFullYear();
|
|
50
|
-
if (type === 'date') {
|
|
51
|
-
return `${day}-${month}-${year}`;
|
|
52
|
-
} else if (type === 'datetime') {
|
|
53
|
-
const hours = date.getHours().toString().padStart(2, '0');
|
|
54
|
-
const minutes = date.getMinutes().toString().padStart(2, '0');
|
|
55
|
-
return `${day}-${month}-${year} ${hours}:${minutes}`;
|
|
56
|
-
} else if (type === 'time') {
|
|
57
|
-
const hours = date.getHours().toString().padStart(2, '0');
|
|
58
|
-
const minutes = date.getMinutes().toString().padStart(2, '0');
|
|
59
|
-
return `${hours}:${minutes}`;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const showDateTimepicker = () => {
|
|
64
|
-
DateTimePickerAndroid.open({
|
|
65
|
-
value: value || new Date(),
|
|
66
|
-
onChange: (event, selectedDate) => {
|
|
67
|
-
if (event.type === 'set' && selectedDate) {
|
|
68
|
-
onChangeText(selectedDate);
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
mode: type === 'time' ? type : 'date',
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
return (
|
|
75
|
-
<View>
|
|
76
|
-
<TextInput
|
|
77
|
-
label={label}
|
|
78
|
-
mode={'flat'}
|
|
79
|
-
value={value ? formatDate(value) : placeholder}
|
|
80
|
-
selectionColor={
|
|
81
|
-
!errorRequired
|
|
82
|
-
? styleInput['input'].borderBottomColor
|
|
83
|
-
: styleInput['input-txt-error'].borderBottomColor
|
|
84
|
-
}
|
|
85
|
-
theme={{
|
|
86
|
-
colors: {
|
|
87
|
-
primary: theme.colors.border_dark,
|
|
88
|
-
onSurfaceVariant: theme.colors.text_p,
|
|
89
|
-
},
|
|
90
|
-
}}
|
|
91
|
-
onFocus={() => {
|
|
92
|
-
setIsFocus(true);
|
|
93
|
-
onFocus && onFocus();
|
|
94
|
-
}}
|
|
95
|
-
onBlur={() => {
|
|
96
|
-
setIsFocus(false);
|
|
97
|
-
onBlur && onBlur();
|
|
98
|
-
if (!value && required) {
|
|
99
|
-
setErrorRequired(true);
|
|
100
|
-
onInvalid && onInvalid();
|
|
101
|
-
}
|
|
102
|
-
}}
|
|
103
|
-
error={error || errorRequired}
|
|
104
|
-
right={
|
|
105
|
-
<TextInput.Icon
|
|
106
|
-
onPress={() => {
|
|
107
|
-
setDialogDate(true);
|
|
108
|
-
Platform.OS === 'android' && showDateTimepicker();
|
|
109
|
-
}}
|
|
110
|
-
icon={(_) =>
|
|
111
|
-
type === 'date' || type === 'datetime' ? (
|
|
112
|
-
<MaterialCommunityIcons
|
|
113
|
-
name="calendar-blank"
|
|
114
|
-
size={24}
|
|
115
|
-
color={isValid && !errorRequired ? theme.colors.icon : theme.colors.error}
|
|
116
|
-
/>
|
|
117
|
-
) : (
|
|
118
|
-
<MaterialCommunityIcons
|
|
119
|
-
name="clock-outline"
|
|
120
|
-
size={24}
|
|
121
|
-
color={isValid && !errorRequired ? theme.colors.icon : theme.colors.error}
|
|
122
|
-
/>
|
|
123
|
-
)
|
|
124
|
-
}
|
|
125
|
-
/>
|
|
126
|
-
}
|
|
127
|
-
style={[
|
|
128
|
-
styleInput['input-label'],
|
|
129
|
-
((!isValid && value) || errorRequired) && styleInput['input-error-focused'],
|
|
130
|
-
isFocus && isValid && !errorRequired && styleInput['input-text--focused'],
|
|
131
|
-
style ?? [],
|
|
132
|
-
]}
|
|
133
|
-
contentStyle={[styleInput['input-txt']]}
|
|
134
|
-
underlineColor={
|
|
135
|
-
isValid && !errorRequired
|
|
136
|
-
? styleInput['input-text-underline'].color
|
|
137
|
-
: styleInput['input-txt-error'].borderBottomColor
|
|
138
|
-
}
|
|
139
|
-
activeUnderlineColor={
|
|
140
|
-
!isValid && value
|
|
141
|
-
? styleInput['input-text--activeUnderline'].color
|
|
142
|
-
: errorRequired
|
|
143
|
-
? styleInput['input-txt-error'].color
|
|
144
|
-
: ''
|
|
145
|
-
}
|
|
146
|
-
readOnly={isDisabled || readonly}
|
|
147
|
-
/>
|
|
148
|
-
{!isDisabled && (
|
|
149
|
-
<>
|
|
150
|
-
{isValid && !errorRequired && (
|
|
151
|
-
<HelperText type="info" style={styleInput['input-password-helper']} visible={true}>
|
|
152
|
-
{msgHelper}
|
|
153
|
-
</HelperText>
|
|
154
|
-
)}
|
|
155
|
-
{!isValid && msgError !== undefined && value && !errorRequired && (
|
|
156
|
-
<View style={styleInput['input-helper--error-text']}>
|
|
157
|
-
<ErrorInputIcon />
|
|
158
|
-
<Text style={styleInput['input-password-helper--error-text']}>{msgError}</Text>
|
|
159
|
-
</View>
|
|
160
|
-
)}
|
|
161
|
-
{errorRequired && (
|
|
162
|
-
<View style={styleInput['input-helper--error-text']}>
|
|
163
|
-
<ErrorInputIcon />
|
|
164
|
-
<Text style={styleInput['input-password-helper--error-text']}>{msgErrorRequired}</Text>
|
|
165
|
-
</View>
|
|
166
|
-
)}
|
|
167
|
-
</>
|
|
168
|
-
)}
|
|
169
|
-
{Platform.OS === 'ios' && (
|
|
170
|
-
<DialogDown
|
|
171
|
-
isVisible={showDialogDate}
|
|
172
|
-
title={label ?? ''}
|
|
173
|
-
onDismiss={() => {
|
|
174
|
-
setDialogDate(false);
|
|
175
|
-
if (!value && required) {
|
|
176
|
-
setErrorRequired(true);
|
|
177
|
-
onInvalid && onInvalid();
|
|
178
|
-
}
|
|
179
|
-
}}
|
|
180
|
-
>
|
|
181
|
-
<RNDateTimePicker
|
|
182
|
-
display="spinner"
|
|
183
|
-
mode={type}
|
|
184
|
-
locale={lang}
|
|
185
|
-
value={value || new Date()}
|
|
186
|
-
onChange={(event, date) => {
|
|
187
|
-
if (date) onChangeText(date);
|
|
188
|
-
}}
|
|
189
|
-
/>
|
|
190
|
-
<BtnContained
|
|
191
|
-
text={textBtnSave}
|
|
192
|
-
onPress={() => {
|
|
193
|
-
setDialogDate(false);
|
|
194
|
-
}}
|
|
195
|
-
/>
|
|
196
|
-
</DialogDown>
|
|
197
|
-
)}
|
|
198
|
-
</View>
|
|
199
|
-
);
|
|
200
|
-
};
|