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

ngx-pmr-duration-picker

v16.0.0

Published

[![Build](https://github.com/pmrelvas/pmr-angular-duration-picker/actions/workflows/build-deploy-lib.yml/badge.svg)](https://github.com/pmrelvas/pmr-angular-duration-picker/actions/workflows/build-deploy-lib.yml) [![Deploy Docs to GitHub Pages](https://gi

Downloads

244

Readme

ngx-pmr-duration-picker

Build Deploy Docs to GitHub Pages

Table of contents

Overview

ngx-pmr-duration-picker is an Angular library to display and manage durations on your application following the standard ISO 8601.

It is able to work with both ngModel and FormsModule, and allows you to customize it to best match your application.

It parses and allows you to edit durations on a pretty and string modes.

Live examples and documentation can be found on the documentation page.

example of duration picker

example of duration picker

example of duration picker

How to use it

You can install this lib with the following command:

npm i --save ngx-pmr-duration-picker

Then you need to import it into your module:

import { NgxPmrDurationPickerModule } from 'ngx-pmr-duration-picker';

Then you can use it on your angular components as described on the following section.

Examples

NgModel

HTML

<pmr-duration-picker [(ngModel)]="duration"></pmr-duration-picker>

TS

import { Component } from '@angular/core';
import { FormBuilder } from '@angular/forms';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  duration = 'P4DT5H6M7S';
}

FormsModule

HTML

<form [formGroup]="formGroup">
  <pmr-duration-picker formControlName="duration"></pmr-duration-picker>
</form>

TS

import { Component } from '@angular/core';
import { FormBuilder } from '@angular/forms';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  formGroup = this.formBuilder.group({
    duration: ['P1Y2M3W4DT5H6M7S']
  });

  constructor(private formBuilder: FormBuilder) {
  }
}

Time

HTML

<pmr-duration-picker [displayedItems]="displayedItems" [(ngModel)]="duration"></pmr-duration-picker>

TS

import { Component } from '@angular/core';
import { FormBuilder } from '@angular/forms';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  displayedItems = ['TH', 'TM', 'TS'];
  duration = 'PT1H2M3S';
}

Increased Font

HTML

<pmr-duration-picker style="font-size: 30px" [(ngModel)]="duration"></pmr-duration-picker>

TS

import { Component } from '@angular/core';
import { FormBuilder } from '@angular/forms';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  duration = 'PT1H2M3S';
}

Disable switch

HTML

<pmr-duration-picker [disableSwitchMode]="true" [(ngModel)]="duration"></pmr-duration-picker>

TS

import { Component } from '@angular/core';
import { FormBuilder } from '@angular/forms';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  duration = 'PT1H2M3S';
}

Properties

| Property | Type | Datatype | Description | Default Value | | --- | --- | --- | --- | --- | | displayedItems | Input | string[] | List of duration units to be displayed. Time fields have a T prefix. Possible values are: Y, M, W, D TH, TM, TS. | ['Y', 'M', 'W', 'D', 'TH', 'TM', 'TS'] | | disableLabel | Input | boolean | If set to true, disables the duration label. | false | | disableSwitchMode | Input | boolean | If set to true, disables the switch mode between pretty and string modes. | false | | duration | Input | string | Allows to override form field label text. | Duration | | valid | Output | EventEmitter | Boolean EventEmitter that reports wether the duration string is valid or not. | |

Run test/docs application

In order to run the test/documentation page, you first need to build the library and run it in watched mode to be able to catch automatically catch your changes.

ng build ngx-pmr-duration-picker --watch

Then on another terminal window we just need to run the application:

npm start

Testing

This lib is covered by cypress component tests.

Tests are automatically run after every build, but they can also be run through the following command:

npm run cy:run:component

or by opening cypress tool in headed mode and by choosing component tests.

npm run cy:open

Build

We can build this lib using the following command:

ng build ngx-pmr-duration-picker

In development mode, to see the changes on our test application, we can append the --watch flag.

To build a production artifact, we can add the --configuration=production flag.

Deploy

We can deploy this lib to a npm registry using the following command:

npm publish dist/ngx-pmr-duration-picker

CI/CD

We are using GitHub actions workflows to build this lib, run cypress component unit tests on every pull request commit commit.

We also ensure continuous delivery publishing the artifact to npm registry and drafting a new release when merging the PR to master.

For the documentation/test page, we also have a GitHub actions workflow to deploy it to GitHub pages.

Issues

For issues reporting, please fill one of the following template forms.

To avoid duplicate issues, please have a look on the existing issues first.