input-style-one
v1.5.1
Published
React-based input component, espessially created for WExport 2.0 project. π
Downloads
124
Readme
WExport InputStyleOne
React-based input component, espessially created for WExport 2.0 project. π
This component include following input types based on other popular npm packages:
- TEXT INPUT - simple input with wexport based styles
- TEXTAREA - thanks to author of npm package "react-textarea-autosize"
- SELECT - thanks to author of npm package "react-select"
- NUMBER FORMAT - thanks to author of npm package "react-number-format"
- DAY PICKER - thanks to author of npm package "react-day-picker"
Installation
$ npm install input-style-one
Props
@required
label
- set text above the input tag, placeholder ifplaceholder
not set and used in tooltip header. SetshowLabel = false
if you need to hide text above input.name
- name property of input taghandleChange({name, value, label, isValid} => void)
- HandleChange event of input.value
- value of input tagname
- name of input tag. Used on this.setState([name]: value). Not necessary if you use React Hookslabel
- used only wheninputType="select"
. this value return the select component label. Sometimes it is necessary to store the label of selected value. Example:selectOptions: [{value:1, label: "Option One"}, {value: "2", label: "Options Two"}]
isValid
- returntrue
if input satisfy all rules.
@optional
layout?
-@deprecated
. It means that component always keep structure [label
input
]. Iflayout="one"
,label
aboveinput
will be hidden,input
field will be with iconiconUrl
propertyenableTooltip?
-true
by default. Enable or dirable left side PopovershowLabel?
-true
by default. Show or hidelabel
text above input.showOptionalLabel?
-true
by default. Show or hide "optional" text inlabel
no matterrequired
rule is accepted.inputType?
-text
by default. Available options:select
,multi-select
,password
,textArea
,datePicker
andnumberFormat
disabled?
-false
by default. Set this proptrue
whenever input should be sidabledautocomplete?
-true
by default. Set this proptrue
whenever htmlautocomplete
property should be enabled/disabledplaceholder?
- equals tolabel
by default.minRows?
- minRow prop of text area autosize package. Will be moved totextAreaOptions
in the futuremaxRows?
- maxRow prop of text area autosize package. Will be moved totextAreaOptions
in the futureinfoDescription?
- pass "Custom information" message to tooltip if needediconUrl?
- use this whenever need to add icon from leftside of inputrules
- Array of rules where input value should be validated. Available rules:required
email
card
integer
float
[maxString, <integer>]
- max symbols on input value[compare, <any>]
- compare input value with definite variable. Example:repeatPassword
[minAmountValue, <number>]
- specific rule where minimal amount validated[lte, <number>]
- check whenever input value less or equal than specific number[gte, <number>]
- check whenever input value greater or equal than specific number[custom, <function>]
- check whenever custom validation is realized. example:const validateUsernameExist = (value) => { const existUser = "[email protected]" if (value == existUser) { return { isValid: false, description: "This user is already exist in system" } } else { return { isValid: true, description: "All is Fine" } } } ... rules={['required', 'email', ['custom', validateUsernameExist]]}
- Now we have following rules but they will grow in the future π
datePickerOptions
- all props related to DayPickerInput packages. All available props see "react-day-picker" package. Example:disabledDays
,initialMonth
selectOptions
- all props related to ReactSelect packages. All available props see "react-select" packages. Example:options
,value
,isClearable
numberFormatOptions
- all props related to NumberFormat packages. All available props see "react-number-format" package. Example:suffix
,thousandSeparator
,format
,mask
,type
,allowNegative
,allowZeroStart