native-pytech 1.0.175 → 1.0.177

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,3 +1,3 @@
1
1
  import type Props from './types';
2
- declare const _default: import("react").MemoExoticComponent<({ itemKey, label, defaultValue, minDate, maxDate, }: Props) => import("react").JSX.Element>;
2
+ declare const _default: import("react").MemoExoticComponent<({ itemKey, label, defaultValue, minDate, maxDate, onValueChange, }: Props) => import("react").JSX.Element>;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import type Props from './types';
2
- declare const _default: import("react").MemoExoticComponent<({ itemKey, label, defaultValue, minDate, maxDate, }: Props) => import("react").JSX.Element>;
2
+ declare const _default: import("react").MemoExoticComponent<({ itemKey, label, defaultValue, minDate, maxDate, onValueChange, }: Props) => import("react").JSX.Element>;
3
3
  export default _default;
@@ -2,7 +2,7 @@ import { Section, DatePicker } from '@expo/ui/swift-ui';
2
2
  import { memo, useCallback, useEffect, useRef, useState } from 'react';
3
3
  import { environment } from '@expo/ui/swift-ui/modifiers';
4
4
  import { usePage } from '../../context/page';
5
- export default memo(({ itemKey, label, defaultValue, minDate = new Date(new Date().setFullYear(new Date().getFullYear() - 100)), maxDate = new Date(), }) => {
5
+ export default memo(({ itemKey, label, defaultValue, minDate, maxDate, onValueChange, }) => {
6
6
  const { store, registerItem } = usePage();
7
7
  const [selection, setSelection] = useState(defaultValue);
8
8
  // Key
@@ -12,16 +12,17 @@ export default memo(({ itemKey, label, defaultValue, minDate = new Date(new Date
12
12
  }, []);
13
13
  // Hooks
14
14
  useEffect(() => setSelection(defaultValue), [defaultValue]);
15
- const onValueChange = useCallback((value) => {
15
+ const _onValueChange = useCallback((value) => {
16
16
  setSelection(value);
17
17
  store.values[keyRef.current ?? 0].set({
18
18
  value: value,
19
19
  hasChanged: value.getTime() !== defaultValue?.getTime(),
20
20
  isValid: true,
21
21
  });
22
+ onValueChange?.(value);
22
23
  }, []);
23
24
  return (<Section>
24
- <DatePicker title={label} selection={selection} onDateChange={onValueChange} modifiers={[environment('locale', 'es_ES')]} range={{
25
+ <DatePicker title={label} selection={selection} onDateChange={_onValueChange} modifiers={[environment('locale', 'es_ES')]} range={{
25
26
  start: minDate,
26
27
  end: maxDate,
27
28
  }}/>
@@ -5,7 +5,7 @@ import { useApp } from '../../../../../libs/providers/App';
5
5
  import Formats from '../../../../../libs/constants/formats';
6
6
  import { usePage } from '../../context/page';
7
7
  import Colors from '../../../../../libs/constants/colors';
8
- export default memo(({ itemKey, label, defaultValue, minDate = new Date(new Date().setFullYear(new Date().getFullYear() - 100)), maxDate = new Date(), }) => {
8
+ export default memo(({ itemKey, label, defaultValue, minDate, maxDate, onValueChange, }) => {
9
9
  const { colorScheme } = useApp();
10
10
  const { store, registerItem } = usePage();
11
11
  const [selection, setSelection] = useState(defaultValue ?? new Date());
@@ -19,9 +19,9 @@ export default memo(({ itemKey, label, defaultValue, minDate = new Date(new Date
19
19
  useEffect(() => {
20
20
  setSelection(defaultValue ?? new Date());
21
21
  if (defaultValue === undefined)
22
- onValueChange(Formats.dateToTextFormat(selection, 'yyyy-MM-dd'));
22
+ _onValueChange(Formats.dateToTextFormat(selection, 'yyyy-MM-dd'));
23
23
  }, [defaultValue]);
24
- const onValueChange = useCallback((value_str) => {
24
+ const _onValueChange = useCallback((value_str) => {
25
25
  const [year, month, day] = value_str.split('-').map(Number);
26
26
  const value = new Date(year, month - 1, day);
27
27
  setSelection(value);
@@ -30,11 +30,12 @@ export default memo(({ itemKey, label, defaultValue, minDate = new Date(new Date
30
30
  hasChanged: value.getTime() !== defaultValue?.getTime(),
31
31
  isValid: true,
32
32
  });
33
+ onValueChange?.(value);
33
34
  }, []);
34
35
  return (<Table.Option id={label ?? ''} colorScheme={colorScheme} childrenLeft={<Table.Option.Components.Text text={label ?? 'Seleccione una fecha'}/>} childrenRight={(<>
35
36
  <Pressable onPress={() => inputRef.current?.showPicker()} style={[styles.container, { backgroundColor: Colors.especiales.azul }]}>
36
37
  <Table.Option.Components.Text text={Formats.dateToTextFormat(selection, 'dd/MM/yyyy')} style={{ color: 'white', userSelect: 'none' }}/>
37
- <input ref={inputRef} type="date" value={Formats.dateToTextFormat(selection, 'yyyy-MM-dd')} onChange={(e) => onValueChange(e.target.value)} style={{
38
+ <input ref={inputRef} type="date" value={Formats.dateToTextFormat(selection, 'yyyy-MM-dd')} onChange={(e) => _onValueChange(e.target.value)} style={{
38
39
  all: 'unset',
39
40
  visibility: 'hidden',
40
41
  width: 0,
@@ -13,13 +13,15 @@ type Props = {
13
13
  defaultValue?: Date;
14
14
  /**
15
15
  Minimum date allowed.
16
- @default 100 years ago
17
16
  */
18
17
  minDate?: Date;
19
18
  /**
20
19
  Maximum date allowed.
21
- @default today
22
20
  */
23
21
  maxDate?: Date;
22
+ /**
23
+ Callback function to be called when the value changes.
24
+ */
25
+ onValueChange?: (value: Date) => void;
24
26
  };
25
27
  export default Props;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-pytech",
3
- "version": "1.0.175",
3
+ "version": "1.0.177",
4
4
  "description": "Libreria de React Native Pytech",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",