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

@matheo/datepicker

v13.0.0-beta.1

Published

Angular material date+time picker

Downloads

3,310

Readme

@matheo/datepicker

Fork of the official Material Datepicker for Angular with time picking support.

The datepicker allows users to enter a date either through text input, or by choosing a date from the calendar.

Installation

As usual, just execute

npm install @matheo/datepicker
# or
yarn add @matheo/datepicker

Then add the modules to your Angular module, or replace the ones imported from @angular/material/datepicker with these:

import { MatDatepickerModule } from '@matheo/datepicker';
import { MatNativeDateModule } from '@matheo/datepicker/core';

@NgModule({
  imports: [
    MatNativeDateModule,
    MatDatepickerModule,
    ...
  ],
  ...
})
export class AppModule {}

Note that the MatDatepickerModule can be loaded into feature modules,
but it requires the providers given by MatNativeDateModule, so it's recommended to import the former in your root Module. There's the MatLuxonDateModule at @matheo/datepicker/luxon if you use luxon in your application.

<mat-form-field>
  <mat-label>Choose a datetime</mat-label>
  <input matInput [matDatepicker]="picker" formControlName="datetime" />
  <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
  <mat-datepicker type="datetime" #picker></mat-datepicker>
</mat-form-field>

Theming

This module supports the Angular Material prebuilt themes that can be included in angular.json:

"styles": [
  "node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
  "node_modules/@matheo/datepicker/prebuilt-themes/indigo-pink.css",
],

available themes are deeppurple-amber, indigo-pink, pink-bluegrey and purple-green.

Or you can use your customized Material Theme via mixins:

Angular 12+

@use '@angular/material' as mat;
@use '@matheo/datepicker/theming' as datepicker;

mat.$theme-ignore-duplication-warnings: true;

@include mat.core();
...
@include mat.all-component-themes($theme);
@include datepicker.theme($theme)

and add node_modules to your preprocessor options in yourangular.json:

"projects": {
  "[your-project]": {
    "architect": {
      "build": {
        ...
        "stylePreprocessorOptions": {
          "includePaths": ["node_modules"]
        }
      }
    }
  }

For Angular 11 please use @matheo/[email protected].

API

Some relevant input parameters of the mat-datepicker:

  • type: date | datetime | time | month | year output type. default: date
  • startView: multi-year | year | month | hour | minute initial view to load. default: month
  • startAt: start Date, otherwise the current selected value
  • clockStep: interval to use in the minute view. default: 1
  • twelveHour: whether to use 12 or 24 hrs format. default: true
  • color: primary | accent | warn
  • touchUi: calendar UI mode. default: false
  • dateClass: function that can be used to add custom CSS classes to dates

and matInput[matDatepicker] can receive:

  • matDatepickerFilter: function of (D, DateUnit?) => boolean to exclude with a particular algorithm.

For a complete API reference please check the official docs: https://material.angular.io/components/datepicker/api

Internationalization

The message strings used in the datepicker's UI can be overriden providing a subclass of MatDatepickerIntl with the translated values in your application root module.

Date Formats Customization

The display and parse formats used by the datepicker can be overriden providing a custom configuration of MatDateFormats via the MAT_DATE_FORMATS token from @angular/material/core, and using the NativeDateModule instead the Mat-prefixed version which does not include the default formats like:

@NgModule({
  imports: [MatDatepickerModule, NativeDateModule],
  providers: [
    {
      provide: MAT_DATE_FORMATS,
      useValue: {
        parse: {
          ...
        },
        display: {
          ...
        }
      }
    }
  ],
})

More information in the official docs: https://material.angular.io/components/datepicker/overview#internationalization.

Usage Examples

Datepicker by default

<mat-datepicker type="date" #datePicker></mat-datepicker>

DateTime picker (year, month, date and clock views)

<mat-datepicker type="datetime" #datetimePicker></mat-datepicker>

With accent color (starting on the year view)

<mat-datepicker
  color="accent"
  type="datetime"
  startView="year"
  #clockPicker
></mat-datepicker>

Time picker (clock view with 24 hours format)

<mat-datepicker type="time" [twelveHour]="false" #timePicker></mat-datepicker>

Month picker

<mat-datepicker type="month" #monthPicker></mat-datepicker>

Year picker

<mat-datepicker type="year" #yearPicker></mat-datepicker>

See the source code of the demo page for more insights.

Further documentation can be found at the official docs: https://material.angular.io/components/datepicker/overview

Enjoy!