import { __assign } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import { useContext, useCallback } from 'react';
import { I18nReceiver as Receiver } from '../i18n';
import SinglePicker from './components/SinglePickerBase';
import MonthPanel from './panels/month-panel';
import { DisabledContext } from '../disabled';
import PickerContext from './context/PickerContext';
import { getCallbackValueWithDate } from './utils/getValueInSinglePicker';
import { dateConfig } from './utils/dateUtils';
import { formatText } from './utils/formatInputText';
import { MONTH_FORMAT, defaultDatePickerCommonProps } from './constants';
var generateDate = dateConfig.month;
var PickerContextProvider = PickerContext.Provider;
var DefaultMonthPickerProps = {
    format: MONTH_FORMAT,
};
export var MonthPicker = function (props) {
    var disabledContext = useContext(DisabledContext);
    var propsRequired = __assign(__assign(__assign({}, defaultDatePickerCommonProps), DefaultMonthPickerProps), props);
    var format = propsRequired.format, valueType = propsRequired.valueType, placeholder = propsRequired.placeholder, _a = propsRequired.disabled, disabled = _a === void 0 ? disabledContext.value : _a;
    var getInputText = useCallback(function (val) { return formatText(val, format); }, [format]);
    var getSelectedValue = useCallback(function (val) { return val; }, []);
    var getCallbackValue = useCallback(function (val) { return getCallbackValueWithDate(val, valueType, format); }, [valueType, format]);
    return (_jsx(Receiver, __assign({ componentName: "TimePicker" }, { children: function (i18n) { return (_jsx(PickerContextProvider, __assign({ value: {
                i18n: i18n,
                generateDate: generateDate,
                getCallbackValue: getCallbackValue,
                getSelectedValue: getSelectedValue,
                getInputText: getInputText,
            } }, { children: _jsx(SinglePicker, __assign({}, propsRequired, { disabled: disabled, placeholder: placeholder || i18n.month, PanelComponent: MonthPanel }), void 0) }), void 0)); } }), void 0));
};
export default MonthPicker;
