@progress/kendo-react-dateinputs
Version:
React DateInput is a perfect input component for handling quick and efficient date values. KendoReact Date Inputs package
103 lines (102 loc) • 3.1 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 { classNames as v, uCalendar as E } from "@progress/kendo-react-common";
const y = (l, e) => {
const t = Object.getOwnPropertyNames(l), n = Object.getOwnPropertyNames(e);
if (t.length !== n.length)
return !1;
for (let a = 0; a < t.length; a++) {
const o = t[a];
if (l[o] !== e[o])
return !1;
}
return !0;
};
class L extends r.Component {
constructor() {
super(...arguments), this.handleClick = (e) => {
const { onClick: t, value: n } = this.props;
t && t.call(void 0, n, e);
}, this.handleMouseEnter = () => {
const { onMouseEnter: e, value: t } = this.props;
e && e.call(void 0, t);
}, this.handleMouseLeave = () => {
const { onMouseLeave: e, value: t } = this.props;
e && e.call(void 0, t);
};
}
// Manually checking if the component needs an update
// due to date object being compared by instance
// and new Date object is created
// every time and fails the shallow compare of the React.PureComponent.
/**
* @hidden
*/
shouldComponentUpdate(e) {
const { value: t, ...n } = this.props, { value: a, ...o } = e;
return !((!(t && a) || t.getTime() === a.getTime()) && y(n, o));
}
/* eslint-disable max-len */
render() {
const {
className: e,
formattedValue: t,
isWeekend: n,
isFocused: a,
isInRange: o,
isSelected: d,
isRangeStart: i,
isRangeMid: f,
isRangeEnd: c,
isRangeSplitStart: C,
isRangeSplitEnd: M,
isToday: R,
isDisabled: S,
view: O,
value: P,
isOtherMonth: s,
showOtherMonthDays: p,
allowReverse: u,
unstyled: h,
...N
} = this.props, w = this.props.activeRangeEnd === "end" && c, k = this.props.activeRangeEnd === "start" && i, m = h && h.uCalendar, g = v(
E.td({
c: m,
rangeStart: !s && !u && i,
rangeEnd: !s && !u && c,
rangeMid: !s && f,
rangeSplitEnd: !s && M,
rangeSplitStart: !s && C,
active: k || w,
focused: a,
selected: !s && (d || i || c),
today: !s && R,
weekend: n,
disabled: S,
isOtherMonth: s,
isEmpty: !p && s
}),
e
);
return !p && s ? /* @__PURE__ */ r.createElement("td", { role: "gridcell", className: g }) : /* @__PURE__ */ r.createElement(
"td",
{
...N,
className: g,
onClick: this.handleClick,
onMouseEnter: this.handleMouseEnter,
onMouseLeave: this.handleMouseLeave
},
/* @__PURE__ */ r.createElement("span", { className: v(E.link({ c: m })) }, this.props.children)
);
}
}
export {
L as CalendarCell
};