Whitelisted file extensions for Form.FilePicker
Description
I think a new optional prop to Form.FilePicker, accepting an array of file extensions (example: allowedFileExtensions: [".png", ".webp", ".jpg", ".jpeg"] would be great.
This would add 2 functionalities:
- Auto-filter in/out non-whitelisted file extensions when using
getSelectedFinderItems, saving work for extension developers; - Grey-out (make unselectable) non-whitelisted file types when browsing the Finder, hinting the user to what file types are accepted.
Additionally (probably harder to implement/impossible due to MacOS, I don't know, haven't looked into it), it would be great to be able to update the prop dynamically based on what files they have selected so far.
Example: I'm working on Media Converter, where we accept image, video and audio files. But if the first selected file is an image, we will only be able to process images, same for the others. So, allow for allowedFileExtensions: [...ALLOWED_IMAGE_EXTENSIONS, ...ALLOWED_VIDEO_EXTENSIONS, ...ALLOWED_AUDIO_EXTENSIONS] when the user hasn't selected any file in the Finder window of FilePicker, but when he has selected one file, say an image, update to allowedFileExtensions: ALLOWED_IMAGE_EXTENSIONS. If they have selected multiple files at once, treat the first as the "selected allowed file type", and discard the non-whitelisted selected.
Who will benefit from this feature?
I believe most developers using Form.FilePicker. Would certainly be handy for Media Converter, non-vital though. Nice QOL feature.
Anything else?
No response
I feel like this would be a better way to handle input files than outputting a Form.FilePicker error prop. Won't replace it though, of course.