native-pytech 1.0.24 → 1.0.25
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/dist/libs/editPage/index.d.ts +2 -0
- package/dist/libs/editPage/index.js +2 -0
- package/dist/libs/editPage/src/components/ItemDate/index.d.ts +4 -0
- package/dist/libs/editPage/src/components/ItemDate/index.js +32 -0
- package/dist/libs/editPage/src/components/ItemDate/types.d.ts +22 -0
- package/dist/libs/editPage/src/components/ItemDate/types.js +1 -0
- package/dist/libs/editPage/src/components/Page/types.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import Page from './src/components/Page';
|
|
2
2
|
import Item from './src/components/Item';
|
|
3
|
+
import ItemDate from './src/components/ItemDate';
|
|
3
4
|
type EditPageComponent = typeof Page & {
|
|
4
5
|
Item: typeof Item;
|
|
6
|
+
ItemDate: typeof ItemDate;
|
|
5
7
|
};
|
|
6
8
|
declare const EditPage: EditPageComponent;
|
|
7
9
|
export default EditPage;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Section, DatePicker } from '@expo/ui/swift-ui';
|
|
2
|
+
import React, { memo, useCallback, useEffect, useMemo } from 'react';
|
|
3
|
+
import { environment } from '@expo/ui/swift-ui/modifiers';
|
|
4
|
+
import { usePage } from '../../context/page';
|
|
5
|
+
import { useItem } from '../../context/item';
|
|
6
|
+
export default memo(({ label, defaultValue, minDate = new Date(new Date().setFullYear(new Date().getFullYear() - 100)), maxDate = new Date(), modifiers, ...restProps }) => {
|
|
7
|
+
// ------------------- Variables -------------------
|
|
8
|
+
const { store } = usePage();
|
|
9
|
+
const { index } = useItem();
|
|
10
|
+
// ------------------- Hooks -------------------
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
store.values[index].value.set(defaultValue);
|
|
13
|
+
}, [defaultValue]);
|
|
14
|
+
// -------------------- Functions --------------------
|
|
15
|
+
const onValueChange = useCallback((value) => {
|
|
16
|
+
store.values[index].set({
|
|
17
|
+
value: value,
|
|
18
|
+
hasChanged: value !== defaultValue,
|
|
19
|
+
isValid: true,
|
|
20
|
+
});
|
|
21
|
+
}, []);
|
|
22
|
+
const _modifiers = useMemo(() => [
|
|
23
|
+
environment('locale', 'es_ES'),
|
|
24
|
+
...(modifiers ?? []),
|
|
25
|
+
], [modifiers]);
|
|
26
|
+
return (<Section>
|
|
27
|
+
<DatePicker title={label} selection={defaultValue} onDateChange={onValueChange} modifiers={_modifiers} range={{
|
|
28
|
+
start: minDate,
|
|
29
|
+
end: maxDate,
|
|
30
|
+
}} {...restProps}/>
|
|
31
|
+
</Section>);
|
|
32
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DatePickerProps } from '@expo/ui/swift-ui';
|
|
2
|
+
type Props = Omit<DatePickerProps, 'title' | 'selection' | 'range' | 'onDateChange'> & {
|
|
3
|
+
/**
|
|
4
|
+
Title of the date picker.
|
|
5
|
+
*/
|
|
6
|
+
label?: string;
|
|
7
|
+
/**
|
|
8
|
+
Default value of the date picker.
|
|
9
|
+
*/
|
|
10
|
+
defaultValue?: Date;
|
|
11
|
+
/**
|
|
12
|
+
Minimum date allowed.
|
|
13
|
+
@default 100 years ago
|
|
14
|
+
*/
|
|
15
|
+
minDate?: Date;
|
|
16
|
+
/**
|
|
17
|
+
Maximum date allowed.
|
|
18
|
+
@default today
|
|
19
|
+
*/
|
|
20
|
+
maxDate?: Date;
|
|
21
|
+
};
|
|
22
|
+
export default Props;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -12,10 +12,10 @@ type Props<T> = {
|
|
|
12
12
|
Function to be called when the user saves the changes.
|
|
13
13
|
If the function returns true, the user will be redirected to the previous screen.
|
|
14
14
|
*/
|
|
15
|
-
onSave?: (values: (string | null)[]) => boolean | Promise<boolean>;
|
|
15
|
+
onSave?: (values: (string | null | Date)[]) => boolean | Promise<boolean>;
|
|
16
16
|
};
|
|
17
17
|
export type Values = Record<number, {
|
|
18
|
-
value: string | null | undefined;
|
|
18
|
+
value: string | null | Date | undefined;
|
|
19
19
|
hasChanged: boolean;
|
|
20
20
|
isValid: boolean;
|
|
21
21
|
}>;
|