Giter Site home page Giter Site logo

jarema / saturn-datepicker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from saturnteam/saturn-datepicker

0.0 3.0 0.0 485 KB

Material Datepicker with range selection

License: MIT License

TypeScript 88.69% JavaScript 1.24% PHP 0.72% CSS 2.44% Python 1.67% HTML 5.25%

saturn-datepicker's Introduction

Material range datepicker

Material datepicker with range support

What is this?

This is a based on Material source code (March 22, 2018) implementation of Material Datepicker for Angular. I created this repository and this package due to it takes a lot of time to contribute to material2 repository. Issue in material2 repo. Material date range picker

DEMO

Advantages

  1. Dates range selecting in datepicker
  2. Have special attribute to turn on range mode on datepicker
  3. Value managing as easy as it in MatDatepicker
  4. You can use all attributes: min, max, formControl and others
  5. Supports input from keyboard
  6. Supports keyboard handling

Changelog

6.1.1

Fixed a bug with ignoring calendarHeaderComponent

6.1.0

Merged #31

  • Add option to sort views when clicking on period label button (month -> year or year -> month)
  • Add option to enable closing datepicker after date selection #30

6.0.5

Return back style files

6.0.4

The week for pt-BR starts from Sunday

6.0.2

  • Updated to material datepicker 6.4.2
  • Fixed the issue with [value] and [formControl] binding
  • Added FAQ to popular questions

6.0.1

Updated to material datepicker 6.0.1

6.0.0

Styles included! Read below

1.1.7

Update to angular material 6.0.0 (2018/05/04)

It's awesome, but how to use it?

As easy as pie. Installation: yarn add saturn-datepicker or npm install saturn-datepicker Import SatDatepickerModule, SatNativeDateModule and MatDatepickerModule

  <mat-form-field>
    <input matInput
        placeholder="Choose a date"
        [satDatepicker]="picker"
        [value]="date">
    <sat-datepicker #picker [rangeMode]="true"></sat-datepicker>
    <sat-datepicker-toggle matSuffix [for]="picker"></sat-datepicker-toggle>
  </mat-form-field>

Add styles:

  • If you are using CSS: copy-paste or include somehow the file saturn-datepicker/bundle.css
  • If you are using SCSS (preferable):
@import '~saturn-datepicker/theming';
@include sat-datepicker-theme($theme); # material theme data structure https://material.angular.io/guide/theming#defining-a-custom-theme

ngModel/formControl value have this interface:

export interface SatDatepickerRangeValue<D> {
  begin: D | null;
  end: D | null;
}

FAQ

How to change date format or locale?

As same as for material, but with more code, just import constants from 'saturn-datepicker'.

Also you need to install @angular/material-moment-adapter package.

import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, SatDatepickerModule } from 'saturn-datepicker'
import { MAT_MOMENT_DATE_FORMATS, MomentDateAdapter } from '@angular/material-moment-adapter'


@NgModule({
    imports: [
        SatDatepickerModule,
    ],
    providers: [
        MyReportsService,
        {provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
        {provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS},
    ],
})
export class MyModule {
}

For advanced formatting, please look through material documentation.

How to add option to sort views when clicking on period label button ?

orderPeriodLabel option sort the label period views.

  • Default [multi-year]: multi-year then back to month
  • Month [month]: month > year > multi-year
  <mat-form-field>
    <input matInput [satDatepicker]="resultPicker">
    <sat-datepicker
        #resultPicker
        [rangeMode]="true"
        orderPeriodLabel="month">
    </sat-datepicker>
   </mat-form-field>

How disable closing datepicker after date selection ?

closeAfterSelection option enables or disables datepicker closing after date selections. By default the option is true

  <mat-form-field>
    <input matInput [satDatepicker]="resultPicker">
    <sat-datepicker
        #resultPicker
        [rangeMode]="true"
        [closeAfterSelection]="false">
    </sat-datepicker>
   </mat-form-field>

Licence: MIT

A little note for myself

npm run build:lib
cp saturn-datepicker/src/bundle.css saturn-datepicker/src/_theming.scss dist   
(cd dist ; npm pack)
(cd dist ; npm publish)

saturn-datepicker's People

Contributors

hunzaboy avatar jarema avatar saturnteam avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.