Skip to content

Commit d5ca5a6

Browse files
authored
Merge branch '18.2.x' into mkirova/partial-fix-13993-18.2.x
2 parents b7eded0 + 10e960b commit d5ca5a6

File tree

70 files changed

+572
-242
lines changed

Some content is hidden

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

70 files changed

+572
-242
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,17 @@ describe('Avatar', () => {
159159
expect(hostEl.getAttribute('aria-roledescription')).toEqual('image avatar');
160160
expect(hostEl.getAttribute('aria-label')).toEqual('avatar');
161161
});
162+
163+
it('Normalizes the value of the `src` input', () => {
164+
const fixture = TestBed.createComponent(InitImageAvatarComponent);
165+
fixture.detectChanges();
166+
167+
const instance = fixture.componentInstance.avatar;
168+
instance.src = "/assets/Test - 17.jpg";
169+
fixture.detectChanges();
170+
171+
expect(instance.src).toEqual("/assets/Test%20-%2017.jpg");
172+
});
162173
});
163174

164175
@Component({

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

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

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

1515
let NEXT_ID = 0;
@@ -202,7 +202,13 @@ export class IgxAvatarComponent implements OnInit {
202202
* @igxFriendlyName Image URL
203203
*/
204204
@Input()
205-
public src: string;
205+
public set src(value: string) {
206+
this._src = normalizeURI(value);
207+
}
208+
209+
public get src() {
210+
return this._src;
211+
}
206212

207213
/** @hidden @internal */
208214
@ViewChild('defaultTemplate', { read: TemplateRef, static: true })
@@ -225,6 +231,7 @@ export class IgxAvatarComponent implements OnInit {
225231
* @internal
226232
*/
227233
private _size: string | IgxAvatarSize;
234+
private _src: string;
228235

229236
/**
230237
* Returns the size of the avatar.

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/checkbox/checkbox.component.ts

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ import {
1212
Renderer2,
1313
Optional,
1414
Self,
15-
booleanAttribute
15+
booleanAttribute,
16+
inject,
17+
DestroyRef
1618
} from '@angular/core';
1719
import { ControlValueAccessor, NgControl, Validators } from '@angular/forms';
1820
import { IgxRippleDirective } from '../directives/ripple/ripple.directive';
1921
import { IBaseEventArgs, mkenum } from '../core/utils';
2022
import { EditorProvider, EDITOR_PROVIDER } from '../core/edit-provider';
21-
import { noop, Subject } from 'rxjs';
23+
import { noop, Subject, Subscription } from 'rxjs';
2224
import { takeUntil } from 'rxjs/operators';
2325
import { IgxTheme, ThemeService } from '../services/theme/theme.service';
2426

@@ -287,6 +289,58 @@ export class IgxCheckboxComponent implements EditorProvider, AfterViewInit, Cont
287289
@HostBinding('class.igx-checkbox')
288290
public cssClass = 'igx-checkbox';
289291

292+
/**
293+
* Returns if the component is of type `material`.
294+
*
295+
* @example
296+
* ```typescript
297+
* let checkbox = this.checkbox.material;
298+
* ```
299+
*/
300+
@HostBinding('class.igx-checkbox--material')
301+
protected get material() {
302+
return this.theme === 'material';
303+
}
304+
305+
/**
306+
* Returns if the component is of type `indigo`.
307+
*
308+
* @example
309+
* ```typescript
310+
* let checkbox = this.checkbox.indigo;
311+
* ```
312+
*/
313+
@HostBinding('class.igx-checkbox--indigo')
314+
protected get indigo() {
315+
return this.theme === 'indigo';
316+
}
317+
318+
/**
319+
* Returns if the component is of type `bootstrap`.
320+
*
321+
* @example
322+
* ```typescript
323+
* let checkbox = this.checkbox.bootstrap;
324+
* ```
325+
*/
326+
@HostBinding('class.igx-checkbox--bootstrap')
327+
protected get bootstrap() {
328+
return this.theme === 'bootstrap';
329+
}
330+
331+
/**
332+
* Returns if the component is of type `fluent`.
333+
*
334+
* @example
335+
* ```typescript
336+
* let checkbox = this.checkbox.fluent;
337+
* ```
338+
*/
339+
@HostBinding('class.igx-checkbox--fluent')
340+
protected get fluent() {
341+
return this.theme === 'fluent';
342+
}
343+
290344
/**
291345
* Sets/gets whether the checkbox component is on focus.
292346
* Default value is `false`.
@@ -410,42 +464,57 @@ export class IgxCheckboxComponent implements EditorProvider, AfterViewInit, Cont
410464
* @internal
411465
*/
412466
public inputId = `${this.id}-input`;
467+
413468
/**
414469
* @hidden
415470
*/
416471
protected _onChangeCallback: (_: any) => void = noop;
472+
417473
/**
418474
* @hidden
419475
*/
420476
private _onTouchedCallback: () => void = noop;
477+
421478
/**
422479
* @hidden
423480
* @internal
424481
*/
425482
protected _checked = false;
483+
426484
/**
427485
* @hidden
428486
* @internal
429487
*/
430-
private _required = false;
488+
protected theme: IgxTheme;
431489

432490
/**
433491
* @hidden
434492
* @internal
435493
*/
436-
protected theme: IgxTheme = 'material';
494+
private _required = false;
495+
private elRef = inject(ElementRef);
496+
private _theme$ = new Subject<IgxTheme>();
497+
private _subscription: Subscription;
498+
private destroyRef = inject(DestroyRef);
437499

438500
constructor(
439501
protected cdr: ChangeDetectorRef,
440502
protected renderer: Renderer2,
441503
protected themeService: ThemeService,
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.themeService.globalTheme;
511+
512+
this._subscription = this._theme$.asObservable().subscribe(value => {
513+
this.theme = value as IgxTheme;
514+
this.cdr.detectChanges();
515+
});
516+
517+
this.destroyRef.onDestroy(() => this._subscription.unsubscribe());
449518
}
450519

451520
/**
@@ -461,6 +530,13 @@ export class IgxCheckboxComponent implements EditorProvider, AfterViewInit, Cont
461530
this.cdr.detectChanges();
462531
}
463532
}
533+
534+
const theme = this.themeService.getComponentTheme(this.elRef);
535+
536+
if (theme) {
537+
this._theme$.next(theme);
538+
this.cdr.markForCheck();
539+
}
464540
}
465541

466542
/** @hidden @internal */

projects/igniteui-angular/src/lib/core/styles/components/action-strip/_action-strip-component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
@include register-component(
1111
$name: string.slice($this, 2, -1),
1212
$deps: (
13-
igx-button,
13+
igx-icon-button,
1414
igx-drop-down,
1515
igx-icon,
1616
)

projects/igniteui-angular/src/lib/core/styles/components/action-strip/_action-strip-theme.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
icon-color: $icon-color,
5959
delete-action: $delete-action,
6060
actions-border-radius: $actions-border-radius,
61+
theme: map.get($schema, '_meta', 'theme'),
6162
_meta: map.merge(if($meta, $meta, ()), (
6263
variant: map.get($schema, '_meta', 'theme')
6364
)),

projects/igniteui-angular/src/lib/core/styles/components/avatar/_avatar-theme.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
icon-color: $icon-color,
5555
border-radius: $border-radius,
5656
size: $size,
57+
theme: map.get($schema, '_meta', 'theme'),
5758
_meta: map.merge(if($meta, $meta, ()), (
5859
variant: map.get($schema, '_meta', 'theme')
5960
)),

projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-theme.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
border-radius: $border-radius,
7474
background-color: $background-color,
7575
shadow: $shadow,
76+
theme: map.get($schema, '_meta', 'theme'),
7677
_meta: map.merge(if($meta, $meta, ()), (
7778
variant: map.get($schema, '_meta', 'theme'),
7879
)),

projects/igniteui-angular/src/lib/core/styles/components/banner/_banner-theme.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
banner-border-color: $banner-border-color,
5858
banner-illustration-color: $banner-illustration-color,
5959
border-radius: $border-radius,
60+
theme: map.get($schema, '_meta', 'theme'),
6061
_meta: map.merge(if($meta, $meta, ()), (
6162
variant: map.get($schema, '_meta', 'theme')
6263
)),

0 commit comments

Comments
 (0)