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) 2.78 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 f=require("react"),c=require("prop-types"),T=require("@progress/kendo-react-intl"),a=require("@progress/kendo-react-common"),C=require("./CalendarHeaderTitle.js"),h=require("../../utils.js");function b(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const s=b(f),n=class n extends s.Component{constructor(){super(...arguments),this.getTitle=()=>{if(!this.props.currentDate)return"";const e=this.rangeLength-1,t=this.props.service.title(this.props.currentDate),r=this.props.service.addToDate(this.props.currentDate,e);return e<1||!this.props.service.isInRange(r,this.min,this.max)?t:`${t} - ${this.props.service.title(r)}`},this.handleTitleClick=e=>{this.canMoveUp&&this.props.bus.moveUp(this.props.activeView,e)}}get min(){return this.props.min!==void 0?this.props.min:n.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:n.defaultProps.max}get rangeLength(){return this.props.rangeLength!==void 0?this.props.rangeLength:n.defaultProps.rangeLength}get canMoveUp(){return this.props.bus.canMoveUp(this.props.activeView)}render(){const{activeView:e,commands:t,unstyled:r}=this.props,o=r&&r.uCalendar,p=this.getTitle(),d=a.classNames(a.uCalendar.title({c:o})),u={children:p,value:p,view:e,className:d,onClick:this.handleTitleClick,disabled:!this.canMoveUp},m={headerTitleProps:u,commands:t},g=this.props.headerTitle?s.createElement(this.props.headerTitle,{...u},p):s.createElement(C.CalendarHeaderTitle,{...u},p),v=this.props.header?s.createElement(this.props.header,{...m}):s.createElement(s.Fragment,null,g,s.createElement("span",{className:a.classNames(a.uCalendar.spacer({c:o}))}),s.createElement("span",{className:a.classNames(a.uCalendar.nav({c:o}))},this.props.commands));return s.createElement("div",{className:a.classNames(a.uCalendar.header({c:o,vertical:this.props.verticalView}))},v)}};n.propTypes={activeView:c.number.isRequired,currentDate:c.instanceOf(Date).isRequired,max:c.instanceOf(Date).isRequired,min:c.instanceOf(Date).isRequired,rangeLength:c.number},n.defaultProps={rangeLength:1,min:h.MIN_DATE,max:h.MAX_DATE};let l=n;T.registerForLocalization(l);exports.Header=l;