Skip to content

Commit

Permalink
refactor: remove deprecated re-exports (#2199)
Browse files Browse the repository at this point in the history
* refactor: remove deprecated re-exports

* chore: fix comments

* chore: rename function
  • Loading branch information
vladimirpotekhin authored and splincode committed Jul 29, 2022
1 parent 128b31b commit 309cb84
Show file tree
Hide file tree
Showing 36 changed files with 142 additions and 284 deletions.
31 changes: 13 additions & 18 deletions projects/addon-doc/src/languages/russian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,39 @@ import {
TUI_DOC_SOURCE_CODE_TEXT,
} from '../tokens/i18n';

// TODO: 3.0 remove in ivy compilation
export const DEMO_TEXTS = [`Сделано с помощью директивы: `, `Фон`, `Детали формы`];
export const DOC_TEXTS = [
`Аргумент`,
`Тип`,
`Имя и описание`,
`Значение`,
`Для работы с динамическими шаблонами используется`,
];
export const EXAMPLE_TEXTS = [`Превью`, `Ссылка на пример скопирована`, `Готово`];

export const TUI_DOC_RUSSIAN: Provider[] = [
{
provide: TUI_DOC_DEMO_TEXTS,
useValue: DEMO_TEXTS,
useValue: ['Сделано с помощью директивы: ', 'Фон', 'Детали формы'],
},
{
provide: TUI_DOC_DOCUMENTATION_TEXTS,
useValue: DOC_TEXTS,
useValue: [
'Аргумент',
'Тип',
'Имя и описание',
'Значение',
'Для работы с динамическими шаблонами используется',
],
},
{
provide: TUI_DOC_EXAMPLE_TEXTS,
useValue: EXAMPLE_TEXTS,
useValue: ['Превью', 'Ссылка на пример скопирована', 'Готово'],
},
{
provide: TUI_DOC_MENU_TEXT,
useValue: `Меню`,
useValue: 'Меню',
},
{
provide: TUI_DOC_SEARCH_TEXT,
useValue: `Поиск`,
useValue: 'Поиск',
},
{
provide: TUI_DOC_SEE_ALSO_TEXT,
useValue: `Смотрите также`,
useValue: 'Смотрите также',
},
{
provide: TUI_DOC_SOURCE_CODE_TEXT,
useValue: `Исходный код`,
useValue: 'Исходный код',
},
];
8 changes: 0 additions & 8 deletions projects/addon-editor/extensions/default-editor-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ export function starterKitExtractor<T>(importedExtension: {
return importedExtension.StarterKit;
}

// TODO: 3.0 remove in ivy compilation
// eslint-disable-next-line @typescript-eslint/naming-convention
export function defaultExtractor<T>(importedExtension: {
default: Extension<T>;
}): Extension<T> {
return importedExtension.default;
}

// TODO: 3.0 remove in ivy compilation
// eslint-disable-next-line @typescript-eslint/naming-convention
export function starterKitConfigurator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import {TUI_MOBILE_CALENDAR} from '@taiga-ui/kit';

import {TuiMobileCalendarDialogComponent} from './mobile-calendar-dialog.component';

// TODO: 3.0 remove in ivy compilation
export const MOBILE_CALENDAR_COMPONENT = TuiMobileCalendarDialogComponent;

@NgModule({
imports: [TuiMobileCalendarModule],
declarations: [TuiMobileCalendarDialogComponent],
Expand All @@ -15,7 +12,7 @@ export const MOBILE_CALENDAR_COMPONENT = TuiMobileCalendarDialogComponent;
providers: [
{
provide: TUI_MOBILE_CALENDAR,
useValue: MOBILE_CALENDAR_COMPONENT,
useValue: TuiMobileCalendarDialogComponent,
},
],
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import {Directive} from '@angular/core';
import {TUI_BUTTON_OPTIONS, TuiButtonOptions} from '@taiga-ui/core';

// TODO: 3.0 remove in ivy compilation
export const PREVIEW_ACTION_OPTIONS: TuiButtonOptions = {
appearance: `preview-action`,
shape: `rounded`,
size: `s`,
};
import {tuiButtonOptionsProvider} from '@taiga-ui/core';

@Directive({
selector: `[tuiPreviewAction]`,
selector: '[tuiPreviewAction]',
providers: [
{
provide: TUI_BUTTON_OPTIONS,
useValue: PREVIEW_ACTION_OPTIONS,
},
tuiButtonOptionsProvider({
appearance: 'preview-action',
shape: 'rounded',
size: 's',
}),
],
})
export class TuiPreviewActionDirective {}
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import {ChangeDetectorRef, Provider, SkipSelf} from '@angular/core';
import {TuiDestroyService} from '@taiga-ui/cdk';
import {watchedControllerFactory} from '@taiga-ui/core';
import {tuiWatchedControllerFactory} from '@taiga-ui/core';

import {TuiTableDirective} from '../directives/table.directive';
import {TuiTableSortPipe} from '../pipes/table-sort.pipe';

// TODO: 3.0 remove in ivy compilation
export const TABLE_FACTORY = watchedControllerFactory;

export const TUI_TABLE_PROVIDER: Provider[] = [
TuiDestroyService,
TuiTableSortPipe,
{
provide: TuiTableDirective,
deps: [[new SkipSelf(), TuiTableDirective], ChangeDetectorRef, TuiDestroyService],
useFactory: TABLE_FACTORY,
useFactory: tuiWatchedControllerFactory,
},
];
18 changes: 7 additions & 11 deletions projects/addon-table/components/table/providers/table.providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ import {
TUI_TEXTFIELD_APPEARANCE,
TUI_TEXTFIELD_LABEL_OUTSIDE,
TUI_TEXTFIELD_SIZE,
TuiAppearance,
} from '@taiga-ui/core';
import {TUI_INPUT_COUNT_OPTIONS, TuiInputCountOptions} from '@taiga-ui/kit';

import {TuiTableDirective} from '../directives/table.directive';
import {TUI_STUCK_PROVIDER} from './stuck.provider';

// TODO: 3.0 remove in ivy compilation
export const TABLE_THRESHOLD = [0, 1];
export const TABLE_LABEL = {
labelOutside: true,
};

// eslint-disable-next-line @typescript-eslint/naming-convention
export function inputCountOptionsFactory(
options: TuiInputCountOptions,
Expand All @@ -31,20 +26,21 @@ export function inputCountOptionsFactory(
export const TUI_TABLE_PROVIDERS = [
{
provide: INTERSECTION_ROOT_MARGIN,
useValue: `10000px 10000px 10000px 0px`,
useValue: '10000px 10000px 10000px 0px',
},
{
provide: INTERSECTION_THRESHOLD,
useValue: TABLE_THRESHOLD,
useValue: [0, 1],
},
{
provide: TUI_TEXTFIELD_APPEARANCE,
// TODO: 3.0 remove in ivy compilation
useValue: `table`, // TuiAppearance.Table
useValue: TuiAppearance.Table,
},
{
provide: TUI_TEXTFIELD_LABEL_OUTSIDE,
useValue: TABLE_LABEL,
useValue: {
labelOutside: true,
},
},
{
provide: TUI_INPUT_COUNT_OPTIONS,
Expand Down
16 changes: 7 additions & 9 deletions projects/cdk/components/dialog-host/dialog-host.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,23 @@ import {combineLatest, Observable, of} from 'rxjs';
import {map} from 'rxjs/operators';

export const TUI_DIALOG_CLOSES_ON_BACK = new InjectionToken<Observable<boolean>>(
`Is closing dialog on browser backward navigation enabled`,
'Is closing dialog on browser backward navigation enabled',
{
factory: () => of(false),
},
);

// TODO: 3.0 remove in ivy compilation
export const FAKE_HISTORY_STATE = {label: `ignoreMe`} as const;
// TODO: 3.0 remove in ivy compilation
export const isFakeHistoryState = (
const FAKE_HISTORY_STATE = {label: 'ignoreMe'} as const;
const isFakeHistoryState = (
historyState: Record<string, unknown>,
): historyState is typeof FAKE_HISTORY_STATE =>
historyState?.label === FAKE_HISTORY_STATE.label;

// @dynamic
@Component({
selector: `tui-dialog-host`,
templateUrl: `./dialog-host.template.html`,
styleUrls: [`./dialog-host.style.less`],
selector: 'tui-dialog-host',
templateUrl: './dialog-host.template.html',
styleUrls: ['./dialog-host.style.less'],
changeDetection: ChangeDetectionStrategy.OnPush,
animations: [TUI_PARENT_ANIMATION],
})
Expand Down Expand Up @@ -71,7 +69,7 @@ export class TuiDialogHostComponent<T extends TuiDialog<unknown, unknown>> {
popupOpened: boolean,
isDialogClosesOnBack: boolean,
): void {
if (!isDialogClosesOnBack || propertyName !== `letter-spacing`) {
if (!isDialogClosesOnBack || propertyName !== 'letter-spacing') {
return;
}

Expand Down
48 changes: 22 additions & 26 deletions projects/cdk/directives/auto-focus/autofocus.options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,32 @@ export const TUI_AUTOFOCUS_HANDLER = new InjectionToken<TuiAutofocusHandler>(
`Autofocusing handler`,
);

// TODO: 3.0 remove in ivy compilation
export function tuiAutofocusHandlerFactory(
tuiFocusableComponent: TuiFocusableElementAccessor | null,
elementRef: ElementRef<HTMLElement>,
animationFrame$: Observable<number>,
renderer: Renderer2,
ngZone: NgZone,
windowRef: Window,
isIos: boolean,
): TuiAutofocusHandler {
return isIos
? new TuiIosAutofocusHandler(
tuiFocusableComponent,
elementRef,
renderer,
ngZone,
windowRef,
)
: new TuiDefaultAutofocusHandler(
tuiFocusableComponent,
elementRef,
animationFrame$,
);
}

export const TUI_AUTOFOCUS_PROVIDERS = [
{
provide: TUI_AUTOFOCUS_HANDLER,
// TODO: replace to useClass in v3.0
useFactory: tuiAutofocusHandlerFactory,
useFactory: (
tuiFocusableComponent: TuiFocusableElementAccessor | null,
elementRef: ElementRef<HTMLElement>,
animationFrame$: Observable<number>,
renderer: Renderer2,
ngZone: NgZone,
windowRef: Window,
isIos: boolean,
) =>
isIos
? new TuiIosAutofocusHandler(
tuiFocusableComponent,
elementRef,
renderer,
ngZone,
windowRef,
)
: new TuiDefaultAutofocusHandler(
tuiFocusableComponent,
elementRef,
animationFrame$,
),
deps: [
[new Optional(), new Self(), TUI_FOCUSABLE_ITEM_ACCESSOR],
ElementRef,
Expand Down
3 changes: 1 addition & 2 deletions projects/cdk/observables/replay-control-value-changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import {startWith} from 'rxjs/operators';

/**
* Turns AbstractControl/Abstract-control-directive valueChanges into ReplaySubject(1)
* TODO: 3.0 name should be shorter.
*/
export function tuiReplayedValueChangesFrom<T>(
export function tuiControlValue<T>(
control: AbstractControl | AbstractControlDirective,
): Observable<T> {
return new Observable(subscriber => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {fakeAsync} from '@angular/core/testing';
import {AbstractControl, FormControl} from '@angular/forms';
import {tuiReplayedValueChangesFrom} from '@taiga-ui/cdk';
import {tuiControlValue} from '@taiga-ui/cdk';
import {skip} from 'rxjs/operators';

describe(`tuiReplayedValueChangesFrom`, () => {
it(`takes control and starts with its value`, fakeAsync(() => {
let actual = ``;
const control = new FormControl(`hello`);

tuiReplayedValueChangesFrom<string>(control).subscribe(value => {
tuiControlValue<string>(control).subscribe(value => {
actual = value;
});

Expand All @@ -19,7 +19,7 @@ describe(`tuiReplayedValueChangesFrom`, () => {
let actual = ``;
const control = new FormControl(`hello`);

tuiReplayedValueChangesFrom<string>(control)
tuiControlValue<string>(control)
.pipe(skip(1))
.subscribe(value => {
actual = value;
Expand All @@ -33,7 +33,7 @@ describe(`tuiReplayedValueChangesFrom`, () => {
it(`throws an error if there is no valueChanges`, fakeAsync(() => {
let actual = ``;

tuiReplayedValueChangesFrom({} as AbstractControl).subscribe(
tuiControlValue({} as AbstractControl).subscribe(
() => {},
(err: unknown) => {
actual = (err as Error).message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ export interface TuiPrimitiveTextfieldOptions {
readonly iconCleaner: PolymorpheusContent;
}

// TODO: 3.0 remove in ivy compilation
export const TUI_PRIMITIVE_TEXTFIELD_ICON_CLEANER = 'tuiIconCloseLarge';

/** Default values for primitive textfield options */
export const TUI_PRIMITIVE_TEXTFIELD_DEFAULT_OPTIONS: TuiPrimitiveTextfieldOptions = {
iconCleaner: TUI_PRIMITIVE_TEXTFIELD_ICON_CLEANER,
iconCleaner: 'tuiIconCloseLarge',
};

export const TUI_PRIMITIVE_TEXTFIELD_OPTIONS =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import {ChangeDetectorRef, InjectionToken, Provider} from '@angular/core';
import {TuiDestroyService} from '@taiga-ui/cdk';
import {watchedControllerFactory} from '@taiga-ui/core/providers';
import {tuiWatchedControllerFactory} from '@taiga-ui/core/providers';

import {TUI_DROPDOWN_CONTROLLER} from './dropdown-controller.token';

export const TUI_DROPDOWN_WATCHED_CONTROLLER = new InjectionToken(
`watched dropdown controller`,
);
// TODO: 3.0 remove in ivy compilation
export const DROPDOWN_CONTROLLER_FACTORY = watchedControllerFactory;

export const DROPDOWN_CONTROLLER_PROVIDER: Provider = [
TuiDestroyService,
{
provide: TUI_DROPDOWN_WATCHED_CONTROLLER,
deps: [TUI_DROPDOWN_CONTROLLER, ChangeDetectorRef, TuiDestroyService],
useFactory: DROPDOWN_CONTROLLER_FACTORY,
useFactory: tuiWatchedControllerFactory,
},
];
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import {ChangeDetectorRef, InjectionToken, Provider} from '@angular/core';
import {TuiDestroyService} from '@taiga-ui/cdk';
import {watchedControllerFactory} from '@taiga-ui/core/providers';
import {tuiWatchedControllerFactory} from '@taiga-ui/core/providers';

import {TUI_HINT_CONTROLLER} from './hint-controller.token';

export const TUI_HINT_WATCHED_CONTROLLER = new InjectionToken(`watched hint controller`);
// TODO: 3.0 remove in ivy compilation
export const HINT_CONTROLLER_FACTORY = watchedControllerFactory;
export const TUI_HINT_WATCHED_CONTROLLER = new InjectionToken('watched hint controller');

export const HINT_CONTROLLER_PROVIDER: Provider = [
TuiDestroyService,
{
provide: TUI_HINT_WATCHED_CONTROLLER,
deps: [TUI_HINT_CONTROLLER, ChangeDetectorRef, TuiDestroyService],
useFactory: HINT_CONTROLLER_FACTORY,
useFactory: tuiWatchedControllerFactory,
},
];
Loading

0 comments on commit 309cb84

Please sign in to comment.