carbon-react
Version:
A library of reusable React components for easily building user interfaces.
54 lines (53 loc) • 2.39 kB
TypeScript
import React from "react";
import { TextboxProps } from "../textbox";
import { PickerProps } from "./__internal__/date-picker";
import { InputName } from "../date-range/__internal__/date-range.context";
export interface DateChangeEvent {
target: {
id?: string;
name?: string;
value: {
formattedValue: string;
rawValue: string | null;
};
};
}
export interface DateInputProps extends Omit<TextboxProps, "value" | "formattedValue" | "rawValue" | "onChange" | "onBlur" | "onMouseDown" | "onChangeDeferred" | "deferTimeout" | "children" | "leftChildren" | "placeholder" | "iconOnClick" | "iconOnMouseDown" | "characterLimit" | "warnOverLimit" | "iconTabIndex" | "inputIcon" | "data-component"> {
/** Boolean to allow the input to have an empty value */
allowEmptyValue?: boolean;
/** Boolean to toggle where DatePicker is rendered in relation to the Date Input */
disablePortal?: boolean;
/** Minimum possible date YYYY-MM-DD */
minDate?: string;
/** Maximum possible date YYYY-MM-DD */
maxDate?: string;
/** Specify a callback triggered on change */
onChange: (ev: DateChangeEvent) => void;
/** Specify a callback triggered on blur */
onBlur?: (ev: DateChangeEvent) => void;
/** The current date string */
value: string;
/**
* Pass any props that match the DayPickerProps interface to override default behaviors
* See [DayPickerProps](https://daypicker.dev/api/type-aliases/DayPickerProps) for a full list of available props
* */
pickerProps?: PickerProps;
/**
* @private
* @ignore
* Name passed from DateRange to allow it to know which input is updating
* */
inputName?: InputName;
/** Callback triggered when the picker is opened */
onPickerOpen?: () => void;
/** Callback triggered when the picker is closed */
onPickerClose?: () => void;
/** Date format string to be applied to the date inputs */
dateFormatOverride?: string;
/** Prop to specify the aria-label attribute of the date picker */
datePickerAriaLabel?: string;
/** Prop to specify the aria-labelledby attribute of the date picker */
datePickerAriaLabelledBy?: string;
}
export declare const DateInput: React.ForwardRefExoticComponent<DateInputProps & React.RefAttributes<HTMLInputElement>>;
export default DateInput;