Skip to content

Commit

Permalink
refactor!: move FallbackSrc, Initials, Autocolor pipes to core,…
Browse files Browse the repository at this point in the history
… make it standalone (#6961)

Co-authored-by: taiga-family-bot <[email protected]>
  • Loading branch information
vladimirpotekhin and taiga-family-bot authored Mar 7, 2024
1 parent 5ac9963 commit eabaf64
Show file tree
Hide file tree
Showing 47 changed files with 98 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,20 @@ export const IDENTIFIERS_TO_REPLACE: ReplacementIdentifier[] = [
moduleSpecifier: '@taiga-ui/kit',
},
},
{
from: {name: 'TuiInitialsModule', moduleSpecifier: '@taiga-ui/experimental'},
to: {name: 'TuiInitialsPipe', moduleSpecifier: '@taiga-ui/core'},
},
{
from: {name: 'TuiFallbackSrcModule', moduleSpecifier: '@taiga-ui/experimental'},
to: {name: 'TuiFallbackSrcPipe', moduleSpecifier: '@taiga-ui/core'},
},
{
from: {name: 'TuiAutoColorModule', moduleSpecifier: '@taiga-ui/experimental'},
to: {name: 'TuiAutoColorPipe', moduleSpecifier: '@taiga-ui/core'},
},
{
from: {name: 'tuiStringHashToHsl', moduleSpecifier: '@taiga-ui/kit'},
to: {name: 'tuiStringHashToHsl', moduleSpecifier: '@taiga-ui/core'},
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ export function migrateAvatar({

const modules = [
...(fallbackModule
? [{moduleName: 'TuiFallbackModule', moduleSpecifier: '@taiga-ui/cdk'}]
? [{moduleName: 'TuiFallbackSrcPipe', moduleSpecifier: '@taiga-ui/core'}]
: []),
...(initialsModule
? [{moduleName: 'TuiInitialsModule', moduleSpecifier: '@taiga-ui/cdk'}]
? [{moduleName: 'TuiInitialsPipe', moduleSpecifier: '@taiga-ui/core'}]
: []),
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import { TuiAvatarModule } from "@taiga-ui/experimental";
export class TestComponent {
}`;

const COMPONENT_AFTER = `import { TuiFallbackModule, TuiInitialsModule } from "@taiga-ui/cdk";
const COMPONENT_AFTER = `import { TuiFallbackSrcPipe, TuiInitialsPipe } from "@taiga-ui/core";
import { TuiAvatarModule } from "@taiga-ui/kit";
@Component({
standalone: true,
templateUrl: './test.template.html',
imports: [TuiAvatarModule, TuiFallbackModule, TuiInitialsModule]
imports: [TuiAvatarModule, TuiFallbackSrcPipe, TuiInitialsPipe]
})
export class TestComponent {
}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import { TuiBadgedContentModule } from "@taiga-ui/experimental";
export class TestComponent {
}`;

const COMPONENT_AFTER = `import { TuiInitialsModule } from "@taiga-ui/cdk";
const COMPONENT_AFTER = `import { TuiInitialsPipe } from "@taiga-ui/core";
import { TuiBadgedContentComponent } from "@taiga-ui/kit";
@Component({
standalone: true,
templateUrl: './test.template.html',
imports: [TuiBadgedContentComponent, TuiInitialsModule]
imports: [TuiBadgedContentComponent, TuiInitialsPipe]
})
export class TestComponent {
}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type {PipeTransform} from '@angular/core';
import {Pipe} from '@angular/core';
import {tuiStringHashToHsl} from '@taiga-ui/kit';
import {tuiStringHashToHsl} from '@taiga-ui/core/utils';

@Pipe({
standalone: true,
name: 'tuiAutoColor',
})
export class TuiAutoColorPipe implements PipeTransform {
Expand Down
1 change: 1 addition & 0 deletions projects/core/pipes/auto-color/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './auto-color.pipe';
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type {PipeTransform} from '@angular/core';
import {ElementRef, inject, Pipe} from '@angular/core';
import {TUI_ICON_ERROR} from '@taiga-ui/core';
import {TUI_ICON_ERROR} from '@taiga-ui/core/constants';
import type {Observable} from 'rxjs';
import {fromEvent, map, merge, startWith} from 'rxjs';

@Pipe({
standalone: true,
name: 'tuiFallbackSrc',
})
export class TuiFallbackSrcPipe implements PipeTransform {
Expand Down
1 change: 1 addition & 0 deletions projects/core/pipes/fallback-src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './fallback-src.pipe';
3 changes: 3 additions & 0 deletions projects/core/pipes/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
export * from '@taiga-ui/core/pipes/auto-color';
export * from '@taiga-ui/core/pipes/calendar-sheet';
export * from '@taiga-ui/core/pipes/fallback-src';
export * from '@taiga-ui/core/pipes/flag';
export * from '@taiga-ui/core/pipes/format-date';
export * from '@taiga-ui/core/pipes/format-number';
export * from '@taiga-ui/core/pipes/format-phone';
export * from '@taiga-ui/core/pipes/initials';
export * from '@taiga-ui/core/pipes/month';
export * from '@taiga-ui/core/pipes/order-week-days';
1 change: 1 addition & 0 deletions projects/core/pipes/initials/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './initials.pipe';
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {PipeTransform} from '@angular/core';
import {Pipe} from '@angular/core';

@Pipe({
standalone: true,
name: 'tuiInitials',
})
export class TuiInitialsPipe implements PipeTransform {
Expand Down
1 change: 1 addition & 0 deletions projects/core/utils/format/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './format-phone';
export * from './get-fractional-part-padded';
export * from './number-to-string-without-exp';
export * from './other-decimal-symbol';
export * from './string-hash-to-hsl';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {tuiStringHashToHsl} from '@taiga-ui/kit';
import {tuiStringHashToHsl} from '../string-hash-to-hsl';

describe('Convert string to HSL color', () => {
it('The name in Russian is converted correctly', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
>
<tui-notification class="tui-space_bottom-4">
This example requires import of
<code>TuiFallbackSrcModule</code>
<code>TuiFallbackSrcPipe</code>
</tui-notification>
<tui-avatar-example-1></tui-avatar-example-1>
</tui-doc-example>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import {AsyncPipe} from '@angular/common';
import {Component} from '@angular/core';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiFallbackSrcModule} from '@taiga-ui/experimental';
import {TuiFallbackSrcPipe} from '@taiga-ui/core';
import {TuiAvatarComponent} from '@taiga-ui/kit';

@Component({
standalone: true,
selector: 'tui-avatar-example-1',
imports: [TuiAvatarComponent, TuiFallbackSrcModule, AsyncPipe],
imports: [TuiAvatarComponent, TuiFallbackSrcPipe, AsyncPipe],
templateUrl: './index.html',
styleUrls: ['./index.less'],
encapsulation,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {Component} from '@angular/core';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiAutoColorModule} from '@taiga-ui/experimental';
import {TuiAutoColorPipe} from '@taiga-ui/core';
import {TuiAvatarComponent, TuiFadeDirective} from '@taiga-ui/kit';

@Component({
standalone: true,
selector: 'tui-avatar-example-2',
imports: [TuiAvatarComponent, TuiAutoColorModule, TuiFadeDirective],
imports: [TuiAvatarComponent, TuiAutoColorPipe, TuiFadeDirective],
templateUrl: './index.html',
styleUrls: ['./index.less'],
encapsulation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Component} from '@angular/core';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import type {TuiSizeXS, TuiSizeXXL} from '@taiga-ui/core';
import {TuiAutoColorModule, TuiInitialsModule} from '@taiga-ui/experimental';
import {TuiAutoColorPipe, TuiInitialsPipe} from '@taiga-ui/core';
import {TuiAvatarComponent, TuiAvatarStackComponent} from '@taiga-ui/kit';

@Component({
Expand All @@ -13,8 +13,8 @@ import {TuiAvatarComponent, TuiAvatarStackComponent} from '@taiga-ui/kit';
TuiAvatarStackComponent,
NgForOf,
TuiAvatarComponent,
TuiInitialsModule,
TuiAutoColorModule,
TuiInitialsPipe,
TuiAutoColorPipe,
],
templateUrl: './index.html',
encapsulation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {AsyncPipe} from '@angular/common';
import {Component} from '@angular/core';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiFallbackSrcModule} from '@taiga-ui/experimental';
import {TuiFallbackSrcPipe} from '@taiga-ui/core';
import {
TuiAvatarComponent,
TuiAvatarLabeledComponent,
Expand All @@ -14,7 +14,7 @@ import {
selector: 'tui-avatar-example-6',
imports: [
AsyncPipe,
TuiFallbackSrcModule,
TuiFallbackSrcPipe,
TuiAvatarLabeledComponent,
TuiAvatarComponent,
TuiFadeDirective,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ import {NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
import {TuiAddonDocModule, tuiGenerateRoutes} from '@taiga-ui/addon-doc';
import {TuiPlatformModule} from '@taiga-ui/cdk';
import {TuiNotificationModule} from '@taiga-ui/core';
import {
TuiButtonModule,
TuiFallbackSrcModule,
TuiIconModule,
} from '@taiga-ui/experimental';
import {TuiFallbackSrcPipe, TuiNotificationModule} from '@taiga-ui/core';
import {TuiButtonModule, TuiIconModule} from '@taiga-ui/experimental';
import {
TuiAvatarComponent,
TuiBadgedContentComponent,
Expand All @@ -30,7 +26,7 @@ import {TuiBadgedContentExample3} from './examples/3';
TuiBadgeDirective,
TuiBadgedContentComponent,
TuiAvatarComponent,
TuiFallbackSrcModule,
TuiFallbackSrcPipe,
TuiInputModule,
TuiButtonModule,
TuiAddonDocModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {RouterModule} from '@angular/router';
import {TuiAddonDocModule, tuiGenerateRoutes} from '@taiga-ui/addon-doc';
import {TuiPlatformModule} from '@taiga-ui/cdk';
import {TuiButtonModule, TuiLinkModule} from '@taiga-ui/core';
import {TuiAutoColorModule, TuiInitialsModule} from '@taiga-ui/experimental';
import {
TuiAutoColorPipe,
TuiButtonModule,
TuiInitialsPipe,
TuiLinkModule,
} from '@taiga-ui/core';
import {TuiAvatarComponent} from '@taiga-ui/kit';
import {TuiBlockStatusModule} from '@taiga-ui/layout';

Expand All @@ -28,8 +32,8 @@ import {TuiBlockStatusExample5} from './examples/5';
RouterModule.forChild(tuiGenerateRoutes(ExampleTuiBlockStatusComponent)),
TuiPlatformModule,
TuiAvatarComponent,
TuiAutoColorModule,
TuiInitialsModule,
TuiAutoColorPipe,
TuiInitialsPipe,
],
declarations: [
ExampleTuiBlockStatusComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
TuiDataListModule,
TuiDropdownModule,
TuiHintModule,
TuiInitialsPipe,
TuiLinkModule,
TuiLoaderModule,
TuiNotificationModule,
Expand All @@ -22,7 +23,6 @@ import {
TuiSvgModule,
TuiTextfieldControllerModule,
} from '@taiga-ui/core';
import {TuiInitialsModule} from '@taiga-ui/experimental';
import {
TuiAvatarComponent,
TuiComboBoxModule,
Expand Down Expand Up @@ -72,7 +72,7 @@ import {TuiComboBoxExample8} from './examples/8';
RouterModule.forChild(tuiGenerateRoutes(ExampleTuiComboBoxComponent)),
TuiTextCodeModule,
TuiScrollableDirective,
TuiInitialsModule,
TuiInitialsPipe,
],
declarations: [
ExampleTuiComboBoxComponent,
Expand Down
4 changes: 2 additions & 2 deletions projects/demo/src/modules/components/input/input.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import {
TuiDropdownModule,
TuiGroupDirective,
TuiHintModule,
TuiInitialsPipe,
TuiLinkModule,
TuiModeModule,
TuiNotificationModule,
TuiPrimitiveTextfieldModule,
TuiSvgModule,
TuiTextfieldControllerModule,
} from '@taiga-ui/core';
import {TuiInitialsModule} from '@taiga-ui/experimental';
import {
TuiAvatarComponent,
TuiDataListWrapperModule,
Expand Down Expand Up @@ -87,7 +87,7 @@ import {ExampleTuiInputComponent} from './input.component';
TuiTextCodeModule,
MaskitoDirective,
TuiUnmaskHandlerModule,
TuiInitialsModule,
TuiInitialsPipe,
],
declarations: [
ExampleTuiInputComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import {
TuiDataListModule,
TuiDropdownModule,
TuiHintModule,
TuiInitialsPipe,
TuiLabelModule,
TuiLinkModule,
TuiScrollableDirective,
TuiScrollbarComponent,
TuiTextfieldControllerModule,
} from '@taiga-ui/core';
import {TuiInitialsModule} from '@taiga-ui/experimental';
import {
TuiAvatarComponent,
TuiDataListWrapperModule,
Expand Down Expand Up @@ -65,7 +65,7 @@ import {ExampleTuiMultiSelectComponent} from './multi-select.component';
RouterModule.forChild(tuiGenerateRoutes(ExampleTuiMultiSelectComponent)),
PolymorpheusModule,
TuiScrollableDirective,
TuiInitialsModule,
TuiInitialsPipe,
],
declarations: [
ExampleTuiMultiSelectComponent,
Expand Down
4 changes: 2 additions & 2 deletions projects/demo/src/modules/components/select/select.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
TuiDataListModule,
TuiDropdownModule,
TuiHintModule,
TuiInitialsPipe,
TuiLabelModule,
TuiLinkModule,
TuiLoaderModule,
Expand All @@ -21,7 +22,6 @@ import {
TuiSvgModule,
TuiTextfieldControllerModule,
} from '@taiga-ui/core';
import {TuiInitialsModule} from '@taiga-ui/experimental';
import {
TuiAvatarComponent,
TuiDataListWrapperModule,
Expand Down Expand Up @@ -83,7 +83,7 @@ import {ExampleTuiSelectComponent} from './select.component';
TuiAmountPipe,
TuiNumberFormatModule,
TuiScrollableDirective,
TuiInitialsModule,
TuiInitialsPipe,
],
declarations: [
ExampleTuiSelectComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import {TuiAddonDocModule, tuiGenerateRoutes} from '@taiga-ui/addon-doc';
import {TuiSheetDialogModule} from '@taiga-ui/addon-mobile';
import {TuiSwipeModule} from '@taiga-ui/cdk';
import {
TuiAutoColorPipe,
TuiButtonModule,
TuiInitialsPipe,
TuiLabelModule,
TuiNotificationModule,
TuiTextfieldControllerModule,
} from '@taiga-ui/core';
import {TuiAutoColorModule, TuiInitialsModule} from '@taiga-ui/experimental';
import {TuiAvatarComponent, TuiInputModule} from '@taiga-ui/kit';

import {TuiSheetDialogExample1} from './examples/1';
Expand All @@ -36,8 +37,8 @@ import {ExampleTuiSheetDialogComponent} from './sheet-dialog.component';
TuiAddonDocModule,
RouterModule.forChild(tuiGenerateRoutes(ExampleTuiSheetDialogComponent)),
TuiSwipeModule,
TuiAutoColorModule,
TuiInitialsModule,
TuiAutoColorPipe,
TuiInitialsPipe,
],
declarations: [
ExampleTuiSheetDialogComponent,
Expand Down
Loading

0 comments on commit eabaf64

Please sign in to comment.