viewof form3 = {
const row = (label, input) => {
const id = input.id || (input.id = DOM.uid('input').id);
const l = html`<label class="b" for=${id}>${DOM.text(label)}:`;
return html`
<div>
<div class="fl w-third pa1">${l}</div>
<div class="fl w-two-thirds pa1">
${input}
${input.title ? html`<span class="db f6 i">${DOM.text(input.title)}` : ''}
</div>
`;
};
const inputs = {};
const form = html`<div>
<form class=dt>
${row('Surveyor ID', inputs.surveyor_ID = html`<input
placeholder="First Name + Last Name"
required
title="Please enter the primary surveyor's full name.">`)}
${row('My Selection',
mySelect({
value1: "Label for value 1",
value2: "Label for value 2"
}, "the_element_name", "value2"))}
<div class="pt2 bt1"><button>Submit
`;
const values = linkViews({}, inputs);
form.value = {...values};
form.oninput = e => e.target !== form && e.stopImmediatePropagation();
form.onsubmit = e => {
e.preventDefault();
Object.assign(form.value, values);
form.dispatchEvent(new Event('input'));
}
return form;
}