@draftbit/core 46.8.2-799d91.2 → 46.8.2-81337b.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/DeprecatedCardWrapper.js +15 -1
- package/lib/commonjs/components/Image.js +2 -17
- package/lib/commonjs/components/Portal/PortalHost.js +15 -44
- package/lib/commonjs/components/ScreenContainer.js +6 -24
- package/lib/commonjs/components/TabView/TabView.js +100 -0
- package/lib/commonjs/components/TabView/TabViewItem.js +25 -0
- package/lib/commonjs/components/TabView/index.js +20 -0
- package/lib/commonjs/index.js +13 -7
- package/lib/commonjs/mappings/TabView.js +74 -0
- package/lib/commonjs/mappings/TabViewItem.js +37 -0
- package/lib/commonjs/styles/overlay.js +1 -3
- package/lib/commonjs/utilities.js +1 -2
- package/lib/module/components/TabView/TabView.js +90 -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 -1
- package/lib/module/mappings/TabView.js +67 -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 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mappings/TabView.d.ts +123 -0
- package/lib/typescript/src/mappings/TabView.d.ts.map +1 -0
- package/lib/typescript/src/mappings/{Markdown.d.ts → TabViewItem.d.ts} +10 -5
- package/lib/typescript/src/mappings/TabViewItem.d.ts.map +1 -0
- package/package.json +5 -4
- package/src/components/TabView/TabView.js +45 -0
- package/src/components/TabView/TabView.tsx +129 -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 -1
- package/src/index.tsx +1 -1
- package/src/mappings/TabView.js +70 -0
- package/src/mappings/TabView.ts +81 -0
- package/src/mappings/TabViewItem.js +30 -0
- package/src/mappings/TabViewItem.ts +38 -0
- package/lib/commonjs/components/Markdown.js +0 -30
- package/lib/commonjs/mappings/Markdown.js +0 -27
- package/lib/module/components/Markdown.js +0 -20
- package/lib/module/mappings/Markdown.js +0 -20
- package/lib/typescript/src/components/Markdown.d.ts +0 -8
- package/lib/typescript/src/components/Markdown.d.ts.map +0 -1
- package/lib/typescript/src/mappings/Markdown.d.ts.map +0 -1
- package/src/components/Markdown.js +0 -10
- package/src/components/Markdown.tsx +0 -22
- package/src/mappings/Markdown.js +0 -25
- package/src/mappings/Markdown.ts +0 -32
|
@@ -8,7 +8,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _theming = require("../theming");
|
|
9
9
|
var _Touchable = _interopRequireDefault(require("./Touchable"));
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
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); }
|
|
12
11
|
const getWidth = numColumns => {
|
|
13
12
|
switch (numColumns) {
|
|
14
13
|
case 1:
|
|
@@ -28,6 +27,21 @@ const Card = _ref => {
|
|
|
28
27
|
...rest
|
|
29
28
|
} = _ref;
|
|
30
29
|
const width = getWidth(numColumns);
|
|
30
|
+
return /*#__PURE__*/_react.default.createElement(_Touchable.default, {
|
|
31
|
+
disabled: !onPress,
|
|
32
|
+
onPress: onPress,
|
|
33
|
+
style: [style, {
|
|
34
|
+
width
|
|
35
|
+
}],
|
|
36
|
+
...rest
|
|
37
|
+
}, children);
|
|
38
|
+
};
|
|
39
|
+
var _default = (0, _theming.withTheme)(Card);
|
|
40
|
+
exports.default = _default;s,
|
|
41
|
+
style,
|
|
42
|
+
...rest
|
|
43
|
+
} = _ref;
|
|
44
|
+
const width = getWidth(numColumns);
|
|
31
45
|
return /*#__PURE__*/_react.default.createElement(_Touchable.default, _extends({
|
|
32
46
|
disabled: !onPress,
|
|
33
47
|
onPress: onPress,
|
|
@@ -9,8 +9,7 @@ var _reactNative = require("react-native");
|
|
|
9
9
|
var _Config = _interopRequireDefault(require("./Config"));
|
|
10
10
|
var _AspectRatio = _interopRequireDefault(require("./AspectRatio"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
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
13
|
const generateDimensions = _ref => {
|
|
15
14
|
let {
|
|
16
15
|
aspectRatio,
|
|
@@ -63,27 +62,13 @@ const Image = _ref2 => {
|
|
|
63
62
|
height,
|
|
64
63
|
aspectRatio
|
|
65
64
|
}]
|
|
66
|
-
}, /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
|
|
67
|
-
...props,
|
|
65
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNative.Image, _extends({}, props, {
|
|
68
66
|
source: imageSource,
|
|
69
67
|
resizeMode: resizeMode,
|
|
70
68
|
style: [style, {
|
|
71
69
|
height: "100%",
|
|
72
70
|
width: "100%"
|
|
73
71
|
}]
|
|
74
|
-
}));
|
|
75
|
-
}
|
|
76
|
-
return /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
|
|
77
|
-
...props,
|
|
78
|
-
source: source,
|
|
79
|
-
resizeMode: resizeMode,
|
|
80
|
-
style: style
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
var _default = Image;
|
|
84
|
-
exports.default = _default; "100%",
|
|
85
|
-
width: "100%"
|
|
86
|
-
}]
|
|
87
72
|
})));
|
|
88
73
|
}
|
|
89
74
|
return /*#__PURE__*/_react.default.createElement(_reactNative.Image, _extends({}, props, {
|
|
@@ -10,7 +10,11 @@ var _PortalManager = _interopRequireDefault(require("./PortalManager"));
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
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); }
|
|
12
12
|
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; }
|
|
13
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
15
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
16
|
const PortalContext = /*#__PURE__*/React.createContext(null);
|
|
17
|
+
|
|
14
18
|
/**
|
|
15
19
|
* Portal host renders all of its children `Portal` elements.
|
|
16
20
|
* For example, you can wrap a screen in `Portal.Host` to render items above the screen.
|
|
@@ -39,10 +43,10 @@ exports.PortalContext = PortalContext;
|
|
|
39
43
|
class PortalHost extends React.Component {
|
|
40
44
|
constructor() {
|
|
41
45
|
super(...arguments);
|
|
42
|
-
this
|
|
46
|
+
_defineProperty(this, "setManager", manager => {
|
|
43
47
|
this.manager = manager;
|
|
44
|
-
};
|
|
45
|
-
this
|
|
48
|
+
});
|
|
49
|
+
_defineProperty(this, "mount", children => {
|
|
46
50
|
const key = this.nextKey++;
|
|
47
51
|
if (this.manager) {
|
|
48
52
|
this.manager.mount(key, children);
|
|
@@ -54,8 +58,8 @@ class PortalHost extends React.Component {
|
|
|
54
58
|
});
|
|
55
59
|
}
|
|
56
60
|
return key;
|
|
57
|
-
};
|
|
58
|
-
this
|
|
61
|
+
});
|
|
62
|
+
_defineProperty(this, "update", (key, children) => {
|
|
59
63
|
if (this.manager) {
|
|
60
64
|
this.manager.update(key, children);
|
|
61
65
|
} else {
|
|
@@ -72,8 +76,8 @@ class PortalHost extends React.Component {
|
|
|
72
76
|
this.queue.push(op);
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
|
-
};
|
|
76
|
-
this
|
|
79
|
+
});
|
|
80
|
+
_defineProperty(this, "unmount", key => {
|
|
77
81
|
if (this.manager) {
|
|
78
82
|
this.manager.unmount(key);
|
|
79
83
|
} else {
|
|
@@ -82,9 +86,10 @@ class PortalHost extends React.Component {
|
|
|
82
86
|
key
|
|
83
87
|
});
|
|
84
88
|
}
|
|
85
|
-
};
|
|
86
|
-
this
|
|
87
|
-
this
|
|
89
|
+
});
|
|
90
|
+
_defineProperty(this, "nextKey", 0);
|
|
91
|
+
_defineProperty(this, "queue", []);
|
|
92
|
+
_defineProperty(this, "manager", void 0);
|
|
88
93
|
}
|
|
89
94
|
componentDidMount() {
|
|
90
95
|
const manager = this.manager;
|
|
@@ -123,40 +128,6 @@ class PortalHost extends React.Component {
|
|
|
123
128
|
}
|
|
124
129
|
}
|
|
125
130
|
exports.default = PortalHost;
|
|
126
|
-
PortalHost.displayName = "Portal.Host";
|
|
127
|
-
const styles = _reactNative.StyleSheet.create({
|
|
128
|
-
container: {
|
|
129
|
-
flex: 1
|
|
130
|
-
}
|
|
131
|
-
});nager.mount(action.key, action.children);
|
|
132
|
-
break;
|
|
133
|
-
case "update":
|
|
134
|
-
manager.update(action.key, action.children);
|
|
135
|
-
break;
|
|
136
|
-
case "unmount":
|
|
137
|
-
manager.unmount(action.key);
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
render() {
|
|
144
|
-
return /*#__PURE__*/React.createElement(PortalContext.Provider, {
|
|
145
|
-
value: {
|
|
146
|
-
mount: this.mount,
|
|
147
|
-
update: this.update,
|
|
148
|
-
unmount: this.unmount
|
|
149
|
-
}
|
|
150
|
-
}, /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
151
|
-
style: styles.container,
|
|
152
|
-
collapsable: false,
|
|
153
|
-
pointerEvents: "box-none"
|
|
154
|
-
}, this.props.children), /*#__PURE__*/React.createElement(_PortalManager.default, {
|
|
155
|
-
ref: this.setManager
|
|
156
|
-
}));
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
exports.default = PortalHost;
|
|
160
131
|
_defineProperty(PortalHost, "displayName", "Portal.Host");
|
|
161
132
|
const styles = _reactNative.StyleSheet.create({
|
|
162
133
|
container: {
|
|
@@ -10,7 +10,9 @@ var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
|
|
|
10
10
|
var _theming = require("../theming");
|
|
11
11
|
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); }
|
|
12
12
|
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; }
|
|
13
|
+
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); }
|
|
13
14
|
function ScreenContainer(_ref) {
|
|
15
|
+
var _StyleSheet$flatten;
|
|
14
16
|
let {
|
|
15
17
|
scrollable = false,
|
|
16
18
|
hasSafeArea = false,
|
|
@@ -21,8 +23,7 @@ function ScreenContainer(_ref) {
|
|
|
21
23
|
children,
|
|
22
24
|
...rest
|
|
23
25
|
} = _ref;
|
|
24
|
-
|
|
25
|
-
const backgroundColor = ((_a = _reactNative.StyleSheet.flatten(style)) === null || _a === void 0 ? void 0 : _a.backgroundColor) || theme.colors.background;
|
|
26
|
+
const backgroundColor = ((_StyleSheet$flatten = _reactNative.StyleSheet.flatten(style)) === null || _StyleSheet$flatten === void 0 ? void 0 : _StyleSheet$flatten.backgroundColor) || theme.colors.background;
|
|
26
27
|
const edges = ["left", "right"];
|
|
27
28
|
if (hasSafeArea || hasTopSafeArea) {
|
|
28
29
|
edges.push("top");
|
|
@@ -30,13 +31,12 @@ function ScreenContainer(_ref) {
|
|
|
30
31
|
if (hasSafeArea || hasBottomSafeArea) {
|
|
31
32
|
edges.push("bottom");
|
|
32
33
|
}
|
|
33
|
-
return /*#__PURE__*/React.createElement(_reactNativeSafeAreaContext.SafeAreaView, {
|
|
34
|
+
return /*#__PURE__*/React.createElement(_reactNativeSafeAreaContext.SafeAreaView, _extends({
|
|
34
35
|
edges: edges,
|
|
35
36
|
style: [styles.container, {
|
|
36
37
|
backgroundColor
|
|
37
|
-
}]
|
|
38
|
-
|
|
39
|
-
}, scrollable ? /*#__PURE__*/React.createElement(_reactNative.ScrollView, {
|
|
38
|
+
}]
|
|
39
|
+
}, rest), scrollable ? /*#__PURE__*/React.createElement(_reactNative.ScrollView, {
|
|
40
40
|
contentContainerStyle: [styles.scrollViewContainer, {
|
|
41
41
|
backgroundColor
|
|
42
42
|
}, style]
|
|
@@ -56,22 +56,4 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
var _default = (0, _theming.withTheme)(ScreenContainer);
|
|
59
|
-
exports.default = _default;olor
|
|
60
|
-
}, style]
|
|
61
|
-
}, children) : /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
62
|
-
style: [styles.container, {
|
|
63
|
-
backgroundColor
|
|
64
|
-
}, style]
|
|
65
|
-
}, children));
|
|
66
|
-
}
|
|
67
|
-
const styles = _reactNative.StyleSheet.create({
|
|
68
|
-
container: {
|
|
69
|
-
flex: 1
|
|
70
|
-
},
|
|
71
|
-
scrollViewContainer: {
|
|
72
|
-
flexGrow: 1,
|
|
73
|
-
flex: undefined
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
var _default = (0, _theming.withTheme)(ScreenContainer);
|
|
77
59
|
exports.default = _default;
|
|
@@ -0,0 +1,100 @@
|
|
|
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 _reactNativeTabView = require("react-native-tab-view");
|
|
9
|
+
var _TabViewItem = _interopRequireDefault(require("./TabViewItem"));
|
|
10
|
+
var _theming = require("../../theming");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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
|
+
|
|
37
|
+
//Populate routes and scenes based on children
|
|
38
|
+
React.useEffect(() => {
|
|
39
|
+
const newRoutes = [];
|
|
40
|
+
const scenes = {};
|
|
41
|
+
React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && child.type === _TabViewItem.default).forEach((item, idx) => {
|
|
42
|
+
const child = item;
|
|
43
|
+
newRoutes.push({
|
|
44
|
+
key: idx.toString(),
|
|
45
|
+
title: child.props.title,
|
|
46
|
+
icon: child.props.icon,
|
|
47
|
+
accessibilityLabel: child.props.accessibilityLabel
|
|
48
|
+
});
|
|
49
|
+
scenes[idx] = () => child;
|
|
50
|
+
});
|
|
51
|
+
setRoutes(newRoutes);
|
|
52
|
+
setTabScenes(scenes);
|
|
53
|
+
}, [children]);
|
|
54
|
+
const indexChangeHandler = i => {
|
|
55
|
+
setIndex(i);
|
|
56
|
+
onIndexChanged === null || onIndexChanged === void 0 ? void 0 : onIndexChanged(i);
|
|
57
|
+
if (i === routes.length) {
|
|
58
|
+
onEndReached === null || onEndReached === void 0 ? void 0 : onEndReached();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const renderTabBar = props => {
|
|
62
|
+
return /*#__PURE__*/React.createElement(_reactNativeTabView.TabBar, _extends({}, props, {
|
|
63
|
+
activeColor: activeColor || theme.colors.primary,
|
|
64
|
+
inactiveColor: inactiveColor || theme.colors.divider,
|
|
65
|
+
pressColor: pressColor || theme.colors.primary,
|
|
66
|
+
scrollEnabled: scrollEnabled,
|
|
67
|
+
indicatorStyle: {
|
|
68
|
+
backgroundColor: indicatorColor || theme.colors.primary
|
|
69
|
+
},
|
|
70
|
+
renderIcon: _ref2 => {
|
|
71
|
+
let {
|
|
72
|
+
route,
|
|
73
|
+
color
|
|
74
|
+
} = _ref2;
|
|
75
|
+
return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
|
|
76
|
+
name: route.icon,
|
|
77
|
+
color: color,
|
|
78
|
+
size: 36
|
|
79
|
+
}) : null;
|
|
80
|
+
},
|
|
81
|
+
style: [{
|
|
82
|
+
backgroundColor: tabsBackgroundColor || theme.colors.background
|
|
83
|
+
}, style]
|
|
84
|
+
}));
|
|
85
|
+
};
|
|
86
|
+
return /*#__PURE__*/React.createElement(_reactNativeTabView.TabView, {
|
|
87
|
+
navigationState: {
|
|
88
|
+
index,
|
|
89
|
+
routes
|
|
90
|
+
},
|
|
91
|
+
renderScene: (0, _reactNativeTabView.SceneMap)(tabScenes),
|
|
92
|
+
renderTabBar: renderTabBar,
|
|
93
|
+
onIndexChange: indexChangeHandler,
|
|
94
|
+
tabBarPosition: tabBarPosition,
|
|
95
|
+
keyboardDismissMode: keyboardDismissMode,
|
|
96
|
+
swipeEnabled: swipeEnabled
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
var _default = (0, _theming.withTheme)(TabViewComponent);
|
|
100
|
+
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 }; }
|
package/lib/commonjs/index.js
CHANGED
|
@@ -177,12 +177,6 @@ Object.defineProperty(exports, "Link", {
|
|
|
177
177
|
return _Text.Link;
|
|
178
178
|
}
|
|
179
179
|
});
|
|
180
|
-
Object.defineProperty(exports, "Markdown", {
|
|
181
|
-
enumerable: true,
|
|
182
|
-
get: function () {
|
|
183
|
-
return _Markdown.default;
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
180
|
Object.defineProperty(exports, "NumberInput", {
|
|
187
181
|
enumerable: true,
|
|
188
182
|
get: function () {
|
|
@@ -345,6 +339,18 @@ Object.defineProperty(exports, "SwitchRow", {
|
|
|
345
339
|
return _Switch.SwitchRow;
|
|
346
340
|
}
|
|
347
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
|
+
});
|
|
348
354
|
Object.defineProperty(exports, "TextField", {
|
|
349
355
|
enumerable: true,
|
|
350
356
|
get: function () {
|
|
@@ -420,7 +426,7 @@ var _Swiper = require("./components/Swiper");
|
|
|
420
426
|
var _Layout = require("./components/Layout");
|
|
421
427
|
var _index = require("./components/RadioButton/index");
|
|
422
428
|
var _DeckSwiper = require("./components/DeckSwiper");
|
|
423
|
-
var
|
|
429
|
+
var _TabView = require("./components/TabView");
|
|
424
430
|
var _DatePicker = _interopRequireDefault(require("./components/DatePicker/DatePicker"));
|
|
425
431
|
var _Picker = _interopRequireDefault(require("./components/Picker/Picker"));
|
|
426
432
|
var _ProgressBar = _interopRequireDefault(require("./components/ProgressBar"));
|
|
@@ -0,0 +1,74 @@
|
|
|
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.BLOCK_STYLES_SECTIONS, _types.StylesPanelSections.Background],
|
|
14
|
+
triggers: [_types.Triggers.OnIndexChanged, _types.Triggers.OnEndReached],
|
|
15
|
+
props: {
|
|
16
|
+
onIndexChanged: (0, _types.createActionProp)({
|
|
17
|
+
label: "On index changed",
|
|
18
|
+
description: "Action to execute when swipe to new index"
|
|
19
|
+
}),
|
|
20
|
+
onEndReached: (0, _types.createActionProp)({
|
|
21
|
+
label: "On end reached",
|
|
22
|
+
description: "Action to execute when end of swiping reached"
|
|
23
|
+
}),
|
|
24
|
+
tabBarPosition: (0, _types.createTextEnumProp)({
|
|
25
|
+
label: "Tab Bar Position",
|
|
26
|
+
description: "Position of tab bar",
|
|
27
|
+
options: ["top", "bottom"],
|
|
28
|
+
defaultValue: "top"
|
|
29
|
+
}),
|
|
30
|
+
keyboardDismissMode: (0, _types.createTextEnumProp)({
|
|
31
|
+
label: "Keyboard Dismiss Mode",
|
|
32
|
+
description: "Keyboard Dismiss Mode",
|
|
33
|
+
options: ["auto", "on-drag", "none"],
|
|
34
|
+
defaultValue: "auto"
|
|
35
|
+
}),
|
|
36
|
+
swipeEnabled: (0, _types.createStaticBoolProp)({
|
|
37
|
+
label: "Swipe Enabled",
|
|
38
|
+
description: "Whether swiping is enabled or not",
|
|
39
|
+
defaultValue: true
|
|
40
|
+
}),
|
|
41
|
+
scrollEnabled: (0, _types.createStaticBoolProp)({
|
|
42
|
+
label: "Scroll Enabled",
|
|
43
|
+
description: "Whether scrolling of tabs is enabled or not",
|
|
44
|
+
defaultValue: false
|
|
45
|
+
}),
|
|
46
|
+
activeColor: (0, _types.createColorProp)({
|
|
47
|
+
label: "Active Color",
|
|
48
|
+
description: "Color of icon and text of active tab",
|
|
49
|
+
defaultValue: "primary"
|
|
50
|
+
}),
|
|
51
|
+
inactiveColor: (0, _types.createColorProp)({
|
|
52
|
+
label: "Inactive Color",
|
|
53
|
+
description: "Color of icon and text of inactive tab(s)",
|
|
54
|
+
defaultValue: null
|
|
55
|
+
}),
|
|
56
|
+
pressColor: (0, _types.createColorProp)({
|
|
57
|
+
label: "Press Color",
|
|
58
|
+
description: "Color of ripple when pressed",
|
|
59
|
+
defaultValue: "primary",
|
|
60
|
+
group: _types.GROUPS.android
|
|
61
|
+
}),
|
|
62
|
+
indicatorColor: (0, _types.createColorProp)({
|
|
63
|
+
label: "Indicator Color",
|
|
64
|
+
description: "Color of indicator",
|
|
65
|
+
defaultValue: "primary"
|
|
66
|
+
}),
|
|
67
|
+
tabsBackgroundColor: (0, _types.createColorProp)({
|
|
68
|
+
label: "Tabs Background Color",
|
|
69
|
+
description: "Background color of tabs container",
|
|
70
|
+
defaultValue: "background"
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
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;
|
|
@@ -15,7 +15,6 @@ function overlay(elevation) {
|
|
|
15
15
|
let surfaceColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _DarkTheme.default.colors.surface;
|
|
16
16
|
if (isAnimatedValue(elevation)) {
|
|
17
17
|
const inputRange = [0, 1, 2, 3, 8, 24];
|
|
18
|
-
|
|
19
18
|
// @ts-expect-error: TS doesn't seem to refine the type correctly
|
|
20
19
|
return elevation.interpolate({
|
|
21
20
|
inputRange,
|
|
@@ -24,7 +23,6 @@ function overlay(elevation) {
|
|
|
24
23
|
})
|
|
25
24
|
});
|
|
26
25
|
}
|
|
27
|
-
|
|
28
26
|
// @ts-expect-error: TS doesn't seem to refine the type correctly
|
|
29
27
|
return calculateColor(surfaceColor, elevation);
|
|
30
28
|
}
|
|
@@ -65,4 +63,4 @@ const elevationOverlayTransparency = {
|
|
|
65
63
|
22: 15.72,
|
|
66
64
|
23: 15.84,
|
|
67
65
|
24: 16
|
|
68
|
-
};
|
|
66
|
+
};};
|
|
@@ -57,7 +57,6 @@ function extractBorderAndMarginStyles(style, additionalBorderStyles, additionalM
|
|
|
57
57
|
marginStyles
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
|
|
61
60
|
/**
|
|
62
61
|
* Merges a style object on top of another style object. In React Native,
|
|
63
62
|
* keys with undefined values in a style object will still override styles
|
|
@@ -90,4 +89,4 @@ function getValueForRadioButton(value) {
|
|
|
90
89
|
} else {
|
|
91
90
|
throw new Error("Invalid value: ".concat(value));
|
|
92
91
|
}
|
|
93
|
-
}
|
|
92
|
+
}}
|
|
@@ -0,0 +1,90 @@
|
|
|
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 { TabView, TabBar, SceneMap } from "react-native-tab-view";
|
|
4
|
+
import TabViewItem from "./TabViewItem";
|
|
5
|
+
import { withTheme } from "../../theming";
|
|
6
|
+
const TabViewComponent = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
Icon,
|
|
9
|
+
onIndexChanged,
|
|
10
|
+
onEndReached,
|
|
11
|
+
tabBarPosition,
|
|
12
|
+
keyboardDismissMode,
|
|
13
|
+
swipeEnabled,
|
|
14
|
+
scrollEnabled,
|
|
15
|
+
activeColor,
|
|
16
|
+
inactiveColor,
|
|
17
|
+
pressColor,
|
|
18
|
+
indicatorColor,
|
|
19
|
+
tabsBackgroundColor,
|
|
20
|
+
style,
|
|
21
|
+
theme,
|
|
22
|
+
children
|
|
23
|
+
} = _ref;
|
|
24
|
+
const [index, setIndex] = React.useState(0);
|
|
25
|
+
const [routes, setRoutes] = React.useState([]);
|
|
26
|
+
const [tabScenes, setTabScenes] = React.useState({});
|
|
27
|
+
|
|
28
|
+
//Populate routes and scenes based on children
|
|
29
|
+
React.useEffect(() => {
|
|
30
|
+
const newRoutes = [];
|
|
31
|
+
const scenes = {};
|
|
32
|
+
React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && child.type === TabViewItem).forEach((item, idx) => {
|
|
33
|
+
const child = item;
|
|
34
|
+
newRoutes.push({
|
|
35
|
+
key: idx.toString(),
|
|
36
|
+
title: child.props.title,
|
|
37
|
+
icon: child.props.icon,
|
|
38
|
+
accessibilityLabel: child.props.accessibilityLabel
|
|
39
|
+
});
|
|
40
|
+
scenes[idx] = () => child;
|
|
41
|
+
});
|
|
42
|
+
setRoutes(newRoutes);
|
|
43
|
+
setTabScenes(scenes);
|
|
44
|
+
}, [children]);
|
|
45
|
+
const indexChangeHandler = i => {
|
|
46
|
+
setIndex(i);
|
|
47
|
+
onIndexChanged === null || onIndexChanged === void 0 ? void 0 : onIndexChanged(i);
|
|
48
|
+
if (i === routes.length) {
|
|
49
|
+
onEndReached === null || onEndReached === void 0 ? void 0 : onEndReached();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const renderTabBar = props => {
|
|
53
|
+
return /*#__PURE__*/React.createElement(TabBar, _extends({}, props, {
|
|
54
|
+
activeColor: activeColor || theme.colors.primary,
|
|
55
|
+
inactiveColor: inactiveColor || theme.colors.divider,
|
|
56
|
+
pressColor: pressColor || theme.colors.primary,
|
|
57
|
+
scrollEnabled: scrollEnabled,
|
|
58
|
+
indicatorStyle: {
|
|
59
|
+
backgroundColor: indicatorColor || theme.colors.primary
|
|
60
|
+
},
|
|
61
|
+
renderIcon: _ref2 => {
|
|
62
|
+
let {
|
|
63
|
+
route,
|
|
64
|
+
color
|
|
65
|
+
} = _ref2;
|
|
66
|
+
return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
|
|
67
|
+
name: route.icon,
|
|
68
|
+
color: color,
|
|
69
|
+
size: 36
|
|
70
|
+
}) : null;
|
|
71
|
+
},
|
|
72
|
+
style: [{
|
|
73
|
+
backgroundColor: tabsBackgroundColor || theme.colors.background
|
|
74
|
+
}, style]
|
|
75
|
+
}));
|
|
76
|
+
};
|
|
77
|
+
return /*#__PURE__*/React.createElement(TabView, {
|
|
78
|
+
navigationState: {
|
|
79
|
+
index,
|
|
80
|
+
routes
|
|
81
|
+
},
|
|
82
|
+
renderScene: SceneMap(tabScenes),
|
|
83
|
+
renderTabBar: renderTabBar,
|
|
84
|
+
onIndexChange: indexChangeHandler,
|
|
85
|
+
tabBarPosition: tabBarPosition,
|
|
86
|
+
keyboardDismissMode: keyboardDismissMode,
|
|
87
|
+
swipeEnabled: swipeEnabled
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
export default withTheme(TabViewComponent);
|