Installations
npm install @w0s/input-file-preview
Developer Guide
BETA
Typescript
Yes
Module System
ESM
Node Version
22.13.0
NPM Version
10.9.2
Score
70.5
Supply Chain
83.3
Quality
85.1
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
1
Languages
3
TypeScript
HTML
JavaScript
TypeScript (76.2%)
HTML (22.93%)
JavaScript (0.87%)
Developer
SaekiTominaga
Download Statistics
Total Downloads
713
Last Day
2
Last Week
51
Last Month
71
Last Year
610
GitHub Statistics
1 Stars
498 Commits
1 Watching
1 Branches
1 Contributors
Package Meta Information
Latest Version
3.0.1
Package Id
@w0s/input-file-preview@3.0.1
Unpacked Size
18.76 kB
Size
5.61 kB
File Count
22
NPM Version
10.9.2
Node Version
22.13.0
Publised On
26 Jan 2025
Total Downloads
Cumulative downloads
Total Downloads
713
Last day
0%
2
Compared to previous day
Last week
750%
51
Compared to previous week
Last month
1,320%
71
Compared to previous month
Last year
492.2%
610
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Dev Dependencies
1
Versions
Show preview with <input type=file>
Demo
Examples
1<script type="importmap"> 2 { 3 "imports": { 4 "@w0s/input-file-preview": "...", 5 "@w0s/html-escape": "...", 6 "whatwg-mimetype": "..." 7 } 8 } 9</script> 10<script type="module"> 11 import inputFilePreview from '@w0s/input-file-preview'; 12 13 inputFilePreview(document.querySelectorAll('.js-input-file-preview')); // `getElementById()` or `getElementsByClassName()` or `getElementsByTagName()` or `querySelector()` or `querySelectorAll()` 14</script> 15 16<input type="file" class="js-input-file-preview" 17 data-preview="preview" 18 data-max-size="1048576" 19/> 20<template id="preview"> 21 <output><code>${name}</code> (<data value="${size}">${size} byte</data>) cannot be previewed.</output> 22</template>
HTML attributes
type
[required]- This attribute must include
file
. data-preview
[required]- ID of the
<template>
element to display the preview. data-max-size
[optional]- The number of bytes of maximum file size to preview (Files larger than this will not be previewed, but will not result in an error). If not specified, the default value is 10 MiB.
<template>
element
<template>
element must have one<output>
element.- 🆗
<template> <output>Message</output> </template>
- 🆗
<ul> <template> <li> <output>Message</output> </li> </template> </ul>
- 🆖
<template> <p>Message</p> </template>
- 🆗
- Include the error message in the
<output>
element. ${name}
in the<output>
element is converted to the file name, and${size}
is converted to the file size (in bytes).- e.g.
<output><code>${name}</code> (<data value="${size}">${size} byte</data>) cannot be previewed.</output>
- e.g.
No vulnerabilities found.
No security vulnerabilities found.