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cesContent":["import { Collapse } from 'bootstrap';\r\n\r\nconst changeEvent = new Event('rccChange');\r\nclass RadioCollapseControl {\r\n constructor(el) {\r\n this.el = el;\r\n this.radios = [];\r\n let findRadios = this.el.querySelectorAll('input[type=\"radio\"]');\r\n if(findRadios) {\r\n findRadios.forEach(r => {\r\n let findTarget = document.querySelector(r.dataset.rccTarget);\r\n this.radios.push({\r\n el: r,\r\n collapseEl: findTarget == null ? null : Collapse.getOrCreateInstance(findTarget, {\r\n toggle: false\r\n }),\r\n childCheckboxes: findTarget == null ? null : findTarget.querySelectorAll('input[type=\"checkbox\"]'),\r\n childTextFields: findTarget == null ? null : findTarget.querySelectorAll('input[type=\"text\"]')\r\n });\r\n r.onclick = () => {\r\n this.update();\r\n }\r\n });\r\n }\r\n this.update();\r\n }\r\n\r\n update() {\r\n for(let x = 0, l = this.radios.length; x < l; x++) {\r\n let r = this.radios[x];\r\n if(r.collapseEl != null) {\r\n if(r.el.checked) {\r\n r.collapseEl.show();\r\n r.el.setAttribute('aria-expanded', true);\r\n } else {\r\n r.collapseEl.hide();\r\n r.el.setAttribute('aria-expanded', false);\r\n // clear some child form fields\r\n if(r.childCheckboxes) {\r\n r.childCheckboxes.forEach(c => {\r\n c.checked = false;\r\n c.removeAttribute('checked');\r\n });\r\n }\r\n if(r.TextFields) {\r\n r.TextFields.forEach(t => {\r\n t.value = '';\r\n });\r\n }\r\n }\r\n }\r\n }\r\n window.dispatchEvent(changeEvent);\r\n }\r\n}\r\n\r\nexport function createFrom(wrappers) {\r\n wrappers.forEach((node) => {\r\n // if node is an element\r\n if (node.nodeType === 1) {\r\n new RadioCollapseControl(node);\r\n }\r\n });\r\n}"],"names":["changeEvent","Event","RadioCollapseControl","constructor","el","this","radios","findRadios","querySelectorAll","forEach","r","findTarget","document","querySelector","dataset","rccTarget","push","collapseEl","Collapse","getOrCreateInstance","toggle","childCheckboxes","childTextFields","onclick","update","x","l","length","checked","show","setAttribute","hide","c","removeAttribute","TextFields","t","value","window","dispatchEvent","createFrom","wrappers","node","nodeType"],"sourceRoot":""}