diff --git a/projects/core/components/primitive-calendar/primitive-calendar.component.ts b/projects/core/components/primitive-calendar/primitive-calendar.component.ts index 30e3db1c18c1..b8d7b34b5c6a 100644 --- a/projects/core/components/primitive-calendar/primitive-calendar.component.ts +++ b/projects/core/components/primitive-calendar/primitive-calendar.component.ts @@ -116,11 +116,11 @@ export class TuiPrimitiveCalendarComponent { } if (value instanceof TuiDay) { - return value.daySame(item) ? TuiRangeState.Single : null; + return value.daySame(item) ? 'single' : null; } if (!(value instanceof TuiDayRange)) { - return value.find(day => day.daySame(item)) ? TuiRangeState.Single : null; + return value.find(day => day.daySame(item)) ? 'single' : null; } if ( @@ -132,7 +132,7 @@ export class TuiPrimitiveCalendarComponent { hoveredItem.dayBefore(value.from) && value.isSingleDay) ) { - return TuiRangeState.Start; + return 'start'; } if ( @@ -144,12 +144,10 @@ export class TuiPrimitiveCalendarComponent { hoveredItem.dayAfter(value.from) && value.isSingleDay) ) { - return TuiRangeState.End; + return 'end'; } - return value.isSingleDay && value.from.daySame(item) - ? TuiRangeState.Single - : null; + return value.isSingleDay && value.from.daySame(item) ? 'single' : null; } itemIsToday(item: TuiDay): boolean { diff --git a/projects/core/components/primitive-calendar/test/primitive-calendar.component.spec.ts b/projects/core/components/primitive-calendar/test/primitive-calendar.component.spec.ts index e4d339717bd5..9e2d18d72e3c 100644 --- a/projects/core/components/primitive-calendar/test/primitive-calendar.component.spec.ts +++ b/projects/core/components/primitive-calendar/test/primitive-calendar.component.spec.ts @@ -14,7 +14,6 @@ import { TuiInteractiveState, TuiPrimitiveCalendarComponent, TuiPrimitiveCalendarModule, - TuiRangeState, } from '@taiga-ui/core'; import {TUI_FIRST_DAY_OF_WEEK} from '@taiga-ui/core/tokens'; import {tuiMockCurrentDate, tuiRestoreRealDate} from '@taiga-ui/testing'; @@ -156,7 +155,7 @@ describe('PrimitiveCalendar', () => { component.value = range; - expect(component.getItemRange(day1)).toBe(TuiRangeState.Start); + expect(component.getItemRange(day1)).toBe('start'); }); it('returns end correctly if there is range in value', () => { @@ -166,7 +165,7 @@ describe('PrimitiveCalendar', () => { component.value = range; - expect(component.getItemRange(day2)).toBe(TuiRangeState.End); + expect(component.getItemRange(day2)).toBe('end'); }); it('returns single if value is single day and item equals this', () => { @@ -175,7 +174,7 @@ describe('PrimitiveCalendar', () => { component.value = range; - expect(component.getItemRange(day1)).toBe(TuiRangeState.Single); + expect(component.getItemRange(day1)).toBe('single'); }); }); diff --git a/projects/core/components/primitive-year-picker/primitive-year-picker.component.ts b/projects/core/components/primitive-year-picker/primitive-year-picker.component.ts index 9359d582b7af..49a10cdee534 100644 --- a/projects/core/components/primitive-year-picker/primitive-year-picker.component.ts +++ b/projects/core/components/primitive-year-picker/primitive-year-picker.component.ts @@ -127,11 +127,11 @@ export class TuiPrimitiveYearPickerComponent { } if (value instanceof TuiYear) { - return value.year === item ? TuiRangeState.Single : null; + return value.year === item ? 'single' : null; } if (!(value instanceof TuiMonthRange)) { - return value.find(day => day.year === item) ? TuiRangeState.Single : null; + return value.find(day => day.year === item) ? 'single' : null; } if ( @@ -145,7 +145,7 @@ export class TuiPrimitiveYearPickerComponent { hoveredItem < value.from.year && value.from.yearSame(value.to)) ) { - return TuiRangeState.Start; + return 'start'; } if ( @@ -159,11 +159,11 @@ export class TuiPrimitiveYearPickerComponent { hoveredItem > value.from.year && value.from.yearSame(value.to)) ) { - return TuiRangeState.End; + return 'end'; } return value.from.yearSame(value.to) && value.from.year === item - ? TuiRangeState.Single + ? 'single' : null; } diff --git a/projects/core/components/primitive-year-picker/test/primitive-year-picker.component.spec.ts b/projects/core/components/primitive-year-picker/test/primitive-year-picker.component.spec.ts index 47f015fe5433..462f83a5c67a 100644 --- a/projects/core/components/primitive-year-picker/test/primitive-year-picker.component.spec.ts +++ b/projects/core/components/primitive-year-picker/test/primitive-year-picker.component.spec.ts @@ -5,7 +5,6 @@ import { TuiInteractiveState, TuiPrimitiveYearPickerComponent, TuiPrimitiveYearPickerModule, - TuiRangeState, } from '@taiga-ui/core'; import {TuiPageObject} from '@taiga-ui/testing'; @@ -104,7 +103,7 @@ describe('TuiPrimitiveYearPickerComponent', () => { new TuiDay(2020, 1, 1), ); - expect(component.getItemRange(item)).toBe(TuiRangeState.Start); + expect(component.getItemRange(item)).toBe('start'); }); it('returns end correctly', () => { @@ -115,7 +114,7 @@ describe('TuiPrimitiveYearPickerComponent', () => { new TuiDay(item, 1, 1), ); - expect(component.getItemRange(item)).toBe(TuiRangeState.End); + expect(component.getItemRange(item)).toBe('end'); }); it('returns single correctly', () => { @@ -126,7 +125,7 @@ describe('TuiPrimitiveYearPickerComponent', () => { new TuiDay(item, 2, 2), ); - expect(component.getItemRange(item)).toBe(TuiRangeState.Single); + expect(component.getItemRange(item)).toBe('single'); }); }); diff --git a/projects/core/enums/range-state.ts b/projects/core/enums/range-state.ts index 78fe6df7f065..2d196f02d376 100644 --- a/projects/core/enums/range-state.ts +++ b/projects/core/enums/range-state.ts @@ -1,10 +1,4 @@ /** * @internal used in calendar and year picker */ -// TODO: change type in v4.0 -// eslint-disable-next-line no-restricted-syntax -export enum TuiRangeState { - End = 'end', - Single = 'single', - Start = 'start', -} +export type TuiRangeState = 'end' | 'single' | 'start'; diff --git a/projects/kit/components/calendar-month/calendar-month.component.ts b/projects/kit/components/calendar-month/calendar-month.component.ts index abf760d4a757..ff3d8fc016f1 100644 --- a/projects/kit/components/calendar-month/calendar-month.component.ts +++ b/projects/kit/components/calendar-month/calendar-month.component.ts @@ -118,7 +118,7 @@ export class TuiCalendarMonthComponent implements TuiWithOptionalMinMax { component.value = month; - expect(component.getItemRange(month)).toBe(TuiRangeState.Single); + expect(component.getItemRange(month)).toBe('single'); }); it('returns start if item is start of range', () => { @@ -173,7 +173,7 @@ describe('CalendarMonth', () => { component.value = new TuiMonthRange(month, month.append({month: 2})); - expect(component.getItemRange(month)).toBe(TuiRangeState.Start); + expect(component.getItemRange(month)).toBe('start'); }); it('returns end if item is start of range', () => { @@ -181,7 +181,7 @@ describe('CalendarMonth', () => { component.value = new TuiMonthRange(month.append({month: -2}), month); - expect(component.getItemRange(month)).toBe(TuiRangeState.End); + expect(component.getItemRange(month)).toBe('end'); }); it('returns end if hovered item before item', () => { @@ -190,7 +190,7 @@ describe('CalendarMonth', () => { component.value = new TuiMonthRange(month, month); component.hoveredItem = new TuiMonth(TODAY.year, 4); - expect(component.getItemRange(month)).toBe(TuiRangeState.End); + expect(component.getItemRange(month)).toBe('end'); }); });