From 93d6ae72258f91f08ef9d95254520d0890819b0d Mon Sep 17 00:00:00 2001 From: splincode Date: Fri, 11 Oct 2024 12:36:11 +0300 Subject: [PATCH] refactor: improve a11y --- package.json | 3 +- .../textfield/textfield.component.ts | 4 ++- .../textfield/textfield.template.html | 4 ++- projects/core/tokens/i18n.ts | 5 +++ .../components/app-bar/examples/1/index.html | 2 ++ .../components/app-bar/examples/3/index.html | 2 ++ .../components/carousel/examples/4/index.html | 8 +++-- .../data-list/examples/2/index.html | 4 ++- .../data-list/examples/3/index.html | 8 +++-- .../input-slider/examples/2/index.html | 8 +++-- .../mobile-calendar/examples/4/index.html | 4 ++- .../mobile-calendar/examples/5/index.html | 4 ++- .../primitive-textfield/examples/1/index.html | 4 ++- .../components/slider/examples/6/index.html | 8 +++-- .../swipe-action/examples/1/index.html | 32 ++++++++++++++----- .../swipe-action/examples/2/index.html | 4 ++- .../swipe-action/examples/3/index.html | 24 ++++++++++---- .../swipe-action/examples/4/index.html | 8 +++-- .../swipe-action/examples/5/index.html | 12 +++++-- .../components/tag/examples/3/index.html | 4 ++- .../components/tag/examples/6/index.html | 8 +++-- .../dropdown-hover/examples/2/index.html | 1 + .../dropdown-open/examples/4/index.html | 4 ++- projects/i18n/languages/belarusian/core.ts | 1 + projects/i18n/languages/belarusian/kit.ts | 3 ++ projects/i18n/languages/chinese/core.ts | 1 + projects/i18n/languages/chinese/kit.ts | 3 ++ projects/i18n/languages/dutch/core.ts | 1 + projects/i18n/languages/dutch/kit.ts | 3 ++ projects/i18n/languages/english/core.ts | 1 + projects/i18n/languages/english/kit.ts | 3 ++ projects/i18n/languages/french/core.ts | 1 + projects/i18n/languages/french/kit.ts | 3 ++ projects/i18n/languages/german/core.ts | 1 + projects/i18n/languages/german/kit.ts | 3 ++ projects/i18n/languages/hebrew/core.ts | 1 + projects/i18n/languages/hebrew/kit.ts | 3 ++ projects/i18n/languages/italian/core.ts | 1 + projects/i18n/languages/italian/kit.ts | 3 ++ projects/i18n/languages/japan/core.ts | 1 + projects/i18n/languages/japan/kit.ts | 3 ++ projects/i18n/languages/kazakh/core.ts | 1 + projects/i18n/languages/kazakh/kit.ts | 3 ++ projects/i18n/languages/korean/core.ts | 1 + projects/i18n/languages/korean/kit.ts | 3 ++ projects/i18n/languages/lithuanian/core.ts | 1 + projects/i18n/languages/lithuanian/kit.ts | 3 ++ projects/i18n/languages/malay/core.ts | 1 + projects/i18n/languages/malay/kit.ts | 3 ++ projects/i18n/languages/polish/core.ts | 1 + projects/i18n/languages/polish/kit.ts | 3 ++ projects/i18n/languages/portuguese/core.ts | 1 + projects/i18n/languages/portuguese/kit.ts | 3 ++ projects/i18n/languages/russian/core.ts | 1 + projects/i18n/languages/russian/kit.ts | 3 ++ projects/i18n/languages/spanish/core.ts | 1 + projects/i18n/languages/spanish/kit.ts | 3 ++ projects/i18n/languages/turkish/core.ts | 1 + projects/i18n/languages/turkish/kit.ts | 3 ++ projects/i18n/languages/ukrainian/core.ts | 1 + projects/i18n/languages/ukrainian/kit.ts | 3 ++ projects/i18n/languages/vietnamese/core.ts | 1 + projects/i18n/languages/vietnamese/kit.ts | 3 ++ projects/i18n/types/language.ts | 4 +++ .../pagination/pagination.component.ts | 4 ++- .../pagination/pagination.template.html | 1 + .../tree-item-content.component.ts | 2 ++ .../tree-item-content.template.html | 4 ++- projects/kit/tokens/i18n.ts | 2 ++ 69 files changed, 220 insertions(+), 42 deletions(-) diff --git a/package.json b/package.json index 1e1b8b1d6ba9..9ee10b818a8a 100644 --- a/package.json +++ b/package.json @@ -85,8 +85,7 @@ "i18n/no-russian-character": "off", "i18n/no-thai-character": "off", "jest/prefer-importing-jest-globals": "off", - "sonarjs/prefer-nullish-coalescing": "off", - "@angular-eslint/template/elements-content": "off" + "sonarjs/prefer-nullish-coalescing": "off" }, "overrides": [ { diff --git a/projects/core/components/textfield/textfield.component.ts b/projects/core/components/textfield/textfield.component.ts index 6c8bf06b0eed..d72428928aae 100644 --- a/projects/core/components/textfield/textfield.component.ts +++ b/projects/core/components/textfield/textfield.component.ts @@ -13,6 +13,7 @@ import { ViewContainerRef, ViewEncapsulation, } from '@angular/core'; +import {toSignal} from '@angular/core/rxjs-interop'; import {NgControl} from '@angular/forms'; import {WaResizeObserver} from '@ng-web-apis/resize-observer'; import {tuiInjectId} from '@taiga-ui/cdk/services'; @@ -31,7 +32,7 @@ import { TuiWithDropdownOpen, } from '@taiga-ui/core/directives/dropdown'; import {TuiWithIcons} from '@taiga-ui/core/directives/icons'; -import {TUI_COMMON_ICONS} from '@taiga-ui/core/tokens'; +import {TUI_CLEAR_WORD, TUI_COMMON_ICONS} from '@taiga-ui/core/tokens'; import type {TuiSizeL, TuiSizeS} from '@taiga-ui/core/types'; import type {PolymorpheusContent} from '@taiga-ui/polymorpheus'; import {PolymorpheusOutlet} from '@taiga-ui/polymorpheus'; @@ -81,6 +82,7 @@ export class TuiTextfieldComponent implements TuiDataListHost { protected readonly control?: NgControl; protected readonly icons = inject(TUI_COMMON_ICONS); + protected readonly clear = toSignal(inject(TUI_CLEAR_WORD)); protected computedFiller = computed(() => { const value = this.directive?.nativeValue() || ''; diff --git a/projects/core/components/textfield/textfield.template.html b/projects/core/components/textfield/textfield.template.html index aba2f6b964ca..32ddda880a7a 100644 --- a/projects/core/components/textfield/textfield.template.html +++ b/projects/core/components/textfield/textfield.template.html @@ -18,7 +18,9 @@ [iconStart]="icons.close" (click)="directive?.setValue(null)" (pointerdown.silent.prevent)="input?.nativeElement?.focus()" - > + > + {{ clear() }} + diff --git a/projects/core/tokens/i18n.ts b/projects/core/tokens/i18n.ts index df553ddf237f..f5f61cf6789a 100644 --- a/projects/core/tokens/i18n.ts +++ b/projects/core/tokens/i18n.ts @@ -11,6 +11,11 @@ export const TUI_MONTHS = tuiCreateTokenFromFactory(tuiExtractI18n('months')); */ export const TUI_CLOSE_WORD = tuiCreateTokenFromFactory(tuiExtractI18n('close')); +/** + * i18n 'clear' word + */ +export const TUI_CLEAR_WORD = tuiCreateTokenFromFactory(tuiExtractI18n('clear')); + /** * i18n 'Nothing found' message */ diff --git a/projects/demo/src/modules/components/app-bar/examples/1/index.html b/projects/demo/src/modules/components/app-bar/examples/1/index.html index 45a62a964c05..8deb7091b498 100644 --- a/projects/demo/src/modules/components/app-bar/examples/1/index.html +++ b/projects/demo/src/modules/components/app-bar/examples/1/index.html @@ -37,6 +37,7 @@

iOS

+ > + Previous +

Carousel is awesome

@@ -66,7 +68,9 @@

Buttons

type="button" class="tui-space_left-4" (click)="navigate(1)" - > + > + Next +
+> + Open + Multi select control [tuiDropdown]="content" [tuiDropdownMaxHeight]="500" [(tuiDropdownOpen)]="control" -> +> + Open + Separate toggles [tuiDropdown]="separate" [tuiDropdownMaxHeight]="500" [(tuiDropdownOpen)]="label" -> +> + Open + {{ hint }} diff --git a/projects/demo/src/modules/components/slider/examples/6/index.html b/projects/demo/src/modules/components/slider/examples/6/index.html index dc815b948999..9ca6ca1fd93d 100644 --- a/projects/demo/src/modules/components/slider/examples/6/index.html +++ b/projects/demo/src/modules/components/slider/examples/6/index.html @@ -7,7 +7,9 @@ type="button" class="minus" (click)="change(-0.25)" - > + > + Minus +