Liferay.Loader.define("@liferay/object-js-components-web@1.0.58/hooks/useForm",["module","exports","require","liferay!frontend-js-react-web$react"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.invalidateLocalizableLabelRequired=function invalidateLocalizableLabelRequired(e){const t=Liferay.ThemeDisplay.getDefaultLanguageId();if(!e)return!0;return!e[t]},t.invalidateRequired=function invalidateRequired(e){return!(null==e?void 0:e.trim())},t.useForm=function useForm({initialValues:e,onSubmit:t,validate:r}){const[a,o]=(0,n.useState)(e),[i,c]=(0,n.useState)({}),validateSubmit=()=>{const e=r(a);Object.keys(e).length?c(e):(c({}),t(a))};return{errors:i,handleChange:({target:{name:e,value:t}})=>o((r=>_objectSpread(_objectSpread({},r),{},{[e]:t}))),handleSubmit:e=>{e.preventDefault(),validateSubmit()},handleValidate:()=>{const e=r(a);return Object.keys(e).length?c(e):c({}),e},setValues:e=>o((t=>_objectSpread(_objectSpread({},t),e))),validateSubmit:validateSubmit,values:a}};var n=r("liferay!frontend-js-react-web$react");function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}}}));
//# sourceMappingURL=useForm.js.map