Liferay.Loader.define("@liferay/object-web@1.0.132/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 r=_interopRequireDefault(a("@frontend-taglib-clay$clayui/alert")),n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/button")),l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/form")),i=_interopRequireWildcard(a("@frontend-taglib-clay$clayui/modal")),u=a("@liferay/object-js-components-web"),o=_interopRequireWildcard(a("liferay!frontend-js-react-web$react"));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}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 a={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var l=r?Object.getOwnPropertyDescriptor(e,n):null;l&&(l.get||l.set)?Object.defineProperty(a,n,l):a[n]=e[n]}return a.default=e,t&&t.set(e,a),a}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const e=Liferay.ThemeDisplay.getDefaultLanguageId(),ModalAddListTypeDefinition=({apiURL:t,observer:a,onClose:d})=>{const[f,c]=(0,o.useState)(""),{errors:y,handleSubmit:s,setValues:p,values:g}=(0,u.useForm)({initialValues:{name_i18n:{[e]:""}},onSubmit:async e=>{try{await u.API.save(t,e,"POST"),d(),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 o.default.createElement(i.default,{observer:a},o.default.createElement(l.default,{onSubmit:s},o.default.createElement(i.default.Header,null,Liferay.Language.get("new-picklist")),o.default.createElement(i.default.Body,null,f&&o.default.createElement(r.default,{displayType:"danger"},f),o.default.createElement(u.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:g.name_i18n[e]})),o.default.createElement(i.default.Footer,{last:o.default.createElement(n.default.Group,{key:1,spaced:!0},o.default.createElement(n.default,{displayType:"secondary",onClick:()=>d()},Liferay.Language.get("cancel")),o.default.createElement(n.default,{displayType:"primary",type:"submit"},Liferay.Language.get("save")))})))};var _default=({apiURL:e})=>{const[t,a]=(0,o.useState)(!1),{observer:r,onClose:n}=(0,i.useModal)({onClose:()=>a(!1)});return(0,o.useEffect)((()=>(Liferay.on("addListTypeDefinition",(()=>a(!0))),()=>{Liferay.detach("addListTypeDefinition",(()=>a(!0)))})),[]),o.default.createElement(i.ClayModalProvider,null,t&&o.default.createElement(ModalAddListTypeDefinition,{apiURL:e,observer:r,onClose:n}))};t.default=_default}}));
//# sourceMappingURL=ModalAddListTypeDefinition.js.map