native-pytech 1.0.148 → 1.0.151
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.
|
@@ -8,7 +8,7 @@ import Colors from '../../../../../libs/constants/colors';
|
|
|
8
8
|
export default memo(({ itemKey, label, defaultValue, minDate = new Date(new Date().setFullYear(new Date().getFullYear() - 100)), maxDate = new Date(), }) => {
|
|
9
9
|
const { colorScheme } = useApp();
|
|
10
10
|
const { store, registerItem } = usePage();
|
|
11
|
-
const [selection, setSelection] = useState(defaultValue);
|
|
11
|
+
const [selection, setSelection] = useState(defaultValue ?? new Date());
|
|
12
12
|
const inputRef = useRef(null);
|
|
13
13
|
// Key
|
|
14
14
|
const keyRef = useRef(itemKey);
|
|
@@ -16,7 +16,7 @@ export default memo(({ itemKey, label, defaultValue, minDate = new Date(new Date
|
|
|
16
16
|
keyRef.current = registerItem(itemKey);
|
|
17
17
|
}, []);
|
|
18
18
|
// Hooks
|
|
19
|
-
useEffect(() => setSelection(defaultValue), [defaultValue]);
|
|
19
|
+
useEffect(() => setSelection(defaultValue ?? new Date()), [defaultValue]);
|
|
20
20
|
const onValueChange = useCallback((value_str) => {
|
|
21
21
|
const [year, month, day] = value_str.split('-').map(Number);
|
|
22
22
|
const value = new Date(year, month - 1, day);
|
|
@@ -27,10 +27,12 @@ export default memo(({ itemKey, label, defaultValue, minDate = new Date(new Date
|
|
|
27
27
|
isValid: true,
|
|
28
28
|
});
|
|
29
29
|
}, []);
|
|
30
|
+
if (defaultValue === undefined)
|
|
31
|
+
onValueChange(Formats.dateToTextFormat(selection, 'yyyy-MM-dd')); // Set default value on first render
|
|
30
32
|
return (<Table.Option id={label ?? ''} colorScheme={colorScheme} childrenLeft={<Table.Option.Components.Text text={label ?? 'Seleccione una fecha'}/>} childrenRight={(<>
|
|
31
33
|
<Pressable onPress={() => inputRef.current?.showPicker()} style={[styles.container, { backgroundColor: Colors.especiales.azul }]}>
|
|
32
|
-
<Table.Option.Components.Text text={
|
|
33
|
-
<input ref={inputRef} type="date" value={
|
|
34
|
+
<Table.Option.Components.Text text={Formats.dateToTextFormat(selection, 'dd/MM/yyyy')} style={{ color: 'white', userSelect: 'none' }}/>
|
|
35
|
+
<input ref={inputRef} type="date" value={Formats.dateToTextFormat(selection, 'yyyy-MM-dd')} onChange={(e) => onValueChange(e.target.value)} style={{
|
|
34
36
|
all: 'unset',
|
|
35
37
|
visibility: 'hidden',
|
|
36
38
|
width: 0,
|
|
@@ -8,7 +8,13 @@ export default memo(({ ...props }) => {
|
|
|
8
8
|
});
|
|
9
9
|
const Component = memo(({ text, enabled = true, style = {}, colorScheme, fontScale, ...props }) => {
|
|
10
10
|
const Theme = colors.theme[colorScheme];
|
|
11
|
-
const textStyle = useMemo(() => [
|
|
11
|
+
const textStyle = useMemo(() => [
|
|
12
|
+
styles.text,
|
|
13
|
+
{
|
|
14
|
+
color: enabled ? Theme.text : Theme.text2
|
|
15
|
+
},
|
|
16
|
+
style
|
|
17
|
+
], [enabled, Theme, style]);
|
|
12
18
|
return (<Text$ fontScale={fontScale} style={textStyle} {...props}>
|
|
13
19
|
{text}
|
|
14
20
|
</Text$>);
|