import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { cn } from '../../../utils/cn.js';
import { DataFormFieldLayout } from '../shared/data_form_field_layout.js';
export function DateField(props) {
    const { field, mode, value, config, on_change, on_blur, paired_value, paired_on_change } = props;
    const date_value = value != null ? String(value) : '';
    const paired_date_value = paired_value != null ? String(paired_value) : '';
    const has_paired = Boolean(field.paired_field);
    const field_style = config.style_resolver.has_style(mode === 'view' ? 'field_view' : 'field')
        ? config.style_resolver.to_style(mode === 'view' ? 'field_view' : 'field')
        : undefined;
    if (has_paired) {
        return (_jsx(DataFormFieldLayout, { ...props, children: _jsx("div", { className: "flex items-center gap-2", children: mode === 'edit' ? (_jsxs(_Fragment, { children: [_jsx("input", { type: "date", className: cn('cls_data_form_date_input', 'flex-1'), style: field_style, value: date_value, disabled: field.disabled, onChange: (e) => on_change(e.target.value), onBlur: on_blur }), _jsx("span", { className: "text-gray-400 text-sm", children: "to" }), _jsx("input", { type: "date", className: cn('cls_data_form_date_input', 'flex-1'), style: field_style, value: paired_date_value, disabled: field.paired_field?.disabled, onChange: (e) => paired_on_change?.(e.target.value), onBlur: on_blur })] })) : (_jsx("div", { className: "cls_data_form_date_view", style: field_style, children: date_value ? `${date_value} to ${paired_date_value || '...'}` : '\u00A0' })) }) }));
    }
    return (_jsx(DataFormFieldLayout, { ...props, children: mode === 'edit' ? (_jsx("input", { type: "date", className: cn('cls_data_form_date_input', 'w-full'), style: field_style, value: date_value, disabled: field.disabled, onChange: (e) => on_change(e.target.value), onBlur: on_blur })) : (_jsx("div", { className: "cls_data_form_date_view", style: field_style, children: date_value || '\u00A0' })) }));
}
//# sourceMappingURL=date_field.js.map