import React from "react"; import "react-dates/initialize"; import * as R from "ramda"; import { compose, withHandlers, withState } from "recompose"; import moment, { Moment } from "moment"; import { SingleDatePicker } from "react-dates"; import "react-dates/lib/css/_datepicker.css"; const OnlyLabelName = ({ labelName }: { labelName?: string }) => ( ); const RequiredLabelName = ({ labelName, requiredFieldText }: { labelName?: string; requiredFieldText?: string; }) => ( ); const DatePicker = ({ labelName, requiredFieldText, value, id = "arkDatePicker", changeData, focusedInput, setFocusedInput, format, disabled = false, readOnly = false, placeHolder = "Choose Date", withPortal = false, numberOfMonths = 1 }: OutputProps) => ( <> {!R.isEmpty(labelName) && R.isEmpty(requiredFieldText) ? ( ) : null} {!R.isEmpty(labelName) && !R.isEmpty(requiredFieldText) ? ( ) : null} ); export type InputProps = { labelName?: string; requiredFieldText?: string; value: Moment | null; update: any; format: string; placeHolder?: string; numberOfMonths?: number; disabled?: boolean; withPortal?: boolean; readOnly?: boolean; id?: string; }; export type OutputProps = InputProps & { changeData: any; setFocusedInput: any; focusedInput: boolean; }; export default compose( withState("focusedInput", "updateFocusedInput", false), withHandlers({ changeData: ({ update }: { update: any }) => (val: any) => update(val), setFocusedInput: (props: any) => ({ focused }: { focused: string }) => props.updateFocusedInput(focused) }) )(DatePicker);