DieselDepot-APP/node_modules/@react-leaflet/core/lib/path.js
SJCoetz 34608475cb feat: add depot map integration
Add Leaflet and react-leaflet dependencies for interactive map functionality
Extend DDDepot type with optional latitude/longitude fields for map markers
Update site metadata and admin settings page text
Add client-side DepotMap component to render depot locations
Update PocketBase admin token in environment configuration
2026-07-20 12:31:18 +02:00

28 lines
1 KiB
JavaScript

import { useEffect, useRef } from 'react';
import { useLeafletContext } from './context.js';
import { useEventHandlers } from './events.js';
import { useLayerLifecycle } from './layer.js';
import { withPane } from './pane.js';
export function usePathOptions(element, props) {
const optionsRef = useRef();
useEffect(function updatePathOptions() {
if (props.pathOptions !== optionsRef.current) {
const options = props.pathOptions ?? {};
element.instance.setStyle(options);
optionsRef.current = options;
}
}, [
element,
props
]);
}
export function createPathHook(useElement) {
return function usePath(props) {
const context = useLeafletContext();
const elementRef = useElement(withPane(props, context), context);
useEventHandlers(elementRef.current, props.eventHandlers);
useLayerLifecycle(elementRef.current, context);
usePathOptions(elementRef.current, props);
return elementRef;
};
}