react-crud-mobile 1.3.358 → 1.3.360

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 (32) hide show
  1. package/dist/react-crud-mobile.cjs.development.js +3 -9
  2. package/dist/react-crud-mobile.cjs.development.js.map +1 -1
  3. package/dist/react-crud-mobile.cjs.production.min.js +1 -1
  4. package/dist/react-crud-mobile.cjs.production.min.js.map +1 -1
  5. package/dist/react-crud-mobile.esm.js +3 -9
  6. package/dist/react-crud-mobile.esm.js.map +1 -1
  7. package/package.json +76 -76
  8. package/src/elements/UI.tsx +77 -77
  9. package/src/elements/UIChildren.tsx +142 -142
  10. package/src/elements/UIComplete.tsx +14 -14
  11. package/src/elements/UIElement.tsx +872 -878
  12. package/src/elements/UITag.tsx +13 -13
  13. package/src/elements/charts/ElChart.tsx +10 -10
  14. package/src/elements/core/GestureView.tsx +16 -16
  15. package/src/elements/core/SafeView.tsx +63 -63
  16. package/src/elements/core/UIButton.tsx +144 -144
  17. package/src/elements/core/UIHeader.tsx +38 -38
  18. package/src/elements/core/UIIcon.tsx +32 -32
  19. package/src/elements/core/UIInclude.tsx +40 -40
  20. package/src/elements/core/UIInput.tsx +149 -149
  21. package/src/elements/core/UIList.tsx +180 -180
  22. package/src/elements/core/UIListRow.tsx +132 -132
  23. package/src/elements/core/UIModal.tsx +212 -212
  24. package/src/elements/core/UIOrder.tsx +194 -194
  25. package/src/elements/core/UIQuantity.tsx +98 -98
  26. package/src/elements/core/UISelect.tsx +194 -194
  27. package/src/elements/core/UIToast.tsx +44 -44
  28. package/src/elements/core/UIToggle.tsx +114 -114
  29. package/src/elements/core/UIView.tsx +69 -69
  30. package/src/elements/index.ts +1 -1
  31. package/src/elements/tabs/ElTabs.tsx +178 -178
  32. package/src/index.ts +1 -1
@@ -1,194 +1,194 @@
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
- import UIChildren from '../UIChildren';
12
-
13
- export default function UIOrder(props: ChildType) {
14
- const scope = props.scope;
15
- const crud = scope.crud;
16
- const original = scope.original;
17
- const cols = Utils.nvl(scope.getPart('cols', undefined, 1));
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 items = Utils.call(() => {
34
- let list = Utils.nvl(scope.getItems(), []);
35
-
36
- if (original.search && !original.list?.url) {
37
- let query = crud
38
- .get('query', '')
39
- .toLowerCase()
40
- .trim() as string;
41
-
42
- if (query.length > 1) {
43
- let filters: any[] = [];
44
- let filterBy = Utils.nvl(original.filterBy, 'label');
45
-
46
- Utils.each(list, o => {
47
- let label = o[filterBy];
48
-
49
- if (label) {
50
- if (label.includes(query)) {
51
- filters.push(o);
52
- }
53
- }
54
- });
55
-
56
- return filters;
57
- }
58
- }
59
- return list;
60
- });
61
-
62
- //v2
63
-
64
- const renderItem = ({ item, drag, isActive, getIndex }) => {
65
- const index = getIndex();
66
- const name = `${scope.key('row', index, '')}`;
67
- const [row] = useState(
68
- ScopeUtils.create({
69
- ...original,
70
- parent: scope,
71
- name,
72
- crud: scope.crud,
73
- index,
74
- type: 'row',
75
- data: item,
76
- })
77
- );
78
-
79
- let css = { ...scope.getStyle('row') };
80
-
81
- if (isActive) {
82
- css = { ...css, ...scope.getStyle('active') };
83
- }
84
-
85
- if (isActive) {
86
- css = { ...css, ...row.getStyle('rowSelected', {}) };
87
- } else {
88
- css = { ...css, ...row.getStyle('rowUnSelected', {}) };
89
- }
90
- const Child = () => {
91
- if (Utils.isEmpty(props.children)) {
92
- return (
93
- <>
94
- <MaterialCommunityIcons name="drag" size={24} color="black" />
95
- <Text style={styles.text}>{scope.getItemLabel(item)}</Text>
96
- </>
97
- );
98
- }
99
-
100
- return (
101
- <>
102
- <UIChildren transient scope={row} crud={row.crud}>
103
- {props.children}
104
- </UIChildren>
105
- </>
106
- );
107
- };
108
- return (
109
- <ScaleDecorator>
110
- <TouchableOpacity
111
- style={[
112
- styles.row,
113
- { backgroundColor: isActive ? 'lightblue' : 'white' },
114
- { ...css },
115
- ]}
116
- delayLongPress={100}
117
- onLongPress={drag} // Initiate drag on long press
118
- >
119
- <Child />
120
- </TouchableOpacity>
121
- </ScaleDecorator>
122
- );
123
- };
124
-
125
- const OrderView = ({ children }) => {
126
- if (original.gesture !== false) {
127
- return (
128
- <GestureHandlerRootView
129
- style={{
130
- flex: 1,
131
- width: '100%',
132
- ...scope.getStyle('order', { justifyContent: 'flex-start' }),
133
- }}
134
- >
135
- {children}
136
- </GestureHandlerRootView>
137
- );
138
- }
139
- return <>{children}</>;
140
- };
141
-
142
- const Header = ({ pos }) => {
143
- const hPos = Utils.nvl(original.headerPos, 'outer');
144
-
145
- if (hPos !== pos) return <></>;
146
-
147
- return <UIHeader scope={scope} />;
148
- };
149
-
150
- let OrderData = () => {
151
- const [data, setData] = useState(items);
152
-
153
- return (
154
- <DraggableFlatList
155
- data={data}
156
- ListHeaderComponent={<Header pos="inner" />}
157
- ListFooterComponent={<>{scope.getPart('footer')}</>}
158
- renderItem={renderItem}
159
- containerStyle={{ ...scope.getStyle('list') }}
160
- keyExtractor={item => {
161
- let key = scope.getItemValue(item);
162
-
163
- if (original?.debug) {
164
- console.log(key);
165
- }
166
- return key;
167
- }}
168
- onDragEnd={({ data }) => {
169
- setData(data);
170
- scope.changeValue(data);
171
- }}
172
- />
173
- );
174
- };
175
- return (
176
- <OrderView>
177
- <Header pos="outer" />
178
- <OrderData />
179
- </OrderView>
180
- );
181
- }
182
-
183
- const styles = StyleSheet.create({
184
- row: {
185
- flexDirection: 'row',
186
- gap: 10,
187
- padding: 15,
188
- borderBottomWidth: 1,
189
- borderBottomColor: '#ccc',
190
- },
191
- text: {
192
- fontSize: 18,
193
- },
194
- });
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
+ import UIChildren from '../UIChildren';
12
+
13
+ export default function UIOrder(props: ChildType) {
14
+ const scope = props.scope;
15
+ const crud = scope.crud;
16
+ const original = scope.original;
17
+ const cols = Utils.nvl(scope.getPart('cols', undefined, 1));
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 items = Utils.call(() => {
34
+ let list = Utils.nvl(scope.getItems(), []);
35
+
36
+ if (original.search && !original.list?.url) {
37
+ let query = crud
38
+ .get('query', '')
39
+ .toLowerCase()
40
+ .trim() as string;
41
+
42
+ if (query.length > 1) {
43
+ let filters: any[] = [];
44
+ let filterBy = Utils.nvl(original.filterBy, 'label');
45
+
46
+ Utils.each(list, o => {
47
+ let label = o[filterBy];
48
+
49
+ if (label) {
50
+ if (label.includes(query)) {
51
+ filters.push(o);
52
+ }
53
+ }
54
+ });
55
+
56
+ return filters;
57
+ }
58
+ }
59
+ return list;
60
+ });
61
+
62
+ //v2
63
+
64
+ const renderItem = ({ item, drag, isActive, getIndex }) => {
65
+ const index = getIndex();
66
+ const name = `${scope.key('row', index, '')}`;
67
+ const [row] = useState(
68
+ ScopeUtils.create({
69
+ ...original,
70
+ parent: scope,
71
+ name,
72
+ crud: scope.crud,
73
+ index,
74
+ type: 'row',
75
+ data: item,
76
+ })
77
+ );
78
+
79
+ let css = { ...scope.getStyle('row') };
80
+
81
+ if (isActive) {
82
+ css = { ...css, ...scope.getStyle('active') };
83
+ }
84
+
85
+ if (isActive) {
86
+ css = { ...css, ...row.getStyle('rowSelected', {}) };
87
+ } else {
88
+ css = { ...css, ...row.getStyle('rowUnSelected', {}) };
89
+ }
90
+ const Child = () => {
91
+ if (Utils.isEmpty(props.children)) {
92
+ return (
93
+ <>
94
+ <MaterialCommunityIcons name="drag" size={24} color="black" />
95
+ <Text style={styles.text}>{scope.getItemLabel(item)}</Text>
96
+ </>
97
+ );
98
+ }
99
+
100
+ return (
101
+ <>
102
+ <UIChildren transient scope={row} crud={row.crud}>
103
+ {props.children}
104
+ </UIChildren>
105
+ </>
106
+ );
107
+ };
108
+ return (
109
+ <ScaleDecorator>
110
+ <TouchableOpacity
111
+ style={[
112
+ styles.row,
113
+ { backgroundColor: isActive ? 'lightblue' : 'white' },
114
+ { ...css },
115
+ ]}
116
+ delayLongPress={100}
117
+ onLongPress={drag} // Initiate drag on long press
118
+ >
119
+ <Child />
120
+ </TouchableOpacity>
121
+ </ScaleDecorator>
122
+ );
123
+ };
124
+
125
+ const OrderView = ({ children }) => {
126
+ if (original.gesture !== false) {
127
+ return (
128
+ <GestureHandlerRootView
129
+ style={{
130
+ flex: 1,
131
+ width: '100%',
132
+ ...scope.getStyle('order', { justifyContent: 'flex-start' }),
133
+ }}
134
+ >
135
+ {children}
136
+ </GestureHandlerRootView>
137
+ );
138
+ }
139
+ return <>{children}</>;
140
+ };
141
+
142
+ const Header = ({ pos }) => {
143
+ const hPos = Utils.nvl(original.headerPos, 'outer');
144
+
145
+ if (hPos !== pos) return <></>;
146
+
147
+ return <UIHeader scope={scope} />;
148
+ };
149
+
150
+ let OrderData = () => {
151
+ const [data, setData] = useState(items);
152
+
153
+ return (
154
+ <DraggableFlatList
155
+ data={data}
156
+ ListHeaderComponent={<Header pos="inner" />}
157
+ ListFooterComponent={<>{scope.getPart('footer')}</>}
158
+ renderItem={renderItem}
159
+ containerStyle={{ ...scope.getStyle('list') }}
160
+ keyExtractor={item => {
161
+ let key = scope.getItemValue(item);
162
+
163
+ if (original?.debug) {
164
+ console.log(key);
165
+ }
166
+ return key;
167
+ }}
168
+ onDragEnd={({ data }) => {
169
+ setData(data);
170
+ scope.changeValue(data);
171
+ }}
172
+ />
173
+ );
174
+ };
175
+ return (
176
+ <OrderView>
177
+ <Header pos="outer" />
178
+ <OrderData />
179
+ </OrderView>
180
+ );
181
+ }
182
+
183
+ const styles = StyleSheet.create({
184
+ row: {
185
+ flexDirection: 'row',
186
+ gap: 10,
187
+ padding: 15,
188
+ borderBottomWidth: 1,
189
+ borderBottomColor: '#ccc',
190
+ },
191
+ text: {
192
+ fontSize: 18,
193
+ },
194
+ });
@@ -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
+ }