1.2.0 • Published 10 days ago

vue-3-material-date-picker v1.2.0

Weekly downloads
-
License
-
Repository
github
Last release
10 days ago

🚀 Installation

Install using your package manager of choice:

yarn add vue-3-material-date-picker

✨ Features

  • Multiple date selection
  • Customizable and themable
  • Can be changed to any locale on the fly

📺 Demo

https://matija-components.vercel.app/date-picker

⚙️ Usage

Import the component locally or define it globally and include the css file:

<template>
  <div style="display: flex">
    <date-picker
      multiple
      :selected-items-text-formatter="(n) => `${n} dates selected`"
      :first-day-of-week="1"
      :allowed-dates="(date) => parseInt(date.split('-')[2], 10) % 2 === 0"
      :locale="locale"
      v-model="date"
    />
    <div style="margin-left: 30px">
      {{ date }}
      <button @click="changeDate" style="margin-left: 5px">Change</button>
      <button @click="changeLocale" style="margin-left: 5px">
        Change locale
      </button>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref } from "vue";
import { DatePicker } from "vue-3-material-date-picker";
import "vue-3-material-date-picker/dist/style.css";

const date = ref(new Date().toISOString().substring(0, 10));
const locale = ref("en-US");

const changeDate = () => {
  date.value = "2023-09-23";
};

const changeLocale = () => {
  locale.value = "hr-HR";
};
</script>

📃 Props

NameTypeDefaultDescription
v-modelstring/string[]nullStandard two way input, must be passed as an ISO string (YYYY-mm-dd format e.g. 2023-04-23)
minstring1970-01-01Allowed starting date, must be passed as an ISO string (YYYY-mm-dd format e.g. 2023-04-23)
maxstringCurrent dateAllowed ending date, must be passed as an ISO string (YYYY-mm-dd format e.g. 2023-04-23)
disabledbooleanfalseMakes the component uninteractable
readonlybooleanfalseMakes the component uninteractable, but without the style of the disabled variant
widthnumber/string290pxSets the width of the element - can be provided as a string like "290px" or "290" or a number, defaults to 290px
full-widthbooleanfalseIgnores the previous width prop and sets the width to 100% of the parent container
colorstring#2e79bdColor of the various active component elements
first-day-of-weeknumber/string0Sets the first day of the week, starting with 0 for Sunday
hide-titlebooleanfalseHide the picker title
show-adjacent-monthsbooleanfalseToggles visibility of days from previous and next months
localestringundefinedSets the locale, accepts a string with a BCP 47 language tag e.g. en-us or hr-HR
multiplebooleanfalseAllow the selection of multiple dates
allowed-datesfunction ((date: string) => boolean)nullRestricts which dates can be selected
selected-items-text-formatterfunction ((n: number) => string)Selected ${n} datesFunction for formatting the text for selecting multiple dates
title-text-formatterfunction ((date: string) => string)undefinedFunction for formatting the title text
eventsstring[][]Marks the provided dates on the component with a small dot

🎺 Events

NameTypeDescription
change(date: string) => voidTriggered when a date is selected
select:year() => voidTriggered when the user selects the year portion
select:month() => voidTriggered when the user selects the month portion
select:day() => voidTriggered when the user selects the day portion

🧩 Slots

title

Use this slot if you want to override the date picker title, an example being:

<date-picker v-model="date">
  <template
    #title="{
      date,
      selectYears,
      selectMonths,
      selectDays,
    }"
  >
    {{ date }}
  </template>
</date-picker>

There are a few props being exposed:

NameTypeDefaultDescription
datestringnullCurrently selected date
selectYearsfunctionN/AHelper function used for triggering the selection of the years
selectMonthsfunctionN/AHelper function used for triggering the selection of the months
selectDaysfunctionN/AHelper function used for triggering the selection of the days
1.2.0

10 days ago

1.1.1

11 days ago

1.1.0

23 days ago

1.0.0

6 months ago

0.0.9

6 months ago

0.0.8

6 months ago

0.0.7

6 months ago

0.0.6

6 months ago

0.0.5

6 months ago

0.0.4

6 months ago

0.0.3

6 months ago

0.0.2

6 months ago

0.0.1

6 months ago