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

@bspjojo/reusable-components

v1.0.1

Published

<!-- Start content from readme.part.md --> # ReusableComponents

Downloads

149

Readme

ReusableComponents

Notes

This is a generated file from the individual reusable components, services, and directives in this package.

Installation

npm install @bspjojo/reusable-components

Dialog Service

Description

A service that allows the consumer to create a dialog that will return a result.

Usage

Typescript


import { BspWuiDialogConfig, BspWuiDialogService } from '@bspjojo/reusable-components';
import { ExampleDialogComponent } from './example-dialog/example-dialog.component';

export class ExampleClass {
  constructor(
    private dialogService: BspWuiDialogService
  ) { }

  public openDialog(): void {
    const dialogConf: BspWuiDialogConfig<string> = {
      data: 'some data',
      dialogConfig: {
        allowBackdropClickDismiss: true // set to false to disable dismiss on backdrop click
      }
    };

    this.dialogService
      .open(ExampleDialogComponent, dialogConf)
      .afterClosed()
      .subscribe(v => {
        console.log({ v });
      });
  }
}

ExampleDialogComponent


import { JsonPipe } from '@angular/common';
import { Component, Inject } from '@angular/core';
import { BSPWUI_DIALOG_DATA, BspWuiDialogRef } from '@bspjojo/reusable-components';

@Component({
  selector: 'bsp-ex-example-dialog',
  standalone: true,
  imports: [JsonPipe],
  template: `
  <div class="header">
    <div class="title">Title</div>
    <div class="close" (click)="close()"><i class="bi bi-x-circle"></i></div>
  </div>
  <div class="body">
    {{ dialogData | json }}
  </div>
  <div class="footer">
    <button (click)="acceptAndClose()">Accept</button>
  </div>
`,
  styles: `
  :host {
    width: 500px;
    height: 400px;

    display: flex;
    flex-direction: column;

    .header {
      display: flex;
      flex-direction: row;
      border-bottom: 1px solid darkgray;
      flex: 0 1 auto;

      .title {
        flex: 1 1 auto;
      }

      .close {
        flex: 0 1 auto;
      }
    }

    .body {
      flex: 1 1 auto
    }

    .footer {
      flex: 0 1 auto;
    }
  }
`
})
export class ExampleDialogComponent {
  constructor(
    private dialogRef: BspWuiDialogRef,
    @Inject(BSPWUI_DIALOG_DATA) public dialogData: string
  ) { }

  public close(): void {
    this.dialogRef.close({ res: false });
  }

  public acceptAndClose(): void {
    this.dialogRef.close({ res: true });
  }
}

Generic Input

Description

An input wrapper that displays the label and validation errors in a consistent way.

Usage

Typescript

import { Component, DestroyRef, OnInit } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
import { BspWuiInputComponent } from '@bspjojo/reusable-components';

@Component({
  ...
  imports: [BspWuiInputComponent, ReactiveFormsModule],
  ...
})
export class TextInputComponent implements OnInit {
  public formControl!: FormControl<string | null>;
  public inputId = 'formId'

  constructor(private destroyRef: DestroyRef) { }

  public ngOnInit(): void {
    this.formControl = new FormControl<string>('test', Validators.required);

    this.formControl.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(v => {
      console.log(v);
    });
  }
}

HTML

<bsp-w-ui-input fieldName="Example Field" [formControl]="formControl" [id]="inputId"></bsp-w-ui-input>

Styles

CSS Variables
  • --bsp-w-ui-field-height
    • the height of the BspWuiInputComponent

Nested Menu

Description

A vertical menu with a nested structure where the child items can collapse.

Usage

Typescript

import { Component } from '@angular/core';
import { BspWuiNestedMenuComponent, BspWuiNestedMenuDataItem } from '@bspjojo/reusable-components';

@Component({
  ...
  imports: [BspWuiNestedMenuComponent],
  ...
})
export class MenuContainerComponent {
  public readonly menu: BspWuiNestedMenuDataItem[] = [
    {
      route: '/',
      text: 'Home'
    },
    {
      text: 'Awesome menu item',
      children: [
        {
          collapsed: true,
          route: '/awesome/menu/item',
          text: 'Menu text'
        }
      ],
      text: 'Expanded menu item',
      children: [
        {
          route: '/expanded/menu/item',
          text: 'Expanded'
        }
      ]
    },
    {
      route: 'components',
      text: 'Components',
      children: [
        {
          route: '/inputs', // components/inputs
          text: 'Inputs',
          children: [
            {
              route: '/generic', // components/inputs/generic
              text: 'Generic'
            }
          ]
        }
      ]
    }
  ];
}

HTML

<bsp-w-ui-nested-menu [menuItems]="menu" rootRoute="/"></bsp-w-ui-nested-menu>

Styles

CSS Variables
  • --bsp-w-ui-color-hover
    • The color of the menu items on hover

Page Layout

Description

This module contains

  • a component to help with page layout.
  • a component to handle sections within the page.

Component also has a shortcut menu to the right.

Usage

Typescript

import { Component } from '@angular/core';
import { BspWuiPageLayoutModule } from '@bspjojo/reusable-components';

@Component({
  ...
  imports: [BspWuiPageLayoutModule],
  ...
})
export class PageComponent {
  public numbers = new Array(100);
}

HTML

<bsp-w-ui-page-layout>
  @for (item of numbers; track $index) {
  <bsp-w-ui-page-section heading="Heading section {{$index}}" [sectionId]="$index">
    Content for section {{$index}}
  </bsp-w-ui-page-section>
  }
</bsp-w-ui-page-layout>

Styles

CSS Variables
  • --bsp-w-ui-page-section-border-bottom
    • The border separating the page sections
  • --bsp-w-ui-page-section-list-width
    • The width of the page section list

Validation Error Display

Description

A component that will display any known errors

Usage

HTML

<bsp-w-ui-validation-display [errors]="control.errors"></bsp-w-ui-validation-display>
@Component({
  ...
  imports: [BspWuiValidationDisplayComponent],
  ...
})
export class ComponentClass OnInit {
  public control: FormControl;

  public ngOnInit(): void {
    this.control = new FormControl<string>('a value');
  }
}

Validation Display Service

Description

A service that single sources the form error messages for invalid inputs

Usage

import { Component } from '@angular/core';
import { BspWuiValidationDisplayService } from '@bspjojo/reusable-components';

@Component({
  ...
})
export class AppComponent {
  constructor(validation: BspWuiValidationDisplayService) {
    validation.overrideMessageGenerator('max', ({ max, actual }) => `override for max value of ${max} vs actual ${actual}`);
  }
}