@idealyst/components 1.1.7 → 1.1.9
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 +3 -3
- package/plugin/web.js +280 -532
- package/src/Accordion/Accordion.native.tsx +8 -6
- package/src/Accordion/Accordion.styles.old.tsx +298 -0
- package/src/Accordion/Accordion.styles.tsx +102 -236
- package/src/Accordion/Accordion.web.tsx +1 -3
- package/src/ActivityIndicator/ActivityIndicator.styles.old.tsx +94 -0
- package/src/ActivityIndicator/ActivityIndicator.styles.tsx +44 -74
- package/src/Alert/Alert.native.tsx +16 -6
- package/src/Alert/Alert.styles.old.tsx +209 -0
- package/src/Alert/Alert.styles.tsx +67 -149
- package/src/Alert/Alert.web.tsx +3 -4
- package/src/Avatar/Avatar.styles.old.tsx +99 -0
- package/src/Avatar/Avatar.styles.tsx +35 -80
- package/src/Badge/Badge.styles.old.tsx +157 -0
- package/src/Badge/Badge.styles.tsx +61 -121
- package/src/Badge/Badge.web.tsx +8 -15
- package/src/Breadcrumb/Breadcrumb.styles.old.tsx +231 -0
- package/src/Breadcrumb/Breadcrumb.styles.tsx +83 -200
- package/src/Breadcrumb/Breadcrumb.web.tsx +31 -30
- package/src/Button/Button.native.tsx +14 -21
- package/src/Button/Button.styles.tsx +103 -140
- package/src/Button/Button.web.tsx +9 -19
- package/src/Card/Card.native.tsx +7 -11
- package/src/Card/Card.styles.old.tsx +160 -0
- package/src/Card/Card.styles.tsx +105 -142
- package/src/Card/Card.web.tsx +5 -4
- package/src/Checkbox/Checkbox.native.tsx +9 -5
- package/src/Checkbox/Checkbox.styles.old.tsx +271 -0
- package/src/Checkbox/Checkbox.styles.tsx +104 -216
- package/src/Checkbox/Checkbox.web.tsx +7 -8
- package/src/Chip/Chip.styles.old.tsx +184 -0
- package/src/Chip/Chip.styles.tsx +34 -72
- package/src/Chip/Chip.web.tsx +3 -5
- package/src/Dialog/Dialog.native.tsx +7 -4
- package/src/Dialog/Dialog.styles.old.tsx +202 -0
- package/src/Dialog/Dialog.styles.tsx +69 -133
- package/src/Dialog/Dialog.web.tsx +3 -3
- package/src/Dialog/types.ts +1 -1
- package/src/Divider/Divider.styles.old.tsx +172 -0
- package/src/Divider/Divider.styles.tsx +62 -84
- package/src/Icon/Icon.native.tsx +8 -8
- package/src/Icon/Icon.styles.old.tsx +81 -0
- package/src/Icon/Icon.styles.tsx +52 -66
- package/src/Icon/Icon.web.tsx +62 -21
- package/src/Icon/IconRegistry.native.ts +41 -0
- package/src/Icon/IconRegistry.ts +107 -0
- package/src/Icon/IconSvg/IconSvg.web.tsx +28 -5
- package/src/Icon/icon-resolver.ts +12 -43
- package/src/Icon/index.native.ts +2 -1
- package/src/Icon/index.ts +1 -0
- package/src/Icon/index.web.ts +1 -0
- package/src/Image/Image.styles.old.tsx +69 -0
- package/src/Image/Image.styles.tsx +46 -60
- package/src/Input/Input.native.tsx +138 -53
- package/src/Input/Input.styles.old.tsx +289 -0
- package/src/Input/Input.styles.tsx +134 -232
- package/src/Input/Input.web.tsx +5 -8
- package/src/List/List.native.tsx +5 -2
- package/src/List/List.styles.old.tsx +242 -0
- package/src/List/List.styles.tsx +179 -215
- package/src/List/ListItem.native.tsx +16 -11
- package/src/List/ListItem.web.tsx +26 -16
- package/src/Menu/Menu.styles.old.tsx +197 -0
- package/src/Menu/Menu.styles.tsx +68 -150
- package/src/Menu/MenuItem.native.tsx +5 -3
- package/src/Menu/MenuItem.styles.old.tsx +114 -0
- package/src/Menu/MenuItem.styles.tsx +57 -89
- package/src/Menu/MenuItem.web.tsx +10 -7
- package/src/Popover/Popover.native.tsx +10 -4
- package/src/Popover/Popover.styles.old.tsx +135 -0
- package/src/Popover/Popover.styles.tsx +51 -112
- package/src/Pressable/Pressable.styles.old.tsx +27 -0
- package/src/Pressable/Pressable.styles.tsx +35 -27
- package/src/Progress/Progress.styles.old.tsx +200 -0
- package/src/Progress/Progress.styles.tsx +75 -164
- package/src/RadioButton/RadioButton.native.tsx +4 -3
- package/src/RadioButton/RadioButton.styles.old.tsx +175 -0
- package/src/RadioButton/RadioButton.styles.tsx +83 -154
- package/src/RadioButton/RadioButton.web.tsx +2 -2
- package/src/SVGImage/SVGImage.styles.old.tsx +86 -0
- package/src/SVGImage/SVGImage.styles.tsx +35 -78
- package/src/Screen/Screen.native.tsx +19 -26
- package/src/Screen/Screen.styles.old.tsx +87 -0
- package/src/Screen/Screen.styles.tsx +103 -68
- package/src/Screen/Screen.web.tsx +2 -2
- package/src/Select/Select.native.tsx +42 -33
- package/src/Select/Select.styles.old.tsx +353 -0
- package/src/Select/Select.styles.tsx +214 -300
- package/src/Select/Select.web.tsx +45 -33
- package/src/Skeleton/Skeleton.styles.old.tsx +67 -0
- package/src/Skeleton/Skeleton.styles.tsx +29 -53
- package/src/Slider/Slider.styles.old.tsx +259 -0
- package/src/Slider/Slider.styles.tsx +153 -234
- package/src/Slider/Slider.web.tsx +2 -4
- package/src/Switch/Switch.native.tsx +9 -7
- package/src/Switch/Switch.styles.old.tsx +203 -0
- package/src/Switch/Switch.styles.tsx +101 -174
- package/src/Switch/Switch.web.tsx +7 -8
- package/src/TabBar/TabBar.native.tsx +3 -2
- package/src/TabBar/TabBar.styles.old.tsx +343 -0
- package/src/TabBar/TabBar.styles.tsx +145 -279
- package/src/Table/Table.native.tsx +180 -68
- package/src/Table/Table.styles.old.tsx +311 -0
- package/src/Table/Table.styles.tsx +140 -281
- package/src/Table/Table.web.tsx +169 -70
- package/src/Text/Text.native.tsx +1 -3
- package/src/Text/Text.style.demo.tsx +16 -0
- package/src/Text/Text.styles.old.tsx +219 -0
- package/src/Text/Text.styles.tsx +94 -84
- package/src/Text/Text.web.tsx +3 -2
- package/src/Text/index.ts +1 -0
- package/src/TextArea/TextArea.native.tsx +21 -8
- package/src/TextArea/TextArea.styles.old.tsx +213 -0
- package/src/TextArea/TextArea.styles.tsx +87 -187
- package/src/TextArea/TextArea.web.tsx +17 -6
- package/src/Tooltip/Tooltip.styles.old.tsx +82 -0
- package/src/Tooltip/Tooltip.styles.tsx +32 -56
- package/src/Video/Video.styles.old.tsx +51 -0
- package/src/Video/Video.styles.tsx +32 -44
- package/src/View/View.native.tsx +41 -13
- package/src/View/View.styles.old.tsx +125 -0
- package/src/View/View.styles.tsx +76 -106
- package/src/View/View.web.tsx +5 -21
- package/src/View/types.ts +31 -3
- package/src/examples/ButtonExamples.tsx +20 -0
- package/src/examples/CardExamples.tsx +0 -6
- package/src/extensions/extendComponent.ts +61 -0
- package/src/index.ts +1 -1
|
@@ -1,9 +1,140 @@
|
|
|
1
|
-
import React, { forwardRef, useMemo } from 'react';
|
|
1
|
+
import React, { forwardRef, useMemo, ReactNode } from 'react';
|
|
2
2
|
import { View, ScrollView, Text, TouchableOpacity } from 'react-native';
|
|
3
3
|
import { tableStyles } from './Table.styles';
|
|
4
|
-
import type { TableProps, TableColumn } from './types';
|
|
4
|
+
import type { TableProps, TableColumn, TableType, TableSizeVariant, TableAlignVariant } from './types';
|
|
5
5
|
import { getNativeAccessibilityProps } from '../utils/accessibility';
|
|
6
6
|
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Sub-component Props
|
|
9
|
+
// ============================================================================
|
|
10
|
+
|
|
11
|
+
interface TRProps {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
size?: TableSizeVariant;
|
|
14
|
+
type?: TableType;
|
|
15
|
+
clickable?: boolean;
|
|
16
|
+
onPress?: () => void;
|
|
17
|
+
testID?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface THProps {
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
size?: TableSizeVariant;
|
|
23
|
+
type?: TableType;
|
|
24
|
+
align?: TableAlignVariant;
|
|
25
|
+
width?: number | string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface TDProps {
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
size?: TableSizeVariant;
|
|
31
|
+
type?: TableType;
|
|
32
|
+
align?: TableAlignVariant;
|
|
33
|
+
width?: number | string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// TR Component
|
|
38
|
+
// ============================================================================
|
|
39
|
+
|
|
40
|
+
function TR({
|
|
41
|
+
children,
|
|
42
|
+
size = 'md',
|
|
43
|
+
type = 'standard',
|
|
44
|
+
clickable = false,
|
|
45
|
+
onPress,
|
|
46
|
+
testID,
|
|
47
|
+
}: TRProps) {
|
|
48
|
+
tableStyles.useVariants({
|
|
49
|
+
size,
|
|
50
|
+
type,
|
|
51
|
+
clickable,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const rowStyle = (tableStyles.row as any)({});
|
|
55
|
+
const RowComponent = clickable ? TouchableOpacity : View;
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<RowComponent
|
|
59
|
+
style={rowStyle}
|
|
60
|
+
onPress={clickable ? onPress : undefined}
|
|
61
|
+
testID={testID}
|
|
62
|
+
>
|
|
63
|
+
<View style={{ flexDirection: 'row' }}>
|
|
64
|
+
{children}
|
|
65
|
+
</View>
|
|
66
|
+
</RowComponent>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ============================================================================
|
|
71
|
+
// TH Component
|
|
72
|
+
// ============================================================================
|
|
73
|
+
|
|
74
|
+
function TH({
|
|
75
|
+
children,
|
|
76
|
+
size = 'md',
|
|
77
|
+
type = 'standard',
|
|
78
|
+
align = 'left',
|
|
79
|
+
width,
|
|
80
|
+
}: THProps) {
|
|
81
|
+
tableStyles.useVariants({
|
|
82
|
+
size,
|
|
83
|
+
type,
|
|
84
|
+
align,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const headerCellStyle = (tableStyles.headerCell as any)({});
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<View
|
|
91
|
+
style={[
|
|
92
|
+
headerCellStyle,
|
|
93
|
+
{ width, flex: width ? undefined : 1 },
|
|
94
|
+
]}
|
|
95
|
+
>
|
|
96
|
+
<Text style={headerCellStyle}>
|
|
97
|
+
{children}
|
|
98
|
+
</Text>
|
|
99
|
+
</View>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ============================================================================
|
|
104
|
+
// TD Component
|
|
105
|
+
// ============================================================================
|
|
106
|
+
|
|
107
|
+
function TD({
|
|
108
|
+
children,
|
|
109
|
+
size = 'md',
|
|
110
|
+
type = 'standard',
|
|
111
|
+
align = 'left',
|
|
112
|
+
width,
|
|
113
|
+
}: TDProps) {
|
|
114
|
+
tableStyles.useVariants({
|
|
115
|
+
size,
|
|
116
|
+
type,
|
|
117
|
+
align,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const cellStyle = (tableStyles.cell as any)({});
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<View
|
|
124
|
+
style={[
|
|
125
|
+
cellStyle,
|
|
126
|
+
{ width, flex: width ? undefined : 1 },
|
|
127
|
+
]}
|
|
128
|
+
>
|
|
129
|
+
{children}
|
|
130
|
+
</View>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ============================================================================
|
|
135
|
+
// Main Table Component
|
|
136
|
+
// ============================================================================
|
|
137
|
+
|
|
7
138
|
function TableInner<T = any>({
|
|
8
139
|
columns,
|
|
9
140
|
data,
|
|
@@ -37,7 +168,8 @@ function TableInner<T = any>({
|
|
|
37
168
|
accessibilityHidden,
|
|
38
169
|
});
|
|
39
170
|
}, [accessibilityLabel, accessibilityHint, accessibilityRole, accessibilityHidden]);
|
|
40
|
-
|
|
171
|
+
|
|
172
|
+
// Apply variants for container
|
|
41
173
|
tableStyles.useVariants({
|
|
42
174
|
type,
|
|
43
175
|
size,
|
|
@@ -50,6 +182,13 @@ function TableInner<T = any>({
|
|
|
50
182
|
marginHorizontal,
|
|
51
183
|
});
|
|
52
184
|
|
|
185
|
+
// Call styles as functions to get theme-reactive styles
|
|
186
|
+
const containerStyle = (tableStyles.container as any)({});
|
|
187
|
+
const tableStyle = (tableStyles.table as any)({});
|
|
188
|
+
const theadStyle = (tableStyles.thead as any)({});
|
|
189
|
+
const tbodyStyle = (tableStyles.tbody as any)({});
|
|
190
|
+
const cellStyle = (tableStyles.cell as any)({});
|
|
191
|
+
|
|
53
192
|
// Helper to get cell value
|
|
54
193
|
const getCellValue = (column: TableColumn<T>, row: T, rowIndex: number) => {
|
|
55
194
|
if (column.render) {
|
|
@@ -57,7 +196,7 @@ function TableInner<T = any>({
|
|
|
57
196
|
return column.render(value, row, rowIndex);
|
|
58
197
|
}
|
|
59
198
|
const value = column.dataIndex ? (row as any)[column.dataIndex] : '';
|
|
60
|
-
return <Text style={
|
|
199
|
+
return <Text style={cellStyle}>{String(value)}</Text>;
|
|
61
200
|
};
|
|
62
201
|
|
|
63
202
|
const isClickable = !!onRowPress;
|
|
@@ -67,79 +206,52 @@ function TableInner<T = any>({
|
|
|
67
206
|
ref={ref}
|
|
68
207
|
nativeID={id}
|
|
69
208
|
horizontal
|
|
70
|
-
style={[
|
|
209
|
+
style={[containerStyle, style]}
|
|
71
210
|
testID={testID}
|
|
72
211
|
{...nativeA11yProps}
|
|
73
212
|
>
|
|
74
|
-
<View style={
|
|
213
|
+
<View style={tableStyle}>
|
|
75
214
|
{/* Header */}
|
|
76
|
-
<View style={
|
|
215
|
+
<View style={theadStyle}>
|
|
77
216
|
<View style={{ flexDirection: 'row' }}>
|
|
78
|
-
{columns.map((column) =>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
type
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
tableStyles.headerCell,
|
|
90
|
-
{ width: column.width, flex: column.width ? undefined : 1 },
|
|
91
|
-
]}
|
|
92
|
-
>
|
|
93
|
-
<Text style={tableStyles.headerCell}>
|
|
94
|
-
{column.title}
|
|
95
|
-
</Text>
|
|
96
|
-
</View>
|
|
97
|
-
);
|
|
98
|
-
})}
|
|
217
|
+
{columns.map((column) => (
|
|
218
|
+
<TH
|
|
219
|
+
key={column.key}
|
|
220
|
+
size={size}
|
|
221
|
+
type={type}
|
|
222
|
+
align={column.align}
|
|
223
|
+
width={column.width}
|
|
224
|
+
>
|
|
225
|
+
{column.title}
|
|
226
|
+
</TH>
|
|
227
|
+
))}
|
|
99
228
|
</View>
|
|
100
229
|
</View>
|
|
101
230
|
|
|
102
231
|
{/* Body */}
|
|
103
|
-
<View style={
|
|
104
|
-
{data.map((row, rowIndex) =>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return (
|
|
128
|
-
<View
|
|
129
|
-
key={column.key}
|
|
130
|
-
style={[
|
|
131
|
-
tableStyles.cell,
|
|
132
|
-
{ width: column.width, flex: column.width ? undefined : 1 },
|
|
133
|
-
]}
|
|
134
|
-
>
|
|
135
|
-
{getCellValue(column, row, rowIndex)}
|
|
136
|
-
</View>
|
|
137
|
-
);
|
|
138
|
-
})}
|
|
139
|
-
</View>
|
|
140
|
-
</RowComponent>
|
|
141
|
-
);
|
|
142
|
-
})}
|
|
232
|
+
<View style={tbodyStyle}>
|
|
233
|
+
{data.map((row, rowIndex) => (
|
|
234
|
+
<TR
|
|
235
|
+
key={rowIndex}
|
|
236
|
+
size={size}
|
|
237
|
+
type={type}
|
|
238
|
+
clickable={isClickable}
|
|
239
|
+
onPress={() => onRowPress?.(row, rowIndex)}
|
|
240
|
+
testID={testID ? `${testID}-row-${rowIndex}` : undefined}
|
|
241
|
+
>
|
|
242
|
+
{columns.map((column) => (
|
|
243
|
+
<TD
|
|
244
|
+
key={column.key}
|
|
245
|
+
size={size}
|
|
246
|
+
type={type}
|
|
247
|
+
align={column.align}
|
|
248
|
+
width={column.width}
|
|
249
|
+
>
|
|
250
|
+
{getCellValue(column, row, rowIndex)}
|
|
251
|
+
</TD>
|
|
252
|
+
))}
|
|
253
|
+
</TR>
|
|
254
|
+
))}
|
|
143
255
|
</View>
|
|
144
256
|
</View>
|
|
145
257
|
</ScrollView>
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
import { Theme, StylesheetStyles, CompoundVariants, Size } from '@idealyst/theme';
|
|
3
|
+
import { buildSizeVariants } from '../utils/buildSizeVariants';
|
|
4
|
+
import {
|
|
5
|
+
buildGapVariants,
|
|
6
|
+
buildPaddingVariants,
|
|
7
|
+
buildPaddingVerticalVariants,
|
|
8
|
+
buildPaddingHorizontalVariants,
|
|
9
|
+
buildMarginVariants,
|
|
10
|
+
buildMarginVerticalVariants,
|
|
11
|
+
buildMarginHorizontalVariants,
|
|
12
|
+
} from '../utils/buildViewStyleVariants';
|
|
13
|
+
import { applyExtensions } from '../extensions/applyExtension';
|
|
14
|
+
|
|
15
|
+
type TableType = 'default' | 'bordered' | 'striped';
|
|
16
|
+
|
|
17
|
+
type TableRowVariants = {
|
|
18
|
+
type: TableType;
|
|
19
|
+
clickable: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create type variants for container
|
|
23
|
+
*/
|
|
24
|
+
function createContainerTypeVariants(theme: Theme) {
|
|
25
|
+
return {
|
|
26
|
+
standard: {
|
|
27
|
+
borderWidth: 1,
|
|
28
|
+
borderStyle: 'solid',
|
|
29
|
+
borderColor: theme.colors.border.primary,
|
|
30
|
+
borderRadius: 8,
|
|
31
|
+
overflow: 'hidden',
|
|
32
|
+
_web: {
|
|
33
|
+
border: `1px solid ${theme.colors.border.primary}`,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
bordered: {
|
|
37
|
+
borderWidth: 1,
|
|
38
|
+
borderStyle: 'solid',
|
|
39
|
+
borderColor: theme.colors.border.primary,
|
|
40
|
+
borderRadius: 8,
|
|
41
|
+
overflow: 'hidden',
|
|
42
|
+
_web: {
|
|
43
|
+
border: `1px solid ${theme.colors.border.primary}`,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
striped: {
|
|
47
|
+
borderWidth: 1,
|
|
48
|
+
borderStyle: 'solid',
|
|
49
|
+
borderColor: theme.colors.border.primary,
|
|
50
|
+
borderRadius: 8,
|
|
51
|
+
overflow: 'hidden',
|
|
52
|
+
_web: {
|
|
53
|
+
border: `1px solid ${theme.colors.border.primary}`,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
} as const;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Create type variants for row
|
|
61
|
+
*/
|
|
62
|
+
function createRowTypeVariants(theme: Theme) {
|
|
63
|
+
return {
|
|
64
|
+
standard: {},
|
|
65
|
+
bordered: {
|
|
66
|
+
borderBottomWidth: 1,
|
|
67
|
+
borderBottomStyle: 'solid',
|
|
68
|
+
borderBottomColor: theme.colors.border.primary,
|
|
69
|
+
_web: {
|
|
70
|
+
borderBottom: `1px solid ${theme.colors.border.primary}`,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
striped: {
|
|
74
|
+
borderBottomWidth: 1,
|
|
75
|
+
borderBottomStyle: 'solid',
|
|
76
|
+
borderBottomColor: theme.colors.border.primary,
|
|
77
|
+
_web: {
|
|
78
|
+
borderBottom: `1px solid ${theme.colors.border.primary}`,
|
|
79
|
+
':nth-child(even)': {
|
|
80
|
+
backgroundColor: theme.colors.surface.secondary,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
} as const;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Create compound variants for row
|
|
89
|
+
*/
|
|
90
|
+
function createRowCompoundVariants(theme: Theme): CompoundVariants<keyof TableRowVariants> {
|
|
91
|
+
return [
|
|
92
|
+
{
|
|
93
|
+
type: 'striped',
|
|
94
|
+
clickable: true,
|
|
95
|
+
styles: {
|
|
96
|
+
_web: {
|
|
97
|
+
_hover: {
|
|
98
|
+
backgroundColor: theme.colors.surface.tertiary,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
] as const;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Create size variants for header cell
|
|
108
|
+
*/
|
|
109
|
+
function createHeaderCellSizeVariants(theme: Theme) {
|
|
110
|
+
return buildSizeVariants(theme, 'table', (size) => ({
|
|
111
|
+
padding: size.padding,
|
|
112
|
+
fontSize: size.fontSize,
|
|
113
|
+
lineHeight: size.lineHeight,
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Create type variants for header cell
|
|
119
|
+
*/
|
|
120
|
+
function createHeaderCellTypeVariants(theme: Theme) {
|
|
121
|
+
return {
|
|
122
|
+
standard: {},
|
|
123
|
+
bordered: {
|
|
124
|
+
borderRightWidth: 1,
|
|
125
|
+
borderRightStyle: 'solid',
|
|
126
|
+
borderRightColor: theme.colors.border.primary,
|
|
127
|
+
_web: {
|
|
128
|
+
borderRight: `1px solid ${theme.colors.border.primary}`,
|
|
129
|
+
':last-child': {
|
|
130
|
+
borderRight: 'none',
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
striped: {},
|
|
135
|
+
} as const;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Create size variants for cell
|
|
140
|
+
*/
|
|
141
|
+
function createCellSizeVariants(theme: Theme) {
|
|
142
|
+
return buildSizeVariants(theme, 'table', (size) => ({
|
|
143
|
+
padding: size.padding,
|
|
144
|
+
fontSize: size.fontSize,
|
|
145
|
+
lineHeight: size.lineHeight,
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Create type variants for cell
|
|
151
|
+
*/
|
|
152
|
+
function createCellTypeVariants(theme: Theme) {
|
|
153
|
+
return {
|
|
154
|
+
standard: {},
|
|
155
|
+
bordered: {
|
|
156
|
+
borderRightWidth: 1,
|
|
157
|
+
borderRightStyle: 'solid',
|
|
158
|
+
borderRightColor: theme.colors.border.primary,
|
|
159
|
+
_web: {
|
|
160
|
+
borderRight: `1px solid ${theme.colors.border.primary}`,
|
|
161
|
+
':last-child': {
|
|
162
|
+
borderRight: 'none',
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
striped: {},
|
|
167
|
+
} as const;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function createContainerStyles(theme: Theme) {
|
|
171
|
+
return () => ({
|
|
172
|
+
width: '100%',
|
|
173
|
+
_web: {
|
|
174
|
+
overflow: 'auto',
|
|
175
|
+
},
|
|
176
|
+
variants: {
|
|
177
|
+
type: createContainerTypeVariants(theme),
|
|
178
|
+
// Spacing variants from ContainerStyleProps
|
|
179
|
+
gap: buildGapVariants(theme),
|
|
180
|
+
padding: buildPaddingVariants(theme),
|
|
181
|
+
paddingVertical: buildPaddingVerticalVariants(theme),
|
|
182
|
+
paddingHorizontal: buildPaddingHorizontalVariants(theme),
|
|
183
|
+
margin: buildMarginVariants(theme),
|
|
184
|
+
marginVertical: buildMarginVerticalVariants(theme),
|
|
185
|
+
marginHorizontal: buildMarginHorizontalVariants(theme),
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const createTableStyles = (theme: Theme) => {
|
|
191
|
+
return {
|
|
192
|
+
width: '100%',
|
|
193
|
+
_web: {
|
|
194
|
+
borderCollapse: 'collapse',
|
|
195
|
+
},
|
|
196
|
+
} as const;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const createTheadStyles = (theme: Theme) => {
|
|
200
|
+
return {
|
|
201
|
+
backgroundColor: theme.colors.surface.secondary,
|
|
202
|
+
variants: {
|
|
203
|
+
sticky: {
|
|
204
|
+
true: {
|
|
205
|
+
_web: {
|
|
206
|
+
position: 'sticky',
|
|
207
|
+
top: 0,
|
|
208
|
+
zIndex: 10,
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
false: {},
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
} as const;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const createRowStyles = (theme: Theme) => {
|
|
218
|
+
return {
|
|
219
|
+
variants: {
|
|
220
|
+
type: createRowTypeVariants(theme),
|
|
221
|
+
clickable: {
|
|
222
|
+
true: {
|
|
223
|
+
_web: {
|
|
224
|
+
cursor: 'pointer',
|
|
225
|
+
_hover: {
|
|
226
|
+
backgroundColor: theme.colors.surface.secondary,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
false: {},
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
compoundVariants: createRowCompoundVariants(theme),
|
|
234
|
+
_web: {
|
|
235
|
+
transition: 'background-color 0.2s ease',
|
|
236
|
+
},
|
|
237
|
+
} as const;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const createHeaderCellStyles = (theme: Theme) => {
|
|
241
|
+
return {
|
|
242
|
+
flexDirection: 'row',
|
|
243
|
+
alignItems: 'center',
|
|
244
|
+
textAlign: 'left',
|
|
245
|
+
fontWeight: '600',
|
|
246
|
+
color: theme.colors.text.primary,
|
|
247
|
+
borderBottomWidth: 2,
|
|
248
|
+
borderBottomStyle: 'solid',
|
|
249
|
+
borderBottomColor: theme.colors.border.primary,
|
|
250
|
+
_web: {
|
|
251
|
+
borderBottom: `2px solid ${theme.colors.border.primary}`,
|
|
252
|
+
},
|
|
253
|
+
variants: {
|
|
254
|
+
size: createHeaderCellSizeVariants(theme),
|
|
255
|
+
align: {
|
|
256
|
+
left: {
|
|
257
|
+
textAlign: 'left',
|
|
258
|
+
justifyContent: 'flex-start',
|
|
259
|
+
},
|
|
260
|
+
center: {
|
|
261
|
+
textAlign: 'center',
|
|
262
|
+
justifyContent: 'center',
|
|
263
|
+
},
|
|
264
|
+
right: {
|
|
265
|
+
textAlign: 'right',
|
|
266
|
+
justifyContent: 'flex-end',
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
type: createHeaderCellTypeVariants(theme),
|
|
270
|
+
},
|
|
271
|
+
} as const;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const createCellStyles = (theme: Theme) => {
|
|
275
|
+
return {
|
|
276
|
+
flexDirection: 'row',
|
|
277
|
+
alignItems: 'center',
|
|
278
|
+
textAlign: 'left',
|
|
279
|
+
color: theme.colors.text.primary,
|
|
280
|
+
variants: {
|
|
281
|
+
size: createCellSizeVariants(theme),
|
|
282
|
+
align: {
|
|
283
|
+
left: {
|
|
284
|
+
textAlign: 'left',
|
|
285
|
+
justifyContent: 'flex-start',
|
|
286
|
+
},
|
|
287
|
+
center: {
|
|
288
|
+
textAlign: 'center',
|
|
289
|
+
justifyContent: 'center',
|
|
290
|
+
},
|
|
291
|
+
right: {
|
|
292
|
+
textAlign: 'right',
|
|
293
|
+
justifyContent: 'flex-end',
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
type: createCellTypeVariants(theme),
|
|
297
|
+
},
|
|
298
|
+
} as const;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export const tableStyles = StyleSheet.create((theme: Theme) => {
|
|
302
|
+
return applyExtensions('Table', theme, {
|
|
303
|
+
container: createContainerStyles(theme),
|
|
304
|
+
table: createTableStyles(theme),
|
|
305
|
+
thead: createTheadStyles(theme),
|
|
306
|
+
tbody: {},
|
|
307
|
+
row: createRowStyles(theme),
|
|
308
|
+
headerCell: createHeaderCellStyles(theme),
|
|
309
|
+
cell: createCellStyles(theme),
|
|
310
|
+
});
|
|
311
|
+
});
|