UNPKG

devextreme-react

Version:

DevExtreme React UI and Visualization Components

454 lines (452 loc) • 15.8 kB
/*! * devextreme-react * Version: 24.2.6 * Build date: Mon Mar 17 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file in the root of the project for details. * * https://github.com/DevExpress/devextreme-react */ "use client"; import * as React from "react"; import { memo, forwardRef, useImperativeHandle, useRef, useMemo } from "react"; import dxGantt from "devextreme/ui/gantt"; import { Component as BaseComponent } from "./core/component"; import NestedOption from "./core/nested-option"; const Gantt = memo(forwardRef((props, ref) => { const baseRef = useRef(null); useImperativeHandle(ref, () => ({ instance() { return baseRef.current?.getInstance(); } }), [baseRef.current]); const independentEvents = useMemo(() => (["onContentReady", "onContextMenuPreparing", "onCustomCommand", "onDependencyDeleted", "onDependencyDeleting", "onDependencyInserted", "onDependencyInserting", "onDisposing", "onInitialized", "onResourceAssigned", "onResourceAssigning", "onResourceDeleted", "onResourceDeleting", "onResourceInserted", "onResourceInserting", "onResourceManagerDialogShowing", "onResourceUnassigned", "onResourceUnassigning", "onScaleCellPrepared", "onTaskClick", "onTaskDblClick", "onTaskDeleted", "onTaskDeleting", "onTaskEditDialogShowing", "onTaskInserted", "onTaskInserting", "onTaskMoving", "onTaskUpdated", "onTaskUpdating"]), []); const expectedChildren = useMemo(() => ({ column: { optionName: "columns", isCollectionItem: true }, contextMenu: { optionName: "contextMenu", isCollectionItem: false }, dependencies: { optionName: "dependencies", isCollectionItem: false }, editing: { optionName: "editing", isCollectionItem: false }, filterRow: { optionName: "filterRow", isCollectionItem: false }, ganttHeaderFilter: { optionName: "headerFilter", isCollectionItem: false }, headerFilter: { optionName: "headerFilter", isCollectionItem: false }, resourceAssignments: { optionName: "resourceAssignments", isCollectionItem: false }, resources: { optionName: "resources", isCollectionItem: false }, scaleTypeRange: { optionName: "scaleTypeRange", isCollectionItem: false }, sorting: { optionName: "sorting", isCollectionItem: false }, stripLine: { optionName: "stripLines", isCollectionItem: true }, tasks: { optionName: "tasks", isCollectionItem: false }, toolbar: { optionName: "toolbar", isCollectionItem: false }, validation: { optionName: "validation", isCollectionItem: false } }), []); const templateProps = useMemo(() => ([ { tmplOption: "taskContentTemplate", render: "taskContentRender", component: "taskContentComponent" }, { tmplOption: "taskProgressTooltipContentTemplate", render: "taskProgressTooltipContentRender", component: "taskProgressTooltipContentComponent" }, { tmplOption: "taskTimeTooltipContentTemplate", render: "taskTimeTooltipContentRender", component: "taskTimeTooltipContentComponent" }, { tmplOption: "taskTooltipContentTemplate", render: "taskTooltipContentRender", component: "taskTooltipContentComponent" }, ]), []); return (React.createElement((BaseComponent), { WidgetClass: dxGantt, ref: baseRef, independentEvents, expectedChildren, templateProps, ...props, })); })); const _componentColumn = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "columns", IsCollectionItem: true, DefaultsProps: { defaultFilterValue: "filterValue", defaultFilterValues: "filterValues", defaultSelectedFilterOperation: "selectedFilterOperation", defaultSortIndex: "sortIndex", defaultSortOrder: "sortOrder", defaultVisible: "visible", defaultVisibleIndex: "visibleIndex" }, ExpectedChildren: { columnHeaderFilter: { optionName: "headerFilter", isCollectionItem: false }, format: { optionName: "format", isCollectionItem: false }, headerFilter: { optionName: "headerFilter", isCollectionItem: false } }, TemplateProps: [{ tmplOption: "cellTemplate", render: "cellRender", component: "cellComponent" }, { tmplOption: "headerCellTemplate", render: "headerCellRender", component: "headerCellComponent" }], }, }); }; const Column = Object.assign(_componentColumn, { componentType: "option", }); const _componentColumnHeaderFilter = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "headerFilter", ExpectedChildren: { columnHeaderFilterSearch: { optionName: "search", isCollectionItem: false }, search: { optionName: "search", isCollectionItem: false } }, }, }); }; const ColumnHeaderFilter = Object.assign(_componentColumnHeaderFilter, { componentType: "option", }); const _componentColumnHeaderFilterSearch = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "search", }, }); }; const ColumnHeaderFilterSearch = Object.assign(_componentColumnHeaderFilterSearch, { componentType: "option", }); const _componentContextMenu = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "contextMenu", ExpectedChildren: { contextMenuItem: { optionName: "items", isCollectionItem: true }, item: { optionName: "items", isCollectionItem: true } }, }, }); }; const ContextMenu = Object.assign(_componentContextMenu, { componentType: "option", }); const _componentContextMenuItem = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "items", IsCollectionItem: true, ExpectedChildren: { contextMenuItemItem: { optionName: "items", isCollectionItem: true }, item: { optionName: "items", isCollectionItem: true } }, TemplateProps: [{ tmplOption: "template", render: "render", component: "component" }], }, }); }; const ContextMenuItem = Object.assign(_componentContextMenuItem, { componentType: "option", }); const _componentContextMenuItemItem = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "items", IsCollectionItem: true, TemplateProps: [{ tmplOption: "template", render: "render", component: "component" }], }, }); }; const ContextMenuItemItem = Object.assign(_componentContextMenuItemItem, { componentType: "option", }); const _componentDependencies = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "dependencies", }, }); }; const Dependencies = Object.assign(_componentDependencies, { componentType: "option", }); const _componentEditing = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "editing", }, }); }; const Editing = Object.assign(_componentEditing, { componentType: "option", }); const _componentFilterRow = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "filterRow", ExpectedChildren: { operationDescriptions: { optionName: "operationDescriptions", isCollectionItem: false } }, }, }); }; const FilterRow = Object.assign(_componentFilterRow, { componentType: "option", }); const _componentFormat = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "format", }, }); }; const Format = Object.assign(_componentFormat, { componentType: "option", }); const _componentGanttHeaderFilter = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "headerFilter", ExpectedChildren: { ganttHeaderFilterSearch: { optionName: "search", isCollectionItem: false }, search: { optionName: "search", isCollectionItem: false }, texts: { optionName: "texts", isCollectionItem: false } }, }, }); }; const GanttHeaderFilter = Object.assign(_componentGanttHeaderFilter, { componentType: "option", }); const _componentGanttHeaderFilterSearch = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "search", }, }); }; const GanttHeaderFilterSearch = Object.assign(_componentGanttHeaderFilterSearch, { componentType: "option", }); const _componentHeaderFilter = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "headerFilter", ExpectedChildren: { columnHeaderFilterSearch: { optionName: "search", isCollectionItem: false }, ganttHeaderFilterSearch: { optionName: "search", isCollectionItem: false }, texts: { optionName: "texts", isCollectionItem: false } }, }, }); }; const HeaderFilter = Object.assign(_componentHeaderFilter, { componentType: "option", }); const _componentItem = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "items", IsCollectionItem: true, ExpectedChildren: { contextMenuItemItem: { optionName: "items", isCollectionItem: true }, item: { optionName: "items", isCollectionItem: true } }, TemplateProps: [{ tmplOption: "template", render: "render", component: "component" }, { tmplOption: "menuItemTemplate", render: "menuItemRender", component: "menuItemComponent" }], }, }); }; const Item = Object.assign(_componentItem, { componentType: "option", }); const _componentOperationDescriptions = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "operationDescriptions", }, }); }; const OperationDescriptions = Object.assign(_componentOperationDescriptions, { componentType: "option", }); const _componentResourceAssignments = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "resourceAssignments", }, }); }; const ResourceAssignments = Object.assign(_componentResourceAssignments, { componentType: "option", }); const _componentResources = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "resources", }, }); }; const Resources = Object.assign(_componentResources, { componentType: "option", }); const _componentScaleTypeRange = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "scaleTypeRange", }, }); }; const ScaleTypeRange = Object.assign(_componentScaleTypeRange, { componentType: "option", }); const _componentSearch = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "search", }, }); }; const Search = Object.assign(_componentSearch, { componentType: "option", }); const _componentSorting = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "sorting", }, }); }; const Sorting = Object.assign(_componentSorting, { componentType: "option", }); const _componentStripLine = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "stripLines", IsCollectionItem: true, }, }); }; const StripLine = Object.assign(_componentStripLine, { componentType: "option", }); const _componentTasks = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "tasks", }, }); }; const Tasks = Object.assign(_componentTasks, { componentType: "option", }); const _componentTexts = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "texts", }, }); }; const Texts = Object.assign(_componentTexts, { componentType: "option", }); const _componentToolbar = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "toolbar", ExpectedChildren: { item: { optionName: "items", isCollectionItem: true }, toolbarItem: { optionName: "items", isCollectionItem: true } }, }, }); }; const Toolbar = Object.assign(_componentToolbar, { componentType: "option", }); const _componentToolbarItem = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "items", IsCollectionItem: true, TemplateProps: [{ tmplOption: "menuItemTemplate", render: "menuItemRender", component: "menuItemComponent" }, { tmplOption: "template", render: "render", component: "component" }], }, }); }; const ToolbarItem = Object.assign(_componentToolbarItem, { componentType: "option", }); const _componentValidation = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "validation", }, }); }; const Validation = Object.assign(_componentValidation, { componentType: "option", }); export default Gantt; export { Gantt, Column, ColumnHeaderFilter, ColumnHeaderFilterSearch, ContextMenu, ContextMenuItem, ContextMenuItemItem, Dependencies, Editing, FilterRow, Format, GanttHeaderFilter, GanttHeaderFilterSearch, HeaderFilter, Item, OperationDescriptions, ResourceAssignments, Resources, ScaleTypeRange, Search, Sorting, StripLine, Tasks, Texts, Toolbar, ToolbarItem, Validation };