@adaptabletools/adaptable
Version:
Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
37 lines (36 loc) • 1.62 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import * as React from 'react';
import { Datepicker } from '../../../components/Datepicker';
import { useAdaptable } from '../../AdaptableContext';
import useProperty from '../../../components/utils/useProperty';
import { dateToISO, parseDateValue } from '../../../Utilities/Helpers/DateHelper';
const AdaptableDateInput = React.forwardRef(function AdaptableDateInputCmp(props, ref) {
const dateInputOptions = useAdaptable().adaptableOptions.userInterfaceOptions.dateInputOptions;
const { value: _, defaultValue: __, onChange, required, disabled, showClearButton, showTriggerButton, ...inputProps } = props;
const [value, setValue] = useProperty(props, 'value', undefined, {
onChange: (dateString) => props.onChange?.({
target: {
value: dateString,
},
}),
});
const dateValue = value ? parseDateValue(value) : null;
const datepickerProps = {
value: dateValue,
onChange: (dateValue) => setValue(dateToISO(dateValue) ?? ''),
required,
disabled,
dateProps: {
format: dateInputOptions.dateFormat,
locale: dateInputOptions.locale,
},
showWeekNumber: dateInputOptions.showWeekNumber,
showOutsideDays: dateInputOptions.showOutsideDays,
datepickerButtons: dateInputOptions.datepickerButtons,
showClearButton,
showTriggerButton: showTriggerButton ?? true,
...inputProps,
};
return _jsx(Datepicker, { ref: ref, ...datepickerProps });
});
export default AdaptableDateInput;