UNPKG

@progress/kendo-vue-dateinputs

Version:
9 lines (8 loc) 2.46 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@progress/kendo-date-math");require("@progress/kendo-vue-intl");const S=require("../../utils.js"),r=require("../utils.js"),d=60,p=n=>t=>t%n,g=p(d),x=(n,t)=>s=>g(n+s*t),m=(n,t)=>g(d+n-t),u=n=>(t,s)=>!s||t.getMinutes()===s.getMinutes()&&t.getHours()===s.getHours()?t:r.setSeconds(t,n),l=u(0),I=u(d-1);class f{constructor(t){this.intl=t,this.insertUndividedMax=!1}apply(t,s){return r.setSeconds(t,s.getSeconds())}configure(t){const{insertUndividedMax:s=this.insertUndividedMax,min:i=this.min,max:o=this.max,part:e,step:c=this.step}=t;this.insertUndividedMax=s,this.toListItem=M=>{const h=r.setSeconds(S.MIDNIGHT_DATE,M);return{text:this.intl.formatDate(h,e.pattern),value:h}},this.min=i,this.max=o,this.step=c}data(t){const[s]=this.range(t),i=x(s,this.step),o=c=>this.toListItem(i(c)),e=r.range(0,this.countFromMin(t)).map(o);return this.addLast(e),t&&this.addMissing(e,t),e}isRangeChanged(t,s){return!a.isEqual(this.min,t)||!a.isEqual(this.max,s)}limitRange(t,s,i){return[l(t,i),I(s,i)]}total(t){const s=this.insertUndividedMax&&this.isLastMissing(t)?1:0,i=this.isMissing(t)?1:0;return this.countFromMin(t)+i+s}selectedIndex(t){return Math.ceil(this.divideByStep(t))}valueInList(t){return t?this.insertUndividedMax&&this.lastSecond(t)===t.getSeconds()||!this.isMissing(t):!0}divideByStep(t){return m(t.getSeconds(),this.min.getSeconds())/this.step}addLast(t,s){return this.insertUndividedMax&&this.isLastMissing(s)&&t.push(this.toListItem(this.lastSecond(s))),t}addMissing(t,s){if(this.valueInList(s))return t;const i=this.toListItem(s.getSeconds());return t.splice(this.selectedIndex(s),0,i),t}countFromMin(t){const[s,i]=this.range(t);return Math.floor(m(i,s)/this.step)+1}isMissing(t){return t?this.selectedIndex(t)!==this.divideByStep(t):!1}isLastMissing(t){return this.isMissing(r.setSeconds(this.max,this.lastSecond(t)))}lastSecond(t){return this.range(t)[1]}range(t){const[s,i]=this.limitRange(this.min,this.max,t);return[s.getSeconds(),i.getSeconds()]}}exports.SecondsService=f;