@draftbit/core 46.8.2-fee87c.2 → 46.9.1-01e871.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 (80) 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/CircleImage.js +15 -1
  5. package/lib/commonjs/components/Markdown.js +30 -0
  6. package/lib/commonjs/components/Shadow.js +46 -0
  7. package/lib/commonjs/components/TabView/TabView.js +22 -6
  8. package/lib/commonjs/index.js +21 -0
  9. package/lib/commonjs/mappings/BottomSheet.js +75 -0
  10. package/lib/commonjs/mappings/FlashList.js +2 -8
  11. package/lib/commonjs/mappings/Markdown.js +27 -0
  12. package/lib/commonjs/mappings/Shadow.js +102 -0
  13. package/lib/commonjs/mappings/TabView.js +6 -5
  14. package/lib/commonjs/mappings/TabViewItem.js +5 -3
  15. package/lib/module/components/BottomSheet/BottomSheet.js +81 -0
  16. package/lib/module/components/BottomSheet/BottomSheetComponent.js +470 -0
  17. package/lib/module/components/BottomSheet/index.js +1 -0
  18. package/lib/module/components/Markdown.js +20 -0
  19. package/lib/module/components/Shadow.js +38 -0
  20. package/lib/module/components/TabView/TabView.js +22 -5
  21. package/lib/module/index.js +3 -0
  22. package/lib/module/mappings/BottomSheet.js +68 -0
  23. package/lib/module/mappings/FlashList.js +3 -9
  24. package/lib/module/mappings/Markdown.js +20 -0
  25. package/lib/module/mappings/Shadow.js +95 -0
  26. package/lib/module/mappings/TabView.js +7 -6
  27. package/lib/module/mappings/TabViewItem.js +6 -4
  28. package/lib/typescript/src/components/BottomSheet/BottomSheet.d.ts +20 -0
  29. package/lib/typescript/src/components/BottomSheet/BottomSheet.d.ts.map +1 -0
  30. package/lib/typescript/src/components/BottomSheet/BottomSheetComponent.d.ts +170 -0
  31. package/lib/typescript/src/components/BottomSheet/BottomSheetComponent.d.ts.map +1 -0
  32. package/lib/typescript/src/components/BottomSheet/index.d.ts +2 -0
  33. package/lib/typescript/src/components/BottomSheet/index.d.ts.map +1 -0
  34. package/lib/typescript/src/components/Markdown.d.ts +8 -0
  35. package/lib/typescript/src/components/Markdown.d.ts.map +1 -0
  36. package/lib/typescript/src/components/Shadow.d.ts +24 -0
  37. package/lib/typescript/src/components/Shadow.d.ts.map +1 -0
  38. package/lib/typescript/src/components/TabView/TabView.d.ts.map +1 -1
  39. package/lib/typescript/src/components/TabView/TabViewItem.d.ts +1 -1
  40. package/lib/typescript/src/components/TabView/TabViewItem.d.ts.map +1 -1
  41. package/lib/typescript/src/index.d.ts +3 -0
  42. package/lib/typescript/src/index.d.ts.map +1 -1
  43. package/lib/typescript/src/mappings/BottomSheet.d.ts +120 -0
  44. package/lib/typescript/src/mappings/BottomSheet.d.ts.map +1 -0
  45. package/lib/typescript/src/mappings/FlashList.d.ts +0 -6
  46. package/lib/typescript/src/mappings/FlashList.d.ts.map +1 -1
  47. package/lib/typescript/src/mappings/Markdown.d.ts +20 -0
  48. package/lib/typescript/src/mappings/Markdown.d.ts.map +1 -0
  49. package/lib/typescript/src/mappings/Shadow.d.ts +173 -0
  50. package/lib/typescript/src/mappings/Shadow.d.ts.map +1 -0
  51. package/lib/typescript/src/mappings/TabView.d.ts.map +1 -1
  52. package/lib/typescript/src/mappings/TabViewItem.d.ts.map +1 -1
  53. package/package.json +6 -3
  54. package/src/components/BottomSheet/BottomSheet.js +57 -0
  55. package/src/components/BottomSheet/BottomSheet.tsx +121 -0
  56. package/src/components/BottomSheet/BottomSheetComponent.js +437 -0
  57. package/src/components/BottomSheet/BottomSheetComponent.tsx +895 -0
  58. package/src/components/BottomSheet/index.js +1 -0
  59. package/src/components/BottomSheet/index.ts +1 -0
  60. package/src/components/Markdown.js +10 -0
  61. package/src/components/Markdown.tsx +22 -0
  62. package/src/components/Shadow.js +16 -0
  63. package/src/components/Shadow.tsx +62 -0
  64. package/src/components/TabView/TabView.js +16 -7
  65. package/src/components/TabView/TabView.tsx +25 -7
  66. package/src/components/TabView/TabViewItem.tsx +1 -1
  67. package/src/index.js +3 -0
  68. package/src/index.tsx +5 -0
  69. package/src/mappings/BottomSheet.js +64 -0
  70. package/src/mappings/BottomSheet.ts +78 -0
  71. package/src/mappings/FlashList.js +9 -9
  72. package/src/mappings/FlashList.ts +9 -9
  73. package/src/mappings/Markdown.js +25 -0
  74. package/src/mappings/Markdown.ts +32 -0
  75. package/src/mappings/Shadow.js +95 -0
  76. package/src/mappings/Shadow.ts +104 -0
  77. package/src/mappings/TabView.js +11 -5
  78. package/src/mappings/TabView.ts +11 -5
  79. package/src/mappings/TabViewItem.js +4 -2
  80. package/src/mappings/TabViewItem.ts +4 -1
@@ -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";
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+ import { StyleSheet } from "react-native";
3
+ import MarkdownComponent from "react-native-markdown-display";
4
+ const Markdown = _ref => {
5
+ let {
6
+ children,
7
+ style
8
+ } = _ref;
9
+ return (
10
+ /*#__PURE__*/
11
+ //'body' style applies to all markdown components
12
+ //@ts-ignore TS does not like the type of this named style for some reason
13
+ React.createElement(MarkdownComponent, {
14
+ style: {
15
+ body: StyleSheet.flatten(style)
16
+ }
17
+ }, children)
18
+ );
19
+ };
20
+ export default Markdown;
@@ -0,0 +1,38 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ import React from "react";
3
+ import { Shadow as ShadowComponent } from "react-native-shadow-2";
4
+ const Shadow = _ref => {
5
+ let {
6
+ offsetX = 0,
7
+ offsetY = 0,
8
+ showShadowSideStart = true,
9
+ showShadowSideEnd = true,
10
+ showShadowSideTop = true,
11
+ showShadowSideBottom = true,
12
+ showShadowCornerTopStart = true,
13
+ showShadowCornerTopEnd = true,
14
+ showShadowCornerBottomStart = true,
15
+ showShadowCornerBottomEnd = true,
16
+ paintInside = false,
17
+ style,
18
+ ...rest
19
+ } = _ref;
20
+ return /*#__PURE__*/React.createElement(ShadowComponent, _extends({
21
+ offset: [offsetX, offsetY],
22
+ sides: {
23
+ start: showShadowSideStart,
24
+ end: showShadowSideEnd,
25
+ top: showShadowSideTop,
26
+ bottom: showShadowSideBottom
27
+ },
28
+ corners: {
29
+ topStart: showShadowCornerTopStart,
30
+ topEnd: showShadowCornerTopEnd,
31
+ bottomStart: showShadowCornerBottomStart,
32
+ bottomEnd: showShadowCornerBottomEnd
33
+ },
34
+ containerStyle: style,
35
+ paintInside: paintInside
36
+ }, rest));
37
+ };
38
+ export default Shadow;
@@ -1,8 +1,8 @@
1
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
2
  import * as React from "react";
3
3
  import { TabView, TabBar, SceneMap } from "react-native-tab-view";
4
- import TabViewItem from "./TabViewItem";
5
4
  import { withTheme } from "../../theming";
5
+ import { extractStyles } from "../../utilities";
6
6
  const TabViewComponent = _ref => {
7
7
  let {
8
8
  Icon,
@@ -24,12 +24,22 @@ const TabViewComponent = _ref => {
24
24
  const [index, setIndex] = React.useState(0);
25
25
  const [routes, setRoutes] = React.useState([]);
26
26
  const [tabScenes, setTabScenes] = React.useState({});
27
+ const {
28
+ textStyles,
29
+ viewStyles
30
+ } = extractStyles(style);
31
+
32
+ //Check type of child using props
33
+ //Regular '.type' cannot work because Draftbit strips the type in Draft view
34
+ const instanceOfTabViewItemProps = object => {
35
+ return "title" in object;
36
+ };
27
37
 
28
38
  //Populate routes and scenes based on children
29
39
  React.useEffect(() => {
30
40
  const newRoutes = [];
31
41
  const scenes = {};
32
- React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && child.type === TabViewItem).forEach((item, idx) => {
42
+ React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && instanceOfTabViewItemProps(child.props)).forEach((item, idx) => {
33
43
  const child = item;
34
44
  newRoutes.push({
35
45
  key: idx.toString(),
@@ -58,6 +68,7 @@ const TabViewComponent = _ref => {
58
68
  indicatorStyle: {
59
69
  backgroundColor: indicatorColor || theme.colors.primary
60
70
  },
71
+ labelStyle: textStyles,
61
72
  renderIcon: _ref2 => {
62
73
  let {
63
74
  route,
@@ -66,15 +77,21 @@ const TabViewComponent = _ref => {
66
77
  return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
67
78
  name: route.icon,
68
79
  color: color,
69
- size: 36
80
+ size: 16
70
81
  }) : null;
71
82
  },
72
- style: [{
83
+ style: {
73
84
  backgroundColor: tabsBackgroundColor || theme.colors.background
74
- }, style]
85
+ }
75
86
  }));
76
87
  };
88
+
89
+ //Cannot render TabView without at least one tab
90
+ if (!routes.length) {
91
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
92
+ }
77
93
  return /*#__PURE__*/React.createElement(TabView, {
94
+ style: [viewStyles],
78
95
  navigationState: {
79
96
  index,
80
97
  routes
@@ -31,8 +31,11 @@ export { ActionSheet, ActionSheetItem, ActionSheetCancel } from "./components/Ac
31
31
  export { Swiper, SwiperItem } from "./components/Swiper";
32
32
  export { Center, Circle, Square, Row, Stack, Spacer } from "./components/Layout";
33
33
  export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup } from "./components/RadioButton/index";
34
+ export { default as Shadow } from "./components/Shadow";
34
35
  export { DeckSwiper, DeckSwiperCard } from "./components/DeckSwiper";
35
36
  export { TabView, TabViewItem } from "./components/TabView";
37
+ export { default as Markdown } from "./components/Markdown";
38
+ export { BottomSheet } from "./components/BottomSheet";
36
39
 
37
40
  /* Deprecated: Fix or Delete! */
38
41
  export { default as DatePicker } from "./components/DatePicker/DatePicker";