@draftbit/core 46.9.1-310331.2 → 46.9.1-4cfcf2.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 (54) hide show
  1. package/lib/commonjs/components/BottomSheet/BottomSheet.js +89 -0
  2. package/lib/commonjs/components/BottomSheet/BottomSheetComponent.js +464 -0
  3. package/lib/commonjs/components/BottomSheet/index.js +13 -0
  4. package/lib/commonjs/components/Checkbox/CheckboxGroup.js +17 -2
  5. package/lib/commonjs/components/Checkbox/CheckboxRow.js +6 -23
  6. package/lib/commonjs/components/CircleImage.js +15 -1
  7. package/lib/commonjs/components/Container.js +4 -15
  8. package/lib/commonjs/components/DeprecatedFAB.js +3 -21
  9. package/lib/commonjs/components/NumberInput.js +3 -12
  10. package/lib/commonjs/components/Picker/PickerComponent.web.js +3 -20
  11. package/lib/commonjs/components/RadioButton/RadioButtonRow.js +5 -23
  12. package/lib/commonjs/constants.js +1 -1
  13. package/lib/commonjs/index.js +7 -7
  14. package/lib/commonjs/mappings/BottomSheet.js +75 -0
  15. package/lib/commonjs/mappings/FieldSearchBarFull.js +3 -1
  16. package/lib/commonjs/styles/overlay.js +1 -3
  17. package/lib/module/components/BottomSheet/BottomSheet.js +81 -0
  18. package/lib/module/components/BottomSheet/BottomSheetComponent.js +470 -0
  19. package/lib/module/components/BottomSheet/index.js +1 -0
  20. package/lib/module/index.js +1 -1
  21. package/lib/module/mappings/BottomSheet.js +68 -0
  22. package/lib/typescript/src/components/BottomSheet/BottomSheet.d.ts +20 -0
  23. package/lib/typescript/src/components/BottomSheet/BottomSheet.d.ts.map +1 -0
  24. package/lib/typescript/src/components/BottomSheet/BottomSheetComponent.d.ts +170 -0
  25. package/lib/typescript/src/components/BottomSheet/BottomSheetComponent.d.ts.map +1 -0
  26. package/lib/typescript/src/components/BottomSheet/index.d.ts +2 -0
  27. package/lib/typescript/src/components/BottomSheet/index.d.ts.map +1 -0
  28. package/lib/typescript/src/index.d.ts +1 -1
  29. package/lib/typescript/src/index.d.ts.map +1 -1
  30. package/lib/typescript/src/mappings/BottomSheet.d.ts +120 -0
  31. package/lib/typescript/src/mappings/BottomSheet.d.ts.map +1 -0
  32. package/package.json +6 -6
  33. package/src/components/BottomSheet/BottomSheet.js +57 -0
  34. package/src/components/BottomSheet/BottomSheet.tsx +121 -0
  35. package/src/components/BottomSheet/BottomSheetComponent.js +437 -0
  36. package/src/components/BottomSheet/BottomSheetComponent.tsx +895 -0
  37. package/src/components/BottomSheet/index.js +1 -0
  38. package/src/components/BottomSheet/index.ts +1 -0
  39. package/src/index.js +1 -1
  40. package/src/index.tsx +1 -1
  41. package/src/mappings/BottomSheet.js +64 -0
  42. package/src/mappings/BottomSheet.ts +78 -0
  43. package/lib/commonjs/components/YotubePlayer.js +0 -37
  44. package/lib/commonjs/mappings/YoutubePlayer.js +0 -44
  45. package/lib/module/components/YotubePlayer.js +0 -29
  46. package/lib/module/mappings/YoutubePlayer.js +0 -37
  47. package/lib/typescript/src/components/YotubePlayer.d.ts +0 -12
  48. package/lib/typescript/src/components/YotubePlayer.d.ts.map +0 -1
  49. package/lib/typescript/src/mappings/YoutubePlayer.d.ts +0 -37
  50. package/lib/typescript/src/mappings/YoutubePlayer.d.ts.map +0 -1
  51. package/src/components/YotubePlayer.js +0 -9
  52. package/src/components/YotubePlayer.tsx +0 -37
  53. package/src/mappings/YoutubePlayer.js +0 -37
  54. package/src/mappings/YoutubePlayer.ts +0 -43
@@ -0,0 +1,470 @@
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
+ 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; }
3
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
4
+ 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); }
5
+ /**
6
+ * Slightly modfied version as taken from https://github.com/rgommezz/react-native-scroll-bottom-sheet
7
+ * Main previously breaking change:
8
+ * const node = this.props.innerRef.current?.getNode() ==> const node = this.props.innerRef.current as any
9
+ */
10
+
11
+ /**
12
+ * Copyright (c) 2020 Raul Gomez Acuna
13
+ *
14
+ * This source code is licensed under the MIT license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ *
17
+ */
18
+
19
+ import React, { Component } from "react";
20
+ import { Dimensions, FlatList, Platform, ScrollView, SectionList, StyleSheet, View } from "react-native";
21
+ import Animated, { abs, add, and, call, Clock, clockRunning, cond, Easing as EasingDeprecated,
22
+ // @ts-ignore: this property is only present in Reanimated 2
23
+ EasingNode, eq, event, Extrapolate, greaterOrEq, greaterThan, multiply, not, onChange, or, set, startClock, stopClock, sub, spring, timing, Value } from "react-native-reanimated";
24
+ import { NativeViewGestureHandler, PanGestureHandler, State as GestureState, TapGestureHandler } from "react-native-gesture-handler";
25
+ const {
26
+ //@ts-ignore
27
+ interpolate: interpolateDeprecated,
28
+ // @ts-ignore: this property is only present in Reanimated 2
29
+ interpolateNode
30
+ } = Animated;
31
+ const interpolate = interpolateNode !== null && interpolateNode !== void 0 ? interpolateNode : interpolateDeprecated;
32
+ //@ts-ignore
33
+ const Easing = EasingNode !== null && EasingNode !== void 0 ? EasingNode : EasingDeprecated;
34
+ const FlatListComponentType = "FlatList";
35
+ const ScrollViewComponentType = "ScrollView";
36
+ const SectionListComponentType = "SectionList";
37
+ const TimingAnimationType = "timing";
38
+ const SpringAnimationType = "spring";
39
+ const DEFAULT_SPRING_PARAMS = {
40
+ damping: 50,
41
+ mass: 0.3,
42
+ stiffness: 121.6,
43
+ overshootClamping: true,
44
+ restSpeedThreshold: 0.3,
45
+ restDisplacementThreshold: 0.3
46
+ };
47
+ const {
48
+ height: windowHeight
49
+ } = Dimensions.get("window");
50
+ const IOS_NORMAL_DECELERATION_RATE = 0.998;
51
+ const ANDROID_NORMAL_DECELERATION_RATE = 0.985;
52
+ const DEFAULT_ANIMATION_DURATION = 250;
53
+ const DEFAULT_EASING = Easing.inOut(Easing.linear);
54
+ const imperativeScrollOptions = {
55
+ [FlatListComponentType]: {
56
+ method: "scrollToIndex",
57
+ args: {
58
+ index: 0,
59
+ viewPosition: 0,
60
+ viewOffset: 1000,
61
+ animated: true
62
+ }
63
+ },
64
+ [ScrollViewComponentType]: {
65
+ method: "scrollTo",
66
+ args: {
67
+ x: 0,
68
+ y: 0,
69
+ animated: true
70
+ }
71
+ },
72
+ [SectionListComponentType]: {
73
+ method: "scrollToLocation",
74
+ args: {
75
+ itemIndex: 0,
76
+ sectionIndex: 0,
77
+ viewPosition: 0,
78
+ viewOffset: 1000,
79
+ animated: true
80
+ }
81
+ }
82
+ };
83
+ export class ScrollBottomSheet extends Component {
84
+ /**
85
+ * Gesture Handler references
86
+ */
87
+
88
+ /**
89
+ * ScrollView prop
90
+ */
91
+
92
+ /**
93
+ * Pan gesture handler events for drawer handle and content
94
+ */
95
+
96
+ /**
97
+ * Main Animated Value that drives the top position of the UI drawer at any point in time
98
+ */
99
+
100
+ /**
101
+ * Animated value that keeps track of the position: 0 => closed, 1 => opened
102
+ */
103
+
104
+ /**
105
+ * Flag to indicate imperative snapping
106
+ */
107
+
108
+ /**
109
+ * Manual snapping amount
110
+ */
111
+
112
+ /**
113
+ * Keeps track of the current index
114
+ */
115
+
116
+ /**
117
+ * Deceleration rate of the scroll component. This is used only on Android to
118
+ * compensate the unexpected glide it gets sometimes.
119
+ */
120
+
121
+ constructor(props) {
122
+ var _props$animationConfi, _this;
123
+ super(props);
124
+ _this = this;
125
+ _defineProperty(this, "masterDrawer", /*#__PURE__*/React.createRef());
126
+ _defineProperty(this, "drawerHandleRef", /*#__PURE__*/React.createRef());
127
+ _defineProperty(this, "drawerContentRef", /*#__PURE__*/React.createRef());
128
+ _defineProperty(this, "scrollComponentRef", /*#__PURE__*/React.createRef());
129
+ _defineProperty(this, "onScrollBeginDrag", void 0);
130
+ _defineProperty(this, "onHandleGestureEvent", void 0);
131
+ _defineProperty(this, "onDrawerGestureEvent", void 0);
132
+ _defineProperty(this, "translateY", void 0);
133
+ _defineProperty(this, "position", void 0);
134
+ _defineProperty(this, "isManuallySetValue", new Value(0));
135
+ _defineProperty(this, "manualYOffset", new Value(0));
136
+ _defineProperty(this, "nextSnapIndex", void 0);
137
+ _defineProperty(this, "decelerationRate", void 0);
138
+ _defineProperty(this, "prevSnapIndex", -1);
139
+ _defineProperty(this, "dragY", new Value(0));
140
+ _defineProperty(this, "prevDragY", new Value(0));
141
+ _defineProperty(this, "tempDestSnapPoint", new Value(0));
142
+ _defineProperty(this, "isAndroid", new Value(Number(Platform.OS === "android")));
143
+ _defineProperty(this, "animationClock", new Clock());
144
+ _defineProperty(this, "animationPosition", new Value(0));
145
+ _defineProperty(this, "animationFinished", new Value(0));
146
+ _defineProperty(this, "animationFrameTime", new Value(0));
147
+ _defineProperty(this, "velocityY", new Value(0));
148
+ _defineProperty(this, "lastStartScrollY", new Value(0));
149
+ _defineProperty(this, "prevTranslateYOffset", void 0);
150
+ _defineProperty(this, "translationY", void 0);
151
+ _defineProperty(this, "destSnapPoint", new Value(0));
152
+ _defineProperty(this, "lastSnap", void 0);
153
+ _defineProperty(this, "dragWithHandle", new Value(0));
154
+ _defineProperty(this, "scrollUpAndPullDown", new Value(0));
155
+ _defineProperty(this, "didGestureFinish", void 0);
156
+ _defineProperty(this, "didScrollUpAndPullDown", void 0);
157
+ _defineProperty(this, "setTranslationY", void 0);
158
+ _defineProperty(this, "extraOffset", void 0);
159
+ _defineProperty(this, "calculateNextSnapPoint", void 0);
160
+ _defineProperty(this, "scrollComponent", void 0);
161
+ _defineProperty(this, "convertPercentageToDp", str => Number(str.split("%")[0]) * (windowHeight - this.props.topInset) / 100);
162
+ _defineProperty(this, "getNormalisedSnapPoints", () => {
163
+ return this.props.snapPoints.map(p => {
164
+ if (typeof p === "string") {
165
+ return this.convertPercentageToDp(p);
166
+ } else if (typeof p === "number") {
167
+ return p;
168
+ }
169
+ throw new Error("Invalid type for value ".concat(p, ": ").concat(typeof p, ". It should be either a percentage string or a number"));
170
+ });
171
+ });
172
+ _defineProperty(this, "getScrollComponent", () => {
173
+ switch (this.props.componentType) {
174
+ case "FlatList":
175
+ return FlatList;
176
+ case "ScrollView":
177
+ return ScrollView;
178
+ case "SectionList":
179
+ return SectionList;
180
+ default:
181
+ throw new Error("Component type not supported: it should be one of `FlatList`, `ScrollView` or `SectionList`");
182
+ }
183
+ });
184
+ _defineProperty(this, "snapTo", index => {
185
+ const snapPoints = this.getNormalisedSnapPoints();
186
+ this.isManuallySetValue.setValue(1);
187
+ this.manualYOffset.setValue(snapPoints[index]);
188
+ this.nextSnapIndex.setValue(index);
189
+ });
190
+ const {
191
+ initialSnapIndex,
192
+ animationType
193
+ } = props;
194
+ const animationDriver = animationType === "timing" ? 0 : 1;
195
+ const animationDuration = props.animationType === "timing" && ((_props$animationConfi = props.animationConfig) === null || _props$animationConfi === void 0 ? void 0 : _props$animationConfi.duration) || DEFAULT_ANIMATION_DURATION;
196
+ const ScrollComponent = this.getScrollComponent();
197
+ // @ts-ignore
198
+ this.scrollComponent = Animated.createAnimatedComponent(ScrollComponent);
199
+ const _snapPoints = this.getNormalisedSnapPoints();
200
+ const openPosition = _snapPoints[0];
201
+ const closedPosition = this.props.enableOverScroll ? windowHeight : _snapPoints[_snapPoints.length - 1];
202
+ const initialSnap = _snapPoints[initialSnapIndex];
203
+ this.nextSnapIndex = new Value(initialSnapIndex);
204
+ const initialDecelerationRate = Platform.select({
205
+ android: props.initialSnapIndex === 0 ? ANDROID_NORMAL_DECELERATION_RATE : 0,
206
+ ios: IOS_NORMAL_DECELERATION_RATE
207
+ });
208
+ this.decelerationRate = new Value(initialDecelerationRate);
209
+
210
+ //@ts-ignore
211
+ const handleGestureState = new Value(-1);
212
+ //@ts-ignore
213
+ const handleOldGestureState = new Value(-1);
214
+ //@ts-ignore
215
+ const drawerGestureState = new Value(-1);
216
+ //@ts-ignore
217
+ const drawerOldGestureState = new Value(-1);
218
+ const lastSnapInRange = new Value(1);
219
+ this.prevTranslateYOffset = new Value(initialSnap);
220
+ this.translationY = new Value(initialSnap);
221
+ this.lastSnap = new Value(initialSnap);
222
+ this.onHandleGestureEvent = event([{
223
+ nativeEvent: {
224
+ translationY: this.dragY,
225
+ oldState: handleOldGestureState,
226
+ state: handleGestureState,
227
+ velocityY: this.velocityY
228
+ }
229
+ }]);
230
+ this.onDrawerGestureEvent = event([{
231
+ nativeEvent: {
232
+ translationY: this.dragY,
233
+ oldState: drawerOldGestureState,
234
+ state: drawerGestureState,
235
+ velocityY: this.velocityY
236
+ }
237
+ }]);
238
+ this.onScrollBeginDrag = event([{
239
+ nativeEvent: {
240
+ contentOffset: {
241
+ y: this.lastStartScrollY
242
+ }
243
+ }
244
+ }]);
245
+ const didHandleGestureBegin = eq(handleGestureState, GestureState.ACTIVE);
246
+ const isAnimationInterrupted = and(or(eq(handleGestureState, GestureState.BEGAN), eq(drawerGestureState, GestureState.BEGAN), and(eq(this.isAndroid, 0), eq(animationDriver, 1), or(eq(drawerGestureState, GestureState.ACTIVE), eq(handleGestureState, GestureState.ACTIVE)))), clockRunning(this.animationClock));
247
+ this.didGestureFinish = or(and(eq(handleOldGestureState, GestureState.ACTIVE), eq(handleGestureState, GestureState.END)), and(eq(drawerOldGestureState, GestureState.ACTIVE), eq(drawerGestureState, GestureState.END)));
248
+
249
+ // Function that determines if the last snap point is in the range {snapPoints}
250
+ // In the case of interruptions in the middle of an animation, we'll get
251
+ // lastSnap values outside the range
252
+ const isLastSnapPointInRange = function () {
253
+ let i = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
254
+ return i === _snapPoints.length ? lastSnapInRange : cond(eq(_this.lastSnap, _snapPoints[i]), [set(lastSnapInRange, 1)], isLastSnapPointInRange(i + 1));
255
+ };
256
+ const scrollY = [set(lastSnapInRange, 0), isLastSnapPointInRange(), cond(or(didHandleGestureBegin, and(this.isManuallySetValue, not(eq(this.manualYOffset, _snapPoints[0])))), [set(this.dragWithHandle, 1), 0]), cond(
257
+ // This is to account for a continuous scroll on the drawer from a snap point
258
+ // Different than top, bringing the drawer to the top position, so that if we
259
+ // change scroll direction without releasing the gesture, it doesn't pull down the drawer again
260
+ and(eq(this.dragWithHandle, 1), greaterThan(_snapPoints[0], add(this.lastSnap, this.dragY)), and(not(eq(this.lastSnap, _snapPoints[0])), lastSnapInRange)), [set(this.lastSnap, _snapPoints[0]), set(this.dragWithHandle, 0), this.lastStartScrollY], cond(eq(this.dragWithHandle, 1), 0, this.lastStartScrollY))];
261
+ this.didScrollUpAndPullDown = cond(and(greaterOrEq(this.dragY, this.lastStartScrollY), greaterThan(this.lastStartScrollY, 0)), set(this.scrollUpAndPullDown, 1));
262
+ this.setTranslationY = cond(and(not(this.dragWithHandle), not(greaterOrEq(this.dragY, this.lastStartScrollY))), set(this.translationY, sub(this.dragY, this.lastStartScrollY)), set(this.translationY, this.dragY));
263
+ this.extraOffset = cond(eq(this.scrollUpAndPullDown, 1), this.lastStartScrollY, 0);
264
+ const endOffsetY = add(this.lastSnap, this.translationY, multiply(1 - props.friction, this.velocityY));
265
+ this.calculateNextSnapPoint = function () {
266
+ let i = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
267
+ return i === _snapPoints.length ? _this.tempDestSnapPoint : cond(greaterThan(abs(sub(_this.tempDestSnapPoint, endOffsetY)), abs(sub(add(_snapPoints[i], _this.extraOffset), endOffsetY))), [set(_this.tempDestSnapPoint, add(_snapPoints[i], _this.extraOffset)), set(_this.nextSnapIndex, i), _this.calculateNextSnapPoint(i + 1)], _this.calculateNextSnapPoint(i + 1));
268
+ };
269
+ const runAnimation = _ref => {
270
+ var _props$animationConfi2;
271
+ let {
272
+ clock,
273
+ from,
274
+ to,
275
+ position,
276
+ finished,
277
+ velocity,
278
+ frameTime
279
+ } = _ref;
280
+ const state = {
281
+ finished,
282
+ velocity: new Value(0),
283
+ position,
284
+ time: new Value(0),
285
+ frameTime
286
+ };
287
+ const timingConfig = {
288
+ duration: animationDuration,
289
+ easing: props.animationType === "timing" && ((_props$animationConfi2 = props.animationConfig) === null || _props$animationConfi2 === void 0 ? void 0 : _props$animationConfi2.easing) || DEFAULT_EASING,
290
+ toValue: new Value(0)
291
+ };
292
+ const springConfig = {
293
+ ...DEFAULT_SPRING_PARAMS,
294
+ ...(props.animationType === "spring" && props.animationConfig || {}),
295
+ toValue: new Value(0)
296
+ };
297
+ return [cond(and(not(clockRunning(clock)), not(eq(finished, 1))), [
298
+ // If the clock isn't running, we reset all the animation params and start the clock
299
+ set(state.finished, 0), set(state.velocity, velocity), set(state.time, 0), set(state.position, from), set(state.frameTime, 0), set(timingConfig.toValue, to), set(springConfig.toValue, to), startClock(clock)]),
300
+ // We run the step here that is going to update position
301
+ cond(eq(animationDriver, 0),
302
+ //@ts-ignore
303
+ timing(clock, state, timingConfig), spring(clock, state, springConfig)), cond(state.finished, [call([this.nextSnapIndex], _ref2 => {
304
+ let [value] = _ref2;
305
+ if (value !== this.prevSnapIndex) {
306
+ var _this$props$onSettle, _this$props;
307
+ (_this$props$onSettle = (_this$props = this.props).onSettle) === null || _this$props$onSettle === void 0 ? void 0 : _this$props$onSettle.call(_this$props, value);
308
+ }
309
+ this.prevSnapIndex = value;
310
+ }),
311
+ // Resetting appropriate values
312
+ set(drawerOldGestureState, GestureState.END), set(handleOldGestureState, GestureState.END), set(this.prevTranslateYOffset, state.position), cond(eq(this.scrollUpAndPullDown, 1), [set(this.prevTranslateYOffset, sub(this.prevTranslateYOffset, this.lastStartScrollY)), set(this.lastStartScrollY, 0), set(this.scrollUpAndPullDown, 0)]), cond(eq(this.destSnapPoint, _snapPoints[0]), [set(this.dragWithHandle, 0)]), set(this.isManuallySetValue, 0), set(this.manualYOffset, 0), stopClock(clock), this.prevTranslateYOffset],
313
+ // We made the block return the updated position,
314
+ state.position)];
315
+ };
316
+ const translateYOffset = cond(isAnimationInterrupted, [
317
+ // set(prevTranslateYOffset, animationPosition) should only run if we are
318
+ // interrupting an animation when the drawer is currently in a different
319
+ // position than the top
320
+ cond(or(this.dragWithHandle, greaterOrEq(abs(this.prevDragY), this.lastStartScrollY)), set(this.prevTranslateYOffset, this.animationPosition)), set(this.animationFinished, 1), set(this.translationY, 0),
321
+ // Resetting appropriate values
322
+ set(drawerOldGestureState, GestureState.END), set(handleOldGestureState, GestureState.END),
323
+ // By forcing that frameTime exceeds duration, it has the effect of stopping the animation
324
+ set(this.animationFrameTime, add(animationDuration, 1000)), set(this.velocityY, 0), stopClock(this.animationClock), this.prevTranslateYOffset], cond(or(this.didGestureFinish, this.isManuallySetValue, clockRunning(this.animationClock)), [runAnimation({
325
+ clock: this.animationClock,
326
+ from: cond(this.isManuallySetValue, this.prevTranslateYOffset, add(this.prevTranslateYOffset, this.translationY)),
327
+ to: this.destSnapPoint,
328
+ position: this.animationPosition,
329
+ finished: this.animationFinished,
330
+ frameTime: this.animationFrameTime,
331
+ velocity: this.velocityY
332
+ })], [set(this.animationFrameTime, 0), set(this.animationFinished, 0),
333
+ // @ts-ignore
334
+ this.prevTranslateYOffset]));
335
+ this.translateY = interpolate(add(translateYOffset, this.dragY, multiply(scrollY, -1)), {
336
+ inputRange: [openPosition, closedPosition],
337
+ outputRange: [openPosition, closedPosition],
338
+ extrapolate: Extrapolate.CLAMP
339
+ });
340
+ this.position = interpolate(this.translateY, {
341
+ inputRange: [openPosition, _snapPoints[_snapPoints.length - 1]],
342
+ outputRange: [1, 0],
343
+ extrapolate: Extrapolate.CLAMP
344
+ });
345
+ }
346
+ render() {
347
+ const {
348
+ renderHandle,
349
+ initialSnapIndex,
350
+ containerStyle,
351
+ ...rest
352
+ } = this.props;
353
+ const AnimatedScrollableComponent = this.scrollComponent;
354
+ const normalisedSnapPoints = this.getNormalisedSnapPoints();
355
+ const initialSnap = normalisedSnapPoints[initialSnapIndex];
356
+ const Content = /*#__PURE__*/React.createElement(Animated.View, {
357
+ style: [StyleSheet.absoluteFillObject, containerStyle,
358
+ // @ts-ignore
359
+ {
360
+ transform: [{
361
+ translateY: this.translateY
362
+ }]
363
+ }]
364
+ }, /*#__PURE__*/React.createElement(PanGestureHandler, {
365
+ ref: this.drawerHandleRef,
366
+ shouldCancelWhenOutside: false,
367
+ simultaneousHandlers: this.masterDrawer,
368
+ onGestureEvent: this.onHandleGestureEvent,
369
+ onHandlerStateChange: this.onHandleGestureEvent
370
+ }, /*#__PURE__*/React.createElement(Animated.View, null, renderHandle())), /*#__PURE__*/React.createElement(PanGestureHandler, {
371
+ ref: this.drawerContentRef,
372
+ simultaneousHandlers: [this.scrollComponentRef, this.masterDrawer],
373
+ shouldCancelWhenOutside: false,
374
+ onGestureEvent: this.onDrawerGestureEvent,
375
+ onHandlerStateChange: this.onDrawerGestureEvent
376
+ }, /*#__PURE__*/React.createElement(Animated.View, {
377
+ style: styles.container
378
+ }, /*#__PURE__*/React.createElement(NativeViewGestureHandler, {
379
+ ref: this.scrollComponentRef,
380
+ waitFor: this.masterDrawer,
381
+ simultaneousHandlers: this.drawerContentRef
382
+ }, /*#__PURE__*/React.createElement(AnimatedScrollableComponent, _extends({
383
+ overScrollMode: "never",
384
+ bounces: false
385
+ }, rest, {
386
+ ref: this.props.innerRef
387
+ // @ts-ignore
388
+ ,
389
+ decelerationRate: this.decelerationRate,
390
+ onScrollBeginDrag: this.onScrollBeginDrag,
391
+ scrollEventThrottle: 1,
392
+ contentContainerStyle: [rest.contentContainerStyle, {
393
+ paddingBottom: this.getNormalisedSnapPoints()[0]
394
+ }]
395
+ }))))), this.props.animatedPosition && /*#__PURE__*/React.createElement(Animated.Code, {
396
+ exec: onChange(this.position, set(this.props.animatedPosition, this.position))
397
+ }), /*#__PURE__*/React.createElement(Animated.Code, {
398
+ exec: onChange(this.dragY, cond(not(eq(this.dragY, 0)), set(this.prevDragY, this.dragY)))
399
+ }), /*#__PURE__*/React.createElement(Animated.Code, {
400
+ exec: onChange(this.didGestureFinish, cond(this.didGestureFinish, [this.didScrollUpAndPullDown, this.setTranslationY, set(this.tempDestSnapPoint, add(normalisedSnapPoints[0], this.extraOffset)), set(this.nextSnapIndex, 0), set(this.destSnapPoint, this.calculateNextSnapPoint()), cond(and(greaterThan(this.dragY, this.lastStartScrollY), this.isAndroid, not(this.dragWithHandle)), call([], () => {
401
+ var _this$props2, _this$props2$data;
402
+ // This prevents the scroll glide from happening on Android when pulling down with inertia.
403
+ // It's not perfect, but does the job for now
404
+ const {
405
+ method,
406
+ args
407
+ } = imperativeScrollOptions[this.props.componentType];
408
+ // @ts-ignore
409
+ const node = this.props.innerRef.current;
410
+ if (node && node[method] && (this.props.componentType === "FlatList" && (((_this$props2 = this.props) === null || _this$props2 === void 0 ? void 0 : (_this$props2$data = _this$props2.data) === null || _this$props2$data === void 0 ? void 0 : _this$props2$data.length) || 0) > 0 || this.props.componentType === "SectionList" && this.props.sections.length > 0 || this.props.componentType === "ScrollView")) {
411
+ node[method](args);
412
+ }
413
+ })), set(this.dragY, 0), set(this.velocityY, 0), set(this.lastSnap, sub(this.destSnapPoint, cond(eq(this.scrollUpAndPullDown, 1), this.lastStartScrollY, 0))), call([this.lastSnap], _ref3 => {
414
+ var _this$masterDrawer, _this$masterDrawer$cu;
415
+ let [value] = _ref3;
416
+ // This is the TapGHandler trick
417
+ // @ts-ignore
418
+ (_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({
419
+ maxDeltaY: value - this.getNormalisedSnapPoints()[0]
420
+ });
421
+ }), set(this.decelerationRate, cond(eq(this.isAndroid, 1), cond(eq(this.lastSnap, normalisedSnapPoints[0]), ANDROID_NORMAL_DECELERATION_RATE, 0), IOS_NORMAL_DECELERATION_RATE))]))
422
+ }), /*#__PURE__*/React.createElement(Animated.Code, {
423
+ exec: onChange(this.isManuallySetValue, [cond(this.isManuallySetValue, [set(this.destSnapPoint, this.manualYOffset), set(this.animationFinished, 0), set(this.lastSnap, this.manualYOffset), call([this.lastSnap], _ref4 => {
424
+ var _this$masterDrawer2, _this$masterDrawer2$c;
425
+ let [value] = _ref4;
426
+ // This is the TapGHandler trick
427
+ // @ts-ignore
428
+ (_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({
429
+ maxDeltaY: value - this.getNormalisedSnapPoints()[0]
430
+ });
431
+ })], [set(this.nextSnapIndex, 0)])])
432
+ }));
433
+
434
+ // On Android, having an intermediary view with pointerEvents="box-none", breaks the
435
+ // waitFor logic
436
+ if (Platform.OS === "android") {
437
+ return /*#__PURE__*/React.createElement(TapGestureHandler, {
438
+ maxDurationMs: 100000,
439
+ ref: this.masterDrawer,
440
+ maxDeltaY: initialSnap - this.getNormalisedSnapPoints()[0],
441
+ shouldCancelWhenOutside: false
442
+ }, Content);
443
+ }
444
+
445
+ // On iOS, We need to wrap the content on a view with PointerEvents box-none
446
+ // So that we can start scrolling automatically when reaching the top without
447
+ // Stopping the gesture
448
+ return /*#__PURE__*/React.createElement(TapGestureHandler, {
449
+ maxDurationMs: 100000,
450
+ ref: this.masterDrawer,
451
+ maxDeltaY: initialSnap - this.getNormalisedSnapPoints()[0]
452
+ }, /*#__PURE__*/React.createElement(View, {
453
+ style: StyleSheet.absoluteFillObject,
454
+ pointerEvents: "box-none"
455
+ }, Content));
456
+ }
457
+ }
458
+ _defineProperty(ScrollBottomSheet, "defaultProps", {
459
+ topInset: 0,
460
+ friction: 0.95,
461
+ animationType: "timing",
462
+ innerRef: /*#__PURE__*/React.createRef(),
463
+ enableOverScroll: false
464
+ });
465
+ export default ScrollBottomSheet;
466
+ const styles = StyleSheet.create({
467
+ container: {
468
+ flex: 1
469
+ }
470
+ });
@@ -0,0 +1 @@
1
+ export { default as BottomSheet } from "./BottomSheet";
@@ -35,7 +35,7 @@ export { default as Shadow } from "./components/Shadow";
35
35
  export { DeckSwiper, DeckSwiperCard } from "./components/DeckSwiper";
36
36
  export { TabView, TabViewItem } from "./components/TabView";
37
37
  export { default as Markdown } from "./components/Markdown";
38
- export { default as YoutubePlayer } from "./components/YotubePlayer";
38
+ export { BottomSheet } from "./components/BottomSheet";
39
39
 
40
40
  /* Deprecated: Fix or Delete! */
41
41
  export { default as DatePicker } from "./components/DatePicker/DatePicker";
@@ -0,0 +1,68 @@
1
+ import { COMPONENT_TYPES, createStaticBoolProp, CONTAINER_COMPONENT_STYLES_SECTIONS, Triggers, createActionProp, createColorProp, createStaticArrayProp, createStaticNumberProp } from "@draftbit/types";
2
+ export const SEED_DATA = {
3
+ name: "Bottom Sheet",
4
+ tag: "BottomSheet",
5
+ description: "A draggable Bottom sheet that snaps to specific points. Renders children in ScrollView",
6
+ category: COMPONENT_TYPES.bottomsheet,
7
+ stylesPanelSections: CONTAINER_COMPONENT_STYLES_SECTIONS,
8
+ layout: {
9
+ paddingHorizontal: 16,
10
+ paddingVertical: 10,
11
+ flex: 1
12
+ },
13
+ triggers: [Triggers.OnSettle],
14
+ props: {
15
+ onSettle: createActionProp({
16
+ label: "On settle",
17
+ description: "Action to execute when sheet settles on a snap point"
18
+ }),
19
+ snapPoints: createStaticArrayProp({
20
+ label: "Snap points",
21
+ description: "An array of numerical values (that represent distance from the top) where bottom sheet can snap to place. Accepts numbers and percentages (minimum 2 snap points)",
22
+ defaultValue: ["10%", "50%", "80%"]
23
+ }),
24
+ initialSnapIndex: createStaticNumberProp({
25
+ label: "Initial snap index",
26
+ description: "Index of the snap point to be used as the initial point",
27
+ defaultValue: 0,
28
+ required: false
29
+ }),
30
+ showHandle: createStaticBoolProp({
31
+ label: "Show handle",
32
+ description: "Whether to show the top handle or not",
33
+ defaultValue: true
34
+ }),
35
+ handleColor: createColorProp({
36
+ label: "Handle color",
37
+ description: "Color of the top handle",
38
+ defaultValue: "divider"
39
+ }),
40
+ topBorderRadius: createStaticNumberProp({
41
+ label: "Top border radius",
42
+ description: "Border radius of top corners",
43
+ defaultValue: 20,
44
+ required: false
45
+ }),
46
+ borderWidth: createStaticNumberProp({
47
+ label: "Border width",
48
+ description: "Width of bottom sheet borders",
49
+ defaultValue: 1,
50
+ required: false
51
+ }),
52
+ borderColor: createColorProp({
53
+ label: "Border color",
54
+ description: "Color of bottom sheet borders",
55
+ defaultValue: "divider"
56
+ }),
57
+ showsVerticalScrollIndicator: createStaticBoolProp({
58
+ label: "Show Vertical Scroll Indicator",
59
+ description: "When true, shows a vertical scroll indicator. The default value is true.",
60
+ defaultValue: true
61
+ }),
62
+ bounces: createStaticBoolProp({
63
+ label: "Bounce",
64
+ description: "When true, the scroll view bounces when it reaches the end of the content if the content is larger then the scroll view along the axis of the scroll direction.",
65
+ defaultValue: true
66
+ })
67
+ }
68
+ };
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import { StyleProp, ViewStyle, ScrollViewProps } from "react-native";
3
+ import type { Theme } from "../../styles/DefaultTheme";
4
+ export interface BottomSheetProps extends ScrollViewProps {
5
+ snapPoints?: (string | number)[];
6
+ initialSnapIndex?: number;
7
+ showHandle?: boolean;
8
+ handleColor?: string;
9
+ topBorderRadius?: number;
10
+ borderWidth?: number;
11
+ borderColor?: string;
12
+ onSettle?: (index: number) => void;
13
+ style?: StyleProp<ViewStyle>;
14
+ theme: Theme;
15
+ }
16
+ declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<React.PropsWithChildren<BottomSheetProps>, "theme"> & {
17
+ theme?: import("@draftbit/react-theme-provider").$DeepPartial<any> | undefined;
18
+ }> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<React.PropsWithChildren<BottomSheetProps>> & React.FC<React.PropsWithChildren<BottomSheetProps>>, {}>;
19
+ export default _default;
20
+ //# sourceMappingURL=BottomSheet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BottomSheet.d.ts","sourceRoot":"","sources":["../../../../../src/components/BottomSheet/BottomSheet.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAGL,SAAS,EACT,SAAS,EACT,eAAe,EAChB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAGvD,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,UAAU,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,KAAK,EAAE,KAAK,CAAC;CACd;;;;AAgGD,wBAAsC"}