@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.19 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react"),o=require("prop-types"),p=require("@progress/kendo-react-intl"),l=require("@progress/kendo-react-common"),y=require("@progress/kendo-react-buttons"),u=require("@progress/kendo-date-math"),c=require("../../messages/index.js"),n=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 a=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,a.get?a:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const d=b(f),s=class s extends d.Component{constructor(){super(...arguments),this.localization=null,this.handleClick=e=>{if(this.todayIsInRange&&this.props.onClick){const t={syntheticEvent:e,nativeEvent:e.nativeEvent,value:n.dateInRange(n.getToday(),this.min,this.max),target:this,isTodayClick:!0};this.props.onClick.call(void 0,t)}}}get min(){return this.props.min!==void 0?this.props.min:s.defaultProps.min}get max(){return this.props.max!==void 0?this.props.max:s.defaultProps.max}get todayIsInRange(){return n.isInRange(n.getToday(),u.getDate(this.min),u.getDate(this.max))}render(){const{disabled:e,tabIndex:t,unstyled:a}=this.props,m=a&&a.uCalendar;this.localization=p.provideLocalizationService(this);const g=this.localization.toLanguageString(c.today,c.messages[c.today]),h=l.classNames(l.uCalendar.today({c:m,disabled:e}));return d.createElement(y.Button,{className:h,onClick:this.handleClick,tabIndex:t,fillMode:"flat",themeColor:"base",role:"link"},g)}};s.propTypes={max:o.instanceOf(Date).isRequired,min:o.instanceOf(Date).isRequired,onClick:o.func,disabled:o.bool},s.defaultProps={min:n.MIN_DATE,max:n.MAX_DATE};let r=s;p.registerForLocalization(r);exports.TodayCommand=r;