diff --git a/projects/addon-doc/components/documentation/documentation-property-connector.directive.ts b/projects/addon-doc/components/documentation/documentation-property-connector.directive.ts index 5169f04f6a8f0..f2e45d439b1ef 100644 --- a/projects/addon-doc/components/documentation/documentation-property-connector.directive.ts +++ b/projects/addon-doc/components/documentation/documentation-property-connector.directive.ts @@ -13,6 +13,7 @@ import {ActivatedRoute, Params, UrlSerializer, UrlTree} from '@angular/router'; import {TUI_DOC_URL_STATE_HANDLER} from '@taiga-ui/addon-doc/tokens'; import {tuiCoerceValue} from '@taiga-ui/addon-doc/utils'; import {tuiIsNumber, TuiStringHandler} from '@taiga-ui/cdk'; +import {TuiAlertService} from '@taiga-ui/core'; import {BehaviorSubject, Subject} from 'rxjs'; const SERIALIZED_SUFFIX = '$'; @@ -66,6 +67,7 @@ export class TuiDocDocumentationPropertyConnectorDirective @Inject(UrlSerializer) private readonly urlSerializer: UrlSerializer, @Inject(TUI_DOC_URL_STATE_HANDLER) private readonly urlStateHandler: TuiStringHandler, + @Inject(TuiAlertService) private readonly alerts: TuiAlertService, ) {} ngOnInit(): void { @@ -103,11 +105,29 @@ export class TuiDocDocumentationPropertyConnectorDirective this.setQueryParam(value); } - emitEvent(event: unknown): void { + emitEvent(event: unknown, showAlert = true): void { // For more convenient debugging console.info(this.attrName, event); this.emits$.next(this.emits$.value + 1); + + if (!showAlert) { + return; + } + + let content: string | undefined; + + if (event !== undefined) { + content = String(event); + + if (content === '[object Object]') { + try { + content = JSON.stringify(event); + } catch {} + } + } + + this.alerts.open(content, {label: this.attrName}).subscribe(); } private parseParams(params: Params): void { diff --git a/projects/demo/src/modules/components/abstract/inherited-documentation/inherited-documentation.component.ts b/projects/demo/src/modules/components/abstract/inherited-documentation/inherited-documentation.component.ts index 19b2a3bed1d35..b257a2eeaeb3a 100644 --- a/projects/demo/src/modules/components/abstract/inherited-documentation/inherited-documentation.component.ts +++ b/projects/demo/src/modules/components/abstract/inherited-documentation/inherited-documentation.component.ts @@ -1,5 +1,6 @@ -import {Component, Inject, Input} from '@angular/core'; +import {Component, Inject, Input, ViewChild} from '@angular/core'; import {changeDetection} from '@demo/emulate/change-detection'; +import {TuiDocDocumentationPropertyConnectorDirective} from '@taiga-ui/addon-doc'; import {TUI_HINT_DIRECTIONS} from '@taiga-ui/core'; import {AbstractExampleTuiControl} from '../control'; @@ -14,6 +15,11 @@ import {TuiSupportingDocumentationComponent} from './supporting-documentation-co changeDetection, }) export class InheritedDocumentationComponent { + @ViewChild('documentationPropertyFocusedChange', { + read: TuiDocDocumentationPropertyConnectorDirective, + }) + propertyFocusedChange?: TuiDocDocumentationPropertyConnectorDirective; + @Input() dropdown = false; @@ -51,4 +57,8 @@ export class InheritedDocumentationComponent { ): documentedComponent is AbstractExampleTuiHint { return documentedComponent instanceof AbstractExampleTuiHint; } + + emitFocusedChange(event: boolean): void { + this.propertyFocusedChange?.emitEvent(event, false); + } } diff --git a/projects/demo/src/modules/components/abstract/inherited-documentation/inherited-documentation.template.html b/projects/demo/src/modules/components/abstract/inherited-documentation/inherited-documentation.template.html index 4c9550e515129..e6da4dcb61005 100644 --- a/projects/demo/src/modules/components/abstract/inherited-documentation/inherited-documentation.template.html +++ b/projects/demo/src/modules/components/abstract/inherited-documentation/inherited-documentation.template.html @@ -76,6 +76,7 @@
Visual pressed state @@ -198,7 +200,7 @@ Size - + diff --git a/projects/demo/src/modules/components/calendar-month/calendar-month.component.ts b/projects/demo/src/modules/components/calendar-month/calendar-month.component.ts index 63e1ef3f209e5..3de74e50dd985 100644 --- a/projects/demo/src/modules/components/calendar-month/calendar-month.component.ts +++ b/projects/demo/src/modules/components/calendar-month/calendar-month.component.ts @@ -1,4 +1,4 @@ -import {Component, Inject} from '@angular/core'; +import {Component} from '@angular/core'; import {changeDetection} from '@demo/emulate/change-detection'; import {TuiDocExample} from '@taiga-ui/addon-doc'; import { @@ -11,7 +11,6 @@ import { TuiMonthRange, TuiYear, } from '@taiga-ui/cdk'; -import {TuiAlertService} from '@taiga-ui/core'; @Component({ selector: 'example-tui-calendar-month', @@ -68,13 +67,4 @@ export class ExampleTuiCalendarMonthComponent { ]; year = this.yearVariants[0]; - - constructor( - @Inject(TuiAlertService) - private readonly alerts: TuiAlertService, - ) {} - - onMonthClick(month: TuiMonth): void { - this.alerts.open(String(month)).subscribe(); - } } diff --git a/projects/demo/src/modules/components/calendar-month/calendar-month.template.html b/projects/demo/src/modules/components/calendar-month/calendar-month.template.html index 923a0ee9deab8..795fdd52063eb 100644 --- a/projects/demo/src/modules/components/calendar-month/calendar-month.template.html +++ b/projects/demo/src/modules/components/calendar-month/calendar-month.template.html @@ -39,7 +39,7 @@ [min]="min" [value]="value" [year]="year" - (monthClick)="onMonthClick($event)" + (monthClick)="documentationPropertyMonthClick.emitEvent($event)" > @@ -91,6 +91,7 @@ Current year @@ -204,6 +204,7 @@ Selected day or range One option @@ -66,6 +67,7 @@ [pseudoInvalid]="pseudoInvalid" [readOnly]="readOnly" [size]="currentSize" + (focusedChange)="inherited.emitFocusedChange($event)" > An alternative one @@ -81,6 +83,7 @@ [pseudoInvalid]="pseudoInvalid" [readOnly]="readOnly" [size]="currentSize" + (focusedChange)="inherited.emitFocusedChange($event)" > Other @@ -125,6 +128,7 @@ diff --git a/projects/demo/src/modules/components/checkbox-labeled/checkbox-labeled.template.html b/projects/demo/src/modules/components/checkbox-labeled/checkbox-labeled.template.html index 369bda611afe6..5280f6c3fd1dd 100644 --- a/projects/demo/src/modules/components/checkbox-labeled/checkbox-labeled.template.html +++ b/projects/demo/src/modules/components/checkbox-labeled/checkbox-labeled.template.html @@ -48,6 +48,7 @@ [pseudoInvalid]="pseudoInvalid" [readOnly]="readOnly" [size]="size" + (focusedChange)="inherited.emitFocusedChange($event)" > An option @@ -61,6 +62,7 @@ [pseudoInvalid]="pseudoInvalid" [readOnly]="readOnly" [size]="size" + (focusedChange)="inherited.emitFocusedChange($event)" > An alternative one @@ -74,6 +76,7 @@ [pseudoInvalid]="pseudoInvalid" [readOnly]="readOnly" [size]="size" + (focusedChange)="inherited.emitFocusedChange($event)" > Other @@ -101,6 +104,7 @@ diff --git a/projects/demo/src/modules/components/checkbox/checkbox.template.html b/projects/demo/src/modules/components/checkbox/checkbox.template.html index aa13e3f275f7f..027a8a302942a 100644 --- a/projects/demo/src/modules/components/checkbox/checkbox.template.html +++ b/projects/demo/src/modules/components/checkbox/checkbox.template.html @@ -57,6 +57,7 @@ [pseudoInvalid]="pseudoInvalid" [readOnly]="readOnly" [size]="size" + (focusedChange)="inherited.emitFocusedChange($event)" > @@ -102,6 +105,7 @@ diff --git a/projects/demo/src/modules/components/combo-box/combo-box.template.html b/projects/demo/src/modules/components/combo-box/combo-box.template.html index 77bbb6ef3c6f9..1464b3b007b82 100644 --- a/projects/demo/src/modules/components/combo-box/combo-box.template.html +++ b/projects/demo/src/modules/components/combo-box/combo-box.template.html @@ -131,6 +131,7 @@ [tuiTextfieldSize]="size" [valueContent]="valueContent" [(search)]="search" + (focusedChange)="inherited.emitFocusedChange($event)" (tuiDropdownOpenChange)="dropdownOpen.next($event)" > Choose an account @@ -255,7 +256,10 @@ A template for custom view of selected value - +
    diff --git a/projects/demo/src/modules/components/filter/filter.component.ts b/projects/demo/src/modules/components/filter/filter.component.ts index 2ae3579076f64..b8c5bf620e855 100644 --- a/projects/demo/src/modules/components/filter/filter.component.ts +++ b/projects/demo/src/modules/components/filter/filter.component.ts @@ -1,9 +1,9 @@ -import {Component, Inject} from '@angular/core'; +import {Component} from '@angular/core'; import {FormControl} from '@angular/forms'; import {changeDetection} from '@demo/emulate/change-detection'; import {TuiDocExample} from '@taiga-ui/addon-doc'; import {ALWAYS_FALSE_HANDLER, TuiBooleanHandler, TuiHandler} from '@taiga-ui/cdk'; -import {TuiAlertService, TuiSizeL, TuiSizeXS} from '@taiga-ui/core'; +import {TuiSizeL, TuiSizeXS} from '@taiga-ui/core'; class ItemWithBadge { constructor( @@ -86,13 +86,4 @@ export class ExampleTuiFilterComponent { readonly sizeVariants: ReadonlyArray = ['xs', 's', 'm', 'l']; size = this.sizeVariants[2]; - - constructor( - @Inject(TuiAlertService) - private readonly alerts: TuiAlertService, - ) {} - - onToggledItemChange(item: unknown): void { - this.alerts.open(String(item)).subscribe(); - } } diff --git a/projects/demo/src/modules/components/filter/filter.template.html b/projects/demo/src/modules/components/filter/filter.template.html index cfdc451252980..c846c96c3c101 100644 --- a/projects/demo/src/modules/components/filter/filter.template.html +++ b/projects/demo/src/modules/components/filter/filter.template.html @@ -52,7 +52,7 @@ [formControl]="control" [items]="items" [size]="size" - (toggledItem)="onToggledItemChange($event)" + (toggledItem)="documentationPropertyToggledItem.emitEvent($event)" > @@ -118,6 +118,7 @@ Size @@ -131,6 +132,7 @@ Code length - + diff --git a/projects/demo/src/modules/components/input-card/input-card.component.ts b/projects/demo/src/modules/components/input-card/input-card.component.ts index 057268a02ebf6..365c7531764ae 100644 --- a/projects/demo/src/modules/components/input-card/input-card.component.ts +++ b/projects/demo/src/modules/components/input-card/input-card.component.ts @@ -1,12 +1,16 @@ -import {Component, forwardRef, Inject} from '@angular/core'; +import {Component, forwardRef, ViewChild} from '@angular/core'; import {FormControl, FormGroup, Validators} from '@angular/forms'; import {changeDetection} from '@demo/emulate/change-detection'; import {TuiCodeCVCLength, tuiCreateLuhnValidator} from '@taiga-ui/addon-commerce'; -import {TuiDocExample} from '@taiga-ui/addon-doc'; -import {TuiAlertService, TuiHintOptions} from '@taiga-ui/core'; +import { + TuiDocDocumentationPropertyConnectorDirective, + TuiDocExample, +} from '@taiga-ui/addon-doc'; +import {TuiHintOptions} from '@taiga-ui/core'; import {AbstractExampleTuiControl} from '../abstract/control'; import {ABSTRACT_PROPS_ACCESSOR} from '../abstract/inherited-documentation/abstract-props-accessor'; +import {InheritedDocumentationComponent} from '../abstract/inherited-documentation/inherited-documentation.component'; @Component({ selector: 'example-input-card', @@ -21,6 +25,14 @@ import {ABSTRACT_PROPS_ACCESSOR} from '../abstract/inherited-documentation/abstr ], }) export class ExampleTuiInputCardComponent extends AbstractExampleTuiControl { + @ViewChild('documentationPropertyBinChange', { + read: TuiDocDocumentationPropertyConnectorDirective, + }) + binChangeProperty?: TuiDocDocumentationPropertyConnectorDirective; + + @ViewChild('inheritedDocumentation') + inherited?: InheritedDocumentationComponent; + readonly exampleModule = import('./examples/import/import-module.md?raw'); readonly exampleHtml = import('./examples/import/insert-template.md?raw'); @@ -73,13 +85,6 @@ export class ExampleTuiInputCardComponent extends AbstractExampleTuiControl { cvc: new FormControl('', Validators.required), }); - constructor( - @Inject(TuiAlertService) - private readonly alerts: TuiAlertService, - ) { - super(); - } - get cardSrc(): string | null { return this.cardSrcSelected === null ? null : this.cards[this.cardSrcSelected]; } @@ -121,8 +126,4 @@ export class ExampleTuiInputCardComponent extends AbstractExampleTuiControl { this.control.get(control)!.enable(); } - - onBinChange(bin: string | null): void { - this.alerts.open(`bin: ${bin}`).subscribe(); - } } diff --git a/projects/demo/src/modules/components/input-card/input-card.template.html b/projects/demo/src/modules/components/input-card/input-card.template.html index 3d36c27897f73..6ea83f3c2a017 100644 --- a/projects/demo/src/modules/components/input-card/input-card.template.html +++ b/projects/demo/src/modules/components/input-card/input-card.template.html @@ -47,7 +47,8 @@ [tuiTextfieldCleaner]="cleaner" [tuiTextfieldLabelOutside]="labelOutside" [tuiTextfieldSize]="size" - (binChange)="onBinChange($event)" + (binChange)="binChangeProperty?.emitEvent($event)" + (focusedChange)="inherited?.emitFocusedChange($event)" > Card number @@ -63,6 +64,7 @@ [readOnly]="readOnly" [tuiTextfieldLabelOutside]="labelOutside" [tuiTextfieldSize]="size" + (focusedChange)="inherited?.emitFocusedChange($event)" > Expire date @@ -82,6 +84,7 @@ [tuiHintDirection]="hintDirectionCVC" [tuiTextfieldLabelOutside]="labelOutside" [tuiTextfieldSize]="size" + (focusedChange)="inherited?.emitFocusedChange($event)" > CVC/CVV @@ -135,6 +138,7 @@ SVG card icon - + diff --git a/projects/demo/src/modules/components/input-copy/input-copy.template.html b/projects/demo/src/modules/components/input-copy/input-copy.template.html index 9a7614f92b166..72b219d654af3 100644 --- a/projects/demo/src/modules/components/input-copy/input-copy.template.html +++ b/projects/demo/src/modules/components/input-copy/input-copy.template.html @@ -41,6 +41,7 @@ [tuiTextfieldIconLeft]="iconLeft" [tuiTextfieldLabelOutside]="labelOutside" [tuiTextfieldSize]="size" + (focusedChange)="inherited.emitFocusedChange($event)" > Type a text @@ -83,7 +84,7 @@ Message tooltip mode - + Number of accounts @@ -169,7 +170,7 @@ Step for buttons - + Choose a date @@ -111,7 +112,10 @@ mode - + diff --git a/projects/demo/src/modules/components/input-date-range/input-date-range.template.html b/projects/demo/src/modules/components/input-date-range/input-date-range.template.html index 2ce353f6786b7..b9b7afe9c75b3 100644 --- a/projects/demo/src/modules/components/input-date-range/input-date-range.template.html +++ b/projects/demo/src/modules/components/input-date-range/input-date-range.template.html @@ -152,6 +152,7 @@

    DI-tokens for input-configurations:

    [tuiTextfieldIconLeft]="iconLeft" [tuiTextfieldLabelOutside]="labelOutside" [tuiTextfieldSize]="size" + (focusedChange)="inherited.emitFocusedChange($event)" > Choose dates @@ -242,7 +243,7 @@

    DI-tokens for input-configurations:

    Maximal length of range
    - + DI-tokens for input-configurations:
[tuiTextfieldIconLeft]="iconLeft" [tuiTextfieldLabelOutside]="labelOutside" [tuiTextfieldSize]="size" + (focusedChange)="inherited.emitFocusedChange($event)" (tuiDropdownOpenChange)="dropdownOpen.next($event)" > Choose date and time @@ -196,7 +197,10 @@

DI-tokens for input-configurations:

Time modes for SS and MS support - + DI-tokens for input-configurations: [tuiTextfieldIconLeft]="iconLeft" [tuiTextfieldLabelOutside]="labelOutside" [tuiTextfieldSize]="size" + (focusedChange)="inherited.emitFocusedChange($event)" (tuiDropdownOpenChange)="dropdownOpen.next($event)" > Choose a date @@ -210,7 +211,10 @@

DI-tokens for input-configurations:

Maximum date
- + @@ -161,6 +161,7 @@ Max file size in bytes (30 MB by default — 30 * 1000 * 1000) Months @@ -105,7 +106,7 @@ Maximum date - + Month @@ -102,7 +103,7 @@ Maximum date - + There are also other components to input numbers: [tuiTextfieldPostfix]="postfix" [tuiTextfieldPrefix]="prefix" [tuiTextfieldSize]="size" + (focusedChange)="inherited.emitFocusedChange($event)" > Type a sum @@ -262,7 +263,7 @@

There are also other components to input numbers:

Step to increase/decrease value with keyboard and buttons on the side
- + Type a password @@ -61,7 +62,7 @@ ) - + Type a phone number @@ -89,7 +90,7 @@ ISO-code of selected country - + diff --git a/projects/demo/src/modules/components/input-phone/input-phone.template.html b/projects/demo/src/modules/components/input-phone/input-phone.template.html index f019c99859cf9..a1b2e14849628 100644 --- a/projects/demo/src/modules/components/input-phone/input-phone.template.html +++ b/projects/demo/src/modules/components/input-phone/input-phone.template.html @@ -73,6 +73,7 @@ [tuiTextfieldPostfix]="postfix" [tuiTextfieldPrefix]="prefix" [tuiTextfieldSize]="size" + (focusedChange)="inherited.emitFocusedChange($event)" (tuiDropdownOpenChange)="dropdownOpen.next($event)" > Type a phone number @@ -119,7 +120,10 @@ Textfield value to subscribe on input or setting it from the outside - + Range @@ -232,7 +233,7 @@ instead - + diff --git a/projects/demo/src/modules/components/input-tag/input-tag.template.html b/projects/demo/src/modules/components/input-tag/input-tag.template.html index 5643f29da98cf..895c09eab14ab 100644 --- a/projects/demo/src/modules/components/input-tag/input-tag.template.html +++ b/projects/demo/src/modules/components/input-tag/input-tag.template.html @@ -132,6 +132,7 @@ [tuiTextfieldSize]="size" [uniqueTags]="uniqueTags" [(search)]="search" + (focusedChange)="inherited.emitFocusedChange($event)" (tuiDropdownOpenChange)="dropdownOpen.next($event)" > Please enter Pythons' names @@ -259,7 +260,10 @@ - + Input time @@ -154,7 +155,7 @@ Modes for seconds and ms support - + Year @@ -97,7 +98,7 @@ Maximum year - + Label @@ -295,7 +296,10 @@ to set it) - + Lorem ipsum @@ -91,6 +92,7 @@ Number of visible lines @@ -119,6 +121,7 @@ Single date or a range Choose an account @@ -283,7 +284,10 @@ Placeholder - + diff --git a/projects/demo/src/modules/components/primitive-textfield/primitive-textfield.template.html b/projects/demo/src/modules/components/primitive-textfield/primitive-textfield.template.html index 85060cae8d7d9..7e73441cc1b61 100644 --- a/projects/demo/src/modules/components/primitive-textfield/primitive-textfield.template.html +++ b/projects/demo/src/modules/components/primitive-textfield/primitive-textfield.template.html @@ -75,6 +75,7 @@ [tuiTextfieldPrefix]="prefix" [tuiTextfieldSize]="size" [(value)]="value" + (focusedChange)="inherited.emitFocusedChange($event)" > Component label @@ -203,7 +204,7 @@ - + Oranges @@ -76,6 +77,7 @@ [pseudoInvalid]="pseudoInvalid" [readOnly]="readOnly" [size]="currentSize" + (focusedChange)="inherited.emitFocusedChange($event)" > Apples @@ -92,6 +94,7 @@ [pseudoInvalid]="pseudoInvalid" [readOnly]="readOnly" [size]="currentSize" + (focusedChange)="inherited.emitFocusedChange($event)" > Pinapples @@ -155,6 +158,7 @@ diff --git a/projects/demo/src/modules/components/radio-labeled/radio-labeled.template.html b/projects/demo/src/modules/components/radio-labeled/radio-labeled.template.html index 01395ead65c0b..5061d8c9781dc 100644 --- a/projects/demo/src/modules/components/radio-labeled/radio-labeled.template.html +++ b/projects/demo/src/modules/components/radio-labeled/radio-labeled.template.html @@ -56,6 +56,7 @@ [pseudoInvalid]="pseudoInvalid" [readOnly]="readOnly" [size]="size" + (focusedChange)="inherited.emitFocusedChange($event)" > One @@ -71,6 +72,7 @@ [pseudoInvalid]="pseudoInvalid" [readOnly]="readOnly" [size]="size" + (focusedChange)="inherited.emitFocusedChange($event)" > Two @@ -86,6 +88,7 @@ [pseudoInvalid]="pseudoInvalid" [readOnly]="readOnly" [size]="size" + (focusedChange)="inherited.emitFocusedChange($event)" > Three @@ -131,6 +134,7 @@ diff --git a/projects/demo/src/modules/components/radio-list/radio-list.template.html b/projects/demo/src/modules/components/radio-list/radio-list.template.html index 79817c4cbc867..691ffa2866310 100644 --- a/projects/demo/src/modules/components/radio-list/radio-list.template.html +++ b/projects/demo/src/modules/components/radio-list/radio-list.template.html @@ -42,6 +42,7 @@ [pseudoInvalid]="pseudoInvalid" [readOnly]="readOnly" [size]="size" + (focusedChange)="inherited.emitFocusedChange($event)" > @@ -93,6 +94,7 @@ diff --git a/projects/demo/src/modules/components/radio/radio.template.html b/projects/demo/src/modules/components/radio/radio.template.html index f71df20580a9a..745236cab0c02 100644 --- a/projects/demo/src/modules/components/radio/radio.template.html +++ b/projects/demo/src/modules/components/radio/radio.template.html @@ -55,6 +55,7 @@ [pseudoInvalid]="pseudoInvalid" [readOnly]="readOnly" [size]="size" + (focusedChange)="inherited.emitFocusedChange($event)" > @@ -136,6 +139,7 @@ diff --git a/projects/demo/src/modules/components/select/select.template.html b/projects/demo/src/modules/components/select/select.template.html index d1311379d8382..8f9fea13fc350 100644 --- a/projects/demo/src/modules/components/select/select.template.html +++ b/projects/demo/src/modules/components/select/select.template.html @@ -158,6 +158,7 @@ [tuiTextfieldLabelOutside]="labelOutside" [tuiTextfieldSize]="size" [valueContent]="valueContent" + (focusedChange)="inherited.emitFocusedChange($event)" (tuiDropdownOpenChange)="dropdownOpen.next($event)" > Choose an account @@ -229,7 +230,10 @@ A template for custom view of selected value - + diff --git a/projects/demo/src/modules/components/tag/tag.template.html b/projects/demo/src/modules/components/tag/tag.template.html index 0da0f2340cbcb..8a8f961b894f6 100644 --- a/projects/demo/src/modules/components/tag/tag.template.html +++ b/projects/demo/src/modules/components/tag/tag.template.html @@ -77,7 +77,7 @@ [size]="size" [status]="status" [value]="value" - (edited)="editTag($event)" + (edited)="editTag($event); documentationPropertyModeEdited.emitEvent($event)" > Textfield for multiline input. It can grow with its content.