Capgemini / dcx-react-library

React Library UI/UX agnostic
https://main--6069a6f47f4b9f002171f8e1.chromatic.com
MIT License
107 stars 7 forks source link

fix: adding fileList to onChange for multi file uploads #613

Closed Ibabalola closed 3 months ago

Ibabalola commented 3 months ago

On change will now return a fileList of all files uploaded

export const MultiUploadDemo = () => {

  const onChangeHandler: (files: FileList | null) => void = (
    files: FileList
  ) => {
    if (files) {
      Array.from(files).forEach((file: File) => {
        // https://developer.mozilla.org/en-US/docs/Web/API/File
        // data in file object _should_ be available here
      });
    }
  };

  return (
      <MultiUpload
        label="Label"
        name="name"
        acceptedFormats=".doc, .pdf"
        className="file-upload"
        error={{
          text: 'Error',
          className: "govuk-error-message",
          id: "error-impact-assessment",
          visuallyHiddenText: {
            text: "visuallyHiddenText",
            className: "govuk-visually-hidden",
          },
        }}
        hint={{
          text: "Text",
          className: "govuk-hint",
        }}
        id="impact_assessment"
        inputProperties={{
          className: "govuk-file-upload",
        }}
        labelProperties={{
          className: "govuk-heading-m",
        }}
        multiple
        onChange={onChangeHandler}
      />
  );
};
codecov-commenter commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (c58641a) to head (bf80646).

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## release/1.0.0 #613 +/- ## =============================================== Coverage 100.00% 100.00% =============================================== Files 85 85 Lines 1511 1512 +1 Branches 527 527 =============================================== + Hits 1511 1512 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.