@jobber/components-native 0.36.0 → 0.37.1-JOB-70291.14
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/dist/src/AtlantisContext/AtlantisContext.js +2 -0
- package/dist/src/ContentOverlay/ContentOverlay.js +144 -0
- package/dist/src/ContentOverlay/ContentOverlay.style.js +56 -0
- package/dist/src/ContentOverlay/hooks/useKeyboardVisibility.js +21 -0
- package/dist/src/ContentOverlay/hooks/useViewLayoutHeight.js +10 -0
- package/dist/src/ContentOverlay/index.js +1 -0
- package/dist/src/ContentOverlay/messages.js +8 -0
- package/dist/src/ContentOverlay/types.js +1 -0
- package/dist/src/Disclosure/Disclosure.js +50 -0
- package/dist/src/Disclosure/Disclosure.style.js +21 -0
- package/dist/src/Disclosure/constants.js +1 -0
- package/dist/src/Disclosure/index.js +1 -0
- package/dist/src/Form/Form.js +187 -0
- package/dist/src/Form/Form.style.js +33 -0
- package/dist/src/Form/components/FormActionBar/FormActionBar.js +21 -0
- package/dist/src/Form/components/FormActionBar/FormActionBar.style.js +5 -0
- package/dist/src/Form/components/FormActionBar/index.js +1 -0
- package/dist/src/Form/components/FormBody/FormBody.js +20 -0
- package/dist/src/Form/components/FormBody/FormBody.style.js +26 -0
- package/dist/src/Form/components/FormBody/index.js +1 -0
- package/dist/src/Form/components/FormCache/FormCache.js +34 -0
- package/dist/src/Form/components/FormErrorBanner/FormErrorBanner.js +21 -0
- package/dist/src/Form/components/FormErrorBanner/index.js +1 -0
- package/dist/src/Form/components/FormErrorBanner/messages.js +13 -0
- package/dist/src/Form/components/FormMask/FormMask.js +11 -0
- package/dist/src/Form/components/FormMask/FormMask.style.js +15 -0
- package/dist/src/Form/components/FormMask/index.js +1 -0
- package/dist/src/Form/components/FormMessage/FormMessage.js +48 -0
- package/dist/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.js +28 -0
- package/dist/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.style.js +17 -0
- package/dist/src/Form/components/FormMessage/components/InternalFormMessage/index.js +1 -0
- package/dist/src/Form/components/FormMessage/components/InternalFormMessage/messages.js +8 -0
- package/dist/src/Form/components/FormMessage/index.js +1 -0
- package/dist/src/Form/components/FormMessageBanner/FormMessageBanner.js +15 -0
- package/dist/src/Form/components/FormMessageBanner/index.js +1 -0
- package/dist/src/Form/components/FormSaveButton/FormSaveButton.js +69 -0
- package/dist/src/Form/components/FormSaveButton/index.js +1 -0
- package/dist/src/Form/components/FormSaveButton/messages.js +8 -0
- package/dist/src/Form/constants.js +2 -0
- package/dist/src/Form/context/AtlantisFormContext.js +16 -0
- package/dist/src/Form/context/index.js +1 -0
- package/dist/src/Form/context/types.js +1 -0
- package/dist/src/Form/hooks/useFormViewRefs.js +14 -0
- package/dist/src/Form/hooks/useInternalForm.js +37 -0
- package/dist/src/Form/hooks/useOfflineHandler.js +24 -0
- package/dist/src/Form/hooks/useSaveButtonPosition.js +25 -0
- package/dist/src/Form/hooks/useScreenInformation.js +15 -0
- package/dist/src/Form/hooks/useScrollToError/index.js +1 -0
- package/dist/src/Form/hooks/useScrollToError/useScrollToError.js +63 -0
- package/dist/src/Form/index.js +4 -0
- package/dist/src/Form/messages.js +28 -0
- package/dist/src/Form/types.js +10 -0
- package/dist/src/FormatFile/FormatFile.js +114 -0
- package/dist/src/FormatFile/FormatFile.style.js +16 -0
- package/dist/src/FormatFile/components/ErrorIcon/ErrorIcon.js +8 -0
- package/dist/src/FormatFile/components/ErrorIcon/ErrorIcon.style.js +10 -0
- package/dist/src/FormatFile/components/ErrorIcon/index.js +1 -0
- package/dist/src/FormatFile/components/FileView/FileView.js +67 -0
- package/dist/src/FormatFile/components/FileView/FileView.style.js +64 -0
- package/dist/src/FormatFile/components/FileView/index.js +1 -0
- package/dist/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.js +22 -0
- package/dist/src/FormatFile/components/FormatFileBottomSheet/index.js +1 -0
- package/dist/src/FormatFile/components/FormatFileBottomSheet/messages.js +13 -0
- package/dist/src/FormatFile/components/MediaView/MediaView.js +56 -0
- package/dist/src/FormatFile/components/MediaView/MediaView.style.js +27 -0
- package/dist/src/FormatFile/components/MediaView/index.js +1 -0
- package/dist/src/FormatFile/components/ProgressBar/ProgressBar.js +29 -0
- package/dist/src/FormatFile/components/ProgressBar/ProgressBar.style.js +15 -0
- package/dist/src/FormatFile/components/ProgressBar/index.js +1 -0
- package/dist/src/FormatFile/components/_mocks/mockFiles.js +78 -0
- package/dist/src/FormatFile/constants.js +14 -0
- package/dist/src/FormatFile/context/FormatFileContext.js +8 -0
- package/dist/src/FormatFile/context/types.js +1 -0
- package/dist/src/FormatFile/index.js +1 -0
- package/dist/src/FormatFile/messages.js +23 -0
- package/dist/src/FormatFile/types.js +8 -0
- package/dist/src/FormatFile/utils/computeA11yLabel.js +12 -0
- package/dist/src/FormatFile/utils/createUseCreateThumbnail.js +22 -0
- package/dist/src/FormatFile/utils/index.js +1 -0
- package/dist/src/InputDate/InputDate.js +76 -0
- package/dist/src/InputDate/index.js +1 -0
- package/dist/src/InputDate/messages.js +8 -0
- package/dist/src/Menu/Menu.js +67 -0
- package/dist/src/Menu/Menu.style.js +6 -0
- package/dist/src/Menu/components/MenuOption/MenuOption.js +25 -0
- package/dist/src/Menu/components/MenuOption/MenuOption.style.js +10 -0
- package/dist/src/Menu/components/MenuOption/index.js +1 -0
- package/dist/src/Menu/components/Overlay/Overlay.js +9 -0
- package/dist/src/Menu/components/Overlay/Overlay.style.js +6 -0
- package/dist/src/Menu/components/Overlay/index.js +1 -0
- package/dist/src/Menu/index.js +1 -0
- package/dist/src/Menu/messages.js +8 -0
- package/dist/src/Menu/types.js +1 -0
- package/dist/src/Menu/utils.js +84 -0
- package/dist/src/ThumbnailList/ThumbnailList.js +35 -0
- package/dist/src/ThumbnailList/ThumbnailList.style.js +49 -0
- package/dist/src/ThumbnailList/index.js +1 -0
- package/dist/src/index.js +7 -0
- package/dist/src/utils/test/wait.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/AtlantisContext/AtlantisContext.d.ts +7 -1
- package/dist/types/src/ContentOverlay/ContentOverlay.d.ts +6 -0
- package/dist/types/src/ContentOverlay/ContentOverlay.style.d.ts +60 -0
- package/dist/types/src/ContentOverlay/hooks/useKeyboardVisibility.d.ts +6 -0
- package/dist/types/src/ContentOverlay/hooks/useViewLayoutHeight.d.ts +6 -0
- package/dist/types/src/ContentOverlay/index.d.ts +2 -0
- package/dist/types/src/ContentOverlay/messages.d.ts +7 -0
- package/dist/types/src/ContentOverlay/types.d.ts +87 -0
- package/dist/types/src/Disclosure/Disclosure.d.ts +35 -0
- package/dist/types/src/Disclosure/Disclosure.style.d.ts +19 -0
- package/dist/types/src/Disclosure/constants.d.ts +1 -0
- package/dist/types/src/Disclosure/index.d.ts +1 -0
- package/dist/types/src/Form/Form.d.ts +4 -0
- package/dist/types/src/Form/Form.style.d.ts +31 -0
- package/dist/types/src/Form/components/FormActionBar/FormActionBar.d.ts +13 -0
- package/dist/types/src/Form/components/FormActionBar/FormActionBar.style.d.ts +15 -0
- package/dist/types/src/Form/components/FormActionBar/index.d.ts +2 -0
- package/dist/types/src/Form/components/FormBody/FormBody.d.ts +10 -0
- package/dist/types/src/Form/components/FormBody/FormBody.style.d.ts +24 -0
- package/dist/types/src/Form/components/FormBody/index.d.ts +1 -0
- package/dist/types/src/Form/components/FormCache/FormCache.d.ts +10 -0
- package/dist/types/src/Form/components/FormErrorBanner/FormErrorBanner.d.ts +3 -0
- package/dist/types/src/Form/components/FormErrorBanner/index.d.ts +1 -0
- package/dist/types/src/Form/components/FormErrorBanner/messages.d.ts +12 -0
- package/dist/types/src/Form/components/FormMask/FormMask.d.ts +2 -0
- package/dist/types/src/Form/components/FormMask/FormMask.style.d.ts +13 -0
- package/dist/types/src/Form/components/FormMask/index.d.ts +1 -0
- package/dist/types/src/Form/components/FormMessage/FormMessage.d.ts +20 -0
- package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.d.ts +8 -0
- package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.style.d.ts +20 -0
- package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/index.d.ts +1 -0
- package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/messages.d.ts +7 -0
- package/dist/types/src/Form/components/FormMessage/index.d.ts +1 -0
- package/dist/types/src/Form/components/FormMessageBanner/FormMessageBanner.d.ts +7 -0
- package/dist/types/src/Form/components/FormMessageBanner/index.d.ts +1 -0
- package/dist/types/src/Form/components/FormSaveButton/FormSaveButton.d.ts +3 -0
- package/dist/types/src/Form/components/FormSaveButton/index.d.ts +1 -0
- package/dist/types/src/Form/components/FormSaveButton/messages.d.ts +7 -0
- package/dist/types/src/Form/constants.d.ts +2 -0
- package/dist/types/src/Form/context/AtlantisFormContext.d.ts +12 -0
- package/dist/types/src/Form/context/index.d.ts +2 -0
- package/dist/types/src/Form/context/types.d.ts +26 -0
- package/dist/types/src/Form/hooks/useFormViewRefs.d.ts +10 -0
- package/dist/types/src/Form/hooks/useInternalForm.d.ts +19 -0
- package/dist/types/src/Form/hooks/useOfflineHandler.d.ts +1 -0
- package/dist/types/src/Form/hooks/useSaveButtonPosition.d.ts +12 -0
- package/dist/types/src/Form/hooks/useScreenInformation.d.ts +8 -0
- package/dist/types/src/Form/hooks/useScrollToError/index.d.ts +1 -0
- package/dist/types/src/Form/hooks/useScrollToError/useScrollToError.d.ts +10 -0
- package/dist/types/src/Form/index.d.ts +5 -0
- package/dist/types/src/Form/messages.d.ts +27 -0
- package/dist/types/src/Form/types.d.ts +199 -0
- package/dist/types/src/FormatFile/FormatFile.d.ts +47 -0
- package/dist/types/src/FormatFile/FormatFile.style.d.ts +14 -0
- package/dist/types/src/FormatFile/components/ErrorIcon/ErrorIcon.d.ts +2 -0
- package/dist/types/src/FormatFile/components/ErrorIcon/ErrorIcon.style.d.ts +8 -0
- package/dist/types/src/FormatFile/components/ErrorIcon/index.d.ts +1 -0
- package/dist/types/src/FormatFile/components/FileView/FileView.d.ts +12 -0
- package/dist/types/src/FormatFile/components/FileView/FileView.style.d.ts +62 -0
- package/dist/types/src/FormatFile/components/FileView/index.d.ts +1 -0
- package/dist/types/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.d.ts +11 -0
- package/dist/types/src/FormatFile/components/FormatFileBottomSheet/index.d.ts +2 -0
- package/dist/types/src/FormatFile/components/FormatFileBottomSheet/messages.d.ts +12 -0
- package/dist/types/src/FormatFile/components/MediaView/MediaView.d.ts +12 -0
- package/dist/types/src/FormatFile/components/MediaView/MediaView.style.d.ts +25 -0
- package/dist/types/src/FormatFile/components/MediaView/index.d.ts +1 -0
- package/dist/types/src/FormatFile/components/ProgressBar/ProgressBar.d.ts +19 -0
- package/dist/types/src/FormatFile/components/ProgressBar/ProgressBar.style.d.ts +13 -0
- package/dist/types/src/FormatFile/components/ProgressBar/index.d.ts +1 -0
- package/dist/types/src/FormatFile/components/_mocks/mockFiles.d.ts +18 -0
- package/dist/types/src/FormatFile/constants.d.ts +6 -0
- package/dist/types/src/FormatFile/context/FormatFileContext.d.ts +10 -0
- package/dist/types/src/FormatFile/context/types.d.ts +9 -0
- package/dist/types/src/FormatFile/index.d.ts +3 -0
- package/dist/types/src/FormatFile/messages.d.ts +22 -0
- package/dist/types/src/FormatFile/types.d.ts +105 -0
- package/dist/types/src/FormatFile/utils/computeA11yLabel.d.ts +9 -0
- package/dist/types/src/FormatFile/utils/createUseCreateThumbnail.d.ts +5 -0
- package/dist/types/src/FormatFile/utils/index.d.ts +1 -0
- package/dist/types/src/InputCurrency/InputCurrency.d.ts +1 -1
- package/dist/types/src/InputDate/InputDate.d.ts +74 -0
- package/dist/types/src/InputDate/index.d.ts +1 -0
- package/dist/types/src/InputDate/messages.d.ts +7 -0
- package/dist/types/src/InputNumber/InputNumber.d.ts +1 -1
- package/dist/types/src/Menu/Menu.d.ts +3 -0
- package/dist/types/src/Menu/Menu.style.d.ts +18 -0
- package/dist/types/src/Menu/components/MenuOption/MenuOption.d.ts +3 -0
- package/dist/types/src/Menu/components/MenuOption/MenuOption.style.d.ts +8 -0
- package/dist/types/src/Menu/components/MenuOption/index.d.ts +1 -0
- package/dist/types/src/Menu/components/Overlay/Overlay.d.ts +3 -0
- package/dist/types/src/Menu/components/Overlay/Overlay.style.d.ts +12 -0
- package/dist/types/src/Menu/components/Overlay/index.d.ts +1 -0
- package/dist/types/src/Menu/index.d.ts +2 -0
- package/dist/types/src/Menu/messages.d.ts +7 -0
- package/dist/types/src/Menu/types.d.ts +22 -0
- package/dist/types/src/Menu/utils.d.ts +10 -0
- package/dist/types/src/ThumbnailList/ThumbnailList.d.ts +17 -0
- package/dist/types/src/ThumbnailList/ThumbnailList.style.d.ts +47 -0
- package/dist/types/src/ThumbnailList/index.d.ts +1 -0
- package/dist/types/src/index.d.ts +7 -0
- package/package.json +4 -2
- package/src/AtlantisContext/AtlantisContext.tsx +10 -1
- package/src/ContentOverlay/ContentOverlay.style.ts +70 -0
- package/src/ContentOverlay/ContentOverlay.test.tsx +371 -0
- package/src/ContentOverlay/ContentOverlay.tsx +295 -0
- package/src/ContentOverlay/hooks/useKeyboardVisibility.test.ts +42 -0
- package/src/ContentOverlay/hooks/useKeyboardVisibility.ts +36 -0
- package/src/ContentOverlay/hooks/useViewLayoutHeight.test.ts +56 -0
- package/src/ContentOverlay/hooks/useViewLayoutHeight.ts +18 -0
- package/src/ContentOverlay/index.ts +2 -0
- package/src/ContentOverlay/messages.ts +9 -0
- package/src/ContentOverlay/types.ts +96 -0
- package/src/Disclosure/Disclosure.style.ts +22 -0
- package/src/Disclosure/Disclosure.test.tsx +71 -0
- package/src/Disclosure/Disclosure.tsx +162 -0
- package/src/Disclosure/__snapshots__/Disclosure.test.tsx.snap +488 -0
- package/src/Disclosure/constants.ts +1 -0
- package/src/Disclosure/index.ts +1 -0
- package/src/Form/Form.style.ts +34 -0
- package/src/Form/Form.test.tsx +588 -0
- package/src/Form/Form.tsx +296 -0
- package/src/Form/components/FormActionBar/FormActionBar.style.ts +11 -0
- package/src/Form/components/FormActionBar/FormActionBar.tsx +63 -0
- package/src/Form/components/FormActionBar/index.ts +2 -0
- package/src/Form/components/FormBody/FormBody.style.ts +27 -0
- package/src/Form/components/FormBody/FormBody.tsx +62 -0
- package/src/Form/components/FormBody/index.ts +1 -0
- package/src/Form/components/FormCache/FormCache.tsx +50 -0
- package/src/Form/components/FormErrorBanner/FormErrorBanner.test.tsx +124 -0
- package/src/Form/components/FormErrorBanner/FormErrorBanner.tsx +34 -0
- package/src/Form/components/FormErrorBanner/index.ts +1 -0
- package/src/Form/components/FormErrorBanner/messages.ts +14 -0
- package/src/Form/components/FormMask/FormMask.style.tsx +16 -0
- package/src/Form/components/FormMask/FormMask.tsx +19 -0
- package/src/Form/components/FormMask/index.ts +1 -0
- package/src/Form/components/FormMessage/FormMessage.test.tsx +72 -0
- package/src/Form/components/FormMessage/FormMessage.tsx +63 -0
- package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.style.ts +18 -0
- package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.tsx +55 -0
- package/src/Form/components/FormMessage/components/InternalFormMessage/index.ts +1 -0
- package/src/Form/components/FormMessage/components/InternalFormMessage/messages.ts +10 -0
- package/src/Form/components/FormMessage/index.ts +1 -0
- package/src/Form/components/FormMessageBanner/FormMessageBanner.test.tsx +27 -0
- package/src/Form/components/FormMessageBanner/FormMessageBanner.tsx +33 -0
- package/src/Form/components/FormMessageBanner/index.ts +1 -0
- package/src/Form/components/FormSaveButton/FormSaveButton.test.tsx +159 -0
- package/src/Form/components/FormSaveButton/FormSaveButton.tsx +103 -0
- package/src/Form/components/FormSaveButton/index.ts +1 -0
- package/src/Form/components/FormSaveButton/messages.ts +9 -0
- package/src/Form/constants.ts +2 -0
- package/src/Form/context/AtlantisFormContext.test.tsx +45 -0
- package/src/Form/context/AtlantisFormContext.tsx +21 -0
- package/src/Form/context/index.ts +5 -0
- package/src/Form/context/types.ts +34 -0
- package/src/Form/hooks/useFormViewRefs.ts +23 -0
- package/src/Form/hooks/useInternalForm.ts +99 -0
- package/src/Form/hooks/useOfflineHandler.ts +36 -0
- package/src/Form/hooks/useSaveButtonPosition.ts +52 -0
- package/src/Form/hooks/useScreenInformation.ts +25 -0
- package/src/Form/hooks/useScrollToError/index.ts +1 -0
- package/src/Form/hooks/useScrollToError/useScrollToError.test.tsx +103 -0
- package/src/Form/hooks/useScrollToError/useScrollToError.ts +102 -0
- package/src/Form/index.ts +13 -0
- package/src/Form/messages.ts +33 -0
- package/src/Form/types.ts +255 -0
- package/src/FormatFile/FormatFile.style.ts +17 -0
- package/src/FormatFile/FormatFile.test.tsx +333 -0
- package/src/FormatFile/FormatFile.tsx +300 -0
- package/src/FormatFile/components/ErrorIcon/ErrorIcon.style.ts +11 -0
- package/src/FormatFile/components/ErrorIcon/ErrorIcon.tsx +12 -0
- package/src/FormatFile/components/ErrorIcon/index.ts +1 -0
- package/src/FormatFile/components/FileView/FileView.style.ts +65 -0
- package/src/FormatFile/components/FileView/FileView.tsx +134 -0
- package/src/FormatFile/components/FileView/index.ts +1 -0
- package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.test.tsx +108 -0
- package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.tsx +56 -0
- package/src/FormatFile/components/FormatFileBottomSheet/index.ts +2 -0
- package/src/FormatFile/components/FormatFileBottomSheet/messages.ts +14 -0
- package/src/FormatFile/components/MediaView/MediaView.style.ts +28 -0
- package/src/FormatFile/components/MediaView/MediaView.tsx +145 -0
- package/src/FormatFile/components/MediaView/index.ts +1 -0
- package/src/FormatFile/components/ProgressBar/ProgressBar.style.tsx +16 -0
- package/src/FormatFile/components/ProgressBar/ProgressBar.tsx +57 -0
- package/src/FormatFile/components/ProgressBar/index.ts +1 -0
- package/src/FormatFile/components/_mocks/mockFiles.ts +105 -0
- package/src/FormatFile/constants.ts +15 -0
- package/src/FormatFile/context/FormatFileContext.ts +13 -0
- package/src/FormatFile/context/types.ts +12 -0
- package/src/FormatFile/index.ts +13 -0
- package/src/FormatFile/messages.ts +24 -0
- package/src/FormatFile/types.ts +126 -0
- package/src/FormatFile/utils/computeA11yLabel.ts +26 -0
- package/src/FormatFile/utils/createUseCreateThumbnail.ts +33 -0
- package/src/FormatFile/utils/index.ts +1 -0
- package/src/InputCurrency/InputCurrency.tsx +1 -1
- package/src/InputDate/InputDate.test.tsx +295 -0
- package/src/InputDate/InputDate.tsx +231 -0
- package/src/InputDate/index.ts +1 -0
- package/src/InputDate/messages.ts +9 -0
- package/src/InputNumber/InputNumber.tsx +1 -1
- package/src/Menu/Menu.style.ts +16 -0
- package/src/Menu/Menu.test.tsx +201 -0
- package/src/Menu/Menu.tsx +116 -0
- package/src/Menu/components/MenuOption/MenuOption.style.tsx +11 -0
- package/src/Menu/components/MenuOption/MenuOption.tsx +63 -0
- package/src/Menu/components/MenuOption/index.ts +1 -0
- package/src/Menu/components/Overlay/Overlay.style.ts +13 -0
- package/src/Menu/components/Overlay/Overlay.tsx +16 -0
- package/src/Menu/components/Overlay/index.ts +1 -0
- package/src/Menu/index.ts +6 -0
- package/src/Menu/messages.ts +9 -0
- package/src/Menu/types.ts +25 -0
- package/src/Menu/utils.ts +151 -0
- package/src/ThumbnailList/ThumbnailList.style.ts +50 -0
- package/src/ThumbnailList/ThumbnailList.test.tsx +71 -0
- package/src/ThumbnailList/ThumbnailList.tsx +74 -0
- package/src/ThumbnailList/__snapshots__/ThumbnailList.test.tsx.snap +154 -0
- package/src/ThumbnailList/index.ts +1 -0
- package/src/index.ts +7 -0
- package/src/utils/test/wait.ts +3 -1
|
@@ -3,6 +3,7 @@ import { createContext, useContext } from "react";
|
|
|
3
3
|
import RNLocalize from "react-native-localize";
|
|
4
4
|
import { DEFAULT_CURRENCY_SYMBOL } from "../InputCurrency/constants";
|
|
5
5
|
export const defaultValues = {
|
|
6
|
+
dateFormat: "PP",
|
|
6
7
|
// The system time is "p"
|
|
7
8
|
timeFormat: "p",
|
|
8
9
|
timeZone: RNLocalize.getTimeZone(),
|
|
@@ -12,6 +13,7 @@ export const defaultValues = {
|
|
|
12
13
|
},
|
|
13
14
|
floatSeparators: { group: ",", decimal: "." },
|
|
14
15
|
currencySymbol: DEFAULT_CURRENCY_SYMBOL,
|
|
16
|
+
headerHeight: 0,
|
|
15
17
|
};
|
|
16
18
|
export const AtlantisContext = createContext(defaultValues);
|
|
17
19
|
export function useAtlantisContext() {
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import React, { forwardRef, useCallback, useImperativeHandle, useMemo, useRef, useState, } from "react";
|
|
2
|
+
import { Modalize } from "react-native-modalize";
|
|
3
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
4
|
+
import { AccessibilityInfo, Platform, View, findNodeHandle, useWindowDimensions, } from "react-native";
|
|
5
|
+
import { Portal } from "react-native-portalize";
|
|
6
|
+
import { useIntl } from "react-intl";
|
|
7
|
+
import { useKeyboardVisibility } from "./hooks/useKeyboardVisibility";
|
|
8
|
+
import { styles } from "./ContentOverlay.style";
|
|
9
|
+
import { messages } from "./messages";
|
|
10
|
+
import { useViewLayoutHeight } from "./hooks/useViewLayoutHeight";
|
|
11
|
+
import { useIsScreenReaderEnabled } from "../hooks";
|
|
12
|
+
import { IconButton } from "../IconButton";
|
|
13
|
+
import { tokens } from "../utils/design";
|
|
14
|
+
import { Heading } from "../Heading";
|
|
15
|
+
export const ContentOverlay = forwardRef(ContentOverlayPortal);
|
|
16
|
+
const ContentOverlayModal = forwardRef(ContentOverlayInternal);
|
|
17
|
+
// eslint-disable-next-line max-statements
|
|
18
|
+
function ContentOverlayInternal({ children, title, accessibilityLabel, fullScreen = false, showDismiss = false, isDraggable = true, adjustToContentHeight = false, keyboardShouldPersistTaps = false, keyboardAvoidingBehavior, scrollEnabled = false, modalBackgroundColor = "surface", onClose, onOpen, onBeforeExit, loading = false, avoidKeyboardLikeIOS, }, ref) {
|
|
19
|
+
isDraggable = onBeforeExit ? false : isDraggable;
|
|
20
|
+
const isCloseableOnOverlayTap = onBeforeExit ? false : true;
|
|
21
|
+
const { formatMessage } = useIntl();
|
|
22
|
+
const { width: windowWidth, height: windowHeight } = useWindowDimensions();
|
|
23
|
+
const insets = useSafeAreaInsets();
|
|
24
|
+
const [position, setPosition] = useState("initial");
|
|
25
|
+
const isScreenReaderEnabled = useIsScreenReaderEnabled();
|
|
26
|
+
const isFullScreenOrTopPosition = fullScreen || (!adjustToContentHeight && position === "top");
|
|
27
|
+
const shouldShowDismiss = showDismiss || isScreenReaderEnabled || isFullScreenOrTopPosition;
|
|
28
|
+
const [showHeaderShadow, setShowHeaderShadow] = useState(false);
|
|
29
|
+
const overlayHeader = useRef();
|
|
30
|
+
const internalRef = useRef();
|
|
31
|
+
const [modalizeMethods, setModalizeMethods] = useState();
|
|
32
|
+
const callbackInternalRef = useCallback((instance) => {
|
|
33
|
+
if (instance && !internalRef.current) {
|
|
34
|
+
internalRef.current = instance;
|
|
35
|
+
setModalizeMethods(instance);
|
|
36
|
+
}
|
|
37
|
+
}, []);
|
|
38
|
+
const refMethods = useMemo(() => {
|
|
39
|
+
if (!(modalizeMethods === null || modalizeMethods === void 0 ? void 0 : modalizeMethods.open) || !(modalizeMethods === null || modalizeMethods === void 0 ? void 0 : modalizeMethods.close)) {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
open: modalizeMethods === null || modalizeMethods === void 0 ? void 0 : modalizeMethods.open,
|
|
44
|
+
close: modalizeMethods === null || modalizeMethods === void 0 ? void 0 : modalizeMethods.close,
|
|
45
|
+
};
|
|
46
|
+
}, [modalizeMethods]);
|
|
47
|
+
const { keyboardHeight } = useKeyboardVisibility();
|
|
48
|
+
useImperativeHandle(ref, () => refMethods, [refMethods]);
|
|
49
|
+
const { handleLayout: handleChildrenLayout, height: childrenHeight, heightKnown: childrenHeightKnown, } = useViewLayoutHeight();
|
|
50
|
+
const { handleLayout: handleHeaderLayout, height: headerHeight, heightKnown: headerHeightKnown, } = useViewLayoutHeight();
|
|
51
|
+
const snapPoint = useMemo(() => {
|
|
52
|
+
if (fullScreen || !isDraggable || adjustToContentHeight) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
const overlayHeight = headerHeight + childrenHeight;
|
|
56
|
+
if (overlayHeight >= windowHeight) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
return overlayHeight;
|
|
60
|
+
}, [
|
|
61
|
+
fullScreen,
|
|
62
|
+
isDraggable,
|
|
63
|
+
adjustToContentHeight,
|
|
64
|
+
headerHeight,
|
|
65
|
+
childrenHeight,
|
|
66
|
+
windowHeight,
|
|
67
|
+
]);
|
|
68
|
+
const modalStyle = [
|
|
69
|
+
styles.modal,
|
|
70
|
+
windowWidth > 640 ? styles.modalForLargeScreens : undefined,
|
|
71
|
+
{ backgroundColor: getModalBackgroundColor(modalBackgroundColor) },
|
|
72
|
+
keyboardHeight > 0 && { marginBottom: 0 },
|
|
73
|
+
];
|
|
74
|
+
const renderedChildren = renderChildren();
|
|
75
|
+
const renderedHeader = renderHeader();
|
|
76
|
+
const onCloseController = () => {
|
|
77
|
+
var _a;
|
|
78
|
+
if (!onBeforeExit) {
|
|
79
|
+
(_a = internalRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
onBeforeExit();
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return (React.createElement(React.Fragment, null,
|
|
88
|
+
headerHeightKnown && childrenHeightKnown && (React.createElement(Modalize, { ref: callbackInternalRef, overlayStyle: styles.overlay, handleStyle: styles.handle, handlePosition: "inside", modalStyle: modalStyle, modalTopOffset: tokens["space-larger"], snapPoint: snapPoint, closeSnapPointStraightEnabled: false, withHandle: isDraggable, panGestureEnabled: isDraggable, adjustToContentHeight: adjustToContentHeight, disableScrollIfPossible: !adjustToContentHeight, onClose: onClose, onOpen: onOpen, keyboardAvoidingBehavior: keyboardAvoidingBehavior, avoidKeyboardLikeIOS: avoidKeyboardLikeIOS, childrenStyle: styles.childrenStyle, onBackButtonPress: onCloseController, closeOnOverlayTap: isCloseableOnOverlayTap, onOpened: () => {
|
|
89
|
+
if (overlayHeader.current) {
|
|
90
|
+
const reactTag = findNodeHandle(overlayHeader.current);
|
|
91
|
+
if (reactTag) {
|
|
92
|
+
AccessibilityInfo.setAccessibilityFocus(reactTag);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}, scrollViewProps: {
|
|
96
|
+
scrollEnabled,
|
|
97
|
+
showsVerticalScrollIndicator: false,
|
|
98
|
+
stickyHeaderIndices: Platform.OS === "android" ? [0] : undefined,
|
|
99
|
+
onScroll: handleOnScroll,
|
|
100
|
+
keyboardShouldPersistTaps: keyboardShouldPersistTaps
|
|
101
|
+
? "handled"
|
|
102
|
+
: "never",
|
|
103
|
+
}, HeaderComponent: Platform.OS === "ios" ? renderedHeader : undefined, onPositionChange: setPosition },
|
|
104
|
+
Platform.OS === "android" ? renderedHeader : undefined,
|
|
105
|
+
renderedChildren)),
|
|
106
|
+
!childrenHeightKnown && (React.createElement(View, { style: [styles.hiddenContent, modalStyle] }, renderedChildren)),
|
|
107
|
+
!headerHeightKnown && (React.createElement(View, { style: [styles.hiddenContent, modalStyle] }, renderedHeader))));
|
|
108
|
+
function renderHeader() {
|
|
109
|
+
const closeOverlayA11YLabel = formatMessage(messages.closeOverlayA11YLabel, {
|
|
110
|
+
title: title,
|
|
111
|
+
});
|
|
112
|
+
const headerStyles = [
|
|
113
|
+
styles.header,
|
|
114
|
+
showHeaderShadow && styles.headerShadow,
|
|
115
|
+
{ backgroundColor: getModalBackgroundColor(modalBackgroundColor) },
|
|
116
|
+
];
|
|
117
|
+
return (React.createElement(View, { onLayout: handleHeaderLayout, testID: "ATL-Overlay-Header" },
|
|
118
|
+
React.createElement(View, { style: headerStyles },
|
|
119
|
+
React.createElement(View, { style: showDismiss ? styles.titleWithDismiss : styles.titleWithoutDimiss },
|
|
120
|
+
React.createElement(Heading, { level: "subtitle", variation: loading ? "subdued" : "heading" }, title)),
|
|
121
|
+
shouldShowDismiss && (React.createElement(View, { style: styles.dismissButton,
|
|
122
|
+
// @ts-expect-error tsc-ci
|
|
123
|
+
ref: overlayHeader, accessibilityLabel: accessibilityLabel || closeOverlayA11YLabel, accessible: true },
|
|
124
|
+
React.createElement(IconButton, { name: "cross", customColor: loading ? tokens["color-disabled"] : tokens["color-heading"], onPress: () => onCloseController(), accessibilityLabel: closeOverlayA11YLabel, testID: "ATL-Overlay-CloseButton" }))))));
|
|
125
|
+
}
|
|
126
|
+
function renderChildren() {
|
|
127
|
+
return (React.createElement(View, { style: { paddingBottom: insets.bottom }, onLayout: handleChildrenLayout, testID: "ATL-Overlay-Children" }, children));
|
|
128
|
+
}
|
|
129
|
+
function handleOnScroll({ nativeEvent, }) {
|
|
130
|
+
setShowHeaderShadow(nativeEvent.contentOffset.y > 0);
|
|
131
|
+
}
|
|
132
|
+
function getModalBackgroundColor(variation) {
|
|
133
|
+
switch (variation) {
|
|
134
|
+
case "surface":
|
|
135
|
+
return tokens["color-surface"];
|
|
136
|
+
case "background":
|
|
137
|
+
return tokens["color-surface--background"];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function ContentOverlayPortal(modalProps, ref) {
|
|
142
|
+
return (React.createElement(Portal, null,
|
|
143
|
+
React.createElement(ContentOverlayModal, Object.assign({ ref: ref }, modalProps))));
|
|
144
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { tokens } from "../utils/design";
|
|
3
|
+
const modalBorderRadius = tokens["radius-larger"];
|
|
4
|
+
const titleOffsetFromHandle = tokens["space-small"] + tokens["space-smallest"];
|
|
5
|
+
export const styles = StyleSheet.create({
|
|
6
|
+
handle: {
|
|
7
|
+
width: tokens["space-largest"],
|
|
8
|
+
height: tokens["space-smaller"] + tokens["space-smallest"],
|
|
9
|
+
backgroundColor: tokens["color-border"],
|
|
10
|
+
top: tokens["space-small"],
|
|
11
|
+
borderRadius: tokens["radius-circle"],
|
|
12
|
+
},
|
|
13
|
+
overlay: {
|
|
14
|
+
backgroundColor: tokens["color-overlay"],
|
|
15
|
+
},
|
|
16
|
+
modal: {
|
|
17
|
+
borderTopLeftRadius: modalBorderRadius,
|
|
18
|
+
borderTopRightRadius: modalBorderRadius,
|
|
19
|
+
},
|
|
20
|
+
modalForLargeScreens: {
|
|
21
|
+
width: 640,
|
|
22
|
+
alignSelf: "center",
|
|
23
|
+
},
|
|
24
|
+
header: {
|
|
25
|
+
flexDirection: "row",
|
|
26
|
+
backgroundColor: tokens["color-surface"],
|
|
27
|
+
paddingTop: titleOffsetFromHandle,
|
|
28
|
+
zIndex: tokens["elevation-base"],
|
|
29
|
+
borderTopLeftRadius: modalBorderRadius,
|
|
30
|
+
borderTopRightRadius: modalBorderRadius,
|
|
31
|
+
height: tokens["space-extravagant"],
|
|
32
|
+
},
|
|
33
|
+
headerShadow: Object.assign({}, tokens["shadow-base"]),
|
|
34
|
+
childrenStyle: {
|
|
35
|
+
// We need to explicity lower the zIndex because otherwise, the modal content slides over the header shadow.
|
|
36
|
+
zIndex: -1,
|
|
37
|
+
},
|
|
38
|
+
dismissButton: {
|
|
39
|
+
alignItems: "center",
|
|
40
|
+
},
|
|
41
|
+
hiddenContent: {
|
|
42
|
+
opacity: 0,
|
|
43
|
+
},
|
|
44
|
+
titleWithoutDimiss: {
|
|
45
|
+
flex: 1,
|
|
46
|
+
flexDirection: "row",
|
|
47
|
+
justifyContent: "center",
|
|
48
|
+
paddingTop: tokens["space-base"],
|
|
49
|
+
},
|
|
50
|
+
titleWithDismiss: {
|
|
51
|
+
flex: 1,
|
|
52
|
+
justifyContent: "center",
|
|
53
|
+
paddingLeft: tokens["space-base"],
|
|
54
|
+
paddingRight: tokens["space-smaller"],
|
|
55
|
+
},
|
|
56
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { Keyboard } from "react-native";
|
|
3
|
+
export function useKeyboardVisibility() {
|
|
4
|
+
const [isKeyboardVisible, setKeyboardVisible] = useState(false);
|
|
5
|
+
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const keyboardDidShowListener = Keyboard.addListener("keyboardDidShow", (event) => {
|
|
8
|
+
setKeyboardVisible(true);
|
|
9
|
+
setKeyboardHeight(event.endCoordinates.height);
|
|
10
|
+
});
|
|
11
|
+
const keyboardDidHideListener = Keyboard.addListener("keyboardDidHide", () => {
|
|
12
|
+
setKeyboardVisible(false);
|
|
13
|
+
setKeyboardHeight(0);
|
|
14
|
+
});
|
|
15
|
+
return () => {
|
|
16
|
+
keyboardDidHideListener.remove();
|
|
17
|
+
keyboardDidShowListener.remove();
|
|
18
|
+
};
|
|
19
|
+
}, []);
|
|
20
|
+
return { isKeyboardVisible, keyboardHeight };
|
|
21
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
export function useViewLayoutHeight() {
|
|
3
|
+
const [heightKnown, setHeightKnown] = useState(false);
|
|
4
|
+
const [height, setHeight] = useState(0);
|
|
5
|
+
const handleLayout = ({ nativeEvent }) => {
|
|
6
|
+
setHeightKnown(true);
|
|
7
|
+
setHeight(nativeEvent.layout.height);
|
|
8
|
+
};
|
|
9
|
+
return { handleLayout, height, heightKnown };
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ContentOverlay } from "./ContentOverlay";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defineMessages } from "react-intl";
|
|
2
|
+
export const messages = defineMessages({
|
|
3
|
+
closeOverlayA11YLabel: {
|
|
4
|
+
id: "closeOverlayA11yLabel",
|
|
5
|
+
defaultMessage: "Close {title} modal",
|
|
6
|
+
description: "Accessibility label for button to close the overlay modal",
|
|
7
|
+
},
|
|
8
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { ScrollView, TouchableOpacity, View, } from "react-native";
|
|
3
|
+
import Reanimated, { Easing, useAnimatedStyle, useSharedValue, withTiming, } from "react-native-reanimated";
|
|
4
|
+
import { EASE_CUBIC_IN_OUT } from "./constants";
|
|
5
|
+
import { styles } from "./Disclosure.style";
|
|
6
|
+
import { tokens } from "../utils/design";
|
|
7
|
+
import { Icon } from "../Icon";
|
|
8
|
+
const ReanimatedView = Reanimated.createAnimatedComponent(View);
|
|
9
|
+
const ReanimatedScrollView = Reanimated.createAnimatedComponent(ScrollView);
|
|
10
|
+
export function Disclosure({ content, header, open, onToggle, isEmpty, animationDuration = tokens["timing-slowest"], }) {
|
|
11
|
+
return (React.createElement(View, { style: styles.container },
|
|
12
|
+
React.createElement(DisclosureHeader, Object.assign({}, { header, onToggle, isEmpty, open, animationDuration })),
|
|
13
|
+
React.createElement(DisclosureContent, Object.assign({}, { content, open, animationDuration }))));
|
|
14
|
+
}
|
|
15
|
+
function DisclosureHeader({ header, onToggle, isEmpty, open, animationDuration, }) {
|
|
16
|
+
const rotateZ = useSharedValue(0);
|
|
17
|
+
rotateZ.value = withTiming(open ? 0 : -180, {
|
|
18
|
+
easing: Easing.bezier(...EASE_CUBIC_IN_OUT),
|
|
19
|
+
duration: animationDuration,
|
|
20
|
+
});
|
|
21
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
22
|
+
return {
|
|
23
|
+
transform: [{ rotateZ: `${rotateZ.value}deg` }],
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
return (React.createElement(TouchableOpacity, { activeOpacity: tokens["opacity-pressed"], onPress: onToggle, disabled: isEmpty },
|
|
27
|
+
React.createElement(View, { style: styles.headerContainer },
|
|
28
|
+
header,
|
|
29
|
+
!isEmpty && (React.createElement(ReanimatedView, { style: [animatedStyle] },
|
|
30
|
+
React.createElement(Icon, { name: "arrowUp", color: "grey" }))))));
|
|
31
|
+
}
|
|
32
|
+
function DisclosureContent({ content, open, animationDuration, }) {
|
|
33
|
+
const [maxHeight, setMaxHeight] = useState(0);
|
|
34
|
+
const height = useSharedValue(0);
|
|
35
|
+
const onContentLayoutChange = (event) => {
|
|
36
|
+
const newHeight = event.nativeEvent.layout.height;
|
|
37
|
+
setMaxHeight(newHeight);
|
|
38
|
+
};
|
|
39
|
+
height.value = withTiming(open ? maxHeight : 0, {
|
|
40
|
+
duration: animationDuration,
|
|
41
|
+
easing: Easing.bezier(...EASE_CUBIC_IN_OUT),
|
|
42
|
+
});
|
|
43
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
44
|
+
return {
|
|
45
|
+
height: height.value,
|
|
46
|
+
};
|
|
47
|
+
}, []);
|
|
48
|
+
return (React.createElement(ReanimatedScrollView, { scrollEnabled: false, showsHorizontalScrollIndicator: false, showsVerticalScrollIndicator: false, style: [styles.contentContainer, animatedStyle] },
|
|
49
|
+
React.createElement(View, { testID: "content", onLayout: onContentLayoutChange }, content)));
|
|
50
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { tokens } from "../utils/design";
|
|
3
|
+
export const styles = StyleSheet.create({
|
|
4
|
+
container: {
|
|
5
|
+
width: "100%",
|
|
6
|
+
},
|
|
7
|
+
headerContainer: {
|
|
8
|
+
flexDirection: "row",
|
|
9
|
+
alignItems: "flex-start",
|
|
10
|
+
justifyContent: "space-between",
|
|
11
|
+
},
|
|
12
|
+
countColumn: {
|
|
13
|
+
paddingRight: tokens["space-base"],
|
|
14
|
+
},
|
|
15
|
+
titleContainer: {
|
|
16
|
+
flexDirection: "row",
|
|
17
|
+
},
|
|
18
|
+
contentContainer: {
|
|
19
|
+
paddingTop: tokens["space-small"],
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const EASE_CUBIC_IN_OUT = [0.645, 0.045, 0.355, 1.0];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Disclosure } from "./Disclosure";
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
import React, { useState } from "react";
|
|
22
|
+
import { FormProvider } from "react-hook-form";
|
|
23
|
+
import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
|
|
24
|
+
import { Keyboard, Platform, View, findNodeHandle, } from "react-native";
|
|
25
|
+
import { styles } from "./Form.style";
|
|
26
|
+
import { FormErrorBanner } from "./components/FormErrorBanner";
|
|
27
|
+
import { KEYBOARD_SAVE_BUTTON_DISTANCE } from "./constants";
|
|
28
|
+
import { FormMessageBanner } from "./components/FormMessageBanner";
|
|
29
|
+
import { FormSubmitErrorType, } from "./types";
|
|
30
|
+
import { FormMask } from "./components/FormMask";
|
|
31
|
+
import { useInternalForm } from "./hooks/useInternalForm";
|
|
32
|
+
import { useFormViewRefs } from "./hooks/useFormViewRefs";
|
|
33
|
+
import { useScreenInformation } from "./hooks/useScreenInformation";
|
|
34
|
+
import { FormMessage } from "./components/FormMessage";
|
|
35
|
+
import { FormBody, useBottomPadding } from "./components/FormBody";
|
|
36
|
+
import { useOfflineHandler } from "./hooks/useOfflineHandler";
|
|
37
|
+
import { useScrollToError } from "./hooks/useScrollToError";
|
|
38
|
+
import { FormSaveButton } from "./components/FormSaveButton";
|
|
39
|
+
import { useSaveButtonPosition } from "./hooks/useSaveButtonPosition";
|
|
40
|
+
import { FormCache } from "./components/FormCache/FormCache";
|
|
41
|
+
import { InputAccessoriesProvider } from "../InputText";
|
|
42
|
+
import { tokens } from "../utils/design";
|
|
43
|
+
import { ErrorMessageProvider } from "../ErrorMessageWrapper";
|
|
44
|
+
export function Form(_a) {
|
|
45
|
+
var { initialLoading } = _a, rest = __rest(_a, ["initialLoading"]);
|
|
46
|
+
const child = initialLoading ? React.createElement(FormMask, null) : React.createElement(InternalForm, Object.assign({}, rest));
|
|
47
|
+
return (React.createElement(InputAccessoriesProvider, null,
|
|
48
|
+
React.createElement(ErrorMessageProvider, null, child)));
|
|
49
|
+
}
|
|
50
|
+
// eslint-disable-next-line max-statements
|
|
51
|
+
function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSubmitSuccess, bannerErrors, bannerMessages, initialValues, mode = "onTouched", reValidateMode = "onChange", formRef, saveButtonLabel, renderStickySection, localCacheKey, localCacheExclude, localCacheId, secondaryActions, saveButtonOffset, showStickySaveButton = false, renderFooter, }) {
|
|
52
|
+
var _a;
|
|
53
|
+
const { scrollViewRef, bottomViewRef, scrollToTop } = useFormViewRefs();
|
|
54
|
+
const [saveButtonHeight, setSaveButtonHeight] = useState(0);
|
|
55
|
+
const [messageBannerHeight, setMessageBannerHeight] = useState(0);
|
|
56
|
+
const { formMethods, handleSubmit, isSubmitting, removeListenerRef, setLocalCache, } = useInternalForm({
|
|
57
|
+
mode,
|
|
58
|
+
reValidateMode,
|
|
59
|
+
initialValues,
|
|
60
|
+
formRef,
|
|
61
|
+
localCacheKey,
|
|
62
|
+
localCacheExclude,
|
|
63
|
+
localCacheId,
|
|
64
|
+
scrollViewRef,
|
|
65
|
+
saveButtonHeight,
|
|
66
|
+
messageBannerHeight,
|
|
67
|
+
});
|
|
68
|
+
const { windowHeight, headerHeight } = useScreenInformation();
|
|
69
|
+
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
70
|
+
const [keyboardScreenY, setKeyboardScreenY] = useState(0);
|
|
71
|
+
const [formContentHeight, setFormContentHeight] = useState(0);
|
|
72
|
+
const [isBottomSheetOpen, setIsBottomSheetOpen] = useState(false);
|
|
73
|
+
const paddingBottom = useBottomPadding();
|
|
74
|
+
const { saveButtonPosition } = useSaveButtonPosition({
|
|
75
|
+
formContentHeight,
|
|
76
|
+
isBottomSheetOpen,
|
|
77
|
+
showStickySaveButton,
|
|
78
|
+
keyboardHeight,
|
|
79
|
+
keyboardScreenY,
|
|
80
|
+
});
|
|
81
|
+
const [isSecondaryActionLoading, setIsSecondaryActionLoading] = useState(false);
|
|
82
|
+
const extraViewHeight = paddingBottom + KEYBOARD_SAVE_BUTTON_DISTANCE;
|
|
83
|
+
const calculatedKeyboardHeight = keyboardHeight - extraViewHeight;
|
|
84
|
+
useScrollToError({
|
|
85
|
+
formState: formMethods.formState,
|
|
86
|
+
refNode: findNodeHandle(scrollViewRef.current),
|
|
87
|
+
setFocus: formMethods.setFocus,
|
|
88
|
+
scrollToPosition: (_a = scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.scrollToPosition,
|
|
89
|
+
});
|
|
90
|
+
const handleOfflineSubmit = useOfflineHandler();
|
|
91
|
+
const keyboardProps = Platform.select({
|
|
92
|
+
ios: {
|
|
93
|
+
onKeyboardWillHide: handleKeyboardHide,
|
|
94
|
+
onKeyboardWillShow: handleKeyboardShow,
|
|
95
|
+
},
|
|
96
|
+
android: {
|
|
97
|
+
onKeyboardDidHide: handleKeyboardHide,
|
|
98
|
+
onKeyboardDidShow: handleKeyboardShow,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
const onLayout = (event) => {
|
|
102
|
+
setMessageBannerHeight(event.nativeEvent.layout.height);
|
|
103
|
+
};
|
|
104
|
+
return (React.createElement(FormProvider, Object.assign({}, formMethods),
|
|
105
|
+
React.createElement(React.Fragment, null,
|
|
106
|
+
(isSubmitting || isSecondaryActionLoading) && React.createElement(FormMask, null),
|
|
107
|
+
React.createElement(FormCache, { localCacheKey: localCacheKey, localCacheExclude: localCacheExclude, setLocalCache: setLocalCache }),
|
|
108
|
+
React.createElement(FormBody, { keyboardHeight: calculateSaveButtonOffset(), submit: handleSubmit(internalSubmit), isFormSubmitting: isSubmitting, saveButtonLabel: saveButtonLabel, shouldRenderActionBar: saveButtonPosition === "sticky", renderStickySection: renderStickySection, secondaryActions: secondaryActions, setSecondaryActionLoading: setIsSecondaryActionLoading, setSaveButtonHeight: setSaveButtonHeight, saveButtonOffset: saveButtonOffset },
|
|
109
|
+
React.createElement(KeyboardAwareScrollView, Object.assign({ enableResetScrollToCoords: false, enableAutomaticScroll: true, keyboardOpeningTime: Platform.OS === "ios" ? tokens["timing-slowest"] : 0, keyboardShouldPersistTaps: "handled", ref: scrollViewRef }, keyboardProps, { extraHeight: headerHeight, contentContainerStyle: !keyboardHeight && styles.scrollContentContainer }),
|
|
110
|
+
React.createElement(View, { onLayout: ({ nativeEvent }) => {
|
|
111
|
+
setFormContentHeight(nativeEvent.layout.height);
|
|
112
|
+
} },
|
|
113
|
+
React.createElement(View, { onLayout: onLayout },
|
|
114
|
+
React.createElement(FormMessageBanner, { bannerMessages: bannerMessages }),
|
|
115
|
+
React.createElement(FormErrorBanner, { networkError: bannerErrors === null || bannerErrors === void 0 ? void 0 : bannerErrors.networkError, bannerError: bannerErrors === null || bannerErrors === void 0 ? void 0 : bannerErrors.bannerError })),
|
|
116
|
+
React.createElement(View, { style: styles.formChildContainer },
|
|
117
|
+
React.createElement(React.Fragment, null,
|
|
118
|
+
React.createElement(View, { style: styles.formContent }, children),
|
|
119
|
+
saveButtonPosition === "inline" && (React.createElement(View, { style: styles.fixedSaveButton }, renderStickySection ? (renderStickySection(handleSubmit(internalSubmit), saveButtonLabel, isSubmitting)) : (React.createElement(FormSaveButton, { primaryAction: handleSubmit(internalSubmit), label: saveButtonLabel, loading: isSubmitting, secondaryActions: secondaryActions, setSecondaryActionLoading: setIsSecondaryActionLoading, onOpenBottomSheet: () => setIsBottomSheetOpen(true), onCloseBottomSheet: () => setIsBottomSheetOpen(false) })))),
|
|
120
|
+
renderFooter))),
|
|
121
|
+
React.createElement(View, { style: styles.safeArea, ref: bottomViewRef })))),
|
|
122
|
+
React.createElement(FormMessage, null)));
|
|
123
|
+
function handleKeyboardShow(frames) {
|
|
124
|
+
setKeyboardScreenY(frames.endCoordinates.screenY);
|
|
125
|
+
setKeyboardHeight(frames.endCoordinates.height);
|
|
126
|
+
}
|
|
127
|
+
function handleKeyboardHide() {
|
|
128
|
+
var _a;
|
|
129
|
+
(_a = bottomViewRef === null || bottomViewRef === void 0 ? void 0 : bottomViewRef.current) === null || _a === void 0 ? void 0 : _a.measureInWindow(
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
131
|
+
(_x, y, _width, _height) => {
|
|
132
|
+
var _a;
|
|
133
|
+
// This fixes extra whitespace below the form if it was scrolled down while the keyboard was open
|
|
134
|
+
// i.e. a View below the form is higher than the bottom of the window
|
|
135
|
+
if (y < windowHeight) {
|
|
136
|
+
(_a = scrollViewRef === null || scrollViewRef === void 0 ? void 0 : scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.scrollToEnd();
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
setKeyboardHeight(0);
|
|
140
|
+
setKeyboardScreenY(0);
|
|
141
|
+
}
|
|
142
|
+
function internalSubmit(data) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
let performSubmit = true;
|
|
145
|
+
if (onBeforeSubmit) {
|
|
146
|
+
performSubmit = yield onBeforeSubmit(data);
|
|
147
|
+
}
|
|
148
|
+
if (performSubmit) {
|
|
149
|
+
Keyboard.dismiss();
|
|
150
|
+
return onSubmit(data)
|
|
151
|
+
.then((result) => {
|
|
152
|
+
var _a;
|
|
153
|
+
(_a = removeListenerRef.current) === null || _a === void 0 ? void 0 : _a.call(removeListenerRef);
|
|
154
|
+
onSubmitSuccess(result);
|
|
155
|
+
})
|
|
156
|
+
.catch(handleSubmitCatch);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function handleSubmitCatch(error) {
|
|
161
|
+
// Scroll to top of form to see error
|
|
162
|
+
scrollToTop();
|
|
163
|
+
onSubmitError(error);
|
|
164
|
+
if ((error === null || error === void 0 ? void 0 : error.errorType) === FormSubmitErrorType.NetworkError) {
|
|
165
|
+
// @ts-expect-error We are making the form submission fail so that we can
|
|
166
|
+
// prevent the isSubmitSuccess to be true
|
|
167
|
+
formMethods.setError("offline", "Error saving form.");
|
|
168
|
+
handleOfflineSubmit(handleRetry, clearFormErrors)();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function clearFormErrors() {
|
|
172
|
+
// @ts-expect-error We are clearing the error that we previously set
|
|
173
|
+
// when the form had no internet connection
|
|
174
|
+
formMethods.clearErrors("offline");
|
|
175
|
+
}
|
|
176
|
+
function handleRetry() {
|
|
177
|
+
clearFormErrors();
|
|
178
|
+
return handleSubmit(internalSubmit)();
|
|
179
|
+
}
|
|
180
|
+
function calculateSaveButtonOffset() {
|
|
181
|
+
if (saveButtonOffset) {
|
|
182
|
+
// Included the space-base because it's the padding of the FormActionBar
|
|
183
|
+
return calculatedKeyboardHeight - saveButtonOffset + tokens["space-base"];
|
|
184
|
+
}
|
|
185
|
+
return calculatedKeyboardHeight;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { tokens } from "../utils/design";
|
|
3
|
+
export const styles = StyleSheet.create({
|
|
4
|
+
container: {
|
|
5
|
+
flex: 1,
|
|
6
|
+
flexGrow: 1,
|
|
7
|
+
width: "100%",
|
|
8
|
+
},
|
|
9
|
+
safeArea: {
|
|
10
|
+
backgroundColor: tokens["color-surface"],
|
|
11
|
+
},
|
|
12
|
+
scrollContentContainer: {
|
|
13
|
+
flexGrow: 1,
|
|
14
|
+
},
|
|
15
|
+
scrollView: {
|
|
16
|
+
flexGrow: 1,
|
|
17
|
+
},
|
|
18
|
+
formChildContainer: {
|
|
19
|
+
flexGrow: 1,
|
|
20
|
+
justifyContent: "flex-start",
|
|
21
|
+
},
|
|
22
|
+
formContent: {
|
|
23
|
+
paddingVertical: tokens["space-small"],
|
|
24
|
+
},
|
|
25
|
+
fixedSaveButton: {
|
|
26
|
+
padding: tokens["space-base"],
|
|
27
|
+
backgroundColor: tokens["color-surface"],
|
|
28
|
+
},
|
|
29
|
+
activityIndicator: {
|
|
30
|
+
marginVertical: tokens["space-base"],
|
|
31
|
+
flex: 1,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleSheet, View } from "react-native";
|
|
3
|
+
import Reanimated from "react-native-reanimated";
|
|
4
|
+
import { styles } from "./FormActionBar.style";
|
|
5
|
+
import { FormSaveButton } from "../FormSaveButton";
|
|
6
|
+
const ReanimatedView = Reanimated.createAnimatedComponent(View);
|
|
7
|
+
export function FormActionBar({ keyboardHeight, submit, isFormSubmitting, saveButtonLabel, renderStickySection, setSaveButtonHeight, secondaryActions, setSecondaryActionLoading, }) {
|
|
8
|
+
const buttonStyle = StyleSheet.flatten([
|
|
9
|
+
styles.saveButton,
|
|
10
|
+
{
|
|
11
|
+
position: keyboardHeight > 0 ? "absolute" : "relative",
|
|
12
|
+
bottom: 0,
|
|
13
|
+
},
|
|
14
|
+
]);
|
|
15
|
+
const onLayout = (event) => {
|
|
16
|
+
setSaveButtonHeight && setSaveButtonHeight(event.nativeEvent.layout.height);
|
|
17
|
+
};
|
|
18
|
+
return (
|
|
19
|
+
//@ts-expect-error tsc-ci
|
|
20
|
+
React.createElement(ReanimatedView, { style: buttonStyle, onLayout: onLayout }, renderStickySection ? (renderStickySection(submit, saveButtonLabel, isFormSubmitting)) : (React.createElement(FormSaveButton, { setSecondaryActionLoading: setSecondaryActionLoading, primaryAction: submit, loading: isFormSubmitting, label: saveButtonLabel, secondaryActions: secondaryActions }))));
|
|
21
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { tokens } from "../../../utils/design";
|
|
3
|
+
export const styles = StyleSheet.create({
|
|
4
|
+
saveButton: Object.assign({ padding: tokens["space-base"], backgroundColor: tokens["color-surface"], width: "100%" }, tokens["shadow-high"]),
|
|
5
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FormActionBar } from "./FormActionBar";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { styles } from "./FormBody.style";
|
|
4
|
+
import { useScreenInformation } from "../../hooks/useScreenInformation";
|
|
5
|
+
import { FormActionBar } from "../FormActionBar";
|
|
6
|
+
import { tokens } from "../../../utils/design";
|
|
7
|
+
export function FormBody({ isFormSubmitting, submit, keyboardHeight, children, saveButtonLabel, renderStickySection, shouldRenderActionBar = true, secondaryActions, setSecondaryActionLoading, setSaveButtonHeight, saveButtonOffset, }) {
|
|
8
|
+
const paddingBottom = useBottomPadding();
|
|
9
|
+
const fullViewPadding = useMemo(() => ({ paddingBottom }), [paddingBottom]);
|
|
10
|
+
return (React.createElement(React.Fragment, null,
|
|
11
|
+
React.createElement(View, { style: [styles.container] },
|
|
12
|
+
children,
|
|
13
|
+
shouldRenderActionBar && (React.createElement(FormActionBar, { setSecondaryActionLoading: setSecondaryActionLoading, keyboardHeight: keyboardHeight, submit: submit, isFormSubmitting: isFormSubmitting, saveButtonLabel: saveButtonLabel, renderStickySection: renderStickySection, secondaryActions: secondaryActions, setSaveButtonHeight: setSaveButtonHeight }))),
|
|
14
|
+
shouldRenderActionBar && !saveButtonOffset && (React.createElement(View, { style: [fullViewPadding, styles.safeArea], testID: "ATL-FormSafeArea" }))));
|
|
15
|
+
}
|
|
16
|
+
export function useBottomPadding() {
|
|
17
|
+
const { insets } = useScreenInformation();
|
|
18
|
+
const extraBottomSpace = insets.bottom - tokens["space-base"];
|
|
19
|
+
return extraBottomSpace >= 0 ? extraBottomSpace : 0;
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { tokens } from "../../../utils/design";
|
|
3
|
+
export const styles = StyleSheet.create({
|
|
4
|
+
container: {
|
|
5
|
+
flex: 1,
|
|
6
|
+
flexGrow: 1,
|
|
7
|
+
width: "100%",
|
|
8
|
+
},
|
|
9
|
+
safeArea: {
|
|
10
|
+
backgroundColor: tokens["color-surface"],
|
|
11
|
+
},
|
|
12
|
+
scrollContentContainer: {
|
|
13
|
+
flexGrow: 1,
|
|
14
|
+
},
|
|
15
|
+
scrollView: {
|
|
16
|
+
flexGrow: 1,
|
|
17
|
+
},
|
|
18
|
+
formChildContainer: {
|
|
19
|
+
flexGrow: 1,
|
|
20
|
+
justifyContent: "flex-start",
|
|
21
|
+
},
|
|
22
|
+
activityIndicator: {
|
|
23
|
+
marginVertical: tokens["space-base"],
|
|
24
|
+
flex: 1,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FormBody, useBottomPadding } from "./FormBody";
|