2.1.2 • Published 10 months ago

vue-time-date-range-picker v2.1.2

Weekly downloads
213
License
MIT
Repository
github
Last release
10 months ago

codecov

vue-time-date-range-picker

A Vue Component to pick a ranged datetime in calendar. Built alongside Vue 3.x . This datepicker utilize moment for translations.

Version matrix

Vue.js versionPackage versionBranch
2.x1.xversion-1
3.x2.xmaster

Demo

codepen demo : https://codepen.io/limbara/pen/ZEQxoZZ sandbox demo : https://codesandbox.io/s/example-vue-time-date-range-picker-byw7g

Clone the repo and run 'npm install && npm run serve' for local demo

Install

npm i vue-time-date-range-picker

Usage

Usage within JS project

import DatePicker, { CalendarDialog } from 'vue-time-date-range-picker/dist/vdprDatePicker'
import 'vue-time-date-range-picker/dist/vdprDatePicker.min.css'

export default {
  //...
  components: {
    DatePicker,
    CalendarDialog
  }
  //...
}

You can use CalendarDialog Component if you want to implement your own input element

Usage from CDN

<head>
  <link rel="stylesheet" href="https://unpkg.com/vue-time-date-range-picker@2.1.1/dist/vdprDatePicker.min.css">
</head>`
<body>
  <div id="app">
    <datepicker></datepicker>
  </div>
  <script src="https://unpkg.com/vue"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.27.0/moment-with-locales.min.js"></script>
  <script src="https://unpkg.com/vue-time-date-range-picker@2.1.1/dist/vdprDatePicker.js"></script>
  <script>
  const app = Vue.createApp({
      components: {
        'datepicker' : vdprDatePicker.default,
        'calendar-dialog' : vdprDatePicker.CalendarDialog
      }
    }).mount("#app")
  </script>
</body>

Available props

Below is props that're available in DatePicker Component

date format refer to moment

PropTypeDefaultDescription
initial-datesDate, DateInitial value for the datepicker
inlineBooleanfalseUse datepicker inline style
languageStringenLanguange
formatStringDD/MM/YYYY HH:mmFormat for display date input
same-date-formatObjectrefer belowFormat for display date input if start & end date same
disabled-datesObjectrefer belowDisable certain dates
available-datesObjectrefer belowAllow only certain dates
date-inputObjectInput configuration
show-helper-buttonsBooleanShow helper buttons
helper-buttons ObjectCustom helper button
calendar-date-inputObjectrefer belowCalendar input date configuration
calendar-time-inputObjectrefer belowCalendar input time configuration
switch-button-labelStringSwitch Button label
switch-button-initialBooleanSwitch Button initial value
apply-button-labelStringApply Button Label
reset-button-labelStringReset Button Label
is-monday-firstBooleanCalendar start from Monday instead of Sunday

Below is props that're available in Calendar Dialog Component

PropTypeDefaultDescription
initial-datesDate, DateInitial value for the datepicker
inlineBooleanfalseUse datepicker inline style
languageStringenLanguange
disabled-datesObjectrefer belowDisable certain dates
available-datesObjectrefer belowAllow only certain dates
show-helper-buttonsBooleantrueShow helper buttons
helper-buttons Object Custom helper button
date-inputObjectCalendar input date configuration
time-inputObjectCalendar input time configuration
switch-button-labelStringAll DaysSwitch Button label
switch-button-initialBooleanfalseSwitch Button initial value
apply-button-labelStringApplyApply Button Label
reset-button-labelStringResetReset Button Label
is-monday-firstBooleanfalseCalendar start from Monday (default Sunday)

Same Date Format

Below is values that're available for props "same-date-format"

KeyTypeDefaultDescription
fromStringDD/MM/YYYY, HH:mmformat selected start date
toStringHH:mmformat selected end date

Date Input

Below is values that're available for props "date-input"

KeyTypeDefaultDescription
inputClassString|Array|Objectclass for input element
refNameStringref name for input element
nameStringattribute name
placeholderStringattribute placeholder
idStringatttibute id
requiredBooleanattirbute required

Disabled Dates

Below is values that're available for props "disabled-dates"

KeyTypeDefaultDescription
dates Datedisable dates matching array of Date object
fromDatedisable dates from this date
toDatedisable dates until this date
rangesObjectdisable dates matching object of date "from" & "to"
customFunctiondisable dates with function

If accidentially both disabled dates and available dates are provided, disabled dates take priority.

Available Dates

Below is values that're available for props "available-dates"

KeyTypeDefaultDescription
dates Dateallow dates matching array of Date object
fromDateallow dates from this date
toDateallow dates until this date
rangesObjectallow dates matching object of date "from" & "to"
customFunctionallow dates with function

If accidentially both disabled dates and available dates are provided, disabled dates take priority.

Helper Buttons

Below is values that're available for props "helper-buttons"

KeyTypeDefaultDescription
nameStringbutton name
fromStringformat selected start date
toStringformat selected end date

C Date Input

Below is values that're available for props "calendar-date-input" or "date-input" for Calendar Dialog component

KeyTypeDefaultDescription
labelStartsStringStartsstart date label
labelEndsStringEndsends date label
inputClassString|Array|Objectclass for input element
formatStringDD/MM/YYYYdate format

C Time Input

Below is values that're available for props "calendar-time-input" or "time-input" for Calendar Dialog component

KeyTypeDefaultDescription
inputClassString|Array|Objectclass for input element
readonlyBooleanfalseattribute readonly
stepNumber60step value in minutes

Events

Below is events that're available in DatePicker Component

EventOutputDescription
date-appliedDate, DateDates is applied to date input. Output start & end date
on-prev-calendarOn calendar page previous
on-next-calendarOn calendar page next
datepicker-openedDatepicker is opened
datepicker-closedDatepicker is closed
select-dateDate, DateA date is selected in calendar. Output start & end date
select-disabled-dateDateA disabled date is selected in calendar
on-resetOn reset when button reset clicked

Below is events that're available in Calendar Dialog Component

EventOutputDescription
on-applyDate, DateDates is applied to date input. Output start & end date
on-prev-calendarOn calendar page previous
on-next-calendarOn calendar page next
select-dateDate, DateA date is selected in calendar. Output start & end date
select-disabled-dateDateA disabled date is selected in calendar
on-resetOn reset when button reset clicked

Translations

available languages refer to moment

2.1.2

10 months ago

2.1.1

12 months ago

1.6.0

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.5.1

2 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago