devextreme-react
Version:
DevExtreme React UI and Visualization Components
490 lines (488 loc) • 16.8 kB
JavaScript
/*!
* 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";
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ZoomLevel = exports.ViewToolbar = exports.ToolboxGroup = exports.Toolbox = exports.TabGroup = exports.Tab = exports.PropertiesPanel = exports.PageSizeItem = exports.PageSize = exports.Nodes = exports.MainToolbar = exports.Item = exports.HistoryToolbar = exports.Group = exports.GridSize = exports.Export = exports.Editing = exports.Edges = exports.DefaultItemProperties = exports.CustomShape = exports.ContextToolbox = exports.ContextMenu = exports.ConnectionPoint = exports.CommandItem = exports.Command = exports.AutoLayout = exports.Diagram = void 0;
const React = __importStar(require("react"));
const react_1 = require("react");
const diagram_1 = __importDefault(require("devextreme/ui/diagram"));
const component_1 = require("./core/component");
const nested_option_1 = __importDefault(require("./core/nested-option"));
const Diagram = (0, react_1.memo)((0, react_1.forwardRef)((props, ref) => {
const baseRef = (0, react_1.useRef)(null);
(0, react_1.useImperativeHandle)(ref, () => ({
instance() {
return baseRef.current?.getInstance();
}
}), [baseRef.current]);
const subscribableOptions = (0, react_1.useMemo)(() => (["gridSize", "gridSize.value", "pageSize", "pageSize.height", "pageSize.width", "zoomLevel", "zoomLevel.value"]), []);
const independentEvents = (0, react_1.useMemo)(() => (["onContentReady", "onCustomCommand", "onDisposing", "onInitialized", "onItemClick", "onItemDblClick", "onRequestEditOperation", "onRequestLayoutUpdate"]), []);
const defaults = (0, react_1.useMemo)(() => ({
defaultGridSize: "gridSize",
defaultPageSize: "pageSize",
defaultZoomLevel: "zoomLevel",
}), []);
const expectedChildren = (0, react_1.useMemo)(() => ({
contextMenu: { optionName: "contextMenu", isCollectionItem: false },
contextToolbox: { optionName: "contextToolbox", isCollectionItem: false },
customShape: { optionName: "customShapes", isCollectionItem: true },
defaultItemProperties: { optionName: "defaultItemProperties", isCollectionItem: false },
edges: { optionName: "edges", isCollectionItem: false },
editing: { optionName: "editing", isCollectionItem: false },
export: { optionName: "export", isCollectionItem: false },
gridSize: { optionName: "gridSize", isCollectionItem: false },
historyToolbar: { optionName: "historyToolbar", isCollectionItem: false },
mainToolbar: { optionName: "mainToolbar", isCollectionItem: false },
nodes: { optionName: "nodes", isCollectionItem: false },
pageSize: { optionName: "pageSize", isCollectionItem: false },
propertiesPanel: { optionName: "propertiesPanel", isCollectionItem: false },
toolbox: { optionName: "toolbox", isCollectionItem: false },
viewToolbar: { optionName: "viewToolbar", isCollectionItem: false },
zoomLevel: { optionName: "zoomLevel", isCollectionItem: false }
}), []);
const templateProps = (0, react_1.useMemo)(() => ([
{
tmplOption: "customShapeTemplate",
render: "customShapeRender",
component: "customShapeComponent"
},
{
tmplOption: "customShapeToolboxTemplate",
render: "customShapeToolboxRender",
component: "customShapeToolboxComponent"
},
]), []);
return (React.createElement((component_1.Component), {
WidgetClass: diagram_1.default,
ref: baseRef,
subscribableOptions,
independentEvents,
defaults,
expectedChildren,
templateProps,
...props,
}));
}));
exports.Diagram = Diagram;
const _componentAutoLayout = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "autoLayout",
},
});
};
const AutoLayout = Object.assign(_componentAutoLayout, {
componentType: "option",
});
exports.AutoLayout = AutoLayout;
const _componentCommand = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "commands",
IsCollectionItem: true,
ExpectedChildren: {
item: { optionName: "items", isCollectionItem: true }
},
},
});
};
const Command = Object.assign(_componentCommand, {
componentType: "option",
});
exports.Command = Command;
const _componentCommandItem = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "items",
IsCollectionItem: true,
},
});
};
const CommandItem = Object.assign(_componentCommandItem, {
componentType: "option",
});
exports.CommandItem = CommandItem;
const _componentConnectionPoint = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "connectionPoints",
IsCollectionItem: true,
},
});
};
const ConnectionPoint = Object.assign(_componentConnectionPoint, {
componentType: "option",
});
exports.ConnectionPoint = ConnectionPoint;
const _componentContextMenu = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "contextMenu",
ExpectedChildren: {
command: { optionName: "commands", isCollectionItem: true }
},
},
});
};
const ContextMenu = Object.assign(_componentContextMenu, {
componentType: "option",
});
exports.ContextMenu = ContextMenu;
const _componentContextToolbox = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "contextToolbox",
},
});
};
const ContextToolbox = Object.assign(_componentContextToolbox, {
componentType: "option",
});
exports.ContextToolbox = ContextToolbox;
const _componentCustomShape = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "customShapes",
IsCollectionItem: true,
ExpectedChildren: {
connectionPoint: { optionName: "connectionPoints", isCollectionItem: true }
},
TemplateProps: [{
tmplOption: "template",
render: "render",
component: "component"
}, {
tmplOption: "toolboxTemplate",
render: "toolboxRender",
component: "toolboxComponent"
}],
},
});
};
const CustomShape = Object.assign(_componentCustomShape, {
componentType: "option",
});
exports.CustomShape = CustomShape;
const _componentDefaultItemProperties = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "defaultItemProperties",
},
});
};
const DefaultItemProperties = Object.assign(_componentDefaultItemProperties, {
componentType: "option",
});
exports.DefaultItemProperties = DefaultItemProperties;
const _componentEdges = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "edges",
},
});
};
const Edges = Object.assign(_componentEdges, {
componentType: "option",
});
exports.Edges = Edges;
const _componentEditing = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "editing",
},
});
};
const Editing = Object.assign(_componentEditing, {
componentType: "option",
});
exports.Editing = Editing;
const _componentExport = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "export",
},
});
};
const Export = Object.assign(_componentExport, {
componentType: "option",
});
exports.Export = Export;
const _componentGridSize = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "gridSize",
DefaultsProps: {
defaultValue: "value"
},
},
});
};
const GridSize = Object.assign(_componentGridSize, {
componentType: "option",
});
exports.GridSize = GridSize;
const _componentGroup = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "groups",
IsCollectionItem: true,
ExpectedChildren: {
command: { optionName: "commands", isCollectionItem: true }
},
},
});
};
const Group = Object.assign(_componentGroup, {
componentType: "option",
});
exports.Group = Group;
const _componentHistoryToolbar = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "historyToolbar",
ExpectedChildren: {
command: { optionName: "commands", isCollectionItem: true }
},
},
});
};
const HistoryToolbar = Object.assign(_componentHistoryToolbar, {
componentType: "option",
});
exports.HistoryToolbar = HistoryToolbar;
const _componentItem = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "items",
IsCollectionItem: true,
},
});
};
const Item = Object.assign(_componentItem, {
componentType: "option",
});
exports.Item = Item;
const _componentMainToolbar = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "mainToolbar",
ExpectedChildren: {
command: { optionName: "commands", isCollectionItem: true }
},
},
});
};
const MainToolbar = Object.assign(_componentMainToolbar, {
componentType: "option",
});
exports.MainToolbar = MainToolbar;
const _componentNodes = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "nodes",
ExpectedChildren: {
autoLayout: { optionName: "autoLayout", isCollectionItem: false }
},
},
});
};
const Nodes = Object.assign(_componentNodes, {
componentType: "option",
});
exports.Nodes = Nodes;
const _componentPageSize = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "pageSize",
DefaultsProps: {
defaultHeight: "height",
defaultWidth: "width"
},
ExpectedChildren: {
item: { optionName: "items", isCollectionItem: true },
pageSizeItem: { optionName: "items", isCollectionItem: true }
},
},
});
};
const PageSize = Object.assign(_componentPageSize, {
componentType: "option",
});
exports.PageSize = PageSize;
const _componentPageSizeItem = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "items",
IsCollectionItem: true,
},
});
};
const PageSizeItem = Object.assign(_componentPageSizeItem, {
componentType: "option",
});
exports.PageSizeItem = PageSizeItem;
const _componentPropertiesPanel = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "propertiesPanel",
ExpectedChildren: {
tab: { optionName: "tabs", isCollectionItem: true }
},
},
});
};
const PropertiesPanel = Object.assign(_componentPropertiesPanel, {
componentType: "option",
});
exports.PropertiesPanel = PropertiesPanel;
const _componentTab = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "tabs",
IsCollectionItem: true,
ExpectedChildren: {
command: { optionName: "commands", isCollectionItem: true },
group: { optionName: "groups", isCollectionItem: true },
tabGroup: { optionName: "groups", isCollectionItem: true }
},
},
});
};
const Tab = Object.assign(_componentTab, {
componentType: "option",
});
exports.Tab = Tab;
const _componentTabGroup = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "groups",
IsCollectionItem: true,
ExpectedChildren: {
command: { optionName: "commands", isCollectionItem: true }
},
},
});
};
const TabGroup = Object.assign(_componentTabGroup, {
componentType: "option",
});
exports.TabGroup = TabGroup;
const _componentToolbox = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "toolbox",
ExpectedChildren: {
group: { optionName: "groups", isCollectionItem: true },
toolboxGroup: { optionName: "groups", isCollectionItem: true }
},
},
});
};
const Toolbox = Object.assign(_componentToolbox, {
componentType: "option",
});
exports.Toolbox = Toolbox;
const _componentToolboxGroup = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "groups",
IsCollectionItem: true,
},
});
};
const ToolboxGroup = Object.assign(_componentToolboxGroup, {
componentType: "option",
});
exports.ToolboxGroup = ToolboxGroup;
const _componentViewToolbar = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "viewToolbar",
ExpectedChildren: {
command: { optionName: "commands", isCollectionItem: true }
},
},
});
};
const ViewToolbar = Object.assign(_componentViewToolbar, {
componentType: "option",
});
exports.ViewToolbar = ViewToolbar;
const _componentZoomLevel = (props) => {
return React.createElement((nested_option_1.default), {
...props,
elementDescriptor: {
OptionName: "zoomLevel",
DefaultsProps: {
defaultValue: "value"
},
},
});
};
const ZoomLevel = Object.assign(_componentZoomLevel, {
componentType: "option",
});
exports.ZoomLevel = ZoomLevel;
exports.default = Diagram;