Mobile friendly datetime picker for Vue. Supports date, datetime and time modes, i18n and disabling dates.
npm install vue-datetime3---
> Mobile friendly datetime picker for Vue. Supports date, datetime and time modes, i18n and more.
This is a fork and port of Vue 2 vue-datetime by mariomka
to support Vue 3 and typescript. For older versions of Vue refer to aforementioned project.
[//]: # ([](LICENSE))
[//]: # ([](https://npmjs.com/package/vue-datetime))
[//]: # ([](https://www.npmjs.com/package/vue-datetime))
[//]: # ([](https://vuejs.org))
[//]: # ([](https://travis-ci.org/mariomka/vue-datetime))
[//]: # ([](https://codecov.io/gh/mariomka/vue-datetime))

``bash`
yarn add luxon vue-datetime3 weekstart
Or
`bash`
npm install --save luxon vue-datetime3 weekstart
weekstart is optional, is used to get the first day of the week.
#### Register
`js
import createApp from 'vue'
import createDatetime from 'vue-datetime'
// You need a specific loader for CSS files
import 'vue-datetime/dist/style.css'
const app = createApp();
app.use(createDatetime());
`
`html`
| Parameter | Type | Default | Description |
|----------------------|-------------------------------|---------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| v-model (required) | ISO 8601 String | - | Datetime. |String
| type | | date | Picker type: date, datetime or time. |String
| input-id | | '' | Id for the input. |String
| input-class | , Array or Object | '' | Class for the input. |String
| input-style | , Array or Object | '' | Style for the input. |String
| hidden-name | | null | Name for hidden input with raw value. See #51. |String
| value-zone | | UTC | Time zone for the value. |String
| zone | | local | Time zone for the picker. |Object
| format | or String | DateTime.DATE_MED, DateTime.DATETIME_MED or DateTime.TIME_24_SIMPLE | Input date format. Luxon presets or tokens. |Object
| phrases | | {ok: 'Ok', cancel: 'Cancel'} | Phrases. |Boolean
| use12-hour | | false | Display 12 hour (AM/PM) mode |Number
| hour-step | | 1 | Hour step. |Number
| minute-step | | 1 | Minute step. |String
| min-datetime | ISO 8601 | null | Minimum datetime. |String
| max-datetime | ISO 8601 | null | Maximum datetime. |Boolean
| auto | | false | Auto continue/close on select. |Number
| week-start | | auto from locale if _weekstart_ is available or 1 | First day of the week. 1 is Monday and 7 is Sunday. |Array
| flow | | Depends of type | Customize steps flow, steps available: time, date, month, year. Example: ['year', 'date', 'time'] |String
| title | | '' | Popup title. |Boolean
| hide-backdrop | | false | Show/Hide backdrop. |Boolean
| backdrop-click | | true | Enable/Disable backdrop click to cancel (outside click). |String
| color | | #3f51b5 | Color theme of the component |Boolean
| fixed-date | | false | Enables 'datetime' to have fixed date, input acts like a time picker, returns datetime value |Boolean
| fixed-time | | false | Enables 'datetime' to have fixed time, input acts like a date picker, returns datetime value |
Input inherits all props not defined above but style and class will be inherited by root element. See inheritAttrs option
The component is based on Luxon, check out documentation to set time zones and format.
Date internationalization depends on luxon. Set the default locale.
`js
import { Settings } from 'luxon'
Settings.defaultLocale = 'es'
`
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.
You can customize the component using named slots.
Available slots: before, after, button-cancel and button-confirm
#### Button customization example:
`html`
The field description
Cancel
Confirm
You can also use slot-scope to determine which view is currently active:
`html`
Next
Publish
Theming is supported by defining a color in props. color should be a valid css #3f51b5
color option, it's default value is .
`bash`
npm run test
Note: Currently not working. Tests need to be rewritten to ViTest.
`bash`
npm run demo
Bundle the js and css to the dist folder:
`bash``
npm run build