UNPKG

@progress/kendo-react-gantt

Version:

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

74 lines (73 loc) 2.98 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 o from "react"; import e from "prop-types"; import { ZonedDate as l, firstDayInWeek as y, getDate as T } from "@progress/kendo-date-math"; import { BaseView as b } from "../components/BaseView.mjs"; import { getWeekSlots as h, getDaySlots as L, getWorkDays as U, getStartDate as _, getEndDate as G, toUTCDateTime as S } from "../utils/index.mjs"; import { useGanttPropsContext as H, useGanttDateRangeContext as N } from "../context/GanttContext.mjs"; import { DEFAULT_COLUMN_WIDTH as O, DAYS_IN_WEEK_COUNT as v } from "../constants/index.mjs"; import { weekViewTitle as E, messages as x } from "../messages/index.mjs"; import { useInternationalization as z } from "@progress/kendo-react-intl"; const R = o.forwardRef((t, m) => { const { slotWidth: f = g.slotWidth, firstSlotRangeRef: r, timelineHeaderCell: w } = t, { timezone: a } = H(), s = z(), c = o.useRef(null), n = o.useRef(null), k = o.useCallback((D) => { n.current && n.current.scrollIntoView(D); }, []); o.useImperativeHandle(c, () => ({ scrollIntoView: k })), o.useImperativeHandle(m, () => c.current); const d = N(), u = t.workWeekStart || g.workWeekStart, W = t.workWeekEnd || g.workWeekEnd, V = o.useMemo(() => { const D = U({ workWeekStart: u, workWeekEnd: W }), i = [], p = h(d, { timezone: a }, s); return p.forEach((C) => { const I = L(C.range, { workDays: D, timezone: a }, s); i.push.apply(i, I); }), r && i[0] && (r.current = i[0].range), [p, i]; }, [a, d.start.getTime(), d.end.getTime(), s, u, W]); return /* @__PURE__ */ o.createElement( b, { ref: n, slotWidth: f, slotLevels: V, timelineHeaderCell: w } ); }), P = ({ intl: t, tasksStart: m, tasksEnd: f, timezone: r }) => { const w = l.fromLocalDate(m, r), a = l.fromLocalDate(f, r), s = _(y(T(w), t.firstDay())), c = G(y(T(a), t.firstDay()), v), n = l.fromUTCDate(S(s), r), k = l.fromUTCDate(S(c), r); return { start: new Date(n.getTime()), end: new Date(k.getTime()), zonedStart: n, zonedEnd: k }; }, g = { name: "week", dateRange: P, title: (t) => t.toLanguageString(E, x[E]), slotWidth: O, workWeekStart: 1, workWeekEnd: 5, workDayStart: "08:00", workDayEnd: "17:00" }; R.propTypes = { name: e.string, dateRange: e.oneOfType([e.func, e.object]), title: e.oneOfType([e.string, e.func]), slotWidth: e.number, workWeekStart: e.number, workWeekEnd: e.number, workDayStart: e.string, workDayEnd: e.string }; R.displayName = "KendoReactGanttWeekView"; export { R as GanttWeekView, g as ganttWeekViewDefaultProps };