Skip to content

Commit 9cf467d

Browse files
authored
Merge branch 'master' into skrastev/feat-7387
2 parents 4c732be + fe3a767 commit 9cf467d

File tree

11 files changed

+793
-445
lines changed

11 files changed

+793
-445
lines changed

gulpfile.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ module.exports.copySchematics = (cb) => {
135135
};
136136

137137
const typedocBuildTheme = (cb) => {
138-
spawnSync(`typedoc`, [TYPEDOC.PROJECT_PATH], { stdio: 'inherit', shell: true });
138+
spawnSync(`typedoc`, [TYPEDOC.PROJECT_PATH,
139+
"--tsconfig",
140+
"tsconfig.base.json"], { stdio: 'inherit', shell: true });
139141
cb();
140142
};
141143
typedocBuildTheme.displayName = 'typedoc-build:theme';
@@ -208,7 +210,9 @@ function typedocBuildDocsJA (cb) {
208210
TYPEDOC.TEMPLATE_STRINGS_PATH,
209211
'--warns',
210212
'--localize',
211-
'jp'], { stdio: 'inherit', shell: true });
213+
'jp',
214+
"--tsconfig",
215+
"tsconfig.base.json"], { stdio: 'inherit', shell: true });
212216

213217
cb();
214218
}
@@ -217,7 +221,9 @@ function typedocBuildDocsEN (cb) {
217221
spawnSync('typedoc', [
218222
TYPEDOC.PROJECT_PATH,
219223
'--localize',
220-
'en'], { stdio: 'inherit', shell: true});
224+
'en',
225+
"--tsconfig",
226+
"tsconfig.base.json"], { stdio: 'inherit', shell: true});
221227

222228
cb();
223229
}

package-lock.json

Lines changed: 95 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"build:style": "gulp buildStyle",
2626
"build:migration": "gulp copyMigrations && tsc --listEmittedFiles --project ./projects/igniteui-angular/migrations/tsconfig.json",
2727
"build:schematics": "gulp copySchematics && tsc --listEmittedFiles --project ./projects/igniteui-angular/schematics/tsconfig.json",
28-
"build:docs": "sassdoc projects/igniteui-angular/src/lib/core/styles && gulp typedocBuildTheme",
28+
"build:docs": "sassdoc projects/igniteui-angular/src/lib/core/styles && gulp typedoc-build:theme",
2929
"lint:lib": "ng lint && stylelint \"projects/igniteui-angular/src/lib/core/styles\"",
3030
"typedoc:dev": "gulp typedocServe",
3131
"typedoc-build:export": "gulp exportTypedocJson ",
@@ -93,7 +93,7 @@
9393
"gulp-util": "^3.0.8",
9494
"hammer-simulator": "0.0.1",
9595
"igniteui-sassdoc-theme": "^1.1.2",
96-
"igniteui-typedoc-theme": "^1.3.5",
96+
"igniteui-typedoc-theme": "^1.3.6",
9797
"jasmine": "~3.5.0",
9898
"jasmine-core": "~3.5.0",
9999
"jasmine-spec-reporter": "~5.0.2",
@@ -116,7 +116,7 @@
116116
"themeleon": "^3.0.2",
117117
"ts-node": "~7.0.1",
118118
"tslint": "~6.1.0",
119-
"typedoc": "^0.16.9",
119+
"typedoc": "^0.17.7",
120120
"typedoc-plugin-localization": "^2.2.1",
121121
"typescript": "~3.9.3",
122122
"webpack-sources": "1.3.0"

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)