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

ng2-itx-datepicker

v1.0.6

Published

Angular2 date picker

Downloads

22

Readme

ng2-itx-datepicker

Angular 2 date picker - Angular2 reusable UI component based on mydatepicker

npm

preview

Installation

To install this component to an external project, follow the procedure:

  1. npm install ng2-itx-datepicker --save

  2. Add MyDatePickerModule import to your @NgModule like example below

    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    import { MyTestApp } from './my-test-app';
    import { MyDatePickerModule } from 'ng2-itx-datepicker';
    
    @NgModule({
        imports:      [ BrowserModule, MyDatePickerModule ],
        declarations: [ MyTestApp ],
        bootstrap:    [ MyTestApp ]
    })
    export class MyTestAppModule {}
  3. Use the following snippet inside your template:

    <my-date-picker [options]="myDatePickerOptions"
                    (dateChanged)="onDateChanged($event)"></my-date-picker>
    • Mandatory attributes:

      • [options]="myDatePickerOptions"
      • (dateChanged)="onDateChanged($event)"
    • Optional attributes:

      • [selDate]="selectedDate" || [defaultMonth]="defaultMonth"
      • [locale]="locale"
      • [events] = "['2016-11-15', ...dates]"
    • Example of the options data (not all properties listed):

        myDatePickerOptions = {
            todayBtnTxt: 'Today',
            dateFormat: 'yyyy-mm-dd',
            firstDayOfWeek: 'su',
            sunHighlight: true,
            height: '34px',
            width: '375px',
            inline: true
        };
    • Example of the date changed callback:
        onDateChanged(event:any) {
            console.log('onDateChanged(): ', 
                event.date,
                ' - formatted: ', event.formatted,
                ' - epoc timestamp: ', event.epoc,
                ' - selected week start: ', event.start,
                ' - selected week end: ', event.end);
        }
  4. If you are using systemjs package loader add the following mydatepicker properties to the System.config:

    (function (global) {
        System.config({
            paths: {
                'npm:': 'node_modules/'
            },
            map: {
                // Other components are here...
    
                'ng2-itx-datepicker': 'npm:ng2-itx-datepicker',
            },
            packages: {
                // Other components are here...
    
                ng2-itx-datepicker: {
                    main: './index.js',
                    defaultExtension: 'js'
                }
            }
        });
    })(this);

Usage

options attribute

Value of the options attribute is a javascript object. It can contain the following properties.

| Option | Default | Description | | :------------- | :------------- | :----- | | dayLabels | {su: 'Sun', mo: 'Mon', tu: 'Tue', we: 'Wed', th: 'Thu', fr: 'Fri', sa: 'Sat'} | Day labels visible on the selector. | | monthLabels | { 1: 'Jan', 2: 'Feb', 3: 'Mar', 4: 'Apr', 5: 'May', 6: 'Jun', 7: 'Jul', 8: 'Aug', 9: 'Sep', 10: 'Oct', 11: 'Nov', 12: 'Dec' } | Month labels visible on the selector. | | dateFormat | yyyy-mm-dd | Date format on selection area and callback. | | todayBtnTxt | Today | Today button text. | | firstDayOfWeek | mo | First day of week on calendar. One of the following: mo, tu, we, th, fr, sa, su | | sunHighlight | true | Sunday red colored on calendar. | | editableMonthAndYear | true | Is month and year labels editable or not. | | minYear | 1000 | Minimum allowed year in calendar. Cannot be less than 1000. | | maxYear | 9999 | Maximum allowed year in calendar. Cannot be more than 9999. | | disableUntil | no default value | Disable dates backward starting from the given date. For example: {year: 2016, month: 6, day: 26} | | disableSince | no default value | Disable dates forward starting from the given date. For example: {year: 2016, month: 7, day: 22} | | disableWeekends | false | Disable weekends (Saturday and Sunday). | | inline | false | Show mydatepicker in inline mode. | | height | 34px | mydatepicker height without selector. Can be used if inline = false. | | width | 100% | mydatepicker width. Can be used if inline = false. | | selectionTxtFontSize | 18px | Selection area font size. Can be used if inline = false. | | alignSelectorRight | false | Align selector right. Can be used if inline = false. | | indicateInvalidDate | true | If user typed date is not same format as dateFormat, show red background in the selection area. Can be used if inline = false. | | showDateFormatPlaceholder | false | Show value of dateFormat as placeholder in the selection area if it is empty. Can be used if inline = false. |

locale attribute

A two-letter ISO 639-1 language code can be provided as shorthand for several of the options listed above. Currently supported languages: en, fr, ja, fi and es. If the locale attribute is used it overrides dayLabels, monthLabels, dateFormat, todayBtnTxt, firstDayOfWeek and sunHighlight properties from the options.

  • new locale data can be added to this file.

selDate attribute

Provide the initially chosen date that will display both in the text input field and provide the default for the popped-up selector.

events attribute

List of days that will be marked in the calentar, the date must be specified using the same format than options.dateFormat.

<my-date-picker [options]="myDatePickerOptions"
                (dateChanged)="onDateChanged($event)"
                [events] = "['2016-11-15', '2016-11-15']"></my-date-picker>

defaultMonth attribute

If selDate is not specified, when the datepicker is opened, it will ordinarily default to selecting the current date. If you would prefer a different year and month to be the default for a freshly chosen date picking operation, specify a [defaultMonth] in the same format as that for the datepicker options (yyyy.mm if not otherwise specified).

Development of this component

At first fork and clone this repo.

Install all dependencies:

  1. npm install
  2. npm install --global gulp-cli

Run sample application:

  1. Open a terminal and type npm start
  2. Open http://localhost:5000 to browser

Build dist folder (javascript version of the component):

  • gulp all

Execute unit tests and coverage (output is generated to the test-output folder):

  • npm test

Compatibility (tested with)

  • Firefox (latest)
  • Chromium (latest)
  • Edge
  • IE11

License

  • License: MIT

Author

  • Author: brauliolomeli

Credits