native-pytech 1.0.141 → 1.0.143

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.
@@ -0,0 +1,3 @@
1
+ import Props from "./types";
2
+ declare const _default: import("react").MemoExoticComponent<({ saveEnabled, onPressSave }: Props) => import("react").JSX.Element>;
3
+ export default _default;
@@ -0,0 +1,17 @@
1
+ import { memo } from "react";
2
+ import { router, Stack } from "expo-router";
3
+ export default memo(({ saveEnabled, onPressSave }) => {
4
+ return (<>
5
+ <Stack.Toolbar placement="left">
6
+ <Stack.Toolbar.Button onPress={() => router.back()}>
7
+ <Stack.Toolbar.Icon sf="xmark"/>
8
+ </Stack.Toolbar.Button>
9
+ </Stack.Toolbar>
10
+
11
+ <Stack.Toolbar placement="right">
12
+ <Stack.Toolbar.Button disabled={!saveEnabled} variant="done" onPress={onPressSave}>
13
+ <Stack.Toolbar.Icon sf="checkmark"/>
14
+ </Stack.Toolbar.Button>
15
+ </Stack.Toolbar>
16
+ </>);
17
+ });
@@ -0,0 +1,3 @@
1
+ import Props from "./types";
2
+ declare const _default: import("react").MemoExoticComponent<({ saveEnabled, onPressSave }: Props) => import("react").JSX.Element>;
3
+ export default _default;
@@ -0,0 +1,17 @@
1
+ import { memo } from "react";
2
+ import { Stack } from "expo-router";
3
+ import { Pressable, StyleSheet } from "react-native";
4
+ import { Ionicons } from "@expo/vector-icons";
5
+ import Colors from "../../../../../libs/constants/colors";
6
+ export default memo(({ saveEnabled, onPressSave }) => {
7
+ return (<Stack.Screen options={{
8
+ headerRight: () => (<Pressable disabled={!saveEnabled} onPress={onPressSave} style={[styles.pressable, { opacity: saveEnabled ? 1 : 0.5 }]}>
9
+ <Ionicons name="checkmark" size={24} color={Colors.especiales.azul}/>
10
+ </Pressable>)
11
+ }}/>);
12
+ });
13
+ const styles = StyleSheet.create({
14
+ pressable: {
15
+ padding: 10,
16
+ }
17
+ });
@@ -0,0 +1,5 @@
1
+ type Props = {
2
+ saveEnabled: boolean;
3
+ onPressSave: () => Promise<void>;
4
+ };
5
+ export default Props;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,3 @@
1
1
  import type Props from './types';
2
- declare const _default: ({ ...props }: Props) => null;
2
+ declare const _default: import("react").MemoExoticComponent<({ label, minLengthSpacer, placeholder, ...textFieldProps }: Props) => import("react").JSX.Element>;
3
3
  export default _default;
@@ -1 +1,8 @@
1
- export default ({ ...props }) => null;
1
+ import { memo } from 'react';
2
+ import Table from '../../../../../libs/table';
3
+ import { useApp } from '../../../../../libs/providers/App';
4
+ import TextField from '../TextField';
5
+ export default memo(({ label, minLengthSpacer, placeholder, ...textFieldProps }) => {
6
+ const { colorScheme } = useApp();
7
+ return (<Table.Option id={label ?? ''} colorScheme={colorScheme} childrenLeft={label ? <Table.Option.Components.Text text={label}/> : <Table.Option.Components.Text text={placeholder ?? ''}/>} childrenRight={<TextField placeholder={label ? placeholder : undefined} {...textFieldProps}/>}/>);
8
+ });
@@ -1,3 +1,3 @@
1
1
  import type Props from './types';
2
- declare const _default: ({ ...props }: Props) => null;
2
+ declare const _default: import("react").MemoExoticComponent<({ itemKey, label, defaultValue, minDate, maxDate, }: Props) => import("react").JSX.Element>;
3
3
  export default _default;
@@ -1 +1,48 @@
1
- export default ({ ...props }) => null;
1
+ import { memo, useCallback, useEffect, useRef, useState } 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 { usePage } from '../../context/page';
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(), }) => {
9
+ const { colorScheme } = useApp();
10
+ const { store, registerItem } = usePage();
11
+ const [selection, setSelection] = useState(defaultValue);
12
+ const inputRef = useRef(null);
13
+ // Key
14
+ const keyRef = useRef(itemKey);
15
+ useEffect(() => {
16
+ keyRef.current = registerItem(itemKey);
17
+ }, []);
18
+ // Hooks
19
+ useEffect(() => setSelection(defaultValue), [defaultValue]);
20
+ const onValueChange = useCallback((value_str) => {
21
+ const [year, month, day] = value_str.split('-').map(Number);
22
+ const value = new Date(year, month - 1, day);
23
+ setSelection(value);
24
+ store.values[keyRef.current ?? 0].set({
25
+ value: value,
26
+ hasChanged: value.getTime() !== defaultValue?.getTime(),
27
+ isValid: true,
28
+ });
29
+ }, []);
30
+ return (<Table.Option id={label ?? ''} colorScheme={colorScheme} childrenLeft={<Table.Option.Components.Text text={label ?? 'Seleccione una fecha'}/>} childrenRight={(<>
31
+ <Pressable onPress={() => inputRef.current?.showPicker()} style={[styles.container, { backgroundColor: Colors.especiales.azul }]}>
32
+ <Table.Option.Components.Text text={selection ? Formats.dateToTextFormat(selection, 'dd/MM/yyyy') : ''} style={{ color: 'white', userSelect: 'none' }}/>
33
+ <input ref={inputRef} type="date" value={selection ? Formats.dateToTextFormat(selection, 'yyyy-MM-dd') : ''} onChange={(e) => onValueChange(e.target.value)} style={{
34
+ all: 'unset',
35
+ visibility: 'hidden',
36
+ width: 0,
37
+ position: 'absolute'
38
+ }}/>
39
+ </Pressable>
40
+ </>)}/>);
41
+ });
42
+ const styles = StyleSheet.create({
43
+ container: {
44
+ padding: 10,
45
+ paddingHorizontal: 30,
46
+ borderRadius: 20
47
+ },
48
+ });
@@ -1,4 +1,4 @@
1
1
  declare const _default: ({ children }: {
2
2
  children: React.ReactNode;
3
- }) => null;
3
+ }) => import("react").JSX.Element;
4
4
  export default _default;
@@ -1 +1,7 @@
1
- export default ({ children }) => null;
1
+ import { ScrollView } from 'react-native';
2
+ import Table from '../../../../../libs/table';
3
+ export default ({ children }) => (<ScrollView showsVerticalScrollIndicator={false}>
4
+ <Table>
5
+ {children}
6
+ </Table>
7
+ </ScrollView>);
@@ -1,3 +1,3 @@
1
1
  import type Props from './types';
2
- declare const _default: ({ ...props }: Props) => null;
2
+ declare const _default: import("react").MemoExoticComponent<({ itemKey, defaultValue, placeholder, keyboardType, autocapitalization, secureTextEntry, isValid, }: Props) => import("react").JSX.Element>;
3
3
  export default _default;
@@ -1 +1,28 @@
1
- export default ({ ...props }) => null;
1
+ import { memo, useRef, useCallback, useEffect } from "react";
2
+ import { useValue } from "@legendapp/state/react";
3
+ import { useApp } from '../../../../../libs/providers/App';
4
+ import Table from '../../../../../libs/table';
5
+ import { usePage } from '../../context/page';
6
+ import Colors from '../../../../../libs/constants/colors';
7
+ export default memo(({ itemKey, defaultValue, placeholder, keyboardType, autocapitalization = true, secureTextEntry, isValid, }) => {
8
+ const { colorScheme } = useApp();
9
+ const { store, registerItem, onSubmit: _onSubmit } = usePage();
10
+ const isUniqueItem = useValue(() => store.isUniqueItem.get());
11
+ const ref = useRef(null);
12
+ // Key
13
+ const keyRef = useRef(itemKey ?? 0);
14
+ useEffect(() => {
15
+ keyRef.current = registerItem(itemKey, ref);
16
+ onValueChange(defaultValue ?? '');
17
+ }, []);
18
+ // onChange
19
+ const onValueChange = useCallback((value) => {
20
+ const _value = value.trim() === '' ? null : value.trim();
21
+ store.values[keyRef.current].set({
22
+ value: _value,
23
+ hasChanged: _value != defaultValue,
24
+ isValid: isValid?.(_value) ?? true,
25
+ });
26
+ }, []);
27
+ return <Table.Option.Components.TextInput onChangeText={onValueChange} value={defaultValue} placeholderTextColor={Colors[colorScheme].SearchBarText} placeholder={placeholder ?? defaultValue} keyboardType={keyboardType} autoFocus={isUniqueItem} autoCapitalize={!autocapitalization ? 'none' : undefined} secureTextEntry={secureTextEntry} onSubmitEditing={() => _onSubmit(keyRef.current)}/>;
28
+ });
@@ -14,7 +14,7 @@ type Props = {
14
14
  /**
15
15
  Keyboard type. Uses the keyboardType modifier.
16
16
  */
17
- keyboardType?: "default" | "email-address" | "numeric" | "phone-pad" | "ascii-capable" | "numbers-and-punctuation" | "url" | "name-phone-pad" | "decimal-pad" | "twitter" | "web-search" | "ascii-capable-number-pad";
17
+ keyboardType?: "default" | "email-address" | "numeric" | "phone-pad" | "ascii-capable" | "numbers-and-punctuation" | "url" | "name-phone-pad" | "decimal-pad" | "twitter" | "web-search";
18
18
  /**
19
19
  If true, the text field will be autocapitalized. Uses the textInputAutocapitalization modifier.
20
20
  @default true
@@ -1,8 +1,9 @@
1
1
  import { useObservable, useValue } from '@legendapp/state/react';
2
- import { Stack, router } from 'expo-router';
2
+ import { router } from 'expo-router';
3
3
  import { memo, useCallback, useMemo, useRef } from 'react';
4
4
  import { Provider } from '../../context/page';
5
5
  import Screen from '../Screen';
6
+ import Header from '../Header';
6
7
  export default memo(({ children, onSave }) => {
7
8
  const textFieldsRefs = useRef({});
8
9
  const indexRef = useRef(0);
@@ -21,6 +22,7 @@ export default memo(({ children, onSave }) => {
21
22
  },
22
23
  });
23
24
  const saveEnabled = useValue(() => store.saveEnabled.get());
25
+ console.log('saveEnabled', saveEnabled);
24
26
  // onPress
25
27
  const onPressSave = useCallback(async () => {
26
28
  // Obtengo los valores del store
@@ -50,10 +52,9 @@ export default memo(({ children, onSave }) => {
50
52
  textFieldsRefs.current[nextKey].current?.focus();
51
53
  };
52
54
  const onSubmit = async (itemKey) => {
53
- console.log('onSubmit', 'itemKey', itemKey);
54
55
  // Guarda los cambios
55
56
  if (store.isUniqueItem.peek()) {
56
- if (!saveEnabled)
57
+ if (!store.saveEnabled.peek())
57
58
  return;
58
59
  await onPressSave();
59
60
  return;
@@ -63,18 +64,7 @@ export default memo(({ children, onSave }) => {
63
64
  };
64
65
  const value = useMemo(() => ({ store, onSubmit, registerItem }), []);
65
66
  return (<>
66
- <Stack.Toolbar placement="left">
67
- <Stack.Toolbar.Button onPress={() => router.back()}>
68
- <Stack.Toolbar.Icon sf="xmark"/>
69
- </Stack.Toolbar.Button>
70
- </Stack.Toolbar>
71
-
72
- <Stack.Toolbar placement="right">
73
- <Stack.Toolbar.Button disabled={!saveEnabled} variant="done" onPress={onPressSave}>
74
- <Stack.Toolbar.Icon sf="checkmark"/>
75
- </Stack.Toolbar.Button>
76
- </Stack.Toolbar>
77
-
67
+ <Header saveEnabled={saveEnabled} onPressSave={onPressSave}/>
78
68
  <Screen>
79
69
  <Provider value={value}>
80
70
  {children}
@@ -49,7 +49,7 @@ const styles = StyleSheet.create({
49
49
  pressable: {
50
50
  backgroundColor: Colors.especiales.azul,
51
51
  padding: 10,
52
- borderRadius: 10
52
+ borderRadius: 20
53
53
  },
54
54
  label: {
55
55
  color: 'white',
@@ -16,5 +16,6 @@ const Component = memo(({ text, enabled = true, style = {}, colorScheme, fontSca
16
16
  const styles = StyleSheet.create({
17
17
  text: {
18
18
  fontSize: 17,
19
+ userSelect: 'none'
19
20
  }
20
21
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-pytech",
3
- "version": "1.0.141",
3
+ "version": "1.0.143",
4
4
  "description": "Libreria de React Native Pytech",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",