@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,150 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Heading applies style props 1`] = `
|
|
4
|
+
<Text
|
|
5
|
+
accessibilityRole="header"
|
|
6
|
+
style={
|
|
7
|
+
Array [
|
|
8
|
+
Object {
|
|
9
|
+
"color": "black",
|
|
10
|
+
},
|
|
11
|
+
Object {
|
|
12
|
+
"fontSize": 16,
|
|
13
|
+
"fontWeight": "900",
|
|
14
|
+
"lineHeight": 24,
|
|
15
|
+
},
|
|
16
|
+
Object {
|
|
17
|
+
"color": "red",
|
|
18
|
+
},
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
>
|
|
22
|
+
Test Heading
|
|
23
|
+
</Text>
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
exports[`Heading renders a level 1 Heading as expected 1`] = `
|
|
27
|
+
<Text
|
|
28
|
+
accessibilityRole="header"
|
|
29
|
+
style={
|
|
30
|
+
Array [
|
|
31
|
+
Object {
|
|
32
|
+
"color": "black",
|
|
33
|
+
},
|
|
34
|
+
Object {
|
|
35
|
+
"fontSize": 56,
|
|
36
|
+
"fontWeight": "100",
|
|
37
|
+
"lineHeight": 84,
|
|
38
|
+
},
|
|
39
|
+
undefined,
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
>
|
|
43
|
+
Heading level 1
|
|
44
|
+
</Text>
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
exports[`Heading renders a level 2 Heading as expected 1`] = `
|
|
48
|
+
<Text
|
|
49
|
+
accessibilityRole="header"
|
|
50
|
+
style={
|
|
51
|
+
Array [
|
|
52
|
+
Object {
|
|
53
|
+
"color": "black",
|
|
54
|
+
},
|
|
55
|
+
Object {
|
|
56
|
+
"fontSize": 44,
|
|
57
|
+
"fontWeight": "200",
|
|
58
|
+
"lineHeight": 66,
|
|
59
|
+
},
|
|
60
|
+
undefined,
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
>
|
|
64
|
+
Heading level 2
|
|
65
|
+
</Text>
|
|
66
|
+
`;
|
|
67
|
+
|
|
68
|
+
exports[`Heading renders a level 3 Heading as expected 1`] = `
|
|
69
|
+
<Text
|
|
70
|
+
accessibilityRole="header"
|
|
71
|
+
style={
|
|
72
|
+
Array [
|
|
73
|
+
Object {
|
|
74
|
+
"color": "black",
|
|
75
|
+
},
|
|
76
|
+
Object {
|
|
77
|
+
"fontSize": 34,
|
|
78
|
+
"fontWeight": "300",
|
|
79
|
+
"lineHeight": 51,
|
|
80
|
+
},
|
|
81
|
+
undefined,
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
>
|
|
85
|
+
Heading level 3
|
|
86
|
+
</Text>
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
exports[`Heading renders a level 4 Heading as expected 1`] = `
|
|
90
|
+
<Text
|
|
91
|
+
accessibilityRole="header"
|
|
92
|
+
style={
|
|
93
|
+
Array [
|
|
94
|
+
Object {
|
|
95
|
+
"color": "black",
|
|
96
|
+
},
|
|
97
|
+
Object {
|
|
98
|
+
"fontSize": 26,
|
|
99
|
+
"fontWeight": "500",
|
|
100
|
+
"lineHeight": 39,
|
|
101
|
+
},
|
|
102
|
+
undefined,
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
>
|
|
106
|
+
Heading level 4
|
|
107
|
+
</Text>
|
|
108
|
+
`;
|
|
109
|
+
|
|
110
|
+
exports[`Heading renders a level 5 Heading as expected 1`] = `
|
|
111
|
+
<Text
|
|
112
|
+
accessibilityRole="header"
|
|
113
|
+
style={
|
|
114
|
+
Array [
|
|
115
|
+
Object {
|
|
116
|
+
"color": "black",
|
|
117
|
+
},
|
|
118
|
+
Object {
|
|
119
|
+
"fontSize": 20,
|
|
120
|
+
"fontWeight": "700",
|
|
121
|
+
"lineHeight": 30,
|
|
122
|
+
},
|
|
123
|
+
undefined,
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
>
|
|
127
|
+
Heading level 5
|
|
128
|
+
</Text>
|
|
129
|
+
`;
|
|
130
|
+
|
|
131
|
+
exports[`Heading renders a level 6 Heading as expected 1`] = `
|
|
132
|
+
<Text
|
|
133
|
+
accessibilityRole="header"
|
|
134
|
+
style={
|
|
135
|
+
Array [
|
|
136
|
+
Object {
|
|
137
|
+
"color": "black",
|
|
138
|
+
},
|
|
139
|
+
Object {
|
|
140
|
+
"fontSize": 16,
|
|
141
|
+
"fontWeight": "900",
|
|
142
|
+
"lineHeight": 24,
|
|
143
|
+
},
|
|
144
|
+
undefined,
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
>
|
|
148
|
+
Heading level 6
|
|
149
|
+
</Text>
|
|
150
|
+
`;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { getLineHeight } from '../../utils';
|
|
3
|
+
import { HeadingStyles } from './types';
|
|
4
|
+
|
|
5
|
+
export const styles: HeadingStyles = StyleSheet.create({
|
|
6
|
+
text: {
|
|
7
|
+
color: 'black',
|
|
8
|
+
},
|
|
9
|
+
// these values are completely arbitrary for now
|
|
10
|
+
1: { fontSize: 56, fontWeight: '100', lineHeight: getLineHeight(56) },
|
|
11
|
+
2: { fontSize: 44, fontWeight: '200', lineHeight: getLineHeight(44) },
|
|
12
|
+
3: { fontSize: 34, fontWeight: '300', lineHeight: getLineHeight(34) },
|
|
13
|
+
4: { fontSize: 26, fontWeight: '500', lineHeight: getLineHeight(26) },
|
|
14
|
+
5: { fontSize: 20, fontWeight: '700', lineHeight: getLineHeight(20) },
|
|
15
|
+
6: { fontSize: 16, fontWeight: '900', lineHeight: getLineHeight(16) },
|
|
16
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TextProps, TextStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
type Level = 1 | 2 | 3 | 4 | 5 | 6;
|
|
4
|
+
|
|
5
|
+
export interface HeadingProps extends TextProps {
|
|
6
|
+
level?: Level;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type HeadingStyles = {
|
|
10
|
+
text: TextStyle;
|
|
11
|
+
} & {
|
|
12
|
+
[key in Level]: TextStyle;
|
|
13
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { Animated, Image } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { getStyles } from './styles';
|
|
5
|
+
import { IconProps } from './types';
|
|
6
|
+
|
|
7
|
+
export default function Icon({
|
|
8
|
+
animated,
|
|
9
|
+
color,
|
|
10
|
+
size,
|
|
11
|
+
style,
|
|
12
|
+
...rest
|
|
13
|
+
}: IconProps): JSX.Element {
|
|
14
|
+
const { icon } = useMemo(() => getStyles(color, size), [color, size]);
|
|
15
|
+
|
|
16
|
+
if (animated) {
|
|
17
|
+
return <Animated.Image {...rest} style={[icon, style]} />;
|
|
18
|
+
}
|
|
19
|
+
return <Image {...rest} style={[icon, style]} />;
|
|
20
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react-native';
|
|
3
|
+
import Icon from '../Icon';
|
|
4
|
+
|
|
5
|
+
const MOCK_SOURCE = { uri: 'mock.png' };
|
|
6
|
+
|
|
7
|
+
describe('Icon', () => {
|
|
8
|
+
it('renders as expected', () => {
|
|
9
|
+
const { toJSON } = render(<Icon source={MOCK_SOURCE} />);
|
|
10
|
+
expect(toJSON()).toMatchSnapshot();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('renders as expected with custom styles', () => {
|
|
14
|
+
const customStyle = { tintColor: 'red' };
|
|
15
|
+
const { toJSON } = render(
|
|
16
|
+
<Icon source={MOCK_SOURCE} style={customStyle} />
|
|
17
|
+
);
|
|
18
|
+
expect(toJSON()).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('renders an animated icon', () => {
|
|
22
|
+
const { toJSON } = render(<Icon source={MOCK_SOURCE} animated />);
|
|
23
|
+
expect(toJSON()).toMatchSnapshot();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Icon renders an animated icon 1`] = `
|
|
4
|
+
<Image
|
|
5
|
+
collapsable={false}
|
|
6
|
+
source={
|
|
7
|
+
Object {
|
|
8
|
+
"uri": "mock.png",
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
style={
|
|
12
|
+
Object {
|
|
13
|
+
"height": undefined,
|
|
14
|
+
"resizeMode": "contain",
|
|
15
|
+
"tintColor": undefined,
|
|
16
|
+
"width": undefined,
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/>
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
exports[`Icon renders as expected 1`] = `
|
|
23
|
+
<Image
|
|
24
|
+
source={
|
|
25
|
+
Object {
|
|
26
|
+
"uri": "mock.png",
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
style={
|
|
30
|
+
Array [
|
|
31
|
+
Object {
|
|
32
|
+
"height": undefined,
|
|
33
|
+
"resizeMode": "contain",
|
|
34
|
+
"tintColor": undefined,
|
|
35
|
+
"width": undefined,
|
|
36
|
+
},
|
|
37
|
+
undefined,
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
/>
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
exports[`Icon renders as expected with custom styles 1`] = `
|
|
44
|
+
<Image
|
|
45
|
+
source={
|
|
46
|
+
Object {
|
|
47
|
+
"uri": "mock.png",
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
style={
|
|
51
|
+
Array [
|
|
52
|
+
Object {
|
|
53
|
+
"height": undefined,
|
|
54
|
+
"resizeMode": "contain",
|
|
55
|
+
"tintColor": undefined,
|
|
56
|
+
"width": undefined,
|
|
57
|
+
},
|
|
58
|
+
Object {
|
|
59
|
+
"tintColor": "red",
|
|
60
|
+
},
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
/>
|
|
64
|
+
`;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { IconProps, IconStyles } from './types';
|
|
4
|
+
|
|
5
|
+
export const getStyles = (
|
|
6
|
+
color: IconProps['color'],
|
|
7
|
+
size: IconProps['size']
|
|
8
|
+
): IconStyles =>
|
|
9
|
+
StyleSheet.create({
|
|
10
|
+
icon: {
|
|
11
|
+
height: size,
|
|
12
|
+
resizeMode: 'contain',
|
|
13
|
+
tintColor: color,
|
|
14
|
+
width: size,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ColorValue, ImageProps, ImageStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export interface IconStyles {
|
|
4
|
+
icon: ImageStyle;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface IconProps extends ImageProps {
|
|
8
|
+
/**
|
|
9
|
+
* Whether the icon is animated
|
|
10
|
+
*/
|
|
11
|
+
animated?: boolean;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Color to be applied to the icon
|
|
15
|
+
*/
|
|
16
|
+
color?: ColorValue;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Icon size
|
|
20
|
+
*/
|
|
21
|
+
size?: number;
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Pressable } from 'react-native';
|
|
3
|
+
import { Icon } from '../Icon';
|
|
4
|
+
|
|
5
|
+
import { IconButtonProps } from './types';
|
|
6
|
+
|
|
7
|
+
export default function IconButton({
|
|
8
|
+
color,
|
|
9
|
+
iconStyle,
|
|
10
|
+
source,
|
|
11
|
+
size = 16,
|
|
12
|
+
...rest
|
|
13
|
+
}: IconButtonProps): JSX.Element {
|
|
14
|
+
return (
|
|
15
|
+
<Pressable {...rest}>
|
|
16
|
+
<Icon color={color} size={size} source={source} style={iconStyle} />
|
|
17
|
+
</Pressable>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import TestRenderer from 'react-test-renderer';
|
|
3
|
+
|
|
4
|
+
import IconButton from '../IconButton';
|
|
5
|
+
|
|
6
|
+
const source = { uri: 'icon.png' };
|
|
7
|
+
|
|
8
|
+
describe('IconButton', () => {
|
|
9
|
+
it('renders as expected', () => {
|
|
10
|
+
const iconButton = TestRenderer.create(<IconButton source={source} />);
|
|
11
|
+
expect(iconButton.toJSON()).toMatchSnapshot();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('renders as expected with custom icon style', () => {
|
|
15
|
+
const iconButton = TestRenderer.create(
|
|
16
|
+
<IconButton
|
|
17
|
+
iconStyle={{ backgroundColor: 'antiquewhite' }}
|
|
18
|
+
source={source}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
expect(iconButton.toJSON()).toMatchSnapshot();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`IconButton renders as expected 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
accessible={true}
|
|
6
|
+
collapsable={false}
|
|
7
|
+
focusable={true}
|
|
8
|
+
onBlur={[Function]}
|
|
9
|
+
onClick={[Function]}
|
|
10
|
+
onFocus={[Function]}
|
|
11
|
+
onResponderGrant={[Function]}
|
|
12
|
+
onResponderMove={[Function]}
|
|
13
|
+
onResponderRelease={[Function]}
|
|
14
|
+
onResponderTerminate={[Function]}
|
|
15
|
+
onResponderTerminationRequest={[Function]}
|
|
16
|
+
onStartShouldSetResponder={[Function]}
|
|
17
|
+
>
|
|
18
|
+
<Image
|
|
19
|
+
source={
|
|
20
|
+
Object {
|
|
21
|
+
"uri": "icon.png",
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
style={
|
|
25
|
+
Array [
|
|
26
|
+
Object {
|
|
27
|
+
"height": 16,
|
|
28
|
+
"resizeMode": "contain",
|
|
29
|
+
"tintColor": undefined,
|
|
30
|
+
"width": 16,
|
|
31
|
+
},
|
|
32
|
+
undefined,
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
/>
|
|
36
|
+
</View>
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
exports[`IconButton renders as expected with custom icon style 1`] = `
|
|
40
|
+
<View
|
|
41
|
+
accessible={true}
|
|
42
|
+
collapsable={false}
|
|
43
|
+
focusable={true}
|
|
44
|
+
onBlur={[Function]}
|
|
45
|
+
onClick={[Function]}
|
|
46
|
+
onFocus={[Function]}
|
|
47
|
+
onResponderGrant={[Function]}
|
|
48
|
+
onResponderMove={[Function]}
|
|
49
|
+
onResponderRelease={[Function]}
|
|
50
|
+
onResponderTerminate={[Function]}
|
|
51
|
+
onResponderTerminationRequest={[Function]}
|
|
52
|
+
onStartShouldSetResponder={[Function]}
|
|
53
|
+
>
|
|
54
|
+
<Image
|
|
55
|
+
source={
|
|
56
|
+
Object {
|
|
57
|
+
"uri": "icon.png",
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
style={
|
|
61
|
+
Array [
|
|
62
|
+
Object {
|
|
63
|
+
"height": 16,
|
|
64
|
+
"resizeMode": "contain",
|
|
65
|
+
"tintColor": undefined,
|
|
66
|
+
"width": 16,
|
|
67
|
+
},
|
|
68
|
+
Object {
|
|
69
|
+
"backgroundColor": "antiquewhite",
|
|
70
|
+
},
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
/>
|
|
74
|
+
</View>
|
|
75
|
+
`;
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ColorValue,
|
|
3
|
+
ImageSourcePropType,
|
|
4
|
+
ImageStyle,
|
|
5
|
+
PressableProps,
|
|
6
|
+
StyleProp,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
|
|
9
|
+
export interface IconButtonStyles {
|
|
10
|
+
icon: ImageStyle;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface IconButtonProps extends PressableProps {
|
|
14
|
+
/**
|
|
15
|
+
* Color to be applied to the icon
|
|
16
|
+
*/
|
|
17
|
+
color?: ColorValue;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Icon style properties
|
|
21
|
+
*/
|
|
22
|
+
iconStyle?: StyleProp<ImageStyle>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Icon source, only supports images at this time
|
|
26
|
+
*/
|
|
27
|
+
source: ImageSourcePropType;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Icon size
|
|
31
|
+
*/
|
|
32
|
+
size?: number;
|
|
33
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
import { LabelProps } from './types';
|
|
4
|
+
import { styles } from './styles';
|
|
5
|
+
|
|
6
|
+
export default function Label({
|
|
7
|
+
accessibilityRole = 'text',
|
|
8
|
+
children,
|
|
9
|
+
style,
|
|
10
|
+
...rest
|
|
11
|
+
}: LabelProps): JSX.Element {
|
|
12
|
+
return (
|
|
13
|
+
<Text
|
|
14
|
+
{...rest}
|
|
15
|
+
accessibilityRole={accessibilityRole}
|
|
16
|
+
style={[styles.label, style]}
|
|
17
|
+
>
|
|
18
|
+
{children}
|
|
19
|
+
</Text>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import TestRenderer from 'react-test-renderer';
|
|
3
|
+
import Label from '../Label';
|
|
4
|
+
|
|
5
|
+
describe('Label', () => {
|
|
6
|
+
it('renders a default Label', () => {
|
|
7
|
+
const defaultLabel = TestRenderer.create(<Label>Default Label</Label>);
|
|
8
|
+
|
|
9
|
+
expect(defaultLabel.toJSON()).toMatchSnapshot();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('applies style props', () => {
|
|
13
|
+
const customStyle = { color: 'red' };
|
|
14
|
+
|
|
15
|
+
const styledLabel = TestRenderer.create(
|
|
16
|
+
<Label style={customStyle}>Red Label</Label>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
expect(styledLabel.toJSON()).toMatchSnapshot();
|
|
20
|
+
expect(styledLabel.root.props.style).toBe(customStyle);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Label applies style props 1`] = `
|
|
4
|
+
<Text
|
|
5
|
+
accessibilityRole="text"
|
|
6
|
+
style={
|
|
7
|
+
Array [
|
|
8
|
+
Object {
|
|
9
|
+
"fontSize": 16,
|
|
10
|
+
"marginHorizontal": 4,
|
|
11
|
+
"marginVertical": 2,
|
|
12
|
+
},
|
|
13
|
+
Object {
|
|
14
|
+
"color": "red",
|
|
15
|
+
},
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
>
|
|
19
|
+
Red Label
|
|
20
|
+
</Text>
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
exports[`Label renders a default Label 1`] = `
|
|
24
|
+
<Text
|
|
25
|
+
accessibilityRole="text"
|
|
26
|
+
style={
|
|
27
|
+
Array [
|
|
28
|
+
Object {
|
|
29
|
+
"fontSize": 16,
|
|
30
|
+
"marginHorizontal": 4,
|
|
31
|
+
"marginVertical": 2,
|
|
32
|
+
},
|
|
33
|
+
undefined,
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
>
|
|
37
|
+
Default Label
|
|
38
|
+
</Text>
|
|
39
|
+
`;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ViewStyle } from 'react-native';
|
|
2
|
+
import { LabelPosition } from './types';
|
|
3
|
+
|
|
4
|
+
const FLEX_DIRECTIONS: Record<LabelPosition, ViewStyle['flexDirection']> = {
|
|
5
|
+
start: 'row-reverse',
|
|
6
|
+
end: 'row',
|
|
7
|
+
top: 'column-reverse',
|
|
8
|
+
bottom: 'column',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The `flexDirection` value returned from `getFlexDirectionFromLabelPosition`
|
|
13
|
+
* assumes a `Label` component follows the `Primary` component it labels inside
|
|
14
|
+
* the `Container` that the `flexDirection` is applied to.
|
|
15
|
+
*
|
|
16
|
+
* Example Usage:
|
|
17
|
+
* ```jsx
|
|
18
|
+
* const flexDirection = getFlexDirectionFromLabelPosition(labelPosition);
|
|
19
|
+
* <Container style={{ flexDirection }}>
|
|
20
|
+
* <Primary />
|
|
21
|
+
* <Label />
|
|
22
|
+
* </Container>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export const getFlexDirectionFromLabelPosition = (
|
|
26
|
+
position: LabelPosition
|
|
27
|
+
): ViewStyle['flexDirection'] => FLEX_DIRECTIONS[position];
|