@draftbit/core 46.4.4-64c11a.2 → 46.4.4-79d05e.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/BottomSheet/BottomSheet.native.js +68 -0
- package/lib/commonjs/components/BottomSheet/BottomSheet.web.js +97 -0
- package/lib/commonjs/components/BottomSheet/index.js +15 -0
- package/lib/commonjs/components/BottomSheet/types.js +5 -0
- package/lib/commonjs/components/Button.js +11 -32
- package/lib/commonjs/components/CircleImage.js +16 -2
- package/lib/commonjs/index.js +8 -0
- package/lib/commonjs/mappings/AudioPlayer.js +2 -28
- package/lib/commonjs/mappings/BottomSheet.js +22 -0
- package/lib/module/components/BottomSheet/BottomSheet.native.js +50 -0
- package/lib/module/components/BottomSheet/BottomSheet.web.js +78 -0
- package/lib/module/components/BottomSheet/index.js +2 -0
- package/lib/module/components/BottomSheet/types.js +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/mappings/AudioPlayer.js +3 -29
- package/lib/module/mappings/BottomSheet.js +13 -0
- package/lib/typescript/src/components/BottomSheet/BottomSheet.native.d.ts +4 -0
- package/lib/typescript/src/components/BottomSheet/BottomSheet.web.d.ts +4 -0
- package/lib/typescript/src/components/BottomSheet/index.d.ts +1 -0
- package/lib/typescript/src/components/BottomSheet/types.d.ts +8 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/mappings/AudioPlayer.d.ts +1 -52
- package/lib/typescript/src/mappings/BottomSheet.d.ts +19 -0
- package/package.json +3 -3
- package/src/components/BottomSheet/BottomSheet.native.js +37 -0
- package/src/components/BottomSheet/BottomSheet.native.tsx +60 -0
- package/src/components/BottomSheet/BottomSheet.web.js +56 -0
- package/src/components/BottomSheet/BottomSheet.web.tsx +90 -0
- package/src/components/BottomSheet/index.js +2 -0
- package/src/components/BottomSheet/index.tsx +2 -0
- package/src/components/BottomSheet/types.js +1 -0
- package/src/components/BottomSheet/types.tsx +8 -0
- package/src/index.js +1 -0
- package/src/index.tsx +1 -0
- package/src/mappings/AudioPlayer.js +2 -35
- package/src/mappings/AudioPlayer.ts +1 -37
- package/src/mappings/BottomSheet.js +20 -0
- package/src/mappings/BottomSheet.ts +25 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
12
|
+
var _bottomSheet = _interopRequireWildcard(require("@gorhom/bottom-sheet"));
|
|
13
|
+
|
|
14
|
+
var _utilities = require("../../utilities");
|
|
15
|
+
|
|
16
|
+
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); }
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
const BottomSheetComponent = _ref => {
|
|
21
|
+
let {
|
|
22
|
+
style,
|
|
23
|
+
children,
|
|
24
|
+
step
|
|
25
|
+
} = _ref;
|
|
26
|
+
const bottomSheetRef = (0, _react.useRef)(null);
|
|
27
|
+
const {
|
|
28
|
+
viewStyles
|
|
29
|
+
} = (0, _utilities.extractStyles)(style); // variables
|
|
30
|
+
|
|
31
|
+
const snapPoints = (0, _react.useMemo)(() => ["25%", "50%", "90%"], []); // callbacks
|
|
32
|
+
|
|
33
|
+
const handleSheetChanges = (0, _react.useCallback)(index => {
|
|
34
|
+
console.log("handleSheetChanges", index);
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
37
|
+
_react.default.useEffect(() => {
|
|
38
|
+
if (step === -1) {
|
|
39
|
+
var _bottomSheetRef$curre;
|
|
40
|
+
|
|
41
|
+
bottomSheetRef === null || bottomSheetRef === void 0 ? void 0 : (_bottomSheetRef$curre = bottomSheetRef.current) === null || _bottomSheetRef$curre === void 0 ? void 0 : _bottomSheetRef$curre.close();
|
|
42
|
+
}
|
|
43
|
+
}, [step]);
|
|
44
|
+
|
|
45
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
46
|
+
style: [containerStyle.container, viewStyles, {
|
|
47
|
+
backgroundColor: step !== -1 ? "grey" : "transparent"
|
|
48
|
+
}]
|
|
49
|
+
}, /*#__PURE__*/_react.default.createElement(_bottomSheet.default, {
|
|
50
|
+
ref: bottomSheetRef,
|
|
51
|
+
index: step,
|
|
52
|
+
snapPoints: snapPoints,
|
|
53
|
+
onChange: handleSheetChanges
|
|
54
|
+
}, /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetView, null, children)));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
var _default = BottomSheetComponent;
|
|
58
|
+
exports.default = _default;
|
|
59
|
+
|
|
60
|
+
const containerStyle = _reactNative.StyleSheet.create({
|
|
61
|
+
container: {
|
|
62
|
+
flex: 1
|
|
63
|
+
},
|
|
64
|
+
contentContainer: {
|
|
65
|
+
flex: 1,
|
|
66
|
+
alignItems: "center"
|
|
67
|
+
}
|
|
68
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
12
|
+
var _reactNativeScrollBottomSheet = _interopRequireDefault(require("react-native-scroll-bottom-sheet"));
|
|
13
|
+
|
|
14
|
+
var _utilities = require("../../utilities");
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
const windowHeight = _reactNative.Dimensions.get("window").height;
|
|
19
|
+
|
|
20
|
+
const BottomSheetComponent = _ref => {
|
|
21
|
+
let {
|
|
22
|
+
style,
|
|
23
|
+
children,
|
|
24
|
+
step
|
|
25
|
+
} = _ref;
|
|
26
|
+
const {
|
|
27
|
+
viewStyles
|
|
28
|
+
} = (0, _utilities.extractStyles)(style);
|
|
29
|
+
|
|
30
|
+
const bottomSheetRef = _react.default.useRef();
|
|
31
|
+
|
|
32
|
+
const webStep = _react.default.useMemo(() => step + 1, [step]);
|
|
33
|
+
|
|
34
|
+
const snapPoints = _react.default.useMemo(() => ["25%", "50%", windowHeight - 200], []);
|
|
35
|
+
|
|
36
|
+
_react.default.useEffect(() => {
|
|
37
|
+
var _bottomSheetRef$curre;
|
|
38
|
+
|
|
39
|
+
bottomSheetRef === null || bottomSheetRef === void 0 ? void 0 : (_bottomSheetRef$curre = bottomSheetRef.current) === null || _bottomSheetRef$curre === void 0 ? void 0 : _bottomSheetRef$curre.snapTo(snapPoints.length - webStep); // bottomSheetRef.current.snapTo(step);
|
|
40
|
+
}, [webStep, step, snapPoints]);
|
|
41
|
+
|
|
42
|
+
if (step === -1) {
|
|
43
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
47
|
+
style: styles.container
|
|
48
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNativeScrollBottomSheet.default, {
|
|
49
|
+
ref: bottomSheetRef,
|
|
50
|
+
componentType: "ScrollView",
|
|
51
|
+
snapPoints: snapPoints,
|
|
52
|
+
initialSnapIndex: 0,
|
|
53
|
+
renderHandle: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
54
|
+
style: styles.header
|
|
55
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
56
|
+
style: styles.panelHandle
|
|
57
|
+
})),
|
|
58
|
+
contentContainerStyle: styles.contentContainerStyle
|
|
59
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
60
|
+
style: { ...styles.container,
|
|
61
|
+
...viewStyles,
|
|
62
|
+
backgroundColor: webStep !== -1 ? "grey" : "transparent"
|
|
63
|
+
}
|
|
64
|
+
}, children)));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
var _default = BottomSheetComponent;
|
|
68
|
+
exports.default = _default;
|
|
69
|
+
|
|
70
|
+
const styles = _reactNative.StyleSheet.create({
|
|
71
|
+
container: {
|
|
72
|
+
flex: 1
|
|
73
|
+
},
|
|
74
|
+
contentContainerStyle: {
|
|
75
|
+
padding: 16
|
|
76
|
+
},
|
|
77
|
+
header: {
|
|
78
|
+
alignItems: "center",
|
|
79
|
+
backgroundColor: "white",
|
|
80
|
+
paddingVertical: 20,
|
|
81
|
+
borderTopLeftRadius: 20,
|
|
82
|
+
borderTopRightRadius: 20
|
|
83
|
+
},
|
|
84
|
+
panelHandle: {
|
|
85
|
+
width: 40,
|
|
86
|
+
height: 2,
|
|
87
|
+
backgroundColor: "rgba(0,0,0,0.3)",
|
|
88
|
+
borderRadius: 4
|
|
89
|
+
},
|
|
90
|
+
item: {
|
|
91
|
+
padding: 20,
|
|
92
|
+
justifyContent: "center",
|
|
93
|
+
backgroundColor: "white",
|
|
94
|
+
alignItems: "center",
|
|
95
|
+
marginVertical: 10
|
|
96
|
+
}
|
|
97
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "BottomSheet", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _BottomSheet.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _BottomSheet = _interopRequireDefault(require("./BottomSheet"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -15,6 +15,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
15
15
|
|
|
16
16
|
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; }
|
|
17
17
|
|
|
18
|
+
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); }
|
|
19
|
+
|
|
18
20
|
const CONSTANTS = {
|
|
19
21
|
baseHeight: 42,
|
|
20
22
|
borderRadius: 4,
|
|
@@ -71,7 +73,7 @@ function Base(_ref) {
|
|
|
71
73
|
buttonStyles.justifyContent = "flex-end";
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
return /*#__PURE__*/React.createElement(_reactNative.Pressable, {
|
|
76
|
+
return /*#__PURE__*/React.createElement(_reactNative.Pressable, _extends({
|
|
75
77
|
onPress: onPress,
|
|
76
78
|
disabled: disabled || loading,
|
|
77
79
|
style: _ref2 => {
|
|
@@ -81,9 +83,8 @@ function Base(_ref) {
|
|
|
81
83
|
return [styles.base, {
|
|
82
84
|
opacity: pressed || disabled ? 0.75 : 1
|
|
83
85
|
}, buttonStyles];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
}, loading ? /*#__PURE__*/React.createElement(_reactNative.ActivityIndicator, {
|
|
86
|
+
}
|
|
87
|
+
}, props), loading ? /*#__PURE__*/React.createElement(_reactNative.ActivityIndicator, {
|
|
87
88
|
size: "small",
|
|
88
89
|
color: color,
|
|
89
90
|
style: styles.loading
|
|
@@ -103,14 +104,13 @@ const Solid = _ref3 => {
|
|
|
103
104
|
theme,
|
|
104
105
|
...props
|
|
105
106
|
} = _ref3;
|
|
106
|
-
return /*#__PURE__*/React.createElement(Base, {
|
|
107
|
+
return /*#__PURE__*/React.createElement(Base, _extends({
|
|
107
108
|
style: [{
|
|
108
109
|
color: "#FFF",
|
|
109
110
|
borderRadius: theme.roundness,
|
|
110
111
|
backgroundColor: theme.colors.primary
|
|
111
|
-
}, style]
|
|
112
|
-
|
|
113
|
-
});
|
|
112
|
+
}, style]
|
|
113
|
+
}, props));
|
|
114
114
|
};
|
|
115
115
|
|
|
116
116
|
const ButtonSolid = (0, _theming.withTheme)(Solid);
|
|
@@ -124,14 +124,13 @@ const Outline = _ref4 => {
|
|
|
124
124
|
theme,
|
|
125
125
|
...props
|
|
126
126
|
} = _ref4;
|
|
127
|
-
return /*#__PURE__*/React.createElement(Base, {
|
|
127
|
+
return /*#__PURE__*/React.createElement(Base, _extends({
|
|
128
128
|
style: [styles.outline, {
|
|
129
129
|
borderRadius: theme.roundness,
|
|
130
130
|
borderColor: theme.colors.primary,
|
|
131
131
|
color: theme.colors.primary
|
|
132
|
-
}, style]
|
|
133
|
-
|
|
134
|
-
});
|
|
132
|
+
}, style]
|
|
133
|
+
}, props));
|
|
135
134
|
};
|
|
136
135
|
|
|
137
136
|
const ButtonOutline = (0, _theming.withTheme)(Outline);
|
|
@@ -179,24 +178,4 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
179
178
|
}
|
|
180
179
|
})
|
|
181
180
|
}
|
|
182
|
-
});nsparent",
|
|
183
|
-
padding: 0,
|
|
184
|
-
minHeight: undefined
|
|
185
|
-
},
|
|
186
|
-
loading: {
|
|
187
|
-
marginRight: 6
|
|
188
|
-
},
|
|
189
|
-
icon: { ..._reactNative.Platform.select({
|
|
190
|
-
web: {
|
|
191
|
-
marginTop: 1,
|
|
192
|
-
marginRight: 4,
|
|
193
|
-
alignSelf: "center"
|
|
194
|
-
},
|
|
195
|
-
default: {
|
|
196
|
-
marginBottom: 2,
|
|
197
|
-
marginRight: 4,
|
|
198
|
-
alignSelf: "center"
|
|
199
|
-
}
|
|
200
|
-
})
|
|
201
|
-
}
|
|
202
181
|
});
|
|
@@ -17,8 +17,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
17
17
|
|
|
18
18
|
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; }
|
|
19
19
|
|
|
20
|
-
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); }
|
|
21
|
-
|
|
22
20
|
const CircleImage = _ref => {
|
|
23
21
|
let {
|
|
24
22
|
source = _Config.default.placeholderImageURL,
|
|
@@ -27,6 +25,22 @@ const CircleImage = _ref => {
|
|
|
27
25
|
...props
|
|
28
26
|
} = _ref;
|
|
29
27
|
const borderRadius = size / 2;
|
|
28
|
+
return /*#__PURE__*/React.createElement(_reactNative.Image, {
|
|
29
|
+
style: [{
|
|
30
|
+
width: size,
|
|
31
|
+
height: size,
|
|
32
|
+
borderRadius
|
|
33
|
+
}, style],
|
|
34
|
+
source: typeof source === "string" ? {
|
|
35
|
+
uri: source
|
|
36
|
+
} : source,
|
|
37
|
+
resizeMode: "cover",
|
|
38
|
+
...props
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
var _default = CircleImage;
|
|
43
|
+
exports.default = _default;size / 2;
|
|
30
44
|
return /*#__PURE__*/React.createElement(_reactNative.Image, _extends({
|
|
31
45
|
style: [{
|
|
32
46
|
width: size,
|
package/lib/commonjs/index.js
CHANGED
|
@@ -51,6 +51,12 @@ Object.defineProperty(exports, "Banner", {
|
|
|
51
51
|
return _Banner.default;
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
|
+
Object.defineProperty(exports, "BottomSheet", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _BottomSheet.BottomSheet;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
54
60
|
Object.defineProperty(exports, "Button", {
|
|
55
61
|
enumerable: true,
|
|
56
62
|
get: function () {
|
|
@@ -472,6 +478,8 @@ var _ActionSheet = require("./components/ActionSheet");
|
|
|
472
478
|
|
|
473
479
|
var _Swiper = require("./components/Swiper");
|
|
474
480
|
|
|
481
|
+
var _BottomSheet = require("./components/BottomSheet");
|
|
482
|
+
|
|
475
483
|
var _Layout = require("./components/Layout");
|
|
476
484
|
|
|
477
485
|
var _index = require("./components/RadioButton/index");
|
|
@@ -12,17 +12,7 @@ const SEED_DATA = {
|
|
|
12
12
|
tag: "AudioPlayer",
|
|
13
13
|
description: "Given a source URL, plays sounds & audio!",
|
|
14
14
|
category: _types.COMPONENT_TYPES.media,
|
|
15
|
-
|
|
16
|
-
layout: {
|
|
17
|
-
backgroundColor: "#eee",
|
|
18
|
-
paddingLeft: 16,
|
|
19
|
-
paddingRight: 16,
|
|
20
|
-
paddingTop: 8,
|
|
21
|
-
paddingBottom: 8,
|
|
22
|
-
borderRadius: 24,
|
|
23
|
-
flexDirection: "row",
|
|
24
|
-
alignItems: "center"
|
|
25
|
-
},
|
|
15
|
+
layout: {},
|
|
26
16
|
props: {
|
|
27
17
|
source: {
|
|
28
18
|
group: _types.GROUPS.data,
|
|
@@ -33,23 +23,7 @@ const SEED_DATA = {
|
|
|
33
23
|
defaultValue: "https://static.draftbit.com/audio/intro-to-draftbit-audio.mp3",
|
|
34
24
|
formType: _types.FORM_TYPES.sourceUrl,
|
|
35
25
|
propType: _types.PROP_TYPES.OBJECT
|
|
36
|
-
}
|
|
37
|
-
sliderColor: (0, _types.createColorProp)({
|
|
38
|
-
label: "Thumb Color",
|
|
39
|
-
defaultValue: "black"
|
|
40
|
-
}),
|
|
41
|
-
completedTrackColor: (0, _types.createColorProp)({
|
|
42
|
-
label: "Completed Track Color",
|
|
43
|
-
defaultValue: "white"
|
|
44
|
-
}),
|
|
45
|
-
remainingTrackColor: (0, _types.createColorProp)({
|
|
46
|
-
label: "Remaining Track Color",
|
|
47
|
-
defaultValue: "#333333"
|
|
48
|
-
}),
|
|
49
|
-
trackThumbSize: (0, _types.createNumberProp)({
|
|
50
|
-
label: "Thumb Size",
|
|
51
|
-
defaultValue: 24
|
|
52
|
-
})
|
|
26
|
+
}
|
|
53
27
|
}
|
|
54
28
|
};
|
|
55
29
|
exports.SEED_DATA = SEED_DATA;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SEED_DATA = void 0;
|
|
7
|
+
|
|
8
|
+
var _types = require("@draftbit/types");
|
|
9
|
+
|
|
10
|
+
const SEED_DATA = {
|
|
11
|
+
name: "Bottom Sheet",
|
|
12
|
+
tag: "BottomSheet",
|
|
13
|
+
category: _types.COMPONENT_TYPES.container,
|
|
14
|
+
stylesPanelSections: [_types.StylesPanelSections.Background, _types.StylesPanelSections.Borders, _types.StylesPanelSections.Size, _types.StylesPanelSections.MarginsAndPaddings, _types.StylesPanelSections.Position, _types.StylesPanelSections.Effects],
|
|
15
|
+
props: {
|
|
16
|
+
step: (0, _types.createNumberProp)({
|
|
17
|
+
label: "Step",
|
|
18
|
+
description: "Step can be -1, 0, 1, or 2."
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
exports.SEED_DATA = SEED_DATA;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { useCallback, useMemo, useRef } from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import BottomSheet, { BottomSheetView } from "@gorhom/bottom-sheet";
|
|
4
|
+
import { extractStyles } from "../../utilities";
|
|
5
|
+
|
|
6
|
+
const BottomSheetComponent = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
style,
|
|
9
|
+
children,
|
|
10
|
+
step
|
|
11
|
+
} = _ref;
|
|
12
|
+
const bottomSheetRef = useRef(null);
|
|
13
|
+
const {
|
|
14
|
+
viewStyles
|
|
15
|
+
} = extractStyles(style); // variables
|
|
16
|
+
|
|
17
|
+
const snapPoints = useMemo(() => ["25%", "50%", "90%"], []); // callbacks
|
|
18
|
+
|
|
19
|
+
const handleSheetChanges = useCallback(index => {
|
|
20
|
+
console.log("handleSheetChanges", index);
|
|
21
|
+
}, []);
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
if (step === -1) {
|
|
24
|
+
var _bottomSheetRef$curre;
|
|
25
|
+
|
|
26
|
+
bottomSheetRef === null || bottomSheetRef === void 0 ? void 0 : (_bottomSheetRef$curre = bottomSheetRef.current) === null || _bottomSheetRef$curre === void 0 ? void 0 : _bottomSheetRef$curre.close();
|
|
27
|
+
}
|
|
28
|
+
}, [step]);
|
|
29
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
30
|
+
style: [containerStyle.container, viewStyles, {
|
|
31
|
+
backgroundColor: step !== -1 ? "grey" : "transparent"
|
|
32
|
+
}]
|
|
33
|
+
}, /*#__PURE__*/React.createElement(BottomSheet, {
|
|
34
|
+
ref: bottomSheetRef,
|
|
35
|
+
index: step,
|
|
36
|
+
snapPoints: snapPoints,
|
|
37
|
+
onChange: handleSheetChanges
|
|
38
|
+
}, /*#__PURE__*/React.createElement(BottomSheetView, null, children)));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default BottomSheetComponent;
|
|
42
|
+
const containerStyle = StyleSheet.create({
|
|
43
|
+
container: {
|
|
44
|
+
flex: 1
|
|
45
|
+
},
|
|
46
|
+
contentContainer: {
|
|
47
|
+
flex: 1,
|
|
48
|
+
alignItems: "center"
|
|
49
|
+
}
|
|
50
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleSheet, View, Dimensions } from "react-native";
|
|
3
|
+
import ScrollBottomSheet from "react-native-scroll-bottom-sheet";
|
|
4
|
+
import { extractStyles } from "../../utilities";
|
|
5
|
+
const windowHeight = Dimensions.get("window").height;
|
|
6
|
+
|
|
7
|
+
const BottomSheetComponent = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
style,
|
|
10
|
+
children,
|
|
11
|
+
step
|
|
12
|
+
} = _ref;
|
|
13
|
+
const {
|
|
14
|
+
viewStyles
|
|
15
|
+
} = extractStyles(style);
|
|
16
|
+
const bottomSheetRef = React.useRef();
|
|
17
|
+
const webStep = React.useMemo(() => step + 1, [step]);
|
|
18
|
+
const snapPoints = React.useMemo(() => ["25%", "50%", windowHeight - 200], []);
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
var _bottomSheetRef$curre;
|
|
21
|
+
|
|
22
|
+
bottomSheetRef === null || bottomSheetRef === void 0 ? void 0 : (_bottomSheetRef$curre = bottomSheetRef.current) === null || _bottomSheetRef$curre === void 0 ? void 0 : _bottomSheetRef$curre.snapTo(snapPoints.length - webStep); // bottomSheetRef.current.snapTo(step);
|
|
23
|
+
}, [webStep, step, snapPoints]);
|
|
24
|
+
|
|
25
|
+
if (step === -1) {
|
|
26
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
30
|
+
style: styles.container
|
|
31
|
+
}, /*#__PURE__*/React.createElement(ScrollBottomSheet, {
|
|
32
|
+
ref: bottomSheetRef,
|
|
33
|
+
componentType: "ScrollView",
|
|
34
|
+
snapPoints: snapPoints,
|
|
35
|
+
initialSnapIndex: 0,
|
|
36
|
+
renderHandle: () => /*#__PURE__*/React.createElement(View, {
|
|
37
|
+
style: styles.header
|
|
38
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
39
|
+
style: styles.panelHandle
|
|
40
|
+
})),
|
|
41
|
+
contentContainerStyle: styles.contentContainerStyle
|
|
42
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
43
|
+
style: { ...styles.container,
|
|
44
|
+
...viewStyles,
|
|
45
|
+
backgroundColor: webStep !== -1 ? "grey" : "transparent"
|
|
46
|
+
}
|
|
47
|
+
}, children)));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default BottomSheetComponent;
|
|
51
|
+
const styles = StyleSheet.create({
|
|
52
|
+
container: {
|
|
53
|
+
flex: 1
|
|
54
|
+
},
|
|
55
|
+
contentContainerStyle: {
|
|
56
|
+
padding: 16
|
|
57
|
+
},
|
|
58
|
+
header: {
|
|
59
|
+
alignItems: "center",
|
|
60
|
+
backgroundColor: "white",
|
|
61
|
+
paddingVertical: 20,
|
|
62
|
+
borderTopLeftRadius: 20,
|
|
63
|
+
borderTopRightRadius: 20
|
|
64
|
+
},
|
|
65
|
+
panelHandle: {
|
|
66
|
+
width: 40,
|
|
67
|
+
height: 2,
|
|
68
|
+
backgroundColor: "rgba(0,0,0,0.3)",
|
|
69
|
+
borderRadius: 4
|
|
70
|
+
},
|
|
71
|
+
item: {
|
|
72
|
+
padding: 20,
|
|
73
|
+
justifyContent: "center",
|
|
74
|
+
backgroundColor: "white",
|
|
75
|
+
alignItems: "center",
|
|
76
|
+
marginVertical: 10
|
|
77
|
+
}
|
|
78
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
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 { BottomSheet } from "./components/BottomSheet";
|
|
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,22 +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
|
-
})
|
|
18
|
+
}
|
|
45
19
|
}
|
|
46
20
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { COMPONENT_TYPES, createNumberProp, StylesPanelSections } from "@draftbit/types";
|
|
2
|
+
export const SEED_DATA = {
|
|
3
|
+
name: "Bottom Sheet",
|
|
4
|
+
tag: "BottomSheet",
|
|
5
|
+
category: COMPONENT_TYPES.container,
|
|
6
|
+
stylesPanelSections: [StylesPanelSections.Background, StylesPanelSections.Borders, StylesPanelSections.Size, StylesPanelSections.MarginsAndPaddings, StylesPanelSections.Position, StylesPanelSections.Effects],
|
|
7
|
+
props: {
|
|
8
|
+
step: createNumberProp({
|
|
9
|
+
label: "Step",
|
|
10
|
+
description: "Step can be -1, 0, 1, or 2."
|
|
11
|
+
})
|
|
12
|
+
}
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BottomSheet } from "./BottomSheet";
|
|
@@ -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 { BottomSheet } from "./components/BottomSheet";
|
|
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,46 +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
18
|
};
|
|
70
19
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const SEED_DATA: {
|
|
2
|
+
name: string;
|
|
3
|
+
tag: string;
|
|
4
|
+
category: string;
|
|
5
|
+
stylesPanelSections: string[];
|
|
6
|
+
props: {
|
|
7
|
+
step: {
|
|
8
|
+
label: string;
|
|
9
|
+
description: string;
|
|
10
|
+
formType: string;
|
|
11
|
+
propType: string;
|
|
12
|
+
group: string;
|
|
13
|
+
defaultValue: null;
|
|
14
|
+
editable: boolean;
|
|
15
|
+
required: boolean;
|
|
16
|
+
step: number;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
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-79d05e.2+79d05e6",
|
|
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-79d05e.2+79d05e6",
|
|
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",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
]
|
|
82
82
|
]
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "79d05e6769899c770ade5ff791187b8d8ee234b4"
|
|
85
85
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { useCallback, useMemo, useRef } from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import BottomSheet, { BottomSheetView } from "@gorhom/bottom-sheet";
|
|
4
|
+
import { extractStyles } from "../../utilities";
|
|
5
|
+
const BottomSheetComponent = ({ style, children, step, }) => {
|
|
6
|
+
const bottomSheetRef = useRef(null);
|
|
7
|
+
const { viewStyles } = extractStyles(style);
|
|
8
|
+
// variables
|
|
9
|
+
const snapPoints = useMemo(() => ["25%", "50%", "90%"], []);
|
|
10
|
+
// callbacks
|
|
11
|
+
const handleSheetChanges = useCallback((index) => {
|
|
12
|
+
console.log("handleSheetChanges", index);
|
|
13
|
+
}, []);
|
|
14
|
+
React.useEffect(() => {
|
|
15
|
+
var _a;
|
|
16
|
+
if (step === -1) {
|
|
17
|
+
(_a = bottomSheetRef === null || bottomSheetRef === void 0 ? void 0 : bottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
18
|
+
}
|
|
19
|
+
}, [step]);
|
|
20
|
+
return (React.createElement(View, { style: [
|
|
21
|
+
containerStyle.container,
|
|
22
|
+
viewStyles,
|
|
23
|
+
{ backgroundColor: step !== -1 ? "grey" : "transparent" },
|
|
24
|
+
] },
|
|
25
|
+
React.createElement(BottomSheet, { ref: bottomSheetRef, index: step, snapPoints: snapPoints, onChange: handleSheetChanges },
|
|
26
|
+
React.createElement(BottomSheetView, null, children))));
|
|
27
|
+
};
|
|
28
|
+
export default BottomSheetComponent;
|
|
29
|
+
const containerStyle = StyleSheet.create({
|
|
30
|
+
container: {
|
|
31
|
+
flex: 1,
|
|
32
|
+
},
|
|
33
|
+
contentContainer: {
|
|
34
|
+
flex: 1,
|
|
35
|
+
alignItems: "center",
|
|
36
|
+
},
|
|
37
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { useCallback, useMemo, useRef } from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import BottomSheet, { BottomSheetView } from "@gorhom/bottom-sheet";
|
|
4
|
+
|
|
5
|
+
import { extractStyles } from "../../utilities";
|
|
6
|
+
import { BottomSheetProps } from "./types";
|
|
7
|
+
|
|
8
|
+
const BottomSheetComponent: React.FC<BottomSheetProps> = ({
|
|
9
|
+
style,
|
|
10
|
+
children,
|
|
11
|
+
step,
|
|
12
|
+
}) => {
|
|
13
|
+
const bottomSheetRef = useRef<BottomSheet>(null);
|
|
14
|
+
const { viewStyles } = extractStyles(style);
|
|
15
|
+
|
|
16
|
+
// variables
|
|
17
|
+
const snapPoints = useMemo(() => ["25%", "50%", "90%"], []);
|
|
18
|
+
|
|
19
|
+
// callbacks
|
|
20
|
+
const handleSheetChanges = useCallback((index: number) => {
|
|
21
|
+
console.log("handleSheetChanges", index);
|
|
22
|
+
}, []);
|
|
23
|
+
|
|
24
|
+
React.useEffect(() => {
|
|
25
|
+
if (step === -1) {
|
|
26
|
+
bottomSheetRef?.current?.close();
|
|
27
|
+
}
|
|
28
|
+
}, [step]);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<View
|
|
32
|
+
style={[
|
|
33
|
+
containerStyle.container,
|
|
34
|
+
viewStyles,
|
|
35
|
+
{ backgroundColor: step !== -1 ? "grey" : "transparent" },
|
|
36
|
+
]}
|
|
37
|
+
>
|
|
38
|
+
<BottomSheet
|
|
39
|
+
ref={bottomSheetRef}
|
|
40
|
+
index={step}
|
|
41
|
+
snapPoints={snapPoints}
|
|
42
|
+
onChange={handleSheetChanges}
|
|
43
|
+
>
|
|
44
|
+
<BottomSheetView>{children}</BottomSheetView>
|
|
45
|
+
</BottomSheet>
|
|
46
|
+
</View>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default BottomSheetComponent;
|
|
51
|
+
|
|
52
|
+
const containerStyle = StyleSheet.create({
|
|
53
|
+
container: {
|
|
54
|
+
flex: 1,
|
|
55
|
+
},
|
|
56
|
+
contentContainer: {
|
|
57
|
+
flex: 1,
|
|
58
|
+
alignItems: "center",
|
|
59
|
+
},
|
|
60
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleSheet, View, Dimensions } from "react-native";
|
|
3
|
+
import ScrollBottomSheet from "react-native-scroll-bottom-sheet";
|
|
4
|
+
import { extractStyles } from "../../utilities";
|
|
5
|
+
const windowHeight = Dimensions.get("window").height;
|
|
6
|
+
const BottomSheetComponent = ({ style, children, step, }) => {
|
|
7
|
+
const { viewStyles } = extractStyles(style);
|
|
8
|
+
const bottomSheetRef = React.useRef();
|
|
9
|
+
const webStep = React.useMemo(() => step + 1, [step]);
|
|
10
|
+
const snapPoints = React.useMemo(() => ["25%", "50%", windowHeight - 200], []);
|
|
11
|
+
React.useEffect(() => {
|
|
12
|
+
var _a;
|
|
13
|
+
(_a = bottomSheetRef === null || bottomSheetRef === void 0 ? void 0 : bottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.snapTo(snapPoints.length - webStep);
|
|
14
|
+
// bottomSheetRef.current.snapTo(step);
|
|
15
|
+
}, [webStep, step, snapPoints]);
|
|
16
|
+
if (step === -1) {
|
|
17
|
+
return React.createElement(React.Fragment, null);
|
|
18
|
+
}
|
|
19
|
+
return (React.createElement(View, { style: styles.container },
|
|
20
|
+
React.createElement(ScrollBottomSheet, { ref: bottomSheetRef, componentType: "ScrollView", snapPoints: snapPoints, initialSnapIndex: 0, renderHandle: () => (React.createElement(View, { style: styles.header },
|
|
21
|
+
React.createElement(View, { style: styles.panelHandle }))), contentContainerStyle: styles.contentContainerStyle },
|
|
22
|
+
React.createElement(View, { style: {
|
|
23
|
+
...styles.container,
|
|
24
|
+
...viewStyles,
|
|
25
|
+
backgroundColor: webStep !== -1 ? "grey" : "transparent",
|
|
26
|
+
} }, children))));
|
|
27
|
+
};
|
|
28
|
+
export default BottomSheetComponent;
|
|
29
|
+
const styles = StyleSheet.create({
|
|
30
|
+
container: {
|
|
31
|
+
flex: 1,
|
|
32
|
+
},
|
|
33
|
+
contentContainerStyle: {
|
|
34
|
+
padding: 16,
|
|
35
|
+
},
|
|
36
|
+
header: {
|
|
37
|
+
alignItems: "center",
|
|
38
|
+
backgroundColor: "white",
|
|
39
|
+
paddingVertical: 20,
|
|
40
|
+
borderTopLeftRadius: 20,
|
|
41
|
+
borderTopRightRadius: 20,
|
|
42
|
+
},
|
|
43
|
+
panelHandle: {
|
|
44
|
+
width: 40,
|
|
45
|
+
height: 2,
|
|
46
|
+
backgroundColor: "rgba(0,0,0,0.3)",
|
|
47
|
+
borderRadius: 4,
|
|
48
|
+
},
|
|
49
|
+
item: {
|
|
50
|
+
padding: 20,
|
|
51
|
+
justifyContent: "center",
|
|
52
|
+
backgroundColor: "white",
|
|
53
|
+
alignItems: "center",
|
|
54
|
+
marginVertical: 10,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleSheet, View, Dimensions } from "react-native";
|
|
3
|
+
import ScrollBottomSheet from "react-native-scroll-bottom-sheet";
|
|
4
|
+
|
|
5
|
+
import { extractStyles } from "../../utilities";
|
|
6
|
+
import { BottomSheetProps } from "./types";
|
|
7
|
+
|
|
8
|
+
const windowHeight = Dimensions.get("window").height;
|
|
9
|
+
|
|
10
|
+
const BottomSheetComponent: React.FC<BottomSheetProps> = ({
|
|
11
|
+
style,
|
|
12
|
+
children,
|
|
13
|
+
step,
|
|
14
|
+
}) => {
|
|
15
|
+
const { viewStyles } = extractStyles(style);
|
|
16
|
+
const bottomSheetRef = React.useRef<any>();
|
|
17
|
+
|
|
18
|
+
const webStep = React.useMemo(() => step + 1, [step]);
|
|
19
|
+
const snapPoints = React.useMemo(
|
|
20
|
+
() => ["25%", "50%", windowHeight - 200],
|
|
21
|
+
[]
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
React.useEffect(() => {
|
|
25
|
+
bottomSheetRef?.current?.snapTo(snapPoints.length - webStep);
|
|
26
|
+
// bottomSheetRef.current.snapTo(step);
|
|
27
|
+
}, [webStep, step, snapPoints]);
|
|
28
|
+
|
|
29
|
+
if (step === -1) {
|
|
30
|
+
return <></>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<View style={styles.container}>
|
|
35
|
+
<ScrollBottomSheet
|
|
36
|
+
ref={bottomSheetRef}
|
|
37
|
+
componentType="ScrollView"
|
|
38
|
+
snapPoints={snapPoints}
|
|
39
|
+
initialSnapIndex={0}
|
|
40
|
+
renderHandle={() => (
|
|
41
|
+
<View style={styles.header}>
|
|
42
|
+
<View style={styles.panelHandle} />
|
|
43
|
+
</View>
|
|
44
|
+
)}
|
|
45
|
+
contentContainerStyle={styles.contentContainerStyle}
|
|
46
|
+
>
|
|
47
|
+
<View
|
|
48
|
+
style={{
|
|
49
|
+
...styles.container,
|
|
50
|
+
...viewStyles,
|
|
51
|
+
backgroundColor: webStep !== -1 ? "grey" : "transparent",
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
{children}
|
|
55
|
+
</View>
|
|
56
|
+
</ScrollBottomSheet>
|
|
57
|
+
</View>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default BottomSheetComponent;
|
|
62
|
+
|
|
63
|
+
const styles = StyleSheet.create({
|
|
64
|
+
container: {
|
|
65
|
+
flex: 1,
|
|
66
|
+
},
|
|
67
|
+
contentContainerStyle: {
|
|
68
|
+
padding: 16,
|
|
69
|
+
},
|
|
70
|
+
header: {
|
|
71
|
+
alignItems: "center",
|
|
72
|
+
backgroundColor: "white",
|
|
73
|
+
paddingVertical: 20,
|
|
74
|
+
borderTopLeftRadius: 20,
|
|
75
|
+
borderTopRightRadius: 20,
|
|
76
|
+
},
|
|
77
|
+
panelHandle: {
|
|
78
|
+
width: 40,
|
|
79
|
+
height: 2,
|
|
80
|
+
backgroundColor: "rgba(0,0,0,0.3)",
|
|
81
|
+
borderRadius: 4,
|
|
82
|
+
},
|
|
83
|
+
item: {
|
|
84
|
+
padding: 20,
|
|
85
|
+
justifyContent: "center",
|
|
86
|
+
backgroundColor: "white",
|
|
87
|
+
alignItems: "center",
|
|
88
|
+
marginVertical: 10,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
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 { BottomSheet } from "./components/BottomSheet";
|
|
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,21 +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
19
|
},
|
|
53
20
|
};
|
|
@@ -3,9 +3,6 @@ import {
|
|
|
3
3
|
COMPONENT_TYPES,
|
|
4
4
|
FORM_TYPES,
|
|
5
5
|
PROP_TYPES,
|
|
6
|
-
StylesPanelSections,
|
|
7
|
-
createColorProp,
|
|
8
|
-
createNumberProp,
|
|
9
6
|
} from "@draftbit/types";
|
|
10
7
|
|
|
11
8
|
export const SEED_DATA = {
|
|
@@ -13,24 +10,7 @@ export const SEED_DATA = {
|
|
|
13
10
|
tag: "AudioPlayer",
|
|
14
11
|
description: "Given a source URL, plays sounds & audio!",
|
|
15
12
|
category: COMPONENT_TYPES.media,
|
|
16
|
-
|
|
17
|
-
StylesPanelSections.Typography,
|
|
18
|
-
StylesPanelSections.Background,
|
|
19
|
-
StylesPanelSections.Borders,
|
|
20
|
-
StylesPanelSections.Size,
|
|
21
|
-
StylesPanelSections.MarginsAndPaddings,
|
|
22
|
-
StylesPanelSections.Position,
|
|
23
|
-
],
|
|
24
|
-
layout: {
|
|
25
|
-
backgroundColor: "#eee",
|
|
26
|
-
paddingLeft: 16,
|
|
27
|
-
paddingRight: 16,
|
|
28
|
-
paddingTop: 8,
|
|
29
|
-
paddingBottom: 8,
|
|
30
|
-
borderRadius: 24,
|
|
31
|
-
flexDirection: "row",
|
|
32
|
-
alignItems: "center",
|
|
33
|
-
},
|
|
13
|
+
layout: {},
|
|
34
14
|
props: {
|
|
35
15
|
source: {
|
|
36
16
|
group: GROUPS.data,
|
|
@@ -43,21 +23,5 @@ export const SEED_DATA = {
|
|
|
43
23
|
formType: FORM_TYPES.sourceUrl,
|
|
44
24
|
propType: PROP_TYPES.OBJECT,
|
|
45
25
|
},
|
|
46
|
-
sliderColor: createColorProp({
|
|
47
|
-
label: "Thumb Color",
|
|
48
|
-
defaultValue: "black",
|
|
49
|
-
}),
|
|
50
|
-
completedTrackColor: createColorProp({
|
|
51
|
-
label: "Completed Track Color",
|
|
52
|
-
defaultValue: "white",
|
|
53
|
-
}),
|
|
54
|
-
remainingTrackColor: createColorProp({
|
|
55
|
-
label: "Remaining Track Color",
|
|
56
|
-
defaultValue: "#333333",
|
|
57
|
-
}),
|
|
58
|
-
trackThumbSize: createNumberProp({
|
|
59
|
-
label: "Thumb Size",
|
|
60
|
-
defaultValue: 24,
|
|
61
|
-
}),
|
|
62
26
|
},
|
|
63
27
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { COMPONENT_TYPES, createNumberProp, StylesPanelSections, } from "@draftbit/types";
|
|
2
|
+
export const SEED_DATA = {
|
|
3
|
+
name: "Bottom Sheet",
|
|
4
|
+
tag: "BottomSheet",
|
|
5
|
+
category: COMPONENT_TYPES.container,
|
|
6
|
+
stylesPanelSections: [
|
|
7
|
+
StylesPanelSections.Background,
|
|
8
|
+
StylesPanelSections.Borders,
|
|
9
|
+
StylesPanelSections.Size,
|
|
10
|
+
StylesPanelSections.MarginsAndPaddings,
|
|
11
|
+
StylesPanelSections.Position,
|
|
12
|
+
StylesPanelSections.Effects,
|
|
13
|
+
],
|
|
14
|
+
props: {
|
|
15
|
+
step: createNumberProp({
|
|
16
|
+
label: "Step",
|
|
17
|
+
description: "Step can be -1, 0, 1, or 2.",
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
COMPONENT_TYPES,
|
|
3
|
+
createNumberProp,
|
|
4
|
+
StylesPanelSections,
|
|
5
|
+
} from "@draftbit/types";
|
|
6
|
+
|
|
7
|
+
export const SEED_DATA = {
|
|
8
|
+
name: "Bottom Sheet",
|
|
9
|
+
tag: "BottomSheet",
|
|
10
|
+
category: COMPONENT_TYPES.container,
|
|
11
|
+
stylesPanelSections: [
|
|
12
|
+
StylesPanelSections.Background,
|
|
13
|
+
StylesPanelSections.Borders,
|
|
14
|
+
StylesPanelSections.Size,
|
|
15
|
+
StylesPanelSections.MarginsAndPaddings,
|
|
16
|
+
StylesPanelSections.Position,
|
|
17
|
+
StylesPanelSections.Effects,
|
|
18
|
+
],
|
|
19
|
+
props: {
|
|
20
|
+
step: createNumberProp({
|
|
21
|
+
label: "Step",
|
|
22
|
+
description: "Step can be -1, 0, 1, or 2.",
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
};
|