2.2.0 • Published 4 months ago

vue-input-facade v2.2.0

Weekly downloads
3,527
License
MIT
Repository
github
Last release
4 months ago

Vue Input Facade

A lightweight and dependency free input facade created specific for Vue

Docs and Demo

Installing

npm i vue-input-facade
or
yarn add vue-input-facade

Importing

Globally

installs the component, directive and filter for your entire application.

import InputFacade from 'vue-input-facade'
Vue.use(InputFacade)

Locally

import { InputFacade, facade } from 'vue-input-facade'
export default {
  components: { InputFacade },
  directives: { facade }
}

Usage

Component

<label>Phone Number</label>
<input-facade mask="(###) ###-####" name="phoneNumber" type="tel" masked />

Directive

<label>Date</label>
<input type="text" v-facade="'##/##/##'" />

See demo page 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 for definition signature

Component Properties

Inherits from HTMLInputElement, plus adds these additional properties:

PropertyRequiredTypeDefaultDescription
maskfalseString, ArrayMask pattern
maskedfalseBooleanfalseemit value with mask chars, default is raw
tokensfalseObjecttokensCustom 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.

import InputFacade from 'vue-input-facade'

// 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: /./ }
  }
}

Vue.use(InputFacade, options)

Thanks

Thanks to Marcos Neves for the vue-the-mask component of which this vue-input-facade was originally forked from.

Contribution

You're free to contribute to this project by submitting Issues and/or pull requests. This project is test-driven, so keep in mind that every change and new feature should be covered by tests. Your name will be added to the hall of fame ;)

License

This project is licensed under MIT License

3.0.0-beta.5

4 months ago

3.0.0-beta.4

4 months ago

2.2.0

4 months ago

3.0.0-beta.3

10 months ago

2.1.2

9 months ago

2.1.1

11 months ago

2.1.3

9 months ago

3.0.0-beta.2

1 year ago

2.1.0

12 months ago

3.0.0-beta.1

2 years ago

2.0.1

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

2.0.0-beta.2

2 years ago

2.0.0-beta.1

2 years ago

2.0.0

2 years ago

2.0.0-beta.3

2 years ago

1.3.9

2 years ago

1.3.8

2 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.3-beta.1

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.2.0-beta.5

4 years ago

1.2.0-beta.4

4 years ago

1.2.0-beta.3

4 years ago

1.2.0-beta.2

4 years ago

1.1.5

4 years ago

1.2.0-beta.1

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago