SHA256
Обновить кошельки и мелкие детали UI
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
|
||||
/** The password is intentionally visible initially on both auth screens. */
|
||||
export function createVisiblePasswordField(input) {
|
||||
input.type = 'text';
|
||||
const wrap = document.createElement('div');
|
||||
wrap.className = 'auth-password-field';
|
||||
const toggle = document.createElement('button');
|
||||
toggle.type = 'button';
|
||||
toggle.className = 'auth-password-field__toggle';
|
||||
function updateToggle() {
|
||||
const visible = input.type !== 'password';
|
||||
toggle.innerHTML = iconHtml(visible ? 'eyeOff' : 'eye', false, 'key-toggle-icon');
|
||||
toggle.setAttribute('aria-label', visible ? 'Скрыть пароль' : 'Показать пароль');
|
||||
toggle.setAttribute('title', visible ? 'Скрыть пароль' : 'Показать пароль');
|
||||
toggle.setAttribute('aria-pressed', String(!visible));
|
||||
}
|
||||
toggle.addEventListener('click', () => {
|
||||
const start = input.selectionStart;
|
||||
const end = input.selectionEnd;
|
||||
input.type = input.type === 'password' ? 'text' : 'password';
|
||||
updateToggle();
|
||||
input.focus();
|
||||
try { if (start !== null && end !== null) input.setSelectionRange(start, end); } catch { /* unsupported input method */ }
|
||||
});
|
||||
updateToggle();
|
||||
wrap.append(input, toggle);
|
||||
return wrap;
|
||||
}
|
||||
Reference in New Issue
Block a user