@draftbit/core 46.10.3-6f5759.2 → 46.10.3-7476ab.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 +12 -1
- package/lib/commonjs/components/AspectRatio.js +17 -1
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +22 -4
- package/lib/commonjs/components/Button.js +33 -10
- package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js +23 -5
- package/lib/commonjs/components/Checkbox/CheckboxRow.js +6 -23
- package/lib/commonjs/components/Checkbox/context.js +1 -1
- package/lib/commonjs/components/CircleImage.js +15 -1
- package/lib/commonjs/components/CircularProgress.js +26 -8
- package/lib/commonjs/components/DatePicker/DatePicker.js +26 -13
- package/lib/commonjs/components/Divider.js +14 -1
- package/lib/commonjs/components/Elevation.js +14 -2
- package/lib/commonjs/components/Image.js +17 -2
- package/lib/commonjs/components/Picker/PickerComponent.android.js +20 -3
- package/lib/commonjs/components/Portal/PortalHost.js +44 -15
- package/lib/commonjs/components/RadioButton/RadioButton.js +13 -2
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js +23 -5
- package/lib/commonjs/components/RadioButton/context.js +1 -1
- package/lib/commonjs/components/Shadow.js +15 -2
- package/lib/commonjs/components/StarRating.js +23 -4
- package/lib/commonjs/components/Switch.js +19 -10
- 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/constants.js +1 -1
- package/lib/commonjs/index.js +19 -7
- package/lib/commonjs/mappings/FieldSearchBarFull.js +3 -1
- package/lib/commonjs/mappings/NativeBase/Layout.js +13 -12
- package/lib/commonjs/mappings/StarRating.js +6 -2
- package/lib/commonjs/mappings/Table.js +140 -0
- package/lib/module/components/AspectRatio.js +18 -1
- package/lib/module/components/BottomSheet/BottomSheet.js +24 -4
- package/lib/module/components/Button.js +33 -10
- package/lib/module/components/Checkbox/Checkbox.js +3 -4
- package/lib/module/components/Checkbox/CheckboxRow.js +24 -6
- package/lib/module/components/Checkbox/context.js +1 -1
- package/lib/module/components/DatePicker/DatePicker.js +27 -13
- package/lib/module/components/DeckSwiper/DeckSwiper.js +1 -4
- package/lib/module/components/DeprecatedButton.js +21 -3
- package/lib/module/components/Divider.js +18 -1
- package/lib/module/components/FormRow.js +17 -2
- package/lib/module/components/NumberInput.js +11 -3
- package/lib/module/components/Picker/PickerComponent.android.js +21 -3
- package/lib/module/components/Portal/PortalHost.js +45 -15
- package/lib/module/components/RadioButton/RadioButtonFieldGroup.js +10 -1
- package/lib/module/components/Shadow.js +15 -2
- package/lib/module/components/StarRating.js +24 -4
- package/lib/module/components/StepIndicator.js +58 -18
- package/lib/module/components/TabView/TabView.js +17 -7
- package/lib/module/components/Table/Table.js +115 -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 +52 -0
- package/lib/module/components/Table/index.js +3 -0
- package/lib/module/constants.js +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/mappings/FieldSearchBarFull.js +4 -1
- package/lib/module/mappings/NativeBase/Layout.js +14 -13
- package/lib/module/mappings/StarRating.js +7 -2
- package/lib/module/mappings/Table.js +133 -0
- package/lib/module/utilities.js +1 -2
- 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 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mappings/NativeBase/Layout.d.ts +36 -20
- package/lib/typescript/src/mappings/NativeBase/Layout.d.ts.map +1 -1
- 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 -1
- package/src/index.tsx +2 -1
- package/src/mappings/NativeBase/Layout.js +24 -12
- package/src/mappings/NativeBase/Layout.ts +24 -12
- package/src/mappings/Table.js +150 -0
- package/src/mappings/Table.ts +170 -0
- package/lib/commonjs/components/Container.js +0 -93
- 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/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/HeaderLarge.js +0 -34
- package/lib/commonjs/mappings/HeaderMedium.js +0 -60
- package/lib/commonjs/mappings/HeaderOverline.js +0 -60
- 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/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/HeaderLarge.js +0 -27
- package/lib/module/mappings/HeaderMedium.js +0 -53
- package/lib/module/mappings/HeaderOverline.js +0 -53
- 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/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/HeaderLarge.d.ts +0 -34
- package/lib/typescript/src/mappings/HeaderLarge.d.ts.map +0 -1
- package/lib/typescript/src/mappings/HeaderMedium.d.ts +0 -53
- package/lib/typescript/src/mappings/HeaderMedium.d.ts.map +0 -1
- package/lib/typescript/src/mappings/HeaderOverline.d.ts +0 -53
- package/lib/typescript/src/mappings/HeaderOverline.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/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/HeaderLarge.js +0 -29
- package/src/mappings/HeaderLarge.ts +0 -38
- package/src/mappings/HeaderMedium.js +0 -55
- package/src/mappings/HeaderMedium.ts +0 -63
- package/src/mappings/HeaderOverline.js +0 -55
- package/src/mappings/HeaderOverline.ts +0 -63
- 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,6 +36,7 @@ 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";
|
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,6 +61,8 @@ 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";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { COMPONENT_TYPES,
|
|
1
|
+
import { COMPONENT_TYPES, createBoolProp, CONTAINER_COMPONENT_STYLES_SECTIONS, createStaticNumberProp, StylesPanelSections, createStaticBoolProp, } from "@draftbit/types";
|
|
2
2
|
const SHARED_SEED_DATA = {
|
|
3
3
|
category: COMPONENT_TYPES.layout,
|
|
4
4
|
packageName: "native-base",
|
|
@@ -19,6 +19,14 @@ export const SEED_DATA = [
|
|
|
19
19
|
defaultValue: 1.33,
|
|
20
20
|
}),
|
|
21
21
|
},
|
|
22
|
+
stylesPanelSections: [
|
|
23
|
+
StylesPanelSections.Background,
|
|
24
|
+
StylesPanelSections.Size,
|
|
25
|
+
StylesPanelSections.Margins,
|
|
26
|
+
StylesPanelSections.Position,
|
|
27
|
+
StylesPanelSections.Borders,
|
|
28
|
+
StylesPanelSections.Effects,
|
|
29
|
+
],
|
|
22
30
|
},
|
|
23
31
|
{
|
|
24
32
|
name: "Box",
|
|
@@ -44,6 +52,13 @@ export const SEED_DATA = [
|
|
|
44
52
|
name: "Container",
|
|
45
53
|
tag: "Container",
|
|
46
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
|
+
},
|
|
47
62
|
...SHARED_SEED_DATA,
|
|
48
63
|
},
|
|
49
64
|
{
|
|
@@ -68,8 +83,15 @@ export const SEED_DATA = [
|
|
|
68
83
|
name: "Spacer",
|
|
69
84
|
tag: "Spacer",
|
|
70
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
|
+
},
|
|
71
89
|
...SHARED_SEED_DATA,
|
|
72
|
-
stylesPanelSections:
|
|
90
|
+
stylesPanelSections: [
|
|
91
|
+
StylesPanelSections.LayoutSelectedItem,
|
|
92
|
+
StylesPanelSections.Background,
|
|
93
|
+
StylesPanelSections.Margins,
|
|
94
|
+
],
|
|
73
95
|
},
|
|
74
96
|
{
|
|
75
97
|
name: "Stack",
|
|
@@ -77,16 +99,6 @@ export const SEED_DATA = [
|
|
|
77
99
|
description: "Stack aligns items vertically or horizontally based on the direction prop",
|
|
78
100
|
...SHARED_SEED_DATA,
|
|
79
101
|
props: {
|
|
80
|
-
direction: createTextEnumProp({
|
|
81
|
-
label: "Direction",
|
|
82
|
-
description: "The direction of the Stack",
|
|
83
|
-
options: ["row", "column"],
|
|
84
|
-
defaultValue: "column",
|
|
85
|
-
}),
|
|
86
|
-
reversed: createBoolProp({
|
|
87
|
-
label: "Reversed",
|
|
88
|
-
description: "Determines whether to reverse the direction of items",
|
|
89
|
-
}),
|
|
90
102
|
isDisabled: createBoolProp({
|
|
91
103
|
label: "Disabled",
|
|
92
104
|
description: "If true, the Stack will be disabled",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
COMPONENT_TYPES,
|
|
3
|
-
createTextEnumProp,
|
|
4
3
|
createBoolProp,
|
|
5
4
|
CONTAINER_COMPONENT_STYLES_SECTIONS,
|
|
6
5
|
createStaticNumberProp,
|
|
7
6
|
StylesPanelSections,
|
|
7
|
+
createStaticBoolProp,
|
|
8
8
|
} from "@draftbit/types";
|
|
9
9
|
|
|
10
10
|
const SHARED_SEED_DATA = {
|
|
@@ -35,6 +35,14 @@ export const SEED_DATA = [
|
|
|
35
35
|
defaultValue: 1.33,
|
|
36
36
|
}),
|
|
37
37
|
},
|
|
38
|
+
stylesPanelSections: [
|
|
39
|
+
StylesPanelSections.Background,
|
|
40
|
+
StylesPanelSections.Size,
|
|
41
|
+
StylesPanelSections.Margins,
|
|
42
|
+
StylesPanelSections.Position,
|
|
43
|
+
StylesPanelSections.Borders,
|
|
44
|
+
StylesPanelSections.Effects,
|
|
45
|
+
],
|
|
38
46
|
},
|
|
39
47
|
{
|
|
40
48
|
name: "Box",
|
|
@@ -63,6 +71,13 @@ export const SEED_DATA = [
|
|
|
63
71
|
tag: "Container",
|
|
64
72
|
description:
|
|
65
73
|
"The Container restricts a content's width according to current breakpoint, while keeping the size fluid",
|
|
74
|
+
props: {
|
|
75
|
+
centerContent: createStaticBoolProp({
|
|
76
|
+
label: "Center content",
|
|
77
|
+
description: "Center child elements based on their content width",
|
|
78
|
+
defaultValue: true,
|
|
79
|
+
}),
|
|
80
|
+
},
|
|
66
81
|
...SHARED_SEED_DATA,
|
|
67
82
|
},
|
|
68
83
|
{
|
|
@@ -88,8 +103,15 @@ export const SEED_DATA = [
|
|
|
88
103
|
tag: "Spacer",
|
|
89
104
|
description:
|
|
90
105
|
"An adjustable, empty space that can be used to tune the spacing between child elements within Flex",
|
|
106
|
+
layout: {
|
|
107
|
+
flex: 1,
|
|
108
|
+
},
|
|
91
109
|
...SHARED_SEED_DATA,
|
|
92
|
-
stylesPanelSections:
|
|
110
|
+
stylesPanelSections: [
|
|
111
|
+
StylesPanelSections.LayoutSelectedItem,
|
|
112
|
+
StylesPanelSections.Background,
|
|
113
|
+
StylesPanelSections.Margins,
|
|
114
|
+
],
|
|
93
115
|
},
|
|
94
116
|
{
|
|
95
117
|
name: "Stack",
|
|
@@ -98,16 +120,6 @@ export const SEED_DATA = [
|
|
|
98
120
|
"Stack aligns items vertically or horizontally based on the direction prop",
|
|
99
121
|
...SHARED_SEED_DATA,
|
|
100
122
|
props: {
|
|
101
|
-
direction: createTextEnumProp({
|
|
102
|
-
label: "Direction",
|
|
103
|
-
description: "The direction of the Stack",
|
|
104
|
-
options: ["row", "column"],
|
|
105
|
-
defaultValue: "column",
|
|
106
|
-
}),
|
|
107
|
-
reversed: createBoolProp({
|
|
108
|
-
label: "Reversed",
|
|
109
|
-
description: "Determines whether to reverse the direction of items",
|
|
110
|
-
}),
|
|
111
123
|
isDisabled: createBoolProp({
|
|
112
124
|
label: "Disabled",
|
|
113
125
|
description: "If true, the Stack will be disabled",
|