diff --git a/projects/addon-doc/components/page/page.component.ts b/projects/addon-doc/components/page/page.component.ts index 0a97c7a148fb..2f9e3bd9f970 100644 --- a/projects/addon-doc/components/page/page.component.ts +++ b/projects/addon-doc/components/page/page.component.ts @@ -1,4 +1,4 @@ -import {NgForOf, NgIf, NgTemplateOutlet} from '@angular/common'; +import {KeyValuePipe, NgForOf, NgIf, NgTemplateOutlet} from '@angular/common'; import type {QueryList} from '@angular/core'; import { ChangeDetectionStrategy, @@ -7,27 +7,30 @@ import { inject, Input, } from '@angular/core'; -import {RouterLink, RouterLinkActive} from '@angular/router'; +import {ActivatedRoute, RouterLink, RouterLinkActive} from '@angular/router'; import {TUI_DOC_DEFAULT_TABS, TUI_DOC_SUPPORT_LANGUAGE} from '@taiga-ui/addon-doc/tokens'; import {EMPTY_QUERY} from '@taiga-ui/cdk/constants'; import {TuiReplacePipe} from '@taiga-ui/cdk/pipes/replace'; import {TuiAutoColorPipe} from '@taiga-ui/core/pipes/auto-color'; import {TuiChip} from '@taiga-ui/kit/components/chip'; import {TuiTabs} from '@taiga-ui/kit/components/tabs'; +import {PolymorpheusOutlet} from '@taiga-ui/polymorpheus'; import {TuiDocSeeAlso} from '../internal/see-also'; import {TuiDocSourceCode} from '../internal/source-code/source-code.component'; import {TuiDocLanguageSwitcher} from '../language-switcher'; -import {PAGE_PROVIDERS, PAGE_SEE_ALSO} from './page.providers'; +import {PAGE_PROVIDERS, PAGE_SEE_ALSO, TUI_DOC_TABS} from './page.providers'; import {TuiDocPageTabConnector} from './page-tab.directive'; @Component({ standalone: true, selector: 'tui-doc-page', imports: [ + KeyValuePipe, NgForOf, NgIf, NgTemplateOutlet, + PolymorpheusOutlet, RouterLink, RouterLinkActive, TuiAutoColorPipe, @@ -44,6 +47,7 @@ import {TuiDocPageTabConnector} from './page-tab.directive'; providers: PAGE_PROVIDERS, }) export class TuiDocPage { + protected readonly tabs = inject(TUI_DOC_TABS)(inject(ActivatedRoute).snapshot); protected readonly supportLanguage = inject(TUI_DOC_SUPPORT_LANGUAGE); protected readonly defaultTabs = inject(TUI_DOC_DEFAULT_TABS); protected readonly from = / /g; diff --git a/projects/addon-doc/components/page/page.providers.ts b/projects/addon-doc/components/page/page.providers.ts index 7bfcdbecc72a..1f12c9de6c06 100644 --- a/projects/addon-doc/components/page/page.providers.ts +++ b/projects/addon-doc/components/page/page.providers.ts @@ -1,7 +1,14 @@ import type {Provider} from '@angular/core'; import {ElementRef} from '@angular/core'; +import type {ActivatedRouteSnapshot} from '@angular/router'; import {TUI_DOC_SEE_ALSO} from '@taiga-ui/addon-doc/tokens'; +import type {TuiHandler} from '@taiga-ui/cdk/types'; import {tuiCreateToken} from '@taiga-ui/cdk/utils/miscellaneous'; +import type {PolymorpheusContent} from '@taiga-ui/polymorpheus'; + +export const TUI_DOC_TABS = tuiCreateToken< + TuiHandler> +>(() => ({})); /** * Array if related page titles diff --git a/projects/addon-doc/components/page/page.template.html b/projects/addon-doc/components/page/page.template.html index f95c94cd9506..d928ca51e764 100644 --- a/projects/addon-doc/components/page/page.template.html +++ b/projects/addon-doc/components/page/page.template.html @@ -46,6 +46,16 @@

+ + + {{ tab.key }} + +
[ngTemplateOutlet]="tab.template" /> + + + {{ text }} + +
diff --git a/projects/addon-doc/components/page/tests/page.component.spec.ts b/projects/addon-doc/components/page/tests/page.component.spec.ts index cf34cbf4c088..86cb80d20204 100644 --- a/projects/addon-doc/components/page/tests/page.component.spec.ts +++ b/projects/addon-doc/components/page/tests/page.component.spec.ts @@ -1,5 +1,6 @@ import type {ComponentFixture} from '@angular/core/testing'; import {TestBed} from '@angular/core/testing'; +import {ActivatedRoute} from '@angular/router'; import {PAGE_SEE_ALSO, TuiDocPage} from '@taiga-ui/addon-doc'; import {TUI_DOC_DEFAULT_TABS} from '@taiga-ui/addon-doc/tokens'; import {EMPTY_QUERY} from '@taiga-ui/cdk'; @@ -12,6 +13,10 @@ describe('TuiDocPageComponent', () => { await TestBed.configureTestingModule({ imports: [TuiDocPage], providers: [ + { + provide: ActivatedRoute, + useValue: {}, + }, { provide: TUI_DOC_DEFAULT_TABS, useValue: ['tab1', 'tab2'], diff --git a/projects/demo-cypress/src/tests/textfield.cy.ts b/projects/demo-cypress/src/tests/textfield.cy.ts index e92297471361..9376617dddee 100644 --- a/projects/demo-cypress/src/tests/textfield.cy.ts +++ b/projects/demo-cypress/src/tests/textfield.cy.ts @@ -42,7 +42,7 @@ describe('Textfield', () => { cy.get('input[tuiTextfield]').focus(); cy.get('tui-textfield').compareSnapshot( - `[filler]-initial-value_${initialValue}`, + `[filler]-initial-value_${initialValue.replaceAll(':', '-')}`, ); }); }); @@ -64,7 +64,7 @@ describe('Textfield', () => { cy.get('input[tuiTextfield]').type(value); cy.get('tui-textfield').compareSnapshot( - `[filler]-user-types_${value}`, + `[filler]-user-types_${value.replaceAll(':', '-')}`, ); }); });