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

angular-reactive-utils

v0.0.8

Published

Library with utility methods for reactive abstract controls

Downloads

2

Readme

Angular Reactive Utils

Library with utility methods for reactive abstract controls

Data Types

AbstractControlError | Property | Description | | :------------- | :------------- | | name? | Abstract Control path when using a FormGroup, otherwise is null | | control | Abstract Control source | | error | Validation error name (e.g. 'required'). Will only be the first one found | | value | Validation error details (e.g. {min: 1, current: 0})

AbstractControlErrorI18n extends AbstractControlError | Property | Description | | :------------- | :------------- | | i18n | Aimed to found the JSON path on i18n file for validation error (e.g. 'errors.required')| | i18nFullPath | Full path based on the Form Group control names (e.g. 'errors.required.address')

AbstractControlErrors: i18n errors mapping | Property | Description | | :------------- | :------------- | | [key: string] | Value with type AbstractControlErrorI18n |

API

AbstractControlsService

Build mapping for abstract control with all validation errors present

  • abstractControlErrors(abstractControl: AbstractControl): AbstractControlErrors

Retrieve the FormGroup from context when the children component is being mounted

  • form(parentForm: FormGroupDirective, controlContainer: ControlContainer): FormGroup Avoid passing around the FormGroup for your component on Input() and retrieve it from its propagation context

Patch abstract control with data provided but ignoring form arrays

  • patchIgnoreArray(abstractControl: AbstractControl, data: any | null): void

Reset abstract control values but ignoring form arrays

  • resetIgnoreArray(abstractControl: AbstractControl): void

Examples

AbstractControlsService.abstractControlErrors

  • Simple Form Control
    const control = this.fb.control(0, [Validators.required, Validators.min(1)]);
    // Errors
    {
      "name": udnefined
      "control": FormControl,
      "error": "min",
      "value": {
        "min": 1,
        "actual": 0
      }
    }
  • Simple Form Group
    const form = this.fb.group({
      country: [null, Validators.required],
      region: [null, Validators.required],
    });
    // Errors
    {
      "country": {
        "name": "country",
        "control": FormControl,
        "error": "required",
        "value": true,
        "i18n": "errors.required",
        "i18nFullPath": "errors.required.country"
      },
      "region": {
        "name": "region",
        "control": FormControl,
        "error": "required",
        "value": true,
        "i18n": "errors.required",
        "i18nFullPath": "errors.required.region"
      }
    }
  • Form Group, Level deep 1
    const formLevel1 = this.fb.group({
      address: this.fb.group({
        country: [null, Validators.required],
        region: [null, Validators.required],
      }),
    });
    // Errors
    {
      "address.country": {
        "name": "address.country",
        "control": FormControl,
        "error": "required",
        "value": true,
        "i18n": "errors.required",
        "i18nFullPath": "errors.required.address.country"
      },
      "address.region": {
        "name": "address.region",
        "control": FormControl,
        "error": "required",
        "value": true,
        "i18n": "errors.required",
        "i18nFullPath": "errors.required.address.region"
      }
    }
  • Form Group, Level deep 2
    const formLevel2 = this.fb.group({
      address: this.fb.group({
        user: this.fb.group({
          country: [null, Validators.required],
          region: [null, Validators.required],
        })
      })
    });
    // Errors
    {
      "address.user.country": {
        "name": "address.user.country",
        "control": FormControl,
        "error": "required",
        "value": true,
        "i18n": "errors.required",
        "i18nFullPath": "errors.required.address.user.country"
      },
      "address.user.region": {
        "name": "address.user.region",
        "control": FormControl,
        "error": "required",
        "value": true,
        "i18n": "errors.required",
        "i18nFullPath": "errors.required.address.user.region"
      }
    }
  • Simple Form Array
    const formArray = this.fb.array([
      this.fb.group({
        country: [null, Validators.required],
        region: [null, Validators.required],
      }),
      this.fb.group({
        country: [null, Validators.required],
        region: [null, Validators.required],
      }),
    ]);
    // Errors
    {
      "0.country": {
        "name": "0.country",
        "control": FormControl,
        "error": "required",
        "value": true,
        "i18n": "errors.required",
        "i18nFullPath": "errors.required.0.country"
      },
      "0.region": {
        "name": "0.region",
        "control": FormControl,
        "error": "required",
        "value": true,
        "i18n": "errors.required",
        "i18nFullPath": "errors.required.0.region"
      },
      "1.country": {
        "name": "1.country",
        "control": FormControl,
        "error": "required",
        "value": true,
        "i18n": "errors.required",
        "i18nFullPath": "errors.required.1.country"
      },
      "1.region": {
        "name": "1.region",
        "control": FormControl,
        "error": "required",
        "value": true,
        "i18n": "errors.required",
        "i18nFullPath": "errors.required.1.region"
      }
    }
  • Form Group with Array
    const formWithArray = this.fb.group({
      addresses: this.fb.array([
        this.fb.group({
          country: [null, Validators.required],
          region: [null, Validators.required],
        }),
        this.fb.group({
          country: [null, Validators.required],
          region: [null, Validators.required],
        }),
      ])
    });
    // Errors
    {
      "addresses.0.country": {
        "name": "addresses.0.country",
        "control": FormControl,
        "error": "required",
        "value": true,
        "i18n": "errors.required",
        "i18nFullPath": "errors.required.addresses.0.country"
      },
      "addresses.0.region": {
        "name": "addresses.0.region",
        "control": FormControl,
        "error": "required",
        "value": true,
        "i18n": "errors.required",
        "i18nFullPath": "errors.required.addresses.0.region"
      },
      "addresses.1.country": {
        "name": "addresses.1.country",
        "control": FormControl,
        "error": "required",
        "value": true,
        "i18n": "errors.required",
        "i18nFullPath": "errors.required.addresses.1.country"
      },
      "addresses.1.region": {
        "name": "addresses.1.region",
        "control": FormControl,
        "error": "required",
        "value": true,
        "i18n": "errors.required",
        "i18nFullPath": "errors.required.addresses.1.region"
      }
    }