@douglas-serena/ng-inputs
Version:
angular entry library
215 lines (172 loc) • 5.16 kB
Markdown
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 11.2.3.
```bash
npm install --save @douglas-serena/ng-inputs
// Or with yarn
yarn add @douglas-serena/ng-inputs
```
Import **ng-inputs** module in Angular app.
```typescript
import { NgModule } from '@angular/core';
import { NgInputsModule } from '@douglas-serena/ng-inputs';
@NgModule({
imports: [
NgInputsModule,
],
})
```
```typescript
import { NgModule } from '@angular/core';
import { NgInputsModule, INgInputConfig } from '@douglas-serena/ng-inputs';
const config: INgInputConfig = {
currency: { prefix: '$' },
percent: { suffix: '%' },
environments: {
debug: false,
url: 'localhost:5000/search' // Variable used in components like search
},
field: {
alignIcons: 'left', // Align is set to defautl for all icons if it doesn't get past
/**
* the icons are defined with the type that is passed in the
* input being able to make custom types,
* if not enough * native html will be changed
* to text
*/
icons: {
currency: {
align: 'left',
clickable: true,
icon: 'fas fa-dollar-sign'
}
},
type: 'group' // fields: 'group' | 'floating'/ options used only in the bootstrap
},
theme: 'bootstrap' // Themes: 'bootstrap' | 'materialize'
}
@NgModule({
imports: [
NgInputsModule.forRoot(config),
],
})
```
```typescript
const configCurrencyAndPercent = {
prefix: "$",
align: "left",
allowNegative: false,
cursor: "end",
decimalSeparator: ".",
suffix: " ",
thousandsSeparator: ",",
};
```
All inputs are used with Reactive Form and already offer it, without needing to import **ReactiveFormsModule** and **FormsModule**
```html
<dss-input
label="password: "
placeholder="password"
formControlName="password"
field="floating"
[]="true"
[]="true"
[]="password-id-custom"
[]="{ required: 'Errro' }"
[]="{default: 12,lg: 6,md: 9,sm: 12}"
type="password"
alignIcon="left"
alignText="right"
[]="true"
[]="fas fa-dollar-sign"
[]="true"
[]="https://malcoded.com/static/8c48d4c4bb8b1f2793fa9c6536dae7c6/ba299/angular-reactive-forms-tutorial.png"
[]="left"
[]="0000000/00000|0000000000/0000000"
></dss-input>
```
- **Name** is used in case of conflict of the id which is automatically defined by taking the name of the formControlName
- **currency:** the currency type has predefined settings that can be customized in the import settings in the app
- **percent:** the percent type has predefined settings that can be customized in the import settings in the app
- **password:** Password already has an eye icon with the option to show password
- **masks:**
- **zipCode: "00000-000"**
- **cpf: "000.000.000-00"**
- **cnpj: "00.000.000/0000-00"**
- **cpf_cnpj: "000.000.000-00" | "00.000.000/0000-00"**
- **rg: "00.000.000-0"**
- **estadual: "00.0.000.0000000-0"**
- **rg_estadual: "00.000.000-0" | "00.0.000.0000000-0"**
- **tel: "(00) 0000-0000" | "(00) 0 0000-0000"**
```html
<dss-text-area
label="description: "
placeholder="description"
formControlName="description"
field="floating"
[]="true"
[]="true"
[]="description-id-custom"
[]="{ required: 'Errro' }"
[]="{default: 12,lg: 6,md: 9,sm: 12}"
[]="2"
[]="300"
></dss-text-area>
```
```html
<dss-select
label="State: "
formControlName="state"
[]="{label: 'Select client', value: '', hide: true}"
[]="clients"
[]="{'people.name': 'people.id'}"
[]="true"
[]="true"
[]="password-id-custom"
field="floating"
[]="{ required: 'Errro' }"
[]="{default: 12,lg: 6,md: 9,sm: 12}"
></dss-select>
```
- **options**: use if it is not defined as a standard object {label: '', value: ''}
- **path**: use if it is not defined as a standard object {label: '', value: ''}
- **optionDefault**: use if it is not defined as a standard object {label: '', value: ''}
```html
<dss-search
type="search"
label="search: "
placeholder="search"
alignIcon="left"
alignText="right"
[]="true"
[]="true"
field="floating"
[]="valueStart"
pathLabel="people.name"
uri="{url}/client/name/{value}"
responseData="data"
return="pessoa.id"
></dss-search>
```
- **return**
- **value**
- **pathLabel**
- **uri**
- **responseData**
the errors are rendered with the type that is defined in the ReactiveFormsModule
-