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

@libusoftcicom/lc-datepicker

v18.2.0

Published

LC DatePicker - Pure Angular date and time picker component.

Downloads

352

Readme

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 v18.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)

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 inputDate: DateTime;
  public datePickerConfig: DatePickerConfig;
	public dateRangePickerConfig: DatePickerConfig;

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

   const timezone = 'Europe/Zagreb';
   // For dates use ISO 8601 formatted strings, e.g. 2024-09-12T22:00:00.000Z
   // For LCDateRangePickerComponent separate the first and second date using /,
   // e.g. 2024-09-12T22:00:00.000Z/2024-09-13T22:00:00.000Z
   this.inputDate = this.dateAdapter.toISOString(this.dateAdapter.now(timezone));
   // configuration is optional, except for the value.
   // Other properties will be given default values.
   const datePickerConfiguration: IDatePickerConfiguration = {
     value: this.inputDate,
     calendarType: ECalendarType.Date,
     localization: 'hr',
     hourFormat: EHourFormat.TWENTY_FOUR_HOUR,
     timezone: timezone,
     minimumDate: minDate,
     maximumDate: maxDate,
     disabledDates: [
       2024-09-12T22:00:00.000Z
       // ...
     ],
     disabledTimeRanges: [
       {startTime: {hour: 0, minute: 0}, stopTime: {hour: 7, minute: 59}}
       // ...
     ]
     labels: { confirmLabel: 'OK', fromLabel: 'From', toLabel: 'To' },
     theme: { primaryColor: '#5e666f', fontColor: '#5e666f' }
   };
   this.datePickerConfig = new DatePickerConfig(datePickerConfiguration, this.dateAdapter);
   
   const today = this.dateAdapter.today(timezone);

    const dateRangePickerConfiguration = {
      ...Object.assign(datePickerConfiguration),
      value: this.dateAdapter.toISOString(today) + '/' + this.dateAdapter.toISOString(this.dateAdapter.add(today, 1, 'day')),
      calendarType: ECalendarType.DateRange
    };

    this.dateRangePickerConfig = new DatePickerConfig(dateRangePickerConfiguration, this.dateAdapter);
   ...
  }

  public setCalendarDate(dateTime: string): void {
   this.dateInput.nativeElement.value = dateTime;
  }
  
  public setDatePickerOpen(open: boolean): void {
    if (!open) {
      this.dateInput.nativeElement.click();
      this.dateInput.nativeElement.select();
    }
  }

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

<lc-datepicker
   [config]="datePickerConfig"
   (openedChange)="setDatePickerOpen($event)"
   (dateChange)="setCalendarDate($event)">
 </lc-datepicker>

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

<lc-date-range-picker
   [config]="dateRangePickerConfig"
   (openedChange)="setDateRangePickerOpen($event)"
   (dateChange)="setCalendarDateRange($event)">
 </lc-date-range-picker> 

IDatePickerConfiguration properties

  • value: string;
  • calendarType?: ECalendarType
  • theme?: IColorTheme
  • fontColor: string
  • labels?: ILabels
  • hourFormat?: EHourFormat
  • localization?: string
  • minimumDate?: string
  • maximumDate?: string
  • disabledDates?: string[]
  • disabledTimeRanges?: IDisabledTimeRange[]
  • timezone?: string
  • open?: boolean

Developing

Built With:

  • Angular
  • Font Awesome

Setting up Dev

This project was generated with Angular CLI version 18.0.0.

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 18.0.0.

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 18.0.0.

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.