LibusoftCicom / lc-datepicker

Pure Angular 2+ date and time picker.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Logo of the project

LC DatePicker

Pure Angular date and time picker component.

npm version

Build Status

Demo

Click here for preview

Description

  • LC DatePicker is an Angular component that generates a datepicker calendar on your input element
  • Compatible with Angular up to v16.0.0
  • Only dependencies are RxJS and Font Awesome
  • Customizable date format and language
  • Can be configured as time, date-time, date, month or year picker

Tested with

  • Firefox (latest)
  • Chrome (latest)
  • Chromium (latest)
  • Edge

Installing / Getting started

npm install @libusoftcicom/lc-datepicker

Use the following snippet inside your app module:

import {LcDatePickerModule} from '@libusoftcicom/lc-datepicker';

@NgModule({
  declarations: [
    ...
  ],
  imports: [
    ...
    LcDatePickerModule.withImplementation({adapter: LuxonDateAdapterService})
    // or LcDatePickerModule.withImplementation({adapter: MomentDateAdapterService})
    // It is also possible to extend LCDatePickerAdapter and implement the adapter using a different library.
  ],
  providers: [
    ...
  ],
  bootstrap: [...]
})
export class AppModule {}

Use the following snippet inside your component:

import {DatePickerConfig, ECalendarType} from '@libusoftcicom/lc-datepicker';


@Component({
  ...
})
export class AppComponent {

  public config = new DatePickerConfig();
  public inputDate: DateTime;
  public CalendarOpened = false;
  public CalendarRangeOpened = false;

  constructor(
    private readonly dateAdapter: LCDatePickerAdapter,
    ...
  ) {

    // configuration is optional
    this.config.setCalendarType(ECalendarType.Date);
    this.config.setLocalization('en');
    this.inputDate = this.dateAdapter.now(this.config.getTimezone());
    ...
  }

  public setCalendarDate(dateTime: DateTime): void {
    this.dateInput.nativeElement.value = this.dateAdapter.toISOString(dateTime);
  }

  public toggleCalendarOpen(): void {
    this.CalendarOpened = !this.CalendarOpened;
    ...
  }

Use the following snippet inside your template for date-picker:

<lc-datepicker
   [value]="inputDate"
   [config]="config"
   *ngIf="CalendarOpened"
   (openedChange)="toggleCalendarOpen()"
   (dateChange)="setCalendarDate($event)">
 </lc-datepicker>

Use the following snippet inside your template for date-range-picker:

<lc-date-range-picker
   [valueFrom]="inputRangeDateFrom"
   [valueTo]="inputRangeDateTo"
   [config]="config"
   *ngIf="CalendarRangeOpened"
   (openedChange)="toggleCalendarRangeOpen()"
   (dateChange)="setCalendarDateRange($event)">
 </lc-date-range-picker> 

DatePicker config parameters

  • confirmLabel: string
  • primaryColor: string
  • fontColor: string
  • setCalendarType(ECalendarType)
  • setLocalization(string)
  • setActivePanel(Panel)
  • setTimeFormat(boolean)
  • setTimezone(string)
  • setMinDate(DateTime)
  • setMaxDate(DateTime)
  • setDisabledDates(DateTime[])
  • addDisabledTimeRange(ITime)

Developing

Built With:

  • Angular
  • Font Awesome

Setting up Dev

This project was generated with Angular CLI version 16.2.1.

Angular CLI must be installed before building LC DatePicker component.

npm install -g @angular/cli
git clone https://github.com/LibusoftCicom/lc-datepicker.git
cd lc-datepicker/
npm install
npm run start

Open "http://localhost:4200" in browser

Building

This project was generated with Angular CLI version 16.2.1.

Angular CLI must be installed before building LC DatePicker component.

npm install -g @angular/cli
git clone https://github.com/LibusoftCicom/lc-datepicker.git
cd lc-datepicker/
npm install
npm run build

Versioning

We use SemVer for versioning. For the versions available, see the link to tags on this repository.

Tests

This project was generated with Angular CLI version 16.2.1.

Angular CLI must be installed before building LC DatePicker component.

npm install -g @angular/cli
git clone https://github.com/LibusoftCicom/lc-datepicker.git
cd lc-datepicker/
npm install
npm run test

Contributing

Want to help?

Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our contributing guide and code of conduct and then check out one of our issues.

Licensing

LC DatePicker is freely distributable under the terms of the MIT license.

About

Pure Angular 2+ date and time picker.

License:MIT License


Languages

Language:TypeScript 73.2%Language:HTML 15.4%Language:CSS 7.0%Language:JavaScript 4.3%Language:SCSS 0.2%