@draftbit/core 46.8.2-2fe7f4.2 → 46.8.2-3b498d.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/Accordion/AccordionItem.js +4 -23
- package/lib/commonjs/components/TabView/TabView.js +5 -24
- package/lib/module/components/TabView/TabView.js +4 -24
- package/lib/typescript/src/components/TabView/TabView.d.ts.map +1 -1
- package/lib/typescript/src/components/TabView/TabViewItem.d.ts +1 -1
- package/lib/typescript/src/components/TabView/TabViewItem.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/TabView/TabView.js +4 -15
- package/src/components/TabView/TabView.tsx +3 -27
- package/src/components/TabView/TabViewItem.tsx +1 -1
|
@@ -12,6 +12,7 @@ var _theming = require("../../theming");
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
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); }
|
|
15
16
|
const AccordionItem = _ref => {
|
|
16
17
|
let {
|
|
17
18
|
Icon,
|
|
@@ -26,10 +27,9 @@ const AccordionItem = _ref => {
|
|
|
26
27
|
textStyles,
|
|
27
28
|
viewStyles
|
|
28
29
|
} = (0, _utilities.extractStyles)(style);
|
|
29
|
-
return /*#__PURE__*/React.createElement(_reactNative.Pressable, {
|
|
30
|
-
style: [styles.container, viewStyles]
|
|
31
|
-
|
|
32
|
-
}, /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
30
|
+
return /*#__PURE__*/React.createElement(_reactNative.Pressable, _extends({
|
|
31
|
+
style: [styles.container, viewStyles]
|
|
32
|
+
}, rest), /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
33
33
|
style: styles.row
|
|
34
34
|
}, icon ? /*#__PURE__*/React.createElement(Icon, {
|
|
35
35
|
name: icon,
|
|
@@ -61,23 +61,4 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
var _default = (0, _theming.withTheme)(AccordionItem);
|
|
64
|
-
exports.default = _default;.StyleSheet.create({
|
|
65
|
-
container: {
|
|
66
|
-
padding: 8
|
|
67
|
-
},
|
|
68
|
-
row: {
|
|
69
|
-
flexDirection: "row",
|
|
70
|
-
alignItems: "center",
|
|
71
|
-
paddingLeft: 8
|
|
72
|
-
},
|
|
73
|
-
item: {
|
|
74
|
-
marginVertical: 6,
|
|
75
|
-
paddingLeft: 8
|
|
76
|
-
},
|
|
77
|
-
content: {
|
|
78
|
-
flex: 1,
|
|
79
|
-
justifyContent: "center"
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
var _default = (0, _theming.withTheme)(AccordionItem);
|
|
83
64
|
exports.default = _default;
|
|
@@ -7,8 +7,10 @@ exports.default = void 0;
|
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _reactNativeTabView = require("react-native-tab-view");
|
|
10
|
+
var _TabViewItem = _interopRequireDefault(require("./TabViewItem"));
|
|
10
11
|
var _theming = require("../../theming");
|
|
11
12
|
var _utilities = require("../../utilities");
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
15
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
16
|
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); }
|
|
@@ -38,17 +40,11 @@ const TabViewComponent = _ref => {
|
|
|
38
40
|
viewStyles
|
|
39
41
|
} = (0, _utilities.extractStyles)(style);
|
|
40
42
|
|
|
41
|
-
//Check type of child using props
|
|
42
|
-
//Regular '.type' cannot work because Draftbit strips the type in Draft view
|
|
43
|
-
const instanceOfTabViewItemProps = object => {
|
|
44
|
-
return "title" in object;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
43
|
//Populate routes and scenes based on children
|
|
48
44
|
React.useEffect(() => {
|
|
49
45
|
const newRoutes = [];
|
|
50
46
|
const scenes = {};
|
|
51
|
-
React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) &&
|
|
47
|
+
React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && child.type === _TabViewItem.default).forEach((item, idx) => {
|
|
52
48
|
const child = item;
|
|
53
49
|
newRoutes.push({
|
|
54
50
|
key: idx.toString(),
|
|
@@ -84,23 +80,16 @@ const TabViewComponent = _ref => {
|
|
|
84
80
|
color
|
|
85
81
|
} = _ref2;
|
|
86
82
|
return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
|
|
87
|
-
style: styles.icon,
|
|
88
83
|
name: route.icon,
|
|
89
84
|
color: color,
|
|
90
|
-
size:
|
|
85
|
+
size: 36
|
|
91
86
|
}) : null;
|
|
92
87
|
},
|
|
93
88
|
style: {
|
|
94
89
|
backgroundColor: tabsBackgroundColor || theme.colors.background
|
|
95
|
-
}
|
|
96
|
-
contentContainerStyle: styles.tabBarContainer
|
|
90
|
+
}
|
|
97
91
|
}));
|
|
98
92
|
};
|
|
99
|
-
|
|
100
|
-
//Cannot render TabView without at least one tab
|
|
101
|
-
if (!routes.length) {
|
|
102
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
103
|
-
}
|
|
104
93
|
return /*#__PURE__*/React.createElement(_reactNativeTabView.TabView, {
|
|
105
94
|
style: [styles.tabView, viewStyles],
|
|
106
95
|
navigationState: {
|
|
@@ -118,14 +107,6 @@ const TabViewComponent = _ref => {
|
|
|
118
107
|
const styles = _reactNative.StyleSheet.create({
|
|
119
108
|
tabView: {
|
|
120
109
|
flex: 1
|
|
121
|
-
},
|
|
122
|
-
//Prevent height of bar from filling container
|
|
123
|
-
tabBarContainer: {
|
|
124
|
-
flex: undefined
|
|
125
|
-
},
|
|
126
|
-
icon: {
|
|
127
|
-
width: 16,
|
|
128
|
-
height: 16
|
|
129
110
|
}
|
|
130
111
|
});
|
|
131
112
|
var _default = (0, _theming.withTheme)(TabViewComponent);
|
|
@@ -2,6 +2,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { StyleSheet } from "react-native";
|
|
4
4
|
import { TabView, TabBar, SceneMap } from "react-native-tab-view";
|
|
5
|
+
import TabViewItem from "./TabViewItem";
|
|
5
6
|
import { withTheme } from "../../theming";
|
|
6
7
|
import { extractStyles } from "../../utilities";
|
|
7
8
|
const TabViewComponent = _ref => {
|
|
@@ -30,17 +31,11 @@ const TabViewComponent = _ref => {
|
|
|
30
31
|
viewStyles
|
|
31
32
|
} = extractStyles(style);
|
|
32
33
|
|
|
33
|
-
//Check type of child using props
|
|
34
|
-
//Regular '.type' cannot work because Draftbit strips the type in Draft view
|
|
35
|
-
const instanceOfTabViewItemProps = object => {
|
|
36
|
-
return "title" in object;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
34
|
//Populate routes and scenes based on children
|
|
40
35
|
React.useEffect(() => {
|
|
41
36
|
const newRoutes = [];
|
|
42
37
|
const scenes = {};
|
|
43
|
-
React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) &&
|
|
38
|
+
React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && child.type === TabViewItem).forEach((item, idx) => {
|
|
44
39
|
const child = item;
|
|
45
40
|
newRoutes.push({
|
|
46
41
|
key: idx.toString(),
|
|
@@ -76,23 +71,16 @@ const TabViewComponent = _ref => {
|
|
|
76
71
|
color
|
|
77
72
|
} = _ref2;
|
|
78
73
|
return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
|
|
79
|
-
style: styles.icon,
|
|
80
74
|
name: route.icon,
|
|
81
75
|
color: color,
|
|
82
|
-
size:
|
|
76
|
+
size: 36
|
|
83
77
|
}) : null;
|
|
84
78
|
},
|
|
85
79
|
style: {
|
|
86
80
|
backgroundColor: tabsBackgroundColor || theme.colors.background
|
|
87
|
-
}
|
|
88
|
-
contentContainerStyle: styles.tabBarContainer
|
|
81
|
+
}
|
|
89
82
|
}));
|
|
90
83
|
};
|
|
91
|
-
|
|
92
|
-
//Cannot render TabView without at least one tab
|
|
93
|
-
if (!routes.length) {
|
|
94
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
95
|
-
}
|
|
96
84
|
return /*#__PURE__*/React.createElement(TabView, {
|
|
97
85
|
style: [styles.tabView, viewStyles],
|
|
98
86
|
navigationState: {
|
|
@@ -110,14 +98,6 @@ const TabViewComponent = _ref => {
|
|
|
110
98
|
const styles = StyleSheet.create({
|
|
111
99
|
tabView: {
|
|
112
100
|
flex: 1
|
|
113
|
-
},
|
|
114
|
-
//Prevent height of bar from filling container
|
|
115
|
-
tabBarContainer: {
|
|
116
|
-
flex: undefined
|
|
117
|
-
},
|
|
118
|
-
icon: {
|
|
119
|
-
width: 16,
|
|
120
|
-
height: 16
|
|
121
101
|
}
|
|
122
102
|
});
|
|
123
103
|
export default withTheme(TabViewComponent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabView.d.ts","sourceRoot":"","sources":["../../../../../src/components/TabView/TabView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAc,MAAM,cAAc,CAAC;AAWhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAMvD,aAAK,cAAc,GAAG,KAAK,GAAG,QAAQ,CAAC;AACvC,aAAK,mBAAmB,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAEvD,aAAK,YAAY,GAAG;IAClB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,KAAK,EAAE,KAAK,CAAC;CACd,GAAG,QAAQ,CAAC;;;;
|
|
1
|
+
{"version":3,"file":"TabView.d.ts","sourceRoot":"","sources":["../../../../../src/components/TabView/TabView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAc,MAAM,cAAc,CAAC;AAWhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAMvD,aAAK,cAAc,GAAG,KAAK,GAAG,QAAQ,CAAC;AACvC,aAAK,mBAAmB,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAEvD,aAAK,YAAY,GAAG;IAClB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,KAAK,EAAE,KAAK,CAAC;CACd,GAAG,QAAQ,CAAC;;;;AAmGb,wBAA2C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabViewItem.d.ts","sourceRoot":"","sources":["../../../../../src/components/TabView/TabViewItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAoB,MAAM,cAAc,CAAC;AAGtE,
|
|
1
|
+
{"version":3,"file":"TabViewItem.d.ts","sourceRoot":"","sources":["../../../../../src/components/TabView/TabViewItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAoB,MAAM,cAAc,CAAC;AAGtE,UAAU,gBAAgB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAKpE,CAAC;AAQF,eAAe,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "46.8.2-
|
|
3
|
+
"version": "46.8.2-3b498d.2+3b498d6",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@date-io/date-fns": "^1.3.13",
|
|
43
43
|
"@draftbit/react-theme-provider": "^2.1.1",
|
|
44
|
-
"@draftbit/types": "^46.8.2-
|
|
44
|
+
"@draftbit/types": "^46.8.2-3b498d.2+3b498d6",
|
|
45
45
|
"@material-ui/core": "^4.11.0",
|
|
46
46
|
"@material-ui/pickers": "^3.2.10",
|
|
47
47
|
"@react-native-community/slider": "4.2.3",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
]
|
|
95
95
|
]
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "3b498d688155757b31754dc848a019892c1d55b8"
|
|
98
98
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { StyleSheet } from "react-native";
|
|
3
3
|
import { TabView, TabBar, SceneMap, } from "react-native-tab-view";
|
|
4
|
+
import TabViewItem from "./TabViewItem";
|
|
4
5
|
import { withTheme } from "../../theming";
|
|
5
6
|
import { extractStyles } from "../../utilities";
|
|
6
7
|
const TabViewComponent = ({ Icon, onIndexChanged, onEndReached, tabBarPosition, keyboardDismissMode, swipeEnabled, scrollEnabled, activeColor, inactiveColor, pressColor, indicatorColor, tabsBackgroundColor, style, theme, children, }) => {
|
|
@@ -8,17 +9,12 @@ const TabViewComponent = ({ Icon, onIndexChanged, onEndReached, tabBarPosition,
|
|
|
8
9
|
const [routes, setRoutes] = React.useState([]);
|
|
9
10
|
const [tabScenes, setTabScenes] = React.useState({});
|
|
10
11
|
const { textStyles, viewStyles } = extractStyles(style);
|
|
11
|
-
//Check type of child using props
|
|
12
|
-
//Regular '.type' cannot work because Draftbit strips the type in Draft view
|
|
13
|
-
const instanceOfTabViewItemProps = (object) => {
|
|
14
|
-
return "title" in object;
|
|
15
|
-
};
|
|
16
12
|
//Populate routes and scenes based on children
|
|
17
13
|
React.useEffect(() => {
|
|
18
14
|
const newRoutes = [];
|
|
19
15
|
const scenes = {};
|
|
20
16
|
React.Children.toArray(children)
|
|
21
|
-
.filter((child) => React.isValidElement(child) &&
|
|
17
|
+
.filter((child) => React.isValidElement(child) && child.type === TabViewItem)
|
|
22
18
|
.forEach((item, idx) => {
|
|
23
19
|
const child = item;
|
|
24
20
|
newRoutes.push({
|
|
@@ -42,20 +38,13 @@ const TabViewComponent = ({ Icon, onIndexChanged, onEndReached, tabBarPosition,
|
|
|
42
38
|
const renderTabBar = (props) => {
|
|
43
39
|
return (React.createElement(TabBar, { ...props, activeColor: activeColor || theme.colors.primary, inactiveColor: inactiveColor || theme.colors.divider, pressColor: pressColor || theme.colors.primary, scrollEnabled: scrollEnabled, indicatorStyle: {
|
|
44
40
|
backgroundColor: indicatorColor || theme.colors.primary,
|
|
45
|
-
}, labelStyle: textStyles, renderIcon: ({ route, color }) => (route === null || route === void 0 ? void 0 : route.icon) ? (React.createElement(Icon, {
|
|
41
|
+
}, labelStyle: textStyles, renderIcon: ({ route, color }) => (route === null || route === void 0 ? void 0 : route.icon) ? (React.createElement(Icon, { name: route.icon, color: color, size: 36 })) : null, style: {
|
|
46
42
|
backgroundColor: tabsBackgroundColor || theme.colors.background,
|
|
47
|
-
}
|
|
43
|
+
} }));
|
|
48
44
|
};
|
|
49
|
-
//Cannot render TabView without at least one tab
|
|
50
|
-
if (!routes.length) {
|
|
51
|
-
return React.createElement(React.Fragment, null);
|
|
52
|
-
}
|
|
53
45
|
return (React.createElement(TabView, { style: [styles.tabView, viewStyles], navigationState: { index, routes }, renderScene: SceneMap(tabScenes), renderTabBar: renderTabBar, onIndexChange: indexChangeHandler, tabBarPosition: tabBarPosition, keyboardDismissMode: keyboardDismissMode, swipeEnabled: swipeEnabled }));
|
|
54
46
|
};
|
|
55
47
|
const styles = StyleSheet.create({
|
|
56
48
|
tabView: { flex: 1 },
|
|
57
|
-
//Prevent height of bar from filling container
|
|
58
|
-
tabBarContainer: { flex: undefined },
|
|
59
|
-
icon: { width: 16, height: 16 },
|
|
60
49
|
});
|
|
61
50
|
export default withTheme(TabViewComponent);
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
Route,
|
|
10
10
|
} from "react-native-tab-view";
|
|
11
11
|
|
|
12
|
-
import
|
|
12
|
+
import TabViewItem from "./TabViewItem";
|
|
13
13
|
import type { IconSlot } from "../../interfaces/Icon";
|
|
14
14
|
import { withTheme } from "../../theming";
|
|
15
15
|
import type { Theme } from "../../styles/DefaultTheme";
|
|
@@ -60,14 +60,6 @@ const TabViewComponent: React.FC<React.PropsWithChildren<TabViewProps>> = ({
|
|
|
60
60
|
|
|
61
61
|
const { textStyles, viewStyles } = extractStyles(style);
|
|
62
62
|
|
|
63
|
-
//Check type of child using props
|
|
64
|
-
//Regular '.type' cannot work because Draftbit strips the type in Draft view
|
|
65
|
-
const instanceOfTabViewItemProps = (
|
|
66
|
-
object: any
|
|
67
|
-
): object is TabViewItemProps => {
|
|
68
|
-
return "title" in object;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
63
|
//Populate routes and scenes based on children
|
|
72
64
|
React.useEffect(() => {
|
|
73
65
|
const newRoutes: Route[] = [];
|
|
@@ -75,8 +67,7 @@ const TabViewComponent: React.FC<React.PropsWithChildren<TabViewProps>> = ({
|
|
|
75
67
|
|
|
76
68
|
React.Children.toArray(children)
|
|
77
69
|
.filter(
|
|
78
|
-
(child) =>
|
|
79
|
-
React.isValidElement(child) && instanceOfTabViewItemProps(child.props)
|
|
70
|
+
(child) => React.isValidElement(child) && child.type === TabViewItem
|
|
80
71
|
)
|
|
81
72
|
.forEach((item: any, idx) => {
|
|
82
73
|
const child = item as React.ReactElement;
|
|
@@ -115,27 +106,16 @@ const TabViewComponent: React.FC<React.PropsWithChildren<TabViewProps>> = ({
|
|
|
115
106
|
labelStyle={textStyles}
|
|
116
107
|
renderIcon={({ route, color }) =>
|
|
117
108
|
route?.icon ? (
|
|
118
|
-
<Icon
|
|
119
|
-
style={styles.icon}
|
|
120
|
-
name={route.icon}
|
|
121
|
-
color={color}
|
|
122
|
-
size={16}
|
|
123
|
-
/>
|
|
109
|
+
<Icon name={route.icon} color={color} size={36} />
|
|
124
110
|
) : null
|
|
125
111
|
}
|
|
126
112
|
style={{
|
|
127
113
|
backgroundColor: tabsBackgroundColor || theme.colors.background,
|
|
128
114
|
}}
|
|
129
|
-
contentContainerStyle={styles.tabBarContainer}
|
|
130
115
|
/>
|
|
131
116
|
);
|
|
132
117
|
};
|
|
133
118
|
|
|
134
|
-
//Cannot render TabView without at least one tab
|
|
135
|
-
if (!routes.length) {
|
|
136
|
-
return <></>;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
119
|
return (
|
|
140
120
|
<TabView
|
|
141
121
|
style={[styles.tabView, viewStyles]}
|
|
@@ -152,10 +132,6 @@ const TabViewComponent: React.FC<React.PropsWithChildren<TabViewProps>> = ({
|
|
|
152
132
|
|
|
153
133
|
const styles = StyleSheet.create({
|
|
154
134
|
tabView: { flex: 1 },
|
|
155
|
-
|
|
156
|
-
//Prevent height of bar from filling container
|
|
157
|
-
tabBarContainer: { flex: undefined },
|
|
158
|
-
icon: { width: 16, height: 16 },
|
|
159
135
|
});
|
|
160
136
|
|
|
161
137
|
export default withTheme(TabViewComponent);
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { StyleProp, ViewStyle, StyleSheet, View } from "react-native";
|
|
3
3
|
|
|
4
4
|
//Props used by parent (TabView) to create tabs
|
|
5
|
-
|
|
5
|
+
interface TabViewItemProps {
|
|
6
6
|
title: string;
|
|
7
7
|
icon?: string;
|
|
8
8
|
accessibilityLabel?: string;
|