react-crud-mobile 1.0.673 → 1.0.678
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.
- package/dist/elements/UI.d.ts +2 -11
- package/dist/react-crud-mobile.cjs.development.js +13 -1
- package/dist/react-crud-mobile.cjs.development.js.map +1 -1
- package/dist/react-crud-mobile.cjs.production.min.js +1 -1
- package/dist/react-crud-mobile.cjs.production.min.js.map +1 -1
- package/dist/react-crud-mobile.esm.js +14 -2
- package/dist/react-crud-mobile.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/elements/UI.tsx +15 -11
- package/src/elements/core/SafeView.tsx +7 -2
- package/src/elements/core/UIAutoComplete.tsx +17 -17
- package/src/elements/core/UIIcon.tsx +20 -3
- package/src/elements/core/UILink.tsx +17 -17
- package/src/elements/core/UIListItem.tsx +32 -32
- package/src/elements/core/UIOption.tsx +17 -17
- package/src/elements/core/UIRadio.tsx +17 -17
- package/src/elements/core/UISwitch.tsx +27 -27
- package/src/hooks/useIsVisible.ts +39 -39
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.678",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"description": "Uma biblioteca de componentes para React Native",
|
|
5
5
|
"main": "dist/index.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@react-native-vector-icons/ionicons": "^7.4.0",
|
|
45
45
|
"@react-native-vector-icons/material-icons": "^0.0.1",
|
|
46
46
|
"react": "19.0.0",
|
|
47
|
-
"react-crud-utils": "^0.1.
|
|
47
|
+
"react-crud-utils": "^0.1.268",
|
|
48
48
|
"react-dom": "19.0.0",
|
|
49
49
|
"react-native": "0.79.2",
|
|
50
50
|
"react-native-gesture-handler": "~2.24.0",
|
package/src/elements/UI.tsx
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import {
|
|
2
|
+
ListType,
|
|
3
|
+
UserType,
|
|
4
|
+
InputType,
|
|
5
|
+
ChartType,
|
|
6
|
+
ContainerType,
|
|
7
|
+
ListInputType,
|
|
8
|
+
TabsType,
|
|
9
|
+
DefineType,
|
|
10
|
+
ButtonType,
|
|
11
|
+
IconType,
|
|
12
|
+
LinkType,
|
|
13
|
+
} from 'react-crud-utils';
|
|
7
14
|
import UIElement from './UIElement';
|
|
8
|
-
|
|
9
|
-
import { DefineType } from 'react-crud-utils';
|
|
10
|
-
import { ButtonType } from 'react-crud-utils';
|
|
11
|
-
import { LinkType } from 'react-crud-utils';
|
|
15
|
+
|
|
12
16
|
import UIInclude from './core/UIInclude';
|
|
13
17
|
import SafeView from './core/SafeView';
|
|
14
18
|
|
|
@@ -30,7 +34,7 @@ const UI = {
|
|
|
30
34
|
Email: (props: InputType) => <UIElement {...props} type="email" />,
|
|
31
35
|
Button: (props: ButtonType) => <UIElement {...props} type="button" />,
|
|
32
36
|
Link: (props: LinkType) => <UIElement {...props} type="link" />,
|
|
33
|
-
Icon: (props:
|
|
37
|
+
Icon: (props: IconType) => <UIElement {...props} type="icon" />,
|
|
34
38
|
Output: (props: ContainerType) => <UIElement {...props} type="output" />,
|
|
35
39
|
Form: (props: ContainerType) => <UIElement {...props} type="form" />,
|
|
36
40
|
Crud: (props: ContainerType) => <UIElement {...props} type="crud" />,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
SafeAreaProvider,
|
|
12
12
|
SafeAreaView as SafeAreaContextView,
|
|
13
13
|
} from 'react-native-safe-area-context';
|
|
14
|
-
import { ThemeUtils, useTheme } from 'react-crud-utils';
|
|
14
|
+
import { ThemeUtils, useTheme, Utils } from 'react-crud-utils';
|
|
15
15
|
import { useEffect } from 'react';
|
|
16
16
|
|
|
17
17
|
interface SafeViewType {
|
|
@@ -21,7 +21,12 @@ interface SafeViewType {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export default function SafeView(props: SafeViewType) {
|
|
24
|
-
|
|
24
|
+
let theme = ThemeUtils.getCurrentTheme();
|
|
25
|
+
|
|
26
|
+
if (Utils.isEmpty(theme)) {
|
|
27
|
+
theme = useTheme();
|
|
28
|
+
}
|
|
29
|
+
|
|
25
30
|
const dismissKeyboard = () => {
|
|
26
31
|
if (Platform.OS !== 'web') {
|
|
27
32
|
Keyboard.dismiss();
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
|
|
2
|
-
|
|
3
|
-
export default function UIAutoComplete(props: any) {
|
|
4
|
-
const handlePress = () => {
|
|
5
|
-
Linking.openURL('https://reactnative.dev/');
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<TouchableOpacity onPress={handlePress}>
|
|
10
|
-
<Text style={styles.link}>Clique aqui para acessar o React Native</Text>
|
|
11
|
-
</TouchableOpacity>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const styles = {
|
|
16
|
-
link: {},
|
|
17
|
-
};
|
|
1
|
+
import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export default function UIAutoComplete(props: any) {
|
|
4
|
+
const handlePress = () => {
|
|
5
|
+
Linking.openURL('https://reactnative.dev/');
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<TouchableOpacity onPress={handlePress}>
|
|
10
|
+
<Text style={styles.link}>Clique aqui para acessar o React Native</Text>
|
|
11
|
+
</TouchableOpacity>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const styles = {
|
|
16
|
+
link: {},
|
|
17
|
+
};
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Ionicons,
|
|
3
|
+
MaterialCommunityIcons,
|
|
4
|
+
AntDesign,
|
|
5
|
+
Entypo,
|
|
6
|
+
EvilIcons,
|
|
7
|
+
} from '@expo/vector-icons';
|
|
8
|
+
|
|
9
|
+
import { ChildType, Utils } from 'react-crud-utils';
|
|
3
10
|
|
|
4
11
|
export default function UIIcon({ scope }: ChildType) {
|
|
5
12
|
let name = scope.getValue();
|
|
13
|
+
let libs: any = {
|
|
14
|
+
ion: Ionicons,
|
|
15
|
+
ant: AntDesign,
|
|
16
|
+
entypo: Entypo,
|
|
17
|
+
evil: EvilIcons,
|
|
18
|
+
material: MaterialCommunityIcons,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
let library = Utils.nvl(scope.original.library, 'ion');
|
|
22
|
+
let Aux = libs[library];
|
|
6
23
|
|
|
7
|
-
return <
|
|
24
|
+
return <Aux name={name} style={scope.getStyle('icon')} />;
|
|
8
25
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
|
|
2
|
-
|
|
3
|
-
export default function UILink(props: any) {
|
|
4
|
-
const handlePress = () => {
|
|
5
|
-
Linking.openURL('https://reactnative.dev/');
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<TouchableOpacity onPress={handlePress}>
|
|
10
|
-
<Text style={styles.link}>Clique aqui para acessar o React Native</Text>
|
|
11
|
-
</TouchableOpacity>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const styles = {
|
|
16
|
-
link: {},
|
|
17
|
-
};
|
|
1
|
+
import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export default function UILink(props: any) {
|
|
4
|
+
const handlePress = () => {
|
|
5
|
+
Linking.openURL('https://reactnative.dev/');
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<TouchableOpacity onPress={handlePress}>
|
|
10
|
+
<Text style={styles.link}>Clique aqui para acessar o React Native</Text>
|
|
11
|
+
</TouchableOpacity>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const styles = {
|
|
16
|
+
link: {},
|
|
17
|
+
};
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { ChildType, Utils } from 'react-crud-utils';
|
|
3
|
-
import { FlatList, StyleSheet, Switch, Text, View } from 'react-native';
|
|
4
|
-
|
|
5
|
-
interface UIListItemType extends ChildType {
|
|
6
|
-
data: any;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export default function UIListItem(props: UIListItemType) {
|
|
10
|
-
const scope = props.scope;
|
|
11
|
-
const crud = props.crud;
|
|
12
|
-
|
|
13
|
-
return <View style={styles.item}></View>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const styles = StyleSheet.create({
|
|
17
|
-
container: {
|
|
18
|
-
flex: 1,
|
|
19
|
-
padding: 20,
|
|
20
|
-
backgroundColor: '#fff',
|
|
21
|
-
},
|
|
22
|
-
item: {
|
|
23
|
-
padding: 15,
|
|
24
|
-
marginVertical: 8,
|
|
25
|
-
backgroundColor: '#f9c2ff',
|
|
26
|
-
borderRadius: 8,
|
|
27
|
-
},
|
|
28
|
-
text: {
|
|
29
|
-
fontSize: 18,
|
|
30
|
-
fontWeight: 'bold',
|
|
31
|
-
},
|
|
32
|
-
});
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { ChildType, Utils } from 'react-crud-utils';
|
|
3
|
+
import { FlatList, StyleSheet, Switch, Text, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
interface UIListItemType extends ChildType {
|
|
6
|
+
data: any;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default function UIListItem(props: UIListItemType) {
|
|
10
|
+
const scope = props.scope;
|
|
11
|
+
const crud = props.crud;
|
|
12
|
+
|
|
13
|
+
return <View style={styles.item}></View>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const styles = StyleSheet.create({
|
|
17
|
+
container: {
|
|
18
|
+
flex: 1,
|
|
19
|
+
padding: 20,
|
|
20
|
+
backgroundColor: '#fff',
|
|
21
|
+
},
|
|
22
|
+
item: {
|
|
23
|
+
padding: 15,
|
|
24
|
+
marginVertical: 8,
|
|
25
|
+
backgroundColor: '#f9c2ff',
|
|
26
|
+
borderRadius: 8,
|
|
27
|
+
},
|
|
28
|
+
text: {
|
|
29
|
+
fontSize: 18,
|
|
30
|
+
fontWeight: 'bold',
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
|
|
2
|
-
|
|
3
|
-
export default function UIOption(props: any) {
|
|
4
|
-
const handlePress = () => {
|
|
5
|
-
Linking.openURL('https://reactnative.dev/');
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<TouchableOpacity onPress={handlePress}>
|
|
10
|
-
<Text style={styles.link}>Clique aqui para acessar o React Native</Text>
|
|
11
|
-
</TouchableOpacity>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const styles = {
|
|
16
|
-
link: {},
|
|
17
|
-
};
|
|
1
|
+
import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export default function UIOption(props: any) {
|
|
4
|
+
const handlePress = () => {
|
|
5
|
+
Linking.openURL('https://reactnative.dev/');
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<TouchableOpacity onPress={handlePress}>
|
|
10
|
+
<Text style={styles.link}>Clique aqui para acessar o React Native</Text>
|
|
11
|
+
</TouchableOpacity>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const styles = {
|
|
16
|
+
link: {},
|
|
17
|
+
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
|
|
2
|
-
|
|
3
|
-
export default function UIRadio(props: any) {
|
|
4
|
-
const handlePress = () => {
|
|
5
|
-
Linking.openURL('https://reactnative.dev/');
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<TouchableOpacity onPress={handlePress}>
|
|
10
|
-
<Text style={styles.link}>Clique aqui para acessar o React Native</Text>
|
|
11
|
-
</TouchableOpacity>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const styles = {
|
|
16
|
-
link: {},
|
|
17
|
-
};
|
|
1
|
+
import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export default function UIRadio(props: any) {
|
|
4
|
+
const handlePress = () => {
|
|
5
|
+
Linking.openURL('https://reactnative.dev/');
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<TouchableOpacity onPress={handlePress}>
|
|
10
|
+
<Text style={styles.link}>Clique aqui para acessar o React Native</Text>
|
|
11
|
+
</TouchableOpacity>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const styles = {
|
|
16
|
+
link: {},
|
|
17
|
+
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { ChildType, Utils } from 'react-crud-utils';
|
|
3
|
-
import { Switch } from 'react-native';
|
|
4
|
-
|
|
5
|
-
export default function UISwitch(props: ChildType) {
|
|
6
|
-
const scope = props.scope;
|
|
7
|
-
const initial = Utils.nvl(scope.getValue(), false) as boolean;
|
|
8
|
-
const [value, setValue] = useState(initial);
|
|
9
|
-
|
|
10
|
-
let onChange = v => {
|
|
11
|
-
scope.changeValue(v);
|
|
12
|
-
|
|
13
|
-
setValue(v);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<Switch
|
|
18
|
-
value={value}
|
|
19
|
-
style={scope.getStyle('element')}
|
|
20
|
-
onValueChange={onChange} // Alterna o estado
|
|
21
|
-
/>
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const styles = {
|
|
26
|
-
link: {},
|
|
27
|
-
};
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { ChildType, Utils } from 'react-crud-utils';
|
|
3
|
+
import { Switch } from 'react-native';
|
|
4
|
+
|
|
5
|
+
export default function UISwitch(props: ChildType) {
|
|
6
|
+
const scope = props.scope;
|
|
7
|
+
const initial = Utils.nvl(scope.getValue(), false) as boolean;
|
|
8
|
+
const [value, setValue] = useState(initial);
|
|
9
|
+
|
|
10
|
+
let onChange = v => {
|
|
11
|
+
scope.changeValue(v);
|
|
12
|
+
|
|
13
|
+
setValue(v);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Switch
|
|
18
|
+
value={value}
|
|
19
|
+
style={scope.getStyle('element')}
|
|
20
|
+
onValueChange={onChange} // Alterna o estado
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const styles = {
|
|
26
|
+
link: {},
|
|
27
|
+
};
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import { Scope } from 'react-crud-utils';
|
|
3
|
-
import { Dimensions, Platform } from 'react-native';
|
|
4
|
-
|
|
5
|
-
export function useIsVisible(ref: any, scope: Scope) {
|
|
6
|
-
const [isVisible, setIsVisible] = useState(scope.visible === true);
|
|
7
|
-
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
const checkVisibility = () => {
|
|
10
|
-
if (!ref.current || isVisible || !scope.original?.useIsInView) return;
|
|
11
|
-
|
|
12
|
-
if (Platform.OS === 'web') {
|
|
13
|
-
const rect = ref.current.getBoundingClientRect?.();
|
|
14
|
-
|
|
15
|
-
if (rect && typeof window !== 'undefined') {
|
|
16
|
-
const windowHeight = window.innerHeight;
|
|
17
|
-
const visible = rect.top < windowHeight && rect.bottom > 0;
|
|
18
|
-
|
|
19
|
-
if (visible) scope.visible = visible;
|
|
20
|
-
|
|
21
|
-
setIsVisible(visible);
|
|
22
|
-
}
|
|
23
|
-
} else {
|
|
24
|
-
ref.current.measureInWindow?.((x, y, width, height) => {
|
|
25
|
-
const windowHeight = Dimensions.get('window').height;
|
|
26
|
-
const visible = y < windowHeight && y + height > 0;
|
|
27
|
-
|
|
28
|
-
if (visible) scope.visible = visible;
|
|
29
|
-
setIsVisible(visible);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const interval = setInterval(checkVisibility, 300); // roda a cada 300ms
|
|
35
|
-
return () => clearInterval(interval);
|
|
36
|
-
}, [ref]);
|
|
37
|
-
|
|
38
|
-
return isVisible;
|
|
39
|
-
}
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { Scope } from 'react-crud-utils';
|
|
3
|
+
import { Dimensions, Platform } from 'react-native';
|
|
4
|
+
|
|
5
|
+
export function useIsVisible(ref: any, scope: Scope) {
|
|
6
|
+
const [isVisible, setIsVisible] = useState(scope.visible === true);
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const checkVisibility = () => {
|
|
10
|
+
if (!ref.current || isVisible || !scope.original?.useIsInView) return;
|
|
11
|
+
|
|
12
|
+
if (Platform.OS === 'web') {
|
|
13
|
+
const rect = ref.current.getBoundingClientRect?.();
|
|
14
|
+
|
|
15
|
+
if (rect && typeof window !== 'undefined') {
|
|
16
|
+
const windowHeight = window.innerHeight;
|
|
17
|
+
const visible = rect.top < windowHeight && rect.bottom > 0;
|
|
18
|
+
|
|
19
|
+
if (visible) scope.visible = visible;
|
|
20
|
+
|
|
21
|
+
setIsVisible(visible);
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
ref.current.measureInWindow?.((x, y, width, height) => {
|
|
25
|
+
const windowHeight = Dimensions.get('window').height;
|
|
26
|
+
const visible = y < windowHeight && y + height > 0;
|
|
27
|
+
|
|
28
|
+
if (visible) scope.visible = visible;
|
|
29
|
+
setIsVisible(visible);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const interval = setInterval(checkVisibility, 300); // roda a cada 300ms
|
|
35
|
+
return () => clearInterval(interval);
|
|
36
|
+
}, [ref]);
|
|
37
|
+
|
|
38
|
+
return isVisible;
|
|
39
|
+
}
|