2.1.1 • Published 6 years ago

vue2-persian-datepicker v2.1.1

Weekly downloads
77
License
MIT
Repository
github
Last release
6 years ago

vue persian datepicker

Build Status Dependency Status Coverage Status

This is a Jalali date picker component for Vue.

این برنامه یک کامپوننت انتخاب تاریخ جلالی می باشد.

Demo

You can see a demo and several examples in this page: Demo & examples

Universal Module Definition(UMD)

In order to use datepicker without node package manager include these scripts and style sheet ( I recommend using unpkg ):

<link href="https://unpkg.com/vue2-persian-datepicker/dist/vue2-persian-datepicker.css" rel="stylesheet"></script>
<script type=text/javascript src="https://unpkg.com/vue"></script>
<script type=text/javascript src="https://unpkg.com/vue2-persian-datepicker/dist/vue2-persian-datepicker.js"></script>

Then register the component :

Vue.component('pdatepicker', PDatePicker.PDatePicker);

For a complete example you can see this jsFiddle .

NPM

$ npm install vue2-persian-datepicker

Then register the component:

import Vue from 'vue'
import PDatePicker from 'vue2-persian-datepicker'
Vue.component('pdatepicker', PDatePicker)

Usage

After registering the component you can use it in your markup:

<pdatepicker></pdatepicker>

Basic usage

In most cases you use pdatepicker to provide a persian date picker for your users to pick a date from. So, you need a way to get selected date. You can easily achieve this by syncing a variable.

This is pretty much what you have to do in order to get selected date or display a date to a user:

<pdatepicker v-model="date"></pdatepicker>
export default{
    data(){
        return {
            date : '1396/6/8'
        };
    }
}

Properties

PropertyTypeDefaultDescription
placeholderStringیک تاریخ را انتخاب کنیدPlace holder of input
header-colorColor'white'Header text color
header-background-colorColor'#137e95'Header background color
hover-day-back-colorColor'#137e95'Background color when mouse hovers an element
chosen-day-back-colorColor'#137e95'Background color for chosen day
dialog-color'black'Color Dialog text color
dialog-background-colorColor'#fafafa'Dialog background color
minimum-yearNumber1300Minimum selectable year for user
maximum-yearNumber1350Maximum selectable year for user
nameString''Name element for normal http form submit
requiredBooleanfalsevalue of HTML required attribute
idString''value of input's id attribute
input-classString''css class for input element
dialog classString''css class for dialog element
wrapper-classString''css class wrapper element of component
input-disabledBooleantruefor responsive reasons input is disabled by default but you can enable it if you need to.
initial-viewString'day'Initial view of component (year or month or day)
inline-modeBooleanfalseinline mode
format-dateString'yyyy/MM/dd'formats output date. order of date element should not change
open-transition-animationString'slide-fade'you can specify a transition for opening and closing dialog.
persianDigitsBooleantruewhether to use persian or english digits
availableDatesBooleanfalseIf you want limit user to certain range of dates
availableDateStartString1300/01/01In case of setting availableDates to true, use this to set start date
availableDateEndString1450/12/29In case of setting availableDates to true, use this to set end date
disableDatesBeforeTodayBooleanfalseThis will disable all dates before today
modal-modeBooleanfalseThis will make dialog modal.
modal-open-transition-animationString'scale-fade'you can specify a transition for opening and closing dialog in modal mode.

Events

eventParametersdescription
openedDate StringThe picker's dialog is opened
closedDate StringThe picker's dialog is closed
monthChangedDate StringMonth page has changed
yearChangedDate StringYear page has changed
selectedDate ObjectA date has been selected
inputDate StringInput changed

Get selected date

Using v-model you can sync a value to selected date. Or, you can listen to selected event and get selected date.

Date formatting

There are several ways you can print selected date on user input. Keep in mind that you have to keep order of date (year/month/date)

tokendescexample
dday3
ddday with 0 prefixed day03
Mmonth number4
MMmonth with 0 prefix day04
MMMmonth nameفروردین
yytwo digits year96
yyyyfour digits year1396
2.1.1

6 years ago

2.1.0

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.9.9

6 years ago

1.7.8

6 years ago

1.7.7

6 years ago

1.7.5

6 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.5.29

6 years ago

1.5.28

6 years ago

1.5.27

6 years ago

1.5.26

6 years ago

1.5.25

6 years ago

1.5.24

6 years ago

1.5.23

6 years ago

1.5.22

6 years ago

1.5.21

6 years ago

1.5.20

6 years ago

1.5.19

6 years ago

1.5.18

6 years ago

1.5.17

6 years ago

1.5.16

6 years ago

1.5.15

6 years ago

1.5.14

6 years ago

1.5.13

6 years ago

1.5.12

6 years ago

1.5.11

6 years ago

1.5.10

6 years ago

1.5.9

6 years ago

1.5.8

6 years ago

1.5.7

6 years ago

1.5.6

6 years ago

1.5.5

6 years ago

1.5.4

6 years ago

1.5.3

6 years ago

1.5.2

6 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.0

7 years ago

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago