Skip to content

Commit

Permalink
fix: doesn't work with React 15
Browse files Browse the repository at this point in the history
  • Loading branch information
arfedulov committed Jun 30, 2018
1 parent 9cc79c0 commit 40dd5df
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 115 deletions.
50 changes: 31 additions & 19 deletions src/components/TimePickerComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,64 @@ import React from 'react';
import { HourPicker, MinutePicker, PickerHeader } from '.';
import PropTypes from 'prop-types';
import moment from 'moment';
import { Table } from 'semantic-ui-react';

function TimePickerComponent(props) {
const {
selectedDate,
onNextDayBtnClick,
onPrevDayBtnClick,
activeDate,
showDate,
handleHeaderTimeClick,
showNextDay,
showPrevDay,
onHourClick,
onMinuteClick,
activeHour,
activeMinute,
mode
} = props;

const headerWidth = mode === 'minute'? '3' : mode === 'hour'? '4' : '7';

if (mode === 'minute') {
return (
<React.Fragment>
{ selectedDate && (
<Table
unstackable
celled
textAlign="center">
{ showDate && (
<PickerHeader
width="3"
onDateClick={handleHeaderTimeClick}
onNextBtnClick={showNextDay}
onPrevBtnClick={showPrevDay}
activeDate={activeDate}
includeDay
activeDate={selectedDate}
onNextBtnClick={onNextDayBtnClick}
onPrevBtnClick={onPrevDayBtnClick} />
width={headerWidth} />
) }
<MinutePicker
hour={activeHour}
activeMinute={activeMinute}
onMinuteClick={onMinuteClick} />
</React.Fragment>
</Table>
);
} else {
return (
<React.Fragment>
{ selectedDate && (
<Table
unstackable
celled
textAlign="center">
{ showDate && (
<PickerHeader
width="4"
onDateClick={handleHeaderTimeClick}
onNextBtnClick={showNextDay}
onPrevBtnClick={showPrevDay}
activeDate={activeDate}
includeDay
activeDate={selectedDate}
onNextBtnClick={onNextDayBtnClick}
onPrevBtnClick={onPrevDayBtnClick} />
width={headerWidth} />
) }
<HourPicker
activeHour={activeHour}
onHourClick={onHourClick} />
</React.Fragment>
</Table>
);
}
}
Expand All @@ -56,8 +69,7 @@ TimePickerComponent.propTypes = {
onHourClick: PropTypes.func.isRequired,
/** (event, data) => {} */
onMinuteClick: PropTypes.func.isRequired,
/** Show date in header if given */
selectedDate: PropTypes.instanceOf(moment),
showDate: PropTypes.bool,
activeHour: PropTypes.string,
activeMinute: PropTypes.string,
onNextDayBtnClick: PropTypes.func,
Expand Down
29 changes: 12 additions & 17 deletions src/components/pickerContent/DateTimePickerContent.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';

import { PickerHeader, TimePickerComponent } from '..';
import { TimePickerComponent } from '..';
import { DatePickerContent } from './DatePickerContent';
import { CustomPropTypes } from '../../lib/customPropTypes';

Expand Down Expand Up @@ -29,7 +29,6 @@ function DateTimePickerContent(props) {
onPrevBtnClick,
onNextBtnClick
} = props;
const headerWidth = mode === 'minute'? '3' : mode === 'hour'? '4' : '7';
if (mode !== 'hour' && mode !== 'minute') {
return (
<DatePickerContent
Expand All @@ -50,21 +49,17 @@ function DateTimePickerContent(props) {
);
}
return (
<React.Fragment>
<PickerHeader
onDateClick={handleHeaderTimeClick}
onNextBtnClick={showNextDay}
onPrevBtnClick={showPrevDay}
activeDate={activeDate}
includeDay
width={headerWidth} />
<TimePickerComponent
mode={mode}
activeHour={activeHour}
activeMinute={activeMinute}
onHourClick={onHourClick}
onMinuteClick={onMinuteClick} />
</React.Fragment>
<TimePickerComponent
mode={mode}
showDate
activeHour={activeHour}
activeMinute={activeMinute}
onHourClick={onHourClick}
onMinuteClick={onMinuteClick}
handleHeaderTimeClick={handleHeaderTimeClick}
activeDate={activeDate}
showNextDay={showNextDay}
showPrevDay={showPrevDay} />
);
}

Expand Down
8 changes: 6 additions & 2 deletions src/components/pickerContent/DatesRangePickerContent.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Table } from 'semantic-ui-react';

import { PickerHeader, DatePickerComponent } from '..';
import { CustomPropTypes } from '../../lib/customPropTypes';
Expand All @@ -14,7 +15,10 @@ function DatesRangePickerContent(props) {
setDatesRange
} = props;
return (
<React.Fragment>
<Table
unstackable
celled
textAlign="center">
<PickerHeader
onDateClick={handleHeaderDateClick}
onNextBtnClick={showNextMonth}
Expand All @@ -27,7 +31,7 @@ function DatesRangePickerContent(props) {
datesRange={datesRange}
onDateClick={setDatesRange}
showedMonth={dateToShow} />
</React.Fragment>
</Table>
);
}

Expand Down
8 changes: 6 additions & 2 deletions src/components/pickerModes/DayMode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Table } from 'semantic-ui-react';

import { PickerHeader, DatePickerComponent } from '..';
import { CustomPropTypes } from '../../lib/customPropTypes';
Expand All @@ -14,7 +15,10 @@ function DayMode(props) {
activeDate
} = props;
return (
<React.Fragment>
<Table
unstackable
celled
textAlign="center">
<PickerHeader
onDateClick={handleHeaderDateClick}
onNextBtnClick={showNextMonth}
Expand All @@ -26,7 +30,7 @@ function DayMode(props) {
onDateClick={onDateClick}
activeDate={activeDate}
showedMonth={dateToShow} />
</React.Fragment>
</Table>
);
}

Expand Down
8 changes: 6 additions & 2 deletions src/components/pickerModes/MonthMode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Table } from 'semantic-ui-react';

import { PickerHeader, MonthPickerComponent } from '..';
import { CustomPropTypes } from '../../lib/customPropTypes';
Expand All @@ -13,7 +14,10 @@ function MonthMode(props) {
onMonthChange
} = props;
return (
<React.Fragment>
<Table
unstackable
celled
textAlign="center">
<PickerHeader
onDateClick={handleHeaderDateClick}
onNextBtnClick={showNextYear}
Expand All @@ -23,7 +27,7 @@ function MonthMode(props) {
<MonthPickerComponent
activeMonth={dateToShow.format('MMM')}
onMonthClick={onMonthChange} />
</React.Fragment>
</Table>
);
}

Expand Down
8 changes: 6 additions & 2 deletions src/components/pickerModes/YearMode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Table } from 'semantic-ui-react';

import { PickerHeader, YearPickerComponent } from '..';
import { CustomPropTypes } from '../../lib/customPropTypes';
Expand All @@ -14,7 +15,10 @@ function YearMode(props) {
value
} = props;
return (
<React.Fragment>
<Table
unstackable
celled
textAlign="center">
<PickerHeader
width="3"
onDateClick={onHeaderDateClick}
Expand All @@ -25,7 +29,7 @@ function YearMode(props) {
onYearClick={onYearClick}
activeYear={value}
yearsStart={yearsRange.start} />
</React.Fragment>
</Table>
);
}

Expand Down
36 changes: 15 additions & 21 deletions src/containers/inputs/DateInput.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { Table } from 'semantic-ui-react';
import PropTypes from 'prop-types';

import {
Expand Down Expand Up @@ -45,26 +44,21 @@ class DateInput extends YearPickerMixin {
activeDate
} = this.props.wrapperState;
return (
<Table
unstackable
celled
textAlign="center">
<DatePickerContent
mode={mode}
handleHeaderDateClick={handleHeaderDateClick}
onYearChange={onYearChange}
showNextYear={showNextYear}
showPrevYear={showPrevYear}
dateToShow={dateToShow}
onMonthChange={onMonthChange}
showNextMonth={showNextMonth}
showPrevMonth={showPrevMonth}
onDateClick={onDateClick}
activeDate={activeDate}
yearsRange={this.getYearsRange()}
onPrevBtnClick={this.onPrevBtnClick}
onNextBtnClick={this.onNextBtnClick} />
</Table>
<DatePickerContent
mode={mode}
handleHeaderDateClick={handleHeaderDateClick}
onYearChange={onYearChange}
showNextYear={showNextYear}
showPrevYear={showPrevYear}
dateToShow={dateToShow}
onMonthChange={onMonthChange}
showNextMonth={showNextMonth}
showPrevMonth={showPrevMonth}
onDateClick={onDateClick}
activeDate={activeDate}
yearsRange={this.getYearsRange()}
onPrevBtnClick={this.onPrevBtnClick}
onNextBtnClick={this.onNextBtnClick} />
);
}

Expand Down
49 changes: 22 additions & 27 deletions src/containers/inputs/DateTimeInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,28 @@ class DateTimeInput extends YearPickerMixin {
onMinuteClick
} = this.props.wrapperState;
return (
<Table
unstackable
celled
textAlign="center">
<DateTimePickerContent
activeDate={dateToShow}
activeHour={activeHour}
activeMinute={activeMinute}
mode={mode}
handleHeaderDateClick={handleHeaderDateClick}
handleHeaderTimeClick={handleHeaderTimeClick}
onYearChange={onYearChange}
showNextMonth={showNextMonth}
showPrevMonth={showPrevMonth}
showNextYear={showNextYear}
showPrevYear={showPrevYear}
showNextDay={showNextDay}
showPrevDay={showPrevDay}
dateToShow={dateToShow}
onMonthChange={onMonthChange}
onDateClick={onDateClick}
onHourClick={onHourClick}
onMinuteClick={onMinuteClick}
yearsRange={this.getYearsRange()}
onPrevBtnClick={this.onPrevBtnClick}
onNextBtnClick={this.onNextBtnClick} />
</Table>
<DateTimePickerContent
activeDate={dateToShow}
activeHour={activeHour}
activeMinute={activeMinute}
mode={mode}
handleHeaderDateClick={handleHeaderDateClick}
handleHeaderTimeClick={handleHeaderTimeClick}
onYearChange={onYearChange}
showNextMonth={showNextMonth}
showPrevMonth={showPrevMonth}
showNextYear={showNextYear}
showPrevYear={showPrevYear}
showNextDay={showNextDay}
showPrevDay={showPrevDay}
dateToShow={dateToShow}
onMonthChange={onMonthChange}
onDateClick={onDateClick}
onHourClick={onHourClick}
onMinuteClick={onMinuteClick}
yearsRange={this.getYearsRange()}
onPrevBtnClick={this.onPrevBtnClick}
onNextBtnClick={this.onNextBtnClick} />
);
}

Expand Down
19 changes: 7 additions & 12 deletions src/containers/inputs/DatesRangeInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,13 @@ class DatesRangeInput extends React.Component {
setDatesRange
} = this.props.wrapperState;
return (
<Table
unstackable
celled
textAlign="center">
<DatesRangePickerContent
handleHeaderDateClick={handleHeaderDateClick}
showNextMonth={showNextMonth}
showPrevMonth={showPrevMonth}
dateToShow={dateToShow}
datesRange={datesRange}
setDatesRange={setDatesRange} />
</Table>
<DatesRangePickerContent
handleHeaderDateClick={handleHeaderDateClick}
showNextMonth={showNextMonth}
showPrevMonth={showPrevMonth}
dateToShow={dateToShow}
datesRange={datesRange}
setDatesRange={setDatesRange} />
);
}

Expand Down
Loading

0 comments on commit 40dd5df

Please sign in to comment.