@draftbit/core 46.8.2-af4b7d.2 → 46.8.2-bdb2fb.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.
Files changed (43) hide show
  1. package/lib/commonjs/components/TabView/TabView.js +113 -0
  2. package/lib/commonjs/components/TabView/TabViewItem.js +25 -0
  3. package/lib/commonjs/components/TabView/index.js +20 -0
  4. package/lib/commonjs/index.js +13 -0
  5. package/lib/commonjs/mappings/TabView.js +77 -0
  6. package/lib/commonjs/mappings/TabViewItem.js +37 -0
  7. package/lib/module/components/Portal/PortalManager.js +33 -7
  8. package/lib/module/components/TabView/TabView.js +103 -0
  9. package/lib/module/components/TabView/TabViewItem.js +20 -0
  10. package/lib/module/components/TabView/index.js +2 -0
  11. package/lib/module/index.js +1 -0
  12. package/lib/module/mappings/TabView.js +70 -0
  13. package/lib/module/mappings/TabViewItem.js +30 -0
  14. package/lib/typescript/src/components/TabView/TabView.d.ts +26 -0
  15. package/lib/typescript/src/components/TabView/TabView.d.ts.map +1 -0
  16. package/lib/typescript/src/components/TabView/TabViewItem.d.ts +11 -0
  17. package/lib/typescript/src/components/TabView/TabViewItem.d.ts.map +1 -0
  18. package/lib/typescript/src/components/TabView/index.d.ts +3 -0
  19. package/lib/typescript/src/components/TabView/index.d.ts.map +1 -0
  20. package/lib/typescript/src/index.d.ts +1 -0
  21. package/lib/typescript/src/index.d.ts.map +1 -1
  22. package/lib/typescript/src/mappings/{HtmlElements.d.ts → TabView.d.ts} +64 -47
  23. package/lib/typescript/src/mappings/TabView.d.ts.map +1 -0
  24. package/lib/typescript/src/mappings/TabViewItem.d.ts +25 -0
  25. package/lib/typescript/src/mappings/TabViewItem.d.ts.map +1 -0
  26. package/package.json +5 -4
  27. package/src/components/TabView/TabView.js +50 -0
  28. package/src/components/TabView/TabView.tsx +137 -0
  29. package/src/components/TabView/TabViewItem.js +11 -0
  30. package/src/components/TabView/TabViewItem.tsx +25 -0
  31. package/src/components/TabView/index.js +2 -0
  32. package/src/components/TabView/index.tsx +2 -0
  33. package/src/index.js +1 -0
  34. package/src/index.tsx +2 -0
  35. package/src/mappings/TabView.js +76 -0
  36. package/src/mappings/TabView.ts +86 -0
  37. package/src/mappings/TabViewItem.js +30 -0
  38. package/src/mappings/TabViewItem.ts +38 -0
  39. package/lib/commonjs/mappings/HtmlElements.js +0 -160
  40. package/lib/module/mappings/HtmlElements.js +0 -153
  41. package/lib/typescript/src/mappings/HtmlElements.d.ts.map +0 -1
  42. package/src/mappings/HtmlElements.js +0 -180
  43. package/src/mappings/HtmlElements.ts +0 -194
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,OAAO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AAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC"}
@@ -1,23 +1,36 @@
1
- export declare const SEED_DATA: ({
1
+ export declare const SEED_DATA: {
2
+ name: string;
3
+ tag: string;
4
+ description: string;
2
5
  category: string;
3
6
  stylesPanelSections: string[];
4
7
  layout: {
5
- color: string;
8
+ flex: number;
6
9
  };
10
+ triggers: string[];
7
11
  props: {
8
- children: {
12
+ onIndexChanged: {
13
+ label: string;
14
+ description: string;
15
+ editable: boolean;
16
+ required: boolean;
17
+ formType: string;
18
+ propType: string;
19
+ defaultValue: null;
9
20
  group: string;
21
+ };
22
+ onEndReached: {
10
23
  label: string;
11
24
  description: string;
12
- defaultValue: string;
13
25
  editable: boolean;
14
26
  required: boolean;
15
27
  formType: string;
16
28
  propType: string;
29
+ defaultValue: null;
30
+ group: string;
17
31
  };
18
- accessibilityLabel: {
32
+ tabBarPosition: {
19
33
  group: string;
20
- name: string;
21
34
  label: string;
22
35
  description: string;
23
36
  editable: boolean;
@@ -25,85 +38,89 @@ export declare const SEED_DATA: ({
25
38
  formType: string;
26
39
  propType: string;
27
40
  defaultValue: null;
41
+ options: never[];
28
42
  };
29
- selectable: {
43
+ keyboardDismissMode: {
30
44
  group: string;
31
- name: string;
32
45
  label: string;
33
46
  description: string;
34
47
  editable: boolean;
35
48
  required: boolean;
36
49
  formType: string;
37
50
  propType: string;
51
+ defaultValue: null;
52
+ options: never[];
53
+ };
54
+ swipeEnabled: {
55
+ label: string;
56
+ description: string;
57
+ formType: string;
58
+ propType: string;
38
59
  defaultValue: boolean;
60
+ editable: boolean;
61
+ required: boolean;
62
+ group: string;
39
63
  };
40
- };
41
- doc_link: string;
42
- code_link: string;
43
- packageName: string;
44
- name: string;
45
- tag: string;
46
- } | {
47
- doc_link: string;
48
- code_link: string;
49
- packageName: string;
50
- stylesPanelSections: string[];
51
- category: string;
52
- name: string;
53
- tag: string;
54
- } | {
55
- props: {
56
- href: any;
57
- target: {
64
+ scrollEnabled: {
65
+ label: string;
66
+ description: string;
67
+ formType: string;
68
+ propType: string;
69
+ defaultValue: boolean;
70
+ editable: boolean;
71
+ required: boolean;
72
+ group: string;
73
+ };
74
+ activeColor: {
58
75
  group: string;
59
76
  label: string;
60
77
  description: string;
78
+ editable: boolean;
79
+ required: boolean;
80
+ defaultValue: null;
61
81
  formType: string;
62
- defaultValue: string;
63
- options: string[];
82
+ propType: string;
64
83
  };
65
- children: {
84
+ inactiveColor: {
66
85
  group: string;
67
86
  label: string;
68
87
  description: string;
69
- defaultValue: string;
70
88
  editable: boolean;
71
89
  required: boolean;
90
+ defaultValue: null;
72
91
  formType: string;
73
92
  propType: string;
74
93
  };
75
- accessibilityLabel: {
94
+ pressColor: {
76
95
  group: string;
77
- name: string;
78
96
  label: string;
79
97
  description: string;
80
98
  editable: boolean;
81
99
  required: boolean;
100
+ defaultValue: null;
82
101
  formType: string;
83
102
  propType: string;
103
+ };
104
+ indicatorColor: {
105
+ group: string;
106
+ label: string;
107
+ description: string;
108
+ editable: boolean;
109
+ required: boolean;
84
110
  defaultValue: null;
111
+ formType: string;
112
+ propType: string;
85
113
  };
86
- selectable: {
114
+ tabsBackgroundColor: {
87
115
  group: string;
88
- name: string;
89
116
  label: string;
90
117
  description: string;
91
118
  editable: boolean;
92
119
  required: boolean;
120
+ defaultValue: null;
93
121
  formType: string;
94
122
  propType: string;
95
- defaultValue: boolean;
96
123
  };
97
124
  };
98
- category: string;
99
- stylesPanelSections: string[];
100
- layout: {
101
- color: string;
102
- };
103
- doc_link: string;
104
- code_link: string;
105
- packageName: string;
106
- name: string;
107
- tag: string;
108
- })[];
109
- //# sourceMappingURL=HtmlElements.d.ts.map
125
+ };
126
+ //# sourceMappingURL=TabView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TabView.d.ts","sourceRoot":"","sources":["../../../../src/mappings/TabView.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0ErB,CAAC"}
@@ -0,0 +1,25 @@
1
+ export declare const SEED_DATA: {
2
+ name: string;
3
+ tag: string;
4
+ description: string;
5
+ category: string;
6
+ stylesPanelSections: string[];
7
+ layout: {
8
+ flex: number;
9
+ };
10
+ props: {
11
+ title: any;
12
+ icon: {
13
+ label: string;
14
+ description: string;
15
+ formType: string;
16
+ propType: string;
17
+ defaultValue: string;
18
+ required: boolean;
19
+ editable: boolean;
20
+ group: string;
21
+ };
22
+ accessibilityLabel: any;
23
+ };
24
+ };
25
+ //# sourceMappingURL=TabViewItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TabViewItem.d.ts","sourceRoot":"","sources":["../../../../src/mappings/TabViewItem.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;CA6BrB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftbit/core",
3
- "version": "46.8.2-af4b7d.2+af4b7d0",
3
+ "version": "46.8.2-bdb2fb.2+bdb2fbd",
4
4
  "description": "Core (non-native) Components",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -41,8 +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-af4b7d.2+af4b7d0",
45
- "@expo/html-elements": "^0.3.1",
44
+ "@draftbit/types": "^46.8.2-bdb2fb.2+bdb2fbd",
46
45
  "@material-ui/core": "^4.11.0",
47
46
  "@material-ui/pickers": "^3.2.10",
48
47
  "@react-native-community/slider": "4.2.3",
@@ -56,7 +55,9 @@
56
55
  "lodash.tonumber": "^4.0.3",
57
56
  "react-native-deck-swiper": "^2.0.12",
58
57
  "react-native-modal-datetime-picker": "^13.0.0",
58
+ "react-native-pager-view": "5.4.24",
59
59
  "react-native-svg": "12.3.0",
60
+ "react-native-tab-view": "^3.4.0",
60
61
  "react-native-typography": "^1.4.1",
61
62
  "react-native-web-swiper": "^2.2.3"
62
63
  },
@@ -93,5 +94,5 @@
93
94
  ]
94
95
  ]
95
96
  },
96
- "gitHead": "af4b7d05423db7dbcc8d6ad29c655abae47ca702"
97
+ "gitHead": "bdb2fbd9d472a8abb0d9553ca73679456ab4aa40"
97
98
  }
@@ -0,0 +1,50 @@
1
+ import * as React from "react";
2
+ import { StyleSheet } from "react-native";
3
+ import { TabView, TabBar, SceneMap, } from "react-native-tab-view";
4
+ import TabViewItem from "./TabViewItem";
5
+ import { withTheme } from "../../theming";
6
+ import { extractStyles } from "../../utilities";
7
+ const TabViewComponent = ({ Icon, onIndexChanged, onEndReached, tabBarPosition, keyboardDismissMode, swipeEnabled, scrollEnabled, activeColor, inactiveColor, pressColor, indicatorColor, tabsBackgroundColor, style, theme, children, }) => {
8
+ const [index, setIndex] = React.useState(0);
9
+ const [routes, setRoutes] = React.useState([]);
10
+ const [tabScenes, setTabScenes] = React.useState({});
11
+ const { textStyles, viewStyles } = extractStyles(style);
12
+ //Populate routes and scenes based on children
13
+ React.useEffect(() => {
14
+ const newRoutes = [];
15
+ const scenes = {};
16
+ React.Children.toArray(children)
17
+ .filter((child) => React.isValidElement(child) && child.type === TabViewItem)
18
+ .forEach((item, idx) => {
19
+ const child = item;
20
+ newRoutes.push({
21
+ key: idx.toString(),
22
+ title: child.props.title,
23
+ icon: child.props.icon,
24
+ accessibilityLabel: child.props.accessibilityLabel,
25
+ });
26
+ scenes[idx] = () => child;
27
+ });
28
+ setRoutes(newRoutes);
29
+ setTabScenes(scenes);
30
+ }, [children]);
31
+ const indexChangeHandler = (i) => {
32
+ setIndex(i);
33
+ onIndexChanged === null || onIndexChanged === void 0 ? void 0 : onIndexChanged(i);
34
+ if (i === routes.length) {
35
+ onEndReached === null || onEndReached === void 0 ? void 0 : onEndReached();
36
+ }
37
+ };
38
+ const renderTabBar = (props) => {
39
+ return (React.createElement(TabBar, { ...props, activeColor: activeColor || theme.colors.primary, inactiveColor: inactiveColor || theme.colors.divider, pressColor: pressColor || theme.colors.primary, scrollEnabled: scrollEnabled, indicatorStyle: {
40
+ backgroundColor: indicatorColor || theme.colors.primary,
41
+ }, labelStyle: textStyles, renderIcon: ({ route, color }) => (route === null || route === void 0 ? void 0 : route.icon) ? (React.createElement(Icon, { name: route.icon, color: color, size: 36 })) : null, style: {
42
+ backgroundColor: tabsBackgroundColor || theme.colors.background,
43
+ } }));
44
+ };
45
+ return (React.createElement(TabView, { style: [styles.tabView, viewStyles], navigationState: { index, routes }, renderScene: SceneMap(tabScenes), renderTabBar: renderTabBar, onIndexChange: indexChangeHandler, tabBarPosition: tabBarPosition, keyboardDismissMode: keyboardDismissMode, swipeEnabled: swipeEnabled }));
46
+ };
47
+ const styles = StyleSheet.create({
48
+ tabView: { flex: 1 },
49
+ });
50
+ export default withTheme(TabViewComponent);
@@ -0,0 +1,137 @@
1
+ import * as React from "react";
2
+ import { StyleProp, ViewStyle, StyleSheet } from "react-native";
3
+ import {
4
+ TabView,
5
+ TabBar,
6
+ SceneMap,
7
+ SceneRendererProps,
8
+ NavigationState,
9
+ Route,
10
+ } from "react-native-tab-view";
11
+
12
+ import TabViewItem from "./TabViewItem";
13
+ import type { IconSlot } from "../../interfaces/Icon";
14
+ import { withTheme } from "../../theming";
15
+ import type { Theme } from "../../styles/DefaultTheme";
16
+ import { extractStyles } from "../../utilities";
17
+
18
+ type TabBarProps = SceneRendererProps & {
19
+ navigationState: NavigationState<any>;
20
+ };
21
+ type TabBarPosition = "top" | "bottom";
22
+ type KeyboardDismissMode = "none" | "auto" | "on-drag";
23
+
24
+ type TabViewProps = {
25
+ onIndexChanged?: (index: number) => void;
26
+ onEndReached?: () => void;
27
+ tabBarPosition?: TabBarPosition;
28
+ keyboardDismissMode?: KeyboardDismissMode;
29
+ swipeEnabled?: boolean;
30
+ scrollEnabled?: boolean;
31
+ activeColor?: string;
32
+ inactiveColor?: string;
33
+ pressColor?: string;
34
+ indicatorColor?: string;
35
+ tabsBackgroundColor?: string;
36
+ style?: StyleProp<ViewStyle>;
37
+ theme: Theme;
38
+ } & IconSlot;
39
+
40
+ const TabViewComponent: React.FC<React.PropsWithChildren<TabViewProps>> = ({
41
+ Icon,
42
+ onIndexChanged,
43
+ onEndReached,
44
+ tabBarPosition,
45
+ keyboardDismissMode,
46
+ swipeEnabled,
47
+ scrollEnabled,
48
+ activeColor,
49
+ inactiveColor,
50
+ pressColor,
51
+ indicatorColor,
52
+ tabsBackgroundColor,
53
+ style,
54
+ theme,
55
+ children,
56
+ }) => {
57
+ const [index, setIndex] = React.useState(0);
58
+ const [routes, setRoutes] = React.useState<Route[]>([]);
59
+ const [tabScenes, setTabScenes] = React.useState({});
60
+
61
+ const { textStyles, viewStyles } = extractStyles(style);
62
+
63
+ //Populate routes and scenes based on children
64
+ React.useEffect(() => {
65
+ const newRoutes: Route[] = [];
66
+ const scenes: any = {};
67
+
68
+ React.Children.toArray(children)
69
+ .filter(
70
+ (child) => React.isValidElement(child) && child.type === TabViewItem
71
+ )
72
+ .forEach((item: any, idx) => {
73
+ const child = item as React.ReactElement;
74
+ newRoutes.push({
75
+ key: idx.toString(),
76
+ title: child.props.title,
77
+ icon: child.props.icon,
78
+ accessibilityLabel: child.props.accessibilityLabel,
79
+ });
80
+ scenes[idx] = () => child;
81
+ });
82
+
83
+ setRoutes(newRoutes);
84
+ setTabScenes(scenes);
85
+ }, [children]);
86
+
87
+ const indexChangeHandler = (i: number) => {
88
+ setIndex(i);
89
+ onIndexChanged?.(i);
90
+ if (i === routes.length) {
91
+ onEndReached?.();
92
+ }
93
+ };
94
+
95
+ const renderTabBar: React.FC<TabBarProps> = (props) => {
96
+ return (
97
+ <TabBar
98
+ {...props}
99
+ activeColor={activeColor || theme.colors.primary}
100
+ inactiveColor={inactiveColor || theme.colors.divider}
101
+ pressColor={pressColor || theme.colors.primary}
102
+ scrollEnabled={scrollEnabled}
103
+ indicatorStyle={{
104
+ backgroundColor: indicatorColor || theme.colors.primary,
105
+ }}
106
+ labelStyle={textStyles}
107
+ renderIcon={({ route, color }) =>
108
+ route?.icon ? (
109
+ <Icon name={route.icon} color={color} size={36} />
110
+ ) : null
111
+ }
112
+ style={{
113
+ backgroundColor: tabsBackgroundColor || theme.colors.background,
114
+ }}
115
+ />
116
+ );
117
+ };
118
+
119
+ return (
120
+ <TabView
121
+ style={[styles.tabView, viewStyles]}
122
+ navigationState={{ index, routes }}
123
+ renderScene={SceneMap(tabScenes)}
124
+ renderTabBar={renderTabBar}
125
+ onIndexChange={indexChangeHandler}
126
+ tabBarPosition={tabBarPosition}
127
+ keyboardDismissMode={keyboardDismissMode}
128
+ swipeEnabled={swipeEnabled}
129
+ />
130
+ );
131
+ };
132
+
133
+ const styles = StyleSheet.create({
134
+ tabView: { flex: 1 },
135
+ });
136
+
137
+ export default withTheme(TabViewComponent);
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import { StyleSheet, View } from "react-native";
3
+ const TabViewItem = ({ style, children, }) => {
4
+ return React.createElement(View, { style: [styles.parentContainer, style] }, children);
5
+ };
6
+ const styles = StyleSheet.create({
7
+ parentContainer: {
8
+ flex: 1,
9
+ },
10
+ });
11
+ export default TabViewItem;
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+ import { StyleProp, ViewStyle, StyleSheet, View } from "react-native";
3
+
4
+ //Props used by parent (TabView) to create tabs
5
+ interface TabViewItemProps {
6
+ title: string;
7
+ icon?: string;
8
+ accessibilityLabel?: string;
9
+ style?: StyleProp<ViewStyle>;
10
+ }
11
+
12
+ const TabViewItem: React.FC<React.PropsWithChildren<TabViewItemProps>> = ({
13
+ style,
14
+ children,
15
+ }) => {
16
+ return <View style={[styles.parentContainer, style]}>{children}</View>;
17
+ };
18
+
19
+ const styles = StyleSheet.create({
20
+ parentContainer: {
21
+ flex: 1,
22
+ },
23
+ });
24
+
25
+ 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
@@ -32,6 +32,7 @@ export { Swiper, SwiperItem } from "./components/Swiper";
32
32
  export { Center, Circle, Square, Row, Stack, Spacer, } from "./components/Layout";
33
33
  export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup, } from "./components/RadioButton/index";
34
34
  export { DeckSwiper, DeckSwiperCard } from "./components/DeckSwiper";
35
+ export { TabView, TabViewItem } from "./components/TabView";
35
36
  /* Deprecated: Fix or Delete! */
36
37
  export { default as DatePicker } from "./components/DatePicker/DatePicker";
37
38
  export { default as Picker } from "./components/Picker/Picker";
package/src/index.tsx CHANGED
@@ -53,6 +53,8 @@ export {
53
53
 
54
54
  export { DeckSwiper, DeckSwiperCard } from "./components/DeckSwiper";
55
55
 
56
+ export { TabView, TabViewItem } from "./components/TabView";
57
+
56
58
  /* Deprecated: Fix or Delete! */
57
59
  export { default as DatePicker } from "./components/DatePicker/DatePicker";
58
60
  export { default as Picker } from "./components/Picker/Picker";
@@ -0,0 +1,76 @@
1
+ import { COMPONENT_TYPES, createTextEnumProp, createColorProp, StylesPanelSections, Triggers, createActionProp, createStaticBoolProp, GROUPS, } from "@draftbit/types";
2
+ export const SEED_DATA = {
3
+ name: "Tab View",
4
+ tag: "TabView",
5
+ description: "Tab view container",
6
+ category: COMPONENT_TYPES.swiper,
7
+ stylesPanelSections: [
8
+ StylesPanelSections.Size,
9
+ StylesPanelSections.MarginsAndPaddings,
10
+ StylesPanelSections.Position,
11
+ StylesPanelSections.Effects,
12
+ StylesPanelSections.LayoutSelectedItem,
13
+ StylesPanelSections.Background,
14
+ StylesPanelSections.Typography,
15
+ ],
16
+ layout: { flex: 1 },
17
+ triggers: [Triggers.OnIndexChanged, Triggers.OnEndReached],
18
+ props: {
19
+ onIndexChanged: createActionProp({
20
+ label: "On index changed",
21
+ description: "Action to execute when swipe to new index",
22
+ }),
23
+ onEndReached: createActionProp({
24
+ label: "On end reached",
25
+ description: "Action to execute when end of swiping reached",
26
+ }),
27
+ tabBarPosition: createTextEnumProp({
28
+ label: "Tab Bar Position",
29
+ description: "Position of tab bar",
30
+ options: ["top", "bottom"],
31
+ defaultValue: "top",
32
+ }),
33
+ keyboardDismissMode: createTextEnumProp({
34
+ label: "Keyboard Dismiss Mode",
35
+ description: "Keyboard Dismiss Mode",
36
+ options: ["auto", "on-drag", "none"],
37
+ defaultValue: "auto",
38
+ }),
39
+ swipeEnabled: createStaticBoolProp({
40
+ label: "Swipe Enabled",
41
+ description: "Whether swiping is enabled or not",
42
+ defaultValue: true,
43
+ }),
44
+ scrollEnabled: createStaticBoolProp({
45
+ label: "Scroll Enabled",
46
+ description: "Whether scrolling of tabs is enabled or not",
47
+ defaultValue: false,
48
+ }),
49
+ activeColor: createColorProp({
50
+ label: "Active Color",
51
+ description: "Color of icon and text of active tab",
52
+ defaultValue: "primary",
53
+ }),
54
+ inactiveColor: createColorProp({
55
+ label: "Inactive Color",
56
+ description: "Color of icon and text of inactive tab(s)",
57
+ defaultValue: null,
58
+ }),
59
+ pressColor: createColorProp({
60
+ label: "Press Color",
61
+ description: "Color of ripple when pressed",
62
+ defaultValue: "primary",
63
+ group: GROUPS.android,
64
+ }),
65
+ indicatorColor: createColorProp({
66
+ label: "Indicator Color",
67
+ description: "Color of indicator",
68
+ defaultValue: "primary",
69
+ }),
70
+ tabsBackgroundColor: createColorProp({
71
+ label: "Tabs Background Color",
72
+ description: "Background color of tabs container",
73
+ defaultValue: "background",
74
+ }),
75
+ },
76
+ };
@@ -0,0 +1,86 @@
1
+ import {
2
+ COMPONENT_TYPES,
3
+ createTextEnumProp,
4
+ createColorProp,
5
+ StylesPanelSections,
6
+ Triggers,
7
+ createActionProp,
8
+ createStaticBoolProp,
9
+ GROUPS,
10
+ } from "@draftbit/types";
11
+
12
+ export const SEED_DATA = {
13
+ name: "Tab View",
14
+ tag: "TabView",
15
+ description: "Tab view container",
16
+ category: COMPONENT_TYPES.swiper,
17
+ stylesPanelSections: [
18
+ StylesPanelSections.Size,
19
+ StylesPanelSections.MarginsAndPaddings,
20
+ StylesPanelSections.Position,
21
+ StylesPanelSections.Effects,
22
+ StylesPanelSections.LayoutSelectedItem,
23
+ StylesPanelSections.Background,
24
+ StylesPanelSections.Typography,
25
+ ],
26
+ layout: { flex: 1 },
27
+ triggers: [Triggers.OnIndexChanged, Triggers.OnEndReached],
28
+ props: {
29
+ onIndexChanged: createActionProp({
30
+ label: "On index changed",
31
+ description: "Action to execute when swipe to new index",
32
+ }),
33
+ onEndReached: createActionProp({
34
+ label: "On end reached",
35
+ description: "Action to execute when end of swiping reached",
36
+ }),
37
+ tabBarPosition: createTextEnumProp({
38
+ label: "Tab Bar Position",
39
+ description: "Position of tab bar",
40
+ options: ["top", "bottom"],
41
+ defaultValue: "top",
42
+ }),
43
+ keyboardDismissMode: createTextEnumProp({
44
+ label: "Keyboard Dismiss Mode",
45
+ description: "Keyboard Dismiss Mode",
46
+ options: ["auto", "on-drag", "none"],
47
+ defaultValue: "auto",
48
+ }),
49
+ swipeEnabled: createStaticBoolProp({
50
+ label: "Swipe Enabled",
51
+ description: "Whether swiping is enabled or not",
52
+ defaultValue: true,
53
+ }),
54
+ scrollEnabled: createStaticBoolProp({
55
+ label: "Scroll Enabled",
56
+ description: "Whether scrolling of tabs is enabled or not",
57
+ defaultValue: false,
58
+ }),
59
+ activeColor: createColorProp({
60
+ label: "Active Color",
61
+ description: "Color of icon and text of active tab",
62
+ defaultValue: "primary",
63
+ }),
64
+ inactiveColor: createColorProp({
65
+ label: "Inactive Color",
66
+ description: "Color of icon and text of inactive tab(s)",
67
+ defaultValue: null,
68
+ }),
69
+ pressColor: createColorProp({
70
+ label: "Press Color",
71
+ description: "Color of ripple when pressed",
72
+ defaultValue: "primary",
73
+ group: GROUPS.android,
74
+ }),
75
+ indicatorColor: createColorProp({
76
+ label: "Indicator Color",
77
+ description: "Color of indicator",
78
+ defaultValue: "primary",
79
+ }),
80
+ tabsBackgroundColor: createColorProp({
81
+ label: "Tabs Background Color",
82
+ description: "Background color of tabs container",
83
+ defaultValue: "background",
84
+ }),
85
+ },
86
+ };