@draftbit/core 46.9.1-1cf4d4.2 → 46.9.1-1f5cbe.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/lib/commonjs/components/BottomSheet/BottomSheet.js +88 -0
  2. package/lib/commonjs/components/BottomSheet/BottomSheetComponent.js +480 -0
  3. package/lib/commonjs/components/BottomSheet/index.js +13 -0
  4. package/lib/commonjs/components/CircleImage.js +15 -1
  5. package/lib/commonjs/index.js +7 -0
  6. package/lib/commonjs/mappings/BottomSheet.js +74 -0
  7. package/lib/module/components/BottomSheet/BottomSheet.js +80 -0
  8. package/lib/module/components/BottomSheet/BottomSheetComponent.js +470 -0
  9. package/lib/module/components/BottomSheet/index.js +1 -0
  10. package/lib/module/index.js +1 -0
  11. package/lib/module/mappings/BottomSheet.js +67 -0
  12. package/lib/typescript/src/components/BottomSheet/BottomSheet.d.ts +20 -0
  13. package/lib/typescript/src/components/BottomSheet/BottomSheet.d.ts.map +1 -0
  14. package/lib/typescript/src/components/BottomSheet/BottomSheetComponent.d.ts +170 -0
  15. package/lib/typescript/src/components/BottomSheet/BottomSheetComponent.d.ts.map +1 -0
  16. package/lib/typescript/src/components/BottomSheet/index.d.ts +2 -0
  17. package/lib/typescript/src/components/BottomSheet/index.d.ts.map +1 -0
  18. package/lib/typescript/src/index.d.ts +1 -0
  19. package/lib/typescript/src/index.d.ts.map +1 -1
  20. package/lib/typescript/src/mappings/BottomSheet.d.ts +119 -0
  21. package/lib/typescript/src/mappings/BottomSheet.d.ts.map +1 -0
  22. package/package.json +5 -3
  23. package/src/components/BottomSheet/BottomSheet.js +56 -0
  24. package/src/components/BottomSheet/BottomSheet.tsx +120 -0
  25. package/src/components/BottomSheet/BottomSheetComponent.js +437 -0
  26. package/src/components/BottomSheet/BottomSheetComponent.tsx +895 -0
  27. package/src/components/BottomSheet/index.js +1 -0
  28. package/src/components/BottomSheet/index.ts +1 -0
  29. package/src/index.js +1 -0
  30. package/src/index.tsx +2 -0
  31. package/src/mappings/BottomSheet.js +64 -0
  32. package/src/mappings/BottomSheet.ts +78 -0
@@ -0,0 +1,88 @@
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
+ var _BottomSheetComponent = _interopRequireDefault(require("./BottomSheetComponent"));
10
+ var _theming = require("../../theming");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
13
+ const BottomSheet = _ref => {
14
+ let {
15
+ theme,
16
+ snapPoints = ["10%", "50%", "80%"],
17
+ initialSnapIndex = 0,
18
+ showHandle = true,
19
+ handleColor = theme.colors.divider,
20
+ topBorderRadius = 20,
21
+ borderWidth = 1,
22
+ borderColor = theme.colors.divider,
23
+ onSettle,
24
+ style,
25
+ children,
26
+ ...rest
27
+ } = _ref;
28
+ const backgroundColor = (style === null || style === void 0 ? void 0 : style.backgroundColor) || theme.colors.background;
29
+ return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
30
+ style: styles.parentContainer,
31
+ pointerEvents: "box-none"
32
+ }, /*#__PURE__*/_react.default.createElement(_BottomSheetComponent.default, _extends({
33
+ componentType: "ScrollView",
34
+ snapPoints: snapPoints,
35
+ initialSnapIndex: initialSnapIndex,
36
+ renderHandle: () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, showHandle && /*#__PURE__*/_react.default.createElement(_reactNative.View, {
37
+ style: [styles.handleContainer, {
38
+ backgroundColor,
39
+ borderTopLeftRadius: topBorderRadius,
40
+ borderTopRightRadius: topBorderRadius
41
+ }]
42
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
43
+ style: [styles.handle, {
44
+ backgroundColor: handleColor
45
+ }]
46
+ }))),
47
+ contentContainerStyle: [styles.contentContainerStyle, style],
48
+ containerStyle: _reactNative.StyleSheet.flatten([styles.containerStyle, {
49
+ backgroundColor,
50
+ borderTopLeftRadius: topBorderRadius,
51
+ borderTopRightRadius: topBorderRadius,
52
+ borderWidth,
53
+ borderColor
54
+ }]),
55
+ onSettle: onSettle
56
+ }, rest), children));
57
+ };
58
+ const styles = _reactNative.StyleSheet.create({
59
+ //Render on top of everything
60
+ parentContainer: {
61
+ position: "absolute",
62
+ left: 0,
63
+ right: 0,
64
+ top: 0,
65
+ bottom: 0,
66
+ zIndex: 10,
67
+ overflow: "hidden"
68
+ },
69
+ contentContainerStyle: {
70
+ paddingHorizontal: 16,
71
+ paddingVertical: 10
72
+ },
73
+ containerStyle: {
74
+ flex: 1,
75
+ overflow: "hidden"
76
+ },
77
+ handleContainer: {
78
+ alignItems: "center",
79
+ paddingVertical: 20
80
+ },
81
+ handle: {
82
+ width: 40,
83
+ height: 2,
84
+ borderRadius: 4
85
+ }
86
+ });
87
+ var _default = (0, _theming.withTheme)(BottomSheet);
88
+ exports.default = _default;
@@ -0,0 +1,480 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.ScrollBottomSheet = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
10
+ var _reactNativeGestureHandler = require("react-native-gesture-handler");
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
+ 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
+ /**
14
+ * Slightly modfied version as taken from https://github.com/rgommezz/react-native-scroll-bottom-sheet
15
+ * Main previously breaking change:
16
+ * const node = this.props.innerRef.current?.getNode() ==> const node = this.props.innerRef.current as any
17
+ */
18
+ /**
19
+ * Copyright (c) 2020 Raul Gomez Acuna
20
+ *
21
+ * This source code is licensed under the MIT license found in the
22
+ * LICENSE file in the root directory of this source tree.
23
+ *
24
+ */
25
+
26
+ const {
27
+ //@ts-ignore
28
+ interpolate: interpolateDeprecated,
29
+ // @ts-ignore: this property is only present in Reanimated 2
30
+ interpolateNode
31
+ } = _reactNativeReanimated.default;
32
+ const interpolate = interpolateNode !== null && interpolateNode !== void 0 ? interpolateNode : interpolateDeprecated;
33
+ //@ts-ignore
34
+ const Easing = _reactNativeReanimated.EasingNode !== null && _reactNativeReanimated.EasingNode !== void 0 ? _reactNativeReanimated.EasingNode : _reactNativeReanimated.Easing;
35
+ const FlatListComponentType = "FlatList";
36
+ const ScrollViewComponentType = "ScrollView";
37
+ const SectionListComponentType = "SectionList";
38
+ const TimingAnimationType = "timing";
39
+ const SpringAnimationType = "spring";
40
+ const DEFAULT_SPRING_PARAMS = {
41
+ damping: 50,
42
+ mass: 0.3,
43
+ stiffness: 121.6,
44
+ overshootClamping: true,
45
+ restSpeedThreshold: 0.3,
46
+ restDisplacementThreshold: 0.3
47
+ };
48
+ const {
49
+ height: windowHeight
50
+ } = _reactNative.Dimensions.get("window");
51
+ const IOS_NORMAL_DECELERATION_RATE = 0.998;
52
+ const ANDROID_NORMAL_DECELERATION_RATE = 0.985;
53
+ const DEFAULT_ANIMATION_DURATION = 250;
54
+ const DEFAULT_EASING = Easing.inOut(Easing.linear);
55
+ const imperativeScrollOptions = {
56
+ [FlatListComponentType]: {
57
+ method: "scrollToIndex",
58
+ args: {
59
+ index: 0,
60
+ viewPosition: 0,
61
+ viewOffset: 1000,
62
+ animated: true
63
+ }
64
+ },
65
+ [ScrollViewComponentType]: {
66
+ method: "scrollTo",
67
+ args: {
68
+ x: 0,
69
+ y: 0,
70
+ animated: true
71
+ }
72
+ },
73
+ [SectionListComponentType]: {
74
+ method: "scrollToLocation",
75
+ args: {
76
+ itemIndex: 0,
77
+ sectionIndex: 0,
78
+ viewPosition: 0,
79
+ viewOffset: 1000,
80
+ animated: true
81
+ }
82
+ }
83
+ };
84
+ class ScrollBottomSheet extends _react.Component {
85
+ constructor(props) {
86
+ var _this;
87
+ var _a;
88
+ super(props);
89
+ _this = this;
90
+ /**
91
+ * Gesture Handler references
92
+ */
93
+ this.masterDrawer = /*#__PURE__*/_react.default.createRef();
94
+ this.drawerHandleRef = /*#__PURE__*/_react.default.createRef();
95
+ this.drawerContentRef = /*#__PURE__*/_react.default.createRef();
96
+ this.scrollComponentRef = /*#__PURE__*/_react.default.createRef();
97
+ /**
98
+ * Flag to indicate imperative snapping
99
+ */
100
+ this.isManuallySetValue = new _reactNativeReanimated.Value(0);
101
+ /**
102
+ * Manual snapping amount
103
+ */
104
+ this.manualYOffset = new _reactNativeReanimated.Value(0);
105
+ this.prevSnapIndex = -1;
106
+ this.dragY = new _reactNativeReanimated.Value(0);
107
+ this.prevDragY = new _reactNativeReanimated.Value(0);
108
+ this.tempDestSnapPoint = new _reactNativeReanimated.Value(0);
109
+ this.isAndroid = new _reactNativeReanimated.Value(Number(_reactNative.Platform.OS === "android"));
110
+ this.animationClock = new _reactNativeReanimated.Clock();
111
+ this.animationPosition = new _reactNativeReanimated.Value(0);
112
+ this.animationFinished = new _reactNativeReanimated.Value(0);
113
+ this.animationFrameTime = new _reactNativeReanimated.Value(0);
114
+ this.velocityY = new _reactNativeReanimated.Value(0);
115
+ this.lastStartScrollY = new _reactNativeReanimated.Value(0);
116
+ this.destSnapPoint = new _reactNativeReanimated.Value(0);
117
+ this.dragWithHandle = new _reactNativeReanimated.Value(0);
118
+ this.scrollUpAndPullDown = new _reactNativeReanimated.Value(0);
119
+ this.convertPercentageToDp = str => Number(str.split("%")[0]) * (windowHeight - this.props.topInset) / 100;
120
+ this.getNormalisedSnapPoints = () => {
121
+ return this.props.snapPoints.map(p => {
122
+ if (typeof p === "string") {
123
+ return this.convertPercentageToDp(p);
124
+ } else if (typeof p === "number") {
125
+ return p;
126
+ }
127
+ throw new Error("Invalid type for value ".concat(p, ": ").concat(typeof p, ". It should be either a percentage string or a number"));
128
+ });
129
+ };
130
+ this.getScrollComponent = () => {
131
+ switch (this.props.componentType) {
132
+ case "FlatList":
133
+ return _reactNative.FlatList;
134
+ case "ScrollView":
135
+ return _reactNative.ScrollView;
136
+ case "SectionList":
137
+ return _reactNative.SectionList;
138
+ default:
139
+ throw new Error("Component type not supported: it should be one of `FlatList`, `ScrollView` or `SectionList`");
140
+ }
141
+ };
142
+ this.snapTo = index => {
143
+ const snapPoints = this.getNormalisedSnapPoints();
144
+ this.isManuallySetValue.setValue(1);
145
+ this.manualYOffset.setValue(snapPoints[index]);
146
+ this.nextSnapIndex.setValue(index);
147
+ };
148
+ const {
149
+ initialSnapIndex,
150
+ animationType
151
+ } = props;
152
+ const animationDriver = animationType === "timing" ? 0 : 1;
153
+ const animationDuration = props.animationType === "timing" && ((_a = props.animationConfig) === null || _a === void 0 ? void 0 : _a.duration) || DEFAULT_ANIMATION_DURATION;
154
+ const ScrollComponent = this.getScrollComponent();
155
+ // @ts-ignore
156
+ this.scrollComponent = _reactNativeReanimated.default.createAnimatedComponent(ScrollComponent);
157
+ const snapPoints = this.getNormalisedSnapPoints();
158
+ const openPosition = snapPoints[0];
159
+ const closedPosition = this.props.enableOverScroll ? windowHeight : snapPoints[snapPoints.length - 1];
160
+ const initialSnap = snapPoints[initialSnapIndex];
161
+ this.nextSnapIndex = new _reactNativeReanimated.Value(initialSnapIndex);
162
+ const initialDecelerationRate = _reactNative.Platform.select({
163
+ android: props.initialSnapIndex === 0 ? ANDROID_NORMAL_DECELERATION_RATE : 0,
164
+ ios: IOS_NORMAL_DECELERATION_RATE
165
+ });
166
+ this.decelerationRate = new _reactNativeReanimated.Value(initialDecelerationRate);
167
+ //@ts-ignore
168
+ const handleGestureState = new _reactNativeReanimated.Value(-1);
169
+ //@ts-ignore
170
+ const handleOldGestureState = new _reactNativeReanimated.Value(-1);
171
+ //@ts-ignore
172
+ const drawerGestureState = new _reactNativeReanimated.Value(-1);
173
+ //@ts-ignore
174
+ const drawerOldGestureState = new _reactNativeReanimated.Value(-1);
175
+ const lastSnapInRange = new _reactNativeReanimated.Value(1);
176
+ this.prevTranslateYOffset = new _reactNativeReanimated.Value(initialSnap);
177
+ this.translationY = new _reactNativeReanimated.Value(initialSnap);
178
+ this.lastSnap = new _reactNativeReanimated.Value(initialSnap);
179
+ this.onHandleGestureEvent = (0, _reactNativeReanimated.event)([{
180
+ nativeEvent: {
181
+ translationY: this.dragY,
182
+ oldState: handleOldGestureState,
183
+ state: handleGestureState,
184
+ velocityY: this.velocityY
185
+ }
186
+ }]);
187
+ this.onDrawerGestureEvent = (0, _reactNativeReanimated.event)([{
188
+ nativeEvent: {
189
+ translationY: this.dragY,
190
+ oldState: drawerOldGestureState,
191
+ state: drawerGestureState,
192
+ velocityY: this.velocityY
193
+ }
194
+ }]);
195
+ this.onScrollBeginDrag = (0, _reactNativeReanimated.event)([{
196
+ nativeEvent: {
197
+ contentOffset: {
198
+ y: this.lastStartScrollY
199
+ }
200
+ }
201
+ }]);
202
+ const didHandleGestureBegin = (0, _reactNativeReanimated.eq)(handleGestureState, _reactNativeGestureHandler.State.ACTIVE);
203
+ const isAnimationInterrupted = (0, _reactNativeReanimated.and)((0, _reactNativeReanimated.or)((0, _reactNativeReanimated.eq)(handleGestureState, _reactNativeGestureHandler.State.BEGAN), (0, _reactNativeReanimated.eq)(drawerGestureState, _reactNativeGestureHandler.State.BEGAN), (0, _reactNativeReanimated.and)((0, _reactNativeReanimated.eq)(this.isAndroid, 0), (0, _reactNativeReanimated.eq)(animationDriver, 1), (0, _reactNativeReanimated.or)((0, _reactNativeReanimated.eq)(drawerGestureState, _reactNativeGestureHandler.State.ACTIVE), (0, _reactNativeReanimated.eq)(handleGestureState, _reactNativeGestureHandler.State.ACTIVE)))), (0, _reactNativeReanimated.clockRunning)(this.animationClock));
204
+ this.didGestureFinish = (0, _reactNativeReanimated.or)((0, _reactNativeReanimated.and)((0, _reactNativeReanimated.eq)(handleOldGestureState, _reactNativeGestureHandler.State.ACTIVE), (0, _reactNativeReanimated.eq)(handleGestureState, _reactNativeGestureHandler.State.END)), (0, _reactNativeReanimated.and)((0, _reactNativeReanimated.eq)(drawerOldGestureState, _reactNativeGestureHandler.State.ACTIVE), (0, _reactNativeReanimated.eq)(drawerGestureState, _reactNativeGestureHandler.State.END)));
205
+ // Function that determines if the last snap point is in the range {snapPoints}
206
+ // In the case of interruptions in the middle of an animation, we'll get
207
+ // lastSnap values outside the range
208
+ const isLastSnapPointInRange = function () {
209
+ let i = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
210
+ return i === snapPoints.length ? lastSnapInRange : (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.eq)(_this.lastSnap, snapPoints[i]), [(0, _reactNativeReanimated.set)(lastSnapInRange, 1)], isLastSnapPointInRange(i + 1));
211
+ };
212
+ const scrollY = [(0, _reactNativeReanimated.set)(lastSnapInRange, 0), isLastSnapPointInRange(), (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.or)(didHandleGestureBegin, (0, _reactNativeReanimated.and)(this.isManuallySetValue, (0, _reactNativeReanimated.not)((0, _reactNativeReanimated.eq)(this.manualYOffset, snapPoints[0])))), [(0, _reactNativeReanimated.set)(this.dragWithHandle, 1), 0]), (0, _reactNativeReanimated.cond)(
213
+ // This is to account for a continuous scroll on the drawer from a snap point
214
+ // Different than top, bringing the drawer to the top position, so that if we
215
+ // change scroll direction without releasing the gesture, it doesn't pull down the drawer again
216
+ (0, _reactNativeReanimated.and)((0, _reactNativeReanimated.eq)(this.dragWithHandle, 1), (0, _reactNativeReanimated.greaterThan)(snapPoints[0], (0, _reactNativeReanimated.add)(this.lastSnap, this.dragY)), (0, _reactNativeReanimated.and)((0, _reactNativeReanimated.not)((0, _reactNativeReanimated.eq)(this.lastSnap, snapPoints[0])), lastSnapInRange)), [(0, _reactNativeReanimated.set)(this.lastSnap, snapPoints[0]), (0, _reactNativeReanimated.set)(this.dragWithHandle, 0), this.lastStartScrollY], (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.eq)(this.dragWithHandle, 1), 0, this.lastStartScrollY))];
217
+ this.didScrollUpAndPullDown = (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.and)((0, _reactNativeReanimated.greaterOrEq)(this.dragY, this.lastStartScrollY), (0, _reactNativeReanimated.greaterThan)(this.lastStartScrollY, 0)), (0, _reactNativeReanimated.set)(this.scrollUpAndPullDown, 1));
218
+ this.setTranslationY = (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.and)((0, _reactNativeReanimated.not)(this.dragWithHandle), (0, _reactNativeReanimated.not)((0, _reactNativeReanimated.greaterOrEq)(this.dragY, this.lastStartScrollY))), (0, _reactNativeReanimated.set)(this.translationY, (0, _reactNativeReanimated.sub)(this.dragY, this.lastStartScrollY)), (0, _reactNativeReanimated.set)(this.translationY, this.dragY));
219
+ this.extraOffset = (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.eq)(this.scrollUpAndPullDown, 1), this.lastStartScrollY, 0);
220
+ const endOffsetY = (0, _reactNativeReanimated.add)(this.lastSnap, this.translationY, (0, _reactNativeReanimated.multiply)(1 - props.friction, this.velocityY));
221
+ this.calculateNextSnapPoint = function () {
222
+ let i = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
223
+ return i === snapPoints.length ? _this.tempDestSnapPoint : (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.greaterThan)((0, _reactNativeReanimated.abs)((0, _reactNativeReanimated.sub)(_this.tempDestSnapPoint, endOffsetY)), (0, _reactNativeReanimated.abs)((0, _reactNativeReanimated.sub)((0, _reactNativeReanimated.add)(snapPoints[i], _this.extraOffset), endOffsetY))), [(0, _reactNativeReanimated.set)(_this.tempDestSnapPoint, (0, _reactNativeReanimated.add)(snapPoints[i], _this.extraOffset)), (0, _reactNativeReanimated.set)(_this.nextSnapIndex, i), _this.calculateNextSnapPoint(i + 1)], _this.calculateNextSnapPoint(i + 1));
224
+ };
225
+ const runAnimation = _ref => {
226
+ let {
227
+ clock,
228
+ from,
229
+ to,
230
+ position,
231
+ finished,
232
+ velocity,
233
+ frameTime
234
+ } = _ref;
235
+ var _a;
236
+ const state = {
237
+ finished,
238
+ velocity: new _reactNativeReanimated.Value(0),
239
+ position,
240
+ time: new _reactNativeReanimated.Value(0),
241
+ frameTime
242
+ };
243
+ const timingConfig = {
244
+ duration: animationDuration,
245
+ easing: props.animationType === "timing" && ((_a = props.animationConfig) === null || _a === void 0 ? void 0 : _a.easing) || DEFAULT_EASING,
246
+ toValue: new _reactNativeReanimated.Value(0)
247
+ };
248
+ const springConfig = {
249
+ ...DEFAULT_SPRING_PARAMS,
250
+ ...(props.animationType === "spring" && props.animationConfig || {}),
251
+ toValue: new _reactNativeReanimated.Value(0)
252
+ };
253
+ return [(0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.and)((0, _reactNativeReanimated.not)((0, _reactNativeReanimated.clockRunning)(clock)), (0, _reactNativeReanimated.not)((0, _reactNativeReanimated.eq)(finished, 1))), [
254
+ // If the clock isn't running, we reset all the animation params and start the clock
255
+ (0, _reactNativeReanimated.set)(state.finished, 0), (0, _reactNativeReanimated.set)(state.velocity, velocity), (0, _reactNativeReanimated.set)(state.time, 0), (0, _reactNativeReanimated.set)(state.position, from), (0, _reactNativeReanimated.set)(state.frameTime, 0), (0, _reactNativeReanimated.set)(timingConfig.toValue, to), (0, _reactNativeReanimated.set)(springConfig.toValue, to), (0, _reactNativeReanimated.startClock)(clock)]),
256
+ // We run the step here that is going to update position
257
+ (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.eq)(animationDriver, 0),
258
+ //@ts-ignore
259
+ (0, _reactNativeReanimated.timing)(clock, state, timingConfig), (0, _reactNativeReanimated.spring)(clock, state, springConfig)), (0, _reactNativeReanimated.cond)(state.finished, [(0, _reactNativeReanimated.call)([this.nextSnapIndex], _ref2 => {
260
+ let [value] = _ref2;
261
+ var _a, _b;
262
+ if (value !== this.prevSnapIndex) {
263
+ (_b = (_a = this.props).onSettle) === null || _b === void 0 ? void 0 : _b.call(_a, value);
264
+ }
265
+ this.prevSnapIndex = value;
266
+ }),
267
+ // Resetting appropriate values
268
+ (0, _reactNativeReanimated.set)(drawerOldGestureState, _reactNativeGestureHandler.State.END), (0, _reactNativeReanimated.set)(handleOldGestureState, _reactNativeGestureHandler.State.END), (0, _reactNativeReanimated.set)(this.prevTranslateYOffset, state.position), (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.eq)(this.scrollUpAndPullDown, 1), [(0, _reactNativeReanimated.set)(this.prevTranslateYOffset, (0, _reactNativeReanimated.sub)(this.prevTranslateYOffset, this.lastStartScrollY)), (0, _reactNativeReanimated.set)(this.lastStartScrollY, 0), (0, _reactNativeReanimated.set)(this.scrollUpAndPullDown, 0)]), (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.eq)(this.destSnapPoint, snapPoints[0]), [(0, _reactNativeReanimated.set)(this.dragWithHandle, 0)]), (0, _reactNativeReanimated.set)(this.isManuallySetValue, 0), (0, _reactNativeReanimated.set)(this.manualYOffset, 0), (0, _reactNativeReanimated.stopClock)(clock), this.prevTranslateYOffset],
269
+ // We made the block return the updated position,
270
+ state.position)];
271
+ };
272
+ const translateYOffset = (0, _reactNativeReanimated.cond)(isAnimationInterrupted, [
273
+ // set(prevTranslateYOffset, animationPosition) should only run if we are
274
+ // interrupting an animation when the drawer is currently in a different
275
+ // position than the top
276
+ (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.or)(this.dragWithHandle, (0, _reactNativeReanimated.greaterOrEq)((0, _reactNativeReanimated.abs)(this.prevDragY), this.lastStartScrollY)), (0, _reactNativeReanimated.set)(this.prevTranslateYOffset, this.animationPosition)), (0, _reactNativeReanimated.set)(this.animationFinished, 1), (0, _reactNativeReanimated.set)(this.translationY, 0),
277
+ // Resetting appropriate values
278
+ (0, _reactNativeReanimated.set)(drawerOldGestureState, _reactNativeGestureHandler.State.END), (0, _reactNativeReanimated.set)(handleOldGestureState, _reactNativeGestureHandler.State.END),
279
+ // By forcing that frameTime exceeds duration, it has the effect of stopping the animation
280
+ (0, _reactNativeReanimated.set)(this.animationFrameTime, (0, _reactNativeReanimated.add)(animationDuration, 1000)), (0, _reactNativeReanimated.set)(this.velocityY, 0), (0, _reactNativeReanimated.stopClock)(this.animationClock), this.prevTranslateYOffset], (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.or)(this.didGestureFinish, this.isManuallySetValue, (0, _reactNativeReanimated.clockRunning)(this.animationClock)), [runAnimation({
281
+ clock: this.animationClock,
282
+ from: (0, _reactNativeReanimated.cond)(this.isManuallySetValue, this.prevTranslateYOffset, (0, _reactNativeReanimated.add)(this.prevTranslateYOffset, this.translationY)),
283
+ to: this.destSnapPoint,
284
+ position: this.animationPosition,
285
+ finished: this.animationFinished,
286
+ frameTime: this.animationFrameTime,
287
+ velocity: this.velocityY
288
+ })], [(0, _reactNativeReanimated.set)(this.animationFrameTime, 0), (0, _reactNativeReanimated.set)(this.animationFinished, 0),
289
+ // @ts-ignore
290
+ this.prevTranslateYOffset]));
291
+ this.translateY = interpolate((0, _reactNativeReanimated.add)(translateYOffset, this.dragY, (0, _reactNativeReanimated.multiply)(scrollY, -1)), {
292
+ inputRange: [openPosition, closedPosition],
293
+ outputRange: [openPosition, closedPosition],
294
+ extrapolate: _reactNativeReanimated.Extrapolate.CLAMP
295
+ });
296
+ this.position = interpolate(this.translateY, {
297
+ inputRange: [openPosition, snapPoints[snapPoints.length - 1]],
298
+ outputRange: [1, 0],
299
+ extrapolate: _reactNativeReanimated.Extrapolate.CLAMP
300
+ });
301
+ }
302
+ render() {
303
+ const {
304
+ renderHandle,
305
+ initialSnapIndex,
306
+ containerStyle,
307
+ ...rest
308
+ } = this.props;
309
+ const AnimatedScrollableComponent = this.scrollComponent;
310
+ const normalisedSnapPoints = this.getNormalisedSnapPoints();
311
+ const initialSnap = normalisedSnapPoints[initialSnapIndex];
312
+ const Content = /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
313
+ style: [_reactNative.StyleSheet.absoluteFillObject, containerStyle,
314
+ // @ts-ignore
315
+ {
316
+ transform: [{
317
+ translateY: this.translateY
318
+ }]
319
+ }]
320
+ }, /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.PanGestureHandler, {
321
+ ref: this.drawerHandleRef,
322
+ shouldCancelWhenOutside: false,
323
+ simultaneousHandlers: this.masterDrawer,
324
+ onGestureEvent: this.onHandleGestureEvent,
325
+ onHandlerStateChange: this.onHandleGestureEvent
326
+ }, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, null, renderHandle())), /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.PanGestureHandler, {
327
+ ref: this.drawerContentRef,
328
+ simultaneousHandlers: [this.scrollComponentRef, this.masterDrawer],
329
+ shouldCancelWhenOutside: false,
330
+ onGestureEvent: this.onDrawerGestureEvent,
331
+ onHandlerStateChange: this.onDrawerGestureEvent
332
+ }, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
333
+ style: styles.container
334
+ }, /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.NativeViewGestureHandler, {
335
+ ref: this.scrollComponentRef,
336
+ waitFor: this.masterDrawer,
337
+ simultaneousHandlers: this.drawerContentRef
338
+ }, /*#__PURE__*/_react.default.createElement(AnimatedScrollableComponent, {
339
+ overScrollMode: "never",
340
+ bounces: false,
341
+ ...rest,
342
+ ref: this.props.innerRef,
343
+ // @ts-ignore
344
+ decelerationRate: this.decelerationRate,
345
+ onScrollBeginDrag: this.onScrollBeginDrag,
346
+ scrollEventThrottle: 1,
347
+ contentContainerStyle: [rest.contentContainerStyle, {
348
+ paddingBottom: this.getNormalisedSnapPoints()[0]
349
+ }]
350
+ })))), this.props.animatedPosition && /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.Code, {
351
+ exec: (0, _reactNativeReanimated.onChange)(this.position, (0, _reactNativeReanimated.set)(this.props.animatedPosition, this.position))
352
+ }), /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.Code, {
353
+ exec: (0, _reactNativeReanimated.onChange)(this.dragY, (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.not)((0, _reactNativeReanimated.eq)(this.dragY, 0)), (0, _reactNativeReanimated.set)(this.prevDragY, this.dragY)))
354
+ }), /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.Code, {
355
+ exec: (0, _reactNativeReanimated.onChange)(this.didGestureFinish, (0, _reactNativeReanimated.cond)(this.didGestureFinish, [this.didScrollUpAndPullDown, this.setTranslationY, (0, _reactNativeReanimated.set)(this.tempDestSnapPoint, (0, _reactNativeReanimated.add)(normalisedSnapPoints[0], this.extraOffset)), (0, _reactNativeReanimated.set)(this.nextSnapIndex, 0), (0, _reactNativeReanimated.set)(this.destSnapPoint, this.calculateNextSnapPoint()), (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.and)((0, _reactNativeReanimated.greaterThan)(this.dragY, this.lastStartScrollY), this.isAndroid, (0, _reactNativeReanimated.not)(this.dragWithHandle)), (0, _reactNativeReanimated.call)([], () => {
356
+ var _a, _b;
357
+ // This prevents the scroll glide from happening on Android when pulling down with inertia.
358
+ // It's not perfect, but does the job for now
359
+ const {
360
+ method,
361
+ args
362
+ } = imperativeScrollOptions[this.props.componentType];
363
+ // @ts-ignore
364
+ const node = this.props.innerRef.current;
365
+ if (node && node[method] && (this.props.componentType === "FlatList" && (((_b = (_a = this.props) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.length) || 0) > 0 || this.props.componentType === "SectionList" && this.props.sections.length > 0 || this.props.componentType === "ScrollView")) {
366
+ node[method](args);
367
+ }
368
+ })), (0, _reactNativeReanimated.set)(this.dragY, 0), (0, _reactNativeReanimated.set)(this.velocityY, 0), (0, _reactNativeReanimated.set)(this.lastSnap, (0, _reactNativeReanimated.sub)(this.destSnapPoint, (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.eq)(this.scrollUpAndPullDown, 1), this.lastStartScrollY, 0))), (0, _reactNativeReanimated.call)([this.lastSnap], _ref3 => {
369
+ let [value] = _ref3;
370
+ var _a, _b;
371
+ // This is the TapGHandler trick
372
+ // @ts-ignore
373
+ (_b = (_a = this.masterDrawer) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.setNativeProps({
374
+ maxDeltaY: value - this.getNormalisedSnapPoints()[0]
375
+ });
376
+ }), (0, _reactNativeReanimated.set)(this.decelerationRate, (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.eq)(this.isAndroid, 1), (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.eq)(this.lastSnap, normalisedSnapPoints[0]), ANDROID_NORMAL_DECELERATION_RATE, 0), IOS_NORMAL_DECELERATION_RATE))]))
377
+ }), /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.Code, {
378
+ exec: (0, _reactNativeReanimated.onChange)(this.isManuallySetValue, [(0, _reactNativeReanimated.cond)(this.isManuallySetValue, [(0, _reactNativeReanimated.set)(this.destSnapPoint, this.manualYOffset), (0, _reactNativeReanimated.set)(this.animationFinished, 0), (0, _reactNativeReanimated.set)(this.lastSnap, this.manualYOffset), (0, _reactNativeReanimated.call)([this.lastSnap], _ref4 => {
379
+ let [value] = _ref4;
380
+ var _a, _b;
381
+ // This is the TapGHandler trick
382
+ // @ts-ignore
383
+ (_b = (_a = this.masterDrawer) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.setNativeProps({
384
+ maxDeltaY: value - this.getNormalisedSnapPoints()[0]
385
+ });
386
+ })], [(0, _reactNativeReanimated.set)(this.nextSnapIndex, 0)])])
387
+ }));
388
+ // On Android, having an intermediary view with pointerEvents="box-none", breaks the
389
+ // waitFor logic
390
+ if (_reactNative.Platform.OS === "android") {
391
+ return /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.TapGestureHandler, {
392
+ maxDurationMs: 100000,
393
+ ref: this.masterDrawer,
394
+ maxDeltaY: initialSnap - this.getNormalisedSnapPoints()[0],
395
+ shouldCancelWhenOutside: false
396
+ }, Content);
397
+ }
398
+ // On iOS, We need to wrap the content on a view with PointerEvents box-none
399
+ // So that we can start scrolling automatically when reaching the top without
400
+ // Stopping the gesture
401
+ return /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.TapGestureHandler, {
402
+ maxDurationMs: 100000,
403
+ ref: this.masterDrawer,
404
+ maxDeltaY: initialSnap - this.getNormalisedSnapPoints()[0]
405
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
406
+ style: _reactNative.StyleSheet.absoluteFillObject,
407
+ pointerEvents: "box-none"
408
+ }, Content));
409
+ }
410
+ }
411
+ exports.ScrollBottomSheet = ScrollBottomSheet;
412
+ ScrollBottomSheet.defaultProps = {
413
+ topInset: 0,
414
+ friction: 0.95,
415
+ animationType: "timing",
416
+ innerRef: /*#__PURE__*/_react.default.createRef(),
417
+ enableOverScroll: false
418
+ };
419
+ var _default = ScrollBottomSheet;
420
+ exports.default = _default;
421
+ const styles = _reactNative.StyleSheet.create({
422
+ container: {
423
+ flex: 1
424
+ }
425
+ }); @ts-ignore
426
+ (_this$masterDrawer = this.masterDrawer) === null || _this$masterDrawer === void 0 ? void 0 : (_this$masterDrawer$cu = _this$masterDrawer.current) === null || _this$masterDrawer$cu === void 0 ? void 0 : _this$masterDrawer$cu.setNativeProps({
427
+ maxDeltaY: value - this.getNormalisedSnapPoints()[0]
428
+ });
429
+ }), (0, _reactNativeReanimated.set)(this.decelerationRate, (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.eq)(this.isAndroid, 1), (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.eq)(this.lastSnap, normalisedSnapPoints[0]), ANDROID_NORMAL_DECELERATION_RATE, 0), IOS_NORMAL_DECELERATION_RATE))]))
430
+ }), /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.Code, {
431
+ exec: (0, _reactNativeReanimated.onChange)(this.isManuallySetValue, [(0, _reactNativeReanimated.cond)(this.isManuallySetValue, [(0, _reactNativeReanimated.set)(this.destSnapPoint, this.manualYOffset), (0, _reactNativeReanimated.set)(this.animationFinished, 0), (0, _reactNativeReanimated.set)(this.lastSnap, this.manualYOffset), (0, _reactNativeReanimated.call)([this.lastSnap], _ref4 => {
432
+ var _this$masterDrawer2, _this$masterDrawer2$c;
433
+ let [value] = _ref4;
434
+ // This is the TapGHandler trick
435
+ // @ts-ignore
436
+ (_this$masterDrawer2 = this.masterDrawer) === null || _this$masterDrawer2 === void 0 ? void 0 : (_this$masterDrawer2$c = _this$masterDrawer2.current) === null || _this$masterDrawer2$c === void 0 ? void 0 : _this$masterDrawer2$c.setNativeProps({
437
+ maxDeltaY: value - this.getNormalisedSnapPoints()[0]
438
+ });
439
+ })], [(0, _reactNativeReanimated.set)(this.nextSnapIndex, 0)])])
440
+ }));
441
+
442
+ // On Android, having an intermediary view with pointerEvents="box-none", breaks the
443
+ // waitFor logic
444
+ if (_reactNative.Platform.OS === "android") {
445
+ return /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.TapGestureHandler, {
446
+ maxDurationMs: 100000,
447
+ ref: this.masterDrawer,
448
+ maxDeltaY: initialSnap - this.getNormalisedSnapPoints()[0],
449
+ shouldCancelWhenOutside: false
450
+ }, Content);
451
+ }
452
+
453
+ // On iOS, We need to wrap the content on a view with PointerEvents box-none
454
+ // So that we can start scrolling automatically when reaching the top without
455
+ // Stopping the gesture
456
+ return /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.TapGestureHandler, {
457
+ maxDurationMs: 100000,
458
+ ref: this.masterDrawer,
459
+ maxDeltaY: initialSnap - this.getNormalisedSnapPoints()[0]
460
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
461
+ style: _reactNative.StyleSheet.absoluteFillObject,
462
+ pointerEvents: "box-none"
463
+ }, Content));
464
+ }
465
+ }
466
+ exports.ScrollBottomSheet = ScrollBottomSheet;
467
+ _defineProperty(ScrollBottomSheet, "defaultProps", {
468
+ topInset: 0,
469
+ friction: 0.95,
470
+ animationType: "timing",
471
+ innerRef: /*#__PURE__*/_react.default.createRef(),
472
+ enableOverScroll: false
473
+ });
474
+ var _default = ScrollBottomSheet;
475
+ exports.default = _default;
476
+ const styles = _reactNative.StyleSheet.create({
477
+ container: {
478
+ flex: 1
479
+ }
480
+ });
@@ -0,0 +1,13 @@
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
+ var _BottomSheet = _interopRequireDefault(require("./BottomSheet"));
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -10,7 +10,6 @@ var _Config = _interopRequireDefault(require("./Config"));
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 _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 CircleImage = _ref => {
15
14
  let {
16
15
  source = _Config.default.placeholderImageURL,
@@ -19,6 +18,21 @@ const CircleImage = _ref => {
19
18
  ...props
20
19
  } = _ref;
21
20
  const borderRadius = size / 2;
21
+ return /*#__PURE__*/React.createElement(_reactNative.Image, {
22
+ style: [{
23
+ width: size,
24
+ height: size,
25
+ borderRadius
26
+ }, style],
27
+ source: typeof source === "string" ? {
28
+ uri: source
29
+ } : source,
30
+ resizeMode: "cover",
31
+ ...props
32
+ });
33
+ };
34
+ var _default = CircleImage;
35
+ exports.default = _default;size / 2;
22
36
  return /*#__PURE__*/React.createElement(_reactNative.Image, _extends({
23
37
  style: [{
24
38
  width: size,
@@ -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 () {
@@ -441,6 +447,7 @@ var _Shadow = _interopRequireDefault(require("./components/Shadow"));
441
447
  var _DeckSwiper = require("./components/DeckSwiper");
442
448
  var _TabView = require("./components/TabView");
443
449
  var _Markdown = _interopRequireDefault(require("./components/Markdown"));
450
+ var _BottomSheet = require("./components/BottomSheet");
444
451
  var _DatePicker = _interopRequireDefault(require("./components/DatePicker/DatePicker"));
445
452
  var _Picker = _interopRequireDefault(require("./components/Picker/Picker"));
446
453
  var _ProgressBar = _interopRequireDefault(require("./components/ProgressBar"));