devextreme-react
Version:
DevExtreme React UI and Visualization Components
140 lines (138 loc) • 4.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 dxMap from "devextreme/ui/map";
import { Component as BaseComponent } from "./core/component";
import NestedOption from "./core/nested-option";
const Map = memo(forwardRef((props, ref) => {
const baseRef = useRef(null);
useImperativeHandle(ref, () => ({
instance() {
return baseRef.current?.getInstance();
}
}), [baseRef.current]);
const subscribableOptions = useMemo(() => (["center", "markers", "routes", "zoom"]), []);
const independentEvents = useMemo(() => (["onClick", "onDisposing", "onInitialized", "onMarkerAdded", "onMarkerRemoved", "onReady", "onRouteAdded", "onRouteRemoved"]), []);
const defaults = useMemo(() => ({
defaultCenter: "center",
defaultMarkers: "markers",
defaultRoutes: "routes",
defaultZoom: "zoom",
}), []);
const expectedChildren = useMemo(() => ({
apiKey: { optionName: "apiKey", isCollectionItem: false },
center: { optionName: "center", isCollectionItem: false },
marker: { optionName: "markers", isCollectionItem: true },
providerConfig: { optionName: "providerConfig", isCollectionItem: false },
route: { optionName: "routes", isCollectionItem: true }
}), []);
return (React.createElement((BaseComponent), {
WidgetClass: dxMap,
ref: baseRef,
subscribableOptions,
independentEvents,
defaults,
expectedChildren,
...props,
}));
}));
const _componentApiKey = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "apiKey",
},
});
};
const ApiKey = Object.assign(_componentApiKey, {
componentType: "option",
});
const _componentCenter = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "center",
},
});
};
const Center = Object.assign(_componentCenter, {
componentType: "option",
});
const _componentLocation = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "location",
},
});
};
const Location = Object.assign(_componentLocation, {
componentType: "option",
});
const _componentMarker = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "markers",
IsCollectionItem: true,
ExpectedChildren: {
location: { optionName: "location", isCollectionItem: false },
tooltip: { optionName: "tooltip", isCollectionItem: false }
},
},
});
};
const Marker = Object.assign(_componentMarker, {
componentType: "option",
});
const _componentProviderConfig = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "providerConfig",
},
});
};
const ProviderConfig = Object.assign(_componentProviderConfig, {
componentType: "option",
});
const _componentRoute = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "routes",
IsCollectionItem: true,
ExpectedChildren: {
location: { optionName: "locations", isCollectionItem: true }
},
},
});
};
const Route = Object.assign(_componentRoute, {
componentType: "option",
});
const _componentTooltip = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "tooltip",
},
});
};
const Tooltip = Object.assign(_componentTooltip, {
componentType: "option",
});
export default Map;
export { Map, ApiKey, Center, Location, Marker, ProviderConfig, Route, Tooltip };