Skip to content

Commit 843d836

Browse files
committed
introducing cdk (#576)
resolves #570
1 parent 207bc6f commit 843d836

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+341
-518
lines changed

.eslintrc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@
4949
"error"
5050
]
5151
}
52+
],
53+
"no-debugger": [
54+
"error"
55+
],
56+
"quotes": [
57+
"error",
58+
"single",
59+
{
60+
"allowTemplateLiterals": true
61+
}
5262
]
5363
}
5464
},

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ All notable changes to this project will be documented in this file.
77
- Working with RTL ([575](https://github.com/vlio20/angular-datepicker/pull/575)) closes [#504](https://github.com/vlio20/angular-datepicker/issues/504)
88

99
# Breaking changes
10-
- Replace deprecated `Moment` with Dayjs ([573](https://github.com/vlio20/angular-datepicker/pull/573)) closes [#530](https://github.com/vlio20/angular-datepicker/issues/530)
10+
- Replace deprecated `Moment` with Dayjs ([573](https://github.com/vlio20/angular-datepicker/pull/573)) closes [#530](https://github.com/vlio20/angular-datepicker/issues/530)
1111
Locale was removed from the library configuration, changing the locale should be done outside the component. More information can be found in the readme.md file under the Locale section.
1212
Some formats also might be change due to the way Dayjs is implemented.
13+
- Replace internal position resolving with Angular material cdk library ([576](https://github.com/vlio20/angular-datepicker/pull/576)) closes [#570 ](https://github.com/vlio20/angular-datepicker/issues/570 )
14+
This removal will drop the `attachTo` option from the library configuration.
15+
*Note:* You will also need to add the cdk styles to your project. You can do so by adding `@import '~@angular/cdk/overlay-prebuilt.css';` to your global styles or by adding it to the styles attribute in your angular.json file.
16+
1317

1418
# [13.0.0] (2021-12-22)
1519

README.md

Lines changed: 68 additions & 54 deletions
Large diffs are not rendered by default.

e2e/app.po.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class DemoPage {
116116
meridiemDisplayInline = $(`.dp-inline .dp-time-select-display-meridiem`);
117117
timeSeparatorDisplay = $(`${this.popupSelector} .dp-time-select-separator:nth-child(2)`);
118118
monthRows = $$('.dp-months-row');
119-
numOfMonthRowsToggle2 = $('#numOfMonthRows2');
119+
numOfMonthRowsToggle = $('#numOfMonthRows2');
120120

121121
daytimePickerMenu = $('#daytimePickerMenu');
122122
daytimeInlineMenu = $('#daytimeInlineMenu');

e2e/bugs/debounce-open-e2e.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('debounce open delay', () => {
1414
await page.dayPickerInput.click();
1515
await browser.waitForAngularEnabled(false);
1616
await browser.sleep(500);
17-
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
17+
expect(await page.datePickerPopup.isPresent()).toBe(false);
1818
await browser.sleep(600);
1919
await browser.waitForAngularEnabled(true);
2020
expect(await page.datePickerPopup.isDisplayed()).toBe(true);
@@ -25,10 +25,10 @@ describe('debounce open delay', () => {
2525
await page.dayPickerInput.click();
2626
await browser.waitForAngularEnabled(false);
2727
await browser.sleep(500);
28-
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
28+
expect(await page.datePickerPopup.isPresent()).toBe(false);
2929
await page.clickOnBody();
3030
await browser.sleep(600);
3131
await browser.waitForAngularEnabled(true);
32-
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
32+
expect(await page.datePickerPopup.isPresent()).toBe(false);
3333
});
3434
});

e2e/configuration-e2e.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('dpDayPicker configuration', () => {
1515
await page.openOnClickRadioOff.click();
1616
await page.openOnFocusRadioOff.click();
1717
await page.daytimePickerInput.click();
18-
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
18+
expect(await page.datePickerPopup.isPresent()).toBe(false);
1919
});
2020

2121
it('openOnClick = true, should open picker when clicked', async () => {

e2e/datepicker-e2e.spec.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('dpDayPicker dayPicker', () => {
1616
await page.dayPickerInput.click();
1717
expect(await page.datePickerPopup.isDisplayed()).toBe(true);
1818
await page.clickOnBody();
19-
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
19+
expect(await page.datePickerPopup.isPresent()).toBe(false);
2020

2121
await page.showOnOutsideClick.click();
2222
await page.dayPickerInput.click();
@@ -26,15 +26,18 @@ describe('dpDayPicker dayPicker', () => {
2626

2727
it('should check that the theme is added and removed', async () => {
2828
await page.themeOnRadio.click();
29+
await page.dayPickerInput.click();
2930
expect(await page.datePickerPopup.getAttribute('class')).toContain('dp-material');
3031
await page.themeOffRadio.click();
32+
await page.dayPickerInput.click();
3133
expect(await page.datePickerPopup.getAttribute('class')).not.toContain('dp-material');
3234
await page.themeOnRadio.click();
35+
await page.dayPickerInput.click();
3336
expect(await page.datePickerPopup.getAttribute('class')).toContain('dp-material');
3437
});
3538

3639
it('should check that the onOpenDelay is working', async () => {
37-
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
40+
expect(await page.datePickerPopup.isPresent()).toBe(false);
3841

3942
await page.scrollIntoView(page.onOpenDelayInput, true);
4043
await page.setInputValue(page.onOpenDelayInput, '1000');
@@ -45,7 +48,7 @@ describe('dpDayPicker dayPicker', () => {
4548
await browser.waitForAngularEnabled(false);
4649
await page.scrollIntoView(page.dayPickerInput, true);
4750
await page.dayPickerInput.click();
48-
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
51+
expect(await page.datePickerPopup.isPresent()).toBe(false);
4952
await browser.waitForAngularEnabled(true);
5053
browser.sleep(1000);
5154
expect(await page.datePickerPopup.isDisplayed()).toBe(true);
@@ -79,11 +82,19 @@ describe('dpDayPicker dayPicker', () => {
7982
expect(await page.weekNumbers.getText()).toEqual(['8', '9', '10', '11', '12', '13']);
8083
});
8184

85+
it('should remember last position', async () => {
86+
await page.setInputValue(page.dayPickerInput, '28-03-2017');
87+
await page.dayPickerInput.click();
88+
expect(await page.dayCalendarNavHeaderBtn.getText()).toEqual('Mar, 2017');
89+
await page.currentLocationBtn.click();
90+
expect(await page.dayCalendarNavHeaderBtn.getText()).toEqual(dayjs().format('MMM, YYYY'));
91+
});
92+
8293
it('should hide calendar on tab (blur)', async () => {
8394
await page.dayPickerInput.click();
8495
expect(await page.datePickerPopup.isDisplayed()).toBe(true);
8596
await page.dayPickerInput.sendKeys(protractor.Key.TAB);
86-
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
97+
expect(await page.datePickerPopup.isPresent()).toBe(false);
8798
});
8899

89100
it('should disable/enable month selection', async () => {
@@ -141,7 +152,7 @@ describe('dpDayPicker dayPicker', () => {
141152
await page.pickerDisabledRadio.click();
142153
expect(await page.dayPickerInput.getAttribute('disabled')).toEqual('true');
143154
await page.dayPickerInput.click();
144-
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
155+
expect(await page.datePickerPopup.isPresent()).toBe(false);
145156
await page.pickerEnabledRadio.click();
146157
expect(await page.dayPickerInput.getAttribute('disabled')).toBe(null);
147158
});
@@ -221,7 +232,7 @@ describe('dpDayPicker dayPicker', () => {
221232
it('should check that the date picker popup closes/opened after selection ', async () => {
222233
await page.dayPickerInput.click();
223234
await page.clickOnDayButton('15');
224-
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
235+
expect(await page.datePickerPopup.isPresent()).toBe(false);
225236
await page.scrollIntoView(page.noCloseOnSelect, true);
226237
await page.noCloseOnSelect.click();
227238
await page.dayPickerInput.click();
@@ -238,8 +249,8 @@ describe('dpDayPicker dayPicker', () => {
238249
expect(await page.datePickerPopup.isDisplayed()).toBe(true);
239250
await browser.sleep(200);
240251
expect(await page.datePickerPopup.isDisplayed()).toBe(true);
241-
await browser.sleep(1000);
242-
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
252+
await browser.sleep(1100);
253+
expect(await page.datePickerPopup.isPresent()).toBe(false);
243254
});
244255

245256
it('should check weekday names', async () => {

e2e/directive-e2e.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('dpDayPicker directive', () => {
1717
await page.dayDirectiveInput.click();
1818
expect(await page.datePickerPopup.isDisplayed()).toBe(true);
1919
await page.clickOnBody();
20-
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
20+
expect(await page.datePickerPopup.isPresent()).toBe(false);
2121
});
2222

2323
it('should make sure that day directive keeps the prev state of the calendar', async () => {
@@ -32,10 +32,13 @@ describe('dpDayPicker directive', () => {
3232

3333
it('should check that the theme is added and removed', async () => {
3434
await page.themeOnRadio.click();
35+
await page.dayDirectiveInput.click();
3536
expect(await page.datePickerPopup.getAttribute('class')).toContain('dp-material');
3637
await page.themeOffRadio.click();
38+
await page.dayDirectiveInput.click();
3739
expect(await page.datePickerPopup.getAttribute('class')).not.toContain('dp-material');
3840
await page.themeOnRadio.click();
41+
await page.dayDirectiveInput.click();
3942
expect(await page.datePickerPopup.getAttribute('class')).toContain('dp-material');
4043
});
4144

@@ -48,7 +51,7 @@ describe('dpDayPicker directive', () => {
4851
await browser.sleep(200);
4952
await browser.waitForAngularEnabled(false);
5053
await page.dayDirectiveInput.click();
51-
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
54+
expect(await page.datePickerPopup.isPresent()).toBe(false);
5255
await browser.waitForAngularEnabled(true);
5356
await browser.sleep(1000);
5457
expect(await page.datePickerPopup.isDisplayed()).toBe(true);

e2e/fetures/enter-keydown-e2e.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('enter keypress', () => {
1414
await page.dayPickerInput.click();
1515
expect(await page.datePickerPopup.isDisplayed()).toBe(true);
1616
page.dayPickerInput.sendKeys(protractor.Key.ENTER);
17-
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
17+
expect(await page.datePickerPopup.isPresent()).toBe(false);
1818

1919
await page.disableCloseOnEnter.click();
2020
await page.dayPickerInput.click();

e2e/fetures/number-of-month-rows-e2e.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ describe('number of month rows', () => {
1515
await page.dayCalendarNavHeaderBtn.click();
1616
expect(await page.monthRows.count()).toEqual(3);
1717

18-
await page.numOfMonthRowsToggle2.click();
18+
await page.numOfMonthRowsToggle.click();
1919
await page.dayPickerInput.click();
20+
await page.dayCalendarNavHeaderBtn.click();
2021
expect(await page.monthRows.count()).toEqual(2);
2122
});
2223

@@ -25,7 +26,7 @@ describe('number of month rows', () => {
2526
await page.monthPickerInput.click();
2627
expect(await page.monthRows.count()).toEqual(3);
2728

28-
await page.numOfMonthRowsToggle2.click();
29+
await page.numOfMonthRowsToggle.click();
2930
await page.dayPickerInput.click();
3031
expect(await page.monthRows.count()).toEqual(2);
3132
});
@@ -34,7 +35,7 @@ describe('number of month rows', () => {
3435
await page.monthInlineMenu.click();
3536
expect(await page.monthRows.count()).toEqual(3);
3637

37-
await page.numOfMonthRowsToggle2.click();
38+
await page.numOfMonthRowsToggle.click();
3839
expect(await page.monthRows.count()).toEqual(2);
3940
});
4041
});

package-lock.json

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

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"test:ci": "ng test --watch=false --browsers=ChromeHeadless",
1414
"test:ci:lib": "ng test ng2-date-picker --watch=true --browsers=ChromeHeadless",
1515
"lint": "ng lint",
16+
"lint:fix": "ng lint --fix",
1617
"e2e": "ng e2e --port 3200",
1718
"e2e:quick": "ng e2e --dev-server-target --webdriverUpdate=false",
1819
"e2e:headless": "HEADLESS=true ng e2e",
@@ -86,6 +87,7 @@
8687
"strictMetadataEmit": true
8788
},
8889
"dependencies": {
90+
"@angular/cdk": "^13.1.1",
8991
"dayjs": "^1.10.7",
9092
"tslib": "^2.3.0"
9193
}

projects/ng2-date-picker/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"peerDependencies": {
2121
"@angular/common": "^13.1.1",
2222
"@angular/core": "^13.1.1",
23+
"@angular/cdk": "^13.1.1",
2324
"dayjs": "^1.10.7"
2425
},
2526
"dependencies": {

0 commit comments

Comments
 (0)