UNPKG

stylescape

Version:

Stylescape is a visual identity framework developed by Scape Agency.

30 lines 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PasswordToggleManager = void 0; 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)); } } exports.PasswordToggleManager = PasswordToggleManager; //# sourceMappingURL=PasswordToggleManager.js.map