react-crud-mobile 1.3.194 → 1.3.198

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 (42) hide show
  1. package/dist/react-crud-mobile.cjs.development.js +16 -7
  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 +16 -7
  6. package/dist/react-crud-mobile.esm.js.map +1 -1
  7. package/package.json +77 -77
  8. package/src/elements/UI.tsx +76 -76
  9. package/src/elements/UIChildren.tsx +142 -142
  10. package/src/elements/UIComplete.tsx +14 -14
  11. package/src/elements/UIElement.tsx +824 -823
  12. package/src/elements/UITag.tsx +13 -13
  13. package/src/elements/charts/ElChart.tsx +10 -10
  14. package/src/elements/core/GestureView.tsx +16 -16
  15. package/src/elements/core/SafeView.tsx +63 -63
  16. package/src/elements/core/UIAutoComplete.tsx +17 -17
  17. package/src/elements/core/UIButton.tsx +143 -143
  18. package/src/elements/core/UIHeader.tsx +38 -38
  19. package/src/elements/core/UIIcon.tsx +25 -25
  20. package/src/elements/core/UIInclude.tsx +40 -40
  21. package/src/elements/core/UIInput.tsx +102 -96
  22. package/src/elements/core/UILink.tsx +17 -17
  23. package/src/elements/core/UIList.tsx +169 -168
  24. package/src/elements/core/UIListItem.tsx +32 -32
  25. package/src/elements/core/UIListRow.tsx +132 -132
  26. package/src/elements/core/UIModal.tsx +225 -225
  27. package/src/elements/core/UIOption.tsx +17 -17
  28. package/src/elements/core/UIOrder.tsx +194 -194
  29. package/src/elements/core/UIQuantity.tsx +98 -98
  30. package/src/elements/core/UIRadio.tsx +17 -17
  31. package/src/elements/core/UISelect.tsx +171 -171
  32. package/src/elements/core/UISlider.tsx +61 -61
  33. package/src/elements/core/UIStatusBar.tsx +5 -5
  34. package/src/elements/core/UISwitch.tsx +27 -27
  35. package/src/elements/core/UIToast.tsx +44 -44
  36. package/src/elements/core/UIToggle.tsx +102 -102
  37. package/src/elements/core/UIView.tsx +69 -69
  38. package/src/elements/index.ts +1 -1
  39. package/src/elements/tabs/ElTabs.tsx +178 -178
  40. package/src/hooks/useIsVisible.ts +39 -39
  41. package/src/index.ts +1 -1
  42. package/src/utils/MobileUtils.ts +12 -12
@@ -1,40 +1,40 @@
1
- import UIChildren from '../UIChildren';
2
- import { ComponentUtils, DefineType, Utils } from 'react-crud-utils';
3
-
4
- export default function UIInclude(props: DefineType) {
5
- if (props.rendered === false) {
6
- return <></>;
7
- }
8
-
9
- let includes = ComponentUtils.getDefine(props, props.name, props.position);
10
-
11
- if (Utils.isEmpty(includes)) {
12
- includes = props.default;
13
- }
14
-
15
- if (!Utils.isEmpty(includes)) {
16
- let Aux = (tagProp: any) => {
17
- let Tag: any = props.tag;
18
-
19
- if (!Utils.isEmpty(Tag)) {
20
- return <Tag {...tagProp}>{tagProp.children}</Tag>;
21
- }
22
- return <>{tagProp.children}</>;
23
- };
24
-
25
- return (
26
- <Aux {...props.tagProps}>
27
- <UIChildren
28
- transient
29
- {...props}
30
- scope={props.scope}
31
- crud={props.crud}
32
- part={props.name}
33
- >
34
- {includes}
35
- </UIChildren>
36
- </Aux>
37
- );
38
- }
39
- return <>{includes}</>;
40
- }
1
+ import UIChildren from '../UIChildren';
2
+ import { ComponentUtils, DefineType, Utils } from 'react-crud-utils';
3
+
4
+ export default function UIInclude(props: DefineType) {
5
+ if (props.rendered === false) {
6
+ return <></>;
7
+ }
8
+
9
+ let includes = ComponentUtils.getDefine(props, props.name, props.position);
10
+
11
+ if (Utils.isEmpty(includes)) {
12
+ includes = props.default;
13
+ }
14
+
15
+ if (!Utils.isEmpty(includes)) {
16
+ let Aux = (tagProp: any) => {
17
+ let Tag: any = props.tag;
18
+
19
+ if (!Utils.isEmpty(Tag)) {
20
+ return <Tag {...tagProp}>{tagProp.children}</Tag>;
21
+ }
22
+ return <>{tagProp.children}</>;
23
+ };
24
+
25
+ return (
26
+ <Aux {...props.tagProps}>
27
+ <UIChildren
28
+ transient
29
+ {...props}
30
+ scope={props.scope}
31
+ crud={props.crud}
32
+ part={props.name}
33
+ >
34
+ {includes}
35
+ </UIChildren>
36
+ </Aux>
37
+ );
38
+ }
39
+ return <>{includes}</>;
40
+ }
@@ -1,96 +1,102 @@
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
+
55
+ let type = scope.getPart('type', 'none');
56
+ let decode = { textarea: { multiline: true, textAlignVertical: 'top' } };
57
+ let defs = Utils.nvl(decode[type], {});
58
+
59
+ return (
60
+ <>
61
+ <View style={style('base')}>
62
+ {scope.getPart('left')}
63
+ <TextInput
64
+ style={style('input')}
65
+ onChangeText={onChange}
66
+ value={value}
67
+ placeholder={placeholder}
68
+ {...defs}
69
+ />
70
+ <CustomIcon />
71
+ </View>
72
+ {scope.getPart('right')}
73
+ </>
74
+ );
75
+ }
76
+
77
+ const styles = StyleSheet.create({
78
+ base: {
79
+ flex: 1,
80
+ width: '100%',
81
+ paddingBottom: 0,
82
+ paddingTop: 0,
83
+ alignItems: 'center',
84
+ borderWidth: 1,
85
+ borderColor: 'borderColor',
86
+ borderRadius: 5,
87
+ paddingHorizontal: 15,
88
+ alignSelf: 'flex-start',
89
+ flexDirection: 'row',
90
+ flexWrap: 'wrap',
91
+ gap: 10,
92
+ },
93
+ icon: {
94
+ marginRight: 10, // Espaço entre ícone e input
95
+ },
96
+ input: {
97
+ marginHorizontal: 0,
98
+ marginVertical: 0,
99
+ height: 40,
100
+ flex: 1, // Para o input ocupar o espaço restante
101
+ },
102
+ });
@@ -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,169 @@
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 !== false && !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 = Utils.getValue(filterBy, 'none', o).toLowerCase();
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, Utils } from 'react-crud-utils';
3
+ import { StyleSheet, Text, 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 !== false && !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 = Utils.getValue(filterBy, 'none', o).toLowerCase();
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: 15,
96
+ padding: 10,
97
+ textAlign: 'center',
98
+ width: '100%',
99
+ justifyContent: 'center',
100
+ alignItems: 'center',
101
+ })}
102
+ >
103
+ {empty}
104
+ </Text>
105
+ );
106
+ }
107
+
108
+ return <>{empty}</>;
109
+ };
110
+
111
+ return (
112
+ <View style={getContainerStyle()}>
113
+ <Empty />
114
+ {items.map((item: any, i: number) => (
115
+ <UIListRow index={i} item={item} scope={scope}>
116
+ {props.children}
117
+ </UIListRow>
118
+ ))}
119
+ {isShowAdd() && <>{add}</>}
120
+ </View>
121
+ );
122
+ };
123
+
124
+ return (
125
+ <>
126
+ {original.search !== false && (
127
+ <UI.Text
128
+ placeholder="Pesquisar..."
129
+ field="query"
130
+ crud={crud}
131
+ style={{ marginBottom: 10 }}
132
+ change={{
133
+ action: () => {
134
+ scope.search();
135
+ },
136
+ }}
137
+ icon={<Ionicons name="search" size={20} color="#888" />}
138
+ />
139
+ )}
140
+ <LocalData />
141
+ </>
142
+ );
143
+ }
144
+
145
+ const stylesList = StyleSheet.create({
146
+ container: {
147
+ display: 'flex',
148
+ flexWrap: 'wrap',
149
+ gap: 10,
150
+ width: '100%',
151
+ },
152
+ text: {
153
+ fontSize: 18,
154
+ fontWeight: 'bold',
155
+ },
156
+ });
157
+
158
+ const stylesRepeat = StyleSheet.create({
159
+ container: {
160
+ display: 'flex',
161
+ flexWrap: 'wrap',
162
+ gap: 10,
163
+ width: '100%',
164
+ },
165
+ text: {
166
+ fontSize: 18,
167
+ fontWeight: 'bold',
168
+ },
169
+ });