Files
flights_web_raw/ClientApp/node_modules/react-leaflet/lib/SVGOverlay.js
T
gnezim 0a5ab058a6 Initial commit: Aeroflot Flights Web - Angular 12 baseline
- Angular 12 application with PrimeNG components
- 5 existing Cypress e2e test suites
- SCSS styling with BEM naming convention
- i18n support (10 languages)
- Leaflet map integration
- Complete component hierarchy and routing structure

This baseline will be used for Angular → React migration.
2026-04-05 18:47:57 +03:00

24 lines
1.3 KiB
JavaScript

import { createElementHook, createElementObject, createLayerHook, updateMediaOverlay } from '@react-leaflet/core';
import { SVGOverlay as LeafletSVGOverlay } from 'leaflet';
import { forwardRef, useImperativeHandle } from 'react';
import { createPortal } from 'react-dom';
export const useSVGOverlayElement = createElementHook(function createSVGOverlay(props, context) {
const { attributes , bounds , ...options } = props;
const container = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
container.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
if (attributes != null) {
Object.keys(attributes).forEach((name)=>{
container.setAttribute(name, attributes[name]);
});
}
const overlay = new LeafletSVGOverlay(container, bounds, options);
return createElementObject(overlay, context, container);
}, updateMediaOverlay);
export const useSVGOverlay = createLayerHook(useSVGOverlayElement);
function SVGOverlayComponent({ children , ...options }, forwardedRef) {
const { instance , container } = useSVGOverlay(options).current;
useImperativeHandle(forwardedRef, ()=>instance);
return container == null || children == null ? null : /*#__PURE__*/ createPortal(children, container);
}
export const SVGOverlay = /*#__PURE__*/ forwardRef(SVGOverlayComponent);