!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={6031:e=>{e.exports=require("@babel/runtime/helpers/extends")},2462:e=>{e.exports=require("@babel/runtime/helpers/objectWithoutProperties")},8619:e=>{e.exports=require("@mui/material")},3294:e=>{e.exports=require("formik")},6842:e=>{e.exports=require("i18n-react/dist/i18n-react")},2015:e=>{e.exports=require("react")}},t={};function r(l){var a=t[l];if(void 0!==a)return a.exports;var n=t[l]={exports:{}};return e[l](n,n.exports,r),n.exports}(()=>{r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t}})(),(()=>{r.d=(e,t)=>{for(var l in t)r.o(t,l)&&!r.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})}})(),(()=>{r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}})();var l={};r.r(l),r.d(l,{default:()=>b});var a=r(6031),n=r.n(a),o=r(2462),u=r.n(o),i=r(2015),c=r.n(i),s=r(8619),d=r(3294),p=r(6842),m=r.n(p);const v=["name","label","placeholder","options"],b=e=>{let{name:t,label:r,placeholder:l,options:a}=e,o=u()(e,v);const[i,p,b]=(0,d.useField)(t),f=l||m().translate("placeholders.select"),x=a.every((({value:e})=>{var t;return null===(t=i.value)||void 0===t?void 0:t.includes(e)}));return c().createElement(s.FormControl,{fullWidth:!0,error:p.touched&&Boolean(p.error)},r&&c().createElement(s.InputLabel,{shrink:!0,id:`${t}-label`},r),c().createElement(s.Select,n()({variant:"outlined",name:t,label:r,labelId:`${t}-label`,multiple:!0,value:i.value||[],onChange:e=>{const{value:t}=e.target;t.includes("all")?x?b.setValue([]):b.setValue(a.map((e=>e.value))):b.setValue(t)},onBlur:i.onBlur,displayEmpty:!0},o,{renderValue:e=>{if(null==e||!e.length)return c().createElement("em",null,f);if(x)return m().translate("general.all");const t=a.filter((({value:t})=>null==e?void 0:e.includes(t))).map((({label:e})=>e));return t.join(", ")}}),c().createElement(s.MenuItem,{key:"all",value:"all"},c().createElement(s.Checkbox,{checked:x}),c().createElement(s.ListItemText,{primary:m().translate("general.all")})),c().createElement(s.Divider,{sx:{m:0}}),a.map((({label:e,value:t})=>{var r;return c().createElement(s.MenuItem,{key:`ckbx-ddl-${t}`,value:t},c().createElement(s.Checkbox,{checked:null===(r=i.value)||void 0===r?void 0:r.includes(t)}),c().createElement(s.ListItemText,{primary:e}))}))))};return l})()));
//# sourceMappingURL=dropdown-checkbox.js.map