UNPKG

@progress/kendo-react-gantt

Version:

React Gantt enables the display of self-referencing tabular data with many features. KendoReact Gantt package

55 lines (54 loc) 2.55 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 t from "react"; import e from "prop-types"; import { ZonedDate as c, firstDayOfMonth as M, firstMonthOfYear as C, getDate as g, addDays as S, lastDayOfMonth as O, lastMonthOfYear as I } from "@progress/kendo-date-math"; import { BaseView as L } from "../components/BaseView.mjs"; import { getYearSlots as Y, getMonthSlots as E, toUTCDateTime as D } from "../utils/index.mjs"; import { useGanttPropsContext as U, useGanttDateRangeContext as W } from "../context/GanttContext.mjs"; import { DEFAULT_COLUMN_WIDTH as b } from "../constants/index.mjs"; import { yearViewTitle as T, messages as G } from "../messages/index.mjs"; import { useInternationalization as H } from "@progress/kendo-react-intl"; const h = t.forwardRef((n, p) => { const { slotWidth: o = v.slotWidth, firstSlotRangeRef: m, timelineHeaderCell: u } = n, { timezone: a } = U(), r = H(), s = t.useRef(null), i = t.useRef(null), y = t.useCallback((f) => { i.current && i.current.scrollIntoView(f); }, []); t.useImperativeHandle(s, () => ({ scrollIntoView: y })), t.useImperativeHandle(p, () => s.current); const d = W(), w = t.useMemo(() => { const f = Y(d, { timezone: a }, r), l = []; return f.forEach((R) => { const V = E(R.range, { timezone: a }, r); l.push.apply(l, V); }), m && l[0] && (m.current = l[0].range), [f, l]; }, [a, d.start.getTime(), d.end.getTime(), r]); return /* @__PURE__ */ t.createElement(L, { slotWidth: o, slotLevels: w, timelineHeaderCell: u }); }), k = ({ tasksStart: n, tasksEnd: p, timezone: o }) => { const m = c.fromLocalDate(n, o), u = c.fromLocalDate(p, o), a = M(C(g(m))), r = S(O(I(g(u))), 1), s = c.fromUTCDate(D(a), o), i = c.fromUTCDate(D(r), o); return { start: new Date(s.getTime()), end: new Date(i.getTime()), zonedStart: s, zonedEnd: i }; }, v = { name: "year", dateRange: k, title: (n) => n.toLanguageString(T, G[T]), slotWidth: b }; h.propTypes = { name: e.string, dateRange: e.oneOfType([e.func, e.object]), title: e.oneOfType([e.string, e.func]), slotWidth: e.number }; h.displayName = "GanttYearView"; export { h as GanttYearView, v as ganttYearViewDefaultProps };