Liferay.Loader.define("frontend-js-web@5.0.32/liferay/modal/components/SimpleInputModal.es",["module","exports","require","@frontend-taglib-clay$clayui/alert","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/modal","@liferay/frontend-js-react-web","liferay!frontend-js-react-web$react","../../util/fetch.es","../../util/navigate.es"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var l=y(a("@frontend-taglib-clay$clayui/alert")),r=y(a("@frontend-taglib-clay$clayui/button")),n=a("@frontend-taglib-clay$clayui/form"),c=y(a("@frontend-taglib-clay$clayui/icon")),o=m(a("@frontend-taglib-clay$clayui/modal")),i=a("@liferay/frontend-js-react-web"),u=m(a("liferay!frontend-js-react-web$react")),d=y(a("../../util/fetch.es")),f=y(a("../../util/navigate.es"));function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}function m(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=s();if(t&&t.has(e))return t.get(e);var a={},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var n=l?Object.getOwnPropertyDescriptor(e,r):null;n&&(n.get||n.set)?Object.defineProperty(a,r,n):a[r]=e[r]}return a.default=e,t&&t.set(e,a),a}function y(e){return e&&e.__esModule?e:{default:e}}function b(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,l)}return a}function p(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?b(Object(a),!0).forEach((function(t){g(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):b(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}var O=({alert:e,checkboxFieldLabel:t,checkboxFieldName:a,checkboxFieldValue:s,closeModal:m,dialogTitle:y,formSubmitURL:b,idFieldName:g,idFieldValue:O,initialVisible:h,mainFieldLabel:v,mainFieldName:j,namespace:E,onFormSuccess:w,placeholder:P})=>{const k=(0,i.useIsMounted)(),[L,S]=(0,u.useState)(),[F,N]=(0,u.useState)(!1),[$,M]=(0,u.useState)(h),[D,x]=(0,u.useState)(""),[C,_]=(0,u.useState)(s),R=e=>{S(e.error||"")},{observer:T,onClose:U}=(0,o.useModal)({onClose:()=>{M(!1),m()}});return $&&u.default.createElement(o.default,{observer:T,size:"md"},u.default.createElement(o.default.Header,null,y),u.default.createElement("form",{id:"".concat(E,"form"),onSubmit:e=>{e.preventDefault();const t=new FormData(document.querySelector("#".concat(E,"form")));(0,d.default)(b,{body:t,method:"POST"}).then((e=>e.json())).then((e=>{k()&&(e.error?(N(!1),R(e)):(M(!1),m(),e.redirectURL?(0,f.default)(e.redirectURL):w&&w(p(p({},e),{},{redirectURL:e.redirectURL||""}))))})).catch((e=>{R(e)})),N(!0)}},u.default.createElement(o.default.Body,null,e&&e.message&&e.title&&u.default.createElement(l.default,{displayType:e.style,title:e.title},e.message),u.default.createElement("input",{name:"".concat(E).concat(g),type:"hidden",value:O}),u.default.createElement("div",{className:"form-group ".concat(L?"has-error":"")},u.default.createElement("label",{className:"control-label",htmlFor:"".concat(E).concat(j)},v,u.default.createElement("span",{className:"reference-mark"},u.default.createElement(c.default,{symbol:"asterisk"}))),u.default.createElement("input",{autoFocus:!0,className:"form-control",disabled:F,id:"".concat(E).concat(j),name:"".concat(E).concat(j),onChange:e=>x(e.target.value),placeholder:P,required:!0,type:"text",value:D}),L&&u.default.createElement("div",{className:"form-feedback-item"},u.default.createElement(c.default,{className:"inline-item inline-item-before",symbol:"exclamation-full"}),L)),a&&t&&u.default.createElement("div",{className:"form-check"},u.default.createElement(n.ClayCheckbox,{checked:C,disabled:F,label:t,name:"".concat(E).concat(a),onChange:()=>_((e=>!e))}))),u.default.createElement(o.default.Footer,{last:u.default.createElement(r.default.Group,{spaced:!0},u.default.createElement(r.default,{disabled:F,displayType:"secondary",onClick:U},Liferay.Language.get("cancel")),u.default.createElement(r.default,{disabled:F,displayType:"primary",type:"submit"},F&&u.default.createElement("span",{className:"inline-item inline-item-before"},u.default.createElement("span",{"aria-hidden":"true",className:"loading-animation"})),Liferay.Language.get("save")))})))};t.default=O}}));
//# sourceMappingURL=SimpleInputModal.es.js.map