New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vuetify-masked

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vuetify-masked

vuetify masked textfield and filter

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
108
increased by36.71%
Maintainers
1
Weekly downloads
 
Created
Source

vuetify-masked

Create a masked text field for vuetify 2.x based on v-text-field. Supported are static masks provided by string/object and the masking of float and integer values. Additionally, a filter exists to format a value.

Demo

CodeSandbox Demo

Install

npm install vuetify-masked --save

Global

import Vue from 'vue'
import VuetifyMasked from 'vuetify-masked'

Vue.use(VuetifyMasked)

Local

// use only the component
import { VuetifyMaskedComponent } from 'vuetify-masked'

// use only the filter
import { VuetifyMaskedFilter } from 'vuetify-masked'

export default {
  components: {
    'v-text-field-masked': VuetifyMaskedComponent
  },
  filters: {
    VuetifyMaskedFilter
  }
}

Usage

Once installed, for a simple mask the component can be used in a template as simple as:

Type 'text'

<!-- Component -->
<v-text-field-masked
  v-model="text"
  formatMask="###A/##l/D#U"
  label="default type (text)"
  :showHints="true"
></v-text-field-masked>

<!-- Filter -->
{{ text | vuetifyMaskedFilter({ formatMask: "###A/##l/D#U" }) }}

Resulted value for '123A56U89a' is '123A/56u/89A'. In the text field default hints will be shown.

Type 'float'

<v-text-field-masked
  v-model="text"
  label="float type"
  type="float"
></v-text-field-masked>

<!-- Filter -->
{{ text | vuetifyMaskedFilter({ type:"float" }) }}

Resulted value for '1234567890' is '1,234,567,890.00'

Type 'integer'

<v-text-field-masked
  v-model="text"
  label="integer type"
  type="integer"
></v-text-field-masked>

<!-- Filter -->
{{ text | vuetifyMaskedFilter({ type:"integer" }) }}

Resulted value for '1234567890' is '1,234,567,890'

Type 'currency'

<v-text-field-masked
  v-model="text"
  label="currency type"
  type="currency"
></v-text-field-masked>

<!-- Filter -->
{{ text | vuetifyMaskedFilter({ type:"currency" }) }}

Resulted value for '1234567890' is '1,234,567,890.00USD'

Type 'percentage'

<v-text-field-masked
  v-model="text"
  label="percentage type"
  type="percentage"
></v-text-field-masked>

<!-- Filter -->
{{ text | vuetifyMaskedFilter({ type:"percentage" }) }}

Resulted value for '1234567890' is '1,234,567,890.00%'

Options (Component Props and Filter Parameters)

The following options can be used for component and filter

OptionTypeDefaultComponentFilterDescription
deformatMaskstring, objectnullyesnoMask used to deformat the masked value. If null all characters of the masked will be removed
emptystringnullyesyesValue returned for an empty text field when using the component. For the filter the provided string will be displayed if value is empty or null
falseCharWildcardstring''yesyesFalse characters of the provided v-model/value will be replaced with this one. By default they will simply be deleted.
formatMaskstring, object'##########'yesyesUsed to mask the given value. Meaning of characters and usable attributes for object can be found below table
hintsobjectyesnoHints will be displayed depending on the cursor position and according to the next possible character that can be entered.
lengthnumbernullyesnoMax number of digits (including precision) that can be entered into the text field. Ignored for type text.
localestring'en-EN'yesyesUsed to determine the decimal and thousands seperator.
maskCharacterarray['-', '+', '.', ',', ' ', '/', '(', ')', '_', '\\', '\'', '~', '*', '&', '"', '?']yesyesCharacters of the mask. Can not be used as input character for the text field. Used for both, formatMask and deformatMask.
precisionnumber2yesyesPrecision used for numbers. Ingored for types text and integer.
propertiesobjectnullyesnoProperties for the v-text-field used by vuetify-masked
showHintsbooleanfalseyesnoIf true, show hints defined by hints
suffixstringnull (text, integer, float)
'%' (percentage)
'USD'(currency)
yesyes
typestring'text'yesyes5 types exist: text, float, integer, currency, and percentage
valuestring, numbernullyesyesMapped to the v-model of the component
v-modelstring, numbernullyesno

Predefined Mask Characters

CharacterDescription
ACharacter is alphabetical
DCharacter is a digit
lCharacter will be transformed to lower cased
UCharacter will be transformed to upper cased
#Any character is valid

Any other alphabetical character of the mask will be handled as #.

Object Attributes for Mask

In case of an object, the following attributes can be set.

AttributeTypeDescription
maskstringCharacter of the mask.
toUpperCasebooleanIf true the character will be transformed to upper case. If not explicity set it will be true if mask is 'U'.
toLowerCasebooleanIf true the character will be transformed to upper case. If not explicity set it will be true if mask is 'l'.
onlyDigitbooleanIf true the character will be transformed to upper case. If not explicity set it will be true if mask is 'D'.
onlyAlphabeticalbooleanIf true the character will be transformed to upper case. If not explicity set it will be true if mask is 'A'.
hintstringHint only used for this character of the mask.

Hints Object Attributes and Default Values

AttributeTypeDefaultDescription
alphabeticstring'The next char is alphabetic'By default used for 'A'
alphanumericstring'The next char is alphanumeric'By default used for '#'
digitstring'The next char is a digit'By default used for 'D'
lowerCasestring'The next char is lower case'By default used for 'l'
maxLengthstring'Max number of characters reached'
numericstringnullOnly used for types float, integer, currency, and percentage
upperCasestring'The next char is upper case'By default used for 'U'

Keywords

FAQs

Package last updated on 13 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc