!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("openstack-uicore-foundation",[],t):"object"==typeof exports?exports["openstack-uicore-foundation"]=t():e["openstack-uicore-foundation"]=t()}(this,(()=>(()=>{"use strict";var e={418:(e,t,a)=>{a.d(t,{default:()=>p});var r=a(8213),l=a.n(r),n=a(3838),o=a.n(n),s=a(6689),i=a.n(s);const c=["children","replaceNewLine","className"],p=e=>{let{children:t,replaceNewLine:a=!1,className:r=""}=e,n=o()(e,c);return i().createElement("span",l()({className:r,dangerouslySetInnerHTML:{__html:a?null==t?void 0:t.replace(/\n/g,"<br />"):t}},n))}},8213:e=>{e.exports=require("@babel/runtime/helpers/extends")},3838:e=>{e.exports=require("@babel/runtime/helpers/objectWithoutProperties")},6471:e=>{e.exports=require("awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css")},4656:e=>{e.exports=require("i18n-react/dist/i18n-react")},580:e=>{e.exports=require("prop-types")},6689:e=>{e.exports=require("react")}},t={};function a(r){var l=t[r];if(void 0!==l)return l.exports;var n=t[r]={exports:{}};return e[r](n,n.exports,a),n.exports}(()=>{a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t}})(),(()=>{a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}})(),(()=>{a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}})();var r={};return(()=>{a.r(r),a.d(r,{default:()=>h});var e=a(3838),t=a.n(e),l=a(580),n=a.n(l),o=a(6689),s=a.n(o),i=a(4656),c=a.n(i),p=a(418);a(6471);const d=["onChange","value","className","options","id","children","error","disabled","name","ariaLabelledBy"];class h extends s().Component{constructor(e){super(e);let t=!!e.value&&e.value.find((t=>!e.options.map((e=>e.value)).includes(t)));this.state={otherChecked:!!t},this.handleChange=this.handleChange.bind(this),this.handleOtherCBChange=this.handleOtherCBChange.bind(this)}handleChange(e){let t=this.props.options.map((e=>e.value)),a=this.props.value?[...this.props.value]:[];if("checkbox"===e.target.type)if(e.target.checked){const t=isNaN(e.target.value)?e.target.value:parseInt(e.target.value);a.push(t)}else a=a.filter((t=>t!=e.target.value));else a=a.filter((e=>t.includes(e))),a.push(e.target.value);let r={target:{id:this.props.id,value:a,type:"checkboxlist"}};this.props.onChange(r)}handleOtherCBChange(e){this.setState({otherChecked:e.target.checked})}render(){let e,a=this.props,{onChange:r,value:l,className:n,options:o,id:i,children:h,error:u,disabled:m,name:b,ariaLabelledBy:f}=a,{otherChecked:v}=(t()(a,d),this.state),g=this.props.hasOwnProperty("inline"),y=this.props.hasOwnProperty("allowOther"),x=!!l&&l.find((e=>!o.map((e=>e.value)).includes(e))),k=this.props.hasOwnProperty("error")&&""!==u,C=this.props.hasOwnProperty("disabled")&&1==m;return e=g?{paddingLeft:"22px",marginLeft:"20px",float:"left"}:{paddingLeft:"22px",marginTop:"7px"},s().createElement("div",{id:`chl_wrapper_${i}`,"aria-labelledby":f},s().createElement("div",{className:"checkboxes-div"+(k?" error":"")},o.map((t=>{let a=!!l&&l.includes(t.value);return s().createElement("div",{className:"form-check abc-checkbox",key:"radio_key_"+t.value,style:e},s().createElement("input",{type:"checkbox",id:`cb_${i}_${t.value}`,name:b||i,checked:a,disabled:C,onChange:this.handleChange,className:"form-check-input",value:t.value}),s().createElement("label",{className:"form-check-label",htmlFor:`cb_${i}_${t.value}`},s().createElement(p.default,null,t.label)))})),y&&s().createElement("div",{className:"form-check abc-checkbox",style:e},s().createElement("input",{type:"checkbox",id:"cb_other"+i,checked:v,disabled:C,onChange:this.handleOtherCBChange,className:"form-check-input",value:"other"}),s().createElement("label",{className:"form-check-label",htmlFor:"cb_other"+i},c().translate("general.other"))),y&&v&&s().createElement("div",{style:{paddingLeft:"22px",width:"50%"}},s().createElement("input",{className:"form-control",disabled:C,onChange:this.handleChange,value:x}))),k&&s().createElement("p",{className:"error-label"},u))}}h.defaultProps={ariaLabelledBy:null},h.propTypes={id:n().string.isRequired}})(),r})()));
//# sourceMappingURL=checkbox-list.js.map