Liferay.Loader.define("@liferay/frontend-data-set-web@1.0.31/management_bar/components/filters/DateRangeFilter",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/drop-down","@frontend-taglib-clay$clayui/form","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../../utils/dates"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.getOdataString=t.getSelectedItemsLabel=void 0;var r=f(a("@frontend-taglib-clay$clayui/button")),l=f(a("@frontend-taglib-clay$clayui/drop-down")),o=f(a("@frontend-taglib-clay$clayui/form")),n=(f(a("liferay!frontend-js-react-web$prop-types")),function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=d();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 o=r?Object.getOwnPropertyDescriptor(e,l):null;o&&(o.get||o.set)?Object.defineProperty(a,l,o):a[l]=e[l]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react"))),c=a("../../../utils/dates");function d(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return d=function(){return e},e}function f(e){return e&&e.__esModule?e:{default:e}}const e=({selectedData:e})=>(0,c.formatDateRangeObject)(e);t.getSelectedItemsLabel=e;const u=({id:e,selectedData:t})=>{const{from:a,to:r}=t;return a&&r?"".concat(e," ge ").concat((0,c.convertObjectDateToIsoString)(a,"from"),") and (").concat(e," le ").concat((0,c.convertObjectDateToIsoString)(r,"to")):a?"".concat(e," ge ").concat((0,c.convertObjectDateToIsoString)(a,"from")):r?"".concat(e," le ").concat((0,c.convertObjectDateToIsoString)(r,"to")):void 0};t.getOdataString=u;var i=function({id:t,max:a,min:d,placeholder:f,selectedData:i,setFilter:m}){const[s,g]=(0,n.useState)((null==i?void 0:i.from)&&(0,c.formatDateObject)(i.from)),[y,p]=(0,n.useState)((null==i?void 0:i.to)&&(0,c.formatDateObject)(i.to));let b="edit";!i||s||y||(b="delete"),i||(b="add");let D=!0;return("delete"===b||(!i||!i.from)&&s||(!i||!i.to)&&y||i&&i.from&&s!==(0,c.formatDateObject)(i.from)||i&&i.to&&y!==(0,c.formatDateObject)(i.to))&&(D=!1),n.default.createElement(n.default.Fragment,null,n.default.createElement(l.default.Caption,null,n.default.createElement("div",{className:"form-group"},n.default.createElement(o.default.Group,{className:"form-group-sm"},n.default.createElement("label",{htmlFor:"from-".concat(t)},Liferay.Language.get("from")),n.default.createElement("input",{className:"form-control",id:"from-".concat(t),max:y||a&&(0,c.formatDateObject)(a),min:d&&(0,c.formatDateObject)(d),onChange:e=>g(e.target.value),pattern:"\\d{4}-\\d{2}-\\d{2}",placeholder:f||"yyyy-mm-dd",type:"date",value:s||""})),n.default.createElement(o.default.Group,{className:"form-group-sm mt-2"},n.default.createElement("label",{htmlFor:"to-".concat(t)},Liferay.Language.get("to")),n.default.createElement("input",{className:"form-control",id:"to-".concat(t),max:a&&(0,c.formatDateObject)(a),min:s||d&&(0,c.formatDateObject)(d),onChange:e=>p(e.target.value),pattern:"\\d{4}-\\d{2}-\\d{2}",placeholder:f||"yyyy-mm-dd",type:"date",value:y||""})))),n.default.createElement(l.default.Divider,null),n.default.createElement(l.default.Caption,null,n.default.createElement(r.default,{disabled:D,onClick:()=>{if("delete"===b)m({active:!1,id:t});else{const a={from:s?(0,c.getDateFromDateString)(s):null,to:y?(0,c.getDateFromDateString)(y):null};m({active:!0,id:t,odataFilterString:u({id:t,selectedData:a}),selectedData:a,selectedItemsLabel:e({selectedData:a})})}},small:!0},"add"===b&&Liferay.Language.get("add-filter"),"edit"===b&&Liferay.Language.get("edit-filter"),"delete"===b&&Liferay.Language.get("delete-filter"))))};t.default=i}}));
//# sourceMappingURL=DateRangeFilter.js.map