Skip to content

Commit f4c9a83

Browse files
committed
refactor(*): replace mkenum with const assertion
1 parent bb28024 commit f4c9a83

File tree

24 files changed

+90
-108
lines changed

24 files changed

+90
-108
lines changed

projects/igniteui-angular/src/lib/avatar/avatar.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ import {
99
ViewChild
1010
} from '@angular/core';
1111

12-
import { mkenum, normalizeURI } from '../core/utils';
12+
import { normalizeURI } from '../core/utils';
1313
import { IgxIconComponent } from '../icon/icon.component';
1414

1515
let NEXT_ID = 0;
16-
export const IgxAvatarSize = /*@__PURE__*/mkenum({
16+
export const IgxAvatarSize = {
1717
SMALL: 'small',
1818
MEDIUM: 'medium',
1919
LARGE: 'large'
20-
});
20+
} as const;
2121
export type IgxAvatarSize = (typeof IgxAvatarSize)[keyof typeof IgxAvatarSize];
2222

23-
export const IgxAvatarType = /*@__PURE__*/mkenum({
23+
export const IgxAvatarType = {
2424
INITIALS: 'initials',
2525
IMAGE: 'image',
2626
ICON: 'icon',
2727
CUSTOM: 'custom'
28-
});
28+
} as const;
2929
export type IgxAvatarType = (typeof IgxAvatarType)[keyof typeof IgxAvatarType];
3030

3131
/**

projects/igniteui-angular/src/lib/badge/badge.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import { booleanAttribute, Component, HostBinding, Input } from '@angular/core';
2-
import { mkenum } from '../core/utils';
32
import { IgxIconComponent } from '../icon/icon.component';
43

54
let NEXT_ID = 0;
65

76
/**
87
* Determines the igxBadge type
98
*/
10-
export const IgxBadgeType = /*@__PURE__*/mkenum({
9+
export const IgxBadgeType = {
1110
PRIMARY: 'primary',
1211
INFO: 'info',
1312
SUCCESS: 'success',
1413
WARNING: 'warning',
1514
ERROR: 'error'
16-
});
15+
} as const;
1716
export type IgxBadgeType = (typeof IgxBadgeType)[keyof typeof IgxBadgeType];
1817
/**
1918
* Badge provides visual notifications used to decorate avatars, menus, etc.

projects/igniteui-angular/src/lib/buttonGroup/buttonGroup.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@ import { IgxRippleDirective } from '../directives/ripple/ripple.directive';
2020

2121
import { takeUntil } from 'rxjs/operators';
2222
import { IBaseEventArgs } from '../core/utils';
23-
import { mkenum } from '../core/utils';
2423
import { IgxIconComponent } from '../icon/icon.component';
2524

2625
/**
2726
* Determines the Button Group alignment
2827
*/
29-
export const ButtonGroupAlignment = mkenum({
28+
export const ButtonGroupAlignment = {
3029
horizontal: 'horizontal',
3130
vertical: 'vertical'
32-
});
31+
} as const;
3332
export type ButtonGroupAlignment = typeof ButtonGroupAlignment[keyof typeof ButtonGroupAlignment];
3433

3534
let NEXT_ID = 0;

projects/igniteui-angular/src/lib/calendar/calendar.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import { mkenum } from '../core/utils';
21

32
/**
43
* Sets the selection type - single, multi or range.
54
*/
6-
export const CalendarSelection = /*@__PURE__*/mkenum({
5+
export const CalendarSelection = {
76
SINGLE: 'single',
87
MULTI: 'multi',
98
RANGE: 'range'
10-
});
9+
} as const;
1110
export type CalendarSelection = (typeof CalendarSelection)[keyof typeof CalendarSelection];
1211

1312
export const enum ScrollDirection {
@@ -21,11 +20,11 @@ export interface IViewDateChangeEventArgs {
2120
currentValue: Date;
2221
}
2322

24-
export const IgxCalendarView = /*@__PURE__*/mkenum({
23+
export const IgxCalendarView = {
2524
Month: 'month',
2625
Year: 'year',
2726
Decade: 'decade'
28-
});
27+
} as const;
2928

3029
/**
3130
* Determines the Calendar active view - days, months or years.

projects/igniteui-angular/src/lib/card/card.component.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import {
1111
booleanAttribute
1212
} from '@angular/core';
1313

14-
import { mkenum } from '../core/utils';
15-
1614
let NEXT_ID = 0;
1715

1816
/**
@@ -269,10 +267,10 @@ export class IgxCardComponent {
269267
public horizontal = false;
270268
}
271269

272-
export const IgxCardActionsLayout = /*@__PURE__*/mkenum({
270+
export const IgxCardActionsLayout = {
273271
START: 'start',
274272
JUSTIFY: 'justify'
275-
});
273+
} as const;
276274
export type IgxCardActionsLayout = (typeof IgxCardActionsLayout)[keyof typeof IgxCardActionsLayout];
277275

278276
/**
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import { mkenum } from '../core/utils';
21

3-
export const CarouselAnimationType = /*@__PURE__*/mkenum({
2+
export const CarouselAnimationType = {
43
none: 'none',
54
slide: 'slide',
65
fade: 'fade'
7-
});
6+
} as const;
87
export type CarouselAnimationType = (typeof CarouselAnimationType)[keyof typeof CarouselAnimationType];
98

10-
export const CarouselIndicatorsOrientation = /*@__PURE__*/mkenum({
9+
export const CarouselIndicatorsOrientation = {
1110
/**
1211
* @deprecated in version 19.1.0. Use `end` instead.
1312
*/
@@ -18,5 +17,5 @@ export const CarouselIndicatorsOrientation = /*@__PURE__*/mkenum({
1817
top: 'top',
1918
start: 'start',
2019
end: 'end'
21-
});
20+
} as const;
2221
export type CarouselIndicatorsOrientation = (typeof CarouselIndicatorsOrientation)[keyof typeof CarouselIndicatorsOrientation];

projects/igniteui-angular/src/lib/checkbox/checkbox-base.directive.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
AfterViewInit,
1818
} from '@angular/core';
1919
import { NgControl, Validators } from '@angular/forms';
20-
import { IBaseEventArgs, getComponentTheme, mkenum } from '../core/utils';
20+
import { IBaseEventArgs, getComponentTheme } from '../core/utils';
2121
import { noop, Subject } from 'rxjs';
2222
import { takeUntil } from 'rxjs/operators';
2323
import {
@@ -26,10 +26,10 @@ import {
2626
ThemeToken,
2727
} from '../services/theme/theme.token';
2828

29-
export const LabelPosition = /*@__PURE__*/ mkenum({
29+
export const LabelPosition = {
3030
BEFORE: 'before',
3131
AFTER: 'after'
32-
});
32+
} as const;
3333
export type LabelPosition = typeof LabelPosition[keyof typeof LabelPosition];
3434

3535
export interface IChangeCheckboxEventArgs extends IBaseEventArgs {

projects/igniteui-angular/src/lib/chips/chip.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ import {
1717
DOCUMENT
1818
} from '@angular/core';
1919
import { IgxDragDirective, IDragBaseEventArgs, IDragStartEventArgs, IDropBaseEventArgs, IDropDroppedEventArgs, IgxDropDirective } from '../directives/drag-drop/drag-drop.directive';
20-
import { IBaseEventArgs, mkenum } from '../core/utils';
20+
import { IBaseEventArgs } from '../core/utils';
2121
import { ChipResourceStringsEN, IChipResourceStrings } from '../core/i18n/chip-resources';
2222
import { Subject } from 'rxjs';
2323
import { IgxIconComponent } from '../icon/icon.component';
2424
import { NgClass, NgTemplateOutlet } from '@angular/common';
2525
import { getCurrentResourceStrings } from '../core/i18n/resources';
2626
import { Size } from '../grids/common/enums';
2727

28-
export const IgxChipTypeVariant = /*@__PURE__*/mkenum({
28+
export const IgxChipTypeVariant = {
2929
PRIMARY: 'primary',
3030
INFO: 'info',
3131
SUCCESS: 'success',
3232
WARNING: 'warning',
3333
DANGER: 'danger'
34-
});
34+
} as const;
3535

3636
export interface IBaseChipEventArgs extends IBaseEventArgs {
3737
originalEvent: IDragBaseEventArgs | IDropBaseEventArgs | KeyboardEvent | MouseEvent | TouchEvent;

projects/igniteui-angular/src/lib/core/utils.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ export const showMessage = (message: string, isMessageShown: boolean): boolean =
2020
return true;
2121
};
2222

23-
export const mkenum = <T extends { [index: string]: U }, U extends string>(x: T) => x;
24-
2523
/**
2624
*
2725
* @hidden @internal
@@ -247,7 +245,7 @@ export class PlatformUtil {
247245
/** @hidden @internal */
248246
public isElements = inject(ELEMENTS_TOKEN, { optional: true });
249247

250-
public KEYMAP = mkenum({
248+
public KEYMAP = {
251249
ENTER: 'Enter',
252250
SPACE: ' ',
253251
ESCAPE: 'Escape',
@@ -269,7 +267,7 @@ export class PlatformUtil {
269267
X: 'x',
270268
Y: 'y',
271269
Z: 'z'
272-
});
270+
} as const;
273271

274272
constructor(@Inject(PLATFORM_ID) private platformId: any) { }
275273

projects/igniteui-angular/src/lib/data-operations/data-util.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { IPagingState, PagingError } from './paging-state.interface';
55
import { IGroupByKey } from './groupby-expand-state.interface';
66
import { IGroupByRecord } from './groupby-record.interface';
77
import { IGroupingState } from './groupby-state.interface';
8-
import { mergeObjects, mkenum } from '../core/utils';
8+
import { mergeObjects } from '../core/utils';
99
import { Transaction, TransactionType, HierarchicalTransaction } from '../services/transaction/transaction';
1010
import { getHierarchy, isHierarchyMatch } from './operations';
1111
import { GridType } from '../grids/common/grid.interface';
@@ -24,7 +24,7 @@ import { IGroupingExpression } from './grouping-expression.interface';
2424
/**
2525
* @hidden
2626
*/
27-
export const DataType = /*@__PURE__*/mkenum({
27+
export const DataType = {
2828
String: 'string',
2929
Number: 'number',
3030
Boolean: 'boolean',
@@ -34,7 +34,7 @@ import { IGroupingExpression } from './grouping-expression.interface';
3434
Currency: 'currency',
3535
Percent: 'percent',
3636
Image: 'image'
37-
});
37+
} as const;
3838
export type DataType = (typeof DataType)[keyof typeof DataType];
3939

4040
/**

0 commit comments

Comments
 (0)