From 8515dfa5fefae53a98eb772335be3cb36373df93 Mon Sep 17 00:00:00 2001 From: Alex Inkin Date: Wed, 12 Jun 2024 00:51:02 +0800 Subject: [PATCH] refactor(legacy): move all deprecated stuff in it (#7711) Signed-off-by: waterplea --- projects/addon-doc/components/demo/index.ts | 3 +- .../utils}/clean-object.ts | 9 +- projects/addon-doc/utils/index.ts | 1 + projects/cdk/constants/empty.ts | 4 +- projects/cdk/constants/index.ts | 1 - projects/cdk/constants/polling-time.ts | 1 - .../auto-focus/autofocus.options.ts | 27 +---- .../auto-focus/handlers/abstract.handler.ts | 18 ++-- .../auto-focus/handlers/default.handler.ts | 7 +- .../auto-focus/handlers/ios.handler.ts | 4 +- .../test/auto-focus.directive.spec.ts | 92 +--------------- .../cdk/directives/media/media.directive.ts | 7 +- .../directives/obscured/obscured.service.ts | 4 +- projects/cdk/observables/typed-from-event.ts | 21 +++- .../v4/steps/templates/migrate-money.ts | 4 +- .../ng-update/v4/steps/utils/clean-object.ts | 20 ++++ .../tokens/{is-mobile.ts => environment.ts} | 47 +++++++- projects/cdk/tokens/index.ts | 16 +-- projects/cdk/tokens/is-android.ts | 12 --- projects/cdk/tokens/is-cypress.ts | 15 --- projects/cdk/tokens/is-e2e.ts | 12 --- projects/cdk/tokens/is-ios.ts | 8 -- projects/cdk/tokens/is-playwright.ts | 7 -- projects/cdk/tokens/is-webkit.ts | 10 -- projects/cdk/tokens/platform.ts | 14 --- projects/cdk/types/deep-partial.ts | 3 - projects/cdk/types/event-with.ts | 19 ---- .../cdk/types/focusable-element-accessor.ts | 13 --- projects/cdk/types/index.ts | 5 - projects/cdk/types/input-mode.ts | 9 -- projects/cdk/types/input-type.ts | 1 - projects/cdk/utils/browser/index.ts | 1 - .../cdk/utils/browser/is-apple-platform.ts | 13 --- projects/cdk/utils/browser/is-apple.ts | 16 ++- projects/cdk/utils/browser/is-ios.ts | 4 +- projects/cdk/utils/miscellaneous/index.ts | 1 - .../miscellaneous/test/clean-object.spec.ts | 32 ------ .../calendar/calendar-spin.component.ts | 3 +- .../components/calendar/calendar.component.ts | 3 +- .../data-list/data-list.component.ts | 1 - .../components/data-list/option.component.ts | 1 - .../expand/test/expand.component.spec.ts | 6 +- .../core/components/group/group.style.less | 6 +- .../core/components/label/label.directive.ts | 2 +- .../scrollbar/scrollbar.directive.ts | 4 +- .../svg-defs-host/svg-defs-host.component.ts | 3 +- projects/core/components/svg/svg.component.ts | 3 +- .../textfield/textfield.component.ts | 39 ++----- projects/core/services/svg.service.ts | 2 +- projects/core/styles/theme/variables.less | 7 +- projects/core/tokens/index.ts | 3 - projects/core/tokens/textfield-host.ts | 16 --- projects/core/types/index.ts | 2 - projects/core/types/point.ts | 1 + projects/core/types/with-optional-min-max.ts | 5 - .../utils/miscellaneous/icons-path-factory.ts | 1 + projects/core/utils/miscellaneous/index.ts | 1 - .../miscellaneous/is-presumed-html-string.ts | 1 + .../modules/components/abstract/control.ts | 7 +- .../input-date-range/examples/1/index.ts | 3 +- .../components/input-date/examples/1/index.ts | 7 +- .../components/input-time/examples/1/index.ts | 8 +- .../primitive-textfield/examples/1/index.ts | 2 +- .../primitive-textfield/examples/2/index.ts | 2 +- .../components/primitive-textfield/index.ts | 6 +- .../utils/tokens/examples/2/index.html | 19 +++- .../utils/tokens/examples/2/index.ts | 7 +- .../utils/tokens/examples/3/index.html | 10 +- .../utils/tokens/examples/3/index.ts | 6 +- .../utils/tokens/examples/4/index.html | 11 +- .../utils/tokens/examples/4/index.ts | 7 +- .../utils/tokens/examples/5/index.html | 81 +++++++++++++- .../utils/tokens/examples/5/index.ts | 8 +- .../utils/tokens/examples/6/index.html | 64 +++++------ .../utils/tokens/examples/6/index.ts | 3 +- .../utils/tokens/examples/7/index.html | 100 ++++-------------- .../utils/tokens/examples/7/index.ts | 36 ++++++- .../provide-first-day-of-week-token.md | 0 .../utils/tokens/examples/8/index.html | 25 ----- .../utils/tokens/examples/8/index.ts | 45 -------- .../components/utils/tokens/index.html | 32 +++--- .../directives/textfield-controller/index.ts | 7 +- .../components/tooltip/tooltip.component.ts | 2 +- .../accordion/accordion-item.style.less | 4 + .../calendar-month.component.ts | 4 +- .../calendar-range.component.ts | 6 +- .../pagination/pagination.component.ts | 4 +- .../kit/components/range/range.component.ts | 7 +- .../unfinished-validator.directive.ts | 10 +- .../unfinished.validator.ts | 16 +-- .../filter-by-input/filter-by-input.pipe.ts | 30 +++--- .../legacy/classes/abstract-native-select.ts | 5 +- .../legacy/classes/abstract-textfield-host.ts | 2 +- .../combo-box/combo-box.component.ts | 16 +-- .../combo-box/combo-box.directive.ts | 2 +- .../input-copy/input-copy.component.ts | 8 +- .../input-copy/input-copy.directive.ts | 2 +- .../input-date-multi.component.ts | 19 +--- .../input-date-range.component.ts | 20 +--- .../input-date-range.directive.ts | 2 +- .../input-date-time.component.ts | 10 +- .../input-date-time.directive.ts | 2 +- .../native-date-time.directive.ts | 2 +- .../input-date/input-date.component.ts | 13 +-- .../input-date/input-date.directive.ts | 2 +- .../native-date/native-date.component.ts | 2 +- .../input-month-range.component.ts | 19 ++-- .../input-month-range.directive.ts | 3 +- .../input-month/input-month.component.ts | 18 ++-- .../input-month/input-month.directive.ts | 3 +- .../input-number/input-number.component.ts | 11 +- .../input-number/input-number.directive.ts | 2 +- .../input-password.component.ts | 15 ++- .../input-password.directive.ts | 2 +- .../input-phone-international.component.ts | 12 +-- .../input-phone/input-phone.component.ts | 13 +-- .../input-phone/input-phone.directive.ts | 2 +- .../input-range/input-range.component.ts | 15 ++- .../input-slider/input-slider.component.ts | 22 ++-- .../input-tag/input-tag.component.ts | 10 +- .../input-time/input-time.component.ts | 10 +- .../input-time/input-time.directive.ts | 2 +- .../native-time/native-time.component.ts | 2 +- .../input-year/input-year.component.ts | 16 ++- .../input-year/input-year.directive.ts | 2 +- .../components/input/input.component.ts | 10 +- .../components/input/input.directive.ts | 2 +- .../multi-select/multi-select.component.ts | 4 +- .../multi-select/multi-select.directive.ts | 2 +- .../primitive-textfield-types.ts | 2 +- .../primitive-textfield.component.ts | 9 +- .../primitive-textfield.directive.ts | 2 +- .../test/textfield.component.spec.ts | 2 +- .../textfield/textfield.component.ts | 4 +- .../value-decoration.component.ts | 2 +- .../components/select/select.component.ts | 14 +-- .../components/select/select.directive.ts | 2 +- .../components/textarea/textarea.component.ts | 13 ++- .../components/textarea/textarea.directive.ts | 2 +- projects/legacy/directives/index.ts | 1 + .../textfield-controller.provider.ts | 2 +- .../directives/unfinished-validator/index.ts | 2 + .../unfinished-validator/ng-package.json | 5 + .../unfinished-validator.directive.ts | 21 ++++ .../unfinished.validator.ts | 23 ++++ .../value-accessor/value-accessor.provider.ts | 2 +- .../tokens/focusable-item-accessor.ts | 15 ++- .../{cdk => legacy}/tokens/fonts-ready.ts | 0 projects/legacy/tokens/index.ts | 10 ++ projects/{cdk => legacy}/tokens/is-apple.ts | 3 +- .../{cdk => legacy}/tokens/is-chromium.ts | 2 +- projects/{cdk => legacy}/tokens/is-firefox.ts | 2 +- .../{cdk => legacy}/tokens/is-stackblitz.ts | 2 +- .../tokens/textfield-appearance.ts | 1 - .../types => legacy/tokens}/textfield-host.ts | 16 ++- .../{cdk => legacy}/tokens/touch-supported.ts | 2 +- .../{core => legacy}/tokens/value-accessor.ts | 1 - .../utils}/get-border.ts | 2 +- projects/legacy/utils/index.ts | 2 + projects/legacy/utils/is-apple.ts | 7 ++ .../utils/tests}/get-border.spec.ts | 2 +- 161 files changed, 674 insertions(+), 975 deletions(-) rename projects/{cdk/utils/miscellaneous => addon-doc/utils}/clean-object.ts (65%) delete mode 100644 projects/cdk/constants/polling-time.ts create mode 100644 projects/cdk/schematics/ng-update/v4/steps/utils/clean-object.ts rename projects/cdk/tokens/{is-mobile.ts => environment.ts} (61%) delete mode 100644 projects/cdk/tokens/is-android.ts delete mode 100644 projects/cdk/tokens/is-cypress.ts delete mode 100644 projects/cdk/tokens/is-e2e.ts delete mode 100644 projects/cdk/tokens/is-ios.ts delete mode 100644 projects/cdk/tokens/is-playwright.ts delete mode 100644 projects/cdk/tokens/is-webkit.ts delete mode 100644 projects/cdk/tokens/platform.ts delete mode 100644 projects/cdk/types/deep-partial.ts delete mode 100644 projects/cdk/types/event-with.ts delete mode 100644 projects/cdk/types/focusable-element-accessor.ts delete mode 100644 projects/cdk/types/input-mode.ts delete mode 100644 projects/cdk/types/input-type.ts delete mode 100644 projects/cdk/utils/browser/is-apple-platform.ts delete mode 100644 projects/cdk/utils/miscellaneous/test/clean-object.spec.ts delete mode 100644 projects/core/tokens/textfield-host.ts delete mode 100644 projects/core/types/with-optional-min-max.ts rename projects/demo/src/modules/components/utils/tokens/examples/{8 => 7}/provide-first-day-of-week-token.md (100%) delete mode 100644 projects/demo/src/modules/components/utils/tokens/examples/8/index.html delete mode 100644 projects/demo/src/modules/components/utils/tokens/examples/8/index.ts create mode 100644 projects/legacy/directives/unfinished-validator/index.ts create mode 100644 projects/legacy/directives/unfinished-validator/ng-package.json create mode 100644 projects/legacy/directives/unfinished-validator/unfinished-validator.directive.ts create mode 100644 projects/legacy/directives/unfinished-validator/unfinished.validator.ts rename projects/{cdk => legacy}/tokens/focusable-item-accessor.ts (55%) rename projects/{cdk => legacy}/tokens/fonts-ready.ts (100%) rename projects/{cdk => legacy}/tokens/is-apple.ts (67%) rename projects/{cdk => legacy}/tokens/is-chromium.ts (80%) rename projects/{cdk => legacy}/tokens/is-firefox.ts (83%) rename projects/{cdk => legacy}/tokens/is-stackblitz.ts (77%) rename projects/{core => legacy}/tokens/textfield-appearance.ts (87%) rename projects/{core/types => legacy/tokens}/textfield-host.ts (50%) rename projects/{cdk => legacy}/tokens/touch-supported.ts (77%) rename projects/{core => legacy}/tokens/value-accessor.ts (85%) rename projects/{core/utils/miscellaneous => legacy/utils}/get-border.ts (90%) create mode 100644 projects/legacy/utils/is-apple.ts rename projects/{core/utils/miscellaneous/test => legacy/utils/tests}/get-border.spec.ts (86%) diff --git a/projects/addon-doc/components/demo/index.ts b/projects/addon-doc/components/demo/index.ts index ee1c9b79df93..8b39a8e576c1 100644 --- a/projects/addon-doc/components/demo/index.ts +++ b/projects/addon-doc/components/demo/index.ts @@ -18,10 +18,9 @@ import {UrlSerializer} from '@angular/router'; import {TuiThemeDarkService} from '@taiga-ui/addon-doc/services'; import {TUI_DOC_DEMO_TEXTS, TUI_DOC_URL_STATE_HANDLER} from '@taiga-ui/addon-doc/tokens'; import type {TuiDemoParams} from '@taiga-ui/addon-doc/types'; -import {tuiCoerceValueIsTrue} from '@taiga-ui/addon-doc/utils'; +import {tuiCleanObject, tuiCoerceValueIsTrue} from '@taiga-ui/addon-doc/utils'; import { tuiClamp, - tuiCleanObject, tuiInjectElement, tuiPure, tuiPx, diff --git a/projects/cdk/utils/miscellaneous/clean-object.ts b/projects/addon-doc/utils/clean-object.ts similarity index 65% rename from projects/cdk/utils/miscellaneous/clean-object.ts rename to projects/addon-doc/utils/clean-object.ts index 7b3b7e81a7f4..9e31acc2d2da 100644 --- a/projects/cdk/utils/miscellaneous/clean-object.ts +++ b/projects/addon-doc/utils/clean-object.ts @@ -1,11 +1,12 @@ -import type {TuiDeepPartial} from '@taiga-ui/cdk/types'; - -import {tuiIsString} from './is-string'; +export type TuiDeepPartial = { + [K in keyof T]?: T[K] extends object ? TuiDeepPartial : T[K]; +}; type EmptyValue = '' | null | undefined; function checkValueIsEmpty(value: EmptyValue | T): value is EmptyValue { - const nextValue: any = tuiIsString(value) ? value.trim() : value; + // eslint-disable-next-line + const nextValue: any = typeof value === 'string' ? value.trim() : value; return [undefined, null, NaN, ''].includes(nextValue); } diff --git a/projects/addon-doc/utils/index.ts b/projects/addon-doc/utils/index.ts index f3e09b9b2906..130005e4f7a4 100644 --- a/projects/addon-doc/utils/index.ts +++ b/projects/addon-doc/utils/index.ts @@ -1,3 +1,4 @@ +export * from './clean-object'; export * from './coerce-boolean'; export * from './coerce-value'; export * from './inspect'; diff --git a/projects/cdk/constants/empty.ts b/projects/cdk/constants/empty.ts index a6256a53ae10..50b630577276 100644 --- a/projects/cdk/constants/empty.ts +++ b/projects/cdk/constants/empty.ts @@ -21,7 +21,5 @@ export const EMPTY_ARRAY: [] = []; export const EMPTY_FUNCTION: (...args: any[]) => void = () => {}; export const EMPTY_CLIENT_RECT: DOMRect = { ...rect, - toJSON() { - return rect; - }, + toJSON: () => rect, }; diff --git a/projects/cdk/constants/index.ts b/projects/cdk/constants/index.ts index a883ab85f1bb..67e3ab384ea1 100644 --- a/projects/cdk/constants/index.ts +++ b/projects/cdk/constants/index.ts @@ -1,7 +1,6 @@ export * from './empty'; export * from './handlers'; export * from './matchers'; -export * from './polling-time'; export * from './regexp'; export * from './svg-node-filter'; export * from './unicode-chars'; diff --git a/projects/cdk/constants/polling-time.ts b/projects/cdk/constants/polling-time.ts deleted file mode 100644 index 9516c561e644..000000000000 --- a/projects/cdk/constants/polling-time.ts +++ /dev/null @@ -1 +0,0 @@ -export const POLLING_TIME = 1000 / 15; diff --git a/projects/cdk/directives/auto-focus/autofocus.options.ts b/projects/cdk/directives/auto-focus/autofocus.options.ts index ee55f5d7ad5a..f93ee7542a8b 100644 --- a/projects/cdk/directives/auto-focus/autofocus.options.ts +++ b/projects/cdk/directives/auto-focus/autofocus.options.ts @@ -1,15 +1,7 @@ import type {Provider} from '@angular/core'; -import { - ElementRef, - InjectionToken, - NgZone, - Optional, - Renderer2, - Self, -} from '@angular/core'; +import {ElementRef, InjectionToken, NgZone, Renderer2} from '@angular/core'; import {ANIMATION_FRAME, WINDOW} from '@ng-web-apis/common'; -import {TUI_FOCUSABLE_ITEM_ACCESSOR, TUI_IS_IOS} from '@taiga-ui/cdk/tokens'; -import type {TuiFocusableElementAccessor} from '@taiga-ui/cdk/types'; +import {TUI_IS_IOS} from '@taiga-ui/cdk/tokens'; import {tuiCreateToken, tuiProvideOptions} from '@taiga-ui/cdk/utils/miscellaneous'; import type {Observable} from 'rxjs'; @@ -48,7 +40,6 @@ export const TUI_AUTOFOCUS_PROVIDERS = [ { provide: TUI_AUTOFOCUS_HANDLER, useFactory: ( - focusable: TuiFocusableElementAccessor | null, el: ElementRef, animationFrame$: Observable, renderer: Renderer2, @@ -57,16 +48,8 @@ export const TUI_AUTOFOCUS_PROVIDERS = [ isIos: boolean, ) => isIos - ? new TuiIosAutofocusHandler(focusable, el, renderer, zone, win) - : new TuiDefaultAutofocusHandler(focusable, el, animationFrame$), - deps: [ - [new Optional(), new Self(), TUI_FOCUSABLE_ITEM_ACCESSOR], - ElementRef, - ANIMATION_FRAME, - Renderer2, - NgZone, - WINDOW, - TUI_IS_IOS, - ], + ? new TuiIosAutofocusHandler(el, renderer, zone, win) + : new TuiDefaultAutofocusHandler(el, animationFrame$), + deps: [ElementRef, ANIMATION_FRAME, Renderer2, NgZone, WINDOW, TUI_IS_IOS], }, ]; diff --git a/projects/cdk/directives/auto-focus/handlers/abstract.handler.ts b/projects/cdk/directives/auto-focus/handlers/abstract.handler.ts index 24bfbe634175..f6ff0e75c84f 100644 --- a/projects/cdk/directives/auto-focus/handlers/abstract.handler.ts +++ b/projects/cdk/directives/auto-focus/handlers/abstract.handler.ts @@ -1,21 +1,19 @@ import type {ElementRef} from '@angular/core'; -import type { - TuiFocusableElementAccessor, - TuiNativeFocusableElement, -} from '@taiga-ui/cdk/types'; import type {TuiAutofocusHandler} from '../autofocus.options'; export abstract class AbstractTuiAutofocusHandler implements TuiAutofocusHandler { - constructor( - protected readonly focusable: TuiFocusableElementAccessor | null, - protected readonly el: ElementRef, - ) {} + constructor(protected readonly el: ElementRef) {} public abstract setFocus(): void; - protected get element(): TuiNativeFocusableElement { - return this.focusable?.nativeFocusableElement || this.el.nativeElement; + protected get element(): HTMLElement { + // TODO: Remove when legacy controls are dropped + const el = this.el.nativeElement.tagName.includes('-') + ? this.el.nativeElement.querySelector('input,textarea') + : this.el.nativeElement; + + return el || this.el.nativeElement; } protected get isTextFieldElement(): boolean { diff --git a/projects/cdk/directives/auto-focus/handlers/default.handler.ts b/projects/cdk/directives/auto-focus/handlers/default.handler.ts index ca5ae8ff89d8..2b725b161f35 100644 --- a/projects/cdk/directives/auto-focus/handlers/default.handler.ts +++ b/projects/cdk/directives/auto-focus/handlers/default.handler.ts @@ -1,6 +1,4 @@ import type {ElementRef} from '@angular/core'; -import {POLLING_TIME} from '@taiga-ui/cdk/constants'; -import type {TuiFocusableElementAccessor} from '@taiga-ui/cdk/types'; import type {Observable} from 'rxjs'; import {map, race, skipWhile, take, throttleTime, timer} from 'rxjs'; @@ -11,11 +9,10 @@ const NG_ANIMATION_SELECTOR = '.ng-animating'; export class TuiDefaultAutofocusHandler extends AbstractTuiAutofocusHandler { constructor( - focusable: TuiFocusableElementAccessor | null, el: ElementRef, private readonly animationFrame$: Observable, ) { - super(focusable, el); + super(el); } public setFocus(): void { @@ -23,7 +20,7 @@ export class TuiDefaultAutofocusHandler extends AbstractTuiAutofocusHandler { race( timer(TIMEOUT), this.animationFrame$.pipe( - throttleTime(POLLING_TIME), + throttleTime(100), map(() => this.element.closest(NG_ANIMATION_SELECTOR)), skipWhile(Boolean), take(1), diff --git a/projects/cdk/directives/auto-focus/handlers/ios.handler.ts b/projects/cdk/directives/auto-focus/handlers/ios.handler.ts index 8f42ac9bb2db..fda964f03600 100644 --- a/projects/cdk/directives/auto-focus/handlers/ios.handler.ts +++ b/projects/cdk/directives/auto-focus/handlers/ios.handler.ts @@ -1,5 +1,4 @@ import type {ElementRef, NgZone, Renderer2} from '@angular/core'; -import type {TuiFocusableElementAccessor} from '@taiga-ui/cdk/types'; import {tuiIsPresent, tuiPx} from '@taiga-ui/cdk/utils'; import {AbstractTuiAutofocusHandler} from './abstract.handler'; @@ -19,13 +18,12 @@ const TEXTFIELD_ATTRS = [ export class TuiIosAutofocusHandler extends AbstractTuiAutofocusHandler { constructor( - focusable: TuiFocusableElementAccessor | null, el: ElementRef, private readonly renderer: Renderer2, private readonly zone: NgZone, private readonly win: Window, ) { - super(focusable, el); + super(el); this.patchCssStyles(); } diff --git a/projects/cdk/directives/auto-focus/test/auto-focus.directive.spec.ts b/projects/cdk/directives/auto-focus/test/auto-focus.directive.spec.ts index 39b904123283..b8cbff8092c3 100644 --- a/projects/cdk/directives/auto-focus/test/auto-focus.directive.spec.ts +++ b/projects/cdk/directives/auto-focus/test/auto-focus.directive.spec.ts @@ -3,25 +3,19 @@ import { Component, ElementRef, NgZone, - Optional, Renderer2, - Self, ViewChild, } from '@angular/core'; import type {ComponentFixture} from '@angular/core/testing'; import {fakeAsync, TestBed, tick} from '@angular/core/testing'; import {WINDOW} from '@ng-web-apis/common'; -import type {TuiFocusableElementAccessor} from '@taiga-ui/cdk'; import { TUI_AUTOFOCUS_HANDLER, - TUI_FOCUSABLE_ITEM_ACCESSOR, - tuiAsFocusableItemAccessor, TuiAutoFocusDirective, TuiIosAutofocusHandler, tuiIsNativeFocused, } from '@taiga-ui/cdk'; import {NG_EVENT_PLUGINS} from '@tinkoff/ng-event-plugins'; -import {EMPTY} from 'rxjs'; describe('TuiAutoFocus directive', () => { describe('works for focusable HTML element', () => { @@ -61,74 +55,6 @@ describe('TuiAutoFocus directive', () => { })); }); - describe('works for TUI_FOCUSABLE_ITEM_ACCESSOR', () => { - @Component({ - standalone: true, - selector: 'focusable-component', - template: ` -

- -

- `, - changeDetection: ChangeDetectionStrategy.OnPush, - providers: [tuiAsFocusableItemAccessor(TestFocusableComponent)], - }) - class TestFocusableComponent implements TuiFocusableElementAccessor { - @ViewChild('input') - public input?: ElementRef; - - public focusedChange = EMPTY; - - public get nativeFocusableElement(): HTMLInputElement | null { - return this.input?.nativeElement ?? null; - } - - public get focused(): boolean { - return this.input - ? document.activeElement === this.input.nativeElement - : false; - } - } - - @Component({ - standalone: true, - imports: [TestFocusableComponent, TuiAutoFocusDirective], - template: ` - - `, - changeDetection: ChangeDetectionStrategy.OnPush, - }) - class TestComponentWithTuiButton { - @ViewChild(TestFocusableComponent) - public focusable!: TestFocusableComponent; - } - - let fixture: ComponentFixture; - let testComponent: TestComponentWithTuiButton; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [TestComponentWithTuiButton, TestFocusableComponent], - providers: [NG_EVENT_PLUGINS], - }); - - fixture = TestBed.createComponent(TestComponentWithTuiButton); - testComponent = fixture.componentInstance; - }); - - it('Focuses native element of a TUI_FOCUSABLE_ITEM_ACCESSOR', fakeAsync(() => { - fixture.detectChanges(); - tick(100); - expect(testComponent.focusable.focused).toBe(true); - expect(document.activeElement).toBe( - testComponent.focusable.nativeFocusableElement, - ); - })); - }); - describe('works for iOS decoy method', () => { @Component({ standalone: true, @@ -155,26 +81,12 @@ describe('TuiAutoFocus directive', () => { provide: TUI_AUTOFOCUS_HANDLER, useClass: TuiIosAutofocusHandler, useFactory: ( - focusable: TuiFocusableElementAccessor | null, el: ElementRef, renderer: Renderer2, zone: NgZone, win: Window, - ) => - new TuiIosAutofocusHandler( - focusable, - el, - renderer, - zone, - win, - ), - deps: [ - [new Optional(), new Self(), TUI_FOCUSABLE_ITEM_ACCESSOR], - ElementRef, - Renderer2, - NgZone, - WINDOW, - ], + ) => new TuiIosAutofocusHandler(el, renderer, zone, win), + deps: [ElementRef, Renderer2, NgZone, WINDOW], }, ], }); diff --git a/projects/cdk/directives/media/media.directive.ts b/projects/cdk/directives/media/media.directive.ts index e67ef7695198..6249fb599a65 100644 --- a/projects/cdk/directives/media/media.directive.ts +++ b/projects/cdk/directives/media/media.directive.ts @@ -12,6 +12,7 @@ import {tuiInjectElement} from '@taiga-ui/cdk/utils'; standalone: true, selector: 'video[tuiMedia], audio[tuiMedia]', exportAs: 'tuiMedia', + host: {'(durationchange)': '0'}, }) export class TuiMediaDirective { private readonly el = tuiInjectElement(); @@ -61,7 +62,6 @@ export class TuiMediaDirective { return Boolean(this.el.paused); } - // @bad TODO: Make sure no other events can affect this like network issues etc. @HostListener('ended', ['true']) @HostListener('pause', ['true']) @HostListener('play', ['false']) @@ -83,11 +83,6 @@ export class TuiMediaDirective { this.currentTimeChange.emit(this.currentTime); } - @HostListener('durationchange') - protected changeDetectionTrigger(): void { - // @bad TODO: consider if other events need to trigger CD - } - private updatePlaybackRate(playbackRate: number): void { this.playbackRate = playbackRate; this.el.playbackRate = this.playbackRate; diff --git a/projects/cdk/directives/obscured/obscured.service.ts b/projects/cdk/directives/obscured/obscured.service.ts index 0dfd28f779f6..3ddf12fa3568 100644 --- a/projects/cdk/directives/obscured/obscured.service.ts +++ b/projects/cdk/directives/obscured/obscured.service.ts @@ -1,11 +1,9 @@ import {inject, Injectable, NgZone} from '@angular/core'; import {ANIMATION_FRAME} from '@ng-web-apis/common'; -import {POLLING_TIME} from '@taiga-ui/cdk/constants'; import {tuiZoneOptimized} from '@taiga-ui/cdk/observables'; import {tuiGetElementObscures, tuiInjectElement} from '@taiga-ui/cdk/utils/dom'; import {distinctUntilChanged, map, Observable, startWith, throttleTime} from 'rxjs'; -// @bad TODO: Consider Intersection Observer with fallback to current implementation /** * Service that monitors element visibility by polling and returning * either null or an array of elements that overlap given element edges @@ -14,7 +12,7 @@ import {distinctUntilChanged, map, Observable, startWith, throttleTime} from 'rx export class TuiObscuredService extends Observable { private readonly el = tuiInjectElement(); private readonly obscured$ = inject(ANIMATION_FRAME).pipe( - throttleTime(POLLING_TIME), + throttleTime(100), map(() => tuiGetElementObscures(this.el)), startWith(null), distinctUntilChanged(), diff --git a/projects/cdk/observables/typed-from-event.ts b/projects/cdk/observables/typed-from-event.ts index 0cfc4d5cdf92..123e1d1300f4 100644 --- a/projects/cdk/observables/typed-from-event.ts +++ b/projects/cdk/observables/typed-from-event.ts @@ -1,7 +1,26 @@ -import type {TuiEventWith, TuiTypedEventTarget} from '@taiga-ui/cdk/types'; import type {Observable} from 'rxjs'; import {fromEvent} from 'rxjs'; +export interface TuiTypedEventTarget { + addEventListener( + type: string, + listener: ((evt: E) => void) | null, + options?: AddEventListenerOptions | boolean, + ): void; + removeEventListener( + type: string, + listener?: ((evt: E) => void) | null, + options?: EventListenerOptions | boolean, + ): void; +} + +/** + * Wrapper around {@link Event} to add typings to target and currentTarget. + */ +export type TuiEventWith> = G & { + readonly currentTarget: T; +}; + export function tuiTypedFromEvent( target: Window, event: E, diff --git a/projects/cdk/schematics/ng-update/v4/steps/templates/migrate-money.ts b/projects/cdk/schematics/ng-update/v4/steps/templates/migrate-money.ts index 2e9a1ff861f8..85679e58507c 100644 --- a/projects/cdk/schematics/ng-update/v4/steps/templates/migrate-money.ts +++ b/projects/cdk/schematics/ng-update/v4/steps/templates/migrate-money.ts @@ -2,7 +2,6 @@ import type {UpdateRecorder} from '@angular-devkit/schematics'; import type {DevkitFileSystem} from '@taiga-ui/morph'; import type {Attribute} from 'parse5/dist/common/token'; -import {tuiCleanObject} from '../../../../../utils/miscellaneous/clean-object'; import type {TemplateResource} from '../../../../ng-update/interfaces'; import {removeAttrs} from '../../../../ng-update/v4/steps/utils/remove-attrs'; import {addImportToClosestModule} from '../../../../utils/add-import-to-closest-module'; @@ -12,6 +11,7 @@ import { getTemplateFromTemplateResource, getTemplateOffset, } from '../../../../utils/templates/template-resource'; +import {cleanObject} from '../utils/clean-object'; export function migrateMoney({ resource, @@ -62,7 +62,7 @@ export function migrateMoney({ ); const format = JSON.stringify( - tuiCleanObject({ + cleanObject({ decimal: decimalAttr?.value, precision: precisionAttr?.value, }), diff --git a/projects/cdk/schematics/ng-update/v4/steps/utils/clean-object.ts b/projects/cdk/schematics/ng-update/v4/steps/utils/clean-object.ts new file mode 100644 index 000000000000..980c550a2511 --- /dev/null +++ b/projects/cdk/schematics/ng-update/v4/steps/utils/clean-object.ts @@ -0,0 +1,20 @@ +export type TuiDeepPartial = { + [K in keyof T]?: T[K] extends object ? TuiDeepPartial : T[K]; +}; + +type EmptyValue = '' | null | undefined; + +function checkValueIsEmpty(value: EmptyValue | T): value is EmptyValue { + // eslint-disable-next-line + const nextValue: any = typeof value === 'string' ? value.trim() : value; + + return [undefined, null, NaN, ''].includes(nextValue); +} + +export function cleanObject(object: T): TuiDeepPartial { + return JSON.parse( + JSON.stringify(object, (_key: string, value: unknown) => + checkValueIsEmpty(value) ? undefined : value, + ), + ); +} diff --git a/projects/cdk/tokens/is-mobile.ts b/projects/cdk/tokens/environment.ts similarity index 61% rename from projects/cdk/tokens/is-mobile.ts rename to projects/cdk/tokens/environment.ts index 73ac050a98c3..b26b89ee9e04 100644 --- a/projects/cdk/tokens/is-mobile.ts +++ b/projects/cdk/tokens/environment.ts @@ -1,6 +1,8 @@ import {inject} from '@angular/core'; -import {USER_AGENT} from '@ng-web-apis/common'; -import {tuiCreateTokenFromFactory} from '@taiga-ui/cdk/utils'; +import {NAVIGATOR, USER_AGENT, WINDOW} from '@ng-web-apis/common'; +import {TUI_FALSE_HANDLER} from '@taiga-ui/cdk/constants'; +import type {TuiPlatform} from '@taiga-ui/cdk/types'; +import {tuiCreateTokenFromFactory, tuiIsIos} from '@taiga-ui/cdk/utils'; // https://stackoverflow.com/a/11381730/2706426 http://detectmobilebrowsers.com/ const firstRegex = @@ -8,11 +10,46 @@ const firstRegex = const secondRegex = /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/; -/** - * Mobile browser detection - */ export const TUI_IS_MOBILE = tuiCreateTokenFromFactory( () => firstRegex.test(inject(USER_AGENT).toLowerCase()) || secondRegex.test(inject(USER_AGENT).slice(0, 4).toLowerCase()), ); + +export const TUI_IS_IOS = tuiCreateTokenFromFactory(() => tuiIsIos(inject(NAVIGATOR))); + +export const TUI_IS_ANDROID = tuiCreateTokenFromFactory( + () => inject(TUI_IS_MOBILE) && !inject(TUI_IS_IOS), +); + +export const TUI_IS_WEBKIT = tuiCreateTokenFromFactory( + () => !!inject(WINDOW)?.webkitConvertPointFromNodeToPage, +); + +export const TUI_PLATFORM = tuiCreateTokenFromFactory(() => { + if (inject(TUI_IS_IOS)) { + return 'ios'; + } + + return inject(TUI_IS_ANDROID) ? 'android' : 'web'; +}); + +/** + * Detect if app is running under Cypress + * {@link https://docs.cypress.io/faq/questions/using-cypress-faq#Is-there-any-way-to-detect-if-my-app-is-running-under-Cypress Cypress docs} + */ +export const TUI_IS_CYPRESS = tuiCreateTokenFromFactory( + () => !!inject(WINDOW).Cypress, +); + +/** + * Manually provide `true` when running tests in Playwright + */ +export const TUI_IS_PLAYWRIGHT = tuiCreateTokenFromFactory(TUI_FALSE_HANDLER); + +/** + * Detect if app is running under any of test frameworks + */ +export const TUI_IS_E2E = tuiCreateTokenFromFactory( + () => inject(TUI_IS_CYPRESS) || inject(TUI_IS_PLAYWRIGHT), +); diff --git a/projects/cdk/tokens/index.ts b/projects/cdk/tokens/index.ts index aaf322696737..3312ef07d418 100644 --- a/projects/cdk/tokens/index.ts +++ b/projects/cdk/tokens/index.ts @@ -1,21 +1,7 @@ export * from './active-element'; export * from './base-href'; +export * from './environment'; export * from './fallback-value'; -export * from './focusable-item-accessor'; -export * from './fonts-ready'; -export * from './is-android'; -export * from './is-apple'; -export * from './is-chromium'; -export * from './is-cypress'; -export * from './is-e2e'; -export * from './is-firefox'; -export * from './is-ios'; -export * from './is-mobile'; -export * from './is-playwright'; -export * from './is-stackblitz'; -export * from './is-webkit'; -export * from './platform'; export * from './range'; export * from './removed-element'; -export * from './touch-supported'; export * from './window-size'; diff --git a/projects/cdk/tokens/is-android.ts b/projects/cdk/tokens/is-android.ts deleted file mode 100644 index a262291fec44..000000000000 --- a/projects/cdk/tokens/is-android.ts +++ /dev/null @@ -1,12 +0,0 @@ -import {inject} from '@angular/core'; -import {tuiCreateTokenFromFactory} from '@taiga-ui/cdk/utils'; - -import {TUI_IS_IOS} from './is-ios'; -import {TUI_IS_MOBILE} from './is-mobile'; - -/** - * Mobile browser that is not iOS (technically includes Windows Phone, Blackberry etc.) - */ -export const TUI_IS_ANDROID = tuiCreateTokenFromFactory( - () => inject(TUI_IS_MOBILE) && !inject(TUI_IS_IOS), -); diff --git a/projects/cdk/tokens/is-cypress.ts b/projects/cdk/tokens/is-cypress.ts deleted file mode 100644 index b38c43e34f38..000000000000 --- a/projects/cdk/tokens/is-cypress.ts +++ /dev/null @@ -1,15 +0,0 @@ -import {inject} from '@angular/core'; -import {WINDOW} from '@ng-web-apis/common'; -import {tuiCreateTokenFromFactory} from '@taiga-ui/cdk/utils'; - -interface WindowWithCypress extends Window { - Cypress?: unknown; -} - -/** - * Detect if app is running under Cypress - * {@link https://docs.cypress.io/faq/questions/using-cypress-faq#Is-there-any-way-to-detect-if-my-app-is-running-under-Cypress Cypress docs} - */ -export const TUI_IS_CYPRESS = tuiCreateTokenFromFactory( - () => !!inject(WINDOW).Cypress, -); diff --git a/projects/cdk/tokens/is-e2e.ts b/projects/cdk/tokens/is-e2e.ts deleted file mode 100644 index 2694a8eb7290..000000000000 --- a/projects/cdk/tokens/is-e2e.ts +++ /dev/null @@ -1,12 +0,0 @@ -import {inject} from '@angular/core'; -import {tuiCreateTokenFromFactory} from '@taiga-ui/cdk/utils'; - -import {TUI_IS_CYPRESS} from './is-cypress'; -import {TUI_IS_PLAYWRIGHT} from './is-playwright'; - -/** - * Detect if app is running under any of test frameworks - */ -export const TUI_IS_E2E = tuiCreateTokenFromFactory( - () => inject(TUI_IS_CYPRESS) || inject(TUI_IS_PLAYWRIGHT), -); diff --git a/projects/cdk/tokens/is-ios.ts b/projects/cdk/tokens/is-ios.ts deleted file mode 100644 index 0af1d1bf7c8a..000000000000 --- a/projects/cdk/tokens/is-ios.ts +++ /dev/null @@ -1,8 +0,0 @@ -import {inject} from '@angular/core'; -import {NAVIGATOR} from '@ng-web-apis/common'; -import {tuiCreateTokenFromFactory, tuiIsIos} from '@taiga-ui/cdk/utils'; - -/** - * iOS browser detection - */ -export const TUI_IS_IOS = tuiCreateTokenFromFactory(() => tuiIsIos(inject(NAVIGATOR))); diff --git a/projects/cdk/tokens/is-playwright.ts b/projects/cdk/tokens/is-playwright.ts deleted file mode 100644 index bae170c1cfa2..000000000000 --- a/projects/cdk/tokens/is-playwright.ts +++ /dev/null @@ -1,7 +0,0 @@ -import {TUI_FALSE_HANDLER} from '@taiga-ui/cdk/constants'; -import {tuiCreateTokenFromFactory} from '@taiga-ui/cdk/utils'; - -/** - * Detect if app is running under Playwright - */ -export const TUI_IS_PLAYWRIGHT = tuiCreateTokenFromFactory(TUI_FALSE_HANDLER); diff --git a/projects/cdk/tokens/is-webkit.ts b/projects/cdk/tokens/is-webkit.ts deleted file mode 100644 index 3e64bf681b96..000000000000 --- a/projects/cdk/tokens/is-webkit.ts +++ /dev/null @@ -1,10 +0,0 @@ -import {inject} from '@angular/core'; -import {WINDOW} from '@ng-web-apis/common'; -import {tuiCreateTokenFromFactory} from '@taiga-ui/cdk/utils'; - -/** - * Webkit browser engine detection - */ -export const TUI_IS_WEBKIT = tuiCreateTokenFromFactory( - (): boolean => !!inject(WINDOW)?.webkitConvertPointFromNodeToPage, -); diff --git a/projects/cdk/tokens/platform.ts b/projects/cdk/tokens/platform.ts deleted file mode 100644 index a9bbfba29cdf..000000000000 --- a/projects/cdk/tokens/platform.ts +++ /dev/null @@ -1,14 +0,0 @@ -import {inject} from '@angular/core'; -import type {TuiPlatform} from '@taiga-ui/cdk/types'; -import {tuiCreateTokenFromFactory} from '@taiga-ui/cdk/utils'; - -import {TUI_IS_ANDROID} from './is-android'; -import {TUI_IS_IOS} from './is-ios'; - -export const TUI_PLATFORM = tuiCreateTokenFromFactory(() => { - if (inject(TUI_IS_IOS)) { - return 'ios'; - } - - return inject(TUI_IS_ANDROID) ? 'android' : 'web'; -}); diff --git a/projects/cdk/types/deep-partial.ts b/projects/cdk/types/deep-partial.ts deleted file mode 100644 index e669cffc2b4a..000000000000 --- a/projects/cdk/types/deep-partial.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type TuiDeepPartial = { - [K in keyof T]?: T[K] extends object ? TuiDeepPartial : T[K]; -}; diff --git a/projects/cdk/types/event-with.ts b/projects/cdk/types/event-with.ts deleted file mode 100644 index d2199c5defad..000000000000 --- a/projects/cdk/types/event-with.ts +++ /dev/null @@ -1,19 +0,0 @@ -export interface TuiTypedEventTarget { - addEventListener( - type: string, - listener: ((evt: E) => void) | null, - options?: AddEventListenerOptions | boolean, - ): void; - removeEventListener( - type: string, - listener?: ((evt: E) => void) | null, - options?: EventListenerOptions | boolean, - ): void; -} - -/** - * Wrapper around {@link Event} to add typings to target and currentTarget. - */ -export type TuiEventWith> = G & { - readonly currentTarget: T; -}; diff --git a/projects/cdk/types/focusable-element-accessor.ts b/projects/cdk/types/focusable-element-accessor.ts deleted file mode 100644 index 1a7902fa44fe..000000000000 --- a/projects/cdk/types/focusable-element-accessor.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type {Observable} from 'rxjs'; - -export interface TuiNativeFocusableElement extends Element, HTMLOrSVGElement {} - -/** - * Public interface for any focusable component or directive - * TODO: shorten `nativeFocusableElement` in 4.0 - */ -export interface TuiFocusableElementAccessor { - focused: boolean; - readonly focusedChange: Observable; - nativeFocusableElement: TuiNativeFocusableElement | null; -} diff --git a/projects/cdk/types/index.ts b/projects/cdk/types/index.ts index 178814544708..870cb1dc3524 100644 --- a/projects/cdk/types/index.ts +++ b/projects/cdk/types/index.ts @@ -1,10 +1,5 @@ export * from './context'; -export * from './deep-partial'; -export * from './event-with'; -export * from './focusable-element-accessor'; export * from './handler'; -export * from './input-mode'; -export * from './input-type'; export * from './mapper'; export * from './matcher'; export * from './platform'; diff --git a/projects/cdk/types/input-mode.ts b/projects/cdk/types/input-mode.ts deleted file mode 100644 index 5dafa6de74e3..000000000000 --- a/projects/cdk/types/input-mode.ts +++ /dev/null @@ -1,9 +0,0 @@ -export type TuiInputMode = - | 'decimal' - | 'email' - | 'none' - | 'numeric' - | 'search' - | 'tel' - | 'text' - | 'url'; diff --git a/projects/cdk/types/input-type.ts b/projects/cdk/types/input-type.ts deleted file mode 100644 index 648ef821133c..000000000000 --- a/projects/cdk/types/input-type.ts +++ /dev/null @@ -1 +0,0 @@ -export type TuiInputType = 'email' | 'password' | 'tel' | 'text' | 'url'; diff --git a/projects/cdk/utils/browser/index.ts b/projects/cdk/utils/browser/index.ts index e500915a5672..ad58a89aa4f0 100644 --- a/projects/cdk/utils/browser/index.ts +++ b/projects/cdk/utils/browser/index.ts @@ -1,5 +1,4 @@ export * from './is-apple'; -export * from './is-apple-platform'; export * from './is-edge'; export * from './is-firefox'; export * from './is-ios'; diff --git a/projects/cdk/utils/browser/is-apple-platform.ts b/projects/cdk/utils/browser/is-apple-platform.ts deleted file mode 100644 index b65e97bc7b6d..000000000000 --- a/projects/cdk/utils/browser/is-apple-platform.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * @description: - * All Chrome / Chromium-based browsers will return MacIntel on macOS, - * no matter what the hardware architecture is. See the source code here: - * https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/frame/navigator_id.cc;l=64;drc=703d3c472cf27470dad21a3f2c8972aca3732cd6 - * But maybe in future years, it will be changed to MacM1 - * - * Documentation: - * https://developer.mozilla.org/en-US/docs/Web/API/Navigator/platform - */ -export function tuiIsApplePlatform(navigator: Navigator): boolean { - return navigator.platform.startsWith('Mac') || navigator.platform === 'iPhone'; -} diff --git a/projects/cdk/utils/browser/is-apple.ts b/projects/cdk/utils/browser/is-apple.ts index 8181cce0ac1e..637d07a11ca1 100644 --- a/projects/cdk/utils/browser/is-apple.ts +++ b/projects/cdk/utils/browser/is-apple.ts @@ -1,7 +1,13 @@ -import {tuiIsIos} from './is-ios'; - -const SAFARI_REG_EXP = /^((?!chrome|android).)*safari/i; - +/** + * @description: + * All Chrome / Chromium-based browsers will return MacIntel on macOS, + * no matter what the hardware architecture is. See the source code here: + * https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/frame/navigator_id.cc;l=64;drc=703d3c472cf27470dad21a3f2c8972aca3732cd6 + * But maybe in future years, it will be changed to MacM1 + * + * Documentation: + * https://developer.mozilla.org/en-US/docs/Web/API/Navigator/platform + */ export function tuiIsApple(navigator: Navigator): boolean { - return tuiIsIos(navigator) || SAFARI_REG_EXP.test(navigator.userAgent.toLowerCase()); + return navigator.platform.startsWith('Mac') || navigator.platform === 'iPhone'; } diff --git a/projects/cdk/utils/browser/is-ios.ts b/projects/cdk/utils/browser/is-ios.ts index 033a2f2a6331..c68ea0ba913a 100644 --- a/projects/cdk/utils/browser/is-ios.ts +++ b/projects/cdk/utils/browser/is-ios.ts @@ -1,10 +1,10 @@ -import {tuiIsApplePlatform} from './is-apple-platform'; +import {tuiIsApple} from './is-apple'; const IOS_REG_EXP = /ipad|iphone|ipod/; export function tuiIsIos(navigator: Navigator): boolean { return ( IOS_REG_EXP.test(navigator.userAgent.toLowerCase()) || - (tuiIsApplePlatform(navigator) && navigator.maxTouchPoints > 1) + (tuiIsApple(navigator) && navigator.maxTouchPoints > 1) ); } diff --git a/projects/cdk/utils/miscellaneous/index.ts b/projects/cdk/utils/miscellaneous/index.ts index 5c68b47b30e9..ac63f8d800c0 100644 --- a/projects/cdk/utils/miscellaneous/index.ts +++ b/projects/cdk/utils/miscellaneous/index.ts @@ -2,7 +2,6 @@ export * from './array-remove'; export * from './array-shallow-equals'; export * from './array-toggle'; export * from './change-date-separator'; -export * from './clean-object'; export * from './create-token'; export * from './default-sort'; export * from './directive-binding'; diff --git a/projects/cdk/utils/miscellaneous/test/clean-object.spec.ts b/projects/cdk/utils/miscellaneous/test/clean-object.spec.ts deleted file mode 100644 index 0e17e56de535..000000000000 --- a/projects/cdk/utils/miscellaneous/test/clean-object.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -import {tuiCleanObject} from '@taiga-ui/cdk'; - -describe('tuiCleanObject', () => { - it('should be clear empty values', (): void => { - expect( - tuiCleanObject({ - a: null, - b: undefined, - c: '', - d: null, - e: NaN, - f: [ - { - a: 2, - b: undefined, - c: '', - }, - { - a: 0, - b: undefined, - c: '', - }, - ], - g: { - a: 4, - b: undefined, - c: ' ', - }, - }), - ).toEqual({f: [{a: 2}, {a: 0}], g: {a: 4}}); - }); -}); diff --git a/projects/core/components/calendar/calendar-spin.component.ts b/projects/core/components/calendar/calendar-spin.component.ts index 3af1db1227e2..35a1cd8adf0b 100644 --- a/projects/core/components/calendar/calendar-spin.component.ts +++ b/projects/core/components/calendar/calendar-spin.component.ts @@ -11,7 +11,6 @@ import {TUI_FIRST_DAY, TUI_LAST_DAY, TuiMonth} from '@taiga-ui/cdk'; import {TuiLinkDirective} from '@taiga-ui/core/components/link'; import {TuiSpinButtonComponent} from '@taiga-ui/core/components/spin-button'; import {TuiMonthPipe} from '@taiga-ui/core/pipes'; -import type {TuiWithOptionalMinMax} from '@taiga-ui/core/types'; @Component({ standalone: true, @@ -21,7 +20,7 @@ import type {TuiWithOptionalMinMax} from '@taiga-ui/core/types'; styleUrls: ['./calendar-spin.style.less'], changeDetection: ChangeDetectionStrategy.OnPush, }) -export class TuiCalendarSpinComponent implements TuiWithOptionalMinMax { +export class TuiCalendarSpinComponent { @Input() public value = TuiMonth.currentLocal(); diff --git a/projects/core/components/calendar/calendar.component.ts b/projects/core/components/calendar/calendar.component.ts index 46afe845fdb9..6c61330c465c 100644 --- a/projects/core/components/calendar/calendar.component.ts +++ b/projects/core/components/calendar/calendar.component.ts @@ -17,7 +17,6 @@ import { tuiNullableSame, } from '@taiga-ui/cdk'; import {TuiScrollbarComponent} from '@taiga-ui/core/components/scrollbar'; -import type {TuiWithOptionalMinMax} from '@taiga-ui/core/types'; import { TuiCalendarSheetComponent, @@ -41,7 +40,7 @@ import {TuiCalendarYearComponent} from './calendar-year.component'; styleUrls: ['./calendar.style.less'], changeDetection: ChangeDetectionStrategy.OnPush, }) -export class TuiCalendarComponent implements TuiWithOptionalMinMax { +export class TuiCalendarComponent { private day: TuiDay | TuiDayRange | readonly TuiDay[] | null = null; private view: 'month' | 'year' = 'month'; diff --git a/projects/core/components/data-list/data-list.component.ts b/projects/core/components/data-list/data-list.component.ts index f6829e48bbd6..ef52394a2cb3 100644 --- a/projects/core/components/data-list/data-list.component.ts +++ b/projects/core/components/data-list/data-list.component.ts @@ -76,7 +76,6 @@ export class TuiDataListComponent implements TuiDataListAccessor { tuiMoveFocus(elements.indexOf(current), elements, step); } - // TODO: Consider aria-activedescendant for proper accessibility implementation @HostListener('wheel.silent.passive') @HostListener('mouseleave', ['$event.target']) @HostListener('keydown.tab') diff --git a/projects/core/components/data-list/option.component.ts b/projects/core/components/data-list/option.component.ts index e77239f07d93..07de8a98aae8 100644 --- a/projects/core/components/data-list/option.component.ts +++ b/projects/core/components/data-list/option.component.ts @@ -81,7 +81,6 @@ export class TuiOptionComponent implements OnDestroy { } } - // @bad TODO: Consider aria-activedescendant for proper accessibility implementation protected onMouseMove(): void { if (!this.isMobile && !tuiIsNativeFocused(this.el)) { this.el.focus({preventScroll: true}); diff --git a/projects/core/components/expand/test/expand.component.spec.ts b/projects/core/components/expand/test/expand.component.spec.ts index 9612fdf1d237..e39398d430b0 100644 --- a/projects/core/components/expand/test/expand.component.spec.ts +++ b/projects/core/components/expand/test/expand.component.spec.ts @@ -4,6 +4,7 @@ import {fakeAsync, TestBed, tick} from '@angular/core/testing'; import type {TuiExpandComponent} from '@taiga-ui/core'; import {TUI_EXPAND_LOADED, TuiExpand} from '@taiga-ui/core'; import {TuiPageObject} from '@taiga-ui/testing'; +import {NG_EVENT_PLUGINS} from '@tinkoff/ng-event-plugins'; const ANIMATION_DELAY = 900; @@ -45,8 +46,7 @@ describe('expand', () => { beforeEach(async () => { TestBed.configureTestingModule({ imports: [TestComponent], - // TODO: why tests are failed with NG_EVENT_PLUGINS - // providers: [NG_EVENT_PLUGINS], + providers: [NG_EVENT_PLUGINS], }); await TestBed.compileComponents(); fixture = TestBed.createComponent(TestComponent); @@ -148,7 +148,7 @@ describe('expand', () => { * JSDOM doesn't support native transitionend */ function transitionend(): void { - const event = new Event('transitionend.self'); + const event = new Event('transitionend'); (event as any).propertyName = 'opacity'; testComponent.expandElement.nativeElement.dispatchEvent(event); diff --git a/projects/core/components/group/group.style.less b/projects/core/components/group/group.style.less index 669e0f2e252b..cafae496a110 100644 --- a/projects/core/components/group/group.style.less +++ b/projects/core/components/group/group.style.less @@ -1,5 +1,6 @@ @import '@taiga-ui/core/styles/taiga-ui-local'; +// TODO: Refactor .tui-group { position: relative; display: flex; @@ -7,11 +8,6 @@ --t-radius: var(--tui-radius-m); - // TODO: Remove this hack after accordion redesign - tui-accordion& { - width: 100%; - } - & > * { flex: 1 1 0; min-width: 0; diff --git a/projects/core/components/label/label.directive.ts b/projects/core/components/label/label.directive.ts index d4cf1a44beff..3e4778fe1f58 100644 --- a/projects/core/components/label/label.directive.ts +++ b/projects/core/components/label/label.directive.ts @@ -27,7 +27,7 @@ class TuiLabelStyles {} standalone: true, selector: 'label[tuiLabel]', host: { - '[attr.for]': 'el.htmlFor || parent?.id', + '[attr.for]': 'el.htmlFor || parent?.input.id', '[class._textfield]': 'textfield', }, }) diff --git a/projects/core/components/scrollbar/scrollbar.directive.ts b/projects/core/components/scrollbar/scrollbar.directive.ts index 9d45a14f27cf..02fc4a463f15 100644 --- a/projects/core/components/scrollbar/scrollbar.directive.ts +++ b/projects/core/components/scrollbar/scrollbar.directive.ts @@ -1,7 +1,7 @@ import {Directive, inject, Input, NgZone} from '@angular/core'; import {takeUntilDestroyed} from '@angular/core/rxjs-interop'; import {ANIMATION_FRAME} from '@ng-web-apis/common'; -import {POLLING_TIME, tuiInjectElement, tuiScrollFrom, tuiZonefree} from '@taiga-ui/cdk'; +import {tuiInjectElement, tuiScrollFrom, tuiZonefree} from '@taiga-ui/cdk'; import {TUI_SCROLL_REF} from '@taiga-ui/core/tokens'; import {merge, throttleTime} from 'rxjs'; @@ -27,7 +27,7 @@ export class TuiScrollbarDirective { }); protected readonly styleSub = merge( - inject(ANIMATION_FRAME).pipe(throttleTime(POLLING_TIME)), + inject(ANIMATION_FRAME).pipe(throttleTime(100)), tuiScrollFrom(this.el), ) .pipe(tuiZonefree(inject(NgZone)), takeUntilDestroyed()) diff --git a/projects/core/components/svg-defs-host/svg-defs-host.component.ts b/projects/core/components/svg-defs-host/svg-defs-host.component.ts index e0a64ef40998..4f5d9e2864a7 100644 --- a/projects/core/components/svg-defs-host/svg-defs-host.component.ts +++ b/projects/core/components/svg-defs-host/svg-defs-host.component.ts @@ -12,7 +12,7 @@ import {takeUntilDestroyed} from '@angular/core/rxjs-interop'; import type {SafeHtml} from '@angular/platform-browser'; import {TuiSvgService} from '@taiga-ui/core/services'; -// TODO: Consider for legacy in 4.0 +// TODO: Move to legacy in 4.0 @Component({ standalone: true, selector: 'tui-svg-defs-host', @@ -28,7 +28,6 @@ export class TuiSvgDefsHostComponent implements OnInit { protected readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID)); protected items!: IterableIterator; - // @bad TODO: Looks like it could be async piped but it was probably written like that for a reason public ngOnInit(): void { this.svgService.items$ .pipe(takeUntilDestroyed(this.destroyRef)) diff --git a/projects/core/components/svg/svg.component.ts b/projects/core/components/svg/svg.component.ts index 0dafa687a301..b0ec733a816d 100644 --- a/projects/core/components/svg/svg.component.ts +++ b/projects/core/components/svg/svg.component.ts @@ -41,7 +41,7 @@ export interface TuiIconError { readonly message: string; } -// TODO: Consider moving to CDK along with SvgService and SvgDefsHostComponent +// TODO: Move to legacy along with all related infrastructure SvgService and SvgDefsHostComponent @Component({ standalone: true, selector: 'tui-svg', @@ -69,6 +69,7 @@ export class TuiSvgComponent { protected readonly innerHTML$: Observable; constructor() { + // TODO: Consider legacy mode where all icons are treated as external to support new icons this.innerHTML$ = this.src$.pipe( switchMap(() => { if (tuiIsString(this.icon)) { diff --git a/projects/core/components/textfield/textfield.component.ts b/projects/core/components/textfield/textfield.component.ts index ae95fdb69f1b..55b925281e27 100644 --- a/projects/core/components/textfield/textfield.component.ts +++ b/projects/core/components/textfield/textfield.component.ts @@ -9,16 +9,8 @@ import { } from '@angular/core'; import {NgControl} from '@angular/forms'; import {ResizeObserverModule} from '@ng-web-apis/resize-observer'; -import type { - TuiContext, - TuiFocusableElementAccessor, - TuiStringHandler, -} from '@taiga-ui/cdk'; -import { - tuiAsFocusableItemAccessor, - tuiIsNativeFocused, - TuiNativeValidatorDirective, -} from '@taiga-ui/cdk'; +import type {TuiContext, TuiStringHandler} from '@taiga-ui/cdk'; +import {tuiIsNativeFocused, TuiNativeValidatorDirective} from '@taiga-ui/cdk'; import {TuiButtonDirective} from '@taiga-ui/core/components/button'; import type {TuiDataListHost} from '@taiga-ui/core/components/data-list'; import {tuiAsDataListHost, TuiWithDataList} from '@taiga-ui/core/components/data-list'; @@ -32,7 +24,6 @@ import { import {TuiIconsDirective} from '@taiga-ui/core/directives/icons'; import type {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; import {PolymorpheusModule} from '@tinkoff/ng-polymorpheus'; -import {EMPTY} from 'rxjs'; import {TuiTextfieldDirective} from './textfield.directive'; import {TUI_TEXTFIELD_OPTIONS, TuiTextfieldOptionsDirective} from './textfield.options'; @@ -49,7 +40,6 @@ export interface TuiTextfieldContext extends TuiContext { styleUrls: ['./textfield.style.less'], changeDetection: ChangeDetectionStrategy.OnPush, providers: [ - tuiAsFocusableItemAccessor(TuiTextfieldComponent), tuiAsDataListHost(TuiTextfieldComponent), tuiAppearanceOptionsProvider(TUI_TEXTFIELD_OPTIONS), tuiDropdownOptionsProvider({limitWidth: 'fixed'}), @@ -75,9 +65,7 @@ export interface TuiTextfieldContext extends TuiContext { }, ], }) -export class TuiTextfieldComponent - implements TuiDataListHost, TuiFocusableElementAccessor -{ +export class TuiTextfieldComponent implements TuiDataListHost { @ContentChild(TuiTextfieldDirective, {read: ElementRef}) private readonly el?: ElementRef; @@ -108,15 +96,12 @@ export class TuiTextfieldComponent @Input() public content: PolymorpheusContent>; - // TODO: Refactor - public readonly focusedChange = EMPTY; - - public get nativeFocusableElement(): HTMLInputElement { - return this.input; - } + public get input(): HTMLInputElement { + if (!this.el) { + throw new Error('[tuiTextfield] component is required'); + } - public get id(): string { - return this.input.id || ''; + return this.el.nativeElement; } // TODO: Do not change to `this.input`, will be refactored @@ -129,14 +114,6 @@ export class TuiTextfieldComponent this.dropdown?.toggle(false); } - protected get input(): HTMLInputElement { - if (!this.el) { - throw new Error('[tuiTextfield] component is required'); - } - - return this.el.nativeElement; - } - protected get computedFiller(): string { const value = this.input.value || ''; const filler = value + this.filler.slice(value.length); diff --git a/projects/core/services/svg.service.ts b/projects/core/services/svg.service.ts index f760f6d05423..8414049cf501 100644 --- a/projects/core/services/svg.service.ts +++ b/projects/core/services/svg.service.ts @@ -8,7 +8,7 @@ import {BehaviorSubject} from 'rxjs'; /** * Service for reusing SVGs without inlining each instance - * TODO: Consider for legacy in 4.0 + * TODO: Move to legacy in 4.0 */ @Injectable({ providedIn: 'root', diff --git a/projects/core/styles/theme/variables.less b/projects/core/styles/theme/variables.less index 73025c27cd09..e7adcb19462e 100644 --- a/projects/core/styles/theme/variables.less +++ b/projects/core/styles/theme/variables.less @@ -2,18 +2,15 @@ :root, [tuiTheme='light'][tuiTheme='light'] { - // Deprecated TODO 4.0 delete variables --tui-heading-font and --tui-text-font - --tui-heading-font: 'Manrope', @font-fallback; - --tui-text-font: 'Manrope', @font-fallback; // Fonts - --tui-font-heading: var(--tui-heading-font); + --tui-font-heading: 'Manrope', @font-fallback; --tui-font-heading-1: bold 3.125rem/3.5rem var(--tui-font-heading); --tui-font-heading-2: bold 2.75rem/3rem var(--tui-font-heading); --tui-font-heading-3: bold 2.25rem/2.5rem var(--tui-font-heading); --tui-font-heading-4: bold 1.75rem/2rem var(--tui-font-heading); --tui-font-heading-5: bold 1.5rem/1.75rem var(--tui-font-heading); --tui-font-heading-6: bold 1.25rem/1.5rem var(--tui-font-heading); - --tui-font-text: var(--tui-text-font); + --tui-font-text: 'Manrope', @font-fallback; --tui-font-text-xl: normal 1.1875rem/1.75rem var(--tui-font-text); --tui-font-text-l: normal 1.0625rem/1.75rem var(--tui-font-text); --tui-font-text-l-2: normal 1.0625rem/1.5rem var(--tui-font-text); diff --git a/projects/core/tokens/index.ts b/projects/core/tokens/index.ts index 6e8a639cdceb..f183205e333b 100644 --- a/projects/core/tokens/index.ts +++ b/projects/core/tokens/index.ts @@ -13,8 +13,5 @@ export * from './sanitizer'; export * from './scroll-ref'; export * from './selection-stream'; export * from './spin-icons'; -export * from './textfield-appearance'; -export * from './textfield-host'; export * from './theme'; -export * from './value-accessor'; export * from './viewport'; diff --git a/projects/core/tokens/textfield-host.ts b/projects/core/tokens/textfield-host.ts deleted file mode 100644 index 6aee605678b3..000000000000 --- a/projects/core/tokens/textfield-host.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type {Provider, Type} from '@angular/core'; -import {InjectionToken} from '@angular/core'; -import {tuiProvide} from '@taiga-ui/cdk'; -import type {TuiTextfieldHost} from '@taiga-ui/core/types'; - -/** - * An interface to communicate with textfield based controls - * TODO: Consider moving to legacy in 4.0 - */ -export const TUI_TEXTFIELD_HOST = new InjectionToken( - '[TUI_TEXTFIELD_HOST]', -); - -export function tuiAsTextfieldHost(host: Type): Provider { - return tuiProvide(TUI_TEXTFIELD_HOST, host); -} diff --git a/projects/core/types/index.ts b/projects/core/types/index.ts index a9cc8a976f03..809cef1a6b08 100644 --- a/projects/core/types/index.ts +++ b/projects/core/types/index.ts @@ -5,6 +5,4 @@ export * from './point'; export * from './portal-item'; export * from './range-state'; export * from './size'; -export * from './textfield-host'; export * from './value-content-context'; -export * from './with-optional-min-max'; diff --git a/projects/core/types/point.ts b/projects/core/types/point.ts index 32ed0604be6d..d5e70163d298 100644 --- a/projects/core/types/point.ts +++ b/projects/core/types/point.ts @@ -1 +1,2 @@ +// TODO: Refactor to [x: number, y: number] across the library export type TuiPoint = Readonly<[number, number]>; diff --git a/projects/core/types/with-optional-min-max.ts b/projects/core/types/with-optional-min-max.ts deleted file mode 100644 index c8a57f8860e7..000000000000 --- a/projects/core/types/with-optional-min-max.ts +++ /dev/null @@ -1,5 +0,0 @@ -// @bad TODO: declare methods -export interface TuiWithOptionalMinMax { - max: T | null; - min: T | null; -} diff --git a/projects/core/utils/miscellaneous/icons-path-factory.ts b/projects/core/utils/miscellaneous/icons-path-factory.ts index f491e2a2504d..2df61e2c250a 100644 --- a/projects/core/utils/miscellaneous/icons-path-factory.ts +++ b/projects/core/utils/miscellaneous/icons-path-factory.ts @@ -6,6 +6,7 @@ export const TUI_CACHE_BUSTING_PAYLOAD = `?v=${TUI_VERSION}` as const; export const DEFAULT_ICONS_PATH: TuiStringHandler = name => name.includes('.svg#') ? name : `#${name}`; +// TODO: Move to legacy with tui-svg export function tuiIconsPathFactory(staticPath: string): TuiStringHandler { const base = staticPath.endsWith('/') ? staticPath : `${staticPath}/`; diff --git a/projects/core/utils/miscellaneous/index.ts b/projects/core/utils/miscellaneous/index.ts index 610f37bac890..02908df745c9 100644 --- a/projects/core/utils/miscellaneous/index.ts +++ b/projects/core/utils/miscellaneous/index.ts @@ -1,4 +1,3 @@ -export * from './get-border'; export * from './icons-path-factory'; export * from './is-editing-key'; export * from './is-obscured'; diff --git a/projects/core/utils/miscellaneous/is-presumed-html-string.ts b/projects/core/utils/miscellaneous/is-presumed-html-string.ts index 0aeb15c480ee..0fbea517da32 100644 --- a/projects/core/utils/miscellaneous/is-presumed-html-string.ts +++ b/projects/core/utils/miscellaneous/is-presumed-html-string.ts @@ -1,3 +1,4 @@ +// TODO: Move to legacy with tui-svg export function tuiIsPresumedHTMLString(candidate: string): boolean { const trimmed = candidate.trim(); diff --git a/projects/demo/src/modules/components/abstract/control.ts b/projects/demo/src/modules/components/abstract/control.ts index 9a278c31348f..c87ec07f4908 100644 --- a/projects/demo/src/modules/components/abstract/control.ts +++ b/projects/demo/src/modules/components/abstract/control.ts @@ -1,5 +1,4 @@ import type {AbstractControl} from '@angular/forms'; -import type {TuiInputMode, TuiInputType} from '@taiga-ui/cdk'; import type { TuiDropdownAlign, TuiDropdownWidth, @@ -41,7 +40,7 @@ export abstract class AbstractExampleTuiControl public readonly hintAppearanceVariants = ['', 'error', 'dark']; - public readonly typeVariants: readonly TuiInputType[] = [ + public readonly typeVariants: readonly string[] = [ 'text', 'email', 'password', @@ -51,7 +50,7 @@ export abstract class AbstractExampleTuiControl public readonly maxLengthVariants: readonly TuiPossibleGenericType[] = [10]; - public readonly inputModeVariants: readonly TuiInputMode[] = ['text', 'numeric']; + public readonly inputModeVariants: readonly string[] = ['text', 'numeric']; public readonly customContentVariants: PolymorpheusContent[] = [ '', @@ -68,7 +67,7 @@ export abstract class AbstractExampleTuiControl public maxLength: TuiPossibleGenericType | null = null; - public type: TuiInputType = this.typeVariants[0]; + public type = this.typeVariants[0]; public cleaner = false; diff --git a/projects/demo/src/modules/components/input-date-range/examples/1/index.ts b/projects/demo/src/modules/components/input-date-range/examples/1/index.ts index cdea6170c23a..b86bc9c217a2 100644 --- a/projects/demo/src/modules/components/input-date-range/examples/1/index.ts +++ b/projects/demo/src/modules/components/input-date-range/examples/1/index.ts @@ -3,8 +3,7 @@ import {FormControl, FormGroup, ReactiveFormsModule} from '@angular/forms'; import {changeDetection} from '@demo/emulate/change-detection'; import {encapsulation} from '@demo/emulate/encapsulation'; import {TuiDay, TuiDayRange} from '@taiga-ui/cdk'; -import {TuiUnfinishedValidatorDirective} from '@taiga-ui/kit'; -import {TuiInputDateRangeModule} from '@taiga-ui/legacy'; +import {TuiInputDateRangeModule, TuiUnfinishedValidatorDirective} from '@taiga-ui/legacy'; @Component({ standalone: true, diff --git a/projects/demo/src/modules/components/input-date/examples/1/index.ts b/projects/demo/src/modules/components/input-date/examples/1/index.ts index 6f53614b823e..6d5f5bebd31c 100644 --- a/projects/demo/src/modules/components/input-date/examples/1/index.ts +++ b/projects/demo/src/modules/components/input-date/examples/1/index.ts @@ -6,7 +6,11 @@ import {encapsulation} from '@demo/emulate/encapsulation'; import {TuiDay} from '@taiga-ui/cdk'; import {TuiErrorComponent} from '@taiga-ui/core'; import {TuiFieldErrorPipe} from '@taiga-ui/kit'; -import {TuiInputDateModule, TuiTextfieldControllerModule} from '@taiga-ui/legacy'; +import { + TuiInputDateModule, + TuiTextfieldControllerModule, + TuiUnfinishedValidatorDirective, +} from '@taiga-ui/legacy'; @Component({ standalone: true, @@ -17,6 +21,7 @@ import {TuiInputDateModule, TuiTextfieldControllerModule} from '@taiga-ui/legacy TuiFieldErrorPipe, ReactiveFormsModule, AsyncPipe, + TuiUnfinishedValidatorDirective, ], templateUrl: './index.html', encapsulation, diff --git a/projects/demo/src/modules/components/input-time/examples/1/index.ts b/projects/demo/src/modules/components/input-time/examples/1/index.ts index 6987f312c5ff..db3bc308ceb2 100644 --- a/projects/demo/src/modules/components/input-time/examples/1/index.ts +++ b/projects/demo/src/modules/components/input-time/examples/1/index.ts @@ -3,8 +3,11 @@ import {FormControl, FormGroup, ReactiveFormsModule} from '@angular/forms'; import {changeDetection} from '@demo/emulate/change-detection'; import {encapsulation} from '@demo/emulate/encapsulation'; import {TuiTime} from '@taiga-ui/cdk'; -import {TuiUnfinishedValidatorDirective} from '@taiga-ui/kit'; -import {TuiInputTimeModule, TuiTextfieldControllerModule} from '@taiga-ui/legacy'; +import { + TuiInputTimeModule, + TuiTextfieldControllerModule, + TuiUnfinishedValidatorDirective, +} from '@taiga-ui/legacy'; @Component({ standalone: true, @@ -13,6 +16,7 @@ import {TuiInputTimeModule, TuiTextfieldControllerModule} from '@taiga-ui/legacy TuiInputTimeModule, TuiTextfieldControllerModule, TuiUnfinishedValidatorDirective, + TuiUnfinishedValidatorDirective, ], templateUrl: './index.html', encapsulation, diff --git a/projects/demo/src/modules/components/primitive-textfield/examples/1/index.ts b/projects/demo/src/modules/components/primitive-textfield/examples/1/index.ts index 73872c760e74..452d21b6b241 100644 --- a/projects/demo/src/modules/components/primitive-textfield/examples/1/index.ts +++ b/projects/demo/src/modules/components/primitive-textfield/examples/1/index.ts @@ -1,8 +1,8 @@ import {Component, ViewChild} from '@angular/core'; import {changeDetection} from '@demo/emulate/change-detection'; import {encapsulation} from '@demo/emulate/encapsulation'; -import type {TuiNativeFocusableElement} from '@taiga-ui/cdk'; import {TuiHintDirective, TuiSvgComponent} from '@taiga-ui/core'; +import type {TuiNativeFocusableElement} from '@taiga-ui/legacy'; import { AbstractTuiControl, TuiPrimitiveTextfieldComponent, diff --git a/projects/demo/src/modules/components/primitive-textfield/examples/2/index.ts b/projects/demo/src/modules/components/primitive-textfield/examples/2/index.ts index 41d8959bc1a5..ecffa8e85a83 100644 --- a/projects/demo/src/modules/components/primitive-textfield/examples/2/index.ts +++ b/projects/demo/src/modules/components/primitive-textfield/examples/2/index.ts @@ -1,8 +1,8 @@ import {Component, ViewChild} from '@angular/core'; import {changeDetection} from '@demo/emulate/change-detection'; import {encapsulation} from '@demo/emulate/encapsulation'; -import type {TuiNativeFocusableElement} from '@taiga-ui/cdk'; import {TuiHintOptionsDirective} from '@taiga-ui/core'; +import type {TuiNativeFocusableElement} from '@taiga-ui/legacy'; import { AbstractTuiControl, TuiPrimitiveTextfieldComponent, diff --git a/projects/demo/src/modules/components/primitive-textfield/index.ts b/projects/demo/src/modules/components/primitive-textfield/index.ts index 40db3221c21d..19df7d6bcd39 100644 --- a/projects/demo/src/modules/components/primitive-textfield/index.ts +++ b/projects/demo/src/modules/components/primitive-textfield/index.ts @@ -4,7 +4,7 @@ import {RouterLink} from '@angular/router'; import {changeDetection} from '@demo/emulate/change-detection'; import {DemoRoute} from '@demo/routes'; import {TuiDemo} from '@demo/utils'; -import type {TuiContext, TuiInputMode, TuiInputType} from '@taiga-ui/cdk'; +import type {TuiContext} from '@taiga-ui/cdk'; import {tuiProvide} from '@taiga-ui/cdk'; import type {TuiSizeL, TuiSizeS} from '@taiga-ui/core'; import { @@ -84,7 +84,7 @@ export default class PageComponent extends AbstractExampleTuiInteractive { protected iconLeft = ''; - protected readonly typeVariants: readonly TuiInputType[] = [ + protected readonly typeVariants: readonly string[] = [ 'text', 'email', 'password', @@ -106,7 +106,7 @@ export default class PageComponent extends AbstractExampleTuiInteractive { protected maxLength = null; - protected readonly inputModeVariants: readonly TuiInputMode[] = ['text', 'numeric']; + protected readonly inputModeVariants: readonly string[] = ['text', 'numeric']; protected inputMode = this.inputModeVariants[0]; diff --git a/projects/demo/src/modules/components/utils/tokens/examples/2/index.html b/projects/demo/src/modules/components/utils/tokens/examples/2/index.html index 9baaefb6b5f2..74e51b6b842d 100644 --- a/projects/demo/src/modules/components/utils/tokens/examples/2/index.html +++ b/projects/demo/src/modules/components/utils/tokens/examples/2/index.html @@ -1,4 +1,19 @@

- All Taiga UI components that can be focused provide this token so you can inject them into your directives that work - with focus. + A token with a factory. It takes + + TUI_IS_MOBILE + + and + + TUI_IS_IOS + + , returns true if the device is mobile but not iOS (technically includes Windows Phone, Blackberry etc.)

diff --git a/projects/demo/src/modules/components/utils/tokens/examples/2/index.ts b/projects/demo/src/modules/components/utils/tokens/examples/2/index.ts index c18bd511b205..f8a844b171aa 100644 --- a/projects/demo/src/modules/components/utils/tokens/examples/2/index.ts +++ b/projects/demo/src/modules/components/utils/tokens/examples/2/index.ts @@ -1,14 +1,17 @@ import {Component, inject} from '@angular/core'; +import {RouterLink} from '@angular/router'; import {changeDetection} from '@demo/emulate/change-detection'; import {encapsulation} from '@demo/emulate/encapsulation'; -import {TUI_FOCUSABLE_ITEM_ACCESSOR} from '@taiga-ui/cdk'; +import {TUI_IS_ANDROID} from '@taiga-ui/cdk'; +import {TuiLinkDirective} from '@taiga-ui/core'; @Component({ standalone: true, + imports: [RouterLink, TuiLinkDirective], templateUrl: './index.html', encapsulation, changeDetection, }) export default class ExampleComponent { - protected readonly focusable = inject(TUI_FOCUSABLE_ITEM_ACCESSOR, {optional: true}); + protected readonly isAndroid = inject(TUI_IS_ANDROID); } diff --git a/projects/demo/src/modules/components/utils/tokens/examples/3/index.html b/projects/demo/src/modules/components/utils/tokens/examples/3/index.html index 74e51b6b842d..2b0b3c564cf1 100644 --- a/projects/demo/src/modules/components/utils/tokens/examples/3/index.html +++ b/projects/demo/src/modules/components/utils/tokens/examples/3/index.html @@ -7,13 +7,5 @@ > TUI_IS_MOBILE - and - - TUI_IS_IOS - - , returns true if the device is mobile but not iOS (technically includes Windows Phone, Blackberry etc.) + and if it is true detects iOS devices with a regex

diff --git a/projects/demo/src/modules/components/utils/tokens/examples/3/index.ts b/projects/demo/src/modules/components/utils/tokens/examples/3/index.ts index f8a844b171aa..275bde4d9831 100644 --- a/projects/demo/src/modules/components/utils/tokens/examples/3/index.ts +++ b/projects/demo/src/modules/components/utils/tokens/examples/3/index.ts @@ -2,16 +2,16 @@ import {Component, inject} from '@angular/core'; import {RouterLink} from '@angular/router'; import {changeDetection} from '@demo/emulate/change-detection'; import {encapsulation} from '@demo/emulate/encapsulation'; -import {TUI_IS_ANDROID} from '@taiga-ui/cdk'; +import {TUI_IS_IOS} from '@taiga-ui/cdk'; import {TuiLinkDirective} from '@taiga-ui/core'; @Component({ standalone: true, - imports: [RouterLink, TuiLinkDirective], + imports: [TuiLinkDirective, RouterLink], templateUrl: './index.html', encapsulation, changeDetection, }) export default class ExampleComponent { - protected readonly isAndroid = inject(TUI_IS_ANDROID); + protected readonly isIos = inject(TUI_IS_IOS); } diff --git a/projects/demo/src/modules/components/utils/tokens/examples/4/index.html b/projects/demo/src/modules/components/utils/tokens/examples/4/index.html index 2b0b3c564cf1..c18c8e91e158 100644 --- a/projects/demo/src/modules/components/utils/tokens/examples/4/index.html +++ b/projects/demo/src/modules/components/utils/tokens/examples/4/index.html @@ -1,11 +1,4 @@

- A token with a factory. It takes - - TUI_IS_MOBILE - - and if it is true detects iOS devices with a regex + A token with a factory. It takes USER_AGENT token and parses it with a complex Regex to detect users with mobile + devices

diff --git a/projects/demo/src/modules/components/utils/tokens/examples/4/index.ts b/projects/demo/src/modules/components/utils/tokens/examples/4/index.ts index 275bde4d9831..0431e96c0411 100644 --- a/projects/demo/src/modules/components/utils/tokens/examples/4/index.ts +++ b/projects/demo/src/modules/components/utils/tokens/examples/4/index.ts @@ -1,17 +1,14 @@ import {Component, inject} from '@angular/core'; -import {RouterLink} from '@angular/router'; import {changeDetection} from '@demo/emulate/change-detection'; import {encapsulation} from '@demo/emulate/encapsulation'; -import {TUI_IS_IOS} from '@taiga-ui/cdk'; -import {TuiLinkDirective} from '@taiga-ui/core'; +import {TUI_IS_MOBILE} from '@taiga-ui/cdk'; @Component({ standalone: true, - imports: [TuiLinkDirective, RouterLink], templateUrl: './index.html', encapsulation, changeDetection, }) export default class ExampleComponent { - protected readonly isIos = inject(TUI_IS_IOS); + protected readonly isMobile = inject(TUI_IS_MOBILE); } diff --git a/projects/demo/src/modules/components/utils/tokens/examples/5/index.html b/projects/demo/src/modules/components/utils/tokens/examples/5/index.html index c18c8e91e158..904ea55f6dbb 100644 --- a/projects/demo/src/modules/components/utils/tokens/examples/5/index.html +++ b/projects/demo/src/modules/components/utils/tokens/examples/5/index.html @@ -1,4 +1,77 @@ -

- A token with a factory. It takes USER_AGENT token and parses it with a complex Regex to detect users with mobile - devices -

+
+
+ Using + TUI_NUMBER_FORMAT + injection token you can customize numbers formatting. +
+
For example: 10 500,33
+
Can be customized as: 10/500.33
+ +
+

Defaults:

+
    +
  • + decimalSeparator = + , +
  • +
  • + thousandSeparator = + CHAR_NO_BREAK_SPACE +
  • +
  • + zeroPadding = + true +
  • +
  • + rounding = + truncate +
  • +
+
+ +
+

Components that are customizable:

+ +
+
diff --git a/projects/demo/src/modules/components/utils/tokens/examples/5/index.ts b/projects/demo/src/modules/components/utils/tokens/examples/5/index.ts index 0431e96c0411..28eb5c4f078f 100644 --- a/projects/demo/src/modules/components/utils/tokens/examples/5/index.ts +++ b/projects/demo/src/modules/components/utils/tokens/examples/5/index.ts @@ -1,14 +1,16 @@ -import {Component, inject} from '@angular/core'; +import {Component} from '@angular/core'; +import {RouterLink} from '@angular/router'; import {changeDetection} from '@demo/emulate/change-detection'; import {encapsulation} from '@demo/emulate/encapsulation'; -import {TUI_IS_MOBILE} from '@taiga-ui/cdk'; +import {DemoRoute} from '@demo/routes'; @Component({ standalone: true, + imports: [RouterLink], templateUrl: './index.html', encapsulation, changeDetection, }) export default class ExampleComponent { - protected readonly isMobile = inject(TUI_IS_MOBILE); + protected readonly routes = DemoRoute; } diff --git a/projects/demo/src/modules/components/utils/tokens/examples/6/index.html b/projects/demo/src/modules/components/utils/tokens/examples/6/index.html index 904ea55f6dbb..44033871d582 100644 --- a/projects/demo/src/modules/components/utils/tokens/examples/6/index.html +++ b/projects/demo/src/modules/components/utils/tokens/examples/6/index.html @@ -1,30 +1,40 @@
Using - TUI_NUMBER_FORMAT + TUI_DATE_FORMAT injection token you can customize numbers formatting.
-
For example: 10 500,33
-
Can be customized as: 10/500.33
+
For example: 10.01.2024
+
Can be customized as: 2024/01/10
+ +
+

Description:

+
+
+ mode +
+
+ active date format ( + 'DMY' | 'MDY' | 'YMD' + ) +
+
+ separator +
+
single-character date's separator (dot, slash etc.)
+
+

Defaults:

  • - decimalSeparator = - , -
  • -
  • - thousandSeparator = - CHAR_NO_BREAK_SPACE -
  • -
  • - zeroPadding = - true + mode = + DMY
  • - rounding = - truncate + separator = + .
@@ -35,41 +45,33 @@

Components that are customizable:

  • - TuiAmount - -
  • -
  • - - TuiFormatNumberPipe + TuiInputDate
  • - TuiInputNumberComponent + TuiInputDateRange
  • - TuiInputSliderComponent + TuiInputDateTime
  • - TuiInputRangeComponent + TuiInputDateMulti
  • diff --git a/projects/demo/src/modules/components/utils/tokens/examples/6/index.ts b/projects/demo/src/modules/components/utils/tokens/examples/6/index.ts index 28eb5c4f078f..e763d5114147 100644 --- a/projects/demo/src/modules/components/utils/tokens/examples/6/index.ts +++ b/projects/demo/src/modules/components/utils/tokens/examples/6/index.ts @@ -3,10 +3,11 @@ import {RouterLink} from '@angular/router'; import {changeDetection} from '@demo/emulate/change-detection'; import {encapsulation} from '@demo/emulate/encapsulation'; import {DemoRoute} from '@demo/routes'; +import {TuiLinkDirective} from '@taiga-ui/core'; @Component({ standalone: true, - imports: [RouterLink], + imports: [TuiLinkDirective, RouterLink], templateUrl: './index.html', encapsulation, changeDetection, diff --git a/projects/demo/src/modules/components/utils/tokens/examples/7/index.html b/projects/demo/src/modules/components/utils/tokens/examples/7/index.html index 44033871d582..41b3855958bb 100644 --- a/projects/demo/src/modules/components/utils/tokens/examples/7/index.html +++ b/projects/demo/src/modules/components/utils/tokens/examples/7/index.html @@ -1,79 +1,25 @@ -
    -
    - Using - TUI_DATE_FORMAT - injection token you can customize numbers formatting. -
    -
    For example: 10.01.2024
    -
    Can be customized as: 2024/01/10
    +

    + Use + TUI_FIRST_DAY_OF_WEEK + injection token to change start day of the week (Monday by default). +

    -
    -

    Description:

    -
    -
    - mode -
    -
    - active date format ( - 'DMY' | 'MDY' | 'YMD' - ) -
    -
    - separator -
    -
    single-character date's separator (dot, slash etc.)
    -
    -
    + -
    -

    Defaults:

    -
      -
    • - mode = - DMY -
    • -
    • - separator = - . -
    • -
    -
    - -
    -

    Components that are customizable:

    - -
    -
    +
    +

    This token can customize the following components:

    + +
    diff --git a/projects/demo/src/modules/components/utils/tokens/examples/7/index.ts b/projects/demo/src/modules/components/utils/tokens/examples/7/index.ts index e763d5114147..35f066dcdb89 100644 --- a/projects/demo/src/modules/components/utils/tokens/examples/7/index.ts +++ b/projects/demo/src/modules/components/utils/tokens/examples/7/index.ts @@ -1,17 +1,45 @@ +import {NgForOf} from '@angular/common'; import {Component} from '@angular/core'; import {RouterLink} from '@angular/router'; import {changeDetection} from '@demo/emulate/change-detection'; import {encapsulation} from '@demo/emulate/encapsulation'; -import {DemoRoute} from '@demo/routes'; -import {TuiLinkDirective} from '@taiga-ui/core'; +import {TuiDocCodeComponent} from '@taiga-ui/addon-doc'; +import {TuiDayOfWeek} from '@taiga-ui/cdk'; +import {TUI_FIRST_DAY_OF_WEEK, TuiLinkDirective} from '@taiga-ui/core'; @Component({ standalone: true, - imports: [TuiLinkDirective, RouterLink], + imports: [TuiDocCodeComponent, NgForOf, TuiLinkDirective, RouterLink], templateUrl: './index.html', encapsulation, changeDetection, + providers: [ + { + provide: TUI_FIRST_DAY_OF_WEEK, + useValue: TuiDayOfWeek.Sunday, + }, + ], }) export default class ExampleComponent { - protected readonly routes = DemoRoute; + protected readonly provideFirstDayOfWeekToken = import( + './provide-first-day-of-week-token.md?raw' + ); + + protected readonly customizableComponentsViaThisToken = [ + { + name: 'Calendar', + link: '/components/calendar', + fragment: 'localization', + }, + { + name: 'CalendarRange', + link: '/components/calendar-range', + fragment: 'localization', + }, + { + name: 'MobileCalendar', + link: '/components/mobile-calendar', + fragment: 'localization', + }, + ] as const; } diff --git a/projects/demo/src/modules/components/utils/tokens/examples/8/provide-first-day-of-week-token.md b/projects/demo/src/modules/components/utils/tokens/examples/7/provide-first-day-of-week-token.md similarity index 100% rename from projects/demo/src/modules/components/utils/tokens/examples/8/provide-first-day-of-week-token.md rename to projects/demo/src/modules/components/utils/tokens/examples/7/provide-first-day-of-week-token.md diff --git a/projects/demo/src/modules/components/utils/tokens/examples/8/index.html b/projects/demo/src/modules/components/utils/tokens/examples/8/index.html deleted file mode 100644 index 41b3855958bb..000000000000 --- a/projects/demo/src/modules/components/utils/tokens/examples/8/index.html +++ /dev/null @@ -1,25 +0,0 @@ -

    - Use - TUI_FIRST_DAY_OF_WEEK - injection token to change start day of the week (Monday by default). -

    - - - -
    -

    This token can customize the following components:

    - -
    diff --git a/projects/demo/src/modules/components/utils/tokens/examples/8/index.ts b/projects/demo/src/modules/components/utils/tokens/examples/8/index.ts deleted file mode 100644 index 35f066dcdb89..000000000000 --- a/projects/demo/src/modules/components/utils/tokens/examples/8/index.ts +++ /dev/null @@ -1,45 +0,0 @@ -import {NgForOf} from '@angular/common'; -import {Component} from '@angular/core'; -import {RouterLink} from '@angular/router'; -import {changeDetection} from '@demo/emulate/change-detection'; -import {encapsulation} from '@demo/emulate/encapsulation'; -import {TuiDocCodeComponent} from '@taiga-ui/addon-doc'; -import {TuiDayOfWeek} from '@taiga-ui/cdk'; -import {TUI_FIRST_DAY_OF_WEEK, TuiLinkDirective} from '@taiga-ui/core'; - -@Component({ - standalone: true, - imports: [TuiDocCodeComponent, NgForOf, TuiLinkDirective, RouterLink], - templateUrl: './index.html', - encapsulation, - changeDetection, - providers: [ - { - provide: TUI_FIRST_DAY_OF_WEEK, - useValue: TuiDayOfWeek.Sunday, - }, - ], -}) -export default class ExampleComponent { - protected readonly provideFirstDayOfWeekToken = import( - './provide-first-day-of-week-token.md?raw' - ); - - protected readonly customizableComponentsViaThisToken = [ - { - name: 'Calendar', - link: '/components/calendar', - fragment: 'localization', - }, - { - name: 'CalendarRange', - link: '/components/calendar-range', - fragment: 'localization', - }, - { - name: 'MobileCalendar', - link: '/components/mobile-calendar', - fragment: 'localization', - }, - ] as const; -} diff --git a/projects/demo/src/modules/components/utils/tokens/index.html b/projects/demo/src/modules/components/utils/tokens/index.html index 0f7c96764dff..18b10cc953aa 100644 --- a/projects/demo/src/modules/components/utils/tokens/index.html +++ b/projects/demo/src/modules/components/utils/tokens/index.html @@ -13,59 +13,51 @@ [fullsize]="true" /> - - diff --git a/projects/demo/src/modules/directives/textfield-controller/index.ts b/projects/demo/src/modules/directives/textfield-controller/index.ts index 3965456ea21f..682671d783ff 100644 --- a/projects/demo/src/modules/directives/textfield-controller/index.ts +++ b/projects/demo/src/modules/directives/textfield-controller/index.ts @@ -4,7 +4,6 @@ import {RouterLink} from '@angular/router'; import {changeDetection} from '@demo/emulate/change-detection'; import {DemoRoute} from '@demo/routes'; import {TuiDemo} from '@demo/utils'; -import type {TuiInputMode, TuiInputType} from '@taiga-ui/cdk'; import type {TuiSizeL, TuiSizeS} from '@taiga-ui/core'; import {TuiLinkDirective, TuiTextfieldOptionsDirective} from '@taiga-ui/core'; import {TuiInputModule, TuiTextfieldControllerModule} from '@taiga-ui/legacy'; @@ -26,11 +25,11 @@ import {TuiInputModule, TuiTextfieldControllerModule} from '@taiga-ui/legacy'; export default class PageComponent { protected readonly sizeVariants: ReadonlyArray = ['s', 'm', 'l']; - protected readonly inputModeVariants: readonly TuiInputMode[] = ['text', 'numeric']; + protected readonly inputModeVariants: readonly string[] = ['text', 'numeric']; protected readonly maxLengthVariants: readonly number[] = [10]; - protected readonly typeVariants: readonly TuiInputType[] = [ + protected readonly typeVariants: readonly string[] = [ 'text', 'email', 'password', @@ -38,7 +37,7 @@ export default class PageComponent { 'url', ]; - protected type: TuiInputType = this.typeVariants[0]; + protected type = this.typeVariants[0]; protected readonly customContentVariants = ['', 'Bell']; diff --git a/projects/experimental/components/tooltip/tooltip.component.ts b/projects/experimental/components/tooltip/tooltip.component.ts index 84934ac8b374..1484a926ce25 100644 --- a/projects/experimental/components/tooltip/tooltip.component.ts +++ b/projects/experimental/components/tooltip/tooltip.component.ts @@ -42,7 +42,7 @@ export class TuiTooltipComponent extends TuiHintOptionsDirective { public context?: C; protected get id(): string { - return this.describeId || this.textfield?.id || ''; + return this.describeId || this.textfield?.input.id || ''; } protected get computedAppearance(): string { diff --git a/projects/kit/components/accordion/accordion-item.style.less b/projects/kit/components/accordion/accordion-item.style.less index 61aaf2d0a7d9..842dacc20596 100644 --- a/projects/kit/components/accordion/accordion-item.style.less +++ b/projects/kit/components/accordion/accordion-item.style.less @@ -13,6 +13,10 @@ } } +::ng-deep tui-accordion { + width: 100%; +} + .t-wrapper { position: relative; border-radius: inherit; diff --git a/projects/kit/components/calendar-month/calendar-month.component.ts b/projects/kit/components/calendar-month/calendar-month.component.ts index 2bb65279a0db..67d9f2857620 100644 --- a/projects/kit/components/calendar-month/calendar-month.component.ts +++ b/projects/kit/components/calendar-month/calendar-month.component.ts @@ -22,7 +22,7 @@ import { tuiPure, TuiYear, } from '@taiga-ui/cdk'; -import type {TuiRangeState, TuiWithOptionalMinMax} from '@taiga-ui/core'; +import type {TuiRangeState} from '@taiga-ui/core'; import { TuiCalendarYearComponent, TuiLinkDirective, @@ -51,7 +51,7 @@ const TODAY = TuiDay.currentLocal(); styleUrls: ['./calendar-month.style.less'], changeDetection: ChangeDetectionStrategy.OnPush, }) -export class TuiCalendarMonthComponent implements TuiWithOptionalMinMax { +export class TuiCalendarMonthComponent { protected isYearPickerShown = false; protected readonly months$ = inject(TUI_CALENDAR_MONTHS); diff --git a/projects/kit/components/calendar-range/calendar-range.component.ts b/projects/kit/components/calendar-range/calendar-range.component.ts index 6fc3857f016a..ecf216f1bc6a 100644 --- a/projects/kit/components/calendar-range/calendar-range.component.ts +++ b/projects/kit/components/calendar-range/calendar-range.component.ts @@ -24,7 +24,7 @@ import { tuiPure, tuiWatch, } from '@taiga-ui/cdk'; -import type {TuiMarkerHandler, TuiWithOptionalMinMax} from '@taiga-ui/core'; +import type {TuiMarkerHandler} from '@taiga-ui/core'; import { TUI_COMMON_ICONS, TuiCalendarComponent, @@ -53,9 +53,7 @@ import type {TuiDayRangePeriod} from './day-range-period'; styleUrls: ['./calendar-range.style.less'], changeDetection: ChangeDetectionStrategy.OnPush, }) -export class TuiCalendarRangeComponent - implements OnChanges, TuiWithOptionalMinMax -{ +export class TuiCalendarRangeComponent implements OnChanges { protected readonly otherDateText$ = inject(TUI_OTHER_DATE_TEXT); protected readonly icons = inject(TUI_COMMON_ICONS); protected previousValue: TuiDayRange | null = null; diff --git a/projects/kit/components/pagination/pagination.component.ts b/projects/kit/components/pagination/pagination.component.ts index 0c0df8cd8cb5..9d220ec6bae4 100644 --- a/projects/kit/components/pagination/pagination.component.ts +++ b/projects/kit/components/pagination/pagination.component.ts @@ -9,7 +9,7 @@ import { Output, ViewChildren, } from '@angular/core'; -import type {TuiContext, TuiNativeFocusableElement} from '@taiga-ui/cdk'; +import type {TuiContext} from '@taiga-ui/cdk'; import { EMPTY_QUERY, tuiClamp, @@ -78,7 +78,7 @@ export class TuiPaginationComponent { @Output() public readonly indexChange = new EventEmitter(); - public get nativeFocusableElement(): TuiNativeFocusableElement | null { + public get nativeFocusableElement(): HTMLElement | null { if (this.disabled) { return null; } diff --git a/projects/kit/components/range/range.component.ts b/projects/kit/components/range/range.component.ts index 767fc500c4f3..d81b30cec03c 100644 --- a/projects/kit/components/range/range.component.ts +++ b/projects/kit/components/range/range.component.ts @@ -20,7 +20,7 @@ import { tuiPure, tuiQuantize, } from '@taiga-ui/cdk'; -import type {TuiSizeS, TuiWithOptionalMinMax} from '@taiga-ui/core'; +import type {TuiSizeS} from '@taiga-ui/core'; import type {TuiKeySteps} from '@taiga-ui/kit/components/slider'; import { tuiKeyStepValueToPercentage, @@ -54,10 +54,7 @@ import {TuiRangeChangeDirective} from './range-change.directive'; }, providers: [tuiFallbackValueProvider([0, 0])], }) -export class TuiRangeComponent - extends TuiControl<[number, number]> - implements TuiWithOptionalMinMax, OnChanges -{ +export class TuiRangeComponent extends TuiControl<[number, number]> implements OnChanges { // TODO: workaround until we get signal inputs private readonly changes = signal(1); private readonly el = tuiInjectElement(); diff --git a/projects/kit/directives/unfinished-validator/unfinished-validator.directive.ts b/projects/kit/directives/unfinished-validator/unfinished-validator.directive.ts index 431660c4591a..15d16d87e436 100644 --- a/projects/kit/directives/unfinished-validator/unfinished-validator.directive.ts +++ b/projects/kit/directives/unfinished-validator/unfinished-validator.directive.ts @@ -1,20 +1,18 @@ -import {Directive, inject, INJECTOR} from '@angular/core'; +import {Directive} from '@angular/core'; import type {Validator} from '@angular/forms'; import {NG_VALIDATORS} from '@angular/forms'; -import {TUI_FOCUSABLE_ITEM_ACCESSOR, tuiInjectElement, tuiProvide} from '@taiga-ui/cdk'; +import {tuiInjectElement, tuiProvide} from '@taiga-ui/cdk'; import {tuiCreateUnfinishedValidator} from './unfinished.validator'; @Directive({ standalone: true, - selector: '[tuiUnfinishedValidator]', + selector: 'input[tuiUnfinishedValidator]', providers: [tuiProvide(NG_VALIDATORS, TuiUnfinishedValidatorDirective, true)], }) export class TuiUnfinishedValidatorDirective implements Validator { - private readonly injector = inject(INJECTOR); - public readonly validate = tuiCreateUnfinishedValidator( - () => this.injector.get(TUI_FOCUSABLE_ITEM_ACCESSOR), + tuiInjectElement(), tuiInjectElement().getAttribute('tuiUnfinishedValidator') || '', ); } diff --git a/projects/kit/directives/unfinished-validator/unfinished.validator.ts b/projects/kit/directives/unfinished-validator/unfinished.validator.ts index 04d7a89135ca..0d964eed6318 100644 --- a/projects/kit/directives/unfinished-validator/unfinished.validator.ts +++ b/projects/kit/directives/unfinished-validator/unfinished.validator.ts @@ -1,23 +1,15 @@ import type {AbstractControl, ValidatorFn} from '@angular/forms'; -import type {TuiFocusableElementAccessor} from '@taiga-ui/cdk'; -import {tuiIsHTMLElement, tuiIsInput, TuiValidationError} from '@taiga-ui/cdk'; +import {TuiValidationError} from '@taiga-ui/cdk'; import type {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; export function tuiCreateUnfinishedValidator( - nativeInputGetter: () => TuiFocusableElementAccessor, + element: HTMLInputElement, message: PolymorpheusContent, ): ValidatorFn { return ({ value, - }: AbstractControl): {unfinished: TuiValidationError | string} | null => { - const nativeInput = nativeInputGetter(); - - return value === null && - nativeInput && - tuiIsHTMLElement(nativeInput.nativeFocusableElement) && - tuiIsInput(nativeInput.nativeFocusableElement) && - nativeInput.nativeFocusableElement.value !== '' + }: AbstractControl): {unfinished: TuiValidationError | string} | null => + value === null && element.value !== '' ? {unfinished: new TuiValidationError(message)} : null; - }; } diff --git a/projects/kit/pipes/filter-by-input/filter-by-input.pipe.ts b/projects/kit/pipes/filter-by-input/filter-by-input.pipe.ts index 6d4ce6d5e307..7e69e7e0a747 100644 --- a/projects/kit/pipes/filter-by-input/filter-by-input.pipe.ts +++ b/projects/kit/pipes/filter-by-input/filter-by-input.pipe.ts @@ -1,13 +1,8 @@ import type {PipeTransform} from '@angular/core'; import {inject, Pipe} from '@angular/core'; import type {TuiStringHandler, TuiStringMatcher} from '@taiga-ui/cdk'; -import { - TUI_DEFAULT_MATCHER, - TUI_FOCUSABLE_ITEM_ACCESSOR, - tuiIsPresent, - tuiPure, -} from '@taiga-ui/cdk'; -import {TUI_DATA_LIST_HOST} from '@taiga-ui/core'; +import {TUI_DEFAULT_MATCHER, tuiIsPresent, tuiPure} from '@taiga-ui/cdk'; +import {TUI_DATA_LIST_HOST, TuiTextfieldComponent} from '@taiga-ui/core'; import {tuiIsFlat} from '@taiga-ui/kit/utils'; type TuiArrayElement = @@ -17,29 +12,30 @@ type TuiArrayElement = : T : never; -// TODO: Adapt for new MultiSelect +// TODO: Consider replacing TuiTextfieldComponent with proper token once we refactor textfields @Pipe({ standalone: true, name: 'tuiFilterByInput', pure: false, }) export class TuiFilterByInputPipe implements PipeTransform { + // TODO: Remove optional after legacy controls are dropped + private readonly textfield = inject(TuiTextfieldComponent, {optional: true}); private readonly host = inject(TUI_DATA_LIST_HOST); - // protected readonly multiSelect = inject(TuiMultiSelectDirective, {optional: true}); - private readonly accessor = inject(TUI_FOCUSABLE_ITEM_ACCESSOR); public transform(items: T, matcher?: TuiStringMatcher>): T; public transform( items: ReadonlyArray | readonly T[] | null, matcher: TuiStringMatcher = TUI_DEFAULT_MATCHER, ): ReadonlyArray | readonly T[] | null { - return this.filter(items, matcher, this.host.stringify || String, this.query); - } - - private get query(): string { - return this.accessor.nativeFocusableElement - ? (this.accessor.nativeFocusableElement as HTMLInputElement).value || '' - : ''; + return this.filter( + items, + matcher, + this.host.stringify || String, + this.textfield?.input.value || + (this.host as any).nativeFocusableElement?.value || + '', + ); } @tuiPure diff --git a/projects/legacy/classes/abstract-native-select.ts b/projects/legacy/classes/abstract-native-select.ts index ea1bb4f137cf..ae0ef7ad9344 100644 --- a/projects/legacy/classes/abstract-native-select.ts +++ b/projects/legacy/classes/abstract-native-select.ts @@ -8,9 +8,10 @@ import { } from '@angular/core'; import type {TuiBooleanHandler} from '@taiga-ui/cdk'; import {TuiIdService, tuiInjectElement} from '@taiga-ui/cdk'; -import type {TuiTextfieldHost} from '@taiga-ui/core'; -import {TUI_TEXTFIELD_HOST, TuiDataListDirective} from '@taiga-ui/core'; +import {TuiDataListDirective} from '@taiga-ui/core'; import {TUI_ITEMS_HANDLERS} from '@taiga-ui/kit'; +import type {TuiTextfieldHost} from '@taiga-ui/legacy/tokens'; +import {TUI_TEXTFIELD_HOST} from '@taiga-ui/legacy/tokens'; import {AbstractTuiControl} from './control'; diff --git a/projects/legacy/classes/abstract-textfield-host.ts b/projects/legacy/classes/abstract-textfield-host.ts index 298795ed8cc1..91d836207484 100644 --- a/projects/legacy/classes/abstract-textfield-host.ts +++ b/projects/legacy/classes/abstract-textfield-host.ts @@ -1,5 +1,5 @@ import {Directive, inject} from '@angular/core'; -import type {TuiTextfieldHost} from '@taiga-ui/core'; +import type {TuiTextfieldHost} from '@taiga-ui/legacy/tokens'; import {AbstractTuiControl} from './control'; diff --git a/projects/legacy/components/combo-box/combo-box.component.ts b/projects/legacy/components/combo-box/combo-box.component.ts index 28ea012b37b6..d8c936fdaa3b 100644 --- a/projects/legacy/components/combo-box/combo-box.component.ts +++ b/projects/legacy/components/combo-box/combo-box.component.ts @@ -10,18 +10,8 @@ import { TemplateRef, ViewChild, } from '@angular/core'; -import type { - TuiActiveZoneDirective, - TuiContext, - TuiFocusableElementAccessor, - TuiStringMatcher, -} from '@taiga-ui/cdk'; -import { - TUI_STRICT_MATCHER, - tuiAsFocusableItemAccessor, - tuiIsNativeFocused, - tuiIsPresent, -} from '@taiga-ui/cdk'; +import type {TuiActiveZoneDirective, TuiContext, TuiStringMatcher} from '@taiga-ui/cdk'; +import {TUI_STRICT_MATCHER, tuiIsNativeFocused, tuiIsPresent} from '@taiga-ui/cdk'; import type { TuiDataListAccessor, TuiDataListHost, @@ -44,6 +34,8 @@ import {TUI_ARROW_MODE} from '@taiga-ui/legacy/components/arrow'; import {TuiPrimitiveTextfieldComponent} from '@taiga-ui/legacy/components/primitive-textfield'; import {TUI_SELECT_OPTION} from '@taiga-ui/legacy/components/select-option'; import {TUI_TEXTFIELD_SIZE} from '@taiga-ui/legacy/directives'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; import {FIXED_DROPDOWN_CONTROLLER_PROVIDER} from '@taiga-ui/legacy/utils'; import type {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; diff --git a/projects/legacy/components/combo-box/combo-box.directive.ts b/projects/legacy/components/combo-box/combo-box.directive.ts index d08489d2232e..07b27d6f1f3b 100644 --- a/projects/legacy/components/combo-box/combo-box.directive.ts +++ b/projects/legacy/components/combo-box/combo-box.directive.ts @@ -1,6 +1,6 @@ import {Directive} from '@angular/core'; -import {tuiAsTextfieldHost} from '@taiga-ui/core'; import {AbstractTuiTextfieldHost} from '@taiga-ui/legacy/classes'; +import {tuiAsTextfieldHost} from '@taiga-ui/legacy/tokens'; import type {TuiComboBoxComponent} from './combo-box.component'; diff --git a/projects/legacy/components/input-copy/input-copy.component.ts b/projects/legacy/components/input-copy/input-copy.component.ts index 860f738edae5..5a468dafcc0e 100644 --- a/projects/legacy/components/input-copy/input-copy.component.ts +++ b/projects/legacy/components/input-copy/input-copy.component.ts @@ -7,8 +7,7 @@ import { Input, ViewChild, } from '@angular/core'; -import type {TuiFocusableElementAccessor, TuiNativeFocusableElement} from '@taiga-ui/cdk'; -import {tuiAsFocusableItemAccessor, tuiPure} from '@taiga-ui/cdk'; +import {tuiPure} from '@taiga-ui/cdk'; import type {TuiSizeL, TuiSizeS} from '@taiga-ui/core'; import {TUI_COPY_TEXTS} from '@taiga-ui/kit'; import {AbstractTuiControl, tuiAsControl} from '@taiga-ui/legacy/classes'; @@ -17,6 +16,11 @@ import { TUI_TEXTFIELD_SIZE, TUI_VALUE_ACCESSOR_PROVIDER, } from '@taiga-ui/legacy/directives'; +import type { + TuiFocusableElementAccessor, + TuiNativeFocusableElement, +} from '@taiga-ui/legacy/tokens'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; import type {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; import type {Observable} from 'rxjs'; import {BehaviorSubject, map, merge, of, switchMap, timer} from 'rxjs'; diff --git a/projects/legacy/components/input-copy/input-copy.directive.ts b/projects/legacy/components/input-copy/input-copy.directive.ts index a77f64f3261e..8f0742cbc055 100644 --- a/projects/legacy/components/input-copy/input-copy.directive.ts +++ b/projects/legacy/components/input-copy/input-copy.directive.ts @@ -1,6 +1,6 @@ import {Directive} from '@angular/core'; -import {tuiAsTextfieldHost} from '@taiga-ui/core'; import {AbstractTuiTextfieldHost} from '@taiga-ui/legacy/classes'; +import {tuiAsTextfieldHost} from '@taiga-ui/legacy/tokens'; import type {TuiInputCopyComponent} from './input-copy.component'; diff --git a/projects/legacy/components/input-date-multi/input-date-multi.component.ts b/projects/legacy/components/input-date-multi/input-date-multi.component.ts index 0516110ea561..156f3bcd4a55 100644 --- a/projects/legacy/components/input-date-multi/input-date-multi.component.ts +++ b/projects/legacy/components/input-date-multi/input-date-multi.component.ts @@ -10,30 +10,19 @@ import { import {takeUntilDestroyed} from '@angular/core/rxjs-interop'; import type {MaskitoOptions} from '@maskito/core'; import {maskitoDateOptionsGenerator} from '@maskito/kit'; -import type { - TuiBooleanHandler, - TuiFocusableElementAccessor, - TuiMapper, - TuiValueTransformer, -} from '@taiga-ui/cdk'; +import type {TuiBooleanHandler, TuiMapper, TuiValueTransformer} from '@taiga-ui/cdk'; import { changeDateSeparator, TUI_FALSE_HANDLER, TUI_IS_MOBILE, tuiAsControl, - tuiAsFocusableItemAccessor, tuiDateClamp, TuiDay, tuiIsString, TuiMonth, tuiWatch, } from '@taiga-ui/cdk'; -import type { - TuiMarkerHandler, - TuiSizeL, - TuiSizeS, - TuiWithOptionalMinMax, -} from '@taiga-ui/core'; +import type {TuiMarkerHandler, TuiSizeL, TuiSizeS} from '@taiga-ui/core'; import {TUI_DATE_FORMAT, TUI_DEFAULT_DATE_FORMAT} from '@taiga-ui/core'; import type {TuiInputDateOptions} from '@taiga-ui/kit'; import { @@ -54,6 +43,8 @@ import { import {TuiInputTagComponent} from '@taiga-ui/legacy/components/input-tag'; import {TuiPrimitiveTextfieldComponent} from '@taiga-ui/legacy/components/primitive-textfield'; import {TUI_TEXTFIELD_SIZE} from '@taiga-ui/legacy/directives'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; import type {Observable} from 'rxjs'; import {map} from 'rxjs'; @@ -72,7 +63,7 @@ import {map} from 'rxjs'; }) export class TuiInputDateMultiComponent extends AbstractTuiMultipleControl - implements TuiWithOptionalMinMax, TuiFocusableElementAccessor + implements TuiFocusableElementAccessor { @ViewChild(TuiPrimitiveTextfieldComponent) private readonly textfield?: TuiPrimitiveTextfieldComponent; diff --git a/projects/legacy/components/input-date-range/input-date-range.component.ts b/projects/legacy/components/input-date-range/input-date-range.component.ts index 4d4802130d28..04ad2d4a98f4 100644 --- a/projects/legacy/components/input-date-range/input-date-range.component.ts +++ b/projects/legacy/components/input-date-range/input-date-range.component.ts @@ -11,13 +11,7 @@ import {takeUntilDestroyed} from '@angular/core/rxjs-interop'; import type {MaskitoOptions} from '@maskito/core'; import {MASKITO_DEFAULT_OPTIONS} from '@maskito/core'; import {maskitoDateRangeOptionsGenerator} from '@maskito/kit'; -import type { - TuiBooleanHandler, - TuiDateMode, - TuiDay, - TuiDayLike, - TuiFocusableElementAccessor, -} from '@taiga-ui/cdk'; +import type {TuiBooleanHandler, TuiDateMode, TuiDay, TuiDayLike} from '@taiga-ui/cdk'; import { changeDateSeparator, DATE_FILLER_LENGTH, @@ -28,7 +22,6 @@ import { TUI_IS_MOBILE, TUI_LAST_DAY, tuiAsControl, - tuiAsFocusableItemAccessor, TuiDayRange, tuiIsPresent, TuiMonth, @@ -36,12 +29,7 @@ import { tuiPure, tuiWatch, } from '@taiga-ui/cdk'; -import type { - TuiMarkerHandler, - TuiSizeL, - TuiSizeS, - TuiWithOptionalMinMax, -} from '@taiga-ui/core'; +import type {TuiMarkerHandler, TuiSizeL, TuiSizeS} from '@taiga-ui/core'; import {TUI_DATE_FORMAT, TUI_DEFAULT_DATE_FORMAT} from '@taiga-ui/core'; import type {TuiDayRangePeriod, TuiInputDateOptions} from '@taiga-ui/kit'; import { @@ -58,6 +46,8 @@ import { } from '@taiga-ui/legacy/classes'; import {TuiPrimitiveTextfieldComponent} from '@taiga-ui/legacy/components/primitive-textfield'; import {TUI_TEXTFIELD_SIZE} from '@taiga-ui/legacy/directives'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; import {TUI_DATE_MODE_MASKITO_ADAPTER} from '@taiga-ui/legacy/utils'; import type {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; import {map} from 'rxjs'; @@ -77,7 +67,7 @@ import {map} from 'rxjs'; }) export class TuiInputDateRangeComponent extends AbstractTuiNullableControl - implements TuiWithOptionalMinMax, TuiFocusableElementAccessor + implements TuiFocusableElementAccessor { @ViewChild(TuiPrimitiveTextfieldComponent) private readonly textfield?: TuiPrimitiveTextfieldComponent; diff --git a/projects/legacy/components/input-date-range/input-date-range.directive.ts b/projects/legacy/components/input-date-range/input-date-range.directive.ts index 785031749f18..a2273b2cd1b2 100644 --- a/projects/legacy/components/input-date-range/input-date-range.directive.ts +++ b/projects/legacy/components/input-date-range/input-date-range.directive.ts @@ -1,7 +1,7 @@ import type {DoCheck} from '@angular/core'; import {Directive} from '@angular/core'; -import {tuiAsTextfieldHost} from '@taiga-ui/core'; import {AbstractTuiTextfieldHost} from '@taiga-ui/legacy/classes'; +import {tuiAsTextfieldHost} from '@taiga-ui/legacy/tokens'; import type {TuiInputDateRangeComponent} from './input-date-range.component'; diff --git a/projects/legacy/components/input-date-time/input-date-time.component.ts b/projects/legacy/components/input-date-time/input-date-time.component.ts index 17fb9d45a5fa..474f37421833 100644 --- a/projects/legacy/components/input-date-time/input-date-time.component.ts +++ b/projects/legacy/components/input-date-time/input-date-time.component.ts @@ -15,7 +15,6 @@ import type { TuiBooleanHandler, TuiContext, TuiDateMode, - TuiFocusableElementAccessor, TuiTimeMode, } from '@taiga-ui/cdk'; import { @@ -23,7 +22,6 @@ import { DATE_FILLER_LENGTH, TUI_FALSE_HANDLER, TUI_IS_MOBILE, - tuiAsFocusableItemAccessor, tuiClamp, tuiDateClamp, TuiDay, @@ -33,7 +31,7 @@ import { TuiTime, tuiWatch, } from '@taiga-ui/cdk'; -import type {TuiSizeL, TuiSizeS, TuiWithOptionalMinMax} from '@taiga-ui/core'; +import type {TuiSizeL, TuiSizeS} from '@taiga-ui/core'; import {TUI_DATE_FORMAT, TUI_DEFAULT_DATE_FORMAT} from '@taiga-ui/core'; import type {TuiInputDateOptions} from '@taiga-ui/kit'; import { @@ -46,6 +44,8 @@ import { import {AbstractTuiControl, tuiAsControl} from '@taiga-ui/legacy/classes'; import {TuiPrimitiveTextfieldComponent} from '@taiga-ui/legacy/components/primitive-textfield'; import {TUI_TEXTFIELD_SIZE} from '@taiga-ui/legacy/directives'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; import {TUI_DATE_MODE_MASKITO_ADAPTER} from '@taiga-ui/legacy/utils'; import type {Observable} from 'rxjs'; import {BehaviorSubject, combineLatest, map, timer} from 'rxjs'; @@ -65,9 +65,7 @@ const DATE_TIME_SEPARATOR = ', '; }) export class TuiInputDateTimeComponent extends AbstractTuiControl<[TuiDay | null, TuiTime | null]> - implements - TuiWithOptionalMinMax, - TuiFocusableElementAccessor + implements TuiFocusableElementAccessor { @ViewChild(TuiPrimitiveTextfieldComponent) private readonly textfield?: TuiPrimitiveTextfieldComponent; diff --git a/projects/legacy/components/input-date-time/input-date-time.directive.ts b/projects/legacy/components/input-date-time/input-date-time.directive.ts index afe68a996198..1ad6cc08070c 100644 --- a/projects/legacy/components/input-date-time/input-date-time.directive.ts +++ b/projects/legacy/components/input-date-time/input-date-time.directive.ts @@ -1,7 +1,7 @@ import {Directive} from '@angular/core'; import type {TuiDay, TuiTime} from '@taiga-ui/cdk'; -import {tuiAsTextfieldHost} from '@taiga-ui/core'; import {AbstractTuiTextfieldHost} from '@taiga-ui/legacy/classes'; +import {tuiAsTextfieldHost} from '@taiga-ui/legacy/tokens'; import type {TuiInputDateTimeComponent} from './input-date-time.component'; diff --git a/projects/legacy/components/input-date-time/native-date-time/native-date-time.directive.ts b/projects/legacy/components/input-date-time/native-date-time/native-date-time.directive.ts index 3884ebe68b8e..d28a1b460e0a 100644 --- a/projects/legacy/components/input-date-time/native-date-time/native-date-time.directive.ts +++ b/projects/legacy/components/input-date-time/native-date-time/native-date-time.directive.ts @@ -1,6 +1,6 @@ import {Directive, inject} from '@angular/core'; import {TuiDay, TuiTime} from '@taiga-ui/cdk'; -import {TUI_TEXTFIELD_HOST} from '@taiga-ui/core'; +import {TUI_TEXTFIELD_HOST} from '@taiga-ui/legacy/tokens'; import type {TuiInputDateTimeDirective} from '../input-date-time.directive'; diff --git a/projects/legacy/components/input-date/input-date.component.ts b/projects/legacy/components/input-date/input-date.component.ts index d58cd048c4e6..e0bb47883cab 100644 --- a/projects/legacy/components/input-date/input-date.component.ts +++ b/projects/legacy/components/input-date/input-date.component.ts @@ -17,7 +17,6 @@ import type { TuiBooleanHandler, TuiContext, TuiDateMode, - TuiFocusableElementAccessor, } from '@taiga-ui/cdk'; import { changeDateSeparator, @@ -25,7 +24,6 @@ import { TUI_FALSE_HANDLER, TUI_IS_MOBILE, tuiAsControl, - tuiAsFocusableItemAccessor, tuiDateClamp, TuiDay, TuiMonth, @@ -33,12 +31,7 @@ import { tuiPure, tuiWatch, } from '@taiga-ui/cdk'; -import type { - TuiMarkerHandler, - TuiSizeL, - TuiSizeS, - TuiWithOptionalMinMax, -} from '@taiga-ui/core'; +import type {TuiMarkerHandler, TuiSizeL, TuiSizeS} from '@taiga-ui/core'; import {TUI_DATE_FORMAT, TUI_DEFAULT_DATE_FORMAT} from '@taiga-ui/core'; import type {TuiInputDateOptions} from '@taiga-ui/kit'; import { @@ -56,6 +49,8 @@ import { } from '@taiga-ui/legacy/classes'; import {TuiPrimitiveTextfieldComponent} from '@taiga-ui/legacy/components/primitive-textfield'; import {TUI_TEXTFIELD_SIZE} from '@taiga-ui/legacy/directives'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; import {TUI_DATE_MODE_MASKITO_ADAPTER} from '@taiga-ui/legacy/utils'; import type {Observable} from 'rxjs'; import {map} from 'rxjs'; @@ -75,7 +70,7 @@ import {map} from 'rxjs'; }) export class TuiInputDateComponent extends AbstractTuiNullableControl - implements TuiWithOptionalMinMax, TuiFocusableElementAccessor + implements TuiFocusableElementAccessor { @ViewChild(TuiPrimitiveTextfieldComponent) private readonly textfield?: TuiPrimitiveTextfieldComponent; diff --git a/projects/legacy/components/input-date/input-date.directive.ts b/projects/legacy/components/input-date/input-date.directive.ts index 1659b93c2771..1711631811c7 100644 --- a/projects/legacy/components/input-date/input-date.directive.ts +++ b/projects/legacy/components/input-date/input-date.directive.ts @@ -1,8 +1,8 @@ import {Directive} from '@angular/core'; import type {TuiDay} from '@taiga-ui/cdk'; import type {TuiDateFormatSettings} from '@taiga-ui/core'; -import {tuiAsTextfieldHost} from '@taiga-ui/core'; import {AbstractTuiTextfieldHost} from '@taiga-ui/legacy/classes'; +import {tuiAsTextfieldHost} from '@taiga-ui/legacy/tokens'; import type {TuiInputDateComponent} from './input-date.component'; diff --git a/projects/legacy/components/input-date/native-date/native-date.component.ts b/projects/legacy/components/input-date/native-date/native-date.component.ts index 4f910f217c84..af613f48ee08 100644 --- a/projects/legacy/components/input-date/native-date/native-date.component.ts +++ b/projects/legacy/components/input-date/native-date/native-date.component.ts @@ -1,6 +1,6 @@ import {Directive, inject} from '@angular/core'; import {DATE_FILLER_LENGTH, TuiDay} from '@taiga-ui/cdk'; -import {TUI_TEXTFIELD_HOST} from '@taiga-ui/core'; +import {TUI_TEXTFIELD_HOST} from '@taiga-ui/legacy/tokens'; import type {TuiInputDateDirective} from '../input-date.directive'; diff --git a/projects/legacy/components/input-month-range/input-month-range.component.ts b/projects/legacy/components/input-month-range/input-month-range.component.ts index dfafcbaf5a18..c783a12bee10 100644 --- a/projects/legacy/components/input-month-range/input-month-range.component.ts +++ b/projects/legacy/components/input-month-range/input-month-range.component.ts @@ -6,28 +6,27 @@ import { Input, ViewChild, } from '@angular/core'; -import type { - TuiBooleanHandler, - TuiFocusableElementAccessor, - TuiMonth, - TuiYear, -} from '@taiga-ui/cdk'; +import type {TuiBooleanHandler, TuiMonth, TuiYear} from '@taiga-ui/cdk'; import { CHAR_EN_DASH, TUI_FALSE_HANDLER, - tuiAsFocusableItemAccessor, tuiDateClamp, TuiDay, TuiMonthRange, } from '@taiga-ui/cdk'; -import type {TuiSizeL, TuiSizeS, TuiWithOptionalMinMax} from '@taiga-ui/core'; +import type {TuiSizeL, TuiSizeS} from '@taiga-ui/core'; import {TuiMonthPipe} from '@taiga-ui/core'; import type {TuiInputDateOptions} from '@taiga-ui/kit'; import {TUI_INPUT_DATE_OPTIONS} from '@taiga-ui/kit'; import {AbstractTuiNullableControl, tuiAsControl} from '@taiga-ui/legacy/classes'; import {TuiPrimitiveTextfieldComponent} from '@taiga-ui/legacy/components/primitive-textfield'; import {TUI_TEXTFIELD_SIZE} from '@taiga-ui/legacy/directives'; -import {TUI_MONTH_FORMATTER, TUI_MONTH_FORMATTER_PROVIDER} from '@taiga-ui/legacy/tokens'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; +import { + TUI_MONTH_FORMATTER, + TUI_MONTH_FORMATTER_PROVIDER, + tuiAsFocusableItemAccessor, +} from '@taiga-ui/legacy/tokens'; @Component({ selector: 'tui-input-month-range', @@ -43,7 +42,7 @@ import {TUI_MONTH_FORMATTER, TUI_MONTH_FORMATTER_PROVIDER} from '@taiga-ui/legac }) export class TuiInputMonthRangeComponent extends AbstractTuiNullableControl - implements TuiWithOptionalMinMax, TuiFocusableElementAccessor + implements TuiFocusableElementAccessor { @ViewChild(TuiPrimitiveTextfieldComponent) private readonly textfield?: TuiPrimitiveTextfieldComponent; diff --git a/projects/legacy/components/input-month-range/input-month-range.directive.ts b/projects/legacy/components/input-month-range/input-month-range.directive.ts index 82f45d19c6fc..90843378e739 100644 --- a/projects/legacy/components/input-month-range/input-month-range.directive.ts +++ b/projects/legacy/components/input-month-range/input-month-range.directive.ts @@ -2,9 +2,8 @@ import type {DoCheck} from '@angular/core'; import {Directive, inject} from '@angular/core'; import {takeUntilDestroyed} from '@angular/core/rxjs-interop'; import type {TuiMonthRange} from '@taiga-ui/cdk'; -import {tuiAsTextfieldHost} from '@taiga-ui/core'; import {AbstractTuiTextfieldHost} from '@taiga-ui/legacy/classes'; -import {TUI_MONTH_FORMATTER} from '@taiga-ui/legacy/tokens'; +import {TUI_MONTH_FORMATTER, tuiAsTextfieldHost} from '@taiga-ui/legacy/tokens'; import {combineLatest, distinctUntilChanged, Subject, switchMap} from 'rxjs'; import type {TuiInputMonthRangeComponent} from './input-month-range.component'; diff --git a/projects/legacy/components/input-month/input-month.component.ts b/projects/legacy/components/input-month/input-month.component.ts index 69ee0370102e..21ff978dab19 100644 --- a/projects/legacy/components/input-month/input-month.component.ts +++ b/projects/legacy/components/input-month/input-month.component.ts @@ -6,27 +6,27 @@ import { Input, ViewChild, } from '@angular/core'; -import type { - TuiBooleanHandler, - TuiFocusableElementAccessor, - TuiYear, -} from '@taiga-ui/cdk'; +import type {TuiBooleanHandler, TuiYear} from '@taiga-ui/cdk'; import { TUI_FALSE_HANDLER, TUI_IS_MOBILE, - tuiAsFocusableItemAccessor, tuiDateClamp, TuiDay, TuiMonth, } from '@taiga-ui/cdk'; -import type {TuiSizeL, TuiSizeS, TuiWithOptionalMinMax} from '@taiga-ui/core'; +import type {TuiSizeL, TuiSizeS} from '@taiga-ui/core'; import {TuiMonthPipe} from '@taiga-ui/core'; import type {TuiInputDateOptions} from '@taiga-ui/kit'; import {TUI_INPUT_DATE_OPTIONS} from '@taiga-ui/kit'; import {AbstractTuiNullableControl, tuiAsControl} from '@taiga-ui/legacy/classes'; import {TuiPrimitiveTextfieldComponent} from '@taiga-ui/legacy/components/primitive-textfield'; import {TUI_TEXTFIELD_SIZE} from '@taiga-ui/legacy/directives'; -import {TUI_MONTH_FORMATTER, TUI_MONTH_FORMATTER_PROVIDER} from '@taiga-ui/legacy/tokens'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; +import { + TUI_MONTH_FORMATTER, + TUI_MONTH_FORMATTER_PROVIDER, + tuiAsFocusableItemAccessor, +} from '@taiga-ui/legacy/tokens'; @Component({ selector: 'tui-input-month', @@ -42,7 +42,7 @@ import {TUI_MONTH_FORMATTER, TUI_MONTH_FORMATTER_PROVIDER} from '@taiga-ui/legac }) export class TuiInputMonthComponent extends AbstractTuiNullableControl - implements TuiWithOptionalMinMax, TuiFocusableElementAccessor + implements TuiFocusableElementAccessor { @ViewChild(TuiPrimitiveTextfieldComponent) private readonly textfield?: TuiPrimitiveTextfieldComponent; diff --git a/projects/legacy/components/input-month/input-month.directive.ts b/projects/legacy/components/input-month/input-month.directive.ts index fa8107107b8e..4b1c1f4d17fb 100644 --- a/projects/legacy/components/input-month/input-month.directive.ts +++ b/projects/legacy/components/input-month/input-month.directive.ts @@ -2,9 +2,8 @@ import type {DoCheck} from '@angular/core'; import {Directive, inject} from '@angular/core'; import {takeUntilDestroyed} from '@angular/core/rxjs-interop'; import type {TuiMonth} from '@taiga-ui/cdk'; -import {tuiAsTextfieldHost} from '@taiga-ui/core'; import {AbstractTuiTextfieldHost} from '@taiga-ui/legacy/classes'; -import {TUI_MONTH_FORMATTER} from '@taiga-ui/legacy/tokens'; +import {TUI_MONTH_FORMATTER, tuiAsTextfieldHost} from '@taiga-ui/legacy/tokens'; import {distinctUntilChanged, Subject, switchMap} from 'rxjs'; import type {TuiInputMonthComponent} from './input-month.component'; diff --git a/projects/legacy/components/input-number/input-number.component.ts b/projects/legacy/components/input-number/input-number.component.ts index 0115a960b0b6..b7a78d265880 100644 --- a/projects/legacy/components/input-number/input-number.component.ts +++ b/projects/legacy/components/input-number/input-number.component.ts @@ -17,17 +17,12 @@ import { maskitoNumberOptionsGenerator, maskitoParseNumber, } from '@maskito/kit'; -import type { - TuiFocusableElementAccessor, - TuiInputMode, - TuiValueTransformer, -} from '@taiga-ui/cdk'; +import type {TuiValueTransformer} from '@taiga-ui/cdk'; import { CHAR_HYPHEN, CHAR_MINUS, EMPTY_QUERY, TUI_IS_IOS, - tuiAsFocusableItemAccessor, tuiClamp, tuiPure, tuiWatch, @@ -45,6 +40,8 @@ import { TUI_TEXTFIELD_SIZE, TUI_TEXTFIELD_WATCHED_CONTROLLER, } from '@taiga-ui/legacy/directives'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; import {PolymorpheusOutletDirective} from '@tinkoff/ng-polymorpheus'; import type {TuiInputNumberOptions} from './input-number.options'; @@ -113,7 +110,7 @@ export class TuiInputNumberComponent return !!this.textfield?.focused; } - public get inputMode(): TuiInputMode { + public get inputMode(): string { if (this.isIOS && this.isNegativeAllowed) { // iPhone does not have minus sign if inputMode is equal to 'numeric' / 'decimal' return 'text'; diff --git a/projects/legacy/components/input-number/input-number.directive.ts b/projects/legacy/components/input-number/input-number.directive.ts index 9e8d27712796..97d7a1d329c8 100644 --- a/projects/legacy/components/input-number/input-number.directive.ts +++ b/projects/legacy/components/input-number/input-number.directive.ts @@ -1,7 +1,7 @@ import type {DoCheck} from '@angular/core'; import {Directive} from '@angular/core'; -import {tuiAsTextfieldHost} from '@taiga-ui/core'; import {AbstractTuiTextfieldHost} from '@taiga-ui/legacy/classes'; +import {tuiAsTextfieldHost} from '@taiga-ui/legacy/tokens'; import type {TuiInputNumberComponent} from './input-number.component'; diff --git a/projects/legacy/components/input-password/input-password.component.ts b/projects/legacy/components/input-password/input-password.component.ts index 9b9d894292c5..9ed965b11559 100644 --- a/projects/legacy/components/input-password/input-password.component.ts +++ b/projects/legacy/components/input-password/input-password.component.ts @@ -5,19 +5,18 @@ import { inject, ViewChild, } from '@angular/core'; -import type { - TuiContext, - TuiFocusableElementAccessor, - TuiInputType, - TuiNativeFocusableElement, -} from '@taiga-ui/cdk'; -import {tuiAsFocusableItemAccessor} from '@taiga-ui/cdk'; +import type {TuiContext} from '@taiga-ui/cdk'; import type {TuiSizeL, TuiSizeS} from '@taiga-ui/core'; import {TuiHintOptionsDirective} from '@taiga-ui/core'; import {TUI_PASSWORD_TEXTS} from '@taiga-ui/kit'; import {AbstractTuiControl, tuiAsControl} from '@taiga-ui/legacy/classes'; import {TuiPrimitiveTextfieldComponent} from '@taiga-ui/legacy/components/primitive-textfield'; import {TUI_TEXTFIELD_SIZE} from '@taiga-ui/legacy/directives'; +import type { + TuiFocusableElementAccessor, + TuiNativeFocusableElement, +} from '@taiga-ui/legacy/tokens'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; import type {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; import type {Observable} from 'rxjs'; import {EMPTY, map, startWith} from 'rxjs'; @@ -67,7 +66,7 @@ export class TuiInputPasswordComponent return !!this.textfield?.focused; } - public get inputType(): TuiInputType { + public get inputType(): string { return this.isPasswordHidden || !this.interactive ? 'password' : 'text'; } diff --git a/projects/legacy/components/input-password/input-password.directive.ts b/projects/legacy/components/input-password/input-password.directive.ts index b1d19495696e..d36e3c3bc869 100644 --- a/projects/legacy/components/input-password/input-password.directive.ts +++ b/projects/legacy/components/input-password/input-password.directive.ts @@ -1,8 +1,8 @@ import type {DoCheck} from '@angular/core'; import {Directive} from '@angular/core'; import {tuiIsInput} from '@taiga-ui/cdk'; -import {tuiAsTextfieldHost} from '@taiga-ui/core'; import {AbstractTuiTextfieldHost} from '@taiga-ui/legacy/classes'; +import {tuiAsTextfieldHost} from '@taiga-ui/legacy/tokens'; import type {TuiInputPasswordComponent} from './input-password.component'; diff --git a/projects/legacy/components/input-phone-international/input-phone-international.component.ts b/projects/legacy/components/input-phone-international/input-phone-international.component.ts index c87c5992c08d..81fe101407d6 100644 --- a/projects/legacy/components/input-phone-international/input-phone-international.component.ts +++ b/projects/legacy/components/input-phone-international/input-phone-international.component.ts @@ -11,13 +11,8 @@ import { ViewChild, } from '@angular/core'; import {FormsModule} from '@angular/forms'; -import type {TuiContext, TuiFocusableElementAccessor} from '@taiga-ui/cdk'; -import { - CHAR_PLUS, - TUI_NON_DIGITS_REGEXP, - tuiAsFocusableItemAccessor, - tuiPure, -} from '@taiga-ui/cdk'; +import type {TuiContext} from '@taiga-ui/cdk'; +import {CHAR_PLUS, TUI_NON_DIGITS_REGEXP, tuiPure} from '@taiga-ui/cdk'; import type {TuiSizeL, TuiSizeM, TuiSizeS} from '@taiga-ui/core'; import { TuiAppearanceDirective, @@ -45,7 +40,8 @@ import { TuiTextfieldControllerModule, } from '@taiga-ui/legacy/directives'; import {TuiIsoToCountryCodePipe, TuiToCountryCodePipe} from '@taiga-ui/legacy/pipes'; -import {TUI_COUNTRIES_MASKS} from '@taiga-ui/legacy/tokens'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; +import {TUI_COUNTRIES_MASKS, tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; import { FIXED_DROPDOWN_CONTROLLER_PROVIDER, tuiGetMaxAllowedPhoneLength, diff --git a/projects/legacy/components/input-phone/input-phone.component.ts b/projects/legacy/components/input-phone/input-phone.component.ts index 3e97c51782ef..1a4f2c72dfab 100644 --- a/projects/legacy/components/input-phone/input-phone.component.ts +++ b/projects/legacy/components/input-phone/input-phone.component.ts @@ -13,13 +13,8 @@ import { import type {MaskitoOptions} from '@maskito/core'; import {MASKITO_DEFAULT_OPTIONS, maskitoTransform} from '@maskito/core'; import {maskitoCaretGuard, maskitoPrefixPostprocessorGenerator} from '@maskito/kit'; -import type { - TuiActiveZoneDirective, - TuiContext, - TuiFocusableElementAccessor, - TuiInputMode, -} from '@taiga-ui/cdk'; -import {tuiAsFocusableItemAccessor, tuiIsNativeFocused, tuiPure} from '@taiga-ui/cdk'; +import type {TuiActiveZoneDirective, TuiContext} from '@taiga-ui/cdk'; +import {tuiIsNativeFocused, tuiPure} from '@taiga-ui/cdk'; import type {TuiDataListHost, TuiSizeL, TuiSizeS} from '@taiga-ui/core'; import { tuiAsDataListHost, @@ -29,6 +24,8 @@ import { import {AbstractTuiControl, tuiAsControl} from '@taiga-ui/legacy/classes'; import {TuiPrimitiveTextfieldComponent} from '@taiga-ui/legacy/components/primitive-textfield'; import {TUI_TEXTFIELD_CLEANER, TUI_TEXTFIELD_SIZE} from '@taiga-ui/legacy/directives'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; import {FIXED_DROPDOWN_CONTROLLER_PROVIDER} from '@taiga-ui/legacy/utils'; import {TUI_INPUT_PHONE_OPTIONS} from './input-phone.options'; @@ -126,7 +123,7 @@ export class TuiInputPhoneComponent } } - public get inputMode(): TuiInputMode { + public get inputMode(): string { return this.allowText ? 'text' : 'numeric'; } diff --git a/projects/legacy/components/input-phone/input-phone.directive.ts b/projects/legacy/components/input-phone/input-phone.directive.ts index eaf0af4e07c5..ec1e496a3873 100644 --- a/projects/legacy/components/input-phone/input-phone.directive.ts +++ b/projects/legacy/components/input-phone/input-phone.directive.ts @@ -1,7 +1,7 @@ import type {DoCheck} from '@angular/core'; import {Directive} from '@angular/core'; -import {tuiAsTextfieldHost} from '@taiga-ui/core'; import {AbstractTuiTextfieldHost} from '@taiga-ui/legacy/classes'; +import {tuiAsTextfieldHost} from '@taiga-ui/legacy/tokens'; import type {TuiInputPhoneComponent} from './input-phone.component'; diff --git a/projects/legacy/components/input-range/input-range.component.ts b/projects/legacy/components/input-range/input-range.component.ts index 2935d76b531e..f39240dd6bcd 100644 --- a/projects/legacy/components/input-range/input-range.component.ts +++ b/projects/legacy/components/input-range/input-range.component.ts @@ -8,15 +8,10 @@ import { ViewChild, ViewChildren, } from '@angular/core'; -import type { - TuiContext, - TuiFocusableElementAccessor, - TuiNativeFocusableElement, -} from '@taiga-ui/cdk'; +import type {TuiContext} from '@taiga-ui/cdk'; import { EMPTY_QUERY, TUI_IS_MOBILE, - tuiAsFocusableItemAccessor, tuiClamp, tuiInjectElement, tuiIsNativeFocused, @@ -24,7 +19,6 @@ import { tuiPure, tuiRound, } from '@taiga-ui/cdk'; -import type {TuiWithOptionalMinMax} from '@taiga-ui/core'; import {tuiGetFractionPartPadded} from '@taiga-ui/core'; import type {TuiKeySteps} from '@taiga-ui/kit'; import {TUI_FLOATING_PRECISION, TuiRangeComponent} from '@taiga-ui/kit'; @@ -34,6 +28,11 @@ import { TEXTFIELD_CONTROLLER_PROVIDER, TUI_TEXTFIELD_WATCHED_CONTROLLER, } from '@taiga-ui/legacy/directives'; +import type { + TuiFocusableElementAccessor, + TuiNativeFocusableElement, +} from '@taiga-ui/legacy/tokens'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; import type {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; @Component({ @@ -53,7 +52,7 @@ import type {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; }) export class TuiInputRangeComponent extends AbstractTuiControl<[number, number]> - implements TuiWithOptionalMinMax, TuiFocusableElementAccessor + implements TuiFocusableElementAccessor { @ViewChildren(TuiInputNumberComponent) private readonly inputNumberRefs: QueryList = EMPTY_QUERY; diff --git a/projects/legacy/components/input-slider/input-slider.component.ts b/projects/legacy/components/input-slider/input-slider.component.ts index cdeb867edbcd..9221711d4421 100644 --- a/projects/legacy/components/input-slider/input-slider.component.ts +++ b/projects/legacy/components/input-slider/input-slider.component.ts @@ -6,19 +6,8 @@ import { Input, ViewChild, } from '@angular/core'; -import type { - TuiContext, - TuiFocusableElementAccessor, - TuiNativeFocusableElement, -} from '@taiga-ui/cdk'; -import { - tuiAsFocusableItemAccessor, - tuiClamp, - tuiIsNativeFocused, - tuiPure, - tuiRound, -} from '@taiga-ui/cdk'; -import type {TuiWithOptionalMinMax} from '@taiga-ui/core'; +import type {TuiContext} from '@taiga-ui/cdk'; +import {tuiClamp, tuiIsNativeFocused, tuiPure, tuiRound} from '@taiga-ui/cdk'; import {tuiGetFractionPartPadded} from '@taiga-ui/core'; import type {TuiKeySteps} from '@taiga-ui/kit'; import { @@ -32,6 +21,11 @@ import { TEXTFIELD_CONTROLLER_PROVIDER, TUI_TEXTFIELD_WATCHED_CONTROLLER, } from '@taiga-ui/legacy/directives'; +import type { + TuiFocusableElementAccessor, + TuiNativeFocusableElement, +} from '@taiga-ui/legacy/tokens'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; import type {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; @Component({ @@ -52,7 +46,7 @@ import type {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; }) export class TuiInputSliderComponent extends AbstractTuiControl - implements TuiWithOptionalMinMax, TuiFocusableElementAccessor + implements TuiFocusableElementAccessor { @ViewChild(TuiInputNumberComponent) private readonly inputNumberRef?: TuiInputNumberComponent; diff --git a/projects/legacy/components/input-tag/input-tag.component.ts b/projects/legacy/components/input-tag/input-tag.component.ts index 66194f7af5db..657c63058588 100644 --- a/projects/legacy/components/input-tag/input-tag.component.ts +++ b/projects/legacy/components/input-tag/input-tag.component.ts @@ -15,18 +15,12 @@ import { ViewChildren, } from '@angular/core'; import {takeUntilDestroyed} from '@angular/core/rxjs-interop'; -import type { - TuiActiveZoneDirective, - TuiBooleanHandler, - TuiContext, - TuiFocusableElementAccessor, -} from '@taiga-ui/cdk'; +import type {TuiActiveZoneDirective, TuiBooleanHandler, TuiContext} from '@taiga-ui/cdk'; import { EMPTY_QUERY, TUI_FALSE_HANDLER, TUI_TRUE_HANDLER, tuiArrayRemove, - tuiAsFocusableItemAccessor, tuiGetActualTarget, tuiGetClipboardDataText, tuiInjectElement, @@ -49,6 +43,8 @@ import { TEXTFIELD_CONTROLLER_PROVIDER, TUI_TEXTFIELD_WATCHED_CONTROLLER, } from '@taiga-ui/legacy/directives'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; import type {TuiStatus} from '@taiga-ui/legacy/utils'; import {FIXED_DROPDOWN_CONTROLLER_PROVIDER} from '@taiga-ui/legacy/utils'; import type {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; diff --git a/projects/legacy/components/input-time/input-time.component.ts b/projects/legacy/components/input-time/input-time.component.ts index b2faaff837cc..429eef3503e7 100644 --- a/projects/legacy/components/input-time/input-time.component.ts +++ b/projects/legacy/components/input-time/input-time.component.ts @@ -10,18 +10,12 @@ import { import {takeUntilDestroyed} from '@angular/core/rxjs-interop'; import type {MaskitoOptions} from '@maskito/core'; import {maskitoTimeOptionsGenerator} from '@maskito/kit'; -import type { - TuiBooleanHandler, - TuiFocusableElementAccessor, - TuiTimeLike, - TuiTimeMode, -} from '@taiga-ui/cdk'; +import type {TuiBooleanHandler, TuiTimeLike, TuiTimeMode} from '@taiga-ui/cdk'; import { TUI_FALSE_HANDLER, TUI_IS_IOS, TUI_IS_MOBILE, TUI_STRICT_MATCHER, - tuiAsFocusableItemAccessor, tuiIsElement, tuiIsInput, tuiIsNativeFocused, @@ -35,6 +29,8 @@ import {AbstractTuiNullableControl, tuiAsControl} from '@taiga-ui/legacy/classes import {TuiPrimitiveTextfieldComponent} from '@taiga-ui/legacy/components/primitive-textfield'; import {TUI_SELECT_OPTION} from '@taiga-ui/legacy/components/select-option'; import {TUI_TEXTFIELD_SIZE} from '@taiga-ui/legacy/directives'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; import {FIXED_DROPDOWN_CONTROLLER_PROVIDER} from '@taiga-ui/legacy/utils'; import type {Observable} from 'rxjs'; import {map, timer} from 'rxjs'; diff --git a/projects/legacy/components/input-time/input-time.directive.ts b/projects/legacy/components/input-time/input-time.directive.ts index 0ef7bb5c7165..4c670c4d3579 100644 --- a/projects/legacy/components/input-time/input-time.directive.ts +++ b/projects/legacy/components/input-time/input-time.directive.ts @@ -1,7 +1,7 @@ import {Directive} from '@angular/core'; import type {TuiTime, TuiTimeMode} from '@taiga-ui/cdk'; -import {tuiAsTextfieldHost} from '@taiga-ui/core'; import {AbstractTuiTextfieldHost} from '@taiga-ui/legacy/classes'; +import {tuiAsTextfieldHost} from '@taiga-ui/legacy/tokens'; import type {TuiInputTimeComponent} from './input-time.component'; diff --git a/projects/legacy/components/input-time/native-time/native-time.component.ts b/projects/legacy/components/input-time/native-time/native-time.component.ts index a8c85bc84e20..d876be2aad87 100644 --- a/projects/legacy/components/input-time/native-time/native-time.component.ts +++ b/projects/legacy/components/input-time/native-time/native-time.component.ts @@ -1,6 +1,6 @@ import {ChangeDetectionStrategy, Component, inject} from '@angular/core'; import {TuiIdService} from '@taiga-ui/cdk'; -import {TUI_TEXTFIELD_HOST} from '@taiga-ui/core'; +import {TUI_TEXTFIELD_HOST} from '@taiga-ui/legacy/tokens'; import type {TuiInputTimeDirective} from '../input-time.directive'; diff --git a/projects/legacy/components/input-year/input-year.component.ts b/projects/legacy/components/input-year/input-year.component.ts index 3daa6c653ea6..dc60da9dce93 100644 --- a/projects/legacy/components/input-year/input-year.component.ts +++ b/projects/legacy/components/input-year/input-year.component.ts @@ -8,20 +8,16 @@ import { } from '@angular/core'; import type {MaskitoOptions} from '@maskito/core'; import {maskitoNumberOptionsGenerator} from '@maskito/kit'; -import type {TuiBooleanHandler, TuiFocusableElementAccessor} from '@taiga-ui/cdk'; -import { - MAX_YEAR, - MIN_YEAR, - TUI_FALSE_HANDLER, - tuiAsFocusableItemAccessor, - tuiPure, -} from '@taiga-ui/cdk'; -import type {TuiSizeL, TuiSizeS, TuiWithOptionalMinMax} from '@taiga-ui/core'; +import type {TuiBooleanHandler} from '@taiga-ui/cdk'; +import {MAX_YEAR, MIN_YEAR, TUI_FALSE_HANDLER, tuiPure} from '@taiga-ui/cdk'; +import type {TuiSizeL, TuiSizeS} from '@taiga-ui/core'; import type {TuiInputDateOptions} from '@taiga-ui/kit'; import {TUI_INPUT_DATE_OPTIONS} from '@taiga-ui/kit'; import {AbstractTuiNullableControl, tuiAsControl} from '@taiga-ui/legacy/classes'; import {TuiPrimitiveTextfieldComponent} from '@taiga-ui/legacy/components/primitive-textfield'; import {TUI_TEXTFIELD_SIZE} from '@taiga-ui/legacy/directives'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; const UP_TO_4_DIGITS_REG = /^\d{0,4}$/; @@ -37,7 +33,7 @@ const UP_TO_4_DIGITS_REG = /^\d{0,4}$/; }) export class TuiInputYearComponent extends AbstractTuiNullableControl - implements TuiWithOptionalMinMax, TuiFocusableElementAccessor + implements TuiFocusableElementAccessor { @ViewChild(TuiPrimitiveTextfieldComponent) private readonly textfield?: TuiPrimitiveTextfieldComponent; diff --git a/projects/legacy/components/input-year/input-year.directive.ts b/projects/legacy/components/input-year/input-year.directive.ts index fa679b5cf43e..385b34431da2 100644 --- a/projects/legacy/components/input-year/input-year.directive.ts +++ b/projects/legacy/components/input-year/input-year.directive.ts @@ -1,6 +1,6 @@ import {Directive} from '@angular/core'; -import {tuiAsTextfieldHost} from '@taiga-ui/core'; import {AbstractTuiTextfieldHost} from '@taiga-ui/legacy/classes'; +import {tuiAsTextfieldHost} from '@taiga-ui/legacy/tokens'; import type {TuiInputYearComponent} from './input-year.component'; diff --git a/projects/legacy/components/input/input.component.ts b/projects/legacy/components/input/input.component.ts index 5ee66e86c41a..c750bc40e879 100644 --- a/projects/legacy/components/input/input.component.ts +++ b/projects/legacy/components/input/input.component.ts @@ -7,12 +7,8 @@ import { TemplateRef, ViewChild, } from '@angular/core'; -import type { - TuiActiveZoneDirective, - TuiContext, - TuiFocusableElementAccessor, -} from '@taiga-ui/cdk'; -import {tuiAsFocusableItemAccessor, tuiIsNativeFocused} from '@taiga-ui/cdk'; +import type {TuiActiveZoneDirective, TuiContext} from '@taiga-ui/cdk'; +import {tuiIsNativeFocused} from '@taiga-ui/cdk'; import type {TuiDataListHost, TuiSizeL, TuiSizeS} from '@taiga-ui/core'; import { tuiAsDataListHost, @@ -25,6 +21,8 @@ import { TUI_TEXTFIELD_SIZE, TUI_VALUE_ACCESSOR_PROVIDER, } from '@taiga-ui/legacy/directives'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; import {FIXED_DROPDOWN_CONTROLLER_PROVIDER} from '@taiga-ui/legacy/utils'; import type {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; diff --git a/projects/legacy/components/input/input.directive.ts b/projects/legacy/components/input/input.directive.ts index 9bbc60247243..a9b15fa455d6 100644 --- a/projects/legacy/components/input/input.directive.ts +++ b/projects/legacy/components/input/input.directive.ts @@ -1,6 +1,6 @@ import {Directive} from '@angular/core'; -import {tuiAsTextfieldHost} from '@taiga-ui/core'; import {AbstractTuiTextfieldHost} from '@taiga-ui/legacy/classes'; +import {tuiAsTextfieldHost} from '@taiga-ui/legacy/tokens'; import type {TuiInputComponent} from './input.component'; diff --git a/projects/legacy/components/multi-select/multi-select.component.ts b/projects/legacy/components/multi-select/multi-select.component.ts index ec247f47b2e2..a492ad236d71 100644 --- a/projects/legacy/components/multi-select/multi-select.component.ts +++ b/projects/legacy/components/multi-select/multi-select.component.ts @@ -14,7 +14,6 @@ import type { TuiActiveZoneDirective, TuiBooleanHandler, TuiContext, - TuiFocusableElementAccessor, TuiMapper, TuiStringHandler, } from '@taiga-ui/cdk'; @@ -23,7 +22,6 @@ import { TUI_IS_MOBILE, TUI_TRUE_HANDLER, tuiArrayToggle, - tuiAsFocusableItemAccessor, tuiIsNativeFocused, tuiIsString, tuiPure, @@ -54,6 +52,8 @@ import { TEXTFIELD_CONTROLLER_PROVIDER, TUI_TEXTFIELD_WATCHED_CONTROLLER, } from '@taiga-ui/legacy/directives'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; import {FIXED_DROPDOWN_CONTROLLER_PROVIDER} from '@taiga-ui/legacy/utils'; import type {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; diff --git a/projects/legacy/components/multi-select/multi-select.directive.ts b/projects/legacy/components/multi-select/multi-select.directive.ts index b81f77d6ca31..7abed75a6d80 100644 --- a/projects/legacy/components/multi-select/multi-select.directive.ts +++ b/projects/legacy/components/multi-select/multi-select.directive.ts @@ -1,8 +1,8 @@ import {Directive} from '@angular/core'; import type {TuiBooleanHandler} from '@taiga-ui/cdk'; -import {tuiAsTextfieldHost} from '@taiga-ui/core'; import type {TuiItemsHandlers} from '@taiga-ui/kit'; import {AbstractTuiTextfieldHost} from '@taiga-ui/legacy/classes'; +import {tuiAsTextfieldHost} from '@taiga-ui/legacy/tokens'; import type {TuiMultiSelectComponent} from './multi-select.component'; diff --git a/projects/legacy/components/primitive-textfield/primitive-textfield-types.ts b/projects/legacy/components/primitive-textfield/primitive-textfield-types.ts index 889081176297..3a57c84bad64 100644 --- a/projects/legacy/components/primitive-textfield/primitive-textfield-types.ts +++ b/projects/legacy/components/primitive-textfield/primitive-textfield-types.ts @@ -1,5 +1,5 @@ -import type {TuiFocusableElementAccessor} from '@taiga-ui/cdk'; import type {AbstractTuiInteractive} from '@taiga-ui/legacy/classes'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; export type TuiPrimitiveTextfield = AbstractTuiInteractive & TuiFocusableElementAccessor & { diff --git a/projects/legacy/components/primitive-textfield/primitive-textfield.component.ts b/projects/legacy/components/primitive-textfield/primitive-textfield.component.ts index 788216b37b38..fc4cddf43b82 100644 --- a/projects/legacy/components/primitive-textfield/primitive-textfield.component.ts +++ b/projects/legacy/components/primitive-textfield/primitive-textfield.component.ts @@ -13,24 +13,21 @@ import { } from '@angular/core'; import type {TuiContext} from '@taiga-ui/cdk'; import { - tuiAsFocusableItemAccessor, tuiInjectElement, tuiIsNativeFocusedIn, tuiPure, tuiRetargetedBoundaryCrossing, } from '@taiga-ui/cdk'; import type {TuiSizeL, TuiSizeS} from '@taiga-ui/core'; -import { - TUI_TEXTFIELD_OPTIONS as OPTIONS, - tuiGetBorder, - TuiHintOptionsDirective, -} from '@taiga-ui/core'; +import {TUI_TEXTFIELD_OPTIONS as OPTIONS, TuiHintOptionsDirective} from '@taiga-ui/core'; import {AbstractTuiInteractive} from '@taiga-ui/legacy/classes'; import { TEXTFIELD_CONTROLLER_PROVIDER, TUI_TEXTFIELD_OPTIONS as LEGACY_OPTIONS, TUI_TEXTFIELD_WATCHED_CONTROLLER, } from '@taiga-ui/legacy/directives'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; +import {tuiGetBorder} from '@taiga-ui/legacy/utils'; import type {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; import {PolymorpheusOutletDirective} from '@tinkoff/ng-polymorpheus'; import type {Observable} from 'rxjs'; diff --git a/projects/legacy/components/primitive-textfield/primitive-textfield.directive.ts b/projects/legacy/components/primitive-textfield/primitive-textfield.directive.ts index 0f010d02af13..6ad66322e861 100644 --- a/projects/legacy/components/primitive-textfield/primitive-textfield.directive.ts +++ b/projects/legacy/components/primitive-textfield/primitive-textfield.directive.ts @@ -1,6 +1,6 @@ import {Directive, inject} from '@angular/core'; -import {tuiAsTextfieldHost} from '@taiga-ui/core'; import {AbstractTuiTextfieldHost} from '@taiga-ui/legacy/classes'; +import {tuiAsTextfieldHost} from '@taiga-ui/legacy/tokens'; import {TuiPrimitiveTextfieldComponent} from './primitive-textfield.component'; diff --git a/projects/legacy/components/primitive-textfield/test/textfield.component.spec.ts b/projects/legacy/components/primitive-textfield/test/textfield.component.spec.ts index c80547f1fb8e..0f8c8433ad75 100644 --- a/projects/legacy/components/primitive-textfield/test/textfield.component.spec.ts +++ b/projects/legacy/components/primitive-textfield/test/textfield.component.spec.ts @@ -1,7 +1,7 @@ import {Component, ElementRef, ViewChild} from '@angular/core'; import type {ComponentFixture} from '@angular/core/testing'; import {TestBed} from '@angular/core/testing'; -import {TUI_TEXTFIELD_HOST} from '@taiga-ui/core/tokens'; +import {TUI_TEXTFIELD_HOST} from '@taiga-ui/legacy'; import {TuiPrimitiveTextfieldModule} from '../primitive-textfield.module'; diff --git a/projects/legacy/components/primitive-textfield/textfield/textfield.component.ts b/projects/legacy/components/primitive-textfield/textfield/textfield.component.ts index fbf25f95e219..32e55dbe9c4f 100644 --- a/projects/legacy/components/primitive-textfield/textfield/textfield.component.ts +++ b/projects/legacy/components/primitive-textfield/textfield/textfield.component.ts @@ -1,11 +1,11 @@ import {ChangeDetectionStrategy, Component, inject} from '@angular/core'; import {TuiIdService, tuiInjectElement} from '@taiga-ui/cdk'; -import type {TuiTextfieldHost} from '@taiga-ui/core'; -import {TUI_TEXTFIELD_HOST} from '@taiga-ui/core'; import { TEXTFIELD_CONTROLLER_PROVIDER, TUI_TEXTFIELD_WATCHED_CONTROLLER, } from '@taiga-ui/legacy/directives'; +import type {TuiTextfieldHost} from '@taiga-ui/legacy/tokens'; +import {TUI_TEXTFIELD_HOST} from '@taiga-ui/legacy/tokens'; @Component({ selector: 'input[tuiTextfieldLegacy], textarea[tuiTextfieldLegacy]', diff --git a/projects/legacy/components/primitive-textfield/value-decoration/value-decoration.component.ts b/projects/legacy/components/primitive-textfield/value-decoration/value-decoration.component.ts index 88170e27abea..7293907554db 100644 --- a/projects/legacy/components/primitive-textfield/value-decoration/value-decoration.component.ts +++ b/projects/legacy/components/primitive-textfield/value-decoration/value-decoration.component.ts @@ -8,7 +8,7 @@ import { inject, ViewChild, } from '@angular/core'; -import {TUI_FOCUSABLE_ITEM_ACCESSOR, TUI_FONTS_READY} from '@taiga-ui/cdk'; +import {TUI_FOCUSABLE_ITEM_ACCESSOR, TUI_FONTS_READY} from '@taiga-ui/legacy/tokens'; import {BehaviorSubject, delay, distinctUntilChanged, filter, map, merge} from 'rxjs'; import type {TuiPrimitiveTextfield} from '../primitive-textfield-types'; diff --git a/projects/legacy/components/select/select.component.ts b/projects/legacy/components/select/select.component.ts index 977d94020d46..1bd17e97d19c 100644 --- a/projects/legacy/components/select/select.component.ts +++ b/projects/legacy/components/select/select.component.ts @@ -8,16 +8,8 @@ import { TemplateRef, ViewChild, } from '@angular/core'; -import type { - TuiActiveZoneDirective, - TuiContext, - TuiFocusableElementAccessor, -} from '@taiga-ui/cdk'; -import { - TUI_IS_MOBILE, - tuiAsFocusableItemAccessor, - tuiIsNativeFocused, -} from '@taiga-ui/cdk'; +import type {TuiActiveZoneDirective, TuiContext} from '@taiga-ui/cdk'; +import {TUI_IS_MOBILE, tuiIsNativeFocused} from '@taiga-ui/cdk'; import type { TuiDataListHost, TuiSizeL, @@ -42,6 +34,8 @@ import {TUI_ARROW_MODE} from '@taiga-ui/legacy/components/arrow'; import {TuiPrimitiveTextfieldComponent} from '@taiga-ui/legacy/components/primitive-textfield'; import {TUI_SELECT_OPTION} from '@taiga-ui/legacy/components/select-option'; import {TUI_TEXTFIELD_CLEANER, TUI_TEXTFIELD_SIZE} from '@taiga-ui/legacy/directives'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; import {FIXED_DROPDOWN_CONTROLLER_PROVIDER} from '@taiga-ui/legacy/utils'; import type {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; diff --git a/projects/legacy/components/select/select.directive.ts b/projects/legacy/components/select/select.directive.ts index 93577a44df6e..7bbd6cf32eaa 100644 --- a/projects/legacy/components/select/select.directive.ts +++ b/projects/legacy/components/select/select.directive.ts @@ -1,7 +1,7 @@ import {Directive} from '@angular/core'; -import {tuiAsTextfieldHost} from '@taiga-ui/core'; import type {TuiItemsHandlers} from '@taiga-ui/kit'; import {AbstractTuiTextfieldHost} from '@taiga-ui/legacy/classes'; +import {tuiAsTextfieldHost} from '@taiga-ui/legacy/tokens'; import type {TuiSelectComponent} from './select.component'; diff --git a/projects/legacy/components/textarea/textarea.component.ts b/projects/legacy/components/textarea/textarea.component.ts index f8d2543c2547..dba1d50e327a 100644 --- a/projects/legacy/components/textarea/textarea.component.ts +++ b/projects/legacy/components/textarea/textarea.component.ts @@ -9,14 +9,10 @@ import { Input, ViewChild, } from '@angular/core'; -import type {TuiContext, TuiFocusableElementAccessor} from '@taiga-ui/cdk'; -import {TUI_IS_IOS, tuiAsFocusableItemAccessor, tuiIsNativeFocused} from '@taiga-ui/cdk'; +import type {TuiContext} from '@taiga-ui/cdk'; +import {TUI_IS_IOS, tuiIsNativeFocused} from '@taiga-ui/cdk'; import type {TuiSizeL, TuiSizeS} from '@taiga-ui/core'; -import { - TUI_TEXTFIELD_OPTIONS, - tuiGetBorder, - TuiHintOptionsDirective, -} from '@taiga-ui/core'; +import {TUI_TEXTFIELD_OPTIONS, TuiHintOptionsDirective} from '@taiga-ui/core'; import {AbstractTuiControl, tuiAsControl} from '@taiga-ui/legacy/classes'; import { TUI_ICON_PADDINGS, @@ -26,6 +22,9 @@ import { TEXTFIELD_CONTROLLER_PROVIDER, TUI_TEXTFIELD_WATCHED_CONTROLLER, } from '@taiga-ui/legacy/directives'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; +import {tuiAsFocusableItemAccessor} from '@taiga-ui/legacy/tokens'; +import {tuiGetBorder} from '@taiga-ui/legacy/utils'; import type {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; export const DEFAULT_ROWS = 20; diff --git a/projects/legacy/components/textarea/textarea.directive.ts b/projects/legacy/components/textarea/textarea.directive.ts index dc3824f28b7b..fda61ff7e1e6 100644 --- a/projects/legacy/components/textarea/textarea.directive.ts +++ b/projects/legacy/components/textarea/textarea.directive.ts @@ -1,6 +1,6 @@ import {Directive} from '@angular/core'; -import {tuiAsTextfieldHost} from '@taiga-ui/core'; import {AbstractTuiTextfieldHost} from '@taiga-ui/legacy/classes'; +import {tuiAsTextfieldHost} from '@taiga-ui/legacy/tokens'; import type {TuiTextareaComponent} from './textarea.component'; diff --git a/projects/legacy/directives/index.ts b/projects/legacy/directives/index.ts index 9f4ef7aed142..2d0c5854adfb 100644 --- a/projects/legacy/directives/index.ts +++ b/projects/legacy/directives/index.ts @@ -1,4 +1,5 @@ export * from '@taiga-ui/legacy/directives/legacy-dropdown-open-monitor'; export * from '@taiga-ui/legacy/directives/textfield-controller'; +export * from '@taiga-ui/legacy/directives/unfinished-validator'; export * from '@taiga-ui/legacy/directives/value-accessor'; export * from '@taiga-ui/legacy/directives/wrapper'; diff --git a/projects/legacy/directives/textfield-controller/textfield-controller.provider.ts b/projects/legacy/directives/textfield-controller/textfield-controller.provider.ts index ac6020e61a7d..305a616b7668 100644 --- a/projects/legacy/directives/textfield-controller/textfield-controller.provider.ts +++ b/projects/legacy/directives/textfield-controller/textfield-controller.provider.ts @@ -2,7 +2,7 @@ import type {Provider} from '@angular/core'; import {ChangeDetectorRef, InjectionToken} from '@angular/core'; import {takeUntilDestroyed} from '@angular/core/rxjs-interop'; import {tuiWatch} from '@taiga-ui/cdk'; -import {TUI_TEXTFIELD_APPEARANCE} from '@taiga-ui/core'; +import {TUI_TEXTFIELD_APPEARANCE} from '@taiga-ui/legacy/tokens'; import {merge, NEVER} from 'rxjs'; import {TuiTextfieldController} from './textfield.controller'; diff --git a/projects/legacy/directives/unfinished-validator/index.ts b/projects/legacy/directives/unfinished-validator/index.ts new file mode 100644 index 000000000000..c7887952065c --- /dev/null +++ b/projects/legacy/directives/unfinished-validator/index.ts @@ -0,0 +1,2 @@ +export * from './unfinished.validator'; +export * from './unfinished-validator.directive'; diff --git a/projects/legacy/directives/unfinished-validator/ng-package.json b/projects/legacy/directives/unfinished-validator/ng-package.json new file mode 100644 index 000000000000..bebf62dcb5e5 --- /dev/null +++ b/projects/legacy/directives/unfinished-validator/ng-package.json @@ -0,0 +1,5 @@ +{ + "lib": { + "entryFile": "index.ts" + } +} diff --git a/projects/legacy/directives/unfinished-validator/unfinished-validator.directive.ts b/projects/legacy/directives/unfinished-validator/unfinished-validator.directive.ts new file mode 100644 index 000000000000..cd42cd7bc365 --- /dev/null +++ b/projects/legacy/directives/unfinished-validator/unfinished-validator.directive.ts @@ -0,0 +1,21 @@ +import {Directive, inject, INJECTOR} from '@angular/core'; +import type {Validator} from '@angular/forms'; +import {NG_VALIDATORS} from '@angular/forms'; +import {tuiInjectElement, tuiProvide} from '@taiga-ui/cdk'; +import {TUI_FOCUSABLE_ITEM_ACCESSOR} from '@taiga-ui/legacy/tokens'; + +import {tuiCreateUnfinishedValidator} from './unfinished.validator'; + +@Directive({ + standalone: true, + selector: '[tuiUnfinishedValidator]', + providers: [tuiProvide(NG_VALIDATORS, TuiUnfinishedValidatorDirective, true)], +}) +export class TuiUnfinishedValidatorDirective implements Validator { + private readonly injector = inject(INJECTOR); + + public readonly validate = tuiCreateUnfinishedValidator( + () => this.injector.get(TUI_FOCUSABLE_ITEM_ACCESSOR), + tuiInjectElement().getAttribute('tuiUnfinishedValidator') || '', + ); +} diff --git a/projects/legacy/directives/unfinished-validator/unfinished.validator.ts b/projects/legacy/directives/unfinished-validator/unfinished.validator.ts new file mode 100644 index 000000000000..17cae189d758 --- /dev/null +++ b/projects/legacy/directives/unfinished-validator/unfinished.validator.ts @@ -0,0 +1,23 @@ +import type {AbstractControl, ValidatorFn} from '@angular/forms'; +import {tuiIsHTMLElement, tuiIsInput, TuiValidationError} from '@taiga-ui/cdk'; +import type {TuiFocusableElementAccessor} from '@taiga-ui/legacy/tokens'; +import type {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; + +export function tuiCreateUnfinishedValidator( + nativeInputGetter: () => TuiFocusableElementAccessor, + message: PolymorpheusContent, +): ValidatorFn { + return ({ + value, + }: AbstractControl): {unfinished: TuiValidationError | string} | null => { + const nativeInput = nativeInputGetter(); + + return value === null && + nativeInput && + tuiIsHTMLElement(nativeInput.nativeFocusableElement) && + tuiIsInput(nativeInput.nativeFocusableElement) && + nativeInput.nativeFocusableElement.value !== '' + ? {unfinished: new TuiValidationError(message)} + : null; + }; +} diff --git a/projects/legacy/directives/value-accessor/value-accessor.provider.ts b/projects/legacy/directives/value-accessor/value-accessor.provider.ts index 246e824afe6a..c2fa85069d65 100644 --- a/projects/legacy/directives/value-accessor/value-accessor.provider.ts +++ b/projects/legacy/directives/value-accessor/value-accessor.provider.ts @@ -1,7 +1,7 @@ import type {FactoryProvider} from '@angular/core'; import {Optional, Self} from '@angular/core'; import {NG_VALUE_ACCESSOR} from '@angular/forms'; -import {TUI_VALUE_ACCESSOR} from '@taiga-ui/core'; +import {TUI_VALUE_ACCESSOR} from '@taiga-ui/legacy/tokens'; import {identity} from 'rxjs'; export const TUI_VALUE_ACCESSOR_PROVIDER: FactoryProvider = { diff --git a/projects/cdk/tokens/focusable-item-accessor.ts b/projects/legacy/tokens/focusable-item-accessor.ts similarity index 55% rename from projects/cdk/tokens/focusable-item-accessor.ts rename to projects/legacy/tokens/focusable-item-accessor.ts index 4e93ca30c5a1..ad4150a06619 100644 --- a/projects/cdk/tokens/focusable-item-accessor.ts +++ b/projects/legacy/tokens/focusable-item-accessor.ts @@ -1,7 +1,18 @@ import type {Provider, Type} from '@angular/core'; import {InjectionToken} from '@angular/core'; -import type {TuiFocusableElementAccessor} from '@taiga-ui/cdk/types'; -import {tuiProvide} from '@taiga-ui/cdk/utils'; +import {tuiProvide} from '@taiga-ui/cdk'; +import type {Observable} from 'rxjs'; + +export interface TuiNativeFocusableElement extends Element, HTMLOrSVGElement {} + +/** + * Public interface for any focusable component or directive + */ +export interface TuiFocusableElementAccessor { + focused: boolean; + readonly focusedChange: Observable; + nativeFocusableElement: TuiNativeFocusableElement | null; +} /** * A component that can be focused diff --git a/projects/cdk/tokens/fonts-ready.ts b/projects/legacy/tokens/fonts-ready.ts similarity index 100% rename from projects/cdk/tokens/fonts-ready.ts rename to projects/legacy/tokens/fonts-ready.ts diff --git a/projects/legacy/tokens/index.ts b/projects/legacy/tokens/index.ts index dc8149747372..fe195008359a 100644 --- a/projects/legacy/tokens/index.ts +++ b/projects/legacy/tokens/index.ts @@ -1,2 +1,12 @@ export * from './countries-masks'; +export * from './focusable-item-accessor'; +export * from './fonts-ready'; +export * from './is-apple'; +export * from './is-chromium'; +export * from './is-firefox'; +export * from './is-stackblitz'; export * from './month-formatter'; +export * from './textfield-appearance'; +export * from './textfield-host'; +export * from './touch-supported'; +export * from './value-accessor'; diff --git a/projects/cdk/tokens/is-apple.ts b/projects/legacy/tokens/is-apple.ts similarity index 67% rename from projects/cdk/tokens/is-apple.ts rename to projects/legacy/tokens/is-apple.ts index 84b08956a936..72bf4853ce47 100644 --- a/projects/cdk/tokens/is-apple.ts +++ b/projects/legacy/tokens/is-apple.ts @@ -1,6 +1,7 @@ import {inject} from '@angular/core'; import {NAVIGATOR} from '@ng-web-apis/common'; -import {tuiCreateTokenFromFactory, tuiIsApple} from '@taiga-ui/cdk/utils'; +import {tuiCreateTokenFromFactory} from '@taiga-ui/cdk'; +import {tuiIsApple} from '@taiga-ui/legacy/utils'; /** * Apple(safari/webkit) detection diff --git a/projects/cdk/tokens/is-chromium.ts b/projects/legacy/tokens/is-chromium.ts similarity index 80% rename from projects/cdk/tokens/is-chromium.ts rename to projects/legacy/tokens/is-chromium.ts index effca9a181da..a7e1c44d70ad 100644 --- a/projects/cdk/tokens/is-chromium.ts +++ b/projects/legacy/tokens/is-chromium.ts @@ -1,6 +1,6 @@ import {inject} from '@angular/core'; import {WINDOW} from '@ng-web-apis/common'; -import {tuiCreateTokenFromFactory} from '@taiga-ui/cdk/utils'; +import {tuiCreateTokenFromFactory} from '@taiga-ui/cdk'; /** * Chromium browser engine detection diff --git a/projects/cdk/tokens/is-firefox.ts b/projects/legacy/tokens/is-firefox.ts similarity index 83% rename from projects/cdk/tokens/is-firefox.ts rename to projects/legacy/tokens/is-firefox.ts index c4456e814b8b..51f4169b0517 100644 --- a/projects/cdk/tokens/is-firefox.ts +++ b/projects/legacy/tokens/is-firefox.ts @@ -1,6 +1,6 @@ import {inject} from '@angular/core'; import {WINDOW} from '@ng-web-apis/common'; -import {tuiCreateTokenFromFactory} from '@taiga-ui/cdk/utils'; +import {tuiCreateTokenFromFactory} from '@taiga-ui/cdk'; /** * Firefox browser engine detection diff --git a/projects/cdk/tokens/is-stackblitz.ts b/projects/legacy/tokens/is-stackblitz.ts similarity index 77% rename from projects/cdk/tokens/is-stackblitz.ts rename to projects/legacy/tokens/is-stackblitz.ts index 532aab8a051c..faf078063724 100644 --- a/projects/cdk/tokens/is-stackblitz.ts +++ b/projects/legacy/tokens/is-stackblitz.ts @@ -1,6 +1,6 @@ import {inject} from '@angular/core'; import {WINDOW} from '@ng-web-apis/common'; -import {tuiCreateTokenFromFactory} from '@taiga-ui/cdk/utils'; +import {tuiCreateTokenFromFactory} from '@taiga-ui/cdk'; export const TUI_IS_STACKBLITZ = tuiCreateTokenFromFactory(() => inject(WINDOW).location.host.endsWith('stackblitz.io'), diff --git a/projects/core/tokens/textfield-appearance.ts b/projects/legacy/tokens/textfield-appearance.ts similarity index 87% rename from projects/core/tokens/textfield-appearance.ts rename to projects/legacy/tokens/textfield-appearance.ts index 305a17ba6812..cf241d0e50c4 100644 --- a/projects/core/tokens/textfield-appearance.ts +++ b/projects/legacy/tokens/textfield-appearance.ts @@ -3,6 +3,5 @@ import {tuiCreateToken} from '@taiga-ui/cdk'; /** * Appearance for inputs * @deprecated use {@link TUI_TEXTFIELD_APPEARANCE_DIRECTIVE} instead - * TODO: Move to legacy in 4.0 */ export const TUI_TEXTFIELD_APPEARANCE = tuiCreateToken('textfield'); diff --git a/projects/core/types/textfield-host.ts b/projects/legacy/tokens/textfield-host.ts similarity index 50% rename from projects/core/types/textfield-host.ts rename to projects/legacy/tokens/textfield-host.ts index ebdb391f19d2..8fee4c25114d 100644 --- a/projects/core/types/textfield-host.ts +++ b/projects/legacy/tokens/textfield-host.ts @@ -1,4 +1,7 @@ -// TODO: move to legacy before 4.0 +import type {Provider, Type} from '@angular/core'; +import {InjectionToken} from '@angular/core'; +import {tuiProvide} from '@taiga-ui/cdk'; + export interface TuiTextfieldHost { readonly disabled: boolean; readonly focusable: boolean; @@ -17,3 +20,14 @@ export interface TuiTextfieldHost { readonly readOnly: boolean; readonly value: string; } + +/** + * An interface to communicate with textfield based controls + */ +export const TUI_TEXTFIELD_HOST = new InjectionToken( + '[TUI_TEXTFIELD_HOST]', +); + +export function tuiAsTextfieldHost(host: Type): Provider { + return tuiProvide(TUI_TEXTFIELD_HOST, host); +} diff --git a/projects/cdk/tokens/touch-supported.ts b/projects/legacy/tokens/touch-supported.ts similarity index 77% rename from projects/cdk/tokens/touch-supported.ts rename to projects/legacy/tokens/touch-supported.ts index a9d9b76e9d4f..afad7513b585 100644 --- a/projects/cdk/tokens/touch-supported.ts +++ b/projects/legacy/tokens/touch-supported.ts @@ -1,6 +1,6 @@ import {inject} from '@angular/core'; import {WINDOW} from '@ng-web-apis/common'; -import {tuiCreateTokenFromFactory} from '@taiga-ui/cdk/utils'; +import {tuiCreateTokenFromFactory} from '@taiga-ui/cdk'; export const TUI_TOUCH_SUPPORTED = tuiCreateTokenFromFactory( () => inject(WINDOW).matchMedia('(any-pointer: coarse)').matches, diff --git a/projects/core/tokens/value-accessor.ts b/projects/legacy/tokens/value-accessor.ts similarity index 85% rename from projects/core/tokens/value-accessor.ts rename to projects/legacy/tokens/value-accessor.ts index 5ba011fc803f..1d511952d63f 100644 --- a/projects/core/tokens/value-accessor.ts +++ b/projects/legacy/tokens/value-accessor.ts @@ -4,7 +4,6 @@ import type {ControlValueAccessor} from '@angular/forms'; /** * Buffer token to pass NG_VALUE_ACCESSOR to a different Injector * @deprecated - * TODO: remove after textfield refactor before 4.0 */ export const TUI_VALUE_ACCESSOR = new InjectionToken( '[TUI_VALUE_ACCESSOR]', diff --git a/projects/core/utils/miscellaneous/get-border.ts b/projects/legacy/utils/get-border.ts similarity index 90% rename from projects/core/utils/miscellaneous/get-border.ts rename to projects/legacy/utils/get-border.ts index 954c9543c19b..9d29a5546315 100644 --- a/projects/core/utils/miscellaneous/get-border.ts +++ b/projects/legacy/utils/get-border.ts @@ -1,4 +1,4 @@ -import type {TuiSizeL, TuiSizeS} from '@taiga-ui/core/types'; +import type {TuiSizeL, TuiSizeS} from '@taiga-ui/core'; const ITEM_SIZE = 1.5; const CONTENT_SIZE = 2.5; diff --git a/projects/legacy/utils/index.ts b/projects/legacy/utils/index.ts index d5d0b04852fb..6517b9a31ee9 100644 --- a/projects/legacy/utils/index.ts +++ b/projects/legacy/utils/index.ts @@ -1,7 +1,9 @@ export * from './date-mode-maskito-adapter'; export * from './format-phone'; +export * from './get-border'; export * from './get-max-allowed-phone-length'; export * from './get-safe-area-size'; +export * from './is-apple'; export * from './iso-to-country-code'; export * from './not-kz-region'; export * from './specific-dropdown-controllers'; diff --git a/projects/legacy/utils/is-apple.ts b/projects/legacy/utils/is-apple.ts new file mode 100644 index 000000000000..c2fdedf682cf --- /dev/null +++ b/projects/legacy/utils/is-apple.ts @@ -0,0 +1,7 @@ +import {tuiIsIos} from '@taiga-ui/cdk'; + +const SAFARI_REG_EXP = /^((?!chrome|android).)*safari/i; + +export function tuiIsApple(navigator: Navigator): boolean { + return tuiIsIos(navigator) || SAFARI_REG_EXP.test(navigator.userAgent.toLowerCase()); +} diff --git a/projects/core/utils/miscellaneous/test/get-border.spec.ts b/projects/legacy/utils/tests/get-border.spec.ts similarity index 86% rename from projects/core/utils/miscellaneous/test/get-border.spec.ts rename to projects/legacy/utils/tests/get-border.spec.ts index e3a46c207654..104aa1426dfe 100644 --- a/projects/core/utils/miscellaneous/test/get-border.spec.ts +++ b/projects/legacy/utils/tests/get-border.spec.ts @@ -1,4 +1,4 @@ -import {tuiGetBorder} from '../get-border'; +import {tuiGetBorder} from '@taiga-ui/legacy'; describe('getBorder', () => { it('calculates all options', () => {