@zj-dynamics/components-native 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE.foundation +21 -0
- package/README.md +16 -2
- package/RulnarComponentsNative.podspec +16 -0
- package/dist/AutoLink.d.ts +9 -0
- package/dist/AutoLink.js +63 -0
- package/dist/BottomSheetKeyboardAwareScrollView.d.ts +12 -0
- package/dist/BottomSheetKeyboardAwareScrollView.js +19 -0
- package/dist/Button.d.ts +37 -0
- package/dist/Button.js +24 -0
- package/dist/Checkbox.d.ts +37 -0
- package/dist/Checkbox.js +73 -0
- package/dist/Content.d.ts +16 -0
- package/dist/Content.js +17 -0
- package/dist/ContentOverlay.d.ts +31 -0
- package/dist/ContentOverlay.js +151 -0
- package/dist/Divider.d.ts +6 -0
- package/dist/Divider.js +20 -0
- package/dist/Flex.d.ts +10 -0
- package/dist/Flex.js +19 -0
- package/dist/Icon.d.ts +11 -0
- package/dist/Icon.js +17 -0
- package/dist/InputCurrency.d.ts +12 -0
- package/dist/InputCurrency.js +57 -0
- package/dist/InputText.d.ts +32 -0
- package/dist/InputText.js +103 -0
- package/dist/NativeTextFields.d.ts +22 -0
- package/dist/NativeTextFields.js +59 -0
- package/dist/Switch.d.ts +17 -0
- package/dist/Switch.js +27 -0
- package/dist/controlledField.d.ts +4 -0
- package/dist/controlledField.js +9 -0
- package/dist/foundationText/ActionItem/ActionItem.d.ts +42 -0
- package/dist/foundationText/ActionItem/ActionItem.js +31 -0
- package/dist/foundationText/ActionItem/ActionItem.style.d.ts +21 -0
- package/dist/foundationText/ActionItem/ActionItem.style.js +24 -0
- package/dist/foundationText/ActionItem/ActionItemGroup.d.ts +12 -0
- package/dist/foundationText/ActionItem/ActionItemGroup.js +18 -0
- package/dist/foundationText/ActionItem/components/ActionItemContainer.d.ts +10 -0
- package/dist/foundationText/ActionItem/components/ActionItemContainer.js +17 -0
- package/dist/foundationText/ActionItem/components/ActionItemContainer.style.d.ts +10 -0
- package/dist/foundationText/ActionItem/components/ActionItemContainer.style.js +13 -0
- package/dist/foundationText/ActionItem/index.d.ts +4 -0
- package/dist/foundationText/ActionItem/index.js +3 -0
- package/dist/foundationText/ActionLabel/ActionLabel.d.ts +28 -0
- package/dist/foundationText/ActionLabel/ActionLabel.js +22 -0
- package/dist/foundationText/ActionLabel/index.d.ts +2 -0
- package/dist/foundationText/ActionLabel/index.js +1 -0
- package/dist/foundationText/ActivityIndicator/ActivityIndicator.d.ts +46 -0
- package/dist/foundationText/ActivityIndicator/ActivityIndicator.js +191 -0
- package/dist/foundationText/ActivityIndicator/index.d.ts +2 -0
- package/dist/foundationText/ActivityIndicator/index.js +1 -0
- package/dist/foundationText/Banner/Banner.d.ts +3 -0
- package/dist/foundationText/Banner/Banner.js +64 -0
- package/dist/foundationText/Banner/Banner.style.d.ts +56 -0
- package/dist/foundationText/Banner/Banner.style.js +59 -0
- package/dist/foundationText/Banner/components/BannerIcon/BannerIcon.d.ts +8 -0
- package/dist/foundationText/Banner/components/BannerIcon/BannerIcon.js +9 -0
- package/dist/foundationText/Banner/components/BannerIcon/BannerIcon.style.d.ts +18 -0
- package/dist/foundationText/Banner/components/BannerIcon/BannerIcon.style.js +21 -0
- package/dist/foundationText/Banner/index.d.ts +2 -0
- package/dist/foundationText/Banner/index.js +1 -0
- package/dist/foundationText/Banner/types.d.ts +63 -0
- package/dist/foundationText/Banner/types.js +1 -0
- package/dist/foundationText/BottomSheet/BottomSheet.d.ts +32 -0
- package/dist/foundationText/BottomSheet/BottomSheet.js +75 -0
- package/dist/foundationText/BottomSheet/BottomSheet.style.d.ts +26 -0
- package/dist/foundationText/BottomSheet/BottomSheet.style.js +30 -0
- package/dist/foundationText/BottomSheet/components/BottomSheetOption/BottomSheetOption.d.ts +13 -0
- package/dist/foundationText/BottomSheet/components/BottomSheetOption/BottomSheetOption.js +16 -0
- package/dist/foundationText/BottomSheet/components/BottomSheetOption/BottomSheetOption.styles.d.ts +16 -0
- package/dist/foundationText/BottomSheet/components/BottomSheetOption/BottomSheetOption.styles.js +19 -0
- package/dist/foundationText/BottomSheet/components/BottomSheetOption/index.d.ts +2 -0
- package/dist/foundationText/BottomSheet/components/BottomSheetOption/index.js +1 -0
- package/dist/foundationText/BottomSheet/hooks/useBottomSheetBackHandler.d.ts +8 -0
- package/dist/foundationText/BottomSheet/hooks/useBottomSheetBackHandler.js +25 -0
- package/dist/foundationText/BottomSheet/index.d.ts +4 -0
- package/dist/foundationText/BottomSheet/index.js +2 -0
- package/dist/foundationText/ButtonGroup/ButtonGroup.d.ts +30 -0
- package/dist/foundationText/ButtonGroup/ButtonGroup.js +25 -0
- package/dist/foundationText/ButtonGroup/ButtonGroup.style.d.ts +16 -0
- package/dist/foundationText/ButtonGroup/ButtonGroup.style.js +19 -0
- package/dist/foundationText/ButtonGroup/ButtonGroupAction.d.ts +47 -0
- package/dist/foundationText/ButtonGroup/ButtonGroupAction.js +11 -0
- package/dist/foundationText/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.d.ts +14 -0
- package/dist/foundationText/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.js +15 -0
- package/dist/foundationText/ButtonGroup/components/SecondaryActionSheet/index.d.ts +1 -0
- package/dist/foundationText/ButtonGroup/components/SecondaryActionSheet/index.js +1 -0
- package/dist/foundationText/ButtonGroup/index.d.ts +3 -0
- package/dist/foundationText/ButtonGroup/index.js +2 -0
- package/dist/foundationText/ButtonGroup/types.d.ts +7 -0
- package/dist/foundationText/ButtonGroup/types.js +1 -0
- package/dist/foundationText/ButtonGroup/utils.d.ts +19 -0
- package/dist/foundationText/ButtonGroup/utils.js +41 -0
- package/dist/foundationText/Card/Card.d.ts +41 -0
- package/dist/foundationText/Card/Card.js +26 -0
- package/dist/foundationText/Card/Card.style.d.ts +56 -0
- package/dist/foundationText/Card/Card.style.js +38 -0
- package/dist/foundationText/Card/components/InternalCardHeader.d.ts +10 -0
- package/dist/foundationText/Card/components/InternalCardHeader.js +16 -0
- package/dist/foundationText/Card/components/InternalCardHeader.style.d.ts +14 -0
- package/dist/foundationText/Card/components/InternalCardHeader.style.js +17 -0
- package/dist/foundationText/Card/components/index.d.ts +1 -0
- package/dist/foundationText/Card/components/index.js +1 -0
- package/dist/foundationText/Card/index.d.ts +2 -0
- package/dist/foundationText/Card/index.js +1 -0
- package/dist/foundationText/Chip/Chip.d.ts +45 -0
- package/dist/foundationText/Chip/Chip.js +88 -0
- package/dist/foundationText/Chip/Chip.style.d.ts +27 -0
- package/dist/foundationText/Chip/Chip.style.js +31 -0
- package/dist/foundationText/Chip/index.d.ts +2 -0
- package/dist/foundationText/Chip/index.js +1 -0
- package/dist/foundationText/ComponentSettingsContext/ComponentSettingsContext.d.ts +57 -0
- package/dist/foundationText/ComponentSettingsContext/ComponentSettingsContext.js +26 -0
- package/dist/foundationText/ComponentSettingsContext/index.d.ts +1 -0
- package/dist/foundationText/ComponentSettingsContext/index.js +1 -0
- package/dist/foundationText/Disclosure/Disclosure.d.ts +35 -0
- package/dist/foundationText/Disclosure/Disclosure.js +51 -0
- package/dist/foundationText/Disclosure/Disclosure.style.d.ts +19 -0
- package/dist/foundationText/Disclosure/Disclosure.style.js +22 -0
- package/dist/foundationText/Disclosure/constants.d.ts +1 -0
- package/dist/foundationText/Disclosure/constants.js +1 -0
- package/dist/foundationText/Disclosure/index.d.ts +1 -0
- package/dist/foundationText/Disclosure/index.js +1 -0
- package/dist/foundationText/EmptyState/EmptyState.d.ts +35 -0
- package/dist/foundationText/EmptyState/EmptyState.js +18 -0
- package/dist/foundationText/EmptyState/EmptyState.style.d.ts +6 -0
- package/dist/foundationText/EmptyState/EmptyState.style.js +9 -0
- package/dist/foundationText/EmptyState/index.d.ts +2 -0
- package/dist/foundationText/EmptyState/index.js +1 -0
- package/dist/foundationText/ErrorMessageWrapper/ErrorMessageWrapper.d.ts +22 -0
- package/dist/foundationText/ErrorMessageWrapper/ErrorMessageWrapper.js +35 -0
- package/dist/foundationText/ErrorMessageWrapper/ErrorMessageWrapper.style.d.ts +29 -0
- package/dist/foundationText/ErrorMessageWrapper/ErrorMessageWrapper.style.js +32 -0
- package/dist/foundationText/ErrorMessageWrapper/context/ErrorMessageContext.d.ts +3 -0
- package/dist/foundationText/ErrorMessageWrapper/context/ErrorMessageContext.js +11 -0
- package/dist/foundationText/ErrorMessageWrapper/context/ErrorMessageProvider.d.ts +7 -0
- package/dist/foundationText/ErrorMessageWrapper/context/ErrorMessageProvider.js +38 -0
- package/dist/foundationText/ErrorMessageWrapper/context/index.d.ts +2 -0
- package/dist/foundationText/ErrorMessageWrapper/context/index.js +2 -0
- package/dist/foundationText/ErrorMessageWrapper/context/types.d.ts +62 -0
- package/dist/foundationText/ErrorMessageWrapper/context/types.js +1 -0
- package/dist/foundationText/ErrorMessageWrapper/index.d.ts +2 -0
- package/dist/foundationText/ErrorMessageWrapper/index.js +2 -0
- package/dist/foundationText/Form/Form.d.ts +4 -0
- package/dist/foundationText/Form/Form.js +142 -0
- package/dist/foundationText/Form/Form.style.d.ts +31 -0
- package/dist/foundationText/Form/Form.style.js +34 -0
- package/dist/foundationText/Form/components/FormActionBar/FormActionBar.d.ts +13 -0
- package/dist/foundationText/Form/components/FormActionBar/FormActionBar.js +21 -0
- package/dist/foundationText/Form/components/FormActionBar/FormActionBar.style.d.ts +15 -0
- package/dist/foundationText/Form/components/FormActionBar/FormActionBar.style.js +11 -0
- package/dist/foundationText/Form/components/FormActionBar/index.d.ts +2 -0
- package/dist/foundationText/Form/components/FormActionBar/index.js +1 -0
- package/dist/foundationText/Form/components/FormBody/FormBody.d.ts +10 -0
- package/dist/foundationText/Form/components/FormBody/FormBody.js +18 -0
- package/dist/foundationText/Form/components/FormBody/FormBody.style.d.ts +24 -0
- package/dist/foundationText/Form/components/FormBody/FormBody.style.js +27 -0
- package/dist/foundationText/Form/components/FormBody/index.d.ts +1 -0
- package/dist/foundationText/Form/components/FormBody/index.js +1 -0
- package/dist/foundationText/Form/components/FormCache/FormCache.d.ts +10 -0
- package/dist/foundationText/Form/components/FormCache/FormCache.js +28 -0
- package/dist/foundationText/Form/components/FormErrorBanner/FormErrorBanner.d.ts +3 -0
- package/dist/foundationText/Form/components/FormErrorBanner/FormErrorBanner.js +14 -0
- package/dist/foundationText/Form/components/FormErrorBanner/index.d.ts +1 -0
- package/dist/foundationText/Form/components/FormErrorBanner/index.js +1 -0
- package/dist/foundationText/Form/components/FormMask/FormMask.d.ts +2 -0
- package/dist/foundationText/Form/components/FormMask/FormMask.js +9 -0
- package/dist/foundationText/Form/components/FormMask/FormMask.style.d.ts +13 -0
- package/dist/foundationText/Form/components/FormMask/FormMask.style.js +16 -0
- package/dist/foundationText/Form/components/FormMask/index.d.ts +1 -0
- package/dist/foundationText/Form/components/FormMask/index.js +1 -0
- package/dist/foundationText/Form/components/FormMessage/FormMessage.d.ts +19 -0
- package/dist/foundationText/Form/components/FormMessage/FormMessage.js +49 -0
- package/dist/foundationText/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.d.ts +8 -0
- package/dist/foundationText/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.js +27 -0
- package/dist/foundationText/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.style.d.ts +20 -0
- package/dist/foundationText/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.style.js +18 -0
- package/dist/foundationText/Form/components/FormMessage/components/InternalFormMessage/index.d.ts +1 -0
- package/dist/foundationText/Form/components/FormMessage/components/InternalFormMessage/index.js +1 -0
- package/dist/foundationText/Form/components/FormMessage/index.d.ts +1 -0
- package/dist/foundationText/Form/components/FormMessage/index.js +1 -0
- package/dist/foundationText/Form/components/FormMessageBanner/FormMessageBanner.d.ts +7 -0
- package/dist/foundationText/Form/components/FormMessageBanner/FormMessageBanner.js +16 -0
- package/dist/foundationText/Form/components/FormMessageBanner/index.d.ts +1 -0
- package/dist/foundationText/Form/components/FormMessageBanner/index.js +1 -0
- package/dist/foundationText/Form/components/FormSaveButton/FormSaveButton.d.ts +3 -0
- package/dist/foundationText/Form/components/FormSaveButton/FormSaveButton.js +55 -0
- package/dist/foundationText/Form/components/FormSaveButton/index.d.ts +1 -0
- package/dist/foundationText/Form/components/FormSaveButton/index.js +1 -0
- package/dist/foundationText/Form/components/IOSKeyboardAwareScrollViewSpacer/IOSKeyboardAwareScrollViewSpacer.d.ts +6 -0
- package/dist/foundationText/Form/components/IOSKeyboardAwareScrollViewSpacer/IOSKeyboardAwareScrollViewSpacer.js +13 -0
- package/dist/foundationText/Form/constants.d.ts +2 -0
- package/dist/foundationText/Form/constants.js +2 -0
- package/dist/foundationText/Form/context/FormContext.d.ts +11 -0
- package/dist/foundationText/Form/context/FormContext.js +16 -0
- package/dist/foundationText/Form/context/index.d.ts +2 -0
- package/dist/foundationText/Form/context/index.js +1 -0
- package/dist/foundationText/Form/context/types.d.ts +26 -0
- package/dist/foundationText/Form/context/types.js +1 -0
- package/dist/foundationText/Form/hooks/useFormViewRefs.d.ts +10 -0
- package/dist/foundationText/Form/hooks/useFormViewRefs.js +13 -0
- package/dist/foundationText/Form/hooks/useInternalForm.d.ts +19 -0
- package/dist/foundationText/Form/hooks/useInternalForm.js +43 -0
- package/dist/foundationText/Form/hooks/useOfflineHandler.d.ts +1 -0
- package/dist/foundationText/Form/hooks/useOfflineHandler.js +23 -0
- package/dist/foundationText/Form/hooks/useSaveButtonPosition.d.ts +12 -0
- package/dist/foundationText/Form/hooks/useSaveButtonPosition.js +25 -0
- package/dist/foundationText/Form/hooks/useScreenInformation.d.ts +8 -0
- package/dist/foundationText/Form/hooks/useScreenInformation.js +15 -0
- package/dist/foundationText/Form/hooks/useScrollToError/index.d.ts +1 -0
- package/dist/foundationText/Form/hooks/useScrollToError/index.js +1 -0
- package/dist/foundationText/Form/hooks/useScrollToError/useScrollToError.d.ts +9 -0
- package/dist/foundationText/Form/hooks/useScrollToError/useScrollToError.js +64 -0
- package/dist/foundationText/Form/index.d.ts +5 -0
- package/dist/foundationText/Form/index.js +4 -0
- package/dist/foundationText/Form/types.d.ts +215 -0
- package/dist/foundationText/Form/types.js +10 -0
- package/dist/foundationText/FormField/FormField.d.ts +24 -0
- package/dist/foundationText/FormField/FormField.js +11 -0
- package/dist/foundationText/FormField/index.d.ts +1 -0
- package/dist/foundationText/FormField/index.js +1 -0
- package/dist/foundationText/FormatFile/FormatFile.d.ts +79 -0
- package/dist/foundationText/FormatFile/FormatFile.js +47 -0
- package/dist/foundationText/FormatFile/FormatFile.style.d.ts +15 -0
- package/dist/foundationText/FormatFile/FormatFile.style.js +19 -0
- package/dist/foundationText/FormatFile/FormatFileThumbnail.d.ts +58 -0
- package/dist/foundationText/FormatFile/FormatFileThumbnail.js +35 -0
- package/dist/foundationText/FormatFile/components/ErrorIcon/ErrorIcon.d.ts +2 -0
- package/dist/foundationText/FormatFile/components/ErrorIcon/ErrorIcon.js +9 -0
- package/dist/foundationText/FormatFile/components/ErrorIcon/ErrorIcon.style.d.ts +8 -0
- package/dist/foundationText/FormatFile/components/ErrorIcon/ErrorIcon.style.js +11 -0
- package/dist/foundationText/FormatFile/components/ErrorIcon/index.d.ts +1 -0
- package/dist/foundationText/FormatFile/components/ErrorIcon/index.js +1 -0
- package/dist/foundationText/FormatFile/components/FileView/FileView.d.ts +13 -0
- package/dist/foundationText/FormatFile/components/FileView/FileView.js +42 -0
- package/dist/foundationText/FormatFile/components/FileView/FileView.style.d.ts +64 -0
- package/dist/foundationText/FormatFile/components/FileView/FileView.style.js +70 -0
- package/dist/foundationText/FormatFile/components/FileView/index.d.ts +1 -0
- package/dist/foundationText/FormatFile/components/FileView/index.js +1 -0
- package/dist/foundationText/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.d.ts +12 -0
- package/dist/foundationText/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.js +17 -0
- package/dist/foundationText/FormatFile/components/FormatFileBottomSheet/index.d.ts +2 -0
- package/dist/foundationText/FormatFile/components/FormatFileBottomSheet/index.js +1 -0
- package/dist/foundationText/FormatFile/components/MediaView/MediaView.d.ts +14 -0
- package/dist/foundationText/FormatFile/components/MediaView/MediaView.js +108 -0
- package/dist/foundationText/FormatFile/components/MediaView/MediaView.style.d.ts +25 -0
- package/dist/foundationText/FormatFile/components/MediaView/MediaView.style.js +28 -0
- package/dist/foundationText/FormatFile/components/MediaView/index.d.ts +1 -0
- package/dist/foundationText/FormatFile/components/MediaView/index.js +1 -0
- package/dist/foundationText/FormatFile/components/ProgressBar/ProgressBar.d.ts +18 -0
- package/dist/foundationText/FormatFile/components/ProgressBar/ProgressBar.js +30 -0
- package/dist/foundationText/FormatFile/components/ProgressBar/ProgressBar.style.d.ts +13 -0
- package/dist/foundationText/FormatFile/components/ProgressBar/ProgressBar.style.js +16 -0
- package/dist/foundationText/FormatFile/components/ProgressBar/index.d.ts +1 -0
- package/dist/foundationText/FormatFile/components/ProgressBar/index.js +1 -0
- package/dist/foundationText/FormatFile/constants.d.ts +35 -0
- package/dist/foundationText/FormatFile/constants.js +74 -0
- package/dist/foundationText/FormatFile/context/FormatFileContext.d.ts +9 -0
- package/dist/foundationText/FormatFile/context/FormatFileContext.js +8 -0
- package/dist/foundationText/FormatFile/context/types.d.ts +9 -0
- package/dist/foundationText/FormatFile/context/types.js +1 -0
- package/dist/foundationText/FormatFile/index.d.ts +8 -0
- package/dist/foundationText/FormatFile/index.js +3 -0
- package/dist/foundationText/FormatFile/types.d.ts +105 -0
- package/dist/foundationText/FormatFile/types.js +8 -0
- package/dist/foundationText/FormatFile/utils/computeA11yLabel.d.ts +9 -0
- package/dist/foundationText/FormatFile/utils/computeA11yLabel.js +11 -0
- package/dist/foundationText/FormatFile/utils/createUseCreateThumbnail.d.ts +6 -0
- package/dist/foundationText/FormatFile/utils/createUseCreateThumbnail.js +27 -0
- package/dist/foundationText/FormatFile/utils/getFileCategory.d.ts +28 -0
- package/dist/foundationText/FormatFile/utils/getFileCategory.js +62 -0
- package/dist/foundationText/FormatFile/utils/index.d.ts +7 -0
- package/dist/foundationText/FormatFile/utils/index.js +6 -0
- package/dist/foundationText/FormatFile/utils/mapFileTypeToIconName.d.ts +17 -0
- package/dist/foundationText/FormatFile/utils/mapFileTypeToIconName.js +30 -0
- package/dist/foundationText/FormatFile/utils/parseFile.d.ts +3 -0
- package/dist/foundationText/FormatFile/utils/parseFile.js +58 -0
- package/dist/foundationText/FormatFile/utils/sanitizeFileName.d.ts +5 -0
- package/dist/foundationText/FormatFile/utils/sanitizeFileName.js +9 -0
- package/dist/foundationText/FormatFile/utils/truncateFileNameForLine.d.ts +24 -0
- package/dist/foundationText/FormatFile/utils/truncateFileNameForLine.js +58 -0
- package/dist/foundationText/Glimmer/Glimmer.d.ts +32 -0
- package/dist/foundationText/Glimmer/Glimmer.js +42 -0
- package/dist/foundationText/Glimmer/Glimmer.shape.style.d.ts +14 -0
- package/dist/foundationText/Glimmer/Glimmer.shape.style.js +17 -0
- package/dist/foundationText/Glimmer/Glimmer.size.style.d.ts +17 -0
- package/dist/foundationText/Glimmer/Glimmer.size.style.js +10 -0
- package/dist/foundationText/Glimmer/Glimmer.style.d.ts +26 -0
- package/dist/foundationText/Glimmer/Glimmer.style.js +30 -0
- package/dist/foundationText/Glimmer/index.d.ts +1 -0
- package/dist/foundationText/Glimmer/index.js +1 -0
- package/dist/foundationText/Heading/Heading.d.ts +38 -0
- package/dist/foundationText/Heading/Heading.js +53 -0
- package/dist/foundationText/Heading/index.d.ts +2 -0
- package/dist/foundationText/Heading/index.js +1 -0
- package/dist/foundationText/IconButton/IconButton.d.ts +35 -0
- package/dist/foundationText/IconButton/IconButton.js +9 -0
- package/dist/foundationText/IconButton/IconButton.style.d.ts +8 -0
- package/dist/foundationText/IconButton/IconButton.style.js +11 -0
- package/dist/foundationText/IconButton/index.d.ts +1 -0
- package/dist/foundationText/IconButton/index.js +1 -0
- package/dist/foundationText/InputCurrency/constants.d.ts +1 -0
- package/dist/foundationText/InputCurrency/constants.js +1 -0
- package/dist/foundationText/InputCurrency/utils.d.ts +9 -0
- package/dist/foundationText/InputCurrency/utils.js +57 -0
- package/dist/foundationText/InputDate/InputDate.d.ts +76 -0
- package/dist/foundationText/InputDate/InputDate.js +70 -0
- package/dist/foundationText/InputDate/index.d.ts +2 -0
- package/dist/foundationText/InputDate/index.js +1 -0
- package/dist/foundationText/InputFieldWrapper/CommonInputStyles.style.d.ts +10 -0
- package/dist/foundationText/InputFieldWrapper/CommonInputStyles.style.js +49 -0
- package/dist/foundationText/InputFieldWrapper/InputFieldWrapper.d.ts +92 -0
- package/dist/foundationText/InputFieldWrapper/InputFieldWrapper.js +99 -0
- package/dist/foundationText/InputFieldWrapper/InputFieldWrapper.style.d.ts +106 -0
- package/dist/foundationText/InputFieldWrapper/InputFieldWrapper.style.js +123 -0
- package/dist/foundationText/InputFieldWrapper/components/ClearAction/ClearAction.d.ts +10 -0
- package/dist/foundationText/InputFieldWrapper/components/ClearAction/ClearAction.js +11 -0
- package/dist/foundationText/InputFieldWrapper/components/ClearAction/ClearAction.style.d.ts +22 -0
- package/dist/foundationText/InputFieldWrapper/components/ClearAction/ClearAction.style.js +26 -0
- package/dist/foundationText/InputFieldWrapper/components/ClearAction/index.d.ts +1 -0
- package/dist/foundationText/InputFieldWrapper/components/ClearAction/index.js +1 -0
- package/dist/foundationText/InputFieldWrapper/components/Prefix/Prefix.d.ts +22 -0
- package/dist/foundationText/InputFieldWrapper/components/Prefix/Prefix.js +39 -0
- package/dist/foundationText/InputFieldWrapper/components/Suffix/Suffix.d.ts +25 -0
- package/dist/foundationText/InputFieldWrapper/components/Suffix/Suffix.js +40 -0
- package/dist/foundationText/InputFieldWrapper/index.d.ts +4 -0
- package/dist/foundationText/InputFieldWrapper/index.js +3 -0
- package/dist/foundationText/InputPressable/InputPressable.d.ts +91 -0
- package/dist/foundationText/InputPressable/InputPressable.js +42 -0
- package/dist/foundationText/InputPressable/InputPressable.style.d.ts +21 -0
- package/dist/foundationText/InputPressable/InputPressable.style.js +28 -0
- package/dist/foundationText/InputPressable/index.d.ts +2 -0
- package/dist/foundationText/InputPressable/index.js +1 -0
- package/dist/foundationText/InputSearch/components/FilterButton.d.ts +7 -0
- package/dist/foundationText/InputSearch/components/FilterButton.js +10 -0
- package/dist/foundationText/InputText/context/InputAccessoriesContext.d.ts +3 -0
- package/dist/foundationText/InputText/context/InputAccessoriesContext.js +16 -0
- package/dist/foundationText/InputText/context/InputAccessoriesProvider.d.ts +5 -0
- package/dist/foundationText/InputText/context/InputAccessoriesProvider.js +68 -0
- package/dist/foundationText/InputText/context/InputAccessoriesProvider.style.d.ts +17 -0
- package/dist/foundationText/InputText/context/InputAccessoriesProvider.style.js +23 -0
- package/dist/foundationText/InputText/context/index.d.ts +2 -0
- package/dist/foundationText/InputText/context/index.js +2 -0
- package/dist/foundationText/InputText/context/types.d.ts +23 -0
- package/dist/foundationText/InputText/context/types.js +1 -0
- package/dist/foundationText/InputTime/InputTime.d.ts +63 -0
- package/dist/foundationText/InputTime/InputTime.js +76 -0
- package/dist/foundationText/InputTime/InputTime.style.d.ts +6 -0
- package/dist/foundationText/InputTime/InputTime.style.js +7 -0
- package/dist/foundationText/InputTime/index.d.ts +2 -0
- package/dist/foundationText/InputTime/index.js +2 -0
- package/dist/foundationText/InputTime/utils/index.d.ts +11 -0
- package/dist/foundationText/InputTime/utils/index.js +16 -0
- package/dist/foundationText/ProgressBar/ProgressBar.d.ts +6 -0
- package/dist/foundationText/ProgressBar/ProgressBar.js +36 -0
- package/dist/foundationText/ProgressBar/ProgressBar.size.style.d.ts +11 -0
- package/dist/foundationText/ProgressBar/ProgressBar.size.style.js +6 -0
- package/dist/foundationText/ProgressBar/ProgressBar.style.d.ts +34 -0
- package/dist/foundationText/ProgressBar/ProgressBar.style.js +37 -0
- package/dist/foundationText/ProgressBar/ProgressBarInner.d.ts +12 -0
- package/dist/foundationText/ProgressBar/ProgressBarInner.js +25 -0
- package/dist/foundationText/ProgressBar/ProgressBarStepped.d.ts +12 -0
- package/dist/foundationText/ProgressBar/ProgressBarStepped.js +32 -0
- package/dist/foundationText/ProgressBar/index.d.ts +2 -0
- package/dist/foundationText/ProgressBar/index.js +1 -0
- package/dist/foundationText/ProgressBar/types.d.ts +61 -0
- package/dist/foundationText/ProgressBar/types.js +1 -0
- package/dist/foundationText/ProgressIndicator/ProgressIndicator.d.ts +3 -0
- package/dist/foundationText/ProgressIndicator/ProgressIndicator.js +105 -0
- package/dist/foundationText/ProgressIndicator/ProgressIndicator.size.style.d.ts +19 -0
- package/dist/foundationText/ProgressIndicator/ProgressIndicator.size.style.js +15 -0
- package/dist/foundationText/ProgressIndicator/ProgressIndicator.style.d.ts +48 -0
- package/dist/foundationText/ProgressIndicator/ProgressIndicator.style.js +51 -0
- package/dist/foundationText/ProgressIndicator/index.d.ts +2 -0
- package/dist/foundationText/ProgressIndicator/index.js +1 -0
- package/dist/foundationText/ProgressIndicator/types.d.ts +44 -0
- package/dist/foundationText/ProgressIndicator/types.js +1 -0
- package/dist/foundationText/Select/Select.d.ts +92 -0
- package/dist/foundationText/Select/Select.js +102 -0
- package/dist/foundationText/Select/Select.style.d.ts +29 -0
- package/dist/foundationText/Select/Select.style.js +55 -0
- package/dist/foundationText/Select/SelectComposableTypes.d.ts +50 -0
- package/dist/foundationText/Select/SelectComposableTypes.js +1 -0
- package/dist/foundationText/Select/SelectRoot.d.ts +12 -0
- package/dist/foundationText/Select/SelectRoot.js +69 -0
- package/dist/foundationText/Select/SelectRoot.style.d.ts +8 -0
- package/dist/foundationText/Select/SelectRoot.style.js +9 -0
- package/dist/foundationText/Select/components/SelectContent.d.ts +8 -0
- package/dist/foundationText/Select/components/SelectContent.js +34 -0
- package/dist/foundationText/Select/components/SelectDefaultPicker/SelectDefaultPicker.d.ts +5 -0
- package/dist/foundationText/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.d.ts +5 -0
- package/dist/foundationText/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.js +22 -0
- package/dist/foundationText/Select/components/SelectDefaultPicker/SelectDefaultPicker.js +15 -0
- package/dist/foundationText/Select/components/SelectDefaultPicker/SelectDefaultPicker.style.d.ts +30 -0
- package/dist/foundationText/Select/components/SelectDefaultPicker/SelectDefaultPicker.style.js +29 -0
- package/dist/foundationText/Select/components/SelectDefaultPicker/index.d.ts +1 -0
- package/dist/foundationText/Select/components/SelectDefaultPicker/index.js +1 -0
- package/dist/foundationText/Select/components/SelectFieldContext.d.ts +27 -0
- package/dist/foundationText/Select/components/SelectFieldContext.js +10 -0
- package/dist/foundationText/Select/components/SelectIOSPicker/SelectIOSPicker.d.ts +10 -0
- package/dist/foundationText/Select/components/SelectIOSPicker/SelectIOSPicker.js +2 -0
- package/dist/foundationText/Select/components/SelectIOSPicker/index.d.ts +1 -0
- package/dist/foundationText/Select/components/SelectIOSPicker/index.js +1 -0
- package/dist/foundationText/Select/components/SelectInternalPicker/SelectInternalPicker.d.ts +3 -0
- package/dist/foundationText/Select/components/SelectInternalPicker/SelectInternalPicker.js +14 -0
- package/dist/foundationText/Select/components/SelectInternalPicker/index.d.ts +1 -0
- package/dist/foundationText/Select/components/SelectInternalPicker/index.js +1 -0
- package/dist/foundationText/Select/components/SelectInternalPicker/utils.d.ts +3 -0
- package/dist/foundationText/Select/components/SelectInternalPicker/utils.js +13 -0
- package/dist/foundationText/Select/components/SelectItem.d.ts +32 -0
- package/dist/foundationText/Select/components/SelectItem.js +26 -0
- package/dist/foundationText/Select/components/SelectItem.style.d.ts +5 -0
- package/dist/foundationText/Select/components/SelectItem.style.js +6 -0
- package/dist/foundationText/Select/components/SelectLabel.d.ts +22 -0
- package/dist/foundationText/Select/components/SelectLabel.js +30 -0
- package/dist/foundationText/Select/components/SelectPressable/SelectPressable.d.ts +11 -0
- package/dist/foundationText/Select/components/SelectPressable/SelectPressable.js +17 -0
- package/dist/foundationText/Select/components/SelectPressable/SelectPressable.style.d.ts +5 -0
- package/dist/foundationText/Select/components/SelectPressable/SelectPressable.style.js +8 -0
- package/dist/foundationText/Select/components/SelectPressable/index.d.ts +1 -0
- package/dist/foundationText/Select/components/SelectPressable/index.js +1 -0
- package/dist/foundationText/Select/components/SelectTrigger.d.ts +20 -0
- package/dist/foundationText/Select/components/SelectTrigger.js +39 -0
- package/dist/foundationText/Select/components/SelectTrigger.style.d.ts +25 -0
- package/dist/foundationText/Select/components/SelectTrigger.style.js +31 -0
- package/dist/foundationText/Select/index.d.ts +4 -0
- package/dist/foundationText/Select/index.js +4 -0
- package/dist/foundationText/Select/types.d.ts +38 -0
- package/dist/foundationText/Select/types.js +1 -0
- package/dist/foundationText/StatusLabel/StatusLabel.d.ts +22 -0
- package/dist/foundationText/StatusLabel/StatusLabel.js +20 -0
- package/dist/foundationText/StatusLabel/StatusLabel.style.d.ts +23 -0
- package/dist/foundationText/StatusLabel/StatusLabel.style.js +29 -0
- package/dist/foundationText/StatusLabel/index.d.ts +2 -0
- package/dist/foundationText/StatusLabel/index.js +1 -0
- package/dist/foundationText/Text/Text.d.ts +76 -0
- package/dist/foundationText/Text/Text.js +39 -0
- package/dist/foundationText/Text/index.d.ts +2 -0
- package/dist/foundationText/Text/index.js +1 -0
- package/dist/foundationText/TextList/TextList.d.ts +30 -0
- package/dist/foundationText/TextList/TextList.js +11 -0
- package/dist/foundationText/TextList/TextList.style.d.ts +14 -0
- package/dist/foundationText/TextList/TextList.style.js +17 -0
- package/dist/foundationText/TextList/index.d.ts +1 -0
- package/dist/foundationText/TextList/index.js +1 -0
- package/dist/foundationText/ThumbnailList/ThumbnailList.d.ts +5 -0
- package/dist/foundationText/ThumbnailList/ThumbnailList.js +32 -0
- package/dist/foundationText/ThumbnailList/ThumbnailList.style.d.ts +47 -0
- package/dist/foundationText/ThumbnailList/ThumbnailList.style.js +50 -0
- package/dist/foundationText/ThumbnailList/index.d.ts +2 -0
- package/dist/foundationText/ThumbnailList/index.js +2 -0
- package/dist/foundationText/ThumbnailList/types.d.ts +15 -0
- package/dist/foundationText/ThumbnailList/types.js +5 -0
- package/dist/foundationText/Toast/Toast.d.ts +28 -0
- package/dist/foundationText/Toast/Toast.js +64 -0
- package/dist/foundationText/Toast/Toast.styles.d.ts +31 -0
- package/dist/foundationText/Toast/Toast.styles.js +31 -0
- package/dist/foundationText/Toast/index.d.ts +2 -0
- package/dist/foundationText/Toast/index.js +1 -0
- package/dist/foundationText/Typography/Typography.d.ts +126 -0
- package/dist/foundationText/Typography/Typography.js +124 -0
- package/dist/foundationText/Typography/Typography.style.d.ts +16 -0
- package/dist/foundationText/Typography/Typography.style.js +472 -0
- package/dist/foundationText/Typography/TypographyGestureDetector.d.ts +8 -0
- package/dist/foundationText/Typography/TypographyGestureDetector.js +11 -0
- package/dist/foundationText/Typography/index.d.ts +5 -0
- package/dist/foundationText/Typography/index.js +4 -0
- package/dist/foundationText/Typography/webFonts.d.ts +4 -0
- package/dist/foundationText/Typography/webFonts.js +34 -0
- package/dist/foundationText/capitalize.d.ts +1 -0
- package/dist/foundationText/capitalize.js +6 -0
- package/dist/foundationText/compatTheme.d.ts +8 -0
- package/dist/foundationText/compatTheme.js +14 -0
- package/dist/foundationText/dateFormatter.d.ts +6 -0
- package/dist/foundationText/dateFormatter.js +19 -0
- package/dist/foundationText/foundationMessages.d.ts +11 -0
- package/dist/foundationText/foundationMessages.js +24 -0
- package/dist/foundationText/messages-en.d.ts +38 -0
- package/dist/foundationText/messages-en.js +38 -0
- package/dist/foundationText/messages-es.d.ts +38 -0
- package/dist/foundationText/messages-es.js +38 -0
- package/dist/foundationText/primitives/HelperText/HelperText.d.ts +15 -0
- package/dist/foundationText/primitives/HelperText/HelperText.js +11 -0
- package/dist/foundationText/primitives/HelperText/HelperText.style.d.ts +16 -0
- package/dist/foundationText/primitives/HelperText/HelperText.style.js +19 -0
- package/dist/foundationText/primitives/HelperText/index.d.ts +2 -0
- package/dist/foundationText/primitives/HelperText/index.js +1 -0
- package/dist/foundationText/primitives/Portal/index.d.ts +1 -0
- package/dist/foundationText/primitives/Portal/index.js +7 -0
- package/dist/foundationText/primitives/Select/SelectPrimitive.d.ts +69 -0
- package/dist/foundationText/primitives/Select/SelectPrimitive.js +160 -0
- package/dist/foundationText/primitives/Select/SelectPrimitive.style.d.ts +114 -0
- package/dist/foundationText/primitives/Select/SelectPrimitive.style.js +130 -0
- package/dist/foundationText/primitives/Select/index.d.ts +2 -0
- package/dist/foundationText/primitives/Select/index.js +1 -0
- package/dist/foundationText/primitives/Select/nativeTypes.d.ts +84 -0
- package/dist/foundationText/primitives/Select/nativeTypes.js +1 -0
- package/dist/foundationText/primitives/Select/types.d.ts +41 -0
- package/dist/foundationText/primitives/Select/types.js +1 -0
- package/dist/foundationText/primitives/index.d.ts +3 -0
- package/dist/foundationText/primitives/index.js +3 -0
- package/dist/foundationTokens.d.ts +388 -0
- package/dist/foundationTokens.js +26 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +54 -0
- package/dist/legacyTheme.d.ts +18 -0
- package/dist/legacyTheme.js +23 -0
- package/dist/sheetContext.d.ts +3 -0
- package/dist/sheetContext.js +6 -0
- package/dist/theme.d.ts +29 -0
- package/dist/theme.js +42 -0
- package/dist/useFormController.d.ts +11 -0
- package/dist/useFormController.js +15 -0
- package/dist/useIsScreenReaderEnabled.d.ts +1 -0
- package/dist/useIsScreenReaderEnabled.js +21 -0
- package/ios/RulnarPickerManager.m +59 -0
- package/package.json +146 -4
- package/resources/meta.json +85 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { Alert } from "react-native";
|
|
3
|
+
import { useComponentMessages } from "../../foundationMessages.js";
|
|
4
|
+
export function useOfflineHandler() {
|
|
5
|
+
const { t } = useComponentMessages();
|
|
6
|
+
const handleOfflineSubmit = useCallback((callback, dismiss) => {
|
|
7
|
+
return () => {
|
|
8
|
+
Alert.alert(t("networkUnavailableTitle"), t("networkUnavailableDescription"), [
|
|
9
|
+
{
|
|
10
|
+
text: t("dismiss"),
|
|
11
|
+
style: "cancel",
|
|
12
|
+
onPress: dismiss,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
text: t("tryAgain"),
|
|
16
|
+
style: "default",
|
|
17
|
+
onPress: callback,
|
|
18
|
+
},
|
|
19
|
+
]);
|
|
20
|
+
};
|
|
21
|
+
}, [t]);
|
|
22
|
+
return handleOfflineSubmit;
|
|
23
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface UseSaveButtonPositionReturn {
|
|
2
|
+
saveButtonPosition: "sticky" | "inline";
|
|
3
|
+
}
|
|
4
|
+
interface UseSaveButtonPositionParams {
|
|
5
|
+
formContentHeight: number;
|
|
6
|
+
isBottomSheetOpen: boolean;
|
|
7
|
+
showStickySaveButton: boolean;
|
|
8
|
+
keyboardHeight: number;
|
|
9
|
+
keyboardScreenY: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function useSaveButtonPosition({ formContentHeight, isBottomSheetOpen, showStickySaveButton, keyboardHeight, keyboardScreenY, }: UseSaveButtonPositionParams): UseSaveButtonPositionReturn;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Platform } from "react-native";
|
|
2
|
+
import { useScreenInformation } from "./useScreenInformation.js";
|
|
3
|
+
import { platformTokens as tokens } from "../../../foundationTokens.js";
|
|
4
|
+
export function useSaveButtonPosition({ formContentHeight, isBottomSheetOpen, showStickySaveButton, keyboardHeight, keyboardScreenY, }) {
|
|
5
|
+
const { headerHeight } = useScreenInformation();
|
|
6
|
+
if (showStickySaveButton) {
|
|
7
|
+
return {
|
|
8
|
+
saveButtonPosition: "sticky",
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
if (Platform.OS === "android" || isBottomSheetOpen) {
|
|
12
|
+
return {
|
|
13
|
+
saveButtonPosition: "inline",
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const isKeyboardOpen = Boolean(keyboardHeight);
|
|
17
|
+
// tokens["space-large"] acts like a safe space below the form to avoid
|
|
18
|
+
// rendering the sticky button above the form elements.
|
|
19
|
+
const calculatedFormContentHeight = formContentHeight + headerHeight + tokens["space-large"];
|
|
20
|
+
const isKeyboardOverForm = calculatedFormContentHeight > keyboardScreenY;
|
|
21
|
+
const showInlineSaveButton = isKeyboardOpen && isKeyboardOverForm;
|
|
22
|
+
return {
|
|
23
|
+
saveButtonPosition: showInlineSaveButton ? "inline" : "sticky",
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EdgeInsets } from "react-native-safe-area-context";
|
|
2
|
+
interface UseScreenInformation {
|
|
3
|
+
readonly windowHeight: number;
|
|
4
|
+
readonly headerHeight: number;
|
|
5
|
+
readonly insets: EdgeInsets;
|
|
6
|
+
}
|
|
7
|
+
export declare function useScreenInformation(): UseScreenInformation;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useWindowDimensions } from "react-native";
|
|
2
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
3
|
+
import { KEYBOARD_TOP_PADDING_AUTO_SCROLL } from "../constants.js";
|
|
4
|
+
import { useComponentSettings } from "../../ComponentSettingsContext/index.js";
|
|
5
|
+
export function useScreenInformation() {
|
|
6
|
+
const { headerHeight } = useComponentSettings();
|
|
7
|
+
const windowHeight = useWindowDimensions().height;
|
|
8
|
+
const headerHeightWithPadding = headerHeight + KEYBOARD_TOP_PADDING_AUTO_SCROLL;
|
|
9
|
+
const insets = useSafeAreaInsets();
|
|
10
|
+
return {
|
|
11
|
+
windowHeight,
|
|
12
|
+
headerHeight: headerHeightWithPadding,
|
|
13
|
+
insets,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useScrollToError.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useScrollToError.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FieldValues, FormState, UseFormSetFocus } from "react-hook-form";
|
|
2
|
+
import type { KeyboardAwareScrollViewRef } from "react-native-keyboard-controller";
|
|
3
|
+
export interface UseScrollToErrorParams<T extends FieldValues> {
|
|
4
|
+
readonly formState: FormState<T>;
|
|
5
|
+
readonly refNode: number | null;
|
|
6
|
+
readonly setFocus: UseFormSetFocus<T>;
|
|
7
|
+
readonly scrollTo?: KeyboardAwareScrollViewRef["scrollTo"];
|
|
8
|
+
}
|
|
9
|
+
export declare function useScrollToError<T extends FieldValues>({ formState: { errors, isValid, submitCount }, refNode, setFocus, scrollTo, }: UseScrollToErrorParams<T>): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
import { Keyboard, Platform } from "react-native";
|
|
3
|
+
import { useIsScreenReaderEnabled } from "../../../../useIsScreenReaderEnabled.js";
|
|
4
|
+
import { useErrorMessageContext } from "../../../ErrorMessageWrapper/index.js";
|
|
5
|
+
export function useScrollToError({ formState: { errors, isValid, submitCount }, refNode, setFocus, scrollTo, }) {
|
|
6
|
+
const [submitCounter, setSubmitCounter] = useState(submitCount);
|
|
7
|
+
const isScreenReaderEnabled = useIsScreenReaderEnabled();
|
|
8
|
+
const manuallyScrollToElement = useManuallyScrollToElement(handleScroll, refNode);
|
|
9
|
+
// Determine if the form has been submitted by checking if the submit count
|
|
10
|
+
// went up.
|
|
11
|
+
const hasBeenSubmitted = submitCounter < submitCount;
|
|
12
|
+
if (!hasBeenSubmitted)
|
|
13
|
+
return;
|
|
14
|
+
if (isScreenReaderEnabled) {
|
|
15
|
+
manuallyScrollToElement();
|
|
16
|
+
Keyboard.dismiss();
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
defaultAutoScroll();
|
|
20
|
+
}
|
|
21
|
+
setSubmitCounter(submitCount);
|
|
22
|
+
function defaultAutoScroll() {
|
|
23
|
+
if (isValid)
|
|
24
|
+
return;
|
|
25
|
+
try {
|
|
26
|
+
focusInputWithRHF(errors, setFocus);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
manuallyScrollToElement();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function handleScroll(...[x, y]) {
|
|
33
|
+
/**
|
|
34
|
+
* Disable scroll animation on android when screen reader is active since it
|
|
35
|
+
* can't accessibility-focus on an offscreen component.
|
|
36
|
+
*/
|
|
37
|
+
const isAndroidWithScreenReader = isScreenReaderEnabled && Platform.OS === "android";
|
|
38
|
+
const shouldAnimateScroll = !isAndroidWithScreenReader;
|
|
39
|
+
scrollTo?.({ x, y, animated: shouldAnimateScroll });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function focusInputWithRHF(errors, setFocus) {
|
|
43
|
+
const errorMessages = Object.keys(errors);
|
|
44
|
+
setFocus(errorMessages[0]);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Manually scroll to the element by checking which elements has an error from
|
|
48
|
+
* the Error Message Context
|
|
49
|
+
*/
|
|
50
|
+
function useManuallyScrollToElement(callback, refNode) {
|
|
51
|
+
const { elements } = useErrorMessageContext();
|
|
52
|
+
return useCallback(() => {
|
|
53
|
+
const elementWithError = Object.keys(elements).find(el => elements[el]?.hasErrorMessage);
|
|
54
|
+
if (elementWithError) {
|
|
55
|
+
const element = elements[elementWithError];
|
|
56
|
+
if (element && refNode)
|
|
57
|
+
element.measure(refNode, callback, handleError);
|
|
58
|
+
element?.accessibilityFocus();
|
|
59
|
+
}
|
|
60
|
+
}, [callback, elements, refNode]);
|
|
61
|
+
}
|
|
62
|
+
function handleError() {
|
|
63
|
+
return Error("Couldn't scroll to error");
|
|
64
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Form } from "./Form.js";
|
|
2
|
+
export { FormMessage } from "./components/FormMessage/index.js";
|
|
3
|
+
export type { FormBannerErrors, FormBannerMessage, FormUserErrors, FormErrors, FormRef, FormValues, SecondaryActionProp, ValidationRulesByFieldPath, } from "./types.js";
|
|
4
|
+
export { FormSubmitErrorType, FormBannerMessageType } from "./types.js";
|
|
5
|
+
export * from "./context/index.js";
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import type { ReactElement, RefObject } from "react";
|
|
2
|
+
import type { ControllerProps, DefaultValues, FieldPath, FieldValues, Mode, UseFormReturn } from "react-hook-form";
|
|
3
|
+
import type { IconNames } from "@zj-dynamics/design/native";
|
|
4
|
+
import type { KeyboardAwareScrollViewRef } from "react-native-keyboard-controller";
|
|
5
|
+
export type FormValues<T> = T;
|
|
6
|
+
export type FormErrors = FormNetworkErrors | FormUserErrors;
|
|
7
|
+
export type FormBannerMessage = FormWarningMessage | FormNoticeMessage;
|
|
8
|
+
export declare enum FormSubmitErrorType {
|
|
9
|
+
NetworkError = "NetworkError",
|
|
10
|
+
UserError = "UserErrors"
|
|
11
|
+
}
|
|
12
|
+
export declare enum FormBannerMessageType {
|
|
13
|
+
WarningMessage = "WarningMessage",
|
|
14
|
+
NoticeMessage = "NoticeMessage"
|
|
15
|
+
}
|
|
16
|
+
export interface FormBannerErrors {
|
|
17
|
+
networkError?: string | undefined;
|
|
18
|
+
bannerError?: {
|
|
19
|
+
title: string;
|
|
20
|
+
messages?: string[];
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
interface FormNetworkErrors {
|
|
24
|
+
errorType: FormSubmitErrorType.NetworkError;
|
|
25
|
+
networkErrors: string;
|
|
26
|
+
}
|
|
27
|
+
export interface FormUserErrors {
|
|
28
|
+
errorType: FormSubmitErrorType.UserError;
|
|
29
|
+
userErrors: Record<string, string>;
|
|
30
|
+
}
|
|
31
|
+
interface FormWarningMessage {
|
|
32
|
+
messageType: FormBannerMessageType.WarningMessage;
|
|
33
|
+
message: string;
|
|
34
|
+
}
|
|
35
|
+
interface FormNoticeMessage {
|
|
36
|
+
messageType: FormBannerMessageType.NoticeMessage;
|
|
37
|
+
message: string;
|
|
38
|
+
}
|
|
39
|
+
export type FormRef<T extends FieldValues = FieldValues> = (UseFormReturn<T> & {
|
|
40
|
+
scrollViewRef?: RefObject<KeyboardAwareScrollViewRef | null>;
|
|
41
|
+
saveButtonHeight?: number;
|
|
42
|
+
messageBannerHeight?: number;
|
|
43
|
+
}) | undefined;
|
|
44
|
+
export interface FormProps<T extends FieldValues, SubmitResponseType> {
|
|
45
|
+
/**
|
|
46
|
+
* Content to be passed into the form
|
|
47
|
+
*/
|
|
48
|
+
children: React.ReactNode;
|
|
49
|
+
/**
|
|
50
|
+
* A callback function that is run before invoking onSubmit. Form submission is canceled if the promise resolves to false.
|
|
51
|
+
*/
|
|
52
|
+
onBeforeSubmit?: (data: FormValues<T>) => Promise<boolean>;
|
|
53
|
+
/**
|
|
54
|
+
* A callback function that handles the submission of form data.
|
|
55
|
+
* If an error occurs during submission, it should not be caught and handled silently; the error must be thrown again.
|
|
56
|
+
* If the submission is successful and no error is thrown, the `onSubmitSuccess` callback will be called.
|
|
57
|
+
* If an error is thrown, the `onSubmitError` callback will be called.
|
|
58
|
+
*/
|
|
59
|
+
onSubmit: (data: FormValues<T>) => Promise<SubmitResponseType>;
|
|
60
|
+
/**
|
|
61
|
+
* A callback function that handles any error that occurs during "onSubmit"
|
|
62
|
+
*/
|
|
63
|
+
onSubmitError: (error: FormErrors) => void;
|
|
64
|
+
/**
|
|
65
|
+
* A callback function that handles a successful form submission from "onSubmit"
|
|
66
|
+
*/
|
|
67
|
+
onSubmitSuccess: (data: SubmitResponseType) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Network or user errors to be displayed as a banner at the top of the form
|
|
70
|
+
*/
|
|
71
|
+
bannerErrors?: FormBannerErrors;
|
|
72
|
+
/**
|
|
73
|
+
* Status messages to be displayed as a banner at the top of the form
|
|
74
|
+
*/
|
|
75
|
+
bannerMessages?: FormBannerMessage[];
|
|
76
|
+
/**
|
|
77
|
+
* Loading when the initial form data is being fetched
|
|
78
|
+
*/
|
|
79
|
+
initialLoading?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* The initial values of the form inputs
|
|
82
|
+
* This should be available as soon as initialLoading is set to false
|
|
83
|
+
*/
|
|
84
|
+
initialValues?: DefaultValues<T>;
|
|
85
|
+
/**
|
|
86
|
+
* When the validation should happen.
|
|
87
|
+
* Possible values are "onBlur", "onChange", "onSubmit", "onTouched", and "all".
|
|
88
|
+
* The default value is "onTouched"
|
|
89
|
+
*/
|
|
90
|
+
mode?: Mode;
|
|
91
|
+
/**
|
|
92
|
+
* When the validation after submission should happen.
|
|
93
|
+
* Possible values are "onBlur", "onChange", and "onSubmit".
|
|
94
|
+
* The default value is "onChange"
|
|
95
|
+
*/
|
|
96
|
+
reValidateMode?: Exclude<Mode, "onTouched" | "all">;
|
|
97
|
+
/**
|
|
98
|
+
* ref object to access react hook form methods and state
|
|
99
|
+
*/
|
|
100
|
+
formRef?: RefObject<FormRef<T> | undefined>;
|
|
101
|
+
/**
|
|
102
|
+
* Label to be displayed for the save button
|
|
103
|
+
*/
|
|
104
|
+
saveButtonLabel?: string;
|
|
105
|
+
/**
|
|
106
|
+
* @deprecated use `secondaryAction` instead.
|
|
107
|
+
* Override default save button in the sticky section of the form with another element.
|
|
108
|
+
*/
|
|
109
|
+
renderStickySection?: (onSubmit: () => void, label: string | undefined, isSubmitting: boolean) => ReactElement;
|
|
110
|
+
/**
|
|
111
|
+
* Adding a key will save a local copy of the form data that will be used to
|
|
112
|
+
* recover values when the app is backgrounded or has crashed.
|
|
113
|
+
*/
|
|
114
|
+
localCacheKey?: string;
|
|
115
|
+
/**
|
|
116
|
+
* Forms field names that will not be considered for caching.
|
|
117
|
+
* Useful for omitting sensitive data.
|
|
118
|
+
*/
|
|
119
|
+
localCacheExclude?: string[];
|
|
120
|
+
/**
|
|
121
|
+
* A string or array of strings that can be used to identify the pre-filled
|
|
122
|
+
* data on the form. This can be used to support local caching for forms that
|
|
123
|
+
* prefill data without inadvertently applying the cache at the wrong time.
|
|
124
|
+
*
|
|
125
|
+
* For example this can be used to when an object is based on data from
|
|
126
|
+
* another object (Quote being converted into a Job). This will allow
|
|
127
|
+
* the user to retrieve data from the cache when trying to create the
|
|
128
|
+
* same object (same Quote being converted into a Job) following an app crash.
|
|
129
|
+
*
|
|
130
|
+
* There is still only one copy of data for each `localCacheKey`.
|
|
131
|
+
* If a user opens the same form the data will only be loaded if the `localCacheId` matches
|
|
132
|
+
*/
|
|
133
|
+
localCacheId?: string | string[];
|
|
134
|
+
/**
|
|
135
|
+
* If true, the local cache will be removed when the user navigates away from
|
|
136
|
+
* the dirty form even when offline. By default, cache is only removed on back when online.
|
|
137
|
+
* Defaults to false.
|
|
138
|
+
*/
|
|
139
|
+
UNSAFE_allowDiscardLocalCacheWhenOffline?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Secondary Action for ButtonGroup
|
|
142
|
+
*/
|
|
143
|
+
secondaryActions?: SecondaryActionProp[];
|
|
144
|
+
/**
|
|
145
|
+
* A number that will pull down the save button when the position is sticky.
|
|
146
|
+
* Useful when there's a footer or content below the form that is pulling
|
|
147
|
+
* the button up.
|
|
148
|
+
*/
|
|
149
|
+
saveButtonOffset?: number;
|
|
150
|
+
/**
|
|
151
|
+
* Forces to render the sticky save button instead of the inline.
|
|
152
|
+
* The sticky save button is default for iOS but not for Android due to
|
|
153
|
+
* limitations. Use this prop with caution on Android.
|
|
154
|
+
*/
|
|
155
|
+
showStickySaveButton?: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Renders a footer below the save button.
|
|
158
|
+
*/
|
|
159
|
+
renderFooter?: React.ReactNode;
|
|
160
|
+
/**
|
|
161
|
+
* @internal Do not use this prop. It is a hack and will be removed.
|
|
162
|
+
* TODO: JOB-147156 This is a HACK for multiline inputs on iOS scrolling issue.
|
|
163
|
+
* Disables the keyboard aware scroll view.
|
|
164
|
+
* This is needed to fix issues with multiline inputs on iOS. DO NOT
|
|
165
|
+
*/
|
|
166
|
+
disableKeyboardAwareScroll?: boolean;
|
|
167
|
+
}
|
|
168
|
+
export type InternalFormProps<T extends FieldValues, SubmitResponseType> = Omit<FormProps<T, SubmitResponseType>, "initialLoading">;
|
|
169
|
+
export type ValidationRulesByFieldPath<T extends FieldValues> = {
|
|
170
|
+
[p in FieldPath<T>]: ControllerProps<T, p>["rules"];
|
|
171
|
+
};
|
|
172
|
+
export interface FormSaveButtonProps {
|
|
173
|
+
/**
|
|
174
|
+
* Press handler
|
|
175
|
+
*/
|
|
176
|
+
primaryAction: () => Promise<void> | void;
|
|
177
|
+
/**
|
|
178
|
+
* Primary Button is loading
|
|
179
|
+
*/
|
|
180
|
+
loading: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Label for the save button
|
|
183
|
+
*/
|
|
184
|
+
label?: string;
|
|
185
|
+
/**
|
|
186
|
+
* Props and information regarding the secondary Action button(s)
|
|
187
|
+
*/
|
|
188
|
+
secondaryActions?: SecondaryActionProp[];
|
|
189
|
+
/**
|
|
190
|
+
* Set whether secondary Button is loading
|
|
191
|
+
*/
|
|
192
|
+
setSecondaryActionLoading?: (bool: boolean) => void;
|
|
193
|
+
/**
|
|
194
|
+
* Callback that is called when the secondary actions bottom sheet is opened.
|
|
195
|
+
*/
|
|
196
|
+
onOpenBottomSheet?: () => void;
|
|
197
|
+
/**
|
|
198
|
+
* Callback that is called when the secondary actions bottom sheet is closed.
|
|
199
|
+
*/
|
|
200
|
+
onCloseBottomSheet?: () => void;
|
|
201
|
+
}
|
|
202
|
+
interface SecondaryActionOnPress {
|
|
203
|
+
onBeforeSubmit?: () => Promise<boolean>;
|
|
204
|
+
onSubmit: (formSubmit: FormSaveButtonProps["primaryAction"]) => Promise<void>;
|
|
205
|
+
onSubmitSuccess?: () => void;
|
|
206
|
+
onSubmitError?: (error: FormErrors) => void;
|
|
207
|
+
resetFormOnSubmit?: boolean;
|
|
208
|
+
}
|
|
209
|
+
export interface SecondaryActionProp {
|
|
210
|
+
label: string;
|
|
211
|
+
icon?: IconNames | undefined;
|
|
212
|
+
handleAction: SecondaryActionOnPress;
|
|
213
|
+
destructive?: boolean;
|
|
214
|
+
}
|
|
215
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var FormSubmitErrorType;
|
|
2
|
+
(function (FormSubmitErrorType) {
|
|
3
|
+
FormSubmitErrorType["NetworkError"] = "NetworkError";
|
|
4
|
+
FormSubmitErrorType["UserError"] = "UserErrors";
|
|
5
|
+
})(FormSubmitErrorType || (FormSubmitErrorType = {}));
|
|
6
|
+
export var FormBannerMessageType;
|
|
7
|
+
(function (FormBannerMessageType) {
|
|
8
|
+
FormBannerMessageType["WarningMessage"] = "WarningMessage";
|
|
9
|
+
FormBannerMessageType["NoticeMessage"] = "NoticeMessage";
|
|
10
|
+
})(FormBannerMessageType || (FormBannerMessageType = {}));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ControllerRenderProps, FieldError, FieldValues, RegisterOptions } from "react-hook-form";
|
|
3
|
+
interface FormFieldProps<T> {
|
|
4
|
+
/**
|
|
5
|
+
* Name of the field.
|
|
6
|
+
*/
|
|
7
|
+
readonly name: string;
|
|
8
|
+
/**
|
|
9
|
+
* The initial value of the form field.
|
|
10
|
+
*/
|
|
11
|
+
readonly defaultValue?: T;
|
|
12
|
+
/**
|
|
13
|
+
* Children to render.
|
|
14
|
+
*/
|
|
15
|
+
readonly children: (field: ControllerRenderProps<FieldValues, string>, error?: FieldError) => React.ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Rules for returning an error when validations are violated.
|
|
18
|
+
* WARNING: This component needs to be nested inside a FormProvider
|
|
19
|
+
* for validations to work.
|
|
20
|
+
*/
|
|
21
|
+
readonly validations?: RegisterOptions;
|
|
22
|
+
}
|
|
23
|
+
export declare function FormField<T>({ name, children, defaultValue: value, validations, }: FormFieldProps<T>): React.JSX.Element;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { useFormController } from "../../useFormController.js";
|
|
4
|
+
export function FormField({ name, children, defaultValue: value, validations, }) {
|
|
5
|
+
const { error, field } = useFormController({
|
|
6
|
+
name,
|
|
7
|
+
value,
|
|
8
|
+
validations,
|
|
9
|
+
});
|
|
10
|
+
return _jsx(_Fragment, { children: children({ ...field }, error) });
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FormField } from "./FormField.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FormField } from "./FormField.js";
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { BottomSheetOptionsSuffix } from "./components/FormatFileBottomSheet/index.js";
|
|
3
|
+
import type { CreateThumbnail, File, FileUpload, FormattedFile } from "./types.js";
|
|
4
|
+
export interface FormatFileProps<T> {
|
|
5
|
+
/**
|
|
6
|
+
* File upload details object. Can be a File or a FileUpload
|
|
7
|
+
*/
|
|
8
|
+
readonly file: T;
|
|
9
|
+
/**
|
|
10
|
+
* Accessibility label
|
|
11
|
+
*/
|
|
12
|
+
readonly accessibilityLabel?: (string) | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Accessibility hint
|
|
15
|
+
*/
|
|
16
|
+
readonly accessibilityHint?: (string) | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* A function which handles the onTap event.
|
|
19
|
+
*/
|
|
20
|
+
readonly onTap?: (file: T) => void;
|
|
21
|
+
/**
|
|
22
|
+
* A function to be called on "Remove" Bottom Sheet Option press
|
|
23
|
+
*/
|
|
24
|
+
readonly onRemove?: (() => void) | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Handler for the "Preview" Bottom Sheet Option press
|
|
27
|
+
*/
|
|
28
|
+
readonly onPreviewPress?: ((formattedFile: FormattedFile) => void) | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* A file type to show at Bottom Sheet options
|
|
31
|
+
*/
|
|
32
|
+
readonly bottomSheetOptionsSuffix?: (BottomSheetOptionsSuffix) | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Uses a grid layout when multi-file upload is supported
|
|
35
|
+
*/
|
|
36
|
+
readonly styleInGrid?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* A reference to the element in the rendered output
|
|
39
|
+
*/
|
|
40
|
+
readonly testID?: (string) | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Set false to hide all file type iconography, including the video fallback
|
|
43
|
+
* placeholder icon.
|
|
44
|
+
*/
|
|
45
|
+
readonly showFileTypeIndicator?: (boolean) | undefined;
|
|
46
|
+
readonly createThumbnail?: (CreateThumbnail) | undefined;
|
|
47
|
+
}
|
|
48
|
+
interface FormatFileContentProps {
|
|
49
|
+
readonly accessibilityLabel?: (string) | undefined;
|
|
50
|
+
readonly file: FormattedFile;
|
|
51
|
+
readonly showOverlay: boolean;
|
|
52
|
+
readonly styleInGrid: boolean;
|
|
53
|
+
readonly onUploadComplete: () => void;
|
|
54
|
+
readonly isMedia: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* @internal
|
|
57
|
+
* When true, the component skips its container wrapper entirely
|
|
58
|
+
* (no border, background, or dimension styles). Use this when the
|
|
59
|
+
* parent component handles container styling directly, such as in
|
|
60
|
+
* FormatFileThumbnail.
|
|
61
|
+
*/
|
|
62
|
+
readonly skipContainerStyles?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* @internal
|
|
65
|
+
* A function to be called when the media has loaded.
|
|
66
|
+
* This is only used in FormatFileThumbnail.
|
|
67
|
+
*/
|
|
68
|
+
readonly onMediaLoadEnd?: (() => void) | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Optional override for the tile's surface colour, forwarded to the
|
|
71
|
+
* underlying `FileView` or `MediaView`. Only meaningful when
|
|
72
|
+
* `skipContainerStyles` is true and the consumer (e.g.
|
|
73
|
+
* `FormatFileThumbnail`) is wrapping this content directly.
|
|
74
|
+
*/
|
|
75
|
+
readonly surfaceColor?: (string) | undefined;
|
|
76
|
+
}
|
|
77
|
+
export declare function FormatFileContent({ accessibilityLabel, file, showOverlay, styleInGrid, onUploadComplete, isMedia, skipContainerStyles, onMediaLoadEnd, surfaceColor, }: FormatFileContentProps): React.JSX.Element;
|
|
78
|
+
export declare function FormatFile<T extends File | FileUpload>({ file, accessibilityLabel, accessibilityHint, onTap, onRemove, bottomSheetOptionsSuffix, styleInGrid, testID, showFileTypeIndicator, createThumbnail, onPreviewPress, }: FormatFileProps<T>): React.JSX.Element;
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { createRef, useCallback, useMemo, useState } from "react";
|
|
3
|
+
import { TouchableOpacity, View } from "react-native";
|
|
4
|
+
import { useStyles } from "./FormatFile.style.js";
|
|
5
|
+
import { MediaView } from "./components/MediaView/index.js";
|
|
6
|
+
import { FormatFileBottomSheet } from "./components/FormatFileBottomSheet/index.js";
|
|
7
|
+
import { FileView } from "./components/FileView/index.js";
|
|
8
|
+
import { StatusCode } from "./types.js";
|
|
9
|
+
import { FormatFileContext } from "./context/FormatFileContext.js";
|
|
10
|
+
import { createUseCreateThumbnail, emptyThumbnail } from "./utils/createUseCreateThumbnail.js";
|
|
11
|
+
import { parseFile } from "./utils/parseFile.js";
|
|
12
|
+
import { useComponentMessages } from "../foundationMessages.js";
|
|
13
|
+
export function FormatFileContent({ accessibilityLabel, file, showOverlay, styleInGrid, onUploadComplete, isMedia, skipContainerStyles = false, onMediaLoadEnd, surfaceColor, }) {
|
|
14
|
+
const styles = useStyles();
|
|
15
|
+
const content = isMedia ? (_jsx(MediaView, { accessibilityLabel: accessibilityLabel, file: file, showOverlay: showOverlay, showError: file.error, styleInGrid: styleInGrid, onUploadComplete: onUploadComplete, onLoadEnd: onMediaLoadEnd, surfaceColor: surfaceColor })) : (_jsx(FileView, { accessibilityLabel: accessibilityLabel, file: file, showOverlay: showOverlay, showError: file.error, styleInGrid: styleInGrid, onUploadComplete: onUploadComplete, surfaceColor: surfaceColor }));
|
|
16
|
+
if (skipContainerStyles) {
|
|
17
|
+
return content;
|
|
18
|
+
}
|
|
19
|
+
return (_jsx(View, { style: [
|
|
20
|
+
styles.thumbnailContainer,
|
|
21
|
+
styleInGrid && styles.thumbnailContainerGrid,
|
|
22
|
+
], children: content }));
|
|
23
|
+
}
|
|
24
|
+
const FormatFileInternalMemoized = React.memo(FormatFileInternal);
|
|
25
|
+
export function FormatFile({ file, accessibilityLabel, accessibilityHint, onTap, onRemove, bottomSheetOptionsSuffix, styleInGrid = false, testID, showFileTypeIndicator = true, createThumbnail, onPreviewPress, }) {
|
|
26
|
+
const onTapModified = onTap ? () => onTap(file) : () => undefined;
|
|
27
|
+
const formattedFile = useMemo(() => parseFile(file, showFileTypeIndicator), [file, showFileTypeIndicator]);
|
|
28
|
+
return (_jsx(FormatFileInternalMemoized, { file: formattedFile, accessibilityLabel: accessibilityLabel, accessibilityHint: accessibilityHint, onTap: onTapModified, onRemove: onRemove, bottomSheetOptionsSuffix: bottomSheetOptionsSuffix, styleInGrid: styleInGrid, testID: testID, createThumbnail: createThumbnail, onPreviewPress: onPreviewPress }));
|
|
29
|
+
}
|
|
30
|
+
function FormatFileInternal({ file, accessibilityLabel, accessibilityHint, onTap, onRemove, bottomSheetOptionsSuffix, styleInGrid = false, onPreviewPress, testID, createThumbnail: createThumbnailProp, }) {
|
|
31
|
+
const [showOverlay, setShowOverlay] = useState(file.status !== StatusCode.Completed);
|
|
32
|
+
const { t } = useComponentMessages();
|
|
33
|
+
const bottomSheetRef = createRef();
|
|
34
|
+
const handlePreviewPress = useCallback(() => {
|
|
35
|
+
onPreviewPress?.(file);
|
|
36
|
+
}, [file, onPreviewPress]);
|
|
37
|
+
const createThumbnail = createThumbnailProp ?? emptyThumbnail;
|
|
38
|
+
const { useCreateThumbnail } = createUseCreateThumbnail(createThumbnail);
|
|
39
|
+
return (_jsx(FormatFileContext.Provider, { value: { useCreateThumbnail }, children: _jsxs(View, { children: [_jsx(TouchableOpacity, { accessibilityRole: "imagebutton", accessibilityHint: accessibilityHint ?? t("FormatFile.hint"), onPress: handleOnPress, testID: testID, children: _jsx(FormatFileContent, { accessibilityLabel: accessibilityLabel, file: file, onUploadComplete: () => setShowOverlay(false), isMedia: !!file.isMedia, styleInGrid: styleInGrid, showOverlay: showOverlay }) }), _jsx(FormatFileBottomSheet, { bottomSheetRef: bottomSheetRef, onRemovePress: onRemove, bottomSheetOptionsSuffix: bottomSheetOptionsSuffix, onPreviewPress: file.showPreview ? handlePreviewPress : undefined })] }) }));
|
|
40
|
+
function handleOnPress() {
|
|
41
|
+
if (showOverlay || !onRemove) {
|
|
42
|
+
onTap();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
bottomSheetRef.current?.open();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const useStyles: () => {
|
|
2
|
+
thumbnailContainer: {
|
|
3
|
+
backgroundColor: string;
|
|
4
|
+
borderWidth: number;
|
|
5
|
+
borderColor: string;
|
|
6
|
+
borderRadius: number;
|
|
7
|
+
marginBottom: number;
|
|
8
|
+
overflow: "hidden";
|
|
9
|
+
};
|
|
10
|
+
thumbnailContainerGrid: {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
marginRight: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { buildThemedStyles } from "../compatTheme.js";
|
|
2
|
+
export const useStyles = buildThemedStyles(tokens => {
|
|
3
|
+
return {
|
|
4
|
+
thumbnailContainer: {
|
|
5
|
+
backgroundColor: tokens["color-surface--background"],
|
|
6
|
+
borderWidth: tokens["border-base"],
|
|
7
|
+
borderColor: tokens["color-border"],
|
|
8
|
+
borderRadius: tokens["radius-base"],
|
|
9
|
+
marginBottom: tokens["space-small"],
|
|
10
|
+
// This is to prevent the image from overflowing the container's border radius, otherwise it can "bleed" out the corners
|
|
11
|
+
overflow: "hidden",
|
|
12
|
+
},
|
|
13
|
+
thumbnailContainerGrid: {
|
|
14
|
+
width: tokens["space-extravagant"],
|
|
15
|
+
height: tokens["space-extravagant"],
|
|
16
|
+
marginRight: tokens["space-small"],
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
});
|