Skip to content

introducing cdk #576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Dec 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@
"error"
]
}
],
"no-debugger": [
"error"
],
"quotes": [
"error",
"single",
{
"allowTemplateLiterals": true
}
]
}
},
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ All notable changes to this project will be documented in this file.
- Working with RTL ([575](https://github.com/vlio20/angular-datepicker/pull/575)) closes [#504](https://github.com/vlio20/angular-datepicker/issues/504)

# Breaking changes
- Replace deprecated `Moment` with Dayjs ([573](https://github.com/vlio20/angular-datepicker/pull/573)) closes [#530](https://github.com/vlio20/angular-datepicker/issues/530)
- Replace deprecated `Moment` with Dayjs ([573](https://github.com/vlio20/angular-datepicker/pull/573)) closes [#530](https://github.com/vlio20/angular-datepicker/issues/530)
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.
Some formats also might be change due to the way Dayjs is implemented.
- 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 )
This removal will drop the `attachTo` option from the library configuration.
*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.


# [13.0.0] (2021-12-22)

Expand Down
122 changes: 68 additions & 54 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion e2e/app.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class DemoPage {
meridiemDisplayInline = $(`.dp-inline .dp-time-select-display-meridiem`);
timeSeparatorDisplay = $(`${this.popupSelector} .dp-time-select-separator:nth-child(2)`);
monthRows = $$('.dp-months-row');
numOfMonthRowsToggle2 = $('#numOfMonthRows2');
numOfMonthRowsToggle = $('#numOfMonthRows2');

daytimePickerMenu = $('#daytimePickerMenu');
daytimeInlineMenu = $('#daytimeInlineMenu');
Expand Down
6 changes: 3 additions & 3 deletions e2e/bugs/debounce-open-e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('debounce open delay', () => {
await page.dayPickerInput.click();
await browser.waitForAngularEnabled(false);
await browser.sleep(500);
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
expect(await page.datePickerPopup.isPresent()).toBe(false);
await browser.sleep(600);
await browser.waitForAngularEnabled(true);
expect(await page.datePickerPopup.isDisplayed()).toBe(true);
Expand All @@ -25,10 +25,10 @@ describe('debounce open delay', () => {
await page.dayPickerInput.click();
await browser.waitForAngularEnabled(false);
await browser.sleep(500);
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
expect(await page.datePickerPopup.isPresent()).toBe(false);
await page.clickOnBody();
await browser.sleep(600);
await browser.waitForAngularEnabled(true);
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
expect(await page.datePickerPopup.isPresent()).toBe(false);
});
});
2 changes: 1 addition & 1 deletion e2e/configuration-e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('dpDayPicker configuration', () => {
await page.openOnClickRadioOff.click();
await page.openOnFocusRadioOff.click();
await page.daytimePickerInput.click();
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
expect(await page.datePickerPopup.isPresent()).toBe(false);
});

it('openOnClick = true, should open picker when clicked', async () => {
Expand Down
27 changes: 19 additions & 8 deletions e2e/datepicker-e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('dpDayPicker dayPicker', () => {
await page.dayPickerInput.click();
expect(await page.datePickerPopup.isDisplayed()).toBe(true);
await page.clickOnBody();
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
expect(await page.datePickerPopup.isPresent()).toBe(false);

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

it('should check that the theme is added and removed', async () => {
await page.themeOnRadio.click();
await page.dayPickerInput.click();
expect(await page.datePickerPopup.getAttribute('class')).toContain('dp-material');
await page.themeOffRadio.click();
await page.dayPickerInput.click();
expect(await page.datePickerPopup.getAttribute('class')).not.toContain('dp-material');
await page.themeOnRadio.click();
await page.dayPickerInput.click();
expect(await page.datePickerPopup.getAttribute('class')).toContain('dp-material');
});

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

await page.scrollIntoView(page.onOpenDelayInput, true);
await page.setInputValue(page.onOpenDelayInput, '1000');
Expand All @@ -45,7 +48,7 @@ describe('dpDayPicker dayPicker', () => {
await browser.waitForAngularEnabled(false);
await page.scrollIntoView(page.dayPickerInput, true);
await page.dayPickerInput.click();
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
expect(await page.datePickerPopup.isPresent()).toBe(false);
await browser.waitForAngularEnabled(true);
browser.sleep(1000);
expect(await page.datePickerPopup.isDisplayed()).toBe(true);
Expand Down Expand Up @@ -79,11 +82,19 @@ describe('dpDayPicker dayPicker', () => {
expect(await page.weekNumbers.getText()).toEqual(['8', '9', '10', '11', '12', '13']);
});

it('should remember last position', async () => {
await page.setInputValue(page.dayPickerInput, '28-03-2017');
await page.dayPickerInput.click();
expect(await page.dayCalendarNavHeaderBtn.getText()).toEqual('Mar, 2017');
await page.currentLocationBtn.click();
expect(await page.dayCalendarNavHeaderBtn.getText()).toEqual(dayjs().format('MMM, YYYY'));
});

it('should hide calendar on tab (blur)', async () => {
await page.dayPickerInput.click();
expect(await page.datePickerPopup.isDisplayed()).toBe(true);
await page.dayPickerInput.sendKeys(protractor.Key.TAB);
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
expect(await page.datePickerPopup.isPresent()).toBe(false);
});

it('should disable/enable month selection', async () => {
Expand Down Expand Up @@ -141,7 +152,7 @@ describe('dpDayPicker dayPicker', () => {
await page.pickerDisabledRadio.click();
expect(await page.dayPickerInput.getAttribute('disabled')).toEqual('true');
await page.dayPickerInput.click();
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
expect(await page.datePickerPopup.isPresent()).toBe(false);
await page.pickerEnabledRadio.click();
expect(await page.dayPickerInput.getAttribute('disabled')).toBe(null);
});
Expand Down Expand Up @@ -221,7 +232,7 @@ describe('dpDayPicker dayPicker', () => {
it('should check that the date picker popup closes/opened after selection ', async () => {
await page.dayPickerInput.click();
await page.clickOnDayButton('15');
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
expect(await page.datePickerPopup.isPresent()).toBe(false);
await page.scrollIntoView(page.noCloseOnSelect, true);
await page.noCloseOnSelect.click();
await page.dayPickerInput.click();
Expand All @@ -238,8 +249,8 @@ describe('dpDayPicker dayPicker', () => {
expect(await page.datePickerPopup.isDisplayed()).toBe(true);
await browser.sleep(200);
expect(await page.datePickerPopup.isDisplayed()).toBe(true);
await browser.sleep(1000);
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
await browser.sleep(1100);
expect(await page.datePickerPopup.isPresent()).toBe(false);
});

it('should check weekday names', async () => {
Expand Down
7 changes: 5 additions & 2 deletions e2e/directive-e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('dpDayPicker directive', () => {
await page.dayDirectiveInput.click();
expect(await page.datePickerPopup.isDisplayed()).toBe(true);
await page.clickOnBody();
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
expect(await page.datePickerPopup.isPresent()).toBe(false);
});

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

it('should check that the theme is added and removed', async () => {
await page.themeOnRadio.click();
await page.dayDirectiveInput.click();
expect(await page.datePickerPopup.getAttribute('class')).toContain('dp-material');
await page.themeOffRadio.click();
await page.dayDirectiveInput.click();
expect(await page.datePickerPopup.getAttribute('class')).not.toContain('dp-material');
await page.themeOnRadio.click();
await page.dayDirectiveInput.click();
expect(await page.datePickerPopup.getAttribute('class')).toContain('dp-material');
});

Expand All @@ -48,7 +51,7 @@ describe('dpDayPicker directive', () => {
await browser.sleep(200);
await browser.waitForAngularEnabled(false);
await page.dayDirectiveInput.click();
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
expect(await page.datePickerPopup.isPresent()).toBe(false);
await browser.waitForAngularEnabled(true);
await browser.sleep(1000);
expect(await page.datePickerPopup.isDisplayed()).toBe(true);
Expand Down
2 changes: 1 addition & 1 deletion e2e/fetures/enter-keydown-e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('enter keypress', () => {
await page.dayPickerInput.click();
expect(await page.datePickerPopup.isDisplayed()).toBe(true);
page.dayPickerInput.sendKeys(protractor.Key.ENTER);
expect(await page.datePickerPopup.isDisplayed()).toBe(false);
expect(await page.datePickerPopup.isPresent()).toBe(false);

await page.disableCloseOnEnter.click();
await page.dayPickerInput.click();
Expand Down
7 changes: 4 additions & 3 deletions e2e/fetures/number-of-month-rows-e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ describe('number of month rows', () => {
await page.dayCalendarNavHeaderBtn.click();
expect(await page.monthRows.count()).toEqual(3);

await page.numOfMonthRowsToggle2.click();
await page.numOfMonthRowsToggle.click();
await page.dayPickerInput.click();
await page.dayCalendarNavHeaderBtn.click();
expect(await page.monthRows.count()).toEqual(2);
});

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

await page.numOfMonthRowsToggle2.click();
await page.numOfMonthRowsToggle.click();
await page.dayPickerInput.click();
expect(await page.monthRows.count()).toEqual(2);
});
Expand All @@ -34,7 +35,7 @@ describe('number of month rows', () => {
await page.monthInlineMenu.click();
expect(await page.monthRows.count()).toEqual(3);

await page.numOfMonthRowsToggle2.click();
await page.numOfMonthRowsToggle.click();
expect(await page.monthRows.count()).toEqual(2);
});
});
40 changes: 40 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"test:ci": "ng test --watch=false --browsers=ChromeHeadless",
"test:ci:lib": "ng test ng2-date-picker --watch=true --browsers=ChromeHeadless",
"lint": "ng lint",
"lint:fix": "ng lint --fix",
"e2e": "ng e2e --port 3200",
"e2e:quick": "ng e2e --dev-server-target --webdriverUpdate=false",
"e2e:headless": "HEADLESS=true ng e2e",
Expand Down Expand Up @@ -86,6 +87,7 @@
"strictMetadataEmit": true
},
"dependencies": {
"@angular/cdk": "^13.1.1",
"dayjs": "^1.10.7",
"tslib": "^2.3.0"
}
Expand Down
1 change: 1 addition & 0 deletions projects/ng2-date-picker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"peerDependencies": {
"@angular/common": "^13.1.1",
"@angular/core": "^13.1.1",
"@angular/cdk": "^13.1.1",
"dayjs": "^1.10.7"
},
"dependencies": {
Expand Down
Loading