npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

Iโ€™ve always been into building performant and accessible sites, but lately Iโ€™ve been taking it extremely seriously. So much so that Iโ€™ve been building a tool to help me optimize and monitor the sites that I build to make sure that Iโ€™m making an attempt to offer the best experience to those who visit them. If youโ€™re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, ๐Ÿ‘‹, Iโ€™m Ryan Hefnerย  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If youโ€™re interested in other things Iโ€™m working on, follow me on Twitter or check out the open source projects Iโ€™ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soonโ€“ish.

Open Software & Tools

This site wouldnโ€™t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you ๐Ÿ™

ยฉ 2024 โ€“ย Pkg Stats / Ryan Hefner

react-mui-upload

v0.0.1

Published

๐Ÿ—ƒ๏ธ React mui fileuploader is a react component based on @mui v5 that allows you to upload files with an awesome ui component

Downloads

1

Readme


React mui fileuploader is a React component based on @mui v5 that allows you to upload files with an awesome ui component.

DEMO

๐Ÿš€ Installation

  npm install react-mui-fileuploader

๐Ÿ’ป Usage

const handleFileUploadError = (error) => {
  // Do something...
}

const handleFilesChange = (files) => {
  // Do something...
  setUploadedFiles([...files]);
}

return (
  <FileUpload 
    getBase64={false}
    multiFile={true}
    disabled={false}
    title="My awesome file uploader"
    header="[Drag to drop]"
    leftLabel="or"
    rightLabel="to select files"
    buttonLabel="click here"
    buttonRemoveLabel="Remove all"
    maxFileSize={10}
    maxUploadFiles={0}
    maxFilesContainerHeight={357}
    acceptedType={'image/*'}
    errorSizeMessage={'fill it or remove it to use the default error message'}
    allowedExtensions={['jpg', 'jpeg']}
    onFilesChange={handleFilesChange}
    onError={handleFileUploadError}
    imageSrc={'path/to/custom/image'}
    BannerProps={{ elevation: 0, variant: "outlined" }}
    showPlaceholderImage={true}
    PlaceholderGridProps={{ md: 4 }}
    LabelsGridProps={{ md: 8 }}
    onContextReady={context => {
      // access to component context here
    }}
    ContainerProps={{
      elevation: 0,
      variant: "outlined",
      sx: { p: 1 }
    }}
    PlaceholderImageDimension={{
      xs: { width: 128, height: 128 },
      sm: { width: 128, height: 128 },
      md: { width: 164, height: 164 },
      lg: { width: 256, height: 256 }
    }}
  />
)

๐ŸŽจ Possible application

import React, { useState } from "react"
import { createRoot } from "react-dom/client"
import FileUpload from "react-mui-fileuploader"

function MuiFileUploader() {
  const [filesToUpload, setFilesToUpload] = useState([])

  const handleFilesChange = (files) => {
    // Update chosen files
    setFilesToUpload([ ...files ])
  };

  const uploadFiles = () => {
    // Create a form and post it to server
    let formData = new FormData()
    filesToUpload.forEach((file) => formData.append("files", file))

    fetch("/file/upload", {
      method: "POST",
      body: formData
    })
  }

  return (
    <>
      <FileUpload
        multiFile={true}
        onFilesChange={handleFilesChange}
        onContextReady={(context) => {}}
      />
      <button onClick={uploadFiles}>Upload</button>
    </>
  )
}

const root = createRoot(document.getElementById("root"))
root.render(<MuiFileUploader />)

Edit react-mui-fileuploader example

Data structure

| Name | Type | Required | Details |
|------ |--- |--- |--- | | getBase64 | boolean | false | Get the original input files. Default value false | | multiFile | boolean | false | Multifile support. Default value true | | title | string | false | Component title | | header | string | false | Banner component big title | | showPlaceholderImage | boolean | false | Show or hide placeholder image | | imageSrc | string | false | Banner image placeholder source path | | imageSrcAlt | string | false | Banner image placeholder label | | leftLabel | string | false | Banner left label | | rightLabel | string | false | Banner right label | | buttonLabel | string | false | Banner button label | | buttonRemoveLabel | string | false | Remove button label | | disabled | boolean | false | This property enables or disables the component. Default value false |
| maxFileSize | number | false | Maximum size (in mb) for files to add. Default value 0. Value 0 means unlimited size | | maxUploadFiles | number | false | Maximum files to add. Default to 0. Value 0 means unlimited size | | errorSizeMessage | string | false | Error returned when a file exceeds maxFileSize limit | | acceptedType | string | false | Accepted file type. Default value image/* | | allowedExtensions | array | false | Array of allowed extensions. For example, you can specify ['jpg', 'jpeg', 'png']as allowedExtensions | | filesContainerHeight | number | false | Container Height | | maxFilesContainerHeight | number | false | Container max height. Default value 300 | | onError | function | false | Returned error message when error occurs | | onFilesChange | function | false | Event handler returned when files changes | | onContextReady | function | false | Returns the component context api | | BannerProps | object | false | Banner props. Only MUI props are accepted | | ContainerProps | object | false | Container props. Only MUI props are accepted | | PlaceholderImageDimension | object | false | Dimensions (width and height) of the placeholder image. You can specify them in the properties xs: {width: 64, height: 64}, sm: {width: 64, height: 64}, md: {width: 64, height: 64}, lg: {width: 64, height: 64}, etc. | | PlaceholderGridProps | object | false | Customize the placeholder Grid xs, sm, md, lg, xl sizes | | LabelsGridProps | object | false | Customize the labels Grid xs, sm, md, lg, xl sizes |

๐Ÿ˜ Authors

๐Ÿค” FAQ

  • Where can I find more documentation?

    This library is a marriage of @mui and a React setup created with React. Either one would be a great place to start!

๐Ÿ™‡โ€โ™‚๏ธ Extra

Do you like this library ? Buy me a coffee or support me with a star on Github

  • Btc address: bc1qettgagenn9nc8ks7ghntjfme96yvvkfhntk774

  • Eth address: 0xB0413d8D0336E263e289A915c383e152155881E0

License

react-mui-fileuploader

MIT License

Copyright (c) 2023 rouftom

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.