This commit is contained in:
2025-09-11 07:45:47 -07:00
parent 955946e79d
commit a9425720e9
2759 changed files with 0 additions and 294955 deletions

View File

@@ -1,43 +0,0 @@
react-leaflet Copyright 2020 Paul Le Cam and contributors (“Licensor”)
Hippocratic License Version Number: 2.1.
Purpose. The purpose of this License is for the Licensor named above to permit the Licensee (as defined below) broad permission, if consistent with Human Rights Laws and Human Rights Principles (as each is defined below), to use and work with the Software (as defined below) within the full scope of Licensors copyright and patent rights, if any, in the Software, while ensuring attribution and protecting the Licensor from liability.
Permission and Conditions. The Licensor grants permission by this license (“License”), free of charge, to the extent of Licensors rights under applicable copyright and patent law, to any person or entity (the “Licensee”) obtaining a copy of this software and associated documentation files (the “Software”), to do everything with the Software that would otherwise infringe (i) the Licensors copyright in the Software or (ii) any patent claims to the Software that the Licensor can license or becomes able to license, subject to all of the following terms and conditions:
- Acceptance. This License is automatically offered to every person and entity subject to its terms and conditions. Licensee accepts this License and agrees to its terms and conditions by taking any action with the Software that, absent this License, would infringe any intellectual property right held by Licensor.
- Notice. Licensee must ensure that everyone who gets a copy of any part of this Software from Licensee, with or without changes, also receives the License and the above copyright notice (and if included by the Licensor, patent, trademark and attribution notice). Licensee must cause any modified versions of the Software to carry prominent notices stating that Licensee changed the Software. For clarity, although Licensee is free to create modifications of the Software and distribute only the modified portion created by Licensee with additional or different terms, the portion of the Software not modified must be distributed pursuant to this License. If anyone notifies Licensee in writing that Licensee has not complied with this Notice section, Licensee can keep this License by taking all practical steps to comply within 30 days after the notice. If Licensee does not do so, Licensees License (and all rights licensed hereunder) shall end immediately.
- Compliance with Human Rights Principles and Human Rights Laws.
1. Human Rights Principles.
(a) Licensee is advised to consult the articles of the United Nations Universal Declaration of Human Rights and the United Nations Global Compact that define recognized principles of international human rights (the “Human Rights Principles”). Licensee shall use the Software in a manner consistent with Human Rights Principles.
(b) Unless the Licensor and Licensee agree otherwise, any dispute, controversy, or claim arising out of or relating to (i) Section 1(a) regarding Human Rights Principles, including the breach of Section 1(a), termination of this License for breach of the Human Rights Principles, or invalidity of Section 1(a) or (ii) a determination of whether any Law is consistent or in conflict with Human Rights Principles pursuant to Section 2, below, shall be settled by arbitration in accordance with the Hague Rules on Business and Human Rights Arbitration (the “Rules”); provided, however, that Licensee may elect not to participate in such arbitration, in which event this License (and all rights licensed hereunder) shall end immediately. The number of arbitrators shall be one unless the Rules require otherwise.
Unless both the Licensor and Licensee agree to the contrary: (1) All documents and information concerning the arbitration shall be public and may be disclosed by any party; (2) The repository referred to under Article 43 of the Rules shall make available to the public in a timely manner all documents concerning the arbitration which are communicated to it, including all submissions of the parties, all evidence admitted into the record of the proceedings, all transcripts or other recordings of hearings and all orders, decisions and awards of the arbitral tribunal, subject only to the arbitral tribunal's powers to take such measures as may be necessary to safeguard the integrity of the arbitral process pursuant to Articles 18, 33, 41 and 42 of the Rules; and (3) Article 26(6) of the Rules shall not apply.
2. Human Rights Laws. The Software shall not be used by any person or entity for any systems, activities, or other uses that violate any Human Rights Laws. “Human Rights Laws” means any applicable laws, regulations, or rules (collectively, “Laws”) that protect human, civil, labor, privacy, political, environmental, security, economic, due process, or similar rights; provided, however, that such Laws are consistent and not in conflict with Human Rights Principles (a dispute over the consistency or a conflict between Laws and Human Rights Principles shall be determined by arbitration as stated above). Where the Human Rights Laws of more than one jurisdiction are applicable or in conflict with respect to the use of the Software, the Human Rights Laws that are most protective of the individuals or groups harmed shall apply.
3. Indemnity. Licensee shall hold harmless and indemnify Licensor (and any other contributor) against all losses, damages, liabilities, deficiencies, claims, actions, judgments, settlements, interest, awards, penalties, fines, costs, or expenses of whatever kind, including Licensors reasonable attorneys fees, arising out of or relating to Licensees use of the Software in violation of Human Rights Laws or Human Rights Principles.
- Failure to Comply. Any failure of Licensee to act according to the terms and conditions of this License is both a breach of the License and an infringement of the intellectual property rights of the Licensor (subject to exceptions under Laws, e.g., fair use). In the event of a breach or infringement, the terms and conditions of this License may be enforced by Licensor under the Laws of any jurisdiction to which Licensee is subject. Licensee also agrees that the Licensor may enforce the terms and conditions of this License against Licensee through specific performance (or similar remedy under Laws) to the extent permitted by Laws. For clarity, except in the event of a breach of this License, infringement, or as otherwise stated in this License, Licensor may not terminate this License with Licensee.
- Enforceability and Interpretation. If any term or provision of this License is determined to be invalid, illegal, or unenforceable by a court of competent jurisdiction, then such invalidity, illegality, or unenforceability shall not affect any other term or provision of this License or invalidate or render unenforceable such term or provision in any other jurisdiction; provided, however, subject to a court modification pursuant to the immediately following sentence, if any term or provision of this License pertaining to Human Rights Laws or Human Rights Principles is deemed invalid, illegal, or unenforceable against Licensee by a court of competent jurisdiction, all rights in the Software granted to Licensee shall be deemed null and void as between Licensor and Licensee. Upon a determination that any term or provision is invalid, illegal, or unenforceable, to the extent permitted by Laws, the court may modify this License to affect the original purpose that the Software be used in compliance with Human Rights Principles and Human Rights Laws as closely as possible. The language in this License shall be interpreted as to its fair meaning and not strictly for or against any party.
- Disclaimer. TO THE FULL EXTENT ALLOWED BY LAW, THIS SOFTWARE COMES “AS IS,” WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED, AND LICENSOR AND ANY OTHER CONTRIBUTOR SHALL NOT BE LIABLE TO ANYONE FOR ANY DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THIS LICENSE, UNDER ANY KIND OF LEGAL CLAIM.
This Hippocratic License is an Ethical Source license (https://ethicalsource.dev) and is offered for use by licensors and licensees at their own risk, on an “AS IS” basis, and with no warranties express or implied, to the maximum extent permitted by Laws.
Some portions of code from previous versions of react-leaflet are released under the MIT License (MIT):
Copyright (c) 2015-2020 Paul Le Cam and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,3 +0,0 @@
# React Leaflet
[Documentation](https://react-leaflet.js.org/)

View File

@@ -1,4 +0,0 @@
/// <reference types="react" />
import { Control } from 'leaflet';
export type AttributionControlProps = Control.AttributionOptions;
export declare const AttributionControl: import("react").ForwardRefExoticComponent<Control.AttributionOptions & import("react").RefAttributes<Control.Attribution>>;

View File

@@ -1,5 +0,0 @@
import { createControlComponent } from '@react-leaflet/core';
import { Control } from 'leaflet';
export const AttributionControl = createControlComponent(function createAttributionControl(props) {
return new Control.Attribution(props);
});

View File

@@ -1,5 +0,0 @@
/// <reference types="react" />
import { type CircleProps } from '@react-leaflet/core';
import { Circle as LeafletCircle } from 'leaflet';
export type { CircleProps } from '@react-leaflet/core';
export declare const Circle: import("react").ForwardRefExoticComponent<CircleProps & import("react").RefAttributes<LeafletCircle<any>>>;

View File

@@ -1,8 +0,0 @@
import { createElementObject, createPathComponent, extendContext, updateCircle } from '@react-leaflet/core';
import { Circle as LeafletCircle } from 'leaflet';
export const Circle = createPathComponent(function createCircle({ center , children: _c , ...options }, ctx) {
const circle = new LeafletCircle(center, options);
return createElementObject(circle, extendContext(ctx, {
overlayContainer: circle
}));
}, updateCircle);

View File

@@ -1,5 +0,0 @@
/// <reference types="react" />
import { type CircleMarkerProps } from '@react-leaflet/core';
import { CircleMarker as LeafletCircleMarker } from 'leaflet';
export type { CircleMarkerProps } from '@react-leaflet/core';
export declare const CircleMarker: import("react").ForwardRefExoticComponent<CircleMarkerProps & import("react").RefAttributes<LeafletCircleMarker<any>>>;

View File

@@ -1,8 +0,0 @@
import { createElementObject, createPathComponent, extendContext, updateCircle } from '@react-leaflet/core';
import { CircleMarker as LeafletCircleMarker } from 'leaflet';
export const CircleMarker = createPathComponent(function createCircleMarker({ center , children: _c , ...options }, ctx) {
const marker = new LeafletCircleMarker(center, options);
return createElementObject(marker, extendContext(ctx, {
overlayContainer: marker
}));
}, updateCircle);

View File

@@ -1,7 +0,0 @@
/// <reference types="react" />
import { type PathProps } from '@react-leaflet/core';
import { FeatureGroup as LeafletFeatureGroup } from 'leaflet';
import type { LayerGroupProps } from './LayerGroup.js';
export interface FeatureGroupProps extends LayerGroupProps, PathProps {
}
export declare const FeatureGroup: import("react").ForwardRefExoticComponent<FeatureGroupProps & import("react").RefAttributes<LeafletFeatureGroup<any>>>;

View File

@@ -1,9 +0,0 @@
import { createElementObject, createPathComponent, extendContext } from '@react-leaflet/core';
import { FeatureGroup as LeafletFeatureGroup } from 'leaflet';
export const FeatureGroup = createPathComponent(function createFeatureGroup({ children: _c , ...options }, ctx) {
const group = new LeafletFeatureGroup([], options);
return createElementObject(group, extendContext(ctx, {
layerContainer: group,
overlayContainer: group
}));
});

View File

@@ -1,9 +0,0 @@
/// <reference types="react" />
import { type PathProps } from '@react-leaflet/core';
import type { GeoJsonObject } from 'geojson';
import { GeoJSON as LeafletGeoJSON, type GeoJSONOptions } from 'leaflet';
import type { LayerGroupProps } from './LayerGroup.js';
export interface GeoJSONProps extends GeoJSONOptions, LayerGroupProps, PathProps {
data: GeoJsonObject;
}
export declare const GeoJSON: import("react").ForwardRefExoticComponent<GeoJSONProps & import("react").RefAttributes<LeafletGeoJSON<any, import("geojson").Geometry>>>;

View File

@@ -1,16 +0,0 @@
import { createElementObject, createPathComponent, extendContext } from '@react-leaflet/core';
import { GeoJSON as LeafletGeoJSON } from 'leaflet';
export const GeoJSON = createPathComponent(function createGeoJSON({ data , ...options }, ctx) {
const geoJSON = new LeafletGeoJSON(data, options);
return createElementObject(geoJSON, extendContext(ctx, {
overlayContainer: geoJSON
}));
}, function updateGeoJSON(layer, props, prevProps) {
if (props.style !== prevProps.style) {
if (props.style == null) {
layer.resetStyle();
} else {
layer.setStyle(props.style);
}
}
});

View File

@@ -1,8 +0,0 @@
import { type MediaOverlayProps } from '@react-leaflet/core';
import { ImageOverlay as LeafletImageOverlay } from 'leaflet';
import type { ReactNode } from 'react';
export interface ImageOverlayProps extends MediaOverlayProps {
children?: ReactNode;
url: string;
}
export declare const ImageOverlay: import("react").ForwardRefExoticComponent<ImageOverlayProps & import("react").RefAttributes<LeafletImageOverlay>>;

View File

@@ -1,17 +0,0 @@
import { createElementObject, createLayerComponent, extendContext, updateMediaOverlay } from '@react-leaflet/core';
import { LatLngBounds, ImageOverlay as LeafletImageOverlay } from 'leaflet';
export const ImageOverlay = createLayerComponent(function createImageOveraly({ bounds , url , ...options }, ctx) {
const overlay = new LeafletImageOverlay(url, bounds, options);
return createElementObject(overlay, extendContext(ctx, {
overlayContainer: overlay
}));
}, function updateImageOverlay(overlay, props, prevProps) {
updateMediaOverlay(overlay, props, prevProps);
if (props.bounds !== prevProps.bounds) {
const bounds = props.bounds instanceof LatLngBounds ? props.bounds : new LatLngBounds(props.bounds);
overlay.setBounds(bounds);
}
if (props.url !== prevProps.url) {
overlay.setUrl(props.url);
}
});

View File

@@ -1,7 +0,0 @@
import { type EventedProps } from '@react-leaflet/core';
import { LayerGroup as LeafletLayerGroup, type LayerOptions } from 'leaflet';
import type { ReactNode } from 'react';
export interface LayerGroupProps extends LayerOptions, EventedProps {
children?: ReactNode;
}
export declare const LayerGroup: import("react").ForwardRefExoticComponent<LayerGroupProps & import("react").RefAttributes<LeafletLayerGroup<any>>>;

View File

@@ -1,8 +0,0 @@
import { createElementObject, createLayerComponent, extendContext } from '@react-leaflet/core';
import { LayerGroup as LeafletLayerGroup } from 'leaflet';
export const LayerGroup = createLayerComponent(function createLayerGroup({ children: _c , ...options }, ctx) {
const group = new LeafletLayerGroup([], options);
return createElementObject(group, extendContext(ctx, {
layerContainer: group
}));
});

View File

@@ -1,48 +0,0 @@
import { Control, type Layer } from 'leaflet';
import React, { type ForwardRefExoticComponent, type FunctionComponent, type ReactNode, type RefAttributes } from 'react';
export interface LayersControlProps extends Control.LayersOptions {
children?: ReactNode;
}
export declare const useLayersControlElement: (props: LayersControlProps, context: Readonly<{
__version: number;
map: import("leaflet").Map;
layerContainer?: import("leaflet").LayerGroup<any> | import("@react-leaflet/core/lib/context").ControlledLayer | undefined;
layersControl?: Control.Layers | undefined;
overlayContainer?: Layer | undefined;
pane?: string | undefined;
}>) => React.MutableRefObject<Readonly<{
instance: Control.Layers;
context: Readonly<{
__version: number;
map: import("leaflet").Map;
layerContainer?: import("leaflet").LayerGroup<any> | import("@react-leaflet/core/lib/context").ControlledLayer | undefined;
layersControl?: Control.Layers | undefined;
overlayContainer?: Layer | undefined;
pane?: string | undefined;
}>;
container?: any;
}>>;
export declare const useLayersControl: (props: LayersControlProps) => React.MutableRefObject<Readonly<{
instance: Control.Layers;
context: Readonly<{
__version: number;
map: import("leaflet").Map;
layerContainer?: import("leaflet").LayerGroup<any> | import("@react-leaflet/core/lib/context").ControlledLayer | undefined;
layersControl?: Control.Layers | undefined;
overlayContainer?: Layer | undefined;
pane?: string | undefined;
}>;
container?: any;
}>>;
export interface ControlledLayerProps {
checked?: boolean;
children: ReactNode;
name: string;
}
export declare const LayersControl: ForwardRefExoticComponent<LayersControlProps & RefAttributes<Control.Layers>> & {
BaseLayer: FunctionComponent<ControlledLayerProps>;
Overlay: FunctionComponent<ControlledLayerProps>;
};
type AddLayerFunc = (layersControl: Control.Layers, layer: Layer, name: string) => void;
export declare function createControlledLayer(addLayerToControl: AddLayerFunc): (props: ControlledLayerProps) => JSX.Element | null;
export {};

View File

@@ -1,77 +0,0 @@
import { LeafletProvider, createContainerComponent, createControlHook, createElementHook, createElementObject, extendContext, useLeafletContext } from '@react-leaflet/core';
import { Control } from 'leaflet';
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
export const useLayersControlElement = createElementHook(function createLayersControl({ children: _c , ...options }, ctx) {
const control = new Control.Layers(undefined, undefined, options);
return createElementObject(control, extendContext(ctx, {
layersControl: control
}));
}, function updateLayersControl(control, props, prevProps) {
if (props.collapsed !== prevProps.collapsed) {
if (props.collapsed === true) {
control.collapse();
} else {
control.expand();
}
}
});
export const useLayersControl = createControlHook(useLayersControlElement);
// @ts-ignore
export const LayersControl = createContainerComponent(useLayersControl);
export function createControlledLayer(addLayerToControl) {
return function ControlledLayer(props) {
const parentContext = useLeafletContext();
const propsRef = useRef(props);
const [layer, setLayer] = useState(null);
const { layersControl , map } = parentContext;
const addLayer = useCallback((layerToAdd)=>{
if (layersControl != null) {
if (propsRef.current.checked) {
map.addLayer(layerToAdd);
}
addLayerToControl(layersControl, layerToAdd, propsRef.current.name);
setLayer(layerToAdd);
}
}, [
layersControl,
map
]);
const removeLayer = useCallback((layerToRemove)=>{
layersControl?.removeLayer(layerToRemove);
setLayer(null);
}, [
layersControl
]);
const context = useMemo(()=>{
return extendContext(parentContext, {
layerContainer: {
addLayer,
removeLayer
}
});
}, [
parentContext,
addLayer,
removeLayer
]);
useEffect(()=>{
if (layer !== null && propsRef.current !== props) {
if (props.checked === true && (propsRef.current.checked == null || propsRef.current.checked === false)) {
map.addLayer(layer);
} else if (propsRef.current.checked === true && (props.checked == null || props.checked === false)) {
map.removeLayer(layer);
}
propsRef.current = props;
}
});
return props.children ? /*#__PURE__*/ React.createElement(LeafletProvider, {
value: context
}, props.children) : null;
};
}
LayersControl.BaseLayer = createControlledLayer(function addBaseLayer(layersControl, layer, name) {
layersControl.addBaseLayer(layer, name);
});
LayersControl.Overlay = createControlledLayer(function addOverlay(layersControl, layer, name) {
layersControl.addOverlay(layer, name);
});

View File

@@ -1,13 +0,0 @@
import { type FitBoundsOptions, type LatLngBoundsExpression, Map as LeafletMap, type MapOptions } from 'leaflet';
import React, { type CSSProperties, type ReactNode } from 'react';
export interface MapContainerProps extends MapOptions {
bounds?: LatLngBoundsExpression;
boundsOptions?: FitBoundsOptions;
children?: ReactNode;
className?: string;
id?: string;
placeholder?: ReactNode;
style?: CSSProperties;
whenReady?: () => void;
}
export declare const MapContainer: React.ForwardRefExoticComponent<MapContainerProps & React.RefAttributes<LeafletMap>>;

View File

@@ -1,57 +0,0 @@
function _extends() {
_extends = Object.assign || function(target) {
for(var i = 1; i < arguments.length; i++){
var source = arguments[i];
for(var key in source){
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
import { LeafletProvider, createLeafletContext } from '@react-leaflet/core';
import { Map as LeafletMap } from 'leaflet';
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useState } from 'react';
function MapContainerComponent({ bounds , boundsOptions , center , children , className , id , placeholder , style , whenReady , zoom , ...options }, forwardedRef) {
const [props] = useState({
className,
id,
style
});
const [context, setContext] = useState(null);
useImperativeHandle(forwardedRef, ()=>context?.map ?? null, [
context
]);
const mapRef = useCallback((node)=>{
if (node !== null && context === null) {
const map = new LeafletMap(node, options);
if (center != null && zoom != null) {
map.setView(center, zoom);
} else if (bounds != null) {
map.fitBounds(bounds, boundsOptions);
}
if (whenReady != null) {
map.whenReady(whenReady);
}
setContext(createLeafletContext(map));
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useEffect(()=>{
return ()=>{
context?.map.remove();
};
}, [
context
]);
const contents = context ? /*#__PURE__*/ React.createElement(LeafletProvider, {
value: context
}, children) : placeholder ?? null;
return /*#__PURE__*/ React.createElement("div", _extends({}, props, {
ref: mapRef
}), contents);
}
export const MapContainer = /*#__PURE__*/ forwardRef(MapContainerComponent);

View File

@@ -1,8 +0,0 @@
import { type EventedProps } from '@react-leaflet/core';
import { type LatLngExpression, Marker as LeafletMarker, type MarkerOptions } from 'leaflet';
import type { ReactNode } from 'react';
export interface MarkerProps extends MarkerOptions, EventedProps {
children?: ReactNode;
position: LatLngExpression;
}
export declare const Marker: import("react").ForwardRefExoticComponent<MarkerProps & import("react").RefAttributes<LeafletMarker<any>>>;

View File

@@ -1,28 +0,0 @@
import { createElementObject, createLayerComponent, extendContext } from '@react-leaflet/core';
import { Marker as LeafletMarker } from 'leaflet';
export const Marker = createLayerComponent(function createMarker({ position , ...options }, ctx) {
const marker = new LeafletMarker(position, options);
return createElementObject(marker, extendContext(ctx, {
overlayContainer: marker
}));
}, function updateMarker(marker, props, prevProps) {
if (props.position !== prevProps.position) {
marker.setLatLng(props.position);
}
if (props.icon != null && props.icon !== prevProps.icon) {
marker.setIcon(props.icon);
}
if (props.zIndexOffset != null && props.zIndexOffset !== prevProps.zIndexOffset) {
marker.setZIndexOffset(props.zIndexOffset);
}
if (props.opacity != null && props.opacity !== prevProps.opacity) {
marker.setOpacity(props.opacity);
}
if (marker.dragging != null && props.draggable !== prevProps.draggable) {
if (props.draggable === true) {
marker.dragging.enable();
} else {
marker.dragging.disable();
}
}
});

View File

@@ -1,9 +0,0 @@
import React, { type CSSProperties, type ReactNode } from 'react';
export interface PaneProps {
children?: ReactNode;
className?: string;
name: string;
pane?: string;
style?: CSSProperties;
}
export declare const Pane: React.ForwardRefExoticComponent<PaneProps & React.RefAttributes<HTMLElement>>;

View File

@@ -1,72 +0,0 @@
import { LeafletProvider, addClassName, useLeafletContext } from '@react-leaflet/core';
import React, { forwardRef, useState, useEffect, useImperativeHandle, useMemo } from 'react';
import { createPortal } from 'react-dom';
const DEFAULT_PANES = [
'mapPane',
'markerPane',
'overlayPane',
'popupPane',
'shadowPane',
'tilePane',
'tooltipPane'
];
function omitPane(obj, pane) {
const { [pane]: _p , ...others } = obj;
return others;
}
function createPane(name, props, context) {
if (DEFAULT_PANES.indexOf(name) !== -1) {
throw new Error(`You must use a unique name for a pane that is not a default Leaflet pane: ${name}`);
}
if (context.map.getPane(name) != null) {
throw new Error(`A pane with this name already exists: ${name}`);
}
const parentPaneName = props.pane ?? context.pane;
const parentPane = parentPaneName ? context.map.getPane(parentPaneName) : undefined;
const element = context.map.createPane(name, parentPane);
if (props.className != null) {
addClassName(element, props.className);
}
if (props.style != null) {
Object.keys(props.style).forEach((key)=>{
// @ts-ignore
element.style[key] = props.style[key];
});
}
return element;
}
function PaneComponent(props, forwardedRef) {
const [paneName] = useState(props.name);
const [paneElement, setPaneElement] = useState(null);
useImperativeHandle(forwardedRef, ()=>paneElement, [
paneElement
]);
const context = useLeafletContext();
// eslint-disable-next-line react-hooks/exhaustive-deps
const newContext = useMemo(()=>({
...context,
pane: paneName
}), [
context
]);
useEffect(()=>{
setPaneElement(createPane(paneName, props, context));
return function removeCreatedPane() {
const pane = context.map.getPane(paneName);
pane?.remove?.();
// @ts-ignore map internals
if (context.map._panes != null) {
// @ts-ignore map internals
context.map._panes = omitPane(context.map._panes, paneName);
// @ts-ignore map internals
context.map._paneRenderers = omitPane(// @ts-ignore map internals
context.map._paneRenderers, paneName);
}
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return props.children != null && paneElement != null ? /*#__PURE__*/ createPortal(/*#__PURE__*/ React.createElement(LeafletProvider, {
value: newContext
}, props.children), paneElement) : null;
}
export const Pane = /*#__PURE__*/ forwardRef(PaneComponent);

View File

@@ -1,8 +0,0 @@
import { type PathProps } from '@react-leaflet/core';
import { type LatLngExpression, type PolylineOptions, Polygon as LeafletPolygon } from 'leaflet';
import type { ReactNode } from 'react';
export interface PolygonProps extends PolylineOptions, PathProps {
children?: ReactNode;
positions: LatLngExpression[] | LatLngExpression[][] | LatLngExpression[][][];
}
export declare const Polygon: import("react").ForwardRefExoticComponent<PolygonProps & import("react").RefAttributes<LeafletPolygon<any>>>;

View File

@@ -1,12 +0,0 @@
import { createElementObject, createPathComponent, extendContext } from '@react-leaflet/core';
import { Polygon as LeafletPolygon } from 'leaflet';
export const Polygon = createPathComponent(function createPolygon({ positions , ...options }, ctx) {
const polygon = new LeafletPolygon(positions, options);
return createElementObject(polygon, extendContext(ctx, {
overlayContainer: polygon
}));
}, function updatePolygon(layer, props, prevProps) {
if (props.positions !== prevProps.positions) {
layer.setLatLngs(props.positions);
}
});

View File

@@ -1,8 +0,0 @@
import { type PathProps } from '@react-leaflet/core';
import { type LatLngExpression, Polyline as LeafletPolyline, type PolylineOptions } from 'leaflet';
import type { ReactNode } from 'react';
export interface PolylineProps extends PolylineOptions, PathProps {
children?: ReactNode;
positions: LatLngExpression[] | LatLngExpression[][];
}
export declare const Polyline: import("react").ForwardRefExoticComponent<PolylineProps & import("react").RefAttributes<LeafletPolyline<import("geojson").LineString | import("geojson").MultiLineString, any>>>;

View File

@@ -1,12 +0,0 @@
import { createElementObject, createPathComponent, extendContext } from '@react-leaflet/core';
import { Polyline as LeafletPolyline } from 'leaflet';
export const Polyline = createPathComponent(function createPolyline({ positions , ...options }, ctx) {
const polyline = new LeafletPolyline(positions, options);
return createElementObject(polyline, extendContext(ctx, {
overlayContainer: polyline
}));
}, function updatePolyline(layer, props, prevProps) {
if (props.positions !== prevProps.positions) {
layer.setLatLngs(props.positions);
}
});

View File

@@ -1,8 +0,0 @@
import { type EventedProps } from '@react-leaflet/core';
import { type LatLngExpression, Popup as LeafletPopup, type PopupOptions } from 'leaflet';
import { type ReactNode } from 'react';
export interface PopupProps extends PopupOptions, EventedProps {
children?: ReactNode;
position?: LatLngExpression;
}
export declare const Popup: import("react").ForwardRefExoticComponent<PopupProps & import("react").RefAttributes<LeafletPopup>>;

View File

@@ -1,49 +0,0 @@
import { createElementObject, createOverlayComponent } from '@react-leaflet/core';
import { Popup as LeafletPopup } from 'leaflet';
import { useEffect } from 'react';
export const Popup = createOverlayComponent(function createPopup(props, context) {
const popup = new LeafletPopup(props, context.overlayContainer);
return createElementObject(popup, context);
}, function usePopupLifecycle(element, context, { position }, setOpen) {
useEffect(function addPopup() {
const { instance } = element;
function onPopupOpen(event) {
if (event.popup === instance) {
instance.update();
setOpen(true);
}
}
function onPopupClose(event) {
if (event.popup === instance) {
setOpen(false);
}
}
context.map.on({
popupopen: onPopupOpen,
popupclose: onPopupClose
});
if (context.overlayContainer == null) {
// Attach to a Map
if (position != null) {
instance.setLatLng(position);
}
instance.openOn(context.map);
} else {
// Attach to container component
context.overlayContainer.bindPopup(instance);
}
return function removePopup() {
context.map.off({
popupopen: onPopupOpen,
popupclose: onPopupClose
});
context.overlayContainer?.unbindPopup();
context.map.removeLayer(instance);
};
}, [
element,
context,
setOpen,
position
]);
});

View File

@@ -1,8 +0,0 @@
import { type PathProps } from '@react-leaflet/core';
import { type LatLngBoundsExpression, Rectangle as LeafletRectangle, type PathOptions } from 'leaflet';
import type { ReactNode } from 'react';
export interface RectangleProps extends PathOptions, PathProps {
bounds: LatLngBoundsExpression;
children?: ReactNode;
}
export declare const Rectangle: import("react").ForwardRefExoticComponent<RectangleProps & import("react").RefAttributes<LeafletRectangle<any>>>;

View File

@@ -1,12 +0,0 @@
import { createElementObject, createPathComponent, extendContext } from '@react-leaflet/core';
import { Rectangle as LeafletRectangle } from 'leaflet';
export const Rectangle = createPathComponent(function createRectangle({ bounds , ...options }, ctx) {
const rectangle = new LeafletRectangle(bounds, options);
return createElementObject(rectangle, extendContext(ctx, {
overlayContainer: rectangle
}));
}, function updateRectangle(layer, props, prevProps) {
if (props.bounds !== prevProps.bounds) {
layer.setBounds(props.bounds);
}
});

View File

@@ -1,39 +0,0 @@
import { type MediaOverlayProps } from '@react-leaflet/core';
import { SVGOverlay as LeafletSVGOverlay } from 'leaflet';
import { type ReactNode } from 'react';
export interface SVGOverlayProps extends MediaOverlayProps {
attributes?: Record<string, string>;
children?: ReactNode;
}
export declare const useSVGOverlayElement: (props: SVGOverlayProps, context: Readonly<{
__version: number;
map: import("leaflet").Map;
layerContainer?: import("leaflet").LayerGroup<any> | import("@react-leaflet/core/lib/context").ControlledLayer | undefined;
layersControl?: import("leaflet").Control.Layers | undefined;
overlayContainer?: import("leaflet").Layer | undefined;
pane?: string | undefined;
}>) => import("react").MutableRefObject<Readonly<{
instance: LeafletSVGOverlay;
context: Readonly<{
__version: number;
map: import("leaflet").Map;
layerContainer?: import("leaflet").LayerGroup<any> | import("@react-leaflet/core/lib/context").ControlledLayer | undefined;
layersControl?: import("leaflet").Control.Layers | undefined;
overlayContainer?: import("leaflet").Layer | undefined;
pane?: string | undefined;
}>;
container?: any;
}>>;
export declare const useSVGOverlay: (props: SVGOverlayProps) => import("react").MutableRefObject<Readonly<{
instance: LeafletSVGOverlay;
context: Readonly<{
__version: number;
map: import("leaflet").Map;
layerContainer?: import("leaflet").LayerGroup<any> | import("@react-leaflet/core/lib/context").ControlledLayer | undefined;
layersControl?: import("leaflet").Control.Layers | undefined;
overlayContainer?: import("leaflet").Layer | undefined;
pane?: string | undefined;
}>;
container?: any;
}>>;
export declare const SVGOverlay: import("react").ForwardRefExoticComponent<SVGOverlayProps & import("react").RefAttributes<LeafletSVGOverlay>>;

View File

@@ -1,23 +0,0 @@
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);

View File

@@ -1,4 +0,0 @@
/// <reference types="react" />
import { Control } from 'leaflet';
export type ScaleControlProps = Control.ScaleOptions;
export declare const ScaleControl: import("react").ForwardRefExoticComponent<Control.ScaleOptions & import("react").RefAttributes<Control.Scale>>;

View File

@@ -1,5 +0,0 @@
import { createControlComponent } from '@react-leaflet/core';
import { Control } from 'leaflet';
export const ScaleControl = createControlComponent(function createScaleControl(props) {
return new Control.Scale(props);
});

View File

@@ -1,7 +0,0 @@
/// <reference types="react" />
import { type LayerProps } from '@react-leaflet/core';
import { TileLayer as LeafletTileLayer, type TileLayerOptions } from 'leaflet';
export interface TileLayerProps extends TileLayerOptions, LayerProps {
url: string;
}
export declare const TileLayer: import("react").ForwardRefExoticComponent<TileLayerProps & import("react").RefAttributes<LeafletTileLayer>>;

View File

@@ -1,12 +0,0 @@
import { createElementObject, createTileLayerComponent, updateGridLayer, withPane } from '@react-leaflet/core';
import { TileLayer as LeafletTileLayer } from 'leaflet';
export const TileLayer = createTileLayerComponent(function createTileLayer({ url , ...options }, context) {
const layer = new LeafletTileLayer(url, withPane(options, context));
return createElementObject(layer, context);
}, function updateTileLayer(layer, props, prevProps) {
updateGridLayer(layer, props, prevProps);
const { url } = props;
if (url != null && url !== prevProps.url) {
layer.setUrl(url);
}
});

View File

@@ -1,8 +0,0 @@
import { type EventedProps } from '@react-leaflet/core';
import { type LatLngExpression, Tooltip as LeafletTooltip, type TooltipOptions } from 'leaflet';
import { type ReactNode } from 'react';
export interface TooltipProps extends TooltipOptions, EventedProps {
children?: ReactNode;
position?: LatLngExpression;
}
export declare const Tooltip: import("react").ForwardRefExoticComponent<TooltipProps & import("react").RefAttributes<LeafletTooltip>>;

View File

@@ -1,49 +0,0 @@
import { createElementObject, createOverlayComponent } from '@react-leaflet/core';
import { Tooltip as LeafletTooltip } from 'leaflet';
import { useEffect } from 'react';
export const Tooltip = createOverlayComponent(function createTooltip(props, context) {
const tooltip = new LeafletTooltip(props, context.overlayContainer);
return createElementObject(tooltip, context);
}, function useTooltipLifecycle(element, context, { position }, setOpen) {
useEffect(function addTooltip() {
const container = context.overlayContainer;
if (container == null) {
return;
}
const { instance } = element;
const onTooltipOpen = (event)=>{
if (event.tooltip === instance) {
if (position != null) {
instance.setLatLng(position);
}
instance.update();
setOpen(true);
}
};
const onTooltipClose = (event)=>{
if (event.tooltip === instance) {
setOpen(false);
}
};
container.on({
tooltipopen: onTooltipOpen,
tooltipclose: onTooltipClose
});
container.bindTooltip(instance);
return function removeTooltip() {
container.off({
tooltipopen: onTooltipOpen,
tooltipclose: onTooltipClose
});
// @ts-ignore protected property
if (container._map != null) {
container.unbindTooltip();
}
};
}, [
element,
context,
setOpen,
position
]);
});

View File

@@ -1,9 +0,0 @@
import { type MediaOverlayProps } from '@react-leaflet/core';
import { VideoOverlay as LeafletVideoOverlay, type VideoOverlayOptions } from 'leaflet';
import type { ReactNode } from 'react';
export interface VideoOverlayProps extends MediaOverlayProps, VideoOverlayOptions {
children?: ReactNode;
play?: boolean;
url: string | string[] | HTMLVideoElement;
}
export declare const VideoOverlay: import("react").ForwardRefExoticComponent<VideoOverlayProps & import("react").RefAttributes<LeafletVideoOverlay>>;

View File

@@ -1,24 +0,0 @@
import { createElementObject, createLayerComponent, extendContext, updateMediaOverlay } from '@react-leaflet/core';
import { VideoOverlay as LeafletVideoOverlay } from 'leaflet';
export const VideoOverlay = createLayerComponent(function createVideoOverlay({ bounds , url , ...options }, ctx) {
const overlay = new LeafletVideoOverlay(url, bounds, options);
if (options.play === true) {
overlay.getElement()?.play();
}
return createElementObject(overlay, extendContext(ctx, {
overlayContainer: overlay
}));
}, function updateVideoOverlay(overlay, props, prevProps) {
updateMediaOverlay(overlay, props, prevProps);
if (typeof props.url === 'string' && props.url !== prevProps.url) {
overlay.setUrl(props.url);
}
const video = overlay.getElement();
if (video != null) {
if (props.play === true && !prevProps.play) {
video.play();
} else if (!props.play && prevProps.play === true) {
video.pause();
}
}
});

View File

@@ -1,8 +0,0 @@
/// <reference types="react" />
import { type LayerProps } from '@react-leaflet/core';
import { TileLayer, type WMSOptions, type WMSParams } from 'leaflet';
export interface WMSTileLayerProps extends WMSOptions, LayerProps {
params?: WMSParams;
url: string;
}
export declare const WMSTileLayer: import("react").ForwardRefExoticComponent<WMSTileLayerProps & import("react").RefAttributes<TileLayer.WMS>>;

View File

@@ -1,14 +0,0 @@
import { createElementObject, createTileLayerComponent, updateGridLayer, withPane } from '@react-leaflet/core';
import { TileLayer } from 'leaflet';
export const WMSTileLayer = createTileLayerComponent(function createWMSTileLayer({ eventHandlers: _eh , params ={} , url , ...options }, context) {
const layer = new TileLayer.WMS(url, {
...params,
...withPane(options, context)
});
return createElementObject(layer, context);
}, function updateWMSTileLayer(layer, props, prevProps) {
updateGridLayer(layer, props, prevProps);
if (props.params != null && props.params !== prevProps.params) {
layer.setParams(props.params);
}
});

View File

@@ -1,4 +0,0 @@
/// <reference types="react" />
import { Control } from 'leaflet';
export type ZoomControlProps = Control.ZoomOptions;
export declare const ZoomControl: import("react").ForwardRefExoticComponent<Control.ZoomOptions & import("react").RefAttributes<Control.Zoom>>;

View File

@@ -1,5 +0,0 @@
import { createControlComponent } from '@react-leaflet/core';
import { Control } from 'leaflet';
export const ZoomControl = createControlComponent(function createZoomControl(props) {
return new Control.Zoom(props);
});

View File

@@ -1,4 +0,0 @@
import type { LeafletEventHandlerFnMap, Map } from 'leaflet';
export declare function useMap(): Map;
export declare function useMapEvent<T extends keyof LeafletEventHandlerFnMap>(type: T, handler: LeafletEventHandlerFnMap[T]): Map;
export declare function useMapEvents(handlers: LeafletEventHandlerFnMap): Map;

View File

@@ -1,34 +0,0 @@
import { useLeafletContext } from '@react-leaflet/core';
import { useEffect } from 'react';
export function useMap() {
return useLeafletContext().map;
}
export function useMapEvent(type, handler) {
const map = useMap();
useEffect(function addMapEventHandler() {
// @ts-ignore event type
map.on(type, handler);
return function removeMapEventHandler() {
// @ts-ignore event type
map.off(type, handler);
};
}, [
map,
type,
handler
]);
return map;
}
export function useMapEvents(handlers) {
const map = useMap();
useEffect(function addMapEventHandlers() {
map.on(handlers);
return function removeMapEventHandlers() {
map.off(handlers);
};
}, [
map,
handlers
]);
return map;
}

View File

@@ -1,23 +0,0 @@
export { useMap, useMapEvent, useMapEvents } from './hooks.js';
export { AttributionControl, type AttributionControlProps, } from './AttributionControl.js';
export { Circle, type CircleProps } from './Circle.js';
export { CircleMarker, type CircleMarkerProps } from './CircleMarker.js';
export { FeatureGroup, type FeatureGroupProps } from './FeatureGroup.js';
export { GeoJSON, type GeoJSONProps } from './GeoJSON.js';
export { ImageOverlay, type ImageOverlayProps } from './ImageOverlay.js';
export { LayerGroup, type LayerGroupProps } from './LayerGroup.js';
export { LayersControl, type LayersControlProps, type ControlledLayerProps, } from './LayersControl.js';
export { MapContainer, type MapContainerProps } from './MapContainer.js';
export { Marker, type MarkerProps } from './Marker.js';
export { Pane, type PaneProps } from './Pane.js';
export { Polygon, type PolygonProps } from './Polygon.js';
export { Polyline, type PolylineProps } from './Polyline.js';
export { Popup, type PopupProps } from './Popup.js';
export { Rectangle, type RectangleProps } from './Rectangle.js';
export { ScaleControl, type ScaleControlProps } from './ScaleControl.js';
export { SVGOverlay, type SVGOverlayProps } from './SVGOverlay.js';
export { TileLayer, type TileLayerProps } from './TileLayer.js';
export { Tooltip, type TooltipProps } from './Tooltip.js';
export { VideoOverlay, type VideoOverlayProps } from './VideoOverlay.js';
export { WMSTileLayer, type WMSTileLayerProps } from './WMSTileLayer.js';
export { ZoomControl, type ZoomControlProps } from './ZoomControl.js';

View File

@@ -1,23 +0,0 @@
export { useMap, useMapEvent, useMapEvents } from './hooks.js';
export { AttributionControl } from './AttributionControl.js';
export { Circle } from './Circle.js';
export { CircleMarker } from './CircleMarker.js';
export { FeatureGroup } from './FeatureGroup.js';
export { GeoJSON } from './GeoJSON.js';
export { ImageOverlay } from './ImageOverlay.js';
export { LayerGroup } from './LayerGroup.js';
export { LayersControl } from './LayersControl.js';
export { MapContainer } from './MapContainer.js';
export { Marker } from './Marker.js';
export { Pane } from './Pane.js';
export { Polygon } from './Polygon.js';
export { Polyline } from './Polyline.js';
export { Popup } from './Popup.js';
export { Rectangle } from './Rectangle.js';
export { ScaleControl } from './ScaleControl.js';
export { SVGOverlay } from './SVGOverlay.js';
export { TileLayer } from './TileLayer.js';
export { Tooltip } from './Tooltip.js';
export { VideoOverlay } from './VideoOverlay.js';
export { WMSTileLayer } from './WMSTileLayer.js';
export { ZoomControl } from './ZoomControl.js';

View File

@@ -1,72 +0,0 @@
{
"name": "react-leaflet",
"version": "4.2.1",
"description": "React components for Leaflet maps",
"repository": {
"type": "git",
"url": "https://github.com/PaulLeCam/react-leaflet.git"
},
"keywords": [
"react-component",
"react",
"leaflet",
"map"
],
"author": "Paul Le Cam <paul@ulem.net>",
"license": "Hippocratic-2.1",
"bugs": {
"url": "https://github.com/PaulLeCam/react-leaflet/issues"
},
"homepage": "https://react-leaflet.js.org",
"type": "module",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"exports": {
".": "./lib/index.js",
"./*": "./lib/*.js"
},
"files": [
"lib/*"
],
"sideEffects": false,
"dependencies": {
"@react-leaflet/core": "^2.1.0"
},
"peerDependencies": {
"leaflet": "^1.9.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"devDependencies": {
"@types/geojson": "^7946.0.10",
"@types/leaflet": "^1.9.1",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11"
},
"jest": {
"extensionsToTreatAsEsm": [
".ts",
".tsx"
],
"resolver": "ts-jest-resolver",
"testEnvironment": "jsdom",
"transform": {
"^.+\\.(t|j)sx?$": [
"@swc/jest",
{
"root": "../.."
}
]
}
},
"scripts": {
"build:clean": "del lib",
"build:js": "swc src -d ./lib --config-file ../../.swcrc",
"build:types": "tsc --emitDeclarationOnly",
"build": "pnpm run build:clean && pnpm run build:types && pnpm run build:js",
"test:types": "tsc --noEmit",
"test:unit": "cross-env NODE_ENV=test jest",
"test": "pnpm run test:types && pnpm run test:unit",
"start": "pnpm run test && pnpm run build"
}
}