Socket
Book a DemoInstallSign in
Socket

vue-time-date-range-picker

Package Overview
Dependencies
Maintainers
0
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-time-date-range-picker

a vue time date range picker

latest
npmnpm
Version
2.2.1
Version published
Weekly downloads
622
-16.06%
Maintainers
0
Weekly downloads
 
Created
Source

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 moment

Usage

Usage within JS project

import { DatePicker, CalendarDialog } from 'vue-time-date-range-picker'
import 'vue-time-date-range-picker/dist/style.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.2/dist/style.css">
</head>`
<body>
   <div id="app">
    <div>
      <div>v-model value is: {{ initialDates?.map(v => v.toString()) ?? 'empty' }}</div>
      <datepicker v-model="initialDates" @date-applied="onApply" />
    </div>
  </div>

  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></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.2"></script>
  <script>
    const { createApp, ref } = Vue;

    createApp({
      setup() {
        const initialDates = ref(null)

        const onApply = (date1, date2) => {
          console.log(date1, date2)
        }

        return {
          initialDates,
          onApply,
        };
      },
    }).component('datepicker', vdprDatePicker.DatePicker).component('calendardialog', vdprDatePicker.CalendarDialog).mount("#app");
  </script>
</body>

Available props

Below is props that're available in DatePicker Component

** date format refer to moment **

PropTypeDefaultDescription
v-model[Date,Date] / nullv-model binding
initial-dates[Date, Date]Initial 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-dates[Date, Date]Initial 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 **

Keywords

vue

FAQs

Package last updated on 07 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts