native-pytech 1.0.190 → 1.0.191

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.
Files changed (24) hide show
  1. package/dist/libs/editPage/src/components/ItemDate/Picker/Date/index.d.ts +3 -0
  2. package/dist/libs/editPage/src/components/ItemDate/Picker/Date/index.ios.d.ts +3 -0
  3. package/dist/libs/editPage/src/components/ItemDate/{DatePicker → Picker/Date}/index.js +4 -4
  4. package/dist/libs/editPage/src/components/ItemDate/Picker/Time/index.d.ts +3 -0
  5. package/dist/libs/editPage/src/components/ItemDate/Picker/Time/index.ios.d.ts +3 -0
  6. package/dist/libs/editPage/src/components/ItemDate/Picker/Time/index.ios.js +4 -0
  7. package/dist/libs/editPage/src/components/ItemDate/Picker/Time/index.js +36 -0
  8. package/dist/libs/editPage/src/components/ItemDate/index.d.ts +1 -1
  9. package/dist/libs/editPage/src/components/ItemDate/index.js +11 -3
  10. package/dist/libs/editPage/src/components/ItemDate/types.d.ts +6 -1
  11. package/dist/libs/editPage/src/components/ItemTime/TimePicker/index.ios.js +4 -0
  12. package/dist/libs/editPage/src/components/ItemTime/TimePicker/index.js +36 -0
  13. package/dist/libs/editPage/src/components/ItemTime/TimePicker/types.d.ts +23 -0
  14. package/dist/libs/editPage/src/components/ItemTime/TimePicker/types.js +1 -0
  15. package/dist/libs/editPage/src/components/ItemTime/index.d.ts +3 -0
  16. package/dist/libs/editPage/src/components/ItemTime/index.js +38 -0
  17. package/dist/libs/editPage/src/components/ItemTime/types.d.ts +17 -0
  18. package/dist/libs/editPage/src/components/ItemTime/types.js +1 -0
  19. package/package.json +1 -1
  20. /package/dist/libs/editPage/src/components/ItemDate/{DatePicker → Picker/Date}/index.ios.js +0 -0
  21. /package/dist/libs/editPage/src/components/ItemDate/{DatePicker → Picker}/types.d.ts +0 -0
  22. /package/dist/libs/editPage/src/components/ItemDate/{DatePicker → Picker}/types.js +0 -0
  23. /package/dist/libs/editPage/src/components/{ItemDate/DatePicker → ItemTime/TimePicker}/index.d.ts +0 -0
  24. /package/dist/libs/editPage/src/components/{ItemDate/DatePicker → ItemTime/TimePicker}/index.ios.d.ts +0 -0
@@ -0,0 +1,3 @@
1
+ import type Props from '../types';
2
+ declare const _default: import("react").MemoExoticComponent<({ label, selection, minDate, maxDate, onValueChange, }: Props) => import("react").JSX.Element>;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import type Props from '../types';
2
+ declare const _default: import("react").MemoExoticComponent<({ label, selection, minDate, maxDate, onValueChange }: Props) => import("react").JSX.Element>;
3
+ export default _default;
@@ -1,9 +1,9 @@
1
1
  import { memo, useCallback, useRef } from 'react';
2
2
  import { Pressable, StyleSheet } from 'react-native';
3
- import Table from '../../../../../../libs/table';
4
- import { useApp } from '../../../../../../libs/providers/App';
5
- import Formats from '../../../../../../libs/constants/formats';
6
- import Colors from '../../../../../../libs/constants/colors';
3
+ import Table from '../../../../../../../libs/table';
4
+ import { useApp } from '../../../../../../../libs/providers/App';
5
+ import Formats from '../../../../../../../libs/constants/formats';
6
+ import Colors from '../../../../../../../libs/constants/colors';
7
7
  export default memo(({ label, selection, minDate, maxDate, onValueChange, }) => {
8
8
  const { colorScheme } = useApp();
9
9
  const inputRef = useRef(null);
@@ -0,0 +1,3 @@
1
+ import type Props from '../types';
2
+ declare const _default: import("react").MemoExoticComponent<({ label, selection, minDate, maxDate, onValueChange, }: Props) => import("react").JSX.Element>;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import type Props from '../types';
2
+ declare const _default: import("react").MemoExoticComponent<({ label, selection, minDate, maxDate, onValueChange }: Props) => import("react").JSX.Element>;
3
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import { DatePicker } from '@expo/ui/swift-ui';
2
+ import { memo } from 'react';
3
+ import { environment } from '@expo/ui/swift-ui/modifiers';
4
+ export default memo(({ label, selection, minDate, maxDate, onValueChange }) => (<DatePicker title={label} selection={selection} onDateChange={onValueChange} modifiers={[environment('locale', 'es_ES')]} displayedComponents={['hourAndMinute']}/>));
@@ -0,0 +1,36 @@
1
+ import { memo, useCallback, useRef } from 'react';
2
+ import { Pressable, StyleSheet } from 'react-native';
3
+ import Table from '../../../../../../../libs/table';
4
+ import { useApp } from '../../../../../../../libs/providers/App';
5
+ import Formats from '../../../../../../../libs/constants/formats';
6
+ import Colors from '../../../../../../../libs/constants/colors';
7
+ export default memo(({ label, selection, minDate, maxDate, onValueChange, }) => {
8
+ const { colorScheme } = useApp();
9
+ const inputRef = useRef(null);
10
+ const _onValueChange = useCallback((value_str) => {
11
+ const [hours, minutes] = value_str.split(':').map(Number);
12
+ if (Number.isNaN(hours) || Number.isNaN(minutes))
13
+ return;
14
+ const value = new Date();
15
+ value.setHours(hours, minutes, 0, 0);
16
+ onValueChange?.(value);
17
+ }, []);
18
+ return (<Table.Option id={label ?? ''} colorScheme={colorScheme} childrenLeft={<Table.Option.Components.Text text={label ?? 'Seleccione una hora'}/>} childrenRight={(<>
19
+ <Pressable onPress={() => inputRef.current?.showPicker()} style={[styles.container, { backgroundColor: Colors.especiales.azul }]}>
20
+ <Table.Option.Components.Text text={Formats.dateToTextFormat(selection, 'HH:mm')} style={{ color: 'white', userSelect: 'none' }}/>
21
+ <input ref={inputRef} type="date" value={Formats.dateToTextFormat(selection, 'HH:mm')} onChange={(e) => _onValueChange(e.target.value)} style={{
22
+ all: 'unset',
23
+ visibility: 'hidden',
24
+ width: 0,
25
+ position: 'absolute'
26
+ }}/>
27
+ </Pressable>
28
+ </>)}/>);
29
+ });
30
+ const styles = StyleSheet.create({
31
+ container: {
32
+ padding: 7,
33
+ paddingHorizontal: 30,
34
+ borderRadius: 20
35
+ },
36
+ });
@@ -1,3 +1,3 @@
1
1
  import type Props from './types';
2
- declare const _default: import("react").MemoExoticComponent<({ itemKey, label, selection, defaultValue, minDate, maxDate, onValueChange, }: Props) => import("react").JSX.Element>;
2
+ declare const _default: import("react").MemoExoticComponent<({ itemKey, label, selection, defaultValue, minDate, maxDate, type, onValueChange, }: Props) => import("react").JSX.Element>;
3
3
  export default _default;
@@ -1,8 +1,9 @@
1
1
  import { memo, useCallback, useEffect, useRef, useState, useMemo } from 'react';
2
2
  import { usePage } from '../../context/page';
3
3
  import Hooks from '../../../../../libs/constants/hooks';
4
- import DatePicker from './DatePicker';
5
- export default memo(({ itemKey, label, selection, defaultValue, minDate, maxDate, onValueChange, }) => {
4
+ import DatePicker from './Picker/Date';
5
+ import TimePicker from './Picker/Time';
6
+ export default memo(({ itemKey, label, selection, defaultValue, minDate, maxDate, type = 'date', onValueChange, }) => {
6
7
  const { store, registerItem } = usePage();
7
8
  const [_selection, setSelection] = useState(selection);
8
9
  const currentDate = useMemo(() => _selection ?? defaultValue ?? new Date(), [_selection, defaultValue]);
@@ -34,5 +35,12 @@ export default memo(({ itemKey, label, selection, defaultValue, minDate, maxDate
34
35
  });
35
36
  onValueChange?.(value);
36
37
  }, []);
37
- return (<DatePicker label={label} selection={currentDateRanged} onValueChange={_onValueChange} minDate={minDate} maxDate={maxDate}/>);
38
+ const props = {
39
+ label: label,
40
+ selection: currentDateRanged,
41
+ onValueChange: _onValueChange,
42
+ minDate: minDate,
43
+ maxDate: maxDate,
44
+ };
45
+ return (type === 'date' ? <DatePicker {...props}/> : <TimePicker {...props}/>);
38
46
  });
@@ -1,4 +1,4 @@
1
- import DatePickerProps from './DatePicker/types';
1
+ import DatePickerProps from './Picker/types';
2
2
  type Props = Omit<DatePickerProps, 'selection'> & {
3
3
  /**
4
4
  identification key of the item.
@@ -13,5 +13,10 @@ type Props = Omit<DatePickerProps, 'selection'> & {
13
13
  Selection of the date picker.
14
14
  */
15
15
  selection?: Date;
16
+ /**
17
+ Type of the date picker.
18
+ @default 'date'
19
+ */
20
+ type?: 'date' | 'time';
16
21
  };
17
22
  export default Props;
@@ -0,0 +1,4 @@
1
+ import { DatePicker } from '@expo/ui/swift-ui';
2
+ import { memo } from 'react';
3
+ import { environment } from '@expo/ui/swift-ui/modifiers';
4
+ export default memo(({ label, selection, minDate, maxDate, onValueChange }) => (<DatePicker title={label} selection={selection} onDateChange={onValueChange} modifiers={[environment('locale', 'es_ES')]} displayedComponents={['hourAndMinute']}/>));
@@ -0,0 +1,36 @@
1
+ import { memo, useCallback, useRef } from 'react';
2
+ import { Pressable, StyleSheet } from 'react-native';
3
+ import Table from '../../../../../../libs/table';
4
+ import { useApp } from '../../../../../../libs/providers/App';
5
+ import Formats from '../../../../../../libs/constants/formats';
6
+ import Colors from '../../../../../../libs/constants/colors';
7
+ export default memo(({ label, selection, minDate, maxDate, onValueChange, }) => {
8
+ const { colorScheme } = useApp();
9
+ const inputRef = useRef(null);
10
+ const _onValueChange = useCallback((value_str) => {
11
+ const [hours, minutes] = value_str.split(':').map(Number);
12
+ if (Number.isNaN(hours) || Number.isNaN(minutes))
13
+ return;
14
+ const value = new Date();
15
+ value.setHours(hours, minutes, 0, 0);
16
+ onValueChange?.(value);
17
+ }, []);
18
+ return (<Table.Option id={label ?? ''} colorScheme={colorScheme} childrenLeft={<Table.Option.Components.Text text={label ?? 'Seleccione una hora'}/>} childrenRight={(<>
19
+ <Pressable onPress={() => inputRef.current?.showPicker()} style={[styles.container, { backgroundColor: Colors.especiales.azul }]}>
20
+ <Table.Option.Components.Text text={Formats.dateToTextFormat(selection, 'HH:mm')} style={{ color: 'white', userSelect: 'none' }}/>
21
+ <input ref={inputRef} type="date" value={Formats.dateToTextFormat(selection, 'HH:mm')} onChange={(e) => _onValueChange(e.target.value)} style={{
22
+ all: 'unset',
23
+ visibility: 'hidden',
24
+ width: 0,
25
+ position: 'absolute'
26
+ }}/>
27
+ </Pressable>
28
+ </>)}/>);
29
+ });
30
+ const styles = StyleSheet.create({
31
+ container: {
32
+ padding: 7,
33
+ paddingHorizontal: 30,
34
+ borderRadius: 20
35
+ },
36
+ });
@@ -0,0 +1,23 @@
1
+ type Props = {
2
+ /**
3
+ Title of the date picker.
4
+ */
5
+ label?: string;
6
+ /**
7
+ Selection of the date picker.
8
+ */
9
+ selection: Date;
10
+ /**
11
+ Minimum date allowed.
12
+ */
13
+ minDate?: Date;
14
+ /**
15
+ Maximum date allowed.
16
+ */
17
+ maxDate?: Date;
18
+ /**
19
+ Callback function to be called when the value changes.
20
+ */
21
+ onValueChange?: (value: Date) => void;
22
+ };
23
+ export default Props;
@@ -0,0 +1,3 @@
1
+ import type Props from './types';
2
+ declare const _default: import("react").MemoExoticComponent<({ itemKey, label, selection, defaultValue, minDate, maxDate, onValueChange, }: Props) => import("react").JSX.Element>;
3
+ export default _default;
@@ -0,0 +1,38 @@
1
+ import { memo, useCallback, useEffect, useRef, useState, useMemo } from 'react';
2
+ import { usePage } from '../../context/page';
3
+ import Hooks from '../../../../../libs/constants/hooks';
4
+ import DatePicker from './TimePicker';
5
+ export default memo(({ itemKey, label, selection, defaultValue, minDate, maxDate, onValueChange, }) => {
6
+ const { store, registerItem } = usePage();
7
+ const [_selection, setSelection] = useState(selection);
8
+ const currentDate = useMemo(() => _selection ?? defaultValue ?? new Date(), [_selection, defaultValue]);
9
+ const currentDateRanged = useMemo(() => {
10
+ if (maxDate && currentDate > maxDate)
11
+ return maxDate;
12
+ if (minDate && currentDate < minDate)
13
+ return minDate;
14
+ return currentDate;
15
+ }, [currentDate, minDate, maxDate]);
16
+ // Key
17
+ const keyRef = useRef(itemKey);
18
+ useEffect(() => {
19
+ keyRef.current = registerItem(itemKey);
20
+ _onValueChange(currentDate);
21
+ }, []);
22
+ // Hooks
23
+ useEffect(() => setSelection(selection), [selection]);
24
+ Hooks.useEffectWithoutFirstRender(() => {
25
+ setSelection(currentDateRanged);
26
+ _onValueChange(currentDateRanged);
27
+ }, [currentDateRanged]);
28
+ const _onValueChange = useCallback((value) => {
29
+ setSelection(value);
30
+ store.values[keyRef.current ?? 0].set({
31
+ value: value,
32
+ hasChanged: value.getTime() !== selection?.getTime(),
33
+ isValid: true,
34
+ });
35
+ onValueChange?.(value);
36
+ }, []);
37
+ return (<DatePicker label={label} selection={currentDateRanged} onValueChange={_onValueChange} minDate={minDate} maxDate={maxDate}/>);
38
+ });
@@ -0,0 +1,17 @@
1
+ import DatePickerProps from './TimePicker/types';
2
+ type Props = Omit<DatePickerProps, 'selection'> & {
3
+ /**
4
+ identification key of the item.
5
+ */
6
+ itemKey?: string;
7
+ /**
8
+ The value that applies when selection is undefined.
9
+ @default Date()
10
+ */
11
+ defaultValue?: Date;
12
+ /**
13
+ Selection of the date picker.
14
+ */
15
+ selection?: Date;
16
+ };
17
+ export default Props;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-pytech",
3
- "version": "1.0.190",
3
+ "version": "1.0.191",
4
4
  "description": "Libreria de React Native Pytech",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",