UNPKG

@capgeminiuk/dcx-react-library

Version:

[![CircleCI](https://circleci.com/gh/Capgemini/dcx-react-library.svg?style=svg)](https://circleci.com/gh/Capgemini/dcx-react-library)

125 lines (124 loc) 3.59 kB
import React from 'react'; export type DateType = { label?: string; classNameInput?: string; classNameLabel?: string; classNameSpan?: string; customLabel?: JSX.Element; tabIndex?: number; }; type ErrorPosition = 'top' | 'bottom'; type FormDateProps = { /** * Different type format accepted */ dateFormat: 'dd/mm/yyyy' | 'DD/MM/YYYY' | 'dd/mm/yy' | 'DD/MM/YY' | 'yyyy/mm/dd' | 'YYYY/MM/DD' | 'yy/mm/dd' | 'YY/MM/DD'; /** * It will return if the date is valid and the actual value */ handleValidity: (isValid: boolean, value: number | null) => void; /** * optional className for the container */ inputContainerClass?: string; /** * optional className to style all the input */ inputClass?: string; /** * all the properties available to customise the year: * // input label * label?: string; * //optional className for the input * classNameInput?: string; * //optional className for the label * classNameLabel?: string; * // optional className for the span * classNameSpan?: string; * // if you want to pass a custom Label (i.e. an h1 etc) * customLabel?: JSX.Element; * // if you want to pass tab index for the input * tabIndex?: number; */ yearProps?: DateType; /** * all the properties available to customise the month: * // input label * label?: string; * //optional className for the input * classNameInput?: string; * //optional className for the label * classNameLabel?: string; * // optional className for the span * classNameSpan?: string; * // if you want to pass a custom Label (i.e. an h1 etc) * customLabel?: JSX.Element; * // if you want to pass tab index for the input * tabIndex?: number; */ monthProps?: DateType; /** * all the properties available to customise the day: * // input label * label?: string; * //optional className for the input * classNameInput?: string; * //optional className for the label * classNameLabel?: string; * // optional className for the span * classNameSpan?: string; * // if you want to pass a custom Label (i.e. an h1 etc) * customLabel?: JSX.Element; * // if you want to pass tab index for the input * tabIndex?: number; */ dayProps?: DateType; /** * show hide error */ displayError?: boolean; /** * error message **/ errorMessage?: any; /** * error position - top or bottom **/ errorPosition?: ErrorPosition; /** * class to style the error */ errorClass?: string; /** * define a pre-set day */ day?: string; /** * define a pre-set month */ month?: string; /** * define a pre-set year */ year?: string; /** * allow to disable the input */ disabled?: boolean; }; type State = { day: string | undefined; month: string | undefined; year: string | undefined; }; type Action = { type: 'setYear' | 'setMonth' | 'setDay'; value: string; }; export declare function reducer(state: State, action: Action): { day: string | undefined; month: string | undefined; year: string | undefined; }; export declare const FormDate: ({ dateFormat, handleValidity, inputContainerClass, inputClass, yearProps, monthProps, dayProps, displayError, errorPosition, errorMessage, errorClass, day, month, year, disabled, }: FormDateProps) => React.JSX.Element; export {};