2.2.0 • Published 1 year ago

@apility/vue-datepicker v2.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Datepicker for Vue 3

Installation

NPM

npm install @apility/vue-datepicker

Yarn

yarn add @apility/vue-datepicker

Usage

You can either register the component globally or locally.

import { DatePicker } from '@apility/vue-datepicker';
Vue.component('date-picker', DatePicker);
<date-picker v-model="date" />

Or you can import it locally in your component.

<script setup>
    import { ref } from 'vue';
    import { DatePicker } from '@apility/vue-datepicker';

    const date = ref(new Date());
</script>

<template>
    <DatePicker v-model="date" />
</template>

Props

NameTypeDefaultDescription
v-modelDatenullThe currently selected date.
minDatenullThe minimum date that can be selected.
maxDatenullThe maximum date that can be selected.
predicateFunction(date) => trueDetermine if a given date should be selectable
optionsObject{}Options for the DatePicker.

The predicate property is a function that receives a Date object and returns a boolean. If the function returns true, the date will be selectable. If the function returns false, the date will be disabled.

This can be used to disable dates that are not available, for example, if you are booking a hotel room.

Options

NameTypeDefaultDescription
emitOnMonthChangeBooleanfalseSets the v-model value to the end or start of the month when changing month in the month view.
emitOnYearChangeBooleanfalseSets the v-model value to the end or start of the year when changing year in the year view.
emitOnDecadeChangeBooleanfalseSets the v-model value to the end or start of the decade when changing decade in the decade view.

Localization

This datepicker is built with date-fns. To override the locale and other date-fns options, you must provide a date-fns-options injection.

This package provides a composable to make it easier to provide the localization options.

import { useDateFnsOptions } from '@apility/vue-datepicker';
import { nb } from 'date-fns/locale';

const { setLocale } = useDateFnsOptions();
setLocale(nb)

You may also provide this manually:

import { nb } from 'date-fns/locale';

provide('date-fns-options', {
    locale: nb,
});

Styling

This datepicker is written to be independent of any CSS framework. It is up to you to style the datepicker to fit your needs. However, we provide a default SCSS stylesheet for Bootstrap 5 for your convenience that you can use to get started.

// If using Webpack
@import "~@apility/vue-datepicker";
// If using Vite
@import "../path/to/node_modules/@apility/vue-datepicker";

Make sure to import this stylesheet after Bootstrap, otherwise it won't be able to inherit the Bootstrap styles.

2.2.0

1 year ago

2.1.2

1 year ago

2.0.3

2 years ago

2.1.1

1 year ago

2.0.2

2 years ago

2.0.0-dev-1

2 years ago

2.1.0

1 year ago

2.0.1

2 years ago

2.0.0

2 years ago

2.0.0-dev

2 years ago

1.7.0

3 years ago

1.6.3

5 years ago

1.6.2

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.5

5 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago