Liferay.Loader.define("@liferay/object-web@1.0.108/js/components/ModalAddListTypeDefinition",["module","exports","require","@frontend-taglib-clay$clayui/alert","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/modal","@liferay/object-js-components-web","liferay!frontend-js-react-web$react"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=c(a("@frontend-taglib-clay$clayui/alert")),r=c(a("@frontend-taglib-clay$clayui/button")),l=c(a("@frontend-taglib-clay$clayui/form")),i=d(a("@frontend-taglib-clay$clayui/modal")),o=a("@liferay/object-js-components-web"),u=d(a("liferay!frontend-js-react-web$react"));function f(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return f=function(){return e},e}function d(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=f();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var l=n?Object.getOwnPropertyDescriptor(e,r):null;l&&(l.get||l.set)?Object.defineProperty(a,r,l):a[r]=e[r]}return a.default=e,t&&t.set(e,a),a}function c(e){return e&&e.__esModule?e:{default:e}}const e=Liferay.ThemeDisplay.getDefaultLanguageId(),s=({apiURL:t,observer:a,onClose:f})=>{const[d,c]=(0,u.useState)(""),{errors:y,handleSubmit:s,setValues:p,values:m}=(0,o.useForm)({initialValues:{name_i18n:{[e]:""}},onSubmit:async e=>{try{await o.API.save(t,e,"POST"),f(),window.location.reload()}catch(e){c(e.message)}},validate:t=>{const a={};return t.name_i18n[e]||(a.name_i18n=Liferay.Language.get("required")),a}});return u.default.createElement(i.default,{observer:a},u.default.createElement(l.default,{onSubmit:s},u.default.createElement(i.default.Header,null,Liferay.Language.get("new-picklist")),u.default.createElement(i.default.Body,null,d&&u.default.createElement(n.default,{displayType:"danger"},d),u.default.createElement(o.Input,{error:y.name_i18n,id:"listTypeDefinitionName",label:Liferay.Language.get("name"),name:"name_i18n",onChange:({target:{value:t}})=>p({name_i18n:{[e]:t}}),required:!0,value:m.name_i18n[e]})),u.default.createElement(i.default.Footer,{last:u.default.createElement(r.default.Group,{key:1,spaced:!0},u.default.createElement(r.default,{displayType:"secondary",onClick:()=>f()},Liferay.Language.get("cancel")),u.default.createElement(r.default,{displayType:"primary",type:"submit"},Liferay.Language.get("save")))})))};var y=({apiURL:e})=>{const[t,a]=(0,u.useState)(!1),{observer:n,onClose:r}=(0,i.useModal)({onClose:()=>a(!1)});return(0,u.useEffect)((()=>(Liferay.on("addListTypeDefinition",(()=>a(!0))),()=>{Liferay.detach("addListTypeDefinition",(()=>a(!0)))})),[]),u.default.createElement(i.ClayModalProvider,null,t&&u.default.createElement(s,{apiURL:e,observer:n,onClose:r}))};t.default=y}}));
//# sourceMappingURL=ModalAddListTypeDefinition.js.map