UNPKG

@progress/kendo-react-gantt

Version:

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

9 lines (8 loc) 2.65 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("react"),e=require("prop-types"),o=require("@progress/kendo-date-math"),V=require("../components/BaseView.js"),f=require("../utils/index.js"),T=require("../context/GanttContext.js"),M=require("../constants/index.js"),m=require("../messages/index.js"),O=require("@progress/kendo-react-intl");function C(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return r.default=t,Object.freeze(r)}const a=C(R),w=a.forwardRef((t,r)=>{const{slotWidth:n=h.slotWidth,firstSlotRangeRef:s,timelineHeaderCell:g}=t,{timezone:l}=T.useGanttPropsContext(),u=O.useInternationalization(),d=a.useRef(null),c=a.useRef(null),k=a.useCallback(i=>{c.current&&c.current.scrollIntoView(i)},[]);a.useImperativeHandle(d,()=>({scrollIntoView:k})),a.useImperativeHandle(r,()=>d.current);const D=T.useGanttDateRangeContext(),y=a.useMemo(()=>{const i=[],p=f.getMonthSlots(D,{timezone:l},u);return p.forEach(S=>{const b=f.getWeekSlots(S.range,{timezone:l},u);i.push.apply(i,b)}),s&&i[0]&&(s.current=i[0].range),[p,i]},[l,D.start.getTime(),D.end.getTime(),u]);return a.createElement(V.BaseView,{ref:c,slotWidth:n,slotLevels:y,timelineHeaderCell:g})}),W=({tasksStart:t,tasksEnd:r,timezone:n})=>{const s=o.ZonedDate.fromLocalDate(t,n),g=o.ZonedDate.fromLocalDate(r,n),l=o.firstDayOfMonth(o.getDate(s)),u=o.addDays(o.lastDayOfMonth(o.getDate(g)),1),d=o.ZonedDate.fromUTCDate(f.toUTCDateTime(l),n),c=o.ZonedDate.fromUTCDate(f.toUTCDateTime(u),n);return{start:new Date(d.getTime()),end:new Date(c.getTime()),zonedStart:d,zonedEnd:c}},h={name:"month",dateRange:W,title:t=>t.toLanguageString(m.monthViewTitle,m.messages[m.monthViewTitle]),slotWidth:M.DEFAULT_COLUMN_WIDTH,workWeekStart:1,workWeekEnd:5,workDayStart:"08:00",workDayEnd:"17:00"};w.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};w.displayName="GanttMonthView";exports.GanttMonthView=w;exports.ganttMonthViewDefaultProps=h;