0.0.117 • Published 3 months ago

@solid-primitives/upload v0.0.117

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

@solid-primitives/upload

turborepo size size stage

Primitive to make uploading files and making dropzones easier.

Installation

npm install @solid-primitives/upload
# or
yarn add @solid-primitives/upload

How to use it

createFileUploader

// single files
const { files, selectFiles } = createFileUploader();
selectFiles([file] => console.log(file));

// multiple files
const { files, selectFiles } = createFileUploader({ multiple: true, accept: "image/*" });
selectFiles(files => files.forEach(file => console.log(file)));

use:fileUploader directive

const [files, setFiles] = createSignal<UploadFile[]>([]);

<input
  type="file"
  multiple
  use:fileUploader={{
    userCallback: fs => fs.forEach(f => console.log(f)),
    setFiles,
  }}
/>;

createDropzone

<div
  ref={dropzoneRef}
  style={{ width: "100px", height: "100px", background: "red" }}>
  Dropzone
</div>
const { setRef: dropzoneRef, files: droppedFiles } = createDropzone({
  onDrop: async files => {
    await doStuff(2);
    files.forEach(f => console.log(f));
  },
  onDragStart: files => files.forEach(f => console.log(f)),
  onDragOver: files => console.log("drag over"),
});

Demo

Working example: https://primitives.solidjs.community/playground/upload Source code: https://github.com/solidjs-community/solid-primitives/blob/main/packages/upload/dev/index.tsx

Changelog

See CHANGELOG.md

0.0.117

3 months ago

0.0.116

3 months ago

0.0.115

4 months ago

0.0.114

10 months ago

0.0.113

1 year ago

0.0.112

1 year ago

0.0.109

1 year ago

0.0.108

1 year ago

0.0.111

1 year ago

0.0.110

1 year ago

0.0.109-beta.0

1 year ago

0.0.107

1 year ago

0.0.106

1 year ago

0.0.105

2 years ago

0.0.104

2 years ago

0.0.103

2 years ago

0.0.102

2 years ago

0.0.101

2 years ago

0.0.100

2 years ago