@aws-amplify/ui-react-native 0.0.0-fileuploader-41bde68-20221115171326
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/.eslintrc.js +100 -0
- package/.lintstagedrc.js +6 -0
- package/.turbo/turbo-build.log +3 -0
- package/CHANGELOG.md +22 -0
- package/LICENSE +201 -0
- package/README.md +23 -0
- package/babel.config.js +3 -0
- package/dist/InAppMessaging/components/BannerMessage/BannerMessage.d.ts +2 -0
- package/dist/InAppMessaging/components/BannerMessage/BannerMessage.js +16 -0
- package/dist/InAppMessaging/components/BannerMessage/index.d.ts +2 -0
- package/dist/InAppMessaging/components/BannerMessage/index.js +1 -0
- package/dist/InAppMessaging/components/BannerMessage/styles.d.ts +7 -0
- package/dist/InAppMessaging/components/BannerMessage/styles.js +77 -0
- package/dist/InAppMessaging/components/BannerMessage/types.d.ts +12 -0
- package/dist/InAppMessaging/components/BannerMessage/types.js +1 -0
- package/dist/InAppMessaging/components/CarouselMessage/CarouselMessage.d.ts +2 -0
- package/dist/InAppMessaging/components/CarouselMessage/CarouselMessage.js +20 -0
- package/dist/InAppMessaging/components/CarouselMessage/CarouselMessageItem.d.ts +2 -0
- package/dist/InAppMessaging/components/CarouselMessage/CarouselMessageItem.js +18 -0
- package/dist/InAppMessaging/components/CarouselMessage/index.d.ts +2 -0
- package/dist/InAppMessaging/components/CarouselMessage/index.js +1 -0
- package/dist/InAppMessaging/components/CarouselMessage/styles.d.ts +5 -0
- package/dist/InAppMessaging/components/CarouselMessage/styles.js +98 -0
- package/dist/InAppMessaging/components/CarouselMessage/types.d.ts +18 -0
- package/dist/InAppMessaging/components/CarouselMessage/types.js +1 -0
- package/dist/InAppMessaging/components/FullScreenMessage/FullScreenMessage.d.ts +2 -0
- package/dist/InAppMessaging/components/FullScreenMessage/FullScreenMessage.js +18 -0
- package/dist/InAppMessaging/components/FullScreenMessage/index.d.ts +2 -0
- package/dist/InAppMessaging/components/FullScreenMessage/index.js +1 -0
- package/dist/InAppMessaging/components/FullScreenMessage/styles.d.ts +3 -0
- package/dist/InAppMessaging/components/FullScreenMessage/styles.js +86 -0
- package/dist/InAppMessaging/components/FullScreenMessage/types.d.ts +6 -0
- package/dist/InAppMessaging/components/FullScreenMessage/types.js +1 -0
- package/dist/InAppMessaging/components/InAppMessageDisplay/InAppMessageDisplay.d.ts +9 -0
- package/dist/InAppMessaging/components/InAppMessageDisplay/InAppMessageDisplay.js +29 -0
- package/dist/InAppMessaging/components/InAppMessageDisplay/handleMessageLinkAction.d.ts +3 -0
- package/dist/InAppMessaging/components/InAppMessageDisplay/handleMessageLinkAction.js +24 -0
- package/dist/InAppMessaging/components/InAppMessageDisplay/index.d.ts +2 -0
- package/dist/InAppMessaging/components/InAppMessageDisplay/index.js +1 -0
- package/dist/InAppMessaging/components/InAppMessageDisplay/types.d.ts +24 -0
- package/dist/InAppMessaging/components/InAppMessageDisplay/types.js +1 -0
- package/dist/InAppMessaging/components/MessageLayout/MessageLayout.d.ts +2 -0
- package/dist/InAppMessaging/components/MessageLayout/MessageLayout.js +34 -0
- package/dist/InAppMessaging/components/MessageLayout/index.d.ts +1 -0
- package/dist/InAppMessaging/components/MessageLayout/index.js +1 -0
- package/dist/InAppMessaging/components/MessageLayout/types.d.ts +7 -0
- package/dist/InAppMessaging/components/MessageLayout/types.js +1 -0
- package/dist/InAppMessaging/components/MessageWrapper/MessageWrapper.d.ts +2 -0
- package/dist/InAppMessaging/components/MessageWrapper/MessageWrapper.js +20 -0
- package/dist/InAppMessaging/components/MessageWrapper/index.d.ts +2 -0
- package/dist/InAppMessaging/components/MessageWrapper/index.js +1 -0
- package/dist/InAppMessaging/components/MessageWrapper/styles.d.ts +2 -0
- package/dist/InAppMessaging/components/MessageWrapper/styles.js +5 -0
- package/dist/InAppMessaging/components/MessageWrapper/types.d.ts +10 -0
- package/dist/InAppMessaging/components/MessageWrapper/types.js +1 -0
- package/dist/InAppMessaging/components/ModalMessage/ModalMessage.d.ts +2 -0
- package/dist/InAppMessaging/components/ModalMessage/ModalMessage.js +18 -0
- package/dist/InAppMessaging/components/ModalMessage/index.d.ts +2 -0
- package/dist/InAppMessaging/components/ModalMessage/index.js +1 -0
- package/dist/InAppMessaging/components/ModalMessage/styles.d.ts +4 -0
- package/dist/InAppMessaging/components/ModalMessage/styles.js +99 -0
- package/dist/InAppMessaging/components/ModalMessage/types.d.ts +6 -0
- package/dist/InAppMessaging/components/ModalMessage/types.js +1 -0
- package/dist/InAppMessaging/components/index.d.ts +6 -0
- package/dist/InAppMessaging/components/index.js +2 -0
- package/dist/InAppMessaging/components/withInAppMessaging/index.d.ts +1 -0
- package/dist/InAppMessaging/components/withInAppMessaging/index.js +1 -0
- package/dist/InAppMessaging/components/withInAppMessaging/withInAppMessaging.d.ts +5 -0
- package/dist/InAppMessaging/components/withInAppMessaging/withInAppMessaging.js +11 -0
- package/dist/InAppMessaging/constants.d.ts +32 -0
- package/dist/InAppMessaging/constants.js +44 -0
- package/dist/InAppMessaging/hooks/index.d.ts +2 -0
- package/dist/InAppMessaging/hooks/index.js +2 -0
- package/dist/InAppMessaging/hooks/useMessageImage/constants.d.ts +8 -0
- package/dist/InAppMessaging/hooks/useMessageImage/constants.js +18 -0
- package/dist/InAppMessaging/hooks/useMessageImage/index.d.ts +2 -0
- package/dist/InAppMessaging/hooks/useMessageImage/index.js +1 -0
- package/dist/InAppMessaging/hooks/useMessageImage/types.d.ts +15 -0
- package/dist/InAppMessaging/hooks/useMessageImage/types.js +6 -0
- package/dist/InAppMessaging/hooks/useMessageImage/useMessageImage.d.ts +10 -0
- package/dist/InAppMessaging/hooks/useMessageImage/useMessageImage.js +50 -0
- package/dist/InAppMessaging/hooks/useMessageImage/utils.d.ts +4 -0
- package/dist/InAppMessaging/hooks/useMessageImage/utils.js +56 -0
- package/dist/InAppMessaging/hooks/useMessageProps/index.d.ts +2 -0
- package/dist/InAppMessaging/hooks/useMessageProps/index.js +1 -0
- package/dist/InAppMessaging/hooks/useMessageProps/types.d.ts +109 -0
- package/dist/InAppMessaging/hooks/useMessageProps/types.js +1 -0
- package/dist/InAppMessaging/hooks/useMessageProps/useMessageProps.d.ts +12 -0
- package/dist/InAppMessaging/hooks/useMessageProps/useMessageProps.js +49 -0
- package/dist/InAppMessaging/hooks/useMessageProps/utils.d.ts +43 -0
- package/dist/InAppMessaging/hooks/useMessageProps/utils.js +192 -0
- package/dist/InAppMessaging/index.d.ts +2 -0
- package/dist/InAppMessaging/index.js +2 -0
- package/dist/__mocks__/@react-native-async-storage/async-storage.d.ts +1 -0
- package/dist/__mocks__/@react-native-async-storage/async-storage.js +2 -0
- package/dist/__mocks__/@react-native-community/netinfo.d.ts +1 -0
- package/dist/__mocks__/@react-native-community/netinfo.js +2 -0
- package/dist/__mocks__/react-native-safe-area-context.d.ts +3 -0
- package/dist/__mocks__/react-native-safe-area-context.js +4 -0
- package/dist/assets/icons/checkboxFilled.png +0 -0
- package/dist/assets/icons/checkboxOutline.png +0 -0
- package/dist/assets/icons/close.png +0 -0
- package/dist/assets/icons/index.d.ts +7 -0
- package/dist/assets/icons/index.js +6 -0
- package/dist/assets/icons/index.ts +9 -0
- package/dist/assets/index.d.ts +1 -0
- package/dist/assets/index.js +1 -0
- package/dist/assets/index.ts +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useDeviceOrientation/index.d.ts +1 -0
- package/dist/hooks/useDeviceOrientation/index.js +1 -0
- package/dist/hooks/useDeviceOrientation/useDeviceOrientation.d.ts +6 -0
- package/dist/hooks/useDeviceOrientation/useDeviceOrientation.js +33 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/primitives/Button/Button.d.ts +2 -0
- package/dist/primitives/Button/Button.js +8 -0
- package/dist/primitives/Button/index.d.ts +2 -0
- package/dist/primitives/Button/index.js +1 -0
- package/dist/primitives/Button/styles.d.ts +2 -0
- package/dist/primitives/Button/styles.js +4 -0
- package/dist/primitives/Button/types.d.ts +7 -0
- package/dist/primitives/Button/types.js +1 -0
- package/dist/primitives/Carousel/Carousel.d.ts +2 -0
- package/dist/primitives/Carousel/Carousel.js +58 -0
- package/dist/primitives/Carousel/CarouselPageIndicator.d.ts +2 -0
- package/dist/primitives/Carousel/CarouselPageIndicator.js +10 -0
- package/dist/primitives/Carousel/constants.d.ts +9 -0
- package/dist/primitives/Carousel/constants.js +18 -0
- package/dist/primitives/Carousel/index.d.ts +3 -0
- package/dist/primitives/Carousel/index.js +2 -0
- package/dist/primitives/Carousel/styles.d.ts +2 -0
- package/dist/primitives/Carousel/styles.js +11 -0
- package/dist/primitives/Carousel/types.d.ts +19 -0
- package/dist/primitives/Carousel/types.js +1 -0
- package/dist/primitives/Checkbox/Checkbox.d.ts +2 -0
- package/dist/primitives/Checkbox/Checkbox.js +23 -0
- package/dist/primitives/Checkbox/index.d.ts +2 -0
- package/dist/primitives/Checkbox/index.js +1 -0
- package/dist/primitives/Checkbox/styles.d.ts +2 -0
- package/dist/primitives/Checkbox/styles.js +6 -0
- package/dist/primitives/Checkbox/types.d.ts +18 -0
- package/dist/primitives/Checkbox/types.js +1 -0
- package/dist/primitives/Heading/Heading.d.ts +2 -0
- package/dist/primitives/Heading/Heading.js +8 -0
- package/dist/primitives/Heading/index.d.ts +2 -0
- package/dist/primitives/Heading/index.js +1 -0
- package/dist/primitives/Heading/styles.d.ts +2 -0
- package/dist/primitives/Heading/styles.js +14 -0
- package/dist/primitives/Heading/types.d.ts +11 -0
- package/dist/primitives/Heading/types.js +1 -0
- package/dist/primitives/Icon/Icon.d.ts +2 -0
- package/dist/primitives/Icon/Icon.js +10 -0
- package/dist/primitives/Icon/index.d.ts +2 -0
- package/dist/primitives/Icon/index.js +1 -0
- package/dist/primitives/Icon/styles.d.ts +2 -0
- package/dist/primitives/Icon/styles.js +9 -0
- package/dist/primitives/Icon/types.d.ts +18 -0
- package/dist/primitives/Icon/types.js +1 -0
- package/dist/primitives/IconButton/IconButton.d.ts +2 -0
- package/dist/primitives/IconButton/IconButton.js +8 -0
- package/dist/primitives/IconButton/index.d.ts +2 -0
- package/dist/primitives/IconButton/index.js +1 -0
- package/dist/primitives/IconButton/styles.d.ts +0 -0
- package/dist/primitives/IconButton/styles.js +1 -0
- package/dist/primitives/IconButton/types.d.ts +22 -0
- package/dist/primitives/IconButton/types.js +1 -0
- package/dist/primitives/Label/Label.d.ts +2 -0
- package/dist/primitives/Label/Label.js +8 -0
- package/dist/primitives/Label/index.d.ts +2 -0
- package/dist/primitives/Label/index.js +1 -0
- package/dist/primitives/Label/styles.d.ts +2 -0
- package/dist/primitives/Label/styles.js +4 -0
- package/dist/primitives/Label/types.d.ts +7 -0
- package/dist/primitives/Label/types.js +1 -0
- package/dist/primitives/Label/utils.d.ts +17 -0
- package/dist/primitives/Label/utils.js +21 -0
- package/dist/primitives/Radio/Radio.d.ts +2 -0
- package/dist/primitives/Radio/Radio.js +29 -0
- package/dist/primitives/Radio/getRadioDimensions.d.ts +18 -0
- package/dist/primitives/Radio/getRadioDimensions.js +27 -0
- package/dist/primitives/Radio/index.d.ts +2 -0
- package/dist/primitives/Radio/index.js +1 -0
- package/dist/primitives/Radio/styles.d.ts +2 -0
- package/dist/primitives/Radio/styles.js +46 -0
- package/dist/primitives/Radio/types.d.ts +28 -0
- package/dist/primitives/Radio/types.js +1 -0
- package/dist/primitives/index.d.ts +8 -0
- package/dist/primitives/index.js +8 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +7 -0
- package/jest.config.js +20 -0
- package/package.json +57 -0
- package/src/InAppMessaging/components/BannerMessage/BannerMessage.tsx +37 -0
- package/src/InAppMessaging/components/BannerMessage/__tests__/BannerMessage.spec.tsx +138 -0
- package/src/InAppMessaging/components/BannerMessage/__tests__/__snapshots__/BannerMessage.spec.tsx.snap +230 -0
- package/src/InAppMessaging/components/BannerMessage/index.ts +2 -0
- package/src/InAppMessaging/components/BannerMessage/styles.ts +106 -0
- package/src/InAppMessaging/components/BannerMessage/types.ts +15 -0
- package/src/InAppMessaging/components/CarouselMessage/CarouselMessage.tsx +42 -0
- package/src/InAppMessaging/components/CarouselMessage/CarouselMessageItem.tsx +37 -0
- package/src/InAppMessaging/components/CarouselMessage/__tests__/CarouselMessage.spec.tsx +55 -0
- package/src/InAppMessaging/components/CarouselMessage/__tests__/CarouselMessageItem.spec.tsx +56 -0
- package/src/InAppMessaging/components/CarouselMessage/__tests__/__snapshots__/CarouselMessage.spec.tsx.snap +86 -0
- package/src/InAppMessaging/components/CarouselMessage/__tests__/__snapshots__/CarouselMessageItem.spec.tsx.snap +248 -0
- package/src/InAppMessaging/components/CarouselMessage/index.ts +2 -0
- package/src/InAppMessaging/components/CarouselMessage/styles.ts +126 -0
- package/src/InAppMessaging/components/CarouselMessage/types.ts +28 -0
- package/src/InAppMessaging/components/FullScreenMessage/FullScreenMessage.tsx +38 -0
- package/src/InAppMessaging/components/FullScreenMessage/__tests__/FullScreenMessage.spec.tsx +53 -0
- package/src/InAppMessaging/components/FullScreenMessage/__tests__/__snapshots__/FullScreenMessage.spec.tsx.snap +236 -0
- package/src/InAppMessaging/components/FullScreenMessage/index.ts +2 -0
- package/src/InAppMessaging/components/FullScreenMessage/styles.ts +107 -0
- package/src/InAppMessaging/components/FullScreenMessage/types.ts +7 -0
- package/src/InAppMessaging/components/InAppMessageDisplay/InAppMessageDisplay.tsx +48 -0
- package/src/InAppMessaging/components/InAppMessageDisplay/__tests__/InAppMessageDisplay.spec.tsx +31 -0
- package/src/InAppMessaging/components/InAppMessageDisplay/__tests__/__snapshots__/InAppMessageDisplay.spec.tsx.snap +9 -0
- package/src/InAppMessaging/components/InAppMessageDisplay/__tests__/handleMessageLinkAction.spec.ts +51 -0
- package/src/InAppMessaging/components/InAppMessageDisplay/handleMessageLinkAction.ts +30 -0
- package/src/InAppMessaging/components/InAppMessageDisplay/index.ts +2 -0
- package/src/InAppMessaging/components/InAppMessageDisplay/types.ts +32 -0
- package/src/InAppMessaging/components/MessageLayout/MessageLayout.tsx +102 -0
- package/src/InAppMessaging/components/MessageLayout/index.ts +1 -0
- package/src/InAppMessaging/components/MessageLayout/types.ts +15 -0
- package/src/InAppMessaging/components/MessageWrapper/MessageWrapper.tsx +34 -0
- package/src/InAppMessaging/components/MessageWrapper/__tests__/MessageWrapper.spec.tsx +19 -0
- package/src/InAppMessaging/components/MessageWrapper/__tests__/__snapshots__/MessageWrapper.spec.tsx.snap +35 -0
- package/src/InAppMessaging/components/MessageWrapper/index.ts +2 -0
- package/src/InAppMessaging/components/MessageWrapper/styles.ts +7 -0
- package/src/InAppMessaging/components/MessageWrapper/types.ts +12 -0
- package/src/InAppMessaging/components/ModalMessage/ModalMessage.tsx +37 -0
- package/src/InAppMessaging/components/ModalMessage/__tests__/ModalMessage.spec.tsx +155 -0
- package/src/InAppMessaging/components/ModalMessage/__tests__/__snapshots__/ModalMessage.spec.tsx.snap +332 -0
- package/src/InAppMessaging/components/ModalMessage/index.ts +2 -0
- package/src/InAppMessaging/components/ModalMessage/styles.ts +133 -0
- package/src/InAppMessaging/components/ModalMessage/types.ts +8 -0
- package/src/InAppMessaging/components/index.ts +6 -0
- package/src/InAppMessaging/components/withInAppMessaging/__tests__/__snapshots__/withInAppMessaging.spec.tsx.snap +3 -0
- package/src/InAppMessaging/components/withInAppMessaging/__tests__/withInAppMessaging.spec.tsx +15 -0
- package/src/InAppMessaging/components/withInAppMessaging/index.ts +1 -0
- package/src/InAppMessaging/components/withInAppMessaging/withInAppMessaging.tsx +18 -0
- package/src/InAppMessaging/constants.ts +57 -0
- package/src/InAppMessaging/hooks/index.ts +9 -0
- package/src/InAppMessaging/hooks/useMessageImage/__tests__/useMessageImage.spec.ts +141 -0
- package/src/InAppMessaging/hooks/useMessageImage/__tests__/utils.spec.ts +107 -0
- package/src/InAppMessaging/hooks/useMessageImage/constants.ts +27 -0
- package/src/InAppMessaging/hooks/useMessageImage/index.ts +2 -0
- package/src/InAppMessaging/hooks/useMessageImage/types.ts +18 -0
- package/src/InAppMessaging/hooks/useMessageImage/useMessageImage.ts +74 -0
- package/src/InAppMessaging/hooks/useMessageImage/utils.ts +80 -0
- package/src/InAppMessaging/hooks/useMessageProps/__tests__/__snapshots__/utils.spec.ts.snap +223 -0
- package/src/InAppMessaging/hooks/useMessageProps/__tests__/useMessageProps.spec.ts +162 -0
- package/src/InAppMessaging/hooks/useMessageProps/__tests__/utils.spec.ts +354 -0
- package/src/InAppMessaging/hooks/useMessageProps/index.ts +8 -0
- package/src/InAppMessaging/hooks/useMessageProps/types.ts +131 -0
- package/src/InAppMessaging/hooks/useMessageProps/useMessageProps.ts +70 -0
- package/src/InAppMessaging/hooks/useMessageProps/utils.ts +274 -0
- package/src/InAppMessaging/index.ts +14 -0
- package/src/__mocks__/@react-native-async-storage/async-storage.ts +2 -0
- package/src/__mocks__/@react-native-community/netinfo.ts +2 -0
- package/src/__mocks__/react-native-safe-area-context.ts +6 -0
- package/src/__tests__/__snapshots__/index.spec.ts.snap +15 -0
- package/src/__tests__/index.spec.ts +8 -0
- package/src/assets/icons/checkboxFilled.png +0 -0
- package/src/assets/icons/checkboxOutline.png +0 -0
- package/src/assets/icons/close.png +0 -0
- package/src/assets/icons/index.ts +9 -0
- package/src/assets/index.ts +1 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useDeviceOrientation/__tests__/useDeviceOrientation.spec.ts +87 -0
- package/src/hooks/useDeviceOrientation/index.ts +4 -0
- package/src/hooks/useDeviceOrientation/useDeviceOrientation.ts +47 -0
- package/src/index.ts +1 -0
- package/src/primitives/Button/Button.tsx +21 -0
- package/src/primitives/Button/__tests__/Button.spec.tsx +24 -0
- package/src/primitives/Button/__tests__/__snapshots__/Button.spec.tsx.snap +52 -0
- package/src/primitives/Button/index.ts +2 -0
- package/src/primitives/Button/styles.ts +6 -0
- package/src/primitives/Button/types.ts +9 -0
- package/src/primitives/Carousel/Carousel.tsx +115 -0
- package/src/primitives/Carousel/CarouselPageIndicator.tsx +39 -0
- package/src/primitives/Carousel/__tests__/Carousel.spec.tsx +185 -0
- package/src/primitives/Carousel/__tests__/CarouselPageIndicator.spec.tsx +71 -0
- package/src/primitives/Carousel/__tests__/__snapshots__/Carousel.spec.tsx.snap +216 -0
- package/src/primitives/Carousel/__tests__/__snapshots__/CarouselPageIndicator.spec.tsx.snap +191 -0
- package/src/primitives/Carousel/constants.ts +25 -0
- package/src/primitives/Carousel/index.ts +3 -0
- package/src/primitives/Carousel/styles.ts +14 -0
- package/src/primitives/Carousel/types.ts +22 -0
- package/src/primitives/Checkbox/Checkbox.tsx +57 -0
- package/src/primitives/Checkbox/__tests__/Checkbox.spec.tsx +50 -0
- package/src/primitives/Checkbox/__tests__/__snapshots__/Checkbox.spec.tsx.snap +198 -0
- package/src/primitives/Checkbox/index.ts +2 -0
- package/src/primitives/Checkbox/styles.ts +8 -0
- package/src/primitives/Checkbox/types.ts +20 -0
- package/src/primitives/Heading/Heading.tsx +22 -0
- package/src/primitives/Heading/__tests__/Heading.spec.tsx +36 -0
- package/src/primitives/Heading/__tests__/__snapshots__/Heading.spec.tsx.snap +150 -0
- package/src/primitives/Heading/index.ts +2 -0
- package/src/primitives/Heading/styles.ts +16 -0
- package/src/primitives/Heading/types.ts +13 -0
- package/src/primitives/Icon/Icon.tsx +20 -0
- package/src/primitives/Icon/__tests__/Icon.spec.tsx +25 -0
- package/src/primitives/Icon/__tests__/__snapshots__/Icon.spec.tsx.snap +64 -0
- package/src/primitives/Icon/index.ts +2 -0
- package/src/primitives/Icon/styles.ts +16 -0
- package/src/primitives/Icon/types.ts +22 -0
- package/src/primitives/IconButton/IconButton.tsx +19 -0
- package/src/primitives/IconButton/__tests__/IconButton.spec.tsx +23 -0
- package/src/primitives/IconButton/__tests__/__snapshots__/IconButton.spec.tsx.snap +75 -0
- package/src/primitives/IconButton/index.ts +2 -0
- package/src/primitives/IconButton/styles.ts +0 -0
- package/src/primitives/IconButton/types.ts +33 -0
- package/src/primitives/Label/Label.tsx +21 -0
- package/src/primitives/Label/__tests__/Label.spec.tsx +22 -0
- package/src/primitives/Label/__tests__/__snapshots__/Label.spec.tsx.snap +39 -0
- package/src/primitives/Label/index.ts +2 -0
- package/src/primitives/Label/styles.ts +7 -0
- package/src/primitives/Label/types.ts +8 -0
- package/src/primitives/Label/utils.ts +27 -0
- package/src/primitives/Radio/Radio.tsx +75 -0
- package/src/primitives/Radio/__tests__/Radio.spec.tsx +70 -0
- package/src/primitives/Radio/__tests__/__snapshots__/Radio.spec.tsx.snap +555 -0
- package/src/primitives/Radio/getRadioDimensions.ts +38 -0
- package/src/primitives/Radio/index.ts +2 -0
- package/src/primitives/Radio/styles.ts +50 -0
- package/src/primitives/Radio/types.ts +32 -0
- package/src/primitives/index.ts +8 -0
- package/src/utils/index.ts +10 -0
- package/tsconfig.dist.json +4 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ViewStyle } from 'react-native';
|
|
2
|
+
import { LabelPosition } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* The `flexDirection` value returned from `getFlexDirectionFromLabelPosition`
|
|
5
|
+
* assumes a `Label` component follows the `Primary` component it labels inside
|
|
6
|
+
* the `Container` that the `flexDirection` is applied to.
|
|
7
|
+
*
|
|
8
|
+
* Example Usage:
|
|
9
|
+
* ```jsx
|
|
10
|
+
* const flexDirection = getFlexDirectionFromLabelPosition(labelPosition);
|
|
11
|
+
* <Container style={{ flexDirection }}>
|
|
12
|
+
* <Primary />
|
|
13
|
+
* <Label />
|
|
14
|
+
* </Container>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const getFlexDirectionFromLabelPosition: (position: LabelPosition) => ViewStyle['flexDirection'];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const FLEX_DIRECTIONS = {
|
|
2
|
+
start: 'row-reverse',
|
|
3
|
+
end: 'row',
|
|
4
|
+
top: 'column-reverse',
|
|
5
|
+
bottom: 'column',
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The `flexDirection` value returned from `getFlexDirectionFromLabelPosition`
|
|
9
|
+
* assumes a `Label` component follows the `Primary` component it labels inside
|
|
10
|
+
* the `Container` that the `flexDirection` is applied to.
|
|
11
|
+
*
|
|
12
|
+
* Example Usage:
|
|
13
|
+
* ```jsx
|
|
14
|
+
* const flexDirection = getFlexDirectionFromLabelPosition(labelPosition);
|
|
15
|
+
* <Container style={{ flexDirection }}>
|
|
16
|
+
* <Primary />
|
|
17
|
+
* <Label />
|
|
18
|
+
* </Container>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export const getFlexDirectionFromLabelPosition = (position) => FLEX_DIRECTIONS[position];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
2
|
+
import { Pressable, View, } from 'react-native';
|
|
3
|
+
import { Label } from '../Label';
|
|
4
|
+
import { getFlexDirectionFromLabelPosition } from '../Label/utils';
|
|
5
|
+
import { styles } from './styles';
|
|
6
|
+
import { getRadioDimensions } from './getRadioDimensions';
|
|
7
|
+
export default function Radio({ accessibilityRole = 'radio', disabled, label, labelPosition = 'end', labelStyle, onChange, radioContainerStyle, radioDotStyle, selected, size = 'medium', style, value, ...rest }) {
|
|
8
|
+
const handleOnChange = useCallback(() => {
|
|
9
|
+
if (!disabled) {
|
|
10
|
+
onChange?.(value);
|
|
11
|
+
}
|
|
12
|
+
}, [onChange, value, disabled]);
|
|
13
|
+
const containerStyle = useCallback(({ pressed }) => {
|
|
14
|
+
const containerStyle = {
|
|
15
|
+
...styles.container,
|
|
16
|
+
flexDirection: getFlexDirectionFromLabelPosition(labelPosition),
|
|
17
|
+
...(disabled && styles.disabled),
|
|
18
|
+
};
|
|
19
|
+
const pressedStateStyle = typeof style === 'function' ? style({ pressed }) : style;
|
|
20
|
+
return [containerStyle, pressedStateStyle];
|
|
21
|
+
}, [disabled, labelPosition, style]);
|
|
22
|
+
const { radioContainerSize, radioDotSize } = useMemo(() => getRadioDimensions(size, styles), [size]);
|
|
23
|
+
return (<Pressable {...rest} accessibilityRole={accessibilityRole} onPress={handleOnChange} style={containerStyle}>
|
|
24
|
+
<View style={[styles.radioContainer, radioContainerSize, radioContainerStyle]}>
|
|
25
|
+
{selected ? (<View style={[styles.radioDot, radioDotSize, radioDotStyle]}/>) : null}
|
|
26
|
+
</View>
|
|
27
|
+
{label ? <Label style={labelStyle}>{label}</Label> : null}
|
|
28
|
+
</Pressable>);
|
|
29
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RadioDimensions, RadioStyles, Size } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* These utility functions are used to apply styles to
|
|
4
|
+
* the two nested View's comprising the Radio:
|
|
5
|
+
* - The outer <View> is named 'radioContainer'
|
|
6
|
+
* - The inner <View> is named 'radioDot'
|
|
7
|
+
*
|
|
8
|
+
* If a customer passes a number to the `size` prop, then we simply calculate the dimensions
|
|
9
|
+
* for both the 'radioContainer' and 'radioDot' based on that number.
|
|
10
|
+
*
|
|
11
|
+
* If a customer passes a string ('small' | 'medium' | 'large') to the `size` prop,
|
|
12
|
+
* then we return the respective dimensions as defined in the `styles` object
|
|
13
|
+
* (e.g., 'small' => { radioContainerSmall, radioDotSmall } )
|
|
14
|
+
*/
|
|
15
|
+
export declare const getRadioDimensions: (size: Size, styles: RadioStyles) => {
|
|
16
|
+
radioContainerSize: RadioDimensions;
|
|
17
|
+
radioDotSize: RadioDimensions;
|
|
18
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { capitalize } from '../../utils';
|
|
2
|
+
/**
|
|
3
|
+
* These utility functions are used to apply styles to
|
|
4
|
+
* the two nested View's comprising the Radio:
|
|
5
|
+
* - The outer <View> is named 'radioContainer'
|
|
6
|
+
* - The inner <View> is named 'radioDot'
|
|
7
|
+
*
|
|
8
|
+
* If a customer passes a number to the `size` prop, then we simply calculate the dimensions
|
|
9
|
+
* for both the 'radioContainer' and 'radioDot' based on that number.
|
|
10
|
+
*
|
|
11
|
+
* If a customer passes a string ('small' | 'medium' | 'large') to the `size` prop,
|
|
12
|
+
* then we return the respective dimensions as defined in the `styles` object
|
|
13
|
+
* (e.g., 'small' => { radioContainerSmall, radioDotSmall } )
|
|
14
|
+
*/
|
|
15
|
+
export const getRadioDimensions = (size, styles) => {
|
|
16
|
+
if (typeof size === 'number') {
|
|
17
|
+
return {
|
|
18
|
+
radioContainerSize: { height: size, width: size },
|
|
19
|
+
radioDotSize: { height: size * 0.5, width: size * 0.5 },
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const sizeKey = capitalize(size);
|
|
23
|
+
return {
|
|
24
|
+
radioContainerSize: styles[`radioContainer${sizeKey}`],
|
|
25
|
+
radioDotSize: styles[`radioDot${sizeKey}`],
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Radio } from './Radio';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
const RADIO_COLOR = '#317d95';
|
|
3
|
+
const ROUNDED_BORDER_RADIUS = 999;
|
|
4
|
+
export const styles = StyleSheet.create({
|
|
5
|
+
container: {
|
|
6
|
+
alignItems: 'center',
|
|
7
|
+
},
|
|
8
|
+
disabled: {
|
|
9
|
+
opacity: 0.6,
|
|
10
|
+
},
|
|
11
|
+
radioContainer: {
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
borderColor: RADIO_COLOR,
|
|
14
|
+
borderRadius: ROUNDED_BORDER_RADIUS,
|
|
15
|
+
borderWidth: 2,
|
|
16
|
+
justifyContent: 'center',
|
|
17
|
+
},
|
|
18
|
+
radioDot: {
|
|
19
|
+
backgroundColor: RADIO_COLOR,
|
|
20
|
+
borderRadius: ROUNDED_BORDER_RADIUS,
|
|
21
|
+
},
|
|
22
|
+
radioContainerLarge: {
|
|
23
|
+
height: 24,
|
|
24
|
+
width: 24,
|
|
25
|
+
},
|
|
26
|
+
radioContainerMedium: {
|
|
27
|
+
height: 20,
|
|
28
|
+
width: 20,
|
|
29
|
+
},
|
|
30
|
+
radioContainerSmall: {
|
|
31
|
+
height: 16,
|
|
32
|
+
width: 16,
|
|
33
|
+
},
|
|
34
|
+
radioDotLarge: {
|
|
35
|
+
height: 12,
|
|
36
|
+
width: 12,
|
|
37
|
+
},
|
|
38
|
+
radioDotMedium: {
|
|
39
|
+
height: 10,
|
|
40
|
+
width: 10,
|
|
41
|
+
},
|
|
42
|
+
radioDotSmall: {
|
|
43
|
+
height: 8,
|
|
44
|
+
width: 8,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PressableProps, StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
import { LabelPosition } from '../Label/types';
|
|
3
|
+
export declare type Size = number | 'small' | 'medium' | 'large';
|
|
4
|
+
export interface RadioProps<T> extends PressableProps {
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
label?: string;
|
|
7
|
+
labelPosition?: LabelPosition;
|
|
8
|
+
labelStyle?: StyleProp<TextStyle>;
|
|
9
|
+
onChange?: (value?: T) => void;
|
|
10
|
+
radioContainerStyle?: StyleProp<ViewStyle>;
|
|
11
|
+
radioDotStyle?: StyleProp<ViewStyle>;
|
|
12
|
+
size?: Size;
|
|
13
|
+
selected?: boolean;
|
|
14
|
+
value: T;
|
|
15
|
+
}
|
|
16
|
+
export declare type RadioDimensions = Pick<ViewStyle, 'height' | 'width'>;
|
|
17
|
+
export interface RadioStyles {
|
|
18
|
+
container: ViewStyle;
|
|
19
|
+
disabled: ViewStyle;
|
|
20
|
+
radioContainer: ViewStyle;
|
|
21
|
+
radioContainerLarge: RadioDimensions;
|
|
22
|
+
radioContainerMedium: RadioDimensions;
|
|
23
|
+
radioContainerSmall: RadioDimensions;
|
|
24
|
+
radioDot: ViewStyle;
|
|
25
|
+
radioDotLarge: RadioDimensions;
|
|
26
|
+
radioDotMedium: RadioDimensions;
|
|
27
|
+
radioDotSmall: RadioDimensions;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// as a safeguard against known React Native lineHeight issues, e.g. https://github.com/facebook/react-native/issues/29507
|
|
2
|
+
// use a value of 1.5 as the default line height multiplier
|
|
3
|
+
const LINE_HEIGHT_MULTIPLIER = 1.5;
|
|
4
|
+
export const getLineHeight = (fontSize) => fontSize * LINE_HEIGHT_MULTIPLIER;
|
|
5
|
+
export function capitalize(value) {
|
|
6
|
+
return (value.charAt(0).toUpperCase() + value.slice(1));
|
|
7
|
+
}
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
preset: 'react-native',
|
|
3
|
+
modulePathIgnorePatterns: ['<rootDir>/dist/'],
|
|
4
|
+
collectCoverageFrom: [
|
|
5
|
+
'<rootDir>/src/**/*.{js,jsx,ts,tsx}',
|
|
6
|
+
'!<rootDir>/src/**/*{c,C}onstants.ts',
|
|
7
|
+
],
|
|
8
|
+
moduleNameMapper: {
|
|
9
|
+
'^react$': '<rootDir>/node_modules/react',
|
|
10
|
+
'^react-native$': '<rootDir>/node_modules/react-native',
|
|
11
|
+
},
|
|
12
|
+
coverageThreshold: {
|
|
13
|
+
global: {
|
|
14
|
+
branches: 90,
|
|
15
|
+
functions: 90,
|
|
16
|
+
lines: 90,
|
|
17
|
+
statements: 90,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aws-amplify/ui-react-native",
|
|
3
|
+
"version": "0.0.0-fileuploader-41bde68-20221115171326",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"module": "dist/esm/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "yarn dist && cp -a src/assets dist",
|
|
10
|
+
"clean": "rimraf dist",
|
|
11
|
+
"dev": "yarn dist --watch",
|
|
12
|
+
"dist": "tsc --project tsconfig.dist.json",
|
|
13
|
+
"lint": "tsc --noEmit && eslint src",
|
|
14
|
+
"prebuild": "rimraf dist",
|
|
15
|
+
"test": "jest --coverage",
|
|
16
|
+
"test:watch": "yarn test --watch"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@babel/cli": "^7.17.10",
|
|
20
|
+
"@babel/core": "^7.17.10",
|
|
21
|
+
"@babel/preset-env": "^7.17.10",
|
|
22
|
+
"@testing-library/react-hooks": "^8.0.0",
|
|
23
|
+
"@testing-library/react-native": "^11.1.0",
|
|
24
|
+
"@types/react": "^17.0.2",
|
|
25
|
+
"@types/react-native": "^0.67.6",
|
|
26
|
+
"@types/react-test-renderer": "^17.0.1",
|
|
27
|
+
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
|
28
|
+
"@typescript-eslint/parser": "^5.20.0",
|
|
29
|
+
"babel-jest": "^28.0.3",
|
|
30
|
+
"eslint": "^8.14.0",
|
|
31
|
+
"eslint-config-prettier": "^8.5.0",
|
|
32
|
+
"eslint-plugin-import": "^2.26.0",
|
|
33
|
+
"eslint-plugin-jest": "^26.1.4",
|
|
34
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
35
|
+
"eslint-plugin-react": "^7.29.4",
|
|
36
|
+
"eslint-plugin-react-hooks": "^4.4.0",
|
|
37
|
+
"metro-react-native-babel-preset": "^0.70.2",
|
|
38
|
+
"react": "^17.0.2",
|
|
39
|
+
"react-native": "^0.68.1",
|
|
40
|
+
"react-native-safe-area-context": "^4.2.5",
|
|
41
|
+
"react-test-renderer": "^17.0.2",
|
|
42
|
+
"rimraf": "^3.0.2"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@aws-amplify/ui": "0.0.0-fileuploader-41bde68-20221115171326",
|
|
46
|
+
"@aws-amplify/ui-react-core": "0.0.0-fileuploader-41bde68-20221115171326"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"aws-amplify": ">= 5.0.1",
|
|
50
|
+
"react": ">= 16.14.0",
|
|
51
|
+
"react-native": ">= 0.63.4",
|
|
52
|
+
"react-native-safe-area-context": ">= 4.2.5"
|
|
53
|
+
},
|
|
54
|
+
"resolutions": {
|
|
55
|
+
"@types/react": "^17.0.2"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { ImageDimensions, useMessageProps } from '../../hooks';
|
|
4
|
+
import { MessageWrapper } from '../MessageWrapper';
|
|
5
|
+
import { MessageLayout } from '../MessageLayout';
|
|
6
|
+
|
|
7
|
+
import { getStyles, positionStyle } from './styles';
|
|
8
|
+
import { BannerMessageProps } from './types';
|
|
9
|
+
|
|
10
|
+
export default function BannerMessage({
|
|
11
|
+
position = 'top',
|
|
12
|
+
...props
|
|
13
|
+
}: BannerMessageProps): JSX.Element | null {
|
|
14
|
+
const messageProps = useMessageProps(
|
|
15
|
+
props,
|
|
16
|
+
(imageDimensions: ImageDimensions) =>
|
|
17
|
+
getStyles(imageDimensions, { position: { ...positionStyle[position] } })
|
|
18
|
+
);
|
|
19
|
+
const { shouldRenderMessage, styles } = messageProps;
|
|
20
|
+
|
|
21
|
+
if (!shouldRenderMessage) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const { wrapper, ...messageStyles } = styles!;
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<MessageWrapper style={wrapper}>
|
|
29
|
+
<MessageLayout
|
|
30
|
+
{...props}
|
|
31
|
+
{...messageProps}
|
|
32
|
+
orientation="landscape"
|
|
33
|
+
styles={messageStyles}
|
|
34
|
+
/>
|
|
35
|
+
</MessageWrapper>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import TestRenderer from 'react-test-renderer';
|
|
3
|
+
|
|
4
|
+
import { IN_APP_MESSAGING_TEST_ID } from '../../../constants';
|
|
5
|
+
import { useMessageImage } from '../../../hooks/useMessageImage';
|
|
6
|
+
|
|
7
|
+
import BannerMessage from '../BannerMessage';
|
|
8
|
+
|
|
9
|
+
jest.mock('../../../hooks/useMessageImage');
|
|
10
|
+
jest.mock('../../MessageWrapper', () => ({ MessageWrapper: 'MessageWrapper' }));
|
|
11
|
+
|
|
12
|
+
const mockUseMessageImage = useMessageImage as jest.Mock;
|
|
13
|
+
const onAction = jest.fn();
|
|
14
|
+
const onClose = jest.fn();
|
|
15
|
+
|
|
16
|
+
const baseProps = { layout: 'TOP_BANNER' as const, onClose };
|
|
17
|
+
|
|
18
|
+
describe('BannerMessage', () => {
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
jest.clearAllMocks();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('renders a message as expected without an image', () => {
|
|
24
|
+
mockUseMessageImage.mockReturnValueOnce({
|
|
25
|
+
hasRenderableImage: false,
|
|
26
|
+
imageDimensions: { height: undefined, width: undefined },
|
|
27
|
+
isImageFetching: false,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const renderer = TestRenderer.create(<BannerMessage {...baseProps} />);
|
|
31
|
+
|
|
32
|
+
expect(renderer.toJSON()).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('renders a message as expected with an image', () => {
|
|
36
|
+
mockUseMessageImage.mockReturnValueOnce({
|
|
37
|
+
hasRenderableImage: true,
|
|
38
|
+
imageDimensions: { height: 100, width: 100 },
|
|
39
|
+
isImageFetching: false,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const src = 'asset.png';
|
|
43
|
+
const props = { ...baseProps, image: { src } };
|
|
44
|
+
|
|
45
|
+
const renderer = TestRenderer.create(<BannerMessage {...props} />);
|
|
46
|
+
|
|
47
|
+
const image = renderer.root.findByProps({
|
|
48
|
+
testID: IN_APP_MESSAGING_TEST_ID.IMAGE,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
expect(image.props).toEqual(
|
|
52
|
+
expect.objectContaining({ source: { uri: src } })
|
|
53
|
+
);
|
|
54
|
+
expect(renderer.toJSON()).toMatchSnapshot();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('returns null while an image is fetching', () => {
|
|
58
|
+
mockUseMessageImage.mockReturnValueOnce({
|
|
59
|
+
hasRenderableImage: false,
|
|
60
|
+
imageDimensions: { height: undefined, width: undefined },
|
|
61
|
+
isImageFetching: true,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const renderer = TestRenderer.create(<BannerMessage {...baseProps} />);
|
|
65
|
+
|
|
66
|
+
expect(renderer.toJSON()).toBeNull();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it.each([
|
|
70
|
+
[
|
|
71
|
+
'header',
|
|
72
|
+
IN_APP_MESSAGING_TEST_ID.HEADER,
|
|
73
|
+
{
|
|
74
|
+
testProps: { content: 'header content' },
|
|
75
|
+
expectedProps: { children: 'header content' },
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
'body',
|
|
80
|
+
IN_APP_MESSAGING_TEST_ID.BODY,
|
|
81
|
+
{
|
|
82
|
+
testProps: { content: 'body content' },
|
|
83
|
+
expectedProps: { children: 'body content' },
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
'primaryButton',
|
|
88
|
+
IN_APP_MESSAGING_TEST_ID.PRIMARY_BUTTON,
|
|
89
|
+
{
|
|
90
|
+
testProps: { onAction, title: 'primary button' },
|
|
91
|
+
expectedProps: { children: 'primary button', onPress: onAction },
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
'secondaryButton',
|
|
96
|
+
IN_APP_MESSAGING_TEST_ID.SECONDARY_BUTTON,
|
|
97
|
+
{
|
|
98
|
+
testProps: { onAction, title: 'secondary button' },
|
|
99
|
+
expectedProps: { children: 'secondary button', onPress: onAction },
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
])(
|
|
103
|
+
'correctly handles a %s prop',
|
|
104
|
+
(key, testID, { testProps, expectedProps }) => {
|
|
105
|
+
mockUseMessageImage.mockReturnValueOnce({
|
|
106
|
+
hasRenderableImage: false,
|
|
107
|
+
imageDimensions: { height: undefined, width: undefined },
|
|
108
|
+
isImageFetching: false,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const props = { ...baseProps, [key]: testProps };
|
|
112
|
+
|
|
113
|
+
const renderer = TestRenderer.create(<BannerMessage {...props} />);
|
|
114
|
+
const testElement = renderer.root.findByProps({ testID });
|
|
115
|
+
|
|
116
|
+
expect(testElement.props).toEqual(expect.objectContaining(expectedProps));
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
it('calls onClose when the close button is pressed', () => {
|
|
121
|
+
mockUseMessageImage.mockReturnValueOnce({
|
|
122
|
+
hasRenderableImage: false,
|
|
123
|
+
imageDimensions: { height: undefined, width: undefined },
|
|
124
|
+
isImageFetching: false,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const renderer = TestRenderer.create(<BannerMessage {...baseProps} />);
|
|
128
|
+
const closeButton = renderer.root.findByProps({
|
|
129
|
+
testID: IN_APP_MESSAGING_TEST_ID.CLOSE_BUTTON,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
TestRenderer.act(() => {
|
|
133
|
+
(closeButton.props as { onPress: () => void }).onPress();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
expect(onClose).toHaveBeenCalledTimes(1);
|
|
137
|
+
});
|
|
138
|
+
});
|