native-pytech 1.0.92 → 1.0.93

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
- import { type SpacerProps } from "@expo/ui/swift-ui";
2
1
  import type TextFieldProps from '../TextField/types';
3
2
  type Props = TextFieldProps & {
4
3
  /**
@@ -10,6 +9,6 @@ type Props = TextFieldProps & {
10
9
  Minimum length of the spacer between the title and the text field.
11
10
  If the title is not provided, will not be displayed.
12
11
  */
13
- minLengthSpacer?: SpacerProps['minLength'];
12
+ minLengthSpacer?: number;
14
13
  };
15
14
  export default Props;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import type Props from './types';
3
- declare const _default: React.MemoExoticComponent<({ label, defaultValue, minDate, maxDate, modifiers, ...restProps }: Props) => React.JSX.Element>;
3
+ declare const _default: React.MemoExoticComponent<({ label, defaultValue, minDate, maxDate }: Props) => React.JSX.Element>;
4
4
  export default _default;
@@ -1,20 +1,14 @@
1
1
  import { Section, DatePicker } from '@expo/ui/swift-ui';
2
- import React, { memo, useCallback, useEffect, useMemo, useState } from 'react';
2
+ import React, { memo, useCallback, useEffect, 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';
6
- export default memo(({ label, defaultValue, minDate = new Date(new Date().setFullYear(new Date().getFullYear() - 100)), maxDate = new Date(), modifiers, ...restProps }) => {
7
- // ------------------- Variables -------------------
6
+ export default memo(({ label, defaultValue, minDate = new Date(new Date().setFullYear(new Date().getFullYear() - 100)), maxDate = new Date() }) => {
8
7
  const { store } = usePage();
9
8
  const { index } = useItem();
10
9
  const [selection, setSelection] = useState(defaultValue);
11
- const _modifiers = useMemo(() => [
12
- ...(modifiers ?? []),
13
- environment('locale', 'es_ES'),
14
- ], [modifiers]);
15
- // ------------------- Hooks -------------------
10
+ // Hooks
16
11
  useEffect(() => setSelection(defaultValue), [defaultValue]);
17
- // -------------------- Functions --------------------
18
12
  const onValueChange = useCallback((value) => {
19
13
  setSelection(value);
20
14
  store.values[index].set({
@@ -24,9 +18,9 @@ export default memo(({ label, defaultValue, minDate = new Date(new Date().setFul
24
18
  });
25
19
  }, []);
26
20
  return (<Section>
27
- <DatePicker title={label} selection={selection} onDateChange={onValueChange} modifiers={_modifiers} range={{
21
+ <DatePicker title={label} selection={selection} onDateChange={onValueChange} modifiers={[environment('locale', 'es_ES')]} range={{
28
22
  start: minDate,
29
23
  end: maxDate,
30
- }} {...restProps}/>
24
+ }}/>
31
25
  </Section>);
32
26
  });
@@ -1,5 +1,4 @@
1
- import type { DatePickerProps } from '@expo/ui/swift-ui';
2
- type Props = Omit<DatePickerProps, 'title' | 'selection' | 'range' | 'onDateChange'> & {
1
+ type Props = {
3
2
  /**
4
3
  Title of the date picker.
5
4
  */
@@ -6,9 +6,9 @@ import Hooks from '../../../../../libs/constants/hooks';
6
6
  import { Provider } from '../../context/page';
7
7
  import { Provider as ItemProvider } from '../../context/item';
8
8
  function Component({ data = [], renderItem, onSave, }) {
9
- // ------------------- Variables -------------------
10
9
  const router = useRouter();
11
10
  const saveEnabledRef = useRef(false);
11
+ // Store
12
12
  const values = (data ?? []).reduce((acc, item, index) => {
13
13
  acc[index] = {
14
14
  value: undefined,
@@ -19,20 +19,17 @@ function Component({ data = [], renderItem, onSave, }) {
19
19
  }, {});
20
20
  const store = useObservable({
21
21
  values: values,
22
- saveEnabled: (() => {
23
- const values = store.values.get();
24
- const listValues = Object.values(values);
22
+ saveEnabled: () => {
23
+ const listValues = Object.values(store.values.get());
25
24
  const hasChanged = listValues.some(value => value.hasChanged);
26
25
  const allValid = listValues.every(value => value.isValid);
27
26
  return hasChanged && allValid;
28
- }),
27
+ },
29
28
  });
30
29
  const saveEnabled = useValue(() => store.saveEnabled.get());
31
- Hooks.useEffectWithoutFirstRender(() => {
32
- saveEnabledRef.current = saveEnabled;
33
- }, [saveEnabled]);
30
+ Hooks.useEffectWithoutFirstRender(() => saveEnabledRef.current = saveEnabled, [saveEnabled]);
34
31
  const textFieldsRefs = useRef({});
35
- // ------------------- Functions -------------------
32
+ // onPress
36
33
  const onPressSave = useCallback(async () => {
37
34
  // Obtengo los valores del store
38
35
  const values = store.values.peek();
@@ -43,14 +40,7 @@ function Component({ data = [], renderItem, onSave, }) {
43
40
  return;
44
41
  router.back();
45
42
  }, [onSave, store.values]);
46
- // ------------------- Provider -------------------
47
- const value = useMemo(() => ({
48
- store,
49
- saveEnabledRef,
50
- onPressSave,
51
- isUniqueItem: (data?.length ?? 0) === 1,
52
- textFieldsRefs
53
- }), []);
43
+ const value = useMemo(() => ({ store, saveEnabledRef, onPressSave, isUniqueItem: (data?.length ?? 0) === 1, textFieldsRefs }), []);
54
44
  return (<>
55
45
  <Stack.Toolbar placement="left">
56
46
  <Stack.Toolbar.Button onPress={() => router.back()}>
@@ -14,11 +14,12 @@ type Props<T> = {
14
14
  */
15
15
  onSave?: (values: (string | null | Date)[]) => boolean | Promise<boolean>;
16
16
  };
17
- export type Values = Record<number, {
17
+ export type Value = {
18
18
  value: string | null | Date | undefined;
19
19
  hasChanged: boolean;
20
20
  isValid: boolean;
21
- }>;
21
+ };
22
+ export type Values = Record<number, Value>;
22
23
  export type Store = {
23
24
  values: Values;
24
25
  saveEnabled: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-pytech",
3
- "version": "1.0.92",
3
+ "version": "1.0.93",
4
4
  "description": "Libreria de React Native Pytech",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",