react-crud-mobile 1.1.3 → 1.3.2
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.
- package/dist/elements/UI.d.ts +47 -0
- package/dist/elements/UIChildren.d.ts +15 -0
- package/dist/elements/UIComplete.d.ts +3 -0
- package/dist/elements/UIElement.d.ts +3 -0
- package/dist/elements/UITag.d.ts +7 -0
- package/dist/elements/charts/ElChart.d.ts +3 -0
- package/dist/elements/core/SafeView.d.ts +9 -0
- package/dist/elements/core/UIAutoComplete.d.ts +2 -0
- package/dist/elements/core/UIButton.d.ts +3 -0
- package/dist/elements/core/UIIcon.d.ts +3 -0
- package/dist/elements/core/UIInclude.d.ts +3 -0
- package/dist/elements/core/UIInput.d.ts +3 -0
- package/dist/elements/core/UILink.d.ts +2 -0
- package/dist/elements/core/UIList.d.ts +3 -0
- package/dist/elements/core/UIListItem.d.ts +7 -0
- package/dist/elements/core/UIListRow.d.ts +8 -0
- package/dist/elements/core/UIModal.d.ts +3 -0
- package/dist/elements/core/UIOption.d.ts +2 -0
- package/dist/elements/core/UIQuantity.d.ts +3 -0
- package/dist/elements/core/UIRadio.d.ts +2 -0
- package/dist/elements/core/UISelect.d.ts +3 -0
- package/dist/elements/core/UISlider.d.ts +3 -0
- package/dist/elements/core/UISwitch.d.ts +3 -0
- package/dist/elements/core/UIToast.d.ts +2 -0
- package/dist/elements/core/UIToggle.d.ts +3 -0
- package/dist/elements/core/UIView.d.ts +3 -0
- package/dist/elements/index.d.ts +1 -0
- package/dist/elements/tabs/ElTabs.d.ts +3 -0
- package/dist/hooks/useIsVisible.d.ts +2 -0
- package/dist/index.d.ts +1 -2
- package/dist/react-crud-mobile.cjs.development.js +2367 -0
- package/dist/react-crud-mobile.cjs.development.js.map +1 -0
- package/dist/react-crud-mobile.cjs.production.min.js +2 -0
- package/dist/react-crud-mobile.cjs.production.min.js.map +1 -0
- package/dist/react-crud-mobile.esm.js +2359 -0
- package/dist/react-crud-mobile.esm.js.map +1 -0
- package/dist/utils/MobileUtils.d.ts +3 -0
- package/package.json +54 -30
- package/src/elements/UI.tsx +34 -18
- package/src/elements/UIChildren.tsx +38 -16
- package/src/elements/UIComplete.tsx +1 -2
- package/src/elements/UIElement.tsx +542 -225
- package/src/elements/core/SafeView.tsx +69 -0
- package/src/elements/core/{Link.tsx → UIAutoComplete.tsx} +17 -18
- package/src/elements/core/UIButton.tsx +139 -0
- package/src/elements/core/UIIcon.tsx +25 -0
- package/src/elements/{grid/ElInclude.tsx → core/UIInclude.tsx} +3 -3
- package/src/elements/core/UIInput.tsx +96 -0
- package/src/elements/core/{Icon.tsx → UILink.tsx} +17 -18
- package/src/elements/core/UIList.tsx +168 -0
- package/src/elements/core/UIListItem.tsx +32 -0
- package/src/elements/core/UIListRow.tsx +123 -0
- package/src/elements/core/UIModal.tsx +204 -0
- package/src/elements/core/{Input.tsx → UIOption.tsx} +17 -18
- package/src/elements/core/UIQuantity.tsx +98 -0
- package/src/elements/core/{Radio.tsx → UIRadio.tsx} +17 -18
- package/src/elements/core/UISelect.tsx +135 -0
- package/src/elements/core/UISlider.tsx +61 -0
- package/src/elements/core/UISwitch.tsx +27 -0
- package/src/elements/core/UIToast.tsx +44 -0
- package/src/elements/core/UIToggle.tsx +102 -0
- package/src/elements/core/UIView.tsx +94 -0
- package/src/elements/grid/ElInclude +0 -0
- package/src/hooks/useIsVisible.ts +39 -0
- package/src/index.ts +1 -1
- package/src/utils/MobileUtils.ts +12 -0
- package/src/elements/card/ElCard.tsx +0 -26
- package/src/elements/core/AutoComplete.tsx +0 -18
- package/src/elements/core/Button.tsx +0 -18
- package/src/elements/core/Option.tsx +0 -18
- package/src/elements/core/Select.tsx +0 -18
- package/src/elements/core/Switch.tsx +0 -18
- package/src/elements/grid/ElGrid.tsx +0 -50
- package/src/elements/grid/ElGridBotom.tsx +0 -21
- package/src/elements/grid/ElGridCheck.tsx +0 -67
- package/src/elements/grid/ElGridColumn.tsx +0 -32
- package/src/elements/grid/ElGridFilter.tsx +0 -5
- package/src/elements/grid/ElGridPaginator.tsx +0 -82
- package/src/elements/grid/ElGridRow.tsx +0 -123
- package/src/elements/grid/ElGridTop.tsx +0 -45
- package/src/elements/grid/ElLabel.tsx +0 -50
- package/src/elements/grid/ElRepeat.tsx +0 -24
- package/src/elements/grid/ElRepeatRow.tsx +0 -40
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { ChildType, Utils } from 'react-crud-utils';
|
|
3
|
+
import { Switch } from 'react-native';
|
|
4
|
+
|
|
5
|
+
export default function UISwitch(props: ChildType) {
|
|
6
|
+
const scope = props.scope;
|
|
7
|
+
const initial = Utils.nvl(scope.getValue(), false) as boolean;
|
|
8
|
+
const [value, setValue] = useState(initial);
|
|
9
|
+
|
|
10
|
+
let onChange = v => {
|
|
11
|
+
scope.changeValue(v);
|
|
12
|
+
|
|
13
|
+
setValue(v);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Switch
|
|
18
|
+
value={value}
|
|
19
|
+
style={scope.getStyle('element')}
|
|
20
|
+
onValueChange={onChange} // Alterna o estado
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const styles = {
|
|
26
|
+
link: {},
|
|
27
|
+
};
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +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
|
+
});
|
|
@@ -0,0 +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
|
+
});
|
|
File without changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { Scope } from 'react-crud-utils';
|
|
3
|
+
import { Dimensions, Platform } from 'react-native';
|
|
4
|
+
|
|
5
|
+
export function useIsVisible(ref: any, scope: Scope) {
|
|
6
|
+
const [isVisible, setIsVisible] = useState(scope.visible === true);
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const checkVisibility = () => {
|
|
10
|
+
if (!ref.current || isVisible || !scope.original?.useIsInView) return;
|
|
11
|
+
|
|
12
|
+
if (Platform.OS === 'web') {
|
|
13
|
+
const rect = ref.current.getBoundingClientRect?.();
|
|
14
|
+
|
|
15
|
+
if (rect && typeof window !== 'undefined') {
|
|
16
|
+
const windowHeight = window.innerHeight;
|
|
17
|
+
const visible = rect.top < windowHeight && rect.bottom > 0;
|
|
18
|
+
|
|
19
|
+
if (visible) scope.visible = visible;
|
|
20
|
+
|
|
21
|
+
setIsVisible(visible);
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
ref.current.measureInWindow?.((x, y, width, height) => {
|
|
25
|
+
const windowHeight = Dimensions.get('window').height;
|
|
26
|
+
const visible = y < windowHeight && y + height > 0;
|
|
27
|
+
|
|
28
|
+
if (visible) scope.visible = visible;
|
|
29
|
+
setIsVisible(visible);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const interval = setInterval(checkVisibility, 300); // roda a cada 300ms
|
|
35
|
+
return () => clearInterval(interval);
|
|
36
|
+
}, [ref]);
|
|
37
|
+
|
|
38
|
+
return isVisible;
|
|
39
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './elements';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//import { ThemeUtils, Utils } from 'react-crud-utils';
|
|
2
|
+
//import { StatusBar } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export default class MobileUtils {
|
|
5
|
+
static syncTheme() {
|
|
6
|
+
// let current = ThemeUtils.getCurrentTheme();
|
|
7
|
+
//let dec: any = { light: 'light-content', dark: 'dark-content' };
|
|
8
|
+
//let name = Utils.nvl(dec[current?.theme], dec.light);
|
|
9
|
+
//StatusBar.setBarStyle?.(name);
|
|
10
|
+
//StatusBar.setBackgroundColor?.(current?.colors?.theme);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import UIChildren from '../UIChildren';
|
|
3
|
-
import ElLabel from '../grid/ElLabel';
|
|
4
|
-
import ElInclude from '../grid/ElInclude';
|
|
5
|
-
import { ChildType } from 'react-crud-utils';
|
|
6
|
-
|
|
7
|
-
export default function ElCard(props: ChildType) {
|
|
8
|
-
let scope = props.scope;
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<div
|
|
12
|
-
className={scope.getStyleClass('inner')}
|
|
13
|
-
style={scope.getStyle('inner')}
|
|
14
|
-
>
|
|
15
|
-
<ElLabel {...props} scope={scope}></ElLabel>
|
|
16
|
-
<UIChildren {...props} scope={scope} />
|
|
17
|
-
|
|
18
|
-
<div
|
|
19
|
-
className={scope.getStyleClass('bottom')}
|
|
20
|
-
style={scope.getStyle('bottom')}
|
|
21
|
-
>
|
|
22
|
-
<ElInclude {...props} scope={scope} name="bottom" />
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
|
|
3
|
-
|
|
4
|
-
export default function AutoComplete(props: any) {
|
|
5
|
-
const handlePress = () => {
|
|
6
|
-
Linking.openURL('https://reactnative.dev/');
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<TouchableOpacity onPress={handlePress}>
|
|
11
|
-
<Text style={styles.link}>Clique aqui para acessar o React Native</Text>
|
|
12
|
-
</TouchableOpacity>
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const styles = {
|
|
17
|
-
link: {},
|
|
18
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
|
|
3
|
-
|
|
4
|
-
export default function Button(props: any) {
|
|
5
|
-
const handlePress = () => {
|
|
6
|
-
Linking.openURL('https://reactnative.dev/');
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<TouchableOpacity onPress={handlePress}>
|
|
11
|
-
<Text style={styles.link}>Clique aqui para acessar o React Native</Text>
|
|
12
|
-
</TouchableOpacity>
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const styles = {
|
|
17
|
-
link: {},
|
|
18
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
|
|
3
|
-
|
|
4
|
-
export default function Option(props: any) {
|
|
5
|
-
const handlePress = () => {
|
|
6
|
-
Linking.openURL('https://reactnative.dev/');
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<TouchableOpacity onPress={handlePress}>
|
|
11
|
-
<Text style={styles.link}>Clique aqui para acessar o React Native</Text>
|
|
12
|
-
</TouchableOpacity>
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const styles = {
|
|
17
|
-
link: {},
|
|
18
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
|
|
3
|
-
|
|
4
|
-
export default function Select(props: any) {
|
|
5
|
-
const handlePress = () => {
|
|
6
|
-
Linking.openURL('https://reactnative.dev/');
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<TouchableOpacity onPress={handlePress}>
|
|
11
|
-
<Text style={styles.link}>Clique aqui para acessar o React Native</Text>
|
|
12
|
-
</TouchableOpacity>
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const styles = {
|
|
17
|
-
link: {},
|
|
18
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
|
|
3
|
-
|
|
4
|
-
export default function Switch(props: any) {
|
|
5
|
-
const handlePress = () => {
|
|
6
|
-
Linking.openURL('https://reactnative.dev/');
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<TouchableOpacity onPress={handlePress}>
|
|
11
|
-
<Text style={styles.link}>Clique aqui para acessar o React Native</Text>
|
|
12
|
-
</TouchableOpacity>
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const styles = {
|
|
17
|
-
link: {},
|
|
18
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import ElGridRow from './ElGridRow';
|
|
4
|
-
import ElGridTop from './ElGridTop';
|
|
5
|
-
import ElGridFilter from './ElGridFilter';
|
|
6
|
-
import ElGridBotom from './ElGridBotom';
|
|
7
|
-
import ElLabel from './ElLabel';
|
|
8
|
-
import { ChildType, ComponentUtils, Scope } from 'react-crud-utils';
|
|
9
|
-
|
|
10
|
-
export default function ElGrid(props: ChildType) {
|
|
11
|
-
let scope: Scope = props.scope;
|
|
12
|
-
let items: any = scope.getItems();
|
|
13
|
-
let expansion = ComponentUtils.getDefine(props, 'expansion');
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<div
|
|
17
|
-
className={scope.getStyleClass('inner')}
|
|
18
|
-
style={scope.getStyle('inner')}
|
|
19
|
-
>
|
|
20
|
-
<ElLabel {...props} scope={scope} position="outside"></ElLabel>
|
|
21
|
-
<div
|
|
22
|
-
className={scope.getStyleClass('child')}
|
|
23
|
-
style={scope.getStyle('child')}
|
|
24
|
-
>
|
|
25
|
-
<ElLabel {...props} scope={scope} position="inside"></ElLabel>
|
|
26
|
-
<div className="ui-data">
|
|
27
|
-
<ElGridTop {...props} scope={scope}></ElGridTop>
|
|
28
|
-
<ElGridFilter scope={scope}></ElGridFilter>
|
|
29
|
-
<div className="ui-grid-data">
|
|
30
|
-
<table className="ui-grid ui-table">
|
|
31
|
-
<tbody>
|
|
32
|
-
{items.map((row: any, i: number) => (
|
|
33
|
-
<ElGridRow
|
|
34
|
-
{...props}
|
|
35
|
-
expansion={expansion}
|
|
36
|
-
key={'r' + i}
|
|
37
|
-
scope={scope}
|
|
38
|
-
value={row}
|
|
39
|
-
index={i}
|
|
40
|
-
/>
|
|
41
|
-
))}
|
|
42
|
-
</tbody>
|
|
43
|
-
</table>
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
<ElGridBotom {...props} scope={scope} />
|
|
47
|
-
</div>
|
|
48
|
-
</div>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import ElGridPaginator from "./ElGridPaginator";
|
|
3
|
-
import UI from "../UI";
|
|
4
|
-
import { ChildType } from "react-crud-utils";
|
|
5
|
-
|
|
6
|
-
export default function ElGridBotom(props: ChildType) {
|
|
7
|
-
let scope = props.scope;
|
|
8
|
-
let children = props.children;
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<div className="ui-grid-bottom">
|
|
12
|
-
<div className="ui-grid-bottom-inner">
|
|
13
|
-
<UI.Include {...props} transient name="bottomLeft" />
|
|
14
|
-
<ElGridPaginator scope={scope} position="bottom">
|
|
15
|
-
{children}
|
|
16
|
-
</ElGridPaginator>
|
|
17
|
-
<UI.Include {...props} transient name="bottomRight" />
|
|
18
|
-
</div>
|
|
19
|
-
</div>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import UI from '../UI';
|
|
2
|
-
import Ionicons from '@expo/vector-icons/Ionicons';
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
import { GridRowType, Utils } from 'react-crud-utils';
|
|
5
|
-
|
|
6
|
-
export default function ElGridCheck({ scope, value, rowIndex }: GridRowType) {
|
|
7
|
-
let original = scope.original;
|
|
8
|
-
let [index, setIndex] = useState(0);
|
|
9
|
-
let key = scope.key('check', rowIndex, 's', index);
|
|
10
|
-
|
|
11
|
-
let check = () => {
|
|
12
|
-
let cs = scope.crudSearch;
|
|
13
|
-
|
|
14
|
-
if (cs) {
|
|
15
|
-
if (!cs.selecteds) {
|
|
16
|
-
cs.selecteds = {};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
let itemValue = Utils.nvl(original.itemValue, 'id');
|
|
20
|
-
let key = value[itemValue];
|
|
21
|
-
|
|
22
|
-
if (typeof key !== 'undefined') {
|
|
23
|
-
if (typeof cs.selecteds[key] === 'undefined') {
|
|
24
|
-
cs.selecteds[key] = value;
|
|
25
|
-
} else {
|
|
26
|
-
delete cs.selecteds[key];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
setIndex(++index);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
let getCheckIcon = () => {
|
|
34
|
-
if (isChecked()) {
|
|
35
|
-
return <Ionicons />;
|
|
36
|
-
}
|
|
37
|
-
return <Ionicons />;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
let isChecked = () => {
|
|
41
|
-
let cs = scope.crudSearch;
|
|
42
|
-
|
|
43
|
-
if (cs) {
|
|
44
|
-
if (!cs.selecteds) {
|
|
45
|
-
cs.selecteds = {};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
let itemValue = Utils.nvl(original.itemValue, 'id');
|
|
49
|
-
let key = value[itemValue];
|
|
50
|
-
|
|
51
|
-
if (typeof key !== 'undefined') {
|
|
52
|
-
if (typeof cs.selecteds[key] !== 'undefined') {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return false;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<UI.Button
|
|
62
|
-
key={key}
|
|
63
|
-
icon={getCheckIcon()}
|
|
64
|
-
click={{ action: check }}
|
|
65
|
-
></UI.Button>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import UIChildren from "../UIChildren";
|
|
3
|
-
import { Scope, Utils } from "react-crud-utils";
|
|
4
|
-
|
|
5
|
-
interface ElGridColumnType {
|
|
6
|
-
scope: Scope;
|
|
7
|
-
styleClass?: string;
|
|
8
|
-
children?: any;
|
|
9
|
-
colspan?: number;
|
|
10
|
-
column?: any;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default function ElGridColumn(props: ElGridColumnType) {
|
|
14
|
-
let scope = props.scope;
|
|
15
|
-
let col = Utils.nvl(props.column?.props, {});
|
|
16
|
-
let [colScope] = useState(new Scope(col, scope, scope.crud));
|
|
17
|
-
|
|
18
|
-
let getStyleClass = () => {
|
|
19
|
-
let def = Utils.nvl(props.styleClass, "");
|
|
20
|
-
|
|
21
|
-
return "ui-grid-col " + def + " " + colScope.getStyleClass("column");
|
|
22
|
-
};
|
|
23
|
-
return (
|
|
24
|
-
<td
|
|
25
|
-
className={getStyleClass()}
|
|
26
|
-
style={colScope.getStyle("column")}
|
|
27
|
-
colSpan={props.colspan}
|
|
28
|
-
>
|
|
29
|
-
<UIChildren scope={scope}>{props.children}</UIChildren>
|
|
30
|
-
</td>
|
|
31
|
-
);
|
|
32
|
-
}
|