@zj-dynamics/components-native 0.0.0-stage → 0.2.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 +20 -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,75 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useCallback, useImperativeHandle, useRef } from "react";
|
|
3
|
+
import { Keyboard, Platform, View } from "react-native";
|
|
4
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
|
+
import { FullWindowOverlay } from "react-native-screens";
|
|
6
|
+
import { BottomSheetBackdrop, BottomSheetModal, BottomSheetView, } from "@gorhom/bottom-sheet";
|
|
7
|
+
import { tokens } from "@zj-dynamics/design/native";
|
|
8
|
+
import { useStyles } from "./BottomSheet.style.js";
|
|
9
|
+
import { BottomSheetOption } from "./components/BottomSheetOption/index.js";
|
|
10
|
+
import { useBottomSheetBackHandler } from "./hooks/useBottomSheetBackHandler.js";
|
|
11
|
+
import { ThemeSnapshot, useThemeScope } from "../../theme.js";
|
|
12
|
+
import { Divider } from "../../Divider.js";
|
|
13
|
+
import { Heading } from "../Heading/index.js";
|
|
14
|
+
import { useIsScreenReaderEnabled } from "../../useIsScreenReaderEnabled.js";
|
|
15
|
+
import { useComponentMessages } from "../foundationMessages.js";
|
|
16
|
+
// eslint-disable-next-line max-statements
|
|
17
|
+
export function BottomSheet({ children, showCancel, loading = false, heading, onOpen, onClose, ref, }) {
|
|
18
|
+
const styles = useStyles();
|
|
19
|
+
const theme = useThemeScope();
|
|
20
|
+
const isScreenReaderEnabled = useIsScreenReaderEnabled();
|
|
21
|
+
const cancellable = (showCancel && !loading) || isScreenReaderEnabled;
|
|
22
|
+
const { t } = useComponentMessages();
|
|
23
|
+
const insets = useSafeAreaInsets();
|
|
24
|
+
const previousIndexRef = useRef(-1);
|
|
25
|
+
const bottomSheetRef = useRef(null);
|
|
26
|
+
const { handleSheetPositionChange } = useBottomSheetBackHandler(bottomSheetRef);
|
|
27
|
+
useImperativeHandle(ref, () => ({
|
|
28
|
+
open: () => {
|
|
29
|
+
dismissKeyboard();
|
|
30
|
+
bottomSheetRef.current?.present();
|
|
31
|
+
},
|
|
32
|
+
close: () => {
|
|
33
|
+
close();
|
|
34
|
+
},
|
|
35
|
+
}));
|
|
36
|
+
const close = useCallback(() => {
|
|
37
|
+
bottomSheetRef.current?.dismiss();
|
|
38
|
+
}, []);
|
|
39
|
+
const handleChange = (index) => {
|
|
40
|
+
// Handle Android back button
|
|
41
|
+
handleSheetPositionChange(index);
|
|
42
|
+
const previousIndex = previousIndexRef.current;
|
|
43
|
+
if (previousIndex === -1 && index >= 0) {
|
|
44
|
+
onOpen?.();
|
|
45
|
+
}
|
|
46
|
+
previousIndexRef.current = index;
|
|
47
|
+
};
|
|
48
|
+
return (_jsx(BottomSheetModal, { ref: bottomSheetRef, accessible: false, backdropComponent: Backdrop, ...(Platform.OS === "ios" && { containerComponent: Container }), backgroundStyle: styles.background, enablePanDownToClose: true, onChange: handleChange, onDismiss: () => {
|
|
49
|
+
previousIndexRef.current = -1;
|
|
50
|
+
handleSheetPositionChange(-1);
|
|
51
|
+
dismissKeyboard();
|
|
52
|
+
onClose?.();
|
|
53
|
+
}, keyboardBlurBehavior: "restore", handleStyle: styles.handle, children: _jsx(ThemeSnapshot, { value: theme, children: _jsxs(BottomSheetView, { style: {
|
|
54
|
+
paddingBottom: insets.bottom + tokens["space-small"],
|
|
55
|
+
paddingTop: tokens["space-small"],
|
|
56
|
+
}, children: [heading && _jsx(Header, { heading: heading, styles: styles }), children, cancellable && (_jsx(Footer, { styles: styles, close: close, cancelLabel: t("cancel") }))] }) }) }));
|
|
57
|
+
}
|
|
58
|
+
function Header({ heading, styles, }) {
|
|
59
|
+
return (_jsx(View, { style: styles.header, children: _jsx(Heading, { level: "subtitle", children: heading }) }));
|
|
60
|
+
}
|
|
61
|
+
function Footer({ styles, close, cancelLabel, }) {
|
|
62
|
+
return (_jsxs(View, { children: [_jsx(View, { style: styles.footerDivider, children: _jsx(Divider, {}) }), _jsx(BottomSheetOption, { text: cancelLabel, icon: "cross", onPress: close })] }));
|
|
63
|
+
}
|
|
64
|
+
function dismissKeyboard() {
|
|
65
|
+
//Dismisses the keyboard before opening the bottom sheet.
|
|
66
|
+
//In the case where an input text field is focused we don't want to show the bottom sheet behind or above keyboard
|
|
67
|
+
Keyboard.dismiss();
|
|
68
|
+
}
|
|
69
|
+
function Backdrop(bottomSheetBackdropProps) {
|
|
70
|
+
const styles = useStyles();
|
|
71
|
+
return (_jsx(BottomSheetBackdrop, { ...bottomSheetBackdropProps, appearsOnIndex: 0, disappearsOnIndex: -1, style: styles.backdrop, opacity: 1 }));
|
|
72
|
+
}
|
|
73
|
+
function Container({ children }) {
|
|
74
|
+
return _jsx(FullWindowOverlay, { children: children });
|
|
75
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const useStyles: () => {
|
|
2
|
+
backdrop: {
|
|
3
|
+
backgroundColor: string;
|
|
4
|
+
};
|
|
5
|
+
background: {
|
|
6
|
+
borderTopLeftRadius: number;
|
|
7
|
+
borderTopRightRadius: number;
|
|
8
|
+
backgroundColor: string;
|
|
9
|
+
};
|
|
10
|
+
footerContainer: {
|
|
11
|
+
backgroundColor: string;
|
|
12
|
+
};
|
|
13
|
+
header: {
|
|
14
|
+
paddingHorizontal: number;
|
|
15
|
+
paddingTop: number;
|
|
16
|
+
paddingBottom: number;
|
|
17
|
+
};
|
|
18
|
+
footerDivider: {
|
|
19
|
+
marginHorizontal: number;
|
|
20
|
+
marginTop: number;
|
|
21
|
+
marginBottom: number;
|
|
22
|
+
};
|
|
23
|
+
handle: {
|
|
24
|
+
display: "none";
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { buildThemedStyles } from "../compatTheme.js";
|
|
2
|
+
export const useStyles = buildThemedStyles(tokens => {
|
|
3
|
+
const modalBorderRadius = tokens["radius-larger"];
|
|
4
|
+
return {
|
|
5
|
+
backdrop: {
|
|
6
|
+
backgroundColor: tokens["color-overlay"],
|
|
7
|
+
},
|
|
8
|
+
background: {
|
|
9
|
+
borderTopLeftRadius: modalBorderRadius,
|
|
10
|
+
borderTopRightRadius: modalBorderRadius,
|
|
11
|
+
backgroundColor: tokens["color-surface"],
|
|
12
|
+
},
|
|
13
|
+
footerContainer: {
|
|
14
|
+
backgroundColor: tokens["color-surface"],
|
|
15
|
+
},
|
|
16
|
+
header: {
|
|
17
|
+
paddingHorizontal: tokens["space-base"],
|
|
18
|
+
paddingTop: tokens["space-small"],
|
|
19
|
+
paddingBottom: tokens["space-base"],
|
|
20
|
+
},
|
|
21
|
+
footerDivider: {
|
|
22
|
+
marginHorizontal: tokens["space-base"],
|
|
23
|
+
marginTop: tokens["space-small"],
|
|
24
|
+
marginBottom: tokens["space-smaller"],
|
|
25
|
+
},
|
|
26
|
+
handle: {
|
|
27
|
+
display: "none",
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { IconColorNames, IconNames } from "@zj-dynamics/design/native";
|
|
3
|
+
import type { TextAlign } from "../../../Typography/index.js";
|
|
4
|
+
export interface BottomSheetOptionProps {
|
|
5
|
+
readonly text: string;
|
|
6
|
+
readonly icon?: IconNames;
|
|
7
|
+
readonly iconColor?: IconColorNames;
|
|
8
|
+
readonly textAlign?: TextAlign;
|
|
9
|
+
readonly destructive?: boolean;
|
|
10
|
+
readonly textTransform?: "none" | "capitalize";
|
|
11
|
+
readonly onPress: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function BottomSheetOption({ text, icon, iconColor, textAlign, destructive, textTransform, onPress, }: BottomSheetOptionProps): React.JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { TouchableOpacity, View } from "react-native";
|
|
4
|
+
import { useStyles } from "./BottomSheetOption.styles.js";
|
|
5
|
+
import { capitalize } from "../../../capitalize.js";
|
|
6
|
+
import { Text } from "../../../Text/index.js";
|
|
7
|
+
import { Icon } from "../../../../Icon.js";
|
|
8
|
+
export function BottomSheetOption({ text, icon, iconColor, textAlign, destructive, textTransform = "capitalize", onPress, }) {
|
|
9
|
+
const destructiveColor = "destructive";
|
|
10
|
+
const iconTone = destructive ? destructiveColor : iconColor;
|
|
11
|
+
const textVariation = destructive ? destructiveColor : "subdued";
|
|
12
|
+
const styles = useStyles();
|
|
13
|
+
return (_jsxs(TouchableOpacity, { style: styles.bottomSheetOption, onPress: onPress, accessibilityLabel: text, children: [icon && (_jsx(View, { style: styles.icon, children: _jsx(Icon, { name: icon, ...(iconTone !== undefined && { color: iconTone }) }) })), _jsx(View, { style: styles.title, children: _jsx(Text, { variation: textVariation, emphasis: "strong", ...(textAlign !== undefined && { align: textAlign }), children: textTransform === "capitalize"
|
|
14
|
+
? capitalize(text.toLocaleLowerCase())
|
|
15
|
+
: text }) })] }));
|
|
16
|
+
}
|
package/dist/foundationText/BottomSheet/components/BottomSheetOption/BottomSheetOption.styles.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const useStyles: () => {
|
|
2
|
+
bottomSheetOption: {
|
|
3
|
+
display: "flex";
|
|
4
|
+
flexDirection: "row";
|
|
5
|
+
alignContent: "center";
|
|
6
|
+
alignItems: "center";
|
|
7
|
+
padding: number;
|
|
8
|
+
};
|
|
9
|
+
icon: {
|
|
10
|
+
paddingHorizontal: number;
|
|
11
|
+
};
|
|
12
|
+
title: {
|
|
13
|
+
paddingHorizontal: number;
|
|
14
|
+
flexShrink: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
package/dist/foundationText/BottomSheet/components/BottomSheetOption/BottomSheetOption.styles.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { buildThemedStyles } from "../../../compatTheme.js";
|
|
2
|
+
export const useStyles = buildThemedStyles(tokens => {
|
|
3
|
+
return {
|
|
4
|
+
bottomSheetOption: {
|
|
5
|
+
display: "flex",
|
|
6
|
+
flexDirection: "row",
|
|
7
|
+
alignContent: "center",
|
|
8
|
+
alignItems: "center",
|
|
9
|
+
padding: tokens["space-small"],
|
|
10
|
+
},
|
|
11
|
+
icon: {
|
|
12
|
+
paddingHorizontal: tokens["space-small"],
|
|
13
|
+
},
|
|
14
|
+
title: {
|
|
15
|
+
paddingHorizontal: tokens["space-small"],
|
|
16
|
+
flexShrink: 1,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BottomSheetOption } from "./BottomSheetOption.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BottomSheetModal } from "@gorhom/bottom-sheet";
|
|
2
|
+
/**
|
|
3
|
+
* Hook that dismisses the bottom sheet modal on the hardware back button press if it is visible
|
|
4
|
+
* @param bottomSheetRef ref to the bottom sheet component
|
|
5
|
+
*/
|
|
6
|
+
export declare function useBottomSheetBackHandler(bottomSheetRef: React.RefObject<BottomSheetModal | null>): {
|
|
7
|
+
handleSheetPositionChange: (index: number) => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
2
|
+
import { BackHandler } from "react-native";
|
|
3
|
+
/**
|
|
4
|
+
* Hook that dismisses the bottom sheet modal on the hardware back button press if it is visible
|
|
5
|
+
* @param bottomSheetRef ref to the bottom sheet component
|
|
6
|
+
*/
|
|
7
|
+
export function useBottomSheetBackHandler(bottomSheetRef) {
|
|
8
|
+
const backHandlerSubscriptionRef = useRef(null);
|
|
9
|
+
const handleSheetPositionChange = useCallback((index) => {
|
|
10
|
+
const isBottomSheetVisible = index >= 0;
|
|
11
|
+
if (isBottomSheetVisible && !backHandlerSubscriptionRef.current) {
|
|
12
|
+
// Setup the back handler if the bottom sheet is right in front of the user
|
|
13
|
+
backHandlerSubscriptionRef.current = BackHandler.addEventListener("hardwareBackPress", () => {
|
|
14
|
+
bottomSheetRef.current?.dismiss();
|
|
15
|
+
return true;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
else if (!isBottomSheetVisible) {
|
|
19
|
+
backHandlerSubscriptionRef.current?.remove();
|
|
20
|
+
backHandlerSubscriptionRef.current = null;
|
|
21
|
+
}
|
|
22
|
+
}, [bottomSheetRef]);
|
|
23
|
+
useEffect(() => () => handleSheetPositionChange(-1), [handleSheetPositionChange]);
|
|
24
|
+
return { handleSheetPositionChange };
|
|
25
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ButtonGroupActionElement } from "./types.js";
|
|
3
|
+
export interface ButtonGroupProps {
|
|
4
|
+
readonly children: ButtonGroupActionElement | ButtonGroupActionElement[];
|
|
5
|
+
/**
|
|
6
|
+
* Display a cancel button in the secondary bottom sheet footer.
|
|
7
|
+
*/
|
|
8
|
+
readonly showCancelInBottomSheet?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* An optional heading to display in the secondary bottom sheet header.
|
|
11
|
+
*/
|
|
12
|
+
readonly bottomSheetHeading?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Callback that is called when the secondary actions bottom sheet is opened.
|
|
15
|
+
*/
|
|
16
|
+
readonly onOpenBottomSheet?: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Callback that is called when the secondary actions bottom sheet is closed.
|
|
19
|
+
*/
|
|
20
|
+
readonly onCloseBottomSheet?: () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Allows you to Tap the button while offline
|
|
23
|
+
*/
|
|
24
|
+
readonly allowTapWhenOffline?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function ButtonGroup({ children, showCancelInBottomSheet, bottomSheetHeading, onOpenBottomSheet, onCloseBottomSheet, allowTapWhenOffline, }: ButtonGroupProps): React.JSX.Element;
|
|
27
|
+
export declare namespace ButtonGroup {
|
|
28
|
+
var PrimaryAction: typeof import("./ButtonGroupAction.js").PrimaryAction;
|
|
29
|
+
var SecondaryAction: typeof import("./ButtonGroupAction.js").SecondaryAction;
|
|
30
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useRef } from "react";
|
|
3
|
+
import { View } from "react-native";
|
|
4
|
+
import { PrimaryAction, SecondaryAction } from "./ButtonGroupAction.js";
|
|
5
|
+
import { useStyles } from "./ButtonGroup.style.js";
|
|
6
|
+
import { SecondaryActionSheet } from "./components/SecondaryActionSheet/index.js";
|
|
7
|
+
import { getActions, usePreventTapWhenOffline } from "./utils.js";
|
|
8
|
+
import { Button } from "../../Button.js";
|
|
9
|
+
import { useComponentMessages } from "../foundationMessages.js";
|
|
10
|
+
export function ButtonGroup({ children, showCancelInBottomSheet, bottomSheetHeading, onOpenBottomSheet, onCloseBottomSheet, allowTapWhenOffline = false, }) {
|
|
11
|
+
const { t } = useComponentMessages();
|
|
12
|
+
const { handlePress } = usePreventTapWhenOffline();
|
|
13
|
+
const secondaryActionsRef = useRef(null);
|
|
14
|
+
const { primaryActions, secondaryActions } = getActions(children);
|
|
15
|
+
const styles = useStyles();
|
|
16
|
+
return (_jsxs(View, { style: styles.buttonGroup, children: [primaryActions.map((action, index) => {
|
|
17
|
+
const { label, onPress, buttonType, buttonVariation, icon, customButton, loading, } = action.props;
|
|
18
|
+
return (_jsx(View, { style: styles.button, children: customButton || (_jsx(Button, { label: label, accessibilityLabel: label, onPress: allowTapWhenOffline ? onPress : handlePress(onPress), ...(buttonType !== undefined && { type: buttonType }), ...(buttonVariation !== undefined && { variation: buttonVariation }), fullHeight: true, ...(icon !== undefined && { icon: icon }), ...(loading !== undefined && { loading: loading }), testID: `ButtonGroup-Primary-Action-${index}` })) }, index));
|
|
19
|
+
}), secondaryActions.length > 0 && (_jsx(View, { style: styles.moreButton, children: _jsx(Button, { type: "secondary", icon: "more", accessibilityLabel: t("more"), onPress: handlePress(openBottomSheet), fullHeight: true, testID: "ButtonGroup-Secondary-Action" }) })), _jsx(SecondaryActionSheet, { ...(bottomSheetHeading !== undefined && { heading: bottomSheetHeading }), ...(showCancelInBottomSheet !== undefined && { showCancel: showCancelInBottomSheet }), secondaryActionsRef: secondaryActionsRef, actions: secondaryActions.map(secondaryAction => secondaryAction.props), ...(onOpenBottomSheet !== undefined && { onOpenBottomSheet: onOpenBottomSheet }), ...(onCloseBottomSheet !== undefined && { onCloseBottomSheet: onCloseBottomSheet }) })] }));
|
|
20
|
+
function openBottomSheet() {
|
|
21
|
+
secondaryActionsRef.current?.open();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
ButtonGroup.PrimaryAction = PrimaryAction;
|
|
25
|
+
ButtonGroup.SecondaryAction = SecondaryAction;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const useStyles: () => {
|
|
2
|
+
buttonGroup: {
|
|
3
|
+
width: "100%";
|
|
4
|
+
flexDirection: "row";
|
|
5
|
+
justifyContent: "flex-end";
|
|
6
|
+
gap: number;
|
|
7
|
+
};
|
|
8
|
+
button: {
|
|
9
|
+
flexBasis: number;
|
|
10
|
+
flexGrow: number;
|
|
11
|
+
};
|
|
12
|
+
moreButton: {
|
|
13
|
+
flexBasis: number;
|
|
14
|
+
flexGrow: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { buildThemedStyles } from "../compatTheme.js";
|
|
2
|
+
export const useStyles = buildThemedStyles(tokens => {
|
|
3
|
+
return {
|
|
4
|
+
buttonGroup: {
|
|
5
|
+
width: "100%",
|
|
6
|
+
flexDirection: "row",
|
|
7
|
+
justifyContent: "flex-end",
|
|
8
|
+
gap: tokens["space-small"],
|
|
9
|
+
},
|
|
10
|
+
button: {
|
|
11
|
+
flexBasis: tokens["space-largest"],
|
|
12
|
+
flexGrow: 1,
|
|
13
|
+
},
|
|
14
|
+
moreButton: {
|
|
15
|
+
flexBasis: tokens["space-largest"],
|
|
16
|
+
flexGrow: 0,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { IconColorNames, IconNames } from "@zj-dynamics/design/native";
|
|
2
|
+
import React, { type ReactElement } from "react";
|
|
3
|
+
import type { ButtonProps } from "../../Button.js";
|
|
4
|
+
export interface ButtonGroupActionProps {
|
|
5
|
+
/**
|
|
6
|
+
* Text to be displayed on the action button
|
|
7
|
+
*/
|
|
8
|
+
label: string;
|
|
9
|
+
/**
|
|
10
|
+
* Icon to be displayed on the action button
|
|
11
|
+
*/
|
|
12
|
+
icon?: IconNames;
|
|
13
|
+
/**
|
|
14
|
+
* Determines the color of the icon. If not specified, some icons have a default system colour which will be used
|
|
15
|
+
* Others that don't have a system colour fall back to greyBlue.
|
|
16
|
+
* Only applies the iconColor to ButtonGroup.PrimaryAction when it is rendered under the "more" menu.
|
|
17
|
+
*/
|
|
18
|
+
iconColor?: IconColorNames;
|
|
19
|
+
/**
|
|
20
|
+
* Press handler for the action button
|
|
21
|
+
*/
|
|
22
|
+
onPress: () => void;
|
|
23
|
+
loading?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface ButtonGroupSecondaryActionProps extends ButtonGroupActionProps {
|
|
26
|
+
/**
|
|
27
|
+
* Indicates whether the secondary action is destructive in nature.
|
|
28
|
+
*/
|
|
29
|
+
destructive?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface ButtonGroupPrimaryActionProps extends ButtonGroupActionProps {
|
|
32
|
+
/**
|
|
33
|
+
* Sets the action button style (default: "primary")
|
|
34
|
+
*/
|
|
35
|
+
buttonType?: NonNullable<ButtonProps["type"]>;
|
|
36
|
+
/**
|
|
37
|
+
* Themes the action button to the type of action it performs (default: "work")
|
|
38
|
+
*/
|
|
39
|
+
buttonVariation?: NonNullable<ButtonProps["variation"]>;
|
|
40
|
+
/**
|
|
41
|
+
* Optional custom button that can be rendered in place of the primary action button
|
|
42
|
+
*/
|
|
43
|
+
customButton?: ReactElement;
|
|
44
|
+
loading?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export declare function PrimaryAction(_: ButtonGroupPrimaryActionProps): React.JSX.Element;
|
|
47
|
+
export declare function SecondaryAction(_: ButtonGroupSecondaryActionProps): React.JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, {} from "react";
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4
|
+
export function PrimaryAction(_) {
|
|
5
|
+
return _jsx(_Fragment, {});
|
|
6
|
+
}
|
|
7
|
+
export function SecondaryAction(
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9
|
+
_) {
|
|
10
|
+
return _jsx(_Fragment, {});
|
|
11
|
+
}
|
package/dist/foundationText/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import type { ButtonGroupSecondaryActionProps } from "../../types.js";
|
|
4
|
+
import type { BottomSheetRef } from "../../../BottomSheet/BottomSheet.js";
|
|
5
|
+
interface SecondaryActionSheetProps {
|
|
6
|
+
readonly actions: ButtonGroupSecondaryActionProps[];
|
|
7
|
+
readonly secondaryActionsRef: RefObject<BottomSheetRef | null>;
|
|
8
|
+
readonly showCancel?: boolean;
|
|
9
|
+
readonly heading?: string;
|
|
10
|
+
readonly onOpenBottomSheet?: () => void;
|
|
11
|
+
readonly onCloseBottomSheet?: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function SecondaryActionSheet({ actions, secondaryActionsRef, heading, showCancel, onOpenBottomSheet, onCloseBottomSheet, }: SecondaryActionSheetProps): React.JSX.Element;
|
|
14
|
+
export {};
|
package/dist/foundationText/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createElement as _createElement } from "react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { View } from "react-native";
|
|
5
|
+
import { BottomSheetOption } from "../../../BottomSheet/components/BottomSheetOption/index.js";
|
|
6
|
+
import { BottomSheet } from "../../../BottomSheet/BottomSheet.js";
|
|
7
|
+
export function SecondaryActionSheet({ actions, secondaryActionsRef, heading, showCancel, onOpenBottomSheet, onCloseBottomSheet, }) {
|
|
8
|
+
return (_jsx(BottomSheet, { ...(heading !== undefined && { heading: heading }), ...(showCancel !== undefined && { showCancel: showCancel }), ref: secondaryActionsRef, ...(onOpenBottomSheet !== undefined && { onOpen: onOpenBottomSheet }), ...(onCloseBottomSheet !== undefined && { onClose: onCloseBottomSheet }), children: _jsx(View, { children: actions.map((action, index) => {
|
|
9
|
+
const { label, onPress, icon, iconColor, destructive } = action;
|
|
10
|
+
return (_createElement(BottomSheetOption, { ...(destructive !== undefined && { destructive: destructive }), key: index, text: label, onPress: () => {
|
|
11
|
+
secondaryActionsRef?.current?.close();
|
|
12
|
+
onPress();
|
|
13
|
+
}, ...(icon !== undefined && { icon: icon }), ...(iconColor !== undefined && { iconColor: iconColor }) }));
|
|
14
|
+
}) }) }));
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SecondaryActionSheet } from "./SecondaryActionSheet.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SecondaryActionSheet } from "./SecondaryActionSheet.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { ButtonGroupActionProps, ButtonGroupPrimaryActionProps, ButtonGroupSecondaryActionProps, PrimaryAction, SecondaryAction } from "./ButtonGroupAction.js";
|
|
3
|
+
export type ButtonGroupPrimaryActionElement = ReactElement<ButtonGroupPrimaryActionProps, typeof PrimaryAction>;
|
|
4
|
+
export type ButtonGroupSecondaryActionElement = ReactElement<ButtonGroupActionProps, typeof SecondaryAction>;
|
|
5
|
+
export type ButtonGroupActionElement = ButtonGroupPrimaryActionElement | ButtonGroupSecondaryActionElement;
|
|
6
|
+
export type BottomSheetTextTransform = "capitalize" | "none";
|
|
7
|
+
export type { ButtonGroupActionProps, ButtonGroupPrimaryActionProps, ButtonGroupSecondaryActionProps, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ButtonGroupActionElement, ButtonGroupPrimaryActionElement } from "./types.js";
|
|
2
|
+
import type { ButtonGroupActionProps } from "./ButtonGroupAction.js";
|
|
3
|
+
interface UsePreventTapWhenOfflineShape {
|
|
4
|
+
readonly handlePress: (callback: ButtonGroupActionProps["onPress"]) => () => void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Determine if the onPress should be fired or an alert when the device is
|
|
8
|
+
* online or offline
|
|
9
|
+
*/
|
|
10
|
+
export declare function usePreventTapWhenOffline(): UsePreventTapWhenOfflineShape;
|
|
11
|
+
interface GetActionShape {
|
|
12
|
+
readonly primaryActions: ButtonGroupPrimaryActionElement[];
|
|
13
|
+
readonly secondaryActions: ButtonGroupActionElement[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Separate the Primary and Secondary actions into 2 const
|
|
17
|
+
*/
|
|
18
|
+
export declare function getActions(children: ButtonGroupActionElement | ButtonGroupActionElement[]): GetActionShape;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import { Alert } from "react-native";
|
|
3
|
+
import { PrimaryAction, SecondaryAction } from "./ButtonGroupAction.js";
|
|
4
|
+
import { useComponentSettings } from "../ComponentSettingsContext/ComponentSettingsContext.js";
|
|
5
|
+
import { useComponentMessages } from "../foundationMessages.js";
|
|
6
|
+
/**
|
|
7
|
+
* Determine if the onPress should be fired or an alert when the device is
|
|
8
|
+
* online or offline
|
|
9
|
+
*/
|
|
10
|
+
export function usePreventTapWhenOffline() {
|
|
11
|
+
const { t } = useComponentMessages();
|
|
12
|
+
const { isOnline } = useComponentSettings();
|
|
13
|
+
const handlePress = useCallback((callback) => {
|
|
14
|
+
if (isOnline)
|
|
15
|
+
return callback;
|
|
16
|
+
return () => Alert.alert(t("networkUnavailableTitle"), t("networkUnavailableDescription"));
|
|
17
|
+
}, [isOnline, t]);
|
|
18
|
+
return { handlePress };
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Separate the Primary and Secondary actions into 2 const
|
|
22
|
+
*/
|
|
23
|
+
export function getActions(children) {
|
|
24
|
+
const childArray = React.Children.toArray(children);
|
|
25
|
+
let primaryActions = childArray.filter(action =>
|
|
26
|
+
/* Checking the component type does not work in dev environments due to
|
|
27
|
+
* wrapper components used for hot-reload
|
|
28
|
+
* However, checking the type name does not work in prod due to code minification
|
|
29
|
+
* Hence 2 different checks here */
|
|
30
|
+
action.type === PrimaryAction || action.type.name === "PrimaryAction");
|
|
31
|
+
let secondaryActions = childArray.filter(action => action.type === SecondaryAction || action.type.name === "SecondaryAction");
|
|
32
|
+
if (primaryActions.length > 2) {
|
|
33
|
+
secondaryActions = primaryActions.slice(2).concat(secondaryActions);
|
|
34
|
+
primaryActions = primaryActions.slice(0, 2);
|
|
35
|
+
}
|
|
36
|
+
if (primaryActions.length === 0) {
|
|
37
|
+
primaryActions = secondaryActions.slice(0, 1);
|
|
38
|
+
secondaryActions = secondaryActions.slice(1);
|
|
39
|
+
}
|
|
40
|
+
return { primaryActions, secondaryActions };
|
|
41
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import type { IconNames } from "@zj-dynamics/design/native";
|
|
4
|
+
import type { XOR } from "ts-xor";
|
|
5
|
+
interface CardProps {
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use <ActionItem /> with the title and onPress properties instead
|
|
8
|
+
*/
|
|
9
|
+
readonly header?: HeaderProps;
|
|
10
|
+
readonly footer?: FooterProps;
|
|
11
|
+
readonly children?: ReactNode;
|
|
12
|
+
readonly reportCardHeight?: (height: number) => void;
|
|
13
|
+
readonly testID?: string;
|
|
14
|
+
readonly error?: string;
|
|
15
|
+
readonly elevation?: elevationProp;
|
|
16
|
+
}
|
|
17
|
+
type elevationProp = "none" | "low" | "base" | "high";
|
|
18
|
+
export type HeaderProps = HeaderCommonProps & HeaderActionProps;
|
|
19
|
+
interface FooterProps {
|
|
20
|
+
readonly onPress: () => void;
|
|
21
|
+
readonly title: string;
|
|
22
|
+
}
|
|
23
|
+
interface HeaderCommonProps {
|
|
24
|
+
readonly title: string;
|
|
25
|
+
}
|
|
26
|
+
type HeaderActionProps = {
|
|
27
|
+
readonly onPress?: never;
|
|
28
|
+
readonly actionItem?: never;
|
|
29
|
+
} | {
|
|
30
|
+
readonly onPress: () => void;
|
|
31
|
+
readonly actionItem: CardAction;
|
|
32
|
+
};
|
|
33
|
+
interface IconAction {
|
|
34
|
+
readonly iconName: IconNames;
|
|
35
|
+
}
|
|
36
|
+
interface ButtonAction {
|
|
37
|
+
readonly label: string;
|
|
38
|
+
}
|
|
39
|
+
export type CardAction = XOR<IconAction, ButtonAction>;
|
|
40
|
+
export declare function Card({ header, footer, children, reportCardHeight: onCardHeightChange, testID, error, elevation, }: CardProps): React.JSX.Element;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Pressable, View } from "react-native";
|
|
4
|
+
import { useStyles } from "./Card.style.js";
|
|
5
|
+
import { InternalCardHeader } from "./components/InternalCardHeader.js";
|
|
6
|
+
import { ErrorMessageWrapper } from "../ErrorMessageWrapper/index.js";
|
|
7
|
+
import { ActionLabel } from "../ActionLabel/index.js";
|
|
8
|
+
import { Typography } from "../Typography/index.js";
|
|
9
|
+
import { Icon } from "../../Icon.js";
|
|
10
|
+
function getElevationStyle(elevation, styles) {
|
|
11
|
+
if (elevation === "none") {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
return styles[`${elevation}Elevation`];
|
|
15
|
+
}
|
|
16
|
+
export function Card({ header, footer, children, reportCardHeight: onCardHeightChange, testID = "card", error, elevation = "none", }) {
|
|
17
|
+
const styles = useStyles();
|
|
18
|
+
return (_jsx(ErrorMessageWrapper, { message: error, wrapFor: "card", children: _jsxs(View, { onLayout: handleLayoutChange, style: [styles.container, getElevationStyle(elevation, styles)], testID: testID, children: [header && (_jsxs(InternalCardHeader, { ...(header.onPress && { onPress: header.onPress }), testID: `${testID}Header`, collapsable: !!children, children: [_jsx(View, { style: styles.headerTitle, children: _jsx(Typography, { color: "heading", fontFamily: "base", fontWeight: "bold", size: "default", lineHeight: "base", accessibilityRole: "header", children: header.title }) }), _jsxs(View, { style: styles.actionItem, children: [!!header.actionItem?.label && (_jsx(View, { style: styles.actionLabel, children: _jsx(ActionLabel, { type: "cardTitle", children: header.actionItem.label }) })), header.actionItem?.iconName && (_jsx(Icon, { name: header.actionItem.iconName, color: "interactive" }))] })] })), children, footer && (_jsx(Pressable, { testID: `${testID}Footer`, onPress: footer.onPress, style: ({ pressed }) => [
|
|
19
|
+
styles.footer,
|
|
20
|
+
pressed && styles.pressed,
|
|
21
|
+
], accessibilityRole: "button", children: _jsx(ActionLabel, { children: footer.title }) }))] }) }));
|
|
22
|
+
function handleLayoutChange(event) {
|
|
23
|
+
const { height } = event.nativeEvent.layout;
|
|
24
|
+
onCardHeightChange?.(height);
|
|
25
|
+
}
|
|
26
|
+
}
|