@jobber/components-native 0.93.0 → 0.94.0

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.
@@ -0,0 +1,41 @@
1
+ import { useCallback, useRef } from "react";
2
+ import { BackHandler, type NativeEventSubscription } from "react-native";
3
+ import type BottomSheet from "@gorhom/bottom-sheet";
4
+
5
+ /**
6
+ * Hook that closes the bottom sheet on the hardware back button press if it is visible
7
+ * @param bottomSheetRef ref to the bottom sheet component
8
+ */
9
+ export function useBottomSheetBackHandler(
10
+ bottomSheetRef: React.RefObject<BottomSheet | null>,
11
+ ): {
12
+ handleSheetPositionChange: (index: number) => void;
13
+ } {
14
+ const backHandlerSubscriptionRef = useRef<NativeEventSubscription | null>(
15
+ null,
16
+ );
17
+
18
+ const handleSheetPositionChange = useCallback(
19
+ (index: number) => {
20
+ const isBottomSheetVisible = index >= 0;
21
+
22
+ if (isBottomSheetVisible && !backHandlerSubscriptionRef.current) {
23
+ // Setup the back handler if the bottom sheet is right in front of the user
24
+ backHandlerSubscriptionRef.current = BackHandler.addEventListener(
25
+ "hardwareBackPress",
26
+ () => {
27
+ bottomSheetRef.current?.close();
28
+
29
+ return true;
30
+ },
31
+ );
32
+ } else if (!isBottomSheetVisible) {
33
+ backHandlerSubscriptionRef.current?.remove();
34
+ backHandlerSubscriptionRef.current = null;
35
+ }
36
+ },
37
+ [bottomSheetRef],
38
+ );
39
+
40
+ return { handleSheetPositionChange };
41
+ }
@@ -126,7 +126,7 @@ export interface InputTextProps
126
126
  /**
127
127
  * Callback that is called when the text input is blurred
128
128
  */
129
- readonly onBlur?: () => void;
129
+ readonly onBlur?: (event?: FocusEvent) => void;
130
130
 
131
131
  /**
132
132
  * VoiceOver will read this string when a user selects the associated element
@@ -436,10 +436,10 @@ function InputTextInternal(
436
436
  setFocused(true);
437
437
  onFocus?.(event);
438
438
  }}
439
- onBlur={() => {
439
+ onBlur={event => {
440
440
  _name && setFocusedInput("");
441
441
  setFocused(false);
442
- onBlur?.();
442
+ onBlur?.(event);
443
443
  field.onBlur();
444
444
  trimWhitespace(inputTransform(field.value), updateFormAndState);
445
445
  }}
@@ -150,6 +150,204 @@ exports[`renders a thumbnail component with attachments 1`] = `
150
150
  "top": 0,
151
151
  }
152
152
  }
153
- />,
153
+ >
154
+ <View
155
+ backdropComponent={[Function]}
156
+ backgroundStyle={
157
+ {
158
+ "borderTopLeftRadius": 24,
159
+ "borderTopRightRadius": 24,
160
+ }
161
+ }
162
+ enablePanDownToClose={true}
163
+ handleStyle={
164
+ {
165
+ "display": "none",
166
+ }
167
+ }
168
+ keyboardBlurBehavior="restore"
169
+ style={
170
+ {
171
+ "display": "none",
172
+ }
173
+ }
174
+ testID="bottom-sheet-mock"
175
+ >
176
+ <View
177
+ style={
178
+ {
179
+ "paddingBottom": 8,
180
+ "paddingTop": 8,
181
+ }
182
+ }
183
+ testID="bottom-sheet-view"
184
+ >
185
+ <View
186
+ accessibilityLabel="Preview "
187
+ accessibilityState={
188
+ {
189
+ "busy": undefined,
190
+ "checked": undefined,
191
+ "disabled": undefined,
192
+ "expanded": undefined,
193
+ "selected": undefined,
194
+ }
195
+ }
196
+ accessibilityValue={
197
+ {
198
+ "max": undefined,
199
+ "min": undefined,
200
+ "now": undefined,
201
+ "text": undefined,
202
+ }
203
+ }
204
+ accessible={true}
205
+ collapsable={false}
206
+ focusable={true}
207
+ onClick={[Function]}
208
+ onResponderGrant={[Function]}
209
+ onResponderMove={[Function]}
210
+ onResponderRelease={[Function]}
211
+ onResponderTerminate={[Function]}
212
+ onResponderTerminationRequest={[Function]}
213
+ onStartShouldSetResponder={[Function]}
214
+ style={
215
+ {
216
+ "alignContent": "center",
217
+ "alignItems": "center",
218
+ "display": "flex",
219
+ "flexDirection": "row",
220
+ "opacity": 1,
221
+ "padding": 8,
222
+ }
223
+ }
224
+ >
225
+ <View
226
+ style={
227
+ {
228
+ "paddingHorizontal": 8,
229
+ }
230
+ }
231
+ >
232
+ <RNSVGSvgView
233
+ align="xMidYMid"
234
+ bbHeight={24}
235
+ bbWidth={24}
236
+ focusable={false}
237
+ meetOrSlice={0}
238
+ minX={0}
239
+ minY={0}
240
+ style={
241
+ [
242
+ {
243
+ "backgroundColor": "transparent",
244
+ "borderWidth": 0,
245
+ },
246
+ {
247
+ "display": "flex",
248
+ "fill": "hsl(198, 35%, 21%)",
249
+ "height": 24,
250
+ "verticalAlign": "middle",
251
+ "width": 24,
252
+ },
253
+ {
254
+ "flex": 0,
255
+ "height": 24,
256
+ "width": 24,
257
+ },
258
+ ]
259
+ }
260
+ testID="eye"
261
+ vbHeight={24}
262
+ vbWidth={24}
263
+ >
264
+ <RNSVGGroup
265
+ fill={
266
+ {
267
+ "payload": 4280499528,
268
+ "type": 0,
269
+ }
270
+ }
271
+ propList={
272
+ [
273
+ "fill",
274
+ ]
275
+ }
276
+ >
277
+ <RNSVGPath
278
+ d="M16 12a4 4 0 1 1-8 0 4 4 0 0 1 8 0Zm-2 0a2 2 0 1 0-4 0 2 2 0 0 0 4 0Z"
279
+ fill={
280
+ {
281
+ "payload": 4280499528,
282
+ "type": 0,
283
+ }
284
+ }
285
+ propList={
286
+ [
287
+ "fill",
288
+ ]
289
+ }
290
+ />
291
+ <RNSVGPath
292
+ d="M21.863 12.477C20.794 14.2 16.703 20 12 20c-4.702 0-8.795-5.8-9.863-7.523a.903.903 0 0 1 0-.954C3.205 9.8 7.297 4 12 4c4.703 0 8.794 5.8 9.863 7.523a.903.903 0 0 1 0 .954ZM20 12s-3.582-6-8-6-8 6-8 6 3.582 6 8 6 8-6 8-6Z"
293
+ fill={
294
+ {
295
+ "payload": 4280499528,
296
+ "type": 0,
297
+ }
298
+ }
299
+ propList={
300
+ [
301
+ "fill",
302
+ ]
303
+ }
304
+ />
305
+ </RNSVGGroup>
306
+ </RNSVGSvgView>
307
+ </View>
308
+ <View
309
+ style={
310
+ {
311
+ "flexShrink": 1,
312
+ "paddingHorizontal": 8,
313
+ }
314
+ }
315
+ >
316
+ <Text
317
+ accessibilityRole="text"
318
+ adjustsFontSizeToFit={false}
319
+ allowFontScaling={true}
320
+ collapsable={false}
321
+ maxFontSizeMultiplier={3.125}
322
+ selectable={true}
323
+ selectionColor="hsl(86, 100%, 46%)"
324
+ style={
325
+ [
326
+ {
327
+ "fontFamily": "inter-semibold",
328
+ },
329
+ {
330
+ "color": "hsl(197, 15%, 43%)",
331
+ },
332
+ {
333
+ "textAlign": "left",
334
+ },
335
+ {
336
+ "fontSize": 16,
337
+ "lineHeight": 20,
338
+ },
339
+ {
340
+ "letterSpacing": 0,
341
+ },
342
+ ]
343
+ }
344
+ >
345
+ Preview
346
+ </Text>
347
+ </View>
348
+ </View>
349
+ </View>
350
+ </View>
351
+ </View>,
154
352
  ]
155
353
  `;