Skip to content

Commit

Permalink
chore: fix doc, add tuiTextfieldFiller
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirpotekhin committed Dec 12, 2022
1 parent b80d9c5 commit 94a0fd6
Show file tree
Hide file tree
Showing 21 changed files with 83 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ export class TuiPrimitiveTextfieldComponent
@tuiDefaultProp()
editable = true;

@Input()
/** @deprecated use `tuiTextfieldFiller` from {@link TuiTextfieldControllerModule} instead */
@Input(`filler`)
@tuiDefaultProp()
filler = ``;
textfieldFiller = ``;

@Input()
@tuiDefaultProp()
Expand Down Expand Up @@ -137,6 +138,10 @@ export class TuiPrimitiveTextfieldComponent
return this.textfieldPostfix || this.controller.postfix;
}

get filler(): string {
return this.textfieldFiller || this.controller.filler;
}

get nativeFocusableElement(): HTMLInputElement | null {
if (this.computedDisabled || !this.focusableElement) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe(`PrimitiveTextfield`, () => {
<tui-primitive-textfield id="test1"></tui-primitive-textfield>
<tui-primitive-textfield
id="test2"
[filler]="'filler'"
[tuiTextfieldFiller]="'filler'"
[postfix]="'post'"
[value]="'value'"
[pseudoFocus]="true"
Expand Down
1 change: 1 addition & 0 deletions projects/core/directives/textfield-controller/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from './textfield-cleaner.directive';
export * from './textfield-controller.module';
export * from './textfield-controller.provider';
export * from './textfield-custom-content.directive';
export * from './textfield-filler.directive';
export * from './textfield-icon.directive';
export * from './textfield-icon-left.directive';
export * from './textfield-label-outside.directive';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {NgModule} from '@angular/core';

import {TuiTextfieldCleanerDirective} from './textfield-cleaner.directive';
import {TuiTextfieldCustomContentDirective} from './textfield-custom-content.directive';
import {TuiTextfieldFillerDirective} from './textfield-filler.directive';
import {TuiTextfieldIconDirective} from './textfield-icon.directive';
import {TuiTextfieldIconLeftDirective} from './textfield-icon-left.directive';
import {TuiTextfieldLabelOutsideDirective} from './textfield-label-outside.directive';
Expand All @@ -19,6 +20,7 @@ import {TuiTextfieldSizeDirective} from './textfield-size.directive';
TuiTextfieldIconLeftDirective,
TuiTextfieldPrefixDirective,
TuiTextfieldPostfixDirective,
TuiTextfieldFillerDirective,
],
exports: [
TuiTextfieldCleanerDirective,
Expand All @@ -29,6 +31,7 @@ import {TuiTextfieldSizeDirective} from './textfield-size.directive';
TuiTextfieldIconLeftDirective,
TuiTextfieldPrefixDirective,
TuiTextfieldPostfixDirective,
TuiTextfieldFillerDirective,
],
})
export class TuiTextfieldControllerModule {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import {ChangeDetectorRef, InjectionToken, Provider} from '@angular/core';
import {TuiDestroyService, tuiWatch} from '@taiga-ui/cdk';
import {
TUI_TEXTFIELD_FILLER,
TuiTextfieldFillerDirective,
} from '@taiga-ui/core/directives/textfield-controller/textfield-filler.directive';
import {merge, NEVER, Observable} from 'rxjs';
import {takeUntil} from 'rxjs/operators';

Expand Down Expand Up @@ -51,6 +55,7 @@ export const TEXTFIELD_CONTROLLER_PROVIDER: Provider = [
TUI_TEXTFIELD_SIZE,
TUI_TEXTFIELD_PREFIX,
TUI_TEXTFIELD_POSTFIX,
TUI_TEXTFIELD_FILLER,
],
useFactory: (
changeDetectorRef: ChangeDetectorRef,
Expand All @@ -64,6 +69,7 @@ export const TEXTFIELD_CONTROLLER_PROVIDER: Provider = [
TuiTextfieldSizeDirective,
TuiTextfieldPrefixDirective,
TuiTextfieldPostfixDirective,
TuiTextfieldFillerDirective,
]
) => {
const change$ = merge(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {Directive, forwardRef, InjectionToken, Input} from '@angular/core';
import {AbstractTuiController} from '@taiga-ui/cdk';

export const TUI_TEXTFIELD_FILLER = new InjectionToken<TuiTextfieldFillerDirective>(
`[TUI_TEXTFIELD_FILLER]: tuiTextfieldPrefix`,
{
factory: () => new TuiTextfieldFillerDirective(),
},
);

@Directive({
selector: `[tuiTextfieldFiller]`,
providers: [
{
provide: TUI_TEXTFIELD_FILLER,
useExisting: forwardRef(() => TuiTextfieldFillerDirective),
},
],
})
export class TuiTextfieldFillerDirective extends AbstractTuiController {
@Input(`tuiTextfieldFiller`)
filler = ``;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {TuiContextWithImplicit} from '@taiga-ui/cdk';
import {TuiTextfieldFillerDirective} from '@taiga-ui/core/directives/textfield-controller/textfield-filler.directive';
import {TuiSizeL, TuiSizeS} from '@taiga-ui/core/types';
import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus';
import {Observable} from 'rxjs';
Expand All @@ -23,6 +24,7 @@ export class TuiTextfieldController {
private readonly sizeDirective: TuiTextfieldSizeDirective,
private readonly prefixDirective: TuiTextfieldPrefixDirective,
private readonly postfixDirective: TuiTextfieldPostfixDirective,
private readonly fillerDirective: TuiTextfieldFillerDirective,
) {}

get cleaner(): boolean {
Expand Down Expand Up @@ -56,4 +58,8 @@ export class TuiTextfieldController {
get postfix(): string {
return this.postfixDirective.postfix;
}

get filler(): string {
return this.fillerDirective.filler;
}
}
2 changes: 2 additions & 0 deletions projects/demo/src/modules/components/abstract/control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ export abstract class AbstractExampleTuiControl

exampleText = ``;

filler = ``;

maxHeight: number | null = null;

readonly iconLeftVariants = [``, `tuiIconMailLarge`, `tuiIconPiechartLarge`];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,13 @@
<code>SvgService</code>
</a>
</ng-template>
<ng-template
i18n
documentationPropertyName="tuiTextfieldFiller"
documentationPropertyMode="input"
documentationPropertyType="string"
[(documentationPropertyValue)]="documentedComponent.filler"
>
Gray background text as a hint (e.g. HH:MM:SS for time)
</ng-template>
</tui-doc-documentation>
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
[tuiHintDirection]="hintDirection"
[tuiHintAppearance]="hintAppearance"
[tuiTextfieldIconLeft]="iconLeft"
[tuiTextfieldFiller]="filler"
[tuiTextfieldCleaner]="cleaner"
[tuiTextfieldLabelOutside]="labelOutside"
[tuiTextfieldSize]="size"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
[readOnly]="readOnly"
[tuiTextfieldIconLeft]="iconLeft"
[tuiTextfieldLabelOutside]="labelOutside"
[tuiTextfieldFiller]="filler"
[tuiTextfieldSize]="size"
[style.text-align]="textAlign"
>
Expand Down Expand Up @@ -136,7 +137,7 @@
[documentationPropertyDeprecated]="true"
[(documentationPropertyValue)]="prefix"
>
A prefix symbol, like currency Use
A prefix symbol, like currency. Use
<code>tuiTextfieldPrefix</code>
instead
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ <h3>There are also other components to input numbers:</h3>
[tuiTextfieldSize]="size"
[tuiTextfieldPrefix]="prefix"
[tuiTextfieldPostfix]="postfix"
[tuiTextfieldFiller]="filler"
[prefix]="prefix"
[postfix]="postfix"
[min]="min"
Expand Down Expand Up @@ -230,7 +231,7 @@ <h3>There are also other components to input numbers:</h3>
[documentationPropertyValues]="prefixVariants"
[(documentationPropertyValue)]="prefix"
>
A prefix symbol, like currency Use
A prefix symbol, like currency. Use
<code>tuiTextfieldPrefix</code>
instead
</ng-template>
Expand All @@ -243,7 +244,7 @@ <h3>There are also other components to input numbers:</h3>
[documentationPropertyValues]="prefixVariants"
[(documentationPropertyValue)]="postfix"
>
A postfix symbol, like currency Use
A postfix symbol, like currency. Use
<code>tuiTextfieldPostfix</code>
instead
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
[tuiTextfieldCustomContent]="customContent"
[tuiTextfieldLabelOutside]="labelOutside"
[tuiTextfieldSize]="size"
[tuiTextfieldFiller]="filler"
[countryCode]="countryCode"
[phoneMaskAfterCountryCode]="phoneMaskAfterCountryCode"
[pseudoInvalid]="pseudoInvalid"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@
[documentationPropertyDeprecated]="true"
[(documentationPropertyValue)]="prefix"
>
A prefix symbol, like currency
A prefix symbol, like currency. Use
<code>tuiTextfieldPrefix</code>
instead
</ng-template>
<ng-template
i18n
Expand All @@ -244,7 +246,9 @@
[documentationPropertyDeprecated]="true"
[(documentationPropertyValue)]="postfix"
>
A postfix symbol, like currency
A postfix symbol, like currency. Use
<code>tuiTextfieldPostfix</code>
instead
</ng-template>
<ng-template
i18n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
[tuiTextfieldSize]="size"
[tuiTextfieldPrefix]="prefix"
[tuiTextfieldPostfix]="postfix"
[tuiTextfieldFiller]="filler"
[tuiTextfieldCleaner]="cleaner"
[tuiDropdownAlign]="dropdownAlign"
[tuiDropdownDirection]="dropdownDirection"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
[tuiTextfieldCustomContent]="customContent"
[tuiTextfieldLabelOutside]="labelOutside"
[tuiTextfieldSize]="size"
[tuiTextfieldFiller]="filler"
[pseudoActive]="pseudoPressed"
[pseudoFocus]="pseudoFocused"
[pseudoHover]="pseudoHovered"
Expand Down Expand Up @@ -122,9 +123,12 @@
documentationPropertyName="filler"
documentationPropertyMode="input"
documentationPropertyType="string"
[documentationPropertyDeprecated]="true"
[(documentationPropertyValue)]="filler"
>
Gray background text as a hint (e.g. HH:MM:SS for time)
Gray background text as a hint (e.g. HH:MM:SS for time). Use
<code>tuiTextfieldFiller</code>
instead
</ng-template>
<ng-template
i18n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
tuiValueAccessor
class="t-textfield"
[tuiTextfieldIcon]="calendarIcon && iconContent"
[tuiTextfieldFiller]="getComputedRangeFiller(dateFiller || '')"
[pseudoFocus]="innerPseudoFocused"
[pseudoHover]="pseudoHover"
[pseudoActive]="pseudoActive"
[invalid]="computedInvalid"
[nativeId]="nativeId"
[filler]="getComputedRangeFiller(dateFiller || '')"
[readOnly]="readOnly"
[disabled]="computedDisabled"
[textMask]="computedMask"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
tuiValueAccessor
class="t-textfield"
[tuiTextfieldIcon]="calendarIcon && iconContent"
[tuiTextfieldFiller]="(filler$ | async) || ''"
[pseudoFocus]="pseudoFocus"
[pseudoHover]="pseudoHover"
[invalid]="computedInvalid"
[filler]="(filler$ | async) || ''"
[nativeId]="nativeId"
[readOnly]="readOnly"
[disabled]="computedDisabled"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
tuiValueAccessor
class="t-textfield"
[tuiTextfieldIcon]="calendarIcon && iconContent"
[tuiTextfieldFiller]="getComputedFiller(filler || '')"
[pseudoFocus]="pseudoFocus"
[pseudoHover]="pseudoHover"
[invalid]="computedInvalid"
[filler]="getComputedFiller(filler || '')"
[nativeId]="nativeId"
[readOnly]="readOnly"
[focusable]="computedFocusable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class TuiInputSliderComponent
/** @deprecated use `tuiTextfieldPostfix` from {@link TuiTextfieldControllerModule} instead */
@Input(`postfix`)
@tuiDefaultProp()
texfieldPostfix = ``;
textfieldPostfix = ``;

constructor(
@Optional()
Expand All @@ -123,7 +123,7 @@ export class TuiInputSliderComponent
}

get postfix(): string {
return this.texfieldPostfix || this.controller.postfix;
return this.textfieldPostfix || this.controller.postfix;
}

get nativeFocusableElement(): TuiNativeFocusableElement | null {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<tui-primitive-textfield
tuiValueAccessor
class="t-textfield"
[filler]="(getFiller$(mode) | async) || ''"
[tuiTextfieldFiller]="(getFiller$(mode) | async) || ''"
[nativeId]="nativeId"
[pseudoFocus]="innerPseudoFocused"
[pseudoHover]="pseudoHover"
Expand Down

0 comments on commit 94a0fd6

Please sign in to comment.