All Projects → ankurk91 → Vue Flatpickr Component

ankurk91 / Vue Flatpickr Component

Licence: mit
Vue.js component for Flatpickr datetime picker 📆

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vue Flatpickr Component

Vue Ctk Date Time Picker
VueJS component to select dates & time, including a range mode
Stars: ✭ 707 (-8.54%)
Mutual labels:  datepicker, vue-component, timepicker
ng-sq-ui
Flexible and easily customizable UI-kit for Angular 11+
Stars: ✭ 99 (-87.19%)
Mutual labels:  timepicker, datepicker
WheelPicker
A wheel picker for Android, support DateWheelPicker, TimeWheelPicker(滚轮控件,日期、时间选择器,省市区三级联动)
Stars: ✭ 33 (-95.73%)
Mutual labels:  timepicker, datepicker
Pickerjs
⚠️ [Deprecated] No longer maintained. JavaScript date time picker.
Stars: ✭ 299 (-61.32%)
Mutual labels:  datepicker, timepicker
Angular Moment Picker
Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js.
Stars: ✭ 536 (-30.66%)
Mutual labels:  datepicker, timepicker
qing
🍧一个UI组件库。包括 { 日期选择器组件 } { 时间选择器组件 } { 分页组件 } { 树组件 } { 级联选择器组件 } { 表单组件 } 等,ES6语法编写,原生模块化
Stars: ✭ 71 (-90.82%)
Mutual labels:  timepicker, datepicker
skwas-cordova-plugin-datetimepicker
Cordova Plugin for showing a native date, time or datetime picker.
Stars: ✭ 37 (-95.21%)
Mutual labels:  timepicker, datepicker
vue3-date-time-picker
Datepicker component for Vue 3
Stars: ✭ 157 (-79.69%)
Mutual labels:  timepicker, datepicker
Android Switchdatetimepicker
Android library for Date and Time Picker in same dialog
Stars: ✭ 360 (-53.43%)
Mutual labels:  datepicker, timepicker
Zebra datepicker
A super-lightweight, highly configurable, cross-browser date / time picker jQuery plugin
Stars: ✭ 367 (-52.52%)
Mutual labels:  datepicker, timepicker
popoPicker
popoPicker是一个移动端3D滚轮日期时间和单项的选择器,支持无限循环滚动,不依赖第三方库
Stars: ✭ 26 (-96.64%)
Mutual labels:  timepicker, datepicker
Androidpicker
安卓选择器类库,包括日期及时间选择器(可用于出生日期、营业时间等)、单项选择器(可用于性别、民族、职业、学历、星座等)、二三级联动选择器(可用于车牌号、基金定投日期等)、城市地址选择器(分省级、地市级及区县级)、数字选择器(可用于年龄、身高、体重、温度等)、日历选日期择器(可用于酒店及机票预定日期)、颜色选择器、文件及目录选择器、图片选择器等……WheelPicker/DatePicker/TimePicker/OptionPicker/NumberPicker/LinkagePicker/AddressPicker/CarPlatePicker/CalendarPicker/ColorPicker/FilePicker/ImagePicker etc.
Stars: ✭ 5,320 (+588.23%)
Mutual labels:  datepicker, timepicker
silverware-calendar
SilverWare Calendar Module
Stars: ✭ 15 (-98.06%)
Mutual labels:  timepicker, datepicker
svelty-picker
Simple date & time picker in svelte
Stars: ✭ 38 (-95.08%)
Mutual labels:  timepicker, datepicker
flatpickr-rails
This gem packages flatpickr's assets for drop-in use in Rails applications.
Stars: ✭ 29 (-96.25%)
Mutual labels:  timepicker, datepicker
date-time-picker
Angular Date Time Picker (Responsive Design)
Stars: ✭ 98 (-87.32%)
Mutual labels:  timepicker, datepicker
ng-persian-datepicker
Persian datepicker for angular 12+
Stars: ✭ 62 (-91.98%)
Mutual labels:  timepicker, datepicker
NodaTimePicker
A Date/Time picker component library for Blazor using NodaTime
Stars: ✭ 49 (-93.66%)
Mutual labels:  timepicker, datepicker
Datetimepicker
jQuery Plugin Date and Time Picker
Stars: ✭ 3,402 (+340.1%)
Mutual labels:  datepicker, timepicker
Datetimepicker
⭐️🎉一个简约、漂亮的日期时间选择器,支持全方位自定义UI
Stars: ✭ 378 (-51.1%)
Mutual labels:  datepicker, timepicker

Vue FlatPickr Component

downloads jsdelivr npm-version github-tag build codecov license

Vue.js component for Flatpickr date-time picker.

Demo or JSFiddle

Version matrix

Vue.js version Package version Branch
2.x 8.x 8.x
3.x 9.x master

Features

  • Reactive v-model value
    • You can change flatpickr value programmatically
  • Reactive config options
    • You can change config options dynamically
    • Component will watch for any changes and redraw itself
  • Can emit all possible events
  • Compatible with Bootstrap or any other CSS framework
  • Supports wrapped mode
    • Just set wrap:true in config and component will take care of all
  • Works with validation libraries

Installation

# yarn
yarn add vue-flatpickr-component

# npm
npm install vue-flatpickr-component

Usage

Minimal example

<template>
  <div>
    <flat-pickr v-model="date"></flat-pickr>
  </div>
</template>

<script>
  import flatPickr from 'vue-flatpickr-component';
  import 'flatpickr/dist/flatpickr.css';
  
  export default {    
    data () {
      return {
        date: null,       
      }
    },
    components: {
      flatPickr
    }
  }
</script>

Detailed example

Using Bootstrap input group and Font Awesome icons

<template>
  <section>
    <div class="form-group">
      <label>Select a date</label>
      <div class="input-group">
        <flat-pickr
                v-model="date"
                :config="config"                                                          
                class="form-control" 
                placeholder="Select date"               
                name="date">
        </flat-pickr>
        <div class="input-group-append">
          <button class="btn btn-default" type="button" title="Toggle" data-toggle>
            <i class="fa fa-calendar">
              <span aria-hidden="true" class="sr-only">Toggle</span>
            </i>
          </button>
          <button class="btn btn-default" type="button" title="Clear" data-clear>
            <i class="fa fa-times">
              <span aria-hidden="true" class="sr-only">Clear</span>
            </i>               
          </button>
        </div>
      </div>
    </div>
    <pre>Selected date is - {{date}}</pre>
  </section>
</template>

<script>
  // bootstrap is just for this example
  import 'bootstrap/dist/css/bootstrap.css';
  // import this component
  import flatPickr from 'vue-flatpickr-component';  
  import 'flatpickr/dist/flatpickr.css';
  // theme is optional
  // try more themes at - https://flatpickr.js.org/themes/
  import 'flatpickr/dist/themes/material_blue.css';
  // localization is optional
  import {Hindi} from 'flatpickr/dist/l10n/hi.js';
  
  export default {
    name: 'yourComponent',
    data () {
      return {
        // Initial value can be a date object as well
        date: '2020-10-16',
        // Get more form https://flatpickr.js.org/options/
        config: {
          wrap: true, // set wrap to true only when using 'input-group'
          altFormat: 'M j, Y',
          altInput: true,
          dateFormat: 'Y-m-d',
          locale: Hindi, // locale for this instance only          
        },                
      }
    },
    components: {
      flatPickr
    },    
  }
</script>

As plugin

  import {createApp} from 'vue';
  import VueFlatPickr from 'vue-flatpickr-component';
  import 'flatpickr/dist/flatpickr.css';
  // Your app initialization logic goes here
  const app = createApp().mount('#app')
  app.use(VueFlatPickr);

This will register a global component <flat-pickr>

Events

  • The component can emit all possible events, you can listen to them in your component
<flat-pickr v-model="date" @on-change="doSomethingOnChange" @on-close="doSomethingOnClose"></flat-pickr>
  • Event names has been converted to kebab-case.
  • You can still pass your callback methods in :config like original flatpickr do.

Available props

The component accepts these props:

Attribute Type Default Description
v-model String / Date Object / Array / Timestamp / null null Set or Get date-picker value (required)
config Object { wrap:false } Flatpickr configuration options
events Array Array of sensible events Customise the events to be emitted

Install in non-module environments (without webpack)

<!-- Flatpickr related files -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/flatpickr.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/flatpickr.min.js"></script>
<!-- Vue js -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<!-- Lastly add this package -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script>
// Initialize as global component
yourAppInstance.component('flat-pickr', VueFlatpickr);
</script>

Run examples on your localhost

  • Clone this repo
  • You should have node-js 12.14.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 and vue-test-utils for testing.
  • Tests can be found in __test__ folder.
  • Execute tests with this command yarn test

Changelog

Please see CHANGELOG for more information what has changed recently.

License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].