@draftbit/core 46.10.3-ccc53a.2 → 46.10.3-cf3748.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 (97) hide show
  1. package/lib/commonjs/components/Checkbox/context.js +1 -1
  2. package/lib/commonjs/components/Table/Table.js +123 -0
  3. package/lib/commonjs/components/Table/TableCell.js +49 -0
  4. package/lib/commonjs/components/Table/TableRow.js +61 -0
  5. package/lib/commonjs/components/Table/index.js +51 -0
  6. package/lib/commonjs/index.js +19 -0
  7. package/lib/commonjs/mappings/Table.js +140 -0
  8. package/lib/module/components/Table/Table.js +114 -0
  9. package/lib/module/components/Table/TableCell.js +41 -0
  10. package/lib/module/components/Table/TableRow.js +53 -0
  11. package/lib/module/components/Table/index.js +24 -0
  12. package/lib/module/constants.js +0 -1
  13. package/lib/module/index.js +1 -0
  14. package/lib/module/mappings/Table.js +133 -0
  15. package/lib/typescript/src/components/Table/Table.d.ts +19 -0
  16. package/lib/typescript/src/components/Table/Table.d.ts.map +1 -0
  17. package/lib/typescript/src/components/Table/TableCell.d.ts +9 -0
  18. package/lib/typescript/src/components/Table/TableCell.d.ts.map +1 -0
  19. package/lib/typescript/src/components/{DeprecatedCardWrapper.d.ts → Table/TableRow.d.ts} +7 -8
  20. package/lib/typescript/src/components/Table/TableRow.d.ts.map +1 -0
  21. package/lib/typescript/src/components/Table/index.d.ts +22 -0
  22. package/lib/typescript/src/components/Table/index.d.ts.map +1 -0
  23. package/lib/typescript/src/index.d.ts +1 -0
  24. package/lib/typescript/src/index.d.ts.map +1 -1
  25. package/lib/typescript/src/mappings/{CardBlock.d.ts → Table.d.ts} +129 -81
  26. package/lib/typescript/src/mappings/Table.d.ts.map +1 -0
  27. package/package.json +3 -3
  28. package/src/components/Table/Table.js +93 -0
  29. package/src/components/Table/Table.tsx +176 -0
  30. package/src/components/Table/TableCell.js +31 -0
  31. package/src/components/Table/TableCell.tsx +59 -0
  32. package/src/components/Table/TableRow.js +37 -0
  33. package/src/components/Table/TableRow.tsx +77 -0
  34. package/src/components/Table/index.js +15 -0
  35. package/src/components/Table/index.tsx +44 -0
  36. package/src/index.js +1 -0
  37. package/src/index.tsx +2 -0
  38. package/src/mappings/Table.js +150 -0
  39. package/src/mappings/Table.ts +170 -0
  40. package/lib/commonjs/components/DeprecatedCardWrapper.js +0 -40
  41. package/lib/commonjs/components/DeprecatedFAB.js +0 -157
  42. package/lib/commonjs/components/ProgressIndicator.js +0 -55
  43. package/lib/commonjs/components/ResizeMode.js +0 -5
  44. package/lib/commonjs/mappings/CardBlock.js +0 -126
  45. package/lib/commonjs/mappings/CardContainer.js +0 -108
  46. package/lib/commonjs/mappings/CardContainerRating.js +0 -130
  47. package/lib/commonjs/mappings/CardContainerShortImage.js +0 -124
  48. package/lib/commonjs/mappings/CardInline.js +0 -59
  49. package/lib/commonjs/mappings/ProgressIndicator.js +0 -188
  50. package/lib/module/components/DeprecatedCardWrapper.js +0 -32
  51. package/lib/module/components/DeprecatedFAB.js +0 -147
  52. package/lib/module/components/ProgressIndicator.js +0 -45
  53. package/lib/module/components/ResizeMode.js +0 -1
  54. package/lib/module/mappings/CardBlock.js +0 -119
  55. package/lib/module/mappings/CardContainer.js +0 -101
  56. package/lib/module/mappings/CardContainerRating.js +0 -123
  57. package/lib/module/mappings/CardContainerShortImage.js +0 -117
  58. package/lib/module/mappings/CardInline.js +0 -52
  59. package/lib/module/mappings/ProgressIndicator.js +0 -181
  60. package/lib/typescript/src/components/DeprecatedCardWrapper.d.ts.map +0 -1
  61. package/lib/typescript/src/components/DeprecatedFAB.d.ts +0 -56
  62. package/lib/typescript/src/components/DeprecatedFAB.d.ts.map +0 -1
  63. package/lib/typescript/src/components/ProgressIndicator.d.ts +0 -24
  64. package/lib/typescript/src/components/ProgressIndicator.d.ts.map +0 -1
  65. package/lib/typescript/src/components/ResizeMode.d.ts +0 -2
  66. package/lib/typescript/src/components/ResizeMode.d.ts.map +0 -1
  67. package/lib/typescript/src/mappings/CardBlock.d.ts.map +0 -1
  68. package/lib/typescript/src/mappings/CardContainer.d.ts +0 -102
  69. package/lib/typescript/src/mappings/CardContainer.d.ts.map +0 -1
  70. package/lib/typescript/src/mappings/CardContainerRating.d.ts +0 -108
  71. package/lib/typescript/src/mappings/CardContainerRating.d.ts.map +0 -1
  72. package/lib/typescript/src/mappings/CardContainerShortImage.d.ts +0 -139
  73. package/lib/typescript/src/mappings/CardContainerShortImage.d.ts.map +0 -1
  74. package/lib/typescript/src/mappings/CardInline.d.ts +0 -62
  75. package/lib/typescript/src/mappings/CardInline.d.ts.map +0 -1
  76. package/lib/typescript/src/mappings/ProgressIndicator.d.ts +0 -181
  77. package/lib/typescript/src/mappings/ProgressIndicator.d.ts.map +0 -1
  78. package/src/components/DeprecatedCardWrapper.js +0 -18
  79. package/src/components/DeprecatedCardWrapper.tsx +0 -46
  80. package/src/components/DeprecatedFAB.js +0 -114
  81. package/src/components/DeprecatedFAB.tsx +0 -231
  82. package/src/components/ProgressIndicator.js +0 -27
  83. package/src/components/ProgressIndicator.tsx +0 -71
  84. package/src/components/ResizeMode.js +0 -1
  85. package/src/components/ResizeMode.ts +0 -7
  86. package/src/mappings/CardBlock.js +0 -123
  87. package/src/mappings/CardBlock.ts +0 -136
  88. package/src/mappings/CardContainer.js +0 -104
  89. package/src/mappings/CardContainer.ts +0 -116
  90. package/src/mappings/CardContainerRating.js +0 -126
  91. package/src/mappings/CardContainerRating.ts +0 -137
  92. package/src/mappings/CardContainerShortImage.js +0 -120
  93. package/src/mappings/CardContainerShortImage.ts +0 -130
  94. package/src/mappings/CardInline.js +0 -52
  95. package/src/mappings/CardInline.ts +0 -61
  96. package/src/mappings/ProgressIndicator.js +0 -181
  97. 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 "./index";
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 "./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 { default as 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 { default as Table } from "./Table";
43
+ export { default as TableRow } from "./TableRow";
44
+ export { default as TableCell } from "./TableCell";
package/src/index.js CHANGED
@@ -36,6 +36,7 @@ export { TabView, TabViewItem } from "./components/TabView";
36
36
  export { default as Markdown } from "./components/Markdown";
37
37
  export { BottomSheet } from "./components/BottomSheet";
38
38
  export { YoutubePlayer } from "./components/YoutubePlayer";
39
+ export { Table, TableRow, TableCell } from "./components/Table";
39
40
  /* Deprecated: Fix or Delete! */
40
41
  export { default as DatePicker } from "./components/DatePicker/DatePicker";
41
42
  export { default as Picker } from "./components/Picker/Picker";
package/src/index.tsx CHANGED
@@ -61,6 +61,8 @@ export { BottomSheet } from "./components/BottomSheet";
61
61
 
62
62
  export { YoutubePlayer } from "./components/YoutubePlayer";
63
63
 
64
+ export { Table, TableRow, TableCell } from "./components/Table";
65
+
64
66
  /* Deprecated: Fix or Delete! */
65
67
  export { default as DatePicker } from "./components/DatePicker/DatePicker";
66
68
  export { default as Picker } from "./components/Picker/Picker";
@@ -0,0 +1,150 @@
1
+ import { COMPONENT_TYPES, StylesPanelSections, createColorProp, createStaticBoolProp, createStaticNumberProp, createTextEnumProp, } from "@draftbit/types";
2
+ const SHARED_SEED_DATA_PROPS = {
3
+ borderWidth: createStaticNumberProp({
4
+ label: "Border Width",
5
+ description: "Specifies the width of the border. Passed down to child Table(Row/Cell) components unless overridden",
6
+ required: false,
7
+ defaultValue: null,
8
+ }),
9
+ borderColor: createColorProp({
10
+ label: "Border Color",
11
+ description: "Specifies the color of the border. Passed down to child Table(Row/Cell) components unless overridden",
12
+ defaultValue: null,
13
+ }),
14
+ borderStyle: createTextEnumProp({
15
+ label: "Border Style",
16
+ description: "Specifies the style of the border. Passed down to child Table(Row/Cell) components unless overridden",
17
+ options: ["solid", "dotted", "dashed"],
18
+ defaultValue: null,
19
+ }),
20
+ drawTopBorder: createStaticBoolProp({
21
+ label: "Draw Top Border",
22
+ description: "Whether to draw the top border at this layer of the Table tree or not",
23
+ defaultValue: false,
24
+ }),
25
+ drawBottomBorder: createStaticBoolProp({
26
+ label: "Draw Bottom Border",
27
+ description: "Whether to draw the bottom border at this layer of the Table tree or not",
28
+ defaultValue: false,
29
+ }),
30
+ drawStartBorder: createStaticBoolProp({
31
+ label: "Draw Start Border",
32
+ description: "Whether to draw the start border at this layer of the Table tree or not",
33
+ defaultValue: false,
34
+ }),
35
+ drawEndBorder: createStaticBoolProp({
36
+ label: "Draw End Border",
37
+ description: "Whether to draw the end border at this layer of the Table tree or not",
38
+ defaultValue: false,
39
+ }),
40
+ cellVerticalPadding: createStaticNumberProp({
41
+ label: "Cell Vertical Padding",
42
+ description: "Specifies the vertical padding of the cell. Passed down to TableCell components unless overridden",
43
+ required: false,
44
+ defaultValue: null,
45
+ }),
46
+ cellHorizontalPadding: createStaticNumberProp({
47
+ label: "Cell Horizontal Padding",
48
+ description: "Specifies the horizontal padding of the cell. Passed down to TableCell components unless overridden",
49
+ required: false,
50
+ defaultValue: null,
51
+ }),
52
+ };
53
+ export const SEED_DATA = [
54
+ {
55
+ name: "Table",
56
+ tag: "Table",
57
+ description: "Top level table container",
58
+ category: COMPONENT_TYPES.table,
59
+ stylesPanelSections: [
60
+ StylesPanelSections.Size,
61
+ StylesPanelSections.Margins,
62
+ StylesPanelSections.Position,
63
+ StylesPanelSections.Effects,
64
+ StylesPanelSections.Background,
65
+ StylesPanelSections.LayoutSelectedItem,
66
+ ],
67
+ layout: {
68
+ flex: 1,
69
+ },
70
+ props: {
71
+ ...SHARED_SEED_DATA_PROPS,
72
+ borderWidth: { ...SHARED_SEED_DATA_PROPS.borderWidth, defaultValue: 1 },
73
+ borderColor: {
74
+ ...SHARED_SEED_DATA_PROPS.borderColor,
75
+ defaultValue: "divider",
76
+ },
77
+ borderStyle: {
78
+ ...SHARED_SEED_DATA_PROPS.borderStyle,
79
+ defaultValue: "solid",
80
+ },
81
+ drawTopBorder: {
82
+ ...SHARED_SEED_DATA_PROPS.drawTopBorder,
83
+ defaultValue: true,
84
+ },
85
+ cellVerticalPadding: {
86
+ ...SHARED_SEED_DATA_PROPS.cellVerticalPadding,
87
+ defaultValue: 10,
88
+ },
89
+ cellHorizontalPadding: {
90
+ ...SHARED_SEED_DATA_PROPS.cellHorizontalPadding,
91
+ defaultValue: 10,
92
+ },
93
+ showsVerticalScrollIndicator: createStaticBoolProp({
94
+ label: "Show Vertical Scroll Indicator",
95
+ description: "When true, shows a vertical scroll indicator. The default value is true.",
96
+ defaultValue: true,
97
+ }),
98
+ },
99
+ },
100
+ {
101
+ name: "Table Row",
102
+ tag: "TableRow",
103
+ description: "Table Row container",
104
+ category: COMPONENT_TYPES.table,
105
+ stylesPanelSections: [StylesPanelSections.Background],
106
+ props: {
107
+ ...SHARED_SEED_DATA_PROPS,
108
+ drawStartBorder: {
109
+ ...SHARED_SEED_DATA_PROPS.drawStartBorder,
110
+ defaultValue: true,
111
+ },
112
+ drawBottomBorder: {
113
+ ...SHARED_SEED_DATA_PROPS.drawBottomBorder,
114
+ defaultValue: true,
115
+ },
116
+ isTableHeader: createStaticBoolProp({
117
+ label: "Header",
118
+ description: "Whether this row is a header or not (changes background and sticks while scrolling)",
119
+ defaultValue: false,
120
+ }),
121
+ },
122
+ },
123
+ {
124
+ name: "Table Cell",
125
+ tag: "TableCell",
126
+ description: "Table Cell container",
127
+ category: COMPONENT_TYPES.table,
128
+ stylesPanelSections: [
129
+ StylesPanelSections.LayoutFlexItems,
130
+ StylesPanelSections.LayoutSelectedItem,
131
+ StylesPanelSections.LayoutContent,
132
+ StylesPanelSections.Background,
133
+ StylesPanelSections.Size,
134
+ StylesPanelSections.MarginsAndPaddings,
135
+ StylesPanelSections.Position,
136
+ StylesPanelSections.Effects,
137
+ ],
138
+ layout: {
139
+ flex: 1,
140
+ flexDirection: "row",
141
+ },
142
+ props: {
143
+ ...SHARED_SEED_DATA_PROPS,
144
+ drawEndBorder: {
145
+ ...SHARED_SEED_DATA_PROPS.drawEndBorder,
146
+ defaultValue: true,
147
+ },
148
+ },
149
+ },
150
+ ];