Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@easepick/lock-plugin

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@easepick/lock-plugin - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

dist/index.esm.js

@@ -1,1 +0,1 @@

import{DateTime as t}from"@easepick/datetime";import{BasePlugin as i}from"@easepick/base-plugin";class s extends i{priority=1;binds={onView:this.onView.bind(this)};options={minDate:null,maxDate:null,minDays:null,maxDays:null,selectForward:null,selectBackward:null,presets:!0,inseparable:!1,filter:null};getName(){return"LockPlugin"}onAttach(){if(this.options.minDate&&(this.options.minDate=new t(this.options.minDate,this.picker.options.format,this.picker.options.lang)),this.options.maxDate&&(this.options.maxDate=new t(this.options.maxDate,this.picker.options.format,this.picker.options.lang)),(this.options.minDays||this.options.maxDays||this.options.selectForward||this.options.selectBackward)&&!this.picker.options.plugins.includes("RangePlugin")){const t=["minDays","maxDays","selectForward","selectBackward"];console.warn(`${this.getName()}: options ${t.join(", ")} required RangePlugin.`)}this.picker.on("view",this.binds.onView)}onDetach(){this.picker.off("view",this.binds.onView)}onView(i){const{view:s,target:e,date:a}=i.detail;if("CalendarHeader"===s&&(this.options.minDate instanceof t&&a.isSameOrBefore(this.options.minDate,"month")&&e.classList.add("no-previous-month"),this.options.maxDate instanceof t&&a.isSameOrAfter(this.options.maxDate,"month")&&e.classList.add("no-next-month")),"CalendarDay"===s){const t=this.picker.datePicked.length?this.picker.datePicked[0]:null;if(this.testFilter(a))return void e.classList.add("locked");if(this.options.inseparable){if(this.options.minDays){const t=a.clone().subtract(this.options.minDays-1,"day"),i=a.clone().add(this.options.minDays-1,"day");let s=!1,o=!1;for(;t.isBefore(a,"day");){if(this.testFilter(t)){s=!0;break}t.add(1,"day")}for(;i.isAfter(a,"day");){if(this.testFilter(i)){o=!0;break}i.subtract(1,"day")}s&&o&&e.classList.add("not-available")}this.rangeIsNotAvailable(a,t)&&e.classList.add("not-available")}this.dateIsNotAvailable(a,t)&&e.classList.add("not-available")}if(this.options.presets&&"PresetPluginButton"===s){const i=new t(Number(e.dataset.start)),s=new t(Number(e.dataset.end)),a=s.diff(i,"day"),o=this.options.minDays&&a<this.options.minDays,n=this.options.maxDays&&a>this.options.maxDays;(o||n||this.lockMinDate(i)||this.lockMaxDate(i)||this.lockMinDate(s)||this.lockMaxDate(s)||this.rangeIsNotAvailable(i,s))&&e.setAttribute("disabled","disabled")}}dateIsNotAvailable(t,i){return this.lockMinDate(t)||this.lockMaxDate(t)||this.lockMinDays(t,i)||this.lockMaxDays(t,i)||this.lockSelectForward(t)||this.lockSelectBackward(t)}rangeIsNotAvailable(t,i){if(!t||!i)return!1;const s=(t.isSameOrBefore(i,"day")?t:i).clone(),e=(i.isSameOrAfter(t,"day")?i:t).clone();for(;s.isSameOrBefore(e,"day");){if(this.testFilter(s))return!0;s.add(1,"day")}return!1}lockMinDate(i){return this.options.minDate instanceof t&&i.isBefore(this.options.minDate,"day")}lockMaxDate(i){return this.options.maxDate instanceof t&&i.isAfter(this.options.maxDate,"day")}lockMinDays(t,i){if(this.options.minDays&&i){const s=i.clone().subtract(this.options.minDays-1,"day"),e=i.clone().add(this.options.minDays-1,"day");return t.isBetween(s,e)}return!1}lockMaxDays(t,i){if(this.options.maxDays&&i){const s=i.clone().subtract(this.options.maxDays,"day"),e=i.clone().add(this.options.maxDays,"day");return!t.isBetween(s,e)}return!1}lockSelectForward(t){if(1===this.picker.datePicked.length&&this.options.selectForward){const i=this.picker.datePicked[0].clone();return t.isAfter(i,"day")}return!1}lockSelectBackward(t){if(1===this.picker.datePicked.length&&this.options.selectBackward){const i=this.picker.datePicked[0].clone();return t.isBefore(i,"day")}return!1}testFilter(t){return"function"==typeof this.options.filter&&this.options.filter(t,this.picker.datePicked)}}export{s as LockPlugin};
import{DateTime as t}from"@easepick/datetime";import{BasePlugin as i}from"@easepick/base-plugin";class s extends i{priority=1;binds={onView:this.onView.bind(this)};options={minDate:null,maxDate:null,minDays:null,maxDays:null,selectForward:null,selectBackward:null,presets:!0,inseparable:!1,filter:null};getName(){return"LockPlugin"}onAttach(){if(this.options.minDate&&(this.options.minDate=new t(this.options.minDate,this.picker.options.format,this.picker.options.lang)),this.options.maxDate&&(this.options.maxDate=new t(this.options.maxDate,this.picker.options.format,this.picker.options.lang)),(this.options.minDays||this.options.maxDays||this.options.selectForward||this.options.selectBackward)&&!this.picker.options.plugins.includes("RangePlugin")){const t=["minDays","maxDays","selectForward","selectBackward"];console.warn(`${this.getName()}: options ${t.join(", ")} required RangePlugin.`)}this.picker.on("view",this.binds.onView)}onDetach(){this.picker.off("view",this.binds.onView)}onView(i){const{view:s,target:e,date:a}=i.detail;if("CalendarHeader"===s&&(this.options.minDate instanceof t&&a.isSameOrBefore(this.options.minDate,"month")&&e.classList.add("no-previous-month"),this.options.maxDate instanceof t&&a.isSameOrAfter(this.options.maxDate,"month")&&e.classList.add("no-next-month")),"CalendarDay"===s){const t=this.picker.datePicked.length?this.picker.datePicked[0]:null;if(this.testFilter(a))return void e.classList.add("locked");if(this.options.inseparable){if(this.options.minDays){const t=a.clone().subtract(this.options.minDays-1,"day"),i=a.clone().add(this.options.minDays-1,"day");let s=!1,o=!1;for(;t.isBefore(a,"day");){if(this.testFilter(t)){s=!0;break}t.add(1,"day")}for(;i.isAfter(a,"day");){if(this.testFilter(i)){o=!0;break}i.subtract(1,"day")}s&&o&&e.classList.add("not-available")}this.rangeIsNotAvailable(a,t)&&e.classList.add("not-available")}this.dateIsNotAvailable(a,t)&&e.classList.add("not-available")}if(this.options.presets&&"PresetPluginButton"===s){const i=new t(Number(e.dataset.start)),s=new t(Number(e.dataset.end)),a=s.diff(i,"day"),o=this.options.minDays&&a<this.options.minDays,n=this.options.maxDays&&a>this.options.maxDays;(o||n||this.lockMinDate(i)||this.lockMaxDate(i)||this.lockMinDate(s)||this.lockMaxDate(s)||this.rangeIsNotAvailable(i,s))&&e.setAttribute("disabled","disabled")}}dateIsNotAvailable(t,i){return this.lockMinDate(t)||this.lockMaxDate(t)||this.lockMinDays(t,i)||this.lockMaxDays(t,i)||this.lockSelectForward(t)||this.lockSelectBackward(t)}rangeIsNotAvailable(t,i){if(!t||!i)return!1;const s=(t.isSameOrBefore(i,"day")?t:i).clone(),e=(i.isSameOrAfter(t,"day")?i:t).clone();for(;s.isSameOrBefore(e,"day");){if(this.testFilter(s))return!0;s.add(1,"day")}return!1}lockMinDate(i){return this.options.minDate instanceof t&&i.isBefore(this.options.minDate,"day")}lockMaxDate(i){return this.options.maxDate instanceof t&&i.isAfter(this.options.maxDate,"day")}lockMinDays(t,i){if(this.options.minDays&&i){const s=i.clone().subtract(this.options.minDays-1,"day"),e=i.clone().add(this.options.minDays-1,"day");return t.isBetween(s,e)}return!1}lockMaxDays(t,i){if(this.options.maxDays&&i){const s=i.clone().subtract(this.options.maxDays,"day"),e=i.clone().add(this.options.maxDays,"day");return!t.isBetween(s,e)}return!1}lockSelectForward(t){if(1===this.picker.datePicked.length&&this.options.selectForward){const i=this.picker.datePicked[0].clone();return t.isBefore(i,"day")}return!1}lockSelectBackward(t){if(1===this.picker.datePicked.length&&this.options.selectBackward){const i=this.picker.datePicked[0].clone();return t.isAfter(i,"day")}return!1}testFilter(t){return"function"==typeof this.options.filter&&this.options.filter(t,this.picker.datePicked)}}export{s as LockPlugin};
/**
* @license
* Package: @easepick/lock-plugin
* Version: 1.0.2
* Version: 1.0.3
* https://easepick.com/

@@ -10,2 +10,2 @@ * Copyright 2022 Rinat G.

*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@easepick/datetime"),require("@easepick/base-plugin")):"function"==typeof define&&define.amd?define(["exports","@easepick/datetime","@easepick/base-plugin"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).easepick=t.easepick||{},t.easepick,t.easepick)}(this,(function(t,e,i){"use strict";class s extends i.BasePlugin{priority=1;binds={onView:this.onView.bind(this)};options={minDate:null,maxDate:null,minDays:null,maxDays:null,selectForward:null,selectBackward:null,presets:!0,inseparable:!1,filter:null};getName(){return"LockPlugin"}onAttach(){if(this.options.minDate&&(this.options.minDate=new e.DateTime(this.options.minDate,this.picker.options.format,this.picker.options.lang)),this.options.maxDate&&(this.options.maxDate=new e.DateTime(this.options.maxDate,this.picker.options.format,this.picker.options.lang)),(this.options.minDays||this.options.maxDays||this.options.selectForward||this.options.selectBackward)&&!this.picker.options.plugins.includes("RangePlugin")){const t=["minDays","maxDays","selectForward","selectBackward"];console.warn(`${this.getName()}: options ${t.join(", ")} required RangePlugin.`)}this.picker.on("view",this.binds.onView)}onDetach(){this.picker.off("view",this.binds.onView)}onView(t){const{view:i,target:s,date:a}=t.detail;if("CalendarHeader"===i&&(this.options.minDate instanceof e.DateTime&&a.isSameOrBefore(this.options.minDate,"month")&&s.classList.add("no-previous-month"),this.options.maxDate instanceof e.DateTime&&a.isSameOrAfter(this.options.maxDate,"month")&&s.classList.add("no-next-month")),"CalendarDay"===i){const t=this.picker.datePicked.length?this.picker.datePicked[0]:null;if(this.testFilter(a))return void s.classList.add("locked");if(this.options.inseparable){if(this.options.minDays){const t=a.clone().subtract(this.options.minDays-1,"day"),e=a.clone().add(this.options.minDays-1,"day");let i=!1,n=!1;for(;t.isBefore(a,"day");){if(this.testFilter(t)){i=!0;break}t.add(1,"day")}for(;e.isAfter(a,"day");){if(this.testFilter(e)){n=!0;break}e.subtract(1,"day")}i&&n&&s.classList.add("not-available")}this.rangeIsNotAvailable(a,t)&&s.classList.add("not-available")}this.dateIsNotAvailable(a,t)&&s.classList.add("not-available")}if(this.options.presets&&"PresetPluginButton"===i){const t=new e.DateTime(Number(s.dataset.start)),i=new e.DateTime(Number(s.dataset.end)),a=i.diff(t,"day"),n=this.options.minDays&&a<this.options.minDays,o=this.options.maxDays&&a>this.options.maxDays;(n||o||this.lockMinDate(t)||this.lockMaxDate(t)||this.lockMinDate(i)||this.lockMaxDate(i)||this.rangeIsNotAvailable(t,i))&&s.setAttribute("disabled","disabled")}}dateIsNotAvailable(t,e){return this.lockMinDate(t)||this.lockMaxDate(t)||this.lockMinDays(t,e)||this.lockMaxDays(t,e)||this.lockSelectForward(t)||this.lockSelectBackward(t)}rangeIsNotAvailable(t,e){if(!t||!e)return!1;const i=(t.isSameOrBefore(e,"day")?t:e).clone(),s=(e.isSameOrAfter(t,"day")?e:t).clone();for(;i.isSameOrBefore(s,"day");){if(this.testFilter(i))return!0;i.add(1,"day")}return!1}lockMinDate(t){return this.options.minDate instanceof e.DateTime&&t.isBefore(this.options.minDate,"day")}lockMaxDate(t){return this.options.maxDate instanceof e.DateTime&&t.isAfter(this.options.maxDate,"day")}lockMinDays(t,e){if(this.options.minDays&&e){const i=e.clone().subtract(this.options.minDays-1,"day"),s=e.clone().add(this.options.minDays-1,"day");return t.isBetween(i,s)}return!1}lockMaxDays(t,e){if(this.options.maxDays&&e){const i=e.clone().subtract(this.options.maxDays,"day"),s=e.clone().add(this.options.maxDays,"day");return!t.isBetween(i,s)}return!1}lockSelectForward(t){if(1===this.picker.datePicked.length&&this.options.selectForward){const e=this.picker.datePicked[0].clone();return t.isAfter(e,"day")}return!1}lockSelectBackward(t){if(1===this.picker.datePicked.length&&this.options.selectBackward){const e=this.picker.datePicked[0].clone();return t.isBefore(e,"day")}return!1}testFilter(t){return"function"==typeof this.options.filter&&this.options.filter(t,this.picker.datePicked)}}t.LockPlugin=s,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@easepick/datetime"),require("@easepick/base-plugin")):"function"==typeof define&&define.amd?define(["exports","@easepick/datetime","@easepick/base-plugin"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).easepick=t.easepick||{},t.easepick,t.easepick)}(this,(function(t,e,i){"use strict";class s extends i.BasePlugin{priority=1;binds={onView:this.onView.bind(this)};options={minDate:null,maxDate:null,minDays:null,maxDays:null,selectForward:null,selectBackward:null,presets:!0,inseparable:!1,filter:null};getName(){return"LockPlugin"}onAttach(){if(this.options.minDate&&(this.options.minDate=new e.DateTime(this.options.minDate,this.picker.options.format,this.picker.options.lang)),this.options.maxDate&&(this.options.maxDate=new e.DateTime(this.options.maxDate,this.picker.options.format,this.picker.options.lang)),(this.options.minDays||this.options.maxDays||this.options.selectForward||this.options.selectBackward)&&!this.picker.options.plugins.includes("RangePlugin")){const t=["minDays","maxDays","selectForward","selectBackward"];console.warn(`${this.getName()}: options ${t.join(", ")} required RangePlugin.`)}this.picker.on("view",this.binds.onView)}onDetach(){this.picker.off("view",this.binds.onView)}onView(t){const{view:i,target:s,date:a}=t.detail;if("CalendarHeader"===i&&(this.options.minDate instanceof e.DateTime&&a.isSameOrBefore(this.options.minDate,"month")&&s.classList.add("no-previous-month"),this.options.maxDate instanceof e.DateTime&&a.isSameOrAfter(this.options.maxDate,"month")&&s.classList.add("no-next-month")),"CalendarDay"===i){const t=this.picker.datePicked.length?this.picker.datePicked[0]:null;if(this.testFilter(a))return void s.classList.add("locked");if(this.options.inseparable){if(this.options.minDays){const t=a.clone().subtract(this.options.minDays-1,"day"),e=a.clone().add(this.options.minDays-1,"day");let i=!1,n=!1;for(;t.isBefore(a,"day");){if(this.testFilter(t)){i=!0;break}t.add(1,"day")}for(;e.isAfter(a,"day");){if(this.testFilter(e)){n=!0;break}e.subtract(1,"day")}i&&n&&s.classList.add("not-available")}this.rangeIsNotAvailable(a,t)&&s.classList.add("not-available")}this.dateIsNotAvailable(a,t)&&s.classList.add("not-available")}if(this.options.presets&&"PresetPluginButton"===i){const t=new e.DateTime(Number(s.dataset.start)),i=new e.DateTime(Number(s.dataset.end)),a=i.diff(t,"day"),n=this.options.minDays&&a<this.options.minDays,o=this.options.maxDays&&a>this.options.maxDays;(n||o||this.lockMinDate(t)||this.lockMaxDate(t)||this.lockMinDate(i)||this.lockMaxDate(i)||this.rangeIsNotAvailable(t,i))&&s.setAttribute("disabled","disabled")}}dateIsNotAvailable(t,e){return this.lockMinDate(t)||this.lockMaxDate(t)||this.lockMinDays(t,e)||this.lockMaxDays(t,e)||this.lockSelectForward(t)||this.lockSelectBackward(t)}rangeIsNotAvailable(t,e){if(!t||!e)return!1;const i=(t.isSameOrBefore(e,"day")?t:e).clone(),s=(e.isSameOrAfter(t,"day")?e:t).clone();for(;i.isSameOrBefore(s,"day");){if(this.testFilter(i))return!0;i.add(1,"day")}return!1}lockMinDate(t){return this.options.minDate instanceof e.DateTime&&t.isBefore(this.options.minDate,"day")}lockMaxDate(t){return this.options.maxDate instanceof e.DateTime&&t.isAfter(this.options.maxDate,"day")}lockMinDays(t,e){if(this.options.minDays&&e){const i=e.clone().subtract(this.options.minDays-1,"day"),s=e.clone().add(this.options.minDays-1,"day");return t.isBetween(i,s)}return!1}lockMaxDays(t,e){if(this.options.maxDays&&e){const i=e.clone().subtract(this.options.maxDays,"day"),s=e.clone().add(this.options.maxDays,"day");return!t.isBetween(i,s)}return!1}lockSelectForward(t){if(1===this.picker.datePicked.length&&this.options.selectForward){const e=this.picker.datePicked[0].clone();return t.isBefore(e,"day")}return!1}lockSelectBackward(t){if(1===this.picker.datePicked.length&&this.options.selectBackward){const e=this.picker.datePicked[0].clone();return t.isAfter(e,"day")}return!1}testFilter(t){return"function"==typeof this.options.filter&&this.options.filter(t,this.picker.datePicked)}}t.LockPlugin=s,Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "@easepick/lock-plugin",
"description": "Plugin for easepick.",
"version": "1.0.2",
"version": "1.0.3",
"main": "dist/index.umd.js",

@@ -9,3 +9,3 @@ "module": "dist/index.esm.js",

"dependencies": {
"@easepick/base-plugin": "^1.0.0"
"@easepick/base-plugin": "^1.0.2"
},

@@ -12,0 +12,0 @@ "author": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc