From 109ed0b9e67a56805468eb49987a40f77e5de62a Mon Sep 17 00:00:00 2001 From: dilandoogan <147757889+dilandoogan@users.noreply.github.com> Date: Mon, 6 Jan 2025 10:25:14 +0300 Subject: [PATCH 1/4] feat(calendar-component): fix calendar component test case (#977) --- src/components/calendar/bl-calendar.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/calendar/bl-calendar.test.ts b/src/components/calendar/bl-calendar.test.ts index b5b91266..21d2af71 100644 --- a/src/components/calendar/bl-calendar.test.ts +++ b/src/components/calendar/bl-calendar.test.ts @@ -534,7 +534,7 @@ describe("bl-calendar", () => { const setNextCalendarViewSpy = sinon.spy(element, "setNextCalendarView"); - element.handleDate(new Date(2024, 2, 15)); + element.handleDate(new Date(element.today.getFullYear()+1,2,15)); expect(setNextCalendarViewSpy).to.have.been.called; From cda4b34f58a71eaa39d5d90a8c316c98f564fa31 Mon Sep 17 00:00:00 2001 From: dilandoogan <147757889+dilandoogan@users.noreply.github.com> Date: Mon, 6 Jan 2025 14:26:28 +0300 Subject: [PATCH 2/4] feat(datepicker): fix disabled dates type (#979) --- .../datepicker-calendar-mixin/datepicker-calendar-mixin.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mixins/datepicker-calendar-mixin/datepicker-calendar-mixin.ts b/src/mixins/datepicker-calendar-mixin/datepicker-calendar-mixin.ts index eeff8460..f7dc5e1b 100644 --- a/src/mixins/datepicker-calendar-mixin/datepicker-calendar-mixin.ts +++ b/src/mixins/datepicker-calendar-mixin/datepicker-calendar-mixin.ts @@ -34,7 +34,6 @@ export default class DatepickerCalendarMixin extends LitElement { @property({ attribute: "disabled-dates", - type: Array, reflect: true, }) set disabledDates(disabledDates: Date[] | string) { From 004e7696158381e6f8bcb4346a0d68d9e0880c00 Mon Sep 17 00:00:00 2001 From: dilandoogan <147757889+dilandoogan@users.noreply.github.com> Date: Tue, 7 Jan 2025 14:59:26 +0300 Subject: [PATCH 3/4] feat(datepicker): fix clear dates event bug (#982) --- src/components/datepicker/bl-datepicker.test.ts | 9 +++++++++ src/components/datepicker/bl-datepicker.ts | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/datepicker/bl-datepicker.test.ts b/src/components/datepicker/bl-datepicker.test.ts index 36a52247..9e0c6528 100644 --- a/src/components/datepicker/bl-datepicker.test.ts +++ b/src/components/datepicker/bl-datepicker.test.ts @@ -95,11 +95,20 @@ describe("BlDatepicker", () => { element._selectedDates = [new Date(2023, 1, 1)]; await element.updateComplete; + element.addEventListener("bl-datepicker-change", (event) => { + const customEvent = event as CustomEvent; + + expect(customEvent).to.exist; + expect(customEvent.detail).to.deep.equal([]); + + }); + const clearButton = element.shadowRoot?.querySelector("bl-button") as BlButton; clearButton?.click(); await element.updateComplete; + expect(element._selectedDates).to.deep.equal([]); expect(element._inputValue).to.equal(""); }); diff --git a/src/components/datepicker/bl-datepicker.ts b/src/components/datepicker/bl-datepicker.ts index b77eabbe..b3f8942a 100644 --- a/src/components/datepicker/bl-datepicker.ts +++ b/src/components/datepicker/bl-datepicker.ts @@ -147,10 +147,10 @@ export default class BlDatepicker extends DatepickerCalendarMixin { } clearDatepicker() { - this._calendarEl.handleClearSelectedDates(); this._selectedDates = []; this._inputValue = ""; this._floatingDateCount = 0; + this._calendarEl.handleClearSelectedDates(); } openPopover() { @@ -242,7 +242,7 @@ export default class BlDatepicker extends DatepickerCalendarMixin { variant="tertiary" kind="neutral" icon="close" - @click=${() => this.clearDatepicker()} + @click=${this.clearDatepicker} >
` : ""; From 33dd9a42b575e97de81456fc4e5980e8cd7f5bd3 Mon Sep 17 00:00:00 2001 From: dilandoogan <147757889+dilandoogan@users.noreply.github.com> Date: Wed, 8 Jan 2025 12:05:59 +0300 Subject: [PATCH 4/4] =?UTF-8?q?feat(datepicker):=20when=20datepicker=20val?= =?UTF-8?q?ue=20updated=20datepicker=20input=20valu=E2=80=A6=20(#983)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …e should also updated --- src/components/datepicker/bl-datepicker.test.ts | 11 ++++++++++- src/components/datepicker/bl-datepicker.ts | 8 +++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/components/datepicker/bl-datepicker.test.ts b/src/components/datepicker/bl-datepicker.test.ts index 9e0c6528..136480e4 100644 --- a/src/components/datepicker/bl-datepicker.test.ts +++ b/src/components/datepicker/bl-datepicker.test.ts @@ -1,4 +1,4 @@ -import { aTimeout, expect, fixture, html } from "@open-wc/testing"; +import { aTimeout, elementUpdated, expect, fixture, html } from "@open-wc/testing"; import { BlButton, BlDatePicker } from "../../baklava"; import { CALENDAR_TYPES } from "../calendar/bl-calendar.constant"; import sinon from "sinon"; @@ -385,4 +385,13 @@ describe("BlDatepicker", () => { expect(focusSpy.called).to.be.true; }); + it("should call setDatePickerInput when _selectedDates changes", async () => { + const setDatePickerInputSpy = sinon.spy(element, "setDatePickerInput"); + + element.value = [new Date(2025,0,10)]; + await elementUpdated(element); + + expect(setDatePickerInputSpy).to.have.been.calledOnceWith(element._selectedDates); + }); + }); diff --git a/src/components/datepicker/bl-datepicker.ts b/src/components/datepicker/bl-datepicker.ts index b3f8942a..9632f610 100644 --- a/src/components/datepicker/bl-datepicker.ts +++ b/src/components/datepicker/bl-datepicker.ts @@ -1,4 +1,4 @@ -import { CSSResultGroup, html, TemplateResult } from "lit"; +import { CSSResultGroup, html, PropertyValues, TemplateResult } from "lit"; import { customElement, property, query, state } from "lit/decorators.js"; import { BlCalendar, BlPopover } from "../../baklava"; import DatepickerCalendarMixin from "../../mixins/datepicker-calendar-mixin/datepicker-calendar-mixin"; @@ -197,6 +197,12 @@ export default class BlDatepicker extends DatepickerCalendarMixin { } } + updated(changedProperties: PropertyValues) { + if (changedProperties.has("_selectedDates")) { + this.setDatePickerInput(this._selectedDates); + } + } + disconnectedCallback() { super.disconnectedCallback(); this._calendarEl?.removeEventListener("mousedown", this._onCalendarMouseDown);