@jobber/components-native 0.91.2 → 0.91.3

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.
@@ -4,7 +4,7 @@ import type { ButtonGroupSecondaryActionProps } from "../../types";
4
4
  import type { BottomSheetRef } from "../../../BottomSheet/BottomSheet";
5
5
  interface SecondaryActionSheetProps {
6
6
  readonly actions: ButtonGroupSecondaryActionProps[];
7
- readonly secondaryActionsRef: RefObject<BottomSheetRef>;
7
+ readonly secondaryActionsRef: RefObject<BottomSheetRef | null>;
8
8
  readonly showCancel?: boolean;
9
9
  readonly heading?: string;
10
10
  readonly onOpenBottomSheet?: () => void;
@@ -1,3 +1,3 @@
1
1
  import React from "react";
2
2
  import type { IHandles } from "react-native-modalize/lib/options";
3
- export declare const UNSAFE_WrappedModalize: React.ForwardRefExoticComponent<Omit<import("react-native-modalize/lib/options").IProps<any> & React.RefAttributes<string | number | boolean | {} | React.ReactPortal | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)> | React.ReactNodeArray | undefined>, "ref"> & React.RefAttributes<IHandles | undefined>>;
3
+ export declare const UNSAFE_WrappedModalize: React.ForwardRefExoticComponent<Omit<import("react-native-modalize/lib/options").IProps<any> & React.RefAttributes<any>, "ref"> & React.RefAttributes<IHandles | undefined>>;
@@ -43,7 +43,7 @@ type ElementID = Element["id"];
43
43
  export interface ErrorMessageContextRegisterParams {
44
44
  readonly id: ElementID;
45
45
  readonly hasErrorMessage: Methods["hasErrorMessage"];
46
- readonly ref: RefObject<View>;
46
+ readonly ref: RefObject<View | null>;
47
47
  }
48
48
  export interface ErrorMessageContextProps {
49
49
  /**
@@ -1,6 +1,6 @@
1
1
  import type { AtlantisFormContextProps } from "./types";
2
2
  export declare const atlantisFormContextDefaultValues: {
3
- useConfirmBeforeBack: () => import("react").MutableRefObject<() => undefined>;
3
+ useConfirmBeforeBack: () => import("react").RefObject<() => undefined>;
4
4
  useInternalFormLocalCache: () => {
5
5
  setLocalCache: () => undefined;
6
6
  removeLocalCache: () => undefined;
@@ -2,8 +2,8 @@ import type { RefObject } from "react";
2
2
  import type { View } from "react-native";
3
3
  import type { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
4
4
  interface UseFormViewRefsReturn {
5
- readonly scrollViewRef: RefObject<KeyboardAwareScrollView>;
6
- readonly bottomViewRef: RefObject<View>;
5
+ readonly scrollViewRef: RefObject<KeyboardAwareScrollView | null>;
6
+ readonly bottomViewRef: RefObject<View | null>;
7
7
  readonly scrollToTop: () => void;
8
8
  }
9
9
  export declare function useFormViewRefs(): UseFormViewRefsReturn;
@@ -3,7 +3,7 @@ import type { MutableRefObject, RefObject } from "react";
3
3
  import type { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
4
4
  import type { InternalFormProps } from "../types";
5
5
  type UseInternalFormProps<T extends FieldValues, SubmitResponseType> = Pick<InternalFormProps<T, SubmitResponseType>, "mode" | "reValidateMode" | "initialValues" | "formRef" | "localCacheKey" | "localCacheExclude" | "localCacheId" | "UNSAFE_allowDiscardLocalCacheWhenOffline"> & {
6
- scrollViewRef?: RefObject<KeyboardAwareScrollView>;
6
+ scrollViewRef?: RefObject<KeyboardAwareScrollView | null>;
7
7
  readonly saveButtonHeight: number;
8
8
  readonly messageBannerHeight: number;
9
9
  };
@@ -1,4 +1,4 @@
1
- import type { MutableRefObject, ReactElement, RefObject } from "react";
1
+ import type { ReactElement, RefObject } from "react";
2
2
  import type { ControllerProps, DefaultValues, FieldPath, FieldValues, Mode, UseFormReturn } from "react-hook-form";
3
3
  import type { IconNames } from "@jobber/design";
4
4
  import type { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
@@ -37,7 +37,7 @@ interface FormNoticeMessage {
37
37
  message: string;
38
38
  }
39
39
  export type FormRef<T extends FieldValues = FieldValues> = (UseFormReturn<T> & {
40
- scrollViewRef?: RefObject<KeyboardAwareScrollView>;
40
+ scrollViewRef?: RefObject<KeyboardAwareScrollView | null>;
41
41
  saveButtonHeight?: number;
42
42
  messageBannerHeight?: number;
43
43
  }) | undefined;
@@ -97,7 +97,7 @@ export interface FormProps<T extends FieldValues, SubmitResponseType> {
97
97
  /**
98
98
  * ref object to access react hook form methods and state
99
99
  */
100
- formRef?: MutableRefObject<FormRef<T> | undefined>;
100
+ formRef?: RefObject<FormRef<T> | undefined>;
101
101
  /**
102
102
  * Label to be displayed for the save button
103
103
  */
@@ -3,7 +3,7 @@ import React from "react";
3
3
  import type { BottomSheetRef } from "../../../BottomSheet/BottomSheet";
4
4
  export type BottomSheetOptionsSuffix = "receipt" | "image" | "file" | "video";
5
5
  interface FormatFileBottomSheetProps {
6
- readonly bottomSheetRef: RefObject<BottomSheetRef>;
6
+ readonly bottomSheetRef: RefObject<BottomSheetRef | null>;
7
7
  readonly onPreviewPress?: () => void;
8
8
  readonly onRemovePress?: () => void;
9
9
  readonly bottomSheetOptionsSuffix?: BottomSheetOptionsSuffix;
@@ -13,9 +13,13 @@ export interface MenuOptionProps {
13
13
  export interface MenuOptionInternalProps extends MenuOptionProps {
14
14
  setOpen: (bool: boolean) => void;
15
15
  }
16
+ export interface CustomActivatorProps {
17
+ readonly onPress?: () => void;
18
+ readonly onLongPress?: () => void;
19
+ }
16
20
  export interface MenuProps {
17
21
  readonly menuOptions?: MenuOptionProps[];
18
- readonly customActivator?: ReactElement;
22
+ readonly customActivator?: ReactElement<CustomActivatorProps>;
19
23
  }
20
24
  export interface OverlayProp {
21
25
  setOpen: (bool: boolean) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components-native",
3
- "version": "0.91.2",
3
+ "version": "0.91.3",
4
4
  "license": "MIT",
5
5
  "description": "React Native implementation of Atlantis",
6
6
  "repository": {
@@ -94,5 +94,5 @@
94
94
  "react-native-safe-area-context": "^5.4.0",
95
95
  "react-native-svg": ">=12.0.0"
96
96
  },
97
- "gitHead": "89fec0b77276ec2b2fc80f4fc4ec2f6d207c1ac6"
97
+ "gitHead": "4b120bbb1789aa1b6b9a8eaf157be90d4ea15efc"
98
98
  }
@@ -48,7 +48,7 @@ export function ButtonGroup({
48
48
  }: ButtonGroupProps) {
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
 
@@ -9,7 +9,7 @@ import { BottomSheet } from "../../../BottomSheet/BottomSheet";
9
9
 
10
10
  interface SecondaryActionSheetProps {
11
11
  readonly actions: ButtonGroupSecondaryActionProps[];
12
- readonly secondaryActionsRef: RefObject<BottomSheetRef>;
12
+ readonly secondaryActionsRef: RefObject<BottomSheetRef | null>;
13
13
  readonly showCancel?: boolean;
14
14
  readonly heading?: string;
15
15
  readonly onOpenBottomSheet?: () => void;
@@ -71,9 +71,9 @@ function ContentOverlayInternal(
71
71
  const shouldShowDismiss =
72
72
  showDismiss || isScreenReaderEnabled || isFullScreenOrTopPosition;
73
73
  const [showHeaderShadow, setShowHeaderShadow] = useState<boolean>(false);
74
- const overlayHeader = useRef<View>();
74
+ const overlayHeader = useRef<View>(null);
75
75
 
76
- const internalRef = useRef<Modalize>();
76
+ const internalRef = useRef<Modalize>(null);
77
77
  const [modalizeMethods, setModalizeMethods] = useState<ContentOverlayRef>();
78
78
  const callbackInternalRef = useCallback((instance: Modalize) => {
79
79
  if (instance && !internalRef.current) {
@@ -244,7 +244,6 @@ function ContentOverlayInternal(
244
244
  {shouldShowDismiss && (
245
245
  <View
246
246
  style={styles.dismissButton}
247
- // @ts-expect-error tsc-ci
248
247
  ref={overlayHeader}
249
248
  accessibilityLabel={accessibilityLabel || closeOverlayA11YLabel}
250
249
  accessible={true}
@@ -49,13 +49,13 @@ export function ErrorMessageProvider({ children }: ErrorMessageProviderProps) {
49
49
  }
50
50
  }
51
51
 
52
- function getMeasure(ref: RefObject<View>) {
52
+ function getMeasure(ref: RefObject<View | null>) {
53
53
  return function measure(...args: Parameters<NativeMethods["measureLayout"]>) {
54
54
  ref.current?.measureLayout(...args);
55
55
  };
56
56
  }
57
57
 
58
- function getAccessibilityFocus(ref: RefObject<View>) {
58
+ function getAccessibilityFocus(ref: RefObject<View | null>) {
59
59
  return function accessibilityFocus() {
60
60
  const reactTag = findNodeHandle(ref.current);
61
61
  reactTag &&
@@ -50,7 +50,7 @@ type ElementID = Element["id"];
50
50
  export interface ErrorMessageContextRegisterParams {
51
51
  readonly id: ElementID;
52
52
  readonly hasErrorMessage: Methods["hasErrorMessage"];
53
- readonly ref: RefObject<View>;
53
+ readonly ref: RefObject<View | null>;
54
54
  }
55
55
 
56
56
  export interface ErrorMessageContextProps {
@@ -4,15 +4,14 @@ import type { View } from "react-native";
4
4
  import type { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
5
5
 
6
6
  interface UseFormViewRefsReturn {
7
- readonly scrollViewRef: RefObject<KeyboardAwareScrollView>;
8
- readonly bottomViewRef: RefObject<View>;
7
+ readonly scrollViewRef: RefObject<KeyboardAwareScrollView | null>;
8
+ readonly bottomViewRef: RefObject<View | null>;
9
9
  readonly scrollToTop: () => void;
10
10
  }
11
11
 
12
12
  export function useFormViewRefs(): UseFormViewRefsReturn {
13
- const scrollViewRef: RefObject<KeyboardAwareScrollView> =
14
- useRef<KeyboardAwareScrollView>(null);
15
- const bottomViewRef: RefObject<View> = useRef<View>(null);
13
+ const scrollViewRef = useRef<KeyboardAwareScrollView>(null);
14
+ const bottomViewRef = useRef<View>(null);
16
15
  const scrollToTop = useCallback(() => {
17
16
  scrollViewRef.current?.scrollToPosition(0, 0);
18
17
  }, [scrollViewRef]);
@@ -22,7 +22,7 @@ type UseInternalFormProps<T extends FieldValues, SubmitResponseType> = Pick<
22
22
  | "localCacheId"
23
23
  | "UNSAFE_allowDiscardLocalCacheWhenOffline"
24
24
  > & {
25
- scrollViewRef?: RefObject<KeyboardAwareScrollView>;
25
+ scrollViewRef?: RefObject<KeyboardAwareScrollView | null>;
26
26
  readonly saveButtonHeight: number;
27
27
  readonly messageBannerHeight: number;
28
28
  };
package/src/Form/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { MutableRefObject, ReactElement, RefObject } from "react";
1
+ import type { ReactElement, RefObject } from "react";
2
2
  import type {
3
3
  ControllerProps,
4
4
  DefaultValues,
@@ -54,7 +54,7 @@ interface FormNoticeMessage {
54
54
 
55
55
  export type FormRef<T extends FieldValues = FieldValues> =
56
56
  | (UseFormReturn<T> & {
57
- scrollViewRef?: RefObject<KeyboardAwareScrollView>;
57
+ scrollViewRef?: RefObject<KeyboardAwareScrollView | null>;
58
58
  saveButtonHeight?: number;
59
59
  messageBannerHeight?: number;
60
60
  })
@@ -127,7 +127,7 @@ export interface FormProps<T extends FieldValues, SubmitResponseType> {
127
127
  /**
128
128
  * ref object to access react hook form methods and state
129
129
  */
130
- formRef?: MutableRefObject<FormRef<T> | undefined>;
130
+ formRef?: RefObject<FormRef<T> | undefined>;
131
131
 
132
132
  /**
133
133
  * Label to be displayed for the save button
@@ -9,7 +9,7 @@ import { useAtlantisI18n } from "../../../hooks/useAtlantisI18n";
9
9
  export type BottomSheetOptionsSuffix = "receipt" | "image" | "file" | "video";
10
10
 
11
11
  interface FormatFileBottomSheetProps {
12
- readonly bottomSheetRef: RefObject<BottomSheetRef>;
12
+ readonly bottomSheetRef: RefObject<BottomSheetRef | null>;
13
13
  readonly onPreviewPress?: () => void;
14
14
  readonly onRemovePress?: () => void;
15
15
  readonly bottomSheetOptionsSuffix?: BottomSheetOptionsSuffix;
package/src/Menu/Menu.tsx CHANGED
@@ -23,8 +23,8 @@ import { useAtlantisTheme } from "../AtlantisThemeContext";
23
23
  export function Menu({ menuOptions, customActivator }: MenuProps) {
24
24
  const [open, setOpen] = useState<boolean>(false);
25
25
  const [menuPosition, setMenuPosition] = useState<object>();
26
- const activatorLayout = useRef<LayoutRectangle>();
27
- const menuButtonRef = useRef<View | null>();
26
+ const activatorLayout = useRef<LayoutRectangle>(null);
27
+ const menuButtonRef = useRef<View>(null);
28
28
  const screenInfo = useScreenInformation();
29
29
 
30
30
  const { t } = useAtlantisI18n();
package/src/Menu/types.ts CHANGED
@@ -16,9 +16,14 @@ export interface MenuOptionInternalProps extends MenuOptionProps {
16
16
  setOpen: (bool: boolean) => void;
17
17
  }
18
18
 
19
+ export interface CustomActivatorProps {
20
+ readonly onPress?: () => void;
21
+ readonly onLongPress?: () => void;
22
+ }
23
+
19
24
  export interface MenuProps {
20
25
  readonly menuOptions?: MenuOptionProps[];
21
- readonly customActivator?: ReactElement;
26
+ readonly customActivator?: ReactElement<CustomActivatorProps>;
22
27
  }
23
28
 
24
29
  export interface OverlayProp {