@draftbit/core 46.8.1-1b6459.2 → 46.8.1-61264d.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/lib/commonjs/components/Checkbox/CheckboxGroupRow.js +5 -23
- package/lib/commonjs/components/Checkbox/CheckboxRow.js +6 -23
- package/lib/commonjs/components/Checkbox/context.js +1 -1
- package/lib/commonjs/components/CircleImage.js +1 -15
- package/lib/commonjs/components/CircularProgress.js +8 -26
- package/lib/commonjs/components/Container.js +4 -15
- package/lib/commonjs/components/DeprecatedButton.js +3 -20
- package/lib/commonjs/components/DeprecatedCardWrapper.js +1 -15
- package/lib/commonjs/components/Divider.js +1 -14
- package/lib/commonjs/components/Elevation.js +2 -14
- package/lib/commonjs/components/FAB.js +4 -18
- package/lib/commonjs/components/Picker/PickerComponent.android.js +20 -3
- package/lib/commonjs/components/Portal/PortalHost.js +15 -44
- package/lib/commonjs/components/Portal/PortalManager.js +8 -34
- package/lib/commonjs/components/ProgressBar.js +7 -37
- package/lib/commonjs/components/RadioButton/RadioButton.js +2 -13
- package/lib/commonjs/components/RadioButton/RadioButtonGroup.js +2 -15
- package/lib/commonjs/components/Table/Table.js +65 -0
- package/lib/commonjs/components/Table/TableCell.js +48 -0
- package/lib/commonjs/components/Table/TableCommon.js +25 -0
- package/lib/commonjs/components/Table/TableRow.js +63 -0
- package/lib/commonjs/components/Table/index.js +27 -0
- package/lib/commonjs/index.js +19 -0
- package/lib/commonjs/mappings/Table.js +143 -0
- package/lib/module/components/Table/Table.js +57 -0
- package/lib/module/components/Table/TableCell.js +40 -0
- package/lib/module/components/Table/TableCommon.js +19 -0
- package/lib/module/components/Table/TableRow.js +55 -0
- package/lib/module/components/Table/index.js +3 -0
- package/lib/module/index.js +1 -0
- package/lib/module/mappings/Table.js +136 -0
- package/lib/typescript/src/components/Table/Table.d.ts +15 -0
- package/lib/typescript/src/components/Table/Table.d.ts.map +1 -0
- package/lib/typescript/src/components/Table/TableCell.d.ts +11 -0
- package/lib/typescript/src/components/Table/TableCell.d.ts.map +1 -0
- package/lib/typescript/src/components/Table/TableCommon.d.ts +14 -0
- package/lib/typescript/src/components/Table/TableCommon.d.ts.map +1 -0
- package/lib/typescript/src/components/Table/TableRow.d.ts +11 -0
- package/lib/typescript/src/components/Table/TableRow.d.ts.map +1 -0
- package/lib/typescript/src/components/Table/index.d.ts +4 -0
- package/lib/typescript/src/components/Table/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mappings/Table.d.ts +314 -0
- package/lib/typescript/src/mappings/Table.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/components/Table/Table.js +46 -0
- package/src/components/Table/Table.tsx +83 -0
- package/src/components/Table/TableCell.js +30 -0
- package/src/components/Table/TableCell.tsx +57 -0
- package/src/components/Table/TableCommon.js +10 -0
- package/src/components/Table/TableCommon.ts +32 -0
- package/src/components/Table/TableRow.js +45 -0
- package/src/components/Table/TableRow.tsx +77 -0
- package/src/components/Table/index.js +3 -0
- package/src/components/Table/index.tsx +3 -0
- package/src/index.js +1 -0
- package/src/index.tsx +2 -0
- package/src/mappings/Table.js +137 -0
- package/src/mappings/Table.ts +161 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
export declare const SEED_DATA: ({
|
|
2
|
+
name: string;
|
|
3
|
+
tag: string;
|
|
4
|
+
description: string;
|
|
5
|
+
category: string;
|
|
6
|
+
stylesPanelSections: string[];
|
|
7
|
+
props: {
|
|
8
|
+
borderWidth: {
|
|
9
|
+
defaultValue: number;
|
|
10
|
+
label: string;
|
|
11
|
+
description: string;
|
|
12
|
+
formType: string;
|
|
13
|
+
propType: string;
|
|
14
|
+
group: string;
|
|
15
|
+
editable: boolean;
|
|
16
|
+
required: boolean;
|
|
17
|
+
step: number;
|
|
18
|
+
};
|
|
19
|
+
borderColor: {
|
|
20
|
+
defaultValue: string;
|
|
21
|
+
group: string;
|
|
22
|
+
label: string;
|
|
23
|
+
description: string;
|
|
24
|
+
editable: boolean;
|
|
25
|
+
required: boolean;
|
|
26
|
+
formType: string;
|
|
27
|
+
propType: string;
|
|
28
|
+
};
|
|
29
|
+
borderStyle: {
|
|
30
|
+
defaultValue: string;
|
|
31
|
+
group: string;
|
|
32
|
+
label: string;
|
|
33
|
+
description: string;
|
|
34
|
+
editable: boolean;
|
|
35
|
+
required: boolean;
|
|
36
|
+
formType: string;
|
|
37
|
+
propType: string;
|
|
38
|
+
options: never[];
|
|
39
|
+
};
|
|
40
|
+
drawTopBorder: {
|
|
41
|
+
defaultValue: boolean;
|
|
42
|
+
label: string;
|
|
43
|
+
description: string;
|
|
44
|
+
formType: string;
|
|
45
|
+
propType: string;
|
|
46
|
+
editable: boolean;
|
|
47
|
+
required: boolean;
|
|
48
|
+
group: string;
|
|
49
|
+
};
|
|
50
|
+
cellVerticalPadding: {
|
|
51
|
+
label: string;
|
|
52
|
+
description: string;
|
|
53
|
+
formType: string;
|
|
54
|
+
propType: string;
|
|
55
|
+
group: string;
|
|
56
|
+
defaultValue: null;
|
|
57
|
+
editable: boolean;
|
|
58
|
+
required: boolean;
|
|
59
|
+
step: number;
|
|
60
|
+
};
|
|
61
|
+
callHorizontalPadding: {
|
|
62
|
+
label: string;
|
|
63
|
+
description: string;
|
|
64
|
+
formType: string;
|
|
65
|
+
propType: string;
|
|
66
|
+
group: string;
|
|
67
|
+
defaultValue: null;
|
|
68
|
+
editable: boolean;
|
|
69
|
+
required: boolean;
|
|
70
|
+
step: number;
|
|
71
|
+
};
|
|
72
|
+
drawBottomBorder: {
|
|
73
|
+
label: string;
|
|
74
|
+
description: string;
|
|
75
|
+
formType: string;
|
|
76
|
+
propType: string;
|
|
77
|
+
defaultValue: boolean;
|
|
78
|
+
editable: boolean;
|
|
79
|
+
required: boolean;
|
|
80
|
+
group: string;
|
|
81
|
+
};
|
|
82
|
+
drawStartBorder: {
|
|
83
|
+
label: string;
|
|
84
|
+
description: string;
|
|
85
|
+
formType: string;
|
|
86
|
+
propType: string;
|
|
87
|
+
defaultValue: boolean;
|
|
88
|
+
editable: boolean;
|
|
89
|
+
required: boolean;
|
|
90
|
+
group: string;
|
|
91
|
+
};
|
|
92
|
+
drawEndBorder: {
|
|
93
|
+
label: string;
|
|
94
|
+
description: string;
|
|
95
|
+
formType: string;
|
|
96
|
+
propType: string;
|
|
97
|
+
defaultValue: boolean;
|
|
98
|
+
editable: boolean;
|
|
99
|
+
required: boolean;
|
|
100
|
+
group: string;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
layout?: undefined;
|
|
104
|
+
} | {
|
|
105
|
+
name: string;
|
|
106
|
+
tag: string;
|
|
107
|
+
description: string;
|
|
108
|
+
category: string;
|
|
109
|
+
stylesPanelSections: string[];
|
|
110
|
+
props: {
|
|
111
|
+
drawStartBorder: {
|
|
112
|
+
defaultValue: boolean;
|
|
113
|
+
label: string;
|
|
114
|
+
description: string;
|
|
115
|
+
formType: string;
|
|
116
|
+
propType: string;
|
|
117
|
+
editable: boolean;
|
|
118
|
+
required: boolean;
|
|
119
|
+
group: string;
|
|
120
|
+
};
|
|
121
|
+
drawBottomBorder: {
|
|
122
|
+
defaultValue: boolean;
|
|
123
|
+
label: string;
|
|
124
|
+
description: string;
|
|
125
|
+
formType: string;
|
|
126
|
+
propType: string;
|
|
127
|
+
editable: boolean;
|
|
128
|
+
required: boolean;
|
|
129
|
+
group: string;
|
|
130
|
+
};
|
|
131
|
+
cellVerticalPadding: {
|
|
132
|
+
label: string;
|
|
133
|
+
description: string;
|
|
134
|
+
formType: string;
|
|
135
|
+
propType: string;
|
|
136
|
+
group: string;
|
|
137
|
+
defaultValue: null;
|
|
138
|
+
editable: boolean;
|
|
139
|
+
required: boolean;
|
|
140
|
+
step: number;
|
|
141
|
+
};
|
|
142
|
+
callHorizontalPadding: {
|
|
143
|
+
label: string;
|
|
144
|
+
description: string;
|
|
145
|
+
formType: string;
|
|
146
|
+
propType: string;
|
|
147
|
+
group: string;
|
|
148
|
+
defaultValue: null;
|
|
149
|
+
editable: boolean;
|
|
150
|
+
required: boolean;
|
|
151
|
+
step: number;
|
|
152
|
+
};
|
|
153
|
+
borderWidth: {
|
|
154
|
+
label: string;
|
|
155
|
+
description: string;
|
|
156
|
+
formType: string;
|
|
157
|
+
propType: string;
|
|
158
|
+
group: string;
|
|
159
|
+
defaultValue: null;
|
|
160
|
+
editable: boolean;
|
|
161
|
+
required: boolean;
|
|
162
|
+
step: number;
|
|
163
|
+
};
|
|
164
|
+
borderColor: {
|
|
165
|
+
group: string;
|
|
166
|
+
label: string;
|
|
167
|
+
description: string;
|
|
168
|
+
editable: boolean;
|
|
169
|
+
required: boolean;
|
|
170
|
+
defaultValue: null;
|
|
171
|
+
formType: string;
|
|
172
|
+
propType: string;
|
|
173
|
+
};
|
|
174
|
+
borderStyle: {
|
|
175
|
+
group: string;
|
|
176
|
+
label: string;
|
|
177
|
+
description: string;
|
|
178
|
+
editable: boolean;
|
|
179
|
+
required: boolean;
|
|
180
|
+
formType: string;
|
|
181
|
+
propType: string;
|
|
182
|
+
defaultValue: null;
|
|
183
|
+
options: never[];
|
|
184
|
+
};
|
|
185
|
+
drawTopBorder: {
|
|
186
|
+
label: string;
|
|
187
|
+
description: string;
|
|
188
|
+
formType: string;
|
|
189
|
+
propType: string;
|
|
190
|
+
defaultValue: boolean;
|
|
191
|
+
editable: boolean;
|
|
192
|
+
required: boolean;
|
|
193
|
+
group: string;
|
|
194
|
+
};
|
|
195
|
+
drawEndBorder: {
|
|
196
|
+
label: string;
|
|
197
|
+
description: string;
|
|
198
|
+
formType: string;
|
|
199
|
+
propType: string;
|
|
200
|
+
defaultValue: boolean;
|
|
201
|
+
editable: boolean;
|
|
202
|
+
required: boolean;
|
|
203
|
+
group: string;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
layout?: undefined;
|
|
207
|
+
} | {
|
|
208
|
+
name: string;
|
|
209
|
+
tag: string;
|
|
210
|
+
description: string;
|
|
211
|
+
category: string;
|
|
212
|
+
stylesPanelSections: string[];
|
|
213
|
+
layout: {
|
|
214
|
+
flex: number;
|
|
215
|
+
flexDirection: string;
|
|
216
|
+
};
|
|
217
|
+
props: {
|
|
218
|
+
drawEndBorder: {
|
|
219
|
+
defaultValue: boolean;
|
|
220
|
+
label: string;
|
|
221
|
+
description: string;
|
|
222
|
+
formType: string;
|
|
223
|
+
propType: string;
|
|
224
|
+
editable: boolean;
|
|
225
|
+
required: boolean;
|
|
226
|
+
group: string;
|
|
227
|
+
};
|
|
228
|
+
verticalPadding: {
|
|
229
|
+
label: string;
|
|
230
|
+
description: string;
|
|
231
|
+
formType: string;
|
|
232
|
+
propType: string;
|
|
233
|
+
group: string;
|
|
234
|
+
defaultValue: null;
|
|
235
|
+
editable: boolean;
|
|
236
|
+
required: boolean;
|
|
237
|
+
step: number;
|
|
238
|
+
};
|
|
239
|
+
horizontalPadding: {
|
|
240
|
+
label: string;
|
|
241
|
+
description: string;
|
|
242
|
+
formType: string;
|
|
243
|
+
propType: string;
|
|
244
|
+
group: string;
|
|
245
|
+
defaultValue: null;
|
|
246
|
+
editable: boolean;
|
|
247
|
+
required: boolean;
|
|
248
|
+
step: number;
|
|
249
|
+
};
|
|
250
|
+
borderWidth: {
|
|
251
|
+
label: string;
|
|
252
|
+
description: string;
|
|
253
|
+
formType: string;
|
|
254
|
+
propType: string;
|
|
255
|
+
group: string;
|
|
256
|
+
defaultValue: null;
|
|
257
|
+
editable: boolean;
|
|
258
|
+
required: boolean;
|
|
259
|
+
step: number;
|
|
260
|
+
};
|
|
261
|
+
borderColor: {
|
|
262
|
+
group: string;
|
|
263
|
+
label: string;
|
|
264
|
+
description: string;
|
|
265
|
+
editable: boolean;
|
|
266
|
+
required: boolean;
|
|
267
|
+
defaultValue: null;
|
|
268
|
+
formType: string;
|
|
269
|
+
propType: string;
|
|
270
|
+
};
|
|
271
|
+
borderStyle: {
|
|
272
|
+
group: string;
|
|
273
|
+
label: string;
|
|
274
|
+
description: string;
|
|
275
|
+
editable: boolean;
|
|
276
|
+
required: boolean;
|
|
277
|
+
formType: string;
|
|
278
|
+
propType: string;
|
|
279
|
+
defaultValue: null;
|
|
280
|
+
options: never[];
|
|
281
|
+
};
|
|
282
|
+
drawTopBorder: {
|
|
283
|
+
label: string;
|
|
284
|
+
description: string;
|
|
285
|
+
formType: string;
|
|
286
|
+
propType: string;
|
|
287
|
+
defaultValue: boolean;
|
|
288
|
+
editable: boolean;
|
|
289
|
+
required: boolean;
|
|
290
|
+
group: string;
|
|
291
|
+
};
|
|
292
|
+
drawBottomBorder: {
|
|
293
|
+
label: string;
|
|
294
|
+
description: string;
|
|
295
|
+
formType: string;
|
|
296
|
+
propType: string;
|
|
297
|
+
defaultValue: boolean;
|
|
298
|
+
editable: boolean;
|
|
299
|
+
required: boolean;
|
|
300
|
+
group: string;
|
|
301
|
+
};
|
|
302
|
+
drawStartBorder: {
|
|
303
|
+
label: string;
|
|
304
|
+
description: string;
|
|
305
|
+
formType: string;
|
|
306
|
+
propType: string;
|
|
307
|
+
defaultValue: boolean;
|
|
308
|
+
editable: boolean;
|
|
309
|
+
required: boolean;
|
|
310
|
+
group: string;
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
})[];
|
|
314
|
+
//# sourceMappingURL=Table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/mappings/Table.ts"],"names":[],"mappings":"AA0DA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsGrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "46.8.1-
|
|
3
|
+
"version": "46.8.1-61264d.2+61264d3",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@date-io/date-fns": "^1.3.13",
|
|
43
43
|
"@draftbit/react-theme-provider": "^2.1.1",
|
|
44
|
-
"@draftbit/types": "^46.8.1-
|
|
44
|
+
"@draftbit/types": "^46.8.1-61264d.2+61264d3",
|
|
45
45
|
"@material-ui/core": "^4.11.0",
|
|
46
46
|
"@material-ui/pickers": "^3.2.10",
|
|
47
47
|
"@react-native-community/slider": "4.2.3",
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
]
|
|
93
93
|
]
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "61264d30c8d88a2b2f3ef07bd44d44f682b838d4"
|
|
96
96
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import { withTheme } from "../../theming";
|
|
4
|
+
import { generateBorderStyles } from "./TableCommon";
|
|
5
|
+
import TableRow from "./TableRow";
|
|
6
|
+
const Table = ({ theme, borderWidth = 1, borderColor = theme.colors.divider, borderStyle = "solid", drawTopBorder = true, drawBottomBorder = false, drawStartBorder = false, drawEndBorder = false, cellVerticalPadding = 10, callHorizontalPadding = 10, children, style, }) => {
|
|
7
|
+
//Populate each TableRow props with default values provided here
|
|
8
|
+
const populatedTableRows = React.useMemo(() => React.Children.map(children, (child) => {
|
|
9
|
+
if (React.isValidElement(child) && child.type === TableRow) {
|
|
10
|
+
const oldProps = { ...child.props };
|
|
11
|
+
const newProps = {
|
|
12
|
+
cellVerticalPadding: oldProps.cellVerticalPadding || cellVerticalPadding,
|
|
13
|
+
callHorizontalPadding: oldProps.callHorizontalPadding || callHorizontalPadding,
|
|
14
|
+
borderWidth: oldProps.borderWidth || borderWidth,
|
|
15
|
+
borderColor: oldProps.borderColor || borderColor,
|
|
16
|
+
borderStyle: oldProps.borderStyle || borderStyle,
|
|
17
|
+
};
|
|
18
|
+
return React.cloneElement(child, newProps);
|
|
19
|
+
}
|
|
20
|
+
return child;
|
|
21
|
+
}), [
|
|
22
|
+
children,
|
|
23
|
+
borderColor,
|
|
24
|
+
borderWidth,
|
|
25
|
+
borderStyle,
|
|
26
|
+
cellVerticalPadding,
|
|
27
|
+
callHorizontalPadding,
|
|
28
|
+
]);
|
|
29
|
+
const borderViewStyle = generateBorderStyles({
|
|
30
|
+
borderColor,
|
|
31
|
+
borderWidth,
|
|
32
|
+
borderStyle,
|
|
33
|
+
drawTopBorder,
|
|
34
|
+
drawBottomBorder,
|
|
35
|
+
drawStartBorder,
|
|
36
|
+
drawEndBorder,
|
|
37
|
+
});
|
|
38
|
+
return (React.createElement(View, { style: [styles.container, borderViewStyle, style] }, populatedTableRows));
|
|
39
|
+
};
|
|
40
|
+
const styles = StyleSheet.create({
|
|
41
|
+
container: {
|
|
42
|
+
display: "flex",
|
|
43
|
+
flexDirection: "column",
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
export default withTheme(Table);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleProp, ViewStyle, StyleSheet } from "react-native";
|
|
3
|
+
import { Theme } from "../../styles/DefaultTheme";
|
|
4
|
+
import { withTheme } from "../../theming";
|
|
5
|
+
import { generateBorderStyles, TableBorderProps } from "./TableCommon";
|
|
6
|
+
import TableRow, { TableRowProps } from "./TableRow";
|
|
7
|
+
|
|
8
|
+
export interface TableProps extends TableBorderProps {
|
|
9
|
+
cellVerticalPadding?: number;
|
|
10
|
+
callHorizontalPadding?: number;
|
|
11
|
+
style?: StyleProp<ViewStyle>;
|
|
12
|
+
theme: Theme;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const Table: React.FC<React.PropsWithChildren<TableProps>> = ({
|
|
16
|
+
theme,
|
|
17
|
+
borderWidth = 1,
|
|
18
|
+
borderColor = theme.colors.divider,
|
|
19
|
+
borderStyle = "solid",
|
|
20
|
+
drawTopBorder = true,
|
|
21
|
+
drawBottomBorder = false,
|
|
22
|
+
drawStartBorder = false,
|
|
23
|
+
drawEndBorder = false,
|
|
24
|
+
cellVerticalPadding = 10,
|
|
25
|
+
callHorizontalPadding = 10,
|
|
26
|
+
children,
|
|
27
|
+
style,
|
|
28
|
+
}) => {
|
|
29
|
+
//Populate each TableRow props with default values provided here
|
|
30
|
+
const populatedTableRows = React.useMemo(
|
|
31
|
+
() =>
|
|
32
|
+
React.Children.map(children, (child) => {
|
|
33
|
+
if (React.isValidElement(child) && child.type === TableRow) {
|
|
34
|
+
const oldProps = { ...(child.props as TableRowProps) };
|
|
35
|
+
const newProps: TableRowProps = {
|
|
36
|
+
cellVerticalPadding:
|
|
37
|
+
oldProps.cellVerticalPadding || cellVerticalPadding,
|
|
38
|
+
callHorizontalPadding:
|
|
39
|
+
oldProps.callHorizontalPadding || callHorizontalPadding,
|
|
40
|
+
borderWidth: oldProps.borderWidth || borderWidth,
|
|
41
|
+
borderColor: oldProps.borderColor || borderColor,
|
|
42
|
+
borderStyle: oldProps.borderStyle || borderStyle,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return React.cloneElement(child, newProps);
|
|
46
|
+
}
|
|
47
|
+
return child;
|
|
48
|
+
}),
|
|
49
|
+
[
|
|
50
|
+
children,
|
|
51
|
+
borderColor,
|
|
52
|
+
borderWidth,
|
|
53
|
+
borderStyle,
|
|
54
|
+
cellVerticalPadding,
|
|
55
|
+
callHorizontalPadding,
|
|
56
|
+
]
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const borderViewStyle = generateBorderStyles({
|
|
60
|
+
borderColor,
|
|
61
|
+
borderWidth,
|
|
62
|
+
borderStyle,
|
|
63
|
+
drawTopBorder,
|
|
64
|
+
drawBottomBorder,
|
|
65
|
+
drawStartBorder,
|
|
66
|
+
drawEndBorder,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<View style={[styles.container, borderViewStyle, style]}>
|
|
71
|
+
{populatedTableRows}
|
|
72
|
+
</View>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const styles = StyleSheet.create({
|
|
77
|
+
container: {
|
|
78
|
+
display: "flex",
|
|
79
|
+
flexDirection: "column",
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export default withTheme(Table);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import { generateBorderStyles } from "./TableCommon";
|
|
4
|
+
const TableCell = ({ borderWidth, borderColor, borderStyle, drawTopBorder = false, drawBottomBorder = false, drawStartBorder = false, drawEndBorder = true, verticalPadding, horizontalPadding, children, style, }) => {
|
|
5
|
+
const borderViewStyle = generateBorderStyles({
|
|
6
|
+
borderColor,
|
|
7
|
+
borderWidth,
|
|
8
|
+
borderStyle,
|
|
9
|
+
drawTopBorder,
|
|
10
|
+
drawBottomBorder,
|
|
11
|
+
drawStartBorder,
|
|
12
|
+
drawEndBorder,
|
|
13
|
+
});
|
|
14
|
+
return (React.createElement(View, { style: [
|
|
15
|
+
styles.cellContainer,
|
|
16
|
+
borderViewStyle,
|
|
17
|
+
{
|
|
18
|
+
paddingVertical: verticalPadding,
|
|
19
|
+
paddingHorizontal: horizontalPadding,
|
|
20
|
+
},
|
|
21
|
+
style,
|
|
22
|
+
] }, children));
|
|
23
|
+
};
|
|
24
|
+
const styles = StyleSheet.create({
|
|
25
|
+
cellContainer: {
|
|
26
|
+
flex: 1,
|
|
27
|
+
flexDirection: "row",
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
export default TableCell;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleProp, ViewStyle, StyleSheet } from "react-native";
|
|
3
|
+
import { generateBorderStyles, TableBorderProps } from "./TableCommon";
|
|
4
|
+
|
|
5
|
+
export interface TableCellProps extends TableBorderProps {
|
|
6
|
+
verticalPadding?: number;
|
|
7
|
+
horizontalPadding?: number;
|
|
8
|
+
style?: StyleProp<ViewStyle>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const TableCell: React.FC<React.PropsWithChildren<TableCellProps>> = ({
|
|
12
|
+
borderWidth,
|
|
13
|
+
borderColor,
|
|
14
|
+
borderStyle,
|
|
15
|
+
drawTopBorder = false,
|
|
16
|
+
drawBottomBorder = false,
|
|
17
|
+
drawStartBorder = false,
|
|
18
|
+
drawEndBorder = true,
|
|
19
|
+
verticalPadding,
|
|
20
|
+
horizontalPadding,
|
|
21
|
+
children,
|
|
22
|
+
style,
|
|
23
|
+
}) => {
|
|
24
|
+
const borderViewStyle = generateBorderStyles({
|
|
25
|
+
borderColor,
|
|
26
|
+
borderWidth,
|
|
27
|
+
borderStyle,
|
|
28
|
+
drawTopBorder,
|
|
29
|
+
drawBottomBorder,
|
|
30
|
+
drawStartBorder,
|
|
31
|
+
drawEndBorder,
|
|
32
|
+
});
|
|
33
|
+
return (
|
|
34
|
+
<View
|
|
35
|
+
style={[
|
|
36
|
+
styles.cellContainer,
|
|
37
|
+
borderViewStyle,
|
|
38
|
+
{
|
|
39
|
+
paddingVertical: verticalPadding,
|
|
40
|
+
paddingHorizontal: horizontalPadding,
|
|
41
|
+
},
|
|
42
|
+
style,
|
|
43
|
+
]}
|
|
44
|
+
>
|
|
45
|
+
{children}
|
|
46
|
+
</View>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const styles = StyleSheet.create({
|
|
51
|
+
cellContainer: {
|
|
52
|
+
flex: 1,
|
|
53
|
+
flexDirection: "row",
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export default TableCell;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function generateBorderStyles({ borderColor, borderWidth, borderStyle, drawTopBorder, drawBottomBorder, drawStartBorder, drawEndBorder, }) {
|
|
2
|
+
return {
|
|
3
|
+
borderColor,
|
|
4
|
+
borderStyle,
|
|
5
|
+
borderTopWidth: drawTopBorder ? borderWidth : 0,
|
|
6
|
+
borderBottomWidth: drawBottomBorder ? borderWidth : 0,
|
|
7
|
+
borderStartWidth: drawStartBorder ? borderWidth : 0,
|
|
8
|
+
borderEndWidth: drawEndBorder ? borderWidth : 0,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ViewStyle } from "react-native";
|
|
2
|
+
|
|
3
|
+
type BorderStyle = "solid" | "dotted" | "dashed";
|
|
4
|
+
|
|
5
|
+
export interface TableBorderProps {
|
|
6
|
+
borderWidth?: number;
|
|
7
|
+
borderColor?: string;
|
|
8
|
+
borderStyle?: BorderStyle;
|
|
9
|
+
drawTopBorder?: boolean;
|
|
10
|
+
drawBottomBorder?: boolean;
|
|
11
|
+
drawStartBorder?: boolean;
|
|
12
|
+
drawEndBorder?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function generateBorderStyles({
|
|
16
|
+
borderColor,
|
|
17
|
+
borderWidth,
|
|
18
|
+
borderStyle,
|
|
19
|
+
drawTopBorder,
|
|
20
|
+
drawBottomBorder,
|
|
21
|
+
drawStartBorder,
|
|
22
|
+
drawEndBorder,
|
|
23
|
+
}: TableBorderProps): ViewStyle {
|
|
24
|
+
return {
|
|
25
|
+
borderColor,
|
|
26
|
+
borderStyle,
|
|
27
|
+
borderTopWidth: drawTopBorder ? borderWidth : 0,
|
|
28
|
+
borderBottomWidth: drawBottomBorder ? borderWidth : 0,
|
|
29
|
+
borderStartWidth: drawStartBorder ? borderWidth : 0,
|
|
30
|
+
borderEndWidth: drawEndBorder ? borderWidth : 0,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import { generateBorderStyles } from "./TableCommon";
|
|
4
|
+
import TableCell from "./TableCell";
|
|
5
|
+
const TableRow = ({ borderWidth, borderColor, borderStyle, drawTopBorder = false, drawBottomBorder = true, drawStartBorder = true, drawEndBorder = false, cellVerticalPadding, callHorizontalPadding, children, style, }) => {
|
|
6
|
+
//Populate each TableCell props with default values provided here
|
|
7
|
+
const populatedTableCells = React.useMemo(() => React.Children.map(children, (child) => {
|
|
8
|
+
if (React.isValidElement(child) && child.type === TableCell) {
|
|
9
|
+
const oldProps = { ...child.props };
|
|
10
|
+
const newProps = {
|
|
11
|
+
verticalPadding: oldProps.verticalPadding || cellVerticalPadding,
|
|
12
|
+
horizontalPadding: oldProps.horizontalPadding || callHorizontalPadding,
|
|
13
|
+
borderWidth: oldProps.borderWidth || borderWidth,
|
|
14
|
+
borderColor: oldProps.borderColor || borderColor,
|
|
15
|
+
borderStyle: oldProps.borderStyle || borderStyle,
|
|
16
|
+
};
|
|
17
|
+
return React.cloneElement(child, newProps);
|
|
18
|
+
}
|
|
19
|
+
return child;
|
|
20
|
+
}), [
|
|
21
|
+
children,
|
|
22
|
+
borderColor,
|
|
23
|
+
borderWidth,
|
|
24
|
+
borderStyle,
|
|
25
|
+
cellVerticalPadding,
|
|
26
|
+
callHorizontalPadding,
|
|
27
|
+
]);
|
|
28
|
+
const borderViewStyle = generateBorderStyles({
|
|
29
|
+
borderColor,
|
|
30
|
+
borderWidth,
|
|
31
|
+
borderStyle,
|
|
32
|
+
drawTopBorder,
|
|
33
|
+
drawBottomBorder,
|
|
34
|
+
drawStartBorder,
|
|
35
|
+
drawEndBorder,
|
|
36
|
+
});
|
|
37
|
+
return (React.createElement(View, { style: [borderViewStyle, style, styles.cellsContainer] }, populatedTableCells));
|
|
38
|
+
};
|
|
39
|
+
const styles = StyleSheet.create({
|
|
40
|
+
cellsContainer: {
|
|
41
|
+
flex: 1,
|
|
42
|
+
flexDirection: "row",
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
export default TableRow;
|