@draftbit/core 46.9.1-258aa2.2 → 46.9.1-2a60b8.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.
Files changed (58) hide show
  1. package/lib/commonjs/components/Container.js +4 -15
  2. package/lib/commonjs/components/YotubePlayer.js +38 -0
  3. package/lib/commonjs/constants.js +1 -1
  4. package/lib/commonjs/index.js +7 -19
  5. package/lib/commonjs/mappings/YoutubePlayer.js +44 -0
  6. package/lib/module/components/Accordion/AccordionItem.js +25 -4
  7. package/lib/module/components/YotubePlayer.js +30 -0
  8. package/lib/module/index.js +1 -1
  9. package/lib/module/mappings/YoutubePlayer.js +37 -0
  10. package/lib/typescript/src/components/YotubePlayer.d.ts +12 -0
  11. package/lib/typescript/src/components/YotubePlayer.d.ts.map +1 -0
  12. package/lib/typescript/src/index.d.ts +1 -1
  13. package/lib/typescript/src/index.d.ts.map +1 -1
  14. package/lib/typescript/src/mappings/YoutubePlayer.d.ts +37 -0
  15. package/lib/typescript/src/mappings/YoutubePlayer.d.ts.map +1 -0
  16. package/package.json +6 -4
  17. package/src/components/YotubePlayer.js +10 -0
  18. package/src/components/YotubePlayer.tsx +38 -0
  19. package/src/index.js +1 -1
  20. package/src/index.tsx +1 -1
  21. package/src/mappings/YoutubePlayer.js +37 -0
  22. package/src/mappings/YoutubePlayer.ts +43 -0
  23. package/lib/commonjs/components/Table/Table.js +0 -91
  24. package/lib/commonjs/components/Table/TableCell.js +0 -49
  25. package/lib/commonjs/components/Table/TableCommon.js +0 -30
  26. package/lib/commonjs/components/Table/TableRow.js +0 -61
  27. package/lib/commonjs/components/Table/index.js +0 -27
  28. package/lib/commonjs/mappings/Table.js +0 -135
  29. package/lib/module/components/Table/Table.js +0 -83
  30. package/lib/module/components/Table/TableCell.js +0 -41
  31. package/lib/module/components/Table/TableCommon.js +0 -21
  32. package/lib/module/components/Table/TableRow.js +0 -53
  33. package/lib/module/components/Table/index.js +0 -3
  34. package/lib/module/mappings/Table.js +0 -128
  35. package/lib/typescript/src/components/Table/Table.d.ts +0 -19
  36. package/lib/typescript/src/components/Table/Table.d.ts.map +0 -1
  37. package/lib/typescript/src/components/Table/TableCell.d.ts +0 -9
  38. package/lib/typescript/src/components/Table/TableCell.d.ts.map +0 -1
  39. package/lib/typescript/src/components/Table/TableCommon.d.ts +0 -20
  40. package/lib/typescript/src/components/Table/TableCommon.d.ts.map +0 -1
  41. package/lib/typescript/src/components/Table/TableRow.d.ts +0 -14
  42. package/lib/typescript/src/components/Table/TableRow.d.ts.map +0 -1
  43. package/lib/typescript/src/components/Table/index.d.ts +0 -4
  44. package/lib/typescript/src/components/Table/index.d.ts.map +0 -1
  45. package/lib/typescript/src/mappings/Table.d.ts +0 -327
  46. package/lib/typescript/src/mappings/Table.d.ts.map +0 -1
  47. package/src/components/Table/Table.js +0 -64
  48. package/src/components/Table/Table.tsx +0 -136
  49. package/src/components/Table/TableCell.js +0 -31
  50. package/src/components/Table/TableCell.tsx +0 -63
  51. package/src/components/Table/TableCommon.js +0 -12
  52. package/src/components/Table/TableCommon.ts +0 -40
  53. package/src/components/Table/TableRow.js +0 -37
  54. package/src/components/Table/TableRow.tsx +0 -77
  55. package/src/components/Table/index.js +0 -3
  56. package/src/components/Table/index.tsx +0 -3
  57. package/src/mappings/Table.js +0 -145
  58. package/src/mappings/Table.ts +0 -164
@@ -1,20 +0,0 @@
1
- import React from "react";
2
- import { ViewStyle } from "react-native";
3
- declare type BorderStyle = "solid" | "dotted" | "dashed";
4
- export declare const TableStyleContext: React.Context<TableStyleProps>;
5
- export interface TableStyleProps {
6
- borderWidth?: number;
7
- borderColor?: string;
8
- borderStyle?: BorderStyle;
9
- cellVerticalPadding?: number;
10
- cellHorizontalPadding?: number;
11
- }
12
- export interface TableProps extends TableStyleProps {
13
- drawTopBorder?: boolean;
14
- drawBottomBorder?: boolean;
15
- drawStartBorder?: boolean;
16
- drawEndBorder?: boolean;
17
- }
18
- export declare function generateBorderStyles({ borderColor, borderWidth, borderStyle, drawTopBorder, drawBottomBorder, drawStartBorder, drawEndBorder, }: TableProps): ViewStyle;
19
- export {};
20
- //# sourceMappingURL=TableCommon.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableCommon.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/TableCommon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,aAAK,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEjD,eAAO,MAAM,iBAAiB,gCAA2C,CAAC;AAE1E,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,UAAW,SAAQ,eAAe;IACjD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,oBAAoB,CAAC,EACnC,WAAW,EACX,WAAW,EACX,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,aAAa,GACd,EAAE,UAAU,GAAG,SAAS,CASxB"}
@@ -1,14 +0,0 @@
1
- import React from "react";
2
- import { StyleProp, ViewStyle } from "react-native";
3
- import { TableProps } from "./TableCommon";
4
- import { Theme } from "../../styles/DefaultTheme";
5
- export interface Props extends TableProps {
6
- isTableHeader?: boolean;
7
- style?: StyleProp<ViewStyle>;
8
- theme: Theme;
9
- }
10
- declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<React.PropsWithChildren<Props>, "theme"> & {
11
- theme?: import("@draftbit/react-theme-provider").$DeepPartial<any> | undefined;
12
- }> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<React.PropsWithChildren<Props>> & React.FC<React.PropsWithChildren<Props>>, {}>;
13
- export default _default;
14
- //# sourceMappingURL=TableRow.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableRow.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/TableRow.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAQ,SAAS,EAAE,SAAS,EAAc,MAAM,cAAc,CAAC;AACtE,OAAO,EAEL,UAAU,EAGX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAGlD,MAAM,WAAW,KAAM,SAAQ,UAAU;IACvC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,KAAK,EAAE,KAAK,CAAC;CACd;;;;AA6DD,wBAAmC"}
@@ -1,4 +0,0 @@
1
- export { default as Table } from "./Table";
2
- export { default as TableRow } from "./TableRow";
3
- export { default as TableCell } from "./TableCell";
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC"}
@@ -1,327 +0,0 @@
1
- export declare const SEED_DATA: ({
2
- name: string;
3
- tag: string;
4
- description: string;
5
- category: string;
6
- stylesPanelSections: string[];
7
- layout: {
8
- flex: number;
9
- flexDirection?: undefined;
10
- };
11
- props: {
12
- borderWidth: {
13
- defaultValue: number;
14
- label: string;
15
- description: string;
16
- formType: string;
17
- propType: string;
18
- group: string;
19
- editable: boolean;
20
- required: boolean;
21
- step: number;
22
- };
23
- borderColor: {
24
- defaultValue: string;
25
- group: string;
26
- label: string;
27
- description: string;
28
- editable: boolean;
29
- required: boolean;
30
- formType: string;
31
- propType: string;
32
- };
33
- borderStyle: {
34
- defaultValue: string;
35
- group: string;
36
- label: string;
37
- description: string;
38
- editable: boolean;
39
- required: boolean;
40
- formType: string;
41
- propType: string;
42
- options: never[];
43
- };
44
- drawTopBorder: {
45
- defaultValue: boolean;
46
- label: string;
47
- description: string;
48
- formType: string;
49
- propType: string;
50
- editable: boolean;
51
- required: boolean;
52
- group: string;
53
- };
54
- cellVerticalPadding: {
55
- defaultValue: number;
56
- label: string;
57
- description: string;
58
- formType: string;
59
- propType: string;
60
- group: string;
61
- editable: boolean;
62
- required: boolean;
63
- step: number;
64
- };
65
- cellHorizontalPadding: {
66
- defaultValue: number;
67
- label: string;
68
- description: string;
69
- formType: string;
70
- propType: string;
71
- group: string;
72
- editable: boolean;
73
- required: boolean;
74
- step: number;
75
- };
76
- drawBottomBorder: {
77
- label: string;
78
- description: string;
79
- formType: string;
80
- propType: string;
81
- defaultValue: boolean;
82
- editable: boolean;
83
- required: boolean;
84
- group: string;
85
- };
86
- drawStartBorder: {
87
- label: string;
88
- description: string;
89
- formType: string;
90
- propType: string;
91
- defaultValue: boolean;
92
- editable: boolean;
93
- required: boolean;
94
- group: string;
95
- };
96
- drawEndBorder: {
97
- label: string;
98
- description: string;
99
- formType: string;
100
- propType: string;
101
- defaultValue: boolean;
102
- editable: boolean;
103
- required: boolean;
104
- group: string;
105
- };
106
- };
107
- } | {
108
- name: string;
109
- tag: string;
110
- description: string;
111
- category: string;
112
- stylesPanelSections: string[];
113
- props: {
114
- drawStartBorder: {
115
- defaultValue: boolean;
116
- label: string;
117
- description: string;
118
- formType: string;
119
- propType: string;
120
- editable: boolean;
121
- required: boolean;
122
- group: string;
123
- };
124
- drawBottomBorder: {
125
- defaultValue: boolean;
126
- label: string;
127
- description: string;
128
- formType: string;
129
- propType: string;
130
- editable: boolean;
131
- required: boolean;
132
- group: string;
133
- };
134
- isTableHeader: {
135
- label: string;
136
- description: string;
137
- formType: string;
138
- propType: string;
139
- defaultValue: boolean;
140
- editable: boolean;
141
- required: boolean;
142
- group: string;
143
- };
144
- borderWidth: {
145
- label: string;
146
- description: string;
147
- formType: string;
148
- propType: string;
149
- group: string;
150
- defaultValue: null;
151
- editable: boolean;
152
- required: boolean;
153
- step: number;
154
- };
155
- borderColor: {
156
- group: string;
157
- label: string;
158
- description: string;
159
- editable: boolean;
160
- required: boolean;
161
- defaultValue: null;
162
- formType: string;
163
- propType: string;
164
- };
165
- borderStyle: {
166
- group: string;
167
- label: string;
168
- description: string;
169
- editable: boolean;
170
- required: boolean;
171
- formType: string;
172
- propType: string;
173
- defaultValue: null;
174
- options: never[];
175
- };
176
- drawTopBorder: {
177
- label: string;
178
- description: string;
179
- formType: string;
180
- propType: string;
181
- defaultValue: boolean;
182
- editable: boolean;
183
- required: boolean;
184
- group: string;
185
- };
186
- drawEndBorder: {
187
- label: string;
188
- description: string;
189
- formType: string;
190
- propType: string;
191
- defaultValue: boolean;
192
- editable: boolean;
193
- required: boolean;
194
- group: string;
195
- };
196
- cellVerticalPadding: {
197
- label: string;
198
- description: string;
199
- formType: string;
200
- propType: string;
201
- group: string;
202
- defaultValue: null;
203
- editable: boolean;
204
- required: boolean;
205
- step: number;
206
- };
207
- cellHorizontalPadding: {
208
- label: string;
209
- description: string;
210
- formType: string;
211
- propType: string;
212
- group: string;
213
- defaultValue: null;
214
- editable: boolean;
215
- required: boolean;
216
- step: number;
217
- };
218
- };
219
- layout?: undefined;
220
- } | {
221
- name: string;
222
- tag: string;
223
- description: string;
224
- category: string;
225
- stylesPanelSections: string[];
226
- layout: {
227
- flex: number;
228
- flexDirection: string;
229
- };
230
- props: {
231
- drawEndBorder: {
232
- defaultValue: boolean;
233
- label: string;
234
- description: string;
235
- formType: string;
236
- propType: string;
237
- editable: boolean;
238
- required: boolean;
239
- group: string;
240
- };
241
- borderWidth: {
242
- label: string;
243
- description: string;
244
- formType: string;
245
- propType: string;
246
- group: string;
247
- defaultValue: null;
248
- editable: boolean;
249
- required: boolean;
250
- step: number;
251
- };
252
- borderColor: {
253
- group: string;
254
- label: string;
255
- description: string;
256
- editable: boolean;
257
- required: boolean;
258
- defaultValue: null;
259
- formType: string;
260
- propType: string;
261
- };
262
- borderStyle: {
263
- group: string;
264
- label: string;
265
- description: string;
266
- editable: boolean;
267
- required: boolean;
268
- formType: string;
269
- propType: string;
270
- defaultValue: null;
271
- options: never[];
272
- };
273
- drawTopBorder: {
274
- label: string;
275
- description: string;
276
- formType: string;
277
- propType: string;
278
- defaultValue: boolean;
279
- editable: boolean;
280
- required: boolean;
281
- group: string;
282
- };
283
- drawBottomBorder: {
284
- label: string;
285
- description: string;
286
- formType: string;
287
- propType: string;
288
- defaultValue: boolean;
289
- editable: boolean;
290
- required: boolean;
291
- group: string;
292
- };
293
- drawStartBorder: {
294
- label: string;
295
- description: string;
296
- formType: string;
297
- propType: string;
298
- defaultValue: boolean;
299
- editable: boolean;
300
- required: boolean;
301
- group: string;
302
- };
303
- cellVerticalPadding: {
304
- label: string;
305
- description: string;
306
- formType: string;
307
- propType: string;
308
- group: string;
309
- defaultValue: null;
310
- editable: boolean;
311
- required: boolean;
312
- step: number;
313
- };
314
- cellHorizontalPadding: {
315
- label: string;
316
- description: string;
317
- formType: string;
318
- propType: string;
319
- group: string;
320
- defaultValue: null;
321
- editable: boolean;
322
- required: boolean;
323
- step: number;
324
- };
325
- };
326
- })[];
327
- //# sourceMappingURL=Table.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/mappings/Table.ts"],"names":[],"mappings":"AAsEA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6FrB,CAAC"}
@@ -1,64 +0,0 @@
1
- import React from "react";
2
- import { ScrollView, View, StyleSheet, } from "react-native";
3
- import { withTheme } from "../../theming";
4
- import { generateBorderStyles, TableStyleContext, } from "./TableCommon";
5
- const Table = ({ theme, borderWidth = 1, borderColor = theme.colors.divider, borderStyle = "solid", drawTopBorder = true, drawBottomBorder = false, drawStartBorder = false, drawEndBorder = false, cellVerticalPadding = 10, cellHorizontalPadding = 10, data, keyExtractor, renderItem, children: childrenProp, style, }) => {
6
- //Both 'renderItem' and 'data' are optional to allow direct children. But if one is included, both need to be included
7
- if ((data && !renderItem) || (renderItem && !data)) {
8
- throw new Error("'renderItem' and 'data' need to both be provided to render from 'data'. Either remove them entirley or include both");
9
- }
10
- if (data && renderItem && childrenProp) {
11
- console.warn("'children' of Table ignored due to usage of 'data' and 'renderItem'");
12
- }
13
- const isTableHeader = React.useCallback((object) => {
14
- return object.isTableHeader;
15
- }, []);
16
- const isRenderItem = data && renderItem;
17
- //Uses 'renderItem' and 'data' to create an array of children
18
- const dataAsChildren = React.useMemo(() => {
19
- if (!isRenderItem)
20
- return [];
21
- return data.map((item, index) => {
22
- const component = renderItem({ item, index });
23
- if (!component) {
24
- return null;
25
- }
26
- const key = keyExtractor ? keyExtractor(item, index) : index.toString();
27
- return React.cloneElement(component, {
28
- key,
29
- });
30
- });
31
- }, [data, renderItem, keyExtractor, isRenderItem]);
32
- const children = isRenderItem
33
- ? dataAsChildren
34
- : React.Children.toArray(childrenProp);
35
- const validChildren = React.useMemo(() => children.filter((item) => React.isValidElement(item)), [children]);
36
- const childrenWithoutHeader = React.useMemo(() => validChildren.filter((item) => !isTableHeader(item.props)), [validChildren, isTableHeader]);
37
- const headers = React.useMemo(() => validChildren.filter((item) => isTableHeader(item.props)), [validChildren, isTableHeader]);
38
- const contextValue = {
39
- borderColor,
40
- borderStyle,
41
- borderWidth,
42
- cellHorizontalPadding,
43
- cellVerticalPadding,
44
- };
45
- const borderViewStyle = generateBorderStyles({
46
- borderColor,
47
- borderWidth,
48
- borderStyle,
49
- drawTopBorder,
50
- drawBottomBorder,
51
- drawStartBorder,
52
- drawEndBorder,
53
- });
54
- return (React.createElement(TableStyleContext.Provider, { value: contextValue },
55
- React.createElement(View, { style: [styles.container, borderViewStyle, style] },
56
- React.createElement(React.Fragment, null, headers),
57
- React.createElement(ScrollView, null, childrenWithoutHeader))));
58
- };
59
- const styles = StyleSheet.create({
60
- container: {
61
- flex: 1,
62
- },
63
- });
64
- export default withTheme(Table);
@@ -1,136 +0,0 @@
1
- import React from "react";
2
- import {
3
- ScrollView,
4
- StyleProp,
5
- ViewStyle,
6
- View,
7
- StyleSheet,
8
- } from "react-native";
9
- import { Theme } from "../../styles/DefaultTheme";
10
- import { withTheme } from "../../theming";
11
- import {
12
- generateBorderStyles,
13
- TableProps,
14
- TableStyleContext,
15
- TableStyleProps,
16
- } from "./TableCommon";
17
-
18
- export interface Props<T> extends TableProps {
19
- data?: Array<T>;
20
- keyExtractor?: (item: T, index: number) => string;
21
- renderItem?: ({ item, index }: { item: T; index: number }) => JSX.Element;
22
- style?: StyleProp<ViewStyle>;
23
- theme: Theme;
24
- }
25
-
26
- const Table = <T extends object>({
27
- theme,
28
- borderWidth = 1,
29
- borderColor = theme.colors.divider,
30
- borderStyle = "solid",
31
- drawTopBorder = true,
32
- drawBottomBorder = false,
33
- drawStartBorder = false,
34
- drawEndBorder = false,
35
- cellVerticalPadding = 10,
36
- cellHorizontalPadding = 10,
37
- data,
38
- keyExtractor,
39
- renderItem,
40
- children: childrenProp,
41
- style,
42
- }: React.PropsWithChildren<Props<T>>) => {
43
- //Both 'renderItem' and 'data' are optional to allow direct children. But if one is included, both need to be included
44
- if ((data && !renderItem) || (renderItem && !data)) {
45
- throw new Error(
46
- "'renderItem' and 'data' need to both be provided to render from 'data'. Either remove them entirley or include both"
47
- );
48
- }
49
-
50
- if (data && renderItem && childrenProp) {
51
- console.warn(
52
- "'children' of Table ignored due to usage of 'data' and 'renderItem'"
53
- );
54
- }
55
-
56
- const isTableHeader = React.useCallback((object: any): boolean => {
57
- return object.isTableHeader;
58
- }, []);
59
-
60
- const isRenderItem = data && renderItem;
61
-
62
- //Uses 'renderItem' and 'data' to create an array of children
63
- const dataAsChildren = React.useMemo(() => {
64
- if (!isRenderItem) return [];
65
-
66
- return data.map((item, index) => {
67
- const component = renderItem({ item, index });
68
-
69
- if (!component) {
70
- return null;
71
- }
72
-
73
- const key = keyExtractor ? keyExtractor(item, index) : index.toString();
74
- return React.cloneElement(component, {
75
- key,
76
- });
77
- });
78
- }, [data, renderItem, keyExtractor, isRenderItem]);
79
-
80
- const children = isRenderItem
81
- ? dataAsChildren
82
- : React.Children.toArray(childrenProp);
83
-
84
- const validChildren = React.useMemo(
85
- () =>
86
- (children as any[]).filter((item) =>
87
- React.isValidElement(item)
88
- ) as React.ReactElement[],
89
- [children]
90
- );
91
-
92
- const childrenWithoutHeader = React.useMemo(
93
- () => validChildren.filter((item) => !isTableHeader(item.props)),
94
- [validChildren, isTableHeader]
95
- );
96
-
97
- const headers = React.useMemo(
98
- () => validChildren.filter((item) => isTableHeader(item.props)),
99
- [validChildren, isTableHeader]
100
- );
101
-
102
- const contextValue: TableStyleProps = {
103
- borderColor,
104
- borderStyle,
105
- borderWidth,
106
- cellHorizontalPadding,
107
- cellVerticalPadding,
108
- };
109
-
110
- const borderViewStyle = generateBorderStyles({
111
- borderColor,
112
- borderWidth,
113
- borderStyle,
114
- drawTopBorder,
115
- drawBottomBorder,
116
- drawStartBorder,
117
- drawEndBorder,
118
- });
119
-
120
- return (
121
- <TableStyleContext.Provider value={contextValue}>
122
- <View style={[styles.container, borderViewStyle, style]}>
123
- <>{headers}</>
124
- <ScrollView>{childrenWithoutHeader}</ScrollView>
125
- </View>
126
- </TableStyleContext.Provider>
127
- );
128
- };
129
-
130
- const styles = StyleSheet.create({
131
- container: {
132
- flex: 1,
133
- },
134
- });
135
-
136
- export default withTheme(Table);
@@ -1,31 +0,0 @@
1
- import React from "react";
2
- import { View, StyleSheet } from "react-native";
3
- import { generateBorderStyles, TableStyleContext, } from "./TableCommon";
4
- const TableCell = ({ borderWidth, borderColor, borderStyle, drawTopBorder = false, drawBottomBorder = false, drawStartBorder = false, drawEndBorder = true, cellVerticalPadding, cellHorizontalPadding, children, style, }) => {
5
- const parentContextValue = React.useContext(TableStyleContext);
6
- const borderViewStyle = generateBorderStyles({
7
- borderColor: borderColor || parentContextValue.borderColor,
8
- borderWidth: borderWidth || parentContextValue.borderWidth,
9
- borderStyle: borderStyle || parentContextValue.borderStyle,
10
- drawTopBorder,
11
- drawBottomBorder,
12
- drawStartBorder,
13
- drawEndBorder,
14
- });
15
- return (React.createElement(View, { style: [
16
- styles.cellContainer,
17
- borderViewStyle,
18
- {
19
- paddingVertical: cellVerticalPadding || parentContextValue.cellVerticalPadding,
20
- paddingHorizontal: cellHorizontalPadding || parentContextValue.cellHorizontalPadding,
21
- },
22
- style,
23
- ] }, children));
24
- };
25
- const styles = StyleSheet.create({
26
- cellContainer: {
27
- flex: 1,
28
- flexDirection: "row",
29
- },
30
- });
31
- export default TableCell;
@@ -1,63 +0,0 @@
1
- import React from "react";
2
- import { View, StyleProp, ViewStyle, StyleSheet } from "react-native";
3
- import {
4
- generateBorderStyles,
5
- TableProps,
6
- TableStyleContext,
7
- } from "./TableCommon";
8
-
9
- export interface Props extends TableProps {
10
- style?: StyleProp<ViewStyle>;
11
- }
12
-
13
- const TableCell: React.FC<React.PropsWithChildren<Props>> = ({
14
- borderWidth,
15
- borderColor,
16
- borderStyle,
17
- drawTopBorder = false,
18
- drawBottomBorder = false,
19
- drawStartBorder = false,
20
- drawEndBorder = true,
21
- cellVerticalPadding,
22
- cellHorizontalPadding,
23
- children,
24
- style,
25
- }) => {
26
- const parentContextValue = React.useContext(TableStyleContext);
27
-
28
- const borderViewStyle = generateBorderStyles({
29
- borderColor: borderColor || parentContextValue.borderColor,
30
- borderWidth: borderWidth || parentContextValue.borderWidth,
31
- borderStyle: borderStyle || parentContextValue.borderStyle,
32
- drawTopBorder,
33
- drawBottomBorder,
34
- drawStartBorder,
35
- drawEndBorder,
36
- });
37
- return (
38
- <View
39
- style={[
40
- styles.cellContainer,
41
- borderViewStyle,
42
- {
43
- paddingVertical:
44
- cellVerticalPadding || parentContextValue.cellVerticalPadding,
45
- paddingHorizontal:
46
- cellHorizontalPadding || parentContextValue.cellHorizontalPadding,
47
- },
48
- style,
49
- ]}
50
- >
51
- {children}
52
- </View>
53
- );
54
- };
55
-
56
- const styles = StyleSheet.create({
57
- cellContainer: {
58
- flex: 1,
59
- flexDirection: "row",
60
- },
61
- });
62
-
63
- export default TableCell;
@@ -1,12 +0,0 @@
1
- import React from "react";
2
- export const TableStyleContext = React.createContext({});
3
- export function generateBorderStyles({ borderColor, borderWidth, borderStyle, drawTopBorder, drawBottomBorder, drawStartBorder, drawEndBorder, }) {
4
- return {
5
- borderColor,
6
- borderStyle,
7
- borderTopWidth: drawTopBorder ? borderWidth : 0,
8
- borderBottomWidth: drawBottomBorder ? borderWidth : 0,
9
- borderStartWidth: drawStartBorder ? borderWidth : 0,
10
- borderEndWidth: drawEndBorder ? borderWidth : 0,
11
- };
12
- }