New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@easepick/time-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/time-plugin - npm Package Compare versions

Comparing version 1.0.0-beta.1 to 1.0.0-beta.2

9

dist/index.umd.js

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

/**
* @license
* Package: @easepick/time-plugin
* Version: 1.0.0-beta.2
* https://easepick.com/
* Copyright 2022 Rinat G.
*
* Licensed under the terms of GNU General Public License Version 2 or later. (http://www.gnu.org/licenses/gpl.html)
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@easepick/datetime"),require("@easepick/base-plugin")):"function"==typeof define&&define.amd?define(["exports","@easepick/datetime","@easepick/base-plugin"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).easepick=e.easepick||{},e.easepick,e.easepick)}(this,(function(e,t,i){"use strict";class n extends i.BasePlugin{options={native:!1,format:"HH:mm",append:"start",seconds:!1,stepHours:1,stepMinutes:5,stepSeconds:5,format12:!1};rangePlugin;timePicked={input:null,start:null,end:null};binds={getDate:this.getDate.bind(this),getStartDate:this.getStartDate.bind(this),getEndDate:this.getEndDate.bind(this),onView:this.onView.bind(this),onInput:this.onInput.bind(this),onChange:this.onChange.bind(this),onSelect:this.onSelect.bind(this)};getName(){return"TimePlugin"}onAttach(){this.binds._getDate=this.picker.getDate,this.binds._getStartDate=this.picker.getStartDate,this.binds._getEndDate=this.picker.getEndDate,Object.defineProperties(this.picker,{getDate:{configurable:!0,value:this.binds.getDate},getStartDate:{configurable:!0,value:this.binds.getStartDate},getEndDate:{configurable:!0,value:this.binds.getEndDate}}),this.picker.on("view",this.binds.onView),this.picker.on("input",this.binds.onInput),this.picker.on("change",this.binds.onChange),this.picker.on("select",this.binds.onSelect)}onDetach(){Object.defineProperties(this.picker,{getDate:{configurable:!0,value:this.binds._getDate},getStartDate:{configurable:!0,value:this.binds._getStartDate},getEndDate:{configurable:!0,value:this.binds._getEndDate}}),this.picker.off("view",this.binds.onView),this.picker.off("input",this.binds.onInput),this.picker.off("change",this.binds.onChange),this.picker.off("select",this.binds.onSelect)}getDate(){if(this.picker.options.date instanceof Date){const e=new t.DateTime(this.picker.options.date);if(this.timePicked.input){const t=this.timePicked.input;e.setHours(t.getHours(),t.getMinutes(),t.getSeconds(),0)}return e}return null}getStartDate(){if(this.rangePlugin.options.startDate instanceof Date){const e=new t.DateTime(this.rangePlugin.options.startDate);if(this.timePicked.start){const t=this.timePicked.start;e.setHours(t.getHours(),t.getMinutes(),t.getSeconds(),0)}return e}return null}getEndDate(){if(this.rangePlugin.options.endDate instanceof Date){const e=new t.DateTime(this.rangePlugin.options.endDate);if(this.timePicked.end){const t=this.timePicked.end;e.setHours(t.getHours(),t.getMinutes(),t.getSeconds(),0)}return e}return null}onView(e){const{view:t,target:i}=e.detail;if("Main"===t){this.rangePlugin=this.picker.PluginManager.getInstance("RangePlugin");const e=document.createElement("div");if(e.className="time-plugin-container",this.rangePlugin){const t=this.getStartInput();e.appendChild(t),this.picker.trigger("view",{view:"TimePluginInput",target:t});const i=this.getEndInput();e.appendChild(i),this.picker.trigger("view",{view:"TimePluginInput",target:i})}else{const t=this.getSingleInput();e.appendChild(t),this.picker.trigger("view",{view:"TimePluginInput",target:t})}i.appendChild(e),this.picker.trigger("view",{view:"TimePluginContainer",target:e})}}onInput(e){const i=e.target;if(i instanceof HTMLInputElement&&i.classList.contains("time-plugin-input")){const e=this.timePicked[i.name]||new t.DateTime,[n,s]=i.value.split(":");e.setHours(Number(n)||0,Number(s)||0,0,0),this.timePicked[i.name]=e}}onChange(e){const i=e.target;if(i instanceof HTMLSelectElement&&i.classList.contains("time-plugin-custom-input")){const e=/(\w+)\[(\w+)\]/,[,n,s]=i.name.match(e),o=Number(i.value),a=this.timePicked[n]||new t.DateTime;switch(s){case"HH":if(this.options.format12){const e=i.closest(".time-plugin-custom-block").querySelector(`select[name="${n}[period]"]`).value,t=this.handleFormat12(e,a,o);a.setHours(t.getHours(),t.getMinutes(),t.getSeconds(),0)}else a.setHours(o,a.getMinutes(),a.getSeconds(),0);break;case"mm":a.setHours(a.getHours(),o,a.getSeconds(),0);break;case"ss":a.setHours(a.getHours(),a.getMinutes(),o,0);break;case"period":if(this.options.format12){const e=i.closest(".time-plugin-custom-block").querySelector(`select[name="${n}[HH]"]`).value,t=this.handleFormat12(i.value,a,Number(e));a.setHours(t.getHours(),t.getMinutes(),t.getSeconds(),0)}}this.timePicked[n]=a}}onSelect(e){const{date:t,start:i,end:n}=e.detail,s=this.picker.options,o=s.element,a=this.picker.PluginManager.getInstance("RangePlugin");if(a){const e=this.formatDateTime(i),t=this.formatDateTime(n);if(a.options.elementEnd){const i=s.RangePlugin.elementEnd;o.value=e,i.value=t}else o instanceof HTMLInputElement?o.value=`${e}${a.options.delimiter}${t}`:o instanceof HTMLElement&&(o.innerText=`${e}${a.options.delimiter}${t}`)}else{const e=this.formatDateTime(t);o instanceof HTMLInputElement?o.value=e:o instanceof HTMLElement&&(o.innerText=e)}}formatDateTime(e){if(!e)return"";const t=[],i=this.picker.options;return this.options.format12?(t.push(e.toJSDate().toLocaleString("en-US",{hour:"numeric",minute:"numeric",hour12:!0})),t.push(e.format(i.format))):(t.push(e.format(this.options.format)),t.push(e.format(i.format))),"end"===this.options.append?t.reverse().join(" "):t.join(" ")}getSingleInput(){return this.options.native?this.getNativeInput("input"):this.getCustomInput("input")}getStartInput(){return this.options.native?this.getNativeInput("start"):this.getCustomInput("start")}getEndInput(){return this.options.native?this.getNativeInput("end"):this.getCustomInput("end")}getNativeInput(e){const t=document.createElement("input");t.type="time",t.name=e,t.className="time-plugin-input unit";const i=this.timePicked[e];if(i){const e=`0${i.getHours()}`.slice(-2),n=`0${i.getMinutes()}`.slice(-2);t.value=`${e}:${n}`}return t}getCustomInput(e){const t=document.createElement("div");t.className="time-plugin-custom-block";const i=document.createElement("select");i.className="time-plugin-custom-input unit",i.name=`${e}[HH]`;const n=this.options.format12?1:0,s=this.options.format12?13:24,o=this.timePicked[e];for(let e=n;e<s;e+=this.options.stepHours){const t=document.createElement("option");if(t.value=String(e),t.text=String(e),o)if(this.options.format12){(o.getHours()%12?o.getHours()%12:12)===e&&(t.selected=!0)}else o.getHours()===e&&(t.selected=!0);i.appendChild(t)}t.appendChild(i);const a=document.createElement("select");a.className="time-plugin-custom-input unit",a.name=`${e}[mm]`;for(let e=0;e<60;e+=this.options.stepMinutes){const t=document.createElement("option");t.value=`0${String(e)}`.slice(-2),t.text=`0${String(e)}`.slice(-2),o&&o.getMinutes()===e&&(t.selected=!0),a.appendChild(t)}if(t.appendChild(a),this.options.seconds){const i=document.createElement("select");i.className="time-plugin-custom-input unit",i.name=`${e}[ss]`;const n=60;for(let e=0;e<n;e+=this.options.stepSeconds){const t=document.createElement("option");t.value=`0${String(e)}`.slice(-2),t.text=`0${String(e)}`.slice(-2),o&&o.getSeconds()===e&&(t.selected=!0),i.appendChild(t)}t.appendChild(i)}if(this.options.format12){const i=document.createElement("select");i.className="time-plugin-custom-input unit",i.name=`${e}[period]`,["AM","PM"].forEach((e=>{const t=document.createElement("option");t.value=e,t.text=e,o&&"PM"===e&&o.getHours()>=12&&(t.selected=!0),i.appendChild(t)})),t.appendChild(i)}return t}handleFormat12(e,t,i){const n=t.clone();switch(e){case"AM":12===i?n.setHours(0,n.getMinutes(),n.getSeconds(),0):n.setHours(i,n.getMinutes(),n.getSeconds(),0);break;case"PM":12!==i?n.setHours(i+12,n.getMinutes(),n.getSeconds(),0):n.setHours(i,n.getMinutes(),n.getSeconds(),0)}return n}}e.TimePlugin=n,Object.defineProperty(e,"__esModule",{value:!0})}));

2

package.json
{
"name": "@easepick/time-plugin",
"description": "Plugin for easepick.",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"main": "dist/index.umd.js",

@@ -6,0 +6,0 @@ "module": "dist/index.esm.js",

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