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-compack

v16.0.4

Published

some components/services/directives for angular project

Downloads

15

Readme

Introduction

This library is used in the author's personal works, but if someone likes the implementation and wants to use it too, I will only be glad. This project was generated with Angular CLI version 14.0.0. Supported 9/10/11+.

You can view live example

License

Table of contents

Dependency

BrowserAnimationsModule

Components

compack-date-picker-range

Import in project

import { CompackDatepickerModule } from 'ngx-compack';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

@NgModule({
  ...
  imports: [
  BrowserAnimationsModule,
  CompackDatepickerModule
  ...
})
export class AppModule { }

Using

add compackDatePickerRangeHost directive to element or create <compack-date-picker-range></compack-date-picker-range> in code Example:

<compack-date-picker-range [locale]="'en'" (selectLastDateEvent)="selectLastDateEventRange($event)">
</compack-date-picker-range>

<input placeholder="click me" compackDatePickerRangeHost [locale]="'en'"
  (selectLastDateEvent)="selectLastDateEventRange($event)" [disabled]="false" [formatOutputDate]="'dd-mm-yyyy'" />

<div compackDatePickerRangeHost (selectLastDateEvent)="selectLastDateEventRange($event)" [relativeDateModel]="[]">
  click me
</div>

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" compackDatePickerRangeHost [locale]="localeRange"
  (selectLastDateEvent)="selectLastDateEventRange($event)" [disabled]="disabledRange"
  [formatOutputDate]="formatOutputDateRange" [relativeDateModel]="relativeDateModel">
  <path d="M0 0h24v24H0z" fill="none" />
  <path
    d="M17 12h-5v5h5v-5zM16 1v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2h-1V1h-2zm3 18H5V8h14v11z" />
</svg>

Properties

parameters with which there is changed data-picker-range behavior

| Name | Default | Description | | -------------------------------------------- | --------- | ----------------------------------------------------------- | | @Input() locale: string | 'en' | Intl.Locale | | @Input() disabled: boolean | false | disabled state | | @Input() formatOutputDate: string|'dd.mm.yyyy' | after accept date will convert to this format | | @Input() relativeDateModel: CompackRelativeDateModel[] | undefined | relative date in left side picker|

Events

Events generated from date-picker-range

| Name | Default | Description | | ---------------------------------------------------------- | ------------ | ----------------- | | @Output() selectLastDateEvent | EventEmitter<string[]> | event after select date |

CompackRelativeDateModel

export interface CompackRelativeDateModel {
    title: string;
    dateStartFunc: () => Date;
    dateEndFunc: () => Date
}

| field | descrption | | ------------ | ------------ | | title | displayed name for period in calendar | | dateStartFunc | func returned start date | | dateEndFunc | func returned end date |

example:

      {
        title: 'last 7 day',
        dateStartFunc: () => {
          const date = new Date(new Date().setHours(0, 0, 0, 0));
          date.setDate(date.getDate() - 7);
          return date;
        },
        dateEndFunc: () => new Date(new Date().setHours(0, 0, 0, 0))
      },

compack-date-picker

Import in project

import { CompackDatepickerModule } from 'ngx-compack';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

@NgModule({
  ...
  imports: [
  BrowserAnimationsModule,
  CompackDatepickerModule
  ...
})
export class AppModule { }

Using

add compackDatePickerHost directive to element or create <compack-date-picker></compack-date-picker> in code Example:

<svg compackDatePickerHost class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" [locale]="'en'"
  [type]="'icon'" [maxChoseDay]="5" [max]="max" [min]="min" (selectLastDateEvent)="selectLastDateEvent($event)">
  <path d="M0 0h24v24H0z" fill="none" />
  <path
    d="M17 12h-5v5h5v-5zM16 1v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2h-1V1h-2zm3 18H5V8h14v11z" />
</svg>

<compack-date-picker [locale]="'en'" [type]="'icon'" [maxChoseDay]="5" [max]="max" [min]="min">
</compack-date-picker>

<compack-date-picker [type]="'line'" [maxChoseDay]="5" [max]="max" [min]="min">
</compack-date-picker>

Properties

parameters with which there is changed data-picker behavior

| Name | Default | Description| | -------------------------------------------- | --------- | ----------------------------------------------------------- | | @Input() locale: string | 'en' | Intl.Locale | | @Input() disabled: boolean | false | disabled state | | @Input() rangeMode: boolean | false | select one date or range | | @Input() viewFieldSelectedDate: boolean | false | display field with selected date | | @Input() useTime: boolean | false | add time field or not | | @Input() autoSelect: boolean | false | auto select date after choose only without useTime | | @Input() maxChoseDay: number | undefined | maximum range for selection | | @Input() max: Date | undefined | date limit from below | | @Input() min: Date | undefined | date cut from above | | @Input() formatOutputDate: string|'dd.mm.yyyy' | after accept date will convert to this format |

Events:

Events generated from date picker

| Name | Default | Description | | ---------------------------------------------------------- | ------------ | ----------------- | | @Output() selectLastDateEvent | EventEmitter<string[]> | event after select date |

compack-banner

is the message hanging in the foreground.

DisplayMessageConfig

export class DisplayMessageConfig {
    public title?: string;
    public message: string;
    public intervalView?: number;
    public typeMessage: TypeMessage;
    public position: TypePositionMessage;

    constructor() {
        this.title = undefined;
        this.message = '';
        this.intervalView = undefined;
        this.typeMessage = 0;
        this.position = 0;
    }
}

TypePositions

export enum TypePositionMessage {
    Top = 0,
    TopLeft = 1,
    TopRight = 2,
    Middle = 3,
    Bottom = 4,
    BottomLeft = 5,
    BottomRight = 6
}

TypeBanner

export enum TypeMessage {
    Info = 0,
    Error = 1
}

Import in project

import { CompackBannerModule } from 'ngx-compack';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

@NgModule({
  ...
  imports: [
    CompackBannerModule,
	BrowserAnimationsModule
  ...
})
export class AppModule { }

Using

For view banner need call method viewBanner() in Injected service Compackbannerservice

public viewBanner(typeMessage: TypeMessage, position: TypePositionMessage, message: string, title?: string, intervalView?: number)

import { Component, OnInit } from '@angular/core';
import { TypeMessage, TypePositionMessage } from 'ngx-compack';
import { CompackBannerService, DisplayMessageConfig } from 'ngx-compack';

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

constructor(private cbs: CompackBannerService ) { }

ngOnInit() {
	this.cbs.setInfoColor('#000');
	this.cbs.setErrorColor('#fff');
   setTimeout(() => this.cbs.viewBanner(TypeMessage.Info, TypePositionMessage.TopRight, 'asdas'), 0);
	}
}

Using api

add CompackBannerService from DI in constructor.

| Method | Description | | -------------------------------- | ------------------------------------ | | viewBanner(typeMessage: TypeMessage, position: TypePositionMessage, message: string, title?: string, intervalView?: number) | add new banner | | removeBanner() | remove last banner | | setInfoColor(color: string) | set back color for info type banner | | setErrorColor(color: string) | set back color for error type banner |

compack-toast

ToastConfig

export class ToastConfig {
    public title: string;
    public type: TypeToast;
    public message?: string;

    constructor() {
        this.title = '';
        this.type = TypeToast.Error
    }
}

TypeToast

export declare enum TypeToast {
    Error = 0,
    Info = 1,
    Success = 2
}

Import in project

import { CompackToastModule } from 'ngx-compack';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

@NgModule({
  ...
  imports: [
    CompackToastModule,
    BrowserAnimationsModule
  ...
})
export class AppModule { }

Using

For view toast message need call method emitNotife() in Injected service CompackToastService

public emitNotife(type: TypeToast, title: string, message?: string);

import { Component, OnInit } from '@angular/core';
import { CompackToastService, TypeToast } from 'ngx-compack';

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

constructor(private cts: CompackToastService) { }

ngOnInit() {
	this.cts.emitNotife(TypeToast.Error, 'Error Error ErrorError ErrorErrorErrorErrorError vErrorError Error Error');
	this.cts.emitNotife(TypeToast.Info, 'Info');
}
}

Using api

add CompackToastService from DI in constructor.

| Method | Description | | ------------------------------------------------------------ | --------------------------------------- | | emitNotife(type: TypeToast, title: string, message?: string) | add new message | | setInfoColor(color: string) | set back color for info type message | | setErrorColor(color: string) | set back color for error type message | | setSuccessColor(color: string) | set back color for success type message | | setTimeToAutoRemove(time: number) | set time to auto remove message |