Skip to content

Commit 2cf3203

Browse files
Merge branch '18.2.x' into aahmedov/fix-column-resize-line-positioning-for-scaled-grid-18.2.x
2 parents 774346d + c974006 commit 2cf3203

File tree

84 files changed

+1127
-544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1127
-544
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,28 @@ describe('Avatar', () => {
170170

171171
expect(instance.src).toEqual("/assets/Test%20-%2017.jpg");
172172
});
173+
174+
it('should not throw error if src is null', () => {
175+
const fixture = TestBed.createComponent(InitImageAvatarComponent);
176+
fixture.detectChanges();
177+
expect(() => {
178+
const instance = fixture.componentInstance.avatar;
179+
instance.src = null;
180+
fixture.detectChanges();
181+
}).not.toThrow();
182+
});
183+
184+
it('avatar with [src] and fallback [initials] should not throw error if src is null', () => {
185+
const fixture = TestBed.createComponent(AvatarWithAttribsComponent);
186+
fixture.detectChanges();
187+
const instance = fixture.componentInstance.avatar;
188+
expect(instance.type).toEqual(IgxAvatarType.INITIALS);
189+
expect(instance.initials).toEqual('ZK');
190+
expect(() => {
191+
instance.src = null;
192+
fixture.detectChanges();
193+
}).not.toThrow();
194+
});
173195
});
174196

175197
@Component({

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ export class IgxAvatarComponent implements OnInit {
342342
* @internal
343343
*/
344344
public getSrcUrl() {
345-
return `url(${this.src})`;
345+
return `url("${this.src}")`;
346346
}
347347

348348
/** @hidden @internal */

projects/igniteui-angular/src/lib/calendar/common/calendar-view.directive.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
import { CalendarDay, DayInterval } from "../common/model";
2222
import { getNextActiveDate, isDateInRanges } from "./helpers";
2323
import { DateRangeType } from "../../core/dates";
24+
import { isDate } from "../../core/utils";
2425

2526
export enum Direction {
2627
NEXT = 1,
@@ -141,7 +142,7 @@ export abstract class IgxCalendarViewDirective implements ControlValueAccessor {
141142
*/
142143
@Input()
143144
public set date(value: Date) {
144-
if (!(value instanceof Date)) return;
145+
if (!isDate(value)) return;
145146

146147
this._date = value;
147148
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { isDate } from "../../core/utils";
2+
13
/* eslint-disable @typescript-eslint/consistent-type-definitions */
24
export type DayParameter = CalendarDay | Date;
35

@@ -19,7 +21,7 @@ export const daysInWeek = 7;
1921
const millisecondsInDay = 86400000;
2022

2123
export function toCalendarDay(date: DayParameter) {
22-
return date instanceof Date ? CalendarDay.from(date) : date;
24+
return isDate(date) ? CalendarDay.from(date) : date;
2325
}
2426

2527
function checkRollover(original: CalendarDay, modified: CalendarDay) {

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ describe('Card', () => {
6868
InitCardComponent,
6969
InitOutlinedCardComponent,
7070
CardWithHeaderComponent,
71+
CardContentIconComponent,
7172
VerticalCardComponent,
7273
HorizontalCardComponent
7374
]
@@ -182,6 +183,16 @@ describe('Card', () => {
182183
expect(actions).not.toHaveClass(classes.actions.vertical);
183184
});
184185

186+
it('Should use Material Icons font-family for igx-icon in card content', () => {
187+
const fixture = TestBed.createComponent(CardContentIconComponent);
188+
fixture.detectChanges();
189+
190+
const iconElement = fixture.debugElement.query(By.css('igx-icon')).nativeElement;
191+
const computedStyle = window.getComputedStyle(iconElement);
192+
193+
expect(computedStyle.fontFamily).toBe('"Material Icons"');
194+
});
195+
185196
it('Should automatically align actions vertically when in horizontal layout', () => {
186197
const fixture = TestBed.createComponent(HorizontalCardComponent);
187198
fixture.detectChanges();
@@ -249,6 +260,17 @@ class InitOutlinedCardComponent {
249260
})
250261
class CardWithHeaderComponent { }
251262

263+
@Component({
264+
template: `<igx-card class="ig-typography">
265+
<igx-card-content>
266+
<igx-icon>face</igx-icon>
267+
</igx-card-content>
268+
<igx-card>`,
269+
standalone: true,
270+
imports: [IgxCardComponent, IgxCardContentDirective, IgxIconComponent]
271+
})
272+
class CardContentIconComponent { }
273+
252274
@Component({
253275
template: `<igx-card>
254276
<igx-card-media width="200px" height="50%">

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NgIf, NgClass, NgFor, NgTemplateOutlet } from '@angular/common';
1+
import { NgIf, NgClass, NgFor, NgTemplateOutlet, DOCUMENT } from '@angular/common';
22
import {
33
AfterContentInit,
44
ChangeDetectorRef,
@@ -584,7 +584,8 @@ export class IgxCarouselComponent extends IgxCarouselComponentBase implements On
584584
private iterableDiffers: IterableDiffers,
585585
@Inject(IgxAngularAnimationService) animationService: AnimationService,
586586
private platformUtil: PlatformUtil,
587-
private dir: IgxDirectionality
587+
private dir: IgxDirectionality,
588+
@Inject(DOCUMENT) private document: any
588589
) {
589590
super(animationService, cdr);
590591
this.differ = this.iterableDiffers.find([]).create(null);
@@ -1003,7 +1004,7 @@ export class IgxCarouselComponent extends IgxCarouselComponentBase implements On
10031004
}
10041005

10051006
private focusElement() {
1006-
const focusedElement = document.activeElement;
1007+
const focusedElement = this.document.activeElement;
10071008

10081009
if (focusedElement.classList.contains('igx-carousel-indicators__indicator')) {
10091010
this.indicatorsElements[this.current].nativeElement.focus();

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

Lines changed: 92 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ import {
1212
Renderer2,
1313
Optional,
1414
Self,
15-
booleanAttribute
15+
booleanAttribute,
16+
inject,
17+
DestroyRef,
18+
Inject
1619
} from '@angular/core';
1720
import { ControlValueAccessor, NgControl, Validators } from '@angular/forms';
1821
import { IgxRippleDirective } from '../directives/ripple/ripple.directive';
19-
import { IBaseEventArgs, mkenum } from '../core/utils';
22+
import { IBaseEventArgs, getComponentTheme, mkenum } from '../core/utils';
2023
import { EditorProvider, EDITOR_PROVIDER } from '../core/edit-provider';
2124
import { noop, Subject } from 'rxjs';
2225
import { takeUntil } from 'rxjs/operators';
23-
import { IgxTheme, ThemeService } from '../services/theme/theme.service';
26+
import { IgxTheme, THEME_TOKEN, ThemeToken } from '../services/theme/theme.token';
2427

2528
export const LabelPosition = /*@__PURE__*/mkenum({
2629
BEFORE: 'before',
@@ -287,6 +290,58 @@ export class IgxCheckboxComponent implements EditorProvider, AfterViewInit, Cont
287290
@HostBinding('class.igx-checkbox')
288291
public cssClass = 'igx-checkbox';
289292

293+
/**
294+
* Returns if the component is of type `material`.
295+
*
296+
* @example
297+
* ```typescript
298+
* let checkbox = this.checkbox.material;
299+
* ```
300+
*/
301+
@HostBinding('class.igx-checkbox--material')
302+
protected get material() {
303+
return this.theme === 'material';
304+
}
305+
306+
/**
307+
* Returns if the component is of type `indigo`.
308+
*
309+
* @example
310+
* ```typescript
311+
* let checkbox = this.checkbox.indigo;
312+
* ```
313+
*/
314+
@HostBinding('class.igx-checkbox--indigo')
315+
protected get indigo() {
316+
return this.theme === 'indigo';
317+
}
318+
319+
/**
320+
* Returns if the component is of type `bootstrap`.
321+
*
322+
* @example
323+
* ```typescript
324+
* let checkbox = this.checkbox.bootstrap;
325+
* ```
326+
*/
327+
@HostBinding('class.igx-checkbox--bootstrap')
328+
protected get bootstrap() {
329+
return this.theme === 'bootstrap';
330+
}
331+
332+
/**
333+
* Returns if the component is of type `fluent`.
334+
*
335+
* @example
336+
* ```typescript
337+
* let checkbox = this.checkbox.fluent;
338+
* ```
339+
*/
340+
@HostBinding('class.igx-checkbox--fluent')
341+
protected get fluent() {
342+
return this.theme === 'fluent';
343+
}
344+
290345
/**
291346
* Sets/gets whether the checkbox component is on focus.
292347
* Default value is `false`.
@@ -410,42 +465,69 @@ export class IgxCheckboxComponent implements EditorProvider, AfterViewInit, Cont
410465
* @internal
411466
*/
412467
public inputId = `${this.id}-input`;
468+
413469
/**
414470
* @hidden
415471
*/
416472
protected _onChangeCallback: (_: any) => void = noop;
473+
417474
/**
418475
* @hidden
419476
*/
420477
private _onTouchedCallback: () => void = noop;
478+
421479
/**
422480
* @hidden
423481
* @internal
424482
*/
425483
protected _checked = false;
484+
426485
/**
427486
* @hidden
428487
* @internal
429488
*/
430-
private _required = false;
489+
protected theme: IgxTheme;
431490

432491
/**
433492
* @hidden
434493
* @internal
435494
*/
436-
protected theme: IgxTheme = 'material';
495+
private _required = false;
496+
private elRef = inject(ElementRef);
497+
private destroyRef = inject(DestroyRef);
437498

438499
constructor(
439500
protected cdr: ChangeDetectorRef,
440501
protected renderer: Renderer2,
441-
protected themeService: ThemeService,
502+
@Inject(THEME_TOKEN)
503+
protected themeToken: ThemeToken,
442504
@Optional() @Self() public ngControl: NgControl,
443505
) {
444-
this.theme = this.themeService?.globalTheme;
445-
446506
if (this.ngControl !== null) {
447507
this.ngControl.valueAccessor = this;
448508
}
509+
510+
this.theme = this.themeToken.theme;
511+
512+
const { unsubscribe } = this.themeToken.onChange((theme) => {
513+
if (this.theme !== theme) {
514+
this.theme = theme;
515+
this.cdr.detectChanges();
516+
}
517+
});
518+
519+
this.destroyRef.onDestroy(() => unsubscribe);
520+
}
521+
522+
private setComponentTheme() {
523+
if(!this.themeToken.preferToken) {
524+
const theme = getComponentTheme(this.elRef.nativeElement);
525+
526+
if (theme && theme !== this.theme) {
527+
this.theme = theme;
528+
this.cdr.markForCheck();
529+
}
530+
}
449531
}
450532

451533
/**
@@ -461,6 +543,8 @@ export class IgxCheckboxComponent implements EditorProvider, AfterViewInit, Cont
461543
this.cdr.detectChanges();
462544
}
463545
}
546+
547+
this.setComponentTheme();
464548
}
465549

466550
/** @hidden @internal */

projects/igniteui-angular/src/lib/combo/combo.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
[labelledBy]="ariaLabelledBy || label?.id || placeholder || ''"
3636
[width]="itemsWidth || '100%'" (opening)="handleOpening($event)" (closing)="handleClosing($event)"
3737
(opened)="handleOpened()" (closed)="handleClosed()">
38-
<div class="igx-combo__search">
39-
<igx-input-group *ngIf="displaySearchInput">
38+
<div class="igx-combo__search" *ngIf="displaySearchInput">
39+
<igx-input-group>
4040
<input igxInput #searchInput name="searchInput" autocomplete="off" type="text"
4141
[(ngModel)]="searchValue" (ngModelChange)="handleInputChange($event)" (keyup)="handleKeyUp($event)"
4242
(keydown)="handleKeyDown($event)" (focus)="dropdown.onBlur($event)" [attr.placeholder]="getSearchPlaceholderText()"

0 commit comments

Comments
 (0)