@draftbit/core 46.2.4-4eaebb.5 → 46.2.4-54d316.5

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 (57) hide show
  1. package/lib/commonjs/components/Accordion/AccordionItem.js +25 -5
  2. package/lib/commonjs/components/Table/index.js +55 -0
  3. package/lib/commonjs/components/Table/table.js +35 -0
  4. package/lib/commonjs/components/Table/tableCell.js +50 -0
  5. package/lib/commonjs/components/Table/tableHeader.js +41 -0
  6. package/lib/commonjs/components/Table/tablePaginator.js +17 -0
  7. package/lib/commonjs/components/Table/tableRow.js +47 -0
  8. package/lib/commonjs/components/Table/tableTitle.js +60 -0
  9. package/lib/commonjs/index.js +38 -0
  10. package/lib/commonjs/mappings/SVG.js +0 -1
  11. package/lib/commonjs/mappings/table.js +103 -0
  12. package/lib/commonjs/utilities.js +2 -2
  13. package/lib/module/components/Table/index.js +6 -0
  14. package/lib/module/components/Table/table.js +23 -0
  15. package/lib/module/components/Table/tableCell.js +37 -0
  16. package/lib/module/components/Table/tableHeader.js +27 -0
  17. package/lib/module/components/Table/tablePaginator.js +6 -0
  18. package/lib/module/components/Table/tableRow.js +33 -0
  19. package/lib/module/components/Table/tableTitle.js +47 -0
  20. package/lib/module/index.js +1 -0
  21. package/lib/module/mappings/SVG.js +1 -2
  22. package/lib/module/mappings/table.js +94 -0
  23. package/lib/module/utilities.js +3 -3
  24. package/lib/typescript/src/components/Table/index.d.ts +6 -0
  25. package/lib/typescript/src/components/Table/table.d.ts +8 -0
  26. package/lib/typescript/src/components/Table/tableCell.d.ts +10 -0
  27. package/lib/typescript/src/components/Table/tableHeader.d.ts +12 -0
  28. package/lib/typescript/src/components/Table/tablePaginator.d.ts +3 -0
  29. package/lib/typescript/src/components/Table/tableRow.d.ts +12 -0
  30. package/lib/typescript/src/components/Table/tableTitle.d.ts +12 -0
  31. package/lib/typescript/src/index.d.ts +1 -0
  32. package/lib/typescript/src/mappings/SVG.d.ts +0 -1
  33. package/lib/typescript/src/mappings/table.d.ts +153 -0
  34. package/lib/typescript/src/utilities.d.ts +3 -3
  35. package/package.json +2 -2
  36. package/src/components/Table/index.js +6 -0
  37. package/src/components/Table/index.tsx +6 -0
  38. package/src/components/Table/table.js +10 -0
  39. package/src/components/Table/table.tsx +22 -0
  40. package/src/components/Table/tableCell.js +21 -0
  41. package/src/components/Table/tableCell.tsx +44 -0
  42. package/src/components/Table/tableHeader.js +11 -0
  43. package/src/components/Table/tableHeader.tsx +28 -0
  44. package/src/components/Table/tablePaginator.js +5 -0
  45. package/src/components/Table/tablePaginator.tsx +10 -0
  46. package/src/components/Table/tableRow.js +16 -0
  47. package/src/components/Table/tableRow.tsx +31 -0
  48. package/src/components/Table/tableTitle.js +28 -0
  49. package/src/components/Table/tableTitle.tsx +58 -0
  50. package/src/index.js +1 -0
  51. package/src/index.tsx +9 -0
  52. package/src/mappings/SVG.js +1 -7
  53. package/src/mappings/SVG.ts +1 -11
  54. package/src/mappings/table.js +137 -0
  55. package/src/mappings/table.ts +145 -0
  56. package/src/utilities.js +5 -2
  57. package/src/utilities.ts +13 -2
@@ -0,0 +1,31 @@
1
+ import React from "react";
2
+ import { View, StyleProp, ViewStyle, StyleSheet } from "react-native";
3
+ import { Theme } from "../../styles/DefaultTheme";
4
+ import { withTheme } from "../../theming";
5
+ export interface TableRowProps {
6
+ children: React.ReactNode;
7
+ style?: StyleProp<ViewStyle>;
8
+ theme: Theme;
9
+ }
10
+
11
+ const TableRow = ({ children, style, theme, ...rest }: TableRowProps) => (
12
+ <View
13
+ {...rest}
14
+ style={[styles.container, { borderBottomColor: theme.colors.light }, style]}
15
+ >
16
+ <View style={styles.content}>{children}</View>
17
+ </View>
18
+ );
19
+
20
+ const styles = StyleSheet.create({
21
+ container: {
22
+ display: "flex",
23
+ flexDirection: "row",
24
+ },
25
+ content: {
26
+ flex: 1,
27
+ flexDirection: "row",
28
+ },
29
+ });
30
+
31
+ export default withTheme(TableRow);
@@ -0,0 +1,28 @@
1
+ import React from "react";
2
+ import { View, Text, StyleSheet } from "react-native";
3
+ import { extractStyles } from "../../utilities";
4
+ const TableTitle = ({ children, style, numeric = false, isAscending = false, numberOfLines = 1, title, ...rest }) => {
5
+ const { textStyles, viewStyles } = extractStyles(style);
6
+ return (React.createElement(View, { ...rest, style: [styles.wrapper, numeric && styles.right, viewStyles] },
7
+ React.createElement(Text, { style: [isAscending ? styles.sorted : { color: "gray" }, textStyles], numberOfLines: numberOfLines },
8
+ children,
9
+ title)));
10
+ };
11
+ const styles = StyleSheet.create({
12
+ wrapper: {
13
+ flex: 1,
14
+ display: "flex",
15
+ flexDirection: "row",
16
+ },
17
+ right: {
18
+ justifyContent: "flex-end",
19
+ },
20
+ sorted: {
21
+ // marginLeft: 8,
22
+ },
23
+ icon: {
24
+ height: 24,
25
+ justifyContent: "center",
26
+ },
27
+ });
28
+ export default TableTitle;
@@ -0,0 +1,58 @@
1
+ import React from "react";
2
+ import { View, Text, StyleProp, ViewStyle, StyleSheet } from "react-native";
3
+ import { extractStyles } from "../../utilities";
4
+
5
+ export interface TableCellProps {
6
+ children: React.ReactNode;
7
+ numeric?: boolean;
8
+ isAscending: boolean;
9
+ numberOfLines?: number;
10
+ title?: string;
11
+ style?: StyleProp<ViewStyle>;
12
+ }
13
+
14
+ const TableTitle = ({
15
+ children,
16
+ style,
17
+ numeric = false,
18
+ isAscending = false,
19
+ numberOfLines = 1,
20
+ title,
21
+ ...rest
22
+ }: TableCellProps) => {
23
+ const { textStyles, viewStyles } = extractStyles(style);
24
+ return (
25
+ <View
26
+ {...rest}
27
+ style={[styles.wrapper, numeric && styles.right, viewStyles]}
28
+ >
29
+ <Text
30
+ style={[isAscending ? styles.sorted : { color: "gray" }, textStyles]}
31
+ numberOfLines={numberOfLines}
32
+ >
33
+ {children}
34
+ {title}
35
+ </Text>
36
+ </View>
37
+ );
38
+ };
39
+
40
+ const styles = StyleSheet.create({
41
+ wrapper: {
42
+ flex: 1,
43
+ display: "flex",
44
+ flexDirection: "row",
45
+ },
46
+ right: {
47
+ justifyContent: "flex-end",
48
+ },
49
+ sorted: {
50
+ // marginLeft: 8,
51
+ },
52
+ icon: {
53
+ height: 24,
54
+ justifyContent: "center",
55
+ },
56
+ });
57
+
58
+ export default TableTitle;
package/src/index.js CHANGED
@@ -31,6 +31,7 @@ export { ActionSheet, ActionSheetItem, ActionSheetCancel, } from "./components/A
31
31
  export { Swiper, SwiperItem } from "./components/Swiper";
32
32
  export { Center, Circle, Square, Row, Stack, Spacer, } from "./components/Layout";
33
33
  export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup, } from "./components/RadioButton/index";
34
+ export { Table, TableRow, TablePaginator, TableHeader, TableCell, TableTitle, } from "./components/Table";
34
35
  /* Deprecated: Fix or Delete! */
35
36
  export { default as Button } from "./components/DeprecatedButton";
36
37
  export { default as CardBlock } from "./components/CardBlock";
package/src/index.tsx CHANGED
@@ -51,6 +51,15 @@ export {
51
51
  RadioButtonFieldGroup,
52
52
  } from "./components/RadioButton/index";
53
53
 
54
+ export {
55
+ Table,
56
+ TableRow,
57
+ TablePaginator,
58
+ TableHeader,
59
+ TableCell,
60
+ TableTitle,
61
+ } from "./components/Table";
62
+
54
63
  /* Deprecated: Fix or Delete! */
55
64
  export { default as Button } from "./components/DeprecatedButton";
56
65
  export { default as CardBlock } from "./components/CardBlock";
@@ -1,4 +1,4 @@
1
- import { COMPONENT_TYPES, createSvgProp, StylesPanelSections, } from "@draftbit/types";
1
+ import { COMPONENT_TYPES, createSvgProp } from "@draftbit/types";
2
2
  export const SEED_DATA = {
3
3
  name: "SVG",
4
4
  tag: "SVG",
@@ -8,12 +8,6 @@ export const SEED_DATA = {
8
8
  width: 100,
9
9
  height: 100,
10
10
  },
11
- stylesPanelSections: [
12
- StylesPanelSections.Size,
13
- StylesPanelSections.Margins,
14
- StylesPanelSections.Position,
15
- StylesPanelSections.Effects,
16
- ],
17
11
  props: {
18
12
  source: createSvgProp(),
19
13
  },
@@ -1,8 +1,4 @@
1
- import {
2
- COMPONENT_TYPES,
3
- createSvgProp,
4
- StylesPanelSections,
5
- } from "@draftbit/types";
1
+ import { COMPONENT_TYPES, createSvgProp } from "@draftbit/types";
6
2
 
7
3
  export const SEED_DATA = {
8
4
  name: "SVG",
@@ -13,12 +9,6 @@ export const SEED_DATA = {
13
9
  width: 100,
14
10
  height: 100,
15
11
  },
16
- stylesPanelSections: [
17
- StylesPanelSections.Size,
18
- StylesPanelSections.Margins,
19
- StylesPanelSections.Position,
20
- StylesPanelSections.Effects,
21
- ],
22
12
  props: {
23
13
  source: createSvgProp(),
24
14
  },
@@ -0,0 +1,137 @@
1
+ import { COMPONENT_TYPES, GROUPS, createBoolProp, createTextProp, createNumberProp, StylesPanelSections, } from "@draftbit/types";
2
+ export const SEED_DATA = [
3
+ {
4
+ name: "Table",
5
+ tag: "Table",
6
+ category: COMPONENT_TYPES.container,
7
+ stylesPanelSections: [
8
+ StylesPanelSections.Background,
9
+ StylesPanelSections.Borders,
10
+ StylesPanelSections.Size,
11
+ StylesPanelSections.MarginsAndPaddings,
12
+ StylesPanelSections.Position,
13
+ StylesPanelSections.Effects,
14
+ ],
15
+ layout: {
16
+ width: "100%",
17
+ },
18
+ props: {},
19
+ },
20
+ {
21
+ name: "Table Row",
22
+ tag: "TableRow",
23
+ category: COMPONENT_TYPES.container,
24
+ stylesPanelSections: [
25
+ StylesPanelSections.Background,
26
+ StylesPanelSections.Borders,
27
+ StylesPanelSections.Size,
28
+ StylesPanelSections.MarginsAndPaddings,
29
+ StylesPanelSections.Position,
30
+ StylesPanelSections.Effects,
31
+ ],
32
+ layout: {
33
+ paddingLeft: 16,
34
+ paddingRight: 16,
35
+ borderBottomWidth: 1,
36
+ borderStyle: "solid",
37
+ },
38
+ props: {},
39
+ },
40
+ {
41
+ name: "Table Cell",
42
+ tag: "TableCell",
43
+ category: COMPONENT_TYPES.container,
44
+ layout: {
45
+ paddingTop: 16,
46
+ paddingBottom: 16,
47
+ paddingLeft: 8,
48
+ paddingRight: 8,
49
+ },
50
+ stylesPanelSections: [
51
+ StylesPanelSections.Typography,
52
+ StylesPanelSections.Background,
53
+ StylesPanelSections.Borders,
54
+ StylesPanelSections.Size,
55
+ StylesPanelSections.MarginsAndPaddings,
56
+ StylesPanelSections.Position,
57
+ StylesPanelSections.Effects,
58
+ ],
59
+ props: {
60
+ numeric: createBoolProp({
61
+ label: "Is Numeric Cell?",
62
+ description: "Does the cell contain a numeric value?",
63
+ group: GROUPS.data,
64
+ }),
65
+ value: createTextProp({
66
+ label: "Cell Value",
67
+ description: "Table Cell Value",
68
+ group: GROUPS.data,
69
+ }),
70
+ },
71
+ },
72
+ {
73
+ name: "Table Header",
74
+ tag: "TableHeader",
75
+ category: COMPONENT_TYPES.container,
76
+ stylesPanelSections: [
77
+ StylesPanelSections.Background,
78
+ StylesPanelSections.Borders,
79
+ StylesPanelSections.Size,
80
+ StylesPanelSections.MarginsAndPaddings,
81
+ StylesPanelSections.Position,
82
+ StylesPanelSections.Effects,
83
+ ],
84
+ layout: {
85
+ paddingLeft: 16,
86
+ paddingRight: 16,
87
+ borderBottomWidth: 1,
88
+ borderStyle: "solid",
89
+ backgroundColor: "#EFEFEF",
90
+ },
91
+ props: {},
92
+ },
93
+ {
94
+ name: "Table Title",
95
+ tag: "TableTitle",
96
+ category: COMPONENT_TYPES.container,
97
+ stylesPanelSections: [
98
+ StylesPanelSections.Typography,
99
+ StylesPanelSections.Background,
100
+ StylesPanelSections.Borders,
101
+ StylesPanelSections.Size,
102
+ StylesPanelSections.MarginsAndPaddings,
103
+ StylesPanelSections.Position,
104
+ StylesPanelSections.Effects,
105
+ ],
106
+ layout: {
107
+ fontSize: 14,
108
+ fontWeight: "500",
109
+ paddingTop: 16,
110
+ paddingBottom: 16,
111
+ paddingLeft: 8,
112
+ paddingRight: 8,
113
+ },
114
+ props: {
115
+ numeric: createBoolProp({
116
+ label: "Is Numeric Cell?",
117
+ description: "Does the cell contain a numeric value?",
118
+ group: GROUPS.data,
119
+ }),
120
+ value: createTextProp({
121
+ label: "Cell Value",
122
+ description: "Table Cell Value",
123
+ group: GROUPS.data,
124
+ }),
125
+ isAscending: createBoolProp({
126
+ label: "Is Ascending?",
127
+ description: "Does the cell contain a numeric value?",
128
+ group: GROUPS.data,
129
+ }),
130
+ numberOfLines: createNumberProp({
131
+ label: "Number of Lines",
132
+ description: "Number of Lines",
133
+ group: GROUPS.basic,
134
+ }),
135
+ },
136
+ },
137
+ ];
@@ -0,0 +1,145 @@
1
+ import {
2
+ COMPONENT_TYPES,
3
+ GROUPS,
4
+ createBoolProp,
5
+ createTextProp,
6
+ createNumberProp,
7
+ StylesPanelSections,
8
+ } from "@draftbit/types";
9
+
10
+ export const SEED_DATA = [
11
+ {
12
+ name: "Table",
13
+ tag: "Table",
14
+ category: COMPONENT_TYPES.container,
15
+ stylesPanelSections: [
16
+ StylesPanelSections.Background,
17
+ StylesPanelSections.Borders,
18
+ StylesPanelSections.Size,
19
+ StylesPanelSections.MarginsAndPaddings,
20
+ StylesPanelSections.Position,
21
+ StylesPanelSections.Effects,
22
+ ],
23
+ layout: {
24
+ width: "100%",
25
+ },
26
+ props: {},
27
+ },
28
+ {
29
+ name: "Table Row",
30
+ tag: "TableRow",
31
+ category: COMPONENT_TYPES.container,
32
+ stylesPanelSections: [
33
+ StylesPanelSections.Background,
34
+ StylesPanelSections.Borders,
35
+ StylesPanelSections.Size,
36
+ StylesPanelSections.MarginsAndPaddings,
37
+ StylesPanelSections.Position,
38
+ StylesPanelSections.Effects,
39
+ ],
40
+ layout: {
41
+ paddingLeft: 16,
42
+ paddingRight: 16,
43
+ borderBottomWidth: 1,
44
+ borderStyle: "solid",
45
+ },
46
+ props: {},
47
+ },
48
+ {
49
+ name: "Table Cell",
50
+ tag: "TableCell",
51
+ category: COMPONENT_TYPES.container,
52
+ layout: {
53
+ paddingTop: 16,
54
+ paddingBottom: 16,
55
+ paddingLeft: 8,
56
+ paddingRight: 8,
57
+ },
58
+ stylesPanelSections: [
59
+ StylesPanelSections.Typography,
60
+ StylesPanelSections.Background,
61
+ StylesPanelSections.Borders,
62
+ StylesPanelSections.Size,
63
+ StylesPanelSections.MarginsAndPaddings,
64
+ StylesPanelSections.Position,
65
+ StylesPanelSections.Effects,
66
+ ],
67
+ props: {
68
+ numeric: createBoolProp({
69
+ label: "Is Numeric Cell?",
70
+ description: "Does the cell contain a numeric value?",
71
+ group: GROUPS.data,
72
+ }),
73
+ value: createTextProp({
74
+ label: "Cell Value",
75
+ description: "Table Cell Value",
76
+ group: GROUPS.data,
77
+ }),
78
+ },
79
+ },
80
+ {
81
+ name: "Table Header",
82
+ tag: "TableHeader",
83
+ category: COMPONENT_TYPES.container,
84
+ stylesPanelSections: [
85
+ StylesPanelSections.Background,
86
+ StylesPanelSections.Borders,
87
+ StylesPanelSections.Size,
88
+ StylesPanelSections.MarginsAndPaddings,
89
+ StylesPanelSections.Position,
90
+ StylesPanelSections.Effects,
91
+ ],
92
+ layout: {
93
+ paddingLeft: 16,
94
+ paddingRight: 16,
95
+ borderBottomWidth: 1,
96
+ borderStyle: "solid",
97
+ backgroundColor: "#EFEFEF",
98
+ },
99
+ props: {},
100
+ },
101
+ {
102
+ name: "Table Title",
103
+ tag: "TableTitle",
104
+ category: COMPONENT_TYPES.container,
105
+ stylesPanelSections: [
106
+ StylesPanelSections.Typography,
107
+ StylesPanelSections.Background,
108
+ StylesPanelSections.Borders,
109
+ StylesPanelSections.Size,
110
+ StylesPanelSections.MarginsAndPaddings,
111
+ StylesPanelSections.Position,
112
+ StylesPanelSections.Effects,
113
+ ],
114
+ layout: {
115
+ fontSize: 14,
116
+ fontWeight: "500",
117
+ paddingTop: 16,
118
+ paddingBottom: 16,
119
+ paddingLeft: 8,
120
+ paddingRight: 8,
121
+ },
122
+ props: {
123
+ numeric: createBoolProp({
124
+ label: "Is Numeric Cell?",
125
+ description: "Does the cell contain a numeric value?",
126
+ group: GROUPS.data,
127
+ }),
128
+ value: createTextProp({
129
+ label: "Cell Value",
130
+ description: "Table Cell Value",
131
+ group: GROUPS.data,
132
+ }),
133
+ isAscending: createBoolProp({
134
+ label: "Is Ascending?",
135
+ description: "Does the cell contain a numeric value?",
136
+ group: GROUPS.data,
137
+ }),
138
+ numberOfLines: createNumberProp({
139
+ label: "Number of Lines",
140
+ description: "Number of Lines",
141
+ group: GROUPS.basic,
142
+ }),
143
+ },
144
+ },
145
+ ];
package/src/utilities.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { StyleSheet } from "react-native";
2
- import { isString, isNumber, pick, pickBy, identity } from "lodash";
2
+ import { isString, isNumber, pick, pickBy, identity, omitBy, isNil, } from "lodash";
3
3
  export function extractStyles(style) {
4
4
  const { color, fontFamily, fontWeight, fontSize, lineHeight, letterSpacing, textTransform, textAlign, textDecorationLine, textDecorationColor, textDecorationStyle, ...viewStyles } = StyleSheet.flatten(style || {});
5
5
  const textStyles = {
@@ -15,7 +15,10 @@ export function extractStyles(style) {
15
15
  textDecorationColor,
16
16
  textDecorationStyle,
17
17
  };
18
- return { viewStyles, textStyles };
18
+ return {
19
+ viewStyles: omitBy(viewStyles, isNil),
20
+ textStyles: omitBy(textStyles, isNil),
21
+ };
19
22
  }
20
23
  export const borderStyleNames = [
21
24
  "borderRadius",
package/src/utilities.ts CHANGED
@@ -1,5 +1,13 @@
1
1
  import { StyleSheet, StyleProp, TextStyle } from "react-native";
2
- import { isString, isNumber, pick, pickBy, identity } from "lodash";
2
+ import {
3
+ isString,
4
+ isNumber,
5
+ pick,
6
+ pickBy,
7
+ identity,
8
+ omitBy,
9
+ isNil,
10
+ } from "lodash";
3
11
 
4
12
  export function extractStyles(style: StyleProp<any>) {
5
13
  const {
@@ -31,7 +39,10 @@ export function extractStyles(style: StyleProp<any>) {
31
39
  textDecorationStyle,
32
40
  };
33
41
 
34
- return { viewStyles, textStyles };
42
+ return {
43
+ viewStyles: omitBy(viewStyles, isNil),
44
+ textStyles: omitBy(textStyles, isNil),
45
+ };
35
46
  }
36
47
 
37
48
  export const borderStyleNames = [