devextreme-react
Version:
DevExtreme React UI and Visualization Components
386 lines (384 loc) • 12.3 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 dxCircularGauge from "devextreme/viz/circular_gauge";
import { Component as BaseComponent } from "./core/component";
import NestedOption from "./core/nested-option";
const CircularGauge = memo(forwardRef((props, ref) => {
const baseRef = useRef(null);
useImperativeHandle(ref, () => ({
instance() {
return baseRef.current?.getInstance();
}
}), [baseRef.current]);
const subscribableOptions = useMemo(() => (["loadingIndicator", "loadingIndicator.show", "subvalues", "value"]), []);
const independentEvents = useMemo(() => (["onDisposing", "onDrawn", "onExported", "onExporting", "onFileSaving", "onIncidentOccurred", "onInitialized", "onTooltipHidden", "onTooltipShown"]), []);
const defaults = useMemo(() => ({
defaultLoadingIndicator: "loadingIndicator",
defaultSubvalues: "subvalues",
defaultValue: "value",
}), []);
const expectedChildren = useMemo(() => ({
animation: { optionName: "animation", isCollectionItem: false },
export: { optionName: "export", isCollectionItem: false },
geometry: { optionName: "geometry", isCollectionItem: false },
loadingIndicator: { optionName: "loadingIndicator", isCollectionItem: false },
margin: { optionName: "margin", isCollectionItem: false },
rangeContainer: { optionName: "rangeContainer", isCollectionItem: false },
scale: { optionName: "scale", isCollectionItem: false },
size: { optionName: "size", isCollectionItem: false },
subvalueIndicator: { optionName: "subvalueIndicator", isCollectionItem: false },
title: { optionName: "title", isCollectionItem: false },
tooltip: { optionName: "tooltip", isCollectionItem: false },
valueIndicator: { optionName: "valueIndicator", isCollectionItem: false }
}), []);
const templateProps = useMemo(() => ([
{
tmplOption: "centerTemplate",
render: "centerRender",
component: "centerComponent"
},
]), []);
return (React.createElement((BaseComponent), {
WidgetClass: dxCircularGauge,
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 _componentBackgroundColor = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "backgroundColor",
},
});
};
const BackgroundColor = Object.assign(_componentBackgroundColor, {
componentType: "option",
});
const _componentBorder = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "border",
},
});
};
const Border = Object.assign(_componentBorder, {
componentType: "option",
});
const _componentColor = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "color",
},
});
};
const Color = Object.assign(_componentColor, {
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 _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 _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 _componentMinorTick = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "minorTick",
},
});
};
const MinorTick = Object.assign(_componentMinorTick, {
componentType: "option",
});
const _componentRange = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "ranges",
IsCollectionItem: true,
ExpectedChildren: {
color: { optionName: "color", isCollectionItem: false }
},
},
});
};
const Range = Object.assign(_componentRange, {
componentType: "option",
});
const _componentRangeContainer = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "rangeContainer",
ExpectedChildren: {
backgroundColor: { optionName: "backgroundColor", isCollectionItem: false },
range: { optionName: "ranges", isCollectionItem: true }
},
},
});
};
const RangeContainer = Object.assign(_componentRangeContainer, {
componentType: "option",
});
const _componentScale = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "scale",
ExpectedChildren: {
label: { optionName: "label", isCollectionItem: false },
minorTick: { optionName: "minorTick", isCollectionItem: false },
tick: { optionName: "tick", isCollectionItem: false }
},
},
});
};
const Scale = Object.assign(_componentScale, {
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 _componentSubvalueIndicator = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "subvalueIndicator",
ExpectedChildren: {
color: { optionName: "color", isCollectionItem: false },
text: { optionName: "text", isCollectionItem: false }
},
},
});
};
const SubvalueIndicator = Object.assign(_componentSubvalueIndicator, {
componentType: "option",
});
const _componentText = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "text",
ExpectedChildren: {
font: { optionName: "font", isCollectionItem: false },
format: { optionName: "format", isCollectionItem: false }
},
},
});
};
const Text = Object.assign(_componentText, {
componentType: "option",
});
const _componentTick = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "tick",
},
});
};
const Tick = Object.assign(_componentTick, {
componentType: "option",
});
const _componentTitle = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "title",
ExpectedChildren: {
font: { optionName: "font", isCollectionItem: false },
margin: { optionName: "margin", isCollectionItem: false },
subtitle: { optionName: "subtitle", 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 }
},
TemplateProps: [{
tmplOption: "contentTemplate",
render: "contentRender",
component: "contentComponent"
}],
},
});
};
const Tooltip = Object.assign(_componentTooltip, {
componentType: "option",
});
const _componentValueIndicator = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "valueIndicator",
ExpectedChildren: {
color: { optionName: "color", isCollectionItem: false },
text: { optionName: "text", isCollectionItem: false }
},
},
});
};
const ValueIndicator = Object.assign(_componentValueIndicator, {
componentType: "option",
});
export default CircularGauge;
export { CircularGauge, Animation, BackgroundColor, Border, Color, Export, Font, Format, Geometry, Label, LoadingIndicator, Margin, MinorTick, Range, RangeContainer, Scale, Shadow, Size, Subtitle, SubvalueIndicator, Text, Tick, Title, Tooltip, ValueIndicator };