/** @format */ /** * External dependencies */ import { __ } from '@wordpress/i18n'; import { Component, Fragment } from '@wordpress/element'; import { TabPanel, Button } from '@wordpress/components'; import PropTypes from 'prop-types'; import classnames from 'classnames'; /** * Internal dependencies */ import ComparePeriods from './compare-periods'; import { H, Section } from 'layout/section'; import PresetPeriods from './preset-periods'; import Link from 'components/link'; import { DateRange } from 'components/calendar'; const isMobileViewport = () => window.innerWidth < 782; class DatePickerContent extends Component { constructor() { super(); this.onTabSelect = this.onTabSelect.bind( this ); } onTabSelect( tab ) { const { onSelect, period } = this.props; /** * If the period is `custom` and the user switches tabs to view the presets, * then a preset should be selected. This logic selects the default, otherwise * `custom` value for period will result in no selection. */ if ( 'period' === tab && 'custom' === period ) { onSelect( { period: 'today' } ); } } render() { const { period, compare, after, before, onSelect, onClose, getUpdatePath, isValidSelection, resetCustomValues, } = this.props; return (