TP_JO2024/home/dist/component/toggle/toggle.module.min.js
2024-03-27 17:19:37 +01:00

3 lines
1.3 KiB
JavaScript

/*! DSFR v1.11.2 | SPDX-License-Identifier: MIT | License-Filename: LICENSE.md | restricted use (see terms and conditions) */
const e=window.dsfr;class t extends e.core.Instance{static get instanceClassName(){return"ToggleInput"}get isChecked(){return this.node.checked}}class s extends e.core.Instance{static get instanceClassName(){return"ToggleStatusLabel"}init(){this.register(`input[id="${this.getAttribute("for")}"]`,t),this.update(),this.isSwappingFont=!0}get proxy(){return Object.assign(super.proxy,{update:this.update.bind(this)})}get input(){return this.getRegisteredInstances("ToggleInput")[0]}update(){this.node.style.removeProperty("--toggle-status-width");const e=this.input.isChecked,t=getComputedStyle(this.node,":before");let s=parseFloat(t.width);this.input.node.checked=!e;const n=getComputedStyle(this.node,":before"),i=parseFloat(n.width);i>s&&(s=i),this.input.node.checked=e,this.node.style.setProperty("--toggle-status-width",s/16+"rem")}swapFont(e){this.update()}}const n={STATUS_LABEL:`${e.internals.ns.selector("toggle__label")}${e.internals.ns.attr.selector("checked-label")}${e.internals.ns.attr.selector("unchecked-label")}`};e.toggle={ToggleStatusLabel:s,ToggleSelector:n},e.internals.register(e.toggle.ToggleSelector.STATUS_LABEL,e.toggle.ToggleStatusLabel);
//# sourceMappingURL=toggle.module.min.js.map