@jobber/components-native 0.89.4 → 0.89.5-JOB-140604-4c8f8f2.41

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 (25) hide show
  1. package/dist/package.json +4 -2
  2. package/dist/src/BottomSheet/BottomSheet.js +55 -35
  3. package/dist/src/BottomSheet/BottomSheet.style.js +10 -8
  4. package/dist/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.js +45 -0
  5. package/dist/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.styles.js +8 -0
  6. package/dist/src/ButtonGroup/ButtonGroup.js +1 -1
  7. package/dist/src/InputText/InputText.js +2 -2
  8. package/dist/src/utils/meta/meta.json +1 -0
  9. package/dist/tsconfig.build.tsbuildinfo +1 -1
  10. package/dist/types/src/BottomSheet/BottomSheet.d.ts +13 -4
  11. package/dist/types/src/BottomSheet/BottomSheet.style.d.ts +9 -7
  12. package/dist/types/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.d.ts +9 -0
  13. package/dist/types/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.styles.d.ts +5 -0
  14. package/dist/types/src/InputText/InputText.d.ts +1 -1
  15. package/package.json +4 -2
  16. package/src/BottomSheet/BottomSheet.stories.tsx +129 -0
  17. package/src/BottomSheet/BottomSheet.style.ts +10 -11
  18. package/src/BottomSheet/BottomSheet.test.tsx +19 -24
  19. package/src/BottomSheet/BottomSheet.tsx +125 -103
  20. package/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.styles.ts +9 -0
  21. package/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.tsx +89 -0
  22. package/src/ButtonGroup/ButtonGroup.tsx +1 -1
  23. package/src/InputText/InputText.tsx +3 -3
  24. package/src/ThumbnailList/__snapshots__/ThumbnailList.test.tsx.snap +211 -1
  25. package/src/utils/meta/meta.json +1 -0
@@ -0,0 +1,89 @@
1
+ import React, { forwardRef, useCallback } from "react";
2
+ import type { FocusEvent } from "react-native";
3
+ import { TextInput, View, findNodeHandle } from "react-native";
4
+ import { useBottomSheetInternal } from "@gorhom/bottom-sheet";
5
+ import { useStyles } from "./BottomSheetInputText.styles";
6
+ import type {
7
+ InputTextProps,
8
+ InputTextRef,
9
+ } from "../../../InputText/InputText";
10
+ import { InputText } from "../../../InputText/InputText";
11
+
12
+ /**
13
+ * BottomSheetInputText is a wrapper around InputText that provides
14
+ * bottom sheet keyboard handling. It implements the handleOnFocus and
15
+ * handleOnBlur logic from BottomSheetTextInput to ensure proper keyboard
16
+ * positioning within bottom sheets.
17
+ */
18
+ export const BottomSheetInputText = forwardRef<InputTextRef, InputTextProps>(
19
+ function BottomSheetInputText(props, ref) {
20
+ const styles = useStyles();
21
+ const { onFocus, onBlur } = props;
22
+ const { animatedKeyboardState, textInputNodesRef } =
23
+ useBottomSheetInternal();
24
+
25
+ const handleOnFocus = useCallback(
26
+ (event?: FocusEvent) => {
27
+ animatedKeyboardState.set(
28
+ (state: ReturnType<typeof animatedKeyboardState.get>) => ({
29
+ ...state,
30
+ target: event?.nativeEvent.target,
31
+ }),
32
+ );
33
+
34
+ onFocus?.(event);
35
+ },
36
+ [animatedKeyboardState, onFocus],
37
+ );
38
+
39
+ const handleOnBlur = useCallback(
40
+ (event?: FocusEvent) => {
41
+ const keyboardState = animatedKeyboardState.get();
42
+ const currentlyFocusedInput = TextInput.State.currentlyFocusedInput();
43
+ const currentFocusedInput =
44
+ currentlyFocusedInput !== null
45
+ ? findNodeHandle(
46
+ // @ts-expect-error - TextInput.State.currentlyFocusedInput() returns NativeMethods
47
+ // which is not directly assignable to findNodeHandle's expected type,
48
+ // but it works at runtime. This is a known type limitation in React Native.
49
+ currentlyFocusedInput,
50
+ )
51
+ : null;
52
+
53
+ /**
54
+ * we need to make sure that we only remove the target
55
+ * if the target belong to the current component and
56
+ * if the currently focused input is not in the targets set.
57
+ */
58
+ const shouldRemoveCurrentTarget =
59
+ keyboardState.target === event?.nativeEvent.target;
60
+ const shouldIgnoreBlurEvent =
61
+ currentFocusedInput &&
62
+ textInputNodesRef.current.has(currentFocusedInput);
63
+
64
+ if (shouldRemoveCurrentTarget && !shouldIgnoreBlurEvent) {
65
+ animatedKeyboardState.set(
66
+ (state: ReturnType<typeof animatedKeyboardState.get>) => ({
67
+ ...state,
68
+ target: undefined,
69
+ }),
70
+ );
71
+ }
72
+
73
+ onBlur?.(event);
74
+ },
75
+ [animatedKeyboardState, textInputNodesRef, onBlur],
76
+ );
77
+
78
+ return (
79
+ <View style={styles.inputText}>
80
+ <InputText
81
+ {...props}
82
+ ref={ref}
83
+ onFocus={handleOnFocus}
84
+ onBlur={handleOnBlur}
85
+ />
86
+ </View>
87
+ );
88
+ },
89
+ );
@@ -48,7 +48,7 @@ export function ButtonGroup({
48
48
  }: ButtonGroupProps): JSX.Element {
49
49
  const { t } = useAtlantisI18n();
50
50
  const { handlePress } = usePreventTapWhenOffline();
51
- const secondaryActionsRef = useRef<BottomSheetRef>();
51
+ const secondaryActionsRef = useRef<BottomSheetRef>(null);
52
52
  const { primaryActions, secondaryActions } = getActions(children);
53
53
  const styles = useStyles();
54
54
 
@@ -117,7 +117,7 @@ export interface InputTextProps
117
117
  /**
118
118
  * Callback that is called when the text input is blurred
119
119
  */
120
- readonly onBlur?: () => void;
120
+ readonly onBlur?: (event?: FocusEvent) => void;
121
121
 
122
122
  /**
123
123
  * VoiceOver will read this string when a user selects the associated element
@@ -422,10 +422,10 @@ function InputTextInternal(
422
422
  setFocused(true);
423
423
  onFocus?.(event);
424
424
  }}
425
- onBlur={() => {
425
+ onBlur={event => {
426
426
  _name && setFocusedInput("");
427
427
  setFocused(false);
428
- onBlur?.();
428
+ onBlur?.(event);
429
429
  field.onBlur();
430
430
  trimWhitespace(inputTransform(field.value), updateFormAndState);
431
431
  }}
@@ -150,6 +150,216 @@ 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
+ "paddingTop": 8,
161
+ }
162
+ }
163
+ enablePanDownToClose={true}
164
+ keyboardBlurBehavior="restore"
165
+ style={
166
+ {
167
+ "display": "none",
168
+ }
169
+ }
170
+ testID="bottom-sheet-mock"
171
+ >
172
+ <View
173
+ enableFooterMarginAdjustment={true}
174
+ style={
175
+ {
176
+ "paddingBottom": 8,
177
+ }
178
+ }
179
+ testID="bottom-sheet-view"
180
+ >
181
+ <View
182
+ accessibilityLabel="Preview "
183
+ accessibilityState={
184
+ {
185
+ "busy": undefined,
186
+ "checked": undefined,
187
+ "disabled": undefined,
188
+ "expanded": undefined,
189
+ "selected": undefined,
190
+ }
191
+ }
192
+ accessibilityValue={
193
+ {
194
+ "max": undefined,
195
+ "min": undefined,
196
+ "now": undefined,
197
+ "text": undefined,
198
+ }
199
+ }
200
+ accessible={true}
201
+ collapsable={false}
202
+ focusable={true}
203
+ onClick={[Function]}
204
+ onResponderGrant={[Function]}
205
+ onResponderMove={[Function]}
206
+ onResponderRelease={[Function]}
207
+ onResponderTerminate={[Function]}
208
+ onResponderTerminationRequest={[Function]}
209
+ onStartShouldSetResponder={[Function]}
210
+ style={
211
+ {
212
+ "alignContent": "center",
213
+ "alignItems": "center",
214
+ "display": "flex",
215
+ "flexDirection": "row",
216
+ "opacity": 1,
217
+ "padding": 8,
218
+ }
219
+ }
220
+ >
221
+ <View
222
+ style={
223
+ {
224
+ "paddingHorizontal": 8,
225
+ }
226
+ }
227
+ >
228
+ <RNSVGSvgView
229
+ align="xMidYMid"
230
+ bbHeight={24}
231
+ bbWidth={24}
232
+ focusable={false}
233
+ meetOrSlice={0}
234
+ minX={0}
235
+ minY={0}
236
+ style={
237
+ [
238
+ {
239
+ "backgroundColor": "transparent",
240
+ "borderWidth": 0,
241
+ },
242
+ {
243
+ "display": "flex",
244
+ "fill": "hsl(198, 35%, 21%)",
245
+ "height": 24,
246
+ "verticalAlign": "middle",
247
+ "width": 24,
248
+ },
249
+ {
250
+ "flex": 0,
251
+ "height": 24,
252
+ "width": 24,
253
+ },
254
+ ]
255
+ }
256
+ testID="eye"
257
+ vbHeight={24}
258
+ vbWidth={24}
259
+ >
260
+ <RNSVGGroup
261
+ fill={
262
+ {
263
+ "payload": 4280499528,
264
+ "type": 0,
265
+ }
266
+ }
267
+ propList={
268
+ [
269
+ "fill",
270
+ ]
271
+ }
272
+ >
273
+ <RNSVGPath
274
+ 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"
275
+ fill={
276
+ {
277
+ "payload": 4280499528,
278
+ "type": 0,
279
+ }
280
+ }
281
+ propList={
282
+ [
283
+ "fill",
284
+ ]
285
+ }
286
+ />
287
+ <RNSVGPath
288
+ 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"
289
+ fill={
290
+ {
291
+ "payload": 4280499528,
292
+ "type": 0,
293
+ }
294
+ }
295
+ propList={
296
+ [
297
+ "fill",
298
+ ]
299
+ }
300
+ />
301
+ </RNSVGGroup>
302
+ </RNSVGSvgView>
303
+ </View>
304
+ <View
305
+ style={
306
+ {
307
+ "flexShrink": 1,
308
+ "paddingHorizontal": 8,
309
+ }
310
+ }
311
+ >
312
+ <Text
313
+ accessibilityRole="text"
314
+ adjustsFontSizeToFit={false}
315
+ allowFontScaling={true}
316
+ collapsable={false}
317
+ maxFontSizeMultiplier={3.125}
318
+ selectable={true}
319
+ selectionColor="hsl(86, 100%, 46%)"
320
+ style={
321
+ [
322
+ {
323
+ "fontFamily": "inter-semibold",
324
+ },
325
+ {
326
+ "color": "hsl(197, 15%, 43%)",
327
+ },
328
+ {
329
+ "textAlign": "left",
330
+ },
331
+ {
332
+ "fontSize": 16,
333
+ "lineHeight": 20,
334
+ },
335
+ {
336
+ "letterSpacing": 0,
337
+ },
338
+ ]
339
+ }
340
+ >
341
+ Preview
342
+ </Text>
343
+ </View>
344
+ </View>
345
+ </View>
346
+ <View
347
+ testID="bottom-sheet-footer"
348
+ >
349
+ <View
350
+ style={
351
+ [
352
+ {
353
+ "backgroundColor": "rgba(255, 255, 255, 1)",
354
+ },
355
+ {
356
+ "paddingBottom": 0,
357
+ },
358
+ ]
359
+ }
360
+ />
361
+ </View>
362
+ </View>
363
+ </View>,
154
364
  ]
155
365
  `;
@@ -12,6 +12,7 @@
12
12
  "AutoLink",
13
13
  "Banner",
14
14
  "BottomSheet",
15
+ "BottomSheet.InputText",
15
16
  "BottomSheetOption",
16
17
  "Button",
17
18
  "ButtonGroup",