react-crud-mobile 1.3.333 → 1.3.335

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 (39) hide show
  1. package/dist/react-crud-mobile.cjs.development.js.map +1 -1
  2. package/dist/react-crud-mobile.cjs.production.min.js.map +1 -1
  3. package/dist/react-crud-mobile.esm.js.map +1 -1
  4. package/package.json +76 -76
  5. package/src/elements/UI.tsx +77 -77
  6. package/src/elements/UIChildren.tsx +142 -142
  7. package/src/elements/UIComplete.tsx +14 -14
  8. package/src/elements/UIElement.tsx +870 -870
  9. package/src/elements/UITag.tsx +13 -13
  10. package/src/elements/charts/ElChart.tsx +10 -10
  11. package/src/elements/core/GestureView.tsx +16 -16
  12. package/src/elements/core/SafeView.tsx +63 -63
  13. package/src/elements/core/UIAutoComplete.tsx +17 -17
  14. package/src/elements/core/UIButton.tsx +143 -143
  15. package/src/elements/core/UIHeader.tsx +38 -38
  16. package/src/elements/core/UIIcon.tsx +25 -25
  17. package/src/elements/core/UIInclude.tsx +40 -40
  18. package/src/elements/core/UIInput.tsx +147 -147
  19. package/src/elements/core/UILink.tsx +17 -17
  20. package/src/elements/core/UIList.tsx +180 -180
  21. package/src/elements/core/UIListItem.tsx +32 -32
  22. package/src/elements/core/UIListRow.tsx +132 -132
  23. package/src/elements/core/UIModal.tsx +212 -212
  24. package/src/elements/core/UIOption.tsx +17 -17
  25. package/src/elements/core/UIOrder.tsx +194 -194
  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 +175 -175
  29. package/src/elements/core/UISlider.tsx +61 -61
  30. package/src/elements/core/UIStatusBar.tsx +5 -5
  31. package/src/elements/core/UISwitch.tsx +27 -27
  32. package/src/elements/core/UIToast.tsx +44 -44
  33. package/src/elements/core/UIToggle.tsx +114 -114
  34. package/src/elements/core/UIView.tsx +69 -69
  35. package/src/elements/index.ts +1 -1
  36. package/src/elements/tabs/ElTabs.tsx +178 -178
  37. package/src/hooks/useIsVisible.ts +39 -39
  38. package/src/index.ts +1 -1
  39. package/src/utils/MobileUtils.ts +12 -12
@@ -1,180 +1,180 @@
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
- const hideEmpty = original.hideEmpty;
17
-
18
- //v2
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 LocalData = () => {
34
- let [index, setIndex] = useState(scope.updateIndex);
35
- let empty = scope.attr('empty', 'Sem registro');
36
-
37
- scope.update = () => {
38
- scope.updateIndex = ++index;
39
-
40
- setIndex(index);
41
- };
42
-
43
- const items = Utils.call(() => {
44
- let list = Utils.nvl(scope.getItems(), []);
45
-
46
- if (original.search !== false && !original.list?.url) {
47
- let query = crud
48
- .get('query', '')
49
- .toLowerCase()
50
- .trim() as string;
51
-
52
- if (query.length > 1) {
53
- let filters: any[] = [];
54
- let filterBy = Utils.nvl(original.filterBy, 'label');
55
-
56
- Utils.each(list, o => {
57
- let label = Utils.getValue(filterBy, 'none', o).toLowerCase();
58
-
59
- if (label) {
60
- if (label.includes(query)) {
61
- filters.push(o);
62
- }
63
- }
64
- });
65
-
66
- return filters;
67
- }
68
- }
69
- return list;
70
- });
71
-
72
- let isEmpty = Utils.isEmpty(items);
73
-
74
- const isShowAdd = () => {
75
- if (!isEmpty) {
76
- return true;
77
- }
78
- return hideAddWhenEmpty !== true;
79
- };
80
-
81
- let Empty = () => {
82
- if (!isEmpty) {
83
- return <></>;
84
- }
85
-
86
- if (!empty) {
87
- return <></>;
88
- }
89
-
90
- if (typeof empty === 'string') {
91
- return (
92
- <Text
93
- style={scope.getStyle('empty', {
94
- flex: 1,
95
- fontWeight: 400,
96
- fontSize: 18,
97
- padding: 10,
98
- textAlign: 'center',
99
- width: '100%',
100
- justifyContent: 'center',
101
- alignItems: 'center',
102
- })}
103
- >
104
- {empty}
105
- </Text>
106
- );
107
- }
108
-
109
- return <>{empty}</>;
110
- };
111
-
112
- if (empty === false && isEmpty) {
113
- return <></>;
114
- }
115
-
116
- return (
117
- <View style={getContainerStyle()}>
118
- <Empty />
119
- {items.map((item: any, i: number) => (
120
- <UIListRow index={i} item={item} scope={scope}>
121
- {props.children}
122
- </UIListRow>
123
- ))}
124
- {isShowAdd() && <>{add}</>}
125
- </View>
126
- );
127
- };
128
-
129
- let items = Utils.nvl(scope.getItems(), []);
130
-
131
- if (hideEmpty && Utils.isEmpty(items)) {
132
- return <></>;
133
- }
134
-
135
- return (
136
- <>
137
- {original.search !== false && (
138
- <UI.Text
139
- placeholder="Pesquisar..."
140
- field="query"
141
- crud={crud}
142
- style={{ marginBottom: 10 }}
143
- change={{
144
- action: () => {
145
- scope.search();
146
- },
147
- }}
148
- icon={<Ionicons name="search" size={20} color="#888" />}
149
- />
150
- )}
151
- <LocalData />
152
- </>
153
- );
154
- }
155
-
156
- const stylesList = StyleSheet.create({
157
- container: {
158
- display: 'flex',
159
- flexWrap: 'wrap',
160
- gap: 10,
161
- width: '100%',
162
- },
163
- text: {
164
- fontSize: 18,
165
- fontWeight: 'bold',
166
- },
167
- });
168
-
169
- const stylesRepeat = StyleSheet.create({
170
- container: {
171
- display: 'flex',
172
- flexWrap: 'wrap',
173
- gap: 10,
174
- width: '100%',
175
- },
176
- text: {
177
- fontSize: 18,
178
- fontWeight: 'bold',
179
- },
180
- });
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
+ const hideEmpty = original.hideEmpty;
17
+
18
+ //v2
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 LocalData = () => {
34
+ let [index, setIndex] = useState(scope.updateIndex);
35
+ let empty = scope.attr('empty', 'Sem registro');
36
+
37
+ scope.update = () => {
38
+ scope.updateIndex = ++index;
39
+
40
+ setIndex(index);
41
+ };
42
+
43
+ const items = Utils.call(() => {
44
+ let list = Utils.nvl(scope.getItems(), []);
45
+
46
+ if (original.search !== false && !original.list?.url) {
47
+ let query = crud
48
+ .get('query', '')
49
+ .toLowerCase()
50
+ .trim() as string;
51
+
52
+ if (query.length > 1) {
53
+ let filters: any[] = [];
54
+ let filterBy = Utils.nvl(original.filterBy, 'label');
55
+
56
+ Utils.each(list, o => {
57
+ let label = Utils.getValue(filterBy, 'none', o).toLowerCase();
58
+
59
+ if (label) {
60
+ if (label.includes(query)) {
61
+ filters.push(o);
62
+ }
63
+ }
64
+ });
65
+
66
+ return filters;
67
+ }
68
+ }
69
+ return list;
70
+ });
71
+
72
+ let isEmpty = Utils.isEmpty(items);
73
+
74
+ const isShowAdd = () => {
75
+ if (!isEmpty) {
76
+ return true;
77
+ }
78
+ return hideAddWhenEmpty !== true;
79
+ };
80
+
81
+ let Empty = () => {
82
+ if (!isEmpty) {
83
+ return <></>;
84
+ }
85
+
86
+ if (!empty) {
87
+ return <></>;
88
+ }
89
+
90
+ if (typeof empty === 'string') {
91
+ return (
92
+ <Text
93
+ style={scope.getStyle('empty', {
94
+ flex: 1,
95
+ fontWeight: 400,
96
+ fontSize: 18,
97
+ padding: 10,
98
+ textAlign: 'center',
99
+ width: '100%',
100
+ justifyContent: 'center',
101
+ alignItems: 'center',
102
+ })}
103
+ >
104
+ {empty}
105
+ </Text>
106
+ );
107
+ }
108
+
109
+ return <>{empty}</>;
110
+ };
111
+
112
+ if (empty === false && isEmpty) {
113
+ return <></>;
114
+ }
115
+
116
+ return (
117
+ <View style={getContainerStyle()}>
118
+ <Empty />
119
+ {items.map((item: any, i: number) => (
120
+ <UIListRow index={i} item={item} scope={scope}>
121
+ {props.children}
122
+ </UIListRow>
123
+ ))}
124
+ {isShowAdd() && <>{add}</>}
125
+ </View>
126
+ );
127
+ };
128
+
129
+ let items = Utils.nvl(scope.getItems(), []);
130
+
131
+ if (hideEmpty && Utils.isEmpty(items)) {
132
+ return <></>;
133
+ }
134
+
135
+ return (
136
+ <>
137
+ {original.search !== false && (
138
+ <UI.Text
139
+ placeholder="Pesquisar..."
140
+ field="query"
141
+ crud={crud}
142
+ style={{ marginBottom: 10 }}
143
+ change={{
144
+ action: () => {
145
+ scope.search();
146
+ },
147
+ }}
148
+ icon={<Ionicons name="search" size={20} color="#888" />}
149
+ />
150
+ )}
151
+ <LocalData />
152
+ </>
153
+ );
154
+ }
155
+
156
+ const stylesList = StyleSheet.create({
157
+ container: {
158
+ display: 'flex',
159
+ flexWrap: 'wrap',
160
+ gap: 10,
161
+ width: '100%',
162
+ },
163
+ text: {
164
+ fontSize: 18,
165
+ fontWeight: 'bold',
166
+ },
167
+ });
168
+
169
+ const stylesRepeat = StyleSheet.create({
170
+ container: {
171
+ display: 'flex',
172
+ flexWrap: 'wrap',
173
+ gap: 10,
174
+ width: '100%',
175
+ },
176
+ text: {
177
+ fontSize: 18,
178
+ fontWeight: 'bold',
179
+ },
180
+ });
@@ -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,132 +1,132 @@
1
- import React, { useRef, 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
- import { useIsVisible } from '../../hooks/useIsVisible';
6
-
7
- interface UIListRowType extends ChildType {
8
- item: any;
9
- index: number;
10
- }
11
-
12
- export default function UIListRow(props: UIListRowType) {
13
- const scope = props.scope;
14
- const index = props.index;
15
- const original = scope.original;
16
- const item = props.item;
17
- const cols = scope.getPart('cols', undefined, -1);
18
- const rowWidth = Math.floor(100 / cols) + '%';
19
- const styles = { repeat: stylesRepeat, list: stylesList }?.[original.type];
20
- const name = `${scope.key('row', index, '')}`;
21
- const [row] = useState(
22
- ScopeUtils.create({
23
- ...original,
24
- parent: scope,
25
- name,
26
- crud: scope.crud,
27
- index,
28
- type: 'row',
29
- data: item,
30
- })
31
- );
32
-
33
- //v5
34
- const targetRef = useRef(null);
35
- const isVisible = useIsVisible(targetRef, row);
36
-
37
- const onClick = (item: any) => {
38
- row.call('click', { value: item, item, edit: true, index });
39
- };
40
-
41
- const Child = () => {
42
- if (!isVisible && original.useIsInView && !row.visible && index > 20) {
43
- return <></>;
44
- }
45
- return (
46
- <>
47
- <UIChildren transient scope={row} crud={row.crud}>
48
- {props.children}
49
- </UIChildren>
50
- </>
51
- );
52
- };
53
-
54
- const ListItem = () => {
55
- let [updateIndex, setUpdateIndex] = useState(0);
56
- let key = scope.key('item');
57
-
58
- row.selected = row.getPart('isSelectedRow', undefined, false);
59
-
60
- const getRowStyle = () => {
61
- let css = row.getStyle('row', { ...styles.row, minHeight: 40 });
62
-
63
- if (row.selected) {
64
- css = { ...css, ...row.getStyle('rowSelected', {}) };
65
- } else {
66
- css = { ...css, ...row.getStyle('rowUnSelected', {}) };
67
- }
68
-
69
- if (cols > 0) {
70
- css.width = rowWidth;
71
- }
72
-
73
- return css;
74
- };
75
-
76
- row.update = () => {
77
- scope.updateIndex = scope.updateIndex + 1;
78
-
79
- setUpdateIndex(++updateIndex);
80
- };
81
-
82
- let renderedRow = row.getPart('renderedItem', undefined, true);
83
-
84
- if (renderedRow === false) {
85
- return <></>;
86
- }
87
-
88
- if (!original.click) {
89
- return (
90
- <View key={key} style={getRowStyle()} ref={targetRef}>
91
- <Child />
92
- </View>
93
- );
94
- }
95
- return (
96
- <TouchableHighlight
97
- key={key}
98
- style={getRowStyle()}
99
- underlayColor={'transparent'}
100
- ref={targetRef}
101
- onPress={e => {
102
- e.stopPropagation();
103
- onClick(item);
104
- }}
105
- >
106
- <Child />
107
- </TouchableHighlight>
108
- );
109
- };
110
-
111
- return <ListItem />;
112
- }
113
-
114
- const stylesList = StyleSheet.create({
115
- row: {
116
- padding: 5,
117
- margin: 0,
118
- width: '100%',
119
- backgroundColor: 'background',
120
- gap: 10,
121
- borderRadius: 8,
122
- justifyContent: 'center',
123
- },
124
- });
125
-
126
- const stylesRepeat = StyleSheet.create({
127
- row: {
128
- padding: 0,
129
- width: '100%',
130
- justifyContent: 'center',
131
- },
132
- });
1
+ import React, { useRef, 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
+ import { useIsVisible } from '../../hooks/useIsVisible';
6
+
7
+ interface UIListRowType extends ChildType {
8
+ item: any;
9
+ index: number;
10
+ }
11
+
12
+ export default function UIListRow(props: UIListRowType) {
13
+ const scope = props.scope;
14
+ const index = props.index;
15
+ const original = scope.original;
16
+ const item = props.item;
17
+ const cols = scope.getPart('cols', undefined, -1);
18
+ const rowWidth = Math.floor(100 / cols) + '%';
19
+ const styles = { repeat: stylesRepeat, list: stylesList }?.[original.type];
20
+ const name = `${scope.key('row', index, '')}`;
21
+ const [row] = useState(
22
+ ScopeUtils.create({
23
+ ...original,
24
+ parent: scope,
25
+ name,
26
+ crud: scope.crud,
27
+ index,
28
+ type: 'row',
29
+ data: item,
30
+ })
31
+ );
32
+
33
+ //v5
34
+ const targetRef = useRef(null);
35
+ const isVisible = useIsVisible(targetRef, row);
36
+
37
+ const onClick = (item: any) => {
38
+ row.call('click', { value: item, item, edit: true, index });
39
+ };
40
+
41
+ const Child = () => {
42
+ if (!isVisible && original.useIsInView && !row.visible && index > 20) {
43
+ return <></>;
44
+ }
45
+ return (
46
+ <>
47
+ <UIChildren transient scope={row} crud={row.crud}>
48
+ {props.children}
49
+ </UIChildren>
50
+ </>
51
+ );
52
+ };
53
+
54
+ const ListItem = () => {
55
+ let [updateIndex, setUpdateIndex] = useState(0);
56
+ let key = scope.key('item');
57
+
58
+ row.selected = row.getPart('isSelectedRow', undefined, false);
59
+
60
+ const getRowStyle = () => {
61
+ let css = row.getStyle('row', { ...styles.row, minHeight: 40 });
62
+
63
+ if (row.selected) {
64
+ css = { ...css, ...row.getStyle('rowSelected', {}) };
65
+ } else {
66
+ css = { ...css, ...row.getStyle('rowUnSelected', {}) };
67
+ }
68
+
69
+ if (cols > 0) {
70
+ css.width = rowWidth;
71
+ }
72
+
73
+ return css;
74
+ };
75
+
76
+ row.update = () => {
77
+ scope.updateIndex = scope.updateIndex + 1;
78
+
79
+ setUpdateIndex(++updateIndex);
80
+ };
81
+
82
+ let renderedRow = row.getPart('renderedItem', undefined, true);
83
+
84
+ if (renderedRow === false) {
85
+ return <></>;
86
+ }
87
+
88
+ if (!original.click) {
89
+ return (
90
+ <View key={key} style={getRowStyle()} ref={targetRef}>
91
+ <Child />
92
+ </View>
93
+ );
94
+ }
95
+ return (
96
+ <TouchableHighlight
97
+ key={key}
98
+ style={getRowStyle()}
99
+ underlayColor={'transparent'}
100
+ ref={targetRef}
101
+ onPress={e => {
102
+ e.stopPropagation();
103
+ onClick(item);
104
+ }}
105
+ >
106
+ <Child />
107
+ </TouchableHighlight>
108
+ );
109
+ };
110
+
111
+ return <ListItem />;
112
+ }
113
+
114
+ const stylesList = StyleSheet.create({
115
+ row: {
116
+ padding: 5,
117
+ margin: 0,
118
+ width: '100%',
119
+ backgroundColor: 'background',
120
+ gap: 10,
121
+ borderRadius: 8,
122
+ justifyContent: 'center',
123
+ },
124
+ });
125
+
126
+ const stylesRepeat = StyleSheet.create({
127
+ row: {
128
+ padding: 0,
129
+ width: '100%',
130
+ justifyContent: 'center',
131
+ },
132
+ });