A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/bootstrap-vue/bootstrap-vue/commit/1d957ebd78a8693e91a8116d12c28fe24bd7c19c below:

add new `initial-date` prop, and … · bootstrap-vue/bootstrap-vue@1d957eb · GitHub

@@ -7,6 +7,7 @@ import { getComponentConfig } from '../../utils/config'

7 7

import {

8 8

createDate,

9 9

createDateFormatter,

10 +

constrainDate,

10 11

datesEqual,

11 12

firstDateOfMonth,

12 13

formatYMD,

@@ -58,6 +59,13 @@ export const BCalendar = Vue.extend({

58 59

type: Boolean,

59 60

default: false

60 61

},

62 +

initialDate: {

63 +

// This specifies the calendar year/month/day that will be shown when

64 +

// first opening the datepicker if no v-model value is provided

65 +

// Default is the current date (or `min`/`max`)

66 +

type: [String, Date],

67 +

default: null

68 +

},

61 69

disabled: {

62 70

type: Boolean,

63 71

default: false

@@ -212,7 +220,9 @@ export const BCalendar = Vue.extend({

212 220

// Selected date

213 221

selectedYMD: selected,

214 222

// Date in calendar grid that has `tabindex` of `0`

215 -

activeYMD: selected || formatYMD(this.getToday()),

223 +

activeYMD:

224 +

selected ||

225 +

formatYMD(constrainDate(this.initialDate || this.getToday()), this.min, this.max),

216 226

// Will be true if the calendar grid has/contains focus

217 227

gridHasFocus: false,

218 228

// Flag to enable the `aria-live` region(s) after mount

@@ -361,6 +371,7 @@ export const BCalendar = Vue.extend({

361 371

// Merge in user supplied options

362 372

...this.dateFormatOptions,

363 373

// Ensure hours/minutes/seconds are not shown

374 +

// As we do not support the time portion (yet)

364 375

hour: undefined,

365 376

minute: undefined,

366 377

second: undefined,

@@ -487,7 +498,9 @@ export const BCalendar = Vue.extend({

487 498

},

488 499

hidden(newVal) {

489 500

// Reset the active focused day when hidden

490 -

this.activeYMD = this.selectedYMD || formatYMD(this.value) || formatYMD(this.getToday())

501 +

this.activeYMD =

502 +

this.selectedYMD ||

503 +

formatYMD(this.value || this.constrainDate(this.initialDate || this.getToday()))

491 504

// Enable/disable the live regions

492 505

this.setLive(!newVal)

493 506

}

@@ -541,10 +554,7 @@ export const BCalendar = Vue.extend({

541 554

constrainDate(date) {

542 555

// Constrains a date between min and max

543 556

// returns a new `Date` object instance

544 -

date = parseYMD(date)

545 -

const min = this.computedMin || date

546 -

const max = this.computedMax || date

547 -

return createDate(date < min ? min : date > max ? max : date)

557 +

return constrainDate(date, this.computedMin, this.computedMax)

548 558

},

549 559

emitSelected(date) {

550 560

// Performed in a `$nextTick()` to (probably) ensure

@@ -573,6 +583,7 @@ export const BCalendar = Vue.extend({

573 583

let activeDate = createDate(this.activeDate)

574 584

let checkDate = createDate(this.activeDate)

575 585

const day = activeDate.getDate()

586 +

const constrainedToday = this.constrainDate(this.getToday())

576 587

const isRTL = this.isRTL

577 588

if (keyCode === PAGEUP) {

578 589

// PAGEUP - Previous month/year

@@ -605,11 +616,11 @@ export const BCalendar = Vue.extend({

605 616

checkDate = activeDate

606 617

} else if (keyCode === HOME) {

607 618

// HOME - Today

608 -

activeDate = this.getToday()

619 +

activeDate = constrainedToday

609 620

checkDate = activeDate

610 621

} else if (keyCode === END) {

611 622

// END - Selected date, or today if no selected date

612 -

activeDate = parseYMD(this.selectedDate) || this.getToday()

623 +

activeDate = parseYMD(this.selectedDate) || constrainedToday

613 624

checkDate = activeDate

614 625

}

615 626

if (!this.dateOutOfRange(checkDate) && !datesEqual(activeDate, this.activeDate)) {

@@ -664,7 +675,7 @@ export const BCalendar = Vue.extend({

664 675

},

665 676

gotoCurrentMonth() {

666 677

// TODO: Maybe this goto date should be configurable?

667 -

this.activeYMD = formatYMD(this.getToday())

678 +

this.activeYMD = formatYMD(this.constrainDate(this.getToday()))

668 679

},

669 680

gotoNextMonth() {

670 681

this.activeYMD = formatYMD(this.constrainDate(oneMonthAhead(this.activeDate)))

@@ -694,7 +705,7 @@ export const BCalendar = Vue.extend({

694 705

// Flag for making the `aria-live` regions live

695 706

const isLive = this.isLive

696 707

// Pre-compute some IDs

697 -

// Thes should be computed props

708 +

// This should be computed props

698 709

const idValue = safeId()

699 710

const idWidget = safeId('_calendar-wrapper_')

700 711

const idNav = safeId('_calendar-nav_')


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4