tweb-i2p/src/components/radioForm.ts
morethanwords 31fcc95989 Forward options
Fixed opening scheduled chat after forwarding
2021-11-29 17:51:29 +04:00

22 lines
600 B
TypeScript

/*
* https://github.com/morethanwords/tweb
* Copyright (C) 2019-2021 Eduard Kuzmenko
* https://github.com/morethanwords/tweb/blob/master/LICENSE
*/
export default function RadioForm(radios: {container: HTMLElement, input: HTMLInputElement}[], onChange: (value: string, event: Event) => void) {
const form = document.createElement('form');
radios.forEach(r => {
const {container, input} = r;
form.append(container);
input.addEventListener('change', (e) => {
if(input.checked) {
onChange(input.value, e);
}
});
});
return form;
}