{"version":3,"file":"checkbox_controller--uHwAZei.js","sources":["../../../app/javascript/controllers/checkbox_controller.js"],"sourcesContent":["import { Controller } from \"@hotwired/stimulus\"\n\nimport ApplicationController from \"./application_controller\"\n\nexport default class extends ApplicationController {\n static targets = [\"checkbox\", \"checkmark\"]\n static classes = [\"checked\", \"unchecked\"]\n\n connect() {\n this.sync()\n }\n\n check() {\n this.checkboxTarget.checked = true\n this.checkboxTarget.dispatchEvent(new Event(\"change\"))\n\n this.applyActiveClasses()\n }\n\n uncheck() {\n this.checkboxTarget.checked = false\n this.checkboxTarget.dispatchEvent(new Event(\"change\"))\n\n this.applyInactiveClasses()\n this.hideCheckmark()\n }\n\n toggle() {\n this.checkboxTarget.checked = !this.checkboxTarget.checked\n this.checkboxTarget.dispatchEvent(new Event(\"change\"))\n\n this.sync()\n }\n\n sync() {\n if(this.checkboxTarget.checked) {\n this.applyActiveClasses()\n this.showCheckmark()\n } else {\n this.applyInactiveClasses()\n this.hideCheckmark()\n }\n }\n\n // private\n\n applyActiveClasses() {\n this.element.classList.add(...this.checkedClasses)\n\n if(this.hasUncheckedClass) {\n this.element.classList.remove(...this.uncheckedClasses)\n }\n }\n\n applyInactiveClasses() {\n if(this.hasUncheckedClass) {\n this.element.classList.add(...this.uncheckedClasses)\n }\n\n this.element.classList.remove(...this.checkedClasses)\n }\n\n showCheckmark() {\n if(this.hasCheckmarkTarget) {\n this.show(this.checkmarkTarget)\n }\n }\n\n hideCheckmark() {\n if(this.hasCheckmarkTarget) {\n this.hide(this.checkmarkTarget)\n }\n }\n\n get checkedClasses() {\n return this.hasCheckedClass ? this.checkedClass : [\"border-lavender\"]\n }\n}\n"],"names":["checkbox_controller","ApplicationController","__publicField"],"mappings":"mPAIe,MAAKA,UAASC,CAAsB,CAIjD,SAAU,CACR,KAAK,KAAI,CACb,CAEE,OAAQ,CACN,KAAK,eAAe,QAAU,GAC9B,KAAK,eAAe,cAAc,IAAI,MAAM,QAAQ,CAAC,EAErD,KAAK,mBAAkB,CAC3B,CAEE,SAAU,CACR,KAAK,eAAe,QAAU,GAC9B,KAAK,eAAe,cAAc,IAAI,MAAM,QAAQ,CAAC,EAErD,KAAK,qBAAoB,EACzB,KAAK,cAAa,CACtB,CAEE,QAAS,CACP,KAAK,eAAe,QAAU,CAAC,KAAK,eAAe,QACnD,KAAK,eAAe,cAAc,IAAI,MAAM,QAAQ,CAAC,EAErD,KAAK,KAAI,CACb,CAEE,MAAO,CACF,KAAK,eAAe,SACrB,KAAK,mBAAkB,EACvB,KAAK,cAAa,IAElB,KAAK,qBAAoB,EACzB,KAAK,cAAa,EAExB,CAIE,oBAAqB,CACnB,KAAK,QAAQ,UAAU,IAAI,GAAG,KAAK,cAAc,EAE9C,KAAK,mBACN,KAAK,QAAQ,UAAU,OAAO,GAAG,KAAK,gBAAgB,CAE5D,CAEE,sBAAuB,CAClB,KAAK,mBACN,KAAK,QAAQ,UAAU,IAAI,GAAG,KAAK,gBAAgB,EAGrD,KAAK,QAAQ,UAAU,OAAO,GAAG,KAAK,cAAc,CACxD,CAEE,eAAgB,CACX,KAAK,oBACN,KAAK,KAAK,KAAK,eAAe,CAEpC,CAEE,eAAgB,CACX,KAAK,oBACN,KAAK,KAAK,KAAK,eAAe,CAEpC,CAEE,IAAI,gBAAiB,CACnB,OAAO,KAAK,gBAAkB,KAAK,aAAe,CAAC,iBAAiB,CACxE,CACA,CAxEEC,EADkBF,EACX,UAAU,CAAC,WAAY,WAAW,GACzCE,EAFkBF,EAEX,UAAU,CAAC,UAAW,WAAW"}