# vue-time-date-range-picker

> a vue time date range picker

Latest version **2.2.1** (published 2024-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-time-date-range-picker
pnpm add vue-time-date-range-picker
yarn add vue-time-date-range-picker
bun add vue-time-date-range-picker
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.1 |
| Published | 2024-11-07 |
| First published | 2020-07-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20.18.0 |
| Dependencies | 0 |
| Unpacked size | 403.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Nico Limbara |
| Maintainers | nico-lim |
| Keywords | vue, vuejs, range-datetime-picker, date-time-range-picker |

## Links

- npm: https://www.npmjs.com/package/vue-time-date-range-picker
- Homepage: https://github.com/limbara/vue-time-date-range-picker#readme
- Issues: https://github.com/limbara/vue-time-date-range-picker/issues
- npm.io page: https://npm.io/package/vue-time-date-range-picker

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 2.2.1 (latest) — 2024-11-07
- 1.6.0 (version-1) — 2022-04-30
- 2.2.0 — 2024-11-06
- 2.1.2 — 2023-07-28
- 2.1.1 — 2023-05-18
- 2.1.0 — 2022-04-30
- 2.0.1 — 2022-03-27
- 2.0.0 — 2022-03-27
- 1.5.1 — 2022-02-27
- 1.5.0 — 2021-09-18
- 1.4.0 — 2021-06-21
- 1.3.0 — 2021-06-08
- 1.2.3 — 2021-03-19
- 1.2.2 — 2021-02-01
- 1.2.1 — 2020-10-28
- … 7 more at https://npm.io/package/vue-time-date-range-picker/versions

## README

[![codecov](https://codecov.io/gh/limbara/vue-time-date-range-picker/branch/master/graph/badge.svg)](https://codecov.io/gh/limbara/vue-time-date-range-picker)

# 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 version | Package version | Branch                                                                       |
| :---           |:---------------:| ---:                                                                         | 
| 2.x            |       1.x       | [version-1](https://github.com/limbara/vue-time-date-range-picker/tree/version-1)  |
| 3.x            |       2.x       | `master`                                                                     |

- [Demo](#demo)
- [Install](#install)
- [Usage](#usage)
- [Props](#available-props)
- [Events](#events)
- [Translations](#translations)

## 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

```bash
npm i vue-time-date-range-picker moment
```

## Usage

Usage within JS project

```javascript
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
```html
<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](https://momentjs.com/) **

| Prop                                  | Type          | Default           | Description                                             |
|---------------------------------------|---------------|-------------------|---------------------------------------------------------|
| v-model                               | [Date,Date] / null|               | v-model binding                                         |
| initial-dates                         | [Date, Date]  |                   | Initial value for the datepicker                        |
| inline                                | Boolean       | false             | Use datepicker inline style                             |
| language                              | String        | en                | Languange                                               |
| format                                | String        | DD/MM/YYYY HH:mm  | Format for display date input                           |
| [same-date-format](#same-date-format) | Object        | refer below       | Format for display date input if start & end date same  |
| [disabled-dates](#disabled-dates)     | Object        | refer below       | Disable certain dates                                   |
| [available-dates](#available-dates)   | Object        | refer below       | Allow only certain dates                                |
| [date-input](#date-input)             | Object        |                   | Input configuration                                     |
| show-helper-buttons                   | Boolean       |                   | Show helper buttons                                     |
| [helper-buttons](#helper-buttons)     | [ ]Object     |                   | Custom helper button                                    |
| [calendar-date-input](#c-date-input)  | Object        | refer below       | Calendar input date configuration                       |
| [calendar-time-input](#c-time-input)  | Object        | refer below       | Calendar input time configuration                       |
| switch-button-label                   | String        |                   | Switch Button label                                     |
| switch-button-initial                 | Boolean       |                   | Switch Button initial value                             |
| apply-button-label                    | String        |                   | Apply Button Label                                      |
| reset-button-label                    | String        |                   | Reset Button Label                                      | 
| is-monday-first                       | Boolean       |                   | Calendar start from Monday instead of Sunday            |

Below is props that're available in **Calendar Dialog** Component

| Prop                                  | Type            | Default     | Description                                 |
|---------------------------------------|-----------------|-------------|---------------------------------------------|
| initial-dates                         | [Date, Date]    |             | Initial value for the datepicker            |
| inline                                | Boolean         | false       | Use datepicker inline style                 |
| language                              | String          | en          | Languange                                   |
| [disabled-dates](#disabled-dates)     | Object          | refer below | Disable certain dates                       |
| [available-dates](#available-dates)   | Object          | refer below | Allow only certain dates                    |
| show-helper-buttons                   | Boolean         | true        | Show helper buttons                         |
| [helper-buttons](#helper-buttons)     | [ ]Object       | [ ]         | Custom helper button                        |
| [date-input](#c-date-input)           | Object          |             | Calendar input date configuration           |
| [time-input](#c-time-input)           | Object          |             | Calendar input time configuration           |
| switch-button-label                   | String          | All Days    | Switch Button label                         |
| switch-button-initial                 | Boolean         | false       | Switch Button initial value                 |
| apply-button-label                    | String          | Apply       | Apply Button Label                          |
| reset-button-label                    | String          | Reset       | Reset Button Label                          |
| is-monday-first                       | Boolean         | false       | Calendar start from Monday (default Sunday) |

#### Same Date Format 
Below is values that're available for props "same-date-format"

| Key         | Type           | Default             | Description                              |
|-------------|----------------|---------------------|------------------------------------------|
| from        | String         | DD/MM/YYYY, HH:mm   | format selected start date               |
| to          | String         | HH:mm               | format selected end date                 |

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

| Key         | Type                  | Default             | Description                               |
|-------------|-----------------------|---------------------|-------------------------------------------|
| inputClass  | String\|Array\|Object |                     | class for input element                   |
| refName     | String                |                     | ref name for input element                |
| name        | String                |                     | attribute name                            |
| placeholder | String                |                     | attribute placeholder                     |
| id          | String                |                     | atttibute id                              |
| required    | Boolean               |                     | attirbute required                        |

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

| Key         | Type            | Default    | Description                                             |
|-------------|-----------------|------------|---------------------------------------------------------|
| dates       | [ ]Date         |            | disable dates matching array of Date object             | 
| from        | Date            |            | disable dates from this date                            |
| to          | Date            |            | disable dates until this date                           |
| ranges      | Object          |            | disable dates matching object of date "from" & "to"     |
| custom      | Function        |            | disable 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"

| Key         | Type            | Default    | Description                                             |
|-------------|-----------------|------------|---------------------------------------------------------|
| dates       | [ ]Date         |            | allow dates matching array of Date object               | 
| from        | Date            |            | allow dates from this date                              |
| to          | Date            |            | allow dates until this date                             |
| ranges      | Object          |            | allow dates matching object of date "from" & "to"       |
| custom      | Function        |            | allow 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"

| Key         | Type           | Default      | Description                              |
|-------------|----------------|--------------|------------------------------------------|
| name        | String         |              | button name                              |
| from        | String         |              | format selected start date               |
| to          | String         |              | format selected end date                 |

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

| Key         | Type                  | Default      | Description                              |
|-------------|-----------------------|--------------|------------------------------------------|
| labelStarts | String                | Starts       | start date label                         |
| labelEnds   | String                | Ends         | ends date label                          |
| inputClass  | String\|Array\|Object |              | class for input element                  |
| format      | String                | DD/MM/YYYY   | date format                              |

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

| Key         | Type                  | Default      | Description                              |
|-------------|-----------------------|--------------|------------------------------------------|
| inputClass  | String\|Array\|Object |              | class for input element                  |
| readonly    | Boolean               | false        | attribute readonly                       |
| step        | Number                | 60           | step value in minutes                    |

## Events

Below is events that're available in **DatePicker** Component

| Event                 | Output        | Description                                                 |
|-----------------------|---------------|-------------------------------------------------------------|
| date-applied          | Date, Date    | Dates is applied to date input. Output start & end date     |
| on-prev-calendar      |               | On calendar page previous                                   |
| on-next-calendar      |               | On calendar page next                                       |
| datepicker-opened     |               | Datepicker is opened                                        |
| datepicker-closed     |               | Datepicker is closed                                        |
| select-date           | Date, Date    | A date is selected in calendar. Output start & end date     |
| select-disabled-date  | Date          | A disabled date is selected in calendar                     |
| on-reset              |               | On reset when button reset clicked                          |

Below is events that're available in **Calendar Dialog** Component 

| Event                 | Output        | Description                                                 |
|-----------------------|---------------|-------------------------------------------------------------|
| on-apply              | Date, Date    | Dates is applied to date input. Output start & end date     |
| on-prev-calendar      |               | On calendar page previous                                   |
| on-next-calendar      |               | On calendar page next                                       |
| select-date           | Date, Date    | A date is selected in calendar. Output start & end date     |
| select-disabled-date  | Date          | A disabled date is selected in calendar                     |
| on-reset              |               | On reset when button reset clicked                          |

## Translations

** available languages refer to [moment](https://momentjs.com/) **

---
_Source: https://npm.io/package/vue-time-date-range-picker · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
