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

@tarienna/ng-tri-state-checkbox

v1.0.0

Published

A TriStateCheckbox for Angular 9

Downloads

7

Readme

NgTriStateCheckbox

This is a three state checkbox for angular 9, which is easy to use and implement. It supports custom styling and can be easily modified.

It can be used to select some entries from a list and control those entries. The user can select / unselect all entries by one click.

Sample Image 1

Installation

It can be installed with npm or yarn

npm install @tarienna/ng-tri-state-checkbox --save

or:

yarn install @tarienna/ng-tri-state-checkbox

Add NgTriStateCheckboxModule to your module

To use the component you have to add the module "NgTriStateCheckboxModule" to your application.

import { NgModule } from '@angular/core';
import { NgTriStateCheckboxModule } from 'ng-tri-state-checkbox';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';

@NgModule({
    imports: [
        // This modules are required to use the ngModel to access the the value of the checkbox
        FormsModule, 
        ReactiveFormsModule,
        // Simply add this module
        NgTriStateCheckboxModule 
    ],
})
export class AppModule { }

Usage

For a more complex implementation see the Sample application section in this documentation. First create the tree state checkbox:

<ng-tri-state-checkbox [(ngModel)]="checkedCountries" #myTriStateBox="ngTriStateCheckbox"></ng-tri-state-checkbox>

Then create the controllers with values:

<input type="checkbox" [ngTriStateControl]="myTriStateBox" [value]="{country: 'USA'}" [(ngModel)]="usaIsChecked">
<input type="checkbox" [ngTriStateControl]="myTriStateBox" [value]="{country: 'Germany'}" [(ngModel)]="germanyIsChecked">
<input type="checkbox" [ngTriStateControl]="myTriStateBox" [value]="{country: 'Great Britain'}" [(ngModel)]="greatBritainIsChecked">
...

API

NgTriStateCheckboxComponent

Typ: Component Tag: ng-tri-state-checkbox Export as: ngTriStateCheckbox

This component is the three (tri) state control. It will handle the ngTriStateControls and output their values.

ngModel

Typ: Template Tag Input: will be ignored at the moment Output: An array of values from the checked ngTriStateControl checkboxes.

checkboxClass

Typ: Template Tag Input: Checkbox class to use a custom theme

NgTriStateControlDirective

Typ: Directive Tag: ngTriStateControl Supported HTML Tags: input[type="checkbox"] Export as: ngTriStateControl Input: ngTriStateCheckbox Required tags: value

The value of this checkbox will only be added to the ngModel output of the connected "ngTriStateCheckbox", when this checkbox is checked.

value

Typ: Template Tag Input: The value of the connected ngTriStateCheckbox.

Custom styles

See the example style in: src/tri-state-checkbox-sample/src/app/basic-sample/basic-sample.component.scss. And the usage in the sunday src/tri-state-checkbox-sample/src/app/basic-sample/basic-sample.component.html checkbox.

To replace the default style for the component simply use the "checkboxClass" tag and set your css class.

<th scope="col">Sunday<br /><ng-tri-state-checkbox ... checkboxClass="tri-state-checkbox-sunday"></ng-tri-state-checkbox></th>

Sample application

The sample application's sourcecode can be found at: src/tri-state-checkbox-sample/.

Sample Image 1

Before you start

To run the sample application, you need to download the source code.

Download the source code

You can download the source code using git or as a zip. Descriptions are below.

Download the Source code with git

Before you download the source code create a new empty directory! Open the commandline in the created directory and check out the source code.

git clone https://github.com/tarienna/ng-tri-state-checkbox.git
Download the source code as zip

There is also the possibility to download the project as zip: Click here to download. After downloading you have to unzip the package.

Install the node packages

To install all dependencies execute the following command:

npm install

Start the Application

To run the sample application execute the following command:

npm run start:example