1.2.7 • Published 3 years ago

@solution5520/s-inputs v1.2.7

Weekly downloads
13
License
ISC
Repository
github
Last release
3 years ago

s-inputs

Inputs components with built-in logic for different data type.

Contains inputs for :

Installation

npm i @solution5520/s-inputs

Importing

Register all components globaly

In main.js:

import Vue from 'vue'
import SInputs from "@solution5520/s-inputs"
import '@solution5520/s-inputs/dist/s-inputs.css'

Vue.use(SInputs)

Register specific components locally

Install only needed components.

import {
    DateInput,
    DurationInput,
    IconInput,
    NumberInput,
    RatingInput,
    SwitchInput,
    TextAreaInput,
    TextInput
} from "@solution5520/s-inputs"

export default {
  components: { 
    DateInput,
    DurationInput,
    IconInput,
    NumberInput,
    RatingInput,
    SwitchInput,
    TextAreaInput,
    TextInput 
  },
  // ... rest of component config
}

Docs

TextInput

Simple text input warper.

Usage

<template>
  <TextInput 
    v-model="value"
    placeholder="Type something here..."
  />
</template>

<script>
export default {
  data: () => ({
    value: 'Lorem ipsum'
  })
}
</script>

Interface

Props

PropsRequiredTypeDefaultDescription
v-modelnoString''Value binding.
valuenoString''Part of the v-model binding.
masknoString, Array''The mask pattern for this input, it could be a single pattern or multiple patterns when its an array.
maskednoBooleanfalseWether emits the raw value (false), or formated with the mask (true)
tokensnoObjectdefault tokenThe mask tokens with their text modifications, see Mask Tokens

Events

NameParamsDescription
inputvalue - The input's current value, masked or unmasked.Fires when the value of the input has been changed. Part of the v-model binding.
changevalue - The input's current value, masked or unmasked.Fires when the value has been commited on the input. Usually on blur.

Methods

NameParamsDescription
focusnoneFocus the input.

Mask Tokens

default values :

{
  "*": { pattern: /[\s\S]/ }, // Any character
  "#": { pattern: /\d/ }, // Number
  X: { pattern: /[0-9a-z]/i }, // Alphanumeric
  H: { pattern: /[0-9A-F]/i, transform: (v) => v.toLocaleUpperCase() }, // Hexadecimal
  S: { pattern: /[a-z]/i }, // Letter in any case
  A: { pattern: /[a-z]/i, transform: (v) => v.toLocaleUpperCase() }, // Letter in upper case
  a: { pattern: /[a-z]/i, transform: (v) => v.toLocaleLowerCase() }, // Letter in lower case
  "\\": { escape: true }, // Escape character
}

TextIconInput

Text input with optional prefix and suffix icons.

Usage

<template>
  <TextIconInput
    v-model="value"
    placeholder="Type something here..."
    inputClass="form-control"
    prefixIcon="search"
    :suffixIcon="['fas', 'search']"
    iconColor="red"
  />
</template>

<script>
export default {
  data: () => ({
    value: 'Lorem ipsum'
  })
}
</script>

Interface

Props

Inherits from TextInput

PropsRequiredTypeDefaultDescription
v-modelnoString''Value binding.
valuenoString''Part of the v-model binding.
inputClassnoString, Array, Object''Css class applied to the input.
prefixIconnoString, Array''Font-awesome icon put before the input.
suffixIconnoString, Array''Font-awesome icon put after the input.
iconColornoStringnullColor of the icons.

Events

NameParamsDescription
inputvalueFires when the value of the input has been changed. Part of the v-model binding.
clickMouseEventFires when the control is clicked.
prefixIconClickMouseEventFires when the prefix icon is clicked.
suffixIconClickMouseEventFires when the suffix icon is clicked.

Methods

NameParamsDescription
focusnoneFocus the input.

TextAreaInput

Input for multiline text, comes with auto-resize.

Usag

<template>
  <TextAreaInput 
    v-model="value"
  />
</template>

<script>
export default {
  data: () => ({
    value: 'Lorem ipsum'
  })
}
</script>

Interface

Props

Inherits from vue-textarea-autosize

PropsRequiredTypeDefaultDescription
v-modelnoString''Value binding.
valuenoString''Part of the v-model binding.
autosizenoBooleantrueAllows to enable/disable auto resizing.

Events

NameParamsDescription
inputvalueFires when the value of the textarea has been changed. Part of the v-model binding.

Methods

NameParamsDescription
focusnoneFocus the input.
resizenoneForce a one shot auto-resize.

NumberInput

Base for any number related input. Built-in currency system.

Usage

<template>
  <NumberInput 
    v-model="value"
    currency="EUR"
    locale="de"
  />
</template>

<script>
export default {
  data: () => ({
    value: 1000
  })
}
</script>

Interface

Props

inherits from vue-currency-input

PropsRequiredTypeDefaultDescription
v-modelnoNumber''Value binding.
valuenoNumber''Part of the v-model binding.
currencynoString, ObjectnullOverride default value of vue-currency-input.

Events

NameParamsDescription
inputvalueFires on interaction with the input. Part of the v-model binding.
changevalueFires when the value has been commited on the input. Usually on blur. Only if the value has changed.

Methods

NameParamsDescription
focusnoneFocus the input.

DateInput

Simple date and datetime-local input warper. Display in the local timezone.

Usage

<template>
  <DateInput 
    v-model="value"
    :withTime="true"
  />
</template>

<script>
export default {
  data: () => ({
    value: new Date()
  })
}
</script>

Interface

Props

Inherits from <input type="date"> or from <input type="datetime-local">

PropsRequiredTypeDefaultDescription
v-modelnoDate''Value binding.
valuenoDate''Part of the v-model binding.
withTimenoBooleanfalseOption to show date with time portion or not.

Events

NameParamsDescription
inputvalueFires when the value of the input has been changed. Part of the v-model binding.

Methods

NameParamsDescription
focusnoneFocus the input.

DurationInput

Component to show a duration of time like 1:23:04.567.

Usage

<template>
  <DurationInput 
    v-model="value"
    format="h:mm:ss.fff"
  />
</template>

<script>
export default {
  data: () => ({
    value: {
      hours: 1, 
      minutes: 23, 
      seconds: 4.567
    }
  })
}
</script>

Interface

Props

PropsRequiredTypeDefaultDescription
v-modelnoObject''Value binding.
valuenoObject''Part of the v-model binding. Object like .{hours:Number, minutes:Number, seconds:Number}
formatnoString'h:mm'Display format option. Possible value: 'h:mm', 'h:mm:ss', 'h:mm:ss.f', 'h:mm:ss.ff', 'h:mm:ss.fff'.

Events

NameParamsDescription
inputvalueFires when the value of the input has been changed.
blurvalueFires when the input lost focus. Part of the v-model binding.

Methods

NameParamsDescription
focusnoneFocus the input.

RatingInput

Simple 5 star rating component.

Usage

<template>
  <RatingInput 
    v-model="value"
    :increment: "0.5"
  />
</template>

<script>
export default {
  data: () => ({
    value: 4.5
  })
}
</script>

Interface

Props

Inherits from vue-rate-it

PropsRequiredTypeDefaultDescription
v-modelnoNumber0Value binding.
valuenoNumber0Part of the v-model binding.
resetablenoBooleantrueAllows to reset the value if click on the same value.
glyphnoStringStarA svg path to follow. Large library of font-awesome like icons at vue-rate-it/glyphs.
activeColornoString#FCB400The color of the highlighted portion of a glyph.
inactiveColornoString#C4C4C4The color of the non-highlighted portion of a glyph.
itemSizenoNumber30The size of each glyph. This gets passed to the SVG width attribute, so larger numbers are larger glyphs.
borderWidthnoNumber0Sets the width of the border for each glyph.
showRatingnoBooleanfalseWhether or not to show the rating next to the glyphs.
readonlynoBooleanfalseWhen set to true, the rating cannot be edited.
disablednoBooleanfalseWhen set to true, the rating cannot be edited.

Events

NameParamsDescription
inputvalueFires when the value of the selected rating has been changed. Returns the rating that the user has selected. Part of the v-model binding
current-ratingvalueFires when the mouse is over. Returns the rating the mouse is currently over.

SwitchInput

Simple on/off switch

Usage

<template>
  <SwitchInput 
    v-model="value"
    :type-bold="false"
    theme="bootstrap"
    color="warning"
  />
</template>

<script>
export default {
  data: () => ({
    value: true
  })
}
</script>

Interface

Props

Inherits from vue-switches

PropsRequiredTypeDefaultDescription
v-modelnoString''Value binding.
valuenoString''Part of the v-model binding.
typeBoldnoBooleantrueSwitch between bold and skiny display.
themenoString'custom'Which theme to use. Used with color to change the colors.
colornoString'green'Which color to use. Used with theme to change the colors.
emitOnMountnoBooleanfalseEmit a "changed" event when the component mounts.
readonlynoBooleanfalseMake component readonly.

Events

NameParamsDescription
inputvalueFires when the value of the input has been changed. Part of the v-model binding.