@progress/kendo-react-dateinputs
Version:
React DateInput is a perfect input component for handling quick and efficient date values. KendoReact Date Inputs package
72 lines (71 loc) • 2.33 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
*-------------------------------------------------------------------------------------------
*/
import * as r from "react";
import e from "prop-types";
import { provideLocalizationService as h, registerForLocalization as u } from "@progress/kendo-react-intl";
import { classNames as f, uCalendar as g } from "@progress/kendo-react-common";
import { Button as x } from "@progress/kendo-react-buttons";
import { getDate as n } from "@progress/kendo-date-math";
import { today as l, messages as v } from "../../messages/index.mjs";
import { dateInRange as C, getToday as m, MIN_DATE as k, MAX_DATE as I, isInRange as y } from "../../utils.mjs";
const t = class t extends r.Component {
constructor() {
super(...arguments), this.localization = null, this.handleClick = (i) => {
if (this.todayIsInRange && this.props.onClick) {
const s = {
syntheticEvent: i,
nativeEvent: i.nativeEvent,
value: C(m(), this.min, this.max),
target: this,
isTodayClick: !0
};
this.props.onClick.call(void 0, s);
}
};
}
get min() {
return this.props.min !== void 0 ? this.props.min : t.defaultProps.min;
}
get max() {
return this.props.max !== void 0 ? this.props.max : t.defaultProps.max;
}
get todayIsInRange() {
return y(m(), n(this.min), n(this.max));
}
render() {
const { disabled: i, tabIndex: s, unstyled: o } = this.props, p = o && o.uCalendar;
this.localization = h(this);
const c = this.localization.toLanguageString(l, v[l]), d = f(g.today({ c: p, disabled: i }));
return /* @__PURE__ */ r.createElement(
x,
{
className: d,
onClick: this.handleClick,
tabIndex: s,
fillMode: "flat",
themeColor: "base",
role: "link"
},
c
);
}
};
t.propTypes = {
max: e.instanceOf(Date).isRequired,
min: e.instanceOf(Date).isRequired,
onClick: e.func,
disabled: e.bool
}, t.defaultProps = {
min: k,
max: I
};
let a = t;
u(a);
export {
a as TodayCommand
};