react-crud-mobile 1.0.627 → 1.0.628

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.
@@ -1,150 +1,150 @@
1
- import React 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
- import UIChildren from '../UIChildren';
8
-
9
- export default function UIList(props: ChildType) {
10
- const scope = props.scope;
11
- const crud = scope.crud;
12
- const original = scope.original;
13
- const cols = Utils.nvl(original.cols, 1);
14
- const items = Utils.nvl(scope.getItems(), []);
15
- const styles = { repeat: stylesRepeat, list: stylesList }?.[original.type];
16
- const add = ComponentUtils.getDefine(props, 'add');
17
- const hideAddWhenEmpty = original.hideAddWhenEmpty;
18
-
19
- const getStyle = (key: string, extra?: any) => {
20
- return scope.getStyle(key, { ...extra, ...styles[key] });
21
- };
22
-
23
- const getContainerStyle = (extra?: any) => {
24
- let row = getStyle('container', {});
25
-
26
- if (cols > 1) {
27
- row = { ...row, flexDirection: 'row', flexWrap: 'wrap' };
28
- }
29
-
30
- return row;
31
- };
32
-
33
- const isShowAdd = () => {
34
- if (!Utils.isEmpty(items)) {
35
- return true;
36
- }
37
- return hideAddWhenEmpty !== true;
38
- };
39
-
40
- let Empty = () => {
41
- if (!Utils.isEmpty(items)) {
42
- return <></>;
43
- }
44
-
45
- let empty = scope.attr('empty', 'Sem registro');
46
-
47
- if (!empty) {
48
- return <></>;
49
- }
50
-
51
- if (typeof empty === 'string') {
52
- return (
53
- <Text
54
- style={scope.getStyle('empty', {
55
- flex: 1,
56
- fontWeight: 500,
57
- fontSize: 20,
58
- padding: 10,
59
- textAlign: 'center',
60
- justifyContent: 'center',
61
- alignItems: 'center',
62
- })}
63
- >
64
- {empty}
65
- </Text>
66
- );
67
- }
68
-
69
- return <>{empty}</>;
70
- };
71
-
72
- return (
73
- <>
74
- {original.search !== false && (
75
- <UI.Text
76
- placeholder="Pesquisar..."
77
- field="query"
78
- crud={crud}
79
- right={<Ionicons name="search" size={20} color="#888" />}
80
- />
81
- )}
82
-
83
- <View style={getContainerStyle()}>
84
- <Empty />
85
- {items.map((item: any, i: number) => (
86
- <UIListRow index={i} item={item} scope={scope}>
87
- {props.children}
88
- </UIListRow>
89
- ))}
90
- {isShowAdd() && <>{add}</>}
91
- </View>
92
- </>
93
- );
94
- }
95
-
96
- const stylesList = StyleSheet.create({
97
- container: {
98
- flex: 1,
99
- width: '100%',
100
- flexDirection: 'row',
101
- flexWrap: 'wrap',
102
- alignItems: 'stretch',
103
- },
104
- row: {
105
- padding: 5,
106
- margin: 3,
107
- width: '100%',
108
- backgroundColor: '#f5f5f5',
109
- gap: 10,
110
- borderRadius: 8,
111
- },
112
- rowInner: {
113
- flexGrow: 1, // ✅ cresce conforme o conteúdo
114
- justifyContent: 'center',
115
- alignItems: 'center',
116
- borderRadius: 8,
117
- padding: 10,
118
- width: '100%',
119
- },
120
- text: {
121
- fontSize: 18,
122
- fontWeight: 'bold',
123
- },
124
- });
125
-
126
- const stylesRepeat = StyleSheet.create({
127
- container: {
128
- flex: 1,
129
- width: '100%',
130
- flexDirection: 'row',
131
- flexWrap: 'wrap',
132
- gap: 10,
133
- alignItems: 'stretch',
134
- },
135
- row: {
136
- padding: 0,
137
- width: '100%',
138
- },
139
- rowInner: {
140
- flexGrow: 1, // ✅ cresce conforme o conteúdo
141
- justifyContent: 'center',
142
- alignItems: 'center',
143
- padding: 0,
144
- width: '100%',
145
- },
146
- text: {
147
- fontSize: 18,
148
- fontWeight: 'bold',
149
- },
150
- });
1
+ import React 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
+ import UIChildren from '../UIChildren';
8
+
9
+ export default function UIList(props: ChildType) {
10
+ const scope = props.scope;
11
+ const crud = scope.crud;
12
+ const original = scope.original;
13
+ const cols = Utils.nvl(original.cols, 1);
14
+ const items = Utils.nvl(scope.getItems(), []);
15
+ const styles = { repeat: stylesRepeat, list: stylesList }?.[original.type];
16
+ const add = ComponentUtils.getDefine(props, 'add');
17
+ const hideAddWhenEmpty = original.hideAddWhenEmpty;
18
+
19
+ const getStyle = (key: string, extra?: any) => {
20
+ return scope.getStyle(key, { ...extra, ...styles[key] });
21
+ };
22
+
23
+ const getContainerStyle = (extra?: any) => {
24
+ let row = getStyle('container', {});
25
+
26
+ if (cols > 1) {
27
+ row = { ...row, flexDirection: 'row', flexWrap: 'wrap' };
28
+ }
29
+
30
+ return row;
31
+ };
32
+
33
+ const isShowAdd = () => {
34
+ if (!Utils.isEmpty(items)) {
35
+ return true;
36
+ }
37
+ return hideAddWhenEmpty !== true;
38
+ };
39
+
40
+ let Empty = () => {
41
+ if (!Utils.isEmpty(items)) {
42
+ return <></>;
43
+ }
44
+
45
+ let empty = scope.attr('empty', 'Sem registro');
46
+
47
+ if (!empty) {
48
+ return <></>;
49
+ }
50
+
51
+ if (typeof empty === 'string') {
52
+ return (
53
+ <Text
54
+ style={scope.getStyle('empty', {
55
+ flex: 1,
56
+ fontWeight: 500,
57
+ fontSize: 20,
58
+ padding: 10,
59
+ textAlign: 'center',
60
+ justifyContent: 'center',
61
+ alignItems: 'center',
62
+ })}
63
+ >
64
+ {empty}
65
+ </Text>
66
+ );
67
+ }
68
+
69
+ return <>{empty}</>;
70
+ };
71
+
72
+ return (
73
+ <>
74
+ {original.search !== false && (
75
+ <UI.Text
76
+ placeholder="Pesquisar..."
77
+ field="query"
78
+ crud={crud}
79
+ right={<Ionicons name="search" size={20} color="#888" />}
80
+ />
81
+ )}
82
+
83
+ <View style={getContainerStyle()}>
84
+ <Empty />
85
+ {items.map((item: any, i: number) => (
86
+ <UIListRow index={i} item={item} scope={scope}>
87
+ {props.children}
88
+ </UIListRow>
89
+ ))}
90
+ {isShowAdd() && <>{add}</>}
91
+ </View>
92
+ </>
93
+ );
94
+ }
95
+
96
+ const stylesList = StyleSheet.create({
97
+ container: {
98
+ flex: 1,
99
+ width: '100%',
100
+ flexDirection: 'row',
101
+ flexWrap: 'wrap',
102
+ alignItems: 'stretch',
103
+ },
104
+ row: {
105
+ padding: 5,
106
+ margin: 3,
107
+ width: '100%',
108
+ backgroundColor: '#f5f5f5',
109
+ gap: 10,
110
+ borderRadius: 8,
111
+ },
112
+ rowInner: {
113
+ flexGrow: 1, // ✅ cresce conforme o conteúdo
114
+ justifyContent: 'center',
115
+ alignItems: 'center',
116
+ borderRadius: 8,
117
+ padding: 10,
118
+ width: '100%',
119
+ },
120
+ text: {
121
+ fontSize: 18,
122
+ fontWeight: 'bold',
123
+ },
124
+ });
125
+
126
+ const stylesRepeat = StyleSheet.create({
127
+ container: {
128
+ flex: 1,
129
+ width: '100%',
130
+ flexDirection: 'row',
131
+ flexWrap: 'wrap',
132
+ gap: 10,
133
+ alignItems: 'stretch',
134
+ },
135
+ row: {
136
+ padding: 0,
137
+ width: '100%',
138
+ },
139
+ rowInner: {
140
+ flexGrow: 1, // ✅ cresce conforme o conteúdo
141
+ justifyContent: 'center',
142
+ alignItems: 'center',
143
+ padding: 0,
144
+ width: '100%',
145
+ },
146
+ text: {
147
+ fontSize: 18,
148
+ fontWeight: 'bold',
149
+ },
150
+ });
@@ -1,101 +1,101 @@
1
- import React, { useState } from 'react';
2
- import { ChildType, ScopeUtils, Utils } from 'react-crud-utils';
3
- import UIChildren from '../UIChildren';
4
- import { StyleSheet, TouchableHighlight, View } from 'react-native';
5
-
6
- interface UIListRowType extends ChildType {
7
- item: any;
8
- index: number;
9
- }
10
-
11
- export default function UIListRow(props: UIListRowType) {
12
- const scope = props.scope;
13
- const index = props.index;
14
- const original = scope.original;
15
- const item = props.item;
16
- const cols = Utils.nvl(original.cols, 1);
17
- const rowWidth = Math.floor(100 / cols) + '%';
18
- const styles = { repeat: stylesRepeat, list: stylesList }?.[original.type];
19
- const name = `${scope.key('row', index, '')}`;
20
- const [row] = useState(
21
- ScopeUtils.create({
22
- ...original,
23
- parent: scope,
24
- name,
25
- crud: scope.crud,
26
- index,
27
- type: 'row',
28
- data: item,
29
- })
30
- );
31
-
32
- const onClick = (item: any) => {
33
- row.call('click', { value: item, item, edit: true });
34
- };
35
-
36
- const ListItem = () => {
37
- let [updateIndex, setUpdateIndex] = useState(0);
38
- let key = scope.key('item');
39
-
40
- const getRowStyle = () => {
41
- let css = row.getStyle('row', { ...styles.row });
42
-
43
- if (cols > 0) {
44
- css.width = rowWidth;
45
- }
46
-
47
- return css;
48
- };
49
-
50
- row.update = () => {
51
- scope.updateIndex = scope.updateIndex + 1;
52
-
53
- setUpdateIndex(++updateIndex);
54
- };
55
-
56
- if (!original.click) {
57
- return (
58
- <View key={key} style={getRowStyle()}>
59
- <UIChildren scope={row} crud={row.crud}>
60
- {props.children}
61
- </UIChildren>
62
- </View>
63
- );
64
- }
65
- return (
66
- <TouchableHighlight
67
- key={key}
68
- style={getRowStyle()}
69
- underlayColor={'transparent'}
70
- onPress={e => {
71
- e.stopPropagation();
72
- onClick(item);
73
- }}
74
- >
75
- <UIChildren scope={row} crud={row.crud}>
76
- {props.children}
77
- </UIChildren>
78
- </TouchableHighlight>
79
- );
80
- };
81
-
82
- return <ListItem />;
83
- }
84
-
85
- const stylesList = StyleSheet.create({
86
- row: {
87
- padding: 5,
88
- margin: 3,
89
- width: '100%',
90
- backgroundColor: '#f5f5f5',
91
- gap: 10,
92
- borderRadius: 8,
93
- },
94
- });
95
-
96
- const stylesRepeat = StyleSheet.create({
97
- row: {
98
- padding: 0,
99
- width: '100%',
100
- },
101
- });
1
+ import React, { useState } from 'react';
2
+ import { ChildType, ScopeUtils, Utils } from 'react-crud-utils';
3
+ import UIChildren from '../UIChildren';
4
+ import { StyleSheet, TouchableHighlight, View } from 'react-native';
5
+
6
+ interface UIListRowType extends ChildType {
7
+ item: any;
8
+ index: number;
9
+ }
10
+
11
+ export default function UIListRow(props: UIListRowType) {
12
+ const scope = props.scope;
13
+ const index = props.index;
14
+ const original = scope.original;
15
+ const item = props.item;
16
+ const cols = Utils.nvl(original.cols, 1);
17
+ const rowWidth = Math.floor(100 / cols) + '%';
18
+ const styles = { repeat: stylesRepeat, list: stylesList }?.[original.type];
19
+ const name = `${scope.key('row', index, '')}`;
20
+ const [row] = useState(
21
+ ScopeUtils.create({
22
+ ...original,
23
+ parent: scope,
24
+ name,
25
+ crud: scope.crud,
26
+ index,
27
+ type: 'row',
28
+ data: item,
29
+ })
30
+ );
31
+
32
+ const onClick = (item: any) => {
33
+ row.call('click', { value: item, item, edit: true });
34
+ };
35
+
36
+ const ListItem = () => {
37
+ let [updateIndex, setUpdateIndex] = useState(0);
38
+ let key = scope.key('item');
39
+
40
+ const getRowStyle = () => {
41
+ let css = row.getStyle('row', { ...styles.row });
42
+
43
+ if (cols > 0) {
44
+ css.width = rowWidth;
45
+ }
46
+
47
+ return css;
48
+ };
49
+
50
+ row.update = () => {
51
+ scope.updateIndex = scope.updateIndex + 1;
52
+
53
+ setUpdateIndex(++updateIndex);
54
+ };
55
+
56
+ if (!original.click) {
57
+ return (
58
+ <View key={key} style={getRowStyle()}>
59
+ <UIChildren scope={row} crud={row.crud}>
60
+ {props.children}
61
+ </UIChildren>
62
+ </View>
63
+ );
64
+ }
65
+ return (
66
+ <TouchableHighlight
67
+ key={key}
68
+ style={getRowStyle()}
69
+ underlayColor={'transparent'}
70
+ onPress={e => {
71
+ e.stopPropagation();
72
+ onClick(item);
73
+ }}
74
+ >
75
+ <UIChildren scope={row} crud={row.crud}>
76
+ {props.children}
77
+ </UIChildren>
78
+ </TouchableHighlight>
79
+ );
80
+ };
81
+
82
+ return <ListItem />;
83
+ }
84
+
85
+ const stylesList = StyleSheet.create({
86
+ row: {
87
+ padding: 5,
88
+ margin: 3,
89
+ width: '100%',
90
+ backgroundColor: '#f5f5f5',
91
+ gap: 10,
92
+ borderRadius: 8,
93
+ },
94
+ });
95
+
96
+ const stylesRepeat = StyleSheet.create({
97
+ row: {
98
+ padding: 0,
99
+ width: '100%',
100
+ },
101
+ });