import React from 'react';
import { classes } from './CalendarPanel.st.css.js';
import DropdownLayout from '../DropdownLayout';
import Calendar from '../Calendar';
import { DIVIDER_OPTION_VALUE } from '../DropdownLayout/DropdownLayout.constants';
import { SupportedWixLocales } from '@wix/design-systems-locale-utils';
class CalendarPanel extends React.Component {
    constructor() {
        super(...arguments);
        this.onSelectPreset = preset => {
            const { onChange } = this.props;
            onChange(preset.selectedDays);
        };
    }
    getSelectedPresetId() {
        const { presets = [], value } = this.props;
        const selectedPreset = presets.find(preset => Calendar.areValuesEqual(preset.selectedDays, value));
        return selectedPreset ? selectedPreset.id : -1;
    }
    isSubmitDisabled() {
        const { selectionMode, value } = this.props;
        if (selectionMode === 'range') {
            return !Boolean(value) || !Boolean(value.from) || !Boolean(value.to);
        }
        return !Boolean(value);
    }
    render() {
        const { dataHook, presets, footer, ...calendarProps } = this.props;
        return (React.createElement("div", { className: classes.root, "data-hook": dataHook },
            React.createElement("div", { className: classes.calendarWithPresets },
                Boolean(presets && presets.length) && (React.createElement("div", { className: classes.presets },
                    React.createElement(DropdownLayout, { visible: true, inContainer: true, onSelect: this.onSelectPreset, dataHook: "dropdown-layout", options: presets, maxHeightPixels: 342, selectedId: this.getSelectedPresetId() }))),
                React.createElement(Calendar, { ...calendarProps, dataHook: "calendar", className: classes.calendar })),
            footer && (React.createElement("div", { className: classes.footer }, footer({
                selectedDays: calendarProps.value,
                submitDisabled: this.isSubmitDisabled(),
            })))));
    }
}
CalendarPanel.displayName = 'CalendarPanel';
CalendarPanel.defaultProps = {
    numOfMonths: 2,
};
export default CalendarPanel;
//# sourceMappingURL=CalendarPanel.js.map