Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.169/page_editor/app/components/FormValidationModal",["module","exports","require","@frontend-taglib-clay$clayui/alert","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/modal","@frontend-taglib-clay$clayui/panel","frontend-js-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../config/index","../contexts/FormValidationContext","../utils/getFormErrorDescription"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.FormValidationModal=function FormValidationModal({onCloseModal:e,onPublish:t}){const{observer:a,onClose:l}=(0,n.useModal)({onClose:e}),s=(0,f.useFormValidations)();if(1===s.length&&1===s[0].errors.length){const[e]=s;return u.default.createElement(SingleErrorModal,{formValidation:e,observer:a,onClose:l,onPublish:t})}return u.default.createElement(n.default,{className:"page-editor__form-validation-modal",observer:a,status:"warning"},u.default.createElement(n.default.Header,null,Liferay.Language.get("form-errors")),u.default.createElement(n.default.Body,null,u.default.createElement("p",{className:"mb-4"},Liferay.Language.get("the-following-errors-have-been-found-with-the-forms-on-the-page")),s.map(((e,t)=>{const a=d.config.formTypes.find((({value:t})=>t===e.classNameId)).label;return u.default.createElement(o.default,{className:"mb-0",collapsable:!0,defaultExpanded:!0,displayTitle:(0,i.sub)(Liferay.Language.get("x-form"),a),displayType:"link",key:t,showCollapseIcon:!0},u.default.createElement(o.default.Body,null,e.errors.map((e=>{const{summary:t}=(0,c.getFormErrorDescription)({name:a,type:e});return u.default.createElement(r.default,{displayType:"warning",key:e,variant:"feedback"},t)}))))}))),u.default.createElement(ModalFooter,{onClose:l,onPublish:t}))};var r=_interopRequireDefault(a("@frontend-taglib-clay$clayui/alert")),l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/button")),n=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 l in e)if(Object.prototype.hasOwnProperty.call(e,l)){var n=r?Object.getOwnPropertyDescriptor(e,l):null;n&&(n.get||n.set)?Object.defineProperty(a,l,n):a[l]=e[l]}a.default=e,t&&t.set(e,a);return a}(a("@frontend-taglib-clay$clayui/modal")),o=_interopRequireDefault(a("@frontend-taglib-clay$clayui/panel")),i=a("frontend-js-web"),u=(_interopRequireDefault(a("liferay!frontend-js-react-web$prop-types")),_interopRequireDefault(a("liferay!frontend-js-react-web$react"))),d=a("../config/index"),f=a("../contexts/FormValidationContext"),c=a("../utils/getFormErrorDescription");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function SingleErrorModal({formValidation:e,observer:t,onClose:a,onPublish:r}){const[l]=e.errors,o=d.config.formTypes.find((({value:t})=>t===e.classNameId)).label,{message:i,title:f}=(0,c.getFormErrorDescription)({name:o,type:l});return u.default.createElement(n.default,{className:"page-editor__form-validation-modal",observer:t,status:"warning"},u.default.createElement(n.default.Header,null,f),u.default.createElement(n.default.Body,null,u.default.createElement("p",{className:"mb-0"},i)),u.default.createElement(ModalFooter,{onClose:a,onPublish:r}))}function ModalFooter({onClose:e,onPublish:t}){return u.default.createElement(n.default.Footer,{last:u.default.createElement(l.default.Group,{spaced:!0},u.default.createElement(l.default,{displayType:"secondary",onClick:e},Liferay.Language.get("cancel")),u.default.createElement(l.default,{displayType:"warning",onClick:t},Liferay.Language.get("publish")))})}}}));
//# sourceMappingURL=FormValidationModal.js.map