1.0.7 • Published 5 years ago

vue-datetime-custom v1.0.7

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

vue-datetime

Software License Latest Version on NPM npm Vue 2.x Build Coverage

FORK OF https://github.com/mariomka/vue-datetime - Mobile friendly datetime picker for Vue. Supports date, datetime and time modes, i18n and disabling dates.

NOTICE: This README is related to next version (1.0.x) of vue-datetime-custom. For the old release 0.x, see here.

Installation

You have to intall Font-awesome for VueJs

Bundler (Webpack, Rollup...)

yarn add luxon npm i vue-datetime-custom weekstart

Or

npm install --save luxon npm i vue-datetime-custom weekstart

weekstart is optional, is used to get the first day of the week.

Register

import Vue from 'vue'
import Datetime from 'vue-datetime-custom'
// You need a specific loader for CSS files
import 'vue-datetime/dist/vue-datetime-custom.css'

Vue.use(Datetime)

Register manually

Global
import { Datetime } from 'vue-datetime-custom';

Vue.component('datetime', Datetime);
Local
import { Datetime } from 'vue-datetime';

Vue.extend({
  template: '...',
  components: {
    datetime: Datetime
  }
});

Browser

Download vue, luxon, weekstart and vue-datetime or use a CDN like unpkg.

<link rel="stylesheet" href="vue-datetime-custom.css"></link>
<script src="vue.js"></script>
<script src="luxon.js"></script>
<script src="weekstart.js"></script>
<script src="vue-datetime.js"></script>

weekstart is optional, is used to get the first day of the week.

Usage

Minimal

<datetime v-model="date"></datetime>

Custom

You can customize the component output using named slots and component props.

<datetime v-model="date" input-id="startDate">
  <label for="startDate" slot="before">Field Label</label>
  <span class="description" slot="after">The field description</span>
</datetime>

Setup

Parameters

ParameterTypeDefaultDescription
v-model (required)ISO 8601 String-Datetime.
typeStringdatePicker type: date, datetime or time.
input-idString''Id for the input.
input-classString''Class for the input.
hidden-nameStringnullName for hidden input with raw value. See #51.
value-zoneStringUTCTime zone for the value.
zoneStringlocalTime zone for the picker.
formatObject or StringDateTime.DATE_MED, DateTime.DATETIME_MED or DateTime.TIME_24_SIMPLEInput date format. Luxon presets or tokens.
phrasesObject{ok: 'Ok', cancel: 'Cancel'}Phrases.
use12-hourBooleanfalseDisplay 12 hour (AM/PM) mode
hour-stepNumber1Hour step.
minute-stepNumber1Minute step.
min-datetimeISO 8601 StringnullMinimum datetime.
max-datetimeISO 8601 StringnullMaximum datetime.
autoBooleanfalseAuto continue/close on select.
week-startNumberauto from locale if weekstart is available or 1First day of the week. 1 is Monday and 7 is Sunday.

Input inherits all props not defined above but style and class will be inherited by root element.

The component is based on Luxon, check out documentation to set time zones and format.

Internationalization

Date internationalization depends on luxon. Set the default locale.

import { Settings } from 'luxon'

Settings.defaultLocale = 'es'

Events

Component emits the input event to work with v-model. More info.

close event is emitted when the popup closes.

Also, input text inherits all component events.

Theming

Theming is supported by overwriting CSS classes.

Development

Launch lint and tests

yarn test

Launch visual tests

yarn dev

Build

Bundle the js and css to the dist folder:

yarn build

License

The MIT License

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago