@scalar/api-client
Version:
the open source API testing client
22 lines (21 loc) • 526 B
JavaScript
import { ref as f, readonly as p } from "vue";
function s({ multiple: l, accept: i, onChange: o, onError: n } = {}) {
const t = f(null);
let e;
typeof document < "u" && (e = document.createElement("input"), e.type = "file", e.onchange = (c) => {
const r = c.target;
t.value = r.files, o?.(t.value);
}, e.onerror = () => n?.(), e.multiple = l, e.accept = i);
const u = () => {
if (!e)
return n?.();
e.click();
};
return {
files: p(t),
open: u
};
}
export {
s as useFileDialog
};