react-crud-mobile 1.0.433 → 1.0.435

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 (34) hide show
  1. package/dist/elements/core/UIView.d.ts +3 -0
  2. package/dist/react-crud-mobile.cjs.development.js +59 -7
  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 +60 -8
  7. package/dist/react-crud-mobile.esm.js.map +1 -1
  8. package/package.json +72 -71
  9. package/src/elements/UI.tsx +65 -65
  10. package/src/elements/UIChildren.tsx +127 -127
  11. package/src/elements/UIComplete.tsx +14 -14
  12. package/src/elements/UIElement.tsx +523 -518
  13. package/src/elements/UITag.tsx +13 -13
  14. package/src/elements/charts/ElChart.tsx +10 -10
  15. package/src/elements/core/UIAutoComplete.tsx +17 -17
  16. package/src/elements/core/UIButton.tsx +73 -73
  17. package/src/elements/core/UIIcon.tsx +8 -8
  18. package/src/elements/core/UIInclude.tsx +40 -40
  19. package/src/elements/core/UIInput.tsx +69 -69
  20. package/src/elements/core/UILink.tsx +17 -17
  21. package/src/elements/core/UIList.tsx +135 -135
  22. package/src/elements/core/UIListItem.tsx +32 -32
  23. package/src/elements/core/UIListRow.tsx +32 -32
  24. package/src/elements/core/UIModal.tsx +139 -139
  25. package/src/elements/core/UIOption.tsx +17 -17
  26. package/src/elements/core/UIQuantity.tsx +97 -97
  27. package/src/elements/core/UIRadio.tsx +17 -17
  28. package/src/elements/core/UISelect.tsx +122 -122
  29. package/src/elements/core/UISwitch.tsx +26 -26
  30. package/src/elements/core/UIToggle.tsx +102 -102
  31. package/src/elements/core/UIView.tsx +62 -0
  32. package/src/elements/index.ts +1 -1
  33. package/src/elements/tabs/ElTabs.tsx +178 -178
  34. package/src/index.ts +1 -1
@@ -1,102 +1,102 @@
1
- import React, { useState } from 'react';
2
- import { ChildType, Utils } from 'react-crud-utils';
3
- import { StyleSheet, Text, TouchableHighlight, View } from 'react-native';
4
- import UIListRow from './UIListRow';
5
-
6
- export default function UIToggle(props: ChildType) {
7
- const scope = props.scope;
8
- const options = Utils.nvl(scope.getOptions(), []);
9
- const value = scope.getInputValue();
10
-
11
- let [index, setIndex] = useState(0);
12
-
13
- const isSelected = (item: any) => {
14
- return item?.value === value;
15
- };
16
-
17
- const onClick = (item: any) => {
18
- scope.changeValue(item.object);
19
- setIndex(++index);
20
- };
21
-
22
- const Item = ({ item, index }) => {
23
- let selected = isSelected(item);
24
- let style: any = { ...styles.text };
25
-
26
- if (selected) style.color = '#ffffff';
27
-
28
- if (Utils.isEmpty(props.children)) {
29
- return <Text style={style}>{item.label}</Text>;
30
- }
31
-
32
- return (
33
- <UIListRow scope={scope} item={item.object} index={index}>
34
- {props.children}
35
- </UIListRow>
36
- );
37
- };
38
-
39
- const getItemStyle = (item: any) => {
40
- let style = { ...styles.item, ...scope.getStyle('item') };
41
-
42
- let wPart = 100 / options.length;
43
- let width = Math.floor(wPart) + '%';
44
-
45
- if (isSelected(item)) {
46
- let selectedColor = scope.getPart('selectedColor', undefined, 'primary');
47
- let st = scope.getStyle('selected', {
48
- backgroundColor: selectedColor,
49
- color: '#ffffff',
50
- });
51
-
52
- style = { ...style, ...st };
53
-
54
- if (!style.color) {
55
- style.color = '#ffffff';
56
- }
57
- }
58
-
59
- style.width = width;
60
-
61
- return style;
62
- };
63
-
64
- return (
65
- <>
66
- {options.map((item: any, i: number) => (
67
- <TouchableHighlight
68
- key={`k-${i}`}
69
- style={getItemStyle(item)}
70
- onPress={e => {
71
- onClick(item);
72
- }}
73
- >
74
- <Item item={item} index={i} />
75
- </TouchableHighlight>
76
- ))}
77
- </>
78
- );
79
- }
80
-
81
- const styles = StyleSheet.create({
82
- container: {
83
- flex: 1,
84
- width: '100%',
85
- gap: 10,
86
- justifyContent: 'center',
87
- flexDirection: 'row',
88
- },
89
- item: {
90
- padding: 15,
91
- marginVertical: 8,
92
- backgroundColor: '#f5f5f5',
93
- borderRadius: 8,
94
- justifyContent: 'center',
95
- width: 'auto',
96
- flexDirection: 'row',
97
- },
98
- text: {
99
- fontSize: 16,
100
- fontWeight: 500,
101
- },
102
- });
1
+ import React, { useState } from 'react';
2
+ import { ChildType, Utils } from 'react-crud-utils';
3
+ import { StyleSheet, Text, TouchableHighlight, View } from 'react-native';
4
+ import UIListRow from './UIListRow';
5
+
6
+ export default function UIToggle(props: ChildType) {
7
+ const scope = props.scope;
8
+ const options = Utils.nvl(scope.getOptions(), []);
9
+ const value = scope.getInputValue();
10
+
11
+ let [index, setIndex] = useState(0);
12
+
13
+ const isSelected = (item: any) => {
14
+ return item?.value === value;
15
+ };
16
+
17
+ const onClick = (item: any) => {
18
+ scope.changeValue(item.object);
19
+ setIndex(++index);
20
+ };
21
+
22
+ const Item = ({ item, index }) => {
23
+ let selected = isSelected(item);
24
+ let style: any = { ...styles.text };
25
+
26
+ if (selected) style.color = '#ffffff';
27
+
28
+ if (Utils.isEmpty(props.children)) {
29
+ return <Text style={style}>{item.label}</Text>;
30
+ }
31
+
32
+ return (
33
+ <UIListRow scope={scope} item={item.object} index={index}>
34
+ {props.children}
35
+ </UIListRow>
36
+ );
37
+ };
38
+
39
+ const getItemStyle = (item: any) => {
40
+ let style = { ...styles.item, ...scope.getStyle('item') };
41
+
42
+ let wPart = 100 / options.length;
43
+ let width = Math.floor(wPart) + '%';
44
+
45
+ if (isSelected(item)) {
46
+ let selectedColor = scope.getPart('selectedColor', undefined, 'primary');
47
+ let st = scope.getStyle('selected', {
48
+ backgroundColor: selectedColor,
49
+ color: '#ffffff',
50
+ });
51
+
52
+ style = { ...style, ...st };
53
+
54
+ if (!style.color) {
55
+ style.color = '#ffffff';
56
+ }
57
+ }
58
+
59
+ style.width = width;
60
+
61
+ return style;
62
+ };
63
+
64
+ return (
65
+ <>
66
+ {options.map((item: any, i: number) => (
67
+ <TouchableHighlight
68
+ key={`k-${i}`}
69
+ style={getItemStyle(item)}
70
+ onPress={e => {
71
+ onClick(item);
72
+ }}
73
+ >
74
+ <Item item={item} index={i} />
75
+ </TouchableHighlight>
76
+ ))}
77
+ </>
78
+ );
79
+ }
80
+
81
+ const styles = StyleSheet.create({
82
+ container: {
83
+ flex: 1,
84
+ width: '100%',
85
+ gap: 10,
86
+ justifyContent: 'center',
87
+ flexDirection: 'row',
88
+ },
89
+ item: {
90
+ padding: 15,
91
+ marginVertical: 8,
92
+ backgroundColor: '#f5f5f5',
93
+ borderRadius: 8,
94
+ justifyContent: 'center',
95
+ width: 'auto',
96
+ flexDirection: 'row',
97
+ },
98
+ text: {
99
+ fontSize: 16,
100
+ fontWeight: 500,
101
+ },
102
+ });
@@ -0,0 +1,62 @@
1
+ import { StatusBar } from 'expo-status-bar';
2
+ import {
3
+ Keyboard,
4
+ KeyboardAvoidingView,
5
+ Platform,
6
+ ScrollView,
7
+ StyleSheet,
8
+ TouchableWithoutFeedback,
9
+ View,
10
+ } from 'react-native';
11
+ import {
12
+ SafeAreaProvider,
13
+ SafeAreaView as SafeAreaContextView,
14
+ } from 'react-native-safe-area-context';
15
+
16
+ import UIChildren from '../UIChildren';
17
+ import { ChildType } from 'react-crud-utils';
18
+
19
+ export default function UIView({ scope, children }: ChildType) {
20
+ const header = scope.getPart('header', null, []);
21
+ const dismissKeyboard = () => {
22
+ if (Platform.OS !== 'web') {
23
+ Keyboard.dismiss();
24
+ }
25
+ };
26
+
27
+ return (
28
+ <SafeAreaProvider>
29
+ <StatusBar style="dark" />
30
+ <SafeAreaContextView style={scope.getStyle('view', styles.view)}>
31
+ <KeyboardAvoidingView
32
+ behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
33
+ style={{
34
+ flex: 1, // 🔹 Ocupa 100% da tela
35
+ justifyContent: 'center',
36
+ }}
37
+ >
38
+ {header}
39
+ <View style={scope.getStyle('container', styles.container)}>
40
+ <ScrollView keyboardShouldPersistTaps="handled">
41
+ <TouchableWithoutFeedback
42
+ onPress={dismissKeyboard}
43
+ accessible={false}
44
+ >
45
+ <UIChildren scope={scope}>{children}</UIChildren>
46
+ </TouchableWithoutFeedback>
47
+ </ScrollView>
48
+ </View>
49
+ </KeyboardAvoidingView>
50
+ </SafeAreaContextView>
51
+ </SafeAreaProvider>
52
+ );
53
+ }
54
+
55
+ const styles = StyleSheet.create({
56
+ container: {
57
+ backgroundColor: 'background',
58
+ },
59
+ view: {
60
+ backgroundColor: 'primary',
61
+ },
62
+ });
@@ -1 +1 @@
1
- export { default as UI } from "./UI";
1
+ export { default as UI } from "./UI";
@@ -1,178 +1,178 @@
1
- import React, { useState, useEffect } from 'react';
2
- import UIChildren from '../UIChildren';
3
- import UI from '../UI';
4
-
5
- import Ionicons from '@expo/vector-icons/Ionicons';
6
- import { ChildType, CrudUtils, Utils } from 'react-crud-utils';
7
-
8
- export default function ElTabs(props: ChildType) {
9
- let scope = props.scope;
10
- let [selectedIndex, setSelectedIndex]: any = useState(0);
11
- let element = scope.original;
12
- let items = scope.getItems();
13
- let counter = 0;
14
-
15
- let tabs: any = [];
16
- let [selected, setSelected]: any = useState(null);
17
-
18
- const onChangeTab = (tab: any, validate = true) => {
19
- if (tab) {
20
- scope.execute({
21
- event: {
22
- validate,
23
- validateScope: element.validateScope,
24
- action: () => {
25
- scope.changeValue(tab.data);
26
-
27
- selected = tab;
28
- selectedIndex = tab.index;
29
-
30
- setSelectedIndex(selectedIndex);
31
- setSelected(tab);
32
- },
33
- },
34
- });
35
- }
36
- };
37
-
38
- const getStyleClass = (t: any) => {
39
- let s = 'ui-tabs-item ui-click';
40
-
41
- if (selected?.index === t.index) {
42
- s = s + ' ui-tab-selected';
43
- }
44
- return s;
45
- };
46
-
47
- const addTab = (child: any, item: any) => {
48
- let original = { ...child.props };
49
-
50
- if (!item) {
51
- item = scope.crud.data;
52
- }
53
-
54
- let crudTab = CrudUtils.create('tabs', {
55
- data: item,
56
- changed: item,
57
- parent: scope.crud,
58
- });
59
-
60
- let element = Utils.resolve(original, crudTab);
61
-
62
- if (element.rendered === false) {
63
- return;
64
- }
65
-
66
- tabs.push({
67
- ...element,
68
- child,
69
- element,
70
- original,
71
- index: counter++,
72
- data: item,
73
- });
74
- };
75
-
76
- React.Children.map(props.children, (child, index) => {
77
- if (Utils.isEmpty(items)) {
78
- addTab(child, {});
79
- } else {
80
- for (const i in items) {
81
- let o = items[i];
82
-
83
- addTab(child, o);
84
- }
85
- }
86
- });
87
-
88
- if (!selected) {
89
- onChangeTab(tabs[selectedIndex], false);
90
- }
91
-
92
- const nav = (i: any) => {
93
- let t = tabs[selectedIndex + i];
94
-
95
- onChangeTab(t);
96
- };
97
-
98
- const previous = () => {
99
- nav(-1);
100
- };
101
-
102
- const next = () => {
103
- nav(1);
104
- };
105
-
106
- let isStepper = element.layout === 'stepper';
107
-
108
- return (
109
- <div
110
- className={scope.getStyleClass('inner')}
111
- style={scope.getStyle('inner')}
112
- >
113
- <div className="ui-tabs-content">
114
- <div className="ui-tabs-items">
115
- {tabs.map((t: any, i: number) => (
116
- <div
117
- key={Utils.key(element.id, 'tab', i)}
118
- className={getStyleClass(t)}
119
- onClick={() => {
120
- onChangeTab(t);
121
- }}
122
- >
123
- {isStepper && <div className="ui-tab-item-divisor" />}
124
- <div className="ui-tab-item-inner">
125
- {isStepper && <div className="ui-step-line" />}
126
- <div className="ui-tab-item-label">
127
- {isStepper ? t.index + 1 : t.label}
128
- </div>
129
- </div>
130
- </div>
131
- ))}
132
- </div>
133
- {selected && (
134
- <>
135
- {isStepper && <div className="ui-tabs-label">{selected.label}</div>}
136
- <div className="ui-tabs-area">
137
- <UIChildren {...props} scope={scope}>
138
- {selected.child}
139
- </UIChildren>
140
- </div>
141
- {element.layout === 'stepper' && (
142
- <div className="ui-tabs-actions">
143
- <UI.Output space={6} layout="left">
144
- <UI.Include
145
- {...props}
146
- transient
147
- name="left"
148
- default={
149
- <UI.Button
150
- rendered={selectedIndex > 0}
151
- icon={<Ionicons />}
152
- click={previous}
153
- />
154
- }
155
- />
156
- </UI.Output>
157
- <UI.Output space={6} layout="right">
158
- <UI.Include
159
- {...props}
160
- transient
161
- name="right"
162
- default={
163
- <UI.Button
164
- rendered={selectedIndex < tabs.length - 1}
165
- icon={<Ionicons />}
166
- click={next}
167
- />
168
- }
169
- />
170
- </UI.Output>
171
- </div>
172
- )}
173
- </>
174
- )}
175
- </div>
176
- </div>
177
- );
178
- }
1
+ import React, { useState, useEffect } from 'react';
2
+ import UIChildren from '../UIChildren';
3
+ import UI from '../UI';
4
+
5
+ import Ionicons from '@expo/vector-icons/Ionicons';
6
+ import { ChildType, CrudUtils, Utils } from 'react-crud-utils';
7
+
8
+ export default function ElTabs(props: ChildType) {
9
+ let scope = props.scope;
10
+ let [selectedIndex, setSelectedIndex]: any = useState(0);
11
+ let element = scope.original;
12
+ let items = scope.getItems();
13
+ let counter = 0;
14
+
15
+ let tabs: any = [];
16
+ let [selected, setSelected]: any = useState(null);
17
+
18
+ const onChangeTab = (tab: any, validate = true) => {
19
+ if (tab) {
20
+ scope.execute({
21
+ event: {
22
+ validate,
23
+ validateScope: element.validateScope,
24
+ action: () => {
25
+ scope.changeValue(tab.data);
26
+
27
+ selected = tab;
28
+ selectedIndex = tab.index;
29
+
30
+ setSelectedIndex(selectedIndex);
31
+ setSelected(tab);
32
+ },
33
+ },
34
+ });
35
+ }
36
+ };
37
+
38
+ const getStyleClass = (t: any) => {
39
+ let s = 'ui-tabs-item ui-click';
40
+
41
+ if (selected?.index === t.index) {
42
+ s = s + ' ui-tab-selected';
43
+ }
44
+ return s;
45
+ };
46
+
47
+ const addTab = (child: any, item: any) => {
48
+ let original = { ...child.props };
49
+
50
+ if (!item) {
51
+ item = scope.crud.data;
52
+ }
53
+
54
+ let crudTab = CrudUtils.create('tabs', {
55
+ data: item,
56
+ changed: item,
57
+ parent: scope.crud,
58
+ });
59
+
60
+ let element = Utils.resolve(original, crudTab);
61
+
62
+ if (element.rendered === false) {
63
+ return;
64
+ }
65
+
66
+ tabs.push({
67
+ ...element,
68
+ child,
69
+ element,
70
+ original,
71
+ index: counter++,
72
+ data: item,
73
+ });
74
+ };
75
+
76
+ React.Children.map(props.children, (child, index) => {
77
+ if (Utils.isEmpty(items)) {
78
+ addTab(child, {});
79
+ } else {
80
+ for (const i in items) {
81
+ let o = items[i];
82
+
83
+ addTab(child, o);
84
+ }
85
+ }
86
+ });
87
+
88
+ if (!selected) {
89
+ onChangeTab(tabs[selectedIndex], false);
90
+ }
91
+
92
+ const nav = (i: any) => {
93
+ let t = tabs[selectedIndex + i];
94
+
95
+ onChangeTab(t);
96
+ };
97
+
98
+ const previous = () => {
99
+ nav(-1);
100
+ };
101
+
102
+ const next = () => {
103
+ nav(1);
104
+ };
105
+
106
+ let isStepper = element.layout === 'stepper';
107
+
108
+ return (
109
+ <div
110
+ className={scope.getStyleClass('inner')}
111
+ style={scope.getStyle('inner')}
112
+ >
113
+ <div className="ui-tabs-content">
114
+ <div className="ui-tabs-items">
115
+ {tabs.map((t: any, i: number) => (
116
+ <div
117
+ key={Utils.key(element.id, 'tab', i)}
118
+ className={getStyleClass(t)}
119
+ onClick={() => {
120
+ onChangeTab(t);
121
+ }}
122
+ >
123
+ {isStepper && <div className="ui-tab-item-divisor" />}
124
+ <div className="ui-tab-item-inner">
125
+ {isStepper && <div className="ui-step-line" />}
126
+ <div className="ui-tab-item-label">
127
+ {isStepper ? t.index + 1 : t.label}
128
+ </div>
129
+ </div>
130
+ </div>
131
+ ))}
132
+ </div>
133
+ {selected && (
134
+ <>
135
+ {isStepper && <div className="ui-tabs-label">{selected.label}</div>}
136
+ <div className="ui-tabs-area">
137
+ <UIChildren {...props} scope={scope}>
138
+ {selected.child}
139
+ </UIChildren>
140
+ </div>
141
+ {element.layout === 'stepper' && (
142
+ <div className="ui-tabs-actions">
143
+ <UI.Output space={6} layout="left">
144
+ <UI.Include
145
+ {...props}
146
+ transient
147
+ name="left"
148
+ default={
149
+ <UI.Button
150
+ rendered={selectedIndex > 0}
151
+ icon={<Ionicons />}
152
+ click={previous}
153
+ />
154
+ }
155
+ />
156
+ </UI.Output>
157
+ <UI.Output space={6} layout="right">
158
+ <UI.Include
159
+ {...props}
160
+ transient
161
+ name="right"
162
+ default={
163
+ <UI.Button
164
+ rendered={selectedIndex < tabs.length - 1}
165
+ icon={<Ionicons />}
166
+ click={next}
167
+ />
168
+ }
169
+ />
170
+ </UI.Output>
171
+ </div>
172
+ )}
173
+ </>
174
+ )}
175
+ </div>
176
+ </div>
177
+ );
178
+ }
package/src/index.ts CHANGED
@@ -1 +1 @@
1
- export * from './elements';
1
+ export * from './elements';