@jsxtools/aui
Version:
A baseline UI as Mixins, Custom Elements, React Components, etc.
1 lines • 869 B
JavaScript
import{FormAssociatedMixin}from"./form-associated.js";import{FileMixin}from"./file.js";var FormAssociatedFileMixin=(Element)=>class extends FormAssociatedMixin(FileMixin(Element)){types=[{description:"All Files",accept:{"*/*":[]}}];#handleInput(){const data=new FormData;let hasSuccess=!1;for(let file2 of this.files)if(file2.validity.valid)data.append(this.name,file2),hasSuccess=!0;if(hasSuccess===!1&&this.files.length>0)this.internals.setValidity(this.files[0].validity,this.files[0].validityMessage);else this.internals.setValidity({});this.internals.setFormValue(data),this.dispatchEvent(new Event("change",{bubbles:!0}))}connectedCallback(){this.addEventListener("input",this.#handleInput,!0),super.connectedCallback?.()}disconnectedCallback(){this.removeEventListener("drop",this.#handleInput,!0),super.disconnectedCallback?.()}};export{FormAssociatedFileMixin}