Liferay.Loader.define("dynamic-data-mapping-form-field-type@6.0.124/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){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=l("@frontend-taglib-clay$clayui/form"),n=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(l("liferay!frontend-js-react-web$classnames")),r=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();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"),o=l("../util/setters.es");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _extends(){return(_extends=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 _objectWithoutProperties(e,t){if(null==e)return{};var l,a,n=function _objectWithoutPropertiesLoose(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 Switcher=({checked:e,disabled:t,inline:l,label:a,name:i,onBlur:o,onChange:c,onFocus:u,value:d})=>r.default.createElement("div",{className:(0,n.default)("lfr-ddm-form-field-checkbox-switch",{"lfr-ddm-form-field-checkbox-switch-inline":l})},r.default.createElement("label",{className:"simple-toggle-switch toggle-switch"},r.default.createElement("input",{checked:e,className:"toggle-switch-check",disabled:t,name:i,onBlur:o,onChange:c,onFocus:u,type:"checkbox",value:d}),r.default.createElement("span",{"aria-hidden":"true",className:"toggle-switch-bar"},r.default.createElement("span",{className:"toggle-switch-handle"})),r.default.createElement("span",{className:"toggle-switch-label"},a))),CheckboxMultiple=({disabled:e,inline:t,isSwitcher:l,localizedValueEdited:n,name:i,onBlur:o,onChange:c,onFocus:u,options:d,predefinedValue:s,value:f})=>{const[p,h]=(0,r.useState)(f);(0,r.useEffect)((()=>{h(f)}),[f]);const m=(null==p?void 0:p.length)||0===(null==p?void 0:p.length)&&n?p:s,b=l?Switcher:a.ClayCheckbox,handleChange=e=>{const{target:t}=e,l=p.filter((e=>e!==t.value));t.checked&&l.push(t.value),h(l),c(e,l)};return r.default.createElement("div",{className:"lfr-ddm-checkbox-multiple"},d.map(((l,a)=>r.default.createElement(b,{checked:m.includes(l.value),disabled:e,inline:t,key:l.value,label:l.label,name:"".concat(i,"_").concat(a),onBlur:o,onChange:handleChange,onFocus:u,value:l.value}))),r.default.createElement("input",{name:i,type:"hidden",value:p}))},Main=e=>{let{inline:t,name:l,options:a=[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"}],onBlur:n,onChange:c,onFocus:u,predefinedValue:d,readOnly:s,showAsSwitcher:f=!0,value:p,localizedValueEdited:h}=e,m=_objectWithoutProperties(e,["inline","name","options","onBlur","onChange","onFocus","predefinedValue","readOnly","showAsSwitcher","value","localizedValueEdited"]);return r.default.createElement(i.FieldBase,_extends({name:l,readOnly:s},m),r.default.createElement(CheckboxMultiple,{disabled:s,inline:t,isSwitcher:f,localizedValueEdited:h,name:l,onBlur:n,onChange:c,onFocus:u,options:a,predefinedValue:(0,o.setJSONArrayValue)(d),value:(0,o.setJSONArrayValue)(p)}))};Main.displayName="CheckboxMultiple";var c=Main;t.default=c}}));
//# sourceMappingURL=CheckboxMultiple.es.js.map