@progress/kendo-react-gantt
Version:
React Gantt enables the display of self-referencing tabular data with many features. KendoReact Gantt package
71 lines (70 loc) • 2.74 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 e from "react";
import t from "prop-types";
import { ZonedDate as c, firstDayOfMonth as S, getDate as g, addDays as V, lastDayOfMonth as W } from "@progress/kendo-date-math";
import { BaseView as E } from "../components/BaseView.mjs";
import { getMonthSlots as C, getWeekSlots as M, toUTCDateTime as w } from "../utils/index.mjs";
import { useGanttPropsContext as b, useGanttDateRangeContext as I } from "../context/GanttContext.mjs";
import { DEFAULT_COLUMN_WIDTH as L } from "../constants/index.mjs";
import { monthViewTitle as D, messages as O } from "../messages/index.mjs";
import { useInternationalization as U } from "@progress/kendo-react-intl";
const k = e.forwardRef((a, f) => {
const { slotWidth: n = H.slotWidth, firstSlotRangeRef: l, timelineHeaderCell: d } = a, { timezone: s } = b(), i = U(), m = e.useRef(null), r = e.useRef(null), h = e.useCallback((o) => {
r.current && r.current.scrollIntoView(o);
}, []);
e.useImperativeHandle(m, () => ({ scrollIntoView: h })), e.useImperativeHandle(f, () => m.current);
const u = I(), T = e.useMemo(() => {
const o = [], p = C(u, { timezone: s }, i);
return p.forEach((y) => {
const R = M(y.range, { timezone: s }, i);
o.push.apply(o, R);
}), l && o[0] && (l.current = o[0].range), [p, o];
}, [s, u.start.getTime(), u.end.getTime(), i]);
return /* @__PURE__ */ e.createElement(
E,
{
ref: r,
slotWidth: n,
slotLevels: T,
timelineHeaderCell: d
}
);
}), G = ({ tasksStart: a, tasksEnd: f, timezone: n }) => {
const l = c.fromLocalDate(a, n), d = c.fromLocalDate(f, n), s = S(g(l)), i = V(W(g(d)), 1), m = c.fromUTCDate(w(s), n), r = c.fromUTCDate(w(i), n);
return {
start: new Date(m.getTime()),
end: new Date(r.getTime()),
zonedStart: m,
zonedEnd: r
};
}, H = {
name: "month",
dateRange: G,
title: (a) => a.toLanguageString(D, O[D]),
slotWidth: L,
workWeekStart: 1,
workWeekEnd: 5,
workDayStart: "08:00",
workDayEnd: "17:00"
};
k.propTypes = {
name: t.string,
dateRange: t.oneOfType([t.func, t.object]),
title: t.oneOfType([t.string, t.func]),
slotWidth: t.number,
workWeekStart: t.number,
workWeekEnd: t.number,
workDayStart: t.string,
workDayEnd: t.string
};
k.displayName = "GanttMonthView";
export {
k as GanttMonthView,
H as ganttMonthViewDefaultProps
};