npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular2-air-datepicker

v2.0.1

Published

Angular2 Datepicker | Native implementation of air-datepicker

Downloads

318

Readme

npm version Build Status codecov

Angular2 Air Datepicker

Lightweight, customizable, cross-browser Angular2 datepicker. Native implementation of air-datepicker.

Install

npm i angular2-air-datepicker -S  

Usage

template:

<air-datepicker [airOptions]="options" [(airDate)]="date"></air-datepicker>  

While you can use two way binding with airDate, it's recommended you listen to the airChange event for new values.

<air-datepicker [airOptions]="options" (airChange)="dateChanged($event)"></air-datepicker>  

The default value for airDate is null (no date selected). You can get the new selected date by passing $event to your handler function.

<air-datepicker [airOptions]="{ timepicker: true, format12h: true }" [airDate]="date" (airChange)="dateChanged($event)"></air-datepicker>  

You can set the options directly.

component:

import { Component } from '@angular/core';  
  
@Component({  
    selector: 'my-component',  
    templateUrl: './my.template.html'  
})  
export class MyComponent {  
    options: any = { timepicker: true, format12h: true };  
    date: Date = new Date;  
  
    dateChanged (date) {  
        console.log(date, this.date);  
    }  
}  

module:

import { NgModule } from "@angular/core";  
import { CommonModule } from '@angular/common';  
import { FormsModule } from '@angular/forms';

import { Angular2AirDatepickerModule } from 'angular2-air-datepicker';

import { MyComponent } from "./my.component";
  
@NgModule({  
    imports: [  
        CommonModule,
        FormsModule,
        Angular2AirDatepickerModule
    ],  
    declarations: [  
        MyComponent
    ]  
})  
export class HomeModule {}  
  

AirDatepicker requires CommonModule and FormsModule to be imported, either in your current module or your SharedModule

Options

  • timepicker: boolean = false;

Display the time picker (hour & minute).

  • format12h: boolean = false;

For the timepicker, switch to a 12 hour format (AM/PM).

  • language: string = 'en';

Choose a language for localization (currently available: cs, da, de, en, es, fi, fr, hu, it, jp, nl, pl, pt, ro, ru, sk, zh).

  • hourStep: number = 1;

The number of hours the hour slider will move at a time when dragged.

  • minuteStep: number = 1;

The number of minutes the minute slider will move at a time when dragged.

  • range: bool = false;
<air-datepicker [airOptions]="{ range: true }" [airDate]="date" (airChange)="dateChanged()" [airEndDate]="endDate" (airEndChange)="endDateChanged()"></air-datepicker>  

Note: airDate and airEndDate are optional, but if you do set them, you should always use single way binding in tandem with the respective events (airEndDate doesn't support two way binding).

  • enabledDateRanges: DateRange[];

An array of date ranges (objects with start and end Date properties), that defines which dates are selectable. This works both as a minDate/maxDate option, as well as a selective date enabler/disabler.

const now = Date.now();  
const days = 24 * 60 * 60 * 1000;  
  
const options = {  
 enabledDateRanges: [  
  { start: new Date(now - 3 * days), end: new Date(now + 2 * days) },  
  { start: new Date(now + 4 * days), end: new Date(now + 7 * days) }  
 ]  
};  

Note: You'll usually want to set the start and end dates to the start and end of the day (00:00, 23:59), not doing so may result in unintended behaviors in non GMT timezones, unless you know what you're doing. The timepicker option is currently not supported.
Hint: If you only need a minDate, just set one DateRange with the end set to a very distant date.

Notes

Build and Development

git clone https://github.com/kesarion/angular2-air-datepicker
cd angular2-air-datepicker
npm install -g @angular/cli
npm install
ng build
ng serve angular2-air-datepicker-app

The library is the main project, you can build it with ng build and run the tests with ng test (requires chrome). The angular2-air-datepicker-app project is a test app you can use to test the library and any changes you might have made to it. You'll need to rebuild the library after any change or use ng build --watch in another terminal window or tab.

Note: The src/package.json needs to have its version changed manually (before npm version <type>, for deployment purposes; the actual deployment is done automatically on every push to master). Same for the src/README.md. There's a better way to do this, but not this day!

Differences from the original:

  • A Date Object is used as input/output; The developer is responsible for potentially displaying and formatting the selected date;
  • The first day of the week is always Monday;
  • The default language is English;
  • The language options are heavily simplified (names only for days, minDays and months);

To be implemented:

  • input + tooltip version; (only the div based datepicker is currently available)
  • multiple date selection;

Future:

With 2.x out, this package's development may be at an end. I may not be able to continue maintaining and updating it 😔 Although many of the remaining features have been implemented, bugs have been squashed and testing done, this means that any new changes you may require will need to be done by you, whether through a fork or a new project.

On the bright side, I expect it will continue working for a long time in its current state 😄 or with some slight adjustment at some point 🤔

If someone creates a new home for this project at some point, please keep an eye on the issues here for a while, directing people to a more up-to-date version 😉

Thanks

A big thank you to t1m0n/air-datepicker for making this possible with a fantastic datepicker design! And to those who take up the torch to keep it updated! 🎉