timepicker-ui 4.1.6 → 4.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/plugins/range.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var d=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var R=(n,t)=>{for(var e in t)d(n,e,{get:t[e],enumerable:!0})},E=(n,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of P(t))!T.call(n,i)&&i!==e&&d(n,i,{get:()=>t[i],enumerable:!(a=y(t,i))||a.enumerable});return n};var C=n=>E(d({},"__esModule",{value:!0}),n);var D={};R(D,{RangeManager:()=>u,RangePlugin:()=>A});module.exports=C(D);function f(n){if(!n||n==="--:--")return null;let t=n.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);if(t)return{hour:t[1],minutes:t[2],type:t[3].toUpperCase()};let e=n.match(/^(\d{1,2}):(\d{2})$/);return e?{hour:e[1],minutes:e[2]}:null}function o(n){let t=n.minutes==="--"?"--":n.minutes.padStart(2,"0"),e=`${n.hour}:${t}`;return n.type?`${e} ${n.type}`:e}function g(n,t){if(!n)return 0;let e=parseInt(n.hour,10),a=parseInt(n.minutes,10);return t==="12h"&&n.type&&(n.type==="PM"&&e!==12&&(e+=12),n.type==="AM"&&e===12&&(e=0)),e*60+a}function v(n,t,e){if(!n||!t)return 0;let a=g(n,e);return g(t,e)-a}function p(n,t){return n?t==="12h"?!!(n.hour&&n.minutes&&n.type):!!(n.hour&&n.minutes):!1}function V(n){if(!n||!n.includes(" - "))return{from:null,to:null};let t=n.split(" - ").map(e=>e.trim());return t.length!==2||t[0]==="--:--"||t[1]==="--:--"?{from:null,to:null}:{from:f(t[0]),to:f(t[1])}}var m=class{activePart="from";fromValue=null;toValue=null;previewValue=null;clockType;minDuration;maxDuration;emitter;constructor(t,e,a,i){this.clockType=t,this.minDuration=e,this.maxDuration=a,this.emitter=i}getActivePart(){return this.activePart}getFromValue(){return this.fromValue}getToValue(){return this.toValue}getPreviewValue(){return this.previewValue}setFromValue(t){this.fromValue=t}setToValue(t){this.toValue=t}setPreviewValue(t){this.previewValue=t}isFromComplete(){return p(this.fromValue,this.clockType)}isToComplete(){return p(this.toValue,this.clockType)}canSwitchToEnd(){return this.isFromComplete()}canConfirm(){return!this.isFromComplete()||!this.isToComplete()?!1:this.getDuration()>0}setActivePart(t){if(t==="to"&&!this.canSwitchToEnd())return!1;let e=this.activePart!==t;return this.activePart=t,e&&(this.previewValue=null),e}getCurrentValue(){return this.previewValue?this.previewValue:this.activePart==="from"?this.fromValue:this.toValue}getSavedValue(){return this.activePart==="from"?this.fromValue:this.toValue}commitPreview(){this.previewValue&&(this.activePart==="from"?this.fromValue=this.previewValue:this.toValue=this.previewValue,this.previewValue=null)}getDuration(){return v(this.fromValue,this.toValue,this.clockType)}validate(){if(!this.fromValue||!this.toValue)return{valid:!0,duration:0};let t=this.getDuration(),e=!0;return this.minDuration!==void 0&&t<this.minDuration&&(e=!1),this.maxDuration!==void 0&&t>this.maxDuration&&(e=!1),this.emitter.emit("range:validation",{valid:e,duration:t,minDuration:this.minDuration,maxDuration:this.maxDuration}),{valid:e,duration:t}}getDisabledTimeForEndPart(){if(this.activePart==="from"||!this.fromValue||!this.isFromComplete())return null;let t=[],e=[],a=parseInt(this.fromValue.hour,10),i=parseInt(this.fromValue.minutes,10),r=this.fromValue.type;if(this.clockType==="24h"){for(let s=0;s<a;s++)t.push(s.toString().padStart(2,"0"));for(let s=0;s<i;s++)e.push(s.toString().padStart(2,"0"));return{hours:t,minutes:e,fromHour:a}}for(let s=0;s<i;s++)e.push(s.toString().padStart(2,"0"));return{hours:t,minutes:e,fromType:r,fromHour:a}}reset(){this.activePart="from",this.fromValue=null,this.toValue=null,this.previewValue=null}};var h=class{core;state;constructor(t,e){this.core=t,this.state=e}updateTabs(){let t=this.core.getModalElement();if(!t)return;let e=t.querySelector(".tp-ui-range-tab.tp-ui-range-from"),a=t.querySelector(".tp-ui-range-tab.tp-ui-range-to"),i=this.state.getActivePart()==="from",r=this.state.isFromComplete();e?.classList.toggle("active",i),a?.classList.toggle("active",!i),a?.classList.toggle("disabled",!r),e?.setAttribute("aria-selected",String(i)),a?.setAttribute("aria-selected",String(!i)),a?.setAttribute("aria-disabled",String(!r)),e?.setAttribute("tabindex",i?"0":"-1"),a?.setAttribute("tabindex",i||!r?"-1":"0")}updateTimeDisplay(){let t=this.core.getModalElement();if(!t)return;let e=t.querySelector(".tp-ui-range-from-time"),a=t.querySelector(".tp-ui-range-to-time"),i=this.state.getActivePart(),r=this.state.getPreviewValue(),s=this.state.getFromValue(),l=this.state.getToValue(),c=i==="from"&&r?o(r):s?o(s):"--:--",b=i==="to"&&r?o(r):l?o(l):"--:--";e&&(e.textContent=c),a&&(a.textContent=b)}updateOkButton(){let t=this.core.getOkButton();if(!t)return;let e=this.state.canConfirm();t.classList.toggle("disabled",!e),t.setAttribute("aria-disabled",String(!e))}updateInputValue(){let t=this.core.getInput();if(!t)return;let e=this.state.getFromValue(),a=this.state.getToValue(),i=e?o(e):"--:--",r=a?o(a):"--:--";t.value=`${i} - ${r}`}syncClockToActivePart(){let t=this.state.getSavedValue(),e=this.core.getHour(),a=this.core.getMinutes();if(e&&(e.value=t?.hour??"12"),a&&(a.value=t?.minutes??"00"),this.core.options.clock.type==="12h"){let i=this.core.getAM(),r=this.core.getPM();t?.type==="AM"?(i?.classList.add("active"),r?.classList.remove("active")):t?.type==="PM"?(r?.classList.add("active"),i?.classList.remove("active")):(i?.classList.remove("active"),r?.classList.remove("active"))}a&&(a.blur(),a.classList.remove("active")),e&&e.click()}updateAll(){this.updateTabs(),this.updateTimeDisplay(),this.updateOkButton()}};var u=class{core;emitter;state;ui;cleanupHandlers=[];boundHandleMinuteCommit;boundHandleConfirm;boundHandleUpdate;boundHandleAmPm;constructor(t,e){this.core=t,this.emitter=e;let{range:a,clock:i}=t.options;this.state=new m(i.type,a?.minDuration,a?.maxDuration,e),this.ui=new h(t,this.state),this.boundHandleMinuteCommit=this.handleMinuteCommit.bind(this),this.boundHandleConfirm=this.handleConfirm.bind(this),this.boundHandleUpdate=this.handleUpdate.bind(this),this.boundHandleAmPm=this.handleAmPm.bind(this)}get isEnabled(){return this.core.options.range?.enabled===!0}init(){if(!this.isEnabled)return;let e=this.core.getInput()?.value||"",{from:a,to:i}=V(e);this.state.setFromValue(a),this.state.setToValue(i),this.state.setActivePart("from"),this.state.setPreviewValue(null),this.bindEvents(),this.ui.syncClockToActivePart(),this.ui.updateAll()}getActivePart(){return this.state.getActivePart()}setActivePart(t){if(!this.isEnabled)return;this.state.setActivePart(t)&&this.emitter.emit("range:switch",{active:t,disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart(),this.ui.updateAll()}getFromValue(){return this.state.getFromValue()}getToValue(){return this.state.getToValue()}getDisabledTimeForEndPart(){return this.isEnabled?this.state.getDisabledTimeForEndPart():null}getDuration(){return this.state.getDuration()}validateRange(){return this.isEnabled?this.state.validate():{valid:!0,duration:0}}canConfirm(){return this.isEnabled?this.state.canConfirm():!0}getFormattedRange(){let t=this.state.getFromValue(),e=this.state.getToValue();return!t||!e?null:{from:o(t),to:o(e)}}bindEvents(){let t=this.core.getModalElement();if(!t)return;let e=t.querySelector(".tp-ui-range-tab.tp-ui-range-from"),a=t.querySelector(".tp-ui-range-tab.tp-ui-range-to");if(e){let i=()=>this.setActivePart("from");e.addEventListener("click",i),this.cleanupHandlers.push(()=>e.removeEventListener("click",i))}if(a){let i=()=>this.setActivePart("to");a.addEventListener("click",i),this.cleanupHandlers.push(()=>a.removeEventListener("click",i))}this.emitter.on("update",this.boundHandleUpdate),this.cleanupHandlers.push(()=>this.emitter.off("update",this.boundHandleUpdate)),this.emitter.on("range:minute:commit",this.boundHandleMinuteCommit),this.cleanupHandlers.push(()=>this.emitter.off("range:minute:commit",this.boundHandleMinuteCommit)),this.emitter.on("confirm",this.boundHandleConfirm),this.cleanupHandlers.push(()=>this.emitter.off("confirm",this.boundHandleConfirm)),this.emitter.on("select:am",this.boundHandleAmPm),this.cleanupHandlers.push(()=>this.emitter.off("select:am",this.boundHandleAmPm)),this.emitter.on("select:pm",this.boundHandleAmPm),this.cleanupHandlers.push(()=>this.emitter.off("select:pm",this.boundHandleAmPm))}handleUpdate(){if(!this.isEnabled)return;let t=this.core.getHour(),e=this.core.getMinutes(),a=this.core.getActiveTypeMode(),i=t?.value??"12",r=this.state.getSavedValue(),l=r?.minutes&&r.minutes!=="--"?e?.value??"--":"--",c=this.core.options.clock.type==="12h"?a?.textContent??void 0:void 0;this.state.setPreviewValue({hour:i,minutes:l,type:c}),this.ui.updateAll()}handleMinuteCommit(t){if(!this.isEnabled)return;let e={hour:t.hour,minutes:t.minutes,type:t.type??void 0};this.state.getActivePart()==="from"?(this.state.setFromValue(e),this.state.setPreviewValue(null),this.state.isFromComplete()&&(this.state.setActivePart("to"),this.emitter.emit("range:switch",{active:"to",disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart())):(this.state.setToValue(e),this.state.setPreviewValue(null)),this.state.validate(),this.ui.updateAll()}handleAmPm(){if(!this.isEnabled||this.core.options.clock.type!=="12h")return;let e=this.core.getActiveTypeMode()?.textContent;if(!e)return;if(this.state.getActivePart()==="from"){let i=this.state.getFromValue();i&&(this.state.setFromValue({...i,type:e}),this.state.isFromComplete()&&(this.state.setActivePart("to"),this.state.setPreviewValue(null),this.emitter.emit("range:switch",{active:"to",disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart()))}else{let i=this.state.getToValue();i&&this.state.setToValue({...i,type:e}),this.emitter.emit("range:switch",{active:"to",disabledTime:this.state.getDisabledTimeForEndPart()})}this.state.validate(),this.ui.updateAll()}handleConfirm(t){if(!this.isEnabled)return;this.state.commitPreview();let e=this.state.getFromValue(),a=this.state.getToValue(),i=e?o(e):"--:--",r=a?o(a):"--:--",s=this.state.getDuration();this.ui.updateInputValue(),this.emitter.emit("range:confirm",{from:i,to:r,duration:s})}reset(){this.state.reset()}destroy(){this.cleanupHandlers.forEach(t=>t()),this.cleanupHandlers=[],this.reset()}};var A={name:"range",factory:(n,t)=>new u(n,t)};0&&(module.exports={RangeManager,RangePlugin});
|
|
1
|
+
"use strict";var d=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var E=(n,t)=>{for(var e in t)d(n,e,{get:t[e],enumerable:!0})},R=(n,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of P(t))!T.call(n,i)&&i!==e&&d(n,i,{get:()=>t[i],enumerable:!(a=b(t,i))||a.enumerable});return n};var A=n=>R(d({},"__esModule",{value:!0}),n);var S={};E(S,{RangeManager:()=>u,RangePlugin:()=>C});module.exports=A(S);function f(n){if(!n||n==="--:--")return null;let t=n.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);if(t)return{hour:t[1],minutes:t[2],type:t[3].toUpperCase()};let e=n.match(/^(\d{1,2}):(\d{2})$/);return e?{hour:e[1],minutes:e[2]}:null}function o(n){let t=n.minutes==="--"?"--":n.minutes.padStart(2,"0"),e=`${n.hour}:${t}`;return n.type?`${e} ${n.type}`:e}function g(n,t){if(!n)return 0;let e=parseInt(n.hour,10),a=parseInt(n.minutes,10);return t==="12h"&&n.type&&(n.type==="PM"&&e!==12&&(e+=12),n.type==="AM"&&e===12&&(e=0)),e*60+a}function v(n,t,e){if(!n||!t)return 0;let a=g(n,e);return g(t,e)-a}function p(n,t){return n?t==="12h"?!!(n.hour&&n.minutes&&n.type):!!(n.hour&&n.minutes):!1}function V(n){if(!n||!n.includes(" - "))return{from:null,to:null};let t=n.split(" - ").map(e=>e.trim());return t.length!==2||t[0]==="--:--"||t[1]==="--:--"?{from:null,to:null}:{from:f(t[0]),to:f(t[1])}}var m=class{activePart="from";fromValue=null;toValue=null;previewValue=null;clockType;minDuration;maxDuration;emitter;constructor(t,e,a,i){this.clockType=t,this.minDuration=e,this.maxDuration=a,this.emitter=i}getActivePart(){return this.activePart}getFromValue(){return this.fromValue}getToValue(){return this.toValue}getPreviewValue(){return this.previewValue}setFromValue(t){this.fromValue=t}setToValue(t){this.toValue=t}setPreviewValue(t){this.previewValue=t}isFromComplete(){return p(this.fromValue,this.clockType)}isToComplete(){return p(this.toValue,this.clockType)}canSwitchToEnd(){return this.isFromComplete()}canConfirm(){return!this.isFromComplete()||!this.isToComplete()?!1:this.getDuration()>0}setActivePart(t){if(t==="to"&&!this.canSwitchToEnd())return!1;let e=this.activePart!==t;return this.activePart=t,e&&(this.previewValue=null),e}getCurrentValue(){return this.previewValue?this.previewValue:this.activePart==="from"?this.fromValue:this.toValue}getSavedValue(){return this.activePart==="from"?this.fromValue:this.toValue}commitPreview(){this.previewValue&&(this.activePart==="from"?this.fromValue=this.previewValue:this.toValue=this.previewValue,this.previewValue=null)}getDuration(){return v(this.fromValue,this.toValue,this.clockType)}validate(){if(!this.fromValue||!this.toValue)return{valid:!0,duration:0};let t=this.getDuration(),e=!0;return this.minDuration!==void 0&&t<this.minDuration&&(e=!1),this.maxDuration!==void 0&&t>this.maxDuration&&(e=!1),this.emitter.emit("range:validation",{valid:e,duration:t,minDuration:this.minDuration,maxDuration:this.maxDuration}),{valid:e,duration:t}}getDisabledTimeForEndPart(){if(this.activePart==="from"||!this.fromValue||!this.isFromComplete())return null;let t=[],e=[],a=parseInt(this.fromValue.hour,10),i=parseInt(this.fromValue.minutes,10),r=this.fromValue.type;if(this.clockType==="24h"){for(let s=0;s<a;s++)t.push(s.toString().padStart(2,"0"));for(let s=0;s<i;s++)e.push(s.toString().padStart(2,"0"));return{hours:t,minutes:e,fromHour:a}}for(let s=0;s<i;s++)e.push(s.toString().padStart(2,"0"));return{hours:t,minutes:e,fromType:r,fromHour:a}}reset(){this.activePart="from",this.fromValue=null,this.toValue=null,this.previewValue=null}};var c=class{core;state;constructor(t,e){this.core=t,this.state=e}updateTabs(){let t=this.core.getModalElement();if(!t)return;let e=t.querySelector(".tp-ui-range-tab.tp-ui-range-from"),a=t.querySelector(".tp-ui-range-tab.tp-ui-range-to"),i=this.state.getActivePart()==="from",r=this.state.isFromComplete();e?.classList.toggle("active",i),a?.classList.toggle("active",!i),a?.classList.toggle("disabled",!r),e?.setAttribute("aria-selected",String(i)),a?.setAttribute("aria-selected",String(!i)),a?.setAttribute("aria-disabled",String(!r)),e?.setAttribute("tabindex",i?"0":"-1"),a?.setAttribute("tabindex",i||!r?"-1":"0")}updateTimeDisplay(){let t=this.core.getModalElement();if(!t)return;let e=t.querySelector(".tp-ui-range-from-time"),a=t.querySelector(".tp-ui-range-to-time"),i=this.state.getActivePart(),r=this.state.getPreviewValue(),s=this.state.getFromValue(),l=this.state.getToValue(),h=i==="from"&&r?o(r):s?o(s):"--:--",y=i==="to"&&r?o(r):l?o(l):"--:--";e&&(e.textContent=h),a&&(a.textContent=y)}updateOkButton(){let t=this.core.getOkButton();if(!t)return;let e=this.state.canConfirm();t.classList.toggle("disabled",!e),t.setAttribute("aria-disabled",String(!e))}updateInputValue(){let t=this.core.getInput();if(!t)return;let e=this.state.getFromValue(),a=this.state.getToValue(),i=e?o(e):"--:--",r=a?o(a):"--:--";t.value=`${i} - ${r}`}syncClockToActivePart(){let t=this.state.getSavedValue(),e=this.core.getHour(),a=this.core.getMinutes();if(e&&(e.value=t?.hour??"12"),a&&(a.value=t?.minutes??"00"),this.core.options.clock.type==="12h"){let i=this.core.getAM(),r=this.core.getPM();t?.type==="AM"?(i?.classList.add("active"),r?.classList.remove("active")):t?.type==="PM"?(r?.classList.add("active"),i?.classList.remove("active")):(i?.classList.remove("active"),r?.classList.remove("active"))}a&&(a.blur(),a.classList.remove("active")),e&&e.click()}updateAll(){this.updateTabs(),this.updateTimeDisplay(),this.updateOkButton()}};var u=class{core;emitter;state;ui;cleanupHandlers=[];isSyncingAmPm=!1;boundHandleMinuteCommit;boundHandleConfirm;boundHandleUpdate;boundHandleAmPm;constructor(t,e){this.core=t,this.emitter=e;let{range:a,clock:i}=t.options;this.state=new m(i.type,a?.minDuration,a?.maxDuration,e),this.ui=new c(t,this.state),this.boundHandleMinuteCommit=this.handleMinuteCommit.bind(this),this.boundHandleConfirm=this.handleConfirm.bind(this),this.boundHandleUpdate=this.handleUpdate.bind(this),this.boundHandleAmPm=this.handleAmPm.bind(this)}get isEnabled(){return this.core.options.range?.enabled===!0}init(){if(!this.isEnabled)return;let e=this.core.getInput()?.value||"",{from:a,to:i}=V(e);this.state.setFromValue(a),this.state.setToValue(i),this.state.setActivePart("from"),this.state.setPreviewValue(null),this.bindEvents(),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent(),this.ui.updateAll()}getActivePart(){return this.state.getActivePart()}setActivePart(t){if(!this.isEnabled)return;this.state.setActivePart(t)&&this.emitter.emit("range:switch",{active:t,disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent(),this.ui.updateAll()}getFromValue(){return this.state.getFromValue()}getToValue(){return this.state.getToValue()}getDisabledTimeForEndPart(){return this.isEnabled?this.state.getDisabledTimeForEndPart():null}getDuration(){return this.state.getDuration()}validateRange(){return this.isEnabled?this.state.validate():{valid:!0,duration:0}}canConfirm(){return this.isEnabled?this.state.canConfirm():!0}getFormattedRange(){let t=this.state.getFromValue(),e=this.state.getToValue();return!t||!e?null:{from:o(t),to:o(e)}}bindEvents(){let t=this.core.getModalElement();if(!t)return;let e=t.querySelector(".tp-ui-range-tab.tp-ui-range-from"),a=t.querySelector(".tp-ui-range-tab.tp-ui-range-to");if(e){let i=()=>this.setActivePart("from");e.addEventListener("click",i),this.cleanupHandlers.push(()=>e.removeEventListener("click",i))}if(a){let i=()=>this.setActivePart("to");a.addEventListener("click",i),this.cleanupHandlers.push(()=>a.removeEventListener("click",i))}this.emitter.on("update",this.boundHandleUpdate),this.cleanupHandlers.push(()=>this.emitter.off("update",this.boundHandleUpdate)),this.emitter.on("range:minute:commit",this.boundHandleMinuteCommit),this.cleanupHandlers.push(()=>this.emitter.off("range:minute:commit",this.boundHandleMinuteCommit)),this.emitter.on("confirm",this.boundHandleConfirm),this.cleanupHandlers.push(()=>this.emitter.off("confirm",this.boundHandleConfirm)),this.emitter.on("select:am",this.boundHandleAmPm),this.cleanupHandlers.push(()=>this.emitter.off("select:am",this.boundHandleAmPm)),this.emitter.on("select:pm",this.boundHandleAmPm),this.cleanupHandlers.push(()=>this.emitter.off("select:pm",this.boundHandleAmPm))}handleUpdate(){if(!this.isEnabled)return;let t=this.core.getHour(),e=this.core.getMinutes(),a=this.core.getActiveTypeMode(),i=t?.value??"12",r=this.state.getSavedValue(),l=r?.minutes&&r.minutes!=="--"?e?.value??"--":"--",h=this.core.options.clock.type==="12h"?a?.textContent??void 0:void 0;this.state.setPreviewValue({hour:i,minutes:l,type:h}),this.ui.updateAll()}handleMinuteCommit(t){if(!this.isEnabled)return;let e={hour:t.hour,minutes:t.minutes,type:t.type??void 0};this.state.getActivePart()==="from"?(this.state.setFromValue(e),this.state.setPreviewValue(null),this.state.isFromComplete()&&(this.state.setActivePart("to"),this.emitter.emit("range:switch",{active:"to",disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent())):(this.state.setToValue(e),this.state.setPreviewValue(null)),this.state.validate(),this.ui.updateAll()}handleAmPm(){if(!this.isEnabled||this.isSyncingAmPm||this.core.options.clock.type!=="12h")return;let e=this.core.getActiveTypeMode()?.textContent;if(!e)return;if(this.state.getActivePart()==="from"){let i=this.state.getFromValue();i&&(this.state.setFromValue({...i,type:e}),this.state.isFromComplete()&&(this.state.setActivePart("to"),this.state.setPreviewValue(null),this.emitter.emit("range:switch",{active:"to",disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent()))}else{let i=this.state.getToValue();i&&this.state.setToValue({...i,type:e}),this.emitter.emit("range:switch",{active:"to",disabledTime:this.state.getDisabledTimeForEndPart()})}this.state.validate(),this.ui.updateAll()}emitAmPmSyncEvent(){if(this.core.options.clock.type!=="12h")return;let t=this.state.getSavedValue();if(t?.type){this.isSyncingAmPm=!0;try{t.type==="AM"?this.emitter.emit("select:am",{}):t.type==="PM"&&this.emitter.emit("select:pm",{})}finally{this.isSyncingAmPm=!1}}}handleConfirm(t){if(!this.isEnabled)return;this.state.commitPreview();let e=this.state.getFromValue(),a=this.state.getToValue(),i=e?o(e):"--:--",r=a?o(a):"--:--",s=this.state.getDuration();this.ui.updateInputValue(),this.emitter.emit("range:confirm",{from:i,to:r,duration:s})}reset(){this.state.reset()}destroy(){this.cleanupHandlers.forEach(t=>t()),this.cleanupHandlers=[],this.reset()}};var C={name:"range",factory:(n,t)=>new u(n,t)};0&&(module.exports={RangeManager,RangePlugin});
|
package/dist/plugins/range.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function p(n){if(!n||n==="--:--")return null;let t=n.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);if(t)return{hour:t[1],minutes:t[2],type:t[3].toUpperCase()};let e=n.match(/^(\d{1,2}):(\d{2})$/);return e?{hour:e[1],minutes:e[2]}:null}function o(n){let t=n.minutes==="--"?"--":n.minutes.padStart(2,"0"),e=`${n.hour}:${t}`;return n.type?`${e} ${n.type}`:e}function f(n,t){if(!n)return 0;let e=parseInt(n.hour,10),i=parseInt(n.minutes,10);return t==="12h"&&n.type&&(n.type==="PM"&&e!==12&&(e+=12),n.type==="AM"&&e===12&&(e=0)),e*60+i}function g(n,t,e){if(!n||!t)return 0;let i=f(n,e);return f(t,e)-i}function d(n,t){return n?t==="12h"?!!(n.hour&&n.minutes&&n.type):!!(n.hour&&n.minutes):!1}function v(n){if(!n||!n.includes(" - "))return{from:null,to:null};let t=n.split(" - ").map(e=>e.trim());return t.length!==2||t[0]==="--:--"||t[1]==="--:--"?{from:null,to:null}:{from:p(t[0]),to:p(t[1])}}var m=class{activePart="from";fromValue=null;toValue=null;previewValue=null;clockType;minDuration;maxDuration;emitter;constructor(t,e,i,a){this.clockType=t,this.minDuration=e,this.maxDuration=i,this.emitter=a}getActivePart(){return this.activePart}getFromValue(){return this.fromValue}getToValue(){return this.toValue}getPreviewValue(){return this.previewValue}setFromValue(t){this.fromValue=t}setToValue(t){this.toValue=t}setPreviewValue(t){this.previewValue=t}isFromComplete(){return d(this.fromValue,this.clockType)}isToComplete(){return d(this.toValue,this.clockType)}canSwitchToEnd(){return this.isFromComplete()}canConfirm(){return!this.isFromComplete()||!this.isToComplete()?!1:this.getDuration()>0}setActivePart(t){if(t==="to"&&!this.canSwitchToEnd())return!1;let e=this.activePart!==t;return this.activePart=t,e&&(this.previewValue=null),e}getCurrentValue(){return this.previewValue?this.previewValue:this.activePart==="from"?this.fromValue:this.toValue}getSavedValue(){return this.activePart==="from"?this.fromValue:this.toValue}commitPreview(){this.previewValue&&(this.activePart==="from"?this.fromValue=this.previewValue:this.toValue=this.previewValue,this.previewValue=null)}getDuration(){return g(this.fromValue,this.toValue,this.clockType)}validate(){if(!this.fromValue||!this.toValue)return{valid:!0,duration:0};let t=this.getDuration(),e=!0;return this.minDuration!==void 0&&t<this.minDuration&&(e=!1),this.maxDuration!==void 0&&t>this.maxDuration&&(e=!1),this.emitter.emit("range:validation",{valid:e,duration:t,minDuration:this.minDuration,maxDuration:this.maxDuration}),{valid:e,duration:t}}getDisabledTimeForEndPart(){if(this.activePart==="from"||!this.fromValue||!this.isFromComplete())return null;let t=[],e=[],i=parseInt(this.fromValue.hour,10),a=parseInt(this.fromValue.minutes,10),r=this.fromValue.type;if(this.clockType==="24h"){for(let s=0;s<i;s++)t.push(s.toString().padStart(2,"0"));for(let s=0;s<a;s++)e.push(s.toString().padStart(2,"0"));return{hours:t,minutes:e,fromHour:i}}for(let s=0;s<a;s++)e.push(s.toString().padStart(2,"0"));return{hours:t,minutes:e,fromType:r,fromHour:i}}reset(){this.activePart="from",this.fromValue=null,this.toValue=null,this.previewValue=null}};var h=class{core;state;constructor(t,e){this.core=t,this.state=e}updateTabs(){let t=this.core.getModalElement();if(!t)return;let e=t.querySelector(".tp-ui-range-tab.tp-ui-range-from"),i=t.querySelector(".tp-ui-range-tab.tp-ui-range-to"),a=this.state.getActivePart()==="from",r=this.state.isFromComplete();e?.classList.toggle("active",a),i?.classList.toggle("active",!a),i?.classList.toggle("disabled",!r),e?.setAttribute("aria-selected",String(a)),i?.setAttribute("aria-selected",String(!a)),i?.setAttribute("aria-disabled",String(!r)),e?.setAttribute("tabindex",a?"0":"-1"),i?.setAttribute("tabindex",a||!r?"-1":"0")}updateTimeDisplay(){let t=this.core.getModalElement();if(!t)return;let e=t.querySelector(".tp-ui-range-from-time"),i=t.querySelector(".tp-ui-range-to-time"),a=this.state.getActivePart(),r=this.state.getPreviewValue(),s=this.state.getFromValue(),l=this.state.getToValue(),c=a==="from"&&r?o(r):s?o(s):"--:--",V=a==="to"&&r?o(r):l?o(l):"--:--";e&&(e.textContent=c),i&&(i.textContent=V)}updateOkButton(){let t=this.core.getOkButton();if(!t)return;let e=this.state.canConfirm();t.classList.toggle("disabled",!e),t.setAttribute("aria-disabled",String(!e))}updateInputValue(){let t=this.core.getInput();if(!t)return;let e=this.state.getFromValue(),i=this.state.getToValue(),a=e?o(e):"--:--",r=i?o(i):"--:--";t.value=`${a} - ${r}`}syncClockToActivePart(){let t=this.state.getSavedValue(),e=this.core.getHour(),i=this.core.getMinutes();if(e&&(e.value=t?.hour??"12"),i&&(i.value=t?.minutes??"00"),this.core.options.clock.type==="12h"){let a=this.core.getAM(),r=this.core.getPM();t?.type==="AM"?(a?.classList.add("active"),r?.classList.remove("active")):t?.type==="PM"?(r?.classList.add("active"),a?.classList.remove("active")):(a?.classList.remove("active"),r?.classList.remove("active"))}i&&(i.blur(),i.classList.remove("active")),e&&e.click()}updateAll(){this.updateTabs(),this.updateTimeDisplay(),this.updateOkButton()}};var u=class{core;emitter;state;ui;cleanupHandlers=[];boundHandleMinuteCommit;boundHandleConfirm;boundHandleUpdate;boundHandleAmPm;constructor(t,e){this.core=t,this.emitter=e;let{range:i,clock:a}=t.options;this.state=new m(a.type,i?.minDuration,i?.maxDuration,e),this.ui=new h(t,this.state),this.boundHandleMinuteCommit=this.handleMinuteCommit.bind(this),this.boundHandleConfirm=this.handleConfirm.bind(this),this.boundHandleUpdate=this.handleUpdate.bind(this),this.boundHandleAmPm=this.handleAmPm.bind(this)}get isEnabled(){return this.core.options.range?.enabled===!0}init(){if(!this.isEnabled)return;let e=this.core.getInput()?.value||"",{from:i,to:a}=v(e);this.state.setFromValue(i),this.state.setToValue(a),this.state.setActivePart("from"),this.state.setPreviewValue(null),this.bindEvents(),this.ui.syncClockToActivePart(),this.ui.updateAll()}getActivePart(){return this.state.getActivePart()}setActivePart(t){if(!this.isEnabled)return;this.state.setActivePart(t)&&this.emitter.emit("range:switch",{active:t,disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart(),this.ui.updateAll()}getFromValue(){return this.state.getFromValue()}getToValue(){return this.state.getToValue()}getDisabledTimeForEndPart(){return this.isEnabled?this.state.getDisabledTimeForEndPart():null}getDuration(){return this.state.getDuration()}validateRange(){return this.isEnabled?this.state.validate():{valid:!0,duration:0}}canConfirm(){return this.isEnabled?this.state.canConfirm():!0}getFormattedRange(){let t=this.state.getFromValue(),e=this.state.getToValue();return!t||!e?null:{from:o(t),to:o(e)}}bindEvents(){let t=this.core.getModalElement();if(!t)return;let e=t.querySelector(".tp-ui-range-tab.tp-ui-range-from"),i=t.querySelector(".tp-ui-range-tab.tp-ui-range-to");if(e){let a=()=>this.setActivePart("from");e.addEventListener("click",a),this.cleanupHandlers.push(()=>e.removeEventListener("click",a))}if(i){let a=()=>this.setActivePart("to");i.addEventListener("click",a),this.cleanupHandlers.push(()=>i.removeEventListener("click",a))}this.emitter.on("update",this.boundHandleUpdate),this.cleanupHandlers.push(()=>this.emitter.off("update",this.boundHandleUpdate)),this.emitter.on("range:minute:commit",this.boundHandleMinuteCommit),this.cleanupHandlers.push(()=>this.emitter.off("range:minute:commit",this.boundHandleMinuteCommit)),this.emitter.on("confirm",this.boundHandleConfirm),this.cleanupHandlers.push(()=>this.emitter.off("confirm",this.boundHandleConfirm)),this.emitter.on("select:am",this.boundHandleAmPm),this.cleanupHandlers.push(()=>this.emitter.off("select:am",this.boundHandleAmPm)),this.emitter.on("select:pm",this.boundHandleAmPm),this.cleanupHandlers.push(()=>this.emitter.off("select:pm",this.boundHandleAmPm))}handleUpdate(){if(!this.isEnabled)return;let t=this.core.getHour(),e=this.core.getMinutes(),i=this.core.getActiveTypeMode(),a=t?.value??"12",r=this.state.getSavedValue(),l=r?.minutes&&r.minutes!=="--"?e?.value??"--":"--",c=this.core.options.clock.type==="12h"?i?.textContent??void 0:void 0;this.state.setPreviewValue({hour:a,minutes:l,type:c}),this.ui.updateAll()}handleMinuteCommit(t){if(!this.isEnabled)return;let e={hour:t.hour,minutes:t.minutes,type:t.type??void 0};this.state.getActivePart()==="from"?(this.state.setFromValue(e),this.state.setPreviewValue(null),this.state.isFromComplete()&&(this.state.setActivePart("to"),this.emitter.emit("range:switch",{active:"to",disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart())):(this.state.setToValue(e),this.state.setPreviewValue(null)),this.state.validate(),this.ui.updateAll()}handleAmPm(){if(!this.isEnabled||this.core.options.clock.type!=="12h")return;let e=this.core.getActiveTypeMode()?.textContent;if(!e)return;if(this.state.getActivePart()==="from"){let a=this.state.getFromValue();a&&(this.state.setFromValue({...a,type:e}),this.state.isFromComplete()&&(this.state.setActivePart("to"),this.state.setPreviewValue(null),this.emitter.emit("range:switch",{active:"to",disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart()))}else{let a=this.state.getToValue();a&&this.state.setToValue({...a,type:e}),this.emitter.emit("range:switch",{active:"to",disabledTime:this.state.getDisabledTimeForEndPart()})}this.state.validate(),this.ui.updateAll()}handleConfirm(t){if(!this.isEnabled)return;this.state.commitPreview();let e=this.state.getFromValue(),i=this.state.getToValue(),a=e?o(e):"--:--",r=i?o(i):"--:--",s=this.state.getDuration();this.ui.updateInputValue(),this.emitter.emit("range:confirm",{from:a,to:r,duration:s})}reset(){this.state.reset()}destroy(){this.cleanupHandlers.forEach(t=>t()),this.cleanupHandlers=[],this.reset()}};var k={name:"range",factory:(n,t)=>new u(n,t)};export{u as RangeManager,k as RangePlugin};
|
|
1
|
+
function p(n){if(!n||n==="--:--")return null;let t=n.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);if(t)return{hour:t[1],minutes:t[2],type:t[3].toUpperCase()};let e=n.match(/^(\d{1,2}):(\d{2})$/);return e?{hour:e[1],minutes:e[2]}:null}function o(n){let t=n.minutes==="--"?"--":n.minutes.padStart(2,"0"),e=`${n.hour}:${t}`;return n.type?`${e} ${n.type}`:e}function f(n,t){if(!n)return 0;let e=parseInt(n.hour,10),i=parseInt(n.minutes,10);return t==="12h"&&n.type&&(n.type==="PM"&&e!==12&&(e+=12),n.type==="AM"&&e===12&&(e=0)),e*60+i}function g(n,t,e){if(!n||!t)return 0;let i=f(n,e);return f(t,e)-i}function d(n,t){return n?t==="12h"?!!(n.hour&&n.minutes&&n.type):!!(n.hour&&n.minutes):!1}function v(n){if(!n||!n.includes(" - "))return{from:null,to:null};let t=n.split(" - ").map(e=>e.trim());return t.length!==2||t[0]==="--:--"||t[1]==="--:--"?{from:null,to:null}:{from:p(t[0]),to:p(t[1])}}var m=class{activePart="from";fromValue=null;toValue=null;previewValue=null;clockType;minDuration;maxDuration;emitter;constructor(t,e,i,a){this.clockType=t,this.minDuration=e,this.maxDuration=i,this.emitter=a}getActivePart(){return this.activePart}getFromValue(){return this.fromValue}getToValue(){return this.toValue}getPreviewValue(){return this.previewValue}setFromValue(t){this.fromValue=t}setToValue(t){this.toValue=t}setPreviewValue(t){this.previewValue=t}isFromComplete(){return d(this.fromValue,this.clockType)}isToComplete(){return d(this.toValue,this.clockType)}canSwitchToEnd(){return this.isFromComplete()}canConfirm(){return!this.isFromComplete()||!this.isToComplete()?!1:this.getDuration()>0}setActivePart(t){if(t==="to"&&!this.canSwitchToEnd())return!1;let e=this.activePart!==t;return this.activePart=t,e&&(this.previewValue=null),e}getCurrentValue(){return this.previewValue?this.previewValue:this.activePart==="from"?this.fromValue:this.toValue}getSavedValue(){return this.activePart==="from"?this.fromValue:this.toValue}commitPreview(){this.previewValue&&(this.activePart==="from"?this.fromValue=this.previewValue:this.toValue=this.previewValue,this.previewValue=null)}getDuration(){return g(this.fromValue,this.toValue,this.clockType)}validate(){if(!this.fromValue||!this.toValue)return{valid:!0,duration:0};let t=this.getDuration(),e=!0;return this.minDuration!==void 0&&t<this.minDuration&&(e=!1),this.maxDuration!==void 0&&t>this.maxDuration&&(e=!1),this.emitter.emit("range:validation",{valid:e,duration:t,minDuration:this.minDuration,maxDuration:this.maxDuration}),{valid:e,duration:t}}getDisabledTimeForEndPart(){if(this.activePart==="from"||!this.fromValue||!this.isFromComplete())return null;let t=[],e=[],i=parseInt(this.fromValue.hour,10),a=parseInt(this.fromValue.minutes,10),r=this.fromValue.type;if(this.clockType==="24h"){for(let s=0;s<i;s++)t.push(s.toString().padStart(2,"0"));for(let s=0;s<a;s++)e.push(s.toString().padStart(2,"0"));return{hours:t,minutes:e,fromHour:i}}for(let s=0;s<a;s++)e.push(s.toString().padStart(2,"0"));return{hours:t,minutes:e,fromType:r,fromHour:i}}reset(){this.activePart="from",this.fromValue=null,this.toValue=null,this.previewValue=null}};var c=class{core;state;constructor(t,e){this.core=t,this.state=e}updateTabs(){let t=this.core.getModalElement();if(!t)return;let e=t.querySelector(".tp-ui-range-tab.tp-ui-range-from"),i=t.querySelector(".tp-ui-range-tab.tp-ui-range-to"),a=this.state.getActivePart()==="from",r=this.state.isFromComplete();e?.classList.toggle("active",a),i?.classList.toggle("active",!a),i?.classList.toggle("disabled",!r),e?.setAttribute("aria-selected",String(a)),i?.setAttribute("aria-selected",String(!a)),i?.setAttribute("aria-disabled",String(!r)),e?.setAttribute("tabindex",a?"0":"-1"),i?.setAttribute("tabindex",a||!r?"-1":"0")}updateTimeDisplay(){let t=this.core.getModalElement();if(!t)return;let e=t.querySelector(".tp-ui-range-from-time"),i=t.querySelector(".tp-ui-range-to-time"),a=this.state.getActivePart(),r=this.state.getPreviewValue(),s=this.state.getFromValue(),l=this.state.getToValue(),h=a==="from"&&r?o(r):s?o(s):"--:--",V=a==="to"&&r?o(r):l?o(l):"--:--";e&&(e.textContent=h),i&&(i.textContent=V)}updateOkButton(){let t=this.core.getOkButton();if(!t)return;let e=this.state.canConfirm();t.classList.toggle("disabled",!e),t.setAttribute("aria-disabled",String(!e))}updateInputValue(){let t=this.core.getInput();if(!t)return;let e=this.state.getFromValue(),i=this.state.getToValue(),a=e?o(e):"--:--",r=i?o(i):"--:--";t.value=`${a} - ${r}`}syncClockToActivePart(){let t=this.state.getSavedValue(),e=this.core.getHour(),i=this.core.getMinutes();if(e&&(e.value=t?.hour??"12"),i&&(i.value=t?.minutes??"00"),this.core.options.clock.type==="12h"){let a=this.core.getAM(),r=this.core.getPM();t?.type==="AM"?(a?.classList.add("active"),r?.classList.remove("active")):t?.type==="PM"?(r?.classList.add("active"),a?.classList.remove("active")):(a?.classList.remove("active"),r?.classList.remove("active"))}i&&(i.blur(),i.classList.remove("active")),e&&e.click()}updateAll(){this.updateTabs(),this.updateTimeDisplay(),this.updateOkButton()}};var u=class{core;emitter;state;ui;cleanupHandlers=[];isSyncingAmPm=!1;boundHandleMinuteCommit;boundHandleConfirm;boundHandleUpdate;boundHandleAmPm;constructor(t,e){this.core=t,this.emitter=e;let{range:i,clock:a}=t.options;this.state=new m(a.type,i?.minDuration,i?.maxDuration,e),this.ui=new c(t,this.state),this.boundHandleMinuteCommit=this.handleMinuteCommit.bind(this),this.boundHandleConfirm=this.handleConfirm.bind(this),this.boundHandleUpdate=this.handleUpdate.bind(this),this.boundHandleAmPm=this.handleAmPm.bind(this)}get isEnabled(){return this.core.options.range?.enabled===!0}init(){if(!this.isEnabled)return;let e=this.core.getInput()?.value||"",{from:i,to:a}=v(e);this.state.setFromValue(i),this.state.setToValue(a),this.state.setActivePart("from"),this.state.setPreviewValue(null),this.bindEvents(),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent(),this.ui.updateAll()}getActivePart(){return this.state.getActivePart()}setActivePart(t){if(!this.isEnabled)return;this.state.setActivePart(t)&&this.emitter.emit("range:switch",{active:t,disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent(),this.ui.updateAll()}getFromValue(){return this.state.getFromValue()}getToValue(){return this.state.getToValue()}getDisabledTimeForEndPart(){return this.isEnabled?this.state.getDisabledTimeForEndPart():null}getDuration(){return this.state.getDuration()}validateRange(){return this.isEnabled?this.state.validate():{valid:!0,duration:0}}canConfirm(){return this.isEnabled?this.state.canConfirm():!0}getFormattedRange(){let t=this.state.getFromValue(),e=this.state.getToValue();return!t||!e?null:{from:o(t),to:o(e)}}bindEvents(){let t=this.core.getModalElement();if(!t)return;let e=t.querySelector(".tp-ui-range-tab.tp-ui-range-from"),i=t.querySelector(".tp-ui-range-tab.tp-ui-range-to");if(e){let a=()=>this.setActivePart("from");e.addEventListener("click",a),this.cleanupHandlers.push(()=>e.removeEventListener("click",a))}if(i){let a=()=>this.setActivePart("to");i.addEventListener("click",a),this.cleanupHandlers.push(()=>i.removeEventListener("click",a))}this.emitter.on("update",this.boundHandleUpdate),this.cleanupHandlers.push(()=>this.emitter.off("update",this.boundHandleUpdate)),this.emitter.on("range:minute:commit",this.boundHandleMinuteCommit),this.cleanupHandlers.push(()=>this.emitter.off("range:minute:commit",this.boundHandleMinuteCommit)),this.emitter.on("confirm",this.boundHandleConfirm),this.cleanupHandlers.push(()=>this.emitter.off("confirm",this.boundHandleConfirm)),this.emitter.on("select:am",this.boundHandleAmPm),this.cleanupHandlers.push(()=>this.emitter.off("select:am",this.boundHandleAmPm)),this.emitter.on("select:pm",this.boundHandleAmPm),this.cleanupHandlers.push(()=>this.emitter.off("select:pm",this.boundHandleAmPm))}handleUpdate(){if(!this.isEnabled)return;let t=this.core.getHour(),e=this.core.getMinutes(),i=this.core.getActiveTypeMode(),a=t?.value??"12",r=this.state.getSavedValue(),l=r?.minutes&&r.minutes!=="--"?e?.value??"--":"--",h=this.core.options.clock.type==="12h"?i?.textContent??void 0:void 0;this.state.setPreviewValue({hour:a,minutes:l,type:h}),this.ui.updateAll()}handleMinuteCommit(t){if(!this.isEnabled)return;let e={hour:t.hour,minutes:t.minutes,type:t.type??void 0};this.state.getActivePart()==="from"?(this.state.setFromValue(e),this.state.setPreviewValue(null),this.state.isFromComplete()&&(this.state.setActivePart("to"),this.emitter.emit("range:switch",{active:"to",disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent())):(this.state.setToValue(e),this.state.setPreviewValue(null)),this.state.validate(),this.ui.updateAll()}handleAmPm(){if(!this.isEnabled||this.isSyncingAmPm||this.core.options.clock.type!=="12h")return;let e=this.core.getActiveTypeMode()?.textContent;if(!e)return;if(this.state.getActivePart()==="from"){let a=this.state.getFromValue();a&&(this.state.setFromValue({...a,type:e}),this.state.isFromComplete()&&(this.state.setActivePart("to"),this.state.setPreviewValue(null),this.emitter.emit("range:switch",{active:"to",disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent()))}else{let a=this.state.getToValue();a&&this.state.setToValue({...a,type:e}),this.emitter.emit("range:switch",{active:"to",disabledTime:this.state.getDisabledTimeForEndPart()})}this.state.validate(),this.ui.updateAll()}emitAmPmSyncEvent(){if(this.core.options.clock.type!=="12h")return;let t=this.state.getSavedValue();if(t?.type){this.isSyncingAmPm=!0;try{t.type==="AM"?this.emitter.emit("select:am",{}):t.type==="PM"&&this.emitter.emit("select:pm",{})}finally{this.isSyncingAmPm=!1}}}handleConfirm(t){if(!this.isEnabled)return;this.state.commitPreview();let e=this.state.getFromValue(),i=this.state.getToValue(),a=e?o(e):"--:--",r=i?o(i):"--:--",s=this.state.getDuration();this.ui.updateInputValue(),this.emitter.emit("range:confirm",{from:a,to:r,duration:s})}reset(){this.state.reset()}destroy(){this.cleanupHandlers.forEach(t=>t()),this.cleanupHandlers=[],this.reset()}};var H={name:"range",factory:(n,t)=>new u(n,t)};export{u as RangeManager,H as RangePlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TimepickerUIRange={})}(this,function(t){"use strict";function e(t){if(!t||"--:--"===t)return null;const e=t.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);if(e)return{hour:e[1],minutes:e[2],type:e[3].toUpperCase()};const i=t.match(/^(\d{1,2}):(\d{2})$/);return i?{hour:i[1],minutes:i[2]}:null}function i(t){const e="--"===t.minutes?"--":t.minutes.padStart(2,"0"),i=`${t.hour}:${e}`;return t.type?`${i} ${t.type}`:i}function s(t,e){if(!t)return 0;let i=parseInt(t.hour,10);const s=parseInt(t.minutes,10);return"12h"===e&&t.type&&("PM"===t.type&&12!==i&&(i+=12),"AM"===t.type&&12===i&&(i=0)),60*i+s}function a(t,e){return!!t&&("12h"===e?!!(t.hour&&t.minutes&&t.type):!(!t.hour||!t.minutes))}class r{activePart="from";fromValue=null;toValue=null;previewValue=null;clockType;minDuration;maxDuration;emitter;constructor(t,e,i,s){this.clockType=t,this.minDuration=e,this.maxDuration=i,this.emitter=s}getActivePart(){return this.activePart}getFromValue(){return this.fromValue}getToValue(){return this.toValue}getPreviewValue(){return this.previewValue}setFromValue(t){this.fromValue=t}setToValue(t){this.toValue=t}setPreviewValue(t){this.previewValue=t}isFromComplete(){return a(this.fromValue,this.clockType)}isToComplete(){return a(this.toValue,this.clockType)}canSwitchToEnd(){return this.isFromComplete()}canConfirm(){if(!this.isFromComplete()||!this.isToComplete())return!1;return this.getDuration()>0}setActivePart(t){if("to"===t&&!this.canSwitchToEnd())return!1;const e=this.activePart!==t;return this.activePart=t,e&&(this.previewValue=null),e}getCurrentValue(){return this.previewValue?this.previewValue:"from"===this.activePart?this.fromValue:this.toValue}getSavedValue(){return"from"===this.activePart?this.fromValue:this.toValue}commitPreview(){this.previewValue&&("from"===this.activePart?this.fromValue=this.previewValue:this.toValue=this.previewValue,this.previewValue=null)}getDuration(){return function(t,e,i){if(!t||!e)return 0;const a=s(t,i);return s(e,i)-a}(this.fromValue,this.toValue,this.clockType)}validate(){if(!this.fromValue||!this.toValue)return{valid:!0,duration:0};const t=this.getDuration();let e=!0;return void 0!==this.minDuration&&t<this.minDuration&&(e=!1),void 0!==this.maxDuration&&t>this.maxDuration&&(e=!1),this.emitter.emit("range:validation",{valid:e,duration:t,minDuration:this.minDuration,maxDuration:this.maxDuration}),{valid:e,duration:t}}getDisabledTimeForEndPart(){if("from"===this.activePart)return null;if(!this.fromValue||!this.isFromComplete())return null;const t=[],e=[],i=parseInt(this.fromValue.hour,10),s=parseInt(this.fromValue.minutes,10),a=this.fromValue.type;if("24h"===this.clockType){for(let e=0;e<i;e++)t.push(e.toString().padStart(2,"0"));for(let t=0;t<s;t++)e.push(t.toString().padStart(2,"0"));return{hours:t,minutes:e,fromHour:i}}for(let t=0;t<s;t++)e.push(t.toString().padStart(2,"0"));return{hours:t,minutes:e,fromType:a,fromHour:i}}reset(){this.activePart="from",this.fromValue=null,this.toValue=null,this.previewValue=null}}class n{core;state;constructor(t,e){this.core=t,this.state=e}updateTabs(){const t=this.core.getModalElement();if(!t)return;const e=t.querySelector(".tp-ui-range-tab.tp-ui-range-from"),i=t.querySelector(".tp-ui-range-tab.tp-ui-range-to"),s="from"===this.state.getActivePart(),a=this.state.isFromComplete();e?.classList.toggle("active",s),i?.classList.toggle("active",!s),i?.classList.toggle("disabled",!a),e?.setAttribute("aria-selected",String(s)),i?.setAttribute("aria-selected",String(!s)),i?.setAttribute("aria-disabled",String(!a)),e?.setAttribute("tabindex",s?"0":"-1"),i?.setAttribute("tabindex",s||!a?"-1":"0")}updateTimeDisplay(){const t=this.core.getModalElement();if(!t)return;const e=t.querySelector(".tp-ui-range-from-time"),s=t.querySelector(".tp-ui-range-to-time"),a=this.state.getActivePart(),r=this.state.getPreviewValue(),n=this.state.getFromValue(),o=this.state.getToValue(),u="from"===a&&r?i(r):n?i(n):"--:--",l="to"===a&&r?i(r):o?i(o):"--:--";e&&(e.textContent=u),s&&(s.textContent=l)}updateOkButton(){const t=this.core.getOkButton();if(!t)return;const e=this.state.canConfirm();t.classList.toggle("disabled",!e),t.setAttribute("aria-disabled",String(!e))}updateInputValue(){const t=this.core.getInput();if(!t)return;const e=this.state.getFromValue(),s=this.state.getToValue(),a=e?i(e):"--:--",r=s?i(s):"--:--";t.value=`${a} - ${r}`}syncClockToActivePart(){const t=this.state.getSavedValue(),e=this.core.getHour(),i=this.core.getMinutes();if(e&&(e.value=t?.hour??"12"),i&&(i.value=t?.minutes??"00"),"12h"===this.core.options.clock.type){const e=this.core.getAM(),i=this.core.getPM();"AM"===t?.type?(e?.classList.add("active"),i?.classList.remove("active")):"PM"===t?.type?(i?.classList.add("active"),e?.classList.remove("active")):(e?.classList.remove("active"),i?.classList.remove("active"))}i&&(i.blur(),i.classList.remove("active")),e&&e.click()}updateAll(){this.updateTabs(),this.updateTimeDisplay(),this.updateOkButton()}}class o{core;emitter;state;ui;cleanupHandlers=[];boundHandleMinuteCommit;boundHandleConfirm;boundHandleUpdate;boundHandleAmPm;constructor(t,e){this.core=t,this.emitter=e;const{range:i,clock:s}=t.options;this.state=new r(s.type,i?.minDuration,i?.maxDuration,e),this.ui=new n(t,this.state),this.boundHandleMinuteCommit=this.handleMinuteCommit.bind(this),this.boundHandleConfirm=this.handleConfirm.bind(this),this.boundHandleUpdate=this.handleUpdate.bind(this),this.boundHandleAmPm=this.handleAmPm.bind(this)}get isEnabled(){return!0===this.core.options.range?.enabled}init(){if(!this.isEnabled)return;const t=this.core.getInput(),i=t?.value||"",{from:s,to:a}=function(t){if(!t||!t.includes(" - "))return{from:null,to:null};const i=t.split(" - ").map(t=>t.trim());return 2!==i.length||"--:--"===i[0]||"--:--"===i[1]?{from:null,to:null}:{from:e(i[0]),to:e(i[1])}}(i);this.state.setFromValue(s),this.state.setToValue(a),this.state.setActivePart("from"),this.state.setPreviewValue(null),this.bindEvents(),this.ui.syncClockToActivePart(),this.ui.updateAll()}getActivePart(){return this.state.getActivePart()}setActivePart(t){if(!this.isEnabled)return;this.state.setActivePart(t)&&this.emitter.emit("range:switch",{active:t,disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart(),this.ui.updateAll()}getFromValue(){return this.state.getFromValue()}getToValue(){return this.state.getToValue()}getDisabledTimeForEndPart(){return this.isEnabled?this.state.getDisabledTimeForEndPart():null}getDuration(){return this.state.getDuration()}validateRange(){return this.isEnabled?this.state.validate():{valid:!0,duration:0}}canConfirm(){return!this.isEnabled||this.state.canConfirm()}getFormattedRange(){const t=this.state.getFromValue(),e=this.state.getToValue();return t&&e?{from:i(t),to:i(e)}:null}bindEvents(){const t=this.core.getModalElement();if(!t)return;const e=t.querySelector(".tp-ui-range-tab.tp-ui-range-from"),i=t.querySelector(".tp-ui-range-tab.tp-ui-range-to");if(e){const t=()=>this.setActivePart("from");e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}if(i){const t=()=>this.setActivePart("to");i.addEventListener("click",t),this.cleanupHandlers.push(()=>i.removeEventListener("click",t))}this.emitter.on("update",this.boundHandleUpdate),this.cleanupHandlers.push(()=>this.emitter.off("update",this.boundHandleUpdate)),this.emitter.on("range:minute:commit",this.boundHandleMinuteCommit),this.cleanupHandlers.push(()=>this.emitter.off("range:minute:commit",this.boundHandleMinuteCommit)),this.emitter.on("confirm",this.boundHandleConfirm),this.cleanupHandlers.push(()=>this.emitter.off("confirm",this.boundHandleConfirm)),this.emitter.on("select:am",this.boundHandleAmPm),this.cleanupHandlers.push(()=>this.emitter.off("select:am",this.boundHandleAmPm)),this.emitter.on("select:pm",this.boundHandleAmPm),this.cleanupHandlers.push(()=>this.emitter.off("select:pm",this.boundHandleAmPm))}handleUpdate(){if(!this.isEnabled)return;const t=this.core.getHour(),e=this.core.getMinutes(),i=this.core.getActiveTypeMode(),s=t?.value??"12",a=this.state.getSavedValue(),r=a?.minutes&&"--"!==a.minutes?e?.value??"--":"--",n="12h"===this.core.options.clock.type?i?.textContent??void 0:void 0;this.state.setPreviewValue({hour:s,minutes:r,type:n}),this.ui.updateAll()}handleMinuteCommit(t){if(!this.isEnabled)return;const e={hour:t.hour,minutes:t.minutes,type:t.type??void 0};"from"===this.state.getActivePart()?(this.state.setFromValue(e),this.state.setPreviewValue(null),this.state.isFromComplete()&&(this.state.setActivePart("to"),this.emitter.emit("range:switch",{active:"to",disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart())):(this.state.setToValue(e),this.state.setPreviewValue(null)),this.state.validate(),this.ui.updateAll()}handleAmPm(){if(!this.isEnabled)return;if("12h"!==this.core.options.clock.type)return;const t=this.core.getActiveTypeMode(),e=t?.textContent;if(!e)return;if("from"===this.state.getActivePart()){const t=this.state.getFromValue();t&&(this.state.setFromValue({...t,type:e}),this.state.isFromComplete()&&(this.state.setActivePart("to"),this.state.setPreviewValue(null),this.emitter.emit("range:switch",{active:"to",disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart()))}else{const t=this.state.getToValue();t&&this.state.setToValue({...t,type:e}),this.emitter.emit("range:switch",{active:"to",disabledTime:this.state.getDisabledTimeForEndPart()})}this.state.validate(),this.ui.updateAll()}handleConfirm(t){if(!this.isEnabled)return;this.state.commitPreview();const e=this.state.getFromValue(),s=this.state.getToValue(),a=e?i(e):"--:--",r=s?i(s):"--:--",n=this.state.getDuration();this.ui.updateInputValue(),this.emitter.emit("range:confirm",{from:a,to:r,duration:n})}reset(){this.state.reset()}destroy(){this.cleanupHandlers.forEach(t=>t()),this.cleanupHandlers=[],this.reset()}}const u={name:"range",factory:(t,e)=>new o(t,e)};t.RangeManager=o,t.RangePlugin=u});
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TimepickerUIRange={})}(this,function(t){"use strict";function e(t){if(!t||"--:--"===t)return null;const e=t.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);if(e)return{hour:e[1],minutes:e[2],type:e[3].toUpperCase()};const i=t.match(/^(\d{1,2}):(\d{2})$/);return i?{hour:i[1],minutes:i[2]}:null}function i(t){const e="--"===t.minutes?"--":t.minutes.padStart(2,"0"),i=`${t.hour}:${e}`;return t.type?`${i} ${t.type}`:i}function s(t,e){if(!t)return 0;let i=parseInt(t.hour,10);const s=parseInt(t.minutes,10);return"12h"===e&&t.type&&("PM"===t.type&&12!==i&&(i+=12),"AM"===t.type&&12===i&&(i=0)),60*i+s}function a(t,e){return!!t&&("12h"===e?!!(t.hour&&t.minutes&&t.type):!(!t.hour||!t.minutes))}class r{activePart="from";fromValue=null;toValue=null;previewValue=null;clockType;minDuration;maxDuration;emitter;constructor(t,e,i,s){this.clockType=t,this.minDuration=e,this.maxDuration=i,this.emitter=s}getActivePart(){return this.activePart}getFromValue(){return this.fromValue}getToValue(){return this.toValue}getPreviewValue(){return this.previewValue}setFromValue(t){this.fromValue=t}setToValue(t){this.toValue=t}setPreviewValue(t){this.previewValue=t}isFromComplete(){return a(this.fromValue,this.clockType)}isToComplete(){return a(this.toValue,this.clockType)}canSwitchToEnd(){return this.isFromComplete()}canConfirm(){if(!this.isFromComplete()||!this.isToComplete())return!1;return this.getDuration()>0}setActivePart(t){if("to"===t&&!this.canSwitchToEnd())return!1;const e=this.activePart!==t;return this.activePart=t,e&&(this.previewValue=null),e}getCurrentValue(){return this.previewValue?this.previewValue:"from"===this.activePart?this.fromValue:this.toValue}getSavedValue(){return"from"===this.activePart?this.fromValue:this.toValue}commitPreview(){this.previewValue&&("from"===this.activePart?this.fromValue=this.previewValue:this.toValue=this.previewValue,this.previewValue=null)}getDuration(){return function(t,e,i){if(!t||!e)return 0;const a=s(t,i);return s(e,i)-a}(this.fromValue,this.toValue,this.clockType)}validate(){if(!this.fromValue||!this.toValue)return{valid:!0,duration:0};const t=this.getDuration();let e=!0;return void 0!==this.minDuration&&t<this.minDuration&&(e=!1),void 0!==this.maxDuration&&t>this.maxDuration&&(e=!1),this.emitter.emit("range:validation",{valid:e,duration:t,minDuration:this.minDuration,maxDuration:this.maxDuration}),{valid:e,duration:t}}getDisabledTimeForEndPart(){if("from"===this.activePart)return null;if(!this.fromValue||!this.isFromComplete())return null;const t=[],e=[],i=parseInt(this.fromValue.hour,10),s=parseInt(this.fromValue.minutes,10),a=this.fromValue.type;if("24h"===this.clockType){for(let e=0;e<i;e++)t.push(e.toString().padStart(2,"0"));for(let t=0;t<s;t++)e.push(t.toString().padStart(2,"0"));return{hours:t,minutes:e,fromHour:i}}for(let t=0;t<s;t++)e.push(t.toString().padStart(2,"0"));return{hours:t,minutes:e,fromType:a,fromHour:i}}reset(){this.activePart="from",this.fromValue=null,this.toValue=null,this.previewValue=null}}class n{core;state;constructor(t,e){this.core=t,this.state=e}updateTabs(){const t=this.core.getModalElement();if(!t)return;const e=t.querySelector(".tp-ui-range-tab.tp-ui-range-from"),i=t.querySelector(".tp-ui-range-tab.tp-ui-range-to"),s="from"===this.state.getActivePart(),a=this.state.isFromComplete();e?.classList.toggle("active",s),i?.classList.toggle("active",!s),i?.classList.toggle("disabled",!a),e?.setAttribute("aria-selected",String(s)),i?.setAttribute("aria-selected",String(!s)),i?.setAttribute("aria-disabled",String(!a)),e?.setAttribute("tabindex",s?"0":"-1"),i?.setAttribute("tabindex",s||!a?"-1":"0")}updateTimeDisplay(){const t=this.core.getModalElement();if(!t)return;const e=t.querySelector(".tp-ui-range-from-time"),s=t.querySelector(".tp-ui-range-to-time"),a=this.state.getActivePart(),r=this.state.getPreviewValue(),n=this.state.getFromValue(),o=this.state.getToValue(),u="from"===a&&r?i(r):n?i(n):"--:--",l="to"===a&&r?i(r):o?i(o):"--:--";e&&(e.textContent=u),s&&(s.textContent=l)}updateOkButton(){const t=this.core.getOkButton();if(!t)return;const e=this.state.canConfirm();t.classList.toggle("disabled",!e),t.setAttribute("aria-disabled",String(!e))}updateInputValue(){const t=this.core.getInput();if(!t)return;const e=this.state.getFromValue(),s=this.state.getToValue(),a=e?i(e):"--:--",r=s?i(s):"--:--";t.value=`${a} - ${r}`}syncClockToActivePart(){const t=this.state.getSavedValue(),e=this.core.getHour(),i=this.core.getMinutes();if(e&&(e.value=t?.hour??"12"),i&&(i.value=t?.minutes??"00"),"12h"===this.core.options.clock.type){const e=this.core.getAM(),i=this.core.getPM();"AM"===t?.type?(e?.classList.add("active"),i?.classList.remove("active")):"PM"===t?.type?(i?.classList.add("active"),e?.classList.remove("active")):(e?.classList.remove("active"),i?.classList.remove("active"))}i&&(i.blur(),i.classList.remove("active")),e&&e.click()}updateAll(){this.updateTabs(),this.updateTimeDisplay(),this.updateOkButton()}}class o{core;emitter;state;ui;cleanupHandlers=[];isSyncingAmPm=!1;boundHandleMinuteCommit;boundHandleConfirm;boundHandleUpdate;boundHandleAmPm;constructor(t,e){this.core=t,this.emitter=e;const{range:i,clock:s}=t.options;this.state=new r(s.type,i?.minDuration,i?.maxDuration,e),this.ui=new n(t,this.state),this.boundHandleMinuteCommit=this.handleMinuteCommit.bind(this),this.boundHandleConfirm=this.handleConfirm.bind(this),this.boundHandleUpdate=this.handleUpdate.bind(this),this.boundHandleAmPm=this.handleAmPm.bind(this)}get isEnabled(){return!0===this.core.options.range?.enabled}init(){if(!this.isEnabled)return;const t=this.core.getInput(),i=t?.value||"",{from:s,to:a}=function(t){if(!t||!t.includes(" - "))return{from:null,to:null};const i=t.split(" - ").map(t=>t.trim());return 2!==i.length||"--:--"===i[0]||"--:--"===i[1]?{from:null,to:null}:{from:e(i[0]),to:e(i[1])}}(i);this.state.setFromValue(s),this.state.setToValue(a),this.state.setActivePart("from"),this.state.setPreviewValue(null),this.bindEvents(),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent(),this.ui.updateAll()}getActivePart(){return this.state.getActivePart()}setActivePart(t){if(!this.isEnabled)return;this.state.setActivePart(t)&&this.emitter.emit("range:switch",{active:t,disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent(),this.ui.updateAll()}getFromValue(){return this.state.getFromValue()}getToValue(){return this.state.getToValue()}getDisabledTimeForEndPart(){return this.isEnabled?this.state.getDisabledTimeForEndPart():null}getDuration(){return this.state.getDuration()}validateRange(){return this.isEnabled?this.state.validate():{valid:!0,duration:0}}canConfirm(){return!this.isEnabled||this.state.canConfirm()}getFormattedRange(){const t=this.state.getFromValue(),e=this.state.getToValue();return t&&e?{from:i(t),to:i(e)}:null}bindEvents(){const t=this.core.getModalElement();if(!t)return;const e=t.querySelector(".tp-ui-range-tab.tp-ui-range-from"),i=t.querySelector(".tp-ui-range-tab.tp-ui-range-to");if(e){const t=()=>this.setActivePart("from");e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}if(i){const t=()=>this.setActivePart("to");i.addEventListener("click",t),this.cleanupHandlers.push(()=>i.removeEventListener("click",t))}this.emitter.on("update",this.boundHandleUpdate),this.cleanupHandlers.push(()=>this.emitter.off("update",this.boundHandleUpdate)),this.emitter.on("range:minute:commit",this.boundHandleMinuteCommit),this.cleanupHandlers.push(()=>this.emitter.off("range:minute:commit",this.boundHandleMinuteCommit)),this.emitter.on("confirm",this.boundHandleConfirm),this.cleanupHandlers.push(()=>this.emitter.off("confirm",this.boundHandleConfirm)),this.emitter.on("select:am",this.boundHandleAmPm),this.cleanupHandlers.push(()=>this.emitter.off("select:am",this.boundHandleAmPm)),this.emitter.on("select:pm",this.boundHandleAmPm),this.cleanupHandlers.push(()=>this.emitter.off("select:pm",this.boundHandleAmPm))}handleUpdate(){if(!this.isEnabled)return;const t=this.core.getHour(),e=this.core.getMinutes(),i=this.core.getActiveTypeMode(),s=t?.value??"12",a=this.state.getSavedValue(),r=a?.minutes&&"--"!==a.minutes?e?.value??"--":"--",n="12h"===this.core.options.clock.type?i?.textContent??void 0:void 0;this.state.setPreviewValue({hour:s,minutes:r,type:n}),this.ui.updateAll()}handleMinuteCommit(t){if(!this.isEnabled)return;const e={hour:t.hour,minutes:t.minutes,type:t.type??void 0};"from"===this.state.getActivePart()?(this.state.setFromValue(e),this.state.setPreviewValue(null),this.state.isFromComplete()&&(this.state.setActivePart("to"),this.emitter.emit("range:switch",{active:"to",disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent())):(this.state.setToValue(e),this.state.setPreviewValue(null)),this.state.validate(),this.ui.updateAll()}handleAmPm(){if(!this.isEnabled)return;if(this.isSyncingAmPm)return;if("12h"!==this.core.options.clock.type)return;const t=this.core.getActiveTypeMode(),e=t?.textContent;if(!e)return;if("from"===this.state.getActivePart()){const t=this.state.getFromValue();t&&(this.state.setFromValue({...t,type:e}),this.state.isFromComplete()&&(this.state.setActivePart("to"),this.state.setPreviewValue(null),this.emitter.emit("range:switch",{active:"to",disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent()))}else{const t=this.state.getToValue();t&&this.state.setToValue({...t,type:e}),this.emitter.emit("range:switch",{active:"to",disabledTime:this.state.getDisabledTimeForEndPart()})}this.state.validate(),this.ui.updateAll()}emitAmPmSyncEvent(){if("12h"!==this.core.options.clock.type)return;const t=this.state.getSavedValue();if(t?.type){this.isSyncingAmPm=!0;try{"AM"===t.type?this.emitter.emit("select:am",{}):"PM"===t.type&&this.emitter.emit("select:pm",{})}finally{this.isSyncingAmPm=!1}}}handleConfirm(t){if(!this.isEnabled)return;this.state.commitPreview();const e=this.state.getFromValue(),s=this.state.getToValue(),a=e?i(e):"--:--",r=s?i(s):"--:--",n=this.state.getDuration();this.ui.updateInputValue(),this.emitter.emit("range:confirm",{from:a,to:r,duration:n})}reset(){this.state.reset()}destroy(){this.cleanupHandlers.forEach(t=>t()),this.cleanupHandlers=[],this.reset()}}const u={name:"range",factory:(t,e)=>new o(t,e)};t.RangeManager=o,t.RangePlugin=u});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "timepicker-ui",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.7",
|
|
4
4
|
"description": "timepicker-ui is a customizable time picker library built with TypeScript, inspired by Google's Material Design. Lightweight, themeable, and easy to integrate.",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|