Telegram Web K with changes to work inside I2P https://web.telegram.i2p/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.3 KiB

import appStateManager from "../lib/appManagers/appStateManager";
import { getDeepProperty } from "../helpers/object";
const RadioField = (text: string, name: string, value?: string, stateKey?: string) => {
const label = document.createElement('label');
label.classList.add('radio-field');
const input = document.createElement('input');
input.type = 'radio';
input.id = input.name = 'input-radio-' + name;
if(value) {
input.value = value;
if(stateKey) {
appStateManager.getState().then(state => {
input.checked = getDeepProperty(state, stateKey) === value;
});
input.addEventListener('change', () => {
appStateManager.setByKey(stateKey, value);
});
}
}
const main = document.createElement('div');
main.classList.add('radio-field-main');
if(text) {
main.innerHTML = text;
/* const caption = document.createElement('div');
caption.classList.add('radio-field-main-caption');
caption.innerHTML = text;
if(subtitle) {
label.classList.add('radio-field-with-subtitle');
caption.insertAdjacentHTML('beforeend', `<div class="radio-field-main-subtitle">${subtitle}</div>`);
}
main.append(caption); */
}
label.append(input, main);
return {label, input, main};
};
export default RadioField;