Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ng2-jalali-date-picker

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng2-jalali-date-picker

[![Build Status](https://travis-ci.org/fingerpich/jalali-angular-datepicker.svg?branch=master)](https://travis-ci.org/fingerpich/jalali-angular-datepicker) [![npm version](https://badge.fury.io/js/ng2-jalali-date-picker.svg)](https://badge.fury.io/js/ng2

  • 1.3.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
128
increased by36.17%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status npm version Package Quality

Jalali Date Picker

This is a configurable jalali date-picker build for Angular2 applications and uses MomentJS as its dependency. DEMO

Installation:

  1. Download from npm: npm install ng2-jalali-date-picker --save
  2. import the DpDatePickerModule module:
    import {DpDatePickerModule} from 'ng2-jalali-date-picker';
  3. Add DpDatePickerModule to your module imports:
 @NgModule({
   ...
   imports: [
     ...
     DpDatePickerModule
   ]
 })

Usage

Put the dp-date-picker component wherever you need it.

Example

<dp-date-picker
  [(ngModel)]="dateObject"
  type="day"
  placeholder="تاریخ"
  theme="dp-material">
</dp-date-picker>

Attributes:

NameTypeDefaultDescription
typedaymonthday
disabledBooleanfalseIf set to true the input would be disabled
placeholderString""The date-picker input placeholder
requiredBooleanundefinedThis is a validation rule, if there won't be any selected date then the containing form will be invalid.
minDate`MomentString`undefined
maxDate`MomentString`undefined
themestring ''Theme is a class added to the popup container (and inner components) - this will allow styling of the calendar when it's appended to outer element (for example - body). There is a built in theme named dp-material, you can find it in the demo.
configIDatePickerConfigSee BelowConfiguration object - see description below.

Configuration:

In order to provide configurations to the date-picker you need to pass it to the dp-date-picker component:

<dp-date-picker [(ngModel)]="selectedDate" [config]="datePickerConfig"></dp-date-picker>

Here are the available configurations:

NameTypeDefaultDescription
appendTo`StringHTMLElement`undefined
closeOnSelectBooleantrueIf set to true will close the date-picker after choosing a date from the calender, otherwise, won't.
disableKeypressBooleanfalseDisables the possibility to change the date value by typing it - changing the date would be possible only from the picker
closeOnSelectDelayNumber100The delay (in ms) between the date selection and the date-picker collapse
onOpenDelayNumber0The delay (in ms) between the date picker focusing and the date-picker popup apparel
drops`'up''down'`down
opens`'right''left'`right
formatString"DD-MM-YYYY"If ngModel provided as String the format is required, this format also will be used as the input format style.
firstDayOfWeekString"su"The first day of the calendar's week. Should be one of: "su", "mo", "tu", "we", "th", "fr", "sa"
monthFormatString"MMM-YYYY"The date format of the day calendar, the one that seen above the calendar days. Will be overwritten if monthFormatter provided.
monthFormatter(Moment) => StringundefinedThe date formatter (callback function) of the day calendar, the one that seen above the calendar days.
yearFormatString"YYYY"The date format of the month calendar, the one that seen above the calendar months. Will be overwritten if yearFormatter provided. (available when enableMonthSelector is set to true).
yearFormatter(Moment) => StringundefinedThe date formatter (callback function) of the month calendar, the one that seen above the calendar months. (available when enableMonthSelector is set to true).
allowMultiSelectBooleanundefinedIf set to true will allow for choosing multiple dates. false will force a single selection. If undefined, the picker will attempt to guess based on the type of the input value.
weekdayNamesObject{su: 'sun',mo: 'mon',tu: 'tue',we: 'wed',th: 'thu',fr: 'fri',sa: 'sat'}The weekday names as they are shown above the calendar days. The keys should be the same as seen in the default example.
min`MomentString`undefined
max`MomentString`undefined
showNearMonthDaysBooleantrueWhether to show/hide next and previous month days.
showWeekNumbersBooleanfalseWhether to show/hide the week number of each week (iso week number).
enableMonthSelectorBooleantrueWhether to enable/disable the selection of a moth granularity picker.
isDayDisabledCallback(Moment) => booleanundefinedCallback which should indicate if specific day is disabled.
isMonthDisabledCallback(Moment) => booleanundefinedCallback which should indicate if specific month is disabled (month selector).
dayBtnFormatstringDDThe day format of the day button in the calendar.
dayBtnFormatter(Moment) => StringundefinedThe formatter (callback function) of the day button in the calendar.
monthBtnFormatstringDDThe month format of the month button in the calendar.
monthBtnFormatter(Moment) => StringundefinedThe formatter (callback function) of the month button in the calendar.
calendarSystemECalendarSystemECalendarSystem.jalaliIf ngModel provided as String the format is required, this format also will be used as the input format style.

API:

In order to use the date-picker api user the @ViewChild annotation in the date-picker containing component class, take at the example bellow:
Container component:

import {Component, ViewChild} from '@angular/core';
import {DayPickerComponent} from 'ng2-jalali-date-picker';

@Component({
selector: 'my-container',
template: `
<div>
    <h1>Container</h1>
    <dp-date-picker #dayPicker></dp-date-picker>
    <button (click)="open()"></button>
    <button (click)="close()"></button>
</div>
`
});
class MyContainer {
    @ViewChild('dayPicker') datePicker: DatePickerComponent;
    
    open() {
        this.datePicker.api.open();
    }
     
    close() {
         this.datePicker.api.close();
    } 
}  

Here is the list of APIs:

NameSignatureDescription
open() => voidOpens the date picker
close() => voidCloses the date picker

Inline - Day Calendar

You can use the <dp-day-calendar> component to display the calendar widget without an associated input box.

i.e.

<dp-day-calendar [(ngModel)]="selectedDate" [config]="config"></dp-day-calendar>

Attributes:

NameTypeDefaultDescription
requiredBooleanundefinedThis is a validation rule, if there won't be any selected date then the containing form will be invalid.
minDate`MomentString`undefined
maxDate`MomentString`undefined
themestring ''Theme is a class added to the popup container (and inner components) - this will allow styling of the calendar when it's appended to outer element (for example - body). There is a built in theme named dp-material, you can find it in the demo.
configIDayPickerConfigSee BelowConfiguration object - see description below.

Configuration:

In order to provide configurations to the day-calendar you need to pass it to the dp-day-calendar component:

<dp-day-calendar [(ngModel)]="selectedDate" [config]="config"></dp-day-calendar>

Here are the available configurations:

NameTypeDefaultDescription
formatString"DD-MM-YYYY"If ngModel provided as String the format is required, this format also will be used as the input format style.
firstDayOfWeekString"su"The first day of the calendar's week. Should be one of: "su", "mo", "tu", "we", "th", "fr", "sa"
monthFormatString"MMM-YYYY"The date format of the day calendar, the one that seen above the calendar days. Will be overwritten if monthFormatter provided.
monthFormatter(Moment) => StringundefinedThe date formatter (callback function) of the day calendar, the one that seen above the calendar days.
yearFormatString"YYYY"The date format of the month calendar, the one that seen above the calendar months. Will be overwritten if yearFormatter provided. (available when enableMonthSelector is set to true).
yearFormatter(Moment) => StringundefinedThe date formatter (callback function) of the month calendar, the one that seen above the calendar months. (available when enableMonthSelector is set to true).
allowMultiSelectBooleanundefinedIf set to true will allow for choosing multiple dates. false will force a single selection. If undefined, the picker will attempt to guess based on the type of the input value.
weekdayNamesObject{su: 'sun',mo: 'mon',tu: 'tue',we: 'wed',th: 'thu',fr: 'fri',sa: 'sat'}The weekday names as they are shown above the calendar days. The keys should be the same as seen in the default example.
min`MomentString`undefined
max`MomentString`undefined
showNearMonthDaysBooleantrueWhether to show/hide next and previous month days.
showWeekNumbersBooleanfalseWhether to show/hide the week number of each week (iso week number).
enableMonthSelectorBooleantrueWhether to enable/disable the selection of a moth granularity picker.
isDayDisabledCallback(Moment) => booleanundefinedCallback which should indicate if specific day is disabled.
isMonthDisabledCallback(Moment) => booleanundefinedCallback which should indicate if specific month is disabled (month selector).
dayBtnFormatstringDDThe day format of the day button in the calendar.
dayBtnFormatter(Moment) => StringundefinedThe formatter (callback function) of the day button in the calendar.
monthBtnFormatstringDDThe month format of the month button in the calendar.
monthBtnFormatter(Moment) => StringundefinedThe formatter (callback function) of the month button in the calendar.
calendarSystemECalendarSystemECalendarSystem.jalaliIf ngModel provided as String the format is required, this format also will be used as the input format style.

Inline - Month Calendar

You can use the <dp-month-calendar> component to display the calendar widget without an associated input box.

i.e.

<dp-month-calendar [(ngModel)]="selectedDate" [config]="config"></dp-month-calendar>

Attributes:

NameTypeDefaultDescription
requiredBooleanundefinedThis is a validation rule, if there won't be any selected date then the containing form will be invalid.
minDate`MomentString`undefined
maxDate`MomentString`undefined
themestring ''Theme is a class added to the popup container (and inner components) - this will allow styling of the calendar when it's appended to outer element (for example - body). There is a built in theme named dp-material, you can find it in the demo.
configIMonthPickerConfigSee BelowConfiguration object - see description below.

Configuration:

In order to provide configurations to the month-calendar you need to pass it to the dp-month-calendar component:

<dp-month-picker [(ngModel)]="selectedDate" [config]="config"></dp-month-picker>

Here are the available configurations:

NameTypeDefaultDescription
formatString"DD-MM-YYYY"If ngModel provided as String the format is required, this format also will be used as the input format style.
yearFormatString"YYYY"The date format of the month calendar, the one that seen above the calendar months. Will be overwritten if yearFormatter provided. (available when enableMonthSelector is set to true).
yearFormatter(Moment) => StringundefinedThe date formatter (callback function) of the month calendar, the one that seen above the calendar months. (available when enableMonthSelector is set to true).
allowMultiSelectBooleanundefinedIf set to true will allow for choosing multiple dates. false will force a single selection. If undefined, the picker will attempt to guess based on the type of the input value.
min`MomentString`undefined
max`MomentString`undefined
isMonthDisabledCallback(Moment) => booleanundefinedCallback which should indicate if specific month is disabled (month selector).
monthBtnFormatstringDDThe month format of the month button in the calendar.
monthBtnFormatter(Moment) => StringundefinedThe formatter (callback function) of the month button in the calendar.
calendarSystemECalendarSystemECalendarSystem.jalaliIf ngModel provided as String the format is required, this format also will be used as the input format style.

Directive

You can use the [dpDayPicker] directive to attach the picker to any component with an ngModel or a FormControl (using reactive forms).

i.e.

<input name="someName" [(ngModel)]="selectedDate" [dpDayPicker]="config" />

or using reactive forms:

<input name="someName" formControlName="selectedDate" [dpDayPicker]="config" />
<!-- OR -->
<input name="someName" [formControl]="selectedDateFormControl" [dpDayPicker]="config" />

or with @angular/material:

<md-input-container>
  <input mdInput name="someName" [(ngModel)]="selectedDate" [dpDayPicker]="config" theme="dp-material" attachTo=".mat-input-wrapper" />
</md-input-container>

Attributes:

NameTypeDefaultDescription
type'day'|'month''day'the type of the calender which will be displayed in the picker
attachToElementRef|stringundefinedthe element used to position the picker. If attachTo is a string, it is used as a css selector to match any parent of the directive's host component. If attachTo is undefined, the host component itself is used.
themestring ''Theme is a class added to the popup container (and inner components) - this will allow styling of the calendar when it's appended to outer element (for example - body). There is a built in theme named dp-material, you can find it in the demo.
configIDatePickerDirectiveConfigSee BelowConfiguration object - see description below.

Configuration:

In order to provide configurations to the date-picker you need to pass it to the [dpDayPicker] directive:

<input [(ngModel)]="selectedDate" [dpDayPicker]="datePickerConfig" />

The IDatePickerDirectiveConfig is identical to IDatePickerConfig above except that it lacks the showGoToCurrent property.

Keywords

FAQs

Package last updated on 23 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc