devextreme-react
Version:
DevExtreme React UI and Visualization Components
371 lines (369 loc) • 12.4 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";
import * as React from "react";
import { memo, forwardRef, useImperativeHandle, useRef, useMemo } from "react";
import dxBarGauge from "devextreme/viz/bar_gauge";
import { Component as BaseComponent } from "./core/component";
import NestedOption from "./core/nested-option";
const BarGauge = memo(forwardRef((props, ref) => {
const baseRef = useRef(null);
useImperativeHandle(ref, () => ({
instance() {
return baseRef.current?.getInstance();
}
}), [baseRef.current]);
const subscribableOptions = useMemo(() => (["loadingIndicator", "loadingIndicator.show", "values"]), []);
const independentEvents = useMemo(() => (["onDisposing", "onDrawn", "onExported", "onExporting", "onFileSaving", "onIncidentOccurred", "onInitialized", "onTooltipHidden", "onTooltipShown"]), []);
const defaults = useMemo(() => ({
defaultLoadingIndicator: "loadingIndicator",
defaultValues: "values",
}), []);
const expectedChildren = useMemo(() => ({
animation: { optionName: "animation", isCollectionItem: false },
barGaugeTitle: { optionName: "title", isCollectionItem: false },
export: { optionName: "export", isCollectionItem: false },
geometry: { optionName: "geometry", isCollectionItem: false },
label: { optionName: "label", isCollectionItem: false },
legend: { optionName: "legend", isCollectionItem: false },
loadingIndicator: { optionName: "loadingIndicator", isCollectionItem: false },
margin: { optionName: "margin", isCollectionItem: false },
size: { optionName: "size", isCollectionItem: false },
title: { optionName: "title", isCollectionItem: false },
tooltip: { optionName: "tooltip", isCollectionItem: false }
}), []);
const templateProps = useMemo(() => ([
{
tmplOption: "centerTemplate",
render: "centerRender",
component: "centerComponent"
},
]), []);
return (React.createElement((BaseComponent), {
WidgetClass: dxBarGauge,
ref: baseRef,
subscribableOptions,
independentEvents,
defaults,
expectedChildren,
templateProps,
...props,
}));
}));
const _componentAnimation = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "animation",
},
});
};
const Animation = Object.assign(_componentAnimation, {
componentType: "option",
});
const _componentBarGaugeTitle = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "title",
ExpectedChildren: {
barGaugeTitleSubtitle: { optionName: "subtitle", isCollectionItem: false },
font: { optionName: "font", isCollectionItem: false },
margin: { optionName: "margin", isCollectionItem: false },
subtitle: { optionName: "subtitle", isCollectionItem: false }
},
},
});
};
const BarGaugeTitle = Object.assign(_componentBarGaugeTitle, {
componentType: "option",
});
const _componentBarGaugeTitleSubtitle = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "subtitle",
ExpectedChildren: {
font: { optionName: "font", isCollectionItem: false }
},
},
});
};
const BarGaugeTitleSubtitle = Object.assign(_componentBarGaugeTitleSubtitle, {
componentType: "option",
});
const _componentBorder = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "border",
},
});
};
const Border = Object.assign(_componentBorder, {
componentType: "option",
});
const _componentExport = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "export",
},
});
};
const Export = Object.assign(_componentExport, {
componentType: "option",
});
const _componentFont = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "font",
},
});
};
const Font = Object.assign(_componentFont, {
componentType: "option",
});
const _componentFormat = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "format",
},
});
};
const Format = Object.assign(_componentFormat, {
componentType: "option",
});
const _componentGeometry = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "geometry",
},
});
};
const Geometry = Object.assign(_componentGeometry, {
componentType: "option",
});
const _componentItemTextFormat = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "itemTextFormat",
},
});
};
const ItemTextFormat = Object.assign(_componentItemTextFormat, {
componentType: "option",
});
const _componentLabel = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "label",
ExpectedChildren: {
font: { optionName: "font", isCollectionItem: false },
format: { optionName: "format", isCollectionItem: false }
},
},
});
};
const Label = Object.assign(_componentLabel, {
componentType: "option",
});
const _componentLegend = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "legend",
ExpectedChildren: {
border: { optionName: "border", isCollectionItem: false },
font: { optionName: "font", isCollectionItem: false },
itemTextFormat: { optionName: "itemTextFormat", isCollectionItem: false },
legendBorder: { optionName: "border", isCollectionItem: false },
legendTitle: { optionName: "title", isCollectionItem: false },
margin: { optionName: "margin", isCollectionItem: false },
title: { optionName: "title", isCollectionItem: false }
},
TemplateProps: [{
tmplOption: "markerTemplate",
render: "markerRender",
component: "markerComponent"
}],
},
});
};
const Legend = Object.assign(_componentLegend, {
componentType: "option",
});
const _componentLegendBorder = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "border",
},
});
};
const LegendBorder = Object.assign(_componentLegendBorder, {
componentType: "option",
});
const _componentLegendTitle = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "title",
ExpectedChildren: {
font: { optionName: "font", isCollectionItem: false },
legendTitleSubtitle: { optionName: "subtitle", isCollectionItem: false },
margin: { optionName: "margin", isCollectionItem: false },
subtitle: { optionName: "subtitle", isCollectionItem: false }
},
},
});
};
const LegendTitle = Object.assign(_componentLegendTitle, {
componentType: "option",
});
const _componentLegendTitleSubtitle = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "subtitle",
ExpectedChildren: {
font: { optionName: "font", isCollectionItem: false }
},
},
});
};
const LegendTitleSubtitle = Object.assign(_componentLegendTitleSubtitle, {
componentType: "option",
});
const _componentLoadingIndicator = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "loadingIndicator",
DefaultsProps: {
defaultShow: "show"
},
ExpectedChildren: {
font: { optionName: "font", isCollectionItem: false }
},
},
});
};
const LoadingIndicator = Object.assign(_componentLoadingIndicator, {
componentType: "option",
});
const _componentMargin = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "margin",
},
});
};
const Margin = Object.assign(_componentMargin, {
componentType: "option",
});
const _componentShadow = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "shadow",
},
});
};
const Shadow = Object.assign(_componentShadow, {
componentType: "option",
});
const _componentSize = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "size",
},
});
};
const Size = Object.assign(_componentSize, {
componentType: "option",
});
const _componentSubtitle = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "subtitle",
ExpectedChildren: {
font: { optionName: "font", isCollectionItem: false }
},
},
});
};
const Subtitle = Object.assign(_componentSubtitle, {
componentType: "option",
});
const _componentTitle = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "title",
ExpectedChildren: {
barGaugeTitleSubtitle: { optionName: "subtitle", isCollectionItem: false },
font: { optionName: "font", isCollectionItem: false },
legendTitleSubtitle: { optionName: "subtitle", isCollectionItem: false },
margin: { optionName: "margin", isCollectionItem: false }
},
},
});
};
const Title = Object.assign(_componentTitle, {
componentType: "option",
});
const _componentTooltip = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "tooltip",
ExpectedChildren: {
border: { optionName: "border", isCollectionItem: false },
font: { optionName: "font", isCollectionItem: false },
format: { optionName: "format", isCollectionItem: false },
shadow: { optionName: "shadow", isCollectionItem: false },
tooltipBorder: { optionName: "border", isCollectionItem: false }
},
TemplateProps: [{
tmplOption: "contentTemplate",
render: "contentRender",
component: "contentComponent"
}],
},
});
};
const Tooltip = Object.assign(_componentTooltip, {
componentType: "option",
});
const _componentTooltipBorder = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "border",
},
});
};
const TooltipBorder = Object.assign(_componentTooltipBorder, {
componentType: "option",
});
export default BarGauge;
export { BarGauge, Animation, BarGaugeTitle, BarGaugeTitleSubtitle, Border, Export, Font, Format, Geometry, ItemTextFormat, Label, Legend, LegendBorder, LegendTitle, LegendTitleSubtitle, LoadingIndicator, Margin, Shadow, Size, Subtitle, Title, Tooltip, TooltipBorder };