namespace formgen { /** */ type type_action = { label : string; target : string; }; /** */ export class class_form { /** */ private input : formgen.input.interface_input; /** */ private actions : Array; /** */ public constructor( input : formgen.input.interface_input, actions : Array ) { this.input = input; this.actions = actions; } /** */ public async setup( element_target : Element ) : Promise { const element_form : Element = document.createElement("form"); element_form.classList.add("formgen-form"); // element_form.setAttribute("method", "POST"); // input { const element_input : Element = document.createElement("div"); element_input.classList.add("formgen-form-input"); await this.input.setup(element_input); element_form.appendChild(element_input); } // actions { const element_actions : Element = document.createElement("div"); element_actions.classList.add("formgen-form-actions"); for (const action of this.actions) { const element_action : Element = document.createElement("button"); element_action.classList.add("formgen-form-button"); element_action.setAttribute("formaction", action.target); element_action.textContent = action.label; element_actions.appendChild(element_action); } element_form.appendChild(element_actions); } element_target.appendChild(element_form); return Promise.resolve(undefined); } } }