react-crud-mobile 1.0.392 → 1.0.394

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 (32) hide show
  1. package/dist/react-crud-mobile.cjs.development.js +15 -3
  2. package/dist/react-crud-mobile.cjs.development.js.map +1 -1
  3. package/dist/react-crud-mobile.cjs.production.min.js +1 -1
  4. package/dist/react-crud-mobile.cjs.production.min.js.map +1 -1
  5. package/dist/react-crud-mobile.esm.js +15 -3
  6. package/dist/react-crud-mobile.esm.js.map +1 -1
  7. package/package.json +71 -71
  8. package/src/elements/UI.tsx +65 -65
  9. package/src/elements/UIChildren.tsx +126 -126
  10. package/src/elements/UIComplete.tsx +14 -14
  11. package/src/elements/UIElement.tsx +496 -496
  12. package/src/elements/UITag.tsx +13 -13
  13. package/src/elements/charts/ElChart.tsx +10 -10
  14. package/src/elements/core/UIAutoComplete.tsx +17 -17
  15. package/src/elements/core/UIButton.tsx +73 -73
  16. package/src/elements/core/UIIcon.tsx +17 -17
  17. package/src/elements/core/UIInclude.tsx +40 -40
  18. package/src/elements/core/UIInput.tsx +69 -69
  19. package/src/elements/core/UILink.tsx +17 -17
  20. package/src/elements/core/UIList.tsx +117 -102
  21. package/src/elements/core/UIListItem.tsx +32 -32
  22. package/src/elements/core/UIListRow.tsx +29 -29
  23. package/src/elements/core/UIModal.tsx +111 -111
  24. package/src/elements/core/UIOption.tsx +17 -17
  25. package/src/elements/core/UIQuantity.tsx +97 -97
  26. package/src/elements/core/UIRadio.tsx +17 -17
  27. package/src/elements/core/UISelect.tsx +122 -122
  28. package/src/elements/core/UISwitch.tsx +26 -26
  29. package/src/elements/core/UIToggle.tsx +102 -102
  30. package/src/elements/index.ts +1 -1
  31. package/src/elements/tabs/ElTabs.tsx +178 -178
  32. package/src/index.ts +1 -1
@@ -1,102 +1,117 @@
1
- import React, { useState } from 'react';
2
- import { ChildType, Utils } from 'react-crud-utils';
3
- import { StyleSheet, Text, TouchableHighlight, View } from 'react-native';
4
- import UIListRow from './UIListRow';
5
- import UI from '../UI';
6
- import { Ionicons } from '@expo/vector-icons';
7
-
8
- export default function UIList(props: ChildType) {
9
- const scope = props.scope;
10
- const crud = scope.crud;
11
- const original = scope.original;
12
- const cols = Utils.nvl(original.cols, 1);
13
- const rowWidth = Math.floor(100 / cols) + '%';
14
- const items = Utils.nvl(scope.getItems(), []);
15
-
16
- const onClick = (item: any) => {
17
- scope.call('click', { value: item, item, edit: true });
18
- };
19
-
20
- const getStyle = (key: string, extra?: any) => {
21
- return scope.getStyle(key, { ...extra, ...styles[key] });
22
- };
23
-
24
- const getRowStyle = (extra?: any) => {
25
- let row = getStyle('row', {});
26
-
27
- if (cols > 0) {
28
- row.width = rowWidth;
29
- }
30
-
31
- return row;
32
- };
33
-
34
- const getContainerStyle = (extra?: any) => {
35
- let row = getStyle('container', {});
36
-
37
- if (cols > 1) {
38
- row = { ...row, flexDirection: 'row', flexWrap: 'wrap' };
39
- }
40
-
41
- return row;
42
- };
43
-
44
- return (
45
- <>
46
- {original.search !== false && (
47
- <UI.Text
48
- placeholder="Pesquisar..."
49
- field="query"
50
- crud={crud}
51
- right={<Ionicons name="search" size={20} color="#888" />}
52
- />
53
- )}
54
-
55
- <View style={getContainerStyle()}>
56
- {items.map((item: any, i: number) => (
57
- <TouchableHighlight
58
- key={`k-${i}`}
59
- style={getRowStyle()}
60
- underlayColor={'transparent'}
61
- onPress={e => {
62
- onClick(item);
63
- }}
64
- >
65
- <View style={getStyle('rowInner')}>
66
- <UIListRow scope={scope} item={item} index={i}>
67
- {props.children}
68
- </UIListRow>
69
- </View>
70
- </TouchableHighlight>
71
- ))}
72
- </View>
73
- </>
74
- );
75
- }
76
-
77
- const styles = StyleSheet.create({
78
- container: {
79
- flex: 1,
80
- width: '100%',
81
- flexDirection: 'row',
82
- flexWrap: 'wrap',
83
- alignItems: 'stretch',
84
- },
85
- row: {
86
- padding: 5,
87
- width: '100%',
88
- },
89
- rowInner: {
90
- flexGrow: 1, // ✅ cresce conforme o conteúdo
91
- justifyContent: 'center',
92
- alignItems: 'center',
93
- backgroundColor: '#f5f5f5',
94
- borderRadius: 8,
95
- padding: 10,
96
- width: '100%',
97
- },
98
- text: {
99
- fontSize: 18,
100
- fontWeight: 'bold',
101
- },
102
- });
1
+ import React, { useState } from 'react';
2
+ import { ChildType, Utils } from 'react-crud-utils';
3
+ import { StyleSheet, Text, TouchableHighlight, View } from 'react-native';
4
+ import UIListRow from './UIListRow';
5
+ import UI from '../UI';
6
+ import { Ionicons } from '@expo/vector-icons';
7
+
8
+ export default function UIList(props: ChildType) {
9
+ const scope = props.scope;
10
+ const crud = scope.crud;
11
+ const original = scope.original;
12
+ const cols = Utils.nvl(original.cols, 1);
13
+ const rowWidth = Math.floor(100 / cols) + '%';
14
+ const items = Utils.nvl(scope.getItems(), []);
15
+
16
+ const onClick = (item: any) => {
17
+ scope.call('click', { value: item, item, edit: true });
18
+ };
19
+
20
+ const getStyle = (key: string, extra?: any) => {
21
+ return scope.getStyle(key, { ...extra, ...styles[key] });
22
+ };
23
+
24
+ const getRowStyle = (extra?: any) => {
25
+ let row = getStyle('row', {});
26
+
27
+ if (cols > 0) {
28
+ row.width = rowWidth;
29
+ }
30
+
31
+ return row;
32
+ };
33
+
34
+ const getContainerStyle = (extra?: any) => {
35
+ let row = getStyle('container', {});
36
+
37
+ if (cols > 1) {
38
+ row = { ...row, flexDirection: 'row', flexWrap: 'wrap' };
39
+ }
40
+
41
+ return row;
42
+ };
43
+
44
+ let Empty = () => {
45
+ if (Utils.isEmpty(items)) {
46
+ return <></>;
47
+ }
48
+
49
+ let empty = scope.getPart('empty', 'Sem registro');
50
+
51
+ if (!empty) {
52
+ return <></>;
53
+ }
54
+
55
+ return <>{empty}</>;
56
+ };
57
+
58
+ return (
59
+ <>
60
+ {original.search !== false && (
61
+ <UI.Text
62
+ placeholder="Pesquisar..."
63
+ field="query"
64
+ crud={crud}
65
+ right={<Ionicons name="search" size={20} color="#888" />}
66
+ />
67
+ )}
68
+
69
+ <View style={getContainerStyle()}>
70
+ <Empty />
71
+ {items.map((item: any, i: number) => (
72
+ <TouchableHighlight
73
+ key={`k-${i}`}
74
+ style={getRowStyle()}
75
+ underlayColor={'transparent'}
76
+ onPress={e => {
77
+ onClick(item);
78
+ }}
79
+ >
80
+ <View style={getStyle('rowInner')}>
81
+ <UIListRow scope={scope} item={item} index={i}>
82
+ {props.children}
83
+ </UIListRow>
84
+ </View>
85
+ </TouchableHighlight>
86
+ ))}
87
+ </View>
88
+ </>
89
+ );
90
+ }
91
+
92
+ const styles = StyleSheet.create({
93
+ container: {
94
+ flex: 1,
95
+ width: '100%',
96
+ flexDirection: 'row',
97
+ flexWrap: 'wrap',
98
+ alignItems: 'stretch',
99
+ },
100
+ row: {
101
+ padding: 5,
102
+ width: '100%',
103
+ },
104
+ rowInner: {
105
+ flexGrow: 1, // ✅ cresce conforme o conteúdo
106
+ justifyContent: 'center',
107
+ alignItems: 'center',
108
+ backgroundColor: '#f5f5f5',
109
+ borderRadius: 8,
110
+ padding: 10,
111
+ width: '100%',
112
+ },
113
+ text: {
114
+ fontSize: 18,
115
+ fontWeight: 'bold',
116
+ },
117
+ });
@@ -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,29 +1,29 @@
1
- import React, { useState } from 'react';
2
- import { ChildType, ScopeUtils, Utils } from 'react-crud-utils';
3
- import UIChildren from '../UIChildren';
4
-
5
- interface UIListRowType extends ChildType {
6
- item: any;
7
- index: number;
8
- }
9
-
10
- export default function UIListRow(props: UIListRowType) {
11
- const parent = props.scope;
12
- const item = props.item;
13
- const row = {
14
- parent,
15
- crud: parent.crud,
16
- index: props.index,
17
- type: 'row',
18
- data: item,
19
- };
20
- let [scope] = useState(ScopeUtils.create(row));
21
-
22
- return (
23
- <>
24
- <UIChildren scope={scope} crud={scope.crud}>
25
- {props.children}
26
- </UIChildren>
27
- </>
28
- );
29
- }
1
+ import React, { useState } from 'react';
2
+ import { ChildType, ScopeUtils, Utils } from 'react-crud-utils';
3
+ import UIChildren from '../UIChildren';
4
+
5
+ interface UIListRowType extends ChildType {
6
+ item: any;
7
+ index: number;
8
+ }
9
+
10
+ export default function UIListRow(props: UIListRowType) {
11
+ const parent = props.scope;
12
+ const item = props.item;
13
+ const row = {
14
+ parent,
15
+ crud: parent.crud,
16
+ index: props.index,
17
+ type: 'row',
18
+ data: item,
19
+ };
20
+ let [scope] = useState(ScopeUtils.create(row));
21
+
22
+ return (
23
+ <>
24
+ <UIChildren scope={scope} crud={scope.crud}>
25
+ {props.children}
26
+ </UIChildren>
27
+ </>
28
+ );
29
+ }
@@ -1,111 +1,111 @@
1
- import { useEffect, useState } from 'react';
2
- import { ChildType, MethodType, useTheme, Utils } from 'react-crud-utils';
3
- import {
4
- Text,
5
- TouchableOpacity,
6
- StyleSheet,
7
- Modal,
8
- View,
9
- StatusBar,
10
- SafeAreaView,
11
- ScrollView,
12
- } from 'react-native';
13
- import UIChildren from '../UIChildren';
14
-
15
- export default function UIModal(props: ChildType) {
16
- let [modalVisible, setModalVisible] = useState(false);
17
-
18
- const scope = props.scope;
19
- const label = scope.getLabel();
20
- const theme = useTheme();
21
-
22
- const style = (part: string, extra?: any) => {
23
- let st = { ...styles[part], ...extra };
24
-
25
- return { ...scope.getStyle(part, st) };
26
- };
27
-
28
- const toggle = vis => {
29
- modalVisible = vis;
30
- setModalVisible(modalVisible);
31
- };
32
-
33
- scope.show = () => {
34
- toggle(true);
35
- };
36
-
37
- scope.hide = () => {
38
- toggle(false);
39
- };
40
-
41
- useEffect(() => {
42
- if (modalVisible) {
43
- StatusBar.setBarStyle('light-content');
44
- StatusBar.setBackgroundColor?.(theme.colors.primary);
45
- } else {
46
- StatusBar.setBarStyle('dark-content');
47
- StatusBar.setBackgroundColor?.('#f5f5f5');
48
- }
49
- }, [modalVisible]);
50
-
51
- return (
52
- <Modal
53
- animationType="slide"
54
- transparent={true}
55
- visible={modalVisible}
56
- onRequestClose={() => setModalVisible(false)}
57
- >
58
- <SafeAreaView style={style('modalSafe')}>
59
- <View style={style('modalHeader')}>
60
- <TouchableOpacity
61
- onPress={() => setModalVisible(false)}
62
- style={style('modalCloseButton')}
63
- >
64
- <Text style={style('modalCloseText')}>X</Text>
65
- </TouchableOpacity>
66
- <Text style={style('modalTitle')}>{label}</Text>
67
- </View>
68
- <ScrollView
69
- contentContainerStyle={{ flexGrow: 1 }}
70
- style={style('modalContent')}
71
- >
72
- <View style={{ flex: 1 }}>
73
- <UIChildren scope={scope}>{props.children}</UIChildren>
74
- </View>
75
- </ScrollView>
76
- </SafeAreaView>
77
- </Modal>
78
- );
79
- }
80
-
81
- const styles = StyleSheet.create({
82
- modalSafe: {
83
- flex: 1,
84
- backgroundColor: 'primary',
85
- width: '100%',
86
- },
87
- modalHeader: {
88
- flexDirection: 'row',
89
- alignItems: 'center',
90
- padding: 15,
91
- backgroundColor: 'primary',
92
- },
93
- modalCloseButton: {
94
- padding: 10,
95
- },
96
- modalCloseText: {
97
- fontSize: 18,
98
- color: 'white',
99
- },
100
- modalTitle: {
101
- fontSize: 18,
102
- color: 'white',
103
- fontWeight: 'bold',
104
- marginLeft: 10,
105
- },
106
- modalContent: {
107
- flex: 1,
108
- backgroundColor: '#f5f5f5',
109
- padding: 20,
110
- },
111
- });
1
+ import { useEffect, useState } from 'react';
2
+ import { ChildType, MethodType, useTheme, Utils } from 'react-crud-utils';
3
+ import {
4
+ Text,
5
+ TouchableOpacity,
6
+ StyleSheet,
7
+ Modal,
8
+ View,
9
+ StatusBar,
10
+ SafeAreaView,
11
+ ScrollView,
12
+ } from 'react-native';
13
+ import UIChildren from '../UIChildren';
14
+
15
+ export default function UIModal(props: ChildType) {
16
+ let [modalVisible, setModalVisible] = useState(false);
17
+
18
+ const scope = props.scope;
19
+ const label = scope.getLabel();
20
+ const theme = useTheme();
21
+
22
+ const style = (part: string, extra?: any) => {
23
+ let st = { ...styles[part], ...extra };
24
+
25
+ return { ...scope.getStyle(part, st) };
26
+ };
27
+
28
+ const toggle = vis => {
29
+ modalVisible = vis;
30
+ setModalVisible(modalVisible);
31
+ };
32
+
33
+ scope.show = () => {
34
+ toggle(true);
35
+ };
36
+
37
+ scope.hide = () => {
38
+ toggle(false);
39
+ };
40
+
41
+ useEffect(() => {
42
+ if (modalVisible) {
43
+ StatusBar.setBarStyle('light-content');
44
+ StatusBar.setBackgroundColor?.(theme.colors.primary);
45
+ } else {
46
+ StatusBar.setBarStyle('dark-content');
47
+ StatusBar.setBackgroundColor?.('#f5f5f5');
48
+ }
49
+ }, [modalVisible]);
50
+
51
+ return (
52
+ <Modal
53
+ animationType="slide"
54
+ transparent={true}
55
+ visible={modalVisible}
56
+ onRequestClose={() => setModalVisible(false)}
57
+ >
58
+ <SafeAreaView style={style('modalSafe')}>
59
+ <View style={style('modalHeader')}>
60
+ <TouchableOpacity
61
+ onPress={() => setModalVisible(false)}
62
+ style={style('modalCloseButton')}
63
+ >
64
+ <Text style={style('modalCloseText')}>X</Text>
65
+ </TouchableOpacity>
66
+ <Text style={style('modalTitle')}>{label}</Text>
67
+ </View>
68
+ <ScrollView
69
+ contentContainerStyle={{ flexGrow: 1 }}
70
+ style={style('modalContent')}
71
+ >
72
+ <View style={{ flex: 1 }}>
73
+ <UIChildren scope={scope}>{props.children}</UIChildren>
74
+ </View>
75
+ </ScrollView>
76
+ </SafeAreaView>
77
+ </Modal>
78
+ );
79
+ }
80
+
81
+ const styles = StyleSheet.create({
82
+ modalSafe: {
83
+ flex: 1,
84
+ backgroundColor: 'primary',
85
+ width: '100%',
86
+ },
87
+ modalHeader: {
88
+ flexDirection: 'row',
89
+ alignItems: 'center',
90
+ padding: 15,
91
+ backgroundColor: 'primary',
92
+ },
93
+ modalCloseButton: {
94
+ padding: 10,
95
+ },
96
+ modalCloseText: {
97
+ fontSize: 18,
98
+ color: 'white',
99
+ },
100
+ modalTitle: {
101
+ fontSize: 18,
102
+ color: 'white',
103
+ fontWeight: 'bold',
104
+ marginLeft: 10,
105
+ },
106
+ modalContent: {
107
+ flex: 1,
108
+ backgroundColor: '#f5f5f5',
109
+ padding: 20,
110
+ },
111
+ });
@@ -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
+ };