2.0.4 • Published 5 years ago
@fdmg/fd-inputs v2.0.4
fd-inputs
FD-themed inputs
Installation
- Run
npm i -D @fdmg/fd-inputs
Demo
To run the demo, check-out this repository and run npm run build-demo
.
After the build succeeded you can open dist/demo.html
with your webbrowser.
Props
When developing in TypeScript autocompletion and code documentation is shown in IDE's like Visual Studio Code.
export interface Props {
/**
* Mandatory id of the input element.
*/
id: string;
/**
* Optional name of the input element. Id is used when name is unset.
*/
name?: string;
/**
* Optional className is set as the className of the outmost container element.
*/
className?: string;
/**
* Optional value of the input element.
*/
value?: string;
/**
* Optional. When true the default input validation kicks in. Tip: use in combination with pattern.
*/
required?: boolean;
/**
* Optional. The pattern to which the input value is validated. Only works when required is set to true.
* Tip: the exported Patterns enum already contains some validation rules for common use-cases.
*/
pattern?: Patterns | string;
/**
* Optional. The label shown in the input field.
*/
label?: string;
/**
* Optional. The native browser tooltip text shown on hover. When omitted then the label is used.
*/
title?: string;
/**
* Optional. Custom error message shown when the value does fit the pattern.
*/
errorMessage?: string;
/**
* Optional. Type of the input field. Default is `text`.
*/
type?: string;
/**
* Optional minimum length of the input field.
*/
minLength?: number;
/**
* Optional maximum length of the input field.
*/
maxLength?: number;
/**
* Optional callback hook triggered when a change event occured in the input field.
*/
onChange?: (value: React.ChangeEvent<HTMLInputElement>) => void;
onFocus?: (value: React.FocusEvent<HTMLInputElement>) => void;
onBlur?: (value: React.FocusEvent<HTMLInputElement>) => void;
/**
* Optional. Store the value to localStorage which will be used as default value upon subsequent visits of the page.
* Tip: `id` is used as suffix for the property name.
*/
localStorage?: boolean;
}
Usage
import {TextInput} from '@fdmg/fd-inputs';
...
<TextInput id="email1" type="email" label="E-mailadres" required={true} pattern={Patterns.EMAIL} errorMessage="Voer een geldig e-mailadres in"/>
2.0.4
5 years ago
2.0.3
6 years ago
2.0.2
6 years ago
2.0.1
6 years ago
2.0.0
6 years ago
1.0.24
6 years ago
1.0.23
6 years ago
1.0.22
6 years ago
1.0.21
6 years ago
1.0.20
6 years ago
1.0.19
6 years ago
1.0.18
6 years ago
1.0.17
6 years ago
1.0.16
6 years ago
1.0.15
6 years ago
1.0.14
6 years ago
1.0.13
6 years ago
1.0.12
6 years ago
1.0.11
6 years ago
1.0.10
7 years ago
1.0.9
7 years ago
1.0.8
7 years ago
1.0.7
7 years ago
1.0.6
7 years ago
1.0.5
7 years ago
1.0.4
7 years ago
1.0.3
7 years ago
1.0.2
7 years ago
1.0.1
7 years ago
1.0.0
7 years ago