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