@quintype/native-components 2.29.1-beta.3 → 2.29.1-beta.4
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/package.json
CHANGED
|
@@ -40,7 +40,7 @@ const getHTMLContent = (embedJs) => {
|
|
|
40
40
|
const width = useWindowDimensions().width;
|
|
41
41
|
const decodedContent = getDecodedContent(embedJs);
|
|
42
42
|
let htmlContent = replaceDefaultProtocol(decodedContent);
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
const webViewScript = `
|
|
45
45
|
<script type="application/javascript">
|
|
46
46
|
var interValId;
|
|
@@ -78,6 +78,7 @@ export const JSEmbedElement = (props) => {
|
|
|
78
78
|
const [height, setHeight] = useState(-1);
|
|
79
79
|
const webViewRef = useRef(null);
|
|
80
80
|
const screenWidth = useWindowDimensions().width;
|
|
81
|
+
const screenHeight = useWindowDimensions().height;
|
|
81
82
|
const width = get(
|
|
82
83
|
props,
|
|
83
84
|
['currentLayout', 'width'],
|
|
@@ -92,15 +93,31 @@ export const JSEmbedElement = (props) => {
|
|
|
92
93
|
setHeight(parseInt(event.nativeEvent.data));
|
|
93
94
|
};
|
|
94
95
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
// Function to manually extract the base URL from an iframe src
|
|
97
|
+
const extractBaseUrlFromIframe = (iframeHtml) => {
|
|
98
|
+
const regex = /src="([^"]+)"/; // Regex to extract src URL from iframe
|
|
99
|
+
const match = iframeHtml.match(regex);
|
|
100
|
+
|
|
101
|
+
if (match && match[1]) {
|
|
102
|
+
const srcUrl = match[1]; // The full src URL from iframe
|
|
103
|
+
|
|
104
|
+
// Manually extract the base URL (protocol + host + pathname)
|
|
105
|
+
const urlPattern = /^(https?:\/\/[^/]+(?:\/[^?]*)?)/;
|
|
106
|
+
const baseUrlMatch = srcUrl.match(urlPattern);
|
|
101
107
|
|
|
102
|
-
|
|
108
|
+
if (baseUrlMatch) {
|
|
109
|
+
return baseUrlMatch[1]; // Return the base URL
|
|
110
|
+
} else {
|
|
111
|
+
console.error('Invalid URL format.');
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
console.error('Iframe src not found.');
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
103
119
|
|
|
120
|
+
const constructSource = () => {
|
|
104
121
|
return {
|
|
105
122
|
html: getHTMLContent(props.element['embed-js']),
|
|
106
123
|
baseUrl: extractBaseUrlFromIframe(getDecodedContent(props.element['embed-js'])),
|
|
@@ -113,7 +130,7 @@ export const JSEmbedElement = (props) => {
|
|
|
113
130
|
ref={webViewRef}
|
|
114
131
|
style={{
|
|
115
132
|
width,
|
|
116
|
-
height: Number(height),
|
|
133
|
+
height: Math.min(Number(height), screenHeight-250),
|
|
117
134
|
flex: 0,
|
|
118
135
|
opacity: 0.99,
|
|
119
136
|
}}
|
|
@@ -132,6 +149,7 @@ export const JSEmbedElement = (props) => {
|
|
|
132
149
|
source={constructSource()}
|
|
133
150
|
mixedContentMode="always"
|
|
134
151
|
mediaPlaybackRequiresUserAction={true}
|
|
152
|
+
nestedScrollEnabled={true}
|
|
135
153
|
/>
|
|
136
154
|
</View>
|
|
137
155
|
}
|
|
@@ -162,6 +180,7 @@ export const JSEmbedElement = (props) => {
|
|
|
162
180
|
mixedContentMode="always"
|
|
163
181
|
mediaPlaybackRequiresUserAction={true}
|
|
164
182
|
injectedJavaScript='window.ReactNativeWebView.postMessage(document.body.scrollHeight)'
|
|
183
|
+
nestedScrollEnabled={true}
|
|
165
184
|
/>
|
|
166
185
|
</View>
|
|
167
186
|
);
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
|
|
3
|
+
|
|
4
|
+
const Pagination = ({ currentPage, totalPages, onPageChange }) => {
|
|
5
|
+
const range = 2;
|
|
6
|
+
|
|
7
|
+
const getPages = () => {
|
|
8
|
+
const pages = [];
|
|
9
|
+
let start = Math.max(1, currentPage - range);
|
|
10
|
+
let end = Math.min(totalPages, currentPage + range);
|
|
11
|
+
|
|
12
|
+
if (start > 1) pages.push('...');
|
|
13
|
+
for (let i = start; i <= end; i++) {
|
|
14
|
+
pages.push(i);
|
|
15
|
+
}
|
|
16
|
+
if (end < totalPages) pages.push('...');
|
|
17
|
+
|
|
18
|
+
return pages;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const handlePageChange = (page) => {
|
|
23
|
+
if (page >= 1 && page <= totalPages && page !== currentPage) {
|
|
24
|
+
onPageChange(page);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const pages = getPages();
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<View style={styles.container}>
|
|
32
|
+
<TouchableOpacity
|
|
33
|
+
onPress={() => handlePageChange(currentPage - 1)}
|
|
34
|
+
disabled={currentPage === 1}
|
|
35
|
+
style={[styles.arrow, currentPage === 1 && styles.disabled]}>
|
|
36
|
+
<Text style={styles.arrowText}>{'<'}</Text>
|
|
37
|
+
</TouchableOpacity>
|
|
38
|
+
|
|
39
|
+
{pages.map((page, index) => (
|
|
40
|
+
<TouchableOpacity
|
|
41
|
+
key={index}
|
|
42
|
+
onPress={() => handlePageChange(page)}
|
|
43
|
+
|
|
44
|
+
style={[
|
|
45
|
+
styles.pageButton,
|
|
46
|
+
page === currentPage && styles.activePage,
|
|
47
|
+
|
|
48
|
+
]}
|
|
49
|
+
>
|
|
50
|
+
<Text style={styles.pageText}>
|
|
51
|
+
{page}
|
|
52
|
+
</Text>
|
|
53
|
+
</TouchableOpacity>
|
|
54
|
+
))}
|
|
55
|
+
|
|
56
|
+
<TouchableOpacity
|
|
57
|
+
onPress={() => handlePageChange(currentPage + 1)}
|
|
58
|
+
disabled={currentPage === totalPages}
|
|
59
|
+
style={[styles.arrow, currentPage === totalPages && styles.disabled]}>
|
|
60
|
+
<Text style={styles.arrowText}>{'>'}</Text>
|
|
61
|
+
</TouchableOpacity>
|
|
62
|
+
</View>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const styles = StyleSheet.create({
|
|
67
|
+
container: {
|
|
68
|
+
flexDirection: 'row',
|
|
69
|
+
alignItems: 'center',
|
|
70
|
+
justifyContent: 'center',
|
|
71
|
+
marginVertical: 20,
|
|
72
|
+
|
|
73
|
+
marginHorizontal:20,
|
|
74
|
+
borderRadius:5
|
|
75
|
+
},
|
|
76
|
+
arrow: {
|
|
77
|
+
padding: 5,
|
|
78
|
+
borderRadius: 5,
|
|
79
|
+
backgroundColor: '#f0f0f0',
|
|
80
|
+
height:38,
|
|
81
|
+
paddingHorizontal:10
|
|
82
|
+
},
|
|
83
|
+
arrowText: {
|
|
84
|
+
fontSize: 20,
|
|
85
|
+
color: '#000',
|
|
86
|
+
},
|
|
87
|
+
pageButton: {
|
|
88
|
+
marginHorizontal: 5,
|
|
89
|
+
padding: 10,
|
|
90
|
+
borderRadius: 5,
|
|
91
|
+
backgroundColor: '#f0f0f0',
|
|
92
|
+
height:38,
|
|
93
|
+
paddingHorizontal:12
|
|
94
|
+
},
|
|
95
|
+
pageText: {
|
|
96
|
+
fontSize: 16,
|
|
97
|
+
color: '#000',
|
|
98
|
+
},
|
|
99
|
+
activePage: {
|
|
100
|
+
backgroundColor: '#993366',
|
|
101
|
+
height:38,
|
|
102
|
+
padding: 10,
|
|
103
|
+
},
|
|
104
|
+
disabled: {
|
|
105
|
+
opacity: 0.5,
|
|
106
|
+
},
|
|
107
|
+
disabledText: {
|
|
108
|
+
color: '#ccc',
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
export default Pagination;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
import { View , ScrollView } from 'react-native';
|
|
1
|
+
import React, { useContext, useEffect } from 'react';
|
|
2
|
+
import { View , ScrollView, Button } from 'react-native';
|
|
3
3
|
import get from 'lodash/get';
|
|
4
4
|
import { formatData } from '../../utils/tableUtils';
|
|
5
5
|
import { tableStyles } from './styles';
|
|
6
6
|
import { Text } from '../index';
|
|
7
7
|
import { AppTheme } from '../../utils';
|
|
8
|
+
import Pagination from '@quintype/native-components/src/components/Pagination';
|
|
8
9
|
|
|
9
10
|
export const Table = ({ card }) => {
|
|
10
11
|
const csv = get(card, ['data', 'content'], '');
|
|
@@ -19,10 +20,19 @@ export const Table = ({ card }) => {
|
|
|
19
20
|
);
|
|
20
21
|
|
|
21
22
|
const tableData = [tableHeaderRow].concat(headerData);
|
|
23
|
+
const [filteredData, setFilteredData] = React.useState([]);
|
|
24
|
+
const [activePage, setActivePage] = React.useState(1);
|
|
25
|
+
|
|
26
|
+
useEffect(()=>{
|
|
27
|
+
const nextData = tableData.slice(Math.max(0, (activePage - 1) * 10), activePage * 10);
|
|
28
|
+
if(nextData.length > 0){
|
|
29
|
+
setFilteredData(nextData)
|
|
30
|
+
}
|
|
31
|
+
},[activePage])
|
|
22
32
|
|
|
23
33
|
const renderTableBody = () => (
|
|
24
34
|
<View style={styles.tableBody}>
|
|
25
|
-
{
|
|
35
|
+
{filteredData.map((data) => (
|
|
26
36
|
<View style={styles.tableRow}>
|
|
27
37
|
{headerFields.map((headerField) => (
|
|
28
38
|
<View style={styles.tableHeaderTitle}>
|
|
@@ -34,11 +44,18 @@ export const Table = ({ card }) => {
|
|
|
34
44
|
</View>
|
|
35
45
|
);
|
|
36
46
|
|
|
47
|
+
const onPageChange = (page) => {
|
|
48
|
+
setActivePage(page);
|
|
49
|
+
};
|
|
50
|
+
|
|
37
51
|
return (
|
|
52
|
+
<>
|
|
53
|
+
<Pagination currentPage={activePage} totalPages={tableData.length / 10} onPageChange={onPageChange}/>
|
|
38
54
|
<ScrollView horizontal>
|
|
39
55
|
<View style={styles.tableContainer}>
|
|
40
|
-
<View>{renderTableBody()}</View>
|
|
56
|
+
{filteredData && <View>{renderTableBody()}</View>}
|
|
41
57
|
</View>
|
|
42
58
|
</ScrollView>
|
|
59
|
+
</>
|
|
43
60
|
);
|
|
44
61
|
};
|