UNPKG

@progress/kendo-react-dateinputs

Version:

React DateInput is a perfect input component for handling quick and efficient date values. KendoReact Date Inputs package

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