intelicoreact 1.6.22 → 1.6.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Atomic/FormElements/ActionAlert/ActionAlert.js +98 -1
- package/dist/Atomic/FormElements/AdvancedStatus/AdvancedStatus.js +48 -1
- package/dist/Atomic/FormElements/Calendar/Calendar.js +249 -1
- package/dist/Atomic/FormElements/Calendar/Calendar.props.js +4 -1
- package/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.js +65 -1
- package/dist/Atomic/FormElements/CheckboxesLine/CheckboxesLine.js +52 -1
- package/dist/Atomic/FormElements/Datepicker/Datepicker.js +424 -1
- package/dist/Atomic/FormElements/Datepicker/Datepicker.props.js +4 -1
- package/dist/Atomic/FormElements/Datepicker/components/DatepickerCalendar.js +173 -1
- package/dist/Atomic/FormElements/Datepicker/components/DatepickerCalendar.props.js +4 -1
- package/dist/Atomic/FormElements/Dropdown/Dropdown.js +735 -1
- package/dist/Atomic/FormElements/Dropdown/components/DropdownLoader.js +20 -1
- package/dist/Atomic/FormElements/DropdownLiveSearch/DropdownLiveSearch.js +529 -1
- package/dist/Atomic/FormElements/FileLoader/FileLoader.js +94 -1
- package/dist/Atomic/FormElements/FileLoader/partial/LoadZone.js +105 -1
- package/dist/Atomic/FormElements/FileLoader/partial/LoadedContent.js +67 -1
- package/dist/Atomic/FormElements/FileLoaderDescription/FileLoaderDescription.js +247 -1
- package/dist/Atomic/FormElements/FileLoaderLocal/FileLoaderLocal.js +160 -1
- package/dist/Atomic/FormElements/FileLoaderLocalGroup/FileLoaderLocalGroup.js +193 -1
- package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN.js +135 -1
- package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN_old.js +116 -1
- package/dist/Atomic/FormElements/Input/Input.js +467 -1
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +161 -1
- package/dist/Atomic/FormElements/InputColor/InputColor.js +64 -1
- package/dist/Atomic/FormElements/InputCurrency/InputCurrency.js +200 -1
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.js +354 -1
- package/dist/Atomic/FormElements/InputDateRange/components/DateInput.js +71 -1
- package/dist/Atomic/FormElements/InputDateRange/components/Datepicker.js +693 -1
- package/dist/Atomic/FormElements/InputDateRange/components/OpenedPart.js +254 -1
- package/dist/Atomic/FormElements/InputDateRange/components/SelectItem.js +32 -1
- package/dist/Atomic/FormElements/InputDateRange/dependencies.js +200 -1
- package/dist/Atomic/FormElements/InputLink/InputLink.js +99 -1
- package/dist/Atomic/FormElements/InputMask/InputCarretPosition.js +37 -1
- package/dist/Atomic/FormElements/InputMask/InputMask.js +1214 -1
- package/dist/Atomic/FormElements/InputMask/config.js +15 -1
- package/dist/Atomic/FormElements/InputMask/functions.js +58 -1
- package/dist/Atomic/FormElements/InputMask2/InputMask2.js +674 -1
- package/dist/Atomic/FormElements/InputMask2/config.js +15 -1
- package/dist/Atomic/FormElements/InputMask2/functions.js +58 -1
- package/dist/Atomic/FormElements/InputMask3/InputMask3.js +766 -1
- package/dist/Atomic/FormElements/InputMask3/config.js +15 -1
- package/dist/Atomic/FormElements/InputMask3/functions.js +58 -1
- package/dist/Atomic/FormElements/InputWithAction/InputWithAction.js +114 -1
- package/dist/Atomic/FormElements/InputsRow/InputsRow.js +140 -1
- package/dist/Atomic/FormElements/Label/Label.js +87 -1
- package/dist/Atomic/FormElements/MobileCalendar/MobileCalendar.js +506 -1
- package/dist/Atomic/FormElements/MultiSelect/MultiSelect.js +45 -1
- package/dist/Atomic/FormElements/NumericInput/NumericInput.js +331 -1
- package/dist/Atomic/FormElements/RadioGroup/RadioGroup.js +66 -1
- package/dist/Atomic/FormElements/RadioGroupWithInput/RadioGroupWithInput.js +80 -1
- package/dist/Atomic/FormElements/RadioInput/RadioInput.js +57 -1
- package/dist/Atomic/FormElements/RadioRowSwitcher/RadioRowSwitcher.js +54 -1
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.js +183 -1
- package/dist/Atomic/FormElements/RangeInputs/RangeInputs.js +222 -1
- package/dist/Atomic/FormElements/RangeList/RangeList.js +175 -1
- package/dist/Atomic/FormElements/RangeList/partial/RangeListRow.js +43 -1
- package/dist/Atomic/FormElements/RangeSlider/RangeSlider.js +443 -1
- package/dist/Atomic/FormElements/RangeSlider2/RangeSlider2.js +858 -1
- package/dist/Atomic/FormElements/SwitchableRow/SwitchableRow.js +39 -1
- package/dist/Atomic/FormElements/Switcher/Switcher.js +59 -1
- package/dist/Atomic/FormElements/SwitcherCheckbox/SwitcherCheckbox.js +50 -1
- package/dist/Atomic/FormElements/SwitcherHide/SwitcherHide.js +44 -1
- package/dist/Atomic/FormElements/SwitcherRadio/SwitcherRadio.js +100 -1
- package/dist/Atomic/FormElements/SwitcherRange/SwitcherRange.js +52 -1
- package/dist/Atomic/FormElements/SwitcherRangeList/SwitcherRangeList.js +64 -1
- package/dist/Atomic/FormElements/SwitcherTagsDropdown/SwitcherTagsDropdown.js +170 -1
- package/dist/Atomic/FormElements/SwitcherTagsDropdown/partial/States.js +202 -1
- package/dist/Atomic/FormElements/SwitcherTextarea/SwitcherTextarea.js +67 -1
- package/dist/Atomic/FormElements/TagListToDropdown/TagListToDropdown.js +115 -1
- package/dist/Atomic/FormElements/TagsDropdown/TagsDropdown.interface.ts +2 -2
- package/dist/Atomic/FormElements/TagsDropdown/TagsDropdown.js +1110 -1
- package/dist/Atomic/FormElements/Text/Text.js +125 -1
- package/dist/Atomic/FormElements/TextSwitcher/TextSwitcher.js +49 -1
- package/dist/Atomic/FormElements/Textarea/Textarea.js +80 -1
- package/dist/Atomic/FormElements/TieredCheckboxes/TieredCheckboxes.js +176 -1
- package/dist/Atomic/FormElements/TieredCheckboxes/partial/AccordionWithCheckbox.js +62 -1
- package/dist/Atomic/FormElements/TimeRange/TimeRange.js +119 -1
- package/dist/Atomic/FormElements/UserContacts/UserContacts.js +188 -1
- package/dist/Atomic/FormElements/VariantsListRadio/VariantsListRadio.js +83 -1
- package/dist/Atomic/FormElements/VariantsListRadio/partials/VariantsListRadioItem.js +82 -1
- package/dist/Atomic/FormElements/WidgetPseudoTable/WidgetPseudoTable.js +101 -1
- package/dist/Atomic/FormElements/WidgetPseudoTable/partial/constructor.js +29 -1
- package/dist/Atomic/FormElements/WidgetWithSwitchableRows/WidgetWithSwitchableRows.js +113 -1
- package/dist/Atomic/FormElements/WidgetWithSwitchableRows/partial/constructor.js +30 -1
- package/dist/Atomic/Layout/Header/Header.js +85 -1
- package/dist/Atomic/Layout/Spinner/Spinner.js +44 -1
- package/dist/Atomic/UI/Accordion/Accordion.js +108 -1
- package/dist/Atomic/UI/Accordion/AccordionItem.js +176 -1
- package/dist/Atomic/UI/AccordionTable/AccordionTable.js +238 -1
- package/dist/Atomic/UI/AccordionText/AccordionText.js +69 -1
- package/dist/Atomic/UI/AdvancedTag/AdvTag.js +207 -1
- package/dist/Atomic/UI/AdvancedTag/AdvancedTags.js +56 -1
- package/dist/Atomic/UI/Alert/Alert.js +72 -1
- package/dist/Atomic/UI/Arrow/Arrow.js +132 -1
- package/dist/Atomic/UI/Box/Box.js +52 -1
- package/dist/Atomic/UI/Button/Button.js +47 -1
- package/dist/Atomic/UI/ButtonsBar/ButtonsBar.js +72 -1
- package/dist/Atomic/UI/Chart/Chart.js +172 -1
- package/dist/Atomic/UI/Chart/partial/Chart.constants.js +95 -1
- package/dist/Atomic/UI/Chart/partial/ChartTypeSwitcherIcon/ChartTypeSwitcherIcon.js +80 -1
- package/dist/Atomic/UI/Chart/partial/datasetSetters.js +188 -1
- package/dist/Atomic/UI/Chart/partial/optionsConstructor.js +335 -1
- package/dist/Atomic/UI/Chart/partial/optionsSetters.js +43 -1
- package/dist/Atomic/UI/Chart/partial/utils.js +60 -1
- package/dist/Atomic/UI/CircleProgressBar/CircleProgressBar.js +109 -1
- package/dist/Atomic/UI/DateTime/DateTime.js +57 -1
- package/dist/Atomic/UI/DebugContainer/DebugContainer.js +44 -1
- package/dist/Atomic/UI/DebugContainer/useDebugContainer.js +15 -1
- package/dist/Atomic/UI/DoubleString/DoubleString.js +102 -1
- package/dist/Atomic/UI/DynamicIcon/DynamicIcon.js +70 -1
- package/dist/Atomic/UI/ExampleChartIntegration/ExampleChartIntegration.js +221 -1
- package/dist/Atomic/UI/ExampleChartIntegration/partial/utils.js +106 -1
- package/dist/Atomic/UI/Hint/Hint.js +256 -1
- package/dist/Atomic/UI/Hint/partials/_utils.js +64 -1
- package/dist/Atomic/UI/Modal/Modal.js +179 -1
- package/dist/Atomic/UI/Modal/ModalHOC.js +97 -1
- package/dist/Atomic/UI/Modal/partials/ModalFooter.js +71 -1
- package/dist/Atomic/UI/Modal/partials/ModalTitle.js +110 -1
- package/dist/Atomic/UI/Modal/partials/useMobileModal.js +192 -1
- package/dist/Atomic/UI/MonoAccordion/MonoAccordion._test.js +75 -1
- package/dist/Atomic/UI/MonoAccordion/MonoAccordion.js +80 -1
- package/dist/Atomic/UI/NavLine/NavLine.js +317 -1
- package/dist/Atomic/UI/PageTitle/PageTitle.js +77 -1
- package/dist/Atomic/UI/PieChart/PieChart.js +42 -1
- package/dist/Atomic/UI/Price/Price.js +31 -1
- package/dist/Atomic/UI/PriceRange/PriceRange.js +44 -1
- package/dist/Atomic/UI/ProgressLine/ProgressLine.js +98 -1
- package/dist/Atomic/UI/Status/Status.js +67 -1
- package/dist/Atomic/UI/Table/Partials/TdCell.js +87 -1
- package/dist/Atomic/UI/Table/Partials/TdHeader.js +38 -1
- package/dist/Atomic/UI/Table/Partials/TdRow.js +99 -1
- package/dist/Atomic/UI/Table/Partials/TdTitle.js +52 -1
- package/dist/Atomic/UI/Table/Table.js +63 -1
- package/dist/Atomic/UI/Table/TdTypes/TdActions.js +80 -1
- package/dist/Atomic/UI/Table/TdTypes/TdPriority.js +28 -1
- package/dist/Atomic/UI/Table/TdTypes/TdRange.js +13 -1
- package/dist/Atomic/UI/Table/TdTypes/TdWeight.js +53 -1
- package/dist/Atomic/UI/Tag/Tag.js +167 -1
- package/dist/Atomic/UI/TagList/TagList.js +251 -1
- package/dist/Atomic/UI/UserBox/UserBox.js +86 -1
- package/dist/Atomic/UI/WizardStepper/constructor.js +84 -1
- package/dist/Atomic/UI/WizardStepper/index.js +3 -1
- package/dist/Atomic/UI/WizardStepper/ui/StateIcon/StateIcon.js +37 -1
- package/dist/Atomic/UI/WizardStepper/ui/StateIcon/index.js +3 -1
- package/dist/Atomic/UI/WizardStepper/ui/StepRow/StepRow.js +61 -1
- package/dist/Atomic/UI/WizardStepper/ui/StepRow/index.js +3 -1
- package/dist/Atomic/UI/WizardStepper/ui/StepWrapper/StepWrapper.js +39 -1
- package/dist/Atomic/UI/WizardStepper/ui/StepWrapper/index.js +3 -1
- package/dist/Atomic/UI/WizardStepper/ui/icons.js +49 -1
- package/dist/Atomic/UI/WizardStepper/ui/index.js +3 -1
- package/dist/Classes/AbortableFetch.js +454 -1
- package/dist/Classes/AnimatedHandler.js +47 -1
- package/dist/Classes/RESTAPI/index.js +228 -1
- package/dist/Classes/RESTAPI/partials/AbortableFetch.js +457 -1
- package/dist/Classes/RESTAPI/partials/ApiBase.js +48 -1
- package/dist/Classes/RESTAPI/partials/ApiRequestCreators.js +112 -1
- package/dist/Classes/RESTAPI/partials/ApiUtils.js +189 -1
- package/dist/Classes/RESTAPI/partials/CredentialsProcessing.js +252 -1
- package/dist/Classes/RESTAPI/partials/Utils.js +92 -1
- package/dist/Classes/RESTAPI/partials/_outerDependencies.js +3 -1
- package/dist/Classes/RESTAPI/partials/_utils.js +197 -1
- package/dist/Constants/index.constants.js +78 -1
- package/dist/Functions/Portal.js +22 -1
- package/dist/Functions/customEventListener.js +96 -1
- package/dist/Functions/dateTime.js +149 -1
- package/dist/Functions/fieldValueFormatters.js +405 -1
- package/dist/Functions/guards/assertions.js +294 -1
- package/dist/Functions/guards/safeValue.js +75 -1
- package/dist/Functions/guards/typeGuards.js +373 -1
- package/dist/Functions/hooks/useFormFieldsChangesManager.js +95 -1
- package/dist/Functions/locale/createTranslator.js +32 -1
- package/dist/Functions/operations.js +130 -1
- package/dist/Functions/presets/inputMaskPresets.js +170 -1
- package/dist/Functions/presets/inputPresets.js +60 -1
- package/dist/Functions/presets/mobileKeyboardTypesPresets.js +45 -1
- package/dist/Functions/schemas.js +31 -1
- package/dist/Functions/useBodyScrollLock.js +17 -1
- package/dist/Functions/useClickOutside.js +15 -1
- package/dist/Functions/useDebounce.js +17 -1
- package/dist/Functions/useFieldFocus.js +84 -1
- package/dist/Functions/useFormTools/form-drivers/ArrayWithObjects.js +39 -1
- package/dist/Functions/useFormTools/form-drivers/ObjectWithIterableObjects.js +159 -1
- package/dist/Functions/useFormTools/form-drivers/ObjectWithNamedKeyObjects.js +78 -1
- package/dist/Functions/useFormTools/functions/General.js +134 -1
- package/dist/Functions/useFormTools/functions/RenderFields.js +111 -1
- package/dist/Functions/useFormTools/functions/usePrevious.js +12 -1
- package/dist/Functions/useFormTools/index.js +778 -1
- package/dist/Functions/useInputHighlightError.js +67 -1
- package/dist/Functions/useIsMobile/useIsMobile.js +33 -1
- package/dist/Functions/useKeyPress/useHandleKeyPress.js +52 -1
- package/dist/Functions/useKeyPress/useKeyPress.js +52 -1
- package/dist/Functions/useLocalStorage.js +34 -1
- package/dist/Functions/useLocationParams.js +27 -1
- package/dist/Functions/useMediaQuery.js +17 -1
- package/dist/Functions/useMetaInfo.js +43 -1
- package/dist/Functions/useMouseUpOutside.js +16 -1
- package/dist/Functions/useOnlineStatus.js +29 -1
- package/dist/Functions/usePasswordChecker.js +110 -1
- package/dist/Functions/usePrevious.js +12 -1
- package/dist/Functions/useResize.js +31 -1
- package/dist/Functions/useScrollTo.js +17 -1
- package/dist/Functions/useToggle.js +17 -1
- package/dist/Functions/utils.js +522 -1
- package/dist/Langs.js +168 -1
- package/dist/Molecular/CustomIcons/components/AffiliateNetworks.js +21 -1
- package/dist/Molecular/CustomIcons/components/AlertCircle.js +23 -1
- package/dist/Molecular/CustomIcons/components/AppStore.js +29 -1
- package/dist/Molecular/CustomIcons/components/Arrow.js +32 -1
- package/dist/Molecular/CustomIcons/components/ArrowDown.js +17 -1
- package/dist/Molecular/CustomIcons/components/ArrowLeft.js +22 -1
- package/dist/Molecular/CustomIcons/components/ArrowRight.js +22 -1
- package/dist/Molecular/CustomIcons/components/ArrowUp.js +17 -1
- package/dist/Molecular/CustomIcons/components/Bell.js +15 -1
- package/dist/Molecular/CustomIcons/components/Button.js +12 -1
- package/dist/Molecular/CustomIcons/components/Campaigns.js +16 -1
- package/dist/Molecular/CustomIcons/components/Check.js +14 -1
- package/dist/Molecular/CustomIcons/components/Check2.js +12 -1
- package/dist/Molecular/CustomIcons/components/ChevronDown.js +12 -1
- package/dist/Molecular/CustomIcons/components/ChevronDownDisabled.js +11 -1
- package/dist/Molecular/CustomIcons/components/ChevronLeft.js +11 -1
- package/dist/Molecular/CustomIcons/components/ChevronRight.js +11 -1
- package/dist/Molecular/CustomIcons/components/ChevronUp.js +11 -1
- package/dist/Molecular/CustomIcons/components/ChevronUpDown.js +27 -1
- package/dist/Molecular/CustomIcons/components/Close.js +14 -1
- package/dist/Molecular/CustomIcons/components/ColumnsOrder.js +17 -1
- package/dist/Molecular/CustomIcons/components/Delete.js +16 -1
- package/dist/Molecular/CustomIcons/components/Edit.js +15 -1
- package/dist/Molecular/CustomIcons/components/Email.js +31 -1
- package/dist/Molecular/CustomIcons/components/FinturfLogo.js +18 -1
- package/dist/Molecular/CustomIcons/components/FinturfLogo2.js +35 -1
- package/dist/Molecular/CustomIcons/components/Flows.js +15 -1
- package/dist/Molecular/CustomIcons/components/Gift.js +25 -1
- package/dist/Molecular/CustomIcons/components/GoogleAuth.js +29 -1
- package/dist/Molecular/CustomIcons/components/GooglePlay.js +29 -1
- package/dist/Molecular/CustomIcons/components/HelpCircle.js +19 -1
- package/dist/Molecular/CustomIcons/components/HelpCircle2.js +20 -1
- package/dist/Molecular/CustomIcons/components/HelpCircleFilled.js +19 -1
- package/dist/Molecular/CustomIcons/components/Home.js +16 -1
- package/dist/Molecular/CustomIcons/components/Home2.js +22 -1
- package/dist/Molecular/CustomIcons/components/Key.js +23 -1
- package/dist/Molecular/CustomIcons/components/Landers.js +20 -1
- package/dist/Molecular/CustomIcons/components/Lock.js +15 -1
- package/dist/Molecular/CustomIcons/components/Mail.js +26 -1
- package/dist/Molecular/CustomIcons/components/Mastercard.js +73 -1
- package/dist/Molecular/CustomIcons/components/Minus.js +25 -1
- package/dist/Molecular/CustomIcons/components/Offers.js +16 -1
- package/dist/Molecular/CustomIcons/components/Pause.js +28 -1
- package/dist/Molecular/CustomIcons/components/PayPal.js +41 -1
- package/dist/Molecular/CustomIcons/components/PayPalLightLarge.js +28 -1
- package/dist/Molecular/CustomIcons/components/Phone.js +30 -1
- package/dist/Molecular/CustomIcons/components/Play.js +25 -1
- package/dist/Molecular/CustomIcons/components/Plus.js +25 -1
- package/dist/Molecular/CustomIcons/components/Profile.js +16 -1
- package/dist/Molecular/CustomIcons/components/QRCode.js +29 -1
- package/dist/Molecular/CustomIcons/components/Rectangle.js +12 -1
- package/dist/Molecular/CustomIcons/components/Revert.js +13 -1
- package/dist/Molecular/CustomIcons/components/Star.js +14 -1
- package/dist/Molecular/CustomIcons/components/Star2.js +16 -1
- package/dist/Molecular/CustomIcons/components/TrafficSources.js +14 -1
- package/dist/Molecular/CustomIcons/components/Trash.js +15 -1
- package/dist/Molecular/CustomIcons/components/TrashRed.js +15 -1
- package/dist/Molecular/CustomIcons/components/Triggers.js +15 -1
- package/dist/Molecular/CustomIcons/components/User.js +25 -1
- package/dist/Molecular/CustomIcons/components/Visa.js +31 -1
- package/dist/Molecular/CustomIcons/components/X.js +12 -1
- package/dist/Molecular/CustomIcons/index.js +61 -1
- package/dist/Molecular/FormElement/FormElement.js +54 -1
- package/dist/Molecular/FormWithDependOn/FormWithDependOn.js +184 -1
- package/dist/Molecular/FormWithDependOn/partials/_utils.js +53 -1
- package/dist/Molecular/InputAddress/InputAddress.js +626 -1
- package/dist/Molecular/InputPassword/InputPassword.js +48 -1
- package/dist/index.js +104 -1
- package/package.json +1 -1
- package/dist/Molecular/InputAddress/InputAddress.d.ts +0 -26
- package/dist/Molecular/InputAddress/InputAddress.js.map +0 -1
|
@@ -1 +1,693 @@
|
|
|
1
|
-
function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,r=Array(e);a<e;a++)r[a]=t[a];return r}function e(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var a,r,n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i=[],o=!0,d=!1;try{for(n=n.call(t);!(o=(a=n.next()).done)&&(i.push(a.value),!e||i.length!==e);o=!0);}catch(t){d=!0,r=t}finally{try{o||null==n.return||n.return()}finally{if(d)throw r}}return i}}(t,e)||r(t,e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||r(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,a){if(e){if("string"==typeof e)return t(e,a);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return t(e,a)}}import{jsx as n,jsxs as i,Fragment as o}from"react/jsx-runtime";import{useEffect as d,useMemo as u,useRef as c,useState as s}from"react";import l from"classnames";import m from"moment-timezone";import p from"../../../UI/Button/Button";import f from"../../Dropdown/Dropdown";import h from"../../RangeCalendar/RangeCalendar";import v from"../../Switcher/Switcher";import{MAIN_FORMAT as _,MAIN_TIME_FORMAT as y,getActualDateRange as D,getIsDateValid as b}from"../dependencies";import k from"./DateInput";var I={handleHoverTimerId:null},N=function(t){return"".concat(t.toString().padStart(2,"0"),":00")};export default function(t){var r,g,S,C=t.txt,O=t.className,A=t.buttonsTypes,w=void 0===A?{}:A,M=t.values,x=void 0===M?{}:M,P=t.onChange,T=t.onChangeMobile,B=t.onChangeCompare,L=t.onCancel,j=t.getSelectedMode,F=t.onChangeInterval,H=t.isCompareHidden,R=t.limitRange,U=(t.handleItemClick,t.setActiveInterval),Y=t.isShortWeekNames,K=t.minDate,W=t.maxDate,E=t.momentMinDate,z=t.momentMaxDate,V=t.isDontLimitFuture,$=t.testId,q=t.mainId,G=t.withMobileLogic,J=t.isDoNotPullOutListOfMainContainer,Q=x.start,X=void 0===Q?null:Q,Z=x.end,tt=void 0===Z?null:Z,te=x.compare,ta=c(null),tr=c(null),tn=e(s(b(X)?m(X):""),2),ti=tn[0],to=tn[1],td=e(s(b(tt)?m(tt):""),2),tu=td[0],tc=td[1],ts=j({start:ti,end:tu}),tl=e(s(null),2),tm=tl[0],tp=tl[1],tf=e(s(null),2),th=tf[0],tv=tf[1],t_=e(s(!1),2),ty=t_[0],tD=t_[1],tb=e(s(!1),2),tk=tb[0],tI=tb[1],tN=e(s(X?m(X).hour():0),2),tg=tN[0],tS=tN[1],tC=e(s(tt?m(tt).hour():0),2),tO=tC[0],tA=tC[1],tw=e(s(void 0!==te&&te),2),tM=tw[0],tx=tw[1],tP=e(s(X?m(X):m().subtract(1,"month")),2),tT=tP[0],tB=tP[1],tL=e(s(tt?m(tt):m()),2),tj=tL[0],tF=tL[1],tH=e(s(null),2),tR=(tH[0],tH[1]),tU=u(function(){return m(tj).subtract(1,"month").isSame(m(tT),"month")},[tT,tj]),tY=u(function(){return tM&&!H&&ti&&tu},[ti,tu,tM]),tK=c(tO),tW=u(function(){if(!tY)return null;var t=m(tu).diff(ti,"hours");return m(ti).subtract(t,"hours").toDate()},[ti,tu,tM]),tE=u(function(){return tY?ti:null},[ti,tu,tM]),tz=u(function(){return tM&&!H&&ti&&tu?"".concat(m(tW).format("ll")," (").concat(m(tW).format(y),") - ").concat(m(tE).format("ll")," (").concat(m(tE).format(y),")"):""},[ti,tu,tM]),tV=function(t,e){var a;return"startDateInput"===t?m(e):(a=m(e),0===tO?m(a).subtract(1,"days"):m(a))},t$=function(){U(D({start:ti,end:tu}).intervalKey)},tq=function(t){tK.current=0,!ti||ti&&tu&&!(m(ti).add(1,"d").isSame(tu,"day")&&0===tO)?(to(m(t).startOf("day")),tc(m(t).add(1,"d").startOf("day")),tS(0),tA(0)):m(t).isBefore(m(ti),"day")?(tc(m(ti).add(1,"d").startOf("day")),to(m(t).set("hour",parseInt(tg,10)))):m(t).isAfter(m(ti),"day")&&tc(m(t).add(1,"d").startOf("day")),tR(null)},tG=function(t){if(I.handleHoverTimerId&&clearTimeout(I.handleHoverTimerId),!t){I.handleHoverTimerId=setTimeout(function(){tR(null)},400);return}m(ti).add(1,"d").isSame(tu,"day")&&0===tO?m(t).isAfter(m(ti),"day")?tR("end"):m(t).isBefore(m(ti),"day")?tR("start"):tR(null):tR("start")},tJ=function(t){tS(Number(t)),to(m(ti||m()).set("hour",Number(t)))},tQ=function(t){var e=Number(t);tA(e);var a=m();tu&&(0===tK.current&&0!==e?a=m(tu).subtract(1,"days"):0!==tK.current&&0===e&&(a=m(tu).add(1,"days"))),tK.current=e,tc(m(a).set("hour",e))},tX=function(t,e){var a="startDateInput"===t?tD:tI,r="startDateInput"===t?tp:tv,n="startDateInput"===t?ti:tu;a(!0),r(n?tV(t,n).format("L"):""),setTimeout(function(){var a,r="startDateInput"===t?ta.current:tr.current;(null!=(a=null==e?void 0:e.target)?a:r).select()},0)},tZ=function(t,e){e.target.blur(),("startDateInput"===t?tD:tI)(!1)},t0=function(t,e,a){var r=m(t,"MM/DD/YYYY");if(!r.isValid())return e;var n,i,o=m().endOf("day"),d="startDateInput"===a?tg:tO;return i=K&&r.isBefore(E)?E:W&&r.isAfter(z)?z:!V&&r.isAfter(o)?o.startOf("day"):r,"endDateInput"===a&&(n=i,i=0===tO?m(n).add(1,"days"):m(n)),i.set("hour",parseInt(d,10))},t1=function(t,e){var a,r,n="startDateInput"===t?tm:th,i="startDateInput"===t?ti:tu,o="startDateInput"===t?to:tc,d="startDateInput"===t?tB:tF,u=t0(null!=(r=null==e||null==(a=e.target)?void 0:a.value)?r:n,i,t);o(u),d("endDateInput"===t?u:m(u).isSameOrAfter(m(tj),"month")?m(tj).subtract(1,"month"):m(u)),tZ(t,e)},t2=function(t,e,a){13===t&&t1(a,e),27===t&&tZ(a,e)},t3=function(){var t;return i(o,{children:[(null==C||null==(t=C.labels)?void 0:t.previousPeriod)||"",":"," ",n("span",{className:"date-picker__previous-period-interval",children:tz})]})};d(function(){m(ti).isSameOrAfter(tu)&&(to(m(tu).subtract(1,"d")),tB(m(tu).subtract(1,"d")))},[ti]),d(function(){m(tu).isSameOrBefore(ti)&&(tc(m(ti).add(1,"d")),tF(m(ti).add(1,"d")))},[tu]),d(function(){m(ti).isBefore(m(tu),"month")&&(tB(m(ti)),tF(m(tu))),t$()},[ti,tu]),d(function(){m(tT).isSameOrAfter(m(tj),"month")&&!G&&tB(m(tj).subtract(1,"month"))},[tT,tj]),d(function(){F(ts)},[ts]),d(function(){"function"==typeof T&&T({start:m(ti).format(_),end:m(tu).format(_),startPrevDate:m(tW).format(_),endPrevDate:m(tE).format(_),compare:tM})},[ti,tu,tW,tE,tM]);var t4=function(){return i("div",{className:"date-picker__date-row",children:[n(k,{ref:ta,testId:"datepicker-".concat($,"_start-date-input"),RC:"date-picker__date-input",className:l("date-picker__date-input"),isFocused:ty,value:tm,date:tV("startDateInput",ti),disabled:!ti,onChange:tp,onFocus:function(t){return tX("startDateInput",t)},onBlur:function(t){return t1("startDateInput",t)},onKeyUp:function(t,e){return t2(t,e,"startDateInput")}}),n(f,{testId:$,id:"datepicker-id-".concat(q,"_start-hour-select-input"),dataTest:"datepicker_start-hour-select-input",className:l("date-picker__hour-select-input"),onChange:function(t){return tJ(t)},value:tg,options:a(Array(24).keys()).map(function(t){return{label:N(t),value:t,disabled:m(ti).isSame(tu,"day")&&tO<=t}}),disabled:!ti,isDoNotPullOutListOfMainContainer:J,short:!0,withMobileLogic:G})]})},t8=function(){return i("div",{className:"date-picker__date-row",children:[n(k,{ref:tr,testId:"datepicker-".concat($,"_start-date-input"),RC:"date-picker__date-input",className:l("date-picker__date-input"),isFocused:tk,value:th,date:tV("endDateInput",tu),disabled:!tu,onChange:tv,onFocus:function(t){return tX("endDateInput",t)},onBlur:function(t){return t1("endDateInput",t)},onKeyUp:function(t,e){return t2(t,e,"endDateInput")}}),n(f,{testId:$,id:"datepicker-id-".concat(q,"_end-hour-select-input"),dataTest:"datepicker_end-hour-select-input",className:l("date-picker__hour-select-input"),onChange:function(t){return tQ(t)},value:tO,options:a(Array(24).keys()).map(function(t){return{label:N(t+1),value:23===t?0:t+1,disabled:(m(ti).isSame(tu,"day")||m(ti).isSame(m(tu).subtract(1,"days"),"day")&&0===tO)&&t<tg}}),disabled:!tu,isDoNotPullOutListOfMainContainer:J,short:!0,withMobileLogic:G})]})},t5=function(){return n(h,{testId:$,className:"date-picker__calendar",date:tT,setDate:tB,allowNext:G?!m(tT).startOf("month").isSameOrAfter(m().startOf("day"),"months"):!tU,startDate:ti,endDate:tu,startPrevDate:tW,endPrevDate:tE,onClick:tq,onHover:tG,limitRange:R,isShortWeekNames:Y,minDate:K,maxDate:W,momentMinDate:E,momentMaxDate:z})};return G?i("div",{className:l("date-picker",O),children:[i("div",{className:"date-picker__header",children:[i("div",{className:"date-picker__inputs-block",children:[t4(),n("div",{className:"date-picker__inputs-separator date-picker__header--gray",children:"—"}),t8()]}),tM&&!H&&ti&&tu&&n("div",{className:"date-picker__previous-period",children:t3()})]}),n("div",{className:"date-picker__calendars",children:n("div",{className:"date-picker__calendars-wrapper",children:t5()})})]}):i("div",{className:l("date-picker",O),children:[i("div",{className:"date-picker__header",children:[i("div",{className:"date-picker__inputs-block",children:[t4(),n("div",{className:"date-picker__inputs-separator date-picker__header--gray",children:"—"}),t8()]}),tM&&!H&&ti&&tu&&n("div",{className:"date-picker__previous-period",children:t3()})]}),n("div",{className:"date-picker__calendars",children:i("div",{className:"date-picker__calendars-wrapper",children:[t5(),n(h,{className:"date-picker__calendar",date:tj,setDate:tF,allowPrev:!tU,startDate:ti,endDate:tu,startPrevDate:tW,endPrevDate:tE,onClick:tq,onHover:tG,isShortWeekNames:Y,minDate:K,maxDate:W,momentMinDate:E,momentMaxDate:z,isDontLimitFuture:V})]})}),i("div",{className:l("date-picker__footer",{"date-picker__footer_once-element":H}),children:[H?n("div",{}):n("div",{className:"date-picker__compare-block",children:n("div",{className:"mr5",children:n(v,{dataTest:"datepicker_compare",label:(null==C||null==(S=C.labels)?void 0:S.compare)||"Compare",isSwitchOn:tM,onChange:function(){B(!tM),tx(function(t){return!t})}})})}),n("div",{className:"date-picker__buttons-block",children:i(o,{children:[n(p,{className:"date-picker__button",onClick:function(){return L()},variant:null==w?void 0:w.cancel,children:(null==C||null==(r=C.buttons)?void 0:r.cancel)||"Cancel"}),n(p,{className:"date-picker__button",variant:null==w?void 0:w.apply,disabled:!ti||!tu,onClick:function(){return P({start:m(ti).format(_),end:m(tu).format(_),startPrevDate:m(tW).format(_),endPrevDate:m(tE).format(_),compare:tM})},children:(null==C||null==(g=C.buttons)?void 0:g.apply)||"apply"})]})})]})]})}
|
|
1
|
+
// eslint-disable-next-line no-unused-vars
|
|
2
|
+
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
|
|
4
|
+
import cn from "classnames";
|
|
5
|
+
import moment from "moment-timezone";
|
|
6
|
+
|
|
7
|
+
import Btn from "../../../UI/Button/Button";
|
|
8
|
+
import SelectInput from "../../Dropdown/Dropdown";
|
|
9
|
+
import Calendar from "../../RangeCalendar/RangeCalendar";
|
|
10
|
+
import Switcher from "../../Switcher/Switcher";
|
|
11
|
+
import {
|
|
12
|
+
MAIN_FORMAT,
|
|
13
|
+
MAIN_TIME_FORMAT,
|
|
14
|
+
getActualDateRange,
|
|
15
|
+
getIsDateValid,
|
|
16
|
+
} from "../dependencies";
|
|
17
|
+
|
|
18
|
+
import DateInput from "./DateInput";
|
|
19
|
+
|
|
20
|
+
const outsideScope = {
|
|
21
|
+
handleHoverTimerId: null,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const DATE_INPUT_FORMAT = "MM/DD/YYYY";
|
|
25
|
+
|
|
26
|
+
const padTime = (time) => {
|
|
27
|
+
return `${time.toString().padStart(2, "0")}:00`;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const Datepicker = (props) => {
|
|
31
|
+
const {
|
|
32
|
+
txt,
|
|
33
|
+
className,
|
|
34
|
+
buttonsTypes = {},
|
|
35
|
+
values = {},
|
|
36
|
+
onChange,
|
|
37
|
+
onChangeMobile,
|
|
38
|
+
onChangeCompare,
|
|
39
|
+
onCancel,
|
|
40
|
+
getSelectedMode,
|
|
41
|
+
onChangeInterval,
|
|
42
|
+
isCompareHidden,
|
|
43
|
+
limitRange,
|
|
44
|
+
handleItemClick,
|
|
45
|
+
setActiveInterval,
|
|
46
|
+
isShortWeekNames,
|
|
47
|
+
minDate,
|
|
48
|
+
maxDate,
|
|
49
|
+
momentMinDate,
|
|
50
|
+
momentMaxDate,
|
|
51
|
+
isDontLimitFuture,
|
|
52
|
+
testId,
|
|
53
|
+
mainId,
|
|
54
|
+
withMobileLogic,
|
|
55
|
+
isDoNotPullOutListOfMainContainer,
|
|
56
|
+
} = props;
|
|
57
|
+
const { start = null, end = null, compare = false } = values;
|
|
58
|
+
console.log('isDoNotPullOutListOfMainContainer', isDoNotPullOutListOfMainContainer)
|
|
59
|
+
|
|
60
|
+
const startDateInputRef = useRef(null);
|
|
61
|
+
const endDateInputRef = useRef(null);
|
|
62
|
+
|
|
63
|
+
const [startDate, setStartDate] = useState(
|
|
64
|
+
getIsDateValid(start) ? moment(start) : "",
|
|
65
|
+
);
|
|
66
|
+
const [endDate, setEndDate] = useState(
|
|
67
|
+
getIsDateValid(end) ? moment(end) : "",
|
|
68
|
+
);
|
|
69
|
+
const dateInterval = getSelectedMode({ start: startDate, end: endDate });
|
|
70
|
+
|
|
71
|
+
const [startDateInput, setStartDateInput] = useState(null);
|
|
72
|
+
const [endDateInput, setEndDateInput] = useState(null);
|
|
73
|
+
const [isStartFocused, setIsStartFocused] = useState(false);
|
|
74
|
+
const [isEndFocused, setIsEndFocused] = useState(false);
|
|
75
|
+
|
|
76
|
+
const [startHour, setStartHour] = useState(start ? moment(start).hour() : 0);
|
|
77
|
+
const [endHour, setEndHour] = useState(end ? moment(end).hour() : 0);
|
|
78
|
+
|
|
79
|
+
// eslint-disable-next-line no-unused-vars
|
|
80
|
+
const [isCompare, setIsCompare] = useState(compare);
|
|
81
|
+
|
|
82
|
+
const [date1, setDate1] = useState(
|
|
83
|
+
start ? moment(start) : moment().subtract(1, "month"),
|
|
84
|
+
);
|
|
85
|
+
const [date2, setDate2] = useState(end ? moment(end) : moment());
|
|
86
|
+
|
|
87
|
+
const [hoverStatus, setHoverStatus] = useState(null);
|
|
88
|
+
|
|
89
|
+
// ********************
|
|
90
|
+
// Constants
|
|
91
|
+
// ********************
|
|
92
|
+
|
|
93
|
+
const isNearby = useMemo(
|
|
94
|
+
() => moment(date2).subtract(1, "month").isSame(moment(date1), "month"),
|
|
95
|
+
[date1, date2],
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const isPreviousPeriodShowed = useMemo(
|
|
99
|
+
() => isCompare && !isCompareHidden && startDate && endDate,
|
|
100
|
+
[startDate, endDate, isCompare],
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const prevEndHour = useRef(endHour);
|
|
104
|
+
|
|
105
|
+
const startPrevDate = useMemo(() => {
|
|
106
|
+
if (isPreviousPeriodShowed) {
|
|
107
|
+
const intervalHoursCount = moment(endDate).diff(startDate, "hours");
|
|
108
|
+
return moment(startDate).subtract(intervalHoursCount, "hours").toDate();
|
|
109
|
+
} else return null;
|
|
110
|
+
}, [startDate, endDate, isCompare]);
|
|
111
|
+
|
|
112
|
+
const endPrevDate = useMemo(() => {
|
|
113
|
+
if (isPreviousPeriodShowed) {
|
|
114
|
+
return startDate;
|
|
115
|
+
} else return null;
|
|
116
|
+
}, [startDate, endDate, isCompare]);
|
|
117
|
+
|
|
118
|
+
const title = useMemo(() => {
|
|
119
|
+
if (isCompare && !isCompareHidden && startDate && endDate) {
|
|
120
|
+
return `${moment(startPrevDate).format("ll")} (${moment(startPrevDate).format(MAIN_TIME_FORMAT)}) - ${moment(
|
|
121
|
+
endPrevDate,
|
|
122
|
+
).format("ll")} (${moment(endPrevDate).format(MAIN_TIME_FORMAT)})`;
|
|
123
|
+
} else return "";
|
|
124
|
+
}, [startDate, endDate, isCompare]);
|
|
125
|
+
|
|
126
|
+
// ********************
|
|
127
|
+
// Methods
|
|
128
|
+
// ********************
|
|
129
|
+
|
|
130
|
+
const subtractDay = (date) =>
|
|
131
|
+
endHour === 0 ? moment(date).subtract(1, "days") : moment(date);
|
|
132
|
+
const addDay = (date) =>
|
|
133
|
+
endHour === 0 ? moment(date).add(1, "days") : moment(date);
|
|
134
|
+
|
|
135
|
+
const getCorrectedDateForDateInput = (key, date) => {
|
|
136
|
+
if (key === "startDateInput") return moment(date);
|
|
137
|
+
// return moment(date).subtract(1, 'm');
|
|
138
|
+
return subtractDay(moment(date));
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const setInterval = () => {
|
|
142
|
+
setActiveInterval(
|
|
143
|
+
getActualDateRange({ start: startDate, end: endDate }).intervalKey,
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// ********************
|
|
148
|
+
// Handlers
|
|
149
|
+
// ********************
|
|
150
|
+
|
|
151
|
+
const handleClick = (date) => {
|
|
152
|
+
prevEndHour.current = 0;
|
|
153
|
+
if (
|
|
154
|
+
!startDate ||
|
|
155
|
+
(startDate &&
|
|
156
|
+
endDate &&
|
|
157
|
+
!(
|
|
158
|
+
moment(startDate).add(1, "d").isSame(endDate, "day") && endHour === 0
|
|
159
|
+
))
|
|
160
|
+
) {
|
|
161
|
+
setStartDate(moment(date).startOf("day"));
|
|
162
|
+
setEndDate(moment(date).add(1, "d").startOf("day"));
|
|
163
|
+
setStartHour(0);
|
|
164
|
+
setEndHour(0);
|
|
165
|
+
} else if (moment(date).isBefore(moment(startDate), "day")) {
|
|
166
|
+
setEndDate(moment(startDate).add(1, "d").startOf("day"));
|
|
167
|
+
setStartDate(moment(date).set("hour", parseInt(startHour, 10)));
|
|
168
|
+
} else if (moment(date).isAfter(moment(startDate), "day")) {
|
|
169
|
+
setEndDate(moment(date).add(1, "d").startOf("day"));
|
|
170
|
+
}
|
|
171
|
+
setHoverStatus(null);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const handleHover = (date) => {
|
|
175
|
+
if (outsideScope.handleHoverTimerId)
|
|
176
|
+
clearTimeout(outsideScope.handleHoverTimerId);
|
|
177
|
+
if (!date) {
|
|
178
|
+
outsideScope.handleHoverTimerId = setTimeout(() => {
|
|
179
|
+
setHoverStatus(null);
|
|
180
|
+
}, 400);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (moment(startDate).add(1, "d").isSame(endDate, "day") && endHour === 0) {
|
|
184
|
+
if (moment(date).isAfter(moment(startDate), "day")) setHoverStatus("end");
|
|
185
|
+
else if (moment(date).isBefore(moment(startDate), "day"))
|
|
186
|
+
setHoverStatus("start");
|
|
187
|
+
else setHoverStatus(null);
|
|
188
|
+
} else {
|
|
189
|
+
setHoverStatus("start");
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const handleChangeStartHour = (val) => {
|
|
194
|
+
setStartHour(Number(val));
|
|
195
|
+
setStartDate(moment(startDate || moment()).set("hour", Number(val)));
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const handleChangeEndHour = (val) => {
|
|
199
|
+
const newHour = Number(val);
|
|
200
|
+
setEndHour(newHour);
|
|
201
|
+
let newEndDate = moment();
|
|
202
|
+
|
|
203
|
+
if (endDate) {
|
|
204
|
+
if (prevEndHour.current === 0 && newHour !== 0) {
|
|
205
|
+
newEndDate = moment(endDate).subtract(1, "days");
|
|
206
|
+
} else if (prevEndHour.current !== 0 && newHour === 0) {
|
|
207
|
+
newEndDate = moment(endDate).add(1, "days");
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
prevEndHour.current = newHour;
|
|
212
|
+
setEndDate(moment(newEndDate).set("hour", newHour));
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// const doBlur = (type, e) => {
|
|
216
|
+
// const executor = type === 'start' ? setIsStartFocused : setIsEndFocused;
|
|
217
|
+
// e.target.blur();
|
|
218
|
+
// executor(false);
|
|
219
|
+
// };
|
|
220
|
+
|
|
221
|
+
// const handleStartDateBlur = e => {
|
|
222
|
+
// let newDate;
|
|
223
|
+
|
|
224
|
+
// if (!moment(startDateInput).isValid()) {
|
|
225
|
+
// newDate = moment(startDate);
|
|
226
|
+
// } else {
|
|
227
|
+
// if (minDate && moment(startDateInput).isBefore(minDate)) newDate = momentMinDate;
|
|
228
|
+
// else if (!isDontLimitFuture) {
|
|
229
|
+
// const edge = maxDate ? momentMaxDate : moment().add(1, 'day').startOf('day');
|
|
230
|
+
// if (moment(startDateInput).isAfter(edge)) newDate = edge;
|
|
231
|
+
// else newDate = moment(startDateInput);
|
|
232
|
+
// } else newDate = moment(startDateInput);
|
|
233
|
+
// }
|
|
234
|
+
|
|
235
|
+
// setStartDateInput(newDate.format(format));
|
|
236
|
+
// setStartDate(newDate.set('hour', parseInt(startHour, 10)).toDate());
|
|
237
|
+
|
|
238
|
+
// doBlur('start', e);
|
|
239
|
+
// setDate1(
|
|
240
|
+
// moment(newDate).isSameOrAfter(moment(date2), 'month') ? moment(date2).subtract(1, 'month') : moment(newDate),
|
|
241
|
+
// );
|
|
242
|
+
// };
|
|
243
|
+
|
|
244
|
+
// const handleEndDateBlur = e => {
|
|
245
|
+
// let newDate;
|
|
246
|
+
|
|
247
|
+
// if (!moment(endDateInput).isValid()) {
|
|
248
|
+
// newDate = moment(endDate);
|
|
249
|
+
// } else {
|
|
250
|
+
// if (minDate && moment(endDateInput).isBefore(minDate)) newDate = momentMinDate;
|
|
251
|
+
// else if (!isDontLimitFuture) {
|
|
252
|
+
// const edge = maxDate ? momentMaxDate : moment().endOf('day');
|
|
253
|
+
// if (moment(endDateInput).isAfter(edge)) newDate = maxDate ? edge : edge.startOf('day');
|
|
254
|
+
// else newDate = moment(startDateInput);
|
|
255
|
+
// } else newDate = moment(startDateInput);
|
|
256
|
+
// }
|
|
257
|
+
|
|
258
|
+
// setEndDate(addDay(newDate.set('hour', parseInt(endHour, 10)).toDate()));
|
|
259
|
+
// setEndDateInput(newDate.format(format));
|
|
260
|
+
|
|
261
|
+
// doBlur('end', e);
|
|
262
|
+
// setDate2(newDate);
|
|
263
|
+
// };
|
|
264
|
+
|
|
265
|
+
const handleDateInputFocus = (key, e) => {
|
|
266
|
+
const changeFlag =
|
|
267
|
+
key === "startDateInput" ? setIsStartFocused : setIsEndFocused;
|
|
268
|
+
const set = key === "startDateInput" ? setStartDateInput : setEndDateInput;
|
|
269
|
+
const date = key === "startDateInput" ? startDate : endDate;
|
|
270
|
+
|
|
271
|
+
changeFlag(true);
|
|
272
|
+
set(date ? getCorrectedDateForDateInput(key, date).format("L") : "");
|
|
273
|
+
setTimeout(() => {
|
|
274
|
+
const defaultTarget =
|
|
275
|
+
key === "startDateInput"
|
|
276
|
+
? startDateInputRef.current
|
|
277
|
+
: endDateInputRef.current;
|
|
278
|
+
const target = e?.target ?? defaultTarget;
|
|
279
|
+
target.select();
|
|
280
|
+
|
|
281
|
+
//? Для инпут-маск, почему-то нужно пропустить 2 эвентлупа
|
|
282
|
+
// setTimeout(() => {
|
|
283
|
+
// target.select();
|
|
284
|
+
// }, 0);
|
|
285
|
+
}, 0);
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
const doBlur = (type, e) => {
|
|
289
|
+
const executor =
|
|
290
|
+
type === "startDateInput" ? setIsStartFocused : setIsEndFocused;
|
|
291
|
+
|
|
292
|
+
e.target.blur();
|
|
293
|
+
executor(false);
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
const processOverflow = (newDateAsString, valueForRollback, key) => {
|
|
297
|
+
const newDateAsMomentObj = moment(newDateAsString, DATE_INPUT_FORMAT);
|
|
298
|
+
|
|
299
|
+
// console.log('processOverflow - newDateAsString - ', newDateAsString);
|
|
300
|
+
// console.log('processOverflow - valueForRollback - ', valueForRollback);
|
|
301
|
+
// console.log('----------');
|
|
302
|
+
// console.log('processOverflow - minDate - ', minDate);
|
|
303
|
+
// console.log('processOverflow - maxDate - ', maxDate);
|
|
304
|
+
// console.log('----------');
|
|
305
|
+
// console.log('processOverflow - momentMinDate - ', momentMinDate);
|
|
306
|
+
// console.log('processOverflow - momentMaxDate - ', momentMaxDate);
|
|
307
|
+
// console.log('----------');
|
|
308
|
+
// console.log('processOverflow - newDateAsMomentObj - ', newDateAsMomentObj);
|
|
309
|
+
// console.log('*********');
|
|
310
|
+
|
|
311
|
+
//? Если значение не валидно...
|
|
312
|
+
if (!newDateAsMomentObj.isValid()) {
|
|
313
|
+
//? ... то откатываем к дате до набора руками
|
|
314
|
+
return valueForRollback;
|
|
315
|
+
} else {
|
|
316
|
+
const beforeOfFuture = moment().endOf("day");
|
|
317
|
+
const hour = key === "startDateInput" ? startHour : endHour;
|
|
318
|
+
|
|
319
|
+
let output;
|
|
320
|
+
|
|
321
|
+
//? Если есть минимальная дата и введенная меньше минимальной, то ставим минимальную
|
|
322
|
+
if (minDate && newDateAsMomentObj.isBefore(momentMinDate))
|
|
323
|
+
output = momentMinDate;
|
|
324
|
+
//? Если есть максимальная дата и введенная больше максимальной, то ставим максимальную
|
|
325
|
+
else if (maxDate && newDateAsMomentObj.isAfter(momentMaxDate))
|
|
326
|
+
output = momentMaxDate;
|
|
327
|
+
//? Если нет установки не ограничивать дату по будущему...
|
|
328
|
+
else if (
|
|
329
|
+
!isDontLimitFuture &&
|
|
330
|
+
newDateAsMomentObj.isAfter(beforeOfFuture)
|
|
331
|
+
) {
|
|
332
|
+
output = beforeOfFuture.startOf("day");
|
|
333
|
+
} else output = newDateAsMomentObj;
|
|
334
|
+
|
|
335
|
+
// if (key === 'startDateInput') {
|
|
336
|
+
// console.log('endDate - ', endDate.format('YYYY-MM-DDTHH:mm'));
|
|
337
|
+
// console.log('endDate.subtract(1, d) - ', endDate.subtract(1, 'd').format('YYYY-MM-DDTHH:mm'));
|
|
338
|
+
// if (output.isAfter(endDate.subtract(1, 'd'))) output = endDate.subtract(1, 'd');
|
|
339
|
+
// }
|
|
340
|
+
|
|
341
|
+
if (key === "endDateInput") {
|
|
342
|
+
// console.log('startDate - ', startDate.format('YYYY-MM-DDTHH:mm'));
|
|
343
|
+
// if (output.isBefore(startDate)) output = startDate.add(1, 'd');
|
|
344
|
+
output = addDay(output);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// console.log('output - ', output.format('YYYY-MM-DDTHH:mm'));
|
|
348
|
+
// console.log('************');
|
|
349
|
+
|
|
350
|
+
return output.set("hour", parseInt(hour, 10));
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
const handleDateInputBlur = (key, e) => {
|
|
355
|
+
const reserveValue =
|
|
356
|
+
key === "startDateInput" ? startDateInput : endDateInput;
|
|
357
|
+
const valueForRollback = key === "startDateInput" ? startDate : endDate;
|
|
358
|
+
|
|
359
|
+
const execute = key === "startDateInput" ? setStartDate : setEndDate;
|
|
360
|
+
const executeForCalendar = key === "startDateInput" ? setDate1 : setDate2;
|
|
361
|
+
const prepareValueForCalendar = (newDate) => {
|
|
362
|
+
if (key === "endDateInput") return newDate;
|
|
363
|
+
return moment(newDate).isSameOrAfter(moment(date2), "month")
|
|
364
|
+
? moment(date2).subtract(1, "month")
|
|
365
|
+
: moment(newDate);
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
const newDateValue = e?.target?.value ?? reserveValue;
|
|
369
|
+
const processedNewDate = processOverflow(
|
|
370
|
+
newDateValue,
|
|
371
|
+
valueForRollback,
|
|
372
|
+
key,
|
|
373
|
+
);
|
|
374
|
+
execute(processedNewDate);
|
|
375
|
+
executeForCalendar(prepareValueForCalendar(processedNewDate));
|
|
376
|
+
doBlur(key, e);
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
const handleKeyPressed = (code, e, type) => {
|
|
380
|
+
if (code === 13) handleDateInputBlur(type, e);
|
|
381
|
+
if (code === 27) doBlur(type, e);
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
// ********************
|
|
385
|
+
// Render Functions
|
|
386
|
+
// ********************
|
|
387
|
+
|
|
388
|
+
const getStartHourItems = () =>
|
|
389
|
+
[...Array(24).keys()].map((hour) => ({
|
|
390
|
+
label: padTime(hour),
|
|
391
|
+
value: hour,
|
|
392
|
+
disabled: moment(startDate).isSame(endDate, "day") && endHour <= hour,
|
|
393
|
+
}));
|
|
394
|
+
const getEndHourItems = () =>
|
|
395
|
+
[...Array(24).keys()].map((hour) => ({
|
|
396
|
+
label: padTime(hour + 1),
|
|
397
|
+
value: hour === 23 ? 0 : hour + 1,
|
|
398
|
+
disabled:
|
|
399
|
+
(moment(startDate).isSame(endDate, "day") ||
|
|
400
|
+
(moment(startDate).isSame(
|
|
401
|
+
moment(endDate).subtract(1, "days"),
|
|
402
|
+
"day",
|
|
403
|
+
) &&
|
|
404
|
+
endHour === 0)) &&
|
|
405
|
+
hour < startHour,
|
|
406
|
+
}));
|
|
407
|
+
|
|
408
|
+
const renderButtons = () => (
|
|
409
|
+
<>
|
|
410
|
+
<Btn
|
|
411
|
+
className="date-picker__button"
|
|
412
|
+
onClick={() => onCancel()}
|
|
413
|
+
variant={buttonsTypes?.cancel}
|
|
414
|
+
>
|
|
415
|
+
{txt?.buttons?.cancel || "Cancel"}
|
|
416
|
+
</Btn>
|
|
417
|
+
<Btn
|
|
418
|
+
className="date-picker__button"
|
|
419
|
+
variant={buttonsTypes?.apply}
|
|
420
|
+
disabled={!startDate || !endDate}
|
|
421
|
+
onClick={() =>
|
|
422
|
+
onChange({
|
|
423
|
+
start: moment(startDate).format(MAIN_FORMAT),
|
|
424
|
+
end: moment(endDate).format(MAIN_FORMAT),
|
|
425
|
+
startPrevDate: moment(startPrevDate).format(MAIN_FORMAT),
|
|
426
|
+
endPrevDate: moment(endPrevDate).format(MAIN_FORMAT),
|
|
427
|
+
compare: isCompare,
|
|
428
|
+
})
|
|
429
|
+
}
|
|
430
|
+
>
|
|
431
|
+
{txt?.buttons?.apply || "apply"}
|
|
432
|
+
</Btn>
|
|
433
|
+
</>
|
|
434
|
+
);
|
|
435
|
+
|
|
436
|
+
const renderPreviousPeriod = () => (
|
|
437
|
+
<>
|
|
438
|
+
{txt?.labels?.previousPeriod || ""}:{" "}
|
|
439
|
+
<span className="date-picker__previous-period-interval">{title}</span>
|
|
440
|
+
</>
|
|
441
|
+
);
|
|
442
|
+
|
|
443
|
+
// ********************
|
|
444
|
+
// useEffects
|
|
445
|
+
// ********************
|
|
446
|
+
|
|
447
|
+
useEffect(() => {
|
|
448
|
+
if (moment(startDate).isSameOrAfter(endDate)) {
|
|
449
|
+
setStartDate(moment(endDate).subtract(1, "d"));
|
|
450
|
+
setDate1(moment(endDate).subtract(1, "d"));
|
|
451
|
+
}
|
|
452
|
+
}, [startDate]);
|
|
453
|
+
|
|
454
|
+
useEffect(() => {
|
|
455
|
+
if (moment(endDate).isSameOrBefore(startDate)) {
|
|
456
|
+
setEndDate(moment(startDate).add(1, "d"));
|
|
457
|
+
setDate2(moment(startDate).add(1, "d"));
|
|
458
|
+
}
|
|
459
|
+
}, [endDate]);
|
|
460
|
+
|
|
461
|
+
useEffect(() => {
|
|
462
|
+
if (moment(startDate).isBefore(moment(endDate), "month")) {
|
|
463
|
+
setDate1(moment(startDate));
|
|
464
|
+
setDate2(moment(endDate));
|
|
465
|
+
}
|
|
466
|
+
setInterval();
|
|
467
|
+
}, [startDate, endDate]);
|
|
468
|
+
|
|
469
|
+
useEffect(() => {
|
|
470
|
+
if (
|
|
471
|
+
moment(date1).isSameOrAfter(moment(date2), "month") &&
|
|
472
|
+
!withMobileLogic
|
|
473
|
+
) {
|
|
474
|
+
setDate1(moment(date2).subtract(1, "month"));
|
|
475
|
+
}
|
|
476
|
+
}, [date1, date2]);
|
|
477
|
+
|
|
478
|
+
useEffect(() => {
|
|
479
|
+
onChangeInterval(dateInterval);
|
|
480
|
+
}, [dateInterval]);
|
|
481
|
+
|
|
482
|
+
useEffect(() => {
|
|
483
|
+
if (typeof onChangeMobile === "function") {
|
|
484
|
+
onChangeMobile({
|
|
485
|
+
start: moment(startDate).format(MAIN_FORMAT),
|
|
486
|
+
end: moment(endDate).format(MAIN_FORMAT),
|
|
487
|
+
startPrevDate: moment(startPrevDate).format(MAIN_FORMAT),
|
|
488
|
+
endPrevDate: moment(endPrevDate).format(MAIN_FORMAT),
|
|
489
|
+
compare: isCompare,
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
}, [startDate, endDate, startPrevDate, endPrevDate, isCompare]);
|
|
493
|
+
|
|
494
|
+
const renderRowStart = () => {
|
|
495
|
+
return (
|
|
496
|
+
<div className="date-picker__date-row">
|
|
497
|
+
<DateInput
|
|
498
|
+
ref={startDateInputRef}
|
|
499
|
+
testId={`datepicker-${testId}_start-date-input`}
|
|
500
|
+
RC="date-picker__date-input"
|
|
501
|
+
className={cn("date-picker__date-input")}
|
|
502
|
+
isFocused={isStartFocused}
|
|
503
|
+
value={startDateInput}
|
|
504
|
+
date={getCorrectedDateForDateInput("startDateInput", startDate)}
|
|
505
|
+
disabled={!startDate}
|
|
506
|
+
onChange={setStartDateInput}
|
|
507
|
+
onFocus={(e) => handleDateInputFocus("startDateInput", e)}
|
|
508
|
+
onBlur={(e) => handleDateInputBlur("startDateInput", e)}
|
|
509
|
+
onKeyUp={(code, e) => handleKeyPressed(code, e, "startDateInput")}
|
|
510
|
+
/>
|
|
511
|
+
<SelectInput
|
|
512
|
+
testId={testId}
|
|
513
|
+
id={`datepicker-id-${mainId}_start-hour-select-input`}
|
|
514
|
+
dataTest="datepicker_start-hour-select-input"
|
|
515
|
+
className={cn("date-picker__hour-select-input")}
|
|
516
|
+
onChange={(value) => handleChangeStartHour(value)}
|
|
517
|
+
value={startHour}
|
|
518
|
+
options={getStartHourItems()}
|
|
519
|
+
disabled={!startDate}
|
|
520
|
+
isDoNotPullOutListOfMainContainer={isDoNotPullOutListOfMainContainer}
|
|
521
|
+
short
|
|
522
|
+
withMobileLogic={withMobileLogic}
|
|
523
|
+
/>
|
|
524
|
+
</div>
|
|
525
|
+
);
|
|
526
|
+
};
|
|
527
|
+
const renderRowEnd = () => {
|
|
528
|
+
return (
|
|
529
|
+
<div className="date-picker__date-row">
|
|
530
|
+
<DateInput
|
|
531
|
+
ref={endDateInputRef}
|
|
532
|
+
testId={`datepicker-${testId}_start-date-input`}
|
|
533
|
+
RC="date-picker__date-input"
|
|
534
|
+
className={cn("date-picker__date-input")}
|
|
535
|
+
isFocused={isEndFocused}
|
|
536
|
+
value={endDateInput}
|
|
537
|
+
date={getCorrectedDateForDateInput("endDateInput", endDate)}
|
|
538
|
+
disabled={!endDate}
|
|
539
|
+
onChange={setEndDateInput}
|
|
540
|
+
onFocus={(e) => handleDateInputFocus("endDateInput", e)}
|
|
541
|
+
onBlur={(e) => handleDateInputBlur("endDateInput", e)}
|
|
542
|
+
onKeyUp={(code, e) => handleKeyPressed(code, e, "endDateInput")}
|
|
543
|
+
/>
|
|
544
|
+
<SelectInput
|
|
545
|
+
testId={testId}
|
|
546
|
+
id={`datepicker-id-${mainId}_end-hour-select-input`}
|
|
547
|
+
dataTest="datepicker_end-hour-select-input"
|
|
548
|
+
className={cn("date-picker__hour-select-input")}
|
|
549
|
+
onChange={(value) => handleChangeEndHour(value)}
|
|
550
|
+
value={endHour}
|
|
551
|
+
options={getEndHourItems()}
|
|
552
|
+
disabled={!endDate}
|
|
553
|
+
isDoNotPullOutListOfMainContainer={isDoNotPullOutListOfMainContainer}
|
|
554
|
+
short
|
|
555
|
+
withMobileLogic={withMobileLogic}
|
|
556
|
+
/>
|
|
557
|
+
</div>
|
|
558
|
+
);
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
const renderCalendarStart = () => {
|
|
562
|
+
return (
|
|
563
|
+
<Calendar
|
|
564
|
+
testId={testId}
|
|
565
|
+
className="date-picker__calendar"
|
|
566
|
+
date={date1}
|
|
567
|
+
setDate={setDate1}
|
|
568
|
+
allowNext={
|
|
569
|
+
withMobileLogic
|
|
570
|
+
? !moment(date1)
|
|
571
|
+
.startOf("month")
|
|
572
|
+
.isSameOrAfter(moment().startOf("day"), "months")
|
|
573
|
+
: !isNearby
|
|
574
|
+
}
|
|
575
|
+
startDate={startDate}
|
|
576
|
+
endDate={endDate}
|
|
577
|
+
startPrevDate={startPrevDate}
|
|
578
|
+
endPrevDate={endPrevDate}
|
|
579
|
+
onClick={handleClick}
|
|
580
|
+
onHover={handleHover}
|
|
581
|
+
limitRange={limitRange}
|
|
582
|
+
isShortWeekNames={isShortWeekNames}
|
|
583
|
+
minDate={minDate}
|
|
584
|
+
maxDate={maxDate}
|
|
585
|
+
momentMinDate={momentMinDate}
|
|
586
|
+
momentMaxDate={momentMaxDate}
|
|
587
|
+
/>
|
|
588
|
+
);
|
|
589
|
+
};
|
|
590
|
+
const renderCalendarEnd = () => {
|
|
591
|
+
return (
|
|
592
|
+
<Calendar
|
|
593
|
+
className="date-picker__calendar"
|
|
594
|
+
date={date2}
|
|
595
|
+
setDate={setDate2}
|
|
596
|
+
allowPrev={!isNearby}
|
|
597
|
+
startDate={startDate}
|
|
598
|
+
endDate={endDate}
|
|
599
|
+
startPrevDate={startPrevDate}
|
|
600
|
+
endPrevDate={endPrevDate}
|
|
601
|
+
onClick={handleClick}
|
|
602
|
+
onHover={handleHover}
|
|
603
|
+
isShortWeekNames={isShortWeekNames}
|
|
604
|
+
minDate={minDate}
|
|
605
|
+
maxDate={maxDate}
|
|
606
|
+
momentMinDate={momentMinDate}
|
|
607
|
+
momentMaxDate={momentMaxDate}
|
|
608
|
+
isDontLimitFuture={isDontLimitFuture}
|
|
609
|
+
/>
|
|
610
|
+
);
|
|
611
|
+
};
|
|
612
|
+
|
|
613
|
+
const render = () => {
|
|
614
|
+
return (
|
|
615
|
+
<div className={cn("date-picker", className)}>
|
|
616
|
+
<div className="date-picker__header">
|
|
617
|
+
<div className="date-picker__inputs-block">
|
|
618
|
+
{renderRowStart()}
|
|
619
|
+
<div className="date-picker__inputs-separator date-picker__header--gray">
|
|
620
|
+
—
|
|
621
|
+
</div>
|
|
622
|
+
{renderRowEnd()}
|
|
623
|
+
</div>
|
|
624
|
+
{isCompare && !isCompareHidden && startDate && endDate && (
|
|
625
|
+
<div className="date-picker__previous-period">
|
|
626
|
+
{renderPreviousPeriod()}
|
|
627
|
+
</div>
|
|
628
|
+
)}
|
|
629
|
+
</div>
|
|
630
|
+
|
|
631
|
+
<div className="date-picker__calendars">
|
|
632
|
+
<div className="date-picker__calendars-wrapper">
|
|
633
|
+
{renderCalendarStart()}
|
|
634
|
+
{renderCalendarEnd()}
|
|
635
|
+
</div>
|
|
636
|
+
</div>
|
|
637
|
+
<div
|
|
638
|
+
className={cn("date-picker__footer", {
|
|
639
|
+
"date-picker__footer_once-element": isCompareHidden,
|
|
640
|
+
})}
|
|
641
|
+
>
|
|
642
|
+
{!isCompareHidden ? (
|
|
643
|
+
<div className="date-picker__compare-block">
|
|
644
|
+
<div className="mr5">
|
|
645
|
+
<Switcher
|
|
646
|
+
dataTest="datepicker_compare"
|
|
647
|
+
label={txt?.labels?.compare || "Compare"}
|
|
648
|
+
isSwitchOn={isCompare}
|
|
649
|
+
onChange={() => {
|
|
650
|
+
onChangeCompare(!isCompare);
|
|
651
|
+
setIsCompare((state) => !state);
|
|
652
|
+
}}
|
|
653
|
+
/>
|
|
654
|
+
</div>
|
|
655
|
+
</div>
|
|
656
|
+
) : (
|
|
657
|
+
<div />
|
|
658
|
+
)}
|
|
659
|
+
<div className="date-picker__buttons-block">{renderButtons()}</div>
|
|
660
|
+
</div>
|
|
661
|
+
</div>
|
|
662
|
+
);
|
|
663
|
+
};
|
|
664
|
+
const renderMobile = () => {
|
|
665
|
+
return (
|
|
666
|
+
<div className={cn("date-picker", className)}>
|
|
667
|
+
<div className="date-picker__header">
|
|
668
|
+
<div className="date-picker__inputs-block">
|
|
669
|
+
{renderRowStart()}
|
|
670
|
+
<div className="date-picker__inputs-separator date-picker__header--gray">
|
|
671
|
+
—
|
|
672
|
+
</div>
|
|
673
|
+
{renderRowEnd()}
|
|
674
|
+
</div>
|
|
675
|
+
{isCompare && !isCompareHidden && startDate && endDate && (
|
|
676
|
+
<div className="date-picker__previous-period">
|
|
677
|
+
{renderPreviousPeriod()}
|
|
678
|
+
</div>
|
|
679
|
+
)}
|
|
680
|
+
</div>
|
|
681
|
+
|
|
682
|
+
<div className="date-picker__calendars">
|
|
683
|
+
<div className="date-picker__calendars-wrapper">
|
|
684
|
+
{renderCalendarStart()}
|
|
685
|
+
</div>
|
|
686
|
+
</div>
|
|
687
|
+
</div>
|
|
688
|
+
);
|
|
689
|
+
};
|
|
690
|
+
return withMobileLogic ? renderMobile() : render();
|
|
691
|
+
};
|
|
692
|
+
|
|
693
|
+
export default Datepicker;
|