@draftbit/core 46.8.1-61264d.2 → 46.8.1-a386d4.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/Picker/PickerComponent.android.js +3 -20
- package/lib/commonjs/components/Pressable.js +2 -15
- package/lib/commonjs/components/Shadow.js +46 -0
- package/lib/commonjs/index.js +7 -19
- package/lib/commonjs/mappings/Shadow.js +94 -0
- package/lib/module/components/NumberInput.js +11 -3
- package/lib/module/components/Shadow.js +38 -0
- package/lib/module/index.js +1 -1
- package/lib/module/mappings/Shadow.js +87 -0
- package/lib/typescript/src/components/Shadow.d.ts +24 -0
- package/lib/typescript/src/components/Shadow.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mappings/{Table.d.ts → Shadow.d.ts} +26 -167
- package/lib/typescript/src/mappings/Shadow.d.ts.map +1 -0
- package/package.json +4 -3
- package/src/components/Shadow.js +16 -0
- package/src/components/Shadow.tsx +62 -0
- package/src/index.js +1 -1
- package/src/index.tsx +2 -2
- package/src/mappings/Shadow.js +87 -0
- package/src/mappings/Shadow.ts +95 -0
- package/lib/commonjs/components/Table/Table.js +0 -65
- package/lib/commonjs/components/Table/TableCell.js +0 -48
- package/lib/commonjs/components/Table/TableCommon.js +0 -25
- package/lib/commonjs/components/Table/TableRow.js +0 -63
- package/lib/commonjs/components/Table/index.js +0 -27
- package/lib/commonjs/mappings/Table.js +0 -143
- package/lib/module/components/Table/Table.js +0 -57
- package/lib/module/components/Table/TableCell.js +0 -40
- package/lib/module/components/Table/TableCommon.js +0 -19
- package/lib/module/components/Table/TableRow.js +0 -55
- package/lib/module/components/Table/index.js +0 -3
- package/lib/module/mappings/Table.js +0 -136
- package/lib/typescript/src/components/Table/Table.d.ts +0 -15
- package/lib/typescript/src/components/Table/Table.d.ts.map +0 -1
- package/lib/typescript/src/components/Table/TableCell.d.ts +0 -11
- package/lib/typescript/src/components/Table/TableCell.d.ts.map +0 -1
- package/lib/typescript/src/components/Table/TableCommon.d.ts +0 -14
- package/lib/typescript/src/components/Table/TableCommon.d.ts.map +0 -1
- package/lib/typescript/src/components/Table/TableRow.d.ts +0 -11
- package/lib/typescript/src/components/Table/TableRow.d.ts.map +0 -1
- package/lib/typescript/src/components/Table/index.d.ts +0 -4
- package/lib/typescript/src/components/Table/index.d.ts.map +0 -1
- package/lib/typescript/src/mappings/Table.d.ts.map +0 -1
- package/src/components/Table/Table.js +0 -46
- package/src/components/Table/Table.tsx +0 -83
- package/src/components/Table/TableCell.js +0 -30
- package/src/components/Table/TableCell.tsx +0 -57
- package/src/components/Table/TableCommon.js +0 -10
- package/src/components/Table/TableCommon.ts +0 -32
- package/src/components/Table/TableRow.js +0 -45
- package/src/components/Table/TableRow.tsx +0 -77
- package/src/components/Table/index.js +0 -3
- package/src/components/Table/index.tsx +0 -3
- package/src/mappings/Table.js +0 -137
- package/src/mappings/Table.ts +0 -161
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { StyleProp, ViewStyle } from "react-native";
|
|
3
|
-
import { Theme } from "../../styles/DefaultTheme";
|
|
4
|
-
import { TableBorderProps } from "./TableCommon";
|
|
5
|
-
export interface TableProps extends TableBorderProps {
|
|
6
|
-
cellVerticalPadding?: number;
|
|
7
|
-
callHorizontalPadding?: number;
|
|
8
|
-
style?: StyleProp<ViewStyle>;
|
|
9
|
-
theme: Theme;
|
|
10
|
-
}
|
|
11
|
-
declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<React.PropsWithChildren<TableProps>, "theme"> & {
|
|
12
|
-
theme?: import("@draftbit/react-theme-provider").$DeepPartial<any> | undefined;
|
|
13
|
-
}> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<React.PropsWithChildren<TableProps>> & React.FC<React.PropsWithChildren<TableProps>>, {}>;
|
|
14
|
-
export default _default;
|
|
15
|
-
//# sourceMappingURL=Table.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAQ,SAAS,EAAE,SAAS,EAAc,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAwB,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGvE,MAAM,WAAW,UAAW,SAAQ,gBAAgB;IAClD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,KAAK,EAAE,KAAK,CAAC;CACd;;;;AAsED,wBAAgC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { StyleProp, ViewStyle } from "react-native";
|
|
3
|
-
import { TableBorderProps } from "./TableCommon";
|
|
4
|
-
export interface TableCellProps extends TableBorderProps {
|
|
5
|
-
verticalPadding?: number;
|
|
6
|
-
horizontalPadding?: number;
|
|
7
|
-
style?: StyleProp<ViewStyle>;
|
|
8
|
-
}
|
|
9
|
-
declare const TableCell: React.FC<React.PropsWithChildren<TableCellProps>>;
|
|
10
|
-
export default TableCell;
|
|
11
|
-
//# sourceMappingURL=TableCell.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TableCell.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/TableCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAQ,SAAS,EAAE,SAAS,EAAc,MAAM,cAAc,CAAC;AACtE,OAAO,EAAwB,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEvE,MAAM,WAAW,cAAe,SAAQ,gBAAgB;IACtD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAqChE,CAAC;AASF,eAAe,SAAS,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ViewStyle } from "react-native";
|
|
2
|
-
declare type BorderStyle = "solid" | "dotted" | "dashed";
|
|
3
|
-
export interface TableBorderProps {
|
|
4
|
-
borderWidth?: number;
|
|
5
|
-
borderColor?: string;
|
|
6
|
-
borderStyle?: BorderStyle;
|
|
7
|
-
drawTopBorder?: boolean;
|
|
8
|
-
drawBottomBorder?: boolean;
|
|
9
|
-
drawStartBorder?: boolean;
|
|
10
|
-
drawEndBorder?: boolean;
|
|
11
|
-
}
|
|
12
|
-
export declare function generateBorderStyles({ borderColor, borderWidth, borderStyle, drawTopBorder, drawBottomBorder, drawStartBorder, drawEndBorder, }: TableBorderProps): ViewStyle;
|
|
13
|
-
export {};
|
|
14
|
-
//# 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,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,aAAK,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEjD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,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,gBAAgB,GAAG,SAAS,CAS9B"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { StyleProp, ViewStyle } from "react-native";
|
|
3
|
-
import { TableBorderProps } from "./TableCommon";
|
|
4
|
-
export interface TableRowProps extends TableBorderProps {
|
|
5
|
-
cellVerticalPadding?: number;
|
|
6
|
-
callHorizontalPadding?: number;
|
|
7
|
-
style?: StyleProp<ViewStyle>;
|
|
8
|
-
}
|
|
9
|
-
declare const TableRow: React.FC<React.PropsWithChildren<TableRowProps>>;
|
|
10
|
-
export default TableRow;
|
|
11
|
-
//# 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,EAAwB,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGvE,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAwD9D,CAAC;AASF,eAAe,QAAQ,CAAC"}
|
|
@@ -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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/mappings/Table.ts"],"names":[],"mappings":"AA0DA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsGrB,CAAC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
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);
|
|
@@ -1,83 +0,0 @@
|
|
|
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);
|
|
@@ -1,30 +0,0 @@
|
|
|
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;
|
|
@@ -1,57 +0,0 @@
|
|
|
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;
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
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;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { View, StyleProp, ViewStyle, StyleSheet } from "react-native";
|
|
3
|
-
import { generateBorderStyles, TableBorderProps } from "./TableCommon";
|
|
4
|
-
import TableCell, { TableCellProps } from "./TableCell";
|
|
5
|
-
|
|
6
|
-
export interface TableRowProps extends TableBorderProps {
|
|
7
|
-
cellVerticalPadding?: number;
|
|
8
|
-
callHorizontalPadding?: number;
|
|
9
|
-
style?: StyleProp<ViewStyle>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const TableRow: React.FC<React.PropsWithChildren<TableRowProps>> = ({
|
|
13
|
-
borderWidth,
|
|
14
|
-
borderColor,
|
|
15
|
-
borderStyle,
|
|
16
|
-
drawTopBorder = false,
|
|
17
|
-
drawBottomBorder = true,
|
|
18
|
-
drawStartBorder = true,
|
|
19
|
-
drawEndBorder = false,
|
|
20
|
-
cellVerticalPadding,
|
|
21
|
-
callHorizontalPadding,
|
|
22
|
-
children,
|
|
23
|
-
style,
|
|
24
|
-
}) => {
|
|
25
|
-
//Populate each TableCell props with default values provided here
|
|
26
|
-
const populatedTableCells = React.useMemo(
|
|
27
|
-
() =>
|
|
28
|
-
React.Children.map(children, (child) => {
|
|
29
|
-
if (React.isValidElement(child) && child.type === TableCell) {
|
|
30
|
-
const oldProps = { ...(child.props as TableCellProps) };
|
|
31
|
-
const newProps: TableCellProps = {
|
|
32
|
-
verticalPadding: oldProps.verticalPadding || cellVerticalPadding,
|
|
33
|
-
horizontalPadding:
|
|
34
|
-
oldProps.horizontalPadding || callHorizontalPadding,
|
|
35
|
-
borderWidth: oldProps.borderWidth || borderWidth,
|
|
36
|
-
borderColor: oldProps.borderColor || borderColor,
|
|
37
|
-
borderStyle: oldProps.borderStyle || borderStyle,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
return React.cloneElement(child, newProps);
|
|
41
|
-
}
|
|
42
|
-
return child;
|
|
43
|
-
}),
|
|
44
|
-
[
|
|
45
|
-
children,
|
|
46
|
-
borderColor,
|
|
47
|
-
borderWidth,
|
|
48
|
-
borderStyle,
|
|
49
|
-
cellVerticalPadding,
|
|
50
|
-
callHorizontalPadding,
|
|
51
|
-
]
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const borderViewStyle = generateBorderStyles({
|
|
55
|
-
borderColor,
|
|
56
|
-
borderWidth,
|
|
57
|
-
borderStyle,
|
|
58
|
-
drawTopBorder,
|
|
59
|
-
drawBottomBorder,
|
|
60
|
-
drawStartBorder,
|
|
61
|
-
drawEndBorder,
|
|
62
|
-
});
|
|
63
|
-
return (
|
|
64
|
-
<View style={[borderViewStyle, style, styles.cellsContainer]}>
|
|
65
|
-
{populatedTableCells}
|
|
66
|
-
</View>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const styles = StyleSheet.create({
|
|
71
|
-
cellsContainer: {
|
|
72
|
-
flex: 1,
|
|
73
|
-
flexDirection: "row",
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
export default TableRow;
|
package/src/mappings/Table.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { COMPONENT_TYPES, StylesPanelSections, createColorProp, createStaticBoolProp, createStaticNumberProp, BLOCK_STYLES_SECTIONS, CONTAINER_COMPONENT_STYLES_SECTIONS, createTextEnumProp, } from "@draftbit/types";
|
|
2
|
-
const SHARED_SEED_DATA_PROPS = {
|
|
3
|
-
borderWidth: createStaticNumberProp({
|
|
4
|
-
label: "Border Width",
|
|
5
|
-
description: "Specifies the width of the border. Passed down to child Table(Row/Cell) components unless overridden",
|
|
6
|
-
required: false,
|
|
7
|
-
defaultValue: null,
|
|
8
|
-
}),
|
|
9
|
-
borderColor: createColorProp({
|
|
10
|
-
label: "Border Color",
|
|
11
|
-
description: "Specifies the color of the border. Passed down to child Table(Row/Cell) components unless overridden",
|
|
12
|
-
defaultValue: null,
|
|
13
|
-
}),
|
|
14
|
-
borderStyle: createTextEnumProp({
|
|
15
|
-
label: "Border Style",
|
|
16
|
-
description: "Specifies the style of the border. Passed down to child Table(Row/Cell) components unless overridden",
|
|
17
|
-
options: ["solid", "dotted", "dashed"],
|
|
18
|
-
defaultValue: null,
|
|
19
|
-
}),
|
|
20
|
-
drawTopBorder: createStaticBoolProp({
|
|
21
|
-
label: "Draw Top Border",
|
|
22
|
-
description: "Whether to draw the top border at this layer of the Table tree or not",
|
|
23
|
-
defaultValue: false,
|
|
24
|
-
}),
|
|
25
|
-
drawBottomBorder: createStaticBoolProp({
|
|
26
|
-
label: "Draw Bottom Border",
|
|
27
|
-
description: "Whether to draw the bottom border at this layer of the Table tree or not",
|
|
28
|
-
defaultValue: false,
|
|
29
|
-
}),
|
|
30
|
-
drawStartBorder: createStaticBoolProp({
|
|
31
|
-
label: "Draw Start Border",
|
|
32
|
-
description: "Whether to draw the start border at this layer of the Table tree or not",
|
|
33
|
-
defaultValue: false,
|
|
34
|
-
}),
|
|
35
|
-
drawEndBorder: createStaticBoolProp({
|
|
36
|
-
label: "Draw End Border",
|
|
37
|
-
description: "Whether to draw the end border at this layer of the Table tree or not",
|
|
38
|
-
defaultValue: false,
|
|
39
|
-
}),
|
|
40
|
-
};
|
|
41
|
-
export const SEED_DATA = [
|
|
42
|
-
{
|
|
43
|
-
name: "Table",
|
|
44
|
-
tag: "Table",
|
|
45
|
-
description: "Top level table container",
|
|
46
|
-
category: COMPONENT_TYPES.table,
|
|
47
|
-
stylesPanelSections: BLOCK_STYLES_SECTIONS,
|
|
48
|
-
props: {
|
|
49
|
-
...SHARED_SEED_DATA_PROPS,
|
|
50
|
-
borderWidth: { ...SHARED_SEED_DATA_PROPS.borderWidth, defaultValue: 1 },
|
|
51
|
-
borderColor: {
|
|
52
|
-
...SHARED_SEED_DATA_PROPS.borderColor,
|
|
53
|
-
defaultValue: "divider",
|
|
54
|
-
},
|
|
55
|
-
borderStyle: {
|
|
56
|
-
...SHARED_SEED_DATA_PROPS.borderStyle,
|
|
57
|
-
defaultValue: "solid",
|
|
58
|
-
},
|
|
59
|
-
drawTopBorder: {
|
|
60
|
-
...SHARED_SEED_DATA_PROPS.drawTopBorder,
|
|
61
|
-
defaultValue: true,
|
|
62
|
-
},
|
|
63
|
-
cellVerticalPadding: createStaticNumberProp({
|
|
64
|
-
label: "Cell Vertical Padding",
|
|
65
|
-
description: "Specifies the vertical padding of the cell. Passed down to child Table Row components unless overridden",
|
|
66
|
-
required: false,
|
|
67
|
-
defaultValue: 10,
|
|
68
|
-
}),
|
|
69
|
-
callHorizontalPadding: createStaticNumberProp({
|
|
70
|
-
label: "Cell Horizontal Padding",
|
|
71
|
-
description: "Specifies the horizontal padding of the cell. Passed down to child Table Row components unless overridden",
|
|
72
|
-
required: false,
|
|
73
|
-
defaultValue: 10,
|
|
74
|
-
}),
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
name: "Table Row",
|
|
79
|
-
tag: "TableRow",
|
|
80
|
-
description: "Table Row container",
|
|
81
|
-
category: COMPONENT_TYPES.table,
|
|
82
|
-
stylesPanelSections: [StylesPanelSections.Background],
|
|
83
|
-
props: {
|
|
84
|
-
...SHARED_SEED_DATA_PROPS,
|
|
85
|
-
drawStartBorder: {
|
|
86
|
-
...SHARED_SEED_DATA_PROPS.drawStartBorder,
|
|
87
|
-
defaultValue: true,
|
|
88
|
-
},
|
|
89
|
-
drawBottomBorder: {
|
|
90
|
-
...SHARED_SEED_DATA_PROPS.drawBottomBorder,
|
|
91
|
-
defaultValue: true,
|
|
92
|
-
},
|
|
93
|
-
cellVerticalPadding: createStaticNumberProp({
|
|
94
|
-
label: "Cell Vertical Padding",
|
|
95
|
-
description: "Specifies the vertical padding of the cell. Passed down to child Table Cell components unless overridden",
|
|
96
|
-
required: false,
|
|
97
|
-
defaultValue: null,
|
|
98
|
-
}),
|
|
99
|
-
callHorizontalPadding: createStaticNumberProp({
|
|
100
|
-
label: "Cell Horizontal Padding",
|
|
101
|
-
description: "Specifies the horizontal padding of the cell. Passed down to child Table Cell components unless overridden",
|
|
102
|
-
required: false,
|
|
103
|
-
defaultValue: null,
|
|
104
|
-
}),
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
name: "Table Cell",
|
|
109
|
-
tag: "TableCell",
|
|
110
|
-
description: "Table Cell container",
|
|
111
|
-
category: COMPONENT_TYPES.table,
|
|
112
|
-
stylesPanelSections: CONTAINER_COMPONENT_STYLES_SECTIONS.filter((item) => item !== StylesPanelSections.Borders),
|
|
113
|
-
layout: {
|
|
114
|
-
flex: 1,
|
|
115
|
-
flexDirection: "row",
|
|
116
|
-
},
|
|
117
|
-
props: {
|
|
118
|
-
...SHARED_SEED_DATA_PROPS,
|
|
119
|
-
drawEndBorder: {
|
|
120
|
-
...SHARED_SEED_DATA_PROPS.drawEndBorder,
|
|
121
|
-
defaultValue: true,
|
|
122
|
-
},
|
|
123
|
-
verticalPadding: createStaticNumberProp({
|
|
124
|
-
label: "Vertical Padding",
|
|
125
|
-
description: "Specifies the vertical padding of the cell",
|
|
126
|
-
required: false,
|
|
127
|
-
defaultValue: null,
|
|
128
|
-
}),
|
|
129
|
-
horizontalPadding: createStaticNumberProp({
|
|
130
|
-
label: "Horizontal Padding",
|
|
131
|
-
description: "Specifies the horizontal padding of the cell",
|
|
132
|
-
required: false,
|
|
133
|
-
defaultValue: null,
|
|
134
|
-
}),
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
];
|