Compare commits
2 Commits
f1a4f51695
...
bccb1b565f
| Author | SHA1 | Date | |
|---|---|---|---|
| bccb1b565f | |||
| 0d46172325 |
@@ -45,124 +45,131 @@
|
|||||||
<hr class="section-divider" />
|
<hr class="section-divider" />
|
||||||
|
|
||||||
<div class="input-grid">
|
<div class="input-grid">
|
||||||
|
<div class="input-field">
|
||||||
|
<label for="search-input">Texto</label>
|
||||||
<app-input
|
<app-input
|
||||||
|
id="search-input"
|
||||||
type="search"
|
type="search"
|
||||||
placeholder="Buscar producto"
|
placeholder="Buscar producto"
|
||||||
[value]="textValue"
|
[(value)]="textValue"
|
||||||
[maxlength]="24"
|
[maxlength]="24"
|
||||||
(valueChange)="textValue = $event"
|
/>
|
||||||
>
|
</div>
|
||||||
Texto
|
|
||||||
</app-input>
|
|
||||||
|
|
||||||
|
<div class="input-field">
|
||||||
|
<label for="number-input">Numero</label>
|
||||||
<app-input
|
<app-input
|
||||||
|
id="number-input"
|
||||||
type="number"
|
type="number"
|
||||||
placeholder="0"
|
placeholder="0"
|
||||||
[value]="numberValue"
|
[(value)]="numberValue"
|
||||||
(valueChange)="numberValue = $event"
|
/>
|
||||||
>
|
</div>
|
||||||
Numero
|
|
||||||
</app-input>
|
|
||||||
|
|
||||||
|
<div class="input-field">
|
||||||
|
<label for="email-input">Email</label>
|
||||||
<app-input
|
<app-input
|
||||||
|
id="email-input"
|
||||||
type="email"
|
type="email"
|
||||||
placeholder="mail@empresa.com"
|
placeholder="mail@empresa.com"
|
||||||
[value]="email"
|
[(value)]="email"
|
||||||
(valueChange)="email = $event"
|
/>
|
||||||
>
|
</div>
|
||||||
Email
|
|
||||||
</app-input>
|
|
||||||
|
|
||||||
|
<div class="input-field">
|
||||||
|
<label for="user-input">Usuario</label>
|
||||||
<app-input
|
<app-input
|
||||||
|
id="user-input"
|
||||||
type="user"
|
type="user"
|
||||||
placeholder="Nombre de usuario"
|
placeholder="Nombre de usuario"
|
||||||
[value]="user"
|
[(value)]="user"
|
||||||
(valueChange)="user = $event"
|
/>
|
||||||
>
|
</div>
|
||||||
Usuario
|
|
||||||
</app-input>
|
|
||||||
|
|
||||||
|
<div class="input-field">
|
||||||
|
<label for="password-input">Password</label>
|
||||||
<app-input
|
<app-input
|
||||||
|
id="password-input"
|
||||||
type="password-toggle"
|
type="password-toggle"
|
||||||
placeholder="********"
|
placeholder="********"
|
||||||
[value]="password"
|
[(value)]="password"
|
||||||
(valueChange)="password = $event"
|
/>
|
||||||
>
|
</div>
|
||||||
Password
|
|
||||||
</app-input>
|
|
||||||
|
|
||||||
<app-input
|
<div class="input-field">
|
||||||
type="date"
|
<label for="date-input">Fecha</label>
|
||||||
[value]="date"
|
<app-input id="date-input" type="date" [(value)]="date" />
|
||||||
(valueChange)="date = $event"
|
</div>
|
||||||
>
|
|
||||||
Fecha
|
|
||||||
</app-input>
|
|
||||||
|
|
||||||
<app-input
|
<div class="input-field">
|
||||||
type="period"
|
<label for="period-input">Periodo</label>
|
||||||
[value]="period"
|
<app-input id="period-input" type="period" [(value)]="period" />
|
||||||
(valueChange)="period = $event"
|
</div>
|
||||||
>
|
|
||||||
Periodo
|
|
||||||
</app-input>
|
|
||||||
|
|
||||||
|
<div class="input-field">
|
||||||
|
<label for="amount-input">Moneda</label>
|
||||||
<app-input
|
<app-input
|
||||||
|
id="amount-input"
|
||||||
type="currency"
|
type="currency"
|
||||||
placeholder="0"
|
placeholder="0"
|
||||||
[value]="amount"
|
[(value)]="amount"
|
||||||
(valueChange)="amount = $event"
|
/>
|
||||||
>
|
</div>
|
||||||
Moneda
|
|
||||||
</app-input>
|
|
||||||
|
|
||||||
|
<div class="input-field">
|
||||||
|
<label for="percent-input">Porcentaje</label>
|
||||||
<app-input
|
<app-input
|
||||||
|
id="percent-input"
|
||||||
type="percent"
|
type="percent"
|
||||||
placeholder="0"
|
placeholder="0"
|
||||||
[value]="percent"
|
[(value)]="percent"
|
||||||
(valueChange)="percent = $event"
|
/>
|
||||||
>
|
</div>
|
||||||
Porcentaje
|
|
||||||
</app-input>
|
|
||||||
|
|
||||||
|
<div class="input-field">
|
||||||
|
<label for="disabled-input">Deshabilitado</label>
|
||||||
<app-input
|
<app-input
|
||||||
|
id="disabled-input"
|
||||||
placeholder="Campo deshabilitado"
|
placeholder="Campo deshabilitado"
|
||||||
[value]="disabledValue"
|
[value]="disabledValue"
|
||||||
[disabled]="true"
|
[disabled]="true"
|
||||||
>
|
/>
|
||||||
Deshabilitado
|
</div>
|
||||||
</app-input>
|
|
||||||
|
|
||||||
|
<div class="input-field">
|
||||||
|
<label for="editable-input">Editable</label>
|
||||||
<app-input
|
<app-input
|
||||||
|
id="editable-input"
|
||||||
type="editable"
|
type="editable"
|
||||||
[value]="editableValue"
|
[(value)]="editableValue"
|
||||||
[disabled]="editableDisabled"
|
[disabled]="editableDisabled"
|
||||||
(valueChange)="editableValue = $event"
|
|
||||||
(disabledChange)="editableDisabled = $event"
|
(disabledChange)="editableDisabled = $event"
|
||||||
>
|
/>
|
||||||
Editable
|
</div>
|
||||||
</app-input>
|
|
||||||
|
|
||||||
|
<div class="input-field">
|
||||||
|
<label for="invalid-input">Invalido</label>
|
||||||
<app-input
|
<app-input
|
||||||
|
id="invalid-input"
|
||||||
type="email"
|
type="email"
|
||||||
placeholder="mail@empresa.com"
|
placeholder="mail@empresa.com"
|
||||||
[value]="invalidEmail"
|
[(value)]="invalidEmail"
|
||||||
[invalid]="true"
|
[invalid]="true"
|
||||||
(valueChange)="invalidEmail = $event"
|
/>
|
||||||
>
|
</div>
|
||||||
Invalido
|
|
||||||
</app-input>
|
|
||||||
|
|
||||||
<div class="file-field">
|
<div class="file-field">
|
||||||
|
<div class="input-field">
|
||||||
|
<label for="file-input">Archivo</label>
|
||||||
<app-input
|
<app-input
|
||||||
|
id="file-input"
|
||||||
type="file"
|
type="file"
|
||||||
accept=".pdf,.png,.jpg"
|
accept=".pdf,.png,.jpg"
|
||||||
[fileName]="fileName"
|
[fileName]="fileName"
|
||||||
[clearTrigger]="clearTrigger"
|
[clearTrigger]="clearTrigger"
|
||||||
(fileChange)="onFileChange($event)"
|
(fileChange)="onFileChange($event)"
|
||||||
>
|
/>
|
||||||
Archivo
|
</div>
|
||||||
</app-input>
|
|
||||||
|
|
||||||
<app-button variant="secondary" (click)="clearFile()">Limpiar archivo</app-button>
|
<app-button variant="secondary" (click)="clearFile()">Limpiar archivo</app-button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -65,6 +65,11 @@ h1 {
|
|||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.input-field {
|
||||||
|
display: grid;
|
||||||
|
gap: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.file-field {
|
.file-field {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 0.75rem;
|
gap: 0.75rem;
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
<label [for]="id" class="input-label">
|
|
||||||
<ng-content />
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="input-control"
|
class="input-control"
|
||||||
[ngClass]="{
|
[ngClass]="{
|
||||||
@@ -20,8 +16,8 @@
|
|||||||
|
|
||||||
<input
|
<input
|
||||||
#inputElement
|
#inputElement
|
||||||
[id]="id"
|
[id]="id()"
|
||||||
[name]="id"
|
[name]="id()"
|
||||||
[type]="inputType()"
|
[type]="inputType()"
|
||||||
[ngClass]="inputClasses()"
|
[ngClass]="inputClasses()"
|
||||||
[disabled]="isInputDisabled()"
|
[disabled]="isInputDisabled()"
|
||||||
|
|||||||
@@ -4,12 +4,6 @@
|
|||||||
padding-bottom: 0 !important;
|
padding-bottom: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-label {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 0.375rem;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-control {
|
.input-control {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
computed,
|
computed,
|
||||||
effect,
|
effect,
|
||||||
input,
|
input,
|
||||||
|
model,
|
||||||
output,
|
output,
|
||||||
signal,
|
signal,
|
||||||
untracked,
|
untracked,
|
||||||
@@ -66,10 +67,12 @@ export class InputComponent {
|
|||||||
private readonly editableDisabled = signal(false);
|
private readonly editableDisabled = signal(false);
|
||||||
private readonly passwordVisible = signal(false);
|
private readonly passwordVisible = signal(false);
|
||||||
private lastClearTrigger = 0;
|
private lastClearTrigger = 0;
|
||||||
|
private readonly defaultId = `app-input-${globalThis.crypto.randomUUID()}`;
|
||||||
|
|
||||||
readonly invalid = input(false);
|
readonly invalid = input(false);
|
||||||
|
readonly id = input(this.defaultId);
|
||||||
readonly placeholder = input('');
|
readonly placeholder = input('');
|
||||||
readonly value = input<string | number>('');
|
readonly value = model<string | number>('');
|
||||||
readonly maxlength = input<number | null>(null);
|
readonly maxlength = input<number | null>(null);
|
||||||
readonly accept = input('');
|
readonly accept = input('');
|
||||||
readonly fileName = input('');
|
readonly fileName = input('');
|
||||||
@@ -81,12 +84,9 @@ export class InputComponent {
|
|||||||
});
|
});
|
||||||
|
|
||||||
readonly disabledChange = output<boolean>();
|
readonly disabledChange = output<boolean>();
|
||||||
readonly valueChange = output<string>();
|
|
||||||
readonly fileChange = output<File | null>();
|
readonly fileChange = output<File | null>();
|
||||||
readonly visibleChange = output<boolean>();
|
readonly visibleChange = output<boolean>();
|
||||||
|
|
||||||
protected readonly id = `app-input-${globalThis.crypto.randomUUID()}`;
|
|
||||||
|
|
||||||
protected readonly inputType = computed(() => {
|
protected readonly inputType = computed(() => {
|
||||||
const type = this.type();
|
const type = this.type();
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ export class InputComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected onValueChange(event: Event): void {
|
protected onValueChange(event: Event): void {
|
||||||
this.valueChange.emit((event.target as HTMLInputElement).value);
|
this.value.set((event.target as HTMLInputElement).value);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected onFileChange(event: Event): void {
|
protected onFileChange(event: Event): void {
|
||||||
|
|||||||
@@ -10,3 +10,9 @@
|
|||||||
:root {
|
:root {
|
||||||
--bs-body-font-family: "Gotham", sans-serif;
|
--bs-body-font-family: "Gotham", sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 0.375rem;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user