Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@persian-tools/vue-persian-tools

persian-tools50MIT0.14.0TypeScript support: included

Persian tools wrapper for vue.js

persian tools, number to persian words, persian words to number, Arabic numbers to Persian, Arabic numbers to English, English numbers to Persian, Persian numbers to English, verify iranian national id, verify iranian card-number, Persian zero-width non-joiner, vue persian tools, persian tools for vue2, persian tools for vue3, persian tools wrapper

readme

Vue persian tools

Persian tools wrapper for vue.js

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


See demo

Persian tools repo




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>


URLfix See details

slots:
url: string

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


Sheba See details

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>


bill See details

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>


commas See details

slots:
number: number | string

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


digits See details

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>


plate See details

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

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.14.0 (2021-09-22)

Features

0.13.0 (2021-06-02)

Features

0.12.0 (2021-05-29)

Features

  • add numberToWords module (db1cf88)
  • add wordsToNumber module (2e17986)

Bug Fixes

  • rename options interface to IPersianToolsVuePluginOptions (1ce0125)

0.11.0 (2021-05-27)

Features

  • add plugin options (d3c0d90)
  • add urlFix directive (57cfec4)
  • export URLfix & halfSpace directives (82d398e)

0.10.0 (2021-05-23)

Features

  • add getBankNameFromCardNumber module (f6bd9b4)
  • add verifyCardNumber module (dd0baef)

0.9.0 (2021-05-20)

Features

  • add getPlaceByIranNationalId module (c1e7851)
  • add verifyIranianNationalId module (60229da)

0.8.0 (2021-05-20)

Features

  • add removeOrdinalSuffix module (3f0504d)
  • isPersian: add isComplex prop (ad5e219)

0.7.1 (2021-05-20)

Bug Fixes

0.7.0 (2021-05-18)

Features

  • add addOrdinalSuffix module (b00cb60)
  • add halfspace directive (5540020)
  • add halfSpace module (6e31409)
  • add hasPersian module (21033aa)
  • add isPersian module (03ce3c4)
  • add isPersian story (b0b4c55)
  • add Sheba module (15e0cf2)
  • add slot handler for both vue2 & vue3 (fc85ed8)
  • add toPersianChars module (e06d170)
  • add URLfix module (f2bbbe1)
  • change text prop to args (c8c330c)
  • vue2 support for halfspace directive (97a1348)
  • ispersian: add trimPattern argument to isPersian module (82334bf)

Bug Fixes

  • fix Directive Interface (c0ee763)
  • haspersian: change text prop to str (2d4db4e)

0.6.0 (2021-03-27)

Features

0.5.0 (2021-03-16)

Features

0.4.0 (2021-03-16)

Features

  • add toPersianChars module (e06d170)

Bug Fixes

  • haspersian: change text prop to str (2d4db4e)

0.3.0 (2021-03-14)

Features

0.2.0 (2021-03-10)

Features

  • add URLfix module (f2bbbe1)
  • ispersian: add trimPattern argument to isPersian module (82334bf)

0.1.1 (2021-03-10)

Features

  • change text prop to args (c8c330c)

0.1.0 (2021-03-10)

Features

  • add isPersian module (03ce3c4)
  • add isPersian story (b0b4c55)
  • add slot handler for both vue2 & vue3 (fc85ed8)