@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.
- package/lib/commonjs/components/Accordion/index.js.map +1 -1
- package/lib/commonjs/components/CardInline.js.map +1 -1
- package/lib/commonjs/components/DeprecatedCardWrapper.js +14 -2
- package/lib/commonjs/components/DeprecatedCardWrapper.js.map +1 -1
- package/lib/commonjs/components/DeprecatedFAB.js +4 -20
- package/lib/commonjs/components/DeprecatedFAB.js.map +1 -1
- package/lib/commonjs/components/Divider.js +3 -13
- package/lib/commonjs/components/Divider.js.map +1 -1
- package/lib/commonjs/components/NumberInput.js +2 -1
- package/lib/commonjs/components/NumberInput.js.map +1 -1
- package/lib/commonjs/components/TabView/TabView.js +101 -0
- package/lib/commonjs/components/TabView/TabView.js.map +1 -0
- package/lib/commonjs/components/TabView/TabViewItem.js +23 -0
- package/lib/commonjs/components/TabView/TabViewItem.js.map +1 -0
- package/lib/commonjs/components/TabView/index.js +24 -0
- package/lib/commonjs/components/TabView/index.js.map +1 -0
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mappings/MapCallout.js +1 -1
- package/lib/commonjs/mappings/MapCallout.js.map +1 -1
- package/lib/commonjs/mappings/MapMarker.js +1 -1
- package/lib/commonjs/mappings/MapMarker.js.map +1 -1
- package/lib/commonjs/mappings/RadioButtonRow.js.map +1 -1
- package/lib/commonjs/mappings/TabView.js +33 -0
- package/lib/commonjs/mappings/TabView.js.map +1 -0
- package/lib/module/components/NumberInput.js +1 -1
- package/lib/module/components/NumberInput.js.map +1 -1
- package/lib/module/components/Picker/PickerComponent.android.js +7 -10
- package/lib/module/components/Picker/PickerComponent.android.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButton.js +3 -14
- package/lib/module/components/RadioButton/RadioButton.js.map +1 -1
- package/lib/module/components/TabView/TabView.js +80 -0
- package/lib/module/components/TabView/TabView.js.map +1 -0
- package/lib/module/components/TabView/TabViewItem.js +15 -0
- package/lib/module/components/TabView/TabViewItem.js.map +1 -0
- package/lib/module/components/TabView/index.js +3 -0
- package/lib/module/components/TabView/index.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/mappings/MapCallout.js +1 -1
- package/lib/module/mappings/MapCallout.js.map +1 -1
- package/lib/module/mappings/MapMarker.js +1 -1
- package/lib/module/mappings/MapMarker.js.map +1 -1
- package/lib/module/mappings/TabView.js +24 -0
- package/lib/module/mappings/TabView.js.map +1 -0
- package/lib/typescript/src/components/TabView/TabView.d.ts +6 -0
- package/lib/typescript/src/components/TabView/TabViewItem.d.ts +8 -0
- package/lib/typescript/src/components/TabView/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/mappings/TabView.d.ts +19 -0
- package/package.json +4 -2
- package/src/components/NumberInput.js +1 -0
- package/src/components/NumberInput.tsx +2 -0
- package/src/components/TabView/TabView.js +54 -0
- package/src/components/TabView/TabView.tsx +90 -0
- package/src/components/TabView/TabViewItem.js +5 -0
- package/src/components/TabView/TabViewItem.tsx +13 -0
- package/src/components/TabView/index.js +2 -0
- package/src/components/TabView/index.ts +2 -0
- package/src/index.js +1 -0
- package/src/index.tsx +1 -0
- package/src/mappings/MapCallout.js +1 -1
- package/src/mappings/MapCallout.ts +1 -1
- package/src/mappings/MapMarker.js +1 -1
- package/src/mappings/MapMarker.ts +1 -1
- package/src/mappings/TabView.js +26 -0
- 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,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;
|
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
|
@@ -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.
|
|
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.
|
|
13
|
+
category: COMPONENT_TYPES.deprecated,
|
|
14
14
|
layout: {},
|
|
15
15
|
props: {
|
|
16
16
|
onPress: createActionProp({
|
|
@@ -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
|
+
];
|