@gothassos/easepick-time-plugin
TIP
This package does not need to be installed if you are using @gothassos/easepick-bundle.
Adds time picker.
Quick example
html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>easepick</title>
<script src="https://cdn.jsdelivr.net/npm/@gothassos/easepick-datetime@1.5.0/dist/index.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@gothassos/easepick-core@1.5.0/dist/index.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@gothassos/easepick-base-plugin@1.5.0/dist/index.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@gothassos/easepick-time-plugin@1.5.0/dist/index.umd.js"></script>
</head>
<body>
<input id="datepicker"/>
<script>
const picker = new easepick.create({
element: document.getElementById('datepicker'),
css: [
'https://cdn.jsdelivr.net/npm/@gothassos/easepick-core@1.5.0/dist/index.css',
'https://cdn.jsdelivr.net/npm/@gothassos/easepick-time-plugin@1.5.0/dist/index.css',
],
plugins: ['TimePlugin'],
TimePlugin: {
format: 'HH:mm',
},
});
</script>
</body>
</html>Installation
NPM
bash
npm install @gothassos/easepick-core @gothassos/easepick-time-pluginCDN
html
<script src="https://cdn.jsdelivr.net/npm/@gothassos/easepick-datetime@1.5.0/dist/index.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@gothassos/easepick-core@1.5.0/dist/index.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@gothassos/easepick-base-plugin@1.5.0/dist/index.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@gothassos/easepick-time-plugin@1.5.0/dist/index.umd.js"></script>Usage
If you’re using a bundler, e.g. webpack:
ts
import { easepick } from '@gothassos/easepick-core';
import { TimePlugin } from '@gothassos/easepick-time-plugin';
const picker = new easepick.create({
element: document.getElementById('datepicker'),
css: [
'https://cdn.jsdelivr.net/npm/@gothassos/easepick-core@1.5.0/dist/index.css',
'https://cdn.jsdelivr.net/npm/@gothassos/easepick-time-plugin@1.5.0/dist/index.css',
],
plugins: [TimePlugin],
});Another way to initialize easypick:
js
const picker = new easepick.create({
element: document.getElementById('datepicker'),
css: [
'https://cdn.jsdelivr.net/npm/@gothassos/easepick-core@1.5.0/dist/index.css',
'https://cdn.jsdelivr.net/npm/@gothassos/easepick-time-plugin@1.5.0/dist/index.css',
],
plugins: ['TimePlugin'],
});Options
| Name | Type | Default | Description |
|---|---|---|---|
| seconds | boolean | false | Enable seconds picker. |
| stepHours | number | 1 | Step for hours. |
| stepMinutes | number | 5 | Step for minutes. |
| stepSeconds | number | 5 | Step for seconds. |
| format12 | boolean | false | Display 12H time. |
| locale | object | { time: 'Time', startTime: 'Start time', endTime: 'End time', hour: 'Hour', minute: 'Minute', second: 'Second', period: 'AM/PM' } | Names of the time controls for screen readers. Each time is a group named time (or startTime / endTime with RangePlugin), holding selects named hour, minute, second and period. |
Methods
| Name | Description |
|---|---|
| setTime(value) | Set a time for single date picker. |
| setStartTime(value) | Set start time of date range. |
| setEndTime(value) | Set end time of date range. |