@capgeminiuk/dcx-react-library
Version:
[](https://circleci.com/gh/Capgemini/dcx-react-library)
118 lines (117 loc) • 2.75 kB
TypeScript
import React, { RefObject } from 'react';
import { HintProps, VisuallyHidden } from '../common/components/commonTypes';
type CharacterCountProps = React.HTMLAttributes<HTMLTextAreaElement> & {
/**
* textarea label
*/
label?: string;
/**
* textarea hint
*/
hint?: HintProps;
/**
* component container class name
*/
containerClassName?: string;
/**
* form group class name
*/
formGroupClassName?: string;
/**
* label class name
*/
labelClassName?: string;
/**
* textarea class name
*/
textareaClassName?: string;
/**
* textarea error class name
*/
textareaErrorClassName?: string;
/**
* character count message class name
*/
messageClassName?: string;
/**
* character count message error class name
*/
messageErrorClassName?: string;
/**
* component id
*/
id?: string;
/**
* textarea name
*/
name?: string;
/**
* text in textarea
*/
value?: string;
/**
* textarea rows value
*/
rows?: number;
/**
* textarea columns value
*/
cols?: number;
/**
* maximum character or word value
*/
maxLength: number;
/**
* type of limit characters or words
*/
limitType?: 'characters' | 'words';
/**
* place constraint on number of words/characters can be typed in the textbox
*/
constrained?: boolean;
/**
* threshold value in percentage to show remaining characters or words message
*/
threshold?: number;
/**
* textarea aria-describedby
*/
ariaDescribedBy?: string;
/**
* onChange event
*/
onChange?: (event: React.FormEvent<HTMLTextAreaElement>) => void;
/**
* show/hide error
*/
displayError?: boolean;
/**
* error message
*/
errorMessage?: string;
/**
* error message class name
*/
errorMessageClassName?: string;
/**
* error id
*/
errorId?: string;
/**
* visually hidden text of the error
*/
errorVisuallyHiddenText?: VisuallyHidden;
/**
* will allow to specify a custom message
*/
customMaxCharMsgFunc?: (remainingCount?: number, overLimitBy?: number, hydrated?: boolean) => string;
/**
* will allow to expose the reset function to clear textbox and reset the component;
* @example
* const textRef = useRef<any>(null);
* <Button onClick={() => textRef.current.reset()} label="Cancel" />
*/
ref?: RefObject<any>;
};
export declare const CharacterCount: React.ForwardRefExoticComponent<Omit<CharacterCountProps, "ref"> & React.RefAttributes<unknown>>;
export {};