react-crud-mobile 1.3.1 → 1.3.3

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 (38) hide show
  1. package/dist/react-crud-mobile.cjs.development.js +5 -1
  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 +5 -1
  6. package/dist/react-crud-mobile.esm.js.map +1 -1
  7. package/package.json +75 -75
  8. package/src/elements/UI.tsx +73 -73
  9. package/src/elements/UIChildren.tsx +139 -139
  10. package/src/elements/UIComplete.tsx +14 -14
  11. package/src/elements/UIElement.tsx +696 -692
  12. package/src/elements/UITag.tsx +13 -13
  13. package/src/elements/charts/ElChart.tsx +10 -10
  14. package/src/elements/core/SafeView.tsx +69 -69
  15. package/src/elements/core/UIAutoComplete.tsx +17 -17
  16. package/src/elements/core/UIButton.tsx +139 -139
  17. package/src/elements/core/UIIcon.tsx +25 -25
  18. package/src/elements/core/UIInclude.tsx +40 -40
  19. package/src/elements/core/UIInput.tsx +96 -96
  20. package/src/elements/core/UILink.tsx +17 -17
  21. package/src/elements/core/UIList.tsx +168 -168
  22. package/src/elements/core/UIListItem.tsx +32 -32
  23. package/src/elements/core/UIListRow.tsx +123 -123
  24. package/src/elements/core/UIModal.tsx +204 -204
  25. package/src/elements/core/UIOption.tsx +17 -17
  26. package/src/elements/core/UIQuantity.tsx +98 -98
  27. package/src/elements/core/UIRadio.tsx +17 -17
  28. package/src/elements/core/UISelect.tsx +135 -135
  29. package/src/elements/core/UISlider.tsx +61 -61
  30. package/src/elements/core/UISwitch.tsx +27 -27
  31. package/src/elements/core/UIToast.tsx +44 -44
  32. package/src/elements/core/UIToggle.tsx +102 -102
  33. package/src/elements/core/UIView.tsx +94 -94
  34. package/src/elements/index.ts +1 -1
  35. package/src/elements/tabs/ElTabs.tsx +178 -178
  36. package/src/hooks/useIsVisible.ts +39 -39
  37. package/src/index.ts +1 -1
  38. package/src/utils/MobileUtils.ts +12 -12
@@ -1,44 +1,44 @@
1
- import { StyleSheet } from 'react-native';
2
- import Toast, { BaseToast, ErrorToast } from 'react-native-toast-message';
3
-
4
- export default function UIToast() {
5
- const toastConfig = {
6
- success: props => (
7
- <BaseToast
8
- {...props}
9
- style={styles.darkToast}
10
- contentContainerStyle={{ paddingHorizontal: 15 }}
11
- text1Style={styles.text}
12
- text2Style={styles.text}
13
- />
14
- ),
15
- error: props => (
16
- <ErrorToast
17
- {...props}
18
- style={styles.darkToast}
19
- text1Style={styles.text}
20
- text2Style={styles.text}
21
- />
22
- ),
23
- info: props => (
24
- <BaseToast
25
- {...props}
26
- style={styles.darkToast}
27
- text1Style={styles.text}
28
- text2Style={styles.text}
29
- />
30
- ),
31
- };
32
-
33
- const styles = StyleSheet.create({
34
- darkToast: {
35
- backgroundColor: 'rgba(34, 34, 34, 0.85)',
36
- borderLeftColor: '#222', // borda mais escura
37
- },
38
- text: {
39
- color: '#fff', // letras brancas
40
- textAlign: 'center',
41
- },
42
- });
43
- return <Toast config={toastConfig} />;
44
- }
1
+ import { StyleSheet } from 'react-native';
2
+ import Toast, { BaseToast, ErrorToast } from 'react-native-toast-message';
3
+
4
+ export default function UIToast() {
5
+ const toastConfig = {
6
+ success: props => (
7
+ <BaseToast
8
+ {...props}
9
+ style={styles.darkToast}
10
+ contentContainerStyle={{ paddingHorizontal: 15 }}
11
+ text1Style={styles.text}
12
+ text2Style={styles.text}
13
+ />
14
+ ),
15
+ error: props => (
16
+ <ErrorToast
17
+ {...props}
18
+ style={styles.darkToast}
19
+ text1Style={styles.text}
20
+ text2Style={styles.text}
21
+ />
22
+ ),
23
+ info: props => (
24
+ <BaseToast
25
+ {...props}
26
+ style={styles.darkToast}
27
+ text1Style={styles.text}
28
+ text2Style={styles.text}
29
+ />
30
+ ),
31
+ };
32
+
33
+ const styles = StyleSheet.create({
34
+ darkToast: {
35
+ backgroundColor: 'rgba(34, 34, 34, 0.85)',
36
+ borderLeftColor: '#222', // borda mais escura
37
+ },
38
+ text: {
39
+ color: '#fff', // letras brancas
40
+ textAlign: 'center',
41
+ },
42
+ });
43
+ return <Toast config={toastConfig} />;
44
+ }
@@ -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: 10,
91
- marginVertical: 8,
92
- backgroundColor: 'background',
93
- borderRadius: 8,
94
- justifyContent: 'center',
95
- width: 'auto',
96
- flexDirection: 'row',
97
- },
98
- text: {
99
- fontSize: 15,
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: 10,
91
+ marginVertical: 8,
92
+ backgroundColor: 'background',
93
+ borderRadius: 8,
94
+ justifyContent: 'center',
95
+ width: 'auto',
96
+ flexDirection: 'row',
97
+ },
98
+ text: {
99
+ fontSize: 15,
100
+ fontWeight: '500',
101
+ },
102
+ });
@@ -1,94 +1,94 @@
1
- import { ScrollView, StyleSheet, Text, View } from 'react-native';
2
-
3
- import UIChildren from '../UIChildren';
4
- import {
5
- ChildType,
6
- ComponentUtils,
7
- HtmlUtils,
8
- Utils,
9
- ViewUtils,
10
- } from 'react-crud-utils';
11
- import { useEffect, useRef } from 'react';
12
- import UIToast from './UIToast';
13
- import MobileUtils from '../../utils/MobileUtils';
14
-
15
- export default function UIView({ scope, children }: ChildType) {
16
- const theme = scope.getTheme();
17
- const header = scope.getPart('header', null, []);
18
- const headerStyle = Utils.nvl(theme.styles?.defaults?.header, {});
19
- const headerTextStyle = Utils.nvl(theme.styles?.defaults?.headerText, {});
20
- const scrollRef = useRef(null);
21
-
22
- useEffect(() => {
23
- MobileUtils.syncTheme();
24
- }, []);
25
-
26
- const onScroll = () => {
27
- const crud = ViewUtils.getCrud();
28
-
29
- Utils.each(crud.scroll, s => {
30
- if (s.onScroll) {
31
- s.onScroll.call(s);
32
- }
33
- });
34
- };
35
-
36
- let headerStyleFull = Utils.call(() => {
37
- let css = scope.getStyle('header', headerStyle);
38
- let bg = css.backgroundColor;
39
-
40
- if (bg) {
41
- css.color = HtmlUtils.getTextColor(bg);
42
- }
43
- return css;
44
- });
45
-
46
- let hasHeader = !Utils.isEmpty(header);
47
- let AuxHeader = () => {
48
- if (typeof header === 'string') {
49
- return <Text style={headerTextStyle}>{header}</Text>;
50
- }
51
- return <>{header}</>;
52
- };
53
-
54
- scope.put('scrollRef', scrollRef);
55
-
56
- ComponentUtils.setViewScope(scope);
57
-
58
- return (
59
- <>
60
- {hasHeader && (
61
- <View style={headerStyleFull}>
62
- <AuxHeader />
63
- </View>
64
- )}
65
- <View style={scope.getStyle('container', styles.container)}>
66
- <ScrollView
67
- onScroll={onScroll}
68
- scrollEventThrottle={16}
69
- ref={scrollRef}
70
- nestedScrollEnabled={true}
71
- keyboardShouldPersistTaps="handled"
72
- contentContainerStyle={scope.getStyle('contentContainer', {
73
- paddingBottom: 50,
74
- })}
75
- style={scope.getStyle('scroll', styles.scroll)}
76
- >
77
- <UIChildren scope={scope}>{children}</UIChildren>
78
- </ScrollView>
79
- </View>
80
- <UIToast /> {/* <- este componente precisa estar aqui */}
81
- </>
82
- );
83
- }
84
-
85
- const styles = StyleSheet.create({
86
- scroll: {
87
- paddingTop: 10,
88
- paddingBottom: 10,
89
- paddingLeft: 15,
90
- paddingRight: 15,
91
- },
92
- container: {},
93
- view: {},
94
- });
1
+ import { ScrollView, StyleSheet, Text, View } from 'react-native';
2
+
3
+ import UIChildren from '../UIChildren';
4
+ import {
5
+ ChildType,
6
+ ComponentUtils,
7
+ HtmlUtils,
8
+ Utils,
9
+ ViewUtils,
10
+ } from 'react-crud-utils';
11
+ import { useEffect, useRef } from 'react';
12
+ import UIToast from './UIToast';
13
+ import MobileUtils from '../../utils/MobileUtils';
14
+
15
+ export default function UIView({ scope, children }: ChildType) {
16
+ const theme = scope.getTheme();
17
+ const header = scope.getPart('header', null, []);
18
+ const headerStyle = Utils.nvl(theme.styles?.defaults?.header, {});
19
+ const headerTextStyle = Utils.nvl(theme.styles?.defaults?.headerText, {});
20
+ const scrollRef = useRef(null);
21
+
22
+ useEffect(() => {
23
+ MobileUtils.syncTheme();
24
+ }, []);
25
+
26
+ const onScroll = () => {
27
+ const crud = ViewUtils.getCrud();
28
+
29
+ Utils.each(crud.scroll, s => {
30
+ if (s.onScroll) {
31
+ s.onScroll.call(s);
32
+ }
33
+ });
34
+ };
35
+
36
+ let headerStyleFull = Utils.call(() => {
37
+ let css = scope.getStyle('header', headerStyle);
38
+ let bg = css.backgroundColor;
39
+
40
+ if (bg) {
41
+ css.color = HtmlUtils.getTextColor(bg);
42
+ }
43
+ return css;
44
+ });
45
+
46
+ let hasHeader = !Utils.isEmpty(header);
47
+ let AuxHeader = () => {
48
+ if (typeof header === 'string') {
49
+ return <Text style={headerTextStyle}>{header}</Text>;
50
+ }
51
+ return <>{header}</>;
52
+ };
53
+
54
+ scope.put('scrollRef', scrollRef);
55
+
56
+ ComponentUtils.setViewScope(scope);
57
+
58
+ return (
59
+ <>
60
+ {hasHeader && (
61
+ <View style={headerStyleFull}>
62
+ <AuxHeader />
63
+ </View>
64
+ )}
65
+ <View style={scope.getStyle('container', styles.container)}>
66
+ <ScrollView
67
+ onScroll={onScroll}
68
+ scrollEventThrottle={16}
69
+ ref={scrollRef}
70
+ nestedScrollEnabled={true}
71
+ keyboardShouldPersistTaps="handled"
72
+ contentContainerStyle={scope.getStyle('contentContainer', {
73
+ paddingBottom: 50,
74
+ })}
75
+ style={scope.getStyle('scroll', styles.scroll)}
76
+ >
77
+ <UIChildren scope={scope}>{children}</UIChildren>
78
+ </ScrollView>
79
+ </View>
80
+ <UIToast /> {/* <- este componente precisa estar aqui */}
81
+ </>
82
+ );
83
+ }
84
+
85
+ const styles = StyleSheet.create({
86
+ scroll: {
87
+ paddingTop: 10,
88
+ paddingBottom: 10,
89
+ paddingLeft: 15,
90
+ paddingRight: 15,
91
+ },
92
+ container: {},
93
+ view: {},
94
+ });
@@ -1 +1 @@
1
- export { default as UI } from "./UI";
1
+ export { default as UI } from "./UI";