UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

14 lines (13 loc) 694 B
import { jsx as _jsx } from "react/jsx-runtime"; import { INPUT_CLASS } from "./Input.js"; export function FileInput({ name, title, placeholder = title, required = false, disabled = false, message, // value, onValue, types = {}, }) { const onChange = (e) => { const files = e.currentTarget.files; if (files) for (const file of files) onValue(file); }; return (_jsx("input", { name: name, type: "file", accept: Object.values(types).join(","), required: required, disabled: disabled, placeholder: placeholder, className: INPUT_CLASS, onChange: onChange, onInput: onChange, multiple: false, title: message, "aria-invalid": !!message })); }