import { Component, ChangeDetectionStrategy, signal } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { TextInputComponent } from '../../../../../ui-essentials/src/lib/components/forms/input'; import { TextareaComponent } from '../../../../../ui-essentials/src/lib/components/forms/input'; import { InputWrapperComponent } from '../../../../../ui-essentials/src/lib/components/forms/input'; import { faSearch, faEnvelope, faEdit } from '@fortawesome/free-solid-svg-icons'; @Component({ selector: 'ui-input-demo', standalone: true, imports: [ CommonModule, FormsModule, TextInputComponent, TextareaComponent, InputWrapperComponent ], changeDetection: ChangeDetectionStrategy.OnPush, template: `

Input Component Showcase

Text Input Variants

Outlined (Default)

Filled

Underlined

Input Types

Input States

Inputs with Icons and Features

Special States

Character Limit

Textarea Variants

Basic Textareas

Textarea Variants

Textarea with Features

Textarea States

Input Wrapper (Dynamic)

Usage Examples

Basic Text Input:

<ui-text-input
  label="Email"
  placeholder="Enter your email"
  type="email"
  variant="outlined"
  size="md"
  [(ngModel)]="email"
  (inputChange)="handleEmailChange($event)">
</ui-text-input>

Text Input with Icons:

<ui-text-input
  label="Search"
  placeholder="Search products..."
  type="search"
  variant="filled"
  [prefixIcon]="faSearch"
  [clearable]="true"
  [(ngModel)]="searchTerm"
  (inputChange)="handleSearch($event)">
</ui-text-input>

Textarea:

<ui-textarea
  label="Message"
  placeholder="Enter your message..."
  variant="outlined"
  [rows]="4"
  [maxLength]="500"
  [showCharacterCount]="true"
  [(ngModel)]="message"
  (textareaChange)="handleMessageChange($event)">
</ui-textarea>

Input Wrapper:

<ui-input-wrapper
  [mode]="inputMode"
  label="Dynamic Input"
  placeholder="Switches between input and textarea"
  variant="outlined"
  [prefixIcon]="faEdit"
  [(ngModel)]="content"
  (inputChange)="handleContentChange($event)">
</ui-input-wrapper>

Interactive Actions

@if (lastChangedInput()) {
Last changed: {{ lastChangedInput() }} = "{{ lastChangedValue() }}"
}

Current Values

{{ getValuesAsJson() }}
`, styles: [` h2 { color: hsl(279, 14%, 11%); font-size: 2rem; margin-bottom: 2rem; border-bottom: 2px solid hsl(258, 100%, 47%); padding-bottom: 0.5rem; } h3 { color: hsl(279, 14%, 25%); font-size: 1.5rem; margin-bottom: 1rem; } h4 { color: hsl(287, 12%, 35%); font-size: 1.125rem; margin-bottom: 0.75rem; } section { border: 1px solid hsl(289, 14%, 90%); border-radius: 8px; padding: 1.5rem; background: hsl(286, 20%, 99%); } pre { font-size: 0.875rem; line-height: 1.5; margin: 0.5rem 0; } code { font-family: 'JetBrains Mono', monospace; color: #d63384; } button { transition: all 0.2s ease-in-out; } button:hover { opacity: 0.9; transform: translateY(-1px); } label { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; cursor: pointer; } `] }) export class InputDemoComponent { textValues: Record = {}; lastChangedInput = signal(''); lastChangedValue = signal(''); isLoading = signal(false); useTextarea = signal(false); // FontAwesome icons readonly faSearch = faSearch; readonly faEnvelope = faEnvelope; readonly faEdit = faEdit; handleInputChange(inputName: string, value: string): void { this.textValues[inputName] = value; this.lastChangedInput.set(inputName); this.lastChangedValue.set(value); console.log(`Input changed: ${inputName} = "${value}"`); } handleClear(inputName: string): void { this.textValues[inputName] = ''; this.lastChangedInput.set(inputName); this.lastChangedValue.set('(cleared)'); console.log(`Input cleared: ${inputName}`); } toggleLoading(): void { this.isLoading.set(!this.isLoading()); console.log(`Loading state: ${this.isLoading() ? 'started' : 'stopped'}`); } toggleInputMode(): void { this.useTextarea.set(!this.useTextarea()); console.log(`Input mode: ${this.useTextarea() ? 'textarea' : 'input'}`); } fillSampleData(): void { this.textValues = { 'outlined-md': 'Sample outlined text', 'email': 'user@example.com', 'search': 'sample search query', 'prefix-icon': 'search with icon', 'textarea-md': 'This is a sample message\nin a textarea component\nwith multiple lines.', 'wrapper': 'Dynamic wrapper content' }; this.lastChangedInput.set('multiple'); this.lastChangedValue.set('(sample data filled)'); console.log('Sample data filled'); } clearAllInputs(): void { this.textValues = {}; this.lastChangedInput.set('all'); this.lastChangedValue.set('(cleared)'); console.log('All inputs cleared'); } getValuesAsJson(): string { return JSON.stringify(this.textValues, null, 2); } }