MCPcopy Index your code
hub / github.com/Grafikart/CustomElement-DropFiles

github.com/Grafikart/CustomElement-DropFiles @1.0.9

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.0.9 ↗ · + Follow
38 symbols 80 edges 19 files 9 documented · 24% updated 4y ago★ 905 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Customized built-in elements is="drop-files"

npm Build Status Build Status

The goal of this module is to add user interaction on a file input with multiple files as a progressive enhancement (the form still works if this JavaScript is disabled). Live demo

Usage

With npm

Install the package using npm or yarn

npm i @grafikart/drop-files-element
# or
yarn add @grafikart/drop-files-element

Then import it in your script

import '@grafikart/drop-files-element'

With unpkg.com

<script type="module" src="https://github.com/Grafikart/CustomElement-DropFiles/raw/1.0.9/unpkg.com/@grafikart/drop-files-element"></script>

Then use the custom element in your html using is="drop-files.

<input
        type="file"
        multiple
        name="files[]"
        label="Drop files here or click to upload."
        help="Upload files here and they won't be sent immediately"
        is="drop-files"
/>

Safari

Unfortunately safari doesn't support Custom built-in elements and you have to polyfill this feature at the moment using @ungap polyfill

<script src="https://unpkg.com/@ungap/custom-elements-builtin"></script>

Customization

Attributes

Attribute Type Description
label string The label used as a bold text for the drop area
help string Help text used as a secondary text for the drop area

CSS Custom Properties

Property
--drop-border-color
--drop-border-color-hover

HTML Structure

This component doesn't use shadow dom so you can customize the style using CSS and overwrite the style already included inside this custom element.

Changelog

1.0.9

  • Fixed the behaviour of a single file input

1.0.8

  • Correctly handle input without the "multiple" attribute (issue #4)

1.0.7

  • Fixed a rendering bug on Firefox (issue #2)

1.0.6

  • Fixed a bug happening when no attributes were passed to the component

1.0.5

  • Fix style when box-sizing is set to border-box

1.0.4

  • Better error handling
  • Improved style for the delete button

Extension points exported contracts — how you extend this code

Props (Interface)
(no doc)
src/components/file.ts
Matchers (Interface)
(no doc)
tests/jest.d.ts
Props (Interface)
(no doc)
src/components/file-list.ts

Core symbols most depended-on inside this repo

remove
called by 7
src/helpers/flip.ts
arrayToFileList
called by 7
src/helpers/files.ts
humanSize
called by 5
src/helpers/sizes.ts
strToDom
called by 5
src/helpers/dom.ts
onFilesUpdate
called by 4
src/index.ts
diffFiles
called by 4
src/helpers/files.ts
render
called by 2
src/index.ts
getAttributes
called by 1
src/index.ts

Shape

Method 15
Function 14
Class 6
Interface 3

Languages

TypeScript100%

Modules by API surface

src/index.ts11 symbols
src/helpers/flip.ts6 symbols
src/helpers/files.ts5 symbols
src/components/file-list.ts5 symbols
src/helpers/files.test.ts2 symbols
src/helpers/dom.ts2 symbols
src/components/file.ts2 symbols
tests/setup.js1 symbols
tests/jest.d.ts1 symbols
tests/e2e/drop-files.test.js1 symbols
src/icons/index.ts1 symbols
src/helpers/sizes.ts1 symbols

For agents

$ claude mcp add CustomElement-DropFiles \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact