react-crud-mobile 1.3.52 → 1.3.53

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.
@@ -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";
@@ -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';