import React from 'react'; import PropTypes from 'prop-types'; import { ComponentProps } from '../utils/types'; /** @public */ type DateChangeHandler = (event: React.MouseEvent | React.KeyboardEvent | React.KeyboardEvent | KeyboardEvent | MouseEvent | TouchEvent | undefined, data: { name?: string; value: string; }) => void; /** @public */ type DateBlurHandler = (event: React.FocusEvent, data: { name?: string; value: string; }) => void; /** @public */ type DateFocusHandler = (event: React.FocusEvent, data: { name?: string; value: string; }) => void; interface DatePropsBase { /** Append removes rounded borders and the border from the right side. */ append?: boolean; /** * Include an "X" button to clear the value. */ canClear?: boolean; /** Default date to display. Set this instead of value to make the Date uncontrolled. */ defaultValue?: string; /** * The id of the description. When placed in a ControlGroup, this automatically set to the * ControlGroup's help component. */ describedBy?: string; /** Add a disabled attribute and prevent clicking. */ disabled?: boolean; /** * A React ref which is set to the DOM element when the component mounts and null when it unmounts. */ elementRef?: React.Ref; /** * Highlight the field as having an error. The border and text will turn red. */ error?: boolean; /** Highlight today's day. */ highlightToday?: boolean; /** When false, display as inline-block with the default width. */ inline?: boolean; /** * The id of the label. When placed in a ControlGroup, this automatically set to the * ControlGroup's label. */ labelledBy?: string; /** * An id for the input, which may be necessary for accessibility, such as for aria * attributes. */ inputId?: string; /** * Whether or not to display the calendar menu. */ inputOnly?: boolean; /** Locale set by language and localization specifiers. */ locale?: string; /** The name is returned with onChange events, which can be used to identify the * control when multiple controls share an onChange callback. */ name?: string; /** A callback for when the input loses focus. */ onBlur?: DateBlurHandler; /** * Return event and data object with date string (in YYYY-MM-DD format) when a date is * selected. */ onChange?: DateChangeHandler; onClick?: React.MouseEventHandler; onFocus?: DateFocusHandler; onKeyDown?: React.KeyboardEventHandler; /** Prepend removes rounded borders from the left side. */ prepend?: boolean; /** * Setting this value makes the property controlled. An onChange callback is required. * * The value must be "" or in the format 'YYYY-MM-DD'. To simplify creation of these strings, * Date provides a Moment.js formatting string: * ``` * moment().format(Date.momentFormat); * ``` */ value?: string; } interface DatePropsBaseControlled extends DatePropsBase { defaultValue?: never; onChange: DateChangeHandler; value?: string; } interface DatePropsBaseUncontrolled extends DatePropsBase { defaultValue?: string; value?: never; } type DateProps = ComponentProps; declare const validateValue: (value: string | undefined) => void; declare function Date({ append, canClear, defaultValue, disabled, elementRef, highlightToday, inline, inputOnly, locale, name, onChange, onClick, onFocus, onKeyDown, prepend, value: valueProp, ...otherProps }: DateProps): React.JSX.Element; declare namespace Date { var propTypes: { append: PropTypes.Requireable; canClear: PropTypes.Requireable; defaultValue: PropTypes.Requireable; describedBy: PropTypes.Requireable; disabled: PropTypes.Requireable; elementRef: PropTypes.Requireable; error: PropTypes.Requireable; highlightToday: PropTypes.Requireable; inline: PropTypes.Requireable; inputId: PropTypes.Requireable; inputOnly: PropTypes.Requireable; labelledBy: PropTypes.Requireable; locale: PropTypes.Requireable; name: PropTypes.Requireable; onBlur: PropTypes.Requireable<(...args: any[]) => any>; onChange: PropTypes.Requireable<(...args: any[]) => any>; onClick: PropTypes.Requireable<(...args: any[]) => any>; onFocus: PropTypes.Requireable<(...args: any[]) => any>; onKeyDown: PropTypes.Requireable<(...args: any[]) => any>; prepend: PropTypes.Requireable; value: PropTypes.Requireable; }; var momentFormat: string; } export default Date; export { DateBlurHandler, DateChangeHandler, DateFocusHandler, validateValue }; export type { DatePropsBase, DatePropsBaseControlled, DatePropsBaseUncontrolled };