@draftbit/core 46.10.3-0bad1e.2 → 46.10.3-106fd0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/lib/commonjs/components/Checkbox/CheckboxRow.js +6 -23
  2. package/lib/commonjs/components/FAB.js +4 -18
  3. package/lib/commonjs/components/Table/Table.js +122 -0
  4. package/lib/commonjs/components/Table/TableCell.js +49 -0
  5. package/lib/commonjs/components/Table/TableRow.js +61 -0
  6. package/lib/commonjs/components/Table/index.js +51 -0
  7. package/lib/commonjs/constants.js +1 -1
  8. package/lib/commonjs/index.js +19 -7
  9. package/lib/commonjs/mappings/NativeBase/Layout.js +25 -14
  10. package/lib/commonjs/mappings/Table.js +140 -0
  11. package/lib/module/components/AspectRatio.js +18 -1
  12. package/lib/module/components/Checkbox/CheckboxGroup.js +16 -2
  13. package/lib/module/components/Checkbox/context.js +1 -1
  14. package/lib/module/components/CircleImage.js +16 -1
  15. package/lib/module/components/DeprecatedButton.js +21 -3
  16. package/lib/module/components/IconButton.js +21 -4
  17. package/lib/module/components/Pressable.js +15 -2
  18. package/lib/module/components/Shadow.js +15 -2
  19. package/lib/module/components/Table/Table.js +114 -0
  20. package/lib/module/components/Table/TableCell.js +41 -0
  21. package/lib/module/components/Table/TableRow.js +52 -0
  22. package/lib/module/components/Table/index.js +24 -0
  23. package/lib/module/components/ToggleButton.js +16 -2
  24. package/lib/module/constants.js +1 -0
  25. package/lib/module/index.js +1 -1
  26. package/lib/module/mappings/NativeBase/Layout.js +26 -15
  27. package/lib/module/mappings/Table.js +133 -0
  28. package/lib/typescript/src/components/Table/Table.d.ts +14 -0
  29. package/lib/typescript/src/components/Table/Table.d.ts.map +1 -0
  30. package/lib/typescript/src/components/Table/TableCell.d.ts +9 -0
  31. package/lib/typescript/src/components/Table/TableCell.d.ts.map +1 -0
  32. package/lib/typescript/src/components/{DeprecatedCardWrapper.d.ts → Table/TableRow.d.ts} +7 -8
  33. package/lib/typescript/src/components/Table/TableRow.d.ts.map +1 -0
  34. package/lib/typescript/src/components/Table/index.d.ts +22 -0
  35. package/lib/typescript/src/components/Table/index.d.ts.map +1 -0
  36. package/lib/typescript/src/index.d.ts +1 -1
  37. package/lib/typescript/src/index.d.ts.map +1 -1
  38. package/lib/typescript/src/mappings/NativeBase/Layout.d.ts +42 -16
  39. package/lib/typescript/src/mappings/NativeBase/Layout.d.ts.map +1 -1
  40. package/lib/typescript/src/mappings/{CardBlock.d.ts → Table.d.ts} +129 -81
  41. package/lib/typescript/src/mappings/Table.d.ts.map +1 -0
  42. package/package.json +3 -3
  43. package/src/components/Table/Table.js +91 -0
  44. package/src/components/Table/Table.tsx +170 -0
  45. package/src/components/Table/TableCell.js +31 -0
  46. package/src/components/Table/TableCell.tsx +59 -0
  47. package/src/components/Table/TableRow.js +37 -0
  48. package/src/components/Table/TableRow.tsx +77 -0
  49. package/src/components/Table/index.js +15 -0
  50. package/src/components/Table/index.tsx +44 -0
  51. package/src/index.js +1 -1
  52. package/src/index.tsx +2 -1
  53. package/src/mappings/NativeBase/Layout.js +34 -11
  54. package/src/mappings/NativeBase/Layout.ts +40 -11
  55. package/src/mappings/Table.js +150 -0
  56. package/src/mappings/Table.ts +170 -0
  57. package/lib/commonjs/components/Container.js +0 -93
  58. package/lib/commonjs/components/DeprecatedCardWrapper.js +0 -40
  59. package/lib/commonjs/components/DeprecatedFAB.js +0 -157
  60. package/lib/commonjs/components/ProgressIndicator.js +0 -55
  61. package/lib/commonjs/components/ResizeMode.js +0 -5
  62. package/lib/commonjs/mappings/CardBlock.js +0 -126
  63. package/lib/commonjs/mappings/CardContainer.js +0 -108
  64. package/lib/commonjs/mappings/CardContainerRating.js +0 -130
  65. package/lib/commonjs/mappings/CardContainerShortImage.js +0 -124
  66. package/lib/commonjs/mappings/CardInline.js +0 -59
  67. package/lib/commonjs/mappings/Container.js +0 -37
  68. package/lib/commonjs/mappings/ProgressIndicator.js +0 -188
  69. package/lib/module/components/Container.js +0 -83
  70. package/lib/module/components/DeprecatedCardWrapper.js +0 -32
  71. package/lib/module/components/DeprecatedFAB.js +0 -147
  72. package/lib/module/components/ProgressIndicator.js +0 -45
  73. package/lib/module/components/ResizeMode.js +0 -1
  74. package/lib/module/mappings/CardBlock.js +0 -119
  75. package/lib/module/mappings/CardContainer.js +0 -101
  76. package/lib/module/mappings/CardContainerRating.js +0 -123
  77. package/lib/module/mappings/CardContainerShortImage.js +0 -117
  78. package/lib/module/mappings/CardInline.js +0 -52
  79. package/lib/module/mappings/Container.js +0 -30
  80. package/lib/module/mappings/ProgressIndicator.js +0 -181
  81. package/lib/typescript/src/components/Container.d.ts +0 -21
  82. package/lib/typescript/src/components/Container.d.ts.map +0 -1
  83. package/lib/typescript/src/components/DeprecatedCardWrapper.d.ts.map +0 -1
  84. package/lib/typescript/src/components/DeprecatedFAB.d.ts +0 -56
  85. package/lib/typescript/src/components/DeprecatedFAB.d.ts.map +0 -1
  86. package/lib/typescript/src/components/ProgressIndicator.d.ts +0 -24
  87. package/lib/typescript/src/components/ProgressIndicator.d.ts.map +0 -1
  88. package/lib/typescript/src/components/ResizeMode.d.ts +0 -2
  89. package/lib/typescript/src/components/ResizeMode.d.ts.map +0 -1
  90. package/lib/typescript/src/mappings/CardBlock.d.ts.map +0 -1
  91. package/lib/typescript/src/mappings/CardContainer.d.ts +0 -102
  92. package/lib/typescript/src/mappings/CardContainer.d.ts.map +0 -1
  93. package/lib/typescript/src/mappings/CardContainerRating.d.ts +0 -108
  94. package/lib/typescript/src/mappings/CardContainerRating.d.ts.map +0 -1
  95. package/lib/typescript/src/mappings/CardContainerShortImage.d.ts +0 -139
  96. package/lib/typescript/src/mappings/CardContainerShortImage.d.ts.map +0 -1
  97. package/lib/typescript/src/mappings/CardInline.d.ts +0 -62
  98. package/lib/typescript/src/mappings/CardInline.d.ts.map +0 -1
  99. package/lib/typescript/src/mappings/Container.d.ts +0 -55
  100. package/lib/typescript/src/mappings/Container.d.ts.map +0 -1
  101. package/lib/typescript/src/mappings/ProgressIndicator.d.ts +0 -181
  102. package/lib/typescript/src/mappings/ProgressIndicator.d.ts.map +0 -1
  103. package/src/components/Container.js +0 -43
  104. package/src/components/Container.tsx +0 -116
  105. package/src/components/DeprecatedCardWrapper.js +0 -18
  106. package/src/components/DeprecatedCardWrapper.tsx +0 -46
  107. package/src/components/DeprecatedFAB.js +0 -114
  108. package/src/components/DeprecatedFAB.tsx +0 -231
  109. package/src/components/ProgressIndicator.js +0 -27
  110. package/src/components/ProgressIndicator.tsx +0 -71
  111. package/src/components/ResizeMode.js +0 -1
  112. package/src/components/ResizeMode.ts +0 -7
  113. package/src/mappings/CardBlock.js +0 -123
  114. package/src/mappings/CardBlock.ts +0 -136
  115. package/src/mappings/CardContainer.js +0 -104
  116. package/src/mappings/CardContainer.ts +0 -116
  117. package/src/mappings/CardContainerRating.js +0 -126
  118. package/src/mappings/CardContainerRating.ts +0 -137
  119. package/src/mappings/CardContainerShortImage.js +0 -120
  120. package/src/mappings/CardContainerShortImage.ts +0 -130
  121. package/src/mappings/CardInline.js +0 -52
  122. package/src/mappings/CardInline.ts +0 -61
  123. package/src/mappings/Container.js +0 -30
  124. package/src/mappings/Container.ts +0 -41
  125. package/src/mappings/ProgressIndicator.js +0 -181
  126. package/src/mappings/ProgressIndicator.ts +0 -190
@@ -0,0 +1,170 @@
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 {
11
+ generateBorderStyles,
12
+ TableProps,
13
+ TableStyleContext,
14
+ TableStyleProps,
15
+ } from "./index";
16
+
17
+ export interface Props<T> extends TableProps, ScrollViewProps {
18
+ data?: Array<T>;
19
+ keyExtractor?: (item: T, index: number) => string;
20
+ renderItem?: ({ item, index }: { item: T; index: number }) => JSX.Element;
21
+ style?: StyleProp<ViewStyle>;
22
+ }
23
+
24
+ export const Table = <T extends object>({
25
+ borderWidth = 1,
26
+ borderColor = "rgba(200, 200, 200, 1)",
27
+ borderStyle = "solid",
28
+ drawTopBorder = true,
29
+ drawBottomBorder = false,
30
+ drawStartBorder = false,
31
+ drawEndBorder = false,
32
+ cellVerticalPadding = 10,
33
+ cellHorizontalPadding = 10,
34
+ data,
35
+ keyExtractor,
36
+ renderItem,
37
+ children: childrenProp,
38
+ style,
39
+ ...rest
40
+ }: React.PropsWithChildren<Props<T>>) => {
41
+ //Both 'renderItem' and 'data' are optional to allow direct children. But if one is included, both need to be included
42
+ if ((data && !renderItem) || (renderItem && !data)) {
43
+ throw new Error(
44
+ "'renderItem' and 'data' need to both be provided to render from 'data'. Either remove them entirley or include both"
45
+ );
46
+ }
47
+
48
+ if (data && renderItem && childrenProp) {
49
+ console.warn(
50
+ "'children' of Table ignored due to usage of 'data' and 'renderItem'"
51
+ );
52
+ }
53
+
54
+ const isTableHeader = React.useCallback((object: any): boolean => {
55
+ return object.isTableHeader;
56
+ }, []);
57
+
58
+ const isRenderItem = data && renderItem;
59
+
60
+ //Uses 'renderItem' and 'data' to create an array of children
61
+ const dataAsChildren = React.useMemo(() => {
62
+ if (!isRenderItem) return [];
63
+
64
+ return data.map((item, index) => {
65
+ const component = renderItem({ item, index });
66
+
67
+ if (!component) {
68
+ return null;
69
+ }
70
+
71
+ const key = keyExtractor ? keyExtractor(item, index) : index.toString();
72
+ return React.cloneElement(component, {
73
+ key,
74
+ });
75
+ });
76
+ }, [data, renderItem, keyExtractor, isRenderItem]);
77
+
78
+ const children = isRenderItem
79
+ ? dataAsChildren
80
+ : React.Children.toArray(childrenProp);
81
+
82
+ const validChildren = React.useMemo(
83
+ () =>
84
+ (children as any[]).filter((item) =>
85
+ React.isValidElement(item)
86
+ ) as React.ReactElement[],
87
+ [children]
88
+ );
89
+
90
+ const childrenWithoutHeader = React.useMemo(() => {
91
+ const flattenedWithoutNestedHeaders = validChildren.map((item) => {
92
+ const nestedChildren = React.Children.toArray(
93
+ item.props.children
94
+ ) as any[];
95
+ //Header can be nested in React.Fragment when in renderItem
96
+ const nestedHeaders = nestedChildren.filter((child: any) =>
97
+ isTableHeader(child.props)
98
+ );
99
+ if (nestedHeaders?.length) {
100
+ //New element excluding header children
101
+ return React.cloneElement(item, {
102
+ children: nestedChildren.filter(
103
+ (child: any) => !isTableHeader(child.props)
104
+ ),
105
+ });
106
+ }
107
+ return item;
108
+ });
109
+
110
+ return flattenedWithoutNestedHeaders.filter(
111
+ (item) => !isTableHeader(item.props)
112
+ );
113
+ }, [validChildren, isTableHeader]);
114
+
115
+ const header = React.useMemo(() => {
116
+ const flattenedPossibleHeaders = validChildren.map((item) => {
117
+ const nestedChildren = React.Children.toArray(
118
+ item.props.children
119
+ ) as any[];
120
+ //Header can be nested in React.Fragment when in renderItem
121
+ const nestedHeaders = nestedChildren.filter((child: any) =>
122
+ isTableHeader(child.props)
123
+ );
124
+ if (nestedHeaders?.length) {
125
+ return nestedHeaders[0];
126
+ }
127
+ return item;
128
+ });
129
+ const allHeaders = flattenedPossibleHeaders.filter((item) =>
130
+ isTableHeader(item.props)
131
+ );
132
+ if (allHeaders.length) {
133
+ return allHeaders[0]; //Only 1 header taken
134
+ }
135
+ return null;
136
+ }, [validChildren, isTableHeader]);
137
+
138
+ const contextValue: TableStyleProps = {
139
+ borderColor,
140
+ borderStyle,
141
+ borderWidth,
142
+ cellHorizontalPadding,
143
+ cellVerticalPadding,
144
+ };
145
+
146
+ const borderViewStyle = generateBorderStyles({
147
+ borderColor,
148
+ borderWidth,
149
+ borderStyle,
150
+ drawTopBorder,
151
+ drawBottomBorder,
152
+ drawStartBorder,
153
+ drawEndBorder,
154
+ });
155
+
156
+ return (
157
+ <TableStyleContext.Provider value={contextValue}>
158
+ <View style={[styles.container, borderViewStyle, style]}>
159
+ <>{header}</>
160
+ <ScrollView {...rest}>{childrenWithoutHeader}</ScrollView>
161
+ </View>
162
+ </TableStyleContext.Provider>
163
+ );
164
+ };
165
+
166
+ const styles = StyleSheet.create({
167
+ container: {
168
+ flex: 1,
169
+ },
170
+ });
@@ -0,0 +1,31 @@
1
+ import React from "react";
2
+ import { View, StyleSheet } from "react-native";
3
+ import { generateBorderStyles, TableStyleContext } from "./index";
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,59 @@
1
+ import React from "react";
2
+ import { View, StyleProp, ViewStyle, StyleSheet } from "react-native";
3
+ import { generateBorderStyles, TableProps, TableStyleContext } from "./index";
4
+
5
+ export interface Props extends TableProps {
6
+ style?: StyleProp<ViewStyle>;
7
+ }
8
+
9
+ const TableCell: React.FC<React.PropsWithChildren<Props>> = ({
10
+ borderWidth,
11
+ borderColor,
12
+ borderStyle,
13
+ drawTopBorder = false,
14
+ drawBottomBorder = false,
15
+ drawStartBorder = false,
16
+ drawEndBorder = true,
17
+ cellVerticalPadding,
18
+ cellHorizontalPadding,
19
+ children,
20
+ style,
21
+ }) => {
22
+ const parentContextValue = React.useContext(TableStyleContext);
23
+
24
+ const borderViewStyle = generateBorderStyles({
25
+ borderColor: borderColor || parentContextValue.borderColor,
26
+ borderWidth: borderWidth || parentContextValue.borderWidth,
27
+ borderStyle: borderStyle || parentContextValue.borderStyle,
28
+ drawTopBorder,
29
+ drawBottomBorder,
30
+ drawStartBorder,
31
+ drawEndBorder,
32
+ });
33
+ return (
34
+ <View
35
+ style={[
36
+ styles.cellContainer,
37
+ borderViewStyle,
38
+ {
39
+ paddingVertical:
40
+ cellVerticalPadding || parentContextValue.cellVerticalPadding,
41
+ paddingHorizontal:
42
+ cellHorizontalPadding || parentContextValue.cellHorizontalPadding,
43
+ },
44
+ style,
45
+ ]}
46
+ >
47
+ {children}
48
+ </View>
49
+ );
50
+ };
51
+
52
+ const styles = StyleSheet.create({
53
+ cellContainer: {
54
+ flex: 1,
55
+ flexDirection: "row",
56
+ },
57
+ });
58
+
59
+ export default TableCell;
@@ -0,0 +1,37 @@
1
+ import React from "react";
2
+ import { View, StyleSheet } from "react-native";
3
+ import { generateBorderStyles, TableStyleContext, } from "./index";
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 "./index";
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);
@@ -0,0 +1,15 @@
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
+ }
13
+ export { Table } from "./Table";
14
+ export { default as TableRow } from "./TableRow";
15
+ export { default as TableCell } from "./TableCell";
@@ -0,0 +1,44 @@
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
+ }
41
+
42
+ export { Table } from "./Table";
43
+ export { default as TableRow } from "./TableRow";
44
+ export { default as TableCell } from "./TableCell";
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,9 +1,11 @@
1
- import { COMPONENT_TYPES, createTextEnumProp, createBoolProp, CONTAINER_COMPONENT_STYLES_SECTIONS, createStaticNumberProp, } from "@draftbit/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",
5
5
  stylesPanelSections: CONTAINER_COMPONENT_STYLES_SECTIONS,
6
6
  };
7
+ const CONTAINER_COMPONENT_STYLES_WITHOUT_FLEX = CONTAINER_COMPONENT_STYLES_SECTIONS.filter((item) => item !== StylesPanelSections.LayoutFlexItems &&
8
+ item !== StylesPanelSections.LayoutContent);
7
9
  export const SEED_DATA = [
8
10
  {
9
11
  name: "Aspect Ratio",
@@ -17,6 +19,14 @@ export const SEED_DATA = [
17
19
  defaultValue: 1.33,
18
20
  }),
19
21
  },
22
+ stylesPanelSections: [
23
+ StylesPanelSections.Background,
24
+ StylesPanelSections.Size,
25
+ StylesPanelSections.Margins,
26
+ StylesPanelSections.Position,
27
+ StylesPanelSections.Borders,
28
+ StylesPanelSections.Effects,
29
+ ],
20
30
  },
21
31
  {
22
32
  name: "Box",
@@ -29,36 +39,59 @@ export const SEED_DATA = [
29
39
  tag: "Center",
30
40
  description: "Center aligns its contents to the center within itself",
31
41
  ...SHARED_SEED_DATA,
42
+ stylesPanelSections: CONTAINER_COMPONENT_STYLES_WITHOUT_FLEX,
32
43
  },
33
44
  {
34
45
  name: "Circle",
35
46
  tag: "Circle",
36
47
  description: "Center aligns its contents to the center within itself with a round border radius",
37
48
  ...SHARED_SEED_DATA,
49
+ stylesPanelSections: CONTAINER_COMPONENT_STYLES_WITHOUT_FLEX,
38
50
  },
39
51
  {
40
52
  name: "Container",
41
53
  tag: "Container",
42
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
+ },
43
62
  ...SHARED_SEED_DATA,
44
63
  },
45
64
  {
46
65
  name: "Column",
47
66
  tag: "Column",
48
67
  description: "Column aligns items vertically",
68
+ layout: {
69
+ flexDirection: "column",
70
+ },
49
71
  ...SHARED_SEED_DATA,
50
72
  },
51
73
  {
52
74
  name: "Row",
53
75
  tag: "Row",
54
76
  description: "Column aligns items horizontally",
77
+ layout: {
78
+ flexDirection: "row",
79
+ },
55
80
  ...SHARED_SEED_DATA,
56
81
  },
57
82
  {
58
83
  name: "Spacer",
59
84
  tag: "Spacer",
60
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
+ },
61
89
  ...SHARED_SEED_DATA,
90
+ stylesPanelSections: [
91
+ StylesPanelSections.LayoutSelectedItem,
92
+ StylesPanelSections.Background,
93
+ StylesPanelSections.Margins,
94
+ ],
62
95
  },
63
96
  {
64
97
  name: "Stack",
@@ -66,16 +99,6 @@ export const SEED_DATA = [
66
99
  description: "Stack aligns items vertically or horizontally based on the direction prop",
67
100
  ...SHARED_SEED_DATA,
68
101
  props: {
69
- direction: createTextEnumProp({
70
- label: "Direction",
71
- description: "The direction of the Stack",
72
- options: ["row", "column"],
73
- defaultValue: "column",
74
- }),
75
- reversed: createBoolProp({
76
- label: "Reversed",
77
- description: "Determines whether to reverse the direction of items",
78
- }),
79
102
  isDisabled: createBoolProp({
80
103
  label: "Disabled",
81
104
  description: "If true, the Stack will be disabled",
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  COMPONENT_TYPES,
3
- createTextEnumProp,
4
3
  createBoolProp,
5
4
  CONTAINER_COMPONENT_STYLES_SECTIONS,
6
5
  createStaticNumberProp,
6
+ StylesPanelSections,
7
+ createStaticBoolProp,
7
8
  } from "@draftbit/types";
8
9
 
9
10
  const SHARED_SEED_DATA = {
@@ -12,6 +13,13 @@ const SHARED_SEED_DATA = {
12
13
  stylesPanelSections: CONTAINER_COMPONENT_STYLES_SECTIONS,
13
14
  };
14
15
 
16
+ const CONTAINER_COMPONENT_STYLES_WITHOUT_FLEX =
17
+ CONTAINER_COMPONENT_STYLES_SECTIONS.filter(
18
+ (item) =>
19
+ item !== StylesPanelSections.LayoutFlexItems &&
20
+ item !== StylesPanelSections.LayoutContent
21
+ );
22
+
15
23
  export const SEED_DATA = [
16
24
  {
17
25
  name: "Aspect Ratio",
@@ -27,6 +35,14 @@ export const SEED_DATA = [
27
35
  defaultValue: 1.33,
28
36
  }),
29
37
  },
38
+ stylesPanelSections: [
39
+ StylesPanelSections.Background,
40
+ StylesPanelSections.Size,
41
+ StylesPanelSections.Margins,
42
+ StylesPanelSections.Position,
43
+ StylesPanelSections.Borders,
44
+ StylesPanelSections.Effects,
45
+ ],
30
46
  },
31
47
  {
32
48
  name: "Box",
@@ -40,6 +56,7 @@ export const SEED_DATA = [
40
56
  tag: "Center",
41
57
  description: "Center aligns its contents to the center within itself",
42
58
  ...SHARED_SEED_DATA,
59
+ stylesPanelSections: CONTAINER_COMPONENT_STYLES_WITHOUT_FLEX,
43
60
  },
44
61
  {
45
62
  name: "Circle",
@@ -47,24 +64,38 @@ export const SEED_DATA = [
47
64
  description:
48
65
  "Center aligns its contents to the center within itself with a round border radius",
49
66
  ...SHARED_SEED_DATA,
67
+ stylesPanelSections: CONTAINER_COMPONENT_STYLES_WITHOUT_FLEX,
50
68
  },
51
69
  {
52
70
  name: "Container",
53
71
  tag: "Container",
54
72
  description:
55
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
+ },
56
81
  ...SHARED_SEED_DATA,
57
82
  },
58
83
  {
59
84
  name: "Column",
60
85
  tag: "Column",
61
86
  description: "Column aligns items vertically",
87
+ layout: {
88
+ flexDirection: "column",
89
+ },
62
90
  ...SHARED_SEED_DATA,
63
91
  },
64
92
  {
65
93
  name: "Row",
66
94
  tag: "Row",
67
95
  description: "Column aligns items horizontally",
96
+ layout: {
97
+ flexDirection: "row",
98
+ },
68
99
  ...SHARED_SEED_DATA,
69
100
  },
70
101
  {
@@ -72,7 +103,15 @@ export const SEED_DATA = [
72
103
  tag: "Spacer",
73
104
  description:
74
105
  "An adjustable, empty space that can be used to tune the spacing between child elements within Flex",
106
+ layout: {
107
+ flex: 1,
108
+ },
75
109
  ...SHARED_SEED_DATA,
110
+ stylesPanelSections: [
111
+ StylesPanelSections.LayoutSelectedItem,
112
+ StylesPanelSections.Background,
113
+ StylesPanelSections.Margins,
114
+ ],
76
115
  },
77
116
  {
78
117
  name: "Stack",
@@ -81,16 +120,6 @@ export const SEED_DATA = [
81
120
  "Stack aligns items vertically or horizontally based on the direction prop",
82
121
  ...SHARED_SEED_DATA,
83
122
  props: {
84
- direction: createTextEnumProp({
85
- label: "Direction",
86
- description: "The direction of the Stack",
87
- options: ["row", "column"],
88
- defaultValue: "column",
89
- }),
90
- reversed: createBoolProp({
91
- label: "Reversed",
92
- description: "Determines whether to reverse the direction of items",
93
- }),
94
123
  isDisabled: createBoolProp({
95
124
  label: "Disabled",
96
125
  description: "If true, the Stack will be disabled",