@payfit/unity-components
Version:
27 lines (26 loc) • 1.13 kB
JavaScript
import { FileUploadDropzone as e } from "../../../../core/components/file-upload-dropzone/FileUploadDropzone.js";
import { useFieldContext as t } from "../../hooks/tanstack-form-context.js";
import { useFieldA11yContext as n } from "../form-field/TanstackFormField.context.js";
import { jsx as r } from "react/jsx-runtime";
//#region src/modules/tanstack-form/components/tanstack-file-upload-dropzone/TanstackFileUploadDropzone.tsx
function i({ isDisabled: i, ...a }) {
let o = t(), s = n(), c = o.state.meta.isTouched && !o.state.meta.isValid;
return /* @__PURE__ */ r(e, {
...a,
name: o.name,
state: i ? "disabled" : c ? "invalid" : void 0,
"aria-labelledby": s.labelId || void 0,
"aria-describedby": [s.helperTextId, s.feedbackTextId].filter(Boolean).join(" ") || void 0,
onSelect: (e) => {
o.handleChange(e ? Array.from(e) : []), o.handleBlur();
},
onDrop: (e) => {
let t = e.items.filter((e) => e.kind === "file");
t.length !== 0 && Promise.all(t.map((e) => e.getFile())).then((e) => {
o.handleChange(e), o.handleBlur();
});
}
});
}
//#endregion
export { i as FileUploadDropzoneInput };