diff --git a/.eslintrc.json b/.eslintrc.json index 81bfba99..dc8c2e79 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -19,7 +19,6 @@ "reservedFirst": ["key"] }], "react/require-default-props": "off", - "react/sort-comp": "off", "react/sort-prop-types": "error" }, "overrides": [ diff --git a/src/Calendar.jsx b/src/Calendar.jsx index 5db5d18d..542853db 100644 --- a/src/Calendar.jsx +++ b/src/Calendar.jsx @@ -153,54 +153,6 @@ const getActiveStartDate = (props) => { }; export default class Calendar extends Component { - get drillDownAvailable() { - const { maxDetail, minDetail } = this.props; - const { view } = this.state; - - const views = getLimitedViews(minDetail, maxDetail); - - return views.indexOf(view) < views.length - 1; - } - - get drillUpAvailable() { - const { maxDetail, minDetail } = this.props; - const { view } = this.state; - - const views = getLimitedViews(minDetail, maxDetail); - - return views.indexOf(view) > 0; - } - - get valueType() { - const { maxDetail } = this.props; - - return getValueType(maxDetail); - } - - /** - * Gets current value in a desired format. - */ - getProcessedValue(value) { - const { - minDate, maxDate, maxDetail, returnValue, - } = this.props; - - const processFunction = (() => { - switch (returnValue) { - case 'start': - return getDetailValueFrom; - case 'end': - return getDetailValueTo; - case 'range': - return getDetailValueArray; - default: - throw new Error('Invalid returnValue.'); - } - })(); - - return processFunction(value, minDate, maxDate, maxDetail); - } - static getDerivedStateFromProps(nextProps, prevState) { const { minDate, maxDate, minDetail, maxDetail, @@ -256,6 +208,54 @@ export default class Calendar extends Component { state = {}; + get drillDownAvailable() { + const { maxDetail, minDetail } = this.props; + const { view } = this.state; + + const views = getLimitedViews(minDetail, maxDetail); + + return views.indexOf(view) < views.length - 1; + } + + get drillUpAvailable() { + const { maxDetail, minDetail } = this.props; + const { view } = this.state; + + const views = getLimitedViews(minDetail, maxDetail); + + return views.indexOf(view) > 0; + } + + get valueType() { + const { maxDetail } = this.props; + + return getValueType(maxDetail); + } + + /** + * Gets current value in a desired format. + */ + getProcessedValue(value) { + const { + minDate, maxDate, maxDetail, returnValue, + } = this.props; + + const processFunction = (() => { + switch (returnValue) { + case 'start': + return getDetailValueFrom; + case 'end': + return getDetailValueTo; + case 'range': + return getDetailValueArray; + default: + throw new Error('Invalid returnValue.'); + } + })(); + + return processFunction(value, minDate, maxDate, maxDetail); + } + /** * Called when the user uses navigation buttons. */