@idealyst/datagrid 1.0.41 → 1.0.45

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.
@@ -0,0 +1,102 @@
1
+ import React from 'react';
2
+ import { UnistylesRuntime } from 'react-native-unistyles';
3
+
4
+ interface TableProps {
5
+ children: React.ReactNode;
6
+ style?: any;
7
+ }
8
+
9
+ export const Table: React.FC<TableProps> = ({ children, style }) => {
10
+ let resolvedStyle = {};
11
+ if (typeof style === 'function') {
12
+ try {
13
+ resolvedStyle = style(UnistylesRuntime.theme);
14
+ } catch (error) {
15
+ resolvedStyle = {};
16
+ }
17
+ } else if (style) {
18
+ resolvedStyle = style;
19
+ }
20
+
21
+ const combinedStyle = {
22
+ width: '100%',
23
+ tableLayout: 'fixed' as const,
24
+ borderCollapse: 'separate' as const,
25
+ borderSpacing: 0,
26
+ ...resolvedStyle,
27
+ };
28
+
29
+ return (
30
+ <table style={combinedStyle}>
31
+ {children}
32
+ </table>
33
+ );
34
+ };
35
+
36
+ interface TableRowProps {
37
+ children: React.ReactNode;
38
+ style?: any;
39
+ onPress?: () => void;
40
+ }
41
+
42
+ export const TableRow: React.FC<TableRowProps> = ({ children, style, onPress }) => {
43
+ let resolvedStyle = {};
44
+ if (typeof style === 'function') {
45
+ try {
46
+ resolvedStyle = style(UnistylesRuntime.theme);
47
+ } catch (error) {
48
+ resolvedStyle = {};
49
+ }
50
+ } else if (style) {
51
+ resolvedStyle = style;
52
+ }
53
+
54
+ return (
55
+ <tr
56
+ style={resolvedStyle}
57
+ onClick={onPress}
58
+ role={onPress ? 'button' : undefined}
59
+ tabIndex={onPress ? 0 : undefined}
60
+ onKeyDown={onPress ? (e) => {
61
+ if (e.key === 'Enter' || e.key === ' ') {
62
+ e.preventDefault();
63
+ onPress();
64
+ }
65
+ } : undefined}
66
+ >
67
+ {children}
68
+ </tr>
69
+ );
70
+ };
71
+
72
+ interface TableCellProps {
73
+ children: React.ReactNode;
74
+ style?: any;
75
+ width?: number | string;
76
+ colSpan?: number;
77
+ }
78
+
79
+ export const TableCell: React.FC<TableCellProps> = ({ children, style, width, colSpan }) => {
80
+ let resolvedStyle = {};
81
+ if (typeof style === 'function') {
82
+ try {
83
+ resolvedStyle = style(UnistylesRuntime.theme);
84
+ } catch (error) {
85
+ resolvedStyle = {};
86
+ }
87
+ } else if (style) {
88
+ resolvedStyle = style;
89
+ }
90
+
91
+ const combinedStyle = {
92
+ verticalAlign: 'middle',
93
+ ...(width && { width }),
94
+ ...resolvedStyle,
95
+ };
96
+
97
+ return (
98
+ <td style={combinedStyle} colSpan={colSpan}>
99
+ {children}
100
+ </td>
101
+ );
102
+ };
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { UnistylesRuntime } from 'react-native-unistyles';
4
+
5
+ interface TableBodyProps {
6
+ children: React.ReactNode;
7
+ style?: any;
8
+ }
9
+
10
+ export const TableBody: React.FC<TableBodyProps> = ({ children, style }) => {
11
+ let resolvedStyle = {};
12
+ if (typeof style === 'function') {
13
+ try {
14
+ resolvedStyle = style(UnistylesRuntime.theme);
15
+ } catch (error) {
16
+ resolvedStyle = {};
17
+ }
18
+ } else if (style) {
19
+ resolvedStyle = style;
20
+ }
21
+
22
+ return (
23
+ <View style={resolvedStyle}>
24
+ {children}
25
+ </View>
26
+ );
27
+ };
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { UnistylesRuntime } from 'react-native-unistyles';
3
+
4
+ interface TableBodyProps {
5
+ children: React.ReactNode;
6
+ style?: any;
7
+ }
8
+
9
+ export const TableBody: React.FC<TableBodyProps> = ({ children, style }) => {
10
+ let resolvedStyle = {};
11
+ if (typeof style === 'function') {
12
+ try {
13
+ resolvedStyle = style(UnistylesRuntime.theme);
14
+ } catch (error) {
15
+ resolvedStyle = {};
16
+ }
17
+ } else if (style) {
18
+ resolvedStyle = style;
19
+ }
20
+
21
+ return (
22
+ <tbody style={resolvedStyle}>
23
+ {children}
24
+ </tbody>
25
+ );
26
+ };
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { UnistylesRuntime } from 'react-native-unistyles';
4
+
5
+ interface TableHeaderProps {
6
+ children: React.ReactNode;
7
+ style?: any;
8
+ }
9
+
10
+ export const TableHeader: React.FC<TableHeaderProps> = ({ children, style }) => {
11
+ let resolvedStyle = {};
12
+ if (typeof style === 'function') {
13
+ try {
14
+ resolvedStyle = style(UnistylesRuntime.theme);
15
+ } catch (error) {
16
+ resolvedStyle = {};
17
+ }
18
+ } else if (style) {
19
+ resolvedStyle = style;
20
+ }
21
+
22
+ return (
23
+ <View style={resolvedStyle}>
24
+ {children}
25
+ </View>
26
+ );
27
+ };
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { UnistylesRuntime } from 'react-native-unistyles';
3
+
4
+ interface TableHeaderProps {
5
+ children: React.ReactNode;
6
+ style?: any;
7
+ }
8
+
9
+ export const TableHeader: React.FC<TableHeaderProps> = ({ children, style }) => {
10
+ let resolvedStyle = {};
11
+ if (typeof style === 'function') {
12
+ try {
13
+ resolvedStyle = style(UnistylesRuntime.theme);
14
+ } catch (error) {
15
+ resolvedStyle = {};
16
+ }
17
+ } else if (style) {
18
+ resolvedStyle = style;
19
+ }
20
+
21
+ return (
22
+ <thead style={resolvedStyle}>
23
+ {children}
24
+ </thead>
25
+ );
26
+ };
@@ -0,0 +1,3 @@
1
+ export { Table, TableRow, TableCell } from './Table.native';
2
+ export { TableHeader } from './TableHeader.native';
3
+ export { TableBody } from './TableBody.native';
@@ -0,0 +1,3 @@
1
+ export { Table, TableRow, TableCell } from './Table.web';
2
+ export { TableHeader } from './TableHeader.web';
3
+ export { TableBody } from './TableBody.web';
@@ -33,12 +33,14 @@ export const VirtualizedList: React.FC<VirtualizedListProps> = ({
33
33
  };
34
34
 
35
35
  return (
36
- <List {...listProps}>
37
- {({ index, style }) => (
38
- <div style={style}>
39
- {renderItem({ item: data[index], index })}
40
- </div>
41
- )}
42
- </List>
36
+ <div style={{ display: 'table', width: '100%', tableLayout: 'fixed' }}>
37
+ <List {...listProps}>
38
+ {({ index, style }) => (
39
+ <div style={{ ...style, display: 'table-row-group' }}>
40
+ {renderItem({ item: data[index], index })}
41
+ </div>
42
+ )}
43
+ </List>
44
+ </div>
43
45
  );
44
46
  };