@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.92 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("react"),t=require("prop-types"),w=require("@progress/kendo-date-math"),I=require("../components/BaseView.js"),s=require("../utils/index.js"),h=require("../context/GanttContext.js"),m=require("../messages/index.js"),P=require("@progress/kendo-react-intl"),j=require("../constants/index.js");function x(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(o,n,i.get?i:{enumerable:!0,get:()=>e[n]})}}return o.default=e,Object.freeze(o)}const a=x(O),S=a.forwardRef((e,o)=>{const{slotWidth:n=r.slotWidth,slotDuration:i=r.slotDuration,firstSlotRangeRef:D,timelineHeaderCell:k}=e,{timezone:l}=h.useGanttPropsContext(),c=P.useInternationalization(),u=a.useRef(null),g=a.useRef(null),C=a.useCallback(f=>{g.current&&g.current.scrollIntoView(f)},[]);a.useImperativeHandle(u,()=>({scrollIntoView:C})),a.useImperativeHandle(o,()=>u.current);const y=h.useGanttDateRangeContext(),T=e.workWeekStart||r.workWeekStart,p=e.workWeekEnd||r.workWeekEnd,E=e.workDayStart||r.workDayStart,W=e.workDayEnd||r.workDayEnd,q=a.useMemo(()=>{const f=s.getWorkDays({workWeekStart:T,workWeekEnd:p}),d=[],b=s.getDaySlots(y,{workDays:f,timezone:l},c);return b.forEach(R=>{const V=s.getHourSlots(R.range,{workDayStart:E,workDayEnd:W,timezone:l,slotDuration:i},c);R.span=V.length,d.push.apply(d,V)}),D&&d[0]&&(D.current=d[0].range),[b,d]},[l,y.start.getTime(),y.end.getTime(),c,T,p,E,W]);return a.createElement(I.BaseView,{ref:g,slotWidth:n,slotLevels:q,timelineHeaderCell:k})}),G=({tasksStart:e,tasksEnd:o,timezone:n})=>{const i=w.ZonedDate.fromLocalDate(e,n),D=w.ZonedDate.fromLocalDate(o,n),k=s.getStartDate(i),l=s.getEndDate(D),c=w.ZonedDate.fromUTCDate(s.toUTCDateTime(k),n),u=w.ZonedDate.fromUTCDate(s.toUTCDateTime(l),n);return{start:new Date(c.getTime()),end:new Date(u.getTime()),zonedStart:c,zonedEnd:u}},r={name:"day",dateRange:G,title:e=>e.toLanguageString(m.dayViewTitle,m.messages[m.dayViewTitle]),slotWidth:j.DEFAULT_COLUMN_WIDTH,slotDuration:60,workWeekStart:1,workWeekEnd:5,workDayStart:"08:00",workDayEnd:"17:00"};S.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};S.displayName="KendoReactGanttDayView";exports.GanttDayView=S;exports.ganttDayViewDefaultProps=r;