react-crud-mobile 1.3.1 → 1.3.2

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 (38) hide show
  1. package/dist/react-crud-mobile.cjs.development.js +4 -1
  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 +4 -1
  6. package/dist/react-crud-mobile.esm.js.map +1 -1
  7. package/package.json +75 -75
  8. package/src/elements/UI.tsx +73 -73
  9. package/src/elements/UIChildren.tsx +139 -139
  10. package/src/elements/UIComplete.tsx +14 -14
  11. package/src/elements/UIElement.tsx +696 -692
  12. package/src/elements/UITag.tsx +13 -13
  13. package/src/elements/charts/ElChart.tsx +10 -10
  14. package/src/elements/core/SafeView.tsx +69 -69
  15. package/src/elements/core/UIAutoComplete.tsx +17 -17
  16. package/src/elements/core/UIButton.tsx +139 -139
  17. package/src/elements/core/UIIcon.tsx +25 -25
  18. package/src/elements/core/UIInclude.tsx +40 -40
  19. package/src/elements/core/UIInput.tsx +96 -96
  20. package/src/elements/core/UILink.tsx +17 -17
  21. package/src/elements/core/UIList.tsx +168 -168
  22. package/src/elements/core/UIListItem.tsx +32 -32
  23. package/src/elements/core/UIListRow.tsx +123 -123
  24. package/src/elements/core/UIModal.tsx +204 -204
  25. package/src/elements/core/UIOption.tsx +17 -17
  26. package/src/elements/core/UIQuantity.tsx +98 -98
  27. package/src/elements/core/UIRadio.tsx +17 -17
  28. package/src/elements/core/UISelect.tsx +135 -135
  29. package/src/elements/core/UISlider.tsx +61 -61
  30. package/src/elements/core/UISwitch.tsx +27 -27
  31. package/src/elements/core/UIToast.tsx +44 -44
  32. package/src/elements/core/UIToggle.tsx +102 -102
  33. package/src/elements/core/UIView.tsx +94 -94
  34. package/src/elements/index.ts +1 -1
  35. package/src/elements/tabs/ElTabs.tsx +178 -178
  36. package/src/hooks/useIsVisible.ts +39 -39
  37. package/src/index.ts +1 -1
  38. package/src/utils/MobileUtils.ts +12 -12
@@ -1,96 +1,96 @@
1
- import { useState } from 'react';
2
- import { ChildType, Utils } from 'react-crud-utils';
3
- import { StyleSheet, TextInput, View } from 'react-native';
4
- import { Ionicons } from '@expo/vector-icons';
5
-
6
- export default function UIInput(props: ChildType) {
7
- let scope = props.scope;
8
- let initial = Utils.call(() => {
9
- let val = Utils.nvl(scope.getValue(), '');
10
-
11
- if (val && val?.push) {
12
- return val.join(', ').trim();
13
- }
14
- return val;
15
- });
16
-
17
- let label = scope.getLabel();
18
- let placeholder = scope.getPart('placeholder', null, label);
19
- let el = scope.original;
20
-
21
- const [value, setValue] = useState(initial);
22
-
23
- let onChange = v => {
24
- v = scope.changeValue(v);
25
-
26
- setValue(v);
27
- };
28
-
29
- const style = (part: string, extra?: any) => {
30
- return { ...scope.getStyle(part, styles[part]), ...extra };
31
- };
32
-
33
- const CustomIcon = () => {
34
- let icon = el.icon;
35
-
36
- if (icon) {
37
- if (typeof icon === 'string') {
38
- return (
39
- <>
40
- {el.icon && (
41
- <Ionicons
42
- name={el.icon}
43
- size={scope.attr('iconSize', 20)}
44
- color={scope.attr('iconColor', '#888')}
45
- />
46
- )}
47
- </>
48
- );
49
- }
50
- return <>{icon}</>;
51
- }
52
- return <></>;
53
- };
54
- return (
55
- <>
56
- <View style={style('base')}>
57
- {scope.getPart('left')}
58
- <TextInput
59
- style={style('input')}
60
- onChangeText={onChange}
61
- value={value}
62
- placeholder={placeholder}
63
- />
64
- <CustomIcon />
65
- </View>
66
- {scope.getPart('right')}
67
- </>
68
- );
69
- }
70
-
71
- const styles = StyleSheet.create({
72
- base: {
73
- flex: 1,
74
- width: '100%',
75
- paddingBottom: 0,
76
- paddingTop: 0,
77
- alignItems: 'center',
78
- borderWidth: 1,
79
- borderColor: 'borderColor',
80
- borderRadius: 5,
81
- paddingHorizontal: 15,
82
- alignSelf: 'flex-start',
83
- flexDirection: 'row',
84
- flexWrap: 'wrap',
85
- gap: 10,
86
- },
87
- icon: {
88
- marginRight: 10, // Espaço entre ícone e input
89
- },
90
- input: {
91
- marginHorizontal: 0,
92
- marginVertical: 0,
93
- height: 40,
94
- flex: 1, // Para o input ocupar o espaço restante
95
- },
96
- });
1
+ import { useState } from 'react';
2
+ import { ChildType, Utils } from 'react-crud-utils';
3
+ import { StyleSheet, TextInput, View } from 'react-native';
4
+ import { Ionicons } from '@expo/vector-icons';
5
+
6
+ export default function UIInput(props: ChildType) {
7
+ let scope = props.scope;
8
+ let initial = Utils.call(() => {
9
+ let val = Utils.nvl(scope.getValue(), '');
10
+
11
+ if (val && val?.push) {
12
+ return val.join(', ').trim();
13
+ }
14
+ return val;
15
+ });
16
+
17
+ let label = scope.getLabel();
18
+ let placeholder = scope.getPart('placeholder', null, label);
19
+ let el = scope.original;
20
+
21
+ const [value, setValue] = useState(initial);
22
+
23
+ let onChange = v => {
24
+ v = scope.changeValue(v);
25
+
26
+ setValue(v);
27
+ };
28
+
29
+ const style = (part: string, extra?: any) => {
30
+ return { ...scope.getStyle(part, styles[part]), ...extra };
31
+ };
32
+
33
+ const CustomIcon = () => {
34
+ let icon = el.icon;
35
+
36
+ if (icon) {
37
+ if (typeof icon === 'string') {
38
+ return (
39
+ <>
40
+ {el.icon && (
41
+ <Ionicons
42
+ name={el.icon}
43
+ size={scope.attr('iconSize', 20)}
44
+ color={scope.attr('iconColor', '#888')}
45
+ />
46
+ )}
47
+ </>
48
+ );
49
+ }
50
+ return <>{icon}</>;
51
+ }
52
+ return <></>;
53
+ };
54
+ return (
55
+ <>
56
+ <View style={style('base')}>
57
+ {scope.getPart('left')}
58
+ <TextInput
59
+ style={style('input')}
60
+ onChangeText={onChange}
61
+ value={value}
62
+ placeholder={placeholder}
63
+ />
64
+ <CustomIcon />
65
+ </View>
66
+ {scope.getPart('right')}
67
+ </>
68
+ );
69
+ }
70
+
71
+ const styles = StyleSheet.create({
72
+ base: {
73
+ flex: 1,
74
+ width: '100%',
75
+ paddingBottom: 0,
76
+ paddingTop: 0,
77
+ alignItems: 'center',
78
+ borderWidth: 1,
79
+ borderColor: 'borderColor',
80
+ borderRadius: 5,
81
+ paddingHorizontal: 15,
82
+ alignSelf: 'flex-start',
83
+ flexDirection: 'row',
84
+ flexWrap: 'wrap',
85
+ gap: 10,
86
+ },
87
+ icon: {
88
+ marginRight: 10, // Espaço entre ícone e input
89
+ },
90
+ input: {
91
+ marginHorizontal: 0,
92
+ marginVertical: 0,
93
+ height: 40,
94
+ flex: 1, // Para o input ocupar o espaço restante
95
+ },
96
+ });
@@ -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,168 +1,168 @@
1
- import React, { useState } from 'react';
2
- import { ChildType, ComponentUtils, ScopeUtils, 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(scope.getPart('cols', undefined, 1));
13
- const styles = { repeat: stylesRepeat, list: stylesList }?.[original.type];
14
- const add = ComponentUtils.getDefine(props, 'add');
15
- const hideAddWhenEmpty = original.hideAddWhenEmpty;
16
-
17
- const getStyle = (key: string, extra?: any) => {
18
- return scope.getStyle(key, { ...extra, ...styles[key] });
19
- };
20
-
21
- const getContainerStyle = (extra?: any) => {
22
- let row = getStyle('container', {});
23
-
24
- if (cols > 1) {
25
- row = { ...row, flexDirection: 'row', flexWrap: 'wrap' };
26
- }
27
-
28
- return row;
29
- };
30
-
31
- const LocalData = () => {
32
- let [index, setIndex] = useState(scope.updateIndex);
33
-
34
- scope.update = () => {
35
- scope.updateIndex = ++index;
36
-
37
- setIndex(index);
38
- };
39
-
40
- let keyData = scope.key('data');
41
-
42
- const items = Utils.call(() => {
43
- let list = Utils.nvl(scope.getItems(), []);
44
-
45
- if (original.search && !original.list?.url) {
46
- let query = crud
47
- .get('query', '')
48
- .toLowerCase()
49
- .trim() as string;
50
-
51
- if (query.length > 1) {
52
- let filters: any[] = [];
53
- let filterBy = Utils.nvl(original.filterBy, 'label');
54
-
55
- Utils.each(list, o => {
56
- let label = o[filterBy];
57
-
58
- if (label) {
59
- if (label.includes(query)) {
60
- filters.push(o);
61
- }
62
- }
63
- });
64
-
65
- return filters;
66
- }
67
- }
68
- return list;
69
- });
70
-
71
- const isShowAdd = () => {
72
- if (!Utils.isEmpty(items)) {
73
- return true;
74
- }
75
- return hideAddWhenEmpty !== true;
76
- };
77
-
78
- let Empty = () => {
79
- if (!Utils.isEmpty(items)) {
80
- return <></>;
81
- }
82
-
83
- let empty = scope.attr('empty', 'Sem registro');
84
-
85
- if (!empty) {
86
- return <></>;
87
- }
88
-
89
- if (typeof empty === 'string') {
90
- return (
91
- <Text
92
- style={scope.getStyle('empty', {
93
- flex: 1,
94
- fontWeight: 500,
95
- fontSize: 20,
96
- padding: 10,
97
- textAlign: 'center',
98
- justifyContent: 'center',
99
- alignItems: 'center',
100
- })}
101
- >
102
- {empty}
103
- </Text>
104
- );
105
- }
106
-
107
- return <>{empty}</>;
108
- };
109
-
110
- return (
111
- <View key={keyData} style={getContainerStyle()}>
112
- <Empty />
113
- {items.map((item: any, i: number) => (
114
- <UIListRow index={i} item={item} scope={scope}>
115
- {props.children}
116
- </UIListRow>
117
- ))}
118
- {isShowAdd() && <>{add}</>}
119
- </View>
120
- );
121
- };
122
-
123
- return (
124
- <>
125
- {original.search !== false && (
126
- <UI.Text
127
- placeholder="Pesquisar..."
128
- field="query"
129
- crud={crud}
130
- style={{ marginBottom: 10 }}
131
- change={{
132
- action: () => {
133
- scope.search();
134
- },
135
- }}
136
- icon={<Ionicons name="search" size={20} color="#888" />}
137
- />
138
- )}
139
- <LocalData />
140
- </>
141
- );
142
- }
143
-
144
- const stylesList = StyleSheet.create({
145
- container: {
146
- display: 'flex',
147
- flexWrap: 'wrap',
148
- gap: 10,
149
- width: '100%',
150
- },
151
- text: {
152
- fontSize: 18,
153
- fontWeight: 'bold',
154
- },
155
- });
156
-
157
- const stylesRepeat = StyleSheet.create({
158
- container: {
159
- display: 'flex',
160
- flexWrap: 'wrap',
161
- gap: 10,
162
- width: '100%',
163
- },
164
- text: {
165
- fontSize: 18,
166
- fontWeight: 'bold',
167
- },
168
- });
1
+ import React, { useState } from 'react';
2
+ import { ChildType, ComponentUtils, ScopeUtils, 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(scope.getPart('cols', undefined, 1));
13
+ const styles = { repeat: stylesRepeat, list: stylesList }?.[original.type];
14
+ const add = ComponentUtils.getDefine(props, 'add');
15
+ const hideAddWhenEmpty = original.hideAddWhenEmpty;
16
+
17
+ const getStyle = (key: string, extra?: any) => {
18
+ return scope.getStyle(key, { ...extra, ...styles[key] });
19
+ };
20
+
21
+ const getContainerStyle = (extra?: any) => {
22
+ let row = getStyle('container', {});
23
+
24
+ if (cols > 1) {
25
+ row = { ...row, flexDirection: 'row', flexWrap: 'wrap' };
26
+ }
27
+
28
+ return row;
29
+ };
30
+
31
+ const LocalData = () => {
32
+ let [index, setIndex] = useState(scope.updateIndex);
33
+
34
+ scope.update = () => {
35
+ scope.updateIndex = ++index;
36
+
37
+ setIndex(index);
38
+ };
39
+
40
+ let keyData = scope.key('data');
41
+
42
+ const items = Utils.call(() => {
43
+ let list = Utils.nvl(scope.getItems(), []);
44
+
45
+ if (original.search && !original.list?.url) {
46
+ let query = crud
47
+ .get('query', '')
48
+ .toLowerCase()
49
+ .trim() as string;
50
+
51
+ if (query.length > 1) {
52
+ let filters: any[] = [];
53
+ let filterBy = Utils.nvl(original.filterBy, 'label');
54
+
55
+ Utils.each(list, o => {
56
+ let label = o[filterBy];
57
+
58
+ if (label) {
59
+ if (label.includes(query)) {
60
+ filters.push(o);
61
+ }
62
+ }
63
+ });
64
+
65
+ return filters;
66
+ }
67
+ }
68
+ return list;
69
+ });
70
+
71
+ const isShowAdd = () => {
72
+ if (!Utils.isEmpty(items)) {
73
+ return true;
74
+ }
75
+ return hideAddWhenEmpty !== true;
76
+ };
77
+
78
+ let Empty = () => {
79
+ if (!Utils.isEmpty(items)) {
80
+ return <></>;
81
+ }
82
+
83
+ let empty = scope.attr('empty', 'Sem registro');
84
+
85
+ if (!empty) {
86
+ return <></>;
87
+ }
88
+
89
+ if (typeof empty === 'string') {
90
+ return (
91
+ <Text
92
+ style={scope.getStyle('empty', {
93
+ flex: 1,
94
+ fontWeight: 500,
95
+ fontSize: 20,
96
+ padding: 10,
97
+ textAlign: 'center',
98
+ justifyContent: 'center',
99
+ alignItems: 'center',
100
+ })}
101
+ >
102
+ {empty}
103
+ </Text>
104
+ );
105
+ }
106
+
107
+ return <>{empty}</>;
108
+ };
109
+
110
+ return (
111
+ <View key={keyData} style={getContainerStyle()}>
112
+ <Empty />
113
+ {items.map((item: any, i: number) => (
114
+ <UIListRow index={i} item={item} scope={scope}>
115
+ {props.children}
116
+ </UIListRow>
117
+ ))}
118
+ {isShowAdd() && <>{add}</>}
119
+ </View>
120
+ );
121
+ };
122
+
123
+ return (
124
+ <>
125
+ {original.search !== false && (
126
+ <UI.Text
127
+ placeholder="Pesquisar..."
128
+ field="query"
129
+ crud={crud}
130
+ style={{ marginBottom: 10 }}
131
+ change={{
132
+ action: () => {
133
+ scope.search();
134
+ },
135
+ }}
136
+ icon={<Ionicons name="search" size={20} color="#888" />}
137
+ />
138
+ )}
139
+ <LocalData />
140
+ </>
141
+ );
142
+ }
143
+
144
+ const stylesList = StyleSheet.create({
145
+ container: {
146
+ display: 'flex',
147
+ flexWrap: 'wrap',
148
+ gap: 10,
149
+ width: '100%',
150
+ },
151
+ text: {
152
+ fontSize: 18,
153
+ fontWeight: 'bold',
154
+ },
155
+ });
156
+
157
+ const stylesRepeat = StyleSheet.create({
158
+ container: {
159
+ display: 'flex',
160
+ flexWrap: 'wrap',
161
+ gap: 10,
162
+ width: '100%',
163
+ },
164
+ text: {
165
+ fontSize: 18,
166
+ fontWeight: 'bold',
167
+ },
168
+ });
@@ -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
+ });