• This repository has been archived on 17/Oct/2022
  • Stars
    star
    281
  • Rank 147,023 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 7 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Vue.js component for Cleave.js input mask library ⌨️

Vue Cleave Component

downloads npm-version github-tag license build codecov

Vue.js component for Cleave.js

Demo on JSFiddle

Version matrix

Vue.js version Package version Branch
2.x 2.x 2.x
3.x 3.x master

Features

  • Reactive v-model value
    • You can change input value programmatically
  • Reactive options
    • You can change config options dynamically
    • Component will watch for any changes and redraw itself
  • Compatible with Bootstrap, Bulma or any other CSS framework
  • Works with validation libraries
  • Option to disable raw mode to get masked value

Installation

npm install vue-cleave-component --save

Usage

<template>
    <div>
        <cleave v-model="cardNumber"
                :options="options"
                class="form-control"
                name="card"/>
    </div>
</template>

<script>
    import Cleave from 'vue-cleave-component';

    export default {
        data() {
            return {
                cardNumber: null,
                options: {
                    creditCard: true,
                    delimiter: '-',
                }
            }
        },
        components: {
            Cleave
        }
    }
</script>

As plugin

import {createApp} from 'vue';
import Cleave from 'vue-cleave-component';
// your app initilization logic goes here
const app = createApp({});
app.use(Cleave);
app.mount('#app');

This will register a global component <cleave>

Available props

The component accepts these props:

Attribute Type Default Description
v-model String / Number / null null Set or Get input value (required)
options Object {} Cleave.js options
raw Boolean true When set to false; emits formatted value with format pattern and delimiter

Install in non-module environments (without webpack)

  • Include required files
<!-- cleave.js -->
<script src="https://cdn.jsdelivr.net/npm/cleave.js@1"></script>
<!-- Vue.js -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<!-- Lastly add this package -->
<script src="https://cdn.jsdelivr.net/npm/vue-cleave-component@3"></script>
<script>
    const app = Vue.createApp({});
    app.use(VueCleave);
    app.mount('#app');
</script>

Run examples on your localhost

  • Clone this repo
  • Make sure you have node-js >=18.9 and pnpm >=7.x pre-installed
  • Install dependencies pnpm install
  • Run webpack dev server npm start
  • This should open the demo page in your default web browser

Testing

  • This package is using Jest and vue-test-utils for testing.
  • Tests can be found in __test__ folder
  • Execute tests with this command npm test

Changelog

Please see CHANGELOG for more information what has changed recently.

Alternatives

If you feel this component heavy, then you can consider these packages.

License

MIT License

More Repositories

1

vue-loading-overlay

Vue.js component for full screen loading indicator 🌀
JavaScript
1,219
star
2

vue-flatpickr-component

Vue.js component for Flatpickr datetime picker 📆
TypeScript
964
star
3

vue-toast-notification

Yet another toast notification plugin for Vue.js 🌷
JavaScript
615
star
4

vue-trumbowyg

Vue.js component for Trumbowyg WYSIWYG editor 📝
JavaScript
236
star
5

vue-bootstrap-datetimepicker

Vue.js component for eonasdan bootstrap datetimepicker
JavaScript
224
star
6

google-chat-electron

An unofficial desktop app for Google Chat :electron:
TypeScript
158
star
7

vue-web-storage

Vue.js plugin for local storage and session storage (1.8 kb min+gz) 💾
TypeScript
85
star
8

fcm-notification-channel

All in One Firebase push notification channel for Laravel 🔔
PHP
68
star
9

laravel-eloquent-relationships

Add some more eloquent relationships to Laravel php framework. 👫
PHP
57
star
10

phpunit-travis-ci-coverage-example

phpUnit Testing on Travis-CI with Code Coverage on CodeCov
PHP
28
star
11

laravel-mix-auto-extract

[DEPRECATED] Laravel Mix v2/3 plugin to auto extract vendor js
JavaScript
25
star
12

laravel-ses-webhooks

AWS SES Webhooks client for Laravel 📬
PHP
22
star
13

laravel-socialite-multiple-providers-example

Laravel socialite with multiple providers example
PHP
20
star
14

vue-jquery-mask

Vue.js component for jQuery mask plugin
JavaScript
20
star
15

vue-lunch-order-app

Lunch order app, built with Vue.js v2 and Google Spreadsheet
JavaScript
17
star
16

laravel-paypal-webhooks

Handle PayPal webhooks in Laravel 💵
PHP
16
star
17

bandwidth-notification-channel

Bandwidth SMS notification channel for Laravel php framework 📩
PHP
12
star
18

wp-google-map

Google Map Plugin for WordPress
PHP
11
star
19

laravel-bundler

Modern asset building tool for Laravel framework with better defaults. 📦
JavaScript
11
star
20

codeception-travis-ci-example

[READ-ONLY] Codeception Acceptance Testing on Travis-CI
PHP
9
star
21

wp-prism-js

Prism Syntax Highlighter Plugin for WordPress
PHP
7
star
22

vue-bugsnag

[DEPRECATED] Vue.js plugin for Bugsnag js v3.x error reporting
JavaScript
6
star
23

vue-progress-indicator

Vue.js component for progress indicator
JavaScript
5
star
24

electron-update-notifier

Update notifier for Electron apps 🔔
TypeScript
5
star
25

laravel-form-validation

Yet another form validation (JS) helper for Laravel. ☂️
TypeScript
5
star
26

laravel-blogger-api-example

Laravel demo blog REST api 🧙‍♂️
PHP
4
star
27

laravel-stripe-exceptions

Handle Stripe exceptions gracefully in Laravel php framework. ☄️
PHP
4
star
28

node-webkit-angular-starter-kit

[READ-ONLY] A node-webkit and Angular js based desktop app
JavaScript
3
star
29

laravel-alert

A Bootstrap alert helper for Laravel php framework 🥭
PHP
3
star
30

laravel-lunch-order-app

[WIP] Lunch order app built with Laravel
PHP
2
star
31

laravel-vonage-inbound-sms

Vonage Inbound SMS Webhooks Client for Laravel ☎️
PHP
2
star
32

wp-google-analytics

Google Analytics Plugin for WordPress
PHP
2
star
33

gulp-3-browsersync-scss-seed

[READ-ONLY] Front-end development starter kit for beginners
JavaScript
2
star
34

vue-php-demo-2021

Sample app to demo vue.js with php
PHP
2
star
35

laravel-otp

One time password (OTP) generator and verifier for Laravel 📲
PHP
2
star
36

ankurk91.github.io

Ankur Kumar's GitHub Profile 🎉
HTML
1
star
37

ankurk91

The README repo 😉
1
star
38

laravel-passport-socialite-example

Laravel passport with socialite
PHP
1
star
39

laravel-shopping-cart

Shopping cart manager for Laravel. 🛒
PHP
1
star
40

wp-tabs-example

WordPress plugin to demonstrate how to use in-built tabs on plugin options page
PHP
1
star
41

wp-lazy-intercom

WordPress plugin to lazy load Intercom widget
PHP
1
star
42

wp-screen-options-example

WordPress plugin to demonstrate screen options usage in your plugin options page
PHP
1
star