@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,35 @@
|
|
|
1
|
+
export declare const acceptedExtensions: {
|
|
2
|
+
name: string;
|
|
3
|
+
}[];
|
|
4
|
+
export declare const videoExtensions: {
|
|
5
|
+
type: string;
|
|
6
|
+
}[];
|
|
7
|
+
/**
|
|
8
|
+
* Extensions that should be treated as documents (Word-family + OpenDocument
|
|
9
|
+
* Text + RTF + Apple Pages + WordPerfect). Used to route to the document
|
|
10
|
+
* icon and the "document" file category.
|
|
11
|
+
*/
|
|
12
|
+
export declare const documentExtensions: {
|
|
13
|
+
type: string;
|
|
14
|
+
}[];
|
|
15
|
+
/**
|
|
16
|
+
* Extensions that should be treated as spreadsheets (Excel-family +
|
|
17
|
+
* OpenDocument Spreadsheet + Apple Numbers + CSV). Used to route to the
|
|
18
|
+
* spreadsheet icon and the "spreadsheet" file category.
|
|
19
|
+
*/
|
|
20
|
+
export declare const spreadsheetExtensions: {
|
|
21
|
+
type: string;
|
|
22
|
+
}[];
|
|
23
|
+
/**
|
|
24
|
+
* Substring patterns matched against the `Content-Type` MIME string for
|
|
25
|
+
* documents. Substring rather than exact match because real-world MIMEs
|
|
26
|
+
* vary widely (e.g. `application/msword`,
|
|
27
|
+
* `application/vnd.openxmlformats-officedocument.wordprocessingml.document`,
|
|
28
|
+
* `application/vnd.oasis.opendocument.text`).
|
|
29
|
+
*/
|
|
30
|
+
export declare const documentMimePatterns: string[];
|
|
31
|
+
/**
|
|
32
|
+
* Substring patterns matched against the `Content-Type` MIME string for
|
|
33
|
+
* spreadsheets.
|
|
34
|
+
*/
|
|
35
|
+
export declare const spreadsheetMimePatterns: string[];
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export const acceptedExtensions = [
|
|
2
|
+
{ name: "video" },
|
|
3
|
+
{ name: "pdf" },
|
|
4
|
+
{ name: "mov" },
|
|
5
|
+
{ name: "mp4" },
|
|
6
|
+
{ name: "docx" },
|
|
7
|
+
{ name: "xlsx" },
|
|
8
|
+
];
|
|
9
|
+
export const videoExtensions = [
|
|
10
|
+
{ type: "mov" },
|
|
11
|
+
{ type: "mp4" },
|
|
12
|
+
{ type: "m4v" },
|
|
13
|
+
{ type: "webm" },
|
|
14
|
+
{ type: "mkv" },
|
|
15
|
+
{ type: "avi" },
|
|
16
|
+
{ type: "wmv" },
|
|
17
|
+
{ type: "flv" },
|
|
18
|
+
{ type: "mpg" },
|
|
19
|
+
{ type: "mpeg" },
|
|
20
|
+
{ type: "3gp" },
|
|
21
|
+
{ type: "3gpp" },
|
|
22
|
+
{ type: "hevc" },
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Extensions that should be treated as documents (Word-family + OpenDocument
|
|
26
|
+
* Text + RTF + Apple Pages + WordPerfect). Used to route to the document
|
|
27
|
+
* icon and the "document" file category.
|
|
28
|
+
*/
|
|
29
|
+
export const documentExtensions = [
|
|
30
|
+
{ type: "doc" },
|
|
31
|
+
{ type: "docx" },
|
|
32
|
+
{ type: "odt" },
|
|
33
|
+
{ type: "fodt" },
|
|
34
|
+
{ type: "rtf" },
|
|
35
|
+
{ type: "pages" },
|
|
36
|
+
{ type: "wpd" },
|
|
37
|
+
];
|
|
38
|
+
/**
|
|
39
|
+
* Extensions that should be treated as spreadsheets (Excel-family +
|
|
40
|
+
* OpenDocument Spreadsheet + Apple Numbers + CSV). Used to route to the
|
|
41
|
+
* spreadsheet icon and the "spreadsheet" file category.
|
|
42
|
+
*/
|
|
43
|
+
export const spreadsheetExtensions = [
|
|
44
|
+
{ type: "xls" },
|
|
45
|
+
{ type: "xlsx" },
|
|
46
|
+
{ type: "ods" },
|
|
47
|
+
{ type: "fods" },
|
|
48
|
+
{ type: "numbers" },
|
|
49
|
+
{ type: "csv" },
|
|
50
|
+
];
|
|
51
|
+
/**
|
|
52
|
+
* Substring patterns matched against the `Content-Type` MIME string for
|
|
53
|
+
* documents. Substring rather than exact match because real-world MIMEs
|
|
54
|
+
* vary widely (e.g. `application/msword`,
|
|
55
|
+
* `application/vnd.openxmlformats-officedocument.wordprocessingml.document`,
|
|
56
|
+
* `application/vnd.oasis.opendocument.text`).
|
|
57
|
+
*/
|
|
58
|
+
export const documentMimePatterns = [
|
|
59
|
+
"msword",
|
|
60
|
+
"ms-word",
|
|
61
|
+
"wordprocessingml",
|
|
62
|
+
"opendocument.text",
|
|
63
|
+
"rtf",
|
|
64
|
+
];
|
|
65
|
+
/**
|
|
66
|
+
* Substring patterns matched against the `Content-Type` MIME string for
|
|
67
|
+
* spreadsheets.
|
|
68
|
+
*/
|
|
69
|
+
export const spreadsheetMimePatterns = [
|
|
70
|
+
"ms-excel",
|
|
71
|
+
"spreadsheetml",
|
|
72
|
+
"opendocument.spreadsheet",
|
|
73
|
+
"csv",
|
|
74
|
+
];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FormatFileContextProps } from "./types.js";
|
|
2
|
+
export declare const formatFileContextDefaultValues: {
|
|
3
|
+
useCreateThumbnail: () => {
|
|
4
|
+
thumbnail: undefined;
|
|
5
|
+
error: boolean;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare const FormatFileContext: import("react").Context<FormatFileContextProps>;
|
|
9
|
+
export declare function useFormatFileContext(): FormatFileContextProps;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
export const formatFileContextDefaultValues = {
|
|
3
|
+
useCreateThumbnail: () => ({ thumbnail: undefined, error: false }),
|
|
4
|
+
};
|
|
5
|
+
export const FormatFileContext = createContext(formatFileContextDefaultValues);
|
|
6
|
+
export function useFormatFileContext() {
|
|
7
|
+
return useContext(FormatFileContext);
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FormattedFile } from "../types.js";
|
|
2
|
+
export interface UseCreateThumbnailResponse {
|
|
3
|
+
readonly thumbnail: string | undefined;
|
|
4
|
+
readonly error: boolean;
|
|
5
|
+
}
|
|
6
|
+
export type UseCreateThumbnail = (formattedFile: FormattedFile) => UseCreateThumbnailResponse;
|
|
7
|
+
export interface FormatFileContextProps {
|
|
8
|
+
useCreateThumbnail: UseCreateThumbnail;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { FormatFileProps } from "./FormatFile.js";
|
|
2
|
+
export { FormatFile } from "./FormatFile.js";
|
|
3
|
+
export type { FormatFileThumbnailProps } from "./FormatFileThumbnail.js";
|
|
4
|
+
export { FormatFileThumbnail } from "./FormatFileThumbnail.js";
|
|
5
|
+
export { getFileCategory, mapFileTypeToIconName, sanitizeFileName, truncateFileNameForLine, } from "./utils/index.js";
|
|
6
|
+
export type { FileCategory } from "./utils/index.js";
|
|
7
|
+
export type { FormattedFile, File, CreateThumbnail, CreateThumbnailResponse, FileUpload, StatusCode, } from "./types.js";
|
|
8
|
+
export type { UseCreateThumbnail, UseCreateThumbnailResponse, } from "./context/types.js";
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
export declare enum StatusCode {
|
|
2
|
+
Pending = 0,
|
|
3
|
+
Started = 1,
|
|
4
|
+
InProgress = 2,
|
|
5
|
+
Completed = 3,
|
|
6
|
+
Failed = 4
|
|
7
|
+
}
|
|
8
|
+
export interface FileUpload {
|
|
9
|
+
/**
|
|
10
|
+
* File Identifier
|
|
11
|
+
*/
|
|
12
|
+
key?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Universally unique identifier
|
|
15
|
+
*/
|
|
16
|
+
readonly uuid: string;
|
|
17
|
+
/**
|
|
18
|
+
* The name of the file.
|
|
19
|
+
*/
|
|
20
|
+
readonly name: string;
|
|
21
|
+
/**
|
|
22
|
+
* The [MIME](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) type of the file
|
|
23
|
+
*/
|
|
24
|
+
readonly type: string;
|
|
25
|
+
/**
|
|
26
|
+
* The size of the file in bytes.
|
|
27
|
+
*/
|
|
28
|
+
readonly size: number;
|
|
29
|
+
/**
|
|
30
|
+
* The progress of a file upload between 0 and 1.
|
|
31
|
+
* - `0` represents Upload just started.
|
|
32
|
+
* - `1` represents a complete upload.
|
|
33
|
+
*/
|
|
34
|
+
readonly progress: number;
|
|
35
|
+
/**
|
|
36
|
+
* The upload status of the file
|
|
37
|
+
*/
|
|
38
|
+
status: StatusCode;
|
|
39
|
+
/**
|
|
40
|
+
* Represents the width and height for images
|
|
41
|
+
*/
|
|
42
|
+
readonly dimension?: {
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Provides context about multi-file upload batch
|
|
48
|
+
*/
|
|
49
|
+
readonly batchContext: {
|
|
50
|
+
/**
|
|
51
|
+
* Batch id
|
|
52
|
+
*/
|
|
53
|
+
readonly batchId: string;
|
|
54
|
+
/**
|
|
55
|
+
* Number of files in batch
|
|
56
|
+
*/
|
|
57
|
+
readonly batchCount: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Url file was uploaded to, used to send in mutation to JO
|
|
61
|
+
*/
|
|
62
|
+
uploadUrl?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The url of the file.
|
|
65
|
+
*/
|
|
66
|
+
sourcePath: string;
|
|
67
|
+
/**
|
|
68
|
+
* Cancel uploading this file
|
|
69
|
+
*/
|
|
70
|
+
cancel: () => void;
|
|
71
|
+
/**
|
|
72
|
+
* Number of retries to upload
|
|
73
|
+
*/
|
|
74
|
+
retries?: number;
|
|
75
|
+
/**
|
|
76
|
+
* Error message when upload fails
|
|
77
|
+
*/
|
|
78
|
+
errorMessage?: string;
|
|
79
|
+
}
|
|
80
|
+
export interface File {
|
|
81
|
+
contentType?: string;
|
|
82
|
+
fileName?: (string) | undefined;
|
|
83
|
+
thumbnailUrl?: (string) | undefined;
|
|
84
|
+
url?: string;
|
|
85
|
+
fileSize: number;
|
|
86
|
+
}
|
|
87
|
+
export interface FormattedFile {
|
|
88
|
+
showPreview: boolean;
|
|
89
|
+
source?: (string) | undefined;
|
|
90
|
+
thumbnailUrl?: (string) | undefined;
|
|
91
|
+
name?: (string) | undefined;
|
|
92
|
+
size: number;
|
|
93
|
+
external: boolean;
|
|
94
|
+
progress: number;
|
|
95
|
+
status: StatusCode;
|
|
96
|
+
error: boolean;
|
|
97
|
+
type?: (string) | undefined;
|
|
98
|
+
isMedia?: (boolean) | undefined;
|
|
99
|
+
showFileTypeIndicator: boolean;
|
|
100
|
+
}
|
|
101
|
+
export interface CreateThumbnailResponse {
|
|
102
|
+
readonly thumbnail: string | undefined;
|
|
103
|
+
readonly error: boolean;
|
|
104
|
+
}
|
|
105
|
+
export type CreateThumbnail = (formattedFile: FormattedFile) => Promise<CreateThumbnailResponse>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var StatusCode;
|
|
2
|
+
(function (StatusCode) {
|
|
3
|
+
StatusCode[StatusCode["Pending"] = 0] = "Pending";
|
|
4
|
+
StatusCode[StatusCode["Started"] = 1] = "Started";
|
|
5
|
+
StatusCode[StatusCode["InProgress"] = 2] = "InProgress";
|
|
6
|
+
StatusCode[StatusCode["Completed"] = 3] = "Completed";
|
|
7
|
+
StatusCode[StatusCode["Failed"] = 4] = "Failed";
|
|
8
|
+
})(StatusCode || (StatusCode = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { useComponentMessages } from "../../foundationMessages.js";
|
|
2
|
+
interface params {
|
|
3
|
+
readonly accessibilityLabel?: (string) | undefined;
|
|
4
|
+
readonly showOverlay: boolean;
|
|
5
|
+
readonly showError: boolean;
|
|
6
|
+
readonly t: ReturnType<typeof useComponentMessages>["t"];
|
|
7
|
+
}
|
|
8
|
+
export declare function computeA11yLabel({ accessibilityLabel, showOverlay, showError, t, }: params): string;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function computeA11yLabel({ accessibilityLabel, showOverlay, showError, t, }) {
|
|
2
|
+
if (!showError && showOverlay) {
|
|
3
|
+
return t("upload.inProgress");
|
|
4
|
+
}
|
|
5
|
+
else if (showError) {
|
|
6
|
+
return t("upload.failed");
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
return accessibilityLabel || t("FormatFile.label");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { UseCreateThumbnail } from "../context/types.js";
|
|
2
|
+
import type { CreateThumbnail } from "../types.js";
|
|
3
|
+
export declare function createUseCreateThumbnail(createThumbnail: CreateThumbnail): {
|
|
4
|
+
useCreateThumbnail: UseCreateThumbnail;
|
|
5
|
+
};
|
|
6
|
+
export declare const emptyThumbnail: CreateThumbnail;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from "react";
|
|
2
|
+
export function createUseCreateThumbnail(createThumbnail) {
|
|
3
|
+
const useCreateThumbnail = useCallback((file) => {
|
|
4
|
+
const [thumbnail, setThumbnail] = useState(undefined);
|
|
5
|
+
const [error, setError] = useState(false);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
let current = true;
|
|
8
|
+
createThumbnail(file)
|
|
9
|
+
.then(({ thumbnail: newThumbnail, error: newError }) => {
|
|
10
|
+
if (!current)
|
|
11
|
+
return;
|
|
12
|
+
setThumbnail(newThumbnail);
|
|
13
|
+
setError(newError);
|
|
14
|
+
})
|
|
15
|
+
.catch(() => {
|
|
16
|
+
if (!current)
|
|
17
|
+
return;
|
|
18
|
+
setError(true);
|
|
19
|
+
setThumbnail(undefined);
|
|
20
|
+
});
|
|
21
|
+
return () => { current = false; };
|
|
22
|
+
}, [file, createThumbnail]);
|
|
23
|
+
return { thumbnail, error };
|
|
24
|
+
}, [createThumbnail]);
|
|
25
|
+
return { useCreateThumbnail };
|
|
26
|
+
}
|
|
27
|
+
export const emptyThumbnail = async () => ({ error: false, thumbnail: "" });
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type FileCategory = "document" | "spreadsheet" | "pdf" | "video" | "image" | "other";
|
|
2
|
+
interface GetFileCategoryParams {
|
|
3
|
+
readonly fileName?: (string) | undefined;
|
|
4
|
+
readonly fileType?: (string) | undefined;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Bucket a file into one of the generic categories the design system
|
|
8
|
+
* recognises. Decoupled from icon names so that:
|
|
9
|
+
*
|
|
10
|
+
* 1. Consumers can use generic terminology in copy, accessibility
|
|
11
|
+
* labels, and filter UI ("Document", "Spreadsheet") without
|
|
12
|
+
* coupling to the brand-named icon assets (`word`, `excel`).
|
|
13
|
+
* 2. When the icon catalog adds generic document and spreadsheet
|
|
14
|
+
* icons, the icon mapping can be updated without breaking
|
|
15
|
+
* consumers who already use this categorisation.
|
|
16
|
+
*
|
|
17
|
+
* Detection precedence: `fileType` (MIME) first, then `fileName`
|
|
18
|
+
* extension. The extension lists cover OpenDocument Text / Spreadsheet,
|
|
19
|
+
* RTF, Apple Pages / Numbers, CSV, and WordPerfect alongside the
|
|
20
|
+
* Microsoft Office formats so callers do not have to enumerate them.
|
|
21
|
+
*
|
|
22
|
+
* `fileType` matching is case-insensitive and accepts both full MIME
|
|
23
|
+
* strings (`"video/mp4"`, `"image/jpeg"`) and coarse type strings
|
|
24
|
+
* (`"video"`, `"image"`) since `parseFile` collapses video MIMEs to
|
|
25
|
+
* the bare token `"video"` for external files.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getFileCategory({ fileName, fileType, }: GetFileCategoryParams): FileCategory;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { documentExtensions, documentMimePatterns, spreadsheetExtensions, spreadsheetMimePatterns, videoExtensions, } from "../constants.js";
|
|
2
|
+
function extensionOf(fileName) {
|
|
3
|
+
const dot = fileName.lastIndexOf(".");
|
|
4
|
+
return dot < 0 ? "" : fileName.slice(dot + 1).toLowerCase();
|
|
5
|
+
}
|
|
6
|
+
function matchesAnyExtension(fileName, list) {
|
|
7
|
+
if (!fileName)
|
|
8
|
+
return false;
|
|
9
|
+
const ext = extensionOf(fileName);
|
|
10
|
+
if (!ext)
|
|
11
|
+
return false;
|
|
12
|
+
return list.some(({ type }) => type === ext);
|
|
13
|
+
}
|
|
14
|
+
function matchesAnyMimePattern(fileType, patterns) {
|
|
15
|
+
if (!fileType)
|
|
16
|
+
return false;
|
|
17
|
+
const lower = fileType.toLowerCase();
|
|
18
|
+
return patterns.some(pattern => lower.includes(pattern));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Bucket a file into one of the generic categories the design system
|
|
22
|
+
* recognises. Decoupled from icon names so that:
|
|
23
|
+
*
|
|
24
|
+
* 1. Consumers can use generic terminology in copy, accessibility
|
|
25
|
+
* labels, and filter UI ("Document", "Spreadsheet") without
|
|
26
|
+
* coupling to the brand-named icon assets (`word`, `excel`).
|
|
27
|
+
* 2. When the icon catalog adds generic document and spreadsheet
|
|
28
|
+
* icons, the icon mapping can be updated without breaking
|
|
29
|
+
* consumers who already use this categorisation.
|
|
30
|
+
*
|
|
31
|
+
* Detection precedence: `fileType` (MIME) first, then `fileName`
|
|
32
|
+
* extension. The extension lists cover OpenDocument Text / Spreadsheet,
|
|
33
|
+
* RTF, Apple Pages / Numbers, CSV, and WordPerfect alongside the
|
|
34
|
+
* Microsoft Office formats so callers do not have to enumerate them.
|
|
35
|
+
*
|
|
36
|
+
* `fileType` matching is case-insensitive and accepts both full MIME
|
|
37
|
+
* strings (`"video/mp4"`, `"image/jpeg"`) and coarse type strings
|
|
38
|
+
* (`"video"`, `"image"`) since `parseFile` collapses video MIMEs to
|
|
39
|
+
* the bare token `"video"` for external files.
|
|
40
|
+
*/
|
|
41
|
+
export function getFileCategory({ fileName, fileType, }) {
|
|
42
|
+
const normalizedType = fileType?.toLowerCase();
|
|
43
|
+
if (normalizedType?.includes("pdf") || fileName?.match(/\.pdf$/i)) {
|
|
44
|
+
return "pdf";
|
|
45
|
+
}
|
|
46
|
+
if (normalizedType?.includes("image")) {
|
|
47
|
+
return "image";
|
|
48
|
+
}
|
|
49
|
+
if (normalizedType?.includes("video") ||
|
|
50
|
+
matchesAnyExtension(fileName, videoExtensions)) {
|
|
51
|
+
return "video";
|
|
52
|
+
}
|
|
53
|
+
if (matchesAnyMimePattern(normalizedType, documentMimePatterns) ||
|
|
54
|
+
matchesAnyExtension(fileName, documentExtensions)) {
|
|
55
|
+
return "document";
|
|
56
|
+
}
|
|
57
|
+
if (matchesAnyMimePattern(normalizedType, spreadsheetMimePatterns) ||
|
|
58
|
+
matchesAnyExtension(fileName, spreadsheetExtensions)) {
|
|
59
|
+
return "spreadsheet";
|
|
60
|
+
}
|
|
61
|
+
return "other";
|
|
62
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { computeA11yLabel } from "./computeA11yLabel.js";
|
|
2
|
+
export { parseFile, isMediaFile } from "./parseFile.js";
|
|
3
|
+
export { mapFileTypeToIconName } from "./mapFileTypeToIconName.js";
|
|
4
|
+
export { getFileCategory } from "./getFileCategory.js";
|
|
5
|
+
export type { FileCategory } from "./getFileCategory.js";
|
|
6
|
+
export { sanitizeFileName } from "./sanitizeFileName.js";
|
|
7
|
+
export { truncateFileNameForLine } from "./truncateFileNameForLine.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { computeA11yLabel } from "./computeA11yLabel.js";
|
|
2
|
+
export { parseFile, isMediaFile } from "./parseFile.js";
|
|
3
|
+
export { mapFileTypeToIconName } from "./mapFileTypeToIconName.js";
|
|
4
|
+
export { getFileCategory } from "./getFileCategory.js";
|
|
5
|
+
export { sanitizeFileName } from "./sanitizeFileName.js";
|
|
6
|
+
export { truncateFileNameForLine } from "./truncateFileNameForLine.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IconNames } from "@zj-dynamics/design/native";
|
|
2
|
+
interface FileTypeToIconNameParams {
|
|
3
|
+
readonly fileName?: (string) | undefined;
|
|
4
|
+
readonly fileType?: (string) | undefined;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Pick the file-type icon name for a given file. Today the design system
|
|
8
|
+
* exposes brand-named icons (`word`, `excel`) which double-duty as the
|
|
9
|
+
* generic "document" / "spreadsheet" indicators; when the icon catalog adds generic icons, the mapping below is the one place that needs to
|
|
10
|
+
* change.
|
|
11
|
+
*
|
|
12
|
+
* The actual file-type detection lives in `getFileCategory` so consumers
|
|
13
|
+
* that need a generic category name (e.g. for accessibility labels or
|
|
14
|
+
* filter UI) do not have to thread brand vocabulary through their copy.
|
|
15
|
+
*/
|
|
16
|
+
export declare function mapFileTypeToIconName({ fileName, fileType, }: FileTypeToIconNameParams): IconNames;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getFileCategory } from "./getFileCategory.js";
|
|
2
|
+
/**
|
|
3
|
+
* Pick the file-type icon name for a given file. Today the design system
|
|
4
|
+
* exposes brand-named icons (`word`, `excel`) which double-duty as the
|
|
5
|
+
* generic "document" / "spreadsheet" indicators; when the icon catalog adds generic icons, the mapping below is the one place that needs to
|
|
6
|
+
* change.
|
|
7
|
+
*
|
|
8
|
+
* The actual file-type detection lives in `getFileCategory` so consumers
|
|
9
|
+
* that need a generic category name (e.g. for accessibility labels or
|
|
10
|
+
* filter UI) do not have to thread brand vocabulary through their copy.
|
|
11
|
+
*/
|
|
12
|
+
export function mapFileTypeToIconName({ fileName, fileType, }) {
|
|
13
|
+
if (!fileName && !fileType) {
|
|
14
|
+
return "alert";
|
|
15
|
+
}
|
|
16
|
+
switch (getFileCategory({ fileName, fileType })) {
|
|
17
|
+
case "pdf":
|
|
18
|
+
return "pdf";
|
|
19
|
+
case "document":
|
|
20
|
+
return "document";
|
|
21
|
+
case "spreadsheet":
|
|
22
|
+
return "spreadsheet";
|
|
23
|
+
case "video":
|
|
24
|
+
return "videoFile";
|
|
25
|
+
case "image":
|
|
26
|
+
case "other":
|
|
27
|
+
default:
|
|
28
|
+
return "file";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { acceptedExtensions, videoExtensions } from "../constants.js";
|
|
2
|
+
import { StatusCode } from "../types.js";
|
|
3
|
+
export function isMediaFile(fileType) {
|
|
4
|
+
return fileType.includes("image") || fileType.includes("video");
|
|
5
|
+
}
|
|
6
|
+
function isVideo(fileName) {
|
|
7
|
+
const extension = fileName.substring(fileName.lastIndexOf(".") + 1);
|
|
8
|
+
return videoExtensions.some(({ type }) => type === extension.toLowerCase());
|
|
9
|
+
}
|
|
10
|
+
function getContentType(fileName = "", fileType = "unknown") {
|
|
11
|
+
if (isVideo(fileName)) {
|
|
12
|
+
return "video";
|
|
13
|
+
}
|
|
14
|
+
return fileType;
|
|
15
|
+
}
|
|
16
|
+
function isAcceptedExtension(file) {
|
|
17
|
+
return acceptedExtensions.some(extension =>
|
|
18
|
+
// type property may return undefined on M1 Systems running iOS Simulator
|
|
19
|
+
(file.type || "").includes(extension.name));
|
|
20
|
+
}
|
|
21
|
+
export function parseFile(file, showFileTypeIndicator) {
|
|
22
|
+
let formattedFile;
|
|
23
|
+
if ("progress" in file) {
|
|
24
|
+
formattedFile = {
|
|
25
|
+
source: file.sourcePath,
|
|
26
|
+
name: file.name,
|
|
27
|
+
size: file.size,
|
|
28
|
+
external: false,
|
|
29
|
+
progress: file.progress,
|
|
30
|
+
status: file.status,
|
|
31
|
+
error: file.status === StatusCode.Failed,
|
|
32
|
+
type: file.type || file.key,
|
|
33
|
+
isMedia: false,
|
|
34
|
+
showPreview: false,
|
|
35
|
+
showFileTypeIndicator: showFileTypeIndicator,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
formattedFile = {
|
|
40
|
+
source: file.url,
|
|
41
|
+
thumbnailUrl: file.thumbnailUrl,
|
|
42
|
+
name: file.fileName,
|
|
43
|
+
size: file.fileSize,
|
|
44
|
+
external: true,
|
|
45
|
+
progress: 1,
|
|
46
|
+
status: StatusCode.Completed,
|
|
47
|
+
error: false,
|
|
48
|
+
type: getContentType(file.fileName, file.contentType),
|
|
49
|
+
isMedia: false,
|
|
50
|
+
showPreview: false,
|
|
51
|
+
showFileTypeIndicator: showFileTypeIndicator,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
formattedFile.isMedia = isMediaFile(formattedFile.type || "");
|
|
55
|
+
formattedFile.showPreview =
|
|
56
|
+
formattedFile.isMedia || isAcceptedExtension(formattedFile);
|
|
57
|
+
return formattedFile;
|
|
58
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collapse CR / LF in a filename to a single space so embedded line breaks
|
|
3
|
+
* never reach the rendered `Text` and cause vertical layout drift.
|
|
4
|
+
*/
|
|
5
|
+
export function sanitizeFileName(name) {
|
|
6
|
+
if (!name)
|
|
7
|
+
return "";
|
|
8
|
+
return name.replace(/[\r\n]+/g, " ");
|
|
9
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Truncate a filename so it fits a single line in the small file-type tile.
|
|
3
|
+
*
|
|
4
|
+
* Why this exists: on Android, RN's `Text` with `numberOfLines={1}` does not
|
|
5
|
+
* always enforce single-line layout for URL-shaped strings with no
|
|
6
|
+
* whitespace (e.g. `vertopal.com/converter`). They wrap to a second line
|
|
7
|
+
* which then bleeds outside the rounded tile border. Pre-truncating in JS
|
|
8
|
+
* guarantees the rendered string is short enough that single-line wrapping
|
|
9
|
+
* is never required.
|
|
10
|
+
*
|
|
11
|
+
* The truncation preserves the trailing file extension when one is
|
|
12
|
+
* detectable so the file type stays visible at a glance (examples below
|
|
13
|
+
* use the default 15-character budget):
|
|
14
|
+
* `vertopal.com/converter` → `vertopal.com/c…`
|
|
15
|
+
* `file-sample_2_dx.docx` → `file-samp….docx`
|
|
16
|
+
* `quarterly-budget.numbers` → `quarte….numbers`
|
|
17
|
+
* `report.pdf` → `report.pdf` (unchanged)
|
|
18
|
+
* `embedded\nname.txt` → caller should pass through
|
|
19
|
+
* `sanitizeFileName` first
|
|
20
|
+
*
|
|
21
|
+
* `maxLength` is clamped to a sensible minimum of 2 so a caller passing
|
|
22
|
+
* `0` or a negative value cannot violate the single-line guarantee.
|
|
23
|
+
*/
|
|
24
|
+
export declare function truncateFileNameForLine(name?: string, maxLength?: number): string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const DEFAULT_MAX_LENGTH = 15;
|
|
2
|
+
const MIN_MAX_LENGTH = 2;
|
|
3
|
+
const ELLIPSIS = "…";
|
|
4
|
+
/**
|
|
5
|
+
* Maximum total length (including the leading dot) of a trailing token that
|
|
6
|
+
* we are willing to treat as a file extension. 10 covers every real-world
|
|
7
|
+
* extension this package routes to a recognisable icon (`.numbers`, `.fodt`,
|
|
8
|
+
* `.docx`, `.xlsx`, etc.) while rejecting accidental long suffixes from
|
|
9
|
+
* URL-shaped filenames. Chained pseudo-extensions like `.tar.gz` collapse
|
|
10
|
+
* to the trailing portion (`.gz`), which is the common-sense user
|
|
11
|
+
* expectation.
|
|
12
|
+
*/
|
|
13
|
+
const MAX_EXTENSION_LENGTH = 10;
|
|
14
|
+
/**
|
|
15
|
+
* Truncate a filename so it fits a single line in the small file-type tile.
|
|
16
|
+
*
|
|
17
|
+
* Why this exists: on Android, RN's `Text` with `numberOfLines={1}` does not
|
|
18
|
+
* always enforce single-line layout for URL-shaped strings with no
|
|
19
|
+
* whitespace (e.g. `vertopal.com/converter`). They wrap to a second line
|
|
20
|
+
* which then bleeds outside the rounded tile border. Pre-truncating in JS
|
|
21
|
+
* guarantees the rendered string is short enough that single-line wrapping
|
|
22
|
+
* is never required.
|
|
23
|
+
*
|
|
24
|
+
* The truncation preserves the trailing file extension when one is
|
|
25
|
+
* detectable so the file type stays visible at a glance (examples below
|
|
26
|
+
* use the default 15-character budget):
|
|
27
|
+
* `vertopal.com/converter` → `vertopal.com/c…`
|
|
28
|
+
* `file-sample_2_dx.docx` → `file-samp….docx`
|
|
29
|
+
* `quarterly-budget.numbers` → `quarte….numbers`
|
|
30
|
+
* `report.pdf` → `report.pdf` (unchanged)
|
|
31
|
+
* `embedded\nname.txt` → caller should pass through
|
|
32
|
+
* `sanitizeFileName` first
|
|
33
|
+
*
|
|
34
|
+
* `maxLength` is clamped to a sensible minimum of 2 so a caller passing
|
|
35
|
+
* `0` or a negative value cannot violate the single-line guarantee.
|
|
36
|
+
*/
|
|
37
|
+
// eslint-disable-next-line max-statements
|
|
38
|
+
export function truncateFileNameForLine(name, maxLength = DEFAULT_MAX_LENGTH) {
|
|
39
|
+
if (!name)
|
|
40
|
+
return "";
|
|
41
|
+
const budget = Math.max(MIN_MAX_LENGTH, Math.floor(maxLength));
|
|
42
|
+
if (name.length <= budget)
|
|
43
|
+
return name;
|
|
44
|
+
const lastDot = name.lastIndexOf(".");
|
|
45
|
+
const extensionLength = name.length - lastDot;
|
|
46
|
+
const hasExtension = lastDot > 0 &&
|
|
47
|
+
lastDot < name.length - 1 &&
|
|
48
|
+
extensionLength <= MAX_EXTENSION_LENGTH;
|
|
49
|
+
if (!hasExtension) {
|
|
50
|
+
return name.slice(0, budget - 1) + ELLIPSIS;
|
|
51
|
+
}
|
|
52
|
+
const extension = name.slice(lastDot);
|
|
53
|
+
const stemBudget = budget - extension.length - 1;
|
|
54
|
+
if (stemBudget <= 0) {
|
|
55
|
+
return name.slice(0, budget - 1) + ELLIPSIS;
|
|
56
|
+
}
|
|
57
|
+
return name.slice(0, stemBudget) + ELLIPSIS + extension;
|
|
58
|
+
}
|