@jobber/components-native 0.38.0 → 0.40.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.
Files changed (184) hide show
  1. package/dist/src/AtlantisContext/AtlantisContext.js +2 -0
  2. package/dist/src/Form/Form.js +187 -0
  3. package/dist/src/Form/Form.style.js +33 -0
  4. package/dist/src/Form/components/FormActionBar/FormActionBar.js +21 -0
  5. package/dist/src/Form/components/FormActionBar/FormActionBar.style.js +5 -0
  6. package/dist/src/Form/components/FormActionBar/index.js +1 -0
  7. package/dist/src/Form/components/FormBody/FormBody.js +20 -0
  8. package/dist/src/Form/components/FormBody/FormBody.style.js +26 -0
  9. package/dist/src/Form/components/FormBody/index.js +1 -0
  10. package/dist/src/Form/components/FormCache/FormCache.js +34 -0
  11. package/dist/src/Form/components/FormErrorBanner/FormErrorBanner.js +21 -0
  12. package/dist/src/Form/components/FormErrorBanner/index.js +1 -0
  13. package/dist/src/Form/components/FormErrorBanner/messages.js +13 -0
  14. package/dist/src/Form/components/FormMask/FormMask.js +11 -0
  15. package/dist/src/Form/components/FormMask/FormMask.style.js +15 -0
  16. package/dist/src/Form/components/FormMask/index.js +1 -0
  17. package/dist/src/Form/components/FormMessage/FormMessage.js +48 -0
  18. package/dist/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.js +28 -0
  19. package/dist/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.style.js +17 -0
  20. package/dist/src/Form/components/FormMessage/components/InternalFormMessage/index.js +1 -0
  21. package/dist/src/Form/components/FormMessage/components/InternalFormMessage/messages.js +8 -0
  22. package/dist/src/Form/components/FormMessage/index.js +1 -0
  23. package/dist/src/Form/components/FormMessageBanner/FormMessageBanner.js +15 -0
  24. package/dist/src/Form/components/FormMessageBanner/index.js +1 -0
  25. package/dist/src/Form/components/FormSaveButton/FormSaveButton.js +69 -0
  26. package/dist/src/Form/components/FormSaveButton/index.js +1 -0
  27. package/dist/src/Form/components/FormSaveButton/messages.js +8 -0
  28. package/dist/src/Form/constants.js +2 -0
  29. package/dist/src/Form/context/AtlantisFormContext.js +16 -0
  30. package/dist/src/Form/context/index.js +1 -0
  31. package/dist/src/Form/context/types.js +1 -0
  32. package/dist/src/Form/hooks/useFormViewRefs.js +14 -0
  33. package/dist/src/Form/hooks/useInternalForm.js +37 -0
  34. package/dist/src/Form/hooks/useOfflineHandler.js +24 -0
  35. package/dist/src/Form/hooks/useSaveButtonPosition.js +25 -0
  36. package/dist/src/Form/hooks/useScreenInformation.js +15 -0
  37. package/dist/src/Form/hooks/useScrollToError/index.js +1 -0
  38. package/dist/src/Form/hooks/useScrollToError/useScrollToError.js +63 -0
  39. package/dist/src/Form/index.js +4 -0
  40. package/dist/src/Form/messages.js +28 -0
  41. package/dist/src/Form/types.js +10 -0
  42. package/dist/src/InputDate/InputDate.js +76 -0
  43. package/dist/src/InputDate/index.js +1 -0
  44. package/dist/src/InputDate/messages.js +8 -0
  45. package/dist/src/Menu/Menu.js +67 -0
  46. package/dist/src/Menu/Menu.style.js +6 -0
  47. package/dist/src/Menu/components/MenuOption/MenuOption.js +25 -0
  48. package/dist/src/Menu/components/MenuOption/MenuOption.style.js +10 -0
  49. package/dist/src/Menu/components/MenuOption/index.js +1 -0
  50. package/dist/src/Menu/components/Overlay/Overlay.js +9 -0
  51. package/dist/src/Menu/components/Overlay/Overlay.style.js +6 -0
  52. package/dist/src/Menu/components/Overlay/index.js +1 -0
  53. package/dist/src/Menu/index.js +1 -0
  54. package/dist/src/Menu/messages.js +8 -0
  55. package/dist/src/Menu/types.js +1 -0
  56. package/dist/src/Menu/utils.js +84 -0
  57. package/dist/src/index.js +3 -0
  58. package/dist/tsconfig.tsbuildinfo +1 -1
  59. package/dist/types/src/AtlantisContext/AtlantisContext.d.ts +7 -1
  60. package/dist/types/src/Form/Form.d.ts +4 -0
  61. package/dist/types/src/Form/Form.style.d.ts +31 -0
  62. package/dist/types/src/Form/components/FormActionBar/FormActionBar.d.ts +13 -0
  63. package/dist/types/src/Form/components/FormActionBar/FormActionBar.style.d.ts +15 -0
  64. package/dist/types/src/Form/components/FormActionBar/index.d.ts +2 -0
  65. package/dist/types/src/Form/components/FormBody/FormBody.d.ts +10 -0
  66. package/dist/types/src/Form/components/FormBody/FormBody.style.d.ts +24 -0
  67. package/dist/types/src/Form/components/FormBody/index.d.ts +1 -0
  68. package/dist/types/src/Form/components/FormCache/FormCache.d.ts +10 -0
  69. package/dist/types/src/Form/components/FormErrorBanner/FormErrorBanner.d.ts +3 -0
  70. package/dist/types/src/Form/components/FormErrorBanner/index.d.ts +1 -0
  71. package/dist/types/src/Form/components/FormErrorBanner/messages.d.ts +12 -0
  72. package/dist/types/src/Form/components/FormMask/FormMask.d.ts +2 -0
  73. package/dist/types/src/Form/components/FormMask/FormMask.style.d.ts +13 -0
  74. package/dist/types/src/Form/components/FormMask/index.d.ts +1 -0
  75. package/dist/types/src/Form/components/FormMessage/FormMessage.d.ts +19 -0
  76. package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.d.ts +8 -0
  77. package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.style.d.ts +20 -0
  78. package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/index.d.ts +1 -0
  79. package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/messages.d.ts +7 -0
  80. package/dist/types/src/Form/components/FormMessage/index.d.ts +1 -0
  81. package/dist/types/src/Form/components/FormMessageBanner/FormMessageBanner.d.ts +7 -0
  82. package/dist/types/src/Form/components/FormMessageBanner/index.d.ts +1 -0
  83. package/dist/types/src/Form/components/FormSaveButton/FormSaveButton.d.ts +3 -0
  84. package/dist/types/src/Form/components/FormSaveButton/index.d.ts +1 -0
  85. package/dist/types/src/Form/components/FormSaveButton/messages.d.ts +7 -0
  86. package/dist/types/src/Form/constants.d.ts +2 -0
  87. package/dist/types/src/Form/context/AtlantisFormContext.d.ts +12 -0
  88. package/dist/types/src/Form/context/index.d.ts +2 -0
  89. package/dist/types/src/Form/context/types.d.ts +26 -0
  90. package/dist/types/src/Form/hooks/useFormViewRefs.d.ts +10 -0
  91. package/dist/types/src/Form/hooks/useInternalForm.d.ts +19 -0
  92. package/dist/types/src/Form/hooks/useOfflineHandler.d.ts +1 -0
  93. package/dist/types/src/Form/hooks/useSaveButtonPosition.d.ts +12 -0
  94. package/dist/types/src/Form/hooks/useScreenInformation.d.ts +8 -0
  95. package/dist/types/src/Form/hooks/useScrollToError/index.d.ts +1 -0
  96. package/dist/types/src/Form/hooks/useScrollToError/useScrollToError.d.ts +10 -0
  97. package/dist/types/src/Form/index.d.ts +5 -0
  98. package/dist/types/src/Form/messages.d.ts +27 -0
  99. package/dist/types/src/Form/types.d.ts +199 -0
  100. package/dist/types/src/InputDate/InputDate.d.ts +74 -0
  101. package/dist/types/src/InputDate/index.d.ts +1 -0
  102. package/dist/types/src/InputDate/messages.d.ts +7 -0
  103. package/dist/types/src/InputNumber/InputNumber.d.ts +1 -1
  104. package/dist/types/src/Menu/Menu.d.ts +3 -0
  105. package/dist/types/src/Menu/Menu.style.d.ts +18 -0
  106. package/dist/types/src/Menu/components/MenuOption/MenuOption.d.ts +3 -0
  107. package/dist/types/src/Menu/components/MenuOption/MenuOption.style.d.ts +8 -0
  108. package/dist/types/src/Menu/components/MenuOption/index.d.ts +1 -0
  109. package/dist/types/src/Menu/components/Overlay/Overlay.d.ts +3 -0
  110. package/dist/types/src/Menu/components/Overlay/Overlay.style.d.ts +12 -0
  111. package/dist/types/src/Menu/components/Overlay/index.d.ts +1 -0
  112. package/dist/types/src/Menu/index.d.ts +2 -0
  113. package/dist/types/src/Menu/messages.d.ts +7 -0
  114. package/dist/types/src/Menu/types.d.ts +22 -0
  115. package/dist/types/src/Menu/utils.d.ts +10 -0
  116. package/dist/types/src/index.d.ts +3 -0
  117. package/package.json +3 -2
  118. package/src/AtlantisContext/AtlantisContext.tsx +10 -1
  119. package/src/Form/Form.style.ts +34 -0
  120. package/src/Form/Form.test.tsx +588 -0
  121. package/src/Form/Form.tsx +296 -0
  122. package/src/Form/components/FormActionBar/FormActionBar.style.ts +11 -0
  123. package/src/Form/components/FormActionBar/FormActionBar.tsx +63 -0
  124. package/src/Form/components/FormActionBar/index.ts +2 -0
  125. package/src/Form/components/FormBody/FormBody.style.ts +27 -0
  126. package/src/Form/components/FormBody/FormBody.tsx +62 -0
  127. package/src/Form/components/FormBody/index.ts +1 -0
  128. package/src/Form/components/FormCache/FormCache.tsx +50 -0
  129. package/src/Form/components/FormErrorBanner/FormErrorBanner.test.tsx +124 -0
  130. package/src/Form/components/FormErrorBanner/FormErrorBanner.tsx +34 -0
  131. package/src/Form/components/FormErrorBanner/index.ts +1 -0
  132. package/src/Form/components/FormErrorBanner/messages.ts +14 -0
  133. package/src/Form/components/FormMask/FormMask.style.tsx +16 -0
  134. package/src/Form/components/FormMask/FormMask.tsx +19 -0
  135. package/src/Form/components/FormMask/index.ts +1 -0
  136. package/src/Form/components/FormMessage/FormMessage.test.tsx +72 -0
  137. package/src/Form/components/FormMessage/FormMessage.tsx +63 -0
  138. package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.style.ts +18 -0
  139. package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.tsx +55 -0
  140. package/src/Form/components/FormMessage/components/InternalFormMessage/index.ts +1 -0
  141. package/src/Form/components/FormMessage/components/InternalFormMessage/messages.ts +10 -0
  142. package/src/Form/components/FormMessage/index.ts +1 -0
  143. package/src/Form/components/FormMessageBanner/FormMessageBanner.test.tsx +27 -0
  144. package/src/Form/components/FormMessageBanner/FormMessageBanner.tsx +33 -0
  145. package/src/Form/components/FormMessageBanner/index.ts +1 -0
  146. package/src/Form/components/FormSaveButton/FormSaveButton.test.tsx +159 -0
  147. package/src/Form/components/FormSaveButton/FormSaveButton.tsx +103 -0
  148. package/src/Form/components/FormSaveButton/index.ts +1 -0
  149. package/src/Form/components/FormSaveButton/messages.ts +9 -0
  150. package/src/Form/constants.ts +2 -0
  151. package/src/Form/context/AtlantisFormContext.test.tsx +45 -0
  152. package/src/Form/context/AtlantisFormContext.tsx +21 -0
  153. package/src/Form/context/index.ts +5 -0
  154. package/src/Form/context/types.ts +34 -0
  155. package/src/Form/hooks/useFormViewRefs.ts +23 -0
  156. package/src/Form/hooks/useInternalForm.ts +99 -0
  157. package/src/Form/hooks/useOfflineHandler.ts +36 -0
  158. package/src/Form/hooks/useSaveButtonPosition.ts +52 -0
  159. package/src/Form/hooks/useScreenInformation.ts +25 -0
  160. package/src/Form/hooks/useScrollToError/index.ts +1 -0
  161. package/src/Form/hooks/useScrollToError/useScrollToError.test.tsx +103 -0
  162. package/src/Form/hooks/useScrollToError/useScrollToError.ts +102 -0
  163. package/src/Form/index.ts +13 -0
  164. package/src/Form/messages.ts +33 -0
  165. package/src/Form/types.ts +255 -0
  166. package/src/InputDate/InputDate.test.tsx +295 -0
  167. package/src/InputDate/InputDate.tsx +231 -0
  168. package/src/InputDate/index.ts +1 -0
  169. package/src/InputDate/messages.ts +9 -0
  170. package/src/InputNumber/InputNumber.tsx +1 -1
  171. package/src/Menu/Menu.style.ts +16 -0
  172. package/src/Menu/Menu.test.tsx +201 -0
  173. package/src/Menu/Menu.tsx +116 -0
  174. package/src/Menu/components/MenuOption/MenuOption.style.tsx +11 -0
  175. package/src/Menu/components/MenuOption/MenuOption.tsx +63 -0
  176. package/src/Menu/components/MenuOption/index.ts +1 -0
  177. package/src/Menu/components/Overlay/Overlay.style.ts +13 -0
  178. package/src/Menu/components/Overlay/Overlay.tsx +16 -0
  179. package/src/Menu/components/Overlay/index.ts +1 -0
  180. package/src/Menu/index.ts +6 -0
  181. package/src/Menu/messages.ts +9 -0
  182. package/src/Menu/types.ts +25 -0
  183. package/src/Menu/utils.ts +151 -0
  184. package/src/index.ts +3 -0
@@ -3,7 +3,7 @@ export interface AtlantisContextProps {
3
3
  /**
4
4
  * The date format Atlantis components would use
5
5
  */
6
- readonly dateFormat?: string;
6
+ readonly dateFormat: string;
7
7
  /**
8
8
  * The time format Atlantis components would use
9
9
  */
@@ -30,6 +30,12 @@ export interface AtlantisContextProps {
30
30
  * The currency symbol Atlantis components will use
31
31
  */
32
32
  readonly currencySymbol: string;
33
+ /**
34
+ * The `headerHeight` property represents the height of the app header in Atlantis.
35
+ * It plays a crucial role in determining the positioning of various elements within the app.
36
+ * By accurately defining this value, Atlantis can effectively calculate the layout and alignment of its components.
37
+ */
38
+ readonly headerHeight: number;
33
39
  }
34
40
  export declare const defaultValues: AtlantisContextProps;
35
41
  export declare const AtlantisContext: import("react").Context<AtlantisContextProps>;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { FieldValues } from "react-hook-form";
3
+ import { FormProps } from "./types";
4
+ export declare function Form<T extends FieldValues, S>({ initialLoading, ...rest }: FormProps<T, S>): JSX.Element;
@@ -0,0 +1,31 @@
1
+ export declare const styles: {
2
+ container: {
3
+ flex: number;
4
+ flexGrow: number;
5
+ width: string;
6
+ };
7
+ safeArea: {
8
+ backgroundColor: string;
9
+ };
10
+ scrollContentContainer: {
11
+ flexGrow: number;
12
+ };
13
+ scrollView: {
14
+ flexGrow: number;
15
+ };
16
+ formChildContainer: {
17
+ flexGrow: number;
18
+ justifyContent: "flex-start";
19
+ };
20
+ formContent: {
21
+ paddingVertical: number;
22
+ };
23
+ fixedSaveButton: {
24
+ padding: number;
25
+ backgroundColor: string;
26
+ };
27
+ activityIndicator: {
28
+ marginVertical: number;
29
+ flex: number;
30
+ };
31
+ };
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { SecondaryActionProp } from "../../types";
3
+ export interface FormActionBarProps {
4
+ readonly keyboardHeight: number;
5
+ readonly isFormSubmitting: boolean;
6
+ readonly saveButtonLabel?: string;
7
+ readonly submit: () => Promise<void> | void;
8
+ readonly setSaveButtonHeight?: (height: number) => void;
9
+ readonly renderStickySection?: (onSubmit: () => void, label: string | undefined, isSubmitting: boolean) => JSX.Element;
10
+ readonly secondaryActions?: SecondaryActionProp[];
11
+ readonly setSecondaryActionLoading?: (bool: boolean) => void;
12
+ }
13
+ export declare function FormActionBar({ keyboardHeight, submit, isFormSubmitting, saveButtonLabel, renderStickySection, setSaveButtonHeight, secondaryActions, setSecondaryActionLoading, }: FormActionBarProps): JSX.Element;
@@ -0,0 +1,15 @@
1
+ export declare const styles: {
2
+ saveButton: {
3
+ shadowColor: string;
4
+ shadowOffset: {
5
+ width: number;
6
+ height: number;
7
+ };
8
+ shadowOpacity: number;
9
+ shadowRadius: number;
10
+ elevation: number;
11
+ padding: number;
12
+ backgroundColor: string;
13
+ width: string;
14
+ };
15
+ };
@@ -0,0 +1,2 @@
1
+ export { FormActionBar } from "./FormActionBar";
2
+ export type { FormActionBarProps } from "./FormActionBar";
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { FormActionBarProps } from "../FormActionBar";
3
+ interface FormBodyProps extends FormActionBarProps {
4
+ children: JSX.Element;
5
+ shouldRenderActionBar?: boolean;
6
+ saveButtonOffset?: number;
7
+ }
8
+ export declare function FormBody({ isFormSubmitting, submit, keyboardHeight, children, saveButtonLabel, renderStickySection, shouldRenderActionBar, secondaryActions, setSecondaryActionLoading, setSaveButtonHeight, saveButtonOffset, }: FormBodyProps): JSX.Element;
9
+ export declare function useBottomPadding(): number;
10
+ export {};
@@ -0,0 +1,24 @@
1
+ export declare const styles: {
2
+ container: {
3
+ flex: number;
4
+ flexGrow: number;
5
+ width: string;
6
+ };
7
+ safeArea: {
8
+ backgroundColor: string;
9
+ };
10
+ scrollContentContainer: {
11
+ flexGrow: number;
12
+ };
13
+ scrollView: {
14
+ flexGrow: number;
15
+ };
16
+ formChildContainer: {
17
+ flexGrow: number;
18
+ justifyContent: "flex-start";
19
+ };
20
+ activityIndicator: {
21
+ marginVertical: number;
22
+ flex: number;
23
+ };
24
+ };
@@ -0,0 +1 @@
1
+ export { FormBody, useBottomPadding } from "./FormBody";
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { FieldValues } from "react-hook-form";
3
+ interface FormCacheProps<T extends FieldValues> {
4
+ localCacheId?: string | string[];
5
+ localCacheKey?: string;
6
+ localCacheExclude?: string[];
7
+ setLocalCache: (data: T) => void;
8
+ }
9
+ export declare function FormCache<T extends FieldValues>({ localCacheExclude, localCacheKey, setLocalCache, }: FormCacheProps<T>): JSX.Element;
10
+ export {};
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { FormBannerErrors } from "../../types";
3
+ export declare function FormErrorBanner({ networkError, bannerError, }: FormBannerErrors): JSX.Element;
@@ -0,0 +1 @@
1
+ export { FormErrorBanner } from "./FormErrorBanner";
@@ -0,0 +1,12 @@
1
+ export declare const messages: {
2
+ networkError: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ offlineError: {
8
+ id: string;
9
+ defaultMessage: string;
10
+ description: string;
11
+ };
12
+ };
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function FormMask(): JSX.Element;
@@ -0,0 +1,13 @@
1
+ export declare const styles: {
2
+ mask: {
3
+ zIndex: number;
4
+ width: string;
5
+ height: string;
6
+ position: "absolute";
7
+ top: number;
8
+ left: number;
9
+ backgroundColor: string;
10
+ padding: number;
11
+ justifyContent: "center";
12
+ };
13
+ };
@@ -0,0 +1 @@
1
+ export { FormMask } from "./FormMask";
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ import { EmptyStateProps } from "../../../EmptyState";
3
+ type FormMessageData = EmptyStateProps;
4
+ /**
5
+ * Show a message that takes over the whole screen to the user. This provides a
6
+ * more urgent feedback when the user does an action that requires attention
7
+ * their full attention.
8
+ *
9
+ * By default, rendering `<FormMessage />` on a screen won't show any messages
10
+ * because it's only a container. Use `FormMessage.open(...)`. to show a
11
+ * message to the user. Use `FormMessage.close()` to close the most
12
+ * recent message.
13
+ */
14
+ export declare const FormMessage: {
15
+ (): JSX.Element;
16
+ show(messageData: FormMessageData): void;
17
+ close(): void;
18
+ };
19
+ export {};
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { EmptyStateProps } from "../../../../../EmptyState";
3
+ interface FormMessageProps {
4
+ readonly data: EmptyStateProps;
5
+ readonly onRequestClose: () => void;
6
+ }
7
+ export declare function InternalFormMessage({ data, onRequestClose, }: FormMessageProps): JSX.Element;
8
+ export {};
@@ -0,0 +1,20 @@
1
+ export declare const styles: {
2
+ wrapper: {
3
+ backgroundColor: string;
4
+ flex: number;
5
+ justifyContent: "center";
6
+ };
7
+ closeAction: {
8
+ position: "absolute";
9
+ top: number;
10
+ right: number;
11
+ zIndex: number;
12
+ };
13
+ scrollWrapper: {
14
+ height: string;
15
+ };
16
+ scrollWrapperContent: {
17
+ flexGrow: number;
18
+ justifyContent: "center";
19
+ };
20
+ };
@@ -0,0 +1 @@
1
+ export { InternalFormMessage } from "./InternalFormMessage";
@@ -0,0 +1,7 @@
1
+ export declare const messages: {
2
+ goBackButton: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ };
@@ -0,0 +1 @@
1
+ export { FormMessage } from "./FormMessage";
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { FormBannerMessage } from "../../types";
3
+ interface FormMessageBannerProps {
4
+ bannerMessages?: FormBannerMessage[];
5
+ }
6
+ export declare function FormMessageBanner({ bannerMessages, }: FormMessageBannerProps): JSX.Element;
7
+ export {};
@@ -0,0 +1 @@
1
+ export { FormMessageBanner } from "./FormMessageBanner";
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { FormSaveButtonProps } from "../../types";
3
+ export declare function FormSaveButton({ primaryAction, loading, label, secondaryActions, setSecondaryActionLoading, onOpenBottomSheet, onCloseBottomSheet, }: FormSaveButtonProps): JSX.Element;
@@ -0,0 +1 @@
1
+ export { FormSaveButton } from "./FormSaveButton";
@@ -0,0 +1,7 @@
1
+ export declare const messages: {
2
+ saveButton: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ };
@@ -0,0 +1,2 @@
1
+ export declare const KEYBOARD_TOP_PADDING_AUTO_SCROLL = 20;
2
+ export declare const KEYBOARD_SAVE_BUTTON_DISTANCE = 1;
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { AtlantisFormContextProps } from "./types";
3
+ export declare const defaultValues: {
4
+ useConfirmBeforeBack: () => import("react").MutableRefObject<() => undefined>;
5
+ useInternalFormLocalCache: () => {
6
+ setLocalCache: () => undefined;
7
+ removeLocalCache: () => undefined;
8
+ };
9
+ headerHeight: number;
10
+ };
11
+ export declare const AtlantisFormContext: import("react").Context<AtlantisFormContextProps>;
12
+ export declare function useAtlantisFormContext(): AtlantisFormContextProps;
@@ -0,0 +1,2 @@
1
+ export { AtlantisFormContext, useAtlantisFormContext, } from "./AtlantisFormContext";
2
+ export type { AtlantisFormContextProps } from "./types";
@@ -0,0 +1,26 @@
1
+ import { MutableRefObject } from "react";
2
+ import { FieldValues, UseFormReturn } from "react-hook-form";
3
+ export interface UseConfirmBeforeBackProps {
4
+ alwaysPreventBack: boolean;
5
+ onAcceptEvent?: () => void;
6
+ shouldShowAlert: boolean;
7
+ showLostProgressMessage?: boolean;
8
+ }
9
+ interface LocalCacheOptions {
10
+ /**
11
+ * Allows the ability to specify that the cached data contains pre-filled data.
12
+ * By setting this the cached data will only be applied if the same id is based
13
+ * for the same key. If the id doesn't match the data will be deleted from the
14
+ * cache.
15
+ */
16
+ readonly id?: string | string[];
17
+ }
18
+ export interface AtlantisFormContextProps {
19
+ useConfirmBeforeBack: (props: UseConfirmBeforeBackProps) => MutableRefObject<() => void>;
20
+ useInternalFormLocalCache: <TData extends FieldValues>(formMethods: UseFormReturn<TData>, cacheKey?: string, options?: LocalCacheOptions) => {
21
+ setLocalCache: (data: TData) => void;
22
+ removeLocalCache: () => void;
23
+ };
24
+ headerHeight: number;
25
+ }
26
+ export {};
@@ -0,0 +1,10 @@
1
+ import { RefObject } from "react";
2
+ import { View } from "react-native";
3
+ import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
4
+ interface UseFormViewRefsReturn {
5
+ readonly scrollViewRef: RefObject<KeyboardAwareScrollView>;
6
+ readonly bottomViewRef: RefObject<View>;
7
+ readonly scrollToTop: () => void;
8
+ }
9
+ export declare function useFormViewRefs(): UseFormViewRefsReturn;
10
+ export {};
@@ -0,0 +1,19 @@
1
+ import { FieldValues, UseFormHandleSubmit, UseFormReturn } from "react-hook-form";
2
+ import { MutableRefObject, RefObject } from "react";
3
+ import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
4
+ import { InternalFormProps } from "../types";
5
+ type UseInternalFormProps<T extends FieldValues, SubmitResponseType> = Pick<InternalFormProps<T, SubmitResponseType>, "mode" | "reValidateMode" | "initialValues" | "formRef" | "localCacheKey" | "localCacheExclude" | "localCacheId"> & {
6
+ scrollViewRef?: RefObject<KeyboardAwareScrollView>;
7
+ readonly saveButtonHeight: number;
8
+ readonly messageBannerHeight: number;
9
+ };
10
+ interface UseInternalForm<T extends FieldValues> {
11
+ readonly formMethods: UseFormReturn<T>;
12
+ readonly handleSubmit: UseFormHandleSubmit<T>;
13
+ readonly isSubmitting: boolean;
14
+ readonly isDirty: boolean;
15
+ readonly removeListenerRef: MutableRefObject<() => void>;
16
+ readonly setLocalCache: (data: T) => void;
17
+ }
18
+ export declare function useInternalForm<T extends FieldValues, SubmitResponseType>({ mode, reValidateMode, initialValues, formRef, localCacheKey, localCacheId, scrollViewRef, saveButtonHeight, messageBannerHeight, }: UseInternalFormProps<T, SubmitResponseType>): UseInternalForm<T>;
19
+ export {};
@@ -0,0 +1 @@
1
+ export declare function useOfflineHandler(): (callback: () => void, dismiss: () => void) => () => void;
@@ -0,0 +1,12 @@
1
+ interface UseSaveButtonPositionReturn {
2
+ saveButtonPosition: "sticky" | "inline";
3
+ }
4
+ interface UseSaveButtonPositionParams {
5
+ formContentHeight: number;
6
+ isBottomSheetOpen: boolean;
7
+ showStickySaveButton: boolean;
8
+ keyboardHeight: number;
9
+ keyboardScreenY: number;
10
+ }
11
+ export declare function useSaveButtonPosition({ formContentHeight, isBottomSheetOpen, showStickySaveButton, keyboardHeight, keyboardScreenY, }: UseSaveButtonPositionParams): UseSaveButtonPositionReturn;
12
+ export {};
@@ -0,0 +1,8 @@
1
+ import { EdgeInsets } from "react-native-safe-area-context";
2
+ interface UseScreenInformation {
3
+ readonly windowHeight: number;
4
+ readonly headerHeight: number;
5
+ readonly insets: EdgeInsets;
6
+ }
7
+ export declare function useScreenInformation(): UseScreenInformation;
8
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./useScrollToError";
@@ -0,0 +1,10 @@
1
+ import { FieldValues, FormState, UseFormSetFocus } from "react-hook-form";
2
+ import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
3
+ interface UseScrollToErrorParams<T extends FieldValues> {
4
+ readonly formState: FormState<T>;
5
+ readonly refNode: number | null;
6
+ readonly setFocus: UseFormSetFocus<T>;
7
+ readonly scrollToPosition?: KeyboardAwareScrollView["scrollToPosition"];
8
+ }
9
+ export declare function useScrollToError<T extends FieldValues>({ formState: { errors, isValid, submitCount }, refNode, setFocus, scrollToPosition, }: UseScrollToErrorParams<T>): void;
10
+ export {};
@@ -0,0 +1,5 @@
1
+ export { Form } from "./Form";
2
+ export { FormMessage } from "./components/FormMessage";
3
+ export type { FormBannerErrors, FormBannerMessage, FormErrors, FormRef, FormValues, SecondaryActionProp, ValidationRulesByFieldPath, } from "./types";
4
+ export { FormSubmitErrorType, FormBannerMessageType } from "./types";
5
+ export * from "./context";
@@ -0,0 +1,27 @@
1
+ export declare const messages: {
2
+ loadingA11YLabel: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ dismissAlertButton: {
8
+ id: string;
9
+ defaultMessage: string;
10
+ description: string;
11
+ };
12
+ retryAlertButton: {
13
+ id: string;
14
+ defaultMessage: string;
15
+ description: string;
16
+ };
17
+ unavailableNetworkTitle: {
18
+ id: string;
19
+ defaultMessage: string;
20
+ description: string;
21
+ };
22
+ unavailableNetworkMessage: {
23
+ id: string;
24
+ defaultMessage: string;
25
+ description: string;
26
+ };
27
+ };
@@ -0,0 +1,199 @@
1
+ import { MutableRefObject, RefObject } from "react";
2
+ import { ControllerProps, DeepPartial, FieldPath, FieldValues, Mode, UnpackNestedValue, UseFormReturn } from "react-hook-form";
3
+ import { IconNames } from "@jobber/design";
4
+ import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
5
+ export type FormValues<T> = UnpackNestedValue<T>;
6
+ export type FormErrors = FormNetworkErrors | FormUserErrors;
7
+ export type FormBannerMessage = FormWarningMessage | FormNoticeMessage;
8
+ export declare enum FormSubmitErrorType {
9
+ NetworkError = "NetworkError",
10
+ UserError = "UserErrors"
11
+ }
12
+ export declare enum FormBannerMessageType {
13
+ WarningMessage = "WarningMessage",
14
+ NoticeMessage = "NoticeMessage"
15
+ }
16
+ export interface FormBannerErrors {
17
+ networkError?: string | undefined;
18
+ bannerError?: {
19
+ title: string;
20
+ messages?: string[];
21
+ };
22
+ }
23
+ interface FormNetworkErrors {
24
+ errorType: FormSubmitErrorType.NetworkError;
25
+ networkErrors: string;
26
+ }
27
+ export interface FormUserErrors {
28
+ errorType: FormSubmitErrorType.UserError;
29
+ userErrors: Record<string, string>;
30
+ }
31
+ interface FormWarningMessage {
32
+ messageType: FormBannerMessageType.WarningMessage;
33
+ message: string;
34
+ }
35
+ interface FormNoticeMessage {
36
+ messageType: FormBannerMessageType.NoticeMessage;
37
+ message: string;
38
+ }
39
+ export type FormRef<T extends FieldValues = FieldValues> = (UseFormReturn<T> & {
40
+ scrollViewRef?: RefObject<KeyboardAwareScrollView>;
41
+ saveButtonHeight?: number;
42
+ messageBannerHeight?: number;
43
+ }) | undefined;
44
+ export interface FormProps<T extends FieldValues, SubmitResponseType> {
45
+ /**
46
+ * Content to be passed into the form
47
+ */
48
+ children: React.ReactNode;
49
+ /**
50
+ * A callback function that is run before invoking onSubmit. Form submission is canceled if the promise resolves to false.
51
+ */
52
+ onBeforeSubmit?: (data: FormValues<T>) => Promise<boolean>;
53
+ /**
54
+ * A callback function that handles the submission of form data
55
+ */
56
+ onSubmit: (data: FormValues<T>) => Promise<SubmitResponseType>;
57
+ /**
58
+ * A callback function that handles any error that occurs during "onSubmit"
59
+ */
60
+ onSubmitError: (error: FormErrors) => void;
61
+ /**
62
+ * A callback function that handles a successful form submission from "onSubmit"
63
+ */
64
+ onSubmitSuccess: (data: SubmitResponseType) => void;
65
+ /**
66
+ * Network or user errors to be displayed as a banner at the top of the form
67
+ */
68
+ bannerErrors?: FormBannerErrors;
69
+ /**
70
+ * Status messages to be displayed as a banner at the top of the form
71
+ */
72
+ bannerMessages?: FormBannerMessage[];
73
+ /**
74
+ * Loading when the initial form data is being fetched
75
+ */
76
+ initialLoading?: boolean;
77
+ /**
78
+ * The initial values of the form inputs
79
+ * This should be available as soon as initialLoading is set to false
80
+ */
81
+ initialValues?: FormValues<DeepPartial<T>>;
82
+ /**
83
+ * When the validation should happen.
84
+ * Possible values are "onBlur", "onChange", "onSubmit", "onTouched", and "all".
85
+ * The default value is "onTouched"
86
+ */
87
+ mode?: Mode;
88
+ /**
89
+ * When the validation after submission should happen.
90
+ * Possible values are "onBlur", "onChange", and "onSubmit".
91
+ * The default value is "onChange"
92
+ */
93
+ reValidateMode?: Exclude<Mode, "onTouched" | "all">;
94
+ /**
95
+ * ref object to access react hook form methods and state
96
+ */
97
+ formRef?: MutableRefObject<FormRef<T> | undefined>;
98
+ /**
99
+ * Label to be displayed for the save button
100
+ */
101
+ saveButtonLabel?: string;
102
+ /**
103
+ * @deprecated use `secondaryAction` instead.
104
+ * Override default save button in the sticky section of the form with another element.
105
+ */
106
+ renderStickySection?: (onSubmit: () => void, label: string | undefined, isSubmitting: boolean) => JSX.Element;
107
+ /**
108
+ * Adding a key will save a local copy of the form data that will be used to
109
+ * recover values when the app is backgrounded or has crashed.
110
+ */
111
+ localCacheKey?: string;
112
+ /**
113
+ * Forms field names that will not be considered for caching.
114
+ * Useful for omitting sensitive data.
115
+ */
116
+ localCacheExclude?: string[];
117
+ /**
118
+ * A string or array of strings that can be used to identify the pre-filled
119
+ * data on the form. This can be used to support local caching for forms that
120
+ * prefill data without inadvertently applying the cache at the wrong time.
121
+ *
122
+ * For example this can be used to when an object is based on data from
123
+ * another object (Quote being converted into a Job). This will allow
124
+ * the user to retrieve data from the cache when trying to create the
125
+ * same object (same Quote being converted into a Job) following an app crash.
126
+ *
127
+ * There is still only one copy of data for each `localCacheKey`.
128
+ * If a user opens the same form the data will only be loaded if the `localCacheId` matches
129
+ */
130
+ localCacheId?: string | string[];
131
+ /**
132
+ * Secondary Action for ButtonGroup
133
+ */
134
+ secondaryActions?: SecondaryActionProp[];
135
+ /**
136
+ * A number that will pull down the save button when the position is sticky.
137
+ * Useful when there's a footer or content below the form that is pulling
138
+ * the button up.
139
+ */
140
+ saveButtonOffset?: number;
141
+ /**
142
+ * Forces to render the sticky save button instead of the inline.
143
+ * The sticky save button is default for iOS but not for Android due to
144
+ * limitations. Use this prop with caution on Android.
145
+ */
146
+ showStickySaveButton?: boolean;
147
+ /**
148
+ * Renders a footer below the save button.
149
+ */
150
+ renderFooter?: React.ReactNode;
151
+ }
152
+ export type InternalFormProps<T extends FieldValues, SubmitResponseType> = Omit<FormProps<T, SubmitResponseType>, "initialLoading">;
153
+ export type ValidationRulesByFieldPath<T extends FieldValues> = {
154
+ [p in FieldPath<T>]: ControllerProps<T, p>["rules"];
155
+ };
156
+ export interface FormSaveButtonProps {
157
+ /**
158
+ * Press handler
159
+ */
160
+ primaryAction: () => Promise<void> | void;
161
+ /**
162
+ * Primary Button is loading
163
+ */
164
+ loading: boolean;
165
+ /**
166
+ * Label for the save button
167
+ */
168
+ label?: string;
169
+ /**
170
+ * Props and information regarding the secondary Action button(s)
171
+ */
172
+ secondaryActions?: SecondaryActionProp[];
173
+ /**
174
+ * Set whether secondary Button is loading
175
+ */
176
+ setSecondaryActionLoading?: (bool: boolean) => void;
177
+ /**
178
+ * Callback that is called when the secondary actions bottom sheet is opened.
179
+ */
180
+ onOpenBottomSheet?: () => void;
181
+ /**
182
+ * Callback that is called when the secondary actions bottom sheet is closed.
183
+ */
184
+ onCloseBottomSheet?: () => void;
185
+ }
186
+ interface SecondaryActionOnPress {
187
+ onBeforeSubmit?: () => Promise<boolean>;
188
+ onSubmit: (formSubmit: FormSaveButtonProps["primaryAction"]) => Promise<void>;
189
+ onSubmitSuccess?: () => void;
190
+ onSubmitError?: (error: FormErrors) => void;
191
+ resetFormOnSubmit?: boolean;
192
+ }
193
+ export interface SecondaryActionProp {
194
+ label: string;
195
+ icon?: IconNames | undefined;
196
+ handleAction: SecondaryActionOnPress;
197
+ destructive?: boolean;
198
+ }
199
+ export {};