react-crud-mobile 1.3.57 → 1.3.59
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.
- package/dist/react-crud-mobile.cjs.development.js +48 -64
- package/dist/react-crud-mobile.cjs.development.js.map +1 -1
- package/dist/react-crud-mobile.cjs.production.min.js +1 -1
- package/dist/react-crud-mobile.cjs.production.min.js.map +1 -1
- package/dist/react-crud-mobile.esm.js +47 -64
- package/dist/react-crud-mobile.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/elements/core/UIOrder.tsx +42 -53
package/package.json
CHANGED
|
@@ -3,7 +3,9 @@ import { ChildType, ComponentUtils, ScopeUtils, Utils } from 'react-crud-utils';
|
|
|
3
3
|
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
|
4
4
|
import UI from '../UI';
|
|
5
5
|
import { Ionicons } from '@expo/vector-icons';
|
|
6
|
-
import DraggableFlatList
|
|
6
|
+
import DraggableFlatList, {
|
|
7
|
+
ScaleDecorator,
|
|
8
|
+
} from 'react-native-draggable-flatlist';
|
|
7
9
|
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
8
10
|
|
|
9
11
|
export default function UIOrder(props: ChildType) {
|
|
@@ -11,7 +13,6 @@ export default function UIOrder(props: ChildType) {
|
|
|
11
13
|
const crud = scope.crud;
|
|
12
14
|
const original = scope.original;
|
|
13
15
|
const cols = Utils.nvl(scope.getPart('cols', undefined, 1));
|
|
14
|
-
const hideAddWhenEmpty = original.hideAddWhenEmpty;
|
|
15
16
|
|
|
16
17
|
const getStyle = (key: string, extra?: any) => {
|
|
17
18
|
return scope.getStyle(key, { ...extra, ...styles[key] });
|
|
@@ -27,48 +28,38 @@ export default function UIOrder(props: ChildType) {
|
|
|
27
28
|
return row;
|
|
28
29
|
};
|
|
29
30
|
|
|
30
|
-
const
|
|
31
|
-
let
|
|
31
|
+
const items = Utils.call(() => {
|
|
32
|
+
let list = Utils.nvl(scope.getItems(), []);
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
if (original.search && !original.list?.url) {
|
|
35
|
+
let query = crud
|
|
36
|
+
.get('query', '')
|
|
37
|
+
.toLowerCase()
|
|
38
|
+
.trim() as string;
|
|
35
39
|
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
if (query.length > 1) {
|
|
41
|
+
let filters: any[] = [];
|
|
42
|
+
let filterBy = Utils.nvl(original.filterBy, 'label');
|
|
38
43
|
|
|
39
|
-
|
|
44
|
+
Utils.each(list, o => {
|
|
45
|
+
let label = o[filterBy];
|
|
40
46
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (original.search && !original.list?.url) {
|
|
45
|
-
let query = crud
|
|
46
|
-
.get('query', '')
|
|
47
|
-
.toLowerCase()
|
|
48
|
-
.trim() as string;
|
|
49
|
-
|
|
50
|
-
if (query.length > 1) {
|
|
51
|
-
let filters: any[] = [];
|
|
52
|
-
let filterBy = Utils.nvl(original.filterBy, 'label');
|
|
53
|
-
|
|
54
|
-
Utils.each(list, o => {
|
|
55
|
-
let label = o[filterBy];
|
|
56
|
-
|
|
57
|
-
if (label) {
|
|
58
|
-
if (label.includes(query)) {
|
|
59
|
-
filters.push(o);
|
|
60
|
-
}
|
|
47
|
+
if (label) {
|
|
48
|
+
if (label.includes(query)) {
|
|
49
|
+
filters.push(o);
|
|
61
50
|
}
|
|
62
|
-
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
63
53
|
|
|
64
|
-
|
|
65
|
-
}
|
|
54
|
+
return filters;
|
|
66
55
|
}
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
}
|
|
57
|
+
return list;
|
|
58
|
+
});
|
|
69
59
|
|
|
70
|
-
|
|
71
|
-
|
|
60
|
+
const renderItem = ({ item, drag, isActive }) => {
|
|
61
|
+
return (
|
|
62
|
+
<ScaleDecorator>
|
|
72
63
|
<TouchableOpacity
|
|
73
64
|
style={[
|
|
74
65
|
styles.row,
|
|
@@ -78,25 +69,14 @@ export default function UIOrder(props: ChildType) {
|
|
|
78
69
|
>
|
|
79
70
|
<Text style={styles.text}>{scope.getItemLabel(item)}</Text>
|
|
80
71
|
</TouchableOpacity>
|
|
81
|
-
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<View key={keyData} style={getContainerStyle()}>
|
|
86
|
-
<DraggableFlatList
|
|
87
|
-
data={items}
|
|
88
|
-
renderItem={renderItem}
|
|
89
|
-
keyExtractor={item => scope.getItemValue(item)}
|
|
90
|
-
onDragEnd={({ data }) => {
|
|
91
|
-
scope.changeValue(data);
|
|
92
|
-
}}
|
|
93
|
-
/>
|
|
94
|
-
</View>
|
|
72
|
+
</ScaleDecorator>
|
|
95
73
|
);
|
|
96
74
|
};
|
|
97
75
|
|
|
76
|
+
const [data, setData] = useState(items);
|
|
77
|
+
|
|
98
78
|
return (
|
|
99
|
-
|
|
79
|
+
<GestureHandlerRootView style={{ flex: 1, ...scope.getStyle('container') }}>
|
|
100
80
|
{original.search !== false && (
|
|
101
81
|
<UI.Text
|
|
102
82
|
placeholder="Pesquisar..."
|
|
@@ -111,8 +91,17 @@ export default function UIOrder(props: ChildType) {
|
|
|
111
91
|
icon={<Ionicons name="search" size={20} color="#888" />}
|
|
112
92
|
/>
|
|
113
93
|
)}
|
|
114
|
-
|
|
115
|
-
|
|
94
|
+
|
|
95
|
+
<DraggableFlatList
|
|
96
|
+
data={data}
|
|
97
|
+
renderItem={renderItem}
|
|
98
|
+
keyExtractor={item => scope.getItemValue(item)}
|
|
99
|
+
onDragEnd={({ data }) => {
|
|
100
|
+
setData(data);
|
|
101
|
+
scope.changeValue(data);
|
|
102
|
+
}}
|
|
103
|
+
/>
|
|
104
|
+
</GestureHandlerRootView>
|
|
116
105
|
);
|
|
117
106
|
}
|
|
118
107
|
|