0.0.14 • Published 7 years ago

@miasta/vue-input v0.0.14

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

vue-input

Part of the M2 UI suite.

A versatile input with optional validation. It is styled in similar way to material design inputs, with floating labels. vue-input can be of all standard html input types (text number date, etc.) or it can be a textarea type.

features:

  • all standard html input attributes are also valid with vue-input
  • validation on key up or on blur
  • built in validation for most common cases (email, length, equality), with possibility to pass custom regex validators
  • textarea auto grow

props:

nametypedefaultcomment
valanyInitial input value
typeStringtextType of input (see: supported input types ) + textarea
labelStringFloating label
placeholderStringInput placeholder
nameStringInput name
requiredBooleanIs required
autocompleteStringonBrowser autocomplete feature
spellcheckBooleanBrowser spellcheck feature
patternStringRegex pattern to validate field
disabledBooleanIs disabled
readonlyBooleanIs readonly
autogrowBooleanOnly for: type textarea – field will grow with text
minHeightString2remMinimum height of textarea (limits auto grow)
maxHeightStringMaximum height of textarea (limits auto grow)
counterBooleanCharacter counter for textarea
autoBooleanValidate while typing
equalsStringValue equals to another field (by ref). Should have the same parent.
minNumberMinimum number of characters OR: minimum numeric value, if field type is number
maxNumberMaximum number of characters OR: maximum numeric value, if field type is number
validatorsArrayArray of regex expressions to test the field value against
errorMinStringMinimum number of characters:Text of error when min fails
errorMaxStringMax number of characters reached:Text of error when max fails
errorEqualsStringfields do not matchText of error when equals fails
errorCustomStringText of error when your custom regex validator fails

data:

propertycomment
valueValue of input
selectedBoolean. Same as focus
validBoolean. Is input valid
errorMessageString. Current error message
infoMessageString. Current info message
filledBoolean. Is input filled

methods:

methodargscomment
validate()Validate input

events:

eventpayloadcomment
enterOn keyup.enter
blurOn input blured
value:changeOn input
validateOnce validated

css variables:

{
--vue-input-error-color: red;
--vue-input-text-color: black;
--vue-input-select-color: blue;
--vue-input-blur-color: rgba(black, .8);
--vue-input-font-family: system-ui, sans-serif;
--vue-input-label-font-family: system-ui, sans-serif;
--vue-input-border-color: rgba(black, .2);
--vue-input-border-color-active: var(--vue-input-select-color);
--vue-input-border-color-error: var(--vue-input-error-color);
}