UNPKG

@iminside/react-yandex-maps

Version:
1 lines 114 kB
{"version":3,"file":"react-yandex-maps.modern.mjs","sources":["../src/util/omit.ts","../src/Context.tsx","../src/hooks/useYMaps.ts","../src/hocs/withYMaps.tsx","../src/util/set.ts","../src/util/is-browser.ts","../src/util/create-api-loader.ts","../src/Provider.tsx","../src/util/events.ts","../src/util/props.ts","../src/util/ref.ts","../src/util/getParentElementSize.ts","../src/hocs/with-error-boundary.tsx","../src/Map.tsx","../src/Panorama.tsx","../src/controls/BaseControl.tsx","../src/controls/Button.tsx","../src/controls/FullscreenControl.tsx","../src/controls/GeolocationControl.tsx","../src/controls/ListBox.tsx","../src/controls/ListBoxItem.tsx","../src/controls/RouteButton.tsx","../src/controls/RouteEditor.tsx","../src/controls/RoutePanel.tsx","../src/controls/RulerControl.tsx","../src/controls/SearchControl.tsx","../src/controls/TrafficControl.tsx","../src/controls/TypeSelector.tsx","../src/controls/ZoomControl.tsx","../src/clusterization/Clusterer.tsx","../src/clusterization/ObjectManager.tsx","../src/geo-objects/BaseGeoObject.tsx","../src/geo-objects/GeoObject.tsx","../src/geo-objects/Circle.tsx","../src/geo-objects/Placemark.tsx","../src/geo-objects/Polygon.tsx","../src/geo-objects/Polyline.tsx","../src/geo-objects/Rectangle.tsx"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\n/**\n * Helper method to remove keys from the object\n *\n * @param {Object} obj Object to remove keys from\n * @param {string[]} arr List of keys to remove\n * @returns {Object} Object with omitted keys\n */\nexport const omit = (obj, arr) => {\n const res = {};\n for (const n in obj) {\n if (arr.indexOf(n) === -1) res[n] = obj[n];\n }\n return res;\n};\n","import React, { useContext } from 'react';\nimport { ApiLoader } from './util/create-api-loader';\nimport { AnyObject } from './util/typing';\n\nexport const YMapsApiLoaderContext = React.createContext<ApiLoader | null>(\n null\n);\n\nexport const withYMapsContext = <TProps extends AnyObject>(\n Component: React.FC<React.PropsWithChildren<TProps>>\n): React.FC<React.PropsWithChildren<TProps>> => {\n const WithYMapsContext: React.FC<React.PropsWithChildren<TProps>> = (\n props\n ) => (\n <YMapsApiLoaderContext.Consumer>\n {(apiLoader) => {\n if (apiLoader === null) {\n const message =\n \"Couldn't find Yandex.Maps API in the context. \" +\n `Make sure that <${Component.displayName} /> is inside <YMaps /> provider`;\n\n throw new Error(message);\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return <Component apiLoader={apiLoader} {...props} />;\n }}\n </YMapsApiLoaderContext.Consumer>\n );\n\n return WithYMapsContext;\n};\n\nexport const useYMapsApiLoader = () => {\n const apiLoader = useContext(YMapsApiLoaderContext);\n if (apiLoader === null) {\n const message =\n \"Couldn't find Yandex.Maps API in the context. \" +\n `Make sure that hook useYMaps is inside <YMaps /> provider`;\n\n throw new Error(message);\n }\n\n return apiLoader;\n};\n\nexport const ParentContext = React.createContext(null);\n\nexport const withParentContext = <TProps extends AnyObject>(\n Component: React.FC<React.PropsWithChildren<TProps>>\n): React.FC<React.PropsWithChildren<TProps>> => {\n const WithParentContext: React.FC<React.PropsWithChildren<TProps>> = (\n props\n ) => (\n <ParentContext.Consumer>\n {(parent) => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return <Component parent={parent} {...props} />;\n }}\n </ParentContext.Consumer>\n );\n\n return WithParentContext;\n};\n","import { useEffect, useRef, useState } from 'react';\nimport { useYMapsApiLoader } from '../Context';\nimport { YMapsApi } from '../util/typing';\n\n/**\n * Return loaded ymaps instance\n * @param modules\n * @param onError\n */\nexport const useYMaps = (modules: string[] = []): YMapsApi | null => {\n const [loaded, setLoaded] = useState(false);\n const modulesRef = useRef(modules);\n const apiLoader = useYMapsApiLoader();\n const api = apiLoader.getApi();\n\n useEffect(() => {\n apiLoader\n .load()\n .then(() => Promise.all(modulesRef.current.map(apiLoader.loadModule)))\n .then(() => setLoaded(true));\n }, []);\n\n return loaded && api ? api : null;\n};\n","import React, { useEffect } from 'react';\nimport { omit } from '../util/omit';\nimport { AnyObject, YMapsApi, YMapsModules } from '../util/typing';\nimport { ApiLoader } from '../util/create-api-loader';\nimport { useYMaps } from '../hooks/useYMaps';\n\nexport interface WithYMapsProps {\n modules?: YMapsModules;\n width?: string | number;\n height?: string | number;\n onLoad?: (api: YMapsApi) => void;\n}\n\nconst defaultFunction = () => void 0;\nconst omitProps = ['onLoad', 'onError', 'modules', 'apiLoader'];\n\nexport default function withYMaps<TProps extends AnyObject>(\n Component: React.FC<TProps> | React.Component<TProps>,\n waitForApi = false,\n hocModules: YMapsModules = []\n): React.FC<TProps> {\n const WithYMaps: React.FC<WithYMapsProps & { apiLoader: ApiLoader }> = (\n props\n ) => {\n const { width, height, modules = [], onLoad = defaultFunction } = props;\n const ymaps = useYMaps(hocModules.concat(modules));\n const shouldRender = !waitForApi || !!ymaps;\n const newProps = omit(props, omitProps);\n\n useEffect(() => (ymaps ? onLoad(ymaps) : void 0), [ymaps]);\n\n if (!shouldRender) {\n return <div style={{ width, height }} />;\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return <Component ymaps={ymaps} {...newProps} />;\n };\n\n return WithYMaps as unknown as React.FC<React.PropsWithChildren<TProps>>;\n}\n","/**\n * Set value in object by path\n *\n * @param {Object} object Object to set value to\n * @param {string | string[]} path Path to value\n * @param {any} value Value\n * @param {boolean} [ifNotExists] Will skip setting value if value exists\n */\nexport const set = <TValue>(\n object: Record<string, unknown>,\n path: string | string[],\n value: TValue,\n ifNotExists = false\n) => {\n const setPath = typeof path === 'string' ? path.split('.') : path.slice();\n\n let key: string;\n let ref = object;\n\n while (setPath.length > 1) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n key = setPath.shift()!;\n if (!ref[key]) ref[key] = {};\n ref = ref[key] as Record<string, unknown>;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const lastPathKey = setPath[0]!;\n\n ref[lastPathKey] = ifNotExists === true ? ref[lastPathKey] || value : value;\n return object;\n};\n","export const isBrowser = typeof window !== 'undefined';\n","import { set } from './set';\nimport { AnyObject, YMapsApi, YMapsModules } from './typing';\nimport { isDevEnv } from './is-dev-env';\nimport { isBrowser } from './is-browser';\n\ninterface YMapsQuery {\n lang?: 'tr_TR' | 'en_US' | 'en_RU' | 'ru_RU' | 'ru_UA' | 'uk_UA';\n apikey?: string;\n coordorder?: 'latlong' | 'longlat';\n load?: string;\n mode?: 'release' | 'debug';\n csp?: boolean;\n ns?: string;\n}\n\ninterface CreateYMapsLoaderOptions {\n version?: string;\n enterprise?: boolean;\n query?: YMapsQuery;\n preload?: boolean;\n}\n\nexport type ApiLoader = ReturnType<typeof createApiLoader>;\n\nconst YMAPS_ONLOAD = '__yandex-maps-api-onload__';\nconst YMAPS_ONERROR = '__yandex-maps-api-onerror__';\n\nconst YMAPS_DEFAULT_QUERY: YMapsQuery = {\n lang: 'ru_RU',\n load: '',\n ns: '',\n mode: isDevEnv ? 'debug' : 'release',\n};\n\nconst getBaseUrl = (isEnterprise?: boolean) =>\n `https://${isEnterprise ? 'enterprise.' : ''}api-maps.yandex.ru`;\n\nconst fetchScript = (url: string) => {\n return new Promise((resolve, reject) => {\n const script = document.createElement('script');\n\n script.type = 'text/javascript';\n script.onload = resolve;\n script.onerror = reject;\n script.src = url;\n script.async = true;\n\n document.head.appendChild(script);\n });\n};\n\nexport const createApiLoader = (options: CreateYMapsLoaderOptions) => {\n const { query = YMAPS_DEFAULT_QUERY } = options;\n const hash = Date.now().toString(32);\n const namespace = query.ns || '';\n const onload = YMAPS_ONLOAD + '$$' + hash;\n const onerror = YMAPS_ONERROR + '$$' + hash;\n const windowObj: AnyObject = isBrowser ? window : {};\n\n const PROMISES: Record<string, Promise<YMapsApi> | undefined> = {};\n let api: YMapsApi;\n\n const getApi = (): YMapsApi =>\n typeof isBrowser && namespace ? windowObj[namespace] : api;\n\n const loadModule = (moduleName: string): Promise<YMapsApi> => {\n return new Promise((res, rej) => {\n api.modules.require(moduleName).done((modules: YMapsModules[]) => {\n modules.forEach((module) => {\n set(api, moduleName, module, true);\n });\n\n res(api);\n }, rej);\n });\n };\n\n const clearWindow = () => {\n delete windowObj[onload];\n delete windowObj[onerror];\n };\n\n const load = (): Promise<YMapsApi> => {\n if (getApi()) {\n return Promise.resolve(api);\n }\n\n if (PROMISES[namespace]) {\n return PROMISES[namespace] as Promise<YMapsApi>;\n }\n\n const ymapsQuery: Record<string, string | boolean> = {\n onload,\n onerror,\n ...YMAPS_DEFAULT_QUERY,\n ...query,\n };\n\n const queryString = Object.keys(ymapsQuery)\n .map((key) => `${key}=${ymapsQuery[key]}`)\n .join('&');\n\n const baseUrl = getBaseUrl(options.enterprise);\n\n const url = [baseUrl, options.version, '?' + queryString].join('/');\n\n PROMISES[namespace] = new Promise<YMapsApi>((resolve, reject) => {\n windowObj[onload] = (ym: YMapsApi) => {\n clearWindow();\n\n void ym.ready(() => {\n api = ym;\n\n resolve(ym);\n });\n };\n\n windowObj[onerror] = (err: Error) => {\n clearWindow();\n reject(err);\n };\n\n fetchScript(url).catch(windowObj[onerror]);\n });\n\n return PROMISES[namespace] as Promise<YMapsApi>;\n };\n\n return { load, getApi, loadModule };\n};\n","import React, { useEffect, useRef } from 'react';\nimport { YMapsApiLoaderContext } from './Context';\nimport { createApiLoader } from './util/create-api-loader';\n\ninterface YMapProvider {\n version?: string;\n enterprise?: boolean;\n /**\n * Yandex.Maps API avaliable query params\n * https://tech.yandex.com/maps/doc/jsapi/2.1/dg/concepts/load-docpage/\n * Some query params will be omitted in any case because they are used\n * by the library: onload, onerror\n */\n query?: {\n lang?: 'tr_TR' | 'en_US' | 'en_RU' | 'ru_RU' | 'ru_UA' | 'uk_UA';\n apikey?: string;\n suggest_apikey?: string;\n coordorder?: 'latlong' | 'longlat';\n load?: string;\n mode?: 'release' | 'debug';\n csp?: boolean;\n ns?: string;\n };\n /**\n * Allows provider to preload Yandex.Maps API even if\n * there are no map components on the page\n */\n preload?: boolean;\n}\n\nexport const Provider: React.FC<React.PropsWithChildren<YMapProvider>> = (\n props\n) => {\n const {\n version = '2.1',\n enterprise = false,\n query = { lang: 'ru_RU', load: '', ns: '' },\n preload = false,\n children,\n } = props;\n\n const ymapsRef = useRef(\n createApiLoader({ version, enterprise, query, preload })\n );\n\n useEffect(() => {\n if (preload) {\n ymapsRef.current.load();\n }\n }, [ymapsRef.current]);\n\n return (\n <YMapsApiLoaderContext.Provider value={ymapsRef.current}>\n {children}\n </YMapsApiLoaderContext.Provider>\n );\n};\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\nconst EVENTS_REGEX = /^on(?=[A-Z])/;\n\n/**\n * Separates YMaps events from other component props based on prop name\n *\n * @param {Object} props Component props\n * @returns {Object} Separated _event props and other component props\n */\nexport function separateEvents(props) {\n return Object.keys(props).reduce(\n (acc, key) => {\n if (EVENTS_REGEX.test(key)) {\n const eventName = key.replace(EVENTS_REGEX, '').toLowerCase();\n acc._events[eventName] = props[key];\n } else {\n acc[key] = props[key];\n }\n\n return acc;\n },\n { _events: {} }\n );\n}\n\n/**\n * Adds event to YMaps object\n *\n * @param {Object} instance YMaps object instance\n * @param {string} eventName Event name (e.g., \"onclick\", \"ontouchstart\")\n * @param {Function} handler Event handler method\n */\nexport function addEvent(instance, eventName, handler) {\n if (typeof handler === 'function') {\n instance.events.add(eventName, handler);\n }\n}\n\n/**\n * Removes event from YMaps object\n *\n * @param {Object} instance YMaps object instance\n * @param {string} eventName Event name (e.g., \"onclick\", \"ontouchstart\")\n * @param {Function} handler Event handler method\n */\nexport function removeEvent(instance, eventName, handler) {\n if (typeof handler === 'function') {\n instance.events.remove(eventName, handler);\n }\n}\n\n/**\n * Given two objects with new and old events, checks if event was\n * changed and updates it by removing the old one and adding the\n * new one\n *\n * @param {Object} instance YMaps object instance\n * @param {Object} oldEvents Map of old events\n * @param {Object} newEvents Map of new events\n */\nexport function updateEvents(instance, oldEvents, newEvents) {\n Object.keys(Object.assign({}, oldEvents, newEvents)).forEach((eventName) => {\n if (oldEvents[eventName] !== newEvents[eventName]) {\n removeEvent(instance, eventName, oldEvents[eventName]);\n addEvent(instance, eventName, newEvents[eventName]);\n }\n });\n}\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\nconst defaultName = (name) =>\n 'default' + name.charAt(0).toUpperCase() + name.slice(1);\n\n/**\n * Checks if key exists on an object\n *\n * @param {Object} props Component props\n * @param {string} key Prop key\n * @returns {boolean} Check result\n */\nexport function isControlledProp(props, key) {\n return props[key] !== undefined || props[defaultName(key)] === undefined;\n}\n\n/**\n * Checks if prop exists, otherwise returns \"uncontrolled\"\n * prop that starts with default (e.g., defaultValue)\n *\n * @param {Object} props Component props\n * @param {string} key Prop key\n * @param {any} defaultValue\n * @return {any} Prop value\n */\nexport function getProp(props, key, defaultValue) {\n return (\n (isControlledProp(props, key) ? props[key] : props[defaultName(key)]) ||\n defaultValue\n );\n}\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\n/**\n * Mimics React ref behavior. First cleans oldRef, if possible, then applies new ref value\n * https://reactjs.org/docs/refs-and-the-dom.html#caveats-with-callback-refs\n *\n * @param {Object<{current: T}> | Function} oldRef\n * @param {Object<{current: T}> | Function?} newRef\n * @param {T?} value\n */\nexport default function applyRef(oldRef, newRef, value = null) {\n if (oldRef !== newRef) {\n if (oldRef) {\n if ('current' in oldRef) {\n oldRef.current = null;\n } else if (typeof oldRef === 'function') {\n oldRef(null);\n }\n }\n\n if (!newRef) return;\n\n if ('current' in newRef) {\n newRef.current = value;\n } else if (typeof newRef === 'function') {\n newRef(value);\n }\n }\n}\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\n/**\n * Return style object depends on props\n *\n * @param {Object} props Component props\n * @returns {Object} Style object result\n */\nexport default function getParentElementSize(props) {\n const { width, height, style, className } = props;\n\n if (typeof style !== 'undefined' || typeof className !== 'undefined') {\n return Object.assign({}, style && { style }, className && { className });\n }\n\n return { style: { width, height } };\n}\n","import React, { ErrorInfo } from 'react';\nimport { AnyObject } from '../util/typing';\n\nexport interface ErrorBoundaryProps {\n onError?: (err: Error) => void;\n}\n\ninterface ErrorBoundaryState {\n error: Error | null;\n errorInfo: ErrorInfo | null;\n}\n\nclass ErrorBoundary extends React.Component<\n React.PropsWithChildren<ErrorBoundaryProps>,\n ErrorBoundaryState\n> {\n constructor(props: React.PropsWithChildren<ErrorBoundaryProps>) {\n super(props);\n this.state = { error: null, errorInfo: null };\n }\n\n override componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n const { onError = () => void 0 } = this.props;\n\n onError(error);\n\n this.setState({\n error: error,\n errorInfo: errorInfo,\n });\n }\n\n override render() {\n return this.state.error ? null : this.props.children;\n }\n}\n\n/**\n * Prevent map tree crashing if components throw an error\n * @param Component\n */\nexport const withErrorBoundary = <TProps extends AnyObject>(\n Component: React.FC<React.PropsWithChildren<TProps>>\n): React.FC<React.PropsWithChildren<TProps & ErrorBoundaryProps>> => {\n const WithErrorBoundary: React.FC<TProps & ErrorBoundaryProps> = ({\n onError,\n ...props\n }) => {\n return (\n <ErrorBoundary onError={onError}>\n {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}\n {/* @ts-ignore */}\n <Component {...props} />\n </ErrorBoundary>\n );\n };\n\n return WithErrorBoundary;\n};\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\nimport React, { CSSProperties } from 'react';\nimport * as events from './util/events';\nimport { omit } from './util/omit';\nimport { getProp, isControlledProp } from './util/props';\nimport withYMaps, { WithYMapsProps } from './hocs/withYMaps';\nimport { ParentContext } from './Context';\nimport applyRef from './util/ref';\nimport getParentElementSize from './util/getParentElementSize';\nimport ymaps from 'yandex-maps';\nimport { AnyObject, WithInstanceRef } from './util/typing';\nimport {\n ErrorBoundaryProps,\n withErrorBoundary,\n} from './hocs/with-error-boundary';\n\ninterface MapProps {\n /**\n * [Map state parameters](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/Map-docpage/#param-state)\n */\n state?: ymaps.IMapState;\n /**\n * Uncontrolled [Map state parameters](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/Map-docpage/#param-state)\n */\n defaultState?: ymaps.IMapState;\n\n /**\n * [Map options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/Map-docpage/#Map__param-options)\n */\n options?: ymaps.IMapOptions;\n /**\n * Uncontrolled [Map options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/Map-docpage/#Map__param-options)\n */\n defaultOptions?: ymaps.IMapOptions;\n\n /**\n * Yandex.Maps Map parent element should have at least\n * some size set to it, otherwise the map is rendered\n * into the container with size 0\n *\n * To avoid this we will use `width` and `height` props as default\n * way of sizing the map element, but then if we see that\n * the library user also provides `style` or `className` prop,\n * we will assume that the Map is sized by those and will\n * not use these\n */\n\n /**\n * Map container width\n */\n width?: string | number;\n\n /**\n * Map container height\n */\n height?: string | number;\n\n /**\n * Map container style\n */\n style?: CSSProperties;\n\n /**\n * Map container className\n */\n className?: string;\n}\n\nexport class Map extends React.Component<\n MapProps & WithYMapsProps & WithInstanceRef & ErrorBoundaryProps\n> {\n constructor() {\n super();\n this.instance = null;\n this.state = { instance: null };\n this._parentElement = null;\n this._getRef = (ref) => {\n this._parentElement = ref;\n };\n }\n\n componentDidMount() {\n this.instance = Map.mountObject(\n this._parentElement,\n // eslint-disable-next-line react/prop-types\n this.props.ymaps.Map,\n this.props\n );\n\n this.setState({ instance: this.instance });\n }\n\n componentDidUpdate(prevProps) {\n if (this.instance !== null) {\n Map.updateObject(this.instance, prevProps, this.props);\n }\n }\n\n componentWillUnmount() {\n Map.unmountObject(this.instance, this.props);\n }\n\n render() {\n const parentElementStyle = getParentElementSize(this.props);\n const separatedProps = events.separateEvents(this.props);\n\n const parentElementProps = omit(separatedProps, [\n '_events',\n 'state',\n 'defaultState',\n 'options',\n 'defaultOptions',\n 'instanceRef',\n 'ymaps',\n 'children',\n 'width',\n 'height',\n 'style',\n 'className',\n ]);\n\n return (\n <ParentContext.Provider value={this.state.instance}>\n <div ref={this._getRef} {...parentElementStyle} {...parentElementProps}>\n {this.props.children}\n </div>\n </ParentContext.Provider>\n );\n }\n\n static mountObject(parentElement, Map, props) {\n const { instanceRef, _events } = events.separateEvents(props);\n\n const state = getProp(props, 'state');\n const options = getProp(props, 'options');\n\n const instance = new Map(parentElement, state, options);\n\n Object.keys(_events).forEach((key) =>\n events.addEvent(instance, key, _events[key])\n );\n\n applyRef(null, instanceRef, instance);\n\n return instance;\n }\n\n static updateObject(instance, oldProps, newProps) {\n const { _events: newEvents, instanceRef } = events.separateEvents(newProps);\n const { _events: oldEvents, instanceRef: oldRef } =\n events.separateEvents(oldProps);\n\n if (isControlledProp(newProps, 'state')) {\n const oldState = getProp(oldProps, 'state', {});\n const newState = getProp(newProps, 'state', {});\n\n if (oldState.type !== newState.type) {\n instance.setType(newState.type);\n }\n\n if (oldState.behaviors !== newState.behaviors) {\n if (oldState.behaviors) instance.behaviors.disable(oldState.behaviors);\n if (newState.behaviors) instance.behaviors.enable(newState.behaviors);\n }\n\n if (newState.zoom && oldState.zoom !== newState.zoom) {\n instance.setZoom(newState.zoom);\n }\n\n if (newState.center && oldState.center !== newState.center) {\n instance.setCenter(newState.center);\n }\n\n if (newState.bounds && oldState.bounds !== newState.bounds) {\n instance.setBounds(newState.bounds);\n }\n }\n\n if (isControlledProp(newProps, 'options')) {\n const oldOptions = getProp(oldProps, 'options');\n const newOptions = getProp(newProps, 'options', {});\n\n if (oldOptions !== newOptions) {\n instance.options.set(newOptions);\n }\n }\n\n if (\n getProp(oldProps, 'width') !== getProp(newProps, 'width') ||\n getProp(oldProps, 'height') !== getProp(newProps, 'height')\n ) {\n instance.container.fitToViewport();\n }\n\n events.updateEvents(instance, oldEvents, newEvents);\n\n applyRef(oldRef, instanceRef, instance);\n }\n\n static unmountObject(instance, props) {\n const { instanceRef, _events } = events.separateEvents(props);\n\n if (instance !== null) {\n Object.keys(_events).forEach((key) =>\n events.removeEvent(instance, key, _events[key])\n );\n\n instance.destroy();\n\n // Clean used ref\n applyRef(instanceRef);\n }\n }\n}\n\nconst YMapsMap = withErrorBoundary(\n withYMaps<MapProps & WithYMapsProps & WithInstanceRef & AnyObject>(\n Map,\n true,\n ['Map']\n )\n);\n\nexport default YMapsMap;\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\nimport React, { CSSProperties } from 'react';\nimport { getProp, isControlledProp } from './util/props';\nimport withYMaps, { WithYMapsProps } from './hocs/withYMaps';\nimport * as events from './util/events';\nimport applyRef from './util/ref';\nimport getParentElementSize from './util/getParentElementSize';\nimport ymaps from 'yandex-maps';\nimport { AnyObject, WithInstanceRef } from './util/typing';\nimport {\n ErrorBoundaryProps,\n withErrorBoundary,\n} from './hocs/with-error-boundary';\n\ninterface PanoramaOptions {\n autoFitToViewport?: 'none' | 'ifNull' | 'always' | undefined;\n controls?: string[] | undefined;\n direction?: number[] | string | undefined;\n hotkeysEnabled?: boolean | undefined;\n scrollZoomBehavior?: boolean | undefined;\n span?: number[] | string | undefined;\n suppressMapOpenBlock?: boolean | undefined;\n}\n\ninterface PanoramaProps {\n /**\n * [Panorama options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/panorama.Player-docpage/#panorama.Player__param-options)\n */\n options?: PanoramaOptions;\n /**\n * Uncontrolled [Panorama options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/panorama.Player-docpage/#panorama.Player__param-options)\n */\n defaultOptions?: PanoramaOptions;\n\n /**\n * The point for searching for nearby panoramas.\n */\n point?: number[];\n /**\n * Uncontrolled point for searching for nearby panoramas.\n */\n defaultPoint?: number[];\n\n /**\n * Panorama [locate options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/panorama.locate-docpage/#panorama.locate__param-options)\n */\n locateOptions?: { layer: ymaps.panorama.Layer };\n\n /**\n * Yandex.Maps Panorama parent element should have at least\n * some size set to it, otherwise the panorama is rendered\n * into the container with size 0\n *\n * To avoid this we will use `width` and `height` props as default\n * way of sizing the panorama element, but then if we see that\n * the library user also provides `style` or `className` prop,\n * we will assume that the panorama is sized by those and will\n * not use these\n */\n\n /**\n * Panorama container width\n */\n width?: string | number;\n\n /**\n * Panorama container height\n */\n height?: string | number;\n\n /**\n * Panorama container style\n */\n style?: CSSProperties;\n\n /**\n * Panorama container className\n */\n className?: string;\n}\n\nexport class Panorama extends React.Component<\n PanoramaProps & WithYMapsProps & WithInstanceRef & ErrorBoundaryProps\n> {\n constructor() {\n super();\n this.state = { instance: null };\n this._parentElement = null;\n this._getRef = (ref) => {\n this._parentElement = ref;\n };\n }\n\n componentDidMount() {\n this._mounted = true;\n\n // eslint-disable-next-line react/prop-types\n if (!this.props.ymaps.panorama.isSupported()) {\n return;\n }\n\n Panorama.mountObject(\n this._parentElement,\n // eslint-disable-next-line react/prop-types\n this.props.ymaps.panorama,\n this.props\n ).then((instance) => this._mounted && this.setState({ instance }));\n }\n\n componentDidUpdate(prevProps) {\n if (this.state.instance !== null) {\n Panorama.updateObject(this.state.instance, prevProps, this.props);\n }\n }\n\n componentWillUnmount() {\n this._mounted = false;\n Panorama.unmountObject(this.state.instance, this.props);\n }\n\n render() {\n const parentElementStyle = getParentElementSize(this.props);\n\n return <div ref={this._getRef} {...parentElementStyle} />;\n }\n\n static mountObject(parentElement, panorama, props) {\n const { instanceRef, _events } = events.separateEvents(props);\n\n const point = getProp(props, 'point');\n const locateOptions = getProp(props, 'locateOptions');\n const options = getProp(props, 'options');\n\n return new Promise((resolve, reject) => {\n panorama.locate(point, locateOptions).done((panoramas) => {\n if (panoramas.length > 0) {\n const instance = new panorama.Player(\n parentElement,\n panoramas[0],\n options\n );\n\n applyRef(null, instanceRef, instance);\n\n Object.keys(_events).forEach((key) =>\n events.addEvent(instance, key, _events[key])\n );\n\n resolve(instance);\n }\n }, reject);\n });\n }\n\n static updateObject(instance, oldProps, newProps) {\n const { _events: newEvents, instanceRef } = events.separateEvents(newProps);\n const { _events: oldEvents, instanceRef: oldRef } =\n events.separateEvents(oldProps);\n\n if (isControlledProp(newProps, 'options')) {\n const oldOptions = getProp(oldProps, 'options');\n const newOptions = getProp(newProps, 'options');\n\n if (oldOptions !== newOptions) {\n instance.options.set(newOptions);\n }\n }\n\n if (isControlledProp(newProps, 'point')) {\n const point = getProp(newProps, 'point');\n const oldPoint = getProp(oldProps, 'point');\n const locateOptions = getProp(newProps, 'locateOptions');\n\n if (point !== oldPoint) {\n instance.moveTo(point, locateOptions);\n }\n }\n\n events.updateEvents(instance, oldEvents, newEvents);\n\n applyRef(oldRef, instanceRef, instance);\n }\n\n static unmountObject(instance, props) {\n const { instanceRef, _events } = events.separateEvents(props);\n\n if (instance !== null) {\n Object.keys(_events).forEach((key) =>\n events.removeEvent(instance, key, _events[key])\n );\n\n // Clean used ref\n applyRef(instanceRef);\n }\n }\n}\n\nconst YMapsPanorama = withErrorBoundary(\n withYMaps<PanoramaProps & WithYMapsProps & WithInstanceRef & AnyObject>(\n Panorama,\n true,\n [\n 'panorama.isSupported',\n 'panorama.locate',\n 'panorama.createPlayer',\n 'panorama.Player',\n ]\n )\n);\n\nexport default YMapsPanorama;\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\nimport React from 'react';\n\nimport * as events from '../util/events';\nimport { getProp, isControlledProp } from '../util/props';\nimport { ParentContext } from '../Context';\nimport applyRef from '../util/ref';\nimport { AnyObject, WithInstanceRef } from '../util/typing';\n\nexport interface BaseControlProps {\n /** Parent object (e.g, ymaps.Map or ymaps.Clusterer) */\n parent?: AnyObject;\n\n /** Control name */\n name: Required<\n | 'Button'\n | 'FullscreenControl'\n | 'GeolocationControl'\n | 'ListBox'\n | 'ListBoxItem'\n | 'RouteButton'\n | 'RouteEditor'\n | 'RoutePanel'\n | 'RulerControl'\n | 'SearchControl'\n | 'TrafficControl'\n | 'TypeSelector'\n | 'ZoomControl'\n >;\n}\n\nexport class BaseControl extends React.Component<\n BaseControlProps & WithInstanceRef\n> {\n constructor() {\n super();\n this.state = { instance: null };\n this.instance = null;\n }\n\n componentDidMount() {\n const instance = BaseControl.mountControl(\n this.props.ymaps.control[this.props.name],\n this.props\n );\n\n this.instance = instance;\n this.setState({ instance });\n }\n\n componentDidUpdate(prevProps) {\n if (this.instance !== null) {\n BaseControl.updateControl(this.instance, prevProps, this.props);\n }\n }\n\n componentWillUnmount() {\n BaseControl.unmountControl(this.instance, this.props);\n }\n\n render() {\n return (\n <ParentContext.Provider value={this.state.instance}>\n {this.props.children}\n </ParentContext.Provider>\n );\n }\n\n static mountControl(Control, props) {\n const { instanceRef, parent, lazy, _events } = events.separateEvents(props);\n\n const data = getProp(props, 'data');\n const options = getProp(props, 'options');\n const state = getProp(props, 'state');\n const mapTypes = getProp(props, 'mapTypes');\n\n const instance = new Control({ data, options, state, mapTypes, lazy });\n\n Object.keys(_events).forEach((key) =>\n events.addEvent(instance, key, _events[key])\n );\n\n if (\n parent &&\n parent.controls &&\n typeof parent.controls.add === 'function'\n ) {\n parent.controls.add(instance);\n } else if (parent && parent.add && typeof parent.add === 'function') {\n parent.add(instance);\n } else {\n throw new Error(`No parent found to mount ${props.name}`);\n }\n\n applyRef(null, instanceRef, instance);\n\n return instance;\n }\n\n static updateControl(instance, oldProps, newProps) {\n const { _events: newEvents, instanceRef } = events.separateEvents(newProps);\n const { _events: oldEvents, instanceRef: oldRef } =\n events.separateEvents(oldProps);\n\n if (isControlledProp(newProps, 'options')) {\n const oldOptions = getProp(oldProps, 'options');\n const newOptions = getProp(newProps, 'options');\n\n if (oldOptions !== newOptions) {\n instance.options.set(newOptions);\n }\n }\n\n if (isControlledProp(newProps, 'data')) {\n const oldData = getProp(oldProps, 'data');\n const newData = getProp(newProps, 'data');\n\n if (oldData !== newData) {\n instance.data.set(newData);\n }\n }\n\n if (isControlledProp(newProps, 'state')) {\n const oldState = getProp(oldProps, 'state');\n const newState = getProp(newProps, 'state');\n\n if (oldState !== newState) {\n instance.state.set(newState);\n }\n }\n\n if (isControlledProp(newProps, 'mapTypes')) {\n const oldMapTypes = getProp(oldProps, 'mapTypes');\n const newMapTypes = getProp(newProps, 'mapTypes');\n\n if (oldMapTypes !== newMapTypes) {\n instance.removeAllMapTypes();\n newMapTypes.forEach((type) => instance.addMapType(type));\n }\n }\n\n events.updateEvents(instance, oldEvents, newEvents);\n\n applyRef(oldRef, instanceRef, instance);\n }\n\n static unmountControl(instance, props) {\n const { instanceRef, parent, _events } = events.separateEvents(props);\n\n if (instance !== null) {\n Object.keys(_events).forEach((key) =>\n events.removeEvent(instance, key, _events[key])\n );\n\n if (parent.controls && typeof parent.controls.remove === 'function') {\n parent.controls.remove(instance);\n } else if (parent.remove && typeof parent.remove === 'function') {\n parent.remove(instance);\n }\n\n applyRef(instanceRef);\n }\n }\n}\n","import React from 'react';\n\nimport { withParentContext } from '../Context';\nimport withYMaps, { WithYMapsProps } from '../hocs/withYMaps';\n\nimport { BaseControl, BaseControlProps } from './BaseControl';\nimport { control } from 'yandex-maps';\nimport { AnyObject, WithInstanceRef } from '../util/typing';\nimport {\n ErrorBoundaryProps,\n withErrorBoundary,\n} from '../hocs/with-error-boundary';\n\ninterface ButtonProps extends Omit<BaseControlProps, 'name'> {\n /**\n * Control [data](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.Button-docpage/#control.Button__param-parameters.data)\n */\n data?: control.IButtonParameters['data'];\n /**\n * Uncontrolled control [data](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.Button-docpage/#control.Button__param-parameters.data)\n */\n defaultData?: control.IButtonParameters['data'];\n /**\n * Control [options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.Button-docpage/#control.Button__param-parameters.options)\n */\n options?: control.IButtonParameters['options'];\n /**\n * Uncontrolled control [options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.Button-docpage/#control.Button__param-parameters.options)\n */\n defaultOptions?: control.IButtonParameters['options'];\n /**\n * Control [state](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.Button-docpage/#control.Button__param-parameters.state)\n */\n state?: control.IButtonParameters['state'];\n /**\n * Uncontrolled control [state](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.Button-docpage/#control.Button__param-parameters.state)\n */\n defaultState?: control.IButtonParameters['state'];\n}\n\nexport const Button: React.FC<\n React.PropsWithChildren<\n ButtonProps &\n WithYMapsProps &\n WithInstanceRef &\n ErrorBoundaryProps &\n AnyObject\n >\n> = (props) => {\n return <BaseControl {...props} name=\"Button\" />;\n};\n\nexport default withErrorBoundary(\n withParentContext(withYMaps(Button, true, [`control.Button`]))\n);\n","import React from 'react';\n\nimport { withParentContext } from '../Context';\nimport withYMaps, { WithYMapsProps } from '../hocs/withYMaps';\n\nimport { BaseControl, BaseControlProps } from './BaseControl';\nimport { control, IDataManager } from 'yandex-maps';\nimport { AnyObject, WithInstanceRef } from '../util/typing';\nimport {\n ErrorBoundaryProps,\n withErrorBoundary,\n} from '../hocs/with-error-boundary';\n\ninterface FullscreenControlProps extends Omit<BaseControlProps, 'name'> {\n /**\n * Control [data](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.FullscreenControl-docpage/#control.FullscreenControl__param-parameters.data)\n */\n data?: control.IFullscreenControlParameters['data'];\n /**\n * Uncontrolled control [data](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.FullscreenControl-docpage/#control.FullscreenControl__param-parameters.data)\n */\n defaultData?: control.IFullscreenControlParameters['data'];\n /**\n * Control [options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.FullscreenControl-docpage/#control.FullscreenControl__param-parameters.options)\n */\n options?: control.IFullscreenControlParameters['options'];\n /**\n * Uncontrolled control [options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.FullscreenControl-docpage/#control.FullscreenControl__param-parameters.options)\n */\n defaultOptions?: control.IFullscreenControlParameters['options'];\n /**\n * Control [state](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.FullscreenControl-docpage/#control.FullscreenControl__param-parameters.state)\n */\n state?: IDataManager;\n /**\n * Uncontrolled control [state](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.FullscreenControl-docpage/#control.FullscreenControl__param-parameters.state)\n */\n defaultState?: IDataManager;\n}\n\nexport const FullscreenControl: React.FC<\n React.PropsWithChildren<\n FullscreenControlProps &\n WithYMapsProps &\n WithInstanceRef &\n ErrorBoundaryProps &\n AnyObject\n >\n> = (props) => {\n return <BaseControl {...props} name=\"FullscreenControl\" />;\n};\n\nexport default withErrorBoundary(\n withParentContext(\n withYMaps(FullscreenControl, true, [`control.FullscreenControl`])\n )\n);\n","import React from 'react';\n\nimport { withParentContext } from '../Context';\nimport withYMaps, { WithYMapsProps } from '../hocs/withYMaps';\n\nimport { BaseControl, BaseControlProps } from './BaseControl';\nimport { control } from 'yandex-maps';\nimport { AnyObject, WithInstanceRef } from '../util/typing';\nimport {\n ErrorBoundaryProps,\n withErrorBoundary,\n} from '../hocs/with-error-boundary';\n\ninterface GeolocationControlProps extends Omit<BaseControlProps, 'name'> {\n /**\n * Control [data](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.GeolocationControl-docpage/#control.GeolocationControl__param-parameters.data)\n */\n data?: control.IGeolocationControlParameters['data'];\n /**\n * Uncontrolled control [data](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.GeolocationControl-docpage/#control.GeolocationControl__param-parameters.data)\n */\n defaultData?: control.IGeolocationControlParameters['data'];\n /**\n * Control [options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.GeolocationControl-docpage/#control.GeolocationControl__param-parameters.options)\n */\n options?: control.IGeolocationControlParameters['options'];\n /**\n * Uncontrolled control [options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.GeolocationControl-docpage/#control.GeolocationControl__param-parameters.options)\n */\n defaultOptions?: control.IGeolocationControlParameters['options'];\n /**\n * Control [state](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.GeolocationControl-docpage/#control.GeolocationControl__param-parameters.state)\n */\n state?: control.IGeolocationControlParameters['state'];\n /**\n * Uncontrolled control [state](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.GeolocationControl-docpage/#control.GeolocationControl__param-parameters.state)\n */\n defaultState?: control.IGeolocationControlParameters['state'];\n}\n\nexport const GeolocationControl: React.FC<\n React.PropsWithChildren<\n GeolocationControlProps &\n WithYMapsProps &\n WithInstanceRef &\n ErrorBoundaryProps &\n AnyObject\n >\n> = (props) => {\n return <BaseControl {...props} name=\"GeolocationControl\" />;\n};\n\nexport default withErrorBoundary(\n withParentContext(\n withYMaps(GeolocationControl, true, [`control.GeolocationControl`])\n )\n);\n","import React from 'react';\n\nimport { withParentContext } from '../Context';\nimport withYMaps, { WithYMapsProps } from '../hocs/withYMaps';\n\nimport { BaseControl, BaseControlProps } from './BaseControl';\nimport { control } from 'yandex-maps';\nimport { AnyObject, WithInstanceRef } from '../util/typing';\nimport {\n ErrorBoundaryProps,\n withErrorBoundary,\n} from '../hocs/with-error-boundary';\n\ninterface ListBoxProps extends Omit<BaseControlProps, 'name'> {\n /**\n * Control [data](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.ListBox-docpage/#control.ListBox__param-parameters.data)\n */\n data?: control.IListBoxParameters['data'];\n /**\n * Uncontrolled control [data](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.ListBox-docpage/#control.ListBox__param-parameters.data)\n */\n defaultData?: control.IListBoxParameters['data'];\n\n /**\n * Control [options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.ListBox-docpage/#control.ListBox__param-parameters.options)\n */\n options?: control.IListBoxParameters['options'];\n /**\n * Uncontrolled control [options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.ListBox-docpage/#control.ListBox__param-parameters.options)\n */\n defaultOptions?: control.IListBoxParameters['options'];\n\n /**\n * Control [state](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.ListBox-docpage/#control.ListBox__param-parameters.state)\n */\n state?: control.IListBoxParameters['state'];\n /**\n * Uncontrolled control [state](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.ListBox-docpage/#control.ListBox__param-parameters.state)\n */\n defaultState?: control.IListBoxParameters['state'];\n}\n\nexport const ListBox: React.FC<\n React.PropsWithChildren<\n ListBoxProps &\n WithYMapsProps &\n WithInstanceRef &\n ErrorBoundaryProps &\n AnyObject\n >\n> = (props) => {\n return <BaseControl {...props} name=\"ListBox\" />;\n};\n\nexport default withErrorBoundary(\n withParentContext(withYMaps(ListBox, true, [`control.ListBox`]))\n);\n","import React from 'react';\n\nimport { withParentContext } from '../Context';\nimport withYMaps, { WithYMapsProps } from '../hocs/withYMaps';\n\nimport { BaseControl } from './BaseControl';\nimport { control } from 'yandex-maps';\nimport { AnyObject, WithInstanceRef } from '../util/typing';\nimport {\n ErrorBoundaryProps,\n withErrorBoundary,\n} from '../hocs/with-error-boundary';\n\ninterface ListBoxItemProps {\n /**\n * Control [data](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.ListBoxItem-docpage/#control.ListBoxItem__param-parameters.data)\n */\n data?: control.IListBoxItemParameters['data'];\n /**\n * Uncontrolled control [data](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.ListBoxItem-docpage/#control.ListBoxItem__param-parameters.data)\n */\n defaultData?: control.IListBoxItemParameters['data'];\n /**\n * Control [options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.ListBoxItem-docpage/#control.ListBoxItem__param-parameters.options)\n */\n options?: control.IListBoxItemParameters['options'];\n /**\n * Uncontrolled control [options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.ListBoxItem-docpage/#control.ListBoxItem__param-parameters.options)\n */\n defaultOptions?: control.IListBoxItemParameters['options'];\n /**\n * Control [state](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.ListBoxItem-docpage/#control.ListBoxItem__param-parameters.state)\n */\n state?: control.IListBoxItemParameters['state'];\n /**\n * Uncontrolled control [state](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.ListBoxItem-docpage/#control.ListBoxItem__param-parameters.state)\n */\n defaultState?: control.IListBoxItemParameters['state'];\n}\n\nexport const ListBoxItem: React.FC<\n React.PropsWithChildren<\n ListBoxItemProps &\n WithYMapsProps &\n WithInstanceRef &\n ErrorBoundaryProps &\n AnyObject\n >\n> = (props) => {\n return <BaseControl {...props} name=\"ListBoxItem\" />;\n};\n\nexport default withErrorBoundary(\n withParentContext(withYMaps(ListBoxItem, true, [`control.ListBoxItem`]))\n);\n","import React from 'react';\n\nimport { withParentContext } from '../Context';\nimport withYMaps, { WithYMapsProps } from '../hocs/withYMaps';\n\nimport { BaseControl, BaseControlProps } from './BaseControl';\nimport { control } from 'yandex-maps';\nimport { AnyObject, WithInstanceRef } from '../util/typing';\nimport {\n ErrorBoundaryProps,\n withErrorBoundary,\n} from '../hocs/with-error-boundary';\n\ninterface RouteButtonProps extends Omit<BaseControlProps, 'name'> {\n /**\n * Control [options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.RouteButton-docpage/#control.RouteButton__param-parameters.options)\n */\n options?: control.IRouteButtonParameters['options'];\n /**\n * Uncontrolled control [options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.RouteButton-docpage/#control.RouteButton__param-parameters.options)\n */\n defaultOptions?: control.IRouteButtonParameters['options'];\n /**\n * Control [state](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.RouteButton-docpage/#control.RouteButton__param-parameters.state)\n */\n state?: control.IRouteButtonParameters['state'];\n /**\n * Uncontrolled control [state](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.RouteButton-docpage/#control.RouteButton__param-parameters.state)\n */\n defaultState?: control.IRouteButtonParameters['state'];\n}\n\nexport const RouteButton: React.FC<\n React.PropsWithChildren<\n RouteButtonProps &\n WithYMapsProps &\n WithInstanceRef &\n ErrorBoundaryProps &\n AnyObject\n >\n> = (props) => {\n return <BaseControl {...props} name=\"RouteButton\" />;\n};\n\nexport default withErrorBoundary(\n withParentContext(withYMaps(RouteButton, true, [`control.RouteButton`]))\n);\n","import React from 'react';\n\nimport { withParentContext } from '../Context';\nimport withYMaps, { WithYMapsProps } from '../hocs/withYMaps';\n\nimport { BaseControl, BaseControlProps } from './BaseControl';\nimport { control } from 'yandex-maps';\nimport { AnyObject, WithInstanceRef } from '../util/typing';\nimport {\n ErrorBoundaryProps,\n withErrorBoundary,\n} from '../hocs/with-error-boundary';\n\ninterface RouteEditorProps extends Omit<BaseControlProps, 'name'> {\n /**\n * Control [data](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.RouteEditor-docpage/#control.RouteEditor__param-parameters.data)\n */\n data?: control.IRouteEditorParameters['data'];\n /**\n * Uncontrolled control [data](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.RouteEditor-docpage/#control.RouteEditor__param-parameters.data)\n */\n defaultData?: control.IRouteEditorParameters['data'];\n /**\n * Control [options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.RouteEditor-docpage/#control.RouteEditor__param-parameters.options)\n */\n options?: control.IRouteEditorParameters['options'];\n /**\n * Uncontrolled control [options](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.RouteEditor-docpage/#control.RouteEditor__param-parameters.options)\n */\n defaultOptions?: control.IRouteEditorParameters['options'];\n /**\n * Control [state](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.RouteEditor-docpage/#control.RouteEditor__param-parameters.state)\n */\n state?: control.IRouteEditorParameters['state'];\n /**\n * Uncontrolled control [state](https://tech.yandex.com/maps/doc/jsapi/2.1/ref/reference/control.RouteEditor-docpage/#control.RouteEditor__param-parameters.state)\n */\n defaultState?: control.IRouteEditorParameters['state'];\n}\n\nexport const RouteEditor: React.FC<\n React.PropsWithChildren<\n RouteEditorProps &\n WithYMapsProps &\n WithInstanceRef &\n ErrorBoundaryProps &\n AnyObject\n >\n> = (props) => {\n return <BaseControl {...props} name=\"RouteEditor\" />;\n};\n\nexport default withErrorBoundary(\n withParentContext(withYMaps(RouteEditor, true, [`control.Route