Liferay.Loader.define("dynamic-data-mapping-form-field-type@6.0.145/Validation/CustomDate",["module","exports","require","liferay!frontend-js-react-web$react","./CustomDate.scss","./DDMQuantity","./DDMSelect","./SelectDateType"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=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 n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var u=r?Object.getOwnPropertyDescriptor(e,n):null;u&&(u.get||u.set)?Object.defineProperty(a,n,u):a[n]=e[n]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react"));a("./CustomDate.scss");var n=_interopRequireDefault(a("./DDMQuantity")),u=_interopRequireDefault(a("./DDMSelect")),i=_interopRequireDefault(a("./SelectDateType"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function ownKeys(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,r)}return a}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(a),!0).forEach((function(t){_defineProperty(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):ownKeys(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function _defineProperty(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const e="plus",l="minus",o="customDate",d=[{label:Liferay.Language.get("plus"),value:e},{label:Liferay.Language.get("minus"),value:l}],c=[{label:Liferay.Language.get("days"),value:"days"},{label:Liferay.Language.get("months"),value:"months"},{label:Liferay.Language.get("years"),value:"years"}];var _default=({dateFieldOptions:t,eventType:a,onChange:f,options:s,parameters:p,readOnly:y})=>{const[g,m]=(0,r.useState)(p);function updateParameter(e){Object.entries(e).some((([e,t])=>g[e]!==t))&&(m((t=>_objectSpread(_objectSpread({},t),e))),f(e))}return(0,r.useEffect)((()=>{m(p)}),[p]),r.default.createElement(r.default.Fragment,null,r.default.createElement(i.default,{dateFieldName:g.dateFieldName,dateFieldOptions:t,label:Liferay.Language.get("date"),onChange:(e,t)=>updateParameter({date:e,dateFieldName:t}),options:s.filter((({name:e})=>e!==o)),type:g.date}),r.default.createElement("div",{className:"lfr-ddm__custom-date"},r.default.createElement(u.default,{className:"lfr_ddm__custom-date-select",disabled:y,label:Liferay.Language.get("operation"),name:"selectedOperation_".concat(a),onChange:({target:{value:t}})=>{if(t!==(g.quantity<0?l:e)){const e=-1*g.quantity;updateParameter({dateFieldName:g.dateFieldName,quantity:e})}},options:d,value:g.quantity<0?l:e}),r.default.createElement(n.default,{label:Liferay.Language.get("quantity"),name:"inputedQuantity_".concat(a),onQuantityChange:e=>{updateParameter({dateFieldName:g.dateFieldName,quantity:g.quantity<0?-1*e:e})},readOnly:y,value:Math.abs(g.quantity)}),r.default.createElement(u.default,{className:"lfr_ddm__custom-date-select",disabled:y,label:Liferay.Language.get("unit"),name:"selectedUnit_".concat(a),onChange:({target:{value:e}})=>updateParameter({dateFieldName:g.dateFieldName,unit:e}),options:c,value:g.unit})))};t.default=_default}}));
//# sourceMappingURL=CustomDate.js.map