@draftbit/core 46.10.2-b59d51.2 → 46.10.2-e28eea.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/BottomSheet/BottomSheetComponent.js +127 -111
- package/lib/commonjs/components/FAB.js +4 -18
- package/lib/commonjs/components/Picker/Picker.js +13 -3
- package/lib/commonjs/constants.js +1 -1
- package/lib/commonjs/mappings/FieldSearchBarFull.js +3 -1
- package/lib/module/components/Picker/Picker.js +13 -3
- package/lib/typescript/src/components/Picker/Picker.d.ts.map +1 -1
- package/package.json +3 -4
- package/src/components/Picker/Picker.js +12 -3
- package/src/components/Picker/Picker.tsx +12 -3
|
@@ -10,10 +10,19 @@ var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reani
|
|
|
10
10
|
var _reactNativeGestureHandler = require("react-native-gesture-handler");
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
+
|
|
17
26
|
const {
|
|
18
27
|
//@ts-ignore
|
|
19
28
|
interpolate: interpolateDeprecated,
|
|
@@ -73,85 +82,42 @@ const imperativeScrollOptions = {
|
|
|
73
82
|
}
|
|
74
83
|
};
|
|
75
84
|
class ScrollBottomSheet extends _react.Component {
|
|
76
|
-
/**
|
|
77
|
-
* Gesture Handler references
|
|
78
|
-
*/
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* ScrollView prop
|
|
82
|
-
*/
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Pan gesture handler events for drawer handle and content
|
|
86
|
-
*/
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Main Animated Value that drives the top position of the UI drawer at any point in time
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Animated value that keeps track of the position: 0 => closed, 1 => opened
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Flag to indicate imperative snapping
|
|
98
|
-
*/
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Manual snapping amount
|
|
102
|
-
*/
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Keeps track of the current index
|
|
106
|
-
*/
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Deceleration rate of the scroll component. This is used only on Android to
|
|
110
|
-
* compensate the unexpected glide it gets sometimes.
|
|
111
|
-
*/
|
|
112
|
-
|
|
113
85
|
constructor(props) {
|
|
114
|
-
var
|
|
86
|
+
var _this;
|
|
87
|
+
var _a;
|
|
115
88
|
super(props);
|
|
116
89
|
_this = this;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
_defineProperty(this, "didScrollUpAndPullDown", void 0);
|
|
149
|
-
_defineProperty(this, "setTranslationY", void 0);
|
|
150
|
-
_defineProperty(this, "extraOffset", void 0);
|
|
151
|
-
_defineProperty(this, "calculateNextSnapPoint", void 0);
|
|
152
|
-
_defineProperty(this, "scrollComponent", void 0);
|
|
153
|
-
_defineProperty(this, "convertPercentageToDp", str => Number(str.split("%")[0]) * (windowHeight - this.props.topInset) / 100);
|
|
154
|
-
_defineProperty(this, "getNormalisedSnapPoints", () => {
|
|
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 = () => {
|
|
155
121
|
return this.props.snapPoints.map(p => {
|
|
156
122
|
if (typeof p === "string") {
|
|
157
123
|
return this.convertPercentageToDp(p);
|
|
@@ -160,8 +126,8 @@ class ScrollBottomSheet extends _react.Component {
|
|
|
160
126
|
}
|
|
161
127
|
throw new Error("Invalid type for value ".concat(p, ": ").concat(typeof p, ". It should be either a percentage string or a number"));
|
|
162
128
|
});
|
|
163
|
-
}
|
|
164
|
-
|
|
129
|
+
};
|
|
130
|
+
this.getScrollComponent = () => {
|
|
165
131
|
switch (this.props.componentType) {
|
|
166
132
|
case "FlatList":
|
|
167
133
|
return _reactNative.FlatList;
|
|
@@ -172,33 +138,32 @@ class ScrollBottomSheet extends _react.Component {
|
|
|
172
138
|
default:
|
|
173
139
|
throw new Error("Component type not supported: it should be one of `FlatList`, `ScrollView` or `SectionList`");
|
|
174
140
|
}
|
|
175
|
-
}
|
|
176
|
-
|
|
141
|
+
};
|
|
142
|
+
this.snapTo = index => {
|
|
177
143
|
const snapPoints = this.getNormalisedSnapPoints();
|
|
178
144
|
this.isManuallySetValue.setValue(1);
|
|
179
145
|
this.manualYOffset.setValue(snapPoints[index]);
|
|
180
146
|
this.nextSnapIndex.setValue(index);
|
|
181
|
-
}
|
|
147
|
+
};
|
|
182
148
|
const {
|
|
183
149
|
initialSnapIndex,
|
|
184
150
|
animationType
|
|
185
151
|
} = props;
|
|
186
152
|
const animationDriver = animationType === "timing" ? 0 : 1;
|
|
187
|
-
const animationDuration = props.animationType === "timing" && ((
|
|
153
|
+
const animationDuration = props.animationType === "timing" && ((_a = props.animationConfig) === null || _a === void 0 ? void 0 : _a.duration) || DEFAULT_ANIMATION_DURATION;
|
|
188
154
|
const ScrollComponent = this.getScrollComponent();
|
|
189
155
|
// @ts-ignore
|
|
190
156
|
this.scrollComponent = _reactNativeReanimated.default.createAnimatedComponent(ScrollComponent);
|
|
191
|
-
const
|
|
192
|
-
const openPosition =
|
|
193
|
-
const closedPosition = this.props.enableOverScroll ? windowHeight :
|
|
194
|
-
const initialSnap =
|
|
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];
|
|
195
161
|
this.nextSnapIndex = new _reactNativeReanimated.Value(initialSnapIndex);
|
|
196
162
|
const initialDecelerationRate = _reactNative.Platform.select({
|
|
197
163
|
android: props.initialSnapIndex === 0 ? ANDROID_NORMAL_DECELERATION_RATE : 0,
|
|
198
164
|
ios: IOS_NORMAL_DECELERATION_RATE
|
|
199
165
|
});
|
|
200
166
|
this.decelerationRate = new _reactNativeReanimated.Value(initialDecelerationRate);
|
|
201
|
-
|
|
202
167
|
//@ts-ignore
|
|
203
168
|
const handleGestureState = new _reactNativeReanimated.Value(-1);
|
|
204
169
|
//@ts-ignore
|
|
@@ -237,29 +202,27 @@ class ScrollBottomSheet extends _react.Component {
|
|
|
237
202
|
const didHandleGestureBegin = (0, _reactNativeReanimated.eq)(handleGestureState, _reactNativeGestureHandler.State.ACTIVE);
|
|
238
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));
|
|
239
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)));
|
|
240
|
-
|
|
241
205
|
// Function that determines if the last snap point is in the range {snapPoints}
|
|
242
206
|
// In the case of interruptions in the middle of an animation, we'll get
|
|
243
207
|
// lastSnap values outside the range
|
|
244
208
|
const isLastSnapPointInRange = function () {
|
|
245
209
|
let i = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
246
|
-
return i ===
|
|
210
|
+
return i === snapPoints.length ? lastSnapInRange : (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.eq)(_this.lastSnap, snapPoints[i]), [(0, _reactNativeReanimated.set)(lastSnapInRange, 1)], isLastSnapPointInRange(i + 1));
|
|
247
211
|
};
|
|
248
|
-
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,
|
|
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)(
|
|
249
213
|
// This is to account for a continuous scroll on the drawer from a snap point
|
|
250
214
|
// Different than top, bringing the drawer to the top position, so that if we
|
|
251
215
|
// change scroll direction without releasing the gesture, it doesn't pull down the drawer again
|
|
252
|
-
(0, _reactNativeReanimated.and)((0, _reactNativeReanimated.eq)(this.dragWithHandle, 1), (0, _reactNativeReanimated.greaterThan)(
|
|
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))];
|
|
253
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));
|
|
254
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));
|
|
255
219
|
this.extraOffset = (0, _reactNativeReanimated.cond)((0, _reactNativeReanimated.eq)(this.scrollUpAndPullDown, 1), this.lastStartScrollY, 0);
|
|
256
220
|
const endOffsetY = (0, _reactNativeReanimated.add)(this.lastSnap, this.translationY, (0, _reactNativeReanimated.multiply)(1 - props.friction, this.velocityY));
|
|
257
221
|
this.calculateNextSnapPoint = function () {
|
|
258
222
|
let i = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
259
|
-
return i ===
|
|
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));
|
|
260
224
|
};
|
|
261
225
|
const runAnimation = _ref => {
|
|
262
|
-
var _props$animationConfi2;
|
|
263
226
|
let {
|
|
264
227
|
clock,
|
|
265
228
|
from,
|
|
@@ -269,6 +232,7 @@ class ScrollBottomSheet extends _react.Component {
|
|
|
269
232
|
velocity,
|
|
270
233
|
frameTime
|
|
271
234
|
} = _ref;
|
|
235
|
+
var _a;
|
|
272
236
|
const state = {
|
|
273
237
|
finished,
|
|
274
238
|
velocity: new _reactNativeReanimated.Value(0),
|
|
@@ -278,7 +242,7 @@ class ScrollBottomSheet extends _react.Component {
|
|
|
278
242
|
};
|
|
279
243
|
const timingConfig = {
|
|
280
244
|
duration: animationDuration,
|
|
281
|
-
easing: props.animationType === "timing" && ((
|
|
245
|
+
easing: props.animationType === "timing" && ((_a = props.animationConfig) === null || _a === void 0 ? void 0 : _a.easing) || DEFAULT_EASING,
|
|
282
246
|
toValue: new _reactNativeReanimated.Value(0)
|
|
283
247
|
};
|
|
284
248
|
const springConfig = {
|
|
@@ -294,14 +258,14 @@ class ScrollBottomSheet extends _react.Component {
|
|
|
294
258
|
//@ts-ignore
|
|
295
259
|
(0, _reactNativeReanimated.timing)(clock, state, timingConfig), (0, _reactNativeReanimated.spring)(clock, state, springConfig)), (0, _reactNativeReanimated.cond)(state.finished, [(0, _reactNativeReanimated.call)([this.nextSnapIndex], _ref2 => {
|
|
296
260
|
let [value] = _ref2;
|
|
261
|
+
var _a, _b;
|
|
297
262
|
if (value !== this.prevSnapIndex) {
|
|
298
|
-
|
|
299
|
-
(_this$props$onSettle = (_this$props = this.props).onSettle) === null || _this$props$onSettle === void 0 ? void 0 : _this$props$onSettle.call(_this$props, value);
|
|
263
|
+
(_b = (_a = this.props).onSettle) === null || _b === void 0 ? void 0 : _b.call(_a, value);
|
|
300
264
|
}
|
|
301
265
|
this.prevSnapIndex = value;
|
|
302
266
|
}),
|
|
303
267
|
// Resetting appropriate values
|
|
304
|
-
(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,
|
|
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],
|
|
305
269
|
// We made the block return the updated position,
|
|
306
270
|
state.position)];
|
|
307
271
|
};
|
|
@@ -330,7 +294,7 @@ class ScrollBottomSheet extends _react.Component {
|
|
|
330
294
|
extrapolate: _reactNativeReanimated.Extrapolate.CLAMP
|
|
331
295
|
});
|
|
332
296
|
this.position = interpolate(this.translateY, {
|
|
333
|
-
inputRange: [openPosition,
|
|
297
|
+
inputRange: [openPosition, snapPoints[snapPoints.length - 1]],
|
|
334
298
|
outputRange: [1, 0],
|
|
335
299
|
extrapolate: _reactNativeReanimated.Extrapolate.CLAMP
|
|
336
300
|
});
|
|
@@ -371,26 +335,25 @@ class ScrollBottomSheet extends _react.Component {
|
|
|
371
335
|
ref: this.scrollComponentRef,
|
|
372
336
|
waitFor: this.masterDrawer,
|
|
373
337
|
simultaneousHandlers: this.drawerContentRef
|
|
374
|
-
}, /*#__PURE__*/_react.default.createElement(AnimatedScrollableComponent,
|
|
338
|
+
}, /*#__PURE__*/_react.default.createElement(AnimatedScrollableComponent, {
|
|
375
339
|
overScrollMode: "never",
|
|
376
|
-
bounces: false
|
|
377
|
-
|
|
378
|
-
ref: this.props.innerRef
|
|
340
|
+
bounces: false,
|
|
341
|
+
...rest,
|
|
342
|
+
ref: this.props.innerRef,
|
|
379
343
|
// @ts-ignore
|
|
380
|
-
,
|
|
381
344
|
decelerationRate: this.decelerationRate,
|
|
382
345
|
onScrollBeginDrag: this.onScrollBeginDrag,
|
|
383
346
|
scrollEventThrottle: 1,
|
|
384
347
|
contentContainerStyle: [rest.contentContainerStyle, {
|
|
385
348
|
paddingBottom: this.getNormalisedSnapPoints()[0]
|
|
386
349
|
}]
|
|
387
|
-
}))))
|
|
350
|
+
})))), this.props.animatedPosition && /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.Code, {
|
|
388
351
|
exec: (0, _reactNativeReanimated.onChange)(this.position, (0, _reactNativeReanimated.set)(this.props.animatedPosition, this.position))
|
|
389
352
|
}), /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.Code, {
|
|
390
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)))
|
|
391
354
|
}), /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.Code, {
|
|
392
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)([], () => {
|
|
393
|
-
var
|
|
356
|
+
var _a, _b;
|
|
394
357
|
// This prevents the scroll glide from happening on Android when pulling down with inertia.
|
|
395
358
|
// It's not perfect, but does the job for now
|
|
396
359
|
const {
|
|
@@ -399,14 +362,67 @@ class ScrollBottomSheet extends _react.Component {
|
|
|
399
362
|
} = imperativeScrollOptions[this.props.componentType];
|
|
400
363
|
// @ts-ignore
|
|
401
364
|
const node = this.props.innerRef.current;
|
|
402
|
-
if (node && node[method] && (this.props.componentType === "FlatList" && (((
|
|
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")) {
|
|
403
366
|
node[method](args);
|
|
404
367
|
}
|
|
405
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 => {
|
|
406
|
-
var _this$masterDrawer, _this$masterDrawer$cu;
|
|
407
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;
|
|
408
381
|
// This is the TapGHandler trick
|
|
409
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
|
|
410
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({
|
|
411
427
|
maxDeltaY: value - this.getNormalisedSnapPoints()[0]
|
|
412
428
|
});
|
|
@@ -9,6 +9,7 @@ var _reactNative = require("react-native");
|
|
|
9
9
|
var _theming = require("../theming");
|
|
10
10
|
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); }
|
|
11
11
|
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; }
|
|
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); }
|
|
12
13
|
const FAB = _ref => {
|
|
13
14
|
let {
|
|
14
15
|
onPress,
|
|
@@ -32,7 +33,7 @@ const FAB = _ref => {
|
|
|
32
33
|
borderRadius: size / 2,
|
|
33
34
|
overflow: "hidden"
|
|
34
35
|
}, style]
|
|
35
|
-
}, /*#__PURE__*/React.createElement(_reactNative.Pressable, {
|
|
36
|
+
}, /*#__PURE__*/React.createElement(_reactNative.Pressable, _extends({
|
|
36
37
|
onPress: onPress,
|
|
37
38
|
disabled: loading || disabled,
|
|
38
39
|
android_ripple: {
|
|
@@ -50,9 +51,8 @@ const FAB = _ref => {
|
|
|
50
51
|
borderRadius: size / 2,
|
|
51
52
|
backgroundColor
|
|
52
53
|
}];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
}, /*#__PURE__*/React.createElement(_reactNative.View, null, loading ? /*#__PURE__*/React.createElement(_reactNative.ActivityIndicator, {
|
|
54
|
+
}
|
|
55
|
+
}, props), /*#__PURE__*/React.createElement(_reactNative.View, null, loading ? /*#__PURE__*/React.createElement(_reactNative.ActivityIndicator, {
|
|
56
56
|
style: size > 50 ? {
|
|
57
57
|
marginTop: 2,
|
|
58
58
|
marginLeft: 2
|
|
@@ -79,18 +79,4 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
81
|
var _default = (0, _theming.withTheme)(FAB);
|
|
82
|
-
exports.default = _default; styles = _reactNative.StyleSheet.create({
|
|
83
|
-
button: {
|
|
84
|
-
backgroundColor: "#5a45ff",
|
|
85
|
-
justifyContent: "center",
|
|
86
|
-
alignItems: "center",
|
|
87
|
-
..._reactNative.Platform.select({
|
|
88
|
-
web: {
|
|
89
|
-
cursor: "pointer",
|
|
90
|
-
userSelect: "none"
|
|
91
|
-
}
|
|
92
|
-
})
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
var _default = (0, _theming.withTheme)(FAB);
|
|
96
82
|
exports.default = _default;
|
|
@@ -58,7 +58,7 @@ const Picker = _ref => {
|
|
|
58
58
|
defaultValue,
|
|
59
59
|
Icon,
|
|
60
60
|
style,
|
|
61
|
-
placeholder,
|
|
61
|
+
placeholder = "Select an option",
|
|
62
62
|
value,
|
|
63
63
|
disabled = false,
|
|
64
64
|
assistiveText,
|
|
@@ -99,7 +99,14 @@ const Picker = _ref => {
|
|
|
99
99
|
_reactNative.Keyboard.dismiss();
|
|
100
100
|
}
|
|
101
101
|
}, [pickerVisible, autoDismissKeyboard]);
|
|
102
|
-
const
|
|
102
|
+
const normalizedOptions = normalizeOptions(options);
|
|
103
|
+
|
|
104
|
+
//Underlying Picker component defaults selection to first element when value is not provided (or undefined)
|
|
105
|
+
//Placholder must be the 1st option in order to allow selection of the 'actual' 1st option
|
|
106
|
+
const pickerOptions = placeholder ? [{
|
|
107
|
+
label: placeholder,
|
|
108
|
+
value: placeholder
|
|
109
|
+
}, ...normalizedOptions] : normalizedOptions;
|
|
103
110
|
const {
|
|
104
111
|
viewStyles,
|
|
105
112
|
textStyles
|
|
@@ -199,9 +206,12 @@ const Picker = _ref => {
|
|
|
199
206
|
} : {})
|
|
200
207
|
};
|
|
201
208
|
const handleValueChange = (newValue, itemIndex) => {
|
|
202
|
-
if (newValue !== "") {
|
|
209
|
+
if (newValue !== "" && newValue !== placeholder) {
|
|
203
210
|
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue, itemIndex);
|
|
204
211
|
setInternalValue(newValue);
|
|
212
|
+
} else if (newValue === placeholder) {
|
|
213
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange("", 0);
|
|
214
|
+
setInternalValue(undefined);
|
|
205
215
|
}
|
|
206
216
|
};
|
|
207
217
|
return (
|
|
@@ -12,4 +12,4 @@ const APPROX_STATUSBAR_HEIGHT = _reactNative.Platform.select({
|
|
|
12
12
|
android: DEFAULT_STATUSBAR_HEIGHT_EXPO,
|
|
13
13
|
ios: _reactNative.Platform.Version < 11 ? DEFAULT_STATUSBAR_HEIGHT_EXPO : 0
|
|
14
14
|
});
|
|
15
|
-
exports.APPROX_STATUSBAR_HEIGHT = APPROX_STATUSBAR_HEIGHT;
|
|
15
|
+
exports.APPROX_STATUSBAR_HEIGHT = APPROX_STATUSBAR_HEIGHT;AR_HEIGHT;
|
|
@@ -14,7 +14,6 @@ const SEED_DATA = [{
|
|
|
14
14
|
preview_image_url: "{CLOUDINARY_URL}/Field_SearchBar_Full.png",
|
|
15
15
|
supports_list_render: false,
|
|
16
16
|
triggers: [_types.Triggers.OnChange],
|
|
17
|
-
// TODO Triggers.OnSubmit for multiple triggers
|
|
18
17
|
props: {
|
|
19
18
|
icon: {
|
|
20
19
|
group: _types.GROUPS.basic,
|
|
@@ -53,4 +52,7 @@ const SEED_DATA = [{
|
|
|
53
52
|
},
|
|
54
53
|
layout: {}
|
|
55
54
|
}];
|
|
55
|
+
exports.SEED_DATA = SEED_DATA;},
|
|
56
|
+
layout: {}
|
|
57
|
+
}];
|
|
56
58
|
exports.SEED_DATA = SEED_DATA;
|
|
@@ -49,7 +49,7 @@ const Picker = _ref => {
|
|
|
49
49
|
defaultValue,
|
|
50
50
|
Icon,
|
|
51
51
|
style,
|
|
52
|
-
placeholder,
|
|
52
|
+
placeholder = "Select an option",
|
|
53
53
|
value,
|
|
54
54
|
disabled = false,
|
|
55
55
|
assistiveText,
|
|
@@ -90,7 +90,14 @@ const Picker = _ref => {
|
|
|
90
90
|
Keyboard.dismiss();
|
|
91
91
|
}
|
|
92
92
|
}, [pickerVisible, autoDismissKeyboard]);
|
|
93
|
-
const
|
|
93
|
+
const normalizedOptions = normalizeOptions(options);
|
|
94
|
+
|
|
95
|
+
//Underlying Picker component defaults selection to first element when value is not provided (or undefined)
|
|
96
|
+
//Placholder must be the 1st option in order to allow selection of the 'actual' 1st option
|
|
97
|
+
const pickerOptions = placeholder ? [{
|
|
98
|
+
label: placeholder,
|
|
99
|
+
value: placeholder
|
|
100
|
+
}, ...normalizedOptions] : normalizedOptions;
|
|
94
101
|
const {
|
|
95
102
|
viewStyles,
|
|
96
103
|
textStyles
|
|
@@ -190,9 +197,12 @@ const Picker = _ref => {
|
|
|
190
197
|
} : {})
|
|
191
198
|
};
|
|
192
199
|
const handleValueChange = (newValue, itemIndex) => {
|
|
193
|
-
if (newValue !== "") {
|
|
200
|
+
if (newValue !== "" && newValue !== placeholder) {
|
|
194
201
|
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue, itemIndex);
|
|
195
202
|
setInternalValue(newValue);
|
|
203
|
+
} else if (newValue === placeholder) {
|
|
204
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange("", 0);
|
|
205
|
+
setInternalValue(undefined);
|
|
196
206
|
}
|
|
197
207
|
};
|
|
198
208
|
return (
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../../../src/components/Picker/Picker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAKL,SAAS,EACT,SAAS,EAGV,MAAM,cAAc,CAAC;AAStB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAQtD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,oBAAY,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,EAAE,CAAC;IACnC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IAC7B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CACxB,CAAC;;;;
|
|
1
|
+
{"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../../../src/components/Picker/Picker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAKL,SAAS,EACT,SAAS,EAGV,MAAM,cAAc,CAAC;AAStB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAQtD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,oBAAY,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,EAAE,CAAC;IACnC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IAC7B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CACxB,CAAC;;;;AAkbF,wBAAiC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "46.10.2-
|
|
3
|
+
"version": "46.10.2-e28eea.2+e28eea8",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@date-io/date-fns": "^1.3.13",
|
|
43
43
|
"@draftbit/react-theme-provider": "^2.1.1",
|
|
44
|
-
"@draftbit/types": "^46.10.2-
|
|
44
|
+
"@draftbit/types": "^46.10.2-e28eea.2+e28eea8",
|
|
45
45
|
"@material-ui/core": "^4.11.0",
|
|
46
46
|
"@material-ui/pickers": "^3.2.10",
|
|
47
47
|
"@react-native-community/slider": "4.2.3",
|
|
@@ -64,7 +64,6 @@
|
|
|
64
64
|
"react-native-tab-view": "^3.4.0",
|
|
65
65
|
"react-native-typography": "^1.4.1",
|
|
66
66
|
"react-native-web-swiper": "^2.2.3",
|
|
67
|
-
"react-native-web-webview": "^1.0.2",
|
|
68
67
|
"react-native-youtube-iframe": "^2.2.2"
|
|
69
68
|
},
|
|
70
69
|
"devDependencies": {
|
|
@@ -100,5 +99,5 @@
|
|
|
100
99
|
]
|
|
101
100
|
]
|
|
102
101
|
},
|
|
103
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "e28eea886cd9b8dcc27491b215f957b930428968"
|
|
104
103
|
}
|
|
@@ -38,7 +38,7 @@ const disabledColor = "rgb(240, 240, 240)";
|
|
|
38
38
|
const errorColor = "rgba(255, 69, 100, 1)";
|
|
39
39
|
//Empty string for 'value' is treated as a non-value
|
|
40
40
|
//reason: Draftbit uses empty string as initial value for string state*/
|
|
41
|
-
const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder, value, disabled = false, assistiveText, label, iconColor = unstyledColor, iconSize = 24, leftIconMode = "inset", leftIconName, placeholderTextColor = unstyledColor, rightIconName, type = "solid", autoDismissKeyboard = true, }) => {
|
|
41
|
+
const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder = "Select an option", value, disabled = false, assistiveText, label, iconColor = unstyledColor, iconSize = 24, leftIconMode = "inset", leftIconName, placeholderTextColor = unstyledColor, rightIconName, type = "solid", autoDismissKeyboard = true, }) => {
|
|
42
42
|
var _a, _b;
|
|
43
43
|
const androidPickerRef = React.useRef(undefined);
|
|
44
44
|
const [internalValue, setInternalValue] = React.useState(value || defaultValue);
|
|
@@ -67,7 +67,12 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
67
67
|
Keyboard.dismiss();
|
|
68
68
|
}
|
|
69
69
|
}, [pickerVisible, autoDismissKeyboard]);
|
|
70
|
-
const
|
|
70
|
+
const normalizedOptions = normalizeOptions(options);
|
|
71
|
+
//Underlying Picker component defaults selection to first element when value is not provided (or undefined)
|
|
72
|
+
//Placholder must be the 1st option in order to allow selection of the 'actual' 1st option
|
|
73
|
+
const pickerOptions = placeholder
|
|
74
|
+
? [{ label: placeholder, value: placeholder }, ...normalizedOptions]
|
|
75
|
+
: normalizedOptions;
|
|
71
76
|
const { viewStyles, textStyles } = extractStyles(style);
|
|
72
77
|
const additionalBorderStyles = ["backgroundColor"];
|
|
73
78
|
const additionalMarginStyles = [
|
|
@@ -162,10 +167,14 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
162
167
|
...(disabled ? { color: unstyledColor } : {}),
|
|
163
168
|
};
|
|
164
169
|
const handleValueChange = (newValue, itemIndex) => {
|
|
165
|
-
if (newValue !== "") {
|
|
170
|
+
if (newValue !== "" && newValue !== placeholder) {
|
|
166
171
|
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue, itemIndex);
|
|
167
172
|
setInternalValue(newValue);
|
|
168
173
|
}
|
|
174
|
+
else if (newValue === placeholder) {
|
|
175
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange("", 0);
|
|
176
|
+
setInternalValue(undefined);
|
|
177
|
+
}
|
|
169
178
|
};
|
|
170
179
|
return (
|
|
171
180
|
/* marginsContainer */
|
|
@@ -101,7 +101,7 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
101
101
|
defaultValue,
|
|
102
102
|
Icon,
|
|
103
103
|
style,
|
|
104
|
-
placeholder,
|
|
104
|
+
placeholder = "Select an option",
|
|
105
105
|
value,
|
|
106
106
|
disabled = false,
|
|
107
107
|
assistiveText,
|
|
@@ -151,7 +151,13 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
151
151
|
}
|
|
152
152
|
}, [pickerVisible, autoDismissKeyboard]);
|
|
153
153
|
|
|
154
|
-
const
|
|
154
|
+
const normalizedOptions = normalizeOptions(options);
|
|
155
|
+
|
|
156
|
+
//Underlying Picker component defaults selection to first element when value is not provided (or undefined)
|
|
157
|
+
//Placholder must be the 1st option in order to allow selection of the 'actual' 1st option
|
|
158
|
+
const pickerOptions = placeholder
|
|
159
|
+
? [{ label: placeholder, value: placeholder }, ...normalizedOptions]
|
|
160
|
+
: normalizedOptions;
|
|
155
161
|
|
|
156
162
|
const { viewStyles, textStyles } = extractStyles(style);
|
|
157
163
|
|
|
@@ -302,9 +308,12 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
302
308
|
};
|
|
303
309
|
|
|
304
310
|
const handleValueChange = (newValue: string, itemIndex: number) => {
|
|
305
|
-
if (newValue !== "") {
|
|
311
|
+
if (newValue !== "" && newValue !== placeholder) {
|
|
306
312
|
onValueChange?.(newValue, itemIndex);
|
|
307
313
|
setInternalValue(newValue);
|
|
314
|
+
} else if (newValue === placeholder) {
|
|
315
|
+
onValueChange?.("", 0);
|
|
316
|
+
setInternalValue(undefined);
|
|
308
317
|
}
|
|
309
318
|
};
|
|
310
319
|
|