native-pytech 1.0.27 → 1.0.29
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Section, DatePicker } from '@expo/ui/swift-ui';
|
|
2
|
-
import React, { memo, useCallback, useEffect, useMemo } from 'react';
|
|
2
|
+
import React, { memo, useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { environment } from '@expo/ui/swift-ui/modifiers';
|
|
4
4
|
import { usePage } from '../../context/page';
|
|
5
5
|
import { useItem } from '../../context/item';
|
|
@@ -7,24 +7,24 @@ export default memo(({ label, defaultValue, minDate = new Date(new Date().setFul
|
|
|
7
7
|
// ------------------- Variables -------------------
|
|
8
8
|
const { store } = usePage();
|
|
9
9
|
const { index } = useItem();
|
|
10
|
+
const [selection, setSelection] = useState(defaultValue);
|
|
11
|
+
const _modifiers = useMemo(() => [
|
|
12
|
+
environment('locale', 'es_ES'),
|
|
13
|
+
...(modifiers ?? []),
|
|
14
|
+
], [modifiers]);
|
|
10
15
|
// ------------------- Hooks -------------------
|
|
11
|
-
useEffect(() =>
|
|
12
|
-
store.values[index].value.set(defaultValue);
|
|
13
|
-
}, [defaultValue]);
|
|
16
|
+
useEffect(() => setSelection(defaultValue), [defaultValue]);
|
|
14
17
|
// -------------------- Functions --------------------
|
|
15
18
|
const onValueChange = useCallback((value) => {
|
|
19
|
+
setSelection(value);
|
|
16
20
|
store.values[index].set({
|
|
17
21
|
value: value,
|
|
18
22
|
hasChanged: value !== defaultValue,
|
|
19
23
|
isValid: true,
|
|
20
24
|
});
|
|
21
25
|
}, []);
|
|
22
|
-
const _modifiers = useMemo(() => [
|
|
23
|
-
environment('locale', 'es_ES'),
|
|
24
|
-
...(modifiers ?? []),
|
|
25
|
-
], [modifiers]);
|
|
26
26
|
return (<Section>
|
|
27
|
-
<DatePicker title={label} selection={
|
|
27
|
+
<DatePicker title={label} selection={selection} onDateChange={onValueChange} modifiers={_modifiers} range={{
|
|
28
28
|
start: minDate,
|
|
29
29
|
end: maxDate,
|
|
30
30
|
}} {...restProps}/>
|
|
@@ -10,7 +10,7 @@ type Props<T> = {
|
|
|
10
10
|
renderItem?: (item: T) => React.ReactNode;
|
|
11
11
|
/**
|
|
12
12
|
Function to be called when the user saves the changes.
|
|
13
|
-
If the function returns
|
|
13
|
+
If the function returns false, the user will not be redirected to the previous screen.
|
|
14
14
|
*/
|
|
15
15
|
onSave?: (values: (string | null | Date)[]) => boolean | Promise<boolean>;
|
|
16
16
|
};
|