react-crud-mobile 1.3.99 → 1.3.101
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/elements/core/UIStatusBar.d.ts +2 -0
- package/dist/react-crud-mobile.cjs.development.js +10 -4
- 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 +11 -5
- package/dist/react-crud-mobile.esm.js.map +1 -1
- package/package.json +77 -76
- package/src/elements/UI.tsx +74 -74
- package/src/elements/UIChildren.tsx +139 -139
- package/src/elements/UIComplete.tsx +14 -14
- package/src/elements/UIElement.tsx +788 -788
- package/src/elements/UITag.tsx +13 -13
- package/src/elements/charts/ElChart.tsx +10 -10
- package/src/elements/core/SafeView.tsx +62 -63
- package/src/elements/core/UIButton.tsx +139 -139
- package/src/elements/core/UIHeader.tsx +38 -38
- package/src/elements/core/UIIcon.tsx +25 -25
- package/src/elements/core/UIInclude.tsx +40 -40
- package/src/elements/core/UIInput.tsx +96 -96
- package/src/elements/core/UIList.tsx +168 -168
- package/src/elements/core/UIListRow.tsx +123 -123
- package/src/elements/core/UIModal.tsx +176 -174
- package/src/elements/core/UIOrder.tsx +123 -123
- package/src/elements/core/UIQuantity.tsx +98 -98
- package/src/elements/core/UISelect.tsx +171 -171
- package/src/elements/core/UIStatusBar.tsx +5 -0
- package/src/elements/core/UIToast.tsx +44 -44
- package/src/elements/core/UIToggle.tsx +102 -102
- package/src/elements/core/UIView.tsx +69 -69
- package/src/elements/index.ts +1 -1
- package/src/elements/tabs/ElTabs.tsx +178 -178
- package/src/index.ts +1 -1
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { ChildType, ComponentUtils, ScopeUtils, Utils } from 'react-crud-utils';
|
|
3
|
-
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
|
4
|
-
import UI from '../UI';
|
|
5
|
-
import { Ionicons, MaterialCommunityIcons } from '@expo/vector-icons';
|
|
6
|
-
import DraggableFlatList, {
|
|
7
|
-
ScaleDecorator,
|
|
8
|
-
} from 'react-native-draggable-flatlist';
|
|
9
|
-
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
10
|
-
import UIHeader from './UIHeader';
|
|
11
|
-
|
|
12
|
-
export default function UIOrder(props: ChildType) {
|
|
13
|
-
const scope = props.scope;
|
|
14
|
-
const crud = scope.crud;
|
|
15
|
-
const original = scope.original;
|
|
16
|
-
const cols = Utils.nvl(scope.getPart('cols', undefined, 1));
|
|
17
|
-
|
|
18
|
-
const getStyle = (key: string, extra?: any) => {
|
|
19
|
-
return scope.getStyle(key, { ...extra, ...styles[key] });
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const getContainerStyle = (extra?: any) => {
|
|
23
|
-
let row = getStyle('container', {});
|
|
24
|
-
|
|
25
|
-
if (cols > 1) {
|
|
26
|
-
row = { ...row, flexDirection: 'row', flexWrap: 'wrap' };
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return row;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const items = Utils.call(() => {
|
|
33
|
-
let list = Utils.nvl(scope.getItems(), []);
|
|
34
|
-
|
|
35
|
-
if (original.search && !original.list?.url) {
|
|
36
|
-
let query = crud
|
|
37
|
-
.get('query', '')
|
|
38
|
-
.toLowerCase()
|
|
39
|
-
.trim() as string;
|
|
40
|
-
|
|
41
|
-
if (query.length > 1) {
|
|
42
|
-
let filters: any[] = [];
|
|
43
|
-
let filterBy = Utils.nvl(original.filterBy, 'label');
|
|
44
|
-
|
|
45
|
-
Utils.each(list, o => {
|
|
46
|
-
let label = o[filterBy];
|
|
47
|
-
|
|
48
|
-
if (label) {
|
|
49
|
-
if (label.includes(query)) {
|
|
50
|
-
filters.push(o);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
return filters;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return list;
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
//v2
|
|
62
|
-
|
|
63
|
-
const renderItem = ({ item, drag, isActive }) => {
|
|
64
|
-
let state = { ...scope.getStyle('row') };
|
|
65
|
-
|
|
66
|
-
if (isActive) {
|
|
67
|
-
state = { ...state, ...scope.getStyle('active') };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<ScaleDecorator>
|
|
72
|
-
<TouchableOpacity
|
|
73
|
-
style={[
|
|
74
|
-
styles.row,
|
|
75
|
-
{ backgroundColor: isActive ? 'lightblue' : 'white' },
|
|
76
|
-
{ ...state },
|
|
77
|
-
]}
|
|
78
|
-
delayLongPress={100}
|
|
79
|
-
onLongPress={drag} // Initiate drag on long press
|
|
80
|
-
>
|
|
81
|
-
<MaterialCommunityIcons name="drag" size={24} color="black" />
|
|
82
|
-
<Text style={styles.text}>{scope.getItemLabel(item)}</Text>
|
|
83
|
-
</TouchableOpacity>
|
|
84
|
-
</ScaleDecorator>
|
|
85
|
-
);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const [data, setData] = useState(items);
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
<GestureHandlerRootView
|
|
92
|
-
style={{
|
|
93
|
-
flex: 1,
|
|
94
|
-
width: '100%',
|
|
95
|
-
...scope.getStyle('order', { justifyContent: 'flex-start' }),
|
|
96
|
-
}}
|
|
97
|
-
>
|
|
98
|
-
<UIHeader scope={scope} />
|
|
99
|
-
<DraggableFlatList
|
|
100
|
-
data={data}
|
|
101
|
-
renderItem={renderItem}
|
|
102
|
-
keyExtractor={item => scope.getItemValue(item)}
|
|
103
|
-
onDragEnd={({ data }) => {
|
|
104
|
-
setData(data);
|
|
105
|
-
scope.changeValue(data);
|
|
106
|
-
}}
|
|
107
|
-
/>
|
|
108
|
-
</GestureHandlerRootView>
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const styles = StyleSheet.create({
|
|
113
|
-
row: {
|
|
114
|
-
flexDirection: 'row',
|
|
115
|
-
gap: 10,
|
|
116
|
-
padding: 15,
|
|
117
|
-
borderBottomWidth: 1,
|
|
118
|
-
borderBottomColor: '#ccc',
|
|
119
|
-
},
|
|
120
|
-
text: {
|
|
121
|
-
fontSize: 18,
|
|
122
|
-
},
|
|
123
|
-
});
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { ChildType, ComponentUtils, ScopeUtils, Utils } from 'react-crud-utils';
|
|
3
|
+
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
|
4
|
+
import UI from '../UI';
|
|
5
|
+
import { Ionicons, MaterialCommunityIcons } from '@expo/vector-icons';
|
|
6
|
+
import DraggableFlatList, {
|
|
7
|
+
ScaleDecorator,
|
|
8
|
+
} from 'react-native-draggable-flatlist';
|
|
9
|
+
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
10
|
+
import UIHeader from './UIHeader';
|
|
11
|
+
|
|
12
|
+
export default function UIOrder(props: ChildType) {
|
|
13
|
+
const scope = props.scope;
|
|
14
|
+
const crud = scope.crud;
|
|
15
|
+
const original = scope.original;
|
|
16
|
+
const cols = Utils.nvl(scope.getPart('cols', undefined, 1));
|
|
17
|
+
|
|
18
|
+
const getStyle = (key: string, extra?: any) => {
|
|
19
|
+
return scope.getStyle(key, { ...extra, ...styles[key] });
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const getContainerStyle = (extra?: any) => {
|
|
23
|
+
let row = getStyle('container', {});
|
|
24
|
+
|
|
25
|
+
if (cols > 1) {
|
|
26
|
+
row = { ...row, flexDirection: 'row', flexWrap: 'wrap' };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return row;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const items = Utils.call(() => {
|
|
33
|
+
let list = Utils.nvl(scope.getItems(), []);
|
|
34
|
+
|
|
35
|
+
if (original.search && !original.list?.url) {
|
|
36
|
+
let query = crud
|
|
37
|
+
.get('query', '')
|
|
38
|
+
.toLowerCase()
|
|
39
|
+
.trim() as string;
|
|
40
|
+
|
|
41
|
+
if (query.length > 1) {
|
|
42
|
+
let filters: any[] = [];
|
|
43
|
+
let filterBy = Utils.nvl(original.filterBy, 'label');
|
|
44
|
+
|
|
45
|
+
Utils.each(list, o => {
|
|
46
|
+
let label = o[filterBy];
|
|
47
|
+
|
|
48
|
+
if (label) {
|
|
49
|
+
if (label.includes(query)) {
|
|
50
|
+
filters.push(o);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return filters;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return list;
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
//v2
|
|
62
|
+
|
|
63
|
+
const renderItem = ({ item, drag, isActive }) => {
|
|
64
|
+
let state = { ...scope.getStyle('row') };
|
|
65
|
+
|
|
66
|
+
if (isActive) {
|
|
67
|
+
state = { ...state, ...scope.getStyle('active') };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<ScaleDecorator>
|
|
72
|
+
<TouchableOpacity
|
|
73
|
+
style={[
|
|
74
|
+
styles.row,
|
|
75
|
+
{ backgroundColor: isActive ? 'lightblue' : 'white' },
|
|
76
|
+
{ ...state },
|
|
77
|
+
]}
|
|
78
|
+
delayLongPress={100}
|
|
79
|
+
onLongPress={drag} // Initiate drag on long press
|
|
80
|
+
>
|
|
81
|
+
<MaterialCommunityIcons name="drag" size={24} color="black" />
|
|
82
|
+
<Text style={styles.text}>{scope.getItemLabel(item)}</Text>
|
|
83
|
+
</TouchableOpacity>
|
|
84
|
+
</ScaleDecorator>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const [data, setData] = useState(items);
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<GestureHandlerRootView
|
|
92
|
+
style={{
|
|
93
|
+
flex: 1,
|
|
94
|
+
width: '100%',
|
|
95
|
+
...scope.getStyle('order', { justifyContent: 'flex-start' }),
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
<UIHeader scope={scope} />
|
|
99
|
+
<DraggableFlatList
|
|
100
|
+
data={data}
|
|
101
|
+
renderItem={renderItem}
|
|
102
|
+
keyExtractor={item => scope.getItemValue(item)}
|
|
103
|
+
onDragEnd={({ data }) => {
|
|
104
|
+
setData(data);
|
|
105
|
+
scope.changeValue(data);
|
|
106
|
+
}}
|
|
107
|
+
/>
|
|
108
|
+
</GestureHandlerRootView>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const styles = StyleSheet.create({
|
|
113
|
+
row: {
|
|
114
|
+
flexDirection: 'row',
|
|
115
|
+
gap: 10,
|
|
116
|
+
padding: 15,
|
|
117
|
+
borderBottomWidth: 1,
|
|
118
|
+
borderBottomColor: '#ccc',
|
|
119
|
+
},
|
|
120
|
+
text: {
|
|
121
|
+
fontSize: 18,
|
|
122
|
+
},
|
|
123
|
+
});
|
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
import { Ionicons } from '@expo/vector-icons';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import { ChildType, Utils } from 'react-crud-utils';
|
|
4
|
-
import { Text, TouchableHighlight, View } from 'react-native';
|
|
5
|
-
|
|
6
|
-
export default function UIQuantity(props: ChildType) {
|
|
7
|
-
const scope = props.scope;
|
|
8
|
-
const element = scope.original;
|
|
9
|
-
|
|
10
|
-
let [index, setIndex] = useState(0);
|
|
11
|
-
|
|
12
|
-
const value = scope.getValue(0);
|
|
13
|
-
|
|
14
|
-
let color = element.color;
|
|
15
|
-
|
|
16
|
-
if (!color) color = 'primary';
|
|
17
|
-
|
|
18
|
-
const btn = {
|
|
19
|
-
padding: 0,
|
|
20
|
-
alignItems: 'center',
|
|
21
|
-
height: 30,
|
|
22
|
-
width: 30,
|
|
23
|
-
textAlign: 'center',
|
|
24
|
-
verticalAling: 'middle',
|
|
25
|
-
borderRadius: 24,
|
|
26
|
-
backgroundColor: color,
|
|
27
|
-
color: '#ffffff',
|
|
28
|
-
justifyContent: 'center',
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const styles: any = {
|
|
32
|
-
buttonLabel: {
|
|
33
|
-
color: '#ffffff',
|
|
34
|
-
fontWeight: '500',
|
|
35
|
-
fontSize: 16,
|
|
36
|
-
},
|
|
37
|
-
value: {
|
|
38
|
-
flex: 1,
|
|
39
|
-
flexDirection: 'row',
|
|
40
|
-
textAlign: 'center',
|
|
41
|
-
fontWeight: '500',
|
|
42
|
-
},
|
|
43
|
-
buttonInner: {
|
|
44
|
-
flexDirection: 'row',
|
|
45
|
-
alignItems: 'center',
|
|
46
|
-
justifyContent: 'center',
|
|
47
|
-
},
|
|
48
|
-
buttonIcon: {
|
|
49
|
-
color: '#fff',
|
|
50
|
-
fontSize: 18,
|
|
51
|
-
},
|
|
52
|
-
button: btn,
|
|
53
|
-
addButton: {
|
|
54
|
-
...btn,
|
|
55
|
-
},
|
|
56
|
-
delButton: {
|
|
57
|
-
...btn,
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const change = (val: number) => {
|
|
62
|
-
scope.changeValue(value + val);
|
|
63
|
-
setIndex(++index);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const onClickAdd = () => {
|
|
67
|
-
change(1);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const onClickDel = () => {
|
|
71
|
-
change(-1);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const style = (part: string, extra?: any) => {
|
|
75
|
-
let s = { ...styles[part], ...extra };
|
|
76
|
-
return scope.getStyle(part, s);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<>
|
|
81
|
-
<TouchableHighlight
|
|
82
|
-
underlayColor={'transparent'}
|
|
83
|
-
onPress={onClickDel}
|
|
84
|
-
style={style('delButton')}
|
|
85
|
-
>
|
|
86
|
-
<Ionicons size={30} style={style('buttonIcon')} name="remove" />
|
|
87
|
-
</TouchableHighlight>
|
|
88
|
-
<Text style={style('value')}>{Utils.nvl(value, 0)}</Text>
|
|
89
|
-
<TouchableHighlight
|
|
90
|
-
underlayColor={'transparent'}
|
|
91
|
-
onPress={onClickAdd}
|
|
92
|
-
style={style('addButton')}
|
|
93
|
-
>
|
|
94
|
-
<Ionicons size={30} style={style('buttonIcon')} name="add" />
|
|
95
|
-
</TouchableHighlight>
|
|
96
|
-
</>
|
|
97
|
-
);
|
|
98
|
-
}
|
|
1
|
+
import { Ionicons } from '@expo/vector-icons';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { ChildType, Utils } from 'react-crud-utils';
|
|
4
|
+
import { Text, TouchableHighlight, View } from 'react-native';
|
|
5
|
+
|
|
6
|
+
export default function UIQuantity(props: ChildType) {
|
|
7
|
+
const scope = props.scope;
|
|
8
|
+
const element = scope.original;
|
|
9
|
+
|
|
10
|
+
let [index, setIndex] = useState(0);
|
|
11
|
+
|
|
12
|
+
const value = scope.getValue(0);
|
|
13
|
+
|
|
14
|
+
let color = element.color;
|
|
15
|
+
|
|
16
|
+
if (!color) color = 'primary';
|
|
17
|
+
|
|
18
|
+
const btn = {
|
|
19
|
+
padding: 0,
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
height: 30,
|
|
22
|
+
width: 30,
|
|
23
|
+
textAlign: 'center',
|
|
24
|
+
verticalAling: 'middle',
|
|
25
|
+
borderRadius: 24,
|
|
26
|
+
backgroundColor: color,
|
|
27
|
+
color: '#ffffff',
|
|
28
|
+
justifyContent: 'center',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const styles: any = {
|
|
32
|
+
buttonLabel: {
|
|
33
|
+
color: '#ffffff',
|
|
34
|
+
fontWeight: '500',
|
|
35
|
+
fontSize: 16,
|
|
36
|
+
},
|
|
37
|
+
value: {
|
|
38
|
+
flex: 1,
|
|
39
|
+
flexDirection: 'row',
|
|
40
|
+
textAlign: 'center',
|
|
41
|
+
fontWeight: '500',
|
|
42
|
+
},
|
|
43
|
+
buttonInner: {
|
|
44
|
+
flexDirection: 'row',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
justifyContent: 'center',
|
|
47
|
+
},
|
|
48
|
+
buttonIcon: {
|
|
49
|
+
color: '#fff',
|
|
50
|
+
fontSize: 18,
|
|
51
|
+
},
|
|
52
|
+
button: btn,
|
|
53
|
+
addButton: {
|
|
54
|
+
...btn,
|
|
55
|
+
},
|
|
56
|
+
delButton: {
|
|
57
|
+
...btn,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const change = (val: number) => {
|
|
62
|
+
scope.changeValue(value + val);
|
|
63
|
+
setIndex(++index);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const onClickAdd = () => {
|
|
67
|
+
change(1);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const onClickDel = () => {
|
|
71
|
+
change(-1);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const style = (part: string, extra?: any) => {
|
|
75
|
+
let s = { ...styles[part], ...extra };
|
|
76
|
+
return scope.getStyle(part, s);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<>
|
|
81
|
+
<TouchableHighlight
|
|
82
|
+
underlayColor={'transparent'}
|
|
83
|
+
onPress={onClickDel}
|
|
84
|
+
style={style('delButton')}
|
|
85
|
+
>
|
|
86
|
+
<Ionicons size={30} style={style('buttonIcon')} name="remove" />
|
|
87
|
+
</TouchableHighlight>
|
|
88
|
+
<Text style={style('value')}>{Utils.nvl(value, 0)}</Text>
|
|
89
|
+
<TouchableHighlight
|
|
90
|
+
underlayColor={'transparent'}
|
|
91
|
+
onPress={onClickAdd}
|
|
92
|
+
style={style('addButton')}
|
|
93
|
+
>
|
|
94
|
+
<Ionicons size={30} style={style('buttonIcon')} name="add" />
|
|
95
|
+
</TouchableHighlight>
|
|
96
|
+
</>
|
|
97
|
+
);
|
|
98
|
+
}
|