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.
Files changed (33) hide show
  1. package/dist/elements/core/UIStatusBar.d.ts +2 -0
  2. package/dist/react-crud-mobile.cjs.development.js +10 -4
  3. package/dist/react-crud-mobile.cjs.development.js.map +1 -1
  4. package/dist/react-crud-mobile.cjs.production.min.js +1 -1
  5. package/dist/react-crud-mobile.cjs.production.min.js.map +1 -1
  6. package/dist/react-crud-mobile.esm.js +11 -5
  7. package/dist/react-crud-mobile.esm.js.map +1 -1
  8. package/package.json +77 -76
  9. package/src/elements/UI.tsx +74 -74
  10. package/src/elements/UIChildren.tsx +139 -139
  11. package/src/elements/UIComplete.tsx +14 -14
  12. package/src/elements/UIElement.tsx +788 -788
  13. package/src/elements/UITag.tsx +13 -13
  14. package/src/elements/charts/ElChart.tsx +10 -10
  15. package/src/elements/core/SafeView.tsx +62 -63
  16. package/src/elements/core/UIButton.tsx +139 -139
  17. package/src/elements/core/UIHeader.tsx +38 -38
  18. package/src/elements/core/UIIcon.tsx +25 -25
  19. package/src/elements/core/UIInclude.tsx +40 -40
  20. package/src/elements/core/UIInput.tsx +96 -96
  21. package/src/elements/core/UIList.tsx +168 -168
  22. package/src/elements/core/UIListRow.tsx +123 -123
  23. package/src/elements/core/UIModal.tsx +176 -174
  24. package/src/elements/core/UIOrder.tsx +123 -123
  25. package/src/elements/core/UIQuantity.tsx +98 -98
  26. package/src/elements/core/UISelect.tsx +171 -171
  27. package/src/elements/core/UIStatusBar.tsx +5 -0
  28. package/src/elements/core/UIToast.tsx +44 -44
  29. package/src/elements/core/UIToggle.tsx +102 -102
  30. package/src/elements/core/UIView.tsx +69 -69
  31. package/src/elements/index.ts +1 -1
  32. package/src/elements/tabs/ElTabs.tsx +178 -178
  33. package/src/index.ts +1 -1
@@ -1,123 +1,123 @@
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
- const targetRef = useRef(null);
34
- const isVisible = useIsVisible(targetRef, row);
35
-
36
- const onClick = (item: any) => {
37
- row.call('click', { value: item, item, edit: true, index });
38
- };
39
-
40
- const Child = () => {
41
- if (!isVisible && original.useIsInView && !row.visible && index > 20) {
42
- return <></>;
43
- }
44
- return (
45
- <>
46
- <UIChildren scope={row} crud={row.crud}>
47
- {props.children}
48
- </UIChildren>
49
- </>
50
- );
51
- };
52
-
53
- const ListItem = () => {
54
- let [updateIndex, setUpdateIndex] = useState(0);
55
- let key = scope.key('item');
56
-
57
- const getRowStyle = () => {
58
- let css = row.getStyle('row', { ...styles.row, minHeight: 40 });
59
-
60
- if (cols > 0) {
61
- css.width = rowWidth;
62
- }
63
-
64
- return css;
65
- };
66
-
67
- row.update = () => {
68
- scope.updateIndex = scope.updateIndex + 1;
69
-
70
- setUpdateIndex(++updateIndex);
71
- };
72
-
73
- let renderedRow = row.getPart('renderedItem', undefined, true);
74
-
75
- if (renderedRow === false) {
76
- return <></>;
77
- }
78
-
79
- if (!original.click) {
80
- return (
81
- <View key={key} style={getRowStyle()} ref={targetRef}>
82
- <Child />
83
- </View>
84
- );
85
- }
86
- return (
87
- <TouchableHighlight
88
- key={key}
89
- style={getRowStyle()}
90
- underlayColor={'transparent'}
91
- ref={targetRef}
92
- onPress={e => {
93
- e.stopPropagation();
94
- onClick(item);
95
- }}
96
- >
97
- <Child />
98
- </TouchableHighlight>
99
- );
100
- };
101
-
102
- return <ListItem />;
103
- }
104
-
105
- const stylesList = StyleSheet.create({
106
- row: {
107
- padding: 5,
108
- margin: 0,
109
- width: '100%',
110
- backgroundColor: 'background',
111
- gap: 10,
112
- borderRadius: 8,
113
- justifyContent: 'center',
114
- },
115
- });
116
-
117
- const stylesRepeat = StyleSheet.create({
118
- row: {
119
- padding: 0,
120
- width: '100%',
121
- justifyContent: 'center',
122
- },
123
- });
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
+ const targetRef = useRef(null);
34
+ const isVisible = useIsVisible(targetRef, row);
35
+
36
+ const onClick = (item: any) => {
37
+ row.call('click', { value: item, item, edit: true, index });
38
+ };
39
+
40
+ const Child = () => {
41
+ if (!isVisible && original.useIsInView && !row.visible && index > 20) {
42
+ return <></>;
43
+ }
44
+ return (
45
+ <>
46
+ <UIChildren scope={row} crud={row.crud}>
47
+ {props.children}
48
+ </UIChildren>
49
+ </>
50
+ );
51
+ };
52
+
53
+ const ListItem = () => {
54
+ let [updateIndex, setUpdateIndex] = useState(0);
55
+ let key = scope.key('item');
56
+
57
+ const getRowStyle = () => {
58
+ let css = row.getStyle('row', { ...styles.row, minHeight: 40 });
59
+
60
+ if (cols > 0) {
61
+ css.width = rowWidth;
62
+ }
63
+
64
+ return css;
65
+ };
66
+
67
+ row.update = () => {
68
+ scope.updateIndex = scope.updateIndex + 1;
69
+
70
+ setUpdateIndex(++updateIndex);
71
+ };
72
+
73
+ let renderedRow = row.getPart('renderedItem', undefined, true);
74
+
75
+ if (renderedRow === false) {
76
+ return <></>;
77
+ }
78
+
79
+ if (!original.click) {
80
+ return (
81
+ <View key={key} style={getRowStyle()} ref={targetRef}>
82
+ <Child />
83
+ </View>
84
+ );
85
+ }
86
+ return (
87
+ <TouchableHighlight
88
+ key={key}
89
+ style={getRowStyle()}
90
+ underlayColor={'transparent'}
91
+ ref={targetRef}
92
+ onPress={e => {
93
+ e.stopPropagation();
94
+ onClick(item);
95
+ }}
96
+ >
97
+ <Child />
98
+ </TouchableHighlight>
99
+ );
100
+ };
101
+
102
+ return <ListItem />;
103
+ }
104
+
105
+ const stylesList = StyleSheet.create({
106
+ row: {
107
+ padding: 5,
108
+ margin: 0,
109
+ width: '100%',
110
+ backgroundColor: 'background',
111
+ gap: 10,
112
+ borderRadius: 8,
113
+ justifyContent: 'center',
114
+ },
115
+ });
116
+
117
+ const stylesRepeat = StyleSheet.create({
118
+ row: {
119
+ padding: 0,
120
+ width: '100%',
121
+ justifyContent: 'center',
122
+ },
123
+ });
@@ -1,174 +1,176 @@
1
- import { useRef, useState } from 'react';
2
- import {
3
- ChildType,
4
- ComponentUtils,
5
- CrudUtils,
6
- MethodType,
7
- Utils,
8
- ViewUtils,
9
- } from 'react-crud-utils';
10
- import {
11
- Text,
12
- TouchableOpacity,
13
- StyleSheet,
14
- Modal,
15
- View,
16
- SafeAreaView,
17
- ScrollView,
18
- } from 'react-native';
19
- import UIChildren from '../UIChildren';
20
- import Ionicons from '@expo/vector-icons/Ionicons';
21
- import UIToast from './UIToast';
22
-
23
- interface UIModalType extends ChildType {
24
- open?: boolean;
25
- dialog?: any;
26
- }
27
-
28
- export default function UIModal({
29
- scope,
30
- open,
31
- dialog,
32
- ...props
33
- }: UIModalType) {
34
- let [modalVisible, setModalVisible] = useState(open === true);
35
- let [index, setIndex] = useState(0);
36
- //v6
37
-
38
- const label = scope.getLabel();
39
- const theme = scope.getTheme();
40
- const headerStyle = Utils.nvl(theme.styles?.defaults?.header, {});
41
- const scrollRef = useRef(null);
42
-
43
- const style = (part: string, extra?: any) => {
44
- let st = { ...styles[part], ...extra };
45
-
46
- return { ...scope.getStyle(part, st) };
47
- };
48
-
49
- const onClose = () => {
50
- scope.close({ scope, crud: scope.currentDialog?.crud, event: {} });
51
- };
52
-
53
- scope.toggleDialog = vis => {
54
- modalVisible = vis;
55
- setModalVisible(modalVisible);
56
- };
57
-
58
- scope.update = () => {
59
- setIndex(++index);
60
- };
61
-
62
- let curr = scope.currentDialog?.crud;
63
- let main = ViewUtils.getCrud('view');
64
-
65
- if (!curr) {
66
- return <></>;
67
- }
68
-
69
- if (curr.uuid !== main.dialog?.crud?.uuid) {
70
- return <></>;
71
- }
72
-
73
- const headerRight = ComponentUtils.getDefine(props, 'header', 'right');
74
- const bottom = ComponentUtils.getDefine(props, 'bottom');
75
-
76
- scope.put('scrollRef', scrollRef);
77
-
78
- ComponentUtils.setViewScope(scope);
79
-
80
- let color = Utils.nvl(headerStyle.color, 'white');
81
- let defaults = { color };
82
- let key = `${curr.name}-${index}`;
83
-
84
- let Content = () => {
85
- if (dialog?.component) {
86
- let Aux = dialog?.component;
87
-
88
- return <Aux crud={curr} />;
89
- }
90
- return (
91
- <UIChildren scope={scope} crud={curr}>
92
- {props.children}
93
- </UIChildren>
94
- );
95
- };
96
-
97
- return (
98
- <Modal
99
- key={key}
100
- animationType="slide"
101
- transparent={true}
102
- visible={modalVisible}
103
- onRequestClose={onClose}
104
- >
105
- <SafeAreaView style={style('modalTop')} />
106
- <SafeAreaView style={style('modalSafe')}>
107
- <View style={scope.getStyle('header', headerStyle)}>
108
- <TouchableOpacity onPress={onClose} style={style('modalCloseButton')}>
109
- <Ionicons
110
- name="chevron-back-outline"
111
- size={24}
112
- color={color}
113
- style={style('modalCloseText', defaults)}
114
- />
115
- </TouchableOpacity>
116
- <Text style={style('modalTitle', defaults)}>{label}</Text>
117
- {!Utils.isEmpty(headerRight) && (
118
- <UIChildren scope={scope} crud={curr} transient>
119
- {headerRight}
120
- </UIChildren>
121
- )}
122
- </View>
123
- <ScrollView
124
- contentContainerStyle={{ flexGrow: 1, paddingBottom: 50 }}
125
- style={style('modalContent')}
126
- nestedScrollEnabled={true}
127
- ref={scrollRef}
128
- >
129
- <View
130
- style={{
131
- flex: 1,
132
- paddingLeft: 15,
133
- paddingRight: 15,
134
- paddingTop: 10,
135
- paddingBottom: 10,
136
- }}
137
- >
138
- <Content />
139
- </View>
140
- </ScrollView>
141
- {bottom}
142
- </SafeAreaView>
143
- <UIToast />
144
- </Modal>
145
- );
146
- }
147
-
148
- const styles = StyleSheet.create({
149
- modalTop: {
150
- backgroundColor: 'primary',
151
- width: '100%',
152
- },
153
- modalSafe: {
154
- flex: 1,
155
- width: '100%',
156
- backgroundColor: 'background',
157
- },
158
- modalCloseButton: {
159
- padding: 10,
160
- },
161
- modalCloseText: {
162
- fontSize: 18,
163
- color: 'white',
164
- },
165
- modalTitle: {
166
- fontSize: 18,
167
- fontWeight: 'bold',
168
- marginLeft: 10,
169
- },
170
- modalContent: {
171
- flex: 1,
172
- backgroundColor: 'background',
173
- },
174
- });
1
+ import { useRef, useState } from 'react';
2
+ import {
3
+ ChildType,
4
+ ComponentUtils,
5
+ CrudUtils,
6
+ MethodType,
7
+ Utils,
8
+ ViewUtils,
9
+ } from 'react-crud-utils';
10
+ import {
11
+ Text,
12
+ TouchableOpacity,
13
+ StyleSheet,
14
+ Modal,
15
+ View,
16
+ SafeAreaView,
17
+ ScrollView,
18
+ } from 'react-native';
19
+ import UIChildren from '../UIChildren';
20
+ import Ionicons from '@expo/vector-icons/Ionicons';
21
+ import UIToast from './UIToast';
22
+ import UIStatusBar from './UIStatusBar';
23
+
24
+ interface UIModalType extends ChildType {
25
+ open?: boolean;
26
+ dialog?: any;
27
+ }
28
+
29
+ export default function UIModal({
30
+ scope,
31
+ open,
32
+ dialog,
33
+ ...props
34
+ }: UIModalType) {
35
+ let [modalVisible, setModalVisible] = useState(open === true);
36
+ let [index, setIndex] = useState(0);
37
+ //v6
38
+
39
+ const label = scope.getLabel();
40
+ const theme = scope.getTheme();
41
+ const headerStyle = Utils.nvl(theme.styles?.defaults?.header, {});
42
+ const scrollRef = useRef(null);
43
+
44
+ const style = (part: string, extra?: any) => {
45
+ let st = { ...styles[part], ...extra };
46
+
47
+ return { ...scope.getStyle(part, st) };
48
+ };
49
+
50
+ const onClose = () => {
51
+ scope.close({ scope, crud: scope.currentDialog?.crud, event: {} });
52
+ };
53
+
54
+ scope.toggleDialog = vis => {
55
+ modalVisible = vis;
56
+ setModalVisible(modalVisible);
57
+ };
58
+
59
+ scope.update = () => {
60
+ setIndex(++index);
61
+ };
62
+
63
+ let curr = scope.currentDialog?.crud;
64
+ let main = ViewUtils.getCrud('view');
65
+
66
+ if (!curr) {
67
+ return <></>;
68
+ }
69
+
70
+ if (curr.uuid !== main.dialog?.crud?.uuid) {
71
+ return <></>;
72
+ }
73
+
74
+ const headerRight = ComponentUtils.getDefine(props, 'header', 'right');
75
+ const bottom = ComponentUtils.getDefine(props, 'bottom');
76
+
77
+ scope.put('scrollRef', scrollRef);
78
+
79
+ ComponentUtils.setViewScope(scope);
80
+
81
+ let color = Utils.nvl(headerStyle.color, 'white');
82
+ let defaults = { color };
83
+ let key = `${curr.name}-${index}`;
84
+
85
+ let Content = () => {
86
+ if (dialog?.component) {
87
+ let Aux = dialog?.component;
88
+
89
+ return <Aux crud={curr} />;
90
+ }
91
+ return (
92
+ <UIChildren scope={scope} crud={curr}>
93
+ {props.children}
94
+ </UIChildren>
95
+ );
96
+ };
97
+
98
+ return (
99
+ <Modal
100
+ key={key}
101
+ animationType="slide"
102
+ transparent={true}
103
+ visible={modalVisible}
104
+ onRequestClose={onClose}
105
+ >
106
+ <UIStatusBar />
107
+ <SafeAreaView style={style('modalTop')} />
108
+ <SafeAreaView style={style('modalSafe')}>
109
+ <View style={scope.getStyle('header', headerStyle)}>
110
+ <TouchableOpacity onPress={onClose} style={style('modalCloseButton')}>
111
+ <Ionicons
112
+ name="chevron-back-outline"
113
+ size={24}
114
+ color={color}
115
+ style={style('modalCloseText', defaults)}
116
+ />
117
+ </TouchableOpacity>
118
+ <Text style={style('modalTitle', defaults)}>{label}</Text>
119
+ {!Utils.isEmpty(headerRight) && (
120
+ <UIChildren scope={scope} crud={curr} transient>
121
+ {headerRight}
122
+ </UIChildren>
123
+ )}
124
+ </View>
125
+ <ScrollView
126
+ contentContainerStyle={{ flexGrow: 1, paddingBottom: 50 }}
127
+ style={style('modalContent')}
128
+ nestedScrollEnabled={true}
129
+ ref={scrollRef}
130
+ >
131
+ <View
132
+ style={{
133
+ flex: 1,
134
+ paddingLeft: 15,
135
+ paddingRight: 15,
136
+ paddingTop: 10,
137
+ paddingBottom: 10,
138
+ }}
139
+ >
140
+ <Content />
141
+ </View>
142
+ </ScrollView>
143
+ {bottom}
144
+ </SafeAreaView>
145
+ <UIToast />
146
+ </Modal>
147
+ );
148
+ }
149
+
150
+ const styles = StyleSheet.create({
151
+ modalTop: {
152
+ backgroundColor: 'primary',
153
+ width: '100%',
154
+ },
155
+ modalSafe: {
156
+ flex: 1,
157
+ width: '100%',
158
+ backgroundColor: 'background',
159
+ },
160
+ modalCloseButton: {
161
+ padding: 10,
162
+ },
163
+ modalCloseText: {
164
+ fontSize: 18,
165
+ color: 'white',
166
+ },
167
+ modalTitle: {
168
+ fontSize: 18,
169
+ fontWeight: 'bold',
170
+ marginLeft: 10,
171
+ },
172
+ modalContent: {
173
+ flex: 1,
174
+ backgroundColor: 'background',
175
+ },
176
+ });