@draftbit/core 46.4.4-b53636.2 → 46.4.4-d93fe1.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.
- package/lib/commonjs/components/Accordion/AccordionItem.js +5 -25
- package/lib/commonjs/components/AnimatedCircularProgress.js +2 -12
- package/lib/commonjs/components/CircleImage.js +2 -16
- package/lib/commonjs/components/Container.js +17 -5
- package/lib/commonjs/components/ProgressBar.js +23 -7
- package/lib/commonjs/components/TabView/TabView.js +102 -0
- package/lib/commonjs/components/TabView/TabViewItem.js +26 -0
- package/lib/commonjs/components/TabView/index.js +23 -0
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/mappings/AudioPlayer.js +2 -32
- package/lib/commonjs/mappings/TabView.js +79 -0
- package/lib/module/components/Accordion/AccordionItem.js +5 -26
- package/lib/module/components/TabView/TabView.js +87 -0
- package/lib/module/components/TabView/TabViewItem.js +18 -0
- package/lib/module/components/TabView/index.js +2 -0
- package/lib/module/components/ToggleButton.js +17 -3
- package/lib/module/index.js +1 -0
- package/lib/module/mappings/AudioPlayer.js +3 -33
- package/lib/module/mappings/TabView.js +70 -0
- package/lib/typescript/src/components/TabView/TabView.d.ts +19 -0
- package/lib/typescript/src/components/TabView/TabViewItem.d.ts +10 -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/AudioPlayer.d.ts +1 -62
- package/lib/typescript/src/mappings/TabView.d.ts +111 -0
- package/package.json +6 -4
- package/src/components/TabView/TabView.js +34 -0
- package/src/components/TabView/TabView.tsx +97 -0
- package/src/components/TabView/TabViewItem.js +5 -0
- package/src/components/TabView/TabViewItem.tsx +21 -0
- package/src/components/TabView/index.js +2 -0
- package/src/components/TabView/index.tsx +2 -0
- package/src/index.js +1 -0
- package/src/index.tsx +1 -0
- package/src/mappings/AudioPlayer.js +2 -39
- package/src/mappings/AudioPlayer.ts +1 -41
- package/src/mappings/TabView.js +73 -0
- package/src/mappings/TabView.ts +80 -0
|
@@ -1,5 +1,3 @@
|
|
|
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
1
|
import * as React from "react";
|
|
4
2
|
import { withTheme } from "../theming";
|
|
5
3
|
import { StyleSheet } from "react-native";
|
|
@@ -42,13 +40,29 @@ const ToggleButton = _ref => {
|
|
|
42
40
|
onPress(!internalValue);
|
|
43
41
|
};
|
|
44
42
|
|
|
45
|
-
return /*#__PURE__*/React.createElement(IconButton,
|
|
43
|
+
return /*#__PURE__*/React.createElement(IconButton, {
|
|
46
44
|
Icon: Icon,
|
|
47
45
|
icon: icon,
|
|
48
46
|
size: iconSize,
|
|
49
47
|
color: internalValue ? colors[color] : colors[colorSecondary],
|
|
50
48
|
onPress: handlePress,
|
|
51
49
|
disabled: disabled,
|
|
50
|
+
style: [styles.mainContainer, {
|
|
51
|
+
width,
|
|
52
|
+
height,
|
|
53
|
+
backgroundColor: internalValue ? colors[colorSecondary] : colors[color],
|
|
54
|
+
borderColor: colors[borderColor]
|
|
55
|
+
}, style],
|
|
56
|
+
...rest
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const styles = StyleSheet.create({
|
|
61
|
+
mainContainer: {
|
|
62
|
+
borderWidth: 1
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
export default withTheme(ToggleButton);: disabled,
|
|
52
66
|
style: [styles.mainContainer, {
|
|
53
67
|
width,
|
|
54
68
|
height,
|
package/lib/module/index.js
CHANGED
|
@@ -29,6 +29,7 @@ export { default as Touchable } from "./components/Touchable";
|
|
|
29
29
|
export { AccordionGroup, AccordionItem } from "./components/Accordion";
|
|
30
30
|
export { ActionSheet, ActionSheetItem, ActionSheetCancel } from "./components/ActionSheet";
|
|
31
31
|
export { Swiper, SwiperItem } from "./components/Swiper";
|
|
32
|
+
export { TabView, TabViewItem } from "./components/TabView";
|
|
32
33
|
export { Center, Circle, Square, Row, Stack, Spacer } from "./components/Layout";
|
|
33
34
|
export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup } from "./components/RadioButton/index";
|
|
34
35
|
/* Deprecated: Fix or Delete! */
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
import { GROUPS, COMPONENT_TYPES, FORM_TYPES, PROP_TYPES
|
|
1
|
+
import { GROUPS, COMPONENT_TYPES, FORM_TYPES, PROP_TYPES } from "@draftbit/types";
|
|
2
2
|
export const SEED_DATA = {
|
|
3
3
|
name: "Audio Player",
|
|
4
4
|
tag: "AudioPlayer",
|
|
5
5
|
description: "Given a source URL, plays sounds & audio!",
|
|
6
6
|
category: COMPONENT_TYPES.media,
|
|
7
|
-
|
|
8
|
-
layout: {
|
|
9
|
-
backgroundColor: "#eee",
|
|
10
|
-
paddingLeft: 16,
|
|
11
|
-
paddingRight: 16,
|
|
12
|
-
paddingTop: 8,
|
|
13
|
-
paddingBottom: 8,
|
|
14
|
-
borderRadius: 24,
|
|
15
|
-
flexDirection: "row",
|
|
16
|
-
alignItems: "center"
|
|
17
|
-
},
|
|
7
|
+
layout: {},
|
|
18
8
|
props: {
|
|
19
9
|
source: {
|
|
20
10
|
group: GROUPS.data,
|
|
@@ -25,26 +15,6 @@ export const SEED_DATA = {
|
|
|
25
15
|
defaultValue: "https://static.draftbit.com/audio/intro-to-draftbit-audio.mp3",
|
|
26
16
|
formType: FORM_TYPES.sourceUrl,
|
|
27
17
|
propType: PROP_TYPES.OBJECT
|
|
28
|
-
}
|
|
29
|
-
sliderColor: createColorProp({
|
|
30
|
-
label: "Thumb Color",
|
|
31
|
-
defaultValue: "black"
|
|
32
|
-
}),
|
|
33
|
-
completedTrackColor: createColorProp({
|
|
34
|
-
label: "Completed Track Color",
|
|
35
|
-
defaultValue: "white"
|
|
36
|
-
}),
|
|
37
|
-
remainingTrackColor: createColorProp({
|
|
38
|
-
label: "Remaining Track Color",
|
|
39
|
-
defaultValue: "#333333"
|
|
40
|
-
}),
|
|
41
|
-
trackThumbSize: createNumberProp({
|
|
42
|
-
label: "Thumb Size",
|
|
43
|
-
defaultValue: 24
|
|
44
|
-
}),
|
|
45
|
-
playIconColor: createColorProp({
|
|
46
|
-
label: "Play Icon Color",
|
|
47
|
-
defaultValue: "black"
|
|
48
|
-
})
|
|
18
|
+
}
|
|
49
19
|
}
|
|
50
20
|
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { COMPONENT_TYPES, createTextProp, createTextEnumProp, createBoolProp, createColorProp } from "@draftbit/types";
|
|
2
|
+
export const SEED_DATA = [{
|
|
3
|
+
name: "Tab View",
|
|
4
|
+
tag: "TabView",
|
|
5
|
+
category: COMPONENT_TYPES.container,
|
|
6
|
+
layout: {},
|
|
7
|
+
props: {
|
|
8
|
+
tabBarPosition: createTextEnumProp({
|
|
9
|
+
label: "Tab Bar Position",
|
|
10
|
+
description: "Tab Bar Position",
|
|
11
|
+
options: ["top", "bottom"],
|
|
12
|
+
defaultValue: "top"
|
|
13
|
+
}),
|
|
14
|
+
keyboardDismissMode: createTextEnumProp({
|
|
15
|
+
label: "Keyboard Dismiss Mode",
|
|
16
|
+
description: "Keyboard Dismiss Mode",
|
|
17
|
+
options: ["auto", "on-drag", "none"],
|
|
18
|
+
defaultValue: "auto"
|
|
19
|
+
}),
|
|
20
|
+
swipeEnabled: createBoolProp({
|
|
21
|
+
label: "Swipe Enabled",
|
|
22
|
+
description: "Swipe Enabled",
|
|
23
|
+
defaultValue: true
|
|
24
|
+
}),
|
|
25
|
+
scrollEnabled: createBoolProp({
|
|
26
|
+
label: "Scroll Enabled",
|
|
27
|
+
description: "Scroll Enabled",
|
|
28
|
+
defaultValue: true
|
|
29
|
+
}),
|
|
30
|
+
activeColor: createColorProp({
|
|
31
|
+
label: "Active Color",
|
|
32
|
+
description: "Active Color",
|
|
33
|
+
defaultValue: "primary"
|
|
34
|
+
}),
|
|
35
|
+
inactiveColor: createColorProp({
|
|
36
|
+
label: "Inactive Color",
|
|
37
|
+
description: "Inactive Color",
|
|
38
|
+
defaultValue: null
|
|
39
|
+
}),
|
|
40
|
+
pressColor: createColorProp({
|
|
41
|
+
label: "Press Color",
|
|
42
|
+
description: "Press Color",
|
|
43
|
+
defaultValue: null
|
|
44
|
+
}),
|
|
45
|
+
indicatorColor: createColorProp({
|
|
46
|
+
label: "Indicator Color",
|
|
47
|
+
description: "Indicator Color",
|
|
48
|
+
defaultValue: null
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
name: "Tab View Item",
|
|
53
|
+
tag: "TabViewItem",
|
|
54
|
+
category: COMPONENT_TYPES.container,
|
|
55
|
+
layout: {},
|
|
56
|
+
props: {
|
|
57
|
+
title: createTextProp({
|
|
58
|
+
label: "Title",
|
|
59
|
+
description: "Tab Title"
|
|
60
|
+
}),
|
|
61
|
+
id: createTextProp({
|
|
62
|
+
label: "Id",
|
|
63
|
+
description: "Tab Id"
|
|
64
|
+
}),
|
|
65
|
+
accessibilityLabel: createTextProp({
|
|
66
|
+
label: "Accessibility Label",
|
|
67
|
+
description: "Accessibility Label"
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
}];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
3
|
+
import type { IconSlot } from "../../interfaces/Icon";
|
|
4
|
+
declare type TabBarPosition = "top" | "bottom";
|
|
5
|
+
declare type KeyboardDismissMode = "none" | "auto" | "on-drag";
|
|
6
|
+
declare type TabViewProps = {
|
|
7
|
+
tabBarPosition?: TabBarPosition;
|
|
8
|
+
keyboardDismissMode?: KeyboardDismissMode;
|
|
9
|
+
swipeEnabled?: boolean;
|
|
10
|
+
scrollEnabled?: boolean;
|
|
11
|
+
activeColor?: string;
|
|
12
|
+
inactiveColor?: string;
|
|
13
|
+
pressColor?: string;
|
|
14
|
+
indicatorColor?: string;
|
|
15
|
+
style?: StyleProp<TextStyle | ViewStyle>;
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
} & IconSlot;
|
|
18
|
+
declare const TabViewComponent: ({ Icon, tabBarPosition, keyboardDismissMode, swipeEnabled, scrollEnabled, activeColor, inactiveColor, pressColor, indicatorColor, style, children, }: TabViewProps) => JSX.Element;
|
|
19
|
+
export default TabViewComponent;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface TabViewItemProps {
|
|
3
|
+
title: string;
|
|
4
|
+
id: string;
|
|
5
|
+
icon: string;
|
|
6
|
+
accessibilityLabel: string;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
declare const TabViewItem: ({ title, id, icon, children, accessibilityLabel, }: TabViewItemProps) => React.ReactNode;
|
|
10
|
+
export default TabViewItem;
|
|
@@ -29,6 +29,7 @@ export { default as Touchable } from "./components/Touchable";
|
|
|
29
29
|
export { AccordionGroup, AccordionItem } from "./components/Accordion";
|
|
30
30
|
export { ActionSheet, ActionSheetItem, ActionSheetCancel, } from "./components/ActionSheet";
|
|
31
31
|
export { Swiper, SwiperItem } from "./components/Swiper";
|
|
32
|
+
export { TabView, TabViewItem } from "./components/TabView";
|
|
32
33
|
export { Center, Circle, Square, Row, Stack, Spacer, } from "./components/Layout";
|
|
33
34
|
export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup, } from "./components/RadioButton/index";
|
|
34
35
|
export { default as CardBlock } from "./components/CardBlock";
|
|
@@ -3,17 +3,7 @@ export declare const SEED_DATA: {
|
|
|
3
3
|
tag: string;
|
|
4
4
|
description: string;
|
|
5
5
|
category: string;
|
|
6
|
-
|
|
7
|
-
layout: {
|
|
8
|
-
backgroundColor: string;
|
|
9
|
-
paddingLeft: number;
|
|
10
|
-
paddingRight: number;
|
|
11
|
-
paddingTop: number;
|
|
12
|
-
paddingBottom: number;
|
|
13
|
-
borderRadius: number;
|
|
14
|
-
flexDirection: string;
|
|
15
|
-
alignItems: string;
|
|
16
|
-
};
|
|
6
|
+
layout: {};
|
|
17
7
|
props: {
|
|
18
8
|
source: {
|
|
19
9
|
group: string;
|
|
@@ -25,56 +15,5 @@ export declare const SEED_DATA: {
|
|
|
25
15
|
formType: string;
|
|
26
16
|
propType: string;
|
|
27
17
|
};
|
|
28
|
-
sliderColor: {
|
|
29
|
-
group: string;
|
|
30
|
-
label: string;
|
|
31
|
-
description: string;
|
|
32
|
-
editable: boolean;
|
|
33
|
-
required: boolean;
|
|
34
|
-
defaultValue: null;
|
|
35
|
-
formType: string;
|
|
36
|
-
propType: string;
|
|
37
|
-
};
|
|
38
|
-
completedTrackColor: {
|
|
39
|
-
group: string;
|
|
40
|
-
label: string;
|
|
41
|
-
description: string;
|
|
42
|
-
editable: boolean;
|
|
43
|
-
required: boolean;
|
|
44
|
-
defaultValue: null;
|
|
45
|
-
formType: string;
|
|
46
|
-
propType: string;
|
|
47
|
-
};
|
|
48
|
-
remainingTrackColor: {
|
|
49
|
-
group: string;
|
|
50
|
-
label: string;
|
|
51
|
-
description: string;
|
|
52
|
-
editable: boolean;
|
|
53
|
-
required: boolean;
|
|
54
|
-
defaultValue: null;
|
|
55
|
-
formType: string;
|
|
56
|
-
propType: string;
|
|
57
|
-
};
|
|
58
|
-
trackThumbSize: {
|
|
59
|
-
label: string;
|
|
60
|
-
description: string;
|
|
61
|
-
formType: string;
|
|
62
|
-
propType: string;
|
|
63
|
-
group: string;
|
|
64
|
-
defaultValue: null;
|
|
65
|
-
editable: boolean;
|
|
66
|
-
required: boolean;
|
|
67
|
-
step: number;
|
|
68
|
-
};
|
|
69
|
-
playIconColor: {
|
|
70
|
-
group: string;
|
|
71
|
-
label: string;
|
|
72
|
-
description: string;
|
|
73
|
-
editable: boolean;
|
|
74
|
-
required: boolean;
|
|
75
|
-
defaultValue: null;
|
|
76
|
-
formType: string;
|
|
77
|
-
propType: string;
|
|
78
|
-
};
|
|
79
18
|
};
|
|
80
19
|
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export declare const SEED_DATA: ({
|
|
2
|
+
name: string;
|
|
3
|
+
tag: string;
|
|
4
|
+
category: string;
|
|
5
|
+
layout: {};
|
|
6
|
+
props: {
|
|
7
|
+
tabBarPosition: {
|
|
8
|
+
group: string;
|
|
9
|
+
label: string;
|
|
10
|
+
description: string;
|
|
11
|
+
editable: boolean;
|
|
12
|
+
required: boolean;
|
|
13
|
+
formType: string;
|
|
14
|
+
propType: string;
|
|
15
|
+
defaultValue: null;
|
|
16
|
+
options: never[];
|
|
17
|
+
};
|
|
18
|
+
keyboardDismissMode: {
|
|
19
|
+
group: string;
|
|
20
|
+
label: string;
|
|
21
|
+
description: string;
|
|
22
|
+
editable: boolean;
|
|
23
|
+
required: boolean;
|
|
24
|
+
formType: string;
|
|
25
|
+
propType: string;
|
|
26
|
+
defaultValue: null;
|
|
27
|
+
options: never[];
|
|
28
|
+
};
|
|
29
|
+
swipeEnabled: {
|
|
30
|
+
label: string;
|
|
31
|
+
description: string;
|
|
32
|
+
formType: string;
|
|
33
|
+
propType: string;
|
|
34
|
+
defaultValue: boolean;
|
|
35
|
+
editable: boolean;
|
|
36
|
+
required: boolean;
|
|
37
|
+
group: string;
|
|
38
|
+
};
|
|
39
|
+
scrollEnabled: {
|
|
40
|
+
label: string;
|
|
41
|
+
description: string;
|
|
42
|
+
formType: string;
|
|
43
|
+
propType: string;
|
|
44
|
+
defaultValue: boolean;
|
|
45
|
+
editable: boolean;
|
|
46
|
+
required: boolean;
|
|
47
|
+
group: string;
|
|
48
|
+
};
|
|
49
|
+
activeColor: {
|
|
50
|
+
group: string;
|
|
51
|
+
label: string;
|
|
52
|
+
description: string;
|
|
53
|
+
editable: boolean;
|
|
54
|
+
required: boolean;
|
|
55
|
+
defaultValue: null;
|
|
56
|
+
formType: string;
|
|
57
|
+
propType: string;
|
|
58
|
+
};
|
|
59
|
+
inactiveColor: {
|
|
60
|
+
group: string;
|
|
61
|
+
label: string;
|
|
62
|
+
description: string;
|
|
63
|
+
editable: boolean;
|
|
64
|
+
required: boolean;
|
|
65
|
+
defaultValue: null;
|
|
66
|
+
formType: string;
|
|
67
|
+
propType: string;
|
|
68
|
+
};
|
|
69
|
+
pressColor: {
|
|
70
|
+
group: string;
|
|
71
|
+
label: string;
|
|
72
|
+
description: string;
|
|
73
|
+
editable: boolean;
|
|
74
|
+
required: boolean;
|
|
75
|
+
defaultValue: null;
|
|
76
|
+
formType: string;
|
|
77
|
+
propType: string;
|
|
78
|
+
};
|
|
79
|
+
indicatorColor: {
|
|
80
|
+
group: string;
|
|
81
|
+
label: string;
|
|
82
|
+
description: string;
|
|
83
|
+
editable: boolean;
|
|
84
|
+
required: boolean;
|
|
85
|
+
defaultValue: null;
|
|
86
|
+
formType: string;
|
|
87
|
+
propType: string;
|
|
88
|
+
};
|
|
89
|
+
title?: undefined;
|
|
90
|
+
id?: undefined;
|
|
91
|
+
accessibilityLabel?: undefined;
|
|
92
|
+
};
|
|
93
|
+
} | {
|
|
94
|
+
name: string;
|
|
95
|
+
tag: string;
|
|
96
|
+
category: string;
|
|
97
|
+
layout: {};
|
|
98
|
+
props: {
|
|
99
|
+
title: any;
|
|
100
|
+
id: any;
|
|
101
|
+
accessibilityLabel: any;
|
|
102
|
+
tabBarPosition?: undefined;
|
|
103
|
+
keyboardDismissMode?: undefined;
|
|
104
|
+
swipeEnabled?: undefined;
|
|
105
|
+
scrollEnabled?: undefined;
|
|
106
|
+
activeColor?: undefined;
|
|
107
|
+
inactiveColor?: undefined;
|
|
108
|
+
pressColor?: undefined;
|
|
109
|
+
indicatorColor?: undefined;
|
|
110
|
+
};
|
|
111
|
+
})[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "46.4.4-
|
|
3
|
+
"version": "46.4.4-d93fe1.2+d93fe16",
|
|
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.4.4-
|
|
44
|
+
"@draftbit/types": "^46.4.4-d93fe1.2+d93fe16",
|
|
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",
|
|
@@ -54,7 +54,9 @@
|
|
|
54
54
|
"lodash.omit": "^4.5.0",
|
|
55
55
|
"lodash.tonumber": "^4.0.3",
|
|
56
56
|
"react-native-modal-datetime-picker": "^13.0.0",
|
|
57
|
-
"react-native-
|
|
57
|
+
"react-native-pager-view": "5.4.24",
|
|
58
|
+
"react-native-svg": "^12.3.0",
|
|
59
|
+
"react-native-tab-view": "^3.0.0",
|
|
58
60
|
"react-native-typography": "^1.4.1",
|
|
59
61
|
"react-native-web-swiper": "^2.2.3"
|
|
60
62
|
},
|
|
@@ -81,5 +83,5 @@
|
|
|
81
83
|
]
|
|
82
84
|
]
|
|
83
85
|
},
|
|
84
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "d93fe16a73f301d097f5b69f29799083dbdcb46c"
|
|
85
87
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { TabView, TabBar, SceneMap } from "react-native-tab-view";
|
|
3
|
+
// import { withTheme } from "../../theming";
|
|
4
|
+
import TabViewItem from "./TabViewItem";
|
|
5
|
+
const TabViewComponent = ({ Icon, tabBarPosition, keyboardDismissMode, swipeEnabled, scrollEnabled, activeColor, inactiveColor, pressColor, indicatorColor, style, children, }) => {
|
|
6
|
+
const [index, setIndex] = React.useState(0);
|
|
7
|
+
const [routes, setRoutes] = React.useState([]);
|
|
8
|
+
const [tabScenes, setTabScenes] = React.useState({});
|
|
9
|
+
React.useEffect(() => {
|
|
10
|
+
const newRoutes = [];
|
|
11
|
+
const scenes = {};
|
|
12
|
+
React.Children.toArray(children)
|
|
13
|
+
.filter((child) => child.type === TabViewItem)
|
|
14
|
+
.forEach((child) => {
|
|
15
|
+
var _a, _b, _c;
|
|
16
|
+
if ((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.id) {
|
|
17
|
+
newRoutes.push({
|
|
18
|
+
key: (_b = child === null || child === void 0 ? void 0 : child.props) === null || _b === void 0 ? void 0 : _b.id,
|
|
19
|
+
...child === null || child === void 0 ? void 0 : child.props,
|
|
20
|
+
});
|
|
21
|
+
scenes[(_c = child === null || child === void 0 ? void 0 : child.props) === null || _c === void 0 ? void 0 : _c.id] = () => child;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
setRoutes(newRoutes);
|
|
25
|
+
setTabScenes(scenes);
|
|
26
|
+
}, [children]);
|
|
27
|
+
const indexChangeHandler = (i) => setIndex(i);
|
|
28
|
+
const renderTabBar = (props) => {
|
|
29
|
+
console.log(props);
|
|
30
|
+
return (React.createElement(TabBar, { ...props, activeColor: activeColor, inactiveColor: inactiveColor, pressColor: pressColor, scrollEnabled: scrollEnabled, indicatorStyle: { backgroundColor: indicatorColor }, renderIcon: ({ route, color }) => (route === null || route === void 0 ? void 0 : route.icon) ? (React.createElement(Icon, { name: route.icon, color: color, size: 36 })) : null, style: style }));
|
|
31
|
+
};
|
|
32
|
+
return (React.createElement(TabView, { navigationState: { index, routes }, renderScene: SceneMap(tabScenes), renderTabBar: renderTabBar, onIndexChange: indexChangeHandler, tabBarPosition: tabBarPosition, keyboardDismissMode: keyboardDismissMode, swipeEnabled: swipeEnabled }));
|
|
33
|
+
};
|
|
34
|
+
export default TabViewComponent;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
3
|
+
import { TabView, TabBar, SceneMap } from "react-native-tab-view";
|
|
4
|
+
|
|
5
|
+
// import { withTheme } from "../../theming";
|
|
6
|
+
import TabViewItem from "./TabViewItem";
|
|
7
|
+
import type { IconSlot } from "../../interfaces/Icon";
|
|
8
|
+
|
|
9
|
+
type TabBarPosition = "top" | "bottom";
|
|
10
|
+
type KeyboardDismissMode = "none" | "auto" | "on-drag";
|
|
11
|
+
|
|
12
|
+
type TabViewProps = {
|
|
13
|
+
tabBarPosition?: TabBarPosition;
|
|
14
|
+
keyboardDismissMode?: KeyboardDismissMode;
|
|
15
|
+
swipeEnabled?: boolean;
|
|
16
|
+
scrollEnabled?: boolean;
|
|
17
|
+
activeColor?: string;
|
|
18
|
+
inactiveColor?: string;
|
|
19
|
+
pressColor?: string;
|
|
20
|
+
indicatorColor?: string;
|
|
21
|
+
style?: StyleProp<TextStyle | ViewStyle>;
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
} & IconSlot;
|
|
24
|
+
|
|
25
|
+
const TabViewComponent = ({
|
|
26
|
+
Icon,
|
|
27
|
+
tabBarPosition,
|
|
28
|
+
keyboardDismissMode,
|
|
29
|
+
swipeEnabled,
|
|
30
|
+
scrollEnabled,
|
|
31
|
+
activeColor,
|
|
32
|
+
inactiveColor,
|
|
33
|
+
pressColor,
|
|
34
|
+
indicatorColor,
|
|
35
|
+
style,
|
|
36
|
+
children,
|
|
37
|
+
}: TabViewProps) => {
|
|
38
|
+
const [index, setIndex] = React.useState(0);
|
|
39
|
+
const [routes, setRoutes] = React.useState([]);
|
|
40
|
+
const [tabScenes, setTabScenes] = React.useState({});
|
|
41
|
+
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
const newRoutes: any = [];
|
|
44
|
+
const scenes: any = {};
|
|
45
|
+
|
|
46
|
+
React.Children.toArray(children)
|
|
47
|
+
.filter((child: any) => child.type === TabViewItem)
|
|
48
|
+
.forEach((child: any) => {
|
|
49
|
+
if (child?.props?.id) {
|
|
50
|
+
newRoutes.push({
|
|
51
|
+
key: child?.props?.id,
|
|
52
|
+
...child?.props,
|
|
53
|
+
});
|
|
54
|
+
scenes[child?.props?.id] = () => child;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
setRoutes(newRoutes);
|
|
59
|
+
setTabScenes(scenes);
|
|
60
|
+
}, [children]);
|
|
61
|
+
|
|
62
|
+
const indexChangeHandler = (i: any) => setIndex(i);
|
|
63
|
+
|
|
64
|
+
const renderTabBar = (props: any) => {
|
|
65
|
+
console.log(props);
|
|
66
|
+
return (
|
|
67
|
+
<TabBar
|
|
68
|
+
{...props}
|
|
69
|
+
activeColor={activeColor}
|
|
70
|
+
inactiveColor={inactiveColor}
|
|
71
|
+
pressColor={pressColor}
|
|
72
|
+
scrollEnabled={scrollEnabled}
|
|
73
|
+
indicatorStyle={{ backgroundColor: indicatorColor }}
|
|
74
|
+
renderIcon={({ route, color }) =>
|
|
75
|
+
route?.icon ? (
|
|
76
|
+
<Icon name={route.icon} color={color} size={36} />
|
|
77
|
+
) : null
|
|
78
|
+
}
|
|
79
|
+
style={style}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<TabView
|
|
86
|
+
navigationState={{ index, routes }}
|
|
87
|
+
renderScene={SceneMap(tabScenes)}
|
|
88
|
+
renderTabBar={renderTabBar}
|
|
89
|
+
onIndexChange={indexChangeHandler}
|
|
90
|
+
tabBarPosition={tabBarPosition}
|
|
91
|
+
keyboardDismissMode={keyboardDismissMode}
|
|
92
|
+
swipeEnabled={swipeEnabled}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export default TabViewComponent;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface TabViewItemProps {
|
|
3
|
+
title: string;
|
|
4
|
+
id: string;
|
|
5
|
+
icon: string;
|
|
6
|
+
accessibilityLabel: string;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const TabViewItem = ({
|
|
11
|
+
title,
|
|
12
|
+
id,
|
|
13
|
+
icon,
|
|
14
|
+
children,
|
|
15
|
+
accessibilityLabel,
|
|
16
|
+
}: TabViewItemProps) => {
|
|
17
|
+
console.log({ title, id, icon, accessibilityLabel });
|
|
18
|
+
return children;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default TabViewItem;
|
package/src/index.js
CHANGED
|
@@ -29,6 +29,7 @@ export { default as Touchable } from "./components/Touchable";
|
|
|
29
29
|
export { AccordionGroup, AccordionItem } from "./components/Accordion";
|
|
30
30
|
export { ActionSheet, ActionSheetItem, ActionSheetCancel, } from "./components/ActionSheet";
|
|
31
31
|
export { Swiper, SwiperItem } from "./components/Swiper";
|
|
32
|
+
export { TabView, TabViewItem } from "./components/TabView";
|
|
32
33
|
export { Center, Circle, Square, Row, Stack, Spacer, } from "./components/Layout";
|
|
33
34
|
export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup, } from "./components/RadioButton/index";
|
|
34
35
|
/* Deprecated: Fix or Delete! */
|
package/src/index.tsx
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
|
-
import { GROUPS, COMPONENT_TYPES, FORM_TYPES, PROP_TYPES,
|
|
1
|
+
import { GROUPS, COMPONENT_TYPES, FORM_TYPES, PROP_TYPES, } from "@draftbit/types";
|
|
2
2
|
export const SEED_DATA = {
|
|
3
3
|
name: "Audio Player",
|
|
4
4
|
tag: "AudioPlayer",
|
|
5
5
|
description: "Given a source URL, plays sounds & audio!",
|
|
6
6
|
category: COMPONENT_TYPES.media,
|
|
7
|
-
|
|
8
|
-
StylesPanelSections.Typography,
|
|
9
|
-
StylesPanelSections.Background,
|
|
10
|
-
StylesPanelSections.Borders,
|
|
11
|
-
StylesPanelSections.Size,
|
|
12
|
-
StylesPanelSections.MarginsAndPaddings,
|
|
13
|
-
StylesPanelSections.Position,
|
|
14
|
-
],
|
|
15
|
-
layout: {
|
|
16
|
-
backgroundColor: "#eee",
|
|
17
|
-
paddingLeft: 16,
|
|
18
|
-
paddingRight: 16,
|
|
19
|
-
paddingTop: 8,
|
|
20
|
-
paddingBottom: 8,
|
|
21
|
-
borderRadius: 24,
|
|
22
|
-
flexDirection: "row",
|
|
23
|
-
alignItems: "center",
|
|
24
|
-
},
|
|
7
|
+
layout: {},
|
|
25
8
|
props: {
|
|
26
9
|
source: {
|
|
27
10
|
group: GROUPS.data,
|
|
@@ -33,25 +16,5 @@ export const SEED_DATA = {
|
|
|
33
16
|
formType: FORM_TYPES.sourceUrl,
|
|
34
17
|
propType: PROP_TYPES.OBJECT,
|
|
35
18
|
},
|
|
36
|
-
sliderColor: createColorProp({
|
|
37
|
-
label: "Thumb Color",
|
|
38
|
-
defaultValue: "black",
|
|
39
|
-
}),
|
|
40
|
-
completedTrackColor: createColorProp({
|
|
41
|
-
label: "Completed Track Color",
|
|
42
|
-
defaultValue: "white",
|
|
43
|
-
}),
|
|
44
|
-
remainingTrackColor: createColorProp({
|
|
45
|
-
label: "Remaining Track Color",
|
|
46
|
-
defaultValue: "#333333",
|
|
47
|
-
}),
|
|
48
|
-
trackThumbSize: createNumberProp({
|
|
49
|
-
label: "Thumb Size",
|
|
50
|
-
defaultValue: 24,
|
|
51
|
-
}),
|
|
52
|
-
playIconColor: createColorProp({
|
|
53
|
-
label: "Play Icon Color",
|
|
54
|
-
defaultValue: "black",
|
|
55
|
-
}),
|
|
56
19
|
},
|
|
57
20
|
};
|