UNPKG

devextreme-react

Version:

DevExtreme React UI and Visualization Components

444 lines (442 loc) 15.2 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 dxVectorMap from "devextreme/viz/vector_map"; import { Component as BaseComponent } from "./core/component"; import NestedOption from "./core/nested-option"; const VectorMap = memo(forwardRef((props, ref) => { const baseRef = useRef(null); useImperativeHandle(ref, () => ({ instance() { return baseRef.current?.getInstance(); } }), [baseRef.current]); const subscribableOptions = useMemo(() => (["loadingIndicator", "loadingIndicator.show"]), []); const independentEvents = useMemo(() => (["onClick", "onDisposing", "onDrawn", "onExported", "onExporting", "onFileSaving", "onIncidentOccurred", "onInitialized", "onTooltipHidden", "onTooltipShown"]), []); const defaults = useMemo(() => ({ defaultLoadingIndicator: "loadingIndicator", }), []); const expectedChildren = useMemo(() => ({ annotation: { optionName: "annotations", isCollectionItem: true }, background: { optionName: "background", isCollectionItem: false }, commonAnnotationSettings: { optionName: "commonAnnotationSettings", isCollectionItem: false }, controlBar: { optionName: "controlBar", isCollectionItem: false }, export: { optionName: "export", isCollectionItem: false }, layer: { optionName: "layers", isCollectionItem: true }, legend: { optionName: "legends", isCollectionItem: true }, loadingIndicator: { optionName: "loadingIndicator", isCollectionItem: false }, projection: { optionName: "projection", isCollectionItem: false }, size: { optionName: "size", isCollectionItem: false }, title: { optionName: "title", isCollectionItem: false }, tooltip: { optionName: "tooltip", isCollectionItem: false }, vectorMapTitle: { optionName: "title", isCollectionItem: false } }), []); return (React.createElement((BaseComponent), { WidgetClass: dxVectorMap, ref: baseRef, subscribableOptions, independentEvents, defaults, expectedChildren, ...props, })); })); const _componentAnnotation = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "annotations", IsCollectionItem: true, ExpectedChildren: { annotationBorder: { optionName: "border", isCollectionItem: false }, border: { optionName: "border", isCollectionItem: false }, font: { optionName: "font", isCollectionItem: false }, image: { optionName: "image", isCollectionItem: false }, shadow: { optionName: "shadow", isCollectionItem: false } }, TemplateProps: [{ tmplOption: "template", render: "render", component: "component" }, { tmplOption: "tooltipTemplate", render: "tooltipRender", component: "tooltipComponent" }], }, }); }; const Annotation = Object.assign(_componentAnnotation, { componentType: "option", }); const _componentAnnotationBorder = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "border", }, }); }; const AnnotationBorder = Object.assign(_componentAnnotationBorder, { componentType: "option", }); const _componentBackground = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "background", }, }); }; const Background = Object.assign(_componentBackground, { componentType: "option", }); const _componentBorder = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "border", }, }); }; const Border = Object.assign(_componentBorder, { componentType: "option", }); const _componentCommonAnnotationSettings = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "commonAnnotationSettings", ExpectedChildren: { annotationBorder: { optionName: "border", isCollectionItem: false }, border: { optionName: "border", isCollectionItem: false }, font: { optionName: "font", isCollectionItem: false }, image: { optionName: "image", isCollectionItem: false }, shadow: { optionName: "shadow", isCollectionItem: false } }, TemplateProps: [{ tmplOption: "template", render: "render", component: "component" }, { tmplOption: "tooltipTemplate", render: "tooltipRender", component: "tooltipComponent" }], }, }); }; const CommonAnnotationSettings = Object.assign(_componentCommonAnnotationSettings, { componentType: "option", }); const _componentControlBar = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "controlBar", }, }); }; const ControlBar = Object.assign(_componentControlBar, { 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 _componentImage = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "image", }, }); }; const Image = Object.assign(_componentImage, { componentType: "option", }); const _componentLabel = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "label", ExpectedChildren: { font: { optionName: "font", isCollectionItem: false } }, }, }); }; const Label = Object.assign(_componentLabel, { componentType: "option", }); const _componentLayer = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "layers", IsCollectionItem: true, ExpectedChildren: { label: { optionName: "label", isCollectionItem: false } }, }, }); }; const Layer = Object.assign(_componentLayer, { componentType: "option", }); const _componentLegend = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "legends", IsCollectionItem: true, ExpectedChildren: { annotationBorder: { optionName: "border", isCollectionItem: false }, border: { optionName: "border", isCollectionItem: false }, font: { optionName: "font", isCollectionItem: false }, legendTitle: { optionName: "title", isCollectionItem: false }, margin: { optionName: "margin", isCollectionItem: false }, source: { optionName: "source", isCollectionItem: false }, title: { optionName: "title", isCollectionItem: false } }, TemplateProps: [{ tmplOption: "markerTemplate", render: "markerRender", component: "markerComponent" }], }, }); }; const Legend = Object.assign(_componentLegend, { 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 _componentProjection = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "projection", }, }); }; const Projection = Object.assign(_componentProjection, { 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 _componentSource = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "source", }, }); }; const Source = Object.assign(_componentSource, { 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: { font: { optionName: "font", isCollectionItem: false }, legendTitleSubtitle: { optionName: "subtitle", isCollectionItem: false }, margin: { optionName: "margin", isCollectionItem: false }, vectorMapTitleSubtitle: { 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 }, 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", }); const _componentVectorMapTitle = (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 }, vectorMapTitleSubtitle: { optionName: "subtitle", isCollectionItem: false } }, }, }); }; const VectorMapTitle = Object.assign(_componentVectorMapTitle, { componentType: "option", }); const _componentVectorMapTitleSubtitle = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "subtitle", ExpectedChildren: { font: { optionName: "font", isCollectionItem: false } }, }, }); }; const VectorMapTitleSubtitle = Object.assign(_componentVectorMapTitleSubtitle, { componentType: "option", }); export default VectorMap; export { VectorMap, Annotation, AnnotationBorder, Background, Border, CommonAnnotationSettings, ControlBar, Export, Font, Image, Label, Layer, Legend, LegendTitle, LegendTitleSubtitle, LoadingIndicator, Margin, Projection, Shadow, Size, Source, Subtitle, Title, Tooltip, TooltipBorder, VectorMapTitle, VectorMapTitleSubtitle };