From b46fb260d36c27871d0936658e5948ca64c97e52 Mon Sep 17 00:00:00 2001 From: Dan Popescu Date: Mon, 31 Jan 2022 15:12:23 +0200 Subject: [PATCH] feat(QDate): Improve range selection; add day slot for content; fix small years; fix subtractFromDate/addToDate incorrect end of month day #5434, #7076, #7290, #8037, #8658, #8918, #8926, #9704, #9704, #12270, #11730, #12783 - add modelNavigation prop - add range-change event - fix cached function when changing from persian to gregorian calendars - fix viewModel as text - add more examples - fix processing of years between 0 and 99 - fix subtractFromDate/addToDate incorrect end of month day - start a new range selection if noUnset and selected date is in existing range --- docs/src/examples/QDate/DaySlot.vue | 111 ++++ docs/src/examples/QDate/Input.vue | 8 +- docs/src/examples/QDate/IntervalSelection.vue | 124 ++++ .../QDate/IntervalSelectionConstrained.vue | 167 ++++++ docs/src/examples/QDate/WeekSelection.vue | 39 ++ docs/src/examples/QTime/Input.vue | 6 +- docs/src/pages/quasar-utils/date-utils.md | 2 +- docs/src/pages/vue-components/date.md | 20 +- ui/dev/src/pages/form/date-day-slot.vue | 111 ++++ .../date-interval-selection-constrained.vue | 167 ++++++ .../pages/form/date-interval-selection.vue | 124 ++++ ui/dev/src/pages/form/date-part1-basic.vue | 125 +++- .../pages/form/date-part2-multiple-range.vue | 7 +- ui/dev/src/pages/form/date-week-selection.vue | 94 +++ ui/dev/src/pages/other/date-utils.vue | 37 +- ui/src/components/date/QDate.js | 536 ++++++++++-------- ui/src/components/date/QDate.json | 201 +++++++ ui/src/components/date/QDate.sass | 17 +- ui/src/components/date/QDate.styl | 17 +- ui/src/components/time/QTime.js | 4 +- ui/src/utils/date.js | 364 ++++++------ ui/types/utils/date.d.ts | 3 +- 22 files changed, 1834 insertions(+), 450 deletions(-) create mode 100644 docs/src/examples/QDate/DaySlot.vue create mode 100644 docs/src/examples/QDate/IntervalSelection.vue create mode 100644 docs/src/examples/QDate/IntervalSelectionConstrained.vue create mode 100644 docs/src/examples/QDate/WeekSelection.vue create mode 100644 ui/dev/src/pages/form/date-day-slot.vue create mode 100644 ui/dev/src/pages/form/date-interval-selection-constrained.vue create mode 100644 ui/dev/src/pages/form/date-interval-selection.vue create mode 100644 ui/dev/src/pages/form/date-week-selection.vue diff --git a/docs/src/examples/QDate/DaySlot.vue b/docs/src/examples/QDate/DaySlot.vue new file mode 100644 index 000000000000..612a116e584f --- /dev/null +++ b/docs/src/examples/QDate/DaySlot.vue @@ -0,0 +1,111 @@ + + + + + diff --git a/docs/src/examples/QDate/Input.vue b/docs/src/examples/QDate/Input.vue index 9c12a7bea395..0b0b6376af9e 100644 --- a/docs/src/examples/QDate/Input.vue +++ b/docs/src/examples/QDate/Input.vue @@ -3,12 +3,8 @@ diff --git a/docs/src/examples/QDate/IntervalSelection.vue b/docs/src/examples/QDate/IntervalSelection.vue new file mode 100644 index 000000000000..04df2cde474e --- /dev/null +++ b/docs/src/examples/QDate/IntervalSelection.vue @@ -0,0 +1,124 @@ + + + diff --git a/docs/src/examples/QDate/IntervalSelectionConstrained.vue b/docs/src/examples/QDate/IntervalSelectionConstrained.vue new file mode 100644 index 000000000000..f137e7125cbb --- /dev/null +++ b/docs/src/examples/QDate/IntervalSelectionConstrained.vue @@ -0,0 +1,167 @@ + + + diff --git a/docs/src/examples/QDate/WeekSelection.vue b/docs/src/examples/QDate/WeekSelection.vue new file mode 100644 index 000000000000..fe1ac04e44f1 --- /dev/null +++ b/docs/src/examples/QDate/WeekSelection.vue @@ -0,0 +1,39 @@ + + + diff --git a/docs/src/examples/QTime/Input.vue b/docs/src/examples/QTime/Input.vue index 056567f0c199..593819c6f673 100644 --- a/docs/src/examples/QTime/Input.vue +++ b/docs/src/examples/QTime/Input.vue @@ -23,11 +23,7 @@ v-model="timeWithSeconds" with-seconds format24h - > -
- -
- + /> diff --git a/docs/src/pages/quasar-utils/date-utils.md b/docs/src/pages/quasar-utils/date-utils.md index ae203cb4ba86..19f107b96a2a 100644 --- a/docs/src/pages/quasar-utils/date-utils.md +++ b/docs/src/pages/quasar-utils/date-utils.md @@ -308,7 +308,7 @@ const newDate = new Date(2017, 1, 4) const day = date.getDayOfYear(newDate) // `day` is 35 ``` -To get the day number in week for a given date object use: +To get the day number in week for a given date object use (1-based, starting with firstDayOfWeek from locale): ```js import { date } from 'quasar' diff --git a/docs/src/pages/vue-components/date.md b/docs/src/pages/vue-components/date.md index 794d1fae1ca1..720947504e82 100644 --- a/docs/src/pages/vue-components/date.md +++ b/docs/src/pages/vue-components/date.md @@ -47,7 +47,7 @@ Notice in the examples below that the model is an Object (single selection) or a ::: tip TIPS * Clicking on an already selected day will deselect it. * The user's current editing range can also be set programmatic through the `setEditingRange` method (check the API card). -* There are two useful events in regards to the current editing range: `range-start` and `range-end` (check the API card). +* There are three useful events in regards to the current editing range: `range-start`, `range-change` and `range-end` (check the API card). ::: ::: warning @@ -58,6 +58,18 @@ The `range` property is only partially compatible with the `options` prop: selec +* Use 2 components to allow easy interval selection + + + +* Adjust the selection to match a fixed interval + + + +* Limit the minimum and maximum selection length + + + ### Custom title and subtitle When not in 'minimal' mode, QDate has a computed header title and subtitle. You can override it, like in the example below. @@ -134,6 +146,12 @@ The first example is using an array and the second example is using a function. +### Day scoped slot + +You can use the `day` scoped slot to render custom event markers or tooltips specific to each day. + + + ### Limiting options * You can use the `options` prop to limit user selection to certain times. diff --git a/ui/dev/src/pages/form/date-day-slot.vue b/ui/dev/src/pages/form/date-day-slot.vue new file mode 100644 index 000000000000..bf6c7f7fc7b0 --- /dev/null +++ b/ui/dev/src/pages/form/date-day-slot.vue @@ -0,0 +1,111 @@ + + + + + diff --git a/ui/dev/src/pages/form/date-interval-selection-constrained.vue b/ui/dev/src/pages/form/date-interval-selection-constrained.vue new file mode 100644 index 000000000000..f137e7125cbb --- /dev/null +++ b/ui/dev/src/pages/form/date-interval-selection-constrained.vue @@ -0,0 +1,167 @@ + + + diff --git a/ui/dev/src/pages/form/date-interval-selection.vue b/ui/dev/src/pages/form/date-interval-selection.vue new file mode 100644 index 000000000000..04df2cde474e --- /dev/null +++ b/ui/dev/src/pages/form/date-interval-selection.vue @@ -0,0 +1,124 @@ + + + diff --git a/ui/dev/src/pages/form/date-part1-basic.vue b/ui/dev/src/pages/form/date-part1-basic.vue index b93b709315ad..26d5881ee4ca 100644 --- a/ui/dev/src/pages/form/date-part1-basic.vue +++ b/ui/dev/src/pages/form/date-part1-basic.vue @@ -22,8 +22,8 @@ :style="style" @input="inputLog" flat bordered - navigation-min-year-month="2018/05" - navigation-max-year-month="2019/03" + :navigation-min-year-month="navigationMinYM" + :navigation-max-year-month="navigationMaxYM" >
@@ -135,25 +135,61 @@
- Limited options + Day slot
+ + +
+ +
+ Limited options +
+
+ @@ -335,6 +370,43 @@
+ + diff --git a/ui/dev/src/pages/other/date-utils.vue b/ui/dev/src/pages/other/date-utils.vue index 9f2b705f0275..0dfd9526f867 100644 --- a/ui/dev/src/pages/other/date-utils.vue +++ b/ui/dev/src/pages/other/date-utils.vue @@ -1,34 +1,35 @@