@draftbit/core 43.2.1-d3fbb1.0 → 43.2.3-0f04d4.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 (67) hide show
  1. package/lib/commonjs/components/Accordion/index.js.map +1 -1
  2. package/lib/commonjs/components/CardInline.js.map +1 -1
  3. package/lib/commonjs/components/DeprecatedCardWrapper.js +14 -2
  4. package/lib/commonjs/components/DeprecatedCardWrapper.js.map +1 -1
  5. package/lib/commonjs/components/DeprecatedFAB.js +4 -20
  6. package/lib/commonjs/components/DeprecatedFAB.js.map +1 -1
  7. package/lib/commonjs/components/Divider.js +3 -13
  8. package/lib/commonjs/components/Divider.js.map +1 -1
  9. package/lib/commonjs/components/NumberInput.js +2 -1
  10. package/lib/commonjs/components/NumberInput.js.map +1 -1
  11. package/lib/commonjs/components/TabView/TabView.js +101 -0
  12. package/lib/commonjs/components/TabView/TabView.js.map +1 -0
  13. package/lib/commonjs/components/TabView/TabViewItem.js +23 -0
  14. package/lib/commonjs/components/TabView/TabViewItem.js.map +1 -0
  15. package/lib/commonjs/components/TabView/index.js +24 -0
  16. package/lib/commonjs/components/TabView/index.js.map +1 -0
  17. package/lib/commonjs/index.js +14 -0
  18. package/lib/commonjs/index.js.map +1 -1
  19. package/lib/commonjs/mappings/MapCallout.js +1 -1
  20. package/lib/commonjs/mappings/MapCallout.js.map +1 -1
  21. package/lib/commonjs/mappings/MapMarker.js +1 -1
  22. package/lib/commonjs/mappings/MapMarker.js.map +1 -1
  23. package/lib/commonjs/mappings/RadioButtonRow.js.map +1 -1
  24. package/lib/commonjs/mappings/TabView.js +33 -0
  25. package/lib/commonjs/mappings/TabView.js.map +1 -0
  26. package/lib/module/components/NumberInput.js +1 -1
  27. package/lib/module/components/NumberInput.js.map +1 -1
  28. package/lib/module/components/Picker/PickerComponent.android.js +7 -10
  29. package/lib/module/components/Picker/PickerComponent.android.js.map +1 -1
  30. package/lib/module/components/RadioButton/RadioButton.js +3 -14
  31. package/lib/module/components/RadioButton/RadioButton.js.map +1 -1
  32. package/lib/module/components/TabView/TabView.js +80 -0
  33. package/lib/module/components/TabView/TabView.js.map +1 -0
  34. package/lib/module/components/TabView/TabViewItem.js +15 -0
  35. package/lib/module/components/TabView/TabViewItem.js.map +1 -0
  36. package/lib/module/components/TabView/index.js +3 -0
  37. package/lib/module/components/TabView/index.js.map +1 -0
  38. package/lib/module/index.js +1 -0
  39. package/lib/module/index.js.map +1 -1
  40. package/lib/module/mappings/MapCallout.js +1 -1
  41. package/lib/module/mappings/MapCallout.js.map +1 -1
  42. package/lib/module/mappings/MapMarker.js +1 -1
  43. package/lib/module/mappings/MapMarker.js.map +1 -1
  44. package/lib/module/mappings/TabView.js +24 -0
  45. package/lib/module/mappings/TabView.js.map +1 -0
  46. package/lib/typescript/src/components/TabView/TabView.d.ts +6 -0
  47. package/lib/typescript/src/components/TabView/TabViewItem.d.ts +8 -0
  48. package/lib/typescript/src/components/TabView/index.d.ts +2 -0
  49. package/lib/typescript/src/index.d.ts +1 -0
  50. package/lib/typescript/src/mappings/TabView.d.ts +19 -0
  51. package/package.json +4 -2
  52. package/src/components/NumberInput.js +1 -0
  53. package/src/components/NumberInput.tsx +2 -0
  54. package/src/components/TabView/TabView.js +54 -0
  55. package/src/components/TabView/TabView.tsx +90 -0
  56. package/src/components/TabView/TabViewItem.js +5 -0
  57. package/src/components/TabView/TabViewItem.tsx +13 -0
  58. package/src/components/TabView/index.js +2 -0
  59. package/src/components/TabView/index.ts +2 -0
  60. package/src/index.js +1 -0
  61. package/src/index.tsx +1 -0
  62. package/src/mappings/MapCallout.js +1 -1
  63. package/src/mappings/MapCallout.ts +1 -1
  64. package/src/mappings/MapMarker.js +1 -1
  65. package/src/mappings/MapMarker.ts +1 -1
  66. package/src/mappings/TabView.js +26 -0
  67. package/src/mappings/TabView.ts +27 -0
@@ -0,0 +1,90 @@
1
+ import * as React from "react";
2
+ import { Animated, View, TouchableOpacity, StyleSheet } from "react-native";
3
+ import { TabView, SceneMap } from "react-native-tab-view";
4
+ import Constants from "expo-constants";
5
+
6
+ import TabViewItem from "./TabViewItem";
7
+
8
+ interface TabViewProps {
9
+ children: React.ReactNode;
10
+ }
11
+
12
+ export default ({ children }: TabViewProps) => {
13
+ const [index, setIndex] = React.useState(0);
14
+ const [routes, setRoutes] = React.useState([]);
15
+ const [tabScenes, setTabScenes] = React.useState({});
16
+
17
+ React.useEffect(() => {
18
+ const newRoutes: any = [];
19
+ const scenes: any = {};
20
+
21
+ React.Children.toArray(children)
22
+ .filter((child: any) => child.type === TabViewItem)
23
+ .forEach((child: any) => {
24
+ if (child?.props?.id) {
25
+ newRoutes.push({
26
+ key: child?.props?.id,
27
+ title: child?.props?.title,
28
+ });
29
+ scenes[child?.props?.id] = () => child;
30
+ }
31
+ });
32
+
33
+ setRoutes(newRoutes);
34
+ setTabScenes(scenes);
35
+ }, [children]);
36
+
37
+ const _handleIndexChange = (i: any) => setIndex(i);
38
+
39
+ const _renderTabBar = (props: any) => {
40
+ const inputRange = props.navigationState.routes.map(
41
+ (__: any, i: number) => i
42
+ );
43
+
44
+ return (
45
+ <View style={styles.tabBar}>
46
+ {props.navigationState.routes.map((route: any, i: number) => {
47
+ const opacity = props.position.interpolate({
48
+ inputRange,
49
+ outputRange: inputRange.map((inputIndex: any) =>
50
+ inputIndex === i ? 1 : 0.5
51
+ ),
52
+ });
53
+
54
+ return (
55
+ <TouchableOpacity
56
+ style={styles.tabItem}
57
+ onPress={() => setIndex(i)}
58
+ >
59
+ <Animated.Text style={{ opacity }}>{route.title}</Animated.Text>
60
+ </TouchableOpacity>
61
+ );
62
+ })}
63
+ </View>
64
+ );
65
+ };
66
+
67
+ return (
68
+ <TabView
69
+ navigationState={{ index, routes }}
70
+ renderScene={SceneMap(tabScenes)}
71
+ renderTabBar={_renderTabBar}
72
+ onIndexChange={_handleIndexChange}
73
+ />
74
+ );
75
+ };
76
+
77
+ const styles = StyleSheet.create({
78
+ container: {
79
+ flex: 1,
80
+ },
81
+ tabBar: {
82
+ flexDirection: "row",
83
+ paddingTop: Constants.statusBarHeight,
84
+ },
85
+ tabItem: {
86
+ flex: 1,
87
+ alignItems: "center",
88
+ padding: 16,
89
+ },
90
+ });
@@ -0,0 +1,5 @@
1
+ const TabViewItem = ({ title, id, children }) => {
2
+ console.log({ title, id });
3
+ return children;
4
+ };
5
+ export default TabViewItem;
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ interface TabViewItemProps {
3
+ title: string;
4
+ id: string;
5
+ children: React.ReactNode;
6
+ }
7
+
8
+ const TabViewItem = ({ title, id, children }: TabViewItemProps) => {
9
+ console.log({ title, id });
10
+ return children;
11
+ };
12
+
13
+ export default TabViewItem;
@@ -0,0 +1,2 @@
1
+ export { default as TabView } from "./TabView";
2
+ export { default as TabViewItem } from "./TabViewItem";
@@ -0,0 +1,2 @@
1
+ export { default as TabView } from "./TabView";
2
+ export { default as TabViewItem } from "./TabViewItem";
package/src/index.js CHANGED
@@ -27,6 +27,7 @@ export { default as Touchable } from "./components/Touchable";
27
27
  export { AccordionGroup, AccordionItem } from "./components/Accordion";
28
28
  export { ActionSheet, ActionSheetItem, ActionSheetCancel, } from "./components/ActionSheet";
29
29
  export { Swiper, SwiperItem } from "./components/Swiper";
30
+ export { TabView, TabViewItem } from "./components/TabView";
30
31
  export { Center, Circle, Square, Row, Stack, Spacer, } from "./components/Layout";
31
32
  export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup, } from "./components/RadioButton/index";
32
33
  /* Deprecated: Fix or Delete! */
package/src/index.tsx CHANGED
@@ -32,6 +32,7 @@ export {
32
32
  ActionSheetCancel,
33
33
  } from "./components/ActionSheet";
34
34
  export { Swiper, SwiperItem } from "./components/Swiper";
35
+ export { TabView, TabViewItem } from "./components/TabView";
35
36
 
36
37
  export {
37
38
  Center,
@@ -3,7 +3,7 @@ export const SEED_DATA = {
3
3
  name: "Map Callout",
4
4
  tag: "MapCallout",
5
5
  description: "An info window to display on top of a marker when it is clicked",
6
- category: COMPONENT_TYPES.container,
6
+ category: COMPONENT_TYPES.deprecated,
7
7
  layout: {},
8
8
  props: {
9
9
  onPress: createActionProp({
@@ -10,7 +10,7 @@ export const SEED_DATA = {
10
10
  tag: "MapCallout",
11
11
  description:
12
12
  "An info window to display on top of a marker when it is clicked",
13
- category: COMPONENT_TYPES.container,
13
+ category: COMPONENT_TYPES.deprecated,
14
14
  layout: {},
15
15
  props: {
16
16
  onPress: createActionProp({
@@ -3,7 +3,7 @@ export const SEED_DATA = {
3
3
  name: "Map Marker",
4
4
  tag: "MapMarker",
5
5
  description: "A marker to show inside map view",
6
- category: COMPONENT_TYPES.button,
6
+ category: COMPONENT_TYPES.deprecated,
7
7
  layout: {},
8
8
  props: {
9
9
  latitude: createNumberProp({
@@ -11,7 +11,7 @@ export const SEED_DATA = {
11
11
  name: "Map Marker",
12
12
  tag: "MapMarker",
13
13
  description: "A marker to show inside map view",
14
- category: COMPONENT_TYPES.button,
14
+ category: COMPONENT_TYPES.deprecated,
15
15
  layout: {},
16
16
  props: {
17
17
  latitude: createNumberProp({
@@ -0,0 +1,26 @@
1
+ import { COMPONENT_TYPES, createTextProp } from "@draftbit/types";
2
+ export const SEED_DATA = [
3
+ {
4
+ name: "TabView",
5
+ tag: "TabView",
6
+ category: COMPONENT_TYPES.container,
7
+ layout: {},
8
+ props: {},
9
+ },
10
+ {
11
+ name: "TabViewItem",
12
+ tag: "TabViewItem",
13
+ category: COMPONENT_TYPES.container,
14
+ layout: {},
15
+ props: {
16
+ title: createTextProp({
17
+ label: "Tab Title",
18
+ description: "Tab Title",
19
+ }),
20
+ id: createTextProp({
21
+ label: "Tab Id",
22
+ description: "Tab Id",
23
+ }),
24
+ },
25
+ },
26
+ ];
@@ -0,0 +1,27 @@
1
+ import { COMPONENT_TYPES, createTextProp } from "@draftbit/types";
2
+
3
+ export const SEED_DATA = [
4
+ {
5
+ name: "TabView",
6
+ tag: "TabView",
7
+ category: COMPONENT_TYPES.container,
8
+ layout: {},
9
+ props: {},
10
+ },
11
+ {
12
+ name: "TabViewItem",
13
+ tag: "TabViewItem",
14
+ category: COMPONENT_TYPES.container,
15
+ layout: {},
16
+ props: {
17
+ title: createTextProp({
18
+ label: "Tab Title",
19
+ description: "Tab Title",
20
+ }),
21
+ id: createTextProp({
22
+ label: "Tab Id",
23
+ description: "Tab Id",
24
+ }),
25
+ },
26
+ },
27
+ ];