diff --git a/modules/@ergonode/core/src/components/Inputs/DatePicker/Calendar/DatePickerCalendar.vue b/modules/@ergonode/core/src/components/Inputs/DatePicker/Calendar/DatePickerCalendar.vue index 1f9e474f3..e17b8acad 100644 --- a/modules/@ergonode/core/src/components/Inputs/DatePicker/Calendar/DatePickerCalendar.vue +++ b/modules/@ergonode/core/src/components/Inputs/DatePicker/Calendar/DatePickerCalendar.vue @@ -3,43 +3,20 @@ * See LICENSE for license details. */ - - diff --git a/modules/@ergonode/core/src/components/Inputs/DatePicker/DatePickerMonth.vue b/modules/@ergonode/core/src/components/Inputs/DatePicker/DatePickerMonth.vue new file mode 100644 index 000000000..1fa9cde6f --- /dev/null +++ b/modules/@ergonode/core/src/components/Inputs/DatePicker/DatePickerMonth.vue @@ -0,0 +1,117 @@ +/* + * Copyright © Bold Brand Commerce Sp. z o.o. All rights reserved. + * See LICENSE for license details. + */ + + + + + diff --git a/modules/@ergonode/core/src/components/Inputs/DatePicker/DatePickerMonths.vue b/modules/@ergonode/core/src/components/Inputs/DatePicker/DatePickerMonths.vue index 98835bd0e..ef2f9a395 100644 --- a/modules/@ergonode/core/src/components/Inputs/DatePicker/DatePickerMonths.vue +++ b/modules/@ergonode/core/src/components/Inputs/DatePicker/DatePickerMonths.vue @@ -3,59 +3,133 @@ * See LICENSE for license details. */ diff --git a/modules/@ergonode/core/src/components/Inputs/DatePicker/DatePickerNavigationHeader.vue b/modules/@ergonode/core/src/components/Inputs/DatePicker/DatePickerNavigationHeader.vue index 59eff2667..525b9df47 100644 --- a/modules/@ergonode/core/src/components/Inputs/DatePicker/DatePickerNavigationHeader.vue +++ b/modules/@ergonode/core/src/components/Inputs/DatePicker/DatePickerNavigationHeader.vue @@ -97,9 +97,10 @@ export default { color: $GRAPHITE_DARK; font: $FONT_MEDIUM_14_20; cursor: pointer; + transition: all 0.3s cubic-bezier(0.25, 0.8, 0.5, 1); &:hover { - box-shadow: $ELEVATOR_2_DP; + box-shadow: $ELEVATOR_HOVER_FOCUS; } } } diff --git a/modules/@ergonode/core/src/components/Inputs/DatePicker/DatePickerYears.vue b/modules/@ergonode/core/src/components/Inputs/DatePicker/DatePickerYears.vue index cb554c1b4..07074a15f 100644 --- a/modules/@ergonode/core/src/components/Inputs/DatePicker/DatePickerYears.vue +++ b/modules/@ergonode/core/src/components/Inputs/DatePicker/DatePickerYears.vue @@ -3,59 +3,101 @@ * See LICENSE for license details. */ diff --git a/modules/@ergonode/core/src/components/Inputs/DatePicker/DateRangePickerContent.vue b/modules/@ergonode/core/src/components/Inputs/DatePicker/DateRangePickerContent.vue index 9aaba8cd3..ec2bfd46e 100644 --- a/modules/@ergonode/core/src/components/Inputs/DatePicker/DateRangePickerContent.vue +++ b/modules/@ergonode/core/src/components/Inputs/DatePicker/DateRangePickerContent.vue @@ -4,75 +4,23 @@ */ @@ -80,10 +28,11 @@ import Fab from '@Core/components/Buttons/Fab'; import Divider from '@Core/components/Dividers/Divider'; import IconArrowSingle from '@Core/components/Icons/Arrows/IconArrowSingle'; +import DatePickerContent from '@Core/components/Inputs/DatePicker/DatePickerContent'; import DatePickerContentHeader from '@Core/components/Inputs/DatePicker/DatePickerContentHeader'; -import DatePickerDays from '@Core/components/Inputs/DatePicker/DatePickerDays'; import DatePickerHeader from '@Core/components/Inputs/DatePicker/DatePickerHeader'; import DatePickerInputHeader from '@Core/components/Inputs/DatePicker/DatePickerInputHeader'; +import DatePickerMonth from '@Core/components/Inputs/DatePicker/DatePickerMonth'; import DatePickerNavigationHeader from '@Core/components/Inputs/DatePicker/DatePickerNavigationHeader'; import { ARROW, @@ -105,8 +54,9 @@ import { export default { name: 'DateRangePickerContent', components: { + DatePickerContent, Fab, - DatePickerDays, + DatePickerMonth, DatePickerContentHeader, DatePickerNavigationHeader, IconArrowSingle, @@ -155,21 +105,6 @@ export default { weekDays() { return Object.values(WEEK_DAYS); }, - lowerBoundCalendarDates() { - return calendar(this.lowerBoundMonth, this.lowerBoundYear); - }, - upperBoundCalendarDates() { - return calendar(this.upperBoundMonth, this.upperBoundYear); - }, - parsedRange() { - return Object.keys(this.value).reduce((previous, current) => { - if (this.value[current]) { - previous.push(new Date(this.value[current])); - } - - return previous; - }, []); - }, fromHeader() { if (this.value.from) { return `From ${formatDate(this.value.from, this.format)}`; @@ -186,77 +121,32 @@ export default { }, }, methods: { - onFromHeaderValueChange(value) { - this.headerFromValue = value; - }, - onToHeaderValueChange(value) { - this.headerToValue = value; - }, - getDisplayingMonthAndYear(month, year) { - return `${this.getDisplayingMonth(month)} ${year}`; - }, - getDisplayingMonth(month) { - return Object.keys(CALENDAR_MONTHS)[Math.max(0, Math.min(month - 1, 11))]; - }, - previousMonth() { - const { - month: previousMonth, year: previousYear, - } = getPreviousMonth(this.lowerBoundMonth, this.lowerBoundYear); - - this.lowerBoundMonth = previousMonth; - this.lowerBoundYear = previousYear; - this.upperBoundMonth = this.upperBoundMonth > 1 - ? this.upperBoundMonth - 1 - : 12; - this.upperBoundYear = this.upperBoundMonth === 12 - ? this.upperBoundYear - 1 - : this.upperBoundYear; - }, - nextMonth() { - const { - month: nextMonth, year: nextYear, - } = getNextMonth(this.upperBoundMonth, this.upperBoundYear); - - this.upperBoundMonth = nextMonth; - this.upperBoundYear = nextYear; - this.lowerBoundMonth = this.lowerBoundMonth < 12 - ? this.lowerBoundMonth + 1 - : 1; - this.lowerBoundYear = this.lowerBoundMonth === 1 - ? this.lowerBoundYear + 1 - : this.lowerBoundYear; - }, onSelectRange(date) { - const to = this.value.to - ? new Date(this.value.to) - : null; - - const from = this.value.from - ? new Date(this.value.from) - : null; - - const dateToInsert = new Date(date.year, date.month - 1, date.day); + const { + from, to, + } = this.value; - if (from) { - if (+from > +dateToInsert) { - this.$emit('input', { - from: dateToInsert, - to, - }); - return; - } - } else { + if (from && to) { + this.$emit('input', { + from: date, + to: null, + }); + } else if (from && date < from) { + this.$emit('input', { + from: date, + to: null, + }); + } else if (from === null) { this.$emit('input', { - from: dateToInsert, + from: date, to, }); - return; + } else { + this.$emit('input', { + from, + to: date, + }); } - - this.$emit('input', { - from, - to: dateToInsert, - }); }, }, }; @@ -267,10 +157,6 @@ export default { display: grid; grid-auto-flow: column; - &__left, &__right { - padding: 16px; - } - .interactive-header { margin-bottom: 8px; } diff --git a/modules/@ergonode/core/src/components/Inputs/DatePicker/Node/DatePickerNode.vue b/modules/@ergonode/core/src/components/Inputs/DatePicker/Node/DatePickerNode.vue index 7e8de86e6..1c500683e 100644 --- a/modules/@ergonode/core/src/components/Inputs/DatePicker/Node/DatePickerNode.vue +++ b/modules/@ergonode/core/src/components/Inputs/DatePicker/Node/DatePickerNode.vue @@ -5,7 +5,9 @@ diff --git a/modules/@ergonode/core/src/models/calendar/calendar.js b/modules/@ergonode/core/src/models/calendar/calendar.js index b16976d80..acb444600 100644 --- a/modules/@ergonode/core/src/models/calendar/calendar.js +++ b/modules/@ergonode/core/src/models/calendar/calendar.js @@ -69,6 +69,24 @@ export const isDate = (date) => { return isDateObject && isValidDate; }; +export const getParsedDate = (date) => { + if (!date) return null; + + const day = date.getDate(); + const month = date.getMonth() + 1; + const year = date.getFullYear(); + + return { + day, + month, + year, + }; +}; + +export const isEqual = (date, withDate) => date.day === withDate.day + && date.month === withDate.month + && date.year === withDate.year; + export const getMonthIndex = (monthDesc) => { const monthDescriptions = Object.values(CALENDAR_MONTHS);