@avto-dev/bank-card-vue-component
v3.2.0
Published
Vue Component - bank card
Downloads
255
Readme
Vue Bank Card (component)
Vue Component for user data entry of the bank card
Demonstration is available here.
Notification
Currently, two versions of the library are supported - compatible with Vue 2 and Vue 3. Version v2 and below is compatible with Vue 2 applications, version v3 and above is compatible with Vue 3.
Installation
npm i --save @avto-dev/bank-card-vue-component
or
yarn add @avto-dev/bank-card-vue-component
You can import the library and styles, then use it as a Vue plugin to enable the functionality globally on all components.
import Vue from "vue"
import VueBankCard from "@avto-dev/bank-card-vue-component"
import "@avto-dev/bank-card-vue-component/dist/bank-card-vue-component.css"
Vue.component("VueBankCard", VueBankCard)
Basic usage
<VueBankCard is-new />
Properties
Name | Required | Type | Default | Description
:--- | :--- | :--- | :--- | :---
number
| no | String, Object | ""
| Number of card
isSmall
| no | Boolean | false
| View card controller: base or small
isNew
| no | Boolean | false
| View card controller: saved or new
disableDelete
| no | Boolean | false
| Disable delete option on small card
errors
| no | Object | {}
| Errors from outside the component. From server etc.
isReset
| no | Boolean | false
| Trigger for reset form
isFocus
| no | Boolean | false
| Card number field focus when component mounted (available if isNew
is true)
imagesBasePath
| no | String | default | Base path and banks or payment systems logotypes
Events
Name | Type | Parameters | Description
:--- | :--- | :--- | :---
enter
| Function | event
- Event of keydown | Handler of keydown on enter event
clear-errors
| Function | errors
- Object of errors | Clearing errors from outside
reset
| Function | isReset
- State of isReset property, type Boolean | Turn off isReset property
delete-card
| Function | event
- Event of click | Handler of click on trash button
Example
<template>
<VueBankCard
is-small
is-new
is-focus
:errors="errors"
:is-reset="resetForm"
@enter="onEnter"
@clear-errors="clearErrors"
@reset="resetForm = $event"
></VueBankCard>
</template>
<script>
export default {
data() {
return {
errors: {
cardNumber: "Недостаточно средств на карте",
expDateMonth: "Карта просрочена",
cvv: "Неверный код cvv"
},
resetForm: false
}
},
methods: {
onEnter(event) {
event.preventDefault();
console.log(event);
},
clearErrors(errors) {
this.errors = { ...errors };
}
}
}
</script>
Use your own logotypes
By default banks logos provided from CDN: https://cdn.jsdelivr.net/gh/avto-dev/bank-card-vue-component@%package_version%/public/images/%image_path%
.
If you want to use your own logotypes you can pass base images path by prop images-base-path
. For example:
<template>
<VueBankCard
is-new
:images-base-path="imagesPath"
></VueBankCard>
</template>
<script>
export default {
data() {
return {
imagesPath: "//your-own-cdn-or-host.com/path/to/assets/"
}
},
}
</script>
Now path to logotype would be //your-own-cdn-or-host.com/path/to/assets/banks-logos/ru-sberbank.png
.
So you must have two folders in your defined path:
banks-logos
- Must contain bank logos;brands-logos
- Must contain payment systems (VISA, Master Card, etc) logos.
Name of files with logotypes should be the same that come with this package.
Testing
For package testing we use jest
framework and docker-ce
+ docker-compose
as develop environment. So, just write into your terminal after repository cloning:
$ make install
$ make test
Changes log
Changes log can be found here.
Support
If you will find any package errors, please, make an issue in current repository.
License
This is open-sourced software licensed under the MIT License.