@draftbit/core 46.10.3-e89832.2 → 46.10.3-fb35c9.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/AnimatedCircularProgress.js +1 -12
- package/lib/commonjs/components/AvatarEdit.js +4 -15
- package/lib/commonjs/components/Banner.js +4 -23
- package/lib/commonjs/components/Button.js +10 -33
- package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js +5 -23
- package/lib/commonjs/components/DeprecatedButton.js +3 -20
- package/lib/commonjs/components/Divider.js +1 -14
- package/lib/commonjs/components/FieldSearchBarFull.js +2 -1
- package/lib/commonjs/components/Layout.js +19 -40
- package/lib/commonjs/components/NumberInput.js +3 -12
- package/lib/commonjs/components/Picker/PickerComponent.android.js +3 -20
- package/lib/commonjs/components/Portal/PortalConsumer.js +7 -22
- package/lib/commonjs/components/Portal/PortalManager.js +8 -34
- package/lib/commonjs/components/RadioButton/RadioButton.js +2 -13
- package/lib/commonjs/components/RadioButton/RadioButtonFieldGroup.js +1 -9
- package/lib/commonjs/components/RadioButton/RadioButtonGroup.js +2 -15
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js +5 -23
- package/lib/commonjs/components/ScreenContainer.js +6 -24
- package/lib/commonjs/components/Shadow.js +2 -15
- package/lib/commonjs/components/Slider.js +4 -21
- package/lib/commonjs/components/StarRating.js +4 -23
- package/lib/commonjs/components/StepIndicator.js +18 -57
- package/lib/commonjs/components/Surface.js +2 -14
- package/lib/commonjs/components/TabView/TabView.js +7 -13
- package/lib/commonjs/components/Table/Table.js +123 -0
- package/lib/commonjs/components/Table/TableCell.js +49 -0
- package/lib/commonjs/components/Table/TableCommon.js +30 -0
- package/lib/commonjs/components/Table/TableRow.js +61 -0
- package/lib/commonjs/components/Table/index.js +27 -0
- package/lib/commonjs/components/Text.js +4 -50
- package/lib/commonjs/components/TextField.js +28 -76
- package/lib/commonjs/components/ToggleButton.js +2 -15
- package/lib/commonjs/components/Touchable.js +2 -15
- package/lib/commonjs/constants.js +1 -1
- package/lib/commonjs/index.js +19 -28
- package/lib/commonjs/mappings/NativeBase/Layout.js +108 -0
- package/lib/commonjs/mappings/Table.js +140 -0
- package/lib/commonjs/styles/overlay.js +3 -1
- package/lib/commonjs/utilities.js +2 -1
- package/lib/module/components/Portal/PortalManager.js +33 -7
- package/lib/module/components/Table/Table.js +114 -0
- package/lib/module/components/Table/TableCell.js +41 -0
- package/lib/module/components/Table/TableCommon.js +21 -0
- package/lib/module/components/Table/TableRow.js +53 -0
- package/lib/module/components/Table/index.js +3 -0
- package/lib/module/index.js +1 -4
- package/lib/module/mappings/NativeBase/Layout.js +101 -0
- package/lib/module/mappings/Table.js +133 -0
- package/lib/typescript/src/components/Table/Table.d.ts +19 -0
- package/lib/typescript/src/components/Table/Table.d.ts.map +1 -0
- package/lib/typescript/src/components/Table/TableCell.d.ts +9 -0
- package/lib/typescript/src/components/Table/TableCell.d.ts.map +1 -0
- package/lib/typescript/src/components/Table/TableCommon.d.ts +20 -0
- package/lib/typescript/src/components/Table/TableCommon.d.ts.map +1 -0
- package/lib/typescript/src/components/{DeprecatedCardWrapper.d.ts → Table/TableRow.d.ts} +7 -8
- 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 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mappings/NativeBase/Layout.d.ts +133 -0
- package/lib/typescript/src/mappings/NativeBase/Layout.d.ts.map +1 -0
- package/lib/typescript/src/mappings/{CardBlock.d.ts → Table.d.ts} +129 -81
- package/lib/typescript/src/mappings/Table.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/components/Table/Table.js +93 -0
- package/src/components/Table/Table.tsx +176 -0
- package/src/components/Table/TableCell.js +31 -0
- package/src/components/Table/TableCell.tsx +63 -0
- package/src/components/Table/TableCommon.js +12 -0
- package/src/components/Table/TableCommon.ts +40 -0
- package/src/components/Table/TableRow.js +37 -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 -4
- package/src/index.tsx +2 -4
- package/src/mappings/NativeBase/Layout.js +124 -0
- package/src/mappings/NativeBase/Layout.ts +145 -0
- package/src/mappings/Table.js +150 -0
- package/src/mappings/Table.ts +170 -0
- package/lib/commonjs/components/Container.js +0 -104
- package/lib/commonjs/components/DeprecatedCardWrapper.js +0 -40
- package/lib/commonjs/components/DeprecatedFAB.js +0 -157
- package/lib/commonjs/components/ProgressIndicator.js +0 -55
- package/lib/commonjs/components/ResizeMode.js +0 -5
- package/lib/commonjs/components/Row.js +0 -73
- package/lib/commonjs/components/RowBodyIcon.js +0 -45
- package/lib/commonjs/components/RowHeadlineImageCaption.js +0 -45
- package/lib/commonjs/components/RowHeadlineImageIcon.js +0 -51
- package/lib/commonjs/mappings/CardBlock.js +0 -126
- package/lib/commonjs/mappings/CardContainer.js +0 -108
- package/lib/commonjs/mappings/CardContainerRating.js +0 -130
- package/lib/commonjs/mappings/CardContainerShortImage.js +0 -124
- package/lib/commonjs/mappings/CardInline.js +0 -59
- package/lib/commonjs/mappings/Container.js +0 -37
- package/lib/commonjs/mappings/ProgressIndicator.js +0 -188
- package/lib/module/components/Container.js +0 -83
- package/lib/module/components/DeprecatedCardWrapper.js +0 -32
- package/lib/module/components/DeprecatedFAB.js +0 -147
- package/lib/module/components/ProgressIndicator.js +0 -45
- package/lib/module/components/ResizeMode.js +0 -1
- package/lib/module/components/Row.js +0 -63
- package/lib/module/components/RowBodyIcon.js +0 -35
- package/lib/module/components/RowHeadlineImageCaption.js +0 -35
- package/lib/module/components/RowHeadlineImageIcon.js +0 -41
- package/lib/module/mappings/CardBlock.js +0 -119
- package/lib/module/mappings/CardContainer.js +0 -101
- package/lib/module/mappings/CardContainerRating.js +0 -123
- package/lib/module/mappings/CardContainerShortImage.js +0 -117
- package/lib/module/mappings/CardInline.js +0 -52
- package/lib/module/mappings/Container.js +0 -30
- package/lib/module/mappings/ProgressIndicator.js +0 -181
- package/lib/typescript/src/components/Container.d.ts +0 -21
- package/lib/typescript/src/components/Container.d.ts.map +0 -1
- package/lib/typescript/src/components/DeprecatedCardWrapper.d.ts.map +0 -1
- package/lib/typescript/src/components/DeprecatedFAB.d.ts +0 -56
- package/lib/typescript/src/components/DeprecatedFAB.d.ts.map +0 -1
- package/lib/typescript/src/components/ProgressIndicator.d.ts +0 -24
- package/lib/typescript/src/components/ProgressIndicator.d.ts.map +0 -1
- package/lib/typescript/src/components/ResizeMode.d.ts +0 -2
- package/lib/typescript/src/components/ResizeMode.d.ts.map +0 -1
- package/lib/typescript/src/components/Row.d.ts +0 -21
- package/lib/typescript/src/components/Row.d.ts.map +0 -1
- package/lib/typescript/src/components/RowBodyIcon.d.ts +0 -16
- package/lib/typescript/src/components/RowBodyIcon.d.ts.map +0 -1
- package/lib/typescript/src/components/RowHeadlineImageCaption.d.ts +0 -16
- package/lib/typescript/src/components/RowHeadlineImageCaption.d.ts.map +0 -1
- package/lib/typescript/src/components/RowHeadlineImageIcon.d.ts +0 -18
- package/lib/typescript/src/components/RowHeadlineImageIcon.d.ts.map +0 -1
- package/lib/typescript/src/mappings/CardBlock.d.ts.map +0 -1
- package/lib/typescript/src/mappings/CardContainer.d.ts +0 -102
- package/lib/typescript/src/mappings/CardContainer.d.ts.map +0 -1
- package/lib/typescript/src/mappings/CardContainerRating.d.ts +0 -108
- package/lib/typescript/src/mappings/CardContainerRating.d.ts.map +0 -1
- package/lib/typescript/src/mappings/CardContainerShortImage.d.ts +0 -139
- package/lib/typescript/src/mappings/CardContainerShortImage.d.ts.map +0 -1
- package/lib/typescript/src/mappings/CardInline.d.ts +0 -62
- package/lib/typescript/src/mappings/CardInline.d.ts.map +0 -1
- package/lib/typescript/src/mappings/Container.d.ts +0 -55
- package/lib/typescript/src/mappings/Container.d.ts.map +0 -1
- package/lib/typescript/src/mappings/ProgressIndicator.d.ts +0 -181
- package/lib/typescript/src/mappings/ProgressIndicator.d.ts.map +0 -1
- package/src/components/Container.js +0 -43
- package/src/components/Container.tsx +0 -116
- package/src/components/DeprecatedCardWrapper.js +0 -18
- package/src/components/DeprecatedCardWrapper.tsx +0 -46
- package/src/components/DeprecatedFAB.js +0 -114
- package/src/components/DeprecatedFAB.tsx +0 -231
- package/src/components/ProgressIndicator.js +0 -27
- package/src/components/ProgressIndicator.tsx +0 -71
- package/src/components/ResizeMode.js +0 -1
- package/src/components/ResizeMode.ts +0 -7
- package/src/components/Row.js +0 -48
- package/src/components/Row.tsx +0 -108
- package/src/components/RowBodyIcon.js +0 -8
- package/src/components/RowBodyIcon.tsx +0 -47
- package/src/components/RowHeadlineImageCaption.js +0 -12
- package/src/components/RowHeadlineImageCaption.tsx +0 -49
- package/src/components/RowHeadlineImageIcon.js +0 -14
- package/src/components/RowHeadlineImageIcon.tsx +0 -61
- package/src/mappings/CardBlock.js +0 -123
- package/src/mappings/CardBlock.ts +0 -136
- package/src/mappings/CardContainer.js +0 -104
- package/src/mappings/CardContainer.ts +0 -116
- package/src/mappings/CardContainerRating.js +0 -126
- package/src/mappings/CardContainerRating.ts +0 -137
- package/src/mappings/CardContainerShortImage.js +0 -120
- package/src/mappings/CardContainerShortImage.ts +0 -130
- package/src/mappings/CardInline.js +0 -52
- package/src/mappings/CardInline.ts +0 -61
- package/src/mappings/Container.js +0 -30
- package/src/mappings/Container.ts +0 -41
- package/src/mappings/ProgressIndicator.js +0 -181
- package/src/mappings/ProgressIndicator.ts +0 -190
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
ScrollView,
|
|
4
|
+
StyleProp,
|
|
5
|
+
ViewStyle,
|
|
6
|
+
View,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
ScrollViewProps,
|
|
9
|
+
} from "react-native";
|
|
10
|
+
import { Theme } from "../../styles/DefaultTheme";
|
|
11
|
+
import { withTheme } from "../../theming";
|
|
12
|
+
import {
|
|
13
|
+
generateBorderStyles,
|
|
14
|
+
TableProps,
|
|
15
|
+
TableStyleContext,
|
|
16
|
+
TableStyleProps,
|
|
17
|
+
} from "./TableCommon";
|
|
18
|
+
|
|
19
|
+
export interface Props<T> extends TableProps, ScrollViewProps {
|
|
20
|
+
data?: Array<T>;
|
|
21
|
+
keyExtractor?: (item: T, index: number) => string;
|
|
22
|
+
renderItem?: ({ item, index }: { item: T; index: number }) => JSX.Element;
|
|
23
|
+
style?: StyleProp<ViewStyle>;
|
|
24
|
+
theme: Theme;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const Table = <T extends object>({
|
|
28
|
+
theme,
|
|
29
|
+
borderWidth = 1,
|
|
30
|
+
borderColor = theme.colors.divider,
|
|
31
|
+
borderStyle = "solid",
|
|
32
|
+
drawTopBorder = true,
|
|
33
|
+
drawBottomBorder = false,
|
|
34
|
+
drawStartBorder = false,
|
|
35
|
+
drawEndBorder = false,
|
|
36
|
+
cellVerticalPadding = 10,
|
|
37
|
+
cellHorizontalPadding = 10,
|
|
38
|
+
data,
|
|
39
|
+
keyExtractor,
|
|
40
|
+
renderItem,
|
|
41
|
+
children: childrenProp,
|
|
42
|
+
style,
|
|
43
|
+
...rest
|
|
44
|
+
}: React.PropsWithChildren<Props<T>>) => {
|
|
45
|
+
//Both 'renderItem' and 'data' are optional to allow direct children. But if one is included, both need to be included
|
|
46
|
+
if ((data && !renderItem) || (renderItem && !data)) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
"'renderItem' and 'data' need to both be provided to render from 'data'. Either remove them entirley or include both"
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (data && renderItem && childrenProp) {
|
|
53
|
+
console.warn(
|
|
54
|
+
"'children' of Table ignored due to usage of 'data' and 'renderItem'"
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const isTableHeader = React.useCallback((object: any): boolean => {
|
|
59
|
+
return object.isTableHeader;
|
|
60
|
+
}, []);
|
|
61
|
+
|
|
62
|
+
const isRenderItem = data && renderItem;
|
|
63
|
+
|
|
64
|
+
//Uses 'renderItem' and 'data' to create an array of children
|
|
65
|
+
const dataAsChildren = React.useMemo(() => {
|
|
66
|
+
if (!isRenderItem) return [];
|
|
67
|
+
|
|
68
|
+
return data.map((item, index) => {
|
|
69
|
+
const component = renderItem({ item, index });
|
|
70
|
+
|
|
71
|
+
if (!component) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const key = keyExtractor ? keyExtractor(item, index) : index.toString();
|
|
76
|
+
return React.cloneElement(component, {
|
|
77
|
+
key,
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}, [data, renderItem, keyExtractor, isRenderItem]);
|
|
81
|
+
|
|
82
|
+
const children = isRenderItem
|
|
83
|
+
? dataAsChildren
|
|
84
|
+
: React.Children.toArray(childrenProp);
|
|
85
|
+
|
|
86
|
+
const validChildren = React.useMemo(
|
|
87
|
+
() =>
|
|
88
|
+
(children as any[]).filter((item) =>
|
|
89
|
+
React.isValidElement(item)
|
|
90
|
+
) as React.ReactElement[],
|
|
91
|
+
[children]
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const childrenWithoutHeader = React.useMemo(() => {
|
|
95
|
+
const flattenedWithoutNestedHeaders = validChildren.map((item) => {
|
|
96
|
+
const nestedChildren = React.Children.toArray(
|
|
97
|
+
item.props.children
|
|
98
|
+
) as any[];
|
|
99
|
+
//Header can be nested in React.Fragment when in renderItem
|
|
100
|
+
const nestedHeaders = nestedChildren.filter((child: any) =>
|
|
101
|
+
isTableHeader(child.props)
|
|
102
|
+
);
|
|
103
|
+
if (nestedHeaders?.length) {
|
|
104
|
+
//New element excluding header children
|
|
105
|
+
return React.cloneElement(item, {
|
|
106
|
+
children: nestedChildren.filter(
|
|
107
|
+
(child: any) => !isTableHeader(child.props)
|
|
108
|
+
),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return item;
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
return flattenedWithoutNestedHeaders.filter(
|
|
115
|
+
(item) => !isTableHeader(item.props)
|
|
116
|
+
);
|
|
117
|
+
}, [validChildren, isTableHeader]);
|
|
118
|
+
|
|
119
|
+
const header = React.useMemo(() => {
|
|
120
|
+
const flattenedPossibleHeaders = validChildren.map((item) => {
|
|
121
|
+
const nestedChildren = React.Children.toArray(
|
|
122
|
+
item.props.children
|
|
123
|
+
) as any[];
|
|
124
|
+
//Header can be nested in React.Fragment when in renderItem
|
|
125
|
+
const nestedHeaders = nestedChildren.filter((child: any) =>
|
|
126
|
+
isTableHeader(child.props)
|
|
127
|
+
);
|
|
128
|
+
if (nestedHeaders?.length) {
|
|
129
|
+
return nestedHeaders[0];
|
|
130
|
+
}
|
|
131
|
+
return item;
|
|
132
|
+
});
|
|
133
|
+
const allHeaders = flattenedPossibleHeaders.filter((item) =>
|
|
134
|
+
isTableHeader(item.props)
|
|
135
|
+
);
|
|
136
|
+
if (allHeaders.length) {
|
|
137
|
+
return allHeaders[0]; //Only 1 header taken
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
}, [validChildren, isTableHeader]);
|
|
141
|
+
|
|
142
|
+
const contextValue: TableStyleProps = {
|
|
143
|
+
borderColor,
|
|
144
|
+
borderStyle,
|
|
145
|
+
borderWidth,
|
|
146
|
+
cellHorizontalPadding,
|
|
147
|
+
cellVerticalPadding,
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const borderViewStyle = generateBorderStyles({
|
|
151
|
+
borderColor,
|
|
152
|
+
borderWidth,
|
|
153
|
+
borderStyle,
|
|
154
|
+
drawTopBorder,
|
|
155
|
+
drawBottomBorder,
|
|
156
|
+
drawStartBorder,
|
|
157
|
+
drawEndBorder,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<TableStyleContext.Provider value={contextValue}>
|
|
162
|
+
<View style={[styles.container, borderViewStyle, style]}>
|
|
163
|
+
<>{header}</>
|
|
164
|
+
<ScrollView {...rest}>{childrenWithoutHeader}</ScrollView>
|
|
165
|
+
</View>
|
|
166
|
+
</TableStyleContext.Provider>
|
|
167
|
+
);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const styles = StyleSheet.create({
|
|
171
|
+
container: {
|
|
172
|
+
flex: 1,
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
export default withTheme(Table);
|
|
@@ -0,0 +1,31 @@
|
|
|
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;
|
|
@@ -0,0 +1,63 @@
|
|
|
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;
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ViewStyle } from "react-native";
|
|
3
|
+
|
|
4
|
+
type BorderStyle = "solid" | "dotted" | "dashed";
|
|
5
|
+
|
|
6
|
+
export const TableStyleContext = React.createContext<TableStyleProps>({});
|
|
7
|
+
|
|
8
|
+
export interface TableStyleProps {
|
|
9
|
+
borderWidth?: number;
|
|
10
|
+
borderColor?: string;
|
|
11
|
+
borderStyle?: BorderStyle;
|
|
12
|
+
cellVerticalPadding?: number;
|
|
13
|
+
cellHorizontalPadding?: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface TableProps extends TableStyleProps {
|
|
17
|
+
drawTopBorder?: boolean;
|
|
18
|
+
drawBottomBorder?: boolean;
|
|
19
|
+
drawStartBorder?: boolean;
|
|
20
|
+
drawEndBorder?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function generateBorderStyles({
|
|
24
|
+
borderColor,
|
|
25
|
+
borderWidth,
|
|
26
|
+
borderStyle,
|
|
27
|
+
drawTopBorder,
|
|
28
|
+
drawBottomBorder,
|
|
29
|
+
drawStartBorder,
|
|
30
|
+
drawEndBorder,
|
|
31
|
+
}: TableProps): ViewStyle {
|
|
32
|
+
return {
|
|
33
|
+
borderColor,
|
|
34
|
+
borderStyle,
|
|
35
|
+
borderTopWidth: drawTopBorder ? borderWidth : 0,
|
|
36
|
+
borderBottomWidth: drawBottomBorder ? borderWidth : 0,
|
|
37
|
+
borderStartWidth: drawStartBorder ? borderWidth : 0,
|
|
38
|
+
borderEndWidth: drawEndBorder ? borderWidth : 0,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import { generateBorderStyles, TableStyleContext, } from "./TableCommon";
|
|
4
|
+
import { withTheme } from "../../theming";
|
|
5
|
+
const TableRow = ({ borderWidth, borderColor, borderStyle, drawTopBorder = false, drawBottomBorder = true, drawStartBorder = true, drawEndBorder = false, cellVerticalPadding, cellHorizontalPadding, isTableHeader = false, children, style, theme, }) => {
|
|
6
|
+
const parentContextValue = React.useContext(TableStyleContext);
|
|
7
|
+
//Create context to use and pass to children based on own props or fall back to parent provided context
|
|
8
|
+
const contextValue = {
|
|
9
|
+
borderColor: borderColor || parentContextValue.borderColor,
|
|
10
|
+
borderStyle: borderStyle || parentContextValue.borderStyle,
|
|
11
|
+
borderWidth: borderWidth || parentContextValue.borderWidth,
|
|
12
|
+
cellHorizontalPadding: cellHorizontalPadding || parentContextValue.cellHorizontalPadding,
|
|
13
|
+
cellVerticalPadding: cellVerticalPadding || parentContextValue.cellVerticalPadding,
|
|
14
|
+
};
|
|
15
|
+
const borderViewStyle = generateBorderStyles({
|
|
16
|
+
borderColor: contextValue.borderColor,
|
|
17
|
+
borderWidth: contextValue.borderWidth,
|
|
18
|
+
borderStyle: contextValue.borderStyle,
|
|
19
|
+
drawTopBorder,
|
|
20
|
+
drawBottomBorder,
|
|
21
|
+
drawStartBorder,
|
|
22
|
+
drawEndBorder,
|
|
23
|
+
});
|
|
24
|
+
return (React.createElement(TableStyleContext.Provider, { value: contextValue },
|
|
25
|
+
React.createElement(View, { style: [
|
|
26
|
+
borderViewStyle,
|
|
27
|
+
isTableHeader ? { backgroundColor: theme.colors.primary } : {},
|
|
28
|
+
style,
|
|
29
|
+
styles.cellsContainer,
|
|
30
|
+
] }, children)));
|
|
31
|
+
};
|
|
32
|
+
const styles = StyleSheet.create({
|
|
33
|
+
cellsContainer: {
|
|
34
|
+
flexDirection: "row",
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
export default withTheme(TableRow);
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleProp, ViewStyle, StyleSheet } from "react-native";
|
|
3
|
+
import {
|
|
4
|
+
generateBorderStyles,
|
|
5
|
+
TableProps,
|
|
6
|
+
TableStyleContext,
|
|
7
|
+
TableStyleProps,
|
|
8
|
+
} from "./TableCommon";
|
|
9
|
+
import { Theme } from "../../styles/DefaultTheme";
|
|
10
|
+
import { withTheme } from "../../theming";
|
|
11
|
+
|
|
12
|
+
export interface Props extends TableProps {
|
|
13
|
+
isTableHeader?: boolean;
|
|
14
|
+
style?: StyleProp<ViewStyle>;
|
|
15
|
+
theme: Theme;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const TableRow: React.FC<React.PropsWithChildren<Props>> = ({
|
|
19
|
+
borderWidth,
|
|
20
|
+
borderColor,
|
|
21
|
+
borderStyle,
|
|
22
|
+
drawTopBorder = false,
|
|
23
|
+
drawBottomBorder = true,
|
|
24
|
+
drawStartBorder = true,
|
|
25
|
+
drawEndBorder = false,
|
|
26
|
+
cellVerticalPadding,
|
|
27
|
+
cellHorizontalPadding,
|
|
28
|
+
isTableHeader = false,
|
|
29
|
+
children,
|
|
30
|
+
style,
|
|
31
|
+
theme,
|
|
32
|
+
}) => {
|
|
33
|
+
const parentContextValue = React.useContext(TableStyleContext);
|
|
34
|
+
|
|
35
|
+
//Create context to use and pass to children based on own props or fall back to parent provided context
|
|
36
|
+
const contextValue: TableStyleProps = {
|
|
37
|
+
borderColor: borderColor || parentContextValue.borderColor,
|
|
38
|
+
borderStyle: borderStyle || parentContextValue.borderStyle,
|
|
39
|
+
borderWidth: borderWidth || parentContextValue.borderWidth,
|
|
40
|
+
cellHorizontalPadding:
|
|
41
|
+
cellHorizontalPadding || parentContextValue.cellHorizontalPadding,
|
|
42
|
+
cellVerticalPadding:
|
|
43
|
+
cellVerticalPadding || parentContextValue.cellVerticalPadding,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const borderViewStyle = generateBorderStyles({
|
|
47
|
+
borderColor: contextValue.borderColor,
|
|
48
|
+
borderWidth: contextValue.borderWidth,
|
|
49
|
+
borderStyle: contextValue.borderStyle,
|
|
50
|
+
drawTopBorder,
|
|
51
|
+
drawBottomBorder,
|
|
52
|
+
drawStartBorder,
|
|
53
|
+
drawEndBorder,
|
|
54
|
+
});
|
|
55
|
+
return (
|
|
56
|
+
<TableStyleContext.Provider value={contextValue}>
|
|
57
|
+
<View
|
|
58
|
+
style={[
|
|
59
|
+
borderViewStyle,
|
|
60
|
+
isTableHeader ? { backgroundColor: theme.colors.primary } : {},
|
|
61
|
+
style,
|
|
62
|
+
styles.cellsContainer,
|
|
63
|
+
]}
|
|
64
|
+
>
|
|
65
|
+
{children}
|
|
66
|
+
</View>
|
|
67
|
+
</TableStyleContext.Provider>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const styles = StyleSheet.create({
|
|
72
|
+
cellsContainer: {
|
|
73
|
+
flexDirection: "row",
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
export default withTheme(TableRow);
|
package/src/index.js
CHANGED
|
@@ -10,7 +10,6 @@ export { default as AvatarEdit } from "./components/AvatarEdit";
|
|
|
10
10
|
export { default as Card } from "./components/Card";
|
|
11
11
|
export { Checkbox, CheckboxGroup, CheckboxRow } from "./components/Checkbox";
|
|
12
12
|
export { default as CircleImage } from "./components/CircleImage";
|
|
13
|
-
export { default as Container } from "./components/Container";
|
|
14
13
|
export { default as Divider } from "./components/Divider";
|
|
15
14
|
export { default as FAB } from "./components/FAB";
|
|
16
15
|
export { default as FieldSearchBarFull } from "./components/FieldSearchBarFull";
|
|
@@ -37,14 +36,12 @@ export { TabView, TabViewItem } from "./components/TabView";
|
|
|
37
36
|
export { default as Markdown } from "./components/Markdown";
|
|
38
37
|
export { BottomSheet } from "./components/BottomSheet";
|
|
39
38
|
export { YoutubePlayer } from "./components/YoutubePlayer";
|
|
39
|
+
export { Table, TableRow, TableCell } from "./components/Table";
|
|
40
40
|
/* Deprecated: Fix or Delete! */
|
|
41
41
|
export { default as DatePicker } from "./components/DatePicker/DatePicker";
|
|
42
42
|
export { default as Picker } from "./components/Picker/Picker";
|
|
43
43
|
export { default as ProgressBar } from "./components/ProgressBar";
|
|
44
44
|
export { default as ProgressCircle } from "./components/ProgressCircle";
|
|
45
|
-
export { default as RowBodyIcon } from "./components/RowBodyIcon";
|
|
46
|
-
export { default as RowHeadlineImageCaption } from "./components/RowHeadlineImageCaption";
|
|
47
|
-
export { default as RowHeadlineImageIcon } from "./components/RowHeadlineImageIcon";
|
|
48
45
|
export { default as Slider } from "./components/Slider";
|
|
49
46
|
export { default as Stepper } from "./components/Stepper";
|
|
50
47
|
export { useAuthState } from "./components/useAuthState";
|
package/src/index.tsx
CHANGED
|
@@ -11,7 +11,6 @@ export { default as AvatarEdit } from "./components/AvatarEdit";
|
|
|
11
11
|
export { default as Card } from "./components/Card";
|
|
12
12
|
export { Checkbox, CheckboxGroup, CheckboxRow } from "./components/Checkbox";
|
|
13
13
|
export { default as CircleImage } from "./components/CircleImage";
|
|
14
|
-
export { default as Container } from "./components/Container";
|
|
15
14
|
export { default as Divider } from "./components/Divider";
|
|
16
15
|
export { default as FAB } from "./components/FAB";
|
|
17
16
|
export { default as FieldSearchBarFull } from "./components/FieldSearchBarFull";
|
|
@@ -62,14 +61,13 @@ export { BottomSheet } from "./components/BottomSheet";
|
|
|
62
61
|
|
|
63
62
|
export { YoutubePlayer } from "./components/YoutubePlayer";
|
|
64
63
|
|
|
64
|
+
export { Table, TableRow, TableCell } from "./components/Table";
|
|
65
|
+
|
|
65
66
|
/* Deprecated: Fix or Delete! */
|
|
66
67
|
export { default as DatePicker } from "./components/DatePicker/DatePicker";
|
|
67
68
|
export { default as Picker } from "./components/Picker/Picker";
|
|
68
69
|
export { default as ProgressBar } from "./components/ProgressBar";
|
|
69
70
|
export { default as ProgressCircle } from "./components/ProgressCircle";
|
|
70
|
-
export { default as RowBodyIcon } from "./components/RowBodyIcon";
|
|
71
|
-
export { default as RowHeadlineImageCaption } from "./components/RowHeadlineImageCaption";
|
|
72
|
-
export { default as RowHeadlineImageIcon } from "./components/RowHeadlineImageIcon";
|
|
73
71
|
export { default as Slider } from "./components/Slider";
|
|
74
72
|
export { default as Stepper } from "./components/Stepper";
|
|
75
73
|
export { useAuthState } from "./components/useAuthState";
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { COMPONENT_TYPES, createBoolProp, CONTAINER_COMPONENT_STYLES_SECTIONS, createStaticNumberProp, StylesPanelSections, createStaticBoolProp, } from "@draftbit/types";
|
|
2
|
+
const SHARED_SEED_DATA = {
|
|
3
|
+
category: COMPONENT_TYPES.layout,
|
|
4
|
+
packageName: "native-base",
|
|
5
|
+
stylesPanelSections: CONTAINER_COMPONENT_STYLES_SECTIONS,
|
|
6
|
+
};
|
|
7
|
+
const CONTAINER_COMPONENT_STYLES_WITHOUT_FLEX = CONTAINER_COMPONENT_STYLES_SECTIONS.filter((item) => item !== StylesPanelSections.LayoutFlexItems &&
|
|
8
|
+
item !== StylesPanelSections.LayoutContent);
|
|
9
|
+
export const SEED_DATA = [
|
|
10
|
+
{
|
|
11
|
+
name: "Aspect Ratio",
|
|
12
|
+
tag: "AspectRatio",
|
|
13
|
+
description: "Controls the size of the undefined dimension of a node or child component using an aspect ratio",
|
|
14
|
+
...SHARED_SEED_DATA,
|
|
15
|
+
props: {
|
|
16
|
+
ratio: createStaticNumberProp({
|
|
17
|
+
label: "Ratio",
|
|
18
|
+
description: "The aspect ratio of the container in decimal format (ex: 3/4 -> 1.33)",
|
|
19
|
+
defaultValue: 1.33,
|
|
20
|
+
}),
|
|
21
|
+
},
|
|
22
|
+
stylesPanelSections: [
|
|
23
|
+
StylesPanelSections.Background,
|
|
24
|
+
StylesPanelSections.Size,
|
|
25
|
+
StylesPanelSections.Margins,
|
|
26
|
+
StylesPanelSections.Position,
|
|
27
|
+
StylesPanelSections.Borders,
|
|
28
|
+
StylesPanelSections.Effects,
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "Box",
|
|
33
|
+
tag: "Box",
|
|
34
|
+
description: "This is a generic component for low level layout needs. It is similar to a div in HTML",
|
|
35
|
+
...SHARED_SEED_DATA,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "Center",
|
|
39
|
+
tag: "Center",
|
|
40
|
+
description: "Center aligns its contents to the center within itself",
|
|
41
|
+
...SHARED_SEED_DATA,
|
|
42
|
+
stylesPanelSections: CONTAINER_COMPONENT_STYLES_WITHOUT_FLEX,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "Circle",
|
|
46
|
+
tag: "Circle",
|
|
47
|
+
description: "Center aligns its contents to the center within itself with a round border radius",
|
|
48
|
+
...SHARED_SEED_DATA,
|
|
49
|
+
stylesPanelSections: CONTAINER_COMPONENT_STYLES_WITHOUT_FLEX,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "Container",
|
|
53
|
+
tag: "Container",
|
|
54
|
+
description: "The Container restricts a content's width according to current breakpoint, while keeping the size fluid",
|
|
55
|
+
props: {
|
|
56
|
+
centerContent: createStaticBoolProp({
|
|
57
|
+
label: "Center content",
|
|
58
|
+
description: "Center child elements based on their content width",
|
|
59
|
+
defaultValue: true,
|
|
60
|
+
}),
|
|
61
|
+
},
|
|
62
|
+
...SHARED_SEED_DATA,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "Column",
|
|
66
|
+
tag: "Column",
|
|
67
|
+
description: "Column aligns items vertically",
|
|
68
|
+
layout: {
|
|
69
|
+
flexDirection: "column",
|
|
70
|
+
},
|
|
71
|
+
...SHARED_SEED_DATA,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "Row",
|
|
75
|
+
tag: "Row",
|
|
76
|
+
description: "Column aligns items horizontally",
|
|
77
|
+
layout: {
|
|
78
|
+
flexDirection: "row",
|
|
79
|
+
},
|
|
80
|
+
...SHARED_SEED_DATA,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "Spacer",
|
|
84
|
+
tag: "Spacer",
|
|
85
|
+
description: "An adjustable, empty space that can be used to tune the spacing between child elements within Flex",
|
|
86
|
+
layout: {
|
|
87
|
+
flex: 1,
|
|
88
|
+
},
|
|
89
|
+
...SHARED_SEED_DATA,
|
|
90
|
+
stylesPanelSections: [
|
|
91
|
+
StylesPanelSections.LayoutSelectedItem,
|
|
92
|
+
StylesPanelSections.Background,
|
|
93
|
+
StylesPanelSections.Margins,
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: "Stack",
|
|
98
|
+
tag: "Stack",
|
|
99
|
+
description: "Stack aligns items vertically or horizontally based on the direction prop",
|
|
100
|
+
...SHARED_SEED_DATA,
|
|
101
|
+
props: {
|
|
102
|
+
isDisabled: createBoolProp({
|
|
103
|
+
label: "Disabled",
|
|
104
|
+
description: "If true, the Stack will be disabled",
|
|
105
|
+
}),
|
|
106
|
+
isInvalid: createBoolProp({
|
|
107
|
+
label: "Invalid",
|
|
108
|
+
description: "If true, the Stack will be invalid",
|
|
109
|
+
}),
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: "ZStack",
|
|
114
|
+
tag: "ZStack",
|
|
115
|
+
description: "ZStack aligns items to the z-axis",
|
|
116
|
+
...SHARED_SEED_DATA,
|
|
117
|
+
props: {
|
|
118
|
+
reversed: createBoolProp({
|
|
119
|
+
label: "Reversed",
|
|
120
|
+
description: "Determines whether to reverse the direction of items",
|
|
121
|
+
}),
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
];
|