diff --git a/docs-src/pages/UiDatepicker.vue b/docs-src/pages/UiDatepicker.vue index e6cac6b6..549ee21a 100644 --- a/docs-src/pages/UiDatepicker.vue +++ b/docs-src/pages/UiDatepicker.vue @@ -208,6 +208,30 @@ disabled placeholder="Select a date" >A Special Day + +

Daterange picker

+ + A Date Range + +

Daterange picker in a modal

+ + A Date Range + +

Daterange picker in a modal with 3 calendars

+ + A Date Range

API

@@ -228,11 +252,12 @@ modelValue, v-model * - Date, String + Date, String, Array

The model the selected date syncs to. Can be set initially for a default value.

If you are not using v-model, you should listen for the update:modelValue event and update modelValue.

+

Use an Array with 0, 1 or 2 Date values for a date range picker, where the first value is the start of the range and the last value is the end of the range.

@@ -452,6 +477,15 @@

Whether or not the datepicker is disabled. Set to true to disable the datepicker.

+ + + calendarsNumber + Number + 2 + +

The number of calendars to show when using a date range picker.

+ + @@ -651,7 +685,10 @@ export default { picker13: null, picker1301: null, picker14: null, - picker15: new Date() + picker15: new Date(), + picker16: [], + picker17: [], + picker18: [] }; }, diff --git a/src/UiCalendarControls.vue b/src/UiCalendarControls.vue index 73186793..2b2ab066 100644 --- a/src/UiCalendarControls.vue +++ b/src/UiCalendarControls.vue @@ -2,6 +2,7 @@
{{ monthAndYear }}
dateUtils.isSameDay(date, selection)) + : this.selected + ? dateUtils.isSameDay(date, this.selected) + : false; + }, + + isDateHighlighted(date) { + return Array.isArray(this.selected) && this.selected.length === 2 + ? dateUtils.isAfter(date, this.selected[0]) && dateUtils.isBefore(date, this.selected[1]) + : false; + }, + selectDate(date) { if (this.isDateDisabled(date)) { return; @@ -120,6 +135,7 @@ export default { width: math.div(100%, 7); min-width: $ui-calendar-cell-size; position: relative; + padding: 0; } } @@ -197,6 +213,11 @@ export default { } } + &.is-highlighted { + background-color: transparentize($brand-primary-color, 0.9); + color: $brand-primary-color; + } + &.is-selected, body[modality="keyboard"] &.is-selected { background-color: $brand-primary-color; @@ -215,6 +236,11 @@ export default { } } + &.is-highlighted { + background-color: transparentize($brand-accent-color, 0.5); + color: white; + } + &.is-selected, body[modality="keyboard"] &.is-selected { background-color: $brand-accent-color; diff --git a/src/UiDatepicker.vue b/src/UiDatepicker.vue index fee47ff6..973532f5 100644 --- a/src/UiDatepicker.vue +++ b/src/UiDatepicker.vue @@ -50,18 +50,35 @@ @open="onPickerOpen" > + + @@ -85,24 +102,42 @@ @open="onPickerOpen" > + + + + diff --git a/src/UiSelect.vue b/src/UiSelect.vue index 8c063083..6df01527 100644 --- a/src/UiSelect.vue +++ b/src/UiSelect.vue @@ -141,7 +141,7 @@ import UiSelectOption from "./UiSelectOption.vue"; import RespondsToExternalClick from "./mixins/RespondsToExternalClick"; import { looseIndexOf, looseEqual } from "./helpers/util"; -import { scrollIntoView, resetScroll } from "./helpers/element-scroll"; +import { resetScroll } from "./helpers/element-scroll"; import fuzzysearch from "fuzzysearch"; @@ -583,10 +583,9 @@ export default { }, scrollOptionIntoView(optionEl) { - scrollIntoView(optionEl, { - container: this.$refs.optionsList, - marginTop: 180, - }); + if (optionEl) { + optionEl.scrollIntoView({ block: "nearest" }); + } }, reset() { diff --git a/src/helpers/date.js b/src/helpers/date.js index 85041424..e5d94bb7 100644 --- a/src/helpers/date.js +++ b/src/helpers/date.js @@ -123,6 +123,11 @@ export function isSameDay(date1, date2) { date1.getDate() === date2.getDate(); } +export function isSameMonth(date1, date2) { + return date1.getFullYear() === date2.getFullYear() && + date1.getMonth() === date2.getMonth(); +} + export function isBefore(date1, date2) { return date1.getTime() < date2.getTime(); } @@ -131,6 +136,24 @@ export function isAfter(date1, date2) { return date1.getTime() > date2.getTime(); } +export function endOfDay (date) { + date = clone(date); + date.setHours(23); + date.setMinutes(59); + date.setSeconds(59); + + return date; +}; + +export function startOfDay (date) { + date = clone(date); + date.setHours(0); + date.setMinutes(0); + date.setSeconds(0); + + return date; +}; + export default { defaultLang, getDayFull, @@ -143,6 +166,9 @@ export default { clone, moveToDayOfWeek, isSameDay, + isSameMonth, + startOfDay, + endOfDay, isBefore, isAfter }; diff --git a/src/helpers/element-scroll.js b/src/helpers/element-scroll.js index b911d7da..e5b7200c 100644 --- a/src/helpers/element-scroll.js +++ b/src/helpers/element-scroll.js @@ -1,32 +1,3 @@ -export function inView(element, container) { - if (!element) { - return; - } - - container = container || element.parentElement; - - const top = element.offsetTop; - const parentTop = container.scrollTop; - const bottom = top + element.offsetHeight; - const parentBottom = container.offsetHeight; - - return top >= parentTop && bottom <= parentBottom; -} - -export function scrollIntoView(element, options = { container: null, marginTop: 0 }) { - if (!element) { - return; - } - - options.container = options.container || element.parentElement; - - if (inView(element, options.container)) { - return; - } - - options.container.scrollTop = element.offsetTop - options.marginTop; -} - export function resetScroll(element) { if (!element) { return; @@ -36,7 +7,5 @@ export function resetScroll(element) { } export default { - inView, - scrollIntoView, resetScroll }; diff --git a/src/styles/tippy/tippy.scss b/src/styles/tippy/tippy.scss index 34520970..92298ca7 100644 --- a/src/styles/tippy/tippy.scss +++ b/src/styles/tippy/tippy.scss @@ -8,7 +8,6 @@ .tippy-popper { max-height: 100%; - max-width: 100%; outline: 0; pointer-events: none; transition-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1);