Giter VIP home page Giter VIP logo

vue-datepicker-ui's Introduction

Vue Datepicker Component

GitHub package.json version codecov npm GitHub

A Datepicker Component For VueJs (https://edisdev.github.io/vue-datepicker-ui)



Using

Installing

for Vue 2.x

   yarn add vue-datepicker-ui

for Vue 3.x

   yarn add vue-datepicker-ui@vue3

Import to Project

// main.js file
import VueDatepickerUi from 'vue-datepicker-ui'
import 'vue-datepicker-ui/lib/vuedatepickerui.css';

Vue.component('Datepicker', VueDatepickerUi)

or

<script>
  import 'vue-datepicker-ui/lib/vuedatepickerui.css';
  import VueDatepickerUi from 'vue-datepicker-ui';

  export default {
    components: {
      Datepicker: VueDatepickerUi
    }
  }
</script>

and

<template>
  <datepicker ...props>
</template>

Props

   <Datepicker 
    v-model="" 
    :range="" 
    :lang="" 
    :firstDayOfWeek="" 
    :input-class="" 
    :position="" 
    :disabled-start-date="" 
    :disabled-end-date=""
    :text-format="" 
    :date-format=""
    :disabled=""
    :placeholder=""
    :circle=""
    :show-clear-button=""
    :show-picker-inital=""/>
Prop Type Value Default
value/modelValue (v-model) Object Date or Array for range {}
range Boolean - false
lang String Supports all languages / iso code language tr
firstDayOfWeek String monday or sunday monday
inputClass String classname for input -
position String options = top, bottom, left, right left
disabled-start-date Object This object consists of the start and end information(from and to params). ( For single status and range status of startDate). { from: null, to: null}
disabled-end-date Object It has the same with disabled-start-end. (For range status of end Date. Ignored in single status.) { from: null, to: null}
text-format String Short And Long / Short and long formats of month and day names -
date-format Object This is the format in which the selected date will be displayed to the user. { day: '2-digit', month: 'long', year: 'numeric' }
disabled Boolean This parameter is the datepicker prevents opening false
placeholder String Input placeholder Select Date
circle Boolean This is selected are circle or area false
showClearButton Boolean This property is If there is a selected date, it allows the button used to delete this date to be displayed or not. false
showPickerInital Booelan Show picker for on mounted false

and customize style with css variables

element {
  --v-calendar-picker-color: #fff;
  --v-calendar-input-bg-color: #fff;
  --v-calendar-input-bg-disable-color:rgb(245, 245, 245);
  --v-calendar-input-text-disable-color:#b8b8b9;
  --v-calendar-select-bg-color: #fff;
  --v-calendar-border-color: #eaeaeb;
  --v-calendar-triangle-color: #eaeaeb;
  --v-calendar-shadow: 0 20px 30px 0 rgba(0, 0, 0, 0.2);
  --v-calendar-top-shadow: 3px -14px 30px 0px rgba(0, 0, 0, 0.2);
  --v-calendar-text-color: #7b8187;
  --v-calendar-action-color: #7b8187;
  --v-calendar-text-disabled-color: #b8b8b9;
  --v-calendar-view-button-color: #7b8187;
  --v-calendar-view-button-font-weight: 400;
  --v-calendar-view-button-font-size: 1rem;
  --v-calendar-datepicker-icon-color: #1bba67;
  --v-calendar-datepicker-icon-size: 1.1rem;
  --v-calendar-active-bg-color: #1bba67;
  --v-calendar-active-text-color: #fff;
  --v-calendar-range-bg-color: #edfff9;
  --v-calendar-range-text-color: #7b8187;
  --v-calendar-range-radius: 100%;
  --v-calendar-day-hover-bg-color: #eaeaeb;
  --v-calendar-day-width: 40px;
  --v-calendar-day-height: 40px;
  --v-calendar-day-font-size: 0.9rem;
  --v-calendar-day-font-weight: 400;
  --v-calendar-day-name-font-size: 0.9rem;
  --v-calendar-day-name-font-weight: 500;
  --v-calendar-day-name-color: #7b8187;
  --v-calendar-input-border: 1px solid #eaeaeb;
  --v-calendar-input-text-color: #7b8187;
  --v-calendar-input-font-size: 0.9rem;
  --v-calendar-input-font-weight: 400;
  --v-calendar-content-radius: 0px;
  --v-calendar-year-font-size: 1.1rem;
  --v-calendar-year-color: #7b8187;
  --v-calendar-year-font-weight: 400;
  --v-calendar-year-disabled-color: #b8b8b9;
  --v-calendar-year-disabled-bg-color: transparent;
  --v-calendar-year-padding: 10px;
  --v-calendar-year-border: none;
  --v-calendar-year-border-radius: none;
  --v-calendar-month-font-size: 1.1rem;
  --v-calendar-month-color: #7b8187;
  --v-calendar-month-font-weight: 400;
  --v-calendar-month-disabled-color: #b8b8b9;
  --v-calendar-month-disabled-bg-color: transparent;
  --v-calendar-month-padding: 8px;
  --v-calendar-month-border: none;
  --v-calendar-month-border-radius: none;
}

DEMO (https://edisdev.github.io/vue-datepicker-ui)

note:

date-format object values is consists to toLocaleString in js. (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString).

Development:

Firstly

  yarn add --peer vue

Because, Vue is peer dependency. Then,

  yarn install
  yarn docs:dev

vue-datepicker-ui's People

Contributors

edisdev avatar eyaylagul avatar sevkioruc avatar sinansonmez avatar tehuel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vue-datepicker-ui's Issues

allow user typing

It will be a nice addition to the plugin to allow the user to also type the date in the input

Applying custom styles

Hello
Thanks for the great component.

I'm trying to decrease height of the date picker from 50px to 40px.
I've added scoped style on my vue component. such as:

<style scoped>
.v-calendar .input-field input {
    height: 40px;
}
</style>

but it doesn't apply. What am I doing wrong?

Tesekkurler 😊

Focus problem

Datepicker tiplerine tıklayınca bir digeri kapanmıyor. Sayfa yana doğru genişliyor.

screen shot 2018-12-31 at 09 10 37

screen shot 2018-12-31 at 09 10 43

Property showClearButton not working

The property showClearButton doesn't work. I'm passing it but as you can see it is recognized as attributes and not as props.

datePicker(v-model="myValue" :showClearButton="true")
Schermata 2021-07-14 alle 10 39 24

2-way-databinding not work

example:

<datepicker v-model="date" :lang="datePicker.lang" :date-format="datePicker.dateFormat"></datepicker>

...

  data() {
    return {
      date: '01.01.2019',
      datePicker: {
        'lang': 'de',
        'dateFormat': {
          'day': '2-digit',
          'month': '2-digit',
          'year': 'numeric'
        }
      }
    }
  },

  mounted() {
    setTimeout(function() {
      this.date = '31.12.2018'
    }, 1000)
  },

The Inputfield still shows '01.01.2019' after the timeout.
When you open the datepicker Jan 2019 is visible, it better should show Dec 2018.

Date selected event

Hi, thank you for this awesome work.

I have just a question, is there any event where the date is selected in the datepicker ?
I tried to find the response in the documentation but there is nothing about events.

Thank you again.

not working on Persian language

on persian (fa) language is not working, because ,
first day of week should be : saturday
and also
the years should be change (for example : 2020 --> 1399).

how can i resolve it?

[Bug] vue-datepicker-ui@vue3 isn't supported by any available resolver

The Issue

When I try to install the package via yarn, it aborts with the following message:

YN0000: ┌ Resolution step
➤ YN0001: │ Error: vue-datepicker-ui@vue3 isn't supported by any available resolver
    at yf.getResolverByDescriptor (C:\Users\[user-name]\AppData\Local\Volta\tools\image\yarn\3.4.0\bin\yarn.js:391:1647)
    at yf.bindDescriptor (C:\Users\[user-name]\AppData\Local\Volta\tools\image\yarn\3.4.0\bin\yarn.js:391:1036)   
    at Z (C:\Users\[user-name]\AppData\Local\Volta\tools\image\yarn\3.4.0\bin\yarn.js:439:6900)
➤ YN0000: └ Completed
➤ YN0000: Failed with errors in 0s 48ms

Used tools

  • yarn v3.4.0
  • node v16.0.0

azerbaijan calendar

Hi. I'm trying to use this plugin in Azerbaijan language but the days in the calendar shows in English. How can i show the days in Azeri lang?

Disable End Date

If you have a start date set in the range calendar picker. Is there a way so that you can only go ahead for the end date not previous dates

Firing events

I don't see a example on how you can fire events

if i do this

<Datepicker range v-model="selectedDate" lang="en" @reset='clearCalendar()'/>

reset doesn't get fired. Please let me know if I am missing something

Doesnʼt update values on emit and doesnʼt pass the initial value

Hi! I'm trying to use Datepicker with custom filter parameters, without using v-model. But it doesn't work, it even doesn't set the initial value.

import { onMounted, ref } from 'vue';
import VueDatepickerUi from 'vue-datepicker-ui';

var date = ref(new Date());

onMounted(() => {
  console.log('onMounted', date.value);
});

function update(date) {
  date.value = date;
  console.log(date);
}

function toISODate(date) {
  return date.toISOString().slice(0, 10);
}
<template>
  <div>
    <p>{{ toISODate(date) }}</p>
    <p>
      <VueDatepickerUi lang="en" :value="date" @change="update" />
    </p>
    <p>
      <VueDatepickerUi lang="en" :value="date" update:modelValue="update" />
    </p>
  </div>
</template>

I've found different code solutions.
This is what I have after the install via npm npm install vue-datepicker-ui@vue3 --save:

emitInputAction: function emitInputAction() {
      if (JSON.stringify(this.modelValue) !== this.selectedDate) {
        this.$emit('update:modelValue', this.selectedDate);
      }
      // other code ...
    },

And this is how it looks at the last (8d1005b) commit:

this.$emit('input', this.selectedDate);

You can check my example at the stackblitz.com:
https://stackblitz.com/edit/vitejs-vite-dhczkx?file=src%2FApp.vue

Improving Usability: Solving Calendar Overlap with a Blur Event

Hello! I believe I've found a usability issue. When there are multiple calendars together, they overlap because there isn't a blur event on exiting the input to close the open calendar. I tried to close it on my end, but I think it would be more appropriate to correct it in the component. I believe it would be something like this in the .content div:
@blur="isShowPicker = false"
image

SyntaxError: Unexpected token <

Hello. When i am adding import Calendar from 'vue-datepicker-ui' prooject crushs with this error

error during render : /
/Library/WebServer/projects/finaxe/node_modules/vue-datepicker-ui/src/components/calendar.vue:1
(function (exports, require, module, __filename, __dirname) { <template>
                                                              ^

SyntaxError: Unexpected token <
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at r (/Library/WebServer/projects/finaxe/node_modules/vue-server-renderer/build.js:8341:16)
    at Object.vue-datepicker-ui (webpack:/external "vue-datepicker-ui":1:0)
    at __webpack_require__ (webpack/bootstrap:19:0)
    at Module../node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js?!./src/components/blanks/RangeTime.vue?vue&type=script&lang=js& (server-bundle.js:2718:75)
    at __webpack_require__ (webpack/bootstrap:19:0)
    at Module../src/components/blanks/RangeTime.vue?vue&type=script&lang=js& (server-bundle.js:13828:192)
    at __webpack_require__ (webpack/bootstrap:19:0)

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.