9.0.2 • Published 3 years ago

b5k-datepicker v9.0.2

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

B5kDatepicker

This project was generated with Angular CLI version 8.3.21.

Based on project https://github.com/tomblachut/skimmed-datepicker

Demo

https://stackblitz.com/edit/b5k-datepicker

Screenshots

Inline mode

inline mode

Popup mode

popup mode

Features

  • select only years, months or day
  • popover or inline mode
  • ngModel binding
  • reactive forms

Install

npm i b5k-datepicker --save

Import module

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';

import { B5kDatepickerModule } from 'b5k-datepicker';


@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    B5kDatepickerModule.forRoot(),
    BrowserAnimationsModule
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

Usage

<input type="text" b5kDatepicker>

Get selected date

  • from event

    <input type="text" b5kDatepicker (dateChange)="dateChangeEvent($event)">

  • ngModel

    <input type="text" b5kDatepicker [(ngModel)]="dateModel">

  • reactive Forms

    <input type="text" b5kDatepicker inlineMode=true formControlName="date">

Localization

Datepicker localization is based on date-fns. Just import lang file into module.

Default language is english enGB, so you don't have to import that language file.

import { pl } from 'date-fns/locale';
import { B5kDatepickerModule, B5kDatepickerConfigService } from 'b5k-datepicker';


const DatepickerConfig = new B5kDatepickerConfigService();
DatepickerConfig.setLocale(pl);

@NgModule({
  ...
  providers: [
    {
      provide: B5kDatepickerConfigService,
      useValue: DatepickerConfig
    }
  ]
})
export class AppModule { }

Options

<input type="text" b5kDatepicker [(ngModel)]="monthModel" [view]="view" [modelFormatter]="monthModelFormatter" [selectOnlyMonths]=true>

PropertyTypeDefaultDescription
dateDate--Initial date
inlineModebooleanfalseAlways visible
inputValueFormatterfunction--Function you can format date that is set to input value.
dayFormatstringdDay format in day view, https://date-fns.org/v2.10.0/docs/format
monthFormatstringLLLFormat month names in month view.
headingFormatstringLLLL yFormat date in month heading, eg. February 2020.
weekStartWeekDayWeekDay.Mondayimport { WeekDay } from '@angular/common';
viewViewModeViewMode.Daysimport { ViewMode } from './view-mode';
selectOnlyMonthsbooleanfalseIf selectOnlyMonths = true and view = ViewMode.Months, you can only select month.
selectOnlyYearsbooleanfalseIf selectOnlyYears = true and view = ViewMode.Years you can only select years.

Events

<input type="text" b5kDatepicker [(ngModel)]="model" (dateChange)="selectedDate($event)">

PropertyTypeDescription
dateChangeDateEmitted event when date are selected.

Todo

  • disable date/dates/date ranges/weekends/weekdays
  • date range selection

Development

Build library and watch for changes ng build b5k-datepicker --watch

Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Build

npm run release && npm run publish

If you want to change only major, minor or patch.

npm run standard-version -- --release-as minor && npm run build && npm run publish

License

MIT

9.0.2

3 years ago

9.0.1

3 years ago

8.1.7

3 years ago

8.1.6

3 years ago

8.1.4

4 years ago

8.1.5

4 years ago

8.1.3

4 years ago

8.1.2

4 years ago

8.1.1

4 years ago

8.1.0

4 years ago

8.0.7

4 years ago

8.0.6

4 years ago

8.0.5

4 years ago

8.0.4

4 years ago

8.0.3

4 years ago

0.0.1

4 years ago