Liferay.Loader.define("dynamic-data-mapping-form-field-type@6.0.108/CheckboxMultiple/CheckboxMultiple.es",["module","exports","require","@frontend-taglib-clay$clayui/form","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$react","../FieldBase/ReactFieldBase.es","../util/setters.es"],(function(e,t,l){var a;window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=l("@frontend-taglib-clay$clayui/form"),r=(a=l("liferay!frontend-js-react-web$classnames"))&&a.__esModule?a:{default:a},o=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=u();if(t&&t.has(e))return t.get(e);var l={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var r=a?Object.getOwnPropertyDescriptor(e,n):null;r&&(r.get||r.set)?Object.defineProperty(l,n,r):l[n]=e[n]}l.default=e,t&&t.set(e,l);return l}(l("liferay!frontend-js-react-web$react")),i=l("../FieldBase/ReactFieldBase.es"),c=l("../util/setters.es");function u(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return u=function(){return e},e}function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var l=arguments[t];for(var a in l)Object.prototype.hasOwnProperty.call(l,a)&&(e[a]=l[a])}return e}).apply(this,arguments)}function d(e,t){if(null==e)return{};var l,a,n=function(e,t){if(null==e)return{};var l,a,n={},r=Object.keys(e);for(a=0;a<r.length;a++)l=r[a],t.indexOf(l)>=0||(n[l]=e[l]);return n}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)l=r[a],t.indexOf(l)>=0||Object.prototype.propertyIsEnumerable.call(e,l)&&(n[l]=e[l])}return n}const e=({checked:e,disabled:t,inline:l,label:a,name:n,onBlur:i,onChange:c,onFocus:u,value:s})=>o.default.createElement("div",{className:(0,r.default)("lfr-ddm-form-field-checkbox-switch",{"lfr-ddm-form-field-checkbox-switch-inline":l})},o.default.createElement("label",{className:"simple-toggle-switch toggle-switch"},o.default.createElement("input",{checked:e,className:"toggle-switch-check",disabled:t,name:n,onBlur:i,onChange:c,onFocus:u,type:"checkbox",value:s}),o.default.createElement("span",{"aria-hidden":"true",className:"toggle-switch-bar"},o.default.createElement("span",{className:"toggle-switch-handle"})),o.default.createElement("span",{className:"toggle-switch-label"},a))),p=({disabled:t,inline:l,isSwitcher:a,localizedValueEdited:r,name:i,onBlur:c,onChange:u,onFocus:s,options:d,predefinedValue:f,value:p})=>{const[h,m]=(0,o.useState)(p);(0,o.useEffect)((()=>{m(p)}),[p]);const b=(null==h?void 0:h.length)||0===(null==h?void 0:h.length)&&r?h:f,y=a?e:n.ClayCheckbox,g=e=>{const{target:t}=e,l=h.filter((e=>e!==t.value));t.checked&&l.push(t.value),m(l),u(e,l)};return o.default.createElement("div",{className:"lfr-ddm-checkbox-multiple"},d.map(((e,a)=>o.default.createElement(y,{checked:b.includes(e.value),disabled:t,inline:l,key:e.value,label:e.label,name:"".concat(i,"_").concat(a),onBlur:c,onChange:g,onFocus:s,value:e.value}))),o.default.createElement("input",{name:i,type:"hidden",value:h}))},h=e=>{let{inline:t,name:l,options:a=[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"}],onBlur:n,onChange:r,onFocus:u,predefinedValue:f,readOnly:h,showAsSwitcher:m=!0,value:b,localizedValueEdited:y}=e,g=d(e,["inline","name","options","onBlur","onChange","onFocus","predefinedValue","readOnly","showAsSwitcher","value","localizedValueEdited"]);return o.default.createElement(i.FieldBase,s({name:l,readOnly:h},g),o.default.createElement(p,{disabled:h,inline:t,isSwitcher:m,localizedValueEdited:y,name:l,onBlur:n,onChange:r,onFocus:u,options:a,predefinedValue:(0,c.setJSONArrayValue)(f),value:(0,c.setJSONArrayValue)(b)}))};h.displayName="CheckboxMultiple";var f=h;t.default=f}}));
//# sourceMappingURL=CheckboxMultiple.es.js.map