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.52 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 b=require("react"),a=require("prop-types"),n=require("@progress/kendo-date-math"),M=require("../components/BaseView.js"),g=require("../utils/index.js"),y=require("../context/GanttContext.js"),S=require("../constants/index.js"),p=require("../messages/index.js"),C=require("@progress/kendo-react-intl");function q(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,s.get?s:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const o=q(b),T=o.forwardRef((e,r)=>{const{slotWidth:t=w.slotWidth,firstSlotRangeRef:s,timelineHeaderCell:D}=e,{timezone:i}=y.useGanttPropsContext(),c=C.useInternationalization(),l=o.useRef(null),u=o.useRef(null),h=o.useCallback(d=>{u.current&&u.current.scrollIntoView(d)},[]);o.useImperativeHandle(l,()=>({scrollIntoView:h})),o.useImperativeHandle(r,()=>l.current);const m=y.useGanttDateRangeContext(),R=o.useMemo(()=>{const d=g.getYearSlots(m,{timezone:i},c),f=[];return d.forEach(V=>{const O=g.getMonthSlots(V.range,{timezone:i},c);f.push.apply(f,O)}),s&&f[0]&&(s.current=f[0].range),[d,f]},[i,m.start.getTime(),m.end.getTime(),c]);return o.createElement(M.BaseView,{slotWidth:t,slotLevels:R,timelineHeaderCell:D})}),Y=({tasksStart:e,tasksEnd:r,timezone:t})=>{const s=n.ZonedDate.fromLocalDate(e,t),D=n.ZonedDate.fromLocalDate(r,t),i=n.firstDayOfMonth(n.firstMonthOfYear(n.getDate(s))),c=n.addDays(n.lastDayOfMonth(n.lastMonthOfYear(n.getDate(D))),1),l=n.ZonedDate.fromUTCDate(g.toUTCDateTime(i),t),u=n.ZonedDate.fromUTCDate(g.toUTCDateTime(c),t);return{start:new Date(l.getTime()),end:new Date(u.getTime()),zonedStart:l,zonedEnd:u}},w={name:"year",dateRange:Y,title:e=>e.toLanguageString(p.yearViewTitle,p.messages[p.yearViewTitle]),slotWidth:S.DEFAULT_COLUMN_WIDTH};T.propTypes={name:a.string,dateRange:a.oneOfType([a.func,a.object]),title:a.oneOfType([a.string,a.func]),slotWidth:a.number};T.displayName="GanttYearView";exports.GanttYearView=T;exports.ganttYearViewDefaultProps=w;