Skip to content

Commit 4dcdb7e

Browse files
authored
Merge branch 'master' into ddincheva/cellEditingFocus
2 parents 8399573 + d7d0d5f commit 4dcdb7e

File tree

6 files changed

+203
-46
lines changed

6 files changed

+203
-46
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ All notable changes for each version of this project will be documented in this
6969
- `tickLabelsOrientation` input was added. Allows you to change the rotation of all tick labels from horizontal to vertical(toptobottom, bottomtotop).
7070
- `igxSliderTickLabel` directive has been introduced. Allows you to set a custom template for all tick labels.
7171
- `isContinuous` - input has been deleted. The option is not supported anymore.
72-
- `onValueChanged` - new output has been exposed. This event is emitted at the end of every slide interaction.
73-
72+
- `onValueChanged` - new output has been exposed. This event is emitted at the end of every slide interaction.
73+
7474
- `IgxCarousel`:
7575
- `keyboardSupport` input is added, which can be used to enable and disable keyboard navigation
7676
- `gesturesSupport` input is added, which can be used to enable and disable gestures
@@ -81,7 +81,7 @@ All notable changes for each version of this project will be documented in this
8181
- `nextButtonTemplate` directive is added, which is used to provide a custom next button template. If not provided, a default next button is used.
8282
- `prevButtonTemplate` directive is added, which is used to provide a custom previous button template. If not provided, a default previous button is used.
8383

84-
- `IgxSelect`:
84+
- `IgxSelect`:
8585
- adding `IgxSelectHeaderDirective` and `IgxSelectFooterDirective`. These can be used to provide a custom header, respectively footer templates for the `igxSelect` drop-down list. If there are no templates marked with these directives - no default templates will be used so the drop-down list will not have header nor footer.
8686

8787
- `IgxCombo`:
@@ -124,6 +124,7 @@ All notable changes for each version of this project will be documented in this
124124

125125
@include igx-progress-circular($theme);
126126
```
127+
- RTL support
127128

128129
## 8.2.6
129130

package-lock.json

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

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@
4545
},
4646
"private": true,
4747
"dependencies": {
48-
"@angular/animations": "^9.0.0-rc.10",
49-
"@angular/common": "^9.0.0-rc.10",
50-
"@angular/compiler": "^9.0.0-rc.10",
51-
"@angular/core": "^9.0.0-rc.10",
52-
"@angular/forms": "^9.0.0-rc.10",
53-
"@angular/platform-browser": "^9.0.0-rc.10",
54-
"@angular/platform-browser-dynamic": "^9.0.0-rc.10",
55-
"@angular/router": "^9.0.0-rc.10",
48+
"@angular/animations": "^9.0.0-rc.11",
49+
"@angular/common": "^9.0.0-rc.11",
50+
"@angular/compiler": "^9.0.0-rc.11",
51+
"@angular/core": "^9.0.0-rc.11",
52+
"@angular/forms": "^9.0.0-rc.11",
53+
"@angular/platform-browser": "^9.0.0-rc.11",
54+
"@angular/platform-browser-dynamic": "^9.0.0-rc.11",
55+
"@angular/router": "^9.0.0-rc.11",
5656
"@types/hammerjs": "^2.0.36",
5757
"@types/source-map": "0.5.2",
5858
"classlist.js": "^1.1.20150312",
@@ -70,8 +70,8 @@
7070
"@angular-devkit/build-ng-packagr": "~0.900.0-rc.10",
7171
"@angular-devkit/schematics": "^9.0.0-rc.10",
7272
"@angular/cli": "~9.0.0-rc.10",
73-
"@angular/compiler-cli": "^9.0.0-rc.10",
74-
"@angular/language-service": "^9.0.0-rc.10",
73+
"@angular/compiler-cli": "^9.0.0-rc.11",
74+
"@angular/language-service": "^9.0.0-rc.11",
7575
"@angularclass/hmr": "^2.1.3",
7676
"@types/jasmine": "~3.3.5",
7777
"@types/jasminewd2": "~2.0.6",

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
IgxProgressBarGradientDirective,
1818
} from './progressbar.common';
1919
import { IBaseEventArgs } from '../core/utils';
20+
import { IgxDirectionality } from '../services/direction/directionality';
2021

2122
const ONE_PERCENT = 0.01;
2223
const MIN_VALUE = 0;
@@ -704,7 +705,7 @@ export class IgxCircularProgressBarComponent extends BaseProgress implements Aft
704705

705706
@ViewChild('circle', { static: true }) private _svgCircle: ElementRef;
706707

707-
constructor(private renderer: Renderer2) {
708+
constructor(private renderer: Renderer2, private _directionality: IgxDirectionality) {
708709
super();
709710
}
710711

@@ -761,8 +762,9 @@ export class IgxCircularProgressBarComponent extends BaseProgress implements Aft
761762
}
762763

763764
private getProgress(percentage: number) {
764-
// Reverse the sign here: '-' should become '+' in RTL mode
765-
return this._circumference - (percentage * this._circumference / 100);
765+
return this._directionality.rtl ?
766+
this._circumference + (percentage * this._circumference / 100) :
767+
this._circumference - (percentage * this._circumference / 100);
766768
}
767769
}
768770

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import { TestBed, async, inject } from '@angular/core/testing';
2+
import { Component } from '@angular/core';
3+
import { IgxDirectionality, DIR_DOCUMENT } from './directionality';
4+
import { DOCUMENT } from '@angular/common';
5+
6+
interface FakeDoc {
7+
body: { dir?: string };
8+
documentElement: { dir?: string };
9+
}
10+
11+
describe('IgxDirectionality DI', () => {
12+
let fakeDoc: FakeDoc;
13+
beforeEach(async(() => {
14+
fakeDoc = {body: {}, documentElement: {}};
15+
16+
TestBed.configureTestingModule({
17+
declarations: [
18+
InjectsIgxDirectionalityComponent
19+
],
20+
}).compileComponents();
21+
}));
22+
23+
it('should inject the document through the injectionToken properly', () => {
24+
const injectionToken = TestBed.inject(DIR_DOCUMENT);
25+
const document = TestBed.inject(DOCUMENT);
26+
27+
expect(injectionToken).toEqual(document);
28+
expect(injectionToken).toEqual(jasmine.any(Document));
29+
expect(document).toBeTruthy(jasmine.any(Document));
30+
});
31+
32+
it('should read dir from html if not specified on the body', inject([DOCUMENT], () => {
33+
const fixture = TestBed.createComponent(InjectsIgxDirectionalityComponent);
34+
const component = fixture.debugElement.componentInstance;
35+
36+
expect(component.dir.document).not.toBeNull();
37+
expect(component.dir.document).not.toBeUndefined();
38+
expect(component.dir.document).toEqual(jasmine.any(Document));
39+
}));
40+
41+
});
42+
describe('IgxDirectionality', () => {
43+
let fakeDoc: FakeDoc;
44+
beforeEach(() => {
45+
fakeDoc = {body: {}, documentElement: {}};
46+
});
47+
48+
let expectedRes: string;
49+
let dirInstance: IgxDirectionality;
50+
it('should read dir from html if not specified on the body', () => {
51+
expectedRes = 'rtl';
52+
fakeDoc.documentElement.dir = expectedRes;
53+
54+
dirInstance = new IgxDirectionality(fakeDoc);
55+
expect(dirInstance.value).toEqual(expectedRes);
56+
});
57+
it('should read dir from body even it is also specified on the html element', () => {
58+
fakeDoc.documentElement.dir = 'ltr';
59+
expectedRes = 'rtl';
60+
fakeDoc.body.dir = expectedRes;
61+
62+
dirInstance = new IgxDirectionality(fakeDoc);
63+
expect(dirInstance.value).toEqual(expectedRes);
64+
});
65+
66+
it('should default to ltr if nothing specified', () => {
67+
expectedRes = 'ltr';
68+
69+
dirInstance = new IgxDirectionality(fakeDoc);
70+
expect(dirInstance.value).toEqual(expectedRes);
71+
});
72+
73+
it('should default to ltr if invalid values are set both on body or html elements', () => {
74+
fakeDoc.documentElement.dir = 'none';
75+
fakeDoc.body.dir = 'irrelevant';
76+
77+
dirInstance = new IgxDirectionality(fakeDoc);
78+
expect(dirInstance.value).toEqual('ltr');
79+
});
80+
});
81+
82+
@Component({
83+
selector: 'igx-div-element',
84+
template: `
85+
<div>element</div>
86+
`
87+
})
88+
class InjectsIgxDirectionalityComponent {
89+
constructor(public dir: IgxDirectionality) { }
90+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { Injectable, Inject, InjectionToken, inject } from '@angular/core';
2+
import { DOCUMENT } from '@angular/common';
3+
4+
/**
5+
* @hidden
6+
*/
7+
export type Direction = 'ltr' | 'rtl';
8+
9+
/**
10+
* Injection token is used to inject the document into Directionality
11+
* which factory could be faked for testing purposes.
12+
*
13+
* We can't provide and mock the DOCUMENT token from platform-browser because configureTestingModule
14+
* allows override of the default providers, directive, pipes, modules of the test injector
15+
* which causes errors.
16+
*
17+
* @hidden
18+
*/
19+
export const DIR_DOCUMENT = new InjectionToken<Document>('dir-doc', {
20+
providedIn: 'root',
21+
factory: DIR_DOCUMENT_FACTORY
22+
});
23+
24+
/**
25+
* @hidden
26+
*/
27+
export function DIR_DOCUMENT_FACTORY(): Document {
28+
return inject(DOCUMENT);
29+
}
30+
31+
/**
32+
* @hidden
33+
*
34+
* Bidirectional service that extracts the value of the direction attribute on the body or html elements.
35+
*
36+
* The dir attribute over the body element takes precedence.
37+
*/
38+
@Injectable({
39+
providedIn: 'root'
40+
})
41+
export class IgxDirectionality {
42+
private _dir: Direction;
43+
private _document: Document;
44+
45+
public get value(): Direction {
46+
return this._dir;
47+
}
48+
49+
public get document() {
50+
return this._document;
51+
}
52+
53+
public get rtl() {
54+
return this._dir === 'rtl';
55+
}
56+
57+
constructor(@Inject(DIR_DOCUMENT) document) {
58+
this._document = <Document>document;
59+
const bodyDir = this._document.body ? this._document.body.dir : null;
60+
const htmlDir = this._document.documentElement ? this._document.documentElement.dir : null;
61+
const extractedDir = bodyDir || htmlDir;
62+
this._dir = (extractedDir === 'ltr' || extractedDir === 'rtl') ? extractedDir : 'ltr';
63+
}
64+
}

0 commit comments

Comments
 (0)