Giter VIP home page Giter VIP logo

datetimerangepicker's Introduction

DateTimeRangePicker

Date time range picker component based on Flatpickr and Quasar. Contains flatpickr wrapper and date-time picker.

Installation

# npm
npm install git+https://github.com/flespi-software/DateTimeRangePicker.git --save

Prerequisites:

Run examples on your localhost

  • Clone this repo
  • You should have quasar (^0.17.0) pre-installed
  • Install dependencies npm install
  • Run webpack dev server quasar dev
  • This should open the demo page at http://localhost:8080 in your default web browser

DateTimeRangePicker component

Screenshot

Features

  • ES6 Javascript
  • Vue.js
  • Writing .vue files
  • Rollup
  • NPM ecosystems

Usage

In quasar.config.js

  framework: {
    components: [
      'QBtnToggle'
    ]
  }
<template>
  <div>
    <date-range v-model="date"/>
  </div>
</template>

<script>
  import DateRange from 'datetimerangepicker'

  export default {
    data () {
      return {
        date: [new Date()],
      }
    },
    components: {
      DateRange
    }
  }
</script>

Available props

The component accepts these props:

Attribute Type Default Description
v-model / value Array [new Date()] RangeValue (required)
mode Number{0,1,2,3,4} 0 Component mode: 0 - Single date picker, 1 - week picker, 2 - month picker, 3 - custom range picker, 4 - manual formated or timestamp mode
theme Object {color:'grey-9', bgColor:'white', modeSwitch:true} color - text color, bgColor - background color, modeSwitch - need show switch mode buttons(it works mode autodetect if enabled, else you can use $refs.range.getModeByRange(range))

Available events

The component accepts these props:

Event Payload Description
input Array Selected dates timestamps array
error Boolean Error in time range.
change:mode Number New component mode

Flatpickr wrapper

Screenshot

Usage

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

<script>
  import { VueFlatPickr } from 'datetimerangepicker'

  export default {
    data () {
      return {
        date: new Date(),
        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: {
      VueFlatPickr
    }
  }
</script>

Events

  • The component can emit all possible events, you can listen to them in your component
<vue-flat-pickr v-model="date" @on-change="doSomethingOnChange" @on-close="doSomethingOnClose" />
  • Events 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 Date-picker value (required)
config Object {wrap:false} Flatpickr configuration options
events Array Array of useful events Customise the events to be emitted
theme Object {color:'grey-9', bgColor:'white'} color - text color, bgColor - background color

License

MIT License

datetimerangepicker's People

Contributors

scarry1992 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.