Skip to content
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

ISCT-98: fix datepicker v1 #250

Merged
merged 6 commits into from
Nov 5, 2023
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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.

### [6.2.1](https://github.com/ironSource/fusion-ui/compare/v6.2.1-rc.1...v6.2.1) (2023-11-05)

### [6.2.1-rc.1](https://github.com/ironSource/fusion-ui/compare/v6.2.1-rc.0...v6.2.1-rc.1) (2023-11-02)

### [6.2.1-rc.0](https://github.com/ironSource/fusion-ui/compare/v6.2.0...v6.2.1-rc.0) (2023-11-02)


### Bug Fixes

* **isct-98:** fix datepicker v1 ([4d0bec0](https://github.com/ironSource/fusion-ui/commit/4d0bec00d49c4dd71fc681e6ad11b1ecea2e6696))

## [6.2.0](https://github.com/ironSource/fusion-ui/compare/v6.2.0-rc.0...v6.2.0) (2023-10-30)

## [6.2.0-rc.0](https://github.com/ironSource/fusion-ui/compare/v6.1.1...v6.2.0-rc.0) (2023-10-16)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fusion-ui",
"version": "6.2.0",
"version": "6.2.1",
"description": "UI library created by ironSource",
"license": "MIT",
"repository": {
Expand Down

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

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

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

14 changes: 8 additions & 6 deletions projects/fusion-docs/src/app/pages/docs/docs.component.html

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

20 changes: 10 additions & 10 deletions projects/fusion-docs/src/app/pages/docs/docs.module.ts

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

Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class DatepickerComponent implements OnInit, OnDestroy, OnChanges, AfterV
@Input() set isOpened(value: boolean) {
this.isOpen$.next(!isNullOrUndefined(value) ? value : false);
}

@Input() isTimePicker = false;
@Input() isTimeZonePicker = false;
@Input() isDisabled = false;
Expand Down Expand Up @@ -115,8 +116,8 @@ export class DatepickerComponent implements OnInit, OnDestroy, OnChanges, AfterV
ngOnChanges(changes) {
if (
this.selectedDate &&
((changes.minDate && changes.minDate.currentValue !== changes.minDate.previousValue) ||
(changes.maxDate && changes.maxDate.currentValue !== changes.maxDate.previousValue))
(!this.isDatesEqual(changes?.minDate?.currentValue, changes?.minDate?.previousValue, 'day') ||
!this.isDatesEqual(changes?.maxDate?.currentValue, changes?.maxDate?.previousValue, 'day'))
) {
this.setWeeks(this.selectedDate.date ? this.selectedDate.date : this.today);
}
Expand Down Expand Up @@ -313,14 +314,22 @@ export class DatepickerComponent implements OnInit, OnDestroy, OnChanges, AfterV
}

private isDatesEqual(dateA: Date, dateB: Date, granularity: 'month' | 'day'): boolean {
dateA = new Date(dateA);
dateB = new Date(dateB);
dateA.setHours(0, 0, 0, 0);
dateB.setHours(0, 0, 0, 0);
if (granularity === 'day') {
return dateA.getTime() === dateB.getTime();
} else if (granularity === 'month') {
return new Date(dateA.getFullYear(), dateA.getMonth()).getTime() === new Date(dateB.getFullYear(), dateB.getMonth()).getTime();
if (isDate(dateA) && isDate(dateB)) {
dateA = new Date(dateA);
dateB = new Date(dateB);
dateA.setHours(0, 0, 0, 0);
dateB.setHours(0, 0, 0, 0);
if (granularity === 'day') {
return dateA.getTime() === dateB.getTime();
} else if (granularity === 'month') {
return (
new Date(dateA.getFullYear(), dateA.getMonth()).getTime() === new Date(dateB.getFullYear(), dateB.getMonth()).getTime()
);
}
} else if ((!isDate(dateA) && isDate(dateB)) || (isDate(dateA) && !isDate(dateB))) {
return false;
} else {
return true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion projects/fusion-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironsource/fusion-ui",
"version": "6.2.0",
"version": "6.2.1",
"dependencies": {
"chart.js": "^3.5.1",
"@floating-ui/dom": "^1.0.9",
Expand Down
2 changes: 1 addition & 1 deletion projects/fusion-ui/utils/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function isRegExp(object: any) {
}

export function isDate(object: any): boolean {
return object instanceof Date;
return object instanceof Date && isFinite(+object);
}

export function isError(object: any): boolean {
Expand Down