Skip to content

Commit 8a555f7

Browse files
committed
Merge branch 'nalipiev/drop-down-shadow-9.1' of https://github.com/IgniteUI/igniteui-angular into nalipiev/drop-down-shadow-9.1
2 parents 26bee66 + e9115ee commit 8a555f7

34 files changed

+1601
-1267
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes for each version of this project will be documented in this file.
44

5+
## 9.1.4
6+
7+
### New Features
8+
- `IgxList`
9+
- Added localization support.
10+
511
## 9.1.1
612

713
### General
@@ -169,7 +175,6 @@ All notable changes for each version of this project will be documented in this
169175
- Added support for tabIndex attribute applied to the main chip element.
170176
- Added `tabIndex` input so it can support change detection as well.
171177

172-
173178
- `IgxHighlightDirective`
174179
- New `metadata` property was introduced, which allows adding additional, custom logic to the activation condition of a highlighted element.
175180

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export interface IListResourceStrings {
2+
igx_list_no_items?: string;
3+
igx_list_loading?: string;
4+
}
5+
6+
export const ListResourceStringsEN: IListResourceStrings = {
7+
igx_list_no_items: 'There are no items in the list.',
8+
igx_list_loading: 'Loading data from the server...'
9+
};

projects/igniteui-angular/src/lib/core/i18n/resources.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ITimePickerResourceStrings, TimePickerResourceStringsEN } from './time-
44
import { PaginatorResourceStringsEN } from './paginator-resources';
55
import { cloneValue } from '../utils';
66
import { ICarouselResourceStrings, CarouselResourceStringsEN } from './carousel-resources';
7+
import { ListResourceStringsEN } from './list-resources';
78

89
export interface IResourceStrings extends IGridResourceStrings, ITimePickerResourceStrings, ICarouselResourceStrings {}
910

@@ -16,6 +17,7 @@ export const CurrentResourceStrings = {
1617
TimePickerResStrings: cloneValue(TimePickerResourceStringsEN),
1718
DateRangePickerResStrings: cloneValue(DateRangePickerResourceStringsEN),
1819
CarouselResStrings: cloneValue(CarouselResourceStringsEN),
20+
ListResStrings: cloneValue(ListResourceStringsEN),
1921
};
2022

2123
function updateResourceStrings(currentStrings: IResourceStrings, newStrings: IResourceStrings ) {

projects/igniteui-angular/src/lib/core/styles/components/grid/_excel-filtering-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@
387387
align-items: center;
388388
padding: 0 rem(16px);
389389

390-
igx-input-group {
390+
igx-select {
391391
flex-grow: 1;
392392
flex-basis: 40%;
393393
margin: rem(16px) 0;

projects/igniteui-angular/src/lib/core/styles/components/input/_input-group-theme.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,6 @@
889889
display: block;
890890
border: none;
891891
height: rem(32px, map-get($base-scale-size, 'comfortable'));
892-
line-height: 0 !important; /* resets typography styles */
893892
width: 100%;
894893
min-width: 0;
895894
overflow: visible;
@@ -900,13 +899,18 @@
900899
border-top: rem(3px) solid transparent;
901900
padding-bottom: rem(3px);
902901

902+
&:not([type='date']) {
903+
line-height: 0 !important; /* resets typography styles */
904+
}
905+
903906
&::-webkit-input-placeholder {
904907
line-height: normal;
905908
}
906909

907910
&::placeholder {
908911
color: --var($theme, 'placeholder-color');
909912
opacity: 1;
913+
line-height: normal; /* Fix placeholder position in Safari */
910914
}
911915
}
912916

projects/igniteui-angular/src/lib/date-picker/date-picker.component.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,22 @@ describe('IgxDatePicker', () => {
132132
expect(inputGroup.nativeElement.classList.contains('igx-input-group--disabled')).toBeTruthy();
133133
});
134134

135+
it('should not be able to toggle & clear when disabled', () => {
136+
const date = new Date();
137+
datePicker.value = date;
138+
datePicker.disabled = true;
139+
fixture.detectChanges();
140+
expect(datePicker.collapsed).toBeTruthy();
141+
142+
datePicker.openDialog();
143+
fixture.detectChanges();
144+
expect(datePicker.collapsed).toBeTruthy();
145+
146+
datePicker.clear();
147+
fixture.detectChanges();
148+
expect(datePicker.value).toEqual(date);
149+
});
150+
135151
it('When labelVisability is set to false the label should not be visible', () => {
136152
let label = fixture.debugElement.query(By.directive(IgxLabelDirective));
137153

projects/igniteui-angular/src/lib/date-picker/date-picker.component.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { IgxInputGroupModule, IgxInputDirective, IgxInputGroupComponent, IgxInpu
3434
import { Subject, fromEvent, animationFrameScheduler, interval, Subscription } from 'rxjs';
3535
import { filter, takeUntil, throttle } from 'rxjs/operators';
3636
import { IgxOverlayOutletDirective } from '../directives/toggle/toggle.directive';
37-
import { IgxTextSelectionModule} from '../directives/text-selection/text-selection.directive';
37+
import { IgxTextSelectionModule } from '../directives/text-selection/text-selection.directive';
3838
import {
3939
OverlaySettings,
4040
IgxOverlayService,
@@ -144,7 +144,7 @@ const noop = () => { };
144144
`]
145145
})
146146
export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor,
147-
EditorProvider, OnInit, AfterViewInit, OnDestroy, AfterViewChecked {
147+
EditorProvider, OnInit, AfterViewInit, OnDestroy, AfterViewChecked {
148148
/**
149149
* Gets/Sets the `IgxDatePickerComponent` label.
150150
* @remarks
@@ -914,10 +914,10 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
914914
* @param date passed date that has to be set to the calendar.
915915
*/
916916
public selectDate(date: Date): void {
917-
const oldValue = this.value;
917+
const oldValue = this.value;
918918
this.value = date;
919919

920-
this.emitValueChangeEvent(oldValue, this.value );
920+
this.emitValueChangeEvent(oldValue, this.value);
921921
this.onSelection.emit(date);
922922
}
923923

@@ -929,9 +929,9 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
929929
* ```
930930
*/
931931
public deselectDate(): void {
932-
const oldValue = this.value;
932+
const oldValue = this.value;
933933
this.value = null;
934-
this.emitValueChangeEvent(oldValue, this.value );
934+
this.emitValueChangeEvent(oldValue, this.value);
935935
if (this.calendar) {
936936
this.calendar.deselectDate();
937937
}
@@ -946,7 +946,7 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
946946
* ```
947947
*/
948948
public openDialog(): void {
949-
if (!this.collapsed) {
949+
if (!this.collapsed || this.disabled) {
950950
return;
951951
}
952952

@@ -987,10 +987,12 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
987987
* @hidden @internal
988988
*/
989989
public clear(): void {
990-
this.isEmpty = true;
991-
this.invalidDate = '';
992-
this.deselectDate();
993-
this._setCursorPosition(0);
990+
if (!this.disabled) {
991+
this.isEmpty = true;
992+
this.invalidDate = '';
993+
this.deselectDate();
994+
this._setCursorPosition(0);
995+
}
994996
}
995997

996998
/**
@@ -1008,10 +1010,10 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
10081010
date.setSeconds(this.value.getSeconds());
10091011
date.setMilliseconds(this.value.getMilliseconds());
10101012
}
1011-
const oldValue = this.value;
1013+
const oldValue = this.value;
10121014
this.value = date;
10131015

1014-
this.emitValueChangeEvent(oldValue, this.value );
1016+
this.emitValueChangeEvent(oldValue, this.value);
10151017
this.calendar.viewDate = date;
10161018
this.closeCalendar();
10171019
this.onSelection.emit(date);
@@ -1141,11 +1143,11 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
11411143

11421144
if (this.disabledDates === null
11431145
|| (this.disabledDates !== null && !isDateInRanges(newValue, this.disabledDates))) {
1144-
const oldValue = this.value;
1145-
this.value = newValue;
1146+
const oldValue = this.value;
1147+
this.value = newValue;
11461148

1147-
this.emitValueChangeEvent(oldValue, this.value );
1148-
this.invalidDate = '';
1149+
this.emitValueChangeEvent(oldValue, this.value);
1150+
this.invalidDate = '';
11491151
} else {
11501152
const args: IDatePickerDisabledDateEventArgs = {
11511153
datePicker: this,

projects/igniteui-angular/src/lib/date-picker/date-picker.utils.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { isIE } from '../core/utils';
22
import { DatePart, DatePartInfo } from '../directives/date-time-editor/date-time-editor.common';
3+
import { formatDate, FormatWidth, getLocaleDateFormat } from '@angular/common';
34

45
/**
56
* This enum is used to keep the date validation result.
@@ -48,7 +49,7 @@ export abstract class DatePickerUtil {
4849

4950

5051
/**
51-
* TODO: Unit tests for all public methods.
52+
* TODO: (in issue #6483) Unit tests and docs for all public methods.
5253
*/
5354

5455

@@ -147,6 +148,38 @@ export abstract class DatePickerUtil {
147148
return DatePickerUtil.getMask(parts);
148149
}
149150

151+
public static formatDate(value: number | Date, format: string, locale: string, timezone?: string): string {
152+
let formattedDate: string;
153+
try {
154+
formattedDate = formatDate(value, format, locale, timezone);
155+
} catch {
156+
this.logMissingLocaleSettings(locale);
157+
const formatter = new Intl.DateTimeFormat(locale);
158+
formattedDate = formatter.format(value);
159+
}
160+
161+
return formattedDate;
162+
}
163+
164+
public static getLocaleDateFormat(locale: string, displayFormat?: string): string {
165+
const formatKeys = Object.keys(FormatWidth) as (keyof FormatWidth)[];
166+
const targetKey = formatKeys.find(k => k.toLowerCase() === displayFormat?.toLowerCase().replace('date', ''));
167+
if (!targetKey) {
168+
// if displayFormat is not shortDate, longDate, etc.
169+
// or if it is not set by the user
170+
return displayFormat;
171+
}
172+
let format: string;
173+
try {
174+
format = getLocaleDateFormat(locale, FormatWidth[targetKey]);
175+
} catch {
176+
this.logMissingLocaleSettings(locale);
177+
format = DatePickerUtil.getDefaultInputFormat(locale);
178+
}
179+
180+
return format;
181+
}
182+
150183
public static isDateOrTimeChar(char: string): boolean {
151184
return DATE_CHARS.indexOf(char) !== -1 || TIME_CHARS.indexOf(char) !== -1;
152185
}
@@ -303,6 +336,11 @@ export abstract class DatePickerUtil {
303336
return _value.getTime() < _minValue.getTime();
304337
}
305338

339+
private static logMissingLocaleSettings(locale: string): void {
340+
console.warn(`Missing locale data for the locale ${locale}. Please refer to https://angular.io/guide/i18n#i18n-pipes`);
341+
console.warn('Using default browser locale settings.');
342+
}
343+
306344
private static ensureLeadingZero(part: DatePartInfo) {
307345
switch (part.type) {
308346
case DatePart.Date:

projects/igniteui-angular/src/lib/date-range-picker/date-range-picker-inputs.common.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Component, ContentChild, Pipe, PipeTransform, Output, EventEmitter, HostListener, Directive } from '@angular/core';
2-
import { formatDate } from '@angular/common';
32
import { NgControl } from '@angular/forms';
43
import { IgxInputDirective, IgxInputState } from '../input-group/public_api';
54
import { IgxInputGroupComponent } from '../input-group/input-group.component';
65
import { IgxInputGroupBase } from '../input-group/input-group.common';
6+
import { DatePickerUtil } from '../date-picker/date-picker.utils';
77
import { IgxDateTimeEditorDirective } from '../directives/date-time-editor/public_api';
88

99
/**
@@ -17,14 +17,17 @@ export interface DateRange {
1717
/** @hidden @internal */
1818
@Pipe({ name: 'dateRange' })
1919
export class DateRangePickerFormatPipe implements PipeTransform {
20-
public transform(values: DateRange, inputFormat?: string, locale?: string): string {
21-
if (!values) {
20+
public transform(values: DateRange, appliedFormat?: string,
21+
locale?: string, formatter?: (_: DateRange) => string): string {
22+
if (!values || !values.start && !values.end) {
2223
return '';
2324
}
25+
if (formatter) {
26+
return formatter(values);
27+
}
2428
const { start, end } = values;
25-
// TODO: move default locale from IgxDateTimeEditorDirective to its commons file/use displayFormat
26-
const startDate = inputFormat ? formatDate(start, inputFormat, locale || 'en') : start?.toLocaleDateString();
27-
const endDate = inputFormat ? formatDate(end, inputFormat, locale || 'en') : end?.toLocaleDateString();
29+
const startDate = appliedFormat ? DatePickerUtil.formatDate(start, appliedFormat, locale || 'en') : start?.toLocaleDateString();
30+
const endDate = appliedFormat ? DatePickerUtil.formatDate(end, appliedFormat, locale || 'en') : end?.toLocaleDateString();
2831
let formatted;
2932
if (start) {
3033
formatted = `${startDate} - `;
@@ -33,7 +36,6 @@ export class DateRangePickerFormatPipe implements PipeTransform {
3336
}
3437
}
3538

36-
// TODO: no need to set format twice
3739
return formatted ? formatted : '';
3840
}
3941
}

projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
<ng-template #defTemplate>
4444
<igx-input-group (click)="open()">
4545
<input #singleInput igxInput type="text" readonly
46-
[placeholder]="this.value ? '' : appliedFormat"
46+
[placeholder]="this.value ? '' : singleInputFormat"
4747
role="combobox"
4848
aria-haspopup="grid"
4949
[attr.aria-expanded]="!toggle.collapsed"
5050
[attr.aria-labelledby]="this.label?.id"
51-
[value]="this.value | dateRange: this.inputFormat : this.locale"
51+
[value]="this.value | dateRange: this.appliedFormat : this.locale : this.formatter"
5252
/>
5353

5454
<igx-prefix *ngIf="!this.toggleComponents.length">

0 commit comments

Comments
 (0)