Giter Club home page Giter Club logo

vue-hotel-datepicker's Introduction

Code Climate Issue Count dependencies Status devDependencies Status npm Build Status

vue-hotel-datepicker

A responsive date range picker for Vue.js that displays the number of nights selected and allow several useful options like custom check-in/check-out rules, localisation support and more.

demo gif

Demo

https://krystalcampioni.github.io/vue-hotel-datepicker/

Installation

NPM

Install the package:

npm install vue-hotel-datepicker --save
import HotelDatePicker from 'vue-hotel-datepicker'

export default {
  components: {
    HotelDatePicker,
  },
}
<HotelDatePicker />

Props/Options

format

  • Type: String
  • Default: YYYY-MM-DD

The date format string.

startDate

  • Type: Date or String
  • Default: new Date()

The start view date. All the dates before this date will be disabled.

endDate

  • Type: Date or String or Boolean
  • Default: false

The end view date. All the dates after this date will be disabled.

initialCheckIn

  • Type: Date
  • Default: null

The initial check-in date (as if the user selected it).

initialCheckOut

  • Type: Date
  • Default: null

The initial check-out date (as if the user selected it).

alwaysOpenOnDesktop

  • Type: Boolean
  • Default: false

If true calendar is always open on desktop-size screens.

numberOfMonthsToDisplay

  • Type: Number
  • Default: 2

Number of months displayed (only 1 and 2 are supported values).

firstDayOfWeek

  • Type: Number
  • Default: 0

The first day of the week. Where Sun = 0, Mon = 1, ... Sat = 6.

You need to set the right order in i18n.day-names too.

minNightsByDate

  • Type: Array
  • Default: []

Minimum nights required to select a range of dates, by date range.

Example:

[
  {start: '2021-01-01', end: '2021-06-30', minNights: 1},
  {start: '2021-07-01', end: '2021-08-31', minNights: 7},
  {start: '2021-09-01', end: '2021-12-31', minNights: 1}
]

disabledDates

  • Type: Array
  • Default: []

An array of mixed:

  • Date objects

  • strings in YYYY-MM-DD format

  • ranges in format (values can be either Date objects or string in YYYY-MM-DD format):

    {
      start: new Date(),
      end: 'YYYY-MM-DD'
    }

All the dates passed to the list (or in ranges passed to this list) will be disabled.

hoveringTooltip

  • Type: Boolean or Function
  • Default: true

Shows a tooltip with the number of nights when hovering a date.

staticTooltipMessage

  • Type: String
  • Default null

If provided, it will override the default tooltip ("X nights min." when choosing check-in, "X nights" when choosing check-out) with the text provided. You can use HTML in the string.

showYear

  • Type boolean
  • Default false

Shows the year next to the month

closeDatepickerOnClickOutside

  • Type: boolean
  • Default: true

displayClearButton

  • Type: boolean
  • Default: true

If set to true, displays a clear button on the right side of the input if there are dates set

disableDatesWithoutPrice

  • Type: boolean
  • Default: false

Is set to true, all dates not matching a price range in priceByDate will be disabled.

customI18n

  • Type: Object

Default:

{
  en: {
    nights: { one: '%{count} night', other: '%{count} nights' },
    minNights: { one: '%{count} night minimum', other: '%{count} nights minimum' },
    'day-names': ['Sun', 'Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat'],
    'check-in': 'Check-in',
    'check-out': 'Check-out',
    'month-names': ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
  },
  fr: {
    nights: { one: '%{count} nuit', other: '%{count} nuits' },
    minNights: { one: '%{count} nuit minimum', other: '%{count} nuits minimum' },
    'check-in': 'Arrivée',
    'check-out': 'Départ',
    'day-names': ['Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa', 'Di'],
    'month-names': ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre']
  }
}

I18n object with multiple languages that completely overrides the default one (see src/i18n.js).

lang

  • Type: String
  • Default: 'en'

Language code to access translation in the (default or custom) i18n object.

API

⚠️ In order to open/close the datepicker from an external element, such as a button make sure to set closeDatepickerOnClickOutside to false

hideDatepicker()

Hide datepicker

showDatepicker()

Show datepicker

toggleDatepicker()

Toggle datepicker

Events

checkInChanged

Emitted every time a new check in date is selected with the new date as payload

checkOutChanged

Emitted every time a new check out date is selected with the new date as payload

Credits

This component was originally built as a Vue wrapper component for the Hotel Datepicker by @benitolopez. Version 2.0.0 was completely rewritten with Vue, removing the original library, removing some features and introducing others.

vue-hotel-datepicker's People

Contributors

cyprille avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.