UNPKG

@progress/kendo-vue-dateinputs

Version:
9 lines (8 loc) 1.79 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 c=require("@progress/kendo-date-math"),a=(e,t)=>{const n=c.cloneDate(e);return n.setHours(t),n},m=e=>e!==null&&e<12,g=e=>e!==null&&(!e||e>11),d=(e,t,n)=>!t&&!n||e>=t&&e<=n,l=(e,t,n)=>!t&&!n||e>=t||e<=n;class H{constructor(t){this.intl=t}apply(t,n){const s=t.getHours(),r=m(s),i=m(n.getHours());if(r&&i||!r&&!i)return t;const[o,u=24]=this.normalizedRange(),h=s+(i?-12:12);return a(t,Math.min(Math.max(o,h),u||24))}configure(t){const{min:n=this.min,max:s=this.max,part:r=this.part}=t;this.min=n,this.max=s,this.part=r}data(t){const n=this.part.names;if(!n)return[];const s=[],[r,i]=this.normalizedRange(),o=this.intl.dateFormatNames(n);return m(r)&&s.push({text:o.am,value:a(this.min,r)}),g(i)&&s.push({text:o.pm,value:a(this.min,Math.max(12,i))}),this.min.getHours()!==r?s.reverse():s}isRangeChanged(t,n){return!1}limitRange(t,n,s){return[t,n]}total(){const[t,n]=this.normalizedRange();return!t&&!n?2:t>11||n<12?1:2}selectedIndex(t){if(!this.valueInList(t))return-1;const n=Math.floor(t.getHours()/12);return this.min.getHours()===this.normalizedRange()[0]?n:n===0?1:0}valueInList(t){return(this.min.getHours()!==this.normalizedRange()[0]?l:d)(t.getHours(),this.min.getHours(),this.max.getHours())}normalizedRange(){const t=this.min.getHours(),n=this.max.getHours();return[Math.min(t,n),Math.max(t,n)]}}exports.DayPeriodService=H;