Skip to content

Commit e9115ee

Browse files
authored
Merge branch '9.1.x' into nalipiev/drop-down-shadow-9.1
2 parents 8c72e3d + 1c72dce commit e9115ee

21 files changed

+1335
-1103
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/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.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)