Skip to content

@gothassos/easepick-lock-plugin ​

npm version

TIP

This package does not need to be installed if you are using @gothassos/easepick-bundle.

Adds the ability to disable days for selection.

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-lock-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-lock-plugin@1.5.0/dist/index.css',
        ],
        plugins: ['LockPlugin'],
        LockPlugin: {
          minDate: new Date(),
        },
      });
    </script>
  </body>
</html>

Installation ​

NPM ​

bash
npm install @gothassos/easepick-core @gothassos/easepick-lock-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-lock-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 { LockPlugin } from '@gothassos/easepick-lock-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-lock-plugin@1.5.0/dist/index.css',
  ],
  plugins: [LockPlugin],
});

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-lock-plugin@1.5.0/dist/index.css',
  ],
  plugins: ['LockPlugin'],
});

Options ​

NameTypeDefaultDescription
minDateDate
string
number
nullThe minimum/earliest date that can be selected.
Date Object or Unix Timestamp (with milliseconds) or ISO String.
maxDateDate
string
number
nullThe maximum/latest date that can be selected.
Date Object or Unix Timestamp (with milliseconds) or ISO String.
minDaysnumbernullThe minimum days of the selected range.
maxDaysnumbernullThe maximum days of the selected range.
selectForwardbooleanfalseSelect second date after the first selected date.
selectBackwardbooleanfalseSelect second date before the first selected date.
presetsbooleantrueDisable unallowed presets (when PresetPlugin is included).
inseparablebooleanfalseDisable date range selection with locked days.
filterfunctionnullLock days by custom function.

With the core's viewMode: 'month' or 'year', minDate and maxDate lock the months (years) entirely outside them and stop the header arrows there. The other options apply to the day view only.