@draftbit/core 46.2.4-00bad7.0 → 46.2.4-463c2c.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/lib/commonjs/components/Carousel.js +10 -34
  2. package/lib/commonjs/components/DeprecatedButton.js +22 -4
  3. package/lib/commonjs/components/Youtube.js +73 -0
  4. package/lib/commonjs/index.js +8 -14
  5. package/lib/module/components/Banner.js +4 -24
  6. package/lib/module/components/CardContainer.js +5 -15
  7. package/lib/module/components/Divider.js +2 -20
  8. package/lib/module/components/FAB.js +5 -23
  9. package/lib/module/components/Portal/PortalHost.js +15 -26
  10. package/lib/module/components/RadioButton/RadioButton.js +2 -15
  11. package/lib/module/components/RadioButton/RadioButtonGroup.js +3 -17
  12. package/lib/module/components/ScreenContainer.js +5 -22
  13. package/lib/module/components/ToggleButton.js +3 -17
  14. package/lib/module/components/Youtube.js +59 -0
  15. package/lib/module/constants.js +0 -1
  16. package/lib/module/index.js +2 -2
  17. package/lib/typescript/src/components/Youtube.d.ts +44 -0
  18. package/lib/typescript/src/index.d.ts +1 -1
  19. package/package.json +5 -5
  20. package/src/components/Youtube.js +38 -0
  21. package/src/components/Youtube.tsx +66 -0
  22. package/src/index.js +1 -1
  23. package/src/index.tsx +1 -1
  24. package/lib/commonjs/components/TabView/TabView.js +0 -102
  25. package/lib/commonjs/components/TabView/TabViewItem.js +0 -26
  26. package/lib/commonjs/components/TabView/index.js +0 -23
  27. package/lib/commonjs/mappings/TabView.js +0 -79
  28. package/lib/module/components/TabView/TabView.js +0 -87
  29. package/lib/module/components/TabView/TabViewItem.js +0 -18
  30. package/lib/module/components/TabView/index.js +0 -2
  31. package/lib/module/mappings/TabView.js +0 -70
  32. package/lib/typescript/src/components/TabView/TabView.d.ts +0 -19
  33. package/lib/typescript/src/components/TabView/TabViewItem.d.ts +0 -10
  34. package/lib/typescript/src/components/TabView/index.d.ts +0 -2
  35. package/lib/typescript/src/mappings/TabView.d.ts +0 -111
  36. package/src/components/TabView/TabView.js +0 -34
  37. package/src/components/TabView/TabView.tsx +0 -97
  38. package/src/components/TabView/TabViewItem.js +0 -5
  39. package/src/components/TabView/TabViewItem.tsx +0 -21
  40. package/src/components/TabView/index.js +0 -2
  41. package/src/components/TabView/index.ts +0 -2
  42. package/src/mappings/TabView.js +0 -73
  43. package/src/mappings/TabView.ts +0 -80
@@ -0,0 +1,59 @@
1
+ import { COMPONENT_TYPES, createBoolProp, createTextProp } from "@draftbit/types";
2
+ import React from "react";
3
+ import YoutubePlayer from "react-native-youtube-iframe";
4
+ import { extractStyles } from "../utilities";
5
+
6
+ const Youtube = _ref => {
7
+ let {
8
+ videoId,
9
+ playlist,
10
+ style,
11
+ mute,
12
+ autoplay
13
+ } = _ref;
14
+ const {
15
+ viewStyles: {
16
+ height,
17
+ width
18
+ }
19
+ } = extractStyles(style);
20
+ return /*#__PURE__*/React.createElement(YoutubePlayer, {
21
+ height: height,
22
+ width: width,
23
+ play: autoplay,
24
+ videoId: videoId,
25
+ playList: playlist,
26
+ mute: mute
27
+ });
28
+ };
29
+
30
+ export default Youtube;
31
+ export const SEED_DATA = {
32
+ name: "Youtube",
33
+ tag: "Youtube",
34
+ description: "Youtube Component",
35
+ category: COMPONENT_TYPES.media,
36
+ layout: {
37
+ width: "100%"
38
+ },
39
+ props: {
40
+ videoId: createTextProp({
41
+ label: "VideoId",
42
+ description: "Youtube Video ID"
43
+ }),
44
+ playlist: createTextProp({
45
+ label: "PlayList",
46
+ description: "Playlist ID"
47
+ }),
48
+ mute: createBoolProp({
49
+ label: "Mute",
50
+ description: "Whether to mute video",
51
+ defaultValue: false
52
+ }),
53
+ autoplay: createBoolProp({
54
+ label: "Autoplay",
55
+ description: "Whether to Autoplay video",
56
+ defaultValue: false
57
+ })
58
+ }
59
+ };
@@ -5,5 +5,4 @@ const DEFAULT_STATUSBAR_HEIGHT_EXPO = expo !== null && expo !== void 0 && expo.C
5
5
  export const APPROX_STATUSBAR_HEIGHT = Platform.select({
6
6
  android: DEFAULT_STATUSBAR_HEIGHT_EXPO,
7
7
  ios: Platform.Version < 11 ? DEFAULT_STATUSBAR_HEIGHT_EXPO : 0
8
- });PO : 0
9
8
  });
@@ -28,7 +28,6 @@ export { default as Touchable } from "./components/Touchable";
28
28
  export { AccordionGroup, AccordionItem } from "./components/Accordion";
29
29
  export { ActionSheet, ActionSheetItem, ActionSheetCancel } from "./components/ActionSheet";
30
30
  export { Swiper, SwiperItem } from "./components/Swiper";
31
- export { TabView, TabViewItem } from "./components/TabView";
32
31
  export { Center, Circle, Square, Row, Stack, Spacer } from "./components/Layout";
33
32
  export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup } from "./components/RadioButton/index";
34
33
  /* Deprecated: Fix or Delete! */
@@ -50,4 +49,5 @@ export { default as RowHeadlineImageCaption } from "./components/RowHeadlineImag
50
49
  export { default as RowHeadlineImageIcon } from "./components/RowHeadlineImageIcon";
51
50
  export { default as Slider } from "./components/Slider";
52
51
  export { default as Stepper } from "./components/Stepper";
53
- export { useAuthState } from "./components/useAuthState"; // a comment to fix sourcemap comment issue
52
+ export { useAuthState } from "./components/useAuthState";
53
+ export { default as Youtube } from "./components/Youtube"; // a comment to fix sourcemap comment issue
@@ -0,0 +1,44 @@
1
+ /// <reference types="react" />
2
+ import { StyleProp, ViewStyle } from "react-native";
3
+ declare type Props = {
4
+ videoId: string;
5
+ playlist: string;
6
+ style: StyleProp<ViewStyle>;
7
+ mute: boolean;
8
+ autoplay: boolean;
9
+ };
10
+ declare const Youtube: ({ videoId, playlist, style, mute, autoplay }: Props) => JSX.Element;
11
+ export default Youtube;
12
+ export declare const SEED_DATA: {
13
+ name: string;
14
+ tag: string;
15
+ description: string;
16
+ category: string;
17
+ layout: {
18
+ width: string;
19
+ };
20
+ props: {
21
+ videoId: any;
22
+ playlist: any;
23
+ mute: {
24
+ label: string;
25
+ description: string;
26
+ formType: string;
27
+ propType: string;
28
+ defaultValue: boolean;
29
+ editable: boolean;
30
+ required: boolean;
31
+ group: string;
32
+ };
33
+ autoplay: {
34
+ label: string;
35
+ description: string;
36
+ formType: string;
37
+ propType: string;
38
+ defaultValue: boolean;
39
+ editable: boolean;
40
+ required: boolean;
41
+ group: string;
42
+ };
43
+ };
44
+ };
@@ -28,7 +28,6 @@ export { default as Touchable } from "./components/Touchable";
28
28
  export { AccordionGroup, AccordionItem } from "./components/Accordion";
29
29
  export { ActionSheet, ActionSheetItem, ActionSheetCancel, } from "./components/ActionSheet";
30
30
  export { Swiper, SwiperItem } from "./components/Swiper";
31
- export { TabView, TabViewItem } from "./components/TabView";
32
31
  export { Center, Circle, Square, Row, Stack, Spacer, } from "./components/Layout";
33
32
  export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup, } from "./components/RadioButton/index";
34
33
  export { default as Button } from "./components/DeprecatedButton";
@@ -49,3 +48,4 @@ export { default as RowHeadlineImageIcon } from "./components/RowHeadlineImageIc
49
48
  export { default as Slider } from "./components/Slider";
50
49
  export { default as Stepper } from "./components/Stepper";
51
50
  export { useAuthState } from "./components/useAuthState";
51
+ export { default as Youtube } from "./components/Youtube";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftbit/core",
3
- "version": "46.2.4-00bad7.0+00bad7e6",
3
+ "version": "46.2.4-463c2c.0+463c2ce7",
4
4
  "description": "Core (non-native) Components",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -53,10 +53,10 @@
53
53
  "lodash.omit": "^4.5.0",
54
54
  "lodash.tonumber": "^4.0.3",
55
55
  "react-native-modal-datetime-picker": "^13.0.0",
56
- "react-native-pager-view": "^6.0.0",
57
- "react-native-tab-view": "^3.1.1",
58
56
  "react-native-typography": "^1.4.1",
59
- "react-native-web-swiper": "^2.2.3"
57
+ "react-native-web-swiper": "^2.2.3",
58
+ "react-native-web-webview": "^1.0.2",
59
+ "react-native-youtube-iframe": "^2.2.2"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@types/color": "^3.0.1",
@@ -81,5 +81,5 @@
81
81
  ]
82
82
  ]
83
83
  },
84
- "gitHead": "00bad7e6fdce245389c03225aefe001e6b72db05"
84
+ "gitHead": "463c2ce73d4c4a323b75ac066ec2554b252f2658"
85
85
  }
@@ -0,0 +1,38 @@
1
+ import { COMPONENT_TYPES, createBoolProp, createTextProp, } from "@draftbit/types";
2
+ import React from "react";
3
+ import YoutubePlayer from "react-native-youtube-iframe";
4
+ import { extractStyles } from "../utilities";
5
+ const Youtube = ({ videoId, playlist, style, mute, autoplay }) => {
6
+ const { viewStyles: { height, width }, } = extractStyles(style);
7
+ return (React.createElement(YoutubePlayer, { height: height, width: width, play: autoplay, videoId: videoId, playList: playlist, mute: mute }));
8
+ };
9
+ export default Youtube;
10
+ export const SEED_DATA = {
11
+ name: "Youtube",
12
+ tag: "Youtube",
13
+ description: "Youtube Component",
14
+ category: COMPONENT_TYPES.media,
15
+ layout: {
16
+ width: "100%",
17
+ },
18
+ props: {
19
+ videoId: createTextProp({
20
+ label: "VideoId",
21
+ description: "Youtube Video ID",
22
+ }),
23
+ playlist: createTextProp({
24
+ label: "PlayList",
25
+ description: "Playlist ID",
26
+ }),
27
+ mute: createBoolProp({
28
+ label: "Mute",
29
+ description: "Whether to mute video",
30
+ defaultValue: false,
31
+ }),
32
+ autoplay: createBoolProp({
33
+ label: "Autoplay",
34
+ description: "Whether to Autoplay video",
35
+ defaultValue: false,
36
+ }),
37
+ },
38
+ };
@@ -0,0 +1,66 @@
1
+ import {
2
+ COMPONENT_TYPES,
3
+ createBoolProp,
4
+ createTextProp,
5
+ } from "@draftbit/types";
6
+ import React from "react";
7
+ import { StyleProp, ViewStyle } from "react-native";
8
+ import YoutubePlayer from "react-native-youtube-iframe";
9
+ import { extractStyles } from "../utilities";
10
+
11
+ type Props = {
12
+ videoId: string;
13
+ playlist: string;
14
+ style: StyleProp<ViewStyle>;
15
+ mute: boolean;
16
+ autoplay: boolean;
17
+ };
18
+
19
+ const Youtube = ({ videoId, playlist, style, mute, autoplay }: Props) => {
20
+ const {
21
+ viewStyles: { height, width },
22
+ } = extractStyles(style);
23
+
24
+ return (
25
+ <YoutubePlayer
26
+ height={height}
27
+ width={width}
28
+ play={autoplay}
29
+ videoId={videoId}
30
+ playList={playlist}
31
+ mute={mute}
32
+ />
33
+ );
34
+ };
35
+
36
+ export default Youtube;
37
+
38
+ export const SEED_DATA = {
39
+ name: "Youtube",
40
+ tag: "Youtube",
41
+ description: "Youtube Component",
42
+ category: COMPONENT_TYPES.media,
43
+ layout: {
44
+ width: "100%",
45
+ },
46
+ props: {
47
+ videoId: createTextProp({
48
+ label: "VideoId",
49
+ description: "Youtube Video ID",
50
+ }),
51
+ playlist: createTextProp({
52
+ label: "PlayList",
53
+ description: "Playlist ID",
54
+ }),
55
+ mute: createBoolProp({
56
+ label: "Mute",
57
+ description: "Whether to mute video",
58
+ defaultValue: false,
59
+ }),
60
+ autoplay: createBoolProp({
61
+ label: "Autoplay",
62
+ description: "Whether to Autoplay video",
63
+ defaultValue: false,
64
+ }),
65
+ },
66
+ };
package/src/index.js CHANGED
@@ -28,7 +28,6 @@ export { default as Touchable } from "./components/Touchable";
28
28
  export { AccordionGroup, AccordionItem } from "./components/Accordion";
29
29
  export { ActionSheet, ActionSheetItem, ActionSheetCancel, } from "./components/ActionSheet";
30
30
  export { Swiper, SwiperItem } from "./components/Swiper";
31
- export { TabView, TabViewItem } from "./components/TabView";
32
31
  export { Center, Circle, Square, Row, Stack, Spacer, } from "./components/Layout";
33
32
  export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup, } from "./components/RadioButton/index";
34
33
  /* Deprecated: Fix or Delete! */
@@ -50,4 +49,5 @@ export { default as RowHeadlineImageIcon } from "./components/RowHeadlineImageIc
50
49
  export { default as Slider } from "./components/Slider";
51
50
  export { default as Stepper } from "./components/Stepper";
52
51
  export { useAuthState } from "./components/useAuthState";
52
+ export { default as Youtube } from "./components/Youtube";
53
53
  // a comment to fix sourcemap comment issue
package/src/index.tsx CHANGED
@@ -33,7 +33,6 @@ export {
33
33
  ActionSheetCancel,
34
34
  } from "./components/ActionSheet";
35
35
  export { Swiper, SwiperItem } from "./components/Swiper";
36
- export { TabView, TabViewItem } from "./components/TabView";
37
36
 
38
37
  export {
39
38
  Center,
@@ -70,5 +69,6 @@ export { default as RowHeadlineImageIcon } from "./components/RowHeadlineImageIc
70
69
  export { default as Slider } from "./components/Slider";
71
70
  export { default as Stepper } from "./components/Stepper";
72
71
  export { useAuthState } from "./components/useAuthState";
72
+ export { default as Youtube } from "./components/Youtube";
73
73
 
74
74
  // a comment to fix sourcemap comment issue
@@ -1,102 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var React = _interopRequireWildcard(require("react"));
9
-
10
- var _reactNativeTabView = require("react-native-tab-view");
11
-
12
- var _TabViewItem = _interopRequireDefault(require("./TabViewItem"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- 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); }
17
-
18
- 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; }
19
-
20
- 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); }
21
-
22
- const TabViewComponent = _ref => {
23
- let {
24
- Icon,
25
- tabBarPosition,
26
- keyboardDismissMode,
27
- swipeEnabled,
28
- scrollEnabled,
29
- activeColor,
30
- inactiveColor,
31
- pressColor,
32
- indicatorColor,
33
- style,
34
- children
35
- } = _ref;
36
- const [index, setIndex] = React.useState(0);
37
- const [routes, setRoutes] = React.useState([]);
38
- const [tabScenes, setTabScenes] = React.useState({});
39
- React.useEffect(() => {
40
- const newRoutes = [];
41
- const scenes = {};
42
- React.Children.toArray(children).filter(child => child.type === _TabViewItem.default).forEach(child => {
43
- var _child$props;
44
-
45
- if (child !== null && child !== void 0 && (_child$props = child.props) !== null && _child$props !== void 0 && _child$props.id) {
46
- var _child$props2, _child$props3;
47
-
48
- newRoutes.push({
49
- key: child === null || child === void 0 ? void 0 : (_child$props2 = child.props) === null || _child$props2 === void 0 ? void 0 : _child$props2.id,
50
- ...(child === null || child === void 0 ? void 0 : child.props)
51
- });
52
-
53
- scenes[child === null || child === void 0 ? void 0 : (_child$props3 = child.props) === null || _child$props3 === void 0 ? void 0 : _child$props3.id] = () => child;
54
- }
55
- });
56
- setRoutes(newRoutes);
57
- setTabScenes(scenes);
58
- }, [children]);
59
-
60
- const indexChangeHandler = i => setIndex(i);
61
-
62
- const renderTabBar = props => {
63
- console.log(props);
64
- return /*#__PURE__*/React.createElement(_reactNativeTabView.TabBar, _extends({}, props, {
65
- activeColor: activeColor,
66
- inactiveColor: inactiveColor,
67
- pressColor: pressColor,
68
- scrollEnabled: scrollEnabled,
69
- indicatorStyle: {
70
- backgroundColor: indicatorColor
71
- },
72
- renderIcon: _ref2 => {
73
- let {
74
- route,
75
- color
76
- } = _ref2;
77
- return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
78
- name: route.icon,
79
- color: color,
80
- size: 36
81
- }) : null;
82
- },
83
- style: style
84
- }));
85
- };
86
-
87
- return /*#__PURE__*/React.createElement(_reactNativeTabView.TabView, {
88
- navigationState: {
89
- index,
90
- routes
91
- },
92
- renderScene: (0, _reactNativeTabView.SceneMap)(tabScenes),
93
- renderTabBar: renderTabBar,
94
- onIndexChange: indexChangeHandler,
95
- tabBarPosition: tabBarPosition,
96
- keyboardDismissMode: keyboardDismissMode,
97
- swipeEnabled: swipeEnabled
98
- });
99
- };
100
-
101
- var _default = TabViewComponent;
102
- exports.default = _default;
@@ -1,26 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- const TabViewItem = _ref => {
9
- let {
10
- title,
11
- id,
12
- icon,
13
- children,
14
- accessibilityLabel
15
- } = _ref;
16
- console.log({
17
- title,
18
- id,
19
- icon,
20
- accessibilityLabel
21
- });
22
- return children;
23
- };
24
-
25
- var _default = TabViewItem;
26
- exports.default = _default;
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "TabView", {
7
- enumerable: true,
8
- get: function () {
9
- return _TabView.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "TabViewItem", {
13
- enumerable: true,
14
- get: function () {
15
- return _TabViewItem.default;
16
- }
17
- });
18
-
19
- var _TabView = _interopRequireDefault(require("./TabView"));
20
-
21
- var _TabViewItem = _interopRequireDefault(require("./TabViewItem"));
22
-
23
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,79 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SEED_DATA = void 0;
7
-
8
- var _types = require("@draftbit/types");
9
-
10
- const SEED_DATA = [{
11
- name: "TabView",
12
- tag: "TabView",
13
- category: _types.COMPONENT_TYPES.container,
14
- layout: {},
15
- props: {
16
- tabBarPosition: (0, _types.createTextEnumProp)({
17
- label: "Tab Bar Position",
18
- description: "Tab Bar Position",
19
- options: ["top", "bottom"],
20
- defaultValue: "top"
21
- }),
22
- keyboardDismissMode: (0, _types.createTextEnumProp)({
23
- label: "Keyboard Dismiss Mode",
24
- description: "Keyboard Dismiss Mode",
25
- options: ["auto", "on-drag", "none"],
26
- defaultValue: "auto"
27
- }),
28
- swipeEnabled: (0, _types.createBoolProp)({
29
- label: "Swipe Enabled",
30
- description: "Swipe Enabled",
31
- defaultValue: true
32
- }),
33
- scrollEnabled: (0, _types.createBoolProp)({
34
- label: "Scroll Enabled",
35
- description: "Scroll Enabled",
36
- defaultValue: true
37
- }),
38
- activeColor: (0, _types.createColorProp)({
39
- label: "Active Color",
40
- description: "Active Color",
41
- defaultValue: "primary"
42
- }),
43
- inactiveColor: (0, _types.createColorProp)({
44
- label: "Inactive Color",
45
- description: "Inactive Color",
46
- defaultValue: null
47
- }),
48
- pressColor: (0, _types.createColorProp)({
49
- label: "Press Color",
50
- description: "Press Color",
51
- defaultValue: null
52
- }),
53
- indicatorColor: (0, _types.createColorProp)({
54
- label: "Indicator Color",
55
- description: "Indicator Color",
56
- defaultValue: null
57
- })
58
- }
59
- }, {
60
- name: "TabViewItem",
61
- tag: "TabViewItem",
62
- category: _types.COMPONENT_TYPES.container,
63
- layout: {},
64
- props: {
65
- title: (0, _types.createTextProp)({
66
- label: "Title",
67
- description: "Tab Title"
68
- }),
69
- id: (0, _types.createTextProp)({
70
- label: "Id",
71
- description: "Tab Id"
72
- }),
73
- accessibilityLabel: (0, _types.createTextProp)({
74
- label: "Accessibility Label",
75
- description: "Accessibility Label"
76
- })
77
- }
78
- }];
79
- exports.SEED_DATA = SEED_DATA;
@@ -1,87 +0,0 @@
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
-
3
- import * as React from "react";
4
- import { TabView, TabBar, SceneMap } from "react-native-tab-view"; // import { withTheme } from "../../theming";
5
-
6
- import TabViewItem from "./TabViewItem";
7
-
8
- const TabViewComponent = _ref => {
9
- let {
10
- Icon,
11
- tabBarPosition,
12
- keyboardDismissMode,
13
- swipeEnabled,
14
- scrollEnabled,
15
- activeColor,
16
- inactiveColor,
17
- pressColor,
18
- indicatorColor,
19
- style,
20
- children
21
- } = _ref;
22
- const [index, setIndex] = React.useState(0);
23
- const [routes, setRoutes] = React.useState([]);
24
- const [tabScenes, setTabScenes] = React.useState({});
25
- React.useEffect(() => {
26
- const newRoutes = [];
27
- const scenes = {};
28
- React.Children.toArray(children).filter(child => child.type === TabViewItem).forEach(child => {
29
- var _child$props;
30
-
31
- if (child !== null && child !== void 0 && (_child$props = child.props) !== null && _child$props !== void 0 && _child$props.id) {
32
- var _child$props2, _child$props3;
33
-
34
- newRoutes.push({
35
- key: child === null || child === void 0 ? void 0 : (_child$props2 = child.props) === null || _child$props2 === void 0 ? void 0 : _child$props2.id,
36
- ...(child === null || child === void 0 ? void 0 : child.props)
37
- });
38
-
39
- scenes[child === null || child === void 0 ? void 0 : (_child$props3 = child.props) === null || _child$props3 === void 0 ? void 0 : _child$props3.id] = () => child;
40
- }
41
- });
42
- setRoutes(newRoutes);
43
- setTabScenes(scenes);
44
- }, [children]);
45
-
46
- const indexChangeHandler = i => setIndex(i);
47
-
48
- const renderTabBar = props => {
49
- console.log(props);
50
- return /*#__PURE__*/React.createElement(TabBar, _extends({}, props, {
51
- activeColor: activeColor,
52
- inactiveColor: inactiveColor,
53
- pressColor: pressColor,
54
- scrollEnabled: scrollEnabled,
55
- indicatorStyle: {
56
- backgroundColor: indicatorColor
57
- },
58
- renderIcon: _ref2 => {
59
- let {
60
- route,
61
- color
62
- } = _ref2;
63
- return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
64
- name: route.icon,
65
- color: color,
66
- size: 36
67
- }) : null;
68
- },
69
- style: style
70
- }));
71
- };
72
-
73
- return /*#__PURE__*/React.createElement(TabView, {
74
- navigationState: {
75
- index,
76
- routes
77
- },
78
- renderScene: SceneMap(tabScenes),
79
- renderTabBar: renderTabBar,
80
- onIndexChange: indexChangeHandler,
81
- tabBarPosition: tabBarPosition,
82
- keyboardDismissMode: keyboardDismissMode,
83
- swipeEnabled: swipeEnabled
84
- });
85
- };
86
-
87
- export default TabViewComponent;
@@ -1,18 +0,0 @@
1
- const TabViewItem = _ref => {
2
- let {
3
- title,
4
- id,
5
- icon,
6
- children,
7
- accessibilityLabel
8
- } = _ref;
9
- console.log({
10
- title,
11
- id,
12
- icon,
13
- accessibilityLabel
14
- });
15
- return children;
16
- };
17
-
18
- export default TabViewItem;
@@ -1,2 +0,0 @@
1
- export { default as TabView } from "./TabView";
2
- export { default as TabViewItem } from "./TabViewItem";