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-material-tools

v14.1.2

Published

Updated to Angular 14

Downloads

4,761

Readme

NgxMaterialToolsDemo

Updated to Angular 14

This is a set of custom directives lib for Angular Materials.

For now it contains only matInputCommified directive to be used with standard material matInput.

How to use

Install package

npm i ngx-material-tools

Import module

...
import {NgxMaterialToolsModule} from 'ngx-material-tools';

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

matInputCommified directive

Use matInputCommified directive together with matInput in Angular Reactive Forms

  <form [formGroup]="myForm" style="margin-top: 20px">
  <mat-form-field appearance="outline">
    <mat-label>Deposit Amount</mat-label>
    <input matInput
           matInputCommified
           formControlName="deposit"
           type="text"/>
  </mat-form-field>
</form>
>

matInputCommified demo

demo app

scrollWatch directive

It allows to monitor if scroll appear on specific element (and change other elements layout respectively if needed). In particular: sometimes if scroll appears some elements alignment may need change (for examples labels above the container may be shifted to compensate scrollBar width)

<code class="code">
  Scroll status: {{scrollable.data | json}}
</code>
<section class="content" >
  <div class="header" [style.margin-right.px]="scrollable?.data?.verticalScrollBarWidth">
    Right aligned label
  </div>
  <div class="scrollable" scrollWatch #scrollable="scrollDetails" >
    <div class="some-long-text" *ngIf="showHideLongContent">
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid, amet aperiam asperiores, harum illo in iure nam non odit pariatur perferendis placeat quia quis reiciendis, rem saepe sequi temporibus unde?
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid, amet aperiam asperiores, harum illo in iure nam non odit pariatur perferendis placeat quia quis reiciendis, rem saepe sequi temporibus unde?
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid, amet aperiam asperiores, harum illo in iure nam non odit pariatur perferendis placeat quia quis reiciendis, rem saepe sequi temporibus unde?
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid, amet aperiam asperiores, harum illo in iure nam non odit pariatur perferendis placeat quia quis reiciendis, rem saepe sequi temporibus unde?
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid, amet aperiam asperiores, harum illo in iure nam non odit pariatur perferendis placeat quia quis reiciendis, rem saepe sequi temporibus unde?
    </div>
  </div>
</section>
  1. Put attribute directive scrollWatch directive on specific html element
  2. assign directive instance axported as scrollDetails to any ref variable (#scrollable="scrollDetails")
  3. Use that variable in scope of template (for example to correct margin of element above)

scrollWatch directive demo

demo app

Provided data interface

export interface ContainsScrollEvent {
  hasHorizontalScroll: boolean;
  hasVerticalScroll: boolean;
  verticalScrollBarWidth: number;
  horizontalScrollBarWidth: number;
};

containsScroll pipe

You can also control specific container scrollBar visibility to a containsScroll pipe. It returns Observable which emit scrollBar data, so use Angular async to read them.

But I recommend to use scrollWatch directive since each time you use pipe in template - new instance of MutationObserver is created.

<section class="content" >

  Scroll status: {{(scrollable | containsScroll | async) | json}}

  <div class="header" [style.margin-right.px]="(scrollable | containsScroll | async)?.verticalScrollBarWidth || 0">
    Right aligned label
  </div>
  <div class="scrollable" #scrollable >
    <div class="some-long-text" *ngIf="showLongContent">
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid, amet aperiam asperiores, harum illo in iure nam non odit pariatur perferendis placeat quia quis reiciendis, rem saepe sequi temporibus unde?
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid, amet aperiam asperiores, harum illo in iure nam non odit pariatur perferendis placeat quia quis reiciendis, rem saepe sequi temporibus unde?
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid, amet aperiam asperiores, harum illo in iure nam non odit pariatur perferendis placeat quia quis reiciendis, rem saepe sequi temporibus unde?
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid, amet aperiam asperiores, harum illo in iure nam non odit pariatur perferendis placeat quia quis reiciendis, rem saepe sequi temporibus unde?
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid, amet aperiam asperiores, harum illo in iure nam non odit pariatur perferendis placeat quia quis reiciendis, rem saepe sequi temporibus unde?
    </div>
  </div>
</section>

Check demo app for details

Start demo project

Clone this repo and do npm install

npm install

ng serve

Go to http://localhost:4200

Did you Like this lib? Follow me on Twitter for more Angular and RxJS staff!

Need a mentorship for Angular and RxJS? Find me on codementor.io

Take a look at my video-course on Udemy/PacktPub:

Check my Youtube video-blog "Angular can waste your time!"

*This project was generated with Angular CLI version 8.3.14.