Liferay.Loader.define("@liferay/object-web@1.0.108/js/components/ModalAddObjectField",["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","../utils/string","./ObjectFieldFormBase"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({apiURL:e,objectDefinitionId:t,objectFieldTypes:a,objectName:r}){const[n,l]=(0,c.useState)(!1),{observer:i,onClose:u}=(0,o.useModal)({onClose:()=>l(!1)});return(0,c.useEffect)((()=>(Liferay.on("addObjectField",(()=>l(!0))),()=>Liferay.detach("addObjectField"))),[]),c.default.createElement(o.ClayModalProvider,null,n&&c.default.createElement(j,{apiURL:e,objectDefinitionId:t,objectFieldTypes:Liferay.FeatureFlags["LPS-149625"]?a:a.filter((e=>"Aggregation"!==e.businessType)),objectName:r,observer:i,onClose:u}))};var r=b(a("@frontend-taglib-clay$clayui/alert")),n=b(a("@frontend-taglib-clay$clayui/button")),l=b(a("@frontend-taglib-clay$clayui/form")),o=s(a("@frontend-taglib-clay$clayui/modal")),i=a("@liferay/object-js-components-web"),c=s(a("liferay!frontend-js-react-web$react")),u=a("../utils/string"),d=s(a("./ObjectFieldFormBase"));function f(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return f=function(){return e},e}function s(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={},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 b(e){return e&&e.__esModule?e:{default:e}}function y(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,r)}return a}function p(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?y(Object(a),!0).forEach((function(t){g(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):y(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function g(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const e=Liferay.ThemeDisplay.getDefaultLanguageId();function j({apiURL:t,objectDefinitionId:a,objectFieldTypes:f,objectName:s,observer:b,onClose:y}){var g;const[j,m]=(0,c.useState)(""),{errors:O,handleChange:v,handleSubmit:w,setValues:L,values:P}=(0,d.useObjectFieldForm)({initialValues:{indexed:!0,indexedAsKeyword:!1,indexedLanguageId:null,listTypeDefinitionId:0,required:!1},onSubmit:async a=>{try{await i.API.save(t,p(p({},a),{},{name:a.name||(0,u.toCamelCase)(a.label[e])}),"POST"),y(),window.location.reload()}catch(e){m(e.message)}}});return c.default.createElement(o.default,{observer:b},c.default.createElement(l.default,{onSubmit:w},c.default.createElement(o.default.Header,null,Liferay.Language.get("new-field")),c.default.createElement(o.default.Body,null,j&&c.default.createElement(r.default,{displayType:"danger"},j),c.default.createElement(i.Input,{error:O.label,label:Liferay.Language.get("label"),name:"label",onChange:({target:{value:t}})=>{L({label:{[e]:t}})},required:!0,value:null===(g=P.label)||void 0===g?void 0:g[e]}),c.default.createElement(d.default,{errors:O,handleChange:v,objectDefinitionId:a,objectField:P,objectFieldTypes:f,objectName:s,setValues:L})),c.default.createElement(o.default.Footer,{last:c.default.createElement(n.default.Group,{spaced:!0},c.default.createElement(n.default,{displayType:"secondary",onClick:()=>y()},Liferay.Language.get("cancel")),c.default.createElement(n.default,{type:"submit"},Liferay.Language.get("save")))})))}}}));
//# sourceMappingURL=ModalAddObjectField.js.map