react-crud-mobile 1.0.533 → 1.0.535
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 +8 -2
- 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 +8 -2
- package/dist/react-crud-mobile.esm.js.map +1 -1
- package/package.json +73 -73
- package/src/elements/UI.tsx +67 -67
- package/src/elements/UIChildren.tsx +127 -127
- package/src/elements/UIComplete.tsx +14 -14
- package/src/elements/UIElement.tsx +548 -548
- package/src/elements/UITag.tsx +13 -13
- package/src/elements/charts/ElChart.tsx +10 -10
- package/src/elements/core/UIButton.tsx +85 -85
- package/src/elements/core/UIIcon.tsx +8 -8
- package/src/elements/core/UIInclude.tsx +40 -40
- package/src/elements/core/UIInput.tsx +69 -69
- package/src/elements/core/UIList.tsx +173 -173
- package/src/elements/core/UIListRow.tsx +32 -32
- package/src/elements/core/UIModal.tsx +173 -165
- package/src/elements/core/UIQuantity.tsx +97 -97
- package/src/elements/core/UISelect.tsx +122 -122
- package/src/elements/core/UIToggle.tsx +102 -102
- package/src/elements/core/UIView.tsx +42 -42
- package/src/elements/index.ts +1 -1
- package/src/elements/tabs/ElTabs.tsx +178 -178
- package/src/index.ts +1 -1
|
@@ -1,165 +1,173 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
ChildType,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
let [
|
|
25
|
-
let
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
let
|
|
52
|
-
let
|
|
53
|
-
let
|
|
54
|
-
let
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
StatusBar.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
<
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ChildType,
|
|
4
|
+
ComponentUtils,
|
|
5
|
+
CrudUtils,
|
|
6
|
+
MethodType,
|
|
7
|
+
useTheme,
|
|
8
|
+
Utils,
|
|
9
|
+
ViewUtils,
|
|
10
|
+
} from 'react-crud-utils';
|
|
11
|
+
import {
|
|
12
|
+
Text,
|
|
13
|
+
TouchableOpacity,
|
|
14
|
+
StyleSheet,
|
|
15
|
+
Modal,
|
|
16
|
+
View,
|
|
17
|
+
StatusBar,
|
|
18
|
+
SafeAreaView,
|
|
19
|
+
ScrollView,
|
|
20
|
+
} from 'react-native';
|
|
21
|
+
import UIChildren from '../UIChildren';
|
|
22
|
+
|
|
23
|
+
export default function UIModal(props: ChildType) {
|
|
24
|
+
let [modalVisible, setModalVisible] = useState(false);
|
|
25
|
+
let [index, setIndex] = useState(0);
|
|
26
|
+
let main = ViewUtils.getCrud('view');
|
|
27
|
+
|
|
28
|
+
const scope = props.scope;
|
|
29
|
+
const label = scope.getLabel();
|
|
30
|
+
const theme = useTheme();
|
|
31
|
+
|
|
32
|
+
const style = (part: string, extra?: any) => {
|
|
33
|
+
let st = { ...styles[part], ...extra };
|
|
34
|
+
|
|
35
|
+
return { ...scope.getStyle(part, st) };
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const onClose = () => {
|
|
39
|
+
scope.close({ scope, crud: scope.currentDialog, event: {} });
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const toggle = vis => {
|
|
43
|
+
modalVisible = vis;
|
|
44
|
+
setModalVisible(modalVisible);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
scope.update = () => {
|
|
48
|
+
setIndex(++index);
|
|
49
|
+
};
|
|
50
|
+
scope.show = (args?: MethodType) => {
|
|
51
|
+
let { crud } = args;
|
|
52
|
+
let name = scope.getName('modal');
|
|
53
|
+
let data = Utils.nvl(args.item, {});
|
|
54
|
+
let edit = args.edit === true;
|
|
55
|
+
let def: any = {};
|
|
56
|
+
|
|
57
|
+
if (crud.is('search')) {
|
|
58
|
+
def.parent = crud.parent;
|
|
59
|
+
def.search = crud;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let d = CrudUtils.create('dialog', {
|
|
63
|
+
parent: crud,
|
|
64
|
+
name,
|
|
65
|
+
dialog: main.dialog,
|
|
66
|
+
data,
|
|
67
|
+
edit,
|
|
68
|
+
scope,
|
|
69
|
+
...def,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
main.dialog = d;
|
|
73
|
+
|
|
74
|
+
scope.currentDialog = d;
|
|
75
|
+
|
|
76
|
+
toggle(true);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
scope.hide = (args?: MethodType) => {
|
|
80
|
+
let old = scope.currentDialog;
|
|
81
|
+
|
|
82
|
+
main.dialog = Utils.nvl(old.dialog, null);
|
|
83
|
+
scope.currentDialog = null;
|
|
84
|
+
|
|
85
|
+
toggle(false);
|
|
86
|
+
|
|
87
|
+
if (main.dialog?.scope) {
|
|
88
|
+
main.dialog.scope.update();
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
StatusBar.setBarStyle('light-content');
|
|
94
|
+
StatusBar.setBackgroundColor?.(theme.colors.primary);
|
|
95
|
+
}, [modalVisible]);
|
|
96
|
+
|
|
97
|
+
let curr = scope.currentDialog;
|
|
98
|
+
|
|
99
|
+
if (!curr) {
|
|
100
|
+
return <></>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (curr.uuid !== main.dialog.uuid) {
|
|
104
|
+
return <></>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const headerRight = ComponentUtils.getDefine(props, 'header', 'right');
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<Modal
|
|
111
|
+
animationType="slide"
|
|
112
|
+
transparent={true}
|
|
113
|
+
visible={modalVisible}
|
|
114
|
+
onRequestClose={onClose}
|
|
115
|
+
>
|
|
116
|
+
<SafeAreaView style={style('modalSafe')}>
|
|
117
|
+
<View style={style('modalHeader')}>
|
|
118
|
+
<TouchableOpacity onPress={onClose} style={style('modalCloseButton')}>
|
|
119
|
+
<Text style={style('modalCloseText')}>X</Text>
|
|
120
|
+
</TouchableOpacity>
|
|
121
|
+
<Text style={style('modalTitle')}>{label}</Text>
|
|
122
|
+
{!Utils.isEmpty(headerRight) && (
|
|
123
|
+
<UIChildren scope={scope} crud={scope.currentDialog}>
|
|
124
|
+
{headerRight}
|
|
125
|
+
</UIChildren>
|
|
126
|
+
)}
|
|
127
|
+
</View>
|
|
128
|
+
<ScrollView
|
|
129
|
+
contentContainerStyle={{ flexGrow: 1 }}
|
|
130
|
+
style={style('modalContent')}
|
|
131
|
+
>
|
|
132
|
+
<View style={{ flex: 1 }}>
|
|
133
|
+
<UIChildren scope={scope} crud={scope.currentDialog}>
|
|
134
|
+
{props.children}
|
|
135
|
+
</UIChildren>
|
|
136
|
+
</View>
|
|
137
|
+
</ScrollView>
|
|
138
|
+
</SafeAreaView>
|
|
139
|
+
</Modal>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const styles = StyleSheet.create({
|
|
144
|
+
modalSafe: {
|
|
145
|
+
flex: 1,
|
|
146
|
+
backgroundColor: 'primary',
|
|
147
|
+
width: '100%',
|
|
148
|
+
},
|
|
149
|
+
modalHeader: {
|
|
150
|
+
flexDirection: 'row',
|
|
151
|
+
alignItems: 'center',
|
|
152
|
+
padding: 15,
|
|
153
|
+
backgroundColor: 'primary',
|
|
154
|
+
},
|
|
155
|
+
modalCloseButton: {
|
|
156
|
+
padding: 10,
|
|
157
|
+
},
|
|
158
|
+
modalCloseText: {
|
|
159
|
+
fontSize: 18,
|
|
160
|
+
color: 'white',
|
|
161
|
+
},
|
|
162
|
+
modalTitle: {
|
|
163
|
+
fontSize: 18,
|
|
164
|
+
color: 'white',
|
|
165
|
+
fontWeight: 'bold',
|
|
166
|
+
marginLeft: 10,
|
|
167
|
+
},
|
|
168
|
+
modalContent: {
|
|
169
|
+
flex: 1,
|
|
170
|
+
backgroundColor: '#f5f5f5',
|
|
171
|
+
padding: 20,
|
|
172
|
+
},
|
|
173
|
+
});
|
|
@@ -1,97 +1,97 @@
|
|
|
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: 10,
|
|
20
|
-
alignItems: 'center',
|
|
21
|
-
height: 44,
|
|
22
|
-
width: 44,
|
|
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
|
-
},
|
|
42
|
-
buttonInner: {
|
|
43
|
-
flexDirection: 'row',
|
|
44
|
-
alignItems: 'center',
|
|
45
|
-
justifyContent: 'center',
|
|
46
|
-
},
|
|
47
|
-
buttonIcon: {
|
|
48
|
-
color: '#fff',
|
|
49
|
-
fontSize: 18,
|
|
50
|
-
},
|
|
51
|
-
button: btn,
|
|
52
|
-
addButton: {
|
|
53
|
-
...btn,
|
|
54
|
-
},
|
|
55
|
-
delButton: {
|
|
56
|
-
...btn,
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const change = (val: number) => {
|
|
61
|
-
scope.changeValue(value + val);
|
|
62
|
-
setIndex(++index);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const onClickAdd = () => {
|
|
66
|
-
change(1);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const onClickDel = () => {
|
|
70
|
-
change(-1);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const style = (part: string, extra?: any) => {
|
|
74
|
-
let s = { ...styles[part], ...extra };
|
|
75
|
-
return scope.getStyle(part, s);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<>
|
|
80
|
-
<TouchableHighlight
|
|
81
|
-
underlayColor={'transparent'}
|
|
82
|
-
onPress={onClickDel}
|
|
83
|
-
style={style('delButton')}
|
|
84
|
-
>
|
|
85
|
-
<Ionicons size={30} style={style('buttonIcon')} name="remove" />
|
|
86
|
-
</TouchableHighlight>
|
|
87
|
-
<Text style={style('value')}>{Utils.nvl(value, 0)}</Text>
|
|
88
|
-
<TouchableHighlight
|
|
89
|
-
underlayColor={'transparent'}
|
|
90
|
-
onPress={onClickAdd}
|
|
91
|
-
style={style('addButton')}
|
|
92
|
-
>
|
|
93
|
-
<Ionicons size={30} style={style('buttonIcon')} name="add" />
|
|
94
|
-
</TouchableHighlight>
|
|
95
|
-
</>
|
|
96
|
-
);
|
|
97
|
-
}
|
|
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: 10,
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
height: 44,
|
|
22
|
+
width: 44,
|
|
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
|
+
},
|
|
42
|
+
buttonInner: {
|
|
43
|
+
flexDirection: 'row',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
justifyContent: 'center',
|
|
46
|
+
},
|
|
47
|
+
buttonIcon: {
|
|
48
|
+
color: '#fff',
|
|
49
|
+
fontSize: 18,
|
|
50
|
+
},
|
|
51
|
+
button: btn,
|
|
52
|
+
addButton: {
|
|
53
|
+
...btn,
|
|
54
|
+
},
|
|
55
|
+
delButton: {
|
|
56
|
+
...btn,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const change = (val: number) => {
|
|
61
|
+
scope.changeValue(value + val);
|
|
62
|
+
setIndex(++index);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const onClickAdd = () => {
|
|
66
|
+
change(1);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const onClickDel = () => {
|
|
70
|
+
change(-1);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const style = (part: string, extra?: any) => {
|
|
74
|
+
let s = { ...styles[part], ...extra };
|
|
75
|
+
return scope.getStyle(part, s);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<>
|
|
80
|
+
<TouchableHighlight
|
|
81
|
+
underlayColor={'transparent'}
|
|
82
|
+
onPress={onClickDel}
|
|
83
|
+
style={style('delButton')}
|
|
84
|
+
>
|
|
85
|
+
<Ionicons size={30} style={style('buttonIcon')} name="remove" />
|
|
86
|
+
</TouchableHighlight>
|
|
87
|
+
<Text style={style('value')}>{Utils.nvl(value, 0)}</Text>
|
|
88
|
+
<TouchableHighlight
|
|
89
|
+
underlayColor={'transparent'}
|
|
90
|
+
onPress={onClickAdd}
|
|
91
|
+
style={style('addButton')}
|
|
92
|
+
>
|
|
93
|
+
<Ionicons size={30} style={style('buttonIcon')} name="add" />
|
|
94
|
+
</TouchableHighlight>
|
|
95
|
+
</>
|
|
96
|
+
);
|
|
97
|
+
}
|