UNPKG

@progress/kendo-react-gantt

Version:

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

101 lines (100 loc) 3.34 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 t from "prop-types"; import { ZonedDate as m } from "@progress/kendo-date-math"; import { BaseView as I } from "../components/BaseView.mjs"; import { getWorkDays as L, getDaySlots as H, getHourSlots as U, getStartDate as G, getEndDate as v, toUTCDateTime as R } from "../utils/index.mjs"; import { useGanttPropsContext as x, useGanttDateRangeContext as z } from "../context/GanttContext.mjs"; import { dayViewTitle as V, messages as O } from "../messages/index.mjs"; import { useInternationalization as P } from "@progress/kendo-react-intl"; import { DEFAULT_COLUMN_WIDTH as M } from "../constants/index.mjs"; const h = o.forwardRef((e, D) => { const { slotWidth: r = a.slotWidth, slotDuration: d = a.slotDuration, firstSlotRangeRef: c, timelineHeaderCell: k } = e, { timezone: s } = x(), n = P(), i = o.useRef(null), u = o.useRef(null), C = o.useCallback((f) => { u.current && u.current.scrollIntoView(f); }, []); o.useImperativeHandle(i, () => ({ scrollIntoView: C })), o.useImperativeHandle(D, () => i.current); const w = z(), g = e.workWeekStart || a.workWeekStart, y = e.workWeekEnd || a.workWeekEnd, p = e.workDayStart || a.workDayStart, S = e.workDayEnd || a.workDayEnd, b = o.useMemo(() => { const f = L({ workWeekStart: g, workWeekEnd: y }), l = [], T = H(w, { workDays: f, timezone: s }, n); return T.forEach((E) => { const W = U( E.range, { workDayStart: p, workDayEnd: S, timezone: s, slotDuration: d }, n ); E.span = W.length, l.push.apply(l, W); }), c && l[0] && (c.current = l[0].range), [T, l]; }, [ s, w.start.getTime(), w.end.getTime(), n, g, y, p, S ]); return /* @__PURE__ */ o.createElement( I, { ref: u, slotWidth: r, slotLevels: b, timelineHeaderCell: k } ); }), N = ({ tasksStart: e, tasksEnd: D, timezone: r }) => { const d = m.fromLocalDate(e, r), c = m.fromLocalDate(D, r), k = G(d), s = v(c), n = m.fromUTCDate(R(k), r), i = m.fromUTCDate(R(s), r); return { // Sat May 31 2014 07:00:00 GMT+0300 (Eastern European Summer Time) start: new Date(n.getTime()), end: new Date(i.getTime()), // Sat May 31 2014 00:00:00 GMT-0400 (EDT) zonedStart: n, zonedEnd: i }; }, a = { name: "day", dateRange: N, title: (e) => e.toLanguageString(V, O[V]), slotWidth: M, slotDuration: 60, workWeekStart: 1, workWeekEnd: 5, workDayStart: "08:00", workDayEnd: "17:00" }; h.propTypes = { name: t.string, dateRange: t.oneOfType([t.func, t.object]), title: t.oneOfType([t.string, t.func]), slotWidth: t.number, slotDuration: t.number, workWeekStart: t.number, workWeekEnd: t.number, workDayStart: t.string, workDayEnd: t.string }; h.displayName = "KendoReactGanttDayView"; export { h as GanttDayView, a as ganttDayViewDefaultProps };