TP_JO2024/home/dist/component/password/password.module.min.js

4 lines
2.6 KiB
JavaScript
Raw Permalink Normal View History

2024-03-27 17:19:37 +01:00
/*! DSFR v1.11.2 | SPDX-License-Identifier: MIT | License-Filename: LICENSE.md | restricted use (see terms and conditions) */
const s=window.dsfr,t={TOGGLE:s.internals.ns.emission("password","toggle"),ADJUST:s.internals.ns.emission("password","adjust")};class e extends s.core.Instance{static get instanceClassName(){return"PasswordToggle"}init(){this.listenClick(),this.ascend(t.ADJUST,this.width),this.isSwappingFont=!0,this._isChecked=this.isChecked}get width(){const s=getComputedStyle(this.node.parentNode);return parseInt(s.width)}get isChecked(){return this.node.checked}set isChecked(s){this._isChecked=s,this.ascend(t.TOGGLE,s)}handleClick(){this.isChecked=!this._isChecked}swapFont(s){this.ascend(t.ADJUST,this.width)}}class i extends s.core.Instance{static get instanceClassName(){return"Password"}init(){this.addAscent(t.TOGGLE,this.toggle.bind(this)),this.addAscent(t.ADJUST,this.adjust.bind(this))}toggle(s){this.descend(t.TOGGLE,s)}adjust(s){this.descend(t.ADJUST,s)}}const a={PASSWORD:s.internals.ns.selector("password"),INPUT:s.internals.ns.selector("password__input"),LABEL:s.internals.ns.selector("password__label"),TOOGLE:`${s.internals.ns.selector("password__checkbox")} input[type="checkbox"]`};class n extends s.core.Instance{static get instanceClassName(){return"PasswordInput"}init(){this.addDescent(t.TOGGLE,this.toggle.bind(this)),this._isRevealed="password"===this.hasAttribute("type"),this.listen("keydown",this.capslock.bind(this)),this.listen("keyup",this.capslock.bind(this))}toggle(s){this.isRevealed=s,this.setAttribute("type",s?"text":"password")}get isRevealed(){return this._isRevealed}capslock(t){t&&"function"!=typeof t.getModifierState||(t.getModifierState("CapsLock")?this.node.parentNode.setAttribute(s.internals.ns.attr("capslock"),""):this.node.parentNode.removeAttribute(s.internals.ns.attr("capslock")))}set isRevealed(s){this._isRevealed=s,this.setAttribute("type",s?"text":"password")}}class d extends s.core.Instance{static get instanceClassName(){return"PasswordLabel"}init(){this.addDescent(t.ADJUST,this.adjust.bind(this))}adjust(s){const t=Math.ceil(s/16);this.node.style.paddingRight=t+"rem"}}s.password={Password:i,PasswordToggle:e,PasswordSelector:a,PasswordInput:n,PasswordLabel:d},s.internals.register(s.password.PasswordSelector.INPUT,s.password.PasswordInput),s.internals.register(s.password.PasswordSelector.PASSWORD,s.password.Password),s.internals.register(s.password.PasswordSelector.TOOGLE,s.password.PasswordToggle),s.internals.register(s.password.PasswordSelector.LABEL,s.password.PasswordLabel);
//# sourceMappingURL=password.module.min.js.map