UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

39 lines (38 loc) 2.24 kB
import type { ReactElement } from 'react'; import type { FieldProps, Validator, ValidatorWithCustomValidators } from '../../types'; import type { DatePickerProps } from '../../../../components/DatePicker'; import { datePickerPropKeys } from './datePickerPropKeys'; export type DateValidator = ValidatorWithCustomValidators<string, { dateValidator: Validator<string>; }>; export type DateProps = Omit<FieldProps<string, undefined | string>, 'onBlurValidator'> & { pattern?: string; /** * Defines if the Date field should support a value of two dates (starting and ending date). * The value needs to be a string containing two dates, separated by a pipe character (`|`) e.g. (`01-09-2024|30-09-2024`) when this is set to `true`. * Defaults to `false`. */ range?: DatePickerProps['range']; /** * If set to `true`, only one calendar is shown in range mode instead of two side-by-side calendars. Only meant to be used if `range` is set to `true`. Defaults to `false`. */ rangeSingleCalendar?: DatePickerProps['rangeSingleCalendar']; /** * If the input fields with the mask should be visible. Defaults to `true`. */ showInput?: DatePickerProps['showInput']; /** * If set to `true`, a cancel button will be shown. You can change the default text by using `cancelButtonText="Avbryt"`. Defaults to `true`. If the `range` property is `true`, then the cancel button is shown. */ showCancelButton?: DatePickerProps['showCancelButton']; /** * If set to `true`, a reset button will be shown. You can change the default text by using `resetButtonText="Tilbakestill"`. When clicked, the field resets to the initial `value` or `defaultValue`. If no initial value was provided, the field is cleared. Defaults to `true`. */ showResetButton?: DatePickerProps['showResetButton']; onBlurValidator?: DateValidator | false; } & PickedDatePickerProps; declare function DateComponent(props: DateProps): ReactElement; export declare function parseRangeValue(value: DateProps['value']): Array<string | null>; export { datePickerPropKeys }; type PickedDatePickerProps = Pick<DatePickerProps, (typeof datePickerPropKeys)[number]>; export default DateComponent;