import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["events","dateTimeView","locale","dropdownForm","dropdownClassName","dropdownRef","currentVisibleDate","onChangeCurrentVisibleDate","multiplicityHours","multiplicityMinutes","multiplicitySeconds","renderAdditionalControls","onDropdownOpen","dropdownOpen","ignoreOutsideClicksRefs","disabled","inputRef","disableDates"];import addMonths from"date-fns/addMonths";import startOfMonth from"date-fns/startOfMonth";import React,{forwardRef,useEffect,useRef}from"react";import{useClickOutside}from"../../../hooks/useClickOutside/useClickOutside";import{useForkRef}from"../../../hooks/useForkRef";import{setRef}from"../../../utils/setRef";import{DatePickerDropdown}from"../DatePickerDropdown/DatePickerDropdown";import{DatePickerFieldTypeDateTime}from"../DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime";import{datePickerPropFormatTypeDateTime,getDropdownZIndex,getMultiplicityTime}from"../helpers";import{useCalendarVisible}from"../useCalendarVisible";import{useCurrentVisibleDate}from"../useCurrentVisibleDate";export var DatePickerTypeDateTime=forwardRef(function(a,b){var c=a.events,d=a.dateTimeView,e=a.locale,f=a.dropdownForm,g=a.dropdownClassName,h=a.dropdownRef,i=a.currentVisibleDate,j=a.onChangeCurrentVisibleDate,k=a.multiplicityHours,l=a.multiplicityMinutes,m=a.multiplicitySeconds,n=a.renderAdditionalControls,o=a.onDropdownOpen,p=a.dropdownOpen,q=a.ignoreOutsideClicksRefs,r=a.disabled,s=a.inputRef,t=a.disableDates,u=_objectWithoutProperties(a,_excluded),v=getMultiplicityTime(u.format||datePickerPropFormatTypeDateTime,k,l,m),w=_slicedToArray(v,3),x=w[0],y=w[1],z=w[2],A=useRef(null),B=useRef(null),C=useRef(null),D=useCalendarVisible({dropdownOpen:p,onDropdownOpen:o,disabled:r,startRef:C}),E=_slicedToArray(D,2),F=E[0],G=E[1],H=useCurrentVisibleDate({currentVisibleDate:i,maxDate:a.maxDate,minDate:a.minDate,value:a.value,startOfUnit:startOfMonth,onChangeCurrentVisibleDate:j,calendarVisible:F}),I=_slicedToArray(H,2),J=I[0],K=I[1];return useEffect(function(){b&&setRef(b,A.current)},[b,A]),useEffect(function(){if(a.value&&"classic"===d&&J){var b=startOfMonth(a.value);return void(b.getTime()!==J.getTime()&&K(b))}if(a.value&&"classic"!==d&&J){var c=startOfMonth(a.value);c.getTime()!==J.getTime()&&c.getTime()!==addMonths(J,1).getTime()&&K(c)}},[a.value]),useClickOutside({isActive:F,ignoreClicksInsideRefs:[A,B].concat(_toConsumableArray(null!==q&&void 0!==q?q:[])),handler:G.off}),React.createElement(React.Fragment,null,React.createElement(DatePickerFieldTypeDateTime,Object.assign({},u,{ref:A,inputRef:useForkRef([C,s]),onClick:G.on,multiplicityHours:x,multiplicitySeconds:z,multiplicityMinutes:y,disabled:r})),React.createElement(DatePickerDropdown,{ref:useForkRef([h,B]),anchorRef:A,isOpen:F,value:a.value||void 0,type:"date-time",view:"classic",events:c,className:g,locale:e,minDate:a.minDate,maxDate:a.maxDate,currentVisibleDate:J,form:f,onChange:a.onChange,renderAdditionalControls:n,onChangeCurrentVisibleDate:K,multiplicityHours:x,multiplicitySeconds:z,multiplicityMinutes:y,zIndex:getDropdownZIndex(a.style),disableDates:t}))});
//# sourceMappingURL=DatePickerTypeDateTime.js.map