Code Monkey home page Code Monkey logo

vue-persian-tools's Introduction

Vue persian tools

Persian tools wrapper for vue.js

CI/CD CI/CD codecov GitHub license PRs Welcome CodeFactor





Installation

npm

npm i @persian-tools/vue-persian-tools

โš ๏ธ If you are using vue2 you need to install composition api alongside the main package

npm i @vue/composition-api

Usage

// in vue 2
import Vue from "vue";
import tools from "@persian-tools/vue-persian-tools";

Vue.use(tools, {
    components: true,
    directives: true
});

// in vue 3
import tools from "@persian-tools/vue-persian-tools";
createApp(App).use(tools, options);

this way, you can install directives & components globally. by default only components will install globally. by passing directives: true to plugin options you can also enable directives

{
    components: false, // it wont install components
    directives: true, // install directives globally
}

You can also install components & directives globally by their names.

{
    components: ['isPersian', 'addOrdinalSuffix', '...'],
    directives: ['halfSpace'],
}

Or import them locally

// import components from module directory
import { halfSpace } from "@persian-tools/vue-persian-tools/dist/modules";
// import directives from directive directory
import { numberToWords, removeOrdinalSuffix } from "@persian-tools/vue-persian-tools/dist/directives";

export default {
    // install locally
    directives: { numberToWords, removeOrdinalSuffix },
    components: { halfSpace }
};



components

tag prop

every component accept a tag prop. you can use it to customize component html tag. default is span

<is-persian tag="div"></is-persian>


isPersian See details

slots:
isPersian: boolean

<is-persian :str="text" :isComplex="complex" :trimPattern="trim" v-slot="{isPersian}">{{ isPersian }}</is-persian>


slots:
url: string

<URLfix :url="your url" v-slot="{ url }">fixed URL: <b>{{ url }}</b></URLfix>


slots:
isValid: boolean
info: ShebaResult

<Sheba :shebaCode="code" v-slot="{ isValid, info }">
    is sheba valid: {{ isValid }}

    <h3>info about sheba</h3>
    <p>nickname: {{ info.nickname }}</p>
    <p>name: {{ info.name }}</p>
    <p>persianName: {{ info.persianName }}</p>
    <p>code: {{ info.code }}</p>
    <p>accountNumberAvailable: {{ info.accountNumberAvailable }}</p>
</Sheba>


addOrdinalSuffix See details

slots:
text: string

<addOrdinalSuffix :number="text" v-slot="{ text }">{{ text }}</addOrdinalSuffix>


slots:
result: billResult
amount: number
type: billType
isBillValid: boolean
isBillIdValid: boolean
isBillPaymentValid: boolean

<bill :bill="val" v-slot="{ result, amount, type, isBillValid, isBillIdValid, isBillPaymentValid }">
    <p>result of bill:{{ result }}</p>
    <p>amount:{{ amount }}</p>
    <p>bill type:{{ type }}</p>
    <p>is bill valid:{{ isBillValid }}</p>
    <p>is bill id valid:{{ isBillIdValid }}</p>
    <p>is bill payment id valid:{{ isBillPaymentValid }}</p>
</bill>


slots:
number: number | string

<div>
    <addCommas :number="your number..." v-slot="{ number }"> {{ number }}</addCommas>
    <removeCommas :number="your number..." v-slot="{ number }">{{ number }}</removeCommas>
</div>


slots:
value: string

<digits :number="input number..." :convert="language to convert..." v-slot="{ value }">converted to: {{ value }}</digits>


extractCardNumber See details

slots:
cards: ExtractCardNumber[]
valid: ExtractCardNumber[]

<extractCardNumber :str="val" v-slot="{ cards, valid }">
    <ul>
        <h4>all extracted cards:</h4>
        <li v-for="(card, i) in cards" :key="i">
            <p>index: {{ card.index }}</p>
            <p>pure: {{ card.pure }}</p>
            <p>base: {{ card.base }}</p>
            <p>isValid: {{ card.isValid }}</p>
        </li>
        <li v-for="(card, i) in valid" :key="i">
            <p>index: {{ card.index }}</p>
            <p>pure: {{ card.pure }}</p>
            <p>base: {{ card.base }}</p>
            <p>isValid: {{ card.isValid }}</p>
        </li>
    </ul>
</extractCardNumber>


getBankNameFromCardNumber See details

slots:
bankName: string

<getBankNameFromCardNumber :digits="card_number..." v-slot="{ bankName }"> {{ bankName }}</getBankNameFromCardNumber>


getPlaceByIranNationalId See details

slots:
city: string
codes: string[]
province: string

<getPlaceByIranNationalId :nationalId="id..." v-slot="{ city, codes, province }">
    city: <b> {{ city }} </b> <br />
    province: <b> {{ province}} </b> codes: <b> {{ codes }} </b>
</getPlaceByIranNationalId>


halfSpace See details

slots:
text: string

<halfSpace :str="text" v-slot="{ text }">{{ text }}</halfSpace>


hasPersian See details

slots:
hasPersian: boolean

<hasPersian :str="text" v-slot="{ hasPersian }">{{ hasPersian }}</hasPersian>


isArabic See details

slots:
isArabic: boolean

<isArabic :str="text" :trimPattern="trim" v-slot="{ isArabic }">{{ isArabic }}</isArabic>


numberToWords See details

slots:
words: string

<numberToWords :number="val" v-slot="{ words }">{{ words }}</numberToWords>


phoneNumber See details

slots:
details: OperatorModel | null
isValid: boolean

<phoneNumber :number="val" v-slot="{ details, isValid }">
    <p>details: {{ details }}</p>
    <p>is phone number valid: {{ isValid }}</p>
</phoneNumber>


removeOrdinalSuffix See details

slots:
text: string

<removeOrdinalSuffix :number="text" v-slot="{ text }"><b>{{ text }}</b></removeOrdinalSuffix>


toPersianChars See details

slots:
text: string

<toPersianChars :str="val" v-slot="{ text }">{{ text }}</toPersianChars>


verifyCardNumber See details

slots:
isValid: boolean

<verifyCardNumber :digits="text" v-slot="{ isValid }">{{ isValid }}</verifyCardNumber>


verifyIranianNationalId See details

slots:
isValid: boolean

<verifyIranianNationalId :nationalId="text" v-slot="{ isValid }">{{ isValid }}</verifyIranianNationalId>


wordsToNumber See details

slots:
number: number

<wordsToNumber :words="val..." fuzzy addCommas v-slot="{ number }">{{ number }}</wordsToNumber>


slots:
number: String | PlateOptions

<plate number="12D45147" v-slot="{ info, isValid }">{{ info }} | {{ isValid }}</plate>


timeAgo See details

slots:
date: String

<timeAgo date="1400/04/07 18:00:00" v-slot="{ time }">{{ time }}</timeAgo>

directives

all directives have sync modifiers. using this modifier will enable reactive data in your directive.

halfSpace directive See details

<span v-half-space>your text</span> <input :value="text" v-half-space.sync />


toPersian directive See details

<span v-to-persian>...</span> <input :value="text" v-to-persian.sync />


URLFix directive See details

<span v-url-fix>...</span> <input :value="text" v-url-fix.sync />


addOrdinalSuffix directive See details

<span v-add-ordinal-suffix>...</span> <input :value="text" v-add-ordinal-suffix.sync />


removeOrdinalSuffix directive See details

<span v-remove-ordinal-suffix>...</span> <input :value="text" v-remove-ordinal-suffix.sync />


numberToWords directive See details

<span v-number-to-words>...</span> <input :value="text" v-number-to-words.sync />


wordsToNumber directive See details

modifires:
addCommas, fuzzy
argument:
digits: 'fa' | 'en' | 'ar'

<span v-words-to-number:fa.addCommas>...</span> <input :value="text" v-words-to-number:en.fuzzy.sync />


Contributing

check Contributing.md for more information

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Changelogs

vue-persian-tools's People

Contributors

alireza-ab avatar mediv0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vue-persian-tools's Issues

Error "the engine node is incompatible with this module"

Hi,
thanks for your incredible Persian Tools package...

I wanted to install this vue-persian-tools on my Nuxt3 project. The problem is that, Nuxt3 need at least node >=18, but the @persian-tools/persian-tools: 3.0.1 dependency need node <=16.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.