Skip to content

Commit c185a72

Browse files
committed
Merge branch 'angular-11' of https://github.com/IgniteUI/igniteui-angular into angular-11
2 parents f55fd70 + e43f6c0 commit c185a72

39 files changed

+3954
-5032
lines changed

package-lock.json

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

projects/igniteui-angular/src/lib/core/styles/base/utilities/_functions.scss

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -477,17 +477,34 @@
477477
}
478478

479479
@function igx-generate-series-colors($palette) {
480+
$color-blind: if(global-variable-exists('_igx-enhanced-accessibility'), $_igx-enhanced-accessibility, false);
481+
482+
@if $color-blind {
483+
@return (
484+
rgb(86, 180, 233),
485+
rgb(0, 158, 115),
486+
rgb(240, 228, 68),
487+
rgb(213, 94, 0),
488+
rgb(214, 0, 254),
489+
rgb(0, 73, 159),
490+
rgb(230, 159, 0),
491+
rgb(0, 0, 0),
492+
rgb(132, 240, 223),
493+
rgb(115, 86, 86),
494+
);
495+
}
496+
480497
@return (
481-
igx-color($palette, 'primary'),
482-
igx-color($palette, 'secondary'),
483-
rgb(249, 98, 50),
484-
rgb(60, 189, 201),
485-
rgb(220, 63, 118),
486-
rgb(255, 152, 0),
487-
rgb(78, 98, 207),
488-
rgb(84, 194, 90),
489-
rgb(121, 85, 72),
490-
rgb(154, 154, 154)
498+
rgb(157, 231, 114),
499+
rgb(139, 91, 177),
500+
rgb(109, 177, 255),
501+
rgb(154, 242, 228),
502+
rgb(238, 88, 121),
503+
rgb(115, 86, 86),
504+
rgb(247, 210, 98),
505+
rgb(168, 168, 183),
506+
rgb(224, 81, 169),
507+
rgb(248, 161, 95),
491508
);
492509
}
493510

projects/igniteui-angular/src/lib/core/styles/themes/_core.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,24 @@
8888

8989
/// @param {boolean} $print-layout [true] - Activates the printing styles of the components.
9090
/// @param {string} $direction [ltr] - Sets the layout direction. Can be 'ltr' or 'rtl'.
91+
/// @param {boolean} $enhanced-accesibility [false] - Switches component colors and other properties to more accessible values.
9192
/// @param {color} $foreground-color [0, 0, 0, .87] - Sets the value of the global $igx-foreground-color used in all typography styles.
9293
/// @requires {mixin} igx-typography
9394
/// @requires {mixin} igx-vhelper
9495
/// @requires {mixin} igx-print-layout
9596
@mixin igx-core(
9697
$print-layout: true,
9798
$direction: ltr,
99+
$enhanced-accessibility: false
98100
) {
99101
@if $direction != ltr and $direction != rtl {
100102
$direction: ltr !global;
101103
} @else {
102104
$direction: $direction !global;
103105
}
104106

107+
$_igx-enhanced-accessibility: $enhanced-accessibility !global;
108+
105109
@include igx-typography();
106110
@include igx-vhelper();
107111

projects/igniteui-angular/src/lib/core/utils.ts

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,34 @@ export function cloneValue(value: any): any {
103103
return value;
104104
}
105105

106+
/**
107+
* Parse provided input to Date.
108+
* @param value input to parse
109+
* @returns Date if parse succeed or null
110+
* @hidden
111+
*/
112+
export function parseDate(value: any): Date | null {
113+
// if value is Invalid Date return null
114+
if (isDate(value)) {
115+
return !isNaN(value.getTime()) ? value : null;
116+
}
117+
return value ? new Date(value) : null;
118+
}
119+
120+
/**
121+
* Returns an array with unique dates only.
122+
* @param columnValues collection of date values (might be numbers or ISO 8601 strings)
123+
* @returns collection of unique dates.
124+
* @hidden
125+
*/
126+
export function uniqueDates(columnValues: any[]) {
127+
return columnValues.reduce((a, c) => {
128+
if (!a.cache[c.label]) { a.result.push(c); }
129+
a.cache[c.label] = true;
130+
return a;
131+
}, {result: [], cache: {}}).result;
132+
}
133+
106134
/**
107135
* Checks if provided variable is Object
108136
* @param value Value to check
@@ -119,8 +147,8 @@ export function isObject(value: any): boolean {
119147
* @returns true if provided variable is Date
120148
* @hidden
121149
*/
122-
export function isDate(value: any) {
123-
return Object.prototype.toString.call(value) === '[object Date]';
150+
export function isDate(value: any): boolean {
151+
return value instanceof Date;
124152
}
125153

126154
/**
@@ -326,9 +354,9 @@ export interface CancelableBrowserEventArgs extends CancelableEventArgs {
326354
event?: Event;
327355
}
328356

329-
export interface IBaseCancelableBrowserEventArgs extends CancelableBrowserEventArgs, IBaseEventArgs {}
357+
export interface IBaseCancelableBrowserEventArgs extends CancelableBrowserEventArgs, IBaseEventArgs { }
330358

331-
export interface IBaseCancelableEventArgs extends CancelableEventArgs, IBaseEventArgs {}
359+
export interface IBaseCancelableEventArgs extends CancelableEventArgs, IBaseEventArgs { }
332360

333361
export const HORIZONTAL_NAV_KEYS = new Set(['arrowleft', 'left', 'arrowright', 'right', 'home', 'end']);
334362

@@ -349,7 +377,8 @@ export const NAVIGATION_KEYS = new Set([
349377
]);
350378
export const ROW_EXPAND_KEYS = new Set('right down arrowright arrowdown'.split(' '));
351379
export const ROW_COLLAPSE_KEYS = new Set('left up arrowleft arrowup'.split(' '));
352-
export const SUPPORTED_KEYS = new Set([...Array.from(NAVIGATION_KEYS), 'enter', 'f2', 'escape', 'esc', 'pagedown', 'pageup', '+', 'add']);
380+
export const ROW_ADD_KEYS = new Set(['+', 'add', '≠', '±', '=']);
381+
export const SUPPORTED_KEYS = new Set([...Array.from(NAVIGATION_KEYS), ...Array.from(ROW_ADD_KEYS), 'enter', 'f2', 'escape', 'esc', 'pagedown', 'pageup']);
353382
export const HEADER_KEYS = new Set([...Array.from(NAVIGATION_KEYS), 'escape', 'esc' , 'l',
354383
/** This symbol corresponds to the Alt + L combination under MAC. */
355384
'¬']);
@@ -464,7 +493,7 @@ export function yieldingLoop(count: number, chunkSize: number, callback: (index:
464493
let i = 0;
465494
const chunk = () => {
466495
const end = Math.min(i + chunkSize, count);
467-
for ( ; i < end; ++i) {
496+
for (; i < end; ++i) {
468497
callback(i);
469498
}
470499
if (i < count) {

projects/igniteui-angular/src/lib/data-operations/data-util.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { ITreeGridRecord } from '../grids/tree-grid/public_api';
1515
import { cloneValue, mergeObjects, mkenum } from '../core/utils';
1616
import { Transaction, TransactionType, HierarchicalTransaction } from '../services/transaction/transaction';
1717
import { getHierarchy, isHierarchyMatch } from './operations';
18+
import { GridType } from '../grids/common/grid.interface';
1819

1920
/**
2021
* @hidden
@@ -31,25 +32,27 @@ export type DataType = (typeof DataType)[keyof typeof DataType];
3132
* @hidden
3233
*/
3334
export class DataUtil {
34-
public static sort<T>(data: T[], expressions: ISortingExpression[], sorting: IGridSortingStrategy = new IgxSorting()): T[] {
35-
return sorting.sort(data, expressions);
35+
public static sort<T>(data: T[], expressions: ISortingExpression[], sorting: IGridSortingStrategy = new IgxSorting(),
36+
grid?: GridType): T[] {
37+
return sorting.sort(data, expressions, grid);
3638
}
3739

3840
public static treeGridSort(hierarchicalData: ITreeGridRecord[],
3941
expressions: ISortingExpression[],
4042
sorting: IGridSortingStrategy = new IgxDataRecordSorting(),
41-
parent?: ITreeGridRecord): ITreeGridRecord[] {
43+
parent?: ITreeGridRecord,
44+
grid?: GridType): ITreeGridRecord[] {
4245
let res: ITreeGridRecord[] = [];
4346
hierarchicalData.forEach((hr: ITreeGridRecord) => {
4447
const rec: ITreeGridRecord = DataUtil.cloneTreeGridRecord(hr);
4548
rec.parent = parent;
4649
if (rec.children) {
47-
rec.children = DataUtil.treeGridSort(rec.children, expressions, sorting, rec);
50+
rec.children = DataUtil.treeGridSort(rec.children, expressions, sorting, rec, grid);
4851
}
4952
res.push(rec);
5053
});
5154

52-
res = DataUtil.sort(res, expressions, sorting);
55+
res = DataUtil.sort(res, expressions, sorting, grid);
5356

5457
return res;
5558
}
@@ -66,7 +69,7 @@ export class DataUtil {
6669
return rec;
6770
}
6871

69-
public static group<T>(data: T[], state: IGroupingState, grid: any = null,
72+
public static group<T>(data: T[], state: IGroupingState, grid: GridType = null,
7073
groupsRecords: any[] = [], fullResult: IGroupByResult = { data: [], metadata: [] }): IGroupByResult {
7174
const grouping = new IgxGrouping();
7275
groupsRecords.splice(0, groupsRecords.length);
@@ -105,11 +108,11 @@ export class DataUtil {
105108
return data.slice(index * recordsPerPage, (index + 1) * recordsPerPage);
106109
}
107110

108-
public static filter<T>(data: T[], state: IFilteringState): T[] {
111+
public static filter<T>(data: T[], state: IFilteringState, grid?: GridType): T[] {
109112
if (!state.strategy) {
110113
state.strategy = new FilteringStrategy();
111114
}
112-
return state.strategy.filter(data, state.expressionsTree, state.advancedExpressionsTree);
115+
return state.strategy.filter(data, state.expressionsTree, state.advancedExpressionsTree, grid);
113116
}
114117

115118
public static correctPagingState(state: IPagingState, length: number) {

projects/igniteui-angular/src/lib/data-operations/filtering-condition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ export class IgxDateFilteringOperand extends IgxFilteringOperand {
391391

392392
protected findValueInSet(target: any, searchVal: Set<any>) {
393393
if (!target) { return false; }
394-
return searchVal.has(new Date(target.getFullYear(), target.getMonth(), target.getDate()).toISOString());
394+
return searchVal.has(target.toISOString());
395395
}
396396
}
397397

projects/igniteui-angular/src/lib/data-operations/filtering-strategy.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('Unit testing FilteringStrategy', () => {
2323
searchVal: 1
2424
}
2525
];
26-
const res = fs.filter(data, expressionTree);
26+
const res = fs.filter(data, expressionTree, null, null);
2727
expect(dataGenerator.getValuesForColumn(res, 'number'))
2828
.toEqual([2, 3, 4]);
2929
});
@@ -65,7 +65,7 @@ describe('Unit testing FilteringStrategy', () => {
6565
searchVal: 'ROW'
6666
}
6767
];
68-
const res = filterstr.filter(data, expressionTree);
68+
const res = filterstr.filter(data, expressionTree, null, null);
6969
expect(dataGenerator.getValuesForColumn(res, 'number'))
7070
.toEqual([0]);
7171
});

projects/igniteui-angular/src/lib/data-operations/filtering-strategy.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { FilteringLogic, IFilteringExpression } from './filtering-expression.interface';
22
import { FilteringExpressionsTree, IFilteringExpressionsTree } from './filtering-expressions-tree';
3-
import { resolveNestedPath } from '../core/utils';
3+
import { resolveNestedPath, parseDate } from '../core/utils';
4+
import { GridType } from '../grids/common/grid.interface';
5+
6+
const DateType = 'date';
47

58
export interface IFilteringStrategy {
6-
filter(data: any[], expressionsTree: IFilteringExpressionsTree, advancedExpressionsTree?: IFilteringExpressionsTree): any[];
9+
filter(data: any[], expressionsTree: IFilteringExpressionsTree, advancedExpressionsTree?: IFilteringExpressionsTree,
10+
grid?: GridType): any[];
711
}
812

913
export class NoopFilteringStrategy implements IFilteringStrategy {
@@ -22,17 +26,17 @@ export class NoopFilteringStrategy implements IFilteringStrategy {
2226

2327
export abstract class BaseFilteringStrategy implements IFilteringStrategy {
2428
public abstract filter(data: any[], expressionsTree: IFilteringExpressionsTree,
25-
advancedExpressionsTree?: IFilteringExpressionsTree): any[];
29+
advancedExpressionsTree?: IFilteringExpressionsTree, grid?: GridType): any[];
2630

27-
protected abstract getFieldValue(rec: object, fieldName: string): any;
31+
protected abstract getFieldValue(rec: object, fieldName: string, isDate: boolean): any;
2832

29-
public findMatchByExpression(rec: object, expr: IFilteringExpression): boolean {
33+
public findMatchByExpression(rec: object, expr: IFilteringExpression, isDate?: boolean): boolean {
3034
const cond = expr.condition;
31-
const val = this.getFieldValue(rec, expr.fieldName);
35+
const val = this.getFieldValue(rec, expr.fieldName, isDate);
3236
return cond.logic(val, expr.searchVal, expr.ignoreCase);
3337
}
3438

35-
public matchRecord(rec: object, expressions: IFilteringExpressionsTree | IFilteringExpression): boolean {
39+
public matchRecord(rec: object, expressions: IFilteringExpressionsTree | IFilteringExpression, grid?: GridType): boolean {
3640
if (expressions) {
3741
if (expressions instanceof FilteringExpressionsTree) {
3842
const expressionsTree = expressions as IFilteringExpressionsTree;
@@ -42,7 +46,7 @@ export abstract class BaseFilteringStrategy implements IFilteringStrategy {
4246
if (expressionsTree.filteringOperands && expressionsTree.filteringOperands.length) {
4347
for (let i = 0; i < expressionsTree.filteringOperands.length; i++) {
4448
operand = expressionsTree.filteringOperands[i];
45-
matchOperand = this.matchRecord(rec, operand);
49+
matchOperand = this.matchRecord(rec, operand, grid);
4650

4751
// Return false if at least one operand does not match and the filtering logic is And
4852
if (!matchOperand && operator === FilteringLogic.And) {
@@ -61,7 +65,9 @@ export abstract class BaseFilteringStrategy implements IFilteringStrategy {
6165
return true;
6266
} else {
6367
const expression = expressions as IFilteringExpression;
64-
return this.findMatchByExpression(rec, expression);
68+
const isDate = grid && grid.getColumnByName(expression.fieldName) ?
69+
grid.getColumnByName(expression.fieldName).dataType === DateType : false;
70+
return this.findMatchByExpression(rec, expression, isDate);
6571
}
6672
}
6773

@@ -78,7 +84,8 @@ export class FilteringStrategy extends BaseFilteringStrategy {
7884
return this._instace || (this._instace = new this());
7985
}
8086

81-
public filter<T>(data: T[], expressionsTree: IFilteringExpressionsTree, advancedExpressionsTree?: IFilteringExpressionsTree): T[] {
87+
public filter<T>(data: T[], expressionsTree: IFilteringExpressionsTree, advancedExpressionsTree: IFilteringExpressionsTree,
88+
grid: GridType): T[] {
8289
let i;
8390
let rec;
8491
const len = data.length;
@@ -88,14 +95,16 @@ export class FilteringStrategy extends BaseFilteringStrategy {
8895
}
8996
for (i = 0; i < len; i++) {
9097
rec = data[i];
91-
if (this.matchRecord(rec, expressionsTree) && this.matchRecord(rec, advancedExpressionsTree)) {
98+
if (this.matchRecord(rec, expressionsTree, grid) && this.matchRecord(rec, advancedExpressionsTree, grid)) {
9299
res.push(rec);
93100
}
94101
}
95102
return res;
96103
}
97104

98-
protected getFieldValue(rec: object, fieldName: string): any {
99-
return resolveNestedPath(rec, fieldName);
105+
protected getFieldValue(rec: object, fieldName: string, isDate: boolean = false): any {
106+
let value = resolveNestedPath(rec, fieldName);
107+
value = value && isDate ? parseDate(value) : value;
108+
return value;
100109
}
101110
}

0 commit comments

Comments
 (0)