@draftbit/core 46.8.2-088bf8.2 → 46.8.2-2fe7f4.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 +23 -4
- package/lib/commonjs/components/RadioButton/context.js +1 -1
- package/lib/commonjs/components/TabView/TabView.js +132 -0
- package/lib/commonjs/components/TabView/TabViewItem.js +25 -0
- package/lib/commonjs/components/TabView/index.js +20 -0
- package/lib/commonjs/components/ToggleButton.js +2 -15
- package/lib/commonjs/hooks.js +2 -1
- package/lib/commonjs/index.js +13 -0
- package/lib/commonjs/mappings/TabView.js +77 -0
- package/lib/commonjs/mappings/TabViewItem.js +37 -0
- package/lib/module/components/Picker/PickerComponent.android.js +11 -8
- package/lib/module/components/TabView/TabView.js +123 -0
- package/lib/module/components/TabView/TabViewItem.js +20 -0
- package/lib/module/components/TabView/index.js +2 -0
- package/lib/module/index.js +1 -0
- package/lib/module/mappings/TabView.js +70 -0
- package/lib/module/mappings/TabViewItem.js +30 -0
- package/lib/typescript/src/components/TabView/TabView.d.ts +26 -0
- package/lib/typescript/src/components/TabView/TabView.d.ts.map +1 -0
- package/lib/typescript/src/components/TabView/TabViewItem.d.ts +11 -0
- package/lib/typescript/src/components/TabView/TabViewItem.d.ts.map +1 -0
- package/lib/typescript/src/components/TabView/index.d.ts +3 -0
- package/lib/typescript/src/components/TabView/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mappings/TabView.d.ts +126 -0
- package/lib/typescript/src/mappings/TabView.d.ts.map +1 -0
- package/lib/typescript/src/mappings/TabViewItem.d.ts +25 -0
- package/lib/typescript/src/mappings/TabViewItem.d.ts.map +1 -0
- package/package.json +5 -4
- package/src/components/TabView/TabView.js +61 -0
- package/src/components/TabView/TabView.tsx +161 -0
- package/src/components/TabView/TabViewItem.js +11 -0
- package/src/components/TabView/TabViewItem.tsx +25 -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 +2 -0
- package/src/mappings/TabView.js +76 -0
- package/src/mappings/TabView.ts +86 -0
- package/src/mappings/TabViewItem.js +30 -0
- package/src/mappings/TabViewItem.ts +38 -0
- package/lib/commonjs/mappings/HtmlElements.js +0 -177
- package/lib/module/mappings/HtmlElements.js +0 -170
- package/lib/typescript/src/mappings/HtmlElements.d.ts +0 -77
- package/lib/typescript/src/mappings/HtmlElements.d.ts.map +0 -1
- package/src/mappings/HtmlElements.js +0 -193
- package/src/mappings/HtmlElements.ts +0 -207
|
@@ -12,7 +12,6 @@ var _theming = require("../../theming");
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
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); }
|
|
14
14
|
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; }
|
|
15
|
-
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); }
|
|
16
15
|
const AccordionItem = _ref => {
|
|
17
16
|
let {
|
|
18
17
|
Icon,
|
|
@@ -27,9 +26,10 @@ const AccordionItem = _ref => {
|
|
|
27
26
|
textStyles,
|
|
28
27
|
viewStyles
|
|
29
28
|
} = (0, _utilities.extractStyles)(style);
|
|
30
|
-
return /*#__PURE__*/React.createElement(_reactNative.Pressable,
|
|
31
|
-
style: [styles.container, viewStyles]
|
|
32
|
-
|
|
29
|
+
return /*#__PURE__*/React.createElement(_reactNative.Pressable, {
|
|
30
|
+
style: [styles.container, viewStyles],
|
|
31
|
+
...rest
|
|
32
|
+
}, /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
33
33
|
style: styles.row
|
|
34
34
|
}, icon ? /*#__PURE__*/React.createElement(Icon, {
|
|
35
35
|
name: icon,
|
|
@@ -61,4 +61,23 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
var _default = (0, _theming.withTheme)(AccordionItem);
|
|
64
|
+
exports.default = _default;.StyleSheet.create({
|
|
65
|
+
container: {
|
|
66
|
+
padding: 8
|
|
67
|
+
},
|
|
68
|
+
row: {
|
|
69
|
+
flexDirection: "row",
|
|
70
|
+
alignItems: "center",
|
|
71
|
+
paddingLeft: 8
|
|
72
|
+
},
|
|
73
|
+
item: {
|
|
74
|
+
marginVertical: 6,
|
|
75
|
+
paddingLeft: 8
|
|
76
|
+
},
|
|
77
|
+
content: {
|
|
78
|
+
flex: 1,
|
|
79
|
+
justifyContent: "center"
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
var _default = (0, _theming.withTheme)(AccordionItem);
|
|
64
83
|
exports.default = _default;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.radioButtonGroupContext = exports.Direction = void 0;
|
|
7
7
|
exports.useRadioButtonGroupContext = useRadioButtonGroupContext;
|
|
8
8
|
var _react = require("react");
|
|
9
|
-
|
|
9
|
+
let Direction;
|
|
10
10
|
exports.Direction = Direction;
|
|
11
11
|
(function (Direction) {
|
|
12
12
|
Direction["Horizontal"] = "horizontal";
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _reactNativeTabView = require("react-native-tab-view");
|
|
10
|
+
var _theming = require("../../theming");
|
|
11
|
+
var _utilities = require("../../utilities");
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
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); }
|
|
15
|
+
const TabViewComponent = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
Icon,
|
|
18
|
+
onIndexChanged,
|
|
19
|
+
onEndReached,
|
|
20
|
+
tabBarPosition,
|
|
21
|
+
keyboardDismissMode,
|
|
22
|
+
swipeEnabled,
|
|
23
|
+
scrollEnabled,
|
|
24
|
+
activeColor,
|
|
25
|
+
inactiveColor,
|
|
26
|
+
pressColor,
|
|
27
|
+
indicatorColor,
|
|
28
|
+
tabsBackgroundColor,
|
|
29
|
+
style,
|
|
30
|
+
theme,
|
|
31
|
+
children
|
|
32
|
+
} = _ref;
|
|
33
|
+
const [index, setIndex] = React.useState(0);
|
|
34
|
+
const [routes, setRoutes] = React.useState([]);
|
|
35
|
+
const [tabScenes, setTabScenes] = React.useState({});
|
|
36
|
+
const {
|
|
37
|
+
textStyles,
|
|
38
|
+
viewStyles
|
|
39
|
+
} = (0, _utilities.extractStyles)(style);
|
|
40
|
+
|
|
41
|
+
//Check type of child using props
|
|
42
|
+
//Regular '.type' cannot work because Draftbit strips the type in Draft view
|
|
43
|
+
const instanceOfTabViewItemProps = object => {
|
|
44
|
+
return "title" in object;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
//Populate routes and scenes based on children
|
|
48
|
+
React.useEffect(() => {
|
|
49
|
+
const newRoutes = [];
|
|
50
|
+
const scenes = {};
|
|
51
|
+
React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && instanceOfTabViewItemProps(child.props)).forEach((item, idx) => {
|
|
52
|
+
const child = item;
|
|
53
|
+
newRoutes.push({
|
|
54
|
+
key: idx.toString(),
|
|
55
|
+
title: child.props.title,
|
|
56
|
+
icon: child.props.icon,
|
|
57
|
+
accessibilityLabel: child.props.accessibilityLabel
|
|
58
|
+
});
|
|
59
|
+
scenes[idx] = () => child;
|
|
60
|
+
});
|
|
61
|
+
setRoutes(newRoutes);
|
|
62
|
+
setTabScenes(scenes);
|
|
63
|
+
}, [children]);
|
|
64
|
+
const indexChangeHandler = i => {
|
|
65
|
+
setIndex(i);
|
|
66
|
+
onIndexChanged === null || onIndexChanged === void 0 ? void 0 : onIndexChanged(i);
|
|
67
|
+
if (i === routes.length) {
|
|
68
|
+
onEndReached === null || onEndReached === void 0 ? void 0 : onEndReached();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const renderTabBar = props => {
|
|
72
|
+
return /*#__PURE__*/React.createElement(_reactNativeTabView.TabBar, _extends({}, props, {
|
|
73
|
+
activeColor: activeColor || theme.colors.primary,
|
|
74
|
+
inactiveColor: inactiveColor || theme.colors.divider,
|
|
75
|
+
pressColor: pressColor || theme.colors.primary,
|
|
76
|
+
scrollEnabled: scrollEnabled,
|
|
77
|
+
indicatorStyle: {
|
|
78
|
+
backgroundColor: indicatorColor || theme.colors.primary
|
|
79
|
+
},
|
|
80
|
+
labelStyle: textStyles,
|
|
81
|
+
renderIcon: _ref2 => {
|
|
82
|
+
let {
|
|
83
|
+
route,
|
|
84
|
+
color
|
|
85
|
+
} = _ref2;
|
|
86
|
+
return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
|
|
87
|
+
style: styles.icon,
|
|
88
|
+
name: route.icon,
|
|
89
|
+
color: color,
|
|
90
|
+
size: 16
|
|
91
|
+
}) : null;
|
|
92
|
+
},
|
|
93
|
+
style: {
|
|
94
|
+
backgroundColor: tabsBackgroundColor || theme.colors.background
|
|
95
|
+
},
|
|
96
|
+
contentContainerStyle: styles.tabBarContainer
|
|
97
|
+
}));
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
//Cannot render TabView without at least one tab
|
|
101
|
+
if (!routes.length) {
|
|
102
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
103
|
+
}
|
|
104
|
+
return /*#__PURE__*/React.createElement(_reactNativeTabView.TabView, {
|
|
105
|
+
style: [styles.tabView, viewStyles],
|
|
106
|
+
navigationState: {
|
|
107
|
+
index,
|
|
108
|
+
routes
|
|
109
|
+
},
|
|
110
|
+
renderScene: (0, _reactNativeTabView.SceneMap)(tabScenes),
|
|
111
|
+
renderTabBar: renderTabBar,
|
|
112
|
+
onIndexChange: indexChangeHandler,
|
|
113
|
+
tabBarPosition: tabBarPosition,
|
|
114
|
+
keyboardDismissMode: keyboardDismissMode,
|
|
115
|
+
swipeEnabled: swipeEnabled
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
const styles = _reactNative.StyleSheet.create({
|
|
119
|
+
tabView: {
|
|
120
|
+
flex: 1
|
|
121
|
+
},
|
|
122
|
+
//Prevent height of bar from filling container
|
|
123
|
+
tabBarContainer: {
|
|
124
|
+
flex: undefined
|
|
125
|
+
},
|
|
126
|
+
icon: {
|
|
127
|
+
width: 16,
|
|
128
|
+
height: 16
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
var _default = (0, _theming.withTheme)(TabViewComponent);
|
|
132
|
+
exports.default = _default;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
const TabViewItem = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
style,
|
|
13
|
+
children
|
|
14
|
+
} = _ref;
|
|
15
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
16
|
+
style: [styles.parentContainer, style]
|
|
17
|
+
}, children);
|
|
18
|
+
};
|
|
19
|
+
const styles = _reactNative.StyleSheet.create({
|
|
20
|
+
parentContainer: {
|
|
21
|
+
flex: 1
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var _default = TabViewItem;
|
|
25
|
+
exports.default = _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
var _TabView = _interopRequireDefault(require("./TabView"));
|
|
19
|
+
var _TabViewItem = _interopRequireDefault(require("./TabViewItem"));
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -11,6 +11,7 @@ var _IconButton = _interopRequireDefault(require("./IconButton"));
|
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
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); }
|
|
13
13
|
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; }
|
|
14
|
+
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); }
|
|
14
15
|
const ToggleButton = _ref => {
|
|
15
16
|
let {
|
|
16
17
|
Icon,
|
|
@@ -46,7 +47,7 @@ const ToggleButton = _ref => {
|
|
|
46
47
|
setInternalValue(!internalValue);
|
|
47
48
|
onPress(!internalValue);
|
|
48
49
|
};
|
|
49
|
-
return /*#__PURE__*/React.createElement(_IconButton.default, {
|
|
50
|
+
return /*#__PURE__*/React.createElement(_IconButton.default, _extends({
|
|
50
51
|
Icon: Icon,
|
|
51
52
|
icon: icon,
|
|
52
53
|
size: iconSize,
|
|
@@ -58,20 +59,6 @@ const ToggleButton = _ref => {
|
|
|
58
59
|
height,
|
|
59
60
|
backgroundColor: internalValue ? colors[colorSecondary] : colors[color],
|
|
60
61
|
borderColor: colors[borderColor]
|
|
61
|
-
}, style],
|
|
62
|
-
...rest
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
const styles = _reactNative.StyleSheet.create({
|
|
66
|
-
mainContainer: {
|
|
67
|
-
borderWidth: 1
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
var _default = (0, _theming.withTheme)(ToggleButton);
|
|
71
|
-
exports.default = _default;idth,
|
|
72
|
-
height,
|
|
73
|
-
backgroundColor: internalValue ? colors[colorSecondary] : colors[color],
|
|
74
|
-
borderColor: colors[borderColor]
|
|
75
62
|
}, style]
|
|
76
63
|
}, rest));
|
|
77
64
|
};
|
package/lib/commonjs/hooks.js
CHANGED
|
@@ -10,11 +10,12 @@ function usePrevious(value) {
|
|
|
10
10
|
// The ref object is a generic container whose current property is mutable
|
|
11
11
|
// and can hold any value, similar to an instance property on a class
|
|
12
12
|
const ref = _react.default.useRef();
|
|
13
|
+
|
|
13
14
|
// Store current value in ref
|
|
14
15
|
_react.default.useEffect(() => {
|
|
15
16
|
ref.current = value;
|
|
16
17
|
}, [value]);
|
|
18
|
+
|
|
17
19
|
// Return previous value (happens before update in useEffect above)
|
|
18
20
|
return ref.current;
|
|
19
|
-
}
|
|
20
21
|
}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -339,6 +339,18 @@ Object.defineProperty(exports, "SwitchRow", {
|
|
|
339
339
|
return _Switch.SwitchRow;
|
|
340
340
|
}
|
|
341
341
|
});
|
|
342
|
+
Object.defineProperty(exports, "TabView", {
|
|
343
|
+
enumerable: true,
|
|
344
|
+
get: function () {
|
|
345
|
+
return _TabView.TabView;
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
Object.defineProperty(exports, "TabViewItem", {
|
|
349
|
+
enumerable: true,
|
|
350
|
+
get: function () {
|
|
351
|
+
return _TabView.TabViewItem;
|
|
352
|
+
}
|
|
353
|
+
});
|
|
342
354
|
Object.defineProperty(exports, "TextField", {
|
|
343
355
|
enumerable: true,
|
|
344
356
|
get: function () {
|
|
@@ -414,6 +426,7 @@ var _Swiper = require("./components/Swiper");
|
|
|
414
426
|
var _Layout = require("./components/Layout");
|
|
415
427
|
var _index = require("./components/RadioButton/index");
|
|
416
428
|
var _DeckSwiper = require("./components/DeckSwiper");
|
|
429
|
+
var _TabView = require("./components/TabView");
|
|
417
430
|
var _DatePicker = _interopRequireDefault(require("./components/DatePicker/DatePicker"));
|
|
418
431
|
var _Picker = _interopRequireDefault(require("./components/Picker/Picker"));
|
|
419
432
|
var _ProgressBar = _interopRequireDefault(require("./components/ProgressBar"));
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SEED_DATA = void 0;
|
|
7
|
+
var _types = require("@draftbit/types");
|
|
8
|
+
const SEED_DATA = {
|
|
9
|
+
name: "Tab View",
|
|
10
|
+
tag: "TabView",
|
|
11
|
+
description: "Tab view container",
|
|
12
|
+
category: _types.COMPONENT_TYPES.swiper,
|
|
13
|
+
stylesPanelSections: [_types.StylesPanelSections.Size, _types.StylesPanelSections.MarginsAndPaddings, _types.StylesPanelSections.Position, _types.StylesPanelSections.Effects, _types.StylesPanelSections.LayoutSelectedItem, _types.StylesPanelSections.Background, _types.StylesPanelSections.Typography],
|
|
14
|
+
layout: {
|
|
15
|
+
flex: 1
|
|
16
|
+
},
|
|
17
|
+
triggers: [_types.Triggers.OnIndexChanged, _types.Triggers.OnEndReached],
|
|
18
|
+
props: {
|
|
19
|
+
onIndexChanged: (0, _types.createActionProp)({
|
|
20
|
+
label: "On index changed",
|
|
21
|
+
description: "Action to execute when swipe to new index"
|
|
22
|
+
}),
|
|
23
|
+
onEndReached: (0, _types.createActionProp)({
|
|
24
|
+
label: "On end reached",
|
|
25
|
+
description: "Action to execute when end of swiping reached"
|
|
26
|
+
}),
|
|
27
|
+
tabBarPosition: (0, _types.createTextEnumProp)({
|
|
28
|
+
label: "Tab Bar Position",
|
|
29
|
+
description: "Position of tab bar",
|
|
30
|
+
options: ["top", "bottom"],
|
|
31
|
+
defaultValue: "top"
|
|
32
|
+
}),
|
|
33
|
+
keyboardDismissMode: (0, _types.createTextEnumProp)({
|
|
34
|
+
label: "Keyboard Dismiss Mode",
|
|
35
|
+
description: "Keyboard Dismiss Mode",
|
|
36
|
+
options: ["auto", "on-drag", "none"],
|
|
37
|
+
defaultValue: "auto"
|
|
38
|
+
}),
|
|
39
|
+
swipeEnabled: (0, _types.createStaticBoolProp)({
|
|
40
|
+
label: "Swipe Enabled",
|
|
41
|
+
description: "Whether swiping is enabled or not",
|
|
42
|
+
defaultValue: true
|
|
43
|
+
}),
|
|
44
|
+
scrollEnabled: (0, _types.createStaticBoolProp)({
|
|
45
|
+
label: "Tab Scroll Enabled",
|
|
46
|
+
description: "Whether scrolling of tabs is enabled or not",
|
|
47
|
+
defaultValue: false
|
|
48
|
+
}),
|
|
49
|
+
activeColor: (0, _types.createColorProp)({
|
|
50
|
+
label: "Active Color",
|
|
51
|
+
description: "Color of icon and text of active tab",
|
|
52
|
+
defaultValue: "primary"
|
|
53
|
+
}),
|
|
54
|
+
inactiveColor: (0, _types.createColorProp)({
|
|
55
|
+
label: "Inactive Color",
|
|
56
|
+
description: "Color of icon and text of inactive tab(s)",
|
|
57
|
+
defaultValue: null
|
|
58
|
+
}),
|
|
59
|
+
pressColor: (0, _types.createColorProp)({
|
|
60
|
+
label: "Press Color",
|
|
61
|
+
description: "Color of ripple when pressed",
|
|
62
|
+
defaultValue: "primary",
|
|
63
|
+
group: _types.GROUPS.android
|
|
64
|
+
}),
|
|
65
|
+
indicatorColor: (0, _types.createColorProp)({
|
|
66
|
+
label: "Indicator Color",
|
|
67
|
+
description: "Color of indicator",
|
|
68
|
+
defaultValue: "primary"
|
|
69
|
+
}),
|
|
70
|
+
tabsBackgroundColor: (0, _types.createColorProp)({
|
|
71
|
+
label: "Tabs Background Color",
|
|
72
|
+
description: "Background color of tabs container",
|
|
73
|
+
defaultValue: "background"
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
exports.SEED_DATA = SEED_DATA;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SEED_DATA = void 0;
|
|
7
|
+
var _types = require("@draftbit/types");
|
|
8
|
+
const SEED_DATA = {
|
|
9
|
+
name: "Tab View Item",
|
|
10
|
+
tag: "TabViewItem",
|
|
11
|
+
description: "Single Tab View item to be used in TabView. Each item represents a single tab and its content",
|
|
12
|
+
category: _types.COMPONENT_TYPES.swiper,
|
|
13
|
+
stylesPanelSections: _types.CONTAINER_COMPONENT_STYLES_SECTIONS,
|
|
14
|
+
layout: {
|
|
15
|
+
flex: 1
|
|
16
|
+
},
|
|
17
|
+
props: {
|
|
18
|
+
title: (0, _types.createTextProp)({
|
|
19
|
+
label: "Title",
|
|
20
|
+
description: "Title of tab item",
|
|
21
|
+
defaultValue: "Title",
|
|
22
|
+
required: true,
|
|
23
|
+
group: _types.GROUPS.basic
|
|
24
|
+
}),
|
|
25
|
+
icon: (0, _types.createIconProp)({
|
|
26
|
+
defaultValue: null,
|
|
27
|
+
required: false
|
|
28
|
+
}),
|
|
29
|
+
accessibilityLabel: (0, _types.createTextProp)({
|
|
30
|
+
label: "Accessibility Label",
|
|
31
|
+
description: "Accessibility Label",
|
|
32
|
+
defaultValue: null,
|
|
33
|
+
group: _types.GROUPS.accessibility
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.SEED_DATA = SEED_DATA;
|
|
@@ -1,3 +1,4 @@
|
|
|
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); }
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
import { View, StyleSheet } from "react-native";
|
|
3
4
|
import omit from "lodash.omit";
|
|
@@ -7,6 +8,7 @@ import { extractStyles } from "../../utilities";
|
|
|
7
8
|
import TextField from "../TextField";
|
|
8
9
|
import Touchable from "../Touchable";
|
|
9
10
|
const Picker = _ref => {
|
|
11
|
+
var _options$find$label, _options$find;
|
|
10
12
|
let {
|
|
11
13
|
style,
|
|
12
14
|
options,
|
|
@@ -16,7 +18,6 @@ const Picker = _ref => {
|
|
|
16
18
|
onValueChange: onValueChangeOverride = () => {},
|
|
17
19
|
...props
|
|
18
20
|
} = _ref;
|
|
19
|
-
var _a, _b;
|
|
20
21
|
const {
|
|
21
22
|
viewStyles: {
|
|
22
23
|
borderRadius,
|
|
@@ -61,7 +62,7 @@ const Picker = _ref => {
|
|
|
61
62
|
};
|
|
62
63
|
|
|
63
64
|
const stylesWithoutMargin = style && omit(StyleSheet.flatten(style), ["margin", "marginTop", "marginRight", "marginBottom", "marginLeft"]);
|
|
64
|
-
const selectedLabel = selectedValue && ((
|
|
65
|
+
const selectedLabel = selectedValue && ((_options$find$label = (_options$find = options.find(o => o.value === selectedValue)) === null || _options$find === void 0 ? void 0 : _options$find.label) !== null && _options$find$label !== void 0 ? _options$find$label : selectedValue);
|
|
65
66
|
return /*#__PURE__*/React.createElement(Touchable, {
|
|
66
67
|
disabled: disabled,
|
|
67
68
|
onPress: toggleFocus,
|
|
@@ -85,16 +86,18 @@ const Picker = _ref => {
|
|
|
85
86
|
key: o.value
|
|
86
87
|
}))), /*#__PURE__*/React.createElement(View, {
|
|
87
88
|
pointerEvents: "none"
|
|
88
|
-
}, /*#__PURE__*/React.createElement(TextField, {
|
|
89
|
-
...props,
|
|
89
|
+
}, /*#__PURE__*/React.createElement(TextField, _extends({}, props, {
|
|
90
90
|
value: selectedLabel,
|
|
91
|
-
placeholder: placeholder
|
|
91
|
+
placeholder: placeholder
|
|
92
92
|
// @ts-ignore
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
,
|
|
94
|
+
ref: textField // cannot determine if ref is of correct type due to component being wrapped in a withTheme()
|
|
95
|
+
,
|
|
96
|
+
disabled: disabled
|
|
95
97
|
// @ts-expect-error
|
|
98
|
+
,
|
|
96
99
|
style: stylesWithoutMargin
|
|
97
|
-
}))));
|
|
100
|
+
})))));
|
|
98
101
|
};
|
|
99
102
|
const styles = StyleSheet.create({
|
|
100
103
|
container: {
|
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
import * as React from "react";
|
|
3
|
+
import { StyleSheet } from "react-native";
|
|
4
|
+
import { TabView, TabBar, SceneMap } from "react-native-tab-view";
|
|
5
|
+
import { withTheme } from "../../theming";
|
|
6
|
+
import { extractStyles } from "../../utilities";
|
|
7
|
+
const TabViewComponent = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
Icon,
|
|
10
|
+
onIndexChanged,
|
|
11
|
+
onEndReached,
|
|
12
|
+
tabBarPosition,
|
|
13
|
+
keyboardDismissMode,
|
|
14
|
+
swipeEnabled,
|
|
15
|
+
scrollEnabled,
|
|
16
|
+
activeColor,
|
|
17
|
+
inactiveColor,
|
|
18
|
+
pressColor,
|
|
19
|
+
indicatorColor,
|
|
20
|
+
tabsBackgroundColor,
|
|
21
|
+
style,
|
|
22
|
+
theme,
|
|
23
|
+
children
|
|
24
|
+
} = _ref;
|
|
25
|
+
const [index, setIndex] = React.useState(0);
|
|
26
|
+
const [routes, setRoutes] = React.useState([]);
|
|
27
|
+
const [tabScenes, setTabScenes] = React.useState({});
|
|
28
|
+
const {
|
|
29
|
+
textStyles,
|
|
30
|
+
viewStyles
|
|
31
|
+
} = extractStyles(style);
|
|
32
|
+
|
|
33
|
+
//Check type of child using props
|
|
34
|
+
//Regular '.type' cannot work because Draftbit strips the type in Draft view
|
|
35
|
+
const instanceOfTabViewItemProps = object => {
|
|
36
|
+
return "title" in object;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//Populate routes and scenes based on children
|
|
40
|
+
React.useEffect(() => {
|
|
41
|
+
const newRoutes = [];
|
|
42
|
+
const scenes = {};
|
|
43
|
+
React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && instanceOfTabViewItemProps(child.props)).forEach((item, idx) => {
|
|
44
|
+
const child = item;
|
|
45
|
+
newRoutes.push({
|
|
46
|
+
key: idx.toString(),
|
|
47
|
+
title: child.props.title,
|
|
48
|
+
icon: child.props.icon,
|
|
49
|
+
accessibilityLabel: child.props.accessibilityLabel
|
|
50
|
+
});
|
|
51
|
+
scenes[idx] = () => child;
|
|
52
|
+
});
|
|
53
|
+
setRoutes(newRoutes);
|
|
54
|
+
setTabScenes(scenes);
|
|
55
|
+
}, [children]);
|
|
56
|
+
const indexChangeHandler = i => {
|
|
57
|
+
setIndex(i);
|
|
58
|
+
onIndexChanged === null || onIndexChanged === void 0 ? void 0 : onIndexChanged(i);
|
|
59
|
+
if (i === routes.length) {
|
|
60
|
+
onEndReached === null || onEndReached === void 0 ? void 0 : onEndReached();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const renderTabBar = props => {
|
|
64
|
+
return /*#__PURE__*/React.createElement(TabBar, _extends({}, props, {
|
|
65
|
+
activeColor: activeColor || theme.colors.primary,
|
|
66
|
+
inactiveColor: inactiveColor || theme.colors.divider,
|
|
67
|
+
pressColor: pressColor || theme.colors.primary,
|
|
68
|
+
scrollEnabled: scrollEnabled,
|
|
69
|
+
indicatorStyle: {
|
|
70
|
+
backgroundColor: indicatorColor || theme.colors.primary
|
|
71
|
+
},
|
|
72
|
+
labelStyle: textStyles,
|
|
73
|
+
renderIcon: _ref2 => {
|
|
74
|
+
let {
|
|
75
|
+
route,
|
|
76
|
+
color
|
|
77
|
+
} = _ref2;
|
|
78
|
+
return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
|
|
79
|
+
style: styles.icon,
|
|
80
|
+
name: route.icon,
|
|
81
|
+
color: color,
|
|
82
|
+
size: 16
|
|
83
|
+
}) : null;
|
|
84
|
+
},
|
|
85
|
+
style: {
|
|
86
|
+
backgroundColor: tabsBackgroundColor || theme.colors.background
|
|
87
|
+
},
|
|
88
|
+
contentContainerStyle: styles.tabBarContainer
|
|
89
|
+
}));
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
//Cannot render TabView without at least one tab
|
|
93
|
+
if (!routes.length) {
|
|
94
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
95
|
+
}
|
|
96
|
+
return /*#__PURE__*/React.createElement(TabView, {
|
|
97
|
+
style: [styles.tabView, viewStyles],
|
|
98
|
+
navigationState: {
|
|
99
|
+
index,
|
|
100
|
+
routes
|
|
101
|
+
},
|
|
102
|
+
renderScene: SceneMap(tabScenes),
|
|
103
|
+
renderTabBar: renderTabBar,
|
|
104
|
+
onIndexChange: indexChangeHandler,
|
|
105
|
+
tabBarPosition: tabBarPosition,
|
|
106
|
+
keyboardDismissMode: keyboardDismissMode,
|
|
107
|
+
swipeEnabled: swipeEnabled
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
const styles = StyleSheet.create({
|
|
111
|
+
tabView: {
|
|
112
|
+
flex: 1
|
|
113
|
+
},
|
|
114
|
+
//Prevent height of bar from filling container
|
|
115
|
+
tabBarContainer: {
|
|
116
|
+
flex: undefined
|
|
117
|
+
},
|
|
118
|
+
icon: {
|
|
119
|
+
width: 16,
|
|
120
|
+
height: 16
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
export default withTheme(TabViewComponent);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleSheet, View } from "react-native";
|
|
3
|
+
|
|
4
|
+
//Props used by parent (TabView) to create tabs
|
|
5
|
+
|
|
6
|
+
const TabViewItem = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
style,
|
|
9
|
+
children
|
|
10
|
+
} = _ref;
|
|
11
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
12
|
+
style: [styles.parentContainer, style]
|
|
13
|
+
}, children);
|
|
14
|
+
};
|
|
15
|
+
const styles = StyleSheet.create({
|
|
16
|
+
parentContainer: {
|
|
17
|
+
flex: 1
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
export default TabViewItem;
|
package/lib/module/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
|
|
|
36
37
|
/* Deprecated: Fix or Delete! */
|
|
37
38
|
export { default as DatePicker } from "./components/DatePicker/DatePicker";
|