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

mat-pick-range-dates

v17.3.0

Published

Angular 2 component range date picker.

Downloads

238

Readme

MatPickRangeModule

This project was generated with Angular CLI version 17.3.0 & npm 20.10.0 Each version has oun branch on git

  • 17.3.0
  • 15.0.3
  • 8.0.0

Run locally

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

Demo

https://ionut88.github.io/mat-pick-range-dates/

With default options

mat-pick-range-dates1.PNG

With custom options

mat-pick-range-dates2.PNG

Install

$ npm install mat-pick-range-dates

Peer Dependencies

Please note and install the following peer dependencies necessary for Angular v15

"peerDependencies": {
  "@angular/animations": "17.3.0",
  "@angular/material": "17.3.0"
}
.css
@import "~@angular/material/prebuilt-themes/indigo-pink.css";

Example

Import MatPickRangeModule module in your application module. app.module.ts

import { MatPickRangeModule } from 'ngx-mat-daterange-picker';

@NgModule({
  imports: [MatPickRangeModule],
})
export class AppModule {}

app.compnent.html

<mat-pick-range (selectedDateRangeChanged)="updateRange($event)" [options]="options" #picker></mat-pick-range>

Options are not required and will use defauls!

app.component.ts

import { Component, OnInit, ViewChild } from '@angular/core';
import { Options, Range } from './mat-pick-range/model/model';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})
export class AppComponent implements OnInit {
  range: Range = { fromDate: new Date(), toDate: new Date() };
  options: Options;
  @ViewChild('picker', { static: false }) picker;

  ngOnInit() {
    const addDays = (numOfDays) => {
      const today = new Date();
      return new Date(today.setDate(today.getDate() + numOfDays));
    };
    const today = new Date();
    this.options = {
      presets: [
        {
          presetLabel: 'Last 7 Days',
          range: { fromDate: addDays(-7), toDate: today },
        },
        {
          presetLabel: 'Last 30 Days',
          range: { fromDate: addDays(-30), toDate: today },
        },
        {
          presetLabel: 'Last 45 Days',
          range: { fromDate: addDays(-45), toDate: today },
        },
      ],
      format: 'mediumDate',
      range: { fromDate: addDays(-1), toDate: today },
      excludeWeekends: true,
      locale: 'en-US',
      fromMinMax: { fromDate: addDays(-45), toDate: addDays(5) },
      toMinMax: { fromDate: addDays(-45), toDate: addDays(5) },
      applyLabel: 'Apply',
      cancelLabel: 'Cancel',
      calendarOverlayConfig: {
        panelClass: 'mat-prd-overlay',
        hasBackdrop: true,
        backdropClass: 'mat-prd-overlay-backdrop',
        shouldCloseOnBackdropClick: true,
      },
      placeholder: 'Choose a date',
      startDatePrefix: 'FROM:',
      endDatePrefix: 'TO:',
    };
  }

  updateRange(range: Range) {
    this.range = range;
  }

  reset() {
    const today = new Date();
    this.picker.resetDates({
      fromDate: new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1),
      toDate: today,
    });
  }
}

defaultOptions

defaultOptions: Options = {
  applyLabel: 'Apply',
  cancelLabel: 'Cancel',
  placeholder: 'Choose a date',
  format: 'mediumDate',
  excludeWeekends: false,
  locale: 'en-US',
  fromMinMax: { fromDate: null, toDate: null },
  toMinMax: { fromDate: null, toDate: null },
  range: { fromDate: new Date(), toDate: new Date() },
  calendarOverlayConfig: {
    panelClass: 'mat-prd-overlay',
    hasBackdrop: true,
    backdropClass: 'mat-prd-overlay-backdrop',
    shouldCloseOnBackdropClick: true,
  },
};

Build

Run ng build to build the project. The build artifacts will be stored in the dist/ directory.

Run npm run watch to build the library project and watch it. The build artifacts will be stored in the dist/.

License

MIT