UNPKG

devexpress-dashboard-react

Version:

A component that integrates DevExpress Web Dashboard in a React application

230 lines (229 loc) 8.19 kB
"use client"; import * as React from "react"; import { memo, forwardRef, useImperativeHandle, useRef, useMemo } from "react"; import dxDashboardControl from "devexpress-dashboard/integration/index"; import { Component as BaseComponent } from "devextreme-react/core/component"; import NestedOption from "devextreme-react/core/nested-option"; const DashboardControl = memo(forwardRef((props, ref) => { const baseRef = useRef(null); useImperativeHandle(ref, () => ({ instance() { return baseRef.current?.getInstance(); } }), [baseRef.current]); const subscribableOptions = useMemo(() => (["dashboardId", "workingMode"]), []); const independentEvents = useMemo(() => (["onBeforeRender", "onDashboardBeginUpdate", "onDashboardEndUpdate", "onDashboardInitialized", "onDashboardInitializing", "onInitializing", "onItemBeginUpdate", "onItemEndUpdate"]), []); const defaults = useMemo(() => ({ defaultDashboardId: "dashboardId", defaultWorkingMode: "workingMode", }), []); const expectedChildren = useMemo(() => ({ ajaxRemoteService: { optionName: "ajaxRemoteService", isCollectionItem: false }, dataRequestOptions: { optionName: "dataRequestOptions", isCollectionItem: false }, extensions: { optionName: "extensions", isCollectionItem: false }, fetchRemoteService: { optionName: "fetchRemoteService", isCollectionItem: false } }), []); return (React.createElement((BaseComponent), { WidgetClass: dxDashboardControl, ref: baseRef, subscribableOptions, independentEvents, defaults, expectedChildren, ...props, })); })); const _componentAjaxRemoteService = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "ajaxRemoteService", }, }); }; const AjaxRemoteService = Object.assign(_componentAjaxRemoteService, { componentType: "option", }); const _componentChartIndicators = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "chartIndicators", }, }); }; const ChartIndicators = Object.assign(_componentChartIndicators, { componentType: "option", }); const _componentDashboardExport = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "dashboardExport", }, }); }; const DashboardExport = Object.assign(_componentDashboardExport, { componentType: "option", }); const _componentDashboardParameterDialog = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "dashboardParameterDialog", }, }); }; const DashboardParameterDialog = Object.assign(_componentDashboardParameterDialog, { componentType: "option", }); const _componentDataInspector = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "dataInspector", }, }); }; const DataInspector = Object.assign(_componentDataInspector, { componentType: "option", }); const _componentDataRequestOptions = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "dataRequestOptions", }, }); }; const DataRequestOptions = Object.assign(_componentDataRequestOptions, { componentType: "option", }); const _componentDataSourceWizard = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "dataSourceWizard", ExpectedChildren: { wizardSettings: { optionName: "wizardSettings", isCollectionItem: false } }, }, }); }; const DataSourceWizard = Object.assign(_componentDataSourceWizard, { componentType: "option", }); const _componentDesignerToolbar = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "designerToolbar", }, }); }; const DesignerToolbar = Object.assign(_componentDesignerToolbar, { componentType: "option", }); const _componentExtensions = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "extensions", ExpectedChildren: { chartIndicators: { optionName: "chartIndicators", isCollectionItem: false }, dashboardExport: { optionName: "dashboardExport", isCollectionItem: false }, dashboardParameterDialog: { optionName: "dashboardParameterDialog", isCollectionItem: false }, dataInspector: { optionName: "dataInspector", isCollectionItem: false }, dataSourceWizard: { optionName: "dataSourceWizard", isCollectionItem: false }, designerToolbar: { optionName: "designerToolbar", isCollectionItem: false }, itemBindingPanel: { optionName: "itemBindingPanel", isCollectionItem: false }, itemOptionsPanel: { optionName: "itemOptionsPanel", isCollectionItem: false }, mobileLayout: { optionName: "mobileLayout", isCollectionItem: false }, textBoxItemEditor: { optionName: "textBoxItemEditor", isCollectionItem: false }, viewerApi: { optionName: "viewerApi", isCollectionItem: false } }, }, }); }; const Extensions = Object.assign(_componentExtensions, { componentType: "option", }); const _componentFetchRemoteService = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "fetchRemoteService", }, }); }; const FetchRemoteService = Object.assign(_componentFetchRemoteService, { componentType: "option", }); const _componentItemBindingPanel = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "itemBindingPanel", }, }); }; const ItemBindingPanel = Object.assign(_componentItemBindingPanel, { componentType: "option", }); const _componentItemOptionsPanel = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "itemOptionsPanel", }, }); }; const ItemOptionsPanel = Object.assign(_componentItemOptionsPanel, { componentType: "option", }); const _componentMobileLayout = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "mobileLayout", }, }); }; const MobileLayout = Object.assign(_componentMobileLayout, { componentType: "option", }); const _componentTextBoxItemEditor = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "textBoxItemEditor", }, }); }; const TextBoxItemEditor = Object.assign(_componentTextBoxItemEditor, { componentType: "option", }); const _componentViewerApi = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "viewerApi", }, }); }; const ViewerApi = Object.assign(_componentViewerApi, { componentType: "option", }); const _componentWizardSettings = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "wizardSettings", }, }); }; const WizardSettings = Object.assign(_componentWizardSettings, { componentType: "option", }); export default DashboardControl; export { DashboardControl, AjaxRemoteService, ChartIndicators, DashboardExport, DashboardParameterDialog, DataInspector, DataRequestOptions, DataSourceWizard, DesignerToolbar, Extensions, FetchRemoteService, ItemBindingPanel, ItemOptionsPanel, MobileLayout, TextBoxItemEditor, ViewerApi, WizardSettings };