@draftbit/core 46.10.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.
- package/lib/commonjs/components/Checkbox/context.js +1 -1
- package/lib/commonjs/components/Table/Table.js +122 -0
- package/lib/commonjs/components/Table/TableCell.js +49 -0
- package/lib/commonjs/components/Table/TableRow.js +61 -0
- package/lib/commonjs/components/Table/index.js +51 -0
- package/lib/commonjs/index.js +19 -28
- package/lib/commonjs/mappings/NativeBase/Layout.js +108 -0
- package/lib/commonjs/mappings/Table.js +140 -0
- package/lib/module/components/AspectRatio.js +18 -1
- package/lib/module/components/Checkbox/CheckboxGroup.js +16 -2
- package/lib/module/components/Checkbox/context.js +1 -1
- package/lib/module/components/CircleImage.js +16 -1
- package/lib/module/components/DeprecatedButton.js +21 -3
- package/lib/module/components/IconButton.js +21 -4
- package/lib/module/components/Pressable.js +15 -2
- package/lib/module/components/Shadow.js +15 -2
- package/lib/module/components/Table/Table.js +114 -0
- package/lib/module/components/Table/TableCell.js +41 -0
- package/lib/module/components/Table/TableRow.js +52 -0
- package/lib/module/components/Table/index.js +24 -0
- package/lib/module/components/ToggleButton.js +16 -2
- package/lib/module/constants.js +1 -0
- package/lib/module/index.js +1 -4
- package/lib/module/mappings/NativeBase/Layout.js +101 -0
- package/lib/module/mappings/Table.js +133 -0
- package/lib/typescript/src/components/Table/Table.d.ts +14 -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/{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 +22 -0
- package/lib/typescript/src/components/Table/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mappings/NativeBase/Layout.d.ts +133 -0
- package/lib/typescript/src/mappings/NativeBase/Layout.d.ts.map +1 -0
- package/lib/typescript/src/mappings/{CardBlock.d.ts → Table.d.ts} +129 -81
- package/lib/typescript/src/mappings/Table.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/components/Table/Table.js +91 -0
- package/src/components/Table/Table.tsx +170 -0
- package/src/components/Table/TableCell.js +31 -0
- package/src/components/Table/TableCell.tsx +59 -0
- package/src/components/Table/TableRow.js +37 -0
- package/src/components/Table/TableRow.tsx +77 -0
- package/src/components/Table/index.js +15 -0
- package/src/components/Table/index.tsx +44 -0
- package/src/index.js +1 -4
- package/src/index.tsx +2 -4
- package/src/mappings/NativeBase/Layout.js +124 -0
- package/src/mappings/NativeBase/Layout.ts +145 -0
- package/src/mappings/Table.js +150 -0
- package/src/mappings/Table.ts +170 -0
- package/lib/commonjs/components/Container.js +0 -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/components/Row.js +0 -73
- package/lib/commonjs/components/RowBodyIcon.js +0 -45
- package/lib/commonjs/components/RowHeadlineImageCaption.js +0 -45
- package/lib/commonjs/components/RowHeadlineImageIcon.js +0 -51
- package/lib/commonjs/mappings/CardBlock.js +0 -126
- package/lib/commonjs/mappings/CardContainer.js +0 -108
- package/lib/commonjs/mappings/CardContainerRating.js +0 -130
- package/lib/commonjs/mappings/CardContainerShortImage.js +0 -124
- package/lib/commonjs/mappings/CardInline.js +0 -59
- package/lib/commonjs/mappings/Container.js +0 -37
- package/lib/commonjs/mappings/ProgressIndicator.js +0 -188
- package/lib/module/components/Container.js +0 -83
- package/lib/module/components/DeprecatedCardWrapper.js +0 -32
- package/lib/module/components/DeprecatedFAB.js +0 -147
- package/lib/module/components/ProgressIndicator.js +0 -45
- package/lib/module/components/ResizeMode.js +0 -1
- package/lib/module/components/Row.js +0 -63
- package/lib/module/components/RowBodyIcon.js +0 -35
- package/lib/module/components/RowHeadlineImageCaption.js +0 -35
- package/lib/module/components/RowHeadlineImageIcon.js +0 -41
- package/lib/module/mappings/CardBlock.js +0 -119
- package/lib/module/mappings/CardContainer.js +0 -101
- package/lib/module/mappings/CardContainerRating.js +0 -123
- package/lib/module/mappings/CardContainerShortImage.js +0 -117
- package/lib/module/mappings/CardInline.js +0 -52
- package/lib/module/mappings/Container.js +0 -30
- package/lib/module/mappings/ProgressIndicator.js +0 -181
- package/lib/typescript/src/components/Container.d.ts +0 -21
- package/lib/typescript/src/components/Container.d.ts.map +0 -1
- package/lib/typescript/src/components/DeprecatedCardWrapper.d.ts.map +0 -1
- package/lib/typescript/src/components/DeprecatedFAB.d.ts +0 -56
- package/lib/typescript/src/components/DeprecatedFAB.d.ts.map +0 -1
- package/lib/typescript/src/components/ProgressIndicator.d.ts +0 -24
- package/lib/typescript/src/components/ProgressIndicator.d.ts.map +0 -1
- package/lib/typescript/src/components/ResizeMode.d.ts +0 -2
- package/lib/typescript/src/components/ResizeMode.d.ts.map +0 -1
- package/lib/typescript/src/components/Row.d.ts +0 -21
- package/lib/typescript/src/components/Row.d.ts.map +0 -1
- package/lib/typescript/src/components/RowBodyIcon.d.ts +0 -16
- package/lib/typescript/src/components/RowBodyIcon.d.ts.map +0 -1
- package/lib/typescript/src/components/RowHeadlineImageCaption.d.ts +0 -16
- package/lib/typescript/src/components/RowHeadlineImageCaption.d.ts.map +0 -1
- package/lib/typescript/src/components/RowHeadlineImageIcon.d.ts +0 -18
- package/lib/typescript/src/components/RowHeadlineImageIcon.d.ts.map +0 -1
- package/lib/typescript/src/mappings/CardBlock.d.ts.map +0 -1
- package/lib/typescript/src/mappings/CardContainer.d.ts +0 -102
- package/lib/typescript/src/mappings/CardContainer.d.ts.map +0 -1
- package/lib/typescript/src/mappings/CardContainerRating.d.ts +0 -108
- package/lib/typescript/src/mappings/CardContainerRating.d.ts.map +0 -1
- package/lib/typescript/src/mappings/CardContainerShortImage.d.ts +0 -139
- package/lib/typescript/src/mappings/CardContainerShortImage.d.ts.map +0 -1
- package/lib/typescript/src/mappings/CardInline.d.ts +0 -62
- package/lib/typescript/src/mappings/CardInline.d.ts.map +0 -1
- package/lib/typescript/src/mappings/Container.d.ts +0 -55
- package/lib/typescript/src/mappings/Container.d.ts.map +0 -1
- package/lib/typescript/src/mappings/ProgressIndicator.d.ts +0 -181
- package/lib/typescript/src/mappings/ProgressIndicator.d.ts.map +0 -1
- package/src/components/Container.js +0 -43
- package/src/components/Container.tsx +0 -116
- package/src/components/DeprecatedCardWrapper.js +0 -18
- package/src/components/DeprecatedCardWrapper.tsx +0 -46
- package/src/components/DeprecatedFAB.js +0 -114
- package/src/components/DeprecatedFAB.tsx +0 -231
- package/src/components/ProgressIndicator.js +0 -27
- package/src/components/ProgressIndicator.tsx +0 -71
- package/src/components/ResizeMode.js +0 -1
- package/src/components/ResizeMode.ts +0 -7
- package/src/components/Row.js +0 -48
- package/src/components/Row.tsx +0 -108
- package/src/components/RowBodyIcon.js +0 -8
- package/src/components/RowBodyIcon.tsx +0 -47
- package/src/components/RowHeadlineImageCaption.js +0 -12
- package/src/components/RowHeadlineImageCaption.tsx +0 -49
- package/src/components/RowHeadlineImageIcon.js +0 -14
- package/src/components/RowHeadlineImageIcon.tsx +0 -61
- package/src/mappings/CardBlock.js +0 -123
- package/src/mappings/CardBlock.ts +0 -136
- package/src/mappings/CardContainer.js +0 -104
- package/src/mappings/CardContainer.ts +0 -116
- package/src/mappings/CardContainerRating.js +0 -126
- package/src/mappings/CardContainerRating.ts +0 -137
- package/src/mappings/CardContainerShortImage.js +0 -120
- package/src/mappings/CardContainerShortImage.ts +0 -130
- package/src/mappings/CardInline.js +0 -52
- package/src/mappings/CardInline.ts +0 -61
- package/src/mappings/Container.js +0 -30
- package/src/mappings/Container.ts +0 -41
- package/src/mappings/ProgressIndicator.js +0 -181
- package/src/mappings/ProgressIndicator.ts +0 -190
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
1
|
import * as React from "react";
|
|
3
2
|
import { Image } from "react-native";
|
|
4
3
|
import Config from "./Config";
|
|
@@ -10,6 +9,22 @@ const CircleImage = _ref => {
|
|
|
10
9
|
...props
|
|
11
10
|
} = _ref;
|
|
12
11
|
const borderRadius = size / 2;
|
|
12
|
+
return /*#__PURE__*/React.createElement(Image, {
|
|
13
|
+
style: [{
|
|
14
|
+
width: size,
|
|
15
|
+
height: size,
|
|
16
|
+
borderRadius
|
|
17
|
+
}, style],
|
|
18
|
+
source: typeof source === "string" ? {
|
|
19
|
+
uri: source
|
|
20
|
+
} : source,
|
|
21
|
+
resizeMode: "cover",
|
|
22
|
+
...props
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export default CircleImage;props
|
|
26
|
+
} = _ref;
|
|
27
|
+
const borderRadius = size / 2;
|
|
13
28
|
return /*#__PURE__*/React.createElement(Image, _extends({
|
|
14
29
|
style: [{
|
|
15
30
|
width: size,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
1
|
import * as React from "react";
|
|
3
2
|
import { ActivityIndicator, View, Text, StyleSheet, Pressable } from "react-native";
|
|
4
3
|
import color from "color";
|
|
@@ -75,7 +74,8 @@ const Button = _ref => {
|
|
|
75
74
|
elevation,
|
|
76
75
|
alignSelf: "stretch"
|
|
77
76
|
}
|
|
78
|
-
}, /*#__PURE__*/React.createElement(Pressable,
|
|
77
|
+
}, /*#__PURE__*/React.createElement(Pressable, {
|
|
78
|
+
...rest,
|
|
79
79
|
onPress: onPress,
|
|
80
80
|
accessibilityState: {
|
|
81
81
|
disabled
|
|
@@ -83,7 +83,7 @@ const Button = _ref => {
|
|
|
83
83
|
accessibilityRole: "button",
|
|
84
84
|
disabled: disabled || loading,
|
|
85
85
|
style: [styles.button, buttonStyle]
|
|
86
|
-
}
|
|
86
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
87
87
|
style: styles.content
|
|
88
88
|
}, icon && loading !== true ? /*#__PURE__*/React.createElement(View, {
|
|
89
89
|
style: iconStyle
|
|
@@ -114,4 +114,22 @@ const styles = StyleSheet.create({
|
|
|
114
114
|
width: Config.buttonIconSize
|
|
115
115
|
}
|
|
116
116
|
});
|
|
117
|
+
export default withTheme(Button);: 1,
|
|
118
|
+
style: [textStyle, typography.button]
|
|
119
|
+
}, children))));
|
|
120
|
+
};
|
|
121
|
+
const styles = StyleSheet.create({
|
|
122
|
+
button: {
|
|
123
|
+
minWidth: 64,
|
|
124
|
+
borderStyle: "solid"
|
|
125
|
+
},
|
|
126
|
+
content: {
|
|
127
|
+
flexDirection: "row",
|
|
128
|
+
alignItems: "center",
|
|
129
|
+
justifyContent: "center"
|
|
130
|
+
},
|
|
131
|
+
icon: {
|
|
132
|
+
width: Config.buttonIconSize
|
|
133
|
+
}
|
|
134
|
+
});
|
|
117
135
|
export default withTheme(Button);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
1
|
import * as React from "react";
|
|
3
2
|
import { View, StyleSheet, ActivityIndicator, Pressable, Platform } from "react-native";
|
|
4
3
|
import { withTheme } from "../theming";
|
|
@@ -18,7 +17,7 @@ const IconButton = _ref => {
|
|
|
18
17
|
...props
|
|
19
18
|
} = _ref;
|
|
20
19
|
const iconColor = customColor || theme.colors.primary;
|
|
21
|
-
return /*#__PURE__*/React.createElement(Pressable,
|
|
20
|
+
return /*#__PURE__*/React.createElement(Pressable, {
|
|
22
21
|
onPress: onPress,
|
|
23
22
|
disabled: disabled || loading,
|
|
24
23
|
style: _ref2 => {
|
|
@@ -32,8 +31,9 @@ const IconButton = _ref => {
|
|
|
32
31
|
alignItems: "center",
|
|
33
32
|
justifyContent: "center"
|
|
34
33
|
}, style];
|
|
35
|
-
}
|
|
36
|
-
|
|
34
|
+
},
|
|
35
|
+
...props
|
|
36
|
+
}, /*#__PURE__*/React.createElement(View, null, icon && !loading ? /*#__PURE__*/React.createElement(Icon, {
|
|
37
37
|
name: icon,
|
|
38
38
|
size: size - 2,
|
|
39
39
|
color: iconColor
|
|
@@ -54,4 +54,21 @@ const styles = StyleSheet.create({
|
|
|
54
54
|
})
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
|
+
export default withTheme(IconButton);ement(ActivityIndicator, {
|
|
58
|
+
size: "small",
|
|
59
|
+
color: iconColor
|
|
60
|
+
}) : null));
|
|
61
|
+
};
|
|
62
|
+
const styles = StyleSheet.create({
|
|
63
|
+
container: {
|
|
64
|
+
alignItems: "center",
|
|
65
|
+
justifyContent: "center",
|
|
66
|
+
...Platform.select({
|
|
67
|
+
web: {
|
|
68
|
+
cursor: "pointer",
|
|
69
|
+
userSelect: "none"
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
});
|
|
57
74
|
export default withTheme(IconButton);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
1
|
import React from "react";
|
|
3
2
|
import { Pressable as NativePressable } from "react-native";
|
|
4
3
|
export default function Pressable(_ref) {
|
|
@@ -13,8 +12,22 @@ export default function Pressable(_ref) {
|
|
|
13
12
|
style,
|
|
14
13
|
...props
|
|
15
14
|
} = _ref;
|
|
16
|
-
return /*#__PURE__*/React.createElement(NativePressable,
|
|
15
|
+
return /*#__PURE__*/React.createElement(NativePressable, {
|
|
17
16
|
onPress: onPress,
|
|
17
|
+
disabled: disabled,
|
|
18
|
+
delayLongPress: delayLongPress ? delayLongPress : 500,
|
|
19
|
+
hitSlop: hitSlop ? hitSlop : 8,
|
|
20
|
+
style: _ref2 => {
|
|
21
|
+
let {
|
|
22
|
+
pressed
|
|
23
|
+
} = _ref2;
|
|
24
|
+
return [{
|
|
25
|
+
opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1
|
|
26
|
+
}, style];
|
|
27
|
+
},
|
|
28
|
+
...props
|
|
29
|
+
}, children);
|
|
30
|
+
} onPress: onPress,
|
|
18
31
|
disabled: disabled,
|
|
19
32
|
delayLongPress: delayLongPress ? delayLongPress : 500,
|
|
20
33
|
hitSlop: hitSlop ? hitSlop : 8,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
1
|
import React from "react";
|
|
3
2
|
import { Shadow as ShadowComponent } from "react-native-shadow-2";
|
|
4
3
|
const Shadow = _ref => {
|
|
@@ -17,7 +16,7 @@ const Shadow = _ref => {
|
|
|
17
16
|
style,
|
|
18
17
|
...rest
|
|
19
18
|
} = _ref;
|
|
20
|
-
return /*#__PURE__*/React.createElement(ShadowComponent,
|
|
19
|
+
return /*#__PURE__*/React.createElement(ShadowComponent, {
|
|
21
20
|
offset: [offsetX, offsetY],
|
|
22
21
|
sides: {
|
|
23
22
|
start: showShadowSideStart,
|
|
@@ -32,6 +31,20 @@ const Shadow = _ref => {
|
|
|
32
31
|
bottomEnd: showShadowCornerBottomEnd
|
|
33
32
|
},
|
|
34
33
|
containerStyle: style,
|
|
34
|
+
paintInside: paintInside,
|
|
35
|
+
...rest
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
export default Shadow;hadowSideTop,
|
|
39
|
+
bottom: showShadowSideBottom
|
|
40
|
+
},
|
|
41
|
+
corners: {
|
|
42
|
+
topStart: showShadowCornerTopStart,
|
|
43
|
+
topEnd: showShadowCornerTopEnd,
|
|
44
|
+
bottomStart: showShadowCornerBottomStart,
|
|
45
|
+
bottomEnd: showShadowCornerBottomEnd
|
|
46
|
+
},
|
|
47
|
+
containerStyle: style,
|
|
35
48
|
paintInside: paintInside
|
|
36
49
|
}, rest));
|
|
37
50
|
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ScrollView, View, StyleSheet } from "react-native";
|
|
3
|
+
import { generateBorderStyles, TableStyleContext } from "./index";
|
|
4
|
+
export const Table = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
borderWidth = 1,
|
|
7
|
+
borderColor = "rgba(200, 200, 200, 1)",
|
|
8
|
+
borderStyle = "solid",
|
|
9
|
+
drawTopBorder = true,
|
|
10
|
+
drawBottomBorder = false,
|
|
11
|
+
drawStartBorder = false,
|
|
12
|
+
drawEndBorder = false,
|
|
13
|
+
cellVerticalPadding = 10,
|
|
14
|
+
cellHorizontalPadding = 10,
|
|
15
|
+
data,
|
|
16
|
+
keyExtractor,
|
|
17
|
+
renderItem,
|
|
18
|
+
children: childrenProp,
|
|
19
|
+
style,
|
|
20
|
+
...rest
|
|
21
|
+
} = _ref;
|
|
22
|
+
//Both 'renderItem' and 'data' are optional to allow direct children. But if one is included, both need to be included
|
|
23
|
+
if (data && !renderItem || renderItem && !data) {
|
|
24
|
+
throw new Error("'renderItem' and 'data' need to both be provided to render from 'data'. Either remove them entirley or include both");
|
|
25
|
+
}
|
|
26
|
+
if (data && renderItem && childrenProp) {
|
|
27
|
+
console.warn("'children' of Table ignored due to usage of 'data' and 'renderItem'");
|
|
28
|
+
}
|
|
29
|
+
const isTableHeader = React.useCallback(object => {
|
|
30
|
+
return object.isTableHeader;
|
|
31
|
+
}, []);
|
|
32
|
+
const isRenderItem = data && renderItem;
|
|
33
|
+
|
|
34
|
+
//Uses 'renderItem' and 'data' to create an array of children
|
|
35
|
+
const dataAsChildren = React.useMemo(() => {
|
|
36
|
+
if (!isRenderItem) return [];
|
|
37
|
+
return data.map((item, index) => {
|
|
38
|
+
const component = renderItem({
|
|
39
|
+
item,
|
|
40
|
+
index
|
|
41
|
+
});
|
|
42
|
+
if (!component) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const key = keyExtractor ? keyExtractor(item, index) : index.toString();
|
|
46
|
+
return /*#__PURE__*/React.cloneElement(component, {
|
|
47
|
+
key
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}, [data, renderItem, keyExtractor, isRenderItem]);
|
|
51
|
+
const children = isRenderItem ? dataAsChildren : React.Children.toArray(childrenProp);
|
|
52
|
+
const validChildren = React.useMemo(() => children.filter(item => /*#__PURE__*/React.isValidElement(item)), [children]);
|
|
53
|
+
const childrenWithoutHeader = React.useMemo(() => {
|
|
54
|
+
const flattenedWithoutNestedHeaders = validChildren.map(item => {
|
|
55
|
+
const nestedChildren = React.Children.toArray(item.props.children);
|
|
56
|
+
//Header can be nested in React.Fragment when in renderItem
|
|
57
|
+
const nestedHeaders = nestedChildren.filter(child => isTableHeader(child.props));
|
|
58
|
+
if (nestedHeaders !== null && nestedHeaders !== void 0 && nestedHeaders.length) {
|
|
59
|
+
//New element excluding header children
|
|
60
|
+
return /*#__PURE__*/React.cloneElement(item, {
|
|
61
|
+
children: nestedChildren.filter(child => !isTableHeader(child.props))
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return item;
|
|
65
|
+
});
|
|
66
|
+
return flattenedWithoutNestedHeaders.filter(item => !isTableHeader(item.props));
|
|
67
|
+
}, [validChildren, isTableHeader]);
|
|
68
|
+
const header = React.useMemo(() => {
|
|
69
|
+
const flattenedPossibleHeaders = validChildren.map(item => {
|
|
70
|
+
const nestedChildren = React.Children.toArray(item.props.children);
|
|
71
|
+
//Header can be nested in React.Fragment when in renderItem
|
|
72
|
+
const nestedHeaders = nestedChildren.filter(child => isTableHeader(child.props));
|
|
73
|
+
if (nestedHeaders !== null && nestedHeaders !== void 0 && nestedHeaders.length) {
|
|
74
|
+
return nestedHeaders[0];
|
|
75
|
+
}
|
|
76
|
+
return item;
|
|
77
|
+
});
|
|
78
|
+
const allHeaders = flattenedPossibleHeaders.filter(item => isTableHeader(item.props));
|
|
79
|
+
if (allHeaders.length) {
|
|
80
|
+
return allHeaders[0]; //Only 1 header taken
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return null;
|
|
84
|
+
}, [validChildren, isTableHeader]);
|
|
85
|
+
const contextValue = {
|
|
86
|
+
borderColor,
|
|
87
|
+
borderStyle,
|
|
88
|
+
borderWidth,
|
|
89
|
+
cellHorizontalPadding,
|
|
90
|
+
cellVerticalPadding
|
|
91
|
+
};
|
|
92
|
+
const borderViewStyle = generateBorderStyles({
|
|
93
|
+
borderColor,
|
|
94
|
+
borderWidth,
|
|
95
|
+
borderStyle,
|
|
96
|
+
drawTopBorder,
|
|
97
|
+
drawBottomBorder,
|
|
98
|
+
drawStartBorder,
|
|
99
|
+
drawEndBorder
|
|
100
|
+
});
|
|
101
|
+
return /*#__PURE__*/React.createElement(TableStyleContext.Provider, {
|
|
102
|
+
value: contextValue
|
|
103
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
104
|
+
style: [styles.container, borderViewStyle, style]
|
|
105
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, header), /*#__PURE__*/React.createElement(ScrollView, rest, childrenWithoutHeader)));
|
|
106
|
+
};
|
|
107
|
+
const styles = StyleSheet.create({
|
|
108
|
+
container: {
|
|
109
|
+
flex: 1
|
|
110
|
+
}
|
|
111
|
+
});ainer: {
|
|
112
|
+
flex: 1
|
|
113
|
+
}
|
|
114
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import { generateBorderStyles, TableStyleContext } from "./index";
|
|
4
|
+
const TableCell = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
borderWidth,
|
|
7
|
+
borderColor,
|
|
8
|
+
borderStyle,
|
|
9
|
+
drawTopBorder = false,
|
|
10
|
+
drawBottomBorder = false,
|
|
11
|
+
drawStartBorder = false,
|
|
12
|
+
drawEndBorder = true,
|
|
13
|
+
cellVerticalPadding,
|
|
14
|
+
cellHorizontalPadding,
|
|
15
|
+
children,
|
|
16
|
+
style
|
|
17
|
+
} = _ref;
|
|
18
|
+
const parentContextValue = React.useContext(TableStyleContext);
|
|
19
|
+
const borderViewStyle = generateBorderStyles({
|
|
20
|
+
borderColor: borderColor || parentContextValue.borderColor,
|
|
21
|
+
borderWidth: borderWidth || parentContextValue.borderWidth,
|
|
22
|
+
borderStyle: borderStyle || parentContextValue.borderStyle,
|
|
23
|
+
drawTopBorder,
|
|
24
|
+
drawBottomBorder,
|
|
25
|
+
drawStartBorder,
|
|
26
|
+
drawEndBorder
|
|
27
|
+
});
|
|
28
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
29
|
+
style: [styles.cellContainer, borderViewStyle, {
|
|
30
|
+
paddingVertical: cellVerticalPadding || parentContextValue.cellVerticalPadding,
|
|
31
|
+
paddingHorizontal: cellHorizontalPadding || parentContextValue.cellHorizontalPadding
|
|
32
|
+
}, style]
|
|
33
|
+
}, children);
|
|
34
|
+
};
|
|
35
|
+
const styles = StyleSheet.create({
|
|
36
|
+
cellContainer: {
|
|
37
|
+
flex: 1,
|
|
38
|
+
flexDirection: "row"
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
export default TableCell;
|
|
@@ -0,0 +1,52 @@
|
|
|
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 = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
borderWidth,
|
|
8
|
+
borderColor,
|
|
9
|
+
borderStyle,
|
|
10
|
+
drawTopBorder = false,
|
|
11
|
+
drawBottomBorder = true,
|
|
12
|
+
drawStartBorder = true,
|
|
13
|
+
drawEndBorder = false,
|
|
14
|
+
cellVerticalPadding,
|
|
15
|
+
cellHorizontalPadding,
|
|
16
|
+
isTableHeader = false,
|
|
17
|
+
children,
|
|
18
|
+
style,
|
|
19
|
+
theme
|
|
20
|
+
} = _ref;
|
|
21
|
+
const parentContextValue = React.useContext(TableStyleContext);
|
|
22
|
+
//Create context to use and pass to children based on own props or fall back to parent provided context
|
|
23
|
+
const contextValue = {
|
|
24
|
+
borderColor: borderColor || parentContextValue.borderColor,
|
|
25
|
+
borderStyle: borderStyle || parentContextValue.borderStyle,
|
|
26
|
+
borderWidth: borderWidth || parentContextValue.borderWidth,
|
|
27
|
+
cellHorizontalPadding: cellHorizontalPadding || parentContextValue.cellHorizontalPadding,
|
|
28
|
+
cellVerticalPadding: cellVerticalPadding || parentContextValue.cellVerticalPadding
|
|
29
|
+
};
|
|
30
|
+
const borderViewStyle = generateBorderStyles({
|
|
31
|
+
borderColor: contextValue.borderColor,
|
|
32
|
+
borderWidth: contextValue.borderWidth,
|
|
33
|
+
borderStyle: contextValue.borderStyle,
|
|
34
|
+
drawTopBorder,
|
|
35
|
+
drawBottomBorder,
|
|
36
|
+
drawStartBorder,
|
|
37
|
+
drawEndBorder
|
|
38
|
+
});
|
|
39
|
+
return /*#__PURE__*/React.createElement(TableStyleContext.Provider, {
|
|
40
|
+
value: contextValue
|
|
41
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
42
|
+
style: [borderViewStyle, isTableHeader ? {
|
|
43
|
+
backgroundColor: theme.colors.primary
|
|
44
|
+
} : {}, style, styles.cellsContainer]
|
|
45
|
+
}, children));
|
|
46
|
+
};
|
|
47
|
+
const styles = StyleSheet.create({
|
|
48
|
+
cellsContainer: {
|
|
49
|
+
flexDirection: "row"
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
export default withTheme(TableRow);;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export const TableStyleContext = /*#__PURE__*/React.createContext({});
|
|
3
|
+
export function generateBorderStyles(_ref) {
|
|
4
|
+
let {
|
|
5
|
+
borderColor,
|
|
6
|
+
borderWidth,
|
|
7
|
+
borderStyle,
|
|
8
|
+
drawTopBorder,
|
|
9
|
+
drawBottomBorder,
|
|
10
|
+
drawStartBorder,
|
|
11
|
+
drawEndBorder
|
|
12
|
+
} = _ref;
|
|
13
|
+
return {
|
|
14
|
+
borderColor,
|
|
15
|
+
borderStyle,
|
|
16
|
+
borderTopWidth: drawTopBorder ? borderWidth : 0,
|
|
17
|
+
borderBottomWidth: drawBottomBorder ? borderWidth : 0,
|
|
18
|
+
borderStartWidth: drawStartBorder ? borderWidth : 0,
|
|
19
|
+
borderEndWidth: drawEndBorder ? borderWidth : 0
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export { Table } from "./Table";
|
|
23
|
+
export { default as TableRow } from "./TableRow";
|
|
24
|
+
export { default as TableCell } from "./TableCell";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
1
|
import * as React from "react";
|
|
3
2
|
import { withTheme } from "../theming";
|
|
4
3
|
import { StyleSheet } from "react-native";
|
|
@@ -38,13 +37,28 @@ const ToggleButton = _ref => {
|
|
|
38
37
|
setInternalValue(!internalValue);
|
|
39
38
|
onPress(!internalValue);
|
|
40
39
|
};
|
|
41
|
-
return /*#__PURE__*/React.createElement(IconButton,
|
|
40
|
+
return /*#__PURE__*/React.createElement(IconButton, {
|
|
42
41
|
Icon: Icon,
|
|
43
42
|
icon: icon,
|
|
44
43
|
size: iconSize,
|
|
45
44
|
color: internalValue ? colors[color] : colors[colorSecondary],
|
|
46
45
|
onPress: handlePress,
|
|
47
46
|
disabled: disabled,
|
|
47
|
+
style: [styles.mainContainer, {
|
|
48
|
+
width,
|
|
49
|
+
height,
|
|
50
|
+
backgroundColor: internalValue ? colors[colorSecondary] : colors[color],
|
|
51
|
+
borderColor: colors[borderColor]
|
|
52
|
+
}, style],
|
|
53
|
+
...rest
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
const styles = StyleSheet.create({
|
|
57
|
+
mainContainer: {
|
|
58
|
+
borderWidth: 1
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
export default withTheme(ToggleButton);: disabled,
|
|
48
62
|
style: [styles.mainContainer, {
|
|
49
63
|
width,
|
|
50
64
|
height,
|
package/lib/module/constants.js
CHANGED
package/lib/module/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,15 +36,13 @@ 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
|
|
|
41
41
|
/* Deprecated: Fix or Delete! */
|
|
42
42
|
export { default as DatePicker } from "./components/DatePicker/DatePicker";
|
|
43
43
|
export { default as Picker } from "./components/Picker/Picker";
|
|
44
44
|
export { default as ProgressBar } from "./components/ProgressBar";
|
|
45
45
|
export { default as ProgressCircle } from "./components/ProgressCircle";
|
|
46
|
-
export { default as RowBodyIcon } from "./components/RowBodyIcon";
|
|
47
|
-
export { default as RowHeadlineImageCaption } from "./components/RowHeadlineImageCaption";
|
|
48
|
-
export { default as RowHeadlineImageIcon } from "./components/RowHeadlineImageIcon";
|
|
49
46
|
export { default as Slider } from "./components/Slider";
|
|
50
47
|
export { default as Stepper } from "./components/Stepper";
|
|
51
48
|
export { useAuthState } from "./components/useAuthState";
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { COMPONENT_TYPES, createBoolProp, CONTAINER_COMPONENT_STYLES_SECTIONS, createStaticNumberProp, StylesPanelSections, createStaticBoolProp } from "@draftbit/types";
|
|
2
|
+
const SHARED_SEED_DATA = {
|
|
3
|
+
category: COMPONENT_TYPES.layout,
|
|
4
|
+
packageName: "native-base",
|
|
5
|
+
stylesPanelSections: CONTAINER_COMPONENT_STYLES_SECTIONS
|
|
6
|
+
};
|
|
7
|
+
const CONTAINER_COMPONENT_STYLES_WITHOUT_FLEX = CONTAINER_COMPONENT_STYLES_SECTIONS.filter(item => item !== StylesPanelSections.LayoutFlexItems && item !== StylesPanelSections.LayoutContent);
|
|
8
|
+
export const SEED_DATA = [{
|
|
9
|
+
name: "Aspect Ratio",
|
|
10
|
+
tag: "AspectRatio",
|
|
11
|
+
description: "Controls the size of the undefined dimension of a node or child component using an aspect ratio",
|
|
12
|
+
...SHARED_SEED_DATA,
|
|
13
|
+
props: {
|
|
14
|
+
ratio: createStaticNumberProp({
|
|
15
|
+
label: "Ratio",
|
|
16
|
+
description: "The aspect ratio of the container in decimal format (ex: 3/4 -> 1.33)",
|
|
17
|
+
defaultValue: 1.33
|
|
18
|
+
})
|
|
19
|
+
},
|
|
20
|
+
stylesPanelSections: [StylesPanelSections.Background, StylesPanelSections.Size, StylesPanelSections.Margins, StylesPanelSections.Position, StylesPanelSections.Borders, StylesPanelSections.Effects]
|
|
21
|
+
}, {
|
|
22
|
+
name: "Box",
|
|
23
|
+
tag: "Box",
|
|
24
|
+
description: "This is a generic component for low level layout needs. It is similar to a div in HTML",
|
|
25
|
+
...SHARED_SEED_DATA
|
|
26
|
+
}, {
|
|
27
|
+
name: "Center",
|
|
28
|
+
tag: "Center",
|
|
29
|
+
description: "Center aligns its contents to the center within itself",
|
|
30
|
+
...SHARED_SEED_DATA,
|
|
31
|
+
stylesPanelSections: CONTAINER_COMPONENT_STYLES_WITHOUT_FLEX
|
|
32
|
+
}, {
|
|
33
|
+
name: "Circle",
|
|
34
|
+
tag: "Circle",
|
|
35
|
+
description: "Center aligns its contents to the center within itself with a round border radius",
|
|
36
|
+
...SHARED_SEED_DATA,
|
|
37
|
+
stylesPanelSections: CONTAINER_COMPONENT_STYLES_WITHOUT_FLEX
|
|
38
|
+
}, {
|
|
39
|
+
name: "Container",
|
|
40
|
+
tag: "Container",
|
|
41
|
+
description: "The Container restricts a content's width according to current breakpoint, while keeping the size fluid",
|
|
42
|
+
props: {
|
|
43
|
+
centerContent: createStaticBoolProp({
|
|
44
|
+
label: "Center content",
|
|
45
|
+
description: "Center child elements based on their content width",
|
|
46
|
+
defaultValue: true
|
|
47
|
+
})
|
|
48
|
+
},
|
|
49
|
+
...SHARED_SEED_DATA
|
|
50
|
+
}, {
|
|
51
|
+
name: "Column",
|
|
52
|
+
tag: "Column",
|
|
53
|
+
description: "Column aligns items vertically",
|
|
54
|
+
layout: {
|
|
55
|
+
flexDirection: "column"
|
|
56
|
+
},
|
|
57
|
+
...SHARED_SEED_DATA
|
|
58
|
+
}, {
|
|
59
|
+
name: "Row",
|
|
60
|
+
tag: "Row",
|
|
61
|
+
description: "Column aligns items horizontally",
|
|
62
|
+
layout: {
|
|
63
|
+
flexDirection: "row"
|
|
64
|
+
},
|
|
65
|
+
...SHARED_SEED_DATA
|
|
66
|
+
}, {
|
|
67
|
+
name: "Spacer",
|
|
68
|
+
tag: "Spacer",
|
|
69
|
+
description: "An adjustable, empty space that can be used to tune the spacing between child elements within Flex",
|
|
70
|
+
layout: {
|
|
71
|
+
flex: 1
|
|
72
|
+
},
|
|
73
|
+
...SHARED_SEED_DATA,
|
|
74
|
+
stylesPanelSections: [StylesPanelSections.LayoutSelectedItem, StylesPanelSections.Background, StylesPanelSections.Margins]
|
|
75
|
+
}, {
|
|
76
|
+
name: "Stack",
|
|
77
|
+
tag: "Stack",
|
|
78
|
+
description: "Stack aligns items vertically or horizontally based on the direction prop",
|
|
79
|
+
...SHARED_SEED_DATA,
|
|
80
|
+
props: {
|
|
81
|
+
isDisabled: createBoolProp({
|
|
82
|
+
label: "Disabled",
|
|
83
|
+
description: "If true, the Stack will be disabled"
|
|
84
|
+
}),
|
|
85
|
+
isInvalid: createBoolProp({
|
|
86
|
+
label: "Invalid",
|
|
87
|
+
description: "If true, the Stack will be invalid"
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
name: "ZStack",
|
|
92
|
+
tag: "ZStack",
|
|
93
|
+
description: "ZStack aligns items to the z-axis",
|
|
94
|
+
...SHARED_SEED_DATA,
|
|
95
|
+
props: {
|
|
96
|
+
reversed: createBoolProp({
|
|
97
|
+
label: "Reversed",
|
|
98
|
+
description: "Determines whether to reverse the direction of items"
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
}];
|