native-pytech 1.0.100 → 1.0.102

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 (39) hide show
  1. package/dist/libs/swiftui/index.d.ts +1 -0
  2. package/dist/libs/swiftui/index.js +1 -0
  3. package/dist/libs/swiftui/src/components/Host.d.ts +6 -0
  4. package/dist/libs/swiftui/src/components/Host.js +5 -0
  5. package/package.json +1 -1
  6. package/dist/libs/editPage copy/index.d.ts +0 -9
  7. package/dist/libs/editPage copy/index.js +0 -7
  8. package/dist/libs/editPage copy/src/components/Item/index.d.ts +0 -4
  9. package/dist/libs/editPage copy/src/components/Item/index.ios.d.ts +0 -4
  10. package/dist/libs/editPage copy/src/components/Item/index.ios.js +0 -12
  11. package/dist/libs/editPage copy/src/components/Item/index.js +0 -1
  12. package/dist/libs/editPage copy/src/components/Item/types.d.ts +0 -14
  13. package/dist/libs/editPage copy/src/components/Item/types.js +0 -1
  14. package/dist/libs/editPage copy/src/components/ItemDate/index.d.ts +0 -4
  15. package/dist/libs/editPage copy/src/components/ItemDate/index.ios.d.ts +0 -4
  16. package/dist/libs/editPage copy/src/components/ItemDate/index.ios.js +0 -26
  17. package/dist/libs/editPage copy/src/components/ItemDate/index.js +0 -1
  18. package/dist/libs/editPage copy/src/components/ItemDate/types.d.ts +0 -21
  19. package/dist/libs/editPage copy/src/components/ItemDate/types.js +0 -1
  20. package/dist/libs/editPage copy/src/components/Screen/index.d.ts +0 -4
  21. package/dist/libs/editPage copy/src/components/Screen/index.ios.d.ts +0 -4
  22. package/dist/libs/editPage copy/src/components/Screen/index.ios.js +0 -8
  23. package/dist/libs/editPage copy/src/components/Screen/index.js +0 -1
  24. package/dist/libs/editPage copy/src/components/Screen/types.d.ts +0 -27
  25. package/dist/libs/editPage copy/src/components/Screen/types.js +0 -1
  26. package/dist/libs/editPage copy/src/components/TextField/index.d.ts +0 -4
  27. package/dist/libs/editPage copy/src/components/TextField/index.ios.d.ts +0 -4
  28. package/dist/libs/editPage copy/src/components/TextField/index.ios.js +0 -52
  29. package/dist/libs/editPage copy/src/components/TextField/index.js +0 -1
  30. package/dist/libs/editPage copy/src/components/TextField/types.d.ts +0 -28
  31. package/dist/libs/editPage copy/src/components/TextField/types.js +0 -1
  32. package/dist/libs/editPage copy/src/components/Wrapper/index.d.ts +0 -5
  33. package/dist/libs/editPage copy/src/components/Wrapper/index.js +0 -70
  34. package/dist/libs/editPage copy/src/components/Wrapper/types.d.ts +0 -27
  35. package/dist/libs/editPage copy/src/components/Wrapper/types.js +0 -1
  36. package/dist/libs/editPage copy/src/context/item.d.ts +0 -7
  37. package/dist/libs/editPage copy/src/context/item.js +0 -2
  38. package/dist/libs/editPage copy/src/context/page.d.ts +0 -18
  39. package/dist/libs/editPage copy/src/context/page.js +0 -2
@@ -1,4 +1,5 @@
1
1
  export { default as NavigationLink } from './src/components/NavigationLink';
2
+ export { default as Host } from './src/components/Host';
2
3
  export { default as Icon } from './src/components/Icon';
3
4
  export { default as IconSection } from './src/components/IconSection';
4
5
  export { default as List } from './src/components/List';
@@ -1,4 +1,5 @@
1
1
  export { default as NavigationLink } from './src/components/NavigationLink';
2
+ export { default as Host } from './src/components/Host';
2
3
  export { default as Icon } from './src/components/Icon';
3
4
  export { default as IconSection } from './src/components/IconSection';
4
5
  export { default as List } from './src/components/List';
@@ -0,0 +1,6 @@
1
+ import { HostProps } from '@expo/ui/swift-ui';
2
+ /**
3
+ Le pone el style "{ flex: 1 }" por defecto
4
+ */
5
+ declare const _default: ({ style, ...props }: HostProps) => import("react").JSX.Element;
6
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import { Host } from '@expo/ui/swift-ui';
2
+ /**
3
+ Le pone el style "{ flex: 1 }" por defecto
4
+ */
5
+ export default ({ style, ...props }) => (<Host style={[{ flex: 1 }, style]} {...props}/>);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-pytech",
3
- "version": "1.0.100",
3
+ "version": "1.0.102",
4
4
  "description": "Libreria de React Native Pytech",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,9 +0,0 @@
1
- import Wrapper from './src/components/Wrapper';
2
- import Item from './src/components/Item';
3
- import ItemDate from './src/components/ItemDate';
4
- type Component = typeof Wrapper & {
5
- Item: typeof Item;
6
- ItemDate: typeof ItemDate;
7
- };
8
- declare const Screen: Component;
9
- export default Screen;
@@ -1,7 +0,0 @@
1
- import Wrapper from './src/components/Wrapper';
2
- import Item from './src/components/Item';
3
- import ItemDate from './src/components/ItemDate';
4
- const Screen = Wrapper;
5
- Screen.Item = Item;
6
- Screen.ItemDate = ItemDate;
7
- export default Screen;
@@ -1,4 +0,0 @@
1
- declare const _default: ({ ...props }: {
2
- [x: string]: any;
3
- }) => any;
4
- export default _default;
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type Props from './types';
3
- declare const _default: React.MemoExoticComponent<({ label, minLengthSpacer, ...textFieldProps }: Props) => React.JSX.Element>;
4
- export default _default;
@@ -1,12 +0,0 @@
1
- import { HStack, Spacer, Text } from '@expo/ui/swift-ui';
2
- import React, { memo } from 'react';
3
- import TextField from '../TextField';
4
- export default memo(({ label, minLengthSpacer, ...textFieldProps }) => {
5
- if (!label)
6
- return <TextField {...textFieldProps}/>;
7
- return (<HStack>
8
- <Text>{label}</Text>
9
- <Spacer minLength={minLengthSpacer}/>
10
- <TextField {...textFieldProps}/>
11
- </HStack>);
12
- });
@@ -1 +0,0 @@
1
- export default ({ ...props }) => null;
@@ -1,14 +0,0 @@
1
- import type TextFieldProps from '../TextField/types';
2
- type Props = TextFieldProps & {
3
- /**
4
- Text to display on the left of the text field.
5
- If not provided, the item will be only a text field.
6
- */
7
- label?: string;
8
- /**
9
- Minimum length of the spacer between the title and the text field.
10
- If the title is not provided, will not be displayed.
11
- */
12
- minLengthSpacer?: number;
13
- };
14
- export default Props;
@@ -1,4 +0,0 @@
1
- declare const _default: ({ ...props }: {
2
- [x: string]: any;
3
- }) => any;
4
- export default _default;
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type Props from './types';
3
- declare const _default: React.MemoExoticComponent<({ label, defaultValue, minDate, maxDate }: Props) => React.JSX.Element>;
4
- export default _default;
@@ -1,26 +0,0 @@
1
- import { Section, DatePicker } from '@expo/ui/swift-ui';
2
- import React, { memo, useCallback, useEffect, useState } from 'react';
3
- import { environment } from '@expo/ui/swift-ui/modifiers';
4
- import { usePage } from '../../context/page';
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() }) => {
7
- const { store } = usePage();
8
- const { index } = useItem();
9
- const [selection, setSelection] = useState(defaultValue);
10
- // Hooks
11
- useEffect(() => setSelection(defaultValue), [defaultValue]);
12
- const onValueChange = useCallback((value) => {
13
- setSelection(value);
14
- store.values[index].set({
15
- value: value,
16
- hasChanged: value.getTime() !== defaultValue?.getTime(),
17
- isValid: true,
18
- });
19
- }, []);
20
- return (<Section>
21
- <DatePicker title={label} selection={selection} onDateChange={onValueChange} modifiers={[environment('locale', 'es_ES')]} range={{
22
- start: minDate,
23
- end: maxDate,
24
- }}/>
25
- </Section>);
26
- });
@@ -1 +0,0 @@
1
- export default ({ ...props }) => null;
@@ -1,21 +0,0 @@
1
- type Props = {
2
- /**
3
- Title of the date picker.
4
- */
5
- label?: string;
6
- /**
7
- Default value of the date picker.
8
- */
9
- defaultValue?: Date;
10
- /**
11
- Minimum date allowed.
12
- @default 100 years ago
13
- */
14
- minDate?: Date;
15
- /**
16
- Maximum date allowed.
17
- @default today
18
- */
19
- maxDate?: Date;
20
- };
21
- export default Props;
@@ -1,4 +0,0 @@
1
- declare const _default: ({ children }: {
2
- children: React.ReactNode;
3
- }) => any;
4
- export default _default;
@@ -1,4 +0,0 @@
1
- declare const _default: ({ children }: {
2
- children: React.ReactNode;
3
- }) => import("react").JSX.Element;
4
- export default _default;
@@ -1,8 +0,0 @@
1
- import { Host, List, Section } from '@expo/ui/swift-ui';
2
- export default ({ children }) => (<Host style={{ flex: 1 }}>
3
- <List>
4
- <Section>
5
- {children}
6
- </Section>
7
- </List>
8
- </Host>);
@@ -1 +0,0 @@
1
- export default ({ children }) => null;
@@ -1,27 +0,0 @@
1
- type Props<T> = {
2
- /**
3
- The data items to be rendered inside the list.
4
- @default []
5
- */
6
- data?: T[];
7
- /**
8
- The function to render the item.
9
- */
10
- renderItem?: (item: T) => React.ReactNode;
11
- /**
12
- Function to be called when the user saves the changes.
13
- If the function returns false, the user will not be redirected to the previous screen.
14
- */
15
- onSave?: (values: (string | null | Date)[]) => boolean | Promise<boolean>;
16
- };
17
- export type Value = {
18
- value: string | null | Date | undefined;
19
- hasChanged: boolean;
20
- isValid: boolean;
21
- };
22
- export type Values = Record<number, Value>;
23
- export type Store = {
24
- values: Values;
25
- saveEnabled: boolean;
26
- };
27
- export default Props;
@@ -1,4 +0,0 @@
1
- declare const _default: ({ ...props }: {
2
- [x: string]: any;
3
- }) => any;
4
- export default _default;
@@ -1,4 +0,0 @@
1
- import React from "react";
2
- import type Props from './types';
3
- declare const _default: React.MemoExoticComponent<({ defaultValue, placeholder, keyboardType, autocapitalization, secureTextEntry, isValid, }: Props) => React.JSX.Element>;
4
- export default _default;
@@ -1,52 +0,0 @@
1
- import React, { useMemo, memo, useRef, useCallback, useEffect } from "react";
2
- import { SecureField, TextField } from "@expo/ui/swift-ui";
3
- import { keyboardType as keyboardTypeModifier, submitLabel, textInputAutocapitalization, onSubmit } from '@expo/ui/swift-ui/modifiers';
4
- import { usePage } from '../../context/page';
5
- import { useItem } from '../../context/item';
6
- export default memo(({ defaultValue, placeholder, keyboardType, autocapitalization = true, secureTextEntry, isValid, }) => {
7
- const { store, isUniqueItem, saveEnabledRef, onPressSave, textFieldsRefs } = usePage();
8
- const { index, nextIndex } = useItem();
9
- const ref = useRef(null);
10
- textFieldsRefs.current[index] = ref;
11
- useEffect(() => store.values[index].value.set(defaultValue), [defaultValue]);
12
- // onChange
13
- const onValueChange = useCallback((value) => {
14
- const _value = value.trim() === '' ? null : value.trim();
15
- store.values[index].set({
16
- value: _value,
17
- hasChanged: _value !== defaultValue,
18
- isValid: isValid?.(_value) ?? true,
19
- });
20
- }, []);
21
- const _onSubmit = useCallback(() => {
22
- // Guarda los cambios
23
- if (isUniqueItem) {
24
- const saveEnabled = saveEnabledRef.current;
25
- if (!saveEnabled)
26
- return;
27
- onPressSave();
28
- return;
29
- }
30
- // Va al siguiente campo
31
- if (!nextIndex)
32
- return;
33
- textFieldsRefs.current[nextIndex].current?.focus();
34
- }, []);
35
- // Props
36
- const modifiers = useMemo(() => [
37
- ...(isUniqueItem ? [submitLabel('done')] : []),
38
- ...(keyboardType ? [keyboardTypeModifier(keyboardType)] : []),
39
- ...(!autocapitalization ? [textInputAutocapitalization('never')] : []),
40
- onSubmit(_onSubmit),
41
- ], [keyboardType, autocapitalization, isUniqueItem]);
42
- const props = {
43
- autoFocus: isUniqueItem,
44
- modifiers,
45
- placeholder,
46
- defaultValue,
47
- onValueChange,
48
- };
49
- if (secureTextEntry)
50
- return <SecureField {...props} ref={ref}/>;
51
- return <TextField {...props} ref={ref}/>;
52
- });
@@ -1 +0,0 @@
1
- export default ({ ...props }) => null;
@@ -1,28 +0,0 @@
1
- type Props = {
2
- /**
3
- Default value of the text field.
4
- */
5
- defaultValue?: string;
6
- /**
7
- Placeholder of the text field.
8
- */
9
- placeholder?: string;
10
- /**
11
- Keyboard type. Uses the keyboardType modifier.
12
- */
13
- 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";
14
- /**
15
- If true, the text field will be autocapitalized. Uses the textInputAutocapitalization modifier.
16
- @default true
17
- */
18
- autocapitalization?: boolean;
19
- /**
20
- If true, the text field will be secure (password).
21
- */
22
- secureTextEntry?: boolean;
23
- /**
24
- Function to validate the value.
25
- */
26
- isValid?: (value: string | null) => boolean;
27
- };
28
- export default Props;
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import Props from './types';
3
- declare function Component<T>({ data, renderItem, onSave, }: Props<T>): React.JSX.Element;
4
- declare const _default: typeof Component;
5
- export default _default;
@@ -1,70 +0,0 @@
1
- import { useObservable, useValue } from '@legendapp/state/react';
2
- import { Stack, useRouter } from 'expo-router';
3
- import React, { memo, useCallback, useMemo, useRef } from 'react';
4
- import Hooks from '../../../../../libs/constants/hooks';
5
- import { Provider } from '../../context/page';
6
- import { Provider as ItemProvider } from '../../context/item';
7
- import Screen from '../Screen';
8
- function Component({ data = [], renderItem, onSave, }) {
9
- const router = useRouter();
10
- const saveEnabledRef = useRef(false);
11
- // Store
12
- const values = (data ?? []).reduce((acc, item, index) => {
13
- acc[index] = {
14
- value: undefined,
15
- hasChanged: false,
16
- isValid: true,
17
- };
18
- return acc;
19
- }, {});
20
- const store = useObservable({
21
- values: values,
22
- saveEnabled: () => {
23
- const listValues = Object.values(store.values.get());
24
- const hasChanged = listValues.some(value => value.hasChanged);
25
- const allValid = listValues.every(value => value.isValid);
26
- return hasChanged && allValid;
27
- },
28
- });
29
- const saveEnabled = useValue(() => store.saveEnabled.get());
30
- Hooks.useEffectWithoutFirstRender(() => saveEnabledRef.current = saveEnabled, [saveEnabled]);
31
- const textFieldsRefs = useRef({});
32
- // onPress
33
- const onPressSave = useCallback(async () => {
34
- // Obtengo los valores del store
35
- const values = store.values.peek();
36
- const valuesToSave = Object.values(values).map(value => value.value ?? null);
37
- // Llamo a la función onSave
38
- const result = await onSave?.(valuesToSave);
39
- if (result === false)
40
- return;
41
- router.back();
42
- }, [onSave, store.values]);
43
- const value = useMemo(() => ({ store, saveEnabledRef, onPressSave, isUniqueItem: (data?.length ?? 0) === 1, textFieldsRefs }), []);
44
- return (<>
45
- <Stack.Toolbar placement="left">
46
- <Stack.Toolbar.Button onPress={() => router.back()}>
47
- <Stack.Toolbar.Icon sf="xmark"/>
48
- </Stack.Toolbar.Button>
49
- </Stack.Toolbar>
50
-
51
- <Stack.Toolbar placement="right">
52
- <Stack.Toolbar.Button disabled={!saveEnabled} variant="done" onPress={onPressSave}>
53
- <Stack.Toolbar.Icon sf="checkmark"/>
54
- </Stack.Toolbar.Button>
55
- </Stack.Toolbar>
56
-
57
- <Screen>
58
- <Provider value={value}>
59
- {data.map((item, index) => {
60
- const nextIndex = index + 1;
61
- const value = { index, nextIndex: nextIndex < data.length ? nextIndex : undefined };
62
- return (<ItemProvider key={index} value={value}>
63
- {renderItem?.(item)}
64
- </ItemProvider>);
65
- })}
66
- </Provider>
67
- </Screen>
68
- </>);
69
- }
70
- export default memo(Component);
@@ -1,27 +0,0 @@
1
- type Props<T> = {
2
- /**
3
- The data items to be rendered inside the list.
4
- @default []
5
- */
6
- data?: T[];
7
- /**
8
- The function to render the item.
9
- */
10
- renderItem?: (item: T) => React.ReactNode;
11
- /**
12
- Function to be called when the user saves the changes.
13
- If the function returns false, the user will not be redirected to the previous screen.
14
- */
15
- onSave?: (values: (string | null | Date)[]) => boolean | Promise<boolean>;
16
- };
17
- export type Value = {
18
- value: string | null | Date | undefined;
19
- hasChanged: boolean;
20
- isValid: boolean;
21
- };
22
- export type Values = Record<number, Value>;
23
- export type Store = {
24
- values: Values;
25
- saveEnabled: boolean;
26
- };
27
- export default Props;
@@ -1,7 +0,0 @@
1
- export declare const Provider: import("react").Provider<{
2
- index: number;
3
- nextIndex?: number;
4
- }>, useItem: () => {
5
- index: number;
6
- nextIndex?: number;
7
- };
@@ -1,2 +0,0 @@
1
- import Utils from '../../../../libs/constants/utils';
2
- export const [Provider, useItem] = Utils.createCtx();
@@ -1,18 +0,0 @@
1
- import type { Observable } from '@legendapp/state';
2
- import { TextFieldRef } from '@expo/ui/swift-ui';
3
- import { RefObject } from 'react';
4
- import type { Store } from '../components/Wrapper/types';
5
- export type TextFieldsRefsType = Record<number, RefObject<TextFieldRef | null>>;
6
- export declare const Provider: import("react").Provider<{
7
- store: Observable<Store>;
8
- saveEnabledRef: RefObject<boolean>;
9
- onPressSave: () => Promise<void>;
10
- isUniqueItem: boolean;
11
- textFieldsRefs: RefObject<TextFieldsRefsType>;
12
- }>, usePage: () => {
13
- store: Observable<Store>;
14
- saveEnabledRef: RefObject<boolean>;
15
- onPressSave: () => Promise<void>;
16
- isUniqueItem: boolean;
17
- textFieldsRefs: RefObject<TextFieldsRefsType>;
18
- };
@@ -1,2 +0,0 @@
1
- import Utils from '../../../../libs/constants/utils';
2
- export const [Provider, usePage] = Utils.createCtx();