native-pytech 1.0.96 → 1.0.98

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,4 +1,3 @@
1
- declare const _default: ({ ...props }: {
2
- [x: string]: any;
3
- }) => any;
1
+ import type Props from './types';
2
+ declare const _default: ({ ...props }: Props) => any;
4
3
  export default _default;
@@ -1,4 +1,3 @@
1
- declare const _default: ({ ...props }: {
2
- [x: string]: any;
3
- }) => any;
1
+ import type Props from './types';
2
+ declare const _default: ({ ...props }: Props) => any;
4
3
  export default _default;
@@ -1,16 +1,20 @@
1
1
  import { Section, DatePicker } from '@expo/ui/swift-ui';
2
- import React, { memo, useCallback, useEffect, useState } from 'react';
2
+ import React, { 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
5
  export default memo(({ itemKey, label, defaultValue, minDate = new Date(new Date().setFullYear(new Date().getFullYear() - 100)), maxDate = new Date(), }) => {
6
6
  const { store, registerItem } = usePage();
7
- const key = registerItem(itemKey);
8
7
  const [selection, setSelection] = useState(defaultValue);
8
+ // Key
9
+ const keyRef = useRef(itemKey);
10
+ useEffect(() => {
11
+ keyRef.current = registerItem(itemKey);
12
+ }, []);
9
13
  // Hooks
10
14
  useEffect(() => setSelection(defaultValue), [defaultValue]);
11
15
  const onValueChange = useCallback((value) => {
12
16
  setSelection(value);
13
- store.values[key].set({
17
+ store.values[keyRef.current].set({
14
18
  value: value,
15
19
  hasChanged: value.getTime() !== defaultValue?.getTime(),
16
20
  isValid: true,
@@ -1,4 +1,3 @@
1
- declare const _default: ({ ...props }: {
2
- [x: string]: any;
3
- }) => any;
1
+ import type Props from './types';
2
+ declare const _default: ({ ...props }: Props) => any;
4
3
  export default _default;
@@ -7,13 +7,16 @@ export default memo(({ itemKey, defaultValue, placeholder, keyboardType, autocap
7
7
  const { store, registerItem, onSubmit: _onSubmit } = usePage();
8
8
  const isUniqueItem = useValue(() => store.isUniqueItem.get());
9
9
  const ref = useRef(null);
10
- const key = registerItem(itemKey, ref);
11
- console.log(placeholder, 'key', key);
12
- useEffect(() => store.values[key].value.set(defaultValue), [defaultValue]);
10
+ // Key
11
+ const keyRef = useRef(itemKey);
12
+ console.log('keyRef', keyRef.current);
13
+ useEffect(() => {
14
+ keyRef.current = registerItem(itemKey, ref);
15
+ }, []);
13
16
  // onChange
14
17
  const onValueChange = useCallback((value) => {
15
18
  const _value = value.trim() === '' ? null : value.trim();
16
- store.values[key].set({
19
+ store.values[keyRef.current].set({
17
20
  value: _value,
18
21
  hasChanged: _value !== defaultValue,
19
22
  isValid: isValid?.(_value) ?? true,
@@ -24,7 +27,7 @@ export default memo(({ itemKey, defaultValue, placeholder, keyboardType, autocap
24
27
  ...(isUniqueItem ? [submitLabel('done')] : []),
25
28
  ...(keyboardType ? [keyboardTypeModifier(keyboardType)] : []),
26
29
  ...(!autocapitalization ? [textInputAutocapitalization('never')] : []),
27
- onSubmit(() => _onSubmit(key)),
30
+ onSubmit(() => _onSubmit(keyRef.current)),
28
31
  ], [keyboardType, autocapitalization, isUniqueItem]);
29
32
  const props = { autoFocus: isUniqueItem, modifiers, placeholder, defaultValue, onValueChange };
30
33
  if (secureTextEntry)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-pytech",
3
- "version": "1.0.96",
3
+ "version": "1.0.98",
4
4
  "description": "Libreria de React Native Pytech",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",