From 131c68579b97d342dd3edc362c1909c2648998c1 Mon Sep 17 00:00:00 2001 From: Cody Tolene Date: Sat, 15 Feb 2025 09:46:13 -0600 Subject: [PATCH 1/2] Add remaining components. --- README.md | 40 ++++++--- prettier.config.js | 2 +- src/app/form/form-group-example.ts | 20 ++++- src/app/form/form.component.html | 58 +++++++++++++ src/app/form/form.component.scss | 12 ++- src/app/form/form.component.ts | 40 ++++++++- src/app/layout/footer.component.html | 4 +- src/app/layout/header.component.html | 6 +- src/app/public/form.directive.ts | 12 +++ .../input-chips/input-chip.component.ts | 18 ++++ .../input-chips/input-chips.component.html | 24 ++++++ .../input-chips.component.scss} | 0 .../input-chips/input-chips.component.ts | 34 ++++++++ .../public/input-chips/input-chips.module.ts | 20 +++++ .../input-datepicker.component.html | 63 +++++++------- .../input-datepicker.component.ts | 3 +- .../input-dropdown-option-group.component.ts | 16 ++++ .../input-dropdown-option.component.ts | 21 +++++ .../input-dropdown.component.html | 41 +++++++++ .../input-dropdown.component.scss | 3 + .../input-dropdown.component.ts | 78 +++++++++++++++++ .../input-dropdown/input-dropdown.module.ts | 31 +++++++ .../input-timepicker.component.html | 59 ++++++------- .../input-timepicker.component.ts | 2 + src/app/public/input/input.component.html | 84 ++++++++++--------- src/app/public/input/input.component.ts | 3 +- src/app/public/types/index.ts | 2 +- .../types/{radio-option.ts => option.ts} | 2 +- .../utilities/loading-input.component.ts | 58 +++++++++++++ 29 files changed, 628 insertions(+), 128 deletions(-) create mode 100644 src/app/public/input-chips/input-chip.component.ts create mode 100644 src/app/public/input-chips/input-chips.component.html rename src/app/public/{input-dropdown/.gitkeep => input-chips/input-chips.component.scss} (100%) create mode 100644 src/app/public/input-chips/input-chips.component.ts create mode 100644 src/app/public/input-chips/input-chips.module.ts create mode 100644 src/app/public/input-dropdown/input-dropdown-option-group.component.ts create mode 100644 src/app/public/input-dropdown/input-dropdown-option.component.ts create mode 100644 src/app/public/input-dropdown/input-dropdown.component.html create mode 100644 src/app/public/input-dropdown/input-dropdown.component.scss create mode 100644 src/app/public/input-dropdown/input-dropdown.component.ts create mode 100644 src/app/public/input-dropdown/input-dropdown.module.ts rename src/app/public/types/{radio-option.ts => option.ts} (59%) create mode 100644 src/app/public/utilities/loading-input.component.ts diff --git a/README.md b/README.md index ac0fef9..5d7eb03 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ The components included in this project are: - **InputComponent**: A generic input field that can be used for text, email, password, etc. - **InputCheckboxComponent**: A checkbox input field. +- **InputChipsComponent**: A chips input field. - **InputDatepickerComponent**: A datepicker input field. - **InputDropdownComponent**: A dropdown input field. - **InputRadioModule**: A radio input options field. @@ -145,6 +146,7 @@ application where used: + import { + InputComponent, + InputCheckboxComponent, ++ InputChipsComponent, + InputDatepickerComponent, + InputDropdownComponent, + InputRadioModule, @@ -158,34 +160,50 @@ application where used: ... imports: [ + InputComponent, ++ InputCheckboxComponent, ++ InputChipsComponent, ++ InputDatepickerComponent, ++ InputDropdownComponent, ++ InputRadioModule, ++ InputTextareaComponent, ++ InputTimepickerComponent, ++ InputToggleComponent, ... ], }) ... -// Or import to component +// Or import to a standalone component @Component({ ... imports: [ + InputComponent, ++ InputCheckboxComponent, ++ InputChipsComponent, ++ InputDatepickerComponent, ++ InputDropdownComponent, ++ InputRadioModule, ++ InputTextareaComponent, ++ InputTimepickerComponent, ++ InputToggleComponent, ... ], }) ... -// Then use in template +// Then use in template, simplified example form below: +
-+ -+ -+ -+ -+ -+ -+ -+ -+ ... ++ ++ ++ ++ ++ ++ ++ ++ ++ + ``` diff --git a/prettier.config.js b/prettier.config.js index 2735ad2..82d6156 100644 --- a/prettier.config.js +++ b/prettier.config.js @@ -1,5 +1,5 @@ /** Prettier configuration and options. */ -const prettierConfig = { +var prettierConfig = { $schema: 'https://json.schemastore.org/prettierrc', plugins: ['@trivago/prettier-plugin-sort-imports'], importOrderParserPlugins: ['typescript', 'decorators-legacy'], diff --git a/src/app/form/form-group-example.ts b/src/app/form/form-group-example.ts index bee9379..6dda8a8 100644 --- a/src/app/form/form-group-example.ts +++ b/src/app/form/form-group-example.ts @@ -2,18 +2,21 @@ import { DateTime } from 'luxon'; import { FormControl, FormGroup, Validators } from '@angular/forms'; -import { RadioOption } from '../public/types'; +import { Option } from '../public/types'; import { CustomValidators } from '../public/utilities/custom-validators'; export interface FormGroupExample { checkboxOptional: FormControl; checkboxRequired: FormControl; + chips: FormControl; count: FormControl; date: FormControl; description: FormControl; + dropdown: FormControl; + dropdownMultiple: FormControl | null>; email: FormControl; name: FormControl; - optionsRadio: FormControl; + optionsRadio: FormControl; password: FormControl; time: FormControl; toggleOptional: FormControl; @@ -42,6 +45,10 @@ export const formGroupExample = new FormGroup({ checkboxRequired: new FormControl(null, [ Validators.required, ]), + chips: new FormControl(null, [ + Validators.required, + Validators.maxLength(3), + ]), count: new FormControl(null, [ Validators.min(validation.count.min), Validators.max(validation.count.max), @@ -55,12 +62,19 @@ export const formGroupExample = new FormGroup({ Validators.required, Validators.maxLength(validation.description.maxLength), ]), + dropdown: new FormControl(null, [ + Validators.required, + ]), + dropdownMultiple: new FormControl | null>( + null, + [Validators.required, Validators.maxLength(2)], + ), email: new FormControl(null, [ Validators.email, Validators.required, ]), name: new FormControl(null, [Validators.required]), - optionsRadio: new FormControl(null, [ + optionsRadio: new FormControl(null, [ Validators.required, ]), password: new FormControl(null, [ diff --git a/src/app/form/form.component.html b/src/app/form/form.component.html index 5b03cbc..e34dd09 100644 --- a/src/app/form/form.component.html +++ b/src/app/form/form.component.html @@ -74,6 +74,64 @@ placeholder="Enter or select a time" hint="A time between 8 AM and 8 PM CST." > + + + @for (option of dropdownOptions; track option) { + {{ + option.label + }} + } + + @for (option of groupedDropdownOptions; track option) { + {{ + option.label + }} + } + + Disabled Option + + + + @for (option of dropdownOptions; track option) { + {{ + option.label + }} + } + + @for (option of groupedDropdownOptions; track option) { + {{ + option.label + }} + } + + Disabled Option + + + + @for (chip of chips; track chip) { + {{ chip }} + } + pro-input, > pro-input-checkbox, + > pro-input-chips, > pro-input-datepicker, + > pro-input-dropdown, > pro-input-radio, - > pro-input-timepicker, > pro-input-textarea, - > pro-input-toggle { + > pro-input-timepicker, + > pro-input-toggle, + > pro-loading-input { flex: 0 0 100%; margin: 0 0 calc($margin * 2) 0; max-width: 100%; diff --git a/src/app/form/form.component.ts b/src/app/form/form.component.ts index ff47ff0..a40af9b 100644 --- a/src/app/form/form.component.ts +++ b/src/app/form/form.component.ts @@ -8,13 +8,15 @@ import { MatSnackBar } from '@angular/material/snack-bar'; import { FormDirective } from '../public/form.directive'; import { InputCheckboxComponent } from '../public/input-checkbox/input-checkbox.component'; +import { InputChipsModule } from '../public/input-chips/input-chips.module'; import { InputDatepickerComponent } from '../public/input-datepicker/input-datepicker.component'; +import { InputDropdownModule } from '../public/input-dropdown/input-dropdown.module'; import { InputRadioModule } from '../public/input-radio/input-radio.module'; import { InputTextareaComponent } from '../public/input-textarea/input-textarea.component'; import { InputTimepickerComponent } from '../public/input-timepicker/input-timepicker.component'; import { InputToggleComponent } from '../public/input-toggle/input-toggle.component'; import { InputComponent } from '../public/input/input.component'; -import { RadioOption } from '../public/types'; +import { Option } from '../public/types'; import { FormGroupExample, formGroupExample, @@ -27,8 +29,10 @@ import { imports: [ CommonModule, InputCheckboxComponent, + InputChipsModule, InputComponent, InputDatepickerComponent, + InputDropdownModule, InputRadioModule, InputTextareaComponent, InputTimepickerComponent, @@ -50,6 +54,9 @@ export class FormComponent extends FormDirective { } protected override readonly formGroup = formGroupExample; + protected readonly chips = chips; + protected readonly dropdownOptions = dropdownOptions; + protected readonly groupedDropdownOptions = groupedDropdownOptions; protected readonly radioOptions = radioOptions; protected readonly thirtyDaysFromNow: DateTime; protected readonly today: DateTime; @@ -60,9 +67,15 @@ export class FormComponent extends FormDirective { this.formGroup.setValue({ checkboxOptional: false, checkboxRequired: true, + chips: [this.chips[0], this.chips[1]], count: 45, date: this.today.plus({ weeks: 1 }), description: 'Lorem ipsum dolor sit amet.', + dropdown: this.dropdownOptions[0].value, + dropdownMultiple: [ + this.dropdownOptions[0].value, + this.dropdownOptions[1].value, + ], email: 'test@test.com', name: 'John Doe', optionsRadio: this.radioOptions[0].value, @@ -105,7 +118,30 @@ export class FormComponent extends FormDirective { } } -const radioOptions: RadioOption[] = [ +const chips: readonly string[] = [ + 'Chip 1', + 'Chip 2', + 'Chip 3', + 'Chip 4', + 'Chip 5', + 'Chip 6', + 'Chip 7', + 'Chip 8', +]; + +const dropdownOptions: readonly Option[] = [ + { label: 'Option 1', value: 'One' }, + { label: 'Option 2', value: '2' }, + { label: 'Option 3', value: 3 }, +]; + +const groupedDropdownOptions: readonly Option[] = [ + { label: 'Option 4', value: 'Four' }, + { label: 'Option 5', value: '5' }, + { label: 'Option 6', value: 6 }, +]; + +const radioOptions: readonly Option[] = [ { label: 'Option 1', value: 1 }, { label: 'Option 2', value: '2' }, { label: 'Option 3', value: 3 }, diff --git a/src/app/layout/footer.component.html b/src/app/layout/footer.component.html index 2ffb88d..39f7683 100644 --- a/src/app/layout/footer.component.html +++ b/src/app/layout/footer.component.html @@ -1,8 +1,6 @@