Liferay.Loader.define("dynamic-data-mapping-form-field-type@6.0.145/Validation/Validation",["module","exports","require","@frontend-taglib-clay$clayui/form","data-engine-js-components-web","liferay!frontend-js-react-web$react","../Checkbox/Checkbox","./ValidationDate","./ValidationTextAndNumeric","./transform","./validationReducer"],(function(e,a,t){window;{Object.defineProperty(a,"__esModule",{value:!0}),a.default=void 0;var n=_interopRequireDefault(t("@frontend-taglib-clay$clayui/form")),i=t("data-engine-js-components-web"),r=_interopRequireWildcard(t("liferay!frontend-js-react-web$react")),l=_interopRequireDefault(t("../Checkbox/Checkbox")),o=_interopRequireDefault(t("./ValidationDate")),d=_interopRequireDefault(t("./ValidationTextAndNumeric")),u=t("./transform"),c=_interopRequireWildcard(t("./validationReducer"));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 a=_getRequireWildcardCache();if(a&&a.has(e))return a.get(e);var t={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var r=n?Object.getOwnPropertyDescriptor(e,i):null;r&&(r.get||r.set)?Object.defineProperty(t,i,r):t[i]=e[i]}return t.default=e,a&&a.set(e,t),t}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _extends(){return(_extends=Object.assign||function(e){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function _objectWithoutProperties(e,a){if(null==e)return{};var t,n,i=function _objectWithoutPropertiesLoose(e,a){if(null==e)return{};var t,n,i={},r=Object.keys(e);for(n=0;n<r.length;n++)t=r[n],a.indexOf(t)>=0||(i[t]=e[t]);return i}(e,a);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n<r.length;n++)t=r[n],a.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}const e={date:o.default,numeric:d.default,string:d.default},Validation=a=>{var t;let{dataType:o,defaultLanguageId:d,editingLanguageId:f,enableValidation:s,errorMessage:g,label:p,localizationMode:b,name:v,onBlur:y,onChange:m,parameter:_,readOnly:h,selectedValidation:O,validation:V,validations:L,visible:j}=a,I=_objectWithoutProperties(a,["dataType","defaultLanguageId","editingLanguageId","enableValidation","errorMessage","label","localizationMode","name","onBlur","onChange","parameter","readOnly","selectedValidation","validation","validations","visible"]);const{focusedField:E}=(0,i.useFormState)(),w=null!==(t=null==V?void 0:V.fieldName)&&void 0!==t?t:null==E?void 0:E.fieldName,[{enableValidation:C,errorMessage:N,parameter:P,selectedValidation:R},T]=(0,r.useReducer)((0,c.default)({editingLanguageId:f,fieldName:w,onChange:m}),{enableValidation:s,errorMessage:g,parameter:_,selectedValidation:O}),D=e[(0,u.normalizeDataType)(o)],q=(0,u.getSelectedValidation)(L),x=(0,u.getLocalizedValue)({defaultLanguageId:d,editingLanguageId:f});return(0,r.useEffect)((()=>{!h&&j||T({payload:{enableValidation:!1},type:c.EVENT_TYPES.ENABLE_VALIDATION})}),[h,j]),r.default.createElement(n.default.Group,{className:"lfr-ddm-form-field-validation"},r.default.createElement(l.default,{label:p,name:"enableValidation",onChange:({target:{value:e}})=>{T({payload:{enableValidation:e,fieldName:null==V?void 0:V.fieldName},type:c.EVENT_TYPES.ENABLE_VALIDATION})},readOnly:h,showAsSwitcher:!0,value:C,visible:j}),C&&r.default.createElement(D,_extends({},I,{dataType:o,dispatch:T,errorMessage:N,localizationMode:b,localizedValue:x,name:v,onBlur:y,parameter:P,parentFieldName:w,readOnly:h,selectedValidation:R,transformSelectedValidation:q,validations:L,visible:j})))};var _default=e=>{let{dataType:a,defaultLanguageId:t,editingLanguageId:n,label:l,name:o,onBlur:d,onChange:c,readOnly:f,validation:s,value:g,visible:p}=e,b=_objectWithoutProperties(e,["dataType","defaultLanguageId","editingLanguageId","label","name","onBlur","onChange","readOnly","validation","value","visible"]);const{validations:v}=(0,i.useFormState)(),y=(0,u.transformData)({defaultLanguageId:t,editingLanguageId:n,initialDataType:a,validation:s,validations:v,value:g});return r.default.createElement(Validation,_extends({},b,y,{defaultLanguageId:t,editingLanguageId:n,label:l,name:o,onBlur:d,onChange:e=>c({target:{value:e}}),readOnly:f,validation:s,visible:p}))};a.default=_default}}));
//# sourceMappingURL=Validation.js.map