@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,191 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`CarouselPageIndicator handles null index value 1`] = `
|
|
4
|
+
<SafeAreaView>
|
|
5
|
+
<View
|
|
6
|
+
style={
|
|
7
|
+
Array [
|
|
8
|
+
Object {
|
|
9
|
+
"backgroundColor": "#a1a1a1",
|
|
10
|
+
"borderRadius": 6,
|
|
11
|
+
"height": 12,
|
|
12
|
+
"margin": 4,
|
|
13
|
+
"width": 12,
|
|
14
|
+
},
|
|
15
|
+
undefined,
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
/>
|
|
19
|
+
<View
|
|
20
|
+
style={
|
|
21
|
+
Array [
|
|
22
|
+
Object {
|
|
23
|
+
"backgroundColor": "#d8d8d8",
|
|
24
|
+
"borderRadius": 6,
|
|
25
|
+
"height": 12,
|
|
26
|
+
"margin": 4,
|
|
27
|
+
"width": 12,
|
|
28
|
+
},
|
|
29
|
+
undefined,
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
/>
|
|
33
|
+
<View
|
|
34
|
+
style={
|
|
35
|
+
Array [
|
|
36
|
+
Object {
|
|
37
|
+
"backgroundColor": "#d8d8d8",
|
|
38
|
+
"borderRadius": 6,
|
|
39
|
+
"height": 12,
|
|
40
|
+
"margin": 4,
|
|
41
|
+
"width": 12,
|
|
42
|
+
},
|
|
43
|
+
undefined,
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
/>
|
|
47
|
+
<View
|
|
48
|
+
style={
|
|
49
|
+
Array [
|
|
50
|
+
Object {
|
|
51
|
+
"backgroundColor": "#d8d8d8",
|
|
52
|
+
"borderRadius": 6,
|
|
53
|
+
"height": 12,
|
|
54
|
+
"margin": 4,
|
|
55
|
+
"width": 12,
|
|
56
|
+
},
|
|
57
|
+
undefined,
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
/>
|
|
61
|
+
<View
|
|
62
|
+
style={
|
|
63
|
+
Array [
|
|
64
|
+
Object {
|
|
65
|
+
"backgroundColor": "#d8d8d8",
|
|
66
|
+
"borderRadius": 6,
|
|
67
|
+
"height": 12,
|
|
68
|
+
"margin": 4,
|
|
69
|
+
"width": 12,
|
|
70
|
+
},
|
|
71
|
+
undefined,
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
/>
|
|
75
|
+
</SafeAreaView>
|
|
76
|
+
`;
|
|
77
|
+
|
|
78
|
+
exports[`CarouselPageIndicator handles null numberOfItems value 1`] = `<SafeAreaView />`;
|
|
79
|
+
|
|
80
|
+
exports[`CarouselPageIndicator renders indicator styles based on current index 1`] = `
|
|
81
|
+
<SafeAreaView>
|
|
82
|
+
<View
|
|
83
|
+
style={
|
|
84
|
+
Array [
|
|
85
|
+
Object {
|
|
86
|
+
"backgroundColor": "#d8d8d8",
|
|
87
|
+
"borderRadius": 6,
|
|
88
|
+
"height": 12,
|
|
89
|
+
"margin": 4,
|
|
90
|
+
"width": 12,
|
|
91
|
+
},
|
|
92
|
+
undefined,
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
/>
|
|
96
|
+
<View
|
|
97
|
+
style={
|
|
98
|
+
Array [
|
|
99
|
+
Object {
|
|
100
|
+
"backgroundColor": "#a1a1a1",
|
|
101
|
+
"borderRadius": 6,
|
|
102
|
+
"height": 12,
|
|
103
|
+
"margin": 4,
|
|
104
|
+
"width": 12,
|
|
105
|
+
},
|
|
106
|
+
undefined,
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
/>
|
|
110
|
+
<View
|
|
111
|
+
style={
|
|
112
|
+
Array [
|
|
113
|
+
Object {
|
|
114
|
+
"backgroundColor": "#d8d8d8",
|
|
115
|
+
"borderRadius": 6,
|
|
116
|
+
"height": 12,
|
|
117
|
+
"margin": 4,
|
|
118
|
+
"width": 12,
|
|
119
|
+
},
|
|
120
|
+
undefined,
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
/>
|
|
124
|
+
</SafeAreaView>
|
|
125
|
+
`;
|
|
126
|
+
|
|
127
|
+
exports[`CarouselPageIndicator renders with just one item 1`] = `
|
|
128
|
+
<SafeAreaView>
|
|
129
|
+
<View
|
|
130
|
+
style={
|
|
131
|
+
Array [
|
|
132
|
+
Object {
|
|
133
|
+
"backgroundColor": "#a1a1a1",
|
|
134
|
+
"borderRadius": 6,
|
|
135
|
+
"height": 12,
|
|
136
|
+
"margin": 4,
|
|
137
|
+
"width": 12,
|
|
138
|
+
},
|
|
139
|
+
undefined,
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
/>
|
|
143
|
+
</SafeAreaView>
|
|
144
|
+
`;
|
|
145
|
+
|
|
146
|
+
exports[`CarouselPageIndicator renders with multiple items 1`] = `
|
|
147
|
+
<SafeAreaView>
|
|
148
|
+
<View
|
|
149
|
+
style={
|
|
150
|
+
Array [
|
|
151
|
+
Object {
|
|
152
|
+
"backgroundColor": "#a1a1a1",
|
|
153
|
+
"borderRadius": 6,
|
|
154
|
+
"height": 12,
|
|
155
|
+
"margin": 4,
|
|
156
|
+
"width": 12,
|
|
157
|
+
},
|
|
158
|
+
undefined,
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
/>
|
|
162
|
+
<View
|
|
163
|
+
style={
|
|
164
|
+
Array [
|
|
165
|
+
Object {
|
|
166
|
+
"backgroundColor": "#d8d8d8",
|
|
167
|
+
"borderRadius": 6,
|
|
168
|
+
"height": 12,
|
|
169
|
+
"margin": 4,
|
|
170
|
+
"width": 12,
|
|
171
|
+
},
|
|
172
|
+
undefined,
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
/>
|
|
176
|
+
<View
|
|
177
|
+
style={
|
|
178
|
+
Array [
|
|
179
|
+
Object {
|
|
180
|
+
"backgroundColor": "#d8d8d8",
|
|
181
|
+
"borderRadius": 6,
|
|
182
|
+
"height": 12,
|
|
183
|
+
"margin": 4,
|
|
184
|
+
"width": 12,
|
|
185
|
+
},
|
|
186
|
+
undefined,
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
/>
|
|
190
|
+
</SafeAreaView>
|
|
191
|
+
`;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_CAROUSEL_COLOR_ACTIVE = '#a1a1a1';
|
|
4
|
+
export const DEFAULT_CAROUSEL_COLOR_INACTIVE = '#d8d8d8';
|
|
5
|
+
|
|
6
|
+
export const DEFAULT_CAROUSEL_INDICATOR_SIZE = 12;
|
|
7
|
+
|
|
8
|
+
const DEFAULT_CAROUSEL_INDICATOR_STYLE: ViewStyle = {
|
|
9
|
+
borderRadius: DEFAULT_CAROUSEL_INDICATOR_SIZE / 2,
|
|
10
|
+
height: DEFAULT_CAROUSEL_INDICATOR_SIZE,
|
|
11
|
+
margin: DEFAULT_CAROUSEL_INDICATOR_SIZE / 3,
|
|
12
|
+
width: DEFAULT_CAROUSEL_INDICATOR_SIZE,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const DEFAULT_CAROUSEL_INDICATOR_ACTIVE_STYLE: ViewStyle = {
|
|
16
|
+
...DEFAULT_CAROUSEL_INDICATOR_STYLE,
|
|
17
|
+
backgroundColor: DEFAULT_CAROUSEL_COLOR_ACTIVE,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const DEFAULT_CAROUSEL_INDICATOR_INACTIVE_STYLE: ViewStyle = {
|
|
21
|
+
...DEFAULT_CAROUSEL_INDICATOR_STYLE,
|
|
22
|
+
backgroundColor: DEFAULT_CAROUSEL_COLOR_INACTIVE,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const VIEWABILITY_CONFIG = { itemVisiblePercentThreshold: 60 };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { CarouselStyles } from './types';
|
|
4
|
+
|
|
5
|
+
export const styles: CarouselStyles = StyleSheet.create({
|
|
6
|
+
indicator: {
|
|
7
|
+
bottom: 0,
|
|
8
|
+
flexDirection: 'row',
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
left: 0,
|
|
11
|
+
position: 'absolute',
|
|
12
|
+
right: 0,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ListRenderItem, StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export interface CarouselProps<T> {
|
|
4
|
+
data: ReadonlyArray<T>;
|
|
5
|
+
indicatorActiveStyle?: StyleProp<ViewStyle>;
|
|
6
|
+
indicatorInactiveStyle?: StyleProp<ViewStyle>;
|
|
7
|
+
onClose?: () => void;
|
|
8
|
+
renderItem: ListRenderItem<T>;
|
|
9
|
+
style?: StyleProp<ViewStyle>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface CarouselPageIndicatorProps {
|
|
13
|
+
activeStyle?: StyleProp<ViewStyle>;
|
|
14
|
+
currentIndex: number | null;
|
|
15
|
+
inactiveStyle?: StyleProp<ViewStyle>;
|
|
16
|
+
numberOfItems: number;
|
|
17
|
+
style?: StyleProp<ViewStyle>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface CarouselStyles {
|
|
21
|
+
indicator: ViewStyle;
|
|
22
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { Pressable, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { icons } from '../../assets';
|
|
5
|
+
import { styles } from './styles';
|
|
6
|
+
import { Label } from '../Label';
|
|
7
|
+
import { CheckboxProps } from './types';
|
|
8
|
+
import { getFlexDirectionFromLabelPosition } from '../Label/utils';
|
|
9
|
+
import { Icon } from '../Icon';
|
|
10
|
+
|
|
11
|
+
export default function Checkbox<T>({
|
|
12
|
+
accessibilityRole = 'checkbox',
|
|
13
|
+
iconStyle,
|
|
14
|
+
disabled,
|
|
15
|
+
label,
|
|
16
|
+
labelPosition = 'end',
|
|
17
|
+
labelStyle,
|
|
18
|
+
onChange,
|
|
19
|
+
selected,
|
|
20
|
+
size,
|
|
21
|
+
style,
|
|
22
|
+
value,
|
|
23
|
+
...rest
|
|
24
|
+
}: CheckboxProps<T>): JSX.Element {
|
|
25
|
+
const [checked, setChecked] = useState(selected ?? false);
|
|
26
|
+
|
|
27
|
+
const handleOnChange = useCallback(() => {
|
|
28
|
+
onChange?.(value);
|
|
29
|
+
setChecked(!checked);
|
|
30
|
+
}, [onChange, value, checked]);
|
|
31
|
+
|
|
32
|
+
const containerStyle: ViewStyle = useMemo(
|
|
33
|
+
() => ({
|
|
34
|
+
...styles.container,
|
|
35
|
+
flexDirection: getFlexDirectionFromLabelPosition(labelPosition),
|
|
36
|
+
opacity: disabled ? 0.6 : 1,
|
|
37
|
+
}),
|
|
38
|
+
[disabled, labelPosition]
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Pressable
|
|
43
|
+
{...rest}
|
|
44
|
+
accessibilityRole={accessibilityRole}
|
|
45
|
+
disabled={disabled}
|
|
46
|
+
onPress={handleOnChange}
|
|
47
|
+
style={[containerStyle, style]}
|
|
48
|
+
>
|
|
49
|
+
<Icon
|
|
50
|
+
source={checked ? icons.checkboxFilled : icons.checkboxOutline}
|
|
51
|
+
size={size}
|
|
52
|
+
style={iconStyle}
|
|
53
|
+
/>
|
|
54
|
+
{label ? <Label style={labelStyle}>{label}</Label> : null}
|
|
55
|
+
</Pressable>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react-native';
|
|
3
|
+
import Checkbox from '../Checkbox';
|
|
4
|
+
|
|
5
|
+
const onChange = jest.fn();
|
|
6
|
+
|
|
7
|
+
describe('Checkbox', () => {
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
onChange.mockClear();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
[true, false].forEach((value) => {
|
|
13
|
+
it(`renders as expected when selected is ${value}`, () => {
|
|
14
|
+
const { toJSON } = render(
|
|
15
|
+
<Checkbox selected={value} value={value} onChange={onChange} />
|
|
16
|
+
);
|
|
17
|
+
expect(toJSON()).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('renders as expected when disabled', () => {
|
|
22
|
+
const { toJSON } = render(
|
|
23
|
+
<Checkbox disabled value="" onChange={onChange} />
|
|
24
|
+
);
|
|
25
|
+
expect(toJSON()).toMatchSnapshot();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('renders as expected with accessibilityRole', () => {
|
|
29
|
+
const { toJSON } = render(
|
|
30
|
+
<Checkbox value="" onChange={onChange} accessibilityRole={'none'} />
|
|
31
|
+
);
|
|
32
|
+
expect(toJSON()).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('calls the expected handler when selected', () => {
|
|
36
|
+
const { getByRole } = render(<Checkbox value="" onChange={onChange} />);
|
|
37
|
+
const checkbox = getByRole('checkbox');
|
|
38
|
+
fireEvent.press(checkbox);
|
|
39
|
+
expect(onChange).toHaveBeenCalledTimes(1);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('does nothing when disabled', () => {
|
|
43
|
+
const { getByRole } = render(
|
|
44
|
+
<Checkbox value="" onChange={onChange} disabled />
|
|
45
|
+
);
|
|
46
|
+
const checkbox = getByRole('checkbox');
|
|
47
|
+
fireEvent.press(checkbox);
|
|
48
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Checkbox renders as expected when disabled 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
accessibilityRole="checkbox"
|
|
6
|
+
accessibilityState={
|
|
7
|
+
Object {
|
|
8
|
+
"disabled": true,
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
accessible={true}
|
|
12
|
+
collapsable={false}
|
|
13
|
+
focusable={true}
|
|
14
|
+
onBlur={[Function]}
|
|
15
|
+
onClick={[Function]}
|
|
16
|
+
onFocus={[Function]}
|
|
17
|
+
onResponderGrant={[Function]}
|
|
18
|
+
onResponderMove={[Function]}
|
|
19
|
+
onResponderRelease={[Function]}
|
|
20
|
+
onResponderTerminate={[Function]}
|
|
21
|
+
onResponderTerminationRequest={[Function]}
|
|
22
|
+
onStartShouldSetResponder={[Function]}
|
|
23
|
+
style={
|
|
24
|
+
Array [
|
|
25
|
+
Object {
|
|
26
|
+
"alignItems": "center",
|
|
27
|
+
"flexDirection": "row",
|
|
28
|
+
"opacity": 0.6,
|
|
29
|
+
"padding": 4,
|
|
30
|
+
},
|
|
31
|
+
undefined,
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
>
|
|
35
|
+
<Image
|
|
36
|
+
source={
|
|
37
|
+
Object {
|
|
38
|
+
"testUri": "../../../src/assets/icons/checkboxOutline.png",
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
style={
|
|
42
|
+
Array [
|
|
43
|
+
Object {
|
|
44
|
+
"height": undefined,
|
|
45
|
+
"resizeMode": "contain",
|
|
46
|
+
"tintColor": undefined,
|
|
47
|
+
"width": undefined,
|
|
48
|
+
},
|
|
49
|
+
undefined,
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
/>
|
|
53
|
+
</View>
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
exports[`Checkbox renders as expected when selected is false 1`] = `
|
|
57
|
+
<View
|
|
58
|
+
accessibilityRole="checkbox"
|
|
59
|
+
accessible={true}
|
|
60
|
+
collapsable={false}
|
|
61
|
+
focusable={true}
|
|
62
|
+
onBlur={[Function]}
|
|
63
|
+
onClick={[Function]}
|
|
64
|
+
onFocus={[Function]}
|
|
65
|
+
onResponderGrant={[Function]}
|
|
66
|
+
onResponderMove={[Function]}
|
|
67
|
+
onResponderRelease={[Function]}
|
|
68
|
+
onResponderTerminate={[Function]}
|
|
69
|
+
onResponderTerminationRequest={[Function]}
|
|
70
|
+
onStartShouldSetResponder={[Function]}
|
|
71
|
+
style={
|
|
72
|
+
Array [
|
|
73
|
+
Object {
|
|
74
|
+
"alignItems": "center",
|
|
75
|
+
"flexDirection": "row",
|
|
76
|
+
"opacity": 1,
|
|
77
|
+
"padding": 4,
|
|
78
|
+
},
|
|
79
|
+
undefined,
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
>
|
|
83
|
+
<Image
|
|
84
|
+
source={
|
|
85
|
+
Object {
|
|
86
|
+
"testUri": "../../../src/assets/icons/checkboxOutline.png",
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
style={
|
|
90
|
+
Array [
|
|
91
|
+
Object {
|
|
92
|
+
"height": undefined,
|
|
93
|
+
"resizeMode": "contain",
|
|
94
|
+
"tintColor": undefined,
|
|
95
|
+
"width": undefined,
|
|
96
|
+
},
|
|
97
|
+
undefined,
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
/>
|
|
101
|
+
</View>
|
|
102
|
+
`;
|
|
103
|
+
|
|
104
|
+
exports[`Checkbox renders as expected when selected is true 1`] = `
|
|
105
|
+
<View
|
|
106
|
+
accessibilityRole="checkbox"
|
|
107
|
+
accessible={true}
|
|
108
|
+
collapsable={false}
|
|
109
|
+
focusable={true}
|
|
110
|
+
onBlur={[Function]}
|
|
111
|
+
onClick={[Function]}
|
|
112
|
+
onFocus={[Function]}
|
|
113
|
+
onResponderGrant={[Function]}
|
|
114
|
+
onResponderMove={[Function]}
|
|
115
|
+
onResponderRelease={[Function]}
|
|
116
|
+
onResponderTerminate={[Function]}
|
|
117
|
+
onResponderTerminationRequest={[Function]}
|
|
118
|
+
onStartShouldSetResponder={[Function]}
|
|
119
|
+
style={
|
|
120
|
+
Array [
|
|
121
|
+
Object {
|
|
122
|
+
"alignItems": "center",
|
|
123
|
+
"flexDirection": "row",
|
|
124
|
+
"opacity": 1,
|
|
125
|
+
"padding": 4,
|
|
126
|
+
},
|
|
127
|
+
undefined,
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
>
|
|
131
|
+
<Image
|
|
132
|
+
source={
|
|
133
|
+
Object {
|
|
134
|
+
"testUri": "../../../src/assets/icons/checkboxFilled.png",
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
style={
|
|
138
|
+
Array [
|
|
139
|
+
Object {
|
|
140
|
+
"height": undefined,
|
|
141
|
+
"resizeMode": "contain",
|
|
142
|
+
"tintColor": undefined,
|
|
143
|
+
"width": undefined,
|
|
144
|
+
},
|
|
145
|
+
undefined,
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
/>
|
|
149
|
+
</View>
|
|
150
|
+
`;
|
|
151
|
+
|
|
152
|
+
exports[`Checkbox renders as expected with accessibilityRole 1`] = `
|
|
153
|
+
<View
|
|
154
|
+
accessibilityRole="none"
|
|
155
|
+
accessible={true}
|
|
156
|
+
collapsable={false}
|
|
157
|
+
focusable={true}
|
|
158
|
+
onBlur={[Function]}
|
|
159
|
+
onClick={[Function]}
|
|
160
|
+
onFocus={[Function]}
|
|
161
|
+
onResponderGrant={[Function]}
|
|
162
|
+
onResponderMove={[Function]}
|
|
163
|
+
onResponderRelease={[Function]}
|
|
164
|
+
onResponderTerminate={[Function]}
|
|
165
|
+
onResponderTerminationRequest={[Function]}
|
|
166
|
+
onStartShouldSetResponder={[Function]}
|
|
167
|
+
style={
|
|
168
|
+
Array [
|
|
169
|
+
Object {
|
|
170
|
+
"alignItems": "center",
|
|
171
|
+
"flexDirection": "row",
|
|
172
|
+
"opacity": 1,
|
|
173
|
+
"padding": 4,
|
|
174
|
+
},
|
|
175
|
+
undefined,
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
>
|
|
179
|
+
<Image
|
|
180
|
+
source={
|
|
181
|
+
Object {
|
|
182
|
+
"testUri": "../../../src/assets/icons/checkboxOutline.png",
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
style={
|
|
186
|
+
Array [
|
|
187
|
+
Object {
|
|
188
|
+
"height": undefined,
|
|
189
|
+
"resizeMode": "contain",
|
|
190
|
+
"tintColor": undefined,
|
|
191
|
+
"width": undefined,
|
|
192
|
+
},
|
|
193
|
+
undefined,
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
/>
|
|
197
|
+
</View>
|
|
198
|
+
`;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PressableProps, StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
import { IconProps } from '../Icon/types';
|
|
3
|
+
import { LabelProps } from '../Label';
|
|
4
|
+
import { LabelPosition } from '../Label/types';
|
|
5
|
+
|
|
6
|
+
export interface CheckboxProps<T> extends PressableProps {
|
|
7
|
+
iconStyle?: IconProps['style'];
|
|
8
|
+
label?: string;
|
|
9
|
+
labelPosition?: LabelPosition;
|
|
10
|
+
labelStyle?: LabelProps['style'];
|
|
11
|
+
onChange: (value: T) => void;
|
|
12
|
+
selected?: boolean;
|
|
13
|
+
size?: number;
|
|
14
|
+
style?: StyleProp<ViewStyle>;
|
|
15
|
+
value: T;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface CheckboxStyle {
|
|
19
|
+
container: ViewStyle;
|
|
20
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
import { styles } from './styles';
|
|
4
|
+
import { HeadingProps } from './types';
|
|
5
|
+
|
|
6
|
+
export default function Heading({
|
|
7
|
+
accessibilityRole = 'header',
|
|
8
|
+
children,
|
|
9
|
+
level = 6,
|
|
10
|
+
style,
|
|
11
|
+
...rest
|
|
12
|
+
}: HeadingProps): JSX.Element {
|
|
13
|
+
return (
|
|
14
|
+
<Text
|
|
15
|
+
{...rest}
|
|
16
|
+
accessibilityRole={accessibilityRole}
|
|
17
|
+
style={[styles.text, styles[level], style]}
|
|
18
|
+
>
|
|
19
|
+
{children}
|
|
20
|
+
</Text>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import TestRenderer from 'react-test-renderer';
|
|
3
|
+
import Heading from '../Heading';
|
|
4
|
+
import { HeadingProps } from '../types';
|
|
5
|
+
|
|
6
|
+
const title = 'Test Heading';
|
|
7
|
+
const levels: HeadingProps['level'][] = [1, 2, 3, 4, 5, 6];
|
|
8
|
+
|
|
9
|
+
describe('Heading', () => {
|
|
10
|
+
it('renders a level 6 Heading by default', () => {
|
|
11
|
+
const defaultHeading = TestRenderer.create(<Heading>{title}</Heading>);
|
|
12
|
+
const headingLevel6 = TestRenderer.create(
|
|
13
|
+
<Heading level={6}>{title}</Heading>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
expect(defaultHeading.toJSON()).toEqual(headingLevel6.toJSON());
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it.each(levels)('renders a level %i Heading as expected', (level) => {
|
|
20
|
+
const heading = TestRenderer.create(
|
|
21
|
+
<Heading level={level}>{`Heading level ${level}`}</Heading>
|
|
22
|
+
);
|
|
23
|
+
expect(heading.toJSON()).toMatchSnapshot();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('applies style props', () => {
|
|
27
|
+
const customStyle = { color: 'red' };
|
|
28
|
+
|
|
29
|
+
const styledHeading = TestRenderer.create(
|
|
30
|
+
<Heading style={customStyle}>{title}</Heading>
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
expect(styledHeading.toJSON()).toMatchSnapshot();
|
|
34
|
+
expect(styledHeading.root.props.style).toBe(customStyle);
|
|
35
|
+
});
|
|
36
|
+
});
|