From ac4e742de5b7944ed6fe9d00296787ab9d11ae0a Mon Sep 17 00:00:00 2001 From: maxim Date: Fri, 15 Dec 2023 16:08:27 +0100 Subject: [PATCH] removed external IProps --- .../DatePicker/DatePicker.tsx | 17 +++++++++++++---- .../DatePicker/Header/Header.tsx | 18 +++++++++++++++--- .../DatePicker/Header/IProps.ts | 15 --------------- src/DateTimeRangePicker/DatePicker/IProps.ts | 13 ------------- .../DatePicker/Month/IProps.ts | 15 --------------- .../DatePicker/Month/Month.tsx | 18 ++++++++++++++---- .../DatePicker/YearView/YearView.tsx | 15 +++++++++++---- src/DateTimeRangePicker/TimePicker/IProps.ts | 9 --------- .../TimePicker/TimePicker.tsx | 13 +++++++++---- 9 files changed, 62 insertions(+), 71 deletions(-) delete mode 100644 src/DateTimeRangePicker/DatePicker/Header/IProps.ts delete mode 100644 src/DateTimeRangePicker/DatePicker/IProps.ts delete mode 100644 src/DateTimeRangePicker/DatePicker/Month/IProps.ts delete mode 100644 src/DateTimeRangePicker/TimePicker/IProps.ts diff --git a/src/DateTimeRangePicker/DatePicker/DatePicker.tsx b/src/DateTimeRangePicker/DatePicker/DatePicker.tsx index 3f9efb3..ac1d095 100644 --- a/src/DateTimeRangePicker/DatePicker/DatePicker.tsx +++ b/src/DateTimeRangePicker/DatePicker/DatePicker.tsx @@ -2,13 +2,22 @@ import React, {useState} from 'react' import moment, {Moment} from 'moment' import './DatePicker.scss' -import IProps from './IProps' import Month from './Month/Month' import Header from './Header/Header' -import {TCalendarMode} from './TCalendarMode' import {YearView} from './YearView/YearView' +import {TCalendarMode} from './TCalendarMode' -const DatePicker: React.FunctionComponent = ( +interface IProps { + range: boolean, + fromDate?: Moment, + untilDate?: Moment, + initialDate?: Moment + months: number, + onFromDateChanged: (date: Moment | undefined) => void + onUntilDateChanged: (date: Moment | undefined) => void +} + +const DatePicker = ( { range = false, fromDate, @@ -17,7 +26,7 @@ const DatePicker: React.FunctionComponent = ( months = 1, onFromDateChanged, onUntilDateChanged - } + }: IProps ) => { const [calendarMode, setCalendarMode] = useState('normal') const [currentDate, setCurrentDate] = useState(fromDate diff --git a/src/DateTimeRangePicker/DatePicker/Header/Header.tsx b/src/DateTimeRangePicker/DatePicker/Header/Header.tsx index 78732f0..e033dff 100644 --- a/src/DateTimeRangePicker/DatePicker/Header/Header.tsx +++ b/src/DateTimeRangePicker/DatePicker/Header/Header.tsx @@ -1,8 +1,20 @@ import React from 'react' -import IProps from './IProps' +import moment from 'moment' +import {TCalendarMode} from '../TCalendarMode' -const Header: React.FunctionComponent = ({ +interface IProps { + date: moment.Moment, + months: number, + onNextMonth: () => void, + onPrevMonth: () => void + onNextYear: () => void + onPrevYear: () => void + calendarMode: TCalendarMode + setCalendarMode: (mode: TCalendarMode) => void +} + +const Header = ({ date, months, onPrevMonth, @@ -11,7 +23,7 @@ const Header: React.FunctionComponent = ({ setCalendarMode, onPrevYear, onNextYear -}) => { +}: IProps) => { const monthsArray = [] for (let monthIndex = 0; monthIndex < months; monthIndex++) { monthsArray.push(monthIndex) diff --git a/src/DateTimeRangePicker/DatePicker/Header/IProps.ts b/src/DateTimeRangePicker/DatePicker/Header/IProps.ts deleted file mode 100644 index 9c89f9f..0000000 --- a/src/DateTimeRangePicker/DatePicker/Header/IProps.ts +++ /dev/null @@ -1,15 +0,0 @@ -import moment from 'moment' -import {TCalendarMode} from '../TCalendarMode' - -interface IProps { - date: moment.Moment, - months: number, - onNextMonth: () => void, - onPrevMonth: () => void - onNextYear: () => void - onPrevYear: () => void - calendarMode: TCalendarMode - setCalendarMode: (mode: TCalendarMode) => void -} - -export default IProps diff --git a/src/DateTimeRangePicker/DatePicker/IProps.ts b/src/DateTimeRangePicker/DatePicker/IProps.ts deleted file mode 100644 index 80dad79..0000000 --- a/src/DateTimeRangePicker/DatePicker/IProps.ts +++ /dev/null @@ -1,13 +0,0 @@ -import {Moment} from 'moment' - -interface IProps { - range: boolean, - fromDate?: Moment, - untilDate?: Moment, - initialDate?: Moment - months: number, - onFromDateChanged: (date: Moment | undefined) => void - onUntilDateChanged: (date: Moment | undefined) => void -} - -export default IProps diff --git a/src/DateTimeRangePicker/DatePicker/Month/IProps.ts b/src/DateTimeRangePicker/DatePicker/Month/IProps.ts deleted file mode 100644 index d6a747e..0000000 --- a/src/DateTimeRangePicker/DatePicker/Month/IProps.ts +++ /dev/null @@ -1,15 +0,0 @@ -import {Moment} from 'moment' - -interface IProps { - month: number, - year: number, - fromDate?: Moment, - untilDate?: Moment, - hoverDate?: Moment, - showDaysPreviousMonth: boolean, - showDaysNextMonth: boolean, - onDaySelected: (date: Moment) => void, - onDayHover: (date?: Moment | undefined) => void -} - -export default IProps diff --git a/src/DateTimeRangePicker/DatePicker/Month/Month.tsx b/src/DateTimeRangePicker/DatePicker/Month/Month.tsx index 7841053..3e83468 100644 --- a/src/DateTimeRangePicker/DatePicker/Month/Month.tsx +++ b/src/DateTimeRangePicker/DatePicker/Month/Month.tsx @@ -1,9 +1,19 @@ -import React, {ReactElement, useState} from 'react' +import React, {ReactElement} from 'react' import moment, {Moment} from 'moment' -import IProps from './IProps' +interface IProps { + month: number, + year: number, + fromDate?: Moment, + untilDate?: Moment, + hoverDate?: Moment, + showDaysPreviousMonth: boolean, + showDaysNextMonth: boolean, + onDaySelected: (date: Moment) => void, + onDayHover: (date?: Moment | undefined) => void +} -const Month: React.FunctionComponent = ( +const Month = ( { month, year, @@ -14,7 +24,7 @@ const Month: React.FunctionComponent = ( showDaysNextMonth, onDaySelected, onDayHover - } + }: IProps ) => { const date = moment(`${month}-${year}`, 'M-YYYY') diff --git a/src/DateTimeRangePicker/DatePicker/YearView/YearView.tsx b/src/DateTimeRangePicker/DatePicker/YearView/YearView.tsx index 9cb193c..22320a3 100644 --- a/src/DateTimeRangePicker/DatePicker/YearView/YearView.tsx +++ b/src/DateTimeRangePicker/DatePicker/YearView/YearView.tsx @@ -1,8 +1,15 @@ -import React, {FunctionComponent} from 'react' -import {IProps} from './IProps' -import moment from 'moment/moment' +import React from 'react' +import moment, {Moment} from 'moment/moment' +import {TCalendarMode} from '../TCalendarMode' -export const YearView: FunctionComponent = ({isRender, currentDate, setCurrentDate, setCalendarMode}) => { +interface IProps { + isRender: boolean + currentDate: Moment + setCurrentDate: (date: Moment) => void + setCalendarMode: (mode: TCalendarMode) => void +} + +export const YearView = ({isRender, currentDate, setCurrentDate, setCalendarMode}: IProps) => { if (!isRender) { return null } diff --git a/src/DateTimeRangePicker/TimePicker/IProps.ts b/src/DateTimeRangePicker/TimePicker/IProps.ts deleted file mode 100644 index fb01c62..0000000 --- a/src/DateTimeRangePicker/TimePicker/IProps.ts +++ /dev/null @@ -1,9 +0,0 @@ -import {Moment} from 'moment' - -interface IProps { - time?: Moment, - step: number, - onTimeChanged: (time: Moment) => void -} - -export default IProps diff --git a/src/DateTimeRangePicker/TimePicker/TimePicker.tsx b/src/DateTimeRangePicker/TimePicker/TimePicker.tsx index 09c38ec..bfe2b4c 100644 --- a/src/DateTimeRangePicker/TimePicker/TimePicker.tsx +++ b/src/DateTimeRangePicker/TimePicker/TimePicker.tsx @@ -1,11 +1,16 @@ -import React, {FunctionComponent, SyntheticEvent, useRef, useState} from 'react' +import React, { SyntheticEvent, useRef, useState} from 'react' import Cleave from 'cleave.js/react' -import moment from 'moment' +import moment, { Moment } from 'moment' -import IProps from './IProps' import './TimePicker.scss' -const TimePicker: FunctionComponent = ({ step = 15, onTimeChanged, time}) => { +interface IProps { + time?: Moment, + step: number, + onTimeChanged: (time: Moment) => void +} + +const TimePicker = ({ step = 15, onTimeChanged, time}: IProps) => { const [currentValue, setCurrentValue] = useState(time ? time.format('HH:mm') : undefined) const [isOpen, setIsOpen] = useState(false) const dropdownRef = useRef()