The module includes 3 binder creators for defi.js which deal with files.
In browser environment these functions live at
const file dropFiles dragOver = fileBinders;// ...defi;// if you don't want to create variablesdefi;
The bundle can be downloaded at gh-pages branch
npm i file-binders
// import all bindersconst file dropFiles dragOver = ;// import only needed bindersconst file = ;const dropFiles = ;const dragOver = ;// ...defi;
Returns a binder for file input. The binder allows not only to get basic data about a file, but also to read it without calling
readAs argument isn’t set, input value gets into the bound property after its changing (on "change" DOM event). If
readAs is set, binder will read the file and transform it into the needed format (data URI, Blob...) and only after reading the file, the property will be changed.
The file (native
File) or an array of files becomes the final value of the property in the presence of
multiple attribute. At the same time the result of reading will get into the object of every file as
readAs optional - the argument value can be "arrayBufer", "binaryString", "dataURL", "text". The value depends on the presence of corresponding methods of the
defi;// ... user changes input content// choosing my-image.png from file system ...defi;
Returns a binder which allows to drop files from a file manager to a given element. After
bindNode is called HTML block gets needed DOM event listeners (eg, "dragover" and "drop"). When user drops files from file manager into the block, the property gets an array of dropped files as its value. As like
file the binder accepts one optional argument called
readAs which says how the files need to be read by
FileReader: data URI, Blob... (the result of reading is placed in
readerResult property of every file). If
readAs isn't given, the property gets an array of files which wasn't read.
readAs optional - the argument value can be
"text". The value depends on the presence of corresponding methods of the
defi;// ... user drops one file called// "my-image.png" into .drop-area blockdefi;
Makes given property equal to
true when something is dragged over a given node.
Add "dragovered" class name when file (or another draggable object) is dragged over .my-node