0.0.5 • Published 1 year ago

ngx-custom-input-material v0.0.5

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

NgxCustomInput

This library was generated with Angular CLI version 15.0.0.

Install

npm i ngx-custom-input-material@latest --save

ng add @angular/material

npm i tippy.js

Import

angular.json

"styles": [
  "@angular/material/prebuilt-themes/indigo-pink.css",
  "./node_modules/tippy.js/dist/tippy.css",
  "./node_modules/tippy.js/themes/light-border.css",

],

app.module.ts

import {BrowserModule} from '@angular/platform-browser';  
import {NgModule} from '@angular/core';  
import {AppComponent} from './app.component';  
/** IMPORT **/
import { InputModule } from 'ngx-custom-input-material'; 👈
  
@NgModule({  
  declarations: [  
    AppComponent  
  ],  
  imports: [  
    BrowserModule,  
	InputModule 👈
  ],  
  providers: [],  
  bootstrap: [AppComponent]  
})  
export class AppModule {  
}

app.component.html

<form [formGroup]="form">
      <h1>{{ title }}</h1>
      <ngx-custom-input-help [form]="form" [values]="values[0]" formControlName="usuario"></ngx-custom-input-help>
      <ngx-custom-input-help-date formControlName="fechaP" [form]="form" [values]="values[1]" ></ngx-custom-input-help-date>
      <ngx-custom-input-help-date-range [values]="dateRangeHelp" [form]="form"></ngx-custom-input-help-date-range>
  </form>

Use

Use in your component

Interfaces

export interface Attributes{
  texto: string;
  id: string;
  label: string;
  placeholder?: string;
  formName: string;
  icon?: string;
  }

export interface AttributesDateRangeHelp{
  texto: string;
  id: string;
  name1: string;
  name2: string;
  label: string;
  group: string;
  }
import  {Component,  OnInit}  from  '@angular/core'; 
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AttributesDateRangeHelp } from 'ngx-custom-input-material/input/interfaces/input-help-date-range.interface'; 👈
import { Attributes } from 'ngx-custom-input-material/input/interfaces/input-help.interface'; 👈

@Component({  
  selector: 'app-root',  
  templateUrl: './app.component.html',  
  styleUrls: ['./app.component.css']  
})  
export class AppComponent implements  OnInit {  
	title = 'app-test';
  form!: FormGroup;
  hide = true;

  values: Attributes[] = [{
    texto: 'esto es un texto de ejemplo por Api',
    id: 'usuario',
    label: 'Usuario Api',
    formName: 'usuario',
    placeholder: 'Usuario',
    icon: 'person'

  },
    {
      texto: 'Fecha de planificación esto es un texto de ejemplo por Api',
      id: 'fechaP',
      label: 'Fecha Api',
      formName: 'fechaP',
      placeholder: 'Fecha ejemplo'
    },
  ];

  dateRangeHelp: AttributesDateRangeHelp = {
    texto: 'Deberá seleccionar el rango de Fecha de contratación API',
    id: 'datepRH',
    name1: 'startFechaP',
    name2: 'endFechaP',
    label: 'Seleccione rango de fecha Api',
    group: 'fechaGroupHelp'
  };

  constructor( private fb: FormBuilder ) {
    this.form = this.fb.group({
      usuario: ['', [Validators.required, Validators.minLength(5)]],
      fechaP: ['', Validators.required],
      fechaGroupHelp: this.fb.group({
        startFechaP: ['', Validators.required],
        endFechaP: ['', Validators.required],
      })
    });
  }
	
	ngOnInit() {
		
	}
	
	
}

Code scaffolding

Run ng generate component component-name --project ngx-custom-input to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module --project ngx-custom-input.

Note: Don't forget to add --project ngx-custom-input or else it will be added to the default project in your angular.json file.

Build

Run ng build ngx-custom-input to build the project. The build artifacts will be stored in the dist/ directory.

Publishing

After building your library with ng build ngx-custom-input, go to the dist folder cd dist/ngx-custom-input and run npm publish.

Running unit tests

Run ng test ngx-custom-input to execute the unit tests via Karma.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI Overview and Command Reference page.

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago