@draftbit/core 46.8.2-e916bf.2 → 46.8.2-fad2ca.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,10 +5,10 @@ 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");
9
+ var _TabViewItem = _interopRequireDefault(require("./TabViewItem"));
10
10
  var _theming = require("../../theming");
11
- var _utilities = require("../../utilities");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
12
  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
13
  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
14
  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); }
@@ -33,22 +33,12 @@ const TabViewComponent = _ref => {
33
33
  const [index, setIndex] = React.useState(0);
34
34
  const [routes, setRoutes] = React.useState([]);
35
35
  const [tabScenes, setTabScenes] = React.useState({});
36
- const {
37
- textStyles,
38
- viewStyles
39
- } = (0, _utilities.extractStyles)(style);
40
-
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
36
 
47
37
  //Populate routes and scenes based on children
48
38
  React.useEffect(() => {
49
39
  const newRoutes = [];
50
40
  const scenes = {};
51
- React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && instanceOfTabViewItemProps(child.props)).forEach((item, idx) => {
41
+ React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && child.type === _TabViewItem.default).forEach((item, idx) => {
52
42
  const child = item;
53
43
  newRoutes.push({
54
44
  key: idx.toString(),
@@ -77,7 +67,6 @@ const TabViewComponent = _ref => {
77
67
  indicatorStyle: {
78
68
  backgroundColor: indicatorColor || theme.colors.primary
79
69
  },
80
- labelStyle: textStyles,
81
70
  renderIcon: _ref2 => {
82
71
  let {
83
72
  route,
@@ -86,21 +75,15 @@ const TabViewComponent = _ref => {
86
75
  return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
87
76
  name: route.icon,
88
77
  color: color,
89
- size: 16
78
+ size: 36
90
79
  }) : null;
91
80
  },
92
- style: {
81
+ style: [{
93
82
  backgroundColor: tabsBackgroundColor || theme.colors.background
94
- }
83
+ }, style]
95
84
  }));
96
85
  };
97
-
98
- //Cannot render TabView without at least one tab
99
- if (!routes.length) {
100
- return /*#__PURE__*/React.createElement(React.Fragment, null);
101
- }
102
86
  return /*#__PURE__*/React.createElement(_reactNativeTabView.TabView, {
103
- style: [styles.tabView, viewStyles],
104
87
  navigationState: {
105
88
  index,
106
89
  routes
@@ -113,10 +96,5 @@ const TabViewComponent = _ref => {
113
96
  swipeEnabled: swipeEnabled
114
97
  });
115
98
  };
116
- const styles = _reactNative.StyleSheet.create({
117
- tabView: {
118
- flex: 1
119
- }
120
- });
121
99
  var _default = (0, _theming.withTheme)(TabViewComponent);
122
100
  exports.default = _default;
@@ -10,10 +10,7 @@ const SEED_DATA = {
10
10
  tag: "TabView",
11
11
  description: "Tab view container",
12
12
  category: _types.COMPONENT_TYPES.swiper,
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
- },
13
+ stylesPanelSections: [..._types.BLOCK_STYLES_SECTIONS, _types.StylesPanelSections.Background],
17
14
  triggers: [_types.Triggers.OnIndexChanged, _types.Triggers.OnEndReached],
18
15
  props: {
19
16
  onIndexChanged: (0, _types.createActionProp)({
@@ -42,9 +39,9 @@ const SEED_DATA = {
42
39
  defaultValue: true
43
40
  }),
44
41
  scrollEnabled: (0, _types.createStaticBoolProp)({
45
- label: "Tab Scroll Enabled",
42
+ label: "Scroll Enabled",
46
43
  description: "Whether scrolling of tabs is enabled or not",
47
- defaultValue: false
44
+ defaultValue: true
48
45
  }),
49
46
  activeColor: (0, _types.createColorProp)({
50
47
  label: "Active Color",
@@ -58,9 +55,8 @@ const SEED_DATA = {
58
55
  }),
59
56
  pressColor: (0, _types.createColorProp)({
60
57
  label: "Press Color",
61
- description: "Color of ripple when pressed",
62
- defaultValue: "primary",
63
- group: _types.GROUPS.android
58
+ description: "Color of ripple when pressed (android only)",
59
+ defaultValue: "primary"
64
60
  }),
65
61
  indicatorColor: (0, _types.createColorProp)({
66
62
  label: "Indicator Color",
@@ -18,9 +18,8 @@ const SEED_DATA = {
18
18
  title: (0, _types.createTextProp)({
19
19
  label: "Title",
20
20
  description: "Title of tab item",
21
- defaultValue: "Title",
22
- required: true,
23
- group: _types.GROUPS.basic
21
+ defaultValue: null,
22
+ required: true
24
23
  }),
25
24
  icon: (0, _types.createIconProp)({
26
25
  defaultValue: null,
@@ -1,9 +1,8 @@
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";
4
+ import TabViewItem from "./TabViewItem";
5
5
  import { withTheme } from "../../theming";
6
- import { extractStyles } from "../../utilities";
7
6
  const TabViewComponent = _ref => {
8
7
  let {
9
8
  Icon,
@@ -25,22 +24,12 @@ const TabViewComponent = _ref => {
25
24
  const [index, setIndex] = React.useState(0);
26
25
  const [routes, setRoutes] = React.useState([]);
27
26
  const [tabScenes, setTabScenes] = React.useState({});
28
- const {
29
- textStyles,
30
- viewStyles
31
- } = extractStyles(style);
32
-
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
27
 
39
28
  //Populate routes and scenes based on children
40
29
  React.useEffect(() => {
41
30
  const newRoutes = [];
42
31
  const scenes = {};
43
- React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && instanceOfTabViewItemProps(child.props)).forEach((item, idx) => {
32
+ React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && child.type === TabViewItem).forEach((item, idx) => {
44
33
  const child = item;
45
34
  newRoutes.push({
46
35
  key: idx.toString(),
@@ -69,7 +58,6 @@ const TabViewComponent = _ref => {
69
58
  indicatorStyle: {
70
59
  backgroundColor: indicatorColor || theme.colors.primary
71
60
  },
72
- labelStyle: textStyles,
73
61
  renderIcon: _ref2 => {
74
62
  let {
75
63
  route,
@@ -78,21 +66,15 @@ const TabViewComponent = _ref => {
78
66
  return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
79
67
  name: route.icon,
80
68
  color: color,
81
- size: 16
69
+ size: 36
82
70
  }) : null;
83
71
  },
84
- style: {
72
+ style: [{
85
73
  backgroundColor: tabsBackgroundColor || theme.colors.background
86
- }
74
+ }, style]
87
75
  }));
88
76
  };
89
-
90
- //Cannot render TabView without at least one tab
91
- if (!routes.length) {
92
- return /*#__PURE__*/React.createElement(React.Fragment, null);
93
- }
94
77
  return /*#__PURE__*/React.createElement(TabView, {
95
- style: [styles.tabView, viewStyles],
96
78
  navigationState: {
97
79
  index,
98
80
  routes
@@ -105,9 +87,4 @@ const TabViewComponent = _ref => {
105
87
  swipeEnabled: swipeEnabled
106
88
  });
107
89
  };
108
- const styles = StyleSheet.create({
109
- tabView: {
110
- flex: 1
111
- }
112
- });
113
90
  export default withTheme(TabViewComponent);
@@ -1,13 +1,10 @@
1
- import { COMPONENT_TYPES, createTextEnumProp, createColorProp, StylesPanelSections, Triggers, createActionProp, createStaticBoolProp, GROUPS } from "@draftbit/types";
1
+ import { COMPONENT_TYPES, createTextEnumProp, createColorProp, BLOCK_STYLES_SECTIONS, StylesPanelSections, Triggers, createActionProp, createStaticBoolProp } from "@draftbit/types";
2
2
  export const SEED_DATA = {
3
3
  name: "Tab View",
4
4
  tag: "TabView",
5
5
  description: "Tab view container",
6
6
  category: COMPONENT_TYPES.swiper,
7
- stylesPanelSections: [StylesPanelSections.Size, StylesPanelSections.MarginsAndPaddings, StylesPanelSections.Position, StylesPanelSections.Effects, StylesPanelSections.LayoutSelectedItem, StylesPanelSections.Background, StylesPanelSections.Typography],
8
- layout: {
9
- flex: 1
10
- },
7
+ stylesPanelSections: [...BLOCK_STYLES_SECTIONS, StylesPanelSections.Background],
11
8
  triggers: [Triggers.OnIndexChanged, Triggers.OnEndReached],
12
9
  props: {
13
10
  onIndexChanged: createActionProp({
@@ -36,9 +33,9 @@ export const SEED_DATA = {
36
33
  defaultValue: true
37
34
  }),
38
35
  scrollEnabled: createStaticBoolProp({
39
- label: "Tab Scroll Enabled",
36
+ label: "Scroll Enabled",
40
37
  description: "Whether scrolling of tabs is enabled or not",
41
- defaultValue: false
38
+ defaultValue: true
42
39
  }),
43
40
  activeColor: createColorProp({
44
41
  label: "Active Color",
@@ -52,9 +49,8 @@ export const SEED_DATA = {
52
49
  }),
53
50
  pressColor: createColorProp({
54
51
  label: "Press Color",
55
- description: "Color of ripple when pressed",
56
- defaultValue: "primary",
57
- group: GROUPS.android
52
+ description: "Color of ripple when pressed (android only)",
53
+ defaultValue: "primary"
58
54
  }),
59
55
  indicatorColor: createColorProp({
60
56
  label: "Indicator Color",
@@ -12,9 +12,8 @@ export const SEED_DATA = {
12
12
  title: createTextProp({
13
13
  label: "Title",
14
14
  description: "Title of tab item",
15
- defaultValue: "Title",
16
- required: true,
17
- group: GROUPS.basic
15
+ defaultValue: null,
16
+ required: true
18
17
  }),
19
18
  icon: createIconProp({
20
19
  defaultValue: null,
@@ -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;;;;AAiHb,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;AAKvD,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;;;;AA4Fb,wBAA2C"}
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { StyleProp, ViewStyle } from "react-native";
3
- export interface TabViewItemProps {
3
+ 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,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"}
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"}
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmErB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"TabViewItem.d.ts","sourceRoot":"","sources":["../../../../src/mappings/TabViewItem.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;CA6BrB,CAAC"}
1
+ {"version":3,"file":"TabViewItem.d.ts","sourceRoot":"","sources":["../../../../src/mappings/TabViewItem.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;CA4BrB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftbit/core",
3
- "version": "46.8.2-e916bf.2+e916bf3",
3
+ "version": "46.8.2-fad2ca.2+fad2cab",
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-e916bf.2+e916bf3",
44
+ "@draftbit/types": "^46.8.2-fad2ca.2+fad2cab",
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": "e916bf330335c3bd9d1a4bd1046b4f7a3bcd30fa"
97
+ "gitHead": "fad2cab35a2ed9e27dc7202ffaf988d41520cfc3"
98
98
  }
@@ -1,24 +1,17 @@
1
1
  import * as React from "react";
2
- import { StyleSheet } from "react-native";
3
2
  import { TabView, TabBar, SceneMap, } from "react-native-tab-view";
3
+ import TabViewItem from "./TabViewItem";
4
4
  import { withTheme } from "../../theming";
5
- import { extractStyles } from "../../utilities";
6
5
  const TabViewComponent = ({ Icon, onIndexChanged, onEndReached, tabBarPosition, keyboardDismissMode, swipeEnabled, scrollEnabled, activeColor, inactiveColor, pressColor, indicatorColor, tabsBackgroundColor, style, theme, children, }) => {
7
6
  const [index, setIndex] = React.useState(0);
8
7
  const [routes, setRoutes] = React.useState([]);
9
8
  const [tabScenes, setTabScenes] = React.useState({});
10
- 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
9
  //Populate routes and scenes based on children
17
10
  React.useEffect(() => {
18
11
  const newRoutes = [];
19
12
  const scenes = {};
20
13
  React.Children.toArray(children)
21
- .filter((child) => React.isValidElement(child) && instanceOfTabViewItemProps(child.props))
14
+ .filter((child) => React.isValidElement(child) && child.type === TabViewItem)
22
15
  .forEach((item, idx) => {
23
16
  const child = item;
24
17
  newRoutes.push({
@@ -42,17 +35,11 @@ const TabViewComponent = ({ Icon, onIndexChanged, onEndReached, tabBarPosition,
42
35
  const renderTabBar = (props) => {
43
36
  return (React.createElement(TabBar, { ...props, activeColor: activeColor || theme.colors.primary, inactiveColor: inactiveColor || theme.colors.divider, pressColor: pressColor || theme.colors.primary, scrollEnabled: scrollEnabled, indicatorStyle: {
44
37
  backgroundColor: indicatorColor || theme.colors.primary,
45
- }, 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: {
46
- backgroundColor: tabsBackgroundColor || theme.colors.background,
47
- } }));
38
+ }, renderIcon: ({ route, color }) => (route === null || route === void 0 ? void 0 : route.icon) ? (React.createElement(Icon, { name: route.icon, color: color, size: 36 })) : null, style: [
39
+ { backgroundColor: tabsBackgroundColor || theme.colors.background },
40
+ style,
41
+ ] }));
48
42
  };
49
- //Cannot render TabView without at least one tab
50
- if (!routes.length) {
51
- return React.createElement(React.Fragment, null);
52
- }
53
- return (React.createElement(TabView, { style: [styles.tabView, viewStyles], navigationState: { index, routes }, renderScene: SceneMap(tabScenes), renderTabBar: renderTabBar, onIndexChange: indexChangeHandler, tabBarPosition: tabBarPosition, keyboardDismissMode: keyboardDismissMode, swipeEnabled: swipeEnabled }));
43
+ return (React.createElement(TabView, { navigationState: { index, routes }, renderScene: SceneMap(tabScenes), renderTabBar: renderTabBar, onIndexChange: indexChangeHandler, tabBarPosition: tabBarPosition, keyboardDismissMode: keyboardDismissMode, swipeEnabled: swipeEnabled }));
54
44
  };
55
- const styles = StyleSheet.create({
56
- tabView: { flex: 1 },
57
- });
58
45
  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,11 +9,10 @@ import {
9
9
  Route,
10
10
  } from "react-native-tab-view";
11
11
 
12
- import { TabViewItemProps } from "./TabViewItem";
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";
16
- import { extractStyles } from "../../utilities";
17
16
 
18
17
  type TabBarProps = SceneRendererProps & {
19
18
  navigationState: NavigationState<any>;
@@ -58,16 +57,6 @@ const TabViewComponent: React.FC<React.PropsWithChildren<TabViewProps>> = ({
58
57
  const [routes, setRoutes] = React.useState<Route[]>([]);
59
58
  const [tabScenes, setTabScenes] = React.useState({});
60
59
 
61
- const { textStyles, viewStyles } = extractStyles(style);
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
60
  //Populate routes and scenes based on children
72
61
  React.useEffect(() => {
73
62
  const newRoutes: Route[] = [];
@@ -75,8 +64,7 @@ const TabViewComponent: React.FC<React.PropsWithChildren<TabViewProps>> = ({
75
64
 
76
65
  React.Children.toArray(children)
77
66
  .filter(
78
- (child) =>
79
- React.isValidElement(child) && instanceOfTabViewItemProps(child.props)
67
+ (child) => React.isValidElement(child) && child.type === TabViewItem
80
68
  )
81
69
  .forEach((item: any, idx) => {
82
70
  const child = item as React.ReactElement;
@@ -112,27 +100,21 @@ const TabViewComponent: React.FC<React.PropsWithChildren<TabViewProps>> = ({
112
100
  indicatorStyle={{
113
101
  backgroundColor: indicatorColor || theme.colors.primary,
114
102
  }}
115
- labelStyle={textStyles}
116
103
  renderIcon={({ route, color }) =>
117
104
  route?.icon ? (
118
- <Icon name={route.icon} color={color} size={16} />
105
+ <Icon name={route.icon} color={color} size={36} />
119
106
  ) : null
120
107
  }
121
- style={{
122
- backgroundColor: tabsBackgroundColor || theme.colors.background,
123
- }}
108
+ style={[
109
+ { backgroundColor: tabsBackgroundColor || theme.colors.background },
110
+ style,
111
+ ]}
124
112
  />
125
113
  );
126
114
  };
127
115
 
128
- //Cannot render TabView without at least one tab
129
- if (!routes.length) {
130
- return <></>;
131
- }
132
-
133
116
  return (
134
117
  <TabView
135
- style={[styles.tabView, viewStyles]}
136
118
  navigationState={{ index, routes }}
137
119
  renderScene={SceneMap(tabScenes)}
138
120
  renderTabBar={renderTabBar}
@@ -144,8 +126,4 @@ const TabViewComponent: React.FC<React.PropsWithChildren<TabViewProps>> = ({
144
126
  );
145
127
  };
146
128
 
147
- const styles = StyleSheet.create({
148
- tabView: { flex: 1 },
149
- });
150
-
151
129
  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
- export interface TabViewItemProps {
5
+ interface TabViewItemProps {
6
6
  title: string;
7
7
  icon?: string;
8
8
  accessibilityLabel?: string;
@@ -1,19 +1,13 @@
1
- import { COMPONENT_TYPES, createTextEnumProp, createColorProp, StylesPanelSections, Triggers, createActionProp, createStaticBoolProp, GROUPS, } from "@draftbit/types";
1
+ import { COMPONENT_TYPES, createTextEnumProp, createColorProp, BLOCK_STYLES_SECTIONS, StylesPanelSections, Triggers, createActionProp, createStaticBoolProp, } from "@draftbit/types";
2
2
  export const SEED_DATA = {
3
3
  name: "Tab View",
4
4
  tag: "TabView",
5
5
  description: "Tab view container",
6
6
  category: COMPONENT_TYPES.swiper,
7
7
  stylesPanelSections: [
8
- StylesPanelSections.Size,
9
- StylesPanelSections.MarginsAndPaddings,
10
- StylesPanelSections.Position,
11
- StylesPanelSections.Effects,
12
- StylesPanelSections.LayoutSelectedItem,
8
+ ...BLOCK_STYLES_SECTIONS,
13
9
  StylesPanelSections.Background,
14
- StylesPanelSections.Typography,
15
10
  ],
16
- layout: { flex: 1 },
17
11
  triggers: [Triggers.OnIndexChanged, Triggers.OnEndReached],
18
12
  props: {
19
13
  onIndexChanged: createActionProp({
@@ -42,9 +36,9 @@ export const SEED_DATA = {
42
36
  defaultValue: true,
43
37
  }),
44
38
  scrollEnabled: createStaticBoolProp({
45
- label: "Tab Scroll Enabled",
39
+ label: "Scroll Enabled",
46
40
  description: "Whether scrolling of tabs is enabled or not",
47
- defaultValue: false,
41
+ defaultValue: true,
48
42
  }),
49
43
  activeColor: createColorProp({
50
44
  label: "Active Color",
@@ -58,9 +52,8 @@ export const SEED_DATA = {
58
52
  }),
59
53
  pressColor: createColorProp({
60
54
  label: "Press Color",
61
- description: "Color of ripple when pressed",
55
+ description: "Color of ripple when pressed (android only)",
62
56
  defaultValue: "primary",
63
- group: GROUPS.android,
64
57
  }),
65
58
  indicatorColor: createColorProp({
66
59
  label: "Indicator Color",
@@ -2,11 +2,11 @@ import {
2
2
  COMPONENT_TYPES,
3
3
  createTextEnumProp,
4
4
  createColorProp,
5
+ BLOCK_STYLES_SECTIONS,
5
6
  StylesPanelSections,
6
7
  Triggers,
7
8
  createActionProp,
8
9
  createStaticBoolProp,
9
- GROUPS,
10
10
  } from "@draftbit/types";
11
11
 
12
12
  export const SEED_DATA = {
@@ -15,15 +15,9 @@ export const SEED_DATA = {
15
15
  description: "Tab view container",
16
16
  category: COMPONENT_TYPES.swiper,
17
17
  stylesPanelSections: [
18
- StylesPanelSections.Size,
19
- StylesPanelSections.MarginsAndPaddings,
20
- StylesPanelSections.Position,
21
- StylesPanelSections.Effects,
22
- StylesPanelSections.LayoutSelectedItem,
18
+ ...BLOCK_STYLES_SECTIONS,
23
19
  StylesPanelSections.Background,
24
- StylesPanelSections.Typography,
25
20
  ],
26
- layout: { flex: 1 },
27
21
  triggers: [Triggers.OnIndexChanged, Triggers.OnEndReached],
28
22
  props: {
29
23
  onIndexChanged: createActionProp({
@@ -52,9 +46,9 @@ export const SEED_DATA = {
52
46
  defaultValue: true,
53
47
  }),
54
48
  scrollEnabled: createStaticBoolProp({
55
- label: "Tab Scroll Enabled",
49
+ label: "Scroll Enabled",
56
50
  description: "Whether scrolling of tabs is enabled or not",
57
- defaultValue: false,
51
+ defaultValue: true,
58
52
  }),
59
53
  activeColor: createColorProp({
60
54
  label: "Active Color",
@@ -68,9 +62,8 @@ export const SEED_DATA = {
68
62
  }),
69
63
  pressColor: createColorProp({
70
64
  label: "Press Color",
71
- description: "Color of ripple when pressed",
65
+ description: "Color of ripple when pressed (android only)",
72
66
  defaultValue: "primary",
73
- group: GROUPS.android,
74
67
  }),
75
68
  indicatorColor: createColorProp({
76
69
  label: "Indicator Color",
@@ -12,9 +12,8 @@ export const SEED_DATA = {
12
12
  title: createTextProp({
13
13
  label: "Title",
14
14
  description: "Title of tab item",
15
- defaultValue: "Title",
15
+ defaultValue: null,
16
16
  required: true,
17
- group: GROUPS.basic,
18
17
  }),
19
18
  icon: createIconProp({
20
19
  defaultValue: null,
@@ -20,9 +20,8 @@ export const SEED_DATA = {
20
20
  title: createTextProp({
21
21
  label: "Title",
22
22
  description: "Title of tab item",
23
- defaultValue: "Title",
23
+ defaultValue: null,
24
24
  required: true,
25
- group: GROUPS.basic,
26
25
  }),
27
26
  icon: createIconProp({
28
27
  defaultValue: null,