UNPKG

stylescape

Version:

Stylescape is a visual identity framework developed by Scape Agency.

26 lines 943 B
export class PasswordToggleManager { constructor(selector = "[data-password-toggle]") { this.selector = selector; this.init(); } init() { document .querySelectorAll(this.selector) .forEach((button) => { const inputId = button.dataset.passwordToggle; if (!inputId) return; const input = document.getElementById(inputId); if (!input || input.type !== "password") return; button.addEventListener("click", () => this.togglePasswordVisibility(input, button)); }); } togglePasswordVisibility(input, button) { const isText = input.type === "text"; input.type = isText ? "password" : "text"; button.classList.toggle("is-visible", !isText); button.setAttribute("aria-pressed", String(!isText)); } } //# sourceMappingURL=PasswordToggleManager.js.map