Skip to content

Commit

Permalink
refactor!: remove deprecations (#2327)
Browse files Browse the repository at this point in the history
* refactor!: remove deprecations

* fix: use `TUI_TAG_OPTIONS` for status

* Revert "fix: use `TUI_TAG_OPTIONS` for status"

This reverts commit d7c0950.
  • Loading branch information
nsbarsukov authored and splincode committed Aug 30, 2022
1 parent d7ac492 commit 1d5a1e4
Show file tree
Hide file tree
Showing 19 changed files with 31 additions and 157 deletions.
8 changes: 2 additions & 6 deletions projects/core/components/button/button-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ import {TuiSizeXL, TuiSizeXS} from '@taiga-ui/core/types';

export interface TuiButtonOptions {
readonly size: TuiSizeXS | TuiSizeXL;
readonly appearance:
| keyof Record<TuiAppearance, string>
| TuiAppearance
| string
| null; // TODO: 3.0 need remove `null`
readonly shape: 'square' | 'rounded' | null; // TODO: 3.0 need remove `null`
readonly appearance: keyof Record<TuiAppearance, string> | TuiAppearance | string;
readonly shape: 'square' | 'rounded' | null;
}

export const TUI_BUTTON_DEFAULT_OPTIONS: TuiButtonOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export class TuiOptionComponent<T = unknown> implements OnDestroy {
@Input()
value?: T;

// TODO: 3.0 Fix dataList type when updated to Ivy and compilation drops metadata
constructor(
@Optional()
@Inject(TUI_OPTION_CONTENT)
Expand Down
3 changes: 1 addition & 2 deletions projects/core/components/expand/expand.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
>
<ng-container *ngIf="contentVisible">
<ng-content></ng-content>
<!-- TODO: 3.0 collision with async pipe, fix after upgrade to ng11 -->
<tui-loader
*ngIf="this.async; else content"
*ngIf="async; else content"
size="l"
[overlay]="true"
[showLoader]="loading"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {DOCUMENT, isPlatformServer} from '@angular/common';
import {isPlatformServer} from '@angular/common';
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Expand All @@ -10,7 +10,6 @@ import {
import {SafeHtml} from '@angular/platform-browser';
import {TuiDestroyService} from '@taiga-ui/cdk';
import {TuiSvgService} from '@taiga-ui/core/services';
import {innerHTML} from '@taiga-ui/core/utils/polyfills';
import {takeUntil} from 'rxjs/operators';

@Component({
Expand All @@ -25,15 +24,13 @@ export class TuiSvgDefsHostComponent implements OnInit {
isBrowser = true;

constructor(
@Inject(DOCUMENT) documentRef: Document,
@Inject(TuiSvgService) private readonly svgService: TuiSvgService,
@Inject(ChangeDetectorRef) private readonly changeDetectorRef: ChangeDetectorRef,
@Inject(TuiDestroyService)
private readonly destroy$: TuiDestroyService,
@Inject(PLATFORM_ID) platformId: Record<string, unknown>,
) {
this.isBrowser = !isPlatformServer(platformId);
innerHTML(documentRef);
}

// @bad TODO: Looks like it could be async piped but it was probably written like that for a reason
Expand Down
1 change: 0 additions & 1 deletion projects/core/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ export * from '@taiga-ui/core/utils/format';
export * from '@taiga-ui/core/utils/mask';
export * from '@taiga-ui/core/utils/miscellaneous';
export * from '@taiga-ui/core/utils/mobile';
export * from '@taiga-ui/core/utils/polyfills';
1 change: 0 additions & 1 deletion projects/core/utils/polyfills/index.ts

This file was deleted.

49 changes: 0 additions & 49 deletions projects/core/utils/polyfills/inner-html.ts

This file was deleted.

7 changes: 0 additions & 7 deletions projects/core/utils/polyfills/package.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ export class ExampleTuiInputTagComponent extends AbstractExampleTuiControl {

expandable = true;

allowSpaces = true;

uniqueTags = true;

readonly separatorVariants = [`,`, `;`, /[\d]/, /[\s,]/];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@
[uniqueTags]="uniqueTags"
[separator]="separator"
[readOnly]="readOnly"
[allowSpaces]="allowSpaces"
[tagValidator]="tagValidator"
[inputHidden]="inputHidden"
[pseudoHover]="pseudoHovered"
Expand Down Expand Up @@ -144,36 +143,6 @@
<code>null</code>
when item from list selected)
</ng-template>
<ng-template
documentationPropertyName="allowSpaces"
documentationPropertyType="boolean"
documentationPropertyMode="input"
[documentationPropertyDeprecated]="true"
[(documentationPropertyValue)]="allowSpaces"
>
Allow spaces inside tag.

<p>In next major release spaces are always allowed by default.</p>

<p>
<strong>
Use property
<code>[separator]</code>
to forbid spaces.
</strong>
</p>
<p>
See this
<a
tuiLink
routerLink="/components/input-tag"
fragment="no-spaces-inside-tags"
>
example
</a>
.
</p>
</ng-template>
<ng-template
i18n
documentationPropertyName="disabledItemHandler"
Expand Down
14 changes: 13 additions & 1 deletion projects/kit/components/input-tag/input-tag-options.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import {InjectionToken} from '@angular/core';
import {InjectionToken, ValueProvider} from '@angular/core';
import {TuiStatus} from '@taiga-ui/kit/types';

export interface TuiInputTagOptions {
readonly separator: string | RegExp;
readonly uniqueTags: boolean;
readonly tagStatus: TuiStatus;
}

export const TUI_INPUT_TAG_DEFAULT_OPTIONS: TuiInputTagOptions = {
separator: `,`,
uniqueTags: true,
tagStatus: `primary`,
};

export const TUI_INPUT_TAG_OPTIONS = new InjectionToken<TuiInputTagOptions>(
Expand All @@ -16,3 +19,12 @@ export const TUI_INPUT_TAG_OPTIONS = new InjectionToken<TuiInputTagOptions>(
factory: () => TUI_INPUT_TAG_DEFAULT_OPTIONS,
},
);

export function tuiInputTagOptionsProvider(
options: Partial<TuiInputTagOptions>,
): ValueProvider {
return {
provide: TUI_INPUT_TAG_OPTIONS,
useValue: {...TUI_INPUT_TAG_DEFAULT_OPTIONS, ...options},
};
}
14 changes: 2 additions & 12 deletions projects/kit/components/input-tag/input-tag.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ import {
TuiTextfieldController,
} from '@taiga-ui/core';
import {TuiStringifiableItem} from '@taiga-ui/kit/classes';
import {ALLOWED_SPACE_REGEXP} from '@taiga-ui/kit/components/tag';
import {FIXED_DROPDOWN_CONTROLLER_PROVIDER} from '@taiga-ui/kit/providers';
import {TUI_TAG_STATUS} from '@taiga-ui/kit/tokens';
import {TuiStatus} from '@taiga-ui/kit/types';
import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus';
import {merge, Observable, Subject} from 'rxjs';
Expand Down Expand Up @@ -113,11 +111,6 @@ export class TuiInputTagComponent
private readonly scrollToStart$ = new Subject<void>();
private readonly scrollToEnd$ = new Subject<void>();

// TODO: 3.0 Remove
@Input()
@tuiDefaultProp()
allowSpaces = true;

@Input()
@tuiDefaultProp()
separator: string | RegExp = this.options.separator;
Expand Down Expand Up @@ -193,7 +186,6 @@ export class TuiInputTagComponent
private readonly modeDirective: TuiModeDirective | null,
@Inject(TUI_MODE)
private readonly mode$: Observable<TuiBrightness | null>,
@Inject(TUI_TAG_STATUS) private readonly tagStatus: TuiStatus,
@Inject(TUI_HINT_WATCHED_CONTROLLER)
readonly hintController: TuiHintControllerDirective,
@Inject(TUI_TEXTFIELD_WATCHED_CONTROLLER)
Expand Down Expand Up @@ -284,7 +276,7 @@ export class TuiInputTagComponent
}

get status(): TuiStatus {
return this.modeDirective?.mode ? `default` : this.tagStatus;
return this.modeDirective?.mode ? `default` : this.options.tagStatus;
}

get canOpen(): boolean {
Expand Down Expand Up @@ -398,9 +390,7 @@ export class TuiInputTagComponent
}

onInput(value: string): void {
const array = this.allowSpaces
? value.split(this.separator)
: value.split(ALLOWED_SPACE_REGEXP);
const array = value.split(this.separator);
const tags = array
.map(item => item.trim())
.filter((item, index, {length}) => item.length > 0 && index !== length - 1);
Expand Down
1 change: 0 additions & 1 deletion projects/kit/components/input-tag/input-tag.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
class="t-tag"
[status]="(status$ | async)!"
[leftContent]="getLeftContent(item)"
[allowSpaces]="allowSpaces"
[tuiFocusable]="false"
[disabled]="computedDisabled || disabledItemHandler(item)"
[editable]="editable && !readOnly"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
TuiSizeS,
TuiTextfieldControllerModule,
} from '@taiga-ui/core';
import {TUI_TAG_STATUS, TuiInputTagComponent, TuiInputTagModule} from '@taiga-ui/kit';
import {
TuiInputTagComponent,
TuiInputTagModule,
tuiInputTagOptionsProvider,
} from '@taiga-ui/kit';

describe(`InputTag [TUI_TAG_STATUS=neutral]`, () => {
@Component({
Expand All @@ -21,7 +25,7 @@ describe(`InputTag [TUI_TAG_STATUS=neutral]`, () => {
></tui-input-tag>
</tui-root>
`,
providers: [{provide: TUI_TAG_STATUS, useValue: `neutral`}],
providers: [tuiInputTagOptionsProvider({tagStatus: `neutral`})],
})
class TestComponent {
@ViewChild(TuiInputTagComponent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ describe(`InputTag`, () => {
[formControl]="control"
[readOnly]="readOnly"
[separator]="separator"
[allowSpaces]="allowSpaces"
[tagValidator]="tagValidator"
[tuiTextfieldCleaner]="cleaner"
[tuiTextfieldExampleText]="exampleText"
Expand All @@ -63,8 +62,7 @@ describe(`InputTag`, () => {
defaultInputs = false;
cleaner = true;
readOnly = false;
allowSpaces = true;
separator = `,`;
separator: string | RegExp = `,`;
labelOutside = true;
exampleText = `Example`;
size: TuiSizeS | TuiSizeL = `m`;
Expand Down Expand Up @@ -219,7 +217,7 @@ describe(`InputTag`, () => {
});
});

describe(`Adding tags with spaces when the allowSpaces option is enabled`, () => {
describe(`Adding tags with spaces (spaces inside tags are allowed)`, () => {
it(`Spaces are preserved and not tagged`, () => {
inputPO.focus();
fixture.detectChanges();
Expand All @@ -231,9 +229,9 @@ describe(`InputTag`, () => {
});
});

describe(`Adding tags when the allowSpaces option is disabled`, () => {
describe(`Adding tags when spaces inside tags are forbidden`, () => {
beforeEach(() => {
testComponent.allowSpaces = false;
testComponent.separator = /[\s,]/;
inputPO.focus();
fixture.detectChanges();
});
Expand Down
11 changes: 1 addition & 10 deletions projects/kit/components/tag/tag.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import {Observable} from 'rxjs';

import {TUI_TAG_OPTIONS, TuiTagOptions} from './tag-options';

export const ALLOWED_SPACE_REGEXP = new RegExp(`,|[\\s]`);

@Component({
selector: `tui-tag, a[tuiTag]`,
templateUrl: `./tag.template.html`,
Expand All @@ -49,11 +47,6 @@ export class TuiTagComponent {
@tuiDefaultProp()
editable = false;

// TODO: 3.0: Remove
@Input()
@tuiDefaultProp()
allowSpaces = true;

@Input()
@tuiDefaultProp()
separator: string | RegExp = `,`;
Expand Down Expand Up @@ -165,9 +158,7 @@ export class TuiTagComponent {
}

onInput(value: string): void {
const newTags = this.allowSpaces
? value.split(this.separator)
: value.split(ALLOWED_SPACE_REGEXP);
const newTags = value.split(this.separator);

if (newTags.length > 1) {
this.save(String(newTags));
Expand Down
1 change: 0 additions & 1 deletion projects/kit/tokens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ export * from './items-handlers';
export * from './mobile-calendar';
export * from './month-formatter';
export * from './tab-margin';
export * from './tag-status';
export * from './validation-errors';
10 changes: 0 additions & 10 deletions projects/kit/tokens/tag-status.ts

This file was deleted.

11 changes: 1 addition & 10 deletions stylelint.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
module.exports = {
extends: ['@tinkoff/stylelint-config/less', '@tinkoff/stylelint-config/angular'],
ignoreFiles: [
'**/demo/**',
'**/dist/**',
'**/coverage/**',
'**/node_modules/**',

// TODO: remove in v3.0
'**/slider-old.style.less',
'**/slider.common.style.less',
],
ignoreFiles: ['**/demo/**', '**/dist/**', '**/coverage/**', '**/node_modules/**'],
rules: {
'unit-allowed-list': [
'px',
Expand Down

0 comments on commit 1d5a1e4

Please sign in to comment.