UNPKG

@progress/kendo-react-dateinputs

Version:

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

68 lines (67 loc) 2.94 kB
/** * @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 e from "react"; import i from "prop-types"; import { registerForLocalization as v } from "@progress/kendo-react-intl"; import { classNames as o, uCalendar as c } from "@progress/kendo-react-common"; import { CalendarHeaderTitle as f } from "./CalendarHeaderTitle.mjs"; import { MIN_DATE as T, MAX_DATE as D } from "../../utils.mjs"; const t = class t extends e.Component { constructor() { super(...arguments), this.getTitle = () => { if (!this.props.currentDate) return ""; const s = this.rangeLength - 1, a = this.props.service.title(this.props.currentDate), r = this.props.service.addToDate(this.props.currentDate, s); return s < 1 || !this.props.service.isInRange(r, this.min, this.max) ? a : `${a} - ${this.props.service.title(r)}`; }, this.handleTitleClick = (s) => { this.canMoveUp && this.props.bus.moveUp(this.props.activeView, 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 rangeLength() { return this.props.rangeLength !== void 0 ? this.props.rangeLength : t.defaultProps.rangeLength; } get canMoveUp() { return this.props.bus.canMoveUp(this.props.activeView); } render() { const { activeView: s, commands: a, unstyled: r } = this.props, n = r && r.uCalendar, p = this.getTitle(), m = o(c.title({ c: n })), h = { children: p, value: p, view: s, className: m, onClick: this.handleTitleClick, disabled: !this.canMoveUp }, d = { headerTitleProps: h, commands: a }, u = this.props.headerTitle ? /* @__PURE__ */ e.createElement(this.props.headerTitle, { ...h }, p) : /* @__PURE__ */ e.createElement(f, { ...h }, p), g = this.props.header ? /* @__PURE__ */ e.createElement(this.props.header, { ...d }) : /* @__PURE__ */ e.createElement(e.Fragment, null, u, /* @__PURE__ */ e.createElement("span", { className: o(c.spacer({ c: n })) }), /* @__PURE__ */ e.createElement("span", { className: o(c.nav({ c: n })) }, this.props.commands)); return /* @__PURE__ */ e.createElement("div", { className: o(c.header({ c: n, vertical: this.props.verticalView })) }, g); } }; t.propTypes = { activeView: i.number.isRequired, currentDate: i.instanceOf(Date).isRequired, max: i.instanceOf(Date).isRequired, min: i.instanceOf(Date).isRequired, rangeLength: i.number }, t.defaultProps = { rangeLength: 1, min: T, max: D }; let l = t; v(l); export { l as Header };