@draftbit/core 46.8.2-bdb2fb.2 → 46.8.2-cd657e.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.
@@ -5,12 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
- var _reactNative = require("react-native");
9
8
  var _reactNativeTabView = require("react-native-tab-view");
10
- var _TabViewItem = _interopRequireDefault(require("./TabViewItem"));
11
9
  var _theming = require("../../theming");
12
10
  var _utilities = require("../../utilities");
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
11
  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); }
15
12
  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; }
16
13
  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); }
@@ -40,11 +37,17 @@ const TabViewComponent = _ref => {
40
37
  viewStyles
41
38
  } = (0, _utilities.extractStyles)(style);
42
39
 
40
+ //Check type of child using props
41
+ //Regular '.type' cannot work because Draftbit strips the type in Draft view
42
+ const instanceOfTabViewItemProps = object => {
43
+ return "title" in object;
44
+ };
45
+
43
46
  //Populate routes and scenes based on children
44
47
  React.useEffect(() => {
45
48
  const newRoutes = [];
46
49
  const scenes = {};
47
- React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && child.type === _TabViewItem.default).forEach((item, idx) => {
50
+ React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && instanceOfTabViewItemProps(child.props)).forEach((item, idx) => {
48
51
  const child = item;
49
52
  newRoutes.push({
50
53
  key: idx.toString(),
@@ -82,7 +85,7 @@ const TabViewComponent = _ref => {
82
85
  return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
83
86
  name: route.icon,
84
87
  color: color,
85
- size: 36
88
+ size: 16
86
89
  }) : null;
87
90
  },
88
91
  style: {
@@ -90,8 +93,13 @@ const TabViewComponent = _ref => {
90
93
  }
91
94
  }));
92
95
  };
96
+
97
+ //Cannot render TabView without at least one tab
98
+ if (!routes.length) {
99
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
100
+ }
93
101
  return /*#__PURE__*/React.createElement(_reactNativeTabView.TabView, {
94
- style: [styles.tabView, viewStyles],
102
+ style: [viewStyles],
95
103
  navigationState: {
96
104
  index,
97
105
  routes
@@ -104,10 +112,5 @@ const TabViewComponent = _ref => {
104
112
  swipeEnabled: swipeEnabled
105
113
  });
106
114
  };
107
- const styles = _reactNative.StyleSheet.create({
108
- tabView: {
109
- flex: 1
110
- }
111
- });
112
115
  var _default = (0, _theming.withTheme)(TabViewComponent);
113
116
  exports.default = _default;
@@ -11,9 +11,6 @@ const SEED_DATA = {
11
11
  description: "Tab view container",
12
12
  category: _types.COMPONENT_TYPES.swiper,
13
13
  stylesPanelSections: [_types.StylesPanelSections.Size, _types.StylesPanelSections.MarginsAndPaddings, _types.StylesPanelSections.Position, _types.StylesPanelSections.Effects, _types.StylesPanelSections.LayoutSelectedItem, _types.StylesPanelSections.Background, _types.StylesPanelSections.Typography],
14
- layout: {
15
- flex: 1
16
- },
17
14
  triggers: [_types.Triggers.OnIndexChanged, _types.Triggers.OnEndReached],
18
15
  props: {
19
16
  onIndexChanged: (0, _types.createActionProp)({
@@ -42,7 +39,7 @@ const SEED_DATA = {
42
39
  defaultValue: true
43
40
  }),
44
41
  scrollEnabled: (0, _types.createStaticBoolProp)({
45
- label: "Scroll Enabled",
42
+ label: "Tab Scroll Enabled",
46
43
  description: "Whether scrolling of tabs is enabled or not",
47
44
  defaultValue: false
48
45
  }),
@@ -1,3 +1,6 @@
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1
4
  import * as React from "react";
2
5
  import { View, StyleSheet } from "react-native";
3
6
  /**
@@ -6,47 +9,18 @@ import { View, StyleSheet } from "react-native";
6
9
  export default class PortalManager extends React.PureComponent {
7
10
  constructor() {
8
11
  super(...arguments);
9
- this.state = {
12
+ _defineProperty(this, "state", {
10
13
  portals: []
11
- };
12
- this.mount = (key, children) => {
14
+ });
15
+ _defineProperty(this, "mount", (key, children) => {
13
16
  this.setState(state => ({
14
17
  portals: [...state.portals, {
15
18
  key,
16
19
  children
17
20
  }]
18
21
  }));
19
- };
20
- this.update = (key, children) => this.setState(state => ({
21
- portals: state.portals.map(item => {
22
- if (item.key === key) {
23
- return {
24
- ...item,
25
- children
26
- };
27
- }
28
- return item;
29
- })
30
- }));
31
- this.unmount = key => this.setState(state => ({
32
- portals: state.portals.filter(item => item.key !== key)
33
- }));
34
- }
35
- render() {
36
- return this.state.portals.map(_ref => {
37
- let {
38
- key,
39
- children
40
- } = _ref;
41
- return /*#__PURE__*/React.createElement(View, {
42
- key: key,
43
- collapsable: false /* Need collapsable=false here to clip the elevations, otherwise they appear above sibling components */,
44
- pointerEvents: "box-none",
45
- style: StyleSheet.absoluteFill
46
- }, children);
47
22
  });
48
- }
49
- }ey, children) => this.setState(state => ({
23
+ _defineProperty(this, "update", (key, children) => this.setState(state => ({
50
24
  portals: state.portals.map(item => {
51
25
  if (item.key === key) {
52
26
  return {
@@ -1,8 +1,6 @@
1
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
2
  import * as React from "react";
3
- import { StyleSheet } from "react-native";
4
3
  import { TabView, TabBar, SceneMap } from "react-native-tab-view";
5
- import TabViewItem from "./TabViewItem";
6
4
  import { withTheme } from "../../theming";
7
5
  import { extractStyles } from "../../utilities";
8
6
  const TabViewComponent = _ref => {
@@ -31,11 +29,17 @@ const TabViewComponent = _ref => {
31
29
  viewStyles
32
30
  } = extractStyles(style);
33
31
 
32
+ //Check type of child using props
33
+ //Regular '.type' cannot work because Draftbit strips the type in Draft view
34
+ const instanceOfTabViewItemProps = object => {
35
+ return "title" in object;
36
+ };
37
+
34
38
  //Populate routes and scenes based on children
35
39
  React.useEffect(() => {
36
40
  const newRoutes = [];
37
41
  const scenes = {};
38
- React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && child.type === TabViewItem).forEach((item, idx) => {
42
+ React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && instanceOfTabViewItemProps(child.props)).forEach((item, idx) => {
39
43
  const child = item;
40
44
  newRoutes.push({
41
45
  key: idx.toString(),
@@ -73,7 +77,7 @@ const TabViewComponent = _ref => {
73
77
  return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
74
78
  name: route.icon,
75
79
  color: color,
76
- size: 36
80
+ size: 16
77
81
  }) : null;
78
82
  },
79
83
  style: {
@@ -81,8 +85,13 @@ const TabViewComponent = _ref => {
81
85
  }
82
86
  }));
83
87
  };
88
+
89
+ //Cannot render TabView without at least one tab
90
+ if (!routes.length) {
91
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
92
+ }
84
93
  return /*#__PURE__*/React.createElement(TabView, {
85
- style: [styles.tabView, viewStyles],
94
+ style: [viewStyles],
86
95
  navigationState: {
87
96
  index,
88
97
  routes
@@ -95,9 +104,4 @@ const TabViewComponent = _ref => {
95
104
  swipeEnabled: swipeEnabled
96
105
  });
97
106
  };
98
- const styles = StyleSheet.create({
99
- tabView: {
100
- flex: 1
101
- }
102
- });
103
107
  export default withTheme(TabViewComponent);
@@ -6,4 +6,5 @@ const DEFAULT_STATUSBAR_HEIGHT_EXPO = expo !== null && expo !== void 0 && expo.C
6
6
  export const APPROX_STATUSBAR_HEIGHT = Platform.select({
7
7
  android: DEFAULT_STATUSBAR_HEIGHT_EXPO,
8
8
  ios: Platform.Version < 11 ? DEFAULT_STATUSBAR_HEIGHT_EXPO : 0
9
+ });O : 0
9
10
  });
@@ -5,9 +5,6 @@ export const SEED_DATA = {
5
5
  description: "Tab view container",
6
6
  category: COMPONENT_TYPES.swiper,
7
7
  stylesPanelSections: [StylesPanelSections.Size, StylesPanelSections.MarginsAndPaddings, StylesPanelSections.Position, StylesPanelSections.Effects, StylesPanelSections.LayoutSelectedItem, StylesPanelSections.Background, StylesPanelSections.Typography],
8
- layout: {
9
- flex: 1
10
- },
11
8
  triggers: [Triggers.OnIndexChanged, Triggers.OnEndReached],
12
9
  props: {
13
10
  onIndexChanged: createActionProp({
@@ -36,7 +33,7 @@ export const SEED_DATA = {
36
33
  defaultValue: true
37
34
  }),
38
35
  scrollEnabled: createStaticBoolProp({
39
- label: "Scroll Enabled",
36
+ label: "Tab Scroll Enabled",
40
37
  description: "Whether scrolling of tabs is enabled or not",
41
38
  defaultValue: false
42
39
  }),
@@ -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;;;;AAmGb,wBAA2C"}
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,EAAE,MAAM,cAAc,CAAC;AAWpD,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;;;;AA6Gb,wBAA2C"}
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { StyleProp, ViewStyle } from "react-native";
3
- interface TabViewItemProps {
3
+ export interface TabViewItemProps {
4
4
  title: string;
5
5
  icon?: string;
6
6
  accessibilityLabel?: string;
@@ -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,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"}
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,MAAM,WAAW,gBAAgB;IAC/B,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"}
@@ -4,9 +4,6 @@ export declare const SEED_DATA: {
4
4
  description: string;
5
5
  category: string;
6
6
  stylesPanelSections: string[];
7
- layout: {
8
- flex: number;
9
- };
10
7
  triggers: string[];
11
8
  props: {
12
9
  onIndexChanged: {
@@ -1 +1 @@
1
- {"version":3,"file":"TabView.d.ts","sourceRoot":"","sources":["../../../../src/mappings/TabView.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0ErB,CAAC"}
1
+ {"version":3,"file":"TabView.d.ts","sourceRoot":"","sources":["../../../../src/mappings/TabView.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyErB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftbit/core",
3
- "version": "46.8.2-bdb2fb.2+bdb2fbd",
3
+ "version": "46.8.2-cd657e.2+cd657e6",
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-bdb2fb.2+bdb2fbd",
44
+ "@draftbit/types": "^46.8.2-cd657e.2+cd657e6",
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": "bdb2fbd9d472a8abb0d9553ca73679456ab4aa40"
97
+ "gitHead": "cd657e600fbd295c13085b08e44baec83d54afa1"
98
98
  }
@@ -1,7 +1,5 @@
1
1
  import * as React from "react";
2
- import { StyleSheet } from "react-native";
3
2
  import { TabView, TabBar, SceneMap, } from "react-native-tab-view";
4
- import TabViewItem from "./TabViewItem";
5
3
  import { withTheme } from "../../theming";
6
4
  import { extractStyles } from "../../utilities";
7
5
  const TabViewComponent = ({ Icon, onIndexChanged, onEndReached, tabBarPosition, keyboardDismissMode, swipeEnabled, scrollEnabled, activeColor, inactiveColor, pressColor, indicatorColor, tabsBackgroundColor, style, theme, children, }) => {
@@ -9,12 +7,17 @@ const TabViewComponent = ({ Icon, onIndexChanged, onEndReached, tabBarPosition,
9
7
  const [routes, setRoutes] = React.useState([]);
10
8
  const [tabScenes, setTabScenes] = React.useState({});
11
9
  const { textStyles, viewStyles } = extractStyles(style);
10
+ //Check type of child using props
11
+ //Regular '.type' cannot work because Draftbit strips the type in Draft view
12
+ const instanceOfTabViewItemProps = (object) => {
13
+ return "title" in object;
14
+ };
12
15
  //Populate routes and scenes based on children
13
16
  React.useEffect(() => {
14
17
  const newRoutes = [];
15
18
  const scenes = {};
16
19
  React.Children.toArray(children)
17
- .filter((child) => React.isValidElement(child) && child.type === TabViewItem)
20
+ .filter((child) => React.isValidElement(child) && instanceOfTabViewItemProps(child.props))
18
21
  .forEach((item, idx) => {
19
22
  const child = item;
20
23
  newRoutes.push({
@@ -38,13 +41,14 @@ const TabViewComponent = ({ Icon, onIndexChanged, onEndReached, tabBarPosition,
38
41
  const renderTabBar = (props) => {
39
42
  return (React.createElement(TabBar, { ...props, activeColor: activeColor || theme.colors.primary, inactiveColor: inactiveColor || theme.colors.divider, pressColor: pressColor || theme.colors.primary, scrollEnabled: scrollEnabled, indicatorStyle: {
40
43
  backgroundColor: indicatorColor || theme.colors.primary,
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: {
44
+ }, labelStyle: textStyles, renderIcon: ({ route, color }) => (route === null || route === void 0 ? void 0 : route.icon) ? (React.createElement(Icon, { name: route.icon, color: color, size: 16 })) : null, style: {
42
45
  backgroundColor: tabsBackgroundColor || theme.colors.background,
43
46
  } }));
44
47
  };
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 }));
48
+ //Cannot render TabView without at least one tab
49
+ if (!routes.length) {
50
+ return React.createElement(React.Fragment, null);
51
+ }
52
+ return (React.createElement(TabView, { style: [viewStyles], navigationState: { index, routes }, renderScene: SceneMap(tabScenes), renderTabBar: renderTabBar, onIndexChange: indexChangeHandler, tabBarPosition: tabBarPosition, keyboardDismissMode: keyboardDismissMode, swipeEnabled: swipeEnabled }));
46
53
  };
47
- const styles = StyleSheet.create({
48
- tabView: { flex: 1 },
49
- });
50
54
  export default withTheme(TabViewComponent);
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { StyleProp, ViewStyle, StyleSheet } from "react-native";
2
+ import { StyleProp, ViewStyle } from "react-native";
3
3
  import {
4
4
  TabView,
5
5
  TabBar,
@@ -9,7 +9,7 @@ import {
9
9
  Route,
10
10
  } from "react-native-tab-view";
11
11
 
12
- import TabViewItem from "./TabViewItem";
12
+ import { TabViewItemProps } 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,6 +60,14 @@ 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
+
63
71
  //Populate routes and scenes based on children
64
72
  React.useEffect(() => {
65
73
  const newRoutes: Route[] = [];
@@ -67,7 +75,8 @@ const TabViewComponent: React.FC<React.PropsWithChildren<TabViewProps>> = ({
67
75
 
68
76
  React.Children.toArray(children)
69
77
  .filter(
70
- (child) => React.isValidElement(child) && child.type === TabViewItem
78
+ (child) =>
79
+ React.isValidElement(child) && instanceOfTabViewItemProps(child.props)
71
80
  )
72
81
  .forEach((item: any, idx) => {
73
82
  const child = item as React.ReactElement;
@@ -106,7 +115,7 @@ const TabViewComponent: React.FC<React.PropsWithChildren<TabViewProps>> = ({
106
115
  labelStyle={textStyles}
107
116
  renderIcon={({ route, color }) =>
108
117
  route?.icon ? (
109
- <Icon name={route.icon} color={color} size={36} />
118
+ <Icon name={route.icon} color={color} size={16} />
110
119
  ) : null
111
120
  }
112
121
  style={{
@@ -116,9 +125,14 @@ const TabViewComponent: React.FC<React.PropsWithChildren<TabViewProps>> = ({
116
125
  );
117
126
  };
118
127
 
128
+ //Cannot render TabView without at least one tab
129
+ if (!routes.length) {
130
+ return <></>;
131
+ }
132
+
119
133
  return (
120
134
  <TabView
121
- style={[styles.tabView, viewStyles]}
135
+ style={[viewStyles]}
122
136
  navigationState={{ index, routes }}
123
137
  renderScene={SceneMap(tabScenes)}
124
138
  renderTabBar={renderTabBar}
@@ -130,8 +144,4 @@ const TabViewComponent: React.FC<React.PropsWithChildren<TabViewProps>> = ({
130
144
  );
131
145
  };
132
146
 
133
- const styles = StyleSheet.create({
134
- tabView: { flex: 1 },
135
- });
136
-
137
147
  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
- interface TabViewItemProps {
5
+ export interface TabViewItemProps {
6
6
  title: string;
7
7
  icon?: string;
8
8
  accessibilityLabel?: string;
@@ -13,7 +13,6 @@ export const SEED_DATA = {
13
13
  StylesPanelSections.Background,
14
14
  StylesPanelSections.Typography,
15
15
  ],
16
- layout: { flex: 1 },
17
16
  triggers: [Triggers.OnIndexChanged, Triggers.OnEndReached],
18
17
  props: {
19
18
  onIndexChanged: createActionProp({
@@ -42,7 +41,7 @@ export const SEED_DATA = {
42
41
  defaultValue: true,
43
42
  }),
44
43
  scrollEnabled: createStaticBoolProp({
45
- label: "Scroll Enabled",
44
+ label: "Tab Scroll Enabled",
46
45
  description: "Whether scrolling of tabs is enabled or not",
47
46
  defaultValue: false,
48
47
  }),
@@ -23,7 +23,6 @@ export const SEED_DATA = {
23
23
  StylesPanelSections.Background,
24
24
  StylesPanelSections.Typography,
25
25
  ],
26
- layout: { flex: 1 },
27
26
  triggers: [Triggers.OnIndexChanged, Triggers.OnEndReached],
28
27
  props: {
29
28
  onIndexChanged: createActionProp({
@@ -52,7 +51,7 @@ export const SEED_DATA = {
52
51
  defaultValue: true,
53
52
  }),
54
53
  scrollEnabled: createStaticBoolProp({
55
- label: "Scroll Enabled",
54
+ label: "Tab Scroll Enabled",
56
55
  description: "Whether scrolling of tabs is enabled or not",
57
56
  defaultValue: false,
58
57
  }),