Skip to content

Commit

Permalink
refactor: use only TuiTextfield (#7790)
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored Jun 18, 2024
1 parent 5a5e487 commit fa6ccf7
Show file tree
Hide file tree
Showing 44 changed files with 100 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {
TuiGroupDirective,
TuiNotificationComponent,
TuiTextfield,
TuiTextfieldOptionsDirective,
} from '@taiga-ui/core';
import {TuiBadgeDirective, TuiDataListWrapper, TuiSwitchComponent} from '@taiga-ui/kit';
import {
Expand Down Expand Up @@ -72,7 +71,6 @@ import {TuiDocTypeReferencePipe} from './pipes/type-reference.pipe';
NgTemplateOutlet,
TuiDocTypeReferencePipe,
TuiSelectModule,
TuiTextfieldOptionsDirective,
FormsModule,
TuiDropdownOptionsDirective,
TuiShowCleanerPipe,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
TuiIcon,
TuiLink,
TuiScrollbarComponent,
TuiTextfieldOptionsDirective,
TuiTextfield,
} from '@taiga-ui/core';
import {TuiAccordion} from '@taiga-ui/kit';
import type {TuiInputComponent} from '@taiga-ui/legacy';
Expand All @@ -53,7 +53,7 @@ import {
selector: 'tui-doc-navigation',
imports: [
TuiInputModule,
TuiTextfieldOptionsDirective,
TuiTextfield,
ReactiveFormsModule,
TuiAutoFocus,
TuiDataList,
Expand Down
2 changes: 1 addition & 1 deletion projects/core/components/label/label.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TuiLabelStyles {}
'[class._textfield]': 'textfield',
},
})
export class TuiLabelDirective {
export class TuiLabel {
@ContentChild(forwardRef(() => TUI_DATA_LIST_HOST))
protected readonly textfield?: unknown;

Expand Down
2 changes: 1 addition & 1 deletion projects/core/components/textfield/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from './textfield';
export * from './textfield.component';
export * from './textfield.directive';
export * from './textfield.module';
export * from './textfield.options';

// Keeping it manually at the bottom for proper build order
Expand Down
21 changes: 8 additions & 13 deletions projects/core/components/textfield/textfield.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {CommonModule} from '@angular/common';
import {AsyncPipe, NgIf} from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
ContentChild,
ElementRef,
forwardRef,
inject,
Input,
} from '@angular/core';
Expand All @@ -14,7 +15,7 @@ import {tuiIsNativeFocused, TuiNativeValidatorDirective} from '@taiga-ui/cdk';
import {TuiButton} from '@taiga-ui/core/components/button';
import type {TuiDataListHost} from '@taiga-ui/core/components/data-list';
import {tuiAsDataListHost, TuiWithDataList} from '@taiga-ui/core/components/data-list';
import {TuiLabelDirective} from '@taiga-ui/core/components/label';
import {TuiLabel} from '@taiga-ui/core/components/label';
import {tuiAppearanceOptionsProvider} from '@taiga-ui/core/directives/appearance';
import {
TuiDropdownDirective,
Expand All @@ -23,7 +24,7 @@ import {
} from '@taiga-ui/core/directives/dropdown';
import {TuiIcons} from '@taiga-ui/core/directives/icons';
import type {PolymorpheusContent} from '@taiga-ui/polymorpheus';
import {PolymorpheusOutlet, PolymorpheusTemplate} from '@taiga-ui/polymorpheus';
import {PolymorpheusOutlet} from '@taiga-ui/polymorpheus';

import {TuiTextfieldDirective} from './textfield.directive';
import {TUI_TEXTFIELD_OPTIONS, TuiTextfieldOptionsDirective} from './textfield.options';
Expand All @@ -35,13 +36,7 @@ export interface TuiTextfieldContext<T> extends TuiContext<T> {
@Component({
standalone: true,
selector: 'tui-textfield',
imports: [
CommonModule,
ResizeObserverDirective,
TuiButton,
PolymorpheusOutlet,
PolymorpheusTemplate,
],
imports: [NgIf, AsyncPipe, ResizeObserverDirective, TuiButton, PolymorpheusOutlet],
templateUrl: './textfield.template.html',
styleUrls: ['./textfield.style.less'],
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down Expand Up @@ -72,18 +67,18 @@ export interface TuiTextfieldContext<T> extends TuiContext<T> {
],
})
export class TuiTextfieldComponent<T> implements TuiDataListHost<T> {
@ContentChild(TuiTextfieldDirective, {read: ElementRef})
@ContentChild(forwardRef(() => TuiTextfieldDirective), {read: ElementRef})
private readonly el?: ElementRef<HTMLInputElement>;

private readonly dropdown = inject(TuiDropdownOpenDirective, {
optional: true,
self: true,
});

@ContentChild(TuiTextfieldDirective)
@ContentChild(forwardRef(() => TuiTextfieldDirective))
protected readonly directive?: TuiTextfieldDirective;

@ContentChild(TuiLabelDirective, {read: ElementRef})
@ContentChild(TuiLabel, {read: ElementRef})
protected readonly label?: ElementRef<HTMLElement>;

protected side = 0;
Expand Down
26 changes: 0 additions & 26 deletions projects/core/components/textfield/textfield.module.ts

This file was deleted.

14 changes: 14 additions & 0 deletions projects/core/components/textfield/textfield.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {TuiLabel} from '@taiga-ui/core/components/label';

import {TuiSelectDirective} from './select.directive';
import {TuiTextfieldComponent} from './textfield.component';
import {TuiTextfieldDirective} from './textfield.directive';
import {TuiTextfieldOptionsDirective} from './textfield.options';

export const TuiTextfield = [
TuiLabel,
TuiSelectDirective,
TuiTextfieldComponent,
TuiTextfieldDirective,
TuiTextfieldOptionsDirective,
] as const;
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import {Component} from '@angular/core';
import {changeDetection} from '@demo/emulate/change-detection';
import {TuiDemo} from '@demo/utils';
import type {TuiSizeL, TuiSizeXS} from '@taiga-ui/core';
import {TuiLabelDirective} from '@taiga-ui/core';
import {TuiLabel} from '@taiga-ui/core';
import {TuiBadgeNotificationComponent} from '@taiga-ui/kit';

@Component({
standalone: true,
imports: [TuiDemo, TuiBadgeNotificationComponent, TuiLabelDirective],
imports: [TuiDemo, TuiBadgeNotificationComponent, TuiLabel],
templateUrl: './index.html',
changeDetection,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {changeDetection} from '@demo/emulate/change-detection';
import {TuiAmountPipe} from '@taiga-ui/addon-commerce';
import {TuiAutoFocus} from '@taiga-ui/cdk';
import type {TuiDialogContext} from '@taiga-ui/core';
import {TuiButton, TuiDialogService, TuiTextfieldOptionsDirective} from '@taiga-ui/core';
import {TuiButton, TuiDialogService, TuiTextfield} from '@taiga-ui/core';
import {TuiDataListWrapper, TuiSlider} from '@taiga-ui/kit';
import {
TuiInputModule,
Expand All @@ -22,7 +22,7 @@ import {POLYMORPHEUS_CONTEXT} from '@taiga-ui/polymorpheus';
TuiAmountPipe,
AsyncPipe,
TuiAutoFocus,
TuiTextfieldOptionsDirective,
TuiTextfield,
FormsModule,
TuiSelectModule,
TuiTextfieldControllerModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
TuiDialogService,
TuiHintOptionsDirective,
TuiIconPipe,
TuiTextfieldOptionsDirective,
TuiTextfield,
} from '@taiga-ui/core';
import {TuiInputNumberModule, TuiTextfieldControllerModule} from '@taiga-ui/legacy';
import {PolymorpheusComponent} from '@taiga-ui/polymorpheus';
Expand All @@ -20,7 +20,7 @@ import {PayModalComponent} from './pay-modal/pay-modal.component';
imports: [
TuiInputNumberModule,
ReactiveFormsModule,
TuiTextfieldOptionsDirective,
TuiTextfield,
TuiTextfieldControllerModule,
TuiHintOptionsDirective,
TuiButton,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ import {
TuiButton,
TuiFormatNumberPipe,
TuiIconPipe,
TuiLabelDirective,
TuiLink,
TuiLoader,
TuiTextfieldOptionsDirective,
TuiTextfield,
} from '@taiga-ui/core';
import {TuiButtonLoadingComponent, TuiCheckboxComponent} from '@taiga-ui/kit';
import {POLYMORPHEUS_CONTEXT} from '@taiga-ui/polymorpheus';
Expand All @@ -52,8 +51,7 @@ import {inputCardGroupedCVCValidator} from '../helpers/validator';
TuiAutoFocus,
TuiLoader,
TuiInputCardGroup,
TuiTextfieldOptionsDirective,
TuiLabelDirective,
TuiTextfield,
TuiCheckboxComponent,
TuiIconPipe,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {FormsModule} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiValidationError} from '@taiga-ui/cdk';
import {TuiErrorComponent, TuiLabelDirective} from '@taiga-ui/core';
import {TuiErrorComponent, TuiLabel} from '@taiga-ui/core';
import {TuiSwitchComponent} from '@taiga-ui/kit';

@Component({
standalone: true,
imports: [FormsModule, TuiLabelDirective, TuiSwitchComponent, TuiErrorComponent],
imports: [FormsModule, TuiLabel, TuiSwitchComponent, TuiErrorComponent],
templateUrl: './index.html',
encapsulation,
changeDetection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import {Component} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiTextfieldOptionsDirective} from '@taiga-ui/core';
import {TuiTextfield} from '@taiga-ui/core';
import {TuiTooltipModule} from '@taiga-ui/experimental';
import {TuiInputModule, TuiTextfieldControllerModule} from '@taiga-ui/legacy';

@Component({
standalone: true,
imports: [
TuiInputModule,
TuiTextfieldOptionsDirective,
TuiTextfield,
TuiTextfieldControllerModule,
FormsModule,
TuiTooltipModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
TuiHint,
TuiLink,
TuiNotificationComponent,
TuiTextfieldOptionsDirective,
TuiTextfield,
} from '@taiga-ui/core';
import type {TuiCountryIsoCode} from '@taiga-ui/i18n';
import {TuiInputPhoneInternationalComponent} from '@taiga-ui/kit';
Expand All @@ -26,7 +26,7 @@ import {InheritedDocumentationComponent} from '../abstract/inherited-documentati
TuiDropdownModule,
TuiHint,
TuiInputPhoneInternationalComponent,
TuiTextfieldOptionsDirective,
TuiTextfield,
ReactiveFormsModule,
TuiLink,
TuiNotificationComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import {Component} from '@angular/core';
import {FormControl, FormGroup, ReactiveFormsModule} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiHint, TuiTextfieldOptionsDirective} from '@taiga-ui/core';
import {TuiHint, TuiTextfield} from '@taiga-ui/core';
import {TuiInputModule, TuiTextfieldControllerModule} from '@taiga-ui/legacy';

@Component({
standalone: true,
imports: [
ReactiveFormsModule,
TuiInputModule,
TuiTextfieldOptionsDirective,
TuiTextfield,
TuiTextfieldControllerModule,
TuiHint,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import {Component} from '@angular/core';
import {FormControl, FormGroup, ReactiveFormsModule} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiTextfieldOptionsDirective} from '@taiga-ui/core';
import {TuiTextfield} from '@taiga-ui/core';
import {TuiInputModule} from '@taiga-ui/legacy';

@Component({
standalone: true,
imports: [ReactiveFormsModule, TuiInputModule, TuiTextfieldOptionsDirective],
imports: [ReactiveFormsModule, TuiInputModule, TuiTextfield],
templateUrl: './index.html',
styleUrls: ['./index.less'],
encapsulation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {FormControl, FormGroup, ReactiveFormsModule, Validators} from '@angular/
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiTable} from '@taiga-ui/addon-table';
import {TuiTextfieldOptionsDirective} from '@taiga-ui/core';
import {TuiTextfield} from '@taiga-ui/core';
import {TuiDataListWrapper} from '@taiga-ui/kit';
import {
TuiInputDateModule,
Expand All @@ -16,7 +16,7 @@ import {
@Component({
standalone: true,
imports: [
TuiTextfieldOptionsDirective,
TuiTextfield,
ReactiveFormsModule,
TuiTextfieldControllerModule,
TuiInputModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import {Component} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiHint, TuiTextfieldOptionsDirective} from '@taiga-ui/core';
import {TuiHint, TuiTextfield} from '@taiga-ui/core';
import {TuiInputModule, TuiTextfieldControllerModule} from '@taiga-ui/legacy';

@Component({
standalone: true,
imports: [
TuiInputModule,
TuiTextfieldOptionsDirective,
TuiTextfield,
FormsModule,
TuiHint,
TuiTextfieldControllerModule,
Expand Down
4 changes: 2 additions & 2 deletions projects/demo/src/modules/components/input/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
TuiHint,
TuiLink,
TuiNotificationComponent,
TuiTextfieldOptionsDirective,
TuiTextfield,
} from '@taiga-ui/core';
import {TuiInputModule, TuiTextfieldControllerModule} from '@taiga-ui/legacy';
import type {PolymorpheusContent} from '@taiga-ui/polymorpheus';
Expand All @@ -37,7 +37,7 @@ const LONG_TEXT_TEMPLATE = '<span>LongTextContent</span>';
TuiDropdownOptionsDirective,
TuiDropdownOpenDirective,
TuiHint,
TuiTextfieldOptionsDirective,
TuiTextfield,
TuiTextfieldControllerModule,
TuiAmountPipe,
InheritedDocumentationComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import {Component} from '@angular/core';
import {FormControl, FormGroup, ReactiveFormsModule} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiLabelDirective, TuiTitle} from '@taiga-ui/core';
import {TuiLabel, TuiTitle} from '@taiga-ui/core';
import {TuiCheckboxComponent} from '@taiga-ui/kit';

@Component({
standalone: true,
imports: [ReactiveFormsModule, TuiLabelDirective, TuiCheckboxComponent, TuiTitle],
imports: [ReactiveFormsModule, TuiLabel, TuiCheckboxComponent, TuiTitle],
templateUrl: './index.html',
encapsulation,
changeDetection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import {Component} from '@angular/core';
import {FormControl, FormGroup, ReactiveFormsModule} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiLabelDirective} from '@taiga-ui/core';
import {TuiLabel} from '@taiga-ui/core';
import {TuiRadioComponent} from '@taiga-ui/kit';

@Component({
standalone: true,
imports: [ReactiveFormsModule, TuiLabelDirective, TuiRadioComponent],
imports: [ReactiveFormsModule, TuiLabel, TuiRadioComponent],
templateUrl: './index.html',
encapsulation,
changeDetection,
Expand Down
Loading

0 comments on commit fa6ccf7

Please sign in to comment.