# Vue FlatPickr Component
[](http://npm-stats.com/~packages/vue-flatpickr-component)
[](https://www.jsdelivr.com/package/npm/vue-flatpickr-component)
[](https://www.npmjs.com/package/vue-flatpickr-component)
[](https://github.com/ankurk91/vue-flatpickr-component/)
[](https://github.com/ankurk91/vue-flatpickr-component/actions)
[](https://codecov.io/gh/ankurk91/vue-flatpickr-component)
[](https://yarnpkg.com/en/package/vue-flatpickr-component)
Vue.js component for [Flatpickr](https://flatpickr.js.org/) date-time picker
## [Demo](https://ankurk91.github.io/vue-flatpickr-component/) or [JSFiddle](https://jsfiddle.net/ankurk91/63kzdwLx/)
## Features
* Reactive ``v-model`` value
- You can change flatpickr value programmatically
* Reactive [config](https://flatpickr.js.org/options/) options
- You can change config options dynamically
- Component will watch for any changes and redraw itself
- You are suggested to modify config via [Vue.set](https://vuejs.org/v2/api/#Vue-set)
* Can emit all possible [events](https://flatpickr.js.org/events/)
* Compatible with [Bootstrap](http://getbootstrap.com/), [Bulma](http://bulma.io/) or any other CSS framework
* Supports [wrapped](https://flatpickr.js.org/examples/#flatpickr-external-elements) mode
- Just set ``wrap:true`` in config and component will take care of all
* Works with validation libraries
## Installation
```bash
# yarn
yarn add vue-flatpickr-component
# npm
npm install vue-flatpickr-component
```
## Usage
#### Minimal example
```html
```
#### Detailed example
This example is based on Bootstrap 4 [input group](https://getbootstrap.com/docs/4.3/components/input-group/)
```html
Selected date is - {{date}}
```
#### As plugin
```js
import Vue from 'vue';
import VueFlatPickr from 'vue-flatpickr-component';
import 'flatpickr/dist/flatpickr.css';
Vue.use(VueFlatPickr);
```
This will register a global component ``
## Events
* The component can emit all possible events, you can listen to them in your component
```html
```
* Event names has been converted to kebab-case.
* You can still pass your methods in `:config` like original flatpickr do.
## Available props
The component accepts these props:
| Attribute | Type | Default | Description |
| :--- | :---: | :---: | :--- |
| v-model / value | String / Date Object / Array / Timestamp / null | `null` | Set or Get date-picker value (required) |
| config | Object | `{ wrap:false }` | Flatpickr configuration [options](https://flatpickr.js.org/options/)|
| events | Array | Array of sensible events | Customise the [events](https://flatpickr.js.org/events/) to be emitted|
## Install in non-module environments (without webpack)
```html
```
## Run examples on your localhost
* Clone this repo
* You should have node-js `10.13.0>=` and yarn `>=1.x` pre-installed
* Install dependencies `yarn install`
* Run webpack dev server `yarn start`
* This should open the demo page at `http://localhost:9000` in your default web browser
## Testing
* This package is using [Jest](https://github.com/facebook/jest) and [vue-test-utils](https://github.com/vuejs/vue-test-utils) for testing.
* Tests can be found in `__test__` folder.
* Execute tests with this command `yarn test`
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Caveats
* :warning: Don't pass config option as inline literal object to `:config` prop.
```html
```
* Vue.js cannot detect changes when literal object/arrays passed within template, [see](https://github.com/vuejs/vue/issues/4060)
## License
[MIT](LICENSE.txt) License