Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-input-facade

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-input-facade - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

package.json
{
"name": "vue-input-facade",
"version": "1.0.1",
"version": "1.0.2",
"description": "A lightweight and dependency free input facade created specific for Vue",

@@ -5,0 +5,0 @@ "main": "dist/vue-input-facade.umd.min.js",

@@ -7,14 +7,16 @@ # Vue Input Facade

## Install
## Installing
```
npm i vue-input-facade
or
yarn add vue-input-facade
or
npm i vue-input-facade
```
## Usage (two flavors)
## Importing
### Global
### Globally
installs the component, directive and filter for your entire application.
```javascript

@@ -25,48 +27,74 @@ import InputFacade from 'vue-input-facade'

### Local (inside the component)
### Locally
```javascript
import { InputFacade } from 'vue-input-facade'
import { InputFacade, facade, masker } from 'vue-input-facade'
export default {
components: { InputFacade }
components: { InputFacade },
directives: { facade },
filters: { facade: masker }
}
```
### Local (as directive)
## Usage
```javascript
import { facade } from 'vue-input-facade'
export default {
directives: { facade }
}
### Component
```html
<label>Phone Number</label>
<input-facade mask="(###) ###-####" name="phoneNumber" type="tel" masked />
```
### Local (as filter)
### Directive
```javascript
import { masker } from 'vue-input-facade'
export default {
filters: { facade: masker }
}
```html
<label>Date</label>
<input type="text" v-facade="'##/##/##'" />
```
## Tokens
See [demo page](https://ronaldjerez.github.io/vue-input-facade) for more usage example
## Default Tokens
+ `S` = alpha characters
+ `#` = numerical characters
+ `X` = alpha numerical characters
+ `A` = alpha characters, forced to uppercase
+ `a` = alpha characters, forced to lowercase
+ `\` = escape any of the above characters
See the [token source file](src/tokens.js) for definition signature
## Component Properties
Inherits from [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement), plus adds these additional properties:
| Property | Required | Type | Default | Description |
| ----------- | -------- | ------------- | ----------------------- | ------------------------------------------ |
| mask | false | String, Array | | Mask pattern |
| masked | false | Boolean | false | emit value with mask chars, default is raw |
| tokens | false | Object | [tokens](src/tokens.js) | Custom tokens for mask |
## Migrating Existing Project
If you are migrating an existing project to vue-input-facade from another plugin and dont want to touch the whole codebase. You may pass options during plugin installation to override the default tokens or directive name.
```javascript
'#': {pattern: /\d/},
'X': {pattern: /[0-9a-zA-Z]/},
'S': {pattern: /[a-zA-Z]/},
'A': {pattern: /[a-zA-Z]/, transform: v => v.toLocaleUpperCase()},
'a': {pattern: /[a-zA-Z]/, transform: v => v.toLocaleLowerCase()},
'!': {escape: true}
```
import InputFacade from 'vue-input-facade'
## Properties
// migrating from v-mask
// the directive will now be v-mask instead of v-facade
// and all the tokens will be replaced globally by the following
const options = {
name: 'mask',
tokens: {
'#': { pattern: /\d/ },
'A': { pattern: /[a-zA-Z]/ },
'N': { pattern: /[0-9a-zA-Z]/ },
'X': { pattern: /./ }
}
}
| Property | Required | Type | Default | Description |
| ----------- | -------- | ------------- | ----------------- | ------------------------------------------ |
| value | false | String | | Input value or v-model |
| mask | false | String, Array | | Mask pattern |
| masked | false | Boolean | false | emit value with mask chars, default is raw |
| tokens | false | Object | [tokens](#tokens) | Custom tokens for mask |
Vue.use(InputFacade, options)
```

@@ -73,0 +101,0 @@ ## Thanks

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