import { __assign } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import { useCallback, useState } from 'react';
import DateRangeQuickPicker from '../../date-range-quick-picker';
import { dateRangeDefaultValueFactory, } from '../shared';
import { FormField } from '../Field';
import { useEventCallbackRef } from '../../utils/hooks/useEventCallbackRef';
var DateRangeQuickPickerField = function (_a) {
    var childProps = _a.childProps, props = _a.props;
    var _b = useState(undefined), chosenDays = _b[0], setChosenDays = _b[1];
    var onChangeRef = useEventCallbackRef(childProps.onChange);
    var onChange = useCallback(function (value, chosenDays) {
        var _a;
        (_a = onChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onChangeRef, value);
        setChosenDays(chosenDays);
    }, [onChangeRef]);
    return (_jsx(DateRangeQuickPicker, __assign({}, props.props, childProps, { chosenDays: chosenDays, onChange: onChange }), void 0));
};
export var FormDateRangeQuickPickerField = function (props) {
    var _a;
    return (_jsx(FormField, __assign({}, props, { defaultValue: (_a = props
            .defaultValue) !== null && _a !== void 0 ? _a : dateRangeDefaultValueFactory }, { children: function (childProps) { return (_jsx(DateRangeQuickPickerField, { childProps: childProps, props: props }, void 0)); } }), void 0));
};
