Skip to content

@gothassos/easepick-time-plugin ​

npm version

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-plugin

CDN ​

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 ​

NameTypeDefaultDescription
secondsbooleanfalseEnable seconds picker.
stepHoursnumber1Step for hours.
stepMinutesnumber5Step for minutes.
stepSecondsnumber5Step for seconds.
format12booleanfalseDisplay 12H time.
localeobject{ 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 ​

NameDescription
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.