diff --git a/package-lock.json b/package-lock.json index c81abf023b62..72ddf4bb83ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,7 +34,7 @@ "@taiga-ui/event-plugins": "4.0.1", "@taiga-ui/prettier-config": "0.113.3", "@taiga-ui/stylelint-config": "0.147.0", - "@taiga-ui/tsconfig": "0.113.3", + "@taiga-ui/tsconfig": "0.147.10", "@types/glob": "8.1.0", "@types/loader-utils": "2.0.6", "@types/node": "22.5.1", @@ -9765,9 +9765,9 @@ "link": true }, "node_modules/@taiga-ui/tsconfig": { - "version": "0.113.3", - "resolved": "https://registry.npmjs.org/@taiga-ui/tsconfig/-/tsconfig-0.113.3.tgz", - "integrity": "sha512-XYQ5VU3Dt4crnI7OZ/BwwMVl7S6c3YUt2+vDWkWv/VLc2yoUu85lEnsl3J5mqasnamENUiSbXWSGxh3h0m2WEA==", + "version": "0.147.10", + "resolved": "https://registry.npmjs.org/@taiga-ui/tsconfig/-/tsconfig-0.147.10.tgz", + "integrity": "sha512-LaNRtPZIwUEPifUwVa4D6H52KJgbEzcb8CeKXvz2hh69ng1GsgrMSQkGm+GtKfuQmlONR8N62R0sIKx0J+jtKQ==", "dev": true, "license": "Apache-2.0" }, diff --git a/package.json b/package.json index d3c2e3bfd7e2..eb8a79284e8e 100644 --- a/package.json +++ b/package.json @@ -130,7 +130,7 @@ "@taiga-ui/event-plugins": "4.0.1", "@taiga-ui/prettier-config": "0.113.3", "@taiga-ui/stylelint-config": "0.147.0", - "@taiga-ui/tsconfig": "0.113.3", + "@taiga-ui/tsconfig": "0.147.10", "@types/glob": "8.1.0", "@types/loader-utils": "2.0.6", "@types/node": "22.5.1", diff --git a/projects/addon-charts/components/line-chart/line-chart.component.ts b/projects/addon-charts/components/line-chart/line-chart.component.ts index ace10d3b05f4..a642df97f669 100644 --- a/projects/addon-charts/components/line-chart/line-chart.component.ts +++ b/projects/addon-charts/components/line-chart/line-chart.component.ts @@ -48,9 +48,7 @@ export class TuiLineChart { private readonly hover$ = new Subject(); private readonly autoId = tuiInjectId(); - protected readonly hintDirective = inject(TuiLineChartHint, { - optional: true, - }); + protected readonly hintDirective = inject(TuiLineChartHint, {optional: true}); protected readonly hintOptions = inject(TuiHintOptionsDirective, {optional: true}); @@ -165,8 +163,10 @@ export class TuiLineChart { protected getImplicit($implicit: TuiPoint): TuiPoint | readonly TuiPoint[] { return ( - this.hintDirective?.getContext(this.value.indexOf($implicit), this) || - $implicit + (this.hintDirective?.getContext( + this.value.indexOf($implicit), + this, + ) as readonly TuiPoint[]) ?? $implicit ); } diff --git a/projects/addon-charts/components/line-days-chart/line-days-chart.component.ts b/projects/addon-charts/components/line-days-chart/line-days-chart.component.ts index 688f11bc0206..ae28ee086ee2 100644 --- a/projects/addon-charts/components/line-days-chart/line-days-chart.component.ts +++ b/projects/addon-charts/components/line-days-chart/line-days-chart.component.ts @@ -1,5 +1,5 @@ import {NgForOf} from '@angular/common'; -import type {AfterViewInit, QueryList} from '@angular/core'; +import {type AfterViewInit, type QueryList} from '@angular/core'; import { ChangeDetectionStrategy, Component, @@ -113,6 +113,12 @@ export class TuiLineDaysChart implements AfterViewInit { }); } + public get hint(): + | PolymorpheusContent> + | PolymorpheusContent> { + return this.hintDirective?.hint ?? this.hintContent; + } + public ngAfterViewInit(): void { combineLatest([tuiLineChartDrivers(this.charts), this.hovered$]) .pipe( @@ -146,6 +152,30 @@ export class TuiLineDaysChart implements AfterViewInit { }); } + public raise(index: number, {value}: TuiLineChart): void { + const x = value[index]?.[0] || 0; + const month = this.getDay(x); + + if (!month) { + return; + } + + if (this.hintDirective) { + this.hintDirective.raise(month); + } else { + this.onHovered(month); + } + } + + public getContext(index: number, {value}: TuiLineChart): unknown { + const x = value[index]?.[0] || 0; + const day = this.getDay(x); + + return this.hintDirective && day + ? this.hintDirective.getContext(day) + : this.getHintContext(x, this.value); + } + protected get months(): ReadonlyArray { return this.value.length ? this.breakMonths(this.value) : EMPTY_ARRAY; } @@ -154,18 +184,12 @@ export class TuiLineDaysChart implements AfterViewInit { return this.months.length * (this.value[0]?.[0].daysCount || 0); } - protected get hint(): - | PolymorpheusContent> - | PolymorpheusContent> { - return this.hintDirective?.hint ?? this.hintContent; - } - @tuiPure protected getHintContext( x: number, value: ReadonlyArray<[TuiDay, number]>, - ): [TuiDay, number] { - return value[x - (value[0]?.[0]?.day || 0) + 1]; + ): [TuiDay, number] | null { + return value[x - (value[0]?.[0]?.day || 0) + 1] ?? null; } protected readonly daysStringify: TuiStringHandler = (index) => { @@ -183,34 +207,10 @@ export class TuiLineDaysChart implements AfterViewInit { return index - offset; } - protected raise(index: number, {value}: TuiLineChart): void { - const x = value[index]?.[0] || 0; - const month = this.getDay(x); - - if (!month) { - return; - } - - if (this.hintDirective) { - this.hintDirective.raise(month); - } else { - this.onHovered(month); - } - } - protected getWidth(index: number): number { return (this.getDay(index)?.daysCount || 0) * this.months.length; } - protected getContext(index: number, {value}: TuiLineChart): unknown { - const x = value[index]?.[0] || 0; - const day = this.getDay(x); - - return this.hintDirective && day - ? this.hintDirective.getContext(day) - : this.getHintContext(x, this.value); - } - @tuiPure private breakMonths( value: ReadonlyArray<[TuiDay, number]>, diff --git a/projects/addon-charts/components/line-days-chart/line-days-chart.template.html b/projects/addon-charts/components/line-days-chart/line-days-chart.template.html index 0d981259f6dc..0010f61862dc 100644 --- a/projects/addon-charts/components/line-days-chart/line-days-chart.template.html +++ b/projects/addon-charts/components/line-days-chart/line-days-chart.template.html @@ -7,8 +7,8 @@ [style.zIndex]="zIndex" [tuiHintContent]="hintContent ? hint : ''" [value]="month" - [width]="first ? firstWidth : getWidth(month[0][0])" - [x]="first ? 0 : getX(month[0][0])" + [width]="first ? firstWidth : getWidth(month[0]?.[0] ?? 0)" + [x]="first ? 0 : getX(month[0]?.[0] ?? 0)" [xStringify]="xStringify ? daysStringify : null" [y]="y" [yStringify]="yStringify" diff --git a/projects/addon-charts/components/pie-chart/pie-chart.template.html b/projects/addon-charts/components/pie-chart/pie-chart.template.html index be29eecbd2d3..9e4c9c6682ab 100644 --- a/projects/addon-charts/components/pie-chart/pie-chart.template.html +++ b/projects/addon-charts/components/pie-chart/pie-chart.template.html @@ -40,7 +40,7 @@ [style.color]="'var(--tui-chart-categorical-0' + index + ')'" [tuiHint]="hintContent" [tuiHintContext]="{$implicit: index}" - [tuiPieChart]="segments[index]" + [tuiPieChart]="segments[index] || [0, 0]" (tuiHoveredChange)="onHovered($event, index)" /> diff --git a/projects/cdk/directives/repeat-times/test/repeat-times.directive.spec.ts b/projects/cdk/directives/repeat-times/test/repeat-times.directive.spec.ts index a833f8f8d97d..b60a6b7d5582 100644 --- a/projects/cdk/directives/repeat-times/test/repeat-times.directive.spec.ts +++ b/projects/cdk/directives/repeat-times/test/repeat-times.directive.spec.ts @@ -82,9 +82,9 @@ describe('TuiRepeatTimes directive', () => { }); it('passes index as implicit context', () => { - expect(debugElements[0].nativeElement.title).toBe('0'); - expect(debugElements[1].nativeElement.title).toBe('1'); - expect(debugElements[2].nativeElement.title).toBe('2'); + expect(debugElements[0]?.nativeElement.title).toBe('0'); + expect(debugElements[1]?.nativeElement.title).toBe('1'); + expect(debugElements[2]?.nativeElement.title).toBe('2'); }); }); }); diff --git a/projects/cdk/utils/dom/test/get-element-obscurers.spec.ts b/projects/cdk/utils/dom/test/get-element-obscurers.spec.ts index 5d2f4d3490e3..cfc096149674 100644 --- a/projects/cdk/utils/dom/test/get-element-obscurers.spec.ts +++ b/projects/cdk/utils/dom/test/get-element-obscurers.spec.ts @@ -105,9 +105,9 @@ describe('tuiGetElementObscures', () => { const mockElementFromPoint = jest.mocked(ownerDocument.elementFromPoint); mockElementFromPoint - .mockReturnValueOnce(others[0]) - .mockReturnValueOnce(others[1]) - .mockReturnValueOnce(others[2]) + .mockReturnValueOnce(others[0]!) + .mockReturnValueOnce(others[1]!) + .mockReturnValueOnce(others[2]!) .mockReturnValueOnce(element); expect(tuiGetElementObscures(element)).toBeNull(); diff --git a/projects/core/components/calendar/test/calendar-sheet.component.spec.ts b/projects/core/components/calendar/test/calendar-sheet.component.spec.ts index 7d7faeaf2948..94b8a57c4d0a 100644 --- a/projects/core/components/calendar/test/calendar-sheet.component.spec.ts +++ b/projects/core/components/calendar/test/calendar-sheet.component.spec.ts @@ -103,12 +103,12 @@ describe('CalendarSheet', () => { it('blocked date under condition', () => { expect(getDisabledCalendarItems().length).toBe(1); expect( - getDisabledCalendarItems()[0].nativeElement.textContent.trim(), + getDisabledCalendarItems()[0]?.nativeElement.textContent.trim(), ).toBe('20'); }); it('click on blocked date does not change value', () => { - getDisabledCalendarItems()[0].nativeElement.click(); + getDisabledCalendarItems()[0]?.nativeElement.click(); fixture.detectChanges(); expect(testComponent.value).toBeNull(); diff --git a/projects/demo-playwright/tests/deep/deep-select.spec.ts b/projects/demo-playwright/tests/deep/deep-select.spec.ts index 84b7e8c0d21e..7be8bdf53b2e 100644 --- a/projects/demo-playwright/tests/deep/deep-select.spec.ts +++ b/projects/demo-playwright/tests/deep/deep-select.spec.ts @@ -57,7 +57,7 @@ test.describe('Deep / Select', () => { if (cleaner) { await cleaner.click(); } else { - await options[0].focus(); + await options[0]?.focus(); await page.keyboard.down('Enter'); } diff --git a/projects/demo-playwright/tests/kit/slider/slider.spec.ts b/projects/demo-playwright/tests/kit/slider/slider.spec.ts index f1f876dae8cf..bc15472cbd8c 100644 --- a/projects/demo-playwright/tests/kit/slider/slider.spec.ts +++ b/projects/demo-playwright/tests/kit/slider/slider.spec.ts @@ -162,7 +162,7 @@ test.describe('Slider', () => { }); test('=> 0', async () => { - await tickLabels[0].click(); + await tickLabels[0]?.click(); await expect(async () => { expect(await slider.value).toBe(0); @@ -173,7 +173,7 @@ test.describe('Slider', () => { }); test('=> 500', async () => { - await tickLabels[2].click(); + await tickLabels[2]?.click(); await expect(async () => { expect(await slider.value).toBe(500); @@ -184,7 +184,7 @@ test.describe('Slider', () => { }); test('=> 750', async () => { - await tickLabels[3].click(); + await tickLabels[3]?.click(); await expect(async () => { expect(await slider.value).toBe(750); @@ -195,7 +195,7 @@ test.describe('Slider', () => { }); test('=> 1000', async () => { - await tickLabels.at(-1)!.click(); + await tickLabels.at(-1)?.click(); await expect(async () => { expect(await slider.value).toBe(1000); diff --git a/projects/demo-playwright/utils/page-objects/calendar-range.po.ts b/projects/demo-playwright/utils/page-objects/calendar-range.po.ts index 2880d0e8642d..ed0fbe636942 100644 --- a/projects/demo-playwright/utils/page-objects/calendar-range.po.ts +++ b/projects/demo-playwright/utils/page-objects/calendar-range.po.ts @@ -14,14 +14,14 @@ export class TuiCalendarRangePO { public async selectItem(index: number): Promise { const items = await this.getItems(); - await items[index].click(); + await items[index]?.click(); } public async itemHasCheckmark(index: number): Promise { const items = await this.getItems(); const itemCheckmark = await items[index] - .locator('[automation-id="tui-calendar-range__checkmark"]') + ?.locator('[automation-id="tui-calendar-range__checkmark"]') .count(); return !!itemCheckmark; diff --git a/projects/demo-playwright/utils/page-objects/input-date-range.po.ts b/projects/demo-playwright/utils/page-objects/input-date-range.po.ts index bb724c0aceee..3ec9104de43e 100644 --- a/projects/demo-playwright/utils/page-objects/input-date-range.po.ts +++ b/projects/demo-playwright/utils/page-objects/input-date-range.po.ts @@ -26,14 +26,14 @@ export class TuiInputDateRangePO { public async selectItem(index: number): Promise { const items = await this.getItems(); - await items[index].click(); + await items[index]?.click(); } public async itemHasCheckmark(index: number): Promise { const items = await this.getItems(); const itemCheckmark = await items[index] - .locator('[automation-id="tui-calendar-range__checkmark"]') + ?.locator('[automation-id="tui-calendar-range__checkmark"]') .count(); return !!itemCheckmark; diff --git a/projects/demo-playwright/utils/page-objects/textfield-with-data-list.po.ts b/projects/demo-playwright/utils/page-objects/textfield-with-data-list.po.ts index 031fd1ebb81e..c91b61085168 100644 --- a/projects/demo-playwright/utils/page-objects/textfield-with-data-list.po.ts +++ b/projects/demo-playwright/utils/page-objects/textfield-with-data-list.po.ts @@ -17,7 +17,7 @@ export class TuiTextfieldWithDataListPO { const options = await this.getOptions(); for (const optionIndex of indexes) { - await options[optionIndex].click(); + await options[optionIndex]?.click(); } } diff --git a/projects/demo/src/modules/app/app.config.ts b/projects/demo/src/modules/app/app.config.ts index 32b22763230a..c654cbcf1966 100644 --- a/projects/demo/src/modules/app/app.config.ts +++ b/projects/demo/src/modules/app/app.config.ts @@ -104,7 +104,7 @@ export const config: ApplicationConfig = { } return `${link}/${pkg.toLowerCase()}/${type.toLowerCase()}/${( - header[0].toLowerCase() + header.slice(1) + (header[0]?.toLowerCase() ?? '') + header.slice(1) ).replaceAll(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)}`; }, }, diff --git a/projects/demo/src/modules/app/landing/index.html b/projects/demo/src/modules/app/landing/index.html index d8f00a257cad..c4e26437b90b 100644 --- a/projects/demo/src/modules/app/landing/index.html +++ b/projects/demo/src/modules/app/landing/index.html @@ -21,7 +21,7 @@