axa-ch-webhub-cloud / pattern-library

AXA CH UI component library. Please share, comment, create issues and work with us!
https://axa-ch-webhub-cloud.github.io/plib-feature/develop
125 stars 18 forks source link

Improve Typing of FileUpload in React #2369

Closed corsin-ragettli closed 1 year ago

corsin-ragettli commented 1 year ago

Currently, the onChange event of the FileUpload has the typing (files: Blob[]) => void. this is very confusing for new developers since they have no idea that actually, the onChange event provides further attributes:

{
   "id": "string",
   "lastModified": "number",
   "lastModifiedDate": "Date",
   "name": "string",
   "size": "number",
   "type": "string"
}

So my proposal is to change the typing of onChange to (files: File[]) => void

MKaHead commented 1 year ago

I have also now found out that the type is based on file and is enriched with id and optionally errorMessage.